pdf.combined.js 1.3 MB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617166181661916620166211662216623166241662516626166271662816629166301663116632166331663416635166361663716638166391664016641166421664316644166451664616647166481664916650166511665216653166541665516656166571665816659166601666116662166631666416665166661666716668166691667016671166721667316674166751667616677166781667916680166811668216683166841668516686166871668816689166901669116692166931669416695166961669716698166991670016701167021670316704167051670616707167081670916710167111671216713167141671516716167171671816719167201672116722167231672416725167261672716728167291673016731167321673316734167351673616737167381673916740167411674216743167441674516746167471674816749167501675116752167531675416755167561675716758167591676016761167621676316764167651676616767167681676916770167711677216773167741677516776167771677816779167801678116782167831678416785167861678716788167891679016791167921679316794167951679616797167981679916800168011680216803168041680516806168071680816809168101681116812168131681416815168161681716818168191682016821168221682316824168251682616827168281682916830168311683216833168341683516836168371683816839168401684116842168431684416845168461684716848168491685016851168521685316854168551685616857168581685916860168611686216863168641686516866168671686816869168701687116872168731687416875168761687716878168791688016881168821688316884168851688616887168881688916890168911689216893168941689516896168971689816899169001690116902169031690416905169061690716908169091691016911169121691316914169151691616917169181691916920169211692216923169241692516926169271692816929169301693116932169331693416935169361693716938169391694016941169421694316944169451694616947169481694916950169511695216953169541695516956169571695816959169601696116962169631696416965169661696716968169691697016971169721697316974169751697616977169781697916980169811698216983169841698516986169871698816989169901699116992169931699416995169961699716998169991700017001170021700317004170051700617007170081700917010170111701217013170141701517016170171701817019170201702117022170231702417025170261702717028170291703017031170321703317034170351703617037170381703917040170411704217043170441704517046170471704817049170501705117052170531705417055170561705717058170591706017061170621706317064170651706617067170681706917070170711707217073170741707517076170771707817079170801708117082170831708417085170861708717088170891709017091170921709317094170951709617097170981709917100171011710217103171041710517106171071710817109171101711117112171131711417115171161711717118171191712017121171221712317124171251712617127171281712917130171311713217133171341713517136171371713817139171401714117142171431714417145171461714717148171491715017151171521715317154171551715617157171581715917160171611716217163171641716517166171671716817169171701717117172171731717417175171761717717178171791718017181171821718317184171851718617187171881718917190171911719217193171941719517196171971719817199172001720117202172031720417205172061720717208172091721017211172121721317214172151721617217172181721917220172211722217223172241722517226172271722817229172301723117232172331723417235172361723717238172391724017241172421724317244172451724617247172481724917250172511725217253172541725517256172571725817259172601726117262172631726417265172661726717268172691727017271172721727317274172751727617277172781727917280172811728217283172841728517286172871728817289172901729117292172931729417295172961729717298172991730017301173021730317304173051730617307173081730917310173111731217313173141731517316173171731817319173201732117322173231732417325173261732717328173291733017331173321733317334173351733617337173381733917340173411734217343173441734517346173471734817349173501735117352173531735417355173561735717358173591736017361173621736317364173651736617367173681736917370173711737217373173741737517376173771737817379173801738117382173831738417385173861738717388173891739017391173921739317394173951739617397173981739917400174011740217403174041740517406174071740817409174101741117412174131741417415174161741717418174191742017421174221742317424174251742617427174281742917430174311743217433174341743517436174371743817439174401744117442174431744417445174461744717448174491745017451174521745317454174551745617457174581745917460174611746217463174641746517466174671746817469174701747117472174731747417475174761747717478174791748017481174821748317484174851748617487174881748917490174911749217493174941749517496174971749817499175001750117502175031750417505175061750717508175091751017511175121751317514175151751617517175181751917520175211752217523175241752517526175271752817529175301753117532175331753417535175361753717538175391754017541175421754317544175451754617547175481754917550175511755217553175541755517556175571755817559175601756117562175631756417565175661756717568175691757017571175721757317574175751757617577175781757917580175811758217583175841758517586175871758817589175901759117592175931759417595175961759717598175991760017601176021760317604176051760617607176081760917610176111761217613176141761517616176171761817619176201762117622176231762417625176261762717628176291763017631176321763317634176351763617637176381763917640176411764217643176441764517646176471764817649176501765117652176531765417655176561765717658176591766017661176621766317664176651766617667176681766917670176711767217673176741767517676176771767817679176801768117682176831768417685176861768717688176891769017691176921769317694176951769617697176981769917700177011770217703177041770517706177071770817709177101771117712177131771417715177161771717718177191772017721177221772317724177251772617727177281772917730177311773217733177341773517736177371773817739177401774117742177431774417745177461774717748177491775017751177521775317754177551775617757177581775917760177611776217763177641776517766177671776817769177701777117772177731777417775177761777717778177791778017781177821778317784177851778617787177881778917790177911779217793177941779517796177971779817799178001780117802178031780417805178061780717808178091781017811178121781317814178151781617817178181781917820178211782217823178241782517826178271782817829178301783117832178331783417835178361783717838178391784017841178421784317844178451784617847178481784917850178511785217853178541785517856178571785817859178601786117862178631786417865178661786717868178691787017871178721787317874178751787617877178781787917880178811788217883178841788517886178871788817889178901789117892178931789417895178961789717898178991790017901179021790317904179051790617907179081790917910179111791217913179141791517916179171791817919179201792117922179231792417925179261792717928179291793017931179321793317934179351793617937179381793917940179411794217943179441794517946179471794817949179501795117952179531795417955179561795717958179591796017961179621796317964179651796617967179681796917970179711797217973179741797517976179771797817979179801798117982179831798417985179861798717988179891799017991179921799317994179951799617997179981799918000180011800218003180041800518006180071800818009180101801118012180131801418015180161801718018180191802018021180221802318024180251802618027180281802918030180311803218033180341803518036180371803818039180401804118042180431804418045180461804718048180491805018051180521805318054180551805618057180581805918060180611806218063180641806518066180671806818069180701807118072180731807418075180761807718078180791808018081180821808318084180851808618087180881808918090180911809218093180941809518096180971809818099181001810118102181031810418105181061810718108181091811018111181121811318114181151811618117181181811918120181211812218123181241812518126181271812818129181301813118132181331813418135181361813718138181391814018141181421814318144181451814618147181481814918150181511815218153181541815518156181571815818159181601816118162181631816418165181661816718168181691817018171181721817318174181751817618177181781817918180181811818218183181841818518186181871818818189181901819118192181931819418195181961819718198181991820018201182021820318204182051820618207182081820918210182111821218213182141821518216182171821818219182201822118222182231822418225182261822718228182291823018231182321823318234182351823618237182381823918240182411824218243182441824518246182471824818249182501825118252182531825418255182561825718258182591826018261182621826318264182651826618267182681826918270182711827218273182741827518276182771827818279182801828118282182831828418285182861828718288182891829018291182921829318294182951829618297182981829918300183011830218303183041830518306183071830818309183101831118312183131831418315183161831718318183191832018321183221832318324183251832618327183281832918330183311833218333183341833518336183371833818339183401834118342183431834418345183461834718348183491835018351183521835318354183551835618357183581835918360183611836218363183641836518366183671836818369183701837118372183731837418375183761837718378183791838018381183821838318384183851838618387183881838918390183911839218393183941839518396183971839818399184001840118402184031840418405184061840718408184091841018411184121841318414184151841618417184181841918420184211842218423184241842518426184271842818429184301843118432184331843418435184361843718438184391844018441184421844318444184451844618447184481844918450184511845218453184541845518456184571845818459184601846118462184631846418465184661846718468184691847018471184721847318474184751847618477184781847918480184811848218483184841848518486184871848818489184901849118492184931849418495184961849718498184991850018501185021850318504185051850618507185081850918510185111851218513185141851518516185171851818519185201852118522185231852418525185261852718528185291853018531185321853318534185351853618537185381853918540185411854218543185441854518546185471854818549185501855118552185531855418555185561855718558185591856018561185621856318564185651856618567185681856918570185711857218573185741857518576185771857818579185801858118582185831858418585185861858718588185891859018591185921859318594185951859618597185981859918600186011860218603186041860518606186071860818609186101861118612186131861418615186161861718618186191862018621186221862318624186251862618627186281862918630186311863218633186341863518636186371863818639186401864118642186431864418645186461864718648186491865018651186521865318654186551865618657186581865918660186611866218663186641866518666186671866818669186701867118672186731867418675186761867718678186791868018681186821868318684186851868618687186881868918690186911869218693186941869518696186971869818699187001870118702187031870418705187061870718708187091871018711187121871318714187151871618717187181871918720187211872218723187241872518726187271872818729187301873118732187331873418735187361873718738187391874018741187421874318744187451874618747187481874918750187511875218753187541875518756187571875818759187601876118762187631876418765187661876718768187691877018771187721877318774187751877618777187781877918780187811878218783187841878518786187871878818789187901879118792187931879418795187961879718798187991880018801188021880318804188051880618807188081880918810188111881218813188141881518816188171881818819188201882118822188231882418825188261882718828188291883018831188321883318834188351883618837188381883918840188411884218843188441884518846188471884818849188501885118852188531885418855188561885718858188591886018861188621886318864188651886618867188681886918870188711887218873188741887518876188771887818879188801888118882188831888418885188861888718888188891889018891188921889318894188951889618897188981889918900189011890218903189041890518906189071890818909189101891118912189131891418915189161891718918189191892018921189221892318924189251892618927189281892918930189311893218933189341893518936189371893818939189401894118942189431894418945189461894718948189491895018951189521895318954189551895618957189581895918960189611896218963189641896518966189671896818969189701897118972189731897418975189761897718978189791898018981189821898318984189851898618987189881898918990189911899218993189941899518996189971899818999190001900119002190031900419005190061900719008190091901019011190121901319014190151901619017190181901919020190211902219023190241902519026190271902819029190301903119032190331903419035190361903719038190391904019041190421904319044190451904619047190481904919050190511905219053190541905519056190571905819059190601906119062190631906419065190661906719068190691907019071190721907319074190751907619077190781907919080190811908219083190841908519086190871908819089190901909119092190931909419095190961909719098190991910019101191021910319104191051910619107191081910919110191111911219113191141911519116191171911819119191201912119122191231912419125191261912719128191291913019131191321913319134191351913619137191381913919140191411914219143191441914519146191471914819149191501915119152191531915419155191561915719158191591916019161191621916319164191651916619167191681916919170191711917219173191741917519176191771917819179191801918119182191831918419185191861918719188191891919019191191921919319194191951919619197191981919919200192011920219203192041920519206192071920819209192101921119212192131921419215192161921719218192191922019221192221922319224192251922619227192281922919230192311923219233192341923519236192371923819239192401924119242192431924419245192461924719248192491925019251192521925319254192551925619257192581925919260192611926219263192641926519266192671926819269192701927119272192731927419275192761927719278192791928019281192821928319284192851928619287192881928919290192911929219293192941929519296192971929819299193001930119302193031930419305193061930719308193091931019311193121931319314193151931619317193181931919320193211932219323193241932519326193271932819329193301933119332193331933419335193361933719338193391934019341193421934319344193451934619347193481934919350193511935219353193541935519356193571935819359193601936119362193631936419365193661936719368193691937019371193721937319374193751937619377193781937919380193811938219383193841938519386193871938819389193901939119392193931939419395193961939719398193991940019401194021940319404194051940619407194081940919410194111941219413194141941519416194171941819419194201942119422194231942419425194261942719428194291943019431194321943319434194351943619437194381943919440194411944219443194441944519446194471944819449194501945119452194531945419455194561945719458194591946019461194621946319464194651946619467194681946919470194711947219473194741947519476194771947819479194801948119482194831948419485194861948719488194891949019491194921949319494194951949619497194981949919500195011950219503195041950519506195071950819509195101951119512195131951419515195161951719518195191952019521195221952319524195251952619527195281952919530195311953219533195341953519536195371953819539195401954119542195431954419545195461954719548195491955019551195521955319554195551955619557195581955919560195611956219563195641956519566195671956819569195701957119572195731957419575195761957719578195791958019581195821958319584195851958619587195881958919590195911959219593195941959519596195971959819599196001960119602196031960419605196061960719608196091961019611196121961319614196151961619617196181961919620196211962219623196241962519626196271962819629196301963119632196331963419635196361963719638196391964019641196421964319644196451964619647196481964919650196511965219653196541965519656196571965819659196601966119662196631966419665196661966719668196691967019671196721967319674196751967619677196781967919680196811968219683196841968519686196871968819689196901969119692196931969419695196961969719698196991970019701197021970319704197051970619707197081970919710197111971219713197141971519716197171971819719197201972119722197231972419725197261972719728197291973019731197321973319734197351973619737197381973919740197411974219743197441974519746197471974819749197501975119752197531975419755197561975719758197591976019761197621976319764197651976619767197681976919770197711977219773197741977519776197771977819779197801978119782197831978419785197861978719788197891979019791197921979319794197951979619797197981979919800198011980219803198041980519806198071980819809198101981119812198131981419815198161981719818198191982019821198221982319824198251982619827198281982919830198311983219833198341983519836198371983819839198401984119842198431984419845198461984719848198491985019851198521985319854198551985619857198581985919860198611986219863198641986519866198671986819869198701987119872198731987419875198761987719878198791988019881198821988319884198851988619887198881988919890198911989219893198941989519896198971989819899199001990119902199031990419905199061990719908199091991019911199121991319914199151991619917199181991919920199211992219923199241992519926199271992819929199301993119932199331993419935199361993719938199391994019941199421994319944199451994619947199481994919950199511995219953199541995519956199571995819959199601996119962199631996419965199661996719968199691997019971199721997319974199751997619977199781997919980199811998219983199841998519986199871998819989199901999119992199931999419995199961999719998199992000020001200022000320004200052000620007200082000920010200112001220013200142001520016200172001820019200202002120022200232002420025200262002720028200292003020031200322003320034200352003620037200382003920040200412004220043200442004520046200472004820049200502005120052200532005420055200562005720058200592006020061200622006320064200652006620067200682006920070200712007220073200742007520076200772007820079200802008120082200832008420085200862008720088200892009020091200922009320094200952009620097200982009920100201012010220103201042010520106201072010820109201102011120112201132011420115201162011720118201192012020121201222012320124201252012620127201282012920130201312013220133201342013520136201372013820139201402014120142201432014420145201462014720148201492015020151201522015320154201552015620157201582015920160201612016220163201642016520166201672016820169201702017120172201732017420175201762017720178201792018020181201822018320184201852018620187201882018920190201912019220193201942019520196201972019820199202002020120202202032020420205202062020720208202092021020211202122021320214202152021620217202182021920220202212022220223202242022520226202272022820229202302023120232202332023420235202362023720238202392024020241202422024320244202452024620247202482024920250202512025220253202542025520256202572025820259202602026120262202632026420265202662026720268202692027020271202722027320274202752027620277202782027920280202812028220283202842028520286202872028820289202902029120292202932029420295202962029720298202992030020301203022030320304203052030620307203082030920310203112031220313203142031520316203172031820319203202032120322203232032420325203262032720328203292033020331203322033320334203352033620337203382033920340203412034220343203442034520346203472034820349203502035120352203532035420355203562035720358203592036020361203622036320364203652036620367203682036920370203712037220373203742037520376203772037820379203802038120382203832038420385203862038720388203892039020391203922039320394203952039620397203982039920400204012040220403204042040520406204072040820409204102041120412204132041420415204162041720418204192042020421204222042320424204252042620427204282042920430204312043220433204342043520436204372043820439204402044120442204432044420445204462044720448204492045020451204522045320454204552045620457204582045920460204612046220463204642046520466204672046820469204702047120472204732047420475204762047720478204792048020481204822048320484204852048620487204882048920490204912049220493204942049520496204972049820499205002050120502205032050420505205062050720508205092051020511205122051320514205152051620517205182051920520205212052220523205242052520526205272052820529205302053120532205332053420535205362053720538205392054020541205422054320544205452054620547205482054920550205512055220553205542055520556205572055820559205602056120562205632056420565205662056720568205692057020571205722057320574205752057620577205782057920580205812058220583205842058520586205872058820589205902059120592205932059420595205962059720598205992060020601206022060320604206052060620607206082060920610206112061220613206142061520616206172061820619206202062120622206232062420625206262062720628206292063020631206322063320634206352063620637206382063920640206412064220643206442064520646206472064820649206502065120652206532065420655206562065720658206592066020661206622066320664206652066620667206682066920670206712067220673206742067520676206772067820679206802068120682206832068420685206862068720688206892069020691206922069320694206952069620697206982069920700207012070220703207042070520706207072070820709207102071120712207132071420715207162071720718207192072020721207222072320724207252072620727207282072920730207312073220733207342073520736207372073820739207402074120742207432074420745207462074720748207492075020751207522075320754207552075620757207582075920760207612076220763207642076520766207672076820769207702077120772207732077420775207762077720778207792078020781207822078320784207852078620787207882078920790207912079220793207942079520796207972079820799208002080120802208032080420805208062080720808208092081020811208122081320814208152081620817208182081920820208212082220823208242082520826208272082820829208302083120832208332083420835208362083720838208392084020841208422084320844208452084620847208482084920850208512085220853208542085520856208572085820859208602086120862208632086420865208662086720868208692087020871208722087320874208752087620877208782087920880208812088220883208842088520886208872088820889208902089120892208932089420895208962089720898208992090020901209022090320904209052090620907209082090920910209112091220913209142091520916209172091820919209202092120922209232092420925209262092720928209292093020931209322093320934209352093620937209382093920940209412094220943209442094520946209472094820949209502095120952209532095420955209562095720958209592096020961209622096320964209652096620967209682096920970209712097220973209742097520976209772097820979209802098120982209832098420985209862098720988209892099020991209922099320994209952099620997209982099921000210012100221003210042100521006210072100821009210102101121012210132101421015210162101721018210192102021021210222102321024210252102621027210282102921030210312103221033210342103521036210372103821039210402104121042210432104421045210462104721048210492105021051210522105321054210552105621057210582105921060210612106221063210642106521066210672106821069210702107121072210732107421075210762107721078210792108021081210822108321084210852108621087210882108921090210912109221093210942109521096210972109821099211002110121102211032110421105211062110721108211092111021111211122111321114211152111621117211182111921120211212112221123211242112521126211272112821129211302113121132211332113421135211362113721138211392114021141211422114321144211452114621147211482114921150211512115221153211542115521156211572115821159211602116121162211632116421165211662116721168211692117021171211722117321174211752117621177211782117921180211812118221183211842118521186211872118821189211902119121192211932119421195211962119721198211992120021201212022120321204212052120621207212082120921210212112121221213212142121521216212172121821219212202122121222212232122421225212262122721228212292123021231212322123321234212352123621237212382123921240212412124221243212442124521246212472124821249212502125121252212532125421255212562125721258212592126021261212622126321264212652126621267212682126921270212712127221273212742127521276212772127821279212802128121282212832128421285212862128721288212892129021291212922129321294212952129621297212982129921300213012130221303213042130521306213072130821309213102131121312213132131421315213162131721318213192132021321213222132321324213252132621327213282132921330213312133221333213342133521336213372133821339213402134121342213432134421345213462134721348213492135021351213522135321354213552135621357213582135921360213612136221363213642136521366213672136821369213702137121372213732137421375213762137721378213792138021381213822138321384213852138621387213882138921390213912139221393213942139521396213972139821399214002140121402214032140421405214062140721408214092141021411214122141321414214152141621417214182141921420214212142221423214242142521426214272142821429214302143121432214332143421435214362143721438214392144021441214422144321444214452144621447214482144921450214512145221453214542145521456214572145821459214602146121462214632146421465214662146721468214692147021471214722147321474214752147621477214782147921480214812148221483214842148521486214872148821489214902149121492214932149421495214962149721498214992150021501215022150321504215052150621507215082150921510215112151221513215142151521516215172151821519215202152121522215232152421525215262152721528215292153021531215322153321534215352153621537215382153921540215412154221543215442154521546215472154821549215502155121552215532155421555215562155721558215592156021561215622156321564215652156621567215682156921570215712157221573215742157521576215772157821579215802158121582215832158421585215862158721588215892159021591215922159321594215952159621597215982159921600216012160221603216042160521606216072160821609216102161121612216132161421615216162161721618216192162021621216222162321624216252162621627216282162921630216312163221633216342163521636216372163821639216402164121642216432164421645216462164721648216492165021651216522165321654216552165621657216582165921660216612166221663216642166521666216672166821669216702167121672216732167421675216762167721678216792168021681216822168321684216852168621687216882168921690216912169221693216942169521696216972169821699217002170121702217032170421705217062170721708217092171021711217122171321714217152171621717217182171921720217212172221723217242172521726217272172821729217302173121732217332173421735217362173721738217392174021741217422174321744217452174621747217482174921750217512175221753217542175521756217572175821759217602176121762217632176421765217662176721768217692177021771217722177321774217752177621777217782177921780217812178221783217842178521786217872178821789217902179121792217932179421795217962179721798217992180021801218022180321804218052180621807218082180921810218112181221813218142181521816218172181821819218202182121822218232182421825218262182721828218292183021831218322183321834218352183621837218382183921840218412184221843218442184521846218472184821849218502185121852218532185421855218562185721858218592186021861218622186321864218652186621867218682186921870218712187221873218742187521876218772187821879218802188121882218832188421885218862188721888218892189021891218922189321894218952189621897218982189921900219012190221903219042190521906219072190821909219102191121912219132191421915219162191721918219192192021921219222192321924219252192621927219282192921930219312193221933219342193521936219372193821939219402194121942219432194421945219462194721948219492195021951219522195321954219552195621957219582195921960219612196221963219642196521966219672196821969219702197121972219732197421975219762197721978219792198021981219822198321984219852198621987219882198921990219912199221993219942199521996219972199821999220002200122002220032200422005220062200722008220092201022011220122201322014220152201622017220182201922020220212202222023220242202522026220272202822029220302203122032220332203422035220362203722038220392204022041220422204322044220452204622047220482204922050220512205222053220542205522056220572205822059220602206122062220632206422065220662206722068220692207022071220722207322074220752207622077220782207922080220812208222083220842208522086220872208822089220902209122092220932209422095220962209722098220992210022101221022210322104221052210622107221082210922110221112211222113221142211522116221172211822119221202212122122221232212422125221262212722128221292213022131221322213322134221352213622137221382213922140221412214222143221442214522146221472214822149221502215122152221532215422155221562215722158221592216022161221622216322164221652216622167221682216922170221712217222173221742217522176221772217822179221802218122182221832218422185221862218722188221892219022191221922219322194221952219622197221982219922200222012220222203222042220522206222072220822209222102221122212222132221422215222162221722218222192222022221222222222322224222252222622227222282222922230222312223222233222342223522236222372223822239222402224122242222432224422245222462224722248222492225022251222522225322254222552225622257222582225922260222612226222263222642226522266222672226822269222702227122272222732227422275222762227722278222792228022281222822228322284222852228622287222882228922290222912229222293222942229522296222972229822299223002230122302223032230422305223062230722308223092231022311223122231322314223152231622317223182231922320223212232222323223242232522326223272232822329223302233122332223332233422335223362233722338223392234022341223422234322344223452234622347223482234922350223512235222353223542235522356223572235822359223602236122362223632236422365223662236722368223692237022371223722237322374223752237622377223782237922380223812238222383223842238522386223872238822389223902239122392223932239422395223962239722398223992240022401224022240322404224052240622407224082240922410224112241222413224142241522416224172241822419224202242122422224232242422425224262242722428224292243022431224322243322434224352243622437224382243922440224412244222443224442244522446224472244822449224502245122452224532245422455224562245722458224592246022461224622246322464224652246622467224682246922470224712247222473224742247522476224772247822479224802248122482224832248422485224862248722488224892249022491224922249322494224952249622497224982249922500225012250222503225042250522506225072250822509225102251122512225132251422515225162251722518225192252022521225222252322524225252252622527225282252922530225312253222533225342253522536225372253822539225402254122542225432254422545225462254722548225492255022551225522255322554225552255622557225582255922560225612256222563225642256522566225672256822569225702257122572225732257422575225762257722578225792258022581225822258322584225852258622587225882258922590225912259222593225942259522596225972259822599226002260122602226032260422605226062260722608226092261022611226122261322614226152261622617226182261922620226212262222623226242262522626226272262822629226302263122632226332263422635226362263722638226392264022641226422264322644226452264622647226482264922650226512265222653226542265522656226572265822659226602266122662226632266422665226662266722668226692267022671226722267322674226752267622677226782267922680226812268222683226842268522686226872268822689226902269122692226932269422695226962269722698226992270022701227022270322704227052270622707227082270922710227112271222713227142271522716227172271822719227202272122722227232272422725227262272722728227292273022731227322273322734227352273622737227382273922740227412274222743227442274522746227472274822749227502275122752227532275422755227562275722758227592276022761227622276322764227652276622767227682276922770227712277222773227742277522776227772277822779227802278122782227832278422785227862278722788227892279022791227922279322794227952279622797227982279922800228012280222803228042280522806228072280822809228102281122812228132281422815228162281722818228192282022821228222282322824228252282622827228282282922830228312283222833228342283522836228372283822839228402284122842228432284422845228462284722848228492285022851228522285322854228552285622857228582285922860228612286222863228642286522866228672286822869228702287122872228732287422875228762287722878228792288022881228822288322884228852288622887228882288922890228912289222893228942289522896228972289822899229002290122902229032290422905229062290722908229092291022911229122291322914229152291622917229182291922920229212292222923229242292522926229272292822929229302293122932229332293422935229362293722938229392294022941229422294322944229452294622947229482294922950229512295222953229542295522956229572295822959229602296122962229632296422965229662296722968229692297022971229722297322974229752297622977229782297922980229812298222983229842298522986229872298822989229902299122992229932299422995229962299722998229992300023001230022300323004230052300623007230082300923010230112301223013230142301523016230172301823019230202302123022230232302423025230262302723028230292303023031230322303323034230352303623037230382303923040230412304223043230442304523046230472304823049230502305123052230532305423055230562305723058230592306023061230622306323064230652306623067230682306923070230712307223073230742307523076230772307823079230802308123082230832308423085230862308723088230892309023091230922309323094230952309623097230982309923100231012310223103231042310523106231072310823109231102311123112231132311423115231162311723118231192312023121231222312323124231252312623127231282312923130231312313223133231342313523136231372313823139231402314123142231432314423145231462314723148231492315023151231522315323154231552315623157231582315923160231612316223163231642316523166231672316823169231702317123172231732317423175231762317723178231792318023181231822318323184231852318623187231882318923190231912319223193231942319523196231972319823199232002320123202232032320423205232062320723208232092321023211232122321323214232152321623217232182321923220232212322223223232242322523226232272322823229232302323123232232332323423235232362323723238232392324023241232422324323244232452324623247232482324923250232512325223253232542325523256232572325823259232602326123262232632326423265232662326723268232692327023271232722327323274232752327623277232782327923280232812328223283232842328523286232872328823289232902329123292232932329423295232962329723298232992330023301233022330323304233052330623307233082330923310233112331223313233142331523316233172331823319233202332123322233232332423325233262332723328233292333023331233322333323334233352333623337233382333923340233412334223343233442334523346233472334823349233502335123352233532335423355233562335723358233592336023361233622336323364233652336623367233682336923370233712337223373233742337523376233772337823379233802338123382233832338423385233862338723388233892339023391233922339323394233952339623397233982339923400234012340223403234042340523406234072340823409234102341123412234132341423415234162341723418234192342023421234222342323424234252342623427234282342923430234312343223433234342343523436234372343823439234402344123442234432344423445234462344723448234492345023451234522345323454234552345623457234582345923460234612346223463234642346523466234672346823469234702347123472234732347423475234762347723478234792348023481234822348323484234852348623487234882348923490234912349223493234942349523496234972349823499235002350123502235032350423505235062350723508235092351023511235122351323514235152351623517235182351923520235212352223523235242352523526235272352823529235302353123532235332353423535235362353723538235392354023541235422354323544235452354623547235482354923550235512355223553235542355523556235572355823559235602356123562235632356423565235662356723568235692357023571235722357323574235752357623577235782357923580235812358223583235842358523586235872358823589235902359123592235932359423595235962359723598235992360023601236022360323604236052360623607236082360923610236112361223613236142361523616236172361823619236202362123622236232362423625236262362723628236292363023631236322363323634236352363623637236382363923640236412364223643236442364523646236472364823649236502365123652236532365423655236562365723658236592366023661236622366323664236652366623667236682366923670236712367223673236742367523676236772367823679236802368123682236832368423685236862368723688236892369023691236922369323694236952369623697236982369923700237012370223703237042370523706237072370823709237102371123712237132371423715237162371723718237192372023721237222372323724237252372623727237282372923730237312373223733237342373523736237372373823739237402374123742237432374423745237462374723748237492375023751237522375323754237552375623757237582375923760237612376223763237642376523766237672376823769237702377123772237732377423775237762377723778237792378023781237822378323784237852378623787237882378923790237912379223793237942379523796237972379823799238002380123802238032380423805238062380723808238092381023811238122381323814238152381623817238182381923820238212382223823238242382523826238272382823829238302383123832238332383423835238362383723838238392384023841238422384323844238452384623847238482384923850238512385223853238542385523856238572385823859238602386123862238632386423865238662386723868238692387023871238722387323874238752387623877238782387923880238812388223883238842388523886238872388823889238902389123892238932389423895238962389723898238992390023901239022390323904239052390623907239082390923910239112391223913239142391523916239172391823919239202392123922239232392423925239262392723928239292393023931239322393323934239352393623937239382393923940239412394223943239442394523946239472394823949239502395123952239532395423955239562395723958239592396023961239622396323964239652396623967239682396923970239712397223973239742397523976239772397823979239802398123982239832398423985239862398723988239892399023991239922399323994239952399623997239982399924000240012400224003240042400524006240072400824009240102401124012240132401424015240162401724018240192402024021240222402324024240252402624027240282402924030240312403224033240342403524036240372403824039240402404124042240432404424045240462404724048240492405024051240522405324054240552405624057240582405924060240612406224063240642406524066240672406824069240702407124072240732407424075240762407724078240792408024081240822408324084240852408624087240882408924090240912409224093240942409524096240972409824099241002410124102241032410424105241062410724108241092411024111241122411324114241152411624117241182411924120241212412224123241242412524126241272412824129241302413124132241332413424135241362413724138241392414024141241422414324144241452414624147241482414924150241512415224153241542415524156241572415824159241602416124162241632416424165241662416724168241692417024171241722417324174241752417624177241782417924180241812418224183241842418524186241872418824189241902419124192241932419424195241962419724198241992420024201242022420324204242052420624207242082420924210242112421224213242142421524216242172421824219242202422124222242232422424225242262422724228242292423024231242322423324234242352423624237242382423924240242412424224243242442424524246242472424824249242502425124252242532425424255242562425724258242592426024261242622426324264242652426624267242682426924270242712427224273242742427524276242772427824279242802428124282242832428424285242862428724288242892429024291242922429324294242952429624297242982429924300243012430224303243042430524306243072430824309243102431124312243132431424315243162431724318243192432024321243222432324324243252432624327243282432924330243312433224333243342433524336243372433824339243402434124342243432434424345243462434724348243492435024351243522435324354243552435624357243582435924360243612436224363243642436524366243672436824369243702437124372243732437424375243762437724378243792438024381243822438324384243852438624387243882438924390243912439224393243942439524396243972439824399244002440124402244032440424405244062440724408244092441024411244122441324414244152441624417244182441924420244212442224423244242442524426244272442824429244302443124432244332443424435244362443724438244392444024441244422444324444244452444624447244482444924450244512445224453244542445524456244572445824459244602446124462244632446424465244662446724468244692447024471244722447324474244752447624477244782447924480244812448224483244842448524486244872448824489244902449124492244932449424495244962449724498244992450024501245022450324504245052450624507245082450924510245112451224513245142451524516245172451824519245202452124522245232452424525245262452724528245292453024531245322453324534245352453624537245382453924540245412454224543245442454524546245472454824549245502455124552245532455424555245562455724558245592456024561245622456324564245652456624567245682456924570245712457224573245742457524576245772457824579245802458124582245832458424585245862458724588245892459024591245922459324594245952459624597245982459924600246012460224603246042460524606246072460824609246102461124612246132461424615246162461724618246192462024621246222462324624246252462624627246282462924630246312463224633246342463524636246372463824639246402464124642246432464424645246462464724648246492465024651246522465324654246552465624657246582465924660246612466224663246642466524666246672466824669246702467124672246732467424675246762467724678246792468024681246822468324684246852468624687246882468924690246912469224693246942469524696246972469824699247002470124702247032470424705247062470724708247092471024711247122471324714247152471624717247182471924720247212472224723247242472524726247272472824729247302473124732247332473424735247362473724738247392474024741247422474324744247452474624747247482474924750247512475224753247542475524756247572475824759247602476124762247632476424765247662476724768247692477024771247722477324774247752477624777247782477924780247812478224783247842478524786247872478824789247902479124792247932479424795247962479724798247992480024801248022480324804248052480624807248082480924810248112481224813248142481524816248172481824819248202482124822248232482424825248262482724828248292483024831248322483324834248352483624837248382483924840248412484224843248442484524846248472484824849248502485124852248532485424855248562485724858248592486024861248622486324864248652486624867248682486924870248712487224873248742487524876248772487824879248802488124882248832488424885248862488724888248892489024891248922489324894248952489624897248982489924900249012490224903249042490524906249072490824909249102491124912249132491424915249162491724918249192492024921249222492324924249252492624927249282492924930249312493224933249342493524936249372493824939249402494124942249432494424945249462494724948249492495024951249522495324954249552495624957249582495924960249612496224963249642496524966249672496824969249702497124972249732497424975249762497724978249792498024981249822498324984249852498624987249882498924990249912499224993249942499524996249972499824999250002500125002250032500425005250062500725008250092501025011250122501325014250152501625017250182501925020250212502225023250242502525026250272502825029250302503125032250332503425035250362503725038250392504025041250422504325044250452504625047250482504925050250512505225053250542505525056250572505825059250602506125062250632506425065250662506725068250692507025071250722507325074250752507625077250782507925080250812508225083250842508525086250872508825089250902509125092250932509425095250962509725098250992510025101251022510325104251052510625107251082510925110251112511225113251142511525116251172511825119251202512125122251232512425125251262512725128251292513025131251322513325134251352513625137251382513925140251412514225143251442514525146251472514825149251502515125152251532515425155251562515725158251592516025161251622516325164251652516625167251682516925170251712517225173251742517525176251772517825179251802518125182251832518425185251862518725188251892519025191251922519325194251952519625197251982519925200252012520225203252042520525206252072520825209252102521125212252132521425215252162521725218252192522025221252222522325224252252522625227252282522925230252312523225233252342523525236252372523825239252402524125242252432524425245252462524725248252492525025251252522525325254252552525625257252582525925260252612526225263252642526525266252672526825269252702527125272252732527425275252762527725278252792528025281252822528325284252852528625287252882528925290252912529225293252942529525296252972529825299253002530125302253032530425305253062530725308253092531025311253122531325314253152531625317253182531925320253212532225323253242532525326253272532825329253302533125332253332533425335253362533725338253392534025341253422534325344253452534625347253482534925350253512535225353253542535525356253572535825359253602536125362253632536425365253662536725368253692537025371253722537325374253752537625377253782537925380253812538225383253842538525386253872538825389253902539125392253932539425395253962539725398253992540025401254022540325404254052540625407254082540925410254112541225413254142541525416254172541825419254202542125422254232542425425254262542725428254292543025431254322543325434254352543625437254382543925440254412544225443254442544525446254472544825449254502545125452254532545425455254562545725458254592546025461254622546325464254652546625467254682546925470254712547225473254742547525476254772547825479254802548125482254832548425485254862548725488254892549025491254922549325494254952549625497254982549925500255012550225503255042550525506255072550825509255102551125512255132551425515255162551725518255192552025521255222552325524255252552625527255282552925530255312553225533255342553525536255372553825539255402554125542255432554425545255462554725548255492555025551255522555325554255552555625557255582555925560255612556225563255642556525566255672556825569255702557125572255732557425575255762557725578255792558025581255822558325584255852558625587255882558925590255912559225593255942559525596255972559825599256002560125602256032560425605256062560725608256092561025611256122561325614256152561625617256182561925620256212562225623256242562525626256272562825629256302563125632256332563425635256362563725638256392564025641256422564325644256452564625647256482564925650256512565225653256542565525656256572565825659256602566125662256632566425665256662566725668256692567025671256722567325674256752567625677256782567925680256812568225683256842568525686256872568825689256902569125692256932569425695256962569725698256992570025701257022570325704257052570625707257082570925710257112571225713257142571525716257172571825719257202572125722257232572425725257262572725728257292573025731257322573325734257352573625737257382573925740257412574225743257442574525746257472574825749257502575125752257532575425755257562575725758257592576025761257622576325764257652576625767257682576925770257712577225773257742577525776257772577825779257802578125782257832578425785257862578725788257892579025791257922579325794257952579625797257982579925800258012580225803258042580525806258072580825809258102581125812258132581425815258162581725818258192582025821258222582325824258252582625827258282582925830258312583225833258342583525836258372583825839258402584125842258432584425845258462584725848258492585025851258522585325854258552585625857258582585925860258612586225863258642586525866258672586825869258702587125872258732587425875258762587725878258792588025881258822588325884258852588625887258882588925890258912589225893258942589525896258972589825899259002590125902259032590425905259062590725908259092591025911259122591325914259152591625917259182591925920259212592225923259242592525926259272592825929259302593125932259332593425935259362593725938259392594025941259422594325944259452594625947259482594925950259512595225953259542595525956259572595825959259602596125962259632596425965259662596725968259692597025971259722597325974259752597625977259782597925980259812598225983259842598525986259872598825989259902599125992259932599425995259962599725998259992600026001260022600326004260052600626007260082600926010260112601226013260142601526016260172601826019260202602126022260232602426025260262602726028260292603026031260322603326034260352603626037260382603926040260412604226043260442604526046260472604826049260502605126052260532605426055260562605726058260592606026061260622606326064260652606626067260682606926070260712607226073260742607526076260772607826079260802608126082260832608426085260862608726088260892609026091260922609326094260952609626097260982609926100261012610226103261042610526106261072610826109261102611126112261132611426115261162611726118261192612026121261222612326124261252612626127261282612926130261312613226133261342613526136261372613826139261402614126142261432614426145261462614726148261492615026151261522615326154261552615626157261582615926160261612616226163261642616526166261672616826169261702617126172261732617426175261762617726178261792618026181261822618326184261852618626187261882618926190261912619226193261942619526196261972619826199262002620126202262032620426205262062620726208262092621026211262122621326214262152621626217262182621926220262212622226223262242622526226262272622826229262302623126232262332623426235262362623726238262392624026241262422624326244262452624626247262482624926250262512625226253262542625526256262572625826259262602626126262262632626426265262662626726268262692627026271262722627326274262752627626277262782627926280262812628226283262842628526286262872628826289262902629126292262932629426295262962629726298262992630026301263022630326304263052630626307263082630926310263112631226313263142631526316263172631826319263202632126322263232632426325263262632726328263292633026331263322633326334263352633626337263382633926340263412634226343263442634526346263472634826349263502635126352263532635426355263562635726358263592636026361263622636326364263652636626367263682636926370263712637226373263742637526376263772637826379263802638126382263832638426385263862638726388263892639026391263922639326394263952639626397263982639926400264012640226403264042640526406264072640826409264102641126412264132641426415264162641726418264192642026421264222642326424264252642626427264282642926430264312643226433264342643526436264372643826439264402644126442264432644426445264462644726448264492645026451264522645326454264552645626457264582645926460264612646226463264642646526466264672646826469264702647126472264732647426475264762647726478264792648026481264822648326484264852648626487264882648926490264912649226493264942649526496264972649826499265002650126502265032650426505265062650726508265092651026511265122651326514265152651626517265182651926520265212652226523265242652526526265272652826529265302653126532265332653426535265362653726538265392654026541265422654326544265452654626547265482654926550265512655226553265542655526556265572655826559265602656126562265632656426565265662656726568265692657026571265722657326574265752657626577265782657926580265812658226583265842658526586265872658826589265902659126592265932659426595265962659726598265992660026601266022660326604266052660626607266082660926610266112661226613266142661526616266172661826619266202662126622266232662426625266262662726628266292663026631266322663326634266352663626637266382663926640266412664226643266442664526646266472664826649266502665126652266532665426655266562665726658266592666026661266622666326664266652666626667266682666926670266712667226673266742667526676266772667826679266802668126682266832668426685266862668726688266892669026691266922669326694266952669626697266982669926700267012670226703267042670526706267072670826709267102671126712267132671426715267162671726718267192672026721267222672326724267252672626727267282672926730267312673226733267342673526736267372673826739267402674126742267432674426745267462674726748267492675026751267522675326754267552675626757267582675926760267612676226763267642676526766267672676826769267702677126772267732677426775267762677726778267792678026781267822678326784267852678626787267882678926790267912679226793267942679526796267972679826799268002680126802268032680426805268062680726808268092681026811268122681326814268152681626817268182681926820268212682226823268242682526826268272682826829268302683126832268332683426835268362683726838268392684026841268422684326844268452684626847268482684926850268512685226853268542685526856268572685826859268602686126862268632686426865268662686726868268692687026871268722687326874268752687626877268782687926880268812688226883268842688526886268872688826889268902689126892268932689426895268962689726898268992690026901269022690326904269052690626907269082690926910269112691226913269142691526916269172691826919269202692126922269232692426925269262692726928269292693026931269322693326934269352693626937269382693926940269412694226943269442694526946269472694826949269502695126952269532695426955269562695726958269592696026961269622696326964269652696626967269682696926970269712697226973269742697526976269772697826979269802698126982269832698426985269862698726988269892699026991269922699326994269952699626997269982699927000270012700227003270042700527006270072700827009270102701127012270132701427015270162701727018270192702027021270222702327024270252702627027270282702927030270312703227033270342703527036270372703827039270402704127042270432704427045270462704727048270492705027051270522705327054270552705627057270582705927060270612706227063270642706527066270672706827069270702707127072270732707427075270762707727078270792708027081270822708327084270852708627087270882708927090270912709227093270942709527096270972709827099271002710127102271032710427105271062710727108271092711027111271122711327114271152711627117271182711927120271212712227123271242712527126271272712827129271302713127132271332713427135271362713727138271392714027141271422714327144271452714627147271482714927150271512715227153271542715527156271572715827159271602716127162271632716427165271662716727168271692717027171271722717327174271752717627177271782717927180271812718227183271842718527186271872718827189271902719127192271932719427195271962719727198271992720027201272022720327204272052720627207272082720927210272112721227213272142721527216272172721827219272202722127222272232722427225272262722727228272292723027231272322723327234272352723627237272382723927240272412724227243272442724527246272472724827249272502725127252272532725427255272562725727258272592726027261272622726327264272652726627267272682726927270272712727227273272742727527276272772727827279272802728127282272832728427285272862728727288272892729027291272922729327294272952729627297272982729927300273012730227303273042730527306273072730827309273102731127312273132731427315273162731727318273192732027321273222732327324273252732627327273282732927330273312733227333273342733527336273372733827339273402734127342273432734427345273462734727348273492735027351273522735327354273552735627357273582735927360273612736227363273642736527366273672736827369273702737127372273732737427375273762737727378273792738027381273822738327384273852738627387273882738927390273912739227393273942739527396273972739827399274002740127402274032740427405274062740727408274092741027411274122741327414274152741627417274182741927420274212742227423274242742527426274272742827429274302743127432274332743427435274362743727438274392744027441274422744327444274452744627447274482744927450274512745227453274542745527456274572745827459274602746127462274632746427465274662746727468274692747027471274722747327474274752747627477274782747927480274812748227483274842748527486274872748827489274902749127492274932749427495274962749727498274992750027501275022750327504275052750627507275082750927510275112751227513275142751527516275172751827519275202752127522275232752427525275262752727528275292753027531275322753327534275352753627537275382753927540275412754227543275442754527546275472754827549275502755127552275532755427555275562755727558275592756027561275622756327564275652756627567275682756927570275712757227573275742757527576275772757827579275802758127582275832758427585275862758727588275892759027591275922759327594275952759627597275982759927600276012760227603276042760527606276072760827609276102761127612276132761427615276162761727618276192762027621276222762327624276252762627627276282762927630276312763227633276342763527636276372763827639276402764127642276432764427645276462764727648276492765027651276522765327654276552765627657276582765927660276612766227663276642766527666276672766827669276702767127672276732767427675276762767727678276792768027681276822768327684276852768627687276882768927690276912769227693276942769527696276972769827699277002770127702277032770427705277062770727708277092771027711277122771327714277152771627717277182771927720277212772227723277242772527726277272772827729277302773127732277332773427735277362773727738277392774027741277422774327744277452774627747277482774927750277512775227753277542775527756277572775827759277602776127762277632776427765277662776727768277692777027771277722777327774277752777627777277782777927780277812778227783277842778527786277872778827789277902779127792277932779427795277962779727798277992780027801278022780327804278052780627807278082780927810278112781227813278142781527816278172781827819278202782127822278232782427825278262782727828278292783027831278322783327834278352783627837278382783927840278412784227843278442784527846278472784827849278502785127852278532785427855278562785727858278592786027861278622786327864278652786627867278682786927870278712787227873278742787527876278772787827879278802788127882278832788427885278862788727888278892789027891278922789327894278952789627897278982789927900279012790227903279042790527906279072790827909279102791127912279132791427915279162791727918279192792027921279222792327924279252792627927279282792927930279312793227933279342793527936279372793827939279402794127942279432794427945279462794727948279492795027951279522795327954279552795627957279582795927960279612796227963279642796527966279672796827969279702797127972279732797427975279762797727978279792798027981279822798327984279852798627987279882798927990279912799227993279942799527996279972799827999280002800128002280032800428005280062800728008280092801028011280122801328014280152801628017280182801928020280212802228023280242802528026280272802828029280302803128032280332803428035280362803728038280392804028041280422804328044280452804628047280482804928050280512805228053280542805528056280572805828059280602806128062280632806428065280662806728068280692807028071280722807328074280752807628077280782807928080280812808228083280842808528086280872808828089280902809128092280932809428095280962809728098280992810028101281022810328104281052810628107281082810928110281112811228113281142811528116281172811828119281202812128122281232812428125281262812728128281292813028131281322813328134281352813628137281382813928140281412814228143281442814528146281472814828149281502815128152281532815428155281562815728158281592816028161281622816328164281652816628167281682816928170281712817228173281742817528176281772817828179281802818128182281832818428185281862818728188281892819028191281922819328194281952819628197281982819928200282012820228203282042820528206282072820828209282102821128212282132821428215282162821728218282192822028221282222822328224282252822628227282282822928230282312823228233282342823528236282372823828239282402824128242282432824428245282462824728248282492825028251282522825328254282552825628257282582825928260282612826228263282642826528266282672826828269282702827128272282732827428275282762827728278282792828028281282822828328284282852828628287282882828928290282912829228293282942829528296282972829828299283002830128302283032830428305283062830728308283092831028311283122831328314283152831628317283182831928320283212832228323283242832528326283272832828329283302833128332283332833428335283362833728338283392834028341283422834328344283452834628347283482834928350283512835228353283542835528356283572835828359283602836128362283632836428365283662836728368283692837028371283722837328374283752837628377283782837928380283812838228383283842838528386283872838828389283902839128392283932839428395283962839728398283992840028401284022840328404284052840628407284082840928410284112841228413284142841528416284172841828419284202842128422284232842428425284262842728428284292843028431284322843328434284352843628437284382843928440284412844228443284442844528446284472844828449284502845128452284532845428455284562845728458284592846028461284622846328464284652846628467284682846928470284712847228473284742847528476284772847828479284802848128482284832848428485284862848728488284892849028491284922849328494284952849628497284982849928500285012850228503285042850528506285072850828509285102851128512285132851428515285162851728518285192852028521285222852328524285252852628527285282852928530285312853228533285342853528536285372853828539285402854128542285432854428545285462854728548285492855028551285522855328554285552855628557285582855928560285612856228563285642856528566285672856828569285702857128572285732857428575285762857728578285792858028581285822858328584285852858628587285882858928590285912859228593285942859528596285972859828599286002860128602286032860428605286062860728608286092861028611286122861328614286152861628617286182861928620286212862228623286242862528626286272862828629286302863128632286332863428635286362863728638286392864028641286422864328644286452864628647286482864928650286512865228653286542865528656286572865828659286602866128662286632866428665286662866728668286692867028671286722867328674286752867628677286782867928680286812868228683286842868528686286872868828689286902869128692286932869428695286962869728698286992870028701287022870328704287052870628707287082870928710287112871228713287142871528716287172871828719287202872128722287232872428725287262872728728287292873028731287322873328734287352873628737287382873928740287412874228743287442874528746287472874828749287502875128752287532875428755287562875728758287592876028761287622876328764287652876628767287682876928770287712877228773287742877528776287772877828779287802878128782287832878428785287862878728788287892879028791287922879328794287952879628797287982879928800288012880228803288042880528806288072880828809288102881128812288132881428815288162881728818288192882028821288222882328824288252882628827288282882928830288312883228833288342883528836288372883828839288402884128842288432884428845288462884728848288492885028851288522885328854288552885628857288582885928860288612886228863288642886528866288672886828869288702887128872288732887428875288762887728878288792888028881288822888328884288852888628887288882888928890288912889228893288942889528896288972889828899289002890128902289032890428905289062890728908289092891028911289122891328914289152891628917289182891928920289212892228923289242892528926289272892828929289302893128932289332893428935289362893728938289392894028941289422894328944289452894628947289482894928950289512895228953289542895528956289572895828959289602896128962289632896428965289662896728968289692897028971289722897328974289752897628977289782897928980289812898228983289842898528986289872898828989289902899128992289932899428995289962899728998289992900029001290022900329004290052900629007290082900929010290112901229013290142901529016290172901829019290202902129022290232902429025290262902729028290292903029031290322903329034290352903629037290382903929040290412904229043290442904529046290472904829049290502905129052290532905429055290562905729058290592906029061290622906329064290652906629067290682906929070290712907229073290742907529076290772907829079290802908129082290832908429085290862908729088290892909029091290922909329094290952909629097290982909929100291012910229103291042910529106291072910829109291102911129112291132911429115291162911729118291192912029121291222912329124291252912629127291282912929130291312913229133291342913529136291372913829139291402914129142291432914429145291462914729148291492915029151291522915329154291552915629157291582915929160291612916229163291642916529166291672916829169291702917129172291732917429175291762917729178291792918029181291822918329184291852918629187291882918929190291912919229193291942919529196291972919829199292002920129202292032920429205292062920729208292092921029211292122921329214292152921629217292182921929220292212922229223292242922529226292272922829229292302923129232292332923429235292362923729238292392924029241292422924329244292452924629247292482924929250292512925229253292542925529256292572925829259292602926129262292632926429265292662926729268292692927029271292722927329274292752927629277292782927929280292812928229283292842928529286292872928829289292902929129292292932929429295292962929729298292992930029301293022930329304293052930629307293082930929310293112931229313293142931529316293172931829319293202932129322293232932429325293262932729328293292933029331293322933329334293352933629337293382933929340293412934229343293442934529346293472934829349293502935129352293532935429355293562935729358293592936029361293622936329364293652936629367293682936929370293712937229373293742937529376293772937829379293802938129382293832938429385293862938729388293892939029391293922939329394293952939629397293982939929400294012940229403294042940529406294072940829409294102941129412294132941429415294162941729418294192942029421294222942329424294252942629427294282942929430294312943229433294342943529436294372943829439294402944129442294432944429445294462944729448294492945029451294522945329454294552945629457294582945929460294612946229463294642946529466294672946829469294702947129472294732947429475294762947729478294792948029481294822948329484294852948629487294882948929490294912949229493294942949529496294972949829499295002950129502295032950429505295062950729508295092951029511295122951329514295152951629517295182951929520295212952229523295242952529526295272952829529295302953129532295332953429535295362953729538295392954029541295422954329544295452954629547295482954929550295512955229553295542955529556295572955829559295602956129562295632956429565295662956729568295692957029571295722957329574295752957629577295782957929580295812958229583295842958529586295872958829589295902959129592295932959429595295962959729598295992960029601296022960329604296052960629607296082960929610296112961229613296142961529616296172961829619296202962129622296232962429625296262962729628296292963029631296322963329634296352963629637296382963929640296412964229643296442964529646296472964829649296502965129652296532965429655296562965729658296592966029661296622966329664296652966629667296682966929670296712967229673296742967529676296772967829679296802968129682296832968429685296862968729688296892969029691296922969329694296952969629697296982969929700297012970229703297042970529706297072970829709297102971129712297132971429715297162971729718297192972029721297222972329724297252972629727297282972929730297312973229733297342973529736297372973829739297402974129742297432974429745297462974729748297492975029751297522975329754297552975629757297582975929760297612976229763297642976529766297672976829769297702977129772297732977429775297762977729778297792978029781297822978329784297852978629787297882978929790297912979229793297942979529796297972979829799298002980129802298032980429805298062980729808298092981029811298122981329814298152981629817298182981929820298212982229823298242982529826298272982829829298302983129832298332983429835298362983729838298392984029841298422984329844298452984629847298482984929850298512985229853298542985529856298572985829859298602986129862298632986429865298662986729868298692987029871298722987329874298752987629877298782987929880298812988229883298842988529886298872988829889298902989129892298932989429895298962989729898298992990029901299022990329904299052990629907299082990929910299112991229913299142991529916299172991829919299202992129922299232992429925299262992729928299292993029931299322993329934299352993629937299382993929940299412994229943299442994529946299472994829949299502995129952299532995429955299562995729958299592996029961299622996329964299652996629967299682996929970299712997229973299742997529976299772997829979299802998129982299832998429985299862998729988299892999029991299922999329994299952999629997299982999930000300013000230003300043000530006300073000830009300103001130012300133001430015300163001730018300193002030021300223002330024300253002630027300283002930030300313003230033300343003530036300373003830039300403004130042300433004430045300463004730048300493005030051300523005330054300553005630057300583005930060300613006230063300643006530066300673006830069300703007130072300733007430075300763007730078300793008030081300823008330084300853008630087300883008930090300913009230093300943009530096300973009830099301003010130102301033010430105301063010730108301093011030111301123011330114301153011630117301183011930120301213012230123301243012530126301273012830129301303013130132301333013430135301363013730138301393014030141301423014330144301453014630147301483014930150301513015230153301543015530156301573015830159301603016130162301633016430165301663016730168301693017030171301723017330174301753017630177301783017930180301813018230183301843018530186301873018830189301903019130192301933019430195301963019730198301993020030201302023020330204302053020630207302083020930210302113021230213302143021530216302173021830219302203022130222302233022430225302263022730228302293023030231302323023330234302353023630237302383023930240302413024230243302443024530246302473024830249302503025130252302533025430255302563025730258302593026030261302623026330264302653026630267302683026930270302713027230273302743027530276302773027830279302803028130282302833028430285302863028730288302893029030291302923029330294302953029630297302983029930300303013030230303303043030530306303073030830309303103031130312303133031430315303163031730318303193032030321303223032330324303253032630327303283032930330303313033230333303343033530336303373033830339303403034130342303433034430345303463034730348303493035030351303523035330354303553035630357303583035930360303613036230363303643036530366303673036830369303703037130372303733037430375303763037730378303793038030381303823038330384303853038630387303883038930390303913039230393303943039530396303973039830399304003040130402304033040430405304063040730408304093041030411304123041330414304153041630417304183041930420304213042230423304243042530426304273042830429304303043130432304333043430435304363043730438304393044030441304423044330444304453044630447304483044930450304513045230453304543045530456304573045830459304603046130462304633046430465304663046730468304693047030471304723047330474304753047630477304783047930480304813048230483304843048530486304873048830489304903049130492304933049430495304963049730498304993050030501305023050330504305053050630507305083050930510305113051230513305143051530516305173051830519305203052130522305233052430525305263052730528305293053030531305323053330534305353053630537305383053930540305413054230543305443054530546305473054830549305503055130552305533055430555305563055730558305593056030561305623056330564305653056630567305683056930570305713057230573305743057530576305773057830579305803058130582305833058430585305863058730588305893059030591305923059330594305953059630597305983059930600306013060230603306043060530606306073060830609306103061130612306133061430615306163061730618306193062030621306223062330624306253062630627306283062930630306313063230633306343063530636306373063830639306403064130642306433064430645306463064730648306493065030651306523065330654306553065630657306583065930660306613066230663306643066530666306673066830669306703067130672306733067430675306763067730678306793068030681306823068330684306853068630687306883068930690306913069230693306943069530696306973069830699307003070130702307033070430705307063070730708307093071030711307123071330714307153071630717307183071930720307213072230723307243072530726307273072830729307303073130732307333073430735307363073730738307393074030741307423074330744307453074630747307483074930750307513075230753307543075530756307573075830759307603076130762307633076430765307663076730768307693077030771307723077330774307753077630777307783077930780307813078230783307843078530786307873078830789307903079130792307933079430795307963079730798307993080030801308023080330804308053080630807308083080930810308113081230813308143081530816308173081830819308203082130822308233082430825308263082730828308293083030831308323083330834308353083630837308383083930840308413084230843308443084530846308473084830849308503085130852308533085430855308563085730858308593086030861308623086330864308653086630867308683086930870308713087230873308743087530876308773087830879308803088130882308833088430885308863088730888308893089030891308923089330894308953089630897308983089930900309013090230903309043090530906309073090830909309103091130912309133091430915309163091730918309193092030921309223092330924309253092630927309283092930930309313093230933309343093530936309373093830939309403094130942309433094430945309463094730948309493095030951309523095330954309553095630957309583095930960309613096230963309643096530966309673096830969309703097130972309733097430975309763097730978309793098030981309823098330984309853098630987309883098930990309913099230993309943099530996309973099830999310003100131002310033100431005310063100731008310093101031011310123101331014310153101631017310183101931020310213102231023310243102531026310273102831029310303103131032310333103431035310363103731038310393104031041310423104331044310453104631047310483104931050310513105231053310543105531056310573105831059310603106131062310633106431065310663106731068310693107031071310723107331074310753107631077310783107931080310813108231083310843108531086310873108831089310903109131092310933109431095310963109731098310993110031101311023110331104311053110631107311083110931110311113111231113311143111531116311173111831119311203112131122311233112431125311263112731128311293113031131311323113331134311353113631137311383113931140311413114231143311443114531146311473114831149311503115131152311533115431155311563115731158311593116031161311623116331164311653116631167311683116931170311713117231173311743117531176311773117831179311803118131182311833118431185311863118731188311893119031191311923119331194311953119631197311983119931200312013120231203312043120531206312073120831209312103121131212312133121431215312163121731218312193122031221312223122331224312253122631227312283122931230312313123231233312343123531236312373123831239312403124131242312433124431245312463124731248312493125031251312523125331254312553125631257312583125931260312613126231263312643126531266312673126831269312703127131272312733127431275312763127731278312793128031281312823128331284312853128631287312883128931290312913129231293312943129531296312973129831299313003130131302313033130431305313063130731308313093131031311313123131331314313153131631317313183131931320313213132231323313243132531326313273132831329313303133131332313333133431335313363133731338313393134031341313423134331344313453134631347313483134931350313513135231353313543135531356313573135831359313603136131362313633136431365313663136731368313693137031371313723137331374313753137631377313783137931380313813138231383313843138531386313873138831389313903139131392313933139431395313963139731398313993140031401314023140331404314053140631407314083140931410314113141231413314143141531416314173141831419314203142131422314233142431425314263142731428314293143031431314323143331434314353143631437314383143931440314413144231443314443144531446314473144831449314503145131452314533145431455314563145731458314593146031461314623146331464314653146631467314683146931470314713147231473314743147531476314773147831479314803148131482314833148431485314863148731488314893149031491314923149331494314953149631497314983149931500315013150231503315043150531506315073150831509315103151131512315133151431515315163151731518315193152031521315223152331524315253152631527315283152931530315313153231533315343153531536315373153831539315403154131542315433154431545315463154731548315493155031551315523155331554315553155631557315583155931560315613156231563315643156531566315673156831569315703157131572315733157431575315763157731578315793158031581315823158331584315853158631587315883158931590315913159231593315943159531596315973159831599316003160131602316033160431605316063160731608316093161031611316123161331614316153161631617316183161931620316213162231623316243162531626316273162831629316303163131632316333163431635316363163731638316393164031641316423164331644316453164631647316483164931650316513165231653316543165531656316573165831659316603166131662316633166431665316663166731668316693167031671316723167331674316753167631677316783167931680316813168231683316843168531686316873168831689316903169131692316933169431695316963169731698316993170031701317023170331704317053170631707317083170931710317113171231713317143171531716317173171831719317203172131722317233172431725317263172731728317293173031731317323173331734317353173631737317383173931740317413174231743317443174531746317473174831749317503175131752317533175431755317563175731758317593176031761317623176331764317653176631767317683176931770317713177231773317743177531776317773177831779317803178131782317833178431785317863178731788317893179031791317923179331794317953179631797317983179931800318013180231803318043180531806318073180831809318103181131812318133181431815318163181731818318193182031821318223182331824318253182631827318283182931830318313183231833318343183531836318373183831839318403184131842318433184431845318463184731848318493185031851318523185331854318553185631857318583185931860318613186231863318643186531866318673186831869318703187131872318733187431875318763187731878318793188031881318823188331884318853188631887318883188931890318913189231893318943189531896318973189831899319003190131902319033190431905319063190731908319093191031911319123191331914319153191631917319183191931920319213192231923319243192531926319273192831929319303193131932319333193431935319363193731938319393194031941319423194331944319453194631947319483194931950319513195231953319543195531956319573195831959319603196131962319633196431965319663196731968319693197031971319723197331974319753197631977319783197931980319813198231983319843198531986319873198831989319903199131992319933199431995319963199731998319993200032001320023200332004320053200632007320083200932010320113201232013320143201532016320173201832019320203202132022320233202432025320263202732028320293203032031320323203332034320353203632037320383203932040320413204232043320443204532046320473204832049320503205132052320533205432055320563205732058320593206032061320623206332064320653206632067320683206932070320713207232073320743207532076320773207832079320803208132082320833208432085320863208732088320893209032091320923209332094320953209632097320983209932100321013210232103321043210532106321073210832109321103211132112321133211432115321163211732118321193212032121321223212332124321253212632127321283212932130321313213232133321343213532136321373213832139321403214132142321433214432145321463214732148321493215032151321523215332154321553215632157321583215932160321613216232163321643216532166321673216832169321703217132172321733217432175321763217732178321793218032181321823218332184321853218632187321883218932190321913219232193321943219532196321973219832199322003220132202322033220432205322063220732208322093221032211322123221332214322153221632217322183221932220322213222232223322243222532226322273222832229322303223132232322333223432235322363223732238322393224032241322423224332244322453224632247322483224932250322513225232253322543225532256322573225832259322603226132262322633226432265322663226732268322693227032271322723227332274322753227632277322783227932280322813228232283322843228532286322873228832289322903229132292322933229432295322963229732298322993230032301323023230332304323053230632307323083230932310323113231232313323143231532316323173231832319323203232132322323233232432325323263232732328323293233032331323323233332334323353233632337323383233932340323413234232343323443234532346323473234832349323503235132352323533235432355323563235732358323593236032361323623236332364323653236632367323683236932370323713237232373323743237532376323773237832379323803238132382323833238432385323863238732388323893239032391323923239332394323953239632397323983239932400324013240232403324043240532406324073240832409324103241132412324133241432415324163241732418324193242032421324223242332424324253242632427324283242932430324313243232433324343243532436324373243832439324403244132442324433244432445324463244732448324493245032451324523245332454324553245632457324583245932460324613246232463324643246532466324673246832469324703247132472324733247432475324763247732478324793248032481324823248332484324853248632487324883248932490324913249232493324943249532496324973249832499325003250132502325033250432505325063250732508325093251032511325123251332514325153251632517325183251932520325213252232523325243252532526325273252832529325303253132532325333253432535325363253732538325393254032541325423254332544325453254632547325483254932550325513255232553325543255532556325573255832559325603256132562325633256432565325663256732568325693257032571325723257332574325753257632577325783257932580325813258232583325843258532586325873258832589325903259132592325933259432595325963259732598325993260032601326023260332604326053260632607326083260932610326113261232613326143261532616326173261832619326203262132622326233262432625326263262732628326293263032631326323263332634326353263632637326383263932640326413264232643326443264532646326473264832649326503265132652326533265432655326563265732658326593266032661326623266332664326653266632667326683266932670326713267232673326743267532676326773267832679326803268132682326833268432685326863268732688326893269032691326923269332694326953269632697326983269932700327013270232703327043270532706327073270832709327103271132712327133271432715327163271732718327193272032721327223272332724327253272632727327283272932730327313273232733327343273532736327373273832739327403274132742327433274432745327463274732748327493275032751327523275332754327553275632757327583275932760327613276232763327643276532766327673276832769327703277132772327733277432775327763277732778327793278032781327823278332784327853278632787327883278932790327913279232793327943279532796327973279832799328003280132802328033280432805328063280732808328093281032811328123281332814328153281632817328183281932820328213282232823328243282532826328273282832829328303283132832328333283432835328363283732838328393284032841328423284332844328453284632847328483284932850328513285232853328543285532856328573285832859328603286132862328633286432865328663286732868328693287032871328723287332874328753287632877328783287932880328813288232883328843288532886328873288832889328903289132892328933289432895328963289732898328993290032901329023290332904329053290632907329083290932910329113291232913329143291532916329173291832919329203292132922329233292432925329263292732928329293293032931329323293332934329353293632937329383293932940329413294232943329443294532946329473294832949329503295132952329533295432955329563295732958329593296032961329623296332964329653296632967329683296932970329713297232973329743297532976329773297832979329803298132982329833298432985329863298732988329893299032991329923299332994329953299632997329983299933000330013300233003330043300533006330073300833009330103301133012330133301433015330163301733018330193302033021330223302333024330253302633027330283302933030330313303233033330343303533036330373303833039330403304133042330433304433045330463304733048330493305033051330523305333054330553305633057330583305933060330613306233063330643306533066330673306833069330703307133072330733307433075330763307733078330793308033081330823308333084330853308633087330883308933090330913309233093330943309533096330973309833099331003310133102331033310433105331063310733108331093311033111331123311333114331153311633117331183311933120331213312233123331243312533126331273312833129331303313133132331333313433135331363313733138331393314033141331423314333144331453314633147331483314933150331513315233153331543315533156331573315833159331603316133162331633316433165331663316733168331693317033171331723317333174331753317633177331783317933180331813318233183331843318533186331873318833189331903319133192331933319433195331963319733198331993320033201332023320333204332053320633207332083320933210332113321233213332143321533216332173321833219332203322133222332233322433225332263322733228332293323033231332323323333234332353323633237332383323933240332413324233243332443324533246332473324833249332503325133252332533325433255332563325733258332593326033261332623326333264332653326633267332683326933270332713327233273332743327533276332773327833279332803328133282332833328433285332863328733288332893329033291332923329333294332953329633297332983329933300333013330233303333043330533306333073330833309333103331133312333133331433315333163331733318333193332033321333223332333324333253332633327333283332933330333313333233333333343333533336333373333833339333403334133342333433334433345333463334733348333493335033351333523335333354333553335633357333583335933360333613336233363333643336533366333673336833369333703337133372333733337433375333763337733378333793338033381333823338333384333853338633387333883338933390333913339233393333943339533396333973339833399334003340133402334033340433405334063340733408334093341033411334123341333414334153341633417334183341933420334213342233423334243342533426334273342833429334303343133432334333343433435334363343733438334393344033441334423344333444334453344633447334483344933450334513345233453334543345533456334573345833459334603346133462334633346433465334663346733468334693347033471334723347333474334753347633477334783347933480334813348233483334843348533486334873348833489334903349133492334933349433495334963349733498334993350033501335023350333504335053350633507335083350933510335113351233513335143351533516335173351833519335203352133522335233352433525335263352733528335293353033531335323353333534335353353633537335383353933540335413354233543335443354533546335473354833549335503355133552335533355433555335563355733558335593356033561335623356333564335653356633567335683356933570335713357233573335743357533576335773357833579335803358133582335833358433585335863358733588335893359033591335923359333594335953359633597335983359933600336013360233603336043360533606336073360833609336103361133612336133361433615336163361733618336193362033621336223362333624336253362633627336283362933630336313363233633336343363533636336373363833639336403364133642336433364433645336463364733648336493365033651336523365333654336553365633657336583365933660336613366233663336643366533666336673366833669336703367133672336733367433675336763367733678336793368033681336823368333684336853368633687336883368933690336913369233693336943369533696336973369833699337003370133702337033370433705337063370733708337093371033711337123371333714337153371633717337183371933720337213372233723337243372533726337273372833729337303373133732337333373433735337363373733738337393374033741337423374333744337453374633747337483374933750337513375233753337543375533756337573375833759337603376133762337633376433765337663376733768337693377033771337723377333774337753377633777337783377933780337813378233783337843378533786337873378833789337903379133792337933379433795337963379733798337993380033801338023380333804338053380633807338083380933810338113381233813338143381533816338173381833819338203382133822338233382433825338263382733828338293383033831338323383333834338353383633837338383383933840338413384233843338443384533846338473384833849338503385133852338533385433855338563385733858338593386033861338623386333864338653386633867338683386933870338713387233873338743387533876338773387833879338803388133882338833388433885338863388733888338893389033891338923389333894338953389633897338983389933900339013390233903339043390533906339073390833909339103391133912339133391433915339163391733918339193392033921339223392333924339253392633927339283392933930339313393233933339343393533936339373393833939339403394133942339433394433945339463394733948339493395033951339523395333954339553395633957339583395933960339613396233963339643396533966339673396833969339703397133972339733397433975339763397733978339793398033981339823398333984339853398633987339883398933990339913399233993339943399533996339973399833999340003400134002340033400434005340063400734008340093401034011340123401334014340153401634017340183401934020340213402234023340243402534026340273402834029340303403134032340333403434035340363403734038340393404034041340423404334044340453404634047340483404934050340513405234053340543405534056340573405834059340603406134062340633406434065340663406734068340693407034071340723407334074340753407634077340783407934080340813408234083340843408534086340873408834089340903409134092340933409434095340963409734098340993410034101341023410334104341053410634107341083410934110341113411234113341143411534116341173411834119341203412134122341233412434125341263412734128341293413034131341323413334134341353413634137341383413934140341413414234143341443414534146341473414834149341503415134152341533415434155341563415734158341593416034161341623416334164341653416634167341683416934170341713417234173341743417534176341773417834179341803418134182341833418434185341863418734188341893419034191341923419334194341953419634197341983419934200342013420234203342043420534206342073420834209342103421134212342133421434215342163421734218342193422034221342223422334224342253422634227342283422934230342313423234233342343423534236342373423834239342403424134242342433424434245342463424734248342493425034251342523425334254342553425634257342583425934260342613426234263342643426534266342673426834269342703427134272342733427434275342763427734278342793428034281342823428334284342853428634287342883428934290342913429234293342943429534296342973429834299343003430134302343033430434305343063430734308343093431034311343123431334314343153431634317343183431934320343213432234323343243432534326343273432834329343303433134332343333433434335343363433734338343393434034341343423434334344343453434634347343483434934350343513435234353343543435534356343573435834359343603436134362343633436434365343663436734368343693437034371343723437334374343753437634377343783437934380343813438234383343843438534386343873438834389343903439134392343933439434395343963439734398343993440034401344023440334404344053440634407344083440934410344113441234413344143441534416344173441834419344203442134422344233442434425344263442734428344293443034431344323443334434344353443634437344383443934440344413444234443344443444534446344473444834449344503445134452344533445434455344563445734458344593446034461344623446334464344653446634467344683446934470344713447234473344743447534476344773447834479344803448134482344833448434485344863448734488344893449034491344923449334494344953449634497344983449934500345013450234503345043450534506345073450834509345103451134512345133451434515345163451734518345193452034521345223452334524345253452634527345283452934530345313453234533345343453534536345373453834539345403454134542345433454434545345463454734548345493455034551345523455334554345553455634557345583455934560345613456234563345643456534566345673456834569345703457134572345733457434575345763457734578345793458034581345823458334584345853458634587345883458934590345913459234593345943459534596345973459834599346003460134602346033460434605346063460734608346093461034611346123461334614346153461634617346183461934620346213462234623346243462534626346273462834629346303463134632346333463434635346363463734638346393464034641346423464334644346453464634647346483464934650346513465234653346543465534656346573465834659346603466134662346633466434665346663466734668346693467034671346723467334674346753467634677346783467934680346813468234683346843468534686346873468834689346903469134692346933469434695346963469734698346993470034701347023470334704347053470634707347083470934710347113471234713347143471534716347173471834719347203472134722347233472434725347263472734728347293473034731347323473334734347353473634737347383473934740347413474234743347443474534746347473474834749347503475134752347533475434755347563475734758347593476034761347623476334764347653476634767347683476934770347713477234773347743477534776347773477834779347803478134782347833478434785347863478734788347893479034791347923479334794347953479634797347983479934800348013480234803348043480534806348073480834809348103481134812348133481434815348163481734818348193482034821348223482334824348253482634827348283482934830348313483234833348343483534836348373483834839348403484134842348433484434845348463484734848348493485034851348523485334854348553485634857348583485934860348613486234863348643486534866348673486834869348703487134872348733487434875348763487734878348793488034881348823488334884348853488634887348883488934890348913489234893348943489534896348973489834899349003490134902349033490434905349063490734908349093491034911349123491334914349153491634917349183491934920349213492234923349243492534926349273492834929349303493134932349333493434935349363493734938349393494034941349423494334944349453494634947349483494934950349513495234953349543495534956349573495834959349603496134962349633496434965349663496734968349693497034971349723497334974349753497634977349783497934980349813498234983349843498534986349873498834989349903499134992349933499434995349963499734998349993500035001350023500335004350053500635007350083500935010350113501235013350143501535016350173501835019350203502135022350233502435025350263502735028350293503035031350323503335034350353503635037350383503935040350413504235043350443504535046350473504835049350503505135052350533505435055350563505735058350593506035061350623506335064350653506635067350683506935070350713507235073350743507535076350773507835079350803508135082350833508435085350863508735088350893509035091350923509335094350953509635097350983509935100351013510235103351043510535106351073510835109351103511135112351133511435115351163511735118351193512035121351223512335124351253512635127351283512935130351313513235133351343513535136351373513835139351403514135142351433514435145351463514735148351493515035151351523515335154351553515635157351583515935160351613516235163351643516535166351673516835169351703517135172351733517435175351763517735178351793518035181351823518335184351853518635187351883518935190351913519235193351943519535196351973519835199352003520135202352033520435205352063520735208352093521035211352123521335214352153521635217352183521935220352213522235223352243522535226352273522835229352303523135232352333523435235352363523735238352393524035241352423524335244352453524635247352483524935250352513525235253352543525535256352573525835259352603526135262352633526435265352663526735268352693527035271352723527335274352753527635277352783527935280352813528235283352843528535286352873528835289352903529135292352933529435295352963529735298352993530035301353023530335304353053530635307353083530935310353113531235313353143531535316353173531835319353203532135322353233532435325353263532735328353293533035331353323533335334353353533635337353383533935340353413534235343353443534535346353473534835349353503535135352353533535435355353563535735358353593536035361353623536335364353653536635367353683536935370353713537235373353743537535376353773537835379353803538135382353833538435385353863538735388353893539035391353923539335394353953539635397353983539935400354013540235403354043540535406354073540835409354103541135412354133541435415354163541735418354193542035421354223542335424354253542635427354283542935430354313543235433354343543535436354373543835439354403544135442354433544435445354463544735448354493545035451354523545335454354553545635457354583545935460354613546235463354643546535466354673546835469354703547135472354733547435475354763547735478354793548035481354823548335484354853548635487354883548935490354913549235493354943549535496354973549835499355003550135502355033550435505355063550735508355093551035511355123551335514355153551635517355183551935520355213552235523355243552535526355273552835529355303553135532355333553435535355363553735538355393554035541355423554335544355453554635547355483554935550355513555235553355543555535556355573555835559355603556135562355633556435565355663556735568355693557035571355723557335574355753557635577355783557935580355813558235583355843558535586355873558835589355903559135592355933559435595355963559735598355993560035601356023560335604356053560635607356083560935610356113561235613356143561535616356173561835619356203562135622356233562435625356263562735628356293563035631356323563335634356353563635637356383563935640356413564235643356443564535646356473564835649356503565135652356533565435655356563565735658356593566035661356623566335664356653566635667356683566935670356713567235673356743567535676356773567835679356803568135682356833568435685356863568735688356893569035691356923569335694356953569635697356983569935700357013570235703357043570535706357073570835709357103571135712357133571435715357163571735718357193572035721357223572335724357253572635727357283572935730357313573235733357343573535736357373573835739357403574135742357433574435745357463574735748357493575035751357523575335754357553575635757357583575935760357613576235763357643576535766357673576835769357703577135772357733577435775357763577735778357793578035781357823578335784357853578635787357883578935790357913579235793357943579535796357973579835799358003580135802358033580435805358063580735808358093581035811358123581335814358153581635817358183581935820358213582235823358243582535826358273582835829358303583135832358333583435835358363583735838358393584035841358423584335844358453584635847358483584935850358513585235853358543585535856358573585835859358603586135862358633586435865358663586735868358693587035871358723587335874358753587635877358783587935880358813588235883358843588535886358873588835889358903589135892358933589435895358963589735898358993590035901359023590335904359053590635907359083590935910359113591235913359143591535916359173591835919359203592135922359233592435925359263592735928359293593035931359323593335934359353593635937359383593935940359413594235943359443594535946359473594835949359503595135952359533595435955359563595735958359593596035961359623596335964359653596635967359683596935970359713597235973359743597535976359773597835979359803598135982359833598435985359863598735988359893599035991359923599335994359953599635997359983599936000360013600236003360043600536006360073600836009360103601136012360133601436015360163601736018360193602036021360223602336024360253602636027360283602936030360313603236033360343603536036360373603836039360403604136042360433604436045360463604736048360493605036051360523605336054360553605636057360583605936060360613606236063360643606536066360673606836069360703607136072360733607436075360763607736078360793608036081360823608336084360853608636087360883608936090360913609236093360943609536096360973609836099361003610136102361033610436105361063610736108361093611036111361123611336114361153611636117361183611936120361213612236123361243612536126361273612836129361303613136132361333613436135361363613736138361393614036141361423614336144361453614636147361483614936150361513615236153361543615536156361573615836159361603616136162361633616436165361663616736168361693617036171361723617336174361753617636177361783617936180361813618236183361843618536186361873618836189361903619136192361933619436195361963619736198361993620036201362023620336204362053620636207362083620936210362113621236213362143621536216362173621836219362203622136222362233622436225362263622736228362293623036231362323623336234362353623636237362383623936240362413624236243362443624536246362473624836249362503625136252362533625436255362563625736258362593626036261362623626336264362653626636267362683626936270362713627236273362743627536276362773627836279362803628136282362833628436285362863628736288362893629036291362923629336294362953629636297362983629936300363013630236303363043630536306363073630836309363103631136312363133631436315363163631736318363193632036321363223632336324363253632636327363283632936330363313633236333363343633536336363373633836339363403634136342363433634436345363463634736348363493635036351363523635336354363553635636357363583635936360363613636236363363643636536366363673636836369363703637136372363733637436375363763637736378363793638036381363823638336384363853638636387363883638936390363913639236393363943639536396363973639836399364003640136402364033640436405364063640736408364093641036411364123641336414364153641636417364183641936420364213642236423364243642536426364273642836429364303643136432364333643436435364363643736438364393644036441364423644336444364453644636447364483644936450364513645236453364543645536456364573645836459364603646136462364633646436465364663646736468364693647036471364723647336474364753647636477364783647936480364813648236483364843648536486364873648836489364903649136492364933649436495364963649736498364993650036501365023650336504365053650636507365083650936510365113651236513365143651536516365173651836519365203652136522365233652436525365263652736528365293653036531365323653336534365353653636537365383653936540365413654236543365443654536546365473654836549365503655136552365533655436555365563655736558365593656036561365623656336564365653656636567365683656936570365713657236573365743657536576365773657836579365803658136582365833658436585365863658736588365893659036591365923659336594365953659636597365983659936600366013660236603366043660536606366073660836609366103661136612366133661436615366163661736618366193662036621366223662336624366253662636627366283662936630366313663236633366343663536636366373663836639366403664136642366433664436645366463664736648366493665036651366523665336654366553665636657366583665936660366613666236663366643666536666366673666836669366703667136672366733667436675366763667736678366793668036681366823668336684366853668636687366883668936690366913669236693366943669536696366973669836699367003670136702367033670436705367063670736708367093671036711367123671336714367153671636717367183671936720367213672236723367243672536726367273672836729367303673136732367333673436735367363673736738367393674036741367423674336744367453674636747367483674936750367513675236753367543675536756367573675836759367603676136762367633676436765367663676736768367693677036771367723677336774367753677636777367783677936780367813678236783367843678536786367873678836789367903679136792367933679436795367963679736798367993680036801368023680336804368053680636807368083680936810368113681236813368143681536816368173681836819368203682136822368233682436825368263682736828368293683036831368323683336834368353683636837368383683936840368413684236843368443684536846368473684836849368503685136852368533685436855368563685736858368593686036861368623686336864368653686636867368683686936870368713687236873368743687536876368773687836879368803688136882368833688436885368863688736888368893689036891368923689336894368953689636897368983689936900369013690236903369043690536906369073690836909369103691136912369133691436915369163691736918369193692036921369223692336924369253692636927369283692936930369313693236933369343693536936369373693836939369403694136942369433694436945369463694736948369493695036951369523695336954369553695636957369583695936960369613696236963369643696536966369673696836969369703697136972369733697436975369763697736978369793698036981369823698336984369853698636987369883698936990369913699236993369943699536996369973699836999370003700137002370033700437005370063700737008370093701037011370123701337014370153701637017370183701937020370213702237023370243702537026370273702837029370303703137032370333703437035370363703737038370393704037041370423704337044370453704637047370483704937050370513705237053370543705537056370573705837059370603706137062370633706437065370663706737068370693707037071370723707337074370753707637077370783707937080370813708237083370843708537086370873708837089370903709137092370933709437095370963709737098370993710037101371023710337104371053710637107371083710937110371113711237113371143711537116371173711837119371203712137122371233712437125371263712737128371293713037131371323713337134371353713637137371383713937140371413714237143371443714537146371473714837149371503715137152371533715437155371563715737158371593716037161371623716337164371653716637167371683716937170371713717237173371743717537176371773717837179371803718137182371833718437185371863718737188371893719037191371923719337194371953719637197371983719937200372013720237203372043720537206372073720837209372103721137212372133721437215372163721737218372193722037221372223722337224372253722637227372283722937230372313723237233372343723537236372373723837239372403724137242372433724437245372463724737248372493725037251372523725337254372553725637257372583725937260372613726237263372643726537266372673726837269372703727137272372733727437275372763727737278372793728037281372823728337284372853728637287372883728937290372913729237293372943729537296372973729837299373003730137302373033730437305373063730737308373093731037311373123731337314373153731637317373183731937320373213732237323373243732537326373273732837329373303733137332373333733437335373363733737338373393734037341373423734337344373453734637347373483734937350373513735237353373543735537356373573735837359373603736137362373633736437365373663736737368373693737037371373723737337374373753737637377373783737937380373813738237383373843738537386373873738837389373903739137392373933739437395373963739737398373993740037401374023740337404374053740637407374083740937410374113741237413374143741537416374173741837419374203742137422374233742437425374263742737428374293743037431374323743337434374353743637437374383743937440374413744237443374443744537446374473744837449374503745137452374533745437455374563745737458374593746037461374623746337464374653746637467374683746937470374713747237473374743747537476374773747837479374803748137482374833748437485374863748737488374893749037491374923749337494374953749637497374983749937500375013750237503375043750537506375073750837509375103751137512375133751437515375163751737518375193752037521375223752337524375253752637527375283752937530375313753237533375343753537536375373753837539375403754137542375433754437545375463754737548375493755037551375523755337554375553755637557375583755937560375613756237563375643756537566375673756837569375703757137572375733757437575375763757737578375793758037581375823758337584375853758637587375883758937590375913759237593375943759537596375973759837599376003760137602376033760437605376063760737608376093761037611376123761337614376153761637617376183761937620376213762237623376243762537626376273762837629376303763137632376333763437635376363763737638376393764037641376423764337644376453764637647376483764937650376513765237653376543765537656376573765837659376603766137662376633766437665376663766737668376693767037671376723767337674376753767637677376783767937680376813768237683376843768537686376873768837689376903769137692376933769437695376963769737698376993770037701377023770337704377053770637707377083770937710377113771237713377143771537716377173771837719377203772137722377233772437725377263772737728377293773037731377323773337734377353773637737377383773937740377413774237743377443774537746377473774837749377503775137752377533775437755377563775737758377593776037761377623776337764377653776637767377683776937770377713777237773377743777537776377773777837779377803778137782377833778437785377863778737788377893779037791377923779337794377953779637797377983779937800378013780237803378043780537806378073780837809378103781137812378133781437815378163781737818378193782037821378223782337824378253782637827378283782937830378313783237833378343783537836378373783837839378403784137842378433784437845378463784737848378493785037851378523785337854378553785637857378583785937860378613786237863378643786537866378673786837869378703787137872378733787437875378763787737878378793788037881378823788337884378853788637887378883788937890378913789237893378943789537896378973789837899379003790137902379033790437905379063790737908379093791037911379123791337914379153791637917379183791937920379213792237923379243792537926379273792837929379303793137932379333793437935379363793737938379393794037941379423794337944379453794637947379483794937950379513795237953379543795537956379573795837959379603796137962379633796437965379663796737968379693797037971379723797337974379753797637977379783797937980379813798237983379843798537986379873798837989379903799137992379933799437995379963799737998379993800038001380023800338004380053800638007380083800938010380113801238013380143801538016380173801838019380203802138022380233802438025380263802738028380293803038031380323803338034380353803638037380383803938040380413804238043380443804538046380473804838049380503805138052380533805438055380563805738058380593806038061380623806338064380653806638067380683806938070380713807238073380743807538076380773807838079380803808138082380833808438085380863808738088380893809038091380923809338094380953809638097380983809938100381013810238103381043810538106381073810838109381103811138112381133811438115381163811738118381193812038121381223812338124381253812638127381283812938130381313813238133381343813538136381373813838139381403814138142381433814438145381463814738148381493815038151381523815338154381553815638157381583815938160381613816238163381643816538166381673816838169381703817138172381733817438175381763817738178381793818038181381823818338184381853818638187381883818938190381913819238193381943819538196381973819838199382003820138202382033820438205382063820738208382093821038211382123821338214382153821638217382183821938220382213822238223382243822538226382273822838229382303823138232382333823438235382363823738238382393824038241382423824338244382453824638247382483824938250382513825238253382543825538256382573825838259382603826138262382633826438265382663826738268382693827038271382723827338274382753827638277382783827938280382813828238283382843828538286382873828838289382903829138292382933829438295382963829738298382993830038301383023830338304383053830638307383083830938310383113831238313383143831538316383173831838319383203832138322383233832438325383263832738328383293833038331383323833338334383353833638337383383833938340383413834238343383443834538346383473834838349383503835138352383533835438355383563835738358383593836038361383623836338364383653836638367383683836938370383713837238373383743837538376383773837838379383803838138382383833838438385383863838738388383893839038391383923839338394383953839638397383983839938400384013840238403384043840538406384073840838409384103841138412384133841438415384163841738418384193842038421384223842338424384253842638427384283842938430384313843238433384343843538436384373843838439384403844138442384433844438445384463844738448384493845038451384523845338454384553845638457384583845938460384613846238463384643846538466384673846838469384703847138472384733847438475384763847738478384793848038481384823848338484384853848638487384883848938490384913849238493384943849538496384973849838499385003850138502385033850438505385063850738508385093851038511385123851338514385153851638517385183851938520385213852238523385243852538526385273852838529385303853138532385333853438535385363853738538385393854038541385423854338544385453854638547385483854938550385513855238553385543855538556385573855838559385603856138562385633856438565385663856738568385693857038571385723857338574385753857638577385783857938580385813858238583385843858538586385873858838589385903859138592385933859438595385963859738598385993860038601386023860338604386053860638607386083860938610386113861238613386143861538616386173861838619386203862138622386233862438625386263862738628386293863038631386323863338634386353863638637386383863938640386413864238643386443864538646386473864838649386503865138652386533865438655386563865738658386593866038661386623866338664386653866638667386683866938670386713867238673386743867538676386773867838679386803868138682386833868438685386863868738688386893869038691386923869338694386953869638697386983869938700387013870238703387043870538706387073870838709387103871138712387133871438715387163871738718387193872038721387223872338724387253872638727387283872938730387313873238733387343873538736387373873838739387403874138742387433874438745387463874738748387493875038751387523875338754387553875638757387583875938760387613876238763387643876538766387673876838769387703877138772387733877438775387763877738778387793878038781387823878338784387853878638787387883878938790387913879238793387943879538796387973879838799388003880138802388033880438805388063880738808388093881038811388123881338814388153881638817388183881938820388213882238823388243882538826388273882838829388303883138832388333883438835388363883738838388393884038841388423884338844388453884638847388483884938850388513885238853388543885538856388573885838859388603886138862388633886438865388663886738868388693887038871388723887338874388753887638877388783887938880388813888238883388843888538886388873888838889388903889138892388933889438895388963889738898388993890038901389023890338904389053890638907389083890938910389113891238913389143891538916389173891838919389203892138922389233892438925389263892738928389293893038931389323893338934389353893638937389383893938940389413894238943389443894538946389473894838949389503895138952389533895438955389563895738958389593896038961389623896338964389653896638967389683896938970389713897238973389743897538976389773897838979389803898138982389833898438985389863898738988389893899038991389923899338994389953899638997389983899939000390013900239003390043900539006390073900839009390103901139012390133901439015390163901739018390193902039021390223902339024390253902639027390283902939030390313903239033390343903539036390373903839039390403904139042390433904439045390463904739048390493905039051390523905339054390553905639057390583905939060390613906239063390643906539066390673906839069390703907139072390733907439075390763907739078390793908039081390823908339084390853908639087390883908939090390913909239093390943909539096390973909839099391003910139102391033910439105391063910739108391093911039111391123911339114391153911639117391183911939120391213912239123391243912539126391273912839129391303913139132391333913439135391363913739138391393914039141391423914339144391453914639147391483914939150391513915239153391543915539156391573915839159391603916139162391633916439165391663916739168391693917039171391723917339174391753917639177391783917939180391813918239183391843918539186391873918839189391903919139192391933919439195391963919739198391993920039201392023920339204392053920639207392083920939210392113921239213392143921539216392173921839219392203922139222392233922439225392263922739228392293923039231392323923339234392353923639237392383923939240392413924239243392443924539246392473924839249392503925139252392533925439255392563925739258392593926039261392623926339264392653926639267392683926939270392713927239273392743927539276392773927839279392803928139282392833928439285392863928739288392893929039291392923929339294392953929639297392983929939300393013930239303393043930539306393073930839309393103931139312393133931439315393163931739318393193932039321393223932339324393253932639327393283932939330393313933239333393343933539336393373933839339393403934139342393433934439345393463934739348393493935039351393523935339354393553935639357393583935939360393613936239363393643936539366393673936839369393703937139372393733937439375393763937739378393793938039381393823938339384393853938639387393883938939390393913939239393393943939539396393973939839399394003940139402394033940439405394063940739408394093941039411394123941339414394153941639417394183941939420394213942239423394243942539426394273942839429394303943139432394333943439435394363943739438394393944039441394423944339444394453944639447394483944939450394513945239453394543945539456394573945839459394603946139462394633946439465394663946739468394693947039471394723947339474394753947639477394783947939480394813948239483394843948539486394873948839489394903949139492394933949439495394963949739498394993950039501395023950339504395053950639507395083950939510395113951239513395143951539516395173951839519395203952139522395233952439525395263952739528395293953039531395323953339534395353953639537395383953939540395413954239543395443954539546395473954839549395503955139552395533955439555395563955739558395593956039561395623956339564395653956639567395683956939570395713957239573395743957539576395773957839579395803958139582395833958439585395863958739588395893959039591395923959339594395953959639597395983959939600396013960239603396043960539606396073960839609396103961139612396133961439615396163961739618396193962039621396223962339624396253962639627396283962939630396313963239633396343963539636396373963839639396403964139642396433964439645396463964739648396493965039651396523965339654396553965639657396583965939660396613966239663396643966539666396673966839669396703967139672396733967439675396763967739678396793968039681396823968339684396853968639687396883968939690396913969239693396943969539696396973969839699397003970139702397033970439705397063970739708397093971039711397123971339714397153971639717397183971939720397213972239723397243972539726397273972839729397303973139732397333973439735397363973739738397393974039741397423974339744397453974639747397483974939750397513975239753397543975539756397573975839759397603976139762397633976439765397663976739768397693977039771397723977339774397753977639777397783977939780397813978239783397843978539786397873978839789397903979139792397933979439795397963979739798397993980039801398023980339804398053980639807398083980939810398113981239813398143981539816398173981839819398203982139822398233982439825398263982739828398293983039831398323983339834398353983639837398383983939840398413984239843398443984539846398473984839849398503985139852398533985439855398563985739858398593986039861398623986339864398653986639867398683986939870398713987239873398743987539876398773987839879398803988139882398833988439885398863988739888398893989039891398923989339894398953989639897398983989939900399013990239903399043990539906399073990839909399103991139912399133991439915399163991739918399193992039921399223992339924399253992639927399283992939930399313993239933399343993539936399373993839939399403994139942399433994439945399463994739948399493995039951399523995339954399553995639957399583995939960399613996239963399643996539966399673996839969399703997139972399733997439975399763997739978399793998039981399823998339984399853998639987399883998939990399913999239993399943999539996399973999839999400004000140002400034000440005400064000740008400094001040011400124001340014400154001640017400184001940020400214002240023400244002540026400274002840029400304003140032400334003440035400364003740038400394004040041400424004340044400454004640047400484004940050400514005240053400544005540056400574005840059400604006140062400634006440065400664006740068400694007040071400724007340074400754007640077400784007940080400814008240083400844008540086400874008840089400904009140092400934009440095400964009740098400994010040101401024010340104401054010640107401084010940110401114011240113401144011540116401174011840119401204012140122401234012440125401264012740128401294013040131401324013340134401354013640137401384013940140401414014240143401444014540146401474014840149401504015140152401534015440155401564015740158401594016040161401624016340164401654016640167401684016940170401714017240173401744017540176401774017840179401804018140182401834018440185401864018740188401894019040191401924019340194401954019640197401984019940200402014020240203402044020540206402074020840209402104021140212402134021440215402164021740218402194022040221402224022340224402254022640227402284022940230402314023240233402344023540236402374023840239402404024140242402434024440245402464024740248402494025040251402524025340254402554025640257402584025940260402614026240263402644026540266402674026840269402704027140272402734027440275402764027740278402794028040281402824028340284402854028640287402884028940290402914029240293402944029540296402974029840299403004030140302403034030440305403064030740308403094031040311403124031340314403154031640317403184031940320403214032240323403244032540326403274032840329403304033140332403334033440335403364033740338403394034040341403424034340344403454034640347403484034940350403514035240353403544035540356403574035840359403604036140362403634036440365403664036740368403694037040371403724037340374403754037640377403784037940380403814038240383403844038540386403874038840389403904039140392403934039440395403964039740398403994040040401404024040340404404054040640407404084040940410404114041240413404144041540416404174041840419404204042140422404234042440425404264042740428404294043040431404324043340434404354043640437404384043940440404414044240443404444044540446404474044840449404504045140452404534045440455404564045740458404594046040461404624046340464404654046640467404684046940470404714047240473404744047540476404774047840479404804048140482404834048440485404864048740488404894049040491404924049340494404954049640497404984049940500405014050240503405044050540506405074050840509405104051140512405134051440515405164051740518405194052040521405224052340524405254052640527405284052940530405314053240533405344053540536405374053840539405404054140542405434054440545405464054740548405494055040551405524055340554405554055640557405584055940560405614056240563405644056540566405674056840569405704057140572405734057440575405764057740578405794058040581405824058340584405854058640587405884058940590405914059240593405944059540596405974059840599406004060140602406034060440605406064060740608406094061040611406124061340614406154061640617406184061940620406214062240623406244062540626406274062840629406304063140632406334063440635406364063740638406394064040641406424064340644406454064640647406484064940650406514065240653406544065540656406574065840659406604066140662406634066440665406664066740668406694067040671406724067340674406754067640677406784067940680406814068240683406844068540686406874068840689406904069140692406934069440695406964069740698406994070040701407024070340704407054070640707407084070940710407114071240713407144071540716407174071840719407204072140722407234072440725407264072740728407294073040731407324073340734407354073640737407384073940740407414074240743407444074540746407474074840749407504075140752407534075440755407564075740758407594076040761407624076340764407654076640767407684076940770407714077240773407744077540776407774077840779407804078140782407834078440785407864078740788407894079040791407924079340794407954079640797407984079940800408014080240803408044080540806408074080840809408104081140812408134081440815408164081740818408194082040821408224082340824408254082640827408284082940830408314083240833408344083540836408374083840839408404084140842408434084440845408464084740848408494085040851408524085340854408554085640857408584085940860408614086240863408644086540866408674086840869408704087140872408734087440875408764087740878408794088040881408824088340884408854088640887408884088940890408914089240893408944089540896408974089840899409004090140902409034090440905409064090740908409094091040911409124091340914409154091640917409184091940920409214092240923409244092540926409274092840929409304093140932409334093440935409364093740938409394094040941409424094340944409454094640947409484094940950409514095240953409544095540956409574095840959409604096140962409634096440965409664096740968409694097040971409724097340974409754097640977409784097940980409814098240983409844098540986409874098840989409904099140992409934099440995409964099740998409994100041001410024100341004410054100641007410084100941010410114101241013410144101541016410174101841019410204102141022410234102441025410264102741028410294103041031410324103341034410354103641037410384103941040410414104241043410444104541046410474104841049410504105141052410534105441055410564105741058410594106041061410624106341064410654106641067410684106941070410714107241073410744107541076410774107841079410804108141082410834108441085410864108741088410894109041091410924109341094410954109641097410984109941100411014110241103411044110541106411074110841109411104111141112411134111441115411164111741118411194112041121411224112341124411254112641127411284112941130411314113241133411344113541136411374113841139411404114141142411434114441145411464114741148411494115041151411524115341154411554115641157411584115941160411614116241163411644116541166411674116841169411704117141172411734117441175411764117741178411794118041181411824118341184411854118641187411884118941190411914119241193411944119541196411974119841199412004120141202412034120441205412064120741208412094121041211412124121341214412154121641217412184121941220412214122241223412244122541226412274122841229412304123141232412334123441235412364123741238412394124041241412424124341244412454124641247412484124941250412514125241253412544125541256412574125841259412604126141262412634126441265412664126741268412694127041271412724127341274412754127641277412784127941280412814128241283412844128541286412874128841289412904129141292412934129441295412964129741298412994130041301413024130341304413054130641307413084130941310413114131241313413144131541316413174131841319413204132141322413234132441325413264132741328413294133041331413324133341334413354133641337413384133941340413414134241343413444134541346413474134841349413504135141352413534135441355413564135741358413594136041361413624136341364413654136641367413684136941370413714137241373413744137541376413774137841379413804138141382413834138441385413864138741388413894139041391413924139341394413954139641397413984139941400414014140241403414044140541406414074140841409414104141141412414134141441415414164141741418414194142041421414224142341424414254142641427414284142941430414314143241433414344143541436414374143841439414404144141442414434144441445414464144741448414494145041451414524145341454414554145641457414584145941460414614146241463414644146541466414674146841469414704147141472414734147441475414764147741478414794148041481414824148341484414854148641487414884148941490414914149241493414944149541496414974149841499415004150141502415034150441505415064150741508415094151041511415124151341514415154151641517415184151941520415214152241523415244152541526415274152841529415304153141532415334153441535415364153741538415394154041541415424154341544415454154641547415484154941550415514155241553415544155541556415574155841559415604156141562415634156441565415664156741568415694157041571415724157341574415754157641577415784157941580415814158241583415844158541586415874158841589415904159141592415934159441595415964159741598415994160041601416024160341604416054160641607416084160941610416114161241613416144161541616416174161841619416204162141622416234162441625416264162741628416294163041631416324163341634416354163641637416384163941640416414164241643416444164541646416474164841649416504165141652416534165441655416564165741658416594166041661416624166341664416654166641667416684166941670416714167241673416744167541676416774167841679416804168141682416834168441685416864168741688416894169041691416924169341694416954169641697416984169941700417014170241703417044170541706417074170841709417104171141712417134171441715417164171741718417194172041721417224172341724417254172641727417284172941730417314173241733417344173541736417374173841739417404174141742417434174441745417464174741748417494175041751417524175341754417554175641757417584175941760417614176241763417644176541766417674176841769417704177141772417734177441775417764177741778417794178041781417824178341784417854178641787417884178941790417914179241793417944179541796417974179841799418004180141802418034180441805418064180741808418094181041811418124181341814418154181641817418184181941820418214182241823418244182541826418274182841829418304183141832418334183441835418364183741838418394184041841418424184341844418454184641847418484184941850418514185241853418544185541856418574185841859418604186141862418634186441865418664186741868418694187041871418724187341874418754187641877418784187941880418814188241883418844188541886418874188841889418904189141892418934189441895418964189741898418994190041901419024190341904419054190641907419084190941910419114191241913419144191541916419174191841919419204192141922419234192441925419264192741928419294193041931419324193341934419354193641937419384193941940419414194241943419444194541946419474194841949419504195141952419534195441955419564195741958419594196041961419624196341964419654196641967419684196941970419714197241973419744197541976419774197841979419804198141982419834198441985419864198741988419894199041991419924199341994419954199641997419984199942000420014200242003420044200542006420074200842009420104201142012420134201442015420164201742018420194202042021420224202342024420254202642027420284202942030420314203242033420344203542036420374203842039420404204142042420434204442045420464204742048420494205042051420524205342054420554205642057420584205942060420614206242063420644206542066420674206842069420704207142072420734207442075420764207742078420794208042081420824208342084420854208642087420884208942090420914209242093420944209542096420974209842099421004210142102421034210442105421064210742108421094211042111421124211342114421154211642117421184211942120421214212242123421244212542126421274212842129421304213142132421334213442135421364213742138421394214042141421424214342144421454214642147421484214942150421514215242153421544215542156421574215842159421604216142162421634216442165421664216742168421694217042171421724217342174421754217642177421784217942180421814218242183421844218542186421874218842189421904219142192421934219442195421964219742198421994220042201422024220342204422054220642207422084220942210422114221242213422144221542216422174221842219422204222142222422234222442225422264222742228422294223042231422324223342234422354223642237422384223942240422414224242243422444224542246422474224842249422504225142252422534225442255422564225742258422594226042261422624226342264422654226642267422684226942270422714227242273422744227542276422774227842279422804228142282422834228442285422864228742288422894229042291422924229342294422954229642297422984229942300423014230242303423044230542306423074230842309423104231142312423134231442315423164231742318423194232042321423224232342324423254232642327423284232942330423314233242333423344233542336423374233842339423404234142342423434234442345423464234742348423494235042351423524235342354423554235642357423584235942360423614236242363423644236542366423674236842369423704237142372423734237442375423764237742378423794238042381423824238342384423854238642387423884238942390423914239242393423944239542396423974239842399424004240142402424034240442405424064240742408424094241042411424124241342414424154241642417424184241942420424214242242423424244242542426424274242842429424304243142432424334243442435424364243742438424394244042441424424244342444424454244642447424484244942450424514245242453424544245542456424574245842459424604246142462424634246442465424664246742468424694247042471424724247342474424754247642477424784247942480424814248242483424844248542486424874248842489424904249142492424934249442495424964249742498424994250042501425024250342504425054250642507425084250942510425114251242513425144251542516425174251842519425204252142522425234252442525425264252742528425294253042531425324253342534425354253642537425384253942540425414254242543425444254542546425474254842549425504255142552425534255442555425564255742558425594256042561425624256342564425654256642567425684256942570425714257242573425744257542576425774257842579425804258142582425834258442585425864258742588425894259042591425924259342594425954259642597425984259942600426014260242603426044260542606426074260842609426104261142612426134261442615426164261742618426194262042621426224262342624426254262642627426284262942630426314263242633426344263542636426374263842639426404264142642426434264442645426464264742648426494265042651426524265342654426554265642657426584265942660426614266242663426644266542666426674266842669426704267142672426734267442675426764267742678426794268042681426824268342684426854268642687426884268942690426914269242693426944269542696426974269842699427004270142702427034270442705427064270742708427094271042711427124271342714427154271642717427184271942720427214272242723427244272542726427274272842729427304273142732427334273442735427364273742738427394274042741427424274342744427454274642747427484274942750427514275242753427544275542756427574275842759427604276142762427634276442765427664276742768427694277042771427724277342774427754277642777427784277942780427814278242783427844278542786427874278842789427904279142792427934279442795427964279742798427994280042801428024280342804428054280642807428084280942810428114281242813428144281542816428174281842819428204282142822428234282442825428264282742828428294283042831428324283342834428354283642837428384283942840428414284242843428444284542846428474284842849428504285142852428534285442855428564285742858428594286042861428624286342864428654286642867428684286942870428714287242873428744287542876428774287842879428804288142882428834288442885428864288742888428894289042891428924289342894428954289642897428984289942900429014290242903429044290542906429074290842909429104291142912429134291442915429164291742918429194292042921429224292342924429254292642927429284292942930429314293242933429344293542936429374293842939429404294142942429434294442945429464294742948429494295042951429524295342954429554295642957429584295942960429614296242963429644296542966429674296842969429704297142972429734297442975429764297742978429794298042981429824298342984429854298642987429884298942990429914299242993429944299542996429974299842999430004300143002430034300443005430064300743008430094301043011430124301343014430154301643017430184301943020430214302243023430244302543026430274302843029430304303143032430334303443035430364303743038430394304043041430424304343044430454304643047430484304943050430514305243053430544305543056430574305843059430604306143062430634306443065430664306743068430694307043071430724307343074430754307643077430784307943080430814308243083430844308543086430874308843089430904309143092430934309443095430964309743098430994310043101431024310343104431054310643107431084310943110431114311243113431144311543116431174311843119431204312143122431234312443125431264312743128431294313043131431324313343134431354313643137431384313943140431414314243143431444314543146431474314843149431504315143152431534315443155431564315743158431594316043161431624316343164431654316643167431684316943170431714317243173431744317543176431774317843179431804318143182431834318443185431864318743188431894319043191431924319343194431954319643197431984319943200432014320243203432044320543206432074320843209432104321143212432134321443215432164321743218432194322043221432224322343224432254322643227432284322943230432314323243233432344323543236432374323843239432404324143242432434324443245432464324743248432494325043251432524325343254432554325643257432584325943260432614326243263432644326543266432674326843269432704327143272432734327443275432764327743278432794328043281432824328343284432854328643287432884328943290432914329243293432944329543296432974329843299433004330143302433034330443305433064330743308433094331043311433124331343314433154331643317433184331943320433214332243323433244332543326433274332843329433304333143332433334333443335433364333743338433394334043341433424334343344433454334643347433484334943350433514335243353433544335543356433574335843359433604336143362433634336443365433664336743368433694337043371433724337343374433754337643377433784337943380433814338243383433844338543386433874338843389433904339143392433934339443395433964339743398433994340043401434024340343404434054340643407434084340943410434114341243413434144341543416434174341843419434204342143422434234342443425434264342743428434294343043431434324343343434434354343643437434384343943440434414344243443434444344543446434474344843449434504345143452434534345443455434564345743458434594346043461434624346343464434654346643467434684346943470434714347243473434744347543476434774347843479434804348143482434834348443485434864348743488434894349043491434924349343494434954349643497434984349943500435014350243503435044350543506435074350843509435104351143512435134351443515435164351743518435194352043521435224352343524435254352643527435284352943530435314353243533435344353543536435374353843539435404354143542435434354443545435464354743548435494355043551435524355343554435554355643557435584355943560435614356243563435644356543566435674356843569435704357143572435734357443575435764357743578435794358043581435824358343584435854358643587435884358943590435914359243593435944359543596435974359843599436004360143602436034360443605436064360743608436094361043611436124361343614436154361643617436184361943620436214362243623436244362543626436274362843629436304363143632436334363443635436364363743638436394364043641436424364343644436454364643647436484364943650436514365243653436544365543656436574365843659436604366143662436634366443665436664366743668436694367043671436724367343674436754367643677436784367943680436814368243683436844368543686436874368843689436904369143692436934369443695436964369743698436994370043701437024370343704437054370643707437084370943710437114371243713437144371543716437174371843719437204372143722437234372443725437264372743728437294373043731437324373343734437354373643737437384373943740437414374243743437444374543746437474374843749437504375143752437534375443755437564375743758437594376043761437624376343764437654376643767437684376943770437714377243773437744377543776437774377843779437804378143782437834378443785437864378743788437894379043791437924379343794437954379643797437984379943800438014380243803438044380543806438074380843809438104381143812438134381443815438164381743818438194382043821438224382343824438254382643827438284382943830438314383243833438344383543836438374383843839438404384143842438434384443845438464384743848438494385043851438524385343854438554385643857438584385943860438614386243863438644386543866438674386843869438704387143872438734387443875438764387743878438794388043881438824388343884438854388643887438884388943890438914389243893438944389543896438974389843899439004390143902439034390443905439064390743908439094391043911439124391343914439154391643917439184391943920439214392243923439244392543926439274392843929439304393143932439334393443935439364393743938439394394043941439424394343944439454394643947439484394943950439514395243953439544395543956439574395843959439604396143962439634396443965439664396743968439694397043971439724397343974439754397643977439784397943980439814398243983439844398543986439874398843989439904399143992439934399443995439964399743998439994400044001440024400344004440054400644007440084400944010440114401244013440144401544016440174401844019440204402144022440234402444025440264402744028440294403044031440324403344034440354403644037440384403944040440414404244043440444404544046440474404844049440504405144052440534405444055440564405744058440594406044061440624406344064440654406644067440684406944070440714407244073440744407544076440774407844079440804408144082440834408444085440864408744088440894409044091440924409344094440954409644097440984409944100441014410244103441044410544106441074410844109441104411144112441134411444115441164411744118441194412044121441224412344124441254412644127441284412944130441314413244133441344413544136441374413844139441404414144142441434414444145441464414744148441494415044151441524415344154441554415644157441584415944160441614416244163441644416544166441674416844169441704417144172441734417444175441764417744178441794418044181441824418344184441854418644187441884418944190441914419244193441944419544196441974419844199442004420144202442034420444205442064420744208442094421044211442124421344214442154421644217442184421944220442214422244223442244422544226442274422844229442304423144232442334423444235442364423744238442394424044241442424424344244442454424644247442484424944250442514425244253442544425544256442574425844259442604426144262442634426444265442664426744268442694427044271442724427344274442754427644277442784427944280442814428244283442844428544286442874428844289442904429144292442934429444295442964429744298442994430044301443024430344304443054430644307443084430944310443114431244313443144431544316443174431844319443204432144322443234432444325443264432744328443294433044331443324433344334443354433644337443384433944340443414434244343443444434544346443474434844349443504435144352443534435444355443564435744358443594436044361443624436344364443654436644367443684436944370443714437244373443744437544376443774437844379443804438144382443834438444385443864438744388443894439044391443924439344394443954439644397443984439944400444014440244403444044440544406444074440844409444104441144412444134441444415444164441744418444194442044421444224442344424444254442644427444284442944430444314443244433444344443544436444374443844439444404444144442444434444444445444464444744448444494445044451444524445344454444554445644457444584445944460444614446244463444644446544466444674446844469444704447144472444734447444475444764447744478444794448044481444824448344484444854448644487444884448944490444914449244493444944449544496444974449844499445004450144502445034450444505445064450744508445094451044511445124451344514445154451644517445184451944520445214452244523445244452544526445274452844529445304453144532445334453444535445364453744538445394454044541445424454344544445454454644547445484454944550445514455244553445544455544556445574455844559445604456144562445634456444565445664456744568445694457044571445724457344574445754457644577445784457944580445814458244583445844458544586445874458844589445904459144592445934459444595445964459744598445994460044601446024460344604446054460644607446084460944610446114461244613446144461544616446174461844619446204462144622446234462444625446264462744628446294463044631446324463344634446354463644637446384463944640446414464244643446444464544646446474464844649446504465144652446534465444655446564465744658446594466044661446624466344664446654466644667446684466944670446714467244673446744467544676446774467844679446804468144682446834468444685446864468744688446894469044691446924469344694446954469644697446984469944700447014470244703447044470544706447074470844709447104471144712447134471444715447164471744718447194472044721447224472344724447254472644727447284472944730447314473244733447344473544736447374473844739447404474144742447434474444745447464474744748447494475044751447524475344754447554475644757447584475944760447614476244763447644476544766447674476844769447704477144772447734477444775447764477744778447794478044781447824478344784447854478644787447884478944790447914479244793447944479544796447974479844799448004480144802448034480444805448064480744808448094481044811448124481344814448154481644817448184481944820448214482244823448244482544826448274482844829448304483144832448334483444835448364483744838448394484044841448424484344844448454484644847448484484944850448514485244853448544485544856448574485844859448604486144862448634486444865448664486744868448694487044871448724487344874448754487644877448784487944880448814488244883448844488544886448874488844889448904489144892448934489444895448964489744898448994490044901449024490344904449054490644907449084490944910449114491244913449144491544916449174491844919449204492144922449234492444925449264492744928449294493044931449324493344934449354493644937449384493944940449414494244943449444494544946449474494844949449504495144952449534495444955449564495744958449594496044961449624496344964449654496644967449684496944970449714497244973449744497544976449774497844979449804498144982449834498444985449864498744988449894499044991449924499344994449954499644997449984499945000450014500245003450044500545006450074500845009450104501145012450134501445015450164501745018450194502045021450224502345024450254502645027450284502945030450314503245033450344503545036450374503845039450404504145042450434504445045450464504745048450494505045051450524505345054450554505645057450584505945060450614506245063450644506545066450674506845069450704507145072450734507445075450764507745078450794508045081450824508345084450854508645087450884508945090450914509245093450944509545096450974509845099451004510145102451034510445105451064510745108451094511045111451124511345114451154511645117451184511945120451214512245123451244512545126451274512845129451304513145132451334513445135451364513745138451394514045141451424514345144451454514645147451484514945150451514515245153451544515545156451574515845159451604516145162451634516445165451664516745168451694517045171451724517345174451754517645177451784517945180451814518245183451844518545186451874518845189451904519145192451934519445195451964519745198451994520045201452024520345204452054520645207452084520945210452114521245213452144521545216452174521845219452204522145222452234522445225452264522745228452294523045231452324523345234452354523645237452384523945240452414524245243452444524545246452474524845249452504525145252452534525445255452564525745258452594526045261452624526345264452654526645267452684526945270452714527245273452744527545276452774527845279452804528145282452834528445285452864528745288452894529045291452924529345294452954529645297452984529945300453014530245303453044530545306453074530845309453104531145312453134531445315453164531745318453194532045321453224532345324453254532645327453284532945330453314533245333453344533545336453374533845339453404534145342453434534445345453464534745348453494535045351453524535345354453554535645357453584535945360453614536245363453644536545366453674536845369453704537145372453734537445375453764537745378453794538045381453824538345384453854538645387453884538945390453914539245393453944539545396453974539845399454004540145402454034540445405454064540745408454094541045411454124541345414454154541645417454184541945420454214542245423454244542545426454274542845429454304543145432454334543445435454364543745438454394544045441454424544345444454454544645447454484544945450454514545245453454544545545456454574545845459454604546145462454634546445465454664546745468454694547045471454724547345474454754547645477454784547945480454814548245483454844548545486454874548845489454904549145492454934549445495454964549745498454994550045501455024550345504455054550645507455084550945510455114551245513455144551545516455174551845519455204552145522455234552445525455264552745528455294553045531455324553345534455354553645537455384553945540455414554245543455444554545546455474554845549455504555145552455534555445555455564555745558455594556045561455624556345564455654556645567455684556945570455714557245573455744557545576455774557845579455804558145582455834558445585455864558745588455894559045591455924559345594455954559645597455984559945600456014560245603456044560545606456074560845609456104561145612456134561445615456164561745618456194562045621456224562345624456254562645627456284562945630456314563245633456344563545636456374563845639456404564145642456434564445645456464564745648456494565045651456524565345654456554565645657456584565945660456614566245663456644566545666456674566845669456704567145672456734567445675456764567745678456794568045681456824568345684456854568645687456884568945690456914569245693456944569545696456974569845699457004570145702457034570445705457064570745708457094571045711457124571345714457154571645717457184571945720457214572245723457244572545726457274572845729457304573145732457334573445735457364573745738457394574045741457424574345744457454574645747457484574945750457514575245753457544575545756457574575845759457604576145762457634576445765457664576745768457694577045771457724577345774457754577645777457784577945780457814578245783457844578545786457874578845789457904579145792457934579445795457964579745798457994580045801458024580345804458054580645807458084580945810458114581245813458144581545816458174581845819458204582145822458234582445825458264582745828458294583045831458324583345834458354583645837458384583945840458414584245843458444584545846458474584845849458504585145852458534585445855458564585745858458594586045861458624586345864458654586645867458684586945870458714587245873458744587545876458774587845879458804588145882458834588445885458864588745888458894589045891458924589345894458954589645897458984589945900459014590245903459044590545906459074590845909459104591145912459134591445915459164591745918459194592045921459224592345924459254592645927459284592945930459314593245933459344593545936459374593845939459404594145942459434594445945459464594745948459494595045951459524595345954459554595645957459584595945960459614596245963459644596545966459674596845969459704597145972459734597445975459764597745978459794598045981459824598345984459854598645987459884598945990459914599245993459944599545996459974599845999460004600146002460034600446005460064600746008460094601046011460124601346014460154601646017460184601946020460214602246023460244602546026460274602846029460304603146032460334603446035460364603746038460394604046041460424604346044460454604646047460484604946050460514605246053460544605546056460574605846059460604606146062460634606446065460664606746068460694607046071460724607346074460754607646077460784607946080460814608246083460844608546086460874608846089460904609146092460934609446095460964609746098460994610046101461024610346104461054610646107461084610946110461114611246113461144611546116461174611846119461204612146122461234612446125461264612746128461294613046131461324613346134461354613646137461384613946140461414614246143461444614546146461474614846149461504615146152461534615446155461564615746158461594616046161461624616346164461654616646167461684616946170461714617246173461744617546176461774617846179461804618146182461834618446185461864618746188461894619046191461924619346194461954619646197461984619946200462014620246203462044620546206462074620846209462104621146212462134621446215462164621746218462194622046221462224622346224462254622646227462284622946230462314623246233462344623546236462374623846239462404624146242462434624446245462464624746248462494625046251462524625346254462554625646257462584625946260462614626246263462644626546266462674626846269462704627146272462734627446275462764627746278462794628046281462824628346284462854628646287462884628946290462914629246293462944629546296462974629846299463004630146302463034630446305463064630746308463094631046311463124631346314463154631646317463184631946320463214632246323463244632546326463274632846329463304633146332463334633446335463364633746338463394634046341463424634346344463454634646347463484634946350463514635246353463544635546356463574635846359463604636146362463634636446365463664636746368463694637046371463724637346374463754637646377463784637946380463814638246383463844638546386463874638846389463904639146392463934639446395463964639746398463994640046401464024640346404464054640646407464084640946410464114641246413464144641546416464174641846419464204642146422464234642446425464264642746428464294643046431464324643346434464354643646437464384643946440464414644246443464444644546446464474644846449464504645146452464534645446455464564645746458464594646046461464624646346464464654646646467464684646946470464714647246473464744647546476464774647846479464804648146482464834648446485464864648746488464894649046491464924649346494464954649646497464984649946500465014650246503465044650546506465074650846509465104651146512465134651446515465164651746518465194652046521465224652346524465254652646527465284652946530465314653246533465344653546536465374653846539465404654146542465434654446545465464654746548465494655046551465524655346554465554655646557465584655946560465614656246563465644656546566465674656846569465704657146572465734657446575465764657746578465794658046581465824658346584465854658646587465884658946590465914659246593465944659546596465974659846599466004660146602466034660446605466064660746608466094661046611466124661346614466154661646617466184661946620466214662246623466244662546626466274662846629466304663146632466334663446635466364663746638466394664046641466424664346644466454664646647466484664946650466514665246653466544665546656466574665846659466604666146662466634666446665466664666746668466694667046671466724667346674466754667646677466784667946680466814668246683466844668546686466874668846689466904669146692466934669446695466964669746698466994670046701467024670346704467054670646707467084670946710467114671246713467144671546716467174671846719467204672146722467234672446725467264672746728467294673046731467324673346734467354673646737467384673946740467414674246743467444674546746467474674846749467504675146752467534675446755467564675746758467594676046761467624676346764467654676646767467684676946770467714677246773467744677546776467774677846779467804678146782467834678446785467864678746788467894679046791467924679346794467954679646797467984679946800468014680246803468044680546806468074680846809468104681146812468134681446815468164681746818468194682046821468224682346824468254682646827468284682946830468314683246833468344683546836468374683846839468404684146842468434684446845468464684746848468494685046851468524685346854468554685646857468584685946860468614686246863468644686546866468674686846869468704687146872468734687446875468764687746878468794688046881468824688346884468854688646887468884688946890468914689246893468944689546896468974689846899469004690146902469034690446905469064690746908469094691046911469124691346914469154691646917469184691946920469214692246923469244692546926469274692846929469304693146932469334693446935469364693746938469394694046941469424694346944469454694646947469484694946950469514695246953469544695546956469574695846959469604696146962469634696446965469664696746968469694697046971469724697346974469754697646977469784697946980469814698246983469844698546986469874698846989469904699146992469934699446995469964699746998469994700047001470024700347004470054700647007470084700947010470114701247013470144701547016470174701847019470204702147022470234702447025470264702747028470294703047031470324703347034470354703647037470384703947040470414704247043470444704547046470474704847049470504705147052470534705447055470564705747058470594706047061470624706347064470654706647067470684706947070470714707247073470744707547076470774707847079470804708147082470834708447085470864708747088470894709047091470924709347094470954709647097470984709947100471014710247103471044710547106471074710847109471104711147112471134711447115471164711747118471194712047121471224712347124471254712647127471284712947130471314713247133471344713547136471374713847139471404714147142471434714447145471464714747148471494715047151471524715347154471554715647157471584715947160471614716247163471644716547166471674716847169471704717147172471734717447175471764717747178471794718047181471824718347184471854718647187471884718947190471914719247193471944719547196471974719847199472004720147202472034720447205472064720747208472094721047211472124721347214472154721647217472184721947220472214722247223472244722547226472274722847229472304723147232472334723447235472364723747238472394724047241472424724347244472454724647247472484724947250472514725247253472544725547256472574725847259472604726147262472634726447265472664726747268472694727047271472724727347274472754727647277472784727947280472814728247283472844728547286472874728847289472904729147292472934729447295472964729747298472994730047301473024730347304473054730647307473084730947310473114731247313473144731547316473174731847319473204732147322473234732447325473264732747328473294733047331473324733347334473354733647337473384733947340473414734247343473444734547346473474734847349473504735147352473534735447355473564735747358473594736047361473624736347364473654736647367473684736947370473714737247373473744737547376473774737847379473804738147382473834738447385473864738747388473894739047391473924739347394473954739647397473984739947400474014740247403474044740547406474074740847409474104741147412474134741447415474164741747418474194742047421474224742347424474254742647427474284742947430474314743247433474344743547436474374743847439474404744147442474434744447445474464744747448474494745047451474524745347454474554745647457474584745947460474614746247463474644746547466474674746847469474704747147472474734747447475474764747747478474794748047481474824748347484474854748647487474884748947490474914749247493474944749547496474974749847499475004750147502475034750447505475064750747508475094751047511475124751347514475154751647517475184751947520475214752247523475244752547526475274752847529475304753147532475334753447535475364753747538475394754047541475424754347544475454754647547475484754947550475514755247553475544755547556475574755847559475604756147562475634756447565475664756747568475694757047571475724757347574475754757647577475784757947580475814758247583475844758547586475874758847589475904759147592475934759447595475964759747598475994760047601476024760347604476054760647607476084760947610476114761247613476144761547616476174761847619476204762147622476234762447625476264762747628476294763047631476324763347634476354763647637476384763947640476414764247643476444764547646476474764847649476504765147652476534765447655476564765747658476594766047661476624766347664476654766647667476684766947670476714767247673476744767547676476774767847679476804768147682476834768447685476864768747688476894769047691476924769347694476954769647697476984769947700477014770247703477044770547706477074770847709477104771147712477134771447715477164771747718477194772047721477224772347724477254772647727477284772947730477314773247733477344773547736477374773847739477404774147742477434774447745477464774747748477494775047751477524775347754477554775647757477584775947760477614776247763477644776547766477674776847769477704777147772477734777447775477764777747778477794778047781477824778347784477854778647787477884778947790477914779247793477944779547796477974779847799478004780147802478034780447805478064780747808478094781047811478124781347814478154781647817478184781947820478214782247823478244782547826478274782847829478304783147832478334783447835478364783747838478394784047841478424784347844478454784647847478484784947850478514785247853478544785547856478574785847859478604786147862478634786447865478664786747868478694787047871478724787347874478754787647877478784787947880478814788247883478844788547886478874788847889478904789147892478934789447895478964789747898478994790047901479024790347904479054790647907479084790947910479114791247913479144791547916479174791847919479204792147922479234792447925479264792747928479294793047931479324793347934479354793647937479384793947940479414794247943479444794547946479474794847949479504795147952479534795447955479564795747958479594796047961479624796347964479654796647967479684796947970479714797247973479744797547976479774797847979479804798147982479834798447985479864798747988479894799047991479924799347994479954799647997479984799948000480014800248003480044800548006480074800848009480104801148012480134801448015480164801748018480194802048021480224802348024480254802648027480284802948030480314803248033480344803548036480374803848039480404804148042480434804448045480464804748048480494805048051480524805348054480554805648057480584805948060480614806248063480644806548066480674806848069480704807148072480734807448075480764807748078480794808048081480824808348084480854808648087480884808948090480914809248093480944809548096480974809848099481004810148102481034810448105481064810748108481094811048111481124811348114481154811648117481184811948120481214812248123481244812548126481274812848129481304813148132481334813448135481364813748138481394814048141481424814348144481454814648147481484814948150481514815248153481544815548156481574815848159481604816148162481634816448165481664816748168481694817048171481724817348174481754817648177481784817948180481814818248183481844818548186481874818848189481904819148192481934819448195481964819748198481994820048201482024820348204482054820648207482084820948210482114821248213482144821548216482174821848219482204822148222482234822448225482264822748228482294823048231482324823348234482354823648237482384823948240482414824248243482444824548246482474824848249482504825148252482534825448255482564825748258482594826048261482624826348264482654826648267482684826948270482714827248273482744827548276482774827848279482804828148282482834828448285482864828748288482894829048291482924829348294482954829648297482984829948300483014830248303483044830548306483074830848309483104831148312483134831448315483164831748318483194832048321483224832348324483254832648327483284832948330483314833248333483344833548336483374833848339483404834148342483434834448345483464834748348483494835048351483524835348354483554835648357483584835948360483614836248363483644836548366483674836848369483704837148372483734837448375483764837748378483794838048381483824838348384483854838648387483884838948390483914839248393483944839548396483974839848399484004840148402484034840448405484064840748408484094841048411484124841348414484154841648417484184841948420484214842248423484244842548426484274842848429484304843148432484334843448435484364843748438484394844048441484424844348444484454844648447484484844948450484514845248453484544845548456484574845848459484604846148462484634846448465484664846748468484694847048471484724847348474484754847648477484784847948480484814848248483484844848548486484874848848489484904849148492484934849448495484964849748498484994850048501485024850348504485054850648507485084850948510485114851248513485144851548516485174851848519485204852148522485234852448525485264852748528485294853048531485324853348534485354853648537485384853948540485414854248543485444854548546485474854848549485504855148552485534855448555485564855748558485594856048561485624856348564485654856648567485684856948570485714857248573485744857548576485774857848579485804858148582485834858448585485864858748588485894859048591485924859348594485954859648597485984859948600486014860248603486044860548606486074860848609486104861148612486134861448615486164861748618486194862048621486224862348624486254862648627486284862948630486314863248633486344863548636486374863848639486404864148642486434864448645486464864748648486494865048651486524865348654486554865648657486584865948660486614866248663486644866548666486674866848669486704867148672486734867448675486764867748678486794868048681486824868348684486854868648687486884868948690486914869248693486944869548696486974869848699487004870148702487034870448705487064870748708487094871048711487124871348714487154871648717487184871948720487214872248723487244872548726487274872848729487304873148732487334873448735487364873748738487394874048741487424874348744487454874648747487484874948750487514875248753487544875548756487574875848759487604876148762487634876448765487664876748768487694877048771487724877348774487754877648777487784877948780487814878248783487844878548786487874878848789487904879148792487934879448795487964879748798487994880048801488024880348804488054880648807488084880948810488114881248813488144881548816488174881848819488204882148822488234882448825488264882748828488294883048831488324883348834488354883648837488384883948840488414884248843488444884548846488474884848849488504885148852488534885448855488564885748858488594886048861488624886348864488654886648867488684886948870488714887248873488744887548876488774887848879488804888148882488834888448885488864888748888488894889048891488924889348894488954889648897488984889948900489014890248903489044890548906489074890848909489104891148912489134891448915489164891748918489194892048921489224892348924489254892648927489284892948930489314893248933489344893548936489374893848939489404894148942489434894448945489464894748948489494895048951489524895348954489554895648957489584895948960489614896248963489644896548966489674896848969489704897148972489734897448975489764897748978489794898048981489824898348984489854898648987489884898948990489914899248993489944899548996489974899848999490004900149002490034900449005490064900749008490094901049011490124901349014490154901649017490184901949020490214902249023490244902549026490274902849029490304903149032490334903449035490364903749038490394904049041490424904349044490454904649047490484904949050490514905249053490544905549056490574905849059490604906149062490634906449065490664906749068490694907049071490724907349074490754907649077490784907949080490814908249083490844908549086490874908849089490904909149092490934909449095490964909749098490994910049101491024910349104491054910649107491084910949110491114911249113491144911549116491174911849119491204912149122491234912449125491264912749128491294913049131491324913349134491354913649137491384913949140491414914249143491444914549146491474914849149491504915149152491534915449155491564915749158491594916049161491624916349164491654916649167491684916949170491714917249173491744917549176491774917849179491804918149182491834918449185491864918749188491894919049191491924919349194491954919649197491984919949200492014920249203492044920549206492074920849209492104921149212492134921449215492164921749218492194922049221492224922349224492254922649227492284922949230492314923249233492344923549236492374923849239492404924149242492434924449245492464924749248492494925049251492524925349254492554925649257492584925949260492614926249263492644926549266492674926849269492704927149272492734927449275492764927749278492794928049281492824928349284492854928649287492884928949290492914929249293492944929549296492974929849299493004930149302493034930449305493064930749308493094931049311493124931349314493154931649317493184931949320493214932249323493244932549326493274932849329493304933149332493334933449335493364933749338493394934049341493424934349344493454934649347493484934949350493514935249353493544935549356493574935849359493604936149362493634936449365493664936749368493694937049371493724937349374493754937649377493784937949380493814938249383493844938549386493874938849389493904939149392493934939449395493964939749398493994940049401494024940349404494054940649407494084940949410494114941249413494144941549416494174941849419494204942149422494234942449425494264942749428494294943049431494324943349434494354943649437494384943949440494414944249443494444944549446494474944849449494504945149452494534945449455494564945749458494594946049461494624946349464494654946649467494684946949470494714947249473494744947549476494774947849479494804948149482494834948449485494864948749488494894949049491494924949349494494954949649497494984949949500495014950249503495044950549506495074950849509495104951149512495134951449515495164951749518495194952049521495224952349524495254952649527495284952949530495314953249533495344953549536495374953849539495404954149542495434954449545495464954749548495494955049551495524955349554495554955649557495584955949560495614956249563495644956549566495674956849569495704957149572495734957449575495764957749578495794958049581495824958349584495854958649587495884958949590495914959249593495944959549596495974959849599496004960149602496034960449605496064960749608496094961049611496124961349614496154961649617496184961949620496214962249623496244962549626496274962849629496304963149632496334963449635496364963749638496394964049641496424964349644496454964649647496484964949650496514965249653496544965549656496574965849659496604966149662496634966449665496664966749668496694967049671496724967349674496754967649677496784967949680496814968249683496844968549686496874968849689496904969149692496934969449695496964969749698496994970049701497024970349704497054970649707497084970949710497114971249713497144971549716497174971849719497204972149722497234972449725497264972749728497294973049731497324973349734497354973649737497384973949740497414974249743497444974549746497474974849749497504975149752497534975449755497564975749758497594976049761497624976349764497654976649767497684976949770497714977249773497744977549776497774977849779497804978149782497834978449785497864978749788497894979049791497924979349794497954979649797497984979949800498014980249803498044980549806498074980849809498104981149812498134981449815498164981749818498194982049821498224982349824498254982649827498284982949830498314983249833498344983549836498374983849839498404984149842498434984449845498464984749848498494985049851498524985349854498554985649857498584985949860498614986249863498644986549866498674986849869498704987149872498734987449875498764987749878498794988049881498824988349884498854988649887498884988949890498914989249893498944989549896498974989849899499004990149902499034990449905499064990749908499094991049911499124991349914499154991649917499184991949920499214992249923499244992549926499274992849929499304993149932499334993449935499364993749938499394994049941499424994349944499454994649947499484994949950499514995249953499544995549956499574995849959499604996149962499634996449965499664996749968499694997049971499724997349974499754997649977499784997949980499814998249983499844998549986499874998849989499904999149992499934999449995499964999749998499995000050001500025000350004500055000650007500085000950010500115001250013500145001550016500175001850019500205002150022500235002450025500265002750028500295003050031500325003350034500355003650037500385003950040500415004250043500445004550046500475004850049500505005150052500535005450055500565005750058500595006050061500625006350064500655006650067500685006950070500715007250073500745007550076500775007850079500805008150082500835008450085500865008750088500895009050091500925009350094500955009650097500985009950100501015010250103501045010550106501075010850109501105011150112501135011450115501165011750118501195012050121501225012350124501255012650127501285012950130501315013250133501345013550136501375013850139501405014150142501435014450145501465014750148501495015050151501525015350154501555015650157501585015950160501615016250163501645016550166501675016850169501705017150172501735017450175501765017750178501795018050181501825018350184501855018650187501885018950190501915019250193501945019550196501975019850199502005020150202502035020450205502065020750208502095021050211502125021350214502155021650217502185021950220502215022250223502245022550226502275022850229502305023150232502335023450235502365023750238502395024050241502425024350244502455024650247502485024950250502515025250253502545025550256502575025850259502605026150262502635026450265502665026750268502695027050271502725027350274502755027650277502785027950280502815028250283502845028550286502875028850289502905029150292502935029450295502965029750298502995030050301503025030350304503055030650307503085030950310503115031250313503145031550316503175031850319503205032150322503235032450325503265032750328503295033050331503325033350334503355033650337503385033950340503415034250343503445034550346503475034850349503505035150352503535035450355503565035750358503595036050361503625036350364503655036650367503685036950370503715037250373503745037550376503775037850379503805038150382503835038450385503865038750388503895039050391503925039350394503955039650397503985039950400504015040250403504045040550406504075040850409504105041150412504135041450415504165041750418504195042050421504225042350424504255042650427504285042950430504315043250433504345043550436504375043850439504405044150442504435044450445504465044750448504495045050451504525045350454504555045650457504585045950460504615046250463504645046550466504675046850469504705047150472504735047450475504765047750478504795048050481504825048350484504855048650487504885048950490504915049250493504945049550496504975049850499505005050150502505035050450505505065050750508505095051050511505125051350514505155051650517505185051950520505215052250523505245052550526505275052850529505305053150532505335053450535505365053750538505395054050541505425054350544505455054650547505485054950550505515055250553505545055550556505575055850559505605056150562505635056450565505665056750568505695057050571505725057350574505755057650577505785057950580505815058250583505845058550586505875058850589505905059150592505935059450595505965059750598505995060050601506025060350604506055060650607506085060950610506115061250613506145061550616506175061850619506205062150622506235062450625506265062750628506295063050631506325063350634506355063650637506385063950640506415064250643506445064550646506475064850649506505065150652506535065450655506565065750658506595066050661506625066350664506655066650667506685066950670506715067250673506745067550676506775067850679506805068150682506835068450685506865068750688506895069050691506925069350694506955069650697506985069950700507015070250703507045070550706507075070850709507105071150712507135071450715507165071750718507195072050721507225072350724507255072650727507285072950730507315073250733507345073550736507375073850739507405074150742507435074450745507465074750748507495075050751507525075350754507555075650757507585075950760507615076250763507645076550766507675076850769507705077150772507735077450775507765077750778507795078050781507825078350784507855078650787507885078950790507915079250793507945079550796507975079850799508005080150802508035080450805508065080750808508095081050811508125081350814508155081650817508185081950820508215082250823508245082550826508275082850829508305083150832508335083450835508365083750838508395084050841508425084350844508455084650847508485084950850508515085250853508545085550856508575085850859508605086150862508635086450865508665086750868508695087050871508725087350874508755087650877508785087950880508815088250883508845088550886508875088850889508905089150892508935089450895508965089750898508995090050901509025090350904509055090650907509085090950910509115091250913509145091550916509175091850919509205092150922509235092450925509265092750928509295093050931509325093350934509355093650937509385093950940509415094250943509445094550946509475094850949509505095150952509535095450955509565095750958509595096050961509625096350964509655096650967509685096950970509715097250973509745097550976509775097850979509805098150982509835098450985509865098750988509895099050991509925099350994509955099650997509985099951000510015100251003510045100551006510075100851009510105101151012510135101451015510165101751018510195102051021510225102351024510255102651027510285102951030510315103251033510345103551036510375103851039510405104151042510435104451045510465104751048510495105051051510525105351054510555105651057510585105951060510615106251063510645106551066510675106851069510705107151072510735107451075510765107751078510795108051081510825108351084510855108651087510885108951090510915109251093510945109551096510975109851099511005110151102511035110451105511065110751108511095111051111511125111351114511155111651117511185111951120511215112251123511245112551126511275112851129511305113151132511335113451135511365113751138511395114051141511425114351144511455114651147511485114951150511515115251153511545115551156511575115851159511605116151162511635116451165511665116751168511695117051171511725117351174511755117651177511785117951180511815118251183511845118551186511875118851189511905119151192511935119451195511965119751198511995120051201512025120351204512055120651207512085120951210512115121251213512145121551216512175121851219512205122151222512235122451225512265122751228512295123051231512325123351234512355123651237512385123951240512415124251243512445124551246512475124851249512505125151252512535125451255512565125751258512595126051261512625126351264512655126651267512685126951270512715127251273512745127551276512775127851279512805128151282512835128451285512865128751288512895129051291512925129351294512955129651297512985129951300513015130251303513045130551306513075130851309513105131151312513135131451315513165131751318513195132051321513225132351324513255132651327513285132951330513315133251333513345133551336513375133851339513405134151342513435134451345513465134751348513495135051351513525135351354513555135651357513585135951360513615136251363513645136551366513675136851369513705137151372513735137451375513765137751378513795138051381513825138351384513855138651387513885138951390513915139251393513945139551396513975139851399514005140151402514035140451405514065140751408514095141051411514125141351414514155141651417514185141951420514215142251423514245142551426514275142851429514305143151432514335143451435514365143751438514395144051441514425144351444514455144651447514485144951450514515145251453514545145551456514575145851459514605146151462514635146451465514665146751468514695147051471514725147351474514755147651477514785147951480514815148251483514845148551486514875148851489514905149151492514935149451495514965149751498514995150051501515025150351504515055150651507515085150951510515115151251513515145151551516515175151851519515205152151522515235152451525515265152751528515295153051531515325153351534515355153651537515385153951540515415154251543515445154551546515475154851549515505155151552515535155451555515565155751558515595156051561515625156351564515655156651567515685156951570515715157251573515745157551576515775157851579515805158151582515835158451585515865158751588515895159051591515925159351594515955159651597515985159951600516015160251603516045160551606516075160851609516105161151612516135161451615516165161751618516195162051621516225162351624516255162651627516285162951630516315163251633516345163551636516375163851639516405164151642516435164451645516465164751648516495165051651516525165351654516555165651657516585165951660516615166251663516645166551666516675166851669516705167151672516735167451675516765167751678516795168051681516825168351684516855168651687516885168951690516915169251693516945169551696516975169851699517005170151702517035170451705517065170751708517095171051711517125171351714517155171651717517185171951720517215172251723517245172551726517275172851729517305173151732517335173451735517365173751738517395174051741517425174351744517455174651747517485174951750517515175251753517545175551756517575175851759517605176151762517635176451765517665176751768517695177051771517725177351774517755177651777517785177951780517815178251783517845178551786517875178851789517905179151792517935179451795517965179751798517995180051801518025180351804518055180651807518085180951810518115181251813518145181551816518175181851819518205182151822518235182451825518265182751828518295183051831518325183351834518355183651837518385183951840518415184251843518445184551846518475184851849518505185151852518535185451855518565185751858518595186051861518625186351864518655186651867518685186951870518715187251873518745187551876518775187851879518805188151882518835188451885518865188751888518895189051891518925189351894518955189651897518985189951900519015190251903519045190551906519075190851909519105191151912519135191451915519165191751918519195192051921519225192351924519255192651927519285192951930519315193251933519345193551936519375193851939519405194151942519435194451945519465194751948519495195051951519525195351954519555195651957519585195951960519615196251963519645196551966519675196851969519705197151972519735197451975519765197751978519795198051981519825198351984519855198651987519885198951990519915199251993519945199551996519975199851999520005200152002520035200452005520065200752008520095201052011520125201352014520155201652017520185201952020520215202252023520245202552026520275202852029520305203152032520335203452035520365203752038520395204052041520425204352044520455204652047520485204952050520515205252053520545205552056520575205852059520605206152062520635206452065520665206752068520695207052071520725207352074520755207652077520785207952080520815208252083520845208552086520875208852089520905209152092520935209452095520965209752098520995210052101521025210352104521055210652107521085210952110521115211252113521145211552116521175211852119521205212152122521235212452125521265212752128521295213052131521325213352134521355213652137521385213952140521415214252143521445214552146521475214852149521505215152152521535215452155521565215752158521595216052161521625216352164521655216652167521685216952170521715217252173521745217552176521775217852179521805218152182521835218452185521865218752188521895219052191521925219352194521955219652197521985219952200522015220252203522045220552206522075220852209522105221152212522135221452215522165221752218522195222052221522225222352224522255222652227522285222952230522315223252233522345223552236522375223852239522405224152242522435224452245522465224752248522495225052251522525225352254522555225652257522585225952260522615226252263522645226552266522675226852269522705227152272522735227452275522765227752278522795228052281522825228352284522855228652287522885228952290522915229252293522945229552296522975229852299523005230152302523035230452305523065230752308523095231052311523125231352314523155231652317523185231952320523215232252323523245232552326523275232852329523305233152332523335233452335523365233752338523395234052341523425234352344523455234652347523485234952350523515235252353523545235552356523575235852359523605236152362523635236452365523665236752368523695237052371523725237352374523755237652377523785237952380523815238252383523845238552386523875238852389523905239152392523935239452395523965239752398523995240052401524025240352404524055240652407524085240952410524115241252413524145241552416524175241852419524205242152422524235242452425524265242752428524295243052431524325243352434524355243652437524385243952440524415244252443524445244552446524475244852449524505245152452524535245452455524565245752458524595246052461524625246352464524655246652467524685246952470524715247252473524745247552476524775247852479524805248152482524835248452485524865248752488524895249052491524925249352494524955249652497524985249952500525015250252503525045250552506525075250852509525105251152512525135251452515525165251752518525195252052521525225252352524525255252652527525285252952530525315253252533525345253552536525375253852539525405254152542525435254452545525465254752548525495255052551525525255352554525555255652557525585255952560525615256252563525645256552566525675256852569525705257152572525735257452575525765257752578525795258052581525825258352584525855258652587525885258952590525915259252593525945259552596525975259852599526005260152602526035260452605526065260752608526095261052611526125261352614526155261652617526185261952620526215262252623526245262552626526275262852629526305263152632526335263452635526365263752638526395264052641526425264352644526455264652647526485264952650526515265252653526545265552656526575265852659526605266152662526635266452665526665266752668526695267052671526725267352674526755267652677526785267952680526815268252683526845268552686526875268852689526905269152692526935269452695526965269752698526995270052701527025270352704527055270652707527085270952710527115271252713527145271552716527175271852719527205272152722527235272452725527265272752728527295273052731527325273352734527355273652737527385273952740527415274252743527445274552746527475274852749527505275152752527535275452755527565275752758527595276052761527625276352764527655276652767527685276952770527715277252773527745277552776527775277852779527805278152782527835278452785527865278752788527895279052791527925279352794527955279652797527985279952800528015280252803528045280552806528075280852809528105281152812528135281452815528165281752818528195282052821528225282352824528255282652827528285282952830528315283252833528345283552836528375283852839528405284152842528435284452845528465284752848528495285052851528525285352854528555285652857528585285952860528615286252863528645286552866528675286852869528705287152872528735287452875528765287752878528795288052881528825288352884528855288652887528885288952890528915289252893528945289552896528975289852899529005290152902529035290452905529065290752908529095291052911529125291352914529155291652917529185291952920529215292252923529245292552926529275292852929529305293152932529335293452935529365293752938529395294052941529425294352944529455294652947529485294952950529515295252953529545295552956529575295852959529605296152962529635296452965529665296752968529695297052971529725297352974529755297652977529785297952980529815298252983529845298552986529875298852989529905299152992529935299452995529965299752998529995300053001530025300353004530055300653007530085300953010530115301253013530145301553016530175301853019530205302153022530235302453025530265302753028530295303053031530325303353034530355303653037530385303953040530415304253043530445304553046530475304853049530505305153052530535305453055530565305753058530595306053061530625306353064530655306653067530685306953070530715307253073530745307553076530775307853079530805308153082530835308453085530865308753088530895309053091530925309353094530955309653097530985309953100531015310253103531045310553106531075310853109531105311153112531135311453115531165311753118531195312053121531225312353124531255312653127531285312953130531315313253133531345313553136531375313853139531405314153142531435314453145531465314753148531495315053151531525315353154531555315653157531585315953160531615316253163531645316553166531675316853169531705317153172531735317453175531765317753178531795318053181531825318353184531855318653187531885318953190531915319253193531945319553196531975319853199532005320153202532035320453205532065320753208532095321053211532125321353214532155321653217532185321953220532215322253223532245322553226532275322853229532305323153232532335323453235532365323753238532395324053241532425324353244532455324653247532485324953250532515325253253532545325553256532575325853259532605326153262532635326453265532665326753268532695327053271532725327353274532755327653277532785327953280532815328253283532845328553286532875328853289532905329153292532935329453295532965329753298532995330053301533025330353304533055330653307533085330953310533115331253313533145331553316533175331853319533205332153322533235332453325533265332753328533295333053331533325333353334533355333653337533385333953340533415334253343533445334553346533475334853349533505335153352533535335453355533565335753358533595336053361533625336353364533655336653367533685336953370533715337253373533745337553376533775337853379533805338153382533835338453385533865338753388533895339053391533925339353394533955339653397533985339953400534015340253403534045340553406534075340853409534105341153412534135341453415534165341753418534195342053421534225342353424534255342653427534285342953430534315343253433534345343553436534375343853439534405344153442534435344453445534465344753448534495345053451534525345353454534555345653457534585345953460534615346253463534645346553466534675346853469534705347153472534735347453475534765347753478534795348053481534825348353484534855348653487534885348953490534915349253493534945349553496534975349853499535005350153502535035350453505535065350753508535095351053511535125351353514535155351653517535185351953520535215352253523535245352553526535275352853529535305353153532535335353453535535365353753538535395354053541535425354353544535455354653547535485354953550535515355253553535545355553556535575355853559535605356153562535635356453565535665356753568535695357053571535725357353574535755357653577535785357953580535815358253583535845358553586535875358853589535905359153592535935359453595535965359753598535995360053601536025360353604536055360653607536085360953610536115361253613536145361553616536175361853619536205362153622536235362453625536265362753628536295363053631536325363353634536355363653637536385363953640536415364253643536445364553646536475364853649536505365153652536535365453655536565365753658536595366053661536625366353664536655366653667536685366953670536715367253673536745367553676536775367853679536805368153682536835368453685536865368753688536895369053691536925369353694536955369653697536985369953700537015370253703537045370553706537075370853709537105371153712537135371453715537165371753718537195372053721537225372353724537255372653727537285372953730537315373253733537345373553736537375373853739537405374153742537435374453745537465374753748537495375053751537525375353754537555375653757537585375953760537615376253763537645376553766537675376853769537705377153772537735377453775537765377753778537795378053781537825378353784537855378653787537885378953790537915379253793537945379553796537975379853799538005380153802538035380453805538065380753808538095381053811538125381353814538155381653817538185381953820538215382253823538245382553826538275382853829538305383153832538335383453835538365383753838538395384053841538425384353844538455384653847538485384953850538515385253853538545385553856538575385853859538605386153862538635386453865538665386753868538695387053871538725387353874538755387653877538785387953880538815388253883538845388553886538875388853889538905389153892538935389453895538965389753898538995390053901539025390353904539055390653907539085390953910539115391253913539145391553916539175391853919539205392153922539235392453925539265392753928539295393053931539325393353934539355393653937539385393953940539415394253943539445394553946539475394853949539505395153952539535395453955539565395753958539595396053961539625396353964539655396653967539685396953970539715397253973539745397553976539775397853979539805398153982539835398453985539865398753988539895399053991539925399353994539955399653997539985399954000540015400254003540045400554006540075400854009540105401154012540135401454015540165401754018540195402054021540225402354024540255402654027540285402954030540315403254033540345403554036540375403854039540405404154042540435404454045540465404754048540495405054051540525405354054540555405654057540585405954060540615406254063540645406554066540675406854069540705407154072540735407454075540765407754078540795408054081540825408354084540855408654087540885408954090540915409254093540945409554096540975409854099541005410154102541035410454105541065410754108541095411054111541125411354114541155411654117541185411954120541215412254123541245412554126541275412854129541305413154132541335413454135541365413754138541395414054141541425414354144541455414654147541485414954150541515415254153541545415554156541575415854159541605416154162541635416454165541665416754168541695417054171541725417354174541755417654177541785417954180541815418254183541845418554186541875418854189541905419154192541935419454195541965419754198541995420054201542025420354204542055420654207542085420954210542115421254213542145421554216542175421854219542205422154222542235422454225542265422754228542295423054231542325423354234542355423654237542385423954240542415424254243542445424554246542475424854249542505425154252542535425454255542565425754258542595426054261542625426354264542655426654267542685426954270542715427254273542745427554276542775427854279542805428154282542835428454285542865428754288542895429054291542925429354294542955429654297542985429954300543015430254303543045430554306543075430854309543105431154312543135431454315543165431754318543195432054321543225432354324543255432654327543285432954330543315433254333543345433554336543375433854339543405434154342543435434454345543465434754348543495435054351543525435354354543555435654357543585435954360543615436254363543645436554366543675436854369543705437154372543735437454375543765437754378543795438054381543825438354384543855438654387543885438954390543915439254393543945439554396543975439854399544005440154402544035440454405544065440754408544095441054411544125441354414544155441654417544185441954420544215442254423544245442554426544275442854429544305443154432544335443454435544365443754438544395444054441544425444354444544455444654447544485444954450544515445254453544545445554456544575445854459544605446154462544635446454465544665446754468544695447054471544725447354474544755447654477544785447954480544815448254483544845448554486544875448854489544905449154492544935449454495544965449754498544995450054501545025450354504545055450654507545085450954510545115451254513545145451554516545175451854519545205452154522545235452454525545265452754528545295453054531545325453354534545355453654537545385453954540545415454254543545445454554546545475454854549545505455154552545535455454555545565455754558545595456054561545625456354564545655456654567545685456954570545715457254573545745457554576545775457854579545805458154582545835458454585545865458754588545895459054591545925459354594545955459654597545985459954600546015460254603546045460554606546075460854609546105461154612546135461454615546165461754618546195462054621546225462354624546255462654627546285462954630546315463254633546345463554636546375463854639546405464154642546435464454645546465464754648546495465054651546525465354654546555465654657546585465954660546615466254663546645466554666546675466854669546705467154672546735467454675546765467754678546795468054681546825468354684546855468654687546885468954690546915469254693546945469554696546975469854699547005470154702547035470454705547065470754708547095471054711547125471354714547155471654717547185471954720547215472254723547245472554726547275472854729547305473154732547335473454735547365473754738547395474054741547425474354744547455474654747547485474954750547515475254753547545475554756547575475854759547605476154762547635476454765547665476754768547695477054771547725477354774547755477654777547785477954780547815478254783547845478554786547875478854789547905479154792547935479454795547965479754798547995480054801548025480354804548055480654807548085480954810548115481254813548145481554816548175481854819548205482154822548235482454825548265482754828548295483054831548325483354834548355483654837548385483954840548415484254843548445484554846548475484854849548505485154852548535485454855548565485754858548595486054861548625486354864548655486654867548685486954870548715487254873548745487554876548775487854879548805488154882548835488454885548865488754888548895489054891548925489354894548955489654897548985489954900549015490254903549045490554906549075490854909549105491154912549135491454915549165491754918549195492054921549225492354924549255492654927549285492954930549315493254933549345493554936549375493854939549405494154942549435494454945549465494754948549495495054951549525495354954549555495654957549585495954960549615496254963549645496554966549675496854969549705497154972549735497454975549765497754978549795498054981549825498354984549855498654987549885498954990549915499254993549945499554996549975499854999550005500155002550035500455005550065500755008550095501055011550125501355014550155501655017550185501955020550215502255023550245502555026550275502855029550305503155032550335503455035550365503755038550395504055041550425504355044550455504655047550485504955050550515505255053550545505555056550575505855059550605506155062550635506455065550665506755068550695507055071550725507355074550755507655077550785507955080550815508255083550845508555086550875508855089550905509155092550935509455095550965509755098550995510055101551025510355104551055510655107551085510955110551115511255113551145511555116551175511855119551205512155122551235512455125551265512755128551295513055131551325513355134551355513655137551385513955140551415514255143551445514555146551475514855149551505515155152551535515455155551565515755158551595516055161551625516355164551655516655167551685516955170551715517255173551745517555176551775517855179551805518155182551835518455185551865518755188551895519055191551925519355194551955519655197551985519955200552015520255203552045520555206552075520855209552105521155212552135521455215552165521755218552195522055221552225522355224552255522655227552285522955230552315523255233552345523555236552375523855239552405524155242552435524455245552465524755248552495525055251552525525355254552555525655257552585525955260552615526255263552645526555266552675526855269552705527155272552735527455275552765527755278552795528055281552825528355284552855528655287552885528955290552915529255293552945529555296552975529855299553005530155302553035530455305553065530755308553095531055311553125531355314553155531655317553185531955320553215532255323553245532555326553275532855329553305533155332553335533455335553365533755338553395534055341553425534355344553455534655347553485534955350553515535255353553545535555356553575535855359553605536155362553635536455365553665536755368553695537055371553725537355374553755537655377553785537955380553815538255383553845538555386553875538855389553905539155392553935539455395553965539755398553995540055401554025540355404554055540655407554085540955410554115541255413554145541555416554175541855419554205542155422554235542455425554265542755428554295543055431554325543355434554355543655437554385543955440554415544255443554445544555446554475544855449554505545155452554535545455455554565545755458554595546055461554625546355464554655546655467554685546955470554715547255473554745547555476554775547855479554805548155482554835548455485554865548755488554895549055491554925549355494554955549655497554985549955500555015550255503555045550555506555075550855509555105551155512555135551455515555165551755518555195552055521555225552355524555255552655527555285552955530555315553255533555345553555536555375553855539555405554155542555435554455545555465554755548555495555055551555525555355554555555555655557555585555955560555615556255563555645556555566555675556855569555705557155572555735557455575555765557755578555795558055581555825558355584555855558655587555885558955590555915559255593555945559555596555975559855599556005560155602556035560455605556065560755608556095561055611556125561355614556155561655617556185561955620556215562255623556245562555626556275562855629556305563155632556335563455635556365563755638556395564055641556425564355644556455564655647556485564955650556515565255653556545565555656556575565855659556605566155662556635566455665556665566755668556695567055671556725567355674556755567655677556785567955680556815568255683556845568555686556875568855689556905569155692556935569455695556965569755698556995570055701557025570355704557055570655707557085570955710557115571255713557145571555716557175571855719557205572155722557235572455725557265572755728557295573055731557325573355734557355573655737557385573955740557415574255743557445574555746557475574855749557505575155752557535575455755557565575755758557595576055761557625576355764557655576655767557685576955770557715577255773557745577555776557775577855779557805578155782557835578455785557865578755788557895579055791557925579355794557955579655797557985579955800558015580255803558045580555806558075580855809558105581155812558135581455815558165581755818558195582055821558225582355824558255582655827558285582955830558315583255833558345583555836558375583855839558405584155842558435584455845558465584755848558495585055851558525585355854558555585655857558585585955860558615586255863558645586555866558675586855869558705587155872558735587455875558765587755878558795588055881558825588355884558855588655887558885588955890558915589255893558945589555896558975589855899559005590155902559035590455905559065590755908559095591055911559125591355914559155591655917559185591955920559215592255923559245592555926559275592855929559305593155932559335593455935559365593755938559395594055941559425594355944559455594655947559485594955950559515595255953559545595555956559575595855959559605596155962559635596455965559665596755968559695597055971559725597355974559755597655977559785597955980559815598255983559845598555986559875598855989559905599155992559935599455995559965599755998559995600056001560025600356004560055600656007560085600956010560115601256013560145601556016560175601856019560205602156022560235602456025560265602756028560295603056031560325603356034560355603656037560385603956040560415604256043560445604556046560475604856049560505605156052560535605456055560565605756058560595606056061560625606356064560655606656067560685606956070560715607256073560745607556076560775607856079560805608156082560835608456085560865608756088560895609056091560925609356094560955609656097560985609956100561015610256103561045610556106561075610856109561105611156112561135611456115561165611756118561195612056121561225612356124561255612656127561285612956130561315613256133561345613556136561375613856139561405614156142561435614456145561465614756148561495615056151561525615356154561555615656157561585615956160561615616256163561645616556166561675616856169561705617156172561735617456175561765617756178561795618056181561825618356184561855618656187561885618956190561915619256193561945619556196561975619856199562005620156202562035620456205562065620756208562095621056211562125621356214562155621656217562185621956220562215622256223562245622556226562275622856229562305623156232562335623456235562365623756238562395624056241562425624356244562455624656247562485624956250562515625256253562545625556256562575625856259562605626156262562635626456265562665626756268562695627056271562725627356274562755627656277562785627956280562815628256283562845628556286562875628856289562905629156292562935629456295562965629756298562995630056301563025630356304563055630656307563085630956310563115631256313563145631556316563175631856319563205632156322563235632456325563265632756328563295633056331563325633356334563355633656337563385633956340563415634256343563445634556346563475634856349563505635156352563535635456355563565635756358563595636056361563625636356364563655636656367563685636956370563715637256373563745637556376563775637856379563805638156382563835638456385563865638756388563895639056391563925639356394563955639656397563985639956400564015640256403564045640556406564075640856409564105641156412564135641456415564165641756418564195642056421564225642356424564255642656427564285642956430564315643256433564345643556436564375643856439564405644156442564435644456445564465644756448564495645056451564525645356454564555645656457564585645956460564615646256463564645646556466564675646856469564705647156472564735647456475564765647756478564795648056481564825648356484564855648656487564885648956490564915649256493564945649556496564975649856499565005650156502565035650456505565065650756508565095651056511565125651356514565155651656517565185651956520565215652256523565245652556526565275652856529565305653156532565335653456535565365653756538565395654056541565425654356544565455654656547565485654956550565515655256553565545655556556565575655856559565605656156562565635656456565565665656756568565695657056571565725657356574565755657656577565785657956580565815658256583565845658556586565875658856589565905659156592565935659456595565965659756598565995660056601566025660356604566055660656607566085660956610566115661256613566145661556616566175661856619566205662156622566235662456625566265662756628566295663056631566325663356634566355663656637566385663956640566415664256643566445664556646566475664856649566505665156652566535665456655566565665756658566595666056661566625666356664566655666656667566685666956670566715667256673566745667556676566775667856679566805668156682566835668456685566865668756688566895669056691566925669356694566955669656697566985669956700567015670256703567045670556706567075670856709567105671156712567135671456715567165671756718567195672056721567225672356724567255672656727567285672956730567315673256733567345673556736567375673856739567405674156742567435674456745567465674756748567495675056751567525675356754567555675656757567585675956760567615676256763567645676556766567675676856769567705677156772567735677456775567765677756778567795678056781567825678356784567855678656787567885678956790567915679256793567945679556796567975679856799568005680156802568035680456805568065680756808568095681056811568125681356814568155681656817568185681956820568215682256823568245682556826568275682856829568305683156832568335683456835568365683756838568395684056841568425684356844568455684656847568485684956850568515685256853568545685556856568575685856859568605686156862568635686456865568665686756868568695687056871568725687356874568755687656877568785687956880568815688256883568845688556886568875688856889568905689156892568935689456895568965689756898568995690056901569025690356904569055690656907569085690956910569115691256913569145691556916569175691856919569205692156922569235692456925569265692756928569295693056931569325693356934569355693656937569385693956940569415694256943569445694556946569475694856949569505695156952569535695456955569565695756958569595696056961569625696356964569655696656967569685696956970569715697256973569745697556976569775697856979569805698156982569835698456985569865698756988569895699056991569925699356994569955699656997569985699957000570015700257003570045700557006570075700857009570105701157012570135701457015570165701757018570195702057021570225702357024570255702657027570285702957030570315703257033570345703557036570375703857039570405704157042570435704457045570465704757048570495705057051570525705357054570555705657057570585705957060570615706257063570645706557066570675706857069570705707157072570735707457075570765707757078570795708057081570825708357084570855708657087570885708957090570915709257093570945709557096570975709857099571005710157102571035710457105571065710757108571095711057111571125711357114571155711657117571185711957120571215712257123571245712557126571275712857129571305713157132571335713457135571365713757138571395714057141571425714357144571455714657147571485714957150571515715257153571545715557156571575715857159571605716157162571635716457165571665716757168571695717057171571725717357174571755717657177571785717957180571815718257183571845718557186571875718857189571905719157192571935719457195571965719757198571995720057201572025720357204572055720657207572085720957210572115721257213572145721557216572175721857219572205722157222572235722457225572265722757228572295723057231572325723357234572355723657237572385723957240572415724257243572445724557246572475724857249572505725157252572535725457255572565725757258572595726057261572625726357264572655726657267572685726957270572715727257273572745727557276572775727857279572805728157282572835728457285572865728757288572895729057291572925729357294572955729657297572985729957300573015730257303573045730557306573075730857309573105731157312573135731457315573165731757318573195732057321573225732357324573255732657327
  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 = 48);
  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 OPS = {
  208. dependency: 1,
  209. setLineWidth: 2,
  210. setLineCap: 3,
  211. setLineJoin: 4,
  212. setMiterLimit: 5,
  213. setDash: 6,
  214. setRenderingIntent: 7,
  215. setFlatness: 8,
  216. setGState: 9,
  217. save: 10,
  218. restore: 11,
  219. transform: 12,
  220. moveTo: 13,
  221. lineTo: 14,
  222. curveTo: 15,
  223. curveTo2: 16,
  224. curveTo3: 17,
  225. closePath: 18,
  226. rectangle: 19,
  227. stroke: 20,
  228. closeStroke: 21,
  229. fill: 22,
  230. eoFill: 23,
  231. fillStroke: 24,
  232. eoFillStroke: 25,
  233. closeFillStroke: 26,
  234. closeEOFillStroke: 27,
  235. endPath: 28,
  236. clip: 29,
  237. eoClip: 30,
  238. beginText: 31,
  239. endText: 32,
  240. setCharSpacing: 33,
  241. setWordSpacing: 34,
  242. setHScale: 35,
  243. setLeading: 36,
  244. setFont: 37,
  245. setTextRenderingMode: 38,
  246. setTextRise: 39,
  247. moveText: 40,
  248. setLeadingMoveText: 41,
  249. setTextMatrix: 42,
  250. nextLine: 43,
  251. showText: 44,
  252. showSpacedText: 45,
  253. nextLineShowText: 46,
  254. nextLineSetSpacingShowText: 47,
  255. setCharWidth: 48,
  256. setCharWidthAndBounds: 49,
  257. setStrokeColorSpace: 50,
  258. setFillColorSpace: 51,
  259. setStrokeColor: 52,
  260. setStrokeColorN: 53,
  261. setFillColor: 54,
  262. setFillColorN: 55,
  263. setStrokeGray: 56,
  264. setFillGray: 57,
  265. setStrokeRGBColor: 58,
  266. setFillRGBColor: 59,
  267. setStrokeCMYKColor: 60,
  268. setFillCMYKColor: 61,
  269. shadingFill: 62,
  270. beginInlineImage: 63,
  271. beginImageData: 64,
  272. endInlineImage: 65,
  273. paintXObject: 66,
  274. markPoint: 67,
  275. markPointProps: 68,
  276. beginMarkedContent: 69,
  277. beginMarkedContentProps: 70,
  278. endMarkedContent: 71,
  279. beginCompat: 72,
  280. endCompat: 73,
  281. paintFormXObjectBegin: 74,
  282. paintFormXObjectEnd: 75,
  283. beginGroup: 76,
  284. endGroup: 77,
  285. beginAnnotations: 78,
  286. endAnnotations: 79,
  287. beginAnnotation: 80,
  288. endAnnotation: 81,
  289. paintJpegXObject: 82,
  290. paintImageMaskXObject: 83,
  291. paintImageMaskXObjectGroup: 84,
  292. paintImageXObject: 85,
  293. paintInlineImageXObject: 86,
  294. paintInlineImageXObjectGroup: 87,
  295. paintImageXObjectRepeat: 88,
  296. paintImageMaskXObjectRepeat: 89,
  297. paintSolidColorImageMask: 90,
  298. constructPath: 91
  299. };
  300. var verbosity = VERBOSITY_LEVELS.warnings;
  301. function setVerbosityLevel(level) {
  302. verbosity = level;
  303. }
  304. function getVerbosityLevel() {
  305. return verbosity;
  306. }
  307. function info(msg) {
  308. if (verbosity >= VERBOSITY_LEVELS.infos) {
  309. console.log('Info: ' + msg);
  310. }
  311. }
  312. function warn(msg) {
  313. if (verbosity >= VERBOSITY_LEVELS.warnings) {
  314. console.log('Warning: ' + msg);
  315. }
  316. }
  317. function deprecated(details) {
  318. console.log('Deprecated API usage: ' + details);
  319. }
  320. function error(msg) {
  321. if (verbosity >= VERBOSITY_LEVELS.errors) {
  322. console.log('Error: ' + msg);
  323. console.log(backtrace());
  324. }
  325. throw new Error(msg);
  326. }
  327. function backtrace() {
  328. try {
  329. throw new Error();
  330. } catch (e) {
  331. return e.stack ? e.stack.split('\n').slice(2).join('\n') : '';
  332. }
  333. }
  334. function assert(cond, msg) {
  335. if (!cond) {
  336. error(msg);
  337. }
  338. }
  339. var UNSUPPORTED_FEATURES = {
  340. unknown: 'unknown',
  341. forms: 'forms',
  342. javaScript: 'javaScript',
  343. smask: 'smask',
  344. shadingPattern: 'shadingPattern',
  345. font: 'font'
  346. };
  347. function isSameOrigin(baseUrl, otherUrl) {
  348. try {
  349. var base = new URL(baseUrl);
  350. if (!base.origin || base.origin === 'null') {
  351. return false;
  352. }
  353. } catch (e) {
  354. return false;
  355. }
  356. var other = new URL(otherUrl, base);
  357. return base.origin === other.origin;
  358. }
  359. function isValidProtocol(url) {
  360. if (!url) {
  361. return false;
  362. }
  363. switch (url.protocol) {
  364. case 'http:':
  365. case 'https:':
  366. case 'ftp:':
  367. case 'mailto:':
  368. case 'tel:':
  369. return true;
  370. default:
  371. return false;
  372. }
  373. }
  374. function createValidAbsoluteUrl(url, baseUrl) {
  375. if (!url) {
  376. return null;
  377. }
  378. try {
  379. var absoluteUrl = baseUrl ? new URL(url, baseUrl) : new URL(url);
  380. if (isValidProtocol(absoluteUrl)) {
  381. return absoluteUrl;
  382. }
  383. } catch (ex) {
  384. }
  385. return null;
  386. }
  387. function shadow(obj, prop, value) {
  388. Object.defineProperty(obj, prop, {
  389. value: value,
  390. enumerable: true,
  391. configurable: true,
  392. writable: false
  393. });
  394. return value;
  395. }
  396. function getLookupTableFactory(initializer) {
  397. var lookup;
  398. return function () {
  399. if (initializer) {
  400. lookup = Object.create(null);
  401. initializer(lookup);
  402. initializer = null;
  403. }
  404. return lookup;
  405. };
  406. }
  407. var PasswordResponses = {
  408. NEED_PASSWORD: 1,
  409. INCORRECT_PASSWORD: 2
  410. };
  411. var PasswordException = function PasswordExceptionClosure() {
  412. function PasswordException(msg, code) {
  413. this.name = 'PasswordException';
  414. this.message = msg;
  415. this.code = code;
  416. }
  417. PasswordException.prototype = new Error();
  418. PasswordException.constructor = PasswordException;
  419. return PasswordException;
  420. }();
  421. var UnknownErrorException = function UnknownErrorExceptionClosure() {
  422. function UnknownErrorException(msg, details) {
  423. this.name = 'UnknownErrorException';
  424. this.message = msg;
  425. this.details = details;
  426. }
  427. UnknownErrorException.prototype = new Error();
  428. UnknownErrorException.constructor = UnknownErrorException;
  429. return UnknownErrorException;
  430. }();
  431. var InvalidPDFException = function InvalidPDFExceptionClosure() {
  432. function InvalidPDFException(msg) {
  433. this.name = 'InvalidPDFException';
  434. this.message = msg;
  435. }
  436. InvalidPDFException.prototype = new Error();
  437. InvalidPDFException.constructor = InvalidPDFException;
  438. return InvalidPDFException;
  439. }();
  440. var MissingPDFException = function MissingPDFExceptionClosure() {
  441. function MissingPDFException(msg) {
  442. this.name = 'MissingPDFException';
  443. this.message = msg;
  444. }
  445. MissingPDFException.prototype = new Error();
  446. MissingPDFException.constructor = MissingPDFException;
  447. return MissingPDFException;
  448. }();
  449. var UnexpectedResponseException = function UnexpectedResponseExceptionClosure() {
  450. function UnexpectedResponseException(msg, status) {
  451. this.name = 'UnexpectedResponseException';
  452. this.message = msg;
  453. this.status = status;
  454. }
  455. UnexpectedResponseException.prototype = new Error();
  456. UnexpectedResponseException.constructor = UnexpectedResponseException;
  457. return UnexpectedResponseException;
  458. }();
  459. var NotImplementedException = function NotImplementedExceptionClosure() {
  460. function NotImplementedException(msg) {
  461. this.message = msg;
  462. }
  463. NotImplementedException.prototype = new Error();
  464. NotImplementedException.prototype.name = 'NotImplementedException';
  465. NotImplementedException.constructor = NotImplementedException;
  466. return NotImplementedException;
  467. }();
  468. var MissingDataException = function MissingDataExceptionClosure() {
  469. function MissingDataException(begin, end) {
  470. this.begin = begin;
  471. this.end = end;
  472. this.message = 'Missing data [' + begin + ', ' + end + ')';
  473. }
  474. MissingDataException.prototype = new Error();
  475. MissingDataException.prototype.name = 'MissingDataException';
  476. MissingDataException.constructor = MissingDataException;
  477. return MissingDataException;
  478. }();
  479. var XRefParseException = function XRefParseExceptionClosure() {
  480. function XRefParseException(msg) {
  481. this.message = msg;
  482. }
  483. XRefParseException.prototype = new Error();
  484. XRefParseException.prototype.name = 'XRefParseException';
  485. XRefParseException.constructor = XRefParseException;
  486. return XRefParseException;
  487. }();
  488. var NullCharactersRegExp = /\x00/g;
  489. function removeNullCharacters(str) {
  490. if (typeof str !== 'string') {
  491. warn('The argument for removeNullCharacters must be a string.');
  492. return str;
  493. }
  494. return str.replace(NullCharactersRegExp, '');
  495. }
  496. function bytesToString(bytes) {
  497. assert(bytes !== null && typeof bytes === 'object' && bytes.length !== undefined, 'Invalid argument for bytesToString');
  498. var length = bytes.length;
  499. var MAX_ARGUMENT_COUNT = 8192;
  500. if (length < MAX_ARGUMENT_COUNT) {
  501. return String.fromCharCode.apply(null, bytes);
  502. }
  503. var strBuf = [];
  504. for (var i = 0; i < length; i += MAX_ARGUMENT_COUNT) {
  505. var chunkEnd = Math.min(i + MAX_ARGUMENT_COUNT, length);
  506. var chunk = bytes.subarray(i, chunkEnd);
  507. strBuf.push(String.fromCharCode.apply(null, chunk));
  508. }
  509. return strBuf.join('');
  510. }
  511. function stringToBytes(str) {
  512. assert(typeof str === 'string', 'Invalid argument for stringToBytes');
  513. var length = str.length;
  514. var bytes = new Uint8Array(length);
  515. for (var i = 0; i < length; ++i) {
  516. bytes[i] = str.charCodeAt(i) & 0xFF;
  517. }
  518. return bytes;
  519. }
  520. function arrayByteLength(arr) {
  521. if (arr.length !== undefined) {
  522. return arr.length;
  523. }
  524. assert(arr.byteLength !== undefined);
  525. return arr.byteLength;
  526. }
  527. function arraysToBytes(arr) {
  528. if (arr.length === 1 && arr[0] instanceof Uint8Array) {
  529. return arr[0];
  530. }
  531. var resultLength = 0;
  532. var i, ii = arr.length;
  533. var item, itemLength;
  534. for (i = 0; i < ii; i++) {
  535. item = arr[i];
  536. itemLength = arrayByteLength(item);
  537. resultLength += itemLength;
  538. }
  539. var pos = 0;
  540. var data = new Uint8Array(resultLength);
  541. for (i = 0; i < ii; i++) {
  542. item = arr[i];
  543. if (!(item instanceof Uint8Array)) {
  544. if (typeof item === 'string') {
  545. item = stringToBytes(item);
  546. } else {
  547. item = new Uint8Array(item);
  548. }
  549. }
  550. itemLength = item.byteLength;
  551. data.set(item, pos);
  552. pos += itemLength;
  553. }
  554. return data;
  555. }
  556. function string32(value) {
  557. return String.fromCharCode(value >> 24 & 0xff, value >> 16 & 0xff, value >> 8 & 0xff, value & 0xff);
  558. }
  559. function log2(x) {
  560. var n = 1, i = 0;
  561. while (x > n) {
  562. n <<= 1;
  563. i++;
  564. }
  565. return i;
  566. }
  567. function readInt8(data, start) {
  568. return data[start] << 24 >> 24;
  569. }
  570. function readUint16(data, offset) {
  571. return data[offset] << 8 | data[offset + 1];
  572. }
  573. function readUint32(data, offset) {
  574. return (data[offset] << 24 | data[offset + 1] << 16 | data[offset + 2] << 8 | data[offset + 3]) >>> 0;
  575. }
  576. function isLittleEndian() {
  577. var buffer8 = new Uint8Array(2);
  578. buffer8[0] = 1;
  579. var buffer16 = new Uint16Array(buffer8.buffer);
  580. return buffer16[0] === 1;
  581. }
  582. function isEvalSupported() {
  583. try {
  584. new Function('');
  585. return true;
  586. } catch (e) {
  587. return false;
  588. }
  589. }
  590. var Uint32ArrayView = function Uint32ArrayViewClosure() {
  591. function Uint32ArrayView(buffer, length) {
  592. this.buffer = buffer;
  593. this.byteLength = buffer.length;
  594. this.length = length === undefined ? this.byteLength >> 2 : length;
  595. ensureUint32ArrayViewProps(this.length);
  596. }
  597. Uint32ArrayView.prototype = Object.create(null);
  598. var uint32ArrayViewSetters = 0;
  599. function createUint32ArrayProp(index) {
  600. return {
  601. get: function () {
  602. var buffer = this.buffer, offset = index << 2;
  603. return (buffer[offset] | buffer[offset + 1] << 8 | buffer[offset + 2] << 16 | buffer[offset + 3] << 24) >>> 0;
  604. },
  605. set: function (value) {
  606. var buffer = this.buffer, offset = index << 2;
  607. buffer[offset] = value & 255;
  608. buffer[offset + 1] = value >> 8 & 255;
  609. buffer[offset + 2] = value >> 16 & 255;
  610. buffer[offset + 3] = value >>> 24 & 255;
  611. }
  612. };
  613. }
  614. function ensureUint32ArrayViewProps(length) {
  615. while (uint32ArrayViewSetters < length) {
  616. Object.defineProperty(Uint32ArrayView.prototype, uint32ArrayViewSetters, createUint32ArrayProp(uint32ArrayViewSetters));
  617. uint32ArrayViewSetters++;
  618. }
  619. }
  620. return Uint32ArrayView;
  621. }();
  622. exports.Uint32ArrayView = Uint32ArrayView;
  623. var IDENTITY_MATRIX = [
  624. 1,
  625. 0,
  626. 0,
  627. 1,
  628. 0,
  629. 0
  630. ];
  631. var Util = function UtilClosure() {
  632. function Util() {
  633. }
  634. var rgbBuf = [
  635. 'rgb(',
  636. 0,
  637. ',',
  638. 0,
  639. ',',
  640. 0,
  641. ')'
  642. ];
  643. Util.makeCssRgb = function Util_makeCssRgb(r, g, b) {
  644. rgbBuf[1] = r;
  645. rgbBuf[3] = g;
  646. rgbBuf[5] = b;
  647. return rgbBuf.join('');
  648. };
  649. Util.transform = function Util_transform(m1, m2) {
  650. return [
  651. m1[0] * m2[0] + m1[2] * m2[1],
  652. m1[1] * m2[0] + m1[3] * m2[1],
  653. m1[0] * m2[2] + m1[2] * m2[3],
  654. m1[1] * m2[2] + m1[3] * m2[3],
  655. m1[0] * m2[4] + m1[2] * m2[5] + m1[4],
  656. m1[1] * m2[4] + m1[3] * m2[5] + m1[5]
  657. ];
  658. };
  659. Util.applyTransform = function Util_applyTransform(p, m) {
  660. var xt = p[0] * m[0] + p[1] * m[2] + m[4];
  661. var yt = p[0] * m[1] + p[1] * m[3] + m[5];
  662. return [
  663. xt,
  664. yt
  665. ];
  666. };
  667. Util.applyInverseTransform = function Util_applyInverseTransform(p, m) {
  668. var d = m[0] * m[3] - m[1] * m[2];
  669. var xt = (p[0] * m[3] - p[1] * m[2] + m[2] * m[5] - m[4] * m[3]) / d;
  670. var yt = (-p[0] * m[1] + p[1] * m[0] + m[4] * m[1] - m[5] * m[0]) / d;
  671. return [
  672. xt,
  673. yt
  674. ];
  675. };
  676. Util.getAxialAlignedBoundingBox = function Util_getAxialAlignedBoundingBox(r, m) {
  677. var p1 = Util.applyTransform(r, m);
  678. var p2 = Util.applyTransform(r.slice(2, 4), m);
  679. var p3 = Util.applyTransform([
  680. r[0],
  681. r[3]
  682. ], m);
  683. var p4 = Util.applyTransform([
  684. r[2],
  685. r[1]
  686. ], m);
  687. return [
  688. Math.min(p1[0], p2[0], p3[0], p4[0]),
  689. Math.min(p1[1], p2[1], p3[1], p4[1]),
  690. Math.max(p1[0], p2[0], p3[0], p4[0]),
  691. Math.max(p1[1], p2[1], p3[1], p4[1])
  692. ];
  693. };
  694. Util.inverseTransform = function Util_inverseTransform(m) {
  695. var d = m[0] * m[3] - m[1] * m[2];
  696. return [
  697. m[3] / d,
  698. -m[1] / d,
  699. -m[2] / d,
  700. m[0] / d,
  701. (m[2] * m[5] - m[4] * m[3]) / d,
  702. (m[4] * m[1] - m[5] * m[0]) / d
  703. ];
  704. };
  705. Util.apply3dTransform = function Util_apply3dTransform(m, v) {
  706. return [
  707. m[0] * v[0] + m[1] * v[1] + m[2] * v[2],
  708. m[3] * v[0] + m[4] * v[1] + m[5] * v[2],
  709. m[6] * v[0] + m[7] * v[1] + m[8] * v[2]
  710. ];
  711. };
  712. Util.singularValueDecompose2dScale = function Util_singularValueDecompose2dScale(m) {
  713. var transpose = [
  714. m[0],
  715. m[2],
  716. m[1],
  717. m[3]
  718. ];
  719. var a = m[0] * transpose[0] + m[1] * transpose[2];
  720. var b = m[0] * transpose[1] + m[1] * transpose[3];
  721. var c = m[2] * transpose[0] + m[3] * transpose[2];
  722. var d = m[2] * transpose[1] + m[3] * transpose[3];
  723. var first = (a + d) / 2;
  724. var second = Math.sqrt((a + d) * (a + d) - 4 * (a * d - c * b)) / 2;
  725. var sx = first + second || 1;
  726. var sy = first - second || 1;
  727. return [
  728. Math.sqrt(sx),
  729. Math.sqrt(sy)
  730. ];
  731. };
  732. Util.normalizeRect = function Util_normalizeRect(rect) {
  733. var r = rect.slice(0);
  734. if (rect[0] > rect[2]) {
  735. r[0] = rect[2];
  736. r[2] = rect[0];
  737. }
  738. if (rect[1] > rect[3]) {
  739. r[1] = rect[3];
  740. r[3] = rect[1];
  741. }
  742. return r;
  743. };
  744. Util.intersect = function Util_intersect(rect1, rect2) {
  745. function compare(a, b) {
  746. return a - b;
  747. }
  748. var orderedX = [
  749. rect1[0],
  750. rect1[2],
  751. rect2[0],
  752. rect2[2]
  753. ].sort(compare), orderedY = [
  754. rect1[1],
  755. rect1[3],
  756. rect2[1],
  757. rect2[3]
  758. ].sort(compare), result = [];
  759. rect1 = Util.normalizeRect(rect1);
  760. rect2 = Util.normalizeRect(rect2);
  761. if (orderedX[0] === rect1[0] && orderedX[1] === rect2[0] || orderedX[0] === rect2[0] && orderedX[1] === rect1[0]) {
  762. result[0] = orderedX[1];
  763. result[2] = orderedX[2];
  764. } else {
  765. return false;
  766. }
  767. if (orderedY[0] === rect1[1] && orderedY[1] === rect2[1] || orderedY[0] === rect2[1] && orderedY[1] === rect1[1]) {
  768. result[1] = orderedY[1];
  769. result[3] = orderedY[2];
  770. } else {
  771. return false;
  772. }
  773. return result;
  774. };
  775. Util.sign = function Util_sign(num) {
  776. return num < 0 ? -1 : 1;
  777. };
  778. var ROMAN_NUMBER_MAP = [
  779. '',
  780. 'C',
  781. 'CC',
  782. 'CCC',
  783. 'CD',
  784. 'D',
  785. 'DC',
  786. 'DCC',
  787. 'DCCC',
  788. 'CM',
  789. '',
  790. 'X',
  791. 'XX',
  792. 'XXX',
  793. 'XL',
  794. 'L',
  795. 'LX',
  796. 'LXX',
  797. 'LXXX',
  798. 'XC',
  799. '',
  800. 'I',
  801. 'II',
  802. 'III',
  803. 'IV',
  804. 'V',
  805. 'VI',
  806. 'VII',
  807. 'VIII',
  808. 'IX'
  809. ];
  810. Util.toRoman = function Util_toRoman(number, lowerCase) {
  811. assert(isInt(number) && number > 0, 'The number should be a positive integer.');
  812. var pos, romanBuf = [];
  813. while (number >= 1000) {
  814. number -= 1000;
  815. romanBuf.push('M');
  816. }
  817. pos = number / 100 | 0;
  818. number %= 100;
  819. romanBuf.push(ROMAN_NUMBER_MAP[pos]);
  820. pos = number / 10 | 0;
  821. number %= 10;
  822. romanBuf.push(ROMAN_NUMBER_MAP[10 + pos]);
  823. romanBuf.push(ROMAN_NUMBER_MAP[20 + number]);
  824. var romanStr = romanBuf.join('');
  825. return lowerCase ? romanStr.toLowerCase() : romanStr;
  826. };
  827. Util.appendToArray = function Util_appendToArray(arr1, arr2) {
  828. Array.prototype.push.apply(arr1, arr2);
  829. };
  830. Util.prependToArray = function Util_prependToArray(arr1, arr2) {
  831. Array.prototype.unshift.apply(arr1, arr2);
  832. };
  833. Util.extendObj = function extendObj(obj1, obj2) {
  834. for (var key in obj2) {
  835. obj1[key] = obj2[key];
  836. }
  837. };
  838. Util.getInheritableProperty = function Util_getInheritableProperty(dict, name, getArray) {
  839. while (dict && !dict.has(name)) {
  840. dict = dict.get('Parent');
  841. }
  842. if (!dict) {
  843. return null;
  844. }
  845. return getArray ? dict.getArray(name) : dict.get(name);
  846. };
  847. Util.inherit = function Util_inherit(sub, base, prototype) {
  848. sub.prototype = Object.create(base.prototype);
  849. sub.prototype.constructor = sub;
  850. for (var prop in prototype) {
  851. sub.prototype[prop] = prototype[prop];
  852. }
  853. };
  854. Util.loadScript = function Util_loadScript(src, callback) {
  855. var script = document.createElement('script');
  856. var loaded = false;
  857. script.setAttribute('src', src);
  858. if (callback) {
  859. script.onload = function () {
  860. if (!loaded) {
  861. callback();
  862. }
  863. loaded = true;
  864. };
  865. }
  866. document.getElementsByTagName('head')[0].appendChild(script);
  867. };
  868. return Util;
  869. }();
  870. var PageViewport = function PageViewportClosure() {
  871. function PageViewport(viewBox, scale, rotation, offsetX, offsetY, dontFlip) {
  872. this.viewBox = viewBox;
  873. this.scale = scale;
  874. this.rotation = rotation;
  875. this.offsetX = offsetX;
  876. this.offsetY = offsetY;
  877. var centerX = (viewBox[2] + viewBox[0]) / 2;
  878. var centerY = (viewBox[3] + viewBox[1]) / 2;
  879. var rotateA, rotateB, rotateC, rotateD;
  880. rotation = rotation % 360;
  881. rotation = rotation < 0 ? rotation + 360 : rotation;
  882. switch (rotation) {
  883. case 180:
  884. rotateA = -1;
  885. rotateB = 0;
  886. rotateC = 0;
  887. rotateD = 1;
  888. break;
  889. case 90:
  890. rotateA = 0;
  891. rotateB = 1;
  892. rotateC = 1;
  893. rotateD = 0;
  894. break;
  895. case 270:
  896. rotateA = 0;
  897. rotateB = -1;
  898. rotateC = -1;
  899. rotateD = 0;
  900. break;
  901. default:
  902. rotateA = 1;
  903. rotateB = 0;
  904. rotateC = 0;
  905. rotateD = -1;
  906. break;
  907. }
  908. if (dontFlip) {
  909. rotateC = -rotateC;
  910. rotateD = -rotateD;
  911. }
  912. var offsetCanvasX, offsetCanvasY;
  913. var width, height;
  914. if (rotateA === 0) {
  915. offsetCanvasX = Math.abs(centerY - viewBox[1]) * scale + offsetX;
  916. offsetCanvasY = Math.abs(centerX - viewBox[0]) * scale + offsetY;
  917. width = Math.abs(viewBox[3] - viewBox[1]) * scale;
  918. height = Math.abs(viewBox[2] - viewBox[0]) * scale;
  919. } else {
  920. offsetCanvasX = Math.abs(centerX - viewBox[0]) * scale + offsetX;
  921. offsetCanvasY = Math.abs(centerY - viewBox[1]) * scale + offsetY;
  922. width = Math.abs(viewBox[2] - viewBox[0]) * scale;
  923. height = Math.abs(viewBox[3] - viewBox[1]) * scale;
  924. }
  925. this.transform = [
  926. rotateA * scale,
  927. rotateB * scale,
  928. rotateC * scale,
  929. rotateD * scale,
  930. offsetCanvasX - rotateA * scale * centerX - rotateC * scale * centerY,
  931. offsetCanvasY - rotateB * scale * centerX - rotateD * scale * centerY
  932. ];
  933. this.width = width;
  934. this.height = height;
  935. this.fontScale = scale;
  936. }
  937. PageViewport.prototype = {
  938. clone: function PageViewPort_clone(args) {
  939. args = args || {};
  940. var scale = 'scale' in args ? args.scale : this.scale;
  941. var rotation = 'rotation' in args ? args.rotation : this.rotation;
  942. return new PageViewport(this.viewBox.slice(), scale, rotation, this.offsetX, this.offsetY, args.dontFlip);
  943. },
  944. convertToViewportPoint: function PageViewport_convertToViewportPoint(x, y) {
  945. return Util.applyTransform([
  946. x,
  947. y
  948. ], this.transform);
  949. },
  950. convertToViewportRectangle: function PageViewport_convertToViewportRectangle(rect) {
  951. var tl = Util.applyTransform([
  952. rect[0],
  953. rect[1]
  954. ], this.transform);
  955. var br = Util.applyTransform([
  956. rect[2],
  957. rect[3]
  958. ], this.transform);
  959. return [
  960. tl[0],
  961. tl[1],
  962. br[0],
  963. br[1]
  964. ];
  965. },
  966. convertToPdfPoint: function PageViewport_convertToPdfPoint(x, y) {
  967. return Util.applyInverseTransform([
  968. x,
  969. y
  970. ], this.transform);
  971. }
  972. };
  973. return PageViewport;
  974. }();
  975. var PDFStringTranslateTable = [
  976. 0,
  977. 0,
  978. 0,
  979. 0,
  980. 0,
  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. 0x2D8,
  1001. 0x2C7,
  1002. 0x2C6,
  1003. 0x2D9,
  1004. 0x2DD,
  1005. 0x2DB,
  1006. 0x2DA,
  1007. 0x2DC,
  1008. 0,
  1009. 0,
  1010. 0,
  1011. 0,
  1012. 0,
  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. 0x2022,
  1105. 0x2020,
  1106. 0x2021,
  1107. 0x2026,
  1108. 0x2014,
  1109. 0x2013,
  1110. 0x192,
  1111. 0x2044,
  1112. 0x2039,
  1113. 0x203A,
  1114. 0x2212,
  1115. 0x2030,
  1116. 0x201E,
  1117. 0x201C,
  1118. 0x201D,
  1119. 0x2018,
  1120. 0x2019,
  1121. 0x201A,
  1122. 0x2122,
  1123. 0xFB01,
  1124. 0xFB02,
  1125. 0x141,
  1126. 0x152,
  1127. 0x160,
  1128. 0x178,
  1129. 0x17D,
  1130. 0x131,
  1131. 0x142,
  1132. 0x153,
  1133. 0x161,
  1134. 0x17E,
  1135. 0,
  1136. 0x20AC
  1137. ];
  1138. function stringToPDFString(str) {
  1139. var i, n = str.length, strBuf = [];
  1140. if (str[0] === '\xFE' && str[1] === '\xFF') {
  1141. for (i = 2; i < n; i += 2) {
  1142. strBuf.push(String.fromCharCode(str.charCodeAt(i) << 8 | str.charCodeAt(i + 1)));
  1143. }
  1144. } else {
  1145. for (i = 0; i < n; ++i) {
  1146. var code = PDFStringTranslateTable[str.charCodeAt(i)];
  1147. strBuf.push(code ? String.fromCharCode(code) : str.charAt(i));
  1148. }
  1149. }
  1150. return strBuf.join('');
  1151. }
  1152. function stringToUTF8String(str) {
  1153. return decodeURIComponent(escape(str));
  1154. }
  1155. function utf8StringToString(str) {
  1156. return unescape(encodeURIComponent(str));
  1157. }
  1158. function isEmptyObj(obj) {
  1159. for (var key in obj) {
  1160. return false;
  1161. }
  1162. return true;
  1163. }
  1164. function isBool(v) {
  1165. return typeof v === 'boolean';
  1166. }
  1167. function isInt(v) {
  1168. return typeof v === 'number' && (v | 0) === v;
  1169. }
  1170. function isNum(v) {
  1171. return typeof v === 'number';
  1172. }
  1173. function isString(v) {
  1174. return typeof v === 'string';
  1175. }
  1176. function isArray(v) {
  1177. return v instanceof Array;
  1178. }
  1179. function isArrayBuffer(v) {
  1180. return typeof v === 'object' && v !== null && v.byteLength !== undefined;
  1181. }
  1182. function isSpace(ch) {
  1183. return ch === 0x20 || ch === 0x09 || ch === 0x0D || ch === 0x0A;
  1184. }
  1185. function createPromiseCapability() {
  1186. var capability = {};
  1187. capability.promise = new Promise(function (resolve, reject) {
  1188. capability.resolve = resolve;
  1189. capability.reject = reject;
  1190. });
  1191. return capability;
  1192. }
  1193. (function PromiseClosure() {
  1194. if (globalScope.Promise) {
  1195. if (typeof globalScope.Promise.all !== 'function') {
  1196. globalScope.Promise.all = function (iterable) {
  1197. var count = 0, results = [], resolve, reject;
  1198. var promise = new globalScope.Promise(function (resolve_, reject_) {
  1199. resolve = resolve_;
  1200. reject = reject_;
  1201. });
  1202. iterable.forEach(function (p, i) {
  1203. count++;
  1204. p.then(function (result) {
  1205. results[i] = result;
  1206. count--;
  1207. if (count === 0) {
  1208. resolve(results);
  1209. }
  1210. }, reject);
  1211. });
  1212. if (count === 0) {
  1213. resolve(results);
  1214. }
  1215. return promise;
  1216. };
  1217. }
  1218. if (typeof globalScope.Promise.resolve !== 'function') {
  1219. globalScope.Promise.resolve = function (value) {
  1220. return new globalScope.Promise(function (resolve) {
  1221. resolve(value);
  1222. });
  1223. };
  1224. }
  1225. if (typeof globalScope.Promise.reject !== 'function') {
  1226. globalScope.Promise.reject = function (reason) {
  1227. return new globalScope.Promise(function (resolve, reject) {
  1228. reject(reason);
  1229. });
  1230. };
  1231. }
  1232. if (typeof globalScope.Promise.prototype.catch !== 'function') {
  1233. globalScope.Promise.prototype.catch = function (onReject) {
  1234. return globalScope.Promise.prototype.then(undefined, onReject);
  1235. };
  1236. }
  1237. return;
  1238. }
  1239. var STATUS_PENDING = 0;
  1240. var STATUS_RESOLVED = 1;
  1241. var STATUS_REJECTED = 2;
  1242. var REJECTION_TIMEOUT = 500;
  1243. var HandlerManager = {
  1244. handlers: [],
  1245. running: false,
  1246. unhandledRejections: [],
  1247. pendingRejectionCheck: false,
  1248. scheduleHandlers: function scheduleHandlers(promise) {
  1249. if (promise._status === STATUS_PENDING) {
  1250. return;
  1251. }
  1252. this.handlers = this.handlers.concat(promise._handlers);
  1253. promise._handlers = [];
  1254. if (this.running) {
  1255. return;
  1256. }
  1257. this.running = true;
  1258. setTimeout(this.runHandlers.bind(this), 0);
  1259. },
  1260. runHandlers: function runHandlers() {
  1261. var RUN_TIMEOUT = 1;
  1262. var timeoutAt = Date.now() + RUN_TIMEOUT;
  1263. while (this.handlers.length > 0) {
  1264. var handler = this.handlers.shift();
  1265. var nextStatus = handler.thisPromise._status;
  1266. var nextValue = handler.thisPromise._value;
  1267. try {
  1268. if (nextStatus === STATUS_RESOLVED) {
  1269. if (typeof handler.onResolve === 'function') {
  1270. nextValue = handler.onResolve(nextValue);
  1271. }
  1272. } else if (typeof handler.onReject === 'function') {
  1273. nextValue = handler.onReject(nextValue);
  1274. nextStatus = STATUS_RESOLVED;
  1275. if (handler.thisPromise._unhandledRejection) {
  1276. this.removeUnhandeledRejection(handler.thisPromise);
  1277. }
  1278. }
  1279. } catch (ex) {
  1280. nextStatus = STATUS_REJECTED;
  1281. nextValue = ex;
  1282. }
  1283. handler.nextPromise._updateStatus(nextStatus, nextValue);
  1284. if (Date.now() >= timeoutAt) {
  1285. break;
  1286. }
  1287. }
  1288. if (this.handlers.length > 0) {
  1289. setTimeout(this.runHandlers.bind(this), 0);
  1290. return;
  1291. }
  1292. this.running = false;
  1293. },
  1294. addUnhandledRejection: function addUnhandledRejection(promise) {
  1295. this.unhandledRejections.push({
  1296. promise: promise,
  1297. time: Date.now()
  1298. });
  1299. this.scheduleRejectionCheck();
  1300. },
  1301. removeUnhandeledRejection: function removeUnhandeledRejection(promise) {
  1302. promise._unhandledRejection = false;
  1303. for (var i = 0; i < this.unhandledRejections.length; i++) {
  1304. if (this.unhandledRejections[i].promise === promise) {
  1305. this.unhandledRejections.splice(i);
  1306. i--;
  1307. }
  1308. }
  1309. },
  1310. scheduleRejectionCheck: function scheduleRejectionCheck() {
  1311. if (this.pendingRejectionCheck) {
  1312. return;
  1313. }
  1314. this.pendingRejectionCheck = true;
  1315. setTimeout(function rejectionCheck() {
  1316. this.pendingRejectionCheck = false;
  1317. var now = Date.now();
  1318. for (var i = 0; i < this.unhandledRejections.length; i++) {
  1319. if (now - this.unhandledRejections[i].time > REJECTION_TIMEOUT) {
  1320. var unhandled = this.unhandledRejections[i].promise._value;
  1321. var msg = 'Unhandled rejection: ' + unhandled;
  1322. if (unhandled.stack) {
  1323. msg += '\n' + unhandled.stack;
  1324. }
  1325. warn(msg);
  1326. this.unhandledRejections.splice(i);
  1327. i--;
  1328. }
  1329. }
  1330. if (this.unhandledRejections.length) {
  1331. this.scheduleRejectionCheck();
  1332. }
  1333. }.bind(this), REJECTION_TIMEOUT);
  1334. }
  1335. };
  1336. var Promise = function Promise(resolver) {
  1337. this._status = STATUS_PENDING;
  1338. this._handlers = [];
  1339. try {
  1340. resolver.call(this, this._resolve.bind(this), this._reject.bind(this));
  1341. } catch (e) {
  1342. this._reject(e);
  1343. }
  1344. };
  1345. Promise.all = function Promise_all(promises) {
  1346. var resolveAll, rejectAll;
  1347. var deferred = new Promise(function (resolve, reject) {
  1348. resolveAll = resolve;
  1349. rejectAll = reject;
  1350. });
  1351. var unresolved = promises.length;
  1352. var results = [];
  1353. if (unresolved === 0) {
  1354. resolveAll(results);
  1355. return deferred;
  1356. }
  1357. function reject(reason) {
  1358. if (deferred._status === STATUS_REJECTED) {
  1359. return;
  1360. }
  1361. results = [];
  1362. rejectAll(reason);
  1363. }
  1364. for (var i = 0, ii = promises.length; i < ii; ++i) {
  1365. var promise = promises[i];
  1366. var resolve = function (i) {
  1367. return function (value) {
  1368. if (deferred._status === STATUS_REJECTED) {
  1369. return;
  1370. }
  1371. results[i] = value;
  1372. unresolved--;
  1373. if (unresolved === 0) {
  1374. resolveAll(results);
  1375. }
  1376. };
  1377. }(i);
  1378. if (Promise.isPromise(promise)) {
  1379. promise.then(resolve, reject);
  1380. } else {
  1381. resolve(promise);
  1382. }
  1383. }
  1384. return deferred;
  1385. };
  1386. Promise.isPromise = function Promise_isPromise(value) {
  1387. return value && typeof value.then === 'function';
  1388. };
  1389. Promise.resolve = function Promise_resolve(value) {
  1390. return new Promise(function (resolve) {
  1391. resolve(value);
  1392. });
  1393. };
  1394. Promise.reject = function Promise_reject(reason) {
  1395. return new Promise(function (resolve, reject) {
  1396. reject(reason);
  1397. });
  1398. };
  1399. Promise.prototype = {
  1400. _status: null,
  1401. _value: null,
  1402. _handlers: null,
  1403. _unhandledRejection: null,
  1404. _updateStatus: function Promise__updateStatus(status, value) {
  1405. if (this._status === STATUS_RESOLVED || this._status === STATUS_REJECTED) {
  1406. return;
  1407. }
  1408. if (status === STATUS_RESOLVED && Promise.isPromise(value)) {
  1409. value.then(this._updateStatus.bind(this, STATUS_RESOLVED), this._updateStatus.bind(this, STATUS_REJECTED));
  1410. return;
  1411. }
  1412. this._status = status;
  1413. this._value = value;
  1414. if (status === STATUS_REJECTED && this._handlers.length === 0) {
  1415. this._unhandledRejection = true;
  1416. HandlerManager.addUnhandledRejection(this);
  1417. }
  1418. HandlerManager.scheduleHandlers(this);
  1419. },
  1420. _resolve: function Promise_resolve(value) {
  1421. this._updateStatus(STATUS_RESOLVED, value);
  1422. },
  1423. _reject: function Promise_reject(reason) {
  1424. this._updateStatus(STATUS_REJECTED, reason);
  1425. },
  1426. then: function Promise_then(onResolve, onReject) {
  1427. var nextPromise = new Promise(function (resolve, reject) {
  1428. this.resolve = resolve;
  1429. this.reject = reject;
  1430. });
  1431. this._handlers.push({
  1432. thisPromise: this,
  1433. onResolve: onResolve,
  1434. onReject: onReject,
  1435. nextPromise: nextPromise
  1436. });
  1437. HandlerManager.scheduleHandlers(this);
  1438. return nextPromise;
  1439. },
  1440. catch: function Promise_catch(onReject) {
  1441. return this.then(undefined, onReject);
  1442. }
  1443. };
  1444. globalScope.Promise = Promise;
  1445. }());
  1446. (function WeakMapClosure() {
  1447. if (globalScope.WeakMap) {
  1448. return;
  1449. }
  1450. var id = 0;
  1451. function WeakMap() {
  1452. this.id = '$weakmap' + id++;
  1453. }
  1454. WeakMap.prototype = {
  1455. has: function (obj) {
  1456. return !!Object.getOwnPropertyDescriptor(obj, this.id);
  1457. },
  1458. get: function (obj, defaultValue) {
  1459. return this.has(obj) ? obj[this.id] : defaultValue;
  1460. },
  1461. set: function (obj, value) {
  1462. Object.defineProperty(obj, this.id, {
  1463. value: value,
  1464. enumerable: false,
  1465. configurable: true
  1466. });
  1467. },
  1468. delete: function (obj) {
  1469. delete obj[this.id];
  1470. }
  1471. };
  1472. globalScope.WeakMap = WeakMap;
  1473. }());
  1474. var StatTimer = function StatTimerClosure() {
  1475. function rpad(str, pad, length) {
  1476. while (str.length < length) {
  1477. str += pad;
  1478. }
  1479. return str;
  1480. }
  1481. function StatTimer() {
  1482. this.started = Object.create(null);
  1483. this.times = [];
  1484. this.enabled = true;
  1485. }
  1486. StatTimer.prototype = {
  1487. time: function StatTimer_time(name) {
  1488. if (!this.enabled) {
  1489. return;
  1490. }
  1491. if (name in this.started) {
  1492. warn('Timer is already running for ' + name);
  1493. }
  1494. this.started[name] = Date.now();
  1495. },
  1496. timeEnd: function StatTimer_timeEnd(name) {
  1497. if (!this.enabled) {
  1498. return;
  1499. }
  1500. if (!(name in this.started)) {
  1501. warn('Timer has not been started for ' + name);
  1502. }
  1503. this.times.push({
  1504. 'name': name,
  1505. 'start': this.started[name],
  1506. 'end': Date.now()
  1507. });
  1508. delete this.started[name];
  1509. },
  1510. toString: function StatTimer_toString() {
  1511. var i, ii;
  1512. var times = this.times;
  1513. var out = '';
  1514. var longest = 0;
  1515. for (i = 0, ii = times.length; i < ii; ++i) {
  1516. var name = times[i]['name'];
  1517. if (name.length > longest) {
  1518. longest = name.length;
  1519. }
  1520. }
  1521. for (i = 0, ii = times.length; i < ii; ++i) {
  1522. var span = times[i];
  1523. var duration = span.end - span.start;
  1524. out += rpad(span['name'], ' ', longest) + ' ' + duration + 'ms\n';
  1525. }
  1526. return out;
  1527. }
  1528. };
  1529. return StatTimer;
  1530. }();
  1531. var createBlob = function createBlob(data, contentType) {
  1532. if (typeof Blob !== 'undefined') {
  1533. return new Blob([data], { type: contentType });
  1534. }
  1535. warn('The "Blob" constructor is not supported.');
  1536. };
  1537. var createObjectURL = function createObjectURLClosure() {
  1538. var digits = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=';
  1539. return function createObjectURL(data, contentType, forceDataSchema) {
  1540. if (!forceDataSchema && typeof URL !== 'undefined' && URL.createObjectURL) {
  1541. var blob = createBlob(data, contentType);
  1542. return URL.createObjectURL(blob);
  1543. }
  1544. var buffer = 'data:' + contentType + ';base64,';
  1545. for (var i = 0, ii = data.length; i < ii; i += 3) {
  1546. var b1 = data[i] & 0xFF;
  1547. var b2 = data[i + 1] & 0xFF;
  1548. var b3 = data[i + 2] & 0xFF;
  1549. var d1 = b1 >> 2, d2 = (b1 & 3) << 4 | b2 >> 4;
  1550. var d3 = i + 1 < ii ? (b2 & 0xF) << 2 | b3 >> 6 : 64;
  1551. var d4 = i + 2 < ii ? b3 & 0x3F : 64;
  1552. buffer += digits[d1] + digits[d2] + digits[d3] + digits[d4];
  1553. }
  1554. return buffer;
  1555. };
  1556. }();
  1557. function MessageHandler(sourceName, targetName, comObj) {
  1558. this.sourceName = sourceName;
  1559. this.targetName = targetName;
  1560. this.comObj = comObj;
  1561. this.callbackIndex = 1;
  1562. this.postMessageTransfers = true;
  1563. var callbacksCapabilities = this.callbacksCapabilities = Object.create(null);
  1564. var ah = this.actionHandler = Object.create(null);
  1565. this._onComObjOnMessage = function messageHandlerComObjOnMessage(event) {
  1566. var data = event.data;
  1567. if (data.targetName !== this.sourceName) {
  1568. return;
  1569. }
  1570. if (data.isReply) {
  1571. var callbackId = data.callbackId;
  1572. if (data.callbackId in callbacksCapabilities) {
  1573. var callback = callbacksCapabilities[callbackId];
  1574. delete callbacksCapabilities[callbackId];
  1575. if ('error' in data) {
  1576. callback.reject(data.error);
  1577. } else {
  1578. callback.resolve(data.data);
  1579. }
  1580. } else {
  1581. error('Cannot resolve callback ' + callbackId);
  1582. }
  1583. } else if (data.action in ah) {
  1584. var action = ah[data.action];
  1585. if (data.callbackId) {
  1586. var sourceName = this.sourceName;
  1587. var targetName = data.sourceName;
  1588. Promise.resolve().then(function () {
  1589. return action[0].call(action[1], data.data);
  1590. }).then(function (result) {
  1591. comObj.postMessage({
  1592. sourceName: sourceName,
  1593. targetName: targetName,
  1594. isReply: true,
  1595. callbackId: data.callbackId,
  1596. data: result
  1597. });
  1598. }, function (reason) {
  1599. if (reason instanceof Error) {
  1600. reason = reason + '';
  1601. }
  1602. comObj.postMessage({
  1603. sourceName: sourceName,
  1604. targetName: targetName,
  1605. isReply: true,
  1606. callbackId: data.callbackId,
  1607. error: reason
  1608. });
  1609. });
  1610. } else {
  1611. action[0].call(action[1], data.data);
  1612. }
  1613. } else {
  1614. error('Unknown action from worker: ' + data.action);
  1615. }
  1616. }.bind(this);
  1617. comObj.addEventListener('message', this._onComObjOnMessage);
  1618. }
  1619. MessageHandler.prototype = {
  1620. on: function messageHandlerOn(actionName, handler, scope) {
  1621. var ah = this.actionHandler;
  1622. if (ah[actionName]) {
  1623. error('There is already an actionName called "' + actionName + '"');
  1624. }
  1625. ah[actionName] = [
  1626. handler,
  1627. scope
  1628. ];
  1629. },
  1630. send: function messageHandlerSend(actionName, data, transfers) {
  1631. var message = {
  1632. sourceName: this.sourceName,
  1633. targetName: this.targetName,
  1634. action: actionName,
  1635. data: data
  1636. };
  1637. this.postMessage(message, transfers);
  1638. },
  1639. sendWithPromise: function messageHandlerSendWithPromise(actionName, data, transfers) {
  1640. var callbackId = this.callbackIndex++;
  1641. var message = {
  1642. sourceName: this.sourceName,
  1643. targetName: this.targetName,
  1644. action: actionName,
  1645. data: data,
  1646. callbackId: callbackId
  1647. };
  1648. var capability = createPromiseCapability();
  1649. this.callbacksCapabilities[callbackId] = capability;
  1650. try {
  1651. this.postMessage(message, transfers);
  1652. } catch (e) {
  1653. capability.reject(e);
  1654. }
  1655. return capability.promise;
  1656. },
  1657. postMessage: function (message, transfers) {
  1658. if (transfers && this.postMessageTransfers) {
  1659. this.comObj.postMessage(message, transfers);
  1660. } else {
  1661. this.comObj.postMessage(message);
  1662. }
  1663. },
  1664. destroy: function () {
  1665. this.comObj.removeEventListener('message', this._onComObjOnMessage);
  1666. }
  1667. };
  1668. function loadJpegStream(id, imageUrl, objs) {
  1669. var img = new Image();
  1670. img.onload = function loadJpegStream_onloadClosure() {
  1671. objs.resolve(id, img);
  1672. };
  1673. img.onerror = function loadJpegStream_onerrorClosure() {
  1674. objs.resolve(id, null);
  1675. warn('Error during JPEG image loading');
  1676. };
  1677. img.src = imageUrl;
  1678. }
  1679. (function checkURLConstructor(scope) {
  1680. var hasWorkingUrl = false;
  1681. try {
  1682. if (typeof URL === 'function' && typeof URL.prototype === 'object' && 'origin' in URL.prototype) {
  1683. var u = new URL('b', 'http://a');
  1684. u.pathname = 'c%20d';
  1685. hasWorkingUrl = u.href === 'http://a/c%20d';
  1686. }
  1687. } catch (e) {
  1688. }
  1689. if (hasWorkingUrl) {
  1690. return;
  1691. }
  1692. var relative = Object.create(null);
  1693. relative['ftp'] = 21;
  1694. relative['file'] = 0;
  1695. relative['gopher'] = 70;
  1696. relative['http'] = 80;
  1697. relative['https'] = 443;
  1698. relative['ws'] = 80;
  1699. relative['wss'] = 443;
  1700. var relativePathDotMapping = Object.create(null);
  1701. relativePathDotMapping['%2e'] = '.';
  1702. relativePathDotMapping['.%2e'] = '..';
  1703. relativePathDotMapping['%2e.'] = '..';
  1704. relativePathDotMapping['%2e%2e'] = '..';
  1705. function isRelativeScheme(scheme) {
  1706. return relative[scheme] !== undefined;
  1707. }
  1708. function invalid() {
  1709. clear.call(this);
  1710. this._isInvalid = true;
  1711. }
  1712. function IDNAToASCII(h) {
  1713. if (h === '') {
  1714. invalid.call(this);
  1715. }
  1716. return h.toLowerCase();
  1717. }
  1718. function percentEscape(c) {
  1719. var unicode = c.charCodeAt(0);
  1720. if (unicode > 0x20 && unicode < 0x7F && [
  1721. 0x22,
  1722. 0x23,
  1723. 0x3C,
  1724. 0x3E,
  1725. 0x3F,
  1726. 0x60
  1727. ].indexOf(unicode) === -1) {
  1728. return c;
  1729. }
  1730. return encodeURIComponent(c);
  1731. }
  1732. function percentEscapeQuery(c) {
  1733. var unicode = c.charCodeAt(0);
  1734. if (unicode > 0x20 && unicode < 0x7F && [
  1735. 0x22,
  1736. 0x23,
  1737. 0x3C,
  1738. 0x3E,
  1739. 0x60
  1740. ].indexOf(unicode) === -1) {
  1741. return c;
  1742. }
  1743. return encodeURIComponent(c);
  1744. }
  1745. var EOF, ALPHA = /[a-zA-Z]/, ALPHANUMERIC = /[a-zA-Z0-9\+\-\.]/;
  1746. function parse(input, stateOverride, base) {
  1747. function err(message) {
  1748. errors.push(message);
  1749. }
  1750. var state = stateOverride || 'scheme start', cursor = 0, buffer = '', seenAt = false, seenBracket = false, errors = [];
  1751. loop:
  1752. while ((input[cursor - 1] !== EOF || cursor === 0) && !this._isInvalid) {
  1753. var c = input[cursor];
  1754. switch (state) {
  1755. case 'scheme start':
  1756. if (c && ALPHA.test(c)) {
  1757. buffer += c.toLowerCase();
  1758. state = 'scheme';
  1759. } else if (!stateOverride) {
  1760. buffer = '';
  1761. state = 'no scheme';
  1762. continue;
  1763. } else {
  1764. err('Invalid scheme.');
  1765. break loop;
  1766. }
  1767. break;
  1768. case 'scheme':
  1769. if (c && ALPHANUMERIC.test(c)) {
  1770. buffer += c.toLowerCase();
  1771. } else if (c === ':') {
  1772. this._scheme = buffer;
  1773. buffer = '';
  1774. if (stateOverride) {
  1775. break loop;
  1776. }
  1777. if (isRelativeScheme(this._scheme)) {
  1778. this._isRelative = true;
  1779. }
  1780. if (this._scheme === 'file') {
  1781. state = 'relative';
  1782. } else if (this._isRelative && base && base._scheme === this._scheme) {
  1783. state = 'relative or authority';
  1784. } else if (this._isRelative) {
  1785. state = 'authority first slash';
  1786. } else {
  1787. state = 'scheme data';
  1788. }
  1789. } else if (!stateOverride) {
  1790. buffer = '';
  1791. cursor = 0;
  1792. state = 'no scheme';
  1793. continue;
  1794. } else if (EOF === c) {
  1795. break loop;
  1796. } else {
  1797. err('Code point not allowed in scheme: ' + c);
  1798. break loop;
  1799. }
  1800. break;
  1801. case 'scheme data':
  1802. if (c === '?') {
  1803. this._query = '?';
  1804. state = 'query';
  1805. } else if (c === '#') {
  1806. this._fragment = '#';
  1807. state = 'fragment';
  1808. } else {
  1809. if (EOF !== c && '\t' !== c && '\n' !== c && '\r' !== c) {
  1810. this._schemeData += percentEscape(c);
  1811. }
  1812. }
  1813. break;
  1814. case 'no scheme':
  1815. if (!base || !isRelativeScheme(base._scheme)) {
  1816. err('Missing scheme.');
  1817. invalid.call(this);
  1818. } else {
  1819. state = 'relative';
  1820. continue;
  1821. }
  1822. break;
  1823. case 'relative or authority':
  1824. if (c === '/' && input[cursor + 1] === '/') {
  1825. state = 'authority ignore slashes';
  1826. } else {
  1827. err('Expected /, got: ' + c);
  1828. state = 'relative';
  1829. continue;
  1830. }
  1831. break;
  1832. case 'relative':
  1833. this._isRelative = true;
  1834. if ('file' !== this._scheme) {
  1835. this._scheme = base._scheme;
  1836. }
  1837. if (EOF === c) {
  1838. this._host = base._host;
  1839. this._port = base._port;
  1840. this._path = base._path.slice();
  1841. this._query = base._query;
  1842. this._username = base._username;
  1843. this._password = base._password;
  1844. break loop;
  1845. } else if (c === '/' || c === '\\') {
  1846. if (c === '\\') {
  1847. err('\\ is an invalid code point.');
  1848. }
  1849. state = 'relative slash';
  1850. } else if (c === '?') {
  1851. this._host = base._host;
  1852. this._port = base._port;
  1853. this._path = base._path.slice();
  1854. this._query = '?';
  1855. this._username = base._username;
  1856. this._password = base._password;
  1857. state = 'query';
  1858. } else if (c === '#') {
  1859. this._host = base._host;
  1860. this._port = base._port;
  1861. this._path = base._path.slice();
  1862. this._query = base._query;
  1863. this._fragment = '#';
  1864. this._username = base._username;
  1865. this._password = base._password;
  1866. state = 'fragment';
  1867. } else {
  1868. var nextC = input[cursor + 1];
  1869. var nextNextC = input[cursor + 2];
  1870. if ('file' !== this._scheme || !ALPHA.test(c) || nextC !== ':' && nextC !== '|' || EOF !== nextNextC && '/' !== nextNextC && '\\' !== nextNextC && '?' !== nextNextC && '#' !== nextNextC) {
  1871. this._host = base._host;
  1872. this._port = base._port;
  1873. this._username = base._username;
  1874. this._password = base._password;
  1875. this._path = base._path.slice();
  1876. this._path.pop();
  1877. }
  1878. state = 'relative path';
  1879. continue;
  1880. }
  1881. break;
  1882. case 'relative slash':
  1883. if (c === '/' || c === '\\') {
  1884. if (c === '\\') {
  1885. err('\\ is an invalid code point.');
  1886. }
  1887. if (this._scheme === 'file') {
  1888. state = 'file host';
  1889. } else {
  1890. state = 'authority ignore slashes';
  1891. }
  1892. } else {
  1893. if ('file' !== this._scheme) {
  1894. this._host = base._host;
  1895. this._port = base._port;
  1896. this._username = base._username;
  1897. this._password = base._password;
  1898. }
  1899. state = 'relative path';
  1900. continue;
  1901. }
  1902. break;
  1903. case 'authority first slash':
  1904. if (c === '/') {
  1905. state = 'authority second slash';
  1906. } else {
  1907. err('Expected \'/\', got: ' + c);
  1908. state = 'authority ignore slashes';
  1909. continue;
  1910. }
  1911. break;
  1912. case 'authority second slash':
  1913. state = 'authority ignore slashes';
  1914. if ('/' !== c) {
  1915. err('Expected \'/\', got: ' + c);
  1916. continue;
  1917. }
  1918. break;
  1919. case 'authority ignore slashes':
  1920. if ('/' !== c && '\\' !== c) {
  1921. state = 'authority';
  1922. continue;
  1923. } else {
  1924. err('Expected authority, got: ' + c);
  1925. }
  1926. break;
  1927. case 'authority':
  1928. if (c === '@') {
  1929. if (seenAt) {
  1930. err('@ already seen.');
  1931. buffer += '%40';
  1932. }
  1933. seenAt = true;
  1934. for (var i = 0; i < buffer.length; i++) {
  1935. var cp = buffer[i];
  1936. if (cp === '\t' || cp === '\n' || cp === '\r') {
  1937. err('Invalid whitespace in authority.');
  1938. continue;
  1939. }
  1940. if (cp === ':' && this._password === null) {
  1941. this._password = '';
  1942. continue;
  1943. }
  1944. var tempC = percentEscape(cp);
  1945. if (null !== this._password) {
  1946. this._password += tempC;
  1947. } else {
  1948. this._username += tempC;
  1949. }
  1950. }
  1951. buffer = '';
  1952. } else if (c === EOF || c === '/' || c === '\\' || c === '?' || c === '#') {
  1953. cursor -= buffer.length;
  1954. buffer = '';
  1955. state = 'host';
  1956. continue;
  1957. } else {
  1958. buffer += c;
  1959. }
  1960. break;
  1961. case 'file host':
  1962. if (c === EOF || c === '/' || c === '\\' || c === '?' || c === '#') {
  1963. if (buffer.length === 2 && ALPHA.test(buffer[0]) && (buffer[1] === ':' || buffer[1] === '|')) {
  1964. state = 'relative path';
  1965. } else if (buffer.length === 0) {
  1966. state = 'relative path start';
  1967. } else {
  1968. this._host = IDNAToASCII.call(this, buffer);
  1969. buffer = '';
  1970. state = 'relative path start';
  1971. }
  1972. continue;
  1973. } else if (c === '\t' || c === '\n' || c === '\r') {
  1974. err('Invalid whitespace in file host.');
  1975. } else {
  1976. buffer += c;
  1977. }
  1978. break;
  1979. case 'host':
  1980. case 'hostname':
  1981. if (c === ':' && !seenBracket) {
  1982. this._host = IDNAToASCII.call(this, buffer);
  1983. buffer = '';
  1984. state = 'port';
  1985. if (stateOverride === 'hostname') {
  1986. break loop;
  1987. }
  1988. } else if (c === EOF || c === '/' || c === '\\' || c === '?' || c === '#') {
  1989. this._host = IDNAToASCII.call(this, buffer);
  1990. buffer = '';
  1991. state = 'relative path start';
  1992. if (stateOverride) {
  1993. break loop;
  1994. }
  1995. continue;
  1996. } else if ('\t' !== c && '\n' !== c && '\r' !== c) {
  1997. if (c === '[') {
  1998. seenBracket = true;
  1999. } else if (c === ']') {
  2000. seenBracket = false;
  2001. }
  2002. buffer += c;
  2003. } else {
  2004. err('Invalid code point in host/hostname: ' + c);
  2005. }
  2006. break;
  2007. case 'port':
  2008. if (/[0-9]/.test(c)) {
  2009. buffer += c;
  2010. } else if (c === EOF || c === '/' || c === '\\' || c === '?' || c === '#' || stateOverride) {
  2011. if ('' !== buffer) {
  2012. var temp = parseInt(buffer, 10);
  2013. if (temp !== relative[this._scheme]) {
  2014. this._port = temp + '';
  2015. }
  2016. buffer = '';
  2017. }
  2018. if (stateOverride) {
  2019. break loop;
  2020. }
  2021. state = 'relative path start';
  2022. continue;
  2023. } else if (c === '\t' || c === '\n' || c === '\r') {
  2024. err('Invalid code point in port: ' + c);
  2025. } else {
  2026. invalid.call(this);
  2027. }
  2028. break;
  2029. case 'relative path start':
  2030. if (c === '\\') {
  2031. err('\'\\\' not allowed in path.');
  2032. }
  2033. state = 'relative path';
  2034. if ('/' !== c && '\\' !== c) {
  2035. continue;
  2036. }
  2037. break;
  2038. case 'relative path':
  2039. if (c === EOF || c === '/' || c === '\\' || !stateOverride && (c === '?' || c === '#')) {
  2040. if (c === '\\') {
  2041. err('\\ not allowed in relative path.');
  2042. }
  2043. var tmp;
  2044. if (tmp = relativePathDotMapping[buffer.toLowerCase()]) {
  2045. buffer = tmp;
  2046. }
  2047. if (buffer === '..') {
  2048. this._path.pop();
  2049. if ('/' !== c && '\\' !== c) {
  2050. this._path.push('');
  2051. }
  2052. } else if (buffer === '.' && '/' !== c && '\\' !== c) {
  2053. this._path.push('');
  2054. } else if ('.' !== buffer) {
  2055. if (this._scheme === 'file' && this._path.length === 0 && buffer.length === 2 && ALPHA.test(buffer[0]) && buffer[1] === '|') {
  2056. buffer = buffer[0] + ':';
  2057. }
  2058. this._path.push(buffer);
  2059. }
  2060. buffer = '';
  2061. if (c === '?') {
  2062. this._query = '?';
  2063. state = 'query';
  2064. } else if (c === '#') {
  2065. this._fragment = '#';
  2066. state = 'fragment';
  2067. }
  2068. } else if ('\t' !== c && '\n' !== c && '\r' !== c) {
  2069. buffer += percentEscape(c);
  2070. }
  2071. break;
  2072. case 'query':
  2073. if (!stateOverride && c === '#') {
  2074. this._fragment = '#';
  2075. state = 'fragment';
  2076. } else if (EOF !== c && '\t' !== c && '\n' !== c && '\r' !== c) {
  2077. this._query += percentEscapeQuery(c);
  2078. }
  2079. break;
  2080. case 'fragment':
  2081. if (EOF !== c && '\t' !== c && '\n' !== c && '\r' !== c) {
  2082. this._fragment += c;
  2083. }
  2084. break;
  2085. }
  2086. cursor++;
  2087. }
  2088. }
  2089. function clear() {
  2090. this._scheme = '';
  2091. this._schemeData = '';
  2092. this._username = '';
  2093. this._password = null;
  2094. this._host = '';
  2095. this._port = '';
  2096. this._path = [];
  2097. this._query = '';
  2098. this._fragment = '';
  2099. this._isInvalid = false;
  2100. this._isRelative = false;
  2101. }
  2102. function JURL(url, base) {
  2103. if (base !== undefined && !(base instanceof JURL)) {
  2104. base = new JURL(String(base));
  2105. }
  2106. this._url = url;
  2107. clear.call(this);
  2108. var input = url.replace(/^[ \t\r\n\f]+|[ \t\r\n\f]+$/g, '');
  2109. parse.call(this, input, null, base);
  2110. }
  2111. JURL.prototype = {
  2112. toString: function () {
  2113. return this.href;
  2114. },
  2115. get href() {
  2116. if (this._isInvalid) {
  2117. return this._url;
  2118. }
  2119. var authority = '';
  2120. if ('' !== this._username || null !== this._password) {
  2121. authority = this._username + (null !== this._password ? ':' + this._password : '') + '@';
  2122. }
  2123. return this.protocol + (this._isRelative ? '//' + authority + this.host : '') + this.pathname + this._query + this._fragment;
  2124. },
  2125. set href(href) {
  2126. clear.call(this);
  2127. parse.call(this, href);
  2128. },
  2129. get protocol() {
  2130. return this._scheme + ':';
  2131. },
  2132. set protocol(protocol) {
  2133. if (this._isInvalid) {
  2134. return;
  2135. }
  2136. parse.call(this, protocol + ':', 'scheme start');
  2137. },
  2138. get host() {
  2139. return this._isInvalid ? '' : this._port ? this._host + ':' + this._port : this._host;
  2140. },
  2141. set host(host) {
  2142. if (this._isInvalid || !this._isRelative) {
  2143. return;
  2144. }
  2145. parse.call(this, host, 'host');
  2146. },
  2147. get hostname() {
  2148. return this._host;
  2149. },
  2150. set hostname(hostname) {
  2151. if (this._isInvalid || !this._isRelative) {
  2152. return;
  2153. }
  2154. parse.call(this, hostname, 'hostname');
  2155. },
  2156. get port() {
  2157. return this._port;
  2158. },
  2159. set port(port) {
  2160. if (this._isInvalid || !this._isRelative) {
  2161. return;
  2162. }
  2163. parse.call(this, port, 'port');
  2164. },
  2165. get pathname() {
  2166. return this._isInvalid ? '' : this._isRelative ? '/' + this._path.join('/') : this._schemeData;
  2167. },
  2168. set pathname(pathname) {
  2169. if (this._isInvalid || !this._isRelative) {
  2170. return;
  2171. }
  2172. this._path = [];
  2173. parse.call(this, pathname, 'relative path start');
  2174. },
  2175. get search() {
  2176. return this._isInvalid || !this._query || this._query === '?' ? '' : this._query;
  2177. },
  2178. set search(search) {
  2179. if (this._isInvalid || !this._isRelative) {
  2180. return;
  2181. }
  2182. this._query = '?';
  2183. if (search[0] === '?') {
  2184. search = search.slice(1);
  2185. }
  2186. parse.call(this, search, 'query');
  2187. },
  2188. get hash() {
  2189. return this._isInvalid || !this._fragment || this._fragment === '#' ? '' : this._fragment;
  2190. },
  2191. set hash(hash) {
  2192. if (this._isInvalid) {
  2193. return;
  2194. }
  2195. this._fragment = '#';
  2196. if (hash[0] === '#') {
  2197. hash = hash.slice(1);
  2198. }
  2199. parse.call(this, hash, 'fragment');
  2200. },
  2201. get origin() {
  2202. var host;
  2203. if (this._isInvalid || !this._scheme) {
  2204. return '';
  2205. }
  2206. switch (this._scheme) {
  2207. case 'data':
  2208. case 'file':
  2209. case 'javascript':
  2210. case 'mailto':
  2211. return 'null';
  2212. }
  2213. host = this.host;
  2214. if (!host) {
  2215. return '';
  2216. }
  2217. return this._scheme + '://' + host;
  2218. }
  2219. };
  2220. var OriginalURL = scope.URL;
  2221. if (OriginalURL) {
  2222. JURL.createObjectURL = function (blob) {
  2223. return OriginalURL.createObjectURL.apply(OriginalURL, arguments);
  2224. };
  2225. JURL.revokeObjectURL = function (url) {
  2226. OriginalURL.revokeObjectURL(url);
  2227. };
  2228. }
  2229. scope.URL = JURL;
  2230. }(globalScope));
  2231. exports.FONT_IDENTITY_MATRIX = FONT_IDENTITY_MATRIX;
  2232. exports.IDENTITY_MATRIX = IDENTITY_MATRIX;
  2233. exports.OPS = OPS;
  2234. exports.VERBOSITY_LEVELS = VERBOSITY_LEVELS;
  2235. exports.UNSUPPORTED_FEATURES = UNSUPPORTED_FEATURES;
  2236. exports.AnnotationBorderStyleType = AnnotationBorderStyleType;
  2237. exports.AnnotationFieldFlag = AnnotationFieldFlag;
  2238. exports.AnnotationFlag = AnnotationFlag;
  2239. exports.AnnotationType = AnnotationType;
  2240. exports.FontType = FontType;
  2241. exports.ImageKind = ImageKind;
  2242. exports.InvalidPDFException = InvalidPDFException;
  2243. exports.MessageHandler = MessageHandler;
  2244. exports.MissingDataException = MissingDataException;
  2245. exports.MissingPDFException = MissingPDFException;
  2246. exports.NotImplementedException = NotImplementedException;
  2247. exports.PageViewport = PageViewport;
  2248. exports.PasswordException = PasswordException;
  2249. exports.PasswordResponses = PasswordResponses;
  2250. exports.StatTimer = StatTimer;
  2251. exports.StreamType = StreamType;
  2252. exports.TextRenderingMode = TextRenderingMode;
  2253. exports.UnexpectedResponseException = UnexpectedResponseException;
  2254. exports.UnknownErrorException = UnknownErrorException;
  2255. exports.Util = Util;
  2256. exports.XRefParseException = XRefParseException;
  2257. exports.arrayByteLength = arrayByteLength;
  2258. exports.arraysToBytes = arraysToBytes;
  2259. exports.assert = assert;
  2260. exports.bytesToString = bytesToString;
  2261. exports.createBlob = createBlob;
  2262. exports.createPromiseCapability = createPromiseCapability;
  2263. exports.createObjectURL = createObjectURL;
  2264. exports.deprecated = deprecated;
  2265. exports.error = error;
  2266. exports.getLookupTableFactory = getLookupTableFactory;
  2267. exports.getVerbosityLevel = getVerbosityLevel;
  2268. exports.globalScope = globalScope;
  2269. exports.info = info;
  2270. exports.isArray = isArray;
  2271. exports.isArrayBuffer = isArrayBuffer;
  2272. exports.isBool = isBool;
  2273. exports.isEmptyObj = isEmptyObj;
  2274. exports.isInt = isInt;
  2275. exports.isNum = isNum;
  2276. exports.isString = isString;
  2277. exports.isSpace = isSpace;
  2278. exports.isSameOrigin = isSameOrigin;
  2279. exports.createValidAbsoluteUrl = createValidAbsoluteUrl;
  2280. exports.isLittleEndian = isLittleEndian;
  2281. exports.isEvalSupported = isEvalSupported;
  2282. exports.loadJpegStream = loadJpegStream;
  2283. exports.log2 = log2;
  2284. exports.readInt8 = readInt8;
  2285. exports.readUint16 = readUint16;
  2286. exports.readUint32 = readUint32;
  2287. exports.removeNullCharacters = removeNullCharacters;
  2288. exports.setVerbosityLevel = setVerbosityLevel;
  2289. exports.shadow = shadow;
  2290. exports.string32 = string32;
  2291. exports.stringToBytes = stringToBytes;
  2292. exports.stringToPDFString = stringToPDFString;
  2293. exports.stringToUTF8String = stringToUTF8String;
  2294. exports.utf8StringToString = utf8StringToString;
  2295. exports.warn = warn;
  2296. /* WEBPACK VAR INJECTION */}.call(exports, __w_pdfjs_require__(27)))
  2297. /***/ }),
  2298. /* 1 */
  2299. /***/ (function(module, exports, __w_pdfjs_require__) {
  2300. "use strict";
  2301. var sharedUtil = __w_pdfjs_require__(0);
  2302. var isArray = sharedUtil.isArray;
  2303. var EOF = {};
  2304. var Name = function NameClosure() {
  2305. function Name(name) {
  2306. this.name = name;
  2307. }
  2308. Name.prototype = {};
  2309. var nameCache = Object.create(null);
  2310. Name.get = function Name_get(name) {
  2311. var nameValue = nameCache[name];
  2312. return nameValue ? nameValue : nameCache[name] = new Name(name);
  2313. };
  2314. return Name;
  2315. }();
  2316. var Cmd = function CmdClosure() {
  2317. function Cmd(cmd) {
  2318. this.cmd = cmd;
  2319. }
  2320. Cmd.prototype = {};
  2321. var cmdCache = Object.create(null);
  2322. Cmd.get = function Cmd_get(cmd) {
  2323. var cmdValue = cmdCache[cmd];
  2324. return cmdValue ? cmdValue : cmdCache[cmd] = new Cmd(cmd);
  2325. };
  2326. return Cmd;
  2327. }();
  2328. var Dict = function DictClosure() {
  2329. var nonSerializable = function nonSerializableClosure() {
  2330. return nonSerializable;
  2331. };
  2332. function Dict(xref) {
  2333. this.map = Object.create(null);
  2334. this.xref = xref;
  2335. this.objId = null;
  2336. this.suppressEncryption = false;
  2337. this.__nonSerializable__ = nonSerializable;
  2338. }
  2339. Dict.prototype = {
  2340. assignXref: function Dict_assignXref(newXref) {
  2341. this.xref = newXref;
  2342. },
  2343. get: function Dict_get(key1, key2, key3) {
  2344. var value;
  2345. var xref = this.xref, suppressEncryption = this.suppressEncryption;
  2346. if (typeof (value = this.map[key1]) !== 'undefined' || key1 in this.map || typeof key2 === 'undefined') {
  2347. return xref ? xref.fetchIfRef(value, suppressEncryption) : value;
  2348. }
  2349. if (typeof (value = this.map[key2]) !== 'undefined' || key2 in this.map || typeof key3 === 'undefined') {
  2350. return xref ? xref.fetchIfRef(value, suppressEncryption) : value;
  2351. }
  2352. value = this.map[key3] || null;
  2353. return xref ? xref.fetchIfRef(value, suppressEncryption) : value;
  2354. },
  2355. getAsync: function Dict_getAsync(key1, key2, key3) {
  2356. var value;
  2357. var xref = this.xref, suppressEncryption = this.suppressEncryption;
  2358. if (typeof (value = this.map[key1]) !== 'undefined' || key1 in this.map || typeof key2 === 'undefined') {
  2359. if (xref) {
  2360. return xref.fetchIfRefAsync(value, suppressEncryption);
  2361. }
  2362. return Promise.resolve(value);
  2363. }
  2364. if (typeof (value = this.map[key2]) !== 'undefined' || key2 in this.map || typeof key3 === 'undefined') {
  2365. if (xref) {
  2366. return xref.fetchIfRefAsync(value, suppressEncryption);
  2367. }
  2368. return Promise.resolve(value);
  2369. }
  2370. value = this.map[key3] || null;
  2371. if (xref) {
  2372. return xref.fetchIfRefAsync(value, suppressEncryption);
  2373. }
  2374. return Promise.resolve(value);
  2375. },
  2376. getArray: function Dict_getArray(key1, key2, key3) {
  2377. var value = this.get(key1, key2, key3);
  2378. var xref = this.xref, suppressEncryption = this.suppressEncryption;
  2379. if (!isArray(value) || !xref) {
  2380. return value;
  2381. }
  2382. value = value.slice();
  2383. for (var i = 0, ii = value.length; i < ii; i++) {
  2384. if (!isRef(value[i])) {
  2385. continue;
  2386. }
  2387. value[i] = xref.fetch(value[i], suppressEncryption);
  2388. }
  2389. return value;
  2390. },
  2391. getRaw: function Dict_getRaw(key) {
  2392. return this.map[key];
  2393. },
  2394. getKeys: function Dict_getKeys() {
  2395. return Object.keys(this.map);
  2396. },
  2397. set: function Dict_set(key, value) {
  2398. this.map[key] = value;
  2399. },
  2400. has: function Dict_has(key) {
  2401. return key in this.map;
  2402. },
  2403. forEach: function Dict_forEach(callback) {
  2404. for (var key in this.map) {
  2405. callback(key, this.get(key));
  2406. }
  2407. }
  2408. };
  2409. Dict.empty = new Dict(null);
  2410. Dict.merge = function Dict_merge(xref, dictArray) {
  2411. var mergedDict = new Dict(xref);
  2412. for (var i = 0, ii = dictArray.length; i < ii; i++) {
  2413. var dict = dictArray[i];
  2414. if (!isDict(dict)) {
  2415. continue;
  2416. }
  2417. for (var keyName in dict.map) {
  2418. if (mergedDict.map[keyName]) {
  2419. continue;
  2420. }
  2421. mergedDict.map[keyName] = dict.map[keyName];
  2422. }
  2423. }
  2424. return mergedDict;
  2425. };
  2426. return Dict;
  2427. }();
  2428. var Ref = function RefClosure() {
  2429. function Ref(num, gen) {
  2430. this.num = num;
  2431. this.gen = gen;
  2432. }
  2433. Ref.prototype = {
  2434. toString: function Ref_toString() {
  2435. var str = this.num + 'R';
  2436. if (this.gen !== 0) {
  2437. str += this.gen;
  2438. }
  2439. return str;
  2440. }
  2441. };
  2442. return Ref;
  2443. }();
  2444. var RefSet = function RefSetClosure() {
  2445. function RefSet() {
  2446. this.dict = Object.create(null);
  2447. }
  2448. RefSet.prototype = {
  2449. has: function RefSet_has(ref) {
  2450. return ref.toString() in this.dict;
  2451. },
  2452. put: function RefSet_put(ref) {
  2453. this.dict[ref.toString()] = true;
  2454. },
  2455. remove: function RefSet_remove(ref) {
  2456. delete this.dict[ref.toString()];
  2457. }
  2458. };
  2459. return RefSet;
  2460. }();
  2461. var RefSetCache = function RefSetCacheClosure() {
  2462. function RefSetCache() {
  2463. this.dict = Object.create(null);
  2464. }
  2465. RefSetCache.prototype = {
  2466. get: function RefSetCache_get(ref) {
  2467. return this.dict[ref.toString()];
  2468. },
  2469. has: function RefSetCache_has(ref) {
  2470. return ref.toString() in this.dict;
  2471. },
  2472. put: function RefSetCache_put(ref, obj) {
  2473. this.dict[ref.toString()] = obj;
  2474. },
  2475. putAlias: function RefSetCache_putAlias(ref, aliasRef) {
  2476. this.dict[ref.toString()] = this.get(aliasRef);
  2477. },
  2478. forEach: function RefSetCache_forEach(fn, thisArg) {
  2479. for (var i in this.dict) {
  2480. fn.call(thisArg, this.dict[i]);
  2481. }
  2482. },
  2483. clear: function RefSetCache_clear() {
  2484. this.dict = Object.create(null);
  2485. }
  2486. };
  2487. return RefSetCache;
  2488. }();
  2489. function isEOF(v) {
  2490. return v === EOF;
  2491. }
  2492. function isName(v, name) {
  2493. return v instanceof Name && (name === undefined || v.name === name);
  2494. }
  2495. function isCmd(v, cmd) {
  2496. return v instanceof Cmd && (cmd === undefined || v.cmd === cmd);
  2497. }
  2498. function isDict(v, type) {
  2499. return v instanceof Dict && (type === undefined || isName(v.get('Type'), type));
  2500. }
  2501. function isRef(v) {
  2502. return v instanceof Ref;
  2503. }
  2504. function isRefsEqual(v1, v2) {
  2505. return v1.num === v2.num && v1.gen === v2.gen;
  2506. }
  2507. function isStream(v) {
  2508. return typeof v === 'object' && v !== null && v.getBytes !== undefined;
  2509. }
  2510. exports.EOF = EOF;
  2511. exports.Cmd = Cmd;
  2512. exports.Dict = Dict;
  2513. exports.Name = Name;
  2514. exports.Ref = Ref;
  2515. exports.RefSet = RefSet;
  2516. exports.RefSetCache = RefSetCache;
  2517. exports.isEOF = isEOF;
  2518. exports.isCmd = isCmd;
  2519. exports.isDict = isDict;
  2520. exports.isName = isName;
  2521. exports.isRef = isRef;
  2522. exports.isRefsEqual = isRefsEqual;
  2523. exports.isStream = isStream;
  2524. /***/ }),
  2525. /* 2 */
  2526. /***/ (function(module, exports, __w_pdfjs_require__) {
  2527. "use strict";
  2528. var sharedUtil = __w_pdfjs_require__(0);
  2529. var corePrimitives = __w_pdfjs_require__(1);
  2530. var coreJbig2 = __w_pdfjs_require__(37);
  2531. var coreJpg = __w_pdfjs_require__(38);
  2532. var coreJpx = __w_pdfjs_require__(19);
  2533. var Util = sharedUtil.Util;
  2534. var error = sharedUtil.error;
  2535. var info = sharedUtil.info;
  2536. var isInt = sharedUtil.isInt;
  2537. var isArray = sharedUtil.isArray;
  2538. var createObjectURL = sharedUtil.createObjectURL;
  2539. var shadow = sharedUtil.shadow;
  2540. var isSpace = sharedUtil.isSpace;
  2541. var Dict = corePrimitives.Dict;
  2542. var isDict = corePrimitives.isDict;
  2543. var isStream = corePrimitives.isStream;
  2544. var Jbig2Image = coreJbig2.Jbig2Image;
  2545. var JpegImage = coreJpg.JpegImage;
  2546. var JpxImage = coreJpx.JpxImage;
  2547. var Stream = function StreamClosure() {
  2548. function Stream(arrayBuffer, start, length, dict) {
  2549. this.bytes = arrayBuffer instanceof Uint8Array ? arrayBuffer : new Uint8Array(arrayBuffer);
  2550. this.start = start || 0;
  2551. this.pos = this.start;
  2552. this.end = start + length || this.bytes.length;
  2553. this.dict = dict;
  2554. }
  2555. Stream.prototype = {
  2556. get length() {
  2557. return this.end - this.start;
  2558. },
  2559. get isEmpty() {
  2560. return this.length === 0;
  2561. },
  2562. getByte: function Stream_getByte() {
  2563. if (this.pos >= this.end) {
  2564. return -1;
  2565. }
  2566. return this.bytes[this.pos++];
  2567. },
  2568. getUint16: function Stream_getUint16() {
  2569. var b0 = this.getByte();
  2570. var b1 = this.getByte();
  2571. if (b0 === -1 || b1 === -1) {
  2572. return -1;
  2573. }
  2574. return (b0 << 8) + b1;
  2575. },
  2576. getInt32: function Stream_getInt32() {
  2577. var b0 = this.getByte();
  2578. var b1 = this.getByte();
  2579. var b2 = this.getByte();
  2580. var b3 = this.getByte();
  2581. return (b0 << 24) + (b1 << 16) + (b2 << 8) + b3;
  2582. },
  2583. getBytes: function Stream_getBytes(length) {
  2584. var bytes = this.bytes;
  2585. var pos = this.pos;
  2586. var strEnd = this.end;
  2587. if (!length) {
  2588. return bytes.subarray(pos, strEnd);
  2589. }
  2590. var end = pos + length;
  2591. if (end > strEnd) {
  2592. end = strEnd;
  2593. }
  2594. this.pos = end;
  2595. return bytes.subarray(pos, end);
  2596. },
  2597. peekByte: function Stream_peekByte() {
  2598. var peekedByte = this.getByte();
  2599. this.pos--;
  2600. return peekedByte;
  2601. },
  2602. peekBytes: function Stream_peekBytes(length) {
  2603. var bytes = this.getBytes(length);
  2604. this.pos -= bytes.length;
  2605. return bytes;
  2606. },
  2607. skip: function Stream_skip(n) {
  2608. if (!n) {
  2609. n = 1;
  2610. }
  2611. this.pos += n;
  2612. },
  2613. reset: function Stream_reset() {
  2614. this.pos = this.start;
  2615. },
  2616. moveStart: function Stream_moveStart() {
  2617. this.start = this.pos;
  2618. },
  2619. makeSubStream: function Stream_makeSubStream(start, length, dict) {
  2620. return new Stream(this.bytes.buffer, start, length, dict);
  2621. }
  2622. };
  2623. return Stream;
  2624. }();
  2625. var StringStream = function StringStreamClosure() {
  2626. function StringStream(str) {
  2627. var length = str.length;
  2628. var bytes = new Uint8Array(length);
  2629. for (var n = 0; n < length; ++n) {
  2630. bytes[n] = str.charCodeAt(n);
  2631. }
  2632. Stream.call(this, bytes);
  2633. }
  2634. StringStream.prototype = Stream.prototype;
  2635. return StringStream;
  2636. }();
  2637. var DecodeStream = function DecodeStreamClosure() {
  2638. var emptyBuffer = new Uint8Array(0);
  2639. function DecodeStream(maybeMinBufferLength) {
  2640. this.pos = 0;
  2641. this.bufferLength = 0;
  2642. this.eof = false;
  2643. this.buffer = emptyBuffer;
  2644. this.minBufferLength = 512;
  2645. if (maybeMinBufferLength) {
  2646. while (this.minBufferLength < maybeMinBufferLength) {
  2647. this.minBufferLength *= 2;
  2648. }
  2649. }
  2650. }
  2651. DecodeStream.prototype = {
  2652. get isEmpty() {
  2653. while (!this.eof && this.bufferLength === 0) {
  2654. this.readBlock();
  2655. }
  2656. return this.bufferLength === 0;
  2657. },
  2658. ensureBuffer: function DecodeStream_ensureBuffer(requested) {
  2659. var buffer = this.buffer;
  2660. if (requested <= buffer.byteLength) {
  2661. return buffer;
  2662. }
  2663. var size = this.minBufferLength;
  2664. while (size < requested) {
  2665. size *= 2;
  2666. }
  2667. var buffer2 = new Uint8Array(size);
  2668. buffer2.set(buffer);
  2669. return this.buffer = buffer2;
  2670. },
  2671. getByte: function DecodeStream_getByte() {
  2672. var pos = this.pos;
  2673. while (this.bufferLength <= pos) {
  2674. if (this.eof) {
  2675. return -1;
  2676. }
  2677. this.readBlock();
  2678. }
  2679. return this.buffer[this.pos++];
  2680. },
  2681. getUint16: function DecodeStream_getUint16() {
  2682. var b0 = this.getByte();
  2683. var b1 = this.getByte();
  2684. if (b0 === -1 || b1 === -1) {
  2685. return -1;
  2686. }
  2687. return (b0 << 8) + b1;
  2688. },
  2689. getInt32: function DecodeStream_getInt32() {
  2690. var b0 = this.getByte();
  2691. var b1 = this.getByte();
  2692. var b2 = this.getByte();
  2693. var b3 = this.getByte();
  2694. return (b0 << 24) + (b1 << 16) + (b2 << 8) + b3;
  2695. },
  2696. getBytes: function DecodeStream_getBytes(length) {
  2697. var end, pos = this.pos;
  2698. if (length) {
  2699. this.ensureBuffer(pos + length);
  2700. end = pos + length;
  2701. while (!this.eof && this.bufferLength < end) {
  2702. this.readBlock();
  2703. }
  2704. var bufEnd = this.bufferLength;
  2705. if (end > bufEnd) {
  2706. end = bufEnd;
  2707. }
  2708. } else {
  2709. while (!this.eof) {
  2710. this.readBlock();
  2711. }
  2712. end = this.bufferLength;
  2713. }
  2714. this.pos = end;
  2715. return this.buffer.subarray(pos, end);
  2716. },
  2717. peekByte: function DecodeStream_peekByte() {
  2718. var peekedByte = this.getByte();
  2719. this.pos--;
  2720. return peekedByte;
  2721. },
  2722. peekBytes: function DecodeStream_peekBytes(length) {
  2723. var bytes = this.getBytes(length);
  2724. this.pos -= bytes.length;
  2725. return bytes;
  2726. },
  2727. makeSubStream: function DecodeStream_makeSubStream(start, length, dict) {
  2728. var end = start + length;
  2729. while (this.bufferLength <= end && !this.eof) {
  2730. this.readBlock();
  2731. }
  2732. return new Stream(this.buffer, start, length, dict);
  2733. },
  2734. skip: function DecodeStream_skip(n) {
  2735. if (!n) {
  2736. n = 1;
  2737. }
  2738. this.pos += n;
  2739. },
  2740. reset: function DecodeStream_reset() {
  2741. this.pos = 0;
  2742. },
  2743. getBaseStreams: function DecodeStream_getBaseStreams() {
  2744. if (this.str && this.str.getBaseStreams) {
  2745. return this.str.getBaseStreams();
  2746. }
  2747. return [];
  2748. }
  2749. };
  2750. return DecodeStream;
  2751. }();
  2752. var StreamsSequenceStream = function StreamsSequenceStreamClosure() {
  2753. function StreamsSequenceStream(streams) {
  2754. this.streams = streams;
  2755. DecodeStream.call(this, null);
  2756. }
  2757. StreamsSequenceStream.prototype = Object.create(DecodeStream.prototype);
  2758. StreamsSequenceStream.prototype.readBlock = function streamSequenceStreamReadBlock() {
  2759. var streams = this.streams;
  2760. if (streams.length === 0) {
  2761. this.eof = true;
  2762. return;
  2763. }
  2764. var stream = streams.shift();
  2765. var chunk = stream.getBytes();
  2766. var bufferLength = this.bufferLength;
  2767. var newLength = bufferLength + chunk.length;
  2768. var buffer = this.ensureBuffer(newLength);
  2769. buffer.set(chunk, bufferLength);
  2770. this.bufferLength = newLength;
  2771. };
  2772. StreamsSequenceStream.prototype.getBaseStreams = function StreamsSequenceStream_getBaseStreams() {
  2773. var baseStreams = [];
  2774. for (var i = 0, ii = this.streams.length; i < ii; i++) {
  2775. var stream = this.streams[i];
  2776. if (stream.getBaseStreams) {
  2777. Util.appendToArray(baseStreams, stream.getBaseStreams());
  2778. }
  2779. }
  2780. return baseStreams;
  2781. };
  2782. return StreamsSequenceStream;
  2783. }();
  2784. var FlateStream = function FlateStreamClosure() {
  2785. var codeLenCodeMap = new Int32Array([
  2786. 16,
  2787. 17,
  2788. 18,
  2789. 0,
  2790. 8,
  2791. 7,
  2792. 9,
  2793. 6,
  2794. 10,
  2795. 5,
  2796. 11,
  2797. 4,
  2798. 12,
  2799. 3,
  2800. 13,
  2801. 2,
  2802. 14,
  2803. 1,
  2804. 15
  2805. ]);
  2806. var lengthDecode = new Int32Array([
  2807. 0x00003,
  2808. 0x00004,
  2809. 0x00005,
  2810. 0x00006,
  2811. 0x00007,
  2812. 0x00008,
  2813. 0x00009,
  2814. 0x0000a,
  2815. 0x1000b,
  2816. 0x1000d,
  2817. 0x1000f,
  2818. 0x10011,
  2819. 0x20013,
  2820. 0x20017,
  2821. 0x2001b,
  2822. 0x2001f,
  2823. 0x30023,
  2824. 0x3002b,
  2825. 0x30033,
  2826. 0x3003b,
  2827. 0x40043,
  2828. 0x40053,
  2829. 0x40063,
  2830. 0x40073,
  2831. 0x50083,
  2832. 0x500a3,
  2833. 0x500c3,
  2834. 0x500e3,
  2835. 0x00102,
  2836. 0x00102,
  2837. 0x00102
  2838. ]);
  2839. var distDecode = new Int32Array([
  2840. 0x00001,
  2841. 0x00002,
  2842. 0x00003,
  2843. 0x00004,
  2844. 0x10005,
  2845. 0x10007,
  2846. 0x20009,
  2847. 0x2000d,
  2848. 0x30011,
  2849. 0x30019,
  2850. 0x40021,
  2851. 0x40031,
  2852. 0x50041,
  2853. 0x50061,
  2854. 0x60081,
  2855. 0x600c1,
  2856. 0x70101,
  2857. 0x70181,
  2858. 0x80201,
  2859. 0x80301,
  2860. 0x90401,
  2861. 0x90601,
  2862. 0xa0801,
  2863. 0xa0c01,
  2864. 0xb1001,
  2865. 0xb1801,
  2866. 0xc2001,
  2867. 0xc3001,
  2868. 0xd4001,
  2869. 0xd6001
  2870. ]);
  2871. var fixedLitCodeTab = [
  2872. new Int32Array([
  2873. 0x70100,
  2874. 0x80050,
  2875. 0x80010,
  2876. 0x80118,
  2877. 0x70110,
  2878. 0x80070,
  2879. 0x80030,
  2880. 0x900c0,
  2881. 0x70108,
  2882. 0x80060,
  2883. 0x80020,
  2884. 0x900a0,
  2885. 0x80000,
  2886. 0x80080,
  2887. 0x80040,
  2888. 0x900e0,
  2889. 0x70104,
  2890. 0x80058,
  2891. 0x80018,
  2892. 0x90090,
  2893. 0x70114,
  2894. 0x80078,
  2895. 0x80038,
  2896. 0x900d0,
  2897. 0x7010c,
  2898. 0x80068,
  2899. 0x80028,
  2900. 0x900b0,
  2901. 0x80008,
  2902. 0x80088,
  2903. 0x80048,
  2904. 0x900f0,
  2905. 0x70102,
  2906. 0x80054,
  2907. 0x80014,
  2908. 0x8011c,
  2909. 0x70112,
  2910. 0x80074,
  2911. 0x80034,
  2912. 0x900c8,
  2913. 0x7010a,
  2914. 0x80064,
  2915. 0x80024,
  2916. 0x900a8,
  2917. 0x80004,
  2918. 0x80084,
  2919. 0x80044,
  2920. 0x900e8,
  2921. 0x70106,
  2922. 0x8005c,
  2923. 0x8001c,
  2924. 0x90098,
  2925. 0x70116,
  2926. 0x8007c,
  2927. 0x8003c,
  2928. 0x900d8,
  2929. 0x7010e,
  2930. 0x8006c,
  2931. 0x8002c,
  2932. 0x900b8,
  2933. 0x8000c,
  2934. 0x8008c,
  2935. 0x8004c,
  2936. 0x900f8,
  2937. 0x70101,
  2938. 0x80052,
  2939. 0x80012,
  2940. 0x8011a,
  2941. 0x70111,
  2942. 0x80072,
  2943. 0x80032,
  2944. 0x900c4,
  2945. 0x70109,
  2946. 0x80062,
  2947. 0x80022,
  2948. 0x900a4,
  2949. 0x80002,
  2950. 0x80082,
  2951. 0x80042,
  2952. 0x900e4,
  2953. 0x70105,
  2954. 0x8005a,
  2955. 0x8001a,
  2956. 0x90094,
  2957. 0x70115,
  2958. 0x8007a,
  2959. 0x8003a,
  2960. 0x900d4,
  2961. 0x7010d,
  2962. 0x8006a,
  2963. 0x8002a,
  2964. 0x900b4,
  2965. 0x8000a,
  2966. 0x8008a,
  2967. 0x8004a,
  2968. 0x900f4,
  2969. 0x70103,
  2970. 0x80056,
  2971. 0x80016,
  2972. 0x8011e,
  2973. 0x70113,
  2974. 0x80076,
  2975. 0x80036,
  2976. 0x900cc,
  2977. 0x7010b,
  2978. 0x80066,
  2979. 0x80026,
  2980. 0x900ac,
  2981. 0x80006,
  2982. 0x80086,
  2983. 0x80046,
  2984. 0x900ec,
  2985. 0x70107,
  2986. 0x8005e,
  2987. 0x8001e,
  2988. 0x9009c,
  2989. 0x70117,
  2990. 0x8007e,
  2991. 0x8003e,
  2992. 0x900dc,
  2993. 0x7010f,
  2994. 0x8006e,
  2995. 0x8002e,
  2996. 0x900bc,
  2997. 0x8000e,
  2998. 0x8008e,
  2999. 0x8004e,
  3000. 0x900fc,
  3001. 0x70100,
  3002. 0x80051,
  3003. 0x80011,
  3004. 0x80119,
  3005. 0x70110,
  3006. 0x80071,
  3007. 0x80031,
  3008. 0x900c2,
  3009. 0x70108,
  3010. 0x80061,
  3011. 0x80021,
  3012. 0x900a2,
  3013. 0x80001,
  3014. 0x80081,
  3015. 0x80041,
  3016. 0x900e2,
  3017. 0x70104,
  3018. 0x80059,
  3019. 0x80019,
  3020. 0x90092,
  3021. 0x70114,
  3022. 0x80079,
  3023. 0x80039,
  3024. 0x900d2,
  3025. 0x7010c,
  3026. 0x80069,
  3027. 0x80029,
  3028. 0x900b2,
  3029. 0x80009,
  3030. 0x80089,
  3031. 0x80049,
  3032. 0x900f2,
  3033. 0x70102,
  3034. 0x80055,
  3035. 0x80015,
  3036. 0x8011d,
  3037. 0x70112,
  3038. 0x80075,
  3039. 0x80035,
  3040. 0x900ca,
  3041. 0x7010a,
  3042. 0x80065,
  3043. 0x80025,
  3044. 0x900aa,
  3045. 0x80005,
  3046. 0x80085,
  3047. 0x80045,
  3048. 0x900ea,
  3049. 0x70106,
  3050. 0x8005d,
  3051. 0x8001d,
  3052. 0x9009a,
  3053. 0x70116,
  3054. 0x8007d,
  3055. 0x8003d,
  3056. 0x900da,
  3057. 0x7010e,
  3058. 0x8006d,
  3059. 0x8002d,
  3060. 0x900ba,
  3061. 0x8000d,
  3062. 0x8008d,
  3063. 0x8004d,
  3064. 0x900fa,
  3065. 0x70101,
  3066. 0x80053,
  3067. 0x80013,
  3068. 0x8011b,
  3069. 0x70111,
  3070. 0x80073,
  3071. 0x80033,
  3072. 0x900c6,
  3073. 0x70109,
  3074. 0x80063,
  3075. 0x80023,
  3076. 0x900a6,
  3077. 0x80003,
  3078. 0x80083,
  3079. 0x80043,
  3080. 0x900e6,
  3081. 0x70105,
  3082. 0x8005b,
  3083. 0x8001b,
  3084. 0x90096,
  3085. 0x70115,
  3086. 0x8007b,
  3087. 0x8003b,
  3088. 0x900d6,
  3089. 0x7010d,
  3090. 0x8006b,
  3091. 0x8002b,
  3092. 0x900b6,
  3093. 0x8000b,
  3094. 0x8008b,
  3095. 0x8004b,
  3096. 0x900f6,
  3097. 0x70103,
  3098. 0x80057,
  3099. 0x80017,
  3100. 0x8011f,
  3101. 0x70113,
  3102. 0x80077,
  3103. 0x80037,
  3104. 0x900ce,
  3105. 0x7010b,
  3106. 0x80067,
  3107. 0x80027,
  3108. 0x900ae,
  3109. 0x80007,
  3110. 0x80087,
  3111. 0x80047,
  3112. 0x900ee,
  3113. 0x70107,
  3114. 0x8005f,
  3115. 0x8001f,
  3116. 0x9009e,
  3117. 0x70117,
  3118. 0x8007f,
  3119. 0x8003f,
  3120. 0x900de,
  3121. 0x7010f,
  3122. 0x8006f,
  3123. 0x8002f,
  3124. 0x900be,
  3125. 0x8000f,
  3126. 0x8008f,
  3127. 0x8004f,
  3128. 0x900fe,
  3129. 0x70100,
  3130. 0x80050,
  3131. 0x80010,
  3132. 0x80118,
  3133. 0x70110,
  3134. 0x80070,
  3135. 0x80030,
  3136. 0x900c1,
  3137. 0x70108,
  3138. 0x80060,
  3139. 0x80020,
  3140. 0x900a1,
  3141. 0x80000,
  3142. 0x80080,
  3143. 0x80040,
  3144. 0x900e1,
  3145. 0x70104,
  3146. 0x80058,
  3147. 0x80018,
  3148. 0x90091,
  3149. 0x70114,
  3150. 0x80078,
  3151. 0x80038,
  3152. 0x900d1,
  3153. 0x7010c,
  3154. 0x80068,
  3155. 0x80028,
  3156. 0x900b1,
  3157. 0x80008,
  3158. 0x80088,
  3159. 0x80048,
  3160. 0x900f1,
  3161. 0x70102,
  3162. 0x80054,
  3163. 0x80014,
  3164. 0x8011c,
  3165. 0x70112,
  3166. 0x80074,
  3167. 0x80034,
  3168. 0x900c9,
  3169. 0x7010a,
  3170. 0x80064,
  3171. 0x80024,
  3172. 0x900a9,
  3173. 0x80004,
  3174. 0x80084,
  3175. 0x80044,
  3176. 0x900e9,
  3177. 0x70106,
  3178. 0x8005c,
  3179. 0x8001c,
  3180. 0x90099,
  3181. 0x70116,
  3182. 0x8007c,
  3183. 0x8003c,
  3184. 0x900d9,
  3185. 0x7010e,
  3186. 0x8006c,
  3187. 0x8002c,
  3188. 0x900b9,
  3189. 0x8000c,
  3190. 0x8008c,
  3191. 0x8004c,
  3192. 0x900f9,
  3193. 0x70101,
  3194. 0x80052,
  3195. 0x80012,
  3196. 0x8011a,
  3197. 0x70111,
  3198. 0x80072,
  3199. 0x80032,
  3200. 0x900c5,
  3201. 0x70109,
  3202. 0x80062,
  3203. 0x80022,
  3204. 0x900a5,
  3205. 0x80002,
  3206. 0x80082,
  3207. 0x80042,
  3208. 0x900e5,
  3209. 0x70105,
  3210. 0x8005a,
  3211. 0x8001a,
  3212. 0x90095,
  3213. 0x70115,
  3214. 0x8007a,
  3215. 0x8003a,
  3216. 0x900d5,
  3217. 0x7010d,
  3218. 0x8006a,
  3219. 0x8002a,
  3220. 0x900b5,
  3221. 0x8000a,
  3222. 0x8008a,
  3223. 0x8004a,
  3224. 0x900f5,
  3225. 0x70103,
  3226. 0x80056,
  3227. 0x80016,
  3228. 0x8011e,
  3229. 0x70113,
  3230. 0x80076,
  3231. 0x80036,
  3232. 0x900cd,
  3233. 0x7010b,
  3234. 0x80066,
  3235. 0x80026,
  3236. 0x900ad,
  3237. 0x80006,
  3238. 0x80086,
  3239. 0x80046,
  3240. 0x900ed,
  3241. 0x70107,
  3242. 0x8005e,
  3243. 0x8001e,
  3244. 0x9009d,
  3245. 0x70117,
  3246. 0x8007e,
  3247. 0x8003e,
  3248. 0x900dd,
  3249. 0x7010f,
  3250. 0x8006e,
  3251. 0x8002e,
  3252. 0x900bd,
  3253. 0x8000e,
  3254. 0x8008e,
  3255. 0x8004e,
  3256. 0x900fd,
  3257. 0x70100,
  3258. 0x80051,
  3259. 0x80011,
  3260. 0x80119,
  3261. 0x70110,
  3262. 0x80071,
  3263. 0x80031,
  3264. 0x900c3,
  3265. 0x70108,
  3266. 0x80061,
  3267. 0x80021,
  3268. 0x900a3,
  3269. 0x80001,
  3270. 0x80081,
  3271. 0x80041,
  3272. 0x900e3,
  3273. 0x70104,
  3274. 0x80059,
  3275. 0x80019,
  3276. 0x90093,
  3277. 0x70114,
  3278. 0x80079,
  3279. 0x80039,
  3280. 0x900d3,
  3281. 0x7010c,
  3282. 0x80069,
  3283. 0x80029,
  3284. 0x900b3,
  3285. 0x80009,
  3286. 0x80089,
  3287. 0x80049,
  3288. 0x900f3,
  3289. 0x70102,
  3290. 0x80055,
  3291. 0x80015,
  3292. 0x8011d,
  3293. 0x70112,
  3294. 0x80075,
  3295. 0x80035,
  3296. 0x900cb,
  3297. 0x7010a,
  3298. 0x80065,
  3299. 0x80025,
  3300. 0x900ab,
  3301. 0x80005,
  3302. 0x80085,
  3303. 0x80045,
  3304. 0x900eb,
  3305. 0x70106,
  3306. 0x8005d,
  3307. 0x8001d,
  3308. 0x9009b,
  3309. 0x70116,
  3310. 0x8007d,
  3311. 0x8003d,
  3312. 0x900db,
  3313. 0x7010e,
  3314. 0x8006d,
  3315. 0x8002d,
  3316. 0x900bb,
  3317. 0x8000d,
  3318. 0x8008d,
  3319. 0x8004d,
  3320. 0x900fb,
  3321. 0x70101,
  3322. 0x80053,
  3323. 0x80013,
  3324. 0x8011b,
  3325. 0x70111,
  3326. 0x80073,
  3327. 0x80033,
  3328. 0x900c7,
  3329. 0x70109,
  3330. 0x80063,
  3331. 0x80023,
  3332. 0x900a7,
  3333. 0x80003,
  3334. 0x80083,
  3335. 0x80043,
  3336. 0x900e7,
  3337. 0x70105,
  3338. 0x8005b,
  3339. 0x8001b,
  3340. 0x90097,
  3341. 0x70115,
  3342. 0x8007b,
  3343. 0x8003b,
  3344. 0x900d7,
  3345. 0x7010d,
  3346. 0x8006b,
  3347. 0x8002b,
  3348. 0x900b7,
  3349. 0x8000b,
  3350. 0x8008b,
  3351. 0x8004b,
  3352. 0x900f7,
  3353. 0x70103,
  3354. 0x80057,
  3355. 0x80017,
  3356. 0x8011f,
  3357. 0x70113,
  3358. 0x80077,
  3359. 0x80037,
  3360. 0x900cf,
  3361. 0x7010b,
  3362. 0x80067,
  3363. 0x80027,
  3364. 0x900af,
  3365. 0x80007,
  3366. 0x80087,
  3367. 0x80047,
  3368. 0x900ef,
  3369. 0x70107,
  3370. 0x8005f,
  3371. 0x8001f,
  3372. 0x9009f,
  3373. 0x70117,
  3374. 0x8007f,
  3375. 0x8003f,
  3376. 0x900df,
  3377. 0x7010f,
  3378. 0x8006f,
  3379. 0x8002f,
  3380. 0x900bf,
  3381. 0x8000f,
  3382. 0x8008f,
  3383. 0x8004f,
  3384. 0x900ff
  3385. ]),
  3386. 9
  3387. ];
  3388. var fixedDistCodeTab = [
  3389. new Int32Array([
  3390. 0x50000,
  3391. 0x50010,
  3392. 0x50008,
  3393. 0x50018,
  3394. 0x50004,
  3395. 0x50014,
  3396. 0x5000c,
  3397. 0x5001c,
  3398. 0x50002,
  3399. 0x50012,
  3400. 0x5000a,
  3401. 0x5001a,
  3402. 0x50006,
  3403. 0x50016,
  3404. 0x5000e,
  3405. 0x00000,
  3406. 0x50001,
  3407. 0x50011,
  3408. 0x50009,
  3409. 0x50019,
  3410. 0x50005,
  3411. 0x50015,
  3412. 0x5000d,
  3413. 0x5001d,
  3414. 0x50003,
  3415. 0x50013,
  3416. 0x5000b,
  3417. 0x5001b,
  3418. 0x50007,
  3419. 0x50017,
  3420. 0x5000f,
  3421. 0x00000
  3422. ]),
  3423. 5
  3424. ];
  3425. function FlateStream(str, maybeLength) {
  3426. this.str = str;
  3427. this.dict = str.dict;
  3428. var cmf = str.getByte();
  3429. var flg = str.getByte();
  3430. if (cmf === -1 || flg === -1) {
  3431. error('Invalid header in flate stream: ' + cmf + ', ' + flg);
  3432. }
  3433. if ((cmf & 0x0f) !== 0x08) {
  3434. error('Unknown compression method in flate stream: ' + cmf + ', ' + flg);
  3435. }
  3436. if (((cmf << 8) + flg) % 31 !== 0) {
  3437. error('Bad FCHECK in flate stream: ' + cmf + ', ' + flg);
  3438. }
  3439. if (flg & 0x20) {
  3440. error('FDICT bit set in flate stream: ' + cmf + ', ' + flg);
  3441. }
  3442. this.codeSize = 0;
  3443. this.codeBuf = 0;
  3444. DecodeStream.call(this, maybeLength);
  3445. }
  3446. FlateStream.prototype = Object.create(DecodeStream.prototype);
  3447. FlateStream.prototype.getBits = function FlateStream_getBits(bits) {
  3448. var str = this.str;
  3449. var codeSize = this.codeSize;
  3450. var codeBuf = this.codeBuf;
  3451. var b;
  3452. while (codeSize < bits) {
  3453. if ((b = str.getByte()) === -1) {
  3454. error('Bad encoding in flate stream');
  3455. }
  3456. codeBuf |= b << codeSize;
  3457. codeSize += 8;
  3458. }
  3459. b = codeBuf & (1 << bits) - 1;
  3460. this.codeBuf = codeBuf >> bits;
  3461. this.codeSize = codeSize -= bits;
  3462. return b;
  3463. };
  3464. FlateStream.prototype.getCode = function FlateStream_getCode(table) {
  3465. var str = this.str;
  3466. var codes = table[0];
  3467. var maxLen = table[1];
  3468. var codeSize = this.codeSize;
  3469. var codeBuf = this.codeBuf;
  3470. var b;
  3471. while (codeSize < maxLen) {
  3472. if ((b = str.getByte()) === -1) {
  3473. break;
  3474. }
  3475. codeBuf |= b << codeSize;
  3476. codeSize += 8;
  3477. }
  3478. var code = codes[codeBuf & (1 << maxLen) - 1];
  3479. var codeLen = code >> 16;
  3480. var codeVal = code & 0xffff;
  3481. if (codeLen < 1 || codeSize < codeLen) {
  3482. error('Bad encoding in flate stream');
  3483. }
  3484. this.codeBuf = codeBuf >> codeLen;
  3485. this.codeSize = codeSize - codeLen;
  3486. return codeVal;
  3487. };
  3488. FlateStream.prototype.generateHuffmanTable = function flateStreamGenerateHuffmanTable(lengths) {
  3489. var n = lengths.length;
  3490. var maxLen = 0;
  3491. var i;
  3492. for (i = 0; i < n; ++i) {
  3493. if (lengths[i] > maxLen) {
  3494. maxLen = lengths[i];
  3495. }
  3496. }
  3497. var size = 1 << maxLen;
  3498. var codes = new Int32Array(size);
  3499. for (var len = 1, code = 0, skip = 2; len <= maxLen; ++len, code <<= 1, skip <<= 1) {
  3500. for (var val = 0; val < n; ++val) {
  3501. if (lengths[val] === len) {
  3502. var code2 = 0;
  3503. var t = code;
  3504. for (i = 0; i < len; ++i) {
  3505. code2 = code2 << 1 | t & 1;
  3506. t >>= 1;
  3507. }
  3508. for (i = code2; i < size; i += skip) {
  3509. codes[i] = len << 16 | val;
  3510. }
  3511. ++code;
  3512. }
  3513. }
  3514. }
  3515. return [
  3516. codes,
  3517. maxLen
  3518. ];
  3519. };
  3520. FlateStream.prototype.readBlock = function FlateStream_readBlock() {
  3521. var buffer, len;
  3522. var str = this.str;
  3523. var hdr = this.getBits(3);
  3524. if (hdr & 1) {
  3525. this.eof = true;
  3526. }
  3527. hdr >>= 1;
  3528. if (hdr === 0) {
  3529. var b;
  3530. if ((b = str.getByte()) === -1) {
  3531. error('Bad block header in flate stream');
  3532. }
  3533. var blockLen = b;
  3534. if ((b = str.getByte()) === -1) {
  3535. error('Bad block header in flate stream');
  3536. }
  3537. blockLen |= b << 8;
  3538. if ((b = str.getByte()) === -1) {
  3539. error('Bad block header in flate stream');
  3540. }
  3541. var check = b;
  3542. if ((b = str.getByte()) === -1) {
  3543. error('Bad block header in flate stream');
  3544. }
  3545. check |= b << 8;
  3546. if (check !== (~blockLen & 0xffff) && (blockLen !== 0 || check !== 0)) {
  3547. error('Bad uncompressed block length in flate stream');
  3548. }
  3549. this.codeBuf = 0;
  3550. this.codeSize = 0;
  3551. var bufferLength = this.bufferLength;
  3552. buffer = this.ensureBuffer(bufferLength + blockLen);
  3553. var end = bufferLength + blockLen;
  3554. this.bufferLength = end;
  3555. if (blockLen === 0) {
  3556. if (str.peekByte() === -1) {
  3557. this.eof = true;
  3558. }
  3559. } else {
  3560. for (var n = bufferLength; n < end; ++n) {
  3561. if ((b = str.getByte()) === -1) {
  3562. this.eof = true;
  3563. break;
  3564. }
  3565. buffer[n] = b;
  3566. }
  3567. }
  3568. return;
  3569. }
  3570. var litCodeTable;
  3571. var distCodeTable;
  3572. if (hdr === 1) {
  3573. litCodeTable = fixedLitCodeTab;
  3574. distCodeTable = fixedDistCodeTab;
  3575. } else if (hdr === 2) {
  3576. var numLitCodes = this.getBits(5) + 257;
  3577. var numDistCodes = this.getBits(5) + 1;
  3578. var numCodeLenCodes = this.getBits(4) + 4;
  3579. var codeLenCodeLengths = new Uint8Array(codeLenCodeMap.length);
  3580. var i;
  3581. for (i = 0; i < numCodeLenCodes; ++i) {
  3582. codeLenCodeLengths[codeLenCodeMap[i]] = this.getBits(3);
  3583. }
  3584. var codeLenCodeTab = this.generateHuffmanTable(codeLenCodeLengths);
  3585. len = 0;
  3586. i = 0;
  3587. var codes = numLitCodes + numDistCodes;
  3588. var codeLengths = new Uint8Array(codes);
  3589. var bitsLength, bitsOffset, what;
  3590. while (i < codes) {
  3591. var code = this.getCode(codeLenCodeTab);
  3592. if (code === 16) {
  3593. bitsLength = 2;
  3594. bitsOffset = 3;
  3595. what = len;
  3596. } else if (code === 17) {
  3597. bitsLength = 3;
  3598. bitsOffset = 3;
  3599. what = len = 0;
  3600. } else if (code === 18) {
  3601. bitsLength = 7;
  3602. bitsOffset = 11;
  3603. what = len = 0;
  3604. } else {
  3605. codeLengths[i++] = len = code;
  3606. continue;
  3607. }
  3608. var repeatLength = this.getBits(bitsLength) + bitsOffset;
  3609. while (repeatLength-- > 0) {
  3610. codeLengths[i++] = what;
  3611. }
  3612. }
  3613. litCodeTable = this.generateHuffmanTable(codeLengths.subarray(0, numLitCodes));
  3614. distCodeTable = this.generateHuffmanTable(codeLengths.subarray(numLitCodes, codes));
  3615. } else {
  3616. error('Unknown block type in flate stream');
  3617. }
  3618. buffer = this.buffer;
  3619. var limit = buffer ? buffer.length : 0;
  3620. var pos = this.bufferLength;
  3621. while (true) {
  3622. var code1 = this.getCode(litCodeTable);
  3623. if (code1 < 256) {
  3624. if (pos + 1 >= limit) {
  3625. buffer = this.ensureBuffer(pos + 1);
  3626. limit = buffer.length;
  3627. }
  3628. buffer[pos++] = code1;
  3629. continue;
  3630. }
  3631. if (code1 === 256) {
  3632. this.bufferLength = pos;
  3633. return;
  3634. }
  3635. code1 -= 257;
  3636. code1 = lengthDecode[code1];
  3637. var code2 = code1 >> 16;
  3638. if (code2 > 0) {
  3639. code2 = this.getBits(code2);
  3640. }
  3641. len = (code1 & 0xffff) + code2;
  3642. code1 = this.getCode(distCodeTable);
  3643. code1 = distDecode[code1];
  3644. code2 = code1 >> 16;
  3645. if (code2 > 0) {
  3646. code2 = this.getBits(code2);
  3647. }
  3648. var dist = (code1 & 0xffff) + code2;
  3649. if (pos + len >= limit) {
  3650. buffer = this.ensureBuffer(pos + len);
  3651. limit = buffer.length;
  3652. }
  3653. for (var k = 0; k < len; ++k, ++pos) {
  3654. buffer[pos] = buffer[pos - dist];
  3655. }
  3656. }
  3657. };
  3658. return FlateStream;
  3659. }();
  3660. var PredictorStream = function PredictorStreamClosure() {
  3661. function PredictorStream(str, maybeLength, params) {
  3662. if (!isDict(params)) {
  3663. return str;
  3664. }
  3665. var predictor = this.predictor = params.get('Predictor') || 1;
  3666. if (predictor <= 1) {
  3667. return str;
  3668. }
  3669. if (predictor !== 2 && (predictor < 10 || predictor > 15)) {
  3670. error('Unsupported predictor: ' + predictor);
  3671. }
  3672. if (predictor === 2) {
  3673. this.readBlock = this.readBlockTiff;
  3674. } else {
  3675. this.readBlock = this.readBlockPng;
  3676. }
  3677. this.str = str;
  3678. this.dict = str.dict;
  3679. var colors = this.colors = params.get('Colors') || 1;
  3680. var bits = this.bits = params.get('BitsPerComponent') || 8;
  3681. var columns = this.columns = params.get('Columns') || 1;
  3682. this.pixBytes = colors * bits + 7 >> 3;
  3683. this.rowBytes = columns * colors * bits + 7 >> 3;
  3684. DecodeStream.call(this, maybeLength);
  3685. return this;
  3686. }
  3687. PredictorStream.prototype = Object.create(DecodeStream.prototype);
  3688. PredictorStream.prototype.readBlockTiff = function predictorStreamReadBlockTiff() {
  3689. var rowBytes = this.rowBytes;
  3690. var bufferLength = this.bufferLength;
  3691. var buffer = this.ensureBuffer(bufferLength + rowBytes);
  3692. var bits = this.bits;
  3693. var colors = this.colors;
  3694. var rawBytes = this.str.getBytes(rowBytes);
  3695. this.eof = !rawBytes.length;
  3696. if (this.eof) {
  3697. return;
  3698. }
  3699. var inbuf = 0, outbuf = 0;
  3700. var inbits = 0, outbits = 0;
  3701. var pos = bufferLength;
  3702. var i;
  3703. if (bits === 1 && colors === 1) {
  3704. for (i = 0; i < rowBytes; ++i) {
  3705. var c = rawBytes[i] ^ inbuf;
  3706. c ^= c >> 1;
  3707. c ^= c >> 2;
  3708. c ^= c >> 4;
  3709. inbuf = (c & 1) << 7;
  3710. buffer[pos++] = c;
  3711. }
  3712. } else if (bits === 8) {
  3713. for (i = 0; i < colors; ++i) {
  3714. buffer[pos++] = rawBytes[i];
  3715. }
  3716. for (; i < rowBytes; ++i) {
  3717. buffer[pos] = buffer[pos - colors] + rawBytes[i];
  3718. pos++;
  3719. }
  3720. } else {
  3721. var compArray = new Uint8Array(colors + 1);
  3722. var bitMask = (1 << bits) - 1;
  3723. var j = 0, k = bufferLength;
  3724. var columns = this.columns;
  3725. for (i = 0; i < columns; ++i) {
  3726. for (var kk = 0; kk < colors; ++kk) {
  3727. if (inbits < bits) {
  3728. inbuf = inbuf << 8 | rawBytes[j++] & 0xFF;
  3729. inbits += 8;
  3730. }
  3731. compArray[kk] = compArray[kk] + (inbuf >> inbits - bits) & bitMask;
  3732. inbits -= bits;
  3733. outbuf = outbuf << bits | compArray[kk];
  3734. outbits += bits;
  3735. if (outbits >= 8) {
  3736. buffer[k++] = outbuf >> outbits - 8 & 0xFF;
  3737. outbits -= 8;
  3738. }
  3739. }
  3740. }
  3741. if (outbits > 0) {
  3742. buffer[k++] = (outbuf << 8 - outbits) + (inbuf & (1 << 8 - outbits) - 1);
  3743. }
  3744. }
  3745. this.bufferLength += rowBytes;
  3746. };
  3747. PredictorStream.prototype.readBlockPng = function predictorStreamReadBlockPng() {
  3748. var rowBytes = this.rowBytes;
  3749. var pixBytes = this.pixBytes;
  3750. var predictor = this.str.getByte();
  3751. var rawBytes = this.str.getBytes(rowBytes);
  3752. this.eof = !rawBytes.length;
  3753. if (this.eof) {
  3754. return;
  3755. }
  3756. var bufferLength = this.bufferLength;
  3757. var buffer = this.ensureBuffer(bufferLength + rowBytes);
  3758. var prevRow = buffer.subarray(bufferLength - rowBytes, bufferLength);
  3759. if (prevRow.length === 0) {
  3760. prevRow = new Uint8Array(rowBytes);
  3761. }
  3762. var i, j = bufferLength, up, c;
  3763. switch (predictor) {
  3764. case 0:
  3765. for (i = 0; i < rowBytes; ++i) {
  3766. buffer[j++] = rawBytes[i];
  3767. }
  3768. break;
  3769. case 1:
  3770. for (i = 0; i < pixBytes; ++i) {
  3771. buffer[j++] = rawBytes[i];
  3772. }
  3773. for (; i < rowBytes; ++i) {
  3774. buffer[j] = buffer[j - pixBytes] + rawBytes[i] & 0xFF;
  3775. j++;
  3776. }
  3777. break;
  3778. case 2:
  3779. for (i = 0; i < rowBytes; ++i) {
  3780. buffer[j++] = prevRow[i] + rawBytes[i] & 0xFF;
  3781. }
  3782. break;
  3783. case 3:
  3784. for (i = 0; i < pixBytes; ++i) {
  3785. buffer[j++] = (prevRow[i] >> 1) + rawBytes[i];
  3786. }
  3787. for (; i < rowBytes; ++i) {
  3788. buffer[j] = (prevRow[i] + buffer[j - pixBytes] >> 1) + rawBytes[i] & 0xFF;
  3789. j++;
  3790. }
  3791. break;
  3792. case 4:
  3793. for (i = 0; i < pixBytes; ++i) {
  3794. up = prevRow[i];
  3795. c = rawBytes[i];
  3796. buffer[j++] = up + c;
  3797. }
  3798. for (; i < rowBytes; ++i) {
  3799. up = prevRow[i];
  3800. var upLeft = prevRow[i - pixBytes];
  3801. var left = buffer[j - pixBytes];
  3802. var p = left + up - upLeft;
  3803. var pa = p - left;
  3804. if (pa < 0) {
  3805. pa = -pa;
  3806. }
  3807. var pb = p - up;
  3808. if (pb < 0) {
  3809. pb = -pb;
  3810. }
  3811. var pc = p - upLeft;
  3812. if (pc < 0) {
  3813. pc = -pc;
  3814. }
  3815. c = rawBytes[i];
  3816. if (pa <= pb && pa <= pc) {
  3817. buffer[j++] = left + c;
  3818. } else if (pb <= pc) {
  3819. buffer[j++] = up + c;
  3820. } else {
  3821. buffer[j++] = upLeft + c;
  3822. }
  3823. }
  3824. break;
  3825. default:
  3826. error('Unsupported predictor: ' + predictor);
  3827. }
  3828. this.bufferLength += rowBytes;
  3829. };
  3830. return PredictorStream;
  3831. }();
  3832. var JpegStream = function JpegStreamClosure() {
  3833. function JpegStream(stream, maybeLength, dict, params) {
  3834. var ch;
  3835. while ((ch = stream.getByte()) !== -1) {
  3836. if (ch === 0xFF) {
  3837. stream.skip(-1);
  3838. break;
  3839. }
  3840. }
  3841. this.stream = stream;
  3842. this.maybeLength = maybeLength;
  3843. this.dict = dict;
  3844. this.params = params;
  3845. DecodeStream.call(this, maybeLength);
  3846. }
  3847. JpegStream.prototype = Object.create(DecodeStream.prototype);
  3848. Object.defineProperty(JpegStream.prototype, 'bytes', {
  3849. get: function JpegStream_bytes() {
  3850. return shadow(this, 'bytes', this.stream.getBytes(this.maybeLength));
  3851. },
  3852. configurable: true
  3853. });
  3854. JpegStream.prototype.ensureBuffer = function JpegStream_ensureBuffer(req) {
  3855. if (this.bufferLength) {
  3856. return;
  3857. }
  3858. var jpegImage = new JpegImage();
  3859. var decodeArr = this.dict.getArray('Decode', 'D');
  3860. if (this.forceRGB && isArray(decodeArr)) {
  3861. var bitsPerComponent = this.dict.get('BitsPerComponent') || 8;
  3862. var decodeArrLength = decodeArr.length;
  3863. var transform = new Int32Array(decodeArrLength);
  3864. var transformNeeded = false;
  3865. var maxValue = (1 << bitsPerComponent) - 1;
  3866. for (var i = 0; i < decodeArrLength; i += 2) {
  3867. transform[i] = (decodeArr[i + 1] - decodeArr[i]) * 256 | 0;
  3868. transform[i + 1] = decodeArr[i] * maxValue | 0;
  3869. if (transform[i] !== 256 || transform[i + 1] !== 0) {
  3870. transformNeeded = true;
  3871. }
  3872. }
  3873. if (transformNeeded) {
  3874. jpegImage.decodeTransform = transform;
  3875. }
  3876. }
  3877. if (isDict(this.params)) {
  3878. var colorTransform = this.params.get('ColorTransform');
  3879. if (isInt(colorTransform)) {
  3880. jpegImage.colorTransform = colorTransform;
  3881. }
  3882. }
  3883. jpegImage.parse(this.bytes);
  3884. var data = jpegImage.getData(this.drawWidth, this.drawHeight, this.forceRGB);
  3885. this.buffer = data;
  3886. this.bufferLength = data.length;
  3887. this.eof = true;
  3888. };
  3889. JpegStream.prototype.getBytes = function JpegStream_getBytes(length) {
  3890. this.ensureBuffer();
  3891. return this.buffer;
  3892. };
  3893. JpegStream.prototype.getIR = function JpegStream_getIR(forceDataSchema) {
  3894. return createObjectURL(this.bytes, 'image/jpeg', forceDataSchema);
  3895. };
  3896. return JpegStream;
  3897. }();
  3898. var JpxStream = function JpxStreamClosure() {
  3899. function JpxStream(stream, maybeLength, dict, params) {
  3900. this.stream = stream;
  3901. this.maybeLength = maybeLength;
  3902. this.dict = dict;
  3903. this.params = params;
  3904. DecodeStream.call(this, maybeLength);
  3905. }
  3906. JpxStream.prototype = Object.create(DecodeStream.prototype);
  3907. Object.defineProperty(JpxStream.prototype, 'bytes', {
  3908. get: function JpxStream_bytes() {
  3909. return shadow(this, 'bytes', this.stream.getBytes(this.maybeLength));
  3910. },
  3911. configurable: true
  3912. });
  3913. JpxStream.prototype.ensureBuffer = function JpxStream_ensureBuffer(req) {
  3914. if (this.bufferLength) {
  3915. return;
  3916. }
  3917. var jpxImage = new JpxImage();
  3918. jpxImage.parse(this.bytes);
  3919. var width = jpxImage.width;
  3920. var height = jpxImage.height;
  3921. var componentsCount = jpxImage.componentsCount;
  3922. var tileCount = jpxImage.tiles.length;
  3923. if (tileCount === 1) {
  3924. this.buffer = jpxImage.tiles[0].items;
  3925. } else {
  3926. var data = new Uint8Array(width * height * componentsCount);
  3927. for (var k = 0; k < tileCount; k++) {
  3928. var tileComponents = jpxImage.tiles[k];
  3929. var tileWidth = tileComponents.width;
  3930. var tileHeight = tileComponents.height;
  3931. var tileLeft = tileComponents.left;
  3932. var tileTop = tileComponents.top;
  3933. var src = tileComponents.items;
  3934. var srcPosition = 0;
  3935. var dataPosition = (width * tileTop + tileLeft) * componentsCount;
  3936. var imgRowSize = width * componentsCount;
  3937. var tileRowSize = tileWidth * componentsCount;
  3938. for (var j = 0; j < tileHeight; j++) {
  3939. var rowBytes = src.subarray(srcPosition, srcPosition + tileRowSize);
  3940. data.set(rowBytes, dataPosition);
  3941. srcPosition += tileRowSize;
  3942. dataPosition += imgRowSize;
  3943. }
  3944. }
  3945. this.buffer = data;
  3946. }
  3947. this.bufferLength = this.buffer.length;
  3948. this.eof = true;
  3949. };
  3950. return JpxStream;
  3951. }();
  3952. var Jbig2Stream = function Jbig2StreamClosure() {
  3953. function Jbig2Stream(stream, maybeLength, dict, params) {
  3954. this.stream = stream;
  3955. this.maybeLength = maybeLength;
  3956. this.dict = dict;
  3957. this.params = params;
  3958. DecodeStream.call(this, maybeLength);
  3959. }
  3960. Jbig2Stream.prototype = Object.create(DecodeStream.prototype);
  3961. Object.defineProperty(Jbig2Stream.prototype, 'bytes', {
  3962. get: function Jbig2Stream_bytes() {
  3963. return shadow(this, 'bytes', this.stream.getBytes(this.maybeLength));
  3964. },
  3965. configurable: true
  3966. });
  3967. Jbig2Stream.prototype.ensureBuffer = function Jbig2Stream_ensureBuffer(req) {
  3968. if (this.bufferLength) {
  3969. return;
  3970. }
  3971. var jbig2Image = new Jbig2Image();
  3972. var chunks = [];
  3973. if (isDict(this.params)) {
  3974. var globalsStream = this.params.get('JBIG2Globals');
  3975. if (isStream(globalsStream)) {
  3976. var globals = globalsStream.getBytes();
  3977. chunks.push({
  3978. data: globals,
  3979. start: 0,
  3980. end: globals.length
  3981. });
  3982. }
  3983. }
  3984. chunks.push({
  3985. data: this.bytes,
  3986. start: 0,
  3987. end: this.bytes.length
  3988. });
  3989. var data = jbig2Image.parseChunks(chunks);
  3990. var dataLength = data.length;
  3991. for (var i = 0; i < dataLength; i++) {
  3992. data[i] ^= 0xFF;
  3993. }
  3994. this.buffer = data;
  3995. this.bufferLength = dataLength;
  3996. this.eof = true;
  3997. };
  3998. return Jbig2Stream;
  3999. }();
  4000. var DecryptStream = function DecryptStreamClosure() {
  4001. function DecryptStream(str, maybeLength, decrypt) {
  4002. this.str = str;
  4003. this.dict = str.dict;
  4004. this.decrypt = decrypt;
  4005. this.nextChunk = null;
  4006. this.initialized = false;
  4007. DecodeStream.call(this, maybeLength);
  4008. }
  4009. var chunkSize = 512;
  4010. DecryptStream.prototype = Object.create(DecodeStream.prototype);
  4011. DecryptStream.prototype.readBlock = function DecryptStream_readBlock() {
  4012. var chunk;
  4013. if (this.initialized) {
  4014. chunk = this.nextChunk;
  4015. } else {
  4016. chunk = this.str.getBytes(chunkSize);
  4017. this.initialized = true;
  4018. }
  4019. if (!chunk || chunk.length === 0) {
  4020. this.eof = true;
  4021. return;
  4022. }
  4023. this.nextChunk = this.str.getBytes(chunkSize);
  4024. var hasMoreData = this.nextChunk && this.nextChunk.length > 0;
  4025. var decrypt = this.decrypt;
  4026. chunk = decrypt(chunk, !hasMoreData);
  4027. var bufferLength = this.bufferLength;
  4028. var i, n = chunk.length;
  4029. var buffer = this.ensureBuffer(bufferLength + n);
  4030. for (i = 0; i < n; i++) {
  4031. buffer[bufferLength++] = chunk[i];
  4032. }
  4033. this.bufferLength = bufferLength;
  4034. };
  4035. return DecryptStream;
  4036. }();
  4037. var Ascii85Stream = function Ascii85StreamClosure() {
  4038. function Ascii85Stream(str, maybeLength) {
  4039. this.str = str;
  4040. this.dict = str.dict;
  4041. this.input = new Uint8Array(5);
  4042. if (maybeLength) {
  4043. maybeLength = 0.8 * maybeLength;
  4044. }
  4045. DecodeStream.call(this, maybeLength);
  4046. }
  4047. Ascii85Stream.prototype = Object.create(DecodeStream.prototype);
  4048. Ascii85Stream.prototype.readBlock = function Ascii85Stream_readBlock() {
  4049. var TILDA_CHAR = 0x7E;
  4050. var Z_LOWER_CHAR = 0x7A;
  4051. var EOF = -1;
  4052. var str = this.str;
  4053. var c = str.getByte();
  4054. while (isSpace(c)) {
  4055. c = str.getByte();
  4056. }
  4057. if (c === EOF || c === TILDA_CHAR) {
  4058. this.eof = true;
  4059. return;
  4060. }
  4061. var bufferLength = this.bufferLength, buffer;
  4062. var i;
  4063. if (c === Z_LOWER_CHAR) {
  4064. buffer = this.ensureBuffer(bufferLength + 4);
  4065. for (i = 0; i < 4; ++i) {
  4066. buffer[bufferLength + i] = 0;
  4067. }
  4068. this.bufferLength += 4;
  4069. } else {
  4070. var input = this.input;
  4071. input[0] = c;
  4072. for (i = 1; i < 5; ++i) {
  4073. c = str.getByte();
  4074. while (isSpace(c)) {
  4075. c = str.getByte();
  4076. }
  4077. input[i] = c;
  4078. if (c === EOF || c === TILDA_CHAR) {
  4079. break;
  4080. }
  4081. }
  4082. buffer = this.ensureBuffer(bufferLength + i - 1);
  4083. this.bufferLength += i - 1;
  4084. if (i < 5) {
  4085. for (; i < 5; ++i) {
  4086. input[i] = 0x21 + 84;
  4087. }
  4088. this.eof = true;
  4089. }
  4090. var t = 0;
  4091. for (i = 0; i < 5; ++i) {
  4092. t = t * 85 + (input[i] - 0x21);
  4093. }
  4094. for (i = 3; i >= 0; --i) {
  4095. buffer[bufferLength + i] = t & 0xFF;
  4096. t >>= 8;
  4097. }
  4098. }
  4099. };
  4100. return Ascii85Stream;
  4101. }();
  4102. var AsciiHexStream = function AsciiHexStreamClosure() {
  4103. function AsciiHexStream(str, maybeLength) {
  4104. this.str = str;
  4105. this.dict = str.dict;
  4106. this.firstDigit = -1;
  4107. if (maybeLength) {
  4108. maybeLength = 0.5 * maybeLength;
  4109. }
  4110. DecodeStream.call(this, maybeLength);
  4111. }
  4112. AsciiHexStream.prototype = Object.create(DecodeStream.prototype);
  4113. AsciiHexStream.prototype.readBlock = function AsciiHexStream_readBlock() {
  4114. var UPSTREAM_BLOCK_SIZE = 8000;
  4115. var bytes = this.str.getBytes(UPSTREAM_BLOCK_SIZE);
  4116. if (!bytes.length) {
  4117. this.eof = true;
  4118. return;
  4119. }
  4120. var maxDecodeLength = bytes.length + 1 >> 1;
  4121. var buffer = this.ensureBuffer(this.bufferLength + maxDecodeLength);
  4122. var bufferLength = this.bufferLength;
  4123. var firstDigit = this.firstDigit;
  4124. for (var i = 0, ii = bytes.length; i < ii; i++) {
  4125. var ch = bytes[i], digit;
  4126. if (ch >= 0x30 && ch <= 0x39) {
  4127. digit = ch & 0x0F;
  4128. } else if (ch >= 0x41 && ch <= 0x46 || ch >= 0x61 && ch <= 0x66) {
  4129. digit = (ch & 0x0F) + 9;
  4130. } else if (ch === 0x3E) {
  4131. this.eof = true;
  4132. break;
  4133. } else {
  4134. continue;
  4135. }
  4136. if (firstDigit < 0) {
  4137. firstDigit = digit;
  4138. } else {
  4139. buffer[bufferLength++] = firstDigit << 4 | digit;
  4140. firstDigit = -1;
  4141. }
  4142. }
  4143. if (firstDigit >= 0 && this.eof) {
  4144. buffer[bufferLength++] = firstDigit << 4;
  4145. firstDigit = -1;
  4146. }
  4147. this.firstDigit = firstDigit;
  4148. this.bufferLength = bufferLength;
  4149. };
  4150. return AsciiHexStream;
  4151. }();
  4152. var RunLengthStream = function RunLengthStreamClosure() {
  4153. function RunLengthStream(str, maybeLength) {
  4154. this.str = str;
  4155. this.dict = str.dict;
  4156. DecodeStream.call(this, maybeLength);
  4157. }
  4158. RunLengthStream.prototype = Object.create(DecodeStream.prototype);
  4159. RunLengthStream.prototype.readBlock = function RunLengthStream_readBlock() {
  4160. var repeatHeader = this.str.getBytes(2);
  4161. if (!repeatHeader || repeatHeader.length < 2 || repeatHeader[0] === 128) {
  4162. this.eof = true;
  4163. return;
  4164. }
  4165. var buffer;
  4166. var bufferLength = this.bufferLength;
  4167. var n = repeatHeader[0];
  4168. if (n < 128) {
  4169. buffer = this.ensureBuffer(bufferLength + n + 1);
  4170. buffer[bufferLength++] = repeatHeader[1];
  4171. if (n > 0) {
  4172. var source = this.str.getBytes(n);
  4173. buffer.set(source, bufferLength);
  4174. bufferLength += n;
  4175. }
  4176. } else {
  4177. n = 257 - n;
  4178. var b = repeatHeader[1];
  4179. buffer = this.ensureBuffer(bufferLength + n + 1);
  4180. for (var i = 0; i < n; i++) {
  4181. buffer[bufferLength++] = b;
  4182. }
  4183. }
  4184. this.bufferLength = bufferLength;
  4185. };
  4186. return RunLengthStream;
  4187. }();
  4188. var CCITTFaxStream = function CCITTFaxStreamClosure() {
  4189. var ccittEOL = -2;
  4190. var ccittEOF = -1;
  4191. var twoDimPass = 0;
  4192. var twoDimHoriz = 1;
  4193. var twoDimVert0 = 2;
  4194. var twoDimVertR1 = 3;
  4195. var twoDimVertL1 = 4;
  4196. var twoDimVertR2 = 5;
  4197. var twoDimVertL2 = 6;
  4198. var twoDimVertR3 = 7;
  4199. var twoDimVertL3 = 8;
  4200. var twoDimTable = [
  4201. [
  4202. -1,
  4203. -1
  4204. ],
  4205. [
  4206. -1,
  4207. -1
  4208. ],
  4209. [
  4210. 7,
  4211. twoDimVertL3
  4212. ],
  4213. [
  4214. 7,
  4215. twoDimVertR3
  4216. ],
  4217. [
  4218. 6,
  4219. twoDimVertL2
  4220. ],
  4221. [
  4222. 6,
  4223. twoDimVertL2
  4224. ],
  4225. [
  4226. 6,
  4227. twoDimVertR2
  4228. ],
  4229. [
  4230. 6,
  4231. twoDimVertR2
  4232. ],
  4233. [
  4234. 4,
  4235. twoDimPass
  4236. ],
  4237. [
  4238. 4,
  4239. twoDimPass
  4240. ],
  4241. [
  4242. 4,
  4243. twoDimPass
  4244. ],
  4245. [
  4246. 4,
  4247. twoDimPass
  4248. ],
  4249. [
  4250. 4,
  4251. twoDimPass
  4252. ],
  4253. [
  4254. 4,
  4255. twoDimPass
  4256. ],
  4257. [
  4258. 4,
  4259. twoDimPass
  4260. ],
  4261. [
  4262. 4,
  4263. twoDimPass
  4264. ],
  4265. [
  4266. 3,
  4267. twoDimHoriz
  4268. ],
  4269. [
  4270. 3,
  4271. twoDimHoriz
  4272. ],
  4273. [
  4274. 3,
  4275. twoDimHoriz
  4276. ],
  4277. [
  4278. 3,
  4279. twoDimHoriz
  4280. ],
  4281. [
  4282. 3,
  4283. twoDimHoriz
  4284. ],
  4285. [
  4286. 3,
  4287. twoDimHoriz
  4288. ],
  4289. [
  4290. 3,
  4291. twoDimHoriz
  4292. ],
  4293. [
  4294. 3,
  4295. twoDimHoriz
  4296. ],
  4297. [
  4298. 3,
  4299. twoDimHoriz
  4300. ],
  4301. [
  4302. 3,
  4303. twoDimHoriz
  4304. ],
  4305. [
  4306. 3,
  4307. twoDimHoriz
  4308. ],
  4309. [
  4310. 3,
  4311. twoDimHoriz
  4312. ],
  4313. [
  4314. 3,
  4315. twoDimHoriz
  4316. ],
  4317. [
  4318. 3,
  4319. twoDimHoriz
  4320. ],
  4321. [
  4322. 3,
  4323. twoDimHoriz
  4324. ],
  4325. [
  4326. 3,
  4327. twoDimHoriz
  4328. ],
  4329. [
  4330. 3,
  4331. twoDimVertL1
  4332. ],
  4333. [
  4334. 3,
  4335. twoDimVertL1
  4336. ],
  4337. [
  4338. 3,
  4339. twoDimVertL1
  4340. ],
  4341. [
  4342. 3,
  4343. twoDimVertL1
  4344. ],
  4345. [
  4346. 3,
  4347. twoDimVertL1
  4348. ],
  4349. [
  4350. 3,
  4351. twoDimVertL1
  4352. ],
  4353. [
  4354. 3,
  4355. twoDimVertL1
  4356. ],
  4357. [
  4358. 3,
  4359. twoDimVertL1
  4360. ],
  4361. [
  4362. 3,
  4363. twoDimVertL1
  4364. ],
  4365. [
  4366. 3,
  4367. twoDimVertL1
  4368. ],
  4369. [
  4370. 3,
  4371. twoDimVertL1
  4372. ],
  4373. [
  4374. 3,
  4375. twoDimVertL1
  4376. ],
  4377. [
  4378. 3,
  4379. twoDimVertL1
  4380. ],
  4381. [
  4382. 3,
  4383. twoDimVertL1
  4384. ],
  4385. [
  4386. 3,
  4387. twoDimVertL1
  4388. ],
  4389. [
  4390. 3,
  4391. twoDimVertL1
  4392. ],
  4393. [
  4394. 3,
  4395. twoDimVertR1
  4396. ],
  4397. [
  4398. 3,
  4399. twoDimVertR1
  4400. ],
  4401. [
  4402. 3,
  4403. twoDimVertR1
  4404. ],
  4405. [
  4406. 3,
  4407. twoDimVertR1
  4408. ],
  4409. [
  4410. 3,
  4411. twoDimVertR1
  4412. ],
  4413. [
  4414. 3,
  4415. twoDimVertR1
  4416. ],
  4417. [
  4418. 3,
  4419. twoDimVertR1
  4420. ],
  4421. [
  4422. 3,
  4423. twoDimVertR1
  4424. ],
  4425. [
  4426. 3,
  4427. twoDimVertR1
  4428. ],
  4429. [
  4430. 3,
  4431. twoDimVertR1
  4432. ],
  4433. [
  4434. 3,
  4435. twoDimVertR1
  4436. ],
  4437. [
  4438. 3,
  4439. twoDimVertR1
  4440. ],
  4441. [
  4442. 3,
  4443. twoDimVertR1
  4444. ],
  4445. [
  4446. 3,
  4447. twoDimVertR1
  4448. ],
  4449. [
  4450. 3,
  4451. twoDimVertR1
  4452. ],
  4453. [
  4454. 3,
  4455. twoDimVertR1
  4456. ],
  4457. [
  4458. 1,
  4459. twoDimVert0
  4460. ],
  4461. [
  4462. 1,
  4463. twoDimVert0
  4464. ],
  4465. [
  4466. 1,
  4467. twoDimVert0
  4468. ],
  4469. [
  4470. 1,
  4471. twoDimVert0
  4472. ],
  4473. [
  4474. 1,
  4475. twoDimVert0
  4476. ],
  4477. [
  4478. 1,
  4479. twoDimVert0
  4480. ],
  4481. [
  4482. 1,
  4483. twoDimVert0
  4484. ],
  4485. [
  4486. 1,
  4487. twoDimVert0
  4488. ],
  4489. [
  4490. 1,
  4491. twoDimVert0
  4492. ],
  4493. [
  4494. 1,
  4495. twoDimVert0
  4496. ],
  4497. [
  4498. 1,
  4499. twoDimVert0
  4500. ],
  4501. [
  4502. 1,
  4503. twoDimVert0
  4504. ],
  4505. [
  4506. 1,
  4507. twoDimVert0
  4508. ],
  4509. [
  4510. 1,
  4511. twoDimVert0
  4512. ],
  4513. [
  4514. 1,
  4515. twoDimVert0
  4516. ],
  4517. [
  4518. 1,
  4519. twoDimVert0
  4520. ],
  4521. [
  4522. 1,
  4523. twoDimVert0
  4524. ],
  4525. [
  4526. 1,
  4527. twoDimVert0
  4528. ],
  4529. [
  4530. 1,
  4531. twoDimVert0
  4532. ],
  4533. [
  4534. 1,
  4535. twoDimVert0
  4536. ],
  4537. [
  4538. 1,
  4539. twoDimVert0
  4540. ],
  4541. [
  4542. 1,
  4543. twoDimVert0
  4544. ],
  4545. [
  4546. 1,
  4547. twoDimVert0
  4548. ],
  4549. [
  4550. 1,
  4551. twoDimVert0
  4552. ],
  4553. [
  4554. 1,
  4555. twoDimVert0
  4556. ],
  4557. [
  4558. 1,
  4559. twoDimVert0
  4560. ],
  4561. [
  4562. 1,
  4563. twoDimVert0
  4564. ],
  4565. [
  4566. 1,
  4567. twoDimVert0
  4568. ],
  4569. [
  4570. 1,
  4571. twoDimVert0
  4572. ],
  4573. [
  4574. 1,
  4575. twoDimVert0
  4576. ],
  4577. [
  4578. 1,
  4579. twoDimVert0
  4580. ],
  4581. [
  4582. 1,
  4583. twoDimVert0
  4584. ],
  4585. [
  4586. 1,
  4587. twoDimVert0
  4588. ],
  4589. [
  4590. 1,
  4591. twoDimVert0
  4592. ],
  4593. [
  4594. 1,
  4595. twoDimVert0
  4596. ],
  4597. [
  4598. 1,
  4599. twoDimVert0
  4600. ],
  4601. [
  4602. 1,
  4603. twoDimVert0
  4604. ],
  4605. [
  4606. 1,
  4607. twoDimVert0
  4608. ],
  4609. [
  4610. 1,
  4611. twoDimVert0
  4612. ],
  4613. [
  4614. 1,
  4615. twoDimVert0
  4616. ],
  4617. [
  4618. 1,
  4619. twoDimVert0
  4620. ],
  4621. [
  4622. 1,
  4623. twoDimVert0
  4624. ],
  4625. [
  4626. 1,
  4627. twoDimVert0
  4628. ],
  4629. [
  4630. 1,
  4631. twoDimVert0
  4632. ],
  4633. [
  4634. 1,
  4635. twoDimVert0
  4636. ],
  4637. [
  4638. 1,
  4639. twoDimVert0
  4640. ],
  4641. [
  4642. 1,
  4643. twoDimVert0
  4644. ],
  4645. [
  4646. 1,
  4647. twoDimVert0
  4648. ],
  4649. [
  4650. 1,
  4651. twoDimVert0
  4652. ],
  4653. [
  4654. 1,
  4655. twoDimVert0
  4656. ],
  4657. [
  4658. 1,
  4659. twoDimVert0
  4660. ],
  4661. [
  4662. 1,
  4663. twoDimVert0
  4664. ],
  4665. [
  4666. 1,
  4667. twoDimVert0
  4668. ],
  4669. [
  4670. 1,
  4671. twoDimVert0
  4672. ],
  4673. [
  4674. 1,
  4675. twoDimVert0
  4676. ],
  4677. [
  4678. 1,
  4679. twoDimVert0
  4680. ],
  4681. [
  4682. 1,
  4683. twoDimVert0
  4684. ],
  4685. [
  4686. 1,
  4687. twoDimVert0
  4688. ],
  4689. [
  4690. 1,
  4691. twoDimVert0
  4692. ],
  4693. [
  4694. 1,
  4695. twoDimVert0
  4696. ],
  4697. [
  4698. 1,
  4699. twoDimVert0
  4700. ],
  4701. [
  4702. 1,
  4703. twoDimVert0
  4704. ],
  4705. [
  4706. 1,
  4707. twoDimVert0
  4708. ],
  4709. [
  4710. 1,
  4711. twoDimVert0
  4712. ]
  4713. ];
  4714. var whiteTable1 = [
  4715. [
  4716. -1,
  4717. -1
  4718. ],
  4719. [
  4720. 12,
  4721. ccittEOL
  4722. ],
  4723. [
  4724. -1,
  4725. -1
  4726. ],
  4727. [
  4728. -1,
  4729. -1
  4730. ],
  4731. [
  4732. -1,
  4733. -1
  4734. ],
  4735. [
  4736. -1,
  4737. -1
  4738. ],
  4739. [
  4740. -1,
  4741. -1
  4742. ],
  4743. [
  4744. -1,
  4745. -1
  4746. ],
  4747. [
  4748. -1,
  4749. -1
  4750. ],
  4751. [
  4752. -1,
  4753. -1
  4754. ],
  4755. [
  4756. -1,
  4757. -1
  4758. ],
  4759. [
  4760. -1,
  4761. -1
  4762. ],
  4763. [
  4764. -1,
  4765. -1
  4766. ],
  4767. [
  4768. -1,
  4769. -1
  4770. ],
  4771. [
  4772. -1,
  4773. -1
  4774. ],
  4775. [
  4776. -1,
  4777. -1
  4778. ],
  4779. [
  4780. 11,
  4781. 1792
  4782. ],
  4783. [
  4784. 11,
  4785. 1792
  4786. ],
  4787. [
  4788. 12,
  4789. 1984
  4790. ],
  4791. [
  4792. 12,
  4793. 2048
  4794. ],
  4795. [
  4796. 12,
  4797. 2112
  4798. ],
  4799. [
  4800. 12,
  4801. 2176
  4802. ],
  4803. [
  4804. 12,
  4805. 2240
  4806. ],
  4807. [
  4808. 12,
  4809. 2304
  4810. ],
  4811. [
  4812. 11,
  4813. 1856
  4814. ],
  4815. [
  4816. 11,
  4817. 1856
  4818. ],
  4819. [
  4820. 11,
  4821. 1920
  4822. ],
  4823. [
  4824. 11,
  4825. 1920
  4826. ],
  4827. [
  4828. 12,
  4829. 2368
  4830. ],
  4831. [
  4832. 12,
  4833. 2432
  4834. ],
  4835. [
  4836. 12,
  4837. 2496
  4838. ],
  4839. [
  4840. 12,
  4841. 2560
  4842. ]
  4843. ];
  4844. var whiteTable2 = [
  4845. [
  4846. -1,
  4847. -1
  4848. ],
  4849. [
  4850. -1,
  4851. -1
  4852. ],
  4853. [
  4854. -1,
  4855. -1
  4856. ],
  4857. [
  4858. -1,
  4859. -1
  4860. ],
  4861. [
  4862. 8,
  4863. 29
  4864. ],
  4865. [
  4866. 8,
  4867. 29
  4868. ],
  4869. [
  4870. 8,
  4871. 30
  4872. ],
  4873. [
  4874. 8,
  4875. 30
  4876. ],
  4877. [
  4878. 8,
  4879. 45
  4880. ],
  4881. [
  4882. 8,
  4883. 45
  4884. ],
  4885. [
  4886. 8,
  4887. 46
  4888. ],
  4889. [
  4890. 8,
  4891. 46
  4892. ],
  4893. [
  4894. 7,
  4895. 22
  4896. ],
  4897. [
  4898. 7,
  4899. 22
  4900. ],
  4901. [
  4902. 7,
  4903. 22
  4904. ],
  4905. [
  4906. 7,
  4907. 22
  4908. ],
  4909. [
  4910. 7,
  4911. 23
  4912. ],
  4913. [
  4914. 7,
  4915. 23
  4916. ],
  4917. [
  4918. 7,
  4919. 23
  4920. ],
  4921. [
  4922. 7,
  4923. 23
  4924. ],
  4925. [
  4926. 8,
  4927. 47
  4928. ],
  4929. [
  4930. 8,
  4931. 47
  4932. ],
  4933. [
  4934. 8,
  4935. 48
  4936. ],
  4937. [
  4938. 8,
  4939. 48
  4940. ],
  4941. [
  4942. 6,
  4943. 13
  4944. ],
  4945. [
  4946. 6,
  4947. 13
  4948. ],
  4949. [
  4950. 6,
  4951. 13
  4952. ],
  4953. [
  4954. 6,
  4955. 13
  4956. ],
  4957. [
  4958. 6,
  4959. 13
  4960. ],
  4961. [
  4962. 6,
  4963. 13
  4964. ],
  4965. [
  4966. 6,
  4967. 13
  4968. ],
  4969. [
  4970. 6,
  4971. 13
  4972. ],
  4973. [
  4974. 7,
  4975. 20
  4976. ],
  4977. [
  4978. 7,
  4979. 20
  4980. ],
  4981. [
  4982. 7,
  4983. 20
  4984. ],
  4985. [
  4986. 7,
  4987. 20
  4988. ],
  4989. [
  4990. 8,
  4991. 33
  4992. ],
  4993. [
  4994. 8,
  4995. 33
  4996. ],
  4997. [
  4998. 8,
  4999. 34
  5000. ],
  5001. [
  5002. 8,
  5003. 34
  5004. ],
  5005. [
  5006. 8,
  5007. 35
  5008. ],
  5009. [
  5010. 8,
  5011. 35
  5012. ],
  5013. [
  5014. 8,
  5015. 36
  5016. ],
  5017. [
  5018. 8,
  5019. 36
  5020. ],
  5021. [
  5022. 8,
  5023. 37
  5024. ],
  5025. [
  5026. 8,
  5027. 37
  5028. ],
  5029. [
  5030. 8,
  5031. 38
  5032. ],
  5033. [
  5034. 8,
  5035. 38
  5036. ],
  5037. [
  5038. 7,
  5039. 19
  5040. ],
  5041. [
  5042. 7,
  5043. 19
  5044. ],
  5045. [
  5046. 7,
  5047. 19
  5048. ],
  5049. [
  5050. 7,
  5051. 19
  5052. ],
  5053. [
  5054. 8,
  5055. 31
  5056. ],
  5057. [
  5058. 8,
  5059. 31
  5060. ],
  5061. [
  5062. 8,
  5063. 32
  5064. ],
  5065. [
  5066. 8,
  5067. 32
  5068. ],
  5069. [
  5070. 6,
  5071. 1
  5072. ],
  5073. [
  5074. 6,
  5075. 1
  5076. ],
  5077. [
  5078. 6,
  5079. 1
  5080. ],
  5081. [
  5082. 6,
  5083. 1
  5084. ],
  5085. [
  5086. 6,
  5087. 1
  5088. ],
  5089. [
  5090. 6,
  5091. 1
  5092. ],
  5093. [
  5094. 6,
  5095. 1
  5096. ],
  5097. [
  5098. 6,
  5099. 1
  5100. ],
  5101. [
  5102. 6,
  5103. 12
  5104. ],
  5105. [
  5106. 6,
  5107. 12
  5108. ],
  5109. [
  5110. 6,
  5111. 12
  5112. ],
  5113. [
  5114. 6,
  5115. 12
  5116. ],
  5117. [
  5118. 6,
  5119. 12
  5120. ],
  5121. [
  5122. 6,
  5123. 12
  5124. ],
  5125. [
  5126. 6,
  5127. 12
  5128. ],
  5129. [
  5130. 6,
  5131. 12
  5132. ],
  5133. [
  5134. 8,
  5135. 53
  5136. ],
  5137. [
  5138. 8,
  5139. 53
  5140. ],
  5141. [
  5142. 8,
  5143. 54
  5144. ],
  5145. [
  5146. 8,
  5147. 54
  5148. ],
  5149. [
  5150. 7,
  5151. 26
  5152. ],
  5153. [
  5154. 7,
  5155. 26
  5156. ],
  5157. [
  5158. 7,
  5159. 26
  5160. ],
  5161. [
  5162. 7,
  5163. 26
  5164. ],
  5165. [
  5166. 8,
  5167. 39
  5168. ],
  5169. [
  5170. 8,
  5171. 39
  5172. ],
  5173. [
  5174. 8,
  5175. 40
  5176. ],
  5177. [
  5178. 8,
  5179. 40
  5180. ],
  5181. [
  5182. 8,
  5183. 41
  5184. ],
  5185. [
  5186. 8,
  5187. 41
  5188. ],
  5189. [
  5190. 8,
  5191. 42
  5192. ],
  5193. [
  5194. 8,
  5195. 42
  5196. ],
  5197. [
  5198. 8,
  5199. 43
  5200. ],
  5201. [
  5202. 8,
  5203. 43
  5204. ],
  5205. [
  5206. 8,
  5207. 44
  5208. ],
  5209. [
  5210. 8,
  5211. 44
  5212. ],
  5213. [
  5214. 7,
  5215. 21
  5216. ],
  5217. [
  5218. 7,
  5219. 21
  5220. ],
  5221. [
  5222. 7,
  5223. 21
  5224. ],
  5225. [
  5226. 7,
  5227. 21
  5228. ],
  5229. [
  5230. 7,
  5231. 28
  5232. ],
  5233. [
  5234. 7,
  5235. 28
  5236. ],
  5237. [
  5238. 7,
  5239. 28
  5240. ],
  5241. [
  5242. 7,
  5243. 28
  5244. ],
  5245. [
  5246. 8,
  5247. 61
  5248. ],
  5249. [
  5250. 8,
  5251. 61
  5252. ],
  5253. [
  5254. 8,
  5255. 62
  5256. ],
  5257. [
  5258. 8,
  5259. 62
  5260. ],
  5261. [
  5262. 8,
  5263. 63
  5264. ],
  5265. [
  5266. 8,
  5267. 63
  5268. ],
  5269. [
  5270. 8,
  5271. 0
  5272. ],
  5273. [
  5274. 8,
  5275. 0
  5276. ],
  5277. [
  5278. 8,
  5279. 320
  5280. ],
  5281. [
  5282. 8,
  5283. 320
  5284. ],
  5285. [
  5286. 8,
  5287. 384
  5288. ],
  5289. [
  5290. 8,
  5291. 384
  5292. ],
  5293. [
  5294. 5,
  5295. 10
  5296. ],
  5297. [
  5298. 5,
  5299. 10
  5300. ],
  5301. [
  5302. 5,
  5303. 10
  5304. ],
  5305. [
  5306. 5,
  5307. 10
  5308. ],
  5309. [
  5310. 5,
  5311. 10
  5312. ],
  5313. [
  5314. 5,
  5315. 10
  5316. ],
  5317. [
  5318. 5,
  5319. 10
  5320. ],
  5321. [
  5322. 5,
  5323. 10
  5324. ],
  5325. [
  5326. 5,
  5327. 10
  5328. ],
  5329. [
  5330. 5,
  5331. 10
  5332. ],
  5333. [
  5334. 5,
  5335. 10
  5336. ],
  5337. [
  5338. 5,
  5339. 10
  5340. ],
  5341. [
  5342. 5,
  5343. 10
  5344. ],
  5345. [
  5346. 5,
  5347. 10
  5348. ],
  5349. [
  5350. 5,
  5351. 10
  5352. ],
  5353. [
  5354. 5,
  5355. 10
  5356. ],
  5357. [
  5358. 5,
  5359. 11
  5360. ],
  5361. [
  5362. 5,
  5363. 11
  5364. ],
  5365. [
  5366. 5,
  5367. 11
  5368. ],
  5369. [
  5370. 5,
  5371. 11
  5372. ],
  5373. [
  5374. 5,
  5375. 11
  5376. ],
  5377. [
  5378. 5,
  5379. 11
  5380. ],
  5381. [
  5382. 5,
  5383. 11
  5384. ],
  5385. [
  5386. 5,
  5387. 11
  5388. ],
  5389. [
  5390. 5,
  5391. 11
  5392. ],
  5393. [
  5394. 5,
  5395. 11
  5396. ],
  5397. [
  5398. 5,
  5399. 11
  5400. ],
  5401. [
  5402. 5,
  5403. 11
  5404. ],
  5405. [
  5406. 5,
  5407. 11
  5408. ],
  5409. [
  5410. 5,
  5411. 11
  5412. ],
  5413. [
  5414. 5,
  5415. 11
  5416. ],
  5417. [
  5418. 5,
  5419. 11
  5420. ],
  5421. [
  5422. 7,
  5423. 27
  5424. ],
  5425. [
  5426. 7,
  5427. 27
  5428. ],
  5429. [
  5430. 7,
  5431. 27
  5432. ],
  5433. [
  5434. 7,
  5435. 27
  5436. ],
  5437. [
  5438. 8,
  5439. 59
  5440. ],
  5441. [
  5442. 8,
  5443. 59
  5444. ],
  5445. [
  5446. 8,
  5447. 60
  5448. ],
  5449. [
  5450. 8,
  5451. 60
  5452. ],
  5453. [
  5454. 9,
  5455. 1472
  5456. ],
  5457. [
  5458. 9,
  5459. 1536
  5460. ],
  5461. [
  5462. 9,
  5463. 1600
  5464. ],
  5465. [
  5466. 9,
  5467. 1728
  5468. ],
  5469. [
  5470. 7,
  5471. 18
  5472. ],
  5473. [
  5474. 7,
  5475. 18
  5476. ],
  5477. [
  5478. 7,
  5479. 18
  5480. ],
  5481. [
  5482. 7,
  5483. 18
  5484. ],
  5485. [
  5486. 7,
  5487. 24
  5488. ],
  5489. [
  5490. 7,
  5491. 24
  5492. ],
  5493. [
  5494. 7,
  5495. 24
  5496. ],
  5497. [
  5498. 7,
  5499. 24
  5500. ],
  5501. [
  5502. 8,
  5503. 49
  5504. ],
  5505. [
  5506. 8,
  5507. 49
  5508. ],
  5509. [
  5510. 8,
  5511. 50
  5512. ],
  5513. [
  5514. 8,
  5515. 50
  5516. ],
  5517. [
  5518. 8,
  5519. 51
  5520. ],
  5521. [
  5522. 8,
  5523. 51
  5524. ],
  5525. [
  5526. 8,
  5527. 52
  5528. ],
  5529. [
  5530. 8,
  5531. 52
  5532. ],
  5533. [
  5534. 7,
  5535. 25
  5536. ],
  5537. [
  5538. 7,
  5539. 25
  5540. ],
  5541. [
  5542. 7,
  5543. 25
  5544. ],
  5545. [
  5546. 7,
  5547. 25
  5548. ],
  5549. [
  5550. 8,
  5551. 55
  5552. ],
  5553. [
  5554. 8,
  5555. 55
  5556. ],
  5557. [
  5558. 8,
  5559. 56
  5560. ],
  5561. [
  5562. 8,
  5563. 56
  5564. ],
  5565. [
  5566. 8,
  5567. 57
  5568. ],
  5569. [
  5570. 8,
  5571. 57
  5572. ],
  5573. [
  5574. 8,
  5575. 58
  5576. ],
  5577. [
  5578. 8,
  5579. 58
  5580. ],
  5581. [
  5582. 6,
  5583. 192
  5584. ],
  5585. [
  5586. 6,
  5587. 192
  5588. ],
  5589. [
  5590. 6,
  5591. 192
  5592. ],
  5593. [
  5594. 6,
  5595. 192
  5596. ],
  5597. [
  5598. 6,
  5599. 192
  5600. ],
  5601. [
  5602. 6,
  5603. 192
  5604. ],
  5605. [
  5606. 6,
  5607. 192
  5608. ],
  5609. [
  5610. 6,
  5611. 192
  5612. ],
  5613. [
  5614. 6,
  5615. 1664
  5616. ],
  5617. [
  5618. 6,
  5619. 1664
  5620. ],
  5621. [
  5622. 6,
  5623. 1664
  5624. ],
  5625. [
  5626. 6,
  5627. 1664
  5628. ],
  5629. [
  5630. 6,
  5631. 1664
  5632. ],
  5633. [
  5634. 6,
  5635. 1664
  5636. ],
  5637. [
  5638. 6,
  5639. 1664
  5640. ],
  5641. [
  5642. 6,
  5643. 1664
  5644. ],
  5645. [
  5646. 8,
  5647. 448
  5648. ],
  5649. [
  5650. 8,
  5651. 448
  5652. ],
  5653. [
  5654. 8,
  5655. 512
  5656. ],
  5657. [
  5658. 8,
  5659. 512
  5660. ],
  5661. [
  5662. 9,
  5663. 704
  5664. ],
  5665. [
  5666. 9,
  5667. 768
  5668. ],
  5669. [
  5670. 8,
  5671. 640
  5672. ],
  5673. [
  5674. 8,
  5675. 640
  5676. ],
  5677. [
  5678. 8,
  5679. 576
  5680. ],
  5681. [
  5682. 8,
  5683. 576
  5684. ],
  5685. [
  5686. 9,
  5687. 832
  5688. ],
  5689. [
  5690. 9,
  5691. 896
  5692. ],
  5693. [
  5694. 9,
  5695. 960
  5696. ],
  5697. [
  5698. 9,
  5699. 1024
  5700. ],
  5701. [
  5702. 9,
  5703. 1088
  5704. ],
  5705. [
  5706. 9,
  5707. 1152
  5708. ],
  5709. [
  5710. 9,
  5711. 1216
  5712. ],
  5713. [
  5714. 9,
  5715. 1280
  5716. ],
  5717. [
  5718. 9,
  5719. 1344
  5720. ],
  5721. [
  5722. 9,
  5723. 1408
  5724. ],
  5725. [
  5726. 7,
  5727. 256
  5728. ],
  5729. [
  5730. 7,
  5731. 256
  5732. ],
  5733. [
  5734. 7,
  5735. 256
  5736. ],
  5737. [
  5738. 7,
  5739. 256
  5740. ],
  5741. [
  5742. 4,
  5743. 2
  5744. ],
  5745. [
  5746. 4,
  5747. 2
  5748. ],
  5749. [
  5750. 4,
  5751. 2
  5752. ],
  5753. [
  5754. 4,
  5755. 2
  5756. ],
  5757. [
  5758. 4,
  5759. 2
  5760. ],
  5761. [
  5762. 4,
  5763. 2
  5764. ],
  5765. [
  5766. 4,
  5767. 2
  5768. ],
  5769. [
  5770. 4,
  5771. 2
  5772. ],
  5773. [
  5774. 4,
  5775. 2
  5776. ],
  5777. [
  5778. 4,
  5779. 2
  5780. ],
  5781. [
  5782. 4,
  5783. 2
  5784. ],
  5785. [
  5786. 4,
  5787. 2
  5788. ],
  5789. [
  5790. 4,
  5791. 2
  5792. ],
  5793. [
  5794. 4,
  5795. 2
  5796. ],
  5797. [
  5798. 4,
  5799. 2
  5800. ],
  5801. [
  5802. 4,
  5803. 2
  5804. ],
  5805. [
  5806. 4,
  5807. 2
  5808. ],
  5809. [
  5810. 4,
  5811. 2
  5812. ],
  5813. [
  5814. 4,
  5815. 2
  5816. ],
  5817. [
  5818. 4,
  5819. 2
  5820. ],
  5821. [
  5822. 4,
  5823. 2
  5824. ],
  5825. [
  5826. 4,
  5827. 2
  5828. ],
  5829. [
  5830. 4,
  5831. 2
  5832. ],
  5833. [
  5834. 4,
  5835. 2
  5836. ],
  5837. [
  5838. 4,
  5839. 2
  5840. ],
  5841. [
  5842. 4,
  5843. 2
  5844. ],
  5845. [
  5846. 4,
  5847. 2
  5848. ],
  5849. [
  5850. 4,
  5851. 2
  5852. ],
  5853. [
  5854. 4,
  5855. 2
  5856. ],
  5857. [
  5858. 4,
  5859. 2
  5860. ],
  5861. [
  5862. 4,
  5863. 2
  5864. ],
  5865. [
  5866. 4,
  5867. 2
  5868. ],
  5869. [
  5870. 4,
  5871. 3
  5872. ],
  5873. [
  5874. 4,
  5875. 3
  5876. ],
  5877. [
  5878. 4,
  5879. 3
  5880. ],
  5881. [
  5882. 4,
  5883. 3
  5884. ],
  5885. [
  5886. 4,
  5887. 3
  5888. ],
  5889. [
  5890. 4,
  5891. 3
  5892. ],
  5893. [
  5894. 4,
  5895. 3
  5896. ],
  5897. [
  5898. 4,
  5899. 3
  5900. ],
  5901. [
  5902. 4,
  5903. 3
  5904. ],
  5905. [
  5906. 4,
  5907. 3
  5908. ],
  5909. [
  5910. 4,
  5911. 3
  5912. ],
  5913. [
  5914. 4,
  5915. 3
  5916. ],
  5917. [
  5918. 4,
  5919. 3
  5920. ],
  5921. [
  5922. 4,
  5923. 3
  5924. ],
  5925. [
  5926. 4,
  5927. 3
  5928. ],
  5929. [
  5930. 4,
  5931. 3
  5932. ],
  5933. [
  5934. 4,
  5935. 3
  5936. ],
  5937. [
  5938. 4,
  5939. 3
  5940. ],
  5941. [
  5942. 4,
  5943. 3
  5944. ],
  5945. [
  5946. 4,
  5947. 3
  5948. ],
  5949. [
  5950. 4,
  5951. 3
  5952. ],
  5953. [
  5954. 4,
  5955. 3
  5956. ],
  5957. [
  5958. 4,
  5959. 3
  5960. ],
  5961. [
  5962. 4,
  5963. 3
  5964. ],
  5965. [
  5966. 4,
  5967. 3
  5968. ],
  5969. [
  5970. 4,
  5971. 3
  5972. ],
  5973. [
  5974. 4,
  5975. 3
  5976. ],
  5977. [
  5978. 4,
  5979. 3
  5980. ],
  5981. [
  5982. 4,
  5983. 3
  5984. ],
  5985. [
  5986. 4,
  5987. 3
  5988. ],
  5989. [
  5990. 4,
  5991. 3
  5992. ],
  5993. [
  5994. 4,
  5995. 3
  5996. ],
  5997. [
  5998. 5,
  5999. 128
  6000. ],
  6001. [
  6002. 5,
  6003. 128
  6004. ],
  6005. [
  6006. 5,
  6007. 128
  6008. ],
  6009. [
  6010. 5,
  6011. 128
  6012. ],
  6013. [
  6014. 5,
  6015. 128
  6016. ],
  6017. [
  6018. 5,
  6019. 128
  6020. ],
  6021. [
  6022. 5,
  6023. 128
  6024. ],
  6025. [
  6026. 5,
  6027. 128
  6028. ],
  6029. [
  6030. 5,
  6031. 128
  6032. ],
  6033. [
  6034. 5,
  6035. 128
  6036. ],
  6037. [
  6038. 5,
  6039. 128
  6040. ],
  6041. [
  6042. 5,
  6043. 128
  6044. ],
  6045. [
  6046. 5,
  6047. 128
  6048. ],
  6049. [
  6050. 5,
  6051. 128
  6052. ],
  6053. [
  6054. 5,
  6055. 128
  6056. ],
  6057. [
  6058. 5,
  6059. 128
  6060. ],
  6061. [
  6062. 5,
  6063. 8
  6064. ],
  6065. [
  6066. 5,
  6067. 8
  6068. ],
  6069. [
  6070. 5,
  6071. 8
  6072. ],
  6073. [
  6074. 5,
  6075. 8
  6076. ],
  6077. [
  6078. 5,
  6079. 8
  6080. ],
  6081. [
  6082. 5,
  6083. 8
  6084. ],
  6085. [
  6086. 5,
  6087. 8
  6088. ],
  6089. [
  6090. 5,
  6091. 8
  6092. ],
  6093. [
  6094. 5,
  6095. 8
  6096. ],
  6097. [
  6098. 5,
  6099. 8
  6100. ],
  6101. [
  6102. 5,
  6103. 8
  6104. ],
  6105. [
  6106. 5,
  6107. 8
  6108. ],
  6109. [
  6110. 5,
  6111. 8
  6112. ],
  6113. [
  6114. 5,
  6115. 8
  6116. ],
  6117. [
  6118. 5,
  6119. 8
  6120. ],
  6121. [
  6122. 5,
  6123. 8
  6124. ],
  6125. [
  6126. 5,
  6127. 9
  6128. ],
  6129. [
  6130. 5,
  6131. 9
  6132. ],
  6133. [
  6134. 5,
  6135. 9
  6136. ],
  6137. [
  6138. 5,
  6139. 9
  6140. ],
  6141. [
  6142. 5,
  6143. 9
  6144. ],
  6145. [
  6146. 5,
  6147. 9
  6148. ],
  6149. [
  6150. 5,
  6151. 9
  6152. ],
  6153. [
  6154. 5,
  6155. 9
  6156. ],
  6157. [
  6158. 5,
  6159. 9
  6160. ],
  6161. [
  6162. 5,
  6163. 9
  6164. ],
  6165. [
  6166. 5,
  6167. 9
  6168. ],
  6169. [
  6170. 5,
  6171. 9
  6172. ],
  6173. [
  6174. 5,
  6175. 9
  6176. ],
  6177. [
  6178. 5,
  6179. 9
  6180. ],
  6181. [
  6182. 5,
  6183. 9
  6184. ],
  6185. [
  6186. 5,
  6187. 9
  6188. ],
  6189. [
  6190. 6,
  6191. 16
  6192. ],
  6193. [
  6194. 6,
  6195. 16
  6196. ],
  6197. [
  6198. 6,
  6199. 16
  6200. ],
  6201. [
  6202. 6,
  6203. 16
  6204. ],
  6205. [
  6206. 6,
  6207. 16
  6208. ],
  6209. [
  6210. 6,
  6211. 16
  6212. ],
  6213. [
  6214. 6,
  6215. 16
  6216. ],
  6217. [
  6218. 6,
  6219. 16
  6220. ],
  6221. [
  6222. 6,
  6223. 17
  6224. ],
  6225. [
  6226. 6,
  6227. 17
  6228. ],
  6229. [
  6230. 6,
  6231. 17
  6232. ],
  6233. [
  6234. 6,
  6235. 17
  6236. ],
  6237. [
  6238. 6,
  6239. 17
  6240. ],
  6241. [
  6242. 6,
  6243. 17
  6244. ],
  6245. [
  6246. 6,
  6247. 17
  6248. ],
  6249. [
  6250. 6,
  6251. 17
  6252. ],
  6253. [
  6254. 4,
  6255. 4
  6256. ],
  6257. [
  6258. 4,
  6259. 4
  6260. ],
  6261. [
  6262. 4,
  6263. 4
  6264. ],
  6265. [
  6266. 4,
  6267. 4
  6268. ],
  6269. [
  6270. 4,
  6271. 4
  6272. ],
  6273. [
  6274. 4,
  6275. 4
  6276. ],
  6277. [
  6278. 4,
  6279. 4
  6280. ],
  6281. [
  6282. 4,
  6283. 4
  6284. ],
  6285. [
  6286. 4,
  6287. 4
  6288. ],
  6289. [
  6290. 4,
  6291. 4
  6292. ],
  6293. [
  6294. 4,
  6295. 4
  6296. ],
  6297. [
  6298. 4,
  6299. 4
  6300. ],
  6301. [
  6302. 4,
  6303. 4
  6304. ],
  6305. [
  6306. 4,
  6307. 4
  6308. ],
  6309. [
  6310. 4,
  6311. 4
  6312. ],
  6313. [
  6314. 4,
  6315. 4
  6316. ],
  6317. [
  6318. 4,
  6319. 4
  6320. ],
  6321. [
  6322. 4,
  6323. 4
  6324. ],
  6325. [
  6326. 4,
  6327. 4
  6328. ],
  6329. [
  6330. 4,
  6331. 4
  6332. ],
  6333. [
  6334. 4,
  6335. 4
  6336. ],
  6337. [
  6338. 4,
  6339. 4
  6340. ],
  6341. [
  6342. 4,
  6343. 4
  6344. ],
  6345. [
  6346. 4,
  6347. 4
  6348. ],
  6349. [
  6350. 4,
  6351. 4
  6352. ],
  6353. [
  6354. 4,
  6355. 4
  6356. ],
  6357. [
  6358. 4,
  6359. 4
  6360. ],
  6361. [
  6362. 4,
  6363. 4
  6364. ],
  6365. [
  6366. 4,
  6367. 4
  6368. ],
  6369. [
  6370. 4,
  6371. 4
  6372. ],
  6373. [
  6374. 4,
  6375. 4
  6376. ],
  6377. [
  6378. 4,
  6379. 4
  6380. ],
  6381. [
  6382. 4,
  6383. 5
  6384. ],
  6385. [
  6386. 4,
  6387. 5
  6388. ],
  6389. [
  6390. 4,
  6391. 5
  6392. ],
  6393. [
  6394. 4,
  6395. 5
  6396. ],
  6397. [
  6398. 4,
  6399. 5
  6400. ],
  6401. [
  6402. 4,
  6403. 5
  6404. ],
  6405. [
  6406. 4,
  6407. 5
  6408. ],
  6409. [
  6410. 4,
  6411. 5
  6412. ],
  6413. [
  6414. 4,
  6415. 5
  6416. ],
  6417. [
  6418. 4,
  6419. 5
  6420. ],
  6421. [
  6422. 4,
  6423. 5
  6424. ],
  6425. [
  6426. 4,
  6427. 5
  6428. ],
  6429. [
  6430. 4,
  6431. 5
  6432. ],
  6433. [
  6434. 4,
  6435. 5
  6436. ],
  6437. [
  6438. 4,
  6439. 5
  6440. ],
  6441. [
  6442. 4,
  6443. 5
  6444. ],
  6445. [
  6446. 4,
  6447. 5
  6448. ],
  6449. [
  6450. 4,
  6451. 5
  6452. ],
  6453. [
  6454. 4,
  6455. 5
  6456. ],
  6457. [
  6458. 4,
  6459. 5
  6460. ],
  6461. [
  6462. 4,
  6463. 5
  6464. ],
  6465. [
  6466. 4,
  6467. 5
  6468. ],
  6469. [
  6470. 4,
  6471. 5
  6472. ],
  6473. [
  6474. 4,
  6475. 5
  6476. ],
  6477. [
  6478. 4,
  6479. 5
  6480. ],
  6481. [
  6482. 4,
  6483. 5
  6484. ],
  6485. [
  6486. 4,
  6487. 5
  6488. ],
  6489. [
  6490. 4,
  6491. 5
  6492. ],
  6493. [
  6494. 4,
  6495. 5
  6496. ],
  6497. [
  6498. 4,
  6499. 5
  6500. ],
  6501. [
  6502. 4,
  6503. 5
  6504. ],
  6505. [
  6506. 4,
  6507. 5
  6508. ],
  6509. [
  6510. 6,
  6511. 14
  6512. ],
  6513. [
  6514. 6,
  6515. 14
  6516. ],
  6517. [
  6518. 6,
  6519. 14
  6520. ],
  6521. [
  6522. 6,
  6523. 14
  6524. ],
  6525. [
  6526. 6,
  6527. 14
  6528. ],
  6529. [
  6530. 6,
  6531. 14
  6532. ],
  6533. [
  6534. 6,
  6535. 14
  6536. ],
  6537. [
  6538. 6,
  6539. 14
  6540. ],
  6541. [
  6542. 6,
  6543. 15
  6544. ],
  6545. [
  6546. 6,
  6547. 15
  6548. ],
  6549. [
  6550. 6,
  6551. 15
  6552. ],
  6553. [
  6554. 6,
  6555. 15
  6556. ],
  6557. [
  6558. 6,
  6559. 15
  6560. ],
  6561. [
  6562. 6,
  6563. 15
  6564. ],
  6565. [
  6566. 6,
  6567. 15
  6568. ],
  6569. [
  6570. 6,
  6571. 15
  6572. ],
  6573. [
  6574. 5,
  6575. 64
  6576. ],
  6577. [
  6578. 5,
  6579. 64
  6580. ],
  6581. [
  6582. 5,
  6583. 64
  6584. ],
  6585. [
  6586. 5,
  6587. 64
  6588. ],
  6589. [
  6590. 5,
  6591. 64
  6592. ],
  6593. [
  6594. 5,
  6595. 64
  6596. ],
  6597. [
  6598. 5,
  6599. 64
  6600. ],
  6601. [
  6602. 5,
  6603. 64
  6604. ],
  6605. [
  6606. 5,
  6607. 64
  6608. ],
  6609. [
  6610. 5,
  6611. 64
  6612. ],
  6613. [
  6614. 5,
  6615. 64
  6616. ],
  6617. [
  6618. 5,
  6619. 64
  6620. ],
  6621. [
  6622. 5,
  6623. 64
  6624. ],
  6625. [
  6626. 5,
  6627. 64
  6628. ],
  6629. [
  6630. 5,
  6631. 64
  6632. ],
  6633. [
  6634. 5,
  6635. 64
  6636. ],
  6637. [
  6638. 4,
  6639. 6
  6640. ],
  6641. [
  6642. 4,
  6643. 6
  6644. ],
  6645. [
  6646. 4,
  6647. 6
  6648. ],
  6649. [
  6650. 4,
  6651. 6
  6652. ],
  6653. [
  6654. 4,
  6655. 6
  6656. ],
  6657. [
  6658. 4,
  6659. 6
  6660. ],
  6661. [
  6662. 4,
  6663. 6
  6664. ],
  6665. [
  6666. 4,
  6667. 6
  6668. ],
  6669. [
  6670. 4,
  6671. 6
  6672. ],
  6673. [
  6674. 4,
  6675. 6
  6676. ],
  6677. [
  6678. 4,
  6679. 6
  6680. ],
  6681. [
  6682. 4,
  6683. 6
  6684. ],
  6685. [
  6686. 4,
  6687. 6
  6688. ],
  6689. [
  6690. 4,
  6691. 6
  6692. ],
  6693. [
  6694. 4,
  6695. 6
  6696. ],
  6697. [
  6698. 4,
  6699. 6
  6700. ],
  6701. [
  6702. 4,
  6703. 6
  6704. ],
  6705. [
  6706. 4,
  6707. 6
  6708. ],
  6709. [
  6710. 4,
  6711. 6
  6712. ],
  6713. [
  6714. 4,
  6715. 6
  6716. ],
  6717. [
  6718. 4,
  6719. 6
  6720. ],
  6721. [
  6722. 4,
  6723. 6
  6724. ],
  6725. [
  6726. 4,
  6727. 6
  6728. ],
  6729. [
  6730. 4,
  6731. 6
  6732. ],
  6733. [
  6734. 4,
  6735. 6
  6736. ],
  6737. [
  6738. 4,
  6739. 6
  6740. ],
  6741. [
  6742. 4,
  6743. 6
  6744. ],
  6745. [
  6746. 4,
  6747. 6
  6748. ],
  6749. [
  6750. 4,
  6751. 6
  6752. ],
  6753. [
  6754. 4,
  6755. 6
  6756. ],
  6757. [
  6758. 4,
  6759. 6
  6760. ],
  6761. [
  6762. 4,
  6763. 6
  6764. ],
  6765. [
  6766. 4,
  6767. 7
  6768. ],
  6769. [
  6770. 4,
  6771. 7
  6772. ],
  6773. [
  6774. 4,
  6775. 7
  6776. ],
  6777. [
  6778. 4,
  6779. 7
  6780. ],
  6781. [
  6782. 4,
  6783. 7
  6784. ],
  6785. [
  6786. 4,
  6787. 7
  6788. ],
  6789. [
  6790. 4,
  6791. 7
  6792. ],
  6793. [
  6794. 4,
  6795. 7
  6796. ],
  6797. [
  6798. 4,
  6799. 7
  6800. ],
  6801. [
  6802. 4,
  6803. 7
  6804. ],
  6805. [
  6806. 4,
  6807. 7
  6808. ],
  6809. [
  6810. 4,
  6811. 7
  6812. ],
  6813. [
  6814. 4,
  6815. 7
  6816. ],
  6817. [
  6818. 4,
  6819. 7
  6820. ],
  6821. [
  6822. 4,
  6823. 7
  6824. ],
  6825. [
  6826. 4,
  6827. 7
  6828. ],
  6829. [
  6830. 4,
  6831. 7
  6832. ],
  6833. [
  6834. 4,
  6835. 7
  6836. ],
  6837. [
  6838. 4,
  6839. 7
  6840. ],
  6841. [
  6842. 4,
  6843. 7
  6844. ],
  6845. [
  6846. 4,
  6847. 7
  6848. ],
  6849. [
  6850. 4,
  6851. 7
  6852. ],
  6853. [
  6854. 4,
  6855. 7
  6856. ],
  6857. [
  6858. 4,
  6859. 7
  6860. ],
  6861. [
  6862. 4,
  6863. 7
  6864. ],
  6865. [
  6866. 4,
  6867. 7
  6868. ],
  6869. [
  6870. 4,
  6871. 7
  6872. ],
  6873. [
  6874. 4,
  6875. 7
  6876. ],
  6877. [
  6878. 4,
  6879. 7
  6880. ],
  6881. [
  6882. 4,
  6883. 7
  6884. ],
  6885. [
  6886. 4,
  6887. 7
  6888. ],
  6889. [
  6890. 4,
  6891. 7
  6892. ]
  6893. ];
  6894. var blackTable1 = [
  6895. [
  6896. -1,
  6897. -1
  6898. ],
  6899. [
  6900. -1,
  6901. -1
  6902. ],
  6903. [
  6904. 12,
  6905. ccittEOL
  6906. ],
  6907. [
  6908. 12,
  6909. ccittEOL
  6910. ],
  6911. [
  6912. -1,
  6913. -1
  6914. ],
  6915. [
  6916. -1,
  6917. -1
  6918. ],
  6919. [
  6920. -1,
  6921. -1
  6922. ],
  6923. [
  6924. -1,
  6925. -1
  6926. ],
  6927. [
  6928. -1,
  6929. -1
  6930. ],
  6931. [
  6932. -1,
  6933. -1
  6934. ],
  6935. [
  6936. -1,
  6937. -1
  6938. ],
  6939. [
  6940. -1,
  6941. -1
  6942. ],
  6943. [
  6944. -1,
  6945. -1
  6946. ],
  6947. [
  6948. -1,
  6949. -1
  6950. ],
  6951. [
  6952. -1,
  6953. -1
  6954. ],
  6955. [
  6956. -1,
  6957. -1
  6958. ],
  6959. [
  6960. -1,
  6961. -1
  6962. ],
  6963. [
  6964. -1,
  6965. -1
  6966. ],
  6967. [
  6968. -1,
  6969. -1
  6970. ],
  6971. [
  6972. -1,
  6973. -1
  6974. ],
  6975. [
  6976. -1,
  6977. -1
  6978. ],
  6979. [
  6980. -1,
  6981. -1
  6982. ],
  6983. [
  6984. -1,
  6985. -1
  6986. ],
  6987. [
  6988. -1,
  6989. -1
  6990. ],
  6991. [
  6992. -1,
  6993. -1
  6994. ],
  6995. [
  6996. -1,
  6997. -1
  6998. ],
  6999. [
  7000. -1,
  7001. -1
  7002. ],
  7003. [
  7004. -1,
  7005. -1
  7006. ],
  7007. [
  7008. -1,
  7009. -1
  7010. ],
  7011. [
  7012. -1,
  7013. -1
  7014. ],
  7015. [
  7016. -1,
  7017. -1
  7018. ],
  7019. [
  7020. -1,
  7021. -1
  7022. ],
  7023. [
  7024. 11,
  7025. 1792
  7026. ],
  7027. [
  7028. 11,
  7029. 1792
  7030. ],
  7031. [
  7032. 11,
  7033. 1792
  7034. ],
  7035. [
  7036. 11,
  7037. 1792
  7038. ],
  7039. [
  7040. 12,
  7041. 1984
  7042. ],
  7043. [
  7044. 12,
  7045. 1984
  7046. ],
  7047. [
  7048. 12,
  7049. 2048
  7050. ],
  7051. [
  7052. 12,
  7053. 2048
  7054. ],
  7055. [
  7056. 12,
  7057. 2112
  7058. ],
  7059. [
  7060. 12,
  7061. 2112
  7062. ],
  7063. [
  7064. 12,
  7065. 2176
  7066. ],
  7067. [
  7068. 12,
  7069. 2176
  7070. ],
  7071. [
  7072. 12,
  7073. 2240
  7074. ],
  7075. [
  7076. 12,
  7077. 2240
  7078. ],
  7079. [
  7080. 12,
  7081. 2304
  7082. ],
  7083. [
  7084. 12,
  7085. 2304
  7086. ],
  7087. [
  7088. 11,
  7089. 1856
  7090. ],
  7091. [
  7092. 11,
  7093. 1856
  7094. ],
  7095. [
  7096. 11,
  7097. 1856
  7098. ],
  7099. [
  7100. 11,
  7101. 1856
  7102. ],
  7103. [
  7104. 11,
  7105. 1920
  7106. ],
  7107. [
  7108. 11,
  7109. 1920
  7110. ],
  7111. [
  7112. 11,
  7113. 1920
  7114. ],
  7115. [
  7116. 11,
  7117. 1920
  7118. ],
  7119. [
  7120. 12,
  7121. 2368
  7122. ],
  7123. [
  7124. 12,
  7125. 2368
  7126. ],
  7127. [
  7128. 12,
  7129. 2432
  7130. ],
  7131. [
  7132. 12,
  7133. 2432
  7134. ],
  7135. [
  7136. 12,
  7137. 2496
  7138. ],
  7139. [
  7140. 12,
  7141. 2496
  7142. ],
  7143. [
  7144. 12,
  7145. 2560
  7146. ],
  7147. [
  7148. 12,
  7149. 2560
  7150. ],
  7151. [
  7152. 10,
  7153. 18
  7154. ],
  7155. [
  7156. 10,
  7157. 18
  7158. ],
  7159. [
  7160. 10,
  7161. 18
  7162. ],
  7163. [
  7164. 10,
  7165. 18
  7166. ],
  7167. [
  7168. 10,
  7169. 18
  7170. ],
  7171. [
  7172. 10,
  7173. 18
  7174. ],
  7175. [
  7176. 10,
  7177. 18
  7178. ],
  7179. [
  7180. 10,
  7181. 18
  7182. ],
  7183. [
  7184. 12,
  7185. 52
  7186. ],
  7187. [
  7188. 12,
  7189. 52
  7190. ],
  7191. [
  7192. 13,
  7193. 640
  7194. ],
  7195. [
  7196. 13,
  7197. 704
  7198. ],
  7199. [
  7200. 13,
  7201. 768
  7202. ],
  7203. [
  7204. 13,
  7205. 832
  7206. ],
  7207. [
  7208. 12,
  7209. 55
  7210. ],
  7211. [
  7212. 12,
  7213. 55
  7214. ],
  7215. [
  7216. 12,
  7217. 56
  7218. ],
  7219. [
  7220. 12,
  7221. 56
  7222. ],
  7223. [
  7224. 13,
  7225. 1280
  7226. ],
  7227. [
  7228. 13,
  7229. 1344
  7230. ],
  7231. [
  7232. 13,
  7233. 1408
  7234. ],
  7235. [
  7236. 13,
  7237. 1472
  7238. ],
  7239. [
  7240. 12,
  7241. 59
  7242. ],
  7243. [
  7244. 12,
  7245. 59
  7246. ],
  7247. [
  7248. 12,
  7249. 60
  7250. ],
  7251. [
  7252. 12,
  7253. 60
  7254. ],
  7255. [
  7256. 13,
  7257. 1536
  7258. ],
  7259. [
  7260. 13,
  7261. 1600
  7262. ],
  7263. [
  7264. 11,
  7265. 24
  7266. ],
  7267. [
  7268. 11,
  7269. 24
  7270. ],
  7271. [
  7272. 11,
  7273. 24
  7274. ],
  7275. [
  7276. 11,
  7277. 24
  7278. ],
  7279. [
  7280. 11,
  7281. 25
  7282. ],
  7283. [
  7284. 11,
  7285. 25
  7286. ],
  7287. [
  7288. 11,
  7289. 25
  7290. ],
  7291. [
  7292. 11,
  7293. 25
  7294. ],
  7295. [
  7296. 13,
  7297. 1664
  7298. ],
  7299. [
  7300. 13,
  7301. 1728
  7302. ],
  7303. [
  7304. 12,
  7305. 320
  7306. ],
  7307. [
  7308. 12,
  7309. 320
  7310. ],
  7311. [
  7312. 12,
  7313. 384
  7314. ],
  7315. [
  7316. 12,
  7317. 384
  7318. ],
  7319. [
  7320. 12,
  7321. 448
  7322. ],
  7323. [
  7324. 12,
  7325. 448
  7326. ],
  7327. [
  7328. 13,
  7329. 512
  7330. ],
  7331. [
  7332. 13,
  7333. 576
  7334. ],
  7335. [
  7336. 12,
  7337. 53
  7338. ],
  7339. [
  7340. 12,
  7341. 53
  7342. ],
  7343. [
  7344. 12,
  7345. 54
  7346. ],
  7347. [
  7348. 12,
  7349. 54
  7350. ],
  7351. [
  7352. 13,
  7353. 896
  7354. ],
  7355. [
  7356. 13,
  7357. 960
  7358. ],
  7359. [
  7360. 13,
  7361. 1024
  7362. ],
  7363. [
  7364. 13,
  7365. 1088
  7366. ],
  7367. [
  7368. 13,
  7369. 1152
  7370. ],
  7371. [
  7372. 13,
  7373. 1216
  7374. ],
  7375. [
  7376. 10,
  7377. 64
  7378. ],
  7379. [
  7380. 10,
  7381. 64
  7382. ],
  7383. [
  7384. 10,
  7385. 64
  7386. ],
  7387. [
  7388. 10,
  7389. 64
  7390. ],
  7391. [
  7392. 10,
  7393. 64
  7394. ],
  7395. [
  7396. 10,
  7397. 64
  7398. ],
  7399. [
  7400. 10,
  7401. 64
  7402. ],
  7403. [
  7404. 10,
  7405. 64
  7406. ]
  7407. ];
  7408. var blackTable2 = [
  7409. [
  7410. 8,
  7411. 13
  7412. ],
  7413. [
  7414. 8,
  7415. 13
  7416. ],
  7417. [
  7418. 8,
  7419. 13
  7420. ],
  7421. [
  7422. 8,
  7423. 13
  7424. ],
  7425. [
  7426. 8,
  7427. 13
  7428. ],
  7429. [
  7430. 8,
  7431. 13
  7432. ],
  7433. [
  7434. 8,
  7435. 13
  7436. ],
  7437. [
  7438. 8,
  7439. 13
  7440. ],
  7441. [
  7442. 8,
  7443. 13
  7444. ],
  7445. [
  7446. 8,
  7447. 13
  7448. ],
  7449. [
  7450. 8,
  7451. 13
  7452. ],
  7453. [
  7454. 8,
  7455. 13
  7456. ],
  7457. [
  7458. 8,
  7459. 13
  7460. ],
  7461. [
  7462. 8,
  7463. 13
  7464. ],
  7465. [
  7466. 8,
  7467. 13
  7468. ],
  7469. [
  7470. 8,
  7471. 13
  7472. ],
  7473. [
  7474. 11,
  7475. 23
  7476. ],
  7477. [
  7478. 11,
  7479. 23
  7480. ],
  7481. [
  7482. 12,
  7483. 50
  7484. ],
  7485. [
  7486. 12,
  7487. 51
  7488. ],
  7489. [
  7490. 12,
  7491. 44
  7492. ],
  7493. [
  7494. 12,
  7495. 45
  7496. ],
  7497. [
  7498. 12,
  7499. 46
  7500. ],
  7501. [
  7502. 12,
  7503. 47
  7504. ],
  7505. [
  7506. 12,
  7507. 57
  7508. ],
  7509. [
  7510. 12,
  7511. 58
  7512. ],
  7513. [
  7514. 12,
  7515. 61
  7516. ],
  7517. [
  7518. 12,
  7519. 256
  7520. ],
  7521. [
  7522. 10,
  7523. 16
  7524. ],
  7525. [
  7526. 10,
  7527. 16
  7528. ],
  7529. [
  7530. 10,
  7531. 16
  7532. ],
  7533. [
  7534. 10,
  7535. 16
  7536. ],
  7537. [
  7538. 10,
  7539. 17
  7540. ],
  7541. [
  7542. 10,
  7543. 17
  7544. ],
  7545. [
  7546. 10,
  7547. 17
  7548. ],
  7549. [
  7550. 10,
  7551. 17
  7552. ],
  7553. [
  7554. 12,
  7555. 48
  7556. ],
  7557. [
  7558. 12,
  7559. 49
  7560. ],
  7561. [
  7562. 12,
  7563. 62
  7564. ],
  7565. [
  7566. 12,
  7567. 63
  7568. ],
  7569. [
  7570. 12,
  7571. 30
  7572. ],
  7573. [
  7574. 12,
  7575. 31
  7576. ],
  7577. [
  7578. 12,
  7579. 32
  7580. ],
  7581. [
  7582. 12,
  7583. 33
  7584. ],
  7585. [
  7586. 12,
  7587. 40
  7588. ],
  7589. [
  7590. 12,
  7591. 41
  7592. ],
  7593. [
  7594. 11,
  7595. 22
  7596. ],
  7597. [
  7598. 11,
  7599. 22
  7600. ],
  7601. [
  7602. 8,
  7603. 14
  7604. ],
  7605. [
  7606. 8,
  7607. 14
  7608. ],
  7609. [
  7610. 8,
  7611. 14
  7612. ],
  7613. [
  7614. 8,
  7615. 14
  7616. ],
  7617. [
  7618. 8,
  7619. 14
  7620. ],
  7621. [
  7622. 8,
  7623. 14
  7624. ],
  7625. [
  7626. 8,
  7627. 14
  7628. ],
  7629. [
  7630. 8,
  7631. 14
  7632. ],
  7633. [
  7634. 8,
  7635. 14
  7636. ],
  7637. [
  7638. 8,
  7639. 14
  7640. ],
  7641. [
  7642. 8,
  7643. 14
  7644. ],
  7645. [
  7646. 8,
  7647. 14
  7648. ],
  7649. [
  7650. 8,
  7651. 14
  7652. ],
  7653. [
  7654. 8,
  7655. 14
  7656. ],
  7657. [
  7658. 8,
  7659. 14
  7660. ],
  7661. [
  7662. 8,
  7663. 14
  7664. ],
  7665. [
  7666. 7,
  7667. 10
  7668. ],
  7669. [
  7670. 7,
  7671. 10
  7672. ],
  7673. [
  7674. 7,
  7675. 10
  7676. ],
  7677. [
  7678. 7,
  7679. 10
  7680. ],
  7681. [
  7682. 7,
  7683. 10
  7684. ],
  7685. [
  7686. 7,
  7687. 10
  7688. ],
  7689. [
  7690. 7,
  7691. 10
  7692. ],
  7693. [
  7694. 7,
  7695. 10
  7696. ],
  7697. [
  7698. 7,
  7699. 10
  7700. ],
  7701. [
  7702. 7,
  7703. 10
  7704. ],
  7705. [
  7706. 7,
  7707. 10
  7708. ],
  7709. [
  7710. 7,
  7711. 10
  7712. ],
  7713. [
  7714. 7,
  7715. 10
  7716. ],
  7717. [
  7718. 7,
  7719. 10
  7720. ],
  7721. [
  7722. 7,
  7723. 10
  7724. ],
  7725. [
  7726. 7,
  7727. 10
  7728. ],
  7729. [
  7730. 7,
  7731. 10
  7732. ],
  7733. [
  7734. 7,
  7735. 10
  7736. ],
  7737. [
  7738. 7,
  7739. 10
  7740. ],
  7741. [
  7742. 7,
  7743. 10
  7744. ],
  7745. [
  7746. 7,
  7747. 10
  7748. ],
  7749. [
  7750. 7,
  7751. 10
  7752. ],
  7753. [
  7754. 7,
  7755. 10
  7756. ],
  7757. [
  7758. 7,
  7759. 10
  7760. ],
  7761. [
  7762. 7,
  7763. 10
  7764. ],
  7765. [
  7766. 7,
  7767. 10
  7768. ],
  7769. [
  7770. 7,
  7771. 10
  7772. ],
  7773. [
  7774. 7,
  7775. 10
  7776. ],
  7777. [
  7778. 7,
  7779. 10
  7780. ],
  7781. [
  7782. 7,
  7783. 10
  7784. ],
  7785. [
  7786. 7,
  7787. 10
  7788. ],
  7789. [
  7790. 7,
  7791. 10
  7792. ],
  7793. [
  7794. 7,
  7795. 11
  7796. ],
  7797. [
  7798. 7,
  7799. 11
  7800. ],
  7801. [
  7802. 7,
  7803. 11
  7804. ],
  7805. [
  7806. 7,
  7807. 11
  7808. ],
  7809. [
  7810. 7,
  7811. 11
  7812. ],
  7813. [
  7814. 7,
  7815. 11
  7816. ],
  7817. [
  7818. 7,
  7819. 11
  7820. ],
  7821. [
  7822. 7,
  7823. 11
  7824. ],
  7825. [
  7826. 7,
  7827. 11
  7828. ],
  7829. [
  7830. 7,
  7831. 11
  7832. ],
  7833. [
  7834. 7,
  7835. 11
  7836. ],
  7837. [
  7838. 7,
  7839. 11
  7840. ],
  7841. [
  7842. 7,
  7843. 11
  7844. ],
  7845. [
  7846. 7,
  7847. 11
  7848. ],
  7849. [
  7850. 7,
  7851. 11
  7852. ],
  7853. [
  7854. 7,
  7855. 11
  7856. ],
  7857. [
  7858. 7,
  7859. 11
  7860. ],
  7861. [
  7862. 7,
  7863. 11
  7864. ],
  7865. [
  7866. 7,
  7867. 11
  7868. ],
  7869. [
  7870. 7,
  7871. 11
  7872. ],
  7873. [
  7874. 7,
  7875. 11
  7876. ],
  7877. [
  7878. 7,
  7879. 11
  7880. ],
  7881. [
  7882. 7,
  7883. 11
  7884. ],
  7885. [
  7886. 7,
  7887. 11
  7888. ],
  7889. [
  7890. 7,
  7891. 11
  7892. ],
  7893. [
  7894. 7,
  7895. 11
  7896. ],
  7897. [
  7898. 7,
  7899. 11
  7900. ],
  7901. [
  7902. 7,
  7903. 11
  7904. ],
  7905. [
  7906. 7,
  7907. 11
  7908. ],
  7909. [
  7910. 7,
  7911. 11
  7912. ],
  7913. [
  7914. 7,
  7915. 11
  7916. ],
  7917. [
  7918. 7,
  7919. 11
  7920. ],
  7921. [
  7922. 9,
  7923. 15
  7924. ],
  7925. [
  7926. 9,
  7927. 15
  7928. ],
  7929. [
  7930. 9,
  7931. 15
  7932. ],
  7933. [
  7934. 9,
  7935. 15
  7936. ],
  7937. [
  7938. 9,
  7939. 15
  7940. ],
  7941. [
  7942. 9,
  7943. 15
  7944. ],
  7945. [
  7946. 9,
  7947. 15
  7948. ],
  7949. [
  7950. 9,
  7951. 15
  7952. ],
  7953. [
  7954. 12,
  7955. 128
  7956. ],
  7957. [
  7958. 12,
  7959. 192
  7960. ],
  7961. [
  7962. 12,
  7963. 26
  7964. ],
  7965. [
  7966. 12,
  7967. 27
  7968. ],
  7969. [
  7970. 12,
  7971. 28
  7972. ],
  7973. [
  7974. 12,
  7975. 29
  7976. ],
  7977. [
  7978. 11,
  7979. 19
  7980. ],
  7981. [
  7982. 11,
  7983. 19
  7984. ],
  7985. [
  7986. 11,
  7987. 20
  7988. ],
  7989. [
  7990. 11,
  7991. 20
  7992. ],
  7993. [
  7994. 12,
  7995. 34
  7996. ],
  7997. [
  7998. 12,
  7999. 35
  8000. ],
  8001. [
  8002. 12,
  8003. 36
  8004. ],
  8005. [
  8006. 12,
  8007. 37
  8008. ],
  8009. [
  8010. 12,
  8011. 38
  8012. ],
  8013. [
  8014. 12,
  8015. 39
  8016. ],
  8017. [
  8018. 11,
  8019. 21
  8020. ],
  8021. [
  8022. 11,
  8023. 21
  8024. ],
  8025. [
  8026. 12,
  8027. 42
  8028. ],
  8029. [
  8030. 12,
  8031. 43
  8032. ],
  8033. [
  8034. 10,
  8035. 0
  8036. ],
  8037. [
  8038. 10,
  8039. 0
  8040. ],
  8041. [
  8042. 10,
  8043. 0
  8044. ],
  8045. [
  8046. 10,
  8047. 0
  8048. ],
  8049. [
  8050. 7,
  8051. 12
  8052. ],
  8053. [
  8054. 7,
  8055. 12
  8056. ],
  8057. [
  8058. 7,
  8059. 12
  8060. ],
  8061. [
  8062. 7,
  8063. 12
  8064. ],
  8065. [
  8066. 7,
  8067. 12
  8068. ],
  8069. [
  8070. 7,
  8071. 12
  8072. ],
  8073. [
  8074. 7,
  8075. 12
  8076. ],
  8077. [
  8078. 7,
  8079. 12
  8080. ],
  8081. [
  8082. 7,
  8083. 12
  8084. ],
  8085. [
  8086. 7,
  8087. 12
  8088. ],
  8089. [
  8090. 7,
  8091. 12
  8092. ],
  8093. [
  8094. 7,
  8095. 12
  8096. ],
  8097. [
  8098. 7,
  8099. 12
  8100. ],
  8101. [
  8102. 7,
  8103. 12
  8104. ],
  8105. [
  8106. 7,
  8107. 12
  8108. ],
  8109. [
  8110. 7,
  8111. 12
  8112. ],
  8113. [
  8114. 7,
  8115. 12
  8116. ],
  8117. [
  8118. 7,
  8119. 12
  8120. ],
  8121. [
  8122. 7,
  8123. 12
  8124. ],
  8125. [
  8126. 7,
  8127. 12
  8128. ],
  8129. [
  8130. 7,
  8131. 12
  8132. ],
  8133. [
  8134. 7,
  8135. 12
  8136. ],
  8137. [
  8138. 7,
  8139. 12
  8140. ],
  8141. [
  8142. 7,
  8143. 12
  8144. ],
  8145. [
  8146. 7,
  8147. 12
  8148. ],
  8149. [
  8150. 7,
  8151. 12
  8152. ],
  8153. [
  8154. 7,
  8155. 12
  8156. ],
  8157. [
  8158. 7,
  8159. 12
  8160. ],
  8161. [
  8162. 7,
  8163. 12
  8164. ],
  8165. [
  8166. 7,
  8167. 12
  8168. ],
  8169. [
  8170. 7,
  8171. 12
  8172. ],
  8173. [
  8174. 7,
  8175. 12
  8176. ]
  8177. ];
  8178. var blackTable3 = [
  8179. [
  8180. -1,
  8181. -1
  8182. ],
  8183. [
  8184. -1,
  8185. -1
  8186. ],
  8187. [
  8188. -1,
  8189. -1
  8190. ],
  8191. [
  8192. -1,
  8193. -1
  8194. ],
  8195. [
  8196. 6,
  8197. 9
  8198. ],
  8199. [
  8200. 6,
  8201. 8
  8202. ],
  8203. [
  8204. 5,
  8205. 7
  8206. ],
  8207. [
  8208. 5,
  8209. 7
  8210. ],
  8211. [
  8212. 4,
  8213. 6
  8214. ],
  8215. [
  8216. 4,
  8217. 6
  8218. ],
  8219. [
  8220. 4,
  8221. 6
  8222. ],
  8223. [
  8224. 4,
  8225. 6
  8226. ],
  8227. [
  8228. 4,
  8229. 5
  8230. ],
  8231. [
  8232. 4,
  8233. 5
  8234. ],
  8235. [
  8236. 4,
  8237. 5
  8238. ],
  8239. [
  8240. 4,
  8241. 5
  8242. ],
  8243. [
  8244. 3,
  8245. 1
  8246. ],
  8247. [
  8248. 3,
  8249. 1
  8250. ],
  8251. [
  8252. 3,
  8253. 1
  8254. ],
  8255. [
  8256. 3,
  8257. 1
  8258. ],
  8259. [
  8260. 3,
  8261. 1
  8262. ],
  8263. [
  8264. 3,
  8265. 1
  8266. ],
  8267. [
  8268. 3,
  8269. 1
  8270. ],
  8271. [
  8272. 3,
  8273. 1
  8274. ],
  8275. [
  8276. 3,
  8277. 4
  8278. ],
  8279. [
  8280. 3,
  8281. 4
  8282. ],
  8283. [
  8284. 3,
  8285. 4
  8286. ],
  8287. [
  8288. 3,
  8289. 4
  8290. ],
  8291. [
  8292. 3,
  8293. 4
  8294. ],
  8295. [
  8296. 3,
  8297. 4
  8298. ],
  8299. [
  8300. 3,
  8301. 4
  8302. ],
  8303. [
  8304. 3,
  8305. 4
  8306. ],
  8307. [
  8308. 2,
  8309. 3
  8310. ],
  8311. [
  8312. 2,
  8313. 3
  8314. ],
  8315. [
  8316. 2,
  8317. 3
  8318. ],
  8319. [
  8320. 2,
  8321. 3
  8322. ],
  8323. [
  8324. 2,
  8325. 3
  8326. ],
  8327. [
  8328. 2,
  8329. 3
  8330. ],
  8331. [
  8332. 2,
  8333. 3
  8334. ],
  8335. [
  8336. 2,
  8337. 3
  8338. ],
  8339. [
  8340. 2,
  8341. 3
  8342. ],
  8343. [
  8344. 2,
  8345. 3
  8346. ],
  8347. [
  8348. 2,
  8349. 3
  8350. ],
  8351. [
  8352. 2,
  8353. 3
  8354. ],
  8355. [
  8356. 2,
  8357. 3
  8358. ],
  8359. [
  8360. 2,
  8361. 3
  8362. ],
  8363. [
  8364. 2,
  8365. 3
  8366. ],
  8367. [
  8368. 2,
  8369. 3
  8370. ],
  8371. [
  8372. 2,
  8373. 2
  8374. ],
  8375. [
  8376. 2,
  8377. 2
  8378. ],
  8379. [
  8380. 2,
  8381. 2
  8382. ],
  8383. [
  8384. 2,
  8385. 2
  8386. ],
  8387. [
  8388. 2,
  8389. 2
  8390. ],
  8391. [
  8392. 2,
  8393. 2
  8394. ],
  8395. [
  8396. 2,
  8397. 2
  8398. ],
  8399. [
  8400. 2,
  8401. 2
  8402. ],
  8403. [
  8404. 2,
  8405. 2
  8406. ],
  8407. [
  8408. 2,
  8409. 2
  8410. ],
  8411. [
  8412. 2,
  8413. 2
  8414. ],
  8415. [
  8416. 2,
  8417. 2
  8418. ],
  8419. [
  8420. 2,
  8421. 2
  8422. ],
  8423. [
  8424. 2,
  8425. 2
  8426. ],
  8427. [
  8428. 2,
  8429. 2
  8430. ],
  8431. [
  8432. 2,
  8433. 2
  8434. ]
  8435. ];
  8436. function CCITTFaxStream(str, maybeLength, params) {
  8437. this.str = str;
  8438. this.dict = str.dict;
  8439. params = params || Dict.empty;
  8440. this.encoding = params.get('K') || 0;
  8441. this.eoline = params.get('EndOfLine') || false;
  8442. this.byteAlign = params.get('EncodedByteAlign') || false;
  8443. this.columns = params.get('Columns') || 1728;
  8444. this.rows = params.get('Rows') || 0;
  8445. var eoblock = params.get('EndOfBlock');
  8446. if (eoblock === null || eoblock === undefined) {
  8447. eoblock = true;
  8448. }
  8449. this.eoblock = eoblock;
  8450. this.black = params.get('BlackIs1') || false;
  8451. this.codingLine = new Uint32Array(this.columns + 1);
  8452. this.refLine = new Uint32Array(this.columns + 2);
  8453. this.codingLine[0] = this.columns;
  8454. this.codingPos = 0;
  8455. this.row = 0;
  8456. this.nextLine2D = this.encoding < 0;
  8457. this.inputBits = 0;
  8458. this.inputBuf = 0;
  8459. this.outputBits = 0;
  8460. var code1;
  8461. while ((code1 = this.lookBits(12)) === 0) {
  8462. this.eatBits(1);
  8463. }
  8464. if (code1 === 1) {
  8465. this.eatBits(12);
  8466. }
  8467. if (this.encoding > 0) {
  8468. this.nextLine2D = !this.lookBits(1);
  8469. this.eatBits(1);
  8470. }
  8471. DecodeStream.call(this, maybeLength);
  8472. }
  8473. CCITTFaxStream.prototype = Object.create(DecodeStream.prototype);
  8474. CCITTFaxStream.prototype.readBlock = function CCITTFaxStream_readBlock() {
  8475. while (!this.eof) {
  8476. var c = this.lookChar();
  8477. this.ensureBuffer(this.bufferLength + 1);
  8478. this.buffer[this.bufferLength++] = c;
  8479. }
  8480. };
  8481. CCITTFaxStream.prototype.addPixels = function ccittFaxStreamAddPixels(a1, blackPixels) {
  8482. var codingLine = this.codingLine;
  8483. var codingPos = this.codingPos;
  8484. if (a1 > codingLine[codingPos]) {
  8485. if (a1 > this.columns) {
  8486. info('row is wrong length');
  8487. this.err = true;
  8488. a1 = this.columns;
  8489. }
  8490. if (codingPos & 1 ^ blackPixels) {
  8491. ++codingPos;
  8492. }
  8493. codingLine[codingPos] = a1;
  8494. }
  8495. this.codingPos = codingPos;
  8496. };
  8497. CCITTFaxStream.prototype.addPixelsNeg = function ccittFaxStreamAddPixelsNeg(a1, blackPixels) {
  8498. var codingLine = this.codingLine;
  8499. var codingPos = this.codingPos;
  8500. if (a1 > codingLine[codingPos]) {
  8501. if (a1 > this.columns) {
  8502. info('row is wrong length');
  8503. this.err = true;
  8504. a1 = this.columns;
  8505. }
  8506. if (codingPos & 1 ^ blackPixels) {
  8507. ++codingPos;
  8508. }
  8509. codingLine[codingPos] = a1;
  8510. } else if (a1 < codingLine[codingPos]) {
  8511. if (a1 < 0) {
  8512. info('invalid code');
  8513. this.err = true;
  8514. a1 = 0;
  8515. }
  8516. while (codingPos > 0 && a1 < codingLine[codingPos - 1]) {
  8517. --codingPos;
  8518. }
  8519. codingLine[codingPos] = a1;
  8520. }
  8521. this.codingPos = codingPos;
  8522. };
  8523. CCITTFaxStream.prototype.lookChar = function CCITTFaxStream_lookChar() {
  8524. var refLine = this.refLine;
  8525. var codingLine = this.codingLine;
  8526. var columns = this.columns;
  8527. var refPos, blackPixels, bits, i;
  8528. if (this.outputBits === 0) {
  8529. if (this.eof) {
  8530. return null;
  8531. }
  8532. this.err = false;
  8533. var code1, code2, code3;
  8534. if (this.nextLine2D) {
  8535. for (i = 0; codingLine[i] < columns; ++i) {
  8536. refLine[i] = codingLine[i];
  8537. }
  8538. refLine[i++] = columns;
  8539. refLine[i] = columns;
  8540. codingLine[0] = 0;
  8541. this.codingPos = 0;
  8542. refPos = 0;
  8543. blackPixels = 0;
  8544. while (codingLine[this.codingPos] < columns) {
  8545. code1 = this.getTwoDimCode();
  8546. switch (code1) {
  8547. case twoDimPass:
  8548. this.addPixels(refLine[refPos + 1], blackPixels);
  8549. if (refLine[refPos + 1] < columns) {
  8550. refPos += 2;
  8551. }
  8552. break;
  8553. case twoDimHoriz:
  8554. code1 = code2 = 0;
  8555. if (blackPixels) {
  8556. do {
  8557. code1 += code3 = this.getBlackCode();
  8558. } while (code3 >= 64);
  8559. do {
  8560. code2 += code3 = this.getWhiteCode();
  8561. } while (code3 >= 64);
  8562. } else {
  8563. do {
  8564. code1 += code3 = this.getWhiteCode();
  8565. } while (code3 >= 64);
  8566. do {
  8567. code2 += code3 = this.getBlackCode();
  8568. } while (code3 >= 64);
  8569. }
  8570. this.addPixels(codingLine[this.codingPos] + code1, blackPixels);
  8571. if (codingLine[this.codingPos] < columns) {
  8572. this.addPixels(codingLine[this.codingPos] + code2, blackPixels ^ 1);
  8573. }
  8574. while (refLine[refPos] <= codingLine[this.codingPos] && refLine[refPos] < columns) {
  8575. refPos += 2;
  8576. }
  8577. break;
  8578. case twoDimVertR3:
  8579. this.addPixels(refLine[refPos] + 3, blackPixels);
  8580. blackPixels ^= 1;
  8581. if (codingLine[this.codingPos] < columns) {
  8582. ++refPos;
  8583. while (refLine[refPos] <= codingLine[this.codingPos] && refLine[refPos] < columns) {
  8584. refPos += 2;
  8585. }
  8586. }
  8587. break;
  8588. case twoDimVertR2:
  8589. this.addPixels(refLine[refPos] + 2, blackPixels);
  8590. blackPixels ^= 1;
  8591. if (codingLine[this.codingPos] < columns) {
  8592. ++refPos;
  8593. while (refLine[refPos] <= codingLine[this.codingPos] && refLine[refPos] < columns) {
  8594. refPos += 2;
  8595. }
  8596. }
  8597. break;
  8598. case twoDimVertR1:
  8599. this.addPixels(refLine[refPos] + 1, blackPixels);
  8600. blackPixels ^= 1;
  8601. if (codingLine[this.codingPos] < columns) {
  8602. ++refPos;
  8603. while (refLine[refPos] <= codingLine[this.codingPos] && refLine[refPos] < columns) {
  8604. refPos += 2;
  8605. }
  8606. }
  8607. break;
  8608. case twoDimVert0:
  8609. this.addPixels(refLine[refPos], blackPixels);
  8610. blackPixels ^= 1;
  8611. if (codingLine[this.codingPos] < columns) {
  8612. ++refPos;
  8613. while (refLine[refPos] <= codingLine[this.codingPos] && refLine[refPos] < columns) {
  8614. refPos += 2;
  8615. }
  8616. }
  8617. break;
  8618. case twoDimVertL3:
  8619. this.addPixelsNeg(refLine[refPos] - 3, blackPixels);
  8620. blackPixels ^= 1;
  8621. if (codingLine[this.codingPos] < columns) {
  8622. if (refPos > 0) {
  8623. --refPos;
  8624. } else {
  8625. ++refPos;
  8626. }
  8627. while (refLine[refPos] <= codingLine[this.codingPos] && refLine[refPos] < columns) {
  8628. refPos += 2;
  8629. }
  8630. }
  8631. break;
  8632. case twoDimVertL2:
  8633. this.addPixelsNeg(refLine[refPos] - 2, blackPixels);
  8634. blackPixels ^= 1;
  8635. if (codingLine[this.codingPos] < columns) {
  8636. if (refPos > 0) {
  8637. --refPos;
  8638. } else {
  8639. ++refPos;
  8640. }
  8641. while (refLine[refPos] <= codingLine[this.codingPos] && refLine[refPos] < columns) {
  8642. refPos += 2;
  8643. }
  8644. }
  8645. break;
  8646. case twoDimVertL1:
  8647. this.addPixelsNeg(refLine[refPos] - 1, blackPixels);
  8648. blackPixels ^= 1;
  8649. if (codingLine[this.codingPos] < columns) {
  8650. if (refPos > 0) {
  8651. --refPos;
  8652. } else {
  8653. ++refPos;
  8654. }
  8655. while (refLine[refPos] <= codingLine[this.codingPos] && refLine[refPos] < columns) {
  8656. refPos += 2;
  8657. }
  8658. }
  8659. break;
  8660. case ccittEOF:
  8661. this.addPixels(columns, 0);
  8662. this.eof = true;
  8663. break;
  8664. default:
  8665. info('bad 2d code');
  8666. this.addPixels(columns, 0);
  8667. this.err = true;
  8668. }
  8669. }
  8670. } else {
  8671. codingLine[0] = 0;
  8672. this.codingPos = 0;
  8673. blackPixels = 0;
  8674. while (codingLine[this.codingPos] < columns) {
  8675. code1 = 0;
  8676. if (blackPixels) {
  8677. do {
  8678. code1 += code3 = this.getBlackCode();
  8679. } while (code3 >= 64);
  8680. } else {
  8681. do {
  8682. code1 += code3 = this.getWhiteCode();
  8683. } while (code3 >= 64);
  8684. }
  8685. this.addPixels(codingLine[this.codingPos] + code1, blackPixels);
  8686. blackPixels ^= 1;
  8687. }
  8688. }
  8689. var gotEOL = false;
  8690. if (this.byteAlign) {
  8691. this.inputBits &= ~7;
  8692. }
  8693. if (!this.eoblock && this.row === this.rows - 1) {
  8694. this.eof = true;
  8695. } else {
  8696. code1 = this.lookBits(12);
  8697. if (this.eoline) {
  8698. while (code1 !== ccittEOF && code1 !== 1) {
  8699. this.eatBits(1);
  8700. code1 = this.lookBits(12);
  8701. }
  8702. } else {
  8703. while (code1 === 0) {
  8704. this.eatBits(1);
  8705. code1 = this.lookBits(12);
  8706. }
  8707. }
  8708. if (code1 === 1) {
  8709. this.eatBits(12);
  8710. gotEOL = true;
  8711. } else if (code1 === ccittEOF) {
  8712. this.eof = true;
  8713. }
  8714. }
  8715. if (!this.eof && this.encoding > 0) {
  8716. this.nextLine2D = !this.lookBits(1);
  8717. this.eatBits(1);
  8718. }
  8719. if (this.eoblock && gotEOL && this.byteAlign) {
  8720. code1 = this.lookBits(12);
  8721. if (code1 === 1) {
  8722. this.eatBits(12);
  8723. if (this.encoding > 0) {
  8724. this.lookBits(1);
  8725. this.eatBits(1);
  8726. }
  8727. if (this.encoding >= 0) {
  8728. for (i = 0; i < 4; ++i) {
  8729. code1 = this.lookBits(12);
  8730. if (code1 !== 1) {
  8731. info('bad rtc code: ' + code1);
  8732. }
  8733. this.eatBits(12);
  8734. if (this.encoding > 0) {
  8735. this.lookBits(1);
  8736. this.eatBits(1);
  8737. }
  8738. }
  8739. }
  8740. this.eof = true;
  8741. }
  8742. } else if (this.err && this.eoline) {
  8743. while (true) {
  8744. code1 = this.lookBits(13);
  8745. if (code1 === ccittEOF) {
  8746. this.eof = true;
  8747. return null;
  8748. }
  8749. if (code1 >> 1 === 1) {
  8750. break;
  8751. }
  8752. this.eatBits(1);
  8753. }
  8754. this.eatBits(12);
  8755. if (this.encoding > 0) {
  8756. this.eatBits(1);
  8757. this.nextLine2D = !(code1 & 1);
  8758. }
  8759. }
  8760. if (codingLine[0] > 0) {
  8761. this.outputBits = codingLine[this.codingPos = 0];
  8762. } else {
  8763. this.outputBits = codingLine[this.codingPos = 1];
  8764. }
  8765. this.row++;
  8766. }
  8767. var c;
  8768. if (this.outputBits >= 8) {
  8769. c = this.codingPos & 1 ? 0 : 0xFF;
  8770. this.outputBits -= 8;
  8771. if (this.outputBits === 0 && codingLine[this.codingPos] < columns) {
  8772. this.codingPos++;
  8773. this.outputBits = codingLine[this.codingPos] - codingLine[this.codingPos - 1];
  8774. }
  8775. } else {
  8776. bits = 8;
  8777. c = 0;
  8778. do {
  8779. if (this.outputBits > bits) {
  8780. c <<= bits;
  8781. if (!(this.codingPos & 1)) {
  8782. c |= 0xFF >> 8 - bits;
  8783. }
  8784. this.outputBits -= bits;
  8785. bits = 0;
  8786. } else {
  8787. c <<= this.outputBits;
  8788. if (!(this.codingPos & 1)) {
  8789. c |= 0xFF >> 8 - this.outputBits;
  8790. }
  8791. bits -= this.outputBits;
  8792. this.outputBits = 0;
  8793. if (codingLine[this.codingPos] < columns) {
  8794. this.codingPos++;
  8795. this.outputBits = codingLine[this.codingPos] - codingLine[this.codingPos - 1];
  8796. } else if (bits > 0) {
  8797. c <<= bits;
  8798. bits = 0;
  8799. }
  8800. }
  8801. } while (bits);
  8802. }
  8803. if (this.black) {
  8804. c ^= 0xFF;
  8805. }
  8806. return c;
  8807. };
  8808. CCITTFaxStream.prototype.findTableCode = function ccittFaxStreamFindTableCode(start, end, table, limit) {
  8809. var limitValue = limit || 0;
  8810. for (var i = start; i <= end; ++i) {
  8811. var code = this.lookBits(i);
  8812. if (code === ccittEOF) {
  8813. return [
  8814. true,
  8815. 1,
  8816. false
  8817. ];
  8818. }
  8819. if (i < end) {
  8820. code <<= end - i;
  8821. }
  8822. if (!limitValue || code >= limitValue) {
  8823. var p = table[code - limitValue];
  8824. if (p[0] === i) {
  8825. this.eatBits(i);
  8826. return [
  8827. true,
  8828. p[1],
  8829. true
  8830. ];
  8831. }
  8832. }
  8833. }
  8834. return [
  8835. false,
  8836. 0,
  8837. false
  8838. ];
  8839. };
  8840. CCITTFaxStream.prototype.getTwoDimCode = function ccittFaxStreamGetTwoDimCode() {
  8841. var code = 0;
  8842. var p;
  8843. if (this.eoblock) {
  8844. code = this.lookBits(7);
  8845. p = twoDimTable[code];
  8846. if (p && p[0] > 0) {
  8847. this.eatBits(p[0]);
  8848. return p[1];
  8849. }
  8850. } else {
  8851. var result = this.findTableCode(1, 7, twoDimTable);
  8852. if (result[0] && result[2]) {
  8853. return result[1];
  8854. }
  8855. }
  8856. info('Bad two dim code');
  8857. return ccittEOF;
  8858. };
  8859. CCITTFaxStream.prototype.getWhiteCode = function ccittFaxStreamGetWhiteCode() {
  8860. var code = 0;
  8861. var p;
  8862. if (this.eoblock) {
  8863. code = this.lookBits(12);
  8864. if (code === ccittEOF) {
  8865. return 1;
  8866. }
  8867. if (code >> 5 === 0) {
  8868. p = whiteTable1[code];
  8869. } else {
  8870. p = whiteTable2[code >> 3];
  8871. }
  8872. if (p[0] > 0) {
  8873. this.eatBits(p[0]);
  8874. return p[1];
  8875. }
  8876. } else {
  8877. var result = this.findTableCode(1, 9, whiteTable2);
  8878. if (result[0]) {
  8879. return result[1];
  8880. }
  8881. result = this.findTableCode(11, 12, whiteTable1);
  8882. if (result[0]) {
  8883. return result[1];
  8884. }
  8885. }
  8886. info('bad white code');
  8887. this.eatBits(1);
  8888. return 1;
  8889. };
  8890. CCITTFaxStream.prototype.getBlackCode = function ccittFaxStreamGetBlackCode() {
  8891. var code, p;
  8892. if (this.eoblock) {
  8893. code = this.lookBits(13);
  8894. if (code === ccittEOF) {
  8895. return 1;
  8896. }
  8897. if (code >> 7 === 0) {
  8898. p = blackTable1[code];
  8899. } else if (code >> 9 === 0 && code >> 7 !== 0) {
  8900. p = blackTable2[(code >> 1) - 64];
  8901. } else {
  8902. p = blackTable3[code >> 7];
  8903. }
  8904. if (p[0] > 0) {
  8905. this.eatBits(p[0]);
  8906. return p[1];
  8907. }
  8908. } else {
  8909. var result = this.findTableCode(2, 6, blackTable3);
  8910. if (result[0]) {
  8911. return result[1];
  8912. }
  8913. result = this.findTableCode(7, 12, blackTable2, 64);
  8914. if (result[0]) {
  8915. return result[1];
  8916. }
  8917. result = this.findTableCode(10, 13, blackTable1);
  8918. if (result[0]) {
  8919. return result[1];
  8920. }
  8921. }
  8922. info('bad black code');
  8923. this.eatBits(1);
  8924. return 1;
  8925. };
  8926. CCITTFaxStream.prototype.lookBits = function CCITTFaxStream_lookBits(n) {
  8927. var c;
  8928. while (this.inputBits < n) {
  8929. if ((c = this.str.getByte()) === -1) {
  8930. if (this.inputBits === 0) {
  8931. return ccittEOF;
  8932. }
  8933. return this.inputBuf << n - this.inputBits & 0xFFFF >> 16 - n;
  8934. }
  8935. this.inputBuf = this.inputBuf << 8 | c;
  8936. this.inputBits += 8;
  8937. }
  8938. return this.inputBuf >> this.inputBits - n & 0xFFFF >> 16 - n;
  8939. };
  8940. CCITTFaxStream.prototype.eatBits = function CCITTFaxStream_eatBits(n) {
  8941. if ((this.inputBits -= n) < 0) {
  8942. this.inputBits = 0;
  8943. }
  8944. };
  8945. return CCITTFaxStream;
  8946. }();
  8947. var LZWStream = function LZWStreamClosure() {
  8948. function LZWStream(str, maybeLength, earlyChange) {
  8949. this.str = str;
  8950. this.dict = str.dict;
  8951. this.cachedData = 0;
  8952. this.bitsCached = 0;
  8953. var maxLzwDictionarySize = 4096;
  8954. var lzwState = {
  8955. earlyChange: earlyChange,
  8956. codeLength: 9,
  8957. nextCode: 258,
  8958. dictionaryValues: new Uint8Array(maxLzwDictionarySize),
  8959. dictionaryLengths: new Uint16Array(maxLzwDictionarySize),
  8960. dictionaryPrevCodes: new Uint16Array(maxLzwDictionarySize),
  8961. currentSequence: new Uint8Array(maxLzwDictionarySize),
  8962. currentSequenceLength: 0
  8963. };
  8964. for (var i = 0; i < 256; ++i) {
  8965. lzwState.dictionaryValues[i] = i;
  8966. lzwState.dictionaryLengths[i] = 1;
  8967. }
  8968. this.lzwState = lzwState;
  8969. DecodeStream.call(this, maybeLength);
  8970. }
  8971. LZWStream.prototype = Object.create(DecodeStream.prototype);
  8972. LZWStream.prototype.readBits = function LZWStream_readBits(n) {
  8973. var bitsCached = this.bitsCached;
  8974. var cachedData = this.cachedData;
  8975. while (bitsCached < n) {
  8976. var c = this.str.getByte();
  8977. if (c === -1) {
  8978. this.eof = true;
  8979. return null;
  8980. }
  8981. cachedData = cachedData << 8 | c;
  8982. bitsCached += 8;
  8983. }
  8984. this.bitsCached = bitsCached -= n;
  8985. this.cachedData = cachedData;
  8986. this.lastCode = null;
  8987. return cachedData >>> bitsCached & (1 << n) - 1;
  8988. };
  8989. LZWStream.prototype.readBlock = function LZWStream_readBlock() {
  8990. var blockSize = 512;
  8991. var estimatedDecodedSize = blockSize * 2, decodedSizeDelta = blockSize;
  8992. var i, j, q;
  8993. var lzwState = this.lzwState;
  8994. if (!lzwState) {
  8995. return;
  8996. }
  8997. var earlyChange = lzwState.earlyChange;
  8998. var nextCode = lzwState.nextCode;
  8999. var dictionaryValues = lzwState.dictionaryValues;
  9000. var dictionaryLengths = lzwState.dictionaryLengths;
  9001. var dictionaryPrevCodes = lzwState.dictionaryPrevCodes;
  9002. var codeLength = lzwState.codeLength;
  9003. var prevCode = lzwState.prevCode;
  9004. var currentSequence = lzwState.currentSequence;
  9005. var currentSequenceLength = lzwState.currentSequenceLength;
  9006. var decodedLength = 0;
  9007. var currentBufferLength = this.bufferLength;
  9008. var buffer = this.ensureBuffer(this.bufferLength + estimatedDecodedSize);
  9009. for (i = 0; i < blockSize; i++) {
  9010. var code = this.readBits(codeLength);
  9011. var hasPrev = currentSequenceLength > 0;
  9012. if (code < 256) {
  9013. currentSequence[0] = code;
  9014. currentSequenceLength = 1;
  9015. } else if (code >= 258) {
  9016. if (code < nextCode) {
  9017. currentSequenceLength = dictionaryLengths[code];
  9018. for (j = currentSequenceLength - 1, q = code; j >= 0; j--) {
  9019. currentSequence[j] = dictionaryValues[q];
  9020. q = dictionaryPrevCodes[q];
  9021. }
  9022. } else {
  9023. currentSequence[currentSequenceLength++] = currentSequence[0];
  9024. }
  9025. } else if (code === 256) {
  9026. codeLength = 9;
  9027. nextCode = 258;
  9028. currentSequenceLength = 0;
  9029. continue;
  9030. } else {
  9031. this.eof = true;
  9032. delete this.lzwState;
  9033. break;
  9034. }
  9035. if (hasPrev) {
  9036. dictionaryPrevCodes[nextCode] = prevCode;
  9037. dictionaryLengths[nextCode] = dictionaryLengths[prevCode] + 1;
  9038. dictionaryValues[nextCode] = currentSequence[0];
  9039. nextCode++;
  9040. codeLength = nextCode + earlyChange & nextCode + earlyChange - 1 ? codeLength : Math.min(Math.log(nextCode + earlyChange) / 0.6931471805599453 + 1, 12) | 0;
  9041. }
  9042. prevCode = code;
  9043. decodedLength += currentSequenceLength;
  9044. if (estimatedDecodedSize < decodedLength) {
  9045. do {
  9046. estimatedDecodedSize += decodedSizeDelta;
  9047. } while (estimatedDecodedSize < decodedLength);
  9048. buffer = this.ensureBuffer(this.bufferLength + estimatedDecodedSize);
  9049. }
  9050. for (j = 0; j < currentSequenceLength; j++) {
  9051. buffer[currentBufferLength++] = currentSequence[j];
  9052. }
  9053. }
  9054. lzwState.nextCode = nextCode;
  9055. lzwState.codeLength = codeLength;
  9056. lzwState.prevCode = prevCode;
  9057. lzwState.currentSequenceLength = currentSequenceLength;
  9058. this.bufferLength = currentBufferLength;
  9059. };
  9060. return LZWStream;
  9061. }();
  9062. var NullStream = function NullStreamClosure() {
  9063. function NullStream() {
  9064. Stream.call(this, new Uint8Array(0));
  9065. }
  9066. NullStream.prototype = Stream.prototype;
  9067. return NullStream;
  9068. }();
  9069. exports.Ascii85Stream = Ascii85Stream;
  9070. exports.AsciiHexStream = AsciiHexStream;
  9071. exports.CCITTFaxStream = CCITTFaxStream;
  9072. exports.DecryptStream = DecryptStream;
  9073. exports.DecodeStream = DecodeStream;
  9074. exports.FlateStream = FlateStream;
  9075. exports.Jbig2Stream = Jbig2Stream;
  9076. exports.JpegStream = JpegStream;
  9077. exports.JpxStream = JpxStream;
  9078. exports.NullStream = NullStream;
  9079. exports.PredictorStream = PredictorStream;
  9080. exports.RunLengthStream = RunLengthStream;
  9081. exports.Stream = Stream;
  9082. exports.StreamsSequenceStream = StreamsSequenceStream;
  9083. exports.StringStream = StringStream;
  9084. exports.LZWStream = LZWStream;
  9085. /***/ }),
  9086. /* 3 */
  9087. /***/ (function(module, exports, __w_pdfjs_require__) {
  9088. "use strict";
  9089. var sharedUtil = __w_pdfjs_require__(0);
  9090. var assert = sharedUtil.assert;
  9091. var removeNullCharacters = sharedUtil.removeNullCharacters;
  9092. var warn = sharedUtil.warn;
  9093. var deprecated = sharedUtil.deprecated;
  9094. var createValidAbsoluteUrl = sharedUtil.createValidAbsoluteUrl;
  9095. var DEFAULT_LINK_REL = 'noopener noreferrer nofollow';
  9096. function DOMCanvasFactory() {
  9097. }
  9098. DOMCanvasFactory.prototype = {
  9099. create: function DOMCanvasFactory_create(width, height) {
  9100. assert(width > 0 && height > 0, 'invalid canvas size');
  9101. var canvas = document.createElement('canvas');
  9102. var context = canvas.getContext('2d');
  9103. canvas.width = width;
  9104. canvas.height = height;
  9105. return {
  9106. canvas: canvas,
  9107. context: context
  9108. };
  9109. },
  9110. reset: function DOMCanvasFactory_reset(canvasAndContextPair, width, height) {
  9111. assert(canvasAndContextPair.canvas, 'canvas is not specified');
  9112. assert(width > 0 && height > 0, 'invalid canvas size');
  9113. canvasAndContextPair.canvas.width = width;
  9114. canvasAndContextPair.canvas.height = height;
  9115. },
  9116. destroy: function DOMCanvasFactory_destroy(canvasAndContextPair) {
  9117. assert(canvasAndContextPair.canvas, 'canvas is not specified');
  9118. canvasAndContextPair.canvas.width = 0;
  9119. canvasAndContextPair.canvas.height = 0;
  9120. canvasAndContextPair.canvas = null;
  9121. canvasAndContextPair.context = null;
  9122. }
  9123. };
  9124. var CustomStyle = function CustomStyleClosure() {
  9125. var prefixes = [
  9126. 'ms',
  9127. 'Moz',
  9128. 'Webkit',
  9129. 'O'
  9130. ];
  9131. var _cache = Object.create(null);
  9132. function CustomStyle() {
  9133. }
  9134. CustomStyle.getProp = function get(propName, element) {
  9135. if (arguments.length === 1 && typeof _cache[propName] === 'string') {
  9136. return _cache[propName];
  9137. }
  9138. element = element || document.documentElement;
  9139. var style = element.style, prefixed, uPropName;
  9140. if (typeof style[propName] === 'string') {
  9141. return _cache[propName] = propName;
  9142. }
  9143. uPropName = propName.charAt(0).toUpperCase() + propName.slice(1);
  9144. for (var i = 0, l = prefixes.length; i < l; i++) {
  9145. prefixed = prefixes[i] + uPropName;
  9146. if (typeof style[prefixed] === 'string') {
  9147. return _cache[propName] = prefixed;
  9148. }
  9149. }
  9150. return _cache[propName] = 'undefined';
  9151. };
  9152. CustomStyle.setProp = function set(propName, element, str) {
  9153. var prop = this.getProp(propName);
  9154. if (prop !== 'undefined') {
  9155. element.style[prop] = str;
  9156. }
  9157. };
  9158. return CustomStyle;
  9159. }();
  9160. var hasCanvasTypedArrays;
  9161. hasCanvasTypedArrays = function hasCanvasTypedArrays() {
  9162. var canvas = document.createElement('canvas');
  9163. canvas.width = canvas.height = 1;
  9164. var ctx = canvas.getContext('2d');
  9165. var imageData = ctx.createImageData(1, 1);
  9166. return typeof imageData.data.buffer !== 'undefined';
  9167. };
  9168. var LinkTarget = {
  9169. NONE: 0,
  9170. SELF: 1,
  9171. BLANK: 2,
  9172. PARENT: 3,
  9173. TOP: 4
  9174. };
  9175. var LinkTargetStringMap = [
  9176. '',
  9177. '_self',
  9178. '_blank',
  9179. '_parent',
  9180. '_top'
  9181. ];
  9182. function addLinkAttributes(link, params) {
  9183. var url = params && params.url;
  9184. link.href = link.title = url ? removeNullCharacters(url) : '';
  9185. if (url) {
  9186. var target = params.target;
  9187. if (typeof target === 'undefined') {
  9188. target = getDefaultSetting('externalLinkTarget');
  9189. }
  9190. link.target = LinkTargetStringMap[target];
  9191. var rel = params.rel;
  9192. if (typeof rel === 'undefined') {
  9193. rel = getDefaultSetting('externalLinkRel');
  9194. }
  9195. link.rel = rel;
  9196. }
  9197. }
  9198. function getFilenameFromUrl(url) {
  9199. var anchor = url.indexOf('#');
  9200. var query = url.indexOf('?');
  9201. var end = Math.min(anchor > 0 ? anchor : url.length, query > 0 ? query : url.length);
  9202. return url.substring(url.lastIndexOf('/', end) + 1, end);
  9203. }
  9204. function getDefaultSetting(id) {
  9205. var globalSettings = sharedUtil.globalScope.PDFJS;
  9206. switch (id) {
  9207. case 'pdfBug':
  9208. return globalSettings ? globalSettings.pdfBug : false;
  9209. case 'disableAutoFetch':
  9210. return globalSettings ? globalSettings.disableAutoFetch : false;
  9211. case 'disableStream':
  9212. return globalSettings ? globalSettings.disableStream : false;
  9213. case 'disableRange':
  9214. return globalSettings ? globalSettings.disableRange : false;
  9215. case 'disableFontFace':
  9216. return globalSettings ? globalSettings.disableFontFace : false;
  9217. case 'disableCreateObjectURL':
  9218. return globalSettings ? globalSettings.disableCreateObjectURL : false;
  9219. case 'disableWebGL':
  9220. return globalSettings ? globalSettings.disableWebGL : true;
  9221. case 'cMapUrl':
  9222. return globalSettings ? globalSettings.cMapUrl : null;
  9223. case 'cMapPacked':
  9224. return globalSettings ? globalSettings.cMapPacked : false;
  9225. case 'postMessageTransfers':
  9226. return globalSettings ? globalSettings.postMessageTransfers : true;
  9227. case 'workerSrc':
  9228. return globalSettings ? globalSettings.workerSrc : null;
  9229. case 'disableWorker':
  9230. return globalSettings ? globalSettings.disableWorker : false;
  9231. case 'maxImageSize':
  9232. return globalSettings ? globalSettings.maxImageSize : -1;
  9233. case 'imageResourcesPath':
  9234. return globalSettings ? globalSettings.imageResourcesPath : '';
  9235. case 'isEvalSupported':
  9236. return globalSettings ? globalSettings.isEvalSupported : true;
  9237. case 'externalLinkTarget':
  9238. if (!globalSettings) {
  9239. return LinkTarget.NONE;
  9240. }
  9241. switch (globalSettings.externalLinkTarget) {
  9242. case LinkTarget.NONE:
  9243. case LinkTarget.SELF:
  9244. case LinkTarget.BLANK:
  9245. case LinkTarget.PARENT:
  9246. case LinkTarget.TOP:
  9247. return globalSettings.externalLinkTarget;
  9248. }
  9249. warn('PDFJS.externalLinkTarget is invalid: ' + globalSettings.externalLinkTarget);
  9250. globalSettings.externalLinkTarget = LinkTarget.NONE;
  9251. return LinkTarget.NONE;
  9252. case 'externalLinkRel':
  9253. return globalSettings ? globalSettings.externalLinkRel : DEFAULT_LINK_REL;
  9254. case 'enableStats':
  9255. return !!(globalSettings && globalSettings.enableStats);
  9256. default:
  9257. throw new Error('Unknown default setting: ' + id);
  9258. }
  9259. }
  9260. function isExternalLinkTargetSet() {
  9261. var externalLinkTarget = getDefaultSetting('externalLinkTarget');
  9262. switch (externalLinkTarget) {
  9263. case LinkTarget.NONE:
  9264. return false;
  9265. case LinkTarget.SELF:
  9266. case LinkTarget.BLANK:
  9267. case LinkTarget.PARENT:
  9268. case LinkTarget.TOP:
  9269. return true;
  9270. }
  9271. }
  9272. function isValidUrl(url, allowRelative) {
  9273. deprecated('isValidUrl(), please use createValidAbsoluteUrl() instead.');
  9274. var baseUrl = allowRelative ? 'http://example.com' : null;
  9275. return createValidAbsoluteUrl(url, baseUrl) !== null;
  9276. }
  9277. exports.CustomStyle = CustomStyle;
  9278. exports.addLinkAttributes = addLinkAttributes;
  9279. exports.isExternalLinkTargetSet = isExternalLinkTargetSet;
  9280. exports.isValidUrl = isValidUrl;
  9281. exports.getFilenameFromUrl = getFilenameFromUrl;
  9282. exports.LinkTarget = LinkTarget;
  9283. exports.hasCanvasTypedArrays = hasCanvasTypedArrays;
  9284. exports.getDefaultSetting = getDefaultSetting;
  9285. exports.DEFAULT_LINK_REL = DEFAULT_LINK_REL;
  9286. exports.DOMCanvasFactory = DOMCanvasFactory;
  9287. /***/ }),
  9288. /* 4 */
  9289. /***/ (function(module, exports, __w_pdfjs_require__) {
  9290. "use strict";
  9291. var sharedUtil = __w_pdfjs_require__(0);
  9292. var corePrimitives = __w_pdfjs_require__(1);
  9293. var coreFunction = __w_pdfjs_require__(7);
  9294. var error = sharedUtil.error;
  9295. var info = sharedUtil.info;
  9296. var isArray = sharedUtil.isArray;
  9297. var isString = sharedUtil.isString;
  9298. var shadow = sharedUtil.shadow;
  9299. var warn = sharedUtil.warn;
  9300. var isDict = corePrimitives.isDict;
  9301. var isName = corePrimitives.isName;
  9302. var isStream = corePrimitives.isStream;
  9303. var PDFFunction = coreFunction.PDFFunction;
  9304. var ColorSpace = function ColorSpaceClosure() {
  9305. function resizeRgbImage(src, bpc, w1, h1, w2, h2, alpha01, dest) {
  9306. var COMPONENTS = 3;
  9307. alpha01 = alpha01 !== 1 ? 0 : alpha01;
  9308. var xRatio = w1 / w2;
  9309. var yRatio = h1 / h2;
  9310. var i, j, py, newIndex = 0, oldIndex;
  9311. var xScaled = new Uint16Array(w2);
  9312. var w1Scanline = w1 * COMPONENTS;
  9313. for (i = 0; i < w2; i++) {
  9314. xScaled[i] = Math.floor(i * xRatio) * COMPONENTS;
  9315. }
  9316. for (i = 0; i < h2; i++) {
  9317. py = Math.floor(i * yRatio) * w1Scanline;
  9318. for (j = 0; j < w2; j++) {
  9319. oldIndex = py + xScaled[j];
  9320. dest[newIndex++] = src[oldIndex++];
  9321. dest[newIndex++] = src[oldIndex++];
  9322. dest[newIndex++] = src[oldIndex++];
  9323. newIndex += alpha01;
  9324. }
  9325. }
  9326. }
  9327. function ColorSpace() {
  9328. error('should not call ColorSpace constructor');
  9329. }
  9330. ColorSpace.prototype = {
  9331. getRgb: function ColorSpace_getRgb(src, srcOffset) {
  9332. var rgb = new Uint8Array(3);
  9333. this.getRgbItem(src, srcOffset, rgb, 0);
  9334. return rgb;
  9335. },
  9336. getRgbItem: function ColorSpace_getRgbItem(src, srcOffset, dest, destOffset) {
  9337. error('Should not call ColorSpace.getRgbItem');
  9338. },
  9339. getRgbBuffer: function ColorSpace_getRgbBuffer(src, srcOffset, count, dest, destOffset, bits, alpha01) {
  9340. error('Should not call ColorSpace.getRgbBuffer');
  9341. },
  9342. getOutputLength: function ColorSpace_getOutputLength(inputLength, alpha01) {
  9343. error('Should not call ColorSpace.getOutputLength');
  9344. },
  9345. isPassthrough: function ColorSpace_isPassthrough(bits) {
  9346. return false;
  9347. },
  9348. fillRgb: function ColorSpace_fillRgb(dest, originalWidth, originalHeight, width, height, actualHeight, bpc, comps, alpha01) {
  9349. var count = originalWidth * originalHeight;
  9350. var rgbBuf = null;
  9351. var numComponentColors = 1 << bpc;
  9352. var needsResizing = originalHeight !== height || originalWidth !== width;
  9353. var i, ii;
  9354. if (this.isPassthrough(bpc)) {
  9355. rgbBuf = comps;
  9356. } else if (this.numComps === 1 && count > numComponentColors && this.name !== 'DeviceGray' && this.name !== 'DeviceRGB') {
  9357. var allColors = bpc <= 8 ? new Uint8Array(numComponentColors) : new Uint16Array(numComponentColors);
  9358. var key;
  9359. for (i = 0; i < numComponentColors; i++) {
  9360. allColors[i] = i;
  9361. }
  9362. var colorMap = new Uint8Array(numComponentColors * 3);
  9363. this.getRgbBuffer(allColors, 0, numComponentColors, colorMap, 0, bpc, 0);
  9364. var destPos, rgbPos;
  9365. if (!needsResizing) {
  9366. destPos = 0;
  9367. for (i = 0; i < count; ++i) {
  9368. key = comps[i] * 3;
  9369. dest[destPos++] = colorMap[key];
  9370. dest[destPos++] = colorMap[key + 1];
  9371. dest[destPos++] = colorMap[key + 2];
  9372. destPos += alpha01;
  9373. }
  9374. } else {
  9375. rgbBuf = new Uint8Array(count * 3);
  9376. rgbPos = 0;
  9377. for (i = 0; i < count; ++i) {
  9378. key = comps[i] * 3;
  9379. rgbBuf[rgbPos++] = colorMap[key];
  9380. rgbBuf[rgbPos++] = colorMap[key + 1];
  9381. rgbBuf[rgbPos++] = colorMap[key + 2];
  9382. }
  9383. }
  9384. } else {
  9385. if (!needsResizing) {
  9386. this.getRgbBuffer(comps, 0, width * actualHeight, dest, 0, bpc, alpha01);
  9387. } else {
  9388. rgbBuf = new Uint8Array(count * 3);
  9389. this.getRgbBuffer(comps, 0, count, rgbBuf, 0, bpc, 0);
  9390. }
  9391. }
  9392. if (rgbBuf) {
  9393. if (needsResizing) {
  9394. resizeRgbImage(rgbBuf, bpc, originalWidth, originalHeight, width, height, alpha01, dest);
  9395. } else {
  9396. rgbPos = 0;
  9397. destPos = 0;
  9398. for (i = 0, ii = width * actualHeight; i < ii; i++) {
  9399. dest[destPos++] = rgbBuf[rgbPos++];
  9400. dest[destPos++] = rgbBuf[rgbPos++];
  9401. dest[destPos++] = rgbBuf[rgbPos++];
  9402. destPos += alpha01;
  9403. }
  9404. }
  9405. }
  9406. },
  9407. usesZeroToOneRange: true
  9408. };
  9409. ColorSpace.parse = function ColorSpace_parse(cs, xref, res) {
  9410. var IR = ColorSpace.parseToIR(cs, xref, res);
  9411. if (IR instanceof AlternateCS) {
  9412. return IR;
  9413. }
  9414. return ColorSpace.fromIR(IR);
  9415. };
  9416. ColorSpace.fromIR = function ColorSpace_fromIR(IR) {
  9417. var name = isArray(IR) ? IR[0] : IR;
  9418. var whitePoint, blackPoint, gamma;
  9419. switch (name) {
  9420. case 'DeviceGrayCS':
  9421. return this.singletons.gray;
  9422. case 'DeviceRgbCS':
  9423. return this.singletons.rgb;
  9424. case 'DeviceCmykCS':
  9425. return this.singletons.cmyk;
  9426. case 'CalGrayCS':
  9427. whitePoint = IR[1];
  9428. blackPoint = IR[2];
  9429. gamma = IR[3];
  9430. return new CalGrayCS(whitePoint, blackPoint, gamma);
  9431. case 'CalRGBCS':
  9432. whitePoint = IR[1];
  9433. blackPoint = IR[2];
  9434. gamma = IR[3];
  9435. var matrix = IR[4];
  9436. return new CalRGBCS(whitePoint, blackPoint, gamma, matrix);
  9437. case 'PatternCS':
  9438. var basePatternCS = IR[1];
  9439. if (basePatternCS) {
  9440. basePatternCS = ColorSpace.fromIR(basePatternCS);
  9441. }
  9442. return new PatternCS(basePatternCS);
  9443. case 'IndexedCS':
  9444. var baseIndexedCS = IR[1];
  9445. var hiVal = IR[2];
  9446. var lookup = IR[3];
  9447. return new IndexedCS(ColorSpace.fromIR(baseIndexedCS), hiVal, lookup);
  9448. case 'AlternateCS':
  9449. var numComps = IR[1];
  9450. var alt = IR[2];
  9451. var tintFnIR = IR[3];
  9452. return new AlternateCS(numComps, ColorSpace.fromIR(alt), PDFFunction.fromIR(tintFnIR));
  9453. case 'LabCS':
  9454. whitePoint = IR[1];
  9455. blackPoint = IR[2];
  9456. var range = IR[3];
  9457. return new LabCS(whitePoint, blackPoint, range);
  9458. default:
  9459. error('Unknown name ' + name);
  9460. }
  9461. return null;
  9462. };
  9463. ColorSpace.parseToIR = function ColorSpace_parseToIR(cs, xref, res) {
  9464. if (isName(cs)) {
  9465. var colorSpaces = res.get('ColorSpace');
  9466. if (isDict(colorSpaces)) {
  9467. var refcs = colorSpaces.get(cs.name);
  9468. if (refcs) {
  9469. cs = refcs;
  9470. }
  9471. }
  9472. }
  9473. cs = xref.fetchIfRef(cs);
  9474. if (isName(cs)) {
  9475. switch (cs.name) {
  9476. case 'DeviceGray':
  9477. case 'G':
  9478. return 'DeviceGrayCS';
  9479. case 'DeviceRGB':
  9480. case 'RGB':
  9481. return 'DeviceRgbCS';
  9482. case 'DeviceCMYK':
  9483. case 'CMYK':
  9484. return 'DeviceCmykCS';
  9485. case 'Pattern':
  9486. return [
  9487. 'PatternCS',
  9488. null
  9489. ];
  9490. default:
  9491. error('unrecognized colorspace ' + cs.name);
  9492. }
  9493. } else if (isArray(cs)) {
  9494. var mode = xref.fetchIfRef(cs[0]).name;
  9495. var numComps, params, alt, whitePoint, blackPoint, gamma;
  9496. switch (mode) {
  9497. case 'DeviceGray':
  9498. case 'G':
  9499. return 'DeviceGrayCS';
  9500. case 'DeviceRGB':
  9501. case 'RGB':
  9502. return 'DeviceRgbCS';
  9503. case 'DeviceCMYK':
  9504. case 'CMYK':
  9505. return 'DeviceCmykCS';
  9506. case 'CalGray':
  9507. params = xref.fetchIfRef(cs[1]);
  9508. whitePoint = params.getArray('WhitePoint');
  9509. blackPoint = params.getArray('BlackPoint');
  9510. gamma = params.get('Gamma');
  9511. return [
  9512. 'CalGrayCS',
  9513. whitePoint,
  9514. blackPoint,
  9515. gamma
  9516. ];
  9517. case 'CalRGB':
  9518. params = xref.fetchIfRef(cs[1]);
  9519. whitePoint = params.getArray('WhitePoint');
  9520. blackPoint = params.getArray('BlackPoint');
  9521. gamma = params.getArray('Gamma');
  9522. var matrix = params.getArray('Matrix');
  9523. return [
  9524. 'CalRGBCS',
  9525. whitePoint,
  9526. blackPoint,
  9527. gamma,
  9528. matrix
  9529. ];
  9530. case 'ICCBased':
  9531. var stream = xref.fetchIfRef(cs[1]);
  9532. var dict = stream.dict;
  9533. numComps = dict.get('N');
  9534. alt = dict.get('Alternate');
  9535. if (alt) {
  9536. var altIR = ColorSpace.parseToIR(alt, xref, res);
  9537. var altCS = ColorSpace.fromIR(altIR);
  9538. if (altCS.numComps === numComps) {
  9539. return altIR;
  9540. }
  9541. warn('ICCBased color space: Ignoring incorrect /Alternate entry.');
  9542. }
  9543. if (numComps === 1) {
  9544. return 'DeviceGrayCS';
  9545. } else if (numComps === 3) {
  9546. return 'DeviceRgbCS';
  9547. } else if (numComps === 4) {
  9548. return 'DeviceCmykCS';
  9549. }
  9550. break;
  9551. case 'Pattern':
  9552. var basePatternCS = cs[1] || null;
  9553. if (basePatternCS) {
  9554. basePatternCS = ColorSpace.parseToIR(basePatternCS, xref, res);
  9555. }
  9556. return [
  9557. 'PatternCS',
  9558. basePatternCS
  9559. ];
  9560. case 'Indexed':
  9561. case 'I':
  9562. var baseIndexedCS = ColorSpace.parseToIR(cs[1], xref, res);
  9563. var hiVal = xref.fetchIfRef(cs[2]) + 1;
  9564. var lookup = xref.fetchIfRef(cs[3]);
  9565. if (isStream(lookup)) {
  9566. lookup = lookup.getBytes();
  9567. }
  9568. return [
  9569. 'IndexedCS',
  9570. baseIndexedCS,
  9571. hiVal,
  9572. lookup
  9573. ];
  9574. case 'Separation':
  9575. case 'DeviceN':
  9576. var name = xref.fetchIfRef(cs[1]);
  9577. numComps = isArray(name) ? name.length : 1;
  9578. alt = ColorSpace.parseToIR(cs[2], xref, res);
  9579. var tintFnIR = PDFFunction.getIR(xref, xref.fetchIfRef(cs[3]));
  9580. return [
  9581. 'AlternateCS',
  9582. numComps,
  9583. alt,
  9584. tintFnIR
  9585. ];
  9586. case 'Lab':
  9587. params = xref.fetchIfRef(cs[1]);
  9588. whitePoint = params.getArray('WhitePoint');
  9589. blackPoint = params.getArray('BlackPoint');
  9590. var range = params.getArray('Range');
  9591. return [
  9592. 'LabCS',
  9593. whitePoint,
  9594. blackPoint,
  9595. range
  9596. ];
  9597. default:
  9598. error('unimplemented color space object "' + mode + '"');
  9599. }
  9600. } else {
  9601. error('unrecognized color space object: "' + cs + '"');
  9602. }
  9603. return null;
  9604. };
  9605. ColorSpace.isDefaultDecode = function ColorSpace_isDefaultDecode(decode, n) {
  9606. if (!isArray(decode)) {
  9607. return true;
  9608. }
  9609. if (n * 2 !== decode.length) {
  9610. warn('The decode map is not the correct length');
  9611. return true;
  9612. }
  9613. for (var i = 0, ii = decode.length; i < ii; i += 2) {
  9614. if (decode[i] !== 0 || decode[i + 1] !== 1) {
  9615. return false;
  9616. }
  9617. }
  9618. return true;
  9619. };
  9620. ColorSpace.singletons = {
  9621. get gray() {
  9622. return shadow(this, 'gray', new DeviceGrayCS());
  9623. },
  9624. get rgb() {
  9625. return shadow(this, 'rgb', new DeviceRgbCS());
  9626. },
  9627. get cmyk() {
  9628. return shadow(this, 'cmyk', new DeviceCmykCS());
  9629. }
  9630. };
  9631. return ColorSpace;
  9632. }();
  9633. var AlternateCS = function AlternateCSClosure() {
  9634. function AlternateCS(numComps, base, tintFn) {
  9635. this.name = 'Alternate';
  9636. this.numComps = numComps;
  9637. this.defaultColor = new Float32Array(numComps);
  9638. for (var i = 0; i < numComps; ++i) {
  9639. this.defaultColor[i] = 1;
  9640. }
  9641. this.base = base;
  9642. this.tintFn = tintFn;
  9643. this.tmpBuf = new Float32Array(base.numComps);
  9644. }
  9645. AlternateCS.prototype = {
  9646. getRgb: ColorSpace.prototype.getRgb,
  9647. getRgbItem: function AlternateCS_getRgbItem(src, srcOffset, dest, destOffset) {
  9648. var tmpBuf = this.tmpBuf;
  9649. this.tintFn(src, srcOffset, tmpBuf, 0);
  9650. this.base.getRgbItem(tmpBuf, 0, dest, destOffset);
  9651. },
  9652. getRgbBuffer: function AlternateCS_getRgbBuffer(src, srcOffset, count, dest, destOffset, bits, alpha01) {
  9653. var tintFn = this.tintFn;
  9654. var base = this.base;
  9655. var scale = 1 / ((1 << bits) - 1);
  9656. var baseNumComps = base.numComps;
  9657. var usesZeroToOneRange = base.usesZeroToOneRange;
  9658. var isPassthrough = (base.isPassthrough(8) || !usesZeroToOneRange) && alpha01 === 0;
  9659. var pos = isPassthrough ? destOffset : 0;
  9660. var baseBuf = isPassthrough ? dest : new Uint8Array(baseNumComps * count);
  9661. var numComps = this.numComps;
  9662. var scaled = new Float32Array(numComps);
  9663. var tinted = new Float32Array(baseNumComps);
  9664. var i, j;
  9665. for (i = 0; i < count; i++) {
  9666. for (j = 0; j < numComps; j++) {
  9667. scaled[j] = src[srcOffset++] * scale;
  9668. }
  9669. tintFn(scaled, 0, tinted, 0);
  9670. if (usesZeroToOneRange) {
  9671. for (j = 0; j < baseNumComps; j++) {
  9672. baseBuf[pos++] = tinted[j] * 255;
  9673. }
  9674. } else {
  9675. base.getRgbItem(tinted, 0, baseBuf, pos);
  9676. pos += baseNumComps;
  9677. }
  9678. }
  9679. if (!isPassthrough) {
  9680. base.getRgbBuffer(baseBuf, 0, count, dest, destOffset, 8, alpha01);
  9681. }
  9682. },
  9683. getOutputLength: function AlternateCS_getOutputLength(inputLength, alpha01) {
  9684. return this.base.getOutputLength(inputLength * this.base.numComps / this.numComps, alpha01);
  9685. },
  9686. isPassthrough: ColorSpace.prototype.isPassthrough,
  9687. fillRgb: ColorSpace.prototype.fillRgb,
  9688. isDefaultDecode: function AlternateCS_isDefaultDecode(decodeMap) {
  9689. return ColorSpace.isDefaultDecode(decodeMap, this.numComps);
  9690. },
  9691. usesZeroToOneRange: true
  9692. };
  9693. return AlternateCS;
  9694. }();
  9695. var PatternCS = function PatternCSClosure() {
  9696. function PatternCS(baseCS) {
  9697. this.name = 'Pattern';
  9698. this.base = baseCS;
  9699. }
  9700. PatternCS.prototype = {};
  9701. return PatternCS;
  9702. }();
  9703. var IndexedCS = function IndexedCSClosure() {
  9704. function IndexedCS(base, highVal, lookup) {
  9705. this.name = 'Indexed';
  9706. this.numComps = 1;
  9707. this.defaultColor = new Uint8Array(this.numComps);
  9708. this.base = base;
  9709. this.highVal = highVal;
  9710. var baseNumComps = base.numComps;
  9711. var length = baseNumComps * highVal;
  9712. if (isStream(lookup)) {
  9713. this.lookup = new Uint8Array(length);
  9714. var bytes = lookup.getBytes(length);
  9715. this.lookup.set(bytes);
  9716. } else if (isString(lookup)) {
  9717. this.lookup = new Uint8Array(length);
  9718. for (var i = 0; i < length; ++i) {
  9719. this.lookup[i] = lookup.charCodeAt(i);
  9720. }
  9721. } else if (lookup instanceof Uint8Array || lookup instanceof Array) {
  9722. this.lookup = lookup;
  9723. } else {
  9724. error('Unrecognized lookup table: ' + lookup);
  9725. }
  9726. }
  9727. IndexedCS.prototype = {
  9728. getRgb: ColorSpace.prototype.getRgb,
  9729. getRgbItem: function IndexedCS_getRgbItem(src, srcOffset, dest, destOffset) {
  9730. var numComps = this.base.numComps;
  9731. var start = src[srcOffset] * numComps;
  9732. this.base.getRgbItem(this.lookup, start, dest, destOffset);
  9733. },
  9734. getRgbBuffer: function IndexedCS_getRgbBuffer(src, srcOffset, count, dest, destOffset, bits, alpha01) {
  9735. var base = this.base;
  9736. var numComps = base.numComps;
  9737. var outputDelta = base.getOutputLength(numComps, alpha01);
  9738. var lookup = this.lookup;
  9739. for (var i = 0; i < count; ++i) {
  9740. var lookupPos = src[srcOffset++] * numComps;
  9741. base.getRgbBuffer(lookup, lookupPos, 1, dest, destOffset, 8, alpha01);
  9742. destOffset += outputDelta;
  9743. }
  9744. },
  9745. getOutputLength: function IndexedCS_getOutputLength(inputLength, alpha01) {
  9746. return this.base.getOutputLength(inputLength * this.base.numComps, alpha01);
  9747. },
  9748. isPassthrough: ColorSpace.prototype.isPassthrough,
  9749. fillRgb: ColorSpace.prototype.fillRgb,
  9750. isDefaultDecode: function IndexedCS_isDefaultDecode(decodeMap) {
  9751. return true;
  9752. },
  9753. usesZeroToOneRange: true
  9754. };
  9755. return IndexedCS;
  9756. }();
  9757. var DeviceGrayCS = function DeviceGrayCSClosure() {
  9758. function DeviceGrayCS() {
  9759. this.name = 'DeviceGray';
  9760. this.numComps = 1;
  9761. this.defaultColor = new Float32Array(this.numComps);
  9762. }
  9763. DeviceGrayCS.prototype = {
  9764. getRgb: ColorSpace.prototype.getRgb,
  9765. getRgbItem: function DeviceGrayCS_getRgbItem(src, srcOffset, dest, destOffset) {
  9766. var c = src[srcOffset] * 255 | 0;
  9767. c = c < 0 ? 0 : c > 255 ? 255 : c;
  9768. dest[destOffset] = dest[destOffset + 1] = dest[destOffset + 2] = c;
  9769. },
  9770. getRgbBuffer: function DeviceGrayCS_getRgbBuffer(src, srcOffset, count, dest, destOffset, bits, alpha01) {
  9771. var scale = 255 / ((1 << bits) - 1);
  9772. var j = srcOffset, q = destOffset;
  9773. for (var i = 0; i < count; ++i) {
  9774. var c = scale * src[j++] | 0;
  9775. dest[q++] = c;
  9776. dest[q++] = c;
  9777. dest[q++] = c;
  9778. q += alpha01;
  9779. }
  9780. },
  9781. getOutputLength: function DeviceGrayCS_getOutputLength(inputLength, alpha01) {
  9782. return inputLength * (3 + alpha01);
  9783. },
  9784. isPassthrough: ColorSpace.prototype.isPassthrough,
  9785. fillRgb: ColorSpace.prototype.fillRgb,
  9786. isDefaultDecode: function DeviceGrayCS_isDefaultDecode(decodeMap) {
  9787. return ColorSpace.isDefaultDecode(decodeMap, this.numComps);
  9788. },
  9789. usesZeroToOneRange: true
  9790. };
  9791. return DeviceGrayCS;
  9792. }();
  9793. var DeviceRgbCS = function DeviceRgbCSClosure() {
  9794. function DeviceRgbCS() {
  9795. this.name = 'DeviceRGB';
  9796. this.numComps = 3;
  9797. this.defaultColor = new Float32Array(this.numComps);
  9798. }
  9799. DeviceRgbCS.prototype = {
  9800. getRgb: ColorSpace.prototype.getRgb,
  9801. getRgbItem: function DeviceRgbCS_getRgbItem(src, srcOffset, dest, destOffset) {
  9802. var r = src[srcOffset] * 255 | 0;
  9803. var g = src[srcOffset + 1] * 255 | 0;
  9804. var b = src[srcOffset + 2] * 255 | 0;
  9805. dest[destOffset] = r < 0 ? 0 : r > 255 ? 255 : r;
  9806. dest[destOffset + 1] = g < 0 ? 0 : g > 255 ? 255 : g;
  9807. dest[destOffset + 2] = b < 0 ? 0 : b > 255 ? 255 : b;
  9808. },
  9809. getRgbBuffer: function DeviceRgbCS_getRgbBuffer(src, srcOffset, count, dest, destOffset, bits, alpha01) {
  9810. if (bits === 8 && alpha01 === 0) {
  9811. dest.set(src.subarray(srcOffset, srcOffset + count * 3), destOffset);
  9812. return;
  9813. }
  9814. var scale = 255 / ((1 << bits) - 1);
  9815. var j = srcOffset, q = destOffset;
  9816. for (var i = 0; i < count; ++i) {
  9817. dest[q++] = scale * src[j++] | 0;
  9818. dest[q++] = scale * src[j++] | 0;
  9819. dest[q++] = scale * src[j++] | 0;
  9820. q += alpha01;
  9821. }
  9822. },
  9823. getOutputLength: function DeviceRgbCS_getOutputLength(inputLength, alpha01) {
  9824. return inputLength * (3 + alpha01) / 3 | 0;
  9825. },
  9826. isPassthrough: function DeviceRgbCS_isPassthrough(bits) {
  9827. return bits === 8;
  9828. },
  9829. fillRgb: ColorSpace.prototype.fillRgb,
  9830. isDefaultDecode: function DeviceRgbCS_isDefaultDecode(decodeMap) {
  9831. return ColorSpace.isDefaultDecode(decodeMap, this.numComps);
  9832. },
  9833. usesZeroToOneRange: true
  9834. };
  9835. return DeviceRgbCS;
  9836. }();
  9837. var DeviceCmykCS = function DeviceCmykCSClosure() {
  9838. function convertToRgb(src, srcOffset, srcScale, dest, destOffset) {
  9839. var c = src[srcOffset + 0] * srcScale;
  9840. var m = src[srcOffset + 1] * srcScale;
  9841. var y = src[srcOffset + 2] * srcScale;
  9842. var k = src[srcOffset + 3] * srcScale;
  9843. 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;
  9844. 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;
  9845. 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;
  9846. dest[destOffset] = r > 255 ? 255 : r < 0 ? 0 : r;
  9847. dest[destOffset + 1] = g > 255 ? 255 : g < 0 ? 0 : g;
  9848. dest[destOffset + 2] = b > 255 ? 255 : b < 0 ? 0 : b;
  9849. }
  9850. function DeviceCmykCS() {
  9851. this.name = 'DeviceCMYK';
  9852. this.numComps = 4;
  9853. this.defaultColor = new Float32Array(this.numComps);
  9854. this.defaultColor[3] = 1;
  9855. }
  9856. DeviceCmykCS.prototype = {
  9857. getRgb: ColorSpace.prototype.getRgb,
  9858. getRgbItem: function DeviceCmykCS_getRgbItem(src, srcOffset, dest, destOffset) {
  9859. convertToRgb(src, srcOffset, 1, dest, destOffset);
  9860. },
  9861. getRgbBuffer: function DeviceCmykCS_getRgbBuffer(src, srcOffset, count, dest, destOffset, bits, alpha01) {
  9862. var scale = 1 / ((1 << bits) - 1);
  9863. for (var i = 0; i < count; i++) {
  9864. convertToRgb(src, srcOffset, scale, dest, destOffset);
  9865. srcOffset += 4;
  9866. destOffset += 3 + alpha01;
  9867. }
  9868. },
  9869. getOutputLength: function DeviceCmykCS_getOutputLength(inputLength, alpha01) {
  9870. return inputLength / 4 * (3 + alpha01) | 0;
  9871. },
  9872. isPassthrough: ColorSpace.prototype.isPassthrough,
  9873. fillRgb: ColorSpace.prototype.fillRgb,
  9874. isDefaultDecode: function DeviceCmykCS_isDefaultDecode(decodeMap) {
  9875. return ColorSpace.isDefaultDecode(decodeMap, this.numComps);
  9876. },
  9877. usesZeroToOneRange: true
  9878. };
  9879. return DeviceCmykCS;
  9880. }();
  9881. var CalGrayCS = function CalGrayCSClosure() {
  9882. function CalGrayCS(whitePoint, blackPoint, gamma) {
  9883. this.name = 'CalGray';
  9884. this.numComps = 1;
  9885. this.defaultColor = new Float32Array(this.numComps);
  9886. if (!whitePoint) {
  9887. error('WhitePoint missing - required for color space CalGray');
  9888. }
  9889. blackPoint = blackPoint || [
  9890. 0,
  9891. 0,
  9892. 0
  9893. ];
  9894. gamma = gamma || 1;
  9895. this.XW = whitePoint[0];
  9896. this.YW = whitePoint[1];
  9897. this.ZW = whitePoint[2];
  9898. this.XB = blackPoint[0];
  9899. this.YB = blackPoint[1];
  9900. this.ZB = blackPoint[2];
  9901. this.G = gamma;
  9902. if (this.XW < 0 || this.ZW < 0 || this.YW !== 1) {
  9903. error('Invalid WhitePoint components for ' + this.name + ', no fallback available');
  9904. }
  9905. if (this.XB < 0 || this.YB < 0 || this.ZB < 0) {
  9906. info('Invalid BlackPoint for ' + this.name + ', falling back to default');
  9907. this.XB = this.YB = this.ZB = 0;
  9908. }
  9909. if (this.XB !== 0 || this.YB !== 0 || this.ZB !== 0) {
  9910. warn(this.name + ', BlackPoint: XB: ' + this.XB + ', YB: ' + this.YB + ', ZB: ' + this.ZB + ', only default values are supported.');
  9911. }
  9912. if (this.G < 1) {
  9913. info('Invalid Gamma: ' + this.G + ' for ' + this.name + ', falling back to default');
  9914. this.G = 1;
  9915. }
  9916. }
  9917. function convertToRgb(cs, src, srcOffset, dest, destOffset, scale) {
  9918. var A = src[srcOffset] * scale;
  9919. var AG = Math.pow(A, cs.G);
  9920. var L = cs.YW * AG;
  9921. var val = Math.max(295.8 * Math.pow(L, 0.333333333333333333) - 40.8, 0) | 0;
  9922. dest[destOffset] = val;
  9923. dest[destOffset + 1] = val;
  9924. dest[destOffset + 2] = val;
  9925. }
  9926. CalGrayCS.prototype = {
  9927. getRgb: ColorSpace.prototype.getRgb,
  9928. getRgbItem: function CalGrayCS_getRgbItem(src, srcOffset, dest, destOffset) {
  9929. convertToRgb(this, src, srcOffset, dest, destOffset, 1);
  9930. },
  9931. getRgbBuffer: function CalGrayCS_getRgbBuffer(src, srcOffset, count, dest, destOffset, bits, alpha01) {
  9932. var scale = 1 / ((1 << bits) - 1);
  9933. for (var i = 0; i < count; ++i) {
  9934. convertToRgb(this, src, srcOffset, dest, destOffset, scale);
  9935. srcOffset += 1;
  9936. destOffset += 3 + alpha01;
  9937. }
  9938. },
  9939. getOutputLength: function CalGrayCS_getOutputLength(inputLength, alpha01) {
  9940. return inputLength * (3 + alpha01);
  9941. },
  9942. isPassthrough: ColorSpace.prototype.isPassthrough,
  9943. fillRgb: ColorSpace.prototype.fillRgb,
  9944. isDefaultDecode: function CalGrayCS_isDefaultDecode(decodeMap) {
  9945. return ColorSpace.isDefaultDecode(decodeMap, this.numComps);
  9946. },
  9947. usesZeroToOneRange: true
  9948. };
  9949. return CalGrayCS;
  9950. }();
  9951. var CalRGBCS = function CalRGBCSClosure() {
  9952. var BRADFORD_SCALE_MATRIX = new Float32Array([
  9953. 0.8951,
  9954. 0.2664,
  9955. -0.1614,
  9956. -0.7502,
  9957. 1.7135,
  9958. 0.0367,
  9959. 0.0389,
  9960. -0.0685,
  9961. 1.0296
  9962. ]);
  9963. var BRADFORD_SCALE_INVERSE_MATRIX = new Float32Array([
  9964. 0.9869929,
  9965. -0.1470543,
  9966. 0.1599627,
  9967. 0.4323053,
  9968. 0.5183603,
  9969. 0.0492912,
  9970. -0.0085287,
  9971. 0.0400428,
  9972. 0.9684867
  9973. ]);
  9974. var SRGB_D65_XYZ_TO_RGB_MATRIX = new Float32Array([
  9975. 3.2404542,
  9976. -1.5371385,
  9977. -0.4985314,
  9978. -0.9692660,
  9979. 1.8760108,
  9980. 0.0415560,
  9981. 0.0556434,
  9982. -0.2040259,
  9983. 1.0572252
  9984. ]);
  9985. var FLAT_WHITEPOINT_MATRIX = new Float32Array([
  9986. 1,
  9987. 1,
  9988. 1
  9989. ]);
  9990. var tempNormalizeMatrix = new Float32Array(3);
  9991. var tempConvertMatrix1 = new Float32Array(3);
  9992. var tempConvertMatrix2 = new Float32Array(3);
  9993. var DECODE_L_CONSTANT = Math.pow((8 + 16) / 116, 3) / 8.0;
  9994. function CalRGBCS(whitePoint, blackPoint, gamma, matrix) {
  9995. this.name = 'CalRGB';
  9996. this.numComps = 3;
  9997. this.defaultColor = new Float32Array(this.numComps);
  9998. if (!whitePoint) {
  9999. error('WhitePoint missing - required for color space CalRGB');
  10000. }
  10001. blackPoint = blackPoint || new Float32Array(3);
  10002. gamma = gamma || new Float32Array([
  10003. 1,
  10004. 1,
  10005. 1
  10006. ]);
  10007. matrix = matrix || new Float32Array([
  10008. 1,
  10009. 0,
  10010. 0,
  10011. 0,
  10012. 1,
  10013. 0,
  10014. 0,
  10015. 0,
  10016. 1
  10017. ]);
  10018. var XW = whitePoint[0];
  10019. var YW = whitePoint[1];
  10020. var ZW = whitePoint[2];
  10021. this.whitePoint = whitePoint;
  10022. var XB = blackPoint[0];
  10023. var YB = blackPoint[1];
  10024. var ZB = blackPoint[2];
  10025. this.blackPoint = blackPoint;
  10026. this.GR = gamma[0];
  10027. this.GG = gamma[1];
  10028. this.GB = gamma[2];
  10029. this.MXA = matrix[0];
  10030. this.MYA = matrix[1];
  10031. this.MZA = matrix[2];
  10032. this.MXB = matrix[3];
  10033. this.MYB = matrix[4];
  10034. this.MZB = matrix[5];
  10035. this.MXC = matrix[6];
  10036. this.MYC = matrix[7];
  10037. this.MZC = matrix[8];
  10038. if (XW < 0 || ZW < 0 || YW !== 1) {
  10039. error('Invalid WhitePoint components for ' + this.name + ', no fallback available');
  10040. }
  10041. if (XB < 0 || YB < 0 || ZB < 0) {
  10042. info('Invalid BlackPoint for ' + this.name + ' [' + XB + ', ' + YB + ', ' + ZB + '], falling back to default');
  10043. this.blackPoint = new Float32Array(3);
  10044. }
  10045. if (this.GR < 0 || this.GG < 0 || this.GB < 0) {
  10046. info('Invalid Gamma [' + this.GR + ', ' + this.GG + ', ' + this.GB + '] for ' + this.name + ', falling back to default');
  10047. this.GR = this.GG = this.GB = 1;
  10048. }
  10049. 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) {
  10050. 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');
  10051. this.MXA = this.MYB = this.MZC = 1;
  10052. this.MXB = this.MYA = this.MZA = this.MXC = this.MYC = this.MZB = 0;
  10053. }
  10054. }
  10055. function matrixProduct(a, b, result) {
  10056. result[0] = a[0] * b[0] + a[1] * b[1] + a[2] * b[2];
  10057. result[1] = a[3] * b[0] + a[4] * b[1] + a[5] * b[2];
  10058. result[2] = a[6] * b[0] + a[7] * b[1] + a[8] * b[2];
  10059. }
  10060. function convertToFlat(sourceWhitePoint, LMS, result) {
  10061. result[0] = LMS[0] * 1 / sourceWhitePoint[0];
  10062. result[1] = LMS[1] * 1 / sourceWhitePoint[1];
  10063. result[2] = LMS[2] * 1 / sourceWhitePoint[2];
  10064. }
  10065. function convertToD65(sourceWhitePoint, LMS, result) {
  10066. var D65X = 0.95047;
  10067. var D65Y = 1;
  10068. var D65Z = 1.08883;
  10069. result[0] = LMS[0] * D65X / sourceWhitePoint[0];
  10070. result[1] = LMS[1] * D65Y / sourceWhitePoint[1];
  10071. result[2] = LMS[2] * D65Z / sourceWhitePoint[2];
  10072. }
  10073. function sRGBTransferFunction(color) {
  10074. if (color <= 0.0031308) {
  10075. return adjustToRange(0, 1, 12.92 * color);
  10076. }
  10077. return adjustToRange(0, 1, (1 + 0.055) * Math.pow(color, 1 / 2.4) - 0.055);
  10078. }
  10079. function adjustToRange(min, max, value) {
  10080. return Math.max(min, Math.min(max, value));
  10081. }
  10082. function decodeL(L) {
  10083. if (L < 0) {
  10084. return -decodeL(-L);
  10085. }
  10086. if (L > 8.0) {
  10087. return Math.pow((L + 16) / 116, 3);
  10088. }
  10089. return L * DECODE_L_CONSTANT;
  10090. }
  10091. function compensateBlackPoint(sourceBlackPoint, XYZ_Flat, result) {
  10092. if (sourceBlackPoint[0] === 0 && sourceBlackPoint[1] === 0 && sourceBlackPoint[2] === 0) {
  10093. result[0] = XYZ_Flat[0];
  10094. result[1] = XYZ_Flat[1];
  10095. result[2] = XYZ_Flat[2];
  10096. return;
  10097. }
  10098. var zeroDecodeL = decodeL(0);
  10099. var X_DST = zeroDecodeL;
  10100. var X_SRC = decodeL(sourceBlackPoint[0]);
  10101. var Y_DST = zeroDecodeL;
  10102. var Y_SRC = decodeL(sourceBlackPoint[1]);
  10103. var Z_DST = zeroDecodeL;
  10104. var Z_SRC = decodeL(sourceBlackPoint[2]);
  10105. var X_Scale = (1 - X_DST) / (1 - X_SRC);
  10106. var X_Offset = 1 - X_Scale;
  10107. var Y_Scale = (1 - Y_DST) / (1 - Y_SRC);
  10108. var Y_Offset = 1 - Y_Scale;
  10109. var Z_Scale = (1 - Z_DST) / (1 - Z_SRC);
  10110. var Z_Offset = 1 - Z_Scale;
  10111. result[0] = XYZ_Flat[0] * X_Scale + X_Offset;
  10112. result[1] = XYZ_Flat[1] * Y_Scale + Y_Offset;
  10113. result[2] = XYZ_Flat[2] * Z_Scale + Z_Offset;
  10114. }
  10115. function normalizeWhitePointToFlat(sourceWhitePoint, XYZ_In, result) {
  10116. if (sourceWhitePoint[0] === 1 && sourceWhitePoint[2] === 1) {
  10117. result[0] = XYZ_In[0];
  10118. result[1] = XYZ_In[1];
  10119. result[2] = XYZ_In[2];
  10120. return;
  10121. }
  10122. var LMS = result;
  10123. matrixProduct(BRADFORD_SCALE_MATRIX, XYZ_In, LMS);
  10124. var LMS_Flat = tempNormalizeMatrix;
  10125. convertToFlat(sourceWhitePoint, LMS, LMS_Flat);
  10126. matrixProduct(BRADFORD_SCALE_INVERSE_MATRIX, LMS_Flat, result);
  10127. }
  10128. function normalizeWhitePointToD65(sourceWhitePoint, XYZ_In, result) {
  10129. var LMS = result;
  10130. matrixProduct(BRADFORD_SCALE_MATRIX, XYZ_In, LMS);
  10131. var LMS_D65 = tempNormalizeMatrix;
  10132. convertToD65(sourceWhitePoint, LMS, LMS_D65);
  10133. matrixProduct(BRADFORD_SCALE_INVERSE_MATRIX, LMS_D65, result);
  10134. }
  10135. function convertToRgb(cs, src, srcOffset, dest, destOffset, scale) {
  10136. var A = adjustToRange(0, 1, src[srcOffset] * scale);
  10137. var B = adjustToRange(0, 1, src[srcOffset + 1] * scale);
  10138. var C = adjustToRange(0, 1, src[srcOffset + 2] * scale);
  10139. var AGR = Math.pow(A, cs.GR);
  10140. var BGG = Math.pow(B, cs.GG);
  10141. var CGB = Math.pow(C, cs.GB);
  10142. var X = cs.MXA * AGR + cs.MXB * BGG + cs.MXC * CGB;
  10143. var Y = cs.MYA * AGR + cs.MYB * BGG + cs.MYC * CGB;
  10144. var Z = cs.MZA * AGR + cs.MZB * BGG + cs.MZC * CGB;
  10145. var XYZ = tempConvertMatrix1;
  10146. XYZ[0] = X;
  10147. XYZ[1] = Y;
  10148. XYZ[2] = Z;
  10149. var XYZ_Flat = tempConvertMatrix2;
  10150. normalizeWhitePointToFlat(cs.whitePoint, XYZ, XYZ_Flat);
  10151. var XYZ_Black = tempConvertMatrix1;
  10152. compensateBlackPoint(cs.blackPoint, XYZ_Flat, XYZ_Black);
  10153. var XYZ_D65 = tempConvertMatrix2;
  10154. normalizeWhitePointToD65(FLAT_WHITEPOINT_MATRIX, XYZ_Black, XYZ_D65);
  10155. var SRGB = tempConvertMatrix1;
  10156. matrixProduct(SRGB_D65_XYZ_TO_RGB_MATRIX, XYZ_D65, SRGB);
  10157. var sR = sRGBTransferFunction(SRGB[0]);
  10158. var sG = sRGBTransferFunction(SRGB[1]);
  10159. var sB = sRGBTransferFunction(SRGB[2]);
  10160. dest[destOffset] = Math.round(sR * 255);
  10161. dest[destOffset + 1] = Math.round(sG * 255);
  10162. dest[destOffset + 2] = Math.round(sB * 255);
  10163. }
  10164. CalRGBCS.prototype = {
  10165. getRgb: function CalRGBCS_getRgb(src, srcOffset) {
  10166. var rgb = new Uint8Array(3);
  10167. this.getRgbItem(src, srcOffset, rgb, 0);
  10168. return rgb;
  10169. },
  10170. getRgbItem: function CalRGBCS_getRgbItem(src, srcOffset, dest, destOffset) {
  10171. convertToRgb(this, src, srcOffset, dest, destOffset, 1);
  10172. },
  10173. getRgbBuffer: function CalRGBCS_getRgbBuffer(src, srcOffset, count, dest, destOffset, bits, alpha01) {
  10174. var scale = 1 / ((1 << bits) - 1);
  10175. for (var i = 0; i < count; ++i) {
  10176. convertToRgb(this, src, srcOffset, dest, destOffset, scale);
  10177. srcOffset += 3;
  10178. destOffset += 3 + alpha01;
  10179. }
  10180. },
  10181. getOutputLength: function CalRGBCS_getOutputLength(inputLength, alpha01) {
  10182. return inputLength * (3 + alpha01) / 3 | 0;
  10183. },
  10184. isPassthrough: ColorSpace.prototype.isPassthrough,
  10185. fillRgb: ColorSpace.prototype.fillRgb,
  10186. isDefaultDecode: function CalRGBCS_isDefaultDecode(decodeMap) {
  10187. return ColorSpace.isDefaultDecode(decodeMap, this.numComps);
  10188. },
  10189. usesZeroToOneRange: true
  10190. };
  10191. return CalRGBCS;
  10192. }();
  10193. var LabCS = function LabCSClosure() {
  10194. function LabCS(whitePoint, blackPoint, range) {
  10195. this.name = 'Lab';
  10196. this.numComps = 3;
  10197. this.defaultColor = new Float32Array(this.numComps);
  10198. if (!whitePoint) {
  10199. error('WhitePoint missing - required for color space Lab');
  10200. }
  10201. blackPoint = blackPoint || [
  10202. 0,
  10203. 0,
  10204. 0
  10205. ];
  10206. range = range || [
  10207. -100,
  10208. 100,
  10209. -100,
  10210. 100
  10211. ];
  10212. this.XW = whitePoint[0];
  10213. this.YW = whitePoint[1];
  10214. this.ZW = whitePoint[2];
  10215. this.amin = range[0];
  10216. this.amax = range[1];
  10217. this.bmin = range[2];
  10218. this.bmax = range[3];
  10219. this.XB = blackPoint[0];
  10220. this.YB = blackPoint[1];
  10221. this.ZB = blackPoint[2];
  10222. if (this.XW < 0 || this.ZW < 0 || this.YW !== 1) {
  10223. error('Invalid WhitePoint components, no fallback available');
  10224. }
  10225. if (this.XB < 0 || this.YB < 0 || this.ZB < 0) {
  10226. info('Invalid BlackPoint, falling back to default');
  10227. this.XB = this.YB = this.ZB = 0;
  10228. }
  10229. if (this.amin > this.amax || this.bmin > this.bmax) {
  10230. info('Invalid Range, falling back to defaults');
  10231. this.amin = -100;
  10232. this.amax = 100;
  10233. this.bmin = -100;
  10234. this.bmax = 100;
  10235. }
  10236. }
  10237. function fn_g(x) {
  10238. var result;
  10239. if (x >= 6 / 29) {
  10240. result = x * x * x;
  10241. } else {
  10242. result = 108 / 841 * (x - 4 / 29);
  10243. }
  10244. return result;
  10245. }
  10246. function decode(value, high1, low2, high2) {
  10247. return low2 + value * (high2 - low2) / high1;
  10248. }
  10249. function convertToRgb(cs, src, srcOffset, maxVal, dest, destOffset) {
  10250. var Ls = src[srcOffset];
  10251. var as = src[srcOffset + 1];
  10252. var bs = src[srcOffset + 2];
  10253. if (maxVal !== false) {
  10254. Ls = decode(Ls, maxVal, 0, 100);
  10255. as = decode(as, maxVal, cs.amin, cs.amax);
  10256. bs = decode(bs, maxVal, cs.bmin, cs.bmax);
  10257. }
  10258. as = as > cs.amax ? cs.amax : as < cs.amin ? cs.amin : as;
  10259. bs = bs > cs.bmax ? cs.bmax : bs < cs.bmin ? cs.bmin : bs;
  10260. var M = (Ls + 16) / 116;
  10261. var L = M + as / 500;
  10262. var N = M - bs / 200;
  10263. var X = cs.XW * fn_g(L);
  10264. var Y = cs.YW * fn_g(M);
  10265. var Z = cs.ZW * fn_g(N);
  10266. var r, g, b;
  10267. if (cs.ZW < 1) {
  10268. r = X * 3.1339 + Y * -1.6170 + Z * -0.4906;
  10269. g = X * -0.9785 + Y * 1.9160 + Z * 0.0333;
  10270. b = X * 0.0720 + Y * -0.2290 + Z * 1.4057;
  10271. } else {
  10272. r = X * 3.2406 + Y * -1.5372 + Z * -0.4986;
  10273. g = X * -0.9689 + Y * 1.8758 + Z * 0.0415;
  10274. b = X * 0.0557 + Y * -0.2040 + Z * 1.0570;
  10275. }
  10276. dest[destOffset] = r <= 0 ? 0 : r >= 1 ? 255 : Math.sqrt(r) * 255 | 0;
  10277. dest[destOffset + 1] = g <= 0 ? 0 : g >= 1 ? 255 : Math.sqrt(g) * 255 | 0;
  10278. dest[destOffset + 2] = b <= 0 ? 0 : b >= 1 ? 255 : Math.sqrt(b) * 255 | 0;
  10279. }
  10280. LabCS.prototype = {
  10281. getRgb: ColorSpace.prototype.getRgb,
  10282. getRgbItem: function LabCS_getRgbItem(src, srcOffset, dest, destOffset) {
  10283. convertToRgb(this, src, srcOffset, false, dest, destOffset);
  10284. },
  10285. getRgbBuffer: function LabCS_getRgbBuffer(src, srcOffset, count, dest, destOffset, bits, alpha01) {
  10286. var maxVal = (1 << bits) - 1;
  10287. for (var i = 0; i < count; i++) {
  10288. convertToRgb(this, src, srcOffset, maxVal, dest, destOffset);
  10289. srcOffset += 3;
  10290. destOffset += 3 + alpha01;
  10291. }
  10292. },
  10293. getOutputLength: function LabCS_getOutputLength(inputLength, alpha01) {
  10294. return inputLength * (3 + alpha01) / 3 | 0;
  10295. },
  10296. isPassthrough: ColorSpace.prototype.isPassthrough,
  10297. fillRgb: ColorSpace.prototype.fillRgb,
  10298. isDefaultDecode: function LabCS_isDefaultDecode(decodeMap) {
  10299. return true;
  10300. },
  10301. usesZeroToOneRange: false
  10302. };
  10303. return LabCS;
  10304. }();
  10305. exports.ColorSpace = ColorSpace;
  10306. /***/ }),
  10307. /* 5 */
  10308. /***/ (function(module, exports, __w_pdfjs_require__) {
  10309. "use strict";
  10310. var ExpertEncoding = [
  10311. '',
  10312. '',
  10313. '',
  10314. '',
  10315. '',
  10316. '',
  10317. '',
  10318. '',
  10319. '',
  10320. '',
  10321. '',
  10322. '',
  10323. '',
  10324. '',
  10325. '',
  10326. '',
  10327. '',
  10328. '',
  10329. '',
  10330. '',
  10331. '',
  10332. '',
  10333. '',
  10334. '',
  10335. '',
  10336. '',
  10337. '',
  10338. '',
  10339. '',
  10340. '',
  10341. '',
  10342. '',
  10343. 'space',
  10344. 'exclamsmall',
  10345. 'Hungarumlautsmall',
  10346. '',
  10347. 'dollaroldstyle',
  10348. 'dollarsuperior',
  10349. 'ampersandsmall',
  10350. 'Acutesmall',
  10351. 'parenleftsuperior',
  10352. 'parenrightsuperior',
  10353. 'twodotenleader',
  10354. 'onedotenleader',
  10355. 'comma',
  10356. 'hyphen',
  10357. 'period',
  10358. 'fraction',
  10359. 'zerooldstyle',
  10360. 'oneoldstyle',
  10361. 'twooldstyle',
  10362. 'threeoldstyle',
  10363. 'fouroldstyle',
  10364. 'fiveoldstyle',
  10365. 'sixoldstyle',
  10366. 'sevenoldstyle',
  10367. 'eightoldstyle',
  10368. 'nineoldstyle',
  10369. 'colon',
  10370. 'semicolon',
  10371. 'commasuperior',
  10372. 'threequartersemdash',
  10373. 'periodsuperior',
  10374. 'questionsmall',
  10375. '',
  10376. 'asuperior',
  10377. 'bsuperior',
  10378. 'centsuperior',
  10379. 'dsuperior',
  10380. 'esuperior',
  10381. '',
  10382. '',
  10383. 'isuperior',
  10384. '',
  10385. '',
  10386. 'lsuperior',
  10387. 'msuperior',
  10388. 'nsuperior',
  10389. 'osuperior',
  10390. '',
  10391. '',
  10392. 'rsuperior',
  10393. 'ssuperior',
  10394. 'tsuperior',
  10395. '',
  10396. 'ff',
  10397. 'fi',
  10398. 'fl',
  10399. 'ffi',
  10400. 'ffl',
  10401. 'parenleftinferior',
  10402. '',
  10403. 'parenrightinferior',
  10404. 'Circumflexsmall',
  10405. 'hyphensuperior',
  10406. 'Gravesmall',
  10407. 'Asmall',
  10408. 'Bsmall',
  10409. 'Csmall',
  10410. 'Dsmall',
  10411. 'Esmall',
  10412. 'Fsmall',
  10413. 'Gsmall',
  10414. 'Hsmall',
  10415. 'Ismall',
  10416. 'Jsmall',
  10417. 'Ksmall',
  10418. 'Lsmall',
  10419. 'Msmall',
  10420. 'Nsmall',
  10421. 'Osmall',
  10422. 'Psmall',
  10423. 'Qsmall',
  10424. 'Rsmall',
  10425. 'Ssmall',
  10426. 'Tsmall',
  10427. 'Usmall',
  10428. 'Vsmall',
  10429. 'Wsmall',
  10430. 'Xsmall',
  10431. 'Ysmall',
  10432. 'Zsmall',
  10433. 'colonmonetary',
  10434. 'onefitted',
  10435. 'rupiah',
  10436. 'Tildesmall',
  10437. '',
  10438. '',
  10439. '',
  10440. '',
  10441. '',
  10442. '',
  10443. '',
  10444. '',
  10445. '',
  10446. '',
  10447. '',
  10448. '',
  10449. '',
  10450. '',
  10451. '',
  10452. '',
  10453. '',
  10454. '',
  10455. '',
  10456. '',
  10457. '',
  10458. '',
  10459. '',
  10460. '',
  10461. '',
  10462. '',
  10463. '',
  10464. '',
  10465. '',
  10466. '',
  10467. '',
  10468. '',
  10469. '',
  10470. '',
  10471. 'exclamdownsmall',
  10472. 'centoldstyle',
  10473. 'Lslashsmall',
  10474. '',
  10475. '',
  10476. 'Scaronsmall',
  10477. 'Zcaronsmall',
  10478. 'Dieresissmall',
  10479. 'Brevesmall',
  10480. 'Caronsmall',
  10481. '',
  10482. 'Dotaccentsmall',
  10483. '',
  10484. '',
  10485. 'Macronsmall',
  10486. '',
  10487. '',
  10488. 'figuredash',
  10489. 'hypheninferior',
  10490. '',
  10491. '',
  10492. 'Ogoneksmall',
  10493. 'Ringsmall',
  10494. 'Cedillasmall',
  10495. '',
  10496. '',
  10497. '',
  10498. 'onequarter',
  10499. 'onehalf',
  10500. 'threequarters',
  10501. 'questiondownsmall',
  10502. 'oneeighth',
  10503. 'threeeighths',
  10504. 'fiveeighths',
  10505. 'seveneighths',
  10506. 'onethird',
  10507. 'twothirds',
  10508. '',
  10509. '',
  10510. 'zerosuperior',
  10511. 'onesuperior',
  10512. 'twosuperior',
  10513. 'threesuperior',
  10514. 'foursuperior',
  10515. 'fivesuperior',
  10516. 'sixsuperior',
  10517. 'sevensuperior',
  10518. 'eightsuperior',
  10519. 'ninesuperior',
  10520. 'zeroinferior',
  10521. 'oneinferior',
  10522. 'twoinferior',
  10523. 'threeinferior',
  10524. 'fourinferior',
  10525. 'fiveinferior',
  10526. 'sixinferior',
  10527. 'seveninferior',
  10528. 'eightinferior',
  10529. 'nineinferior',
  10530. 'centinferior',
  10531. 'dollarinferior',
  10532. 'periodinferior',
  10533. 'commainferior',
  10534. 'Agravesmall',
  10535. 'Aacutesmall',
  10536. 'Acircumflexsmall',
  10537. 'Atildesmall',
  10538. 'Adieresissmall',
  10539. 'Aringsmall',
  10540. 'AEsmall',
  10541. 'Ccedillasmall',
  10542. 'Egravesmall',
  10543. 'Eacutesmall',
  10544. 'Ecircumflexsmall',
  10545. 'Edieresissmall',
  10546. 'Igravesmall',
  10547. 'Iacutesmall',
  10548. 'Icircumflexsmall',
  10549. 'Idieresissmall',
  10550. 'Ethsmall',
  10551. 'Ntildesmall',
  10552. 'Ogravesmall',
  10553. 'Oacutesmall',
  10554. 'Ocircumflexsmall',
  10555. 'Otildesmall',
  10556. 'Odieresissmall',
  10557. 'OEsmall',
  10558. 'Oslashsmall',
  10559. 'Ugravesmall',
  10560. 'Uacutesmall',
  10561. 'Ucircumflexsmall',
  10562. 'Udieresissmall',
  10563. 'Yacutesmall',
  10564. 'Thornsmall',
  10565. 'Ydieresissmall'
  10566. ];
  10567. var MacExpertEncoding = [
  10568. '',
  10569. '',
  10570. '',
  10571. '',
  10572. '',
  10573. '',
  10574. '',
  10575. '',
  10576. '',
  10577. '',
  10578. '',
  10579. '',
  10580. '',
  10581. '',
  10582. '',
  10583. '',
  10584. '',
  10585. '',
  10586. '',
  10587. '',
  10588. '',
  10589. '',
  10590. '',
  10591. '',
  10592. '',
  10593. '',
  10594. '',
  10595. '',
  10596. '',
  10597. '',
  10598. '',
  10599. '',
  10600. 'space',
  10601. 'exclamsmall',
  10602. 'Hungarumlautsmall',
  10603. 'centoldstyle',
  10604. 'dollaroldstyle',
  10605. 'dollarsuperior',
  10606. 'ampersandsmall',
  10607. 'Acutesmall',
  10608. 'parenleftsuperior',
  10609. 'parenrightsuperior',
  10610. 'twodotenleader',
  10611. 'onedotenleader',
  10612. 'comma',
  10613. 'hyphen',
  10614. 'period',
  10615. 'fraction',
  10616. 'zerooldstyle',
  10617. 'oneoldstyle',
  10618. 'twooldstyle',
  10619. 'threeoldstyle',
  10620. 'fouroldstyle',
  10621. 'fiveoldstyle',
  10622. 'sixoldstyle',
  10623. 'sevenoldstyle',
  10624. 'eightoldstyle',
  10625. 'nineoldstyle',
  10626. 'colon',
  10627. 'semicolon',
  10628. '',
  10629. 'threequartersemdash',
  10630. '',
  10631. 'questionsmall',
  10632. '',
  10633. '',
  10634. '',
  10635. '',
  10636. 'Ethsmall',
  10637. '',
  10638. '',
  10639. 'onequarter',
  10640. 'onehalf',
  10641. 'threequarters',
  10642. 'oneeighth',
  10643. 'threeeighths',
  10644. 'fiveeighths',
  10645. 'seveneighths',
  10646. 'onethird',
  10647. 'twothirds',
  10648. '',
  10649. '',
  10650. '',
  10651. '',
  10652. '',
  10653. '',
  10654. 'ff',
  10655. 'fi',
  10656. 'fl',
  10657. 'ffi',
  10658. 'ffl',
  10659. 'parenleftinferior',
  10660. '',
  10661. 'parenrightinferior',
  10662. 'Circumflexsmall',
  10663. 'hypheninferior',
  10664. 'Gravesmall',
  10665. 'Asmall',
  10666. 'Bsmall',
  10667. 'Csmall',
  10668. 'Dsmall',
  10669. 'Esmall',
  10670. 'Fsmall',
  10671. 'Gsmall',
  10672. 'Hsmall',
  10673. 'Ismall',
  10674. 'Jsmall',
  10675. 'Ksmall',
  10676. 'Lsmall',
  10677. 'Msmall',
  10678. 'Nsmall',
  10679. 'Osmall',
  10680. 'Psmall',
  10681. 'Qsmall',
  10682. 'Rsmall',
  10683. 'Ssmall',
  10684. 'Tsmall',
  10685. 'Usmall',
  10686. 'Vsmall',
  10687. 'Wsmall',
  10688. 'Xsmall',
  10689. 'Ysmall',
  10690. 'Zsmall',
  10691. 'colonmonetary',
  10692. 'onefitted',
  10693. 'rupiah',
  10694. 'Tildesmall',
  10695. '',
  10696. '',
  10697. 'asuperior',
  10698. 'centsuperior',
  10699. '',
  10700. '',
  10701. '',
  10702. '',
  10703. 'Aacutesmall',
  10704. 'Agravesmall',
  10705. 'Acircumflexsmall',
  10706. 'Adieresissmall',
  10707. 'Atildesmall',
  10708. 'Aringsmall',
  10709. 'Ccedillasmall',
  10710. 'Eacutesmall',
  10711. 'Egravesmall',
  10712. 'Ecircumflexsmall',
  10713. 'Edieresissmall',
  10714. 'Iacutesmall',
  10715. 'Igravesmall',
  10716. 'Icircumflexsmall',
  10717. 'Idieresissmall',
  10718. 'Ntildesmall',
  10719. 'Oacutesmall',
  10720. 'Ogravesmall',
  10721. 'Ocircumflexsmall',
  10722. 'Odieresissmall',
  10723. 'Otildesmall',
  10724. 'Uacutesmall',
  10725. 'Ugravesmall',
  10726. 'Ucircumflexsmall',
  10727. 'Udieresissmall',
  10728. '',
  10729. 'eightsuperior',
  10730. 'fourinferior',
  10731. 'threeinferior',
  10732. 'sixinferior',
  10733. 'eightinferior',
  10734. 'seveninferior',
  10735. 'Scaronsmall',
  10736. '',
  10737. 'centinferior',
  10738. 'twoinferior',
  10739. '',
  10740. 'Dieresissmall',
  10741. '',
  10742. 'Caronsmall',
  10743. 'osuperior',
  10744. 'fiveinferior',
  10745. '',
  10746. 'commainferior',
  10747. 'periodinferior',
  10748. 'Yacutesmall',
  10749. '',
  10750. 'dollarinferior',
  10751. '',
  10752. 'Thornsmall',
  10753. '',
  10754. 'nineinferior',
  10755. 'zeroinferior',
  10756. 'Zcaronsmall',
  10757. 'AEsmall',
  10758. 'Oslashsmall',
  10759. 'questiondownsmall',
  10760. 'oneinferior',
  10761. 'Lslashsmall',
  10762. '',
  10763. '',
  10764. '',
  10765. '',
  10766. '',
  10767. '',
  10768. 'Cedillasmall',
  10769. '',
  10770. '',
  10771. '',
  10772. '',
  10773. '',
  10774. 'OEsmall',
  10775. 'figuredash',
  10776. 'hyphensuperior',
  10777. '',
  10778. '',
  10779. '',
  10780. '',
  10781. 'exclamdownsmall',
  10782. '',
  10783. 'Ydieresissmall',
  10784. '',
  10785. 'onesuperior',
  10786. 'twosuperior',
  10787. 'threesuperior',
  10788. 'foursuperior',
  10789. 'fivesuperior',
  10790. 'sixsuperior',
  10791. 'sevensuperior',
  10792. 'ninesuperior',
  10793. 'zerosuperior',
  10794. '',
  10795. 'esuperior',
  10796. 'rsuperior',
  10797. 'tsuperior',
  10798. '',
  10799. '',
  10800. 'isuperior',
  10801. 'ssuperior',
  10802. 'dsuperior',
  10803. '',
  10804. '',
  10805. '',
  10806. '',
  10807. '',
  10808. 'lsuperior',
  10809. 'Ogoneksmall',
  10810. 'Brevesmall',
  10811. 'Macronsmall',
  10812. 'bsuperior',
  10813. 'nsuperior',
  10814. 'msuperior',
  10815. 'commasuperior',
  10816. 'periodsuperior',
  10817. 'Dotaccentsmall',
  10818. 'Ringsmall'
  10819. ];
  10820. var MacRomanEncoding = [
  10821. '',
  10822. '',
  10823. '',
  10824. '',
  10825. '',
  10826. '',
  10827. '',
  10828. '',
  10829. '',
  10830. '',
  10831. '',
  10832. '',
  10833. '',
  10834. '',
  10835. '',
  10836. '',
  10837. '',
  10838. '',
  10839. '',
  10840. '',
  10841. '',
  10842. '',
  10843. '',
  10844. '',
  10845. '',
  10846. '',
  10847. '',
  10848. '',
  10849. '',
  10850. '',
  10851. '',
  10852. '',
  10853. 'space',
  10854. 'exclam',
  10855. 'quotedbl',
  10856. 'numbersign',
  10857. 'dollar',
  10858. 'percent',
  10859. 'ampersand',
  10860. 'quotesingle',
  10861. 'parenleft',
  10862. 'parenright',
  10863. 'asterisk',
  10864. 'plus',
  10865. 'comma',
  10866. 'hyphen',
  10867. 'period',
  10868. 'slash',
  10869. 'zero',
  10870. 'one',
  10871. 'two',
  10872. 'three',
  10873. 'four',
  10874. 'five',
  10875. 'six',
  10876. 'seven',
  10877. 'eight',
  10878. 'nine',
  10879. 'colon',
  10880. 'semicolon',
  10881. 'less',
  10882. 'equal',
  10883. 'greater',
  10884. 'question',
  10885. 'at',
  10886. 'A',
  10887. 'B',
  10888. 'C',
  10889. 'D',
  10890. 'E',
  10891. 'F',
  10892. 'G',
  10893. 'H',
  10894. 'I',
  10895. 'J',
  10896. 'K',
  10897. 'L',
  10898. 'M',
  10899. 'N',
  10900. 'O',
  10901. 'P',
  10902. 'Q',
  10903. 'R',
  10904. 'S',
  10905. 'T',
  10906. 'U',
  10907. 'V',
  10908. 'W',
  10909. 'X',
  10910. 'Y',
  10911. 'Z',
  10912. 'bracketleft',
  10913. 'backslash',
  10914. 'bracketright',
  10915. 'asciicircum',
  10916. 'underscore',
  10917. 'grave',
  10918. 'a',
  10919. 'b',
  10920. 'c',
  10921. 'd',
  10922. 'e',
  10923. 'f',
  10924. 'g',
  10925. 'h',
  10926. 'i',
  10927. 'j',
  10928. 'k',
  10929. 'l',
  10930. 'm',
  10931. 'n',
  10932. 'o',
  10933. 'p',
  10934. 'q',
  10935. 'r',
  10936. 's',
  10937. 't',
  10938. 'u',
  10939. 'v',
  10940. 'w',
  10941. 'x',
  10942. 'y',
  10943. 'z',
  10944. 'braceleft',
  10945. 'bar',
  10946. 'braceright',
  10947. 'asciitilde',
  10948. '',
  10949. 'Adieresis',
  10950. 'Aring',
  10951. 'Ccedilla',
  10952. 'Eacute',
  10953. 'Ntilde',
  10954. 'Odieresis',
  10955. 'Udieresis',
  10956. 'aacute',
  10957. 'agrave',
  10958. 'acircumflex',
  10959. 'adieresis',
  10960. 'atilde',
  10961. 'aring',
  10962. 'ccedilla',
  10963. 'eacute',
  10964. 'egrave',
  10965. 'ecircumflex',
  10966. 'edieresis',
  10967. 'iacute',
  10968. 'igrave',
  10969. 'icircumflex',
  10970. 'idieresis',
  10971. 'ntilde',
  10972. 'oacute',
  10973. 'ograve',
  10974. 'ocircumflex',
  10975. 'odieresis',
  10976. 'otilde',
  10977. 'uacute',
  10978. 'ugrave',
  10979. 'ucircumflex',
  10980. 'udieresis',
  10981. 'dagger',
  10982. 'degree',
  10983. 'cent',
  10984. 'sterling',
  10985. 'section',
  10986. 'bullet',
  10987. 'paragraph',
  10988. 'germandbls',
  10989. 'registered',
  10990. 'copyright',
  10991. 'trademark',
  10992. 'acute',
  10993. 'dieresis',
  10994. 'notequal',
  10995. 'AE',
  10996. 'Oslash',
  10997. 'infinity',
  10998. 'plusminus',
  10999. 'lessequal',
  11000. 'greaterequal',
  11001. 'yen',
  11002. 'mu',
  11003. 'partialdiff',
  11004. 'summation',
  11005. 'product',
  11006. 'pi',
  11007. 'integral',
  11008. 'ordfeminine',
  11009. 'ordmasculine',
  11010. 'Omega',
  11011. 'ae',
  11012. 'oslash',
  11013. 'questiondown',
  11014. 'exclamdown',
  11015. 'logicalnot',
  11016. 'radical',
  11017. 'florin',
  11018. 'approxequal',
  11019. 'Delta',
  11020. 'guillemotleft',
  11021. 'guillemotright',
  11022. 'ellipsis',
  11023. 'space',
  11024. 'Agrave',
  11025. 'Atilde',
  11026. 'Otilde',
  11027. 'OE',
  11028. 'oe',
  11029. 'endash',
  11030. 'emdash',
  11031. 'quotedblleft',
  11032. 'quotedblright',
  11033. 'quoteleft',
  11034. 'quoteright',
  11035. 'divide',
  11036. 'lozenge',
  11037. 'ydieresis',
  11038. 'Ydieresis',
  11039. 'fraction',
  11040. 'currency',
  11041. 'guilsinglleft',
  11042. 'guilsinglright',
  11043. 'fi',
  11044. 'fl',
  11045. 'daggerdbl',
  11046. 'periodcentered',
  11047. 'quotesinglbase',
  11048. 'quotedblbase',
  11049. 'perthousand',
  11050. 'Acircumflex',
  11051. 'Ecircumflex',
  11052. 'Aacute',
  11053. 'Edieresis',
  11054. 'Egrave',
  11055. 'Iacute',
  11056. 'Icircumflex',
  11057. 'Idieresis',
  11058. 'Igrave',
  11059. 'Oacute',
  11060. 'Ocircumflex',
  11061. 'apple',
  11062. 'Ograve',
  11063. 'Uacute',
  11064. 'Ucircumflex',
  11065. 'Ugrave',
  11066. 'dotlessi',
  11067. 'circumflex',
  11068. 'tilde',
  11069. 'macron',
  11070. 'breve',
  11071. 'dotaccent',
  11072. 'ring',
  11073. 'cedilla',
  11074. 'hungarumlaut',
  11075. 'ogonek',
  11076. 'caron'
  11077. ];
  11078. var StandardEncoding = [
  11079. '',
  11080. '',
  11081. '',
  11082. '',
  11083. '',
  11084. '',
  11085. '',
  11086. '',
  11087. '',
  11088. '',
  11089. '',
  11090. '',
  11091. '',
  11092. '',
  11093. '',
  11094. '',
  11095. '',
  11096. '',
  11097. '',
  11098. '',
  11099. '',
  11100. '',
  11101. '',
  11102. '',
  11103. '',
  11104. '',
  11105. '',
  11106. '',
  11107. '',
  11108. '',
  11109. '',
  11110. '',
  11111. 'space',
  11112. 'exclam',
  11113. 'quotedbl',
  11114. 'numbersign',
  11115. 'dollar',
  11116. 'percent',
  11117. 'ampersand',
  11118. 'quoteright',
  11119. 'parenleft',
  11120. 'parenright',
  11121. 'asterisk',
  11122. 'plus',
  11123. 'comma',
  11124. 'hyphen',
  11125. 'period',
  11126. 'slash',
  11127. 'zero',
  11128. 'one',
  11129. 'two',
  11130. 'three',
  11131. 'four',
  11132. 'five',
  11133. 'six',
  11134. 'seven',
  11135. 'eight',
  11136. 'nine',
  11137. 'colon',
  11138. 'semicolon',
  11139. 'less',
  11140. 'equal',
  11141. 'greater',
  11142. 'question',
  11143. 'at',
  11144. 'A',
  11145. 'B',
  11146. 'C',
  11147. 'D',
  11148. 'E',
  11149. 'F',
  11150. 'G',
  11151. 'H',
  11152. 'I',
  11153. 'J',
  11154. 'K',
  11155. 'L',
  11156. 'M',
  11157. 'N',
  11158. 'O',
  11159. 'P',
  11160. 'Q',
  11161. 'R',
  11162. 'S',
  11163. 'T',
  11164. 'U',
  11165. 'V',
  11166. 'W',
  11167. 'X',
  11168. 'Y',
  11169. 'Z',
  11170. 'bracketleft',
  11171. 'backslash',
  11172. 'bracketright',
  11173. 'asciicircum',
  11174. 'underscore',
  11175. 'quoteleft',
  11176. 'a',
  11177. 'b',
  11178. 'c',
  11179. 'd',
  11180. 'e',
  11181. 'f',
  11182. 'g',
  11183. 'h',
  11184. 'i',
  11185. 'j',
  11186. 'k',
  11187. 'l',
  11188. 'm',
  11189. 'n',
  11190. 'o',
  11191. 'p',
  11192. 'q',
  11193. 'r',
  11194. 's',
  11195. 't',
  11196. 'u',
  11197. 'v',
  11198. 'w',
  11199. 'x',
  11200. 'y',
  11201. 'z',
  11202. 'braceleft',
  11203. 'bar',
  11204. 'braceright',
  11205. 'asciitilde',
  11206. '',
  11207. '',
  11208. '',
  11209. '',
  11210. '',
  11211. '',
  11212. '',
  11213. '',
  11214. '',
  11215. '',
  11216. '',
  11217. '',
  11218. '',
  11219. '',
  11220. '',
  11221. '',
  11222. '',
  11223. '',
  11224. '',
  11225. '',
  11226. '',
  11227. '',
  11228. '',
  11229. '',
  11230. '',
  11231. '',
  11232. '',
  11233. '',
  11234. '',
  11235. '',
  11236. '',
  11237. '',
  11238. '',
  11239. '',
  11240. 'exclamdown',
  11241. 'cent',
  11242. 'sterling',
  11243. 'fraction',
  11244. 'yen',
  11245. 'florin',
  11246. 'section',
  11247. 'currency',
  11248. 'quotesingle',
  11249. 'quotedblleft',
  11250. 'guillemotleft',
  11251. 'guilsinglleft',
  11252. 'guilsinglright',
  11253. 'fi',
  11254. 'fl',
  11255. '',
  11256. 'endash',
  11257. 'dagger',
  11258. 'daggerdbl',
  11259. 'periodcentered',
  11260. '',
  11261. 'paragraph',
  11262. 'bullet',
  11263. 'quotesinglbase',
  11264. 'quotedblbase',
  11265. 'quotedblright',
  11266. 'guillemotright',
  11267. 'ellipsis',
  11268. 'perthousand',
  11269. '',
  11270. 'questiondown',
  11271. '',
  11272. 'grave',
  11273. 'acute',
  11274. 'circumflex',
  11275. 'tilde',
  11276. 'macron',
  11277. 'breve',
  11278. 'dotaccent',
  11279. 'dieresis',
  11280. '',
  11281. 'ring',
  11282. 'cedilla',
  11283. '',
  11284. 'hungarumlaut',
  11285. 'ogonek',
  11286. 'caron',
  11287. 'emdash',
  11288. '',
  11289. '',
  11290. '',
  11291. '',
  11292. '',
  11293. '',
  11294. '',
  11295. '',
  11296. '',
  11297. '',
  11298. '',
  11299. '',
  11300. '',
  11301. '',
  11302. '',
  11303. '',
  11304. 'AE',
  11305. '',
  11306. 'ordfeminine',
  11307. '',
  11308. '',
  11309. '',
  11310. '',
  11311. 'Lslash',
  11312. 'Oslash',
  11313. 'OE',
  11314. 'ordmasculine',
  11315. '',
  11316. '',
  11317. '',
  11318. '',
  11319. '',
  11320. 'ae',
  11321. '',
  11322. '',
  11323. '',
  11324. 'dotlessi',
  11325. '',
  11326. '',
  11327. 'lslash',
  11328. 'oslash',
  11329. 'oe',
  11330. 'germandbls'
  11331. ];
  11332. var WinAnsiEncoding = [
  11333. '',
  11334. '',
  11335. '',
  11336. '',
  11337. '',
  11338. '',
  11339. '',
  11340. '',
  11341. '',
  11342. '',
  11343. '',
  11344. '',
  11345. '',
  11346. '',
  11347. '',
  11348. '',
  11349. '',
  11350. '',
  11351. '',
  11352. '',
  11353. '',
  11354. '',
  11355. '',
  11356. '',
  11357. '',
  11358. '',
  11359. '',
  11360. '',
  11361. '',
  11362. '',
  11363. '',
  11364. '',
  11365. 'space',
  11366. 'exclam',
  11367. 'quotedbl',
  11368. 'numbersign',
  11369. 'dollar',
  11370. 'percent',
  11371. 'ampersand',
  11372. 'quotesingle',
  11373. 'parenleft',
  11374. 'parenright',
  11375. 'asterisk',
  11376. 'plus',
  11377. 'comma',
  11378. 'hyphen',
  11379. 'period',
  11380. 'slash',
  11381. 'zero',
  11382. 'one',
  11383. 'two',
  11384. 'three',
  11385. 'four',
  11386. 'five',
  11387. 'six',
  11388. 'seven',
  11389. 'eight',
  11390. 'nine',
  11391. 'colon',
  11392. 'semicolon',
  11393. 'less',
  11394. 'equal',
  11395. 'greater',
  11396. 'question',
  11397. 'at',
  11398. 'A',
  11399. 'B',
  11400. 'C',
  11401. 'D',
  11402. 'E',
  11403. 'F',
  11404. 'G',
  11405. 'H',
  11406. 'I',
  11407. 'J',
  11408. 'K',
  11409. 'L',
  11410. 'M',
  11411. 'N',
  11412. 'O',
  11413. 'P',
  11414. 'Q',
  11415. 'R',
  11416. 'S',
  11417. 'T',
  11418. 'U',
  11419. 'V',
  11420. 'W',
  11421. 'X',
  11422. 'Y',
  11423. 'Z',
  11424. 'bracketleft',
  11425. 'backslash',
  11426. 'bracketright',
  11427. 'asciicircum',
  11428. 'underscore',
  11429. 'grave',
  11430. 'a',
  11431. 'b',
  11432. 'c',
  11433. 'd',
  11434. 'e',
  11435. 'f',
  11436. 'g',
  11437. 'h',
  11438. 'i',
  11439. 'j',
  11440. 'k',
  11441. 'l',
  11442. 'm',
  11443. 'n',
  11444. 'o',
  11445. 'p',
  11446. 'q',
  11447. 'r',
  11448. 's',
  11449. 't',
  11450. 'u',
  11451. 'v',
  11452. 'w',
  11453. 'x',
  11454. 'y',
  11455. 'z',
  11456. 'braceleft',
  11457. 'bar',
  11458. 'braceright',
  11459. 'asciitilde',
  11460. 'bullet',
  11461. 'Euro',
  11462. 'bullet',
  11463. 'quotesinglbase',
  11464. 'florin',
  11465. 'quotedblbase',
  11466. 'ellipsis',
  11467. 'dagger',
  11468. 'daggerdbl',
  11469. 'circumflex',
  11470. 'perthousand',
  11471. 'Scaron',
  11472. 'guilsinglleft',
  11473. 'OE',
  11474. 'bullet',
  11475. 'Zcaron',
  11476. 'bullet',
  11477. 'bullet',
  11478. 'quoteleft',
  11479. 'quoteright',
  11480. 'quotedblleft',
  11481. 'quotedblright',
  11482. 'bullet',
  11483. 'endash',
  11484. 'emdash',
  11485. 'tilde',
  11486. 'trademark',
  11487. 'scaron',
  11488. 'guilsinglright',
  11489. 'oe',
  11490. 'bullet',
  11491. 'zcaron',
  11492. 'Ydieresis',
  11493. 'space',
  11494. 'exclamdown',
  11495. 'cent',
  11496. 'sterling',
  11497. 'currency',
  11498. 'yen',
  11499. 'brokenbar',
  11500. 'section',
  11501. 'dieresis',
  11502. 'copyright',
  11503. 'ordfeminine',
  11504. 'guillemotleft',
  11505. 'logicalnot',
  11506. 'hyphen',
  11507. 'registered',
  11508. 'macron',
  11509. 'degree',
  11510. 'plusminus',
  11511. 'twosuperior',
  11512. 'threesuperior',
  11513. 'acute',
  11514. 'mu',
  11515. 'paragraph',
  11516. 'periodcentered',
  11517. 'cedilla',
  11518. 'onesuperior',
  11519. 'ordmasculine',
  11520. 'guillemotright',
  11521. 'onequarter',
  11522. 'onehalf',
  11523. 'threequarters',
  11524. 'questiondown',
  11525. 'Agrave',
  11526. 'Aacute',
  11527. 'Acircumflex',
  11528. 'Atilde',
  11529. 'Adieresis',
  11530. 'Aring',
  11531. 'AE',
  11532. 'Ccedilla',
  11533. 'Egrave',
  11534. 'Eacute',
  11535. 'Ecircumflex',
  11536. 'Edieresis',
  11537. 'Igrave',
  11538. 'Iacute',
  11539. 'Icircumflex',
  11540. 'Idieresis',
  11541. 'Eth',
  11542. 'Ntilde',
  11543. 'Ograve',
  11544. 'Oacute',
  11545. 'Ocircumflex',
  11546. 'Otilde',
  11547. 'Odieresis',
  11548. 'multiply',
  11549. 'Oslash',
  11550. 'Ugrave',
  11551. 'Uacute',
  11552. 'Ucircumflex',
  11553. 'Udieresis',
  11554. 'Yacute',
  11555. 'Thorn',
  11556. 'germandbls',
  11557. 'agrave',
  11558. 'aacute',
  11559. 'acircumflex',
  11560. 'atilde',
  11561. 'adieresis',
  11562. 'aring',
  11563. 'ae',
  11564. 'ccedilla',
  11565. 'egrave',
  11566. 'eacute',
  11567. 'ecircumflex',
  11568. 'edieresis',
  11569. 'igrave',
  11570. 'iacute',
  11571. 'icircumflex',
  11572. 'idieresis',
  11573. 'eth',
  11574. 'ntilde',
  11575. 'ograve',
  11576. 'oacute',
  11577. 'ocircumflex',
  11578. 'otilde',
  11579. 'odieresis',
  11580. 'divide',
  11581. 'oslash',
  11582. 'ugrave',
  11583. 'uacute',
  11584. 'ucircumflex',
  11585. 'udieresis',
  11586. 'yacute',
  11587. 'thorn',
  11588. 'ydieresis'
  11589. ];
  11590. var SymbolSetEncoding = [
  11591. '',
  11592. '',
  11593. '',
  11594. '',
  11595. '',
  11596. '',
  11597. '',
  11598. '',
  11599. '',
  11600. '',
  11601. '',
  11602. '',
  11603. '',
  11604. '',
  11605. '',
  11606. '',
  11607. '',
  11608. '',
  11609. '',
  11610. '',
  11611. '',
  11612. '',
  11613. '',
  11614. '',
  11615. '',
  11616. '',
  11617. '',
  11618. '',
  11619. '',
  11620. '',
  11621. '',
  11622. '',
  11623. 'space',
  11624. 'exclam',
  11625. 'universal',
  11626. 'numbersign',
  11627. 'existential',
  11628. 'percent',
  11629. 'ampersand',
  11630. 'suchthat',
  11631. 'parenleft',
  11632. 'parenright',
  11633. 'asteriskmath',
  11634. 'plus',
  11635. 'comma',
  11636. 'minus',
  11637. 'period',
  11638. 'slash',
  11639. 'zero',
  11640. 'one',
  11641. 'two',
  11642. 'three',
  11643. 'four',
  11644. 'five',
  11645. 'six',
  11646. 'seven',
  11647. 'eight',
  11648. 'nine',
  11649. 'colon',
  11650. 'semicolon',
  11651. 'less',
  11652. 'equal',
  11653. 'greater',
  11654. 'question',
  11655. 'congruent',
  11656. 'Alpha',
  11657. 'Beta',
  11658. 'Chi',
  11659. 'Delta',
  11660. 'Epsilon',
  11661. 'Phi',
  11662. 'Gamma',
  11663. 'Eta',
  11664. 'Iota',
  11665. 'theta1',
  11666. 'Kappa',
  11667. 'Lambda',
  11668. 'Mu',
  11669. 'Nu',
  11670. 'Omicron',
  11671. 'Pi',
  11672. 'Theta',
  11673. 'Rho',
  11674. 'Sigma',
  11675. 'Tau',
  11676. 'Upsilon',
  11677. 'sigma1',
  11678. 'Omega',
  11679. 'Xi',
  11680. 'Psi',
  11681. 'Zeta',
  11682. 'bracketleft',
  11683. 'therefore',
  11684. 'bracketright',
  11685. 'perpendicular',
  11686. 'underscore',
  11687. 'radicalex',
  11688. 'alpha',
  11689. 'beta',
  11690. 'chi',
  11691. 'delta',
  11692. 'epsilon',
  11693. 'phi',
  11694. 'gamma',
  11695. 'eta',
  11696. 'iota',
  11697. 'phi1',
  11698. 'kappa',
  11699. 'lambda',
  11700. 'mu',
  11701. 'nu',
  11702. 'omicron',
  11703. 'pi',
  11704. 'theta',
  11705. 'rho',
  11706. 'sigma',
  11707. 'tau',
  11708. 'upsilon',
  11709. 'omega1',
  11710. 'omega',
  11711. 'xi',
  11712. 'psi',
  11713. 'zeta',
  11714. 'braceleft',
  11715. 'bar',
  11716. 'braceright',
  11717. 'similar',
  11718. '',
  11719. '',
  11720. '',
  11721. '',
  11722. '',
  11723. '',
  11724. '',
  11725. '',
  11726. '',
  11727. '',
  11728. '',
  11729. '',
  11730. '',
  11731. '',
  11732. '',
  11733. '',
  11734. '',
  11735. '',
  11736. '',
  11737. '',
  11738. '',
  11739. '',
  11740. '',
  11741. '',
  11742. '',
  11743. '',
  11744. '',
  11745. '',
  11746. '',
  11747. '',
  11748. '',
  11749. '',
  11750. '',
  11751. 'Euro',
  11752. 'Upsilon1',
  11753. 'minute',
  11754. 'lessequal',
  11755. 'fraction',
  11756. 'infinity',
  11757. 'florin',
  11758. 'club',
  11759. 'diamond',
  11760. 'heart',
  11761. 'spade',
  11762. 'arrowboth',
  11763. 'arrowleft',
  11764. 'arrowup',
  11765. 'arrowright',
  11766. 'arrowdown',
  11767. 'degree',
  11768. 'plusminus',
  11769. 'second',
  11770. 'greaterequal',
  11771. 'multiply',
  11772. 'proportional',
  11773. 'partialdiff',
  11774. 'bullet',
  11775. 'divide',
  11776. 'notequal',
  11777. 'equivalence',
  11778. 'approxequal',
  11779. 'ellipsis',
  11780. 'arrowvertex',
  11781. 'arrowhorizex',
  11782. 'carriagereturn',
  11783. 'aleph',
  11784. 'Ifraktur',
  11785. 'Rfraktur',
  11786. 'weierstrass',
  11787. 'circlemultiply',
  11788. 'circleplus',
  11789. 'emptyset',
  11790. 'intersection',
  11791. 'union',
  11792. 'propersuperset',
  11793. 'reflexsuperset',
  11794. 'notsubset',
  11795. 'propersubset',
  11796. 'reflexsubset',
  11797. 'element',
  11798. 'notelement',
  11799. 'angle',
  11800. 'gradient',
  11801. 'registerserif',
  11802. 'copyrightserif',
  11803. 'trademarkserif',
  11804. 'product',
  11805. 'radical',
  11806. 'dotmath',
  11807. 'logicalnot',
  11808. 'logicaland',
  11809. 'logicalor',
  11810. 'arrowdblboth',
  11811. 'arrowdblleft',
  11812. 'arrowdblup',
  11813. 'arrowdblright',
  11814. 'arrowdbldown',
  11815. 'lozenge',
  11816. 'angleleft',
  11817. 'registersans',
  11818. 'copyrightsans',
  11819. 'trademarksans',
  11820. 'summation',
  11821. 'parenlefttp',
  11822. 'parenleftex',
  11823. 'parenleftbt',
  11824. 'bracketlefttp',
  11825. 'bracketleftex',
  11826. 'bracketleftbt',
  11827. 'bracelefttp',
  11828. 'braceleftmid',
  11829. 'braceleftbt',
  11830. 'braceex',
  11831. '',
  11832. 'angleright',
  11833. 'integral',
  11834. 'integraltp',
  11835. 'integralex',
  11836. 'integralbt',
  11837. 'parenrighttp',
  11838. 'parenrightex',
  11839. 'parenrightbt',
  11840. 'bracketrighttp',
  11841. 'bracketrightex',
  11842. 'bracketrightbt',
  11843. 'bracerighttp',
  11844. 'bracerightmid',
  11845. 'bracerightbt'
  11846. ];
  11847. var ZapfDingbatsEncoding = [
  11848. '',
  11849. '',
  11850. '',
  11851. '',
  11852. '',
  11853. '',
  11854. '',
  11855. '',
  11856. '',
  11857. '',
  11858. '',
  11859. '',
  11860. '',
  11861. '',
  11862. '',
  11863. '',
  11864. '',
  11865. '',
  11866. '',
  11867. '',
  11868. '',
  11869. '',
  11870. '',
  11871. '',
  11872. '',
  11873. '',
  11874. '',
  11875. '',
  11876. '',
  11877. '',
  11878. '',
  11879. '',
  11880. 'space',
  11881. 'a1',
  11882. 'a2',
  11883. 'a202',
  11884. 'a3',
  11885. 'a4',
  11886. 'a5',
  11887. 'a119',
  11888. 'a118',
  11889. 'a117',
  11890. 'a11',
  11891. 'a12',
  11892. 'a13',
  11893. 'a14',
  11894. 'a15',
  11895. 'a16',
  11896. 'a105',
  11897. 'a17',
  11898. 'a18',
  11899. 'a19',
  11900. 'a20',
  11901. 'a21',
  11902. 'a22',
  11903. 'a23',
  11904. 'a24',
  11905. 'a25',
  11906. 'a26',
  11907. 'a27',
  11908. 'a28',
  11909. 'a6',
  11910. 'a7',
  11911. 'a8',
  11912. 'a9',
  11913. 'a10',
  11914. 'a29',
  11915. 'a30',
  11916. 'a31',
  11917. 'a32',
  11918. 'a33',
  11919. 'a34',
  11920. 'a35',
  11921. 'a36',
  11922. 'a37',
  11923. 'a38',
  11924. 'a39',
  11925. 'a40',
  11926. 'a41',
  11927. 'a42',
  11928. 'a43',
  11929. 'a44',
  11930. 'a45',
  11931. 'a46',
  11932. 'a47',
  11933. 'a48',
  11934. 'a49',
  11935. 'a50',
  11936. 'a51',
  11937. 'a52',
  11938. 'a53',
  11939. 'a54',
  11940. 'a55',
  11941. 'a56',
  11942. 'a57',
  11943. 'a58',
  11944. 'a59',
  11945. 'a60',
  11946. 'a61',
  11947. 'a62',
  11948. 'a63',
  11949. 'a64',
  11950. 'a65',
  11951. 'a66',
  11952. 'a67',
  11953. 'a68',
  11954. 'a69',
  11955. 'a70',
  11956. 'a71',
  11957. 'a72',
  11958. 'a73',
  11959. 'a74',
  11960. 'a203',
  11961. 'a75',
  11962. 'a204',
  11963. 'a76',
  11964. 'a77',
  11965. 'a78',
  11966. 'a79',
  11967. 'a81',
  11968. 'a82',
  11969. 'a83',
  11970. 'a84',
  11971. 'a97',
  11972. 'a98',
  11973. 'a99',
  11974. 'a100',
  11975. '',
  11976. 'a89',
  11977. 'a90',
  11978. 'a93',
  11979. 'a94',
  11980. 'a91',
  11981. 'a92',
  11982. 'a205',
  11983. 'a85',
  11984. 'a206',
  11985. 'a86',
  11986. 'a87',
  11987. 'a88',
  11988. 'a95',
  11989. 'a96',
  11990. '',
  11991. '',
  11992. '',
  11993. '',
  11994. '',
  11995. '',
  11996. '',
  11997. '',
  11998. '',
  11999. '',
  12000. '',
  12001. '',
  12002. '',
  12003. '',
  12004. '',
  12005. '',
  12006. '',
  12007. '',
  12008. '',
  12009. 'a101',
  12010. 'a102',
  12011. 'a103',
  12012. 'a104',
  12013. 'a106',
  12014. 'a107',
  12015. 'a108',
  12016. 'a112',
  12017. 'a111',
  12018. 'a110',
  12019. 'a109',
  12020. 'a120',
  12021. 'a121',
  12022. 'a122',
  12023. 'a123',
  12024. 'a124',
  12025. 'a125',
  12026. 'a126',
  12027. 'a127',
  12028. 'a128',
  12029. 'a129',
  12030. 'a130',
  12031. 'a131',
  12032. 'a132',
  12033. 'a133',
  12034. 'a134',
  12035. 'a135',
  12036. 'a136',
  12037. 'a137',
  12038. 'a138',
  12039. 'a139',
  12040. 'a140',
  12041. 'a141',
  12042. 'a142',
  12043. 'a143',
  12044. 'a144',
  12045. 'a145',
  12046. 'a146',
  12047. 'a147',
  12048. 'a148',
  12049. 'a149',
  12050. 'a150',
  12051. 'a151',
  12052. 'a152',
  12053. 'a153',
  12054. 'a154',
  12055. 'a155',
  12056. 'a156',
  12057. 'a157',
  12058. 'a158',
  12059. 'a159',
  12060. 'a160',
  12061. 'a161',
  12062. 'a163',
  12063. 'a164',
  12064. 'a196',
  12065. 'a165',
  12066. 'a192',
  12067. 'a166',
  12068. 'a167',
  12069. 'a168',
  12070. 'a169',
  12071. 'a170',
  12072. 'a171',
  12073. 'a172',
  12074. 'a173',
  12075. 'a162',
  12076. 'a174',
  12077. 'a175',
  12078. 'a176',
  12079. 'a177',
  12080. 'a178',
  12081. 'a179',
  12082. 'a193',
  12083. 'a180',
  12084. 'a199',
  12085. 'a181',
  12086. 'a200',
  12087. 'a182',
  12088. '',
  12089. 'a201',
  12090. 'a183',
  12091. 'a184',
  12092. 'a197',
  12093. 'a185',
  12094. 'a194',
  12095. 'a198',
  12096. 'a186',
  12097. 'a195',
  12098. 'a187',
  12099. 'a188',
  12100. 'a189',
  12101. 'a190',
  12102. 'a191'
  12103. ];
  12104. function getEncoding(encodingName) {
  12105. switch (encodingName) {
  12106. case 'WinAnsiEncoding':
  12107. return WinAnsiEncoding;
  12108. case 'StandardEncoding':
  12109. return StandardEncoding;
  12110. case 'MacRomanEncoding':
  12111. return MacRomanEncoding;
  12112. case 'SymbolSetEncoding':
  12113. return SymbolSetEncoding;
  12114. case 'ZapfDingbatsEncoding':
  12115. return ZapfDingbatsEncoding;
  12116. case 'ExpertEncoding':
  12117. return ExpertEncoding;
  12118. case 'MacExpertEncoding':
  12119. return MacExpertEncoding;
  12120. default:
  12121. return null;
  12122. }
  12123. }
  12124. exports.WinAnsiEncoding = WinAnsiEncoding;
  12125. exports.StandardEncoding = StandardEncoding;
  12126. exports.MacRomanEncoding = MacRomanEncoding;
  12127. exports.SymbolSetEncoding = SymbolSetEncoding;
  12128. exports.ZapfDingbatsEncoding = ZapfDingbatsEncoding;
  12129. exports.ExpertEncoding = ExpertEncoding;
  12130. exports.getEncoding = getEncoding;
  12131. /***/ }),
  12132. /* 6 */
  12133. /***/ (function(module, exports, __w_pdfjs_require__) {
  12134. "use strict";
  12135. var sharedUtil = __w_pdfjs_require__(0);
  12136. var corePrimitives = __w_pdfjs_require__(1);
  12137. var coreStream = __w_pdfjs_require__(2);
  12138. var MissingDataException = sharedUtil.MissingDataException;
  12139. var StreamType = sharedUtil.StreamType;
  12140. var assert = sharedUtil.assert;
  12141. var error = sharedUtil.error;
  12142. var info = sharedUtil.info;
  12143. var isArray = sharedUtil.isArray;
  12144. var isInt = sharedUtil.isInt;
  12145. var isNum = sharedUtil.isNum;
  12146. var isString = sharedUtil.isString;
  12147. var warn = sharedUtil.warn;
  12148. var EOF = corePrimitives.EOF;
  12149. var Cmd = corePrimitives.Cmd;
  12150. var Dict = corePrimitives.Dict;
  12151. var Name = corePrimitives.Name;
  12152. var Ref = corePrimitives.Ref;
  12153. var isEOF = corePrimitives.isEOF;
  12154. var isCmd = corePrimitives.isCmd;
  12155. var isDict = corePrimitives.isDict;
  12156. var isName = corePrimitives.isName;
  12157. var Ascii85Stream = coreStream.Ascii85Stream;
  12158. var AsciiHexStream = coreStream.AsciiHexStream;
  12159. var CCITTFaxStream = coreStream.CCITTFaxStream;
  12160. var FlateStream = coreStream.FlateStream;
  12161. var Jbig2Stream = coreStream.Jbig2Stream;
  12162. var JpegStream = coreStream.JpegStream;
  12163. var JpxStream = coreStream.JpxStream;
  12164. var LZWStream = coreStream.LZWStream;
  12165. var NullStream = coreStream.NullStream;
  12166. var PredictorStream = coreStream.PredictorStream;
  12167. var RunLengthStream = coreStream.RunLengthStream;
  12168. var MAX_LENGTH_TO_CACHE = 1000;
  12169. var Parser = function ParserClosure() {
  12170. function Parser(lexer, allowStreams, xref, recoveryMode) {
  12171. this.lexer = lexer;
  12172. this.allowStreams = allowStreams;
  12173. this.xref = xref;
  12174. this.recoveryMode = recoveryMode || false;
  12175. this.imageCache = Object.create(null);
  12176. this.refill();
  12177. }
  12178. Parser.prototype = {
  12179. refill: function Parser_refill() {
  12180. this.buf1 = this.lexer.getObj();
  12181. this.buf2 = this.lexer.getObj();
  12182. },
  12183. shift: function Parser_shift() {
  12184. if (isCmd(this.buf2, 'ID')) {
  12185. this.buf1 = this.buf2;
  12186. this.buf2 = null;
  12187. } else {
  12188. this.buf1 = this.buf2;
  12189. this.buf2 = this.lexer.getObj();
  12190. }
  12191. },
  12192. tryShift: function Parser_tryShift() {
  12193. try {
  12194. this.shift();
  12195. return true;
  12196. } catch (e) {
  12197. if (e instanceof MissingDataException) {
  12198. throw e;
  12199. }
  12200. return false;
  12201. }
  12202. },
  12203. getObj: function Parser_getObj(cipherTransform) {
  12204. var buf1 = this.buf1;
  12205. this.shift();
  12206. if (buf1 instanceof Cmd) {
  12207. switch (buf1.cmd) {
  12208. case 'BI':
  12209. return this.makeInlineImage(cipherTransform);
  12210. case '[':
  12211. var array = [];
  12212. while (!isCmd(this.buf1, ']') && !isEOF(this.buf1)) {
  12213. array.push(this.getObj(cipherTransform));
  12214. }
  12215. if (isEOF(this.buf1)) {
  12216. if (!this.recoveryMode) {
  12217. error('End of file inside array');
  12218. }
  12219. return array;
  12220. }
  12221. this.shift();
  12222. return array;
  12223. case '<<':
  12224. var dict = new Dict(this.xref);
  12225. while (!isCmd(this.buf1, '>>') && !isEOF(this.buf1)) {
  12226. if (!isName(this.buf1)) {
  12227. info('Malformed dictionary: key must be a name object');
  12228. this.shift();
  12229. continue;
  12230. }
  12231. var key = this.buf1.name;
  12232. this.shift();
  12233. if (isEOF(this.buf1)) {
  12234. break;
  12235. }
  12236. dict.set(key, this.getObj(cipherTransform));
  12237. }
  12238. if (isEOF(this.buf1)) {
  12239. if (!this.recoveryMode) {
  12240. error('End of file inside dictionary');
  12241. }
  12242. return dict;
  12243. }
  12244. if (isCmd(this.buf2, 'stream')) {
  12245. return this.allowStreams ? this.makeStream(dict, cipherTransform) : dict;
  12246. }
  12247. this.shift();
  12248. return dict;
  12249. default:
  12250. return buf1;
  12251. }
  12252. }
  12253. if (isInt(buf1)) {
  12254. var num = buf1;
  12255. if (isInt(this.buf1) && isCmd(this.buf2, 'R')) {
  12256. var ref = new Ref(num, this.buf1);
  12257. this.shift();
  12258. this.shift();
  12259. return ref;
  12260. }
  12261. return num;
  12262. }
  12263. if (isString(buf1)) {
  12264. var str = buf1;
  12265. if (cipherTransform) {
  12266. str = cipherTransform.decryptString(str);
  12267. }
  12268. return str;
  12269. }
  12270. return buf1;
  12271. },
  12272. findDefaultInlineStreamEnd: function Parser_findDefaultInlineStreamEnd(stream) {
  12273. var E = 0x45, I = 0x49, SPACE = 0x20, LF = 0xA, CR = 0xD;
  12274. var startPos = stream.pos, state = 0, ch, i, n, followingBytes;
  12275. while ((ch = stream.getByte()) !== -1) {
  12276. if (state === 0) {
  12277. state = ch === E ? 1 : 0;
  12278. } else if (state === 1) {
  12279. state = ch === I ? 2 : 0;
  12280. } else {
  12281. assert(state === 2);
  12282. if (ch === SPACE || ch === LF || ch === CR) {
  12283. n = 5;
  12284. followingBytes = stream.peekBytes(n);
  12285. for (i = 0; i < n; i++) {
  12286. ch = followingBytes[i];
  12287. if (ch !== LF && ch !== CR && (ch < SPACE || ch > 0x7F)) {
  12288. state = 0;
  12289. break;
  12290. }
  12291. }
  12292. if (state === 2) {
  12293. break;
  12294. }
  12295. } else {
  12296. state = 0;
  12297. }
  12298. }
  12299. }
  12300. return stream.pos - 4 - startPos;
  12301. },
  12302. findDCTDecodeInlineStreamEnd: function Parser_findDCTDecodeInlineStreamEnd(stream) {
  12303. var startPos = stream.pos, foundEOI = false, b, markerLength, length;
  12304. while ((b = stream.getByte()) !== -1) {
  12305. if (b !== 0xFF) {
  12306. continue;
  12307. }
  12308. switch (stream.getByte()) {
  12309. case 0x00:
  12310. break;
  12311. case 0xFF:
  12312. stream.skip(-1);
  12313. break;
  12314. case 0xD9:
  12315. foundEOI = true;
  12316. break;
  12317. case 0xC0:
  12318. case 0xC1:
  12319. case 0xC2:
  12320. case 0xC3:
  12321. case 0xC5:
  12322. case 0xC6:
  12323. case 0xC7:
  12324. case 0xC9:
  12325. case 0xCA:
  12326. case 0xCB:
  12327. case 0xCD:
  12328. case 0xCE:
  12329. case 0xCF:
  12330. case 0xC4:
  12331. case 0xCC:
  12332. case 0xDA:
  12333. case 0xDB:
  12334. case 0xDC:
  12335. case 0xDD:
  12336. case 0xDE:
  12337. case 0xDF:
  12338. case 0xE0:
  12339. case 0xE1:
  12340. case 0xE2:
  12341. case 0xE3:
  12342. case 0xE4:
  12343. case 0xE5:
  12344. case 0xE6:
  12345. case 0xE7:
  12346. case 0xE8:
  12347. case 0xE9:
  12348. case 0xEA:
  12349. case 0xEB:
  12350. case 0xEC:
  12351. case 0xED:
  12352. case 0xEE:
  12353. case 0xEF:
  12354. case 0xFE:
  12355. markerLength = stream.getUint16();
  12356. if (markerLength > 2) {
  12357. stream.skip(markerLength - 2);
  12358. } else {
  12359. stream.skip(-2);
  12360. }
  12361. break;
  12362. }
  12363. if (foundEOI) {
  12364. break;
  12365. }
  12366. }
  12367. length = stream.pos - startPos;
  12368. if (b === -1) {
  12369. warn('Inline DCTDecode image stream: ' + 'EOI marker not found, searching for /EI/ instead.');
  12370. stream.skip(-length);
  12371. return this.findDefaultInlineStreamEnd(stream);
  12372. }
  12373. this.inlineStreamSkipEI(stream);
  12374. return length;
  12375. },
  12376. findASCII85DecodeInlineStreamEnd: function Parser_findASCII85DecodeInlineStreamEnd(stream) {
  12377. var TILDE = 0x7E, GT = 0x3E;
  12378. var startPos = stream.pos, ch, length;
  12379. while ((ch = stream.getByte()) !== -1) {
  12380. if (ch === TILDE && stream.peekByte() === GT) {
  12381. stream.skip();
  12382. break;
  12383. }
  12384. }
  12385. length = stream.pos - startPos;
  12386. if (ch === -1) {
  12387. warn('Inline ASCII85Decode image stream: ' + 'EOD marker not found, searching for /EI/ instead.');
  12388. stream.skip(-length);
  12389. return this.findDefaultInlineStreamEnd(stream);
  12390. }
  12391. this.inlineStreamSkipEI(stream);
  12392. return length;
  12393. },
  12394. findASCIIHexDecodeInlineStreamEnd: function Parser_findASCIIHexDecodeInlineStreamEnd(stream) {
  12395. var GT = 0x3E;
  12396. var startPos = stream.pos, ch, length;
  12397. while ((ch = stream.getByte()) !== -1) {
  12398. if (ch === GT) {
  12399. break;
  12400. }
  12401. }
  12402. length = stream.pos - startPos;
  12403. if (ch === -1) {
  12404. warn('Inline ASCIIHexDecode image stream: ' + 'EOD marker not found, searching for /EI/ instead.');
  12405. stream.skip(-length);
  12406. return this.findDefaultInlineStreamEnd(stream);
  12407. }
  12408. this.inlineStreamSkipEI(stream);
  12409. return length;
  12410. },
  12411. inlineStreamSkipEI: function Parser_inlineStreamSkipEI(stream) {
  12412. var E = 0x45, I = 0x49;
  12413. var state = 0, ch;
  12414. while ((ch = stream.getByte()) !== -1) {
  12415. if (state === 0) {
  12416. state = ch === E ? 1 : 0;
  12417. } else if (state === 1) {
  12418. state = ch === I ? 2 : 0;
  12419. } else if (state === 2) {
  12420. break;
  12421. }
  12422. }
  12423. },
  12424. makeInlineImage: function Parser_makeInlineImage(cipherTransform) {
  12425. var lexer = this.lexer;
  12426. var stream = lexer.stream;
  12427. var dict = new Dict(this.xref);
  12428. while (!isCmd(this.buf1, 'ID') && !isEOF(this.buf1)) {
  12429. if (!isName(this.buf1)) {
  12430. error('Dictionary key must be a name object');
  12431. }
  12432. var key = this.buf1.name;
  12433. this.shift();
  12434. if (isEOF(this.buf1)) {
  12435. break;
  12436. }
  12437. dict.set(key, this.getObj(cipherTransform));
  12438. }
  12439. var filter = dict.get('Filter', 'F'), filterName;
  12440. if (isName(filter)) {
  12441. filterName = filter.name;
  12442. } else if (isArray(filter)) {
  12443. var filterZero = this.xref.fetchIfRef(filter[0]);
  12444. if (isName(filterZero)) {
  12445. filterName = filterZero.name;
  12446. }
  12447. }
  12448. var startPos = stream.pos, length, i, ii;
  12449. if (filterName === 'DCTDecode' || filterName === 'DCT') {
  12450. length = this.findDCTDecodeInlineStreamEnd(stream);
  12451. } else if (filterName === 'ASCII85Decide' || filterName === 'A85') {
  12452. length = this.findASCII85DecodeInlineStreamEnd(stream);
  12453. } else if (filterName === 'ASCIIHexDecode' || filterName === 'AHx') {
  12454. length = this.findASCIIHexDecodeInlineStreamEnd(stream);
  12455. } else {
  12456. length = this.findDefaultInlineStreamEnd(stream);
  12457. }
  12458. var imageStream = stream.makeSubStream(startPos, length, dict);
  12459. var adler32;
  12460. if (length < MAX_LENGTH_TO_CACHE) {
  12461. var imageBytes = imageStream.getBytes();
  12462. imageStream.reset();
  12463. var a = 1;
  12464. var b = 0;
  12465. for (i = 0, ii = imageBytes.length; i < ii; ++i) {
  12466. a += imageBytes[i] & 0xff;
  12467. b += a;
  12468. }
  12469. adler32 = b % 65521 << 16 | a % 65521;
  12470. if (this.imageCache.adler32 === adler32) {
  12471. this.buf2 = Cmd.get('EI');
  12472. this.shift();
  12473. this.imageCache[adler32].reset();
  12474. return this.imageCache[adler32];
  12475. }
  12476. }
  12477. if (cipherTransform) {
  12478. imageStream = cipherTransform.createStream(imageStream, length);
  12479. }
  12480. imageStream = this.filter(imageStream, dict, length);
  12481. imageStream.dict = dict;
  12482. if (adler32 !== undefined) {
  12483. imageStream.cacheKey = 'inline_' + length + '_' + adler32;
  12484. this.imageCache[adler32] = imageStream;
  12485. }
  12486. this.buf2 = Cmd.get('EI');
  12487. this.shift();
  12488. return imageStream;
  12489. },
  12490. makeStream: function Parser_makeStream(dict, cipherTransform) {
  12491. var lexer = this.lexer;
  12492. var stream = lexer.stream;
  12493. lexer.skipToNextLine();
  12494. var pos = stream.pos - 1;
  12495. var length = dict.get('Length');
  12496. if (!isInt(length)) {
  12497. info('Bad ' + length + ' attribute in stream');
  12498. length = 0;
  12499. }
  12500. stream.pos = pos + length;
  12501. lexer.nextChar();
  12502. if (this.tryShift() && isCmd(this.buf2, 'endstream')) {
  12503. this.shift();
  12504. } else {
  12505. stream.pos = pos;
  12506. var SCAN_BLOCK_SIZE = 2048;
  12507. var ENDSTREAM_SIGNATURE_LENGTH = 9;
  12508. var ENDSTREAM_SIGNATURE = [
  12509. 0x65,
  12510. 0x6E,
  12511. 0x64,
  12512. 0x73,
  12513. 0x74,
  12514. 0x72,
  12515. 0x65,
  12516. 0x61,
  12517. 0x6D
  12518. ];
  12519. var skipped = 0, found = false, i, j;
  12520. while (stream.pos < stream.end) {
  12521. var scanBytes = stream.peekBytes(SCAN_BLOCK_SIZE);
  12522. var scanLength = scanBytes.length - ENDSTREAM_SIGNATURE_LENGTH;
  12523. if (scanLength <= 0) {
  12524. break;
  12525. }
  12526. found = false;
  12527. i = 0;
  12528. while (i < scanLength) {
  12529. j = 0;
  12530. while (j < ENDSTREAM_SIGNATURE_LENGTH && scanBytes[i + j] === ENDSTREAM_SIGNATURE[j]) {
  12531. j++;
  12532. }
  12533. if (j >= ENDSTREAM_SIGNATURE_LENGTH) {
  12534. found = true;
  12535. break;
  12536. }
  12537. i++;
  12538. }
  12539. if (found) {
  12540. skipped += i;
  12541. stream.pos += i;
  12542. break;
  12543. }
  12544. skipped += scanLength;
  12545. stream.pos += scanLength;
  12546. }
  12547. if (!found) {
  12548. error('Missing endstream');
  12549. }
  12550. length = skipped;
  12551. lexer.nextChar();
  12552. this.shift();
  12553. this.shift();
  12554. }
  12555. this.shift();
  12556. stream = stream.makeSubStream(pos, length, dict);
  12557. if (cipherTransform) {
  12558. stream = cipherTransform.createStream(stream, length);
  12559. }
  12560. stream = this.filter(stream, dict, length);
  12561. stream.dict = dict;
  12562. return stream;
  12563. },
  12564. filter: function Parser_filter(stream, dict, length) {
  12565. var filter = dict.get('Filter', 'F');
  12566. var params = dict.get('DecodeParms', 'DP');
  12567. if (isName(filter)) {
  12568. if (isArray(params)) {
  12569. params = this.xref.fetchIfRef(params[0]);
  12570. }
  12571. return this.makeFilter(stream, filter.name, length, params);
  12572. }
  12573. var maybeLength = length;
  12574. if (isArray(filter)) {
  12575. var filterArray = filter;
  12576. var paramsArray = params;
  12577. for (var i = 0, ii = filterArray.length; i < ii; ++i) {
  12578. filter = this.xref.fetchIfRef(filterArray[i]);
  12579. if (!isName(filter)) {
  12580. error('Bad filter name: ' + filter);
  12581. }
  12582. params = null;
  12583. if (isArray(paramsArray) && i in paramsArray) {
  12584. params = this.xref.fetchIfRef(paramsArray[i]);
  12585. }
  12586. stream = this.makeFilter(stream, filter.name, maybeLength, params);
  12587. maybeLength = null;
  12588. }
  12589. }
  12590. return stream;
  12591. },
  12592. makeFilter: function Parser_makeFilter(stream, name, maybeLength, params) {
  12593. if (maybeLength === 0) {
  12594. warn('Empty "' + name + '" stream.');
  12595. return new NullStream(stream);
  12596. }
  12597. try {
  12598. var xrefStreamStats = this.xref.stats.streamTypes;
  12599. if (name === 'FlateDecode' || name === 'Fl') {
  12600. xrefStreamStats[StreamType.FLATE] = true;
  12601. if (params) {
  12602. return new PredictorStream(new FlateStream(stream, maybeLength), maybeLength, params);
  12603. }
  12604. return new FlateStream(stream, maybeLength);
  12605. }
  12606. if (name === 'LZWDecode' || name === 'LZW') {
  12607. xrefStreamStats[StreamType.LZW] = true;
  12608. var earlyChange = 1;
  12609. if (params) {
  12610. if (params.has('EarlyChange')) {
  12611. earlyChange = params.get('EarlyChange');
  12612. }
  12613. return new PredictorStream(new LZWStream(stream, maybeLength, earlyChange), maybeLength, params);
  12614. }
  12615. return new LZWStream(stream, maybeLength, earlyChange);
  12616. }
  12617. if (name === 'DCTDecode' || name === 'DCT') {
  12618. xrefStreamStats[StreamType.DCT] = true;
  12619. return new JpegStream(stream, maybeLength, stream.dict, params);
  12620. }
  12621. if (name === 'JPXDecode' || name === 'JPX') {
  12622. xrefStreamStats[StreamType.JPX] = true;
  12623. return new JpxStream(stream, maybeLength, stream.dict, params);
  12624. }
  12625. if (name === 'ASCII85Decode' || name === 'A85') {
  12626. xrefStreamStats[StreamType.A85] = true;
  12627. return new Ascii85Stream(stream, maybeLength);
  12628. }
  12629. if (name === 'ASCIIHexDecode' || name === 'AHx') {
  12630. xrefStreamStats[StreamType.AHX] = true;
  12631. return new AsciiHexStream(stream, maybeLength);
  12632. }
  12633. if (name === 'CCITTFaxDecode' || name === 'CCF') {
  12634. xrefStreamStats[StreamType.CCF] = true;
  12635. return new CCITTFaxStream(stream, maybeLength, params);
  12636. }
  12637. if (name === 'RunLengthDecode' || name === 'RL') {
  12638. xrefStreamStats[StreamType.RL] = true;
  12639. return new RunLengthStream(stream, maybeLength);
  12640. }
  12641. if (name === 'JBIG2Decode') {
  12642. xrefStreamStats[StreamType.JBIG] = true;
  12643. return new Jbig2Stream(stream, maybeLength, stream.dict, params);
  12644. }
  12645. warn('filter "' + name + '" not supported yet');
  12646. return stream;
  12647. } catch (ex) {
  12648. if (ex instanceof MissingDataException) {
  12649. throw ex;
  12650. }
  12651. warn('Invalid stream: \"' + ex + '\"');
  12652. return new NullStream(stream);
  12653. }
  12654. }
  12655. };
  12656. return Parser;
  12657. }();
  12658. var Lexer = function LexerClosure() {
  12659. function Lexer(stream, knownCommands) {
  12660. this.stream = stream;
  12661. this.nextChar();
  12662. this.strBuf = [];
  12663. this.knownCommands = knownCommands;
  12664. }
  12665. var specialChars = [
  12666. 1,
  12667. 0,
  12668. 0,
  12669. 0,
  12670. 0,
  12671. 0,
  12672. 0,
  12673. 0,
  12674. 0,
  12675. 1,
  12676. 1,
  12677. 0,
  12678. 1,
  12679. 1,
  12680. 0,
  12681. 0,
  12682. 0,
  12683. 0,
  12684. 0,
  12685. 0,
  12686. 0,
  12687. 0,
  12688. 0,
  12689. 0,
  12690. 0,
  12691. 0,
  12692. 0,
  12693. 0,
  12694. 0,
  12695. 0,
  12696. 0,
  12697. 0,
  12698. 1,
  12699. 0,
  12700. 0,
  12701. 0,
  12702. 0,
  12703. 2,
  12704. 0,
  12705. 0,
  12706. 2,
  12707. 2,
  12708. 0,
  12709. 0,
  12710. 0,
  12711. 0,
  12712. 0,
  12713. 2,
  12714. 0,
  12715. 0,
  12716. 0,
  12717. 0,
  12718. 0,
  12719. 0,
  12720. 0,
  12721. 0,
  12722. 0,
  12723. 0,
  12724. 0,
  12725. 0,
  12726. 2,
  12727. 0,
  12728. 2,
  12729. 0,
  12730. 0,
  12731. 0,
  12732. 0,
  12733. 0,
  12734. 0,
  12735. 0,
  12736. 0,
  12737. 0,
  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. 0,
  12757. 2,
  12758. 0,
  12759. 2,
  12760. 0,
  12761. 0,
  12762. 0,
  12763. 0,
  12764. 0,
  12765. 0,
  12766. 0,
  12767. 0,
  12768. 0,
  12769. 0,
  12770. 0,
  12771. 0,
  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. 0,
  12785. 0,
  12786. 0,
  12787. 0,
  12788. 0,
  12789. 2,
  12790. 0,
  12791. 2,
  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. 0,
  12816. 0,
  12817. 0,
  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. 0,
  12848. 0,
  12849. 0,
  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. ];
  12923. function toHexDigit(ch) {
  12924. if (ch >= 0x30 && ch <= 0x39) {
  12925. return ch & 0x0F;
  12926. }
  12927. if (ch >= 0x41 && ch <= 0x46 || ch >= 0x61 && ch <= 0x66) {
  12928. return (ch & 0x0F) + 9;
  12929. }
  12930. return -1;
  12931. }
  12932. Lexer.prototype = {
  12933. nextChar: function Lexer_nextChar() {
  12934. return this.currentChar = this.stream.getByte();
  12935. },
  12936. peekChar: function Lexer_peekChar() {
  12937. return this.stream.peekByte();
  12938. },
  12939. getNumber: function Lexer_getNumber() {
  12940. var ch = this.currentChar;
  12941. var eNotation = false;
  12942. var divideBy = 0;
  12943. var sign = 1;
  12944. if (ch === 0x2D) {
  12945. sign = -1;
  12946. ch = this.nextChar();
  12947. if (ch === 0x2D) {
  12948. ch = this.nextChar();
  12949. }
  12950. } else if (ch === 0x2B) {
  12951. ch = this.nextChar();
  12952. }
  12953. if (ch === 0x2E) {
  12954. divideBy = 10;
  12955. ch = this.nextChar();
  12956. }
  12957. if (ch < 0x30 || ch > 0x39) {
  12958. error('Invalid number: ' + String.fromCharCode(ch));
  12959. return 0;
  12960. }
  12961. var baseValue = ch - 0x30;
  12962. var powerValue = 0;
  12963. var powerValueSign = 1;
  12964. while ((ch = this.nextChar()) >= 0) {
  12965. if (0x30 <= ch && ch <= 0x39) {
  12966. var currentDigit = ch - 0x30;
  12967. if (eNotation) {
  12968. powerValue = powerValue * 10 + currentDigit;
  12969. } else {
  12970. if (divideBy !== 0) {
  12971. divideBy *= 10;
  12972. }
  12973. baseValue = baseValue * 10 + currentDigit;
  12974. }
  12975. } else if (ch === 0x2E) {
  12976. if (divideBy === 0) {
  12977. divideBy = 1;
  12978. } else {
  12979. break;
  12980. }
  12981. } else if (ch === 0x2D) {
  12982. warn('Badly formatted number');
  12983. } else if (ch === 0x45 || ch === 0x65) {
  12984. ch = this.peekChar();
  12985. if (ch === 0x2B || ch === 0x2D) {
  12986. powerValueSign = ch === 0x2D ? -1 : 1;
  12987. this.nextChar();
  12988. } else if (ch < 0x30 || ch > 0x39) {
  12989. break;
  12990. }
  12991. eNotation = true;
  12992. } else {
  12993. break;
  12994. }
  12995. }
  12996. if (divideBy !== 0) {
  12997. baseValue /= divideBy;
  12998. }
  12999. if (eNotation) {
  13000. baseValue *= Math.pow(10, powerValueSign * powerValue);
  13001. }
  13002. return sign * baseValue;
  13003. },
  13004. getString: function Lexer_getString() {
  13005. var numParen = 1;
  13006. var done = false;
  13007. var strBuf = this.strBuf;
  13008. strBuf.length = 0;
  13009. var ch = this.nextChar();
  13010. while (true) {
  13011. var charBuffered = false;
  13012. switch (ch | 0) {
  13013. case -1:
  13014. warn('Unterminated string');
  13015. done = true;
  13016. break;
  13017. case 0x28:
  13018. ++numParen;
  13019. strBuf.push('(');
  13020. break;
  13021. case 0x29:
  13022. if (--numParen === 0) {
  13023. this.nextChar();
  13024. done = true;
  13025. } else {
  13026. strBuf.push(')');
  13027. }
  13028. break;
  13029. case 0x5C:
  13030. ch = this.nextChar();
  13031. switch (ch) {
  13032. case -1:
  13033. warn('Unterminated string');
  13034. done = true;
  13035. break;
  13036. case 0x6E:
  13037. strBuf.push('\n');
  13038. break;
  13039. case 0x72:
  13040. strBuf.push('\r');
  13041. break;
  13042. case 0x74:
  13043. strBuf.push('\t');
  13044. break;
  13045. case 0x62:
  13046. strBuf.push('\b');
  13047. break;
  13048. case 0x66:
  13049. strBuf.push('\f');
  13050. break;
  13051. case 0x5C:
  13052. case 0x28:
  13053. case 0x29:
  13054. strBuf.push(String.fromCharCode(ch));
  13055. break;
  13056. case 0x30:
  13057. case 0x31:
  13058. case 0x32:
  13059. case 0x33:
  13060. case 0x34:
  13061. case 0x35:
  13062. case 0x36:
  13063. case 0x37:
  13064. var x = ch & 0x0F;
  13065. ch = this.nextChar();
  13066. charBuffered = true;
  13067. if (ch >= 0x30 && ch <= 0x37) {
  13068. x = (x << 3) + (ch & 0x0F);
  13069. ch = this.nextChar();
  13070. if (ch >= 0x30 && ch <= 0x37) {
  13071. charBuffered = false;
  13072. x = (x << 3) + (ch & 0x0F);
  13073. }
  13074. }
  13075. strBuf.push(String.fromCharCode(x));
  13076. break;
  13077. case 0x0D:
  13078. if (this.peekChar() === 0x0A) {
  13079. this.nextChar();
  13080. }
  13081. break;
  13082. case 0x0A:
  13083. break;
  13084. default:
  13085. strBuf.push(String.fromCharCode(ch));
  13086. break;
  13087. }
  13088. break;
  13089. default:
  13090. strBuf.push(String.fromCharCode(ch));
  13091. break;
  13092. }
  13093. if (done) {
  13094. break;
  13095. }
  13096. if (!charBuffered) {
  13097. ch = this.nextChar();
  13098. }
  13099. }
  13100. return strBuf.join('');
  13101. },
  13102. getName: function Lexer_getName() {
  13103. var ch, previousCh;
  13104. var strBuf = this.strBuf;
  13105. strBuf.length = 0;
  13106. while ((ch = this.nextChar()) >= 0 && !specialChars[ch]) {
  13107. if (ch === 0x23) {
  13108. ch = this.nextChar();
  13109. if (specialChars[ch]) {
  13110. warn('Lexer_getName: ' + 'NUMBER SIGN (#) should be followed by a hexadecimal number.');
  13111. strBuf.push('#');
  13112. break;
  13113. }
  13114. var x = toHexDigit(ch);
  13115. if (x !== -1) {
  13116. previousCh = ch;
  13117. ch = this.nextChar();
  13118. var x2 = toHexDigit(ch);
  13119. if (x2 === -1) {
  13120. warn('Lexer_getName: Illegal digit (' + String.fromCharCode(ch) + ') in hexadecimal number.');
  13121. strBuf.push('#', String.fromCharCode(previousCh));
  13122. if (specialChars[ch]) {
  13123. break;
  13124. }
  13125. strBuf.push(String.fromCharCode(ch));
  13126. continue;
  13127. }
  13128. strBuf.push(String.fromCharCode(x << 4 | x2));
  13129. } else {
  13130. strBuf.push('#', String.fromCharCode(ch));
  13131. }
  13132. } else {
  13133. strBuf.push(String.fromCharCode(ch));
  13134. }
  13135. }
  13136. if (strBuf.length > 127) {
  13137. warn('name token is longer than allowed by the spec: ' + strBuf.length);
  13138. }
  13139. return Name.get(strBuf.join(''));
  13140. },
  13141. getHexString: function Lexer_getHexString() {
  13142. var strBuf = this.strBuf;
  13143. strBuf.length = 0;
  13144. var ch = this.currentChar;
  13145. var isFirstHex = true;
  13146. var firstDigit;
  13147. var secondDigit;
  13148. while (true) {
  13149. if (ch < 0) {
  13150. warn('Unterminated hex string');
  13151. break;
  13152. } else if (ch === 0x3E) {
  13153. this.nextChar();
  13154. break;
  13155. } else if (specialChars[ch] === 1) {
  13156. ch = this.nextChar();
  13157. continue;
  13158. } else {
  13159. if (isFirstHex) {
  13160. firstDigit = toHexDigit(ch);
  13161. if (firstDigit === -1) {
  13162. warn('Ignoring invalid character "' + ch + '" in hex string');
  13163. ch = this.nextChar();
  13164. continue;
  13165. }
  13166. } else {
  13167. secondDigit = toHexDigit(ch);
  13168. if (secondDigit === -1) {
  13169. warn('Ignoring invalid character "' + ch + '" in hex string');
  13170. ch = this.nextChar();
  13171. continue;
  13172. }
  13173. strBuf.push(String.fromCharCode(firstDigit << 4 | secondDigit));
  13174. }
  13175. isFirstHex = !isFirstHex;
  13176. ch = this.nextChar();
  13177. }
  13178. }
  13179. return strBuf.join('');
  13180. },
  13181. getObj: function Lexer_getObj() {
  13182. var comment = false;
  13183. var ch = this.currentChar;
  13184. while (true) {
  13185. if (ch < 0) {
  13186. return EOF;
  13187. }
  13188. if (comment) {
  13189. if (ch === 0x0A || ch === 0x0D) {
  13190. comment = false;
  13191. }
  13192. } else if (ch === 0x25) {
  13193. comment = true;
  13194. } else if (specialChars[ch] !== 1) {
  13195. break;
  13196. }
  13197. ch = this.nextChar();
  13198. }
  13199. switch (ch | 0) {
  13200. case 0x30:
  13201. case 0x31:
  13202. case 0x32:
  13203. case 0x33:
  13204. case 0x34:
  13205. case 0x35:
  13206. case 0x36:
  13207. case 0x37:
  13208. case 0x38:
  13209. case 0x39:
  13210. case 0x2B:
  13211. case 0x2D:
  13212. case 0x2E:
  13213. return this.getNumber();
  13214. case 0x28:
  13215. return this.getString();
  13216. case 0x2F:
  13217. return this.getName();
  13218. case 0x5B:
  13219. this.nextChar();
  13220. return Cmd.get('[');
  13221. case 0x5D:
  13222. this.nextChar();
  13223. return Cmd.get(']');
  13224. case 0x3C:
  13225. ch = this.nextChar();
  13226. if (ch === 0x3C) {
  13227. this.nextChar();
  13228. return Cmd.get('<<');
  13229. }
  13230. return this.getHexString();
  13231. case 0x3E:
  13232. ch = this.nextChar();
  13233. if (ch === 0x3E) {
  13234. this.nextChar();
  13235. return Cmd.get('>>');
  13236. }
  13237. return Cmd.get('>');
  13238. case 0x7B:
  13239. this.nextChar();
  13240. return Cmd.get('{');
  13241. case 0x7D:
  13242. this.nextChar();
  13243. return Cmd.get('}');
  13244. case 0x29:
  13245. error('Illegal character: ' + ch);
  13246. break;
  13247. }
  13248. var str = String.fromCharCode(ch);
  13249. var knownCommands = this.knownCommands;
  13250. var knownCommandFound = knownCommands && knownCommands[str] !== undefined;
  13251. while ((ch = this.nextChar()) >= 0 && !specialChars[ch]) {
  13252. var possibleCommand = str + String.fromCharCode(ch);
  13253. if (knownCommandFound && knownCommands[possibleCommand] === undefined) {
  13254. break;
  13255. }
  13256. if (str.length === 128) {
  13257. error('Command token too long: ' + str.length);
  13258. }
  13259. str = possibleCommand;
  13260. knownCommandFound = knownCommands && knownCommands[str] !== undefined;
  13261. }
  13262. if (str === 'true') {
  13263. return true;
  13264. }
  13265. if (str === 'false') {
  13266. return false;
  13267. }
  13268. if (str === 'null') {
  13269. return null;
  13270. }
  13271. return Cmd.get(str);
  13272. },
  13273. skipToNextLine: function Lexer_skipToNextLine() {
  13274. var ch = this.currentChar;
  13275. while (ch >= 0) {
  13276. if (ch === 0x0D) {
  13277. ch = this.nextChar();
  13278. if (ch === 0x0A) {
  13279. this.nextChar();
  13280. }
  13281. break;
  13282. } else if (ch === 0x0A) {
  13283. this.nextChar();
  13284. break;
  13285. }
  13286. ch = this.nextChar();
  13287. }
  13288. }
  13289. };
  13290. return Lexer;
  13291. }();
  13292. var Linearization = {
  13293. create: function LinearizationCreate(stream) {
  13294. function getInt(name, allowZeroValue) {
  13295. var obj = linDict.get(name);
  13296. if (isInt(obj) && (allowZeroValue ? obj >= 0 : obj > 0)) {
  13297. return obj;
  13298. }
  13299. throw new Error('The "' + name + '" parameter in the linearization ' + 'dictionary is invalid.');
  13300. }
  13301. function getHints() {
  13302. var hints = linDict.get('H'), hintsLength, item;
  13303. if (isArray(hints) && ((hintsLength = hints.length) === 2 || hintsLength === 4)) {
  13304. for (var index = 0; index < hintsLength; index++) {
  13305. if (!(isInt(item = hints[index]) && item > 0)) {
  13306. throw new Error('Hint (' + index + ') in the linearization dictionary is invalid.');
  13307. }
  13308. }
  13309. return hints;
  13310. }
  13311. throw new Error('Hint array in the linearization dictionary is invalid.');
  13312. }
  13313. var parser = new Parser(new Lexer(stream), false, null);
  13314. var obj1 = parser.getObj();
  13315. var obj2 = parser.getObj();
  13316. var obj3 = parser.getObj();
  13317. var linDict = parser.getObj();
  13318. var obj, length;
  13319. if (!(isInt(obj1) && isInt(obj2) && isCmd(obj3, 'obj') && isDict(linDict) && isNum(obj = linDict.get('Linearized')) && obj > 0)) {
  13320. return null;
  13321. } else if ((length = getInt('L')) !== stream.length) {
  13322. throw new Error('The "L" parameter in the linearization dictionary ' + 'does not equal the stream length.');
  13323. }
  13324. return {
  13325. length: length,
  13326. hints: getHints(),
  13327. objectNumberFirst: getInt('O'),
  13328. endFirst: getInt('E'),
  13329. numPages: getInt('N'),
  13330. mainXRefEntriesOffset: getInt('T'),
  13331. pageFirst: linDict.has('P') ? getInt('P', true) : 0
  13332. };
  13333. }
  13334. };
  13335. exports.Lexer = Lexer;
  13336. exports.Linearization = Linearization;
  13337. exports.Parser = Parser;
  13338. /***/ }),
  13339. /* 7 */
  13340. /***/ (function(module, exports, __w_pdfjs_require__) {
  13341. "use strict";
  13342. var sharedUtil = __w_pdfjs_require__(0);
  13343. var corePrimitives = __w_pdfjs_require__(1);
  13344. var corePsParser = __w_pdfjs_require__(43);
  13345. var error = sharedUtil.error;
  13346. var info = sharedUtil.info;
  13347. var isArray = sharedUtil.isArray;
  13348. var isBool = sharedUtil.isBool;
  13349. var isDict = corePrimitives.isDict;
  13350. var isStream = corePrimitives.isStream;
  13351. var PostScriptLexer = corePsParser.PostScriptLexer;
  13352. var PostScriptParser = corePsParser.PostScriptParser;
  13353. var PDFFunction = function PDFFunctionClosure() {
  13354. var CONSTRUCT_SAMPLED = 0;
  13355. var CONSTRUCT_INTERPOLATED = 2;
  13356. var CONSTRUCT_STICHED = 3;
  13357. var CONSTRUCT_POSTSCRIPT = 4;
  13358. return {
  13359. getSampleArray: function PDFFunction_getSampleArray(size, outputSize, bps, str) {
  13360. var i, ii;
  13361. var length = 1;
  13362. for (i = 0, ii = size.length; i < ii; i++) {
  13363. length *= size[i];
  13364. }
  13365. length *= outputSize;
  13366. var array = new Array(length);
  13367. var codeSize = 0;
  13368. var codeBuf = 0;
  13369. var sampleMul = 1.0 / (Math.pow(2.0, bps) - 1);
  13370. var strBytes = str.getBytes((length * bps + 7) / 8);
  13371. var strIdx = 0;
  13372. for (i = 0; i < length; i++) {
  13373. while (codeSize < bps) {
  13374. codeBuf <<= 8;
  13375. codeBuf |= strBytes[strIdx++];
  13376. codeSize += 8;
  13377. }
  13378. codeSize -= bps;
  13379. array[i] = (codeBuf >> codeSize) * sampleMul;
  13380. codeBuf &= (1 << codeSize) - 1;
  13381. }
  13382. return array;
  13383. },
  13384. getIR: function PDFFunction_getIR(xref, fn) {
  13385. var dict = fn.dict;
  13386. if (!dict) {
  13387. dict = fn;
  13388. }
  13389. var types = [
  13390. this.constructSampled,
  13391. null,
  13392. this.constructInterpolated,
  13393. this.constructStiched,
  13394. this.constructPostScript
  13395. ];
  13396. var typeNum = dict.get('FunctionType');
  13397. var typeFn = types[typeNum];
  13398. if (!typeFn) {
  13399. error('Unknown type of function');
  13400. }
  13401. return typeFn.call(this, fn, dict, xref);
  13402. },
  13403. fromIR: function PDFFunction_fromIR(IR) {
  13404. var type = IR[0];
  13405. switch (type) {
  13406. case CONSTRUCT_SAMPLED:
  13407. return this.constructSampledFromIR(IR);
  13408. case CONSTRUCT_INTERPOLATED:
  13409. return this.constructInterpolatedFromIR(IR);
  13410. case CONSTRUCT_STICHED:
  13411. return this.constructStichedFromIR(IR);
  13412. default:
  13413. return this.constructPostScriptFromIR(IR);
  13414. }
  13415. },
  13416. parse: function PDFFunction_parse(xref, fn) {
  13417. var IR = this.getIR(xref, fn);
  13418. return this.fromIR(IR);
  13419. },
  13420. parseArray: function PDFFunction_parseArray(xref, fnObj) {
  13421. if (!isArray(fnObj)) {
  13422. return this.parse(xref, fnObj);
  13423. }
  13424. var fnArray = [];
  13425. for (var j = 0, jj = fnObj.length; j < jj; j++) {
  13426. var obj = xref.fetchIfRef(fnObj[j]);
  13427. fnArray.push(PDFFunction.parse(xref, obj));
  13428. }
  13429. return function (src, srcOffset, dest, destOffset) {
  13430. for (var i = 0, ii = fnArray.length; i < ii; i++) {
  13431. fnArray[i](src, srcOffset, dest, destOffset + i);
  13432. }
  13433. };
  13434. },
  13435. constructSampled: function PDFFunction_constructSampled(str, dict) {
  13436. function toMultiArray(arr) {
  13437. var inputLength = arr.length;
  13438. var out = [];
  13439. var index = 0;
  13440. for (var i = 0; i < inputLength; i += 2) {
  13441. out[index] = [
  13442. arr[i],
  13443. arr[i + 1]
  13444. ];
  13445. ++index;
  13446. }
  13447. return out;
  13448. }
  13449. var domain = dict.getArray('Domain');
  13450. var range = dict.getArray('Range');
  13451. if (!domain || !range) {
  13452. error('No domain or range');
  13453. }
  13454. var inputSize = domain.length / 2;
  13455. var outputSize = range.length / 2;
  13456. domain = toMultiArray(domain);
  13457. range = toMultiArray(range);
  13458. var size = dict.get('Size');
  13459. var bps = dict.get('BitsPerSample');
  13460. var order = dict.get('Order') || 1;
  13461. if (order !== 1) {
  13462. info('No support for cubic spline interpolation: ' + order);
  13463. }
  13464. var encode = dict.getArray('Encode');
  13465. if (!encode) {
  13466. encode = [];
  13467. for (var i = 0; i < inputSize; ++i) {
  13468. encode.push(0);
  13469. encode.push(size[i] - 1);
  13470. }
  13471. }
  13472. encode = toMultiArray(encode);
  13473. var decode = dict.getArray('Decode');
  13474. if (!decode) {
  13475. decode = range;
  13476. } else {
  13477. decode = toMultiArray(decode);
  13478. }
  13479. var samples = this.getSampleArray(size, outputSize, bps, str);
  13480. return [
  13481. CONSTRUCT_SAMPLED,
  13482. inputSize,
  13483. domain,
  13484. encode,
  13485. decode,
  13486. samples,
  13487. size,
  13488. outputSize,
  13489. Math.pow(2, bps) - 1,
  13490. range
  13491. ];
  13492. },
  13493. constructSampledFromIR: function PDFFunction_constructSampledFromIR(IR) {
  13494. function interpolate(x, xmin, xmax, ymin, ymax) {
  13495. return ymin + (x - xmin) * ((ymax - ymin) / (xmax - xmin));
  13496. }
  13497. return function constructSampledFromIRResult(src, srcOffset, dest, destOffset) {
  13498. var m = IR[1];
  13499. var domain = IR[2];
  13500. var encode = IR[3];
  13501. var decode = IR[4];
  13502. var samples = IR[5];
  13503. var size = IR[6];
  13504. var n = IR[7];
  13505. var range = IR[9];
  13506. var cubeVertices = 1 << m;
  13507. var cubeN = new Float64Array(cubeVertices);
  13508. var cubeVertex = new Uint32Array(cubeVertices);
  13509. var i, j;
  13510. for (j = 0; j < cubeVertices; j++) {
  13511. cubeN[j] = 1;
  13512. }
  13513. var k = n, pos = 1;
  13514. for (i = 0; i < m; ++i) {
  13515. var domain_2i = domain[i][0];
  13516. var domain_2i_1 = domain[i][1];
  13517. var xi = Math.min(Math.max(src[srcOffset + i], domain_2i), domain_2i_1);
  13518. var e = interpolate(xi, domain_2i, domain_2i_1, encode[i][0], encode[i][1]);
  13519. var size_i = size[i];
  13520. e = Math.min(Math.max(e, 0), size_i - 1);
  13521. var e0 = e < size_i - 1 ? Math.floor(e) : e - 1;
  13522. var n0 = e0 + 1 - e;
  13523. var n1 = e - e0;
  13524. var offset0 = e0 * k;
  13525. var offset1 = offset0 + k;
  13526. for (j = 0; j < cubeVertices; j++) {
  13527. if (j & pos) {
  13528. cubeN[j] *= n1;
  13529. cubeVertex[j] += offset1;
  13530. } else {
  13531. cubeN[j] *= n0;
  13532. cubeVertex[j] += offset0;
  13533. }
  13534. }
  13535. k *= size_i;
  13536. pos <<= 1;
  13537. }
  13538. for (j = 0; j < n; ++j) {
  13539. var rj = 0;
  13540. for (i = 0; i < cubeVertices; i++) {
  13541. rj += samples[cubeVertex[i] + j] * cubeN[i];
  13542. }
  13543. rj = interpolate(rj, 0, 1, decode[j][0], decode[j][1]);
  13544. dest[destOffset + j] = Math.min(Math.max(rj, range[j][0]), range[j][1]);
  13545. }
  13546. };
  13547. },
  13548. constructInterpolated: function PDFFunction_constructInterpolated(str, dict) {
  13549. var c0 = dict.getArray('C0') || [0];
  13550. var c1 = dict.getArray('C1') || [1];
  13551. var n = dict.get('N');
  13552. if (!isArray(c0) || !isArray(c1)) {
  13553. error('Illegal dictionary for interpolated function');
  13554. }
  13555. var length = c0.length;
  13556. var diff = [];
  13557. for (var i = 0; i < length; ++i) {
  13558. diff.push(c1[i] - c0[i]);
  13559. }
  13560. return [
  13561. CONSTRUCT_INTERPOLATED,
  13562. c0,
  13563. diff,
  13564. n
  13565. ];
  13566. },
  13567. constructInterpolatedFromIR: function PDFFunction_constructInterpolatedFromIR(IR) {
  13568. var c0 = IR[1];
  13569. var diff = IR[2];
  13570. var n = IR[3];
  13571. var length = diff.length;
  13572. return function constructInterpolatedFromIRResult(src, srcOffset, dest, destOffset) {
  13573. var x = n === 1 ? src[srcOffset] : Math.pow(src[srcOffset], n);
  13574. for (var j = 0; j < length; ++j) {
  13575. dest[destOffset + j] = c0[j] + x * diff[j];
  13576. }
  13577. };
  13578. },
  13579. constructStiched: function PDFFunction_constructStiched(fn, dict, xref) {
  13580. var domain = dict.getArray('Domain');
  13581. if (!domain) {
  13582. error('No domain');
  13583. }
  13584. var inputSize = domain.length / 2;
  13585. if (inputSize !== 1) {
  13586. error('Bad domain for stiched function');
  13587. }
  13588. var fnRefs = dict.get('Functions');
  13589. var fns = [];
  13590. for (var i = 0, ii = fnRefs.length; i < ii; ++i) {
  13591. fns.push(PDFFunction.getIR(xref, xref.fetchIfRef(fnRefs[i])));
  13592. }
  13593. var bounds = dict.getArray('Bounds');
  13594. var encode = dict.getArray('Encode');
  13595. return [
  13596. CONSTRUCT_STICHED,
  13597. domain,
  13598. bounds,
  13599. encode,
  13600. fns
  13601. ];
  13602. },
  13603. constructStichedFromIR: function PDFFunction_constructStichedFromIR(IR) {
  13604. var domain = IR[1];
  13605. var bounds = IR[2];
  13606. var encode = IR[3];
  13607. var fnsIR = IR[4];
  13608. var fns = [];
  13609. var tmpBuf = new Float32Array(1);
  13610. for (var i = 0, ii = fnsIR.length; i < ii; i++) {
  13611. fns.push(PDFFunction.fromIR(fnsIR[i]));
  13612. }
  13613. return function constructStichedFromIRResult(src, srcOffset, dest, destOffset) {
  13614. var clip = function constructStichedFromIRClip(v, min, max) {
  13615. if (v > max) {
  13616. v = max;
  13617. } else if (v < min) {
  13618. v = min;
  13619. }
  13620. return v;
  13621. };
  13622. var v = clip(src[srcOffset], domain[0], domain[1]);
  13623. for (var i = 0, ii = bounds.length; i < ii; ++i) {
  13624. if (v < bounds[i]) {
  13625. break;
  13626. }
  13627. }
  13628. var dmin = domain[0];
  13629. if (i > 0) {
  13630. dmin = bounds[i - 1];
  13631. }
  13632. var dmax = domain[1];
  13633. if (i < bounds.length) {
  13634. dmax = bounds[i];
  13635. }
  13636. var rmin = encode[2 * i];
  13637. var rmax = encode[2 * i + 1];
  13638. tmpBuf[0] = dmin === dmax ? rmin : rmin + (v - dmin) * (rmax - rmin) / (dmax - dmin);
  13639. fns[i](tmpBuf, 0, dest, destOffset);
  13640. };
  13641. },
  13642. constructPostScript: function PDFFunction_constructPostScript(fn, dict, xref) {
  13643. var domain = dict.getArray('Domain');
  13644. var range = dict.getArray('Range');
  13645. if (!domain) {
  13646. error('No domain.');
  13647. }
  13648. if (!range) {
  13649. error('No range.');
  13650. }
  13651. var lexer = new PostScriptLexer(fn);
  13652. var parser = new PostScriptParser(lexer);
  13653. var code = parser.parse();
  13654. return [
  13655. CONSTRUCT_POSTSCRIPT,
  13656. domain,
  13657. range,
  13658. code
  13659. ];
  13660. },
  13661. constructPostScriptFromIR: function PDFFunction_constructPostScriptFromIR(IR) {
  13662. var domain = IR[1];
  13663. var range = IR[2];
  13664. var code = IR[3];
  13665. var compiled = new PostScriptCompiler().compile(code, domain, range);
  13666. if (compiled) {
  13667. return new Function('src', 'srcOffset', 'dest', 'destOffset', compiled);
  13668. }
  13669. info('Unable to compile PS function');
  13670. var numOutputs = range.length >> 1;
  13671. var numInputs = domain.length >> 1;
  13672. var evaluator = new PostScriptEvaluator(code);
  13673. var cache = Object.create(null);
  13674. var MAX_CACHE_SIZE = 2048 * 4;
  13675. var cache_available = MAX_CACHE_SIZE;
  13676. var tmpBuf = new Float32Array(numInputs);
  13677. return function constructPostScriptFromIRResult(src, srcOffset, dest, destOffset) {
  13678. var i, value;
  13679. var key = '';
  13680. var input = tmpBuf;
  13681. for (i = 0; i < numInputs; i++) {
  13682. value = src[srcOffset + i];
  13683. input[i] = value;
  13684. key += value + '_';
  13685. }
  13686. var cachedValue = cache[key];
  13687. if (cachedValue !== undefined) {
  13688. dest.set(cachedValue, destOffset);
  13689. return;
  13690. }
  13691. var output = new Float32Array(numOutputs);
  13692. var stack = evaluator.execute(input);
  13693. var stackIndex = stack.length - numOutputs;
  13694. for (i = 0; i < numOutputs; i++) {
  13695. value = stack[stackIndex + i];
  13696. var bound = range[i * 2];
  13697. if (value < bound) {
  13698. value = bound;
  13699. } else {
  13700. bound = range[i * 2 + 1];
  13701. if (value > bound) {
  13702. value = bound;
  13703. }
  13704. }
  13705. output[i] = value;
  13706. }
  13707. if (cache_available > 0) {
  13708. cache_available--;
  13709. cache[key] = output;
  13710. }
  13711. dest.set(output, destOffset);
  13712. };
  13713. }
  13714. };
  13715. }();
  13716. function isPDFFunction(v) {
  13717. var fnDict;
  13718. if (typeof v !== 'object') {
  13719. return false;
  13720. } else if (isDict(v)) {
  13721. fnDict = v;
  13722. } else if (isStream(v)) {
  13723. fnDict = v.dict;
  13724. } else {
  13725. return false;
  13726. }
  13727. return fnDict.has('FunctionType');
  13728. }
  13729. var PostScriptStack = function PostScriptStackClosure() {
  13730. var MAX_STACK_SIZE = 100;
  13731. function PostScriptStack(initialStack) {
  13732. this.stack = !initialStack ? [] : Array.prototype.slice.call(initialStack, 0);
  13733. }
  13734. PostScriptStack.prototype = {
  13735. push: function PostScriptStack_push(value) {
  13736. if (this.stack.length >= MAX_STACK_SIZE) {
  13737. error('PostScript function stack overflow.');
  13738. }
  13739. this.stack.push(value);
  13740. },
  13741. pop: function PostScriptStack_pop() {
  13742. if (this.stack.length <= 0) {
  13743. error('PostScript function stack underflow.');
  13744. }
  13745. return this.stack.pop();
  13746. },
  13747. copy: function PostScriptStack_copy(n) {
  13748. if (this.stack.length + n >= MAX_STACK_SIZE) {
  13749. error('PostScript function stack overflow.');
  13750. }
  13751. var stack = this.stack;
  13752. for (var i = stack.length - n, j = n - 1; j >= 0; j--, i++) {
  13753. stack.push(stack[i]);
  13754. }
  13755. },
  13756. index: function PostScriptStack_index(n) {
  13757. this.push(this.stack[this.stack.length - n - 1]);
  13758. },
  13759. roll: function PostScriptStack_roll(n, p) {
  13760. var stack = this.stack;
  13761. var l = stack.length - n;
  13762. var r = stack.length - 1, c = l + (p - Math.floor(p / n) * n), i, j, t;
  13763. for (i = l, j = r; i < j; i++, j--) {
  13764. t = stack[i];
  13765. stack[i] = stack[j];
  13766. stack[j] = t;
  13767. }
  13768. for (i = l, j = c - 1; i < j; i++, j--) {
  13769. t = stack[i];
  13770. stack[i] = stack[j];
  13771. stack[j] = t;
  13772. }
  13773. for (i = c, j = r; i < j; i++, j--) {
  13774. t = stack[i];
  13775. stack[i] = stack[j];
  13776. stack[j] = t;
  13777. }
  13778. }
  13779. };
  13780. return PostScriptStack;
  13781. }();
  13782. var PostScriptEvaluator = function PostScriptEvaluatorClosure() {
  13783. function PostScriptEvaluator(operators) {
  13784. this.operators = operators;
  13785. }
  13786. PostScriptEvaluator.prototype = {
  13787. execute: function PostScriptEvaluator_execute(initialStack) {
  13788. var stack = new PostScriptStack(initialStack);
  13789. var counter = 0;
  13790. var operators = this.operators;
  13791. var length = operators.length;
  13792. var operator, a, b;
  13793. while (counter < length) {
  13794. operator = operators[counter++];
  13795. if (typeof operator === 'number') {
  13796. stack.push(operator);
  13797. continue;
  13798. }
  13799. switch (operator) {
  13800. case 'jz':
  13801. b = stack.pop();
  13802. a = stack.pop();
  13803. if (!a) {
  13804. counter = b;
  13805. }
  13806. break;
  13807. case 'j':
  13808. a = stack.pop();
  13809. counter = a;
  13810. break;
  13811. case 'abs':
  13812. a = stack.pop();
  13813. stack.push(Math.abs(a));
  13814. break;
  13815. case 'add':
  13816. b = stack.pop();
  13817. a = stack.pop();
  13818. stack.push(a + b);
  13819. break;
  13820. case 'and':
  13821. b = stack.pop();
  13822. a = stack.pop();
  13823. if (isBool(a) && isBool(b)) {
  13824. stack.push(a && b);
  13825. } else {
  13826. stack.push(a & b);
  13827. }
  13828. break;
  13829. case 'atan':
  13830. a = stack.pop();
  13831. stack.push(Math.atan(a));
  13832. break;
  13833. case 'bitshift':
  13834. b = stack.pop();
  13835. a = stack.pop();
  13836. if (a > 0) {
  13837. stack.push(a << b);
  13838. } else {
  13839. stack.push(a >> b);
  13840. }
  13841. break;
  13842. case 'ceiling':
  13843. a = stack.pop();
  13844. stack.push(Math.ceil(a));
  13845. break;
  13846. case 'copy':
  13847. a = stack.pop();
  13848. stack.copy(a);
  13849. break;
  13850. case 'cos':
  13851. a = stack.pop();
  13852. stack.push(Math.cos(a));
  13853. break;
  13854. case 'cvi':
  13855. a = stack.pop() | 0;
  13856. stack.push(a);
  13857. break;
  13858. case 'cvr':
  13859. break;
  13860. case 'div':
  13861. b = stack.pop();
  13862. a = stack.pop();
  13863. stack.push(a / b);
  13864. break;
  13865. case 'dup':
  13866. stack.copy(1);
  13867. break;
  13868. case 'eq':
  13869. b = stack.pop();
  13870. a = stack.pop();
  13871. stack.push(a === b);
  13872. break;
  13873. case 'exch':
  13874. stack.roll(2, 1);
  13875. break;
  13876. case 'exp':
  13877. b = stack.pop();
  13878. a = stack.pop();
  13879. stack.push(Math.pow(a, b));
  13880. break;
  13881. case 'false':
  13882. stack.push(false);
  13883. break;
  13884. case 'floor':
  13885. a = stack.pop();
  13886. stack.push(Math.floor(a));
  13887. break;
  13888. case 'ge':
  13889. b = stack.pop();
  13890. a = stack.pop();
  13891. stack.push(a >= b);
  13892. break;
  13893. case 'gt':
  13894. b = stack.pop();
  13895. a = stack.pop();
  13896. stack.push(a > b);
  13897. break;
  13898. case 'idiv':
  13899. b = stack.pop();
  13900. a = stack.pop();
  13901. stack.push(a / b | 0);
  13902. break;
  13903. case 'index':
  13904. a = stack.pop();
  13905. stack.index(a);
  13906. break;
  13907. case 'le':
  13908. b = stack.pop();
  13909. a = stack.pop();
  13910. stack.push(a <= b);
  13911. break;
  13912. case 'ln':
  13913. a = stack.pop();
  13914. stack.push(Math.log(a));
  13915. break;
  13916. case 'log':
  13917. a = stack.pop();
  13918. stack.push(Math.log(a) / Math.LN10);
  13919. break;
  13920. case 'lt':
  13921. b = stack.pop();
  13922. a = stack.pop();
  13923. stack.push(a < b);
  13924. break;
  13925. case 'mod':
  13926. b = stack.pop();
  13927. a = stack.pop();
  13928. stack.push(a % b);
  13929. break;
  13930. case 'mul':
  13931. b = stack.pop();
  13932. a = stack.pop();
  13933. stack.push(a * b);
  13934. break;
  13935. case 'ne':
  13936. b = stack.pop();
  13937. a = stack.pop();
  13938. stack.push(a !== b);
  13939. break;
  13940. case 'neg':
  13941. a = stack.pop();
  13942. stack.push(-a);
  13943. break;
  13944. case 'not':
  13945. a = stack.pop();
  13946. if (isBool(a)) {
  13947. stack.push(!a);
  13948. } else {
  13949. stack.push(~a);
  13950. }
  13951. break;
  13952. case 'or':
  13953. b = stack.pop();
  13954. a = stack.pop();
  13955. if (isBool(a) && isBool(b)) {
  13956. stack.push(a || b);
  13957. } else {
  13958. stack.push(a | b);
  13959. }
  13960. break;
  13961. case 'pop':
  13962. stack.pop();
  13963. break;
  13964. case 'roll':
  13965. b = stack.pop();
  13966. a = stack.pop();
  13967. stack.roll(a, b);
  13968. break;
  13969. case 'round':
  13970. a = stack.pop();
  13971. stack.push(Math.round(a));
  13972. break;
  13973. case 'sin':
  13974. a = stack.pop();
  13975. stack.push(Math.sin(a));
  13976. break;
  13977. case 'sqrt':
  13978. a = stack.pop();
  13979. stack.push(Math.sqrt(a));
  13980. break;
  13981. case 'sub':
  13982. b = stack.pop();
  13983. a = stack.pop();
  13984. stack.push(a - b);
  13985. break;
  13986. case 'true':
  13987. stack.push(true);
  13988. break;
  13989. case 'truncate':
  13990. a = stack.pop();
  13991. a = a < 0 ? Math.ceil(a) : Math.floor(a);
  13992. stack.push(a);
  13993. break;
  13994. case 'xor':
  13995. b = stack.pop();
  13996. a = stack.pop();
  13997. if (isBool(a) && isBool(b)) {
  13998. stack.push(a !== b);
  13999. } else {
  14000. stack.push(a ^ b);
  14001. }
  14002. break;
  14003. default:
  14004. error('Unknown operator ' + operator);
  14005. break;
  14006. }
  14007. }
  14008. return stack.stack;
  14009. }
  14010. };
  14011. return PostScriptEvaluator;
  14012. }();
  14013. var PostScriptCompiler = function PostScriptCompilerClosure() {
  14014. function AstNode(type) {
  14015. this.type = type;
  14016. }
  14017. AstNode.prototype.visit = function (visitor) {
  14018. throw new Error('abstract method');
  14019. };
  14020. function AstArgument(index, min, max) {
  14021. AstNode.call(this, 'args');
  14022. this.index = index;
  14023. this.min = min;
  14024. this.max = max;
  14025. }
  14026. AstArgument.prototype = Object.create(AstNode.prototype);
  14027. AstArgument.prototype.visit = function (visitor) {
  14028. visitor.visitArgument(this);
  14029. };
  14030. function AstLiteral(number) {
  14031. AstNode.call(this, 'literal');
  14032. this.number = number;
  14033. this.min = number;
  14034. this.max = number;
  14035. }
  14036. AstLiteral.prototype = Object.create(AstNode.prototype);
  14037. AstLiteral.prototype.visit = function (visitor) {
  14038. visitor.visitLiteral(this);
  14039. };
  14040. function AstBinaryOperation(op, arg1, arg2, min, max) {
  14041. AstNode.call(this, 'binary');
  14042. this.op = op;
  14043. this.arg1 = arg1;
  14044. this.arg2 = arg2;
  14045. this.min = min;
  14046. this.max = max;
  14047. }
  14048. AstBinaryOperation.prototype = Object.create(AstNode.prototype);
  14049. AstBinaryOperation.prototype.visit = function (visitor) {
  14050. visitor.visitBinaryOperation(this);
  14051. };
  14052. function AstMin(arg, max) {
  14053. AstNode.call(this, 'max');
  14054. this.arg = arg;
  14055. this.min = arg.min;
  14056. this.max = max;
  14057. }
  14058. AstMin.prototype = Object.create(AstNode.prototype);
  14059. AstMin.prototype.visit = function (visitor) {
  14060. visitor.visitMin(this);
  14061. };
  14062. function AstVariable(index, min, max) {
  14063. AstNode.call(this, 'var');
  14064. this.index = index;
  14065. this.min = min;
  14066. this.max = max;
  14067. }
  14068. AstVariable.prototype = Object.create(AstNode.prototype);
  14069. AstVariable.prototype.visit = function (visitor) {
  14070. visitor.visitVariable(this);
  14071. };
  14072. function AstVariableDefinition(variable, arg) {
  14073. AstNode.call(this, 'definition');
  14074. this.variable = variable;
  14075. this.arg = arg;
  14076. }
  14077. AstVariableDefinition.prototype = Object.create(AstNode.prototype);
  14078. AstVariableDefinition.prototype.visit = function (visitor) {
  14079. visitor.visitVariableDefinition(this);
  14080. };
  14081. function ExpressionBuilderVisitor() {
  14082. this.parts = [];
  14083. }
  14084. ExpressionBuilderVisitor.prototype = {
  14085. visitArgument: function (arg) {
  14086. this.parts.push('Math.max(', arg.min, ', Math.min(', arg.max, ', src[srcOffset + ', arg.index, ']))');
  14087. },
  14088. visitVariable: function (variable) {
  14089. this.parts.push('v', variable.index);
  14090. },
  14091. visitLiteral: function (literal) {
  14092. this.parts.push(literal.number);
  14093. },
  14094. visitBinaryOperation: function (operation) {
  14095. this.parts.push('(');
  14096. operation.arg1.visit(this);
  14097. this.parts.push(' ', operation.op, ' ');
  14098. operation.arg2.visit(this);
  14099. this.parts.push(')');
  14100. },
  14101. visitVariableDefinition: function (definition) {
  14102. this.parts.push('var ');
  14103. definition.variable.visit(this);
  14104. this.parts.push(' = ');
  14105. definition.arg.visit(this);
  14106. this.parts.push(';');
  14107. },
  14108. visitMin: function (max) {
  14109. this.parts.push('Math.min(');
  14110. max.arg.visit(this);
  14111. this.parts.push(', ', max.max, ')');
  14112. },
  14113. toString: function () {
  14114. return this.parts.join('');
  14115. }
  14116. };
  14117. function buildAddOperation(num1, num2) {
  14118. if (num2.type === 'literal' && num2.number === 0) {
  14119. return num1;
  14120. }
  14121. if (num1.type === 'literal' && num1.number === 0) {
  14122. return num2;
  14123. }
  14124. if (num2.type === 'literal' && num1.type === 'literal') {
  14125. return new AstLiteral(num1.number + num2.number);
  14126. }
  14127. return new AstBinaryOperation('+', num1, num2, num1.min + num2.min, num1.max + num2.max);
  14128. }
  14129. function buildMulOperation(num1, num2) {
  14130. if (num2.type === 'literal') {
  14131. if (num2.number === 0) {
  14132. return new AstLiteral(0);
  14133. } else if (num2.number === 1) {
  14134. return num1;
  14135. } else if (num1.type === 'literal') {
  14136. return new AstLiteral(num1.number * num2.number);
  14137. }
  14138. }
  14139. if (num1.type === 'literal') {
  14140. if (num1.number === 0) {
  14141. return new AstLiteral(0);
  14142. } else if (num1.number === 1) {
  14143. return num2;
  14144. }
  14145. }
  14146. var min = Math.min(num1.min * num2.min, num1.min * num2.max, num1.max * num2.min, num1.max * num2.max);
  14147. var max = Math.max(num1.min * num2.min, num1.min * num2.max, num1.max * num2.min, num1.max * num2.max);
  14148. return new AstBinaryOperation('*', num1, num2, min, max);
  14149. }
  14150. function buildSubOperation(num1, num2) {
  14151. if (num2.type === 'literal') {
  14152. if (num2.number === 0) {
  14153. return num1;
  14154. } else if (num1.type === 'literal') {
  14155. return new AstLiteral(num1.number - num2.number);
  14156. }
  14157. }
  14158. if (num2.type === 'binary' && num2.op === '-' && num1.type === 'literal' && num1.number === 1 && num2.arg1.type === 'literal' && num2.arg1.number === 1) {
  14159. return num2.arg2;
  14160. }
  14161. return new AstBinaryOperation('-', num1, num2, num1.min - num2.max, num1.max - num2.min);
  14162. }
  14163. function buildMinOperation(num1, max) {
  14164. if (num1.min >= max) {
  14165. return new AstLiteral(max);
  14166. } else if (num1.max <= max) {
  14167. return num1;
  14168. }
  14169. return new AstMin(num1, max);
  14170. }
  14171. function PostScriptCompiler() {
  14172. }
  14173. PostScriptCompiler.prototype = {
  14174. compile: function PostScriptCompiler_compile(code, domain, range) {
  14175. var stack = [];
  14176. var i, ii;
  14177. var instructions = [];
  14178. var inputSize = domain.length >> 1, outputSize = range.length >> 1;
  14179. var lastRegister = 0;
  14180. var n, j;
  14181. var num1, num2, ast1, ast2, tmpVar, item;
  14182. for (i = 0; i < inputSize; i++) {
  14183. stack.push(new AstArgument(i, domain[i * 2], domain[i * 2 + 1]));
  14184. }
  14185. for (i = 0, ii = code.length; i < ii; i++) {
  14186. item = code[i];
  14187. if (typeof item === 'number') {
  14188. stack.push(new AstLiteral(item));
  14189. continue;
  14190. }
  14191. switch (item) {
  14192. case 'add':
  14193. if (stack.length < 2) {
  14194. return null;
  14195. }
  14196. num2 = stack.pop();
  14197. num1 = stack.pop();
  14198. stack.push(buildAddOperation(num1, num2));
  14199. break;
  14200. case 'cvr':
  14201. if (stack.length < 1) {
  14202. return null;
  14203. }
  14204. break;
  14205. case 'mul':
  14206. if (stack.length < 2) {
  14207. return null;
  14208. }
  14209. num2 = stack.pop();
  14210. num1 = stack.pop();
  14211. stack.push(buildMulOperation(num1, num2));
  14212. break;
  14213. case 'sub':
  14214. if (stack.length < 2) {
  14215. return null;
  14216. }
  14217. num2 = stack.pop();
  14218. num1 = stack.pop();
  14219. stack.push(buildSubOperation(num1, num2));
  14220. break;
  14221. case 'exch':
  14222. if (stack.length < 2) {
  14223. return null;
  14224. }
  14225. ast1 = stack.pop();
  14226. ast2 = stack.pop();
  14227. stack.push(ast1, ast2);
  14228. break;
  14229. case 'pop':
  14230. if (stack.length < 1) {
  14231. return null;
  14232. }
  14233. stack.pop();
  14234. break;
  14235. case 'index':
  14236. if (stack.length < 1) {
  14237. return null;
  14238. }
  14239. num1 = stack.pop();
  14240. if (num1.type !== 'literal') {
  14241. return null;
  14242. }
  14243. n = num1.number;
  14244. if (n < 0 || (n | 0) !== n || stack.length < n) {
  14245. return null;
  14246. }
  14247. ast1 = stack[stack.length - n - 1];
  14248. if (ast1.type === 'literal' || ast1.type === 'var') {
  14249. stack.push(ast1);
  14250. break;
  14251. }
  14252. tmpVar = new AstVariable(lastRegister++, ast1.min, ast1.max);
  14253. stack[stack.length - n - 1] = tmpVar;
  14254. stack.push(tmpVar);
  14255. instructions.push(new AstVariableDefinition(tmpVar, ast1));
  14256. break;
  14257. case 'dup':
  14258. if (stack.length < 1) {
  14259. return null;
  14260. }
  14261. 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]) {
  14262. num1 = stack.pop();
  14263. stack.push(buildMinOperation(num1, code[i + 1]));
  14264. i += 6;
  14265. break;
  14266. }
  14267. ast1 = stack[stack.length - 1];
  14268. if (ast1.type === 'literal' || ast1.type === 'var') {
  14269. stack.push(ast1);
  14270. break;
  14271. }
  14272. tmpVar = new AstVariable(lastRegister++, ast1.min, ast1.max);
  14273. stack[stack.length - 1] = tmpVar;
  14274. stack.push(tmpVar);
  14275. instructions.push(new AstVariableDefinition(tmpVar, ast1));
  14276. break;
  14277. case 'roll':
  14278. if (stack.length < 2) {
  14279. return null;
  14280. }
  14281. num2 = stack.pop();
  14282. num1 = stack.pop();
  14283. if (num2.type !== 'literal' || num1.type !== 'literal') {
  14284. return null;
  14285. }
  14286. j = num2.number;
  14287. n = num1.number;
  14288. if (n <= 0 || (n | 0) !== n || (j | 0) !== j || stack.length < n) {
  14289. return null;
  14290. }
  14291. j = (j % n + n) % n;
  14292. if (j === 0) {
  14293. break;
  14294. }
  14295. Array.prototype.push.apply(stack, stack.splice(stack.length - n, n - j));
  14296. break;
  14297. default:
  14298. return null;
  14299. }
  14300. }
  14301. if (stack.length !== outputSize) {
  14302. return null;
  14303. }
  14304. var result = [];
  14305. instructions.forEach(function (instruction) {
  14306. var statementBuilder = new ExpressionBuilderVisitor();
  14307. instruction.visit(statementBuilder);
  14308. result.push(statementBuilder.toString());
  14309. });
  14310. stack.forEach(function (expr, i) {
  14311. var statementBuilder = new ExpressionBuilderVisitor();
  14312. expr.visit(statementBuilder);
  14313. var min = range[i * 2], max = range[i * 2 + 1];
  14314. var out = [statementBuilder.toString()];
  14315. if (min > expr.min) {
  14316. out.unshift('Math.max(', min, ', ');
  14317. out.push(')');
  14318. }
  14319. if (max < expr.max) {
  14320. out.unshift('Math.min(', max, ', ');
  14321. out.push(')');
  14322. }
  14323. out.unshift('dest[destOffset + ', i, '] = ');
  14324. out.push(';');
  14325. result.push(out.join(''));
  14326. });
  14327. return result.join('\n');
  14328. }
  14329. };
  14330. return PostScriptCompiler;
  14331. }();
  14332. exports.isPDFFunction = isPDFFunction;
  14333. exports.PDFFunction = PDFFunction;
  14334. exports.PostScriptEvaluator = PostScriptEvaluator;
  14335. exports.PostScriptCompiler = PostScriptCompiler;
  14336. /***/ }),
  14337. /* 8 */
  14338. /***/ (function(module, exports, __w_pdfjs_require__) {
  14339. "use strict";
  14340. var sharedUtil = __w_pdfjs_require__(0);
  14341. var getLookupTableFactory = sharedUtil.getLookupTableFactory;
  14342. var getGlyphsUnicode = getLookupTableFactory(function (t) {
  14343. t['A'] = 0x0041;
  14344. t['AE'] = 0x00C6;
  14345. t['AEacute'] = 0x01FC;
  14346. t['AEmacron'] = 0x01E2;
  14347. t['AEsmall'] = 0xF7E6;
  14348. t['Aacute'] = 0x00C1;
  14349. t['Aacutesmall'] = 0xF7E1;
  14350. t['Abreve'] = 0x0102;
  14351. t['Abreveacute'] = 0x1EAE;
  14352. t['Abrevecyrillic'] = 0x04D0;
  14353. t['Abrevedotbelow'] = 0x1EB6;
  14354. t['Abrevegrave'] = 0x1EB0;
  14355. t['Abrevehookabove'] = 0x1EB2;
  14356. t['Abrevetilde'] = 0x1EB4;
  14357. t['Acaron'] = 0x01CD;
  14358. t['Acircle'] = 0x24B6;
  14359. t['Acircumflex'] = 0x00C2;
  14360. t['Acircumflexacute'] = 0x1EA4;
  14361. t['Acircumflexdotbelow'] = 0x1EAC;
  14362. t['Acircumflexgrave'] = 0x1EA6;
  14363. t['Acircumflexhookabove'] = 0x1EA8;
  14364. t['Acircumflexsmall'] = 0xF7E2;
  14365. t['Acircumflextilde'] = 0x1EAA;
  14366. t['Acute'] = 0xF6C9;
  14367. t['Acutesmall'] = 0xF7B4;
  14368. t['Acyrillic'] = 0x0410;
  14369. t['Adblgrave'] = 0x0200;
  14370. t['Adieresis'] = 0x00C4;
  14371. t['Adieresiscyrillic'] = 0x04D2;
  14372. t['Adieresismacron'] = 0x01DE;
  14373. t['Adieresissmall'] = 0xF7E4;
  14374. t['Adotbelow'] = 0x1EA0;
  14375. t['Adotmacron'] = 0x01E0;
  14376. t['Agrave'] = 0x00C0;
  14377. t['Agravesmall'] = 0xF7E0;
  14378. t['Ahookabove'] = 0x1EA2;
  14379. t['Aiecyrillic'] = 0x04D4;
  14380. t['Ainvertedbreve'] = 0x0202;
  14381. t['Alpha'] = 0x0391;
  14382. t['Alphatonos'] = 0x0386;
  14383. t['Amacron'] = 0x0100;
  14384. t['Amonospace'] = 0xFF21;
  14385. t['Aogonek'] = 0x0104;
  14386. t['Aring'] = 0x00C5;
  14387. t['Aringacute'] = 0x01FA;
  14388. t['Aringbelow'] = 0x1E00;
  14389. t['Aringsmall'] = 0xF7E5;
  14390. t['Asmall'] = 0xF761;
  14391. t['Atilde'] = 0x00C3;
  14392. t['Atildesmall'] = 0xF7E3;
  14393. t['Aybarmenian'] = 0x0531;
  14394. t['B'] = 0x0042;
  14395. t['Bcircle'] = 0x24B7;
  14396. t['Bdotaccent'] = 0x1E02;
  14397. t['Bdotbelow'] = 0x1E04;
  14398. t['Becyrillic'] = 0x0411;
  14399. t['Benarmenian'] = 0x0532;
  14400. t['Beta'] = 0x0392;
  14401. t['Bhook'] = 0x0181;
  14402. t['Blinebelow'] = 0x1E06;
  14403. t['Bmonospace'] = 0xFF22;
  14404. t['Brevesmall'] = 0xF6F4;
  14405. t['Bsmall'] = 0xF762;
  14406. t['Btopbar'] = 0x0182;
  14407. t['C'] = 0x0043;
  14408. t['Caarmenian'] = 0x053E;
  14409. t['Cacute'] = 0x0106;
  14410. t['Caron'] = 0xF6CA;
  14411. t['Caronsmall'] = 0xF6F5;
  14412. t['Ccaron'] = 0x010C;
  14413. t['Ccedilla'] = 0x00C7;
  14414. t['Ccedillaacute'] = 0x1E08;
  14415. t['Ccedillasmall'] = 0xF7E7;
  14416. t['Ccircle'] = 0x24B8;
  14417. t['Ccircumflex'] = 0x0108;
  14418. t['Cdot'] = 0x010A;
  14419. t['Cdotaccent'] = 0x010A;
  14420. t['Cedillasmall'] = 0xF7B8;
  14421. t['Chaarmenian'] = 0x0549;
  14422. t['Cheabkhasiancyrillic'] = 0x04BC;
  14423. t['Checyrillic'] = 0x0427;
  14424. t['Chedescenderabkhasiancyrillic'] = 0x04BE;
  14425. t['Chedescendercyrillic'] = 0x04B6;
  14426. t['Chedieresiscyrillic'] = 0x04F4;
  14427. t['Cheharmenian'] = 0x0543;
  14428. t['Chekhakassiancyrillic'] = 0x04CB;
  14429. t['Cheverticalstrokecyrillic'] = 0x04B8;
  14430. t['Chi'] = 0x03A7;
  14431. t['Chook'] = 0x0187;
  14432. t['Circumflexsmall'] = 0xF6F6;
  14433. t['Cmonospace'] = 0xFF23;
  14434. t['Coarmenian'] = 0x0551;
  14435. t['Csmall'] = 0xF763;
  14436. t['D'] = 0x0044;
  14437. t['DZ'] = 0x01F1;
  14438. t['DZcaron'] = 0x01C4;
  14439. t['Daarmenian'] = 0x0534;
  14440. t['Dafrican'] = 0x0189;
  14441. t['Dcaron'] = 0x010E;
  14442. t['Dcedilla'] = 0x1E10;
  14443. t['Dcircle'] = 0x24B9;
  14444. t['Dcircumflexbelow'] = 0x1E12;
  14445. t['Dcroat'] = 0x0110;
  14446. t['Ddotaccent'] = 0x1E0A;
  14447. t['Ddotbelow'] = 0x1E0C;
  14448. t['Decyrillic'] = 0x0414;
  14449. t['Deicoptic'] = 0x03EE;
  14450. t['Delta'] = 0x2206;
  14451. t['Deltagreek'] = 0x0394;
  14452. t['Dhook'] = 0x018A;
  14453. t['Dieresis'] = 0xF6CB;
  14454. t['DieresisAcute'] = 0xF6CC;
  14455. t['DieresisGrave'] = 0xF6CD;
  14456. t['Dieresissmall'] = 0xF7A8;
  14457. t['Digammagreek'] = 0x03DC;
  14458. t['Djecyrillic'] = 0x0402;
  14459. t['Dlinebelow'] = 0x1E0E;
  14460. t['Dmonospace'] = 0xFF24;
  14461. t['Dotaccentsmall'] = 0xF6F7;
  14462. t['Dslash'] = 0x0110;
  14463. t['Dsmall'] = 0xF764;
  14464. t['Dtopbar'] = 0x018B;
  14465. t['Dz'] = 0x01F2;
  14466. t['Dzcaron'] = 0x01C5;
  14467. t['Dzeabkhasiancyrillic'] = 0x04E0;
  14468. t['Dzecyrillic'] = 0x0405;
  14469. t['Dzhecyrillic'] = 0x040F;
  14470. t['E'] = 0x0045;
  14471. t['Eacute'] = 0x00C9;
  14472. t['Eacutesmall'] = 0xF7E9;
  14473. t['Ebreve'] = 0x0114;
  14474. t['Ecaron'] = 0x011A;
  14475. t['Ecedillabreve'] = 0x1E1C;
  14476. t['Echarmenian'] = 0x0535;
  14477. t['Ecircle'] = 0x24BA;
  14478. t['Ecircumflex'] = 0x00CA;
  14479. t['Ecircumflexacute'] = 0x1EBE;
  14480. t['Ecircumflexbelow'] = 0x1E18;
  14481. t['Ecircumflexdotbelow'] = 0x1EC6;
  14482. t['Ecircumflexgrave'] = 0x1EC0;
  14483. t['Ecircumflexhookabove'] = 0x1EC2;
  14484. t['Ecircumflexsmall'] = 0xF7EA;
  14485. t['Ecircumflextilde'] = 0x1EC4;
  14486. t['Ecyrillic'] = 0x0404;
  14487. t['Edblgrave'] = 0x0204;
  14488. t['Edieresis'] = 0x00CB;
  14489. t['Edieresissmall'] = 0xF7EB;
  14490. t['Edot'] = 0x0116;
  14491. t['Edotaccent'] = 0x0116;
  14492. t['Edotbelow'] = 0x1EB8;
  14493. t['Efcyrillic'] = 0x0424;
  14494. t['Egrave'] = 0x00C8;
  14495. t['Egravesmall'] = 0xF7E8;
  14496. t['Eharmenian'] = 0x0537;
  14497. t['Ehookabove'] = 0x1EBA;
  14498. t['Eightroman'] = 0x2167;
  14499. t['Einvertedbreve'] = 0x0206;
  14500. t['Eiotifiedcyrillic'] = 0x0464;
  14501. t['Elcyrillic'] = 0x041B;
  14502. t['Elevenroman'] = 0x216A;
  14503. t['Emacron'] = 0x0112;
  14504. t['Emacronacute'] = 0x1E16;
  14505. t['Emacrongrave'] = 0x1E14;
  14506. t['Emcyrillic'] = 0x041C;
  14507. t['Emonospace'] = 0xFF25;
  14508. t['Encyrillic'] = 0x041D;
  14509. t['Endescendercyrillic'] = 0x04A2;
  14510. t['Eng'] = 0x014A;
  14511. t['Enghecyrillic'] = 0x04A4;
  14512. t['Enhookcyrillic'] = 0x04C7;
  14513. t['Eogonek'] = 0x0118;
  14514. t['Eopen'] = 0x0190;
  14515. t['Epsilon'] = 0x0395;
  14516. t['Epsilontonos'] = 0x0388;
  14517. t['Ercyrillic'] = 0x0420;
  14518. t['Ereversed'] = 0x018E;
  14519. t['Ereversedcyrillic'] = 0x042D;
  14520. t['Escyrillic'] = 0x0421;
  14521. t['Esdescendercyrillic'] = 0x04AA;
  14522. t['Esh'] = 0x01A9;
  14523. t['Esmall'] = 0xF765;
  14524. t['Eta'] = 0x0397;
  14525. t['Etarmenian'] = 0x0538;
  14526. t['Etatonos'] = 0x0389;
  14527. t['Eth'] = 0x00D0;
  14528. t['Ethsmall'] = 0xF7F0;
  14529. t['Etilde'] = 0x1EBC;
  14530. t['Etildebelow'] = 0x1E1A;
  14531. t['Euro'] = 0x20AC;
  14532. t['Ezh'] = 0x01B7;
  14533. t['Ezhcaron'] = 0x01EE;
  14534. t['Ezhreversed'] = 0x01B8;
  14535. t['F'] = 0x0046;
  14536. t['Fcircle'] = 0x24BB;
  14537. t['Fdotaccent'] = 0x1E1E;
  14538. t['Feharmenian'] = 0x0556;
  14539. t['Feicoptic'] = 0x03E4;
  14540. t['Fhook'] = 0x0191;
  14541. t['Fitacyrillic'] = 0x0472;
  14542. t['Fiveroman'] = 0x2164;
  14543. t['Fmonospace'] = 0xFF26;
  14544. t['Fourroman'] = 0x2163;
  14545. t['Fsmall'] = 0xF766;
  14546. t['G'] = 0x0047;
  14547. t['GBsquare'] = 0x3387;
  14548. t['Gacute'] = 0x01F4;
  14549. t['Gamma'] = 0x0393;
  14550. t['Gammaafrican'] = 0x0194;
  14551. t['Gangiacoptic'] = 0x03EA;
  14552. t['Gbreve'] = 0x011E;
  14553. t['Gcaron'] = 0x01E6;
  14554. t['Gcedilla'] = 0x0122;
  14555. t['Gcircle'] = 0x24BC;
  14556. t['Gcircumflex'] = 0x011C;
  14557. t['Gcommaaccent'] = 0x0122;
  14558. t['Gdot'] = 0x0120;
  14559. t['Gdotaccent'] = 0x0120;
  14560. t['Gecyrillic'] = 0x0413;
  14561. t['Ghadarmenian'] = 0x0542;
  14562. t['Ghemiddlehookcyrillic'] = 0x0494;
  14563. t['Ghestrokecyrillic'] = 0x0492;
  14564. t['Gheupturncyrillic'] = 0x0490;
  14565. t['Ghook'] = 0x0193;
  14566. t['Gimarmenian'] = 0x0533;
  14567. t['Gjecyrillic'] = 0x0403;
  14568. t['Gmacron'] = 0x1E20;
  14569. t['Gmonospace'] = 0xFF27;
  14570. t['Grave'] = 0xF6CE;
  14571. t['Gravesmall'] = 0xF760;
  14572. t['Gsmall'] = 0xF767;
  14573. t['Gsmallhook'] = 0x029B;
  14574. t['Gstroke'] = 0x01E4;
  14575. t['H'] = 0x0048;
  14576. t['H18533'] = 0x25CF;
  14577. t['H18543'] = 0x25AA;
  14578. t['H18551'] = 0x25AB;
  14579. t['H22073'] = 0x25A1;
  14580. t['HPsquare'] = 0x33CB;
  14581. t['Haabkhasiancyrillic'] = 0x04A8;
  14582. t['Hadescendercyrillic'] = 0x04B2;
  14583. t['Hardsigncyrillic'] = 0x042A;
  14584. t['Hbar'] = 0x0126;
  14585. t['Hbrevebelow'] = 0x1E2A;
  14586. t['Hcedilla'] = 0x1E28;
  14587. t['Hcircle'] = 0x24BD;
  14588. t['Hcircumflex'] = 0x0124;
  14589. t['Hdieresis'] = 0x1E26;
  14590. t['Hdotaccent'] = 0x1E22;
  14591. t['Hdotbelow'] = 0x1E24;
  14592. t['Hmonospace'] = 0xFF28;
  14593. t['Hoarmenian'] = 0x0540;
  14594. t['Horicoptic'] = 0x03E8;
  14595. t['Hsmall'] = 0xF768;
  14596. t['Hungarumlaut'] = 0xF6CF;
  14597. t['Hungarumlautsmall'] = 0xF6F8;
  14598. t['Hzsquare'] = 0x3390;
  14599. t['I'] = 0x0049;
  14600. t['IAcyrillic'] = 0x042F;
  14601. t['IJ'] = 0x0132;
  14602. t['IUcyrillic'] = 0x042E;
  14603. t['Iacute'] = 0x00CD;
  14604. t['Iacutesmall'] = 0xF7ED;
  14605. t['Ibreve'] = 0x012C;
  14606. t['Icaron'] = 0x01CF;
  14607. t['Icircle'] = 0x24BE;
  14608. t['Icircumflex'] = 0x00CE;
  14609. t['Icircumflexsmall'] = 0xF7EE;
  14610. t['Icyrillic'] = 0x0406;
  14611. t['Idblgrave'] = 0x0208;
  14612. t['Idieresis'] = 0x00CF;
  14613. t['Idieresisacute'] = 0x1E2E;
  14614. t['Idieresiscyrillic'] = 0x04E4;
  14615. t['Idieresissmall'] = 0xF7EF;
  14616. t['Idot'] = 0x0130;
  14617. t['Idotaccent'] = 0x0130;
  14618. t['Idotbelow'] = 0x1ECA;
  14619. t['Iebrevecyrillic'] = 0x04D6;
  14620. t['Iecyrillic'] = 0x0415;
  14621. t['Ifraktur'] = 0x2111;
  14622. t['Igrave'] = 0x00CC;
  14623. t['Igravesmall'] = 0xF7EC;
  14624. t['Ihookabove'] = 0x1EC8;
  14625. t['Iicyrillic'] = 0x0418;
  14626. t['Iinvertedbreve'] = 0x020A;
  14627. t['Iishortcyrillic'] = 0x0419;
  14628. t['Imacron'] = 0x012A;
  14629. t['Imacroncyrillic'] = 0x04E2;
  14630. t['Imonospace'] = 0xFF29;
  14631. t['Iniarmenian'] = 0x053B;
  14632. t['Iocyrillic'] = 0x0401;
  14633. t['Iogonek'] = 0x012E;
  14634. t['Iota'] = 0x0399;
  14635. t['Iotaafrican'] = 0x0196;
  14636. t['Iotadieresis'] = 0x03AA;
  14637. t['Iotatonos'] = 0x038A;
  14638. t['Ismall'] = 0xF769;
  14639. t['Istroke'] = 0x0197;
  14640. t['Itilde'] = 0x0128;
  14641. t['Itildebelow'] = 0x1E2C;
  14642. t['Izhitsacyrillic'] = 0x0474;
  14643. t['Izhitsadblgravecyrillic'] = 0x0476;
  14644. t['J'] = 0x004A;
  14645. t['Jaarmenian'] = 0x0541;
  14646. t['Jcircle'] = 0x24BF;
  14647. t['Jcircumflex'] = 0x0134;
  14648. t['Jecyrillic'] = 0x0408;
  14649. t['Jheharmenian'] = 0x054B;
  14650. t['Jmonospace'] = 0xFF2A;
  14651. t['Jsmall'] = 0xF76A;
  14652. t['K'] = 0x004B;
  14653. t['KBsquare'] = 0x3385;
  14654. t['KKsquare'] = 0x33CD;
  14655. t['Kabashkircyrillic'] = 0x04A0;
  14656. t['Kacute'] = 0x1E30;
  14657. t['Kacyrillic'] = 0x041A;
  14658. t['Kadescendercyrillic'] = 0x049A;
  14659. t['Kahookcyrillic'] = 0x04C3;
  14660. t['Kappa'] = 0x039A;
  14661. t['Kastrokecyrillic'] = 0x049E;
  14662. t['Kaverticalstrokecyrillic'] = 0x049C;
  14663. t['Kcaron'] = 0x01E8;
  14664. t['Kcedilla'] = 0x0136;
  14665. t['Kcircle'] = 0x24C0;
  14666. t['Kcommaaccent'] = 0x0136;
  14667. t['Kdotbelow'] = 0x1E32;
  14668. t['Keharmenian'] = 0x0554;
  14669. t['Kenarmenian'] = 0x053F;
  14670. t['Khacyrillic'] = 0x0425;
  14671. t['Kheicoptic'] = 0x03E6;
  14672. t['Khook'] = 0x0198;
  14673. t['Kjecyrillic'] = 0x040C;
  14674. t['Klinebelow'] = 0x1E34;
  14675. t['Kmonospace'] = 0xFF2B;
  14676. t['Koppacyrillic'] = 0x0480;
  14677. t['Koppagreek'] = 0x03DE;
  14678. t['Ksicyrillic'] = 0x046E;
  14679. t['Ksmall'] = 0xF76B;
  14680. t['L'] = 0x004C;
  14681. t['LJ'] = 0x01C7;
  14682. t['LL'] = 0xF6BF;
  14683. t['Lacute'] = 0x0139;
  14684. t['Lambda'] = 0x039B;
  14685. t['Lcaron'] = 0x013D;
  14686. t['Lcedilla'] = 0x013B;
  14687. t['Lcircle'] = 0x24C1;
  14688. t['Lcircumflexbelow'] = 0x1E3C;
  14689. t['Lcommaaccent'] = 0x013B;
  14690. t['Ldot'] = 0x013F;
  14691. t['Ldotaccent'] = 0x013F;
  14692. t['Ldotbelow'] = 0x1E36;
  14693. t['Ldotbelowmacron'] = 0x1E38;
  14694. t['Liwnarmenian'] = 0x053C;
  14695. t['Lj'] = 0x01C8;
  14696. t['Ljecyrillic'] = 0x0409;
  14697. t['Llinebelow'] = 0x1E3A;
  14698. t['Lmonospace'] = 0xFF2C;
  14699. t['Lslash'] = 0x0141;
  14700. t['Lslashsmall'] = 0xF6F9;
  14701. t['Lsmall'] = 0xF76C;
  14702. t['M'] = 0x004D;
  14703. t['MBsquare'] = 0x3386;
  14704. t['Macron'] = 0xF6D0;
  14705. t['Macronsmall'] = 0xF7AF;
  14706. t['Macute'] = 0x1E3E;
  14707. t['Mcircle'] = 0x24C2;
  14708. t['Mdotaccent'] = 0x1E40;
  14709. t['Mdotbelow'] = 0x1E42;
  14710. t['Menarmenian'] = 0x0544;
  14711. t['Mmonospace'] = 0xFF2D;
  14712. t['Msmall'] = 0xF76D;
  14713. t['Mturned'] = 0x019C;
  14714. t['Mu'] = 0x039C;
  14715. t['N'] = 0x004E;
  14716. t['NJ'] = 0x01CA;
  14717. t['Nacute'] = 0x0143;
  14718. t['Ncaron'] = 0x0147;
  14719. t['Ncedilla'] = 0x0145;
  14720. t['Ncircle'] = 0x24C3;
  14721. t['Ncircumflexbelow'] = 0x1E4A;
  14722. t['Ncommaaccent'] = 0x0145;
  14723. t['Ndotaccent'] = 0x1E44;
  14724. t['Ndotbelow'] = 0x1E46;
  14725. t['Nhookleft'] = 0x019D;
  14726. t['Nineroman'] = 0x2168;
  14727. t['Nj'] = 0x01CB;
  14728. t['Njecyrillic'] = 0x040A;
  14729. t['Nlinebelow'] = 0x1E48;
  14730. t['Nmonospace'] = 0xFF2E;
  14731. t['Nowarmenian'] = 0x0546;
  14732. t['Nsmall'] = 0xF76E;
  14733. t['Ntilde'] = 0x00D1;
  14734. t['Ntildesmall'] = 0xF7F1;
  14735. t['Nu'] = 0x039D;
  14736. t['O'] = 0x004F;
  14737. t['OE'] = 0x0152;
  14738. t['OEsmall'] = 0xF6FA;
  14739. t['Oacute'] = 0x00D3;
  14740. t['Oacutesmall'] = 0xF7F3;
  14741. t['Obarredcyrillic'] = 0x04E8;
  14742. t['Obarreddieresiscyrillic'] = 0x04EA;
  14743. t['Obreve'] = 0x014E;
  14744. t['Ocaron'] = 0x01D1;
  14745. t['Ocenteredtilde'] = 0x019F;
  14746. t['Ocircle'] = 0x24C4;
  14747. t['Ocircumflex'] = 0x00D4;
  14748. t['Ocircumflexacute'] = 0x1ED0;
  14749. t['Ocircumflexdotbelow'] = 0x1ED8;
  14750. t['Ocircumflexgrave'] = 0x1ED2;
  14751. t['Ocircumflexhookabove'] = 0x1ED4;
  14752. t['Ocircumflexsmall'] = 0xF7F4;
  14753. t['Ocircumflextilde'] = 0x1ED6;
  14754. t['Ocyrillic'] = 0x041E;
  14755. t['Odblacute'] = 0x0150;
  14756. t['Odblgrave'] = 0x020C;
  14757. t['Odieresis'] = 0x00D6;
  14758. t['Odieresiscyrillic'] = 0x04E6;
  14759. t['Odieresissmall'] = 0xF7F6;
  14760. t['Odotbelow'] = 0x1ECC;
  14761. t['Ogoneksmall'] = 0xF6FB;
  14762. t['Ograve'] = 0x00D2;
  14763. t['Ogravesmall'] = 0xF7F2;
  14764. t['Oharmenian'] = 0x0555;
  14765. t['Ohm'] = 0x2126;
  14766. t['Ohookabove'] = 0x1ECE;
  14767. t['Ohorn'] = 0x01A0;
  14768. t['Ohornacute'] = 0x1EDA;
  14769. t['Ohorndotbelow'] = 0x1EE2;
  14770. t['Ohorngrave'] = 0x1EDC;
  14771. t['Ohornhookabove'] = 0x1EDE;
  14772. t['Ohorntilde'] = 0x1EE0;
  14773. t['Ohungarumlaut'] = 0x0150;
  14774. t['Oi'] = 0x01A2;
  14775. t['Oinvertedbreve'] = 0x020E;
  14776. t['Omacron'] = 0x014C;
  14777. t['Omacronacute'] = 0x1E52;
  14778. t['Omacrongrave'] = 0x1E50;
  14779. t['Omega'] = 0x2126;
  14780. t['Omegacyrillic'] = 0x0460;
  14781. t['Omegagreek'] = 0x03A9;
  14782. t['Omegaroundcyrillic'] = 0x047A;
  14783. t['Omegatitlocyrillic'] = 0x047C;
  14784. t['Omegatonos'] = 0x038F;
  14785. t['Omicron'] = 0x039F;
  14786. t['Omicrontonos'] = 0x038C;
  14787. t['Omonospace'] = 0xFF2F;
  14788. t['Oneroman'] = 0x2160;
  14789. t['Oogonek'] = 0x01EA;
  14790. t['Oogonekmacron'] = 0x01EC;
  14791. t['Oopen'] = 0x0186;
  14792. t['Oslash'] = 0x00D8;
  14793. t['Oslashacute'] = 0x01FE;
  14794. t['Oslashsmall'] = 0xF7F8;
  14795. t['Osmall'] = 0xF76F;
  14796. t['Ostrokeacute'] = 0x01FE;
  14797. t['Otcyrillic'] = 0x047E;
  14798. t['Otilde'] = 0x00D5;
  14799. t['Otildeacute'] = 0x1E4C;
  14800. t['Otildedieresis'] = 0x1E4E;
  14801. t['Otildesmall'] = 0xF7F5;
  14802. t['P'] = 0x0050;
  14803. t['Pacute'] = 0x1E54;
  14804. t['Pcircle'] = 0x24C5;
  14805. t['Pdotaccent'] = 0x1E56;
  14806. t['Pecyrillic'] = 0x041F;
  14807. t['Peharmenian'] = 0x054A;
  14808. t['Pemiddlehookcyrillic'] = 0x04A6;
  14809. t['Phi'] = 0x03A6;
  14810. t['Phook'] = 0x01A4;
  14811. t['Pi'] = 0x03A0;
  14812. t['Piwrarmenian'] = 0x0553;
  14813. t['Pmonospace'] = 0xFF30;
  14814. t['Psi'] = 0x03A8;
  14815. t['Psicyrillic'] = 0x0470;
  14816. t['Psmall'] = 0xF770;
  14817. t['Q'] = 0x0051;
  14818. t['Qcircle'] = 0x24C6;
  14819. t['Qmonospace'] = 0xFF31;
  14820. t['Qsmall'] = 0xF771;
  14821. t['R'] = 0x0052;
  14822. t['Raarmenian'] = 0x054C;
  14823. t['Racute'] = 0x0154;
  14824. t['Rcaron'] = 0x0158;
  14825. t['Rcedilla'] = 0x0156;
  14826. t['Rcircle'] = 0x24C7;
  14827. t['Rcommaaccent'] = 0x0156;
  14828. t['Rdblgrave'] = 0x0210;
  14829. t['Rdotaccent'] = 0x1E58;
  14830. t['Rdotbelow'] = 0x1E5A;
  14831. t['Rdotbelowmacron'] = 0x1E5C;
  14832. t['Reharmenian'] = 0x0550;
  14833. t['Rfraktur'] = 0x211C;
  14834. t['Rho'] = 0x03A1;
  14835. t['Ringsmall'] = 0xF6FC;
  14836. t['Rinvertedbreve'] = 0x0212;
  14837. t['Rlinebelow'] = 0x1E5E;
  14838. t['Rmonospace'] = 0xFF32;
  14839. t['Rsmall'] = 0xF772;
  14840. t['Rsmallinverted'] = 0x0281;
  14841. t['Rsmallinvertedsuperior'] = 0x02B6;
  14842. t['S'] = 0x0053;
  14843. t['SF010000'] = 0x250C;
  14844. t['SF020000'] = 0x2514;
  14845. t['SF030000'] = 0x2510;
  14846. t['SF040000'] = 0x2518;
  14847. t['SF050000'] = 0x253C;
  14848. t['SF060000'] = 0x252C;
  14849. t['SF070000'] = 0x2534;
  14850. t['SF080000'] = 0x251C;
  14851. t['SF090000'] = 0x2524;
  14852. t['SF100000'] = 0x2500;
  14853. t['SF110000'] = 0x2502;
  14854. t['SF190000'] = 0x2561;
  14855. t['SF200000'] = 0x2562;
  14856. t['SF210000'] = 0x2556;
  14857. t['SF220000'] = 0x2555;
  14858. t['SF230000'] = 0x2563;
  14859. t['SF240000'] = 0x2551;
  14860. t['SF250000'] = 0x2557;
  14861. t['SF260000'] = 0x255D;
  14862. t['SF270000'] = 0x255C;
  14863. t['SF280000'] = 0x255B;
  14864. t['SF360000'] = 0x255E;
  14865. t['SF370000'] = 0x255F;
  14866. t['SF380000'] = 0x255A;
  14867. t['SF390000'] = 0x2554;
  14868. t['SF400000'] = 0x2569;
  14869. t['SF410000'] = 0x2566;
  14870. t['SF420000'] = 0x2560;
  14871. t['SF430000'] = 0x2550;
  14872. t['SF440000'] = 0x256C;
  14873. t['SF450000'] = 0x2567;
  14874. t['SF460000'] = 0x2568;
  14875. t['SF470000'] = 0x2564;
  14876. t['SF480000'] = 0x2565;
  14877. t['SF490000'] = 0x2559;
  14878. t['SF500000'] = 0x2558;
  14879. t['SF510000'] = 0x2552;
  14880. t['SF520000'] = 0x2553;
  14881. t['SF530000'] = 0x256B;
  14882. t['SF540000'] = 0x256A;
  14883. t['Sacute'] = 0x015A;
  14884. t['Sacutedotaccent'] = 0x1E64;
  14885. t['Sampigreek'] = 0x03E0;
  14886. t['Scaron'] = 0x0160;
  14887. t['Scarondotaccent'] = 0x1E66;
  14888. t['Scaronsmall'] = 0xF6FD;
  14889. t['Scedilla'] = 0x015E;
  14890. t['Schwa'] = 0x018F;
  14891. t['Schwacyrillic'] = 0x04D8;
  14892. t['Schwadieresiscyrillic'] = 0x04DA;
  14893. t['Scircle'] = 0x24C8;
  14894. t['Scircumflex'] = 0x015C;
  14895. t['Scommaaccent'] = 0x0218;
  14896. t['Sdotaccent'] = 0x1E60;
  14897. t['Sdotbelow'] = 0x1E62;
  14898. t['Sdotbelowdotaccent'] = 0x1E68;
  14899. t['Seharmenian'] = 0x054D;
  14900. t['Sevenroman'] = 0x2166;
  14901. t['Shaarmenian'] = 0x0547;
  14902. t['Shacyrillic'] = 0x0428;
  14903. t['Shchacyrillic'] = 0x0429;
  14904. t['Sheicoptic'] = 0x03E2;
  14905. t['Shhacyrillic'] = 0x04BA;
  14906. t['Shimacoptic'] = 0x03EC;
  14907. t['Sigma'] = 0x03A3;
  14908. t['Sixroman'] = 0x2165;
  14909. t['Smonospace'] = 0xFF33;
  14910. t['Softsigncyrillic'] = 0x042C;
  14911. t['Ssmall'] = 0xF773;
  14912. t['Stigmagreek'] = 0x03DA;
  14913. t['T'] = 0x0054;
  14914. t['Tau'] = 0x03A4;
  14915. t['Tbar'] = 0x0166;
  14916. t['Tcaron'] = 0x0164;
  14917. t['Tcedilla'] = 0x0162;
  14918. t['Tcircle'] = 0x24C9;
  14919. t['Tcircumflexbelow'] = 0x1E70;
  14920. t['Tcommaaccent'] = 0x0162;
  14921. t['Tdotaccent'] = 0x1E6A;
  14922. t['Tdotbelow'] = 0x1E6C;
  14923. t['Tecyrillic'] = 0x0422;
  14924. t['Tedescendercyrillic'] = 0x04AC;
  14925. t['Tenroman'] = 0x2169;
  14926. t['Tetsecyrillic'] = 0x04B4;
  14927. t['Theta'] = 0x0398;
  14928. t['Thook'] = 0x01AC;
  14929. t['Thorn'] = 0x00DE;
  14930. t['Thornsmall'] = 0xF7FE;
  14931. t['Threeroman'] = 0x2162;
  14932. t['Tildesmall'] = 0xF6FE;
  14933. t['Tiwnarmenian'] = 0x054F;
  14934. t['Tlinebelow'] = 0x1E6E;
  14935. t['Tmonospace'] = 0xFF34;
  14936. t['Toarmenian'] = 0x0539;
  14937. t['Tonefive'] = 0x01BC;
  14938. t['Tonesix'] = 0x0184;
  14939. t['Tonetwo'] = 0x01A7;
  14940. t['Tretroflexhook'] = 0x01AE;
  14941. t['Tsecyrillic'] = 0x0426;
  14942. t['Tshecyrillic'] = 0x040B;
  14943. t['Tsmall'] = 0xF774;
  14944. t['Twelveroman'] = 0x216B;
  14945. t['Tworoman'] = 0x2161;
  14946. t['U'] = 0x0055;
  14947. t['Uacute'] = 0x00DA;
  14948. t['Uacutesmall'] = 0xF7FA;
  14949. t['Ubreve'] = 0x016C;
  14950. t['Ucaron'] = 0x01D3;
  14951. t['Ucircle'] = 0x24CA;
  14952. t['Ucircumflex'] = 0x00DB;
  14953. t['Ucircumflexbelow'] = 0x1E76;
  14954. t['Ucircumflexsmall'] = 0xF7FB;
  14955. t['Ucyrillic'] = 0x0423;
  14956. t['Udblacute'] = 0x0170;
  14957. t['Udblgrave'] = 0x0214;
  14958. t['Udieresis'] = 0x00DC;
  14959. t['Udieresisacute'] = 0x01D7;
  14960. t['Udieresisbelow'] = 0x1E72;
  14961. t['Udieresiscaron'] = 0x01D9;
  14962. t['Udieresiscyrillic'] = 0x04F0;
  14963. t['Udieresisgrave'] = 0x01DB;
  14964. t['Udieresismacron'] = 0x01D5;
  14965. t['Udieresissmall'] = 0xF7FC;
  14966. t['Udotbelow'] = 0x1EE4;
  14967. t['Ugrave'] = 0x00D9;
  14968. t['Ugravesmall'] = 0xF7F9;
  14969. t['Uhookabove'] = 0x1EE6;
  14970. t['Uhorn'] = 0x01AF;
  14971. t['Uhornacute'] = 0x1EE8;
  14972. t['Uhorndotbelow'] = 0x1EF0;
  14973. t['Uhorngrave'] = 0x1EEA;
  14974. t['Uhornhookabove'] = 0x1EEC;
  14975. t['Uhorntilde'] = 0x1EEE;
  14976. t['Uhungarumlaut'] = 0x0170;
  14977. t['Uhungarumlautcyrillic'] = 0x04F2;
  14978. t['Uinvertedbreve'] = 0x0216;
  14979. t['Ukcyrillic'] = 0x0478;
  14980. t['Umacron'] = 0x016A;
  14981. t['Umacroncyrillic'] = 0x04EE;
  14982. t['Umacrondieresis'] = 0x1E7A;
  14983. t['Umonospace'] = 0xFF35;
  14984. t['Uogonek'] = 0x0172;
  14985. t['Upsilon'] = 0x03A5;
  14986. t['Upsilon1'] = 0x03D2;
  14987. t['Upsilonacutehooksymbolgreek'] = 0x03D3;
  14988. t['Upsilonafrican'] = 0x01B1;
  14989. t['Upsilondieresis'] = 0x03AB;
  14990. t['Upsilondieresishooksymbolgreek'] = 0x03D4;
  14991. t['Upsilonhooksymbol'] = 0x03D2;
  14992. t['Upsilontonos'] = 0x038E;
  14993. t['Uring'] = 0x016E;
  14994. t['Ushortcyrillic'] = 0x040E;
  14995. t['Usmall'] = 0xF775;
  14996. t['Ustraightcyrillic'] = 0x04AE;
  14997. t['Ustraightstrokecyrillic'] = 0x04B0;
  14998. t['Utilde'] = 0x0168;
  14999. t['Utildeacute'] = 0x1E78;
  15000. t['Utildebelow'] = 0x1E74;
  15001. t['V'] = 0x0056;
  15002. t['Vcircle'] = 0x24CB;
  15003. t['Vdotbelow'] = 0x1E7E;
  15004. t['Vecyrillic'] = 0x0412;
  15005. t['Vewarmenian'] = 0x054E;
  15006. t['Vhook'] = 0x01B2;
  15007. t['Vmonospace'] = 0xFF36;
  15008. t['Voarmenian'] = 0x0548;
  15009. t['Vsmall'] = 0xF776;
  15010. t['Vtilde'] = 0x1E7C;
  15011. t['W'] = 0x0057;
  15012. t['Wacute'] = 0x1E82;
  15013. t['Wcircle'] = 0x24CC;
  15014. t['Wcircumflex'] = 0x0174;
  15015. t['Wdieresis'] = 0x1E84;
  15016. t['Wdotaccent'] = 0x1E86;
  15017. t['Wdotbelow'] = 0x1E88;
  15018. t['Wgrave'] = 0x1E80;
  15019. t['Wmonospace'] = 0xFF37;
  15020. t['Wsmall'] = 0xF777;
  15021. t['X'] = 0x0058;
  15022. t['Xcircle'] = 0x24CD;
  15023. t['Xdieresis'] = 0x1E8C;
  15024. t['Xdotaccent'] = 0x1E8A;
  15025. t['Xeharmenian'] = 0x053D;
  15026. t['Xi'] = 0x039E;
  15027. t['Xmonospace'] = 0xFF38;
  15028. t['Xsmall'] = 0xF778;
  15029. t['Y'] = 0x0059;
  15030. t['Yacute'] = 0x00DD;
  15031. t['Yacutesmall'] = 0xF7FD;
  15032. t['Yatcyrillic'] = 0x0462;
  15033. t['Ycircle'] = 0x24CE;
  15034. t['Ycircumflex'] = 0x0176;
  15035. t['Ydieresis'] = 0x0178;
  15036. t['Ydieresissmall'] = 0xF7FF;
  15037. t['Ydotaccent'] = 0x1E8E;
  15038. t['Ydotbelow'] = 0x1EF4;
  15039. t['Yericyrillic'] = 0x042B;
  15040. t['Yerudieresiscyrillic'] = 0x04F8;
  15041. t['Ygrave'] = 0x1EF2;
  15042. t['Yhook'] = 0x01B3;
  15043. t['Yhookabove'] = 0x1EF6;
  15044. t['Yiarmenian'] = 0x0545;
  15045. t['Yicyrillic'] = 0x0407;
  15046. t['Yiwnarmenian'] = 0x0552;
  15047. t['Ymonospace'] = 0xFF39;
  15048. t['Ysmall'] = 0xF779;
  15049. t['Ytilde'] = 0x1EF8;
  15050. t['Yusbigcyrillic'] = 0x046A;
  15051. t['Yusbigiotifiedcyrillic'] = 0x046C;
  15052. t['Yuslittlecyrillic'] = 0x0466;
  15053. t['Yuslittleiotifiedcyrillic'] = 0x0468;
  15054. t['Z'] = 0x005A;
  15055. t['Zaarmenian'] = 0x0536;
  15056. t['Zacute'] = 0x0179;
  15057. t['Zcaron'] = 0x017D;
  15058. t['Zcaronsmall'] = 0xF6FF;
  15059. t['Zcircle'] = 0x24CF;
  15060. t['Zcircumflex'] = 0x1E90;
  15061. t['Zdot'] = 0x017B;
  15062. t['Zdotaccent'] = 0x017B;
  15063. t['Zdotbelow'] = 0x1E92;
  15064. t['Zecyrillic'] = 0x0417;
  15065. t['Zedescendercyrillic'] = 0x0498;
  15066. t['Zedieresiscyrillic'] = 0x04DE;
  15067. t['Zeta'] = 0x0396;
  15068. t['Zhearmenian'] = 0x053A;
  15069. t['Zhebrevecyrillic'] = 0x04C1;
  15070. t['Zhecyrillic'] = 0x0416;
  15071. t['Zhedescendercyrillic'] = 0x0496;
  15072. t['Zhedieresiscyrillic'] = 0x04DC;
  15073. t['Zlinebelow'] = 0x1E94;
  15074. t['Zmonospace'] = 0xFF3A;
  15075. t['Zsmall'] = 0xF77A;
  15076. t['Zstroke'] = 0x01B5;
  15077. t['a'] = 0x0061;
  15078. t['aabengali'] = 0x0986;
  15079. t['aacute'] = 0x00E1;
  15080. t['aadeva'] = 0x0906;
  15081. t['aagujarati'] = 0x0A86;
  15082. t['aagurmukhi'] = 0x0A06;
  15083. t['aamatragurmukhi'] = 0x0A3E;
  15084. t['aarusquare'] = 0x3303;
  15085. t['aavowelsignbengali'] = 0x09BE;
  15086. t['aavowelsigndeva'] = 0x093E;
  15087. t['aavowelsigngujarati'] = 0x0ABE;
  15088. t['abbreviationmarkarmenian'] = 0x055F;
  15089. t['abbreviationsigndeva'] = 0x0970;
  15090. t['abengali'] = 0x0985;
  15091. t['abopomofo'] = 0x311A;
  15092. t['abreve'] = 0x0103;
  15093. t['abreveacute'] = 0x1EAF;
  15094. t['abrevecyrillic'] = 0x04D1;
  15095. t['abrevedotbelow'] = 0x1EB7;
  15096. t['abrevegrave'] = 0x1EB1;
  15097. t['abrevehookabove'] = 0x1EB3;
  15098. t['abrevetilde'] = 0x1EB5;
  15099. t['acaron'] = 0x01CE;
  15100. t['acircle'] = 0x24D0;
  15101. t['acircumflex'] = 0x00E2;
  15102. t['acircumflexacute'] = 0x1EA5;
  15103. t['acircumflexdotbelow'] = 0x1EAD;
  15104. t['acircumflexgrave'] = 0x1EA7;
  15105. t['acircumflexhookabove'] = 0x1EA9;
  15106. t['acircumflextilde'] = 0x1EAB;
  15107. t['acute'] = 0x00B4;
  15108. t['acutebelowcmb'] = 0x0317;
  15109. t['acutecmb'] = 0x0301;
  15110. t['acutecomb'] = 0x0301;
  15111. t['acutedeva'] = 0x0954;
  15112. t['acutelowmod'] = 0x02CF;
  15113. t['acutetonecmb'] = 0x0341;
  15114. t['acyrillic'] = 0x0430;
  15115. t['adblgrave'] = 0x0201;
  15116. t['addakgurmukhi'] = 0x0A71;
  15117. t['adeva'] = 0x0905;
  15118. t['adieresis'] = 0x00E4;
  15119. t['adieresiscyrillic'] = 0x04D3;
  15120. t['adieresismacron'] = 0x01DF;
  15121. t['adotbelow'] = 0x1EA1;
  15122. t['adotmacron'] = 0x01E1;
  15123. t['ae'] = 0x00E6;
  15124. t['aeacute'] = 0x01FD;
  15125. t['aekorean'] = 0x3150;
  15126. t['aemacron'] = 0x01E3;
  15127. t['afii00208'] = 0x2015;
  15128. t['afii08941'] = 0x20A4;
  15129. t['afii10017'] = 0x0410;
  15130. t['afii10018'] = 0x0411;
  15131. t['afii10019'] = 0x0412;
  15132. t['afii10020'] = 0x0413;
  15133. t['afii10021'] = 0x0414;
  15134. t['afii10022'] = 0x0415;
  15135. t['afii10023'] = 0x0401;
  15136. t['afii10024'] = 0x0416;
  15137. t['afii10025'] = 0x0417;
  15138. t['afii10026'] = 0x0418;
  15139. t['afii10027'] = 0x0419;
  15140. t['afii10028'] = 0x041A;
  15141. t['afii10029'] = 0x041B;
  15142. t['afii10030'] = 0x041C;
  15143. t['afii10031'] = 0x041D;
  15144. t['afii10032'] = 0x041E;
  15145. t['afii10033'] = 0x041F;
  15146. t['afii10034'] = 0x0420;
  15147. t['afii10035'] = 0x0421;
  15148. t['afii10036'] = 0x0422;
  15149. t['afii10037'] = 0x0423;
  15150. t['afii10038'] = 0x0424;
  15151. t['afii10039'] = 0x0425;
  15152. t['afii10040'] = 0x0426;
  15153. t['afii10041'] = 0x0427;
  15154. t['afii10042'] = 0x0428;
  15155. t['afii10043'] = 0x0429;
  15156. t['afii10044'] = 0x042A;
  15157. t['afii10045'] = 0x042B;
  15158. t['afii10046'] = 0x042C;
  15159. t['afii10047'] = 0x042D;
  15160. t['afii10048'] = 0x042E;
  15161. t['afii10049'] = 0x042F;
  15162. t['afii10050'] = 0x0490;
  15163. t['afii10051'] = 0x0402;
  15164. t['afii10052'] = 0x0403;
  15165. t['afii10053'] = 0x0404;
  15166. t['afii10054'] = 0x0405;
  15167. t['afii10055'] = 0x0406;
  15168. t['afii10056'] = 0x0407;
  15169. t['afii10057'] = 0x0408;
  15170. t['afii10058'] = 0x0409;
  15171. t['afii10059'] = 0x040A;
  15172. t['afii10060'] = 0x040B;
  15173. t['afii10061'] = 0x040C;
  15174. t['afii10062'] = 0x040E;
  15175. t['afii10063'] = 0xF6C4;
  15176. t['afii10064'] = 0xF6C5;
  15177. t['afii10065'] = 0x0430;
  15178. t['afii10066'] = 0x0431;
  15179. t['afii10067'] = 0x0432;
  15180. t['afii10068'] = 0x0433;
  15181. t['afii10069'] = 0x0434;
  15182. t['afii10070'] = 0x0435;
  15183. t['afii10071'] = 0x0451;
  15184. t['afii10072'] = 0x0436;
  15185. t['afii10073'] = 0x0437;
  15186. t['afii10074'] = 0x0438;
  15187. t['afii10075'] = 0x0439;
  15188. t['afii10076'] = 0x043A;
  15189. t['afii10077'] = 0x043B;
  15190. t['afii10078'] = 0x043C;
  15191. t['afii10079'] = 0x043D;
  15192. t['afii10080'] = 0x043E;
  15193. t['afii10081'] = 0x043F;
  15194. t['afii10082'] = 0x0440;
  15195. t['afii10083'] = 0x0441;
  15196. t['afii10084'] = 0x0442;
  15197. t['afii10085'] = 0x0443;
  15198. t['afii10086'] = 0x0444;
  15199. t['afii10087'] = 0x0445;
  15200. t['afii10088'] = 0x0446;
  15201. t['afii10089'] = 0x0447;
  15202. t['afii10090'] = 0x0448;
  15203. t['afii10091'] = 0x0449;
  15204. t['afii10092'] = 0x044A;
  15205. t['afii10093'] = 0x044B;
  15206. t['afii10094'] = 0x044C;
  15207. t['afii10095'] = 0x044D;
  15208. t['afii10096'] = 0x044E;
  15209. t['afii10097'] = 0x044F;
  15210. t['afii10098'] = 0x0491;
  15211. t['afii10099'] = 0x0452;
  15212. t['afii10100'] = 0x0453;
  15213. t['afii10101'] = 0x0454;
  15214. t['afii10102'] = 0x0455;
  15215. t['afii10103'] = 0x0456;
  15216. t['afii10104'] = 0x0457;
  15217. t['afii10105'] = 0x0458;
  15218. t['afii10106'] = 0x0459;
  15219. t['afii10107'] = 0x045A;
  15220. t['afii10108'] = 0x045B;
  15221. t['afii10109'] = 0x045C;
  15222. t['afii10110'] = 0x045E;
  15223. t['afii10145'] = 0x040F;
  15224. t['afii10146'] = 0x0462;
  15225. t['afii10147'] = 0x0472;
  15226. t['afii10148'] = 0x0474;
  15227. t['afii10192'] = 0xF6C6;
  15228. t['afii10193'] = 0x045F;
  15229. t['afii10194'] = 0x0463;
  15230. t['afii10195'] = 0x0473;
  15231. t['afii10196'] = 0x0475;
  15232. t['afii10831'] = 0xF6C7;
  15233. t['afii10832'] = 0xF6C8;
  15234. t['afii10846'] = 0x04D9;
  15235. t['afii299'] = 0x200E;
  15236. t['afii300'] = 0x200F;
  15237. t['afii301'] = 0x200D;
  15238. t['afii57381'] = 0x066A;
  15239. t['afii57388'] = 0x060C;
  15240. t['afii57392'] = 0x0660;
  15241. t['afii57393'] = 0x0661;
  15242. t['afii57394'] = 0x0662;
  15243. t['afii57395'] = 0x0663;
  15244. t['afii57396'] = 0x0664;
  15245. t['afii57397'] = 0x0665;
  15246. t['afii57398'] = 0x0666;
  15247. t['afii57399'] = 0x0667;
  15248. t['afii57400'] = 0x0668;
  15249. t['afii57401'] = 0x0669;
  15250. t['afii57403'] = 0x061B;
  15251. t['afii57407'] = 0x061F;
  15252. t['afii57409'] = 0x0621;
  15253. t['afii57410'] = 0x0622;
  15254. t['afii57411'] = 0x0623;
  15255. t['afii57412'] = 0x0624;
  15256. t['afii57413'] = 0x0625;
  15257. t['afii57414'] = 0x0626;
  15258. t['afii57415'] = 0x0627;
  15259. t['afii57416'] = 0x0628;
  15260. t['afii57417'] = 0x0629;
  15261. t['afii57418'] = 0x062A;
  15262. t['afii57419'] = 0x062B;
  15263. t['afii57420'] = 0x062C;
  15264. t['afii57421'] = 0x062D;
  15265. t['afii57422'] = 0x062E;
  15266. t['afii57423'] = 0x062F;
  15267. t['afii57424'] = 0x0630;
  15268. t['afii57425'] = 0x0631;
  15269. t['afii57426'] = 0x0632;
  15270. t['afii57427'] = 0x0633;
  15271. t['afii57428'] = 0x0634;
  15272. t['afii57429'] = 0x0635;
  15273. t['afii57430'] = 0x0636;
  15274. t['afii57431'] = 0x0637;
  15275. t['afii57432'] = 0x0638;
  15276. t['afii57433'] = 0x0639;
  15277. t['afii57434'] = 0x063A;
  15278. t['afii57440'] = 0x0640;
  15279. t['afii57441'] = 0x0641;
  15280. t['afii57442'] = 0x0642;
  15281. t['afii57443'] = 0x0643;
  15282. t['afii57444'] = 0x0644;
  15283. t['afii57445'] = 0x0645;
  15284. t['afii57446'] = 0x0646;
  15285. t['afii57448'] = 0x0648;
  15286. t['afii57449'] = 0x0649;
  15287. t['afii57450'] = 0x064A;
  15288. t['afii57451'] = 0x064B;
  15289. t['afii57452'] = 0x064C;
  15290. t['afii57453'] = 0x064D;
  15291. t['afii57454'] = 0x064E;
  15292. t['afii57455'] = 0x064F;
  15293. t['afii57456'] = 0x0650;
  15294. t['afii57457'] = 0x0651;
  15295. t['afii57458'] = 0x0652;
  15296. t['afii57470'] = 0x0647;
  15297. t['afii57505'] = 0x06A4;
  15298. t['afii57506'] = 0x067E;
  15299. t['afii57507'] = 0x0686;
  15300. t['afii57508'] = 0x0698;
  15301. t['afii57509'] = 0x06AF;
  15302. t['afii57511'] = 0x0679;
  15303. t['afii57512'] = 0x0688;
  15304. t['afii57513'] = 0x0691;
  15305. t['afii57514'] = 0x06BA;
  15306. t['afii57519'] = 0x06D2;
  15307. t['afii57534'] = 0x06D5;
  15308. t['afii57636'] = 0x20AA;
  15309. t['afii57645'] = 0x05BE;
  15310. t['afii57658'] = 0x05C3;
  15311. t['afii57664'] = 0x05D0;
  15312. t['afii57665'] = 0x05D1;
  15313. t['afii57666'] = 0x05D2;
  15314. t['afii57667'] = 0x05D3;
  15315. t['afii57668'] = 0x05D4;
  15316. t['afii57669'] = 0x05D5;
  15317. t['afii57670'] = 0x05D6;
  15318. t['afii57671'] = 0x05D7;
  15319. t['afii57672'] = 0x05D8;
  15320. t['afii57673'] = 0x05D9;
  15321. t['afii57674'] = 0x05DA;
  15322. t['afii57675'] = 0x05DB;
  15323. t['afii57676'] = 0x05DC;
  15324. t['afii57677'] = 0x05DD;
  15325. t['afii57678'] = 0x05DE;
  15326. t['afii57679'] = 0x05DF;
  15327. t['afii57680'] = 0x05E0;
  15328. t['afii57681'] = 0x05E1;
  15329. t['afii57682'] = 0x05E2;
  15330. t['afii57683'] = 0x05E3;
  15331. t['afii57684'] = 0x05E4;
  15332. t['afii57685'] = 0x05E5;
  15333. t['afii57686'] = 0x05E6;
  15334. t['afii57687'] = 0x05E7;
  15335. t['afii57688'] = 0x05E8;
  15336. t['afii57689'] = 0x05E9;
  15337. t['afii57690'] = 0x05EA;
  15338. t['afii57694'] = 0xFB2A;
  15339. t['afii57695'] = 0xFB2B;
  15340. t['afii57700'] = 0xFB4B;
  15341. t['afii57705'] = 0xFB1F;
  15342. t['afii57716'] = 0x05F0;
  15343. t['afii57717'] = 0x05F1;
  15344. t['afii57718'] = 0x05F2;
  15345. t['afii57723'] = 0xFB35;
  15346. t['afii57793'] = 0x05B4;
  15347. t['afii57794'] = 0x05B5;
  15348. t['afii57795'] = 0x05B6;
  15349. t['afii57796'] = 0x05BB;
  15350. t['afii57797'] = 0x05B8;
  15351. t['afii57798'] = 0x05B7;
  15352. t['afii57799'] = 0x05B0;
  15353. t['afii57800'] = 0x05B2;
  15354. t['afii57801'] = 0x05B1;
  15355. t['afii57802'] = 0x05B3;
  15356. t['afii57803'] = 0x05C2;
  15357. t['afii57804'] = 0x05C1;
  15358. t['afii57806'] = 0x05B9;
  15359. t['afii57807'] = 0x05BC;
  15360. t['afii57839'] = 0x05BD;
  15361. t['afii57841'] = 0x05BF;
  15362. t['afii57842'] = 0x05C0;
  15363. t['afii57929'] = 0x02BC;
  15364. t['afii61248'] = 0x2105;
  15365. t['afii61289'] = 0x2113;
  15366. t['afii61352'] = 0x2116;
  15367. t['afii61573'] = 0x202C;
  15368. t['afii61574'] = 0x202D;
  15369. t['afii61575'] = 0x202E;
  15370. t['afii61664'] = 0x200C;
  15371. t['afii63167'] = 0x066D;
  15372. t['afii64937'] = 0x02BD;
  15373. t['agrave'] = 0x00E0;
  15374. t['agujarati'] = 0x0A85;
  15375. t['agurmukhi'] = 0x0A05;
  15376. t['ahiragana'] = 0x3042;
  15377. t['ahookabove'] = 0x1EA3;
  15378. t['aibengali'] = 0x0990;
  15379. t['aibopomofo'] = 0x311E;
  15380. t['aideva'] = 0x0910;
  15381. t['aiecyrillic'] = 0x04D5;
  15382. t['aigujarati'] = 0x0A90;
  15383. t['aigurmukhi'] = 0x0A10;
  15384. t['aimatragurmukhi'] = 0x0A48;
  15385. t['ainarabic'] = 0x0639;
  15386. t['ainfinalarabic'] = 0xFECA;
  15387. t['aininitialarabic'] = 0xFECB;
  15388. t['ainmedialarabic'] = 0xFECC;
  15389. t['ainvertedbreve'] = 0x0203;
  15390. t['aivowelsignbengali'] = 0x09C8;
  15391. t['aivowelsigndeva'] = 0x0948;
  15392. t['aivowelsigngujarati'] = 0x0AC8;
  15393. t['akatakana'] = 0x30A2;
  15394. t['akatakanahalfwidth'] = 0xFF71;
  15395. t['akorean'] = 0x314F;
  15396. t['alef'] = 0x05D0;
  15397. t['alefarabic'] = 0x0627;
  15398. t['alefdageshhebrew'] = 0xFB30;
  15399. t['aleffinalarabic'] = 0xFE8E;
  15400. t['alefhamzaabovearabic'] = 0x0623;
  15401. t['alefhamzaabovefinalarabic'] = 0xFE84;
  15402. t['alefhamzabelowarabic'] = 0x0625;
  15403. t['alefhamzabelowfinalarabic'] = 0xFE88;
  15404. t['alefhebrew'] = 0x05D0;
  15405. t['aleflamedhebrew'] = 0xFB4F;
  15406. t['alefmaddaabovearabic'] = 0x0622;
  15407. t['alefmaddaabovefinalarabic'] = 0xFE82;
  15408. t['alefmaksuraarabic'] = 0x0649;
  15409. t['alefmaksurafinalarabic'] = 0xFEF0;
  15410. t['alefmaksurainitialarabic'] = 0xFEF3;
  15411. t['alefmaksuramedialarabic'] = 0xFEF4;
  15412. t['alefpatahhebrew'] = 0xFB2E;
  15413. t['alefqamatshebrew'] = 0xFB2F;
  15414. t['aleph'] = 0x2135;
  15415. t['allequal'] = 0x224C;
  15416. t['alpha'] = 0x03B1;
  15417. t['alphatonos'] = 0x03AC;
  15418. t['amacron'] = 0x0101;
  15419. t['amonospace'] = 0xFF41;
  15420. t['ampersand'] = 0x0026;
  15421. t['ampersandmonospace'] = 0xFF06;
  15422. t['ampersandsmall'] = 0xF726;
  15423. t['amsquare'] = 0x33C2;
  15424. t['anbopomofo'] = 0x3122;
  15425. t['angbopomofo'] = 0x3124;
  15426. t['angbracketleft'] = 0x3008;
  15427. t['angbracketright'] = 0x3009;
  15428. t['angkhankhuthai'] = 0x0E5A;
  15429. t['angle'] = 0x2220;
  15430. t['anglebracketleft'] = 0x3008;
  15431. t['anglebracketleftvertical'] = 0xFE3F;
  15432. t['anglebracketright'] = 0x3009;
  15433. t['anglebracketrightvertical'] = 0xFE40;
  15434. t['angleleft'] = 0x2329;
  15435. t['angleright'] = 0x232A;
  15436. t['angstrom'] = 0x212B;
  15437. t['anoteleia'] = 0x0387;
  15438. t['anudattadeva'] = 0x0952;
  15439. t['anusvarabengali'] = 0x0982;
  15440. t['anusvaradeva'] = 0x0902;
  15441. t['anusvaragujarati'] = 0x0A82;
  15442. t['aogonek'] = 0x0105;
  15443. t['apaatosquare'] = 0x3300;
  15444. t['aparen'] = 0x249C;
  15445. t['apostrophearmenian'] = 0x055A;
  15446. t['apostrophemod'] = 0x02BC;
  15447. t['apple'] = 0xF8FF;
  15448. t['approaches'] = 0x2250;
  15449. t['approxequal'] = 0x2248;
  15450. t['approxequalorimage'] = 0x2252;
  15451. t['approximatelyequal'] = 0x2245;
  15452. t['araeaekorean'] = 0x318E;
  15453. t['araeakorean'] = 0x318D;
  15454. t['arc'] = 0x2312;
  15455. t['arighthalfring'] = 0x1E9A;
  15456. t['aring'] = 0x00E5;
  15457. t['aringacute'] = 0x01FB;
  15458. t['aringbelow'] = 0x1E01;
  15459. t['arrowboth'] = 0x2194;
  15460. t['arrowdashdown'] = 0x21E3;
  15461. t['arrowdashleft'] = 0x21E0;
  15462. t['arrowdashright'] = 0x21E2;
  15463. t['arrowdashup'] = 0x21E1;
  15464. t['arrowdblboth'] = 0x21D4;
  15465. t['arrowdbldown'] = 0x21D3;
  15466. t['arrowdblleft'] = 0x21D0;
  15467. t['arrowdblright'] = 0x21D2;
  15468. t['arrowdblup'] = 0x21D1;
  15469. t['arrowdown'] = 0x2193;
  15470. t['arrowdownleft'] = 0x2199;
  15471. t['arrowdownright'] = 0x2198;
  15472. t['arrowdownwhite'] = 0x21E9;
  15473. t['arrowheaddownmod'] = 0x02C5;
  15474. t['arrowheadleftmod'] = 0x02C2;
  15475. t['arrowheadrightmod'] = 0x02C3;
  15476. t['arrowheadupmod'] = 0x02C4;
  15477. t['arrowhorizex'] = 0xF8E7;
  15478. t['arrowleft'] = 0x2190;
  15479. t['arrowleftdbl'] = 0x21D0;
  15480. t['arrowleftdblstroke'] = 0x21CD;
  15481. t['arrowleftoverright'] = 0x21C6;
  15482. t['arrowleftwhite'] = 0x21E6;
  15483. t['arrowright'] = 0x2192;
  15484. t['arrowrightdblstroke'] = 0x21CF;
  15485. t['arrowrightheavy'] = 0x279E;
  15486. t['arrowrightoverleft'] = 0x21C4;
  15487. t['arrowrightwhite'] = 0x21E8;
  15488. t['arrowtableft'] = 0x21E4;
  15489. t['arrowtabright'] = 0x21E5;
  15490. t['arrowup'] = 0x2191;
  15491. t['arrowupdn'] = 0x2195;
  15492. t['arrowupdnbse'] = 0x21A8;
  15493. t['arrowupdownbase'] = 0x21A8;
  15494. t['arrowupleft'] = 0x2196;
  15495. t['arrowupleftofdown'] = 0x21C5;
  15496. t['arrowupright'] = 0x2197;
  15497. t['arrowupwhite'] = 0x21E7;
  15498. t['arrowvertex'] = 0xF8E6;
  15499. t['asciicircum'] = 0x005E;
  15500. t['asciicircummonospace'] = 0xFF3E;
  15501. t['asciitilde'] = 0x007E;
  15502. t['asciitildemonospace'] = 0xFF5E;
  15503. t['ascript'] = 0x0251;
  15504. t['ascriptturned'] = 0x0252;
  15505. t['asmallhiragana'] = 0x3041;
  15506. t['asmallkatakana'] = 0x30A1;
  15507. t['asmallkatakanahalfwidth'] = 0xFF67;
  15508. t['asterisk'] = 0x002A;
  15509. t['asteriskaltonearabic'] = 0x066D;
  15510. t['asteriskarabic'] = 0x066D;
  15511. t['asteriskmath'] = 0x2217;
  15512. t['asteriskmonospace'] = 0xFF0A;
  15513. t['asterisksmall'] = 0xFE61;
  15514. t['asterism'] = 0x2042;
  15515. t['asuperior'] = 0xF6E9;
  15516. t['asymptoticallyequal'] = 0x2243;
  15517. t['at'] = 0x0040;
  15518. t['atilde'] = 0x00E3;
  15519. t['atmonospace'] = 0xFF20;
  15520. t['atsmall'] = 0xFE6B;
  15521. t['aturned'] = 0x0250;
  15522. t['aubengali'] = 0x0994;
  15523. t['aubopomofo'] = 0x3120;
  15524. t['audeva'] = 0x0914;
  15525. t['augujarati'] = 0x0A94;
  15526. t['augurmukhi'] = 0x0A14;
  15527. t['aulengthmarkbengali'] = 0x09D7;
  15528. t['aumatragurmukhi'] = 0x0A4C;
  15529. t['auvowelsignbengali'] = 0x09CC;
  15530. t['auvowelsigndeva'] = 0x094C;
  15531. t['auvowelsigngujarati'] = 0x0ACC;
  15532. t['avagrahadeva'] = 0x093D;
  15533. t['aybarmenian'] = 0x0561;
  15534. t['ayin'] = 0x05E2;
  15535. t['ayinaltonehebrew'] = 0xFB20;
  15536. t['ayinhebrew'] = 0x05E2;
  15537. t['b'] = 0x0062;
  15538. t['babengali'] = 0x09AC;
  15539. t['backslash'] = 0x005C;
  15540. t['backslashmonospace'] = 0xFF3C;
  15541. t['badeva'] = 0x092C;
  15542. t['bagujarati'] = 0x0AAC;
  15543. t['bagurmukhi'] = 0x0A2C;
  15544. t['bahiragana'] = 0x3070;
  15545. t['bahtthai'] = 0x0E3F;
  15546. t['bakatakana'] = 0x30D0;
  15547. t['bar'] = 0x007C;
  15548. t['barmonospace'] = 0xFF5C;
  15549. t['bbopomofo'] = 0x3105;
  15550. t['bcircle'] = 0x24D1;
  15551. t['bdotaccent'] = 0x1E03;
  15552. t['bdotbelow'] = 0x1E05;
  15553. t['beamedsixteenthnotes'] = 0x266C;
  15554. t['because'] = 0x2235;
  15555. t['becyrillic'] = 0x0431;
  15556. t['beharabic'] = 0x0628;
  15557. t['behfinalarabic'] = 0xFE90;
  15558. t['behinitialarabic'] = 0xFE91;
  15559. t['behiragana'] = 0x3079;
  15560. t['behmedialarabic'] = 0xFE92;
  15561. t['behmeeminitialarabic'] = 0xFC9F;
  15562. t['behmeemisolatedarabic'] = 0xFC08;
  15563. t['behnoonfinalarabic'] = 0xFC6D;
  15564. t['bekatakana'] = 0x30D9;
  15565. t['benarmenian'] = 0x0562;
  15566. t['bet'] = 0x05D1;
  15567. t['beta'] = 0x03B2;
  15568. t['betasymbolgreek'] = 0x03D0;
  15569. t['betdagesh'] = 0xFB31;
  15570. t['betdageshhebrew'] = 0xFB31;
  15571. t['bethebrew'] = 0x05D1;
  15572. t['betrafehebrew'] = 0xFB4C;
  15573. t['bhabengali'] = 0x09AD;
  15574. t['bhadeva'] = 0x092D;
  15575. t['bhagujarati'] = 0x0AAD;
  15576. t['bhagurmukhi'] = 0x0A2D;
  15577. t['bhook'] = 0x0253;
  15578. t['bihiragana'] = 0x3073;
  15579. t['bikatakana'] = 0x30D3;
  15580. t['bilabialclick'] = 0x0298;
  15581. t['bindigurmukhi'] = 0x0A02;
  15582. t['birusquare'] = 0x3331;
  15583. t['blackcircle'] = 0x25CF;
  15584. t['blackdiamond'] = 0x25C6;
  15585. t['blackdownpointingtriangle'] = 0x25BC;
  15586. t['blackleftpointingpointer'] = 0x25C4;
  15587. t['blackleftpointingtriangle'] = 0x25C0;
  15588. t['blacklenticularbracketleft'] = 0x3010;
  15589. t['blacklenticularbracketleftvertical'] = 0xFE3B;
  15590. t['blacklenticularbracketright'] = 0x3011;
  15591. t['blacklenticularbracketrightvertical'] = 0xFE3C;
  15592. t['blacklowerlefttriangle'] = 0x25E3;
  15593. t['blacklowerrighttriangle'] = 0x25E2;
  15594. t['blackrectangle'] = 0x25AC;
  15595. t['blackrightpointingpointer'] = 0x25BA;
  15596. t['blackrightpointingtriangle'] = 0x25B6;
  15597. t['blacksmallsquare'] = 0x25AA;
  15598. t['blacksmilingface'] = 0x263B;
  15599. t['blacksquare'] = 0x25A0;
  15600. t['blackstar'] = 0x2605;
  15601. t['blackupperlefttriangle'] = 0x25E4;
  15602. t['blackupperrighttriangle'] = 0x25E5;
  15603. t['blackuppointingsmalltriangle'] = 0x25B4;
  15604. t['blackuppointingtriangle'] = 0x25B2;
  15605. t['blank'] = 0x2423;
  15606. t['blinebelow'] = 0x1E07;
  15607. t['block'] = 0x2588;
  15608. t['bmonospace'] = 0xFF42;
  15609. t['bobaimaithai'] = 0x0E1A;
  15610. t['bohiragana'] = 0x307C;
  15611. t['bokatakana'] = 0x30DC;
  15612. t['bparen'] = 0x249D;
  15613. t['bqsquare'] = 0x33C3;
  15614. t['braceex'] = 0xF8F4;
  15615. t['braceleft'] = 0x007B;
  15616. t['braceleftbt'] = 0xF8F3;
  15617. t['braceleftmid'] = 0xF8F2;
  15618. t['braceleftmonospace'] = 0xFF5B;
  15619. t['braceleftsmall'] = 0xFE5B;
  15620. t['bracelefttp'] = 0xF8F1;
  15621. t['braceleftvertical'] = 0xFE37;
  15622. t['braceright'] = 0x007D;
  15623. t['bracerightbt'] = 0xF8FE;
  15624. t['bracerightmid'] = 0xF8FD;
  15625. t['bracerightmonospace'] = 0xFF5D;
  15626. t['bracerightsmall'] = 0xFE5C;
  15627. t['bracerighttp'] = 0xF8FC;
  15628. t['bracerightvertical'] = 0xFE38;
  15629. t['bracketleft'] = 0x005B;
  15630. t['bracketleftbt'] = 0xF8F0;
  15631. t['bracketleftex'] = 0xF8EF;
  15632. t['bracketleftmonospace'] = 0xFF3B;
  15633. t['bracketlefttp'] = 0xF8EE;
  15634. t['bracketright'] = 0x005D;
  15635. t['bracketrightbt'] = 0xF8FB;
  15636. t['bracketrightex'] = 0xF8FA;
  15637. t['bracketrightmonospace'] = 0xFF3D;
  15638. t['bracketrighttp'] = 0xF8F9;
  15639. t['breve'] = 0x02D8;
  15640. t['brevebelowcmb'] = 0x032E;
  15641. t['brevecmb'] = 0x0306;
  15642. t['breveinvertedbelowcmb'] = 0x032F;
  15643. t['breveinvertedcmb'] = 0x0311;
  15644. t['breveinverteddoublecmb'] = 0x0361;
  15645. t['bridgebelowcmb'] = 0x032A;
  15646. t['bridgeinvertedbelowcmb'] = 0x033A;
  15647. t['brokenbar'] = 0x00A6;
  15648. t['bstroke'] = 0x0180;
  15649. t['bsuperior'] = 0xF6EA;
  15650. t['btopbar'] = 0x0183;
  15651. t['buhiragana'] = 0x3076;
  15652. t['bukatakana'] = 0x30D6;
  15653. t['bullet'] = 0x2022;
  15654. t['bulletinverse'] = 0x25D8;
  15655. t['bulletoperator'] = 0x2219;
  15656. t['bullseye'] = 0x25CE;
  15657. t['c'] = 0x0063;
  15658. t['caarmenian'] = 0x056E;
  15659. t['cabengali'] = 0x099A;
  15660. t['cacute'] = 0x0107;
  15661. t['cadeva'] = 0x091A;
  15662. t['cagujarati'] = 0x0A9A;
  15663. t['cagurmukhi'] = 0x0A1A;
  15664. t['calsquare'] = 0x3388;
  15665. t['candrabindubengali'] = 0x0981;
  15666. t['candrabinducmb'] = 0x0310;
  15667. t['candrabindudeva'] = 0x0901;
  15668. t['candrabindugujarati'] = 0x0A81;
  15669. t['capslock'] = 0x21EA;
  15670. t['careof'] = 0x2105;
  15671. t['caron'] = 0x02C7;
  15672. t['caronbelowcmb'] = 0x032C;
  15673. t['caroncmb'] = 0x030C;
  15674. t['carriagereturn'] = 0x21B5;
  15675. t['cbopomofo'] = 0x3118;
  15676. t['ccaron'] = 0x010D;
  15677. t['ccedilla'] = 0x00E7;
  15678. t['ccedillaacute'] = 0x1E09;
  15679. t['ccircle'] = 0x24D2;
  15680. t['ccircumflex'] = 0x0109;
  15681. t['ccurl'] = 0x0255;
  15682. t['cdot'] = 0x010B;
  15683. t['cdotaccent'] = 0x010B;
  15684. t['cdsquare'] = 0x33C5;
  15685. t['cedilla'] = 0x00B8;
  15686. t['cedillacmb'] = 0x0327;
  15687. t['cent'] = 0x00A2;
  15688. t['centigrade'] = 0x2103;
  15689. t['centinferior'] = 0xF6DF;
  15690. t['centmonospace'] = 0xFFE0;
  15691. t['centoldstyle'] = 0xF7A2;
  15692. t['centsuperior'] = 0xF6E0;
  15693. t['chaarmenian'] = 0x0579;
  15694. t['chabengali'] = 0x099B;
  15695. t['chadeva'] = 0x091B;
  15696. t['chagujarati'] = 0x0A9B;
  15697. t['chagurmukhi'] = 0x0A1B;
  15698. t['chbopomofo'] = 0x3114;
  15699. t['cheabkhasiancyrillic'] = 0x04BD;
  15700. t['checkmark'] = 0x2713;
  15701. t['checyrillic'] = 0x0447;
  15702. t['chedescenderabkhasiancyrillic'] = 0x04BF;
  15703. t['chedescendercyrillic'] = 0x04B7;
  15704. t['chedieresiscyrillic'] = 0x04F5;
  15705. t['cheharmenian'] = 0x0573;
  15706. t['chekhakassiancyrillic'] = 0x04CC;
  15707. t['cheverticalstrokecyrillic'] = 0x04B9;
  15708. t['chi'] = 0x03C7;
  15709. t['chieuchacirclekorean'] = 0x3277;
  15710. t['chieuchaparenkorean'] = 0x3217;
  15711. t['chieuchcirclekorean'] = 0x3269;
  15712. t['chieuchkorean'] = 0x314A;
  15713. t['chieuchparenkorean'] = 0x3209;
  15714. t['chochangthai'] = 0x0E0A;
  15715. t['chochanthai'] = 0x0E08;
  15716. t['chochingthai'] = 0x0E09;
  15717. t['chochoethai'] = 0x0E0C;
  15718. t['chook'] = 0x0188;
  15719. t['cieucacirclekorean'] = 0x3276;
  15720. t['cieucaparenkorean'] = 0x3216;
  15721. t['cieuccirclekorean'] = 0x3268;
  15722. t['cieuckorean'] = 0x3148;
  15723. t['cieucparenkorean'] = 0x3208;
  15724. t['cieucuparenkorean'] = 0x321C;
  15725. t['circle'] = 0x25CB;
  15726. t['circlecopyrt'] = 0x00A9;
  15727. t['circlemultiply'] = 0x2297;
  15728. t['circleot'] = 0x2299;
  15729. t['circleplus'] = 0x2295;
  15730. t['circlepostalmark'] = 0x3036;
  15731. t['circlewithlefthalfblack'] = 0x25D0;
  15732. t['circlewithrighthalfblack'] = 0x25D1;
  15733. t['circumflex'] = 0x02C6;
  15734. t['circumflexbelowcmb'] = 0x032D;
  15735. t['circumflexcmb'] = 0x0302;
  15736. t['clear'] = 0x2327;
  15737. t['clickalveolar'] = 0x01C2;
  15738. t['clickdental'] = 0x01C0;
  15739. t['clicklateral'] = 0x01C1;
  15740. t['clickretroflex'] = 0x01C3;
  15741. t['club'] = 0x2663;
  15742. t['clubsuitblack'] = 0x2663;
  15743. t['clubsuitwhite'] = 0x2667;
  15744. t['cmcubedsquare'] = 0x33A4;
  15745. t['cmonospace'] = 0xFF43;
  15746. t['cmsquaredsquare'] = 0x33A0;
  15747. t['coarmenian'] = 0x0581;
  15748. t['colon'] = 0x003A;
  15749. t['colonmonetary'] = 0x20A1;
  15750. t['colonmonospace'] = 0xFF1A;
  15751. t['colonsign'] = 0x20A1;
  15752. t['colonsmall'] = 0xFE55;
  15753. t['colontriangularhalfmod'] = 0x02D1;
  15754. t['colontriangularmod'] = 0x02D0;
  15755. t['comma'] = 0x002C;
  15756. t['commaabovecmb'] = 0x0313;
  15757. t['commaaboverightcmb'] = 0x0315;
  15758. t['commaaccent'] = 0xF6C3;
  15759. t['commaarabic'] = 0x060C;
  15760. t['commaarmenian'] = 0x055D;
  15761. t['commainferior'] = 0xF6E1;
  15762. t['commamonospace'] = 0xFF0C;
  15763. t['commareversedabovecmb'] = 0x0314;
  15764. t['commareversedmod'] = 0x02BD;
  15765. t['commasmall'] = 0xFE50;
  15766. t['commasuperior'] = 0xF6E2;
  15767. t['commaturnedabovecmb'] = 0x0312;
  15768. t['commaturnedmod'] = 0x02BB;
  15769. t['compass'] = 0x263C;
  15770. t['congruent'] = 0x2245;
  15771. t['contourintegral'] = 0x222E;
  15772. t['control'] = 0x2303;
  15773. t['controlACK'] = 0x0006;
  15774. t['controlBEL'] = 0x0007;
  15775. t['controlBS'] = 0x0008;
  15776. t['controlCAN'] = 0x0018;
  15777. t['controlCR'] = 0x000D;
  15778. t['controlDC1'] = 0x0011;
  15779. t['controlDC2'] = 0x0012;
  15780. t['controlDC3'] = 0x0013;
  15781. t['controlDC4'] = 0x0014;
  15782. t['controlDEL'] = 0x007F;
  15783. t['controlDLE'] = 0x0010;
  15784. t['controlEM'] = 0x0019;
  15785. t['controlENQ'] = 0x0005;
  15786. t['controlEOT'] = 0x0004;
  15787. t['controlESC'] = 0x001B;
  15788. t['controlETB'] = 0x0017;
  15789. t['controlETX'] = 0x0003;
  15790. t['controlFF'] = 0x000C;
  15791. t['controlFS'] = 0x001C;
  15792. t['controlGS'] = 0x001D;
  15793. t['controlHT'] = 0x0009;
  15794. t['controlLF'] = 0x000A;
  15795. t['controlNAK'] = 0x0015;
  15796. t['controlNULL'] = 0x0000;
  15797. t['controlRS'] = 0x001E;
  15798. t['controlSI'] = 0x000F;
  15799. t['controlSO'] = 0x000E;
  15800. t['controlSOT'] = 0x0002;
  15801. t['controlSTX'] = 0x0001;
  15802. t['controlSUB'] = 0x001A;
  15803. t['controlSYN'] = 0x0016;
  15804. t['controlUS'] = 0x001F;
  15805. t['controlVT'] = 0x000B;
  15806. t['copyright'] = 0x00A9;
  15807. t['copyrightsans'] = 0xF8E9;
  15808. t['copyrightserif'] = 0xF6D9;
  15809. t['cornerbracketleft'] = 0x300C;
  15810. t['cornerbracketlefthalfwidth'] = 0xFF62;
  15811. t['cornerbracketleftvertical'] = 0xFE41;
  15812. t['cornerbracketright'] = 0x300D;
  15813. t['cornerbracketrighthalfwidth'] = 0xFF63;
  15814. t['cornerbracketrightvertical'] = 0xFE42;
  15815. t['corporationsquare'] = 0x337F;
  15816. t['cosquare'] = 0x33C7;
  15817. t['coverkgsquare'] = 0x33C6;
  15818. t['cparen'] = 0x249E;
  15819. t['cruzeiro'] = 0x20A2;
  15820. t['cstretched'] = 0x0297;
  15821. t['curlyand'] = 0x22CF;
  15822. t['curlyor'] = 0x22CE;
  15823. t['currency'] = 0x00A4;
  15824. t['cyrBreve'] = 0xF6D1;
  15825. t['cyrFlex'] = 0xF6D2;
  15826. t['cyrbreve'] = 0xF6D4;
  15827. t['cyrflex'] = 0xF6D5;
  15828. t['d'] = 0x0064;
  15829. t['daarmenian'] = 0x0564;
  15830. t['dabengali'] = 0x09A6;
  15831. t['dadarabic'] = 0x0636;
  15832. t['dadeva'] = 0x0926;
  15833. t['dadfinalarabic'] = 0xFEBE;
  15834. t['dadinitialarabic'] = 0xFEBF;
  15835. t['dadmedialarabic'] = 0xFEC0;
  15836. t['dagesh'] = 0x05BC;
  15837. t['dageshhebrew'] = 0x05BC;
  15838. t['dagger'] = 0x2020;
  15839. t['daggerdbl'] = 0x2021;
  15840. t['dagujarati'] = 0x0AA6;
  15841. t['dagurmukhi'] = 0x0A26;
  15842. t['dahiragana'] = 0x3060;
  15843. t['dakatakana'] = 0x30C0;
  15844. t['dalarabic'] = 0x062F;
  15845. t['dalet'] = 0x05D3;
  15846. t['daletdagesh'] = 0xFB33;
  15847. t['daletdageshhebrew'] = 0xFB33;
  15848. t['dalethebrew'] = 0x05D3;
  15849. t['dalfinalarabic'] = 0xFEAA;
  15850. t['dammaarabic'] = 0x064F;
  15851. t['dammalowarabic'] = 0x064F;
  15852. t['dammatanaltonearabic'] = 0x064C;
  15853. t['dammatanarabic'] = 0x064C;
  15854. t['danda'] = 0x0964;
  15855. t['dargahebrew'] = 0x05A7;
  15856. t['dargalefthebrew'] = 0x05A7;
  15857. t['dasiapneumatacyrilliccmb'] = 0x0485;
  15858. t['dblGrave'] = 0xF6D3;
  15859. t['dblanglebracketleft'] = 0x300A;
  15860. t['dblanglebracketleftvertical'] = 0xFE3D;
  15861. t['dblanglebracketright'] = 0x300B;
  15862. t['dblanglebracketrightvertical'] = 0xFE3E;
  15863. t['dblarchinvertedbelowcmb'] = 0x032B;
  15864. t['dblarrowleft'] = 0x21D4;
  15865. t['dblarrowright'] = 0x21D2;
  15866. t['dbldanda'] = 0x0965;
  15867. t['dblgrave'] = 0xF6D6;
  15868. t['dblgravecmb'] = 0x030F;
  15869. t['dblintegral'] = 0x222C;
  15870. t['dbllowline'] = 0x2017;
  15871. t['dbllowlinecmb'] = 0x0333;
  15872. t['dbloverlinecmb'] = 0x033F;
  15873. t['dblprimemod'] = 0x02BA;
  15874. t['dblverticalbar'] = 0x2016;
  15875. t['dblverticallineabovecmb'] = 0x030E;
  15876. t['dbopomofo'] = 0x3109;
  15877. t['dbsquare'] = 0x33C8;
  15878. t['dcaron'] = 0x010F;
  15879. t['dcedilla'] = 0x1E11;
  15880. t['dcircle'] = 0x24D3;
  15881. t['dcircumflexbelow'] = 0x1E13;
  15882. t['dcroat'] = 0x0111;
  15883. t['ddabengali'] = 0x09A1;
  15884. t['ddadeva'] = 0x0921;
  15885. t['ddagujarati'] = 0x0AA1;
  15886. t['ddagurmukhi'] = 0x0A21;
  15887. t['ddalarabic'] = 0x0688;
  15888. t['ddalfinalarabic'] = 0xFB89;
  15889. t['dddhadeva'] = 0x095C;
  15890. t['ddhabengali'] = 0x09A2;
  15891. t['ddhadeva'] = 0x0922;
  15892. t['ddhagujarati'] = 0x0AA2;
  15893. t['ddhagurmukhi'] = 0x0A22;
  15894. t['ddotaccent'] = 0x1E0B;
  15895. t['ddotbelow'] = 0x1E0D;
  15896. t['decimalseparatorarabic'] = 0x066B;
  15897. t['decimalseparatorpersian'] = 0x066B;
  15898. t['decyrillic'] = 0x0434;
  15899. t['degree'] = 0x00B0;
  15900. t['dehihebrew'] = 0x05AD;
  15901. t['dehiragana'] = 0x3067;
  15902. t['deicoptic'] = 0x03EF;
  15903. t['dekatakana'] = 0x30C7;
  15904. t['deleteleft'] = 0x232B;
  15905. t['deleteright'] = 0x2326;
  15906. t['delta'] = 0x03B4;
  15907. t['deltaturned'] = 0x018D;
  15908. t['denominatorminusonenumeratorbengali'] = 0x09F8;
  15909. t['dezh'] = 0x02A4;
  15910. t['dhabengali'] = 0x09A7;
  15911. t['dhadeva'] = 0x0927;
  15912. t['dhagujarati'] = 0x0AA7;
  15913. t['dhagurmukhi'] = 0x0A27;
  15914. t['dhook'] = 0x0257;
  15915. t['dialytikatonos'] = 0x0385;
  15916. t['dialytikatonoscmb'] = 0x0344;
  15917. t['diamond'] = 0x2666;
  15918. t['diamondsuitwhite'] = 0x2662;
  15919. t['dieresis'] = 0x00A8;
  15920. t['dieresisacute'] = 0xF6D7;
  15921. t['dieresisbelowcmb'] = 0x0324;
  15922. t['dieresiscmb'] = 0x0308;
  15923. t['dieresisgrave'] = 0xF6D8;
  15924. t['dieresistonos'] = 0x0385;
  15925. t['dihiragana'] = 0x3062;
  15926. t['dikatakana'] = 0x30C2;
  15927. t['dittomark'] = 0x3003;
  15928. t['divide'] = 0x00F7;
  15929. t['divides'] = 0x2223;
  15930. t['divisionslash'] = 0x2215;
  15931. t['djecyrillic'] = 0x0452;
  15932. t['dkshade'] = 0x2593;
  15933. t['dlinebelow'] = 0x1E0F;
  15934. t['dlsquare'] = 0x3397;
  15935. t['dmacron'] = 0x0111;
  15936. t['dmonospace'] = 0xFF44;
  15937. t['dnblock'] = 0x2584;
  15938. t['dochadathai'] = 0x0E0E;
  15939. t['dodekthai'] = 0x0E14;
  15940. t['dohiragana'] = 0x3069;
  15941. t['dokatakana'] = 0x30C9;
  15942. t['dollar'] = 0x0024;
  15943. t['dollarinferior'] = 0xF6E3;
  15944. t['dollarmonospace'] = 0xFF04;
  15945. t['dollaroldstyle'] = 0xF724;
  15946. t['dollarsmall'] = 0xFE69;
  15947. t['dollarsuperior'] = 0xF6E4;
  15948. t['dong'] = 0x20AB;
  15949. t['dorusquare'] = 0x3326;
  15950. t['dotaccent'] = 0x02D9;
  15951. t['dotaccentcmb'] = 0x0307;
  15952. t['dotbelowcmb'] = 0x0323;
  15953. t['dotbelowcomb'] = 0x0323;
  15954. t['dotkatakana'] = 0x30FB;
  15955. t['dotlessi'] = 0x0131;
  15956. t['dotlessj'] = 0xF6BE;
  15957. t['dotlessjstrokehook'] = 0x0284;
  15958. t['dotmath'] = 0x22C5;
  15959. t['dottedcircle'] = 0x25CC;
  15960. t['doubleyodpatah'] = 0xFB1F;
  15961. t['doubleyodpatahhebrew'] = 0xFB1F;
  15962. t['downtackbelowcmb'] = 0x031E;
  15963. t['downtackmod'] = 0x02D5;
  15964. t['dparen'] = 0x249F;
  15965. t['dsuperior'] = 0xF6EB;
  15966. t['dtail'] = 0x0256;
  15967. t['dtopbar'] = 0x018C;
  15968. t['duhiragana'] = 0x3065;
  15969. t['dukatakana'] = 0x30C5;
  15970. t['dz'] = 0x01F3;
  15971. t['dzaltone'] = 0x02A3;
  15972. t['dzcaron'] = 0x01C6;
  15973. t['dzcurl'] = 0x02A5;
  15974. t['dzeabkhasiancyrillic'] = 0x04E1;
  15975. t['dzecyrillic'] = 0x0455;
  15976. t['dzhecyrillic'] = 0x045F;
  15977. t['e'] = 0x0065;
  15978. t['eacute'] = 0x00E9;
  15979. t['earth'] = 0x2641;
  15980. t['ebengali'] = 0x098F;
  15981. t['ebopomofo'] = 0x311C;
  15982. t['ebreve'] = 0x0115;
  15983. t['ecandradeva'] = 0x090D;
  15984. t['ecandragujarati'] = 0x0A8D;
  15985. t['ecandravowelsigndeva'] = 0x0945;
  15986. t['ecandravowelsigngujarati'] = 0x0AC5;
  15987. t['ecaron'] = 0x011B;
  15988. t['ecedillabreve'] = 0x1E1D;
  15989. t['echarmenian'] = 0x0565;
  15990. t['echyiwnarmenian'] = 0x0587;
  15991. t['ecircle'] = 0x24D4;
  15992. t['ecircumflex'] = 0x00EA;
  15993. t['ecircumflexacute'] = 0x1EBF;
  15994. t['ecircumflexbelow'] = 0x1E19;
  15995. t['ecircumflexdotbelow'] = 0x1EC7;
  15996. t['ecircumflexgrave'] = 0x1EC1;
  15997. t['ecircumflexhookabove'] = 0x1EC3;
  15998. t['ecircumflextilde'] = 0x1EC5;
  15999. t['ecyrillic'] = 0x0454;
  16000. t['edblgrave'] = 0x0205;
  16001. t['edeva'] = 0x090F;
  16002. t['edieresis'] = 0x00EB;
  16003. t['edot'] = 0x0117;
  16004. t['edotaccent'] = 0x0117;
  16005. t['edotbelow'] = 0x1EB9;
  16006. t['eegurmukhi'] = 0x0A0F;
  16007. t['eematragurmukhi'] = 0x0A47;
  16008. t['efcyrillic'] = 0x0444;
  16009. t['egrave'] = 0x00E8;
  16010. t['egujarati'] = 0x0A8F;
  16011. t['eharmenian'] = 0x0567;
  16012. t['ehbopomofo'] = 0x311D;
  16013. t['ehiragana'] = 0x3048;
  16014. t['ehookabove'] = 0x1EBB;
  16015. t['eibopomofo'] = 0x311F;
  16016. t['eight'] = 0x0038;
  16017. t['eightarabic'] = 0x0668;
  16018. t['eightbengali'] = 0x09EE;
  16019. t['eightcircle'] = 0x2467;
  16020. t['eightcircleinversesansserif'] = 0x2791;
  16021. t['eightdeva'] = 0x096E;
  16022. t['eighteencircle'] = 0x2471;
  16023. t['eighteenparen'] = 0x2485;
  16024. t['eighteenperiod'] = 0x2499;
  16025. t['eightgujarati'] = 0x0AEE;
  16026. t['eightgurmukhi'] = 0x0A6E;
  16027. t['eighthackarabic'] = 0x0668;
  16028. t['eighthangzhou'] = 0x3028;
  16029. t['eighthnotebeamed'] = 0x266B;
  16030. t['eightideographicparen'] = 0x3227;
  16031. t['eightinferior'] = 0x2088;
  16032. t['eightmonospace'] = 0xFF18;
  16033. t['eightoldstyle'] = 0xF738;
  16034. t['eightparen'] = 0x247B;
  16035. t['eightperiod'] = 0x248F;
  16036. t['eightpersian'] = 0x06F8;
  16037. t['eightroman'] = 0x2177;
  16038. t['eightsuperior'] = 0x2078;
  16039. t['eightthai'] = 0x0E58;
  16040. t['einvertedbreve'] = 0x0207;
  16041. t['eiotifiedcyrillic'] = 0x0465;
  16042. t['ekatakana'] = 0x30A8;
  16043. t['ekatakanahalfwidth'] = 0xFF74;
  16044. t['ekonkargurmukhi'] = 0x0A74;
  16045. t['ekorean'] = 0x3154;
  16046. t['elcyrillic'] = 0x043B;
  16047. t['element'] = 0x2208;
  16048. t['elevencircle'] = 0x246A;
  16049. t['elevenparen'] = 0x247E;
  16050. t['elevenperiod'] = 0x2492;
  16051. t['elevenroman'] = 0x217A;
  16052. t['ellipsis'] = 0x2026;
  16053. t['ellipsisvertical'] = 0x22EE;
  16054. t['emacron'] = 0x0113;
  16055. t['emacronacute'] = 0x1E17;
  16056. t['emacrongrave'] = 0x1E15;
  16057. t['emcyrillic'] = 0x043C;
  16058. t['emdash'] = 0x2014;
  16059. t['emdashvertical'] = 0xFE31;
  16060. t['emonospace'] = 0xFF45;
  16061. t['emphasismarkarmenian'] = 0x055B;
  16062. t['emptyset'] = 0x2205;
  16063. t['enbopomofo'] = 0x3123;
  16064. t['encyrillic'] = 0x043D;
  16065. t['endash'] = 0x2013;
  16066. t['endashvertical'] = 0xFE32;
  16067. t['endescendercyrillic'] = 0x04A3;
  16068. t['eng'] = 0x014B;
  16069. t['engbopomofo'] = 0x3125;
  16070. t['enghecyrillic'] = 0x04A5;
  16071. t['enhookcyrillic'] = 0x04C8;
  16072. t['enspace'] = 0x2002;
  16073. t['eogonek'] = 0x0119;
  16074. t['eokorean'] = 0x3153;
  16075. t['eopen'] = 0x025B;
  16076. t['eopenclosed'] = 0x029A;
  16077. t['eopenreversed'] = 0x025C;
  16078. t['eopenreversedclosed'] = 0x025E;
  16079. t['eopenreversedhook'] = 0x025D;
  16080. t['eparen'] = 0x24A0;
  16081. t['epsilon'] = 0x03B5;
  16082. t['epsilontonos'] = 0x03AD;
  16083. t['equal'] = 0x003D;
  16084. t['equalmonospace'] = 0xFF1D;
  16085. t['equalsmall'] = 0xFE66;
  16086. t['equalsuperior'] = 0x207C;
  16087. t['equivalence'] = 0x2261;
  16088. t['erbopomofo'] = 0x3126;
  16089. t['ercyrillic'] = 0x0440;
  16090. t['ereversed'] = 0x0258;
  16091. t['ereversedcyrillic'] = 0x044D;
  16092. t['escyrillic'] = 0x0441;
  16093. t['esdescendercyrillic'] = 0x04AB;
  16094. t['esh'] = 0x0283;
  16095. t['eshcurl'] = 0x0286;
  16096. t['eshortdeva'] = 0x090E;
  16097. t['eshortvowelsigndeva'] = 0x0946;
  16098. t['eshreversedloop'] = 0x01AA;
  16099. t['eshsquatreversed'] = 0x0285;
  16100. t['esmallhiragana'] = 0x3047;
  16101. t['esmallkatakana'] = 0x30A7;
  16102. t['esmallkatakanahalfwidth'] = 0xFF6A;
  16103. t['estimated'] = 0x212E;
  16104. t['esuperior'] = 0xF6EC;
  16105. t['eta'] = 0x03B7;
  16106. t['etarmenian'] = 0x0568;
  16107. t['etatonos'] = 0x03AE;
  16108. t['eth'] = 0x00F0;
  16109. t['etilde'] = 0x1EBD;
  16110. t['etildebelow'] = 0x1E1B;
  16111. t['etnahtafoukhhebrew'] = 0x0591;
  16112. t['etnahtafoukhlefthebrew'] = 0x0591;
  16113. t['etnahtahebrew'] = 0x0591;
  16114. t['etnahtalefthebrew'] = 0x0591;
  16115. t['eturned'] = 0x01DD;
  16116. t['eukorean'] = 0x3161;
  16117. t['euro'] = 0x20AC;
  16118. t['evowelsignbengali'] = 0x09C7;
  16119. t['evowelsigndeva'] = 0x0947;
  16120. t['evowelsigngujarati'] = 0x0AC7;
  16121. t['exclam'] = 0x0021;
  16122. t['exclamarmenian'] = 0x055C;
  16123. t['exclamdbl'] = 0x203C;
  16124. t['exclamdown'] = 0x00A1;
  16125. t['exclamdownsmall'] = 0xF7A1;
  16126. t['exclammonospace'] = 0xFF01;
  16127. t['exclamsmall'] = 0xF721;
  16128. t['existential'] = 0x2203;
  16129. t['ezh'] = 0x0292;
  16130. t['ezhcaron'] = 0x01EF;
  16131. t['ezhcurl'] = 0x0293;
  16132. t['ezhreversed'] = 0x01B9;
  16133. t['ezhtail'] = 0x01BA;
  16134. t['f'] = 0x0066;
  16135. t['fadeva'] = 0x095E;
  16136. t['fagurmukhi'] = 0x0A5E;
  16137. t['fahrenheit'] = 0x2109;
  16138. t['fathaarabic'] = 0x064E;
  16139. t['fathalowarabic'] = 0x064E;
  16140. t['fathatanarabic'] = 0x064B;
  16141. t['fbopomofo'] = 0x3108;
  16142. t['fcircle'] = 0x24D5;
  16143. t['fdotaccent'] = 0x1E1F;
  16144. t['feharabic'] = 0x0641;
  16145. t['feharmenian'] = 0x0586;
  16146. t['fehfinalarabic'] = 0xFED2;
  16147. t['fehinitialarabic'] = 0xFED3;
  16148. t['fehmedialarabic'] = 0xFED4;
  16149. t['feicoptic'] = 0x03E5;
  16150. t['female'] = 0x2640;
  16151. t['ff'] = 0xFB00;
  16152. t['ffi'] = 0xFB03;
  16153. t['ffl'] = 0xFB04;
  16154. t['fi'] = 0xFB01;
  16155. t['fifteencircle'] = 0x246E;
  16156. t['fifteenparen'] = 0x2482;
  16157. t['fifteenperiod'] = 0x2496;
  16158. t['figuredash'] = 0x2012;
  16159. t['filledbox'] = 0x25A0;
  16160. t['filledrect'] = 0x25AC;
  16161. t['finalkaf'] = 0x05DA;
  16162. t['finalkafdagesh'] = 0xFB3A;
  16163. t['finalkafdageshhebrew'] = 0xFB3A;
  16164. t['finalkafhebrew'] = 0x05DA;
  16165. t['finalmem'] = 0x05DD;
  16166. t['finalmemhebrew'] = 0x05DD;
  16167. t['finalnun'] = 0x05DF;
  16168. t['finalnunhebrew'] = 0x05DF;
  16169. t['finalpe'] = 0x05E3;
  16170. t['finalpehebrew'] = 0x05E3;
  16171. t['finaltsadi'] = 0x05E5;
  16172. t['finaltsadihebrew'] = 0x05E5;
  16173. t['firsttonechinese'] = 0x02C9;
  16174. t['fisheye'] = 0x25C9;
  16175. t['fitacyrillic'] = 0x0473;
  16176. t['five'] = 0x0035;
  16177. t['fivearabic'] = 0x0665;
  16178. t['fivebengali'] = 0x09EB;
  16179. t['fivecircle'] = 0x2464;
  16180. t['fivecircleinversesansserif'] = 0x278E;
  16181. t['fivedeva'] = 0x096B;
  16182. t['fiveeighths'] = 0x215D;
  16183. t['fivegujarati'] = 0x0AEB;
  16184. t['fivegurmukhi'] = 0x0A6B;
  16185. t['fivehackarabic'] = 0x0665;
  16186. t['fivehangzhou'] = 0x3025;
  16187. t['fiveideographicparen'] = 0x3224;
  16188. t['fiveinferior'] = 0x2085;
  16189. t['fivemonospace'] = 0xFF15;
  16190. t['fiveoldstyle'] = 0xF735;
  16191. t['fiveparen'] = 0x2478;
  16192. t['fiveperiod'] = 0x248C;
  16193. t['fivepersian'] = 0x06F5;
  16194. t['fiveroman'] = 0x2174;
  16195. t['fivesuperior'] = 0x2075;
  16196. t['fivethai'] = 0x0E55;
  16197. t['fl'] = 0xFB02;
  16198. t['florin'] = 0x0192;
  16199. t['fmonospace'] = 0xFF46;
  16200. t['fmsquare'] = 0x3399;
  16201. t['fofanthai'] = 0x0E1F;
  16202. t['fofathai'] = 0x0E1D;
  16203. t['fongmanthai'] = 0x0E4F;
  16204. t['forall'] = 0x2200;
  16205. t['four'] = 0x0034;
  16206. t['fourarabic'] = 0x0664;
  16207. t['fourbengali'] = 0x09EA;
  16208. t['fourcircle'] = 0x2463;
  16209. t['fourcircleinversesansserif'] = 0x278D;
  16210. t['fourdeva'] = 0x096A;
  16211. t['fourgujarati'] = 0x0AEA;
  16212. t['fourgurmukhi'] = 0x0A6A;
  16213. t['fourhackarabic'] = 0x0664;
  16214. t['fourhangzhou'] = 0x3024;
  16215. t['fourideographicparen'] = 0x3223;
  16216. t['fourinferior'] = 0x2084;
  16217. t['fourmonospace'] = 0xFF14;
  16218. t['fournumeratorbengali'] = 0x09F7;
  16219. t['fouroldstyle'] = 0xF734;
  16220. t['fourparen'] = 0x2477;
  16221. t['fourperiod'] = 0x248B;
  16222. t['fourpersian'] = 0x06F4;
  16223. t['fourroman'] = 0x2173;
  16224. t['foursuperior'] = 0x2074;
  16225. t['fourteencircle'] = 0x246D;
  16226. t['fourteenparen'] = 0x2481;
  16227. t['fourteenperiod'] = 0x2495;
  16228. t['fourthai'] = 0x0E54;
  16229. t['fourthtonechinese'] = 0x02CB;
  16230. t['fparen'] = 0x24A1;
  16231. t['fraction'] = 0x2044;
  16232. t['franc'] = 0x20A3;
  16233. t['g'] = 0x0067;
  16234. t['gabengali'] = 0x0997;
  16235. t['gacute'] = 0x01F5;
  16236. t['gadeva'] = 0x0917;
  16237. t['gafarabic'] = 0x06AF;
  16238. t['gaffinalarabic'] = 0xFB93;
  16239. t['gafinitialarabic'] = 0xFB94;
  16240. t['gafmedialarabic'] = 0xFB95;
  16241. t['gagujarati'] = 0x0A97;
  16242. t['gagurmukhi'] = 0x0A17;
  16243. t['gahiragana'] = 0x304C;
  16244. t['gakatakana'] = 0x30AC;
  16245. t['gamma'] = 0x03B3;
  16246. t['gammalatinsmall'] = 0x0263;
  16247. t['gammasuperior'] = 0x02E0;
  16248. t['gangiacoptic'] = 0x03EB;
  16249. t['gbopomofo'] = 0x310D;
  16250. t['gbreve'] = 0x011F;
  16251. t['gcaron'] = 0x01E7;
  16252. t['gcedilla'] = 0x0123;
  16253. t['gcircle'] = 0x24D6;
  16254. t['gcircumflex'] = 0x011D;
  16255. t['gcommaaccent'] = 0x0123;
  16256. t['gdot'] = 0x0121;
  16257. t['gdotaccent'] = 0x0121;
  16258. t['gecyrillic'] = 0x0433;
  16259. t['gehiragana'] = 0x3052;
  16260. t['gekatakana'] = 0x30B2;
  16261. t['geometricallyequal'] = 0x2251;
  16262. t['gereshaccenthebrew'] = 0x059C;
  16263. t['gereshhebrew'] = 0x05F3;
  16264. t['gereshmuqdamhebrew'] = 0x059D;
  16265. t['germandbls'] = 0x00DF;
  16266. t['gershayimaccenthebrew'] = 0x059E;
  16267. t['gershayimhebrew'] = 0x05F4;
  16268. t['getamark'] = 0x3013;
  16269. t['ghabengali'] = 0x0998;
  16270. t['ghadarmenian'] = 0x0572;
  16271. t['ghadeva'] = 0x0918;
  16272. t['ghagujarati'] = 0x0A98;
  16273. t['ghagurmukhi'] = 0x0A18;
  16274. t['ghainarabic'] = 0x063A;
  16275. t['ghainfinalarabic'] = 0xFECE;
  16276. t['ghaininitialarabic'] = 0xFECF;
  16277. t['ghainmedialarabic'] = 0xFED0;
  16278. t['ghemiddlehookcyrillic'] = 0x0495;
  16279. t['ghestrokecyrillic'] = 0x0493;
  16280. t['gheupturncyrillic'] = 0x0491;
  16281. t['ghhadeva'] = 0x095A;
  16282. t['ghhagurmukhi'] = 0x0A5A;
  16283. t['ghook'] = 0x0260;
  16284. t['ghzsquare'] = 0x3393;
  16285. t['gihiragana'] = 0x304E;
  16286. t['gikatakana'] = 0x30AE;
  16287. t['gimarmenian'] = 0x0563;
  16288. t['gimel'] = 0x05D2;
  16289. t['gimeldagesh'] = 0xFB32;
  16290. t['gimeldageshhebrew'] = 0xFB32;
  16291. t['gimelhebrew'] = 0x05D2;
  16292. t['gjecyrillic'] = 0x0453;
  16293. t['glottalinvertedstroke'] = 0x01BE;
  16294. t['glottalstop'] = 0x0294;
  16295. t['glottalstopinverted'] = 0x0296;
  16296. t['glottalstopmod'] = 0x02C0;
  16297. t['glottalstopreversed'] = 0x0295;
  16298. t['glottalstopreversedmod'] = 0x02C1;
  16299. t['glottalstopreversedsuperior'] = 0x02E4;
  16300. t['glottalstopstroke'] = 0x02A1;
  16301. t['glottalstopstrokereversed'] = 0x02A2;
  16302. t['gmacron'] = 0x1E21;
  16303. t['gmonospace'] = 0xFF47;
  16304. t['gohiragana'] = 0x3054;
  16305. t['gokatakana'] = 0x30B4;
  16306. t['gparen'] = 0x24A2;
  16307. t['gpasquare'] = 0x33AC;
  16308. t['gradient'] = 0x2207;
  16309. t['grave'] = 0x0060;
  16310. t['gravebelowcmb'] = 0x0316;
  16311. t['gravecmb'] = 0x0300;
  16312. t['gravecomb'] = 0x0300;
  16313. t['gravedeva'] = 0x0953;
  16314. t['gravelowmod'] = 0x02CE;
  16315. t['gravemonospace'] = 0xFF40;
  16316. t['gravetonecmb'] = 0x0340;
  16317. t['greater'] = 0x003E;
  16318. t['greaterequal'] = 0x2265;
  16319. t['greaterequalorless'] = 0x22DB;
  16320. t['greatermonospace'] = 0xFF1E;
  16321. t['greaterorequivalent'] = 0x2273;
  16322. t['greaterorless'] = 0x2277;
  16323. t['greateroverequal'] = 0x2267;
  16324. t['greatersmall'] = 0xFE65;
  16325. t['gscript'] = 0x0261;
  16326. t['gstroke'] = 0x01E5;
  16327. t['guhiragana'] = 0x3050;
  16328. t['guillemotleft'] = 0x00AB;
  16329. t['guillemotright'] = 0x00BB;
  16330. t['guilsinglleft'] = 0x2039;
  16331. t['guilsinglright'] = 0x203A;
  16332. t['gukatakana'] = 0x30B0;
  16333. t['guramusquare'] = 0x3318;
  16334. t['gysquare'] = 0x33C9;
  16335. t['h'] = 0x0068;
  16336. t['haabkhasiancyrillic'] = 0x04A9;
  16337. t['haaltonearabic'] = 0x06C1;
  16338. t['habengali'] = 0x09B9;
  16339. t['hadescendercyrillic'] = 0x04B3;
  16340. t['hadeva'] = 0x0939;
  16341. t['hagujarati'] = 0x0AB9;
  16342. t['hagurmukhi'] = 0x0A39;
  16343. t['haharabic'] = 0x062D;
  16344. t['hahfinalarabic'] = 0xFEA2;
  16345. t['hahinitialarabic'] = 0xFEA3;
  16346. t['hahiragana'] = 0x306F;
  16347. t['hahmedialarabic'] = 0xFEA4;
  16348. t['haitusquare'] = 0x332A;
  16349. t['hakatakana'] = 0x30CF;
  16350. t['hakatakanahalfwidth'] = 0xFF8A;
  16351. t['halantgurmukhi'] = 0x0A4D;
  16352. t['hamzaarabic'] = 0x0621;
  16353. t['hamzalowarabic'] = 0x0621;
  16354. t['hangulfiller'] = 0x3164;
  16355. t['hardsigncyrillic'] = 0x044A;
  16356. t['harpoonleftbarbup'] = 0x21BC;
  16357. t['harpoonrightbarbup'] = 0x21C0;
  16358. t['hasquare'] = 0x33CA;
  16359. t['hatafpatah'] = 0x05B2;
  16360. t['hatafpatah16'] = 0x05B2;
  16361. t['hatafpatah23'] = 0x05B2;
  16362. t['hatafpatah2f'] = 0x05B2;
  16363. t['hatafpatahhebrew'] = 0x05B2;
  16364. t['hatafpatahnarrowhebrew'] = 0x05B2;
  16365. t['hatafpatahquarterhebrew'] = 0x05B2;
  16366. t['hatafpatahwidehebrew'] = 0x05B2;
  16367. t['hatafqamats'] = 0x05B3;
  16368. t['hatafqamats1b'] = 0x05B3;
  16369. t['hatafqamats28'] = 0x05B3;
  16370. t['hatafqamats34'] = 0x05B3;
  16371. t['hatafqamatshebrew'] = 0x05B3;
  16372. t['hatafqamatsnarrowhebrew'] = 0x05B3;
  16373. t['hatafqamatsquarterhebrew'] = 0x05B3;
  16374. t['hatafqamatswidehebrew'] = 0x05B3;
  16375. t['hatafsegol'] = 0x05B1;
  16376. t['hatafsegol17'] = 0x05B1;
  16377. t['hatafsegol24'] = 0x05B1;
  16378. t['hatafsegol30'] = 0x05B1;
  16379. t['hatafsegolhebrew'] = 0x05B1;
  16380. t['hatafsegolnarrowhebrew'] = 0x05B1;
  16381. t['hatafsegolquarterhebrew'] = 0x05B1;
  16382. t['hatafsegolwidehebrew'] = 0x05B1;
  16383. t['hbar'] = 0x0127;
  16384. t['hbopomofo'] = 0x310F;
  16385. t['hbrevebelow'] = 0x1E2B;
  16386. t['hcedilla'] = 0x1E29;
  16387. t['hcircle'] = 0x24D7;
  16388. t['hcircumflex'] = 0x0125;
  16389. t['hdieresis'] = 0x1E27;
  16390. t['hdotaccent'] = 0x1E23;
  16391. t['hdotbelow'] = 0x1E25;
  16392. t['he'] = 0x05D4;
  16393. t['heart'] = 0x2665;
  16394. t['heartsuitblack'] = 0x2665;
  16395. t['heartsuitwhite'] = 0x2661;
  16396. t['hedagesh'] = 0xFB34;
  16397. t['hedageshhebrew'] = 0xFB34;
  16398. t['hehaltonearabic'] = 0x06C1;
  16399. t['heharabic'] = 0x0647;
  16400. t['hehebrew'] = 0x05D4;
  16401. t['hehfinalaltonearabic'] = 0xFBA7;
  16402. t['hehfinalalttwoarabic'] = 0xFEEA;
  16403. t['hehfinalarabic'] = 0xFEEA;
  16404. t['hehhamzaabovefinalarabic'] = 0xFBA5;
  16405. t['hehhamzaaboveisolatedarabic'] = 0xFBA4;
  16406. t['hehinitialaltonearabic'] = 0xFBA8;
  16407. t['hehinitialarabic'] = 0xFEEB;
  16408. t['hehiragana'] = 0x3078;
  16409. t['hehmedialaltonearabic'] = 0xFBA9;
  16410. t['hehmedialarabic'] = 0xFEEC;
  16411. t['heiseierasquare'] = 0x337B;
  16412. t['hekatakana'] = 0x30D8;
  16413. t['hekatakanahalfwidth'] = 0xFF8D;
  16414. t['hekutaarusquare'] = 0x3336;
  16415. t['henghook'] = 0x0267;
  16416. t['herutusquare'] = 0x3339;
  16417. t['het'] = 0x05D7;
  16418. t['hethebrew'] = 0x05D7;
  16419. t['hhook'] = 0x0266;
  16420. t['hhooksuperior'] = 0x02B1;
  16421. t['hieuhacirclekorean'] = 0x327B;
  16422. t['hieuhaparenkorean'] = 0x321B;
  16423. t['hieuhcirclekorean'] = 0x326D;
  16424. t['hieuhkorean'] = 0x314E;
  16425. t['hieuhparenkorean'] = 0x320D;
  16426. t['hihiragana'] = 0x3072;
  16427. t['hikatakana'] = 0x30D2;
  16428. t['hikatakanahalfwidth'] = 0xFF8B;
  16429. t['hiriq'] = 0x05B4;
  16430. t['hiriq14'] = 0x05B4;
  16431. t['hiriq21'] = 0x05B4;
  16432. t['hiriq2d'] = 0x05B4;
  16433. t['hiriqhebrew'] = 0x05B4;
  16434. t['hiriqnarrowhebrew'] = 0x05B4;
  16435. t['hiriqquarterhebrew'] = 0x05B4;
  16436. t['hiriqwidehebrew'] = 0x05B4;
  16437. t['hlinebelow'] = 0x1E96;
  16438. t['hmonospace'] = 0xFF48;
  16439. t['hoarmenian'] = 0x0570;
  16440. t['hohipthai'] = 0x0E2B;
  16441. t['hohiragana'] = 0x307B;
  16442. t['hokatakana'] = 0x30DB;
  16443. t['hokatakanahalfwidth'] = 0xFF8E;
  16444. t['holam'] = 0x05B9;
  16445. t['holam19'] = 0x05B9;
  16446. t['holam26'] = 0x05B9;
  16447. t['holam32'] = 0x05B9;
  16448. t['holamhebrew'] = 0x05B9;
  16449. t['holamnarrowhebrew'] = 0x05B9;
  16450. t['holamquarterhebrew'] = 0x05B9;
  16451. t['holamwidehebrew'] = 0x05B9;
  16452. t['honokhukthai'] = 0x0E2E;
  16453. t['hookabovecomb'] = 0x0309;
  16454. t['hookcmb'] = 0x0309;
  16455. t['hookpalatalizedbelowcmb'] = 0x0321;
  16456. t['hookretroflexbelowcmb'] = 0x0322;
  16457. t['hoonsquare'] = 0x3342;
  16458. t['horicoptic'] = 0x03E9;
  16459. t['horizontalbar'] = 0x2015;
  16460. t['horncmb'] = 0x031B;
  16461. t['hotsprings'] = 0x2668;
  16462. t['house'] = 0x2302;
  16463. t['hparen'] = 0x24A3;
  16464. t['hsuperior'] = 0x02B0;
  16465. t['hturned'] = 0x0265;
  16466. t['huhiragana'] = 0x3075;
  16467. t['huiitosquare'] = 0x3333;
  16468. t['hukatakana'] = 0x30D5;
  16469. t['hukatakanahalfwidth'] = 0xFF8C;
  16470. t['hungarumlaut'] = 0x02DD;
  16471. t['hungarumlautcmb'] = 0x030B;
  16472. t['hv'] = 0x0195;
  16473. t['hyphen'] = 0x002D;
  16474. t['hypheninferior'] = 0xF6E5;
  16475. t['hyphenmonospace'] = 0xFF0D;
  16476. t['hyphensmall'] = 0xFE63;
  16477. t['hyphensuperior'] = 0xF6E6;
  16478. t['hyphentwo'] = 0x2010;
  16479. t['i'] = 0x0069;
  16480. t['iacute'] = 0x00ED;
  16481. t['iacyrillic'] = 0x044F;
  16482. t['ibengali'] = 0x0987;
  16483. t['ibopomofo'] = 0x3127;
  16484. t['ibreve'] = 0x012D;
  16485. t['icaron'] = 0x01D0;
  16486. t['icircle'] = 0x24D8;
  16487. t['icircumflex'] = 0x00EE;
  16488. t['icyrillic'] = 0x0456;
  16489. t['idblgrave'] = 0x0209;
  16490. t['ideographearthcircle'] = 0x328F;
  16491. t['ideographfirecircle'] = 0x328B;
  16492. t['ideographicallianceparen'] = 0x323F;
  16493. t['ideographiccallparen'] = 0x323A;
  16494. t['ideographiccentrecircle'] = 0x32A5;
  16495. t['ideographicclose'] = 0x3006;
  16496. t['ideographiccomma'] = 0x3001;
  16497. t['ideographiccommaleft'] = 0xFF64;
  16498. t['ideographiccongratulationparen'] = 0x3237;
  16499. t['ideographiccorrectcircle'] = 0x32A3;
  16500. t['ideographicearthparen'] = 0x322F;
  16501. t['ideographicenterpriseparen'] = 0x323D;
  16502. t['ideographicexcellentcircle'] = 0x329D;
  16503. t['ideographicfestivalparen'] = 0x3240;
  16504. t['ideographicfinancialcircle'] = 0x3296;
  16505. t['ideographicfinancialparen'] = 0x3236;
  16506. t['ideographicfireparen'] = 0x322B;
  16507. t['ideographichaveparen'] = 0x3232;
  16508. t['ideographichighcircle'] = 0x32A4;
  16509. t['ideographiciterationmark'] = 0x3005;
  16510. t['ideographiclaborcircle'] = 0x3298;
  16511. t['ideographiclaborparen'] = 0x3238;
  16512. t['ideographicleftcircle'] = 0x32A7;
  16513. t['ideographiclowcircle'] = 0x32A6;
  16514. t['ideographicmedicinecircle'] = 0x32A9;
  16515. t['ideographicmetalparen'] = 0x322E;
  16516. t['ideographicmoonparen'] = 0x322A;
  16517. t['ideographicnameparen'] = 0x3234;
  16518. t['ideographicperiod'] = 0x3002;
  16519. t['ideographicprintcircle'] = 0x329E;
  16520. t['ideographicreachparen'] = 0x3243;
  16521. t['ideographicrepresentparen'] = 0x3239;
  16522. t['ideographicresourceparen'] = 0x323E;
  16523. t['ideographicrightcircle'] = 0x32A8;
  16524. t['ideographicsecretcircle'] = 0x3299;
  16525. t['ideographicselfparen'] = 0x3242;
  16526. t['ideographicsocietyparen'] = 0x3233;
  16527. t['ideographicspace'] = 0x3000;
  16528. t['ideographicspecialparen'] = 0x3235;
  16529. t['ideographicstockparen'] = 0x3231;
  16530. t['ideographicstudyparen'] = 0x323B;
  16531. t['ideographicsunparen'] = 0x3230;
  16532. t['ideographicsuperviseparen'] = 0x323C;
  16533. t['ideographicwaterparen'] = 0x322C;
  16534. t['ideographicwoodparen'] = 0x322D;
  16535. t['ideographiczero'] = 0x3007;
  16536. t['ideographmetalcircle'] = 0x328E;
  16537. t['ideographmooncircle'] = 0x328A;
  16538. t['ideographnamecircle'] = 0x3294;
  16539. t['ideographsuncircle'] = 0x3290;
  16540. t['ideographwatercircle'] = 0x328C;
  16541. t['ideographwoodcircle'] = 0x328D;
  16542. t['ideva'] = 0x0907;
  16543. t['idieresis'] = 0x00EF;
  16544. t['idieresisacute'] = 0x1E2F;
  16545. t['idieresiscyrillic'] = 0x04E5;
  16546. t['idotbelow'] = 0x1ECB;
  16547. t['iebrevecyrillic'] = 0x04D7;
  16548. t['iecyrillic'] = 0x0435;
  16549. t['ieungacirclekorean'] = 0x3275;
  16550. t['ieungaparenkorean'] = 0x3215;
  16551. t['ieungcirclekorean'] = 0x3267;
  16552. t['ieungkorean'] = 0x3147;
  16553. t['ieungparenkorean'] = 0x3207;
  16554. t['igrave'] = 0x00EC;
  16555. t['igujarati'] = 0x0A87;
  16556. t['igurmukhi'] = 0x0A07;
  16557. t['ihiragana'] = 0x3044;
  16558. t['ihookabove'] = 0x1EC9;
  16559. t['iibengali'] = 0x0988;
  16560. t['iicyrillic'] = 0x0438;
  16561. t['iideva'] = 0x0908;
  16562. t['iigujarati'] = 0x0A88;
  16563. t['iigurmukhi'] = 0x0A08;
  16564. t['iimatragurmukhi'] = 0x0A40;
  16565. t['iinvertedbreve'] = 0x020B;
  16566. t['iishortcyrillic'] = 0x0439;
  16567. t['iivowelsignbengali'] = 0x09C0;
  16568. t['iivowelsigndeva'] = 0x0940;
  16569. t['iivowelsigngujarati'] = 0x0AC0;
  16570. t['ij'] = 0x0133;
  16571. t['ikatakana'] = 0x30A4;
  16572. t['ikatakanahalfwidth'] = 0xFF72;
  16573. t['ikorean'] = 0x3163;
  16574. t['ilde'] = 0x02DC;
  16575. t['iluyhebrew'] = 0x05AC;
  16576. t['imacron'] = 0x012B;
  16577. t['imacroncyrillic'] = 0x04E3;
  16578. t['imageorapproximatelyequal'] = 0x2253;
  16579. t['imatragurmukhi'] = 0x0A3F;
  16580. t['imonospace'] = 0xFF49;
  16581. t['increment'] = 0x2206;
  16582. t['infinity'] = 0x221E;
  16583. t['iniarmenian'] = 0x056B;
  16584. t['integral'] = 0x222B;
  16585. t['integralbottom'] = 0x2321;
  16586. t['integralbt'] = 0x2321;
  16587. t['integralex'] = 0xF8F5;
  16588. t['integraltop'] = 0x2320;
  16589. t['integraltp'] = 0x2320;
  16590. t['intersection'] = 0x2229;
  16591. t['intisquare'] = 0x3305;
  16592. t['invbullet'] = 0x25D8;
  16593. t['invcircle'] = 0x25D9;
  16594. t['invsmileface'] = 0x263B;
  16595. t['iocyrillic'] = 0x0451;
  16596. t['iogonek'] = 0x012F;
  16597. t['iota'] = 0x03B9;
  16598. t['iotadieresis'] = 0x03CA;
  16599. t['iotadieresistonos'] = 0x0390;
  16600. t['iotalatin'] = 0x0269;
  16601. t['iotatonos'] = 0x03AF;
  16602. t['iparen'] = 0x24A4;
  16603. t['irigurmukhi'] = 0x0A72;
  16604. t['ismallhiragana'] = 0x3043;
  16605. t['ismallkatakana'] = 0x30A3;
  16606. t['ismallkatakanahalfwidth'] = 0xFF68;
  16607. t['issharbengali'] = 0x09FA;
  16608. t['istroke'] = 0x0268;
  16609. t['isuperior'] = 0xF6ED;
  16610. t['iterationhiragana'] = 0x309D;
  16611. t['iterationkatakana'] = 0x30FD;
  16612. t['itilde'] = 0x0129;
  16613. t['itildebelow'] = 0x1E2D;
  16614. t['iubopomofo'] = 0x3129;
  16615. t['iucyrillic'] = 0x044E;
  16616. t['ivowelsignbengali'] = 0x09BF;
  16617. t['ivowelsigndeva'] = 0x093F;
  16618. t['ivowelsigngujarati'] = 0x0ABF;
  16619. t['izhitsacyrillic'] = 0x0475;
  16620. t['izhitsadblgravecyrillic'] = 0x0477;
  16621. t['j'] = 0x006A;
  16622. t['jaarmenian'] = 0x0571;
  16623. t['jabengali'] = 0x099C;
  16624. t['jadeva'] = 0x091C;
  16625. t['jagujarati'] = 0x0A9C;
  16626. t['jagurmukhi'] = 0x0A1C;
  16627. t['jbopomofo'] = 0x3110;
  16628. t['jcaron'] = 0x01F0;
  16629. t['jcircle'] = 0x24D9;
  16630. t['jcircumflex'] = 0x0135;
  16631. t['jcrossedtail'] = 0x029D;
  16632. t['jdotlessstroke'] = 0x025F;
  16633. t['jecyrillic'] = 0x0458;
  16634. t['jeemarabic'] = 0x062C;
  16635. t['jeemfinalarabic'] = 0xFE9E;
  16636. t['jeeminitialarabic'] = 0xFE9F;
  16637. t['jeemmedialarabic'] = 0xFEA0;
  16638. t['jeharabic'] = 0x0698;
  16639. t['jehfinalarabic'] = 0xFB8B;
  16640. t['jhabengali'] = 0x099D;
  16641. t['jhadeva'] = 0x091D;
  16642. t['jhagujarati'] = 0x0A9D;
  16643. t['jhagurmukhi'] = 0x0A1D;
  16644. t['jheharmenian'] = 0x057B;
  16645. t['jis'] = 0x3004;
  16646. t['jmonospace'] = 0xFF4A;
  16647. t['jparen'] = 0x24A5;
  16648. t['jsuperior'] = 0x02B2;
  16649. t['k'] = 0x006B;
  16650. t['kabashkircyrillic'] = 0x04A1;
  16651. t['kabengali'] = 0x0995;
  16652. t['kacute'] = 0x1E31;
  16653. t['kacyrillic'] = 0x043A;
  16654. t['kadescendercyrillic'] = 0x049B;
  16655. t['kadeva'] = 0x0915;
  16656. t['kaf'] = 0x05DB;
  16657. t['kafarabic'] = 0x0643;
  16658. t['kafdagesh'] = 0xFB3B;
  16659. t['kafdageshhebrew'] = 0xFB3B;
  16660. t['kaffinalarabic'] = 0xFEDA;
  16661. t['kafhebrew'] = 0x05DB;
  16662. t['kafinitialarabic'] = 0xFEDB;
  16663. t['kafmedialarabic'] = 0xFEDC;
  16664. t['kafrafehebrew'] = 0xFB4D;
  16665. t['kagujarati'] = 0x0A95;
  16666. t['kagurmukhi'] = 0x0A15;
  16667. t['kahiragana'] = 0x304B;
  16668. t['kahookcyrillic'] = 0x04C4;
  16669. t['kakatakana'] = 0x30AB;
  16670. t['kakatakanahalfwidth'] = 0xFF76;
  16671. t['kappa'] = 0x03BA;
  16672. t['kappasymbolgreek'] = 0x03F0;
  16673. t['kapyeounmieumkorean'] = 0x3171;
  16674. t['kapyeounphieuphkorean'] = 0x3184;
  16675. t['kapyeounpieupkorean'] = 0x3178;
  16676. t['kapyeounssangpieupkorean'] = 0x3179;
  16677. t['karoriisquare'] = 0x330D;
  16678. t['kashidaautoarabic'] = 0x0640;
  16679. t['kashidaautonosidebearingarabic'] = 0x0640;
  16680. t['kasmallkatakana'] = 0x30F5;
  16681. t['kasquare'] = 0x3384;
  16682. t['kasraarabic'] = 0x0650;
  16683. t['kasratanarabic'] = 0x064D;
  16684. t['kastrokecyrillic'] = 0x049F;
  16685. t['katahiraprolongmarkhalfwidth'] = 0xFF70;
  16686. t['kaverticalstrokecyrillic'] = 0x049D;
  16687. t['kbopomofo'] = 0x310E;
  16688. t['kcalsquare'] = 0x3389;
  16689. t['kcaron'] = 0x01E9;
  16690. t['kcedilla'] = 0x0137;
  16691. t['kcircle'] = 0x24DA;
  16692. t['kcommaaccent'] = 0x0137;
  16693. t['kdotbelow'] = 0x1E33;
  16694. t['keharmenian'] = 0x0584;
  16695. t['kehiragana'] = 0x3051;
  16696. t['kekatakana'] = 0x30B1;
  16697. t['kekatakanahalfwidth'] = 0xFF79;
  16698. t['kenarmenian'] = 0x056F;
  16699. t['kesmallkatakana'] = 0x30F6;
  16700. t['kgreenlandic'] = 0x0138;
  16701. t['khabengali'] = 0x0996;
  16702. t['khacyrillic'] = 0x0445;
  16703. t['khadeva'] = 0x0916;
  16704. t['khagujarati'] = 0x0A96;
  16705. t['khagurmukhi'] = 0x0A16;
  16706. t['khaharabic'] = 0x062E;
  16707. t['khahfinalarabic'] = 0xFEA6;
  16708. t['khahinitialarabic'] = 0xFEA7;
  16709. t['khahmedialarabic'] = 0xFEA8;
  16710. t['kheicoptic'] = 0x03E7;
  16711. t['khhadeva'] = 0x0959;
  16712. t['khhagurmukhi'] = 0x0A59;
  16713. t['khieukhacirclekorean'] = 0x3278;
  16714. t['khieukhaparenkorean'] = 0x3218;
  16715. t['khieukhcirclekorean'] = 0x326A;
  16716. t['khieukhkorean'] = 0x314B;
  16717. t['khieukhparenkorean'] = 0x320A;
  16718. t['khokhaithai'] = 0x0E02;
  16719. t['khokhonthai'] = 0x0E05;
  16720. t['khokhuatthai'] = 0x0E03;
  16721. t['khokhwaithai'] = 0x0E04;
  16722. t['khomutthai'] = 0x0E5B;
  16723. t['khook'] = 0x0199;
  16724. t['khorakhangthai'] = 0x0E06;
  16725. t['khzsquare'] = 0x3391;
  16726. t['kihiragana'] = 0x304D;
  16727. t['kikatakana'] = 0x30AD;
  16728. t['kikatakanahalfwidth'] = 0xFF77;
  16729. t['kiroguramusquare'] = 0x3315;
  16730. t['kiromeetorusquare'] = 0x3316;
  16731. t['kirosquare'] = 0x3314;
  16732. t['kiyeokacirclekorean'] = 0x326E;
  16733. t['kiyeokaparenkorean'] = 0x320E;
  16734. t['kiyeokcirclekorean'] = 0x3260;
  16735. t['kiyeokkorean'] = 0x3131;
  16736. t['kiyeokparenkorean'] = 0x3200;
  16737. t['kiyeoksioskorean'] = 0x3133;
  16738. t['kjecyrillic'] = 0x045C;
  16739. t['klinebelow'] = 0x1E35;
  16740. t['klsquare'] = 0x3398;
  16741. t['kmcubedsquare'] = 0x33A6;
  16742. t['kmonospace'] = 0xFF4B;
  16743. t['kmsquaredsquare'] = 0x33A2;
  16744. t['kohiragana'] = 0x3053;
  16745. t['kohmsquare'] = 0x33C0;
  16746. t['kokaithai'] = 0x0E01;
  16747. t['kokatakana'] = 0x30B3;
  16748. t['kokatakanahalfwidth'] = 0xFF7A;
  16749. t['kooposquare'] = 0x331E;
  16750. t['koppacyrillic'] = 0x0481;
  16751. t['koreanstandardsymbol'] = 0x327F;
  16752. t['koroniscmb'] = 0x0343;
  16753. t['kparen'] = 0x24A6;
  16754. t['kpasquare'] = 0x33AA;
  16755. t['ksicyrillic'] = 0x046F;
  16756. t['ktsquare'] = 0x33CF;
  16757. t['kturned'] = 0x029E;
  16758. t['kuhiragana'] = 0x304F;
  16759. t['kukatakana'] = 0x30AF;
  16760. t['kukatakanahalfwidth'] = 0xFF78;
  16761. t['kvsquare'] = 0x33B8;
  16762. t['kwsquare'] = 0x33BE;
  16763. t['l'] = 0x006C;
  16764. t['labengali'] = 0x09B2;
  16765. t['lacute'] = 0x013A;
  16766. t['ladeva'] = 0x0932;
  16767. t['lagujarati'] = 0x0AB2;
  16768. t['lagurmukhi'] = 0x0A32;
  16769. t['lakkhangyaothai'] = 0x0E45;
  16770. t['lamaleffinalarabic'] = 0xFEFC;
  16771. t['lamalefhamzaabovefinalarabic'] = 0xFEF8;
  16772. t['lamalefhamzaaboveisolatedarabic'] = 0xFEF7;
  16773. t['lamalefhamzabelowfinalarabic'] = 0xFEFA;
  16774. t['lamalefhamzabelowisolatedarabic'] = 0xFEF9;
  16775. t['lamalefisolatedarabic'] = 0xFEFB;
  16776. t['lamalefmaddaabovefinalarabic'] = 0xFEF6;
  16777. t['lamalefmaddaaboveisolatedarabic'] = 0xFEF5;
  16778. t['lamarabic'] = 0x0644;
  16779. t['lambda'] = 0x03BB;
  16780. t['lambdastroke'] = 0x019B;
  16781. t['lamed'] = 0x05DC;
  16782. t['lameddagesh'] = 0xFB3C;
  16783. t['lameddageshhebrew'] = 0xFB3C;
  16784. t['lamedhebrew'] = 0x05DC;
  16785. t['lamfinalarabic'] = 0xFEDE;
  16786. t['lamhahinitialarabic'] = 0xFCCA;
  16787. t['laminitialarabic'] = 0xFEDF;
  16788. t['lamjeeminitialarabic'] = 0xFCC9;
  16789. t['lamkhahinitialarabic'] = 0xFCCB;
  16790. t['lamlamhehisolatedarabic'] = 0xFDF2;
  16791. t['lammedialarabic'] = 0xFEE0;
  16792. t['lammeemhahinitialarabic'] = 0xFD88;
  16793. t['lammeeminitialarabic'] = 0xFCCC;
  16794. t['largecircle'] = 0x25EF;
  16795. t['lbar'] = 0x019A;
  16796. t['lbelt'] = 0x026C;
  16797. t['lbopomofo'] = 0x310C;
  16798. t['lcaron'] = 0x013E;
  16799. t['lcedilla'] = 0x013C;
  16800. t['lcircle'] = 0x24DB;
  16801. t['lcircumflexbelow'] = 0x1E3D;
  16802. t['lcommaaccent'] = 0x013C;
  16803. t['ldot'] = 0x0140;
  16804. t['ldotaccent'] = 0x0140;
  16805. t['ldotbelow'] = 0x1E37;
  16806. t['ldotbelowmacron'] = 0x1E39;
  16807. t['leftangleabovecmb'] = 0x031A;
  16808. t['lefttackbelowcmb'] = 0x0318;
  16809. t['less'] = 0x003C;
  16810. t['lessequal'] = 0x2264;
  16811. t['lessequalorgreater'] = 0x22DA;
  16812. t['lessmonospace'] = 0xFF1C;
  16813. t['lessorequivalent'] = 0x2272;
  16814. t['lessorgreater'] = 0x2276;
  16815. t['lessoverequal'] = 0x2266;
  16816. t['lesssmall'] = 0xFE64;
  16817. t['lezh'] = 0x026E;
  16818. t['lfblock'] = 0x258C;
  16819. t['lhookretroflex'] = 0x026D;
  16820. t['lira'] = 0x20A4;
  16821. t['liwnarmenian'] = 0x056C;
  16822. t['lj'] = 0x01C9;
  16823. t['ljecyrillic'] = 0x0459;
  16824. t['ll'] = 0xF6C0;
  16825. t['lladeva'] = 0x0933;
  16826. t['llagujarati'] = 0x0AB3;
  16827. t['llinebelow'] = 0x1E3B;
  16828. t['llladeva'] = 0x0934;
  16829. t['llvocalicbengali'] = 0x09E1;
  16830. t['llvocalicdeva'] = 0x0961;
  16831. t['llvocalicvowelsignbengali'] = 0x09E3;
  16832. t['llvocalicvowelsigndeva'] = 0x0963;
  16833. t['lmiddletilde'] = 0x026B;
  16834. t['lmonospace'] = 0xFF4C;
  16835. t['lmsquare'] = 0x33D0;
  16836. t['lochulathai'] = 0x0E2C;
  16837. t['logicaland'] = 0x2227;
  16838. t['logicalnot'] = 0x00AC;
  16839. t['logicalnotreversed'] = 0x2310;
  16840. t['logicalor'] = 0x2228;
  16841. t['lolingthai'] = 0x0E25;
  16842. t['longs'] = 0x017F;
  16843. t['lowlinecenterline'] = 0xFE4E;
  16844. t['lowlinecmb'] = 0x0332;
  16845. t['lowlinedashed'] = 0xFE4D;
  16846. t['lozenge'] = 0x25CA;
  16847. t['lparen'] = 0x24A7;
  16848. t['lslash'] = 0x0142;
  16849. t['lsquare'] = 0x2113;
  16850. t['lsuperior'] = 0xF6EE;
  16851. t['ltshade'] = 0x2591;
  16852. t['luthai'] = 0x0E26;
  16853. t['lvocalicbengali'] = 0x098C;
  16854. t['lvocalicdeva'] = 0x090C;
  16855. t['lvocalicvowelsignbengali'] = 0x09E2;
  16856. t['lvocalicvowelsigndeva'] = 0x0962;
  16857. t['lxsquare'] = 0x33D3;
  16858. t['m'] = 0x006D;
  16859. t['mabengali'] = 0x09AE;
  16860. t['macron'] = 0x00AF;
  16861. t['macronbelowcmb'] = 0x0331;
  16862. t['macroncmb'] = 0x0304;
  16863. t['macronlowmod'] = 0x02CD;
  16864. t['macronmonospace'] = 0xFFE3;
  16865. t['macute'] = 0x1E3F;
  16866. t['madeva'] = 0x092E;
  16867. t['magujarati'] = 0x0AAE;
  16868. t['magurmukhi'] = 0x0A2E;
  16869. t['mahapakhhebrew'] = 0x05A4;
  16870. t['mahapakhlefthebrew'] = 0x05A4;
  16871. t['mahiragana'] = 0x307E;
  16872. t['maichattawalowleftthai'] = 0xF895;
  16873. t['maichattawalowrightthai'] = 0xF894;
  16874. t['maichattawathai'] = 0x0E4B;
  16875. t['maichattawaupperleftthai'] = 0xF893;
  16876. t['maieklowleftthai'] = 0xF88C;
  16877. t['maieklowrightthai'] = 0xF88B;
  16878. t['maiekthai'] = 0x0E48;
  16879. t['maiekupperleftthai'] = 0xF88A;
  16880. t['maihanakatleftthai'] = 0xF884;
  16881. t['maihanakatthai'] = 0x0E31;
  16882. t['maitaikhuleftthai'] = 0xF889;
  16883. t['maitaikhuthai'] = 0x0E47;
  16884. t['maitholowleftthai'] = 0xF88F;
  16885. t['maitholowrightthai'] = 0xF88E;
  16886. t['maithothai'] = 0x0E49;
  16887. t['maithoupperleftthai'] = 0xF88D;
  16888. t['maitrilowleftthai'] = 0xF892;
  16889. t['maitrilowrightthai'] = 0xF891;
  16890. t['maitrithai'] = 0x0E4A;
  16891. t['maitriupperleftthai'] = 0xF890;
  16892. t['maiyamokthai'] = 0x0E46;
  16893. t['makatakana'] = 0x30DE;
  16894. t['makatakanahalfwidth'] = 0xFF8F;
  16895. t['male'] = 0x2642;
  16896. t['mansyonsquare'] = 0x3347;
  16897. t['maqafhebrew'] = 0x05BE;
  16898. t['mars'] = 0x2642;
  16899. t['masoracirclehebrew'] = 0x05AF;
  16900. t['masquare'] = 0x3383;
  16901. t['mbopomofo'] = 0x3107;
  16902. t['mbsquare'] = 0x33D4;
  16903. t['mcircle'] = 0x24DC;
  16904. t['mcubedsquare'] = 0x33A5;
  16905. t['mdotaccent'] = 0x1E41;
  16906. t['mdotbelow'] = 0x1E43;
  16907. t['meemarabic'] = 0x0645;
  16908. t['meemfinalarabic'] = 0xFEE2;
  16909. t['meeminitialarabic'] = 0xFEE3;
  16910. t['meemmedialarabic'] = 0xFEE4;
  16911. t['meemmeeminitialarabic'] = 0xFCD1;
  16912. t['meemmeemisolatedarabic'] = 0xFC48;
  16913. t['meetorusquare'] = 0x334D;
  16914. t['mehiragana'] = 0x3081;
  16915. t['meizierasquare'] = 0x337E;
  16916. t['mekatakana'] = 0x30E1;
  16917. t['mekatakanahalfwidth'] = 0xFF92;
  16918. t['mem'] = 0x05DE;
  16919. t['memdagesh'] = 0xFB3E;
  16920. t['memdageshhebrew'] = 0xFB3E;
  16921. t['memhebrew'] = 0x05DE;
  16922. t['menarmenian'] = 0x0574;
  16923. t['merkhahebrew'] = 0x05A5;
  16924. t['merkhakefulahebrew'] = 0x05A6;
  16925. t['merkhakefulalefthebrew'] = 0x05A6;
  16926. t['merkhalefthebrew'] = 0x05A5;
  16927. t['mhook'] = 0x0271;
  16928. t['mhzsquare'] = 0x3392;
  16929. t['middledotkatakanahalfwidth'] = 0xFF65;
  16930. t['middot'] = 0x00B7;
  16931. t['mieumacirclekorean'] = 0x3272;
  16932. t['mieumaparenkorean'] = 0x3212;
  16933. t['mieumcirclekorean'] = 0x3264;
  16934. t['mieumkorean'] = 0x3141;
  16935. t['mieumpansioskorean'] = 0x3170;
  16936. t['mieumparenkorean'] = 0x3204;
  16937. t['mieumpieupkorean'] = 0x316E;
  16938. t['mieumsioskorean'] = 0x316F;
  16939. t['mihiragana'] = 0x307F;
  16940. t['mikatakana'] = 0x30DF;
  16941. t['mikatakanahalfwidth'] = 0xFF90;
  16942. t['minus'] = 0x2212;
  16943. t['minusbelowcmb'] = 0x0320;
  16944. t['minuscircle'] = 0x2296;
  16945. t['minusmod'] = 0x02D7;
  16946. t['minusplus'] = 0x2213;
  16947. t['minute'] = 0x2032;
  16948. t['miribaarusquare'] = 0x334A;
  16949. t['mirisquare'] = 0x3349;
  16950. t['mlonglegturned'] = 0x0270;
  16951. t['mlsquare'] = 0x3396;
  16952. t['mmcubedsquare'] = 0x33A3;
  16953. t['mmonospace'] = 0xFF4D;
  16954. t['mmsquaredsquare'] = 0x339F;
  16955. t['mohiragana'] = 0x3082;
  16956. t['mohmsquare'] = 0x33C1;
  16957. t['mokatakana'] = 0x30E2;
  16958. t['mokatakanahalfwidth'] = 0xFF93;
  16959. t['molsquare'] = 0x33D6;
  16960. t['momathai'] = 0x0E21;
  16961. t['moverssquare'] = 0x33A7;
  16962. t['moverssquaredsquare'] = 0x33A8;
  16963. t['mparen'] = 0x24A8;
  16964. t['mpasquare'] = 0x33AB;
  16965. t['mssquare'] = 0x33B3;
  16966. t['msuperior'] = 0xF6EF;
  16967. t['mturned'] = 0x026F;
  16968. t['mu'] = 0x00B5;
  16969. t['mu1'] = 0x00B5;
  16970. t['muasquare'] = 0x3382;
  16971. t['muchgreater'] = 0x226B;
  16972. t['muchless'] = 0x226A;
  16973. t['mufsquare'] = 0x338C;
  16974. t['mugreek'] = 0x03BC;
  16975. t['mugsquare'] = 0x338D;
  16976. t['muhiragana'] = 0x3080;
  16977. t['mukatakana'] = 0x30E0;
  16978. t['mukatakanahalfwidth'] = 0xFF91;
  16979. t['mulsquare'] = 0x3395;
  16980. t['multiply'] = 0x00D7;
  16981. t['mumsquare'] = 0x339B;
  16982. t['munahhebrew'] = 0x05A3;
  16983. t['munahlefthebrew'] = 0x05A3;
  16984. t['musicalnote'] = 0x266A;
  16985. t['musicalnotedbl'] = 0x266B;
  16986. t['musicflatsign'] = 0x266D;
  16987. t['musicsharpsign'] = 0x266F;
  16988. t['mussquare'] = 0x33B2;
  16989. t['muvsquare'] = 0x33B6;
  16990. t['muwsquare'] = 0x33BC;
  16991. t['mvmegasquare'] = 0x33B9;
  16992. t['mvsquare'] = 0x33B7;
  16993. t['mwmegasquare'] = 0x33BF;
  16994. t['mwsquare'] = 0x33BD;
  16995. t['n'] = 0x006E;
  16996. t['nabengali'] = 0x09A8;
  16997. t['nabla'] = 0x2207;
  16998. t['nacute'] = 0x0144;
  16999. t['nadeva'] = 0x0928;
  17000. t['nagujarati'] = 0x0AA8;
  17001. t['nagurmukhi'] = 0x0A28;
  17002. t['nahiragana'] = 0x306A;
  17003. t['nakatakana'] = 0x30CA;
  17004. t['nakatakanahalfwidth'] = 0xFF85;
  17005. t['napostrophe'] = 0x0149;
  17006. t['nasquare'] = 0x3381;
  17007. t['nbopomofo'] = 0x310B;
  17008. t['nbspace'] = 0x00A0;
  17009. t['ncaron'] = 0x0148;
  17010. t['ncedilla'] = 0x0146;
  17011. t['ncircle'] = 0x24DD;
  17012. t['ncircumflexbelow'] = 0x1E4B;
  17013. t['ncommaaccent'] = 0x0146;
  17014. t['ndotaccent'] = 0x1E45;
  17015. t['ndotbelow'] = 0x1E47;
  17016. t['nehiragana'] = 0x306D;
  17017. t['nekatakana'] = 0x30CD;
  17018. t['nekatakanahalfwidth'] = 0xFF88;
  17019. t['newsheqelsign'] = 0x20AA;
  17020. t['nfsquare'] = 0x338B;
  17021. t['ngabengali'] = 0x0999;
  17022. t['ngadeva'] = 0x0919;
  17023. t['ngagujarati'] = 0x0A99;
  17024. t['ngagurmukhi'] = 0x0A19;
  17025. t['ngonguthai'] = 0x0E07;
  17026. t['nhiragana'] = 0x3093;
  17027. t['nhookleft'] = 0x0272;
  17028. t['nhookretroflex'] = 0x0273;
  17029. t['nieunacirclekorean'] = 0x326F;
  17030. t['nieunaparenkorean'] = 0x320F;
  17031. t['nieuncieuckorean'] = 0x3135;
  17032. t['nieuncirclekorean'] = 0x3261;
  17033. t['nieunhieuhkorean'] = 0x3136;
  17034. t['nieunkorean'] = 0x3134;
  17035. t['nieunpansioskorean'] = 0x3168;
  17036. t['nieunparenkorean'] = 0x3201;
  17037. t['nieunsioskorean'] = 0x3167;
  17038. t['nieuntikeutkorean'] = 0x3166;
  17039. t['nihiragana'] = 0x306B;
  17040. t['nikatakana'] = 0x30CB;
  17041. t['nikatakanahalfwidth'] = 0xFF86;
  17042. t['nikhahitleftthai'] = 0xF899;
  17043. t['nikhahitthai'] = 0x0E4D;
  17044. t['nine'] = 0x0039;
  17045. t['ninearabic'] = 0x0669;
  17046. t['ninebengali'] = 0x09EF;
  17047. t['ninecircle'] = 0x2468;
  17048. t['ninecircleinversesansserif'] = 0x2792;
  17049. t['ninedeva'] = 0x096F;
  17050. t['ninegujarati'] = 0x0AEF;
  17051. t['ninegurmukhi'] = 0x0A6F;
  17052. t['ninehackarabic'] = 0x0669;
  17053. t['ninehangzhou'] = 0x3029;
  17054. t['nineideographicparen'] = 0x3228;
  17055. t['nineinferior'] = 0x2089;
  17056. t['ninemonospace'] = 0xFF19;
  17057. t['nineoldstyle'] = 0xF739;
  17058. t['nineparen'] = 0x247C;
  17059. t['nineperiod'] = 0x2490;
  17060. t['ninepersian'] = 0x06F9;
  17061. t['nineroman'] = 0x2178;
  17062. t['ninesuperior'] = 0x2079;
  17063. t['nineteencircle'] = 0x2472;
  17064. t['nineteenparen'] = 0x2486;
  17065. t['nineteenperiod'] = 0x249A;
  17066. t['ninethai'] = 0x0E59;
  17067. t['nj'] = 0x01CC;
  17068. t['njecyrillic'] = 0x045A;
  17069. t['nkatakana'] = 0x30F3;
  17070. t['nkatakanahalfwidth'] = 0xFF9D;
  17071. t['nlegrightlong'] = 0x019E;
  17072. t['nlinebelow'] = 0x1E49;
  17073. t['nmonospace'] = 0xFF4E;
  17074. t['nmsquare'] = 0x339A;
  17075. t['nnabengali'] = 0x09A3;
  17076. t['nnadeva'] = 0x0923;
  17077. t['nnagujarati'] = 0x0AA3;
  17078. t['nnagurmukhi'] = 0x0A23;
  17079. t['nnnadeva'] = 0x0929;
  17080. t['nohiragana'] = 0x306E;
  17081. t['nokatakana'] = 0x30CE;
  17082. t['nokatakanahalfwidth'] = 0xFF89;
  17083. t['nonbreakingspace'] = 0x00A0;
  17084. t['nonenthai'] = 0x0E13;
  17085. t['nonuthai'] = 0x0E19;
  17086. t['noonarabic'] = 0x0646;
  17087. t['noonfinalarabic'] = 0xFEE6;
  17088. t['noonghunnaarabic'] = 0x06BA;
  17089. t['noonghunnafinalarabic'] = 0xFB9F;
  17090. t['nooninitialarabic'] = 0xFEE7;
  17091. t['noonjeeminitialarabic'] = 0xFCD2;
  17092. t['noonjeemisolatedarabic'] = 0xFC4B;
  17093. t['noonmedialarabic'] = 0xFEE8;
  17094. t['noonmeeminitialarabic'] = 0xFCD5;
  17095. t['noonmeemisolatedarabic'] = 0xFC4E;
  17096. t['noonnoonfinalarabic'] = 0xFC8D;
  17097. t['notcontains'] = 0x220C;
  17098. t['notelement'] = 0x2209;
  17099. t['notelementof'] = 0x2209;
  17100. t['notequal'] = 0x2260;
  17101. t['notgreater'] = 0x226F;
  17102. t['notgreaternorequal'] = 0x2271;
  17103. t['notgreaternorless'] = 0x2279;
  17104. t['notidentical'] = 0x2262;
  17105. t['notless'] = 0x226E;
  17106. t['notlessnorequal'] = 0x2270;
  17107. t['notparallel'] = 0x2226;
  17108. t['notprecedes'] = 0x2280;
  17109. t['notsubset'] = 0x2284;
  17110. t['notsucceeds'] = 0x2281;
  17111. t['notsuperset'] = 0x2285;
  17112. t['nowarmenian'] = 0x0576;
  17113. t['nparen'] = 0x24A9;
  17114. t['nssquare'] = 0x33B1;
  17115. t['nsuperior'] = 0x207F;
  17116. t['ntilde'] = 0x00F1;
  17117. t['nu'] = 0x03BD;
  17118. t['nuhiragana'] = 0x306C;
  17119. t['nukatakana'] = 0x30CC;
  17120. t['nukatakanahalfwidth'] = 0xFF87;
  17121. t['nuktabengali'] = 0x09BC;
  17122. t['nuktadeva'] = 0x093C;
  17123. t['nuktagujarati'] = 0x0ABC;
  17124. t['nuktagurmukhi'] = 0x0A3C;
  17125. t['numbersign'] = 0x0023;
  17126. t['numbersignmonospace'] = 0xFF03;
  17127. t['numbersignsmall'] = 0xFE5F;
  17128. t['numeralsigngreek'] = 0x0374;
  17129. t['numeralsignlowergreek'] = 0x0375;
  17130. t['numero'] = 0x2116;
  17131. t['nun'] = 0x05E0;
  17132. t['nundagesh'] = 0xFB40;
  17133. t['nundageshhebrew'] = 0xFB40;
  17134. t['nunhebrew'] = 0x05E0;
  17135. t['nvsquare'] = 0x33B5;
  17136. t['nwsquare'] = 0x33BB;
  17137. t['nyabengali'] = 0x099E;
  17138. t['nyadeva'] = 0x091E;
  17139. t['nyagujarati'] = 0x0A9E;
  17140. t['nyagurmukhi'] = 0x0A1E;
  17141. t['o'] = 0x006F;
  17142. t['oacute'] = 0x00F3;
  17143. t['oangthai'] = 0x0E2D;
  17144. t['obarred'] = 0x0275;
  17145. t['obarredcyrillic'] = 0x04E9;
  17146. t['obarreddieresiscyrillic'] = 0x04EB;
  17147. t['obengali'] = 0x0993;
  17148. t['obopomofo'] = 0x311B;
  17149. t['obreve'] = 0x014F;
  17150. t['ocandradeva'] = 0x0911;
  17151. t['ocandragujarati'] = 0x0A91;
  17152. t['ocandravowelsigndeva'] = 0x0949;
  17153. t['ocandravowelsigngujarati'] = 0x0AC9;
  17154. t['ocaron'] = 0x01D2;
  17155. t['ocircle'] = 0x24DE;
  17156. t['ocircumflex'] = 0x00F4;
  17157. t['ocircumflexacute'] = 0x1ED1;
  17158. t['ocircumflexdotbelow'] = 0x1ED9;
  17159. t['ocircumflexgrave'] = 0x1ED3;
  17160. t['ocircumflexhookabove'] = 0x1ED5;
  17161. t['ocircumflextilde'] = 0x1ED7;
  17162. t['ocyrillic'] = 0x043E;
  17163. t['odblacute'] = 0x0151;
  17164. t['odblgrave'] = 0x020D;
  17165. t['odeva'] = 0x0913;
  17166. t['odieresis'] = 0x00F6;
  17167. t['odieresiscyrillic'] = 0x04E7;
  17168. t['odotbelow'] = 0x1ECD;
  17169. t['oe'] = 0x0153;
  17170. t['oekorean'] = 0x315A;
  17171. t['ogonek'] = 0x02DB;
  17172. t['ogonekcmb'] = 0x0328;
  17173. t['ograve'] = 0x00F2;
  17174. t['ogujarati'] = 0x0A93;
  17175. t['oharmenian'] = 0x0585;
  17176. t['ohiragana'] = 0x304A;
  17177. t['ohookabove'] = 0x1ECF;
  17178. t['ohorn'] = 0x01A1;
  17179. t['ohornacute'] = 0x1EDB;
  17180. t['ohorndotbelow'] = 0x1EE3;
  17181. t['ohorngrave'] = 0x1EDD;
  17182. t['ohornhookabove'] = 0x1EDF;
  17183. t['ohorntilde'] = 0x1EE1;
  17184. t['ohungarumlaut'] = 0x0151;
  17185. t['oi'] = 0x01A3;
  17186. t['oinvertedbreve'] = 0x020F;
  17187. t['okatakana'] = 0x30AA;
  17188. t['okatakanahalfwidth'] = 0xFF75;
  17189. t['okorean'] = 0x3157;
  17190. t['olehebrew'] = 0x05AB;
  17191. t['omacron'] = 0x014D;
  17192. t['omacronacute'] = 0x1E53;
  17193. t['omacrongrave'] = 0x1E51;
  17194. t['omdeva'] = 0x0950;
  17195. t['omega'] = 0x03C9;
  17196. t['omega1'] = 0x03D6;
  17197. t['omegacyrillic'] = 0x0461;
  17198. t['omegalatinclosed'] = 0x0277;
  17199. t['omegaroundcyrillic'] = 0x047B;
  17200. t['omegatitlocyrillic'] = 0x047D;
  17201. t['omegatonos'] = 0x03CE;
  17202. t['omgujarati'] = 0x0AD0;
  17203. t['omicron'] = 0x03BF;
  17204. t['omicrontonos'] = 0x03CC;
  17205. t['omonospace'] = 0xFF4F;
  17206. t['one'] = 0x0031;
  17207. t['onearabic'] = 0x0661;
  17208. t['onebengali'] = 0x09E7;
  17209. t['onecircle'] = 0x2460;
  17210. t['onecircleinversesansserif'] = 0x278A;
  17211. t['onedeva'] = 0x0967;
  17212. t['onedotenleader'] = 0x2024;
  17213. t['oneeighth'] = 0x215B;
  17214. t['onefitted'] = 0xF6DC;
  17215. t['onegujarati'] = 0x0AE7;
  17216. t['onegurmukhi'] = 0x0A67;
  17217. t['onehackarabic'] = 0x0661;
  17218. t['onehalf'] = 0x00BD;
  17219. t['onehangzhou'] = 0x3021;
  17220. t['oneideographicparen'] = 0x3220;
  17221. t['oneinferior'] = 0x2081;
  17222. t['onemonospace'] = 0xFF11;
  17223. t['onenumeratorbengali'] = 0x09F4;
  17224. t['oneoldstyle'] = 0xF731;
  17225. t['oneparen'] = 0x2474;
  17226. t['oneperiod'] = 0x2488;
  17227. t['onepersian'] = 0x06F1;
  17228. t['onequarter'] = 0x00BC;
  17229. t['oneroman'] = 0x2170;
  17230. t['onesuperior'] = 0x00B9;
  17231. t['onethai'] = 0x0E51;
  17232. t['onethird'] = 0x2153;
  17233. t['oogonek'] = 0x01EB;
  17234. t['oogonekmacron'] = 0x01ED;
  17235. t['oogurmukhi'] = 0x0A13;
  17236. t['oomatragurmukhi'] = 0x0A4B;
  17237. t['oopen'] = 0x0254;
  17238. t['oparen'] = 0x24AA;
  17239. t['openbullet'] = 0x25E6;
  17240. t['option'] = 0x2325;
  17241. t['ordfeminine'] = 0x00AA;
  17242. t['ordmasculine'] = 0x00BA;
  17243. t['orthogonal'] = 0x221F;
  17244. t['oshortdeva'] = 0x0912;
  17245. t['oshortvowelsigndeva'] = 0x094A;
  17246. t['oslash'] = 0x00F8;
  17247. t['oslashacute'] = 0x01FF;
  17248. t['osmallhiragana'] = 0x3049;
  17249. t['osmallkatakana'] = 0x30A9;
  17250. t['osmallkatakanahalfwidth'] = 0xFF6B;
  17251. t['ostrokeacute'] = 0x01FF;
  17252. t['osuperior'] = 0xF6F0;
  17253. t['otcyrillic'] = 0x047F;
  17254. t['otilde'] = 0x00F5;
  17255. t['otildeacute'] = 0x1E4D;
  17256. t['otildedieresis'] = 0x1E4F;
  17257. t['oubopomofo'] = 0x3121;
  17258. t['overline'] = 0x203E;
  17259. t['overlinecenterline'] = 0xFE4A;
  17260. t['overlinecmb'] = 0x0305;
  17261. t['overlinedashed'] = 0xFE49;
  17262. t['overlinedblwavy'] = 0xFE4C;
  17263. t['overlinewavy'] = 0xFE4B;
  17264. t['overscore'] = 0x00AF;
  17265. t['ovowelsignbengali'] = 0x09CB;
  17266. t['ovowelsigndeva'] = 0x094B;
  17267. t['ovowelsigngujarati'] = 0x0ACB;
  17268. t['p'] = 0x0070;
  17269. t['paampssquare'] = 0x3380;
  17270. t['paasentosquare'] = 0x332B;
  17271. t['pabengali'] = 0x09AA;
  17272. t['pacute'] = 0x1E55;
  17273. t['padeva'] = 0x092A;
  17274. t['pagedown'] = 0x21DF;
  17275. t['pageup'] = 0x21DE;
  17276. t['pagujarati'] = 0x0AAA;
  17277. t['pagurmukhi'] = 0x0A2A;
  17278. t['pahiragana'] = 0x3071;
  17279. t['paiyannoithai'] = 0x0E2F;
  17280. t['pakatakana'] = 0x30D1;
  17281. t['palatalizationcyrilliccmb'] = 0x0484;
  17282. t['palochkacyrillic'] = 0x04C0;
  17283. t['pansioskorean'] = 0x317F;
  17284. t['paragraph'] = 0x00B6;
  17285. t['parallel'] = 0x2225;
  17286. t['parenleft'] = 0x0028;
  17287. t['parenleftaltonearabic'] = 0xFD3E;
  17288. t['parenleftbt'] = 0xF8ED;
  17289. t['parenleftex'] = 0xF8EC;
  17290. t['parenleftinferior'] = 0x208D;
  17291. t['parenleftmonospace'] = 0xFF08;
  17292. t['parenleftsmall'] = 0xFE59;
  17293. t['parenleftsuperior'] = 0x207D;
  17294. t['parenlefttp'] = 0xF8EB;
  17295. t['parenleftvertical'] = 0xFE35;
  17296. t['parenright'] = 0x0029;
  17297. t['parenrightaltonearabic'] = 0xFD3F;
  17298. t['parenrightbt'] = 0xF8F8;
  17299. t['parenrightex'] = 0xF8F7;
  17300. t['parenrightinferior'] = 0x208E;
  17301. t['parenrightmonospace'] = 0xFF09;
  17302. t['parenrightsmall'] = 0xFE5A;
  17303. t['parenrightsuperior'] = 0x207E;
  17304. t['parenrighttp'] = 0xF8F6;
  17305. t['parenrightvertical'] = 0xFE36;
  17306. t['partialdiff'] = 0x2202;
  17307. t['paseqhebrew'] = 0x05C0;
  17308. t['pashtahebrew'] = 0x0599;
  17309. t['pasquare'] = 0x33A9;
  17310. t['patah'] = 0x05B7;
  17311. t['patah11'] = 0x05B7;
  17312. t['patah1d'] = 0x05B7;
  17313. t['patah2a'] = 0x05B7;
  17314. t['patahhebrew'] = 0x05B7;
  17315. t['patahnarrowhebrew'] = 0x05B7;
  17316. t['patahquarterhebrew'] = 0x05B7;
  17317. t['patahwidehebrew'] = 0x05B7;
  17318. t['pazerhebrew'] = 0x05A1;
  17319. t['pbopomofo'] = 0x3106;
  17320. t['pcircle'] = 0x24DF;
  17321. t['pdotaccent'] = 0x1E57;
  17322. t['pe'] = 0x05E4;
  17323. t['pecyrillic'] = 0x043F;
  17324. t['pedagesh'] = 0xFB44;
  17325. t['pedageshhebrew'] = 0xFB44;
  17326. t['peezisquare'] = 0x333B;
  17327. t['pefinaldageshhebrew'] = 0xFB43;
  17328. t['peharabic'] = 0x067E;
  17329. t['peharmenian'] = 0x057A;
  17330. t['pehebrew'] = 0x05E4;
  17331. t['pehfinalarabic'] = 0xFB57;
  17332. t['pehinitialarabic'] = 0xFB58;
  17333. t['pehiragana'] = 0x307A;
  17334. t['pehmedialarabic'] = 0xFB59;
  17335. t['pekatakana'] = 0x30DA;
  17336. t['pemiddlehookcyrillic'] = 0x04A7;
  17337. t['perafehebrew'] = 0xFB4E;
  17338. t['percent'] = 0x0025;
  17339. t['percentarabic'] = 0x066A;
  17340. t['percentmonospace'] = 0xFF05;
  17341. t['percentsmall'] = 0xFE6A;
  17342. t['period'] = 0x002E;
  17343. t['periodarmenian'] = 0x0589;
  17344. t['periodcentered'] = 0x00B7;
  17345. t['periodhalfwidth'] = 0xFF61;
  17346. t['periodinferior'] = 0xF6E7;
  17347. t['periodmonospace'] = 0xFF0E;
  17348. t['periodsmall'] = 0xFE52;
  17349. t['periodsuperior'] = 0xF6E8;
  17350. t['perispomenigreekcmb'] = 0x0342;
  17351. t['perpendicular'] = 0x22A5;
  17352. t['perthousand'] = 0x2030;
  17353. t['peseta'] = 0x20A7;
  17354. t['pfsquare'] = 0x338A;
  17355. t['phabengali'] = 0x09AB;
  17356. t['phadeva'] = 0x092B;
  17357. t['phagujarati'] = 0x0AAB;
  17358. t['phagurmukhi'] = 0x0A2B;
  17359. t['phi'] = 0x03C6;
  17360. t['phi1'] = 0x03D5;
  17361. t['phieuphacirclekorean'] = 0x327A;
  17362. t['phieuphaparenkorean'] = 0x321A;
  17363. t['phieuphcirclekorean'] = 0x326C;
  17364. t['phieuphkorean'] = 0x314D;
  17365. t['phieuphparenkorean'] = 0x320C;
  17366. t['philatin'] = 0x0278;
  17367. t['phinthuthai'] = 0x0E3A;
  17368. t['phisymbolgreek'] = 0x03D5;
  17369. t['phook'] = 0x01A5;
  17370. t['phophanthai'] = 0x0E1E;
  17371. t['phophungthai'] = 0x0E1C;
  17372. t['phosamphaothai'] = 0x0E20;
  17373. t['pi'] = 0x03C0;
  17374. t['pieupacirclekorean'] = 0x3273;
  17375. t['pieupaparenkorean'] = 0x3213;
  17376. t['pieupcieuckorean'] = 0x3176;
  17377. t['pieupcirclekorean'] = 0x3265;
  17378. t['pieupkiyeokkorean'] = 0x3172;
  17379. t['pieupkorean'] = 0x3142;
  17380. t['pieupparenkorean'] = 0x3205;
  17381. t['pieupsioskiyeokkorean'] = 0x3174;
  17382. t['pieupsioskorean'] = 0x3144;
  17383. t['pieupsiostikeutkorean'] = 0x3175;
  17384. t['pieupthieuthkorean'] = 0x3177;
  17385. t['pieuptikeutkorean'] = 0x3173;
  17386. t['pihiragana'] = 0x3074;
  17387. t['pikatakana'] = 0x30D4;
  17388. t['pisymbolgreek'] = 0x03D6;
  17389. t['piwrarmenian'] = 0x0583;
  17390. t['plus'] = 0x002B;
  17391. t['plusbelowcmb'] = 0x031F;
  17392. t['pluscircle'] = 0x2295;
  17393. t['plusminus'] = 0x00B1;
  17394. t['plusmod'] = 0x02D6;
  17395. t['plusmonospace'] = 0xFF0B;
  17396. t['plussmall'] = 0xFE62;
  17397. t['plussuperior'] = 0x207A;
  17398. t['pmonospace'] = 0xFF50;
  17399. t['pmsquare'] = 0x33D8;
  17400. t['pohiragana'] = 0x307D;
  17401. t['pointingindexdownwhite'] = 0x261F;
  17402. t['pointingindexleftwhite'] = 0x261C;
  17403. t['pointingindexrightwhite'] = 0x261E;
  17404. t['pointingindexupwhite'] = 0x261D;
  17405. t['pokatakana'] = 0x30DD;
  17406. t['poplathai'] = 0x0E1B;
  17407. t['postalmark'] = 0x3012;
  17408. t['postalmarkface'] = 0x3020;
  17409. t['pparen'] = 0x24AB;
  17410. t['precedes'] = 0x227A;
  17411. t['prescription'] = 0x211E;
  17412. t['primemod'] = 0x02B9;
  17413. t['primereversed'] = 0x2035;
  17414. t['product'] = 0x220F;
  17415. t['projective'] = 0x2305;
  17416. t['prolongedkana'] = 0x30FC;
  17417. t['propellor'] = 0x2318;
  17418. t['propersubset'] = 0x2282;
  17419. t['propersuperset'] = 0x2283;
  17420. t['proportion'] = 0x2237;
  17421. t['proportional'] = 0x221D;
  17422. t['psi'] = 0x03C8;
  17423. t['psicyrillic'] = 0x0471;
  17424. t['psilipneumatacyrilliccmb'] = 0x0486;
  17425. t['pssquare'] = 0x33B0;
  17426. t['puhiragana'] = 0x3077;
  17427. t['pukatakana'] = 0x30D7;
  17428. t['pvsquare'] = 0x33B4;
  17429. t['pwsquare'] = 0x33BA;
  17430. t['q'] = 0x0071;
  17431. t['qadeva'] = 0x0958;
  17432. t['qadmahebrew'] = 0x05A8;
  17433. t['qafarabic'] = 0x0642;
  17434. t['qaffinalarabic'] = 0xFED6;
  17435. t['qafinitialarabic'] = 0xFED7;
  17436. t['qafmedialarabic'] = 0xFED8;
  17437. t['qamats'] = 0x05B8;
  17438. t['qamats10'] = 0x05B8;
  17439. t['qamats1a'] = 0x05B8;
  17440. t['qamats1c'] = 0x05B8;
  17441. t['qamats27'] = 0x05B8;
  17442. t['qamats29'] = 0x05B8;
  17443. t['qamats33'] = 0x05B8;
  17444. t['qamatsde'] = 0x05B8;
  17445. t['qamatshebrew'] = 0x05B8;
  17446. t['qamatsnarrowhebrew'] = 0x05B8;
  17447. t['qamatsqatanhebrew'] = 0x05B8;
  17448. t['qamatsqatannarrowhebrew'] = 0x05B8;
  17449. t['qamatsqatanquarterhebrew'] = 0x05B8;
  17450. t['qamatsqatanwidehebrew'] = 0x05B8;
  17451. t['qamatsquarterhebrew'] = 0x05B8;
  17452. t['qamatswidehebrew'] = 0x05B8;
  17453. t['qarneyparahebrew'] = 0x059F;
  17454. t['qbopomofo'] = 0x3111;
  17455. t['qcircle'] = 0x24E0;
  17456. t['qhook'] = 0x02A0;
  17457. t['qmonospace'] = 0xFF51;
  17458. t['qof'] = 0x05E7;
  17459. t['qofdagesh'] = 0xFB47;
  17460. t['qofdageshhebrew'] = 0xFB47;
  17461. t['qofhebrew'] = 0x05E7;
  17462. t['qparen'] = 0x24AC;
  17463. t['quarternote'] = 0x2669;
  17464. t['qubuts'] = 0x05BB;
  17465. t['qubuts18'] = 0x05BB;
  17466. t['qubuts25'] = 0x05BB;
  17467. t['qubuts31'] = 0x05BB;
  17468. t['qubutshebrew'] = 0x05BB;
  17469. t['qubutsnarrowhebrew'] = 0x05BB;
  17470. t['qubutsquarterhebrew'] = 0x05BB;
  17471. t['qubutswidehebrew'] = 0x05BB;
  17472. t['question'] = 0x003F;
  17473. t['questionarabic'] = 0x061F;
  17474. t['questionarmenian'] = 0x055E;
  17475. t['questiondown'] = 0x00BF;
  17476. t['questiondownsmall'] = 0xF7BF;
  17477. t['questiongreek'] = 0x037E;
  17478. t['questionmonospace'] = 0xFF1F;
  17479. t['questionsmall'] = 0xF73F;
  17480. t['quotedbl'] = 0x0022;
  17481. t['quotedblbase'] = 0x201E;
  17482. t['quotedblleft'] = 0x201C;
  17483. t['quotedblmonospace'] = 0xFF02;
  17484. t['quotedblprime'] = 0x301E;
  17485. t['quotedblprimereversed'] = 0x301D;
  17486. t['quotedblright'] = 0x201D;
  17487. t['quoteleft'] = 0x2018;
  17488. t['quoteleftreversed'] = 0x201B;
  17489. t['quotereversed'] = 0x201B;
  17490. t['quoteright'] = 0x2019;
  17491. t['quoterightn'] = 0x0149;
  17492. t['quotesinglbase'] = 0x201A;
  17493. t['quotesingle'] = 0x0027;
  17494. t['quotesinglemonospace'] = 0xFF07;
  17495. t['r'] = 0x0072;
  17496. t['raarmenian'] = 0x057C;
  17497. t['rabengali'] = 0x09B0;
  17498. t['racute'] = 0x0155;
  17499. t['radeva'] = 0x0930;
  17500. t['radical'] = 0x221A;
  17501. t['radicalex'] = 0xF8E5;
  17502. t['radoverssquare'] = 0x33AE;
  17503. t['radoverssquaredsquare'] = 0x33AF;
  17504. t['radsquare'] = 0x33AD;
  17505. t['rafe'] = 0x05BF;
  17506. t['rafehebrew'] = 0x05BF;
  17507. t['ragujarati'] = 0x0AB0;
  17508. t['ragurmukhi'] = 0x0A30;
  17509. t['rahiragana'] = 0x3089;
  17510. t['rakatakana'] = 0x30E9;
  17511. t['rakatakanahalfwidth'] = 0xFF97;
  17512. t['ralowerdiagonalbengali'] = 0x09F1;
  17513. t['ramiddlediagonalbengali'] = 0x09F0;
  17514. t['ramshorn'] = 0x0264;
  17515. t['ratio'] = 0x2236;
  17516. t['rbopomofo'] = 0x3116;
  17517. t['rcaron'] = 0x0159;
  17518. t['rcedilla'] = 0x0157;
  17519. t['rcircle'] = 0x24E1;
  17520. t['rcommaaccent'] = 0x0157;
  17521. t['rdblgrave'] = 0x0211;
  17522. t['rdotaccent'] = 0x1E59;
  17523. t['rdotbelow'] = 0x1E5B;
  17524. t['rdotbelowmacron'] = 0x1E5D;
  17525. t['referencemark'] = 0x203B;
  17526. t['reflexsubset'] = 0x2286;
  17527. t['reflexsuperset'] = 0x2287;
  17528. t['registered'] = 0x00AE;
  17529. t['registersans'] = 0xF8E8;
  17530. t['registerserif'] = 0xF6DA;
  17531. t['reharabic'] = 0x0631;
  17532. t['reharmenian'] = 0x0580;
  17533. t['rehfinalarabic'] = 0xFEAE;
  17534. t['rehiragana'] = 0x308C;
  17535. t['rekatakana'] = 0x30EC;
  17536. t['rekatakanahalfwidth'] = 0xFF9A;
  17537. t['resh'] = 0x05E8;
  17538. t['reshdageshhebrew'] = 0xFB48;
  17539. t['reshhebrew'] = 0x05E8;
  17540. t['reversedtilde'] = 0x223D;
  17541. t['reviahebrew'] = 0x0597;
  17542. t['reviamugrashhebrew'] = 0x0597;
  17543. t['revlogicalnot'] = 0x2310;
  17544. t['rfishhook'] = 0x027E;
  17545. t['rfishhookreversed'] = 0x027F;
  17546. t['rhabengali'] = 0x09DD;
  17547. t['rhadeva'] = 0x095D;
  17548. t['rho'] = 0x03C1;
  17549. t['rhook'] = 0x027D;
  17550. t['rhookturned'] = 0x027B;
  17551. t['rhookturnedsuperior'] = 0x02B5;
  17552. t['rhosymbolgreek'] = 0x03F1;
  17553. t['rhotichookmod'] = 0x02DE;
  17554. t['rieulacirclekorean'] = 0x3271;
  17555. t['rieulaparenkorean'] = 0x3211;
  17556. t['rieulcirclekorean'] = 0x3263;
  17557. t['rieulhieuhkorean'] = 0x3140;
  17558. t['rieulkiyeokkorean'] = 0x313A;
  17559. t['rieulkiyeoksioskorean'] = 0x3169;
  17560. t['rieulkorean'] = 0x3139;
  17561. t['rieulmieumkorean'] = 0x313B;
  17562. t['rieulpansioskorean'] = 0x316C;
  17563. t['rieulparenkorean'] = 0x3203;
  17564. t['rieulphieuphkorean'] = 0x313F;
  17565. t['rieulpieupkorean'] = 0x313C;
  17566. t['rieulpieupsioskorean'] = 0x316B;
  17567. t['rieulsioskorean'] = 0x313D;
  17568. t['rieulthieuthkorean'] = 0x313E;
  17569. t['rieultikeutkorean'] = 0x316A;
  17570. t['rieulyeorinhieuhkorean'] = 0x316D;
  17571. t['rightangle'] = 0x221F;
  17572. t['righttackbelowcmb'] = 0x0319;
  17573. t['righttriangle'] = 0x22BF;
  17574. t['rihiragana'] = 0x308A;
  17575. t['rikatakana'] = 0x30EA;
  17576. t['rikatakanahalfwidth'] = 0xFF98;
  17577. t['ring'] = 0x02DA;
  17578. t['ringbelowcmb'] = 0x0325;
  17579. t['ringcmb'] = 0x030A;
  17580. t['ringhalfleft'] = 0x02BF;
  17581. t['ringhalfleftarmenian'] = 0x0559;
  17582. t['ringhalfleftbelowcmb'] = 0x031C;
  17583. t['ringhalfleftcentered'] = 0x02D3;
  17584. t['ringhalfright'] = 0x02BE;
  17585. t['ringhalfrightbelowcmb'] = 0x0339;
  17586. t['ringhalfrightcentered'] = 0x02D2;
  17587. t['rinvertedbreve'] = 0x0213;
  17588. t['rittorusquare'] = 0x3351;
  17589. t['rlinebelow'] = 0x1E5F;
  17590. t['rlongleg'] = 0x027C;
  17591. t['rlonglegturned'] = 0x027A;
  17592. t['rmonospace'] = 0xFF52;
  17593. t['rohiragana'] = 0x308D;
  17594. t['rokatakana'] = 0x30ED;
  17595. t['rokatakanahalfwidth'] = 0xFF9B;
  17596. t['roruathai'] = 0x0E23;
  17597. t['rparen'] = 0x24AD;
  17598. t['rrabengali'] = 0x09DC;
  17599. t['rradeva'] = 0x0931;
  17600. t['rragurmukhi'] = 0x0A5C;
  17601. t['rreharabic'] = 0x0691;
  17602. t['rrehfinalarabic'] = 0xFB8D;
  17603. t['rrvocalicbengali'] = 0x09E0;
  17604. t['rrvocalicdeva'] = 0x0960;
  17605. t['rrvocalicgujarati'] = 0x0AE0;
  17606. t['rrvocalicvowelsignbengali'] = 0x09C4;
  17607. t['rrvocalicvowelsigndeva'] = 0x0944;
  17608. t['rrvocalicvowelsigngujarati'] = 0x0AC4;
  17609. t['rsuperior'] = 0xF6F1;
  17610. t['rtblock'] = 0x2590;
  17611. t['rturned'] = 0x0279;
  17612. t['rturnedsuperior'] = 0x02B4;
  17613. t['ruhiragana'] = 0x308B;
  17614. t['rukatakana'] = 0x30EB;
  17615. t['rukatakanahalfwidth'] = 0xFF99;
  17616. t['rupeemarkbengali'] = 0x09F2;
  17617. t['rupeesignbengali'] = 0x09F3;
  17618. t['rupiah'] = 0xF6DD;
  17619. t['ruthai'] = 0x0E24;
  17620. t['rvocalicbengali'] = 0x098B;
  17621. t['rvocalicdeva'] = 0x090B;
  17622. t['rvocalicgujarati'] = 0x0A8B;
  17623. t['rvocalicvowelsignbengali'] = 0x09C3;
  17624. t['rvocalicvowelsigndeva'] = 0x0943;
  17625. t['rvocalicvowelsigngujarati'] = 0x0AC3;
  17626. t['s'] = 0x0073;
  17627. t['sabengali'] = 0x09B8;
  17628. t['sacute'] = 0x015B;
  17629. t['sacutedotaccent'] = 0x1E65;
  17630. t['sadarabic'] = 0x0635;
  17631. t['sadeva'] = 0x0938;
  17632. t['sadfinalarabic'] = 0xFEBA;
  17633. t['sadinitialarabic'] = 0xFEBB;
  17634. t['sadmedialarabic'] = 0xFEBC;
  17635. t['sagujarati'] = 0x0AB8;
  17636. t['sagurmukhi'] = 0x0A38;
  17637. t['sahiragana'] = 0x3055;
  17638. t['sakatakana'] = 0x30B5;
  17639. t['sakatakanahalfwidth'] = 0xFF7B;
  17640. t['sallallahoualayhewasallamarabic'] = 0xFDFA;
  17641. t['samekh'] = 0x05E1;
  17642. t['samekhdagesh'] = 0xFB41;
  17643. t['samekhdageshhebrew'] = 0xFB41;
  17644. t['samekhhebrew'] = 0x05E1;
  17645. t['saraaathai'] = 0x0E32;
  17646. t['saraaethai'] = 0x0E41;
  17647. t['saraaimaimalaithai'] = 0x0E44;
  17648. t['saraaimaimuanthai'] = 0x0E43;
  17649. t['saraamthai'] = 0x0E33;
  17650. t['saraathai'] = 0x0E30;
  17651. t['saraethai'] = 0x0E40;
  17652. t['saraiileftthai'] = 0xF886;
  17653. t['saraiithai'] = 0x0E35;
  17654. t['saraileftthai'] = 0xF885;
  17655. t['saraithai'] = 0x0E34;
  17656. t['saraothai'] = 0x0E42;
  17657. t['saraueeleftthai'] = 0xF888;
  17658. t['saraueethai'] = 0x0E37;
  17659. t['saraueleftthai'] = 0xF887;
  17660. t['sarauethai'] = 0x0E36;
  17661. t['sarauthai'] = 0x0E38;
  17662. t['sarauuthai'] = 0x0E39;
  17663. t['sbopomofo'] = 0x3119;
  17664. t['scaron'] = 0x0161;
  17665. t['scarondotaccent'] = 0x1E67;
  17666. t['scedilla'] = 0x015F;
  17667. t['schwa'] = 0x0259;
  17668. t['schwacyrillic'] = 0x04D9;
  17669. t['schwadieresiscyrillic'] = 0x04DB;
  17670. t['schwahook'] = 0x025A;
  17671. t['scircle'] = 0x24E2;
  17672. t['scircumflex'] = 0x015D;
  17673. t['scommaaccent'] = 0x0219;
  17674. t['sdotaccent'] = 0x1E61;
  17675. t['sdotbelow'] = 0x1E63;
  17676. t['sdotbelowdotaccent'] = 0x1E69;
  17677. t['seagullbelowcmb'] = 0x033C;
  17678. t['second'] = 0x2033;
  17679. t['secondtonechinese'] = 0x02CA;
  17680. t['section'] = 0x00A7;
  17681. t['seenarabic'] = 0x0633;
  17682. t['seenfinalarabic'] = 0xFEB2;
  17683. t['seeninitialarabic'] = 0xFEB3;
  17684. t['seenmedialarabic'] = 0xFEB4;
  17685. t['segol'] = 0x05B6;
  17686. t['segol13'] = 0x05B6;
  17687. t['segol1f'] = 0x05B6;
  17688. t['segol2c'] = 0x05B6;
  17689. t['segolhebrew'] = 0x05B6;
  17690. t['segolnarrowhebrew'] = 0x05B6;
  17691. t['segolquarterhebrew'] = 0x05B6;
  17692. t['segoltahebrew'] = 0x0592;
  17693. t['segolwidehebrew'] = 0x05B6;
  17694. t['seharmenian'] = 0x057D;
  17695. t['sehiragana'] = 0x305B;
  17696. t['sekatakana'] = 0x30BB;
  17697. t['sekatakanahalfwidth'] = 0xFF7E;
  17698. t['semicolon'] = 0x003B;
  17699. t['semicolonarabic'] = 0x061B;
  17700. t['semicolonmonospace'] = 0xFF1B;
  17701. t['semicolonsmall'] = 0xFE54;
  17702. t['semivoicedmarkkana'] = 0x309C;
  17703. t['semivoicedmarkkanahalfwidth'] = 0xFF9F;
  17704. t['sentisquare'] = 0x3322;
  17705. t['sentosquare'] = 0x3323;
  17706. t['seven'] = 0x0037;
  17707. t['sevenarabic'] = 0x0667;
  17708. t['sevenbengali'] = 0x09ED;
  17709. t['sevencircle'] = 0x2466;
  17710. t['sevencircleinversesansserif'] = 0x2790;
  17711. t['sevendeva'] = 0x096D;
  17712. t['seveneighths'] = 0x215E;
  17713. t['sevengujarati'] = 0x0AED;
  17714. t['sevengurmukhi'] = 0x0A6D;
  17715. t['sevenhackarabic'] = 0x0667;
  17716. t['sevenhangzhou'] = 0x3027;
  17717. t['sevenideographicparen'] = 0x3226;
  17718. t['seveninferior'] = 0x2087;
  17719. t['sevenmonospace'] = 0xFF17;
  17720. t['sevenoldstyle'] = 0xF737;
  17721. t['sevenparen'] = 0x247A;
  17722. t['sevenperiod'] = 0x248E;
  17723. t['sevenpersian'] = 0x06F7;
  17724. t['sevenroman'] = 0x2176;
  17725. t['sevensuperior'] = 0x2077;
  17726. t['seventeencircle'] = 0x2470;
  17727. t['seventeenparen'] = 0x2484;
  17728. t['seventeenperiod'] = 0x2498;
  17729. t['seventhai'] = 0x0E57;
  17730. t['sfthyphen'] = 0x00AD;
  17731. t['shaarmenian'] = 0x0577;
  17732. t['shabengali'] = 0x09B6;
  17733. t['shacyrillic'] = 0x0448;
  17734. t['shaddaarabic'] = 0x0651;
  17735. t['shaddadammaarabic'] = 0xFC61;
  17736. t['shaddadammatanarabic'] = 0xFC5E;
  17737. t['shaddafathaarabic'] = 0xFC60;
  17738. t['shaddakasraarabic'] = 0xFC62;
  17739. t['shaddakasratanarabic'] = 0xFC5F;
  17740. t['shade'] = 0x2592;
  17741. t['shadedark'] = 0x2593;
  17742. t['shadelight'] = 0x2591;
  17743. t['shademedium'] = 0x2592;
  17744. t['shadeva'] = 0x0936;
  17745. t['shagujarati'] = 0x0AB6;
  17746. t['shagurmukhi'] = 0x0A36;
  17747. t['shalshelethebrew'] = 0x0593;
  17748. t['shbopomofo'] = 0x3115;
  17749. t['shchacyrillic'] = 0x0449;
  17750. t['sheenarabic'] = 0x0634;
  17751. t['sheenfinalarabic'] = 0xFEB6;
  17752. t['sheeninitialarabic'] = 0xFEB7;
  17753. t['sheenmedialarabic'] = 0xFEB8;
  17754. t['sheicoptic'] = 0x03E3;
  17755. t['sheqel'] = 0x20AA;
  17756. t['sheqelhebrew'] = 0x20AA;
  17757. t['sheva'] = 0x05B0;
  17758. t['sheva115'] = 0x05B0;
  17759. t['sheva15'] = 0x05B0;
  17760. t['sheva22'] = 0x05B0;
  17761. t['sheva2e'] = 0x05B0;
  17762. t['shevahebrew'] = 0x05B0;
  17763. t['shevanarrowhebrew'] = 0x05B0;
  17764. t['shevaquarterhebrew'] = 0x05B0;
  17765. t['shevawidehebrew'] = 0x05B0;
  17766. t['shhacyrillic'] = 0x04BB;
  17767. t['shimacoptic'] = 0x03ED;
  17768. t['shin'] = 0x05E9;
  17769. t['shindagesh'] = 0xFB49;
  17770. t['shindageshhebrew'] = 0xFB49;
  17771. t['shindageshshindot'] = 0xFB2C;
  17772. t['shindageshshindothebrew'] = 0xFB2C;
  17773. t['shindageshsindot'] = 0xFB2D;
  17774. t['shindageshsindothebrew'] = 0xFB2D;
  17775. t['shindothebrew'] = 0x05C1;
  17776. t['shinhebrew'] = 0x05E9;
  17777. t['shinshindot'] = 0xFB2A;
  17778. t['shinshindothebrew'] = 0xFB2A;
  17779. t['shinsindot'] = 0xFB2B;
  17780. t['shinsindothebrew'] = 0xFB2B;
  17781. t['shook'] = 0x0282;
  17782. t['sigma'] = 0x03C3;
  17783. t['sigma1'] = 0x03C2;
  17784. t['sigmafinal'] = 0x03C2;
  17785. t['sigmalunatesymbolgreek'] = 0x03F2;
  17786. t['sihiragana'] = 0x3057;
  17787. t['sikatakana'] = 0x30B7;
  17788. t['sikatakanahalfwidth'] = 0xFF7C;
  17789. t['siluqhebrew'] = 0x05BD;
  17790. t['siluqlefthebrew'] = 0x05BD;
  17791. t['similar'] = 0x223C;
  17792. t['sindothebrew'] = 0x05C2;
  17793. t['siosacirclekorean'] = 0x3274;
  17794. t['siosaparenkorean'] = 0x3214;
  17795. t['sioscieuckorean'] = 0x317E;
  17796. t['sioscirclekorean'] = 0x3266;
  17797. t['sioskiyeokkorean'] = 0x317A;
  17798. t['sioskorean'] = 0x3145;
  17799. t['siosnieunkorean'] = 0x317B;
  17800. t['siosparenkorean'] = 0x3206;
  17801. t['siospieupkorean'] = 0x317D;
  17802. t['siostikeutkorean'] = 0x317C;
  17803. t['six'] = 0x0036;
  17804. t['sixarabic'] = 0x0666;
  17805. t['sixbengali'] = 0x09EC;
  17806. t['sixcircle'] = 0x2465;
  17807. t['sixcircleinversesansserif'] = 0x278F;
  17808. t['sixdeva'] = 0x096C;
  17809. t['sixgujarati'] = 0x0AEC;
  17810. t['sixgurmukhi'] = 0x0A6C;
  17811. t['sixhackarabic'] = 0x0666;
  17812. t['sixhangzhou'] = 0x3026;
  17813. t['sixideographicparen'] = 0x3225;
  17814. t['sixinferior'] = 0x2086;
  17815. t['sixmonospace'] = 0xFF16;
  17816. t['sixoldstyle'] = 0xF736;
  17817. t['sixparen'] = 0x2479;
  17818. t['sixperiod'] = 0x248D;
  17819. t['sixpersian'] = 0x06F6;
  17820. t['sixroman'] = 0x2175;
  17821. t['sixsuperior'] = 0x2076;
  17822. t['sixteencircle'] = 0x246F;
  17823. t['sixteencurrencydenominatorbengali'] = 0x09F9;
  17824. t['sixteenparen'] = 0x2483;
  17825. t['sixteenperiod'] = 0x2497;
  17826. t['sixthai'] = 0x0E56;
  17827. t['slash'] = 0x002F;
  17828. t['slashmonospace'] = 0xFF0F;
  17829. t['slong'] = 0x017F;
  17830. t['slongdotaccent'] = 0x1E9B;
  17831. t['smileface'] = 0x263A;
  17832. t['smonospace'] = 0xFF53;
  17833. t['sofpasuqhebrew'] = 0x05C3;
  17834. t['softhyphen'] = 0x00AD;
  17835. t['softsigncyrillic'] = 0x044C;
  17836. t['sohiragana'] = 0x305D;
  17837. t['sokatakana'] = 0x30BD;
  17838. t['sokatakanahalfwidth'] = 0xFF7F;
  17839. t['soliduslongoverlaycmb'] = 0x0338;
  17840. t['solidusshortoverlaycmb'] = 0x0337;
  17841. t['sorusithai'] = 0x0E29;
  17842. t['sosalathai'] = 0x0E28;
  17843. t['sosothai'] = 0x0E0B;
  17844. t['sosuathai'] = 0x0E2A;
  17845. t['space'] = 0x0020;
  17846. t['spacehackarabic'] = 0x0020;
  17847. t['spade'] = 0x2660;
  17848. t['spadesuitblack'] = 0x2660;
  17849. t['spadesuitwhite'] = 0x2664;
  17850. t['sparen'] = 0x24AE;
  17851. t['squarebelowcmb'] = 0x033B;
  17852. t['squarecc'] = 0x33C4;
  17853. t['squarecm'] = 0x339D;
  17854. t['squarediagonalcrosshatchfill'] = 0x25A9;
  17855. t['squarehorizontalfill'] = 0x25A4;
  17856. t['squarekg'] = 0x338F;
  17857. t['squarekm'] = 0x339E;
  17858. t['squarekmcapital'] = 0x33CE;
  17859. t['squareln'] = 0x33D1;
  17860. t['squarelog'] = 0x33D2;
  17861. t['squaremg'] = 0x338E;
  17862. t['squaremil'] = 0x33D5;
  17863. t['squaremm'] = 0x339C;
  17864. t['squaremsquared'] = 0x33A1;
  17865. t['squareorthogonalcrosshatchfill'] = 0x25A6;
  17866. t['squareupperlefttolowerrightfill'] = 0x25A7;
  17867. t['squareupperrighttolowerleftfill'] = 0x25A8;
  17868. t['squareverticalfill'] = 0x25A5;
  17869. t['squarewhitewithsmallblack'] = 0x25A3;
  17870. t['srsquare'] = 0x33DB;
  17871. t['ssabengali'] = 0x09B7;
  17872. t['ssadeva'] = 0x0937;
  17873. t['ssagujarati'] = 0x0AB7;
  17874. t['ssangcieuckorean'] = 0x3149;
  17875. t['ssanghieuhkorean'] = 0x3185;
  17876. t['ssangieungkorean'] = 0x3180;
  17877. t['ssangkiyeokkorean'] = 0x3132;
  17878. t['ssangnieunkorean'] = 0x3165;
  17879. t['ssangpieupkorean'] = 0x3143;
  17880. t['ssangsioskorean'] = 0x3146;
  17881. t['ssangtikeutkorean'] = 0x3138;
  17882. t['ssuperior'] = 0xF6F2;
  17883. t['sterling'] = 0x00A3;
  17884. t['sterlingmonospace'] = 0xFFE1;
  17885. t['strokelongoverlaycmb'] = 0x0336;
  17886. t['strokeshortoverlaycmb'] = 0x0335;
  17887. t['subset'] = 0x2282;
  17888. t['subsetnotequal'] = 0x228A;
  17889. t['subsetorequal'] = 0x2286;
  17890. t['succeeds'] = 0x227B;
  17891. t['suchthat'] = 0x220B;
  17892. t['suhiragana'] = 0x3059;
  17893. t['sukatakana'] = 0x30B9;
  17894. t['sukatakanahalfwidth'] = 0xFF7D;
  17895. t['sukunarabic'] = 0x0652;
  17896. t['summation'] = 0x2211;
  17897. t['sun'] = 0x263C;
  17898. t['superset'] = 0x2283;
  17899. t['supersetnotequal'] = 0x228B;
  17900. t['supersetorequal'] = 0x2287;
  17901. t['svsquare'] = 0x33DC;
  17902. t['syouwaerasquare'] = 0x337C;
  17903. t['t'] = 0x0074;
  17904. t['tabengali'] = 0x09A4;
  17905. t['tackdown'] = 0x22A4;
  17906. t['tackleft'] = 0x22A3;
  17907. t['tadeva'] = 0x0924;
  17908. t['tagujarati'] = 0x0AA4;
  17909. t['tagurmukhi'] = 0x0A24;
  17910. t['taharabic'] = 0x0637;
  17911. t['tahfinalarabic'] = 0xFEC2;
  17912. t['tahinitialarabic'] = 0xFEC3;
  17913. t['tahiragana'] = 0x305F;
  17914. t['tahmedialarabic'] = 0xFEC4;
  17915. t['taisyouerasquare'] = 0x337D;
  17916. t['takatakana'] = 0x30BF;
  17917. t['takatakanahalfwidth'] = 0xFF80;
  17918. t['tatweelarabic'] = 0x0640;
  17919. t['tau'] = 0x03C4;
  17920. t['tav'] = 0x05EA;
  17921. t['tavdages'] = 0xFB4A;
  17922. t['tavdagesh'] = 0xFB4A;
  17923. t['tavdageshhebrew'] = 0xFB4A;
  17924. t['tavhebrew'] = 0x05EA;
  17925. t['tbar'] = 0x0167;
  17926. t['tbopomofo'] = 0x310A;
  17927. t['tcaron'] = 0x0165;
  17928. t['tccurl'] = 0x02A8;
  17929. t['tcedilla'] = 0x0163;
  17930. t['tcheharabic'] = 0x0686;
  17931. t['tchehfinalarabic'] = 0xFB7B;
  17932. t['tchehinitialarabic'] = 0xFB7C;
  17933. t['tchehmedialarabic'] = 0xFB7D;
  17934. t['tcircle'] = 0x24E3;
  17935. t['tcircumflexbelow'] = 0x1E71;
  17936. t['tcommaaccent'] = 0x0163;
  17937. t['tdieresis'] = 0x1E97;
  17938. t['tdotaccent'] = 0x1E6B;
  17939. t['tdotbelow'] = 0x1E6D;
  17940. t['tecyrillic'] = 0x0442;
  17941. t['tedescendercyrillic'] = 0x04AD;
  17942. t['teharabic'] = 0x062A;
  17943. t['tehfinalarabic'] = 0xFE96;
  17944. t['tehhahinitialarabic'] = 0xFCA2;
  17945. t['tehhahisolatedarabic'] = 0xFC0C;
  17946. t['tehinitialarabic'] = 0xFE97;
  17947. t['tehiragana'] = 0x3066;
  17948. t['tehjeeminitialarabic'] = 0xFCA1;
  17949. t['tehjeemisolatedarabic'] = 0xFC0B;
  17950. t['tehmarbutaarabic'] = 0x0629;
  17951. t['tehmarbutafinalarabic'] = 0xFE94;
  17952. t['tehmedialarabic'] = 0xFE98;
  17953. t['tehmeeminitialarabic'] = 0xFCA4;
  17954. t['tehmeemisolatedarabic'] = 0xFC0E;
  17955. t['tehnoonfinalarabic'] = 0xFC73;
  17956. t['tekatakana'] = 0x30C6;
  17957. t['tekatakanahalfwidth'] = 0xFF83;
  17958. t['telephone'] = 0x2121;
  17959. t['telephoneblack'] = 0x260E;
  17960. t['telishagedolahebrew'] = 0x05A0;
  17961. t['telishaqetanahebrew'] = 0x05A9;
  17962. t['tencircle'] = 0x2469;
  17963. t['tenideographicparen'] = 0x3229;
  17964. t['tenparen'] = 0x247D;
  17965. t['tenperiod'] = 0x2491;
  17966. t['tenroman'] = 0x2179;
  17967. t['tesh'] = 0x02A7;
  17968. t['tet'] = 0x05D8;
  17969. t['tetdagesh'] = 0xFB38;
  17970. t['tetdageshhebrew'] = 0xFB38;
  17971. t['tethebrew'] = 0x05D8;
  17972. t['tetsecyrillic'] = 0x04B5;
  17973. t['tevirhebrew'] = 0x059B;
  17974. t['tevirlefthebrew'] = 0x059B;
  17975. t['thabengali'] = 0x09A5;
  17976. t['thadeva'] = 0x0925;
  17977. t['thagujarati'] = 0x0AA5;
  17978. t['thagurmukhi'] = 0x0A25;
  17979. t['thalarabic'] = 0x0630;
  17980. t['thalfinalarabic'] = 0xFEAC;
  17981. t['thanthakhatlowleftthai'] = 0xF898;
  17982. t['thanthakhatlowrightthai'] = 0xF897;
  17983. t['thanthakhatthai'] = 0x0E4C;
  17984. t['thanthakhatupperleftthai'] = 0xF896;
  17985. t['theharabic'] = 0x062B;
  17986. t['thehfinalarabic'] = 0xFE9A;
  17987. t['thehinitialarabic'] = 0xFE9B;
  17988. t['thehmedialarabic'] = 0xFE9C;
  17989. t['thereexists'] = 0x2203;
  17990. t['therefore'] = 0x2234;
  17991. t['theta'] = 0x03B8;
  17992. t['theta1'] = 0x03D1;
  17993. t['thetasymbolgreek'] = 0x03D1;
  17994. t['thieuthacirclekorean'] = 0x3279;
  17995. t['thieuthaparenkorean'] = 0x3219;
  17996. t['thieuthcirclekorean'] = 0x326B;
  17997. t['thieuthkorean'] = 0x314C;
  17998. t['thieuthparenkorean'] = 0x320B;
  17999. t['thirteencircle'] = 0x246C;
  18000. t['thirteenparen'] = 0x2480;
  18001. t['thirteenperiod'] = 0x2494;
  18002. t['thonangmonthothai'] = 0x0E11;
  18003. t['thook'] = 0x01AD;
  18004. t['thophuthaothai'] = 0x0E12;
  18005. t['thorn'] = 0x00FE;
  18006. t['thothahanthai'] = 0x0E17;
  18007. t['thothanthai'] = 0x0E10;
  18008. t['thothongthai'] = 0x0E18;
  18009. t['thothungthai'] = 0x0E16;
  18010. t['thousandcyrillic'] = 0x0482;
  18011. t['thousandsseparatorarabic'] = 0x066C;
  18012. t['thousandsseparatorpersian'] = 0x066C;
  18013. t['three'] = 0x0033;
  18014. t['threearabic'] = 0x0663;
  18015. t['threebengali'] = 0x09E9;
  18016. t['threecircle'] = 0x2462;
  18017. t['threecircleinversesansserif'] = 0x278C;
  18018. t['threedeva'] = 0x0969;
  18019. t['threeeighths'] = 0x215C;
  18020. t['threegujarati'] = 0x0AE9;
  18021. t['threegurmukhi'] = 0x0A69;
  18022. t['threehackarabic'] = 0x0663;
  18023. t['threehangzhou'] = 0x3023;
  18024. t['threeideographicparen'] = 0x3222;
  18025. t['threeinferior'] = 0x2083;
  18026. t['threemonospace'] = 0xFF13;
  18027. t['threenumeratorbengali'] = 0x09F6;
  18028. t['threeoldstyle'] = 0xF733;
  18029. t['threeparen'] = 0x2476;
  18030. t['threeperiod'] = 0x248A;
  18031. t['threepersian'] = 0x06F3;
  18032. t['threequarters'] = 0x00BE;
  18033. t['threequartersemdash'] = 0xF6DE;
  18034. t['threeroman'] = 0x2172;
  18035. t['threesuperior'] = 0x00B3;
  18036. t['threethai'] = 0x0E53;
  18037. t['thzsquare'] = 0x3394;
  18038. t['tihiragana'] = 0x3061;
  18039. t['tikatakana'] = 0x30C1;
  18040. t['tikatakanahalfwidth'] = 0xFF81;
  18041. t['tikeutacirclekorean'] = 0x3270;
  18042. t['tikeutaparenkorean'] = 0x3210;
  18043. t['tikeutcirclekorean'] = 0x3262;
  18044. t['tikeutkorean'] = 0x3137;
  18045. t['tikeutparenkorean'] = 0x3202;
  18046. t['tilde'] = 0x02DC;
  18047. t['tildebelowcmb'] = 0x0330;
  18048. t['tildecmb'] = 0x0303;
  18049. t['tildecomb'] = 0x0303;
  18050. t['tildedoublecmb'] = 0x0360;
  18051. t['tildeoperator'] = 0x223C;
  18052. t['tildeoverlaycmb'] = 0x0334;
  18053. t['tildeverticalcmb'] = 0x033E;
  18054. t['timescircle'] = 0x2297;
  18055. t['tipehahebrew'] = 0x0596;
  18056. t['tipehalefthebrew'] = 0x0596;
  18057. t['tippigurmukhi'] = 0x0A70;
  18058. t['titlocyrilliccmb'] = 0x0483;
  18059. t['tiwnarmenian'] = 0x057F;
  18060. t['tlinebelow'] = 0x1E6F;
  18061. t['tmonospace'] = 0xFF54;
  18062. t['toarmenian'] = 0x0569;
  18063. t['tohiragana'] = 0x3068;
  18064. t['tokatakana'] = 0x30C8;
  18065. t['tokatakanahalfwidth'] = 0xFF84;
  18066. t['tonebarextrahighmod'] = 0x02E5;
  18067. t['tonebarextralowmod'] = 0x02E9;
  18068. t['tonebarhighmod'] = 0x02E6;
  18069. t['tonebarlowmod'] = 0x02E8;
  18070. t['tonebarmidmod'] = 0x02E7;
  18071. t['tonefive'] = 0x01BD;
  18072. t['tonesix'] = 0x0185;
  18073. t['tonetwo'] = 0x01A8;
  18074. t['tonos'] = 0x0384;
  18075. t['tonsquare'] = 0x3327;
  18076. t['topatakthai'] = 0x0E0F;
  18077. t['tortoiseshellbracketleft'] = 0x3014;
  18078. t['tortoiseshellbracketleftsmall'] = 0xFE5D;
  18079. t['tortoiseshellbracketleftvertical'] = 0xFE39;
  18080. t['tortoiseshellbracketright'] = 0x3015;
  18081. t['tortoiseshellbracketrightsmall'] = 0xFE5E;
  18082. t['tortoiseshellbracketrightvertical'] = 0xFE3A;
  18083. t['totaothai'] = 0x0E15;
  18084. t['tpalatalhook'] = 0x01AB;
  18085. t['tparen'] = 0x24AF;
  18086. t['trademark'] = 0x2122;
  18087. t['trademarksans'] = 0xF8EA;
  18088. t['trademarkserif'] = 0xF6DB;
  18089. t['tretroflexhook'] = 0x0288;
  18090. t['triagdn'] = 0x25BC;
  18091. t['triaglf'] = 0x25C4;
  18092. t['triagrt'] = 0x25BA;
  18093. t['triagup'] = 0x25B2;
  18094. t['ts'] = 0x02A6;
  18095. t['tsadi'] = 0x05E6;
  18096. t['tsadidagesh'] = 0xFB46;
  18097. t['tsadidageshhebrew'] = 0xFB46;
  18098. t['tsadihebrew'] = 0x05E6;
  18099. t['tsecyrillic'] = 0x0446;
  18100. t['tsere'] = 0x05B5;
  18101. t['tsere12'] = 0x05B5;
  18102. t['tsere1e'] = 0x05B5;
  18103. t['tsere2b'] = 0x05B5;
  18104. t['tserehebrew'] = 0x05B5;
  18105. t['tserenarrowhebrew'] = 0x05B5;
  18106. t['tserequarterhebrew'] = 0x05B5;
  18107. t['tserewidehebrew'] = 0x05B5;
  18108. t['tshecyrillic'] = 0x045B;
  18109. t['tsuperior'] = 0xF6F3;
  18110. t['ttabengali'] = 0x099F;
  18111. t['ttadeva'] = 0x091F;
  18112. t['ttagujarati'] = 0x0A9F;
  18113. t['ttagurmukhi'] = 0x0A1F;
  18114. t['tteharabic'] = 0x0679;
  18115. t['ttehfinalarabic'] = 0xFB67;
  18116. t['ttehinitialarabic'] = 0xFB68;
  18117. t['ttehmedialarabic'] = 0xFB69;
  18118. t['tthabengali'] = 0x09A0;
  18119. t['tthadeva'] = 0x0920;
  18120. t['tthagujarati'] = 0x0AA0;
  18121. t['tthagurmukhi'] = 0x0A20;
  18122. t['tturned'] = 0x0287;
  18123. t['tuhiragana'] = 0x3064;
  18124. t['tukatakana'] = 0x30C4;
  18125. t['tukatakanahalfwidth'] = 0xFF82;
  18126. t['tusmallhiragana'] = 0x3063;
  18127. t['tusmallkatakana'] = 0x30C3;
  18128. t['tusmallkatakanahalfwidth'] = 0xFF6F;
  18129. t['twelvecircle'] = 0x246B;
  18130. t['twelveparen'] = 0x247F;
  18131. t['twelveperiod'] = 0x2493;
  18132. t['twelveroman'] = 0x217B;
  18133. t['twentycircle'] = 0x2473;
  18134. t['twentyhangzhou'] = 0x5344;
  18135. t['twentyparen'] = 0x2487;
  18136. t['twentyperiod'] = 0x249B;
  18137. t['two'] = 0x0032;
  18138. t['twoarabic'] = 0x0662;
  18139. t['twobengali'] = 0x09E8;
  18140. t['twocircle'] = 0x2461;
  18141. t['twocircleinversesansserif'] = 0x278B;
  18142. t['twodeva'] = 0x0968;
  18143. t['twodotenleader'] = 0x2025;
  18144. t['twodotleader'] = 0x2025;
  18145. t['twodotleadervertical'] = 0xFE30;
  18146. t['twogujarati'] = 0x0AE8;
  18147. t['twogurmukhi'] = 0x0A68;
  18148. t['twohackarabic'] = 0x0662;
  18149. t['twohangzhou'] = 0x3022;
  18150. t['twoideographicparen'] = 0x3221;
  18151. t['twoinferior'] = 0x2082;
  18152. t['twomonospace'] = 0xFF12;
  18153. t['twonumeratorbengali'] = 0x09F5;
  18154. t['twooldstyle'] = 0xF732;
  18155. t['twoparen'] = 0x2475;
  18156. t['twoperiod'] = 0x2489;
  18157. t['twopersian'] = 0x06F2;
  18158. t['tworoman'] = 0x2171;
  18159. t['twostroke'] = 0x01BB;
  18160. t['twosuperior'] = 0x00B2;
  18161. t['twothai'] = 0x0E52;
  18162. t['twothirds'] = 0x2154;
  18163. t['u'] = 0x0075;
  18164. t['uacute'] = 0x00FA;
  18165. t['ubar'] = 0x0289;
  18166. t['ubengali'] = 0x0989;
  18167. t['ubopomofo'] = 0x3128;
  18168. t['ubreve'] = 0x016D;
  18169. t['ucaron'] = 0x01D4;
  18170. t['ucircle'] = 0x24E4;
  18171. t['ucircumflex'] = 0x00FB;
  18172. t['ucircumflexbelow'] = 0x1E77;
  18173. t['ucyrillic'] = 0x0443;
  18174. t['udattadeva'] = 0x0951;
  18175. t['udblacute'] = 0x0171;
  18176. t['udblgrave'] = 0x0215;
  18177. t['udeva'] = 0x0909;
  18178. t['udieresis'] = 0x00FC;
  18179. t['udieresisacute'] = 0x01D8;
  18180. t['udieresisbelow'] = 0x1E73;
  18181. t['udieresiscaron'] = 0x01DA;
  18182. t['udieresiscyrillic'] = 0x04F1;
  18183. t['udieresisgrave'] = 0x01DC;
  18184. t['udieresismacron'] = 0x01D6;
  18185. t['udotbelow'] = 0x1EE5;
  18186. t['ugrave'] = 0x00F9;
  18187. t['ugujarati'] = 0x0A89;
  18188. t['ugurmukhi'] = 0x0A09;
  18189. t['uhiragana'] = 0x3046;
  18190. t['uhookabove'] = 0x1EE7;
  18191. t['uhorn'] = 0x01B0;
  18192. t['uhornacute'] = 0x1EE9;
  18193. t['uhorndotbelow'] = 0x1EF1;
  18194. t['uhorngrave'] = 0x1EEB;
  18195. t['uhornhookabove'] = 0x1EED;
  18196. t['uhorntilde'] = 0x1EEF;
  18197. t['uhungarumlaut'] = 0x0171;
  18198. t['uhungarumlautcyrillic'] = 0x04F3;
  18199. t['uinvertedbreve'] = 0x0217;
  18200. t['ukatakana'] = 0x30A6;
  18201. t['ukatakanahalfwidth'] = 0xFF73;
  18202. t['ukcyrillic'] = 0x0479;
  18203. t['ukorean'] = 0x315C;
  18204. t['umacron'] = 0x016B;
  18205. t['umacroncyrillic'] = 0x04EF;
  18206. t['umacrondieresis'] = 0x1E7B;
  18207. t['umatragurmukhi'] = 0x0A41;
  18208. t['umonospace'] = 0xFF55;
  18209. t['underscore'] = 0x005F;
  18210. t['underscoredbl'] = 0x2017;
  18211. t['underscoremonospace'] = 0xFF3F;
  18212. t['underscorevertical'] = 0xFE33;
  18213. t['underscorewavy'] = 0xFE4F;
  18214. t['union'] = 0x222A;
  18215. t['universal'] = 0x2200;
  18216. t['uogonek'] = 0x0173;
  18217. t['uparen'] = 0x24B0;
  18218. t['upblock'] = 0x2580;
  18219. t['upperdothebrew'] = 0x05C4;
  18220. t['upsilon'] = 0x03C5;
  18221. t['upsilondieresis'] = 0x03CB;
  18222. t['upsilondieresistonos'] = 0x03B0;
  18223. t['upsilonlatin'] = 0x028A;
  18224. t['upsilontonos'] = 0x03CD;
  18225. t['uptackbelowcmb'] = 0x031D;
  18226. t['uptackmod'] = 0x02D4;
  18227. t['uragurmukhi'] = 0x0A73;
  18228. t['uring'] = 0x016F;
  18229. t['ushortcyrillic'] = 0x045E;
  18230. t['usmallhiragana'] = 0x3045;
  18231. t['usmallkatakana'] = 0x30A5;
  18232. t['usmallkatakanahalfwidth'] = 0xFF69;
  18233. t['ustraightcyrillic'] = 0x04AF;
  18234. t['ustraightstrokecyrillic'] = 0x04B1;
  18235. t['utilde'] = 0x0169;
  18236. t['utildeacute'] = 0x1E79;
  18237. t['utildebelow'] = 0x1E75;
  18238. t['uubengali'] = 0x098A;
  18239. t['uudeva'] = 0x090A;
  18240. t['uugujarati'] = 0x0A8A;
  18241. t['uugurmukhi'] = 0x0A0A;
  18242. t['uumatragurmukhi'] = 0x0A42;
  18243. t['uuvowelsignbengali'] = 0x09C2;
  18244. t['uuvowelsigndeva'] = 0x0942;
  18245. t['uuvowelsigngujarati'] = 0x0AC2;
  18246. t['uvowelsignbengali'] = 0x09C1;
  18247. t['uvowelsigndeva'] = 0x0941;
  18248. t['uvowelsigngujarati'] = 0x0AC1;
  18249. t['v'] = 0x0076;
  18250. t['vadeva'] = 0x0935;
  18251. t['vagujarati'] = 0x0AB5;
  18252. t['vagurmukhi'] = 0x0A35;
  18253. t['vakatakana'] = 0x30F7;
  18254. t['vav'] = 0x05D5;
  18255. t['vavdagesh'] = 0xFB35;
  18256. t['vavdagesh65'] = 0xFB35;
  18257. t['vavdageshhebrew'] = 0xFB35;
  18258. t['vavhebrew'] = 0x05D5;
  18259. t['vavholam'] = 0xFB4B;
  18260. t['vavholamhebrew'] = 0xFB4B;
  18261. t['vavvavhebrew'] = 0x05F0;
  18262. t['vavyodhebrew'] = 0x05F1;
  18263. t['vcircle'] = 0x24E5;
  18264. t['vdotbelow'] = 0x1E7F;
  18265. t['vecyrillic'] = 0x0432;
  18266. t['veharabic'] = 0x06A4;
  18267. t['vehfinalarabic'] = 0xFB6B;
  18268. t['vehinitialarabic'] = 0xFB6C;
  18269. t['vehmedialarabic'] = 0xFB6D;
  18270. t['vekatakana'] = 0x30F9;
  18271. t['venus'] = 0x2640;
  18272. t['verticalbar'] = 0x007C;
  18273. t['verticallineabovecmb'] = 0x030D;
  18274. t['verticallinebelowcmb'] = 0x0329;
  18275. t['verticallinelowmod'] = 0x02CC;
  18276. t['verticallinemod'] = 0x02C8;
  18277. t['vewarmenian'] = 0x057E;
  18278. t['vhook'] = 0x028B;
  18279. t['vikatakana'] = 0x30F8;
  18280. t['viramabengali'] = 0x09CD;
  18281. t['viramadeva'] = 0x094D;
  18282. t['viramagujarati'] = 0x0ACD;
  18283. t['visargabengali'] = 0x0983;
  18284. t['visargadeva'] = 0x0903;
  18285. t['visargagujarati'] = 0x0A83;
  18286. t['vmonospace'] = 0xFF56;
  18287. t['voarmenian'] = 0x0578;
  18288. t['voicediterationhiragana'] = 0x309E;
  18289. t['voicediterationkatakana'] = 0x30FE;
  18290. t['voicedmarkkana'] = 0x309B;
  18291. t['voicedmarkkanahalfwidth'] = 0xFF9E;
  18292. t['vokatakana'] = 0x30FA;
  18293. t['vparen'] = 0x24B1;
  18294. t['vtilde'] = 0x1E7D;
  18295. t['vturned'] = 0x028C;
  18296. t['vuhiragana'] = 0x3094;
  18297. t['vukatakana'] = 0x30F4;
  18298. t['w'] = 0x0077;
  18299. t['wacute'] = 0x1E83;
  18300. t['waekorean'] = 0x3159;
  18301. t['wahiragana'] = 0x308F;
  18302. t['wakatakana'] = 0x30EF;
  18303. t['wakatakanahalfwidth'] = 0xFF9C;
  18304. t['wakorean'] = 0x3158;
  18305. t['wasmallhiragana'] = 0x308E;
  18306. t['wasmallkatakana'] = 0x30EE;
  18307. t['wattosquare'] = 0x3357;
  18308. t['wavedash'] = 0x301C;
  18309. t['wavyunderscorevertical'] = 0xFE34;
  18310. t['wawarabic'] = 0x0648;
  18311. t['wawfinalarabic'] = 0xFEEE;
  18312. t['wawhamzaabovearabic'] = 0x0624;
  18313. t['wawhamzaabovefinalarabic'] = 0xFE86;
  18314. t['wbsquare'] = 0x33DD;
  18315. t['wcircle'] = 0x24E6;
  18316. t['wcircumflex'] = 0x0175;
  18317. t['wdieresis'] = 0x1E85;
  18318. t['wdotaccent'] = 0x1E87;
  18319. t['wdotbelow'] = 0x1E89;
  18320. t['wehiragana'] = 0x3091;
  18321. t['weierstrass'] = 0x2118;
  18322. t['wekatakana'] = 0x30F1;
  18323. t['wekorean'] = 0x315E;
  18324. t['weokorean'] = 0x315D;
  18325. t['wgrave'] = 0x1E81;
  18326. t['whitebullet'] = 0x25E6;
  18327. t['whitecircle'] = 0x25CB;
  18328. t['whitecircleinverse'] = 0x25D9;
  18329. t['whitecornerbracketleft'] = 0x300E;
  18330. t['whitecornerbracketleftvertical'] = 0xFE43;
  18331. t['whitecornerbracketright'] = 0x300F;
  18332. t['whitecornerbracketrightvertical'] = 0xFE44;
  18333. t['whitediamond'] = 0x25C7;
  18334. t['whitediamondcontainingblacksmalldiamond'] = 0x25C8;
  18335. t['whitedownpointingsmalltriangle'] = 0x25BF;
  18336. t['whitedownpointingtriangle'] = 0x25BD;
  18337. t['whiteleftpointingsmalltriangle'] = 0x25C3;
  18338. t['whiteleftpointingtriangle'] = 0x25C1;
  18339. t['whitelenticularbracketleft'] = 0x3016;
  18340. t['whitelenticularbracketright'] = 0x3017;
  18341. t['whiterightpointingsmalltriangle'] = 0x25B9;
  18342. t['whiterightpointingtriangle'] = 0x25B7;
  18343. t['whitesmallsquare'] = 0x25AB;
  18344. t['whitesmilingface'] = 0x263A;
  18345. t['whitesquare'] = 0x25A1;
  18346. t['whitestar'] = 0x2606;
  18347. t['whitetelephone'] = 0x260F;
  18348. t['whitetortoiseshellbracketleft'] = 0x3018;
  18349. t['whitetortoiseshellbracketright'] = 0x3019;
  18350. t['whiteuppointingsmalltriangle'] = 0x25B5;
  18351. t['whiteuppointingtriangle'] = 0x25B3;
  18352. t['wihiragana'] = 0x3090;
  18353. t['wikatakana'] = 0x30F0;
  18354. t['wikorean'] = 0x315F;
  18355. t['wmonospace'] = 0xFF57;
  18356. t['wohiragana'] = 0x3092;
  18357. t['wokatakana'] = 0x30F2;
  18358. t['wokatakanahalfwidth'] = 0xFF66;
  18359. t['won'] = 0x20A9;
  18360. t['wonmonospace'] = 0xFFE6;
  18361. t['wowaenthai'] = 0x0E27;
  18362. t['wparen'] = 0x24B2;
  18363. t['wring'] = 0x1E98;
  18364. t['wsuperior'] = 0x02B7;
  18365. t['wturned'] = 0x028D;
  18366. t['wynn'] = 0x01BF;
  18367. t['x'] = 0x0078;
  18368. t['xabovecmb'] = 0x033D;
  18369. t['xbopomofo'] = 0x3112;
  18370. t['xcircle'] = 0x24E7;
  18371. t['xdieresis'] = 0x1E8D;
  18372. t['xdotaccent'] = 0x1E8B;
  18373. t['xeharmenian'] = 0x056D;
  18374. t['xi'] = 0x03BE;
  18375. t['xmonospace'] = 0xFF58;
  18376. t['xparen'] = 0x24B3;
  18377. t['xsuperior'] = 0x02E3;
  18378. t['y'] = 0x0079;
  18379. t['yaadosquare'] = 0x334E;
  18380. t['yabengali'] = 0x09AF;
  18381. t['yacute'] = 0x00FD;
  18382. t['yadeva'] = 0x092F;
  18383. t['yaekorean'] = 0x3152;
  18384. t['yagujarati'] = 0x0AAF;
  18385. t['yagurmukhi'] = 0x0A2F;
  18386. t['yahiragana'] = 0x3084;
  18387. t['yakatakana'] = 0x30E4;
  18388. t['yakatakanahalfwidth'] = 0xFF94;
  18389. t['yakorean'] = 0x3151;
  18390. t['yamakkanthai'] = 0x0E4E;
  18391. t['yasmallhiragana'] = 0x3083;
  18392. t['yasmallkatakana'] = 0x30E3;
  18393. t['yasmallkatakanahalfwidth'] = 0xFF6C;
  18394. t['yatcyrillic'] = 0x0463;
  18395. t['ycircle'] = 0x24E8;
  18396. t['ycircumflex'] = 0x0177;
  18397. t['ydieresis'] = 0x00FF;
  18398. t['ydotaccent'] = 0x1E8F;
  18399. t['ydotbelow'] = 0x1EF5;
  18400. t['yeharabic'] = 0x064A;
  18401. t['yehbarreearabic'] = 0x06D2;
  18402. t['yehbarreefinalarabic'] = 0xFBAF;
  18403. t['yehfinalarabic'] = 0xFEF2;
  18404. t['yehhamzaabovearabic'] = 0x0626;
  18405. t['yehhamzaabovefinalarabic'] = 0xFE8A;
  18406. t['yehhamzaaboveinitialarabic'] = 0xFE8B;
  18407. t['yehhamzaabovemedialarabic'] = 0xFE8C;
  18408. t['yehinitialarabic'] = 0xFEF3;
  18409. t['yehmedialarabic'] = 0xFEF4;
  18410. t['yehmeeminitialarabic'] = 0xFCDD;
  18411. t['yehmeemisolatedarabic'] = 0xFC58;
  18412. t['yehnoonfinalarabic'] = 0xFC94;
  18413. t['yehthreedotsbelowarabic'] = 0x06D1;
  18414. t['yekorean'] = 0x3156;
  18415. t['yen'] = 0x00A5;
  18416. t['yenmonospace'] = 0xFFE5;
  18417. t['yeokorean'] = 0x3155;
  18418. t['yeorinhieuhkorean'] = 0x3186;
  18419. t['yerahbenyomohebrew'] = 0x05AA;
  18420. t['yerahbenyomolefthebrew'] = 0x05AA;
  18421. t['yericyrillic'] = 0x044B;
  18422. t['yerudieresiscyrillic'] = 0x04F9;
  18423. t['yesieungkorean'] = 0x3181;
  18424. t['yesieungpansioskorean'] = 0x3183;
  18425. t['yesieungsioskorean'] = 0x3182;
  18426. t['yetivhebrew'] = 0x059A;
  18427. t['ygrave'] = 0x1EF3;
  18428. t['yhook'] = 0x01B4;
  18429. t['yhookabove'] = 0x1EF7;
  18430. t['yiarmenian'] = 0x0575;
  18431. t['yicyrillic'] = 0x0457;
  18432. t['yikorean'] = 0x3162;
  18433. t['yinyang'] = 0x262F;
  18434. t['yiwnarmenian'] = 0x0582;
  18435. t['ymonospace'] = 0xFF59;
  18436. t['yod'] = 0x05D9;
  18437. t['yoddagesh'] = 0xFB39;
  18438. t['yoddageshhebrew'] = 0xFB39;
  18439. t['yodhebrew'] = 0x05D9;
  18440. t['yodyodhebrew'] = 0x05F2;
  18441. t['yodyodpatahhebrew'] = 0xFB1F;
  18442. t['yohiragana'] = 0x3088;
  18443. t['yoikorean'] = 0x3189;
  18444. t['yokatakana'] = 0x30E8;
  18445. t['yokatakanahalfwidth'] = 0xFF96;
  18446. t['yokorean'] = 0x315B;
  18447. t['yosmallhiragana'] = 0x3087;
  18448. t['yosmallkatakana'] = 0x30E7;
  18449. t['yosmallkatakanahalfwidth'] = 0xFF6E;
  18450. t['yotgreek'] = 0x03F3;
  18451. t['yoyaekorean'] = 0x3188;
  18452. t['yoyakorean'] = 0x3187;
  18453. t['yoyakthai'] = 0x0E22;
  18454. t['yoyingthai'] = 0x0E0D;
  18455. t['yparen'] = 0x24B4;
  18456. t['ypogegrammeni'] = 0x037A;
  18457. t['ypogegrammenigreekcmb'] = 0x0345;
  18458. t['yr'] = 0x01A6;
  18459. t['yring'] = 0x1E99;
  18460. t['ysuperior'] = 0x02B8;
  18461. t['ytilde'] = 0x1EF9;
  18462. t['yturned'] = 0x028E;
  18463. t['yuhiragana'] = 0x3086;
  18464. t['yuikorean'] = 0x318C;
  18465. t['yukatakana'] = 0x30E6;
  18466. t['yukatakanahalfwidth'] = 0xFF95;
  18467. t['yukorean'] = 0x3160;
  18468. t['yusbigcyrillic'] = 0x046B;
  18469. t['yusbigiotifiedcyrillic'] = 0x046D;
  18470. t['yuslittlecyrillic'] = 0x0467;
  18471. t['yuslittleiotifiedcyrillic'] = 0x0469;
  18472. t['yusmallhiragana'] = 0x3085;
  18473. t['yusmallkatakana'] = 0x30E5;
  18474. t['yusmallkatakanahalfwidth'] = 0xFF6D;
  18475. t['yuyekorean'] = 0x318B;
  18476. t['yuyeokorean'] = 0x318A;
  18477. t['yyabengali'] = 0x09DF;
  18478. t['yyadeva'] = 0x095F;
  18479. t['z'] = 0x007A;
  18480. t['zaarmenian'] = 0x0566;
  18481. t['zacute'] = 0x017A;
  18482. t['zadeva'] = 0x095B;
  18483. t['zagurmukhi'] = 0x0A5B;
  18484. t['zaharabic'] = 0x0638;
  18485. t['zahfinalarabic'] = 0xFEC6;
  18486. t['zahinitialarabic'] = 0xFEC7;
  18487. t['zahiragana'] = 0x3056;
  18488. t['zahmedialarabic'] = 0xFEC8;
  18489. t['zainarabic'] = 0x0632;
  18490. t['zainfinalarabic'] = 0xFEB0;
  18491. t['zakatakana'] = 0x30B6;
  18492. t['zaqefgadolhebrew'] = 0x0595;
  18493. t['zaqefqatanhebrew'] = 0x0594;
  18494. t['zarqahebrew'] = 0x0598;
  18495. t['zayin'] = 0x05D6;
  18496. t['zayindagesh'] = 0xFB36;
  18497. t['zayindageshhebrew'] = 0xFB36;
  18498. t['zayinhebrew'] = 0x05D6;
  18499. t['zbopomofo'] = 0x3117;
  18500. t['zcaron'] = 0x017E;
  18501. t['zcircle'] = 0x24E9;
  18502. t['zcircumflex'] = 0x1E91;
  18503. t['zcurl'] = 0x0291;
  18504. t['zdot'] = 0x017C;
  18505. t['zdotaccent'] = 0x017C;
  18506. t['zdotbelow'] = 0x1E93;
  18507. t['zecyrillic'] = 0x0437;
  18508. t['zedescendercyrillic'] = 0x0499;
  18509. t['zedieresiscyrillic'] = 0x04DF;
  18510. t['zehiragana'] = 0x305C;
  18511. t['zekatakana'] = 0x30BC;
  18512. t['zero'] = 0x0030;
  18513. t['zeroarabic'] = 0x0660;
  18514. t['zerobengali'] = 0x09E6;
  18515. t['zerodeva'] = 0x0966;
  18516. t['zerogujarati'] = 0x0AE6;
  18517. t['zerogurmukhi'] = 0x0A66;
  18518. t['zerohackarabic'] = 0x0660;
  18519. t['zeroinferior'] = 0x2080;
  18520. t['zeromonospace'] = 0xFF10;
  18521. t['zerooldstyle'] = 0xF730;
  18522. t['zeropersian'] = 0x06F0;
  18523. t['zerosuperior'] = 0x2070;
  18524. t['zerothai'] = 0x0E50;
  18525. t['zerowidthjoiner'] = 0xFEFF;
  18526. t['zerowidthnonjoiner'] = 0x200C;
  18527. t['zerowidthspace'] = 0x200B;
  18528. t['zeta'] = 0x03B6;
  18529. t['zhbopomofo'] = 0x3113;
  18530. t['zhearmenian'] = 0x056A;
  18531. t['zhebrevecyrillic'] = 0x04C2;
  18532. t['zhecyrillic'] = 0x0436;
  18533. t['zhedescendercyrillic'] = 0x0497;
  18534. t['zhedieresiscyrillic'] = 0x04DD;
  18535. t['zihiragana'] = 0x3058;
  18536. t['zikatakana'] = 0x30B8;
  18537. t['zinorhebrew'] = 0x05AE;
  18538. t['zlinebelow'] = 0x1E95;
  18539. t['zmonospace'] = 0xFF5A;
  18540. t['zohiragana'] = 0x305E;
  18541. t['zokatakana'] = 0x30BE;
  18542. t['zparen'] = 0x24B5;
  18543. t['zretroflexhook'] = 0x0290;
  18544. t['zstroke'] = 0x01B6;
  18545. t['zuhiragana'] = 0x305A;
  18546. t['zukatakana'] = 0x30BA;
  18547. t['.notdef'] = 0x0000;
  18548. t['angbracketleftbig'] = 0x2329;
  18549. t['angbracketleftBig'] = 0x2329;
  18550. t['angbracketleftbigg'] = 0x2329;
  18551. t['angbracketleftBigg'] = 0x2329;
  18552. t['angbracketrightBig'] = 0x232A;
  18553. t['angbracketrightbig'] = 0x232A;
  18554. t['angbracketrightBigg'] = 0x232A;
  18555. t['angbracketrightbigg'] = 0x232A;
  18556. t['arrowhookleft'] = 0x21AA;
  18557. t['arrowhookright'] = 0x21A9;
  18558. t['arrowlefttophalf'] = 0x21BC;
  18559. t['arrowleftbothalf'] = 0x21BD;
  18560. t['arrownortheast'] = 0x2197;
  18561. t['arrownorthwest'] = 0x2196;
  18562. t['arrowrighttophalf'] = 0x21C0;
  18563. t['arrowrightbothalf'] = 0x21C1;
  18564. t['arrowsoutheast'] = 0x2198;
  18565. t['arrowsouthwest'] = 0x2199;
  18566. t['backslashbig'] = 0x2216;
  18567. t['backslashBig'] = 0x2216;
  18568. t['backslashBigg'] = 0x2216;
  18569. t['backslashbigg'] = 0x2216;
  18570. t['bardbl'] = 0x2016;
  18571. t['bracehtipdownleft'] = 0xFE37;
  18572. t['bracehtipdownright'] = 0xFE37;
  18573. t['bracehtipupleft'] = 0xFE38;
  18574. t['bracehtipupright'] = 0xFE38;
  18575. t['braceleftBig'] = 0x007B;
  18576. t['braceleftbig'] = 0x007B;
  18577. t['braceleftbigg'] = 0x007B;
  18578. t['braceleftBigg'] = 0x007B;
  18579. t['bracerightBig'] = 0x007D;
  18580. t['bracerightbig'] = 0x007D;
  18581. t['bracerightbigg'] = 0x007D;
  18582. t['bracerightBigg'] = 0x007D;
  18583. t['bracketleftbig'] = 0x005B;
  18584. t['bracketleftBig'] = 0x005B;
  18585. t['bracketleftbigg'] = 0x005B;
  18586. t['bracketleftBigg'] = 0x005B;
  18587. t['bracketrightBig'] = 0x005D;
  18588. t['bracketrightbig'] = 0x005D;
  18589. t['bracketrightbigg'] = 0x005D;
  18590. t['bracketrightBigg'] = 0x005D;
  18591. t['ceilingleftbig'] = 0x2308;
  18592. t['ceilingleftBig'] = 0x2308;
  18593. t['ceilingleftBigg'] = 0x2308;
  18594. t['ceilingleftbigg'] = 0x2308;
  18595. t['ceilingrightbig'] = 0x2309;
  18596. t['ceilingrightBig'] = 0x2309;
  18597. t['ceilingrightbigg'] = 0x2309;
  18598. t['ceilingrightBigg'] = 0x2309;
  18599. t['circledotdisplay'] = 0x2299;
  18600. t['circledottext'] = 0x2299;
  18601. t['circlemultiplydisplay'] = 0x2297;
  18602. t['circlemultiplytext'] = 0x2297;
  18603. t['circleplusdisplay'] = 0x2295;
  18604. t['circleplustext'] = 0x2295;
  18605. t['contintegraldisplay'] = 0x222E;
  18606. t['contintegraltext'] = 0x222E;
  18607. t['coproductdisplay'] = 0x2210;
  18608. t['coproducttext'] = 0x2210;
  18609. t['floorleftBig'] = 0x230A;
  18610. t['floorleftbig'] = 0x230A;
  18611. t['floorleftbigg'] = 0x230A;
  18612. t['floorleftBigg'] = 0x230A;
  18613. t['floorrightbig'] = 0x230B;
  18614. t['floorrightBig'] = 0x230B;
  18615. t['floorrightBigg'] = 0x230B;
  18616. t['floorrightbigg'] = 0x230B;
  18617. t['hatwide'] = 0x0302;
  18618. t['hatwider'] = 0x0302;
  18619. t['hatwidest'] = 0x0302;
  18620. t['intercal'] = 0x1D40;
  18621. t['integraldisplay'] = 0x222B;
  18622. t['integraltext'] = 0x222B;
  18623. t['intersectiondisplay'] = 0x22C2;
  18624. t['intersectiontext'] = 0x22C2;
  18625. t['logicalanddisplay'] = 0x2227;
  18626. t['logicalandtext'] = 0x2227;
  18627. t['logicalordisplay'] = 0x2228;
  18628. t['logicalortext'] = 0x2228;
  18629. t['parenleftBig'] = 0x0028;
  18630. t['parenleftbig'] = 0x0028;
  18631. t['parenleftBigg'] = 0x0028;
  18632. t['parenleftbigg'] = 0x0028;
  18633. t['parenrightBig'] = 0x0029;
  18634. t['parenrightbig'] = 0x0029;
  18635. t['parenrightBigg'] = 0x0029;
  18636. t['parenrightbigg'] = 0x0029;
  18637. t['prime'] = 0x2032;
  18638. t['productdisplay'] = 0x220F;
  18639. t['producttext'] = 0x220F;
  18640. t['radicalbig'] = 0x221A;
  18641. t['radicalBig'] = 0x221A;
  18642. t['radicalBigg'] = 0x221A;
  18643. t['radicalbigg'] = 0x221A;
  18644. t['radicalbt'] = 0x221A;
  18645. t['radicaltp'] = 0x221A;
  18646. t['radicalvertex'] = 0x221A;
  18647. t['slashbig'] = 0x002F;
  18648. t['slashBig'] = 0x002F;
  18649. t['slashBigg'] = 0x002F;
  18650. t['slashbigg'] = 0x002F;
  18651. t['summationdisplay'] = 0x2211;
  18652. t['summationtext'] = 0x2211;
  18653. t['tildewide'] = 0x02DC;
  18654. t['tildewider'] = 0x02DC;
  18655. t['tildewidest'] = 0x02DC;
  18656. t['uniondisplay'] = 0x22C3;
  18657. t['unionmultidisplay'] = 0x228E;
  18658. t['unionmultitext'] = 0x228E;
  18659. t['unionsqdisplay'] = 0x2294;
  18660. t['unionsqtext'] = 0x2294;
  18661. t['uniontext'] = 0x22C3;
  18662. t['vextenddouble'] = 0x2225;
  18663. t['vextendsingle'] = 0x2223;
  18664. });
  18665. var getDingbatsGlyphsUnicode = getLookupTableFactory(function (t) {
  18666. t['space'] = 0x0020;
  18667. t['a1'] = 0x2701;
  18668. t['a2'] = 0x2702;
  18669. t['a202'] = 0x2703;
  18670. t['a3'] = 0x2704;
  18671. t['a4'] = 0x260E;
  18672. t['a5'] = 0x2706;
  18673. t['a119'] = 0x2707;
  18674. t['a118'] = 0x2708;
  18675. t['a117'] = 0x2709;
  18676. t['a11'] = 0x261B;
  18677. t['a12'] = 0x261E;
  18678. t['a13'] = 0x270C;
  18679. t['a14'] = 0x270D;
  18680. t['a15'] = 0x270E;
  18681. t['a16'] = 0x270F;
  18682. t['a105'] = 0x2710;
  18683. t['a17'] = 0x2711;
  18684. t['a18'] = 0x2712;
  18685. t['a19'] = 0x2713;
  18686. t['a20'] = 0x2714;
  18687. t['a21'] = 0x2715;
  18688. t['a22'] = 0x2716;
  18689. t['a23'] = 0x2717;
  18690. t['a24'] = 0x2718;
  18691. t['a25'] = 0x2719;
  18692. t['a26'] = 0x271A;
  18693. t['a27'] = 0x271B;
  18694. t['a28'] = 0x271C;
  18695. t['a6'] = 0x271D;
  18696. t['a7'] = 0x271E;
  18697. t['a8'] = 0x271F;
  18698. t['a9'] = 0x2720;
  18699. t['a10'] = 0x2721;
  18700. t['a29'] = 0x2722;
  18701. t['a30'] = 0x2723;
  18702. t['a31'] = 0x2724;
  18703. t['a32'] = 0x2725;
  18704. t['a33'] = 0x2726;
  18705. t['a34'] = 0x2727;
  18706. t['a35'] = 0x2605;
  18707. t['a36'] = 0x2729;
  18708. t['a37'] = 0x272A;
  18709. t['a38'] = 0x272B;
  18710. t['a39'] = 0x272C;
  18711. t['a40'] = 0x272D;
  18712. t['a41'] = 0x272E;
  18713. t['a42'] = 0x272F;
  18714. t['a43'] = 0x2730;
  18715. t['a44'] = 0x2731;
  18716. t['a45'] = 0x2732;
  18717. t['a46'] = 0x2733;
  18718. t['a47'] = 0x2734;
  18719. t['a48'] = 0x2735;
  18720. t['a49'] = 0x2736;
  18721. t['a50'] = 0x2737;
  18722. t['a51'] = 0x2738;
  18723. t['a52'] = 0x2739;
  18724. t['a53'] = 0x273A;
  18725. t['a54'] = 0x273B;
  18726. t['a55'] = 0x273C;
  18727. t['a56'] = 0x273D;
  18728. t['a57'] = 0x273E;
  18729. t['a58'] = 0x273F;
  18730. t['a59'] = 0x2740;
  18731. t['a60'] = 0x2741;
  18732. t['a61'] = 0x2742;
  18733. t['a62'] = 0x2743;
  18734. t['a63'] = 0x2744;
  18735. t['a64'] = 0x2745;
  18736. t['a65'] = 0x2746;
  18737. t['a66'] = 0x2747;
  18738. t['a67'] = 0x2748;
  18739. t['a68'] = 0x2749;
  18740. t['a69'] = 0x274A;
  18741. t['a70'] = 0x274B;
  18742. t['a71'] = 0x25CF;
  18743. t['a72'] = 0x274D;
  18744. t['a73'] = 0x25A0;
  18745. t['a74'] = 0x274F;
  18746. t['a203'] = 0x2750;
  18747. t['a75'] = 0x2751;
  18748. t['a204'] = 0x2752;
  18749. t['a76'] = 0x25B2;
  18750. t['a77'] = 0x25BC;
  18751. t['a78'] = 0x25C6;
  18752. t['a79'] = 0x2756;
  18753. t['a81'] = 0x25D7;
  18754. t['a82'] = 0x2758;
  18755. t['a83'] = 0x2759;
  18756. t['a84'] = 0x275A;
  18757. t['a97'] = 0x275B;
  18758. t['a98'] = 0x275C;
  18759. t['a99'] = 0x275D;
  18760. t['a100'] = 0x275E;
  18761. t['a101'] = 0x2761;
  18762. t['a102'] = 0x2762;
  18763. t['a103'] = 0x2763;
  18764. t['a104'] = 0x2764;
  18765. t['a106'] = 0x2765;
  18766. t['a107'] = 0x2766;
  18767. t['a108'] = 0x2767;
  18768. t['a112'] = 0x2663;
  18769. t['a111'] = 0x2666;
  18770. t['a110'] = 0x2665;
  18771. t['a109'] = 0x2660;
  18772. t['a120'] = 0x2460;
  18773. t['a121'] = 0x2461;
  18774. t['a122'] = 0x2462;
  18775. t['a123'] = 0x2463;
  18776. t['a124'] = 0x2464;
  18777. t['a125'] = 0x2465;
  18778. t['a126'] = 0x2466;
  18779. t['a127'] = 0x2467;
  18780. t['a128'] = 0x2468;
  18781. t['a129'] = 0x2469;
  18782. t['a130'] = 0x2776;
  18783. t['a131'] = 0x2777;
  18784. t['a132'] = 0x2778;
  18785. t['a133'] = 0x2779;
  18786. t['a134'] = 0x277A;
  18787. t['a135'] = 0x277B;
  18788. t['a136'] = 0x277C;
  18789. t['a137'] = 0x277D;
  18790. t['a138'] = 0x277E;
  18791. t['a139'] = 0x277F;
  18792. t['a140'] = 0x2780;
  18793. t['a141'] = 0x2781;
  18794. t['a142'] = 0x2782;
  18795. t['a143'] = 0x2783;
  18796. t['a144'] = 0x2784;
  18797. t['a145'] = 0x2785;
  18798. t['a146'] = 0x2786;
  18799. t['a147'] = 0x2787;
  18800. t['a148'] = 0x2788;
  18801. t['a149'] = 0x2789;
  18802. t['a150'] = 0x278A;
  18803. t['a151'] = 0x278B;
  18804. t['a152'] = 0x278C;
  18805. t['a153'] = 0x278D;
  18806. t['a154'] = 0x278E;
  18807. t['a155'] = 0x278F;
  18808. t['a156'] = 0x2790;
  18809. t['a157'] = 0x2791;
  18810. t['a158'] = 0x2792;
  18811. t['a159'] = 0x2793;
  18812. t['a160'] = 0x2794;
  18813. t['a161'] = 0x2192;
  18814. t['a163'] = 0x2194;
  18815. t['a164'] = 0x2195;
  18816. t['a196'] = 0x2798;
  18817. t['a165'] = 0x2799;
  18818. t['a192'] = 0x279A;
  18819. t['a166'] = 0x279B;
  18820. t['a167'] = 0x279C;
  18821. t['a168'] = 0x279D;
  18822. t['a169'] = 0x279E;
  18823. t['a170'] = 0x279F;
  18824. t['a171'] = 0x27A0;
  18825. t['a172'] = 0x27A1;
  18826. t['a173'] = 0x27A2;
  18827. t['a162'] = 0x27A3;
  18828. t['a174'] = 0x27A4;
  18829. t['a175'] = 0x27A5;
  18830. t['a176'] = 0x27A6;
  18831. t['a177'] = 0x27A7;
  18832. t['a178'] = 0x27A8;
  18833. t['a179'] = 0x27A9;
  18834. t['a193'] = 0x27AA;
  18835. t['a180'] = 0x27AB;
  18836. t['a199'] = 0x27AC;
  18837. t['a181'] = 0x27AD;
  18838. t['a200'] = 0x27AE;
  18839. t['a182'] = 0x27AF;
  18840. t['a201'] = 0x27B1;
  18841. t['a183'] = 0x27B2;
  18842. t['a184'] = 0x27B3;
  18843. t['a197'] = 0x27B4;
  18844. t['a185'] = 0x27B5;
  18845. t['a194'] = 0x27B6;
  18846. t['a198'] = 0x27B7;
  18847. t['a186'] = 0x27B8;
  18848. t['a195'] = 0x27B9;
  18849. t['a187'] = 0x27BA;
  18850. t['a188'] = 0x27BB;
  18851. t['a189'] = 0x27BC;
  18852. t['a190'] = 0x27BD;
  18853. t['a191'] = 0x27BE;
  18854. t['a89'] = 0x2768;
  18855. t['a90'] = 0x2769;
  18856. t['a93'] = 0x276A;
  18857. t['a94'] = 0x276B;
  18858. t['a91'] = 0x276C;
  18859. t['a92'] = 0x276D;
  18860. t['a205'] = 0x276E;
  18861. t['a85'] = 0x276F;
  18862. t['a206'] = 0x2770;
  18863. t['a86'] = 0x2771;
  18864. t['a87'] = 0x2772;
  18865. t['a88'] = 0x2773;
  18866. t['a95'] = 0x2774;
  18867. t['a96'] = 0x2775;
  18868. t['.notdef'] = 0x0000;
  18869. });
  18870. exports.getGlyphsUnicode = getGlyphsUnicode;
  18871. exports.getDingbatsGlyphsUnicode = getDingbatsGlyphsUnicode;
  18872. /***/ }),
  18873. /* 9 */
  18874. /***/ (function(module, exports, __w_pdfjs_require__) {
  18875. "use strict";
  18876. /* WEBPACK VAR INJECTION */(function(module) {
  18877. var sharedUtil = __w_pdfjs_require__(0);
  18878. var corePrimitives = __w_pdfjs_require__(1);
  18879. var corePdfManager = __w_pdfjs_require__(42);
  18880. var UNSUPPORTED_FEATURES = sharedUtil.UNSUPPORTED_FEATURES;
  18881. var InvalidPDFException = sharedUtil.InvalidPDFException;
  18882. var MessageHandler = sharedUtil.MessageHandler;
  18883. var MissingPDFException = sharedUtil.MissingPDFException;
  18884. var UnexpectedResponseException = sharedUtil.UnexpectedResponseException;
  18885. var PasswordException = sharedUtil.PasswordException;
  18886. var UnknownErrorException = sharedUtil.UnknownErrorException;
  18887. var XRefParseException = sharedUtil.XRefParseException;
  18888. var arrayByteLength = sharedUtil.arrayByteLength;
  18889. var arraysToBytes = sharedUtil.arraysToBytes;
  18890. var assert = sharedUtil.assert;
  18891. var createPromiseCapability = sharedUtil.createPromiseCapability;
  18892. var error = sharedUtil.error;
  18893. var info = sharedUtil.info;
  18894. var warn = sharedUtil.warn;
  18895. var setVerbosityLevel = sharedUtil.setVerbosityLevel;
  18896. var Ref = corePrimitives.Ref;
  18897. var LocalPdfManager = corePdfManager.LocalPdfManager;
  18898. var NetworkPdfManager = corePdfManager.NetworkPdfManager;
  18899. var globalScope = sharedUtil.globalScope;
  18900. var WorkerTask = function WorkerTaskClosure() {
  18901. function WorkerTask(name) {
  18902. this.name = name;
  18903. this.terminated = false;
  18904. this._capability = createPromiseCapability();
  18905. }
  18906. WorkerTask.prototype = {
  18907. get finished() {
  18908. return this._capability.promise;
  18909. },
  18910. finish: function () {
  18911. this._capability.resolve();
  18912. },
  18913. terminate: function () {
  18914. this.terminated = true;
  18915. },
  18916. ensureNotTerminated: function () {
  18917. if (this.terminated) {
  18918. throw new Error('Worker task was terminated');
  18919. }
  18920. }
  18921. };
  18922. return WorkerTask;
  18923. }();
  18924. var PDFWorkerStream = function PDFWorkerStreamClosure() {
  18925. function PDFWorkerStream(params, msgHandler) {
  18926. this._queuedChunks = [];
  18927. var initialData = params.initialData;
  18928. if (initialData && initialData.length > 0) {
  18929. this._queuedChunks.push(initialData);
  18930. }
  18931. this._msgHandler = msgHandler;
  18932. this._isRangeSupported = !params.disableRange;
  18933. this._isStreamingSupported = !params.disableStream;
  18934. this._contentLength = params.length;
  18935. this._fullRequestReader = null;
  18936. this._rangeReaders = [];
  18937. msgHandler.on('OnDataRange', this._onReceiveData.bind(this));
  18938. msgHandler.on('OnDataProgress', this._onProgress.bind(this));
  18939. }
  18940. PDFWorkerStream.prototype = {
  18941. _onReceiveData: function PDFWorkerStream_onReceiveData(args) {
  18942. if (args.begin === undefined) {
  18943. if (this._fullRequestReader) {
  18944. this._fullRequestReader._enqueue(args.chunk);
  18945. } else {
  18946. this._queuedChunks.push(args.chunk);
  18947. }
  18948. } else {
  18949. var found = this._rangeReaders.some(function (rangeReader) {
  18950. if (rangeReader._begin !== args.begin) {
  18951. return false;
  18952. }
  18953. rangeReader._enqueue(args.chunk);
  18954. return true;
  18955. });
  18956. assert(found);
  18957. }
  18958. },
  18959. _onProgress: function PDFWorkerStream_onProgress(evt) {
  18960. if (this._rangeReaders.length > 0) {
  18961. var firstReader = this._rangeReaders[0];
  18962. if (firstReader.onProgress) {
  18963. firstReader.onProgress({ loaded: evt.loaded });
  18964. }
  18965. }
  18966. },
  18967. _removeRangeReader: function PDFWorkerStream_removeRangeReader(reader) {
  18968. var i = this._rangeReaders.indexOf(reader);
  18969. if (i >= 0) {
  18970. this._rangeReaders.splice(i, 1);
  18971. }
  18972. },
  18973. getFullReader: function PDFWorkerStream_getFullReader() {
  18974. assert(!this._fullRequestReader);
  18975. var queuedChunks = this._queuedChunks;
  18976. this._queuedChunks = null;
  18977. return new PDFWorkerStreamReader(this, queuedChunks);
  18978. },
  18979. getRangeReader: function PDFWorkerStream_getRangeReader(begin, end) {
  18980. var reader = new PDFWorkerStreamRangeReader(this, begin, end);
  18981. this._msgHandler.send('RequestDataRange', {
  18982. begin: begin,
  18983. end: end
  18984. });
  18985. this._rangeReaders.push(reader);
  18986. return reader;
  18987. },
  18988. cancelAllRequests: function PDFWorkerStream_cancelAllRequests(reason) {
  18989. if (this._fullRequestReader) {
  18990. this._fullRequestReader.cancel(reason);
  18991. }
  18992. var readers = this._rangeReaders.slice(0);
  18993. readers.forEach(function (rangeReader) {
  18994. rangeReader.cancel(reason);
  18995. });
  18996. }
  18997. };
  18998. function PDFWorkerStreamReader(stream, queuedChunks) {
  18999. this._stream = stream;
  19000. this._done = false;
  19001. this._queuedChunks = queuedChunks || [];
  19002. this._requests = [];
  19003. this._headersReady = Promise.resolve();
  19004. stream._fullRequestReader = this;
  19005. this.onProgress = null;
  19006. }
  19007. PDFWorkerStreamReader.prototype = {
  19008. _enqueue: function PDFWorkerStreamReader_enqueue(chunk) {
  19009. if (this._done) {
  19010. return;
  19011. }
  19012. if (this._requests.length > 0) {
  19013. var requestCapability = this._requests.shift();
  19014. requestCapability.resolve({
  19015. value: chunk,
  19016. done: false
  19017. });
  19018. return;
  19019. }
  19020. this._queuedChunks.push(chunk);
  19021. },
  19022. get headersReady() {
  19023. return this._headersReady;
  19024. },
  19025. get isRangeSupported() {
  19026. return this._stream._isRangeSupported;
  19027. },
  19028. get isStreamingSupported() {
  19029. return this._stream._isStreamingSupported;
  19030. },
  19031. get contentLength() {
  19032. return this._stream._contentLength;
  19033. },
  19034. read: function PDFWorkerStreamReader_read() {
  19035. if (this._queuedChunks.length > 0) {
  19036. var chunk = this._queuedChunks.shift();
  19037. return Promise.resolve({
  19038. value: chunk,
  19039. done: false
  19040. });
  19041. }
  19042. if (this._done) {
  19043. return Promise.resolve({
  19044. value: undefined,
  19045. done: true
  19046. });
  19047. }
  19048. var requestCapability = createPromiseCapability();
  19049. this._requests.push(requestCapability);
  19050. return requestCapability.promise;
  19051. },
  19052. cancel: function PDFWorkerStreamReader_cancel(reason) {
  19053. this._done = true;
  19054. this._requests.forEach(function (requestCapability) {
  19055. requestCapability.resolve({
  19056. value: undefined,
  19057. done: true
  19058. });
  19059. });
  19060. this._requests = [];
  19061. }
  19062. };
  19063. function PDFWorkerStreamRangeReader(stream, begin, end) {
  19064. this._stream = stream;
  19065. this._begin = begin;
  19066. this._end = end;
  19067. this._queuedChunk = null;
  19068. this._requests = [];
  19069. this._done = false;
  19070. this.onProgress = null;
  19071. }
  19072. PDFWorkerStreamRangeReader.prototype = {
  19073. _enqueue: function PDFWorkerStreamRangeReader_enqueue(chunk) {
  19074. if (this._done) {
  19075. return;
  19076. }
  19077. if (this._requests.length === 0) {
  19078. this._queuedChunk = chunk;
  19079. } else {
  19080. var requestsCapability = this._requests.shift();
  19081. requestsCapability.resolve({
  19082. value: chunk,
  19083. done: false
  19084. });
  19085. this._requests.forEach(function (requestCapability) {
  19086. requestCapability.resolve({
  19087. value: undefined,
  19088. done: true
  19089. });
  19090. });
  19091. this._requests = [];
  19092. }
  19093. this._done = true;
  19094. this._stream._removeRangeReader(this);
  19095. },
  19096. get isStreamingSupported() {
  19097. return false;
  19098. },
  19099. read: function PDFWorkerStreamRangeReader_read() {
  19100. if (this._queuedChunk) {
  19101. return Promise.resolve({
  19102. value: this._queuedChunk,
  19103. done: false
  19104. });
  19105. }
  19106. if (this._done) {
  19107. return Promise.resolve({
  19108. value: undefined,
  19109. done: true
  19110. });
  19111. }
  19112. var requestCapability = createPromiseCapability();
  19113. this._requests.push(requestCapability);
  19114. return requestCapability.promise;
  19115. },
  19116. cancel: function PDFWorkerStreamRangeReader_cancel(reason) {
  19117. this._done = true;
  19118. this._requests.forEach(function (requestCapability) {
  19119. requestCapability.resolve({
  19120. value: undefined,
  19121. done: true
  19122. });
  19123. });
  19124. this._requests = [];
  19125. this._stream._removeRangeReader(this);
  19126. }
  19127. };
  19128. return PDFWorkerStream;
  19129. }();
  19130. var PDFNetworkStream;
  19131. function setPDFNetworkStreamClass(cls) {
  19132. PDFNetworkStream = cls;
  19133. }
  19134. var WorkerMessageHandler = {
  19135. setup: function wphSetup(handler, port) {
  19136. var testMessageProcessed = false;
  19137. handler.on('test', function wphSetupTest(data) {
  19138. if (testMessageProcessed) {
  19139. return;
  19140. }
  19141. testMessageProcessed = true;
  19142. if (!(data instanceof Uint8Array)) {
  19143. handler.send('test', 'main', false);
  19144. return;
  19145. }
  19146. var supportTransfers = data[0] === 255;
  19147. handler.postMessageTransfers = supportTransfers;
  19148. var xhr = new XMLHttpRequest();
  19149. var responseExists = 'response' in xhr;
  19150. try {
  19151. xhr.responseType;
  19152. } catch (e) {
  19153. responseExists = false;
  19154. }
  19155. if (!responseExists) {
  19156. handler.send('test', false);
  19157. return;
  19158. }
  19159. handler.send('test', {
  19160. supportTypedArray: true,
  19161. supportTransfers: supportTransfers
  19162. });
  19163. });
  19164. handler.on('configure', function wphConfigure(data) {
  19165. setVerbosityLevel(data.verbosity);
  19166. });
  19167. handler.on('GetDocRequest', function wphSetupDoc(data) {
  19168. return WorkerMessageHandler.createDocumentHandler(data, port);
  19169. });
  19170. },
  19171. createDocumentHandler: function wphCreateDocumentHandler(docParams, port) {
  19172. var pdfManager;
  19173. var terminated = false;
  19174. var cancelXHRs = null;
  19175. var WorkerTasks = [];
  19176. var docId = docParams.docId;
  19177. var docBaseUrl = docParams.docBaseUrl;
  19178. var workerHandlerName = docParams.docId + '_worker';
  19179. var handler = new MessageHandler(workerHandlerName, docId, port);
  19180. handler.postMessageTransfers = docParams.postMessageTransfers;
  19181. function ensureNotTerminated() {
  19182. if (terminated) {
  19183. throw new Error('Worker was terminated');
  19184. }
  19185. }
  19186. function startWorkerTask(task) {
  19187. WorkerTasks.push(task);
  19188. }
  19189. function finishWorkerTask(task) {
  19190. task.finish();
  19191. var i = WorkerTasks.indexOf(task);
  19192. WorkerTasks.splice(i, 1);
  19193. }
  19194. function loadDocument(recoveryMode) {
  19195. var loadDocumentCapability = createPromiseCapability();
  19196. var parseSuccess = function parseSuccess() {
  19197. var numPagesPromise = pdfManager.ensureDoc('numPages');
  19198. var fingerprintPromise = pdfManager.ensureDoc('fingerprint');
  19199. var encryptedPromise = pdfManager.ensureXRef('encrypt');
  19200. Promise.all([
  19201. numPagesPromise,
  19202. fingerprintPromise,
  19203. encryptedPromise
  19204. ]).then(function onDocReady(results) {
  19205. var doc = {
  19206. numPages: results[0],
  19207. fingerprint: results[1],
  19208. encrypted: !!results[2]
  19209. };
  19210. loadDocumentCapability.resolve(doc);
  19211. }, parseFailure);
  19212. };
  19213. var parseFailure = function parseFailure(e) {
  19214. loadDocumentCapability.reject(e);
  19215. };
  19216. pdfManager.ensureDoc('checkHeader', []).then(function () {
  19217. pdfManager.ensureDoc('parseStartXRef', []).then(function () {
  19218. pdfManager.ensureDoc('parse', [recoveryMode]).then(parseSuccess, parseFailure);
  19219. }, parseFailure);
  19220. }, parseFailure);
  19221. return loadDocumentCapability.promise;
  19222. }
  19223. function getPdfManager(data, evaluatorOptions) {
  19224. var pdfManagerCapability = createPromiseCapability();
  19225. var pdfManager;
  19226. var source = data.source;
  19227. if (source.data) {
  19228. try {
  19229. pdfManager = new LocalPdfManager(docId, source.data, source.password, evaluatorOptions, docBaseUrl);
  19230. pdfManagerCapability.resolve(pdfManager);
  19231. } catch (ex) {
  19232. pdfManagerCapability.reject(ex);
  19233. }
  19234. return pdfManagerCapability.promise;
  19235. }
  19236. var pdfStream;
  19237. try {
  19238. if (source.chunkedViewerLoading) {
  19239. pdfStream = new PDFWorkerStream(source, handler);
  19240. } else {
  19241. assert(PDFNetworkStream, 'pdfjs/core/network module is not loaded');
  19242. pdfStream = new PDFNetworkStream(data);
  19243. }
  19244. } catch (ex) {
  19245. pdfManagerCapability.reject(ex);
  19246. return pdfManagerCapability.promise;
  19247. }
  19248. var fullRequest = pdfStream.getFullReader();
  19249. fullRequest.headersReady.then(function () {
  19250. if (!fullRequest.isStreamingSupported || !fullRequest.isRangeSupported) {
  19251. fullRequest.onProgress = function (evt) {
  19252. handler.send('DocProgress', {
  19253. loaded: evt.loaded,
  19254. total: evt.total
  19255. });
  19256. };
  19257. }
  19258. if (!fullRequest.isRangeSupported) {
  19259. return;
  19260. }
  19261. var disableAutoFetch = source.disableAutoFetch || fullRequest.isStreamingSupported;
  19262. pdfManager = new NetworkPdfManager(docId, pdfStream, {
  19263. msgHandler: handler,
  19264. url: source.url,
  19265. password: source.password,
  19266. length: fullRequest.contentLength,
  19267. disableAutoFetch: disableAutoFetch,
  19268. rangeChunkSize: source.rangeChunkSize
  19269. }, evaluatorOptions, docBaseUrl);
  19270. pdfManagerCapability.resolve(pdfManager);
  19271. cancelXHRs = null;
  19272. }).catch(function (reason) {
  19273. pdfManagerCapability.reject(reason);
  19274. cancelXHRs = null;
  19275. });
  19276. var cachedChunks = [], loaded = 0;
  19277. var flushChunks = function () {
  19278. var pdfFile = arraysToBytes(cachedChunks);
  19279. if (source.length && pdfFile.length !== source.length) {
  19280. warn('reported HTTP length is different from actual');
  19281. }
  19282. try {
  19283. pdfManager = new LocalPdfManager(docId, pdfFile, source.password, evaluatorOptions, docBaseUrl);
  19284. pdfManagerCapability.resolve(pdfManager);
  19285. } catch (ex) {
  19286. pdfManagerCapability.reject(ex);
  19287. }
  19288. cachedChunks = [];
  19289. };
  19290. var readPromise = new Promise(function (resolve, reject) {
  19291. var readChunk = function (chunk) {
  19292. try {
  19293. ensureNotTerminated();
  19294. if (chunk.done) {
  19295. if (!pdfManager) {
  19296. flushChunks();
  19297. }
  19298. cancelXHRs = null;
  19299. return;
  19300. }
  19301. var data = chunk.value;
  19302. loaded += arrayByteLength(data);
  19303. if (!fullRequest.isStreamingSupported) {
  19304. handler.send('DocProgress', {
  19305. loaded: loaded,
  19306. total: Math.max(loaded, fullRequest.contentLength || 0)
  19307. });
  19308. }
  19309. if (pdfManager) {
  19310. pdfManager.sendProgressiveData(data);
  19311. } else {
  19312. cachedChunks.push(data);
  19313. }
  19314. fullRequest.read().then(readChunk, reject);
  19315. } catch (e) {
  19316. reject(e);
  19317. }
  19318. };
  19319. fullRequest.read().then(readChunk, reject);
  19320. });
  19321. readPromise.catch(function (e) {
  19322. pdfManagerCapability.reject(e);
  19323. cancelXHRs = null;
  19324. });
  19325. cancelXHRs = function () {
  19326. pdfStream.cancelAllRequests('abort');
  19327. };
  19328. return pdfManagerCapability.promise;
  19329. }
  19330. function setupDoc(data) {
  19331. function onSuccess(doc) {
  19332. ensureNotTerminated();
  19333. handler.send('GetDoc', { pdfInfo: doc });
  19334. }
  19335. function onFailure(e) {
  19336. if (e instanceof PasswordException) {
  19337. var task = new WorkerTask('PasswordException: response ' + e.code);
  19338. startWorkerTask(task);
  19339. handler.sendWithPromise('PasswordRequest', e).then(function (data) {
  19340. finishWorkerTask(task);
  19341. pdfManager.updatePassword(data.password);
  19342. pdfManagerReady();
  19343. }).catch(function (ex) {
  19344. finishWorkerTask(task);
  19345. handler.send('PasswordException', ex);
  19346. }.bind(null, e));
  19347. } else if (e instanceof InvalidPDFException) {
  19348. handler.send('InvalidPDF', e);
  19349. } else if (e instanceof MissingPDFException) {
  19350. handler.send('MissingPDF', e);
  19351. } else if (e instanceof UnexpectedResponseException) {
  19352. handler.send('UnexpectedResponse', e);
  19353. } else {
  19354. handler.send('UnknownError', new UnknownErrorException(e.message, e.toString()));
  19355. }
  19356. }
  19357. function pdfManagerReady() {
  19358. ensureNotTerminated();
  19359. loadDocument(false).then(onSuccess, function loadFailure(ex) {
  19360. ensureNotTerminated();
  19361. if (!(ex instanceof XRefParseException)) {
  19362. onFailure(ex);
  19363. return;
  19364. }
  19365. pdfManager.requestLoadedStream();
  19366. pdfManager.onLoadedStream().then(function () {
  19367. ensureNotTerminated();
  19368. loadDocument(true).then(onSuccess, onFailure);
  19369. });
  19370. }, onFailure);
  19371. }
  19372. ensureNotTerminated();
  19373. var cMapOptions = {
  19374. url: data.cMapUrl === undefined ? null : data.cMapUrl,
  19375. packed: data.cMapPacked === true
  19376. };
  19377. var evaluatorOptions = {
  19378. forceDataSchema: data.disableCreateObjectURL,
  19379. maxImageSize: data.maxImageSize === undefined ? -1 : data.maxImageSize,
  19380. disableFontFace: data.disableFontFace,
  19381. cMapOptions: cMapOptions,
  19382. disableNativeImageDecoder: data.disableNativeImageDecoder
  19383. };
  19384. getPdfManager(data, evaluatorOptions).then(function (newPdfManager) {
  19385. if (terminated) {
  19386. newPdfManager.terminate();
  19387. throw new Error('Worker was terminated');
  19388. }
  19389. pdfManager = newPdfManager;
  19390. handler.send('PDFManagerReady', null);
  19391. pdfManager.onLoadedStream().then(function (stream) {
  19392. handler.send('DataLoaded', { length: stream.bytes.byteLength });
  19393. });
  19394. }).then(pdfManagerReady, onFailure);
  19395. }
  19396. handler.on('GetPage', function wphSetupGetPage(data) {
  19397. return pdfManager.getPage(data.pageIndex).then(function (page) {
  19398. var rotatePromise = pdfManager.ensure(page, 'rotate');
  19399. var refPromise = pdfManager.ensure(page, 'ref');
  19400. var userUnitPromise = pdfManager.ensure(page, 'userUnit');
  19401. var viewPromise = pdfManager.ensure(page, 'view');
  19402. return Promise.all([
  19403. rotatePromise,
  19404. refPromise,
  19405. userUnitPromise,
  19406. viewPromise
  19407. ]).then(function (results) {
  19408. return {
  19409. rotate: results[0],
  19410. ref: results[1],
  19411. userUnit: results[2],
  19412. view: results[3]
  19413. };
  19414. });
  19415. });
  19416. });
  19417. handler.on('GetPageIndex', function wphSetupGetPageIndex(data) {
  19418. var ref = new Ref(data.ref.num, data.ref.gen);
  19419. var catalog = pdfManager.pdfDocument.catalog;
  19420. return catalog.getPageIndex(ref);
  19421. });
  19422. handler.on('GetDestinations', function wphSetupGetDestinations(data) {
  19423. return pdfManager.ensureCatalog('destinations');
  19424. });
  19425. handler.on('GetDestination', function wphSetupGetDestination(data) {
  19426. return pdfManager.ensureCatalog('getDestination', [data.id]);
  19427. });
  19428. handler.on('GetPageLabels', function wphSetupGetPageLabels(data) {
  19429. return pdfManager.ensureCatalog('pageLabels');
  19430. });
  19431. handler.on('GetAttachments', function wphSetupGetAttachments(data) {
  19432. return pdfManager.ensureCatalog('attachments');
  19433. });
  19434. handler.on('GetJavaScript', function wphSetupGetJavaScript(data) {
  19435. return pdfManager.ensureCatalog('javaScript');
  19436. });
  19437. handler.on('GetOutline', function wphSetupGetOutline(data) {
  19438. return pdfManager.ensureCatalog('documentOutline');
  19439. });
  19440. handler.on('GetMetadata', function wphSetupGetMetadata(data) {
  19441. return Promise.all([
  19442. pdfManager.ensureDoc('documentInfo'),
  19443. pdfManager.ensureCatalog('metadata')
  19444. ]);
  19445. });
  19446. handler.on('GetData', function wphSetupGetData(data) {
  19447. pdfManager.requestLoadedStream();
  19448. return pdfManager.onLoadedStream().then(function (stream) {
  19449. return stream.bytes;
  19450. });
  19451. });
  19452. handler.on('GetStats', function wphSetupGetStats(data) {
  19453. return pdfManager.pdfDocument.xref.stats;
  19454. });
  19455. handler.on('GetAnnotations', function wphSetupGetAnnotations(data) {
  19456. return pdfManager.getPage(data.pageIndex).then(function (page) {
  19457. return pdfManager.ensure(page, 'getAnnotationsData', [data.intent]);
  19458. });
  19459. });
  19460. handler.on('RenderPageRequest', function wphSetupRenderPage(data) {
  19461. var pageIndex = data.pageIndex;
  19462. pdfManager.getPage(pageIndex).then(function (page) {
  19463. var task = new WorkerTask('RenderPageRequest: page ' + pageIndex);
  19464. startWorkerTask(task);
  19465. var pageNum = pageIndex + 1;
  19466. var start = Date.now();
  19467. page.getOperatorList(handler, task, data.intent, data.renderInteractiveForms).then(function (operatorList) {
  19468. finishWorkerTask(task);
  19469. info('page=' + pageNum + ' - getOperatorList: time=' + (Date.now() - start) + 'ms, len=' + operatorList.totalLength);
  19470. }, function (e) {
  19471. finishWorkerTask(task);
  19472. if (task.terminated) {
  19473. return;
  19474. }
  19475. handler.send('UnsupportedFeature', { featureId: UNSUPPORTED_FEATURES.unknown });
  19476. var minimumStackMessage = 'worker.js: while trying to getPage() and getOperatorList()';
  19477. var wrappedException;
  19478. if (typeof e === 'string') {
  19479. wrappedException = {
  19480. message: e,
  19481. stack: minimumStackMessage
  19482. };
  19483. } else if (typeof e === 'object') {
  19484. wrappedException = {
  19485. message: e.message || e.toString(),
  19486. stack: e.stack || minimumStackMessage
  19487. };
  19488. } else {
  19489. wrappedException = {
  19490. message: 'Unknown exception type: ' + typeof e,
  19491. stack: minimumStackMessage
  19492. };
  19493. }
  19494. handler.send('PageError', {
  19495. pageNum: pageNum,
  19496. error: wrappedException,
  19497. intent: data.intent
  19498. });
  19499. });
  19500. });
  19501. }, this);
  19502. handler.on('GetTextContent', function wphExtractText(data) {
  19503. var pageIndex = data.pageIndex;
  19504. var normalizeWhitespace = data.normalizeWhitespace;
  19505. var combineTextItems = data.combineTextItems;
  19506. return pdfManager.getPage(pageIndex).then(function (page) {
  19507. var task = new WorkerTask('GetTextContent: page ' + pageIndex);
  19508. startWorkerTask(task);
  19509. var pageNum = pageIndex + 1;
  19510. var start = Date.now();
  19511. return page.extractTextContent(task, normalizeWhitespace, combineTextItems).then(function (textContent) {
  19512. finishWorkerTask(task);
  19513. info('text indexing: page=' + pageNum + ' - time=' + (Date.now() - start) + 'ms');
  19514. return textContent;
  19515. }, function (reason) {
  19516. finishWorkerTask(task);
  19517. if (task.terminated) {
  19518. return;
  19519. }
  19520. throw reason;
  19521. });
  19522. });
  19523. });
  19524. handler.on('Cleanup', function wphCleanup(data) {
  19525. return pdfManager.cleanup();
  19526. });
  19527. handler.on('Terminate', function wphTerminate(data) {
  19528. terminated = true;
  19529. if (pdfManager) {
  19530. pdfManager.terminate();
  19531. pdfManager = null;
  19532. }
  19533. if (cancelXHRs) {
  19534. cancelXHRs();
  19535. }
  19536. var waitOn = [];
  19537. WorkerTasks.forEach(function (task) {
  19538. waitOn.push(task.finished);
  19539. task.terminate();
  19540. });
  19541. return Promise.all(waitOn).then(function () {
  19542. handler.destroy();
  19543. handler = null;
  19544. });
  19545. });
  19546. handler.on('Ready', function wphReady(data) {
  19547. setupDoc(docParams);
  19548. docParams = null;
  19549. });
  19550. return workerHandlerName;
  19551. }
  19552. };
  19553. function initializeWorker() {
  19554. if (!('console' in globalScope)) {
  19555. var consoleTimer = {};
  19556. var workerConsole = {
  19557. log: function log() {
  19558. var args = Array.prototype.slice.call(arguments);
  19559. globalScope.postMessage({
  19560. targetName: 'main',
  19561. action: 'console_log',
  19562. data: args
  19563. });
  19564. },
  19565. error: function error() {
  19566. var args = Array.prototype.slice.call(arguments);
  19567. globalScope.postMessage({
  19568. targetName: 'main',
  19569. action: 'console_error',
  19570. data: args
  19571. });
  19572. throw 'pdf.js execution error';
  19573. },
  19574. time: function time(name) {
  19575. consoleTimer[name] = Date.now();
  19576. },
  19577. timeEnd: function timeEnd(name) {
  19578. var time = consoleTimer[name];
  19579. if (!time) {
  19580. error('Unknown timer name ' + name);
  19581. }
  19582. this.log('Timer:', name, Date.now() - time);
  19583. }
  19584. };
  19585. globalScope.console = workerConsole;
  19586. }
  19587. var handler = new MessageHandler('worker', 'main', self);
  19588. WorkerMessageHandler.setup(handler, self);
  19589. handler.send('ready', null);
  19590. }
  19591. if (typeof window === 'undefined' && !(typeof module !== 'undefined' && module.require)) {
  19592. initializeWorker();
  19593. }
  19594. exports.setPDFNetworkStreamClass = setPDFNetworkStreamClass;
  19595. exports.WorkerTask = WorkerTask;
  19596. exports.WorkerMessageHandler = WorkerMessageHandler;
  19597. /* WEBPACK VAR INJECTION */}.call(exports, __w_pdfjs_require__(28)(module)))
  19598. /***/ }),
  19599. /* 10 */
  19600. /***/ (function(module, exports, __w_pdfjs_require__) {
  19601. "use strict";
  19602. var sharedUtil = __w_pdfjs_require__(0);
  19603. var displayDOMUtils = __w_pdfjs_require__(3);
  19604. var AnnotationBorderStyleType = sharedUtil.AnnotationBorderStyleType;
  19605. var AnnotationType = sharedUtil.AnnotationType;
  19606. var stringToPDFString = sharedUtil.stringToPDFString;
  19607. var Util = sharedUtil.Util;
  19608. var addLinkAttributes = displayDOMUtils.addLinkAttributes;
  19609. var LinkTarget = displayDOMUtils.LinkTarget;
  19610. var getFilenameFromUrl = displayDOMUtils.getFilenameFromUrl;
  19611. var warn = sharedUtil.warn;
  19612. var CustomStyle = displayDOMUtils.CustomStyle;
  19613. var getDefaultSetting = displayDOMUtils.getDefaultSetting;
  19614. function AnnotationElementFactory() {
  19615. }
  19616. AnnotationElementFactory.prototype = {
  19617. create: function AnnotationElementFactory_create(parameters) {
  19618. var subtype = parameters.data.annotationType;
  19619. switch (subtype) {
  19620. case AnnotationType.LINK:
  19621. return new LinkAnnotationElement(parameters);
  19622. case AnnotationType.TEXT:
  19623. return new TextAnnotationElement(parameters);
  19624. case AnnotationType.WIDGET:
  19625. var fieldType = parameters.data.fieldType;
  19626. switch (fieldType) {
  19627. case 'Tx':
  19628. return new TextWidgetAnnotationElement(parameters);
  19629. case 'Btn':
  19630. if (parameters.data.radioButton) {
  19631. return new RadioButtonWidgetAnnotationElement(parameters);
  19632. } else if (parameters.data.checkBox) {
  19633. return new CheckboxWidgetAnnotationElement(parameters);
  19634. }
  19635. warn('Unimplemented button widget annotation: pushbutton');
  19636. break;
  19637. case 'Ch':
  19638. return new ChoiceWidgetAnnotationElement(parameters);
  19639. }
  19640. return new WidgetAnnotationElement(parameters);
  19641. case AnnotationType.POPUP:
  19642. return new PopupAnnotationElement(parameters);
  19643. case AnnotationType.HIGHLIGHT:
  19644. return new HighlightAnnotationElement(parameters);
  19645. case AnnotationType.UNDERLINE:
  19646. return new UnderlineAnnotationElement(parameters);
  19647. case AnnotationType.SQUIGGLY:
  19648. return new SquigglyAnnotationElement(parameters);
  19649. case AnnotationType.STRIKEOUT:
  19650. return new StrikeOutAnnotationElement(parameters);
  19651. case AnnotationType.FILEATTACHMENT:
  19652. return new FileAttachmentAnnotationElement(parameters);
  19653. default:
  19654. return new AnnotationElement(parameters);
  19655. }
  19656. }
  19657. };
  19658. var AnnotationElement = function AnnotationElementClosure() {
  19659. function AnnotationElement(parameters, isRenderable) {
  19660. this.isRenderable = isRenderable || false;
  19661. this.data = parameters.data;
  19662. this.layer = parameters.layer;
  19663. this.page = parameters.page;
  19664. this.viewport = parameters.viewport;
  19665. this.linkService = parameters.linkService;
  19666. this.downloadManager = parameters.downloadManager;
  19667. this.imageResourcesPath = parameters.imageResourcesPath;
  19668. this.renderInteractiveForms = parameters.renderInteractiveForms;
  19669. if (isRenderable) {
  19670. this.container = this._createContainer();
  19671. }
  19672. }
  19673. AnnotationElement.prototype = {
  19674. _createContainer: function AnnotationElement_createContainer() {
  19675. var data = this.data, page = this.page, viewport = this.viewport;
  19676. var container = document.createElement('section');
  19677. var width = data.rect[2] - data.rect[0];
  19678. var height = data.rect[3] - data.rect[1];
  19679. container.setAttribute('data-annotation-id', data.id);
  19680. var rect = Util.normalizeRect([
  19681. data.rect[0],
  19682. page.view[3] - data.rect[1] + page.view[1],
  19683. data.rect[2],
  19684. page.view[3] - data.rect[3] + page.view[1]
  19685. ]);
  19686. CustomStyle.setProp('transform', container, 'matrix(' + viewport.transform.join(',') + ')');
  19687. CustomStyle.setProp('transformOrigin', container, -rect[0] + 'px ' + -rect[1] + 'px');
  19688. if (data.borderStyle.width > 0) {
  19689. container.style.borderWidth = data.borderStyle.width + 'px';
  19690. if (data.borderStyle.style !== AnnotationBorderStyleType.UNDERLINE) {
  19691. width = width - 2 * data.borderStyle.width;
  19692. height = height - 2 * data.borderStyle.width;
  19693. }
  19694. var horizontalRadius = data.borderStyle.horizontalCornerRadius;
  19695. var verticalRadius = data.borderStyle.verticalCornerRadius;
  19696. if (horizontalRadius > 0 || verticalRadius > 0) {
  19697. var radius = horizontalRadius + 'px / ' + verticalRadius + 'px';
  19698. CustomStyle.setProp('borderRadius', container, radius);
  19699. }
  19700. switch (data.borderStyle.style) {
  19701. case AnnotationBorderStyleType.SOLID:
  19702. container.style.borderStyle = 'solid';
  19703. break;
  19704. case AnnotationBorderStyleType.DASHED:
  19705. container.style.borderStyle = 'dashed';
  19706. break;
  19707. case AnnotationBorderStyleType.BEVELED:
  19708. warn('Unimplemented border style: beveled');
  19709. break;
  19710. case AnnotationBorderStyleType.INSET:
  19711. warn('Unimplemented border style: inset');
  19712. break;
  19713. case AnnotationBorderStyleType.UNDERLINE:
  19714. container.style.borderBottomStyle = 'solid';
  19715. break;
  19716. default:
  19717. break;
  19718. }
  19719. if (data.color) {
  19720. container.style.borderColor = Util.makeCssRgb(data.color[0] | 0, data.color[1] | 0, data.color[2] | 0);
  19721. } else {
  19722. container.style.borderWidth = 0;
  19723. }
  19724. }
  19725. container.style.left = rect[0] + 'px';
  19726. container.style.top = rect[1] + 'px';
  19727. container.style.width = width + 'px';
  19728. container.style.height = height + 'px';
  19729. return container;
  19730. },
  19731. _createPopup: function AnnotationElement_createPopup(container, trigger, data) {
  19732. if (!trigger) {
  19733. trigger = document.createElement('div');
  19734. trigger.style.height = container.style.height;
  19735. trigger.style.width = container.style.width;
  19736. container.appendChild(trigger);
  19737. }
  19738. var popupElement = new PopupElement({
  19739. container: container,
  19740. trigger: trigger,
  19741. color: data.color,
  19742. title: data.title,
  19743. contents: data.contents,
  19744. hideWrapper: true
  19745. });
  19746. var popup = popupElement.render();
  19747. popup.style.left = container.style.width;
  19748. container.appendChild(popup);
  19749. },
  19750. render: function AnnotationElement_render() {
  19751. throw new Error('Abstract method AnnotationElement.render called');
  19752. }
  19753. };
  19754. return AnnotationElement;
  19755. }();
  19756. var LinkAnnotationElement = function LinkAnnotationElementClosure() {
  19757. function LinkAnnotationElement(parameters) {
  19758. AnnotationElement.call(this, parameters, true);
  19759. }
  19760. Util.inherit(LinkAnnotationElement, AnnotationElement, {
  19761. render: function LinkAnnotationElement_render() {
  19762. this.container.className = 'linkAnnotation';
  19763. var link = document.createElement('a');
  19764. addLinkAttributes(link, {
  19765. url: this.data.url,
  19766. target: this.data.newWindow ? LinkTarget.BLANK : undefined
  19767. });
  19768. if (!this.data.url) {
  19769. if (this.data.action) {
  19770. this._bindNamedAction(link, this.data.action);
  19771. } else {
  19772. this._bindLink(link, this.data.dest);
  19773. }
  19774. }
  19775. this.container.appendChild(link);
  19776. return this.container;
  19777. },
  19778. _bindLink: function LinkAnnotationElement_bindLink(link, destination) {
  19779. var self = this;
  19780. link.href = this.linkService.getDestinationHash(destination);
  19781. link.onclick = function () {
  19782. if (destination) {
  19783. self.linkService.navigateTo(destination);
  19784. }
  19785. return false;
  19786. };
  19787. if (destination) {
  19788. link.className = 'internalLink';
  19789. }
  19790. },
  19791. _bindNamedAction: function LinkAnnotationElement_bindNamedAction(link, action) {
  19792. var self = this;
  19793. link.href = this.linkService.getAnchorUrl('');
  19794. link.onclick = function () {
  19795. self.linkService.executeNamedAction(action);
  19796. return false;
  19797. };
  19798. link.className = 'internalLink';
  19799. }
  19800. });
  19801. return LinkAnnotationElement;
  19802. }();
  19803. var TextAnnotationElement = function TextAnnotationElementClosure() {
  19804. function TextAnnotationElement(parameters) {
  19805. var isRenderable = !!(parameters.data.hasPopup || parameters.data.title || parameters.data.contents);
  19806. AnnotationElement.call(this, parameters, isRenderable);
  19807. }
  19808. Util.inherit(TextAnnotationElement, AnnotationElement, {
  19809. render: function TextAnnotationElement_render() {
  19810. this.container.className = 'textAnnotation';
  19811. var image = document.createElement('img');
  19812. image.style.height = this.container.style.height;
  19813. image.style.width = this.container.style.width;
  19814. image.src = this.imageResourcesPath + 'annotation-' + this.data.name.toLowerCase() + '.svg';
  19815. image.alt = '[{{type}} Annotation]';
  19816. image.dataset.l10nId = 'text_annotation_type';
  19817. image.dataset.l10nArgs = JSON.stringify({ type: this.data.name });
  19818. if (!this.data.hasPopup) {
  19819. this._createPopup(this.container, image, this.data);
  19820. }
  19821. this.container.appendChild(image);
  19822. return this.container;
  19823. }
  19824. });
  19825. return TextAnnotationElement;
  19826. }();
  19827. var WidgetAnnotationElement = function WidgetAnnotationElementClosure() {
  19828. function WidgetAnnotationElement(parameters, isRenderable) {
  19829. AnnotationElement.call(this, parameters, isRenderable);
  19830. }
  19831. Util.inherit(WidgetAnnotationElement, AnnotationElement, {
  19832. render: function WidgetAnnotationElement_render() {
  19833. return this.container;
  19834. }
  19835. });
  19836. return WidgetAnnotationElement;
  19837. }();
  19838. var TextWidgetAnnotationElement = function TextWidgetAnnotationElementClosure() {
  19839. var TEXT_ALIGNMENT = [
  19840. 'left',
  19841. 'center',
  19842. 'right'
  19843. ];
  19844. function TextWidgetAnnotationElement(parameters) {
  19845. var isRenderable = parameters.renderInteractiveForms || !parameters.data.hasAppearance && !!parameters.data.fieldValue;
  19846. WidgetAnnotationElement.call(this, parameters, isRenderable);
  19847. }
  19848. Util.inherit(TextWidgetAnnotationElement, WidgetAnnotationElement, {
  19849. render: function TextWidgetAnnotationElement_render() {
  19850. this.container.className = 'textWidgetAnnotation';
  19851. var element = null;
  19852. if (this.renderInteractiveForms) {
  19853. if (this.data.multiLine) {
  19854. element = document.createElement('textarea');
  19855. element.textContent = this.data.fieldValue;
  19856. } else {
  19857. element = document.createElement('input');
  19858. element.type = 'text';
  19859. element.setAttribute('value', this.data.fieldValue);
  19860. }
  19861. element.disabled = this.data.readOnly;
  19862. if (this.data.maxLen !== null) {
  19863. element.maxLength = this.data.maxLen;
  19864. }
  19865. if (this.data.comb) {
  19866. var fieldWidth = this.data.rect[2] - this.data.rect[0];
  19867. var combWidth = fieldWidth / this.data.maxLen;
  19868. element.classList.add('comb');
  19869. element.style.letterSpacing = 'calc(' + combWidth + 'px - 1ch)';
  19870. }
  19871. } else {
  19872. element = document.createElement('div');
  19873. element.textContent = this.data.fieldValue;
  19874. element.style.verticalAlign = 'middle';
  19875. element.style.display = 'table-cell';
  19876. var font = null;
  19877. if (this.data.fontRefName) {
  19878. font = this.page.commonObjs.getData(this.data.fontRefName);
  19879. }
  19880. this._setTextStyle(element, font);
  19881. }
  19882. if (this.data.textAlignment !== null) {
  19883. element.style.textAlign = TEXT_ALIGNMENT[this.data.textAlignment];
  19884. }
  19885. this.container.appendChild(element);
  19886. return this.container;
  19887. },
  19888. _setTextStyle: function TextWidgetAnnotationElement_setTextStyle(element, font) {
  19889. var style = element.style;
  19890. style.fontSize = this.data.fontSize + 'px';
  19891. style.direction = this.data.fontDirection < 0 ? 'rtl' : 'ltr';
  19892. if (!font) {
  19893. return;
  19894. }
  19895. style.fontWeight = font.black ? font.bold ? '900' : 'bold' : font.bold ? 'bold' : 'normal';
  19896. style.fontStyle = font.italic ? 'italic' : 'normal';
  19897. var fontFamily = font.loadedName ? '"' + font.loadedName + '", ' : '';
  19898. var fallbackName = font.fallbackName || 'Helvetica, sans-serif';
  19899. style.fontFamily = fontFamily + fallbackName;
  19900. }
  19901. });
  19902. return TextWidgetAnnotationElement;
  19903. }();
  19904. var CheckboxWidgetAnnotationElement = function CheckboxWidgetAnnotationElementClosure() {
  19905. function CheckboxWidgetAnnotationElement(parameters) {
  19906. WidgetAnnotationElement.call(this, parameters, parameters.renderInteractiveForms);
  19907. }
  19908. Util.inherit(CheckboxWidgetAnnotationElement, WidgetAnnotationElement, {
  19909. render: function CheckboxWidgetAnnotationElement_render() {
  19910. this.container.className = 'buttonWidgetAnnotation checkBox';
  19911. var element = document.createElement('input');
  19912. element.disabled = this.data.readOnly;
  19913. element.type = 'checkbox';
  19914. if (this.data.fieldValue && this.data.fieldValue !== 'Off') {
  19915. element.setAttribute('checked', true);
  19916. }
  19917. this.container.appendChild(element);
  19918. return this.container;
  19919. }
  19920. });
  19921. return CheckboxWidgetAnnotationElement;
  19922. }();
  19923. var RadioButtonWidgetAnnotationElement = function RadioButtonWidgetAnnotationElementClosure() {
  19924. function RadioButtonWidgetAnnotationElement(parameters) {
  19925. WidgetAnnotationElement.call(this, parameters, parameters.renderInteractiveForms);
  19926. }
  19927. Util.inherit(RadioButtonWidgetAnnotationElement, WidgetAnnotationElement, {
  19928. render: function RadioButtonWidgetAnnotationElement_render() {
  19929. this.container.className = 'buttonWidgetAnnotation radioButton';
  19930. var element = document.createElement('input');
  19931. element.disabled = this.data.readOnly;
  19932. element.type = 'radio';
  19933. element.name = this.data.fieldName;
  19934. if (this.data.fieldValue === this.data.buttonValue) {
  19935. element.setAttribute('checked', true);
  19936. }
  19937. this.container.appendChild(element);
  19938. return this.container;
  19939. }
  19940. });
  19941. return RadioButtonWidgetAnnotationElement;
  19942. }();
  19943. var ChoiceWidgetAnnotationElement = function ChoiceWidgetAnnotationElementClosure() {
  19944. function ChoiceWidgetAnnotationElement(parameters) {
  19945. WidgetAnnotationElement.call(this, parameters, parameters.renderInteractiveForms);
  19946. }
  19947. Util.inherit(ChoiceWidgetAnnotationElement, WidgetAnnotationElement, {
  19948. render: function ChoiceWidgetAnnotationElement_render() {
  19949. this.container.className = 'choiceWidgetAnnotation';
  19950. var selectElement = document.createElement('select');
  19951. selectElement.disabled = this.data.readOnly;
  19952. if (!this.data.combo) {
  19953. selectElement.size = this.data.options.length;
  19954. if (this.data.multiSelect) {
  19955. selectElement.multiple = true;
  19956. }
  19957. }
  19958. for (var i = 0, ii = this.data.options.length; i < ii; i++) {
  19959. var option = this.data.options[i];
  19960. var optionElement = document.createElement('option');
  19961. optionElement.textContent = option.displayValue;
  19962. optionElement.value = option.exportValue;
  19963. if (this.data.fieldValue.indexOf(option.displayValue) >= 0) {
  19964. optionElement.setAttribute('selected', true);
  19965. }
  19966. selectElement.appendChild(optionElement);
  19967. }
  19968. this.container.appendChild(selectElement);
  19969. return this.container;
  19970. }
  19971. });
  19972. return ChoiceWidgetAnnotationElement;
  19973. }();
  19974. var PopupAnnotationElement = function PopupAnnotationElementClosure() {
  19975. function PopupAnnotationElement(parameters) {
  19976. var isRenderable = !!(parameters.data.title || parameters.data.contents);
  19977. AnnotationElement.call(this, parameters, isRenderable);
  19978. }
  19979. Util.inherit(PopupAnnotationElement, AnnotationElement, {
  19980. render: function PopupAnnotationElement_render() {
  19981. this.container.className = 'popupAnnotation';
  19982. var selector = '[data-annotation-id="' + this.data.parentId + '"]';
  19983. var parentElement = this.layer.querySelector(selector);
  19984. if (!parentElement) {
  19985. return this.container;
  19986. }
  19987. var popup = new PopupElement({
  19988. container: this.container,
  19989. trigger: parentElement,
  19990. color: this.data.color,
  19991. title: this.data.title,
  19992. contents: this.data.contents
  19993. });
  19994. var parentLeft = parseFloat(parentElement.style.left);
  19995. var parentWidth = parseFloat(parentElement.style.width);
  19996. CustomStyle.setProp('transformOrigin', this.container, -(parentLeft + parentWidth) + 'px -' + parentElement.style.top);
  19997. this.container.style.left = parentLeft + parentWidth + 'px';
  19998. this.container.appendChild(popup.render());
  19999. return this.container;
  20000. }
  20001. });
  20002. return PopupAnnotationElement;
  20003. }();
  20004. var PopupElement = function PopupElementClosure() {
  20005. var BACKGROUND_ENLIGHT = 0.7;
  20006. function PopupElement(parameters) {
  20007. this.container = parameters.container;
  20008. this.trigger = parameters.trigger;
  20009. this.color = parameters.color;
  20010. this.title = parameters.title;
  20011. this.contents = parameters.contents;
  20012. this.hideWrapper = parameters.hideWrapper || false;
  20013. this.pinned = false;
  20014. }
  20015. PopupElement.prototype = {
  20016. render: function PopupElement_render() {
  20017. var wrapper = document.createElement('div');
  20018. wrapper.className = 'popupWrapper';
  20019. this.hideElement = this.hideWrapper ? wrapper : this.container;
  20020. this.hideElement.setAttribute('hidden', true);
  20021. var popup = document.createElement('div');
  20022. popup.className = 'popup';
  20023. var color = this.color;
  20024. if (color) {
  20025. var r = BACKGROUND_ENLIGHT * (255 - color[0]) + color[0];
  20026. var g = BACKGROUND_ENLIGHT * (255 - color[1]) + color[1];
  20027. var b = BACKGROUND_ENLIGHT * (255 - color[2]) + color[2];
  20028. popup.style.backgroundColor = Util.makeCssRgb(r | 0, g | 0, b | 0);
  20029. }
  20030. var contents = this._formatContents(this.contents);
  20031. var title = document.createElement('h1');
  20032. title.textContent = this.title;
  20033. this.trigger.addEventListener('click', this._toggle.bind(this));
  20034. this.trigger.addEventListener('mouseover', this._show.bind(this, false));
  20035. this.trigger.addEventListener('mouseout', this._hide.bind(this, false));
  20036. popup.addEventListener('click', this._hide.bind(this, true));
  20037. popup.appendChild(title);
  20038. popup.appendChild(contents);
  20039. wrapper.appendChild(popup);
  20040. return wrapper;
  20041. },
  20042. _formatContents: function PopupElement_formatContents(contents) {
  20043. var p = document.createElement('p');
  20044. var lines = contents.split(/(?:\r\n?|\n)/);
  20045. for (var i = 0, ii = lines.length; i < ii; ++i) {
  20046. var line = lines[i];
  20047. p.appendChild(document.createTextNode(line));
  20048. if (i < ii - 1) {
  20049. p.appendChild(document.createElement('br'));
  20050. }
  20051. }
  20052. return p;
  20053. },
  20054. _toggle: function PopupElement_toggle() {
  20055. if (this.pinned) {
  20056. this._hide(true);
  20057. } else {
  20058. this._show(true);
  20059. }
  20060. },
  20061. _show: function PopupElement_show(pin) {
  20062. if (pin) {
  20063. this.pinned = true;
  20064. }
  20065. if (this.hideElement.hasAttribute('hidden')) {
  20066. this.hideElement.removeAttribute('hidden');
  20067. this.container.style.zIndex += 1;
  20068. }
  20069. },
  20070. _hide: function PopupElement_hide(unpin) {
  20071. if (unpin) {
  20072. this.pinned = false;
  20073. }
  20074. if (!this.hideElement.hasAttribute('hidden') && !this.pinned) {
  20075. this.hideElement.setAttribute('hidden', true);
  20076. this.container.style.zIndex -= 1;
  20077. }
  20078. }
  20079. };
  20080. return PopupElement;
  20081. }();
  20082. var HighlightAnnotationElement = function HighlightAnnotationElementClosure() {
  20083. function HighlightAnnotationElement(parameters) {
  20084. var isRenderable = !!(parameters.data.hasPopup || parameters.data.title || parameters.data.contents);
  20085. AnnotationElement.call(this, parameters, isRenderable);
  20086. }
  20087. Util.inherit(HighlightAnnotationElement, AnnotationElement, {
  20088. render: function HighlightAnnotationElement_render() {
  20089. this.container.className = 'highlightAnnotation';
  20090. if (!this.data.hasPopup) {
  20091. this._createPopup(this.container, null, this.data);
  20092. }
  20093. return this.container;
  20094. }
  20095. });
  20096. return HighlightAnnotationElement;
  20097. }();
  20098. var UnderlineAnnotationElement = function UnderlineAnnotationElementClosure() {
  20099. function UnderlineAnnotationElement(parameters) {
  20100. var isRenderable = !!(parameters.data.hasPopup || parameters.data.title || parameters.data.contents);
  20101. AnnotationElement.call(this, parameters, isRenderable);
  20102. }
  20103. Util.inherit(UnderlineAnnotationElement, AnnotationElement, {
  20104. render: function UnderlineAnnotationElement_render() {
  20105. this.container.className = 'underlineAnnotation';
  20106. if (!this.data.hasPopup) {
  20107. this._createPopup(this.container, null, this.data);
  20108. }
  20109. return this.container;
  20110. }
  20111. });
  20112. return UnderlineAnnotationElement;
  20113. }();
  20114. var SquigglyAnnotationElement = function SquigglyAnnotationElementClosure() {
  20115. function SquigglyAnnotationElement(parameters) {
  20116. var isRenderable = !!(parameters.data.hasPopup || parameters.data.title || parameters.data.contents);
  20117. AnnotationElement.call(this, parameters, isRenderable);
  20118. }
  20119. Util.inherit(SquigglyAnnotationElement, AnnotationElement, {
  20120. render: function SquigglyAnnotationElement_render() {
  20121. this.container.className = 'squigglyAnnotation';
  20122. if (!this.data.hasPopup) {
  20123. this._createPopup(this.container, null, this.data);
  20124. }
  20125. return this.container;
  20126. }
  20127. });
  20128. return SquigglyAnnotationElement;
  20129. }();
  20130. var StrikeOutAnnotationElement = function StrikeOutAnnotationElementClosure() {
  20131. function StrikeOutAnnotationElement(parameters) {
  20132. var isRenderable = !!(parameters.data.hasPopup || parameters.data.title || parameters.data.contents);
  20133. AnnotationElement.call(this, parameters, isRenderable);
  20134. }
  20135. Util.inherit(StrikeOutAnnotationElement, AnnotationElement, {
  20136. render: function StrikeOutAnnotationElement_render() {
  20137. this.container.className = 'strikeoutAnnotation';
  20138. if (!this.data.hasPopup) {
  20139. this._createPopup(this.container, null, this.data);
  20140. }
  20141. return this.container;
  20142. }
  20143. });
  20144. return StrikeOutAnnotationElement;
  20145. }();
  20146. var FileAttachmentAnnotationElement = function FileAttachmentAnnotationElementClosure() {
  20147. function FileAttachmentAnnotationElement(parameters) {
  20148. AnnotationElement.call(this, parameters, true);
  20149. var file = this.data.file;
  20150. this.filename = getFilenameFromUrl(file.filename);
  20151. this.content = file.content;
  20152. this.linkService.onFileAttachmentAnnotation({
  20153. id: stringToPDFString(file.filename),
  20154. filename: file.filename,
  20155. content: file.content
  20156. });
  20157. }
  20158. Util.inherit(FileAttachmentAnnotationElement, AnnotationElement, {
  20159. render: function FileAttachmentAnnotationElement_render() {
  20160. this.container.className = 'fileAttachmentAnnotation';
  20161. var trigger = document.createElement('div');
  20162. trigger.style.height = this.container.style.height;
  20163. trigger.style.width = this.container.style.width;
  20164. trigger.addEventListener('dblclick', this._download.bind(this));
  20165. if (!this.data.hasPopup && (this.data.title || this.data.contents)) {
  20166. this._createPopup(this.container, trigger, this.data);
  20167. }
  20168. this.container.appendChild(trigger);
  20169. return this.container;
  20170. },
  20171. _download: function FileAttachmentAnnotationElement_download() {
  20172. if (!this.downloadManager) {
  20173. warn('Download cannot be started due to unavailable download manager');
  20174. return;
  20175. }
  20176. this.downloadManager.downloadData(this.content, this.filename, '');
  20177. }
  20178. });
  20179. return FileAttachmentAnnotationElement;
  20180. }();
  20181. var AnnotationLayer = function AnnotationLayerClosure() {
  20182. return {
  20183. render: function AnnotationLayer_render(parameters) {
  20184. var annotationElementFactory = new AnnotationElementFactory();
  20185. for (var i = 0, ii = parameters.annotations.length; i < ii; i++) {
  20186. var data = parameters.annotations[i];
  20187. if (!data) {
  20188. continue;
  20189. }
  20190. var element = annotationElementFactory.create({
  20191. data: data,
  20192. layer: parameters.div,
  20193. page: parameters.page,
  20194. viewport: parameters.viewport,
  20195. linkService: parameters.linkService,
  20196. downloadManager: parameters.downloadManager,
  20197. imageResourcesPath: parameters.imageResourcesPath || getDefaultSetting('imageResourcesPath'),
  20198. renderInteractiveForms: parameters.renderInteractiveForms || false
  20199. });
  20200. if (element.isRenderable) {
  20201. parameters.div.appendChild(element.render());
  20202. }
  20203. }
  20204. },
  20205. update: function AnnotationLayer_update(parameters) {
  20206. for (var i = 0, ii = parameters.annotations.length; i < ii; i++) {
  20207. var data = parameters.annotations[i];
  20208. var element = parameters.div.querySelector('[data-annotation-id="' + data.id + '"]');
  20209. if (element) {
  20210. CustomStyle.setProp('transform', element, 'matrix(' + parameters.viewport.transform.join(',') + ')');
  20211. }
  20212. }
  20213. parameters.div.removeAttribute('hidden');
  20214. }
  20215. };
  20216. }();
  20217. exports.AnnotationLayer = AnnotationLayer;
  20218. /***/ }),
  20219. /* 11 */
  20220. /***/ (function(module, exports, __w_pdfjs_require__) {
  20221. "use strict";
  20222. var sharedUtil = __w_pdfjs_require__(0);
  20223. var displayFontLoader = __w_pdfjs_require__(46);
  20224. var displayCanvas = __w_pdfjs_require__(45);
  20225. var displayMetadata = __w_pdfjs_require__(23);
  20226. var displayDOMUtils = __w_pdfjs_require__(3);
  20227. var amdRequire;
  20228. var InvalidPDFException = sharedUtil.InvalidPDFException;
  20229. var MessageHandler = sharedUtil.MessageHandler;
  20230. var MissingPDFException = sharedUtil.MissingPDFException;
  20231. var PageViewport = sharedUtil.PageViewport;
  20232. var PasswordException = sharedUtil.PasswordException;
  20233. var StatTimer = sharedUtil.StatTimer;
  20234. var UnexpectedResponseException = sharedUtil.UnexpectedResponseException;
  20235. var UnknownErrorException = sharedUtil.UnknownErrorException;
  20236. var Util = sharedUtil.Util;
  20237. var createPromiseCapability = sharedUtil.createPromiseCapability;
  20238. var error = sharedUtil.error;
  20239. var deprecated = sharedUtil.deprecated;
  20240. var getVerbosityLevel = sharedUtil.getVerbosityLevel;
  20241. var info = sharedUtil.info;
  20242. var isInt = sharedUtil.isInt;
  20243. var isArray = sharedUtil.isArray;
  20244. var isArrayBuffer = sharedUtil.isArrayBuffer;
  20245. var isSameOrigin = sharedUtil.isSameOrigin;
  20246. var loadJpegStream = sharedUtil.loadJpegStream;
  20247. var stringToBytes = sharedUtil.stringToBytes;
  20248. var globalScope = sharedUtil.globalScope;
  20249. var warn = sharedUtil.warn;
  20250. var FontFaceObject = displayFontLoader.FontFaceObject;
  20251. var FontLoader = displayFontLoader.FontLoader;
  20252. var CanvasGraphics = displayCanvas.CanvasGraphics;
  20253. var Metadata = displayMetadata.Metadata;
  20254. var getDefaultSetting = displayDOMUtils.getDefaultSetting;
  20255. var DOMCanvasFactory = displayDOMUtils.DOMCanvasFactory;
  20256. var DEFAULT_RANGE_CHUNK_SIZE = 65536;
  20257. var isWorkerDisabled = false;
  20258. var workerSrc;
  20259. var isPostMessageTransfersDisabled = false;
  20260. var pdfjsFilePath = typeof document !== 'undefined' && document.currentScript ? document.currentScript.src : null;
  20261. var fakeWorkerFilesLoader = null;
  20262. var useRequireEnsure = false;
  20263. function getDocument(src, pdfDataRangeTransport, passwordCallback, progressCallback) {
  20264. var task = new PDFDocumentLoadingTask();
  20265. if (arguments.length > 1) {
  20266. deprecated('getDocument is called with pdfDataRangeTransport, ' + 'passwordCallback or progressCallback argument');
  20267. }
  20268. if (pdfDataRangeTransport) {
  20269. if (!(pdfDataRangeTransport instanceof PDFDataRangeTransport)) {
  20270. pdfDataRangeTransport = Object.create(pdfDataRangeTransport);
  20271. pdfDataRangeTransport.length = src.length;
  20272. pdfDataRangeTransport.initialData = src.initialData;
  20273. if (!pdfDataRangeTransport.abort) {
  20274. pdfDataRangeTransport.abort = function () {
  20275. };
  20276. }
  20277. }
  20278. src = Object.create(src);
  20279. src.range = pdfDataRangeTransport;
  20280. }
  20281. task.onPassword = passwordCallback || null;
  20282. task.onProgress = progressCallback || null;
  20283. var source;
  20284. if (typeof src === 'string') {
  20285. source = { url: src };
  20286. } else if (isArrayBuffer(src)) {
  20287. source = { data: src };
  20288. } else if (src instanceof PDFDataRangeTransport) {
  20289. source = { range: src };
  20290. } else {
  20291. if (typeof src !== 'object') {
  20292. error('Invalid parameter in getDocument, need either Uint8Array, ' + 'string or a parameter object');
  20293. }
  20294. if (!src.url && !src.data && !src.range) {
  20295. error('Invalid parameter object: need either .data, .range or .url');
  20296. }
  20297. source = src;
  20298. }
  20299. var params = {};
  20300. var rangeTransport = null;
  20301. var worker = null;
  20302. for (var key in source) {
  20303. if (key === 'url' && typeof window !== 'undefined') {
  20304. params[key] = new URL(source[key], window.location).href;
  20305. continue;
  20306. } else if (key === 'range') {
  20307. rangeTransport = source[key];
  20308. continue;
  20309. } else if (key === 'worker') {
  20310. worker = source[key];
  20311. continue;
  20312. } else if (key === 'data' && !(source[key] instanceof Uint8Array)) {
  20313. var pdfBytes = source[key];
  20314. if (typeof pdfBytes === 'string') {
  20315. params[key] = stringToBytes(pdfBytes);
  20316. } else if (typeof pdfBytes === 'object' && pdfBytes !== null && !isNaN(pdfBytes.length)) {
  20317. params[key] = new Uint8Array(pdfBytes);
  20318. } else if (isArrayBuffer(pdfBytes)) {
  20319. params[key] = new Uint8Array(pdfBytes);
  20320. } else {
  20321. error('Invalid PDF binary data: either typed array, string or ' + 'array-like object is expected in the data property.');
  20322. }
  20323. continue;
  20324. }
  20325. params[key] = source[key];
  20326. }
  20327. params.rangeChunkSize = params.rangeChunkSize || DEFAULT_RANGE_CHUNK_SIZE;
  20328. params.disableNativeImageDecoder = params.disableNativeImageDecoder === true;
  20329. if (!worker) {
  20330. worker = new PDFWorker();
  20331. task._worker = worker;
  20332. }
  20333. var docId = task.docId;
  20334. worker.promise.then(function () {
  20335. if (task.destroyed) {
  20336. throw new Error('Loading aborted');
  20337. }
  20338. return _fetchDocument(worker, params, rangeTransport, docId).then(function (workerId) {
  20339. if (task.destroyed) {
  20340. throw new Error('Loading aborted');
  20341. }
  20342. var messageHandler = new MessageHandler(docId, workerId, worker.port);
  20343. var transport = new WorkerTransport(messageHandler, task, rangeTransport);
  20344. task._transport = transport;
  20345. messageHandler.send('Ready', null);
  20346. });
  20347. }).catch(task._capability.reject);
  20348. return task;
  20349. }
  20350. function _fetchDocument(worker, source, pdfDataRangeTransport, docId) {
  20351. if (worker.destroyed) {
  20352. return Promise.reject(new Error('Worker was destroyed'));
  20353. }
  20354. source.disableAutoFetch = getDefaultSetting('disableAutoFetch');
  20355. source.disableStream = getDefaultSetting('disableStream');
  20356. source.chunkedViewerLoading = !!pdfDataRangeTransport;
  20357. if (pdfDataRangeTransport) {
  20358. source.length = pdfDataRangeTransport.length;
  20359. source.initialData = pdfDataRangeTransport.initialData;
  20360. }
  20361. return worker.messageHandler.sendWithPromise('GetDocRequest', {
  20362. docId: docId,
  20363. source: source,
  20364. disableRange: getDefaultSetting('disableRange'),
  20365. maxImageSize: getDefaultSetting('maxImageSize'),
  20366. cMapUrl: getDefaultSetting('cMapUrl'),
  20367. cMapPacked: getDefaultSetting('cMapPacked'),
  20368. disableFontFace: getDefaultSetting('disableFontFace'),
  20369. disableCreateObjectURL: getDefaultSetting('disableCreateObjectURL'),
  20370. postMessageTransfers: getDefaultSetting('postMessageTransfers') && !isPostMessageTransfersDisabled,
  20371. docBaseUrl: source.docBaseUrl,
  20372. disableNativeImageDecoder: source.disableNativeImageDecoder
  20373. }).then(function (workerId) {
  20374. if (worker.destroyed) {
  20375. throw new Error('Worker was destroyed');
  20376. }
  20377. return workerId;
  20378. });
  20379. }
  20380. var PDFDocumentLoadingTask = function PDFDocumentLoadingTaskClosure() {
  20381. var nextDocumentId = 0;
  20382. function PDFDocumentLoadingTask() {
  20383. this._capability = createPromiseCapability();
  20384. this._transport = null;
  20385. this._worker = null;
  20386. this.docId = 'd' + nextDocumentId++;
  20387. this.destroyed = false;
  20388. this.onPassword = null;
  20389. this.onProgress = null;
  20390. this.onUnsupportedFeature = null;
  20391. }
  20392. PDFDocumentLoadingTask.prototype = {
  20393. get promise() {
  20394. return this._capability.promise;
  20395. },
  20396. destroy: function () {
  20397. this.destroyed = true;
  20398. var transportDestroyed = !this._transport ? Promise.resolve() : this._transport.destroy();
  20399. return transportDestroyed.then(function () {
  20400. this._transport = null;
  20401. if (this._worker) {
  20402. this._worker.destroy();
  20403. this._worker = null;
  20404. }
  20405. }.bind(this));
  20406. },
  20407. then: function PDFDocumentLoadingTask_then(onFulfilled, onRejected) {
  20408. return this.promise.then.apply(this.promise, arguments);
  20409. }
  20410. };
  20411. return PDFDocumentLoadingTask;
  20412. }();
  20413. var PDFDataRangeTransport = function pdfDataRangeTransportClosure() {
  20414. function PDFDataRangeTransport(length, initialData) {
  20415. this.length = length;
  20416. this.initialData = initialData;
  20417. this._rangeListeners = [];
  20418. this._progressListeners = [];
  20419. this._progressiveReadListeners = [];
  20420. this._readyCapability = createPromiseCapability();
  20421. }
  20422. PDFDataRangeTransport.prototype = {
  20423. addRangeListener: function PDFDataRangeTransport_addRangeListener(listener) {
  20424. this._rangeListeners.push(listener);
  20425. },
  20426. addProgressListener: function PDFDataRangeTransport_addProgressListener(listener) {
  20427. this._progressListeners.push(listener);
  20428. },
  20429. addProgressiveReadListener: function PDFDataRangeTransport_addProgressiveReadListener(listener) {
  20430. this._progressiveReadListeners.push(listener);
  20431. },
  20432. onDataRange: function PDFDataRangeTransport_onDataRange(begin, chunk) {
  20433. var listeners = this._rangeListeners;
  20434. for (var i = 0, n = listeners.length; i < n; ++i) {
  20435. listeners[i](begin, chunk);
  20436. }
  20437. },
  20438. onDataProgress: function PDFDataRangeTransport_onDataProgress(loaded) {
  20439. this._readyCapability.promise.then(function () {
  20440. var listeners = this._progressListeners;
  20441. for (var i = 0, n = listeners.length; i < n; ++i) {
  20442. listeners[i](loaded);
  20443. }
  20444. }.bind(this));
  20445. },
  20446. onDataProgressiveRead: function PDFDataRangeTransport_onDataProgress(chunk) {
  20447. this._readyCapability.promise.then(function () {
  20448. var listeners = this._progressiveReadListeners;
  20449. for (var i = 0, n = listeners.length; i < n; ++i) {
  20450. listeners[i](chunk);
  20451. }
  20452. }.bind(this));
  20453. },
  20454. transportReady: function PDFDataRangeTransport_transportReady() {
  20455. this._readyCapability.resolve();
  20456. },
  20457. requestDataRange: function PDFDataRangeTransport_requestDataRange(begin, end) {
  20458. throw new Error('Abstract method PDFDataRangeTransport.requestDataRange');
  20459. },
  20460. abort: function PDFDataRangeTransport_abort() {
  20461. }
  20462. };
  20463. return PDFDataRangeTransport;
  20464. }();
  20465. var PDFDocumentProxy = function PDFDocumentProxyClosure() {
  20466. function PDFDocumentProxy(pdfInfo, transport, loadingTask) {
  20467. this.pdfInfo = pdfInfo;
  20468. this.transport = transport;
  20469. this.loadingTask = loadingTask;
  20470. }
  20471. PDFDocumentProxy.prototype = {
  20472. get numPages() {
  20473. return this.pdfInfo.numPages;
  20474. },
  20475. get fingerprint() {
  20476. return this.pdfInfo.fingerprint;
  20477. },
  20478. getPage: function PDFDocumentProxy_getPage(pageNumber) {
  20479. return this.transport.getPage(pageNumber);
  20480. },
  20481. getPageIndex: function PDFDocumentProxy_getPageIndex(ref) {
  20482. return this.transport.getPageIndex(ref);
  20483. },
  20484. getDestinations: function PDFDocumentProxy_getDestinations() {
  20485. return this.transport.getDestinations();
  20486. },
  20487. getDestination: function PDFDocumentProxy_getDestination(id) {
  20488. return this.transport.getDestination(id);
  20489. },
  20490. getPageLabels: function PDFDocumentProxy_getPageLabels() {
  20491. return this.transport.getPageLabels();
  20492. },
  20493. getAttachments: function PDFDocumentProxy_getAttachments() {
  20494. return this.transport.getAttachments();
  20495. },
  20496. getJavaScript: function PDFDocumentProxy_getJavaScript() {
  20497. return this.transport.getJavaScript();
  20498. },
  20499. getOutline: function PDFDocumentProxy_getOutline() {
  20500. return this.transport.getOutline();
  20501. },
  20502. getMetadata: function PDFDocumentProxy_getMetadata() {
  20503. return this.transport.getMetadata();
  20504. },
  20505. getData: function PDFDocumentProxy_getData() {
  20506. return this.transport.getData();
  20507. },
  20508. getDownloadInfo: function PDFDocumentProxy_getDownloadInfo() {
  20509. return this.transport.downloadInfoCapability.promise;
  20510. },
  20511. getStats: function PDFDocumentProxy_getStats() {
  20512. return this.transport.getStats();
  20513. },
  20514. cleanup: function PDFDocumentProxy_cleanup() {
  20515. this.transport.startCleanup();
  20516. },
  20517. destroy: function PDFDocumentProxy_destroy() {
  20518. return this.loadingTask.destroy();
  20519. }
  20520. };
  20521. return PDFDocumentProxy;
  20522. }();
  20523. var PDFPageProxy = function PDFPageProxyClosure() {
  20524. function PDFPageProxy(pageIndex, pageInfo, transport) {
  20525. this.pageIndex = pageIndex;
  20526. this.pageInfo = pageInfo;
  20527. this.transport = transport;
  20528. this.stats = new StatTimer();
  20529. this.stats.enabled = getDefaultSetting('enableStats');
  20530. this.commonObjs = transport.commonObjs;
  20531. this.objs = new PDFObjects();
  20532. this.cleanupAfterRender = false;
  20533. this.pendingCleanup = false;
  20534. this.intentStates = Object.create(null);
  20535. this.destroyed = false;
  20536. }
  20537. PDFPageProxy.prototype = {
  20538. get pageNumber() {
  20539. return this.pageIndex + 1;
  20540. },
  20541. get rotate() {
  20542. return this.pageInfo.rotate;
  20543. },
  20544. get ref() {
  20545. return this.pageInfo.ref;
  20546. },
  20547. get userUnit() {
  20548. return this.pageInfo.userUnit;
  20549. },
  20550. get view() {
  20551. return this.pageInfo.view;
  20552. },
  20553. getViewport: function PDFPageProxy_getViewport(scale, rotate) {
  20554. if (arguments.length < 2) {
  20555. rotate = this.rotate;
  20556. }
  20557. return new PageViewport(this.view, scale, rotate, 0, 0);
  20558. },
  20559. getAnnotations: function PDFPageProxy_getAnnotations(params) {
  20560. var intent = params && params.intent || null;
  20561. if (!this.annotationsPromise || this.annotationsIntent !== intent) {
  20562. this.annotationsPromise = this.transport.getAnnotations(this.pageIndex, intent);
  20563. this.annotationsIntent = intent;
  20564. }
  20565. return this.annotationsPromise;
  20566. },
  20567. render: function PDFPageProxy_render(params) {
  20568. var stats = this.stats;
  20569. stats.time('Overall');
  20570. this.pendingCleanup = false;
  20571. var renderingIntent = params.intent === 'print' ? 'print' : 'display';
  20572. var renderInteractiveForms = params.renderInteractiveForms === true ? true : false;
  20573. var canvasFactory = params.canvasFactory || new DOMCanvasFactory();
  20574. if (!this.intentStates[renderingIntent]) {
  20575. this.intentStates[renderingIntent] = Object.create(null);
  20576. }
  20577. var intentState = this.intentStates[renderingIntent];
  20578. if (!intentState.displayReadyCapability) {
  20579. intentState.receivingOperatorList = true;
  20580. intentState.displayReadyCapability = createPromiseCapability();
  20581. intentState.operatorList = {
  20582. fnArray: [],
  20583. argsArray: [],
  20584. lastChunk: false
  20585. };
  20586. this.stats.time('Page Request');
  20587. this.transport.messageHandler.send('RenderPageRequest', {
  20588. pageIndex: this.pageNumber - 1,
  20589. intent: renderingIntent,
  20590. renderInteractiveForms: renderInteractiveForms
  20591. });
  20592. }
  20593. var internalRenderTask = new InternalRenderTask(complete, params, this.objs, this.commonObjs, intentState.operatorList, this.pageNumber, canvasFactory);
  20594. internalRenderTask.useRequestAnimationFrame = renderingIntent !== 'print';
  20595. if (!intentState.renderTasks) {
  20596. intentState.renderTasks = [];
  20597. }
  20598. intentState.renderTasks.push(internalRenderTask);
  20599. var renderTask = internalRenderTask.task;
  20600. if (params.continueCallback) {
  20601. deprecated('render is used with continueCallback parameter');
  20602. renderTask.onContinue = params.continueCallback;
  20603. }
  20604. var self = this;
  20605. intentState.displayReadyCapability.promise.then(function pageDisplayReadyPromise(transparency) {
  20606. if (self.pendingCleanup) {
  20607. complete();
  20608. return;
  20609. }
  20610. stats.time('Rendering');
  20611. internalRenderTask.initializeGraphics(transparency);
  20612. internalRenderTask.operatorListChanged();
  20613. }, function pageDisplayReadPromiseError(reason) {
  20614. complete(reason);
  20615. });
  20616. function complete(error) {
  20617. var i = intentState.renderTasks.indexOf(internalRenderTask);
  20618. if (i >= 0) {
  20619. intentState.renderTasks.splice(i, 1);
  20620. }
  20621. if (self.cleanupAfterRender) {
  20622. self.pendingCleanup = true;
  20623. }
  20624. self._tryCleanup();
  20625. if (error) {
  20626. internalRenderTask.capability.reject(error);
  20627. } else {
  20628. internalRenderTask.capability.resolve();
  20629. }
  20630. stats.timeEnd('Rendering');
  20631. stats.timeEnd('Overall');
  20632. }
  20633. return renderTask;
  20634. },
  20635. getOperatorList: function PDFPageProxy_getOperatorList() {
  20636. function operatorListChanged() {
  20637. if (intentState.operatorList.lastChunk) {
  20638. intentState.opListReadCapability.resolve(intentState.operatorList);
  20639. var i = intentState.renderTasks.indexOf(opListTask);
  20640. if (i >= 0) {
  20641. intentState.renderTasks.splice(i, 1);
  20642. }
  20643. }
  20644. }
  20645. var renderingIntent = 'oplist';
  20646. if (!this.intentStates[renderingIntent]) {
  20647. this.intentStates[renderingIntent] = Object.create(null);
  20648. }
  20649. var intentState = this.intentStates[renderingIntent];
  20650. var opListTask;
  20651. if (!intentState.opListReadCapability) {
  20652. opListTask = {};
  20653. opListTask.operatorListChanged = operatorListChanged;
  20654. intentState.receivingOperatorList = true;
  20655. intentState.opListReadCapability = createPromiseCapability();
  20656. intentState.renderTasks = [];
  20657. intentState.renderTasks.push(opListTask);
  20658. intentState.operatorList = {
  20659. fnArray: [],
  20660. argsArray: [],
  20661. lastChunk: false
  20662. };
  20663. this.transport.messageHandler.send('RenderPageRequest', {
  20664. pageIndex: this.pageIndex,
  20665. intent: renderingIntent
  20666. });
  20667. }
  20668. return intentState.opListReadCapability.promise;
  20669. },
  20670. getTextContent: function PDFPageProxy_getTextContent(params) {
  20671. return this.transport.messageHandler.sendWithPromise('GetTextContent', {
  20672. pageIndex: this.pageNumber - 1,
  20673. normalizeWhitespace: params && params.normalizeWhitespace === true ? true : false,
  20674. combineTextItems: params && params.disableCombineTextItems === true ? false : true
  20675. });
  20676. },
  20677. _destroy: function PDFPageProxy_destroy() {
  20678. this.destroyed = true;
  20679. this.transport.pageCache[this.pageIndex] = null;
  20680. var waitOn = [];
  20681. Object.keys(this.intentStates).forEach(function (intent) {
  20682. if (intent === 'oplist') {
  20683. return;
  20684. }
  20685. var intentState = this.intentStates[intent];
  20686. intentState.renderTasks.forEach(function (renderTask) {
  20687. var renderCompleted = renderTask.capability.promise.catch(function () {
  20688. });
  20689. waitOn.push(renderCompleted);
  20690. renderTask.cancel();
  20691. });
  20692. }, this);
  20693. this.objs.clear();
  20694. this.annotationsPromise = null;
  20695. this.pendingCleanup = false;
  20696. return Promise.all(waitOn);
  20697. },
  20698. destroy: function () {
  20699. deprecated('page destroy method, use cleanup() instead');
  20700. this.cleanup();
  20701. },
  20702. cleanup: function PDFPageProxy_cleanup() {
  20703. this.pendingCleanup = true;
  20704. this._tryCleanup();
  20705. },
  20706. _tryCleanup: function PDFPageProxy_tryCleanup() {
  20707. if (!this.pendingCleanup || Object.keys(this.intentStates).some(function (intent) {
  20708. var intentState = this.intentStates[intent];
  20709. return intentState.renderTasks.length !== 0 || intentState.receivingOperatorList;
  20710. }, this)) {
  20711. return;
  20712. }
  20713. Object.keys(this.intentStates).forEach(function (intent) {
  20714. delete this.intentStates[intent];
  20715. }, this);
  20716. this.objs.clear();
  20717. this.annotationsPromise = null;
  20718. this.pendingCleanup = false;
  20719. },
  20720. _startRenderPage: function PDFPageProxy_startRenderPage(transparency, intent) {
  20721. var intentState = this.intentStates[intent];
  20722. if (intentState.displayReadyCapability) {
  20723. intentState.displayReadyCapability.resolve(transparency);
  20724. }
  20725. },
  20726. _renderPageChunk: function PDFPageProxy_renderPageChunk(operatorListChunk, intent) {
  20727. var intentState = this.intentStates[intent];
  20728. var i, ii;
  20729. for (i = 0, ii = operatorListChunk.length; i < ii; i++) {
  20730. intentState.operatorList.fnArray.push(operatorListChunk.fnArray[i]);
  20731. intentState.operatorList.argsArray.push(operatorListChunk.argsArray[i]);
  20732. }
  20733. intentState.operatorList.lastChunk = operatorListChunk.lastChunk;
  20734. for (i = 0; i < intentState.renderTasks.length; i++) {
  20735. intentState.renderTasks[i].operatorListChanged();
  20736. }
  20737. if (operatorListChunk.lastChunk) {
  20738. intentState.receivingOperatorList = false;
  20739. this._tryCleanup();
  20740. }
  20741. }
  20742. };
  20743. return PDFPageProxy;
  20744. }();
  20745. var PDFWorker = function PDFWorkerClosure() {
  20746. var nextFakeWorkerId = 0;
  20747. function getWorkerSrc() {
  20748. if (typeof workerSrc !== 'undefined') {
  20749. return workerSrc;
  20750. }
  20751. if (getDefaultSetting('workerSrc')) {
  20752. return getDefaultSetting('workerSrc');
  20753. }
  20754. if (pdfjsFilePath) {
  20755. return pdfjsFilePath.replace(/\.js$/i, '.worker.js');
  20756. }
  20757. error('No PDFJS.workerSrc specified');
  20758. }
  20759. var fakeWorkerFilesLoadedCapability;
  20760. function setupFakeWorkerGlobal() {
  20761. var WorkerMessageHandler;
  20762. if (fakeWorkerFilesLoadedCapability) {
  20763. return fakeWorkerFilesLoadedCapability.promise;
  20764. }
  20765. fakeWorkerFilesLoadedCapability = createPromiseCapability();
  20766. WorkerMessageHandler = pdfjsLibs.pdfjsCoreWorker.WorkerMessageHandler;
  20767. fakeWorkerFilesLoadedCapability.resolve(WorkerMessageHandler);
  20768. return fakeWorkerFilesLoadedCapability.promise;
  20769. }
  20770. function FakeWorkerPort(defer) {
  20771. this._listeners = [];
  20772. this._defer = defer;
  20773. this._deferred = Promise.resolve(undefined);
  20774. }
  20775. FakeWorkerPort.prototype = {
  20776. postMessage: function (obj, transfers) {
  20777. function cloneValue(value) {
  20778. if (typeof value !== 'object' || value === null) {
  20779. return value;
  20780. }
  20781. if (cloned.has(value)) {
  20782. return cloned.get(value);
  20783. }
  20784. var result;
  20785. var buffer;
  20786. if ((buffer = value.buffer) && isArrayBuffer(buffer)) {
  20787. var transferable = transfers && transfers.indexOf(buffer) >= 0;
  20788. if (value === buffer) {
  20789. result = value;
  20790. } else if (transferable) {
  20791. result = new value.constructor(buffer, value.byteOffset, value.byteLength);
  20792. } else {
  20793. result = new value.constructor(value);
  20794. }
  20795. cloned.set(value, result);
  20796. return result;
  20797. }
  20798. result = isArray(value) ? [] : {};
  20799. cloned.set(value, result);
  20800. for (var i in value) {
  20801. var desc, p = value;
  20802. while (!(desc = Object.getOwnPropertyDescriptor(p, i))) {
  20803. p = Object.getPrototypeOf(p);
  20804. }
  20805. if (typeof desc.value === 'undefined' || typeof desc.value === 'function') {
  20806. continue;
  20807. }
  20808. result[i] = cloneValue(desc.value);
  20809. }
  20810. return result;
  20811. }
  20812. if (!this._defer) {
  20813. this._listeners.forEach(function (listener) {
  20814. listener.call(this, { data: obj });
  20815. }, this);
  20816. return;
  20817. }
  20818. var cloned = new WeakMap();
  20819. var e = { data: cloneValue(obj) };
  20820. this._deferred.then(function () {
  20821. this._listeners.forEach(function (listener) {
  20822. listener.call(this, e);
  20823. }, this);
  20824. }.bind(this));
  20825. },
  20826. addEventListener: function (name, listener) {
  20827. this._listeners.push(listener);
  20828. },
  20829. removeEventListener: function (name, listener) {
  20830. var i = this._listeners.indexOf(listener);
  20831. this._listeners.splice(i, 1);
  20832. },
  20833. terminate: function () {
  20834. this._listeners = [];
  20835. }
  20836. };
  20837. function createCDNWrapper(url) {
  20838. var wrapper = 'importScripts(\'' + url + '\');';
  20839. return URL.createObjectURL(new Blob([wrapper]));
  20840. }
  20841. function PDFWorker(name) {
  20842. this.name = name;
  20843. this.destroyed = false;
  20844. this._readyCapability = createPromiseCapability();
  20845. this._port = null;
  20846. this._webWorker = null;
  20847. this._messageHandler = null;
  20848. this._initialize();
  20849. }
  20850. PDFWorker.prototype = {
  20851. get promise() {
  20852. return this._readyCapability.promise;
  20853. },
  20854. get port() {
  20855. return this._port;
  20856. },
  20857. get messageHandler() {
  20858. return this._messageHandler;
  20859. },
  20860. _initialize: function PDFWorker_initialize() {
  20861. this._setupFakeWorker();
  20862. },
  20863. _setupFakeWorker: function PDFWorker_setupFakeWorker() {
  20864. if (!isWorkerDisabled && !getDefaultSetting('disableWorker')) {
  20865. warn('Setting up fake worker.');
  20866. isWorkerDisabled = true;
  20867. }
  20868. setupFakeWorkerGlobal().then(function (WorkerMessageHandler) {
  20869. if (this.destroyed) {
  20870. this._readyCapability.reject(new Error('Worker was destroyed'));
  20871. return;
  20872. }
  20873. var isTypedArraysPresent = Uint8Array !== Float32Array;
  20874. var port = new FakeWorkerPort(isTypedArraysPresent);
  20875. this._port = port;
  20876. var id = 'fake' + nextFakeWorkerId++;
  20877. var workerHandler = new MessageHandler(id + '_worker', id, port);
  20878. WorkerMessageHandler.setup(workerHandler, port);
  20879. var messageHandler = new MessageHandler(id, id + '_worker', port);
  20880. this._messageHandler = messageHandler;
  20881. this._readyCapability.resolve();
  20882. }.bind(this));
  20883. },
  20884. destroy: function PDFWorker_destroy() {
  20885. this.destroyed = true;
  20886. if (this._webWorker) {
  20887. this._webWorker.terminate();
  20888. this._webWorker = null;
  20889. }
  20890. this._port = null;
  20891. if (this._messageHandler) {
  20892. this._messageHandler.destroy();
  20893. this._messageHandler = null;
  20894. }
  20895. }
  20896. };
  20897. return PDFWorker;
  20898. }();
  20899. var WorkerTransport = function WorkerTransportClosure() {
  20900. function WorkerTransport(messageHandler, loadingTask, pdfDataRangeTransport) {
  20901. this.messageHandler = messageHandler;
  20902. this.loadingTask = loadingTask;
  20903. this.pdfDataRangeTransport = pdfDataRangeTransport;
  20904. this.commonObjs = new PDFObjects();
  20905. this.fontLoader = new FontLoader(loadingTask.docId);
  20906. this.destroyed = false;
  20907. this.destroyCapability = null;
  20908. this._passwordCapability = null;
  20909. this.pageCache = [];
  20910. this.pagePromises = [];
  20911. this.downloadInfoCapability = createPromiseCapability();
  20912. this.setupMessageHandler();
  20913. }
  20914. WorkerTransport.prototype = {
  20915. destroy: function WorkerTransport_destroy() {
  20916. if (this.destroyCapability) {
  20917. return this.destroyCapability.promise;
  20918. }
  20919. this.destroyed = true;
  20920. this.destroyCapability = createPromiseCapability();
  20921. if (this._passwordCapability) {
  20922. this._passwordCapability.reject(new Error('Worker was destroyed during onPassword callback'));
  20923. }
  20924. var waitOn = [];
  20925. this.pageCache.forEach(function (page) {
  20926. if (page) {
  20927. waitOn.push(page._destroy());
  20928. }
  20929. });
  20930. this.pageCache = [];
  20931. this.pagePromises = [];
  20932. var self = this;
  20933. var terminated = this.messageHandler.sendWithPromise('Terminate', null);
  20934. waitOn.push(terminated);
  20935. Promise.all(waitOn).then(function () {
  20936. self.fontLoader.clear();
  20937. if (self.pdfDataRangeTransport) {
  20938. self.pdfDataRangeTransport.abort();
  20939. self.pdfDataRangeTransport = null;
  20940. }
  20941. if (self.messageHandler) {
  20942. self.messageHandler.destroy();
  20943. self.messageHandler = null;
  20944. }
  20945. self.destroyCapability.resolve();
  20946. }, this.destroyCapability.reject);
  20947. return this.destroyCapability.promise;
  20948. },
  20949. setupMessageHandler: function WorkerTransport_setupMessageHandler() {
  20950. var messageHandler = this.messageHandler;
  20951. var loadingTask = this.loadingTask;
  20952. var pdfDataRangeTransport = this.pdfDataRangeTransport;
  20953. if (pdfDataRangeTransport) {
  20954. pdfDataRangeTransport.addRangeListener(function (begin, chunk) {
  20955. messageHandler.send('OnDataRange', {
  20956. begin: begin,
  20957. chunk: chunk
  20958. });
  20959. });
  20960. pdfDataRangeTransport.addProgressListener(function (loaded) {
  20961. messageHandler.send('OnDataProgress', { loaded: loaded });
  20962. });
  20963. pdfDataRangeTransport.addProgressiveReadListener(function (chunk) {
  20964. messageHandler.send('OnDataRange', { chunk: chunk });
  20965. });
  20966. messageHandler.on('RequestDataRange', function transportDataRange(data) {
  20967. pdfDataRangeTransport.requestDataRange(data.begin, data.end);
  20968. }, this);
  20969. }
  20970. messageHandler.on('GetDoc', function transportDoc(data) {
  20971. var pdfInfo = data.pdfInfo;
  20972. this.numPages = data.pdfInfo.numPages;
  20973. var loadingTask = this.loadingTask;
  20974. var pdfDocument = new PDFDocumentProxy(pdfInfo, this, loadingTask);
  20975. this.pdfDocument = pdfDocument;
  20976. loadingTask._capability.resolve(pdfDocument);
  20977. }, this);
  20978. messageHandler.on('PasswordRequest', function transportPasswordRequest(exception) {
  20979. this._passwordCapability = createPromiseCapability();
  20980. if (loadingTask.onPassword) {
  20981. var updatePassword = function (password) {
  20982. this._passwordCapability.resolve({ password: password });
  20983. }.bind(this);
  20984. loadingTask.onPassword(updatePassword, exception.code);
  20985. } else {
  20986. this._passwordCapability.reject(new PasswordException(exception.message, exception.code));
  20987. }
  20988. return this._passwordCapability.promise;
  20989. }, this);
  20990. messageHandler.on('PasswordException', function transportPasswordException(exception) {
  20991. loadingTask._capability.reject(new PasswordException(exception.message, exception.code));
  20992. }, this);
  20993. messageHandler.on('InvalidPDF', function transportInvalidPDF(exception) {
  20994. this.loadingTask._capability.reject(new InvalidPDFException(exception.message));
  20995. }, this);
  20996. messageHandler.on('MissingPDF', function transportMissingPDF(exception) {
  20997. this.loadingTask._capability.reject(new MissingPDFException(exception.message));
  20998. }, this);
  20999. messageHandler.on('UnexpectedResponse', function transportUnexpectedResponse(exception) {
  21000. this.loadingTask._capability.reject(new UnexpectedResponseException(exception.message, exception.status));
  21001. }, this);
  21002. messageHandler.on('UnknownError', function transportUnknownError(exception) {
  21003. this.loadingTask._capability.reject(new UnknownErrorException(exception.message, exception.details));
  21004. }, this);
  21005. messageHandler.on('DataLoaded', function transportPage(data) {
  21006. this.downloadInfoCapability.resolve(data);
  21007. }, this);
  21008. messageHandler.on('PDFManagerReady', function transportPage(data) {
  21009. if (this.pdfDataRangeTransport) {
  21010. this.pdfDataRangeTransport.transportReady();
  21011. }
  21012. }, this);
  21013. messageHandler.on('StartRenderPage', function transportRender(data) {
  21014. if (this.destroyed) {
  21015. return;
  21016. }
  21017. var page = this.pageCache[data.pageIndex];
  21018. page.stats.timeEnd('Page Request');
  21019. page._startRenderPage(data.transparency, data.intent);
  21020. }, this);
  21021. messageHandler.on('RenderPageChunk', function transportRender(data) {
  21022. if (this.destroyed) {
  21023. return;
  21024. }
  21025. var page = this.pageCache[data.pageIndex];
  21026. page._renderPageChunk(data.operatorList, data.intent);
  21027. }, this);
  21028. messageHandler.on('commonobj', function transportObj(data) {
  21029. if (this.destroyed) {
  21030. return;
  21031. }
  21032. var id = data[0];
  21033. var type = data[1];
  21034. if (this.commonObjs.hasData(id)) {
  21035. return;
  21036. }
  21037. switch (type) {
  21038. case 'Font':
  21039. var exportedData = data[2];
  21040. if ('error' in exportedData) {
  21041. var exportedError = exportedData.error;
  21042. warn('Error during font loading: ' + exportedError);
  21043. this.commonObjs.resolve(id, exportedError);
  21044. break;
  21045. }
  21046. var fontRegistry = null;
  21047. if (getDefaultSetting('pdfBug') && globalScope.FontInspector && globalScope['FontInspector'].enabled) {
  21048. fontRegistry = {
  21049. registerFont: function (font, url) {
  21050. globalScope['FontInspector'].fontAdded(font, url);
  21051. }
  21052. };
  21053. }
  21054. var font = new FontFaceObject(exportedData, {
  21055. isEvalSuported: getDefaultSetting('isEvalSupported'),
  21056. disableFontFace: getDefaultSetting('disableFontFace'),
  21057. fontRegistry: fontRegistry
  21058. });
  21059. this.fontLoader.bind([font], function fontReady(fontObjs) {
  21060. this.commonObjs.resolve(id, font);
  21061. }.bind(this));
  21062. break;
  21063. case 'FontPath':
  21064. this.commonObjs.resolve(id, data[2]);
  21065. break;
  21066. default:
  21067. error('Got unknown common object type ' + type);
  21068. }
  21069. }, this);
  21070. messageHandler.on('obj', function transportObj(data) {
  21071. if (this.destroyed) {
  21072. return;
  21073. }
  21074. var id = data[0];
  21075. var pageIndex = data[1];
  21076. var type = data[2];
  21077. var pageProxy = this.pageCache[pageIndex];
  21078. var imageData;
  21079. if (pageProxy.objs.hasData(id)) {
  21080. return;
  21081. }
  21082. switch (type) {
  21083. case 'JpegStream':
  21084. imageData = data[3];
  21085. loadJpegStream(id, imageData, pageProxy.objs);
  21086. break;
  21087. case 'Image':
  21088. imageData = data[3];
  21089. pageProxy.objs.resolve(id, imageData);
  21090. var MAX_IMAGE_SIZE_TO_STORE = 8000000;
  21091. if (imageData && 'data' in imageData && imageData.data.length > MAX_IMAGE_SIZE_TO_STORE) {
  21092. pageProxy.cleanupAfterRender = true;
  21093. }
  21094. break;
  21095. default:
  21096. error('Got unknown object type ' + type);
  21097. }
  21098. }, this);
  21099. messageHandler.on('DocProgress', function transportDocProgress(data) {
  21100. if (this.destroyed) {
  21101. return;
  21102. }
  21103. var loadingTask = this.loadingTask;
  21104. if (loadingTask.onProgress) {
  21105. loadingTask.onProgress({
  21106. loaded: data.loaded,
  21107. total: data.total
  21108. });
  21109. }
  21110. }, this);
  21111. messageHandler.on('PageError', function transportError(data) {
  21112. if (this.destroyed) {
  21113. return;
  21114. }
  21115. var page = this.pageCache[data.pageNum - 1];
  21116. var intentState = page.intentStates[data.intent];
  21117. if (intentState.displayReadyCapability) {
  21118. intentState.displayReadyCapability.reject(data.error);
  21119. } else {
  21120. error(data.error);
  21121. }
  21122. if (intentState.operatorList) {
  21123. intentState.operatorList.lastChunk = true;
  21124. for (var i = 0; i < intentState.renderTasks.length; i++) {
  21125. intentState.renderTasks[i].operatorListChanged();
  21126. }
  21127. }
  21128. }, this);
  21129. messageHandler.on('UnsupportedFeature', function transportUnsupportedFeature(data) {
  21130. if (this.destroyed) {
  21131. return;
  21132. }
  21133. var featureId = data.featureId;
  21134. var loadingTask = this.loadingTask;
  21135. if (loadingTask.onUnsupportedFeature) {
  21136. loadingTask.onUnsupportedFeature(featureId);
  21137. }
  21138. _UnsupportedManager.notify(featureId);
  21139. }, this);
  21140. messageHandler.on('JpegDecode', function (data) {
  21141. if (this.destroyed) {
  21142. return Promise.reject(new Error('Worker was destroyed'));
  21143. }
  21144. if (typeof document === 'undefined') {
  21145. return Promise.reject(new Error('"document" is not defined.'));
  21146. }
  21147. var imageUrl = data[0];
  21148. var components = data[1];
  21149. if (components !== 3 && components !== 1) {
  21150. return Promise.reject(new Error('Only 3 components or 1 component can be returned'));
  21151. }
  21152. return new Promise(function (resolve, reject) {
  21153. var img = new Image();
  21154. img.onload = function () {
  21155. var width = img.width;
  21156. var height = img.height;
  21157. var size = width * height;
  21158. var rgbaLength = size * 4;
  21159. var buf = new Uint8Array(size * components);
  21160. var tmpCanvas = document.createElement('canvas');
  21161. tmpCanvas.width = width;
  21162. tmpCanvas.height = height;
  21163. var tmpCtx = tmpCanvas.getContext('2d');
  21164. tmpCtx.drawImage(img, 0, 0);
  21165. var data = tmpCtx.getImageData(0, 0, width, height).data;
  21166. var i, j;
  21167. if (components === 3) {
  21168. for (i = 0, j = 0; i < rgbaLength; i += 4, j += 3) {
  21169. buf[j] = data[i];
  21170. buf[j + 1] = data[i + 1];
  21171. buf[j + 2] = data[i + 2];
  21172. }
  21173. } else if (components === 1) {
  21174. for (i = 0, j = 0; i < rgbaLength; i += 4, j++) {
  21175. buf[j] = data[i];
  21176. }
  21177. }
  21178. resolve({
  21179. data: buf,
  21180. width: width,
  21181. height: height
  21182. });
  21183. };
  21184. img.onerror = function () {
  21185. reject(new Error('JpegDecode failed to load image'));
  21186. };
  21187. img.src = imageUrl;
  21188. });
  21189. }, this);
  21190. },
  21191. getData: function WorkerTransport_getData() {
  21192. return this.messageHandler.sendWithPromise('GetData', null);
  21193. },
  21194. getPage: function WorkerTransport_getPage(pageNumber, capability) {
  21195. if (!isInt(pageNumber) || pageNumber <= 0 || pageNumber > this.numPages) {
  21196. return Promise.reject(new Error('Invalid page request'));
  21197. }
  21198. var pageIndex = pageNumber - 1;
  21199. if (pageIndex in this.pagePromises) {
  21200. return this.pagePromises[pageIndex];
  21201. }
  21202. var promise = this.messageHandler.sendWithPromise('GetPage', { pageIndex: pageIndex }).then(function (pageInfo) {
  21203. if (this.destroyed) {
  21204. throw new Error('Transport destroyed');
  21205. }
  21206. var page = new PDFPageProxy(pageIndex, pageInfo, this);
  21207. this.pageCache[pageIndex] = page;
  21208. return page;
  21209. }.bind(this));
  21210. this.pagePromises[pageIndex] = promise;
  21211. return promise;
  21212. },
  21213. getPageIndex: function WorkerTransport_getPageIndexByRef(ref) {
  21214. return this.messageHandler.sendWithPromise('GetPageIndex', { ref: ref }).catch(function (reason) {
  21215. return Promise.reject(new Error(reason));
  21216. });
  21217. },
  21218. getAnnotations: function WorkerTransport_getAnnotations(pageIndex, intent) {
  21219. return this.messageHandler.sendWithPromise('GetAnnotations', {
  21220. pageIndex: pageIndex,
  21221. intent: intent
  21222. });
  21223. },
  21224. getDestinations: function WorkerTransport_getDestinations() {
  21225. return this.messageHandler.sendWithPromise('GetDestinations', null);
  21226. },
  21227. getDestination: function WorkerTransport_getDestination(id) {
  21228. return this.messageHandler.sendWithPromise('GetDestination', { id: id });
  21229. },
  21230. getPageLabels: function WorkerTransport_getPageLabels() {
  21231. return this.messageHandler.sendWithPromise('GetPageLabels', null);
  21232. },
  21233. getAttachments: function WorkerTransport_getAttachments() {
  21234. return this.messageHandler.sendWithPromise('GetAttachments', null);
  21235. },
  21236. getJavaScript: function WorkerTransport_getJavaScript() {
  21237. return this.messageHandler.sendWithPromise('GetJavaScript', null);
  21238. },
  21239. getOutline: function WorkerTransport_getOutline() {
  21240. return this.messageHandler.sendWithPromise('GetOutline', null);
  21241. },
  21242. getMetadata: function WorkerTransport_getMetadata() {
  21243. return this.messageHandler.sendWithPromise('GetMetadata', null).then(function transportMetadata(results) {
  21244. return {
  21245. info: results[0],
  21246. metadata: results[1] ? new Metadata(results[1]) : null
  21247. };
  21248. });
  21249. },
  21250. getStats: function WorkerTransport_getStats() {
  21251. return this.messageHandler.sendWithPromise('GetStats', null);
  21252. },
  21253. startCleanup: function WorkerTransport_startCleanup() {
  21254. this.messageHandler.sendWithPromise('Cleanup', null).then(function endCleanup() {
  21255. for (var i = 0, ii = this.pageCache.length; i < ii; i++) {
  21256. var page = this.pageCache[i];
  21257. if (page) {
  21258. page.cleanup();
  21259. }
  21260. }
  21261. this.commonObjs.clear();
  21262. this.fontLoader.clear();
  21263. }.bind(this));
  21264. }
  21265. };
  21266. return WorkerTransport;
  21267. }();
  21268. var PDFObjects = function PDFObjectsClosure() {
  21269. function PDFObjects() {
  21270. this.objs = Object.create(null);
  21271. }
  21272. PDFObjects.prototype = {
  21273. ensureObj: function PDFObjects_ensureObj(objId) {
  21274. if (this.objs[objId]) {
  21275. return this.objs[objId];
  21276. }
  21277. var obj = {
  21278. capability: createPromiseCapability(),
  21279. data: null,
  21280. resolved: false
  21281. };
  21282. this.objs[objId] = obj;
  21283. return obj;
  21284. },
  21285. get: function PDFObjects_get(objId, callback) {
  21286. if (callback) {
  21287. this.ensureObj(objId).capability.promise.then(callback);
  21288. return null;
  21289. }
  21290. var obj = this.objs[objId];
  21291. if (!obj || !obj.resolved) {
  21292. error('Requesting object that isn\'t resolved yet ' + objId);
  21293. }
  21294. return obj.data;
  21295. },
  21296. resolve: function PDFObjects_resolve(objId, data) {
  21297. var obj = this.ensureObj(objId);
  21298. obj.resolved = true;
  21299. obj.data = data;
  21300. obj.capability.resolve(data);
  21301. },
  21302. isResolved: function PDFObjects_isResolved(objId) {
  21303. var objs = this.objs;
  21304. if (!objs[objId]) {
  21305. return false;
  21306. }
  21307. return objs[objId].resolved;
  21308. },
  21309. hasData: function PDFObjects_hasData(objId) {
  21310. return this.isResolved(objId);
  21311. },
  21312. getData: function PDFObjects_getData(objId) {
  21313. var objs = this.objs;
  21314. if (!objs[objId] || !objs[objId].resolved) {
  21315. return null;
  21316. }
  21317. return objs[objId].data;
  21318. },
  21319. clear: function PDFObjects_clear() {
  21320. this.objs = Object.create(null);
  21321. }
  21322. };
  21323. return PDFObjects;
  21324. }();
  21325. var RenderTask = function RenderTaskClosure() {
  21326. function RenderTask(internalRenderTask) {
  21327. this._internalRenderTask = internalRenderTask;
  21328. this.onContinue = null;
  21329. }
  21330. RenderTask.prototype = {
  21331. get promise() {
  21332. return this._internalRenderTask.capability.promise;
  21333. },
  21334. cancel: function RenderTask_cancel() {
  21335. this._internalRenderTask.cancel();
  21336. },
  21337. then: function RenderTask_then(onFulfilled, onRejected) {
  21338. return this.promise.then.apply(this.promise, arguments);
  21339. }
  21340. };
  21341. return RenderTask;
  21342. }();
  21343. var InternalRenderTask = function InternalRenderTaskClosure() {
  21344. function InternalRenderTask(callback, params, objs, commonObjs, operatorList, pageNumber, canvasFactory) {
  21345. this.callback = callback;
  21346. this.params = params;
  21347. this.objs = objs;
  21348. this.commonObjs = commonObjs;
  21349. this.operatorListIdx = null;
  21350. this.operatorList = operatorList;
  21351. this.pageNumber = pageNumber;
  21352. this.canvasFactory = canvasFactory;
  21353. this.running = false;
  21354. this.graphicsReadyCallback = null;
  21355. this.graphicsReady = false;
  21356. this.useRequestAnimationFrame = false;
  21357. this.cancelled = false;
  21358. this.capability = createPromiseCapability();
  21359. this.task = new RenderTask(this);
  21360. this._continueBound = this._continue.bind(this);
  21361. this._scheduleNextBound = this._scheduleNext.bind(this);
  21362. this._nextBound = this._next.bind(this);
  21363. }
  21364. InternalRenderTask.prototype = {
  21365. initializeGraphics: function InternalRenderTask_initializeGraphics(transparency) {
  21366. if (this.cancelled) {
  21367. return;
  21368. }
  21369. if (getDefaultSetting('pdfBug') && globalScope.StepperManager && globalScope.StepperManager.enabled) {
  21370. this.stepper = globalScope.StepperManager.create(this.pageNumber - 1);
  21371. this.stepper.init(this.operatorList);
  21372. this.stepper.nextBreakPoint = this.stepper.getNextBreakPoint();
  21373. }
  21374. var params = this.params;
  21375. this.gfx = new CanvasGraphics(params.canvasContext, this.commonObjs, this.objs, this.canvasFactory, params.imageLayer);
  21376. this.gfx.beginDrawing(params.transform, params.viewport, transparency);
  21377. this.operatorListIdx = 0;
  21378. this.graphicsReady = true;
  21379. if (this.graphicsReadyCallback) {
  21380. this.graphicsReadyCallback();
  21381. }
  21382. },
  21383. cancel: function InternalRenderTask_cancel() {
  21384. this.running = false;
  21385. this.cancelled = true;
  21386. this.callback('cancelled');
  21387. },
  21388. operatorListChanged: function InternalRenderTask_operatorListChanged() {
  21389. if (!this.graphicsReady) {
  21390. if (!this.graphicsReadyCallback) {
  21391. this.graphicsReadyCallback = this._continueBound;
  21392. }
  21393. return;
  21394. }
  21395. if (this.stepper) {
  21396. this.stepper.updateOperatorList(this.operatorList);
  21397. }
  21398. if (this.running) {
  21399. return;
  21400. }
  21401. this._continue();
  21402. },
  21403. _continue: function InternalRenderTask__continue() {
  21404. this.running = true;
  21405. if (this.cancelled) {
  21406. return;
  21407. }
  21408. if (this.task.onContinue) {
  21409. this.task.onContinue(this._scheduleNextBound);
  21410. } else {
  21411. this._scheduleNext();
  21412. }
  21413. },
  21414. _scheduleNext: function InternalRenderTask__scheduleNext() {
  21415. if (this.useRequestAnimationFrame && typeof window !== 'undefined') {
  21416. window.requestAnimationFrame(this._nextBound);
  21417. } else {
  21418. Promise.resolve(undefined).then(this._nextBound);
  21419. }
  21420. },
  21421. _next: function InternalRenderTask__next() {
  21422. if (this.cancelled) {
  21423. return;
  21424. }
  21425. this.operatorListIdx = this.gfx.executeOperatorList(this.operatorList, this.operatorListIdx, this._continueBound, this.stepper);
  21426. if (this.operatorListIdx === this.operatorList.argsArray.length) {
  21427. this.running = false;
  21428. if (this.operatorList.lastChunk) {
  21429. this.gfx.endDrawing();
  21430. this.callback();
  21431. }
  21432. }
  21433. }
  21434. };
  21435. return InternalRenderTask;
  21436. }();
  21437. var _UnsupportedManager = function UnsupportedManagerClosure() {
  21438. var listeners = [];
  21439. return {
  21440. listen: function (cb) {
  21441. deprecated('Global UnsupportedManager.listen is used: ' + ' use PDFDocumentLoadingTask.onUnsupportedFeature instead');
  21442. listeners.push(cb);
  21443. },
  21444. notify: function (featureId) {
  21445. for (var i = 0, ii = listeners.length; i < ii; i++) {
  21446. listeners[i](featureId);
  21447. }
  21448. }
  21449. };
  21450. }();
  21451. exports.version = '1.7.276';
  21452. exports.build = 'ba81b37b';
  21453. exports.getDocument = getDocument;
  21454. exports.PDFDataRangeTransport = PDFDataRangeTransport;
  21455. exports.PDFWorker = PDFWorker;
  21456. exports.PDFDocumentProxy = PDFDocumentProxy;
  21457. exports.PDFPageProxy = PDFPageProxy;
  21458. exports._UnsupportedManager = _UnsupportedManager;
  21459. /***/ }),
  21460. /* 12 */
  21461. /***/ (function(module, exports, __w_pdfjs_require__) {
  21462. "use strict";
  21463. var sharedUtil = __w_pdfjs_require__(0);
  21464. var FONT_IDENTITY_MATRIX = sharedUtil.FONT_IDENTITY_MATRIX;
  21465. var IDENTITY_MATRIX = sharedUtil.IDENTITY_MATRIX;
  21466. var ImageKind = sharedUtil.ImageKind;
  21467. var OPS = sharedUtil.OPS;
  21468. var Util = sharedUtil.Util;
  21469. var isNum = sharedUtil.isNum;
  21470. var isArray = sharedUtil.isArray;
  21471. var warn = sharedUtil.warn;
  21472. var createObjectURL = sharedUtil.createObjectURL;
  21473. var SVG_DEFAULTS = {
  21474. fontStyle: 'normal',
  21475. fontWeight: 'normal',
  21476. fillColor: '#000000'
  21477. };
  21478. var convertImgDataToPng = function convertImgDataToPngClosure() {
  21479. var PNG_HEADER = new Uint8Array([
  21480. 0x89,
  21481. 0x50,
  21482. 0x4e,
  21483. 0x47,
  21484. 0x0d,
  21485. 0x0a,
  21486. 0x1a,
  21487. 0x0a
  21488. ]);
  21489. var CHUNK_WRAPPER_SIZE = 12;
  21490. var crcTable = new Int32Array(256);
  21491. for (var i = 0; i < 256; i++) {
  21492. var c = i;
  21493. for (var h = 0; h < 8; h++) {
  21494. if (c & 1) {
  21495. c = 0xedB88320 ^ c >> 1 & 0x7fffffff;
  21496. } else {
  21497. c = c >> 1 & 0x7fffffff;
  21498. }
  21499. }
  21500. crcTable[i] = c;
  21501. }
  21502. function crc32(data, start, end) {
  21503. var crc = -1;
  21504. for (var i = start; i < end; i++) {
  21505. var a = (crc ^ data[i]) & 0xff;
  21506. var b = crcTable[a];
  21507. crc = crc >>> 8 ^ b;
  21508. }
  21509. return crc ^ -1;
  21510. }
  21511. function writePngChunk(type, body, data, offset) {
  21512. var p = offset;
  21513. var len = body.length;
  21514. data[p] = len >> 24 & 0xff;
  21515. data[p + 1] = len >> 16 & 0xff;
  21516. data[p + 2] = len >> 8 & 0xff;
  21517. data[p + 3] = len & 0xff;
  21518. p += 4;
  21519. data[p] = type.charCodeAt(0) & 0xff;
  21520. data[p + 1] = type.charCodeAt(1) & 0xff;
  21521. data[p + 2] = type.charCodeAt(2) & 0xff;
  21522. data[p + 3] = type.charCodeAt(3) & 0xff;
  21523. p += 4;
  21524. data.set(body, p);
  21525. p += body.length;
  21526. var crc = crc32(data, offset + 4, p);
  21527. data[p] = crc >> 24 & 0xff;
  21528. data[p + 1] = crc >> 16 & 0xff;
  21529. data[p + 2] = crc >> 8 & 0xff;
  21530. data[p + 3] = crc & 0xff;
  21531. }
  21532. function adler32(data, start, end) {
  21533. var a = 1;
  21534. var b = 0;
  21535. for (var i = start; i < end; ++i) {
  21536. a = (a + (data[i] & 0xff)) % 65521;
  21537. b = (b + a) % 65521;
  21538. }
  21539. return b << 16 | a;
  21540. }
  21541. function encode(imgData, kind, forceDataSchema) {
  21542. var width = imgData.width;
  21543. var height = imgData.height;
  21544. var bitDepth, colorType, lineSize;
  21545. var bytes = imgData.data;
  21546. switch (kind) {
  21547. case ImageKind.GRAYSCALE_1BPP:
  21548. colorType = 0;
  21549. bitDepth = 1;
  21550. lineSize = width + 7 >> 3;
  21551. break;
  21552. case ImageKind.RGB_24BPP:
  21553. colorType = 2;
  21554. bitDepth = 8;
  21555. lineSize = width * 3;
  21556. break;
  21557. case ImageKind.RGBA_32BPP:
  21558. colorType = 6;
  21559. bitDepth = 8;
  21560. lineSize = width * 4;
  21561. break;
  21562. default:
  21563. throw new Error('invalid format');
  21564. }
  21565. var literals = new Uint8Array((1 + lineSize) * height);
  21566. var offsetLiterals = 0, offsetBytes = 0;
  21567. var y, i;
  21568. for (y = 0; y < height; ++y) {
  21569. literals[offsetLiterals++] = 0;
  21570. literals.set(bytes.subarray(offsetBytes, offsetBytes + lineSize), offsetLiterals);
  21571. offsetBytes += lineSize;
  21572. offsetLiterals += lineSize;
  21573. }
  21574. if (kind === ImageKind.GRAYSCALE_1BPP) {
  21575. offsetLiterals = 0;
  21576. for (y = 0; y < height; y++) {
  21577. offsetLiterals++;
  21578. for (i = 0; i < lineSize; i++) {
  21579. literals[offsetLiterals++] ^= 0xFF;
  21580. }
  21581. }
  21582. }
  21583. var ihdr = new Uint8Array([
  21584. width >> 24 & 0xff,
  21585. width >> 16 & 0xff,
  21586. width >> 8 & 0xff,
  21587. width & 0xff,
  21588. height >> 24 & 0xff,
  21589. height >> 16 & 0xff,
  21590. height >> 8 & 0xff,
  21591. height & 0xff,
  21592. bitDepth,
  21593. colorType,
  21594. 0x00,
  21595. 0x00,
  21596. 0x00
  21597. ]);
  21598. var len = literals.length;
  21599. var maxBlockLength = 0xFFFF;
  21600. var deflateBlocks = Math.ceil(len / maxBlockLength);
  21601. var idat = new Uint8Array(2 + len + deflateBlocks * 5 + 4);
  21602. var pi = 0;
  21603. idat[pi++] = 0x78;
  21604. idat[pi++] = 0x9c;
  21605. var pos = 0;
  21606. while (len > maxBlockLength) {
  21607. idat[pi++] = 0x00;
  21608. idat[pi++] = 0xff;
  21609. idat[pi++] = 0xff;
  21610. idat[pi++] = 0x00;
  21611. idat[pi++] = 0x00;
  21612. idat.set(literals.subarray(pos, pos + maxBlockLength), pi);
  21613. pi += maxBlockLength;
  21614. pos += maxBlockLength;
  21615. len -= maxBlockLength;
  21616. }
  21617. idat[pi++] = 0x01;
  21618. idat[pi++] = len & 0xff;
  21619. idat[pi++] = len >> 8 & 0xff;
  21620. idat[pi++] = ~len & 0xffff & 0xff;
  21621. idat[pi++] = (~len & 0xffff) >> 8 & 0xff;
  21622. idat.set(literals.subarray(pos), pi);
  21623. pi += literals.length - pos;
  21624. var adler = adler32(literals, 0, literals.length);
  21625. idat[pi++] = adler >> 24 & 0xff;
  21626. idat[pi++] = adler >> 16 & 0xff;
  21627. idat[pi++] = adler >> 8 & 0xff;
  21628. idat[pi++] = adler & 0xff;
  21629. var pngLength = PNG_HEADER.length + CHUNK_WRAPPER_SIZE * 3 + ihdr.length + idat.length;
  21630. var data = new Uint8Array(pngLength);
  21631. var offset = 0;
  21632. data.set(PNG_HEADER, offset);
  21633. offset += PNG_HEADER.length;
  21634. writePngChunk('IHDR', ihdr, data, offset);
  21635. offset += CHUNK_WRAPPER_SIZE + ihdr.length;
  21636. writePngChunk('IDATA', idat, data, offset);
  21637. offset += CHUNK_WRAPPER_SIZE + idat.length;
  21638. writePngChunk('IEND', new Uint8Array(0), data, offset);
  21639. return createObjectURL(data, 'image/png', forceDataSchema);
  21640. }
  21641. return function convertImgDataToPng(imgData, forceDataSchema) {
  21642. var kind = imgData.kind === undefined ? ImageKind.GRAYSCALE_1BPP : imgData.kind;
  21643. return encode(imgData, kind, forceDataSchema);
  21644. };
  21645. }();
  21646. var SVGExtraState = function SVGExtraStateClosure() {
  21647. function SVGExtraState() {
  21648. this.fontSizeScale = 1;
  21649. this.fontWeight = SVG_DEFAULTS.fontWeight;
  21650. this.fontSize = 0;
  21651. this.textMatrix = IDENTITY_MATRIX;
  21652. this.fontMatrix = FONT_IDENTITY_MATRIX;
  21653. this.leading = 0;
  21654. this.x = 0;
  21655. this.y = 0;
  21656. this.lineX = 0;
  21657. this.lineY = 0;
  21658. this.charSpacing = 0;
  21659. this.wordSpacing = 0;
  21660. this.textHScale = 1;
  21661. this.textRise = 0;
  21662. this.fillColor = SVG_DEFAULTS.fillColor;
  21663. this.strokeColor = '#000000';
  21664. this.fillAlpha = 1;
  21665. this.strokeAlpha = 1;
  21666. this.lineWidth = 1;
  21667. this.lineJoin = '';
  21668. this.lineCap = '';
  21669. this.miterLimit = 0;
  21670. this.dashArray = [];
  21671. this.dashPhase = 0;
  21672. this.dependencies = [];
  21673. this.activeClipUrl = null;
  21674. this.clipGroup = null;
  21675. this.maskId = '';
  21676. }
  21677. SVGExtraState.prototype = {
  21678. clone: function SVGExtraState_clone() {
  21679. return Object.create(this);
  21680. },
  21681. setCurrentPoint: function SVGExtraState_setCurrentPoint(x, y) {
  21682. this.x = x;
  21683. this.y = y;
  21684. }
  21685. };
  21686. return SVGExtraState;
  21687. }();
  21688. var SVGGraphics = function SVGGraphicsClosure() {
  21689. function opListToTree(opList) {
  21690. var opTree = [];
  21691. var tmp = [];
  21692. var opListLen = opList.length;
  21693. for (var x = 0; x < opListLen; x++) {
  21694. if (opList[x].fn === 'save') {
  21695. opTree.push({
  21696. 'fnId': 92,
  21697. 'fn': 'group',
  21698. 'items': []
  21699. });
  21700. tmp.push(opTree);
  21701. opTree = opTree[opTree.length - 1].items;
  21702. continue;
  21703. }
  21704. if (opList[x].fn === 'restore') {
  21705. opTree = tmp.pop();
  21706. } else {
  21707. opTree.push(opList[x]);
  21708. }
  21709. }
  21710. return opTree;
  21711. }
  21712. function pf(value) {
  21713. if (value === (value | 0)) {
  21714. return value.toString();
  21715. }
  21716. var s = value.toFixed(10);
  21717. var i = s.length - 1;
  21718. if (s[i] !== '0') {
  21719. return s;
  21720. }
  21721. do {
  21722. i--;
  21723. } while (s[i] === '0');
  21724. return s.substr(0, s[i] === '.' ? i : i + 1);
  21725. }
  21726. function pm(m) {
  21727. if (m[4] === 0 && m[5] === 0) {
  21728. if (m[1] === 0 && m[2] === 0) {
  21729. if (m[0] === 1 && m[3] === 1) {
  21730. return '';
  21731. }
  21732. return 'scale(' + pf(m[0]) + ' ' + pf(m[3]) + ')';
  21733. }
  21734. if (m[0] === m[3] && m[1] === -m[2]) {
  21735. var a = Math.acos(m[0]) * 180 / Math.PI;
  21736. return 'rotate(' + pf(a) + ')';
  21737. }
  21738. } else {
  21739. if (m[0] === 1 && m[1] === 0 && m[2] === 0 && m[3] === 1) {
  21740. return 'translate(' + pf(m[4]) + ' ' + pf(m[5]) + ')';
  21741. }
  21742. }
  21743. return 'matrix(' + pf(m[0]) + ' ' + pf(m[1]) + ' ' + pf(m[2]) + ' ' + pf(m[3]) + ' ' + pf(m[4]) + ' ' + pf(m[5]) + ')';
  21744. }
  21745. function SVGGraphics(commonObjs, objs, forceDataSchema) {
  21746. this.current = new SVGExtraState();
  21747. this.transformMatrix = IDENTITY_MATRIX;
  21748. this.transformStack = [];
  21749. this.extraStack = [];
  21750. this.commonObjs = commonObjs;
  21751. this.objs = objs;
  21752. this.pendingEOFill = false;
  21753. this.embedFonts = false;
  21754. this.embeddedFonts = Object.create(null);
  21755. this.cssStyle = null;
  21756. this.forceDataSchema = !!forceDataSchema;
  21757. }
  21758. var NS = 'http://www.w3.org/2000/svg';
  21759. var XML_NS = 'http://www.w3.org/XML/1998/namespace';
  21760. var XLINK_NS = 'http://www.w3.org/1999/xlink';
  21761. var LINE_CAP_STYLES = [
  21762. 'butt',
  21763. 'round',
  21764. 'square'
  21765. ];
  21766. var LINE_JOIN_STYLES = [
  21767. 'miter',
  21768. 'round',
  21769. 'bevel'
  21770. ];
  21771. var clipCount = 0;
  21772. var maskCount = 0;
  21773. SVGGraphics.prototype = {
  21774. save: function SVGGraphics_save() {
  21775. this.transformStack.push(this.transformMatrix);
  21776. var old = this.current;
  21777. this.extraStack.push(old);
  21778. this.current = old.clone();
  21779. },
  21780. restore: function SVGGraphics_restore() {
  21781. this.transformMatrix = this.transformStack.pop();
  21782. this.current = this.extraStack.pop();
  21783. this.tgrp = null;
  21784. },
  21785. group: function SVGGraphics_group(items) {
  21786. this.save();
  21787. this.executeOpTree(items);
  21788. this.restore();
  21789. },
  21790. loadDependencies: function SVGGraphics_loadDependencies(operatorList) {
  21791. var fnArray = operatorList.fnArray;
  21792. var fnArrayLen = fnArray.length;
  21793. var argsArray = operatorList.argsArray;
  21794. var self = this;
  21795. for (var i = 0; i < fnArrayLen; i++) {
  21796. if (OPS.dependency === fnArray[i]) {
  21797. var deps = argsArray[i];
  21798. for (var n = 0, nn = deps.length; n < nn; n++) {
  21799. var obj = deps[n];
  21800. var common = obj.substring(0, 2) === 'g_';
  21801. var promise;
  21802. if (common) {
  21803. promise = new Promise(function (resolve) {
  21804. self.commonObjs.get(obj, resolve);
  21805. });
  21806. } else {
  21807. promise = new Promise(function (resolve) {
  21808. self.objs.get(obj, resolve);
  21809. });
  21810. }
  21811. this.current.dependencies.push(promise);
  21812. }
  21813. }
  21814. }
  21815. return Promise.all(this.current.dependencies);
  21816. },
  21817. transform: function SVGGraphics_transform(a, b, c, d, e, f) {
  21818. var transformMatrix = [
  21819. a,
  21820. b,
  21821. c,
  21822. d,
  21823. e,
  21824. f
  21825. ];
  21826. this.transformMatrix = Util.transform(this.transformMatrix, transformMatrix);
  21827. this.tgrp = null;
  21828. },
  21829. getSVG: function SVGGraphics_getSVG(operatorList, viewport) {
  21830. this.viewport = viewport;
  21831. var svgElement = this._initialize(viewport);
  21832. return this.loadDependencies(operatorList).then(function () {
  21833. this.transformMatrix = IDENTITY_MATRIX;
  21834. var opTree = this.convertOpList(operatorList);
  21835. this.executeOpTree(opTree);
  21836. return svgElement;
  21837. }.bind(this));
  21838. },
  21839. convertOpList: function SVGGraphics_convertOpList(operatorList) {
  21840. var argsArray = operatorList.argsArray;
  21841. var fnArray = operatorList.fnArray;
  21842. var fnArrayLen = fnArray.length;
  21843. var REVOPS = [];
  21844. var opList = [];
  21845. for (var op in OPS) {
  21846. REVOPS[OPS[op]] = op;
  21847. }
  21848. for (var x = 0; x < fnArrayLen; x++) {
  21849. var fnId = fnArray[x];
  21850. opList.push({
  21851. 'fnId': fnId,
  21852. 'fn': REVOPS[fnId],
  21853. 'args': argsArray[x]
  21854. });
  21855. }
  21856. return opListToTree(opList);
  21857. },
  21858. executeOpTree: function SVGGraphics_executeOpTree(opTree) {
  21859. var opTreeLen = opTree.length;
  21860. for (var x = 0; x < opTreeLen; x++) {
  21861. var fn = opTree[x].fn;
  21862. var fnId = opTree[x].fnId;
  21863. var args = opTree[x].args;
  21864. switch (fnId | 0) {
  21865. case OPS.beginText:
  21866. this.beginText();
  21867. break;
  21868. case OPS.setLeading:
  21869. this.setLeading(args);
  21870. break;
  21871. case OPS.setLeadingMoveText:
  21872. this.setLeadingMoveText(args[0], args[1]);
  21873. break;
  21874. case OPS.setFont:
  21875. this.setFont(args);
  21876. break;
  21877. case OPS.showText:
  21878. this.showText(args[0]);
  21879. break;
  21880. case OPS.showSpacedText:
  21881. this.showText(args[0]);
  21882. break;
  21883. case OPS.endText:
  21884. this.endText();
  21885. break;
  21886. case OPS.moveText:
  21887. this.moveText(args[0], args[1]);
  21888. break;
  21889. case OPS.setCharSpacing:
  21890. this.setCharSpacing(args[0]);
  21891. break;
  21892. case OPS.setWordSpacing:
  21893. this.setWordSpacing(args[0]);
  21894. break;
  21895. case OPS.setHScale:
  21896. this.setHScale(args[0]);
  21897. break;
  21898. case OPS.setTextMatrix:
  21899. this.setTextMatrix(args[0], args[1], args[2], args[3], args[4], args[5]);
  21900. break;
  21901. case OPS.setLineWidth:
  21902. this.setLineWidth(args[0]);
  21903. break;
  21904. case OPS.setLineJoin:
  21905. this.setLineJoin(args[0]);
  21906. break;
  21907. case OPS.setLineCap:
  21908. this.setLineCap(args[0]);
  21909. break;
  21910. case OPS.setMiterLimit:
  21911. this.setMiterLimit(args[0]);
  21912. break;
  21913. case OPS.setFillRGBColor:
  21914. this.setFillRGBColor(args[0], args[1], args[2]);
  21915. break;
  21916. case OPS.setStrokeRGBColor:
  21917. this.setStrokeRGBColor(args[0], args[1], args[2]);
  21918. break;
  21919. case OPS.setDash:
  21920. this.setDash(args[0], args[1]);
  21921. break;
  21922. case OPS.setGState:
  21923. this.setGState(args[0]);
  21924. break;
  21925. case OPS.fill:
  21926. this.fill();
  21927. break;
  21928. case OPS.eoFill:
  21929. this.eoFill();
  21930. break;
  21931. case OPS.stroke:
  21932. this.stroke();
  21933. break;
  21934. case OPS.fillStroke:
  21935. this.fillStroke();
  21936. break;
  21937. case OPS.eoFillStroke:
  21938. this.eoFillStroke();
  21939. break;
  21940. case OPS.clip:
  21941. this.clip('nonzero');
  21942. break;
  21943. case OPS.eoClip:
  21944. this.clip('evenodd');
  21945. break;
  21946. case OPS.paintSolidColorImageMask:
  21947. this.paintSolidColorImageMask();
  21948. break;
  21949. case OPS.paintJpegXObject:
  21950. this.paintJpegXObject(args[0], args[1], args[2]);
  21951. break;
  21952. case OPS.paintImageXObject:
  21953. this.paintImageXObject(args[0]);
  21954. break;
  21955. case OPS.paintInlineImageXObject:
  21956. this.paintInlineImageXObject(args[0]);
  21957. break;
  21958. case OPS.paintImageMaskXObject:
  21959. this.paintImageMaskXObject(args[0]);
  21960. break;
  21961. case OPS.paintFormXObjectBegin:
  21962. this.paintFormXObjectBegin(args[0], args[1]);
  21963. break;
  21964. case OPS.paintFormXObjectEnd:
  21965. this.paintFormXObjectEnd();
  21966. break;
  21967. case OPS.closePath:
  21968. this.closePath();
  21969. break;
  21970. case OPS.closeStroke:
  21971. this.closeStroke();
  21972. break;
  21973. case OPS.closeFillStroke:
  21974. this.closeFillStroke();
  21975. break;
  21976. case OPS.nextLine:
  21977. this.nextLine();
  21978. break;
  21979. case OPS.transform:
  21980. this.transform(args[0], args[1], args[2], args[3], args[4], args[5]);
  21981. break;
  21982. case OPS.constructPath:
  21983. this.constructPath(args[0], args[1]);
  21984. break;
  21985. case OPS.endPath:
  21986. this.endPath();
  21987. break;
  21988. case 92:
  21989. this.group(opTree[x].items);
  21990. break;
  21991. default:
  21992. warn('Unimplemented operator ' + fn);
  21993. break;
  21994. }
  21995. }
  21996. },
  21997. setWordSpacing: function SVGGraphics_setWordSpacing(wordSpacing) {
  21998. this.current.wordSpacing = wordSpacing;
  21999. },
  22000. setCharSpacing: function SVGGraphics_setCharSpacing(charSpacing) {
  22001. this.current.charSpacing = charSpacing;
  22002. },
  22003. nextLine: function SVGGraphics_nextLine() {
  22004. this.moveText(0, this.current.leading);
  22005. },
  22006. setTextMatrix: function SVGGraphics_setTextMatrix(a, b, c, d, e, f) {
  22007. var current = this.current;
  22008. this.current.textMatrix = this.current.lineMatrix = [
  22009. a,
  22010. b,
  22011. c,
  22012. d,
  22013. e,
  22014. f
  22015. ];
  22016. this.current.x = this.current.lineX = 0;
  22017. this.current.y = this.current.lineY = 0;
  22018. current.xcoords = [];
  22019. current.tspan = document.createElementNS(NS, 'svg:tspan');
  22020. current.tspan.setAttributeNS(null, 'font-family', current.fontFamily);
  22021. current.tspan.setAttributeNS(null, 'font-size', pf(current.fontSize) + 'px');
  22022. current.tspan.setAttributeNS(null, 'y', pf(-current.y));
  22023. current.txtElement = document.createElementNS(NS, 'svg:text');
  22024. current.txtElement.appendChild(current.tspan);
  22025. },
  22026. beginText: function SVGGraphics_beginText() {
  22027. this.current.x = this.current.lineX = 0;
  22028. this.current.y = this.current.lineY = 0;
  22029. this.current.textMatrix = IDENTITY_MATRIX;
  22030. this.current.lineMatrix = IDENTITY_MATRIX;
  22031. this.current.tspan = document.createElementNS(NS, 'svg:tspan');
  22032. this.current.txtElement = document.createElementNS(NS, 'svg:text');
  22033. this.current.txtgrp = document.createElementNS(NS, 'svg:g');
  22034. this.current.xcoords = [];
  22035. },
  22036. moveText: function SVGGraphics_moveText(x, y) {
  22037. var current = this.current;
  22038. this.current.x = this.current.lineX += x;
  22039. this.current.y = this.current.lineY += y;
  22040. current.xcoords = [];
  22041. current.tspan = document.createElementNS(NS, 'svg:tspan');
  22042. current.tspan.setAttributeNS(null, 'font-family', current.fontFamily);
  22043. current.tspan.setAttributeNS(null, 'font-size', pf(current.fontSize) + 'px');
  22044. current.tspan.setAttributeNS(null, 'y', pf(-current.y));
  22045. },
  22046. showText: function SVGGraphics_showText(glyphs) {
  22047. var current = this.current;
  22048. var font = current.font;
  22049. var fontSize = current.fontSize;
  22050. if (fontSize === 0) {
  22051. return;
  22052. }
  22053. var charSpacing = current.charSpacing;
  22054. var wordSpacing = current.wordSpacing;
  22055. var fontDirection = current.fontDirection;
  22056. var textHScale = current.textHScale * fontDirection;
  22057. var glyphsLength = glyphs.length;
  22058. var vertical = font.vertical;
  22059. var widthAdvanceScale = fontSize * current.fontMatrix[0];
  22060. var x = 0, i;
  22061. for (i = 0; i < glyphsLength; ++i) {
  22062. var glyph = glyphs[i];
  22063. if (glyph === null) {
  22064. x += fontDirection * wordSpacing;
  22065. continue;
  22066. } else if (isNum(glyph)) {
  22067. x += -glyph * fontSize * 0.001;
  22068. continue;
  22069. }
  22070. current.xcoords.push(current.x + x * textHScale);
  22071. var width = glyph.width;
  22072. var character = glyph.fontChar;
  22073. var charWidth = width * widthAdvanceScale + charSpacing * fontDirection;
  22074. x += charWidth;
  22075. current.tspan.textContent += character;
  22076. }
  22077. if (vertical) {
  22078. current.y -= x * textHScale;
  22079. } else {
  22080. current.x += x * textHScale;
  22081. }
  22082. current.tspan.setAttributeNS(null, 'x', current.xcoords.map(pf).join(' '));
  22083. current.tspan.setAttributeNS(null, 'y', pf(-current.y));
  22084. current.tspan.setAttributeNS(null, 'font-family', current.fontFamily);
  22085. current.tspan.setAttributeNS(null, 'font-size', pf(current.fontSize) + 'px');
  22086. if (current.fontStyle !== SVG_DEFAULTS.fontStyle) {
  22087. current.tspan.setAttributeNS(null, 'font-style', current.fontStyle);
  22088. }
  22089. if (current.fontWeight !== SVG_DEFAULTS.fontWeight) {
  22090. current.tspan.setAttributeNS(null, 'font-weight', current.fontWeight);
  22091. }
  22092. if (current.fillColor !== SVG_DEFAULTS.fillColor) {
  22093. current.tspan.setAttributeNS(null, 'fill', current.fillColor);
  22094. }
  22095. current.txtElement.setAttributeNS(null, 'transform', pm(current.textMatrix) + ' scale(1, -1)');
  22096. current.txtElement.setAttributeNS(XML_NS, 'xml:space', 'preserve');
  22097. current.txtElement.appendChild(current.tspan);
  22098. current.txtgrp.appendChild(current.txtElement);
  22099. this._ensureTransformGroup().appendChild(current.txtElement);
  22100. },
  22101. setLeadingMoveText: function SVGGraphics_setLeadingMoveText(x, y) {
  22102. this.setLeading(-y);
  22103. this.moveText(x, y);
  22104. },
  22105. addFontStyle: function SVGGraphics_addFontStyle(fontObj) {
  22106. if (!this.cssStyle) {
  22107. this.cssStyle = document.createElementNS(NS, 'svg:style');
  22108. this.cssStyle.setAttributeNS(null, 'type', 'text/css');
  22109. this.defs.appendChild(this.cssStyle);
  22110. }
  22111. var url = createObjectURL(fontObj.data, fontObj.mimetype, this.forceDataSchema);
  22112. this.cssStyle.textContent += '@font-face { font-family: "' + fontObj.loadedName + '";' + ' src: url(' + url + '); }\n';
  22113. },
  22114. setFont: function SVGGraphics_setFont(details) {
  22115. var current = this.current;
  22116. var fontObj = this.commonObjs.get(details[0]);
  22117. var size = details[1];
  22118. this.current.font = fontObj;
  22119. if (this.embedFonts && fontObj.data && !this.embeddedFonts[fontObj.loadedName]) {
  22120. this.addFontStyle(fontObj);
  22121. this.embeddedFonts[fontObj.loadedName] = fontObj;
  22122. }
  22123. current.fontMatrix = fontObj.fontMatrix ? fontObj.fontMatrix : FONT_IDENTITY_MATRIX;
  22124. var bold = fontObj.black ? fontObj.bold ? 'bolder' : 'bold' : fontObj.bold ? 'bold' : 'normal';
  22125. var italic = fontObj.italic ? 'italic' : 'normal';
  22126. if (size < 0) {
  22127. size = -size;
  22128. current.fontDirection = -1;
  22129. } else {
  22130. current.fontDirection = 1;
  22131. }
  22132. current.fontSize = size;
  22133. current.fontFamily = fontObj.loadedName;
  22134. current.fontWeight = bold;
  22135. current.fontStyle = italic;
  22136. current.tspan = document.createElementNS(NS, 'svg:tspan');
  22137. current.tspan.setAttributeNS(null, 'y', pf(-current.y));
  22138. current.xcoords = [];
  22139. },
  22140. endText: function SVGGraphics_endText() {
  22141. },
  22142. setLineWidth: function SVGGraphics_setLineWidth(width) {
  22143. this.current.lineWidth = width;
  22144. },
  22145. setLineCap: function SVGGraphics_setLineCap(style) {
  22146. this.current.lineCap = LINE_CAP_STYLES[style];
  22147. },
  22148. setLineJoin: function SVGGraphics_setLineJoin(style) {
  22149. this.current.lineJoin = LINE_JOIN_STYLES[style];
  22150. },
  22151. setMiterLimit: function SVGGraphics_setMiterLimit(limit) {
  22152. this.current.miterLimit = limit;
  22153. },
  22154. setStrokeRGBColor: function SVGGraphics_setStrokeRGBColor(r, g, b) {
  22155. var color = Util.makeCssRgb(r, g, b);
  22156. this.current.strokeColor = color;
  22157. },
  22158. setFillRGBColor: function SVGGraphics_setFillRGBColor(r, g, b) {
  22159. var color = Util.makeCssRgb(r, g, b);
  22160. this.current.fillColor = color;
  22161. this.current.tspan = document.createElementNS(NS, 'svg:tspan');
  22162. this.current.xcoords = [];
  22163. },
  22164. setDash: function SVGGraphics_setDash(dashArray, dashPhase) {
  22165. this.current.dashArray = dashArray;
  22166. this.current.dashPhase = dashPhase;
  22167. },
  22168. constructPath: function SVGGraphics_constructPath(ops, args) {
  22169. var current = this.current;
  22170. var x = current.x, y = current.y;
  22171. current.path = document.createElementNS(NS, 'svg:path');
  22172. var d = [];
  22173. var opLength = ops.length;
  22174. for (var i = 0, j = 0; i < opLength; i++) {
  22175. switch (ops[i] | 0) {
  22176. case OPS.rectangle:
  22177. x = args[j++];
  22178. y = args[j++];
  22179. var width = args[j++];
  22180. var height = args[j++];
  22181. var xw = x + width;
  22182. var yh = y + height;
  22183. d.push('M', pf(x), pf(y), 'L', pf(xw), pf(y), 'L', pf(xw), pf(yh), 'L', pf(x), pf(yh), 'Z');
  22184. break;
  22185. case OPS.moveTo:
  22186. x = args[j++];
  22187. y = args[j++];
  22188. d.push('M', pf(x), pf(y));
  22189. break;
  22190. case OPS.lineTo:
  22191. x = args[j++];
  22192. y = args[j++];
  22193. d.push('L', pf(x), pf(y));
  22194. break;
  22195. case OPS.curveTo:
  22196. x = args[j + 4];
  22197. y = args[j + 5];
  22198. d.push('C', pf(args[j]), pf(args[j + 1]), pf(args[j + 2]), pf(args[j + 3]), pf(x), pf(y));
  22199. j += 6;
  22200. break;
  22201. case OPS.curveTo2:
  22202. x = args[j + 2];
  22203. y = args[j + 3];
  22204. d.push('C', pf(x), pf(y), pf(args[j]), pf(args[j + 1]), pf(args[j + 2]), pf(args[j + 3]));
  22205. j += 4;
  22206. break;
  22207. case OPS.curveTo3:
  22208. x = args[j + 2];
  22209. y = args[j + 3];
  22210. d.push('C', pf(args[j]), pf(args[j + 1]), pf(x), pf(y), pf(x), pf(y));
  22211. j += 4;
  22212. break;
  22213. case OPS.closePath:
  22214. d.push('Z');
  22215. break;
  22216. }
  22217. }
  22218. current.path.setAttributeNS(null, 'd', d.join(' '));
  22219. current.path.setAttributeNS(null, 'stroke-miterlimit', pf(current.miterLimit));
  22220. current.path.setAttributeNS(null, 'stroke-linecap', current.lineCap);
  22221. current.path.setAttributeNS(null, 'stroke-linejoin', current.lineJoin);
  22222. current.path.setAttributeNS(null, 'stroke-width', pf(current.lineWidth) + 'px');
  22223. current.path.setAttributeNS(null, 'stroke-dasharray', current.dashArray.map(pf).join(' '));
  22224. current.path.setAttributeNS(null, 'stroke-dashoffset', pf(current.dashPhase) + 'px');
  22225. current.path.setAttributeNS(null, 'fill', 'none');
  22226. this._ensureTransformGroup().appendChild(current.path);
  22227. current.element = current.path;
  22228. current.setCurrentPoint(x, y);
  22229. },
  22230. endPath: function SVGGraphics_endPath() {
  22231. },
  22232. clip: function SVGGraphics_clip(type) {
  22233. var current = this.current;
  22234. var clipId = 'clippath' + clipCount;
  22235. clipCount++;
  22236. var clipPath = document.createElementNS(NS, 'svg:clipPath');
  22237. clipPath.setAttributeNS(null, 'id', clipId);
  22238. clipPath.setAttributeNS(null, 'transform', pm(this.transformMatrix));
  22239. var clipElement = current.element.cloneNode();
  22240. if (type === 'evenodd') {
  22241. clipElement.setAttributeNS(null, 'clip-rule', 'evenodd');
  22242. } else {
  22243. clipElement.setAttributeNS(null, 'clip-rule', 'nonzero');
  22244. }
  22245. clipPath.appendChild(clipElement);
  22246. this.defs.appendChild(clipPath);
  22247. if (current.activeClipUrl) {
  22248. current.clipGroup = null;
  22249. this.extraStack.forEach(function (prev) {
  22250. prev.clipGroup = null;
  22251. });
  22252. }
  22253. current.activeClipUrl = 'url(#' + clipId + ')';
  22254. this.tgrp = null;
  22255. },
  22256. closePath: function SVGGraphics_closePath() {
  22257. var current = this.current;
  22258. var d = current.path.getAttributeNS(null, 'd');
  22259. d += 'Z';
  22260. current.path.setAttributeNS(null, 'd', d);
  22261. },
  22262. setLeading: function SVGGraphics_setLeading(leading) {
  22263. this.current.leading = -leading;
  22264. },
  22265. setTextRise: function SVGGraphics_setTextRise(textRise) {
  22266. this.current.textRise = textRise;
  22267. },
  22268. setHScale: function SVGGraphics_setHScale(scale) {
  22269. this.current.textHScale = scale / 100;
  22270. },
  22271. setGState: function SVGGraphics_setGState(states) {
  22272. for (var i = 0, ii = states.length; i < ii; i++) {
  22273. var state = states[i];
  22274. var key = state[0];
  22275. var value = state[1];
  22276. switch (key) {
  22277. case 'LW':
  22278. this.setLineWidth(value);
  22279. break;
  22280. case 'LC':
  22281. this.setLineCap(value);
  22282. break;
  22283. case 'LJ':
  22284. this.setLineJoin(value);
  22285. break;
  22286. case 'ML':
  22287. this.setMiterLimit(value);
  22288. break;
  22289. case 'D':
  22290. this.setDash(value[0], value[1]);
  22291. break;
  22292. case 'Font':
  22293. this.setFont(value);
  22294. break;
  22295. default:
  22296. warn('Unimplemented graphic state ' + key);
  22297. break;
  22298. }
  22299. }
  22300. },
  22301. fill: function SVGGraphics_fill() {
  22302. var current = this.current;
  22303. current.element.setAttributeNS(null, 'fill', current.fillColor);
  22304. },
  22305. stroke: function SVGGraphics_stroke() {
  22306. var current = this.current;
  22307. current.element.setAttributeNS(null, 'stroke', current.strokeColor);
  22308. current.element.setAttributeNS(null, 'fill', 'none');
  22309. },
  22310. eoFill: function SVGGraphics_eoFill() {
  22311. var current = this.current;
  22312. current.element.setAttributeNS(null, 'fill', current.fillColor);
  22313. current.element.setAttributeNS(null, 'fill-rule', 'evenodd');
  22314. },
  22315. fillStroke: function SVGGraphics_fillStroke() {
  22316. this.stroke();
  22317. this.fill();
  22318. },
  22319. eoFillStroke: function SVGGraphics_eoFillStroke() {
  22320. this.current.element.setAttributeNS(null, 'fill-rule', 'evenodd');
  22321. this.fillStroke();
  22322. },
  22323. closeStroke: function SVGGraphics_closeStroke() {
  22324. this.closePath();
  22325. this.stroke();
  22326. },
  22327. closeFillStroke: function SVGGraphics_closeFillStroke() {
  22328. this.closePath();
  22329. this.fillStroke();
  22330. },
  22331. paintSolidColorImageMask: function SVGGraphics_paintSolidColorImageMask() {
  22332. var current = this.current;
  22333. var rect = document.createElementNS(NS, 'svg:rect');
  22334. rect.setAttributeNS(null, 'x', '0');
  22335. rect.setAttributeNS(null, 'y', '0');
  22336. rect.setAttributeNS(null, 'width', '1px');
  22337. rect.setAttributeNS(null, 'height', '1px');
  22338. rect.setAttributeNS(null, 'fill', current.fillColor);
  22339. this._ensureTransformGroup().appendChild(rect);
  22340. },
  22341. paintJpegXObject: function SVGGraphics_paintJpegXObject(objId, w, h) {
  22342. var imgObj = this.objs.get(objId);
  22343. var imgEl = document.createElementNS(NS, 'svg:image');
  22344. imgEl.setAttributeNS(XLINK_NS, 'xlink:href', imgObj.src);
  22345. imgEl.setAttributeNS(null, 'width', imgObj.width + 'px');
  22346. imgEl.setAttributeNS(null, 'height', imgObj.height + 'px');
  22347. imgEl.setAttributeNS(null, 'x', '0');
  22348. imgEl.setAttributeNS(null, 'y', pf(-h));
  22349. imgEl.setAttributeNS(null, 'transform', 'scale(' + pf(1 / w) + ' ' + pf(-1 / h) + ')');
  22350. this._ensureTransformGroup().appendChild(imgEl);
  22351. },
  22352. paintImageXObject: function SVGGraphics_paintImageXObject(objId) {
  22353. var imgData = this.objs.get(objId);
  22354. if (!imgData) {
  22355. warn('Dependent image isn\'t ready yet');
  22356. return;
  22357. }
  22358. this.paintInlineImageXObject(imgData);
  22359. },
  22360. paintInlineImageXObject: function SVGGraphics_paintInlineImageXObject(imgData, mask) {
  22361. var width = imgData.width;
  22362. var height = imgData.height;
  22363. var imgSrc = convertImgDataToPng(imgData, this.forceDataSchema);
  22364. var cliprect = document.createElementNS(NS, 'svg:rect');
  22365. cliprect.setAttributeNS(null, 'x', '0');
  22366. cliprect.setAttributeNS(null, 'y', '0');
  22367. cliprect.setAttributeNS(null, 'width', pf(width));
  22368. cliprect.setAttributeNS(null, 'height', pf(height));
  22369. this.current.element = cliprect;
  22370. this.clip('nonzero');
  22371. var imgEl = document.createElementNS(NS, 'svg:image');
  22372. imgEl.setAttributeNS(XLINK_NS, 'xlink:href', imgSrc);
  22373. imgEl.setAttributeNS(null, 'x', '0');
  22374. imgEl.setAttributeNS(null, 'y', pf(-height));
  22375. imgEl.setAttributeNS(null, 'width', pf(width) + 'px');
  22376. imgEl.setAttributeNS(null, 'height', pf(height) + 'px');
  22377. imgEl.setAttributeNS(null, 'transform', 'scale(' + pf(1 / width) + ' ' + pf(-1 / height) + ')');
  22378. if (mask) {
  22379. mask.appendChild(imgEl);
  22380. } else {
  22381. this._ensureTransformGroup().appendChild(imgEl);
  22382. }
  22383. },
  22384. paintImageMaskXObject: function SVGGraphics_paintImageMaskXObject(imgData) {
  22385. var current = this.current;
  22386. var width = imgData.width;
  22387. var height = imgData.height;
  22388. var fillColor = current.fillColor;
  22389. current.maskId = 'mask' + maskCount++;
  22390. var mask = document.createElementNS(NS, 'svg:mask');
  22391. mask.setAttributeNS(null, 'id', current.maskId);
  22392. var rect = document.createElementNS(NS, 'svg:rect');
  22393. rect.setAttributeNS(null, 'x', '0');
  22394. rect.setAttributeNS(null, 'y', '0');
  22395. rect.setAttributeNS(null, 'width', pf(width));
  22396. rect.setAttributeNS(null, 'height', pf(height));
  22397. rect.setAttributeNS(null, 'fill', fillColor);
  22398. rect.setAttributeNS(null, 'mask', 'url(#' + current.maskId + ')');
  22399. this.defs.appendChild(mask);
  22400. this._ensureTransformGroup().appendChild(rect);
  22401. this.paintInlineImageXObject(imgData, mask);
  22402. },
  22403. paintFormXObjectBegin: function SVGGraphics_paintFormXObjectBegin(matrix, bbox) {
  22404. if (isArray(matrix) && matrix.length === 6) {
  22405. this.transform(matrix[0], matrix[1], matrix[2], matrix[3], matrix[4], matrix[5]);
  22406. }
  22407. if (isArray(bbox) && bbox.length === 4) {
  22408. var width = bbox[2] - bbox[0];
  22409. var height = bbox[3] - bbox[1];
  22410. var cliprect = document.createElementNS(NS, 'svg:rect');
  22411. cliprect.setAttributeNS(null, 'x', bbox[0]);
  22412. cliprect.setAttributeNS(null, 'y', bbox[1]);
  22413. cliprect.setAttributeNS(null, 'width', pf(width));
  22414. cliprect.setAttributeNS(null, 'height', pf(height));
  22415. this.current.element = cliprect;
  22416. this.clip('nonzero');
  22417. this.endPath();
  22418. }
  22419. },
  22420. paintFormXObjectEnd: function SVGGraphics_paintFormXObjectEnd() {
  22421. },
  22422. _initialize: function SVGGraphics_initialize(viewport) {
  22423. var svg = document.createElementNS(NS, 'svg:svg');
  22424. svg.setAttributeNS(null, 'version', '1.1');
  22425. svg.setAttributeNS(null, 'width', viewport.width + 'px');
  22426. svg.setAttributeNS(null, 'height', viewport.height + 'px');
  22427. svg.setAttributeNS(null, 'preserveAspectRatio', 'none');
  22428. svg.setAttributeNS(null, 'viewBox', '0 0 ' + viewport.width + ' ' + viewport.height);
  22429. var definitions = document.createElementNS(NS, 'svg:defs');
  22430. svg.appendChild(definitions);
  22431. this.defs = definitions;
  22432. var rootGroup = document.createElementNS(NS, 'svg:g');
  22433. rootGroup.setAttributeNS(null, 'transform', pm(viewport.transform));
  22434. svg.appendChild(rootGroup);
  22435. this.svg = rootGroup;
  22436. return svg;
  22437. },
  22438. _ensureClipGroup: function SVGGraphics_ensureClipGroup() {
  22439. if (!this.current.clipGroup) {
  22440. var clipGroup = document.createElementNS(NS, 'svg:g');
  22441. clipGroup.setAttributeNS(null, 'clip-path', this.current.activeClipUrl);
  22442. this.svg.appendChild(clipGroup);
  22443. this.current.clipGroup = clipGroup;
  22444. }
  22445. return this.current.clipGroup;
  22446. },
  22447. _ensureTransformGroup: function SVGGraphics_ensureTransformGroup() {
  22448. if (!this.tgrp) {
  22449. this.tgrp = document.createElementNS(NS, 'svg:g');
  22450. this.tgrp.setAttributeNS(null, 'transform', pm(this.transformMatrix));
  22451. if (this.current.activeClipUrl) {
  22452. this._ensureClipGroup().appendChild(this.tgrp);
  22453. } else {
  22454. this.svg.appendChild(this.tgrp);
  22455. }
  22456. }
  22457. return this.tgrp;
  22458. }
  22459. };
  22460. return SVGGraphics;
  22461. }();
  22462. exports.SVGGraphics = SVGGraphics;
  22463. /***/ }),
  22464. /* 13 */
  22465. /***/ (function(module, exports, __w_pdfjs_require__) {
  22466. "use strict";
  22467. var sharedUtil = __w_pdfjs_require__(0);
  22468. var displayDOMUtils = __w_pdfjs_require__(3);
  22469. var Util = sharedUtil.Util;
  22470. var createPromiseCapability = sharedUtil.createPromiseCapability;
  22471. var CustomStyle = displayDOMUtils.CustomStyle;
  22472. var getDefaultSetting = displayDOMUtils.getDefaultSetting;
  22473. var renderTextLayer = function renderTextLayerClosure() {
  22474. var MAX_TEXT_DIVS_TO_RENDER = 100000;
  22475. var NonWhitespaceRegexp = /\S/;
  22476. function isAllWhitespace(str) {
  22477. return !NonWhitespaceRegexp.test(str);
  22478. }
  22479. var styleBuf = [
  22480. 'left: ',
  22481. 0,
  22482. 'px; top: ',
  22483. 0,
  22484. 'px; font-size: ',
  22485. 0,
  22486. 'px; font-family: ',
  22487. '',
  22488. ';'
  22489. ];
  22490. function appendText(task, geom, styles) {
  22491. var textDiv = document.createElement('div');
  22492. var textDivProperties = {
  22493. style: null,
  22494. angle: 0,
  22495. canvasWidth: 0,
  22496. isWhitespace: false,
  22497. originalTransform: null,
  22498. paddingBottom: 0,
  22499. paddingLeft: 0,
  22500. paddingRight: 0,
  22501. paddingTop: 0,
  22502. scale: 1
  22503. };
  22504. task._textDivs.push(textDiv);
  22505. if (isAllWhitespace(geom.str)) {
  22506. textDivProperties.isWhitespace = true;
  22507. task._textDivProperties.set(textDiv, textDivProperties);
  22508. return;
  22509. }
  22510. var tx = Util.transform(task._viewport.transform, geom.transform);
  22511. var angle = Math.atan2(tx[1], tx[0]);
  22512. var style = styles[geom.fontName];
  22513. if (style.vertical) {
  22514. angle += Math.PI / 2;
  22515. }
  22516. var fontHeight = Math.sqrt(tx[2] * tx[2] + tx[3] * tx[3]);
  22517. var fontAscent = fontHeight;
  22518. if (style.ascent) {
  22519. fontAscent = style.ascent * fontAscent;
  22520. } else if (style.descent) {
  22521. fontAscent = (1 + style.descent) * fontAscent;
  22522. }
  22523. var left;
  22524. var top;
  22525. if (angle === 0) {
  22526. left = tx[4];
  22527. top = tx[5] - fontAscent;
  22528. } else {
  22529. left = tx[4] + fontAscent * Math.sin(angle);
  22530. top = tx[5] - fontAscent * Math.cos(angle);
  22531. }
  22532. styleBuf[1] = left;
  22533. styleBuf[3] = top;
  22534. styleBuf[5] = fontHeight;
  22535. styleBuf[7] = style.fontFamily;
  22536. textDivProperties.style = styleBuf.join('');
  22537. textDiv.setAttribute('style', textDivProperties.style);
  22538. textDiv.textContent = geom.str;
  22539. if (getDefaultSetting('pdfBug')) {
  22540. textDiv.dataset.fontName = geom.fontName;
  22541. }
  22542. if (angle !== 0) {
  22543. textDivProperties.angle = angle * (180 / Math.PI);
  22544. }
  22545. if (geom.str.length > 1) {
  22546. if (style.vertical) {
  22547. textDivProperties.canvasWidth = geom.height * task._viewport.scale;
  22548. } else {
  22549. textDivProperties.canvasWidth = geom.width * task._viewport.scale;
  22550. }
  22551. }
  22552. task._textDivProperties.set(textDiv, textDivProperties);
  22553. if (task._enhanceTextSelection) {
  22554. var angleCos = 1, angleSin = 0;
  22555. if (angle !== 0) {
  22556. angleCos = Math.cos(angle);
  22557. angleSin = Math.sin(angle);
  22558. }
  22559. var divWidth = (style.vertical ? geom.height : geom.width) * task._viewport.scale;
  22560. var divHeight = fontHeight;
  22561. var m, b;
  22562. if (angle !== 0) {
  22563. m = [
  22564. angleCos,
  22565. angleSin,
  22566. -angleSin,
  22567. angleCos,
  22568. left,
  22569. top
  22570. ];
  22571. b = Util.getAxialAlignedBoundingBox([
  22572. 0,
  22573. 0,
  22574. divWidth,
  22575. divHeight
  22576. ], m);
  22577. } else {
  22578. b = [
  22579. left,
  22580. top,
  22581. left + divWidth,
  22582. top + divHeight
  22583. ];
  22584. }
  22585. task._bounds.push({
  22586. left: b[0],
  22587. top: b[1],
  22588. right: b[2],
  22589. bottom: b[3],
  22590. div: textDiv,
  22591. size: [
  22592. divWidth,
  22593. divHeight
  22594. ],
  22595. m: m
  22596. });
  22597. }
  22598. }
  22599. function render(task) {
  22600. if (task._canceled) {
  22601. return;
  22602. }
  22603. var textLayerFrag = task._container;
  22604. var textDivs = task._textDivs;
  22605. var capability = task._capability;
  22606. var textDivsLength = textDivs.length;
  22607. if (textDivsLength > MAX_TEXT_DIVS_TO_RENDER) {
  22608. task._renderingDone = true;
  22609. capability.resolve();
  22610. return;
  22611. }
  22612. var canvas = document.createElement('canvas');
  22613. var ctx = canvas.getContext('2d', { alpha: false });
  22614. var lastFontSize;
  22615. var lastFontFamily;
  22616. for (var i = 0; i < textDivsLength; i++) {
  22617. var textDiv = textDivs[i];
  22618. var textDivProperties = task._textDivProperties.get(textDiv);
  22619. if (textDivProperties.isWhitespace) {
  22620. continue;
  22621. }
  22622. var fontSize = textDiv.style.fontSize;
  22623. var fontFamily = textDiv.style.fontFamily;
  22624. if (fontSize !== lastFontSize || fontFamily !== lastFontFamily) {
  22625. ctx.font = fontSize + ' ' + fontFamily;
  22626. lastFontSize = fontSize;
  22627. lastFontFamily = fontFamily;
  22628. }
  22629. var width = ctx.measureText(textDiv.textContent).width;
  22630. textLayerFrag.appendChild(textDiv);
  22631. var transform = '';
  22632. if (textDivProperties.canvasWidth !== 0 && width > 0) {
  22633. textDivProperties.scale = textDivProperties.canvasWidth / width;
  22634. transform = 'scaleX(' + textDivProperties.scale + ')';
  22635. }
  22636. if (textDivProperties.angle !== 0) {
  22637. transform = 'rotate(' + textDivProperties.angle + 'deg) ' + transform;
  22638. }
  22639. if (transform !== '') {
  22640. textDivProperties.originalTransform = transform;
  22641. CustomStyle.setProp('transform', textDiv, transform);
  22642. }
  22643. task._textDivProperties.set(textDiv, textDivProperties);
  22644. }
  22645. task._renderingDone = true;
  22646. capability.resolve();
  22647. }
  22648. function expand(task) {
  22649. var bounds = task._bounds;
  22650. var viewport = task._viewport;
  22651. var expanded = expandBounds(viewport.width, viewport.height, bounds);
  22652. for (var i = 0; i < expanded.length; i++) {
  22653. var div = bounds[i].div;
  22654. var divProperties = task._textDivProperties.get(div);
  22655. if (divProperties.angle === 0) {
  22656. divProperties.paddingLeft = bounds[i].left - expanded[i].left;
  22657. divProperties.paddingTop = bounds[i].top - expanded[i].top;
  22658. divProperties.paddingRight = expanded[i].right - bounds[i].right;
  22659. divProperties.paddingBottom = expanded[i].bottom - bounds[i].bottom;
  22660. task._textDivProperties.set(div, divProperties);
  22661. continue;
  22662. }
  22663. var e = expanded[i], b = bounds[i];
  22664. var m = b.m, c = m[0], s = m[1];
  22665. var points = [
  22666. [
  22667. 0,
  22668. 0
  22669. ],
  22670. [
  22671. 0,
  22672. b.size[1]
  22673. ],
  22674. [
  22675. b.size[0],
  22676. 0
  22677. ],
  22678. b.size
  22679. ];
  22680. var ts = new Float64Array(64);
  22681. points.forEach(function (p, i) {
  22682. var t = Util.applyTransform(p, m);
  22683. ts[i + 0] = c && (e.left - t[0]) / c;
  22684. ts[i + 4] = s && (e.top - t[1]) / s;
  22685. ts[i + 8] = c && (e.right - t[0]) / c;
  22686. ts[i + 12] = s && (e.bottom - t[1]) / s;
  22687. ts[i + 16] = s && (e.left - t[0]) / -s;
  22688. ts[i + 20] = c && (e.top - t[1]) / c;
  22689. ts[i + 24] = s && (e.right - t[0]) / -s;
  22690. ts[i + 28] = c && (e.bottom - t[1]) / c;
  22691. ts[i + 32] = c && (e.left - t[0]) / -c;
  22692. ts[i + 36] = s && (e.top - t[1]) / -s;
  22693. ts[i + 40] = c && (e.right - t[0]) / -c;
  22694. ts[i + 44] = s && (e.bottom - t[1]) / -s;
  22695. ts[i + 48] = s && (e.left - t[0]) / s;
  22696. ts[i + 52] = c && (e.top - t[1]) / -c;
  22697. ts[i + 56] = s && (e.right - t[0]) / s;
  22698. ts[i + 60] = c && (e.bottom - t[1]) / -c;
  22699. });
  22700. var findPositiveMin = function (ts, offset, count) {
  22701. var result = 0;
  22702. for (var i = 0; i < count; i++) {
  22703. var t = ts[offset++];
  22704. if (t > 0) {
  22705. result = result ? Math.min(t, result) : t;
  22706. }
  22707. }
  22708. return result;
  22709. };
  22710. var boxScale = 1 + Math.min(Math.abs(c), Math.abs(s));
  22711. divProperties.paddingLeft = findPositiveMin(ts, 32, 16) / boxScale;
  22712. divProperties.paddingTop = findPositiveMin(ts, 48, 16) / boxScale;
  22713. divProperties.paddingRight = findPositiveMin(ts, 0, 16) / boxScale;
  22714. divProperties.paddingBottom = findPositiveMin(ts, 16, 16) / boxScale;
  22715. task._textDivProperties.set(div, divProperties);
  22716. }
  22717. }
  22718. function expandBounds(width, height, boxes) {
  22719. var bounds = boxes.map(function (box, i) {
  22720. return {
  22721. x1: box.left,
  22722. y1: box.top,
  22723. x2: box.right,
  22724. y2: box.bottom,
  22725. index: i,
  22726. x1New: undefined,
  22727. x2New: undefined
  22728. };
  22729. });
  22730. expandBoundsLTR(width, bounds);
  22731. var expanded = new Array(boxes.length);
  22732. bounds.forEach(function (b) {
  22733. var i = b.index;
  22734. expanded[i] = {
  22735. left: b.x1New,
  22736. top: 0,
  22737. right: b.x2New,
  22738. bottom: 0
  22739. };
  22740. });
  22741. boxes.map(function (box, i) {
  22742. var e = expanded[i], b = bounds[i];
  22743. b.x1 = box.top;
  22744. b.y1 = width - e.right;
  22745. b.x2 = box.bottom;
  22746. b.y2 = width - e.left;
  22747. b.index = i;
  22748. b.x1New = undefined;
  22749. b.x2New = undefined;
  22750. });
  22751. expandBoundsLTR(height, bounds);
  22752. bounds.forEach(function (b) {
  22753. var i = b.index;
  22754. expanded[i].top = b.x1New;
  22755. expanded[i].bottom = b.x2New;
  22756. });
  22757. return expanded;
  22758. }
  22759. function expandBoundsLTR(width, bounds) {
  22760. bounds.sort(function (a, b) {
  22761. return a.x1 - b.x1 || a.index - b.index;
  22762. });
  22763. var fakeBoundary = {
  22764. x1: -Infinity,
  22765. y1: -Infinity,
  22766. x2: 0,
  22767. y2: Infinity,
  22768. index: -1,
  22769. x1New: 0,
  22770. x2New: 0
  22771. };
  22772. var horizon = [{
  22773. start: -Infinity,
  22774. end: Infinity,
  22775. boundary: fakeBoundary
  22776. }];
  22777. bounds.forEach(function (boundary) {
  22778. var i = 0;
  22779. while (i < horizon.length && horizon[i].end <= boundary.y1) {
  22780. i++;
  22781. }
  22782. var j = horizon.length - 1;
  22783. while (j >= 0 && horizon[j].start >= boundary.y2) {
  22784. j--;
  22785. }
  22786. var horizonPart, affectedBoundary;
  22787. var q, k, maxXNew = -Infinity;
  22788. for (q = i; q <= j; q++) {
  22789. horizonPart = horizon[q];
  22790. affectedBoundary = horizonPart.boundary;
  22791. var xNew;
  22792. if (affectedBoundary.x2 > boundary.x1) {
  22793. xNew = affectedBoundary.index > boundary.index ? affectedBoundary.x1New : boundary.x1;
  22794. } else if (affectedBoundary.x2New === undefined) {
  22795. xNew = (affectedBoundary.x2 + boundary.x1) / 2;
  22796. } else {
  22797. xNew = affectedBoundary.x2New;
  22798. }
  22799. if (xNew > maxXNew) {
  22800. maxXNew = xNew;
  22801. }
  22802. }
  22803. boundary.x1New = maxXNew;
  22804. for (q = i; q <= j; q++) {
  22805. horizonPart = horizon[q];
  22806. affectedBoundary = horizonPart.boundary;
  22807. if (affectedBoundary.x2New === undefined) {
  22808. if (affectedBoundary.x2 > boundary.x1) {
  22809. if (affectedBoundary.index > boundary.index) {
  22810. affectedBoundary.x2New = affectedBoundary.x2;
  22811. }
  22812. } else {
  22813. affectedBoundary.x2New = maxXNew;
  22814. }
  22815. } else if (affectedBoundary.x2New > maxXNew) {
  22816. affectedBoundary.x2New = Math.max(maxXNew, affectedBoundary.x2);
  22817. }
  22818. }
  22819. var changedHorizon = [], lastBoundary = null;
  22820. for (q = i; q <= j; q++) {
  22821. horizonPart = horizon[q];
  22822. affectedBoundary = horizonPart.boundary;
  22823. var useBoundary = affectedBoundary.x2 > boundary.x2 ? affectedBoundary : boundary;
  22824. if (lastBoundary === useBoundary) {
  22825. changedHorizon[changedHorizon.length - 1].end = horizonPart.end;
  22826. } else {
  22827. changedHorizon.push({
  22828. start: horizonPart.start,
  22829. end: horizonPart.end,
  22830. boundary: useBoundary
  22831. });
  22832. lastBoundary = useBoundary;
  22833. }
  22834. }
  22835. if (horizon[i].start < boundary.y1) {
  22836. changedHorizon[0].start = boundary.y1;
  22837. changedHorizon.unshift({
  22838. start: horizon[i].start,
  22839. end: boundary.y1,
  22840. boundary: horizon[i].boundary
  22841. });
  22842. }
  22843. if (boundary.y2 < horizon[j].end) {
  22844. changedHorizon[changedHorizon.length - 1].end = boundary.y2;
  22845. changedHorizon.push({
  22846. start: boundary.y2,
  22847. end: horizon[j].end,
  22848. boundary: horizon[j].boundary
  22849. });
  22850. }
  22851. for (q = i; q <= j; q++) {
  22852. horizonPart = horizon[q];
  22853. affectedBoundary = horizonPart.boundary;
  22854. if (affectedBoundary.x2New !== undefined) {
  22855. continue;
  22856. }
  22857. var used = false;
  22858. for (k = i - 1; !used && k >= 0 && horizon[k].start >= affectedBoundary.y1; k--) {
  22859. used = horizon[k].boundary === affectedBoundary;
  22860. }
  22861. for (k = j + 1; !used && k < horizon.length && horizon[k].end <= affectedBoundary.y2; k++) {
  22862. used = horizon[k].boundary === affectedBoundary;
  22863. }
  22864. for (k = 0; !used && k < changedHorizon.length; k++) {
  22865. used = changedHorizon[k].boundary === affectedBoundary;
  22866. }
  22867. if (!used) {
  22868. affectedBoundary.x2New = maxXNew;
  22869. }
  22870. }
  22871. Array.prototype.splice.apply(horizon, [
  22872. i,
  22873. j - i + 1
  22874. ].concat(changedHorizon));
  22875. });
  22876. horizon.forEach(function (horizonPart) {
  22877. var affectedBoundary = horizonPart.boundary;
  22878. if (affectedBoundary.x2New === undefined) {
  22879. affectedBoundary.x2New = Math.max(width, affectedBoundary.x2);
  22880. }
  22881. });
  22882. }
  22883. function TextLayerRenderTask(textContent, container, viewport, textDivs, enhanceTextSelection) {
  22884. this._textContent = textContent;
  22885. this._container = container;
  22886. this._viewport = viewport;
  22887. this._textDivs = textDivs || [];
  22888. this._textDivProperties = new WeakMap();
  22889. this._renderingDone = false;
  22890. this._canceled = false;
  22891. this._capability = createPromiseCapability();
  22892. this._renderTimer = null;
  22893. this._bounds = [];
  22894. this._enhanceTextSelection = !!enhanceTextSelection;
  22895. }
  22896. TextLayerRenderTask.prototype = {
  22897. get promise() {
  22898. return this._capability.promise;
  22899. },
  22900. cancel: function TextLayer_cancel() {
  22901. this._canceled = true;
  22902. if (this._renderTimer !== null) {
  22903. clearTimeout(this._renderTimer);
  22904. this._renderTimer = null;
  22905. }
  22906. this._capability.reject('canceled');
  22907. },
  22908. _render: function TextLayer_render(timeout) {
  22909. var textItems = this._textContent.items;
  22910. var textStyles = this._textContent.styles;
  22911. for (var i = 0, len = textItems.length; i < len; i++) {
  22912. appendText(this, textItems[i], textStyles);
  22913. }
  22914. if (!timeout) {
  22915. render(this);
  22916. } else {
  22917. var self = this;
  22918. this._renderTimer = setTimeout(function () {
  22919. render(self);
  22920. self._renderTimer = null;
  22921. }, timeout);
  22922. }
  22923. },
  22924. expandTextDivs: function TextLayer_expandTextDivs(expandDivs) {
  22925. if (!this._enhanceTextSelection || !this._renderingDone) {
  22926. return;
  22927. }
  22928. if (this._bounds !== null) {
  22929. expand(this);
  22930. this._bounds = null;
  22931. }
  22932. for (var i = 0, ii = this._textDivs.length; i < ii; i++) {
  22933. var div = this._textDivs[i];
  22934. var divProperties = this._textDivProperties.get(div);
  22935. if (divProperties.isWhitespace) {
  22936. continue;
  22937. }
  22938. if (expandDivs) {
  22939. var transform = '', padding = '';
  22940. if (divProperties.scale !== 1) {
  22941. transform = 'scaleX(' + divProperties.scale + ')';
  22942. }
  22943. if (divProperties.angle !== 0) {
  22944. transform = 'rotate(' + divProperties.angle + 'deg) ' + transform;
  22945. }
  22946. if (divProperties.paddingLeft !== 0) {
  22947. padding += ' padding-left: ' + divProperties.paddingLeft / divProperties.scale + 'px;';
  22948. transform += ' translateX(' + -divProperties.paddingLeft / divProperties.scale + 'px)';
  22949. }
  22950. if (divProperties.paddingTop !== 0) {
  22951. padding += ' padding-top: ' + divProperties.paddingTop + 'px;';
  22952. transform += ' translateY(' + -divProperties.paddingTop + 'px)';
  22953. }
  22954. if (divProperties.paddingRight !== 0) {
  22955. padding += ' padding-right: ' + divProperties.paddingRight / divProperties.scale + 'px;';
  22956. }
  22957. if (divProperties.paddingBottom !== 0) {
  22958. padding += ' padding-bottom: ' + divProperties.paddingBottom + 'px;';
  22959. }
  22960. if (padding !== '') {
  22961. div.setAttribute('style', divProperties.style + padding);
  22962. }
  22963. if (transform !== '') {
  22964. CustomStyle.setProp('transform', div, transform);
  22965. }
  22966. } else {
  22967. div.style.padding = 0;
  22968. CustomStyle.setProp('transform', div, divProperties.originalTransform || '');
  22969. }
  22970. }
  22971. }
  22972. };
  22973. function renderTextLayer(renderParameters) {
  22974. var task = new TextLayerRenderTask(renderParameters.textContent, renderParameters.container, renderParameters.viewport, renderParameters.textDivs, renderParameters.enhanceTextSelection);
  22975. task._render(renderParameters.timeout);
  22976. return task;
  22977. }
  22978. return renderTextLayer;
  22979. }();
  22980. exports.renderTextLayer = renderTextLayer;
  22981. /***/ }),
  22982. /* 14 */
  22983. /***/ (function(module, exports, __w_pdfjs_require__) {
  22984. "use strict";
  22985. var ArithmeticDecoder = function ArithmeticDecoderClosure() {
  22986. var QeTable = [
  22987. {
  22988. qe: 0x5601,
  22989. nmps: 1,
  22990. nlps: 1,
  22991. switchFlag: 1
  22992. },
  22993. {
  22994. qe: 0x3401,
  22995. nmps: 2,
  22996. nlps: 6,
  22997. switchFlag: 0
  22998. },
  22999. {
  23000. qe: 0x1801,
  23001. nmps: 3,
  23002. nlps: 9,
  23003. switchFlag: 0
  23004. },
  23005. {
  23006. qe: 0x0AC1,
  23007. nmps: 4,
  23008. nlps: 12,
  23009. switchFlag: 0
  23010. },
  23011. {
  23012. qe: 0x0521,
  23013. nmps: 5,
  23014. nlps: 29,
  23015. switchFlag: 0
  23016. },
  23017. {
  23018. qe: 0x0221,
  23019. nmps: 38,
  23020. nlps: 33,
  23021. switchFlag: 0
  23022. },
  23023. {
  23024. qe: 0x5601,
  23025. nmps: 7,
  23026. nlps: 6,
  23027. switchFlag: 1
  23028. },
  23029. {
  23030. qe: 0x5401,
  23031. nmps: 8,
  23032. nlps: 14,
  23033. switchFlag: 0
  23034. },
  23035. {
  23036. qe: 0x4801,
  23037. nmps: 9,
  23038. nlps: 14,
  23039. switchFlag: 0
  23040. },
  23041. {
  23042. qe: 0x3801,
  23043. nmps: 10,
  23044. nlps: 14,
  23045. switchFlag: 0
  23046. },
  23047. {
  23048. qe: 0x3001,
  23049. nmps: 11,
  23050. nlps: 17,
  23051. switchFlag: 0
  23052. },
  23053. {
  23054. qe: 0x2401,
  23055. nmps: 12,
  23056. nlps: 18,
  23057. switchFlag: 0
  23058. },
  23059. {
  23060. qe: 0x1C01,
  23061. nmps: 13,
  23062. nlps: 20,
  23063. switchFlag: 0
  23064. },
  23065. {
  23066. qe: 0x1601,
  23067. nmps: 29,
  23068. nlps: 21,
  23069. switchFlag: 0
  23070. },
  23071. {
  23072. qe: 0x5601,
  23073. nmps: 15,
  23074. nlps: 14,
  23075. switchFlag: 1
  23076. },
  23077. {
  23078. qe: 0x5401,
  23079. nmps: 16,
  23080. nlps: 14,
  23081. switchFlag: 0
  23082. },
  23083. {
  23084. qe: 0x5101,
  23085. nmps: 17,
  23086. nlps: 15,
  23087. switchFlag: 0
  23088. },
  23089. {
  23090. qe: 0x4801,
  23091. nmps: 18,
  23092. nlps: 16,
  23093. switchFlag: 0
  23094. },
  23095. {
  23096. qe: 0x3801,
  23097. nmps: 19,
  23098. nlps: 17,
  23099. switchFlag: 0
  23100. },
  23101. {
  23102. qe: 0x3401,
  23103. nmps: 20,
  23104. nlps: 18,
  23105. switchFlag: 0
  23106. },
  23107. {
  23108. qe: 0x3001,
  23109. nmps: 21,
  23110. nlps: 19,
  23111. switchFlag: 0
  23112. },
  23113. {
  23114. qe: 0x2801,
  23115. nmps: 22,
  23116. nlps: 19,
  23117. switchFlag: 0
  23118. },
  23119. {
  23120. qe: 0x2401,
  23121. nmps: 23,
  23122. nlps: 20,
  23123. switchFlag: 0
  23124. },
  23125. {
  23126. qe: 0x2201,
  23127. nmps: 24,
  23128. nlps: 21,
  23129. switchFlag: 0
  23130. },
  23131. {
  23132. qe: 0x1C01,
  23133. nmps: 25,
  23134. nlps: 22,
  23135. switchFlag: 0
  23136. },
  23137. {
  23138. qe: 0x1801,
  23139. nmps: 26,
  23140. nlps: 23,
  23141. switchFlag: 0
  23142. },
  23143. {
  23144. qe: 0x1601,
  23145. nmps: 27,
  23146. nlps: 24,
  23147. switchFlag: 0
  23148. },
  23149. {
  23150. qe: 0x1401,
  23151. nmps: 28,
  23152. nlps: 25,
  23153. switchFlag: 0
  23154. },
  23155. {
  23156. qe: 0x1201,
  23157. nmps: 29,
  23158. nlps: 26,
  23159. switchFlag: 0
  23160. },
  23161. {
  23162. qe: 0x1101,
  23163. nmps: 30,
  23164. nlps: 27,
  23165. switchFlag: 0
  23166. },
  23167. {
  23168. qe: 0x0AC1,
  23169. nmps: 31,
  23170. nlps: 28,
  23171. switchFlag: 0
  23172. },
  23173. {
  23174. qe: 0x09C1,
  23175. nmps: 32,
  23176. nlps: 29,
  23177. switchFlag: 0
  23178. },
  23179. {
  23180. qe: 0x08A1,
  23181. nmps: 33,
  23182. nlps: 30,
  23183. switchFlag: 0
  23184. },
  23185. {
  23186. qe: 0x0521,
  23187. nmps: 34,
  23188. nlps: 31,
  23189. switchFlag: 0
  23190. },
  23191. {
  23192. qe: 0x0441,
  23193. nmps: 35,
  23194. nlps: 32,
  23195. switchFlag: 0
  23196. },
  23197. {
  23198. qe: 0x02A1,
  23199. nmps: 36,
  23200. nlps: 33,
  23201. switchFlag: 0
  23202. },
  23203. {
  23204. qe: 0x0221,
  23205. nmps: 37,
  23206. nlps: 34,
  23207. switchFlag: 0
  23208. },
  23209. {
  23210. qe: 0x0141,
  23211. nmps: 38,
  23212. nlps: 35,
  23213. switchFlag: 0
  23214. },
  23215. {
  23216. qe: 0x0111,
  23217. nmps: 39,
  23218. nlps: 36,
  23219. switchFlag: 0
  23220. },
  23221. {
  23222. qe: 0x0085,
  23223. nmps: 40,
  23224. nlps: 37,
  23225. switchFlag: 0
  23226. },
  23227. {
  23228. qe: 0x0049,
  23229. nmps: 41,
  23230. nlps: 38,
  23231. switchFlag: 0
  23232. },
  23233. {
  23234. qe: 0x0025,
  23235. nmps: 42,
  23236. nlps: 39,
  23237. switchFlag: 0
  23238. },
  23239. {
  23240. qe: 0x0015,
  23241. nmps: 43,
  23242. nlps: 40,
  23243. switchFlag: 0
  23244. },
  23245. {
  23246. qe: 0x0009,
  23247. nmps: 44,
  23248. nlps: 41,
  23249. switchFlag: 0
  23250. },
  23251. {
  23252. qe: 0x0005,
  23253. nmps: 45,
  23254. nlps: 42,
  23255. switchFlag: 0
  23256. },
  23257. {
  23258. qe: 0x0001,
  23259. nmps: 45,
  23260. nlps: 43,
  23261. switchFlag: 0
  23262. },
  23263. {
  23264. qe: 0x5601,
  23265. nmps: 46,
  23266. nlps: 46,
  23267. switchFlag: 0
  23268. }
  23269. ];
  23270. function ArithmeticDecoder(data, start, end) {
  23271. this.data = data;
  23272. this.bp = start;
  23273. this.dataEnd = end;
  23274. this.chigh = data[start];
  23275. this.clow = 0;
  23276. this.byteIn();
  23277. this.chigh = this.chigh << 7 & 0xFFFF | this.clow >> 9 & 0x7F;
  23278. this.clow = this.clow << 7 & 0xFFFF;
  23279. this.ct -= 7;
  23280. this.a = 0x8000;
  23281. }
  23282. ArithmeticDecoder.prototype = {
  23283. byteIn: function ArithmeticDecoder_byteIn() {
  23284. var data = this.data;
  23285. var bp = this.bp;
  23286. if (data[bp] === 0xFF) {
  23287. var b1 = data[bp + 1];
  23288. if (b1 > 0x8F) {
  23289. this.clow += 0xFF00;
  23290. this.ct = 8;
  23291. } else {
  23292. bp++;
  23293. this.clow += data[bp] << 9;
  23294. this.ct = 7;
  23295. this.bp = bp;
  23296. }
  23297. } else {
  23298. bp++;
  23299. this.clow += bp < this.dataEnd ? data[bp] << 8 : 0xFF00;
  23300. this.ct = 8;
  23301. this.bp = bp;
  23302. }
  23303. if (this.clow > 0xFFFF) {
  23304. this.chigh += this.clow >> 16;
  23305. this.clow &= 0xFFFF;
  23306. }
  23307. },
  23308. readBit: function ArithmeticDecoder_readBit(contexts, pos) {
  23309. var cx_index = contexts[pos] >> 1, cx_mps = contexts[pos] & 1;
  23310. var qeTableIcx = QeTable[cx_index];
  23311. var qeIcx = qeTableIcx.qe;
  23312. var d;
  23313. var a = this.a - qeIcx;
  23314. if (this.chigh < qeIcx) {
  23315. if (a < qeIcx) {
  23316. a = qeIcx;
  23317. d = cx_mps;
  23318. cx_index = qeTableIcx.nmps;
  23319. } else {
  23320. a = qeIcx;
  23321. d = 1 ^ cx_mps;
  23322. if (qeTableIcx.switchFlag === 1) {
  23323. cx_mps = d;
  23324. }
  23325. cx_index = qeTableIcx.nlps;
  23326. }
  23327. } else {
  23328. this.chigh -= qeIcx;
  23329. if ((a & 0x8000) !== 0) {
  23330. this.a = a;
  23331. return cx_mps;
  23332. }
  23333. if (a < qeIcx) {
  23334. d = 1 ^ cx_mps;
  23335. if (qeTableIcx.switchFlag === 1) {
  23336. cx_mps = d;
  23337. }
  23338. cx_index = qeTableIcx.nlps;
  23339. } else {
  23340. d = cx_mps;
  23341. cx_index = qeTableIcx.nmps;
  23342. }
  23343. }
  23344. do {
  23345. if (this.ct === 0) {
  23346. this.byteIn();
  23347. }
  23348. a <<= 1;
  23349. this.chigh = this.chigh << 1 & 0xFFFF | this.clow >> 15 & 1;
  23350. this.clow = this.clow << 1 & 0xFFFF;
  23351. this.ct--;
  23352. } while ((a & 0x8000) === 0);
  23353. this.a = a;
  23354. contexts[pos] = cx_index << 1 | cx_mps;
  23355. return d;
  23356. }
  23357. };
  23358. return ArithmeticDecoder;
  23359. }();
  23360. exports.ArithmeticDecoder = ArithmeticDecoder;
  23361. /***/ }),
  23362. /* 15 */
  23363. /***/ (function(module, exports, __w_pdfjs_require__) {
  23364. "use strict";
  23365. var sharedUtil = __w_pdfjs_require__(0);
  23366. var coreCharsets = __w_pdfjs_require__(31);
  23367. var coreEncodings = __w_pdfjs_require__(5);
  23368. var error = sharedUtil.error;
  23369. var info = sharedUtil.info;
  23370. var bytesToString = sharedUtil.bytesToString;
  23371. var warn = sharedUtil.warn;
  23372. var isArray = sharedUtil.isArray;
  23373. var Util = sharedUtil.Util;
  23374. var stringToBytes = sharedUtil.stringToBytes;
  23375. var assert = sharedUtil.assert;
  23376. var ISOAdobeCharset = coreCharsets.ISOAdobeCharset;
  23377. var ExpertCharset = coreCharsets.ExpertCharset;
  23378. var ExpertSubsetCharset = coreCharsets.ExpertSubsetCharset;
  23379. var StandardEncoding = coreEncodings.StandardEncoding;
  23380. var ExpertEncoding = coreEncodings.ExpertEncoding;
  23381. var MAX_SUBR_NESTING = 10;
  23382. var CFFStandardStrings = [
  23383. '.notdef',
  23384. 'space',
  23385. 'exclam',
  23386. 'quotedbl',
  23387. 'numbersign',
  23388. 'dollar',
  23389. 'percent',
  23390. 'ampersand',
  23391. 'quoteright',
  23392. 'parenleft',
  23393. 'parenright',
  23394. 'asterisk',
  23395. 'plus',
  23396. 'comma',
  23397. 'hyphen',
  23398. 'period',
  23399. 'slash',
  23400. 'zero',
  23401. 'one',
  23402. 'two',
  23403. 'three',
  23404. 'four',
  23405. 'five',
  23406. 'six',
  23407. 'seven',
  23408. 'eight',
  23409. 'nine',
  23410. 'colon',
  23411. 'semicolon',
  23412. 'less',
  23413. 'equal',
  23414. 'greater',
  23415. 'question',
  23416. 'at',
  23417. 'A',
  23418. 'B',
  23419. 'C',
  23420. 'D',
  23421. 'E',
  23422. 'F',
  23423. 'G',
  23424. 'H',
  23425. 'I',
  23426. 'J',
  23427. 'K',
  23428. 'L',
  23429. 'M',
  23430. 'N',
  23431. 'O',
  23432. 'P',
  23433. 'Q',
  23434. 'R',
  23435. 'S',
  23436. 'T',
  23437. 'U',
  23438. 'V',
  23439. 'W',
  23440. 'X',
  23441. 'Y',
  23442. 'Z',
  23443. 'bracketleft',
  23444. 'backslash',
  23445. 'bracketright',
  23446. 'asciicircum',
  23447. 'underscore',
  23448. 'quoteleft',
  23449. 'a',
  23450. 'b',
  23451. 'c',
  23452. 'd',
  23453. 'e',
  23454. 'f',
  23455. 'g',
  23456. 'h',
  23457. 'i',
  23458. 'j',
  23459. 'k',
  23460. 'l',
  23461. 'm',
  23462. 'n',
  23463. 'o',
  23464. 'p',
  23465. 'q',
  23466. 'r',
  23467. 's',
  23468. 't',
  23469. 'u',
  23470. 'v',
  23471. 'w',
  23472. 'x',
  23473. 'y',
  23474. 'z',
  23475. 'braceleft',
  23476. 'bar',
  23477. 'braceright',
  23478. 'asciitilde',
  23479. 'exclamdown',
  23480. 'cent',
  23481. 'sterling',
  23482. 'fraction',
  23483. 'yen',
  23484. 'florin',
  23485. 'section',
  23486. 'currency',
  23487. 'quotesingle',
  23488. 'quotedblleft',
  23489. 'guillemotleft',
  23490. 'guilsinglleft',
  23491. 'guilsinglright',
  23492. 'fi',
  23493. 'fl',
  23494. 'endash',
  23495. 'dagger',
  23496. 'daggerdbl',
  23497. 'periodcentered',
  23498. 'paragraph',
  23499. 'bullet',
  23500. 'quotesinglbase',
  23501. 'quotedblbase',
  23502. 'quotedblright',
  23503. 'guillemotright',
  23504. 'ellipsis',
  23505. 'perthousand',
  23506. 'questiondown',
  23507. 'grave',
  23508. 'acute',
  23509. 'circumflex',
  23510. 'tilde',
  23511. 'macron',
  23512. 'breve',
  23513. 'dotaccent',
  23514. 'dieresis',
  23515. 'ring',
  23516. 'cedilla',
  23517. 'hungarumlaut',
  23518. 'ogonek',
  23519. 'caron',
  23520. 'emdash',
  23521. 'AE',
  23522. 'ordfeminine',
  23523. 'Lslash',
  23524. 'Oslash',
  23525. 'OE',
  23526. 'ordmasculine',
  23527. 'ae',
  23528. 'dotlessi',
  23529. 'lslash',
  23530. 'oslash',
  23531. 'oe',
  23532. 'germandbls',
  23533. 'onesuperior',
  23534. 'logicalnot',
  23535. 'mu',
  23536. 'trademark',
  23537. 'Eth',
  23538. 'onehalf',
  23539. 'plusminus',
  23540. 'Thorn',
  23541. 'onequarter',
  23542. 'divide',
  23543. 'brokenbar',
  23544. 'degree',
  23545. 'thorn',
  23546. 'threequarters',
  23547. 'twosuperior',
  23548. 'registered',
  23549. 'minus',
  23550. 'eth',
  23551. 'multiply',
  23552. 'threesuperior',
  23553. 'copyright',
  23554. 'Aacute',
  23555. 'Acircumflex',
  23556. 'Adieresis',
  23557. 'Agrave',
  23558. 'Aring',
  23559. 'Atilde',
  23560. 'Ccedilla',
  23561. 'Eacute',
  23562. 'Ecircumflex',
  23563. 'Edieresis',
  23564. 'Egrave',
  23565. 'Iacute',
  23566. 'Icircumflex',
  23567. 'Idieresis',
  23568. 'Igrave',
  23569. 'Ntilde',
  23570. 'Oacute',
  23571. 'Ocircumflex',
  23572. 'Odieresis',
  23573. 'Ograve',
  23574. 'Otilde',
  23575. 'Scaron',
  23576. 'Uacute',
  23577. 'Ucircumflex',
  23578. 'Udieresis',
  23579. 'Ugrave',
  23580. 'Yacute',
  23581. 'Ydieresis',
  23582. 'Zcaron',
  23583. 'aacute',
  23584. 'acircumflex',
  23585. 'adieresis',
  23586. 'agrave',
  23587. 'aring',
  23588. 'atilde',
  23589. 'ccedilla',
  23590. 'eacute',
  23591. 'ecircumflex',
  23592. 'edieresis',
  23593. 'egrave',
  23594. 'iacute',
  23595. 'icircumflex',
  23596. 'idieresis',
  23597. 'igrave',
  23598. 'ntilde',
  23599. 'oacute',
  23600. 'ocircumflex',
  23601. 'odieresis',
  23602. 'ograve',
  23603. 'otilde',
  23604. 'scaron',
  23605. 'uacute',
  23606. 'ucircumflex',
  23607. 'udieresis',
  23608. 'ugrave',
  23609. 'yacute',
  23610. 'ydieresis',
  23611. 'zcaron',
  23612. 'exclamsmall',
  23613. 'Hungarumlautsmall',
  23614. 'dollaroldstyle',
  23615. 'dollarsuperior',
  23616. 'ampersandsmall',
  23617. 'Acutesmall',
  23618. 'parenleftsuperior',
  23619. 'parenrightsuperior',
  23620. 'twodotenleader',
  23621. 'onedotenleader',
  23622. 'zerooldstyle',
  23623. 'oneoldstyle',
  23624. 'twooldstyle',
  23625. 'threeoldstyle',
  23626. 'fouroldstyle',
  23627. 'fiveoldstyle',
  23628. 'sixoldstyle',
  23629. 'sevenoldstyle',
  23630. 'eightoldstyle',
  23631. 'nineoldstyle',
  23632. 'commasuperior',
  23633. 'threequartersemdash',
  23634. 'periodsuperior',
  23635. 'questionsmall',
  23636. 'asuperior',
  23637. 'bsuperior',
  23638. 'centsuperior',
  23639. 'dsuperior',
  23640. 'esuperior',
  23641. 'isuperior',
  23642. 'lsuperior',
  23643. 'msuperior',
  23644. 'nsuperior',
  23645. 'osuperior',
  23646. 'rsuperior',
  23647. 'ssuperior',
  23648. 'tsuperior',
  23649. 'ff',
  23650. 'ffi',
  23651. 'ffl',
  23652. 'parenleftinferior',
  23653. 'parenrightinferior',
  23654. 'Circumflexsmall',
  23655. 'hyphensuperior',
  23656. 'Gravesmall',
  23657. 'Asmall',
  23658. 'Bsmall',
  23659. 'Csmall',
  23660. 'Dsmall',
  23661. 'Esmall',
  23662. 'Fsmall',
  23663. 'Gsmall',
  23664. 'Hsmall',
  23665. 'Ismall',
  23666. 'Jsmall',
  23667. 'Ksmall',
  23668. 'Lsmall',
  23669. 'Msmall',
  23670. 'Nsmall',
  23671. 'Osmall',
  23672. 'Psmall',
  23673. 'Qsmall',
  23674. 'Rsmall',
  23675. 'Ssmall',
  23676. 'Tsmall',
  23677. 'Usmall',
  23678. 'Vsmall',
  23679. 'Wsmall',
  23680. 'Xsmall',
  23681. 'Ysmall',
  23682. 'Zsmall',
  23683. 'colonmonetary',
  23684. 'onefitted',
  23685. 'rupiah',
  23686. 'Tildesmall',
  23687. 'exclamdownsmall',
  23688. 'centoldstyle',
  23689. 'Lslashsmall',
  23690. 'Scaronsmall',
  23691. 'Zcaronsmall',
  23692. 'Dieresissmall',
  23693. 'Brevesmall',
  23694. 'Caronsmall',
  23695. 'Dotaccentsmall',
  23696. 'Macronsmall',
  23697. 'figuredash',
  23698. 'hypheninferior',
  23699. 'Ogoneksmall',
  23700. 'Ringsmall',
  23701. 'Cedillasmall',
  23702. 'questiondownsmall',
  23703. 'oneeighth',
  23704. 'threeeighths',
  23705. 'fiveeighths',
  23706. 'seveneighths',
  23707. 'onethird',
  23708. 'twothirds',
  23709. 'zerosuperior',
  23710. 'foursuperior',
  23711. 'fivesuperior',
  23712. 'sixsuperior',
  23713. 'sevensuperior',
  23714. 'eightsuperior',
  23715. 'ninesuperior',
  23716. 'zeroinferior',
  23717. 'oneinferior',
  23718. 'twoinferior',
  23719. 'threeinferior',
  23720. 'fourinferior',
  23721. 'fiveinferior',
  23722. 'sixinferior',
  23723. 'seveninferior',
  23724. 'eightinferior',
  23725. 'nineinferior',
  23726. 'centinferior',
  23727. 'dollarinferior',
  23728. 'periodinferior',
  23729. 'commainferior',
  23730. 'Agravesmall',
  23731. 'Aacutesmall',
  23732. 'Acircumflexsmall',
  23733. 'Atildesmall',
  23734. 'Adieresissmall',
  23735. 'Aringsmall',
  23736. 'AEsmall',
  23737. 'Ccedillasmall',
  23738. 'Egravesmall',
  23739. 'Eacutesmall',
  23740. 'Ecircumflexsmall',
  23741. 'Edieresissmall',
  23742. 'Igravesmall',
  23743. 'Iacutesmall',
  23744. 'Icircumflexsmall',
  23745. 'Idieresissmall',
  23746. 'Ethsmall',
  23747. 'Ntildesmall',
  23748. 'Ogravesmall',
  23749. 'Oacutesmall',
  23750. 'Ocircumflexsmall',
  23751. 'Otildesmall',
  23752. 'Odieresissmall',
  23753. 'OEsmall',
  23754. 'Oslashsmall',
  23755. 'Ugravesmall',
  23756. 'Uacutesmall',
  23757. 'Ucircumflexsmall',
  23758. 'Udieresissmall',
  23759. 'Yacutesmall',
  23760. 'Thornsmall',
  23761. 'Ydieresissmall',
  23762. '001.000',
  23763. '001.001',
  23764. '001.002',
  23765. '001.003',
  23766. 'Black',
  23767. 'Bold',
  23768. 'Book',
  23769. 'Light',
  23770. 'Medium',
  23771. 'Regular',
  23772. 'Roman',
  23773. 'Semibold'
  23774. ];
  23775. var CFFParser = function CFFParserClosure() {
  23776. var CharstringValidationData = [
  23777. null,
  23778. {
  23779. id: 'hstem',
  23780. min: 2,
  23781. stackClearing: true,
  23782. stem: true
  23783. },
  23784. null,
  23785. {
  23786. id: 'vstem',
  23787. min: 2,
  23788. stackClearing: true,
  23789. stem: true
  23790. },
  23791. {
  23792. id: 'vmoveto',
  23793. min: 1,
  23794. stackClearing: true
  23795. },
  23796. {
  23797. id: 'rlineto',
  23798. min: 2,
  23799. resetStack: true
  23800. },
  23801. {
  23802. id: 'hlineto',
  23803. min: 1,
  23804. resetStack: true
  23805. },
  23806. {
  23807. id: 'vlineto',
  23808. min: 1,
  23809. resetStack: true
  23810. },
  23811. {
  23812. id: 'rrcurveto',
  23813. min: 6,
  23814. resetStack: true
  23815. },
  23816. null,
  23817. {
  23818. id: 'callsubr',
  23819. min: 1,
  23820. undefStack: true
  23821. },
  23822. {
  23823. id: 'return',
  23824. min: 0,
  23825. undefStack: true
  23826. },
  23827. null,
  23828. null,
  23829. {
  23830. id: 'endchar',
  23831. min: 0,
  23832. stackClearing: true
  23833. },
  23834. null,
  23835. null,
  23836. null,
  23837. {
  23838. id: 'hstemhm',
  23839. min: 2,
  23840. stackClearing: true,
  23841. stem: true
  23842. },
  23843. {
  23844. id: 'hintmask',
  23845. min: 0,
  23846. stackClearing: true
  23847. },
  23848. {
  23849. id: 'cntrmask',
  23850. min: 0,
  23851. stackClearing: true
  23852. },
  23853. {
  23854. id: 'rmoveto',
  23855. min: 2,
  23856. stackClearing: true
  23857. },
  23858. {
  23859. id: 'hmoveto',
  23860. min: 1,
  23861. stackClearing: true
  23862. },
  23863. {
  23864. id: 'vstemhm',
  23865. min: 2,
  23866. stackClearing: true,
  23867. stem: true
  23868. },
  23869. {
  23870. id: 'rcurveline',
  23871. min: 8,
  23872. resetStack: true
  23873. },
  23874. {
  23875. id: 'rlinecurve',
  23876. min: 8,
  23877. resetStack: true
  23878. },
  23879. {
  23880. id: 'vvcurveto',
  23881. min: 4,
  23882. resetStack: true
  23883. },
  23884. {
  23885. id: 'hhcurveto',
  23886. min: 4,
  23887. resetStack: true
  23888. },
  23889. null,
  23890. {
  23891. id: 'callgsubr',
  23892. min: 1,
  23893. undefStack: true
  23894. },
  23895. {
  23896. id: 'vhcurveto',
  23897. min: 4,
  23898. resetStack: true
  23899. },
  23900. {
  23901. id: 'hvcurveto',
  23902. min: 4,
  23903. resetStack: true
  23904. }
  23905. ];
  23906. var CharstringValidationData12 = [
  23907. null,
  23908. null,
  23909. null,
  23910. {
  23911. id: 'and',
  23912. min: 2,
  23913. stackDelta: -1
  23914. },
  23915. {
  23916. id: 'or',
  23917. min: 2,
  23918. stackDelta: -1
  23919. },
  23920. {
  23921. id: 'not',
  23922. min: 1,
  23923. stackDelta: 0
  23924. },
  23925. null,
  23926. null,
  23927. null,
  23928. {
  23929. id: 'abs',
  23930. min: 1,
  23931. stackDelta: 0
  23932. },
  23933. {
  23934. id: 'add',
  23935. min: 2,
  23936. stackDelta: -1,
  23937. stackFn: function stack_div(stack, index) {
  23938. stack[index - 2] = stack[index - 2] + stack[index - 1];
  23939. }
  23940. },
  23941. {
  23942. id: 'sub',
  23943. min: 2,
  23944. stackDelta: -1,
  23945. stackFn: function stack_div(stack, index) {
  23946. stack[index - 2] = stack[index - 2] - stack[index - 1];
  23947. }
  23948. },
  23949. {
  23950. id: 'div',
  23951. min: 2,
  23952. stackDelta: -1,
  23953. stackFn: function stack_div(stack, index) {
  23954. stack[index - 2] = stack[index - 2] / stack[index - 1];
  23955. }
  23956. },
  23957. null,
  23958. {
  23959. id: 'neg',
  23960. min: 1,
  23961. stackDelta: 0,
  23962. stackFn: function stack_div(stack, index) {
  23963. stack[index - 1] = -stack[index - 1];
  23964. }
  23965. },
  23966. {
  23967. id: 'eq',
  23968. min: 2,
  23969. stackDelta: -1
  23970. },
  23971. null,
  23972. null,
  23973. {
  23974. id: 'drop',
  23975. min: 1,
  23976. stackDelta: -1
  23977. },
  23978. null,
  23979. {
  23980. id: 'put',
  23981. min: 2,
  23982. stackDelta: -2
  23983. },
  23984. {
  23985. id: 'get',
  23986. min: 1,
  23987. stackDelta: 0
  23988. },
  23989. {
  23990. id: 'ifelse',
  23991. min: 4,
  23992. stackDelta: -3
  23993. },
  23994. {
  23995. id: 'random',
  23996. min: 0,
  23997. stackDelta: 1
  23998. },
  23999. {
  24000. id: 'mul',
  24001. min: 2,
  24002. stackDelta: -1,
  24003. stackFn: function stack_div(stack, index) {
  24004. stack[index - 2] = stack[index - 2] * stack[index - 1];
  24005. }
  24006. },
  24007. null,
  24008. {
  24009. id: 'sqrt',
  24010. min: 1,
  24011. stackDelta: 0
  24012. },
  24013. {
  24014. id: 'dup',
  24015. min: 1,
  24016. stackDelta: 1
  24017. },
  24018. {
  24019. id: 'exch',
  24020. min: 2,
  24021. stackDelta: 0
  24022. },
  24023. {
  24024. id: 'index',
  24025. min: 2,
  24026. stackDelta: 0
  24027. },
  24028. {
  24029. id: 'roll',
  24030. min: 3,
  24031. stackDelta: -2
  24032. },
  24033. null,
  24034. null,
  24035. null,
  24036. {
  24037. id: 'hflex',
  24038. min: 7,
  24039. resetStack: true
  24040. },
  24041. {
  24042. id: 'flex',
  24043. min: 13,
  24044. resetStack: true
  24045. },
  24046. {
  24047. id: 'hflex1',
  24048. min: 9,
  24049. resetStack: true
  24050. },
  24051. {
  24052. id: 'flex1',
  24053. min: 11,
  24054. resetStack: true
  24055. }
  24056. ];
  24057. function CFFParser(file, properties, seacAnalysisEnabled) {
  24058. this.bytes = file.getBytes();
  24059. this.properties = properties;
  24060. this.seacAnalysisEnabled = !!seacAnalysisEnabled;
  24061. }
  24062. CFFParser.prototype = {
  24063. parse: function CFFParser_parse() {
  24064. var properties = this.properties;
  24065. var cff = new CFF();
  24066. this.cff = cff;
  24067. var header = this.parseHeader();
  24068. var nameIndex = this.parseIndex(header.endPos);
  24069. var topDictIndex = this.parseIndex(nameIndex.endPos);
  24070. var stringIndex = this.parseIndex(topDictIndex.endPos);
  24071. var globalSubrIndex = this.parseIndex(stringIndex.endPos);
  24072. var topDictParsed = this.parseDict(topDictIndex.obj.get(0));
  24073. var topDict = this.createDict(CFFTopDict, topDictParsed, cff.strings);
  24074. cff.header = header.obj;
  24075. cff.names = this.parseNameIndex(nameIndex.obj);
  24076. cff.strings = this.parseStringIndex(stringIndex.obj);
  24077. cff.topDict = topDict;
  24078. cff.globalSubrIndex = globalSubrIndex.obj;
  24079. this.parsePrivateDict(cff.topDict);
  24080. cff.isCIDFont = topDict.hasName('ROS');
  24081. var charStringOffset = topDict.getByName('CharStrings');
  24082. var charStringIndex = this.parseIndex(charStringOffset).obj;
  24083. var fontMatrix = topDict.getByName('FontMatrix');
  24084. if (fontMatrix) {
  24085. properties.fontMatrix = fontMatrix;
  24086. }
  24087. var fontBBox = topDict.getByName('FontBBox');
  24088. if (fontBBox) {
  24089. properties.ascent = fontBBox[3];
  24090. properties.descent = fontBBox[1];
  24091. properties.ascentScaled = true;
  24092. }
  24093. var charset, encoding;
  24094. if (cff.isCIDFont) {
  24095. var fdArrayIndex = this.parseIndex(topDict.getByName('FDArray')).obj;
  24096. for (var i = 0, ii = fdArrayIndex.count; i < ii; ++i) {
  24097. var dictRaw = fdArrayIndex.get(i);
  24098. var fontDict = this.createDict(CFFTopDict, this.parseDict(dictRaw), cff.strings);
  24099. this.parsePrivateDict(fontDict);
  24100. cff.fdArray.push(fontDict);
  24101. }
  24102. encoding = null;
  24103. charset = this.parseCharsets(topDict.getByName('charset'), charStringIndex.count, cff.strings, true);
  24104. cff.fdSelect = this.parseFDSelect(topDict.getByName('FDSelect'), charStringIndex.count);
  24105. } else {
  24106. charset = this.parseCharsets(topDict.getByName('charset'), charStringIndex.count, cff.strings, false);
  24107. encoding = this.parseEncoding(topDict.getByName('Encoding'), properties, cff.strings, charset.charset);
  24108. }
  24109. cff.charset = charset;
  24110. cff.encoding = encoding;
  24111. var charStringsAndSeacs = this.parseCharStrings(charStringIndex, topDict.privateDict.subrsIndex, globalSubrIndex.obj, cff.fdSelect, cff.fdArray);
  24112. cff.charStrings = charStringsAndSeacs.charStrings;
  24113. cff.seacs = charStringsAndSeacs.seacs;
  24114. cff.widths = charStringsAndSeacs.widths;
  24115. return cff;
  24116. },
  24117. parseHeader: function CFFParser_parseHeader() {
  24118. var bytes = this.bytes;
  24119. var bytesLength = bytes.length;
  24120. var offset = 0;
  24121. while (offset < bytesLength && bytes[offset] !== 1) {
  24122. ++offset;
  24123. }
  24124. if (offset >= bytesLength) {
  24125. error('Invalid CFF header');
  24126. } else if (offset !== 0) {
  24127. info('cff data is shifted');
  24128. bytes = bytes.subarray(offset);
  24129. this.bytes = bytes;
  24130. }
  24131. var major = bytes[0];
  24132. var minor = bytes[1];
  24133. var hdrSize = bytes[2];
  24134. var offSize = bytes[3];
  24135. var header = new CFFHeader(major, minor, hdrSize, offSize);
  24136. return {
  24137. obj: header,
  24138. endPos: hdrSize
  24139. };
  24140. },
  24141. parseDict: function CFFParser_parseDict(dict) {
  24142. var pos = 0;
  24143. function parseOperand() {
  24144. var value = dict[pos++];
  24145. if (value === 30) {
  24146. return parseFloatOperand();
  24147. } else if (value === 28) {
  24148. value = dict[pos++];
  24149. value = (value << 24 | dict[pos++] << 16) >> 16;
  24150. return value;
  24151. } else if (value === 29) {
  24152. value = dict[pos++];
  24153. value = value << 8 | dict[pos++];
  24154. value = value << 8 | dict[pos++];
  24155. value = value << 8 | dict[pos++];
  24156. return value;
  24157. } else if (value >= 32 && value <= 246) {
  24158. return value - 139;
  24159. } else if (value >= 247 && value <= 250) {
  24160. return (value - 247) * 256 + dict[pos++] + 108;
  24161. } else if (value >= 251 && value <= 254) {
  24162. return -((value - 251) * 256) - dict[pos++] - 108;
  24163. }
  24164. warn('CFFParser_parseDict: "' + value + '" is a reserved command.');
  24165. return NaN;
  24166. }
  24167. function parseFloatOperand() {
  24168. var str = '';
  24169. var eof = 15;
  24170. var lookup = [
  24171. '0',
  24172. '1',
  24173. '2',
  24174. '3',
  24175. '4',
  24176. '5',
  24177. '6',
  24178. '7',
  24179. '8',
  24180. '9',
  24181. '.',
  24182. 'E',
  24183. 'E-',
  24184. null,
  24185. '-'
  24186. ];
  24187. var length = dict.length;
  24188. while (pos < length) {
  24189. var b = dict[pos++];
  24190. var b1 = b >> 4;
  24191. var b2 = b & 15;
  24192. if (b1 === eof) {
  24193. break;
  24194. }
  24195. str += lookup[b1];
  24196. if (b2 === eof) {
  24197. break;
  24198. }
  24199. str += lookup[b2];
  24200. }
  24201. return parseFloat(str);
  24202. }
  24203. var operands = [];
  24204. var entries = [];
  24205. pos = 0;
  24206. var end = dict.length;
  24207. while (pos < end) {
  24208. var b = dict[pos];
  24209. if (b <= 21) {
  24210. if (b === 12) {
  24211. b = b << 8 | dict[++pos];
  24212. }
  24213. entries.push([
  24214. b,
  24215. operands
  24216. ]);
  24217. operands = [];
  24218. ++pos;
  24219. } else {
  24220. operands.push(parseOperand());
  24221. }
  24222. }
  24223. return entries;
  24224. },
  24225. parseIndex: function CFFParser_parseIndex(pos) {
  24226. var cffIndex = new CFFIndex();
  24227. var bytes = this.bytes;
  24228. var count = bytes[pos++] << 8 | bytes[pos++];
  24229. var offsets = [];
  24230. var end = pos;
  24231. var i, ii;
  24232. if (count !== 0) {
  24233. var offsetSize = bytes[pos++];
  24234. var startPos = pos + (count + 1) * offsetSize - 1;
  24235. for (i = 0, ii = count + 1; i < ii; ++i) {
  24236. var offset = 0;
  24237. for (var j = 0; j < offsetSize; ++j) {
  24238. offset <<= 8;
  24239. offset += bytes[pos++];
  24240. }
  24241. offsets.push(startPos + offset);
  24242. }
  24243. end = offsets[count];
  24244. }
  24245. for (i = 0, ii = offsets.length - 1; i < ii; ++i) {
  24246. var offsetStart = offsets[i];
  24247. var offsetEnd = offsets[i + 1];
  24248. cffIndex.add(bytes.subarray(offsetStart, offsetEnd));
  24249. }
  24250. return {
  24251. obj: cffIndex,
  24252. endPos: end
  24253. };
  24254. },
  24255. parseNameIndex: function CFFParser_parseNameIndex(index) {
  24256. var names = [];
  24257. for (var i = 0, ii = index.count; i < ii; ++i) {
  24258. var name = index.get(i);
  24259. var length = Math.min(name.length, 127);
  24260. var data = [];
  24261. for (var j = 0; j < length; ++j) {
  24262. var c = name[j];
  24263. if (j === 0 && c === 0) {
  24264. data[j] = c;
  24265. continue;
  24266. }
  24267. 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) {
  24268. data[j] = 95;
  24269. continue;
  24270. }
  24271. data[j] = c;
  24272. }
  24273. names.push(bytesToString(data));
  24274. }
  24275. return names;
  24276. },
  24277. parseStringIndex: function CFFParser_parseStringIndex(index) {
  24278. var strings = new CFFStrings();
  24279. for (var i = 0, ii = index.count; i < ii; ++i) {
  24280. var data = index.get(i);
  24281. strings.add(bytesToString(data));
  24282. }
  24283. return strings;
  24284. },
  24285. createDict: function CFFParser_createDict(Type, dict, strings) {
  24286. var cffDict = new Type(strings);
  24287. for (var i = 0, ii = dict.length; i < ii; ++i) {
  24288. var pair = dict[i];
  24289. var key = pair[0];
  24290. var value = pair[1];
  24291. cffDict.setByKey(key, value);
  24292. }
  24293. return cffDict;
  24294. },
  24295. parseCharString: function CFFParser_parseCharString(state, data, localSubrIndex, globalSubrIndex) {
  24296. if (state.callDepth > MAX_SUBR_NESTING) {
  24297. return false;
  24298. }
  24299. var stackSize = state.stackSize;
  24300. var stack = state.stack;
  24301. var length = data.length;
  24302. for (var j = 0; j < length;) {
  24303. var value = data[j++];
  24304. var validationCommand = null;
  24305. if (value === 12) {
  24306. var q = data[j++];
  24307. if (q === 0) {
  24308. data[j - 2] = 139;
  24309. data[j - 1] = 22;
  24310. stackSize = 0;
  24311. } else {
  24312. validationCommand = CharstringValidationData12[q];
  24313. }
  24314. } else if (value === 28) {
  24315. stack[stackSize] = (data[j] << 24 | data[j + 1] << 16) >> 16;
  24316. j += 2;
  24317. stackSize++;
  24318. } else if (value === 14) {
  24319. if (stackSize >= 4) {
  24320. stackSize -= 4;
  24321. if (this.seacAnalysisEnabled) {
  24322. state.seac = stack.slice(stackSize, stackSize + 4);
  24323. return false;
  24324. }
  24325. }
  24326. validationCommand = CharstringValidationData[value];
  24327. } else if (value >= 32 && value <= 246) {
  24328. stack[stackSize] = value - 139;
  24329. stackSize++;
  24330. } else if (value >= 247 && value <= 254) {
  24331. stack[stackSize] = value < 251 ? (value - 247 << 8) + data[j] + 108 : -(value - 251 << 8) - data[j] - 108;
  24332. j++;
  24333. stackSize++;
  24334. } else if (value === 255) {
  24335. stack[stackSize] = (data[j] << 24 | data[j + 1] << 16 | data[j + 2] << 8 | data[j + 3]) / 65536;
  24336. j += 4;
  24337. stackSize++;
  24338. } else if (value === 19 || value === 20) {
  24339. state.hints += stackSize >> 1;
  24340. j += state.hints + 7 >> 3;
  24341. stackSize %= 2;
  24342. validationCommand = CharstringValidationData[value];
  24343. } else if (value === 10 || value === 29) {
  24344. var subrsIndex;
  24345. if (value === 10) {
  24346. subrsIndex = localSubrIndex;
  24347. } else {
  24348. subrsIndex = globalSubrIndex;
  24349. }
  24350. if (!subrsIndex) {
  24351. validationCommand = CharstringValidationData[value];
  24352. warn('Missing subrsIndex for ' + validationCommand.id);
  24353. return false;
  24354. }
  24355. var bias = 32768;
  24356. if (subrsIndex.count < 1240) {
  24357. bias = 107;
  24358. } else if (subrsIndex.count < 33900) {
  24359. bias = 1131;
  24360. }
  24361. var subrNumber = stack[--stackSize] + bias;
  24362. if (subrNumber < 0 || subrNumber >= subrsIndex.count) {
  24363. validationCommand = CharstringValidationData[value];
  24364. warn('Out of bounds subrIndex for ' + validationCommand.id);
  24365. return false;
  24366. }
  24367. state.stackSize = stackSize;
  24368. state.callDepth++;
  24369. var valid = this.parseCharString(state, subrsIndex.get(subrNumber), localSubrIndex, globalSubrIndex);
  24370. if (!valid) {
  24371. return false;
  24372. }
  24373. state.callDepth--;
  24374. stackSize = state.stackSize;
  24375. continue;
  24376. } else if (value === 11) {
  24377. state.stackSize = stackSize;
  24378. return true;
  24379. } else {
  24380. validationCommand = CharstringValidationData[value];
  24381. }
  24382. if (validationCommand) {
  24383. if (validationCommand.stem) {
  24384. state.hints += stackSize >> 1;
  24385. }
  24386. if ('min' in validationCommand) {
  24387. if (!state.undefStack && stackSize < validationCommand.min) {
  24388. warn('Not enough parameters for ' + validationCommand.id + '; actual: ' + stackSize + ', expected: ' + validationCommand.min);
  24389. return false;
  24390. }
  24391. }
  24392. if (state.firstStackClearing && validationCommand.stackClearing) {
  24393. state.firstStackClearing = false;
  24394. stackSize -= validationCommand.min;
  24395. if (stackSize >= 2 && validationCommand.stem) {
  24396. stackSize %= 2;
  24397. } else if (stackSize > 1) {
  24398. warn('Found too many parameters for stack-clearing command');
  24399. }
  24400. if (stackSize > 0 && stack[stackSize - 1] >= 0) {
  24401. state.width = stack[stackSize - 1];
  24402. }
  24403. }
  24404. if ('stackDelta' in validationCommand) {
  24405. if ('stackFn' in validationCommand) {
  24406. validationCommand.stackFn(stack, stackSize);
  24407. }
  24408. stackSize += validationCommand.stackDelta;
  24409. } else if (validationCommand.stackClearing) {
  24410. stackSize = 0;
  24411. } else if (validationCommand.resetStack) {
  24412. stackSize = 0;
  24413. state.undefStack = false;
  24414. } else if (validationCommand.undefStack) {
  24415. stackSize = 0;
  24416. state.undefStack = true;
  24417. state.firstStackClearing = false;
  24418. }
  24419. }
  24420. }
  24421. state.stackSize = stackSize;
  24422. return true;
  24423. },
  24424. parseCharStrings: function CFFParser_parseCharStrings(charStrings, localSubrIndex, globalSubrIndex, fdSelect, fdArray) {
  24425. var seacs = [];
  24426. var widths = [];
  24427. var count = charStrings.count;
  24428. for (var i = 0; i < count; i++) {
  24429. var charstring = charStrings.get(i);
  24430. var state = {
  24431. callDepth: 0,
  24432. stackSize: 0,
  24433. stack: [],
  24434. undefStack: true,
  24435. hints: 0,
  24436. firstStackClearing: true,
  24437. seac: null,
  24438. width: null
  24439. };
  24440. var valid = true;
  24441. var localSubrToUse = null;
  24442. if (fdSelect && fdArray.length) {
  24443. var fdIndex = fdSelect.getFDIndex(i);
  24444. if (fdIndex === -1) {
  24445. warn('Glyph index is not in fd select.');
  24446. valid = false;
  24447. }
  24448. if (fdIndex >= fdArray.length) {
  24449. warn('Invalid fd index for glyph index.');
  24450. valid = false;
  24451. }
  24452. if (valid) {
  24453. localSubrToUse = fdArray[fdIndex].privateDict.subrsIndex;
  24454. }
  24455. } else if (localSubrIndex) {
  24456. localSubrToUse = localSubrIndex;
  24457. }
  24458. if (valid) {
  24459. valid = this.parseCharString(state, charstring, localSubrToUse, globalSubrIndex);
  24460. }
  24461. if (state.width !== null) {
  24462. widths[i] = state.width;
  24463. }
  24464. if (state.seac !== null) {
  24465. seacs[i] = state.seac;
  24466. }
  24467. if (!valid) {
  24468. charStrings.set(i, new Uint8Array([14]));
  24469. }
  24470. }
  24471. return {
  24472. charStrings: charStrings,
  24473. seacs: seacs,
  24474. widths: widths
  24475. };
  24476. },
  24477. emptyPrivateDictionary: function CFFParser_emptyPrivateDictionary(parentDict) {
  24478. var privateDict = this.createDict(CFFPrivateDict, [], parentDict.strings);
  24479. parentDict.setByKey(18, [
  24480. 0,
  24481. 0
  24482. ]);
  24483. parentDict.privateDict = privateDict;
  24484. },
  24485. parsePrivateDict: function CFFParser_parsePrivateDict(parentDict) {
  24486. if (!parentDict.hasName('Private')) {
  24487. this.emptyPrivateDictionary(parentDict);
  24488. return;
  24489. }
  24490. var privateOffset = parentDict.getByName('Private');
  24491. if (!isArray(privateOffset) || privateOffset.length !== 2) {
  24492. parentDict.removeByName('Private');
  24493. return;
  24494. }
  24495. var size = privateOffset[0];
  24496. var offset = privateOffset[1];
  24497. if (size === 0 || offset >= this.bytes.length) {
  24498. this.emptyPrivateDictionary(parentDict);
  24499. return;
  24500. }
  24501. var privateDictEnd = offset + size;
  24502. var dictData = this.bytes.subarray(offset, privateDictEnd);
  24503. var dict = this.parseDict(dictData);
  24504. var privateDict = this.createDict(CFFPrivateDict, dict, parentDict.strings);
  24505. parentDict.privateDict = privateDict;
  24506. if (!privateDict.getByName('Subrs')) {
  24507. return;
  24508. }
  24509. var subrsOffset = privateDict.getByName('Subrs');
  24510. var relativeOffset = offset + subrsOffset;
  24511. if (subrsOffset === 0 || relativeOffset >= this.bytes.length) {
  24512. this.emptyPrivateDictionary(parentDict);
  24513. return;
  24514. }
  24515. var subrsIndex = this.parseIndex(relativeOffset);
  24516. privateDict.subrsIndex = subrsIndex.obj;
  24517. },
  24518. parseCharsets: function CFFParser_parseCharsets(pos, length, strings, cid) {
  24519. if (pos === 0) {
  24520. return new CFFCharset(true, CFFCharsetPredefinedTypes.ISO_ADOBE, ISOAdobeCharset);
  24521. } else if (pos === 1) {
  24522. return new CFFCharset(true, CFFCharsetPredefinedTypes.EXPERT, ExpertCharset);
  24523. } else if (pos === 2) {
  24524. return new CFFCharset(true, CFFCharsetPredefinedTypes.EXPERT_SUBSET, ExpertSubsetCharset);
  24525. }
  24526. var bytes = this.bytes;
  24527. var start = pos;
  24528. var format = bytes[pos++];
  24529. var charset = ['.notdef'];
  24530. var id, count, i;
  24531. length -= 1;
  24532. switch (format) {
  24533. case 0:
  24534. for (i = 0; i < length; i++) {
  24535. id = bytes[pos++] << 8 | bytes[pos++];
  24536. charset.push(cid ? id : strings.get(id));
  24537. }
  24538. break;
  24539. case 1:
  24540. while (charset.length <= length) {
  24541. id = bytes[pos++] << 8 | bytes[pos++];
  24542. count = bytes[pos++];
  24543. for (i = 0; i <= count; i++) {
  24544. charset.push(cid ? id++ : strings.get(id++));
  24545. }
  24546. }
  24547. break;
  24548. case 2:
  24549. while (charset.length <= length) {
  24550. id = bytes[pos++] << 8 | bytes[pos++];
  24551. count = bytes[pos++] << 8 | bytes[pos++];
  24552. for (i = 0; i <= count; i++) {
  24553. charset.push(cid ? id++ : strings.get(id++));
  24554. }
  24555. }
  24556. break;
  24557. default:
  24558. error('Unknown charset format');
  24559. }
  24560. var end = pos;
  24561. var raw = bytes.subarray(start, end);
  24562. return new CFFCharset(false, format, charset, raw);
  24563. },
  24564. parseEncoding: function CFFParser_parseEncoding(pos, properties, strings, charset) {
  24565. var encoding = Object.create(null);
  24566. var bytes = this.bytes;
  24567. var predefined = false;
  24568. var format, i, ii;
  24569. var raw = null;
  24570. function readSupplement() {
  24571. var supplementsCount = bytes[pos++];
  24572. for (i = 0; i < supplementsCount; i++) {
  24573. var code = bytes[pos++];
  24574. var sid = (bytes[pos++] << 8) + (bytes[pos++] & 0xff);
  24575. encoding[code] = charset.indexOf(strings.get(sid));
  24576. }
  24577. }
  24578. if (pos === 0 || pos === 1) {
  24579. predefined = true;
  24580. format = pos;
  24581. var baseEncoding = pos ? ExpertEncoding : StandardEncoding;
  24582. for (i = 0, ii = charset.length; i < ii; i++) {
  24583. var index = baseEncoding.indexOf(charset[i]);
  24584. if (index !== -1) {
  24585. encoding[index] = i;
  24586. }
  24587. }
  24588. } else {
  24589. var dataStart = pos;
  24590. format = bytes[pos++];
  24591. switch (format & 0x7f) {
  24592. case 0:
  24593. var glyphsCount = bytes[pos++];
  24594. for (i = 1; i <= glyphsCount; i++) {
  24595. encoding[bytes[pos++]] = i;
  24596. }
  24597. break;
  24598. case 1:
  24599. var rangesCount = bytes[pos++];
  24600. var gid = 1;
  24601. for (i = 0; i < rangesCount; i++) {
  24602. var start = bytes[pos++];
  24603. var left = bytes[pos++];
  24604. for (var j = start; j <= start + left; j++) {
  24605. encoding[j] = gid++;
  24606. }
  24607. }
  24608. break;
  24609. default:
  24610. error('Unknown encoding format: ' + format + ' in CFF');
  24611. break;
  24612. }
  24613. var dataEnd = pos;
  24614. if (format & 0x80) {
  24615. bytes[dataStart] &= 0x7f;
  24616. readSupplement();
  24617. }
  24618. raw = bytes.subarray(dataStart, dataEnd);
  24619. }
  24620. format = format & 0x7f;
  24621. return new CFFEncoding(predefined, format, encoding, raw);
  24622. },
  24623. parseFDSelect: function CFFParser_parseFDSelect(pos, length) {
  24624. var start = pos;
  24625. var bytes = this.bytes;
  24626. var format = bytes[pos++];
  24627. var fdSelect = [], rawBytes;
  24628. var i, invalidFirstGID = false;
  24629. switch (format) {
  24630. case 0:
  24631. for (i = 0; i < length; ++i) {
  24632. var id = bytes[pos++];
  24633. fdSelect.push(id);
  24634. }
  24635. rawBytes = bytes.subarray(start, pos);
  24636. break;
  24637. case 3:
  24638. var rangesCount = bytes[pos++] << 8 | bytes[pos++];
  24639. for (i = 0; i < rangesCount; ++i) {
  24640. var first = bytes[pos++] << 8 | bytes[pos++];
  24641. if (i === 0 && first !== 0) {
  24642. warn('parseFDSelect: The first range must have a first GID of 0' + ' -- trying to recover.');
  24643. invalidFirstGID = true;
  24644. first = 0;
  24645. }
  24646. var fdIndex = bytes[pos++];
  24647. var next = bytes[pos] << 8 | bytes[pos + 1];
  24648. for (var j = first; j < next; ++j) {
  24649. fdSelect.push(fdIndex);
  24650. }
  24651. }
  24652. pos += 2;
  24653. rawBytes = bytes.subarray(start, pos);
  24654. if (invalidFirstGID) {
  24655. rawBytes[3] = rawBytes[4] = 0;
  24656. }
  24657. break;
  24658. default:
  24659. error('parseFDSelect: Unknown format "' + format + '".');
  24660. break;
  24661. }
  24662. assert(fdSelect.length === length, 'parseFDSelect: Invalid font data.');
  24663. return new CFFFDSelect(fdSelect, rawBytes);
  24664. }
  24665. };
  24666. return CFFParser;
  24667. }();
  24668. var CFF = function CFFClosure() {
  24669. function CFF() {
  24670. this.header = null;
  24671. this.names = [];
  24672. this.topDict = null;
  24673. this.strings = new CFFStrings();
  24674. this.globalSubrIndex = null;
  24675. this.encoding = null;
  24676. this.charset = null;
  24677. this.charStrings = null;
  24678. this.fdArray = [];
  24679. this.fdSelect = null;
  24680. this.isCIDFont = false;
  24681. }
  24682. return CFF;
  24683. }();
  24684. var CFFHeader = function CFFHeaderClosure() {
  24685. function CFFHeader(major, minor, hdrSize, offSize) {
  24686. this.major = major;
  24687. this.minor = minor;
  24688. this.hdrSize = hdrSize;
  24689. this.offSize = offSize;
  24690. }
  24691. return CFFHeader;
  24692. }();
  24693. var CFFStrings = function CFFStringsClosure() {
  24694. function CFFStrings() {
  24695. this.strings = [];
  24696. }
  24697. CFFStrings.prototype = {
  24698. get: function CFFStrings_get(index) {
  24699. if (index >= 0 && index <= 390) {
  24700. return CFFStandardStrings[index];
  24701. }
  24702. if (index - 391 <= this.strings.length) {
  24703. return this.strings[index - 391];
  24704. }
  24705. return CFFStandardStrings[0];
  24706. },
  24707. add: function CFFStrings_add(value) {
  24708. this.strings.push(value);
  24709. },
  24710. get count() {
  24711. return this.strings.length;
  24712. }
  24713. };
  24714. return CFFStrings;
  24715. }();
  24716. var CFFIndex = function CFFIndexClosure() {
  24717. function CFFIndex() {
  24718. this.objects = [];
  24719. this.length = 0;
  24720. }
  24721. CFFIndex.prototype = {
  24722. add: function CFFIndex_add(data) {
  24723. this.length += data.length;
  24724. this.objects.push(data);
  24725. },
  24726. set: function CFFIndex_set(index, data) {
  24727. this.length += data.length - this.objects[index].length;
  24728. this.objects[index] = data;
  24729. },
  24730. get: function CFFIndex_get(index) {
  24731. return this.objects[index];
  24732. },
  24733. get count() {
  24734. return this.objects.length;
  24735. }
  24736. };
  24737. return CFFIndex;
  24738. }();
  24739. var CFFDict = function CFFDictClosure() {
  24740. function CFFDict(tables, strings) {
  24741. this.keyToNameMap = tables.keyToNameMap;
  24742. this.nameToKeyMap = tables.nameToKeyMap;
  24743. this.defaults = tables.defaults;
  24744. this.types = tables.types;
  24745. this.opcodes = tables.opcodes;
  24746. this.order = tables.order;
  24747. this.strings = strings;
  24748. this.values = Object.create(null);
  24749. }
  24750. CFFDict.prototype = {
  24751. setByKey: function CFFDict_setByKey(key, value) {
  24752. if (!(key in this.keyToNameMap)) {
  24753. return false;
  24754. }
  24755. var valueLength = value.length;
  24756. if (valueLength === 0) {
  24757. return true;
  24758. }
  24759. for (var i = 0; i < valueLength; i++) {
  24760. if (isNaN(value[i])) {
  24761. warn('Invalid CFFDict value: "' + value + '" for key "' + key + '".');
  24762. return true;
  24763. }
  24764. }
  24765. var type = this.types[key];
  24766. if (type === 'num' || type === 'sid' || type === 'offset') {
  24767. value = value[0];
  24768. }
  24769. this.values[key] = value;
  24770. return true;
  24771. },
  24772. setByName: function CFFDict_setByName(name, value) {
  24773. if (!(name in this.nameToKeyMap)) {
  24774. error('Invalid dictionary name "' + name + '"');
  24775. }
  24776. this.values[this.nameToKeyMap[name]] = value;
  24777. },
  24778. hasName: function CFFDict_hasName(name) {
  24779. return this.nameToKeyMap[name] in this.values;
  24780. },
  24781. getByName: function CFFDict_getByName(name) {
  24782. if (!(name in this.nameToKeyMap)) {
  24783. error('Invalid dictionary name "' + name + '"');
  24784. }
  24785. var key = this.nameToKeyMap[name];
  24786. if (!(key in this.values)) {
  24787. return this.defaults[key];
  24788. }
  24789. return this.values[key];
  24790. },
  24791. removeByName: function CFFDict_removeByName(name) {
  24792. delete this.values[this.nameToKeyMap[name]];
  24793. }
  24794. };
  24795. CFFDict.createTables = function CFFDict_createTables(layout) {
  24796. var tables = {
  24797. keyToNameMap: {},
  24798. nameToKeyMap: {},
  24799. defaults: {},
  24800. types: {},
  24801. opcodes: {},
  24802. order: []
  24803. };
  24804. for (var i = 0, ii = layout.length; i < ii; ++i) {
  24805. var entry = layout[i];
  24806. var key = isArray(entry[0]) ? (entry[0][0] << 8) + entry[0][1] : entry[0];
  24807. tables.keyToNameMap[key] = entry[1];
  24808. tables.nameToKeyMap[entry[1]] = key;
  24809. tables.types[key] = entry[2];
  24810. tables.defaults[key] = entry[3];
  24811. tables.opcodes[key] = isArray(entry[0]) ? entry[0] : [entry[0]];
  24812. tables.order.push(key);
  24813. }
  24814. return tables;
  24815. };
  24816. return CFFDict;
  24817. }();
  24818. var CFFTopDict = function CFFTopDictClosure() {
  24819. var layout = [
  24820. [
  24821. [
  24822. 12,
  24823. 30
  24824. ],
  24825. 'ROS',
  24826. [
  24827. 'sid',
  24828. 'sid',
  24829. 'num'
  24830. ],
  24831. null
  24832. ],
  24833. [
  24834. [
  24835. 12,
  24836. 20
  24837. ],
  24838. 'SyntheticBase',
  24839. 'num',
  24840. null
  24841. ],
  24842. [
  24843. 0,
  24844. 'version',
  24845. 'sid',
  24846. null
  24847. ],
  24848. [
  24849. 1,
  24850. 'Notice',
  24851. 'sid',
  24852. null
  24853. ],
  24854. [
  24855. [
  24856. 12,
  24857. 0
  24858. ],
  24859. 'Copyright',
  24860. 'sid',
  24861. null
  24862. ],
  24863. [
  24864. 2,
  24865. 'FullName',
  24866. 'sid',
  24867. null
  24868. ],
  24869. [
  24870. 3,
  24871. 'FamilyName',
  24872. 'sid',
  24873. null
  24874. ],
  24875. [
  24876. 4,
  24877. 'Weight',
  24878. 'sid',
  24879. null
  24880. ],
  24881. [
  24882. [
  24883. 12,
  24884. 1
  24885. ],
  24886. 'isFixedPitch',
  24887. 'num',
  24888. 0
  24889. ],
  24890. [
  24891. [
  24892. 12,
  24893. 2
  24894. ],
  24895. 'ItalicAngle',
  24896. 'num',
  24897. 0
  24898. ],
  24899. [
  24900. [
  24901. 12,
  24902. 3
  24903. ],
  24904. 'UnderlinePosition',
  24905. 'num',
  24906. -100
  24907. ],
  24908. [
  24909. [
  24910. 12,
  24911. 4
  24912. ],
  24913. 'UnderlineThickness',
  24914. 'num',
  24915. 50
  24916. ],
  24917. [
  24918. [
  24919. 12,
  24920. 5
  24921. ],
  24922. 'PaintType',
  24923. 'num',
  24924. 0
  24925. ],
  24926. [
  24927. [
  24928. 12,
  24929. 6
  24930. ],
  24931. 'CharstringType',
  24932. 'num',
  24933. 2
  24934. ],
  24935. [
  24936. [
  24937. 12,
  24938. 7
  24939. ],
  24940. 'FontMatrix',
  24941. [
  24942. 'num',
  24943. 'num',
  24944. 'num',
  24945. 'num',
  24946. 'num',
  24947. 'num'
  24948. ],
  24949. [
  24950. 0.001,
  24951. 0,
  24952. 0,
  24953. 0.001,
  24954. 0,
  24955. 0
  24956. ]
  24957. ],
  24958. [
  24959. 13,
  24960. 'UniqueID',
  24961. 'num',
  24962. null
  24963. ],
  24964. [
  24965. 5,
  24966. 'FontBBox',
  24967. [
  24968. 'num',
  24969. 'num',
  24970. 'num',
  24971. 'num'
  24972. ],
  24973. [
  24974. 0,
  24975. 0,
  24976. 0,
  24977. 0
  24978. ]
  24979. ],
  24980. [
  24981. [
  24982. 12,
  24983. 8
  24984. ],
  24985. 'StrokeWidth',
  24986. 'num',
  24987. 0
  24988. ],
  24989. [
  24990. 14,
  24991. 'XUID',
  24992. 'array',
  24993. null
  24994. ],
  24995. [
  24996. 15,
  24997. 'charset',
  24998. 'offset',
  24999. 0
  25000. ],
  25001. [
  25002. 16,
  25003. 'Encoding',
  25004. 'offset',
  25005. 0
  25006. ],
  25007. [
  25008. 17,
  25009. 'CharStrings',
  25010. 'offset',
  25011. 0
  25012. ],
  25013. [
  25014. 18,
  25015. 'Private',
  25016. [
  25017. 'offset',
  25018. 'offset'
  25019. ],
  25020. null
  25021. ],
  25022. [
  25023. [
  25024. 12,
  25025. 21
  25026. ],
  25027. 'PostScript',
  25028. 'sid',
  25029. null
  25030. ],
  25031. [
  25032. [
  25033. 12,
  25034. 22
  25035. ],
  25036. 'BaseFontName',
  25037. 'sid',
  25038. null
  25039. ],
  25040. [
  25041. [
  25042. 12,
  25043. 23
  25044. ],
  25045. 'BaseFontBlend',
  25046. 'delta',
  25047. null
  25048. ],
  25049. [
  25050. [
  25051. 12,
  25052. 31
  25053. ],
  25054. 'CIDFontVersion',
  25055. 'num',
  25056. 0
  25057. ],
  25058. [
  25059. [
  25060. 12,
  25061. 32
  25062. ],
  25063. 'CIDFontRevision',
  25064. 'num',
  25065. 0
  25066. ],
  25067. [
  25068. [
  25069. 12,
  25070. 33
  25071. ],
  25072. 'CIDFontType',
  25073. 'num',
  25074. 0
  25075. ],
  25076. [
  25077. [
  25078. 12,
  25079. 34
  25080. ],
  25081. 'CIDCount',
  25082. 'num',
  25083. 8720
  25084. ],
  25085. [
  25086. [
  25087. 12,
  25088. 35
  25089. ],
  25090. 'UIDBase',
  25091. 'num',
  25092. null
  25093. ],
  25094. [
  25095. [
  25096. 12,
  25097. 37
  25098. ],
  25099. 'FDSelect',
  25100. 'offset',
  25101. null
  25102. ],
  25103. [
  25104. [
  25105. 12,
  25106. 36
  25107. ],
  25108. 'FDArray',
  25109. 'offset',
  25110. null
  25111. ],
  25112. [
  25113. [
  25114. 12,
  25115. 38
  25116. ],
  25117. 'FontName',
  25118. 'sid',
  25119. null
  25120. ]
  25121. ];
  25122. var tables = null;
  25123. function CFFTopDict(strings) {
  25124. if (tables === null) {
  25125. tables = CFFDict.createTables(layout);
  25126. }
  25127. CFFDict.call(this, tables, strings);
  25128. this.privateDict = null;
  25129. }
  25130. CFFTopDict.prototype = Object.create(CFFDict.prototype);
  25131. return CFFTopDict;
  25132. }();
  25133. var CFFPrivateDict = function CFFPrivateDictClosure() {
  25134. var layout = [
  25135. [
  25136. 6,
  25137. 'BlueValues',
  25138. 'delta',
  25139. null
  25140. ],
  25141. [
  25142. 7,
  25143. 'OtherBlues',
  25144. 'delta',
  25145. null
  25146. ],
  25147. [
  25148. 8,
  25149. 'FamilyBlues',
  25150. 'delta',
  25151. null
  25152. ],
  25153. [
  25154. 9,
  25155. 'FamilyOtherBlues',
  25156. 'delta',
  25157. null
  25158. ],
  25159. [
  25160. [
  25161. 12,
  25162. 9
  25163. ],
  25164. 'BlueScale',
  25165. 'num',
  25166. 0.039625
  25167. ],
  25168. [
  25169. [
  25170. 12,
  25171. 10
  25172. ],
  25173. 'BlueShift',
  25174. 'num',
  25175. 7
  25176. ],
  25177. [
  25178. [
  25179. 12,
  25180. 11
  25181. ],
  25182. 'BlueFuzz',
  25183. 'num',
  25184. 1
  25185. ],
  25186. [
  25187. 10,
  25188. 'StdHW',
  25189. 'num',
  25190. null
  25191. ],
  25192. [
  25193. 11,
  25194. 'StdVW',
  25195. 'num',
  25196. null
  25197. ],
  25198. [
  25199. [
  25200. 12,
  25201. 12
  25202. ],
  25203. 'StemSnapH',
  25204. 'delta',
  25205. null
  25206. ],
  25207. [
  25208. [
  25209. 12,
  25210. 13
  25211. ],
  25212. 'StemSnapV',
  25213. 'delta',
  25214. null
  25215. ],
  25216. [
  25217. [
  25218. 12,
  25219. 14
  25220. ],
  25221. 'ForceBold',
  25222. 'num',
  25223. 0
  25224. ],
  25225. [
  25226. [
  25227. 12,
  25228. 17
  25229. ],
  25230. 'LanguageGroup',
  25231. 'num',
  25232. 0
  25233. ],
  25234. [
  25235. [
  25236. 12,
  25237. 18
  25238. ],
  25239. 'ExpansionFactor',
  25240. 'num',
  25241. 0.06
  25242. ],
  25243. [
  25244. [
  25245. 12,
  25246. 19
  25247. ],
  25248. 'initialRandomSeed',
  25249. 'num',
  25250. 0
  25251. ],
  25252. [
  25253. 20,
  25254. 'defaultWidthX',
  25255. 'num',
  25256. 0
  25257. ],
  25258. [
  25259. 21,
  25260. 'nominalWidthX',
  25261. 'num',
  25262. 0
  25263. ],
  25264. [
  25265. 19,
  25266. 'Subrs',
  25267. 'offset',
  25268. null
  25269. ]
  25270. ];
  25271. var tables = null;
  25272. function CFFPrivateDict(strings) {
  25273. if (tables === null) {
  25274. tables = CFFDict.createTables(layout);
  25275. }
  25276. CFFDict.call(this, tables, strings);
  25277. this.subrsIndex = null;
  25278. }
  25279. CFFPrivateDict.prototype = Object.create(CFFDict.prototype);
  25280. return CFFPrivateDict;
  25281. }();
  25282. var CFFCharsetPredefinedTypes = {
  25283. ISO_ADOBE: 0,
  25284. EXPERT: 1,
  25285. EXPERT_SUBSET: 2
  25286. };
  25287. var CFFCharset = function CFFCharsetClosure() {
  25288. function CFFCharset(predefined, format, charset, raw) {
  25289. this.predefined = predefined;
  25290. this.format = format;
  25291. this.charset = charset;
  25292. this.raw = raw;
  25293. }
  25294. return CFFCharset;
  25295. }();
  25296. var CFFEncoding = function CFFEncodingClosure() {
  25297. function CFFEncoding(predefined, format, encoding, raw) {
  25298. this.predefined = predefined;
  25299. this.format = format;
  25300. this.encoding = encoding;
  25301. this.raw = raw;
  25302. }
  25303. return CFFEncoding;
  25304. }();
  25305. var CFFFDSelect = function CFFFDSelectClosure() {
  25306. function CFFFDSelect(fdSelect, raw) {
  25307. this.fdSelect = fdSelect;
  25308. this.raw = raw;
  25309. }
  25310. CFFFDSelect.prototype = {
  25311. getFDIndex: function CFFFDSelect_get(glyphIndex) {
  25312. if (glyphIndex < 0 || glyphIndex >= this.fdSelect.length) {
  25313. return -1;
  25314. }
  25315. return this.fdSelect[glyphIndex];
  25316. }
  25317. };
  25318. return CFFFDSelect;
  25319. }();
  25320. var CFFOffsetTracker = function CFFOffsetTrackerClosure() {
  25321. function CFFOffsetTracker() {
  25322. this.offsets = Object.create(null);
  25323. }
  25324. CFFOffsetTracker.prototype = {
  25325. isTracking: function CFFOffsetTracker_isTracking(key) {
  25326. return key in this.offsets;
  25327. },
  25328. track: function CFFOffsetTracker_track(key, location) {
  25329. if (key in this.offsets) {
  25330. error('Already tracking location of ' + key);
  25331. }
  25332. this.offsets[key] = location;
  25333. },
  25334. offset: function CFFOffsetTracker_offset(value) {
  25335. for (var key in this.offsets) {
  25336. this.offsets[key] += value;
  25337. }
  25338. },
  25339. setEntryLocation: function CFFOffsetTracker_setEntryLocation(key, values, output) {
  25340. if (!(key in this.offsets)) {
  25341. error('Not tracking location of ' + key);
  25342. }
  25343. var data = output.data;
  25344. var dataOffset = this.offsets[key];
  25345. var size = 5;
  25346. for (var i = 0, ii = values.length; i < ii; ++i) {
  25347. var offset0 = i * size + dataOffset;
  25348. var offset1 = offset0 + 1;
  25349. var offset2 = offset0 + 2;
  25350. var offset3 = offset0 + 3;
  25351. var offset4 = offset0 + 4;
  25352. if (data[offset0] !== 0x1d || data[offset1] !== 0 || data[offset2] !== 0 || data[offset3] !== 0 || data[offset4] !== 0) {
  25353. error('writing to an offset that is not empty');
  25354. }
  25355. var value = values[i];
  25356. data[offset0] = 0x1d;
  25357. data[offset1] = value >> 24 & 0xFF;
  25358. data[offset2] = value >> 16 & 0xFF;
  25359. data[offset3] = value >> 8 & 0xFF;
  25360. data[offset4] = value & 0xFF;
  25361. }
  25362. }
  25363. };
  25364. return CFFOffsetTracker;
  25365. }();
  25366. var CFFCompiler = function CFFCompilerClosure() {
  25367. function CFFCompiler(cff) {
  25368. this.cff = cff;
  25369. }
  25370. CFFCompiler.prototype = {
  25371. compile: function CFFCompiler_compile() {
  25372. var cff = this.cff;
  25373. var output = {
  25374. data: [],
  25375. length: 0,
  25376. add: function CFFCompiler_add(data) {
  25377. this.data = this.data.concat(data);
  25378. this.length = this.data.length;
  25379. }
  25380. };
  25381. var header = this.compileHeader(cff.header);
  25382. output.add(header);
  25383. var nameIndex = this.compileNameIndex(cff.names);
  25384. output.add(nameIndex);
  25385. if (cff.isCIDFont) {
  25386. if (cff.topDict.hasName('FontMatrix')) {
  25387. var base = cff.topDict.getByName('FontMatrix');
  25388. cff.topDict.removeByName('FontMatrix');
  25389. for (var i = 0, ii = cff.fdArray.length; i < ii; i++) {
  25390. var subDict = cff.fdArray[i];
  25391. var matrix = base.slice(0);
  25392. if (subDict.hasName('FontMatrix')) {
  25393. matrix = Util.transform(matrix, subDict.getByName('FontMatrix'));
  25394. }
  25395. subDict.setByName('FontMatrix', matrix);
  25396. }
  25397. }
  25398. }
  25399. var compiled = this.compileTopDicts([cff.topDict], output.length, cff.isCIDFont);
  25400. output.add(compiled.output);
  25401. var topDictTracker = compiled.trackers[0];
  25402. var stringIndex = this.compileStringIndex(cff.strings.strings);
  25403. output.add(stringIndex);
  25404. var globalSubrIndex = this.compileIndex(cff.globalSubrIndex);
  25405. output.add(globalSubrIndex);
  25406. if (cff.encoding && cff.topDict.hasName('Encoding')) {
  25407. if (cff.encoding.predefined) {
  25408. topDictTracker.setEntryLocation('Encoding', [cff.encoding.format], output);
  25409. } else {
  25410. var encoding = this.compileEncoding(cff.encoding);
  25411. topDictTracker.setEntryLocation('Encoding', [output.length], output);
  25412. output.add(encoding);
  25413. }
  25414. }
  25415. if (cff.charset && cff.topDict.hasName('charset')) {
  25416. if (cff.charset.predefined) {
  25417. topDictTracker.setEntryLocation('charset', [cff.charset.format], output);
  25418. } else {
  25419. var charset = this.compileCharset(cff.charset);
  25420. topDictTracker.setEntryLocation('charset', [output.length], output);
  25421. output.add(charset);
  25422. }
  25423. }
  25424. var charStrings = this.compileCharStrings(cff.charStrings);
  25425. topDictTracker.setEntryLocation('CharStrings', [output.length], output);
  25426. output.add(charStrings);
  25427. if (cff.isCIDFont) {
  25428. topDictTracker.setEntryLocation('FDSelect', [output.length], output);
  25429. var fdSelect = this.compileFDSelect(cff.fdSelect.raw);
  25430. output.add(fdSelect);
  25431. compiled = this.compileTopDicts(cff.fdArray, output.length, true);
  25432. topDictTracker.setEntryLocation('FDArray', [output.length], output);
  25433. output.add(compiled.output);
  25434. var fontDictTrackers = compiled.trackers;
  25435. this.compilePrivateDicts(cff.fdArray, fontDictTrackers, output);
  25436. }
  25437. this.compilePrivateDicts([cff.topDict], [topDictTracker], output);
  25438. output.add([0]);
  25439. return output.data;
  25440. },
  25441. encodeNumber: function CFFCompiler_encodeNumber(value) {
  25442. if (parseFloat(value) === parseInt(value, 10) && !isNaN(value)) {
  25443. return this.encodeInteger(value);
  25444. }
  25445. return this.encodeFloat(value);
  25446. },
  25447. encodeFloat: function CFFCompiler_encodeFloat(num) {
  25448. var value = num.toString();
  25449. var m = /\.(\d*?)(?:9{5,20}|0{5,20})\d{0,2}(?:e(.+)|$)/.exec(value);
  25450. if (m) {
  25451. var epsilon = parseFloat('1e' + ((m[2] ? +m[2] : 0) + m[1].length));
  25452. value = (Math.round(num * epsilon) / epsilon).toString();
  25453. }
  25454. var nibbles = '';
  25455. var i, ii;
  25456. for (i = 0, ii = value.length; i < ii; ++i) {
  25457. var a = value[i];
  25458. if (a === 'e') {
  25459. nibbles += value[++i] === '-' ? 'c' : 'b';
  25460. } else if (a === '.') {
  25461. nibbles += 'a';
  25462. } else if (a === '-') {
  25463. nibbles += 'e';
  25464. } else {
  25465. nibbles += a;
  25466. }
  25467. }
  25468. nibbles += nibbles.length & 1 ? 'f' : 'ff';
  25469. var out = [30];
  25470. for (i = 0, ii = nibbles.length; i < ii; i += 2) {
  25471. out.push(parseInt(nibbles.substr(i, 2), 16));
  25472. }
  25473. return out;
  25474. },
  25475. encodeInteger: function CFFCompiler_encodeInteger(value) {
  25476. var code;
  25477. if (value >= -107 && value <= 107) {
  25478. code = [value + 139];
  25479. } else if (value >= 108 && value <= 1131) {
  25480. value = value - 108;
  25481. code = [
  25482. (value >> 8) + 247,
  25483. value & 0xFF
  25484. ];
  25485. } else if (value >= -1131 && value <= -108) {
  25486. value = -value - 108;
  25487. code = [
  25488. (value >> 8) + 251,
  25489. value & 0xFF
  25490. ];
  25491. } else if (value >= -32768 && value <= 32767) {
  25492. code = [
  25493. 0x1c,
  25494. value >> 8 & 0xFF,
  25495. value & 0xFF
  25496. ];
  25497. } else {
  25498. code = [
  25499. 0x1d,
  25500. value >> 24 & 0xFF,
  25501. value >> 16 & 0xFF,
  25502. value >> 8 & 0xFF,
  25503. value & 0xFF
  25504. ];
  25505. }
  25506. return code;
  25507. },
  25508. compileHeader: function CFFCompiler_compileHeader(header) {
  25509. return [
  25510. header.major,
  25511. header.minor,
  25512. header.hdrSize,
  25513. header.offSize
  25514. ];
  25515. },
  25516. compileNameIndex: function CFFCompiler_compileNameIndex(names) {
  25517. var nameIndex = new CFFIndex();
  25518. for (var i = 0, ii = names.length; i < ii; ++i) {
  25519. nameIndex.add(stringToBytes(names[i]));
  25520. }
  25521. return this.compileIndex(nameIndex);
  25522. },
  25523. compileTopDicts: function CFFCompiler_compileTopDicts(dicts, length, removeCidKeys) {
  25524. var fontDictTrackers = [];
  25525. var fdArrayIndex = new CFFIndex();
  25526. for (var i = 0, ii = dicts.length; i < ii; ++i) {
  25527. var fontDict = dicts[i];
  25528. if (removeCidKeys) {
  25529. fontDict.removeByName('CIDFontVersion');
  25530. fontDict.removeByName('CIDFontRevision');
  25531. fontDict.removeByName('CIDFontType');
  25532. fontDict.removeByName('CIDCount');
  25533. fontDict.removeByName('UIDBase');
  25534. }
  25535. var fontDictTracker = new CFFOffsetTracker();
  25536. var fontDictData = this.compileDict(fontDict, fontDictTracker);
  25537. fontDictTrackers.push(fontDictTracker);
  25538. fdArrayIndex.add(fontDictData);
  25539. fontDictTracker.offset(length);
  25540. }
  25541. fdArrayIndex = this.compileIndex(fdArrayIndex, fontDictTrackers);
  25542. return {
  25543. trackers: fontDictTrackers,
  25544. output: fdArrayIndex
  25545. };
  25546. },
  25547. compilePrivateDicts: function CFFCompiler_compilePrivateDicts(dicts, trackers, output) {
  25548. for (var i = 0, ii = dicts.length; i < ii; ++i) {
  25549. var fontDict = dicts[i];
  25550. assert(fontDict.privateDict && fontDict.hasName('Private'), 'There must be an private dictionary.');
  25551. var privateDict = fontDict.privateDict;
  25552. var privateDictTracker = new CFFOffsetTracker();
  25553. var privateDictData = this.compileDict(privateDict, privateDictTracker);
  25554. var outputLength = output.length;
  25555. privateDictTracker.offset(outputLength);
  25556. if (!privateDictData.length) {
  25557. outputLength = 0;
  25558. }
  25559. trackers[i].setEntryLocation('Private', [
  25560. privateDictData.length,
  25561. outputLength
  25562. ], output);
  25563. output.add(privateDictData);
  25564. if (privateDict.subrsIndex && privateDict.hasName('Subrs')) {
  25565. var subrs = this.compileIndex(privateDict.subrsIndex);
  25566. privateDictTracker.setEntryLocation('Subrs', [privateDictData.length], output);
  25567. output.add(subrs);
  25568. }
  25569. }
  25570. },
  25571. compileDict: function CFFCompiler_compileDict(dict, offsetTracker) {
  25572. var out = [];
  25573. var order = dict.order;
  25574. for (var i = 0; i < order.length; ++i) {
  25575. var key = order[i];
  25576. if (!(key in dict.values)) {
  25577. continue;
  25578. }
  25579. var values = dict.values[key];
  25580. var types = dict.types[key];
  25581. if (!isArray(types)) {
  25582. types = [types];
  25583. }
  25584. if (!isArray(values)) {
  25585. values = [values];
  25586. }
  25587. if (values.length === 0) {
  25588. continue;
  25589. }
  25590. for (var j = 0, jj = types.length; j < jj; ++j) {
  25591. var type = types[j];
  25592. var value = values[j];
  25593. switch (type) {
  25594. case 'num':
  25595. case 'sid':
  25596. out = out.concat(this.encodeNumber(value));
  25597. break;
  25598. case 'offset':
  25599. var name = dict.keyToNameMap[key];
  25600. if (!offsetTracker.isTracking(name)) {
  25601. offsetTracker.track(name, out.length);
  25602. }
  25603. out = out.concat([
  25604. 0x1d,
  25605. 0,
  25606. 0,
  25607. 0,
  25608. 0
  25609. ]);
  25610. break;
  25611. case 'array':
  25612. case 'delta':
  25613. out = out.concat(this.encodeNumber(value));
  25614. for (var k = 1, kk = values.length; k < kk; ++k) {
  25615. out = out.concat(this.encodeNumber(values[k]));
  25616. }
  25617. break;
  25618. default:
  25619. error('Unknown data type of ' + type);
  25620. break;
  25621. }
  25622. }
  25623. out = out.concat(dict.opcodes[key]);
  25624. }
  25625. return out;
  25626. },
  25627. compileStringIndex: function CFFCompiler_compileStringIndex(strings) {
  25628. var stringIndex = new CFFIndex();
  25629. for (var i = 0, ii = strings.length; i < ii; ++i) {
  25630. stringIndex.add(stringToBytes(strings[i]));
  25631. }
  25632. return this.compileIndex(stringIndex);
  25633. },
  25634. compileGlobalSubrIndex: function CFFCompiler_compileGlobalSubrIndex() {
  25635. var globalSubrIndex = this.cff.globalSubrIndex;
  25636. this.out.writeByteArray(this.compileIndex(globalSubrIndex));
  25637. },
  25638. compileCharStrings: function CFFCompiler_compileCharStrings(charStrings) {
  25639. return this.compileIndex(charStrings);
  25640. },
  25641. compileCharset: function CFFCompiler_compileCharset(charset) {
  25642. return this.compileTypedArray(charset.raw);
  25643. },
  25644. compileEncoding: function CFFCompiler_compileEncoding(encoding) {
  25645. return this.compileTypedArray(encoding.raw);
  25646. },
  25647. compileFDSelect: function CFFCompiler_compileFDSelect(fdSelect) {
  25648. return this.compileTypedArray(fdSelect);
  25649. },
  25650. compileTypedArray: function CFFCompiler_compileTypedArray(data) {
  25651. var out = [];
  25652. for (var i = 0, ii = data.length; i < ii; ++i) {
  25653. out[i] = data[i];
  25654. }
  25655. return out;
  25656. },
  25657. compileIndex: function CFFCompiler_compileIndex(index, trackers) {
  25658. trackers = trackers || [];
  25659. var objects = index.objects;
  25660. var count = objects.length;
  25661. if (count === 0) {
  25662. return [
  25663. 0,
  25664. 0,
  25665. 0
  25666. ];
  25667. }
  25668. var data = [
  25669. count >> 8 & 0xFF,
  25670. count & 0xff
  25671. ];
  25672. var lastOffset = 1, i;
  25673. for (i = 0; i < count; ++i) {
  25674. lastOffset += objects[i].length;
  25675. }
  25676. var offsetSize;
  25677. if (lastOffset < 0x100) {
  25678. offsetSize = 1;
  25679. } else if (lastOffset < 0x10000) {
  25680. offsetSize = 2;
  25681. } else if (lastOffset < 0x1000000) {
  25682. offsetSize = 3;
  25683. } else {
  25684. offsetSize = 4;
  25685. }
  25686. data.push(offsetSize);
  25687. var relativeOffset = 1;
  25688. for (i = 0; i < count + 1; i++) {
  25689. if (offsetSize === 1) {
  25690. data.push(relativeOffset & 0xFF);
  25691. } else if (offsetSize === 2) {
  25692. data.push(relativeOffset >> 8 & 0xFF, relativeOffset & 0xFF);
  25693. } else if (offsetSize === 3) {
  25694. data.push(relativeOffset >> 16 & 0xFF, relativeOffset >> 8 & 0xFF, relativeOffset & 0xFF);
  25695. } else {
  25696. data.push(relativeOffset >>> 24 & 0xFF, relativeOffset >> 16 & 0xFF, relativeOffset >> 8 & 0xFF, relativeOffset & 0xFF);
  25697. }
  25698. if (objects[i]) {
  25699. relativeOffset += objects[i].length;
  25700. }
  25701. }
  25702. for (i = 0; i < count; i++) {
  25703. if (trackers[i]) {
  25704. trackers[i].offset(data.length);
  25705. }
  25706. for (var j = 0, jj = objects[i].length; j < jj; j++) {
  25707. data.push(objects[i][j]);
  25708. }
  25709. }
  25710. return data;
  25711. }
  25712. };
  25713. return CFFCompiler;
  25714. }();
  25715. exports.CFFStandardStrings = CFFStandardStrings;
  25716. exports.CFFParser = CFFParser;
  25717. exports.CFF = CFF;
  25718. exports.CFFHeader = CFFHeader;
  25719. exports.CFFStrings = CFFStrings;
  25720. exports.CFFIndex = CFFIndex;
  25721. exports.CFFCharset = CFFCharset;
  25722. exports.CFFTopDict = CFFTopDict;
  25723. exports.CFFPrivateDict = CFFPrivateDict;
  25724. exports.CFFCompiler = CFFCompiler;
  25725. /***/ }),
  25726. /* 16 */
  25727. /***/ (function(module, exports, __w_pdfjs_require__) {
  25728. "use strict";
  25729. var sharedUtil = __w_pdfjs_require__(0);
  25730. var MissingDataException = sharedUtil.MissingDataException;
  25731. var arrayByteLength = sharedUtil.arrayByteLength;
  25732. var arraysToBytes = sharedUtil.arraysToBytes;
  25733. var assert = sharedUtil.assert;
  25734. var createPromiseCapability = sharedUtil.createPromiseCapability;
  25735. var isInt = sharedUtil.isInt;
  25736. var isEmptyObj = sharedUtil.isEmptyObj;
  25737. var ChunkedStream = function ChunkedStreamClosure() {
  25738. function ChunkedStream(length, chunkSize, manager) {
  25739. this.bytes = new Uint8Array(length);
  25740. this.start = 0;
  25741. this.pos = 0;
  25742. this.end = length;
  25743. this.chunkSize = chunkSize;
  25744. this.loadedChunks = [];
  25745. this.numChunksLoaded = 0;
  25746. this.numChunks = Math.ceil(length / chunkSize);
  25747. this.manager = manager;
  25748. this.progressiveDataLength = 0;
  25749. this.lastSuccessfulEnsureByteChunk = -1;
  25750. }
  25751. ChunkedStream.prototype = {
  25752. getMissingChunks: function ChunkedStream_getMissingChunks() {
  25753. var chunks = [];
  25754. for (var chunk = 0, n = this.numChunks; chunk < n; ++chunk) {
  25755. if (!this.loadedChunks[chunk]) {
  25756. chunks.push(chunk);
  25757. }
  25758. }
  25759. return chunks;
  25760. },
  25761. getBaseStreams: function ChunkedStream_getBaseStreams() {
  25762. return [this];
  25763. },
  25764. allChunksLoaded: function ChunkedStream_allChunksLoaded() {
  25765. return this.numChunksLoaded === this.numChunks;
  25766. },
  25767. onReceiveData: function ChunkedStream_onReceiveData(begin, chunk) {
  25768. var end = begin + chunk.byteLength;
  25769. assert(begin % this.chunkSize === 0, 'Bad begin offset: ' + begin);
  25770. var length = this.bytes.length;
  25771. assert(end % this.chunkSize === 0 || end === length, 'Bad end offset: ' + end);
  25772. this.bytes.set(new Uint8Array(chunk), begin);
  25773. var chunkSize = this.chunkSize;
  25774. var beginChunk = Math.floor(begin / chunkSize);
  25775. var endChunk = Math.floor((end - 1) / chunkSize) + 1;
  25776. var curChunk;
  25777. for (curChunk = beginChunk; curChunk < endChunk; ++curChunk) {
  25778. if (!this.loadedChunks[curChunk]) {
  25779. this.loadedChunks[curChunk] = true;
  25780. ++this.numChunksLoaded;
  25781. }
  25782. }
  25783. },
  25784. onReceiveProgressiveData: function ChunkedStream_onReceiveProgressiveData(data) {
  25785. var position = this.progressiveDataLength;
  25786. var beginChunk = Math.floor(position / this.chunkSize);
  25787. this.bytes.set(new Uint8Array(data), position);
  25788. position += data.byteLength;
  25789. this.progressiveDataLength = position;
  25790. var endChunk = position >= this.end ? this.numChunks : Math.floor(position / this.chunkSize);
  25791. var curChunk;
  25792. for (curChunk = beginChunk; curChunk < endChunk; ++curChunk) {
  25793. if (!this.loadedChunks[curChunk]) {
  25794. this.loadedChunks[curChunk] = true;
  25795. ++this.numChunksLoaded;
  25796. }
  25797. }
  25798. },
  25799. ensureByte: function ChunkedStream_ensureByte(pos) {
  25800. var chunk = Math.floor(pos / this.chunkSize);
  25801. if (chunk === this.lastSuccessfulEnsureByteChunk) {
  25802. return;
  25803. }
  25804. if (!this.loadedChunks[chunk]) {
  25805. throw new MissingDataException(pos, pos + 1);
  25806. }
  25807. this.lastSuccessfulEnsureByteChunk = chunk;
  25808. },
  25809. ensureRange: function ChunkedStream_ensureRange(begin, end) {
  25810. if (begin >= end) {
  25811. return;
  25812. }
  25813. if (end <= this.progressiveDataLength) {
  25814. return;
  25815. }
  25816. var chunkSize = this.chunkSize;
  25817. var beginChunk = Math.floor(begin / chunkSize);
  25818. var endChunk = Math.floor((end - 1) / chunkSize) + 1;
  25819. for (var chunk = beginChunk; chunk < endChunk; ++chunk) {
  25820. if (!this.loadedChunks[chunk]) {
  25821. throw new MissingDataException(begin, end);
  25822. }
  25823. }
  25824. },
  25825. nextEmptyChunk: function ChunkedStream_nextEmptyChunk(beginChunk) {
  25826. var chunk, numChunks = this.numChunks;
  25827. for (var i = 0; i < numChunks; ++i) {
  25828. chunk = (beginChunk + i) % numChunks;
  25829. if (!this.loadedChunks[chunk]) {
  25830. return chunk;
  25831. }
  25832. }
  25833. return null;
  25834. },
  25835. hasChunk: function ChunkedStream_hasChunk(chunk) {
  25836. return !!this.loadedChunks[chunk];
  25837. },
  25838. get length() {
  25839. return this.end - this.start;
  25840. },
  25841. get isEmpty() {
  25842. return this.length === 0;
  25843. },
  25844. getByte: function ChunkedStream_getByte() {
  25845. var pos = this.pos;
  25846. if (pos >= this.end) {
  25847. return -1;
  25848. }
  25849. this.ensureByte(pos);
  25850. return this.bytes[this.pos++];
  25851. },
  25852. getUint16: function ChunkedStream_getUint16() {
  25853. var b0 = this.getByte();
  25854. var b1 = this.getByte();
  25855. if (b0 === -1 || b1 === -1) {
  25856. return -1;
  25857. }
  25858. return (b0 << 8) + b1;
  25859. },
  25860. getInt32: function ChunkedStream_getInt32() {
  25861. var b0 = this.getByte();
  25862. var b1 = this.getByte();
  25863. var b2 = this.getByte();
  25864. var b3 = this.getByte();
  25865. return (b0 << 24) + (b1 << 16) + (b2 << 8) + b3;
  25866. },
  25867. getBytes: function ChunkedStream_getBytes(length) {
  25868. var bytes = this.bytes;
  25869. var pos = this.pos;
  25870. var strEnd = this.end;
  25871. if (!length) {
  25872. this.ensureRange(pos, strEnd);
  25873. return bytes.subarray(pos, strEnd);
  25874. }
  25875. var end = pos + length;
  25876. if (end > strEnd) {
  25877. end = strEnd;
  25878. }
  25879. this.ensureRange(pos, end);
  25880. this.pos = end;
  25881. return bytes.subarray(pos, end);
  25882. },
  25883. peekByte: function ChunkedStream_peekByte() {
  25884. var peekedByte = this.getByte();
  25885. this.pos--;
  25886. return peekedByte;
  25887. },
  25888. peekBytes: function ChunkedStream_peekBytes(length) {
  25889. var bytes = this.getBytes(length);
  25890. this.pos -= bytes.length;
  25891. return bytes;
  25892. },
  25893. getByteRange: function ChunkedStream_getBytes(begin, end) {
  25894. this.ensureRange(begin, end);
  25895. return this.bytes.subarray(begin, end);
  25896. },
  25897. skip: function ChunkedStream_skip(n) {
  25898. if (!n) {
  25899. n = 1;
  25900. }
  25901. this.pos += n;
  25902. },
  25903. reset: function ChunkedStream_reset() {
  25904. this.pos = this.start;
  25905. },
  25906. moveStart: function ChunkedStream_moveStart() {
  25907. this.start = this.pos;
  25908. },
  25909. makeSubStream: function ChunkedStream_makeSubStream(start, length, dict) {
  25910. this.ensureRange(start, start + length);
  25911. function ChunkedStreamSubstream() {
  25912. }
  25913. ChunkedStreamSubstream.prototype = Object.create(this);
  25914. ChunkedStreamSubstream.prototype.getMissingChunks = function () {
  25915. var chunkSize = this.chunkSize;
  25916. var beginChunk = Math.floor(this.start / chunkSize);
  25917. var endChunk = Math.floor((this.end - 1) / chunkSize) + 1;
  25918. var missingChunks = [];
  25919. for (var chunk = beginChunk; chunk < endChunk; ++chunk) {
  25920. if (!this.loadedChunks[chunk]) {
  25921. missingChunks.push(chunk);
  25922. }
  25923. }
  25924. return missingChunks;
  25925. };
  25926. var subStream = new ChunkedStreamSubstream();
  25927. subStream.pos = subStream.start = start;
  25928. subStream.end = start + length || this.end;
  25929. subStream.dict = dict;
  25930. return subStream;
  25931. }
  25932. };
  25933. return ChunkedStream;
  25934. }();
  25935. var ChunkedStreamManager = function ChunkedStreamManagerClosure() {
  25936. function ChunkedStreamManager(pdfNetworkStream, args) {
  25937. var chunkSize = args.rangeChunkSize;
  25938. var length = args.length;
  25939. this.stream = new ChunkedStream(length, chunkSize, this);
  25940. this.length = length;
  25941. this.chunkSize = chunkSize;
  25942. this.pdfNetworkStream = pdfNetworkStream;
  25943. this.url = args.url;
  25944. this.disableAutoFetch = args.disableAutoFetch;
  25945. this.msgHandler = args.msgHandler;
  25946. this.currRequestId = 0;
  25947. this.chunksNeededByRequest = Object.create(null);
  25948. this.requestsByChunk = Object.create(null);
  25949. this.promisesByRequest = Object.create(null);
  25950. this.progressiveDataLength = 0;
  25951. this.aborted = false;
  25952. this._loadedStreamCapability = createPromiseCapability();
  25953. }
  25954. ChunkedStreamManager.prototype = {
  25955. onLoadedStream: function ChunkedStreamManager_getLoadedStream() {
  25956. return this._loadedStreamCapability.promise;
  25957. },
  25958. sendRequest: function ChunkedStreamManager_sendRequest(begin, end) {
  25959. var rangeReader = this.pdfNetworkStream.getRangeReader(begin, end);
  25960. if (!rangeReader.isStreamingSupported) {
  25961. rangeReader.onProgress = this.onProgress.bind(this);
  25962. }
  25963. var chunks = [], loaded = 0;
  25964. var manager = this;
  25965. var promise = new Promise(function (resolve, reject) {
  25966. var readChunk = function (chunk) {
  25967. try {
  25968. if (!chunk.done) {
  25969. var data = chunk.value;
  25970. chunks.push(data);
  25971. loaded += arrayByteLength(data);
  25972. if (rangeReader.isStreamingSupported) {
  25973. manager.onProgress({ loaded: loaded });
  25974. }
  25975. rangeReader.read().then(readChunk, reject);
  25976. return;
  25977. }
  25978. var chunkData = arraysToBytes(chunks);
  25979. chunks = null;
  25980. resolve(chunkData);
  25981. } catch (e) {
  25982. reject(e);
  25983. }
  25984. };
  25985. rangeReader.read().then(readChunk, reject);
  25986. });
  25987. promise.then(function (data) {
  25988. if (this.aborted) {
  25989. return;
  25990. }
  25991. this.onReceiveData({
  25992. chunk: data,
  25993. begin: begin
  25994. });
  25995. }.bind(this));
  25996. },
  25997. requestAllChunks: function ChunkedStreamManager_requestAllChunks() {
  25998. var missingChunks = this.stream.getMissingChunks();
  25999. this._requestChunks(missingChunks);
  26000. return this._loadedStreamCapability.promise;
  26001. },
  26002. _requestChunks: function ChunkedStreamManager_requestChunks(chunks) {
  26003. var requestId = this.currRequestId++;
  26004. var i, ii;
  26005. var chunksNeeded = Object.create(null);
  26006. this.chunksNeededByRequest[requestId] = chunksNeeded;
  26007. for (i = 0, ii = chunks.length; i < ii; i++) {
  26008. if (!this.stream.hasChunk(chunks[i])) {
  26009. chunksNeeded[chunks[i]] = true;
  26010. }
  26011. }
  26012. if (isEmptyObj(chunksNeeded)) {
  26013. return Promise.resolve();
  26014. }
  26015. var capability = createPromiseCapability();
  26016. this.promisesByRequest[requestId] = capability;
  26017. var chunksToRequest = [];
  26018. for (var chunk in chunksNeeded) {
  26019. chunk = chunk | 0;
  26020. if (!(chunk in this.requestsByChunk)) {
  26021. this.requestsByChunk[chunk] = [];
  26022. chunksToRequest.push(chunk);
  26023. }
  26024. this.requestsByChunk[chunk].push(requestId);
  26025. }
  26026. if (!chunksToRequest.length) {
  26027. return capability.promise;
  26028. }
  26029. var groupedChunksToRequest = this.groupChunks(chunksToRequest);
  26030. for (i = 0; i < groupedChunksToRequest.length; ++i) {
  26031. var groupedChunk = groupedChunksToRequest[i];
  26032. var begin = groupedChunk.beginChunk * this.chunkSize;
  26033. var end = Math.min(groupedChunk.endChunk * this.chunkSize, this.length);
  26034. this.sendRequest(begin, end);
  26035. }
  26036. return capability.promise;
  26037. },
  26038. getStream: function ChunkedStreamManager_getStream() {
  26039. return this.stream;
  26040. },
  26041. requestRange: function ChunkedStreamManager_requestRange(begin, end) {
  26042. end = Math.min(end, this.length);
  26043. var beginChunk = this.getBeginChunk(begin);
  26044. var endChunk = this.getEndChunk(end);
  26045. var chunks = [];
  26046. for (var chunk = beginChunk; chunk < endChunk; ++chunk) {
  26047. chunks.push(chunk);
  26048. }
  26049. return this._requestChunks(chunks);
  26050. },
  26051. requestRanges: function ChunkedStreamManager_requestRanges(ranges) {
  26052. ranges = ranges || [];
  26053. var chunksToRequest = [];
  26054. for (var i = 0; i < ranges.length; i++) {
  26055. var beginChunk = this.getBeginChunk(ranges[i].begin);
  26056. var endChunk = this.getEndChunk(ranges[i].end);
  26057. for (var chunk = beginChunk; chunk < endChunk; ++chunk) {
  26058. if (chunksToRequest.indexOf(chunk) < 0) {
  26059. chunksToRequest.push(chunk);
  26060. }
  26061. }
  26062. }
  26063. chunksToRequest.sort(function (a, b) {
  26064. return a - b;
  26065. });
  26066. return this._requestChunks(chunksToRequest);
  26067. },
  26068. groupChunks: function ChunkedStreamManager_groupChunks(chunks) {
  26069. var groupedChunks = [];
  26070. var beginChunk = -1;
  26071. var prevChunk = -1;
  26072. for (var i = 0; i < chunks.length; ++i) {
  26073. var chunk = chunks[i];
  26074. if (beginChunk < 0) {
  26075. beginChunk = chunk;
  26076. }
  26077. if (prevChunk >= 0 && prevChunk + 1 !== chunk) {
  26078. groupedChunks.push({
  26079. beginChunk: beginChunk,
  26080. endChunk: prevChunk + 1
  26081. });
  26082. beginChunk = chunk;
  26083. }
  26084. if (i + 1 === chunks.length) {
  26085. groupedChunks.push({
  26086. beginChunk: beginChunk,
  26087. endChunk: chunk + 1
  26088. });
  26089. }
  26090. prevChunk = chunk;
  26091. }
  26092. return groupedChunks;
  26093. },
  26094. onProgress: function ChunkedStreamManager_onProgress(args) {
  26095. var bytesLoaded = this.stream.numChunksLoaded * this.chunkSize + args.loaded;
  26096. this.msgHandler.send('DocProgress', {
  26097. loaded: bytesLoaded,
  26098. total: this.length
  26099. });
  26100. },
  26101. onReceiveData: function ChunkedStreamManager_onReceiveData(args) {
  26102. var chunk = args.chunk;
  26103. var isProgressive = args.begin === undefined;
  26104. var begin = isProgressive ? this.progressiveDataLength : args.begin;
  26105. var end = begin + chunk.byteLength;
  26106. var beginChunk = Math.floor(begin / this.chunkSize);
  26107. var endChunk = end < this.length ? Math.floor(end / this.chunkSize) : Math.ceil(end / this.chunkSize);
  26108. if (isProgressive) {
  26109. this.stream.onReceiveProgressiveData(chunk);
  26110. this.progressiveDataLength = end;
  26111. } else {
  26112. this.stream.onReceiveData(begin, chunk);
  26113. }
  26114. if (this.stream.allChunksLoaded()) {
  26115. this._loadedStreamCapability.resolve(this.stream);
  26116. }
  26117. var loadedRequests = [];
  26118. var i, requestId;
  26119. for (chunk = beginChunk; chunk < endChunk; ++chunk) {
  26120. var requestIds = this.requestsByChunk[chunk] || [];
  26121. delete this.requestsByChunk[chunk];
  26122. for (i = 0; i < requestIds.length; ++i) {
  26123. requestId = requestIds[i];
  26124. var chunksNeeded = this.chunksNeededByRequest[requestId];
  26125. if (chunk in chunksNeeded) {
  26126. delete chunksNeeded[chunk];
  26127. }
  26128. if (!isEmptyObj(chunksNeeded)) {
  26129. continue;
  26130. }
  26131. loadedRequests.push(requestId);
  26132. }
  26133. }
  26134. if (!this.disableAutoFetch && isEmptyObj(this.requestsByChunk)) {
  26135. var nextEmptyChunk;
  26136. if (this.stream.numChunksLoaded === 1) {
  26137. var lastChunk = this.stream.numChunks - 1;
  26138. if (!this.stream.hasChunk(lastChunk)) {
  26139. nextEmptyChunk = lastChunk;
  26140. }
  26141. } else {
  26142. nextEmptyChunk = this.stream.nextEmptyChunk(endChunk);
  26143. }
  26144. if (isInt(nextEmptyChunk)) {
  26145. this._requestChunks([nextEmptyChunk]);
  26146. }
  26147. }
  26148. for (i = 0; i < loadedRequests.length; ++i) {
  26149. requestId = loadedRequests[i];
  26150. var capability = this.promisesByRequest[requestId];
  26151. delete this.promisesByRequest[requestId];
  26152. capability.resolve();
  26153. }
  26154. this.msgHandler.send('DocProgress', {
  26155. loaded: this.stream.numChunksLoaded * this.chunkSize,
  26156. total: this.length
  26157. });
  26158. },
  26159. onError: function ChunkedStreamManager_onError(err) {
  26160. this._loadedStreamCapability.reject(err);
  26161. },
  26162. getBeginChunk: function ChunkedStreamManager_getBeginChunk(begin) {
  26163. var chunk = Math.floor(begin / this.chunkSize);
  26164. return chunk;
  26165. },
  26166. getEndChunk: function ChunkedStreamManager_getEndChunk(end) {
  26167. var chunk = Math.floor((end - 1) / this.chunkSize) + 1;
  26168. return chunk;
  26169. },
  26170. abort: function ChunkedStreamManager_abort() {
  26171. this.aborted = true;
  26172. if (this.pdfNetworkStream) {
  26173. this.pdfNetworkStream.cancelAllRequests('abort');
  26174. }
  26175. for (var requestId in this.promisesByRequest) {
  26176. var capability = this.promisesByRequest[requestId];
  26177. capability.reject(new Error('Request was aborted'));
  26178. }
  26179. }
  26180. };
  26181. return ChunkedStreamManager;
  26182. }();
  26183. exports.ChunkedStream = ChunkedStream;
  26184. exports.ChunkedStreamManager = ChunkedStreamManager;
  26185. /***/ }),
  26186. /* 17 */
  26187. /***/ (function(module, exports, __w_pdfjs_require__) {
  26188. "use strict";
  26189. var sharedUtil = __w_pdfjs_require__(0);
  26190. var corePrimitives = __w_pdfjs_require__(1);
  26191. var coreStream = __w_pdfjs_require__(2);
  26192. var PasswordException = sharedUtil.PasswordException;
  26193. var PasswordResponses = sharedUtil.PasswordResponses;
  26194. var bytesToString = sharedUtil.bytesToString;
  26195. var warn = sharedUtil.warn;
  26196. var error = sharedUtil.error;
  26197. var assert = sharedUtil.assert;
  26198. var isInt = sharedUtil.isInt;
  26199. var stringToBytes = sharedUtil.stringToBytes;
  26200. var utf8StringToString = sharedUtil.utf8StringToString;
  26201. var Name = corePrimitives.Name;
  26202. var isName = corePrimitives.isName;
  26203. var isDict = corePrimitives.isDict;
  26204. var DecryptStream = coreStream.DecryptStream;
  26205. var ARCFourCipher = function ARCFourCipherClosure() {
  26206. function ARCFourCipher(key) {
  26207. this.a = 0;
  26208. this.b = 0;
  26209. var s = new Uint8Array(256);
  26210. var i, j = 0, tmp, keyLength = key.length;
  26211. for (i = 0; i < 256; ++i) {
  26212. s[i] = i;
  26213. }
  26214. for (i = 0; i < 256; ++i) {
  26215. tmp = s[i];
  26216. j = j + tmp + key[i % keyLength] & 0xFF;
  26217. s[i] = s[j];
  26218. s[j] = tmp;
  26219. }
  26220. this.s = s;
  26221. }
  26222. ARCFourCipher.prototype = {
  26223. encryptBlock: function ARCFourCipher_encryptBlock(data) {
  26224. var i, n = data.length, tmp, tmp2;
  26225. var a = this.a, b = this.b, s = this.s;
  26226. var output = new Uint8Array(n);
  26227. for (i = 0; i < n; ++i) {
  26228. a = a + 1 & 0xFF;
  26229. tmp = s[a];
  26230. b = b + tmp & 0xFF;
  26231. tmp2 = s[b];
  26232. s[a] = tmp2;
  26233. s[b] = tmp;
  26234. output[i] = data[i] ^ s[tmp + tmp2 & 0xFF];
  26235. }
  26236. this.a = a;
  26237. this.b = b;
  26238. return output;
  26239. }
  26240. };
  26241. ARCFourCipher.prototype.decryptBlock = ARCFourCipher.prototype.encryptBlock;
  26242. return ARCFourCipher;
  26243. }();
  26244. var calculateMD5 = function calculateMD5Closure() {
  26245. var r = new Uint8Array([
  26246. 7,
  26247. 12,
  26248. 17,
  26249. 22,
  26250. 7,
  26251. 12,
  26252. 17,
  26253. 22,
  26254. 7,
  26255. 12,
  26256. 17,
  26257. 22,
  26258. 7,
  26259. 12,
  26260. 17,
  26261. 22,
  26262. 5,
  26263. 9,
  26264. 14,
  26265. 20,
  26266. 5,
  26267. 9,
  26268. 14,
  26269. 20,
  26270. 5,
  26271. 9,
  26272. 14,
  26273. 20,
  26274. 5,
  26275. 9,
  26276. 14,
  26277. 20,
  26278. 4,
  26279. 11,
  26280. 16,
  26281. 23,
  26282. 4,
  26283. 11,
  26284. 16,
  26285. 23,
  26286. 4,
  26287. 11,
  26288. 16,
  26289. 23,
  26290. 4,
  26291. 11,
  26292. 16,
  26293. 23,
  26294. 6,
  26295. 10,
  26296. 15,
  26297. 21,
  26298. 6,
  26299. 10,
  26300. 15,
  26301. 21,
  26302. 6,
  26303. 10,
  26304. 15,
  26305. 21,
  26306. 6,
  26307. 10,
  26308. 15,
  26309. 21
  26310. ]);
  26311. var k = new Int32Array([
  26312. -680876936,
  26313. -389564586,
  26314. 606105819,
  26315. -1044525330,
  26316. -176418897,
  26317. 1200080426,
  26318. -1473231341,
  26319. -45705983,
  26320. 1770035416,
  26321. -1958414417,
  26322. -42063,
  26323. -1990404162,
  26324. 1804603682,
  26325. -40341101,
  26326. -1502002290,
  26327. 1236535329,
  26328. -165796510,
  26329. -1069501632,
  26330. 643717713,
  26331. -373897302,
  26332. -701558691,
  26333. 38016083,
  26334. -660478335,
  26335. -405537848,
  26336. 568446438,
  26337. -1019803690,
  26338. -187363961,
  26339. 1163531501,
  26340. -1444681467,
  26341. -51403784,
  26342. 1735328473,
  26343. -1926607734,
  26344. -378558,
  26345. -2022574463,
  26346. 1839030562,
  26347. -35309556,
  26348. -1530992060,
  26349. 1272893353,
  26350. -155497632,
  26351. -1094730640,
  26352. 681279174,
  26353. -358537222,
  26354. -722521979,
  26355. 76029189,
  26356. -640364487,
  26357. -421815835,
  26358. 530742520,
  26359. -995338651,
  26360. -198630844,
  26361. 1126891415,
  26362. -1416354905,
  26363. -57434055,
  26364. 1700485571,
  26365. -1894986606,
  26366. -1051523,
  26367. -2054922799,
  26368. 1873313359,
  26369. -30611744,
  26370. -1560198380,
  26371. 1309151649,
  26372. -145523070,
  26373. -1120210379,
  26374. 718787259,
  26375. -343485551
  26376. ]);
  26377. function hash(data, offset, length) {
  26378. var h0 = 1732584193, h1 = -271733879, h2 = -1732584194, h3 = 271733878;
  26379. var paddedLength = length + 72 & ~63;
  26380. var padded = new Uint8Array(paddedLength);
  26381. var i, j, n;
  26382. for (i = 0; i < length; ++i) {
  26383. padded[i] = data[offset++];
  26384. }
  26385. padded[i++] = 0x80;
  26386. n = paddedLength - 8;
  26387. while (i < n) {
  26388. padded[i++] = 0;
  26389. }
  26390. padded[i++] = length << 3 & 0xFF;
  26391. padded[i++] = length >> 5 & 0xFF;
  26392. padded[i++] = length >> 13 & 0xFF;
  26393. padded[i++] = length >> 21 & 0xFF;
  26394. padded[i++] = length >>> 29 & 0xFF;
  26395. padded[i++] = 0;
  26396. padded[i++] = 0;
  26397. padded[i++] = 0;
  26398. var w = new Int32Array(16);
  26399. for (i = 0; i < paddedLength;) {
  26400. for (j = 0; j < 16; ++j, i += 4) {
  26401. w[j] = padded[i] | padded[i + 1] << 8 | padded[i + 2] << 16 | padded[i + 3] << 24;
  26402. }
  26403. var a = h0, b = h1, c = h2, d = h3, f, g;
  26404. for (j = 0; j < 64; ++j) {
  26405. if (j < 16) {
  26406. f = b & c | ~b & d;
  26407. g = j;
  26408. } else if (j < 32) {
  26409. f = d & b | ~d & c;
  26410. g = 5 * j + 1 & 15;
  26411. } else if (j < 48) {
  26412. f = b ^ c ^ d;
  26413. g = 3 * j + 5 & 15;
  26414. } else {
  26415. f = c ^ (b | ~d);
  26416. g = 7 * j & 15;
  26417. }
  26418. var tmp = d, rotateArg = a + f + k[j] + w[g] | 0, rotate = r[j];
  26419. d = c;
  26420. c = b;
  26421. b = b + (rotateArg << rotate | rotateArg >>> 32 - rotate) | 0;
  26422. a = tmp;
  26423. }
  26424. h0 = h0 + a | 0;
  26425. h1 = h1 + b | 0;
  26426. h2 = h2 + c | 0;
  26427. h3 = h3 + d | 0;
  26428. }
  26429. return new Uint8Array([
  26430. h0 & 0xFF,
  26431. h0 >> 8 & 0xFF,
  26432. h0 >> 16 & 0xFF,
  26433. h0 >>> 24 & 0xFF,
  26434. h1 & 0xFF,
  26435. h1 >> 8 & 0xFF,
  26436. h1 >> 16 & 0xFF,
  26437. h1 >>> 24 & 0xFF,
  26438. h2 & 0xFF,
  26439. h2 >> 8 & 0xFF,
  26440. h2 >> 16 & 0xFF,
  26441. h2 >>> 24 & 0xFF,
  26442. h3 & 0xFF,
  26443. h3 >> 8 & 0xFF,
  26444. h3 >> 16 & 0xFF,
  26445. h3 >>> 24 & 0xFF
  26446. ]);
  26447. }
  26448. return hash;
  26449. }();
  26450. var Word64 = function Word64Closure() {
  26451. function Word64(highInteger, lowInteger) {
  26452. this.high = highInteger | 0;
  26453. this.low = lowInteger | 0;
  26454. }
  26455. Word64.prototype = {
  26456. and: function Word64_and(word) {
  26457. this.high &= word.high;
  26458. this.low &= word.low;
  26459. },
  26460. xor: function Word64_xor(word) {
  26461. this.high ^= word.high;
  26462. this.low ^= word.low;
  26463. },
  26464. or: function Word64_or(word) {
  26465. this.high |= word.high;
  26466. this.low |= word.low;
  26467. },
  26468. shiftRight: function Word64_shiftRight(places) {
  26469. if (places >= 32) {
  26470. this.low = this.high >>> places - 32 | 0;
  26471. this.high = 0;
  26472. } else {
  26473. this.low = this.low >>> places | this.high << 32 - places;
  26474. this.high = this.high >>> places | 0;
  26475. }
  26476. },
  26477. shiftLeft: function Word64_shiftLeft(places) {
  26478. if (places >= 32) {
  26479. this.high = this.low << places - 32;
  26480. this.low = 0;
  26481. } else {
  26482. this.high = this.high << places | this.low >>> 32 - places;
  26483. this.low = this.low << places;
  26484. }
  26485. },
  26486. rotateRight: function Word64_rotateRight(places) {
  26487. var low, high;
  26488. if (places & 32) {
  26489. high = this.low;
  26490. low = this.high;
  26491. } else {
  26492. low = this.low;
  26493. high = this.high;
  26494. }
  26495. places &= 31;
  26496. this.low = low >>> places | high << 32 - places;
  26497. this.high = high >>> places | low << 32 - places;
  26498. },
  26499. not: function Word64_not() {
  26500. this.high = ~this.high;
  26501. this.low = ~this.low;
  26502. },
  26503. add: function Word64_add(word) {
  26504. var lowAdd = (this.low >>> 0) + (word.low >>> 0);
  26505. var highAdd = (this.high >>> 0) + (word.high >>> 0);
  26506. if (lowAdd > 0xFFFFFFFF) {
  26507. highAdd += 1;
  26508. }
  26509. this.low = lowAdd | 0;
  26510. this.high = highAdd | 0;
  26511. },
  26512. copyTo: function Word64_copyTo(bytes, offset) {
  26513. bytes[offset] = this.high >>> 24 & 0xFF;
  26514. bytes[offset + 1] = this.high >> 16 & 0xFF;
  26515. bytes[offset + 2] = this.high >> 8 & 0xFF;
  26516. bytes[offset + 3] = this.high & 0xFF;
  26517. bytes[offset + 4] = this.low >>> 24 & 0xFF;
  26518. bytes[offset + 5] = this.low >> 16 & 0xFF;
  26519. bytes[offset + 6] = this.low >> 8 & 0xFF;
  26520. bytes[offset + 7] = this.low & 0xFF;
  26521. },
  26522. assign: function Word64_assign(word) {
  26523. this.high = word.high;
  26524. this.low = word.low;
  26525. }
  26526. };
  26527. return Word64;
  26528. }();
  26529. var calculateSHA256 = function calculateSHA256Closure() {
  26530. function rotr(x, n) {
  26531. return x >>> n | x << 32 - n;
  26532. }
  26533. function ch(x, y, z) {
  26534. return x & y ^ ~x & z;
  26535. }
  26536. function maj(x, y, z) {
  26537. return x & y ^ x & z ^ y & z;
  26538. }
  26539. function sigma(x) {
  26540. return rotr(x, 2) ^ rotr(x, 13) ^ rotr(x, 22);
  26541. }
  26542. function sigmaPrime(x) {
  26543. return rotr(x, 6) ^ rotr(x, 11) ^ rotr(x, 25);
  26544. }
  26545. function littleSigma(x) {
  26546. return rotr(x, 7) ^ rotr(x, 18) ^ x >>> 3;
  26547. }
  26548. function littleSigmaPrime(x) {
  26549. return rotr(x, 17) ^ rotr(x, 19) ^ x >>> 10;
  26550. }
  26551. var k = [
  26552. 0x428a2f98,
  26553. 0x71374491,
  26554. 0xb5c0fbcf,
  26555. 0xe9b5dba5,
  26556. 0x3956c25b,
  26557. 0x59f111f1,
  26558. 0x923f82a4,
  26559. 0xab1c5ed5,
  26560. 0xd807aa98,
  26561. 0x12835b01,
  26562. 0x243185be,
  26563. 0x550c7dc3,
  26564. 0x72be5d74,
  26565. 0x80deb1fe,
  26566. 0x9bdc06a7,
  26567. 0xc19bf174,
  26568. 0xe49b69c1,
  26569. 0xefbe4786,
  26570. 0x0fc19dc6,
  26571. 0x240ca1cc,
  26572. 0x2de92c6f,
  26573. 0x4a7484aa,
  26574. 0x5cb0a9dc,
  26575. 0x76f988da,
  26576. 0x983e5152,
  26577. 0xa831c66d,
  26578. 0xb00327c8,
  26579. 0xbf597fc7,
  26580. 0xc6e00bf3,
  26581. 0xd5a79147,
  26582. 0x06ca6351,
  26583. 0x14292967,
  26584. 0x27b70a85,
  26585. 0x2e1b2138,
  26586. 0x4d2c6dfc,
  26587. 0x53380d13,
  26588. 0x650a7354,
  26589. 0x766a0abb,
  26590. 0x81c2c92e,
  26591. 0x92722c85,
  26592. 0xa2bfe8a1,
  26593. 0xa81a664b,
  26594. 0xc24b8b70,
  26595. 0xc76c51a3,
  26596. 0xd192e819,
  26597. 0xd6990624,
  26598. 0xf40e3585,
  26599. 0x106aa070,
  26600. 0x19a4c116,
  26601. 0x1e376c08,
  26602. 0x2748774c,
  26603. 0x34b0bcb5,
  26604. 0x391c0cb3,
  26605. 0x4ed8aa4a,
  26606. 0x5b9cca4f,
  26607. 0x682e6ff3,
  26608. 0x748f82ee,
  26609. 0x78a5636f,
  26610. 0x84c87814,
  26611. 0x8cc70208,
  26612. 0x90befffa,
  26613. 0xa4506ceb,
  26614. 0xbef9a3f7,
  26615. 0xc67178f2
  26616. ];
  26617. function hash(data, offset, length) {
  26618. var h0 = 0x6a09e667, h1 = 0xbb67ae85, h2 = 0x3c6ef372, h3 = 0xa54ff53a, h4 = 0x510e527f, h5 = 0x9b05688c, h6 = 0x1f83d9ab, h7 = 0x5be0cd19;
  26619. var paddedLength = Math.ceil((length + 9) / 64) * 64;
  26620. var padded = new Uint8Array(paddedLength);
  26621. var i, j, n;
  26622. for (i = 0; i < length; ++i) {
  26623. padded[i] = data[offset++];
  26624. }
  26625. padded[i++] = 0x80;
  26626. n = paddedLength - 8;
  26627. while (i < n) {
  26628. padded[i++] = 0;
  26629. }
  26630. padded[i++] = 0;
  26631. padded[i++] = 0;
  26632. padded[i++] = 0;
  26633. padded[i++] = length >>> 29 & 0xFF;
  26634. padded[i++] = length >> 21 & 0xFF;
  26635. padded[i++] = length >> 13 & 0xFF;
  26636. padded[i++] = length >> 5 & 0xFF;
  26637. padded[i++] = length << 3 & 0xFF;
  26638. var w = new Uint32Array(64);
  26639. for (i = 0; i < paddedLength;) {
  26640. for (j = 0; j < 16; ++j) {
  26641. w[j] = padded[i] << 24 | padded[i + 1] << 16 | padded[i + 2] << 8 | padded[i + 3];
  26642. i += 4;
  26643. }
  26644. for (j = 16; j < 64; ++j) {
  26645. w[j] = littleSigmaPrime(w[j - 2]) + w[j - 7] + littleSigma(w[j - 15]) + w[j - 16] | 0;
  26646. }
  26647. var a = h0, b = h1, c = h2, d = h3, e = h4, f = h5, g = h6, h = h7, t1, t2;
  26648. for (j = 0; j < 64; ++j) {
  26649. t1 = h + sigmaPrime(e) + ch(e, f, g) + k[j] + w[j];
  26650. t2 = sigma(a) + maj(a, b, c);
  26651. h = g;
  26652. g = f;
  26653. f = e;
  26654. e = d + t1 | 0;
  26655. d = c;
  26656. c = b;
  26657. b = a;
  26658. a = t1 + t2 | 0;
  26659. }
  26660. h0 = h0 + a | 0;
  26661. h1 = h1 + b | 0;
  26662. h2 = h2 + c | 0;
  26663. h3 = h3 + d | 0;
  26664. h4 = h4 + e | 0;
  26665. h5 = h5 + f | 0;
  26666. h6 = h6 + g | 0;
  26667. h7 = h7 + h | 0;
  26668. }
  26669. return new Uint8Array([
  26670. h0 >> 24 & 0xFF,
  26671. h0 >> 16 & 0xFF,
  26672. h0 >> 8 & 0xFF,
  26673. h0 & 0xFF,
  26674. h1 >> 24 & 0xFF,
  26675. h1 >> 16 & 0xFF,
  26676. h1 >> 8 & 0xFF,
  26677. h1 & 0xFF,
  26678. h2 >> 24 & 0xFF,
  26679. h2 >> 16 & 0xFF,
  26680. h2 >> 8 & 0xFF,
  26681. h2 & 0xFF,
  26682. h3 >> 24 & 0xFF,
  26683. h3 >> 16 & 0xFF,
  26684. h3 >> 8 & 0xFF,
  26685. h3 & 0xFF,
  26686. h4 >> 24 & 0xFF,
  26687. h4 >> 16 & 0xFF,
  26688. h4 >> 8 & 0xFF,
  26689. h4 & 0xFF,
  26690. h5 >> 24 & 0xFF,
  26691. h5 >> 16 & 0xFF,
  26692. h5 >> 8 & 0xFF,
  26693. h5 & 0xFF,
  26694. h6 >> 24 & 0xFF,
  26695. h6 >> 16 & 0xFF,
  26696. h6 >> 8 & 0xFF,
  26697. h6 & 0xFF,
  26698. h7 >> 24 & 0xFF,
  26699. h7 >> 16 & 0xFF,
  26700. h7 >> 8 & 0xFF,
  26701. h7 & 0xFF
  26702. ]);
  26703. }
  26704. return hash;
  26705. }();
  26706. var calculateSHA512 = function calculateSHA512Closure() {
  26707. function ch(result, x, y, z, tmp) {
  26708. result.assign(x);
  26709. result.and(y);
  26710. tmp.assign(x);
  26711. tmp.not();
  26712. tmp.and(z);
  26713. result.xor(tmp);
  26714. }
  26715. function maj(result, x, y, z, tmp) {
  26716. result.assign(x);
  26717. result.and(y);
  26718. tmp.assign(x);
  26719. tmp.and(z);
  26720. result.xor(tmp);
  26721. tmp.assign(y);
  26722. tmp.and(z);
  26723. result.xor(tmp);
  26724. }
  26725. function sigma(result, x, tmp) {
  26726. result.assign(x);
  26727. result.rotateRight(28);
  26728. tmp.assign(x);
  26729. tmp.rotateRight(34);
  26730. result.xor(tmp);
  26731. tmp.assign(x);
  26732. tmp.rotateRight(39);
  26733. result.xor(tmp);
  26734. }
  26735. function sigmaPrime(result, x, tmp) {
  26736. result.assign(x);
  26737. result.rotateRight(14);
  26738. tmp.assign(x);
  26739. tmp.rotateRight(18);
  26740. result.xor(tmp);
  26741. tmp.assign(x);
  26742. tmp.rotateRight(41);
  26743. result.xor(tmp);
  26744. }
  26745. function littleSigma(result, x, tmp) {
  26746. result.assign(x);
  26747. result.rotateRight(1);
  26748. tmp.assign(x);
  26749. tmp.rotateRight(8);
  26750. result.xor(tmp);
  26751. tmp.assign(x);
  26752. tmp.shiftRight(7);
  26753. result.xor(tmp);
  26754. }
  26755. function littleSigmaPrime(result, x, tmp) {
  26756. result.assign(x);
  26757. result.rotateRight(19);
  26758. tmp.assign(x);
  26759. tmp.rotateRight(61);
  26760. result.xor(tmp);
  26761. tmp.assign(x);
  26762. tmp.shiftRight(6);
  26763. result.xor(tmp);
  26764. }
  26765. var k = [
  26766. new Word64(0x428a2f98, 0xd728ae22),
  26767. new Word64(0x71374491, 0x23ef65cd),
  26768. new Word64(0xb5c0fbcf, 0xec4d3b2f),
  26769. new Word64(0xe9b5dba5, 0x8189dbbc),
  26770. new Word64(0x3956c25b, 0xf348b538),
  26771. new Word64(0x59f111f1, 0xb605d019),
  26772. new Word64(0x923f82a4, 0xaf194f9b),
  26773. new Word64(0xab1c5ed5, 0xda6d8118),
  26774. new Word64(0xd807aa98, 0xa3030242),
  26775. new Word64(0x12835b01, 0x45706fbe),
  26776. new Word64(0x243185be, 0x4ee4b28c),
  26777. new Word64(0x550c7dc3, 0xd5ffb4e2),
  26778. new Word64(0x72be5d74, 0xf27b896f),
  26779. new Word64(0x80deb1fe, 0x3b1696b1),
  26780. new Word64(0x9bdc06a7, 0x25c71235),
  26781. new Word64(0xc19bf174, 0xcf692694),
  26782. new Word64(0xe49b69c1, 0x9ef14ad2),
  26783. new Word64(0xefbe4786, 0x384f25e3),
  26784. new Word64(0x0fc19dc6, 0x8b8cd5b5),
  26785. new Word64(0x240ca1cc, 0x77ac9c65),
  26786. new Word64(0x2de92c6f, 0x592b0275),
  26787. new Word64(0x4a7484aa, 0x6ea6e483),
  26788. new Word64(0x5cb0a9dc, 0xbd41fbd4),
  26789. new Word64(0x76f988da, 0x831153b5),
  26790. new Word64(0x983e5152, 0xee66dfab),
  26791. new Word64(0xa831c66d, 0x2db43210),
  26792. new Word64(0xb00327c8, 0x98fb213f),
  26793. new Word64(0xbf597fc7, 0xbeef0ee4),
  26794. new Word64(0xc6e00bf3, 0x3da88fc2),
  26795. new Word64(0xd5a79147, 0x930aa725),
  26796. new Word64(0x06ca6351, 0xe003826f),
  26797. new Word64(0x14292967, 0x0a0e6e70),
  26798. new Word64(0x27b70a85, 0x46d22ffc),
  26799. new Word64(0x2e1b2138, 0x5c26c926),
  26800. new Word64(0x4d2c6dfc, 0x5ac42aed),
  26801. new Word64(0x53380d13, 0x9d95b3df),
  26802. new Word64(0x650a7354, 0x8baf63de),
  26803. new Word64(0x766a0abb, 0x3c77b2a8),
  26804. new Word64(0x81c2c92e, 0x47edaee6),
  26805. new Word64(0x92722c85, 0x1482353b),
  26806. new Word64(0xa2bfe8a1, 0x4cf10364),
  26807. new Word64(0xa81a664b, 0xbc423001),
  26808. new Word64(0xc24b8b70, 0xd0f89791),
  26809. new Word64(0xc76c51a3, 0x0654be30),
  26810. new Word64(0xd192e819, 0xd6ef5218),
  26811. new Word64(0xd6990624, 0x5565a910),
  26812. new Word64(0xf40e3585, 0x5771202a),
  26813. new Word64(0x106aa070, 0x32bbd1b8),
  26814. new Word64(0x19a4c116, 0xb8d2d0c8),
  26815. new Word64(0x1e376c08, 0x5141ab53),
  26816. new Word64(0x2748774c, 0xdf8eeb99),
  26817. new Word64(0x34b0bcb5, 0xe19b48a8),
  26818. new Word64(0x391c0cb3, 0xc5c95a63),
  26819. new Word64(0x4ed8aa4a, 0xe3418acb),
  26820. new Word64(0x5b9cca4f, 0x7763e373),
  26821. new Word64(0x682e6ff3, 0xd6b2b8a3),
  26822. new Word64(0x748f82ee, 0x5defb2fc),
  26823. new Word64(0x78a5636f, 0x43172f60),
  26824. new Word64(0x84c87814, 0xa1f0ab72),
  26825. new Word64(0x8cc70208, 0x1a6439ec),
  26826. new Word64(0x90befffa, 0x23631e28),
  26827. new Word64(0xa4506ceb, 0xde82bde9),
  26828. new Word64(0xbef9a3f7, 0xb2c67915),
  26829. new Word64(0xc67178f2, 0xe372532b),
  26830. new Word64(0xca273ece, 0xea26619c),
  26831. new Word64(0xd186b8c7, 0x21c0c207),
  26832. new Word64(0xeada7dd6, 0xcde0eb1e),
  26833. new Word64(0xf57d4f7f, 0xee6ed178),
  26834. new Word64(0x06f067aa, 0x72176fba),
  26835. new Word64(0x0a637dc5, 0xa2c898a6),
  26836. new Word64(0x113f9804, 0xbef90dae),
  26837. new Word64(0x1b710b35, 0x131c471b),
  26838. new Word64(0x28db77f5, 0x23047d84),
  26839. new Word64(0x32caab7b, 0x40c72493),
  26840. new Word64(0x3c9ebe0a, 0x15c9bebc),
  26841. new Word64(0x431d67c4, 0x9c100d4c),
  26842. new Word64(0x4cc5d4be, 0xcb3e42b6),
  26843. new Word64(0x597f299c, 0xfc657e2a),
  26844. new Word64(0x5fcb6fab, 0x3ad6faec),
  26845. new Word64(0x6c44198c, 0x4a475817)
  26846. ];
  26847. function hash(data, offset, length, mode384) {
  26848. mode384 = !!mode384;
  26849. var h0, h1, h2, h3, h4, h5, h6, h7;
  26850. if (!mode384) {
  26851. h0 = new Word64(0x6a09e667, 0xf3bcc908);
  26852. h1 = new Word64(0xbb67ae85, 0x84caa73b);
  26853. h2 = new Word64(0x3c6ef372, 0xfe94f82b);
  26854. h3 = new Word64(0xa54ff53a, 0x5f1d36f1);
  26855. h4 = new Word64(0x510e527f, 0xade682d1);
  26856. h5 = new Word64(0x9b05688c, 0x2b3e6c1f);
  26857. h6 = new Word64(0x1f83d9ab, 0xfb41bd6b);
  26858. h7 = new Word64(0x5be0cd19, 0x137e2179);
  26859. } else {
  26860. h0 = new Word64(0xcbbb9d5d, 0xc1059ed8);
  26861. h1 = new Word64(0x629a292a, 0x367cd507);
  26862. h2 = new Word64(0x9159015a, 0x3070dd17);
  26863. h3 = new Word64(0x152fecd8, 0xf70e5939);
  26864. h4 = new Word64(0x67332667, 0xffc00b31);
  26865. h5 = new Word64(0x8eb44a87, 0x68581511);
  26866. h6 = new Word64(0xdb0c2e0d, 0x64f98fa7);
  26867. h7 = new Word64(0x47b5481d, 0xbefa4fa4);
  26868. }
  26869. var paddedLength = Math.ceil((length + 17) / 128) * 128;
  26870. var padded = new Uint8Array(paddedLength);
  26871. var i, j, n;
  26872. for (i = 0; i < length; ++i) {
  26873. padded[i] = data[offset++];
  26874. }
  26875. padded[i++] = 0x80;
  26876. n = paddedLength - 16;
  26877. while (i < n) {
  26878. padded[i++] = 0;
  26879. }
  26880. padded[i++] = 0;
  26881. padded[i++] = 0;
  26882. padded[i++] = 0;
  26883. padded[i++] = 0;
  26884. padded[i++] = 0;
  26885. padded[i++] = 0;
  26886. padded[i++] = 0;
  26887. padded[i++] = 0;
  26888. padded[i++] = 0;
  26889. padded[i++] = 0;
  26890. padded[i++] = 0;
  26891. padded[i++] = length >>> 29 & 0xFF;
  26892. padded[i++] = length >> 21 & 0xFF;
  26893. padded[i++] = length >> 13 & 0xFF;
  26894. padded[i++] = length >> 5 & 0xFF;
  26895. padded[i++] = length << 3 & 0xFF;
  26896. var w = new Array(80);
  26897. for (i = 0; i < 80; i++) {
  26898. w[i] = new Word64(0, 0);
  26899. }
  26900. var a = new Word64(0, 0), b = new Word64(0, 0), c = new Word64(0, 0);
  26901. var d = new Word64(0, 0), e = new Word64(0, 0), f = new Word64(0, 0);
  26902. var g = new Word64(0, 0), h = new Word64(0, 0);
  26903. var t1 = new Word64(0, 0), t2 = new Word64(0, 0);
  26904. var tmp1 = new Word64(0, 0), tmp2 = new Word64(0, 0), tmp3;
  26905. for (i = 0; i < paddedLength;) {
  26906. for (j = 0; j < 16; ++j) {
  26907. w[j].high = padded[i] << 24 | padded[i + 1] << 16 | padded[i + 2] << 8 | padded[i + 3];
  26908. w[j].low = padded[i + 4] << 24 | padded[i + 5] << 16 | padded[i + 6] << 8 | padded[i + 7];
  26909. i += 8;
  26910. }
  26911. for (j = 16; j < 80; ++j) {
  26912. tmp3 = w[j];
  26913. littleSigmaPrime(tmp3, w[j - 2], tmp2);
  26914. tmp3.add(w[j - 7]);
  26915. littleSigma(tmp1, w[j - 15], tmp2);
  26916. tmp3.add(tmp1);
  26917. tmp3.add(w[j - 16]);
  26918. }
  26919. a.assign(h0);
  26920. b.assign(h1);
  26921. c.assign(h2);
  26922. d.assign(h3);
  26923. e.assign(h4);
  26924. f.assign(h5);
  26925. g.assign(h6);
  26926. h.assign(h7);
  26927. for (j = 0; j < 80; ++j) {
  26928. t1.assign(h);
  26929. sigmaPrime(tmp1, e, tmp2);
  26930. t1.add(tmp1);
  26931. ch(tmp1, e, f, g, tmp2);
  26932. t1.add(tmp1);
  26933. t1.add(k[j]);
  26934. t1.add(w[j]);
  26935. sigma(t2, a, tmp2);
  26936. maj(tmp1, a, b, c, tmp2);
  26937. t2.add(tmp1);
  26938. tmp3 = h;
  26939. h = g;
  26940. g = f;
  26941. f = e;
  26942. d.add(t1);
  26943. e = d;
  26944. d = c;
  26945. c = b;
  26946. b = a;
  26947. tmp3.assign(t1);
  26948. tmp3.add(t2);
  26949. a = tmp3;
  26950. }
  26951. h0.add(a);
  26952. h1.add(b);
  26953. h2.add(c);
  26954. h3.add(d);
  26955. h4.add(e);
  26956. h5.add(f);
  26957. h6.add(g);
  26958. h7.add(h);
  26959. }
  26960. var result;
  26961. if (!mode384) {
  26962. result = new Uint8Array(64);
  26963. h0.copyTo(result, 0);
  26964. h1.copyTo(result, 8);
  26965. h2.copyTo(result, 16);
  26966. h3.copyTo(result, 24);
  26967. h4.copyTo(result, 32);
  26968. h5.copyTo(result, 40);
  26969. h6.copyTo(result, 48);
  26970. h7.copyTo(result, 56);
  26971. } else {
  26972. result = new Uint8Array(48);
  26973. h0.copyTo(result, 0);
  26974. h1.copyTo(result, 8);
  26975. h2.copyTo(result, 16);
  26976. h3.copyTo(result, 24);
  26977. h4.copyTo(result, 32);
  26978. h5.copyTo(result, 40);
  26979. }
  26980. return result;
  26981. }
  26982. return hash;
  26983. }();
  26984. var calculateSHA384 = function calculateSHA384Closure() {
  26985. function hash(data, offset, length) {
  26986. return calculateSHA512(data, offset, length, true);
  26987. }
  26988. return hash;
  26989. }();
  26990. var NullCipher = function NullCipherClosure() {
  26991. function NullCipher() {
  26992. }
  26993. NullCipher.prototype = {
  26994. decryptBlock: function NullCipher_decryptBlock(data) {
  26995. return data;
  26996. }
  26997. };
  26998. return NullCipher;
  26999. }();
  27000. var AES128Cipher = function AES128CipherClosure() {
  27001. var rcon = new Uint8Array([
  27002. 0x8d,
  27003. 0x01,
  27004. 0x02,
  27005. 0x04,
  27006. 0x08,
  27007. 0x10,
  27008. 0x20,
  27009. 0x40,
  27010. 0x80,
  27011. 0x1b,
  27012. 0x36,
  27013. 0x6c,
  27014. 0xd8,
  27015. 0xab,
  27016. 0x4d,
  27017. 0x9a,
  27018. 0x2f,
  27019. 0x5e,
  27020. 0xbc,
  27021. 0x63,
  27022. 0xc6,
  27023. 0x97,
  27024. 0x35,
  27025. 0x6a,
  27026. 0xd4,
  27027. 0xb3,
  27028. 0x7d,
  27029. 0xfa,
  27030. 0xef,
  27031. 0xc5,
  27032. 0x91,
  27033. 0x39,
  27034. 0x72,
  27035. 0xe4,
  27036. 0xd3,
  27037. 0xbd,
  27038. 0x61,
  27039. 0xc2,
  27040. 0x9f,
  27041. 0x25,
  27042. 0x4a,
  27043. 0x94,
  27044. 0x33,
  27045. 0x66,
  27046. 0xcc,
  27047. 0x83,
  27048. 0x1d,
  27049. 0x3a,
  27050. 0x74,
  27051. 0xe8,
  27052. 0xcb,
  27053. 0x8d,
  27054. 0x01,
  27055. 0x02,
  27056. 0x04,
  27057. 0x08,
  27058. 0x10,
  27059. 0x20,
  27060. 0x40,
  27061. 0x80,
  27062. 0x1b,
  27063. 0x36,
  27064. 0x6c,
  27065. 0xd8,
  27066. 0xab,
  27067. 0x4d,
  27068. 0x9a,
  27069. 0x2f,
  27070. 0x5e,
  27071. 0xbc,
  27072. 0x63,
  27073. 0xc6,
  27074. 0x97,
  27075. 0x35,
  27076. 0x6a,
  27077. 0xd4,
  27078. 0xb3,
  27079. 0x7d,
  27080. 0xfa,
  27081. 0xef,
  27082. 0xc5,
  27083. 0x91,
  27084. 0x39,
  27085. 0x72,
  27086. 0xe4,
  27087. 0xd3,
  27088. 0xbd,
  27089. 0x61,
  27090. 0xc2,
  27091. 0x9f,
  27092. 0x25,
  27093. 0x4a,
  27094. 0x94,
  27095. 0x33,
  27096. 0x66,
  27097. 0xcc,
  27098. 0x83,
  27099. 0x1d,
  27100. 0x3a,
  27101. 0x74,
  27102. 0xe8,
  27103. 0xcb,
  27104. 0x8d,
  27105. 0x01,
  27106. 0x02,
  27107. 0x04,
  27108. 0x08,
  27109. 0x10,
  27110. 0x20,
  27111. 0x40,
  27112. 0x80,
  27113. 0x1b,
  27114. 0x36,
  27115. 0x6c,
  27116. 0xd8,
  27117. 0xab,
  27118. 0x4d,
  27119. 0x9a,
  27120. 0x2f,
  27121. 0x5e,
  27122. 0xbc,
  27123. 0x63,
  27124. 0xc6,
  27125. 0x97,
  27126. 0x35,
  27127. 0x6a,
  27128. 0xd4,
  27129. 0xb3,
  27130. 0x7d,
  27131. 0xfa,
  27132. 0xef,
  27133. 0xc5,
  27134. 0x91,
  27135. 0x39,
  27136. 0x72,
  27137. 0xe4,
  27138. 0xd3,
  27139. 0xbd,
  27140. 0x61,
  27141. 0xc2,
  27142. 0x9f,
  27143. 0x25,
  27144. 0x4a,
  27145. 0x94,
  27146. 0x33,
  27147. 0x66,
  27148. 0xcc,
  27149. 0x83,
  27150. 0x1d,
  27151. 0x3a,
  27152. 0x74,
  27153. 0xe8,
  27154. 0xcb,
  27155. 0x8d,
  27156. 0x01,
  27157. 0x02,
  27158. 0x04,
  27159. 0x08,
  27160. 0x10,
  27161. 0x20,
  27162. 0x40,
  27163. 0x80,
  27164. 0x1b,
  27165. 0x36,
  27166. 0x6c,
  27167. 0xd8,
  27168. 0xab,
  27169. 0x4d,
  27170. 0x9a,
  27171. 0x2f,
  27172. 0x5e,
  27173. 0xbc,
  27174. 0x63,
  27175. 0xc6,
  27176. 0x97,
  27177. 0x35,
  27178. 0x6a,
  27179. 0xd4,
  27180. 0xb3,
  27181. 0x7d,
  27182. 0xfa,
  27183. 0xef,
  27184. 0xc5,
  27185. 0x91,
  27186. 0x39,
  27187. 0x72,
  27188. 0xe4,
  27189. 0xd3,
  27190. 0xbd,
  27191. 0x61,
  27192. 0xc2,
  27193. 0x9f,
  27194. 0x25,
  27195. 0x4a,
  27196. 0x94,
  27197. 0x33,
  27198. 0x66,
  27199. 0xcc,
  27200. 0x83,
  27201. 0x1d,
  27202. 0x3a,
  27203. 0x74,
  27204. 0xe8,
  27205. 0xcb,
  27206. 0x8d,
  27207. 0x01,
  27208. 0x02,
  27209. 0x04,
  27210. 0x08,
  27211. 0x10,
  27212. 0x20,
  27213. 0x40,
  27214. 0x80,
  27215. 0x1b,
  27216. 0x36,
  27217. 0x6c,
  27218. 0xd8,
  27219. 0xab,
  27220. 0x4d,
  27221. 0x9a,
  27222. 0x2f,
  27223. 0x5e,
  27224. 0xbc,
  27225. 0x63,
  27226. 0xc6,
  27227. 0x97,
  27228. 0x35,
  27229. 0x6a,
  27230. 0xd4,
  27231. 0xb3,
  27232. 0x7d,
  27233. 0xfa,
  27234. 0xef,
  27235. 0xc5,
  27236. 0x91,
  27237. 0x39,
  27238. 0x72,
  27239. 0xe4,
  27240. 0xd3,
  27241. 0xbd,
  27242. 0x61,
  27243. 0xc2,
  27244. 0x9f,
  27245. 0x25,
  27246. 0x4a,
  27247. 0x94,
  27248. 0x33,
  27249. 0x66,
  27250. 0xcc,
  27251. 0x83,
  27252. 0x1d,
  27253. 0x3a,
  27254. 0x74,
  27255. 0xe8,
  27256. 0xcb,
  27257. 0x8d
  27258. ]);
  27259. var s = new Uint8Array([
  27260. 0x63,
  27261. 0x7c,
  27262. 0x77,
  27263. 0x7b,
  27264. 0xf2,
  27265. 0x6b,
  27266. 0x6f,
  27267. 0xc5,
  27268. 0x30,
  27269. 0x01,
  27270. 0x67,
  27271. 0x2b,
  27272. 0xfe,
  27273. 0xd7,
  27274. 0xab,
  27275. 0x76,
  27276. 0xca,
  27277. 0x82,
  27278. 0xc9,
  27279. 0x7d,
  27280. 0xfa,
  27281. 0x59,
  27282. 0x47,
  27283. 0xf0,
  27284. 0xad,
  27285. 0xd4,
  27286. 0xa2,
  27287. 0xaf,
  27288. 0x9c,
  27289. 0xa4,
  27290. 0x72,
  27291. 0xc0,
  27292. 0xb7,
  27293. 0xfd,
  27294. 0x93,
  27295. 0x26,
  27296. 0x36,
  27297. 0x3f,
  27298. 0xf7,
  27299. 0xcc,
  27300. 0x34,
  27301. 0xa5,
  27302. 0xe5,
  27303. 0xf1,
  27304. 0x71,
  27305. 0xd8,
  27306. 0x31,
  27307. 0x15,
  27308. 0x04,
  27309. 0xc7,
  27310. 0x23,
  27311. 0xc3,
  27312. 0x18,
  27313. 0x96,
  27314. 0x05,
  27315. 0x9a,
  27316. 0x07,
  27317. 0x12,
  27318. 0x80,
  27319. 0xe2,
  27320. 0xeb,
  27321. 0x27,
  27322. 0xb2,
  27323. 0x75,
  27324. 0x09,
  27325. 0x83,
  27326. 0x2c,
  27327. 0x1a,
  27328. 0x1b,
  27329. 0x6e,
  27330. 0x5a,
  27331. 0xa0,
  27332. 0x52,
  27333. 0x3b,
  27334. 0xd6,
  27335. 0xb3,
  27336. 0x29,
  27337. 0xe3,
  27338. 0x2f,
  27339. 0x84,
  27340. 0x53,
  27341. 0xd1,
  27342. 0x00,
  27343. 0xed,
  27344. 0x20,
  27345. 0xfc,
  27346. 0xb1,
  27347. 0x5b,
  27348. 0x6a,
  27349. 0xcb,
  27350. 0xbe,
  27351. 0x39,
  27352. 0x4a,
  27353. 0x4c,
  27354. 0x58,
  27355. 0xcf,
  27356. 0xd0,
  27357. 0xef,
  27358. 0xaa,
  27359. 0xfb,
  27360. 0x43,
  27361. 0x4d,
  27362. 0x33,
  27363. 0x85,
  27364. 0x45,
  27365. 0xf9,
  27366. 0x02,
  27367. 0x7f,
  27368. 0x50,
  27369. 0x3c,
  27370. 0x9f,
  27371. 0xa8,
  27372. 0x51,
  27373. 0xa3,
  27374. 0x40,
  27375. 0x8f,
  27376. 0x92,
  27377. 0x9d,
  27378. 0x38,
  27379. 0xf5,
  27380. 0xbc,
  27381. 0xb6,
  27382. 0xda,
  27383. 0x21,
  27384. 0x10,
  27385. 0xff,
  27386. 0xf3,
  27387. 0xd2,
  27388. 0xcd,
  27389. 0x0c,
  27390. 0x13,
  27391. 0xec,
  27392. 0x5f,
  27393. 0x97,
  27394. 0x44,
  27395. 0x17,
  27396. 0xc4,
  27397. 0xa7,
  27398. 0x7e,
  27399. 0x3d,
  27400. 0x64,
  27401. 0x5d,
  27402. 0x19,
  27403. 0x73,
  27404. 0x60,
  27405. 0x81,
  27406. 0x4f,
  27407. 0xdc,
  27408. 0x22,
  27409. 0x2a,
  27410. 0x90,
  27411. 0x88,
  27412. 0x46,
  27413. 0xee,
  27414. 0xb8,
  27415. 0x14,
  27416. 0xde,
  27417. 0x5e,
  27418. 0x0b,
  27419. 0xdb,
  27420. 0xe0,
  27421. 0x32,
  27422. 0x3a,
  27423. 0x0a,
  27424. 0x49,
  27425. 0x06,
  27426. 0x24,
  27427. 0x5c,
  27428. 0xc2,
  27429. 0xd3,
  27430. 0xac,
  27431. 0x62,
  27432. 0x91,
  27433. 0x95,
  27434. 0xe4,
  27435. 0x79,
  27436. 0xe7,
  27437. 0xc8,
  27438. 0x37,
  27439. 0x6d,
  27440. 0x8d,
  27441. 0xd5,
  27442. 0x4e,
  27443. 0xa9,
  27444. 0x6c,
  27445. 0x56,
  27446. 0xf4,
  27447. 0xea,
  27448. 0x65,
  27449. 0x7a,
  27450. 0xae,
  27451. 0x08,
  27452. 0xba,
  27453. 0x78,
  27454. 0x25,
  27455. 0x2e,
  27456. 0x1c,
  27457. 0xa6,
  27458. 0xb4,
  27459. 0xc6,
  27460. 0xe8,
  27461. 0xdd,
  27462. 0x74,
  27463. 0x1f,
  27464. 0x4b,
  27465. 0xbd,
  27466. 0x8b,
  27467. 0x8a,
  27468. 0x70,
  27469. 0x3e,
  27470. 0xb5,
  27471. 0x66,
  27472. 0x48,
  27473. 0x03,
  27474. 0xf6,
  27475. 0x0e,
  27476. 0x61,
  27477. 0x35,
  27478. 0x57,
  27479. 0xb9,
  27480. 0x86,
  27481. 0xc1,
  27482. 0x1d,
  27483. 0x9e,
  27484. 0xe1,
  27485. 0xf8,
  27486. 0x98,
  27487. 0x11,
  27488. 0x69,
  27489. 0xd9,
  27490. 0x8e,
  27491. 0x94,
  27492. 0x9b,
  27493. 0x1e,
  27494. 0x87,
  27495. 0xe9,
  27496. 0xce,
  27497. 0x55,
  27498. 0x28,
  27499. 0xdf,
  27500. 0x8c,
  27501. 0xa1,
  27502. 0x89,
  27503. 0x0d,
  27504. 0xbf,
  27505. 0xe6,
  27506. 0x42,
  27507. 0x68,
  27508. 0x41,
  27509. 0x99,
  27510. 0x2d,
  27511. 0x0f,
  27512. 0xb0,
  27513. 0x54,
  27514. 0xbb,
  27515. 0x16
  27516. ]);
  27517. var inv_s = new Uint8Array([
  27518. 0x52,
  27519. 0x09,
  27520. 0x6a,
  27521. 0xd5,
  27522. 0x30,
  27523. 0x36,
  27524. 0xa5,
  27525. 0x38,
  27526. 0xbf,
  27527. 0x40,
  27528. 0xa3,
  27529. 0x9e,
  27530. 0x81,
  27531. 0xf3,
  27532. 0xd7,
  27533. 0xfb,
  27534. 0x7c,
  27535. 0xe3,
  27536. 0x39,
  27537. 0x82,
  27538. 0x9b,
  27539. 0x2f,
  27540. 0xff,
  27541. 0x87,
  27542. 0x34,
  27543. 0x8e,
  27544. 0x43,
  27545. 0x44,
  27546. 0xc4,
  27547. 0xde,
  27548. 0xe9,
  27549. 0xcb,
  27550. 0x54,
  27551. 0x7b,
  27552. 0x94,
  27553. 0x32,
  27554. 0xa6,
  27555. 0xc2,
  27556. 0x23,
  27557. 0x3d,
  27558. 0xee,
  27559. 0x4c,
  27560. 0x95,
  27561. 0x0b,
  27562. 0x42,
  27563. 0xfa,
  27564. 0xc3,
  27565. 0x4e,
  27566. 0x08,
  27567. 0x2e,
  27568. 0xa1,
  27569. 0x66,
  27570. 0x28,
  27571. 0xd9,
  27572. 0x24,
  27573. 0xb2,
  27574. 0x76,
  27575. 0x5b,
  27576. 0xa2,
  27577. 0x49,
  27578. 0x6d,
  27579. 0x8b,
  27580. 0xd1,
  27581. 0x25,
  27582. 0x72,
  27583. 0xf8,
  27584. 0xf6,
  27585. 0x64,
  27586. 0x86,
  27587. 0x68,
  27588. 0x98,
  27589. 0x16,
  27590. 0xd4,
  27591. 0xa4,
  27592. 0x5c,
  27593. 0xcc,
  27594. 0x5d,
  27595. 0x65,
  27596. 0xb6,
  27597. 0x92,
  27598. 0x6c,
  27599. 0x70,
  27600. 0x48,
  27601. 0x50,
  27602. 0xfd,
  27603. 0xed,
  27604. 0xb9,
  27605. 0xda,
  27606. 0x5e,
  27607. 0x15,
  27608. 0x46,
  27609. 0x57,
  27610. 0xa7,
  27611. 0x8d,
  27612. 0x9d,
  27613. 0x84,
  27614. 0x90,
  27615. 0xd8,
  27616. 0xab,
  27617. 0x00,
  27618. 0x8c,
  27619. 0xbc,
  27620. 0xd3,
  27621. 0x0a,
  27622. 0xf7,
  27623. 0xe4,
  27624. 0x58,
  27625. 0x05,
  27626. 0xb8,
  27627. 0xb3,
  27628. 0x45,
  27629. 0x06,
  27630. 0xd0,
  27631. 0x2c,
  27632. 0x1e,
  27633. 0x8f,
  27634. 0xca,
  27635. 0x3f,
  27636. 0x0f,
  27637. 0x02,
  27638. 0xc1,
  27639. 0xaf,
  27640. 0xbd,
  27641. 0x03,
  27642. 0x01,
  27643. 0x13,
  27644. 0x8a,
  27645. 0x6b,
  27646. 0x3a,
  27647. 0x91,
  27648. 0x11,
  27649. 0x41,
  27650. 0x4f,
  27651. 0x67,
  27652. 0xdc,
  27653. 0xea,
  27654. 0x97,
  27655. 0xf2,
  27656. 0xcf,
  27657. 0xce,
  27658. 0xf0,
  27659. 0xb4,
  27660. 0xe6,
  27661. 0x73,
  27662. 0x96,
  27663. 0xac,
  27664. 0x74,
  27665. 0x22,
  27666. 0xe7,
  27667. 0xad,
  27668. 0x35,
  27669. 0x85,
  27670. 0xe2,
  27671. 0xf9,
  27672. 0x37,
  27673. 0xe8,
  27674. 0x1c,
  27675. 0x75,
  27676. 0xdf,
  27677. 0x6e,
  27678. 0x47,
  27679. 0xf1,
  27680. 0x1a,
  27681. 0x71,
  27682. 0x1d,
  27683. 0x29,
  27684. 0xc5,
  27685. 0x89,
  27686. 0x6f,
  27687. 0xb7,
  27688. 0x62,
  27689. 0x0e,
  27690. 0xaa,
  27691. 0x18,
  27692. 0xbe,
  27693. 0x1b,
  27694. 0xfc,
  27695. 0x56,
  27696. 0x3e,
  27697. 0x4b,
  27698. 0xc6,
  27699. 0xd2,
  27700. 0x79,
  27701. 0x20,
  27702. 0x9a,
  27703. 0xdb,
  27704. 0xc0,
  27705. 0xfe,
  27706. 0x78,
  27707. 0xcd,
  27708. 0x5a,
  27709. 0xf4,
  27710. 0x1f,
  27711. 0xdd,
  27712. 0xa8,
  27713. 0x33,
  27714. 0x88,
  27715. 0x07,
  27716. 0xc7,
  27717. 0x31,
  27718. 0xb1,
  27719. 0x12,
  27720. 0x10,
  27721. 0x59,
  27722. 0x27,
  27723. 0x80,
  27724. 0xec,
  27725. 0x5f,
  27726. 0x60,
  27727. 0x51,
  27728. 0x7f,
  27729. 0xa9,
  27730. 0x19,
  27731. 0xb5,
  27732. 0x4a,
  27733. 0x0d,
  27734. 0x2d,
  27735. 0xe5,
  27736. 0x7a,
  27737. 0x9f,
  27738. 0x93,
  27739. 0xc9,
  27740. 0x9c,
  27741. 0xef,
  27742. 0xa0,
  27743. 0xe0,
  27744. 0x3b,
  27745. 0x4d,
  27746. 0xae,
  27747. 0x2a,
  27748. 0xf5,
  27749. 0xb0,
  27750. 0xc8,
  27751. 0xeb,
  27752. 0xbb,
  27753. 0x3c,
  27754. 0x83,
  27755. 0x53,
  27756. 0x99,
  27757. 0x61,
  27758. 0x17,
  27759. 0x2b,
  27760. 0x04,
  27761. 0x7e,
  27762. 0xba,
  27763. 0x77,
  27764. 0xd6,
  27765. 0x26,
  27766. 0xe1,
  27767. 0x69,
  27768. 0x14,
  27769. 0x63,
  27770. 0x55,
  27771. 0x21,
  27772. 0x0c,
  27773. 0x7d
  27774. ]);
  27775. var mixCol = new Uint8Array(256);
  27776. for (var i = 0; i < 256; i++) {
  27777. if (i < 128) {
  27778. mixCol[i] = i << 1;
  27779. } else {
  27780. mixCol[i] = i << 1 ^ 0x1b;
  27781. }
  27782. }
  27783. var mix = new Uint32Array([
  27784. 0x00000000,
  27785. 0x0e090d0b,
  27786. 0x1c121a16,
  27787. 0x121b171d,
  27788. 0x3824342c,
  27789. 0x362d3927,
  27790. 0x24362e3a,
  27791. 0x2a3f2331,
  27792. 0x70486858,
  27793. 0x7e416553,
  27794. 0x6c5a724e,
  27795. 0x62537f45,
  27796. 0x486c5c74,
  27797. 0x4665517f,
  27798. 0x547e4662,
  27799. 0x5a774b69,
  27800. 0xe090d0b0,
  27801. 0xee99ddbb,
  27802. 0xfc82caa6,
  27803. 0xf28bc7ad,
  27804. 0xd8b4e49c,
  27805. 0xd6bde997,
  27806. 0xc4a6fe8a,
  27807. 0xcaaff381,
  27808. 0x90d8b8e8,
  27809. 0x9ed1b5e3,
  27810. 0x8ccaa2fe,
  27811. 0x82c3aff5,
  27812. 0xa8fc8cc4,
  27813. 0xa6f581cf,
  27814. 0xb4ee96d2,
  27815. 0xbae79bd9,
  27816. 0xdb3bbb7b,
  27817. 0xd532b670,
  27818. 0xc729a16d,
  27819. 0xc920ac66,
  27820. 0xe31f8f57,
  27821. 0xed16825c,
  27822. 0xff0d9541,
  27823. 0xf104984a,
  27824. 0xab73d323,
  27825. 0xa57ade28,
  27826. 0xb761c935,
  27827. 0xb968c43e,
  27828. 0x9357e70f,
  27829. 0x9d5eea04,
  27830. 0x8f45fd19,
  27831. 0x814cf012,
  27832. 0x3bab6bcb,
  27833. 0x35a266c0,
  27834. 0x27b971dd,
  27835. 0x29b07cd6,
  27836. 0x038f5fe7,
  27837. 0x0d8652ec,
  27838. 0x1f9d45f1,
  27839. 0x119448fa,
  27840. 0x4be30393,
  27841. 0x45ea0e98,
  27842. 0x57f11985,
  27843. 0x59f8148e,
  27844. 0x73c737bf,
  27845. 0x7dce3ab4,
  27846. 0x6fd52da9,
  27847. 0x61dc20a2,
  27848. 0xad766df6,
  27849. 0xa37f60fd,
  27850. 0xb16477e0,
  27851. 0xbf6d7aeb,
  27852. 0x955259da,
  27853. 0x9b5b54d1,
  27854. 0x894043cc,
  27855. 0x87494ec7,
  27856. 0xdd3e05ae,
  27857. 0xd33708a5,
  27858. 0xc12c1fb8,
  27859. 0xcf2512b3,
  27860. 0xe51a3182,
  27861. 0xeb133c89,
  27862. 0xf9082b94,
  27863. 0xf701269f,
  27864. 0x4de6bd46,
  27865. 0x43efb04d,
  27866. 0x51f4a750,
  27867. 0x5ffdaa5b,
  27868. 0x75c2896a,
  27869. 0x7bcb8461,
  27870. 0x69d0937c,
  27871. 0x67d99e77,
  27872. 0x3daed51e,
  27873. 0x33a7d815,
  27874. 0x21bccf08,
  27875. 0x2fb5c203,
  27876. 0x058ae132,
  27877. 0x0b83ec39,
  27878. 0x1998fb24,
  27879. 0x1791f62f,
  27880. 0x764dd68d,
  27881. 0x7844db86,
  27882. 0x6a5fcc9b,
  27883. 0x6456c190,
  27884. 0x4e69e2a1,
  27885. 0x4060efaa,
  27886. 0x527bf8b7,
  27887. 0x5c72f5bc,
  27888. 0x0605bed5,
  27889. 0x080cb3de,
  27890. 0x1a17a4c3,
  27891. 0x141ea9c8,
  27892. 0x3e218af9,
  27893. 0x302887f2,
  27894. 0x223390ef,
  27895. 0x2c3a9de4,
  27896. 0x96dd063d,
  27897. 0x98d40b36,
  27898. 0x8acf1c2b,
  27899. 0x84c61120,
  27900. 0xaef93211,
  27901. 0xa0f03f1a,
  27902. 0xb2eb2807,
  27903. 0xbce2250c,
  27904. 0xe6956e65,
  27905. 0xe89c636e,
  27906. 0xfa877473,
  27907. 0xf48e7978,
  27908. 0xdeb15a49,
  27909. 0xd0b85742,
  27910. 0xc2a3405f,
  27911. 0xccaa4d54,
  27912. 0x41ecdaf7,
  27913. 0x4fe5d7fc,
  27914. 0x5dfec0e1,
  27915. 0x53f7cdea,
  27916. 0x79c8eedb,
  27917. 0x77c1e3d0,
  27918. 0x65daf4cd,
  27919. 0x6bd3f9c6,
  27920. 0x31a4b2af,
  27921. 0x3fadbfa4,
  27922. 0x2db6a8b9,
  27923. 0x23bfa5b2,
  27924. 0x09808683,
  27925. 0x07898b88,
  27926. 0x15929c95,
  27927. 0x1b9b919e,
  27928. 0xa17c0a47,
  27929. 0xaf75074c,
  27930. 0xbd6e1051,
  27931. 0xb3671d5a,
  27932. 0x99583e6b,
  27933. 0x97513360,
  27934. 0x854a247d,
  27935. 0x8b432976,
  27936. 0xd134621f,
  27937. 0xdf3d6f14,
  27938. 0xcd267809,
  27939. 0xc32f7502,
  27940. 0xe9105633,
  27941. 0xe7195b38,
  27942. 0xf5024c25,
  27943. 0xfb0b412e,
  27944. 0x9ad7618c,
  27945. 0x94de6c87,
  27946. 0x86c57b9a,
  27947. 0x88cc7691,
  27948. 0xa2f355a0,
  27949. 0xacfa58ab,
  27950. 0xbee14fb6,
  27951. 0xb0e842bd,
  27952. 0xea9f09d4,
  27953. 0xe49604df,
  27954. 0xf68d13c2,
  27955. 0xf8841ec9,
  27956. 0xd2bb3df8,
  27957. 0xdcb230f3,
  27958. 0xcea927ee,
  27959. 0xc0a02ae5,
  27960. 0x7a47b13c,
  27961. 0x744ebc37,
  27962. 0x6655ab2a,
  27963. 0x685ca621,
  27964. 0x42638510,
  27965. 0x4c6a881b,
  27966. 0x5e719f06,
  27967. 0x5078920d,
  27968. 0x0a0fd964,
  27969. 0x0406d46f,
  27970. 0x161dc372,
  27971. 0x1814ce79,
  27972. 0x322bed48,
  27973. 0x3c22e043,
  27974. 0x2e39f75e,
  27975. 0x2030fa55,
  27976. 0xec9ab701,
  27977. 0xe293ba0a,
  27978. 0xf088ad17,
  27979. 0xfe81a01c,
  27980. 0xd4be832d,
  27981. 0xdab78e26,
  27982. 0xc8ac993b,
  27983. 0xc6a59430,
  27984. 0x9cd2df59,
  27985. 0x92dbd252,
  27986. 0x80c0c54f,
  27987. 0x8ec9c844,
  27988. 0xa4f6eb75,
  27989. 0xaaffe67e,
  27990. 0xb8e4f163,
  27991. 0xb6edfc68,
  27992. 0x0c0a67b1,
  27993. 0x02036aba,
  27994. 0x10187da7,
  27995. 0x1e1170ac,
  27996. 0x342e539d,
  27997. 0x3a275e96,
  27998. 0x283c498b,
  27999. 0x26354480,
  28000. 0x7c420fe9,
  28001. 0x724b02e2,
  28002. 0x605015ff,
  28003. 0x6e5918f4,
  28004. 0x44663bc5,
  28005. 0x4a6f36ce,
  28006. 0x587421d3,
  28007. 0x567d2cd8,
  28008. 0x37a10c7a,
  28009. 0x39a80171,
  28010. 0x2bb3166c,
  28011. 0x25ba1b67,
  28012. 0x0f853856,
  28013. 0x018c355d,
  28014. 0x13972240,
  28015. 0x1d9e2f4b,
  28016. 0x47e96422,
  28017. 0x49e06929,
  28018. 0x5bfb7e34,
  28019. 0x55f2733f,
  28020. 0x7fcd500e,
  28021. 0x71c45d05,
  28022. 0x63df4a18,
  28023. 0x6dd64713,
  28024. 0xd731dcca,
  28025. 0xd938d1c1,
  28026. 0xcb23c6dc,
  28027. 0xc52acbd7,
  28028. 0xef15e8e6,
  28029. 0xe11ce5ed,
  28030. 0xf307f2f0,
  28031. 0xfd0efffb,
  28032. 0xa779b492,
  28033. 0xa970b999,
  28034. 0xbb6bae84,
  28035. 0xb562a38f,
  28036. 0x9f5d80be,
  28037. 0x91548db5,
  28038. 0x834f9aa8,
  28039. 0x8d4697a3
  28040. ]);
  28041. function expandKey128(cipherKey) {
  28042. var b = 176, result = new Uint8Array(b);
  28043. result.set(cipherKey);
  28044. for (var j = 16, i = 1; j < b; ++i) {
  28045. var t1 = result[j - 3], t2 = result[j - 2], t3 = result[j - 1], t4 = result[j - 4];
  28046. t1 = s[t1];
  28047. t2 = s[t2];
  28048. t3 = s[t3];
  28049. t4 = s[t4];
  28050. t1 = t1 ^ rcon[i];
  28051. for (var n = 0; n < 4; ++n) {
  28052. result[j] = t1 ^= result[j - 16];
  28053. j++;
  28054. result[j] = t2 ^= result[j - 16];
  28055. j++;
  28056. result[j] = t3 ^= result[j - 16];
  28057. j++;
  28058. result[j] = t4 ^= result[j - 16];
  28059. j++;
  28060. }
  28061. }
  28062. return result;
  28063. }
  28064. function decrypt128(input, key) {
  28065. var state = new Uint8Array(16);
  28066. state.set(input);
  28067. var i, j, k;
  28068. var t, u, v;
  28069. for (j = 0, k = 160; j < 16; ++j, ++k) {
  28070. state[j] ^= key[k];
  28071. }
  28072. for (i = 9; i >= 1; --i) {
  28073. t = state[13];
  28074. state[13] = state[9];
  28075. state[9] = state[5];
  28076. state[5] = state[1];
  28077. state[1] = t;
  28078. t = state[14];
  28079. u = state[10];
  28080. state[14] = state[6];
  28081. state[10] = state[2];
  28082. state[6] = t;
  28083. state[2] = u;
  28084. t = state[15];
  28085. u = state[11];
  28086. v = state[7];
  28087. state[15] = state[3];
  28088. state[11] = t;
  28089. state[7] = u;
  28090. state[3] = v;
  28091. for (j = 0; j < 16; ++j) {
  28092. state[j] = inv_s[state[j]];
  28093. }
  28094. for (j = 0, k = i * 16; j < 16; ++j, ++k) {
  28095. state[j] ^= key[k];
  28096. }
  28097. for (j = 0; j < 16; j += 4) {
  28098. var s0 = mix[state[j]], s1 = mix[state[j + 1]], s2 = mix[state[j + 2]], s3 = mix[state[j + 3]];
  28099. t = s0 ^ s1 >>> 8 ^ s1 << 24 ^ s2 >>> 16 ^ s2 << 16 ^ s3 >>> 24 ^ s3 << 8;
  28100. state[j] = t >>> 24 & 0xFF;
  28101. state[j + 1] = t >> 16 & 0xFF;
  28102. state[j + 2] = t >> 8 & 0xFF;
  28103. state[j + 3] = t & 0xFF;
  28104. }
  28105. }
  28106. t = state[13];
  28107. state[13] = state[9];
  28108. state[9] = state[5];
  28109. state[5] = state[1];
  28110. state[1] = t;
  28111. t = state[14];
  28112. u = state[10];
  28113. state[14] = state[6];
  28114. state[10] = state[2];
  28115. state[6] = t;
  28116. state[2] = u;
  28117. t = state[15];
  28118. u = state[11];
  28119. v = state[7];
  28120. state[15] = state[3];
  28121. state[11] = t;
  28122. state[7] = u;
  28123. state[3] = v;
  28124. for (j = 0; j < 16; ++j) {
  28125. state[j] = inv_s[state[j]];
  28126. state[j] ^= key[j];
  28127. }
  28128. return state;
  28129. }
  28130. function encrypt128(input, key) {
  28131. var t, u, v, k;
  28132. var state = new Uint8Array(16);
  28133. state.set(input);
  28134. for (j = 0; j < 16; ++j) {
  28135. state[j] ^= key[j];
  28136. }
  28137. for (i = 1; i < 10; i++) {
  28138. for (j = 0; j < 16; ++j) {
  28139. state[j] = s[state[j]];
  28140. }
  28141. v = state[1];
  28142. state[1] = state[5];
  28143. state[5] = state[9];
  28144. state[9] = state[13];
  28145. state[13] = v;
  28146. v = state[2];
  28147. u = state[6];
  28148. state[2] = state[10];
  28149. state[6] = state[14];
  28150. state[10] = v;
  28151. state[14] = u;
  28152. v = state[3];
  28153. u = state[7];
  28154. t = state[11];
  28155. state[3] = state[15];
  28156. state[7] = v;
  28157. state[11] = u;
  28158. state[15] = t;
  28159. for (var j = 0; j < 16; j += 4) {
  28160. var s0 = state[j + 0], s1 = state[j + 1];
  28161. var s2 = state[j + 2], s3 = state[j + 3];
  28162. t = s0 ^ s1 ^ s2 ^ s3;
  28163. state[j + 0] ^= t ^ mixCol[s0 ^ s1];
  28164. state[j + 1] ^= t ^ mixCol[s1 ^ s2];
  28165. state[j + 2] ^= t ^ mixCol[s2 ^ s3];
  28166. state[j + 3] ^= t ^ mixCol[s3 ^ s0];
  28167. }
  28168. for (j = 0, k = i * 16; j < 16; ++j, ++k) {
  28169. state[j] ^= key[k];
  28170. }
  28171. }
  28172. for (j = 0; j < 16; ++j) {
  28173. state[j] = s[state[j]];
  28174. }
  28175. v = state[1];
  28176. state[1] = state[5];
  28177. state[5] = state[9];
  28178. state[9] = state[13];
  28179. state[13] = v;
  28180. v = state[2];
  28181. u = state[6];
  28182. state[2] = state[10];
  28183. state[6] = state[14];
  28184. state[10] = v;
  28185. state[14] = u;
  28186. v = state[3];
  28187. u = state[7];
  28188. t = state[11];
  28189. state[3] = state[15];
  28190. state[7] = v;
  28191. state[11] = u;
  28192. state[15] = t;
  28193. for (j = 0, k = 160; j < 16; ++j, ++k) {
  28194. state[j] ^= key[k];
  28195. }
  28196. return state;
  28197. }
  28198. function AES128Cipher(key) {
  28199. this.key = expandKey128(key);
  28200. this.buffer = new Uint8Array(16);
  28201. this.bufferPosition = 0;
  28202. }
  28203. function decryptBlock2(data, finalize) {
  28204. var i, j, ii, sourceLength = data.length, buffer = this.buffer, bufferLength = this.bufferPosition, result = [], iv = this.iv;
  28205. for (i = 0; i < sourceLength; ++i) {
  28206. buffer[bufferLength] = data[i];
  28207. ++bufferLength;
  28208. if (bufferLength < 16) {
  28209. continue;
  28210. }
  28211. var plain = decrypt128(buffer, this.key);
  28212. for (j = 0; j < 16; ++j) {
  28213. plain[j] ^= iv[j];
  28214. }
  28215. iv = buffer;
  28216. result.push(plain);
  28217. buffer = new Uint8Array(16);
  28218. bufferLength = 0;
  28219. }
  28220. this.buffer = buffer;
  28221. this.bufferLength = bufferLength;
  28222. this.iv = iv;
  28223. if (result.length === 0) {
  28224. return new Uint8Array([]);
  28225. }
  28226. var outputLength = 16 * result.length;
  28227. if (finalize) {
  28228. var lastBlock = result[result.length - 1];
  28229. var psLen = lastBlock[15];
  28230. if (psLen <= 16) {
  28231. for (i = 15, ii = 16 - psLen; i >= ii; --i) {
  28232. if (lastBlock[i] !== psLen) {
  28233. psLen = 0;
  28234. break;
  28235. }
  28236. }
  28237. outputLength -= psLen;
  28238. result[result.length - 1] = lastBlock.subarray(0, 16 - psLen);
  28239. }
  28240. }
  28241. var output = new Uint8Array(outputLength);
  28242. for (i = 0, j = 0, ii = result.length; i < ii; ++i, j += 16) {
  28243. output.set(result[i], j);
  28244. }
  28245. return output;
  28246. }
  28247. AES128Cipher.prototype = {
  28248. decryptBlock: function AES128Cipher_decryptBlock(data, finalize) {
  28249. var i, sourceLength = data.length;
  28250. var buffer = this.buffer, bufferLength = this.bufferPosition;
  28251. for (i = 0; bufferLength < 16 && i < sourceLength; ++i, ++bufferLength) {
  28252. buffer[bufferLength] = data[i];
  28253. }
  28254. if (bufferLength < 16) {
  28255. this.bufferLength = bufferLength;
  28256. return new Uint8Array([]);
  28257. }
  28258. this.iv = buffer;
  28259. this.buffer = new Uint8Array(16);
  28260. this.bufferLength = 0;
  28261. this.decryptBlock = decryptBlock2;
  28262. return this.decryptBlock(data.subarray(16), finalize);
  28263. },
  28264. encrypt: function AES128Cipher_encrypt(data, iv) {
  28265. var i, j, ii, sourceLength = data.length, buffer = this.buffer, bufferLength = this.bufferPosition, result = [];
  28266. if (!iv) {
  28267. iv = new Uint8Array(16);
  28268. }
  28269. for (i = 0; i < sourceLength; ++i) {
  28270. buffer[bufferLength] = data[i];
  28271. ++bufferLength;
  28272. if (bufferLength < 16) {
  28273. continue;
  28274. }
  28275. for (j = 0; j < 16; ++j) {
  28276. buffer[j] ^= iv[j];
  28277. }
  28278. var cipher = encrypt128(buffer, this.key);
  28279. iv = cipher;
  28280. result.push(cipher);
  28281. buffer = new Uint8Array(16);
  28282. bufferLength = 0;
  28283. }
  28284. this.buffer = buffer;
  28285. this.bufferLength = bufferLength;
  28286. this.iv = iv;
  28287. if (result.length === 0) {
  28288. return new Uint8Array([]);
  28289. }
  28290. var outputLength = 16 * result.length;
  28291. var output = new Uint8Array(outputLength);
  28292. for (i = 0, j = 0, ii = result.length; i < ii; ++i, j += 16) {
  28293. output.set(result[i], j);
  28294. }
  28295. return output;
  28296. }
  28297. };
  28298. return AES128Cipher;
  28299. }();
  28300. var AES256Cipher = function AES256CipherClosure() {
  28301. var s = new Uint8Array([
  28302. 0x63,
  28303. 0x7c,
  28304. 0x77,
  28305. 0x7b,
  28306. 0xf2,
  28307. 0x6b,
  28308. 0x6f,
  28309. 0xc5,
  28310. 0x30,
  28311. 0x01,
  28312. 0x67,
  28313. 0x2b,
  28314. 0xfe,
  28315. 0xd7,
  28316. 0xab,
  28317. 0x76,
  28318. 0xca,
  28319. 0x82,
  28320. 0xc9,
  28321. 0x7d,
  28322. 0xfa,
  28323. 0x59,
  28324. 0x47,
  28325. 0xf0,
  28326. 0xad,
  28327. 0xd4,
  28328. 0xa2,
  28329. 0xaf,
  28330. 0x9c,
  28331. 0xa4,
  28332. 0x72,
  28333. 0xc0,
  28334. 0xb7,
  28335. 0xfd,
  28336. 0x93,
  28337. 0x26,
  28338. 0x36,
  28339. 0x3f,
  28340. 0xf7,
  28341. 0xcc,
  28342. 0x34,
  28343. 0xa5,
  28344. 0xe5,
  28345. 0xf1,
  28346. 0x71,
  28347. 0xd8,
  28348. 0x31,
  28349. 0x15,
  28350. 0x04,
  28351. 0xc7,
  28352. 0x23,
  28353. 0xc3,
  28354. 0x18,
  28355. 0x96,
  28356. 0x05,
  28357. 0x9a,
  28358. 0x07,
  28359. 0x12,
  28360. 0x80,
  28361. 0xe2,
  28362. 0xeb,
  28363. 0x27,
  28364. 0xb2,
  28365. 0x75,
  28366. 0x09,
  28367. 0x83,
  28368. 0x2c,
  28369. 0x1a,
  28370. 0x1b,
  28371. 0x6e,
  28372. 0x5a,
  28373. 0xa0,
  28374. 0x52,
  28375. 0x3b,
  28376. 0xd6,
  28377. 0xb3,
  28378. 0x29,
  28379. 0xe3,
  28380. 0x2f,
  28381. 0x84,
  28382. 0x53,
  28383. 0xd1,
  28384. 0x00,
  28385. 0xed,
  28386. 0x20,
  28387. 0xfc,
  28388. 0xb1,
  28389. 0x5b,
  28390. 0x6a,
  28391. 0xcb,
  28392. 0xbe,
  28393. 0x39,
  28394. 0x4a,
  28395. 0x4c,
  28396. 0x58,
  28397. 0xcf,
  28398. 0xd0,
  28399. 0xef,
  28400. 0xaa,
  28401. 0xfb,
  28402. 0x43,
  28403. 0x4d,
  28404. 0x33,
  28405. 0x85,
  28406. 0x45,
  28407. 0xf9,
  28408. 0x02,
  28409. 0x7f,
  28410. 0x50,
  28411. 0x3c,
  28412. 0x9f,
  28413. 0xa8,
  28414. 0x51,
  28415. 0xa3,
  28416. 0x40,
  28417. 0x8f,
  28418. 0x92,
  28419. 0x9d,
  28420. 0x38,
  28421. 0xf5,
  28422. 0xbc,
  28423. 0xb6,
  28424. 0xda,
  28425. 0x21,
  28426. 0x10,
  28427. 0xff,
  28428. 0xf3,
  28429. 0xd2,
  28430. 0xcd,
  28431. 0x0c,
  28432. 0x13,
  28433. 0xec,
  28434. 0x5f,
  28435. 0x97,
  28436. 0x44,
  28437. 0x17,
  28438. 0xc4,
  28439. 0xa7,
  28440. 0x7e,
  28441. 0x3d,
  28442. 0x64,
  28443. 0x5d,
  28444. 0x19,
  28445. 0x73,
  28446. 0x60,
  28447. 0x81,
  28448. 0x4f,
  28449. 0xdc,
  28450. 0x22,
  28451. 0x2a,
  28452. 0x90,
  28453. 0x88,
  28454. 0x46,
  28455. 0xee,
  28456. 0xb8,
  28457. 0x14,
  28458. 0xde,
  28459. 0x5e,
  28460. 0x0b,
  28461. 0xdb,
  28462. 0xe0,
  28463. 0x32,
  28464. 0x3a,
  28465. 0x0a,
  28466. 0x49,
  28467. 0x06,
  28468. 0x24,
  28469. 0x5c,
  28470. 0xc2,
  28471. 0xd3,
  28472. 0xac,
  28473. 0x62,
  28474. 0x91,
  28475. 0x95,
  28476. 0xe4,
  28477. 0x79,
  28478. 0xe7,
  28479. 0xc8,
  28480. 0x37,
  28481. 0x6d,
  28482. 0x8d,
  28483. 0xd5,
  28484. 0x4e,
  28485. 0xa9,
  28486. 0x6c,
  28487. 0x56,
  28488. 0xf4,
  28489. 0xea,
  28490. 0x65,
  28491. 0x7a,
  28492. 0xae,
  28493. 0x08,
  28494. 0xba,
  28495. 0x78,
  28496. 0x25,
  28497. 0x2e,
  28498. 0x1c,
  28499. 0xa6,
  28500. 0xb4,
  28501. 0xc6,
  28502. 0xe8,
  28503. 0xdd,
  28504. 0x74,
  28505. 0x1f,
  28506. 0x4b,
  28507. 0xbd,
  28508. 0x8b,
  28509. 0x8a,
  28510. 0x70,
  28511. 0x3e,
  28512. 0xb5,
  28513. 0x66,
  28514. 0x48,
  28515. 0x03,
  28516. 0xf6,
  28517. 0x0e,
  28518. 0x61,
  28519. 0x35,
  28520. 0x57,
  28521. 0xb9,
  28522. 0x86,
  28523. 0xc1,
  28524. 0x1d,
  28525. 0x9e,
  28526. 0xe1,
  28527. 0xf8,
  28528. 0x98,
  28529. 0x11,
  28530. 0x69,
  28531. 0xd9,
  28532. 0x8e,
  28533. 0x94,
  28534. 0x9b,
  28535. 0x1e,
  28536. 0x87,
  28537. 0xe9,
  28538. 0xce,
  28539. 0x55,
  28540. 0x28,
  28541. 0xdf,
  28542. 0x8c,
  28543. 0xa1,
  28544. 0x89,
  28545. 0x0d,
  28546. 0xbf,
  28547. 0xe6,
  28548. 0x42,
  28549. 0x68,
  28550. 0x41,
  28551. 0x99,
  28552. 0x2d,
  28553. 0x0f,
  28554. 0xb0,
  28555. 0x54,
  28556. 0xbb,
  28557. 0x16
  28558. ]);
  28559. var inv_s = new Uint8Array([
  28560. 0x52,
  28561. 0x09,
  28562. 0x6a,
  28563. 0xd5,
  28564. 0x30,
  28565. 0x36,
  28566. 0xa5,
  28567. 0x38,
  28568. 0xbf,
  28569. 0x40,
  28570. 0xa3,
  28571. 0x9e,
  28572. 0x81,
  28573. 0xf3,
  28574. 0xd7,
  28575. 0xfb,
  28576. 0x7c,
  28577. 0xe3,
  28578. 0x39,
  28579. 0x82,
  28580. 0x9b,
  28581. 0x2f,
  28582. 0xff,
  28583. 0x87,
  28584. 0x34,
  28585. 0x8e,
  28586. 0x43,
  28587. 0x44,
  28588. 0xc4,
  28589. 0xde,
  28590. 0xe9,
  28591. 0xcb,
  28592. 0x54,
  28593. 0x7b,
  28594. 0x94,
  28595. 0x32,
  28596. 0xa6,
  28597. 0xc2,
  28598. 0x23,
  28599. 0x3d,
  28600. 0xee,
  28601. 0x4c,
  28602. 0x95,
  28603. 0x0b,
  28604. 0x42,
  28605. 0xfa,
  28606. 0xc3,
  28607. 0x4e,
  28608. 0x08,
  28609. 0x2e,
  28610. 0xa1,
  28611. 0x66,
  28612. 0x28,
  28613. 0xd9,
  28614. 0x24,
  28615. 0xb2,
  28616. 0x76,
  28617. 0x5b,
  28618. 0xa2,
  28619. 0x49,
  28620. 0x6d,
  28621. 0x8b,
  28622. 0xd1,
  28623. 0x25,
  28624. 0x72,
  28625. 0xf8,
  28626. 0xf6,
  28627. 0x64,
  28628. 0x86,
  28629. 0x68,
  28630. 0x98,
  28631. 0x16,
  28632. 0xd4,
  28633. 0xa4,
  28634. 0x5c,
  28635. 0xcc,
  28636. 0x5d,
  28637. 0x65,
  28638. 0xb6,
  28639. 0x92,
  28640. 0x6c,
  28641. 0x70,
  28642. 0x48,
  28643. 0x50,
  28644. 0xfd,
  28645. 0xed,
  28646. 0xb9,
  28647. 0xda,
  28648. 0x5e,
  28649. 0x15,
  28650. 0x46,
  28651. 0x57,
  28652. 0xa7,
  28653. 0x8d,
  28654. 0x9d,
  28655. 0x84,
  28656. 0x90,
  28657. 0xd8,
  28658. 0xab,
  28659. 0x00,
  28660. 0x8c,
  28661. 0xbc,
  28662. 0xd3,
  28663. 0x0a,
  28664. 0xf7,
  28665. 0xe4,
  28666. 0x58,
  28667. 0x05,
  28668. 0xb8,
  28669. 0xb3,
  28670. 0x45,
  28671. 0x06,
  28672. 0xd0,
  28673. 0x2c,
  28674. 0x1e,
  28675. 0x8f,
  28676. 0xca,
  28677. 0x3f,
  28678. 0x0f,
  28679. 0x02,
  28680. 0xc1,
  28681. 0xaf,
  28682. 0xbd,
  28683. 0x03,
  28684. 0x01,
  28685. 0x13,
  28686. 0x8a,
  28687. 0x6b,
  28688. 0x3a,
  28689. 0x91,
  28690. 0x11,
  28691. 0x41,
  28692. 0x4f,
  28693. 0x67,
  28694. 0xdc,
  28695. 0xea,
  28696. 0x97,
  28697. 0xf2,
  28698. 0xcf,
  28699. 0xce,
  28700. 0xf0,
  28701. 0xb4,
  28702. 0xe6,
  28703. 0x73,
  28704. 0x96,
  28705. 0xac,
  28706. 0x74,
  28707. 0x22,
  28708. 0xe7,
  28709. 0xad,
  28710. 0x35,
  28711. 0x85,
  28712. 0xe2,
  28713. 0xf9,
  28714. 0x37,
  28715. 0xe8,
  28716. 0x1c,
  28717. 0x75,
  28718. 0xdf,
  28719. 0x6e,
  28720. 0x47,
  28721. 0xf1,
  28722. 0x1a,
  28723. 0x71,
  28724. 0x1d,
  28725. 0x29,
  28726. 0xc5,
  28727. 0x89,
  28728. 0x6f,
  28729. 0xb7,
  28730. 0x62,
  28731. 0x0e,
  28732. 0xaa,
  28733. 0x18,
  28734. 0xbe,
  28735. 0x1b,
  28736. 0xfc,
  28737. 0x56,
  28738. 0x3e,
  28739. 0x4b,
  28740. 0xc6,
  28741. 0xd2,
  28742. 0x79,
  28743. 0x20,
  28744. 0x9a,
  28745. 0xdb,
  28746. 0xc0,
  28747. 0xfe,
  28748. 0x78,
  28749. 0xcd,
  28750. 0x5a,
  28751. 0xf4,
  28752. 0x1f,
  28753. 0xdd,
  28754. 0xa8,
  28755. 0x33,
  28756. 0x88,
  28757. 0x07,
  28758. 0xc7,
  28759. 0x31,
  28760. 0xb1,
  28761. 0x12,
  28762. 0x10,
  28763. 0x59,
  28764. 0x27,
  28765. 0x80,
  28766. 0xec,
  28767. 0x5f,
  28768. 0x60,
  28769. 0x51,
  28770. 0x7f,
  28771. 0xa9,
  28772. 0x19,
  28773. 0xb5,
  28774. 0x4a,
  28775. 0x0d,
  28776. 0x2d,
  28777. 0xe5,
  28778. 0x7a,
  28779. 0x9f,
  28780. 0x93,
  28781. 0xc9,
  28782. 0x9c,
  28783. 0xef,
  28784. 0xa0,
  28785. 0xe0,
  28786. 0x3b,
  28787. 0x4d,
  28788. 0xae,
  28789. 0x2a,
  28790. 0xf5,
  28791. 0xb0,
  28792. 0xc8,
  28793. 0xeb,
  28794. 0xbb,
  28795. 0x3c,
  28796. 0x83,
  28797. 0x53,
  28798. 0x99,
  28799. 0x61,
  28800. 0x17,
  28801. 0x2b,
  28802. 0x04,
  28803. 0x7e,
  28804. 0xba,
  28805. 0x77,
  28806. 0xd6,
  28807. 0x26,
  28808. 0xe1,
  28809. 0x69,
  28810. 0x14,
  28811. 0x63,
  28812. 0x55,
  28813. 0x21,
  28814. 0x0c,
  28815. 0x7d
  28816. ]);
  28817. var mixCol = new Uint8Array(256);
  28818. for (var i = 0; i < 256; i++) {
  28819. if (i < 128) {
  28820. mixCol[i] = i << 1;
  28821. } else {
  28822. mixCol[i] = i << 1 ^ 0x1b;
  28823. }
  28824. }
  28825. var mix = new Uint32Array([
  28826. 0x00000000,
  28827. 0x0e090d0b,
  28828. 0x1c121a16,
  28829. 0x121b171d,
  28830. 0x3824342c,
  28831. 0x362d3927,
  28832. 0x24362e3a,
  28833. 0x2a3f2331,
  28834. 0x70486858,
  28835. 0x7e416553,
  28836. 0x6c5a724e,
  28837. 0x62537f45,
  28838. 0x486c5c74,
  28839. 0x4665517f,
  28840. 0x547e4662,
  28841. 0x5a774b69,
  28842. 0xe090d0b0,
  28843. 0xee99ddbb,
  28844. 0xfc82caa6,
  28845. 0xf28bc7ad,
  28846. 0xd8b4e49c,
  28847. 0xd6bde997,
  28848. 0xc4a6fe8a,
  28849. 0xcaaff381,
  28850. 0x90d8b8e8,
  28851. 0x9ed1b5e3,
  28852. 0x8ccaa2fe,
  28853. 0x82c3aff5,
  28854. 0xa8fc8cc4,
  28855. 0xa6f581cf,
  28856. 0xb4ee96d2,
  28857. 0xbae79bd9,
  28858. 0xdb3bbb7b,
  28859. 0xd532b670,
  28860. 0xc729a16d,
  28861. 0xc920ac66,
  28862. 0xe31f8f57,
  28863. 0xed16825c,
  28864. 0xff0d9541,
  28865. 0xf104984a,
  28866. 0xab73d323,
  28867. 0xa57ade28,
  28868. 0xb761c935,
  28869. 0xb968c43e,
  28870. 0x9357e70f,
  28871. 0x9d5eea04,
  28872. 0x8f45fd19,
  28873. 0x814cf012,
  28874. 0x3bab6bcb,
  28875. 0x35a266c0,
  28876. 0x27b971dd,
  28877. 0x29b07cd6,
  28878. 0x038f5fe7,
  28879. 0x0d8652ec,
  28880. 0x1f9d45f1,
  28881. 0x119448fa,
  28882. 0x4be30393,
  28883. 0x45ea0e98,
  28884. 0x57f11985,
  28885. 0x59f8148e,
  28886. 0x73c737bf,
  28887. 0x7dce3ab4,
  28888. 0x6fd52da9,
  28889. 0x61dc20a2,
  28890. 0xad766df6,
  28891. 0xa37f60fd,
  28892. 0xb16477e0,
  28893. 0xbf6d7aeb,
  28894. 0x955259da,
  28895. 0x9b5b54d1,
  28896. 0x894043cc,
  28897. 0x87494ec7,
  28898. 0xdd3e05ae,
  28899. 0xd33708a5,
  28900. 0xc12c1fb8,
  28901. 0xcf2512b3,
  28902. 0xe51a3182,
  28903. 0xeb133c89,
  28904. 0xf9082b94,
  28905. 0xf701269f,
  28906. 0x4de6bd46,
  28907. 0x43efb04d,
  28908. 0x51f4a750,
  28909. 0x5ffdaa5b,
  28910. 0x75c2896a,
  28911. 0x7bcb8461,
  28912. 0x69d0937c,
  28913. 0x67d99e77,
  28914. 0x3daed51e,
  28915. 0x33a7d815,
  28916. 0x21bccf08,
  28917. 0x2fb5c203,
  28918. 0x058ae132,
  28919. 0x0b83ec39,
  28920. 0x1998fb24,
  28921. 0x1791f62f,
  28922. 0x764dd68d,
  28923. 0x7844db86,
  28924. 0x6a5fcc9b,
  28925. 0x6456c190,
  28926. 0x4e69e2a1,
  28927. 0x4060efaa,
  28928. 0x527bf8b7,
  28929. 0x5c72f5bc,
  28930. 0x0605bed5,
  28931. 0x080cb3de,
  28932. 0x1a17a4c3,
  28933. 0x141ea9c8,
  28934. 0x3e218af9,
  28935. 0x302887f2,
  28936. 0x223390ef,
  28937. 0x2c3a9de4,
  28938. 0x96dd063d,
  28939. 0x98d40b36,
  28940. 0x8acf1c2b,
  28941. 0x84c61120,
  28942. 0xaef93211,
  28943. 0xa0f03f1a,
  28944. 0xb2eb2807,
  28945. 0xbce2250c,
  28946. 0xe6956e65,
  28947. 0xe89c636e,
  28948. 0xfa877473,
  28949. 0xf48e7978,
  28950. 0xdeb15a49,
  28951. 0xd0b85742,
  28952. 0xc2a3405f,
  28953. 0xccaa4d54,
  28954. 0x41ecdaf7,
  28955. 0x4fe5d7fc,
  28956. 0x5dfec0e1,
  28957. 0x53f7cdea,
  28958. 0x79c8eedb,
  28959. 0x77c1e3d0,
  28960. 0x65daf4cd,
  28961. 0x6bd3f9c6,
  28962. 0x31a4b2af,
  28963. 0x3fadbfa4,
  28964. 0x2db6a8b9,
  28965. 0x23bfa5b2,
  28966. 0x09808683,
  28967. 0x07898b88,
  28968. 0x15929c95,
  28969. 0x1b9b919e,
  28970. 0xa17c0a47,
  28971. 0xaf75074c,
  28972. 0xbd6e1051,
  28973. 0xb3671d5a,
  28974. 0x99583e6b,
  28975. 0x97513360,
  28976. 0x854a247d,
  28977. 0x8b432976,
  28978. 0xd134621f,
  28979. 0xdf3d6f14,
  28980. 0xcd267809,
  28981. 0xc32f7502,
  28982. 0xe9105633,
  28983. 0xe7195b38,
  28984. 0xf5024c25,
  28985. 0xfb0b412e,
  28986. 0x9ad7618c,
  28987. 0x94de6c87,
  28988. 0x86c57b9a,
  28989. 0x88cc7691,
  28990. 0xa2f355a0,
  28991. 0xacfa58ab,
  28992. 0xbee14fb6,
  28993. 0xb0e842bd,
  28994. 0xea9f09d4,
  28995. 0xe49604df,
  28996. 0xf68d13c2,
  28997. 0xf8841ec9,
  28998. 0xd2bb3df8,
  28999. 0xdcb230f3,
  29000. 0xcea927ee,
  29001. 0xc0a02ae5,
  29002. 0x7a47b13c,
  29003. 0x744ebc37,
  29004. 0x6655ab2a,
  29005. 0x685ca621,
  29006. 0x42638510,
  29007. 0x4c6a881b,
  29008. 0x5e719f06,
  29009. 0x5078920d,
  29010. 0x0a0fd964,
  29011. 0x0406d46f,
  29012. 0x161dc372,
  29013. 0x1814ce79,
  29014. 0x322bed48,
  29015. 0x3c22e043,
  29016. 0x2e39f75e,
  29017. 0x2030fa55,
  29018. 0xec9ab701,
  29019. 0xe293ba0a,
  29020. 0xf088ad17,
  29021. 0xfe81a01c,
  29022. 0xd4be832d,
  29023. 0xdab78e26,
  29024. 0xc8ac993b,
  29025. 0xc6a59430,
  29026. 0x9cd2df59,
  29027. 0x92dbd252,
  29028. 0x80c0c54f,
  29029. 0x8ec9c844,
  29030. 0xa4f6eb75,
  29031. 0xaaffe67e,
  29032. 0xb8e4f163,
  29033. 0xb6edfc68,
  29034. 0x0c0a67b1,
  29035. 0x02036aba,
  29036. 0x10187da7,
  29037. 0x1e1170ac,
  29038. 0x342e539d,
  29039. 0x3a275e96,
  29040. 0x283c498b,
  29041. 0x26354480,
  29042. 0x7c420fe9,
  29043. 0x724b02e2,
  29044. 0x605015ff,
  29045. 0x6e5918f4,
  29046. 0x44663bc5,
  29047. 0x4a6f36ce,
  29048. 0x587421d3,
  29049. 0x567d2cd8,
  29050. 0x37a10c7a,
  29051. 0x39a80171,
  29052. 0x2bb3166c,
  29053. 0x25ba1b67,
  29054. 0x0f853856,
  29055. 0x018c355d,
  29056. 0x13972240,
  29057. 0x1d9e2f4b,
  29058. 0x47e96422,
  29059. 0x49e06929,
  29060. 0x5bfb7e34,
  29061. 0x55f2733f,
  29062. 0x7fcd500e,
  29063. 0x71c45d05,
  29064. 0x63df4a18,
  29065. 0x6dd64713,
  29066. 0xd731dcca,
  29067. 0xd938d1c1,
  29068. 0xcb23c6dc,
  29069. 0xc52acbd7,
  29070. 0xef15e8e6,
  29071. 0xe11ce5ed,
  29072. 0xf307f2f0,
  29073. 0xfd0efffb,
  29074. 0xa779b492,
  29075. 0xa970b999,
  29076. 0xbb6bae84,
  29077. 0xb562a38f,
  29078. 0x9f5d80be,
  29079. 0x91548db5,
  29080. 0x834f9aa8,
  29081. 0x8d4697a3
  29082. ]);
  29083. function expandKey256(cipherKey) {
  29084. var b = 240, result = new Uint8Array(b);
  29085. var r = 1;
  29086. result.set(cipherKey);
  29087. for (var j = 32, i = 1; j < b; ++i) {
  29088. if (j % 32 === 16) {
  29089. t1 = s[t1];
  29090. t2 = s[t2];
  29091. t3 = s[t3];
  29092. t4 = s[t4];
  29093. } else if (j % 32 === 0) {
  29094. var t1 = result[j - 3], t2 = result[j - 2], t3 = result[j - 1], t4 = result[j - 4];
  29095. t1 = s[t1];
  29096. t2 = s[t2];
  29097. t3 = s[t3];
  29098. t4 = s[t4];
  29099. t1 = t1 ^ r;
  29100. if ((r <<= 1) >= 256) {
  29101. r = (r ^ 0x1b) & 0xFF;
  29102. }
  29103. }
  29104. for (var n = 0; n < 4; ++n) {
  29105. result[j] = t1 ^= result[j - 32];
  29106. j++;
  29107. result[j] = t2 ^= result[j - 32];
  29108. j++;
  29109. result[j] = t3 ^= result[j - 32];
  29110. j++;
  29111. result[j] = t4 ^= result[j - 32];
  29112. j++;
  29113. }
  29114. }
  29115. return result;
  29116. }
  29117. function decrypt256(input, key) {
  29118. var state = new Uint8Array(16);
  29119. state.set(input);
  29120. var i, j, k;
  29121. var t, u, v;
  29122. for (j = 0, k = 224; j < 16; ++j, ++k) {
  29123. state[j] ^= key[k];
  29124. }
  29125. for (i = 13; i >= 1; --i) {
  29126. t = state[13];
  29127. state[13] = state[9];
  29128. state[9] = state[5];
  29129. state[5] = state[1];
  29130. state[1] = t;
  29131. t = state[14];
  29132. u = state[10];
  29133. state[14] = state[6];
  29134. state[10] = state[2];
  29135. state[6] = t;
  29136. state[2] = u;
  29137. t = state[15];
  29138. u = state[11];
  29139. v = state[7];
  29140. state[15] = state[3];
  29141. state[11] = t;
  29142. state[7] = u;
  29143. state[3] = v;
  29144. for (j = 0; j < 16; ++j) {
  29145. state[j] = inv_s[state[j]];
  29146. }
  29147. for (j = 0, k = i * 16; j < 16; ++j, ++k) {
  29148. state[j] ^= key[k];
  29149. }
  29150. for (j = 0; j < 16; j += 4) {
  29151. var s0 = mix[state[j]], s1 = mix[state[j + 1]], s2 = mix[state[j + 2]], s3 = mix[state[j + 3]];
  29152. t = s0 ^ s1 >>> 8 ^ s1 << 24 ^ s2 >>> 16 ^ s2 << 16 ^ s3 >>> 24 ^ s3 << 8;
  29153. state[j] = t >>> 24 & 0xFF;
  29154. state[j + 1] = t >> 16 & 0xFF;
  29155. state[j + 2] = t >> 8 & 0xFF;
  29156. state[j + 3] = t & 0xFF;
  29157. }
  29158. }
  29159. t = state[13];
  29160. state[13] = state[9];
  29161. state[9] = state[5];
  29162. state[5] = state[1];
  29163. state[1] = t;
  29164. t = state[14];
  29165. u = state[10];
  29166. state[14] = state[6];
  29167. state[10] = state[2];
  29168. state[6] = t;
  29169. state[2] = u;
  29170. t = state[15];
  29171. u = state[11];
  29172. v = state[7];
  29173. state[15] = state[3];
  29174. state[11] = t;
  29175. state[7] = u;
  29176. state[3] = v;
  29177. for (j = 0; j < 16; ++j) {
  29178. state[j] = inv_s[state[j]];
  29179. state[j] ^= key[j];
  29180. }
  29181. return state;
  29182. }
  29183. function encrypt256(input, key) {
  29184. var t, u, v, k;
  29185. var state = new Uint8Array(16);
  29186. state.set(input);
  29187. for (j = 0; j < 16; ++j) {
  29188. state[j] ^= key[j];
  29189. }
  29190. for (i = 1; i < 14; i++) {
  29191. for (j = 0; j < 16; ++j) {
  29192. state[j] = s[state[j]];
  29193. }
  29194. v = state[1];
  29195. state[1] = state[5];
  29196. state[5] = state[9];
  29197. state[9] = state[13];
  29198. state[13] = v;
  29199. v = state[2];
  29200. u = state[6];
  29201. state[2] = state[10];
  29202. state[6] = state[14];
  29203. state[10] = v;
  29204. state[14] = u;
  29205. v = state[3];
  29206. u = state[7];
  29207. t = state[11];
  29208. state[3] = state[15];
  29209. state[7] = v;
  29210. state[11] = u;
  29211. state[15] = t;
  29212. for (var j = 0; j < 16; j += 4) {
  29213. var s0 = state[j + 0], s1 = state[j + 1];
  29214. var s2 = state[j + 2], s3 = state[j + 3];
  29215. t = s0 ^ s1 ^ s2 ^ s3;
  29216. state[j + 0] ^= t ^ mixCol[s0 ^ s1];
  29217. state[j + 1] ^= t ^ mixCol[s1 ^ s2];
  29218. state[j + 2] ^= t ^ mixCol[s2 ^ s3];
  29219. state[j + 3] ^= t ^ mixCol[s3 ^ s0];
  29220. }
  29221. for (j = 0, k = i * 16; j < 16; ++j, ++k) {
  29222. state[j] ^= key[k];
  29223. }
  29224. }
  29225. for (j = 0; j < 16; ++j) {
  29226. state[j] = s[state[j]];
  29227. }
  29228. v = state[1];
  29229. state[1] = state[5];
  29230. state[5] = state[9];
  29231. state[9] = state[13];
  29232. state[13] = v;
  29233. v = state[2];
  29234. u = state[6];
  29235. state[2] = state[10];
  29236. state[6] = state[14];
  29237. state[10] = v;
  29238. state[14] = u;
  29239. v = state[3];
  29240. u = state[7];
  29241. t = state[11];
  29242. state[3] = state[15];
  29243. state[7] = v;
  29244. state[11] = u;
  29245. state[15] = t;
  29246. for (j = 0, k = 224; j < 16; ++j, ++k) {
  29247. state[j] ^= key[k];
  29248. }
  29249. return state;
  29250. }
  29251. function AES256Cipher(key) {
  29252. this.key = expandKey256(key);
  29253. this.buffer = new Uint8Array(16);
  29254. this.bufferPosition = 0;
  29255. }
  29256. function decryptBlock2(data, finalize) {
  29257. var i, j, ii, sourceLength = data.length, buffer = this.buffer, bufferLength = this.bufferPosition, result = [], iv = this.iv;
  29258. for (i = 0; i < sourceLength; ++i) {
  29259. buffer[bufferLength] = data[i];
  29260. ++bufferLength;
  29261. if (bufferLength < 16) {
  29262. continue;
  29263. }
  29264. var plain = decrypt256(buffer, this.key);
  29265. for (j = 0; j < 16; ++j) {
  29266. plain[j] ^= iv[j];
  29267. }
  29268. iv = buffer;
  29269. result.push(plain);
  29270. buffer = new Uint8Array(16);
  29271. bufferLength = 0;
  29272. }
  29273. this.buffer = buffer;
  29274. this.bufferLength = bufferLength;
  29275. this.iv = iv;
  29276. if (result.length === 0) {
  29277. return new Uint8Array([]);
  29278. }
  29279. var outputLength = 16 * result.length;
  29280. if (finalize) {
  29281. var lastBlock = result[result.length - 1];
  29282. var psLen = lastBlock[15];
  29283. if (psLen <= 16) {
  29284. for (i = 15, ii = 16 - psLen; i >= ii; --i) {
  29285. if (lastBlock[i] !== psLen) {
  29286. psLen = 0;
  29287. break;
  29288. }
  29289. }
  29290. outputLength -= psLen;
  29291. result[result.length - 1] = lastBlock.subarray(0, 16 - psLen);
  29292. }
  29293. }
  29294. var output = new Uint8Array(outputLength);
  29295. for (i = 0, j = 0, ii = result.length; i < ii; ++i, j += 16) {
  29296. output.set(result[i], j);
  29297. }
  29298. return output;
  29299. }
  29300. AES256Cipher.prototype = {
  29301. decryptBlock: function AES256Cipher_decryptBlock(data, finalize, iv) {
  29302. var i, sourceLength = data.length;
  29303. var buffer = this.buffer, bufferLength = this.bufferPosition;
  29304. if (iv) {
  29305. this.iv = iv;
  29306. } else {
  29307. for (i = 0; bufferLength < 16 && i < sourceLength; ++i, ++bufferLength) {
  29308. buffer[bufferLength] = data[i];
  29309. }
  29310. if (bufferLength < 16) {
  29311. this.bufferLength = bufferLength;
  29312. return new Uint8Array([]);
  29313. }
  29314. this.iv = buffer;
  29315. data = data.subarray(16);
  29316. }
  29317. this.buffer = new Uint8Array(16);
  29318. this.bufferLength = 0;
  29319. this.decryptBlock = decryptBlock2;
  29320. return this.decryptBlock(data, finalize);
  29321. },
  29322. encrypt: function AES256Cipher_encrypt(data, iv) {
  29323. var i, j, ii, sourceLength = data.length, buffer = this.buffer, bufferLength = this.bufferPosition, result = [];
  29324. if (!iv) {
  29325. iv = new Uint8Array(16);
  29326. }
  29327. for (i = 0; i < sourceLength; ++i) {
  29328. buffer[bufferLength] = data[i];
  29329. ++bufferLength;
  29330. if (bufferLength < 16) {
  29331. continue;
  29332. }
  29333. for (j = 0; j < 16; ++j) {
  29334. buffer[j] ^= iv[j];
  29335. }
  29336. var cipher = encrypt256(buffer, this.key);
  29337. this.iv = cipher;
  29338. result.push(cipher);
  29339. buffer = new Uint8Array(16);
  29340. bufferLength = 0;
  29341. }
  29342. this.buffer = buffer;
  29343. this.bufferLength = bufferLength;
  29344. this.iv = iv;
  29345. if (result.length === 0) {
  29346. return new Uint8Array([]);
  29347. }
  29348. var outputLength = 16 * result.length;
  29349. var output = new Uint8Array(outputLength);
  29350. for (i = 0, j = 0, ii = result.length; i < ii; ++i, j += 16) {
  29351. output.set(result[i], j);
  29352. }
  29353. return output;
  29354. }
  29355. };
  29356. return AES256Cipher;
  29357. }();
  29358. var PDF17 = function PDF17Closure() {
  29359. function compareByteArrays(array1, array2) {
  29360. if (array1.length !== array2.length) {
  29361. return false;
  29362. }
  29363. for (var i = 0; i < array1.length; i++) {
  29364. if (array1[i] !== array2[i]) {
  29365. return false;
  29366. }
  29367. }
  29368. return true;
  29369. }
  29370. function PDF17() {
  29371. }
  29372. PDF17.prototype = {
  29373. checkOwnerPassword: function PDF17_checkOwnerPassword(password, ownerValidationSalt, userBytes, ownerPassword) {
  29374. var hashData = new Uint8Array(password.length + 56);
  29375. hashData.set(password, 0);
  29376. hashData.set(ownerValidationSalt, password.length);
  29377. hashData.set(userBytes, password.length + ownerValidationSalt.length);
  29378. var result = calculateSHA256(hashData, 0, hashData.length);
  29379. return compareByteArrays(result, ownerPassword);
  29380. },
  29381. checkUserPassword: function PDF17_checkUserPassword(password, userValidationSalt, userPassword) {
  29382. var hashData = new Uint8Array(password.length + 8);
  29383. hashData.set(password, 0);
  29384. hashData.set(userValidationSalt, password.length);
  29385. var result = calculateSHA256(hashData, 0, hashData.length);
  29386. return compareByteArrays(result, userPassword);
  29387. },
  29388. getOwnerKey: function PDF17_getOwnerKey(password, ownerKeySalt, userBytes, ownerEncryption) {
  29389. var hashData = new Uint8Array(password.length + 56);
  29390. hashData.set(password, 0);
  29391. hashData.set(ownerKeySalt, password.length);
  29392. hashData.set(userBytes, password.length + ownerKeySalt.length);
  29393. var key = calculateSHA256(hashData, 0, hashData.length);
  29394. var cipher = new AES256Cipher(key);
  29395. return cipher.decryptBlock(ownerEncryption, false, new Uint8Array(16));
  29396. },
  29397. getUserKey: function PDF17_getUserKey(password, userKeySalt, userEncryption) {
  29398. var hashData = new Uint8Array(password.length + 8);
  29399. hashData.set(password, 0);
  29400. hashData.set(userKeySalt, password.length);
  29401. var key = calculateSHA256(hashData, 0, hashData.length);
  29402. var cipher = new AES256Cipher(key);
  29403. return cipher.decryptBlock(userEncryption, false, new Uint8Array(16));
  29404. }
  29405. };
  29406. return PDF17;
  29407. }();
  29408. var PDF20 = function PDF20Closure() {
  29409. function concatArrays(array1, array2) {
  29410. var t = new Uint8Array(array1.length + array2.length);
  29411. t.set(array1, 0);
  29412. t.set(array2, array1.length);
  29413. return t;
  29414. }
  29415. function calculatePDF20Hash(password, input, userBytes) {
  29416. var k = calculateSHA256(input, 0, input.length).subarray(0, 32);
  29417. var e = [0];
  29418. var i = 0;
  29419. while (i < 64 || e[e.length - 1] > i - 32) {
  29420. var arrayLength = password.length + k.length + userBytes.length;
  29421. var k1 = new Uint8Array(arrayLength * 64);
  29422. var array = concatArrays(password, k);
  29423. array = concatArrays(array, userBytes);
  29424. for (var j = 0, pos = 0; j < 64; j++, pos += arrayLength) {
  29425. k1.set(array, pos);
  29426. }
  29427. var cipher = new AES128Cipher(k.subarray(0, 16));
  29428. e = cipher.encrypt(k1, k.subarray(16, 32));
  29429. var remainder = 0;
  29430. for (var z = 0; z < 16; z++) {
  29431. remainder *= 256 % 3;
  29432. remainder %= 3;
  29433. remainder += (e[z] >>> 0) % 3;
  29434. remainder %= 3;
  29435. }
  29436. if (remainder === 0) {
  29437. k = calculateSHA256(e, 0, e.length);
  29438. } else if (remainder === 1) {
  29439. k = calculateSHA384(e, 0, e.length);
  29440. } else if (remainder === 2) {
  29441. k = calculateSHA512(e, 0, e.length);
  29442. }
  29443. i++;
  29444. }
  29445. return k.subarray(0, 32);
  29446. }
  29447. function PDF20() {
  29448. }
  29449. function compareByteArrays(array1, array2) {
  29450. if (array1.length !== array2.length) {
  29451. return false;
  29452. }
  29453. for (var i = 0; i < array1.length; i++) {
  29454. if (array1[i] !== array2[i]) {
  29455. return false;
  29456. }
  29457. }
  29458. return true;
  29459. }
  29460. PDF20.prototype = {
  29461. hash: function PDF20_hash(password, concatBytes, userBytes) {
  29462. return calculatePDF20Hash(password, concatBytes, userBytes);
  29463. },
  29464. checkOwnerPassword: function PDF20_checkOwnerPassword(password, ownerValidationSalt, userBytes, ownerPassword) {
  29465. var hashData = new Uint8Array(password.length + 56);
  29466. hashData.set(password, 0);
  29467. hashData.set(ownerValidationSalt, password.length);
  29468. hashData.set(userBytes, password.length + ownerValidationSalt.length);
  29469. var result = calculatePDF20Hash(password, hashData, userBytes);
  29470. return compareByteArrays(result, ownerPassword);
  29471. },
  29472. checkUserPassword: function PDF20_checkUserPassword(password, userValidationSalt, userPassword) {
  29473. var hashData = new Uint8Array(password.length + 8);
  29474. hashData.set(password, 0);
  29475. hashData.set(userValidationSalt, password.length);
  29476. var result = calculatePDF20Hash(password, hashData, []);
  29477. return compareByteArrays(result, userPassword);
  29478. },
  29479. getOwnerKey: function PDF20_getOwnerKey(password, ownerKeySalt, userBytes, ownerEncryption) {
  29480. var hashData = new Uint8Array(password.length + 56);
  29481. hashData.set(password, 0);
  29482. hashData.set(ownerKeySalt, password.length);
  29483. hashData.set(userBytes, password.length + ownerKeySalt.length);
  29484. var key = calculatePDF20Hash(password, hashData, userBytes);
  29485. var cipher = new AES256Cipher(key);
  29486. return cipher.decryptBlock(ownerEncryption, false, new Uint8Array(16));
  29487. },
  29488. getUserKey: function PDF20_getUserKey(password, userKeySalt, userEncryption) {
  29489. var hashData = new Uint8Array(password.length + 8);
  29490. hashData.set(password, 0);
  29491. hashData.set(userKeySalt, password.length);
  29492. var key = calculatePDF20Hash(password, hashData, []);
  29493. var cipher = new AES256Cipher(key);
  29494. return cipher.decryptBlock(userEncryption, false, new Uint8Array(16));
  29495. }
  29496. };
  29497. return PDF20;
  29498. }();
  29499. var CipherTransform = function CipherTransformClosure() {
  29500. function CipherTransform(stringCipherConstructor, streamCipherConstructor) {
  29501. this.StringCipherConstructor = stringCipherConstructor;
  29502. this.StreamCipherConstructor = streamCipherConstructor;
  29503. }
  29504. CipherTransform.prototype = {
  29505. createStream: function CipherTransform_createStream(stream, length) {
  29506. var cipher = new this.StreamCipherConstructor();
  29507. return new DecryptStream(stream, length, function cipherTransformDecryptStream(data, finalize) {
  29508. return cipher.decryptBlock(data, finalize);
  29509. });
  29510. },
  29511. decryptString: function CipherTransform_decryptString(s) {
  29512. var cipher = new this.StringCipherConstructor();
  29513. var data = stringToBytes(s);
  29514. data = cipher.decryptBlock(data, true);
  29515. return bytesToString(data);
  29516. }
  29517. };
  29518. return CipherTransform;
  29519. }();
  29520. var CipherTransformFactory = function CipherTransformFactoryClosure() {
  29521. var defaultPasswordBytes = new Uint8Array([
  29522. 0x28,
  29523. 0xBF,
  29524. 0x4E,
  29525. 0x5E,
  29526. 0x4E,
  29527. 0x75,
  29528. 0x8A,
  29529. 0x41,
  29530. 0x64,
  29531. 0x00,
  29532. 0x4E,
  29533. 0x56,
  29534. 0xFF,
  29535. 0xFA,
  29536. 0x01,
  29537. 0x08,
  29538. 0x2E,
  29539. 0x2E,
  29540. 0x00,
  29541. 0xB6,
  29542. 0xD0,
  29543. 0x68,
  29544. 0x3E,
  29545. 0x80,
  29546. 0x2F,
  29547. 0x0C,
  29548. 0xA9,
  29549. 0xFE,
  29550. 0x64,
  29551. 0x53,
  29552. 0x69,
  29553. 0x7A
  29554. ]);
  29555. function createEncryptionKey20(revision, password, ownerPassword, ownerValidationSalt, ownerKeySalt, uBytes, userPassword, userValidationSalt, userKeySalt, ownerEncryption, userEncryption, perms) {
  29556. if (password) {
  29557. var passwordLength = Math.min(127, password.length);
  29558. password = password.subarray(0, passwordLength);
  29559. } else {
  29560. password = [];
  29561. }
  29562. var pdfAlgorithm;
  29563. if (revision === 6) {
  29564. pdfAlgorithm = new PDF20();
  29565. } else {
  29566. pdfAlgorithm = new PDF17();
  29567. }
  29568. if (pdfAlgorithm.checkUserPassword(password, userValidationSalt, userPassword)) {
  29569. return pdfAlgorithm.getUserKey(password, userKeySalt, userEncryption);
  29570. } else if (password.length && pdfAlgorithm.checkOwnerPassword(password, ownerValidationSalt, uBytes, ownerPassword)) {
  29571. return pdfAlgorithm.getOwnerKey(password, ownerKeySalt, uBytes, ownerEncryption);
  29572. }
  29573. return null;
  29574. }
  29575. function prepareKeyData(fileId, password, ownerPassword, userPassword, flags, revision, keyLength, encryptMetadata) {
  29576. var hashDataSize = 40 + ownerPassword.length + fileId.length;
  29577. var hashData = new Uint8Array(hashDataSize), i = 0, j, n;
  29578. if (password) {
  29579. n = Math.min(32, password.length);
  29580. for (; i < n; ++i) {
  29581. hashData[i] = password[i];
  29582. }
  29583. }
  29584. j = 0;
  29585. while (i < 32) {
  29586. hashData[i++] = defaultPasswordBytes[j++];
  29587. }
  29588. for (j = 0, n = ownerPassword.length; j < n; ++j) {
  29589. hashData[i++] = ownerPassword[j];
  29590. }
  29591. hashData[i++] = flags & 0xFF;
  29592. hashData[i++] = flags >> 8 & 0xFF;
  29593. hashData[i++] = flags >> 16 & 0xFF;
  29594. hashData[i++] = flags >>> 24 & 0xFF;
  29595. for (j = 0, n = fileId.length; j < n; ++j) {
  29596. hashData[i++] = fileId[j];
  29597. }
  29598. if (revision >= 4 && !encryptMetadata) {
  29599. hashData[i++] = 0xFF;
  29600. hashData[i++] = 0xFF;
  29601. hashData[i++] = 0xFF;
  29602. hashData[i++] = 0xFF;
  29603. }
  29604. var hash = calculateMD5(hashData, 0, i);
  29605. var keyLengthInBytes = keyLength >> 3;
  29606. if (revision >= 3) {
  29607. for (j = 0; j < 50; ++j) {
  29608. hash = calculateMD5(hash, 0, keyLengthInBytes);
  29609. }
  29610. }
  29611. var encryptionKey = hash.subarray(0, keyLengthInBytes);
  29612. var cipher, checkData;
  29613. if (revision >= 3) {
  29614. for (i = 0; i < 32; ++i) {
  29615. hashData[i] = defaultPasswordBytes[i];
  29616. }
  29617. for (j = 0, n = fileId.length; j < n; ++j) {
  29618. hashData[i++] = fileId[j];
  29619. }
  29620. cipher = new ARCFourCipher(encryptionKey);
  29621. checkData = cipher.encryptBlock(calculateMD5(hashData, 0, i));
  29622. n = encryptionKey.length;
  29623. var derivedKey = new Uint8Array(n), k;
  29624. for (j = 1; j <= 19; ++j) {
  29625. for (k = 0; k < n; ++k) {
  29626. derivedKey[k] = encryptionKey[k] ^ j;
  29627. }
  29628. cipher = new ARCFourCipher(derivedKey);
  29629. checkData = cipher.encryptBlock(checkData);
  29630. }
  29631. for (j = 0, n = checkData.length; j < n; ++j) {
  29632. if (userPassword[j] !== checkData[j]) {
  29633. return null;
  29634. }
  29635. }
  29636. } else {
  29637. cipher = new ARCFourCipher(encryptionKey);
  29638. checkData = cipher.encryptBlock(defaultPasswordBytes);
  29639. for (j = 0, n = checkData.length; j < n; ++j) {
  29640. if (userPassword[j] !== checkData[j]) {
  29641. return null;
  29642. }
  29643. }
  29644. }
  29645. return encryptionKey;
  29646. }
  29647. function decodeUserPassword(password, ownerPassword, revision, keyLength) {
  29648. var hashData = new Uint8Array(32), i = 0, j, n;
  29649. n = Math.min(32, password.length);
  29650. for (; i < n; ++i) {
  29651. hashData[i] = password[i];
  29652. }
  29653. j = 0;
  29654. while (i < 32) {
  29655. hashData[i++] = defaultPasswordBytes[j++];
  29656. }
  29657. var hash = calculateMD5(hashData, 0, i);
  29658. var keyLengthInBytes = keyLength >> 3;
  29659. if (revision >= 3) {
  29660. for (j = 0; j < 50; ++j) {
  29661. hash = calculateMD5(hash, 0, hash.length);
  29662. }
  29663. }
  29664. var cipher, userPassword;
  29665. if (revision >= 3) {
  29666. userPassword = ownerPassword;
  29667. var derivedKey = new Uint8Array(keyLengthInBytes), k;
  29668. for (j = 19; j >= 0; j--) {
  29669. for (k = 0; k < keyLengthInBytes; ++k) {
  29670. derivedKey[k] = hash[k] ^ j;
  29671. }
  29672. cipher = new ARCFourCipher(derivedKey);
  29673. userPassword = cipher.encryptBlock(userPassword);
  29674. }
  29675. } else {
  29676. cipher = new ARCFourCipher(hash.subarray(0, keyLengthInBytes));
  29677. userPassword = cipher.encryptBlock(ownerPassword);
  29678. }
  29679. return userPassword;
  29680. }
  29681. var identityName = Name.get('Identity');
  29682. function CipherTransformFactory(dict, fileId, password) {
  29683. var filter = dict.get('Filter');
  29684. if (!isName(filter, 'Standard')) {
  29685. error('unknown encryption method');
  29686. }
  29687. this.dict = dict;
  29688. var algorithm = dict.get('V');
  29689. if (!isInt(algorithm) || algorithm !== 1 && algorithm !== 2 && algorithm !== 4 && algorithm !== 5) {
  29690. error('unsupported encryption algorithm');
  29691. }
  29692. this.algorithm = algorithm;
  29693. var keyLength = dict.get('Length');
  29694. if (!keyLength) {
  29695. if (algorithm <= 3) {
  29696. keyLength = 40;
  29697. } else {
  29698. var cfDict = dict.get('CF');
  29699. var streamCryptoName = dict.get('StmF');
  29700. if (isDict(cfDict) && isName(streamCryptoName)) {
  29701. cfDict.suppressEncryption = true;
  29702. var handlerDict = cfDict.get(streamCryptoName.name);
  29703. keyLength = handlerDict && handlerDict.get('Length') || 128;
  29704. if (keyLength < 40) {
  29705. keyLength <<= 3;
  29706. }
  29707. }
  29708. }
  29709. }
  29710. if (!isInt(keyLength) || keyLength < 40 || keyLength % 8 !== 0) {
  29711. error('invalid key length');
  29712. }
  29713. var ownerPassword = stringToBytes(dict.get('O')).subarray(0, 32);
  29714. var userPassword = stringToBytes(dict.get('U')).subarray(0, 32);
  29715. var flags = dict.get('P');
  29716. var revision = dict.get('R');
  29717. var encryptMetadata = (algorithm === 4 || algorithm === 5) && dict.get('EncryptMetadata') !== false;
  29718. this.encryptMetadata = encryptMetadata;
  29719. var fileIdBytes = stringToBytes(fileId);
  29720. var passwordBytes;
  29721. if (password) {
  29722. if (revision === 6) {
  29723. try {
  29724. password = utf8StringToString(password);
  29725. } catch (ex) {
  29726. warn('CipherTransformFactory: ' + 'Unable to convert UTF8 encoded password.');
  29727. }
  29728. }
  29729. passwordBytes = stringToBytes(password);
  29730. }
  29731. var encryptionKey;
  29732. if (algorithm !== 5) {
  29733. encryptionKey = prepareKeyData(fileIdBytes, passwordBytes, ownerPassword, userPassword, flags, revision, keyLength, encryptMetadata);
  29734. } else {
  29735. var ownerValidationSalt = stringToBytes(dict.get('O')).subarray(32, 40);
  29736. var ownerKeySalt = stringToBytes(dict.get('O')).subarray(40, 48);
  29737. var uBytes = stringToBytes(dict.get('U')).subarray(0, 48);
  29738. var userValidationSalt = stringToBytes(dict.get('U')).subarray(32, 40);
  29739. var userKeySalt = stringToBytes(dict.get('U')).subarray(40, 48);
  29740. var ownerEncryption = stringToBytes(dict.get('OE'));
  29741. var userEncryption = stringToBytes(dict.get('UE'));
  29742. var perms = stringToBytes(dict.get('Perms'));
  29743. encryptionKey = createEncryptionKey20(revision, passwordBytes, ownerPassword, ownerValidationSalt, ownerKeySalt, uBytes, userPassword, userValidationSalt, userKeySalt, ownerEncryption, userEncryption, perms);
  29744. }
  29745. if (!encryptionKey && !password) {
  29746. throw new PasswordException('No password given', PasswordResponses.NEED_PASSWORD);
  29747. } else if (!encryptionKey && password) {
  29748. var decodedPassword = decodeUserPassword(passwordBytes, ownerPassword, revision, keyLength);
  29749. encryptionKey = prepareKeyData(fileIdBytes, decodedPassword, ownerPassword, userPassword, flags, revision, keyLength, encryptMetadata);
  29750. }
  29751. if (!encryptionKey) {
  29752. throw new PasswordException('Incorrect Password', PasswordResponses.INCORRECT_PASSWORD);
  29753. }
  29754. this.encryptionKey = encryptionKey;
  29755. if (algorithm >= 4) {
  29756. var cf = dict.get('CF');
  29757. if (isDict(cf)) {
  29758. cf.suppressEncryption = true;
  29759. }
  29760. this.cf = cf;
  29761. this.stmf = dict.get('StmF') || identityName;
  29762. this.strf = dict.get('StrF') || identityName;
  29763. this.eff = dict.get('EFF') || this.stmf;
  29764. }
  29765. }
  29766. function buildObjectKey(num, gen, encryptionKey, isAes) {
  29767. var key = new Uint8Array(encryptionKey.length + 9), i, n;
  29768. for (i = 0, n = encryptionKey.length; i < n; ++i) {
  29769. key[i] = encryptionKey[i];
  29770. }
  29771. key[i++] = num & 0xFF;
  29772. key[i++] = num >> 8 & 0xFF;
  29773. key[i++] = num >> 16 & 0xFF;
  29774. key[i++] = gen & 0xFF;
  29775. key[i++] = gen >> 8 & 0xFF;
  29776. if (isAes) {
  29777. key[i++] = 0x73;
  29778. key[i++] = 0x41;
  29779. key[i++] = 0x6C;
  29780. key[i++] = 0x54;
  29781. }
  29782. var hash = calculateMD5(key, 0, i);
  29783. return hash.subarray(0, Math.min(encryptionKey.length + 5, 16));
  29784. }
  29785. function buildCipherConstructor(cf, name, num, gen, key) {
  29786. assert(isName(name), 'Invalid crypt filter name.');
  29787. var cryptFilter = cf.get(name.name);
  29788. var cfm;
  29789. if (cryptFilter !== null && cryptFilter !== undefined) {
  29790. cfm = cryptFilter.get('CFM');
  29791. }
  29792. if (!cfm || cfm.name === 'None') {
  29793. return function cipherTransformFactoryBuildCipherConstructorNone() {
  29794. return new NullCipher();
  29795. };
  29796. }
  29797. if (cfm.name === 'V2') {
  29798. return function cipherTransformFactoryBuildCipherConstructorV2() {
  29799. return new ARCFourCipher(buildObjectKey(num, gen, key, false));
  29800. };
  29801. }
  29802. if (cfm.name === 'AESV2') {
  29803. return function cipherTransformFactoryBuildCipherConstructorAESV2() {
  29804. return new AES128Cipher(buildObjectKey(num, gen, key, true));
  29805. };
  29806. }
  29807. if (cfm.name === 'AESV3') {
  29808. return function cipherTransformFactoryBuildCipherConstructorAESV3() {
  29809. return new AES256Cipher(key);
  29810. };
  29811. }
  29812. error('Unknown crypto method');
  29813. }
  29814. CipherTransformFactory.prototype = {
  29815. createCipherTransform: function CipherTransformFactory_createCipherTransform(num, gen) {
  29816. if (this.algorithm === 4 || this.algorithm === 5) {
  29817. return new CipherTransform(buildCipherConstructor(this.cf, this.stmf, num, gen, this.encryptionKey), buildCipherConstructor(this.cf, this.strf, num, gen, this.encryptionKey));
  29818. }
  29819. var key = buildObjectKey(num, gen, this.encryptionKey, false);
  29820. var cipherConstructor = function buildCipherCipherConstructor() {
  29821. return new ARCFourCipher(key);
  29822. };
  29823. return new CipherTransform(cipherConstructor, cipherConstructor);
  29824. }
  29825. };
  29826. return CipherTransformFactory;
  29827. }();
  29828. exports.AES128Cipher = AES128Cipher;
  29829. exports.AES256Cipher = AES256Cipher;
  29830. exports.ARCFourCipher = ARCFourCipher;
  29831. exports.CipherTransformFactory = CipherTransformFactory;
  29832. exports.PDF17 = PDF17;
  29833. exports.PDF20 = PDF20;
  29834. exports.calculateMD5 = calculateMD5;
  29835. exports.calculateSHA256 = calculateSHA256;
  29836. exports.calculateSHA384 = calculateSHA384;
  29837. exports.calculateSHA512 = calculateSHA512;
  29838. /***/ }),
  29839. /* 18 */
  29840. /***/ (function(module, exports, __w_pdfjs_require__) {
  29841. "use strict";
  29842. var sharedUtil = __w_pdfjs_require__(0);
  29843. var corePrimitives = __w_pdfjs_require__(1);
  29844. var coreStream = __w_pdfjs_require__(2);
  29845. var coreParser = __w_pdfjs_require__(6);
  29846. var coreImage = __w_pdfjs_require__(36);
  29847. var coreColorSpace = __w_pdfjs_require__(4);
  29848. var coreMurmurHash3 = __w_pdfjs_require__(40);
  29849. var coreFonts = __w_pdfjs_require__(35);
  29850. var coreFunction = __w_pdfjs_require__(7);
  29851. var corePattern = __w_pdfjs_require__(41);
  29852. var coreCMap = __w_pdfjs_require__(32);
  29853. var coreMetrics = __w_pdfjs_require__(39);
  29854. var coreBidi = __w_pdfjs_require__(30);
  29855. var coreEncodings = __w_pdfjs_require__(5);
  29856. var coreStandardFonts = __w_pdfjs_require__(21);
  29857. var coreUnicode = __w_pdfjs_require__(22);
  29858. var coreGlyphList = __w_pdfjs_require__(8);
  29859. var FONT_IDENTITY_MATRIX = sharedUtil.FONT_IDENTITY_MATRIX;
  29860. var IDENTITY_MATRIX = sharedUtil.IDENTITY_MATRIX;
  29861. var UNSUPPORTED_FEATURES = sharedUtil.UNSUPPORTED_FEATURES;
  29862. var ImageKind = sharedUtil.ImageKind;
  29863. var OPS = sharedUtil.OPS;
  29864. var TextRenderingMode = sharedUtil.TextRenderingMode;
  29865. var Util = sharedUtil.Util;
  29866. var assert = sharedUtil.assert;
  29867. var createPromiseCapability = sharedUtil.createPromiseCapability;
  29868. var error = sharedUtil.error;
  29869. var info = sharedUtil.info;
  29870. var isArray = sharedUtil.isArray;
  29871. var isNum = sharedUtil.isNum;
  29872. var isString = sharedUtil.isString;
  29873. var getLookupTableFactory = sharedUtil.getLookupTableFactory;
  29874. var warn = sharedUtil.warn;
  29875. var Dict = corePrimitives.Dict;
  29876. var Name = corePrimitives.Name;
  29877. var isEOF = corePrimitives.isEOF;
  29878. var isCmd = corePrimitives.isCmd;
  29879. var isDict = corePrimitives.isDict;
  29880. var isName = corePrimitives.isName;
  29881. var isRef = corePrimitives.isRef;
  29882. var isStream = corePrimitives.isStream;
  29883. var DecodeStream = coreStream.DecodeStream;
  29884. var JpegStream = coreStream.JpegStream;
  29885. var Stream = coreStream.Stream;
  29886. var Lexer = coreParser.Lexer;
  29887. var Parser = coreParser.Parser;
  29888. var PDFImage = coreImage.PDFImage;
  29889. var ColorSpace = coreColorSpace.ColorSpace;
  29890. var MurmurHash3_64 = coreMurmurHash3.MurmurHash3_64;
  29891. var ErrorFont = coreFonts.ErrorFont;
  29892. var FontFlags = coreFonts.FontFlags;
  29893. var Font = coreFonts.Font;
  29894. var IdentityToUnicodeMap = coreFonts.IdentityToUnicodeMap;
  29895. var ToUnicodeMap = coreFonts.ToUnicodeMap;
  29896. var getFontType = coreFonts.getFontType;
  29897. var isPDFFunction = coreFunction.isPDFFunction;
  29898. var PDFFunction = coreFunction.PDFFunction;
  29899. var Pattern = corePattern.Pattern;
  29900. var getTilingPatternIR = corePattern.getTilingPatternIR;
  29901. var CMapFactory = coreCMap.CMapFactory;
  29902. var IdentityCMap = coreCMap.IdentityCMap;
  29903. var getMetrics = coreMetrics.getMetrics;
  29904. var bidi = coreBidi.bidi;
  29905. var WinAnsiEncoding = coreEncodings.WinAnsiEncoding;
  29906. var StandardEncoding = coreEncodings.StandardEncoding;
  29907. var MacRomanEncoding = coreEncodings.MacRomanEncoding;
  29908. var SymbolSetEncoding = coreEncodings.SymbolSetEncoding;
  29909. var ZapfDingbatsEncoding = coreEncodings.ZapfDingbatsEncoding;
  29910. var getEncoding = coreEncodings.getEncoding;
  29911. var getStdFontMap = coreStandardFonts.getStdFontMap;
  29912. var getSerifFonts = coreStandardFonts.getSerifFonts;
  29913. var getSymbolsFonts = coreStandardFonts.getSymbolsFonts;
  29914. var getNormalizedUnicodes = coreUnicode.getNormalizedUnicodes;
  29915. var reverseIfRtl = coreUnicode.reverseIfRtl;
  29916. var getUnicodeForGlyph = coreUnicode.getUnicodeForGlyph;
  29917. var getGlyphsUnicode = coreGlyphList.getGlyphsUnicode;
  29918. var PartialEvaluator = function PartialEvaluatorClosure() {
  29919. var DefaultPartialEvaluatorOptions = {
  29920. forceDataSchema: false,
  29921. maxImageSize: -1,
  29922. disableFontFace: false,
  29923. cMapOptions: {
  29924. url: null,
  29925. packed: false
  29926. },
  29927. disableNativeImageDecoder: false
  29928. };
  29929. function NativeImageDecoder(xref, resources, handler, forceDataSchema) {
  29930. this.xref = xref;
  29931. this.resources = resources;
  29932. this.handler = handler;
  29933. this.forceDataSchema = forceDataSchema;
  29934. }
  29935. NativeImageDecoder.prototype = {
  29936. canDecode: function (image) {
  29937. return image instanceof JpegStream && NativeImageDecoder.isDecodable(image, this.xref, this.resources);
  29938. },
  29939. decode: function (image) {
  29940. var dict = image.dict;
  29941. var colorSpace = dict.get('ColorSpace', 'CS');
  29942. colorSpace = ColorSpace.parse(colorSpace, this.xref, this.resources);
  29943. var numComps = colorSpace.numComps;
  29944. var decodePromise = this.handler.sendWithPromise('JpegDecode', [
  29945. image.getIR(this.forceDataSchema),
  29946. numComps
  29947. ]);
  29948. return decodePromise.then(function (message) {
  29949. var data = message.data;
  29950. return new Stream(data, 0, data.length, image.dict);
  29951. });
  29952. }
  29953. };
  29954. NativeImageDecoder.isSupported = function NativeImageDecoder_isSupported(image, xref, res) {
  29955. var dict = image.dict;
  29956. if (dict.has('DecodeParms') || dict.has('DP')) {
  29957. return false;
  29958. }
  29959. var cs = ColorSpace.parse(dict.get('ColorSpace', 'CS'), xref, res);
  29960. return (cs.name === 'DeviceGray' || cs.name === 'DeviceRGB') && cs.isDefaultDecode(dict.getArray('Decode', 'D'));
  29961. };
  29962. NativeImageDecoder.isDecodable = function NativeImageDecoder_isDecodable(image, xref, res) {
  29963. var dict = image.dict;
  29964. if (dict.has('DecodeParms') || dict.has('DP')) {
  29965. return false;
  29966. }
  29967. var cs = ColorSpace.parse(dict.get('ColorSpace', 'CS'), xref, res);
  29968. return (cs.numComps === 1 || cs.numComps === 3) && cs.isDefaultDecode(dict.getArray('Decode', 'D'));
  29969. };
  29970. function PartialEvaluator(pdfManager, xref, handler, pageIndex, idFactory, fontCache, options) {
  29971. this.pdfManager = pdfManager;
  29972. this.xref = xref;
  29973. this.handler = handler;
  29974. this.pageIndex = pageIndex;
  29975. this.idFactory = idFactory;
  29976. this.fontCache = fontCache;
  29977. this.options = options || DefaultPartialEvaluatorOptions;
  29978. }
  29979. var TIME_SLOT_DURATION_MS = 20;
  29980. var CHECK_TIME_EVERY = 100;
  29981. function TimeSlotManager() {
  29982. this.reset();
  29983. }
  29984. TimeSlotManager.prototype = {
  29985. check: function TimeSlotManager_check() {
  29986. if (++this.checked < CHECK_TIME_EVERY) {
  29987. return false;
  29988. }
  29989. this.checked = 0;
  29990. return this.endTime <= Date.now();
  29991. },
  29992. reset: function TimeSlotManager_reset() {
  29993. this.endTime = Date.now() + TIME_SLOT_DURATION_MS;
  29994. this.checked = 0;
  29995. }
  29996. };
  29997. var deferred = Promise.resolve();
  29998. var TILING_PATTERN = 1, SHADING_PATTERN = 2;
  29999. PartialEvaluator.prototype = {
  30000. hasBlendModes: function PartialEvaluator_hasBlendModes(resources) {
  30001. if (!isDict(resources)) {
  30002. return false;
  30003. }
  30004. var processed = Object.create(null);
  30005. if (resources.objId) {
  30006. processed[resources.objId] = true;
  30007. }
  30008. var nodes = [resources], xref = this.xref;
  30009. while (nodes.length) {
  30010. var key, i, ii;
  30011. var node = nodes.shift();
  30012. var graphicStates = node.get('ExtGState');
  30013. if (isDict(graphicStates)) {
  30014. var graphicStatesKeys = graphicStates.getKeys();
  30015. for (i = 0, ii = graphicStatesKeys.length; i < ii; i++) {
  30016. key = graphicStatesKeys[i];
  30017. var graphicState = graphicStates.get(key);
  30018. var bm = graphicState.get('BM');
  30019. if (isName(bm) && bm.name !== 'Normal') {
  30020. return true;
  30021. }
  30022. }
  30023. }
  30024. var xObjects = node.get('XObject');
  30025. if (!isDict(xObjects)) {
  30026. continue;
  30027. }
  30028. var xObjectsKeys = xObjects.getKeys();
  30029. for (i = 0, ii = xObjectsKeys.length; i < ii; i++) {
  30030. key = xObjectsKeys[i];
  30031. var xObject = xObjects.getRaw(key);
  30032. if (isRef(xObject)) {
  30033. if (processed[xObject.toString()]) {
  30034. continue;
  30035. }
  30036. xObject = xref.fetch(xObject);
  30037. }
  30038. if (!isStream(xObject)) {
  30039. continue;
  30040. }
  30041. if (xObject.dict.objId) {
  30042. if (processed[xObject.dict.objId]) {
  30043. continue;
  30044. }
  30045. processed[xObject.dict.objId] = true;
  30046. }
  30047. var xResources = xObject.dict.get('Resources');
  30048. if (isDict(xResources) && (!xResources.objId || !processed[xResources.objId])) {
  30049. nodes.push(xResources);
  30050. if (xResources.objId) {
  30051. processed[xResources.objId] = true;
  30052. }
  30053. }
  30054. }
  30055. }
  30056. return false;
  30057. },
  30058. buildFormXObject: function PartialEvaluator_buildFormXObject(resources, xobj, smask, operatorList, task, initialState) {
  30059. var matrix = xobj.dict.getArray('Matrix');
  30060. var bbox = xobj.dict.getArray('BBox');
  30061. var group = xobj.dict.get('Group');
  30062. if (group) {
  30063. var groupOptions = {
  30064. matrix: matrix,
  30065. bbox: bbox,
  30066. smask: smask,
  30067. isolated: false,
  30068. knockout: false
  30069. };
  30070. var groupSubtype = group.get('S');
  30071. var colorSpace;
  30072. if (isName(groupSubtype, 'Transparency')) {
  30073. groupOptions.isolated = group.get('I') || false;
  30074. groupOptions.knockout = group.get('K') || false;
  30075. colorSpace = group.has('CS') ? ColorSpace.parse(group.get('CS'), this.xref, resources) : null;
  30076. }
  30077. if (smask && smask.backdrop) {
  30078. colorSpace = colorSpace || ColorSpace.singletons.rgb;
  30079. smask.backdrop = colorSpace.getRgb(smask.backdrop, 0);
  30080. }
  30081. operatorList.addOp(OPS.beginGroup, [groupOptions]);
  30082. }
  30083. operatorList.addOp(OPS.paintFormXObjectBegin, [
  30084. matrix,
  30085. bbox
  30086. ]);
  30087. return this.getOperatorList(xobj, task, xobj.dict.get('Resources') || resources, operatorList, initialState).then(function () {
  30088. operatorList.addOp(OPS.paintFormXObjectEnd, []);
  30089. if (group) {
  30090. operatorList.addOp(OPS.endGroup, [groupOptions]);
  30091. }
  30092. });
  30093. },
  30094. buildPaintImageXObject: function PartialEvaluator_buildPaintImageXObject(resources, image, inline, operatorList, cacheKey, imageCache) {
  30095. var self = this;
  30096. var dict = image.dict;
  30097. var w = dict.get('Width', 'W');
  30098. var h = dict.get('Height', 'H');
  30099. if (!(w && isNum(w)) || !(h && isNum(h))) {
  30100. warn('Image dimensions are missing, or not numbers.');
  30101. return;
  30102. }
  30103. var maxImageSize = this.options.maxImageSize;
  30104. if (maxImageSize !== -1 && w * h > maxImageSize) {
  30105. warn('Image exceeded maximum allowed size and was removed.');
  30106. return;
  30107. }
  30108. var imageMask = dict.get('ImageMask', 'IM') || false;
  30109. var imgData, args;
  30110. if (imageMask) {
  30111. var width = dict.get('Width', 'W');
  30112. var height = dict.get('Height', 'H');
  30113. var bitStrideLength = width + 7 >> 3;
  30114. var imgArray = image.getBytes(bitStrideLength * height);
  30115. var decode = dict.getArray('Decode', 'D');
  30116. var inverseDecode = !!decode && decode[0] > 0;
  30117. imgData = PDFImage.createMask(imgArray, width, height, image instanceof DecodeStream, inverseDecode);
  30118. imgData.cached = true;
  30119. args = [imgData];
  30120. operatorList.addOp(OPS.paintImageMaskXObject, args);
  30121. if (cacheKey) {
  30122. imageCache[cacheKey] = {
  30123. fn: OPS.paintImageMaskXObject,
  30124. args: args
  30125. };
  30126. }
  30127. return;
  30128. }
  30129. var softMask = dict.get('SMask', 'SM') || false;
  30130. var mask = dict.get('Mask') || false;
  30131. var SMALL_IMAGE_DIMENSIONS = 200;
  30132. if (inline && !softMask && !mask && !(image instanceof JpegStream) && w + h < SMALL_IMAGE_DIMENSIONS) {
  30133. var imageObj = new PDFImage(this.xref, resources, image, inline, null, null);
  30134. imgData = imageObj.createImageData(true);
  30135. operatorList.addOp(OPS.paintInlineImageXObject, [imgData]);
  30136. return;
  30137. }
  30138. var useNativeImageDecoder = !this.options.disableNativeImageDecoder;
  30139. var objId = 'img_' + this.idFactory.createObjId();
  30140. operatorList.addDependency(objId);
  30141. args = [
  30142. objId,
  30143. w,
  30144. h
  30145. ];
  30146. if (useNativeImageDecoder && !softMask && !mask && image instanceof JpegStream && NativeImageDecoder.isSupported(image, this.xref, resources)) {
  30147. operatorList.addOp(OPS.paintJpegXObject, args);
  30148. this.handler.send('obj', [
  30149. objId,
  30150. this.pageIndex,
  30151. 'JpegStream',
  30152. image.getIR(this.options.forceDataSchema)
  30153. ]);
  30154. return;
  30155. }
  30156. var nativeImageDecoder = null;
  30157. if (useNativeImageDecoder && (image instanceof JpegStream || mask instanceof JpegStream || softMask instanceof JpegStream)) {
  30158. nativeImageDecoder = new NativeImageDecoder(self.xref, resources, self.handler, self.options.forceDataSchema);
  30159. }
  30160. PDFImage.buildImage(self.handler, self.xref, resources, image, inline, nativeImageDecoder).then(function (imageObj) {
  30161. var imgData = imageObj.createImageData(false);
  30162. self.handler.send('obj', [
  30163. objId,
  30164. self.pageIndex,
  30165. 'Image',
  30166. imgData
  30167. ], [imgData.data.buffer]);
  30168. }).then(undefined, function (reason) {
  30169. warn('Unable to decode image: ' + reason);
  30170. self.handler.send('obj', [
  30171. objId,
  30172. self.pageIndex,
  30173. 'Image',
  30174. null
  30175. ]);
  30176. });
  30177. operatorList.addOp(OPS.paintImageXObject, args);
  30178. if (cacheKey) {
  30179. imageCache[cacheKey] = {
  30180. fn: OPS.paintImageXObject,
  30181. args: args
  30182. };
  30183. }
  30184. },
  30185. handleSMask: function PartialEvaluator_handleSmask(smask, resources, operatorList, task, stateManager) {
  30186. var smaskContent = smask.get('G');
  30187. var smaskOptions = {
  30188. subtype: smask.get('S').name,
  30189. backdrop: smask.get('BC')
  30190. };
  30191. var transferObj = smask.get('TR');
  30192. if (isPDFFunction(transferObj)) {
  30193. var transferFn = PDFFunction.parse(this.xref, transferObj);
  30194. var transferMap = new Uint8Array(256);
  30195. var tmp = new Float32Array(1);
  30196. for (var i = 0; i < 256; i++) {
  30197. tmp[0] = i / 255;
  30198. transferFn(tmp, 0, tmp, 0);
  30199. transferMap[i] = tmp[0] * 255 | 0;
  30200. }
  30201. smaskOptions.transferMap = transferMap;
  30202. }
  30203. return this.buildFormXObject(resources, smaskContent, smaskOptions, operatorList, task, stateManager.state.clone());
  30204. },
  30205. handleTilingType: function PartialEvaluator_handleTilingType(fn, args, resources, pattern, patternDict, operatorList, task) {
  30206. var tilingOpList = new OperatorList();
  30207. var resourcesArray = [
  30208. patternDict.get('Resources'),
  30209. resources
  30210. ];
  30211. var patternResources = Dict.merge(this.xref, resourcesArray);
  30212. return this.getOperatorList(pattern, task, patternResources, tilingOpList).then(function () {
  30213. operatorList.addDependencies(tilingOpList.dependencies);
  30214. operatorList.addOp(fn, getTilingPatternIR({
  30215. fnArray: tilingOpList.fnArray,
  30216. argsArray: tilingOpList.argsArray
  30217. }, patternDict, args));
  30218. });
  30219. },
  30220. handleSetFont: function PartialEvaluator_handleSetFont(resources, fontArgs, fontRef, operatorList, task, state) {
  30221. var fontName;
  30222. if (fontArgs) {
  30223. fontArgs = fontArgs.slice();
  30224. fontName = fontArgs[0].name;
  30225. }
  30226. var self = this;
  30227. return this.loadFont(fontName, fontRef, this.xref, resources).then(function (translated) {
  30228. if (!translated.font.isType3Font) {
  30229. return translated;
  30230. }
  30231. return translated.loadType3Data(self, resources, operatorList, task).then(function () {
  30232. return translated;
  30233. }, function (reason) {
  30234. self.handler.send('UnsupportedFeature', { featureId: UNSUPPORTED_FEATURES.font });
  30235. return new TranslatedFont('g_font_error', new ErrorFont('Type3 font load error: ' + reason), translated.font);
  30236. });
  30237. }).then(function (translated) {
  30238. state.font = translated.font;
  30239. translated.send(self.handler);
  30240. return translated.loadedName;
  30241. });
  30242. },
  30243. handleText: function PartialEvaluator_handleText(chars, state) {
  30244. var font = state.font;
  30245. var glyphs = font.charsToGlyphs(chars);
  30246. var isAddToPathSet = !!(state.textRenderingMode & TextRenderingMode.ADD_TO_PATH_FLAG);
  30247. if (font.data && (isAddToPathSet || this.options.disableFontFace)) {
  30248. var buildPath = function (fontChar) {
  30249. if (!font.renderer.hasBuiltPath(fontChar)) {
  30250. var path = font.renderer.getPathJs(fontChar);
  30251. this.handler.send('commonobj', [
  30252. font.loadedName + '_path_' + fontChar,
  30253. 'FontPath',
  30254. path
  30255. ]);
  30256. }
  30257. }.bind(this);
  30258. for (var i = 0, ii = glyphs.length; i < ii; i++) {
  30259. var glyph = glyphs[i];
  30260. buildPath(glyph.fontChar);
  30261. var accent = glyph.accent;
  30262. if (accent && accent.fontChar) {
  30263. buildPath(accent.fontChar);
  30264. }
  30265. }
  30266. }
  30267. return glyphs;
  30268. },
  30269. setGState: function PartialEvaluator_setGState(resources, gState, operatorList, task, xref, stateManager) {
  30270. var gStateObj = [];
  30271. var gStateKeys = gState.getKeys();
  30272. var self = this;
  30273. var promise = Promise.resolve();
  30274. for (var i = 0, ii = gStateKeys.length; i < ii; i++) {
  30275. var key = gStateKeys[i];
  30276. var value = gState.get(key);
  30277. switch (key) {
  30278. case 'Type':
  30279. break;
  30280. case 'LW':
  30281. case 'LC':
  30282. case 'LJ':
  30283. case 'ML':
  30284. case 'D':
  30285. case 'RI':
  30286. case 'FL':
  30287. case 'CA':
  30288. case 'ca':
  30289. gStateObj.push([
  30290. key,
  30291. value
  30292. ]);
  30293. break;
  30294. case 'Font':
  30295. promise = promise.then(function () {
  30296. return self.handleSetFont(resources, null, value[0], operatorList, task, stateManager.state).then(function (loadedName) {
  30297. operatorList.addDependency(loadedName);
  30298. gStateObj.push([
  30299. key,
  30300. [
  30301. loadedName,
  30302. value[1]
  30303. ]
  30304. ]);
  30305. });
  30306. });
  30307. break;
  30308. case 'BM':
  30309. gStateObj.push([
  30310. key,
  30311. value
  30312. ]);
  30313. break;
  30314. case 'SMask':
  30315. if (isName(value, 'None')) {
  30316. gStateObj.push([
  30317. key,
  30318. false
  30319. ]);
  30320. break;
  30321. }
  30322. if (isDict(value)) {
  30323. promise = promise.then(function (dict) {
  30324. return self.handleSMask(dict, resources, operatorList, task, stateManager);
  30325. }.bind(this, value));
  30326. gStateObj.push([
  30327. key,
  30328. true
  30329. ]);
  30330. } else {
  30331. warn('Unsupported SMask type');
  30332. }
  30333. break;
  30334. case 'OP':
  30335. case 'op':
  30336. case 'OPM':
  30337. case 'BG':
  30338. case 'BG2':
  30339. case 'UCR':
  30340. case 'UCR2':
  30341. case 'TR':
  30342. case 'TR2':
  30343. case 'HT':
  30344. case 'SM':
  30345. case 'SA':
  30346. case 'AIS':
  30347. case 'TK':
  30348. info('graphic state operator ' + key);
  30349. break;
  30350. default:
  30351. info('Unknown graphic state operator ' + key);
  30352. break;
  30353. }
  30354. }
  30355. return promise.then(function () {
  30356. if (gStateObj.length > 0) {
  30357. operatorList.addOp(OPS.setGState, [gStateObj]);
  30358. }
  30359. });
  30360. },
  30361. loadFont: function PartialEvaluator_loadFont(fontName, font, xref, resources) {
  30362. function errorFont() {
  30363. return Promise.resolve(new TranslatedFont('g_font_error', new ErrorFont('Font ' + fontName + ' is not available'), font));
  30364. }
  30365. var fontRef;
  30366. if (font) {
  30367. assert(isRef(font));
  30368. fontRef = font;
  30369. } else {
  30370. var fontRes = resources.get('Font');
  30371. if (fontRes) {
  30372. fontRef = fontRes.getRaw(fontName);
  30373. } else {
  30374. warn('fontRes not available');
  30375. return errorFont();
  30376. }
  30377. }
  30378. if (!fontRef) {
  30379. warn('fontRef not available');
  30380. return errorFont();
  30381. }
  30382. if (this.fontCache.has(fontRef)) {
  30383. return this.fontCache.get(fontRef);
  30384. }
  30385. font = xref.fetchIfRef(fontRef);
  30386. if (!isDict(font)) {
  30387. return errorFont();
  30388. }
  30389. if (font.translated) {
  30390. return font.translated;
  30391. }
  30392. var fontCapability = createPromiseCapability();
  30393. var preEvaluatedFont = this.preEvaluateFont(font, xref);
  30394. var descriptor = preEvaluatedFont.descriptor;
  30395. var fontRefIsRef = isRef(fontRef), fontID;
  30396. if (fontRefIsRef) {
  30397. fontID = fontRef.toString();
  30398. }
  30399. if (isDict(descriptor)) {
  30400. if (!descriptor.fontAliases) {
  30401. descriptor.fontAliases = Object.create(null);
  30402. }
  30403. var fontAliases = descriptor.fontAliases;
  30404. var hash = preEvaluatedFont.hash;
  30405. if (fontAliases[hash]) {
  30406. var aliasFontRef = fontAliases[hash].aliasRef;
  30407. if (fontRefIsRef && aliasFontRef && this.fontCache.has(aliasFontRef)) {
  30408. this.fontCache.putAlias(fontRef, aliasFontRef);
  30409. return this.fontCache.get(fontRef);
  30410. }
  30411. } else {
  30412. fontAliases[hash] = { fontID: Font.getFontID() };
  30413. }
  30414. if (fontRefIsRef) {
  30415. fontAliases[hash].aliasRef = fontRef;
  30416. }
  30417. fontID = fontAliases[hash].fontID;
  30418. }
  30419. if (fontRefIsRef) {
  30420. this.fontCache.put(fontRef, fontCapability.promise);
  30421. } else {
  30422. if (!fontID) {
  30423. fontID = this.idFactory.createObjId();
  30424. }
  30425. this.fontCache.put('id_' + fontID, fontCapability.promise);
  30426. }
  30427. assert(fontID, 'The "fontID" must be defined.');
  30428. font.loadedName = 'g_' + this.pdfManager.docId + '_f' + fontID;
  30429. font.translated = fontCapability.promise;
  30430. var translatedPromise;
  30431. try {
  30432. translatedPromise = this.translateFont(preEvaluatedFont, xref);
  30433. } catch (e) {
  30434. translatedPromise = Promise.reject(e);
  30435. }
  30436. var self = this;
  30437. translatedPromise.then(function (translatedFont) {
  30438. if (translatedFont.fontType !== undefined) {
  30439. var xrefFontStats = xref.stats.fontTypes;
  30440. xrefFontStats[translatedFont.fontType] = true;
  30441. }
  30442. fontCapability.resolve(new TranslatedFont(font.loadedName, translatedFont, font));
  30443. }, function (reason) {
  30444. self.handler.send('UnsupportedFeature', { featureId: UNSUPPORTED_FEATURES.font });
  30445. try {
  30446. var descriptor = preEvaluatedFont.descriptor;
  30447. var fontFile3 = descriptor && descriptor.get('FontFile3');
  30448. var subtype = fontFile3 && fontFile3.get('Subtype');
  30449. var fontType = getFontType(preEvaluatedFont.type, subtype && subtype.name);
  30450. var xrefFontStats = xref.stats.fontTypes;
  30451. xrefFontStats[fontType] = true;
  30452. } catch (ex) {
  30453. }
  30454. fontCapability.resolve(new TranslatedFont(font.loadedName, new ErrorFont(reason instanceof Error ? reason.message : reason), font));
  30455. });
  30456. return fontCapability.promise;
  30457. },
  30458. buildPath: function PartialEvaluator_buildPath(operatorList, fn, args) {
  30459. var lastIndex = operatorList.length - 1;
  30460. if (!args) {
  30461. args = [];
  30462. }
  30463. if (lastIndex < 0 || operatorList.fnArray[lastIndex] !== OPS.constructPath) {
  30464. operatorList.addOp(OPS.constructPath, [
  30465. [fn],
  30466. args
  30467. ]);
  30468. } else {
  30469. var opArgs = operatorList.argsArray[lastIndex];
  30470. opArgs[0].push(fn);
  30471. Array.prototype.push.apply(opArgs[1], args);
  30472. }
  30473. },
  30474. handleColorN: function PartialEvaluator_handleColorN(operatorList, fn, args, cs, patterns, resources, task, xref) {
  30475. var patternName = args[args.length - 1];
  30476. var pattern;
  30477. if (isName(patternName) && (pattern = patterns.get(patternName.name))) {
  30478. var dict = isStream(pattern) ? pattern.dict : pattern;
  30479. var typeNum = dict.get('PatternType');
  30480. if (typeNum === TILING_PATTERN) {
  30481. var color = cs.base ? cs.base.getRgb(args, 0) : null;
  30482. return this.handleTilingType(fn, color, resources, pattern, dict, operatorList, task);
  30483. } else if (typeNum === SHADING_PATTERN) {
  30484. var shading = dict.get('Shading');
  30485. var matrix = dict.getArray('Matrix');
  30486. pattern = Pattern.parseShading(shading, matrix, xref, resources, this.handler);
  30487. operatorList.addOp(fn, pattern.getIR());
  30488. return Promise.resolve();
  30489. }
  30490. return Promise.reject('Unknown PatternType: ' + typeNum);
  30491. }
  30492. operatorList.addOp(fn, args);
  30493. return Promise.resolve();
  30494. },
  30495. getOperatorList: function PartialEvaluator_getOperatorList(stream, task, resources, operatorList, initialState) {
  30496. var self = this;
  30497. var xref = this.xref;
  30498. var imageCache = Object.create(null);
  30499. assert(operatorList);
  30500. resources = resources || Dict.empty;
  30501. var xobjs = resources.get('XObject') || Dict.empty;
  30502. var patterns = resources.get('Pattern') || Dict.empty;
  30503. var stateManager = new StateManager(initialState || new EvalState());
  30504. var preprocessor = new EvaluatorPreprocessor(stream, xref, stateManager);
  30505. var timeSlotManager = new TimeSlotManager();
  30506. return new Promise(function promiseBody(resolve, reject) {
  30507. var next = function (promise) {
  30508. promise.then(function () {
  30509. try {
  30510. promiseBody(resolve, reject);
  30511. } catch (ex) {
  30512. reject(ex);
  30513. }
  30514. }, reject);
  30515. };
  30516. task.ensureNotTerminated();
  30517. timeSlotManager.reset();
  30518. var stop, operation = {}, i, ii, cs;
  30519. while (!(stop = timeSlotManager.check())) {
  30520. operation.args = null;
  30521. if (!preprocessor.read(operation)) {
  30522. break;
  30523. }
  30524. var args = operation.args;
  30525. var fn = operation.fn;
  30526. switch (fn | 0) {
  30527. case OPS.paintXObject:
  30528. if (args[0].code) {
  30529. break;
  30530. }
  30531. var name = args[0].name;
  30532. if (!name) {
  30533. warn('XObject must be referred to by name.');
  30534. continue;
  30535. }
  30536. if (imageCache[name] !== undefined) {
  30537. operatorList.addOp(imageCache[name].fn, imageCache[name].args);
  30538. args = null;
  30539. continue;
  30540. }
  30541. var xobj = xobjs.get(name);
  30542. if (xobj) {
  30543. assert(isStream(xobj), 'XObject should be a stream');
  30544. var type = xobj.dict.get('Subtype');
  30545. assert(isName(type), 'XObject should have a Name subtype');
  30546. if (type.name === 'Form') {
  30547. stateManager.save();
  30548. next(self.buildFormXObject(resources, xobj, null, operatorList, task, stateManager.state.clone()).then(function () {
  30549. stateManager.restore();
  30550. }));
  30551. return;
  30552. } else if (type.name === 'Image') {
  30553. self.buildPaintImageXObject(resources, xobj, false, operatorList, name, imageCache);
  30554. args = null;
  30555. continue;
  30556. } else if (type.name === 'PS') {
  30557. info('Ignored XObject subtype PS');
  30558. continue;
  30559. } else {
  30560. error('Unhandled XObject subtype ' + type.name);
  30561. }
  30562. }
  30563. break;
  30564. case OPS.setFont:
  30565. var fontSize = args[1];
  30566. next(self.handleSetFont(resources, args, null, operatorList, task, stateManager.state).then(function (loadedName) {
  30567. operatorList.addDependency(loadedName);
  30568. operatorList.addOp(OPS.setFont, [
  30569. loadedName,
  30570. fontSize
  30571. ]);
  30572. }));
  30573. return;
  30574. case OPS.endInlineImage:
  30575. var cacheKey = args[0].cacheKey;
  30576. if (cacheKey) {
  30577. var cacheEntry = imageCache[cacheKey];
  30578. if (cacheEntry !== undefined) {
  30579. operatorList.addOp(cacheEntry.fn, cacheEntry.args);
  30580. args = null;
  30581. continue;
  30582. }
  30583. }
  30584. self.buildPaintImageXObject(resources, args[0], true, operatorList, cacheKey, imageCache);
  30585. args = null;
  30586. continue;
  30587. case OPS.showText:
  30588. args[0] = self.handleText(args[0], stateManager.state);
  30589. break;
  30590. case OPS.showSpacedText:
  30591. var arr = args[0];
  30592. var combinedGlyphs = [];
  30593. var arrLength = arr.length;
  30594. var state = stateManager.state;
  30595. for (i = 0; i < arrLength; ++i) {
  30596. var arrItem = arr[i];
  30597. if (isString(arrItem)) {
  30598. Array.prototype.push.apply(combinedGlyphs, self.handleText(arrItem, state));
  30599. } else if (isNum(arrItem)) {
  30600. combinedGlyphs.push(arrItem);
  30601. }
  30602. }
  30603. args[0] = combinedGlyphs;
  30604. fn = OPS.showText;
  30605. break;
  30606. case OPS.nextLineShowText:
  30607. operatorList.addOp(OPS.nextLine);
  30608. args[0] = self.handleText(args[0], stateManager.state);
  30609. fn = OPS.showText;
  30610. break;
  30611. case OPS.nextLineSetSpacingShowText:
  30612. operatorList.addOp(OPS.nextLine);
  30613. operatorList.addOp(OPS.setWordSpacing, [args.shift()]);
  30614. operatorList.addOp(OPS.setCharSpacing, [args.shift()]);
  30615. args[0] = self.handleText(args[0], stateManager.state);
  30616. fn = OPS.showText;
  30617. break;
  30618. case OPS.setTextRenderingMode:
  30619. stateManager.state.textRenderingMode = args[0];
  30620. break;
  30621. case OPS.setFillColorSpace:
  30622. stateManager.state.fillColorSpace = ColorSpace.parse(args[0], xref, resources);
  30623. continue;
  30624. case OPS.setStrokeColorSpace:
  30625. stateManager.state.strokeColorSpace = ColorSpace.parse(args[0], xref, resources);
  30626. continue;
  30627. case OPS.setFillColor:
  30628. cs = stateManager.state.fillColorSpace;
  30629. args = cs.getRgb(args, 0);
  30630. fn = OPS.setFillRGBColor;
  30631. break;
  30632. case OPS.setStrokeColor:
  30633. cs = stateManager.state.strokeColorSpace;
  30634. args = cs.getRgb(args, 0);
  30635. fn = OPS.setStrokeRGBColor;
  30636. break;
  30637. case OPS.setFillGray:
  30638. stateManager.state.fillColorSpace = ColorSpace.singletons.gray;
  30639. args = ColorSpace.singletons.gray.getRgb(args, 0);
  30640. fn = OPS.setFillRGBColor;
  30641. break;
  30642. case OPS.setStrokeGray:
  30643. stateManager.state.strokeColorSpace = ColorSpace.singletons.gray;
  30644. args = ColorSpace.singletons.gray.getRgb(args, 0);
  30645. fn = OPS.setStrokeRGBColor;
  30646. break;
  30647. case OPS.setFillCMYKColor:
  30648. stateManager.state.fillColorSpace = ColorSpace.singletons.cmyk;
  30649. args = ColorSpace.singletons.cmyk.getRgb(args, 0);
  30650. fn = OPS.setFillRGBColor;
  30651. break;
  30652. case OPS.setStrokeCMYKColor:
  30653. stateManager.state.strokeColorSpace = ColorSpace.singletons.cmyk;
  30654. args = ColorSpace.singletons.cmyk.getRgb(args, 0);
  30655. fn = OPS.setStrokeRGBColor;
  30656. break;
  30657. case OPS.setFillRGBColor:
  30658. stateManager.state.fillColorSpace = ColorSpace.singletons.rgb;
  30659. args = ColorSpace.singletons.rgb.getRgb(args, 0);
  30660. break;
  30661. case OPS.setStrokeRGBColor:
  30662. stateManager.state.strokeColorSpace = ColorSpace.singletons.rgb;
  30663. args = ColorSpace.singletons.rgb.getRgb(args, 0);
  30664. break;
  30665. case OPS.setFillColorN:
  30666. cs = stateManager.state.fillColorSpace;
  30667. if (cs.name === 'Pattern') {
  30668. next(self.handleColorN(operatorList, OPS.setFillColorN, args, cs, patterns, resources, task, xref));
  30669. return;
  30670. }
  30671. args = cs.getRgb(args, 0);
  30672. fn = OPS.setFillRGBColor;
  30673. break;
  30674. case OPS.setStrokeColorN:
  30675. cs = stateManager.state.strokeColorSpace;
  30676. if (cs.name === 'Pattern') {
  30677. next(self.handleColorN(operatorList, OPS.setStrokeColorN, args, cs, patterns, resources, task, xref));
  30678. return;
  30679. }
  30680. args = cs.getRgb(args, 0);
  30681. fn = OPS.setStrokeRGBColor;
  30682. break;
  30683. case OPS.shadingFill:
  30684. var shadingRes = resources.get('Shading');
  30685. if (!shadingRes) {
  30686. error('No shading resource found');
  30687. }
  30688. var shading = shadingRes.get(args[0].name);
  30689. if (!shading) {
  30690. error('No shading object found');
  30691. }
  30692. var shadingFill = Pattern.parseShading(shading, null, xref, resources, self.handler);
  30693. var patternIR = shadingFill.getIR();
  30694. args = [patternIR];
  30695. fn = OPS.shadingFill;
  30696. break;
  30697. case OPS.setGState:
  30698. var dictName = args[0];
  30699. var extGState = resources.get('ExtGState');
  30700. if (!isDict(extGState) || !extGState.has(dictName.name)) {
  30701. break;
  30702. }
  30703. var gState = extGState.get(dictName.name);
  30704. next(self.setGState(resources, gState, operatorList, task, xref, stateManager));
  30705. return;
  30706. case OPS.moveTo:
  30707. case OPS.lineTo:
  30708. case OPS.curveTo:
  30709. case OPS.curveTo2:
  30710. case OPS.curveTo3:
  30711. case OPS.closePath:
  30712. self.buildPath(operatorList, fn, args);
  30713. continue;
  30714. case OPS.rectangle:
  30715. self.buildPath(operatorList, fn, args);
  30716. continue;
  30717. case OPS.markPoint:
  30718. case OPS.markPointProps:
  30719. case OPS.beginMarkedContent:
  30720. case OPS.beginMarkedContentProps:
  30721. case OPS.endMarkedContent:
  30722. case OPS.beginCompat:
  30723. case OPS.endCompat:
  30724. continue;
  30725. default:
  30726. if (args !== null) {
  30727. for (i = 0, ii = args.length; i < ii; i++) {
  30728. if (args[i] instanceof Dict) {
  30729. break;
  30730. }
  30731. }
  30732. if (i < ii) {
  30733. warn('getOperatorList - ignoring operator: ' + fn);
  30734. continue;
  30735. }
  30736. }
  30737. }
  30738. operatorList.addOp(fn, args);
  30739. }
  30740. if (stop) {
  30741. next(deferred);
  30742. return;
  30743. }
  30744. for (i = 0, ii = preprocessor.savedStatesDepth; i < ii; i++) {
  30745. operatorList.addOp(OPS.restore, []);
  30746. }
  30747. resolve();
  30748. });
  30749. },
  30750. getTextContent: function PartialEvaluator_getTextContent(stream, task, resources, stateManager, normalizeWhitespace, combineTextItems) {
  30751. stateManager = stateManager || new StateManager(new TextState());
  30752. var WhitespaceRegexp = /\s/g;
  30753. var textContent = {
  30754. items: [],
  30755. styles: Object.create(null)
  30756. };
  30757. var textContentItem = {
  30758. initialized: false,
  30759. str: [],
  30760. width: 0,
  30761. height: 0,
  30762. vertical: false,
  30763. lastAdvanceWidth: 0,
  30764. lastAdvanceHeight: 0,
  30765. textAdvanceScale: 0,
  30766. spaceWidth: 0,
  30767. fakeSpaceMin: Infinity,
  30768. fakeMultiSpaceMin: Infinity,
  30769. fakeMultiSpaceMax: -0,
  30770. textRunBreakAllowed: false,
  30771. transform: null,
  30772. fontName: null
  30773. };
  30774. var SPACE_FACTOR = 0.3;
  30775. var MULTI_SPACE_FACTOR = 1.5;
  30776. var MULTI_SPACE_FACTOR_MAX = 4;
  30777. var self = this;
  30778. var xref = this.xref;
  30779. resources = xref.fetchIfRef(resources) || Dict.empty;
  30780. var xobjs = null;
  30781. var xobjsCache = Object.create(null);
  30782. var preprocessor = new EvaluatorPreprocessor(stream, xref, stateManager);
  30783. var textState;
  30784. function ensureTextContentItem() {
  30785. if (textContentItem.initialized) {
  30786. return textContentItem;
  30787. }
  30788. var font = textState.font;
  30789. if (!(font.loadedName in textContent.styles)) {
  30790. textContent.styles[font.loadedName] = {
  30791. fontFamily: font.fallbackName,
  30792. ascent: font.ascent,
  30793. descent: font.descent,
  30794. vertical: font.vertical
  30795. };
  30796. }
  30797. textContentItem.fontName = font.loadedName;
  30798. var tsm = [
  30799. textState.fontSize * textState.textHScale,
  30800. 0,
  30801. 0,
  30802. textState.fontSize,
  30803. 0,
  30804. textState.textRise
  30805. ];
  30806. if (font.isType3Font && textState.fontMatrix !== FONT_IDENTITY_MATRIX && textState.fontSize === 1) {
  30807. var glyphHeight = font.bbox[3] - font.bbox[1];
  30808. if (glyphHeight > 0) {
  30809. glyphHeight = glyphHeight * textState.fontMatrix[3];
  30810. tsm[3] *= glyphHeight;
  30811. }
  30812. }
  30813. var trm = Util.transform(textState.ctm, Util.transform(textState.textMatrix, tsm));
  30814. textContentItem.transform = trm;
  30815. if (!font.vertical) {
  30816. textContentItem.width = 0;
  30817. textContentItem.height = Math.sqrt(trm[2] * trm[2] + trm[3] * trm[3]);
  30818. textContentItem.vertical = false;
  30819. } else {
  30820. textContentItem.width = Math.sqrt(trm[0] * trm[0] + trm[1] * trm[1]);
  30821. textContentItem.height = 0;
  30822. textContentItem.vertical = true;
  30823. }
  30824. var a = textState.textLineMatrix[0];
  30825. var b = textState.textLineMatrix[1];
  30826. var scaleLineX = Math.sqrt(a * a + b * b);
  30827. a = textState.ctm[0];
  30828. b = textState.ctm[1];
  30829. var scaleCtmX = Math.sqrt(a * a + b * b);
  30830. textContentItem.textAdvanceScale = scaleCtmX * scaleLineX;
  30831. textContentItem.lastAdvanceWidth = 0;
  30832. textContentItem.lastAdvanceHeight = 0;
  30833. var spaceWidth = font.spaceWidth / 1000 * textState.fontSize;
  30834. if (spaceWidth) {
  30835. textContentItem.spaceWidth = spaceWidth;
  30836. textContentItem.fakeSpaceMin = spaceWidth * SPACE_FACTOR;
  30837. textContentItem.fakeMultiSpaceMin = spaceWidth * MULTI_SPACE_FACTOR;
  30838. textContentItem.fakeMultiSpaceMax = spaceWidth * MULTI_SPACE_FACTOR_MAX;
  30839. textContentItem.textRunBreakAllowed = !font.isMonospace;
  30840. } else {
  30841. textContentItem.spaceWidth = 0;
  30842. textContentItem.fakeSpaceMin = Infinity;
  30843. textContentItem.fakeMultiSpaceMin = Infinity;
  30844. textContentItem.fakeMultiSpaceMax = 0;
  30845. textContentItem.textRunBreakAllowed = false;
  30846. }
  30847. textContentItem.initialized = true;
  30848. return textContentItem;
  30849. }
  30850. function replaceWhitespace(str) {
  30851. var i = 0, ii = str.length, code;
  30852. while (i < ii && (code = str.charCodeAt(i)) >= 0x20 && code <= 0x7F) {
  30853. i++;
  30854. }
  30855. return i < ii ? str.replace(WhitespaceRegexp, ' ') : str;
  30856. }
  30857. function runBidiTransform(textChunk) {
  30858. var str = textChunk.str.join('');
  30859. var bidiResult = bidi(str, -1, textChunk.vertical);
  30860. return {
  30861. str: normalizeWhitespace ? replaceWhitespace(bidiResult.str) : bidiResult.str,
  30862. dir: bidiResult.dir,
  30863. width: textChunk.width,
  30864. height: textChunk.height,
  30865. transform: textChunk.transform,
  30866. fontName: textChunk.fontName
  30867. };
  30868. }
  30869. function handleSetFont(fontName, fontRef) {
  30870. return self.loadFont(fontName, fontRef, xref, resources).then(function (translated) {
  30871. textState.font = translated.font;
  30872. textState.fontMatrix = translated.font.fontMatrix || FONT_IDENTITY_MATRIX;
  30873. });
  30874. }
  30875. function buildTextContentItem(chars) {
  30876. var font = textState.font;
  30877. var textChunk = ensureTextContentItem();
  30878. var width = 0;
  30879. var height = 0;
  30880. var glyphs = font.charsToGlyphs(chars);
  30881. for (var i = 0; i < glyphs.length; i++) {
  30882. var glyph = glyphs[i];
  30883. var glyphWidth = null;
  30884. if (font.vertical && glyph.vmetric) {
  30885. glyphWidth = glyph.vmetric[0];
  30886. } else {
  30887. glyphWidth = glyph.width;
  30888. }
  30889. var glyphUnicode = glyph.unicode;
  30890. var NormalizedUnicodes = getNormalizedUnicodes();
  30891. if (NormalizedUnicodes[glyphUnicode] !== undefined) {
  30892. glyphUnicode = NormalizedUnicodes[glyphUnicode];
  30893. }
  30894. glyphUnicode = reverseIfRtl(glyphUnicode);
  30895. var charSpacing = textState.charSpacing;
  30896. if (glyph.isSpace) {
  30897. var wordSpacing = textState.wordSpacing;
  30898. charSpacing += wordSpacing;
  30899. if (wordSpacing > 0) {
  30900. addFakeSpaces(wordSpacing, textChunk.str);
  30901. }
  30902. }
  30903. var tx = 0;
  30904. var ty = 0;
  30905. if (!font.vertical) {
  30906. var w0 = glyphWidth * textState.fontMatrix[0];
  30907. tx = (w0 * textState.fontSize + charSpacing) * textState.textHScale;
  30908. width += tx;
  30909. } else {
  30910. var w1 = glyphWidth * textState.fontMatrix[0];
  30911. ty = w1 * textState.fontSize + charSpacing;
  30912. height += ty;
  30913. }
  30914. textState.translateTextMatrix(tx, ty);
  30915. textChunk.str.push(glyphUnicode);
  30916. }
  30917. if (!font.vertical) {
  30918. textChunk.lastAdvanceWidth = width;
  30919. textChunk.width += width;
  30920. } else {
  30921. textChunk.lastAdvanceHeight = height;
  30922. textChunk.height += Math.abs(height);
  30923. }
  30924. return textChunk;
  30925. }
  30926. function addFakeSpaces(width, strBuf) {
  30927. if (width < textContentItem.fakeSpaceMin) {
  30928. return;
  30929. }
  30930. if (width < textContentItem.fakeMultiSpaceMin) {
  30931. strBuf.push(' ');
  30932. return;
  30933. }
  30934. var fakeSpaces = Math.round(width / textContentItem.spaceWidth);
  30935. while (fakeSpaces-- > 0) {
  30936. strBuf.push(' ');
  30937. }
  30938. }
  30939. function flushTextContentItem() {
  30940. if (!textContentItem.initialized) {
  30941. return;
  30942. }
  30943. textContentItem.width *= textContentItem.textAdvanceScale;
  30944. textContentItem.height *= textContentItem.textAdvanceScale;
  30945. textContent.items.push(runBidiTransform(textContentItem));
  30946. textContentItem.initialized = false;
  30947. textContentItem.str.length = 0;
  30948. }
  30949. var timeSlotManager = new TimeSlotManager();
  30950. return new Promise(function promiseBody(resolve, reject) {
  30951. var next = function (promise) {
  30952. promise.then(function () {
  30953. try {
  30954. promiseBody(resolve, reject);
  30955. } catch (ex) {
  30956. reject(ex);
  30957. }
  30958. }, reject);
  30959. };
  30960. task.ensureNotTerminated();
  30961. timeSlotManager.reset();
  30962. var stop, operation = {}, args = [];
  30963. while (!(stop = timeSlotManager.check())) {
  30964. args.length = 0;
  30965. operation.args = args;
  30966. if (!preprocessor.read(operation)) {
  30967. break;
  30968. }
  30969. textState = stateManager.state;
  30970. var fn = operation.fn;
  30971. args = operation.args;
  30972. var advance, diff;
  30973. switch (fn | 0) {
  30974. case OPS.setFont:
  30975. var fontNameArg = args[0].name, fontSizeArg = args[1];
  30976. if (textState.font && fontNameArg === textState.fontName && fontSizeArg === textState.fontSize) {
  30977. break;
  30978. }
  30979. flushTextContentItem();
  30980. textState.fontName = fontNameArg;
  30981. textState.fontSize = fontSizeArg;
  30982. next(handleSetFont(fontNameArg, null));
  30983. return;
  30984. case OPS.setTextRise:
  30985. flushTextContentItem();
  30986. textState.textRise = args[0];
  30987. break;
  30988. case OPS.setHScale:
  30989. flushTextContentItem();
  30990. textState.textHScale = args[0] / 100;
  30991. break;
  30992. case OPS.setLeading:
  30993. flushTextContentItem();
  30994. textState.leading = args[0];
  30995. break;
  30996. case OPS.moveText:
  30997. var isSameTextLine = !textState.font ? false : (textState.font.vertical ? args[0] : args[1]) === 0;
  30998. advance = args[0] - args[1];
  30999. if (combineTextItems && isSameTextLine && textContentItem.initialized && advance > 0 && advance <= textContentItem.fakeMultiSpaceMax) {
  31000. textState.translateTextLineMatrix(args[0], args[1]);
  31001. textContentItem.width += args[0] - textContentItem.lastAdvanceWidth;
  31002. textContentItem.height += args[1] - textContentItem.lastAdvanceHeight;
  31003. diff = args[0] - textContentItem.lastAdvanceWidth - (args[1] - textContentItem.lastAdvanceHeight);
  31004. addFakeSpaces(diff, textContentItem.str);
  31005. break;
  31006. }
  31007. flushTextContentItem();
  31008. textState.translateTextLineMatrix(args[0], args[1]);
  31009. textState.textMatrix = textState.textLineMatrix.slice();
  31010. break;
  31011. case OPS.setLeadingMoveText:
  31012. flushTextContentItem();
  31013. textState.leading = -args[1];
  31014. textState.translateTextLineMatrix(args[0], args[1]);
  31015. textState.textMatrix = textState.textLineMatrix.slice();
  31016. break;
  31017. case OPS.nextLine:
  31018. flushTextContentItem();
  31019. textState.carriageReturn();
  31020. break;
  31021. case OPS.setTextMatrix:
  31022. advance = textState.calcTextLineMatrixAdvance(args[0], args[1], args[2], args[3], args[4], args[5]);
  31023. if (combineTextItems && advance !== null && textContentItem.initialized && advance.value > 0 && advance.value <= textContentItem.fakeMultiSpaceMax) {
  31024. textState.translateTextLineMatrix(advance.width, advance.height);
  31025. textContentItem.width += advance.width - textContentItem.lastAdvanceWidth;
  31026. textContentItem.height += advance.height - textContentItem.lastAdvanceHeight;
  31027. diff = advance.width - textContentItem.lastAdvanceWidth - (advance.height - textContentItem.lastAdvanceHeight);
  31028. addFakeSpaces(diff, textContentItem.str);
  31029. break;
  31030. }
  31031. flushTextContentItem();
  31032. textState.setTextMatrix(args[0], args[1], args[2], args[3], args[4], args[5]);
  31033. textState.setTextLineMatrix(args[0], args[1], args[2], args[3], args[4], args[5]);
  31034. break;
  31035. case OPS.setCharSpacing:
  31036. textState.charSpacing = args[0];
  31037. break;
  31038. case OPS.setWordSpacing:
  31039. textState.wordSpacing = args[0];
  31040. break;
  31041. case OPS.beginText:
  31042. flushTextContentItem();
  31043. textState.textMatrix = IDENTITY_MATRIX.slice();
  31044. textState.textLineMatrix = IDENTITY_MATRIX.slice();
  31045. break;
  31046. case OPS.showSpacedText:
  31047. var items = args[0];
  31048. var offset;
  31049. for (var j = 0, jj = items.length; j < jj; j++) {
  31050. if (typeof items[j] === 'string') {
  31051. buildTextContentItem(items[j]);
  31052. } else if (isNum(items[j])) {
  31053. ensureTextContentItem();
  31054. advance = items[j] * textState.fontSize / 1000;
  31055. var breakTextRun = false;
  31056. if (textState.font.vertical) {
  31057. offset = advance;
  31058. textState.translateTextMatrix(0, offset);
  31059. breakTextRun = textContentItem.textRunBreakAllowed && advance > textContentItem.fakeMultiSpaceMax;
  31060. if (!breakTextRun) {
  31061. textContentItem.height += offset;
  31062. }
  31063. } else {
  31064. advance = -advance;
  31065. offset = advance * textState.textHScale;
  31066. textState.translateTextMatrix(offset, 0);
  31067. breakTextRun = textContentItem.textRunBreakAllowed && advance > textContentItem.fakeMultiSpaceMax;
  31068. if (!breakTextRun) {
  31069. textContentItem.width += offset;
  31070. }
  31071. }
  31072. if (breakTextRun) {
  31073. flushTextContentItem();
  31074. } else if (advance > 0) {
  31075. addFakeSpaces(advance, textContentItem.str);
  31076. }
  31077. }
  31078. }
  31079. break;
  31080. case OPS.showText:
  31081. buildTextContentItem(args[0]);
  31082. break;
  31083. case OPS.nextLineShowText:
  31084. flushTextContentItem();
  31085. textState.carriageReturn();
  31086. buildTextContentItem(args[0]);
  31087. break;
  31088. case OPS.nextLineSetSpacingShowText:
  31089. flushTextContentItem();
  31090. textState.wordSpacing = args[0];
  31091. textState.charSpacing = args[1];
  31092. textState.carriageReturn();
  31093. buildTextContentItem(args[2]);
  31094. break;
  31095. case OPS.paintXObject:
  31096. flushTextContentItem();
  31097. if (args[0].code) {
  31098. break;
  31099. }
  31100. if (!xobjs) {
  31101. xobjs = resources.get('XObject') || Dict.empty;
  31102. }
  31103. var name = args[0].name;
  31104. if (xobjsCache.key === name) {
  31105. if (xobjsCache.texts) {
  31106. Util.appendToArray(textContent.items, xobjsCache.texts.items);
  31107. Util.extendObj(textContent.styles, xobjsCache.texts.styles);
  31108. }
  31109. break;
  31110. }
  31111. var xobj = xobjs.get(name);
  31112. if (!xobj) {
  31113. break;
  31114. }
  31115. assert(isStream(xobj), 'XObject should be a stream');
  31116. var type = xobj.dict.get('Subtype');
  31117. assert(isName(type), 'XObject should have a Name subtype');
  31118. if ('Form' !== type.name) {
  31119. xobjsCache.key = name;
  31120. xobjsCache.texts = null;
  31121. break;
  31122. }
  31123. stateManager.save();
  31124. var matrix = xobj.dict.getArray('Matrix');
  31125. if (isArray(matrix) && matrix.length === 6) {
  31126. stateManager.transform(matrix);
  31127. }
  31128. next(self.getTextContent(xobj, task, xobj.dict.get('Resources') || resources, stateManager, normalizeWhitespace, combineTextItems).then(function (formTextContent) {
  31129. Util.appendToArray(textContent.items, formTextContent.items);
  31130. Util.extendObj(textContent.styles, formTextContent.styles);
  31131. stateManager.restore();
  31132. xobjsCache.key = name;
  31133. xobjsCache.texts = formTextContent;
  31134. }));
  31135. return;
  31136. case OPS.setGState:
  31137. flushTextContentItem();
  31138. var dictName = args[0];
  31139. var extGState = resources.get('ExtGState');
  31140. if (!isDict(extGState) || !isName(dictName)) {
  31141. break;
  31142. }
  31143. var gState = extGState.get(dictName.name);
  31144. if (!isDict(gState)) {
  31145. break;
  31146. }
  31147. var gStateFont = gState.get('Font');
  31148. if (gStateFont) {
  31149. textState.fontName = null;
  31150. textState.fontSize = gStateFont[1];
  31151. next(handleSetFont(null, gStateFont[0]));
  31152. return;
  31153. }
  31154. break;
  31155. }
  31156. }
  31157. if (stop) {
  31158. next(deferred);
  31159. return;
  31160. }
  31161. flushTextContentItem();
  31162. resolve(textContent);
  31163. });
  31164. },
  31165. extractDataStructures: function PartialEvaluator_extractDataStructures(dict, baseDict, xref, properties) {
  31166. var toUnicode = dict.get('ToUnicode') || baseDict.get('ToUnicode');
  31167. var toUnicodePromise = toUnicode ? this.readToUnicode(toUnicode) : Promise.resolve(undefined);
  31168. if (properties.composite) {
  31169. var cidSystemInfo = dict.get('CIDSystemInfo');
  31170. if (isDict(cidSystemInfo)) {
  31171. properties.cidSystemInfo = {
  31172. registry: cidSystemInfo.get('Registry'),
  31173. ordering: cidSystemInfo.get('Ordering'),
  31174. supplement: cidSystemInfo.get('Supplement')
  31175. };
  31176. }
  31177. var cidToGidMap = dict.get('CIDToGIDMap');
  31178. if (isStream(cidToGidMap)) {
  31179. properties.cidToGidMap = this.readCidToGidMap(cidToGidMap);
  31180. }
  31181. }
  31182. var differences = [];
  31183. var baseEncodingName = null;
  31184. var encoding;
  31185. if (dict.has('Encoding')) {
  31186. encoding = dict.get('Encoding');
  31187. if (isDict(encoding)) {
  31188. baseEncodingName = encoding.get('BaseEncoding');
  31189. baseEncodingName = isName(baseEncodingName) ? baseEncodingName.name : null;
  31190. if (encoding.has('Differences')) {
  31191. var diffEncoding = encoding.get('Differences');
  31192. var index = 0;
  31193. for (var j = 0, jj = diffEncoding.length; j < jj; j++) {
  31194. var data = xref.fetchIfRef(diffEncoding[j]);
  31195. if (isNum(data)) {
  31196. index = data;
  31197. } else if (isName(data)) {
  31198. differences[index++] = data.name;
  31199. } else {
  31200. error('Invalid entry in \'Differences\' array: ' + data);
  31201. }
  31202. }
  31203. }
  31204. } else if (isName(encoding)) {
  31205. baseEncodingName = encoding.name;
  31206. } else {
  31207. error('Encoding is not a Name nor a Dict');
  31208. }
  31209. if (baseEncodingName !== 'MacRomanEncoding' && baseEncodingName !== 'MacExpertEncoding' && baseEncodingName !== 'WinAnsiEncoding') {
  31210. baseEncodingName = null;
  31211. }
  31212. }
  31213. if (baseEncodingName) {
  31214. properties.defaultEncoding = getEncoding(baseEncodingName).slice();
  31215. } else {
  31216. var isSymbolicFont = !!(properties.flags & FontFlags.Symbolic);
  31217. var isNonsymbolicFont = !!(properties.flags & FontFlags.Nonsymbolic);
  31218. encoding = StandardEncoding;
  31219. if (properties.type === 'TrueType' && !isNonsymbolicFont) {
  31220. encoding = WinAnsiEncoding;
  31221. }
  31222. if (isSymbolicFont) {
  31223. encoding = MacRomanEncoding;
  31224. if (!properties.file) {
  31225. if (/Symbol/i.test(properties.name)) {
  31226. encoding = SymbolSetEncoding;
  31227. } else if (/Dingbats/i.test(properties.name)) {
  31228. encoding = ZapfDingbatsEncoding;
  31229. }
  31230. }
  31231. }
  31232. properties.defaultEncoding = encoding;
  31233. }
  31234. properties.differences = differences;
  31235. properties.baseEncodingName = baseEncodingName;
  31236. properties.hasEncoding = !!baseEncodingName || differences.length > 0;
  31237. properties.dict = dict;
  31238. return toUnicodePromise.then(function (toUnicode) {
  31239. properties.toUnicode = toUnicode;
  31240. return this.buildToUnicode(properties);
  31241. }.bind(this)).then(function (toUnicode) {
  31242. properties.toUnicode = toUnicode;
  31243. return properties;
  31244. });
  31245. },
  31246. buildToUnicode: function PartialEvaluator_buildToUnicode(properties) {
  31247. properties.hasIncludedToUnicodeMap = !!properties.toUnicode && properties.toUnicode.length > 0;
  31248. if (properties.hasIncludedToUnicodeMap) {
  31249. return Promise.resolve(properties.toUnicode);
  31250. }
  31251. var toUnicode, charcode, glyphName;
  31252. if (!properties.composite) {
  31253. toUnicode = [];
  31254. var encoding = properties.defaultEncoding.slice();
  31255. var baseEncodingName = properties.baseEncodingName;
  31256. var differences = properties.differences;
  31257. for (charcode in differences) {
  31258. glyphName = differences[charcode];
  31259. if (glyphName === '.notdef') {
  31260. continue;
  31261. }
  31262. encoding[charcode] = glyphName;
  31263. }
  31264. var glyphsUnicodeMap = getGlyphsUnicode();
  31265. for (charcode in encoding) {
  31266. glyphName = encoding[charcode];
  31267. if (glyphName === '') {
  31268. continue;
  31269. } else if (glyphsUnicodeMap[glyphName] === undefined) {
  31270. var code = 0;
  31271. switch (glyphName[0]) {
  31272. case 'G':
  31273. if (glyphName.length === 3) {
  31274. code = parseInt(glyphName.substr(1), 16);
  31275. }
  31276. break;
  31277. case 'g':
  31278. if (glyphName.length === 5) {
  31279. code = parseInt(glyphName.substr(1), 16);
  31280. }
  31281. break;
  31282. case 'C':
  31283. case 'c':
  31284. if (glyphName.length >= 3) {
  31285. code = +glyphName.substr(1);
  31286. }
  31287. break;
  31288. default:
  31289. var unicode = getUnicodeForGlyph(glyphName, glyphsUnicodeMap);
  31290. if (unicode !== -1) {
  31291. code = unicode;
  31292. }
  31293. }
  31294. if (code) {
  31295. if (baseEncodingName && code === +charcode) {
  31296. var baseEncoding = getEncoding(baseEncodingName);
  31297. if (baseEncoding && (glyphName = baseEncoding[charcode])) {
  31298. toUnicode[charcode] = String.fromCharCode(glyphsUnicodeMap[glyphName]);
  31299. continue;
  31300. }
  31301. }
  31302. toUnicode[charcode] = String.fromCharCode(code);
  31303. }
  31304. continue;
  31305. }
  31306. toUnicode[charcode] = String.fromCharCode(glyphsUnicodeMap[glyphName]);
  31307. }
  31308. return Promise.resolve(new ToUnicodeMap(toUnicode));
  31309. }
  31310. 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'))) {
  31311. var registry = properties.cidSystemInfo.registry;
  31312. var ordering = properties.cidSystemInfo.ordering;
  31313. var ucs2CMapName = Name.get(registry + '-' + ordering + '-UCS2');
  31314. return CMapFactory.create(ucs2CMapName, this.options.cMapOptions, null).then(function (ucs2CMap) {
  31315. var cMap = properties.cMap;
  31316. toUnicode = [];
  31317. cMap.forEach(function (charcode, cid) {
  31318. assert(cid <= 0xffff, 'Max size of CID is 65,535');
  31319. var ucs2 = ucs2CMap.lookup(cid);
  31320. if (ucs2) {
  31321. toUnicode[charcode] = String.fromCharCode((ucs2.charCodeAt(0) << 8) + ucs2.charCodeAt(1));
  31322. }
  31323. });
  31324. return new ToUnicodeMap(toUnicode);
  31325. });
  31326. }
  31327. return Promise.resolve(new IdentityToUnicodeMap(properties.firstChar, properties.lastChar));
  31328. },
  31329. readToUnicode: function PartialEvaluator_readToUnicode(toUnicode) {
  31330. var cmapObj = toUnicode;
  31331. if (isName(cmapObj)) {
  31332. return CMapFactory.create(cmapObj, this.options.cMapOptions, null).then(function (cmap) {
  31333. if (cmap instanceof IdentityCMap) {
  31334. return new IdentityToUnicodeMap(0, 0xFFFF);
  31335. }
  31336. return new ToUnicodeMap(cmap.getMap());
  31337. });
  31338. } else if (isStream(cmapObj)) {
  31339. return CMapFactory.create(cmapObj, this.options.cMapOptions, null).then(function (cmap) {
  31340. if (cmap instanceof IdentityCMap) {
  31341. return new IdentityToUnicodeMap(0, 0xFFFF);
  31342. }
  31343. var map = new Array(cmap.length);
  31344. cmap.forEach(function (charCode, token) {
  31345. var str = [];
  31346. for (var k = 0; k < token.length; k += 2) {
  31347. var w1 = token.charCodeAt(k) << 8 | token.charCodeAt(k + 1);
  31348. if ((w1 & 0xF800) !== 0xD800) {
  31349. str.push(w1);
  31350. continue;
  31351. }
  31352. k += 2;
  31353. var w2 = token.charCodeAt(k) << 8 | token.charCodeAt(k + 1);
  31354. str.push(((w1 & 0x3ff) << 10) + (w2 & 0x3ff) + 0x10000);
  31355. }
  31356. map[charCode] = String.fromCharCode.apply(String, str);
  31357. });
  31358. return new ToUnicodeMap(map);
  31359. });
  31360. }
  31361. return Promise.resolve(null);
  31362. },
  31363. readCidToGidMap: function PartialEvaluator_readCidToGidMap(cidToGidStream) {
  31364. var glyphsData = cidToGidStream.getBytes();
  31365. var result = [];
  31366. for (var j = 0, jj = glyphsData.length; j < jj; j++) {
  31367. var glyphID = glyphsData[j++] << 8 | glyphsData[j];
  31368. if (glyphID === 0) {
  31369. continue;
  31370. }
  31371. var code = j >> 1;
  31372. result[code] = glyphID;
  31373. }
  31374. return result;
  31375. },
  31376. extractWidths: function PartialEvaluator_extractWidths(dict, xref, descriptor, properties) {
  31377. var glyphsWidths = [];
  31378. var defaultWidth = 0;
  31379. var glyphsVMetrics = [];
  31380. var defaultVMetrics;
  31381. var i, ii, j, jj, start, code, widths;
  31382. if (properties.composite) {
  31383. defaultWidth = dict.get('DW') || 1000;
  31384. widths = dict.get('W');
  31385. if (widths) {
  31386. for (i = 0, ii = widths.length; i < ii; i++) {
  31387. start = xref.fetchIfRef(widths[i++]);
  31388. code = xref.fetchIfRef(widths[i]);
  31389. if (isArray(code)) {
  31390. for (j = 0, jj = code.length; j < jj; j++) {
  31391. glyphsWidths[start++] = xref.fetchIfRef(code[j]);
  31392. }
  31393. } else {
  31394. var width = xref.fetchIfRef(widths[++i]);
  31395. for (j = start; j <= code; j++) {
  31396. glyphsWidths[j] = width;
  31397. }
  31398. }
  31399. }
  31400. }
  31401. if (properties.vertical) {
  31402. var vmetrics = dict.getArray('DW2') || [
  31403. 880,
  31404. -1000
  31405. ];
  31406. defaultVMetrics = [
  31407. vmetrics[1],
  31408. defaultWidth * 0.5,
  31409. vmetrics[0]
  31410. ];
  31411. vmetrics = dict.get('W2');
  31412. if (vmetrics) {
  31413. for (i = 0, ii = vmetrics.length; i < ii; i++) {
  31414. start = xref.fetchIfRef(vmetrics[i++]);
  31415. code = xref.fetchIfRef(vmetrics[i]);
  31416. if (isArray(code)) {
  31417. for (j = 0, jj = code.length; j < jj; j++) {
  31418. glyphsVMetrics[start++] = [
  31419. xref.fetchIfRef(code[j++]),
  31420. xref.fetchIfRef(code[j++]),
  31421. xref.fetchIfRef(code[j])
  31422. ];
  31423. }
  31424. } else {
  31425. var vmetric = [
  31426. xref.fetchIfRef(vmetrics[++i]),
  31427. xref.fetchIfRef(vmetrics[++i]),
  31428. xref.fetchIfRef(vmetrics[++i])
  31429. ];
  31430. for (j = start; j <= code; j++) {
  31431. glyphsVMetrics[j] = vmetric;
  31432. }
  31433. }
  31434. }
  31435. }
  31436. }
  31437. } else {
  31438. var firstChar = properties.firstChar;
  31439. widths = dict.get('Widths');
  31440. if (widths) {
  31441. j = firstChar;
  31442. for (i = 0, ii = widths.length; i < ii; i++) {
  31443. glyphsWidths[j++] = xref.fetchIfRef(widths[i]);
  31444. }
  31445. defaultWidth = parseFloat(descriptor.get('MissingWidth')) || 0;
  31446. } else {
  31447. var baseFontName = dict.get('BaseFont');
  31448. if (isName(baseFontName)) {
  31449. var metrics = this.getBaseFontMetrics(baseFontName.name);
  31450. glyphsWidths = this.buildCharCodeToWidth(metrics.widths, properties);
  31451. defaultWidth = metrics.defaultWidth;
  31452. }
  31453. }
  31454. }
  31455. var isMonospace = true;
  31456. var firstWidth = defaultWidth;
  31457. for (var glyph in glyphsWidths) {
  31458. var glyphWidth = glyphsWidths[glyph];
  31459. if (!glyphWidth) {
  31460. continue;
  31461. }
  31462. if (!firstWidth) {
  31463. firstWidth = glyphWidth;
  31464. continue;
  31465. }
  31466. if (firstWidth !== glyphWidth) {
  31467. isMonospace = false;
  31468. break;
  31469. }
  31470. }
  31471. if (isMonospace) {
  31472. properties.flags |= FontFlags.FixedPitch;
  31473. }
  31474. properties.defaultWidth = defaultWidth;
  31475. properties.widths = glyphsWidths;
  31476. properties.defaultVMetrics = defaultVMetrics;
  31477. properties.vmetrics = glyphsVMetrics;
  31478. },
  31479. isSerifFont: function PartialEvaluator_isSerifFont(baseFontName) {
  31480. var fontNameWoStyle = baseFontName.split('-')[0];
  31481. return fontNameWoStyle in getSerifFonts() || fontNameWoStyle.search(/serif/gi) !== -1;
  31482. },
  31483. getBaseFontMetrics: function PartialEvaluator_getBaseFontMetrics(name) {
  31484. var defaultWidth = 0;
  31485. var widths = [];
  31486. var monospace = false;
  31487. var stdFontMap = getStdFontMap();
  31488. var lookupName = stdFontMap[name] || name;
  31489. var Metrics = getMetrics();
  31490. if (!(lookupName in Metrics)) {
  31491. if (this.isSerifFont(name)) {
  31492. lookupName = 'Times-Roman';
  31493. } else {
  31494. lookupName = 'Helvetica';
  31495. }
  31496. }
  31497. var glyphWidths = Metrics[lookupName];
  31498. if (isNum(glyphWidths)) {
  31499. defaultWidth = glyphWidths;
  31500. monospace = true;
  31501. } else {
  31502. widths = glyphWidths();
  31503. }
  31504. return {
  31505. defaultWidth: defaultWidth,
  31506. monospace: monospace,
  31507. widths: widths
  31508. };
  31509. },
  31510. buildCharCodeToWidth: function PartialEvaluator_bulildCharCodeToWidth(widthsByGlyphName, properties) {
  31511. var widths = Object.create(null);
  31512. var differences = properties.differences;
  31513. var encoding = properties.defaultEncoding;
  31514. for (var charCode = 0; charCode < 256; charCode++) {
  31515. if (charCode in differences && widthsByGlyphName[differences[charCode]]) {
  31516. widths[charCode] = widthsByGlyphName[differences[charCode]];
  31517. continue;
  31518. }
  31519. if (charCode in encoding && widthsByGlyphName[encoding[charCode]]) {
  31520. widths[charCode] = widthsByGlyphName[encoding[charCode]];
  31521. continue;
  31522. }
  31523. }
  31524. return widths;
  31525. },
  31526. preEvaluateFont: function PartialEvaluator_preEvaluateFont(dict, xref) {
  31527. var baseDict = dict;
  31528. var type = dict.get('Subtype');
  31529. assert(isName(type), 'invalid font Subtype');
  31530. var composite = false;
  31531. var uint8array;
  31532. if (type.name === 'Type0') {
  31533. var df = dict.get('DescendantFonts');
  31534. if (!df) {
  31535. error('Descendant fonts are not specified');
  31536. }
  31537. dict = isArray(df) ? xref.fetchIfRef(df[0]) : df;
  31538. type = dict.get('Subtype');
  31539. assert(isName(type), 'invalid font Subtype');
  31540. composite = true;
  31541. }
  31542. var descriptor = dict.get('FontDescriptor');
  31543. if (descriptor) {
  31544. var hash = new MurmurHash3_64();
  31545. var encoding = baseDict.getRaw('Encoding');
  31546. if (isName(encoding)) {
  31547. hash.update(encoding.name);
  31548. } else if (isRef(encoding)) {
  31549. hash.update(encoding.toString());
  31550. } else if (isDict(encoding)) {
  31551. var keys = encoding.getKeys();
  31552. for (var i = 0, ii = keys.length; i < ii; i++) {
  31553. var entry = encoding.getRaw(keys[i]);
  31554. if (isName(entry)) {
  31555. hash.update(entry.name);
  31556. } else if (isRef(entry)) {
  31557. hash.update(entry.toString());
  31558. } else if (isArray(entry)) {
  31559. var diffLength = entry.length, diffBuf = new Array(diffLength);
  31560. for (var j = 0; j < diffLength; j++) {
  31561. var diffEntry = entry[j];
  31562. if (isName(diffEntry)) {
  31563. diffBuf[j] = diffEntry.name;
  31564. } else if (isNum(diffEntry) || isRef(diffEntry)) {
  31565. diffBuf[j] = diffEntry.toString();
  31566. }
  31567. }
  31568. hash.update(diffBuf.join());
  31569. }
  31570. }
  31571. }
  31572. var toUnicode = dict.get('ToUnicode') || baseDict.get('ToUnicode');
  31573. if (isStream(toUnicode)) {
  31574. var stream = toUnicode.str || toUnicode;
  31575. uint8array = stream.buffer ? new Uint8Array(stream.buffer.buffer, 0, stream.bufferLength) : new Uint8Array(stream.bytes.buffer, stream.start, stream.end - stream.start);
  31576. hash.update(uint8array);
  31577. } else if (isName(toUnicode)) {
  31578. hash.update(toUnicode.name);
  31579. }
  31580. var widths = dict.get('Widths') || baseDict.get('Widths');
  31581. if (widths) {
  31582. uint8array = new Uint8Array(new Uint32Array(widths).buffer);
  31583. hash.update(uint8array);
  31584. }
  31585. }
  31586. return {
  31587. descriptor: descriptor,
  31588. dict: dict,
  31589. baseDict: baseDict,
  31590. composite: composite,
  31591. type: type.name,
  31592. hash: hash ? hash.hexdigest() : ''
  31593. };
  31594. },
  31595. translateFont: function PartialEvaluator_translateFont(preEvaluatedFont, xref) {
  31596. var baseDict = preEvaluatedFont.baseDict;
  31597. var dict = preEvaluatedFont.dict;
  31598. var composite = preEvaluatedFont.composite;
  31599. var descriptor = preEvaluatedFont.descriptor;
  31600. var type = preEvaluatedFont.type;
  31601. var maxCharIndex = composite ? 0xFFFF : 0xFF;
  31602. var cMapOptions = this.options.cMapOptions;
  31603. var properties;
  31604. if (!descriptor) {
  31605. if (type === 'Type3') {
  31606. descriptor = new Dict(null);
  31607. descriptor.set('FontName', Name.get(type));
  31608. descriptor.set('FontBBox', dict.getArray('FontBBox'));
  31609. } else {
  31610. var baseFontName = dict.get('BaseFont');
  31611. if (!isName(baseFontName)) {
  31612. error('Base font is not specified');
  31613. }
  31614. baseFontName = baseFontName.name.replace(/[,_]/g, '-');
  31615. var metrics = this.getBaseFontMetrics(baseFontName);
  31616. var fontNameWoStyle = baseFontName.split('-')[0];
  31617. var flags = (this.isSerifFont(fontNameWoStyle) ? FontFlags.Serif : 0) | (metrics.monospace ? FontFlags.FixedPitch : 0) | (getSymbolsFonts()[fontNameWoStyle] ? FontFlags.Symbolic : FontFlags.Nonsymbolic);
  31618. properties = {
  31619. type: type,
  31620. name: baseFontName,
  31621. widths: metrics.widths,
  31622. defaultWidth: metrics.defaultWidth,
  31623. flags: flags,
  31624. firstChar: 0,
  31625. lastChar: maxCharIndex
  31626. };
  31627. return this.extractDataStructures(dict, dict, xref, properties).then(function (properties) {
  31628. properties.widths = this.buildCharCodeToWidth(metrics.widths, properties);
  31629. return new Font(baseFontName, null, properties);
  31630. }.bind(this));
  31631. }
  31632. }
  31633. var firstChar = dict.get('FirstChar') || 0;
  31634. var lastChar = dict.get('LastChar') || maxCharIndex;
  31635. var fontName = descriptor.get('FontName');
  31636. var baseFont = dict.get('BaseFont');
  31637. if (isString(fontName)) {
  31638. fontName = Name.get(fontName);
  31639. }
  31640. if (isString(baseFont)) {
  31641. baseFont = Name.get(baseFont);
  31642. }
  31643. if (type !== 'Type3') {
  31644. var fontNameStr = fontName && fontName.name;
  31645. var baseFontStr = baseFont && baseFont.name;
  31646. if (fontNameStr !== baseFontStr) {
  31647. info('The FontDescriptor\'s FontName is "' + fontNameStr + '" but should be the same as the Font\'s BaseFont "' + baseFontStr + '"');
  31648. if (fontNameStr && baseFontStr && baseFontStr.indexOf(fontNameStr) === 0) {
  31649. fontName = baseFont;
  31650. }
  31651. }
  31652. }
  31653. fontName = fontName || baseFont;
  31654. assert(isName(fontName), 'invalid font name');
  31655. var fontFile = descriptor.get('FontFile', 'FontFile2', 'FontFile3');
  31656. if (fontFile) {
  31657. if (fontFile.dict) {
  31658. var subtype = fontFile.dict.get('Subtype');
  31659. if (subtype) {
  31660. subtype = subtype.name;
  31661. }
  31662. var length1 = fontFile.dict.get('Length1');
  31663. var length2 = fontFile.dict.get('Length2');
  31664. var length3 = fontFile.dict.get('Length3');
  31665. }
  31666. }
  31667. properties = {
  31668. type: type,
  31669. name: fontName.name,
  31670. subtype: subtype,
  31671. file: fontFile,
  31672. length1: length1,
  31673. length2: length2,
  31674. length3: length3,
  31675. loadedName: baseDict.loadedName,
  31676. composite: composite,
  31677. wideChars: composite,
  31678. fixedPitch: false,
  31679. fontMatrix: dict.getArray('FontMatrix') || FONT_IDENTITY_MATRIX,
  31680. firstChar: firstChar || 0,
  31681. lastChar: lastChar || maxCharIndex,
  31682. bbox: descriptor.getArray('FontBBox'),
  31683. ascent: descriptor.get('Ascent'),
  31684. descent: descriptor.get('Descent'),
  31685. xHeight: descriptor.get('XHeight'),
  31686. capHeight: descriptor.get('CapHeight'),
  31687. flags: descriptor.get('Flags'),
  31688. italicAngle: descriptor.get('ItalicAngle'),
  31689. coded: false
  31690. };
  31691. var cMapPromise;
  31692. if (composite) {
  31693. var cidEncoding = baseDict.get('Encoding');
  31694. if (isName(cidEncoding)) {
  31695. properties.cidEncoding = cidEncoding.name;
  31696. }
  31697. cMapPromise = CMapFactory.create(cidEncoding, cMapOptions, null).then(function (cMap) {
  31698. properties.cMap = cMap;
  31699. properties.vertical = properties.cMap.vertical;
  31700. });
  31701. } else {
  31702. cMapPromise = Promise.resolve(undefined);
  31703. }
  31704. return cMapPromise.then(function () {
  31705. return this.extractDataStructures(dict, baseDict, xref, properties);
  31706. }.bind(this)).then(function (properties) {
  31707. this.extractWidths(dict, xref, descriptor, properties);
  31708. if (type === 'Type3') {
  31709. properties.isType3Font = true;
  31710. }
  31711. return new Font(fontName.name, fontFile, properties);
  31712. }.bind(this));
  31713. }
  31714. };
  31715. return PartialEvaluator;
  31716. }();
  31717. var TranslatedFont = function TranslatedFontClosure() {
  31718. function TranslatedFont(loadedName, font, dict) {
  31719. this.loadedName = loadedName;
  31720. this.font = font;
  31721. this.dict = dict;
  31722. this.type3Loaded = null;
  31723. this.sent = false;
  31724. }
  31725. TranslatedFont.prototype = {
  31726. send: function (handler) {
  31727. if (this.sent) {
  31728. return;
  31729. }
  31730. var fontData = this.font.exportData();
  31731. handler.send('commonobj', [
  31732. this.loadedName,
  31733. 'Font',
  31734. fontData
  31735. ]);
  31736. this.sent = true;
  31737. },
  31738. loadType3Data: function (evaluator, resources, parentOperatorList, task) {
  31739. assert(this.font.isType3Font);
  31740. if (this.type3Loaded) {
  31741. return this.type3Loaded;
  31742. }
  31743. var translatedFont = this.font;
  31744. var loadCharProcsPromise = Promise.resolve();
  31745. var charProcs = this.dict.get('CharProcs');
  31746. var fontResources = this.dict.get('Resources') || resources;
  31747. var charProcKeys = charProcs.getKeys();
  31748. var charProcOperatorList = Object.create(null);
  31749. for (var i = 0, n = charProcKeys.length; i < n; ++i) {
  31750. loadCharProcsPromise = loadCharProcsPromise.then(function (key) {
  31751. var glyphStream = charProcs.get(key);
  31752. var operatorList = new OperatorList();
  31753. return evaluator.getOperatorList(glyphStream, task, fontResources, operatorList).then(function () {
  31754. charProcOperatorList[key] = operatorList.getIR();
  31755. parentOperatorList.addDependencies(operatorList.dependencies);
  31756. }, function (reason) {
  31757. warn('Type3 font resource \"' + key + '\" is not available');
  31758. var operatorList = new OperatorList();
  31759. charProcOperatorList[key] = operatorList.getIR();
  31760. });
  31761. }.bind(this, charProcKeys[i]));
  31762. }
  31763. this.type3Loaded = loadCharProcsPromise.then(function () {
  31764. translatedFont.charProcOperatorList = charProcOperatorList;
  31765. });
  31766. return this.type3Loaded;
  31767. }
  31768. };
  31769. return TranslatedFont;
  31770. }();
  31771. var OperatorList = function OperatorListClosure() {
  31772. var CHUNK_SIZE = 1000;
  31773. var CHUNK_SIZE_ABOUT = CHUNK_SIZE - 5;
  31774. function getTransfers(queue) {
  31775. var transfers = [];
  31776. var fnArray = queue.fnArray, argsArray = queue.argsArray;
  31777. for (var i = 0, ii = queue.length; i < ii; i++) {
  31778. switch (fnArray[i]) {
  31779. case OPS.paintInlineImageXObject:
  31780. case OPS.paintInlineImageXObjectGroup:
  31781. case OPS.paintImageMaskXObject:
  31782. var arg = argsArray[i][0];
  31783. if (!arg.cached) {
  31784. transfers.push(arg.data.buffer);
  31785. }
  31786. break;
  31787. }
  31788. }
  31789. return transfers;
  31790. }
  31791. function OperatorList(intent, messageHandler, pageIndex) {
  31792. this.messageHandler = messageHandler;
  31793. this.fnArray = [];
  31794. this.argsArray = [];
  31795. this.dependencies = Object.create(null);
  31796. this._totalLength = 0;
  31797. this.pageIndex = pageIndex;
  31798. this.intent = intent;
  31799. }
  31800. OperatorList.prototype = {
  31801. get length() {
  31802. return this.argsArray.length;
  31803. },
  31804. get totalLength() {
  31805. return this._totalLength + this.length;
  31806. },
  31807. addOp: function (fn, args) {
  31808. this.fnArray.push(fn);
  31809. this.argsArray.push(args);
  31810. if (this.messageHandler) {
  31811. if (this.fnArray.length >= CHUNK_SIZE) {
  31812. this.flush();
  31813. } else if (this.fnArray.length >= CHUNK_SIZE_ABOUT && (fn === OPS.restore || fn === OPS.endText)) {
  31814. this.flush();
  31815. }
  31816. }
  31817. },
  31818. addDependency: function (dependency) {
  31819. if (dependency in this.dependencies) {
  31820. return;
  31821. }
  31822. this.dependencies[dependency] = true;
  31823. this.addOp(OPS.dependency, [dependency]);
  31824. },
  31825. addDependencies: function (dependencies) {
  31826. for (var key in dependencies) {
  31827. this.addDependency(key);
  31828. }
  31829. },
  31830. addOpList: function (opList) {
  31831. Util.extendObj(this.dependencies, opList.dependencies);
  31832. for (var i = 0, ii = opList.length; i < ii; i++) {
  31833. this.addOp(opList.fnArray[i], opList.argsArray[i]);
  31834. }
  31835. },
  31836. getIR: function () {
  31837. return {
  31838. fnArray: this.fnArray,
  31839. argsArray: this.argsArray,
  31840. length: this.length
  31841. };
  31842. },
  31843. flush: function (lastChunk) {
  31844. if (this.intent !== 'oplist') {
  31845. new QueueOptimizer().optimize(this);
  31846. }
  31847. var transfers = getTransfers(this);
  31848. var length = this.length;
  31849. this._totalLength += length;
  31850. this.messageHandler.send('RenderPageChunk', {
  31851. operatorList: {
  31852. fnArray: this.fnArray,
  31853. argsArray: this.argsArray,
  31854. lastChunk: lastChunk,
  31855. length: length
  31856. },
  31857. pageIndex: this.pageIndex,
  31858. intent: this.intent
  31859. }, transfers);
  31860. this.dependencies = Object.create(null);
  31861. this.fnArray.length = 0;
  31862. this.argsArray.length = 0;
  31863. }
  31864. };
  31865. return OperatorList;
  31866. }();
  31867. var StateManager = function StateManagerClosure() {
  31868. function StateManager(initialState) {
  31869. this.state = initialState;
  31870. this.stateStack = [];
  31871. }
  31872. StateManager.prototype = {
  31873. save: function () {
  31874. var old = this.state;
  31875. this.stateStack.push(this.state);
  31876. this.state = old.clone();
  31877. },
  31878. restore: function () {
  31879. var prev = this.stateStack.pop();
  31880. if (prev) {
  31881. this.state = prev;
  31882. }
  31883. },
  31884. transform: function (args) {
  31885. this.state.ctm = Util.transform(this.state.ctm, args);
  31886. }
  31887. };
  31888. return StateManager;
  31889. }();
  31890. var TextState = function TextStateClosure() {
  31891. function TextState() {
  31892. this.ctm = new Float32Array(IDENTITY_MATRIX);
  31893. this.fontName = null;
  31894. this.fontSize = 0;
  31895. this.font = null;
  31896. this.fontMatrix = FONT_IDENTITY_MATRIX;
  31897. this.textMatrix = IDENTITY_MATRIX.slice();
  31898. this.textLineMatrix = IDENTITY_MATRIX.slice();
  31899. this.charSpacing = 0;
  31900. this.wordSpacing = 0;
  31901. this.leading = 0;
  31902. this.textHScale = 1;
  31903. this.textRise = 0;
  31904. }
  31905. TextState.prototype = {
  31906. setTextMatrix: function TextState_setTextMatrix(a, b, c, d, e, f) {
  31907. var m = this.textMatrix;
  31908. m[0] = a;
  31909. m[1] = b;
  31910. m[2] = c;
  31911. m[3] = d;
  31912. m[4] = e;
  31913. m[5] = f;
  31914. },
  31915. setTextLineMatrix: function TextState_setTextMatrix(a, b, c, d, e, f) {
  31916. var m = this.textLineMatrix;
  31917. m[0] = a;
  31918. m[1] = b;
  31919. m[2] = c;
  31920. m[3] = d;
  31921. m[4] = e;
  31922. m[5] = f;
  31923. },
  31924. translateTextMatrix: function TextState_translateTextMatrix(x, y) {
  31925. var m = this.textMatrix;
  31926. m[4] = m[0] * x + m[2] * y + m[4];
  31927. m[5] = m[1] * x + m[3] * y + m[5];
  31928. },
  31929. translateTextLineMatrix: function TextState_translateTextMatrix(x, y) {
  31930. var m = this.textLineMatrix;
  31931. m[4] = m[0] * x + m[2] * y + m[4];
  31932. m[5] = m[1] * x + m[3] * y + m[5];
  31933. },
  31934. calcTextLineMatrixAdvance: function TextState_calcTextLineMatrixAdvance(a, b, c, d, e, f) {
  31935. var font = this.font;
  31936. if (!font) {
  31937. return null;
  31938. }
  31939. var m = this.textLineMatrix;
  31940. if (!(a === m[0] && b === m[1] && c === m[2] && d === m[3])) {
  31941. return null;
  31942. }
  31943. var txDiff = e - m[4], tyDiff = f - m[5];
  31944. if (font.vertical && txDiff !== 0 || !font.vertical && tyDiff !== 0) {
  31945. return null;
  31946. }
  31947. var tx, ty, denominator = a * d - b * c;
  31948. if (font.vertical) {
  31949. tx = -tyDiff * c / denominator;
  31950. ty = tyDiff * a / denominator;
  31951. } else {
  31952. tx = txDiff * d / denominator;
  31953. ty = -txDiff * b / denominator;
  31954. }
  31955. return {
  31956. width: tx,
  31957. height: ty,
  31958. value: font.vertical ? ty : tx
  31959. };
  31960. },
  31961. calcRenderMatrix: function TextState_calcRendeMatrix(ctm) {
  31962. var tsm = [
  31963. this.fontSize * this.textHScale,
  31964. 0,
  31965. 0,
  31966. this.fontSize,
  31967. 0,
  31968. this.textRise
  31969. ];
  31970. return Util.transform(ctm, Util.transform(this.textMatrix, tsm));
  31971. },
  31972. carriageReturn: function TextState_carriageReturn() {
  31973. this.translateTextLineMatrix(0, -this.leading);
  31974. this.textMatrix = this.textLineMatrix.slice();
  31975. },
  31976. clone: function TextState_clone() {
  31977. var clone = Object.create(this);
  31978. clone.textMatrix = this.textMatrix.slice();
  31979. clone.textLineMatrix = this.textLineMatrix.slice();
  31980. clone.fontMatrix = this.fontMatrix.slice();
  31981. return clone;
  31982. }
  31983. };
  31984. return TextState;
  31985. }();
  31986. var EvalState = function EvalStateClosure() {
  31987. function EvalState() {
  31988. this.ctm = new Float32Array(IDENTITY_MATRIX);
  31989. this.font = null;
  31990. this.textRenderingMode = TextRenderingMode.FILL;
  31991. this.fillColorSpace = ColorSpace.singletons.gray;
  31992. this.strokeColorSpace = ColorSpace.singletons.gray;
  31993. }
  31994. EvalState.prototype = {
  31995. clone: function CanvasExtraState_clone() {
  31996. return Object.create(this);
  31997. }
  31998. };
  31999. return EvalState;
  32000. }();
  32001. var EvaluatorPreprocessor = function EvaluatorPreprocessorClosure() {
  32002. var getOPMap = getLookupTableFactory(function (t) {
  32003. t['w'] = {
  32004. id: OPS.setLineWidth,
  32005. numArgs: 1,
  32006. variableArgs: false
  32007. };
  32008. t['J'] = {
  32009. id: OPS.setLineCap,
  32010. numArgs: 1,
  32011. variableArgs: false
  32012. };
  32013. t['j'] = {
  32014. id: OPS.setLineJoin,
  32015. numArgs: 1,
  32016. variableArgs: false
  32017. };
  32018. t['M'] = {
  32019. id: OPS.setMiterLimit,
  32020. numArgs: 1,
  32021. variableArgs: false
  32022. };
  32023. t['d'] = {
  32024. id: OPS.setDash,
  32025. numArgs: 2,
  32026. variableArgs: false
  32027. };
  32028. t['ri'] = {
  32029. id: OPS.setRenderingIntent,
  32030. numArgs: 1,
  32031. variableArgs: false
  32032. };
  32033. t['i'] = {
  32034. id: OPS.setFlatness,
  32035. numArgs: 1,
  32036. variableArgs: false
  32037. };
  32038. t['gs'] = {
  32039. id: OPS.setGState,
  32040. numArgs: 1,
  32041. variableArgs: false
  32042. };
  32043. t['q'] = {
  32044. id: OPS.save,
  32045. numArgs: 0,
  32046. variableArgs: false
  32047. };
  32048. t['Q'] = {
  32049. id: OPS.restore,
  32050. numArgs: 0,
  32051. variableArgs: false
  32052. };
  32053. t['cm'] = {
  32054. id: OPS.transform,
  32055. numArgs: 6,
  32056. variableArgs: false
  32057. };
  32058. t['m'] = {
  32059. id: OPS.moveTo,
  32060. numArgs: 2,
  32061. variableArgs: false
  32062. };
  32063. t['l'] = {
  32064. id: OPS.lineTo,
  32065. numArgs: 2,
  32066. variableArgs: false
  32067. };
  32068. t['c'] = {
  32069. id: OPS.curveTo,
  32070. numArgs: 6,
  32071. variableArgs: false
  32072. };
  32073. t['v'] = {
  32074. id: OPS.curveTo2,
  32075. numArgs: 4,
  32076. variableArgs: false
  32077. };
  32078. t['y'] = {
  32079. id: OPS.curveTo3,
  32080. numArgs: 4,
  32081. variableArgs: false
  32082. };
  32083. t['h'] = {
  32084. id: OPS.closePath,
  32085. numArgs: 0,
  32086. variableArgs: false
  32087. };
  32088. t['re'] = {
  32089. id: OPS.rectangle,
  32090. numArgs: 4,
  32091. variableArgs: false
  32092. };
  32093. t['S'] = {
  32094. id: OPS.stroke,
  32095. numArgs: 0,
  32096. variableArgs: false
  32097. };
  32098. t['s'] = {
  32099. id: OPS.closeStroke,
  32100. numArgs: 0,
  32101. variableArgs: false
  32102. };
  32103. t['f'] = {
  32104. id: OPS.fill,
  32105. numArgs: 0,
  32106. variableArgs: false
  32107. };
  32108. t['F'] = {
  32109. id: OPS.fill,
  32110. numArgs: 0,
  32111. variableArgs: false
  32112. };
  32113. t['f*'] = {
  32114. id: OPS.eoFill,
  32115. numArgs: 0,
  32116. variableArgs: false
  32117. };
  32118. t['B'] = {
  32119. id: OPS.fillStroke,
  32120. numArgs: 0,
  32121. variableArgs: false
  32122. };
  32123. t['B*'] = {
  32124. id: OPS.eoFillStroke,
  32125. numArgs: 0,
  32126. variableArgs: false
  32127. };
  32128. t['b'] = {
  32129. id: OPS.closeFillStroke,
  32130. numArgs: 0,
  32131. variableArgs: false
  32132. };
  32133. t['b*'] = {
  32134. id: OPS.closeEOFillStroke,
  32135. numArgs: 0,
  32136. variableArgs: false
  32137. };
  32138. t['n'] = {
  32139. id: OPS.endPath,
  32140. numArgs: 0,
  32141. variableArgs: false
  32142. };
  32143. t['W'] = {
  32144. id: OPS.clip,
  32145. numArgs: 0,
  32146. variableArgs: false
  32147. };
  32148. t['W*'] = {
  32149. id: OPS.eoClip,
  32150. numArgs: 0,
  32151. variableArgs: false
  32152. };
  32153. t['BT'] = {
  32154. id: OPS.beginText,
  32155. numArgs: 0,
  32156. variableArgs: false
  32157. };
  32158. t['ET'] = {
  32159. id: OPS.endText,
  32160. numArgs: 0,
  32161. variableArgs: false
  32162. };
  32163. t['Tc'] = {
  32164. id: OPS.setCharSpacing,
  32165. numArgs: 1,
  32166. variableArgs: false
  32167. };
  32168. t['Tw'] = {
  32169. id: OPS.setWordSpacing,
  32170. numArgs: 1,
  32171. variableArgs: false
  32172. };
  32173. t['Tz'] = {
  32174. id: OPS.setHScale,
  32175. numArgs: 1,
  32176. variableArgs: false
  32177. };
  32178. t['TL'] = {
  32179. id: OPS.setLeading,
  32180. numArgs: 1,
  32181. variableArgs: false
  32182. };
  32183. t['Tf'] = {
  32184. id: OPS.setFont,
  32185. numArgs: 2,
  32186. variableArgs: false
  32187. };
  32188. t['Tr'] = {
  32189. id: OPS.setTextRenderingMode,
  32190. numArgs: 1,
  32191. variableArgs: false
  32192. };
  32193. t['Ts'] = {
  32194. id: OPS.setTextRise,
  32195. numArgs: 1,
  32196. variableArgs: false
  32197. };
  32198. t['Td'] = {
  32199. id: OPS.moveText,
  32200. numArgs: 2,
  32201. variableArgs: false
  32202. };
  32203. t['TD'] = {
  32204. id: OPS.setLeadingMoveText,
  32205. numArgs: 2,
  32206. variableArgs: false
  32207. };
  32208. t['Tm'] = {
  32209. id: OPS.setTextMatrix,
  32210. numArgs: 6,
  32211. variableArgs: false
  32212. };
  32213. t['T*'] = {
  32214. id: OPS.nextLine,
  32215. numArgs: 0,
  32216. variableArgs: false
  32217. };
  32218. t['Tj'] = {
  32219. id: OPS.showText,
  32220. numArgs: 1,
  32221. variableArgs: false
  32222. };
  32223. t['TJ'] = {
  32224. id: OPS.showSpacedText,
  32225. numArgs: 1,
  32226. variableArgs: false
  32227. };
  32228. t['\''] = {
  32229. id: OPS.nextLineShowText,
  32230. numArgs: 1,
  32231. variableArgs: false
  32232. };
  32233. t['"'] = {
  32234. id: OPS.nextLineSetSpacingShowText,
  32235. numArgs: 3,
  32236. variableArgs: false
  32237. };
  32238. t['d0'] = {
  32239. id: OPS.setCharWidth,
  32240. numArgs: 2,
  32241. variableArgs: false
  32242. };
  32243. t['d1'] = {
  32244. id: OPS.setCharWidthAndBounds,
  32245. numArgs: 6,
  32246. variableArgs: false
  32247. };
  32248. t['CS'] = {
  32249. id: OPS.setStrokeColorSpace,
  32250. numArgs: 1,
  32251. variableArgs: false
  32252. };
  32253. t['cs'] = {
  32254. id: OPS.setFillColorSpace,
  32255. numArgs: 1,
  32256. variableArgs: false
  32257. };
  32258. t['SC'] = {
  32259. id: OPS.setStrokeColor,
  32260. numArgs: 4,
  32261. variableArgs: true
  32262. };
  32263. t['SCN'] = {
  32264. id: OPS.setStrokeColorN,
  32265. numArgs: 33,
  32266. variableArgs: true
  32267. };
  32268. t['sc'] = {
  32269. id: OPS.setFillColor,
  32270. numArgs: 4,
  32271. variableArgs: true
  32272. };
  32273. t['scn'] = {
  32274. id: OPS.setFillColorN,
  32275. numArgs: 33,
  32276. variableArgs: true
  32277. };
  32278. t['G'] = {
  32279. id: OPS.setStrokeGray,
  32280. numArgs: 1,
  32281. variableArgs: false
  32282. };
  32283. t['g'] = {
  32284. id: OPS.setFillGray,
  32285. numArgs: 1,
  32286. variableArgs: false
  32287. };
  32288. t['RG'] = {
  32289. id: OPS.setStrokeRGBColor,
  32290. numArgs: 3,
  32291. variableArgs: false
  32292. };
  32293. t['rg'] = {
  32294. id: OPS.setFillRGBColor,
  32295. numArgs: 3,
  32296. variableArgs: false
  32297. };
  32298. t['K'] = {
  32299. id: OPS.setStrokeCMYKColor,
  32300. numArgs: 4,
  32301. variableArgs: false
  32302. };
  32303. t['k'] = {
  32304. id: OPS.setFillCMYKColor,
  32305. numArgs: 4,
  32306. variableArgs: false
  32307. };
  32308. t['sh'] = {
  32309. id: OPS.shadingFill,
  32310. numArgs: 1,
  32311. variableArgs: false
  32312. };
  32313. t['BI'] = {
  32314. id: OPS.beginInlineImage,
  32315. numArgs: 0,
  32316. variableArgs: false
  32317. };
  32318. t['ID'] = {
  32319. id: OPS.beginImageData,
  32320. numArgs: 0,
  32321. variableArgs: false
  32322. };
  32323. t['EI'] = {
  32324. id: OPS.endInlineImage,
  32325. numArgs: 1,
  32326. variableArgs: false
  32327. };
  32328. t['Do'] = {
  32329. id: OPS.paintXObject,
  32330. numArgs: 1,
  32331. variableArgs: false
  32332. };
  32333. t['MP'] = {
  32334. id: OPS.markPoint,
  32335. numArgs: 1,
  32336. variableArgs: false
  32337. };
  32338. t['DP'] = {
  32339. id: OPS.markPointProps,
  32340. numArgs: 2,
  32341. variableArgs: false
  32342. };
  32343. t['BMC'] = {
  32344. id: OPS.beginMarkedContent,
  32345. numArgs: 1,
  32346. variableArgs: false
  32347. };
  32348. t['BDC'] = {
  32349. id: OPS.beginMarkedContentProps,
  32350. numArgs: 2,
  32351. variableArgs: false
  32352. };
  32353. t['EMC'] = {
  32354. id: OPS.endMarkedContent,
  32355. numArgs: 0,
  32356. variableArgs: false
  32357. };
  32358. t['BX'] = {
  32359. id: OPS.beginCompat,
  32360. numArgs: 0,
  32361. variableArgs: false
  32362. };
  32363. t['EX'] = {
  32364. id: OPS.endCompat,
  32365. numArgs: 0,
  32366. variableArgs: false
  32367. };
  32368. t['BM'] = null;
  32369. t['BD'] = null;
  32370. t['true'] = null;
  32371. t['fa'] = null;
  32372. t['fal'] = null;
  32373. t['fals'] = null;
  32374. t['false'] = null;
  32375. t['nu'] = null;
  32376. t['nul'] = null;
  32377. t['null'] = null;
  32378. });
  32379. function EvaluatorPreprocessor(stream, xref, stateManager) {
  32380. this.opMap = getOPMap();
  32381. this.parser = new Parser(new Lexer(stream, this.opMap), false, xref);
  32382. this.stateManager = stateManager;
  32383. this.nonProcessedArgs = [];
  32384. }
  32385. EvaluatorPreprocessor.prototype = {
  32386. get savedStatesDepth() {
  32387. return this.stateManager.stateStack.length;
  32388. },
  32389. read: function EvaluatorPreprocessor_read(operation) {
  32390. var args = operation.args;
  32391. while (true) {
  32392. var obj = this.parser.getObj();
  32393. if (isCmd(obj)) {
  32394. var cmd = obj.cmd;
  32395. var opSpec = this.opMap[cmd];
  32396. if (!opSpec) {
  32397. warn('Unknown command "' + cmd + '"');
  32398. continue;
  32399. }
  32400. var fn = opSpec.id;
  32401. var numArgs = opSpec.numArgs;
  32402. var argsLength = args !== null ? args.length : 0;
  32403. if (!opSpec.variableArgs) {
  32404. if (argsLength !== numArgs) {
  32405. var nonProcessedArgs = this.nonProcessedArgs;
  32406. while (argsLength > numArgs) {
  32407. nonProcessedArgs.push(args.shift());
  32408. argsLength--;
  32409. }
  32410. while (argsLength < numArgs && nonProcessedArgs.length !== 0) {
  32411. if (args === null) {
  32412. args = [];
  32413. }
  32414. args.unshift(nonProcessedArgs.pop());
  32415. argsLength++;
  32416. }
  32417. }
  32418. if (argsLength < numArgs) {
  32419. warn('Skipping command ' + fn + ': expected ' + numArgs + ' args, but received ' + argsLength + ' args.');
  32420. if (args !== null) {
  32421. args.length = 0;
  32422. }
  32423. continue;
  32424. }
  32425. } else if (argsLength > numArgs) {
  32426. info('Command ' + fn + ': expected [0,' + numArgs + '] args, but received ' + argsLength + ' args.');
  32427. }
  32428. this.preprocessCommand(fn, args);
  32429. operation.fn = fn;
  32430. operation.args = args;
  32431. return true;
  32432. }
  32433. if (isEOF(obj)) {
  32434. return false;
  32435. }
  32436. if (obj !== null) {
  32437. if (args === null) {
  32438. args = [];
  32439. }
  32440. args.push(obj);
  32441. assert(args.length <= 33, 'Too many arguments');
  32442. }
  32443. }
  32444. },
  32445. preprocessCommand: function EvaluatorPreprocessor_preprocessCommand(fn, args) {
  32446. switch (fn | 0) {
  32447. case OPS.save:
  32448. this.stateManager.save();
  32449. break;
  32450. case OPS.restore:
  32451. this.stateManager.restore();
  32452. break;
  32453. case OPS.transform:
  32454. this.stateManager.transform(args);
  32455. break;
  32456. }
  32457. }
  32458. };
  32459. return EvaluatorPreprocessor;
  32460. }();
  32461. var QueueOptimizer = function QueueOptimizerClosure() {
  32462. function addState(parentState, pattern, fn) {
  32463. var state = parentState;
  32464. for (var i = 0, ii = pattern.length - 1; i < ii; i++) {
  32465. var item = pattern[i];
  32466. state = state[item] || (state[item] = []);
  32467. }
  32468. state[pattern[pattern.length - 1]] = fn;
  32469. }
  32470. function handlePaintSolidColorImageMask(iFirstSave, count, fnArray, argsArray) {
  32471. var iFirstPIMXO = iFirstSave + 2;
  32472. for (var i = 0; i < count; i++) {
  32473. var arg = argsArray[iFirstPIMXO + 4 * i];
  32474. var imageMask = arg.length === 1 && arg[0];
  32475. if (imageMask && imageMask.width === 1 && imageMask.height === 1 && (!imageMask.data.length || imageMask.data.length === 1 && imageMask.data[0] === 0)) {
  32476. fnArray[iFirstPIMXO + 4 * i] = OPS.paintSolidColorImageMask;
  32477. continue;
  32478. }
  32479. break;
  32480. }
  32481. return count - i;
  32482. }
  32483. var InitialState = [];
  32484. addState(InitialState, [
  32485. OPS.save,
  32486. OPS.transform,
  32487. OPS.paintInlineImageXObject,
  32488. OPS.restore
  32489. ], function foundInlineImageGroup(context) {
  32490. var MIN_IMAGES_IN_INLINE_IMAGES_BLOCK = 10;
  32491. var MAX_IMAGES_IN_INLINE_IMAGES_BLOCK = 200;
  32492. var MAX_WIDTH = 1000;
  32493. var IMAGE_PADDING = 1;
  32494. var fnArray = context.fnArray, argsArray = context.argsArray;
  32495. var curr = context.iCurr;
  32496. var iFirstSave = curr - 3;
  32497. var iFirstTransform = curr - 2;
  32498. var iFirstPIIXO = curr - 1;
  32499. var i = iFirstSave + 4;
  32500. var ii = fnArray.length;
  32501. while (i + 3 < ii) {
  32502. if (fnArray[i] !== OPS.save || fnArray[i + 1] !== OPS.transform || fnArray[i + 2] !== OPS.paintInlineImageXObject || fnArray[i + 3] !== OPS.restore) {
  32503. break;
  32504. }
  32505. i += 4;
  32506. }
  32507. var count = Math.min((i - iFirstSave) / 4, MAX_IMAGES_IN_INLINE_IMAGES_BLOCK);
  32508. if (count < MIN_IMAGES_IN_INLINE_IMAGES_BLOCK) {
  32509. return i;
  32510. }
  32511. var maxX = 0;
  32512. var map = [], maxLineHeight = 0;
  32513. var currentX = IMAGE_PADDING, currentY = IMAGE_PADDING;
  32514. var q;
  32515. for (q = 0; q < count; q++) {
  32516. var transform = argsArray[iFirstTransform + (q << 2)];
  32517. var img = argsArray[iFirstPIIXO + (q << 2)][0];
  32518. if (currentX + img.width > MAX_WIDTH) {
  32519. maxX = Math.max(maxX, currentX);
  32520. currentY += maxLineHeight + 2 * IMAGE_PADDING;
  32521. currentX = 0;
  32522. maxLineHeight = 0;
  32523. }
  32524. map.push({
  32525. transform: transform,
  32526. x: currentX,
  32527. y: currentY,
  32528. w: img.width,
  32529. h: img.height
  32530. });
  32531. currentX += img.width + 2 * IMAGE_PADDING;
  32532. maxLineHeight = Math.max(maxLineHeight, img.height);
  32533. }
  32534. var imgWidth = Math.max(maxX, currentX) + IMAGE_PADDING;
  32535. var imgHeight = currentY + maxLineHeight + IMAGE_PADDING;
  32536. var imgData = new Uint8Array(imgWidth * imgHeight * 4);
  32537. var imgRowSize = imgWidth << 2;
  32538. for (q = 0; q < count; q++) {
  32539. var data = argsArray[iFirstPIIXO + (q << 2)][0].data;
  32540. var rowSize = map[q].w << 2;
  32541. var dataOffset = 0;
  32542. var offset = map[q].x + map[q].y * imgWidth << 2;
  32543. imgData.set(data.subarray(0, rowSize), offset - imgRowSize);
  32544. for (var k = 0, kk = map[q].h; k < kk; k++) {
  32545. imgData.set(data.subarray(dataOffset, dataOffset + rowSize), offset);
  32546. dataOffset += rowSize;
  32547. offset += imgRowSize;
  32548. }
  32549. imgData.set(data.subarray(dataOffset - rowSize, dataOffset), offset);
  32550. while (offset >= 0) {
  32551. data[offset - 4] = data[offset];
  32552. data[offset - 3] = data[offset + 1];
  32553. data[offset - 2] = data[offset + 2];
  32554. data[offset - 1] = data[offset + 3];
  32555. data[offset + rowSize] = data[offset + rowSize - 4];
  32556. data[offset + rowSize + 1] = data[offset + rowSize - 3];
  32557. data[offset + rowSize + 2] = data[offset + rowSize - 2];
  32558. data[offset + rowSize + 3] = data[offset + rowSize - 1];
  32559. offset -= imgRowSize;
  32560. }
  32561. }
  32562. fnArray.splice(iFirstSave, count * 4, OPS.paintInlineImageXObjectGroup);
  32563. argsArray.splice(iFirstSave, count * 4, [
  32564. {
  32565. width: imgWidth,
  32566. height: imgHeight,
  32567. kind: ImageKind.RGBA_32BPP,
  32568. data: imgData
  32569. },
  32570. map
  32571. ]);
  32572. return iFirstSave + 1;
  32573. });
  32574. addState(InitialState, [
  32575. OPS.save,
  32576. OPS.transform,
  32577. OPS.paintImageMaskXObject,
  32578. OPS.restore
  32579. ], function foundImageMaskGroup(context) {
  32580. var MIN_IMAGES_IN_MASKS_BLOCK = 10;
  32581. var MAX_IMAGES_IN_MASKS_BLOCK = 100;
  32582. var MAX_SAME_IMAGES_IN_MASKS_BLOCK = 1000;
  32583. var fnArray = context.fnArray, argsArray = context.argsArray;
  32584. var curr = context.iCurr;
  32585. var iFirstSave = curr - 3;
  32586. var iFirstTransform = curr - 2;
  32587. var iFirstPIMXO = curr - 1;
  32588. var i = iFirstSave + 4;
  32589. var ii = fnArray.length;
  32590. while (i + 3 < ii) {
  32591. if (fnArray[i] !== OPS.save || fnArray[i + 1] !== OPS.transform || fnArray[i + 2] !== OPS.paintImageMaskXObject || fnArray[i + 3] !== OPS.restore) {
  32592. break;
  32593. }
  32594. i += 4;
  32595. }
  32596. var count = (i - iFirstSave) / 4;
  32597. count = handlePaintSolidColorImageMask(iFirstSave, count, fnArray, argsArray);
  32598. if (count < MIN_IMAGES_IN_MASKS_BLOCK) {
  32599. return i;
  32600. }
  32601. var q;
  32602. var isSameImage = false;
  32603. var iTransform, transformArgs;
  32604. var firstPIMXOArg0 = argsArray[iFirstPIMXO][0];
  32605. if (argsArray[iFirstTransform][1] === 0 && argsArray[iFirstTransform][2] === 0) {
  32606. isSameImage = true;
  32607. var firstTransformArg0 = argsArray[iFirstTransform][0];
  32608. var firstTransformArg3 = argsArray[iFirstTransform][3];
  32609. iTransform = iFirstTransform + 4;
  32610. var iPIMXO = iFirstPIMXO + 4;
  32611. for (q = 1; q < count; q++, iTransform += 4, iPIMXO += 4) {
  32612. transformArgs = argsArray[iTransform];
  32613. if (argsArray[iPIMXO][0] !== firstPIMXOArg0 || transformArgs[0] !== firstTransformArg0 || transformArgs[1] !== 0 || transformArgs[2] !== 0 || transformArgs[3] !== firstTransformArg3) {
  32614. if (q < MIN_IMAGES_IN_MASKS_BLOCK) {
  32615. isSameImage = false;
  32616. } else {
  32617. count = q;
  32618. }
  32619. break;
  32620. }
  32621. }
  32622. }
  32623. if (isSameImage) {
  32624. count = Math.min(count, MAX_SAME_IMAGES_IN_MASKS_BLOCK);
  32625. var positions = new Float32Array(count * 2);
  32626. iTransform = iFirstTransform;
  32627. for (q = 0; q < count; q++, iTransform += 4) {
  32628. transformArgs = argsArray[iTransform];
  32629. positions[q << 1] = transformArgs[4];
  32630. positions[(q << 1) + 1] = transformArgs[5];
  32631. }
  32632. fnArray.splice(iFirstSave, count * 4, OPS.paintImageMaskXObjectRepeat);
  32633. argsArray.splice(iFirstSave, count * 4, [
  32634. firstPIMXOArg0,
  32635. firstTransformArg0,
  32636. firstTransformArg3,
  32637. positions
  32638. ]);
  32639. } else {
  32640. count = Math.min(count, MAX_IMAGES_IN_MASKS_BLOCK);
  32641. var images = [];
  32642. for (q = 0; q < count; q++) {
  32643. transformArgs = argsArray[iFirstTransform + (q << 2)];
  32644. var maskParams = argsArray[iFirstPIMXO + (q << 2)][0];
  32645. images.push({
  32646. data: maskParams.data,
  32647. width: maskParams.width,
  32648. height: maskParams.height,
  32649. transform: transformArgs
  32650. });
  32651. }
  32652. fnArray.splice(iFirstSave, count * 4, OPS.paintImageMaskXObjectGroup);
  32653. argsArray.splice(iFirstSave, count * 4, [images]);
  32654. }
  32655. return iFirstSave + 1;
  32656. });
  32657. addState(InitialState, [
  32658. OPS.save,
  32659. OPS.transform,
  32660. OPS.paintImageXObject,
  32661. OPS.restore
  32662. ], function (context) {
  32663. var MIN_IMAGES_IN_BLOCK = 3;
  32664. var MAX_IMAGES_IN_BLOCK = 1000;
  32665. var fnArray = context.fnArray, argsArray = context.argsArray;
  32666. var curr = context.iCurr;
  32667. var iFirstSave = curr - 3;
  32668. var iFirstTransform = curr - 2;
  32669. var iFirstPIXO = curr - 1;
  32670. var iFirstRestore = curr;
  32671. if (argsArray[iFirstTransform][1] !== 0 || argsArray[iFirstTransform][2] !== 0) {
  32672. return iFirstRestore + 1;
  32673. }
  32674. var firstPIXOArg0 = argsArray[iFirstPIXO][0];
  32675. var firstTransformArg0 = argsArray[iFirstTransform][0];
  32676. var firstTransformArg3 = argsArray[iFirstTransform][3];
  32677. var i = iFirstSave + 4;
  32678. var ii = fnArray.length;
  32679. while (i + 3 < ii) {
  32680. if (fnArray[i] !== OPS.save || fnArray[i + 1] !== OPS.transform || fnArray[i + 2] !== OPS.paintImageXObject || fnArray[i + 3] !== OPS.restore) {
  32681. break;
  32682. }
  32683. if (argsArray[i + 1][0] !== firstTransformArg0 || argsArray[i + 1][1] !== 0 || argsArray[i + 1][2] !== 0 || argsArray[i + 1][3] !== firstTransformArg3) {
  32684. break;
  32685. }
  32686. if (argsArray[i + 2][0] !== firstPIXOArg0) {
  32687. break;
  32688. }
  32689. i += 4;
  32690. }
  32691. var count = Math.min((i - iFirstSave) / 4, MAX_IMAGES_IN_BLOCK);
  32692. if (count < MIN_IMAGES_IN_BLOCK) {
  32693. return i;
  32694. }
  32695. var positions = new Float32Array(count * 2);
  32696. var iTransform = iFirstTransform;
  32697. for (var q = 0; q < count; q++, iTransform += 4) {
  32698. var transformArgs = argsArray[iTransform];
  32699. positions[q << 1] = transformArgs[4];
  32700. positions[(q << 1) + 1] = transformArgs[5];
  32701. }
  32702. var args = [
  32703. firstPIXOArg0,
  32704. firstTransformArg0,
  32705. firstTransformArg3,
  32706. positions
  32707. ];
  32708. fnArray.splice(iFirstSave, count * 4, OPS.paintImageXObjectRepeat);
  32709. argsArray.splice(iFirstSave, count * 4, args);
  32710. return iFirstSave + 1;
  32711. });
  32712. addState(InitialState, [
  32713. OPS.beginText,
  32714. OPS.setFont,
  32715. OPS.setTextMatrix,
  32716. OPS.showText,
  32717. OPS.endText
  32718. ], function (context) {
  32719. var MIN_CHARS_IN_BLOCK = 3;
  32720. var MAX_CHARS_IN_BLOCK = 1000;
  32721. var fnArray = context.fnArray, argsArray = context.argsArray;
  32722. var curr = context.iCurr;
  32723. var iFirstBeginText = curr - 4;
  32724. var iFirstSetFont = curr - 3;
  32725. var iFirstSetTextMatrix = curr - 2;
  32726. var iFirstShowText = curr - 1;
  32727. var iFirstEndText = curr;
  32728. var firstSetFontArg0 = argsArray[iFirstSetFont][0];
  32729. var firstSetFontArg1 = argsArray[iFirstSetFont][1];
  32730. var i = iFirstBeginText + 5;
  32731. var ii = fnArray.length;
  32732. while (i + 4 < ii) {
  32733. 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) {
  32734. break;
  32735. }
  32736. if (argsArray[i + 1][0] !== firstSetFontArg0 || argsArray[i + 1][1] !== firstSetFontArg1) {
  32737. break;
  32738. }
  32739. i += 5;
  32740. }
  32741. var count = Math.min((i - iFirstBeginText) / 5, MAX_CHARS_IN_BLOCK);
  32742. if (count < MIN_CHARS_IN_BLOCK) {
  32743. return i;
  32744. }
  32745. var iFirst = iFirstBeginText;
  32746. 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) {
  32747. count++;
  32748. iFirst -= 5;
  32749. }
  32750. var iEndText = iFirst + 4;
  32751. for (var q = 1; q < count; q++) {
  32752. fnArray.splice(iEndText, 3);
  32753. argsArray.splice(iEndText, 3);
  32754. iEndText += 2;
  32755. }
  32756. return iEndText + 1;
  32757. });
  32758. function QueueOptimizer() {
  32759. }
  32760. QueueOptimizer.prototype = {
  32761. optimize: function QueueOptimizer_optimize(queue) {
  32762. var fnArray = queue.fnArray, argsArray = queue.argsArray;
  32763. var context = {
  32764. iCurr: 0,
  32765. fnArray: fnArray,
  32766. argsArray: argsArray
  32767. };
  32768. var state;
  32769. var i = 0, ii = fnArray.length;
  32770. while (i < ii) {
  32771. state = (state || InitialState)[fnArray[i]];
  32772. if (typeof state === 'function') {
  32773. context.iCurr = i;
  32774. i = state(context);
  32775. state = undefined;
  32776. ii = context.fnArray.length;
  32777. } else {
  32778. i++;
  32779. }
  32780. }
  32781. }
  32782. };
  32783. return QueueOptimizer;
  32784. }();
  32785. exports.OperatorList = OperatorList;
  32786. exports.PartialEvaluator = PartialEvaluator;
  32787. /***/ }),
  32788. /* 19 */
  32789. /***/ (function(module, exports, __w_pdfjs_require__) {
  32790. "use strict";
  32791. var sharedUtil = __w_pdfjs_require__(0);
  32792. var coreArithmeticDecoder = __w_pdfjs_require__(14);
  32793. var info = sharedUtil.info;
  32794. var warn = sharedUtil.warn;
  32795. var error = sharedUtil.error;
  32796. var log2 = sharedUtil.log2;
  32797. var readUint16 = sharedUtil.readUint16;
  32798. var readUint32 = sharedUtil.readUint32;
  32799. var ArithmeticDecoder = coreArithmeticDecoder.ArithmeticDecoder;
  32800. var JpxImage = function JpxImageClosure() {
  32801. var SubbandsGainLog2 = {
  32802. 'LL': 0,
  32803. 'LH': 1,
  32804. 'HL': 1,
  32805. 'HH': 2
  32806. };
  32807. function JpxImage() {
  32808. this.failOnCorruptedImage = false;
  32809. }
  32810. JpxImage.prototype = {
  32811. parse: function JpxImage_parse(data) {
  32812. var head = readUint16(data, 0);
  32813. if (head === 0xFF4F) {
  32814. this.parseCodestream(data, 0, data.length);
  32815. return;
  32816. }
  32817. var position = 0, length = data.length;
  32818. while (position < length) {
  32819. var headerSize = 8;
  32820. var lbox = readUint32(data, position);
  32821. var tbox = readUint32(data, position + 4);
  32822. position += headerSize;
  32823. if (lbox === 1) {
  32824. lbox = readUint32(data, position) * 4294967296 + readUint32(data, position + 4);
  32825. position += 8;
  32826. headerSize += 8;
  32827. }
  32828. if (lbox === 0) {
  32829. lbox = length - position + headerSize;
  32830. }
  32831. if (lbox < headerSize) {
  32832. error('JPX Error: Invalid box field size');
  32833. }
  32834. var dataLength = lbox - headerSize;
  32835. var jumpDataLength = true;
  32836. switch (tbox) {
  32837. case 0x6A703268:
  32838. jumpDataLength = false;
  32839. break;
  32840. case 0x636F6C72:
  32841. var method = data[position];
  32842. if (method === 1) {
  32843. var colorspace = readUint32(data, position + 3);
  32844. switch (colorspace) {
  32845. case 16:
  32846. case 17:
  32847. case 18:
  32848. break;
  32849. default:
  32850. warn('Unknown colorspace ' + colorspace);
  32851. break;
  32852. }
  32853. } else if (method === 2) {
  32854. info('ICC profile not supported');
  32855. }
  32856. break;
  32857. case 0x6A703263:
  32858. this.parseCodestream(data, position, position + dataLength);
  32859. break;
  32860. case 0x6A502020:
  32861. if (0x0d0a870a !== readUint32(data, position)) {
  32862. warn('Invalid JP2 signature');
  32863. }
  32864. break;
  32865. case 0x6A501A1A:
  32866. case 0x66747970:
  32867. case 0x72726571:
  32868. case 0x72657320:
  32869. case 0x69686472:
  32870. break;
  32871. default:
  32872. var headerType = String.fromCharCode(tbox >> 24 & 0xFF, tbox >> 16 & 0xFF, tbox >> 8 & 0xFF, tbox & 0xFF);
  32873. warn('Unsupported header type ' + tbox + ' (' + headerType + ')');
  32874. break;
  32875. }
  32876. if (jumpDataLength) {
  32877. position += dataLength;
  32878. }
  32879. }
  32880. },
  32881. parseImageProperties: function JpxImage_parseImageProperties(stream) {
  32882. var newByte = stream.getByte();
  32883. while (newByte >= 0) {
  32884. var oldByte = newByte;
  32885. newByte = stream.getByte();
  32886. var code = oldByte << 8 | newByte;
  32887. if (code === 0xFF51) {
  32888. stream.skip(4);
  32889. var Xsiz = stream.getInt32() >>> 0;
  32890. var Ysiz = stream.getInt32() >>> 0;
  32891. var XOsiz = stream.getInt32() >>> 0;
  32892. var YOsiz = stream.getInt32() >>> 0;
  32893. stream.skip(16);
  32894. var Csiz = stream.getUint16();
  32895. this.width = Xsiz - XOsiz;
  32896. this.height = Ysiz - YOsiz;
  32897. this.componentsCount = Csiz;
  32898. this.bitsPerComponent = 8;
  32899. return;
  32900. }
  32901. }
  32902. error('JPX Error: No size marker found in JPX stream');
  32903. },
  32904. parseCodestream: function JpxImage_parseCodestream(data, start, end) {
  32905. var context = {};
  32906. var doNotRecover = false;
  32907. try {
  32908. var position = start;
  32909. while (position + 1 < end) {
  32910. var code = readUint16(data, position);
  32911. position += 2;
  32912. var length = 0, j, sqcd, spqcds, spqcdSize, scalarExpounded, tile;
  32913. switch (code) {
  32914. case 0xFF4F:
  32915. context.mainHeader = true;
  32916. break;
  32917. case 0xFFD9:
  32918. break;
  32919. case 0xFF51:
  32920. length = readUint16(data, position);
  32921. var siz = {};
  32922. siz.Xsiz = readUint32(data, position + 4);
  32923. siz.Ysiz = readUint32(data, position + 8);
  32924. siz.XOsiz = readUint32(data, position + 12);
  32925. siz.YOsiz = readUint32(data, position + 16);
  32926. siz.XTsiz = readUint32(data, position + 20);
  32927. siz.YTsiz = readUint32(data, position + 24);
  32928. siz.XTOsiz = readUint32(data, position + 28);
  32929. siz.YTOsiz = readUint32(data, position + 32);
  32930. var componentsCount = readUint16(data, position + 36);
  32931. siz.Csiz = componentsCount;
  32932. var components = [];
  32933. j = position + 38;
  32934. for (var i = 0; i < componentsCount; i++) {
  32935. var component = {
  32936. precision: (data[j] & 0x7F) + 1,
  32937. isSigned: !!(data[j] & 0x80),
  32938. XRsiz: data[j + 1],
  32939. YRsiz: data[j + 1]
  32940. };
  32941. calculateComponentDimensions(component, siz);
  32942. components.push(component);
  32943. }
  32944. context.SIZ = siz;
  32945. context.components = components;
  32946. calculateTileGrids(context, components);
  32947. context.QCC = [];
  32948. context.COC = [];
  32949. break;
  32950. case 0xFF5C:
  32951. length = readUint16(data, position);
  32952. var qcd = {};
  32953. j = position + 2;
  32954. sqcd = data[j++];
  32955. switch (sqcd & 0x1F) {
  32956. case 0:
  32957. spqcdSize = 8;
  32958. scalarExpounded = true;
  32959. break;
  32960. case 1:
  32961. spqcdSize = 16;
  32962. scalarExpounded = false;
  32963. break;
  32964. case 2:
  32965. spqcdSize = 16;
  32966. scalarExpounded = true;
  32967. break;
  32968. default:
  32969. throw new Error('Invalid SQcd value ' + sqcd);
  32970. }
  32971. qcd.noQuantization = spqcdSize === 8;
  32972. qcd.scalarExpounded = scalarExpounded;
  32973. qcd.guardBits = sqcd >> 5;
  32974. spqcds = [];
  32975. while (j < length + position) {
  32976. var spqcd = {};
  32977. if (spqcdSize === 8) {
  32978. spqcd.epsilon = data[j++] >> 3;
  32979. spqcd.mu = 0;
  32980. } else {
  32981. spqcd.epsilon = data[j] >> 3;
  32982. spqcd.mu = (data[j] & 0x7) << 8 | data[j + 1];
  32983. j += 2;
  32984. }
  32985. spqcds.push(spqcd);
  32986. }
  32987. qcd.SPqcds = spqcds;
  32988. if (context.mainHeader) {
  32989. context.QCD = qcd;
  32990. } else {
  32991. context.currentTile.QCD = qcd;
  32992. context.currentTile.QCC = [];
  32993. }
  32994. break;
  32995. case 0xFF5D:
  32996. length = readUint16(data, position);
  32997. var qcc = {};
  32998. j = position + 2;
  32999. var cqcc;
  33000. if (context.SIZ.Csiz < 257) {
  33001. cqcc = data[j++];
  33002. } else {
  33003. cqcc = readUint16(data, j);
  33004. j += 2;
  33005. }
  33006. sqcd = data[j++];
  33007. switch (sqcd & 0x1F) {
  33008. case 0:
  33009. spqcdSize = 8;
  33010. scalarExpounded = true;
  33011. break;
  33012. case 1:
  33013. spqcdSize = 16;
  33014. scalarExpounded = false;
  33015. break;
  33016. case 2:
  33017. spqcdSize = 16;
  33018. scalarExpounded = true;
  33019. break;
  33020. default:
  33021. throw new Error('Invalid SQcd value ' + sqcd);
  33022. }
  33023. qcc.noQuantization = spqcdSize === 8;
  33024. qcc.scalarExpounded = scalarExpounded;
  33025. qcc.guardBits = sqcd >> 5;
  33026. spqcds = [];
  33027. while (j < length + position) {
  33028. spqcd = {};
  33029. if (spqcdSize === 8) {
  33030. spqcd.epsilon = data[j++] >> 3;
  33031. spqcd.mu = 0;
  33032. } else {
  33033. spqcd.epsilon = data[j] >> 3;
  33034. spqcd.mu = (data[j] & 0x7) << 8 | data[j + 1];
  33035. j += 2;
  33036. }
  33037. spqcds.push(spqcd);
  33038. }
  33039. qcc.SPqcds = spqcds;
  33040. if (context.mainHeader) {
  33041. context.QCC[cqcc] = qcc;
  33042. } else {
  33043. context.currentTile.QCC[cqcc] = qcc;
  33044. }
  33045. break;
  33046. case 0xFF52:
  33047. length = readUint16(data, position);
  33048. var cod = {};
  33049. j = position + 2;
  33050. var scod = data[j++];
  33051. cod.entropyCoderWithCustomPrecincts = !!(scod & 1);
  33052. cod.sopMarkerUsed = !!(scod & 2);
  33053. cod.ephMarkerUsed = !!(scod & 4);
  33054. cod.progressionOrder = data[j++];
  33055. cod.layersCount = readUint16(data, j);
  33056. j += 2;
  33057. cod.multipleComponentTransform = data[j++];
  33058. cod.decompositionLevelsCount = data[j++];
  33059. cod.xcb = (data[j++] & 0xF) + 2;
  33060. cod.ycb = (data[j++] & 0xF) + 2;
  33061. var blockStyle = data[j++];
  33062. cod.selectiveArithmeticCodingBypass = !!(blockStyle & 1);
  33063. cod.resetContextProbabilities = !!(blockStyle & 2);
  33064. cod.terminationOnEachCodingPass = !!(blockStyle & 4);
  33065. cod.verticalyStripe = !!(blockStyle & 8);
  33066. cod.predictableTermination = !!(blockStyle & 16);
  33067. cod.segmentationSymbolUsed = !!(blockStyle & 32);
  33068. cod.reversibleTransformation = data[j++];
  33069. if (cod.entropyCoderWithCustomPrecincts) {
  33070. var precinctsSizes = [];
  33071. while (j < length + position) {
  33072. var precinctsSize = data[j++];
  33073. precinctsSizes.push({
  33074. PPx: precinctsSize & 0xF,
  33075. PPy: precinctsSize >> 4
  33076. });
  33077. }
  33078. cod.precinctsSizes = precinctsSizes;
  33079. }
  33080. var unsupported = [];
  33081. if (cod.selectiveArithmeticCodingBypass) {
  33082. unsupported.push('selectiveArithmeticCodingBypass');
  33083. }
  33084. if (cod.resetContextProbabilities) {
  33085. unsupported.push('resetContextProbabilities');
  33086. }
  33087. if (cod.terminationOnEachCodingPass) {
  33088. unsupported.push('terminationOnEachCodingPass');
  33089. }
  33090. if (cod.verticalyStripe) {
  33091. unsupported.push('verticalyStripe');
  33092. }
  33093. if (cod.predictableTermination) {
  33094. unsupported.push('predictableTermination');
  33095. }
  33096. if (unsupported.length > 0) {
  33097. doNotRecover = true;
  33098. throw new Error('Unsupported COD options (' + unsupported.join(', ') + ')');
  33099. }
  33100. if (context.mainHeader) {
  33101. context.COD = cod;
  33102. } else {
  33103. context.currentTile.COD = cod;
  33104. context.currentTile.COC = [];
  33105. }
  33106. break;
  33107. case 0xFF90:
  33108. length = readUint16(data, position);
  33109. tile = {};
  33110. tile.index = readUint16(data, position + 2);
  33111. tile.length = readUint32(data, position + 4);
  33112. tile.dataEnd = tile.length + position - 2;
  33113. tile.partIndex = data[position + 8];
  33114. tile.partsCount = data[position + 9];
  33115. context.mainHeader = false;
  33116. if (tile.partIndex === 0) {
  33117. tile.COD = context.COD;
  33118. tile.COC = context.COC.slice(0);
  33119. tile.QCD = context.QCD;
  33120. tile.QCC = context.QCC.slice(0);
  33121. }
  33122. context.currentTile = tile;
  33123. break;
  33124. case 0xFF93:
  33125. tile = context.currentTile;
  33126. if (tile.partIndex === 0) {
  33127. initializeTile(context, tile.index);
  33128. buildPackets(context);
  33129. }
  33130. length = tile.dataEnd - position;
  33131. parseTilePackets(context, data, position, length);
  33132. break;
  33133. case 0xFF55:
  33134. case 0xFF57:
  33135. case 0xFF58:
  33136. case 0xFF64:
  33137. length = readUint16(data, position);
  33138. break;
  33139. case 0xFF53:
  33140. throw new Error('Codestream code 0xFF53 (COC) is ' + 'not implemented');
  33141. default:
  33142. throw new Error('Unknown codestream code: ' + code.toString(16));
  33143. }
  33144. position += length;
  33145. }
  33146. } catch (e) {
  33147. if (doNotRecover || this.failOnCorruptedImage) {
  33148. error('JPX Error: ' + e.message);
  33149. } else {
  33150. warn('JPX: Trying to recover from: ' + e.message);
  33151. }
  33152. }
  33153. this.tiles = transformComponents(context);
  33154. this.width = context.SIZ.Xsiz - context.SIZ.XOsiz;
  33155. this.height = context.SIZ.Ysiz - context.SIZ.YOsiz;
  33156. this.componentsCount = context.SIZ.Csiz;
  33157. }
  33158. };
  33159. function calculateComponentDimensions(component, siz) {
  33160. component.x0 = Math.ceil(siz.XOsiz / component.XRsiz);
  33161. component.x1 = Math.ceil(siz.Xsiz / component.XRsiz);
  33162. component.y0 = Math.ceil(siz.YOsiz / component.YRsiz);
  33163. component.y1 = Math.ceil(siz.Ysiz / component.YRsiz);
  33164. component.width = component.x1 - component.x0;
  33165. component.height = component.y1 - component.y0;
  33166. }
  33167. function calculateTileGrids(context, components) {
  33168. var siz = context.SIZ;
  33169. var tile, tiles = [];
  33170. var numXtiles = Math.ceil((siz.Xsiz - siz.XTOsiz) / siz.XTsiz);
  33171. var numYtiles = Math.ceil((siz.Ysiz - siz.YTOsiz) / siz.YTsiz);
  33172. for (var q = 0; q < numYtiles; q++) {
  33173. for (var p = 0; p < numXtiles; p++) {
  33174. tile = {};
  33175. tile.tx0 = Math.max(siz.XTOsiz + p * siz.XTsiz, siz.XOsiz);
  33176. tile.ty0 = Math.max(siz.YTOsiz + q * siz.YTsiz, siz.YOsiz);
  33177. tile.tx1 = Math.min(siz.XTOsiz + (p + 1) * siz.XTsiz, siz.Xsiz);
  33178. tile.ty1 = Math.min(siz.YTOsiz + (q + 1) * siz.YTsiz, siz.Ysiz);
  33179. tile.width = tile.tx1 - tile.tx0;
  33180. tile.height = tile.ty1 - tile.ty0;
  33181. tile.components = [];
  33182. tiles.push(tile);
  33183. }
  33184. }
  33185. context.tiles = tiles;
  33186. var componentsCount = siz.Csiz;
  33187. for (var i = 0, ii = componentsCount; i < ii; i++) {
  33188. var component = components[i];
  33189. for (var j = 0, jj = tiles.length; j < jj; j++) {
  33190. var tileComponent = {};
  33191. tile = tiles[j];
  33192. tileComponent.tcx0 = Math.ceil(tile.tx0 / component.XRsiz);
  33193. tileComponent.tcy0 = Math.ceil(tile.ty0 / component.YRsiz);
  33194. tileComponent.tcx1 = Math.ceil(tile.tx1 / component.XRsiz);
  33195. tileComponent.tcy1 = Math.ceil(tile.ty1 / component.YRsiz);
  33196. tileComponent.width = tileComponent.tcx1 - tileComponent.tcx0;
  33197. tileComponent.height = tileComponent.tcy1 - tileComponent.tcy0;
  33198. tile.components[i] = tileComponent;
  33199. }
  33200. }
  33201. }
  33202. function getBlocksDimensions(context, component, r) {
  33203. var codOrCoc = component.codingStyleParameters;
  33204. var result = {};
  33205. if (!codOrCoc.entropyCoderWithCustomPrecincts) {
  33206. result.PPx = 15;
  33207. result.PPy = 15;
  33208. } else {
  33209. result.PPx = codOrCoc.precinctsSizes[r].PPx;
  33210. result.PPy = codOrCoc.precinctsSizes[r].PPy;
  33211. }
  33212. result.xcb_ = r > 0 ? Math.min(codOrCoc.xcb, result.PPx - 1) : Math.min(codOrCoc.xcb, result.PPx);
  33213. result.ycb_ = r > 0 ? Math.min(codOrCoc.ycb, result.PPy - 1) : Math.min(codOrCoc.ycb, result.PPy);
  33214. return result;
  33215. }
  33216. function buildPrecincts(context, resolution, dimensions) {
  33217. var precinctWidth = 1 << dimensions.PPx;
  33218. var precinctHeight = 1 << dimensions.PPy;
  33219. var isZeroRes = resolution.resLevel === 0;
  33220. var precinctWidthInSubband = 1 << dimensions.PPx + (isZeroRes ? 0 : -1);
  33221. var precinctHeightInSubband = 1 << dimensions.PPy + (isZeroRes ? 0 : -1);
  33222. var numprecinctswide = resolution.trx1 > resolution.trx0 ? Math.ceil(resolution.trx1 / precinctWidth) - Math.floor(resolution.trx0 / precinctWidth) : 0;
  33223. var numprecinctshigh = resolution.try1 > resolution.try0 ? Math.ceil(resolution.try1 / precinctHeight) - Math.floor(resolution.try0 / precinctHeight) : 0;
  33224. var numprecincts = numprecinctswide * numprecinctshigh;
  33225. resolution.precinctParameters = {
  33226. precinctWidth: precinctWidth,
  33227. precinctHeight: precinctHeight,
  33228. numprecinctswide: numprecinctswide,
  33229. numprecinctshigh: numprecinctshigh,
  33230. numprecincts: numprecincts,
  33231. precinctWidthInSubband: precinctWidthInSubband,
  33232. precinctHeightInSubband: precinctHeightInSubband
  33233. };
  33234. }
  33235. function buildCodeblocks(context, subband, dimensions) {
  33236. var xcb_ = dimensions.xcb_;
  33237. var ycb_ = dimensions.ycb_;
  33238. var codeblockWidth = 1 << xcb_;
  33239. var codeblockHeight = 1 << ycb_;
  33240. var cbx0 = subband.tbx0 >> xcb_;
  33241. var cby0 = subband.tby0 >> ycb_;
  33242. var cbx1 = subband.tbx1 + codeblockWidth - 1 >> xcb_;
  33243. var cby1 = subband.tby1 + codeblockHeight - 1 >> ycb_;
  33244. var precinctParameters = subband.resolution.precinctParameters;
  33245. var codeblocks = [];
  33246. var precincts = [];
  33247. var i, j, codeblock, precinctNumber;
  33248. for (j = cby0; j < cby1; j++) {
  33249. for (i = cbx0; i < cbx1; i++) {
  33250. codeblock = {
  33251. cbx: i,
  33252. cby: j,
  33253. tbx0: codeblockWidth * i,
  33254. tby0: codeblockHeight * j,
  33255. tbx1: codeblockWidth * (i + 1),
  33256. tby1: codeblockHeight * (j + 1)
  33257. };
  33258. codeblock.tbx0_ = Math.max(subband.tbx0, codeblock.tbx0);
  33259. codeblock.tby0_ = Math.max(subband.tby0, codeblock.tby0);
  33260. codeblock.tbx1_ = Math.min(subband.tbx1, codeblock.tbx1);
  33261. codeblock.tby1_ = Math.min(subband.tby1, codeblock.tby1);
  33262. var pi = Math.floor((codeblock.tbx0_ - subband.tbx0) / precinctParameters.precinctWidthInSubband);
  33263. var pj = Math.floor((codeblock.tby0_ - subband.tby0) / precinctParameters.precinctHeightInSubband);
  33264. precinctNumber = pi + pj * precinctParameters.numprecinctswide;
  33265. codeblock.precinctNumber = precinctNumber;
  33266. codeblock.subbandType = subband.type;
  33267. codeblock.Lblock = 3;
  33268. if (codeblock.tbx1_ <= codeblock.tbx0_ || codeblock.tby1_ <= codeblock.tby0_) {
  33269. continue;
  33270. }
  33271. codeblocks.push(codeblock);
  33272. var precinct = precincts[precinctNumber];
  33273. if (precinct !== undefined) {
  33274. if (i < precinct.cbxMin) {
  33275. precinct.cbxMin = i;
  33276. } else if (i > precinct.cbxMax) {
  33277. precinct.cbxMax = i;
  33278. }
  33279. if (j < precinct.cbyMin) {
  33280. precinct.cbxMin = j;
  33281. } else if (j > precinct.cbyMax) {
  33282. precinct.cbyMax = j;
  33283. }
  33284. } else {
  33285. precincts[precinctNumber] = precinct = {
  33286. cbxMin: i,
  33287. cbyMin: j,
  33288. cbxMax: i,
  33289. cbyMax: j
  33290. };
  33291. }
  33292. codeblock.precinct = precinct;
  33293. }
  33294. }
  33295. subband.codeblockParameters = {
  33296. codeblockWidth: xcb_,
  33297. codeblockHeight: ycb_,
  33298. numcodeblockwide: cbx1 - cbx0 + 1,
  33299. numcodeblockhigh: cby1 - cby0 + 1
  33300. };
  33301. subband.codeblocks = codeblocks;
  33302. subband.precincts = precincts;
  33303. }
  33304. function createPacket(resolution, precinctNumber, layerNumber) {
  33305. var precinctCodeblocks = [];
  33306. var subbands = resolution.subbands;
  33307. for (var i = 0, ii = subbands.length; i < ii; i++) {
  33308. var subband = subbands[i];
  33309. var codeblocks = subband.codeblocks;
  33310. for (var j = 0, jj = codeblocks.length; j < jj; j++) {
  33311. var codeblock = codeblocks[j];
  33312. if (codeblock.precinctNumber !== precinctNumber) {
  33313. continue;
  33314. }
  33315. precinctCodeblocks.push(codeblock);
  33316. }
  33317. }
  33318. return {
  33319. layerNumber: layerNumber,
  33320. codeblocks: precinctCodeblocks
  33321. };
  33322. }
  33323. function LayerResolutionComponentPositionIterator(context) {
  33324. var siz = context.SIZ;
  33325. var tileIndex = context.currentTile.index;
  33326. var tile = context.tiles[tileIndex];
  33327. var layersCount = tile.codingStyleDefaultParameters.layersCount;
  33328. var componentsCount = siz.Csiz;
  33329. var maxDecompositionLevelsCount = 0;
  33330. for (var q = 0; q < componentsCount; q++) {
  33331. maxDecompositionLevelsCount = Math.max(maxDecompositionLevelsCount, tile.components[q].codingStyleParameters.decompositionLevelsCount);
  33332. }
  33333. var l = 0, r = 0, i = 0, k = 0;
  33334. this.nextPacket = function JpxImage_nextPacket() {
  33335. for (; l < layersCount; l++) {
  33336. for (; r <= maxDecompositionLevelsCount; r++) {
  33337. for (; i < componentsCount; i++) {
  33338. var component = tile.components[i];
  33339. if (r > component.codingStyleParameters.decompositionLevelsCount) {
  33340. continue;
  33341. }
  33342. var resolution = component.resolutions[r];
  33343. var numprecincts = resolution.precinctParameters.numprecincts;
  33344. for (; k < numprecincts;) {
  33345. var packet = createPacket(resolution, k, l);
  33346. k++;
  33347. return packet;
  33348. }
  33349. k = 0;
  33350. }
  33351. i = 0;
  33352. }
  33353. r = 0;
  33354. }
  33355. error('JPX Error: Out of packets');
  33356. };
  33357. }
  33358. function ResolutionLayerComponentPositionIterator(context) {
  33359. var siz = context.SIZ;
  33360. var tileIndex = context.currentTile.index;
  33361. var tile = context.tiles[tileIndex];
  33362. var layersCount = tile.codingStyleDefaultParameters.layersCount;
  33363. var componentsCount = siz.Csiz;
  33364. var maxDecompositionLevelsCount = 0;
  33365. for (var q = 0; q < componentsCount; q++) {
  33366. maxDecompositionLevelsCount = Math.max(maxDecompositionLevelsCount, tile.components[q].codingStyleParameters.decompositionLevelsCount);
  33367. }
  33368. var r = 0, l = 0, i = 0, k = 0;
  33369. this.nextPacket = function JpxImage_nextPacket() {
  33370. for (; r <= maxDecompositionLevelsCount; r++) {
  33371. for (; l < layersCount; l++) {
  33372. for (; i < componentsCount; i++) {
  33373. var component = tile.components[i];
  33374. if (r > component.codingStyleParameters.decompositionLevelsCount) {
  33375. continue;
  33376. }
  33377. var resolution = component.resolutions[r];
  33378. var numprecincts = resolution.precinctParameters.numprecincts;
  33379. for (; k < numprecincts;) {
  33380. var packet = createPacket(resolution, k, l);
  33381. k++;
  33382. return packet;
  33383. }
  33384. k = 0;
  33385. }
  33386. i = 0;
  33387. }
  33388. l = 0;
  33389. }
  33390. error('JPX Error: Out of packets');
  33391. };
  33392. }
  33393. function ResolutionPositionComponentLayerIterator(context) {
  33394. var siz = context.SIZ;
  33395. var tileIndex = context.currentTile.index;
  33396. var tile = context.tiles[tileIndex];
  33397. var layersCount = tile.codingStyleDefaultParameters.layersCount;
  33398. var componentsCount = siz.Csiz;
  33399. var l, r, c, p;
  33400. var maxDecompositionLevelsCount = 0;
  33401. for (c = 0; c < componentsCount; c++) {
  33402. var component = tile.components[c];
  33403. maxDecompositionLevelsCount = Math.max(maxDecompositionLevelsCount, component.codingStyleParameters.decompositionLevelsCount);
  33404. }
  33405. var maxNumPrecinctsInLevel = new Int32Array(maxDecompositionLevelsCount + 1);
  33406. for (r = 0; r <= maxDecompositionLevelsCount; ++r) {
  33407. var maxNumPrecincts = 0;
  33408. for (c = 0; c < componentsCount; ++c) {
  33409. var resolutions = tile.components[c].resolutions;
  33410. if (r < resolutions.length) {
  33411. maxNumPrecincts = Math.max(maxNumPrecincts, resolutions[r].precinctParameters.numprecincts);
  33412. }
  33413. }
  33414. maxNumPrecinctsInLevel[r] = maxNumPrecincts;
  33415. }
  33416. l = 0;
  33417. r = 0;
  33418. c = 0;
  33419. p = 0;
  33420. this.nextPacket = function JpxImage_nextPacket() {
  33421. for (; r <= maxDecompositionLevelsCount; r++) {
  33422. for (; p < maxNumPrecinctsInLevel[r]; p++) {
  33423. for (; c < componentsCount; c++) {
  33424. var component = tile.components[c];
  33425. if (r > component.codingStyleParameters.decompositionLevelsCount) {
  33426. continue;
  33427. }
  33428. var resolution = component.resolutions[r];
  33429. var numprecincts = resolution.precinctParameters.numprecincts;
  33430. if (p >= numprecincts) {
  33431. continue;
  33432. }
  33433. for (; l < layersCount;) {
  33434. var packet = createPacket(resolution, p, l);
  33435. l++;
  33436. return packet;
  33437. }
  33438. l = 0;
  33439. }
  33440. c = 0;
  33441. }
  33442. p = 0;
  33443. }
  33444. error('JPX Error: Out of packets');
  33445. };
  33446. }
  33447. function PositionComponentResolutionLayerIterator(context) {
  33448. var siz = context.SIZ;
  33449. var tileIndex = context.currentTile.index;
  33450. var tile = context.tiles[tileIndex];
  33451. var layersCount = tile.codingStyleDefaultParameters.layersCount;
  33452. var componentsCount = siz.Csiz;
  33453. var precinctsSizes = getPrecinctSizesInImageScale(tile);
  33454. var precinctsIterationSizes = precinctsSizes;
  33455. var l = 0, r = 0, c = 0, px = 0, py = 0;
  33456. this.nextPacket = function JpxImage_nextPacket() {
  33457. for (; py < precinctsIterationSizes.maxNumHigh; py++) {
  33458. for (; px < precinctsIterationSizes.maxNumWide; px++) {
  33459. for (; c < componentsCount; c++) {
  33460. var component = tile.components[c];
  33461. var decompositionLevelsCount = component.codingStyleParameters.decompositionLevelsCount;
  33462. for (; r <= decompositionLevelsCount; r++) {
  33463. var resolution = component.resolutions[r];
  33464. var sizeInImageScale = precinctsSizes.components[c].resolutions[r];
  33465. var k = getPrecinctIndexIfExist(px, py, sizeInImageScale, precinctsIterationSizes, resolution);
  33466. if (k === null) {
  33467. continue;
  33468. }
  33469. for (; l < layersCount;) {
  33470. var packet = createPacket(resolution, k, l);
  33471. l++;
  33472. return packet;
  33473. }
  33474. l = 0;
  33475. }
  33476. r = 0;
  33477. }
  33478. c = 0;
  33479. }
  33480. px = 0;
  33481. }
  33482. error('JPX Error: Out of packets');
  33483. };
  33484. }
  33485. function ComponentPositionResolutionLayerIterator(context) {
  33486. var siz = context.SIZ;
  33487. var tileIndex = context.currentTile.index;
  33488. var tile = context.tiles[tileIndex];
  33489. var layersCount = tile.codingStyleDefaultParameters.layersCount;
  33490. var componentsCount = siz.Csiz;
  33491. var precinctsSizes = getPrecinctSizesInImageScale(tile);
  33492. var l = 0, r = 0, c = 0, px = 0, py = 0;
  33493. this.nextPacket = function JpxImage_nextPacket() {
  33494. for (; c < componentsCount; ++c) {
  33495. var component = tile.components[c];
  33496. var precinctsIterationSizes = precinctsSizes.components[c];
  33497. var decompositionLevelsCount = component.codingStyleParameters.decompositionLevelsCount;
  33498. for (; py < precinctsIterationSizes.maxNumHigh; py++) {
  33499. for (; px < precinctsIterationSizes.maxNumWide; px++) {
  33500. for (; r <= decompositionLevelsCount; r++) {
  33501. var resolution = component.resolutions[r];
  33502. var sizeInImageScale = precinctsIterationSizes.resolutions[r];
  33503. var k = getPrecinctIndexIfExist(px, py, sizeInImageScale, precinctsIterationSizes, resolution);
  33504. if (k === null) {
  33505. continue;
  33506. }
  33507. for (; l < layersCount;) {
  33508. var packet = createPacket(resolution, k, l);
  33509. l++;
  33510. return packet;
  33511. }
  33512. l = 0;
  33513. }
  33514. r = 0;
  33515. }
  33516. px = 0;
  33517. }
  33518. py = 0;
  33519. }
  33520. error('JPX Error: Out of packets');
  33521. };
  33522. }
  33523. function getPrecinctIndexIfExist(pxIndex, pyIndex, sizeInImageScale, precinctIterationSizes, resolution) {
  33524. var posX = pxIndex * precinctIterationSizes.minWidth;
  33525. var posY = pyIndex * precinctIterationSizes.minHeight;
  33526. if (posX % sizeInImageScale.width !== 0 || posY % sizeInImageScale.height !== 0) {
  33527. return null;
  33528. }
  33529. var startPrecinctRowIndex = posY / sizeInImageScale.width * resolution.precinctParameters.numprecinctswide;
  33530. return posX / sizeInImageScale.height + startPrecinctRowIndex;
  33531. }
  33532. function getPrecinctSizesInImageScale(tile) {
  33533. var componentsCount = tile.components.length;
  33534. var minWidth = Number.MAX_VALUE;
  33535. var minHeight = Number.MAX_VALUE;
  33536. var maxNumWide = 0;
  33537. var maxNumHigh = 0;
  33538. var sizePerComponent = new Array(componentsCount);
  33539. for (var c = 0; c < componentsCount; c++) {
  33540. var component = tile.components[c];
  33541. var decompositionLevelsCount = component.codingStyleParameters.decompositionLevelsCount;
  33542. var sizePerResolution = new Array(decompositionLevelsCount + 1);
  33543. var minWidthCurrentComponent = Number.MAX_VALUE;
  33544. var minHeightCurrentComponent = Number.MAX_VALUE;
  33545. var maxNumWideCurrentComponent = 0;
  33546. var maxNumHighCurrentComponent = 0;
  33547. var scale = 1;
  33548. for (var r = decompositionLevelsCount; r >= 0; --r) {
  33549. var resolution = component.resolutions[r];
  33550. var widthCurrentResolution = scale * resolution.precinctParameters.precinctWidth;
  33551. var heightCurrentResolution = scale * resolution.precinctParameters.precinctHeight;
  33552. minWidthCurrentComponent = Math.min(minWidthCurrentComponent, widthCurrentResolution);
  33553. minHeightCurrentComponent = Math.min(minHeightCurrentComponent, heightCurrentResolution);
  33554. maxNumWideCurrentComponent = Math.max(maxNumWideCurrentComponent, resolution.precinctParameters.numprecinctswide);
  33555. maxNumHighCurrentComponent = Math.max(maxNumHighCurrentComponent, resolution.precinctParameters.numprecinctshigh);
  33556. sizePerResolution[r] = {
  33557. width: widthCurrentResolution,
  33558. height: heightCurrentResolution
  33559. };
  33560. scale <<= 1;
  33561. }
  33562. minWidth = Math.min(minWidth, minWidthCurrentComponent);
  33563. minHeight = Math.min(minHeight, minHeightCurrentComponent);
  33564. maxNumWide = Math.max(maxNumWide, maxNumWideCurrentComponent);
  33565. maxNumHigh = Math.max(maxNumHigh, maxNumHighCurrentComponent);
  33566. sizePerComponent[c] = {
  33567. resolutions: sizePerResolution,
  33568. minWidth: minWidthCurrentComponent,
  33569. minHeight: minHeightCurrentComponent,
  33570. maxNumWide: maxNumWideCurrentComponent,
  33571. maxNumHigh: maxNumHighCurrentComponent
  33572. };
  33573. }
  33574. return {
  33575. components: sizePerComponent,
  33576. minWidth: minWidth,
  33577. minHeight: minHeight,
  33578. maxNumWide: maxNumWide,
  33579. maxNumHigh: maxNumHigh
  33580. };
  33581. }
  33582. function buildPackets(context) {
  33583. var siz = context.SIZ;
  33584. var tileIndex = context.currentTile.index;
  33585. var tile = context.tiles[tileIndex];
  33586. var componentsCount = siz.Csiz;
  33587. for (var c = 0; c < componentsCount; c++) {
  33588. var component = tile.components[c];
  33589. var decompositionLevelsCount = component.codingStyleParameters.decompositionLevelsCount;
  33590. var resolutions = [];
  33591. var subbands = [];
  33592. for (var r = 0; r <= decompositionLevelsCount; r++) {
  33593. var blocksDimensions = getBlocksDimensions(context, component, r);
  33594. var resolution = {};
  33595. var scale = 1 << decompositionLevelsCount - r;
  33596. resolution.trx0 = Math.ceil(component.tcx0 / scale);
  33597. resolution.try0 = Math.ceil(component.tcy0 / scale);
  33598. resolution.trx1 = Math.ceil(component.tcx1 / scale);
  33599. resolution.try1 = Math.ceil(component.tcy1 / scale);
  33600. resolution.resLevel = r;
  33601. buildPrecincts(context, resolution, blocksDimensions);
  33602. resolutions.push(resolution);
  33603. var subband;
  33604. if (r === 0) {
  33605. subband = {};
  33606. subband.type = 'LL';
  33607. subband.tbx0 = Math.ceil(component.tcx0 / scale);
  33608. subband.tby0 = Math.ceil(component.tcy0 / scale);
  33609. subband.tbx1 = Math.ceil(component.tcx1 / scale);
  33610. subband.tby1 = Math.ceil(component.tcy1 / scale);
  33611. subband.resolution = resolution;
  33612. buildCodeblocks(context, subband, blocksDimensions);
  33613. subbands.push(subband);
  33614. resolution.subbands = [subband];
  33615. } else {
  33616. var bscale = 1 << decompositionLevelsCount - r + 1;
  33617. var resolutionSubbands = [];
  33618. subband = {};
  33619. subband.type = 'HL';
  33620. subband.tbx0 = Math.ceil(component.tcx0 / bscale - 0.5);
  33621. subband.tby0 = Math.ceil(component.tcy0 / bscale);
  33622. subband.tbx1 = Math.ceil(component.tcx1 / bscale - 0.5);
  33623. subband.tby1 = Math.ceil(component.tcy1 / bscale);
  33624. subband.resolution = resolution;
  33625. buildCodeblocks(context, subband, blocksDimensions);
  33626. subbands.push(subband);
  33627. resolutionSubbands.push(subband);
  33628. subband = {};
  33629. subband.type = 'LH';
  33630. subband.tbx0 = Math.ceil(component.tcx0 / bscale);
  33631. subband.tby0 = Math.ceil(component.tcy0 / bscale - 0.5);
  33632. subband.tbx1 = Math.ceil(component.tcx1 / bscale);
  33633. subband.tby1 = Math.ceil(component.tcy1 / bscale - 0.5);
  33634. subband.resolution = resolution;
  33635. buildCodeblocks(context, subband, blocksDimensions);
  33636. subbands.push(subband);
  33637. resolutionSubbands.push(subband);
  33638. subband = {};
  33639. subband.type = 'HH';
  33640. subband.tbx0 = Math.ceil(component.tcx0 / bscale - 0.5);
  33641. subband.tby0 = Math.ceil(component.tcy0 / bscale - 0.5);
  33642. subband.tbx1 = Math.ceil(component.tcx1 / bscale - 0.5);
  33643. subband.tby1 = Math.ceil(component.tcy1 / bscale - 0.5);
  33644. subband.resolution = resolution;
  33645. buildCodeblocks(context, subband, blocksDimensions);
  33646. subbands.push(subband);
  33647. resolutionSubbands.push(subband);
  33648. resolution.subbands = resolutionSubbands;
  33649. }
  33650. }
  33651. component.resolutions = resolutions;
  33652. component.subbands = subbands;
  33653. }
  33654. var progressionOrder = tile.codingStyleDefaultParameters.progressionOrder;
  33655. switch (progressionOrder) {
  33656. case 0:
  33657. tile.packetsIterator = new LayerResolutionComponentPositionIterator(context);
  33658. break;
  33659. case 1:
  33660. tile.packetsIterator = new ResolutionLayerComponentPositionIterator(context);
  33661. break;
  33662. case 2:
  33663. tile.packetsIterator = new ResolutionPositionComponentLayerIterator(context);
  33664. break;
  33665. case 3:
  33666. tile.packetsIterator = new PositionComponentResolutionLayerIterator(context);
  33667. break;
  33668. case 4:
  33669. tile.packetsIterator = new ComponentPositionResolutionLayerIterator(context);
  33670. break;
  33671. default:
  33672. error('JPX Error: Unsupported progression order ' + progressionOrder);
  33673. }
  33674. }
  33675. function parseTilePackets(context, data, offset, dataLength) {
  33676. var position = 0;
  33677. var buffer, bufferSize = 0, skipNextBit = false;
  33678. function readBits(count) {
  33679. while (bufferSize < count) {
  33680. var b = data[offset + position];
  33681. position++;
  33682. if (skipNextBit) {
  33683. buffer = buffer << 7 | b;
  33684. bufferSize += 7;
  33685. skipNextBit = false;
  33686. } else {
  33687. buffer = buffer << 8 | b;
  33688. bufferSize += 8;
  33689. }
  33690. if (b === 0xFF) {
  33691. skipNextBit = true;
  33692. }
  33693. }
  33694. bufferSize -= count;
  33695. return buffer >>> bufferSize & (1 << count) - 1;
  33696. }
  33697. function skipMarkerIfEqual(value) {
  33698. if (data[offset + position - 1] === 0xFF && data[offset + position] === value) {
  33699. skipBytes(1);
  33700. return true;
  33701. } else if (data[offset + position] === 0xFF && data[offset + position + 1] === value) {
  33702. skipBytes(2);
  33703. return true;
  33704. }
  33705. return false;
  33706. }
  33707. function skipBytes(count) {
  33708. position += count;
  33709. }
  33710. function alignToByte() {
  33711. bufferSize = 0;
  33712. if (skipNextBit) {
  33713. position++;
  33714. skipNextBit = false;
  33715. }
  33716. }
  33717. function readCodingpasses() {
  33718. if (readBits(1) === 0) {
  33719. return 1;
  33720. }
  33721. if (readBits(1) === 0) {
  33722. return 2;
  33723. }
  33724. var value = readBits(2);
  33725. if (value < 3) {
  33726. return value + 3;
  33727. }
  33728. value = readBits(5);
  33729. if (value < 31) {
  33730. return value + 6;
  33731. }
  33732. value = readBits(7);
  33733. return value + 37;
  33734. }
  33735. var tileIndex = context.currentTile.index;
  33736. var tile = context.tiles[tileIndex];
  33737. var sopMarkerUsed = context.COD.sopMarkerUsed;
  33738. var ephMarkerUsed = context.COD.ephMarkerUsed;
  33739. var packetsIterator = tile.packetsIterator;
  33740. while (position < dataLength) {
  33741. alignToByte();
  33742. if (sopMarkerUsed && skipMarkerIfEqual(0x91)) {
  33743. skipBytes(4);
  33744. }
  33745. var packet = packetsIterator.nextPacket();
  33746. if (!readBits(1)) {
  33747. continue;
  33748. }
  33749. var layerNumber = packet.layerNumber;
  33750. var queue = [], codeblock;
  33751. for (var i = 0, ii = packet.codeblocks.length; i < ii; i++) {
  33752. codeblock = packet.codeblocks[i];
  33753. var precinct = codeblock.precinct;
  33754. var codeblockColumn = codeblock.cbx - precinct.cbxMin;
  33755. var codeblockRow = codeblock.cby - precinct.cbyMin;
  33756. var codeblockIncluded = false;
  33757. var firstTimeInclusion = false;
  33758. var valueReady;
  33759. if (codeblock['included'] !== undefined) {
  33760. codeblockIncluded = !!readBits(1);
  33761. } else {
  33762. precinct = codeblock.precinct;
  33763. var inclusionTree, zeroBitPlanesTree;
  33764. if (precinct['inclusionTree'] !== undefined) {
  33765. inclusionTree = precinct.inclusionTree;
  33766. } else {
  33767. var width = precinct.cbxMax - precinct.cbxMin + 1;
  33768. var height = precinct.cbyMax - precinct.cbyMin + 1;
  33769. inclusionTree = new InclusionTree(width, height, layerNumber);
  33770. zeroBitPlanesTree = new TagTree(width, height);
  33771. precinct.inclusionTree = inclusionTree;
  33772. precinct.zeroBitPlanesTree = zeroBitPlanesTree;
  33773. }
  33774. if (inclusionTree.reset(codeblockColumn, codeblockRow, layerNumber)) {
  33775. while (true) {
  33776. if (readBits(1)) {
  33777. valueReady = !inclusionTree.nextLevel();
  33778. if (valueReady) {
  33779. codeblock.included = true;
  33780. codeblockIncluded = firstTimeInclusion = true;
  33781. break;
  33782. }
  33783. } else {
  33784. inclusionTree.incrementValue(layerNumber);
  33785. break;
  33786. }
  33787. }
  33788. }
  33789. }
  33790. if (!codeblockIncluded) {
  33791. continue;
  33792. }
  33793. if (firstTimeInclusion) {
  33794. zeroBitPlanesTree = precinct.zeroBitPlanesTree;
  33795. zeroBitPlanesTree.reset(codeblockColumn, codeblockRow);
  33796. while (true) {
  33797. if (readBits(1)) {
  33798. valueReady = !zeroBitPlanesTree.nextLevel();
  33799. if (valueReady) {
  33800. break;
  33801. }
  33802. } else {
  33803. zeroBitPlanesTree.incrementValue();
  33804. }
  33805. }
  33806. codeblock.zeroBitPlanes = zeroBitPlanesTree.value;
  33807. }
  33808. var codingpasses = readCodingpasses();
  33809. while (readBits(1)) {
  33810. codeblock.Lblock++;
  33811. }
  33812. var codingpassesLog2 = log2(codingpasses);
  33813. var bits = (codingpasses < 1 << codingpassesLog2 ? codingpassesLog2 - 1 : codingpassesLog2) + codeblock.Lblock;
  33814. var codedDataLength = readBits(bits);
  33815. queue.push({
  33816. codeblock: codeblock,
  33817. codingpasses: codingpasses,
  33818. dataLength: codedDataLength
  33819. });
  33820. }
  33821. alignToByte();
  33822. if (ephMarkerUsed) {
  33823. skipMarkerIfEqual(0x92);
  33824. }
  33825. while (queue.length > 0) {
  33826. var packetItem = queue.shift();
  33827. codeblock = packetItem.codeblock;
  33828. if (codeblock['data'] === undefined) {
  33829. codeblock.data = [];
  33830. }
  33831. codeblock.data.push({
  33832. data: data,
  33833. start: offset + position,
  33834. end: offset + position + packetItem.dataLength,
  33835. codingpasses: packetItem.codingpasses
  33836. });
  33837. position += packetItem.dataLength;
  33838. }
  33839. }
  33840. return position;
  33841. }
  33842. function copyCoefficients(coefficients, levelWidth, levelHeight, subband, delta, mb, reversible, segmentationSymbolUsed) {
  33843. var x0 = subband.tbx0;
  33844. var y0 = subband.tby0;
  33845. var width = subband.tbx1 - subband.tbx0;
  33846. var codeblocks = subband.codeblocks;
  33847. var right = subband.type.charAt(0) === 'H' ? 1 : 0;
  33848. var bottom = subband.type.charAt(1) === 'H' ? levelWidth : 0;
  33849. for (var i = 0, ii = codeblocks.length; i < ii; ++i) {
  33850. var codeblock = codeblocks[i];
  33851. var blockWidth = codeblock.tbx1_ - codeblock.tbx0_;
  33852. var blockHeight = codeblock.tby1_ - codeblock.tby0_;
  33853. if (blockWidth === 0 || blockHeight === 0) {
  33854. continue;
  33855. }
  33856. if (codeblock['data'] === undefined) {
  33857. continue;
  33858. }
  33859. var bitModel, currentCodingpassType;
  33860. bitModel = new BitModel(blockWidth, blockHeight, codeblock.subbandType, codeblock.zeroBitPlanes, mb);
  33861. currentCodingpassType = 2;
  33862. var data = codeblock.data, totalLength = 0, codingpasses = 0;
  33863. var j, jj, dataItem;
  33864. for (j = 0, jj = data.length; j < jj; j++) {
  33865. dataItem = data[j];
  33866. totalLength += dataItem.end - dataItem.start;
  33867. codingpasses += dataItem.codingpasses;
  33868. }
  33869. var encodedData = new Uint8Array(totalLength);
  33870. var position = 0;
  33871. for (j = 0, jj = data.length; j < jj; j++) {
  33872. dataItem = data[j];
  33873. var chunk = dataItem.data.subarray(dataItem.start, dataItem.end);
  33874. encodedData.set(chunk, position);
  33875. position += chunk.length;
  33876. }
  33877. var decoder = new ArithmeticDecoder(encodedData, 0, totalLength);
  33878. bitModel.setDecoder(decoder);
  33879. for (j = 0; j < codingpasses; j++) {
  33880. switch (currentCodingpassType) {
  33881. case 0:
  33882. bitModel.runSignificancePropagationPass();
  33883. break;
  33884. case 1:
  33885. bitModel.runMagnitudeRefinementPass();
  33886. break;
  33887. case 2:
  33888. bitModel.runCleanupPass();
  33889. if (segmentationSymbolUsed) {
  33890. bitModel.checkSegmentationSymbol();
  33891. }
  33892. break;
  33893. }
  33894. currentCodingpassType = (currentCodingpassType + 1) % 3;
  33895. }
  33896. var offset = codeblock.tbx0_ - x0 + (codeblock.tby0_ - y0) * width;
  33897. var sign = bitModel.coefficentsSign;
  33898. var magnitude = bitModel.coefficentsMagnitude;
  33899. var bitsDecoded = bitModel.bitsDecoded;
  33900. var magnitudeCorrection = reversible ? 0 : 0.5;
  33901. var k, n, nb;
  33902. position = 0;
  33903. var interleave = subband.type !== 'LL';
  33904. for (j = 0; j < blockHeight; j++) {
  33905. var row = offset / width | 0;
  33906. var levelOffset = 2 * row * (levelWidth - width) + right + bottom;
  33907. for (k = 0; k < blockWidth; k++) {
  33908. n = magnitude[position];
  33909. if (n !== 0) {
  33910. n = (n + magnitudeCorrection) * delta;
  33911. if (sign[position] !== 0) {
  33912. n = -n;
  33913. }
  33914. nb = bitsDecoded[position];
  33915. var pos = interleave ? levelOffset + (offset << 1) : offset;
  33916. if (reversible && nb >= mb) {
  33917. coefficients[pos] = n;
  33918. } else {
  33919. coefficients[pos] = n * (1 << mb - nb);
  33920. }
  33921. }
  33922. offset++;
  33923. position++;
  33924. }
  33925. offset += width - blockWidth;
  33926. }
  33927. }
  33928. }
  33929. function transformTile(context, tile, c) {
  33930. var component = tile.components[c];
  33931. var codingStyleParameters = component.codingStyleParameters;
  33932. var quantizationParameters = component.quantizationParameters;
  33933. var decompositionLevelsCount = codingStyleParameters.decompositionLevelsCount;
  33934. var spqcds = quantizationParameters.SPqcds;
  33935. var scalarExpounded = quantizationParameters.scalarExpounded;
  33936. var guardBits = quantizationParameters.guardBits;
  33937. var segmentationSymbolUsed = codingStyleParameters.segmentationSymbolUsed;
  33938. var precision = context.components[c].precision;
  33939. var reversible = codingStyleParameters.reversibleTransformation;
  33940. var transform = reversible ? new ReversibleTransform() : new IrreversibleTransform();
  33941. var subbandCoefficients = [];
  33942. var b = 0;
  33943. for (var i = 0; i <= decompositionLevelsCount; i++) {
  33944. var resolution = component.resolutions[i];
  33945. var width = resolution.trx1 - resolution.trx0;
  33946. var height = resolution.try1 - resolution.try0;
  33947. var coefficients = new Float32Array(width * height);
  33948. for (var j = 0, jj = resolution.subbands.length; j < jj; j++) {
  33949. var mu, epsilon;
  33950. if (!scalarExpounded) {
  33951. mu = spqcds[0].mu;
  33952. epsilon = spqcds[0].epsilon + (i > 0 ? 1 - i : 0);
  33953. } else {
  33954. mu = spqcds[b].mu;
  33955. epsilon = spqcds[b].epsilon;
  33956. b++;
  33957. }
  33958. var subband = resolution.subbands[j];
  33959. var gainLog2 = SubbandsGainLog2[subband.type];
  33960. var delta = reversible ? 1 : Math.pow(2, precision + gainLog2 - epsilon) * (1 + mu / 2048);
  33961. var mb = guardBits + epsilon - 1;
  33962. copyCoefficients(coefficients, width, height, subband, delta, mb, reversible, segmentationSymbolUsed);
  33963. }
  33964. subbandCoefficients.push({
  33965. width: width,
  33966. height: height,
  33967. items: coefficients
  33968. });
  33969. }
  33970. var result = transform.calculate(subbandCoefficients, component.tcx0, component.tcy0);
  33971. return {
  33972. left: component.tcx0,
  33973. top: component.tcy0,
  33974. width: result.width,
  33975. height: result.height,
  33976. items: result.items
  33977. };
  33978. }
  33979. function transformComponents(context) {
  33980. var siz = context.SIZ;
  33981. var components = context.components;
  33982. var componentsCount = siz.Csiz;
  33983. var resultImages = [];
  33984. for (var i = 0, ii = context.tiles.length; i < ii; i++) {
  33985. var tile = context.tiles[i];
  33986. var transformedTiles = [];
  33987. var c;
  33988. for (c = 0; c < componentsCount; c++) {
  33989. transformedTiles[c] = transformTile(context, tile, c);
  33990. }
  33991. var tile0 = transformedTiles[0];
  33992. var out = new Uint8Array(tile0.items.length * componentsCount);
  33993. var result = {
  33994. left: tile0.left,
  33995. top: tile0.top,
  33996. width: tile0.width,
  33997. height: tile0.height,
  33998. items: out
  33999. };
  34000. var shift, offset, max, min, maxK;
  34001. var pos = 0, j, jj, y0, y1, y2, r, g, b, k, val;
  34002. if (tile.codingStyleDefaultParameters.multipleComponentTransform) {
  34003. var fourComponents = componentsCount === 4;
  34004. var y0items = transformedTiles[0].items;
  34005. var y1items = transformedTiles[1].items;
  34006. var y2items = transformedTiles[2].items;
  34007. var y3items = fourComponents ? transformedTiles[3].items : null;
  34008. shift = components[0].precision - 8;
  34009. offset = (128 << shift) + 0.5;
  34010. max = 255 * (1 << shift);
  34011. maxK = max * 0.5;
  34012. min = -maxK;
  34013. var component0 = tile.components[0];
  34014. var alpha01 = componentsCount - 3;
  34015. jj = y0items.length;
  34016. if (!component0.codingStyleParameters.reversibleTransformation) {
  34017. for (j = 0; j < jj; j++, pos += alpha01) {
  34018. y0 = y0items[j] + offset;
  34019. y1 = y1items[j];
  34020. y2 = y2items[j];
  34021. r = y0 + 1.402 * y2;
  34022. g = y0 - 0.34413 * y1 - 0.71414 * y2;
  34023. b = y0 + 1.772 * y1;
  34024. out[pos++] = r <= 0 ? 0 : r >= max ? 255 : r >> shift;
  34025. out[pos++] = g <= 0 ? 0 : g >= max ? 255 : g >> shift;
  34026. out[pos++] = b <= 0 ? 0 : b >= max ? 255 : b >> shift;
  34027. }
  34028. } else {
  34029. for (j = 0; j < jj; j++, pos += alpha01) {
  34030. y0 = y0items[j] + offset;
  34031. y1 = y1items[j];
  34032. y2 = y2items[j];
  34033. g = y0 - (y2 + y1 >> 2);
  34034. r = g + y2;
  34035. b = g + y1;
  34036. out[pos++] = r <= 0 ? 0 : r >= max ? 255 : r >> shift;
  34037. out[pos++] = g <= 0 ? 0 : g >= max ? 255 : g >> shift;
  34038. out[pos++] = b <= 0 ? 0 : b >= max ? 255 : b >> shift;
  34039. }
  34040. }
  34041. if (fourComponents) {
  34042. for (j = 0, pos = 3; j < jj; j++, pos += 4) {
  34043. k = y3items[j];
  34044. out[pos] = k <= min ? 0 : k >= maxK ? 255 : k + offset >> shift;
  34045. }
  34046. }
  34047. } else {
  34048. for (c = 0; c < componentsCount; c++) {
  34049. var items = transformedTiles[c].items;
  34050. shift = components[c].precision - 8;
  34051. offset = (128 << shift) + 0.5;
  34052. max = 127.5 * (1 << shift);
  34053. min = -max;
  34054. for (pos = c, j = 0, jj = items.length; j < jj; j++) {
  34055. val = items[j];
  34056. out[pos] = val <= min ? 0 : val >= max ? 255 : val + offset >> shift;
  34057. pos += componentsCount;
  34058. }
  34059. }
  34060. }
  34061. resultImages.push(result);
  34062. }
  34063. return resultImages;
  34064. }
  34065. function initializeTile(context, tileIndex) {
  34066. var siz = context.SIZ;
  34067. var componentsCount = siz.Csiz;
  34068. var tile = context.tiles[tileIndex];
  34069. for (var c = 0; c < componentsCount; c++) {
  34070. var component = tile.components[c];
  34071. var qcdOrQcc = context.currentTile.QCC[c] !== undefined ? context.currentTile.QCC[c] : context.currentTile.QCD;
  34072. component.quantizationParameters = qcdOrQcc;
  34073. var codOrCoc = context.currentTile.COC[c] !== undefined ? context.currentTile.COC[c] : context.currentTile.COD;
  34074. component.codingStyleParameters = codOrCoc;
  34075. }
  34076. tile.codingStyleDefaultParameters = context.currentTile.COD;
  34077. }
  34078. var TagTree = function TagTreeClosure() {
  34079. function TagTree(width, height) {
  34080. var levelsLength = log2(Math.max(width, height)) + 1;
  34081. this.levels = [];
  34082. for (var i = 0; i < levelsLength; i++) {
  34083. var level = {
  34084. width: width,
  34085. height: height,
  34086. items: []
  34087. };
  34088. this.levels.push(level);
  34089. width = Math.ceil(width / 2);
  34090. height = Math.ceil(height / 2);
  34091. }
  34092. }
  34093. TagTree.prototype = {
  34094. reset: function TagTree_reset(i, j) {
  34095. var currentLevel = 0, value = 0, level;
  34096. while (currentLevel < this.levels.length) {
  34097. level = this.levels[currentLevel];
  34098. var index = i + j * level.width;
  34099. if (level.items[index] !== undefined) {
  34100. value = level.items[index];
  34101. break;
  34102. }
  34103. level.index = index;
  34104. i >>= 1;
  34105. j >>= 1;
  34106. currentLevel++;
  34107. }
  34108. currentLevel--;
  34109. level = this.levels[currentLevel];
  34110. level.items[level.index] = value;
  34111. this.currentLevel = currentLevel;
  34112. delete this.value;
  34113. },
  34114. incrementValue: function TagTree_incrementValue() {
  34115. var level = this.levels[this.currentLevel];
  34116. level.items[level.index]++;
  34117. },
  34118. nextLevel: function TagTree_nextLevel() {
  34119. var currentLevel = this.currentLevel;
  34120. var level = this.levels[currentLevel];
  34121. var value = level.items[level.index];
  34122. currentLevel--;
  34123. if (currentLevel < 0) {
  34124. this.value = value;
  34125. return false;
  34126. }
  34127. this.currentLevel = currentLevel;
  34128. level = this.levels[currentLevel];
  34129. level.items[level.index] = value;
  34130. return true;
  34131. }
  34132. };
  34133. return TagTree;
  34134. }();
  34135. var InclusionTree = function InclusionTreeClosure() {
  34136. function InclusionTree(width, height, defaultValue) {
  34137. var levelsLength = log2(Math.max(width, height)) + 1;
  34138. this.levels = [];
  34139. for (var i = 0; i < levelsLength; i++) {
  34140. var items = new Uint8Array(width * height);
  34141. for (var j = 0, jj = items.length; j < jj; j++) {
  34142. items[j] = defaultValue;
  34143. }
  34144. var level = {
  34145. width: width,
  34146. height: height,
  34147. items: items
  34148. };
  34149. this.levels.push(level);
  34150. width = Math.ceil(width / 2);
  34151. height = Math.ceil(height / 2);
  34152. }
  34153. }
  34154. InclusionTree.prototype = {
  34155. reset: function InclusionTree_reset(i, j, stopValue) {
  34156. var currentLevel = 0;
  34157. while (currentLevel < this.levels.length) {
  34158. var level = this.levels[currentLevel];
  34159. var index = i + j * level.width;
  34160. level.index = index;
  34161. var value = level.items[index];
  34162. if (value === 0xFF) {
  34163. break;
  34164. }
  34165. if (value > stopValue) {
  34166. this.currentLevel = currentLevel;
  34167. this.propagateValues();
  34168. return false;
  34169. }
  34170. i >>= 1;
  34171. j >>= 1;
  34172. currentLevel++;
  34173. }
  34174. this.currentLevel = currentLevel - 1;
  34175. return true;
  34176. },
  34177. incrementValue: function InclusionTree_incrementValue(stopValue) {
  34178. var level = this.levels[this.currentLevel];
  34179. level.items[level.index] = stopValue + 1;
  34180. this.propagateValues();
  34181. },
  34182. propagateValues: function InclusionTree_propagateValues() {
  34183. var levelIndex = this.currentLevel;
  34184. var level = this.levels[levelIndex];
  34185. var currentValue = level.items[level.index];
  34186. while (--levelIndex >= 0) {
  34187. level = this.levels[levelIndex];
  34188. level.items[level.index] = currentValue;
  34189. }
  34190. },
  34191. nextLevel: function InclusionTree_nextLevel() {
  34192. var currentLevel = this.currentLevel;
  34193. var level = this.levels[currentLevel];
  34194. var value = level.items[level.index];
  34195. level.items[level.index] = 0xFF;
  34196. currentLevel--;
  34197. if (currentLevel < 0) {
  34198. return false;
  34199. }
  34200. this.currentLevel = currentLevel;
  34201. level = this.levels[currentLevel];
  34202. level.items[level.index] = value;
  34203. return true;
  34204. }
  34205. };
  34206. return InclusionTree;
  34207. }();
  34208. var BitModel = function BitModelClosure() {
  34209. var UNIFORM_CONTEXT = 17;
  34210. var RUNLENGTH_CONTEXT = 18;
  34211. var LLAndLHContextsLabel = new Uint8Array([
  34212. 0,
  34213. 5,
  34214. 8,
  34215. 0,
  34216. 3,
  34217. 7,
  34218. 8,
  34219. 0,
  34220. 4,
  34221. 7,
  34222. 8,
  34223. 0,
  34224. 0,
  34225. 0,
  34226. 0,
  34227. 0,
  34228. 1,
  34229. 6,
  34230. 8,
  34231. 0,
  34232. 3,
  34233. 7,
  34234. 8,
  34235. 0,
  34236. 4,
  34237. 7,
  34238. 8,
  34239. 0,
  34240. 0,
  34241. 0,
  34242. 0,
  34243. 0,
  34244. 2,
  34245. 6,
  34246. 8,
  34247. 0,
  34248. 3,
  34249. 7,
  34250. 8,
  34251. 0,
  34252. 4,
  34253. 7,
  34254. 8,
  34255. 0,
  34256. 0,
  34257. 0,
  34258. 0,
  34259. 0,
  34260. 2,
  34261. 6,
  34262. 8,
  34263. 0,
  34264. 3,
  34265. 7,
  34266. 8,
  34267. 0,
  34268. 4,
  34269. 7,
  34270. 8,
  34271. 0,
  34272. 0,
  34273. 0,
  34274. 0,
  34275. 0,
  34276. 2,
  34277. 6,
  34278. 8,
  34279. 0,
  34280. 3,
  34281. 7,
  34282. 8,
  34283. 0,
  34284. 4,
  34285. 7,
  34286. 8
  34287. ]);
  34288. var HLContextLabel = new Uint8Array([
  34289. 0,
  34290. 3,
  34291. 4,
  34292. 0,
  34293. 5,
  34294. 7,
  34295. 7,
  34296. 0,
  34297. 8,
  34298. 8,
  34299. 8,
  34300. 0,
  34301. 0,
  34302. 0,
  34303. 0,
  34304. 0,
  34305. 1,
  34306. 3,
  34307. 4,
  34308. 0,
  34309. 6,
  34310. 7,
  34311. 7,
  34312. 0,
  34313. 8,
  34314. 8,
  34315. 8,
  34316. 0,
  34317. 0,
  34318. 0,
  34319. 0,
  34320. 0,
  34321. 2,
  34322. 3,
  34323. 4,
  34324. 0,
  34325. 6,
  34326. 7,
  34327. 7,
  34328. 0,
  34329. 8,
  34330. 8,
  34331. 8,
  34332. 0,
  34333. 0,
  34334. 0,
  34335. 0,
  34336. 0,
  34337. 2,
  34338. 3,
  34339. 4,
  34340. 0,
  34341. 6,
  34342. 7,
  34343. 7,
  34344. 0,
  34345. 8,
  34346. 8,
  34347. 8,
  34348. 0,
  34349. 0,
  34350. 0,
  34351. 0,
  34352. 0,
  34353. 2,
  34354. 3,
  34355. 4,
  34356. 0,
  34357. 6,
  34358. 7,
  34359. 7,
  34360. 0,
  34361. 8,
  34362. 8,
  34363. 8
  34364. ]);
  34365. var HHContextLabel = new Uint8Array([
  34366. 0,
  34367. 1,
  34368. 2,
  34369. 0,
  34370. 1,
  34371. 2,
  34372. 2,
  34373. 0,
  34374. 2,
  34375. 2,
  34376. 2,
  34377. 0,
  34378. 0,
  34379. 0,
  34380. 0,
  34381. 0,
  34382. 3,
  34383. 4,
  34384. 5,
  34385. 0,
  34386. 4,
  34387. 5,
  34388. 5,
  34389. 0,
  34390. 5,
  34391. 5,
  34392. 5,
  34393. 0,
  34394. 0,
  34395. 0,
  34396. 0,
  34397. 0,
  34398. 6,
  34399. 7,
  34400. 7,
  34401. 0,
  34402. 7,
  34403. 7,
  34404. 7,
  34405. 0,
  34406. 7,
  34407. 7,
  34408. 7,
  34409. 0,
  34410. 0,
  34411. 0,
  34412. 0,
  34413. 0,
  34414. 8,
  34415. 8,
  34416. 8,
  34417. 0,
  34418. 8,
  34419. 8,
  34420. 8,
  34421. 0,
  34422. 8,
  34423. 8,
  34424. 8,
  34425. 0,
  34426. 0,
  34427. 0,
  34428. 0,
  34429. 0,
  34430. 8,
  34431. 8,
  34432. 8,
  34433. 0,
  34434. 8,
  34435. 8,
  34436. 8,
  34437. 0,
  34438. 8,
  34439. 8,
  34440. 8
  34441. ]);
  34442. function BitModel(width, height, subband, zeroBitPlanes, mb) {
  34443. this.width = width;
  34444. this.height = height;
  34445. this.contextLabelTable = subband === 'HH' ? HHContextLabel : subband === 'HL' ? HLContextLabel : LLAndLHContextsLabel;
  34446. var coefficientCount = width * height;
  34447. this.neighborsSignificance = new Uint8Array(coefficientCount);
  34448. this.coefficentsSign = new Uint8Array(coefficientCount);
  34449. this.coefficentsMagnitude = mb > 14 ? new Uint32Array(coefficientCount) : mb > 6 ? new Uint16Array(coefficientCount) : new Uint8Array(coefficientCount);
  34450. this.processingFlags = new Uint8Array(coefficientCount);
  34451. var bitsDecoded = new Uint8Array(coefficientCount);
  34452. if (zeroBitPlanes !== 0) {
  34453. for (var i = 0; i < coefficientCount; i++) {
  34454. bitsDecoded[i] = zeroBitPlanes;
  34455. }
  34456. }
  34457. this.bitsDecoded = bitsDecoded;
  34458. this.reset();
  34459. }
  34460. BitModel.prototype = {
  34461. setDecoder: function BitModel_setDecoder(decoder) {
  34462. this.decoder = decoder;
  34463. },
  34464. reset: function BitModel_reset() {
  34465. this.contexts = new Int8Array(19);
  34466. this.contexts[0] = 4 << 1 | 0;
  34467. this.contexts[UNIFORM_CONTEXT] = 46 << 1 | 0;
  34468. this.contexts[RUNLENGTH_CONTEXT] = 3 << 1 | 0;
  34469. },
  34470. setNeighborsSignificance: function BitModel_setNeighborsSignificance(row, column, index) {
  34471. var neighborsSignificance = this.neighborsSignificance;
  34472. var width = this.width, height = this.height;
  34473. var left = column > 0;
  34474. var right = column + 1 < width;
  34475. var i;
  34476. if (row > 0) {
  34477. i = index - width;
  34478. if (left) {
  34479. neighborsSignificance[i - 1] += 0x10;
  34480. }
  34481. if (right) {
  34482. neighborsSignificance[i + 1] += 0x10;
  34483. }
  34484. neighborsSignificance[i] += 0x04;
  34485. }
  34486. if (row + 1 < height) {
  34487. i = index + width;
  34488. if (left) {
  34489. neighborsSignificance[i - 1] += 0x10;
  34490. }
  34491. if (right) {
  34492. neighborsSignificance[i + 1] += 0x10;
  34493. }
  34494. neighborsSignificance[i] += 0x04;
  34495. }
  34496. if (left) {
  34497. neighborsSignificance[index - 1] += 0x01;
  34498. }
  34499. if (right) {
  34500. neighborsSignificance[index + 1] += 0x01;
  34501. }
  34502. neighborsSignificance[index] |= 0x80;
  34503. },
  34504. runSignificancePropagationPass: function BitModel_runSignificancePropagationPass() {
  34505. var decoder = this.decoder;
  34506. var width = this.width, height = this.height;
  34507. var coefficentsMagnitude = this.coefficentsMagnitude;
  34508. var coefficentsSign = this.coefficentsSign;
  34509. var neighborsSignificance = this.neighborsSignificance;
  34510. var processingFlags = this.processingFlags;
  34511. var contexts = this.contexts;
  34512. var labels = this.contextLabelTable;
  34513. var bitsDecoded = this.bitsDecoded;
  34514. var processedInverseMask = ~1;
  34515. var processedMask = 1;
  34516. var firstMagnitudeBitMask = 2;
  34517. for (var i0 = 0; i0 < height; i0 += 4) {
  34518. for (var j = 0; j < width; j++) {
  34519. var index = i0 * width + j;
  34520. for (var i1 = 0; i1 < 4; i1++, index += width) {
  34521. var i = i0 + i1;
  34522. if (i >= height) {
  34523. break;
  34524. }
  34525. processingFlags[index] &= processedInverseMask;
  34526. if (coefficentsMagnitude[index] || !neighborsSignificance[index]) {
  34527. continue;
  34528. }
  34529. var contextLabel = labels[neighborsSignificance[index]];
  34530. var decision = decoder.readBit(contexts, contextLabel);
  34531. if (decision) {
  34532. var sign = this.decodeSignBit(i, j, index);
  34533. coefficentsSign[index] = sign;
  34534. coefficentsMagnitude[index] = 1;
  34535. this.setNeighborsSignificance(i, j, index);
  34536. processingFlags[index] |= firstMagnitudeBitMask;
  34537. }
  34538. bitsDecoded[index]++;
  34539. processingFlags[index] |= processedMask;
  34540. }
  34541. }
  34542. }
  34543. },
  34544. decodeSignBit: function BitModel_decodeSignBit(row, column, index) {
  34545. var width = this.width, height = this.height;
  34546. var coefficentsMagnitude = this.coefficentsMagnitude;
  34547. var coefficentsSign = this.coefficentsSign;
  34548. var contribution, sign0, sign1, significance1;
  34549. var contextLabel, decoded;
  34550. significance1 = column > 0 && coefficentsMagnitude[index - 1] !== 0;
  34551. if (column + 1 < width && coefficentsMagnitude[index + 1] !== 0) {
  34552. sign1 = coefficentsSign[index + 1];
  34553. if (significance1) {
  34554. sign0 = coefficentsSign[index - 1];
  34555. contribution = 1 - sign1 - sign0;
  34556. } else {
  34557. contribution = 1 - sign1 - sign1;
  34558. }
  34559. } else if (significance1) {
  34560. sign0 = coefficentsSign[index - 1];
  34561. contribution = 1 - sign0 - sign0;
  34562. } else {
  34563. contribution = 0;
  34564. }
  34565. var horizontalContribution = 3 * contribution;
  34566. significance1 = row > 0 && coefficentsMagnitude[index - width] !== 0;
  34567. if (row + 1 < height && coefficentsMagnitude[index + width] !== 0) {
  34568. sign1 = coefficentsSign[index + width];
  34569. if (significance1) {
  34570. sign0 = coefficentsSign[index - width];
  34571. contribution = 1 - sign1 - sign0 + horizontalContribution;
  34572. } else {
  34573. contribution = 1 - sign1 - sign1 + horizontalContribution;
  34574. }
  34575. } else if (significance1) {
  34576. sign0 = coefficentsSign[index - width];
  34577. contribution = 1 - sign0 - sign0 + horizontalContribution;
  34578. } else {
  34579. contribution = horizontalContribution;
  34580. }
  34581. if (contribution >= 0) {
  34582. contextLabel = 9 + contribution;
  34583. decoded = this.decoder.readBit(this.contexts, contextLabel);
  34584. } else {
  34585. contextLabel = 9 - contribution;
  34586. decoded = this.decoder.readBit(this.contexts, contextLabel) ^ 1;
  34587. }
  34588. return decoded;
  34589. },
  34590. runMagnitudeRefinementPass: function BitModel_runMagnitudeRefinementPass() {
  34591. var decoder = this.decoder;
  34592. var width = this.width, height = this.height;
  34593. var coefficentsMagnitude = this.coefficentsMagnitude;
  34594. var neighborsSignificance = this.neighborsSignificance;
  34595. var contexts = this.contexts;
  34596. var bitsDecoded = this.bitsDecoded;
  34597. var processingFlags = this.processingFlags;
  34598. var processedMask = 1;
  34599. var firstMagnitudeBitMask = 2;
  34600. var length = width * height;
  34601. var width4 = width * 4;
  34602. for (var index0 = 0, indexNext; index0 < length; index0 = indexNext) {
  34603. indexNext = Math.min(length, index0 + width4);
  34604. for (var j = 0; j < width; j++) {
  34605. for (var index = index0 + j; index < indexNext; index += width) {
  34606. if (!coefficentsMagnitude[index] || (processingFlags[index] & processedMask) !== 0) {
  34607. continue;
  34608. }
  34609. var contextLabel = 16;
  34610. if ((processingFlags[index] & firstMagnitudeBitMask) !== 0) {
  34611. processingFlags[index] ^= firstMagnitudeBitMask;
  34612. var significance = neighborsSignificance[index] & 127;
  34613. contextLabel = significance === 0 ? 15 : 14;
  34614. }
  34615. var bit = decoder.readBit(contexts, contextLabel);
  34616. coefficentsMagnitude[index] = coefficentsMagnitude[index] << 1 | bit;
  34617. bitsDecoded[index]++;
  34618. processingFlags[index] |= processedMask;
  34619. }
  34620. }
  34621. }
  34622. },
  34623. runCleanupPass: function BitModel_runCleanupPass() {
  34624. var decoder = this.decoder;
  34625. var width = this.width, height = this.height;
  34626. var neighborsSignificance = this.neighborsSignificance;
  34627. var coefficentsMagnitude = this.coefficentsMagnitude;
  34628. var coefficentsSign = this.coefficentsSign;
  34629. var contexts = this.contexts;
  34630. var labels = this.contextLabelTable;
  34631. var bitsDecoded = this.bitsDecoded;
  34632. var processingFlags = this.processingFlags;
  34633. var processedMask = 1;
  34634. var firstMagnitudeBitMask = 2;
  34635. var oneRowDown = width;
  34636. var twoRowsDown = width * 2;
  34637. var threeRowsDown = width * 3;
  34638. var iNext;
  34639. for (var i0 = 0; i0 < height; i0 = iNext) {
  34640. iNext = Math.min(i0 + 4, height);
  34641. var indexBase = i0 * width;
  34642. var checkAllEmpty = i0 + 3 < height;
  34643. for (var j = 0; j < width; j++) {
  34644. var index0 = indexBase + j;
  34645. 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;
  34646. var i1 = 0, index = index0;
  34647. var i = i0, sign;
  34648. if (allEmpty) {
  34649. var hasSignificantCoefficent = decoder.readBit(contexts, RUNLENGTH_CONTEXT);
  34650. if (!hasSignificantCoefficent) {
  34651. bitsDecoded[index0]++;
  34652. bitsDecoded[index0 + oneRowDown]++;
  34653. bitsDecoded[index0 + twoRowsDown]++;
  34654. bitsDecoded[index0 + threeRowsDown]++;
  34655. continue;
  34656. }
  34657. i1 = decoder.readBit(contexts, UNIFORM_CONTEXT) << 1 | decoder.readBit(contexts, UNIFORM_CONTEXT);
  34658. if (i1 !== 0) {
  34659. i = i0 + i1;
  34660. index += i1 * width;
  34661. }
  34662. sign = this.decodeSignBit(i, j, index);
  34663. coefficentsSign[index] = sign;
  34664. coefficentsMagnitude[index] = 1;
  34665. this.setNeighborsSignificance(i, j, index);
  34666. processingFlags[index] |= firstMagnitudeBitMask;
  34667. index = index0;
  34668. for (var i2 = i0; i2 <= i; i2++, index += width) {
  34669. bitsDecoded[index]++;
  34670. }
  34671. i1++;
  34672. }
  34673. for (i = i0 + i1; i < iNext; i++, index += width) {
  34674. if (coefficentsMagnitude[index] || (processingFlags[index] & processedMask) !== 0) {
  34675. continue;
  34676. }
  34677. var contextLabel = labels[neighborsSignificance[index]];
  34678. var decision = decoder.readBit(contexts, contextLabel);
  34679. if (decision === 1) {
  34680. sign = this.decodeSignBit(i, j, index);
  34681. coefficentsSign[index] = sign;
  34682. coefficentsMagnitude[index] = 1;
  34683. this.setNeighborsSignificance(i, j, index);
  34684. processingFlags[index] |= firstMagnitudeBitMask;
  34685. }
  34686. bitsDecoded[index]++;
  34687. }
  34688. }
  34689. }
  34690. },
  34691. checkSegmentationSymbol: function BitModel_checkSegmentationSymbol() {
  34692. var decoder = this.decoder;
  34693. var contexts = this.contexts;
  34694. 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);
  34695. if (symbol !== 0xA) {
  34696. error('JPX Error: Invalid segmentation symbol');
  34697. }
  34698. }
  34699. };
  34700. return BitModel;
  34701. }();
  34702. var Transform = function TransformClosure() {
  34703. function Transform() {
  34704. }
  34705. Transform.prototype.calculate = function transformCalculate(subbands, u0, v0) {
  34706. var ll = subbands[0];
  34707. for (var i = 1, ii = subbands.length; i < ii; i++) {
  34708. ll = this.iterate(ll, subbands[i], u0, v0);
  34709. }
  34710. return ll;
  34711. };
  34712. Transform.prototype.extend = function extend(buffer, offset, size) {
  34713. var i1 = offset - 1, j1 = offset + 1;
  34714. var i2 = offset + size - 2, j2 = offset + size;
  34715. buffer[i1--] = buffer[j1++];
  34716. buffer[j2++] = buffer[i2--];
  34717. buffer[i1--] = buffer[j1++];
  34718. buffer[j2++] = buffer[i2--];
  34719. buffer[i1--] = buffer[j1++];
  34720. buffer[j2++] = buffer[i2--];
  34721. buffer[i1] = buffer[j1];
  34722. buffer[j2] = buffer[i2];
  34723. };
  34724. Transform.prototype.iterate = function Transform_iterate(ll, hl_lh_hh, u0, v0) {
  34725. var llWidth = ll.width, llHeight = ll.height, llItems = ll.items;
  34726. var width = hl_lh_hh.width;
  34727. var height = hl_lh_hh.height;
  34728. var items = hl_lh_hh.items;
  34729. var i, j, k, l, u, v;
  34730. for (k = 0, i = 0; i < llHeight; i++) {
  34731. l = i * 2 * width;
  34732. for (j = 0; j < llWidth; j++, k++, l += 2) {
  34733. items[l] = llItems[k];
  34734. }
  34735. }
  34736. llItems = ll.items = null;
  34737. var bufferPadding = 4;
  34738. var rowBuffer = new Float32Array(width + 2 * bufferPadding);
  34739. if (width === 1) {
  34740. if ((u0 & 1) !== 0) {
  34741. for (v = 0, k = 0; v < height; v++, k += width) {
  34742. items[k] *= 0.5;
  34743. }
  34744. }
  34745. } else {
  34746. for (v = 0, k = 0; v < height; v++, k += width) {
  34747. rowBuffer.set(items.subarray(k, k + width), bufferPadding);
  34748. this.extend(rowBuffer, bufferPadding, width);
  34749. this.filter(rowBuffer, bufferPadding, width);
  34750. items.set(rowBuffer.subarray(bufferPadding, bufferPadding + width), k);
  34751. }
  34752. }
  34753. var numBuffers = 16;
  34754. var colBuffers = [];
  34755. for (i = 0; i < numBuffers; i++) {
  34756. colBuffers.push(new Float32Array(height + 2 * bufferPadding));
  34757. }
  34758. var b, currentBuffer = 0;
  34759. ll = bufferPadding + height;
  34760. if (height === 1) {
  34761. if ((v0 & 1) !== 0) {
  34762. for (u = 0; u < width; u++) {
  34763. items[u] *= 0.5;
  34764. }
  34765. }
  34766. } else {
  34767. for (u = 0; u < width; u++) {
  34768. if (currentBuffer === 0) {
  34769. numBuffers = Math.min(width - u, numBuffers);
  34770. for (k = u, l = bufferPadding; l < ll; k += width, l++) {
  34771. for (b = 0; b < numBuffers; b++) {
  34772. colBuffers[b][l] = items[k + b];
  34773. }
  34774. }
  34775. currentBuffer = numBuffers;
  34776. }
  34777. currentBuffer--;
  34778. var buffer = colBuffers[currentBuffer];
  34779. this.extend(buffer, bufferPadding, height);
  34780. this.filter(buffer, bufferPadding, height);
  34781. if (currentBuffer === 0) {
  34782. k = u - numBuffers + 1;
  34783. for (l = bufferPadding; l < ll; k += width, l++) {
  34784. for (b = 0; b < numBuffers; b++) {
  34785. items[k + b] = colBuffers[b][l];
  34786. }
  34787. }
  34788. }
  34789. }
  34790. }
  34791. return {
  34792. width: width,
  34793. height: height,
  34794. items: items
  34795. };
  34796. };
  34797. return Transform;
  34798. }();
  34799. var IrreversibleTransform = function IrreversibleTransformClosure() {
  34800. function IrreversibleTransform() {
  34801. Transform.call(this);
  34802. }
  34803. IrreversibleTransform.prototype = Object.create(Transform.prototype);
  34804. IrreversibleTransform.prototype.filter = function irreversibleTransformFilter(x, offset, length) {
  34805. var len = length >> 1;
  34806. offset = offset | 0;
  34807. var j, n, current, next;
  34808. var alpha = -1.586134342059924;
  34809. var beta = -0.052980118572961;
  34810. var gamma = 0.882911075530934;
  34811. var delta = 0.443506852043971;
  34812. var K = 1.230174104914001;
  34813. var K_ = 1 / K;
  34814. j = offset - 3;
  34815. for (n = len + 4; n--; j += 2) {
  34816. x[j] *= K_;
  34817. }
  34818. j = offset - 2;
  34819. current = delta * x[j - 1];
  34820. for (n = len + 3; n--; j += 2) {
  34821. next = delta * x[j + 1];
  34822. x[j] = K * x[j] - current - next;
  34823. if (n--) {
  34824. j += 2;
  34825. current = delta * x[j + 1];
  34826. x[j] = K * x[j] - current - next;
  34827. } else {
  34828. break;
  34829. }
  34830. }
  34831. j = offset - 1;
  34832. current = gamma * x[j - 1];
  34833. for (n = len + 2; n--; j += 2) {
  34834. next = gamma * x[j + 1];
  34835. x[j] -= current + next;
  34836. if (n--) {
  34837. j += 2;
  34838. current = gamma * x[j + 1];
  34839. x[j] -= current + next;
  34840. } else {
  34841. break;
  34842. }
  34843. }
  34844. j = offset;
  34845. current = beta * x[j - 1];
  34846. for (n = len + 1; n--; j += 2) {
  34847. next = beta * x[j + 1];
  34848. x[j] -= current + next;
  34849. if (n--) {
  34850. j += 2;
  34851. current = beta * x[j + 1];
  34852. x[j] -= current + next;
  34853. } else {
  34854. break;
  34855. }
  34856. }
  34857. if (len !== 0) {
  34858. j = offset + 1;
  34859. current = alpha * x[j - 1];
  34860. for (n = len; n--; j += 2) {
  34861. next = alpha * x[j + 1];
  34862. x[j] -= current + next;
  34863. if (n--) {
  34864. j += 2;
  34865. current = alpha * x[j + 1];
  34866. x[j] -= current + next;
  34867. } else {
  34868. break;
  34869. }
  34870. }
  34871. }
  34872. };
  34873. return IrreversibleTransform;
  34874. }();
  34875. var ReversibleTransform = function ReversibleTransformClosure() {
  34876. function ReversibleTransform() {
  34877. Transform.call(this);
  34878. }
  34879. ReversibleTransform.prototype = Object.create(Transform.prototype);
  34880. ReversibleTransform.prototype.filter = function reversibleTransformFilter(x, offset, length) {
  34881. var len = length >> 1;
  34882. offset = offset | 0;
  34883. var j, n;
  34884. for (j = offset, n = len + 1; n--; j += 2) {
  34885. x[j] -= x[j - 1] + x[j + 1] + 2 >> 2;
  34886. }
  34887. for (j = offset + 1, n = len; n--; j += 2) {
  34888. x[j] += x[j - 1] + x[j + 1] >> 1;
  34889. }
  34890. };
  34891. return ReversibleTransform;
  34892. }();
  34893. return JpxImage;
  34894. }();
  34895. exports.JpxImage = JpxImage;
  34896. /***/ }),
  34897. /* 20 */
  34898. /***/ (function(module, exports, __w_pdfjs_require__) {
  34899. "use strict";
  34900. var sharedUtil = __w_pdfjs_require__(0);
  34901. var corePrimitives = __w_pdfjs_require__(1);
  34902. var coreCrypto = __w_pdfjs_require__(17);
  34903. var coreParser = __w_pdfjs_require__(6);
  34904. var coreChunkedStream = __w_pdfjs_require__(16);
  34905. var coreColorSpace = __w_pdfjs_require__(4);
  34906. var InvalidPDFException = sharedUtil.InvalidPDFException;
  34907. var MissingDataException = sharedUtil.MissingDataException;
  34908. var XRefParseException = sharedUtil.XRefParseException;
  34909. var assert = sharedUtil.assert;
  34910. var bytesToString = sharedUtil.bytesToString;
  34911. var createPromiseCapability = sharedUtil.createPromiseCapability;
  34912. var error = sharedUtil.error;
  34913. var info = sharedUtil.info;
  34914. var isArray = sharedUtil.isArray;
  34915. var isBool = sharedUtil.isBool;
  34916. var isInt = sharedUtil.isInt;
  34917. var isString = sharedUtil.isString;
  34918. var shadow = sharedUtil.shadow;
  34919. var stringToPDFString = sharedUtil.stringToPDFString;
  34920. var stringToUTF8String = sharedUtil.stringToUTF8String;
  34921. var warn = sharedUtil.warn;
  34922. var createValidAbsoluteUrl = sharedUtil.createValidAbsoluteUrl;
  34923. var Util = sharedUtil.Util;
  34924. var Ref = corePrimitives.Ref;
  34925. var RefSet = corePrimitives.RefSet;
  34926. var RefSetCache = corePrimitives.RefSetCache;
  34927. var isName = corePrimitives.isName;
  34928. var isCmd = corePrimitives.isCmd;
  34929. var isDict = corePrimitives.isDict;
  34930. var isRef = corePrimitives.isRef;
  34931. var isRefsEqual = corePrimitives.isRefsEqual;
  34932. var isStream = corePrimitives.isStream;
  34933. var CipherTransformFactory = coreCrypto.CipherTransformFactory;
  34934. var Lexer = coreParser.Lexer;
  34935. var Parser = coreParser.Parser;
  34936. var ChunkedStream = coreChunkedStream.ChunkedStream;
  34937. var ColorSpace = coreColorSpace.ColorSpace;
  34938. var Catalog = function CatalogClosure() {
  34939. function Catalog(pdfManager, xref, pageFactory) {
  34940. this.pdfManager = pdfManager;
  34941. this.xref = xref;
  34942. this.catDict = xref.getCatalogObj();
  34943. this.fontCache = new RefSetCache();
  34944. assert(isDict(this.catDict), 'catalog object is not a dictionary');
  34945. this.pageFactory = pageFactory;
  34946. this.pagePromises = [];
  34947. }
  34948. Catalog.prototype = {
  34949. get metadata() {
  34950. var streamRef = this.catDict.getRaw('Metadata');
  34951. if (!isRef(streamRef)) {
  34952. return shadow(this, 'metadata', null);
  34953. }
  34954. var encryptMetadata = !this.xref.encrypt ? false : this.xref.encrypt.encryptMetadata;
  34955. var stream = this.xref.fetch(streamRef, !encryptMetadata);
  34956. var metadata;
  34957. if (stream && isDict(stream.dict)) {
  34958. var type = stream.dict.get('Type');
  34959. var subtype = stream.dict.get('Subtype');
  34960. if (isName(type, 'Metadata') && isName(subtype, 'XML')) {
  34961. try {
  34962. metadata = stringToUTF8String(bytesToString(stream.getBytes()));
  34963. } catch (e) {
  34964. info('Skipping invalid metadata.');
  34965. }
  34966. }
  34967. }
  34968. return shadow(this, 'metadata', metadata);
  34969. },
  34970. get toplevelPagesDict() {
  34971. var pagesObj = this.catDict.get('Pages');
  34972. assert(isDict(pagesObj), 'invalid top-level pages dictionary');
  34973. return shadow(this, 'toplevelPagesDict', pagesObj);
  34974. },
  34975. get documentOutline() {
  34976. var obj = null;
  34977. try {
  34978. obj = this.readDocumentOutline();
  34979. } catch (ex) {
  34980. if (ex instanceof MissingDataException) {
  34981. throw ex;
  34982. }
  34983. warn('Unable to read document outline');
  34984. }
  34985. return shadow(this, 'documentOutline', obj);
  34986. },
  34987. readDocumentOutline: function Catalog_readDocumentOutline() {
  34988. var obj = this.catDict.get('Outlines');
  34989. if (!isDict(obj)) {
  34990. return null;
  34991. }
  34992. obj = obj.getRaw('First');
  34993. if (!isRef(obj)) {
  34994. return null;
  34995. }
  34996. var root = { items: [] };
  34997. var queue = [{
  34998. obj: obj,
  34999. parent: root
  35000. }];
  35001. var processed = new RefSet();
  35002. processed.put(obj);
  35003. var xref = this.xref, blackColor = new Uint8Array(3);
  35004. while (queue.length > 0) {
  35005. var i = queue.shift();
  35006. var outlineDict = xref.fetchIfRef(i.obj);
  35007. if (outlineDict === null) {
  35008. continue;
  35009. }
  35010. assert(outlineDict.has('Title'), 'Invalid outline item');
  35011. var data = {
  35012. url: null,
  35013. dest: null
  35014. };
  35015. Catalog.parseDestDictionary({
  35016. destDict: outlineDict,
  35017. resultObj: data,
  35018. docBaseUrl: this.pdfManager.docBaseUrl
  35019. });
  35020. var title = outlineDict.get('Title');
  35021. var flags = outlineDict.get('F') || 0;
  35022. var color = outlineDict.getArray('C'), rgbColor = blackColor;
  35023. if (isArray(color) && color.length === 3 && (color[0] !== 0 || color[1] !== 0 || color[2] !== 0)) {
  35024. rgbColor = ColorSpace.singletons.rgb.getRgb(color, 0);
  35025. }
  35026. var outlineItem = {
  35027. dest: data.dest,
  35028. url: data.url,
  35029. unsafeUrl: data.unsafeUrl,
  35030. newWindow: data.newWindow,
  35031. title: stringToPDFString(title),
  35032. color: rgbColor,
  35033. count: outlineDict.get('Count'),
  35034. bold: !!(flags & 2),
  35035. italic: !!(flags & 1),
  35036. items: []
  35037. };
  35038. i.parent.items.push(outlineItem);
  35039. obj = outlineDict.getRaw('First');
  35040. if (isRef(obj) && !processed.has(obj)) {
  35041. queue.push({
  35042. obj: obj,
  35043. parent: outlineItem
  35044. });
  35045. processed.put(obj);
  35046. }
  35047. obj = outlineDict.getRaw('Next');
  35048. if (isRef(obj) && !processed.has(obj)) {
  35049. queue.push({
  35050. obj: obj,
  35051. parent: i.parent
  35052. });
  35053. processed.put(obj);
  35054. }
  35055. }
  35056. return root.items.length > 0 ? root.items : null;
  35057. },
  35058. get numPages() {
  35059. var obj = this.toplevelPagesDict.get('Count');
  35060. assert(isInt(obj), 'page count in top level pages object is not an integer');
  35061. return shadow(this, 'num', obj);
  35062. },
  35063. get destinations() {
  35064. function fetchDestination(dest) {
  35065. return isDict(dest) ? dest.get('D') : dest;
  35066. }
  35067. var xref = this.xref;
  35068. var dests = {}, nameTreeRef, nameDictionaryRef;
  35069. var obj = this.catDict.get('Names');
  35070. if (obj && obj.has('Dests')) {
  35071. nameTreeRef = obj.getRaw('Dests');
  35072. } else if (this.catDict.has('Dests')) {
  35073. nameDictionaryRef = this.catDict.get('Dests');
  35074. }
  35075. if (nameDictionaryRef) {
  35076. obj = nameDictionaryRef;
  35077. obj.forEach(function catalogForEach(key, value) {
  35078. if (!value) {
  35079. return;
  35080. }
  35081. dests[key] = fetchDestination(value);
  35082. });
  35083. }
  35084. if (nameTreeRef) {
  35085. var nameTree = new NameTree(nameTreeRef, xref);
  35086. var names = nameTree.getAll();
  35087. for (var name in names) {
  35088. dests[name] = fetchDestination(names[name]);
  35089. }
  35090. }
  35091. return shadow(this, 'destinations', dests);
  35092. },
  35093. getDestination: function Catalog_getDestination(destinationId) {
  35094. function fetchDestination(dest) {
  35095. return isDict(dest) ? dest.get('D') : dest;
  35096. }
  35097. var xref = this.xref;
  35098. var dest = null, nameTreeRef, nameDictionaryRef;
  35099. var obj = this.catDict.get('Names');
  35100. if (obj && obj.has('Dests')) {
  35101. nameTreeRef = obj.getRaw('Dests');
  35102. } else if (this.catDict.has('Dests')) {
  35103. nameDictionaryRef = this.catDict.get('Dests');
  35104. }
  35105. if (nameDictionaryRef) {
  35106. var value = nameDictionaryRef.get(destinationId);
  35107. if (value) {
  35108. dest = fetchDestination(value);
  35109. }
  35110. }
  35111. if (nameTreeRef) {
  35112. var nameTree = new NameTree(nameTreeRef, xref);
  35113. dest = fetchDestination(nameTree.get(destinationId));
  35114. }
  35115. return dest;
  35116. },
  35117. get pageLabels() {
  35118. var obj = null;
  35119. try {
  35120. obj = this.readPageLabels();
  35121. } catch (ex) {
  35122. if (ex instanceof MissingDataException) {
  35123. throw ex;
  35124. }
  35125. warn('Unable to read page labels.');
  35126. }
  35127. return shadow(this, 'pageLabels', obj);
  35128. },
  35129. readPageLabels: function Catalog_readPageLabels() {
  35130. var obj = this.catDict.getRaw('PageLabels');
  35131. if (!obj) {
  35132. return null;
  35133. }
  35134. var pageLabels = new Array(this.numPages);
  35135. var style = null;
  35136. var prefix = '';
  35137. var numberTree = new NumberTree(obj, this.xref);
  35138. var nums = numberTree.getAll();
  35139. var currentLabel = '', currentIndex = 1;
  35140. for (var i = 0, ii = this.numPages; i < ii; i++) {
  35141. if (i in nums) {
  35142. var labelDict = nums[i];
  35143. assert(isDict(labelDict), 'The PageLabel is not a dictionary.');
  35144. var type = labelDict.get('Type');
  35145. assert(!type || isName(type, 'PageLabel'), 'Invalid type in PageLabel dictionary.');
  35146. var s = labelDict.get('S');
  35147. assert(!s || isName(s), 'Invalid style in PageLabel dictionary.');
  35148. style = s ? s.name : null;
  35149. var p = labelDict.get('P');
  35150. assert(!p || isString(p), 'Invalid prefix in PageLabel dictionary.');
  35151. prefix = p ? stringToPDFString(p) : '';
  35152. var st = labelDict.get('St');
  35153. assert(!st || isInt(st) && st >= 1, 'Invalid start in PageLabel dictionary.');
  35154. currentIndex = st || 1;
  35155. }
  35156. switch (style) {
  35157. case 'D':
  35158. currentLabel = currentIndex;
  35159. break;
  35160. case 'R':
  35161. case 'r':
  35162. currentLabel = Util.toRoman(currentIndex, style === 'r');
  35163. break;
  35164. case 'A':
  35165. case 'a':
  35166. var LIMIT = 26;
  35167. var A_UPPER_CASE = 0x41, A_LOWER_CASE = 0x61;
  35168. var baseCharCode = style === 'a' ? A_LOWER_CASE : A_UPPER_CASE;
  35169. var letterIndex = currentIndex - 1;
  35170. var character = String.fromCharCode(baseCharCode + letterIndex % LIMIT);
  35171. var charBuf = [];
  35172. for (var j = 0, jj = letterIndex / LIMIT | 0; j <= jj; j++) {
  35173. charBuf.push(character);
  35174. }
  35175. currentLabel = charBuf.join('');
  35176. break;
  35177. default:
  35178. assert(!style, 'Invalid style "' + style + '" in PageLabel dictionary.');
  35179. }
  35180. pageLabels[i] = prefix + currentLabel;
  35181. currentLabel = '';
  35182. currentIndex++;
  35183. }
  35184. return pageLabels;
  35185. },
  35186. get attachments() {
  35187. var xref = this.xref;
  35188. var attachments = null, nameTreeRef;
  35189. var obj = this.catDict.get('Names');
  35190. if (obj) {
  35191. nameTreeRef = obj.getRaw('EmbeddedFiles');
  35192. }
  35193. if (nameTreeRef) {
  35194. var nameTree = new NameTree(nameTreeRef, xref);
  35195. var names = nameTree.getAll();
  35196. for (var name in names) {
  35197. var fs = new FileSpec(names[name], xref);
  35198. if (!attachments) {
  35199. attachments = Object.create(null);
  35200. }
  35201. attachments[stringToPDFString(name)] = fs.serializable;
  35202. }
  35203. }
  35204. return shadow(this, 'attachments', attachments);
  35205. },
  35206. get javaScript() {
  35207. var xref = this.xref;
  35208. var obj = this.catDict.get('Names');
  35209. var javaScript = [];
  35210. function appendIfJavaScriptDict(jsDict) {
  35211. var type = jsDict.get('S');
  35212. if (!isName(type, 'JavaScript')) {
  35213. return;
  35214. }
  35215. var js = jsDict.get('JS');
  35216. if (isStream(js)) {
  35217. js = bytesToString(js.getBytes());
  35218. } else if (!isString(js)) {
  35219. return;
  35220. }
  35221. javaScript.push(stringToPDFString(js));
  35222. }
  35223. if (obj && obj.has('JavaScript')) {
  35224. var nameTree = new NameTree(obj.getRaw('JavaScript'), xref);
  35225. var names = nameTree.getAll();
  35226. for (var name in names) {
  35227. var jsDict = names[name];
  35228. if (isDict(jsDict)) {
  35229. appendIfJavaScriptDict(jsDict);
  35230. }
  35231. }
  35232. }
  35233. var openactionDict = this.catDict.get('OpenAction');
  35234. if (isDict(openactionDict, 'Action')) {
  35235. var actionType = openactionDict.get('S');
  35236. if (isName(actionType, 'Named')) {
  35237. var action = openactionDict.get('N');
  35238. if (isName(action, 'Print')) {
  35239. javaScript.push('print({});');
  35240. }
  35241. } else {
  35242. appendIfJavaScriptDict(openactionDict);
  35243. }
  35244. }
  35245. return shadow(this, 'javaScript', javaScript);
  35246. },
  35247. cleanup: function Catalog_cleanup() {
  35248. var promises = [];
  35249. this.fontCache.forEach(function (promise) {
  35250. promises.push(promise);
  35251. });
  35252. return Promise.all(promises).then(function (translatedFonts) {
  35253. for (var i = 0, ii = translatedFonts.length; i < ii; i++) {
  35254. var font = translatedFonts[i].dict;
  35255. delete font.translated;
  35256. }
  35257. this.fontCache.clear();
  35258. }.bind(this));
  35259. },
  35260. getPage: function Catalog_getPage(pageIndex) {
  35261. if (!(pageIndex in this.pagePromises)) {
  35262. this.pagePromises[pageIndex] = this.getPageDict(pageIndex).then(function (a) {
  35263. var dict = a[0];
  35264. var ref = a[1];
  35265. return this.pageFactory.createPage(pageIndex, dict, ref, this.fontCache);
  35266. }.bind(this));
  35267. }
  35268. return this.pagePromises[pageIndex];
  35269. },
  35270. getPageDict: function Catalog_getPageDict(pageIndex) {
  35271. var capability = createPromiseCapability();
  35272. var nodesToVisit = [this.catDict.getRaw('Pages')];
  35273. var currentPageIndex = 0;
  35274. var xref = this.xref;
  35275. var checkAllKids = false;
  35276. function next() {
  35277. while (nodesToVisit.length) {
  35278. var currentNode = nodesToVisit.pop();
  35279. if (isRef(currentNode)) {
  35280. xref.fetchAsync(currentNode).then(function (obj) {
  35281. if (isDict(obj, 'Page') || isDict(obj) && !obj.has('Kids')) {
  35282. if (pageIndex === currentPageIndex) {
  35283. capability.resolve([
  35284. obj,
  35285. currentNode
  35286. ]);
  35287. } else {
  35288. currentPageIndex++;
  35289. next();
  35290. }
  35291. return;
  35292. }
  35293. nodesToVisit.push(obj);
  35294. next();
  35295. }, capability.reject);
  35296. return;
  35297. }
  35298. assert(isDict(currentNode), 'page dictionary kid reference points to wrong type of object');
  35299. var count = currentNode.get('Count');
  35300. if (count === 0) {
  35301. checkAllKids = true;
  35302. }
  35303. if (currentPageIndex + count <= pageIndex) {
  35304. currentPageIndex += count;
  35305. continue;
  35306. }
  35307. var kids = currentNode.get('Kids');
  35308. assert(isArray(kids), 'page dictionary kids object is not an array');
  35309. if (!checkAllKids && count === kids.length) {
  35310. nodesToVisit = [kids[pageIndex - currentPageIndex]];
  35311. currentPageIndex = pageIndex;
  35312. continue;
  35313. } else {
  35314. for (var last = kids.length - 1; last >= 0; last--) {
  35315. nodesToVisit.push(kids[last]);
  35316. }
  35317. }
  35318. }
  35319. capability.reject('Page index ' + pageIndex + ' not found.');
  35320. }
  35321. next();
  35322. return capability.promise;
  35323. },
  35324. getPageIndex: function Catalog_getPageIndex(pageRef) {
  35325. var xref = this.xref;
  35326. function pagesBeforeRef(kidRef) {
  35327. var total = 0;
  35328. var parentRef;
  35329. return xref.fetchAsync(kidRef).then(function (node) {
  35330. if (isRefsEqual(kidRef, pageRef) && !isDict(node, 'Page') && !(isDict(node) && !node.has('Type') && node.has('Contents'))) {
  35331. throw new Error('The reference does not point to a /Page Dict.');
  35332. }
  35333. if (!node) {
  35334. return null;
  35335. }
  35336. assert(isDict(node), 'node must be a Dict.');
  35337. parentRef = node.getRaw('Parent');
  35338. return node.getAsync('Parent');
  35339. }).then(function (parent) {
  35340. if (!parent) {
  35341. return null;
  35342. }
  35343. assert(isDict(parent), 'parent must be a Dict.');
  35344. return parent.getAsync('Kids');
  35345. }).then(function (kids) {
  35346. if (!kids) {
  35347. return null;
  35348. }
  35349. var kidPromises = [];
  35350. var found = false;
  35351. for (var i = 0; i < kids.length; i++) {
  35352. var kid = kids[i];
  35353. assert(isRef(kid), 'kid must be a Ref.');
  35354. if (kid.num === kidRef.num) {
  35355. found = true;
  35356. break;
  35357. }
  35358. kidPromises.push(xref.fetchAsync(kid).then(function (kid) {
  35359. if (kid.has('Count')) {
  35360. var count = kid.get('Count');
  35361. total += count;
  35362. } else {
  35363. total++;
  35364. }
  35365. }));
  35366. }
  35367. if (!found) {
  35368. error('kid ref not found in parents kids');
  35369. }
  35370. return Promise.all(kidPromises).then(function () {
  35371. return [
  35372. total,
  35373. parentRef
  35374. ];
  35375. });
  35376. });
  35377. }
  35378. var total = 0;
  35379. function next(ref) {
  35380. return pagesBeforeRef(ref).then(function (args) {
  35381. if (!args) {
  35382. return total;
  35383. }
  35384. var count = args[0];
  35385. var parentRef = args[1];
  35386. total += count;
  35387. return next(parentRef);
  35388. });
  35389. }
  35390. return next(pageRef);
  35391. }
  35392. };
  35393. Catalog.parseDestDictionary = function Catalog_parseDestDictionary(params) {
  35394. function addDefaultProtocolToUrl(url) {
  35395. if (url.indexOf('www.') === 0) {
  35396. return 'http://' + url;
  35397. }
  35398. return url;
  35399. }
  35400. function tryConvertUrlEncoding(url) {
  35401. try {
  35402. return stringToUTF8String(url);
  35403. } catch (e) {
  35404. return url;
  35405. }
  35406. }
  35407. var destDict = params.destDict;
  35408. if (!isDict(destDict)) {
  35409. warn('Catalog_parseDestDictionary: "destDict" must be a dictionary.');
  35410. return;
  35411. }
  35412. var resultObj = params.resultObj;
  35413. if (typeof resultObj !== 'object') {
  35414. warn('Catalog_parseDestDictionary: "resultObj" must be an object.');
  35415. return;
  35416. }
  35417. var docBaseUrl = params.docBaseUrl || null;
  35418. var action = destDict.get('A'), url, dest;
  35419. if (isDict(action)) {
  35420. var linkType = action.get('S').name;
  35421. switch (linkType) {
  35422. case 'URI':
  35423. url = action.get('URI');
  35424. if (isName(url)) {
  35425. url = '/' + url.name;
  35426. } else if (isString(url)) {
  35427. url = addDefaultProtocolToUrl(url);
  35428. }
  35429. break;
  35430. case 'GoTo':
  35431. dest = action.get('D');
  35432. break;
  35433. case 'Launch':
  35434. case 'GoToR':
  35435. var urlDict = action.get('F');
  35436. if (isDict(urlDict)) {
  35437. url = urlDict.get('F') || null;
  35438. } else if (isString(urlDict)) {
  35439. url = urlDict;
  35440. }
  35441. var remoteDest = action.get('D');
  35442. if (remoteDest) {
  35443. if (isName(remoteDest)) {
  35444. remoteDest = remoteDest.name;
  35445. }
  35446. if (isString(url)) {
  35447. var baseUrl = url.split('#')[0];
  35448. if (isString(remoteDest)) {
  35449. url = baseUrl + '#' + (/^\d+$/.test(remoteDest) ? 'nameddest=' : '') + remoteDest;
  35450. } else if (isArray(remoteDest)) {
  35451. url = baseUrl + '#' + JSON.stringify(remoteDest);
  35452. }
  35453. }
  35454. }
  35455. var newWindow = action.get('NewWindow');
  35456. if (isBool(newWindow)) {
  35457. resultObj.newWindow = newWindow;
  35458. }
  35459. break;
  35460. case 'Named':
  35461. var namedAction = action.get('N');
  35462. if (isName(namedAction)) {
  35463. resultObj.action = namedAction.name;
  35464. }
  35465. break;
  35466. case 'JavaScript':
  35467. var jsAction = action.get('JS'), js;
  35468. if (isStream(jsAction)) {
  35469. js = bytesToString(jsAction.getBytes());
  35470. } else if (isString(jsAction)) {
  35471. js = jsAction;
  35472. }
  35473. if (js) {
  35474. var URL_OPEN_METHODS = [
  35475. 'app.launchURL',
  35476. 'window.open'
  35477. ];
  35478. var regex = new RegExp('^(?:' + URL_OPEN_METHODS.join('|') + ')' + '\\((?:\'|\")(\\S+)(?:\'|\")(?:,|\\))');
  35479. var jsUrl = regex.exec(stringToPDFString(js), 'i');
  35480. if (jsUrl && jsUrl[1]) {
  35481. url = jsUrl[1];
  35482. break;
  35483. }
  35484. }
  35485. default:
  35486. warn('Catalog_parseDestDictionary: Unrecognized link type "' + linkType + '".');
  35487. break;
  35488. }
  35489. } else if (destDict.has('Dest')) {
  35490. dest = destDict.get('Dest');
  35491. }
  35492. if (isString(url)) {
  35493. url = tryConvertUrlEncoding(url);
  35494. var absoluteUrl = createValidAbsoluteUrl(url, docBaseUrl);
  35495. if (absoluteUrl) {
  35496. resultObj.url = absoluteUrl.href;
  35497. }
  35498. resultObj.unsafeUrl = url;
  35499. }
  35500. if (dest) {
  35501. if (isName(dest)) {
  35502. dest = dest.name;
  35503. }
  35504. if (isString(dest) || isArray(dest)) {
  35505. resultObj.dest = dest;
  35506. }
  35507. }
  35508. };
  35509. return Catalog;
  35510. }();
  35511. var XRef = function XRefClosure() {
  35512. function XRef(stream, pdfManager) {
  35513. this.stream = stream;
  35514. this.pdfManager = pdfManager;
  35515. this.entries = [];
  35516. this.xrefstms = Object.create(null);
  35517. this.cache = [];
  35518. this.stats = {
  35519. streamTypes: [],
  35520. fontTypes: []
  35521. };
  35522. }
  35523. XRef.prototype = {
  35524. setStartXRef: function XRef_setStartXRef(startXRef) {
  35525. this.startXRefQueue = [startXRef];
  35526. },
  35527. parse: function XRef_parse(recoveryMode) {
  35528. var trailerDict;
  35529. if (!recoveryMode) {
  35530. trailerDict = this.readXRef();
  35531. } else {
  35532. warn('Indexing all PDF objects');
  35533. trailerDict = this.indexObjects();
  35534. }
  35535. trailerDict.assignXref(this);
  35536. this.trailer = trailerDict;
  35537. var encrypt = trailerDict.get('Encrypt');
  35538. if (isDict(encrypt)) {
  35539. var ids = trailerDict.get('ID');
  35540. var fileId = ids && ids.length ? ids[0] : '';
  35541. encrypt.suppressEncryption = true;
  35542. this.encrypt = new CipherTransformFactory(encrypt, fileId, this.pdfManager.password);
  35543. }
  35544. if (!(this.root = trailerDict.get('Root'))) {
  35545. error('Invalid root reference');
  35546. }
  35547. },
  35548. processXRefTable: function XRef_processXRefTable(parser) {
  35549. if (!('tableState' in this)) {
  35550. this.tableState = {
  35551. entryNum: 0,
  35552. streamPos: parser.lexer.stream.pos,
  35553. parserBuf1: parser.buf1,
  35554. parserBuf2: parser.buf2
  35555. };
  35556. }
  35557. var obj = this.readXRefTable(parser);
  35558. if (!isCmd(obj, 'trailer')) {
  35559. error('Invalid XRef table: could not find trailer dictionary');
  35560. }
  35561. var dict = parser.getObj();
  35562. if (!isDict(dict) && dict.dict) {
  35563. dict = dict.dict;
  35564. }
  35565. if (!isDict(dict)) {
  35566. error('Invalid XRef table: could not parse trailer dictionary');
  35567. }
  35568. delete this.tableState;
  35569. return dict;
  35570. },
  35571. readXRefTable: function XRef_readXRefTable(parser) {
  35572. var stream = parser.lexer.stream;
  35573. var tableState = this.tableState;
  35574. stream.pos = tableState.streamPos;
  35575. parser.buf1 = tableState.parserBuf1;
  35576. parser.buf2 = tableState.parserBuf2;
  35577. var obj;
  35578. while (true) {
  35579. if (!('firstEntryNum' in tableState) || !('entryCount' in tableState)) {
  35580. if (isCmd(obj = parser.getObj(), 'trailer')) {
  35581. break;
  35582. }
  35583. tableState.firstEntryNum = obj;
  35584. tableState.entryCount = parser.getObj();
  35585. }
  35586. var first = tableState.firstEntryNum;
  35587. var count = tableState.entryCount;
  35588. if (!isInt(first) || !isInt(count)) {
  35589. error('Invalid XRef table: wrong types in subsection header');
  35590. }
  35591. for (var i = tableState.entryNum; i < count; i++) {
  35592. tableState.streamPos = stream.pos;
  35593. tableState.entryNum = i;
  35594. tableState.parserBuf1 = parser.buf1;
  35595. tableState.parserBuf2 = parser.buf2;
  35596. var entry = {};
  35597. entry.offset = parser.getObj();
  35598. entry.gen = parser.getObj();
  35599. var type = parser.getObj();
  35600. if (isCmd(type, 'f')) {
  35601. entry.free = true;
  35602. } else if (isCmd(type, 'n')) {
  35603. entry.uncompressed = true;
  35604. }
  35605. if (!isInt(entry.offset) || !isInt(entry.gen) || !(entry.free || entry.uncompressed)) {
  35606. error('Invalid entry in XRef subsection: ' + first + ', ' + count);
  35607. }
  35608. if (i === 0 && entry.free && first === 1) {
  35609. first = 0;
  35610. }
  35611. if (!this.entries[i + first]) {
  35612. this.entries[i + first] = entry;
  35613. }
  35614. }
  35615. tableState.entryNum = 0;
  35616. tableState.streamPos = stream.pos;
  35617. tableState.parserBuf1 = parser.buf1;
  35618. tableState.parserBuf2 = parser.buf2;
  35619. delete tableState.firstEntryNum;
  35620. delete tableState.entryCount;
  35621. }
  35622. if (this.entries[0] && !this.entries[0].free) {
  35623. error('Invalid XRef table: unexpected first object');
  35624. }
  35625. return obj;
  35626. },
  35627. processXRefStream: function XRef_processXRefStream(stream) {
  35628. if (!('streamState' in this)) {
  35629. var streamParameters = stream.dict;
  35630. var byteWidths = streamParameters.get('W');
  35631. var range = streamParameters.get('Index');
  35632. if (!range) {
  35633. range = [
  35634. 0,
  35635. streamParameters.get('Size')
  35636. ];
  35637. }
  35638. this.streamState = {
  35639. entryRanges: range,
  35640. byteWidths: byteWidths,
  35641. entryNum: 0,
  35642. streamPos: stream.pos
  35643. };
  35644. }
  35645. this.readXRefStream(stream);
  35646. delete this.streamState;
  35647. return stream.dict;
  35648. },
  35649. readXRefStream: function XRef_readXRefStream(stream) {
  35650. var i, j;
  35651. var streamState = this.streamState;
  35652. stream.pos = streamState.streamPos;
  35653. var byteWidths = streamState.byteWidths;
  35654. var typeFieldWidth = byteWidths[0];
  35655. var offsetFieldWidth = byteWidths[1];
  35656. var generationFieldWidth = byteWidths[2];
  35657. var entryRanges = streamState.entryRanges;
  35658. while (entryRanges.length > 0) {
  35659. var first = entryRanges[0];
  35660. var n = entryRanges[1];
  35661. if (!isInt(first) || !isInt(n)) {
  35662. error('Invalid XRef range fields: ' + first + ', ' + n);
  35663. }
  35664. if (!isInt(typeFieldWidth) || !isInt(offsetFieldWidth) || !isInt(generationFieldWidth)) {
  35665. error('Invalid XRef entry fields length: ' + first + ', ' + n);
  35666. }
  35667. for (i = streamState.entryNum; i < n; ++i) {
  35668. streamState.entryNum = i;
  35669. streamState.streamPos = stream.pos;
  35670. var type = 0, offset = 0, generation = 0;
  35671. for (j = 0; j < typeFieldWidth; ++j) {
  35672. type = type << 8 | stream.getByte();
  35673. }
  35674. if (typeFieldWidth === 0) {
  35675. type = 1;
  35676. }
  35677. for (j = 0; j < offsetFieldWidth; ++j) {
  35678. offset = offset << 8 | stream.getByte();
  35679. }
  35680. for (j = 0; j < generationFieldWidth; ++j) {
  35681. generation = generation << 8 | stream.getByte();
  35682. }
  35683. var entry = {};
  35684. entry.offset = offset;
  35685. entry.gen = generation;
  35686. switch (type) {
  35687. case 0:
  35688. entry.free = true;
  35689. break;
  35690. case 1:
  35691. entry.uncompressed = true;
  35692. break;
  35693. case 2:
  35694. break;
  35695. default:
  35696. error('Invalid XRef entry type: ' + type);
  35697. }
  35698. if (!this.entries[first + i]) {
  35699. this.entries[first + i] = entry;
  35700. }
  35701. }
  35702. streamState.entryNum = 0;
  35703. streamState.streamPos = stream.pos;
  35704. entryRanges.splice(0, 2);
  35705. }
  35706. },
  35707. indexObjects: function XRef_indexObjects() {
  35708. var TAB = 0x9, LF = 0xA, CR = 0xD, SPACE = 0x20;
  35709. var PERCENT = 0x25, LT = 0x3C;
  35710. function readToken(data, offset) {
  35711. var token = '', ch = data[offset];
  35712. while (ch !== LF && ch !== CR && ch !== LT) {
  35713. if (++offset >= data.length) {
  35714. break;
  35715. }
  35716. token += String.fromCharCode(ch);
  35717. ch = data[offset];
  35718. }
  35719. return token;
  35720. }
  35721. function skipUntil(data, offset, what) {
  35722. var length = what.length, dataLength = data.length;
  35723. var skipped = 0;
  35724. while (offset < dataLength) {
  35725. var i = 0;
  35726. while (i < length && data[offset + i] === what[i]) {
  35727. ++i;
  35728. }
  35729. if (i >= length) {
  35730. break;
  35731. }
  35732. offset++;
  35733. skipped++;
  35734. }
  35735. return skipped;
  35736. }
  35737. var objRegExp = /^(\d+)\s+(\d+)\s+obj\b/;
  35738. var trailerBytes = new Uint8Array([
  35739. 116,
  35740. 114,
  35741. 97,
  35742. 105,
  35743. 108,
  35744. 101,
  35745. 114
  35746. ]);
  35747. var startxrefBytes = new Uint8Array([
  35748. 115,
  35749. 116,
  35750. 97,
  35751. 114,
  35752. 116,
  35753. 120,
  35754. 114,
  35755. 101,
  35756. 102
  35757. ]);
  35758. var endobjBytes = new Uint8Array([
  35759. 101,
  35760. 110,
  35761. 100,
  35762. 111,
  35763. 98,
  35764. 106
  35765. ]);
  35766. var xrefBytes = new Uint8Array([
  35767. 47,
  35768. 88,
  35769. 82,
  35770. 101,
  35771. 102
  35772. ]);
  35773. this.entries.length = 0;
  35774. var stream = this.stream;
  35775. stream.pos = 0;
  35776. var buffer = stream.getBytes();
  35777. var position = stream.start, length = buffer.length;
  35778. var trailers = [], xrefStms = [];
  35779. while (position < length) {
  35780. var ch = buffer[position];
  35781. if (ch === TAB || ch === LF || ch === CR || ch === SPACE) {
  35782. ++position;
  35783. continue;
  35784. }
  35785. if (ch === PERCENT) {
  35786. do {
  35787. ++position;
  35788. if (position >= length) {
  35789. break;
  35790. }
  35791. ch = buffer[position];
  35792. } while (ch !== LF && ch !== CR);
  35793. continue;
  35794. }
  35795. var token = readToken(buffer, position);
  35796. var m;
  35797. if (token.indexOf('xref') === 0 && (token.length === 4 || /\s/.test(token[4]))) {
  35798. position += skipUntil(buffer, position, trailerBytes);
  35799. trailers.push(position);
  35800. position += skipUntil(buffer, position, startxrefBytes);
  35801. } else if (m = objRegExp.exec(token)) {
  35802. if (typeof this.entries[m[1]] === 'undefined') {
  35803. this.entries[m[1]] = {
  35804. offset: position - stream.start,
  35805. gen: m[2] | 0,
  35806. uncompressed: true
  35807. };
  35808. }
  35809. var contentLength = skipUntil(buffer, position, endobjBytes) + 7;
  35810. var content = buffer.subarray(position, position + contentLength);
  35811. var xrefTagOffset = skipUntil(content, 0, xrefBytes);
  35812. if (xrefTagOffset < contentLength && content[xrefTagOffset + 5] < 64) {
  35813. xrefStms.push(position - stream.start);
  35814. this.xrefstms[position - stream.start] = 1;
  35815. }
  35816. position += contentLength;
  35817. } else if (token.indexOf('trailer') === 0 && (token.length === 7 || /\s/.test(token[7]))) {
  35818. trailers.push(position);
  35819. position += skipUntil(buffer, position, startxrefBytes);
  35820. } else {
  35821. position += token.length + 1;
  35822. }
  35823. }
  35824. var i, ii;
  35825. for (i = 0, ii = xrefStms.length; i < ii; ++i) {
  35826. this.startXRefQueue.push(xrefStms[i]);
  35827. this.readXRef(true);
  35828. }
  35829. var dict;
  35830. for (i = 0, ii = trailers.length; i < ii; ++i) {
  35831. stream.pos = trailers[i];
  35832. var parser = new Parser(new Lexer(stream), true, this, true);
  35833. var obj = parser.getObj();
  35834. if (!isCmd(obj, 'trailer')) {
  35835. continue;
  35836. }
  35837. dict = parser.getObj();
  35838. if (!isDict(dict)) {
  35839. continue;
  35840. }
  35841. if (dict.has('ID')) {
  35842. return dict;
  35843. }
  35844. }
  35845. if (dict) {
  35846. return dict;
  35847. }
  35848. throw new InvalidPDFException('Invalid PDF structure');
  35849. },
  35850. readXRef: function XRef_readXRef(recoveryMode) {
  35851. var stream = this.stream;
  35852. try {
  35853. while (this.startXRefQueue.length) {
  35854. var startXRef = this.startXRefQueue[0];
  35855. stream.pos = startXRef + stream.start;
  35856. var parser = new Parser(new Lexer(stream), true, this);
  35857. var obj = parser.getObj();
  35858. var dict;
  35859. if (isCmd(obj, 'xref')) {
  35860. dict = this.processXRefTable(parser);
  35861. if (!this.topDict) {
  35862. this.topDict = dict;
  35863. }
  35864. obj = dict.get('XRefStm');
  35865. if (isInt(obj)) {
  35866. var pos = obj;
  35867. if (!(pos in this.xrefstms)) {
  35868. this.xrefstms[pos] = 1;
  35869. this.startXRefQueue.push(pos);
  35870. }
  35871. }
  35872. } else if (isInt(obj)) {
  35873. if (!isInt(parser.getObj()) || !isCmd(parser.getObj(), 'obj') || !isStream(obj = parser.getObj())) {
  35874. error('Invalid XRef stream');
  35875. }
  35876. dict = this.processXRefStream(obj);
  35877. if (!this.topDict) {
  35878. this.topDict = dict;
  35879. }
  35880. if (!dict) {
  35881. error('Failed to read XRef stream');
  35882. }
  35883. } else {
  35884. error('Invalid XRef stream header');
  35885. }
  35886. obj = dict.get('Prev');
  35887. if (isInt(obj)) {
  35888. this.startXRefQueue.push(obj);
  35889. } else if (isRef(obj)) {
  35890. this.startXRefQueue.push(obj.num);
  35891. }
  35892. this.startXRefQueue.shift();
  35893. }
  35894. return this.topDict;
  35895. } catch (e) {
  35896. if (e instanceof MissingDataException) {
  35897. throw e;
  35898. }
  35899. info('(while reading XRef): ' + e);
  35900. }
  35901. if (recoveryMode) {
  35902. return;
  35903. }
  35904. throw new XRefParseException();
  35905. },
  35906. getEntry: function XRef_getEntry(i) {
  35907. var xrefEntry = this.entries[i];
  35908. if (xrefEntry && !xrefEntry.free && xrefEntry.offset) {
  35909. return xrefEntry;
  35910. }
  35911. return null;
  35912. },
  35913. fetchIfRef: function XRef_fetchIfRef(obj, suppressEncryption) {
  35914. if (!isRef(obj)) {
  35915. return obj;
  35916. }
  35917. return this.fetch(obj, suppressEncryption);
  35918. },
  35919. fetch: function XRef_fetch(ref, suppressEncryption) {
  35920. assert(isRef(ref), 'ref object is not a reference');
  35921. var num = ref.num;
  35922. if (num in this.cache) {
  35923. var cacheEntry = this.cache[num];
  35924. return cacheEntry;
  35925. }
  35926. var xrefEntry = this.getEntry(num);
  35927. if (xrefEntry === null) {
  35928. return this.cache[num] = null;
  35929. }
  35930. if (xrefEntry.uncompressed) {
  35931. xrefEntry = this.fetchUncompressed(ref, xrefEntry, suppressEncryption);
  35932. } else {
  35933. xrefEntry = this.fetchCompressed(xrefEntry, suppressEncryption);
  35934. }
  35935. if (isDict(xrefEntry)) {
  35936. xrefEntry.objId = ref.toString();
  35937. } else if (isStream(xrefEntry)) {
  35938. xrefEntry.dict.objId = ref.toString();
  35939. }
  35940. return xrefEntry;
  35941. },
  35942. fetchUncompressed: function XRef_fetchUncompressed(ref, xrefEntry, suppressEncryption) {
  35943. var gen = ref.gen;
  35944. var num = ref.num;
  35945. if (xrefEntry.gen !== gen) {
  35946. error('inconsistent generation in XRef');
  35947. }
  35948. var stream = this.stream.makeSubStream(xrefEntry.offset + this.stream.start);
  35949. var parser = new Parser(new Lexer(stream), true, this);
  35950. var obj1 = parser.getObj();
  35951. var obj2 = parser.getObj();
  35952. var obj3 = parser.getObj();
  35953. if (!isInt(obj1) || parseInt(obj1, 10) !== num || !isInt(obj2) || parseInt(obj2, 10) !== gen || !isCmd(obj3)) {
  35954. error('bad XRef entry');
  35955. }
  35956. if (!isCmd(obj3, 'obj')) {
  35957. if (obj3.cmd.indexOf('obj') === 0) {
  35958. num = parseInt(obj3.cmd.substring(3), 10);
  35959. if (!isNaN(num)) {
  35960. return num;
  35961. }
  35962. }
  35963. error('bad XRef entry');
  35964. }
  35965. if (this.encrypt && !suppressEncryption) {
  35966. xrefEntry = parser.getObj(this.encrypt.createCipherTransform(num, gen));
  35967. } else {
  35968. xrefEntry = parser.getObj();
  35969. }
  35970. if (!isStream(xrefEntry)) {
  35971. this.cache[num] = xrefEntry;
  35972. }
  35973. return xrefEntry;
  35974. },
  35975. fetchCompressed: function XRef_fetchCompressed(xrefEntry, suppressEncryption) {
  35976. var tableOffset = xrefEntry.offset;
  35977. var stream = this.fetch(new Ref(tableOffset, 0));
  35978. if (!isStream(stream)) {
  35979. error('bad ObjStm stream');
  35980. }
  35981. var first = stream.dict.get('First');
  35982. var n = stream.dict.get('N');
  35983. if (!isInt(first) || !isInt(n)) {
  35984. error('invalid first and n parameters for ObjStm stream');
  35985. }
  35986. var parser = new Parser(new Lexer(stream), false, this);
  35987. parser.allowStreams = true;
  35988. var i, entries = [], num, nums = [];
  35989. for (i = 0; i < n; ++i) {
  35990. num = parser.getObj();
  35991. if (!isInt(num)) {
  35992. error('invalid object number in the ObjStm stream: ' + num);
  35993. }
  35994. nums.push(num);
  35995. var offset = parser.getObj();
  35996. if (!isInt(offset)) {
  35997. error('invalid object offset in the ObjStm stream: ' + offset);
  35998. }
  35999. }
  36000. for (i = 0; i < n; ++i) {
  36001. entries.push(parser.getObj());
  36002. if (isCmd(parser.buf1, 'endobj')) {
  36003. parser.shift();
  36004. }
  36005. num = nums[i];
  36006. var entry = this.entries[num];
  36007. if (entry && entry.offset === tableOffset && entry.gen === i) {
  36008. this.cache[num] = entries[i];
  36009. }
  36010. }
  36011. xrefEntry = entries[xrefEntry.gen];
  36012. if (xrefEntry === undefined) {
  36013. error('bad XRef entry for compressed object');
  36014. }
  36015. return xrefEntry;
  36016. },
  36017. fetchIfRefAsync: function XRef_fetchIfRefAsync(obj, suppressEncryption) {
  36018. if (!isRef(obj)) {
  36019. return Promise.resolve(obj);
  36020. }
  36021. return this.fetchAsync(obj, suppressEncryption);
  36022. },
  36023. fetchAsync: function XRef_fetchAsync(ref, suppressEncryption) {
  36024. var streamManager = this.stream.manager;
  36025. var xref = this;
  36026. return new Promise(function tryFetch(resolve, reject) {
  36027. try {
  36028. resolve(xref.fetch(ref, suppressEncryption));
  36029. } catch (e) {
  36030. if (e instanceof MissingDataException) {
  36031. streamManager.requestRange(e.begin, e.end).then(function () {
  36032. tryFetch(resolve, reject);
  36033. }, reject);
  36034. return;
  36035. }
  36036. reject(e);
  36037. }
  36038. });
  36039. },
  36040. getCatalogObj: function XRef_getCatalogObj() {
  36041. return this.root;
  36042. }
  36043. };
  36044. return XRef;
  36045. }();
  36046. var NameOrNumberTree = function NameOrNumberTreeClosure() {
  36047. function NameOrNumberTree(root, xref) {
  36048. throw new Error('Cannot initialize NameOrNumberTree.');
  36049. }
  36050. NameOrNumberTree.prototype = {
  36051. getAll: function NameOrNumberTree_getAll() {
  36052. var dict = Object.create(null);
  36053. if (!this.root) {
  36054. return dict;
  36055. }
  36056. var xref = this.xref;
  36057. var processed = new RefSet();
  36058. processed.put(this.root);
  36059. var queue = [this.root];
  36060. while (queue.length > 0) {
  36061. var i, n;
  36062. var obj = xref.fetchIfRef(queue.shift());
  36063. if (!isDict(obj)) {
  36064. continue;
  36065. }
  36066. if (obj.has('Kids')) {
  36067. var kids = obj.get('Kids');
  36068. for (i = 0, n = kids.length; i < n; i++) {
  36069. var kid = kids[i];
  36070. assert(!processed.has(kid), 'Duplicate entry in "' + this._type + '" tree.');
  36071. queue.push(kid);
  36072. processed.put(kid);
  36073. }
  36074. continue;
  36075. }
  36076. var entries = obj.get(this._type);
  36077. if (isArray(entries)) {
  36078. for (i = 0, n = entries.length; i < n; i += 2) {
  36079. dict[xref.fetchIfRef(entries[i])] = xref.fetchIfRef(entries[i + 1]);
  36080. }
  36081. }
  36082. }
  36083. return dict;
  36084. },
  36085. get: function NameOrNumberTree_get(key) {
  36086. if (!this.root) {
  36087. return null;
  36088. }
  36089. var xref = this.xref;
  36090. var kidsOrEntries = xref.fetchIfRef(this.root);
  36091. var loopCount = 0;
  36092. var MAX_LEVELS = 10;
  36093. var l, r, m;
  36094. while (kidsOrEntries.has('Kids')) {
  36095. if (++loopCount > MAX_LEVELS) {
  36096. warn('Search depth limit reached for "' + this._type + '" tree.');
  36097. return null;
  36098. }
  36099. var kids = kidsOrEntries.get('Kids');
  36100. if (!isArray(kids)) {
  36101. return null;
  36102. }
  36103. l = 0;
  36104. r = kids.length - 1;
  36105. while (l <= r) {
  36106. m = l + r >> 1;
  36107. var kid = xref.fetchIfRef(kids[m]);
  36108. var limits = kid.get('Limits');
  36109. if (key < xref.fetchIfRef(limits[0])) {
  36110. r = m - 1;
  36111. } else if (key > xref.fetchIfRef(limits[1])) {
  36112. l = m + 1;
  36113. } else {
  36114. kidsOrEntries = xref.fetchIfRef(kids[m]);
  36115. break;
  36116. }
  36117. }
  36118. if (l > r) {
  36119. return null;
  36120. }
  36121. }
  36122. var entries = kidsOrEntries.get(this._type);
  36123. if (isArray(entries)) {
  36124. l = 0;
  36125. r = entries.length - 2;
  36126. while (l <= r) {
  36127. m = l + r & ~1;
  36128. var currentKey = xref.fetchIfRef(entries[m]);
  36129. if (key < currentKey) {
  36130. r = m - 2;
  36131. } else if (key > currentKey) {
  36132. l = m + 2;
  36133. } else {
  36134. return xref.fetchIfRef(entries[m + 1]);
  36135. }
  36136. }
  36137. }
  36138. return null;
  36139. }
  36140. };
  36141. return NameOrNumberTree;
  36142. }();
  36143. var NameTree = function NameTreeClosure() {
  36144. function NameTree(root, xref) {
  36145. this.root = root;
  36146. this.xref = xref;
  36147. this._type = 'Names';
  36148. }
  36149. Util.inherit(NameTree, NameOrNumberTree, {});
  36150. return NameTree;
  36151. }();
  36152. var NumberTree = function NumberTreeClosure() {
  36153. function NumberTree(root, xref) {
  36154. this.root = root;
  36155. this.xref = xref;
  36156. this._type = 'Nums';
  36157. }
  36158. Util.inherit(NumberTree, NameOrNumberTree, {});
  36159. return NumberTree;
  36160. }();
  36161. var FileSpec = function FileSpecClosure() {
  36162. function FileSpec(root, xref) {
  36163. if (!root || !isDict(root)) {
  36164. return;
  36165. }
  36166. this.xref = xref;
  36167. this.root = root;
  36168. if (root.has('FS')) {
  36169. this.fs = root.get('FS');
  36170. }
  36171. this.description = root.has('Desc') ? stringToPDFString(root.get('Desc')) : '';
  36172. if (root.has('RF')) {
  36173. warn('Related file specifications are not supported');
  36174. }
  36175. this.contentAvailable = true;
  36176. if (!root.has('EF')) {
  36177. this.contentAvailable = false;
  36178. warn('Non-embedded file specifications are not supported');
  36179. }
  36180. }
  36181. function pickPlatformItem(dict) {
  36182. if (dict.has('UF')) {
  36183. return dict.get('UF');
  36184. } else if (dict.has('F')) {
  36185. return dict.get('F');
  36186. } else if (dict.has('Unix')) {
  36187. return dict.get('Unix');
  36188. } else if (dict.has('Mac')) {
  36189. return dict.get('Mac');
  36190. } else if (dict.has('DOS')) {
  36191. return dict.get('DOS');
  36192. }
  36193. return null;
  36194. }
  36195. FileSpec.prototype = {
  36196. get filename() {
  36197. if (!this._filename && this.root) {
  36198. var filename = pickPlatformItem(this.root) || 'unnamed';
  36199. this._filename = stringToPDFString(filename).replace(/\\\\/g, '\\').replace(/\\\//g, '/').replace(/\\/g, '/');
  36200. }
  36201. return this._filename;
  36202. },
  36203. get content() {
  36204. if (!this.contentAvailable) {
  36205. return null;
  36206. }
  36207. if (!this.contentRef && this.root) {
  36208. this.contentRef = pickPlatformItem(this.root.get('EF'));
  36209. }
  36210. var content = null;
  36211. if (this.contentRef) {
  36212. var xref = this.xref;
  36213. var fileObj = xref.fetchIfRef(this.contentRef);
  36214. if (fileObj && isStream(fileObj)) {
  36215. content = fileObj.getBytes();
  36216. } else {
  36217. warn('Embedded file specification points to non-existing/invalid ' + 'content');
  36218. }
  36219. } else {
  36220. warn('Embedded file specification does not have a content');
  36221. }
  36222. return content;
  36223. },
  36224. get serializable() {
  36225. return {
  36226. filename: this.filename,
  36227. content: this.content
  36228. };
  36229. }
  36230. };
  36231. return FileSpec;
  36232. }();
  36233. var ObjectLoader = function () {
  36234. function mayHaveChildren(value) {
  36235. return isRef(value) || isDict(value) || isArray(value) || isStream(value);
  36236. }
  36237. function addChildren(node, nodesToVisit) {
  36238. var value;
  36239. if (isDict(node) || isStream(node)) {
  36240. var map;
  36241. if (isDict(node)) {
  36242. map = node.map;
  36243. } else {
  36244. map = node.dict.map;
  36245. }
  36246. for (var key in map) {
  36247. value = map[key];
  36248. if (mayHaveChildren(value)) {
  36249. nodesToVisit.push(value);
  36250. }
  36251. }
  36252. } else if (isArray(node)) {
  36253. for (var i = 0, ii = node.length; i < ii; i++) {
  36254. value = node[i];
  36255. if (mayHaveChildren(value)) {
  36256. nodesToVisit.push(value);
  36257. }
  36258. }
  36259. }
  36260. }
  36261. function ObjectLoader(obj, keys, xref) {
  36262. this.obj = obj;
  36263. this.keys = keys;
  36264. this.xref = xref;
  36265. this.refSet = null;
  36266. this.capability = null;
  36267. }
  36268. ObjectLoader.prototype = {
  36269. load: function ObjectLoader_load() {
  36270. var keys = this.keys;
  36271. this.capability = createPromiseCapability();
  36272. if (!(this.xref.stream instanceof ChunkedStream) || this.xref.stream.getMissingChunks().length === 0) {
  36273. this.capability.resolve();
  36274. return this.capability.promise;
  36275. }
  36276. this.refSet = new RefSet();
  36277. var nodesToVisit = [];
  36278. for (var i = 0; i < keys.length; i++) {
  36279. nodesToVisit.push(this.obj[keys[i]]);
  36280. }
  36281. this._walk(nodesToVisit);
  36282. return this.capability.promise;
  36283. },
  36284. _walk: function ObjectLoader_walk(nodesToVisit) {
  36285. var nodesToRevisit = [];
  36286. var pendingRequests = [];
  36287. while (nodesToVisit.length) {
  36288. var currentNode = nodesToVisit.pop();
  36289. if (isRef(currentNode)) {
  36290. if (this.refSet.has(currentNode)) {
  36291. continue;
  36292. }
  36293. try {
  36294. var ref = currentNode;
  36295. this.refSet.put(ref);
  36296. currentNode = this.xref.fetch(currentNode);
  36297. } catch (e) {
  36298. if (!(e instanceof MissingDataException)) {
  36299. throw e;
  36300. }
  36301. nodesToRevisit.push(currentNode);
  36302. pendingRequests.push({
  36303. begin: e.begin,
  36304. end: e.end
  36305. });
  36306. }
  36307. }
  36308. if (currentNode && currentNode.getBaseStreams) {
  36309. var baseStreams = currentNode.getBaseStreams();
  36310. var foundMissingData = false;
  36311. for (var i = 0; i < baseStreams.length; i++) {
  36312. var stream = baseStreams[i];
  36313. if (stream.getMissingChunks && stream.getMissingChunks().length) {
  36314. foundMissingData = true;
  36315. pendingRequests.push({
  36316. begin: stream.start,
  36317. end: stream.end
  36318. });
  36319. }
  36320. }
  36321. if (foundMissingData) {
  36322. nodesToRevisit.push(currentNode);
  36323. }
  36324. }
  36325. addChildren(currentNode, nodesToVisit);
  36326. }
  36327. if (pendingRequests.length) {
  36328. this.xref.stream.manager.requestRanges(pendingRequests).then(function pendingRequestCallback() {
  36329. nodesToVisit = nodesToRevisit;
  36330. for (var i = 0; i < nodesToRevisit.length; i++) {
  36331. var node = nodesToRevisit[i];
  36332. if (isRef(node)) {
  36333. this.refSet.remove(node);
  36334. }
  36335. }
  36336. this._walk(nodesToVisit);
  36337. }.bind(this), this.capability.reject);
  36338. return;
  36339. }
  36340. this.refSet = null;
  36341. this.capability.resolve();
  36342. }
  36343. };
  36344. return ObjectLoader;
  36345. }();
  36346. exports.Catalog = Catalog;
  36347. exports.ObjectLoader = ObjectLoader;
  36348. exports.XRef = XRef;
  36349. exports.FileSpec = FileSpec;
  36350. /***/ }),
  36351. /* 21 */
  36352. /***/ (function(module, exports, __w_pdfjs_require__) {
  36353. "use strict";
  36354. var sharedUtil = __w_pdfjs_require__(0);
  36355. var getLookupTableFactory = sharedUtil.getLookupTableFactory;
  36356. var getStdFontMap = getLookupTableFactory(function (t) {
  36357. t['ArialNarrow'] = 'Helvetica';
  36358. t['ArialNarrow-Bold'] = 'Helvetica-Bold';
  36359. t['ArialNarrow-BoldItalic'] = 'Helvetica-BoldOblique';
  36360. t['ArialNarrow-Italic'] = 'Helvetica-Oblique';
  36361. t['ArialBlack'] = 'Helvetica';
  36362. t['ArialBlack-Bold'] = 'Helvetica-Bold';
  36363. t['ArialBlack-BoldItalic'] = 'Helvetica-BoldOblique';
  36364. t['ArialBlack-Italic'] = 'Helvetica-Oblique';
  36365. t['Arial-Black'] = 'Helvetica';
  36366. t['Arial-Black-Bold'] = 'Helvetica-Bold';
  36367. t['Arial-Black-BoldItalic'] = 'Helvetica-BoldOblique';
  36368. t['Arial-Black-Italic'] = 'Helvetica-Oblique';
  36369. t['Arial'] = 'Helvetica';
  36370. t['Arial-Bold'] = 'Helvetica-Bold';
  36371. t['Arial-BoldItalic'] = 'Helvetica-BoldOblique';
  36372. t['Arial-Italic'] = 'Helvetica-Oblique';
  36373. t['Arial-BoldItalicMT'] = 'Helvetica-BoldOblique';
  36374. t['Arial-BoldMT'] = 'Helvetica-Bold';
  36375. t['Arial-ItalicMT'] = 'Helvetica-Oblique';
  36376. t['ArialMT'] = 'Helvetica';
  36377. t['Courier-Bold'] = 'Courier-Bold';
  36378. t['Courier-BoldItalic'] = 'Courier-BoldOblique';
  36379. t['Courier-Italic'] = 'Courier-Oblique';
  36380. t['CourierNew'] = 'Courier';
  36381. t['CourierNew-Bold'] = 'Courier-Bold';
  36382. t['CourierNew-BoldItalic'] = 'Courier-BoldOblique';
  36383. t['CourierNew-Italic'] = 'Courier-Oblique';
  36384. t['CourierNewPS-BoldItalicMT'] = 'Courier-BoldOblique';
  36385. t['CourierNewPS-BoldMT'] = 'Courier-Bold';
  36386. t['CourierNewPS-ItalicMT'] = 'Courier-Oblique';
  36387. t['CourierNewPSMT'] = 'Courier';
  36388. t['Helvetica'] = 'Helvetica';
  36389. t['Helvetica-Bold'] = 'Helvetica-Bold';
  36390. t['Helvetica-BoldItalic'] = 'Helvetica-BoldOblique';
  36391. t['Helvetica-BoldOblique'] = 'Helvetica-BoldOblique';
  36392. t['Helvetica-Italic'] = 'Helvetica-Oblique';
  36393. t['Helvetica-Oblique'] = 'Helvetica-Oblique';
  36394. t['Symbol-Bold'] = 'Symbol';
  36395. t['Symbol-BoldItalic'] = 'Symbol';
  36396. t['Symbol-Italic'] = 'Symbol';
  36397. t['TimesNewRoman'] = 'Times-Roman';
  36398. t['TimesNewRoman-Bold'] = 'Times-Bold';
  36399. t['TimesNewRoman-BoldItalic'] = 'Times-BoldItalic';
  36400. t['TimesNewRoman-Italic'] = 'Times-Italic';
  36401. t['TimesNewRomanPS'] = 'Times-Roman';
  36402. t['TimesNewRomanPS-Bold'] = 'Times-Bold';
  36403. t['TimesNewRomanPS-BoldItalic'] = 'Times-BoldItalic';
  36404. t['TimesNewRomanPS-BoldItalicMT'] = 'Times-BoldItalic';
  36405. t['TimesNewRomanPS-BoldMT'] = 'Times-Bold';
  36406. t['TimesNewRomanPS-Italic'] = 'Times-Italic';
  36407. t['TimesNewRomanPS-ItalicMT'] = 'Times-Italic';
  36408. t['TimesNewRomanPSMT'] = 'Times-Roman';
  36409. t['TimesNewRomanPSMT-Bold'] = 'Times-Bold';
  36410. t['TimesNewRomanPSMT-BoldItalic'] = 'Times-BoldItalic';
  36411. t['TimesNewRomanPSMT-Italic'] = 'Times-Italic';
  36412. });
  36413. var getNonStdFontMap = getLookupTableFactory(function (t) {
  36414. t['CenturyGothic'] = 'Helvetica';
  36415. t['CenturyGothic-Bold'] = 'Helvetica-Bold';
  36416. t['CenturyGothic-BoldItalic'] = 'Helvetica-BoldOblique';
  36417. t['CenturyGothic-Italic'] = 'Helvetica-Oblique';
  36418. t['ComicSansMS'] = 'Comic Sans MS';
  36419. t['ComicSansMS-Bold'] = 'Comic Sans MS-Bold';
  36420. t['ComicSansMS-BoldItalic'] = 'Comic Sans MS-BoldItalic';
  36421. t['ComicSansMS-Italic'] = 'Comic Sans MS-Italic';
  36422. t['LucidaConsole'] = 'Courier';
  36423. t['LucidaConsole-Bold'] = 'Courier-Bold';
  36424. t['LucidaConsole-BoldItalic'] = 'Courier-BoldOblique';
  36425. t['LucidaConsole-Italic'] = 'Courier-Oblique';
  36426. t['MS-Gothic'] = 'MS Gothic';
  36427. t['MS-Gothic-Bold'] = 'MS Gothic-Bold';
  36428. t['MS-Gothic-BoldItalic'] = 'MS Gothic-BoldItalic';
  36429. t['MS-Gothic-Italic'] = 'MS Gothic-Italic';
  36430. t['MS-Mincho'] = 'MS Mincho';
  36431. t['MS-Mincho-Bold'] = 'MS Mincho-Bold';
  36432. t['MS-Mincho-BoldItalic'] = 'MS Mincho-BoldItalic';
  36433. t['MS-Mincho-Italic'] = 'MS Mincho-Italic';
  36434. t['MS-PGothic'] = 'MS PGothic';
  36435. t['MS-PGothic-Bold'] = 'MS PGothic-Bold';
  36436. t['MS-PGothic-BoldItalic'] = 'MS PGothic-BoldItalic';
  36437. t['MS-PGothic-Italic'] = 'MS PGothic-Italic';
  36438. t['MS-PMincho'] = 'MS PMincho';
  36439. t['MS-PMincho-Bold'] = 'MS PMincho-Bold';
  36440. t['MS-PMincho-BoldItalic'] = 'MS PMincho-BoldItalic';
  36441. t['MS-PMincho-Italic'] = 'MS PMincho-Italic';
  36442. t['NuptialScript'] = 'Times-Italic';
  36443. t['Wingdings'] = 'ZapfDingbats';
  36444. });
  36445. var getSerifFonts = getLookupTableFactory(function (t) {
  36446. t['Adobe Jenson'] = true;
  36447. t['Adobe Text'] = true;
  36448. t['Albertus'] = true;
  36449. t['Aldus'] = true;
  36450. t['Alexandria'] = true;
  36451. t['Algerian'] = true;
  36452. t['American Typewriter'] = true;
  36453. t['Antiqua'] = true;
  36454. t['Apex'] = true;
  36455. t['Arno'] = true;
  36456. t['Aster'] = true;
  36457. t['Aurora'] = true;
  36458. t['Baskerville'] = true;
  36459. t['Bell'] = true;
  36460. t['Bembo'] = true;
  36461. t['Bembo Schoolbook'] = true;
  36462. t['Benguiat'] = true;
  36463. t['Berkeley Old Style'] = true;
  36464. t['Bernhard Modern'] = true;
  36465. t['Berthold City'] = true;
  36466. t['Bodoni'] = true;
  36467. t['Bauer Bodoni'] = true;
  36468. t['Book Antiqua'] = true;
  36469. t['Bookman'] = true;
  36470. t['Bordeaux Roman'] = true;
  36471. t['Californian FB'] = true;
  36472. t['Calisto'] = true;
  36473. t['Calvert'] = true;
  36474. t['Capitals'] = true;
  36475. t['Cambria'] = true;
  36476. t['Cartier'] = true;
  36477. t['Caslon'] = true;
  36478. t['Catull'] = true;
  36479. t['Centaur'] = true;
  36480. t['Century Old Style'] = true;
  36481. t['Century Schoolbook'] = true;
  36482. t['Chaparral'] = true;
  36483. t['Charis SIL'] = true;
  36484. t['Cheltenham'] = true;
  36485. t['Cholla Slab'] = true;
  36486. t['Clarendon'] = true;
  36487. t['Clearface'] = true;
  36488. t['Cochin'] = true;
  36489. t['Colonna'] = true;
  36490. t['Computer Modern'] = true;
  36491. t['Concrete Roman'] = true;
  36492. t['Constantia'] = true;
  36493. t['Cooper Black'] = true;
  36494. t['Corona'] = true;
  36495. t['Ecotype'] = true;
  36496. t['Egyptienne'] = true;
  36497. t['Elephant'] = true;
  36498. t['Excelsior'] = true;
  36499. t['Fairfield'] = true;
  36500. t['FF Scala'] = true;
  36501. t['Folkard'] = true;
  36502. t['Footlight'] = true;
  36503. t['FreeSerif'] = true;
  36504. t['Friz Quadrata'] = true;
  36505. t['Garamond'] = true;
  36506. t['Gentium'] = true;
  36507. t['Georgia'] = true;
  36508. t['Gloucester'] = true;
  36509. t['Goudy Old Style'] = true;
  36510. t['Goudy Schoolbook'] = true;
  36511. t['Goudy Pro Font'] = true;
  36512. t['Granjon'] = true;
  36513. t['Guardian Egyptian'] = true;
  36514. t['Heather'] = true;
  36515. t['Hercules'] = true;
  36516. t['High Tower Text'] = true;
  36517. t['Hiroshige'] = true;
  36518. t['Hoefler Text'] = true;
  36519. t['Humana Serif'] = true;
  36520. t['Imprint'] = true;
  36521. t['Ionic No. 5'] = true;
  36522. t['Janson'] = true;
  36523. t['Joanna'] = true;
  36524. t['Korinna'] = true;
  36525. t['Lexicon'] = true;
  36526. t['Liberation Serif'] = true;
  36527. t['Linux Libertine'] = true;
  36528. t['Literaturnaya'] = true;
  36529. t['Lucida'] = true;
  36530. t['Lucida Bright'] = true;
  36531. t['Melior'] = true;
  36532. t['Memphis'] = true;
  36533. t['Miller'] = true;
  36534. t['Minion'] = true;
  36535. t['Modern'] = true;
  36536. t['Mona Lisa'] = true;
  36537. t['Mrs Eaves'] = true;
  36538. t['MS Serif'] = true;
  36539. t['Museo Slab'] = true;
  36540. t['New York'] = true;
  36541. t['Nimbus Roman'] = true;
  36542. t['NPS Rawlinson Roadway'] = true;
  36543. t['NuptialScript'] = true;
  36544. t['Palatino'] = true;
  36545. t['Perpetua'] = true;
  36546. t['Plantin'] = true;
  36547. t['Plantin Schoolbook'] = true;
  36548. t['Playbill'] = true;
  36549. t['Poor Richard'] = true;
  36550. t['Rawlinson Roadway'] = true;
  36551. t['Renault'] = true;
  36552. t['Requiem'] = true;
  36553. t['Rockwell'] = true;
  36554. t['Roman'] = true;
  36555. t['Rotis Serif'] = true;
  36556. t['Sabon'] = true;
  36557. t['Scala'] = true;
  36558. t['Seagull'] = true;
  36559. t['Sistina'] = true;
  36560. t['Souvenir'] = true;
  36561. t['STIX'] = true;
  36562. t['Stone Informal'] = true;
  36563. t['Stone Serif'] = true;
  36564. t['Sylfaen'] = true;
  36565. t['Times'] = true;
  36566. t['Trajan'] = true;
  36567. t['Trinité'] = true;
  36568. t['Trump Mediaeval'] = true;
  36569. t['Utopia'] = true;
  36570. t['Vale Type'] = true;
  36571. t['Bitstream Vera'] = true;
  36572. t['Vera Serif'] = true;
  36573. t['Versailles'] = true;
  36574. t['Wanted'] = true;
  36575. t['Weiss'] = true;
  36576. t['Wide Latin'] = true;
  36577. t['Windsor'] = true;
  36578. t['XITS'] = true;
  36579. });
  36580. var getSymbolsFonts = getLookupTableFactory(function (t) {
  36581. t['Dingbats'] = true;
  36582. t['Symbol'] = true;
  36583. t['ZapfDingbats'] = true;
  36584. });
  36585. var getGlyphMapForStandardFonts = getLookupTableFactory(function (t) {
  36586. t[2] = 10;
  36587. t[3] = 32;
  36588. t[4] = 33;
  36589. t[5] = 34;
  36590. t[6] = 35;
  36591. t[7] = 36;
  36592. t[8] = 37;
  36593. t[9] = 38;
  36594. t[10] = 39;
  36595. t[11] = 40;
  36596. t[12] = 41;
  36597. t[13] = 42;
  36598. t[14] = 43;
  36599. t[15] = 44;
  36600. t[16] = 45;
  36601. t[17] = 46;
  36602. t[18] = 47;
  36603. t[19] = 48;
  36604. t[20] = 49;
  36605. t[21] = 50;
  36606. t[22] = 51;
  36607. t[23] = 52;
  36608. t[24] = 53;
  36609. t[25] = 54;
  36610. t[26] = 55;
  36611. t[27] = 56;
  36612. t[28] = 57;
  36613. t[29] = 58;
  36614. t[30] = 894;
  36615. t[31] = 60;
  36616. t[32] = 61;
  36617. t[33] = 62;
  36618. t[34] = 63;
  36619. t[35] = 64;
  36620. t[36] = 65;
  36621. t[37] = 66;
  36622. t[38] = 67;
  36623. t[39] = 68;
  36624. t[40] = 69;
  36625. t[41] = 70;
  36626. t[42] = 71;
  36627. t[43] = 72;
  36628. t[44] = 73;
  36629. t[45] = 74;
  36630. t[46] = 75;
  36631. t[47] = 76;
  36632. t[48] = 77;
  36633. t[49] = 78;
  36634. t[50] = 79;
  36635. t[51] = 80;
  36636. t[52] = 81;
  36637. t[53] = 82;
  36638. t[54] = 83;
  36639. t[55] = 84;
  36640. t[56] = 85;
  36641. t[57] = 86;
  36642. t[58] = 87;
  36643. t[59] = 88;
  36644. t[60] = 89;
  36645. t[61] = 90;
  36646. t[62] = 91;
  36647. t[63] = 92;
  36648. t[64] = 93;
  36649. t[65] = 94;
  36650. t[66] = 95;
  36651. t[67] = 96;
  36652. t[68] = 97;
  36653. t[69] = 98;
  36654. t[70] = 99;
  36655. t[71] = 100;
  36656. t[72] = 101;
  36657. t[73] = 102;
  36658. t[74] = 103;
  36659. t[75] = 104;
  36660. t[76] = 105;
  36661. t[77] = 106;
  36662. t[78] = 107;
  36663. t[79] = 108;
  36664. t[80] = 109;
  36665. t[81] = 110;
  36666. t[82] = 111;
  36667. t[83] = 112;
  36668. t[84] = 113;
  36669. t[85] = 114;
  36670. t[86] = 115;
  36671. t[87] = 116;
  36672. t[88] = 117;
  36673. t[89] = 118;
  36674. t[90] = 119;
  36675. t[91] = 120;
  36676. t[92] = 121;
  36677. t[93] = 122;
  36678. t[94] = 123;
  36679. t[95] = 124;
  36680. t[96] = 125;
  36681. t[97] = 126;
  36682. t[98] = 196;
  36683. t[99] = 197;
  36684. t[100] = 199;
  36685. t[101] = 201;
  36686. t[102] = 209;
  36687. t[103] = 214;
  36688. t[104] = 220;
  36689. t[105] = 225;
  36690. t[106] = 224;
  36691. t[107] = 226;
  36692. t[108] = 228;
  36693. t[109] = 227;
  36694. t[110] = 229;
  36695. t[111] = 231;
  36696. t[112] = 233;
  36697. t[113] = 232;
  36698. t[114] = 234;
  36699. t[115] = 235;
  36700. t[116] = 237;
  36701. t[117] = 236;
  36702. t[118] = 238;
  36703. t[119] = 239;
  36704. t[120] = 241;
  36705. t[121] = 243;
  36706. t[122] = 242;
  36707. t[123] = 244;
  36708. t[124] = 246;
  36709. t[125] = 245;
  36710. t[126] = 250;
  36711. t[127] = 249;
  36712. t[128] = 251;
  36713. t[129] = 252;
  36714. t[130] = 8224;
  36715. t[131] = 176;
  36716. t[132] = 162;
  36717. t[133] = 163;
  36718. t[134] = 167;
  36719. t[135] = 8226;
  36720. t[136] = 182;
  36721. t[137] = 223;
  36722. t[138] = 174;
  36723. t[139] = 169;
  36724. t[140] = 8482;
  36725. t[141] = 180;
  36726. t[142] = 168;
  36727. t[143] = 8800;
  36728. t[144] = 198;
  36729. t[145] = 216;
  36730. t[146] = 8734;
  36731. t[147] = 177;
  36732. t[148] = 8804;
  36733. t[149] = 8805;
  36734. t[150] = 165;
  36735. t[151] = 181;
  36736. t[152] = 8706;
  36737. t[153] = 8721;
  36738. t[154] = 8719;
  36739. t[156] = 8747;
  36740. t[157] = 170;
  36741. t[158] = 186;
  36742. t[159] = 8486;
  36743. t[160] = 230;
  36744. t[161] = 248;
  36745. t[162] = 191;
  36746. t[163] = 161;
  36747. t[164] = 172;
  36748. t[165] = 8730;
  36749. t[166] = 402;
  36750. t[167] = 8776;
  36751. t[168] = 8710;
  36752. t[169] = 171;
  36753. t[170] = 187;
  36754. t[171] = 8230;
  36755. t[210] = 218;
  36756. t[223] = 711;
  36757. t[224] = 321;
  36758. t[225] = 322;
  36759. t[227] = 353;
  36760. t[229] = 382;
  36761. t[234] = 253;
  36762. t[252] = 263;
  36763. t[253] = 268;
  36764. t[254] = 269;
  36765. t[258] = 258;
  36766. t[260] = 260;
  36767. t[261] = 261;
  36768. t[265] = 280;
  36769. t[266] = 281;
  36770. t[268] = 283;
  36771. t[269] = 313;
  36772. t[275] = 323;
  36773. t[276] = 324;
  36774. t[278] = 328;
  36775. t[284] = 345;
  36776. t[285] = 346;
  36777. t[286] = 347;
  36778. t[292] = 367;
  36779. t[295] = 377;
  36780. t[296] = 378;
  36781. t[298] = 380;
  36782. t[305] = 963;
  36783. t[306] = 964;
  36784. t[307] = 966;
  36785. t[308] = 8215;
  36786. t[309] = 8252;
  36787. t[310] = 8319;
  36788. t[311] = 8359;
  36789. t[312] = 8592;
  36790. t[313] = 8593;
  36791. t[337] = 9552;
  36792. t[493] = 1039;
  36793. t[494] = 1040;
  36794. t[705] = 1524;
  36795. t[706] = 8362;
  36796. t[710] = 64288;
  36797. t[711] = 64298;
  36798. t[759] = 1617;
  36799. t[761] = 1776;
  36800. t[763] = 1778;
  36801. t[775] = 1652;
  36802. t[777] = 1764;
  36803. t[778] = 1780;
  36804. t[779] = 1781;
  36805. t[780] = 1782;
  36806. t[782] = 771;
  36807. t[783] = 64726;
  36808. t[786] = 8363;
  36809. t[788] = 8532;
  36810. t[790] = 768;
  36811. t[791] = 769;
  36812. t[792] = 768;
  36813. t[795] = 803;
  36814. t[797] = 64336;
  36815. t[798] = 64337;
  36816. t[799] = 64342;
  36817. t[800] = 64343;
  36818. t[801] = 64344;
  36819. t[802] = 64345;
  36820. t[803] = 64362;
  36821. t[804] = 64363;
  36822. t[805] = 64364;
  36823. t[2424] = 7821;
  36824. t[2425] = 7822;
  36825. t[2426] = 7823;
  36826. t[2427] = 7824;
  36827. t[2428] = 7825;
  36828. t[2429] = 7826;
  36829. t[2430] = 7827;
  36830. t[2433] = 7682;
  36831. t[2678] = 8045;
  36832. t[2679] = 8046;
  36833. t[2830] = 1552;
  36834. t[2838] = 686;
  36835. t[2840] = 751;
  36836. t[2842] = 753;
  36837. t[2843] = 754;
  36838. t[2844] = 755;
  36839. t[2846] = 757;
  36840. t[2856] = 767;
  36841. t[2857] = 848;
  36842. t[2858] = 849;
  36843. t[2862] = 853;
  36844. t[2863] = 854;
  36845. t[2864] = 855;
  36846. t[2865] = 861;
  36847. t[2866] = 862;
  36848. t[2906] = 7460;
  36849. t[2908] = 7462;
  36850. t[2909] = 7463;
  36851. t[2910] = 7464;
  36852. t[2912] = 7466;
  36853. t[2913] = 7467;
  36854. t[2914] = 7468;
  36855. t[2916] = 7470;
  36856. t[2917] = 7471;
  36857. t[2918] = 7472;
  36858. t[2920] = 7474;
  36859. t[2921] = 7475;
  36860. t[2922] = 7476;
  36861. t[2924] = 7478;
  36862. t[2925] = 7479;
  36863. t[2926] = 7480;
  36864. t[2928] = 7482;
  36865. t[2929] = 7483;
  36866. t[2930] = 7484;
  36867. t[2932] = 7486;
  36868. t[2933] = 7487;
  36869. t[2934] = 7488;
  36870. t[2936] = 7490;
  36871. t[2937] = 7491;
  36872. t[2938] = 7492;
  36873. t[2940] = 7494;
  36874. t[2941] = 7495;
  36875. t[2942] = 7496;
  36876. t[2944] = 7498;
  36877. t[2946] = 7500;
  36878. t[2948] = 7502;
  36879. t[2950] = 7504;
  36880. t[2951] = 7505;
  36881. t[2952] = 7506;
  36882. t[2954] = 7508;
  36883. t[2955] = 7509;
  36884. t[2956] = 7510;
  36885. t[2958] = 7512;
  36886. t[2959] = 7513;
  36887. t[2960] = 7514;
  36888. t[2962] = 7516;
  36889. t[2963] = 7517;
  36890. t[2964] = 7518;
  36891. t[2966] = 7520;
  36892. t[2967] = 7521;
  36893. t[2968] = 7522;
  36894. t[2970] = 7524;
  36895. t[2971] = 7525;
  36896. t[2972] = 7526;
  36897. t[2974] = 7528;
  36898. t[2975] = 7529;
  36899. t[2976] = 7530;
  36900. t[2978] = 1537;
  36901. t[2979] = 1538;
  36902. t[2980] = 1539;
  36903. t[2982] = 1549;
  36904. t[2983] = 1551;
  36905. t[2984] = 1552;
  36906. t[2986] = 1554;
  36907. t[2987] = 1555;
  36908. t[2988] = 1556;
  36909. t[2990] = 1623;
  36910. t[2991] = 1624;
  36911. t[2995] = 1775;
  36912. t[2999] = 1791;
  36913. t[3002] = 64290;
  36914. t[3003] = 64291;
  36915. t[3004] = 64292;
  36916. t[3006] = 64294;
  36917. t[3007] = 64295;
  36918. t[3008] = 64296;
  36919. t[3011] = 1900;
  36920. t[3014] = 8223;
  36921. t[3015] = 8244;
  36922. t[3017] = 7532;
  36923. t[3018] = 7533;
  36924. t[3019] = 7534;
  36925. t[3075] = 7590;
  36926. t[3076] = 7591;
  36927. t[3079] = 7594;
  36928. t[3080] = 7595;
  36929. t[3083] = 7598;
  36930. t[3084] = 7599;
  36931. t[3087] = 7602;
  36932. t[3088] = 7603;
  36933. t[3091] = 7606;
  36934. t[3092] = 7607;
  36935. t[3095] = 7610;
  36936. t[3096] = 7611;
  36937. t[3099] = 7614;
  36938. t[3100] = 7615;
  36939. t[3103] = 7618;
  36940. t[3104] = 7619;
  36941. t[3107] = 8337;
  36942. t[3108] = 8338;
  36943. t[3116] = 1884;
  36944. t[3119] = 1885;
  36945. t[3120] = 1885;
  36946. t[3123] = 1886;
  36947. t[3124] = 1886;
  36948. t[3127] = 1887;
  36949. t[3128] = 1887;
  36950. t[3131] = 1888;
  36951. t[3132] = 1888;
  36952. t[3135] = 1889;
  36953. t[3136] = 1889;
  36954. t[3139] = 1890;
  36955. t[3140] = 1890;
  36956. t[3143] = 1891;
  36957. t[3144] = 1891;
  36958. t[3147] = 1892;
  36959. t[3148] = 1892;
  36960. t[3153] = 580;
  36961. t[3154] = 581;
  36962. t[3157] = 584;
  36963. t[3158] = 585;
  36964. t[3161] = 588;
  36965. t[3162] = 589;
  36966. t[3165] = 891;
  36967. t[3166] = 892;
  36968. t[3169] = 1274;
  36969. t[3170] = 1275;
  36970. t[3173] = 1278;
  36971. t[3174] = 1279;
  36972. t[3181] = 7622;
  36973. t[3182] = 7623;
  36974. t[3282] = 11799;
  36975. t[3316] = 578;
  36976. t[3379] = 42785;
  36977. t[3393] = 1159;
  36978. t[3416] = 8377;
  36979. });
  36980. var getSupplementalGlyphMapForArialBlack = getLookupTableFactory(function (t) {
  36981. t[227] = 322;
  36982. t[264] = 261;
  36983. t[291] = 346;
  36984. });
  36985. exports.getStdFontMap = getStdFontMap;
  36986. exports.getNonStdFontMap = getNonStdFontMap;
  36987. exports.getSerifFonts = getSerifFonts;
  36988. exports.getSymbolsFonts = getSymbolsFonts;
  36989. exports.getGlyphMapForStandardFonts = getGlyphMapForStandardFonts;
  36990. exports.getSupplementalGlyphMapForArialBlack = getSupplementalGlyphMapForArialBlack;
  36991. /***/ }),
  36992. /* 22 */
  36993. /***/ (function(module, exports, __w_pdfjs_require__) {
  36994. "use strict";
  36995. var sharedUtil = __w_pdfjs_require__(0);
  36996. var getLookupTableFactory = sharedUtil.getLookupTableFactory;
  36997. var getSpecialPUASymbols = getLookupTableFactory(function (t) {
  36998. t[63721] = 0x00A9;
  36999. t[63193] = 0x00A9;
  37000. t[63720] = 0x00AE;
  37001. t[63194] = 0x00AE;
  37002. t[63722] = 0x2122;
  37003. t[63195] = 0x2122;
  37004. t[63729] = 0x23A7;
  37005. t[63730] = 0x23A8;
  37006. t[63731] = 0x23A9;
  37007. t[63740] = 0x23AB;
  37008. t[63741] = 0x23AC;
  37009. t[63742] = 0x23AD;
  37010. t[63726] = 0x23A1;
  37011. t[63727] = 0x23A2;
  37012. t[63728] = 0x23A3;
  37013. t[63737] = 0x23A4;
  37014. t[63738] = 0x23A5;
  37015. t[63739] = 0x23A6;
  37016. t[63723] = 0x239B;
  37017. t[63724] = 0x239C;
  37018. t[63725] = 0x239D;
  37019. t[63734] = 0x239E;
  37020. t[63735] = 0x239F;
  37021. t[63736] = 0x23A0;
  37022. });
  37023. function mapSpecialUnicodeValues(code) {
  37024. if (code >= 0xFFF0 && code <= 0xFFFF) {
  37025. return 0;
  37026. } else if (code >= 0xF600 && code <= 0xF8FF) {
  37027. return getSpecialPUASymbols()[code] || code;
  37028. }
  37029. return code;
  37030. }
  37031. function getUnicodeForGlyph(name, glyphsUnicodeMap) {
  37032. var unicode = glyphsUnicodeMap[name];
  37033. if (unicode !== undefined) {
  37034. return unicode;
  37035. }
  37036. if (!name) {
  37037. return -1;
  37038. }
  37039. if (name[0] === 'u') {
  37040. var nameLen = name.length, hexStr;
  37041. if (nameLen === 7 && name[1] === 'n' && name[2] === 'i') {
  37042. hexStr = name.substr(3);
  37043. } else if (nameLen >= 5 && nameLen <= 7) {
  37044. hexStr = name.substr(1);
  37045. } else {
  37046. return -1;
  37047. }
  37048. if (hexStr === hexStr.toUpperCase()) {
  37049. unicode = parseInt(hexStr, 16);
  37050. if (unicode >= 0) {
  37051. return unicode;
  37052. }
  37053. }
  37054. }
  37055. return -1;
  37056. }
  37057. var UnicodeRanges = [
  37058. {
  37059. 'begin': 0x0000,
  37060. 'end': 0x007F
  37061. },
  37062. {
  37063. 'begin': 0x0080,
  37064. 'end': 0x00FF
  37065. },
  37066. {
  37067. 'begin': 0x0100,
  37068. 'end': 0x017F
  37069. },
  37070. {
  37071. 'begin': 0x0180,
  37072. 'end': 0x024F
  37073. },
  37074. {
  37075. 'begin': 0x0250,
  37076. 'end': 0x02AF
  37077. },
  37078. {
  37079. 'begin': 0x02B0,
  37080. 'end': 0x02FF
  37081. },
  37082. {
  37083. 'begin': 0x0300,
  37084. 'end': 0x036F
  37085. },
  37086. {
  37087. 'begin': 0x0370,
  37088. 'end': 0x03FF
  37089. },
  37090. {
  37091. 'begin': 0x2C80,
  37092. 'end': 0x2CFF
  37093. },
  37094. {
  37095. 'begin': 0x0400,
  37096. 'end': 0x04FF
  37097. },
  37098. {
  37099. 'begin': 0x0530,
  37100. 'end': 0x058F
  37101. },
  37102. {
  37103. 'begin': 0x0590,
  37104. 'end': 0x05FF
  37105. },
  37106. {
  37107. 'begin': 0xA500,
  37108. 'end': 0xA63F
  37109. },
  37110. {
  37111. 'begin': 0x0600,
  37112. 'end': 0x06FF
  37113. },
  37114. {
  37115. 'begin': 0x07C0,
  37116. 'end': 0x07FF
  37117. },
  37118. {
  37119. 'begin': 0x0900,
  37120. 'end': 0x097F
  37121. },
  37122. {
  37123. 'begin': 0x0980,
  37124. 'end': 0x09FF
  37125. },
  37126. {
  37127. 'begin': 0x0A00,
  37128. 'end': 0x0A7F
  37129. },
  37130. {
  37131. 'begin': 0x0A80,
  37132. 'end': 0x0AFF
  37133. },
  37134. {
  37135. 'begin': 0x0B00,
  37136. 'end': 0x0B7F
  37137. },
  37138. {
  37139. 'begin': 0x0B80,
  37140. 'end': 0x0BFF
  37141. },
  37142. {
  37143. 'begin': 0x0C00,
  37144. 'end': 0x0C7F
  37145. },
  37146. {
  37147. 'begin': 0x0C80,
  37148. 'end': 0x0CFF
  37149. },
  37150. {
  37151. 'begin': 0x0D00,
  37152. 'end': 0x0D7F
  37153. },
  37154. {
  37155. 'begin': 0x0E00,
  37156. 'end': 0x0E7F
  37157. },
  37158. {
  37159. 'begin': 0x0E80,
  37160. 'end': 0x0EFF
  37161. },
  37162. {
  37163. 'begin': 0x10A0,
  37164. 'end': 0x10FF
  37165. },
  37166. {
  37167. 'begin': 0x1B00,
  37168. 'end': 0x1B7F
  37169. },
  37170. {
  37171. 'begin': 0x1100,
  37172. 'end': 0x11FF
  37173. },
  37174. {
  37175. 'begin': 0x1E00,
  37176. 'end': 0x1EFF
  37177. },
  37178. {
  37179. 'begin': 0x1F00,
  37180. 'end': 0x1FFF
  37181. },
  37182. {
  37183. 'begin': 0x2000,
  37184. 'end': 0x206F
  37185. },
  37186. {
  37187. 'begin': 0x2070,
  37188. 'end': 0x209F
  37189. },
  37190. {
  37191. 'begin': 0x20A0,
  37192. 'end': 0x20CF
  37193. },
  37194. {
  37195. 'begin': 0x20D0,
  37196. 'end': 0x20FF
  37197. },
  37198. {
  37199. 'begin': 0x2100,
  37200. 'end': 0x214F
  37201. },
  37202. {
  37203. 'begin': 0x2150,
  37204. 'end': 0x218F
  37205. },
  37206. {
  37207. 'begin': 0x2190,
  37208. 'end': 0x21FF
  37209. },
  37210. {
  37211. 'begin': 0x2200,
  37212. 'end': 0x22FF
  37213. },
  37214. {
  37215. 'begin': 0x2300,
  37216. 'end': 0x23FF
  37217. },
  37218. {
  37219. 'begin': 0x2400,
  37220. 'end': 0x243F
  37221. },
  37222. {
  37223. 'begin': 0x2440,
  37224. 'end': 0x245F
  37225. },
  37226. {
  37227. 'begin': 0x2460,
  37228. 'end': 0x24FF
  37229. },
  37230. {
  37231. 'begin': 0x2500,
  37232. 'end': 0x257F
  37233. },
  37234. {
  37235. 'begin': 0x2580,
  37236. 'end': 0x259F
  37237. },
  37238. {
  37239. 'begin': 0x25A0,
  37240. 'end': 0x25FF
  37241. },
  37242. {
  37243. 'begin': 0x2600,
  37244. 'end': 0x26FF
  37245. },
  37246. {
  37247. 'begin': 0x2700,
  37248. 'end': 0x27BF
  37249. },
  37250. {
  37251. 'begin': 0x3000,
  37252. 'end': 0x303F
  37253. },
  37254. {
  37255. 'begin': 0x3040,
  37256. 'end': 0x309F
  37257. },
  37258. {
  37259. 'begin': 0x30A0,
  37260. 'end': 0x30FF
  37261. },
  37262. {
  37263. 'begin': 0x3100,
  37264. 'end': 0x312F
  37265. },
  37266. {
  37267. 'begin': 0x3130,
  37268. 'end': 0x318F
  37269. },
  37270. {
  37271. 'begin': 0xA840,
  37272. 'end': 0xA87F
  37273. },
  37274. {
  37275. 'begin': 0x3200,
  37276. 'end': 0x32FF
  37277. },
  37278. {
  37279. 'begin': 0x3300,
  37280. 'end': 0x33FF
  37281. },
  37282. {
  37283. 'begin': 0xAC00,
  37284. 'end': 0xD7AF
  37285. },
  37286. {
  37287. 'begin': 0xD800,
  37288. 'end': 0xDFFF
  37289. },
  37290. {
  37291. 'begin': 0x10900,
  37292. 'end': 0x1091F
  37293. },
  37294. {
  37295. 'begin': 0x4E00,
  37296. 'end': 0x9FFF
  37297. },
  37298. {
  37299. 'begin': 0xE000,
  37300. 'end': 0xF8FF
  37301. },
  37302. {
  37303. 'begin': 0x31C0,
  37304. 'end': 0x31EF
  37305. },
  37306. {
  37307. 'begin': 0xFB00,
  37308. 'end': 0xFB4F
  37309. },
  37310. {
  37311. 'begin': 0xFB50,
  37312. 'end': 0xFDFF
  37313. },
  37314. {
  37315. 'begin': 0xFE20,
  37316. 'end': 0xFE2F
  37317. },
  37318. {
  37319. 'begin': 0xFE10,
  37320. 'end': 0xFE1F
  37321. },
  37322. {
  37323. 'begin': 0xFE50,
  37324. 'end': 0xFE6F
  37325. },
  37326. {
  37327. 'begin': 0xFE70,
  37328. 'end': 0xFEFF
  37329. },
  37330. {
  37331. 'begin': 0xFF00,
  37332. 'end': 0xFFEF
  37333. },
  37334. {
  37335. 'begin': 0xFFF0,
  37336. 'end': 0xFFFF
  37337. },
  37338. {
  37339. 'begin': 0x0F00,
  37340. 'end': 0x0FFF
  37341. },
  37342. {
  37343. 'begin': 0x0700,
  37344. 'end': 0x074F
  37345. },
  37346. {
  37347. 'begin': 0x0780,
  37348. 'end': 0x07BF
  37349. },
  37350. {
  37351. 'begin': 0x0D80,
  37352. 'end': 0x0DFF
  37353. },
  37354. {
  37355. 'begin': 0x1000,
  37356. 'end': 0x109F
  37357. },
  37358. {
  37359. 'begin': 0x1200,
  37360. 'end': 0x137F
  37361. },
  37362. {
  37363. 'begin': 0x13A0,
  37364. 'end': 0x13FF
  37365. },
  37366. {
  37367. 'begin': 0x1400,
  37368. 'end': 0x167F
  37369. },
  37370. {
  37371. 'begin': 0x1680,
  37372. 'end': 0x169F
  37373. },
  37374. {
  37375. 'begin': 0x16A0,
  37376. 'end': 0x16FF
  37377. },
  37378. {
  37379. 'begin': 0x1780,
  37380. 'end': 0x17FF
  37381. },
  37382. {
  37383. 'begin': 0x1800,
  37384. 'end': 0x18AF
  37385. },
  37386. {
  37387. 'begin': 0x2800,
  37388. 'end': 0x28FF
  37389. },
  37390. {
  37391. 'begin': 0xA000,
  37392. 'end': 0xA48F
  37393. },
  37394. {
  37395. 'begin': 0x1700,
  37396. 'end': 0x171F
  37397. },
  37398. {
  37399. 'begin': 0x10300,
  37400. 'end': 0x1032F
  37401. },
  37402. {
  37403. 'begin': 0x10330,
  37404. 'end': 0x1034F
  37405. },
  37406. {
  37407. 'begin': 0x10400,
  37408. 'end': 0x1044F
  37409. },
  37410. {
  37411. 'begin': 0x1D000,
  37412. 'end': 0x1D0FF
  37413. },
  37414. {
  37415. 'begin': 0x1D400,
  37416. 'end': 0x1D7FF
  37417. },
  37418. {
  37419. 'begin': 0xFF000,
  37420. 'end': 0xFFFFD
  37421. },
  37422. {
  37423. 'begin': 0xFE00,
  37424. 'end': 0xFE0F
  37425. },
  37426. {
  37427. 'begin': 0xE0000,
  37428. 'end': 0xE007F
  37429. },
  37430. {
  37431. 'begin': 0x1900,
  37432. 'end': 0x194F
  37433. },
  37434. {
  37435. 'begin': 0x1950,
  37436. 'end': 0x197F
  37437. },
  37438. {
  37439. 'begin': 0x1980,
  37440. 'end': 0x19DF
  37441. },
  37442. {
  37443. 'begin': 0x1A00,
  37444. 'end': 0x1A1F
  37445. },
  37446. {
  37447. 'begin': 0x2C00,
  37448. 'end': 0x2C5F
  37449. },
  37450. {
  37451. 'begin': 0x2D30,
  37452. 'end': 0x2D7F
  37453. },
  37454. {
  37455. 'begin': 0x4DC0,
  37456. 'end': 0x4DFF
  37457. },
  37458. {
  37459. 'begin': 0xA800,
  37460. 'end': 0xA82F
  37461. },
  37462. {
  37463. 'begin': 0x10000,
  37464. 'end': 0x1007F
  37465. },
  37466. {
  37467. 'begin': 0x10140,
  37468. 'end': 0x1018F
  37469. },
  37470. {
  37471. 'begin': 0x10380,
  37472. 'end': 0x1039F
  37473. },
  37474. {
  37475. 'begin': 0x103A0,
  37476. 'end': 0x103DF
  37477. },
  37478. {
  37479. 'begin': 0x10450,
  37480. 'end': 0x1047F
  37481. },
  37482. {
  37483. 'begin': 0x10480,
  37484. 'end': 0x104AF
  37485. },
  37486. {
  37487. 'begin': 0x10800,
  37488. 'end': 0x1083F
  37489. },
  37490. {
  37491. 'begin': 0x10A00,
  37492. 'end': 0x10A5F
  37493. },
  37494. {
  37495. 'begin': 0x1D300,
  37496. 'end': 0x1D35F
  37497. },
  37498. {
  37499. 'begin': 0x12000,
  37500. 'end': 0x123FF
  37501. },
  37502. {
  37503. 'begin': 0x1D360,
  37504. 'end': 0x1D37F
  37505. },
  37506. {
  37507. 'begin': 0x1B80,
  37508. 'end': 0x1BBF
  37509. },
  37510. {
  37511. 'begin': 0x1C00,
  37512. 'end': 0x1C4F
  37513. },
  37514. {
  37515. 'begin': 0x1C50,
  37516. 'end': 0x1C7F
  37517. },
  37518. {
  37519. 'begin': 0xA880,
  37520. 'end': 0xA8DF
  37521. },
  37522. {
  37523. 'begin': 0xA900,
  37524. 'end': 0xA92F
  37525. },
  37526. {
  37527. 'begin': 0xA930,
  37528. 'end': 0xA95F
  37529. },
  37530. {
  37531. 'begin': 0xAA00,
  37532. 'end': 0xAA5F
  37533. },
  37534. {
  37535. 'begin': 0x10190,
  37536. 'end': 0x101CF
  37537. },
  37538. {
  37539. 'begin': 0x101D0,
  37540. 'end': 0x101FF
  37541. },
  37542. {
  37543. 'begin': 0x102A0,
  37544. 'end': 0x102DF
  37545. },
  37546. {
  37547. 'begin': 0x1F030,
  37548. 'end': 0x1F09F
  37549. }
  37550. ];
  37551. function getUnicodeRangeFor(value) {
  37552. for (var i = 0, ii = UnicodeRanges.length; i < ii; i++) {
  37553. var range = UnicodeRanges[i];
  37554. if (value >= range.begin && value < range.end) {
  37555. return i;
  37556. }
  37557. }
  37558. return -1;
  37559. }
  37560. function isRTLRangeFor(value) {
  37561. var range = UnicodeRanges[13];
  37562. if (value >= range.begin && value < range.end) {
  37563. return true;
  37564. }
  37565. range = UnicodeRanges[11];
  37566. if (value >= range.begin && value < range.end) {
  37567. return true;
  37568. }
  37569. return false;
  37570. }
  37571. var getNormalizedUnicodes = getLookupTableFactory(function (t) {
  37572. t['\u00A8'] = '\u0020\u0308';
  37573. t['\u00AF'] = '\u0020\u0304';
  37574. t['\u00B4'] = '\u0020\u0301';
  37575. t['\u00B5'] = '\u03BC';
  37576. t['\u00B8'] = '\u0020\u0327';
  37577. t['\u0132'] = '\u0049\u004A';
  37578. t['\u0133'] = '\u0069\u006A';
  37579. t['\u013F'] = '\u004C\u00B7';
  37580. t['\u0140'] = '\u006C\u00B7';
  37581. t['\u0149'] = '\u02BC\u006E';
  37582. t['\u017F'] = '\u0073';
  37583. t['\u01C4'] = '\u0044\u017D';
  37584. t['\u01C5'] = '\u0044\u017E';
  37585. t['\u01C6'] = '\u0064\u017E';
  37586. t['\u01C7'] = '\u004C\u004A';
  37587. t['\u01C8'] = '\u004C\u006A';
  37588. t['\u01C9'] = '\u006C\u006A';
  37589. t['\u01CA'] = '\u004E\u004A';
  37590. t['\u01CB'] = '\u004E\u006A';
  37591. t['\u01CC'] = '\u006E\u006A';
  37592. t['\u01F1'] = '\u0044\u005A';
  37593. t['\u01F2'] = '\u0044\u007A';
  37594. t['\u01F3'] = '\u0064\u007A';
  37595. t['\u02D8'] = '\u0020\u0306';
  37596. t['\u02D9'] = '\u0020\u0307';
  37597. t['\u02DA'] = '\u0020\u030A';
  37598. t['\u02DB'] = '\u0020\u0328';
  37599. t['\u02DC'] = '\u0020\u0303';
  37600. t['\u02DD'] = '\u0020\u030B';
  37601. t['\u037A'] = '\u0020\u0345';
  37602. t['\u0384'] = '\u0020\u0301';
  37603. t['\u03D0'] = '\u03B2';
  37604. t['\u03D1'] = '\u03B8';
  37605. t['\u03D2'] = '\u03A5';
  37606. t['\u03D5'] = '\u03C6';
  37607. t['\u03D6'] = '\u03C0';
  37608. t['\u03F0'] = '\u03BA';
  37609. t['\u03F1'] = '\u03C1';
  37610. t['\u03F2'] = '\u03C2';
  37611. t['\u03F4'] = '\u0398';
  37612. t['\u03F5'] = '\u03B5';
  37613. t['\u03F9'] = '\u03A3';
  37614. t['\u0587'] = '\u0565\u0582';
  37615. t['\u0675'] = '\u0627\u0674';
  37616. t['\u0676'] = '\u0648\u0674';
  37617. t['\u0677'] = '\u06C7\u0674';
  37618. t['\u0678'] = '\u064A\u0674';
  37619. t['\u0E33'] = '\u0E4D\u0E32';
  37620. t['\u0EB3'] = '\u0ECD\u0EB2';
  37621. t['\u0EDC'] = '\u0EAB\u0E99';
  37622. t['\u0EDD'] = '\u0EAB\u0EA1';
  37623. t['\u0F77'] = '\u0FB2\u0F81';
  37624. t['\u0F79'] = '\u0FB3\u0F81';
  37625. t['\u1E9A'] = '\u0061\u02BE';
  37626. t['\u1FBD'] = '\u0020\u0313';
  37627. t['\u1FBF'] = '\u0020\u0313';
  37628. t['\u1FC0'] = '\u0020\u0342';
  37629. t['\u1FFE'] = '\u0020\u0314';
  37630. t['\u2002'] = '\u0020';
  37631. t['\u2003'] = '\u0020';
  37632. t['\u2004'] = '\u0020';
  37633. t['\u2005'] = '\u0020';
  37634. t['\u2006'] = '\u0020';
  37635. t['\u2008'] = '\u0020';
  37636. t['\u2009'] = '\u0020';
  37637. t['\u200A'] = '\u0020';
  37638. t['\u2017'] = '\u0020\u0333';
  37639. t['\u2024'] = '\u002E';
  37640. t['\u2025'] = '\u002E\u002E';
  37641. t['\u2026'] = '\u002E\u002E\u002E';
  37642. t['\u2033'] = '\u2032\u2032';
  37643. t['\u2034'] = '\u2032\u2032\u2032';
  37644. t['\u2036'] = '\u2035\u2035';
  37645. t['\u2037'] = '\u2035\u2035\u2035';
  37646. t['\u203C'] = '\u0021\u0021';
  37647. t['\u203E'] = '\u0020\u0305';
  37648. t['\u2047'] = '\u003F\u003F';
  37649. t['\u2048'] = '\u003F\u0021';
  37650. t['\u2049'] = '\u0021\u003F';
  37651. t['\u2057'] = '\u2032\u2032\u2032\u2032';
  37652. t['\u205F'] = '\u0020';
  37653. t['\u20A8'] = '\u0052\u0073';
  37654. t['\u2100'] = '\u0061\u002F\u0063';
  37655. t['\u2101'] = '\u0061\u002F\u0073';
  37656. t['\u2103'] = '\u00B0\u0043';
  37657. t['\u2105'] = '\u0063\u002F\u006F';
  37658. t['\u2106'] = '\u0063\u002F\u0075';
  37659. t['\u2107'] = '\u0190';
  37660. t['\u2109'] = '\u00B0\u0046';
  37661. t['\u2116'] = '\u004E\u006F';
  37662. t['\u2121'] = '\u0054\u0045\u004C';
  37663. t['\u2135'] = '\u05D0';
  37664. t['\u2136'] = '\u05D1';
  37665. t['\u2137'] = '\u05D2';
  37666. t['\u2138'] = '\u05D3';
  37667. t['\u213B'] = '\u0046\u0041\u0058';
  37668. t['\u2160'] = '\u0049';
  37669. t['\u2161'] = '\u0049\u0049';
  37670. t['\u2162'] = '\u0049\u0049\u0049';
  37671. t['\u2163'] = '\u0049\u0056';
  37672. t['\u2164'] = '\u0056';
  37673. t['\u2165'] = '\u0056\u0049';
  37674. t['\u2166'] = '\u0056\u0049\u0049';
  37675. t['\u2167'] = '\u0056\u0049\u0049\u0049';
  37676. t['\u2168'] = '\u0049\u0058';
  37677. t['\u2169'] = '\u0058';
  37678. t['\u216A'] = '\u0058\u0049';
  37679. t['\u216B'] = '\u0058\u0049\u0049';
  37680. t['\u216C'] = '\u004C';
  37681. t['\u216D'] = '\u0043';
  37682. t['\u216E'] = '\u0044';
  37683. t['\u216F'] = '\u004D';
  37684. t['\u2170'] = '\u0069';
  37685. t['\u2171'] = '\u0069\u0069';
  37686. t['\u2172'] = '\u0069\u0069\u0069';
  37687. t['\u2173'] = '\u0069\u0076';
  37688. t['\u2174'] = '\u0076';
  37689. t['\u2175'] = '\u0076\u0069';
  37690. t['\u2176'] = '\u0076\u0069\u0069';
  37691. t['\u2177'] = '\u0076\u0069\u0069\u0069';
  37692. t['\u2178'] = '\u0069\u0078';
  37693. t['\u2179'] = '\u0078';
  37694. t['\u217A'] = '\u0078\u0069';
  37695. t['\u217B'] = '\u0078\u0069\u0069';
  37696. t['\u217C'] = '\u006C';
  37697. t['\u217D'] = '\u0063';
  37698. t['\u217E'] = '\u0064';
  37699. t['\u217F'] = '\u006D';
  37700. t['\u222C'] = '\u222B\u222B';
  37701. t['\u222D'] = '\u222B\u222B\u222B';
  37702. t['\u222F'] = '\u222E\u222E';
  37703. t['\u2230'] = '\u222E\u222E\u222E';
  37704. t['\u2474'] = '\u0028\u0031\u0029';
  37705. t['\u2475'] = '\u0028\u0032\u0029';
  37706. t['\u2476'] = '\u0028\u0033\u0029';
  37707. t['\u2477'] = '\u0028\u0034\u0029';
  37708. t['\u2478'] = '\u0028\u0035\u0029';
  37709. t['\u2479'] = '\u0028\u0036\u0029';
  37710. t['\u247A'] = '\u0028\u0037\u0029';
  37711. t['\u247B'] = '\u0028\u0038\u0029';
  37712. t['\u247C'] = '\u0028\u0039\u0029';
  37713. t['\u247D'] = '\u0028\u0031\u0030\u0029';
  37714. t['\u247E'] = '\u0028\u0031\u0031\u0029';
  37715. t['\u247F'] = '\u0028\u0031\u0032\u0029';
  37716. t['\u2480'] = '\u0028\u0031\u0033\u0029';
  37717. t['\u2481'] = '\u0028\u0031\u0034\u0029';
  37718. t['\u2482'] = '\u0028\u0031\u0035\u0029';
  37719. t['\u2483'] = '\u0028\u0031\u0036\u0029';
  37720. t['\u2484'] = '\u0028\u0031\u0037\u0029';
  37721. t['\u2485'] = '\u0028\u0031\u0038\u0029';
  37722. t['\u2486'] = '\u0028\u0031\u0039\u0029';
  37723. t['\u2487'] = '\u0028\u0032\u0030\u0029';
  37724. t['\u2488'] = '\u0031\u002E';
  37725. t['\u2489'] = '\u0032\u002E';
  37726. t['\u248A'] = '\u0033\u002E';
  37727. t['\u248B'] = '\u0034\u002E';
  37728. t['\u248C'] = '\u0035\u002E';
  37729. t['\u248D'] = '\u0036\u002E';
  37730. t['\u248E'] = '\u0037\u002E';
  37731. t['\u248F'] = '\u0038\u002E';
  37732. t['\u2490'] = '\u0039\u002E';
  37733. t['\u2491'] = '\u0031\u0030\u002E';
  37734. t['\u2492'] = '\u0031\u0031\u002E';
  37735. t['\u2493'] = '\u0031\u0032\u002E';
  37736. t['\u2494'] = '\u0031\u0033\u002E';
  37737. t['\u2495'] = '\u0031\u0034\u002E';
  37738. t['\u2496'] = '\u0031\u0035\u002E';
  37739. t['\u2497'] = '\u0031\u0036\u002E';
  37740. t['\u2498'] = '\u0031\u0037\u002E';
  37741. t['\u2499'] = '\u0031\u0038\u002E';
  37742. t['\u249A'] = '\u0031\u0039\u002E';
  37743. t['\u249B'] = '\u0032\u0030\u002E';
  37744. t['\u249C'] = '\u0028\u0061\u0029';
  37745. t['\u249D'] = '\u0028\u0062\u0029';
  37746. t['\u249E'] = '\u0028\u0063\u0029';
  37747. t['\u249F'] = '\u0028\u0064\u0029';
  37748. t['\u24A0'] = '\u0028\u0065\u0029';
  37749. t['\u24A1'] = '\u0028\u0066\u0029';
  37750. t['\u24A2'] = '\u0028\u0067\u0029';
  37751. t['\u24A3'] = '\u0028\u0068\u0029';
  37752. t['\u24A4'] = '\u0028\u0069\u0029';
  37753. t['\u24A5'] = '\u0028\u006A\u0029';
  37754. t['\u24A6'] = '\u0028\u006B\u0029';
  37755. t['\u24A7'] = '\u0028\u006C\u0029';
  37756. t['\u24A8'] = '\u0028\u006D\u0029';
  37757. t['\u24A9'] = '\u0028\u006E\u0029';
  37758. t['\u24AA'] = '\u0028\u006F\u0029';
  37759. t['\u24AB'] = '\u0028\u0070\u0029';
  37760. t['\u24AC'] = '\u0028\u0071\u0029';
  37761. t['\u24AD'] = '\u0028\u0072\u0029';
  37762. t['\u24AE'] = '\u0028\u0073\u0029';
  37763. t['\u24AF'] = '\u0028\u0074\u0029';
  37764. t['\u24B0'] = '\u0028\u0075\u0029';
  37765. t['\u24B1'] = '\u0028\u0076\u0029';
  37766. t['\u24B2'] = '\u0028\u0077\u0029';
  37767. t['\u24B3'] = '\u0028\u0078\u0029';
  37768. t['\u24B4'] = '\u0028\u0079\u0029';
  37769. t['\u24B5'] = '\u0028\u007A\u0029';
  37770. t['\u2A0C'] = '\u222B\u222B\u222B\u222B';
  37771. t['\u2A74'] = '\u003A\u003A\u003D';
  37772. t['\u2A75'] = '\u003D\u003D';
  37773. t['\u2A76'] = '\u003D\u003D\u003D';
  37774. t['\u2E9F'] = '\u6BCD';
  37775. t['\u2EF3'] = '\u9F9F';
  37776. t['\u2F00'] = '\u4E00';
  37777. t['\u2F01'] = '\u4E28';
  37778. t['\u2F02'] = '\u4E36';
  37779. t['\u2F03'] = '\u4E3F';
  37780. t['\u2F04'] = '\u4E59';
  37781. t['\u2F05'] = '\u4E85';
  37782. t['\u2F06'] = '\u4E8C';
  37783. t['\u2F07'] = '\u4EA0';
  37784. t['\u2F08'] = '\u4EBA';
  37785. t['\u2F09'] = '\u513F';
  37786. t['\u2F0A'] = '\u5165';
  37787. t['\u2F0B'] = '\u516B';
  37788. t['\u2F0C'] = '\u5182';
  37789. t['\u2F0D'] = '\u5196';
  37790. t['\u2F0E'] = '\u51AB';
  37791. t['\u2F0F'] = '\u51E0';
  37792. t['\u2F10'] = '\u51F5';
  37793. t['\u2F11'] = '\u5200';
  37794. t['\u2F12'] = '\u529B';
  37795. t['\u2F13'] = '\u52F9';
  37796. t['\u2F14'] = '\u5315';
  37797. t['\u2F15'] = '\u531A';
  37798. t['\u2F16'] = '\u5338';
  37799. t['\u2F17'] = '\u5341';
  37800. t['\u2F18'] = '\u535C';
  37801. t['\u2F19'] = '\u5369';
  37802. t['\u2F1A'] = '\u5382';
  37803. t['\u2F1B'] = '\u53B6';
  37804. t['\u2F1C'] = '\u53C8';
  37805. t['\u2F1D'] = '\u53E3';
  37806. t['\u2F1E'] = '\u56D7';
  37807. t['\u2F1F'] = '\u571F';
  37808. t['\u2F20'] = '\u58EB';
  37809. t['\u2F21'] = '\u5902';
  37810. t['\u2F22'] = '\u590A';
  37811. t['\u2F23'] = '\u5915';
  37812. t['\u2F24'] = '\u5927';
  37813. t['\u2F25'] = '\u5973';
  37814. t['\u2F26'] = '\u5B50';
  37815. t['\u2F27'] = '\u5B80';
  37816. t['\u2F28'] = '\u5BF8';
  37817. t['\u2F29'] = '\u5C0F';
  37818. t['\u2F2A'] = '\u5C22';
  37819. t['\u2F2B'] = '\u5C38';
  37820. t['\u2F2C'] = '\u5C6E';
  37821. t['\u2F2D'] = '\u5C71';
  37822. t['\u2F2E'] = '\u5DDB';
  37823. t['\u2F2F'] = '\u5DE5';
  37824. t['\u2F30'] = '\u5DF1';
  37825. t['\u2F31'] = '\u5DFE';
  37826. t['\u2F32'] = '\u5E72';
  37827. t['\u2F33'] = '\u5E7A';
  37828. t['\u2F34'] = '\u5E7F';
  37829. t['\u2F35'] = '\u5EF4';
  37830. t['\u2F36'] = '\u5EFE';
  37831. t['\u2F37'] = '\u5F0B';
  37832. t['\u2F38'] = '\u5F13';
  37833. t['\u2F39'] = '\u5F50';
  37834. t['\u2F3A'] = '\u5F61';
  37835. t['\u2F3B'] = '\u5F73';
  37836. t['\u2F3C'] = '\u5FC3';
  37837. t['\u2F3D'] = '\u6208';
  37838. t['\u2F3E'] = '\u6236';
  37839. t['\u2F3F'] = '\u624B';
  37840. t['\u2F40'] = '\u652F';
  37841. t['\u2F41'] = '\u6534';
  37842. t['\u2F42'] = '\u6587';
  37843. t['\u2F43'] = '\u6597';
  37844. t['\u2F44'] = '\u65A4';
  37845. t['\u2F45'] = '\u65B9';
  37846. t['\u2F46'] = '\u65E0';
  37847. t['\u2F47'] = '\u65E5';
  37848. t['\u2F48'] = '\u66F0';
  37849. t['\u2F49'] = '\u6708';
  37850. t['\u2F4A'] = '\u6728';
  37851. t['\u2F4B'] = '\u6B20';
  37852. t['\u2F4C'] = '\u6B62';
  37853. t['\u2F4D'] = '\u6B79';
  37854. t['\u2F4E'] = '\u6BB3';
  37855. t['\u2F4F'] = '\u6BCB';
  37856. t['\u2F50'] = '\u6BD4';
  37857. t['\u2F51'] = '\u6BDB';
  37858. t['\u2F52'] = '\u6C0F';
  37859. t['\u2F53'] = '\u6C14';
  37860. t['\u2F54'] = '\u6C34';
  37861. t['\u2F55'] = '\u706B';
  37862. t['\u2F56'] = '\u722A';
  37863. t['\u2F57'] = '\u7236';
  37864. t['\u2F58'] = '\u723B';
  37865. t['\u2F59'] = '\u723F';
  37866. t['\u2F5A'] = '\u7247';
  37867. t['\u2F5B'] = '\u7259';
  37868. t['\u2F5C'] = '\u725B';
  37869. t['\u2F5D'] = '\u72AC';
  37870. t['\u2F5E'] = '\u7384';
  37871. t['\u2F5F'] = '\u7389';
  37872. t['\u2F60'] = '\u74DC';
  37873. t['\u2F61'] = '\u74E6';
  37874. t['\u2F62'] = '\u7518';
  37875. t['\u2F63'] = '\u751F';
  37876. t['\u2F64'] = '\u7528';
  37877. t['\u2F65'] = '\u7530';
  37878. t['\u2F66'] = '\u758B';
  37879. t['\u2F67'] = '\u7592';
  37880. t['\u2F68'] = '\u7676';
  37881. t['\u2F69'] = '\u767D';
  37882. t['\u2F6A'] = '\u76AE';
  37883. t['\u2F6B'] = '\u76BF';
  37884. t['\u2F6C'] = '\u76EE';
  37885. t['\u2F6D'] = '\u77DB';
  37886. t['\u2F6E'] = '\u77E2';
  37887. t['\u2F6F'] = '\u77F3';
  37888. t['\u2F70'] = '\u793A';
  37889. t['\u2F71'] = '\u79B8';
  37890. t['\u2F72'] = '\u79BE';
  37891. t['\u2F73'] = '\u7A74';
  37892. t['\u2F74'] = '\u7ACB';
  37893. t['\u2F75'] = '\u7AF9';
  37894. t['\u2F76'] = '\u7C73';
  37895. t['\u2F77'] = '\u7CF8';
  37896. t['\u2F78'] = '\u7F36';
  37897. t['\u2F79'] = '\u7F51';
  37898. t['\u2F7A'] = '\u7F8A';
  37899. t['\u2F7B'] = '\u7FBD';
  37900. t['\u2F7C'] = '\u8001';
  37901. t['\u2F7D'] = '\u800C';
  37902. t['\u2F7E'] = '\u8012';
  37903. t['\u2F7F'] = '\u8033';
  37904. t['\u2F80'] = '\u807F';
  37905. t['\u2F81'] = '\u8089';
  37906. t['\u2F82'] = '\u81E3';
  37907. t['\u2F83'] = '\u81EA';
  37908. t['\u2F84'] = '\u81F3';
  37909. t['\u2F85'] = '\u81FC';
  37910. t['\u2F86'] = '\u820C';
  37911. t['\u2F87'] = '\u821B';
  37912. t['\u2F88'] = '\u821F';
  37913. t['\u2F89'] = '\u826E';
  37914. t['\u2F8A'] = '\u8272';
  37915. t['\u2F8B'] = '\u8278';
  37916. t['\u2F8C'] = '\u864D';
  37917. t['\u2F8D'] = '\u866B';
  37918. t['\u2F8E'] = '\u8840';
  37919. t['\u2F8F'] = '\u884C';
  37920. t['\u2F90'] = '\u8863';
  37921. t['\u2F91'] = '\u897E';
  37922. t['\u2F92'] = '\u898B';
  37923. t['\u2F93'] = '\u89D2';
  37924. t['\u2F94'] = '\u8A00';
  37925. t['\u2F95'] = '\u8C37';
  37926. t['\u2F96'] = '\u8C46';
  37927. t['\u2F97'] = '\u8C55';
  37928. t['\u2F98'] = '\u8C78';
  37929. t['\u2F99'] = '\u8C9D';
  37930. t['\u2F9A'] = '\u8D64';
  37931. t['\u2F9B'] = '\u8D70';
  37932. t['\u2F9C'] = '\u8DB3';
  37933. t['\u2F9D'] = '\u8EAB';
  37934. t['\u2F9E'] = '\u8ECA';
  37935. t['\u2F9F'] = '\u8F9B';
  37936. t['\u2FA0'] = '\u8FB0';
  37937. t['\u2FA1'] = '\u8FB5';
  37938. t['\u2FA2'] = '\u9091';
  37939. t['\u2FA3'] = '\u9149';
  37940. t['\u2FA4'] = '\u91C6';
  37941. t['\u2FA5'] = '\u91CC';
  37942. t['\u2FA6'] = '\u91D1';
  37943. t['\u2FA7'] = '\u9577';
  37944. t['\u2FA8'] = '\u9580';
  37945. t['\u2FA9'] = '\u961C';
  37946. t['\u2FAA'] = '\u96B6';
  37947. t['\u2FAB'] = '\u96B9';
  37948. t['\u2FAC'] = '\u96E8';
  37949. t['\u2FAD'] = '\u9751';
  37950. t['\u2FAE'] = '\u975E';
  37951. t['\u2FAF'] = '\u9762';
  37952. t['\u2FB0'] = '\u9769';
  37953. t['\u2FB1'] = '\u97CB';
  37954. t['\u2FB2'] = '\u97ED';
  37955. t['\u2FB3'] = '\u97F3';
  37956. t['\u2FB4'] = '\u9801';
  37957. t['\u2FB5'] = '\u98A8';
  37958. t['\u2FB6'] = '\u98DB';
  37959. t['\u2FB7'] = '\u98DF';
  37960. t['\u2FB8'] = '\u9996';
  37961. t['\u2FB9'] = '\u9999';
  37962. t['\u2FBA'] = '\u99AC';
  37963. t['\u2FBB'] = '\u9AA8';
  37964. t['\u2FBC'] = '\u9AD8';
  37965. t['\u2FBD'] = '\u9ADF';
  37966. t['\u2FBE'] = '\u9B25';
  37967. t['\u2FBF'] = '\u9B2F';
  37968. t['\u2FC0'] = '\u9B32';
  37969. t['\u2FC1'] = '\u9B3C';
  37970. t['\u2FC2'] = '\u9B5A';
  37971. t['\u2FC3'] = '\u9CE5';
  37972. t['\u2FC4'] = '\u9E75';
  37973. t['\u2FC5'] = '\u9E7F';
  37974. t['\u2FC6'] = '\u9EA5';
  37975. t['\u2FC7'] = '\u9EBB';
  37976. t['\u2FC8'] = '\u9EC3';
  37977. t['\u2FC9'] = '\u9ECD';
  37978. t['\u2FCA'] = '\u9ED1';
  37979. t['\u2FCB'] = '\u9EF9';
  37980. t['\u2FCC'] = '\u9EFD';
  37981. t['\u2FCD'] = '\u9F0E';
  37982. t['\u2FCE'] = '\u9F13';
  37983. t['\u2FCF'] = '\u9F20';
  37984. t['\u2FD0'] = '\u9F3B';
  37985. t['\u2FD1'] = '\u9F4A';
  37986. t['\u2FD2'] = '\u9F52';
  37987. t['\u2FD3'] = '\u9F8D';
  37988. t['\u2FD4'] = '\u9F9C';
  37989. t['\u2FD5'] = '\u9FA0';
  37990. t['\u3036'] = '\u3012';
  37991. t['\u3038'] = '\u5341';
  37992. t['\u3039'] = '\u5344';
  37993. t['\u303A'] = '\u5345';
  37994. t['\u309B'] = '\u0020\u3099';
  37995. t['\u309C'] = '\u0020\u309A';
  37996. t['\u3131'] = '\u1100';
  37997. t['\u3132'] = '\u1101';
  37998. t['\u3133'] = '\u11AA';
  37999. t['\u3134'] = '\u1102';
  38000. t['\u3135'] = '\u11AC';
  38001. t['\u3136'] = '\u11AD';
  38002. t['\u3137'] = '\u1103';
  38003. t['\u3138'] = '\u1104';
  38004. t['\u3139'] = '\u1105';
  38005. t['\u313A'] = '\u11B0';
  38006. t['\u313B'] = '\u11B1';
  38007. t['\u313C'] = '\u11B2';
  38008. t['\u313D'] = '\u11B3';
  38009. t['\u313E'] = '\u11B4';
  38010. t['\u313F'] = '\u11B5';
  38011. t['\u3140'] = '\u111A';
  38012. t['\u3141'] = '\u1106';
  38013. t['\u3142'] = '\u1107';
  38014. t['\u3143'] = '\u1108';
  38015. t['\u3144'] = '\u1121';
  38016. t['\u3145'] = '\u1109';
  38017. t['\u3146'] = '\u110A';
  38018. t['\u3147'] = '\u110B';
  38019. t['\u3148'] = '\u110C';
  38020. t['\u3149'] = '\u110D';
  38021. t['\u314A'] = '\u110E';
  38022. t['\u314B'] = '\u110F';
  38023. t['\u314C'] = '\u1110';
  38024. t['\u314D'] = '\u1111';
  38025. t['\u314E'] = '\u1112';
  38026. t['\u314F'] = '\u1161';
  38027. t['\u3150'] = '\u1162';
  38028. t['\u3151'] = '\u1163';
  38029. t['\u3152'] = '\u1164';
  38030. t['\u3153'] = '\u1165';
  38031. t['\u3154'] = '\u1166';
  38032. t['\u3155'] = '\u1167';
  38033. t['\u3156'] = '\u1168';
  38034. t['\u3157'] = '\u1169';
  38035. t['\u3158'] = '\u116A';
  38036. t['\u3159'] = '\u116B';
  38037. t['\u315A'] = '\u116C';
  38038. t['\u315B'] = '\u116D';
  38039. t['\u315C'] = '\u116E';
  38040. t['\u315D'] = '\u116F';
  38041. t['\u315E'] = '\u1170';
  38042. t['\u315F'] = '\u1171';
  38043. t['\u3160'] = '\u1172';
  38044. t['\u3161'] = '\u1173';
  38045. t['\u3162'] = '\u1174';
  38046. t['\u3163'] = '\u1175';
  38047. t['\u3164'] = '\u1160';
  38048. t['\u3165'] = '\u1114';
  38049. t['\u3166'] = '\u1115';
  38050. t['\u3167'] = '\u11C7';
  38051. t['\u3168'] = '\u11C8';
  38052. t['\u3169'] = '\u11CC';
  38053. t['\u316A'] = '\u11CE';
  38054. t['\u316B'] = '\u11D3';
  38055. t['\u316C'] = '\u11D7';
  38056. t['\u316D'] = '\u11D9';
  38057. t['\u316E'] = '\u111C';
  38058. t['\u316F'] = '\u11DD';
  38059. t['\u3170'] = '\u11DF';
  38060. t['\u3171'] = '\u111D';
  38061. t['\u3172'] = '\u111E';
  38062. t['\u3173'] = '\u1120';
  38063. t['\u3174'] = '\u1122';
  38064. t['\u3175'] = '\u1123';
  38065. t['\u3176'] = '\u1127';
  38066. t['\u3177'] = '\u1129';
  38067. t['\u3178'] = '\u112B';
  38068. t['\u3179'] = '\u112C';
  38069. t['\u317A'] = '\u112D';
  38070. t['\u317B'] = '\u112E';
  38071. t['\u317C'] = '\u112F';
  38072. t['\u317D'] = '\u1132';
  38073. t['\u317E'] = '\u1136';
  38074. t['\u317F'] = '\u1140';
  38075. t['\u3180'] = '\u1147';
  38076. t['\u3181'] = '\u114C';
  38077. t['\u3182'] = '\u11F1';
  38078. t['\u3183'] = '\u11F2';
  38079. t['\u3184'] = '\u1157';
  38080. t['\u3185'] = '\u1158';
  38081. t['\u3186'] = '\u1159';
  38082. t['\u3187'] = '\u1184';
  38083. t['\u3188'] = '\u1185';
  38084. t['\u3189'] = '\u1188';
  38085. t['\u318A'] = '\u1191';
  38086. t['\u318B'] = '\u1192';
  38087. t['\u318C'] = '\u1194';
  38088. t['\u318D'] = '\u119E';
  38089. t['\u318E'] = '\u11A1';
  38090. t['\u3200'] = '\u0028\u1100\u0029';
  38091. t['\u3201'] = '\u0028\u1102\u0029';
  38092. t['\u3202'] = '\u0028\u1103\u0029';
  38093. t['\u3203'] = '\u0028\u1105\u0029';
  38094. t['\u3204'] = '\u0028\u1106\u0029';
  38095. t['\u3205'] = '\u0028\u1107\u0029';
  38096. t['\u3206'] = '\u0028\u1109\u0029';
  38097. t['\u3207'] = '\u0028\u110B\u0029';
  38098. t['\u3208'] = '\u0028\u110C\u0029';
  38099. t['\u3209'] = '\u0028\u110E\u0029';
  38100. t['\u320A'] = '\u0028\u110F\u0029';
  38101. t['\u320B'] = '\u0028\u1110\u0029';
  38102. t['\u320C'] = '\u0028\u1111\u0029';
  38103. t['\u320D'] = '\u0028\u1112\u0029';
  38104. t['\u320E'] = '\u0028\u1100\u1161\u0029';
  38105. t['\u320F'] = '\u0028\u1102\u1161\u0029';
  38106. t['\u3210'] = '\u0028\u1103\u1161\u0029';
  38107. t['\u3211'] = '\u0028\u1105\u1161\u0029';
  38108. t['\u3212'] = '\u0028\u1106\u1161\u0029';
  38109. t['\u3213'] = '\u0028\u1107\u1161\u0029';
  38110. t['\u3214'] = '\u0028\u1109\u1161\u0029';
  38111. t['\u3215'] = '\u0028\u110B\u1161\u0029';
  38112. t['\u3216'] = '\u0028\u110C\u1161\u0029';
  38113. t['\u3217'] = '\u0028\u110E\u1161\u0029';
  38114. t['\u3218'] = '\u0028\u110F\u1161\u0029';
  38115. t['\u3219'] = '\u0028\u1110\u1161\u0029';
  38116. t['\u321A'] = '\u0028\u1111\u1161\u0029';
  38117. t['\u321B'] = '\u0028\u1112\u1161\u0029';
  38118. t['\u321C'] = '\u0028\u110C\u116E\u0029';
  38119. t['\u321D'] = '\u0028\u110B\u1169\u110C\u1165\u11AB\u0029';
  38120. t['\u321E'] = '\u0028\u110B\u1169\u1112\u116E\u0029';
  38121. t['\u3220'] = '\u0028\u4E00\u0029';
  38122. t['\u3221'] = '\u0028\u4E8C\u0029';
  38123. t['\u3222'] = '\u0028\u4E09\u0029';
  38124. t['\u3223'] = '\u0028\u56DB\u0029';
  38125. t['\u3224'] = '\u0028\u4E94\u0029';
  38126. t['\u3225'] = '\u0028\u516D\u0029';
  38127. t['\u3226'] = '\u0028\u4E03\u0029';
  38128. t['\u3227'] = '\u0028\u516B\u0029';
  38129. t['\u3228'] = '\u0028\u4E5D\u0029';
  38130. t['\u3229'] = '\u0028\u5341\u0029';
  38131. t['\u322A'] = '\u0028\u6708\u0029';
  38132. t['\u322B'] = '\u0028\u706B\u0029';
  38133. t['\u322C'] = '\u0028\u6C34\u0029';
  38134. t['\u322D'] = '\u0028\u6728\u0029';
  38135. t['\u322E'] = '\u0028\u91D1\u0029';
  38136. t['\u322F'] = '\u0028\u571F\u0029';
  38137. t['\u3230'] = '\u0028\u65E5\u0029';
  38138. t['\u3231'] = '\u0028\u682A\u0029';
  38139. t['\u3232'] = '\u0028\u6709\u0029';
  38140. t['\u3233'] = '\u0028\u793E\u0029';
  38141. t['\u3234'] = '\u0028\u540D\u0029';
  38142. t['\u3235'] = '\u0028\u7279\u0029';
  38143. t['\u3236'] = '\u0028\u8CA1\u0029';
  38144. t['\u3237'] = '\u0028\u795D\u0029';
  38145. t['\u3238'] = '\u0028\u52B4\u0029';
  38146. t['\u3239'] = '\u0028\u4EE3\u0029';
  38147. t['\u323A'] = '\u0028\u547C\u0029';
  38148. t['\u323B'] = '\u0028\u5B66\u0029';
  38149. t['\u323C'] = '\u0028\u76E3\u0029';
  38150. t['\u323D'] = '\u0028\u4F01\u0029';
  38151. t['\u323E'] = '\u0028\u8CC7\u0029';
  38152. t['\u323F'] = '\u0028\u5354\u0029';
  38153. t['\u3240'] = '\u0028\u796D\u0029';
  38154. t['\u3241'] = '\u0028\u4F11\u0029';
  38155. t['\u3242'] = '\u0028\u81EA\u0029';
  38156. t['\u3243'] = '\u0028\u81F3\u0029';
  38157. t['\u32C0'] = '\u0031\u6708';
  38158. t['\u32C1'] = '\u0032\u6708';
  38159. t['\u32C2'] = '\u0033\u6708';
  38160. t['\u32C3'] = '\u0034\u6708';
  38161. t['\u32C4'] = '\u0035\u6708';
  38162. t['\u32C5'] = '\u0036\u6708';
  38163. t['\u32C6'] = '\u0037\u6708';
  38164. t['\u32C7'] = '\u0038\u6708';
  38165. t['\u32C8'] = '\u0039\u6708';
  38166. t['\u32C9'] = '\u0031\u0030\u6708';
  38167. t['\u32CA'] = '\u0031\u0031\u6708';
  38168. t['\u32CB'] = '\u0031\u0032\u6708';
  38169. t['\u3358'] = '\u0030\u70B9';
  38170. t['\u3359'] = '\u0031\u70B9';
  38171. t['\u335A'] = '\u0032\u70B9';
  38172. t['\u335B'] = '\u0033\u70B9';
  38173. t['\u335C'] = '\u0034\u70B9';
  38174. t['\u335D'] = '\u0035\u70B9';
  38175. t['\u335E'] = '\u0036\u70B9';
  38176. t['\u335F'] = '\u0037\u70B9';
  38177. t['\u3360'] = '\u0038\u70B9';
  38178. t['\u3361'] = '\u0039\u70B9';
  38179. t['\u3362'] = '\u0031\u0030\u70B9';
  38180. t['\u3363'] = '\u0031\u0031\u70B9';
  38181. t['\u3364'] = '\u0031\u0032\u70B9';
  38182. t['\u3365'] = '\u0031\u0033\u70B9';
  38183. t['\u3366'] = '\u0031\u0034\u70B9';
  38184. t['\u3367'] = '\u0031\u0035\u70B9';
  38185. t['\u3368'] = '\u0031\u0036\u70B9';
  38186. t['\u3369'] = '\u0031\u0037\u70B9';
  38187. t['\u336A'] = '\u0031\u0038\u70B9';
  38188. t['\u336B'] = '\u0031\u0039\u70B9';
  38189. t['\u336C'] = '\u0032\u0030\u70B9';
  38190. t['\u336D'] = '\u0032\u0031\u70B9';
  38191. t['\u336E'] = '\u0032\u0032\u70B9';
  38192. t['\u336F'] = '\u0032\u0033\u70B9';
  38193. t['\u3370'] = '\u0032\u0034\u70B9';
  38194. t['\u33E0'] = '\u0031\u65E5';
  38195. t['\u33E1'] = '\u0032\u65E5';
  38196. t['\u33E2'] = '\u0033\u65E5';
  38197. t['\u33E3'] = '\u0034\u65E5';
  38198. t['\u33E4'] = '\u0035\u65E5';
  38199. t['\u33E5'] = '\u0036\u65E5';
  38200. t['\u33E6'] = '\u0037\u65E5';
  38201. t['\u33E7'] = '\u0038\u65E5';
  38202. t['\u33E8'] = '\u0039\u65E5';
  38203. t['\u33E9'] = '\u0031\u0030\u65E5';
  38204. t['\u33EA'] = '\u0031\u0031\u65E5';
  38205. t['\u33EB'] = '\u0031\u0032\u65E5';
  38206. t['\u33EC'] = '\u0031\u0033\u65E5';
  38207. t['\u33ED'] = '\u0031\u0034\u65E5';
  38208. t['\u33EE'] = '\u0031\u0035\u65E5';
  38209. t['\u33EF'] = '\u0031\u0036\u65E5';
  38210. t['\u33F0'] = '\u0031\u0037\u65E5';
  38211. t['\u33F1'] = '\u0031\u0038\u65E5';
  38212. t['\u33F2'] = '\u0031\u0039\u65E5';
  38213. t['\u33F3'] = '\u0032\u0030\u65E5';
  38214. t['\u33F4'] = '\u0032\u0031\u65E5';
  38215. t['\u33F5'] = '\u0032\u0032\u65E5';
  38216. t['\u33F6'] = '\u0032\u0033\u65E5';
  38217. t['\u33F7'] = '\u0032\u0034\u65E5';
  38218. t['\u33F8'] = '\u0032\u0035\u65E5';
  38219. t['\u33F9'] = '\u0032\u0036\u65E5';
  38220. t['\u33FA'] = '\u0032\u0037\u65E5';
  38221. t['\u33FB'] = '\u0032\u0038\u65E5';
  38222. t['\u33FC'] = '\u0032\u0039\u65E5';
  38223. t['\u33FD'] = '\u0033\u0030\u65E5';
  38224. t['\u33FE'] = '\u0033\u0031\u65E5';
  38225. t['\uFB00'] = '\u0066\u0066';
  38226. t['\uFB01'] = '\u0066\u0069';
  38227. t['\uFB02'] = '\u0066\u006C';
  38228. t['\uFB03'] = '\u0066\u0066\u0069';
  38229. t['\uFB04'] = '\u0066\u0066\u006C';
  38230. t['\uFB05'] = '\u017F\u0074';
  38231. t['\uFB06'] = '\u0073\u0074';
  38232. t['\uFB13'] = '\u0574\u0576';
  38233. t['\uFB14'] = '\u0574\u0565';
  38234. t['\uFB15'] = '\u0574\u056B';
  38235. t['\uFB16'] = '\u057E\u0576';
  38236. t['\uFB17'] = '\u0574\u056D';
  38237. t['\uFB4F'] = '\u05D0\u05DC';
  38238. t['\uFB50'] = '\u0671';
  38239. t['\uFB51'] = '\u0671';
  38240. t['\uFB52'] = '\u067B';
  38241. t['\uFB53'] = '\u067B';
  38242. t['\uFB54'] = '\u067B';
  38243. t['\uFB55'] = '\u067B';
  38244. t['\uFB56'] = '\u067E';
  38245. t['\uFB57'] = '\u067E';
  38246. t['\uFB58'] = '\u067E';
  38247. t['\uFB59'] = '\u067E';
  38248. t['\uFB5A'] = '\u0680';
  38249. t['\uFB5B'] = '\u0680';
  38250. t['\uFB5C'] = '\u0680';
  38251. t['\uFB5D'] = '\u0680';
  38252. t['\uFB5E'] = '\u067A';
  38253. t['\uFB5F'] = '\u067A';
  38254. t['\uFB60'] = '\u067A';
  38255. t['\uFB61'] = '\u067A';
  38256. t['\uFB62'] = '\u067F';
  38257. t['\uFB63'] = '\u067F';
  38258. t['\uFB64'] = '\u067F';
  38259. t['\uFB65'] = '\u067F';
  38260. t['\uFB66'] = '\u0679';
  38261. t['\uFB67'] = '\u0679';
  38262. t['\uFB68'] = '\u0679';
  38263. t['\uFB69'] = '\u0679';
  38264. t['\uFB6A'] = '\u06A4';
  38265. t['\uFB6B'] = '\u06A4';
  38266. t['\uFB6C'] = '\u06A4';
  38267. t['\uFB6D'] = '\u06A4';
  38268. t['\uFB6E'] = '\u06A6';
  38269. t['\uFB6F'] = '\u06A6';
  38270. t['\uFB70'] = '\u06A6';
  38271. t['\uFB71'] = '\u06A6';
  38272. t['\uFB72'] = '\u0684';
  38273. t['\uFB73'] = '\u0684';
  38274. t['\uFB74'] = '\u0684';
  38275. t['\uFB75'] = '\u0684';
  38276. t['\uFB76'] = '\u0683';
  38277. t['\uFB77'] = '\u0683';
  38278. t['\uFB78'] = '\u0683';
  38279. t['\uFB79'] = '\u0683';
  38280. t['\uFB7A'] = '\u0686';
  38281. t['\uFB7B'] = '\u0686';
  38282. t['\uFB7C'] = '\u0686';
  38283. t['\uFB7D'] = '\u0686';
  38284. t['\uFB7E'] = '\u0687';
  38285. t['\uFB7F'] = '\u0687';
  38286. t['\uFB80'] = '\u0687';
  38287. t['\uFB81'] = '\u0687';
  38288. t['\uFB82'] = '\u068D';
  38289. t['\uFB83'] = '\u068D';
  38290. t['\uFB84'] = '\u068C';
  38291. t['\uFB85'] = '\u068C';
  38292. t['\uFB86'] = '\u068E';
  38293. t['\uFB87'] = '\u068E';
  38294. t['\uFB88'] = '\u0688';
  38295. t['\uFB89'] = '\u0688';
  38296. t['\uFB8A'] = '\u0698';
  38297. t['\uFB8B'] = '\u0698';
  38298. t['\uFB8C'] = '\u0691';
  38299. t['\uFB8D'] = '\u0691';
  38300. t['\uFB8E'] = '\u06A9';
  38301. t['\uFB8F'] = '\u06A9';
  38302. t['\uFB90'] = '\u06A9';
  38303. t['\uFB91'] = '\u06A9';
  38304. t['\uFB92'] = '\u06AF';
  38305. t['\uFB93'] = '\u06AF';
  38306. t['\uFB94'] = '\u06AF';
  38307. t['\uFB95'] = '\u06AF';
  38308. t['\uFB96'] = '\u06B3';
  38309. t['\uFB97'] = '\u06B3';
  38310. t['\uFB98'] = '\u06B3';
  38311. t['\uFB99'] = '\u06B3';
  38312. t['\uFB9A'] = '\u06B1';
  38313. t['\uFB9B'] = '\u06B1';
  38314. t['\uFB9C'] = '\u06B1';
  38315. t['\uFB9D'] = '\u06B1';
  38316. t['\uFB9E'] = '\u06BA';
  38317. t['\uFB9F'] = '\u06BA';
  38318. t['\uFBA0'] = '\u06BB';
  38319. t['\uFBA1'] = '\u06BB';
  38320. t['\uFBA2'] = '\u06BB';
  38321. t['\uFBA3'] = '\u06BB';
  38322. t['\uFBA4'] = '\u06C0';
  38323. t['\uFBA5'] = '\u06C0';
  38324. t['\uFBA6'] = '\u06C1';
  38325. t['\uFBA7'] = '\u06C1';
  38326. t['\uFBA8'] = '\u06C1';
  38327. t['\uFBA9'] = '\u06C1';
  38328. t['\uFBAA'] = '\u06BE';
  38329. t['\uFBAB'] = '\u06BE';
  38330. t['\uFBAC'] = '\u06BE';
  38331. t['\uFBAD'] = '\u06BE';
  38332. t['\uFBAE'] = '\u06D2';
  38333. t['\uFBAF'] = '\u06D2';
  38334. t['\uFBB0'] = '\u06D3';
  38335. t['\uFBB1'] = '\u06D3';
  38336. t['\uFBD3'] = '\u06AD';
  38337. t['\uFBD4'] = '\u06AD';
  38338. t['\uFBD5'] = '\u06AD';
  38339. t['\uFBD6'] = '\u06AD';
  38340. t['\uFBD7'] = '\u06C7';
  38341. t['\uFBD8'] = '\u06C7';
  38342. t['\uFBD9'] = '\u06C6';
  38343. t['\uFBDA'] = '\u06C6';
  38344. t['\uFBDB'] = '\u06C8';
  38345. t['\uFBDC'] = '\u06C8';
  38346. t['\uFBDD'] = '\u0677';
  38347. t['\uFBDE'] = '\u06CB';
  38348. t['\uFBDF'] = '\u06CB';
  38349. t['\uFBE0'] = '\u06C5';
  38350. t['\uFBE1'] = '\u06C5';
  38351. t['\uFBE2'] = '\u06C9';
  38352. t['\uFBE3'] = '\u06C9';
  38353. t['\uFBE4'] = '\u06D0';
  38354. t['\uFBE5'] = '\u06D0';
  38355. t['\uFBE6'] = '\u06D0';
  38356. t['\uFBE7'] = '\u06D0';
  38357. t['\uFBE8'] = '\u0649';
  38358. t['\uFBE9'] = '\u0649';
  38359. t['\uFBEA'] = '\u0626\u0627';
  38360. t['\uFBEB'] = '\u0626\u0627';
  38361. t['\uFBEC'] = '\u0626\u06D5';
  38362. t['\uFBED'] = '\u0626\u06D5';
  38363. t['\uFBEE'] = '\u0626\u0648';
  38364. t['\uFBEF'] = '\u0626\u0648';
  38365. t['\uFBF0'] = '\u0626\u06C7';
  38366. t['\uFBF1'] = '\u0626\u06C7';
  38367. t['\uFBF2'] = '\u0626\u06C6';
  38368. t['\uFBF3'] = '\u0626\u06C6';
  38369. t['\uFBF4'] = '\u0626\u06C8';
  38370. t['\uFBF5'] = '\u0626\u06C8';
  38371. t['\uFBF6'] = '\u0626\u06D0';
  38372. t['\uFBF7'] = '\u0626\u06D0';
  38373. t['\uFBF8'] = '\u0626\u06D0';
  38374. t['\uFBF9'] = '\u0626\u0649';
  38375. t['\uFBFA'] = '\u0626\u0649';
  38376. t['\uFBFB'] = '\u0626\u0649';
  38377. t['\uFBFC'] = '\u06CC';
  38378. t['\uFBFD'] = '\u06CC';
  38379. t['\uFBFE'] = '\u06CC';
  38380. t['\uFBFF'] = '\u06CC';
  38381. t['\uFC00'] = '\u0626\u062C';
  38382. t['\uFC01'] = '\u0626\u062D';
  38383. t['\uFC02'] = '\u0626\u0645';
  38384. t['\uFC03'] = '\u0626\u0649';
  38385. t['\uFC04'] = '\u0626\u064A';
  38386. t['\uFC05'] = '\u0628\u062C';
  38387. t['\uFC06'] = '\u0628\u062D';
  38388. t['\uFC07'] = '\u0628\u062E';
  38389. t['\uFC08'] = '\u0628\u0645';
  38390. t['\uFC09'] = '\u0628\u0649';
  38391. t['\uFC0A'] = '\u0628\u064A';
  38392. t['\uFC0B'] = '\u062A\u062C';
  38393. t['\uFC0C'] = '\u062A\u062D';
  38394. t['\uFC0D'] = '\u062A\u062E';
  38395. t['\uFC0E'] = '\u062A\u0645';
  38396. t['\uFC0F'] = '\u062A\u0649';
  38397. t['\uFC10'] = '\u062A\u064A';
  38398. t['\uFC11'] = '\u062B\u062C';
  38399. t['\uFC12'] = '\u062B\u0645';
  38400. t['\uFC13'] = '\u062B\u0649';
  38401. t['\uFC14'] = '\u062B\u064A';
  38402. t['\uFC15'] = '\u062C\u062D';
  38403. t['\uFC16'] = '\u062C\u0645';
  38404. t['\uFC17'] = '\u062D\u062C';
  38405. t['\uFC18'] = '\u062D\u0645';
  38406. t['\uFC19'] = '\u062E\u062C';
  38407. t['\uFC1A'] = '\u062E\u062D';
  38408. t['\uFC1B'] = '\u062E\u0645';
  38409. t['\uFC1C'] = '\u0633\u062C';
  38410. t['\uFC1D'] = '\u0633\u062D';
  38411. t['\uFC1E'] = '\u0633\u062E';
  38412. t['\uFC1F'] = '\u0633\u0645';
  38413. t['\uFC20'] = '\u0635\u062D';
  38414. t['\uFC21'] = '\u0635\u0645';
  38415. t['\uFC22'] = '\u0636\u062C';
  38416. t['\uFC23'] = '\u0636\u062D';
  38417. t['\uFC24'] = '\u0636\u062E';
  38418. t['\uFC25'] = '\u0636\u0645';
  38419. t['\uFC26'] = '\u0637\u062D';
  38420. t['\uFC27'] = '\u0637\u0645';
  38421. t['\uFC28'] = '\u0638\u0645';
  38422. t['\uFC29'] = '\u0639\u062C';
  38423. t['\uFC2A'] = '\u0639\u0645';
  38424. t['\uFC2B'] = '\u063A\u062C';
  38425. t['\uFC2C'] = '\u063A\u0645';
  38426. t['\uFC2D'] = '\u0641\u062C';
  38427. t['\uFC2E'] = '\u0641\u062D';
  38428. t['\uFC2F'] = '\u0641\u062E';
  38429. t['\uFC30'] = '\u0641\u0645';
  38430. t['\uFC31'] = '\u0641\u0649';
  38431. t['\uFC32'] = '\u0641\u064A';
  38432. t['\uFC33'] = '\u0642\u062D';
  38433. t['\uFC34'] = '\u0642\u0645';
  38434. t['\uFC35'] = '\u0642\u0649';
  38435. t['\uFC36'] = '\u0642\u064A';
  38436. t['\uFC37'] = '\u0643\u0627';
  38437. t['\uFC38'] = '\u0643\u062C';
  38438. t['\uFC39'] = '\u0643\u062D';
  38439. t['\uFC3A'] = '\u0643\u062E';
  38440. t['\uFC3B'] = '\u0643\u0644';
  38441. t['\uFC3C'] = '\u0643\u0645';
  38442. t['\uFC3D'] = '\u0643\u0649';
  38443. t['\uFC3E'] = '\u0643\u064A';
  38444. t['\uFC3F'] = '\u0644\u062C';
  38445. t['\uFC40'] = '\u0644\u062D';
  38446. t['\uFC41'] = '\u0644\u062E';
  38447. t['\uFC42'] = '\u0644\u0645';
  38448. t['\uFC43'] = '\u0644\u0649';
  38449. t['\uFC44'] = '\u0644\u064A';
  38450. t['\uFC45'] = '\u0645\u062C';
  38451. t['\uFC46'] = '\u0645\u062D';
  38452. t['\uFC47'] = '\u0645\u062E';
  38453. t['\uFC48'] = '\u0645\u0645';
  38454. t['\uFC49'] = '\u0645\u0649';
  38455. t['\uFC4A'] = '\u0645\u064A';
  38456. t['\uFC4B'] = '\u0646\u062C';
  38457. t['\uFC4C'] = '\u0646\u062D';
  38458. t['\uFC4D'] = '\u0646\u062E';
  38459. t['\uFC4E'] = '\u0646\u0645';
  38460. t['\uFC4F'] = '\u0646\u0649';
  38461. t['\uFC50'] = '\u0646\u064A';
  38462. t['\uFC51'] = '\u0647\u062C';
  38463. t['\uFC52'] = '\u0647\u0645';
  38464. t['\uFC53'] = '\u0647\u0649';
  38465. t['\uFC54'] = '\u0647\u064A';
  38466. t['\uFC55'] = '\u064A\u062C';
  38467. t['\uFC56'] = '\u064A\u062D';
  38468. t['\uFC57'] = '\u064A\u062E';
  38469. t['\uFC58'] = '\u064A\u0645';
  38470. t['\uFC59'] = '\u064A\u0649';
  38471. t['\uFC5A'] = '\u064A\u064A';
  38472. t['\uFC5B'] = '\u0630\u0670';
  38473. t['\uFC5C'] = '\u0631\u0670';
  38474. t['\uFC5D'] = '\u0649\u0670';
  38475. t['\uFC5E'] = '\u0020\u064C\u0651';
  38476. t['\uFC5F'] = '\u0020\u064D\u0651';
  38477. t['\uFC60'] = '\u0020\u064E\u0651';
  38478. t['\uFC61'] = '\u0020\u064F\u0651';
  38479. t['\uFC62'] = '\u0020\u0650\u0651';
  38480. t['\uFC63'] = '\u0020\u0651\u0670';
  38481. t['\uFC64'] = '\u0626\u0631';
  38482. t['\uFC65'] = '\u0626\u0632';
  38483. t['\uFC66'] = '\u0626\u0645';
  38484. t['\uFC67'] = '\u0626\u0646';
  38485. t['\uFC68'] = '\u0626\u0649';
  38486. t['\uFC69'] = '\u0626\u064A';
  38487. t['\uFC6A'] = '\u0628\u0631';
  38488. t['\uFC6B'] = '\u0628\u0632';
  38489. t['\uFC6C'] = '\u0628\u0645';
  38490. t['\uFC6D'] = '\u0628\u0646';
  38491. t['\uFC6E'] = '\u0628\u0649';
  38492. t['\uFC6F'] = '\u0628\u064A';
  38493. t['\uFC70'] = '\u062A\u0631';
  38494. t['\uFC71'] = '\u062A\u0632';
  38495. t['\uFC72'] = '\u062A\u0645';
  38496. t['\uFC73'] = '\u062A\u0646';
  38497. t['\uFC74'] = '\u062A\u0649';
  38498. t['\uFC75'] = '\u062A\u064A';
  38499. t['\uFC76'] = '\u062B\u0631';
  38500. t['\uFC77'] = '\u062B\u0632';
  38501. t['\uFC78'] = '\u062B\u0645';
  38502. t['\uFC79'] = '\u062B\u0646';
  38503. t['\uFC7A'] = '\u062B\u0649';
  38504. t['\uFC7B'] = '\u062B\u064A';
  38505. t['\uFC7C'] = '\u0641\u0649';
  38506. t['\uFC7D'] = '\u0641\u064A';
  38507. t['\uFC7E'] = '\u0642\u0649';
  38508. t['\uFC7F'] = '\u0642\u064A';
  38509. t['\uFC80'] = '\u0643\u0627';
  38510. t['\uFC81'] = '\u0643\u0644';
  38511. t['\uFC82'] = '\u0643\u0645';
  38512. t['\uFC83'] = '\u0643\u0649';
  38513. t['\uFC84'] = '\u0643\u064A';
  38514. t['\uFC85'] = '\u0644\u0645';
  38515. t['\uFC86'] = '\u0644\u0649';
  38516. t['\uFC87'] = '\u0644\u064A';
  38517. t['\uFC88'] = '\u0645\u0627';
  38518. t['\uFC89'] = '\u0645\u0645';
  38519. t['\uFC8A'] = '\u0646\u0631';
  38520. t['\uFC8B'] = '\u0646\u0632';
  38521. t['\uFC8C'] = '\u0646\u0645';
  38522. t['\uFC8D'] = '\u0646\u0646';
  38523. t['\uFC8E'] = '\u0646\u0649';
  38524. t['\uFC8F'] = '\u0646\u064A';
  38525. t['\uFC90'] = '\u0649\u0670';
  38526. t['\uFC91'] = '\u064A\u0631';
  38527. t['\uFC92'] = '\u064A\u0632';
  38528. t['\uFC93'] = '\u064A\u0645';
  38529. t['\uFC94'] = '\u064A\u0646';
  38530. t['\uFC95'] = '\u064A\u0649';
  38531. t['\uFC96'] = '\u064A\u064A';
  38532. t['\uFC97'] = '\u0626\u062C';
  38533. t['\uFC98'] = '\u0626\u062D';
  38534. t['\uFC99'] = '\u0626\u062E';
  38535. t['\uFC9A'] = '\u0626\u0645';
  38536. t['\uFC9B'] = '\u0626\u0647';
  38537. t['\uFC9C'] = '\u0628\u062C';
  38538. t['\uFC9D'] = '\u0628\u062D';
  38539. t['\uFC9E'] = '\u0628\u062E';
  38540. t['\uFC9F'] = '\u0628\u0645';
  38541. t['\uFCA0'] = '\u0628\u0647';
  38542. t['\uFCA1'] = '\u062A\u062C';
  38543. t['\uFCA2'] = '\u062A\u062D';
  38544. t['\uFCA3'] = '\u062A\u062E';
  38545. t['\uFCA4'] = '\u062A\u0645';
  38546. t['\uFCA5'] = '\u062A\u0647';
  38547. t['\uFCA6'] = '\u062B\u0645';
  38548. t['\uFCA7'] = '\u062C\u062D';
  38549. t['\uFCA8'] = '\u062C\u0645';
  38550. t['\uFCA9'] = '\u062D\u062C';
  38551. t['\uFCAA'] = '\u062D\u0645';
  38552. t['\uFCAB'] = '\u062E\u062C';
  38553. t['\uFCAC'] = '\u062E\u0645';
  38554. t['\uFCAD'] = '\u0633\u062C';
  38555. t['\uFCAE'] = '\u0633\u062D';
  38556. t['\uFCAF'] = '\u0633\u062E';
  38557. t['\uFCB0'] = '\u0633\u0645';
  38558. t['\uFCB1'] = '\u0635\u062D';
  38559. t['\uFCB2'] = '\u0635\u062E';
  38560. t['\uFCB3'] = '\u0635\u0645';
  38561. t['\uFCB4'] = '\u0636\u062C';
  38562. t['\uFCB5'] = '\u0636\u062D';
  38563. t['\uFCB6'] = '\u0636\u062E';
  38564. t['\uFCB7'] = '\u0636\u0645';
  38565. t['\uFCB8'] = '\u0637\u062D';
  38566. t['\uFCB9'] = '\u0638\u0645';
  38567. t['\uFCBA'] = '\u0639\u062C';
  38568. t['\uFCBB'] = '\u0639\u0645';
  38569. t['\uFCBC'] = '\u063A\u062C';
  38570. t['\uFCBD'] = '\u063A\u0645';
  38571. t['\uFCBE'] = '\u0641\u062C';
  38572. t['\uFCBF'] = '\u0641\u062D';
  38573. t['\uFCC0'] = '\u0641\u062E';
  38574. t['\uFCC1'] = '\u0641\u0645';
  38575. t['\uFCC2'] = '\u0642\u062D';
  38576. t['\uFCC3'] = '\u0642\u0645';
  38577. t['\uFCC4'] = '\u0643\u062C';
  38578. t['\uFCC5'] = '\u0643\u062D';
  38579. t['\uFCC6'] = '\u0643\u062E';
  38580. t['\uFCC7'] = '\u0643\u0644';
  38581. t['\uFCC8'] = '\u0643\u0645';
  38582. t['\uFCC9'] = '\u0644\u062C';
  38583. t['\uFCCA'] = '\u0644\u062D';
  38584. t['\uFCCB'] = '\u0644\u062E';
  38585. t['\uFCCC'] = '\u0644\u0645';
  38586. t['\uFCCD'] = '\u0644\u0647';
  38587. t['\uFCCE'] = '\u0645\u062C';
  38588. t['\uFCCF'] = '\u0645\u062D';
  38589. t['\uFCD0'] = '\u0645\u062E';
  38590. t['\uFCD1'] = '\u0645\u0645';
  38591. t['\uFCD2'] = '\u0646\u062C';
  38592. t['\uFCD3'] = '\u0646\u062D';
  38593. t['\uFCD4'] = '\u0646\u062E';
  38594. t['\uFCD5'] = '\u0646\u0645';
  38595. t['\uFCD6'] = '\u0646\u0647';
  38596. t['\uFCD7'] = '\u0647\u062C';
  38597. t['\uFCD8'] = '\u0647\u0645';
  38598. t['\uFCD9'] = '\u0647\u0670';
  38599. t['\uFCDA'] = '\u064A\u062C';
  38600. t['\uFCDB'] = '\u064A\u062D';
  38601. t['\uFCDC'] = '\u064A\u062E';
  38602. t['\uFCDD'] = '\u064A\u0645';
  38603. t['\uFCDE'] = '\u064A\u0647';
  38604. t['\uFCDF'] = '\u0626\u0645';
  38605. t['\uFCE0'] = '\u0626\u0647';
  38606. t['\uFCE1'] = '\u0628\u0645';
  38607. t['\uFCE2'] = '\u0628\u0647';
  38608. t['\uFCE3'] = '\u062A\u0645';
  38609. t['\uFCE4'] = '\u062A\u0647';
  38610. t['\uFCE5'] = '\u062B\u0645';
  38611. t['\uFCE6'] = '\u062B\u0647';
  38612. t['\uFCE7'] = '\u0633\u0645';
  38613. t['\uFCE8'] = '\u0633\u0647';
  38614. t['\uFCE9'] = '\u0634\u0645';
  38615. t['\uFCEA'] = '\u0634\u0647';
  38616. t['\uFCEB'] = '\u0643\u0644';
  38617. t['\uFCEC'] = '\u0643\u0645';
  38618. t['\uFCED'] = '\u0644\u0645';
  38619. t['\uFCEE'] = '\u0646\u0645';
  38620. t['\uFCEF'] = '\u0646\u0647';
  38621. t['\uFCF0'] = '\u064A\u0645';
  38622. t['\uFCF1'] = '\u064A\u0647';
  38623. t['\uFCF2'] = '\u0640\u064E\u0651';
  38624. t['\uFCF3'] = '\u0640\u064F\u0651';
  38625. t['\uFCF4'] = '\u0640\u0650\u0651';
  38626. t['\uFCF5'] = '\u0637\u0649';
  38627. t['\uFCF6'] = '\u0637\u064A';
  38628. t['\uFCF7'] = '\u0639\u0649';
  38629. t['\uFCF8'] = '\u0639\u064A';
  38630. t['\uFCF9'] = '\u063A\u0649';
  38631. t['\uFCFA'] = '\u063A\u064A';
  38632. t['\uFCFB'] = '\u0633\u0649';
  38633. t['\uFCFC'] = '\u0633\u064A';
  38634. t['\uFCFD'] = '\u0634\u0649';
  38635. t['\uFCFE'] = '\u0634\u064A';
  38636. t['\uFCFF'] = '\u062D\u0649';
  38637. t['\uFD00'] = '\u062D\u064A';
  38638. t['\uFD01'] = '\u062C\u0649';
  38639. t['\uFD02'] = '\u062C\u064A';
  38640. t['\uFD03'] = '\u062E\u0649';
  38641. t['\uFD04'] = '\u062E\u064A';
  38642. t['\uFD05'] = '\u0635\u0649';
  38643. t['\uFD06'] = '\u0635\u064A';
  38644. t['\uFD07'] = '\u0636\u0649';
  38645. t['\uFD08'] = '\u0636\u064A';
  38646. t['\uFD09'] = '\u0634\u062C';
  38647. t['\uFD0A'] = '\u0634\u062D';
  38648. t['\uFD0B'] = '\u0634\u062E';
  38649. t['\uFD0C'] = '\u0634\u0645';
  38650. t['\uFD0D'] = '\u0634\u0631';
  38651. t['\uFD0E'] = '\u0633\u0631';
  38652. t['\uFD0F'] = '\u0635\u0631';
  38653. t['\uFD10'] = '\u0636\u0631';
  38654. t['\uFD11'] = '\u0637\u0649';
  38655. t['\uFD12'] = '\u0637\u064A';
  38656. t['\uFD13'] = '\u0639\u0649';
  38657. t['\uFD14'] = '\u0639\u064A';
  38658. t['\uFD15'] = '\u063A\u0649';
  38659. t['\uFD16'] = '\u063A\u064A';
  38660. t['\uFD17'] = '\u0633\u0649';
  38661. t['\uFD18'] = '\u0633\u064A';
  38662. t['\uFD19'] = '\u0634\u0649';
  38663. t['\uFD1A'] = '\u0634\u064A';
  38664. t['\uFD1B'] = '\u062D\u0649';
  38665. t['\uFD1C'] = '\u062D\u064A';
  38666. t['\uFD1D'] = '\u062C\u0649';
  38667. t['\uFD1E'] = '\u062C\u064A';
  38668. t['\uFD1F'] = '\u062E\u0649';
  38669. t['\uFD20'] = '\u062E\u064A';
  38670. t['\uFD21'] = '\u0635\u0649';
  38671. t['\uFD22'] = '\u0635\u064A';
  38672. t['\uFD23'] = '\u0636\u0649';
  38673. t['\uFD24'] = '\u0636\u064A';
  38674. t['\uFD25'] = '\u0634\u062C';
  38675. t['\uFD26'] = '\u0634\u062D';
  38676. t['\uFD27'] = '\u0634\u062E';
  38677. t['\uFD28'] = '\u0634\u0645';
  38678. t['\uFD29'] = '\u0634\u0631';
  38679. t['\uFD2A'] = '\u0633\u0631';
  38680. t['\uFD2B'] = '\u0635\u0631';
  38681. t['\uFD2C'] = '\u0636\u0631';
  38682. t['\uFD2D'] = '\u0634\u062C';
  38683. t['\uFD2E'] = '\u0634\u062D';
  38684. t['\uFD2F'] = '\u0634\u062E';
  38685. t['\uFD30'] = '\u0634\u0645';
  38686. t['\uFD31'] = '\u0633\u0647';
  38687. t['\uFD32'] = '\u0634\u0647';
  38688. t['\uFD33'] = '\u0637\u0645';
  38689. t['\uFD34'] = '\u0633\u062C';
  38690. t['\uFD35'] = '\u0633\u062D';
  38691. t['\uFD36'] = '\u0633\u062E';
  38692. t['\uFD37'] = '\u0634\u062C';
  38693. t['\uFD38'] = '\u0634\u062D';
  38694. t['\uFD39'] = '\u0634\u062E';
  38695. t['\uFD3A'] = '\u0637\u0645';
  38696. t['\uFD3B'] = '\u0638\u0645';
  38697. t['\uFD3C'] = '\u0627\u064B';
  38698. t['\uFD3D'] = '\u0627\u064B';
  38699. t['\uFD50'] = '\u062A\u062C\u0645';
  38700. t['\uFD51'] = '\u062A\u062D\u062C';
  38701. t['\uFD52'] = '\u062A\u062D\u062C';
  38702. t['\uFD53'] = '\u062A\u062D\u0645';
  38703. t['\uFD54'] = '\u062A\u062E\u0645';
  38704. t['\uFD55'] = '\u062A\u0645\u062C';
  38705. t['\uFD56'] = '\u062A\u0645\u062D';
  38706. t['\uFD57'] = '\u062A\u0645\u062E';
  38707. t['\uFD58'] = '\u062C\u0645\u062D';
  38708. t['\uFD59'] = '\u062C\u0645\u062D';
  38709. t['\uFD5A'] = '\u062D\u0645\u064A';
  38710. t['\uFD5B'] = '\u062D\u0645\u0649';
  38711. t['\uFD5C'] = '\u0633\u062D\u062C';
  38712. t['\uFD5D'] = '\u0633\u062C\u062D';
  38713. t['\uFD5E'] = '\u0633\u062C\u0649';
  38714. t['\uFD5F'] = '\u0633\u0645\u062D';
  38715. t['\uFD60'] = '\u0633\u0645\u062D';
  38716. t['\uFD61'] = '\u0633\u0645\u062C';
  38717. t['\uFD62'] = '\u0633\u0645\u0645';
  38718. t['\uFD63'] = '\u0633\u0645\u0645';
  38719. t['\uFD64'] = '\u0635\u062D\u062D';
  38720. t['\uFD65'] = '\u0635\u062D\u062D';
  38721. t['\uFD66'] = '\u0635\u0645\u0645';
  38722. t['\uFD67'] = '\u0634\u062D\u0645';
  38723. t['\uFD68'] = '\u0634\u062D\u0645';
  38724. t['\uFD69'] = '\u0634\u062C\u064A';
  38725. t['\uFD6A'] = '\u0634\u0645\u062E';
  38726. t['\uFD6B'] = '\u0634\u0645\u062E';
  38727. t['\uFD6C'] = '\u0634\u0645\u0645';
  38728. t['\uFD6D'] = '\u0634\u0645\u0645';
  38729. t['\uFD6E'] = '\u0636\u062D\u0649';
  38730. t['\uFD6F'] = '\u0636\u062E\u0645';
  38731. t['\uFD70'] = '\u0636\u062E\u0645';
  38732. t['\uFD71'] = '\u0637\u0645\u062D';
  38733. t['\uFD72'] = '\u0637\u0645\u062D';
  38734. t['\uFD73'] = '\u0637\u0645\u0645';
  38735. t['\uFD74'] = '\u0637\u0645\u064A';
  38736. t['\uFD75'] = '\u0639\u062C\u0645';
  38737. t['\uFD76'] = '\u0639\u0645\u0645';
  38738. t['\uFD77'] = '\u0639\u0645\u0645';
  38739. t['\uFD78'] = '\u0639\u0645\u0649';
  38740. t['\uFD79'] = '\u063A\u0645\u0645';
  38741. t['\uFD7A'] = '\u063A\u0645\u064A';
  38742. t['\uFD7B'] = '\u063A\u0645\u0649';
  38743. t['\uFD7C'] = '\u0641\u062E\u0645';
  38744. t['\uFD7D'] = '\u0641\u062E\u0645';
  38745. t['\uFD7E'] = '\u0642\u0645\u062D';
  38746. t['\uFD7F'] = '\u0642\u0645\u0645';
  38747. t['\uFD80'] = '\u0644\u062D\u0645';
  38748. t['\uFD81'] = '\u0644\u062D\u064A';
  38749. t['\uFD82'] = '\u0644\u062D\u0649';
  38750. t['\uFD83'] = '\u0644\u062C\u062C';
  38751. t['\uFD84'] = '\u0644\u062C\u062C';
  38752. t['\uFD85'] = '\u0644\u062E\u0645';
  38753. t['\uFD86'] = '\u0644\u062E\u0645';
  38754. t['\uFD87'] = '\u0644\u0645\u062D';
  38755. t['\uFD88'] = '\u0644\u0645\u062D';
  38756. t['\uFD89'] = '\u0645\u062D\u062C';
  38757. t['\uFD8A'] = '\u0645\u062D\u0645';
  38758. t['\uFD8B'] = '\u0645\u062D\u064A';
  38759. t['\uFD8C'] = '\u0645\u062C\u062D';
  38760. t['\uFD8D'] = '\u0645\u062C\u0645';
  38761. t['\uFD8E'] = '\u0645\u062E\u062C';
  38762. t['\uFD8F'] = '\u0645\u062E\u0645';
  38763. t['\uFD92'] = '\u0645\u062C\u062E';
  38764. t['\uFD93'] = '\u0647\u0645\u062C';
  38765. t['\uFD94'] = '\u0647\u0645\u0645';
  38766. t['\uFD95'] = '\u0646\u062D\u0645';
  38767. t['\uFD96'] = '\u0646\u062D\u0649';
  38768. t['\uFD97'] = '\u0646\u062C\u0645';
  38769. t['\uFD98'] = '\u0646\u062C\u0645';
  38770. t['\uFD99'] = '\u0646\u062C\u0649';
  38771. t['\uFD9A'] = '\u0646\u0645\u064A';
  38772. t['\uFD9B'] = '\u0646\u0645\u0649';
  38773. t['\uFD9C'] = '\u064A\u0645\u0645';
  38774. t['\uFD9D'] = '\u064A\u0645\u0645';
  38775. t['\uFD9E'] = '\u0628\u062E\u064A';
  38776. t['\uFD9F'] = '\u062A\u062C\u064A';
  38777. t['\uFDA0'] = '\u062A\u062C\u0649';
  38778. t['\uFDA1'] = '\u062A\u062E\u064A';
  38779. t['\uFDA2'] = '\u062A\u062E\u0649';
  38780. t['\uFDA3'] = '\u062A\u0645\u064A';
  38781. t['\uFDA4'] = '\u062A\u0645\u0649';
  38782. t['\uFDA5'] = '\u062C\u0645\u064A';
  38783. t['\uFDA6'] = '\u062C\u062D\u0649';
  38784. t['\uFDA7'] = '\u062C\u0645\u0649';
  38785. t['\uFDA8'] = '\u0633\u062E\u0649';
  38786. t['\uFDA9'] = '\u0635\u062D\u064A';
  38787. t['\uFDAA'] = '\u0634\u062D\u064A';
  38788. t['\uFDAB'] = '\u0636\u062D\u064A';
  38789. t['\uFDAC'] = '\u0644\u062C\u064A';
  38790. t['\uFDAD'] = '\u0644\u0645\u064A';
  38791. t['\uFDAE'] = '\u064A\u062D\u064A';
  38792. t['\uFDAF'] = '\u064A\u062C\u064A';
  38793. t['\uFDB0'] = '\u064A\u0645\u064A';
  38794. t['\uFDB1'] = '\u0645\u0645\u064A';
  38795. t['\uFDB2'] = '\u0642\u0645\u064A';
  38796. t['\uFDB3'] = '\u0646\u062D\u064A';
  38797. t['\uFDB4'] = '\u0642\u0645\u062D';
  38798. t['\uFDB5'] = '\u0644\u062D\u0645';
  38799. t['\uFDB6'] = '\u0639\u0645\u064A';
  38800. t['\uFDB7'] = '\u0643\u0645\u064A';
  38801. t['\uFDB8'] = '\u0646\u062C\u062D';
  38802. t['\uFDB9'] = '\u0645\u062E\u064A';
  38803. t['\uFDBA'] = '\u0644\u062C\u0645';
  38804. t['\uFDBB'] = '\u0643\u0645\u0645';
  38805. t['\uFDBC'] = '\u0644\u062C\u0645';
  38806. t['\uFDBD'] = '\u0646\u062C\u062D';
  38807. t['\uFDBE'] = '\u062C\u062D\u064A';
  38808. t['\uFDBF'] = '\u062D\u062C\u064A';
  38809. t['\uFDC0'] = '\u0645\u062C\u064A';
  38810. t['\uFDC1'] = '\u0641\u0645\u064A';
  38811. t['\uFDC2'] = '\u0628\u062D\u064A';
  38812. t['\uFDC3'] = '\u0643\u0645\u0645';
  38813. t['\uFDC4'] = '\u0639\u062C\u0645';
  38814. t['\uFDC5'] = '\u0635\u0645\u0645';
  38815. t['\uFDC6'] = '\u0633\u062E\u064A';
  38816. t['\uFDC7'] = '\u0646\u062C\u064A';
  38817. t['\uFE49'] = '\u203E';
  38818. t['\uFE4A'] = '\u203E';
  38819. t['\uFE4B'] = '\u203E';
  38820. t['\uFE4C'] = '\u203E';
  38821. t['\uFE4D'] = '\u005F';
  38822. t['\uFE4E'] = '\u005F';
  38823. t['\uFE4F'] = '\u005F';
  38824. t['\uFE80'] = '\u0621';
  38825. t['\uFE81'] = '\u0622';
  38826. t['\uFE82'] = '\u0622';
  38827. t['\uFE83'] = '\u0623';
  38828. t['\uFE84'] = '\u0623';
  38829. t['\uFE85'] = '\u0624';
  38830. t['\uFE86'] = '\u0624';
  38831. t['\uFE87'] = '\u0625';
  38832. t['\uFE88'] = '\u0625';
  38833. t['\uFE89'] = '\u0626';
  38834. t['\uFE8A'] = '\u0626';
  38835. t['\uFE8B'] = '\u0626';
  38836. t['\uFE8C'] = '\u0626';
  38837. t['\uFE8D'] = '\u0627';
  38838. t['\uFE8E'] = '\u0627';
  38839. t['\uFE8F'] = '\u0628';
  38840. t['\uFE90'] = '\u0628';
  38841. t['\uFE91'] = '\u0628';
  38842. t['\uFE92'] = '\u0628';
  38843. t['\uFE93'] = '\u0629';
  38844. t['\uFE94'] = '\u0629';
  38845. t['\uFE95'] = '\u062A';
  38846. t['\uFE96'] = '\u062A';
  38847. t['\uFE97'] = '\u062A';
  38848. t['\uFE98'] = '\u062A';
  38849. t['\uFE99'] = '\u062B';
  38850. t['\uFE9A'] = '\u062B';
  38851. t['\uFE9B'] = '\u062B';
  38852. t['\uFE9C'] = '\u062B';
  38853. t['\uFE9D'] = '\u062C';
  38854. t['\uFE9E'] = '\u062C';
  38855. t['\uFE9F'] = '\u062C';
  38856. t['\uFEA0'] = '\u062C';
  38857. t['\uFEA1'] = '\u062D';
  38858. t['\uFEA2'] = '\u062D';
  38859. t['\uFEA3'] = '\u062D';
  38860. t['\uFEA4'] = '\u062D';
  38861. t['\uFEA5'] = '\u062E';
  38862. t['\uFEA6'] = '\u062E';
  38863. t['\uFEA7'] = '\u062E';
  38864. t['\uFEA8'] = '\u062E';
  38865. t['\uFEA9'] = '\u062F';
  38866. t['\uFEAA'] = '\u062F';
  38867. t['\uFEAB'] = '\u0630';
  38868. t['\uFEAC'] = '\u0630';
  38869. t['\uFEAD'] = '\u0631';
  38870. t['\uFEAE'] = '\u0631';
  38871. t['\uFEAF'] = '\u0632';
  38872. t['\uFEB0'] = '\u0632';
  38873. t['\uFEB1'] = '\u0633';
  38874. t['\uFEB2'] = '\u0633';
  38875. t['\uFEB3'] = '\u0633';
  38876. t['\uFEB4'] = '\u0633';
  38877. t['\uFEB5'] = '\u0634';
  38878. t['\uFEB6'] = '\u0634';
  38879. t['\uFEB7'] = '\u0634';
  38880. t['\uFEB8'] = '\u0634';
  38881. t['\uFEB9'] = '\u0635';
  38882. t['\uFEBA'] = '\u0635';
  38883. t['\uFEBB'] = '\u0635';
  38884. t['\uFEBC'] = '\u0635';
  38885. t['\uFEBD'] = '\u0636';
  38886. t['\uFEBE'] = '\u0636';
  38887. t['\uFEBF'] = '\u0636';
  38888. t['\uFEC0'] = '\u0636';
  38889. t['\uFEC1'] = '\u0637';
  38890. t['\uFEC2'] = '\u0637';
  38891. t['\uFEC3'] = '\u0637';
  38892. t['\uFEC4'] = '\u0637';
  38893. t['\uFEC5'] = '\u0638';
  38894. t['\uFEC6'] = '\u0638';
  38895. t['\uFEC7'] = '\u0638';
  38896. t['\uFEC8'] = '\u0638';
  38897. t['\uFEC9'] = '\u0639';
  38898. t['\uFECA'] = '\u0639';
  38899. t['\uFECB'] = '\u0639';
  38900. t['\uFECC'] = '\u0639';
  38901. t['\uFECD'] = '\u063A';
  38902. t['\uFECE'] = '\u063A';
  38903. t['\uFECF'] = '\u063A';
  38904. t['\uFED0'] = '\u063A';
  38905. t['\uFED1'] = '\u0641';
  38906. t['\uFED2'] = '\u0641';
  38907. t['\uFED3'] = '\u0641';
  38908. t['\uFED4'] = '\u0641';
  38909. t['\uFED5'] = '\u0642';
  38910. t['\uFED6'] = '\u0642';
  38911. t['\uFED7'] = '\u0642';
  38912. t['\uFED8'] = '\u0642';
  38913. t['\uFED9'] = '\u0643';
  38914. t['\uFEDA'] = '\u0643';
  38915. t['\uFEDB'] = '\u0643';
  38916. t['\uFEDC'] = '\u0643';
  38917. t['\uFEDD'] = '\u0644';
  38918. t['\uFEDE'] = '\u0644';
  38919. t['\uFEDF'] = '\u0644';
  38920. t['\uFEE0'] = '\u0644';
  38921. t['\uFEE1'] = '\u0645';
  38922. t['\uFEE2'] = '\u0645';
  38923. t['\uFEE3'] = '\u0645';
  38924. t['\uFEE4'] = '\u0645';
  38925. t['\uFEE5'] = '\u0646';
  38926. t['\uFEE6'] = '\u0646';
  38927. t['\uFEE7'] = '\u0646';
  38928. t['\uFEE8'] = '\u0646';
  38929. t['\uFEE9'] = '\u0647';
  38930. t['\uFEEA'] = '\u0647';
  38931. t['\uFEEB'] = '\u0647';
  38932. t['\uFEEC'] = '\u0647';
  38933. t['\uFEED'] = '\u0648';
  38934. t['\uFEEE'] = '\u0648';
  38935. t['\uFEEF'] = '\u0649';
  38936. t['\uFEF0'] = '\u0649';
  38937. t['\uFEF1'] = '\u064A';
  38938. t['\uFEF2'] = '\u064A';
  38939. t['\uFEF3'] = '\u064A';
  38940. t['\uFEF4'] = '\u064A';
  38941. t['\uFEF5'] = '\u0644\u0622';
  38942. t['\uFEF6'] = '\u0644\u0622';
  38943. t['\uFEF7'] = '\u0644\u0623';
  38944. t['\uFEF8'] = '\u0644\u0623';
  38945. t['\uFEF9'] = '\u0644\u0625';
  38946. t['\uFEFA'] = '\u0644\u0625';
  38947. t['\uFEFB'] = '\u0644\u0627';
  38948. t['\uFEFC'] = '\u0644\u0627';
  38949. });
  38950. function reverseIfRtl(chars) {
  38951. var charsLength = chars.length;
  38952. if (charsLength <= 1 || !isRTLRangeFor(chars.charCodeAt(0))) {
  38953. return chars;
  38954. }
  38955. var s = '';
  38956. for (var ii = charsLength - 1; ii >= 0; ii--) {
  38957. s += chars[ii];
  38958. }
  38959. return s;
  38960. }
  38961. exports.mapSpecialUnicodeValues = mapSpecialUnicodeValues;
  38962. exports.reverseIfRtl = reverseIfRtl;
  38963. exports.getUnicodeRangeFor = getUnicodeRangeFor;
  38964. exports.getNormalizedUnicodes = getNormalizedUnicodes;
  38965. exports.getUnicodeForGlyph = getUnicodeForGlyph;
  38966. /***/ }),
  38967. /* 23 */
  38968. /***/ (function(module, exports, __w_pdfjs_require__) {
  38969. "use strict";
  38970. var sharedUtil = __w_pdfjs_require__(0);
  38971. var error = sharedUtil.error;
  38972. function fixMetadata(meta) {
  38973. return meta.replace(/>\\376\\377([^<]+)/g, function (all, codes) {
  38974. var bytes = codes.replace(/\\([0-3])([0-7])([0-7])/g, function (code, d1, d2, d3) {
  38975. return String.fromCharCode(d1 * 64 + d2 * 8 + d3 * 1);
  38976. });
  38977. var chars = '';
  38978. for (var i = 0; i < bytes.length; i += 2) {
  38979. var code = bytes.charCodeAt(i) * 256 + bytes.charCodeAt(i + 1);
  38980. chars += code >= 32 && code < 127 && code !== 60 && code !== 62 && code !== 38 ? String.fromCharCode(code) : '&#x' + (0x10000 + code).toString(16).substring(1) + ';';
  38981. }
  38982. return '>' + chars;
  38983. });
  38984. }
  38985. function Metadata(meta) {
  38986. if (typeof meta === 'string') {
  38987. meta = fixMetadata(meta);
  38988. var parser = new DOMParser();
  38989. meta = parser.parseFromString(meta, 'application/xml');
  38990. } else if (!(meta instanceof Document)) {
  38991. error('Metadata: Invalid metadata object');
  38992. }
  38993. this.metaDocument = meta;
  38994. this.metadata = Object.create(null);
  38995. this.parse();
  38996. }
  38997. Metadata.prototype = {
  38998. parse: function Metadata_parse() {
  38999. var doc = this.metaDocument;
  39000. var rdf = doc.documentElement;
  39001. if (rdf.nodeName.toLowerCase() !== 'rdf:rdf') {
  39002. rdf = rdf.firstChild;
  39003. while (rdf && rdf.nodeName.toLowerCase() !== 'rdf:rdf') {
  39004. rdf = rdf.nextSibling;
  39005. }
  39006. }
  39007. var nodeName = rdf ? rdf.nodeName.toLowerCase() : null;
  39008. if (!rdf || nodeName !== 'rdf:rdf' || !rdf.hasChildNodes()) {
  39009. return;
  39010. }
  39011. var children = rdf.childNodes, desc, entry, name, i, ii, length, iLength;
  39012. for (i = 0, length = children.length; i < length; i++) {
  39013. desc = children[i];
  39014. if (desc.nodeName.toLowerCase() !== 'rdf:description') {
  39015. continue;
  39016. }
  39017. for (ii = 0, iLength = desc.childNodes.length; ii < iLength; ii++) {
  39018. if (desc.childNodes[ii].nodeName.toLowerCase() !== '#text') {
  39019. entry = desc.childNodes[ii];
  39020. name = entry.nodeName.toLowerCase();
  39021. this.metadata[name] = entry.textContent.trim();
  39022. }
  39023. }
  39024. }
  39025. },
  39026. get: function Metadata_get(name) {
  39027. return this.metadata[name] || null;
  39028. },
  39029. has: function Metadata_has(name) {
  39030. return typeof this.metadata[name] !== 'undefined';
  39031. }
  39032. };
  39033. exports.Metadata = Metadata;
  39034. /***/ }),
  39035. /* 24 */
  39036. /***/ (function(module, exports, __w_pdfjs_require__) {
  39037. "use strict";
  39038. var sharedUtil = __w_pdfjs_require__(0);
  39039. var displayDOMUtils = __w_pdfjs_require__(3);
  39040. var shadow = sharedUtil.shadow;
  39041. var getDefaultSetting = displayDOMUtils.getDefaultSetting;
  39042. var WebGLUtils = function WebGLUtilsClosure() {
  39043. function loadShader(gl, code, shaderType) {
  39044. var shader = gl.createShader(shaderType);
  39045. gl.shaderSource(shader, code);
  39046. gl.compileShader(shader);
  39047. var compiled = gl.getShaderParameter(shader, gl.COMPILE_STATUS);
  39048. if (!compiled) {
  39049. var errorMsg = gl.getShaderInfoLog(shader);
  39050. throw new Error('Error during shader compilation: ' + errorMsg);
  39051. }
  39052. return shader;
  39053. }
  39054. function createVertexShader(gl, code) {
  39055. return loadShader(gl, code, gl.VERTEX_SHADER);
  39056. }
  39057. function createFragmentShader(gl, code) {
  39058. return loadShader(gl, code, gl.FRAGMENT_SHADER);
  39059. }
  39060. function createProgram(gl, shaders) {
  39061. var program = gl.createProgram();
  39062. for (var i = 0, ii = shaders.length; i < ii; ++i) {
  39063. gl.attachShader(program, shaders[i]);
  39064. }
  39065. gl.linkProgram(program);
  39066. var linked = gl.getProgramParameter(program, gl.LINK_STATUS);
  39067. if (!linked) {
  39068. var errorMsg = gl.getProgramInfoLog(program);
  39069. throw new Error('Error during program linking: ' + errorMsg);
  39070. }
  39071. return program;
  39072. }
  39073. function createTexture(gl, image, textureId) {
  39074. gl.activeTexture(textureId);
  39075. var texture = gl.createTexture();
  39076. gl.bindTexture(gl.TEXTURE_2D, texture);
  39077. gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE);
  39078. gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE);
  39079. gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.NEAREST);
  39080. gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.NEAREST);
  39081. gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, gl.RGBA, gl.UNSIGNED_BYTE, image);
  39082. return texture;
  39083. }
  39084. var currentGL, currentCanvas;
  39085. function generateGL() {
  39086. if (currentGL) {
  39087. return;
  39088. }
  39089. currentCanvas = document.createElement('canvas');
  39090. currentGL = currentCanvas.getContext('webgl', { premultipliedalpha: false });
  39091. }
  39092. var smaskVertexShaderCode = '\
  39093. attribute vec2 a_position; \
  39094. attribute vec2 a_texCoord; \
  39095. \
  39096. uniform vec2 u_resolution; \
  39097. \
  39098. varying vec2 v_texCoord; \
  39099. \
  39100. void main() { \
  39101. vec2 clipSpace = (a_position / u_resolution) * 2.0 - 1.0; \
  39102. gl_Position = vec4(clipSpace * vec2(1, -1), 0, 1); \
  39103. \
  39104. v_texCoord = a_texCoord; \
  39105. } ';
  39106. var smaskFragmentShaderCode = '\
  39107. precision mediump float; \
  39108. \
  39109. uniform vec4 u_backdrop; \
  39110. uniform int u_subtype; \
  39111. uniform sampler2D u_image; \
  39112. uniform sampler2D u_mask; \
  39113. \
  39114. varying vec2 v_texCoord; \
  39115. \
  39116. void main() { \
  39117. vec4 imageColor = texture2D(u_image, v_texCoord); \
  39118. vec4 maskColor = texture2D(u_mask, v_texCoord); \
  39119. if (u_backdrop.a > 0.0) { \
  39120. maskColor.rgb = maskColor.rgb * maskColor.a + \
  39121. u_backdrop.rgb * (1.0 - maskColor.a); \
  39122. } \
  39123. float lum; \
  39124. if (u_subtype == 0) { \
  39125. lum = maskColor.a; \
  39126. } else { \
  39127. lum = maskColor.r * 0.3 + maskColor.g * 0.59 + \
  39128. maskColor.b * 0.11; \
  39129. } \
  39130. imageColor.a *= lum; \
  39131. imageColor.rgb *= imageColor.a; \
  39132. gl_FragColor = imageColor; \
  39133. } ';
  39134. var smaskCache = null;
  39135. function initSmaskGL() {
  39136. var canvas, gl;
  39137. generateGL();
  39138. canvas = currentCanvas;
  39139. currentCanvas = null;
  39140. gl = currentGL;
  39141. currentGL = null;
  39142. var vertexShader = createVertexShader(gl, smaskVertexShaderCode);
  39143. var fragmentShader = createFragmentShader(gl, smaskFragmentShaderCode);
  39144. var program = createProgram(gl, [
  39145. vertexShader,
  39146. fragmentShader
  39147. ]);
  39148. gl.useProgram(program);
  39149. var cache = {};
  39150. cache.gl = gl;
  39151. cache.canvas = canvas;
  39152. cache.resolutionLocation = gl.getUniformLocation(program, 'u_resolution');
  39153. cache.positionLocation = gl.getAttribLocation(program, 'a_position');
  39154. cache.backdropLocation = gl.getUniformLocation(program, 'u_backdrop');
  39155. cache.subtypeLocation = gl.getUniformLocation(program, 'u_subtype');
  39156. var texCoordLocation = gl.getAttribLocation(program, 'a_texCoord');
  39157. var texLayerLocation = gl.getUniformLocation(program, 'u_image');
  39158. var texMaskLocation = gl.getUniformLocation(program, 'u_mask');
  39159. var texCoordBuffer = gl.createBuffer();
  39160. gl.bindBuffer(gl.ARRAY_BUFFER, texCoordBuffer);
  39161. gl.bufferData(gl.ARRAY_BUFFER, new Float32Array([
  39162. 0.0,
  39163. 0.0,
  39164. 1.0,
  39165. 0.0,
  39166. 0.0,
  39167. 1.0,
  39168. 0.0,
  39169. 1.0,
  39170. 1.0,
  39171. 0.0,
  39172. 1.0,
  39173. 1.0
  39174. ]), gl.STATIC_DRAW);
  39175. gl.enableVertexAttribArray(texCoordLocation);
  39176. gl.vertexAttribPointer(texCoordLocation, 2, gl.FLOAT, false, 0, 0);
  39177. gl.uniform1i(texLayerLocation, 0);
  39178. gl.uniform1i(texMaskLocation, 1);
  39179. smaskCache = cache;
  39180. }
  39181. function composeSMask(layer, mask, properties) {
  39182. var width = layer.width, height = layer.height;
  39183. if (!smaskCache) {
  39184. initSmaskGL();
  39185. }
  39186. var cache = smaskCache, canvas = cache.canvas, gl = cache.gl;
  39187. canvas.width = width;
  39188. canvas.height = height;
  39189. gl.viewport(0, 0, gl.drawingBufferWidth, gl.drawingBufferHeight);
  39190. gl.uniform2f(cache.resolutionLocation, width, height);
  39191. if (properties.backdrop) {
  39192. gl.uniform4f(cache.resolutionLocation, properties.backdrop[0], properties.backdrop[1], properties.backdrop[2], 1);
  39193. } else {
  39194. gl.uniform4f(cache.resolutionLocation, 0, 0, 0, 0);
  39195. }
  39196. gl.uniform1i(cache.subtypeLocation, properties.subtype === 'Luminosity' ? 1 : 0);
  39197. var texture = createTexture(gl, layer, gl.TEXTURE0);
  39198. var maskTexture = createTexture(gl, mask, gl.TEXTURE1);
  39199. var buffer = gl.createBuffer();
  39200. gl.bindBuffer(gl.ARRAY_BUFFER, buffer);
  39201. gl.bufferData(gl.ARRAY_BUFFER, new Float32Array([
  39202. 0,
  39203. 0,
  39204. width,
  39205. 0,
  39206. 0,
  39207. height,
  39208. 0,
  39209. height,
  39210. width,
  39211. 0,
  39212. width,
  39213. height
  39214. ]), gl.STATIC_DRAW);
  39215. gl.enableVertexAttribArray(cache.positionLocation);
  39216. gl.vertexAttribPointer(cache.positionLocation, 2, gl.FLOAT, false, 0, 0);
  39217. gl.clearColor(0, 0, 0, 0);
  39218. gl.enable(gl.BLEND);
  39219. gl.blendFunc(gl.ONE, gl.ONE_MINUS_SRC_ALPHA);
  39220. gl.clear(gl.COLOR_BUFFER_BIT);
  39221. gl.drawArrays(gl.TRIANGLES, 0, 6);
  39222. gl.flush();
  39223. gl.deleteTexture(texture);
  39224. gl.deleteTexture(maskTexture);
  39225. gl.deleteBuffer(buffer);
  39226. return canvas;
  39227. }
  39228. var figuresVertexShaderCode = '\
  39229. attribute vec2 a_position; \
  39230. attribute vec3 a_color; \
  39231. \
  39232. uniform vec2 u_resolution; \
  39233. uniform vec2 u_scale; \
  39234. uniform vec2 u_offset; \
  39235. \
  39236. varying vec4 v_color; \
  39237. \
  39238. void main() { \
  39239. vec2 position = (a_position + u_offset) * u_scale; \
  39240. vec2 clipSpace = (position / u_resolution) * 2.0 - 1.0; \
  39241. gl_Position = vec4(clipSpace * vec2(1, -1), 0, 1); \
  39242. \
  39243. v_color = vec4(a_color / 255.0, 1.0); \
  39244. } ';
  39245. var figuresFragmentShaderCode = '\
  39246. precision mediump float; \
  39247. \
  39248. varying vec4 v_color; \
  39249. \
  39250. void main() { \
  39251. gl_FragColor = v_color; \
  39252. } ';
  39253. var figuresCache = null;
  39254. function initFiguresGL() {
  39255. var canvas, gl;
  39256. generateGL();
  39257. canvas = currentCanvas;
  39258. currentCanvas = null;
  39259. gl = currentGL;
  39260. currentGL = null;
  39261. var vertexShader = createVertexShader(gl, figuresVertexShaderCode);
  39262. var fragmentShader = createFragmentShader(gl, figuresFragmentShaderCode);
  39263. var program = createProgram(gl, [
  39264. vertexShader,
  39265. fragmentShader
  39266. ]);
  39267. gl.useProgram(program);
  39268. var cache = {};
  39269. cache.gl = gl;
  39270. cache.canvas = canvas;
  39271. cache.resolutionLocation = gl.getUniformLocation(program, 'u_resolution');
  39272. cache.scaleLocation = gl.getUniformLocation(program, 'u_scale');
  39273. cache.offsetLocation = gl.getUniformLocation(program, 'u_offset');
  39274. cache.positionLocation = gl.getAttribLocation(program, 'a_position');
  39275. cache.colorLocation = gl.getAttribLocation(program, 'a_color');
  39276. figuresCache = cache;
  39277. }
  39278. function drawFigures(width, height, backgroundColor, figures, context) {
  39279. if (!figuresCache) {
  39280. initFiguresGL();
  39281. }
  39282. var cache = figuresCache, canvas = cache.canvas, gl = cache.gl;
  39283. canvas.width = width;
  39284. canvas.height = height;
  39285. gl.viewport(0, 0, gl.drawingBufferWidth, gl.drawingBufferHeight);
  39286. gl.uniform2f(cache.resolutionLocation, width, height);
  39287. var count = 0;
  39288. var i, ii, rows;
  39289. for (i = 0, ii = figures.length; i < ii; i++) {
  39290. switch (figures[i].type) {
  39291. case 'lattice':
  39292. rows = figures[i].coords.length / figures[i].verticesPerRow | 0;
  39293. count += (rows - 1) * (figures[i].verticesPerRow - 1) * 6;
  39294. break;
  39295. case 'triangles':
  39296. count += figures[i].coords.length;
  39297. break;
  39298. }
  39299. }
  39300. var coords = new Float32Array(count * 2);
  39301. var colors = new Uint8Array(count * 3);
  39302. var coordsMap = context.coords, colorsMap = context.colors;
  39303. var pIndex = 0, cIndex = 0;
  39304. for (i = 0, ii = figures.length; i < ii; i++) {
  39305. var figure = figures[i], ps = figure.coords, cs = figure.colors;
  39306. switch (figure.type) {
  39307. case 'lattice':
  39308. var cols = figure.verticesPerRow;
  39309. rows = ps.length / cols | 0;
  39310. for (var row = 1; row < rows; row++) {
  39311. var offset = row * cols + 1;
  39312. for (var col = 1; col < cols; col++, offset++) {
  39313. coords[pIndex] = coordsMap[ps[offset - cols - 1]];
  39314. coords[pIndex + 1] = coordsMap[ps[offset - cols - 1] + 1];
  39315. coords[pIndex + 2] = coordsMap[ps[offset - cols]];
  39316. coords[pIndex + 3] = coordsMap[ps[offset - cols] + 1];
  39317. coords[pIndex + 4] = coordsMap[ps[offset - 1]];
  39318. coords[pIndex + 5] = coordsMap[ps[offset - 1] + 1];
  39319. colors[cIndex] = colorsMap[cs[offset - cols - 1]];
  39320. colors[cIndex + 1] = colorsMap[cs[offset - cols - 1] + 1];
  39321. colors[cIndex + 2] = colorsMap[cs[offset - cols - 1] + 2];
  39322. colors[cIndex + 3] = colorsMap[cs[offset - cols]];
  39323. colors[cIndex + 4] = colorsMap[cs[offset - cols] + 1];
  39324. colors[cIndex + 5] = colorsMap[cs[offset - cols] + 2];
  39325. colors[cIndex + 6] = colorsMap[cs[offset - 1]];
  39326. colors[cIndex + 7] = colorsMap[cs[offset - 1] + 1];
  39327. colors[cIndex + 8] = colorsMap[cs[offset - 1] + 2];
  39328. coords[pIndex + 6] = coords[pIndex + 2];
  39329. coords[pIndex + 7] = coords[pIndex + 3];
  39330. coords[pIndex + 8] = coords[pIndex + 4];
  39331. coords[pIndex + 9] = coords[pIndex + 5];
  39332. coords[pIndex + 10] = coordsMap[ps[offset]];
  39333. coords[pIndex + 11] = coordsMap[ps[offset] + 1];
  39334. colors[cIndex + 9] = colors[cIndex + 3];
  39335. colors[cIndex + 10] = colors[cIndex + 4];
  39336. colors[cIndex + 11] = colors[cIndex + 5];
  39337. colors[cIndex + 12] = colors[cIndex + 6];
  39338. colors[cIndex + 13] = colors[cIndex + 7];
  39339. colors[cIndex + 14] = colors[cIndex + 8];
  39340. colors[cIndex + 15] = colorsMap[cs[offset]];
  39341. colors[cIndex + 16] = colorsMap[cs[offset] + 1];
  39342. colors[cIndex + 17] = colorsMap[cs[offset] + 2];
  39343. pIndex += 12;
  39344. cIndex += 18;
  39345. }
  39346. }
  39347. break;
  39348. case 'triangles':
  39349. for (var j = 0, jj = ps.length; j < jj; j++) {
  39350. coords[pIndex] = coordsMap[ps[j]];
  39351. coords[pIndex + 1] = coordsMap[ps[j] + 1];
  39352. colors[cIndex] = colorsMap[cs[j]];
  39353. colors[cIndex + 1] = colorsMap[cs[j] + 1];
  39354. colors[cIndex + 2] = colorsMap[cs[j] + 2];
  39355. pIndex += 2;
  39356. cIndex += 3;
  39357. }
  39358. break;
  39359. }
  39360. }
  39361. if (backgroundColor) {
  39362. gl.clearColor(backgroundColor[0] / 255, backgroundColor[1] / 255, backgroundColor[2] / 255, 1.0);
  39363. } else {
  39364. gl.clearColor(0, 0, 0, 0);
  39365. }
  39366. gl.clear(gl.COLOR_BUFFER_BIT);
  39367. var coordsBuffer = gl.createBuffer();
  39368. gl.bindBuffer(gl.ARRAY_BUFFER, coordsBuffer);
  39369. gl.bufferData(gl.ARRAY_BUFFER, coords, gl.STATIC_DRAW);
  39370. gl.enableVertexAttribArray(cache.positionLocation);
  39371. gl.vertexAttribPointer(cache.positionLocation, 2, gl.FLOAT, false, 0, 0);
  39372. var colorsBuffer = gl.createBuffer();
  39373. gl.bindBuffer(gl.ARRAY_BUFFER, colorsBuffer);
  39374. gl.bufferData(gl.ARRAY_BUFFER, colors, gl.STATIC_DRAW);
  39375. gl.enableVertexAttribArray(cache.colorLocation);
  39376. gl.vertexAttribPointer(cache.colorLocation, 3, gl.UNSIGNED_BYTE, false, 0, 0);
  39377. gl.uniform2f(cache.scaleLocation, context.scaleX, context.scaleY);
  39378. gl.uniform2f(cache.offsetLocation, context.offsetX, context.offsetY);
  39379. gl.drawArrays(gl.TRIANGLES, 0, count);
  39380. gl.flush();
  39381. gl.deleteBuffer(coordsBuffer);
  39382. gl.deleteBuffer(colorsBuffer);
  39383. return canvas;
  39384. }
  39385. function cleanup() {
  39386. if (smaskCache && smaskCache.canvas) {
  39387. smaskCache.canvas.width = 0;
  39388. smaskCache.canvas.height = 0;
  39389. }
  39390. if (figuresCache && figuresCache.canvas) {
  39391. figuresCache.canvas.width = 0;
  39392. figuresCache.canvas.height = 0;
  39393. }
  39394. smaskCache = null;
  39395. figuresCache = null;
  39396. }
  39397. return {
  39398. get isEnabled() {
  39399. if (getDefaultSetting('disableWebGL')) {
  39400. return false;
  39401. }
  39402. var enabled = false;
  39403. try {
  39404. generateGL();
  39405. enabled = !!currentGL;
  39406. } catch (e) {
  39407. }
  39408. return shadow(this, 'isEnabled', enabled);
  39409. },
  39410. composeSMask: composeSMask,
  39411. drawFigures: drawFigures,
  39412. clear: cleanup
  39413. };
  39414. }();
  39415. exports.WebGLUtils = WebGLUtils;
  39416. /***/ }),
  39417. /* 25 */
  39418. /***/ (function(module, exports, __w_pdfjs_require__) {
  39419. "use strict";
  39420. var sharedUtil = __w_pdfjs_require__(0);
  39421. var coreWorker = __w_pdfjs_require__(9);
  39422. var OK_RESPONSE = 200;
  39423. var PARTIAL_CONTENT_RESPONSE = 206;
  39424. function NetworkManager(url, args) {
  39425. this.url = url;
  39426. args = args || {};
  39427. this.isHttp = /^https?:/i.test(url);
  39428. this.httpHeaders = this.isHttp && args.httpHeaders || {};
  39429. this.withCredentials = args.withCredentials || false;
  39430. this.getXhr = args.getXhr || function NetworkManager_getXhr() {
  39431. return new XMLHttpRequest();
  39432. };
  39433. this.currXhrId = 0;
  39434. this.pendingRequests = Object.create(null);
  39435. this.loadedRequests = Object.create(null);
  39436. }
  39437. function getArrayBuffer(xhr) {
  39438. var data = xhr.response;
  39439. if (typeof data !== 'string') {
  39440. return data;
  39441. }
  39442. var length = data.length;
  39443. var array = new Uint8Array(length);
  39444. for (var i = 0; i < length; i++) {
  39445. array[i] = data.charCodeAt(i) & 0xFF;
  39446. }
  39447. return array.buffer;
  39448. }
  39449. var supportsMozChunked = function supportsMozChunkedClosure() {
  39450. try {
  39451. var x = new XMLHttpRequest();
  39452. x.open('GET', 'https://example.com');
  39453. x.responseType = 'moz-chunked-arraybuffer';
  39454. return x.responseType === 'moz-chunked-arraybuffer';
  39455. } catch (e) {
  39456. return false;
  39457. }
  39458. }();
  39459. NetworkManager.prototype = {
  39460. requestRange: function NetworkManager_requestRange(begin, end, listeners) {
  39461. var args = {
  39462. begin: begin,
  39463. end: end
  39464. };
  39465. for (var prop in listeners) {
  39466. args[prop] = listeners[prop];
  39467. }
  39468. return this.request(args);
  39469. },
  39470. requestFull: function NetworkManager_requestFull(listeners) {
  39471. return this.request(listeners);
  39472. },
  39473. request: function NetworkManager_request(args) {
  39474. var xhr = this.getXhr();
  39475. var xhrId = this.currXhrId++;
  39476. var pendingRequest = this.pendingRequests[xhrId] = { xhr: xhr };
  39477. xhr.open('GET', this.url);
  39478. xhr.withCredentials = this.withCredentials;
  39479. for (var property in this.httpHeaders) {
  39480. var value = this.httpHeaders[property];
  39481. if (typeof value === 'undefined') {
  39482. continue;
  39483. }
  39484. xhr.setRequestHeader(property, value);
  39485. }
  39486. if (this.isHttp && 'begin' in args && 'end' in args) {
  39487. var rangeStr = args.begin + '-' + (args.end - 1);
  39488. xhr.setRequestHeader('Range', 'bytes=' + rangeStr);
  39489. pendingRequest.expectedStatus = 206;
  39490. } else {
  39491. pendingRequest.expectedStatus = 200;
  39492. }
  39493. var useMozChunkedLoading = supportsMozChunked && !!args.onProgressiveData;
  39494. if (useMozChunkedLoading) {
  39495. xhr.responseType = 'moz-chunked-arraybuffer';
  39496. pendingRequest.onProgressiveData = args.onProgressiveData;
  39497. pendingRequest.mozChunked = true;
  39498. } else {
  39499. xhr.responseType = 'arraybuffer';
  39500. }
  39501. if (args.onError) {
  39502. xhr.onerror = function (evt) {
  39503. args.onError(xhr.status);
  39504. };
  39505. }
  39506. xhr.onreadystatechange = this.onStateChange.bind(this, xhrId);
  39507. xhr.onprogress = this.onProgress.bind(this, xhrId);
  39508. pendingRequest.onHeadersReceived = args.onHeadersReceived;
  39509. pendingRequest.onDone = args.onDone;
  39510. pendingRequest.onError = args.onError;
  39511. pendingRequest.onProgress = args.onProgress;
  39512. xhr.send(null);
  39513. return xhrId;
  39514. },
  39515. onProgress: function NetworkManager_onProgress(xhrId, evt) {
  39516. var pendingRequest = this.pendingRequests[xhrId];
  39517. if (!pendingRequest) {
  39518. return;
  39519. }
  39520. if (pendingRequest.mozChunked) {
  39521. var chunk = getArrayBuffer(pendingRequest.xhr);
  39522. pendingRequest.onProgressiveData(chunk);
  39523. }
  39524. var onProgress = pendingRequest.onProgress;
  39525. if (onProgress) {
  39526. onProgress(evt);
  39527. }
  39528. },
  39529. onStateChange: function NetworkManager_onStateChange(xhrId, evt) {
  39530. var pendingRequest = this.pendingRequests[xhrId];
  39531. if (!pendingRequest) {
  39532. return;
  39533. }
  39534. var xhr = pendingRequest.xhr;
  39535. if (xhr.readyState >= 2 && pendingRequest.onHeadersReceived) {
  39536. pendingRequest.onHeadersReceived();
  39537. delete pendingRequest.onHeadersReceived;
  39538. }
  39539. if (xhr.readyState !== 4) {
  39540. return;
  39541. }
  39542. if (!(xhrId in this.pendingRequests)) {
  39543. return;
  39544. }
  39545. delete this.pendingRequests[xhrId];
  39546. if (xhr.status === 0 && this.isHttp) {
  39547. if (pendingRequest.onError) {
  39548. pendingRequest.onError(xhr.status);
  39549. }
  39550. return;
  39551. }
  39552. var xhrStatus = xhr.status || OK_RESPONSE;
  39553. var ok_response_on_range_request = xhrStatus === OK_RESPONSE && pendingRequest.expectedStatus === PARTIAL_CONTENT_RESPONSE;
  39554. if (!ok_response_on_range_request && xhrStatus !== pendingRequest.expectedStatus) {
  39555. if (pendingRequest.onError) {
  39556. pendingRequest.onError(xhr.status);
  39557. }
  39558. return;
  39559. }
  39560. this.loadedRequests[xhrId] = true;
  39561. var chunk = getArrayBuffer(xhr);
  39562. if (xhrStatus === PARTIAL_CONTENT_RESPONSE) {
  39563. var rangeHeader = xhr.getResponseHeader('Content-Range');
  39564. var matches = /bytes (\d+)-(\d+)\/(\d+)/.exec(rangeHeader);
  39565. var begin = parseInt(matches[1], 10);
  39566. pendingRequest.onDone({
  39567. begin: begin,
  39568. chunk: chunk
  39569. });
  39570. } else if (pendingRequest.onProgressiveData) {
  39571. pendingRequest.onDone(null);
  39572. } else if (chunk) {
  39573. pendingRequest.onDone({
  39574. begin: 0,
  39575. chunk: chunk
  39576. });
  39577. } else if (pendingRequest.onError) {
  39578. pendingRequest.onError(xhr.status);
  39579. }
  39580. },
  39581. hasPendingRequests: function NetworkManager_hasPendingRequests() {
  39582. for (var xhrId in this.pendingRequests) {
  39583. return true;
  39584. }
  39585. return false;
  39586. },
  39587. getRequestXhr: function NetworkManager_getXhr(xhrId) {
  39588. return this.pendingRequests[xhrId].xhr;
  39589. },
  39590. isStreamingRequest: function NetworkManager_isStreamingRequest(xhrId) {
  39591. return !!this.pendingRequests[xhrId].onProgressiveData;
  39592. },
  39593. isPendingRequest: function NetworkManager_isPendingRequest(xhrId) {
  39594. return xhrId in this.pendingRequests;
  39595. },
  39596. isLoadedRequest: function NetworkManager_isLoadedRequest(xhrId) {
  39597. return xhrId in this.loadedRequests;
  39598. },
  39599. abortAllRequests: function NetworkManager_abortAllRequests() {
  39600. for (var xhrId in this.pendingRequests) {
  39601. this.abortRequest(xhrId | 0);
  39602. }
  39603. },
  39604. abortRequest: function NetworkManager_abortRequest(xhrId) {
  39605. var xhr = this.pendingRequests[xhrId].xhr;
  39606. delete this.pendingRequests[xhrId];
  39607. xhr.abort();
  39608. }
  39609. };
  39610. var assert = sharedUtil.assert;
  39611. var createPromiseCapability = sharedUtil.createPromiseCapability;
  39612. var isInt = sharedUtil.isInt;
  39613. var MissingPDFException = sharedUtil.MissingPDFException;
  39614. var UnexpectedResponseException = sharedUtil.UnexpectedResponseException;
  39615. function PDFNetworkStream(options) {
  39616. this._options = options;
  39617. var source = options.source;
  39618. this._manager = new NetworkManager(source.url, {
  39619. httpHeaders: source.httpHeaders,
  39620. withCredentials: source.withCredentials
  39621. });
  39622. this._rangeChunkSize = source.rangeChunkSize;
  39623. this._fullRequestReader = null;
  39624. this._rangeRequestReaders = [];
  39625. }
  39626. PDFNetworkStream.prototype = {
  39627. _onRangeRequestReaderClosed: function PDFNetworkStream_onRangeRequestReaderClosed(reader) {
  39628. var i = this._rangeRequestReaders.indexOf(reader);
  39629. if (i >= 0) {
  39630. this._rangeRequestReaders.splice(i, 1);
  39631. }
  39632. },
  39633. getFullReader: function PDFNetworkStream_getFullReader() {
  39634. assert(!this._fullRequestReader);
  39635. this._fullRequestReader = new PDFNetworkStreamFullRequestReader(this._manager, this._options);
  39636. return this._fullRequestReader;
  39637. },
  39638. getRangeReader: function PDFNetworkStream_getRangeReader(begin, end) {
  39639. var reader = new PDFNetworkStreamRangeRequestReader(this._manager, begin, end);
  39640. reader.onClosed = this._onRangeRequestReaderClosed.bind(this);
  39641. this._rangeRequestReaders.push(reader);
  39642. return reader;
  39643. },
  39644. cancelAllRequests: function PDFNetworkStream_cancelAllRequests(reason) {
  39645. if (this._fullRequestReader) {
  39646. this._fullRequestReader.cancel(reason);
  39647. }
  39648. var readers = this._rangeRequestReaders.slice(0);
  39649. readers.forEach(function (reader) {
  39650. reader.cancel(reason);
  39651. });
  39652. }
  39653. };
  39654. function PDFNetworkStreamFullRequestReader(manager, options) {
  39655. this._manager = manager;
  39656. var source = options.source;
  39657. var args = {
  39658. onHeadersReceived: this._onHeadersReceived.bind(this),
  39659. onProgressiveData: source.disableStream ? null : this._onProgressiveData.bind(this),
  39660. onDone: this._onDone.bind(this),
  39661. onError: this._onError.bind(this),
  39662. onProgress: this._onProgress.bind(this)
  39663. };
  39664. this._url = source.url;
  39665. this._fullRequestId = manager.requestFull(args);
  39666. this._headersReceivedCapability = createPromiseCapability();
  39667. this._disableRange = options.disableRange || false;
  39668. this._contentLength = source.length;
  39669. this._rangeChunkSize = source.rangeChunkSize;
  39670. if (!this._rangeChunkSize && !this._disableRange) {
  39671. this._disableRange = true;
  39672. }
  39673. this._isStreamingSupported = false;
  39674. this._isRangeSupported = false;
  39675. this._cachedChunks = [];
  39676. this._requests = [];
  39677. this._done = false;
  39678. this._storedError = undefined;
  39679. this.onProgress = null;
  39680. }
  39681. PDFNetworkStreamFullRequestReader.prototype = {
  39682. _validateRangeRequestCapabilities: function PDFNetworkStreamFullRequestReader_validateRangeRequestCapabilities() {
  39683. if (this._disableRange) {
  39684. return false;
  39685. }
  39686. var networkManager = this._manager;
  39687. if (!networkManager.isHttp) {
  39688. return false;
  39689. }
  39690. var fullRequestXhrId = this._fullRequestId;
  39691. var fullRequestXhr = networkManager.getRequestXhr(fullRequestXhrId);
  39692. if (fullRequestXhr.getResponseHeader('Accept-Ranges') !== 'bytes') {
  39693. return false;
  39694. }
  39695. var contentEncoding = fullRequestXhr.getResponseHeader('Content-Encoding') || 'identity';
  39696. if (contentEncoding !== 'identity') {
  39697. return false;
  39698. }
  39699. var length = fullRequestXhr.getResponseHeader('Content-Length');
  39700. length = parseInt(length, 10);
  39701. if (!isInt(length)) {
  39702. return false;
  39703. }
  39704. this._contentLength = length;
  39705. if (length <= 2 * this._rangeChunkSize) {
  39706. return false;
  39707. }
  39708. return true;
  39709. },
  39710. _onHeadersReceived: function PDFNetworkStreamFullRequestReader_onHeadersReceived() {
  39711. if (this._validateRangeRequestCapabilities()) {
  39712. this._isRangeSupported = true;
  39713. }
  39714. var networkManager = this._manager;
  39715. var fullRequestXhrId = this._fullRequestId;
  39716. if (networkManager.isStreamingRequest(fullRequestXhrId)) {
  39717. this._isStreamingSupported = true;
  39718. } else if (this._isRangeSupported) {
  39719. networkManager.abortRequest(fullRequestXhrId);
  39720. }
  39721. this._headersReceivedCapability.resolve();
  39722. },
  39723. _onProgressiveData: function PDFNetworkStreamFullRequestReader_onProgressiveData(chunk) {
  39724. if (this._requests.length > 0) {
  39725. var requestCapability = this._requests.shift();
  39726. requestCapability.resolve({
  39727. value: chunk,
  39728. done: false
  39729. });
  39730. } else {
  39731. this._cachedChunks.push(chunk);
  39732. }
  39733. },
  39734. _onDone: function PDFNetworkStreamFullRequestReader_onDone(args) {
  39735. if (args) {
  39736. this._onProgressiveData(args.chunk);
  39737. }
  39738. this._done = true;
  39739. if (this._cachedChunks.length > 0) {
  39740. return;
  39741. }
  39742. this._requests.forEach(function (requestCapability) {
  39743. requestCapability.resolve({
  39744. value: undefined,
  39745. done: true
  39746. });
  39747. });
  39748. this._requests = [];
  39749. },
  39750. _onError: function PDFNetworkStreamFullRequestReader_onError(status) {
  39751. var url = this._url;
  39752. var exception;
  39753. if (status === 404 || status === 0 && /^file:/.test(url)) {
  39754. exception = new MissingPDFException('Missing PDF "' + url + '".');
  39755. } else {
  39756. exception = new UnexpectedResponseException('Unexpected server response (' + status + ') while retrieving PDF "' + url + '".', status);
  39757. }
  39758. this._storedError = exception;
  39759. this._headersReceivedCapability.reject(exception);
  39760. this._requests.forEach(function (requestCapability) {
  39761. requestCapability.reject(exception);
  39762. });
  39763. this._requests = [];
  39764. this._cachedChunks = [];
  39765. },
  39766. _onProgress: function PDFNetworkStreamFullRequestReader_onProgress(data) {
  39767. if (this.onProgress) {
  39768. this.onProgress({
  39769. loaded: data.loaded,
  39770. total: data.lengthComputable ? data.total : this._contentLength
  39771. });
  39772. }
  39773. },
  39774. get isRangeSupported() {
  39775. return this._isRangeSupported;
  39776. },
  39777. get isStreamingSupported() {
  39778. return this._isStreamingSupported;
  39779. },
  39780. get contentLength() {
  39781. return this._contentLength;
  39782. },
  39783. get headersReady() {
  39784. return this._headersReceivedCapability.promise;
  39785. },
  39786. read: function PDFNetworkStreamFullRequestReader_read() {
  39787. if (this._storedError) {
  39788. return Promise.reject(this._storedError);
  39789. }
  39790. if (this._cachedChunks.length > 0) {
  39791. var chunk = this._cachedChunks.shift();
  39792. return Promise.resolve(chunk);
  39793. }
  39794. if (this._done) {
  39795. return Promise.resolve({
  39796. value: undefined,
  39797. done: true
  39798. });
  39799. }
  39800. var requestCapability = createPromiseCapability();
  39801. this._requests.push(requestCapability);
  39802. return requestCapability.promise;
  39803. },
  39804. cancel: function PDFNetworkStreamFullRequestReader_cancel(reason) {
  39805. this._done = true;
  39806. this._headersReceivedCapability.reject(reason);
  39807. this._requests.forEach(function (requestCapability) {
  39808. requestCapability.resolve({
  39809. value: undefined,
  39810. done: true
  39811. });
  39812. });
  39813. this._requests = [];
  39814. if (this._manager.isPendingRequest(this._fullRequestId)) {
  39815. this._manager.abortRequest(this._fullRequestId);
  39816. }
  39817. this._fullRequestReader = null;
  39818. }
  39819. };
  39820. function PDFNetworkStreamRangeRequestReader(manager, begin, end) {
  39821. this._manager = manager;
  39822. var args = {
  39823. onDone: this._onDone.bind(this),
  39824. onProgress: this._onProgress.bind(this)
  39825. };
  39826. this._requestId = manager.requestRange(begin, end, args);
  39827. this._requests = [];
  39828. this._queuedChunk = null;
  39829. this._done = false;
  39830. this.onProgress = null;
  39831. this.onClosed = null;
  39832. }
  39833. PDFNetworkStreamRangeRequestReader.prototype = {
  39834. _close: function PDFNetworkStreamRangeRequestReader_close() {
  39835. if (this.onClosed) {
  39836. this.onClosed(this);
  39837. }
  39838. },
  39839. _onDone: function PDFNetworkStreamRangeRequestReader_onDone(data) {
  39840. var chunk = data.chunk;
  39841. if (this._requests.length > 0) {
  39842. var requestCapability = this._requests.shift();
  39843. requestCapability.resolve({
  39844. value: chunk,
  39845. done: false
  39846. });
  39847. } else {
  39848. this._queuedChunk = chunk;
  39849. }
  39850. this._done = true;
  39851. this._requests.forEach(function (requestCapability) {
  39852. requestCapability.resolve({
  39853. value: undefined,
  39854. done: true
  39855. });
  39856. });
  39857. this._requests = [];
  39858. this._close();
  39859. },
  39860. _onProgress: function PDFNetworkStreamRangeRequestReader_onProgress(evt) {
  39861. if (!this.isStreamingSupported && this.onProgress) {
  39862. this.onProgress({ loaded: evt.loaded });
  39863. }
  39864. },
  39865. get isStreamingSupported() {
  39866. return false;
  39867. },
  39868. read: function PDFNetworkStreamRangeRequestReader_read() {
  39869. if (this._queuedChunk !== null) {
  39870. var chunk = this._queuedChunk;
  39871. this._queuedChunk = null;
  39872. return Promise.resolve({
  39873. value: chunk,
  39874. done: false
  39875. });
  39876. }
  39877. if (this._done) {
  39878. return Promise.resolve({
  39879. value: undefined,
  39880. done: true
  39881. });
  39882. }
  39883. var requestCapability = createPromiseCapability();
  39884. this._requests.push(requestCapability);
  39885. return requestCapability.promise;
  39886. },
  39887. cancel: function PDFNetworkStreamRangeRequestReader_cancel(reason) {
  39888. this._done = true;
  39889. this._requests.forEach(function (requestCapability) {
  39890. requestCapability.resolve({
  39891. value: undefined,
  39892. done: true
  39893. });
  39894. });
  39895. this._requests = [];
  39896. if (this._manager.isPendingRequest(this._requestId)) {
  39897. this._manager.abortRequest(this._requestId);
  39898. }
  39899. this._close();
  39900. }
  39901. };
  39902. coreWorker.setPDFNetworkStreamClass(PDFNetworkStream);
  39903. exports.PDFNetworkStream = PDFNetworkStream;
  39904. exports.NetworkManager = NetworkManager;
  39905. /***/ }),
  39906. /* 26 */
  39907. /***/ (function(module, exports, __w_pdfjs_require__) {
  39908. "use strict";
  39909. var sharedUtil = __w_pdfjs_require__(0);
  39910. var displayDOMUtils = __w_pdfjs_require__(3);
  39911. var displayAPI = __w_pdfjs_require__(11);
  39912. var displayAnnotationLayer = __w_pdfjs_require__(10);
  39913. var displayTextLayer = __w_pdfjs_require__(13);
  39914. var displayMetadata = __w_pdfjs_require__(23);
  39915. var displaySVG = __w_pdfjs_require__(12);
  39916. var globalScope = sharedUtil.globalScope;
  39917. var deprecated = sharedUtil.deprecated;
  39918. var warn = sharedUtil.warn;
  39919. var LinkTarget = displayDOMUtils.LinkTarget;
  39920. var DEFAULT_LINK_REL = displayDOMUtils.DEFAULT_LINK_REL;
  39921. var isWorker = typeof window === 'undefined';
  39922. if (!globalScope.PDFJS) {
  39923. globalScope.PDFJS = {};
  39924. }
  39925. var PDFJS = globalScope.PDFJS;
  39926. PDFJS.version = '1.7.276';
  39927. PDFJS.build = 'ba81b37b';
  39928. PDFJS.pdfBug = false;
  39929. if (PDFJS.verbosity !== undefined) {
  39930. sharedUtil.setVerbosityLevel(PDFJS.verbosity);
  39931. }
  39932. delete PDFJS.verbosity;
  39933. Object.defineProperty(PDFJS, 'verbosity', {
  39934. get: function () {
  39935. return sharedUtil.getVerbosityLevel();
  39936. },
  39937. set: function (level) {
  39938. sharedUtil.setVerbosityLevel(level);
  39939. },
  39940. enumerable: true,
  39941. configurable: true
  39942. });
  39943. PDFJS.VERBOSITY_LEVELS = sharedUtil.VERBOSITY_LEVELS;
  39944. PDFJS.OPS = sharedUtil.OPS;
  39945. PDFJS.UNSUPPORTED_FEATURES = sharedUtil.UNSUPPORTED_FEATURES;
  39946. PDFJS.isValidUrl = displayDOMUtils.isValidUrl;
  39947. PDFJS.shadow = sharedUtil.shadow;
  39948. PDFJS.createBlob = sharedUtil.createBlob;
  39949. PDFJS.createObjectURL = function PDFJS_createObjectURL(data, contentType) {
  39950. return sharedUtil.createObjectURL(data, contentType, PDFJS.disableCreateObjectURL);
  39951. };
  39952. Object.defineProperty(PDFJS, 'isLittleEndian', {
  39953. configurable: true,
  39954. get: function PDFJS_isLittleEndian() {
  39955. var value = sharedUtil.isLittleEndian();
  39956. return sharedUtil.shadow(PDFJS, 'isLittleEndian', value);
  39957. }
  39958. });
  39959. PDFJS.removeNullCharacters = sharedUtil.removeNullCharacters;
  39960. PDFJS.PasswordResponses = sharedUtil.PasswordResponses;
  39961. PDFJS.PasswordException = sharedUtil.PasswordException;
  39962. PDFJS.UnknownErrorException = sharedUtil.UnknownErrorException;
  39963. PDFJS.InvalidPDFException = sharedUtil.InvalidPDFException;
  39964. PDFJS.MissingPDFException = sharedUtil.MissingPDFException;
  39965. PDFJS.UnexpectedResponseException = sharedUtil.UnexpectedResponseException;
  39966. PDFJS.Util = sharedUtil.Util;
  39967. PDFJS.PageViewport = sharedUtil.PageViewport;
  39968. PDFJS.createPromiseCapability = sharedUtil.createPromiseCapability;
  39969. PDFJS.maxImageSize = PDFJS.maxImageSize === undefined ? -1 : PDFJS.maxImageSize;
  39970. PDFJS.cMapUrl = PDFJS.cMapUrl === undefined ? null : PDFJS.cMapUrl;
  39971. PDFJS.cMapPacked = PDFJS.cMapPacked === undefined ? false : PDFJS.cMapPacked;
  39972. PDFJS.disableFontFace = PDFJS.disableFontFace === undefined ? false : PDFJS.disableFontFace;
  39973. PDFJS.imageResourcesPath = PDFJS.imageResourcesPath === undefined ? '' : PDFJS.imageResourcesPath;
  39974. PDFJS.disableWorker = PDFJS.disableWorker === undefined ? false : PDFJS.disableWorker;
  39975. PDFJS.workerSrc = PDFJS.workerSrc === undefined ? null : PDFJS.workerSrc;
  39976. PDFJS.disableRange = PDFJS.disableRange === undefined ? false : PDFJS.disableRange;
  39977. PDFJS.disableStream = PDFJS.disableStream === undefined ? false : PDFJS.disableStream;
  39978. PDFJS.disableAutoFetch = PDFJS.disableAutoFetch === undefined ? false : PDFJS.disableAutoFetch;
  39979. PDFJS.pdfBug = PDFJS.pdfBug === undefined ? false : PDFJS.pdfBug;
  39980. PDFJS.postMessageTransfers = PDFJS.postMessageTransfers === undefined ? true : PDFJS.postMessageTransfers;
  39981. PDFJS.disableCreateObjectURL = PDFJS.disableCreateObjectURL === undefined ? false : PDFJS.disableCreateObjectURL;
  39982. PDFJS.disableWebGL = PDFJS.disableWebGL === undefined ? true : PDFJS.disableWebGL;
  39983. PDFJS.externalLinkTarget = PDFJS.externalLinkTarget === undefined ? LinkTarget.NONE : PDFJS.externalLinkTarget;
  39984. PDFJS.externalLinkRel = PDFJS.externalLinkRel === undefined ? DEFAULT_LINK_REL : PDFJS.externalLinkRel;
  39985. PDFJS.isEvalSupported = PDFJS.isEvalSupported === undefined ? true : PDFJS.isEvalSupported;
  39986. var savedOpenExternalLinksInNewWindow = PDFJS.openExternalLinksInNewWindow;
  39987. delete PDFJS.openExternalLinksInNewWindow;
  39988. Object.defineProperty(PDFJS, 'openExternalLinksInNewWindow', {
  39989. get: function () {
  39990. return PDFJS.externalLinkTarget === LinkTarget.BLANK;
  39991. },
  39992. set: function (value) {
  39993. if (value) {
  39994. deprecated('PDFJS.openExternalLinksInNewWindow, please use ' + '"PDFJS.externalLinkTarget = PDFJS.LinkTarget.BLANK" instead.');
  39995. }
  39996. if (PDFJS.externalLinkTarget !== LinkTarget.NONE) {
  39997. warn('PDFJS.externalLinkTarget is already initialized');
  39998. return;
  39999. }
  40000. PDFJS.externalLinkTarget = value ? LinkTarget.BLANK : LinkTarget.NONE;
  40001. },
  40002. enumerable: true,
  40003. configurable: true
  40004. });
  40005. if (savedOpenExternalLinksInNewWindow) {
  40006. PDFJS.openExternalLinksInNewWindow = savedOpenExternalLinksInNewWindow;
  40007. }
  40008. PDFJS.getDocument = displayAPI.getDocument;
  40009. PDFJS.PDFDataRangeTransport = displayAPI.PDFDataRangeTransport;
  40010. PDFJS.PDFWorker = displayAPI.PDFWorker;
  40011. Object.defineProperty(PDFJS, 'hasCanvasTypedArrays', {
  40012. configurable: true,
  40013. get: function PDFJS_hasCanvasTypedArrays() {
  40014. var value = displayDOMUtils.hasCanvasTypedArrays();
  40015. return sharedUtil.shadow(PDFJS, 'hasCanvasTypedArrays', value);
  40016. }
  40017. });
  40018. PDFJS.CustomStyle = displayDOMUtils.CustomStyle;
  40019. PDFJS.LinkTarget = LinkTarget;
  40020. PDFJS.addLinkAttributes = displayDOMUtils.addLinkAttributes;
  40021. PDFJS.getFilenameFromUrl = displayDOMUtils.getFilenameFromUrl;
  40022. PDFJS.isExternalLinkTargetSet = displayDOMUtils.isExternalLinkTargetSet;
  40023. PDFJS.AnnotationLayer = displayAnnotationLayer.AnnotationLayer;
  40024. PDFJS.renderTextLayer = displayTextLayer.renderTextLayer;
  40025. PDFJS.Metadata = displayMetadata.Metadata;
  40026. PDFJS.SVGGraphics = displaySVG.SVGGraphics;
  40027. PDFJS.UnsupportedManager = displayAPI._UnsupportedManager;
  40028. exports.globalScope = globalScope;
  40029. exports.isWorker = isWorker;
  40030. exports.PDFJS = globalScope.PDFJS;
  40031. /***/ }),
  40032. /* 27 */
  40033. /***/ (function(module, exports) {
  40034. var g;
  40035. g = function () {
  40036. return this;
  40037. }();
  40038. try {
  40039. g = g || Function("return this")() || (1, eval)("this");
  40040. } catch (e) {
  40041. if (typeof window === "object")
  40042. g = window;
  40043. }
  40044. module.exports = g;
  40045. /***/ }),
  40046. /* 28 */
  40047. /***/ (function(module, exports) {
  40048. module.exports = function (module) {
  40049. if (!module.webpackPolyfill) {
  40050. module.deprecate = function () {
  40051. };
  40052. module.paths = [];
  40053. if (!module.children)
  40054. module.children = [];
  40055. Object.defineProperty(module, "loaded", {
  40056. enumerable: true,
  40057. get: function () {
  40058. return module.l;
  40059. }
  40060. });
  40061. Object.defineProperty(module, "id", {
  40062. enumerable: true,
  40063. get: function () {
  40064. return module.i;
  40065. }
  40066. });
  40067. module.webpackPolyfill = 1;
  40068. }
  40069. return module;
  40070. };
  40071. /***/ }),
  40072. /* 29 */
  40073. /***/ (function(module, exports, __w_pdfjs_require__) {
  40074. "use strict";
  40075. var sharedUtil = __w_pdfjs_require__(0);
  40076. var corePrimitives = __w_pdfjs_require__(1);
  40077. var coreStream = __w_pdfjs_require__(2);
  40078. var coreColorSpace = __w_pdfjs_require__(4);
  40079. var coreObj = __w_pdfjs_require__(20);
  40080. var coreEvaluator = __w_pdfjs_require__(18);
  40081. var AnnotationBorderStyleType = sharedUtil.AnnotationBorderStyleType;
  40082. var AnnotationFieldFlag = sharedUtil.AnnotationFieldFlag;
  40083. var AnnotationFlag = sharedUtil.AnnotationFlag;
  40084. var AnnotationType = sharedUtil.AnnotationType;
  40085. var OPS = sharedUtil.OPS;
  40086. var Util = sharedUtil.Util;
  40087. var isArray = sharedUtil.isArray;
  40088. var isInt = sharedUtil.isInt;
  40089. var stringToBytes = sharedUtil.stringToBytes;
  40090. var stringToPDFString = sharedUtil.stringToPDFString;
  40091. var warn = sharedUtil.warn;
  40092. var Dict = corePrimitives.Dict;
  40093. var isDict = corePrimitives.isDict;
  40094. var isName = corePrimitives.isName;
  40095. var isRef = corePrimitives.isRef;
  40096. var Stream = coreStream.Stream;
  40097. var ColorSpace = coreColorSpace.ColorSpace;
  40098. var Catalog = coreObj.Catalog;
  40099. var ObjectLoader = coreObj.ObjectLoader;
  40100. var FileSpec = coreObj.FileSpec;
  40101. var OperatorList = coreEvaluator.OperatorList;
  40102. function AnnotationFactory() {
  40103. }
  40104. AnnotationFactory.prototype = {
  40105. create: function AnnotationFactory_create(xref, ref, pdfManager, idFactory) {
  40106. var dict = xref.fetchIfRef(ref);
  40107. if (!isDict(dict)) {
  40108. return;
  40109. }
  40110. var id = isRef(ref) ? ref.toString() : 'annot_' + idFactory.createObjId();
  40111. var subtype = dict.get('Subtype');
  40112. subtype = isName(subtype) ? subtype.name : null;
  40113. var parameters = {
  40114. xref: xref,
  40115. dict: dict,
  40116. ref: isRef(ref) ? ref : null,
  40117. subtype: subtype,
  40118. id: id,
  40119. pdfManager: pdfManager
  40120. };
  40121. switch (subtype) {
  40122. case 'Link':
  40123. return new LinkAnnotation(parameters);
  40124. case 'Text':
  40125. return new TextAnnotation(parameters);
  40126. case 'Widget':
  40127. var fieldType = Util.getInheritableProperty(dict, 'FT');
  40128. fieldType = isName(fieldType) ? fieldType.name : null;
  40129. switch (fieldType) {
  40130. case 'Tx':
  40131. return new TextWidgetAnnotation(parameters);
  40132. case 'Btn':
  40133. return new ButtonWidgetAnnotation(parameters);
  40134. case 'Ch':
  40135. return new ChoiceWidgetAnnotation(parameters);
  40136. }
  40137. warn('Unimplemented widget field type "' + fieldType + '", ' + 'falling back to base field type.');
  40138. return new WidgetAnnotation(parameters);
  40139. case 'Popup':
  40140. return new PopupAnnotation(parameters);
  40141. case 'Highlight':
  40142. return new HighlightAnnotation(parameters);
  40143. case 'Underline':
  40144. return new UnderlineAnnotation(parameters);
  40145. case 'Squiggly':
  40146. return new SquigglyAnnotation(parameters);
  40147. case 'StrikeOut':
  40148. return new StrikeOutAnnotation(parameters);
  40149. case 'FileAttachment':
  40150. return new FileAttachmentAnnotation(parameters);
  40151. default:
  40152. if (!subtype) {
  40153. warn('Annotation is missing the required /Subtype.');
  40154. } else {
  40155. warn('Unimplemented annotation type "' + subtype + '", ' + 'falling back to base annotation.');
  40156. }
  40157. return new Annotation(parameters);
  40158. }
  40159. }
  40160. };
  40161. var Annotation = function AnnotationClosure() {
  40162. function getTransformMatrix(rect, bbox, matrix) {
  40163. var bounds = Util.getAxialAlignedBoundingBox(bbox, matrix);
  40164. var minX = bounds[0];
  40165. var minY = bounds[1];
  40166. var maxX = bounds[2];
  40167. var maxY = bounds[3];
  40168. if (minX === maxX || minY === maxY) {
  40169. return [
  40170. 1,
  40171. 0,
  40172. 0,
  40173. 1,
  40174. rect[0],
  40175. rect[1]
  40176. ];
  40177. }
  40178. var xRatio = (rect[2] - rect[0]) / (maxX - minX);
  40179. var yRatio = (rect[3] - rect[1]) / (maxY - minY);
  40180. return [
  40181. xRatio,
  40182. 0,
  40183. 0,
  40184. yRatio,
  40185. rect[0] - minX * xRatio,
  40186. rect[1] - minY * yRatio
  40187. ];
  40188. }
  40189. function getDefaultAppearance(dict) {
  40190. var appearanceState = dict.get('AP');
  40191. if (!isDict(appearanceState)) {
  40192. return;
  40193. }
  40194. var appearance;
  40195. var appearances = appearanceState.get('N');
  40196. if (isDict(appearances)) {
  40197. var as = dict.get('AS');
  40198. if (as && appearances.has(as.name)) {
  40199. appearance = appearances.get(as.name);
  40200. }
  40201. } else {
  40202. appearance = appearances;
  40203. }
  40204. return appearance;
  40205. }
  40206. function Annotation(params) {
  40207. var dict = params.dict;
  40208. this.setFlags(dict.get('F'));
  40209. this.setRectangle(dict.getArray('Rect'));
  40210. this.setColor(dict.getArray('C'));
  40211. this.setBorderStyle(dict);
  40212. this.appearance = getDefaultAppearance(dict);
  40213. this.data = {};
  40214. this.data.id = params.id;
  40215. this.data.subtype = params.subtype;
  40216. this.data.annotationFlags = this.flags;
  40217. this.data.rect = this.rectangle;
  40218. this.data.color = this.color;
  40219. this.data.borderStyle = this.borderStyle;
  40220. this.data.hasAppearance = !!this.appearance;
  40221. }
  40222. Annotation.prototype = {
  40223. _hasFlag: function Annotation_hasFlag(flags, flag) {
  40224. return !!(flags & flag);
  40225. },
  40226. _isViewable: function Annotation_isViewable(flags) {
  40227. return !this._hasFlag(flags, AnnotationFlag.INVISIBLE) && !this._hasFlag(flags, AnnotationFlag.HIDDEN) && !this._hasFlag(flags, AnnotationFlag.NOVIEW);
  40228. },
  40229. _isPrintable: function AnnotationFlag_isPrintable(flags) {
  40230. return this._hasFlag(flags, AnnotationFlag.PRINT) && !this._hasFlag(flags, AnnotationFlag.INVISIBLE) && !this._hasFlag(flags, AnnotationFlag.HIDDEN);
  40231. },
  40232. get viewable() {
  40233. if (this.flags === 0) {
  40234. return true;
  40235. }
  40236. return this._isViewable(this.flags);
  40237. },
  40238. get printable() {
  40239. if (this.flags === 0) {
  40240. return false;
  40241. }
  40242. return this._isPrintable(this.flags);
  40243. },
  40244. setFlags: function Annotation_setFlags(flags) {
  40245. this.flags = isInt(flags) && flags > 0 ? flags : 0;
  40246. },
  40247. hasFlag: function Annotation_hasFlag(flag) {
  40248. return this._hasFlag(this.flags, flag);
  40249. },
  40250. setRectangle: function Annotation_setRectangle(rectangle) {
  40251. if (isArray(rectangle) && rectangle.length === 4) {
  40252. this.rectangle = Util.normalizeRect(rectangle);
  40253. } else {
  40254. this.rectangle = [
  40255. 0,
  40256. 0,
  40257. 0,
  40258. 0
  40259. ];
  40260. }
  40261. },
  40262. setColor: function Annotation_setColor(color) {
  40263. var rgbColor = new Uint8Array(3);
  40264. if (!isArray(color)) {
  40265. this.color = rgbColor;
  40266. return;
  40267. }
  40268. switch (color.length) {
  40269. case 0:
  40270. this.color = null;
  40271. break;
  40272. case 1:
  40273. ColorSpace.singletons.gray.getRgbItem(color, 0, rgbColor, 0);
  40274. this.color = rgbColor;
  40275. break;
  40276. case 3:
  40277. ColorSpace.singletons.rgb.getRgbItem(color, 0, rgbColor, 0);
  40278. this.color = rgbColor;
  40279. break;
  40280. case 4:
  40281. ColorSpace.singletons.cmyk.getRgbItem(color, 0, rgbColor, 0);
  40282. this.color = rgbColor;
  40283. break;
  40284. default:
  40285. this.color = rgbColor;
  40286. break;
  40287. }
  40288. },
  40289. setBorderStyle: function Annotation_setBorderStyle(borderStyle) {
  40290. this.borderStyle = new AnnotationBorderStyle();
  40291. if (!isDict(borderStyle)) {
  40292. return;
  40293. }
  40294. if (borderStyle.has('BS')) {
  40295. var dict = borderStyle.get('BS');
  40296. var dictType = dict.get('Type');
  40297. if (!dictType || isName(dictType, 'Border')) {
  40298. this.borderStyle.setWidth(dict.get('W'));
  40299. this.borderStyle.setStyle(dict.get('S'));
  40300. this.borderStyle.setDashArray(dict.getArray('D'));
  40301. }
  40302. } else if (borderStyle.has('Border')) {
  40303. var array = borderStyle.getArray('Border');
  40304. if (isArray(array) && array.length >= 3) {
  40305. this.borderStyle.setHorizontalCornerRadius(array[0]);
  40306. this.borderStyle.setVerticalCornerRadius(array[1]);
  40307. this.borderStyle.setWidth(array[2]);
  40308. if (array.length === 4) {
  40309. this.borderStyle.setDashArray(array[3]);
  40310. }
  40311. }
  40312. } else {
  40313. this.borderStyle.setWidth(0);
  40314. }
  40315. },
  40316. _preparePopup: function Annotation_preparePopup(dict) {
  40317. if (!dict.has('C')) {
  40318. this.data.color = null;
  40319. }
  40320. this.data.hasPopup = dict.has('Popup');
  40321. this.data.title = stringToPDFString(dict.get('T') || '');
  40322. this.data.contents = stringToPDFString(dict.get('Contents') || '');
  40323. },
  40324. loadResources: function Annotation_loadResources(keys) {
  40325. return new Promise(function (resolve, reject) {
  40326. this.appearance.dict.getAsync('Resources').then(function (resources) {
  40327. if (!resources) {
  40328. resolve();
  40329. return;
  40330. }
  40331. var objectLoader = new ObjectLoader(resources.map, keys, resources.xref);
  40332. objectLoader.load().then(function () {
  40333. resolve(resources);
  40334. }, reject);
  40335. }, reject);
  40336. }.bind(this));
  40337. },
  40338. getOperatorList: function Annotation_getOperatorList(evaluator, task, renderForms) {
  40339. if (!this.appearance) {
  40340. return Promise.resolve(new OperatorList());
  40341. }
  40342. var data = this.data;
  40343. var appearanceDict = this.appearance.dict;
  40344. var resourcesPromise = this.loadResources([
  40345. 'ExtGState',
  40346. 'ColorSpace',
  40347. 'Pattern',
  40348. 'Shading',
  40349. 'XObject',
  40350. 'Font'
  40351. ]);
  40352. var bbox = appearanceDict.getArray('BBox') || [
  40353. 0,
  40354. 0,
  40355. 1,
  40356. 1
  40357. ];
  40358. var matrix = appearanceDict.getArray('Matrix') || [
  40359. 1,
  40360. 0,
  40361. 0,
  40362. 1,
  40363. 0,
  40364. 0
  40365. ];
  40366. var transform = getTransformMatrix(data.rect, bbox, matrix);
  40367. var self = this;
  40368. return resourcesPromise.then(function (resources) {
  40369. var opList = new OperatorList();
  40370. opList.addOp(OPS.beginAnnotation, [
  40371. data.rect,
  40372. transform,
  40373. matrix
  40374. ]);
  40375. return evaluator.getOperatorList(self.appearance, task, resources, opList).then(function () {
  40376. opList.addOp(OPS.endAnnotation, []);
  40377. self.appearance.reset();
  40378. return opList;
  40379. });
  40380. });
  40381. }
  40382. };
  40383. Annotation.appendToOperatorList = function Annotation_appendToOperatorList(annotations, opList, partialEvaluator, task, intent, renderForms) {
  40384. var annotationPromises = [];
  40385. for (var i = 0, n = annotations.length; i < n; ++i) {
  40386. if (intent === 'display' && annotations[i].viewable || intent === 'print' && annotations[i].printable) {
  40387. annotationPromises.push(annotations[i].getOperatorList(partialEvaluator, task, renderForms));
  40388. }
  40389. }
  40390. return Promise.all(annotationPromises).then(function (operatorLists) {
  40391. opList.addOp(OPS.beginAnnotations, []);
  40392. for (var i = 0, n = operatorLists.length; i < n; ++i) {
  40393. opList.addOpList(operatorLists[i]);
  40394. }
  40395. opList.addOp(OPS.endAnnotations, []);
  40396. });
  40397. };
  40398. return Annotation;
  40399. }();
  40400. var AnnotationBorderStyle = function AnnotationBorderStyleClosure() {
  40401. function AnnotationBorderStyle() {
  40402. this.width = 1;
  40403. this.style = AnnotationBorderStyleType.SOLID;
  40404. this.dashArray = [3];
  40405. this.horizontalCornerRadius = 0;
  40406. this.verticalCornerRadius = 0;
  40407. }
  40408. AnnotationBorderStyle.prototype = {
  40409. setWidth: function AnnotationBorderStyle_setWidth(width) {
  40410. if (width === (width | 0)) {
  40411. this.width = width;
  40412. }
  40413. },
  40414. setStyle: function AnnotationBorderStyle_setStyle(style) {
  40415. if (!style) {
  40416. return;
  40417. }
  40418. switch (style.name) {
  40419. case 'S':
  40420. this.style = AnnotationBorderStyleType.SOLID;
  40421. break;
  40422. case 'D':
  40423. this.style = AnnotationBorderStyleType.DASHED;
  40424. break;
  40425. case 'B':
  40426. this.style = AnnotationBorderStyleType.BEVELED;
  40427. break;
  40428. case 'I':
  40429. this.style = AnnotationBorderStyleType.INSET;
  40430. break;
  40431. case 'U':
  40432. this.style = AnnotationBorderStyleType.UNDERLINE;
  40433. break;
  40434. default:
  40435. break;
  40436. }
  40437. },
  40438. setDashArray: function AnnotationBorderStyle_setDashArray(dashArray) {
  40439. if (isArray(dashArray) && dashArray.length > 0) {
  40440. var isValid = true;
  40441. var allZeros = true;
  40442. for (var i = 0, len = dashArray.length; i < len; i++) {
  40443. var element = dashArray[i];
  40444. var validNumber = +element >= 0;
  40445. if (!validNumber) {
  40446. isValid = false;
  40447. break;
  40448. } else if (element > 0) {
  40449. allZeros = false;
  40450. }
  40451. }
  40452. if (isValid && !allZeros) {
  40453. this.dashArray = dashArray;
  40454. } else {
  40455. this.width = 0;
  40456. }
  40457. } else if (dashArray) {
  40458. this.width = 0;
  40459. }
  40460. },
  40461. setHorizontalCornerRadius: function AnnotationBorderStyle_setHorizontalCornerRadius(radius) {
  40462. if (radius === (radius | 0)) {
  40463. this.horizontalCornerRadius = radius;
  40464. }
  40465. },
  40466. setVerticalCornerRadius: function AnnotationBorderStyle_setVerticalCornerRadius(radius) {
  40467. if (radius === (radius | 0)) {
  40468. this.verticalCornerRadius = radius;
  40469. }
  40470. }
  40471. };
  40472. return AnnotationBorderStyle;
  40473. }();
  40474. var WidgetAnnotation = function WidgetAnnotationClosure() {
  40475. function WidgetAnnotation(params) {
  40476. Annotation.call(this, params);
  40477. var dict = params.dict;
  40478. var data = this.data;
  40479. data.annotationType = AnnotationType.WIDGET;
  40480. data.fieldName = this._constructFieldName(dict);
  40481. data.fieldValue = Util.getInheritableProperty(dict, 'V', true);
  40482. data.alternativeText = stringToPDFString(dict.get('TU') || '');
  40483. data.defaultAppearance = Util.getInheritableProperty(dict, 'DA') || '';
  40484. var fieldType = Util.getInheritableProperty(dict, 'FT');
  40485. data.fieldType = isName(fieldType) ? fieldType.name : null;
  40486. this.fieldResources = Util.getInheritableProperty(dict, 'DR') || Dict.empty;
  40487. data.fieldFlags = Util.getInheritableProperty(dict, 'Ff');
  40488. if (!isInt(data.fieldFlags) || data.fieldFlags < 0) {
  40489. data.fieldFlags = 0;
  40490. }
  40491. data.readOnly = this.hasFieldFlag(AnnotationFieldFlag.READONLY);
  40492. if (data.fieldType === 'Sig') {
  40493. this.setFlags(AnnotationFlag.HIDDEN);
  40494. }
  40495. }
  40496. Util.inherit(WidgetAnnotation, Annotation, {
  40497. _constructFieldName: function WidgetAnnotation_constructFieldName(dict) {
  40498. if (!dict.has('T') && !dict.has('Parent')) {
  40499. warn('Unknown field name, falling back to empty field name.');
  40500. return '';
  40501. }
  40502. if (!dict.has('Parent')) {
  40503. return stringToPDFString(dict.get('T'));
  40504. }
  40505. var fieldName = [];
  40506. if (dict.has('T')) {
  40507. fieldName.unshift(stringToPDFString(dict.get('T')));
  40508. }
  40509. var loopDict = dict;
  40510. while (loopDict.has('Parent')) {
  40511. loopDict = loopDict.get('Parent');
  40512. if (loopDict.has('T')) {
  40513. fieldName.unshift(stringToPDFString(loopDict.get('T')));
  40514. }
  40515. }
  40516. return fieldName.join('.');
  40517. },
  40518. hasFieldFlag: function WidgetAnnotation_hasFieldFlag(flag) {
  40519. return !!(this.data.fieldFlags & flag);
  40520. }
  40521. });
  40522. return WidgetAnnotation;
  40523. }();
  40524. var TextWidgetAnnotation = function TextWidgetAnnotationClosure() {
  40525. function TextWidgetAnnotation(params) {
  40526. WidgetAnnotation.call(this, params);
  40527. this.data.fieldValue = stringToPDFString(this.data.fieldValue || '');
  40528. var alignment = Util.getInheritableProperty(params.dict, 'Q');
  40529. if (!isInt(alignment) || alignment < 0 || alignment > 2) {
  40530. alignment = null;
  40531. }
  40532. this.data.textAlignment = alignment;
  40533. var maximumLength = Util.getInheritableProperty(params.dict, 'MaxLen');
  40534. if (!isInt(maximumLength) || maximumLength < 0) {
  40535. maximumLength = null;
  40536. }
  40537. this.data.maxLen = maximumLength;
  40538. this.data.multiLine = this.hasFieldFlag(AnnotationFieldFlag.MULTILINE);
  40539. this.data.comb = this.hasFieldFlag(AnnotationFieldFlag.COMB) && !this.hasFieldFlag(AnnotationFieldFlag.MULTILINE) && !this.hasFieldFlag(AnnotationFieldFlag.PASSWORD) && !this.hasFieldFlag(AnnotationFieldFlag.FILESELECT) && this.data.maxLen !== null;
  40540. }
  40541. Util.inherit(TextWidgetAnnotation, WidgetAnnotation, {
  40542. getOperatorList: function TextWidgetAnnotation_getOperatorList(evaluator, task, renderForms) {
  40543. var operatorList = new OperatorList();
  40544. if (renderForms) {
  40545. return Promise.resolve(operatorList);
  40546. }
  40547. if (this.appearance) {
  40548. return Annotation.prototype.getOperatorList.call(this, evaluator, task, renderForms);
  40549. }
  40550. if (!this.data.defaultAppearance) {
  40551. return Promise.resolve(operatorList);
  40552. }
  40553. var stream = new Stream(stringToBytes(this.data.defaultAppearance));
  40554. return evaluator.getOperatorList(stream, task, this.fieldResources, operatorList).then(function () {
  40555. return operatorList;
  40556. });
  40557. }
  40558. });
  40559. return TextWidgetAnnotation;
  40560. }();
  40561. var ButtonWidgetAnnotation = function ButtonWidgetAnnotationClosure() {
  40562. function ButtonWidgetAnnotation(params) {
  40563. WidgetAnnotation.call(this, params);
  40564. this.data.checkBox = !this.hasFieldFlag(AnnotationFieldFlag.RADIO) && !this.hasFieldFlag(AnnotationFieldFlag.PUSHBUTTON);
  40565. if (this.data.checkBox) {
  40566. if (!isName(this.data.fieldValue)) {
  40567. return;
  40568. }
  40569. this.data.fieldValue = this.data.fieldValue.name;
  40570. }
  40571. this.data.radioButton = this.hasFieldFlag(AnnotationFieldFlag.RADIO) && !this.hasFieldFlag(AnnotationFieldFlag.PUSHBUTTON);
  40572. if (this.data.radioButton) {
  40573. this.data.fieldValue = this.data.buttonValue = null;
  40574. var fieldParent = params.dict.get('Parent');
  40575. if (isDict(fieldParent) && fieldParent.has('V')) {
  40576. var fieldParentValue = fieldParent.get('V');
  40577. if (isName(fieldParentValue)) {
  40578. this.data.fieldValue = fieldParentValue.name;
  40579. }
  40580. }
  40581. var appearanceStates = params.dict.get('AP');
  40582. if (!isDict(appearanceStates)) {
  40583. return;
  40584. }
  40585. var normalAppearanceState = appearanceStates.get('N');
  40586. if (!isDict(normalAppearanceState)) {
  40587. return;
  40588. }
  40589. var keys = normalAppearanceState.getKeys();
  40590. for (var i = 0, ii = keys.length; i < ii; i++) {
  40591. if (keys[i] !== 'Off') {
  40592. this.data.buttonValue = keys[i];
  40593. break;
  40594. }
  40595. }
  40596. }
  40597. }
  40598. Util.inherit(ButtonWidgetAnnotation, WidgetAnnotation, {
  40599. getOperatorList: function ButtonWidgetAnnotation_getOperatorList(evaluator, task, renderForms) {
  40600. var operatorList = new OperatorList();
  40601. if (renderForms) {
  40602. return Promise.resolve(operatorList);
  40603. }
  40604. if (this.appearance) {
  40605. return Annotation.prototype.getOperatorList.call(this, evaluator, task, renderForms);
  40606. }
  40607. return Promise.resolve(operatorList);
  40608. }
  40609. });
  40610. return ButtonWidgetAnnotation;
  40611. }();
  40612. var ChoiceWidgetAnnotation = function ChoiceWidgetAnnotationClosure() {
  40613. function ChoiceWidgetAnnotation(params) {
  40614. WidgetAnnotation.call(this, params);
  40615. this.data.options = [];
  40616. var options = params.dict.get('Opt');
  40617. if (isArray(options)) {
  40618. var xref = params.xref;
  40619. for (var i = 0, ii = options.length; i < ii; i++) {
  40620. var option = xref.fetchIfRef(options[i]);
  40621. var isOptionArray = isArray(option);
  40622. this.data.options[i] = {
  40623. exportValue: isOptionArray ? xref.fetchIfRef(option[0]) : option,
  40624. displayValue: isOptionArray ? xref.fetchIfRef(option[1]) : option
  40625. };
  40626. }
  40627. }
  40628. if (!isArray(this.data.fieldValue)) {
  40629. this.data.fieldValue = [this.data.fieldValue];
  40630. }
  40631. this.data.combo = this.hasFieldFlag(AnnotationFieldFlag.COMBO);
  40632. this.data.multiSelect = this.hasFieldFlag(AnnotationFieldFlag.MULTISELECT);
  40633. }
  40634. Util.inherit(ChoiceWidgetAnnotation, WidgetAnnotation, {
  40635. getOperatorList: function ChoiceWidgetAnnotation_getOperatorList(evaluator, task, renderForms) {
  40636. var operatorList = new OperatorList();
  40637. if (renderForms) {
  40638. return Promise.resolve(operatorList);
  40639. }
  40640. return Annotation.prototype.getOperatorList.call(this, evaluator, task, renderForms);
  40641. }
  40642. });
  40643. return ChoiceWidgetAnnotation;
  40644. }();
  40645. var TextAnnotation = function TextAnnotationClosure() {
  40646. var DEFAULT_ICON_SIZE = 22;
  40647. function TextAnnotation(parameters) {
  40648. Annotation.call(this, parameters);
  40649. this.data.annotationType = AnnotationType.TEXT;
  40650. if (this.data.hasAppearance) {
  40651. this.data.name = 'NoIcon';
  40652. } else {
  40653. this.data.rect[1] = this.data.rect[3] - DEFAULT_ICON_SIZE;
  40654. this.data.rect[2] = this.data.rect[0] + DEFAULT_ICON_SIZE;
  40655. this.data.name = parameters.dict.has('Name') ? parameters.dict.get('Name').name : 'Note';
  40656. }
  40657. this._preparePopup(parameters.dict);
  40658. }
  40659. Util.inherit(TextAnnotation, Annotation, {});
  40660. return TextAnnotation;
  40661. }();
  40662. var LinkAnnotation = function LinkAnnotationClosure() {
  40663. function LinkAnnotation(params) {
  40664. Annotation.call(this, params);
  40665. var data = this.data;
  40666. data.annotationType = AnnotationType.LINK;
  40667. Catalog.parseDestDictionary({
  40668. destDict: params.dict,
  40669. resultObj: data,
  40670. docBaseUrl: params.pdfManager.docBaseUrl
  40671. });
  40672. }
  40673. Util.inherit(LinkAnnotation, Annotation, {});
  40674. return LinkAnnotation;
  40675. }();
  40676. var PopupAnnotation = function PopupAnnotationClosure() {
  40677. function PopupAnnotation(parameters) {
  40678. Annotation.call(this, parameters);
  40679. this.data.annotationType = AnnotationType.POPUP;
  40680. var dict = parameters.dict;
  40681. var parentItem = dict.get('Parent');
  40682. if (!parentItem) {
  40683. warn('Popup annotation has a missing or invalid parent annotation.');
  40684. return;
  40685. }
  40686. this.data.parentId = dict.getRaw('Parent').toString();
  40687. this.data.title = stringToPDFString(parentItem.get('T') || '');
  40688. this.data.contents = stringToPDFString(parentItem.get('Contents') || '');
  40689. if (!parentItem.has('C')) {
  40690. this.data.color = null;
  40691. } else {
  40692. this.setColor(parentItem.getArray('C'));
  40693. this.data.color = this.color;
  40694. }
  40695. if (!this.viewable) {
  40696. var parentFlags = parentItem.get('F');
  40697. if (this._isViewable(parentFlags)) {
  40698. this.setFlags(parentFlags);
  40699. }
  40700. }
  40701. }
  40702. Util.inherit(PopupAnnotation, Annotation, {});
  40703. return PopupAnnotation;
  40704. }();
  40705. var HighlightAnnotation = function HighlightAnnotationClosure() {
  40706. function HighlightAnnotation(parameters) {
  40707. Annotation.call(this, parameters);
  40708. this.data.annotationType = AnnotationType.HIGHLIGHT;
  40709. this._preparePopup(parameters.dict);
  40710. this.data.borderStyle.setWidth(0);
  40711. }
  40712. Util.inherit(HighlightAnnotation, Annotation, {});
  40713. return HighlightAnnotation;
  40714. }();
  40715. var UnderlineAnnotation = function UnderlineAnnotationClosure() {
  40716. function UnderlineAnnotation(parameters) {
  40717. Annotation.call(this, parameters);
  40718. this.data.annotationType = AnnotationType.UNDERLINE;
  40719. this._preparePopup(parameters.dict);
  40720. this.data.borderStyle.setWidth(0);
  40721. }
  40722. Util.inherit(UnderlineAnnotation, Annotation, {});
  40723. return UnderlineAnnotation;
  40724. }();
  40725. var SquigglyAnnotation = function SquigglyAnnotationClosure() {
  40726. function SquigglyAnnotation(parameters) {
  40727. Annotation.call(this, parameters);
  40728. this.data.annotationType = AnnotationType.SQUIGGLY;
  40729. this._preparePopup(parameters.dict);
  40730. this.data.borderStyle.setWidth(0);
  40731. }
  40732. Util.inherit(SquigglyAnnotation, Annotation, {});
  40733. return SquigglyAnnotation;
  40734. }();
  40735. var StrikeOutAnnotation = function StrikeOutAnnotationClosure() {
  40736. function StrikeOutAnnotation(parameters) {
  40737. Annotation.call(this, parameters);
  40738. this.data.annotationType = AnnotationType.STRIKEOUT;
  40739. this._preparePopup(parameters.dict);
  40740. this.data.borderStyle.setWidth(0);
  40741. }
  40742. Util.inherit(StrikeOutAnnotation, Annotation, {});
  40743. return StrikeOutAnnotation;
  40744. }();
  40745. var FileAttachmentAnnotation = function FileAttachmentAnnotationClosure() {
  40746. function FileAttachmentAnnotation(parameters) {
  40747. Annotation.call(this, parameters);
  40748. var file = new FileSpec(parameters.dict.get('FS'), parameters.xref);
  40749. this.data.annotationType = AnnotationType.FILEATTACHMENT;
  40750. this.data.file = file.serializable;
  40751. this._preparePopup(parameters.dict);
  40752. }
  40753. Util.inherit(FileAttachmentAnnotation, Annotation, {});
  40754. return FileAttachmentAnnotation;
  40755. }();
  40756. exports.Annotation = Annotation;
  40757. exports.AnnotationBorderStyle = AnnotationBorderStyle;
  40758. exports.AnnotationFactory = AnnotationFactory;
  40759. /***/ }),
  40760. /* 30 */
  40761. /***/ (function(module, exports, __w_pdfjs_require__) {
  40762. "use strict";
  40763. var sharedUtil = __w_pdfjs_require__(0);
  40764. var warn = sharedUtil.warn;
  40765. var baseTypes = [
  40766. 'BN',
  40767. 'BN',
  40768. 'BN',
  40769. 'BN',
  40770. 'BN',
  40771. 'BN',
  40772. 'BN',
  40773. 'BN',
  40774. 'BN',
  40775. 'S',
  40776. 'B',
  40777. 'S',
  40778. 'WS',
  40779. 'B',
  40780. 'BN',
  40781. 'BN',
  40782. 'BN',
  40783. 'BN',
  40784. 'BN',
  40785. 'BN',
  40786. 'BN',
  40787. 'BN',
  40788. 'BN',
  40789. 'BN',
  40790. 'BN',
  40791. 'BN',
  40792. 'BN',
  40793. 'BN',
  40794. 'B',
  40795. 'B',
  40796. 'B',
  40797. 'S',
  40798. 'WS',
  40799. 'ON',
  40800. 'ON',
  40801. 'ET',
  40802. 'ET',
  40803. 'ET',
  40804. 'ON',
  40805. 'ON',
  40806. 'ON',
  40807. 'ON',
  40808. 'ON',
  40809. 'ES',
  40810. 'CS',
  40811. 'ES',
  40812. 'CS',
  40813. 'CS',
  40814. 'EN',
  40815. 'EN',
  40816. 'EN',
  40817. 'EN',
  40818. 'EN',
  40819. 'EN',
  40820. 'EN',
  40821. 'EN',
  40822. 'EN',
  40823. 'EN',
  40824. 'CS',
  40825. 'ON',
  40826. 'ON',
  40827. 'ON',
  40828. 'ON',
  40829. 'ON',
  40830. 'ON',
  40831. 'L',
  40832. 'L',
  40833. 'L',
  40834. 'L',
  40835. 'L',
  40836. 'L',
  40837. 'L',
  40838. 'L',
  40839. 'L',
  40840. 'L',
  40841. 'L',
  40842. 'L',
  40843. 'L',
  40844. 'L',
  40845. 'L',
  40846. 'L',
  40847. 'L',
  40848. 'L',
  40849. 'L',
  40850. 'L',
  40851. 'L',
  40852. 'L',
  40853. 'L',
  40854. 'L',
  40855. 'L',
  40856. 'L',
  40857. 'ON',
  40858. 'ON',
  40859. 'ON',
  40860. 'ON',
  40861. 'ON',
  40862. 'ON',
  40863. 'L',
  40864. 'L',
  40865. 'L',
  40866. 'L',
  40867. 'L',
  40868. 'L',
  40869. 'L',
  40870. 'L',
  40871. 'L',
  40872. 'L',
  40873. 'L',
  40874. 'L',
  40875. 'L',
  40876. 'L',
  40877. 'L',
  40878. 'L',
  40879. 'L',
  40880. 'L',
  40881. 'L',
  40882. 'L',
  40883. 'L',
  40884. 'L',
  40885. 'L',
  40886. 'L',
  40887. 'L',
  40888. 'L',
  40889. 'ON',
  40890. 'ON',
  40891. 'ON',
  40892. 'ON',
  40893. 'BN',
  40894. 'BN',
  40895. 'BN',
  40896. 'BN',
  40897. 'BN',
  40898. 'BN',
  40899. 'B',
  40900. 'BN',
  40901. 'BN',
  40902. 'BN',
  40903. 'BN',
  40904. 'BN',
  40905. 'BN',
  40906. 'BN',
  40907. 'BN',
  40908. 'BN',
  40909. 'BN',
  40910. 'BN',
  40911. 'BN',
  40912. 'BN',
  40913. 'BN',
  40914. 'BN',
  40915. 'BN',
  40916. 'BN',
  40917. 'BN',
  40918. 'BN',
  40919. 'BN',
  40920. 'BN',
  40921. 'BN',
  40922. 'BN',
  40923. 'BN',
  40924. 'BN',
  40925. 'BN',
  40926. 'CS',
  40927. 'ON',
  40928. 'ET',
  40929. 'ET',
  40930. 'ET',
  40931. 'ET',
  40932. 'ON',
  40933. 'ON',
  40934. 'ON',
  40935. 'ON',
  40936. 'L',
  40937. 'ON',
  40938. 'ON',
  40939. 'BN',
  40940. 'ON',
  40941. 'ON',
  40942. 'ET',
  40943. 'ET',
  40944. 'EN',
  40945. 'EN',
  40946. 'ON',
  40947. 'L',
  40948. 'ON',
  40949. 'ON',
  40950. 'ON',
  40951. 'EN',
  40952. 'L',
  40953. 'ON',
  40954. 'ON',
  40955. 'ON',
  40956. 'ON',
  40957. 'ON',
  40958. 'L',
  40959. 'L',
  40960. 'L',
  40961. 'L',
  40962. 'L',
  40963. 'L',
  40964. 'L',
  40965. 'L',
  40966. 'L',
  40967. 'L',
  40968. 'L',
  40969. 'L',
  40970. 'L',
  40971. 'L',
  40972. 'L',
  40973. 'L',
  40974. 'L',
  40975. 'L',
  40976. 'L',
  40977. 'L',
  40978. 'L',
  40979. 'L',
  40980. 'L',
  40981. 'ON',
  40982. 'L',
  40983. 'L',
  40984. 'L',
  40985. 'L',
  40986. 'L',
  40987. 'L',
  40988. 'L',
  40989. 'L',
  40990. 'L',
  40991. 'L',
  40992. 'L',
  40993. 'L',
  40994. 'L',
  40995. 'L',
  40996. 'L',
  40997. 'L',
  40998. 'L',
  40999. 'L',
  41000. 'L',
  41001. 'L',
  41002. 'L',
  41003. 'L',
  41004. 'L',
  41005. 'L',
  41006. 'L',
  41007. 'L',
  41008. 'L',
  41009. 'L',
  41010. 'L',
  41011. 'L',
  41012. 'L',
  41013. 'ON',
  41014. 'L',
  41015. 'L',
  41016. 'L',
  41017. 'L',
  41018. 'L',
  41019. 'L',
  41020. 'L',
  41021. 'L'
  41022. ];
  41023. var arabicTypes = [
  41024. 'AN',
  41025. 'AN',
  41026. 'AN',
  41027. 'AN',
  41028. 'AN',
  41029. 'AN',
  41030. 'ON',
  41031. 'ON',
  41032. 'AL',
  41033. 'ET',
  41034. 'ET',
  41035. 'AL',
  41036. 'CS',
  41037. 'AL',
  41038. 'ON',
  41039. 'ON',
  41040. 'NSM',
  41041. 'NSM',
  41042. 'NSM',
  41043. 'NSM',
  41044. 'NSM',
  41045. 'NSM',
  41046. 'NSM',
  41047. 'NSM',
  41048. 'NSM',
  41049. 'NSM',
  41050. 'NSM',
  41051. 'AL',
  41052. 'AL',
  41053. '',
  41054. 'AL',
  41055. 'AL',
  41056. 'AL',
  41057. 'AL',
  41058. 'AL',
  41059. 'AL',
  41060. 'AL',
  41061. 'AL',
  41062. 'AL',
  41063. 'AL',
  41064. 'AL',
  41065. 'AL',
  41066. 'AL',
  41067. 'AL',
  41068. 'AL',
  41069. 'AL',
  41070. 'AL',
  41071. 'AL',
  41072. 'AL',
  41073. 'AL',
  41074. 'AL',
  41075. 'AL',
  41076. 'AL',
  41077. 'AL',
  41078. 'AL',
  41079. 'AL',
  41080. 'AL',
  41081. 'AL',
  41082. 'AL',
  41083. 'AL',
  41084. 'AL',
  41085. 'AL',
  41086. 'AL',
  41087. 'AL',
  41088. 'AL',
  41089. 'AL',
  41090. 'AL',
  41091. 'AL',
  41092. 'AL',
  41093. 'AL',
  41094. 'AL',
  41095. 'AL',
  41096. 'AL',
  41097. 'AL',
  41098. 'AL',
  41099. 'NSM',
  41100. 'NSM',
  41101. 'NSM',
  41102. 'NSM',
  41103. 'NSM',
  41104. 'NSM',
  41105. 'NSM',
  41106. 'NSM',
  41107. 'NSM',
  41108. 'NSM',
  41109. 'NSM',
  41110. 'NSM',
  41111. 'NSM',
  41112. 'NSM',
  41113. 'NSM',
  41114. 'NSM',
  41115. 'NSM',
  41116. 'NSM',
  41117. 'NSM',
  41118. 'NSM',
  41119. 'NSM',
  41120. 'AN',
  41121. 'AN',
  41122. 'AN',
  41123. 'AN',
  41124. 'AN',
  41125. 'AN',
  41126. 'AN',
  41127. 'AN',
  41128. 'AN',
  41129. 'AN',
  41130. 'ET',
  41131. 'AN',
  41132. 'AN',
  41133. 'AL',
  41134. 'AL',
  41135. 'AL',
  41136. 'NSM',
  41137. 'AL',
  41138. 'AL',
  41139. 'AL',
  41140. 'AL',
  41141. 'AL',
  41142. 'AL',
  41143. 'AL',
  41144. 'AL',
  41145. 'AL',
  41146. 'AL',
  41147. 'AL',
  41148. 'AL',
  41149. 'AL',
  41150. 'AL',
  41151. 'AL',
  41152. 'AL',
  41153. 'AL',
  41154. 'AL',
  41155. 'AL',
  41156. 'AL',
  41157. 'AL',
  41158. 'AL',
  41159. 'AL',
  41160. 'AL',
  41161. 'AL',
  41162. 'AL',
  41163. 'AL',
  41164. 'AL',
  41165. 'AL',
  41166. 'AL',
  41167. 'AL',
  41168. 'AL',
  41169. 'AL',
  41170. 'AL',
  41171. 'AL',
  41172. 'AL',
  41173. 'AL',
  41174. 'AL',
  41175. 'AL',
  41176. 'AL',
  41177. 'AL',
  41178. 'AL',
  41179. 'AL',
  41180. 'AL',
  41181. 'AL',
  41182. 'AL',
  41183. 'AL',
  41184. 'AL',
  41185. 'AL',
  41186. 'AL',
  41187. 'AL',
  41188. 'AL',
  41189. 'AL',
  41190. 'AL',
  41191. 'AL',
  41192. 'AL',
  41193. 'AL',
  41194. 'AL',
  41195. 'AL',
  41196. 'AL',
  41197. 'AL',
  41198. 'AL',
  41199. 'AL',
  41200. 'AL',
  41201. 'AL',
  41202. 'AL',
  41203. 'AL',
  41204. 'AL',
  41205. 'AL',
  41206. 'AL',
  41207. 'AL',
  41208. 'AL',
  41209. 'AL',
  41210. 'AL',
  41211. 'AL',
  41212. 'AL',
  41213. 'AL',
  41214. 'AL',
  41215. 'AL',
  41216. 'AL',
  41217. 'AL',
  41218. 'AL',
  41219. 'AL',
  41220. 'AL',
  41221. 'AL',
  41222. 'AL',
  41223. 'AL',
  41224. 'AL',
  41225. 'AL',
  41226. 'AL',
  41227. 'AL',
  41228. 'AL',
  41229. 'AL',
  41230. 'AL',
  41231. 'AL',
  41232. 'AL',
  41233. 'AL',
  41234. 'AL',
  41235. 'AL',
  41236. 'AL',
  41237. 'AL',
  41238. 'NSM',
  41239. 'NSM',
  41240. 'NSM',
  41241. 'NSM',
  41242. 'NSM',
  41243. 'NSM',
  41244. 'NSM',
  41245. 'AN',
  41246. 'ON',
  41247. 'NSM',
  41248. 'NSM',
  41249. 'NSM',
  41250. 'NSM',
  41251. 'NSM',
  41252. 'NSM',
  41253. 'AL',
  41254. 'AL',
  41255. 'NSM',
  41256. 'NSM',
  41257. 'ON',
  41258. 'NSM',
  41259. 'NSM',
  41260. 'NSM',
  41261. 'NSM',
  41262. 'AL',
  41263. 'AL',
  41264. 'EN',
  41265. 'EN',
  41266. 'EN',
  41267. 'EN',
  41268. 'EN',
  41269. 'EN',
  41270. 'EN',
  41271. 'EN',
  41272. 'EN',
  41273. 'EN',
  41274. 'AL',
  41275. 'AL',
  41276. 'AL',
  41277. 'AL',
  41278. 'AL',
  41279. 'AL'
  41280. ];
  41281. function isOdd(i) {
  41282. return (i & 1) !== 0;
  41283. }
  41284. function isEven(i) {
  41285. return (i & 1) === 0;
  41286. }
  41287. function findUnequal(arr, start, value) {
  41288. for (var j = start, jj = arr.length; j < jj; ++j) {
  41289. if (arr[j] !== value) {
  41290. return j;
  41291. }
  41292. }
  41293. return j;
  41294. }
  41295. function setValues(arr, start, end, value) {
  41296. for (var j = start; j < end; ++j) {
  41297. arr[j] = value;
  41298. }
  41299. }
  41300. function reverseValues(arr, start, end) {
  41301. for (var i = start, j = end - 1; i < j; ++i, --j) {
  41302. var temp = arr[i];
  41303. arr[i] = arr[j];
  41304. arr[j] = temp;
  41305. }
  41306. }
  41307. function createBidiText(str, isLTR, vertical) {
  41308. return {
  41309. str: str,
  41310. dir: vertical ? 'ttb' : isLTR ? 'ltr' : 'rtl'
  41311. };
  41312. }
  41313. var chars = [];
  41314. var types = [];
  41315. function bidi(str, startLevel, vertical) {
  41316. var isLTR = true;
  41317. var strLength = str.length;
  41318. if (strLength === 0 || vertical) {
  41319. return createBidiText(str, isLTR, vertical);
  41320. }
  41321. chars.length = strLength;
  41322. types.length = strLength;
  41323. var numBidi = 0;
  41324. var i, ii;
  41325. for (i = 0; i < strLength; ++i) {
  41326. chars[i] = str.charAt(i);
  41327. var charCode = str.charCodeAt(i);
  41328. var charType = 'L';
  41329. if (charCode <= 0x00ff) {
  41330. charType = baseTypes[charCode];
  41331. } else if (0x0590 <= charCode && charCode <= 0x05f4) {
  41332. charType = 'R';
  41333. } else if (0x0600 <= charCode && charCode <= 0x06ff) {
  41334. charType = arabicTypes[charCode & 0xff];
  41335. if (!charType) {
  41336. warn('Bidi: invalid Unicode character ' + charCode.toString(16));
  41337. }
  41338. } else if (0x0700 <= charCode && charCode <= 0x08AC) {
  41339. charType = 'AL';
  41340. }
  41341. if (charType === 'R' || charType === 'AL' || charType === 'AN') {
  41342. numBidi++;
  41343. }
  41344. types[i] = charType;
  41345. }
  41346. if (numBidi === 0) {
  41347. isLTR = true;
  41348. return createBidiText(str, isLTR);
  41349. }
  41350. if (startLevel === -1) {
  41351. if (numBidi / strLength < 0.3) {
  41352. isLTR = true;
  41353. startLevel = 0;
  41354. } else {
  41355. isLTR = false;
  41356. startLevel = 1;
  41357. }
  41358. }
  41359. var levels = [];
  41360. for (i = 0; i < strLength; ++i) {
  41361. levels[i] = startLevel;
  41362. }
  41363. var e = isOdd(startLevel) ? 'R' : 'L';
  41364. var sor = e;
  41365. var eor = sor;
  41366. var lastType = sor;
  41367. for (i = 0; i < strLength; ++i) {
  41368. if (types[i] === 'NSM') {
  41369. types[i] = lastType;
  41370. } else {
  41371. lastType = types[i];
  41372. }
  41373. }
  41374. lastType = sor;
  41375. var t;
  41376. for (i = 0; i < strLength; ++i) {
  41377. t = types[i];
  41378. if (t === 'EN') {
  41379. types[i] = lastType === 'AL' ? 'AN' : 'EN';
  41380. } else if (t === 'R' || t === 'L' || t === 'AL') {
  41381. lastType = t;
  41382. }
  41383. }
  41384. for (i = 0; i < strLength; ++i) {
  41385. t = types[i];
  41386. if (t === 'AL') {
  41387. types[i] = 'R';
  41388. }
  41389. }
  41390. for (i = 1; i < strLength - 1; ++i) {
  41391. if (types[i] === 'ES' && types[i - 1] === 'EN' && types[i + 1] === 'EN') {
  41392. types[i] = 'EN';
  41393. }
  41394. if (types[i] === 'CS' && (types[i - 1] === 'EN' || types[i - 1] === 'AN') && types[i + 1] === types[i - 1]) {
  41395. types[i] = types[i - 1];
  41396. }
  41397. }
  41398. for (i = 0; i < strLength; ++i) {
  41399. if (types[i] === 'EN') {
  41400. var j;
  41401. for (j = i - 1; j >= 0; --j) {
  41402. if (types[j] !== 'ET') {
  41403. break;
  41404. }
  41405. types[j] = 'EN';
  41406. }
  41407. for (j = i + 1; j < strLength; ++j) {
  41408. if (types[j] !== 'ET') {
  41409. break;
  41410. }
  41411. types[j] = 'EN';
  41412. }
  41413. }
  41414. }
  41415. for (i = 0; i < strLength; ++i) {
  41416. t = types[i];
  41417. if (t === 'WS' || t === 'ES' || t === 'ET' || t === 'CS') {
  41418. types[i] = 'ON';
  41419. }
  41420. }
  41421. lastType = sor;
  41422. for (i = 0; i < strLength; ++i) {
  41423. t = types[i];
  41424. if (t === 'EN') {
  41425. types[i] = lastType === 'L' ? 'L' : 'EN';
  41426. } else if (t === 'R' || t === 'L') {
  41427. lastType = t;
  41428. }
  41429. }
  41430. for (i = 0; i < strLength; ++i) {
  41431. if (types[i] === 'ON') {
  41432. var end = findUnequal(types, i + 1, 'ON');
  41433. var before = sor;
  41434. if (i > 0) {
  41435. before = types[i - 1];
  41436. }
  41437. var after = eor;
  41438. if (end + 1 < strLength) {
  41439. after = types[end + 1];
  41440. }
  41441. if (before !== 'L') {
  41442. before = 'R';
  41443. }
  41444. if (after !== 'L') {
  41445. after = 'R';
  41446. }
  41447. if (before === after) {
  41448. setValues(types, i, end, before);
  41449. }
  41450. i = end - 1;
  41451. }
  41452. }
  41453. for (i = 0; i < strLength; ++i) {
  41454. if (types[i] === 'ON') {
  41455. types[i] = e;
  41456. }
  41457. }
  41458. for (i = 0; i < strLength; ++i) {
  41459. t = types[i];
  41460. if (isEven(levels[i])) {
  41461. if (t === 'R') {
  41462. levels[i] += 1;
  41463. } else if (t === 'AN' || t === 'EN') {
  41464. levels[i] += 2;
  41465. }
  41466. } else {
  41467. if (t === 'L' || t === 'AN' || t === 'EN') {
  41468. levels[i] += 1;
  41469. }
  41470. }
  41471. }
  41472. var highestLevel = -1;
  41473. var lowestOddLevel = 99;
  41474. var level;
  41475. for (i = 0, ii = levels.length; i < ii; ++i) {
  41476. level = levels[i];
  41477. if (highestLevel < level) {
  41478. highestLevel = level;
  41479. }
  41480. if (lowestOddLevel > level && isOdd(level)) {
  41481. lowestOddLevel = level;
  41482. }
  41483. }
  41484. for (level = highestLevel; level >= lowestOddLevel; --level) {
  41485. var start = -1;
  41486. for (i = 0, ii = levels.length; i < ii; ++i) {
  41487. if (levels[i] < level) {
  41488. if (start >= 0) {
  41489. reverseValues(chars, start, i);
  41490. start = -1;
  41491. }
  41492. } else if (start < 0) {
  41493. start = i;
  41494. }
  41495. }
  41496. if (start >= 0) {
  41497. reverseValues(chars, start, levels.length);
  41498. }
  41499. }
  41500. for (i = 0, ii = chars.length; i < ii; ++i) {
  41501. var ch = chars[i];
  41502. if (ch === '<' || ch === '>') {
  41503. chars[i] = '';
  41504. }
  41505. }
  41506. return createBidiText(chars.join(''), isLTR);
  41507. }
  41508. exports.bidi = bidi;
  41509. /***/ }),
  41510. /* 31 */
  41511. /***/ (function(module, exports, __w_pdfjs_require__) {
  41512. "use strict";
  41513. var ISOAdobeCharset = [
  41514. '.notdef',
  41515. 'space',
  41516. 'exclam',
  41517. 'quotedbl',
  41518. 'numbersign',
  41519. 'dollar',
  41520. 'percent',
  41521. 'ampersand',
  41522. 'quoteright',
  41523. 'parenleft',
  41524. 'parenright',
  41525. 'asterisk',
  41526. 'plus',
  41527. 'comma',
  41528. 'hyphen',
  41529. 'period',
  41530. 'slash',
  41531. 'zero',
  41532. 'one',
  41533. 'two',
  41534. 'three',
  41535. 'four',
  41536. 'five',
  41537. 'six',
  41538. 'seven',
  41539. 'eight',
  41540. 'nine',
  41541. 'colon',
  41542. 'semicolon',
  41543. 'less',
  41544. 'equal',
  41545. 'greater',
  41546. 'question',
  41547. 'at',
  41548. 'A',
  41549. 'B',
  41550. 'C',
  41551. 'D',
  41552. 'E',
  41553. 'F',
  41554. 'G',
  41555. 'H',
  41556. 'I',
  41557. 'J',
  41558. 'K',
  41559. 'L',
  41560. 'M',
  41561. 'N',
  41562. 'O',
  41563. 'P',
  41564. 'Q',
  41565. 'R',
  41566. 'S',
  41567. 'T',
  41568. 'U',
  41569. 'V',
  41570. 'W',
  41571. 'X',
  41572. 'Y',
  41573. 'Z',
  41574. 'bracketleft',
  41575. 'backslash',
  41576. 'bracketright',
  41577. 'asciicircum',
  41578. 'underscore',
  41579. 'quoteleft',
  41580. 'a',
  41581. 'b',
  41582. 'c',
  41583. 'd',
  41584. 'e',
  41585. 'f',
  41586. 'g',
  41587. 'h',
  41588. 'i',
  41589. 'j',
  41590. 'k',
  41591. 'l',
  41592. 'm',
  41593. 'n',
  41594. 'o',
  41595. 'p',
  41596. 'q',
  41597. 'r',
  41598. 's',
  41599. 't',
  41600. 'u',
  41601. 'v',
  41602. 'w',
  41603. 'x',
  41604. 'y',
  41605. 'z',
  41606. 'braceleft',
  41607. 'bar',
  41608. 'braceright',
  41609. 'asciitilde',
  41610. 'exclamdown',
  41611. 'cent',
  41612. 'sterling',
  41613. 'fraction',
  41614. 'yen',
  41615. 'florin',
  41616. 'section',
  41617. 'currency',
  41618. 'quotesingle',
  41619. 'quotedblleft',
  41620. 'guillemotleft',
  41621. 'guilsinglleft',
  41622. 'guilsinglright',
  41623. 'fi',
  41624. 'fl',
  41625. 'endash',
  41626. 'dagger',
  41627. 'daggerdbl',
  41628. 'periodcentered',
  41629. 'paragraph',
  41630. 'bullet',
  41631. 'quotesinglbase',
  41632. 'quotedblbase',
  41633. 'quotedblright',
  41634. 'guillemotright',
  41635. 'ellipsis',
  41636. 'perthousand',
  41637. 'questiondown',
  41638. 'grave',
  41639. 'acute',
  41640. 'circumflex',
  41641. 'tilde',
  41642. 'macron',
  41643. 'breve',
  41644. 'dotaccent',
  41645. 'dieresis',
  41646. 'ring',
  41647. 'cedilla',
  41648. 'hungarumlaut',
  41649. 'ogonek',
  41650. 'caron',
  41651. 'emdash',
  41652. 'AE',
  41653. 'ordfeminine',
  41654. 'Lslash',
  41655. 'Oslash',
  41656. 'OE',
  41657. 'ordmasculine',
  41658. 'ae',
  41659. 'dotlessi',
  41660. 'lslash',
  41661. 'oslash',
  41662. 'oe',
  41663. 'germandbls',
  41664. 'onesuperior',
  41665. 'logicalnot',
  41666. 'mu',
  41667. 'trademark',
  41668. 'Eth',
  41669. 'onehalf',
  41670. 'plusminus',
  41671. 'Thorn',
  41672. 'onequarter',
  41673. 'divide',
  41674. 'brokenbar',
  41675. 'degree',
  41676. 'thorn',
  41677. 'threequarters',
  41678. 'twosuperior',
  41679. 'registered',
  41680. 'minus',
  41681. 'eth',
  41682. 'multiply',
  41683. 'threesuperior',
  41684. 'copyright',
  41685. 'Aacute',
  41686. 'Acircumflex',
  41687. 'Adieresis',
  41688. 'Agrave',
  41689. 'Aring',
  41690. 'Atilde',
  41691. 'Ccedilla',
  41692. 'Eacute',
  41693. 'Ecircumflex',
  41694. 'Edieresis',
  41695. 'Egrave',
  41696. 'Iacute',
  41697. 'Icircumflex',
  41698. 'Idieresis',
  41699. 'Igrave',
  41700. 'Ntilde',
  41701. 'Oacute',
  41702. 'Ocircumflex',
  41703. 'Odieresis',
  41704. 'Ograve',
  41705. 'Otilde',
  41706. 'Scaron',
  41707. 'Uacute',
  41708. 'Ucircumflex',
  41709. 'Udieresis',
  41710. 'Ugrave',
  41711. 'Yacute',
  41712. 'Ydieresis',
  41713. 'Zcaron',
  41714. 'aacute',
  41715. 'acircumflex',
  41716. 'adieresis',
  41717. 'agrave',
  41718. 'aring',
  41719. 'atilde',
  41720. 'ccedilla',
  41721. 'eacute',
  41722. 'ecircumflex',
  41723. 'edieresis',
  41724. 'egrave',
  41725. 'iacute',
  41726. 'icircumflex',
  41727. 'idieresis',
  41728. 'igrave',
  41729. 'ntilde',
  41730. 'oacute',
  41731. 'ocircumflex',
  41732. 'odieresis',
  41733. 'ograve',
  41734. 'otilde',
  41735. 'scaron',
  41736. 'uacute',
  41737. 'ucircumflex',
  41738. 'udieresis',
  41739. 'ugrave',
  41740. 'yacute',
  41741. 'ydieresis',
  41742. 'zcaron'
  41743. ];
  41744. var ExpertCharset = [
  41745. '.notdef',
  41746. 'space',
  41747. 'exclamsmall',
  41748. 'Hungarumlautsmall',
  41749. 'dollaroldstyle',
  41750. 'dollarsuperior',
  41751. 'ampersandsmall',
  41752. 'Acutesmall',
  41753. 'parenleftsuperior',
  41754. 'parenrightsuperior',
  41755. 'twodotenleader',
  41756. 'onedotenleader',
  41757. 'comma',
  41758. 'hyphen',
  41759. 'period',
  41760. 'fraction',
  41761. 'zerooldstyle',
  41762. 'oneoldstyle',
  41763. 'twooldstyle',
  41764. 'threeoldstyle',
  41765. 'fouroldstyle',
  41766. 'fiveoldstyle',
  41767. 'sixoldstyle',
  41768. 'sevenoldstyle',
  41769. 'eightoldstyle',
  41770. 'nineoldstyle',
  41771. 'colon',
  41772. 'semicolon',
  41773. 'commasuperior',
  41774. 'threequartersemdash',
  41775. 'periodsuperior',
  41776. 'questionsmall',
  41777. 'asuperior',
  41778. 'bsuperior',
  41779. 'centsuperior',
  41780. 'dsuperior',
  41781. 'esuperior',
  41782. 'isuperior',
  41783. 'lsuperior',
  41784. 'msuperior',
  41785. 'nsuperior',
  41786. 'osuperior',
  41787. 'rsuperior',
  41788. 'ssuperior',
  41789. 'tsuperior',
  41790. 'ff',
  41791. 'fi',
  41792. 'fl',
  41793. 'ffi',
  41794. 'ffl',
  41795. 'parenleftinferior',
  41796. 'parenrightinferior',
  41797. 'Circumflexsmall',
  41798. 'hyphensuperior',
  41799. 'Gravesmall',
  41800. 'Asmall',
  41801. 'Bsmall',
  41802. 'Csmall',
  41803. 'Dsmall',
  41804. 'Esmall',
  41805. 'Fsmall',
  41806. 'Gsmall',
  41807. 'Hsmall',
  41808. 'Ismall',
  41809. 'Jsmall',
  41810. 'Ksmall',
  41811. 'Lsmall',
  41812. 'Msmall',
  41813. 'Nsmall',
  41814. 'Osmall',
  41815. 'Psmall',
  41816. 'Qsmall',
  41817. 'Rsmall',
  41818. 'Ssmall',
  41819. 'Tsmall',
  41820. 'Usmall',
  41821. 'Vsmall',
  41822. 'Wsmall',
  41823. 'Xsmall',
  41824. 'Ysmall',
  41825. 'Zsmall',
  41826. 'colonmonetary',
  41827. 'onefitted',
  41828. 'rupiah',
  41829. 'Tildesmall',
  41830. 'exclamdownsmall',
  41831. 'centoldstyle',
  41832. 'Lslashsmall',
  41833. 'Scaronsmall',
  41834. 'Zcaronsmall',
  41835. 'Dieresissmall',
  41836. 'Brevesmall',
  41837. 'Caronsmall',
  41838. 'Dotaccentsmall',
  41839. 'Macronsmall',
  41840. 'figuredash',
  41841. 'hypheninferior',
  41842. 'Ogoneksmall',
  41843. 'Ringsmall',
  41844. 'Cedillasmall',
  41845. 'onequarter',
  41846. 'onehalf',
  41847. 'threequarters',
  41848. 'questiondownsmall',
  41849. 'oneeighth',
  41850. 'threeeighths',
  41851. 'fiveeighths',
  41852. 'seveneighths',
  41853. 'onethird',
  41854. 'twothirds',
  41855. 'zerosuperior',
  41856. 'onesuperior',
  41857. 'twosuperior',
  41858. 'threesuperior',
  41859. 'foursuperior',
  41860. 'fivesuperior',
  41861. 'sixsuperior',
  41862. 'sevensuperior',
  41863. 'eightsuperior',
  41864. 'ninesuperior',
  41865. 'zeroinferior',
  41866. 'oneinferior',
  41867. 'twoinferior',
  41868. 'threeinferior',
  41869. 'fourinferior',
  41870. 'fiveinferior',
  41871. 'sixinferior',
  41872. 'seveninferior',
  41873. 'eightinferior',
  41874. 'nineinferior',
  41875. 'centinferior',
  41876. 'dollarinferior',
  41877. 'periodinferior',
  41878. 'commainferior',
  41879. 'Agravesmall',
  41880. 'Aacutesmall',
  41881. 'Acircumflexsmall',
  41882. 'Atildesmall',
  41883. 'Adieresissmall',
  41884. 'Aringsmall',
  41885. 'AEsmall',
  41886. 'Ccedillasmall',
  41887. 'Egravesmall',
  41888. 'Eacutesmall',
  41889. 'Ecircumflexsmall',
  41890. 'Edieresissmall',
  41891. 'Igravesmall',
  41892. 'Iacutesmall',
  41893. 'Icircumflexsmall',
  41894. 'Idieresissmall',
  41895. 'Ethsmall',
  41896. 'Ntildesmall',
  41897. 'Ogravesmall',
  41898. 'Oacutesmall',
  41899. 'Ocircumflexsmall',
  41900. 'Otildesmall',
  41901. 'Odieresissmall',
  41902. 'OEsmall',
  41903. 'Oslashsmall',
  41904. 'Ugravesmall',
  41905. 'Uacutesmall',
  41906. 'Ucircumflexsmall',
  41907. 'Udieresissmall',
  41908. 'Yacutesmall',
  41909. 'Thornsmall',
  41910. 'Ydieresissmall'
  41911. ];
  41912. var ExpertSubsetCharset = [
  41913. '.notdef',
  41914. 'space',
  41915. 'dollaroldstyle',
  41916. 'dollarsuperior',
  41917. 'parenleftsuperior',
  41918. 'parenrightsuperior',
  41919. 'twodotenleader',
  41920. 'onedotenleader',
  41921. 'comma',
  41922. 'hyphen',
  41923. 'period',
  41924. 'fraction',
  41925. 'zerooldstyle',
  41926. 'oneoldstyle',
  41927. 'twooldstyle',
  41928. 'threeoldstyle',
  41929. 'fouroldstyle',
  41930. 'fiveoldstyle',
  41931. 'sixoldstyle',
  41932. 'sevenoldstyle',
  41933. 'eightoldstyle',
  41934. 'nineoldstyle',
  41935. 'colon',
  41936. 'semicolon',
  41937. 'commasuperior',
  41938. 'threequartersemdash',
  41939. 'periodsuperior',
  41940. 'asuperior',
  41941. 'bsuperior',
  41942. 'centsuperior',
  41943. 'dsuperior',
  41944. 'esuperior',
  41945. 'isuperior',
  41946. 'lsuperior',
  41947. 'msuperior',
  41948. 'nsuperior',
  41949. 'osuperior',
  41950. 'rsuperior',
  41951. 'ssuperior',
  41952. 'tsuperior',
  41953. 'ff',
  41954. 'fi',
  41955. 'fl',
  41956. 'ffi',
  41957. 'ffl',
  41958. 'parenleftinferior',
  41959. 'parenrightinferior',
  41960. 'hyphensuperior',
  41961. 'colonmonetary',
  41962. 'onefitted',
  41963. 'rupiah',
  41964. 'centoldstyle',
  41965. 'figuredash',
  41966. 'hypheninferior',
  41967. 'onequarter',
  41968. 'onehalf',
  41969. 'threequarters',
  41970. 'oneeighth',
  41971. 'threeeighths',
  41972. 'fiveeighths',
  41973. 'seveneighths',
  41974. 'onethird',
  41975. 'twothirds',
  41976. 'zerosuperior',
  41977. 'onesuperior',
  41978. 'twosuperior',
  41979. 'threesuperior',
  41980. 'foursuperior',
  41981. 'fivesuperior',
  41982. 'sixsuperior',
  41983. 'sevensuperior',
  41984. 'eightsuperior',
  41985. 'ninesuperior',
  41986. 'zeroinferior',
  41987. 'oneinferior',
  41988. 'twoinferior',
  41989. 'threeinferior',
  41990. 'fourinferior',
  41991. 'fiveinferior',
  41992. 'sixinferior',
  41993. 'seveninferior',
  41994. 'eightinferior',
  41995. 'nineinferior',
  41996. 'centinferior',
  41997. 'dollarinferior',
  41998. 'periodinferior',
  41999. 'commainferior'
  42000. ];
  42001. exports.ISOAdobeCharset = ISOAdobeCharset;
  42002. exports.ExpertCharset = ExpertCharset;
  42003. exports.ExpertSubsetCharset = ExpertSubsetCharset;
  42004. /***/ }),
  42005. /* 32 */
  42006. /***/ (function(module, exports, __w_pdfjs_require__) {
  42007. "use strict";
  42008. var sharedUtil = __w_pdfjs_require__(0);
  42009. var corePrimitives = __w_pdfjs_require__(1);
  42010. var coreStream = __w_pdfjs_require__(2);
  42011. var coreParser = __w_pdfjs_require__(6);
  42012. var Util = sharedUtil.Util;
  42013. var assert = sharedUtil.assert;
  42014. var warn = sharedUtil.warn;
  42015. var error = sharedUtil.error;
  42016. var isInt = sharedUtil.isInt;
  42017. var isString = sharedUtil.isString;
  42018. var MissingDataException = sharedUtil.MissingDataException;
  42019. var isEOF = corePrimitives.isEOF;
  42020. var isName = corePrimitives.isName;
  42021. var isCmd = corePrimitives.isCmd;
  42022. var isStream = corePrimitives.isStream;
  42023. var StringStream = coreStream.StringStream;
  42024. var Lexer = coreParser.Lexer;
  42025. var BUILT_IN_CMAPS = [
  42026. 'Adobe-GB1-UCS2',
  42027. 'Adobe-CNS1-UCS2',
  42028. 'Adobe-Japan1-UCS2',
  42029. 'Adobe-Korea1-UCS2',
  42030. '78-EUC-H',
  42031. '78-EUC-V',
  42032. '78-H',
  42033. '78-RKSJ-H',
  42034. '78-RKSJ-V',
  42035. '78-V',
  42036. '78ms-RKSJ-H',
  42037. '78ms-RKSJ-V',
  42038. '83pv-RKSJ-H',
  42039. '90ms-RKSJ-H',
  42040. '90ms-RKSJ-V',
  42041. '90msp-RKSJ-H',
  42042. '90msp-RKSJ-V',
  42043. '90pv-RKSJ-H',
  42044. '90pv-RKSJ-V',
  42045. 'Add-H',
  42046. 'Add-RKSJ-H',
  42047. 'Add-RKSJ-V',
  42048. 'Add-V',
  42049. 'Adobe-CNS1-0',
  42050. 'Adobe-CNS1-1',
  42051. 'Adobe-CNS1-2',
  42052. 'Adobe-CNS1-3',
  42053. 'Adobe-CNS1-4',
  42054. 'Adobe-CNS1-5',
  42055. 'Adobe-CNS1-6',
  42056. 'Adobe-GB1-0',
  42057. 'Adobe-GB1-1',
  42058. 'Adobe-GB1-2',
  42059. 'Adobe-GB1-3',
  42060. 'Adobe-GB1-4',
  42061. 'Adobe-GB1-5',
  42062. 'Adobe-Japan1-0',
  42063. 'Adobe-Japan1-1',
  42064. 'Adobe-Japan1-2',
  42065. 'Adobe-Japan1-3',
  42066. 'Adobe-Japan1-4',
  42067. 'Adobe-Japan1-5',
  42068. 'Adobe-Japan1-6',
  42069. 'Adobe-Korea1-0',
  42070. 'Adobe-Korea1-1',
  42071. 'Adobe-Korea1-2',
  42072. 'B5-H',
  42073. 'B5-V',
  42074. 'B5pc-H',
  42075. 'B5pc-V',
  42076. 'CNS-EUC-H',
  42077. 'CNS-EUC-V',
  42078. 'CNS1-H',
  42079. 'CNS1-V',
  42080. 'CNS2-H',
  42081. 'CNS2-V',
  42082. 'ETHK-B5-H',
  42083. 'ETHK-B5-V',
  42084. 'ETen-B5-H',
  42085. 'ETen-B5-V',
  42086. 'ETenms-B5-H',
  42087. 'ETenms-B5-V',
  42088. 'EUC-H',
  42089. 'EUC-V',
  42090. 'Ext-H',
  42091. 'Ext-RKSJ-H',
  42092. 'Ext-RKSJ-V',
  42093. 'Ext-V',
  42094. 'GB-EUC-H',
  42095. 'GB-EUC-V',
  42096. 'GB-H',
  42097. 'GB-V',
  42098. 'GBK-EUC-H',
  42099. 'GBK-EUC-V',
  42100. 'GBK2K-H',
  42101. 'GBK2K-V',
  42102. 'GBKp-EUC-H',
  42103. 'GBKp-EUC-V',
  42104. 'GBT-EUC-H',
  42105. 'GBT-EUC-V',
  42106. 'GBT-H',
  42107. 'GBT-V',
  42108. 'GBTpc-EUC-H',
  42109. 'GBTpc-EUC-V',
  42110. 'GBpc-EUC-H',
  42111. 'GBpc-EUC-V',
  42112. 'H',
  42113. 'HKdla-B5-H',
  42114. 'HKdla-B5-V',
  42115. 'HKdlb-B5-H',
  42116. 'HKdlb-B5-V',
  42117. 'HKgccs-B5-H',
  42118. 'HKgccs-B5-V',
  42119. 'HKm314-B5-H',
  42120. 'HKm314-B5-V',
  42121. 'HKm471-B5-H',
  42122. 'HKm471-B5-V',
  42123. 'HKscs-B5-H',
  42124. 'HKscs-B5-V',
  42125. 'Hankaku',
  42126. 'Hiragana',
  42127. 'KSC-EUC-H',
  42128. 'KSC-EUC-V',
  42129. 'KSC-H',
  42130. 'KSC-Johab-H',
  42131. 'KSC-Johab-V',
  42132. 'KSC-V',
  42133. 'KSCms-UHC-H',
  42134. 'KSCms-UHC-HW-H',
  42135. 'KSCms-UHC-HW-V',
  42136. 'KSCms-UHC-V',
  42137. 'KSCpc-EUC-H',
  42138. 'KSCpc-EUC-V',
  42139. 'Katakana',
  42140. 'NWP-H',
  42141. 'NWP-V',
  42142. 'RKSJ-H',
  42143. 'RKSJ-V',
  42144. 'Roman',
  42145. 'UniCNS-UCS2-H',
  42146. 'UniCNS-UCS2-V',
  42147. 'UniCNS-UTF16-H',
  42148. 'UniCNS-UTF16-V',
  42149. 'UniCNS-UTF32-H',
  42150. 'UniCNS-UTF32-V',
  42151. 'UniCNS-UTF8-H',
  42152. 'UniCNS-UTF8-V',
  42153. 'UniGB-UCS2-H',
  42154. 'UniGB-UCS2-V',
  42155. 'UniGB-UTF16-H',
  42156. 'UniGB-UTF16-V',
  42157. 'UniGB-UTF32-H',
  42158. 'UniGB-UTF32-V',
  42159. 'UniGB-UTF8-H',
  42160. 'UniGB-UTF8-V',
  42161. 'UniJIS-UCS2-H',
  42162. 'UniJIS-UCS2-HW-H',
  42163. 'UniJIS-UCS2-HW-V',
  42164. 'UniJIS-UCS2-V',
  42165. 'UniJIS-UTF16-H',
  42166. 'UniJIS-UTF16-V',
  42167. 'UniJIS-UTF32-H',
  42168. 'UniJIS-UTF32-V',
  42169. 'UniJIS-UTF8-H',
  42170. 'UniJIS-UTF8-V',
  42171. 'UniJIS2004-UTF16-H',
  42172. 'UniJIS2004-UTF16-V',
  42173. 'UniJIS2004-UTF32-H',
  42174. 'UniJIS2004-UTF32-V',
  42175. 'UniJIS2004-UTF8-H',
  42176. 'UniJIS2004-UTF8-V',
  42177. 'UniJISPro-UCS2-HW-V',
  42178. 'UniJISPro-UCS2-V',
  42179. 'UniJISPro-UTF8-V',
  42180. 'UniJISX0213-UTF32-H',
  42181. 'UniJISX0213-UTF32-V',
  42182. 'UniJISX02132004-UTF32-H',
  42183. 'UniJISX02132004-UTF32-V',
  42184. 'UniKS-UCS2-H',
  42185. 'UniKS-UCS2-V',
  42186. 'UniKS-UTF16-H',
  42187. 'UniKS-UTF16-V',
  42188. 'UniKS-UTF32-H',
  42189. 'UniKS-UTF32-V',
  42190. 'UniKS-UTF8-H',
  42191. 'UniKS-UTF8-V',
  42192. 'V',
  42193. 'WP-Symbol'
  42194. ];
  42195. var CMap = function CMapClosure() {
  42196. function CMap(builtInCMap) {
  42197. this.codespaceRanges = [
  42198. [],
  42199. [],
  42200. [],
  42201. []
  42202. ];
  42203. this.numCodespaceRanges = 0;
  42204. this._map = [];
  42205. this.name = '';
  42206. this.vertical = false;
  42207. this.useCMap = null;
  42208. this.builtInCMap = builtInCMap;
  42209. }
  42210. CMap.prototype = {
  42211. addCodespaceRange: function (n, low, high) {
  42212. this.codespaceRanges[n - 1].push(low, high);
  42213. this.numCodespaceRanges++;
  42214. },
  42215. mapCidRange: function (low, high, dstLow) {
  42216. while (low <= high) {
  42217. this._map[low++] = dstLow++;
  42218. }
  42219. },
  42220. mapBfRange: function (low, high, dstLow) {
  42221. var lastByte = dstLow.length - 1;
  42222. while (low <= high) {
  42223. this._map[low++] = dstLow;
  42224. dstLow = dstLow.substr(0, lastByte) + String.fromCharCode(dstLow.charCodeAt(lastByte) + 1);
  42225. }
  42226. },
  42227. mapBfRangeToArray: function (low, high, array) {
  42228. var i = 0, ii = array.length;
  42229. while (low <= high && i < ii) {
  42230. this._map[low] = array[i++];
  42231. ++low;
  42232. }
  42233. },
  42234. mapOne: function (src, dst) {
  42235. this._map[src] = dst;
  42236. },
  42237. lookup: function (code) {
  42238. return this._map[code];
  42239. },
  42240. contains: function (code) {
  42241. return this._map[code] !== undefined;
  42242. },
  42243. forEach: function (callback) {
  42244. var map = this._map;
  42245. var length = map.length;
  42246. var i;
  42247. if (length <= 0x10000) {
  42248. for (i = 0; i < length; i++) {
  42249. if (map[i] !== undefined) {
  42250. callback(i, map[i]);
  42251. }
  42252. }
  42253. } else {
  42254. for (i in this._map) {
  42255. callback(i, map[i]);
  42256. }
  42257. }
  42258. },
  42259. charCodeOf: function (value) {
  42260. return this._map.indexOf(value);
  42261. },
  42262. getMap: function () {
  42263. return this._map;
  42264. },
  42265. readCharCode: function (str, offset, out) {
  42266. var c = 0;
  42267. var codespaceRanges = this.codespaceRanges;
  42268. var codespaceRangesLen = this.codespaceRanges.length;
  42269. for (var n = 0; n < codespaceRangesLen; n++) {
  42270. c = (c << 8 | str.charCodeAt(offset + n)) >>> 0;
  42271. var codespaceRange = codespaceRanges[n];
  42272. for (var k = 0, kk = codespaceRange.length; k < kk;) {
  42273. var low = codespaceRange[k++];
  42274. var high = codespaceRange[k++];
  42275. if (c >= low && c <= high) {
  42276. out.charcode = c;
  42277. out.length = n + 1;
  42278. return;
  42279. }
  42280. }
  42281. }
  42282. out.charcode = 0;
  42283. out.length = 1;
  42284. },
  42285. get length() {
  42286. return this._map.length;
  42287. },
  42288. get isIdentityCMap() {
  42289. if (!(this.name === 'Identity-H' || this.name === 'Identity-V')) {
  42290. return false;
  42291. }
  42292. if (this._map.length !== 0x10000) {
  42293. return false;
  42294. }
  42295. for (var i = 0; i < 0x10000; i++) {
  42296. if (this._map[i] !== i) {
  42297. return false;
  42298. }
  42299. }
  42300. return true;
  42301. }
  42302. };
  42303. return CMap;
  42304. }();
  42305. var IdentityCMap = function IdentityCMapClosure() {
  42306. function IdentityCMap(vertical, n) {
  42307. CMap.call(this);
  42308. this.vertical = vertical;
  42309. this.addCodespaceRange(n, 0, 0xffff);
  42310. }
  42311. Util.inherit(IdentityCMap, CMap, {});
  42312. IdentityCMap.prototype = {
  42313. addCodespaceRange: CMap.prototype.addCodespaceRange,
  42314. mapCidRange: function (low, high, dstLow) {
  42315. error('should not call mapCidRange');
  42316. },
  42317. mapBfRange: function (low, high, dstLow) {
  42318. error('should not call mapBfRange');
  42319. },
  42320. mapBfRangeToArray: function (low, high, array) {
  42321. error('should not call mapBfRangeToArray');
  42322. },
  42323. mapOne: function (src, dst) {
  42324. error('should not call mapCidOne');
  42325. },
  42326. lookup: function (code) {
  42327. return isInt(code) && code <= 0xffff ? code : undefined;
  42328. },
  42329. contains: function (code) {
  42330. return isInt(code) && code <= 0xffff;
  42331. },
  42332. forEach: function (callback) {
  42333. for (var i = 0; i <= 0xffff; i++) {
  42334. callback(i, i);
  42335. }
  42336. },
  42337. charCodeOf: function (value) {
  42338. return isInt(value) && value <= 0xffff ? value : -1;
  42339. },
  42340. getMap: function () {
  42341. var map = new Array(0x10000);
  42342. for (var i = 0; i <= 0xffff; i++) {
  42343. map[i] = i;
  42344. }
  42345. return map;
  42346. },
  42347. readCharCode: CMap.prototype.readCharCode,
  42348. get length() {
  42349. return 0x10000;
  42350. },
  42351. get isIdentityCMap() {
  42352. error('should not access .isIdentityCMap');
  42353. }
  42354. };
  42355. return IdentityCMap;
  42356. }();
  42357. var BinaryCMapReader = function BinaryCMapReaderClosure() {
  42358. function fetchBinaryData(url) {
  42359. return new Promise(function (resolve, reject) {
  42360. var request = new XMLHttpRequest();
  42361. request.open('GET', url, true);
  42362. request.responseType = 'arraybuffer';
  42363. request.onreadystatechange = function () {
  42364. if (request.readyState === XMLHttpRequest.DONE) {
  42365. if (!request.response || request.status !== 200 && request.status !== 0) {
  42366. reject(new Error('Unable to get binary cMap at: ' + url));
  42367. } else {
  42368. resolve(new Uint8Array(request.response));
  42369. }
  42370. }
  42371. };
  42372. request.send(null);
  42373. });
  42374. }
  42375. function hexToInt(a, size) {
  42376. var n = 0;
  42377. for (var i = 0; i <= size; i++) {
  42378. n = n << 8 | a[i];
  42379. }
  42380. return n >>> 0;
  42381. }
  42382. function hexToStr(a, size) {
  42383. if (size === 1) {
  42384. return String.fromCharCode(a[0], a[1]);
  42385. }
  42386. if (size === 3) {
  42387. return String.fromCharCode(a[0], a[1], a[2], a[3]);
  42388. }
  42389. return String.fromCharCode.apply(null, a.subarray(0, size + 1));
  42390. }
  42391. function addHex(a, b, size) {
  42392. var c = 0;
  42393. for (var i = size; i >= 0; i--) {
  42394. c += a[i] + b[i];
  42395. a[i] = c & 255;
  42396. c >>= 8;
  42397. }
  42398. }
  42399. function incHex(a, size) {
  42400. var c = 1;
  42401. for (var i = size; i >= 0 && c > 0; i--) {
  42402. c += a[i];
  42403. a[i] = c & 255;
  42404. c >>= 8;
  42405. }
  42406. }
  42407. var MAX_NUM_SIZE = 16;
  42408. var MAX_ENCODED_NUM_SIZE = 19;
  42409. function BinaryCMapStream(data) {
  42410. this.buffer = data;
  42411. this.pos = 0;
  42412. this.end = data.length;
  42413. this.tmpBuf = new Uint8Array(MAX_ENCODED_NUM_SIZE);
  42414. }
  42415. BinaryCMapStream.prototype = {
  42416. readByte: function () {
  42417. if (this.pos >= this.end) {
  42418. return -1;
  42419. }
  42420. return this.buffer[this.pos++];
  42421. },
  42422. readNumber: function () {
  42423. var n = 0;
  42424. var last;
  42425. do {
  42426. var b = this.readByte();
  42427. if (b < 0) {
  42428. error('unexpected EOF in bcmap');
  42429. }
  42430. last = !(b & 0x80);
  42431. n = n << 7 | b & 0x7F;
  42432. } while (!last);
  42433. return n;
  42434. },
  42435. readSigned: function () {
  42436. var n = this.readNumber();
  42437. return n & 1 ? ~(n >>> 1) : n >>> 1;
  42438. },
  42439. readHex: function (num, size) {
  42440. num.set(this.buffer.subarray(this.pos, this.pos + size + 1));
  42441. this.pos += size + 1;
  42442. },
  42443. readHexNumber: function (num, size) {
  42444. var last;
  42445. var stack = this.tmpBuf, sp = 0;
  42446. do {
  42447. var b = this.readByte();
  42448. if (b < 0) {
  42449. error('unexpected EOF in bcmap');
  42450. }
  42451. last = !(b & 0x80);
  42452. stack[sp++] = b & 0x7F;
  42453. } while (!last);
  42454. var i = size, buffer = 0, bufferSize = 0;
  42455. while (i >= 0) {
  42456. while (bufferSize < 8 && stack.length > 0) {
  42457. buffer = stack[--sp] << bufferSize | buffer;
  42458. bufferSize += 7;
  42459. }
  42460. num[i] = buffer & 255;
  42461. i--;
  42462. buffer >>= 8;
  42463. bufferSize -= 8;
  42464. }
  42465. },
  42466. readHexSigned: function (num, size) {
  42467. this.readHexNumber(num, size);
  42468. var sign = num[size] & 1 ? 255 : 0;
  42469. var c = 0;
  42470. for (var i = 0; i <= size; i++) {
  42471. c = (c & 1) << 8 | num[i];
  42472. num[i] = c >> 1 ^ sign;
  42473. }
  42474. },
  42475. readString: function () {
  42476. var len = this.readNumber();
  42477. var s = '';
  42478. for (var i = 0; i < len; i++) {
  42479. s += String.fromCharCode(this.readNumber());
  42480. }
  42481. return s;
  42482. }
  42483. };
  42484. function processBinaryCMap(url, cMap, extend) {
  42485. return fetchBinaryData(url).then(function (data) {
  42486. var stream = new BinaryCMapStream(data);
  42487. var header = stream.readByte();
  42488. cMap.vertical = !!(header & 1);
  42489. var useCMap = null;
  42490. var start = new Uint8Array(MAX_NUM_SIZE);
  42491. var end = new Uint8Array(MAX_NUM_SIZE);
  42492. var char = new Uint8Array(MAX_NUM_SIZE);
  42493. var charCode = new Uint8Array(MAX_NUM_SIZE);
  42494. var tmp = new Uint8Array(MAX_NUM_SIZE);
  42495. var code;
  42496. var b;
  42497. while ((b = stream.readByte()) >= 0) {
  42498. var type = b >> 5;
  42499. if (type === 7) {
  42500. switch (b & 0x1F) {
  42501. case 0:
  42502. stream.readString();
  42503. break;
  42504. case 1:
  42505. useCMap = stream.readString();
  42506. break;
  42507. }
  42508. continue;
  42509. }
  42510. var sequence = !!(b & 0x10);
  42511. var dataSize = b & 15;
  42512. assert(dataSize + 1 <= MAX_NUM_SIZE);
  42513. var ucs2DataSize = 1;
  42514. var subitemsCount = stream.readNumber();
  42515. var i;
  42516. switch (type) {
  42517. case 0:
  42518. stream.readHex(start, dataSize);
  42519. stream.readHexNumber(end, dataSize);
  42520. addHex(end, start, dataSize);
  42521. cMap.addCodespaceRange(dataSize + 1, hexToInt(start, dataSize), hexToInt(end, dataSize));
  42522. for (i = 1; i < subitemsCount; i++) {
  42523. incHex(end, dataSize);
  42524. stream.readHexNumber(start, dataSize);
  42525. addHex(start, end, dataSize);
  42526. stream.readHexNumber(end, dataSize);
  42527. addHex(end, start, dataSize);
  42528. cMap.addCodespaceRange(dataSize + 1, hexToInt(start, dataSize), hexToInt(end, dataSize));
  42529. }
  42530. break;
  42531. case 1:
  42532. stream.readHex(start, dataSize);
  42533. stream.readHexNumber(end, dataSize);
  42534. addHex(end, start, dataSize);
  42535. code = stream.readNumber();
  42536. for (i = 1; i < subitemsCount; i++) {
  42537. incHex(end, dataSize);
  42538. stream.readHexNumber(start, dataSize);
  42539. addHex(start, end, dataSize);
  42540. stream.readHexNumber(end, dataSize);
  42541. addHex(end, start, dataSize);
  42542. code = stream.readNumber();
  42543. }
  42544. break;
  42545. case 2:
  42546. stream.readHex(char, dataSize);
  42547. code = stream.readNumber();
  42548. cMap.mapOne(hexToInt(char, dataSize), code);
  42549. for (i = 1; i < subitemsCount; i++) {
  42550. incHex(char, dataSize);
  42551. if (!sequence) {
  42552. stream.readHexNumber(tmp, dataSize);
  42553. addHex(char, tmp, dataSize);
  42554. }
  42555. code = stream.readSigned() + (code + 1);
  42556. cMap.mapOne(hexToInt(char, dataSize), code);
  42557. }
  42558. break;
  42559. case 3:
  42560. stream.readHex(start, dataSize);
  42561. stream.readHexNumber(end, dataSize);
  42562. addHex(end, start, dataSize);
  42563. code = stream.readNumber();
  42564. cMap.mapCidRange(hexToInt(start, dataSize), hexToInt(end, dataSize), code);
  42565. for (i = 1; i < subitemsCount; i++) {
  42566. incHex(end, dataSize);
  42567. if (!sequence) {
  42568. stream.readHexNumber(start, dataSize);
  42569. addHex(start, end, dataSize);
  42570. } else {
  42571. start.set(end);
  42572. }
  42573. stream.readHexNumber(end, dataSize);
  42574. addHex(end, start, dataSize);
  42575. code = stream.readNumber();
  42576. cMap.mapCidRange(hexToInt(start, dataSize), hexToInt(end, dataSize), code);
  42577. }
  42578. break;
  42579. case 4:
  42580. stream.readHex(char, ucs2DataSize);
  42581. stream.readHex(charCode, dataSize);
  42582. cMap.mapOne(hexToInt(char, ucs2DataSize), hexToStr(charCode, dataSize));
  42583. for (i = 1; i < subitemsCount; i++) {
  42584. incHex(char, ucs2DataSize);
  42585. if (!sequence) {
  42586. stream.readHexNumber(tmp, ucs2DataSize);
  42587. addHex(char, tmp, ucs2DataSize);
  42588. }
  42589. incHex(charCode, dataSize);
  42590. stream.readHexSigned(tmp, dataSize);
  42591. addHex(charCode, tmp, dataSize);
  42592. cMap.mapOne(hexToInt(char, ucs2DataSize), hexToStr(charCode, dataSize));
  42593. }
  42594. break;
  42595. case 5:
  42596. stream.readHex(start, ucs2DataSize);
  42597. stream.readHexNumber(end, ucs2DataSize);
  42598. addHex(end, start, ucs2DataSize);
  42599. stream.readHex(charCode, dataSize);
  42600. cMap.mapBfRange(hexToInt(start, ucs2DataSize), hexToInt(end, ucs2DataSize), hexToStr(charCode, dataSize));
  42601. for (i = 1; i < subitemsCount; i++) {
  42602. incHex(end, ucs2DataSize);
  42603. if (!sequence) {
  42604. stream.readHexNumber(start, ucs2DataSize);
  42605. addHex(start, end, ucs2DataSize);
  42606. } else {
  42607. start.set(end);
  42608. }
  42609. stream.readHexNumber(end, ucs2DataSize);
  42610. addHex(end, start, ucs2DataSize);
  42611. stream.readHex(charCode, dataSize);
  42612. cMap.mapBfRange(hexToInt(start, ucs2DataSize), hexToInt(end, ucs2DataSize), hexToStr(charCode, dataSize));
  42613. }
  42614. break;
  42615. default:
  42616. error('Unknown type: ' + type);
  42617. break;
  42618. }
  42619. }
  42620. if (useCMap) {
  42621. return extend(useCMap);
  42622. }
  42623. return cMap;
  42624. });
  42625. }
  42626. function BinaryCMapReader() {
  42627. }
  42628. BinaryCMapReader.prototype = { read: processBinaryCMap };
  42629. return BinaryCMapReader;
  42630. }();
  42631. var CMapFactory = function CMapFactoryClosure() {
  42632. function strToInt(str) {
  42633. var a = 0;
  42634. for (var i = 0; i < str.length; i++) {
  42635. a = a << 8 | str.charCodeAt(i);
  42636. }
  42637. return a >>> 0;
  42638. }
  42639. function expectString(obj) {
  42640. if (!isString(obj)) {
  42641. error('Malformed CMap: expected string.');
  42642. }
  42643. }
  42644. function expectInt(obj) {
  42645. if (!isInt(obj)) {
  42646. error('Malformed CMap: expected int.');
  42647. }
  42648. }
  42649. function parseBfChar(cMap, lexer) {
  42650. while (true) {
  42651. var obj = lexer.getObj();
  42652. if (isEOF(obj)) {
  42653. break;
  42654. }
  42655. if (isCmd(obj, 'endbfchar')) {
  42656. return;
  42657. }
  42658. expectString(obj);
  42659. var src = strToInt(obj);
  42660. obj = lexer.getObj();
  42661. expectString(obj);
  42662. var dst = obj;
  42663. cMap.mapOne(src, dst);
  42664. }
  42665. }
  42666. function parseBfRange(cMap, lexer) {
  42667. while (true) {
  42668. var obj = lexer.getObj();
  42669. if (isEOF(obj)) {
  42670. break;
  42671. }
  42672. if (isCmd(obj, 'endbfrange')) {
  42673. return;
  42674. }
  42675. expectString(obj);
  42676. var low = strToInt(obj);
  42677. obj = lexer.getObj();
  42678. expectString(obj);
  42679. var high = strToInt(obj);
  42680. obj = lexer.getObj();
  42681. if (isInt(obj) || isString(obj)) {
  42682. var dstLow = isInt(obj) ? String.fromCharCode(obj) : obj;
  42683. cMap.mapBfRange(low, high, dstLow);
  42684. } else if (isCmd(obj, '[')) {
  42685. obj = lexer.getObj();
  42686. var array = [];
  42687. while (!isCmd(obj, ']') && !isEOF(obj)) {
  42688. array.push(obj);
  42689. obj = lexer.getObj();
  42690. }
  42691. cMap.mapBfRangeToArray(low, high, array);
  42692. } else {
  42693. break;
  42694. }
  42695. }
  42696. error('Invalid bf range.');
  42697. }
  42698. function parseCidChar(cMap, lexer) {
  42699. while (true) {
  42700. var obj = lexer.getObj();
  42701. if (isEOF(obj)) {
  42702. break;
  42703. }
  42704. if (isCmd(obj, 'endcidchar')) {
  42705. return;
  42706. }
  42707. expectString(obj);
  42708. var src = strToInt(obj);
  42709. obj = lexer.getObj();
  42710. expectInt(obj);
  42711. var dst = obj;
  42712. cMap.mapOne(src, dst);
  42713. }
  42714. }
  42715. function parseCidRange(cMap, lexer) {
  42716. while (true) {
  42717. var obj = lexer.getObj();
  42718. if (isEOF(obj)) {
  42719. break;
  42720. }
  42721. if (isCmd(obj, 'endcidrange')) {
  42722. return;
  42723. }
  42724. expectString(obj);
  42725. var low = strToInt(obj);
  42726. obj = lexer.getObj();
  42727. expectString(obj);
  42728. var high = strToInt(obj);
  42729. obj = lexer.getObj();
  42730. expectInt(obj);
  42731. var dstLow = obj;
  42732. cMap.mapCidRange(low, high, dstLow);
  42733. }
  42734. }
  42735. function parseCodespaceRange(cMap, lexer) {
  42736. while (true) {
  42737. var obj = lexer.getObj();
  42738. if (isEOF(obj)) {
  42739. break;
  42740. }
  42741. if (isCmd(obj, 'endcodespacerange')) {
  42742. return;
  42743. }
  42744. if (!isString(obj)) {
  42745. break;
  42746. }
  42747. var low = strToInt(obj);
  42748. obj = lexer.getObj();
  42749. if (!isString(obj)) {
  42750. break;
  42751. }
  42752. var high = strToInt(obj);
  42753. cMap.addCodespaceRange(obj.length, low, high);
  42754. }
  42755. error('Invalid codespace range.');
  42756. }
  42757. function parseWMode(cMap, lexer) {
  42758. var obj = lexer.getObj();
  42759. if (isInt(obj)) {
  42760. cMap.vertical = !!obj;
  42761. }
  42762. }
  42763. function parseCMapName(cMap, lexer) {
  42764. var obj = lexer.getObj();
  42765. if (isName(obj) && isString(obj.name)) {
  42766. cMap.name = obj.name;
  42767. }
  42768. }
  42769. function parseCMap(cMap, lexer, builtInCMapParams, useCMap) {
  42770. var previous;
  42771. var embededUseCMap;
  42772. objLoop:
  42773. while (true) {
  42774. try {
  42775. var obj = lexer.getObj();
  42776. if (isEOF(obj)) {
  42777. break;
  42778. } else if (isName(obj)) {
  42779. if (obj.name === 'WMode') {
  42780. parseWMode(cMap, lexer);
  42781. } else if (obj.name === 'CMapName') {
  42782. parseCMapName(cMap, lexer);
  42783. }
  42784. previous = obj;
  42785. } else if (isCmd(obj)) {
  42786. switch (obj.cmd) {
  42787. case 'endcmap':
  42788. break objLoop;
  42789. case 'usecmap':
  42790. if (isName(previous)) {
  42791. embededUseCMap = previous.name;
  42792. }
  42793. break;
  42794. case 'begincodespacerange':
  42795. parseCodespaceRange(cMap, lexer);
  42796. break;
  42797. case 'beginbfchar':
  42798. parseBfChar(cMap, lexer);
  42799. break;
  42800. case 'begincidchar':
  42801. parseCidChar(cMap, lexer);
  42802. break;
  42803. case 'beginbfrange':
  42804. parseBfRange(cMap, lexer);
  42805. break;
  42806. case 'begincidrange':
  42807. parseCidRange(cMap, lexer);
  42808. break;
  42809. }
  42810. }
  42811. } catch (ex) {
  42812. if (ex instanceof MissingDataException) {
  42813. throw ex;
  42814. }
  42815. warn('Invalid cMap data: ' + ex);
  42816. continue;
  42817. }
  42818. }
  42819. if (!useCMap && embededUseCMap) {
  42820. useCMap = embededUseCMap;
  42821. }
  42822. if (useCMap) {
  42823. return extendCMap(cMap, builtInCMapParams, useCMap);
  42824. }
  42825. return Promise.resolve(cMap);
  42826. }
  42827. function extendCMap(cMap, builtInCMapParams, useCMap) {
  42828. return createBuiltInCMap(useCMap, builtInCMapParams).then(function (newCMap) {
  42829. cMap.useCMap = newCMap;
  42830. if (cMap.numCodespaceRanges === 0) {
  42831. var useCodespaceRanges = cMap.useCMap.codespaceRanges;
  42832. for (var i = 0; i < useCodespaceRanges.length; i++) {
  42833. cMap.codespaceRanges[i] = useCodespaceRanges[i].slice();
  42834. }
  42835. cMap.numCodespaceRanges = cMap.useCMap.numCodespaceRanges;
  42836. }
  42837. cMap.useCMap.forEach(function (key, value) {
  42838. if (!cMap.contains(key)) {
  42839. cMap.mapOne(key, cMap.useCMap.lookup(key));
  42840. }
  42841. });
  42842. return cMap;
  42843. });
  42844. }
  42845. function parseBinaryCMap(name, builtInCMapParams) {
  42846. var url = builtInCMapParams.url + name + '.bcmap';
  42847. var cMap = new CMap(true);
  42848. return new BinaryCMapReader().read(url, cMap, function (useCMap) {
  42849. return extendCMap(cMap, builtInCMapParams, useCMap);
  42850. });
  42851. }
  42852. function createBuiltInCMap(name, builtInCMapParams) {
  42853. if (name === 'Identity-H') {
  42854. return Promise.resolve(new IdentityCMap(false, 2));
  42855. } else if (name === 'Identity-V') {
  42856. return Promise.resolve(new IdentityCMap(true, 2));
  42857. }
  42858. if (BUILT_IN_CMAPS.indexOf(name) === -1) {
  42859. return Promise.reject(new Error('Unknown cMap name: ' + name));
  42860. }
  42861. assert(builtInCMapParams, 'built-in cMap parameters are not provided');
  42862. if (builtInCMapParams.packed) {
  42863. return parseBinaryCMap(name, builtInCMapParams);
  42864. }
  42865. return new Promise(function (resolve, reject) {
  42866. var url = builtInCMapParams.url + name;
  42867. var request = new XMLHttpRequest();
  42868. request.onreadystatechange = function () {
  42869. if (request.readyState === XMLHttpRequest.DONE) {
  42870. if (request.status === 200 || request.status === 0) {
  42871. var cMap = new CMap(true);
  42872. var lexer = new Lexer(new StringStream(request.responseText));
  42873. parseCMap(cMap, lexer, builtInCMapParams, null).then(function (parsedCMap) {
  42874. resolve(parsedCMap);
  42875. });
  42876. } else {
  42877. reject(new Error('Unable to get cMap at: ' + url));
  42878. }
  42879. }
  42880. };
  42881. request.open('GET', url, true);
  42882. request.send(null);
  42883. });
  42884. }
  42885. return {
  42886. create: function (encoding, builtInCMapParams, useCMap) {
  42887. if (isName(encoding)) {
  42888. return createBuiltInCMap(encoding.name, builtInCMapParams);
  42889. } else if (isStream(encoding)) {
  42890. var cMap = new CMap();
  42891. var lexer = new Lexer(encoding);
  42892. return parseCMap(cMap, lexer, builtInCMapParams, useCMap).then(function (parsedCMap) {
  42893. if (parsedCMap.isIdentityCMap) {
  42894. return createBuiltInCMap(parsedCMap.name, builtInCMapParams);
  42895. }
  42896. return parsedCMap;
  42897. });
  42898. }
  42899. return Promise.reject(new Error('Encoding required.'));
  42900. }
  42901. };
  42902. }();
  42903. exports.CMap = CMap;
  42904. exports.CMapFactory = CMapFactory;
  42905. exports.IdentityCMap = IdentityCMap;
  42906. /***/ }),
  42907. /* 33 */
  42908. /***/ (function(module, exports, __w_pdfjs_require__) {
  42909. "use strict";
  42910. var sharedUtil = __w_pdfjs_require__(0);
  42911. var corePrimitives = __w_pdfjs_require__(1);
  42912. var coreStream = __w_pdfjs_require__(2);
  42913. var coreObj = __w_pdfjs_require__(20);
  42914. var coreParser = __w_pdfjs_require__(6);
  42915. var coreCrypto = __w_pdfjs_require__(17);
  42916. var coreEvaluator = __w_pdfjs_require__(18);
  42917. var coreAnnotation = __w_pdfjs_require__(29);
  42918. var MissingDataException = sharedUtil.MissingDataException;
  42919. var Util = sharedUtil.Util;
  42920. var assert = sharedUtil.assert;
  42921. var error = sharedUtil.error;
  42922. var info = sharedUtil.info;
  42923. var isArray = sharedUtil.isArray;
  42924. var isArrayBuffer = sharedUtil.isArrayBuffer;
  42925. var isNum = sharedUtil.isNum;
  42926. var isString = sharedUtil.isString;
  42927. var shadow = sharedUtil.shadow;
  42928. var stringToBytes = sharedUtil.stringToBytes;
  42929. var stringToPDFString = sharedUtil.stringToPDFString;
  42930. var warn = sharedUtil.warn;
  42931. var isSpace = sharedUtil.isSpace;
  42932. var Dict = corePrimitives.Dict;
  42933. var isDict = corePrimitives.isDict;
  42934. var isName = corePrimitives.isName;
  42935. var isStream = corePrimitives.isStream;
  42936. var NullStream = coreStream.NullStream;
  42937. var Stream = coreStream.Stream;
  42938. var StreamsSequenceStream = coreStream.StreamsSequenceStream;
  42939. var Catalog = coreObj.Catalog;
  42940. var ObjectLoader = coreObj.ObjectLoader;
  42941. var XRef = coreObj.XRef;
  42942. var Linearization = coreParser.Linearization;
  42943. var calculateMD5 = coreCrypto.calculateMD5;
  42944. var OperatorList = coreEvaluator.OperatorList;
  42945. var PartialEvaluator = coreEvaluator.PartialEvaluator;
  42946. var Annotation = coreAnnotation.Annotation;
  42947. var AnnotationFactory = coreAnnotation.AnnotationFactory;
  42948. var Page = function PageClosure() {
  42949. var DEFAULT_USER_UNIT = 1.0;
  42950. var LETTER_SIZE_MEDIABOX = [
  42951. 0,
  42952. 0,
  42953. 612,
  42954. 792
  42955. ];
  42956. function Page(pdfManager, xref, pageIndex, pageDict, ref, fontCache) {
  42957. this.pdfManager = pdfManager;
  42958. this.pageIndex = pageIndex;
  42959. this.pageDict = pageDict;
  42960. this.xref = xref;
  42961. this.ref = ref;
  42962. this.fontCache = fontCache;
  42963. this.evaluatorOptions = pdfManager.evaluatorOptions;
  42964. this.resourcesPromise = null;
  42965. var uniquePrefix = 'p' + this.pageIndex + '_';
  42966. var idCounters = { obj: 0 };
  42967. this.idFactory = {
  42968. createObjId: function () {
  42969. return uniquePrefix + ++idCounters.obj;
  42970. }
  42971. };
  42972. }
  42973. Page.prototype = {
  42974. getPageProp: function Page_getPageProp(key) {
  42975. return this.pageDict.get(key);
  42976. },
  42977. getInheritedPageProp: function Page_getInheritedPageProp(key, getArray) {
  42978. var dict = this.pageDict, valueArray = null, loopCount = 0;
  42979. var MAX_LOOP_COUNT = 100;
  42980. getArray = getArray || false;
  42981. while (dict) {
  42982. var value = getArray ? dict.getArray(key) : dict.get(key);
  42983. if (value) {
  42984. if (!valueArray) {
  42985. valueArray = [];
  42986. }
  42987. valueArray.push(value);
  42988. }
  42989. if (++loopCount > MAX_LOOP_COUNT) {
  42990. warn('Page_getInheritedPageProp: maximum loop count exceeded.');
  42991. break;
  42992. }
  42993. dict = dict.get('Parent');
  42994. }
  42995. if (!valueArray) {
  42996. return Dict.empty;
  42997. }
  42998. if (valueArray.length === 1 || !isDict(valueArray[0]) || loopCount > MAX_LOOP_COUNT) {
  42999. return valueArray[0];
  43000. }
  43001. return Dict.merge(this.xref, valueArray);
  43002. },
  43003. get content() {
  43004. return this.getPageProp('Contents');
  43005. },
  43006. get resources() {
  43007. return shadow(this, 'resources', this.getInheritedPageProp('Resources'));
  43008. },
  43009. get mediaBox() {
  43010. var mediaBox = this.getInheritedPageProp('MediaBox', true);
  43011. if (!isArray(mediaBox) || mediaBox.length !== 4) {
  43012. return shadow(this, 'mediaBox', LETTER_SIZE_MEDIABOX);
  43013. }
  43014. return shadow(this, 'mediaBox', mediaBox);
  43015. },
  43016. get cropBox() {
  43017. var cropBox = this.getInheritedPageProp('CropBox', true);
  43018. if (!isArray(cropBox) || cropBox.length !== 4) {
  43019. return shadow(this, 'cropBox', this.mediaBox);
  43020. }
  43021. return shadow(this, 'cropBox', cropBox);
  43022. },
  43023. get userUnit() {
  43024. var obj = this.getPageProp('UserUnit');
  43025. if (!isNum(obj) || obj <= 0) {
  43026. obj = DEFAULT_USER_UNIT;
  43027. }
  43028. return shadow(this, 'userUnit', obj);
  43029. },
  43030. get view() {
  43031. var mediaBox = this.mediaBox, cropBox = this.cropBox;
  43032. if (mediaBox === cropBox) {
  43033. return shadow(this, 'view', mediaBox);
  43034. }
  43035. var intersection = Util.intersect(cropBox, mediaBox);
  43036. return shadow(this, 'view', intersection || mediaBox);
  43037. },
  43038. get rotate() {
  43039. var rotate = this.getInheritedPageProp('Rotate') || 0;
  43040. if (rotate % 90 !== 0) {
  43041. rotate = 0;
  43042. } else if (rotate >= 360) {
  43043. rotate = rotate % 360;
  43044. } else if (rotate < 0) {
  43045. rotate = (rotate % 360 + 360) % 360;
  43046. }
  43047. return shadow(this, 'rotate', rotate);
  43048. },
  43049. getContentStream: function Page_getContentStream() {
  43050. var content = this.content;
  43051. var stream;
  43052. if (isArray(content)) {
  43053. var xref = this.xref;
  43054. var i, n = content.length;
  43055. var streams = [];
  43056. for (i = 0; i < n; ++i) {
  43057. streams.push(xref.fetchIfRef(content[i]));
  43058. }
  43059. stream = new StreamsSequenceStream(streams);
  43060. } else if (isStream(content)) {
  43061. stream = content;
  43062. } else {
  43063. stream = new NullStream();
  43064. }
  43065. return stream;
  43066. },
  43067. loadResources: function Page_loadResources(keys) {
  43068. if (!this.resourcesPromise) {
  43069. this.resourcesPromise = this.pdfManager.ensure(this, 'resources');
  43070. }
  43071. return this.resourcesPromise.then(function resourceSuccess() {
  43072. var objectLoader = new ObjectLoader(this.resources.map, keys, this.xref);
  43073. return objectLoader.load();
  43074. }.bind(this));
  43075. },
  43076. getOperatorList: function Page_getOperatorList(handler, task, intent, renderInteractiveForms) {
  43077. var self = this;
  43078. var pdfManager = this.pdfManager;
  43079. var contentStreamPromise = pdfManager.ensure(this, 'getContentStream', []);
  43080. var resourcesPromise = this.loadResources([
  43081. 'ExtGState',
  43082. 'ColorSpace',
  43083. 'Pattern',
  43084. 'Shading',
  43085. 'XObject',
  43086. 'Font'
  43087. ]);
  43088. var partialEvaluator = new PartialEvaluator(pdfManager, this.xref, handler, this.pageIndex, this.idFactory, this.fontCache, this.evaluatorOptions);
  43089. var dataPromises = Promise.all([
  43090. contentStreamPromise,
  43091. resourcesPromise
  43092. ]);
  43093. var pageListPromise = dataPromises.then(function (data) {
  43094. var contentStream = data[0];
  43095. var opList = new OperatorList(intent, handler, self.pageIndex);
  43096. handler.send('StartRenderPage', {
  43097. transparency: partialEvaluator.hasBlendModes(self.resources),
  43098. pageIndex: self.pageIndex,
  43099. intent: intent
  43100. });
  43101. return partialEvaluator.getOperatorList(contentStream, task, self.resources, opList).then(function () {
  43102. return opList;
  43103. });
  43104. });
  43105. var annotationsPromise = pdfManager.ensure(this, 'annotations');
  43106. return Promise.all([
  43107. pageListPromise,
  43108. annotationsPromise
  43109. ]).then(function (datas) {
  43110. var pageOpList = datas[0];
  43111. var annotations = datas[1];
  43112. if (annotations.length === 0) {
  43113. pageOpList.flush(true);
  43114. return pageOpList;
  43115. }
  43116. var annotationsReadyPromise = Annotation.appendToOperatorList(annotations, pageOpList, partialEvaluator, task, intent, renderInteractiveForms);
  43117. return annotationsReadyPromise.then(function () {
  43118. pageOpList.flush(true);
  43119. return pageOpList;
  43120. });
  43121. });
  43122. },
  43123. extractTextContent: function Page_extractTextContent(task, normalizeWhitespace, combineTextItems) {
  43124. var handler = {
  43125. on: function nullHandlerOn() {
  43126. },
  43127. send: function nullHandlerSend() {
  43128. }
  43129. };
  43130. var self = this;
  43131. var pdfManager = this.pdfManager;
  43132. var contentStreamPromise = pdfManager.ensure(this, 'getContentStream', []);
  43133. var resourcesPromise = this.loadResources([
  43134. 'ExtGState',
  43135. 'XObject',
  43136. 'Font'
  43137. ]);
  43138. var dataPromises = Promise.all([
  43139. contentStreamPromise,
  43140. resourcesPromise
  43141. ]);
  43142. return dataPromises.then(function (data) {
  43143. var contentStream = data[0];
  43144. var partialEvaluator = new PartialEvaluator(pdfManager, self.xref, handler, self.pageIndex, self.idFactory, self.fontCache, self.evaluatorOptions);
  43145. return partialEvaluator.getTextContent(contentStream, task, self.resources, null, normalizeWhitespace, combineTextItems);
  43146. });
  43147. },
  43148. getAnnotationsData: function Page_getAnnotationsData(intent) {
  43149. var annotations = this.annotations;
  43150. var annotationsData = [];
  43151. for (var i = 0, n = annotations.length; i < n; ++i) {
  43152. if (intent) {
  43153. if (!(intent === 'display' && annotations[i].viewable) && !(intent === 'print' && annotations[i].printable)) {
  43154. continue;
  43155. }
  43156. }
  43157. annotationsData.push(annotations[i].data);
  43158. }
  43159. return annotationsData;
  43160. },
  43161. get annotations() {
  43162. var annotations = [];
  43163. var annotationRefs = this.getInheritedPageProp('Annots') || [];
  43164. var annotationFactory = new AnnotationFactory();
  43165. for (var i = 0, n = annotationRefs.length; i < n; ++i) {
  43166. var annotationRef = annotationRefs[i];
  43167. var annotation = annotationFactory.create(this.xref, annotationRef, this.pdfManager, this.idFactory);
  43168. if (annotation) {
  43169. annotations.push(annotation);
  43170. }
  43171. }
  43172. return shadow(this, 'annotations', annotations);
  43173. }
  43174. };
  43175. return Page;
  43176. }();
  43177. var PDFDocument = function PDFDocumentClosure() {
  43178. var FINGERPRINT_FIRST_BYTES = 1024;
  43179. var EMPTY_FINGERPRINT = '\x00\x00\x00\x00\x00\x00\x00' + '\x00\x00\x00\x00\x00\x00\x00\x00\x00';
  43180. function PDFDocument(pdfManager, arg) {
  43181. var stream;
  43182. if (isStream(arg)) {
  43183. stream = arg;
  43184. } else if (isArrayBuffer(arg)) {
  43185. stream = new Stream(arg);
  43186. } else {
  43187. error('PDFDocument: Unknown argument type');
  43188. }
  43189. assert(stream.length > 0, 'stream must have data');
  43190. this.pdfManager = pdfManager;
  43191. this.stream = stream;
  43192. this.xref = new XRef(stream, pdfManager);
  43193. }
  43194. function find(stream, needle, limit, backwards) {
  43195. var pos = stream.pos;
  43196. var end = stream.end;
  43197. var strBuf = [];
  43198. if (pos + limit > end) {
  43199. limit = end - pos;
  43200. }
  43201. for (var n = 0; n < limit; ++n) {
  43202. strBuf.push(String.fromCharCode(stream.getByte()));
  43203. }
  43204. var str = strBuf.join('');
  43205. stream.pos = pos;
  43206. var index = backwards ? str.lastIndexOf(needle) : str.indexOf(needle);
  43207. if (index === -1) {
  43208. return false;
  43209. }
  43210. stream.pos += index;
  43211. return true;
  43212. }
  43213. var DocumentInfoValidators = {
  43214. get entries() {
  43215. return shadow(this, 'entries', {
  43216. Title: isString,
  43217. Author: isString,
  43218. Subject: isString,
  43219. Keywords: isString,
  43220. Creator: isString,
  43221. Producer: isString,
  43222. CreationDate: isString,
  43223. ModDate: isString,
  43224. Trapped: isName
  43225. });
  43226. }
  43227. };
  43228. PDFDocument.prototype = {
  43229. parse: function PDFDocument_parse(recoveryMode) {
  43230. this.setup(recoveryMode);
  43231. var version = this.catalog.catDict.get('Version');
  43232. if (isName(version)) {
  43233. this.pdfFormatVersion = version.name;
  43234. }
  43235. try {
  43236. this.acroForm = this.catalog.catDict.get('AcroForm');
  43237. if (this.acroForm) {
  43238. this.xfa = this.acroForm.get('XFA');
  43239. var fields = this.acroForm.get('Fields');
  43240. if ((!fields || !isArray(fields) || fields.length === 0) && !this.xfa) {
  43241. this.acroForm = null;
  43242. }
  43243. }
  43244. } catch (ex) {
  43245. info('Something wrong with AcroForm entry');
  43246. this.acroForm = null;
  43247. }
  43248. },
  43249. get linearization() {
  43250. var linearization = null;
  43251. if (this.stream.length) {
  43252. try {
  43253. linearization = Linearization.create(this.stream);
  43254. } catch (err) {
  43255. if (err instanceof MissingDataException) {
  43256. throw err;
  43257. }
  43258. info(err);
  43259. }
  43260. }
  43261. return shadow(this, 'linearization', linearization);
  43262. },
  43263. get startXRef() {
  43264. var stream = this.stream;
  43265. var startXRef = 0;
  43266. var linearization = this.linearization;
  43267. if (linearization) {
  43268. stream.reset();
  43269. if (find(stream, 'endobj', 1024)) {
  43270. startXRef = stream.pos + 6;
  43271. }
  43272. } else {
  43273. var step = 1024;
  43274. var found = false, pos = stream.end;
  43275. while (!found && pos > 0) {
  43276. pos -= step - 'startxref'.length;
  43277. if (pos < 0) {
  43278. pos = 0;
  43279. }
  43280. stream.pos = pos;
  43281. found = find(stream, 'startxref', step, true);
  43282. }
  43283. if (found) {
  43284. stream.skip(9);
  43285. var ch;
  43286. do {
  43287. ch = stream.getByte();
  43288. } while (isSpace(ch));
  43289. var str = '';
  43290. while (ch >= 0x20 && ch <= 0x39) {
  43291. str += String.fromCharCode(ch);
  43292. ch = stream.getByte();
  43293. }
  43294. startXRef = parseInt(str, 10);
  43295. if (isNaN(startXRef)) {
  43296. startXRef = 0;
  43297. }
  43298. }
  43299. }
  43300. return shadow(this, 'startXRef', startXRef);
  43301. },
  43302. get mainXRefEntriesOffset() {
  43303. var mainXRefEntriesOffset = 0;
  43304. var linearization = this.linearization;
  43305. if (linearization) {
  43306. mainXRefEntriesOffset = linearization.mainXRefEntriesOffset;
  43307. }
  43308. return shadow(this, 'mainXRefEntriesOffset', mainXRefEntriesOffset);
  43309. },
  43310. checkHeader: function PDFDocument_checkHeader() {
  43311. var stream = this.stream;
  43312. stream.reset();
  43313. if (find(stream, '%PDF-', 1024)) {
  43314. stream.moveStart();
  43315. var MAX_VERSION_LENGTH = 12;
  43316. var version = '', ch;
  43317. while ((ch = stream.getByte()) > 0x20) {
  43318. if (version.length >= MAX_VERSION_LENGTH) {
  43319. break;
  43320. }
  43321. version += String.fromCharCode(ch);
  43322. }
  43323. if (!this.pdfFormatVersion) {
  43324. this.pdfFormatVersion = version.substring(5);
  43325. }
  43326. return;
  43327. }
  43328. },
  43329. parseStartXRef: function PDFDocument_parseStartXRef() {
  43330. var startXRef = this.startXRef;
  43331. this.xref.setStartXRef(startXRef);
  43332. },
  43333. setup: function PDFDocument_setup(recoveryMode) {
  43334. this.xref.parse(recoveryMode);
  43335. var self = this;
  43336. var pageFactory = {
  43337. createPage: function (pageIndex, dict, ref, fontCache) {
  43338. return new Page(self.pdfManager, self.xref, pageIndex, dict, ref, fontCache);
  43339. }
  43340. };
  43341. this.catalog = new Catalog(this.pdfManager, this.xref, pageFactory);
  43342. },
  43343. get numPages() {
  43344. var linearization = this.linearization;
  43345. var num = linearization ? linearization.numPages : this.catalog.numPages;
  43346. return shadow(this, 'numPages', num);
  43347. },
  43348. get documentInfo() {
  43349. var docInfo = {
  43350. PDFFormatVersion: this.pdfFormatVersion,
  43351. IsAcroFormPresent: !!this.acroForm,
  43352. IsXFAPresent: !!this.xfa
  43353. };
  43354. var infoDict;
  43355. try {
  43356. infoDict = this.xref.trailer.get('Info');
  43357. } catch (err) {
  43358. info('The document information dictionary is invalid.');
  43359. }
  43360. if (infoDict) {
  43361. var validEntries = DocumentInfoValidators.entries;
  43362. for (var key in validEntries) {
  43363. if (infoDict.has(key)) {
  43364. var value = infoDict.get(key);
  43365. if (validEntries[key](value)) {
  43366. docInfo[key] = typeof value !== 'string' ? value : stringToPDFString(value);
  43367. } else {
  43368. info('Bad value in document info for "' + key + '"');
  43369. }
  43370. }
  43371. }
  43372. }
  43373. return shadow(this, 'documentInfo', docInfo);
  43374. },
  43375. get fingerprint() {
  43376. var xref = this.xref, hash, fileID = '';
  43377. var idArray = xref.trailer.get('ID');
  43378. if (idArray && isArray(idArray) && idArray[0] && isString(idArray[0]) && idArray[0] !== EMPTY_FINGERPRINT) {
  43379. hash = stringToBytes(idArray[0]);
  43380. } else {
  43381. if (this.stream.ensureRange) {
  43382. this.stream.ensureRange(0, Math.min(FINGERPRINT_FIRST_BYTES, this.stream.end));
  43383. }
  43384. hash = calculateMD5(this.stream.bytes.subarray(0, FINGERPRINT_FIRST_BYTES), 0, FINGERPRINT_FIRST_BYTES);
  43385. }
  43386. for (var i = 0, n = hash.length; i < n; i++) {
  43387. var hex = hash[i].toString(16);
  43388. fileID += hex.length === 1 ? '0' + hex : hex;
  43389. }
  43390. return shadow(this, 'fingerprint', fileID);
  43391. },
  43392. getPage: function PDFDocument_getPage(pageIndex) {
  43393. return this.catalog.getPage(pageIndex);
  43394. },
  43395. cleanup: function PDFDocument_cleanup() {
  43396. return this.catalog.cleanup();
  43397. }
  43398. };
  43399. return PDFDocument;
  43400. }();
  43401. exports.Page = Page;
  43402. exports.PDFDocument = PDFDocument;
  43403. /***/ }),
  43404. /* 34 */
  43405. /***/ (function(module, exports, __w_pdfjs_require__) {
  43406. "use strict";
  43407. var sharedUtil = __w_pdfjs_require__(0);
  43408. var coreStream = __w_pdfjs_require__(2);
  43409. var coreGlyphList = __w_pdfjs_require__(8);
  43410. var coreEncodings = __w_pdfjs_require__(5);
  43411. var coreCFFParser = __w_pdfjs_require__(15);
  43412. var Util = sharedUtil.Util;
  43413. var bytesToString = sharedUtil.bytesToString;
  43414. var error = sharedUtil.error;
  43415. var Stream = coreStream.Stream;
  43416. var getGlyphsUnicode = coreGlyphList.getGlyphsUnicode;
  43417. var StandardEncoding = coreEncodings.StandardEncoding;
  43418. var CFFParser = coreCFFParser.CFFParser;
  43419. var FontRendererFactory = function FontRendererFactoryClosure() {
  43420. function getLong(data, offset) {
  43421. return data[offset] << 24 | data[offset + 1] << 16 | data[offset + 2] << 8 | data[offset + 3];
  43422. }
  43423. function getUshort(data, offset) {
  43424. return data[offset] << 8 | data[offset + 1];
  43425. }
  43426. function parseCmap(data, start, end) {
  43427. var offset = getUshort(data, start + 2) === 1 ? getLong(data, start + 8) : getLong(data, start + 16);
  43428. var format = getUshort(data, start + offset);
  43429. var ranges, p, i;
  43430. if (format === 4) {
  43431. getUshort(data, start + offset + 2);
  43432. var segCount = getUshort(data, start + offset + 6) >> 1;
  43433. p = start + offset + 14;
  43434. ranges = [];
  43435. for (i = 0; i < segCount; i++, p += 2) {
  43436. ranges[i] = { end: getUshort(data, p) };
  43437. }
  43438. p += 2;
  43439. for (i = 0; i < segCount; i++, p += 2) {
  43440. ranges[i].start = getUshort(data, p);
  43441. }
  43442. for (i = 0; i < segCount; i++, p += 2) {
  43443. ranges[i].idDelta = getUshort(data, p);
  43444. }
  43445. for (i = 0; i < segCount; i++, p += 2) {
  43446. var idOffset = getUshort(data, p);
  43447. if (idOffset === 0) {
  43448. continue;
  43449. }
  43450. ranges[i].ids = [];
  43451. for (var j = 0, jj = ranges[i].end - ranges[i].start + 1; j < jj; j++) {
  43452. ranges[i].ids[j] = getUshort(data, p + idOffset);
  43453. idOffset += 2;
  43454. }
  43455. }
  43456. return ranges;
  43457. } else if (format === 12) {
  43458. getLong(data, start + offset + 4);
  43459. var groups = getLong(data, start + offset + 12);
  43460. p = start + offset + 16;
  43461. ranges = [];
  43462. for (i = 0; i < groups; i++) {
  43463. ranges.push({
  43464. start: getLong(data, p),
  43465. end: getLong(data, p + 4),
  43466. idDelta: getLong(data, p + 8) - getLong(data, p)
  43467. });
  43468. p += 12;
  43469. }
  43470. return ranges;
  43471. }
  43472. error('not supported cmap: ' + format);
  43473. }
  43474. function parseCff(data, start, end, seacAnalysisEnabled) {
  43475. var properties = {};
  43476. var parser = new CFFParser(new Stream(data, start, end - start), properties, seacAnalysisEnabled);
  43477. var cff = parser.parse();
  43478. return {
  43479. glyphs: cff.charStrings.objects,
  43480. subrs: cff.topDict.privateDict && cff.topDict.privateDict.subrsIndex && cff.topDict.privateDict.subrsIndex.objects,
  43481. gsubrs: cff.globalSubrIndex && cff.globalSubrIndex.objects
  43482. };
  43483. }
  43484. function parseGlyfTable(glyf, loca, isGlyphLocationsLong) {
  43485. var itemSize, itemDecode;
  43486. if (isGlyphLocationsLong) {
  43487. itemSize = 4;
  43488. itemDecode = function fontItemDecodeLong(data, offset) {
  43489. return data[offset] << 24 | data[offset + 1] << 16 | data[offset + 2] << 8 | data[offset + 3];
  43490. };
  43491. } else {
  43492. itemSize = 2;
  43493. itemDecode = function fontItemDecode(data, offset) {
  43494. return data[offset] << 9 | data[offset + 1] << 1;
  43495. };
  43496. }
  43497. var glyphs = [];
  43498. var startOffset = itemDecode(loca, 0);
  43499. for (var j = itemSize; j < loca.length; j += itemSize) {
  43500. var endOffset = itemDecode(loca, j);
  43501. glyphs.push(glyf.subarray(startOffset, endOffset));
  43502. startOffset = endOffset;
  43503. }
  43504. return glyphs;
  43505. }
  43506. function lookupCmap(ranges, unicode) {
  43507. var code = unicode.charCodeAt(0), gid = 0;
  43508. var l = 0, r = ranges.length - 1;
  43509. while (l < r) {
  43510. var c = l + r + 1 >> 1;
  43511. if (code < ranges[c].start) {
  43512. r = c - 1;
  43513. } else {
  43514. l = c;
  43515. }
  43516. }
  43517. if (ranges[l].start <= code && code <= ranges[l].end) {
  43518. gid = ranges[l].idDelta + (ranges[l].ids ? ranges[l].ids[code - ranges[l].start] : code) & 0xFFFF;
  43519. }
  43520. return {
  43521. charCode: code,
  43522. glyphId: gid
  43523. };
  43524. }
  43525. function compileGlyf(code, cmds, font) {
  43526. function moveTo(x, y) {
  43527. cmds.push({
  43528. cmd: 'moveTo',
  43529. args: [
  43530. x,
  43531. y
  43532. ]
  43533. });
  43534. }
  43535. function lineTo(x, y) {
  43536. cmds.push({
  43537. cmd: 'lineTo',
  43538. args: [
  43539. x,
  43540. y
  43541. ]
  43542. });
  43543. }
  43544. function quadraticCurveTo(xa, ya, x, y) {
  43545. cmds.push({
  43546. cmd: 'quadraticCurveTo',
  43547. args: [
  43548. xa,
  43549. ya,
  43550. x,
  43551. y
  43552. ]
  43553. });
  43554. }
  43555. var i = 0;
  43556. var numberOfContours = (code[i] << 24 | code[i + 1] << 16) >> 16;
  43557. var flags;
  43558. var x = 0, y = 0;
  43559. i += 10;
  43560. if (numberOfContours < 0) {
  43561. do {
  43562. flags = code[i] << 8 | code[i + 1];
  43563. var glyphIndex = code[i + 2] << 8 | code[i + 3];
  43564. i += 4;
  43565. var arg1, arg2;
  43566. if (flags & 0x01) {
  43567. arg1 = (code[i] << 24 | code[i + 1] << 16) >> 16;
  43568. arg2 = (code[i + 2] << 24 | code[i + 3] << 16) >> 16;
  43569. i += 4;
  43570. } else {
  43571. arg1 = code[i++];
  43572. arg2 = code[i++];
  43573. }
  43574. if (flags & 0x02) {
  43575. x = arg1;
  43576. y = arg2;
  43577. } else {
  43578. x = 0;
  43579. y = 0;
  43580. }
  43581. var scaleX = 1, scaleY = 1, scale01 = 0, scale10 = 0;
  43582. if (flags & 0x08) {
  43583. scaleX = scaleY = (code[i] << 24 | code[i + 1] << 16) / 1073741824;
  43584. i += 2;
  43585. } else if (flags & 0x40) {
  43586. scaleX = (code[i] << 24 | code[i + 1] << 16) / 1073741824;
  43587. scaleY = (code[i + 2] << 24 | code[i + 3] << 16) / 1073741824;
  43588. i += 4;
  43589. } else if (flags & 0x80) {
  43590. scaleX = (code[i] << 24 | code[i + 1] << 16) / 1073741824;
  43591. scale01 = (code[i + 2] << 24 | code[i + 3] << 16) / 1073741824;
  43592. scale10 = (code[i + 4] << 24 | code[i + 5] << 16) / 1073741824;
  43593. scaleY = (code[i + 6] << 24 | code[i + 7] << 16) / 1073741824;
  43594. i += 8;
  43595. }
  43596. var subglyph = font.glyphs[glyphIndex];
  43597. if (subglyph) {
  43598. cmds.push({ cmd: 'save' });
  43599. cmds.push({
  43600. cmd: 'transform',
  43601. args: [
  43602. scaleX,
  43603. scale01,
  43604. scale10,
  43605. scaleY,
  43606. x,
  43607. y
  43608. ]
  43609. });
  43610. compileGlyf(subglyph, cmds, font);
  43611. cmds.push({ cmd: 'restore' });
  43612. }
  43613. } while (flags & 0x20);
  43614. } else {
  43615. var endPtsOfContours = [];
  43616. var j, jj;
  43617. for (j = 0; j < numberOfContours; j++) {
  43618. endPtsOfContours.push(code[i] << 8 | code[i + 1]);
  43619. i += 2;
  43620. }
  43621. var instructionLength = code[i] << 8 | code[i + 1];
  43622. i += 2 + instructionLength;
  43623. var numberOfPoints = endPtsOfContours[endPtsOfContours.length - 1] + 1;
  43624. var points = [];
  43625. while (points.length < numberOfPoints) {
  43626. flags = code[i++];
  43627. var repeat = 1;
  43628. if (flags & 0x08) {
  43629. repeat += code[i++];
  43630. }
  43631. while (repeat-- > 0) {
  43632. points.push({ flags: flags });
  43633. }
  43634. }
  43635. for (j = 0; j < numberOfPoints; j++) {
  43636. switch (points[j].flags & 0x12) {
  43637. case 0x00:
  43638. x += (code[i] << 24 | code[i + 1] << 16) >> 16;
  43639. i += 2;
  43640. break;
  43641. case 0x02:
  43642. x -= code[i++];
  43643. break;
  43644. case 0x12:
  43645. x += code[i++];
  43646. break;
  43647. }
  43648. points[j].x = x;
  43649. }
  43650. for (j = 0; j < numberOfPoints; j++) {
  43651. switch (points[j].flags & 0x24) {
  43652. case 0x00:
  43653. y += (code[i] << 24 | code[i + 1] << 16) >> 16;
  43654. i += 2;
  43655. break;
  43656. case 0x04:
  43657. y -= code[i++];
  43658. break;
  43659. case 0x24:
  43660. y += code[i++];
  43661. break;
  43662. }
  43663. points[j].y = y;
  43664. }
  43665. var startPoint = 0;
  43666. for (i = 0; i < numberOfContours; i++) {
  43667. var endPoint = endPtsOfContours[i];
  43668. var contour = points.slice(startPoint, endPoint + 1);
  43669. if (contour[0].flags & 1) {
  43670. contour.push(contour[0]);
  43671. } else if (contour[contour.length - 1].flags & 1) {
  43672. contour.unshift(contour[contour.length - 1]);
  43673. } else {
  43674. var p = {
  43675. flags: 1,
  43676. x: (contour[0].x + contour[contour.length - 1].x) / 2,
  43677. y: (contour[0].y + contour[contour.length - 1].y) / 2
  43678. };
  43679. contour.unshift(p);
  43680. contour.push(p);
  43681. }
  43682. moveTo(contour[0].x, contour[0].y);
  43683. for (j = 1, jj = contour.length; j < jj; j++) {
  43684. if (contour[j].flags & 1) {
  43685. lineTo(contour[j].x, contour[j].y);
  43686. } else if (contour[j + 1].flags & 1) {
  43687. quadraticCurveTo(contour[j].x, contour[j].y, contour[j + 1].x, contour[j + 1].y);
  43688. j++;
  43689. } else {
  43690. quadraticCurveTo(contour[j].x, contour[j].y, (contour[j].x + contour[j + 1].x) / 2, (contour[j].y + contour[j + 1].y) / 2);
  43691. }
  43692. }
  43693. startPoint = endPoint + 1;
  43694. }
  43695. }
  43696. }
  43697. function compileCharString(code, cmds, font) {
  43698. var stack = [];
  43699. var x = 0, y = 0;
  43700. var stems = 0;
  43701. function moveTo(x, y) {
  43702. cmds.push({
  43703. cmd: 'moveTo',
  43704. args: [
  43705. x,
  43706. y
  43707. ]
  43708. });
  43709. }
  43710. function lineTo(x, y) {
  43711. cmds.push({
  43712. cmd: 'lineTo',
  43713. args: [
  43714. x,
  43715. y
  43716. ]
  43717. });
  43718. }
  43719. function bezierCurveTo(x1, y1, x2, y2, x, y) {
  43720. cmds.push({
  43721. cmd: 'bezierCurveTo',
  43722. args: [
  43723. x1,
  43724. y1,
  43725. x2,
  43726. y2,
  43727. x,
  43728. y
  43729. ]
  43730. });
  43731. }
  43732. function parse(code) {
  43733. var i = 0;
  43734. while (i < code.length) {
  43735. var stackClean = false;
  43736. var v = code[i++];
  43737. var xa, xb, ya, yb, y1, y2, y3, n, subrCode;
  43738. switch (v) {
  43739. case 1:
  43740. stems += stack.length >> 1;
  43741. stackClean = true;
  43742. break;
  43743. case 3:
  43744. stems += stack.length >> 1;
  43745. stackClean = true;
  43746. break;
  43747. case 4:
  43748. y += stack.pop();
  43749. moveTo(x, y);
  43750. stackClean = true;
  43751. break;
  43752. case 5:
  43753. while (stack.length > 0) {
  43754. x += stack.shift();
  43755. y += stack.shift();
  43756. lineTo(x, y);
  43757. }
  43758. break;
  43759. case 6:
  43760. while (stack.length > 0) {
  43761. x += stack.shift();
  43762. lineTo(x, y);
  43763. if (stack.length === 0) {
  43764. break;
  43765. }
  43766. y += stack.shift();
  43767. lineTo(x, y);
  43768. }
  43769. break;
  43770. case 7:
  43771. while (stack.length > 0) {
  43772. y += stack.shift();
  43773. lineTo(x, y);
  43774. if (stack.length === 0) {
  43775. break;
  43776. }
  43777. x += stack.shift();
  43778. lineTo(x, y);
  43779. }
  43780. break;
  43781. case 8:
  43782. while (stack.length > 0) {
  43783. xa = x + stack.shift();
  43784. ya = y + stack.shift();
  43785. xb = xa + stack.shift();
  43786. yb = ya + stack.shift();
  43787. x = xb + stack.shift();
  43788. y = yb + stack.shift();
  43789. bezierCurveTo(xa, ya, xb, yb, x, y);
  43790. }
  43791. break;
  43792. case 10:
  43793. n = stack.pop() + font.subrsBias;
  43794. subrCode = font.subrs[n];
  43795. if (subrCode) {
  43796. parse(subrCode);
  43797. }
  43798. break;
  43799. case 11:
  43800. return;
  43801. case 12:
  43802. v = code[i++];
  43803. switch (v) {
  43804. case 34:
  43805. xa = x + stack.shift();
  43806. xb = xa + stack.shift();
  43807. y1 = y + stack.shift();
  43808. x = xb + stack.shift();
  43809. bezierCurveTo(xa, y, xb, y1, x, y1);
  43810. xa = x + stack.shift();
  43811. xb = xa + stack.shift();
  43812. x = xb + stack.shift();
  43813. bezierCurveTo(xa, y1, xb, y, x, y);
  43814. break;
  43815. case 35:
  43816. xa = x + stack.shift();
  43817. ya = y + stack.shift();
  43818. xb = xa + stack.shift();
  43819. yb = ya + stack.shift();
  43820. x = xb + stack.shift();
  43821. y = yb + stack.shift();
  43822. bezierCurveTo(xa, ya, xb, yb, x, y);
  43823. xa = x + stack.shift();
  43824. ya = y + stack.shift();
  43825. xb = xa + stack.shift();
  43826. yb = ya + stack.shift();
  43827. x = xb + stack.shift();
  43828. y = yb + stack.shift();
  43829. bezierCurveTo(xa, ya, xb, yb, x, y);
  43830. stack.pop();
  43831. break;
  43832. case 36:
  43833. xa = x + stack.shift();
  43834. y1 = y + stack.shift();
  43835. xb = xa + stack.shift();
  43836. y2 = y1 + stack.shift();
  43837. x = xb + stack.shift();
  43838. bezierCurveTo(xa, y1, xb, y2, x, y2);
  43839. xa = x + stack.shift();
  43840. xb = xa + stack.shift();
  43841. y3 = y2 + stack.shift();
  43842. x = xb + stack.shift();
  43843. bezierCurveTo(xa, y2, xb, y3, x, y);
  43844. break;
  43845. case 37:
  43846. var x0 = x, y0 = y;
  43847. xa = x + stack.shift();
  43848. ya = y + stack.shift();
  43849. xb = xa + stack.shift();
  43850. yb = ya + stack.shift();
  43851. x = xb + stack.shift();
  43852. y = yb + stack.shift();
  43853. bezierCurveTo(xa, ya, xb, yb, x, y);
  43854. xa = x + stack.shift();
  43855. ya = y + stack.shift();
  43856. xb = xa + stack.shift();
  43857. yb = ya + stack.shift();
  43858. x = xb;
  43859. y = yb;
  43860. if (Math.abs(x - x0) > Math.abs(y - y0)) {
  43861. x += stack.shift();
  43862. } else {
  43863. y += stack.shift();
  43864. }
  43865. bezierCurveTo(xa, ya, xb, yb, x, y);
  43866. break;
  43867. default:
  43868. error('unknown operator: 12 ' + v);
  43869. }
  43870. break;
  43871. case 14:
  43872. if (stack.length >= 4) {
  43873. var achar = stack.pop();
  43874. var bchar = stack.pop();
  43875. y = stack.pop();
  43876. x = stack.pop();
  43877. cmds.push({ cmd: 'save' });
  43878. cmds.push({
  43879. cmd: 'translate',
  43880. args: [
  43881. x,
  43882. y
  43883. ]
  43884. });
  43885. var cmap = lookupCmap(font.cmap, String.fromCharCode(font.glyphNameMap[StandardEncoding[achar]]));
  43886. compileCharString(font.glyphs[cmap.glyphId], cmds, font);
  43887. cmds.push({ cmd: 'restore' });
  43888. cmap = lookupCmap(font.cmap, String.fromCharCode(font.glyphNameMap[StandardEncoding[bchar]]));
  43889. compileCharString(font.glyphs[cmap.glyphId], cmds, font);
  43890. }
  43891. return;
  43892. case 18:
  43893. stems += stack.length >> 1;
  43894. stackClean = true;
  43895. break;
  43896. case 19:
  43897. stems += stack.length >> 1;
  43898. i += stems + 7 >> 3;
  43899. stackClean = true;
  43900. break;
  43901. case 20:
  43902. stems += stack.length >> 1;
  43903. i += stems + 7 >> 3;
  43904. stackClean = true;
  43905. break;
  43906. case 21:
  43907. y += stack.pop();
  43908. x += stack.pop();
  43909. moveTo(x, y);
  43910. stackClean = true;
  43911. break;
  43912. case 22:
  43913. x += stack.pop();
  43914. moveTo(x, y);
  43915. stackClean = true;
  43916. break;
  43917. case 23:
  43918. stems += stack.length >> 1;
  43919. stackClean = true;
  43920. break;
  43921. case 24:
  43922. while (stack.length > 2) {
  43923. xa = x + stack.shift();
  43924. ya = y + stack.shift();
  43925. xb = xa + stack.shift();
  43926. yb = ya + stack.shift();
  43927. x = xb + stack.shift();
  43928. y = yb + stack.shift();
  43929. bezierCurveTo(xa, ya, xb, yb, x, y);
  43930. }
  43931. x += stack.shift();
  43932. y += stack.shift();
  43933. lineTo(x, y);
  43934. break;
  43935. case 25:
  43936. while (stack.length > 6) {
  43937. x += stack.shift();
  43938. y += stack.shift();
  43939. lineTo(x, y);
  43940. }
  43941. xa = x + stack.shift();
  43942. ya = y + stack.shift();
  43943. xb = xa + stack.shift();
  43944. yb = ya + stack.shift();
  43945. x = xb + stack.shift();
  43946. y = yb + stack.shift();
  43947. bezierCurveTo(xa, ya, xb, yb, x, y);
  43948. break;
  43949. case 26:
  43950. if (stack.length % 2) {
  43951. x += stack.shift();
  43952. }
  43953. while (stack.length > 0) {
  43954. xa = x;
  43955. ya = y + stack.shift();
  43956. xb = xa + stack.shift();
  43957. yb = ya + stack.shift();
  43958. x = xb;
  43959. y = yb + stack.shift();
  43960. bezierCurveTo(xa, ya, xb, yb, x, y);
  43961. }
  43962. break;
  43963. case 27:
  43964. if (stack.length % 2) {
  43965. y += stack.shift();
  43966. }
  43967. while (stack.length > 0) {
  43968. xa = x + stack.shift();
  43969. ya = y;
  43970. xb = xa + stack.shift();
  43971. yb = ya + stack.shift();
  43972. x = xb + stack.shift();
  43973. y = yb;
  43974. bezierCurveTo(xa, ya, xb, yb, x, y);
  43975. }
  43976. break;
  43977. case 28:
  43978. stack.push((code[i] << 24 | code[i + 1] << 16) >> 16);
  43979. i += 2;
  43980. break;
  43981. case 29:
  43982. n = stack.pop() + font.gsubrsBias;
  43983. subrCode = font.gsubrs[n];
  43984. if (subrCode) {
  43985. parse(subrCode);
  43986. }
  43987. break;
  43988. case 30:
  43989. while (stack.length > 0) {
  43990. xa = x;
  43991. ya = y + stack.shift();
  43992. xb = xa + stack.shift();
  43993. yb = ya + stack.shift();
  43994. x = xb + stack.shift();
  43995. y = yb + (stack.length === 1 ? stack.shift() : 0);
  43996. bezierCurveTo(xa, ya, xb, yb, x, y);
  43997. if (stack.length === 0) {
  43998. break;
  43999. }
  44000. xa = x + stack.shift();
  44001. ya = y;
  44002. xb = xa + stack.shift();
  44003. yb = ya + stack.shift();
  44004. y = yb + stack.shift();
  44005. x = xb + (stack.length === 1 ? stack.shift() : 0);
  44006. bezierCurveTo(xa, ya, xb, yb, x, y);
  44007. }
  44008. break;
  44009. case 31:
  44010. while (stack.length > 0) {
  44011. xa = x + stack.shift();
  44012. ya = y;
  44013. xb = xa + stack.shift();
  44014. yb = ya + stack.shift();
  44015. y = yb + stack.shift();
  44016. x = xb + (stack.length === 1 ? stack.shift() : 0);
  44017. bezierCurveTo(xa, ya, xb, yb, x, y);
  44018. if (stack.length === 0) {
  44019. break;
  44020. }
  44021. xa = x;
  44022. ya = y + stack.shift();
  44023. xb = xa + stack.shift();
  44024. yb = ya + stack.shift();
  44025. x = xb + stack.shift();
  44026. y = yb + (stack.length === 1 ? stack.shift() : 0);
  44027. bezierCurveTo(xa, ya, xb, yb, x, y);
  44028. }
  44029. break;
  44030. default:
  44031. if (v < 32) {
  44032. error('unknown operator: ' + v);
  44033. }
  44034. if (v < 247) {
  44035. stack.push(v - 139);
  44036. } else if (v < 251) {
  44037. stack.push((v - 247) * 256 + code[i++] + 108);
  44038. } else if (v < 255) {
  44039. stack.push(-(v - 251) * 256 - code[i++] - 108);
  44040. } else {
  44041. stack.push((code[i] << 24 | code[i + 1] << 16 | code[i + 2] << 8 | code[i + 3]) / 65536);
  44042. i += 4;
  44043. }
  44044. break;
  44045. }
  44046. if (stackClean) {
  44047. stack.length = 0;
  44048. }
  44049. }
  44050. }
  44051. parse(code);
  44052. }
  44053. var noop = '';
  44054. function CompiledFont(fontMatrix) {
  44055. this.compiledGlyphs = Object.create(null);
  44056. this.compiledCharCodeToGlyphId = Object.create(null);
  44057. this.fontMatrix = fontMatrix;
  44058. }
  44059. CompiledFont.prototype = {
  44060. getPathJs: function (unicode) {
  44061. var cmap = lookupCmap(this.cmap, unicode);
  44062. var fn = this.compiledGlyphs[cmap.glyphId];
  44063. if (!fn) {
  44064. fn = this.compileGlyph(this.glyphs[cmap.glyphId]);
  44065. this.compiledGlyphs[cmap.glyphId] = fn;
  44066. }
  44067. if (this.compiledCharCodeToGlyphId[cmap.charCode] === undefined) {
  44068. this.compiledCharCodeToGlyphId[cmap.charCode] = cmap.glyphId;
  44069. }
  44070. return fn;
  44071. },
  44072. compileGlyph: function (code) {
  44073. if (!code || code.length === 0 || code[0] === 14) {
  44074. return noop;
  44075. }
  44076. var cmds = [];
  44077. cmds.push({ cmd: 'save' });
  44078. cmds.push({
  44079. cmd: 'transform',
  44080. args: this.fontMatrix.slice()
  44081. });
  44082. cmds.push({
  44083. cmd: 'scale',
  44084. args: [
  44085. 'size',
  44086. '-size'
  44087. ]
  44088. });
  44089. this.compileGlyphImpl(code, cmds);
  44090. cmds.push({ cmd: 'restore' });
  44091. return cmds;
  44092. },
  44093. compileGlyphImpl: function () {
  44094. error('Children classes should implement this.');
  44095. },
  44096. hasBuiltPath: function (unicode) {
  44097. var cmap = lookupCmap(this.cmap, unicode);
  44098. return this.compiledGlyphs[cmap.glyphId] !== undefined && this.compiledCharCodeToGlyphId[cmap.charCode] !== undefined;
  44099. }
  44100. };
  44101. function TrueTypeCompiled(glyphs, cmap, fontMatrix) {
  44102. fontMatrix = fontMatrix || [
  44103. 0.000488,
  44104. 0,
  44105. 0,
  44106. 0.000488,
  44107. 0,
  44108. 0
  44109. ];
  44110. CompiledFont.call(this, fontMatrix);
  44111. this.glyphs = glyphs;
  44112. this.cmap = cmap;
  44113. }
  44114. Util.inherit(TrueTypeCompiled, CompiledFont, {
  44115. compileGlyphImpl: function (code, cmds) {
  44116. compileGlyf(code, cmds, this);
  44117. }
  44118. });
  44119. function Type2Compiled(cffInfo, cmap, fontMatrix, glyphNameMap) {
  44120. fontMatrix = fontMatrix || [
  44121. 0.001,
  44122. 0,
  44123. 0,
  44124. 0.001,
  44125. 0,
  44126. 0
  44127. ];
  44128. CompiledFont.call(this, fontMatrix);
  44129. this.glyphs = cffInfo.glyphs;
  44130. this.gsubrs = cffInfo.gsubrs || [];
  44131. this.subrs = cffInfo.subrs || [];
  44132. this.cmap = cmap;
  44133. this.glyphNameMap = glyphNameMap || getGlyphsUnicode();
  44134. this.gsubrsBias = this.gsubrs.length < 1240 ? 107 : this.gsubrs.length < 33900 ? 1131 : 32768;
  44135. this.subrsBias = this.subrs.length < 1240 ? 107 : this.subrs.length < 33900 ? 1131 : 32768;
  44136. }
  44137. Util.inherit(Type2Compiled, CompiledFont, {
  44138. compileGlyphImpl: function (code, cmds) {
  44139. compileCharString(code, cmds, this);
  44140. }
  44141. });
  44142. return {
  44143. create: function FontRendererFactory_create(font, seacAnalysisEnabled) {
  44144. var data = new Uint8Array(font.data);
  44145. var cmap, glyf, loca, cff, indexToLocFormat, unitsPerEm;
  44146. var numTables = getUshort(data, 4);
  44147. for (var i = 0, p = 12; i < numTables; i++, p += 16) {
  44148. var tag = bytesToString(data.subarray(p, p + 4));
  44149. var offset = getLong(data, p + 8);
  44150. var length = getLong(data, p + 12);
  44151. switch (tag) {
  44152. case 'cmap':
  44153. cmap = parseCmap(data, offset, offset + length);
  44154. break;
  44155. case 'glyf':
  44156. glyf = data.subarray(offset, offset + length);
  44157. break;
  44158. case 'loca':
  44159. loca = data.subarray(offset, offset + length);
  44160. break;
  44161. case 'head':
  44162. unitsPerEm = getUshort(data, offset + 18);
  44163. indexToLocFormat = getUshort(data, offset + 50);
  44164. break;
  44165. case 'CFF ':
  44166. cff = parseCff(data, offset, offset + length, seacAnalysisEnabled);
  44167. break;
  44168. }
  44169. }
  44170. if (glyf) {
  44171. var fontMatrix = !unitsPerEm ? font.fontMatrix : [
  44172. 1 / unitsPerEm,
  44173. 0,
  44174. 0,
  44175. 1 / unitsPerEm,
  44176. 0,
  44177. 0
  44178. ];
  44179. return new TrueTypeCompiled(parseGlyfTable(glyf, loca, indexToLocFormat), cmap, fontMatrix);
  44180. }
  44181. return new Type2Compiled(cff, cmap, font.fontMatrix, font.glyphNameMap);
  44182. }
  44183. };
  44184. }();
  44185. exports.FontRendererFactory = FontRendererFactory;
  44186. /***/ }),
  44187. /* 35 */
  44188. /***/ (function(module, exports, __w_pdfjs_require__) {
  44189. "use strict";
  44190. var sharedUtil = __w_pdfjs_require__(0);
  44191. var corePrimitives = __w_pdfjs_require__(1);
  44192. var coreStream = __w_pdfjs_require__(2);
  44193. var coreGlyphList = __w_pdfjs_require__(8);
  44194. var coreFontRenderer = __w_pdfjs_require__(34);
  44195. var coreEncodings = __w_pdfjs_require__(5);
  44196. var coreStandardFonts = __w_pdfjs_require__(21);
  44197. var coreUnicode = __w_pdfjs_require__(22);
  44198. var coreType1Parser = __w_pdfjs_require__(44);
  44199. var coreCFFParser = __w_pdfjs_require__(15);
  44200. var FONT_IDENTITY_MATRIX = sharedUtil.FONT_IDENTITY_MATRIX;
  44201. var FontType = sharedUtil.FontType;
  44202. var assert = sharedUtil.assert;
  44203. var bytesToString = sharedUtil.bytesToString;
  44204. var error = sharedUtil.error;
  44205. var info = sharedUtil.info;
  44206. var isArray = sharedUtil.isArray;
  44207. var isInt = sharedUtil.isInt;
  44208. var isNum = sharedUtil.isNum;
  44209. var readUint32 = sharedUtil.readUint32;
  44210. var shadow = sharedUtil.shadow;
  44211. var string32 = sharedUtil.string32;
  44212. var warn = sharedUtil.warn;
  44213. var MissingDataException = sharedUtil.MissingDataException;
  44214. var isSpace = sharedUtil.isSpace;
  44215. var Stream = coreStream.Stream;
  44216. var getGlyphsUnicode = coreGlyphList.getGlyphsUnicode;
  44217. var getDingbatsGlyphsUnicode = coreGlyphList.getDingbatsGlyphsUnicode;
  44218. var FontRendererFactory = coreFontRenderer.FontRendererFactory;
  44219. var StandardEncoding = coreEncodings.StandardEncoding;
  44220. var MacRomanEncoding = coreEncodings.MacRomanEncoding;
  44221. var SymbolSetEncoding = coreEncodings.SymbolSetEncoding;
  44222. var ZapfDingbatsEncoding = coreEncodings.ZapfDingbatsEncoding;
  44223. var getEncoding = coreEncodings.getEncoding;
  44224. var getStdFontMap = coreStandardFonts.getStdFontMap;
  44225. var getNonStdFontMap = coreStandardFonts.getNonStdFontMap;
  44226. var getGlyphMapForStandardFonts = coreStandardFonts.getGlyphMapForStandardFonts;
  44227. var getSupplementalGlyphMapForArialBlack = coreStandardFonts.getSupplementalGlyphMapForArialBlack;
  44228. var getUnicodeRangeFor = coreUnicode.getUnicodeRangeFor;
  44229. var mapSpecialUnicodeValues = coreUnicode.mapSpecialUnicodeValues;
  44230. var getUnicodeForGlyph = coreUnicode.getUnicodeForGlyph;
  44231. var Type1Parser = coreType1Parser.Type1Parser;
  44232. var CFFStandardStrings = coreCFFParser.CFFStandardStrings;
  44233. var CFFParser = coreCFFParser.CFFParser;
  44234. var CFFCompiler = coreCFFParser.CFFCompiler;
  44235. var CFF = coreCFFParser.CFF;
  44236. var CFFHeader = coreCFFParser.CFFHeader;
  44237. var CFFTopDict = coreCFFParser.CFFTopDict;
  44238. var CFFPrivateDict = coreCFFParser.CFFPrivateDict;
  44239. var CFFStrings = coreCFFParser.CFFStrings;
  44240. var CFFIndex = coreCFFParser.CFFIndex;
  44241. var CFFCharset = coreCFFParser.CFFCharset;
  44242. var PRIVATE_USE_OFFSET_START = 0xE000;
  44243. var PRIVATE_USE_OFFSET_END = 0xF8FF;
  44244. var SKIP_PRIVATE_USE_RANGE_F000_TO_F01F = false;
  44245. var PDF_GLYPH_SPACE_UNITS = 1000;
  44246. var SEAC_ANALYSIS_ENABLED = false;
  44247. var FontFlags = {
  44248. FixedPitch: 1,
  44249. Serif: 2,
  44250. Symbolic: 4,
  44251. Script: 8,
  44252. Nonsymbolic: 32,
  44253. Italic: 64,
  44254. AllCap: 65536,
  44255. SmallCap: 131072,
  44256. ForceBold: 262144
  44257. };
  44258. var MacStandardGlyphOrdering = [
  44259. '.notdef',
  44260. '.null',
  44261. 'nonmarkingreturn',
  44262. 'space',
  44263. 'exclam',
  44264. 'quotedbl',
  44265. 'numbersign',
  44266. 'dollar',
  44267. 'percent',
  44268. 'ampersand',
  44269. 'quotesingle',
  44270. 'parenleft',
  44271. 'parenright',
  44272. 'asterisk',
  44273. 'plus',
  44274. 'comma',
  44275. 'hyphen',
  44276. 'period',
  44277. 'slash',
  44278. 'zero',
  44279. 'one',
  44280. 'two',
  44281. 'three',
  44282. 'four',
  44283. 'five',
  44284. 'six',
  44285. 'seven',
  44286. 'eight',
  44287. 'nine',
  44288. 'colon',
  44289. 'semicolon',
  44290. 'less',
  44291. 'equal',
  44292. 'greater',
  44293. 'question',
  44294. 'at',
  44295. 'A',
  44296. 'B',
  44297. 'C',
  44298. 'D',
  44299. 'E',
  44300. 'F',
  44301. 'G',
  44302. 'H',
  44303. 'I',
  44304. 'J',
  44305. 'K',
  44306. 'L',
  44307. 'M',
  44308. 'N',
  44309. 'O',
  44310. 'P',
  44311. 'Q',
  44312. 'R',
  44313. 'S',
  44314. 'T',
  44315. 'U',
  44316. 'V',
  44317. 'W',
  44318. 'X',
  44319. 'Y',
  44320. 'Z',
  44321. 'bracketleft',
  44322. 'backslash',
  44323. 'bracketright',
  44324. 'asciicircum',
  44325. 'underscore',
  44326. 'grave',
  44327. 'a',
  44328. 'b',
  44329. 'c',
  44330. 'd',
  44331. 'e',
  44332. 'f',
  44333. 'g',
  44334. 'h',
  44335. 'i',
  44336. 'j',
  44337. 'k',
  44338. 'l',
  44339. 'm',
  44340. 'n',
  44341. 'o',
  44342. 'p',
  44343. 'q',
  44344. 'r',
  44345. 's',
  44346. 't',
  44347. 'u',
  44348. 'v',
  44349. 'w',
  44350. 'x',
  44351. 'y',
  44352. 'z',
  44353. 'braceleft',
  44354. 'bar',
  44355. 'braceright',
  44356. 'asciitilde',
  44357. 'Adieresis',
  44358. 'Aring',
  44359. 'Ccedilla',
  44360. 'Eacute',
  44361. 'Ntilde',
  44362. 'Odieresis',
  44363. 'Udieresis',
  44364. 'aacute',
  44365. 'agrave',
  44366. 'acircumflex',
  44367. 'adieresis',
  44368. 'atilde',
  44369. 'aring',
  44370. 'ccedilla',
  44371. 'eacute',
  44372. 'egrave',
  44373. 'ecircumflex',
  44374. 'edieresis',
  44375. 'iacute',
  44376. 'igrave',
  44377. 'icircumflex',
  44378. 'idieresis',
  44379. 'ntilde',
  44380. 'oacute',
  44381. 'ograve',
  44382. 'ocircumflex',
  44383. 'odieresis',
  44384. 'otilde',
  44385. 'uacute',
  44386. 'ugrave',
  44387. 'ucircumflex',
  44388. 'udieresis',
  44389. 'dagger',
  44390. 'degree',
  44391. 'cent',
  44392. 'sterling',
  44393. 'section',
  44394. 'bullet',
  44395. 'paragraph',
  44396. 'germandbls',
  44397. 'registered',
  44398. 'copyright',
  44399. 'trademark',
  44400. 'acute',
  44401. 'dieresis',
  44402. 'notequal',
  44403. 'AE',
  44404. 'Oslash',
  44405. 'infinity',
  44406. 'plusminus',
  44407. 'lessequal',
  44408. 'greaterequal',
  44409. 'yen',
  44410. 'mu',
  44411. 'partialdiff',
  44412. 'summation',
  44413. 'product',
  44414. 'pi',
  44415. 'integral',
  44416. 'ordfeminine',
  44417. 'ordmasculine',
  44418. 'Omega',
  44419. 'ae',
  44420. 'oslash',
  44421. 'questiondown',
  44422. 'exclamdown',
  44423. 'logicalnot',
  44424. 'radical',
  44425. 'florin',
  44426. 'approxequal',
  44427. 'Delta',
  44428. 'guillemotleft',
  44429. 'guillemotright',
  44430. 'ellipsis',
  44431. 'nonbreakingspace',
  44432. 'Agrave',
  44433. 'Atilde',
  44434. 'Otilde',
  44435. 'OE',
  44436. 'oe',
  44437. 'endash',
  44438. 'emdash',
  44439. 'quotedblleft',
  44440. 'quotedblright',
  44441. 'quoteleft',
  44442. 'quoteright',
  44443. 'divide',
  44444. 'lozenge',
  44445. 'ydieresis',
  44446. 'Ydieresis',
  44447. 'fraction',
  44448. 'currency',
  44449. 'guilsinglleft',
  44450. 'guilsinglright',
  44451. 'fi',
  44452. 'fl',
  44453. 'daggerdbl',
  44454. 'periodcentered',
  44455. 'quotesinglbase',
  44456. 'quotedblbase',
  44457. 'perthousand',
  44458. 'Acircumflex',
  44459. 'Ecircumflex',
  44460. 'Aacute',
  44461. 'Edieresis',
  44462. 'Egrave',
  44463. 'Iacute',
  44464. 'Icircumflex',
  44465. 'Idieresis',
  44466. 'Igrave',
  44467. 'Oacute',
  44468. 'Ocircumflex',
  44469. 'apple',
  44470. 'Ograve',
  44471. 'Uacute',
  44472. 'Ucircumflex',
  44473. 'Ugrave',
  44474. 'dotlessi',
  44475. 'circumflex',
  44476. 'tilde',
  44477. 'macron',
  44478. 'breve',
  44479. 'dotaccent',
  44480. 'ring',
  44481. 'cedilla',
  44482. 'hungarumlaut',
  44483. 'ogonek',
  44484. 'caron',
  44485. 'Lslash',
  44486. 'lslash',
  44487. 'Scaron',
  44488. 'scaron',
  44489. 'Zcaron',
  44490. 'zcaron',
  44491. 'brokenbar',
  44492. 'Eth',
  44493. 'eth',
  44494. 'Yacute',
  44495. 'yacute',
  44496. 'Thorn',
  44497. 'thorn',
  44498. 'minus',
  44499. 'multiply',
  44500. 'onesuperior',
  44501. 'twosuperior',
  44502. 'threesuperior',
  44503. 'onehalf',
  44504. 'onequarter',
  44505. 'threequarters',
  44506. 'franc',
  44507. 'Gbreve',
  44508. 'gbreve',
  44509. 'Idotaccent',
  44510. 'Scedilla',
  44511. 'scedilla',
  44512. 'Cacute',
  44513. 'cacute',
  44514. 'Ccaron',
  44515. 'ccaron',
  44516. 'dcroat'
  44517. ];
  44518. function adjustWidths(properties) {
  44519. if (!properties.fontMatrix) {
  44520. return;
  44521. }
  44522. if (properties.fontMatrix[0] === FONT_IDENTITY_MATRIX[0]) {
  44523. return;
  44524. }
  44525. var scale = 0.001 / properties.fontMatrix[0];
  44526. var glyphsWidths = properties.widths;
  44527. for (var glyph in glyphsWidths) {
  44528. glyphsWidths[glyph] *= scale;
  44529. }
  44530. properties.defaultWidth *= scale;
  44531. }
  44532. function adjustToUnicode(properties, builtInEncoding) {
  44533. if (properties.hasIncludedToUnicodeMap) {
  44534. return;
  44535. }
  44536. if (properties.hasEncoding) {
  44537. return;
  44538. }
  44539. if (builtInEncoding === properties.defaultEncoding) {
  44540. return;
  44541. }
  44542. if (properties.toUnicode instanceof IdentityToUnicodeMap) {
  44543. return;
  44544. }
  44545. var toUnicode = [], glyphsUnicodeMap = getGlyphsUnicode();
  44546. for (var charCode in builtInEncoding) {
  44547. var glyphName = builtInEncoding[charCode];
  44548. var unicode = getUnicodeForGlyph(glyphName, glyphsUnicodeMap);
  44549. if (unicode !== -1) {
  44550. toUnicode[charCode] = String.fromCharCode(unicode);
  44551. }
  44552. }
  44553. properties.toUnicode.amend(toUnicode);
  44554. }
  44555. function getFontType(type, subtype) {
  44556. switch (type) {
  44557. case 'Type1':
  44558. return subtype === 'Type1C' ? FontType.TYPE1C : FontType.TYPE1;
  44559. case 'CIDFontType0':
  44560. return subtype === 'CIDFontType0C' ? FontType.CIDFONTTYPE0C : FontType.CIDFONTTYPE0;
  44561. case 'OpenType':
  44562. return FontType.OPENTYPE;
  44563. case 'TrueType':
  44564. return FontType.TRUETYPE;
  44565. case 'CIDFontType2':
  44566. return FontType.CIDFONTTYPE2;
  44567. case 'MMType1':
  44568. return FontType.MMTYPE1;
  44569. case 'Type0':
  44570. return FontType.TYPE0;
  44571. default:
  44572. return FontType.UNKNOWN;
  44573. }
  44574. }
  44575. function recoverGlyphName(name, glyphsUnicodeMap) {
  44576. if (glyphsUnicodeMap[name] !== undefined) {
  44577. return name;
  44578. }
  44579. var unicode = getUnicodeForGlyph(name, glyphsUnicodeMap);
  44580. if (unicode !== -1) {
  44581. for (var key in glyphsUnicodeMap) {
  44582. if (glyphsUnicodeMap[key] === unicode) {
  44583. return key;
  44584. }
  44585. }
  44586. }
  44587. info('Unable to recover a standard glyph name for: ' + name);
  44588. return name;
  44589. }
  44590. var Glyph = function GlyphClosure() {
  44591. function Glyph(fontChar, unicode, accent, width, vmetric, operatorListId, isSpace, isInFont) {
  44592. this.fontChar = fontChar;
  44593. this.unicode = unicode;
  44594. this.accent = accent;
  44595. this.width = width;
  44596. this.vmetric = vmetric;
  44597. this.operatorListId = operatorListId;
  44598. this.isSpace = isSpace;
  44599. this.isInFont = isInFont;
  44600. }
  44601. Glyph.prototype.matchesForCache = function (fontChar, unicode, accent, width, vmetric, operatorListId, isSpace, isInFont) {
  44602. 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;
  44603. };
  44604. return Glyph;
  44605. }();
  44606. var ToUnicodeMap = function ToUnicodeMapClosure() {
  44607. function ToUnicodeMap(cmap) {
  44608. this._map = cmap;
  44609. }
  44610. ToUnicodeMap.prototype = {
  44611. get length() {
  44612. return this._map.length;
  44613. },
  44614. forEach: function (callback) {
  44615. for (var charCode in this._map) {
  44616. callback(charCode, this._map[charCode].charCodeAt(0));
  44617. }
  44618. },
  44619. has: function (i) {
  44620. return this._map[i] !== undefined;
  44621. },
  44622. get: function (i) {
  44623. return this._map[i];
  44624. },
  44625. charCodeOf: function (v) {
  44626. return this._map.indexOf(v);
  44627. },
  44628. amend: function (map) {
  44629. for (var charCode in map) {
  44630. this._map[charCode] = map[charCode];
  44631. }
  44632. }
  44633. };
  44634. return ToUnicodeMap;
  44635. }();
  44636. var IdentityToUnicodeMap = function IdentityToUnicodeMapClosure() {
  44637. function IdentityToUnicodeMap(firstChar, lastChar) {
  44638. this.firstChar = firstChar;
  44639. this.lastChar = lastChar;
  44640. }
  44641. IdentityToUnicodeMap.prototype = {
  44642. get length() {
  44643. return this.lastChar + 1 - this.firstChar;
  44644. },
  44645. forEach: function (callback) {
  44646. for (var i = this.firstChar, ii = this.lastChar; i <= ii; i++) {
  44647. callback(i, i);
  44648. }
  44649. },
  44650. has: function (i) {
  44651. return this.firstChar <= i && i <= this.lastChar;
  44652. },
  44653. get: function (i) {
  44654. if (this.firstChar <= i && i <= this.lastChar) {
  44655. return String.fromCharCode(i);
  44656. }
  44657. return undefined;
  44658. },
  44659. charCodeOf: function (v) {
  44660. return isInt(v) && v >= this.firstChar && v <= this.lastChar ? v : -1;
  44661. },
  44662. amend: function (map) {
  44663. error('Should not call amend()');
  44664. }
  44665. };
  44666. return IdentityToUnicodeMap;
  44667. }();
  44668. var OpenTypeFileBuilder = function OpenTypeFileBuilderClosure() {
  44669. function writeInt16(dest, offset, num) {
  44670. dest[offset] = num >> 8 & 0xFF;
  44671. dest[offset + 1] = num & 0xFF;
  44672. }
  44673. function writeInt32(dest, offset, num) {
  44674. dest[offset] = num >> 24 & 0xFF;
  44675. dest[offset + 1] = num >> 16 & 0xFF;
  44676. dest[offset + 2] = num >> 8 & 0xFF;
  44677. dest[offset + 3] = num & 0xFF;
  44678. }
  44679. function writeData(dest, offset, data) {
  44680. var i, ii;
  44681. if (data instanceof Uint8Array) {
  44682. dest.set(data, offset);
  44683. } else if (typeof data === 'string') {
  44684. for (i = 0, ii = data.length; i < ii; i++) {
  44685. dest[offset++] = data.charCodeAt(i) & 0xFF;
  44686. }
  44687. } else {
  44688. for (i = 0, ii = data.length; i < ii; i++) {
  44689. dest[offset++] = data[i] & 0xFF;
  44690. }
  44691. }
  44692. }
  44693. function OpenTypeFileBuilder(sfnt) {
  44694. this.sfnt = sfnt;
  44695. this.tables = Object.create(null);
  44696. }
  44697. OpenTypeFileBuilder.getSearchParams = function OpenTypeFileBuilder_getSearchParams(entriesCount, entrySize) {
  44698. var maxPower2 = 1, log2 = 0;
  44699. while ((maxPower2 ^ entriesCount) > maxPower2) {
  44700. maxPower2 <<= 1;
  44701. log2++;
  44702. }
  44703. var searchRange = maxPower2 * entrySize;
  44704. return {
  44705. range: searchRange,
  44706. entry: log2,
  44707. rangeShift: entrySize * entriesCount - searchRange
  44708. };
  44709. };
  44710. var OTF_HEADER_SIZE = 12;
  44711. var OTF_TABLE_ENTRY_SIZE = 16;
  44712. OpenTypeFileBuilder.prototype = {
  44713. toArray: function OpenTypeFileBuilder_toArray() {
  44714. var sfnt = this.sfnt;
  44715. var tables = this.tables;
  44716. var tablesNames = Object.keys(tables);
  44717. tablesNames.sort();
  44718. var numTables = tablesNames.length;
  44719. var i, j, jj, table, tableName;
  44720. var offset = OTF_HEADER_SIZE + numTables * OTF_TABLE_ENTRY_SIZE;
  44721. var tableOffsets = [offset];
  44722. for (i = 0; i < numTables; i++) {
  44723. table = tables[tablesNames[i]];
  44724. var paddedLength = (table.length + 3 & ~3) >>> 0;
  44725. offset += paddedLength;
  44726. tableOffsets.push(offset);
  44727. }
  44728. var file = new Uint8Array(offset);
  44729. for (i = 0; i < numTables; i++) {
  44730. table = tables[tablesNames[i]];
  44731. writeData(file, tableOffsets[i], table);
  44732. }
  44733. if (sfnt === 'true') {
  44734. sfnt = string32(0x00010000);
  44735. }
  44736. file[0] = sfnt.charCodeAt(0) & 0xFF;
  44737. file[1] = sfnt.charCodeAt(1) & 0xFF;
  44738. file[2] = sfnt.charCodeAt(2) & 0xFF;
  44739. file[3] = sfnt.charCodeAt(3) & 0xFF;
  44740. writeInt16(file, 4, numTables);
  44741. var searchParams = OpenTypeFileBuilder.getSearchParams(numTables, 16);
  44742. writeInt16(file, 6, searchParams.range);
  44743. writeInt16(file, 8, searchParams.entry);
  44744. writeInt16(file, 10, searchParams.rangeShift);
  44745. offset = OTF_HEADER_SIZE;
  44746. for (i = 0; i < numTables; i++) {
  44747. tableName = tablesNames[i];
  44748. file[offset] = tableName.charCodeAt(0) & 0xFF;
  44749. file[offset + 1] = tableName.charCodeAt(1) & 0xFF;
  44750. file[offset + 2] = tableName.charCodeAt(2) & 0xFF;
  44751. file[offset + 3] = tableName.charCodeAt(3) & 0xFF;
  44752. var checksum = 0;
  44753. for (j = tableOffsets[i], jj = tableOffsets[i + 1]; j < jj; j += 4) {
  44754. var quad = readUint32(file, j);
  44755. checksum = checksum + quad >>> 0;
  44756. }
  44757. writeInt32(file, offset + 4, checksum);
  44758. writeInt32(file, offset + 8, tableOffsets[i]);
  44759. writeInt32(file, offset + 12, tables[tableName].length);
  44760. offset += OTF_TABLE_ENTRY_SIZE;
  44761. }
  44762. return file;
  44763. },
  44764. addTable: function OpenTypeFileBuilder_addTable(tag, data) {
  44765. if (tag in this.tables) {
  44766. throw new Error('Table ' + tag + ' already exists');
  44767. }
  44768. this.tables[tag] = data;
  44769. }
  44770. };
  44771. return OpenTypeFileBuilder;
  44772. }();
  44773. var ProblematicCharRanges = new Int32Array([
  44774. 0x0000,
  44775. 0x0020,
  44776. 0x007F,
  44777. 0x00A1,
  44778. 0x00AD,
  44779. 0x00AE,
  44780. 0x0600,
  44781. 0x0780,
  44782. 0x08A0,
  44783. 0x10A0,
  44784. 0x1780,
  44785. 0x1800,
  44786. 0x1C00,
  44787. 0x1C50,
  44788. 0x2000,
  44789. 0x2010,
  44790. 0x2011,
  44791. 0x2012,
  44792. 0x2028,
  44793. 0x2030,
  44794. 0x205F,
  44795. 0x2070,
  44796. 0x25CC,
  44797. 0x25CD,
  44798. 0x3000,
  44799. 0x3001,
  44800. 0xAA60,
  44801. 0xAA80,
  44802. 0xFFF0,
  44803. 0x10000
  44804. ]);
  44805. var Font = function FontClosure() {
  44806. function Font(name, file, properties) {
  44807. var charCode, glyphName, unicode;
  44808. this.name = name;
  44809. this.loadedName = properties.loadedName;
  44810. this.isType3Font = properties.isType3Font;
  44811. this.sizes = [];
  44812. this.missingFile = false;
  44813. this.glyphCache = Object.create(null);
  44814. this.isSerifFont = !!(properties.flags & FontFlags.Serif);
  44815. this.isSymbolicFont = !!(properties.flags & FontFlags.Symbolic);
  44816. this.isMonospace = !!(properties.flags & FontFlags.FixedPitch);
  44817. var type = properties.type;
  44818. var subtype = properties.subtype;
  44819. this.type = type;
  44820. this.fallbackName = this.isMonospace ? 'monospace' : this.isSerifFont ? 'serif' : 'sans-serif';
  44821. this.differences = properties.differences;
  44822. this.widths = properties.widths;
  44823. this.defaultWidth = properties.defaultWidth;
  44824. this.composite = properties.composite;
  44825. this.wideChars = properties.wideChars;
  44826. this.cMap = properties.cMap;
  44827. this.ascent = properties.ascent / PDF_GLYPH_SPACE_UNITS;
  44828. this.descent = properties.descent / PDF_GLYPH_SPACE_UNITS;
  44829. this.fontMatrix = properties.fontMatrix;
  44830. this.bbox = properties.bbox;
  44831. this.toUnicode = properties.toUnicode;
  44832. this.toFontChar = [];
  44833. if (properties.type === 'Type3') {
  44834. for (charCode = 0; charCode < 256; charCode++) {
  44835. this.toFontChar[charCode] = this.differences[charCode] || properties.defaultEncoding[charCode];
  44836. }
  44837. this.fontType = FontType.TYPE3;
  44838. return;
  44839. }
  44840. this.cidEncoding = properties.cidEncoding;
  44841. this.vertical = properties.vertical;
  44842. if (this.vertical) {
  44843. this.vmetrics = properties.vmetrics;
  44844. this.defaultVMetrics = properties.defaultVMetrics;
  44845. }
  44846. var glyphsUnicodeMap;
  44847. if (!file || file.isEmpty) {
  44848. if (file) {
  44849. warn('Font file is empty in "' + name + '" (' + this.loadedName + ')');
  44850. }
  44851. this.missingFile = true;
  44852. var fontName = name.replace(/[,_]/g, '-');
  44853. var stdFontMap = getStdFontMap(), nonStdFontMap = getNonStdFontMap();
  44854. var isStandardFont = !!stdFontMap[fontName] || !!(nonStdFontMap[fontName] && stdFontMap[nonStdFontMap[fontName]]);
  44855. fontName = stdFontMap[fontName] || nonStdFontMap[fontName] || fontName;
  44856. this.bold = fontName.search(/bold/gi) !== -1;
  44857. this.italic = fontName.search(/oblique/gi) !== -1 || fontName.search(/italic/gi) !== -1;
  44858. this.black = name.search(/Black/g) !== -1;
  44859. this.remeasure = Object.keys(this.widths).length > 0;
  44860. if (isStandardFont && type === 'CIDFontType2' && properties.cidEncoding.indexOf('Identity-') === 0) {
  44861. var GlyphMapForStandardFonts = getGlyphMapForStandardFonts();
  44862. var map = [];
  44863. for (charCode in GlyphMapForStandardFonts) {
  44864. map[+charCode] = GlyphMapForStandardFonts[charCode];
  44865. }
  44866. if (/Arial-?Black/i.test(name)) {
  44867. var SupplementalGlyphMapForArialBlack = getSupplementalGlyphMapForArialBlack();
  44868. for (charCode in SupplementalGlyphMapForArialBlack) {
  44869. map[+charCode] = SupplementalGlyphMapForArialBlack[charCode];
  44870. }
  44871. }
  44872. var isIdentityUnicode = this.toUnicode instanceof IdentityToUnicodeMap;
  44873. if (!isIdentityUnicode) {
  44874. this.toUnicode.forEach(function (charCode, unicodeCharCode) {
  44875. map[+charCode] = unicodeCharCode;
  44876. });
  44877. }
  44878. this.toFontChar = map;
  44879. this.toUnicode = new ToUnicodeMap(map);
  44880. } else if (/Symbol/i.test(fontName)) {
  44881. this.toFontChar = buildToFontChar(SymbolSetEncoding, getGlyphsUnicode(), properties.differences);
  44882. } else if (/Dingbats/i.test(fontName)) {
  44883. if (/Wingdings/i.test(name)) {
  44884. warn('Non-embedded Wingdings font, falling back to ZapfDingbats.');
  44885. }
  44886. this.toFontChar = buildToFontChar(ZapfDingbatsEncoding, getDingbatsGlyphsUnicode(), properties.differences);
  44887. } else if (isStandardFont) {
  44888. this.toFontChar = buildToFontChar(properties.defaultEncoding, getGlyphsUnicode(), properties.differences);
  44889. } else {
  44890. glyphsUnicodeMap = getGlyphsUnicode();
  44891. this.toUnicode.forEach(function (charCode, unicodeCharCode) {
  44892. if (!this.composite) {
  44893. glyphName = properties.differences[charCode] || properties.defaultEncoding[charCode];
  44894. unicode = getUnicodeForGlyph(glyphName, glyphsUnicodeMap);
  44895. if (unicode !== -1) {
  44896. unicodeCharCode = unicode;
  44897. }
  44898. }
  44899. this.toFontChar[charCode] = unicodeCharCode;
  44900. }.bind(this));
  44901. }
  44902. this.loadedName = fontName.split('-')[0];
  44903. this.loading = false;
  44904. this.fontType = getFontType(type, subtype);
  44905. return;
  44906. }
  44907. if (subtype === 'Type1C') {
  44908. if (type !== 'Type1' && type !== 'MMType1') {
  44909. if (isTrueTypeFile(file)) {
  44910. subtype = 'TrueType';
  44911. } else {
  44912. type = 'Type1';
  44913. }
  44914. } else if (isOpenTypeFile(file)) {
  44915. type = subtype = 'OpenType';
  44916. }
  44917. }
  44918. if (subtype === 'CIDFontType0C' && type !== 'CIDFontType0') {
  44919. type = 'CIDFontType0';
  44920. }
  44921. if (subtype === 'OpenType') {
  44922. type = 'OpenType';
  44923. }
  44924. if (type === 'CIDFontType0') {
  44925. if (isType1File(file)) {
  44926. subtype = 'CIDFontType0';
  44927. } else if (isOpenTypeFile(file)) {
  44928. type = subtype = 'OpenType';
  44929. } else {
  44930. subtype = 'CIDFontType0C';
  44931. }
  44932. }
  44933. var data;
  44934. switch (type) {
  44935. case 'MMType1':
  44936. info('MMType1 font (' + name + '), falling back to Type1.');
  44937. case 'Type1':
  44938. case 'CIDFontType0':
  44939. this.mimetype = 'font/opentype';
  44940. var cff = subtype === 'Type1C' || subtype === 'CIDFontType0C' ? new CFFFont(file, properties) : new Type1Font(name, file, properties);
  44941. adjustWidths(properties);
  44942. data = this.convert(name, cff, properties);
  44943. break;
  44944. case 'OpenType':
  44945. case 'TrueType':
  44946. case 'CIDFontType2':
  44947. this.mimetype = 'font/opentype';
  44948. data = this.checkAndRepair(name, file, properties);
  44949. if (this.isOpenType) {
  44950. adjustWidths(properties);
  44951. type = 'OpenType';
  44952. }
  44953. break;
  44954. default:
  44955. error('Font ' + type + ' is not supported');
  44956. break;
  44957. }
  44958. this.data = data;
  44959. this.fontType = getFontType(type, subtype);
  44960. this.fontMatrix = properties.fontMatrix;
  44961. this.widths = properties.widths;
  44962. this.defaultWidth = properties.defaultWidth;
  44963. this.toUnicode = properties.toUnicode;
  44964. this.encoding = properties.baseEncoding;
  44965. this.seacMap = properties.seacMap;
  44966. this.loading = true;
  44967. }
  44968. Font.getFontID = function () {
  44969. var ID = 1;
  44970. return function Font_getFontID() {
  44971. return String(ID++);
  44972. };
  44973. }();
  44974. function int16(b0, b1) {
  44975. return (b0 << 8) + b1;
  44976. }
  44977. function signedInt16(b0, b1) {
  44978. var value = (b0 << 8) + b1;
  44979. return value & 1 << 15 ? value - 0x10000 : value;
  44980. }
  44981. function int32(b0, b1, b2, b3) {
  44982. return (b0 << 24) + (b1 << 16) + (b2 << 8) + b3;
  44983. }
  44984. function string16(value) {
  44985. return String.fromCharCode(value >> 8 & 0xff, value & 0xff);
  44986. }
  44987. function safeString16(value) {
  44988. value = value > 0x7FFF ? 0x7FFF : value < -0x8000 ? -0x8000 : value;
  44989. return String.fromCharCode(value >> 8 & 0xff, value & 0xff);
  44990. }
  44991. function isTrueTypeFile(file) {
  44992. var header = file.peekBytes(4);
  44993. return readUint32(header, 0) === 0x00010000;
  44994. }
  44995. function isOpenTypeFile(file) {
  44996. var header = file.peekBytes(4);
  44997. return bytesToString(header) === 'OTTO';
  44998. }
  44999. function isType1File(file) {
  45000. var header = file.peekBytes(2);
  45001. if (header[0] === 0x25 && header[1] === 0x21) {
  45002. return true;
  45003. }
  45004. if (header[0] === 0x80 && header[1] === 0x01) {
  45005. return true;
  45006. }
  45007. return false;
  45008. }
  45009. function buildToFontChar(encoding, glyphsUnicodeMap, differences) {
  45010. var toFontChar = [], unicode;
  45011. for (var i = 0, ii = encoding.length; i < ii; i++) {
  45012. unicode = getUnicodeForGlyph(encoding[i], glyphsUnicodeMap);
  45013. if (unicode !== -1) {
  45014. toFontChar[i] = unicode;
  45015. }
  45016. }
  45017. for (var charCode in differences) {
  45018. unicode = getUnicodeForGlyph(differences[charCode], glyphsUnicodeMap);
  45019. if (unicode !== -1) {
  45020. toFontChar[+charCode] = unicode;
  45021. }
  45022. }
  45023. return toFontChar;
  45024. }
  45025. function isProblematicUnicodeLocation(code) {
  45026. var i = 0, j = ProblematicCharRanges.length - 1;
  45027. while (i < j) {
  45028. var c = i + j + 1 >> 1;
  45029. if (code < ProblematicCharRanges[c]) {
  45030. j = c - 1;
  45031. } else {
  45032. i = c;
  45033. }
  45034. }
  45035. return !(i & 1);
  45036. }
  45037. function adjustMapping(charCodeToGlyphId, properties) {
  45038. var toUnicode = properties.toUnicode;
  45039. var isSymbolic = !!(properties.flags & FontFlags.Symbolic);
  45040. var isIdentityUnicode = properties.toUnicode instanceof IdentityToUnicodeMap;
  45041. var newMap = Object.create(null);
  45042. var toFontChar = [];
  45043. var usedFontCharCodes = [];
  45044. var nextAvailableFontCharCode = PRIVATE_USE_OFFSET_START;
  45045. for (var originalCharCode in charCodeToGlyphId) {
  45046. originalCharCode |= 0;
  45047. var glyphId = charCodeToGlyphId[originalCharCode];
  45048. var fontCharCode = originalCharCode;
  45049. var hasUnicodeValue = false;
  45050. if (!isIdentityUnicode && toUnicode.has(originalCharCode)) {
  45051. hasUnicodeValue = true;
  45052. var unicode = toUnicode.get(fontCharCode);
  45053. if (unicode.length === 1) {
  45054. fontCharCode = unicode.charCodeAt(0);
  45055. }
  45056. }
  45057. if ((usedFontCharCodes[fontCharCode] !== undefined || isProblematicUnicodeLocation(fontCharCode) || isSymbolic && !hasUnicodeValue) && nextAvailableFontCharCode <= PRIVATE_USE_OFFSET_END) {
  45058. do {
  45059. fontCharCode = nextAvailableFontCharCode++;
  45060. if (SKIP_PRIVATE_USE_RANGE_F000_TO_F01F && fontCharCode === 0xF000) {
  45061. fontCharCode = 0xF020;
  45062. nextAvailableFontCharCode = fontCharCode + 1;
  45063. }
  45064. } while (usedFontCharCodes[fontCharCode] !== undefined && nextAvailableFontCharCode <= PRIVATE_USE_OFFSET_END);
  45065. }
  45066. newMap[fontCharCode] = glyphId;
  45067. toFontChar[originalCharCode] = fontCharCode;
  45068. usedFontCharCodes[fontCharCode] = true;
  45069. }
  45070. return {
  45071. toFontChar: toFontChar,
  45072. charCodeToGlyphId: newMap,
  45073. nextAvailableFontCharCode: nextAvailableFontCharCode
  45074. };
  45075. }
  45076. function getRanges(glyphs, numGlyphs) {
  45077. var codes = [];
  45078. for (var charCode in glyphs) {
  45079. if (glyphs[charCode] >= numGlyphs) {
  45080. continue;
  45081. }
  45082. codes.push({
  45083. fontCharCode: charCode | 0,
  45084. glyphId: glyphs[charCode]
  45085. });
  45086. }
  45087. codes.sort(function fontGetRangesSort(a, b) {
  45088. return a.fontCharCode - b.fontCharCode;
  45089. });
  45090. var ranges = [];
  45091. var length = codes.length;
  45092. for (var n = 0; n < length;) {
  45093. var start = codes[n].fontCharCode;
  45094. var codeIndices = [codes[n].glyphId];
  45095. ++n;
  45096. var end = start;
  45097. while (n < length && end + 1 === codes[n].fontCharCode) {
  45098. codeIndices.push(codes[n].glyphId);
  45099. ++end;
  45100. ++n;
  45101. if (end === 0xFFFF) {
  45102. break;
  45103. }
  45104. }
  45105. ranges.push([
  45106. start,
  45107. end,
  45108. codeIndices
  45109. ]);
  45110. }
  45111. return ranges;
  45112. }
  45113. function createCmapTable(glyphs, numGlyphs) {
  45114. var ranges = getRanges(glyphs, numGlyphs);
  45115. var numTables = ranges[ranges.length - 1][1] > 0xFFFF ? 2 : 1;
  45116. var cmap = '\x00\x00' + string16(numTables) + '\x00\x03' + '\x00\x01' + string32(4 + numTables * 8);
  45117. var i, ii, j, jj;
  45118. for (i = ranges.length - 1; i >= 0; --i) {
  45119. if (ranges[i][0] <= 0xFFFF) {
  45120. break;
  45121. }
  45122. }
  45123. var bmpLength = i + 1;
  45124. if (ranges[i][0] < 0xFFFF && ranges[i][1] === 0xFFFF) {
  45125. ranges[i][1] = 0xFFFE;
  45126. }
  45127. var trailingRangesCount = ranges[i][1] < 0xFFFF ? 1 : 0;
  45128. var segCount = bmpLength + trailingRangesCount;
  45129. var searchParams = OpenTypeFileBuilder.getSearchParams(segCount, 2);
  45130. var startCount = '';
  45131. var endCount = '';
  45132. var idDeltas = '';
  45133. var idRangeOffsets = '';
  45134. var glyphsIds = '';
  45135. var bias = 0;
  45136. var range, start, end, codes;
  45137. for (i = 0, ii = bmpLength; i < ii; i++) {
  45138. range = ranges[i];
  45139. start = range[0];
  45140. end = range[1];
  45141. startCount += string16(start);
  45142. endCount += string16(end);
  45143. codes = range[2];
  45144. var contiguous = true;
  45145. for (j = 1, jj = codes.length; j < jj; ++j) {
  45146. if (codes[j] !== codes[j - 1] + 1) {
  45147. contiguous = false;
  45148. break;
  45149. }
  45150. }
  45151. if (!contiguous) {
  45152. var offset = (segCount - i) * 2 + bias * 2;
  45153. bias += end - start + 1;
  45154. idDeltas += string16(0);
  45155. idRangeOffsets += string16(offset);
  45156. for (j = 0, jj = codes.length; j < jj; ++j) {
  45157. glyphsIds += string16(codes[j]);
  45158. }
  45159. } else {
  45160. var startCode = codes[0];
  45161. idDeltas += string16(startCode - start & 0xFFFF);
  45162. idRangeOffsets += string16(0);
  45163. }
  45164. }
  45165. if (trailingRangesCount > 0) {
  45166. endCount += '\xFF\xFF';
  45167. startCount += '\xFF\xFF';
  45168. idDeltas += '\x00\x01';
  45169. idRangeOffsets += '\x00\x00';
  45170. }
  45171. var format314 = '\x00\x00' + string16(2 * segCount) + string16(searchParams.range) + string16(searchParams.entry) + string16(searchParams.rangeShift) + endCount + '\x00\x00' + startCount + idDeltas + idRangeOffsets + glyphsIds;
  45172. var format31012 = '';
  45173. var header31012 = '';
  45174. if (numTables > 1) {
  45175. cmap += '\x00\x03' + '\x00\x0A' + string32(4 + numTables * 8 + 4 + format314.length);
  45176. format31012 = '';
  45177. for (i = 0, ii = ranges.length; i < ii; i++) {
  45178. range = ranges[i];
  45179. start = range[0];
  45180. codes = range[2];
  45181. var code = codes[0];
  45182. for (j = 1, jj = codes.length; j < jj; ++j) {
  45183. if (codes[j] !== codes[j - 1] + 1) {
  45184. end = range[0] + j - 1;
  45185. format31012 += string32(start) + string32(end) + string32(code);
  45186. start = end + 1;
  45187. code = codes[j];
  45188. }
  45189. }
  45190. format31012 += string32(start) + string32(range[1]) + string32(code);
  45191. }
  45192. header31012 = '\x00\x0C' + '\x00\x00' + string32(format31012.length + 16) + '\x00\x00\x00\x00' + string32(format31012.length / 12);
  45193. }
  45194. return cmap + '\x00\x04' + string16(format314.length + 4) + format314 + header31012 + format31012;
  45195. }
  45196. function validateOS2Table(os2) {
  45197. var stream = new Stream(os2.data);
  45198. var version = stream.getUint16();
  45199. stream.getBytes(60);
  45200. var selection = stream.getUint16();
  45201. if (version < 4 && selection & 0x0300) {
  45202. return false;
  45203. }
  45204. var firstChar = stream.getUint16();
  45205. var lastChar = stream.getUint16();
  45206. if (firstChar > lastChar) {
  45207. return false;
  45208. }
  45209. stream.getBytes(6);
  45210. var usWinAscent = stream.getUint16();
  45211. if (usWinAscent === 0) {
  45212. return false;
  45213. }
  45214. os2.data[8] = os2.data[9] = 0;
  45215. return true;
  45216. }
  45217. function createOS2Table(properties, charstrings, override) {
  45218. override = override || {
  45219. unitsPerEm: 0,
  45220. yMax: 0,
  45221. yMin: 0,
  45222. ascent: 0,
  45223. descent: 0
  45224. };
  45225. var ulUnicodeRange1 = 0;
  45226. var ulUnicodeRange2 = 0;
  45227. var ulUnicodeRange3 = 0;
  45228. var ulUnicodeRange4 = 0;
  45229. var firstCharIndex = null;
  45230. var lastCharIndex = 0;
  45231. if (charstrings) {
  45232. for (var code in charstrings) {
  45233. code |= 0;
  45234. if (firstCharIndex > code || !firstCharIndex) {
  45235. firstCharIndex = code;
  45236. }
  45237. if (lastCharIndex < code) {
  45238. lastCharIndex = code;
  45239. }
  45240. var position = getUnicodeRangeFor(code);
  45241. if (position < 32) {
  45242. ulUnicodeRange1 |= 1 << position;
  45243. } else if (position < 64) {
  45244. ulUnicodeRange2 |= 1 << position - 32;
  45245. } else if (position < 96) {
  45246. ulUnicodeRange3 |= 1 << position - 64;
  45247. } else if (position < 123) {
  45248. ulUnicodeRange4 |= 1 << position - 96;
  45249. } else {
  45250. error('Unicode ranges Bits > 123 are reserved for internal usage');
  45251. }
  45252. }
  45253. } else {
  45254. firstCharIndex = 0;
  45255. lastCharIndex = 255;
  45256. }
  45257. var bbox = properties.bbox || [
  45258. 0,
  45259. 0,
  45260. 0,
  45261. 0
  45262. ];
  45263. var unitsPerEm = override.unitsPerEm || 1 / (properties.fontMatrix || FONT_IDENTITY_MATRIX)[0];
  45264. var scale = properties.ascentScaled ? 1.0 : unitsPerEm / PDF_GLYPH_SPACE_UNITS;
  45265. var typoAscent = override.ascent || Math.round(scale * (properties.ascent || bbox[3]));
  45266. var typoDescent = override.descent || Math.round(scale * (properties.descent || bbox[1]));
  45267. if (typoDescent > 0 && properties.descent > 0 && bbox[1] < 0) {
  45268. typoDescent = -typoDescent;
  45269. }
  45270. var winAscent = override.yMax || typoAscent;
  45271. var winDescent = -override.yMin || -typoDescent;
  45272. 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';
  45273. }
  45274. function createPostTable(properties) {
  45275. var angle = Math.floor(properties.italicAngle * Math.pow(2, 16));
  45276. 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';
  45277. }
  45278. function createNameTable(name, proto) {
  45279. if (!proto) {
  45280. proto = [
  45281. [],
  45282. []
  45283. ];
  45284. }
  45285. var strings = [
  45286. proto[0][0] || 'Original licence',
  45287. proto[0][1] || name,
  45288. proto[0][2] || 'Unknown',
  45289. proto[0][3] || 'uniqueID',
  45290. proto[0][4] || name,
  45291. proto[0][5] || 'Version 0.11',
  45292. proto[0][6] || '',
  45293. proto[0][7] || 'Unknown',
  45294. proto[0][8] || 'Unknown',
  45295. proto[0][9] || 'Unknown'
  45296. ];
  45297. var stringsUnicode = [];
  45298. var i, ii, j, jj, str;
  45299. for (i = 0, ii = strings.length; i < ii; i++) {
  45300. str = proto[1][i] || strings[i];
  45301. var strBufUnicode = [];
  45302. for (j = 0, jj = str.length; j < jj; j++) {
  45303. strBufUnicode.push(string16(str.charCodeAt(j)));
  45304. }
  45305. stringsUnicode.push(strBufUnicode.join(''));
  45306. }
  45307. var names = [
  45308. strings,
  45309. stringsUnicode
  45310. ];
  45311. var platforms = [
  45312. '\x00\x01',
  45313. '\x00\x03'
  45314. ];
  45315. var encodings = [
  45316. '\x00\x00',
  45317. '\x00\x01'
  45318. ];
  45319. var languages = [
  45320. '\x00\x00',
  45321. '\x04\x09'
  45322. ];
  45323. var namesRecordCount = strings.length * platforms.length;
  45324. var nameTable = '\x00\x00' + string16(namesRecordCount) + string16(namesRecordCount * 12 + 6);
  45325. var strOffset = 0;
  45326. for (i = 0, ii = platforms.length; i < ii; i++) {
  45327. var strs = names[i];
  45328. for (j = 0, jj = strs.length; j < jj; j++) {
  45329. str = strs[j];
  45330. var nameRecord = platforms[i] + encodings[i] + languages[i] + string16(j) + string16(str.length) + string16(strOffset);
  45331. nameTable += nameRecord;
  45332. strOffset += str.length;
  45333. }
  45334. }
  45335. nameTable += strings.join('') + stringsUnicode.join('');
  45336. return nameTable;
  45337. }
  45338. Font.prototype = {
  45339. name: null,
  45340. font: null,
  45341. mimetype: null,
  45342. encoding: null,
  45343. get renderer() {
  45344. var renderer = FontRendererFactory.create(this, SEAC_ANALYSIS_ENABLED);
  45345. return shadow(this, 'renderer', renderer);
  45346. },
  45347. exportData: function Font_exportData() {
  45348. var data = {};
  45349. for (var i in this) {
  45350. if (this.hasOwnProperty(i)) {
  45351. data[i] = this[i];
  45352. }
  45353. }
  45354. return data;
  45355. },
  45356. checkAndRepair: function Font_checkAndRepair(name, font, properties) {
  45357. function readTableEntry(file) {
  45358. var tag = bytesToString(file.getBytes(4));
  45359. var checksum = file.getInt32() >>> 0;
  45360. var offset = file.getInt32() >>> 0;
  45361. var length = file.getInt32() >>> 0;
  45362. var previousPosition = file.pos;
  45363. file.pos = file.start ? file.start : 0;
  45364. file.skip(offset);
  45365. var data = file.getBytes(length);
  45366. file.pos = previousPosition;
  45367. if (tag === 'head') {
  45368. data[8] = data[9] = data[10] = data[11] = 0;
  45369. data[17] |= 0x20;
  45370. }
  45371. return {
  45372. tag: tag,
  45373. checksum: checksum,
  45374. length: length,
  45375. offset: offset,
  45376. data: data
  45377. };
  45378. }
  45379. function readOpenTypeHeader(ttf) {
  45380. return {
  45381. version: bytesToString(ttf.getBytes(4)),
  45382. numTables: ttf.getUint16(),
  45383. searchRange: ttf.getUint16(),
  45384. entrySelector: ttf.getUint16(),
  45385. rangeShift: ttf.getUint16()
  45386. };
  45387. }
  45388. function readCmapTable(cmap, font, isSymbolicFont, hasEncoding) {
  45389. if (!cmap) {
  45390. warn('No cmap table available.');
  45391. return {
  45392. platformId: -1,
  45393. encodingId: -1,
  45394. mappings: [],
  45395. hasShortCmap: false
  45396. };
  45397. }
  45398. var segment;
  45399. var start = (font.start ? font.start : 0) + cmap.offset;
  45400. font.pos = start;
  45401. font.getUint16();
  45402. var numTables = font.getUint16();
  45403. var potentialTable;
  45404. var canBreak = false;
  45405. for (var i = 0; i < numTables; i++) {
  45406. var platformId = font.getUint16();
  45407. var encodingId = font.getUint16();
  45408. var offset = font.getInt32() >>> 0;
  45409. var useTable = false;
  45410. if (platformId === 0 && encodingId === 0) {
  45411. useTable = true;
  45412. } else if (platformId === 1 && encodingId === 0) {
  45413. useTable = true;
  45414. } else if (platformId === 3 && encodingId === 1 && (!isSymbolicFont && hasEncoding || !potentialTable)) {
  45415. useTable = true;
  45416. if (!isSymbolicFont) {
  45417. canBreak = true;
  45418. }
  45419. } else if (isSymbolicFont && platformId === 3 && encodingId === 0) {
  45420. useTable = true;
  45421. canBreak = true;
  45422. }
  45423. if (useTable) {
  45424. potentialTable = {
  45425. platformId: platformId,
  45426. encodingId: encodingId,
  45427. offset: offset
  45428. };
  45429. }
  45430. if (canBreak) {
  45431. break;
  45432. }
  45433. }
  45434. if (potentialTable) {
  45435. font.pos = start + potentialTable.offset;
  45436. }
  45437. if (!potentialTable || font.peekByte() === -1) {
  45438. warn('Could not find a preferred cmap table.');
  45439. return {
  45440. platformId: -1,
  45441. encodingId: -1,
  45442. mappings: [],
  45443. hasShortCmap: false
  45444. };
  45445. }
  45446. var format = font.getUint16();
  45447. font.getUint16();
  45448. font.getUint16();
  45449. var hasShortCmap = false;
  45450. var mappings = [];
  45451. var j, glyphId;
  45452. if (format === 0) {
  45453. for (j = 0; j < 256; j++) {
  45454. var index = font.getByte();
  45455. if (!index) {
  45456. continue;
  45457. }
  45458. mappings.push({
  45459. charCode: j,
  45460. glyphId: index
  45461. });
  45462. }
  45463. hasShortCmap = true;
  45464. } else if (format === 4) {
  45465. var segCount = font.getUint16() >> 1;
  45466. font.getBytes(6);
  45467. var segIndex, segments = [];
  45468. for (segIndex = 0; segIndex < segCount; segIndex++) {
  45469. segments.push({ end: font.getUint16() });
  45470. }
  45471. font.getUint16();
  45472. for (segIndex = 0; segIndex < segCount; segIndex++) {
  45473. segments[segIndex].start = font.getUint16();
  45474. }
  45475. for (segIndex = 0; segIndex < segCount; segIndex++) {
  45476. segments[segIndex].delta = font.getUint16();
  45477. }
  45478. var offsetsCount = 0;
  45479. for (segIndex = 0; segIndex < segCount; segIndex++) {
  45480. segment = segments[segIndex];
  45481. var rangeOffset = font.getUint16();
  45482. if (!rangeOffset) {
  45483. segment.offsetIndex = -1;
  45484. continue;
  45485. }
  45486. var offsetIndex = (rangeOffset >> 1) - (segCount - segIndex);
  45487. segment.offsetIndex = offsetIndex;
  45488. offsetsCount = Math.max(offsetsCount, offsetIndex + segment.end - segment.start + 1);
  45489. }
  45490. var offsets = [];
  45491. for (j = 0; j < offsetsCount; j++) {
  45492. offsets.push(font.getUint16());
  45493. }
  45494. for (segIndex = 0; segIndex < segCount; segIndex++) {
  45495. segment = segments[segIndex];
  45496. start = segment.start;
  45497. var end = segment.end;
  45498. var delta = segment.delta;
  45499. offsetIndex = segment.offsetIndex;
  45500. for (j = start; j <= end; j++) {
  45501. if (j === 0xFFFF) {
  45502. continue;
  45503. }
  45504. glyphId = offsetIndex < 0 ? j : offsets[offsetIndex + j - start];
  45505. glyphId = glyphId + delta & 0xFFFF;
  45506. if (glyphId === 0) {
  45507. continue;
  45508. }
  45509. mappings.push({
  45510. charCode: j,
  45511. glyphId: glyphId
  45512. });
  45513. }
  45514. }
  45515. } else if (format === 6) {
  45516. var firstCode = font.getUint16();
  45517. var entryCount = font.getUint16();
  45518. for (j = 0; j < entryCount; j++) {
  45519. glyphId = font.getUint16();
  45520. var charCode = firstCode + j;
  45521. mappings.push({
  45522. charCode: charCode,
  45523. glyphId: glyphId
  45524. });
  45525. }
  45526. } else {
  45527. warn('cmap table has unsupported format: ' + format);
  45528. return {
  45529. platformId: -1,
  45530. encodingId: -1,
  45531. mappings: [],
  45532. hasShortCmap: false
  45533. };
  45534. }
  45535. mappings.sort(function (a, b) {
  45536. return a.charCode - b.charCode;
  45537. });
  45538. for (i = 1; i < mappings.length; i++) {
  45539. if (mappings[i - 1].charCode === mappings[i].charCode) {
  45540. mappings.splice(i, 1);
  45541. i--;
  45542. }
  45543. }
  45544. return {
  45545. platformId: potentialTable.platformId,
  45546. encodingId: potentialTable.encodingId,
  45547. mappings: mappings,
  45548. hasShortCmap: hasShortCmap
  45549. };
  45550. }
  45551. function sanitizeMetrics(font, header, metrics, numGlyphs) {
  45552. if (!header) {
  45553. if (metrics) {
  45554. metrics.data = null;
  45555. }
  45556. return;
  45557. }
  45558. font.pos = (font.start ? font.start : 0) + header.offset;
  45559. font.pos += header.length - 2;
  45560. var numOfMetrics = font.getUint16();
  45561. if (numOfMetrics > numGlyphs) {
  45562. info('The numOfMetrics (' + numOfMetrics + ') should not be ' + 'greater than the numGlyphs (' + numGlyphs + ')');
  45563. numOfMetrics = numGlyphs;
  45564. header.data[34] = (numOfMetrics & 0xff00) >> 8;
  45565. header.data[35] = numOfMetrics & 0x00ff;
  45566. }
  45567. var numOfSidebearings = numGlyphs - numOfMetrics;
  45568. var numMissing = numOfSidebearings - (metrics.length - numOfMetrics * 4 >> 1);
  45569. if (numMissing > 0) {
  45570. var entries = new Uint8Array(metrics.length + numMissing * 2);
  45571. entries.set(metrics.data);
  45572. metrics.data = entries;
  45573. }
  45574. }
  45575. function sanitizeGlyph(source, sourceStart, sourceEnd, dest, destStart, hintsValid) {
  45576. if (sourceEnd - sourceStart <= 12) {
  45577. return 0;
  45578. }
  45579. var glyf = source.subarray(sourceStart, sourceEnd);
  45580. var contoursCount = glyf[0] << 8 | glyf[1];
  45581. if (contoursCount & 0x8000) {
  45582. dest.set(glyf, destStart);
  45583. return glyf.length;
  45584. }
  45585. var i, j = 10, flagsCount = 0;
  45586. for (i = 0; i < contoursCount; i++) {
  45587. var endPoint = glyf[j] << 8 | glyf[j + 1];
  45588. flagsCount = endPoint + 1;
  45589. j += 2;
  45590. }
  45591. var instructionsStart = j;
  45592. var instructionsLength = glyf[j] << 8 | glyf[j + 1];
  45593. j += 2 + instructionsLength;
  45594. var instructionsEnd = j;
  45595. var coordinatesLength = 0;
  45596. for (i = 0; i < flagsCount; i++) {
  45597. var flag = glyf[j++];
  45598. if (flag & 0xC0) {
  45599. glyf[j - 1] = flag & 0x3F;
  45600. }
  45601. var xyLength = (flag & 2 ? 1 : flag & 16 ? 0 : 2) + (flag & 4 ? 1 : flag & 32 ? 0 : 2);
  45602. coordinatesLength += xyLength;
  45603. if (flag & 8) {
  45604. var repeat = glyf[j++];
  45605. i += repeat;
  45606. coordinatesLength += repeat * xyLength;
  45607. }
  45608. }
  45609. if (coordinatesLength === 0) {
  45610. return 0;
  45611. }
  45612. var glyphDataLength = j + coordinatesLength;
  45613. if (glyphDataLength > glyf.length) {
  45614. return 0;
  45615. }
  45616. if (!hintsValid && instructionsLength > 0) {
  45617. dest.set(glyf.subarray(0, instructionsStart), destStart);
  45618. dest.set([
  45619. 0,
  45620. 0
  45621. ], destStart + instructionsStart);
  45622. dest.set(glyf.subarray(instructionsEnd, glyphDataLength), destStart + instructionsStart + 2);
  45623. glyphDataLength -= instructionsLength;
  45624. if (glyf.length - glyphDataLength > 3) {
  45625. glyphDataLength = glyphDataLength + 3 & ~3;
  45626. }
  45627. return glyphDataLength;
  45628. }
  45629. if (glyf.length - glyphDataLength > 3) {
  45630. glyphDataLength = glyphDataLength + 3 & ~3;
  45631. dest.set(glyf.subarray(0, glyphDataLength), destStart);
  45632. return glyphDataLength;
  45633. }
  45634. dest.set(glyf, destStart);
  45635. return glyf.length;
  45636. }
  45637. function sanitizeHead(head, numGlyphs, locaLength) {
  45638. var data = head.data;
  45639. var version = int32(data[0], data[1], data[2], data[3]);
  45640. if (version >> 16 !== 1) {
  45641. info('Attempting to fix invalid version in head table: ' + version);
  45642. data[0] = 0;
  45643. data[1] = 1;
  45644. data[2] = 0;
  45645. data[3] = 0;
  45646. }
  45647. var indexToLocFormat = int16(data[50], data[51]);
  45648. if (indexToLocFormat < 0 || indexToLocFormat > 1) {
  45649. info('Attempting to fix invalid indexToLocFormat in head table: ' + indexToLocFormat);
  45650. var numGlyphsPlusOne = numGlyphs + 1;
  45651. if (locaLength === numGlyphsPlusOne << 1) {
  45652. data[50] = 0;
  45653. data[51] = 0;
  45654. } else if (locaLength === numGlyphsPlusOne << 2) {
  45655. data[50] = 0;
  45656. data[51] = 1;
  45657. } else {
  45658. warn('Could not fix indexToLocFormat: ' + indexToLocFormat);
  45659. }
  45660. }
  45661. }
  45662. function sanitizeGlyphLocations(loca, glyf, numGlyphs, isGlyphLocationsLong, hintsValid, dupFirstEntry) {
  45663. var itemSize, itemDecode, itemEncode;
  45664. if (isGlyphLocationsLong) {
  45665. itemSize = 4;
  45666. itemDecode = function fontItemDecodeLong(data, offset) {
  45667. return data[offset] << 24 | data[offset + 1] << 16 | data[offset + 2] << 8 | data[offset + 3];
  45668. };
  45669. itemEncode = function fontItemEncodeLong(data, offset, value) {
  45670. data[offset] = value >>> 24 & 0xFF;
  45671. data[offset + 1] = value >> 16 & 0xFF;
  45672. data[offset + 2] = value >> 8 & 0xFF;
  45673. data[offset + 3] = value & 0xFF;
  45674. };
  45675. } else {
  45676. itemSize = 2;
  45677. itemDecode = function fontItemDecode(data, offset) {
  45678. return data[offset] << 9 | data[offset + 1] << 1;
  45679. };
  45680. itemEncode = function fontItemEncode(data, offset, value) {
  45681. data[offset] = value >> 9 & 0xFF;
  45682. data[offset + 1] = value >> 1 & 0xFF;
  45683. };
  45684. }
  45685. var locaData = loca.data;
  45686. var locaDataSize = itemSize * (1 + numGlyphs);
  45687. if (locaData.length !== locaDataSize) {
  45688. locaData = new Uint8Array(locaDataSize);
  45689. locaData.set(loca.data.subarray(0, locaDataSize));
  45690. loca.data = locaData;
  45691. }
  45692. var oldGlyfData = glyf.data;
  45693. var oldGlyfDataLength = oldGlyfData.length;
  45694. var newGlyfData = new Uint8Array(oldGlyfDataLength);
  45695. var startOffset = itemDecode(locaData, 0);
  45696. var writeOffset = 0;
  45697. var missingGlyphData = Object.create(null);
  45698. itemEncode(locaData, 0, writeOffset);
  45699. var i, j;
  45700. for (i = 0, j = itemSize; i < numGlyphs; i++, j += itemSize) {
  45701. var endOffset = itemDecode(locaData, j);
  45702. if (endOffset > oldGlyfDataLength && (oldGlyfDataLength + 3 & ~3) === endOffset) {
  45703. endOffset = oldGlyfDataLength;
  45704. }
  45705. if (endOffset > oldGlyfDataLength) {
  45706. itemEncode(locaData, j, writeOffset);
  45707. startOffset = endOffset;
  45708. continue;
  45709. }
  45710. if (startOffset === endOffset) {
  45711. missingGlyphData[i] = true;
  45712. }
  45713. var newLength = sanitizeGlyph(oldGlyfData, startOffset, endOffset, newGlyfData, writeOffset, hintsValid);
  45714. writeOffset += newLength;
  45715. itemEncode(locaData, j, writeOffset);
  45716. startOffset = endOffset;
  45717. }
  45718. if (writeOffset === 0) {
  45719. var simpleGlyph = new Uint8Array([
  45720. 0,
  45721. 1,
  45722. 0,
  45723. 0,
  45724. 0,
  45725. 0,
  45726. 0,
  45727. 0,
  45728. 0,
  45729. 0,
  45730. 0,
  45731. 0,
  45732. 0,
  45733. 0,
  45734. 49,
  45735. 0
  45736. ]);
  45737. for (i = 0, j = itemSize; i < numGlyphs; i++, j += itemSize) {
  45738. itemEncode(locaData, j, simpleGlyph.length);
  45739. }
  45740. glyf.data = simpleGlyph;
  45741. return missingGlyphData;
  45742. }
  45743. if (dupFirstEntry) {
  45744. var firstEntryLength = itemDecode(locaData, itemSize);
  45745. if (newGlyfData.length > firstEntryLength + writeOffset) {
  45746. glyf.data = newGlyfData.subarray(0, firstEntryLength + writeOffset);
  45747. } else {
  45748. glyf.data = new Uint8Array(firstEntryLength + writeOffset);
  45749. glyf.data.set(newGlyfData.subarray(0, writeOffset));
  45750. }
  45751. glyf.data.set(newGlyfData.subarray(0, firstEntryLength), writeOffset);
  45752. itemEncode(loca.data, locaData.length - itemSize, writeOffset + firstEntryLength);
  45753. } else {
  45754. glyf.data = newGlyfData.subarray(0, writeOffset);
  45755. }
  45756. return missingGlyphData;
  45757. }
  45758. function readPostScriptTable(post, properties, maxpNumGlyphs) {
  45759. var start = (font.start ? font.start : 0) + post.offset;
  45760. font.pos = start;
  45761. var length = post.length, end = start + length;
  45762. var version = font.getInt32();
  45763. font.getBytes(28);
  45764. var glyphNames;
  45765. var valid = true;
  45766. var i;
  45767. switch (version) {
  45768. case 0x00010000:
  45769. glyphNames = MacStandardGlyphOrdering;
  45770. break;
  45771. case 0x00020000:
  45772. var numGlyphs = font.getUint16();
  45773. if (numGlyphs !== maxpNumGlyphs) {
  45774. valid = false;
  45775. break;
  45776. }
  45777. var glyphNameIndexes = [];
  45778. for (i = 0; i < numGlyphs; ++i) {
  45779. var index = font.getUint16();
  45780. if (index >= 32768) {
  45781. valid = false;
  45782. break;
  45783. }
  45784. glyphNameIndexes.push(index);
  45785. }
  45786. if (!valid) {
  45787. break;
  45788. }
  45789. var customNames = [];
  45790. var strBuf = [];
  45791. while (font.pos < end) {
  45792. var stringLength = font.getByte();
  45793. strBuf.length = stringLength;
  45794. for (i = 0; i < stringLength; ++i) {
  45795. strBuf[i] = String.fromCharCode(font.getByte());
  45796. }
  45797. customNames.push(strBuf.join(''));
  45798. }
  45799. glyphNames = [];
  45800. for (i = 0; i < numGlyphs; ++i) {
  45801. var j = glyphNameIndexes[i];
  45802. if (j < 258) {
  45803. glyphNames.push(MacStandardGlyphOrdering[j]);
  45804. continue;
  45805. }
  45806. glyphNames.push(customNames[j - 258]);
  45807. }
  45808. break;
  45809. case 0x00030000:
  45810. break;
  45811. default:
  45812. warn('Unknown/unsupported post table version ' + version);
  45813. valid = false;
  45814. if (properties.defaultEncoding) {
  45815. glyphNames = properties.defaultEncoding;
  45816. }
  45817. break;
  45818. }
  45819. properties.glyphNames = glyphNames;
  45820. return valid;
  45821. }
  45822. function readNameTable(nameTable) {
  45823. var start = (font.start ? font.start : 0) + nameTable.offset;
  45824. font.pos = start;
  45825. var names = [
  45826. [],
  45827. []
  45828. ];
  45829. var length = nameTable.length, end = start + length;
  45830. var format = font.getUint16();
  45831. var FORMAT_0_HEADER_LENGTH = 6;
  45832. if (format !== 0 || length < FORMAT_0_HEADER_LENGTH) {
  45833. return names;
  45834. }
  45835. var numRecords = font.getUint16();
  45836. var stringsStart = font.getUint16();
  45837. var records = [];
  45838. var NAME_RECORD_LENGTH = 12;
  45839. var i, ii;
  45840. for (i = 0; i < numRecords && font.pos + NAME_RECORD_LENGTH <= end; i++) {
  45841. var r = {
  45842. platform: font.getUint16(),
  45843. encoding: font.getUint16(),
  45844. language: font.getUint16(),
  45845. name: font.getUint16(),
  45846. length: font.getUint16(),
  45847. offset: font.getUint16()
  45848. };
  45849. if (r.platform === 1 && r.encoding === 0 && r.language === 0 || r.platform === 3 && r.encoding === 1 && r.language === 0x409) {
  45850. records.push(r);
  45851. }
  45852. }
  45853. for (i = 0, ii = records.length; i < ii; i++) {
  45854. var record = records[i];
  45855. if (record.length <= 0) {
  45856. continue;
  45857. }
  45858. var pos = start + stringsStart + record.offset;
  45859. if (pos + record.length > end) {
  45860. continue;
  45861. }
  45862. font.pos = pos;
  45863. var nameIndex = record.name;
  45864. if (record.encoding) {
  45865. var str = '';
  45866. for (var j = 0, jj = record.length; j < jj; j += 2) {
  45867. str += String.fromCharCode(font.getUint16());
  45868. }
  45869. names[1][nameIndex] = str;
  45870. } else {
  45871. names[0][nameIndex] = bytesToString(font.getBytes(record.length));
  45872. }
  45873. }
  45874. return names;
  45875. }
  45876. var TTOpsStackDeltas = [
  45877. 0,
  45878. 0,
  45879. 0,
  45880. 0,
  45881. 0,
  45882. 0,
  45883. 0,
  45884. 0,
  45885. -2,
  45886. -2,
  45887. -2,
  45888. -2,
  45889. 0,
  45890. 0,
  45891. -2,
  45892. -5,
  45893. -1,
  45894. -1,
  45895. -1,
  45896. -1,
  45897. -1,
  45898. -1,
  45899. -1,
  45900. -1,
  45901. 0,
  45902. 0,
  45903. -1,
  45904. 0,
  45905. -1,
  45906. -1,
  45907. -1,
  45908. -1,
  45909. 1,
  45910. -1,
  45911. -999,
  45912. 0,
  45913. 1,
  45914. 0,
  45915. -1,
  45916. -2,
  45917. 0,
  45918. -1,
  45919. -2,
  45920. -1,
  45921. -1,
  45922. 0,
  45923. -1,
  45924. -1,
  45925. 0,
  45926. 0,
  45927. -999,
  45928. -999,
  45929. -1,
  45930. -1,
  45931. -1,
  45932. -1,
  45933. -2,
  45934. -999,
  45935. -2,
  45936. -2,
  45937. -999,
  45938. 0,
  45939. -2,
  45940. -2,
  45941. 0,
  45942. 0,
  45943. -2,
  45944. 0,
  45945. -2,
  45946. 0,
  45947. 0,
  45948. 0,
  45949. -2,
  45950. -1,
  45951. -1,
  45952. 1,
  45953. 1,
  45954. 0,
  45955. 0,
  45956. -1,
  45957. -1,
  45958. -1,
  45959. -1,
  45960. -1,
  45961. -1,
  45962. -1,
  45963. 0,
  45964. 0,
  45965. -1,
  45966. 0,
  45967. -1,
  45968. -1,
  45969. 0,
  45970. -999,
  45971. -1,
  45972. -1,
  45973. -1,
  45974. -1,
  45975. -1,
  45976. -1,
  45977. 0,
  45978. 0,
  45979. 0,
  45980. 0,
  45981. 0,
  45982. 0,
  45983. 0,
  45984. 0,
  45985. 0,
  45986. 0,
  45987. 0,
  45988. 0,
  45989. -2,
  45990. -999,
  45991. -999,
  45992. -999,
  45993. -999,
  45994. -999,
  45995. -1,
  45996. -1,
  45997. -2,
  45998. -2,
  45999. 0,
  46000. 0,
  46001. 0,
  46002. 0,
  46003. -1,
  46004. -1,
  46005. -999,
  46006. -2,
  46007. -2,
  46008. 0,
  46009. 0,
  46010. -1,
  46011. -2,
  46012. -2,
  46013. 0,
  46014. 0,
  46015. 0,
  46016. -1,
  46017. -1,
  46018. -1,
  46019. -2
  46020. ];
  46021. function sanitizeTTProgram(table, ttContext) {
  46022. var data = table.data;
  46023. var i = 0, j, n, b, funcId, pc, lastEndf = 0, lastDeff = 0;
  46024. var stack = [];
  46025. var callstack = [];
  46026. var functionsCalled = [];
  46027. var tooComplexToFollowFunctions = ttContext.tooComplexToFollowFunctions;
  46028. var inFDEF = false, ifLevel = 0, inELSE = 0;
  46029. for (var ii = data.length; i < ii;) {
  46030. var op = data[i++];
  46031. if (op === 0x40) {
  46032. n = data[i++];
  46033. if (inFDEF || inELSE) {
  46034. i += n;
  46035. } else {
  46036. for (j = 0; j < n; j++) {
  46037. stack.push(data[i++]);
  46038. }
  46039. }
  46040. } else if (op === 0x41) {
  46041. n = data[i++];
  46042. if (inFDEF || inELSE) {
  46043. i += n * 2;
  46044. } else {
  46045. for (j = 0; j < n; j++) {
  46046. b = data[i++];
  46047. stack.push(b << 8 | data[i++]);
  46048. }
  46049. }
  46050. } else if ((op & 0xF8) === 0xB0) {
  46051. n = op - 0xB0 + 1;
  46052. if (inFDEF || inELSE) {
  46053. i += n;
  46054. } else {
  46055. for (j = 0; j < n; j++) {
  46056. stack.push(data[i++]);
  46057. }
  46058. }
  46059. } else if ((op & 0xF8) === 0xB8) {
  46060. n = op - 0xB8 + 1;
  46061. if (inFDEF || inELSE) {
  46062. i += n * 2;
  46063. } else {
  46064. for (j = 0; j < n; j++) {
  46065. b = data[i++];
  46066. stack.push(b << 8 | data[i++]);
  46067. }
  46068. }
  46069. } else if (op === 0x2B && !tooComplexToFollowFunctions) {
  46070. if (!inFDEF && !inELSE) {
  46071. funcId = stack[stack.length - 1];
  46072. ttContext.functionsUsed[funcId] = true;
  46073. if (funcId in ttContext.functionsStackDeltas) {
  46074. stack.length += ttContext.functionsStackDeltas[funcId];
  46075. } else if (funcId in ttContext.functionsDefined && functionsCalled.indexOf(funcId) < 0) {
  46076. callstack.push({
  46077. data: data,
  46078. i: i,
  46079. stackTop: stack.length - 1
  46080. });
  46081. functionsCalled.push(funcId);
  46082. pc = ttContext.functionsDefined[funcId];
  46083. if (!pc) {
  46084. warn('TT: CALL non-existent function');
  46085. ttContext.hintsValid = false;
  46086. return;
  46087. }
  46088. data = pc.data;
  46089. i = pc.i;
  46090. }
  46091. }
  46092. } else if (op === 0x2C && !tooComplexToFollowFunctions) {
  46093. if (inFDEF || inELSE) {
  46094. warn('TT: nested FDEFs not allowed');
  46095. tooComplexToFollowFunctions = true;
  46096. }
  46097. inFDEF = true;
  46098. lastDeff = i;
  46099. funcId = stack.pop();
  46100. ttContext.functionsDefined[funcId] = {
  46101. data: data,
  46102. i: i
  46103. };
  46104. } else if (op === 0x2D) {
  46105. if (inFDEF) {
  46106. inFDEF = false;
  46107. lastEndf = i;
  46108. } else {
  46109. pc = callstack.pop();
  46110. if (!pc) {
  46111. warn('TT: ENDF bad stack');
  46112. ttContext.hintsValid = false;
  46113. return;
  46114. }
  46115. funcId = functionsCalled.pop();
  46116. data = pc.data;
  46117. i = pc.i;
  46118. ttContext.functionsStackDeltas[funcId] = stack.length - pc.stackTop;
  46119. }
  46120. } else if (op === 0x89) {
  46121. if (inFDEF || inELSE) {
  46122. warn('TT: nested IDEFs not allowed');
  46123. tooComplexToFollowFunctions = true;
  46124. }
  46125. inFDEF = true;
  46126. lastDeff = i;
  46127. } else if (op === 0x58) {
  46128. ++ifLevel;
  46129. } else if (op === 0x1B) {
  46130. inELSE = ifLevel;
  46131. } else if (op === 0x59) {
  46132. if (inELSE === ifLevel) {
  46133. inELSE = 0;
  46134. }
  46135. --ifLevel;
  46136. } else if (op === 0x1C) {
  46137. if (!inFDEF && !inELSE) {
  46138. var offset = stack[stack.length - 1];
  46139. if (offset > 0) {
  46140. i += offset - 1;
  46141. }
  46142. }
  46143. }
  46144. if (!inFDEF && !inELSE) {
  46145. var stackDelta = op <= 0x8E ? TTOpsStackDeltas[op] : op >= 0xC0 && op <= 0xDF ? -1 : op >= 0xE0 ? -2 : 0;
  46146. if (op >= 0x71 && op <= 0x75) {
  46147. n = stack.pop();
  46148. if (!isNaN(n)) {
  46149. stackDelta = -n * 2;
  46150. }
  46151. }
  46152. while (stackDelta < 0 && stack.length > 0) {
  46153. stack.pop();
  46154. stackDelta++;
  46155. }
  46156. while (stackDelta > 0) {
  46157. stack.push(NaN);
  46158. stackDelta--;
  46159. }
  46160. }
  46161. }
  46162. ttContext.tooComplexToFollowFunctions = tooComplexToFollowFunctions;
  46163. var content = [data];
  46164. if (i > data.length) {
  46165. content.push(new Uint8Array(i - data.length));
  46166. }
  46167. if (lastDeff > lastEndf) {
  46168. warn('TT: complementing a missing function tail');
  46169. content.push(new Uint8Array([
  46170. 0x22,
  46171. 0x2D
  46172. ]));
  46173. }
  46174. foldTTTable(table, content);
  46175. }
  46176. function checkInvalidFunctions(ttContext, maxFunctionDefs) {
  46177. if (ttContext.tooComplexToFollowFunctions) {
  46178. return;
  46179. }
  46180. if (ttContext.functionsDefined.length > maxFunctionDefs) {
  46181. warn('TT: more functions defined than expected');
  46182. ttContext.hintsValid = false;
  46183. return;
  46184. }
  46185. for (var j = 0, jj = ttContext.functionsUsed.length; j < jj; j++) {
  46186. if (j > maxFunctionDefs) {
  46187. warn('TT: invalid function id: ' + j);
  46188. ttContext.hintsValid = false;
  46189. return;
  46190. }
  46191. if (ttContext.functionsUsed[j] && !ttContext.functionsDefined[j]) {
  46192. warn('TT: undefined function: ' + j);
  46193. ttContext.hintsValid = false;
  46194. return;
  46195. }
  46196. }
  46197. }
  46198. function foldTTTable(table, content) {
  46199. if (content.length > 1) {
  46200. var newLength = 0;
  46201. var j, jj;
  46202. for (j = 0, jj = content.length; j < jj; j++) {
  46203. newLength += content[j].length;
  46204. }
  46205. newLength = newLength + 3 & ~3;
  46206. var result = new Uint8Array(newLength);
  46207. var pos = 0;
  46208. for (j = 0, jj = content.length; j < jj; j++) {
  46209. result.set(content[j], pos);
  46210. pos += content[j].length;
  46211. }
  46212. table.data = result;
  46213. table.length = newLength;
  46214. }
  46215. }
  46216. function sanitizeTTPrograms(fpgm, prep, cvt, maxFunctionDefs) {
  46217. var ttContext = {
  46218. functionsDefined: [],
  46219. functionsUsed: [],
  46220. functionsStackDeltas: [],
  46221. tooComplexToFollowFunctions: false,
  46222. hintsValid: true
  46223. };
  46224. if (fpgm) {
  46225. sanitizeTTProgram(fpgm, ttContext);
  46226. }
  46227. if (prep) {
  46228. sanitizeTTProgram(prep, ttContext);
  46229. }
  46230. if (fpgm) {
  46231. checkInvalidFunctions(ttContext, maxFunctionDefs);
  46232. }
  46233. if (cvt && cvt.length & 1) {
  46234. var cvtData = new Uint8Array(cvt.length + 1);
  46235. cvtData.set(cvt.data);
  46236. cvt.data = cvtData;
  46237. }
  46238. return ttContext.hintsValid;
  46239. }
  46240. font = new Stream(new Uint8Array(font.getBytes()));
  46241. var VALID_TABLES = [
  46242. 'OS/2',
  46243. 'cmap',
  46244. 'head',
  46245. 'hhea',
  46246. 'hmtx',
  46247. 'maxp',
  46248. 'name',
  46249. 'post',
  46250. 'loca',
  46251. 'glyf',
  46252. 'fpgm',
  46253. 'prep',
  46254. 'cvt ',
  46255. 'CFF '
  46256. ];
  46257. var header = readOpenTypeHeader(font);
  46258. var numTables = header.numTables;
  46259. var cff, cffFile;
  46260. var tables = Object.create(null);
  46261. tables['OS/2'] = null;
  46262. tables['cmap'] = null;
  46263. tables['head'] = null;
  46264. tables['hhea'] = null;
  46265. tables['hmtx'] = null;
  46266. tables['maxp'] = null;
  46267. tables['name'] = null;
  46268. tables['post'] = null;
  46269. var table;
  46270. for (var i = 0; i < numTables; i++) {
  46271. table = readTableEntry(font);
  46272. if (VALID_TABLES.indexOf(table.tag) < 0) {
  46273. continue;
  46274. }
  46275. if (table.length === 0) {
  46276. continue;
  46277. }
  46278. tables[table.tag] = table;
  46279. }
  46280. var isTrueType = !tables['CFF '];
  46281. if (!isTrueType) {
  46282. if (header.version === 'OTTO' && !properties.composite || !tables['head'] || !tables['hhea'] || !tables['maxp'] || !tables['post']) {
  46283. cffFile = new Stream(tables['CFF '].data);
  46284. cff = new CFFFont(cffFile, properties);
  46285. adjustWidths(properties);
  46286. return this.convert(name, cff, properties);
  46287. }
  46288. delete tables['glyf'];
  46289. delete tables['loca'];
  46290. delete tables['fpgm'];
  46291. delete tables['prep'];
  46292. delete tables['cvt '];
  46293. this.isOpenType = true;
  46294. } else {
  46295. if (!tables['loca']) {
  46296. error('Required "loca" table is not found');
  46297. }
  46298. if (!tables['glyf']) {
  46299. warn('Required "glyf" table is not found -- trying to recover.');
  46300. tables['glyf'] = {
  46301. tag: 'glyf',
  46302. data: new Uint8Array(0)
  46303. };
  46304. }
  46305. this.isOpenType = false;
  46306. }
  46307. if (!tables['maxp']) {
  46308. error('Required "maxp" table is not found');
  46309. }
  46310. font.pos = (font.start || 0) + tables['maxp'].offset;
  46311. var version = font.getInt32();
  46312. var numGlyphs = font.getUint16();
  46313. var maxFunctionDefs = 0;
  46314. if (version >= 0x00010000 && tables['maxp'].length >= 22) {
  46315. font.pos += 8;
  46316. var maxZones = font.getUint16();
  46317. if (maxZones > 2) {
  46318. tables['maxp'].data[14] = 0;
  46319. tables['maxp'].data[15] = 2;
  46320. }
  46321. font.pos += 4;
  46322. maxFunctionDefs = font.getUint16();
  46323. }
  46324. var dupFirstEntry = false;
  46325. if (properties.type === 'CIDFontType2' && properties.toUnicode && properties.toUnicode.get(0) > '\u0000') {
  46326. dupFirstEntry = true;
  46327. numGlyphs++;
  46328. tables['maxp'].data[4] = numGlyphs >> 8;
  46329. tables['maxp'].data[5] = numGlyphs & 255;
  46330. }
  46331. var hintsValid = sanitizeTTPrograms(tables['fpgm'], tables['prep'], tables['cvt '], maxFunctionDefs);
  46332. if (!hintsValid) {
  46333. delete tables['fpgm'];
  46334. delete tables['prep'];
  46335. delete tables['cvt '];
  46336. }
  46337. sanitizeMetrics(font, tables['hhea'], tables['hmtx'], numGlyphs);
  46338. if (!tables['head']) {
  46339. error('Required "head" table is not found');
  46340. }
  46341. sanitizeHead(tables['head'], numGlyphs, isTrueType ? tables['loca'].length : 0);
  46342. var missingGlyphs = Object.create(null);
  46343. if (isTrueType) {
  46344. var isGlyphLocationsLong = int16(tables['head'].data[50], tables['head'].data[51]);
  46345. missingGlyphs = sanitizeGlyphLocations(tables['loca'], tables['glyf'], numGlyphs, isGlyphLocationsLong, hintsValid, dupFirstEntry);
  46346. }
  46347. if (!tables['hhea']) {
  46348. error('Required "hhea" table is not found');
  46349. }
  46350. if (tables['hhea'].data[10] === 0 && tables['hhea'].data[11] === 0) {
  46351. tables['hhea'].data[10] = 0xFF;
  46352. tables['hhea'].data[11] = 0xFF;
  46353. }
  46354. var metricsOverride = {
  46355. unitsPerEm: int16(tables['head'].data[18], tables['head'].data[19]),
  46356. yMax: int16(tables['head'].data[42], tables['head'].data[43]),
  46357. yMin: signedInt16(tables['head'].data[38], tables['head'].data[39]),
  46358. ascent: int16(tables['hhea'].data[4], tables['hhea'].data[5]),
  46359. descent: signedInt16(tables['hhea'].data[6], tables['hhea'].data[7])
  46360. };
  46361. this.ascent = metricsOverride.ascent / metricsOverride.unitsPerEm;
  46362. this.descent = metricsOverride.descent / metricsOverride.unitsPerEm;
  46363. if (tables['post']) {
  46364. var valid = readPostScriptTable(tables['post'], properties, numGlyphs);
  46365. if (!valid) {
  46366. tables['post'] = null;
  46367. }
  46368. }
  46369. var charCodeToGlyphId = [], charCode;
  46370. var toUnicode = properties.toUnicode, widths = properties.widths;
  46371. var skipToUnicode = toUnicode instanceof IdentityToUnicodeMap || toUnicode.length === 0x10000;
  46372. function hasGlyph(glyphId, charCode, widthCode) {
  46373. if (!missingGlyphs[glyphId]) {
  46374. return true;
  46375. }
  46376. if (!skipToUnicode && charCode >= 0 && toUnicode.has(charCode)) {
  46377. return true;
  46378. }
  46379. if (widths && widthCode >= 0 && isNum(widths[widthCode])) {
  46380. return true;
  46381. }
  46382. return false;
  46383. }
  46384. if (properties.composite) {
  46385. var cidToGidMap = properties.cidToGidMap || [];
  46386. var isCidToGidMapEmpty = cidToGidMap.length === 0;
  46387. properties.cMap.forEach(function (charCode, cid) {
  46388. assert(cid <= 0xffff, 'Max size of CID is 65,535');
  46389. var glyphId = -1;
  46390. if (isCidToGidMapEmpty) {
  46391. glyphId = cid;
  46392. } else if (cidToGidMap[cid] !== undefined) {
  46393. glyphId = cidToGidMap[cid];
  46394. }
  46395. if (glyphId >= 0 && glyphId < numGlyphs && hasGlyph(glyphId, charCode, cid)) {
  46396. charCodeToGlyphId[charCode] = glyphId;
  46397. }
  46398. });
  46399. if (dupFirstEntry && (isCidToGidMapEmpty || !charCodeToGlyphId[0])) {
  46400. charCodeToGlyphId[0] = numGlyphs - 1;
  46401. }
  46402. } else {
  46403. var cmapTable = readCmapTable(tables['cmap'], font, this.isSymbolicFont, properties.hasEncoding);
  46404. var cmapPlatformId = cmapTable.platformId;
  46405. var cmapEncodingId = cmapTable.encodingId;
  46406. var cmapMappings = cmapTable.mappings;
  46407. var cmapMappingsLength = cmapMappings.length;
  46408. if (properties.hasEncoding && (cmapPlatformId === 3 && cmapEncodingId === 1 || cmapPlatformId === 1 && cmapEncodingId === 0) || cmapPlatformId === -1 && cmapEncodingId === -1 && !!getEncoding(properties.baseEncodingName)) {
  46409. var baseEncoding = [];
  46410. if (properties.baseEncodingName === 'MacRomanEncoding' || properties.baseEncodingName === 'WinAnsiEncoding') {
  46411. baseEncoding = getEncoding(properties.baseEncodingName);
  46412. }
  46413. var glyphsUnicodeMap = getGlyphsUnicode();
  46414. for (charCode = 0; charCode < 256; charCode++) {
  46415. var glyphName, standardGlyphName;
  46416. if (this.differences && charCode in this.differences) {
  46417. glyphName = this.differences[charCode];
  46418. } else if (charCode in baseEncoding && baseEncoding[charCode] !== '') {
  46419. glyphName = baseEncoding[charCode];
  46420. } else {
  46421. glyphName = StandardEncoding[charCode];
  46422. }
  46423. if (!glyphName) {
  46424. continue;
  46425. }
  46426. standardGlyphName = recoverGlyphName(glyphName, glyphsUnicodeMap);
  46427. var unicodeOrCharCode, isUnicode = false;
  46428. if (cmapPlatformId === 3 && cmapEncodingId === 1) {
  46429. unicodeOrCharCode = glyphsUnicodeMap[standardGlyphName];
  46430. isUnicode = true;
  46431. } else if (cmapPlatformId === 1 && cmapEncodingId === 0) {
  46432. unicodeOrCharCode = MacRomanEncoding.indexOf(standardGlyphName);
  46433. }
  46434. var found = false;
  46435. for (i = 0; i < cmapMappingsLength; ++i) {
  46436. if (cmapMappings[i].charCode !== unicodeOrCharCode) {
  46437. continue;
  46438. }
  46439. var code = isUnicode ? charCode : unicodeOrCharCode;
  46440. if (hasGlyph(cmapMappings[i].glyphId, code, -1)) {
  46441. charCodeToGlyphId[charCode] = cmapMappings[i].glyphId;
  46442. found = true;
  46443. break;
  46444. }
  46445. }
  46446. if (!found && properties.glyphNames) {
  46447. var glyphId = properties.glyphNames.indexOf(glyphName);
  46448. if (glyphId === -1 && standardGlyphName !== glyphName) {
  46449. glyphId = properties.glyphNames.indexOf(standardGlyphName);
  46450. }
  46451. if (glyphId > 0 && hasGlyph(glyphId, -1, -1)) {
  46452. charCodeToGlyphId[charCode] = glyphId;
  46453. found = true;
  46454. }
  46455. }
  46456. if (!found) {
  46457. charCodeToGlyphId[charCode] = 0;
  46458. }
  46459. }
  46460. } else if (cmapPlatformId === 0 && cmapEncodingId === 0) {
  46461. for (i = 0; i < cmapMappingsLength; ++i) {
  46462. charCodeToGlyphId[cmapMappings[i].charCode] = cmapMappings[i].glyphId;
  46463. }
  46464. } else {
  46465. for (i = 0; i < cmapMappingsLength; ++i) {
  46466. charCode = cmapMappings[i].charCode & 0xFF;
  46467. charCodeToGlyphId[charCode] = cmapMappings[i].glyphId;
  46468. }
  46469. }
  46470. }
  46471. if (charCodeToGlyphId.length === 0) {
  46472. charCodeToGlyphId[0] = 0;
  46473. }
  46474. var newMapping = adjustMapping(charCodeToGlyphId, properties);
  46475. this.toFontChar = newMapping.toFontChar;
  46476. tables['cmap'] = {
  46477. tag: 'cmap',
  46478. data: createCmapTable(newMapping.charCodeToGlyphId, numGlyphs)
  46479. };
  46480. if (!tables['OS/2'] || !validateOS2Table(tables['OS/2'])) {
  46481. tables['OS/2'] = {
  46482. tag: 'OS/2',
  46483. data: createOS2Table(properties, newMapping.charCodeToGlyphId, metricsOverride)
  46484. };
  46485. }
  46486. if (!tables['post']) {
  46487. tables['post'] = {
  46488. tag: 'post',
  46489. data: createPostTable(properties)
  46490. };
  46491. }
  46492. if (!isTrueType) {
  46493. try {
  46494. cffFile = new Stream(tables['CFF '].data);
  46495. var parser = new CFFParser(cffFile, properties, SEAC_ANALYSIS_ENABLED);
  46496. cff = parser.parse();
  46497. var compiler = new CFFCompiler(cff);
  46498. tables['CFF '].data = compiler.compile();
  46499. } catch (e) {
  46500. warn('Failed to compile font ' + properties.loadedName);
  46501. }
  46502. }
  46503. if (!tables['name']) {
  46504. tables['name'] = {
  46505. tag: 'name',
  46506. data: createNameTable(this.name)
  46507. };
  46508. } else {
  46509. var namePrototype = readNameTable(tables['name']);
  46510. tables['name'].data = createNameTable(name, namePrototype);
  46511. }
  46512. var builder = new OpenTypeFileBuilder(header.version);
  46513. for (var tableTag in tables) {
  46514. builder.addTable(tableTag, tables[tableTag].data);
  46515. }
  46516. return builder.toArray();
  46517. },
  46518. convert: function Font_convert(fontName, font, properties) {
  46519. properties.fixedPitch = false;
  46520. if (properties.builtInEncoding) {
  46521. adjustToUnicode(properties, properties.builtInEncoding);
  46522. }
  46523. var mapping = font.getGlyphMapping(properties);
  46524. var newMapping = adjustMapping(mapping, properties);
  46525. this.toFontChar = newMapping.toFontChar;
  46526. var numGlyphs = font.numGlyphs;
  46527. function getCharCodes(charCodeToGlyphId, glyphId) {
  46528. var charCodes = null;
  46529. for (var charCode in charCodeToGlyphId) {
  46530. if (glyphId === charCodeToGlyphId[charCode]) {
  46531. if (!charCodes) {
  46532. charCodes = [];
  46533. }
  46534. charCodes.push(charCode | 0);
  46535. }
  46536. }
  46537. return charCodes;
  46538. }
  46539. function createCharCode(charCodeToGlyphId, glyphId) {
  46540. for (var charCode in charCodeToGlyphId) {
  46541. if (glyphId === charCodeToGlyphId[charCode]) {
  46542. return charCode | 0;
  46543. }
  46544. }
  46545. newMapping.charCodeToGlyphId[newMapping.nextAvailableFontCharCode] = glyphId;
  46546. return newMapping.nextAvailableFontCharCode++;
  46547. }
  46548. var seacs = font.seacs;
  46549. if (SEAC_ANALYSIS_ENABLED && seacs && seacs.length) {
  46550. var matrix = properties.fontMatrix || FONT_IDENTITY_MATRIX;
  46551. var charset = font.getCharset();
  46552. var seacMap = Object.create(null);
  46553. for (var glyphId in seacs) {
  46554. glyphId |= 0;
  46555. var seac = seacs[glyphId];
  46556. var baseGlyphName = StandardEncoding[seac[2]];
  46557. var accentGlyphName = StandardEncoding[seac[3]];
  46558. var baseGlyphId = charset.indexOf(baseGlyphName);
  46559. var accentGlyphId = charset.indexOf(accentGlyphName);
  46560. if (baseGlyphId < 0 || accentGlyphId < 0) {
  46561. continue;
  46562. }
  46563. var accentOffset = {
  46564. x: seac[0] * matrix[0] + seac[1] * matrix[2] + matrix[4],
  46565. y: seac[0] * matrix[1] + seac[1] * matrix[3] + matrix[5]
  46566. };
  46567. var charCodes = getCharCodes(mapping, glyphId);
  46568. if (!charCodes) {
  46569. continue;
  46570. }
  46571. for (var i = 0, ii = charCodes.length; i < ii; i++) {
  46572. var charCode = charCodes[i];
  46573. var charCodeToGlyphId = newMapping.charCodeToGlyphId;
  46574. var baseFontCharCode = createCharCode(charCodeToGlyphId, baseGlyphId);
  46575. var accentFontCharCode = createCharCode(charCodeToGlyphId, accentGlyphId);
  46576. seacMap[charCode] = {
  46577. baseFontCharCode: baseFontCharCode,
  46578. accentFontCharCode: accentFontCharCode,
  46579. accentOffset: accentOffset
  46580. };
  46581. }
  46582. }
  46583. properties.seacMap = seacMap;
  46584. }
  46585. var unitsPerEm = 1 / (properties.fontMatrix || FONT_IDENTITY_MATRIX)[0];
  46586. var builder = new OpenTypeFileBuilder('\x4F\x54\x54\x4F');
  46587. builder.addTable('CFF ', font.data);
  46588. builder.addTable('OS/2', createOS2Table(properties, newMapping.charCodeToGlyphId));
  46589. builder.addTable('cmap', createCmapTable(newMapping.charCodeToGlyphId, numGlyphs));
  46590. 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');
  46591. 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));
  46592. builder.addTable('hmtx', function fontFieldsHmtx() {
  46593. var charstrings = font.charstrings;
  46594. var cffWidths = font.cff ? font.cff.widths : null;
  46595. var hmtx = '\x00\x00\x00\x00';
  46596. for (var i = 1, ii = numGlyphs; i < ii; i++) {
  46597. var width = 0;
  46598. if (charstrings) {
  46599. var charstring = charstrings[i - 1];
  46600. width = 'width' in charstring ? charstring.width : 0;
  46601. } else if (cffWidths) {
  46602. width = Math.ceil(cffWidths[i] || 0);
  46603. }
  46604. hmtx += string16(width) + string16(0);
  46605. }
  46606. return hmtx;
  46607. }());
  46608. builder.addTable('maxp', '\x00\x00\x50\x00' + string16(numGlyphs));
  46609. builder.addTable('name', createNameTable(fontName));
  46610. builder.addTable('post', createPostTable(properties));
  46611. return builder.toArray();
  46612. },
  46613. get spaceWidth() {
  46614. if ('_shadowWidth' in this) {
  46615. return this._shadowWidth;
  46616. }
  46617. var possibleSpaceReplacements = [
  46618. 'space',
  46619. 'minus',
  46620. 'one',
  46621. 'i',
  46622. 'I'
  46623. ];
  46624. var width;
  46625. for (var i = 0, ii = possibleSpaceReplacements.length; i < ii; i++) {
  46626. var glyphName = possibleSpaceReplacements[i];
  46627. if (glyphName in this.widths) {
  46628. width = this.widths[glyphName];
  46629. break;
  46630. }
  46631. var glyphsUnicodeMap = getGlyphsUnicode();
  46632. var glyphUnicode = glyphsUnicodeMap[glyphName];
  46633. var charcode = 0;
  46634. if (this.composite) {
  46635. if (this.cMap.contains(glyphUnicode)) {
  46636. charcode = this.cMap.lookup(glyphUnicode);
  46637. }
  46638. }
  46639. if (!charcode && this.toUnicode) {
  46640. charcode = this.toUnicode.charCodeOf(glyphUnicode);
  46641. }
  46642. if (charcode <= 0) {
  46643. charcode = glyphUnicode;
  46644. }
  46645. width = this.widths[charcode];
  46646. if (width) {
  46647. break;
  46648. }
  46649. }
  46650. width = width || this.defaultWidth;
  46651. this._shadowWidth = width;
  46652. return width;
  46653. },
  46654. charToGlyph: function Font_charToGlyph(charcode, isSpace) {
  46655. var fontCharCode, width, operatorListId;
  46656. var widthCode = charcode;
  46657. if (this.cMap && this.cMap.contains(charcode)) {
  46658. widthCode = this.cMap.lookup(charcode);
  46659. }
  46660. width = this.widths[widthCode];
  46661. width = isNum(width) ? width : this.defaultWidth;
  46662. var vmetric = this.vmetrics && this.vmetrics[widthCode];
  46663. var unicode = this.toUnicode.get(charcode) || charcode;
  46664. if (typeof unicode === 'number') {
  46665. unicode = String.fromCharCode(unicode);
  46666. }
  46667. var isInFont = charcode in this.toFontChar;
  46668. fontCharCode = this.toFontChar[charcode] || charcode;
  46669. if (this.missingFile) {
  46670. fontCharCode = mapSpecialUnicodeValues(fontCharCode);
  46671. }
  46672. if (this.isType3Font) {
  46673. operatorListId = fontCharCode;
  46674. }
  46675. var accent = null;
  46676. if (this.seacMap && this.seacMap[charcode]) {
  46677. isInFont = true;
  46678. var seac = this.seacMap[charcode];
  46679. fontCharCode = seac.baseFontCharCode;
  46680. accent = {
  46681. fontChar: String.fromCharCode(seac.accentFontCharCode),
  46682. offset: seac.accentOffset
  46683. };
  46684. }
  46685. var fontChar = String.fromCharCode(fontCharCode);
  46686. var glyph = this.glyphCache[charcode];
  46687. if (!glyph || !glyph.matchesForCache(fontChar, unicode, accent, width, vmetric, operatorListId, isSpace, isInFont)) {
  46688. glyph = new Glyph(fontChar, unicode, accent, width, vmetric, operatorListId, isSpace, isInFont);
  46689. this.glyphCache[charcode] = glyph;
  46690. }
  46691. return glyph;
  46692. },
  46693. charsToGlyphs: function Font_charsToGlyphs(chars) {
  46694. var charsCache = this.charsCache;
  46695. var glyphs, glyph, charcode;
  46696. if (charsCache) {
  46697. glyphs = charsCache[chars];
  46698. if (glyphs) {
  46699. return glyphs;
  46700. }
  46701. }
  46702. if (!charsCache) {
  46703. charsCache = this.charsCache = Object.create(null);
  46704. }
  46705. glyphs = [];
  46706. var charsCacheKey = chars;
  46707. var i = 0, ii;
  46708. if (this.cMap) {
  46709. var c = Object.create(null);
  46710. while (i < chars.length) {
  46711. this.cMap.readCharCode(chars, i, c);
  46712. charcode = c.charcode;
  46713. var length = c.length;
  46714. i += length;
  46715. var isSpace = length === 1 && chars.charCodeAt(i - 1) === 0x20;
  46716. glyph = this.charToGlyph(charcode, isSpace);
  46717. glyphs.push(glyph);
  46718. }
  46719. } else {
  46720. for (i = 0, ii = chars.length; i < ii; ++i) {
  46721. charcode = chars.charCodeAt(i);
  46722. glyph = this.charToGlyph(charcode, charcode === 0x20);
  46723. glyphs.push(glyph);
  46724. }
  46725. }
  46726. return charsCache[charsCacheKey] = glyphs;
  46727. }
  46728. };
  46729. return Font;
  46730. }();
  46731. var ErrorFont = function ErrorFontClosure() {
  46732. function ErrorFont(error) {
  46733. this.error = error;
  46734. this.loadedName = 'g_font_error';
  46735. this.loading = false;
  46736. }
  46737. ErrorFont.prototype = {
  46738. charsToGlyphs: function ErrorFont_charsToGlyphs() {
  46739. return [];
  46740. },
  46741. exportData: function ErrorFont_exportData() {
  46742. return { error: this.error };
  46743. }
  46744. };
  46745. return ErrorFont;
  46746. }();
  46747. function type1FontGlyphMapping(properties, builtInEncoding, glyphNames) {
  46748. var charCodeToGlyphId = Object.create(null);
  46749. var glyphId, charCode, baseEncoding;
  46750. var isSymbolicFont = !!(properties.flags & FontFlags.Symbolic);
  46751. if (properties.baseEncodingName) {
  46752. baseEncoding = getEncoding(properties.baseEncodingName);
  46753. for (charCode = 0; charCode < baseEncoding.length; charCode++) {
  46754. glyphId = glyphNames.indexOf(baseEncoding[charCode]);
  46755. if (glyphId >= 0) {
  46756. charCodeToGlyphId[charCode] = glyphId;
  46757. } else {
  46758. charCodeToGlyphId[charCode] = 0;
  46759. }
  46760. }
  46761. } else if (isSymbolicFont) {
  46762. for (charCode in builtInEncoding) {
  46763. charCodeToGlyphId[charCode] = builtInEncoding[charCode];
  46764. }
  46765. } else {
  46766. baseEncoding = StandardEncoding;
  46767. for (charCode = 0; charCode < baseEncoding.length; charCode++) {
  46768. glyphId = glyphNames.indexOf(baseEncoding[charCode]);
  46769. if (glyphId >= 0) {
  46770. charCodeToGlyphId[charCode] = glyphId;
  46771. } else {
  46772. charCodeToGlyphId[charCode] = 0;
  46773. }
  46774. }
  46775. }
  46776. var differences = properties.differences, glyphsUnicodeMap;
  46777. if (differences) {
  46778. for (charCode in differences) {
  46779. var glyphName = differences[charCode];
  46780. glyphId = glyphNames.indexOf(glyphName);
  46781. if (glyphId === -1) {
  46782. if (!glyphsUnicodeMap) {
  46783. glyphsUnicodeMap = getGlyphsUnicode();
  46784. }
  46785. var standardGlyphName = recoverGlyphName(glyphName, glyphsUnicodeMap);
  46786. if (standardGlyphName !== glyphName) {
  46787. glyphId = glyphNames.indexOf(standardGlyphName);
  46788. }
  46789. }
  46790. if (glyphId >= 0) {
  46791. charCodeToGlyphId[charCode] = glyphId;
  46792. } else {
  46793. charCodeToGlyphId[charCode] = 0;
  46794. }
  46795. }
  46796. }
  46797. return charCodeToGlyphId;
  46798. }
  46799. var Type1Font = function Type1FontClosure() {
  46800. function findBlock(streamBytes, signature, startIndex) {
  46801. var streamBytesLength = streamBytes.length;
  46802. var signatureLength = signature.length;
  46803. var scanLength = streamBytesLength - signatureLength;
  46804. var i = startIndex, j, found = false;
  46805. while (i < scanLength) {
  46806. j = 0;
  46807. while (j < signatureLength && streamBytes[i + j] === signature[j]) {
  46808. j++;
  46809. }
  46810. if (j >= signatureLength) {
  46811. i += j;
  46812. while (i < streamBytesLength && isSpace(streamBytes[i])) {
  46813. i++;
  46814. }
  46815. found = true;
  46816. break;
  46817. }
  46818. i++;
  46819. }
  46820. return {
  46821. found: found,
  46822. length: i
  46823. };
  46824. }
  46825. function getHeaderBlock(stream, suggestedLength) {
  46826. var EEXEC_SIGNATURE = [
  46827. 0x65,
  46828. 0x65,
  46829. 0x78,
  46830. 0x65,
  46831. 0x63
  46832. ];
  46833. var streamStartPos = stream.pos;
  46834. var headerBytes, headerBytesLength, block;
  46835. try {
  46836. headerBytes = stream.getBytes(suggestedLength);
  46837. headerBytesLength = headerBytes.length;
  46838. } catch (ex) {
  46839. if (ex instanceof MissingDataException) {
  46840. throw ex;
  46841. }
  46842. }
  46843. if (headerBytesLength === suggestedLength) {
  46844. block = findBlock(headerBytes, EEXEC_SIGNATURE, suggestedLength - 2 * EEXEC_SIGNATURE.length);
  46845. if (block.found && block.length === suggestedLength) {
  46846. return {
  46847. stream: new Stream(headerBytes),
  46848. length: suggestedLength
  46849. };
  46850. }
  46851. }
  46852. warn('Invalid "Length1" property in Type1 font -- trying to recover.');
  46853. stream.pos = streamStartPos;
  46854. var SCAN_BLOCK_LENGTH = 2048;
  46855. var actualLength;
  46856. while (true) {
  46857. var scanBytes = stream.peekBytes(SCAN_BLOCK_LENGTH);
  46858. block = findBlock(scanBytes, EEXEC_SIGNATURE, 0);
  46859. if (block.length === 0) {
  46860. break;
  46861. }
  46862. stream.pos += block.length;
  46863. if (block.found) {
  46864. actualLength = stream.pos - streamStartPos;
  46865. break;
  46866. }
  46867. }
  46868. stream.pos = streamStartPos;
  46869. if (actualLength) {
  46870. return {
  46871. stream: new Stream(stream.getBytes(actualLength)),
  46872. length: actualLength
  46873. };
  46874. }
  46875. warn('Unable to recover "Length1" property in Type1 font -- using as is.');
  46876. return {
  46877. stream: new Stream(stream.getBytes(suggestedLength)),
  46878. length: suggestedLength
  46879. };
  46880. }
  46881. function getEexecBlock(stream, suggestedLength) {
  46882. var eexecBytes = stream.getBytes();
  46883. return {
  46884. stream: new Stream(eexecBytes),
  46885. length: eexecBytes.length
  46886. };
  46887. }
  46888. function Type1Font(name, file, properties) {
  46889. var PFB_HEADER_SIZE = 6;
  46890. var headerBlockLength = properties.length1;
  46891. var eexecBlockLength = properties.length2;
  46892. var pfbHeader = file.peekBytes(PFB_HEADER_SIZE);
  46893. var pfbHeaderPresent = pfbHeader[0] === 0x80 && pfbHeader[1] === 0x01;
  46894. if (pfbHeaderPresent) {
  46895. file.skip(PFB_HEADER_SIZE);
  46896. headerBlockLength = pfbHeader[5] << 24 | pfbHeader[4] << 16 | pfbHeader[3] << 8 | pfbHeader[2];
  46897. }
  46898. var headerBlock = getHeaderBlock(file, headerBlockLength);
  46899. headerBlockLength = headerBlock.length;
  46900. var headerBlockParser = new Type1Parser(headerBlock.stream, false, SEAC_ANALYSIS_ENABLED);
  46901. headerBlockParser.extractFontHeader(properties);
  46902. if (pfbHeaderPresent) {
  46903. pfbHeader = file.getBytes(PFB_HEADER_SIZE);
  46904. eexecBlockLength = pfbHeader[5] << 24 | pfbHeader[4] << 16 | pfbHeader[3] << 8 | pfbHeader[2];
  46905. }
  46906. var eexecBlock = getEexecBlock(file, eexecBlockLength);
  46907. eexecBlockLength = eexecBlock.length;
  46908. var eexecBlockParser = new Type1Parser(eexecBlock.stream, true, SEAC_ANALYSIS_ENABLED);
  46909. var data = eexecBlockParser.extractFontProgram();
  46910. for (var info in data.properties) {
  46911. properties[info] = data.properties[info];
  46912. }
  46913. var charstrings = data.charstrings;
  46914. var type2Charstrings = this.getType2Charstrings(charstrings);
  46915. var subrs = this.getType2Subrs(data.subrs);
  46916. this.charstrings = charstrings;
  46917. this.data = this.wrap(name, type2Charstrings, this.charstrings, subrs, properties);
  46918. this.seacs = this.getSeacs(data.charstrings);
  46919. }
  46920. Type1Font.prototype = {
  46921. get numGlyphs() {
  46922. return this.charstrings.length + 1;
  46923. },
  46924. getCharset: function Type1Font_getCharset() {
  46925. var charset = ['.notdef'];
  46926. var charstrings = this.charstrings;
  46927. for (var glyphId = 0; glyphId < charstrings.length; glyphId++) {
  46928. charset.push(charstrings[glyphId].glyphName);
  46929. }
  46930. return charset;
  46931. },
  46932. getGlyphMapping: function Type1Font_getGlyphMapping(properties) {
  46933. var charstrings = this.charstrings;
  46934. var glyphNames = ['.notdef'], glyphId;
  46935. for (glyphId = 0; glyphId < charstrings.length; glyphId++) {
  46936. glyphNames.push(charstrings[glyphId].glyphName);
  46937. }
  46938. var encoding = properties.builtInEncoding;
  46939. if (encoding) {
  46940. var builtInEncoding = Object.create(null);
  46941. for (var charCode in encoding) {
  46942. glyphId = glyphNames.indexOf(encoding[charCode]);
  46943. if (glyphId >= 0) {
  46944. builtInEncoding[charCode] = glyphId;
  46945. }
  46946. }
  46947. }
  46948. return type1FontGlyphMapping(properties, builtInEncoding, glyphNames);
  46949. },
  46950. getSeacs: function Type1Font_getSeacs(charstrings) {
  46951. var i, ii;
  46952. var seacMap = [];
  46953. for (i = 0, ii = charstrings.length; i < ii; i++) {
  46954. var charstring = charstrings[i];
  46955. if (charstring.seac) {
  46956. seacMap[i + 1] = charstring.seac;
  46957. }
  46958. }
  46959. return seacMap;
  46960. },
  46961. getType2Charstrings: function Type1Font_getType2Charstrings(type1Charstrings) {
  46962. var type2Charstrings = [];
  46963. for (var i = 0, ii = type1Charstrings.length; i < ii; i++) {
  46964. type2Charstrings.push(type1Charstrings[i].charstring);
  46965. }
  46966. return type2Charstrings;
  46967. },
  46968. getType2Subrs: function Type1Font_getType2Subrs(type1Subrs) {
  46969. var bias = 0;
  46970. var count = type1Subrs.length;
  46971. if (count < 1133) {
  46972. bias = 107;
  46973. } else if (count < 33769) {
  46974. bias = 1131;
  46975. } else {
  46976. bias = 32768;
  46977. }
  46978. var type2Subrs = [];
  46979. var i;
  46980. for (i = 0; i < bias; i++) {
  46981. type2Subrs.push([0x0B]);
  46982. }
  46983. for (i = 0; i < count; i++) {
  46984. type2Subrs.push(type1Subrs[i]);
  46985. }
  46986. return type2Subrs;
  46987. },
  46988. wrap: function Type1Font_wrap(name, glyphs, charstrings, subrs, properties) {
  46989. var cff = new CFF();
  46990. cff.header = new CFFHeader(1, 0, 4, 4);
  46991. cff.names = [name];
  46992. var topDict = new CFFTopDict();
  46993. topDict.setByName('version', 391);
  46994. topDict.setByName('Notice', 392);
  46995. topDict.setByName('FullName', 393);
  46996. topDict.setByName('FamilyName', 394);
  46997. topDict.setByName('Weight', 395);
  46998. topDict.setByName('Encoding', null);
  46999. topDict.setByName('FontMatrix', properties.fontMatrix);
  47000. topDict.setByName('FontBBox', properties.bbox);
  47001. topDict.setByName('charset', null);
  47002. topDict.setByName('CharStrings', null);
  47003. topDict.setByName('Private', null);
  47004. cff.topDict = topDict;
  47005. var strings = new CFFStrings();
  47006. strings.add('Version 0.11');
  47007. strings.add('See original notice');
  47008. strings.add(name);
  47009. strings.add(name);
  47010. strings.add('Medium');
  47011. cff.strings = strings;
  47012. cff.globalSubrIndex = new CFFIndex();
  47013. var count = glyphs.length;
  47014. var charsetArray = [0];
  47015. var i, ii;
  47016. for (i = 0; i < count; i++) {
  47017. var index = CFFStandardStrings.indexOf(charstrings[i].glyphName);
  47018. if (index === -1) {
  47019. index = 0;
  47020. }
  47021. charsetArray.push(index >> 8 & 0xff, index & 0xff);
  47022. }
  47023. cff.charset = new CFFCharset(false, 0, [], charsetArray);
  47024. var charStringsIndex = new CFFIndex();
  47025. charStringsIndex.add([
  47026. 0x8B,
  47027. 0x0E
  47028. ]);
  47029. for (i = 0; i < count; i++) {
  47030. var glyph = glyphs[i];
  47031. if (glyph.length === 0) {
  47032. charStringsIndex.add([
  47033. 0x8B,
  47034. 0x0E
  47035. ]);
  47036. continue;
  47037. }
  47038. charStringsIndex.add(glyph);
  47039. }
  47040. cff.charStrings = charStringsIndex;
  47041. var privateDict = new CFFPrivateDict();
  47042. privateDict.setByName('Subrs', null);
  47043. var fields = [
  47044. 'BlueValues',
  47045. 'OtherBlues',
  47046. 'FamilyBlues',
  47047. 'FamilyOtherBlues',
  47048. 'StemSnapH',
  47049. 'StemSnapV',
  47050. 'BlueShift',
  47051. 'BlueFuzz',
  47052. 'BlueScale',
  47053. 'LanguageGroup',
  47054. 'ExpansionFactor',
  47055. 'ForceBold',
  47056. 'StdHW',
  47057. 'StdVW'
  47058. ];
  47059. for (i = 0, ii = fields.length; i < ii; i++) {
  47060. var field = fields[i];
  47061. if (!(field in properties.privateData)) {
  47062. continue;
  47063. }
  47064. var value = properties.privateData[field];
  47065. if (isArray(value)) {
  47066. for (var j = value.length - 1; j > 0; j--) {
  47067. value[j] -= value[j - 1];
  47068. }
  47069. }
  47070. privateDict.setByName(field, value);
  47071. }
  47072. cff.topDict.privateDict = privateDict;
  47073. var subrIndex = new CFFIndex();
  47074. for (i = 0, ii = subrs.length; i < ii; i++) {
  47075. subrIndex.add(subrs[i]);
  47076. }
  47077. privateDict.subrsIndex = subrIndex;
  47078. var compiler = new CFFCompiler(cff);
  47079. return compiler.compile();
  47080. }
  47081. };
  47082. return Type1Font;
  47083. }();
  47084. var CFFFont = function CFFFontClosure() {
  47085. function CFFFont(file, properties) {
  47086. this.properties = properties;
  47087. var parser = new CFFParser(file, properties, SEAC_ANALYSIS_ENABLED);
  47088. this.cff = parser.parse();
  47089. var compiler = new CFFCompiler(this.cff);
  47090. this.seacs = this.cff.seacs;
  47091. try {
  47092. this.data = compiler.compile();
  47093. } catch (e) {
  47094. warn('Failed to compile font ' + properties.loadedName);
  47095. this.data = file;
  47096. }
  47097. }
  47098. CFFFont.prototype = {
  47099. get numGlyphs() {
  47100. return this.cff.charStrings.count;
  47101. },
  47102. getCharset: function CFFFont_getCharset() {
  47103. return this.cff.charset.charset;
  47104. },
  47105. getGlyphMapping: function CFFFont_getGlyphMapping() {
  47106. var cff = this.cff;
  47107. var properties = this.properties;
  47108. var charsets = cff.charset.charset;
  47109. var charCodeToGlyphId;
  47110. var glyphId;
  47111. if (properties.composite) {
  47112. charCodeToGlyphId = Object.create(null);
  47113. if (cff.isCIDFont) {
  47114. for (glyphId = 0; glyphId < charsets.length; glyphId++) {
  47115. var cid = charsets[glyphId];
  47116. var charCode = properties.cMap.charCodeOf(cid);
  47117. charCodeToGlyphId[charCode] = glyphId;
  47118. }
  47119. } else {
  47120. for (glyphId = 0; glyphId < cff.charStrings.count; glyphId++) {
  47121. charCodeToGlyphId[glyphId] = glyphId;
  47122. }
  47123. }
  47124. return charCodeToGlyphId;
  47125. }
  47126. var encoding = cff.encoding ? cff.encoding.encoding : null;
  47127. charCodeToGlyphId = type1FontGlyphMapping(properties, encoding, charsets);
  47128. return charCodeToGlyphId;
  47129. }
  47130. };
  47131. return CFFFont;
  47132. }();
  47133. (function checkSeacSupport() {
  47134. if (typeof navigator !== 'undefined' && /Windows/.test(navigator.userAgent)) {
  47135. SEAC_ANALYSIS_ENABLED = true;
  47136. }
  47137. }());
  47138. (function checkChromeWindows() {
  47139. if (typeof navigator !== 'undefined' && /Windows.*Chrome/.test(navigator.userAgent)) {
  47140. SKIP_PRIVATE_USE_RANGE_F000_TO_F01F = true;
  47141. }
  47142. }());
  47143. exports.ErrorFont = ErrorFont;
  47144. exports.Font = Font;
  47145. exports.FontFlags = FontFlags;
  47146. exports.IdentityToUnicodeMap = IdentityToUnicodeMap;
  47147. exports.ToUnicodeMap = ToUnicodeMap;
  47148. exports.getFontType = getFontType;
  47149. /***/ }),
  47150. /* 36 */
  47151. /***/ (function(module, exports, __w_pdfjs_require__) {
  47152. "use strict";
  47153. var sharedUtil = __w_pdfjs_require__(0);
  47154. var corePrimitives = __w_pdfjs_require__(1);
  47155. var coreColorSpace = __w_pdfjs_require__(4);
  47156. var coreStream = __w_pdfjs_require__(2);
  47157. var coreJpx = __w_pdfjs_require__(19);
  47158. var ImageKind = sharedUtil.ImageKind;
  47159. var assert = sharedUtil.assert;
  47160. var error = sharedUtil.error;
  47161. var info = sharedUtil.info;
  47162. var isArray = sharedUtil.isArray;
  47163. var warn = sharedUtil.warn;
  47164. var Name = corePrimitives.Name;
  47165. var isStream = corePrimitives.isStream;
  47166. var ColorSpace = coreColorSpace.ColorSpace;
  47167. var DecodeStream = coreStream.DecodeStream;
  47168. var JpegStream = coreStream.JpegStream;
  47169. var JpxImage = coreJpx.JpxImage;
  47170. var PDFImage = function PDFImageClosure() {
  47171. function handleImageData(image, nativeDecoder) {
  47172. if (nativeDecoder && nativeDecoder.canDecode(image)) {
  47173. return nativeDecoder.decode(image);
  47174. }
  47175. return Promise.resolve(image);
  47176. }
  47177. function decodeAndClamp(value, addend, coefficient, max) {
  47178. value = addend + value * coefficient;
  47179. return value < 0 ? 0 : value > max ? max : value;
  47180. }
  47181. function resizeImageMask(src, bpc, w1, h1, w2, h2) {
  47182. var length = w2 * h2;
  47183. var dest = bpc <= 8 ? new Uint8Array(length) : bpc <= 16 ? new Uint16Array(length) : new Uint32Array(length);
  47184. var xRatio = w1 / w2;
  47185. var yRatio = h1 / h2;
  47186. var i, j, py, newIndex = 0, oldIndex;
  47187. var xScaled = new Uint16Array(w2);
  47188. var w1Scanline = w1;
  47189. for (i = 0; i < w2; i++) {
  47190. xScaled[i] = Math.floor(i * xRatio);
  47191. }
  47192. for (i = 0; i < h2; i++) {
  47193. py = Math.floor(i * yRatio) * w1Scanline;
  47194. for (j = 0; j < w2; j++) {
  47195. oldIndex = py + xScaled[j];
  47196. dest[newIndex++] = src[oldIndex];
  47197. }
  47198. }
  47199. return dest;
  47200. }
  47201. function PDFImage(xref, res, image, inline, smask, mask, isMask) {
  47202. this.image = image;
  47203. var dict = image.dict;
  47204. if (dict.has('Filter')) {
  47205. var filter = dict.get('Filter').name;
  47206. if (filter === 'JPXDecode') {
  47207. var jpxImage = new JpxImage();
  47208. jpxImage.parseImageProperties(image.stream);
  47209. image.stream.reset();
  47210. image.bitsPerComponent = jpxImage.bitsPerComponent;
  47211. image.numComps = jpxImage.componentsCount;
  47212. } else if (filter === 'JBIG2Decode') {
  47213. image.bitsPerComponent = 1;
  47214. image.numComps = 1;
  47215. }
  47216. }
  47217. this.width = dict.get('Width', 'W');
  47218. this.height = dict.get('Height', 'H');
  47219. if (this.width < 1 || this.height < 1) {
  47220. error('Invalid image width: ' + this.width + ' or height: ' + this.height);
  47221. }
  47222. this.interpolate = dict.get('Interpolate', 'I') || false;
  47223. this.imageMask = dict.get('ImageMask', 'IM') || false;
  47224. this.matte = dict.get('Matte') || false;
  47225. var bitsPerComponent = image.bitsPerComponent;
  47226. if (!bitsPerComponent) {
  47227. bitsPerComponent = dict.get('BitsPerComponent', 'BPC');
  47228. if (!bitsPerComponent) {
  47229. if (this.imageMask) {
  47230. bitsPerComponent = 1;
  47231. } else {
  47232. error('Bits per component missing in image: ' + this.imageMask);
  47233. }
  47234. }
  47235. }
  47236. this.bpc = bitsPerComponent;
  47237. if (!this.imageMask) {
  47238. var colorSpace = dict.get('ColorSpace', 'CS');
  47239. if (!colorSpace) {
  47240. info('JPX images (which do not require color spaces)');
  47241. switch (image.numComps) {
  47242. case 1:
  47243. colorSpace = Name.get('DeviceGray');
  47244. break;
  47245. case 3:
  47246. colorSpace = Name.get('DeviceRGB');
  47247. break;
  47248. case 4:
  47249. colorSpace = Name.get('DeviceCMYK');
  47250. break;
  47251. default:
  47252. error('JPX images with ' + this.numComps + ' color components not supported.');
  47253. }
  47254. }
  47255. this.colorSpace = ColorSpace.parse(colorSpace, xref, res);
  47256. this.numComps = this.colorSpace.numComps;
  47257. }
  47258. this.decode = dict.getArray('Decode', 'D');
  47259. this.needsDecode = false;
  47260. if (this.decode && (this.colorSpace && !this.colorSpace.isDefaultDecode(this.decode) || isMask && !ColorSpace.isDefaultDecode(this.decode, 1))) {
  47261. this.needsDecode = true;
  47262. var max = (1 << bitsPerComponent) - 1;
  47263. this.decodeCoefficients = [];
  47264. this.decodeAddends = [];
  47265. for (var i = 0, j = 0; i < this.decode.length; i += 2, ++j) {
  47266. var dmin = this.decode[i];
  47267. var dmax = this.decode[i + 1];
  47268. this.decodeCoefficients[j] = dmax - dmin;
  47269. this.decodeAddends[j] = max * dmin;
  47270. }
  47271. }
  47272. if (smask) {
  47273. this.smask = new PDFImage(xref, res, smask, false);
  47274. } else if (mask) {
  47275. if (isStream(mask)) {
  47276. var maskDict = mask.dict, imageMask = maskDict.get('ImageMask', 'IM');
  47277. if (!imageMask) {
  47278. warn('Ignoring /Mask in image without /ImageMask.');
  47279. } else {
  47280. this.mask = new PDFImage(xref, res, mask, false, null, null, true);
  47281. }
  47282. } else {
  47283. this.mask = mask;
  47284. }
  47285. }
  47286. }
  47287. PDFImage.buildImage = function PDFImage_buildImage(handler, xref, res, image, inline, nativeDecoder) {
  47288. var imagePromise = handleImageData(image, nativeDecoder);
  47289. var smaskPromise;
  47290. var maskPromise;
  47291. var smask = image.dict.get('SMask');
  47292. var mask = image.dict.get('Mask');
  47293. if (smask) {
  47294. smaskPromise = handleImageData(smask, nativeDecoder);
  47295. maskPromise = Promise.resolve(null);
  47296. } else {
  47297. smaskPromise = Promise.resolve(null);
  47298. if (mask) {
  47299. if (isStream(mask)) {
  47300. maskPromise = handleImageData(mask, nativeDecoder);
  47301. } else if (isArray(mask)) {
  47302. maskPromise = Promise.resolve(mask);
  47303. } else {
  47304. warn('Unsupported mask format.');
  47305. maskPromise = Promise.resolve(null);
  47306. }
  47307. } else {
  47308. maskPromise = Promise.resolve(null);
  47309. }
  47310. }
  47311. return Promise.all([
  47312. imagePromise,
  47313. smaskPromise,
  47314. maskPromise
  47315. ]).then(function (results) {
  47316. var imageData = results[0];
  47317. var smaskData = results[1];
  47318. var maskData = results[2];
  47319. return new PDFImage(xref, res, imageData, inline, smaskData, maskData);
  47320. });
  47321. };
  47322. PDFImage.createMask = function PDFImage_createMask(imgArray, width, height, imageIsFromDecodeStream, inverseDecode) {
  47323. var computedLength = (width + 7 >> 3) * height;
  47324. var actualLength = imgArray.byteLength;
  47325. var haveFullData = computedLength === actualLength;
  47326. var data, i;
  47327. if (imageIsFromDecodeStream && (!inverseDecode || haveFullData)) {
  47328. data = imgArray;
  47329. } else if (!inverseDecode) {
  47330. data = new Uint8Array(actualLength);
  47331. data.set(imgArray);
  47332. } else {
  47333. data = new Uint8Array(computedLength);
  47334. data.set(imgArray);
  47335. for (i = actualLength; i < computedLength; i++) {
  47336. data[i] = 0xff;
  47337. }
  47338. }
  47339. if (inverseDecode) {
  47340. for (i = 0; i < actualLength; i++) {
  47341. data[i] = ~data[i];
  47342. }
  47343. }
  47344. return {
  47345. data: data,
  47346. width: width,
  47347. height: height
  47348. };
  47349. };
  47350. PDFImage.prototype = {
  47351. get drawWidth() {
  47352. return Math.max(this.width, this.smask && this.smask.width || 0, this.mask && this.mask.width || 0);
  47353. },
  47354. get drawHeight() {
  47355. return Math.max(this.height, this.smask && this.smask.height || 0, this.mask && this.mask.height || 0);
  47356. },
  47357. decodeBuffer: function PDFImage_decodeBuffer(buffer) {
  47358. var bpc = this.bpc;
  47359. var numComps = this.numComps;
  47360. var decodeAddends = this.decodeAddends;
  47361. var decodeCoefficients = this.decodeCoefficients;
  47362. var max = (1 << bpc) - 1;
  47363. var i, ii;
  47364. if (bpc === 1) {
  47365. for (i = 0, ii = buffer.length; i < ii; i++) {
  47366. buffer[i] = +!buffer[i];
  47367. }
  47368. return;
  47369. }
  47370. var index = 0;
  47371. for (i = 0, ii = this.width * this.height; i < ii; i++) {
  47372. for (var j = 0; j < numComps; j++) {
  47373. buffer[index] = decodeAndClamp(buffer[index], decodeAddends[j], decodeCoefficients[j], max);
  47374. index++;
  47375. }
  47376. }
  47377. },
  47378. getComponents: function PDFImage_getComponents(buffer) {
  47379. var bpc = this.bpc;
  47380. if (bpc === 8) {
  47381. return buffer;
  47382. }
  47383. var width = this.width;
  47384. var height = this.height;
  47385. var numComps = this.numComps;
  47386. var length = width * height * numComps;
  47387. var bufferPos = 0;
  47388. var output = bpc <= 8 ? new Uint8Array(length) : bpc <= 16 ? new Uint16Array(length) : new Uint32Array(length);
  47389. var rowComps = width * numComps;
  47390. var max = (1 << bpc) - 1;
  47391. var i = 0, ii, buf;
  47392. if (bpc === 1) {
  47393. var mask, loop1End, loop2End;
  47394. for (var j = 0; j < height; j++) {
  47395. loop1End = i + (rowComps & ~7);
  47396. loop2End = i + rowComps;
  47397. while (i < loop1End) {
  47398. buf = buffer[bufferPos++];
  47399. output[i] = buf >> 7 & 1;
  47400. output[i + 1] = buf >> 6 & 1;
  47401. output[i + 2] = buf >> 5 & 1;
  47402. output[i + 3] = buf >> 4 & 1;
  47403. output[i + 4] = buf >> 3 & 1;
  47404. output[i + 5] = buf >> 2 & 1;
  47405. output[i + 6] = buf >> 1 & 1;
  47406. output[i + 7] = buf & 1;
  47407. i += 8;
  47408. }
  47409. if (i < loop2End) {
  47410. buf = buffer[bufferPos++];
  47411. mask = 128;
  47412. while (i < loop2End) {
  47413. output[i++] = +!!(buf & mask);
  47414. mask >>= 1;
  47415. }
  47416. }
  47417. }
  47418. } else {
  47419. var bits = 0;
  47420. buf = 0;
  47421. for (i = 0, ii = length; i < ii; ++i) {
  47422. if (i % rowComps === 0) {
  47423. buf = 0;
  47424. bits = 0;
  47425. }
  47426. while (bits < bpc) {
  47427. buf = buf << 8 | buffer[bufferPos++];
  47428. bits += 8;
  47429. }
  47430. var remainingBits = bits - bpc;
  47431. var value = buf >> remainingBits;
  47432. output[i] = value < 0 ? 0 : value > max ? max : value;
  47433. buf = buf & (1 << remainingBits) - 1;
  47434. bits = remainingBits;
  47435. }
  47436. }
  47437. return output;
  47438. },
  47439. fillOpacity: function PDFImage_fillOpacity(rgbaBuf, width, height, actualHeight, image) {
  47440. var smask = this.smask;
  47441. var mask = this.mask;
  47442. var alphaBuf, sw, sh, i, ii, j;
  47443. if (smask) {
  47444. sw = smask.width;
  47445. sh = smask.height;
  47446. alphaBuf = new Uint8Array(sw * sh);
  47447. smask.fillGrayBuffer(alphaBuf);
  47448. if (sw !== width || sh !== height) {
  47449. alphaBuf = resizeImageMask(alphaBuf, smask.bpc, sw, sh, width, height);
  47450. }
  47451. } else if (mask) {
  47452. if (mask instanceof PDFImage) {
  47453. sw = mask.width;
  47454. sh = mask.height;
  47455. alphaBuf = new Uint8Array(sw * sh);
  47456. mask.numComps = 1;
  47457. mask.fillGrayBuffer(alphaBuf);
  47458. for (i = 0, ii = sw * sh; i < ii; ++i) {
  47459. alphaBuf[i] = 255 - alphaBuf[i];
  47460. }
  47461. if (sw !== width || sh !== height) {
  47462. alphaBuf = resizeImageMask(alphaBuf, mask.bpc, sw, sh, width, height);
  47463. }
  47464. } else if (isArray(mask)) {
  47465. alphaBuf = new Uint8Array(width * height);
  47466. var numComps = this.numComps;
  47467. for (i = 0, ii = width * height; i < ii; ++i) {
  47468. var opacity = 0;
  47469. var imageOffset = i * numComps;
  47470. for (j = 0; j < numComps; ++j) {
  47471. var color = image[imageOffset + j];
  47472. var maskOffset = j * 2;
  47473. if (color < mask[maskOffset] || color > mask[maskOffset + 1]) {
  47474. opacity = 255;
  47475. break;
  47476. }
  47477. }
  47478. alphaBuf[i] = opacity;
  47479. }
  47480. } else {
  47481. error('Unknown mask format.');
  47482. }
  47483. }
  47484. if (alphaBuf) {
  47485. for (i = 0, j = 3, ii = width * actualHeight; i < ii; ++i, j += 4) {
  47486. rgbaBuf[j] = alphaBuf[i];
  47487. }
  47488. } else {
  47489. for (i = 0, j = 3, ii = width * actualHeight; i < ii; ++i, j += 4) {
  47490. rgbaBuf[j] = 255;
  47491. }
  47492. }
  47493. },
  47494. undoPreblend: function PDFImage_undoPreblend(buffer, width, height) {
  47495. var matte = this.smask && this.smask.matte;
  47496. if (!matte) {
  47497. return;
  47498. }
  47499. var matteRgb = this.colorSpace.getRgb(matte, 0);
  47500. var matteR = matteRgb[0];
  47501. var matteG = matteRgb[1];
  47502. var matteB = matteRgb[2];
  47503. var length = width * height * 4;
  47504. var r, g, b;
  47505. for (var i = 0; i < length; i += 4) {
  47506. var alpha = buffer[i + 3];
  47507. if (alpha === 0) {
  47508. buffer[i] = 255;
  47509. buffer[i + 1] = 255;
  47510. buffer[i + 2] = 255;
  47511. continue;
  47512. }
  47513. var k = 255 / alpha;
  47514. r = (buffer[i] - matteR) * k + matteR;
  47515. g = (buffer[i + 1] - matteG) * k + matteG;
  47516. b = (buffer[i + 2] - matteB) * k + matteB;
  47517. buffer[i] = r <= 0 ? 0 : r >= 255 ? 255 : r | 0;
  47518. buffer[i + 1] = g <= 0 ? 0 : g >= 255 ? 255 : g | 0;
  47519. buffer[i + 2] = b <= 0 ? 0 : b >= 255 ? 255 : b | 0;
  47520. }
  47521. },
  47522. createImageData: function PDFImage_createImageData(forceRGBA) {
  47523. var drawWidth = this.drawWidth;
  47524. var drawHeight = this.drawHeight;
  47525. var imgData = {
  47526. width: drawWidth,
  47527. height: drawHeight
  47528. };
  47529. var numComps = this.numComps;
  47530. var originalWidth = this.width;
  47531. var originalHeight = this.height;
  47532. var bpc = this.bpc;
  47533. var rowBytes = originalWidth * numComps * bpc + 7 >> 3;
  47534. var imgArray;
  47535. if (!forceRGBA) {
  47536. var kind;
  47537. if (this.colorSpace.name === 'DeviceGray' && bpc === 1) {
  47538. kind = ImageKind.GRAYSCALE_1BPP;
  47539. } else if (this.colorSpace.name === 'DeviceRGB' && bpc === 8 && !this.needsDecode) {
  47540. kind = ImageKind.RGB_24BPP;
  47541. }
  47542. if (kind && !this.smask && !this.mask && drawWidth === originalWidth && drawHeight === originalHeight) {
  47543. imgData.kind = kind;
  47544. imgArray = this.getImageBytes(originalHeight * rowBytes);
  47545. if (this.image instanceof DecodeStream) {
  47546. imgData.data = imgArray;
  47547. } else {
  47548. var newArray = new Uint8Array(imgArray.length);
  47549. newArray.set(imgArray);
  47550. imgData.data = newArray;
  47551. }
  47552. if (this.needsDecode) {
  47553. assert(kind === ImageKind.GRAYSCALE_1BPP);
  47554. var buffer = imgData.data;
  47555. for (var i = 0, ii = buffer.length; i < ii; i++) {
  47556. buffer[i] ^= 0xff;
  47557. }
  47558. }
  47559. return imgData;
  47560. }
  47561. if (this.image instanceof JpegStream && !this.smask && !this.mask && (this.colorSpace.name === 'DeviceGray' || this.colorSpace.name === 'DeviceRGB' || this.colorSpace.name === 'DeviceCMYK')) {
  47562. imgData.kind = ImageKind.RGB_24BPP;
  47563. imgData.data = this.getImageBytes(originalHeight * rowBytes, drawWidth, drawHeight, true);
  47564. return imgData;
  47565. }
  47566. }
  47567. imgArray = this.getImageBytes(originalHeight * rowBytes);
  47568. var actualHeight = 0 | imgArray.length / rowBytes * drawHeight / originalHeight;
  47569. var comps = this.getComponents(imgArray);
  47570. var alpha01, maybeUndoPreblend;
  47571. if (!forceRGBA && !this.smask && !this.mask) {
  47572. imgData.kind = ImageKind.RGB_24BPP;
  47573. imgData.data = new Uint8Array(drawWidth * drawHeight * 3);
  47574. alpha01 = 0;
  47575. maybeUndoPreblend = false;
  47576. } else {
  47577. imgData.kind = ImageKind.RGBA_32BPP;
  47578. imgData.data = new Uint8Array(drawWidth * drawHeight * 4);
  47579. alpha01 = 1;
  47580. maybeUndoPreblend = true;
  47581. this.fillOpacity(imgData.data, drawWidth, drawHeight, actualHeight, comps);
  47582. }
  47583. if (this.needsDecode) {
  47584. this.decodeBuffer(comps);
  47585. }
  47586. this.colorSpace.fillRgb(imgData.data, originalWidth, originalHeight, drawWidth, drawHeight, actualHeight, bpc, comps, alpha01);
  47587. if (maybeUndoPreblend) {
  47588. this.undoPreblend(imgData.data, drawWidth, actualHeight);
  47589. }
  47590. return imgData;
  47591. },
  47592. fillGrayBuffer: function PDFImage_fillGrayBuffer(buffer) {
  47593. var numComps = this.numComps;
  47594. if (numComps !== 1) {
  47595. error('Reading gray scale from a color image: ' + numComps);
  47596. }
  47597. var width = this.width;
  47598. var height = this.height;
  47599. var bpc = this.bpc;
  47600. var rowBytes = width * numComps * bpc + 7 >> 3;
  47601. var imgArray = this.getImageBytes(height * rowBytes);
  47602. var comps = this.getComponents(imgArray);
  47603. var i, length;
  47604. if (bpc === 1) {
  47605. length = width * height;
  47606. if (this.needsDecode) {
  47607. for (i = 0; i < length; ++i) {
  47608. buffer[i] = comps[i] - 1 & 255;
  47609. }
  47610. } else {
  47611. for (i = 0; i < length; ++i) {
  47612. buffer[i] = -comps[i] & 255;
  47613. }
  47614. }
  47615. return;
  47616. }
  47617. if (this.needsDecode) {
  47618. this.decodeBuffer(comps);
  47619. }
  47620. length = width * height;
  47621. var scale = 255 / ((1 << bpc) - 1);
  47622. for (i = 0; i < length; ++i) {
  47623. buffer[i] = scale * comps[i] | 0;
  47624. }
  47625. },
  47626. getImageBytes: function PDFImage_getImageBytes(length, drawWidth, drawHeight, forceRGB) {
  47627. this.image.reset();
  47628. this.image.drawWidth = drawWidth || this.width;
  47629. this.image.drawHeight = drawHeight || this.height;
  47630. this.image.forceRGB = !!forceRGB;
  47631. return this.image.getBytes(length);
  47632. }
  47633. };
  47634. return PDFImage;
  47635. }();
  47636. exports.PDFImage = PDFImage;
  47637. /***/ }),
  47638. /* 37 */
  47639. /***/ (function(module, exports, __w_pdfjs_require__) {
  47640. "use strict";
  47641. var sharedUtil = __w_pdfjs_require__(0);
  47642. var coreArithmeticDecoder = __w_pdfjs_require__(14);
  47643. var error = sharedUtil.error;
  47644. var log2 = sharedUtil.log2;
  47645. var readInt8 = sharedUtil.readInt8;
  47646. var readUint16 = sharedUtil.readUint16;
  47647. var readUint32 = sharedUtil.readUint32;
  47648. var shadow = sharedUtil.shadow;
  47649. var ArithmeticDecoder = coreArithmeticDecoder.ArithmeticDecoder;
  47650. var Jbig2Image = function Jbig2ImageClosure() {
  47651. function ContextCache() {
  47652. }
  47653. ContextCache.prototype = {
  47654. getContexts: function (id) {
  47655. if (id in this) {
  47656. return this[id];
  47657. }
  47658. return this[id] = new Int8Array(1 << 16);
  47659. }
  47660. };
  47661. function DecodingContext(data, start, end) {
  47662. this.data = data;
  47663. this.start = start;
  47664. this.end = end;
  47665. }
  47666. DecodingContext.prototype = {
  47667. get decoder() {
  47668. var decoder = new ArithmeticDecoder(this.data, this.start, this.end);
  47669. return shadow(this, 'decoder', decoder);
  47670. },
  47671. get contextCache() {
  47672. var cache = new ContextCache();
  47673. return shadow(this, 'contextCache', cache);
  47674. }
  47675. };
  47676. function decodeInteger(contextCache, procedure, decoder) {
  47677. var contexts = contextCache.getContexts(procedure);
  47678. var prev = 1;
  47679. function readBits(length) {
  47680. var v = 0;
  47681. for (var i = 0; i < length; i++) {
  47682. var bit = decoder.readBit(contexts, prev);
  47683. prev = prev < 256 ? prev << 1 | bit : (prev << 1 | bit) & 511 | 256;
  47684. v = v << 1 | bit;
  47685. }
  47686. return v >>> 0;
  47687. }
  47688. var sign = readBits(1);
  47689. 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);
  47690. return sign === 0 ? value : value > 0 ? -value : null;
  47691. }
  47692. function decodeIAID(contextCache, decoder, codeLength) {
  47693. var contexts = contextCache.getContexts('IAID');
  47694. var prev = 1;
  47695. for (var i = 0; i < codeLength; i++) {
  47696. var bit = decoder.readBit(contexts, prev);
  47697. prev = prev << 1 | bit;
  47698. }
  47699. if (codeLength < 31) {
  47700. return prev & (1 << codeLength) - 1;
  47701. }
  47702. return prev & 0x7FFFFFFF;
  47703. }
  47704. var SegmentTypes = [
  47705. 'SymbolDictionary',
  47706. null,
  47707. null,
  47708. null,
  47709. 'IntermediateTextRegion',
  47710. null,
  47711. 'ImmediateTextRegion',
  47712. 'ImmediateLosslessTextRegion',
  47713. null,
  47714. null,
  47715. null,
  47716. null,
  47717. null,
  47718. null,
  47719. null,
  47720. null,
  47721. 'patternDictionary',
  47722. null,
  47723. null,
  47724. null,
  47725. 'IntermediateHalftoneRegion',
  47726. null,
  47727. 'ImmediateHalftoneRegion',
  47728. 'ImmediateLosslessHalftoneRegion',
  47729. null,
  47730. null,
  47731. null,
  47732. null,
  47733. null,
  47734. null,
  47735. null,
  47736. null,
  47737. null,
  47738. null,
  47739. null,
  47740. null,
  47741. 'IntermediateGenericRegion',
  47742. null,
  47743. 'ImmediateGenericRegion',
  47744. 'ImmediateLosslessGenericRegion',
  47745. 'IntermediateGenericRefinementRegion',
  47746. null,
  47747. 'ImmediateGenericRefinementRegion',
  47748. 'ImmediateLosslessGenericRefinementRegion',
  47749. null,
  47750. null,
  47751. null,
  47752. null,
  47753. 'PageInformation',
  47754. 'EndOfPage',
  47755. 'EndOfStripe',
  47756. 'EndOfFile',
  47757. 'Profiles',
  47758. 'Tables',
  47759. null,
  47760. null,
  47761. null,
  47762. null,
  47763. null,
  47764. null,
  47765. null,
  47766. null,
  47767. 'Extension'
  47768. ];
  47769. var CodingTemplates = [
  47770. [
  47771. {
  47772. x: -1,
  47773. y: -2
  47774. },
  47775. {
  47776. x: 0,
  47777. y: -2
  47778. },
  47779. {
  47780. x: 1,
  47781. y: -2
  47782. },
  47783. {
  47784. x: -2,
  47785. y: -1
  47786. },
  47787. {
  47788. x: -1,
  47789. y: -1
  47790. },
  47791. {
  47792. x: 0,
  47793. y: -1
  47794. },
  47795. {
  47796. x: 1,
  47797. y: -1
  47798. },
  47799. {
  47800. x: 2,
  47801. y: -1
  47802. },
  47803. {
  47804. x: -4,
  47805. y: 0
  47806. },
  47807. {
  47808. x: -3,
  47809. y: 0
  47810. },
  47811. {
  47812. x: -2,
  47813. y: 0
  47814. },
  47815. {
  47816. x: -1,
  47817. y: 0
  47818. }
  47819. ],
  47820. [
  47821. {
  47822. x: -1,
  47823. y: -2
  47824. },
  47825. {
  47826. x: 0,
  47827. y: -2
  47828. },
  47829. {
  47830. x: 1,
  47831. y: -2
  47832. },
  47833. {
  47834. x: 2,
  47835. y: -2
  47836. },
  47837. {
  47838. x: -2,
  47839. y: -1
  47840. },
  47841. {
  47842. x: -1,
  47843. y: -1
  47844. },
  47845. {
  47846. x: 0,
  47847. y: -1
  47848. },
  47849. {
  47850. x: 1,
  47851. y: -1
  47852. },
  47853. {
  47854. x: 2,
  47855. y: -1
  47856. },
  47857. {
  47858. x: -3,
  47859. y: 0
  47860. },
  47861. {
  47862. x: -2,
  47863. y: 0
  47864. },
  47865. {
  47866. x: -1,
  47867. y: 0
  47868. }
  47869. ],
  47870. [
  47871. {
  47872. x: -1,
  47873. y: -2
  47874. },
  47875. {
  47876. x: 0,
  47877. y: -2
  47878. },
  47879. {
  47880. x: 1,
  47881. y: -2
  47882. },
  47883. {
  47884. x: -2,
  47885. y: -1
  47886. },
  47887. {
  47888. x: -1,
  47889. y: -1
  47890. },
  47891. {
  47892. x: 0,
  47893. y: -1
  47894. },
  47895. {
  47896. x: 1,
  47897. y: -1
  47898. },
  47899. {
  47900. x: -2,
  47901. y: 0
  47902. },
  47903. {
  47904. x: -1,
  47905. y: 0
  47906. }
  47907. ],
  47908. [
  47909. {
  47910. x: -3,
  47911. y: -1
  47912. },
  47913. {
  47914. x: -2,
  47915. y: -1
  47916. },
  47917. {
  47918. x: -1,
  47919. y: -1
  47920. },
  47921. {
  47922. x: 0,
  47923. y: -1
  47924. },
  47925. {
  47926. x: 1,
  47927. y: -1
  47928. },
  47929. {
  47930. x: -4,
  47931. y: 0
  47932. },
  47933. {
  47934. x: -3,
  47935. y: 0
  47936. },
  47937. {
  47938. x: -2,
  47939. y: 0
  47940. },
  47941. {
  47942. x: -1,
  47943. y: 0
  47944. }
  47945. ]
  47946. ];
  47947. var RefinementTemplates = [
  47948. {
  47949. coding: [
  47950. {
  47951. x: 0,
  47952. y: -1
  47953. },
  47954. {
  47955. x: 1,
  47956. y: -1
  47957. },
  47958. {
  47959. x: -1,
  47960. y: 0
  47961. }
  47962. ],
  47963. reference: [
  47964. {
  47965. x: 0,
  47966. y: -1
  47967. },
  47968. {
  47969. x: 1,
  47970. y: -1
  47971. },
  47972. {
  47973. x: -1,
  47974. y: 0
  47975. },
  47976. {
  47977. x: 0,
  47978. y: 0
  47979. },
  47980. {
  47981. x: 1,
  47982. y: 0
  47983. },
  47984. {
  47985. x: -1,
  47986. y: 1
  47987. },
  47988. {
  47989. x: 0,
  47990. y: 1
  47991. },
  47992. {
  47993. x: 1,
  47994. y: 1
  47995. }
  47996. ]
  47997. },
  47998. {
  47999. coding: [
  48000. {
  48001. x: -1,
  48002. y: -1
  48003. },
  48004. {
  48005. x: 0,
  48006. y: -1
  48007. },
  48008. {
  48009. x: 1,
  48010. y: -1
  48011. },
  48012. {
  48013. x: -1,
  48014. y: 0
  48015. }
  48016. ],
  48017. reference: [
  48018. {
  48019. x: 0,
  48020. y: -1
  48021. },
  48022. {
  48023. x: -1,
  48024. y: 0
  48025. },
  48026. {
  48027. x: 0,
  48028. y: 0
  48029. },
  48030. {
  48031. x: 1,
  48032. y: 0
  48033. },
  48034. {
  48035. x: 0,
  48036. y: 1
  48037. },
  48038. {
  48039. x: 1,
  48040. y: 1
  48041. }
  48042. ]
  48043. }
  48044. ];
  48045. var ReusedContexts = [
  48046. 0x9B25,
  48047. 0x0795,
  48048. 0x00E5,
  48049. 0x0195
  48050. ];
  48051. var RefinementReusedContexts = [
  48052. 0x0020,
  48053. 0x0008
  48054. ];
  48055. function decodeBitmapTemplate0(width, height, decodingContext) {
  48056. var decoder = decodingContext.decoder;
  48057. var contexts = decodingContext.contextCache.getContexts('GB');
  48058. var contextLabel, i, j, pixel, row, row1, row2, bitmap = [];
  48059. var OLD_PIXEL_MASK = 0x7BF7;
  48060. for (i = 0; i < height; i++) {
  48061. row = bitmap[i] = new Uint8Array(width);
  48062. row1 = i < 1 ? row : bitmap[i - 1];
  48063. row2 = i < 2 ? row : bitmap[i - 2];
  48064. contextLabel = row2[0] << 13 | row2[1] << 12 | row2[2] << 11 | row1[0] << 7 | row1[1] << 6 | row1[2] << 5 | row1[3] << 4;
  48065. for (j = 0; j < width; j++) {
  48066. row[j] = pixel = decoder.readBit(contexts, contextLabel);
  48067. contextLabel = (contextLabel & OLD_PIXEL_MASK) << 1 | (j + 3 < width ? row2[j + 3] << 11 : 0) | (j + 4 < width ? row1[j + 4] << 4 : 0) | pixel;
  48068. }
  48069. }
  48070. return bitmap;
  48071. }
  48072. function decodeBitmap(mmr, width, height, templateIndex, prediction, skip, at, decodingContext) {
  48073. if (mmr) {
  48074. error('JBIG2 error: MMR encoding is not supported');
  48075. }
  48076. 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) {
  48077. return decodeBitmapTemplate0(width, height, decodingContext);
  48078. }
  48079. var useskip = !!skip;
  48080. var template = CodingTemplates[templateIndex].concat(at);
  48081. template.sort(function (a, b) {
  48082. return a.y - b.y || a.x - b.x;
  48083. });
  48084. var templateLength = template.length;
  48085. var templateX = new Int8Array(templateLength);
  48086. var templateY = new Int8Array(templateLength);
  48087. var changingTemplateEntries = [];
  48088. var reuseMask = 0, minX = 0, maxX = 0, minY = 0;
  48089. var c, k;
  48090. for (k = 0; k < templateLength; k++) {
  48091. templateX[k] = template[k].x;
  48092. templateY[k] = template[k].y;
  48093. minX = Math.min(minX, template[k].x);
  48094. maxX = Math.max(maxX, template[k].x);
  48095. minY = Math.min(minY, template[k].y);
  48096. if (k < templateLength - 1 && template[k].y === template[k + 1].y && template[k].x === template[k + 1].x - 1) {
  48097. reuseMask |= 1 << templateLength - 1 - k;
  48098. } else {
  48099. changingTemplateEntries.push(k);
  48100. }
  48101. }
  48102. var changingEntriesLength = changingTemplateEntries.length;
  48103. var changingTemplateX = new Int8Array(changingEntriesLength);
  48104. var changingTemplateY = new Int8Array(changingEntriesLength);
  48105. var changingTemplateBit = new Uint16Array(changingEntriesLength);
  48106. for (c = 0; c < changingEntriesLength; c++) {
  48107. k = changingTemplateEntries[c];
  48108. changingTemplateX[c] = template[k].x;
  48109. changingTemplateY[c] = template[k].y;
  48110. changingTemplateBit[c] = 1 << templateLength - 1 - k;
  48111. }
  48112. var sbb_left = -minX;
  48113. var sbb_top = -minY;
  48114. var sbb_right = width - maxX;
  48115. var pseudoPixelContext = ReusedContexts[templateIndex];
  48116. var row = new Uint8Array(width);
  48117. var bitmap = [];
  48118. var decoder = decodingContext.decoder;
  48119. var contexts = decodingContext.contextCache.getContexts('GB');
  48120. var ltp = 0, j, i0, j0, contextLabel = 0, bit, shift;
  48121. for (var i = 0; i < height; i++) {
  48122. if (prediction) {
  48123. var sltp = decoder.readBit(contexts, pseudoPixelContext);
  48124. ltp ^= sltp;
  48125. if (ltp) {
  48126. bitmap.push(row);
  48127. continue;
  48128. }
  48129. }
  48130. row = new Uint8Array(row);
  48131. bitmap.push(row);
  48132. for (j = 0; j < width; j++) {
  48133. if (useskip && skip[i][j]) {
  48134. row[j] = 0;
  48135. continue;
  48136. }
  48137. if (j >= sbb_left && j < sbb_right && i >= sbb_top) {
  48138. contextLabel = contextLabel << 1 & reuseMask;
  48139. for (k = 0; k < changingEntriesLength; k++) {
  48140. i0 = i + changingTemplateY[k];
  48141. j0 = j + changingTemplateX[k];
  48142. bit = bitmap[i0][j0];
  48143. if (bit) {
  48144. bit = changingTemplateBit[k];
  48145. contextLabel |= bit;
  48146. }
  48147. }
  48148. } else {
  48149. contextLabel = 0;
  48150. shift = templateLength - 1;
  48151. for (k = 0; k < templateLength; k++, shift--) {
  48152. j0 = j + templateX[k];
  48153. if (j0 >= 0 && j0 < width) {
  48154. i0 = i + templateY[k];
  48155. if (i0 >= 0) {
  48156. bit = bitmap[i0][j0];
  48157. if (bit) {
  48158. contextLabel |= bit << shift;
  48159. }
  48160. }
  48161. }
  48162. }
  48163. }
  48164. var pixel = decoder.readBit(contexts, contextLabel);
  48165. row[j] = pixel;
  48166. }
  48167. }
  48168. return bitmap;
  48169. }
  48170. function decodeRefinement(width, height, templateIndex, referenceBitmap, offsetX, offsetY, prediction, at, decodingContext) {
  48171. var codingTemplate = RefinementTemplates[templateIndex].coding;
  48172. if (templateIndex === 0) {
  48173. codingTemplate = codingTemplate.concat([at[0]]);
  48174. }
  48175. var codingTemplateLength = codingTemplate.length;
  48176. var codingTemplateX = new Int32Array(codingTemplateLength);
  48177. var codingTemplateY = new Int32Array(codingTemplateLength);
  48178. var k;
  48179. for (k = 0; k < codingTemplateLength; k++) {
  48180. codingTemplateX[k] = codingTemplate[k].x;
  48181. codingTemplateY[k] = codingTemplate[k].y;
  48182. }
  48183. var referenceTemplate = RefinementTemplates[templateIndex].reference;
  48184. if (templateIndex === 0) {
  48185. referenceTemplate = referenceTemplate.concat([at[1]]);
  48186. }
  48187. var referenceTemplateLength = referenceTemplate.length;
  48188. var referenceTemplateX = new Int32Array(referenceTemplateLength);
  48189. var referenceTemplateY = new Int32Array(referenceTemplateLength);
  48190. for (k = 0; k < referenceTemplateLength; k++) {
  48191. referenceTemplateX[k] = referenceTemplate[k].x;
  48192. referenceTemplateY[k] = referenceTemplate[k].y;
  48193. }
  48194. var referenceWidth = referenceBitmap[0].length;
  48195. var referenceHeight = referenceBitmap.length;
  48196. var pseudoPixelContext = RefinementReusedContexts[templateIndex];
  48197. var bitmap = [];
  48198. var decoder = decodingContext.decoder;
  48199. var contexts = decodingContext.contextCache.getContexts('GR');
  48200. var ltp = 0;
  48201. for (var i = 0; i < height; i++) {
  48202. if (prediction) {
  48203. var sltp = decoder.readBit(contexts, pseudoPixelContext);
  48204. ltp ^= sltp;
  48205. if (ltp) {
  48206. error('JBIG2 error: prediction is not supported');
  48207. }
  48208. }
  48209. var row = new Uint8Array(width);
  48210. bitmap.push(row);
  48211. for (var j = 0; j < width; j++) {
  48212. var i0, j0;
  48213. var contextLabel = 0;
  48214. for (k = 0; k < codingTemplateLength; k++) {
  48215. i0 = i + codingTemplateY[k];
  48216. j0 = j + codingTemplateX[k];
  48217. if (i0 < 0 || j0 < 0 || j0 >= width) {
  48218. contextLabel <<= 1;
  48219. } else {
  48220. contextLabel = contextLabel << 1 | bitmap[i0][j0];
  48221. }
  48222. }
  48223. for (k = 0; k < referenceTemplateLength; k++) {
  48224. i0 = i + referenceTemplateY[k] + offsetY;
  48225. j0 = j + referenceTemplateX[k] + offsetX;
  48226. if (i0 < 0 || i0 >= referenceHeight || j0 < 0 || j0 >= referenceWidth) {
  48227. contextLabel <<= 1;
  48228. } else {
  48229. contextLabel = contextLabel << 1 | referenceBitmap[i0][j0];
  48230. }
  48231. }
  48232. var pixel = decoder.readBit(contexts, contextLabel);
  48233. row[j] = pixel;
  48234. }
  48235. }
  48236. return bitmap;
  48237. }
  48238. function decodeSymbolDictionary(huffman, refinement, symbols, numberOfNewSymbols, numberOfExportedSymbols, huffmanTables, templateIndex, at, refinementTemplateIndex, refinementAt, decodingContext) {
  48239. if (huffman) {
  48240. error('JBIG2 error: huffman is not supported');
  48241. }
  48242. var newSymbols = [];
  48243. var currentHeight = 0;
  48244. var symbolCodeLength = log2(symbols.length + numberOfNewSymbols);
  48245. var decoder = decodingContext.decoder;
  48246. var contextCache = decodingContext.contextCache;
  48247. while (newSymbols.length < numberOfNewSymbols) {
  48248. var deltaHeight = decodeInteger(contextCache, 'IADH', decoder);
  48249. currentHeight += deltaHeight;
  48250. var currentWidth = 0;
  48251. while (true) {
  48252. var deltaWidth = decodeInteger(contextCache, 'IADW', decoder);
  48253. if (deltaWidth === null) {
  48254. break;
  48255. }
  48256. currentWidth += deltaWidth;
  48257. var bitmap;
  48258. if (refinement) {
  48259. var numberOfInstances = decodeInteger(contextCache, 'IAAI', decoder);
  48260. if (numberOfInstances > 1) {
  48261. bitmap = decodeTextRegion(huffman, refinement, currentWidth, currentHeight, 0, numberOfInstances, 1, symbols.concat(newSymbols), symbolCodeLength, 0, 0, 1, 0, huffmanTables, refinementTemplateIndex, refinementAt, decodingContext);
  48262. } else {
  48263. var symbolId = decodeIAID(contextCache, decoder, symbolCodeLength);
  48264. var rdx = decodeInteger(contextCache, 'IARDX', decoder);
  48265. var rdy = decodeInteger(contextCache, 'IARDY', decoder);
  48266. var symbol = symbolId < symbols.length ? symbols[symbolId] : newSymbols[symbolId - symbols.length];
  48267. bitmap = decodeRefinement(currentWidth, currentHeight, refinementTemplateIndex, symbol, rdx, rdy, false, refinementAt, decodingContext);
  48268. }
  48269. } else {
  48270. bitmap = decodeBitmap(false, currentWidth, currentHeight, templateIndex, false, null, at, decodingContext);
  48271. }
  48272. newSymbols.push(bitmap);
  48273. }
  48274. }
  48275. var exportedSymbols = [];
  48276. var flags = [], currentFlag = false;
  48277. var totalSymbolsLength = symbols.length + numberOfNewSymbols;
  48278. while (flags.length < totalSymbolsLength) {
  48279. var runLength = decodeInteger(contextCache, 'IAEX', decoder);
  48280. while (runLength--) {
  48281. flags.push(currentFlag);
  48282. }
  48283. currentFlag = !currentFlag;
  48284. }
  48285. for (var i = 0, ii = symbols.length; i < ii; i++) {
  48286. if (flags[i]) {
  48287. exportedSymbols.push(symbols[i]);
  48288. }
  48289. }
  48290. for (var j = 0; j < numberOfNewSymbols; i++, j++) {
  48291. if (flags[i]) {
  48292. exportedSymbols.push(newSymbols[j]);
  48293. }
  48294. }
  48295. return exportedSymbols;
  48296. }
  48297. function decodeTextRegion(huffman, refinement, width, height, defaultPixelValue, numberOfSymbolInstances, stripSize, inputSymbols, symbolCodeLength, transposed, dsOffset, referenceCorner, combinationOperator, huffmanTables, refinementTemplateIndex, refinementAt, decodingContext) {
  48298. if (huffman) {
  48299. error('JBIG2 error: huffman is not supported');
  48300. }
  48301. var bitmap = [];
  48302. var i, row;
  48303. for (i = 0; i < height; i++) {
  48304. row = new Uint8Array(width);
  48305. if (defaultPixelValue) {
  48306. for (var j = 0; j < width; j++) {
  48307. row[j] = defaultPixelValue;
  48308. }
  48309. }
  48310. bitmap.push(row);
  48311. }
  48312. var decoder = decodingContext.decoder;
  48313. var contextCache = decodingContext.contextCache;
  48314. var stripT = -decodeInteger(contextCache, 'IADT', decoder);
  48315. var firstS = 0;
  48316. i = 0;
  48317. while (i < numberOfSymbolInstances) {
  48318. var deltaT = decodeInteger(contextCache, 'IADT', decoder);
  48319. stripT += deltaT;
  48320. var deltaFirstS = decodeInteger(contextCache, 'IAFS', decoder);
  48321. firstS += deltaFirstS;
  48322. var currentS = firstS;
  48323. do {
  48324. var currentT = stripSize === 1 ? 0 : decodeInteger(contextCache, 'IAIT', decoder);
  48325. var t = stripSize * stripT + currentT;
  48326. var symbolId = decodeIAID(contextCache, decoder, symbolCodeLength);
  48327. var applyRefinement = refinement && decodeInteger(contextCache, 'IARI', decoder);
  48328. var symbolBitmap = inputSymbols[symbolId];
  48329. var symbolWidth = symbolBitmap[0].length;
  48330. var symbolHeight = symbolBitmap.length;
  48331. if (applyRefinement) {
  48332. var rdw = decodeInteger(contextCache, 'IARDW', decoder);
  48333. var rdh = decodeInteger(contextCache, 'IARDH', decoder);
  48334. var rdx = decodeInteger(contextCache, 'IARDX', decoder);
  48335. var rdy = decodeInteger(contextCache, 'IARDY', decoder);
  48336. symbolWidth += rdw;
  48337. symbolHeight += rdh;
  48338. symbolBitmap = decodeRefinement(symbolWidth, symbolHeight, refinementTemplateIndex, symbolBitmap, (rdw >> 1) + rdx, (rdh >> 1) + rdy, false, refinementAt, decodingContext);
  48339. }
  48340. var offsetT = t - (referenceCorner & 1 ? 0 : symbolHeight);
  48341. var offsetS = currentS - (referenceCorner & 2 ? symbolWidth : 0);
  48342. var s2, t2, symbolRow;
  48343. if (transposed) {
  48344. for (s2 = 0; s2 < symbolHeight; s2++) {
  48345. row = bitmap[offsetS + s2];
  48346. if (!row) {
  48347. continue;
  48348. }
  48349. symbolRow = symbolBitmap[s2];
  48350. var maxWidth = Math.min(width - offsetT, symbolWidth);
  48351. switch (combinationOperator) {
  48352. case 0:
  48353. for (t2 = 0; t2 < maxWidth; t2++) {
  48354. row[offsetT + t2] |= symbolRow[t2];
  48355. }
  48356. break;
  48357. case 2:
  48358. for (t2 = 0; t2 < maxWidth; t2++) {
  48359. row[offsetT + t2] ^= symbolRow[t2];
  48360. }
  48361. break;
  48362. default:
  48363. error('JBIG2 error: operator ' + combinationOperator + ' is not supported');
  48364. }
  48365. }
  48366. currentS += symbolHeight - 1;
  48367. } else {
  48368. for (t2 = 0; t2 < symbolHeight; t2++) {
  48369. row = bitmap[offsetT + t2];
  48370. if (!row) {
  48371. continue;
  48372. }
  48373. symbolRow = symbolBitmap[t2];
  48374. switch (combinationOperator) {
  48375. case 0:
  48376. for (s2 = 0; s2 < symbolWidth; s2++) {
  48377. row[offsetS + s2] |= symbolRow[s2];
  48378. }
  48379. break;
  48380. case 2:
  48381. for (s2 = 0; s2 < symbolWidth; s2++) {
  48382. row[offsetS + s2] ^= symbolRow[s2];
  48383. }
  48384. break;
  48385. default:
  48386. error('JBIG2 error: operator ' + combinationOperator + ' is not supported');
  48387. }
  48388. }
  48389. currentS += symbolWidth - 1;
  48390. }
  48391. i++;
  48392. var deltaS = decodeInteger(contextCache, 'IADS', decoder);
  48393. if (deltaS === null) {
  48394. break;
  48395. }
  48396. currentS += deltaS + dsOffset;
  48397. } while (true);
  48398. }
  48399. return bitmap;
  48400. }
  48401. function readSegmentHeader(data, start) {
  48402. var segmentHeader = {};
  48403. segmentHeader.number = readUint32(data, start);
  48404. var flags = data[start + 4];
  48405. var segmentType = flags & 0x3F;
  48406. if (!SegmentTypes[segmentType]) {
  48407. error('JBIG2 error: invalid segment type: ' + segmentType);
  48408. }
  48409. segmentHeader.type = segmentType;
  48410. segmentHeader.typeName = SegmentTypes[segmentType];
  48411. segmentHeader.deferredNonRetain = !!(flags & 0x80);
  48412. var pageAssociationFieldSize = !!(flags & 0x40);
  48413. var referredFlags = data[start + 5];
  48414. var referredToCount = referredFlags >> 5 & 7;
  48415. var retainBits = [referredFlags & 31];
  48416. var position = start + 6;
  48417. if (referredFlags === 7) {
  48418. referredToCount = readUint32(data, position - 1) & 0x1FFFFFFF;
  48419. position += 3;
  48420. var bytes = referredToCount + 7 >> 3;
  48421. retainBits[0] = data[position++];
  48422. while (--bytes > 0) {
  48423. retainBits.push(data[position++]);
  48424. }
  48425. } else if (referredFlags === 5 || referredFlags === 6) {
  48426. error('JBIG2 error: invalid referred-to flags');
  48427. }
  48428. segmentHeader.retainBits = retainBits;
  48429. var referredToSegmentNumberSize = segmentHeader.number <= 256 ? 1 : segmentHeader.number <= 65536 ? 2 : 4;
  48430. var referredTo = [];
  48431. var i, ii;
  48432. for (i = 0; i < referredToCount; i++) {
  48433. var number = referredToSegmentNumberSize === 1 ? data[position] : referredToSegmentNumberSize === 2 ? readUint16(data, position) : readUint32(data, position);
  48434. referredTo.push(number);
  48435. position += referredToSegmentNumberSize;
  48436. }
  48437. segmentHeader.referredTo = referredTo;
  48438. if (!pageAssociationFieldSize) {
  48439. segmentHeader.pageAssociation = data[position++];
  48440. } else {
  48441. segmentHeader.pageAssociation = readUint32(data, position);
  48442. position += 4;
  48443. }
  48444. segmentHeader.length = readUint32(data, position);
  48445. position += 4;
  48446. if (segmentHeader.length === 0xFFFFFFFF) {
  48447. if (segmentType === 38) {
  48448. var genericRegionInfo = readRegionSegmentInformation(data, position);
  48449. var genericRegionSegmentFlags = data[position + RegionSegmentInformationFieldLength];
  48450. var genericRegionMmr = !!(genericRegionSegmentFlags & 1);
  48451. var searchPatternLength = 6;
  48452. var searchPattern = new Uint8Array(searchPatternLength);
  48453. if (!genericRegionMmr) {
  48454. searchPattern[0] = 0xFF;
  48455. searchPattern[1] = 0xAC;
  48456. }
  48457. searchPattern[2] = genericRegionInfo.height >>> 24 & 0xFF;
  48458. searchPattern[3] = genericRegionInfo.height >> 16 & 0xFF;
  48459. searchPattern[4] = genericRegionInfo.height >> 8 & 0xFF;
  48460. searchPattern[5] = genericRegionInfo.height & 0xFF;
  48461. for (i = position, ii = data.length; i < ii; i++) {
  48462. var j = 0;
  48463. while (j < searchPatternLength && searchPattern[j] === data[i + j]) {
  48464. j++;
  48465. }
  48466. if (j === searchPatternLength) {
  48467. segmentHeader.length = i + searchPatternLength;
  48468. break;
  48469. }
  48470. }
  48471. if (segmentHeader.length === 0xFFFFFFFF) {
  48472. error('JBIG2 error: segment end was not found');
  48473. }
  48474. } else {
  48475. error('JBIG2 error: invalid unknown segment length');
  48476. }
  48477. }
  48478. segmentHeader.headerEnd = position;
  48479. return segmentHeader;
  48480. }
  48481. function readSegments(header, data, start, end) {
  48482. var segments = [];
  48483. var position = start;
  48484. while (position < end) {
  48485. var segmentHeader = readSegmentHeader(data, position);
  48486. position = segmentHeader.headerEnd;
  48487. var segment = {
  48488. header: segmentHeader,
  48489. data: data
  48490. };
  48491. if (!header.randomAccess) {
  48492. segment.start = position;
  48493. position += segmentHeader.length;
  48494. segment.end = position;
  48495. }
  48496. segments.push(segment);
  48497. if (segmentHeader.type === 51) {
  48498. break;
  48499. }
  48500. }
  48501. if (header.randomAccess) {
  48502. for (var i = 0, ii = segments.length; i < ii; i++) {
  48503. segments[i].start = position;
  48504. position += segments[i].header.length;
  48505. segments[i].end = position;
  48506. }
  48507. }
  48508. return segments;
  48509. }
  48510. function readRegionSegmentInformation(data, start) {
  48511. return {
  48512. width: readUint32(data, start),
  48513. height: readUint32(data, start + 4),
  48514. x: readUint32(data, start + 8),
  48515. y: readUint32(data, start + 12),
  48516. combinationOperator: data[start + 16] & 7
  48517. };
  48518. }
  48519. var RegionSegmentInformationFieldLength = 17;
  48520. function processSegment(segment, visitor) {
  48521. var header = segment.header;
  48522. var data = segment.data, position = segment.start, end = segment.end;
  48523. var args, at, i, atLength;
  48524. switch (header.type) {
  48525. case 0:
  48526. var dictionary = {};
  48527. var dictionaryFlags = readUint16(data, position);
  48528. dictionary.huffman = !!(dictionaryFlags & 1);
  48529. dictionary.refinement = !!(dictionaryFlags & 2);
  48530. dictionary.huffmanDHSelector = dictionaryFlags >> 2 & 3;
  48531. dictionary.huffmanDWSelector = dictionaryFlags >> 4 & 3;
  48532. dictionary.bitmapSizeSelector = dictionaryFlags >> 6 & 1;
  48533. dictionary.aggregationInstancesSelector = dictionaryFlags >> 7 & 1;
  48534. dictionary.bitmapCodingContextUsed = !!(dictionaryFlags & 256);
  48535. dictionary.bitmapCodingContextRetained = !!(dictionaryFlags & 512);
  48536. dictionary.template = dictionaryFlags >> 10 & 3;
  48537. dictionary.refinementTemplate = dictionaryFlags >> 12 & 1;
  48538. position += 2;
  48539. if (!dictionary.huffman) {
  48540. atLength = dictionary.template === 0 ? 4 : 1;
  48541. at = [];
  48542. for (i = 0; i < atLength; i++) {
  48543. at.push({
  48544. x: readInt8(data, position),
  48545. y: readInt8(data, position + 1)
  48546. });
  48547. position += 2;
  48548. }
  48549. dictionary.at = at;
  48550. }
  48551. if (dictionary.refinement && !dictionary.refinementTemplate) {
  48552. at = [];
  48553. for (i = 0; i < 2; i++) {
  48554. at.push({
  48555. x: readInt8(data, position),
  48556. y: readInt8(data, position + 1)
  48557. });
  48558. position += 2;
  48559. }
  48560. dictionary.refinementAt = at;
  48561. }
  48562. dictionary.numberOfExportedSymbols = readUint32(data, position);
  48563. position += 4;
  48564. dictionary.numberOfNewSymbols = readUint32(data, position);
  48565. position += 4;
  48566. args = [
  48567. dictionary,
  48568. header.number,
  48569. header.referredTo,
  48570. data,
  48571. position,
  48572. end
  48573. ];
  48574. break;
  48575. case 6:
  48576. case 7:
  48577. var textRegion = {};
  48578. textRegion.info = readRegionSegmentInformation(data, position);
  48579. position += RegionSegmentInformationFieldLength;
  48580. var textRegionSegmentFlags = readUint16(data, position);
  48581. position += 2;
  48582. textRegion.huffman = !!(textRegionSegmentFlags & 1);
  48583. textRegion.refinement = !!(textRegionSegmentFlags & 2);
  48584. textRegion.stripSize = 1 << (textRegionSegmentFlags >> 2 & 3);
  48585. textRegion.referenceCorner = textRegionSegmentFlags >> 4 & 3;
  48586. textRegion.transposed = !!(textRegionSegmentFlags & 64);
  48587. textRegion.combinationOperator = textRegionSegmentFlags >> 7 & 3;
  48588. textRegion.defaultPixelValue = textRegionSegmentFlags >> 9 & 1;
  48589. textRegion.dsOffset = textRegionSegmentFlags << 17 >> 27;
  48590. textRegion.refinementTemplate = textRegionSegmentFlags >> 15 & 1;
  48591. if (textRegion.huffman) {
  48592. var textRegionHuffmanFlags = readUint16(data, position);
  48593. position += 2;
  48594. textRegion.huffmanFS = textRegionHuffmanFlags & 3;
  48595. textRegion.huffmanDS = textRegionHuffmanFlags >> 2 & 3;
  48596. textRegion.huffmanDT = textRegionHuffmanFlags >> 4 & 3;
  48597. textRegion.huffmanRefinementDW = textRegionHuffmanFlags >> 6 & 3;
  48598. textRegion.huffmanRefinementDH = textRegionHuffmanFlags >> 8 & 3;
  48599. textRegion.huffmanRefinementDX = textRegionHuffmanFlags >> 10 & 3;
  48600. textRegion.huffmanRefinementDY = textRegionHuffmanFlags >> 12 & 3;
  48601. textRegion.huffmanRefinementSizeSelector = !!(textRegionHuffmanFlags & 14);
  48602. }
  48603. if (textRegion.refinement && !textRegion.refinementTemplate) {
  48604. at = [];
  48605. for (i = 0; i < 2; i++) {
  48606. at.push({
  48607. x: readInt8(data, position),
  48608. y: readInt8(data, position + 1)
  48609. });
  48610. position += 2;
  48611. }
  48612. textRegion.refinementAt = at;
  48613. }
  48614. textRegion.numberOfSymbolInstances = readUint32(data, position);
  48615. position += 4;
  48616. if (textRegion.huffman) {
  48617. error('JBIG2 error: huffman is not supported');
  48618. }
  48619. args = [
  48620. textRegion,
  48621. header.referredTo,
  48622. data,
  48623. position,
  48624. end
  48625. ];
  48626. break;
  48627. case 38:
  48628. case 39:
  48629. var genericRegion = {};
  48630. genericRegion.info = readRegionSegmentInformation(data, position);
  48631. position += RegionSegmentInformationFieldLength;
  48632. var genericRegionSegmentFlags = data[position++];
  48633. genericRegion.mmr = !!(genericRegionSegmentFlags & 1);
  48634. genericRegion.template = genericRegionSegmentFlags >> 1 & 3;
  48635. genericRegion.prediction = !!(genericRegionSegmentFlags & 8);
  48636. if (!genericRegion.mmr) {
  48637. atLength = genericRegion.template === 0 ? 4 : 1;
  48638. at = [];
  48639. for (i = 0; i < atLength; i++) {
  48640. at.push({
  48641. x: readInt8(data, position),
  48642. y: readInt8(data, position + 1)
  48643. });
  48644. position += 2;
  48645. }
  48646. genericRegion.at = at;
  48647. }
  48648. args = [
  48649. genericRegion,
  48650. data,
  48651. position,
  48652. end
  48653. ];
  48654. break;
  48655. case 48:
  48656. var pageInfo = {
  48657. width: readUint32(data, position),
  48658. height: readUint32(data, position + 4),
  48659. resolutionX: readUint32(data, position + 8),
  48660. resolutionY: readUint32(data, position + 12)
  48661. };
  48662. if (pageInfo.height === 0xFFFFFFFF) {
  48663. delete pageInfo.height;
  48664. }
  48665. var pageSegmentFlags = data[position + 16];
  48666. readUint16(data, position + 17);
  48667. pageInfo.lossless = !!(pageSegmentFlags & 1);
  48668. pageInfo.refinement = !!(pageSegmentFlags & 2);
  48669. pageInfo.defaultPixelValue = pageSegmentFlags >> 2 & 1;
  48670. pageInfo.combinationOperator = pageSegmentFlags >> 3 & 3;
  48671. pageInfo.requiresBuffer = !!(pageSegmentFlags & 32);
  48672. pageInfo.combinationOperatorOverride = !!(pageSegmentFlags & 64);
  48673. args = [pageInfo];
  48674. break;
  48675. case 49:
  48676. break;
  48677. case 50:
  48678. break;
  48679. case 51:
  48680. break;
  48681. case 62:
  48682. break;
  48683. default:
  48684. error('JBIG2 error: segment type ' + header.typeName + '(' + header.type + ') is not implemented');
  48685. }
  48686. var callbackName = 'on' + header.typeName;
  48687. if (callbackName in visitor) {
  48688. visitor[callbackName].apply(visitor, args);
  48689. }
  48690. }
  48691. function processSegments(segments, visitor) {
  48692. for (var i = 0, ii = segments.length; i < ii; i++) {
  48693. processSegment(segments[i], visitor);
  48694. }
  48695. }
  48696. function parseJbig2(data, start, end) {
  48697. var position = start;
  48698. 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) {
  48699. error('JBIG2 error: invalid header');
  48700. }
  48701. var header = {};
  48702. position += 8;
  48703. var flags = data[position++];
  48704. header.randomAccess = !(flags & 1);
  48705. if (!(flags & 2)) {
  48706. header.numberOfPages = readUint32(data, position);
  48707. position += 4;
  48708. }
  48709. readSegments(header, data, position, end);
  48710. error('Not implemented');
  48711. }
  48712. function parseJbig2Chunks(chunks) {
  48713. var visitor = new SimpleSegmentVisitor();
  48714. for (var i = 0, ii = chunks.length; i < ii; i++) {
  48715. var chunk = chunks[i];
  48716. var segments = readSegments({}, chunk.data, chunk.start, chunk.end);
  48717. processSegments(segments, visitor);
  48718. }
  48719. return visitor.buffer;
  48720. }
  48721. function SimpleSegmentVisitor() {
  48722. }
  48723. SimpleSegmentVisitor.prototype = {
  48724. onPageInformation: function SimpleSegmentVisitor_onPageInformation(info) {
  48725. this.currentPageInfo = info;
  48726. var rowSize = info.width + 7 >> 3;
  48727. var buffer = new Uint8Array(rowSize * info.height);
  48728. if (info.defaultPixelValue) {
  48729. for (var i = 0, ii = buffer.length; i < ii; i++) {
  48730. buffer[i] = 0xFF;
  48731. }
  48732. }
  48733. this.buffer = buffer;
  48734. },
  48735. drawBitmap: function SimpleSegmentVisitor_drawBitmap(regionInfo, bitmap) {
  48736. var pageInfo = this.currentPageInfo;
  48737. var width = regionInfo.width, height = regionInfo.height;
  48738. var rowSize = pageInfo.width + 7 >> 3;
  48739. var combinationOperator = pageInfo.combinationOperatorOverride ? regionInfo.combinationOperator : pageInfo.combinationOperator;
  48740. var buffer = this.buffer;
  48741. var mask0 = 128 >> (regionInfo.x & 7);
  48742. var offset0 = regionInfo.y * rowSize + (regionInfo.x >> 3);
  48743. var i, j, mask, offset;
  48744. switch (combinationOperator) {
  48745. case 0:
  48746. for (i = 0; i < height; i++) {
  48747. mask = mask0;
  48748. offset = offset0;
  48749. for (j = 0; j < width; j++) {
  48750. if (bitmap[i][j]) {
  48751. buffer[offset] |= mask;
  48752. }
  48753. mask >>= 1;
  48754. if (!mask) {
  48755. mask = 128;
  48756. offset++;
  48757. }
  48758. }
  48759. offset0 += rowSize;
  48760. }
  48761. break;
  48762. case 2:
  48763. for (i = 0; i < height; i++) {
  48764. mask = mask0;
  48765. offset = offset0;
  48766. for (j = 0; j < width; j++) {
  48767. if (bitmap[i][j]) {
  48768. buffer[offset] ^= mask;
  48769. }
  48770. mask >>= 1;
  48771. if (!mask) {
  48772. mask = 128;
  48773. offset++;
  48774. }
  48775. }
  48776. offset0 += rowSize;
  48777. }
  48778. break;
  48779. default:
  48780. error('JBIG2 error: operator ' + combinationOperator + ' is not supported');
  48781. }
  48782. },
  48783. onImmediateGenericRegion: function SimpleSegmentVisitor_onImmediateGenericRegion(region, data, start, end) {
  48784. var regionInfo = region.info;
  48785. var decodingContext = new DecodingContext(data, start, end);
  48786. var bitmap = decodeBitmap(region.mmr, regionInfo.width, regionInfo.height, region.template, region.prediction, null, region.at, decodingContext);
  48787. this.drawBitmap(regionInfo, bitmap);
  48788. },
  48789. onImmediateLosslessGenericRegion: function SimpleSegmentVisitor_onImmediateLosslessGenericRegion() {
  48790. this.onImmediateGenericRegion.apply(this, arguments);
  48791. },
  48792. onSymbolDictionary: function SimpleSegmentVisitor_onSymbolDictionary(dictionary, currentSegment, referredSegments, data, start, end) {
  48793. var huffmanTables;
  48794. if (dictionary.huffman) {
  48795. error('JBIG2 error: huffman is not supported');
  48796. }
  48797. var symbols = this.symbols;
  48798. if (!symbols) {
  48799. this.symbols = symbols = {};
  48800. }
  48801. var inputSymbols = [];
  48802. for (var i = 0, ii = referredSegments.length; i < ii; i++) {
  48803. inputSymbols = inputSymbols.concat(symbols[referredSegments[i]]);
  48804. }
  48805. var decodingContext = new DecodingContext(data, start, end);
  48806. symbols[currentSegment] = decodeSymbolDictionary(dictionary.huffman, dictionary.refinement, inputSymbols, dictionary.numberOfNewSymbols, dictionary.numberOfExportedSymbols, huffmanTables, dictionary.template, dictionary.at, dictionary.refinementTemplate, dictionary.refinementAt, decodingContext);
  48807. },
  48808. onImmediateTextRegion: function SimpleSegmentVisitor_onImmediateTextRegion(region, referredSegments, data, start, end) {
  48809. var regionInfo = region.info;
  48810. var huffmanTables;
  48811. var symbols = this.symbols;
  48812. var inputSymbols = [];
  48813. for (var i = 0, ii = referredSegments.length; i < ii; i++) {
  48814. inputSymbols = inputSymbols.concat(symbols[referredSegments[i]]);
  48815. }
  48816. var symbolCodeLength = log2(inputSymbols.length);
  48817. var decodingContext = new DecodingContext(data, start, end);
  48818. 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);
  48819. this.drawBitmap(regionInfo, bitmap);
  48820. },
  48821. onImmediateLosslessTextRegion: function SimpleSegmentVisitor_onImmediateLosslessTextRegion() {
  48822. this.onImmediateTextRegion.apply(this, arguments);
  48823. }
  48824. };
  48825. function Jbig2Image() {
  48826. }
  48827. Jbig2Image.prototype = {
  48828. parseChunks: function Jbig2Image_parseChunks(chunks) {
  48829. return parseJbig2Chunks(chunks);
  48830. }
  48831. };
  48832. return Jbig2Image;
  48833. }();
  48834. exports.Jbig2Image = Jbig2Image;
  48835. /***/ }),
  48836. /* 38 */
  48837. /***/ (function(module, exports, __w_pdfjs_require__) {
  48838. "use strict";
  48839. var sharedUtil = __w_pdfjs_require__(0);
  48840. var error = sharedUtil.error;
  48841. var JpegImage = function JpegImageClosure() {
  48842. var dctZigZag = new Uint8Array([
  48843. 0,
  48844. 1,
  48845. 8,
  48846. 16,
  48847. 9,
  48848. 2,
  48849. 3,
  48850. 10,
  48851. 17,
  48852. 24,
  48853. 32,
  48854. 25,
  48855. 18,
  48856. 11,
  48857. 4,
  48858. 5,
  48859. 12,
  48860. 19,
  48861. 26,
  48862. 33,
  48863. 40,
  48864. 48,
  48865. 41,
  48866. 34,
  48867. 27,
  48868. 20,
  48869. 13,
  48870. 6,
  48871. 7,
  48872. 14,
  48873. 21,
  48874. 28,
  48875. 35,
  48876. 42,
  48877. 49,
  48878. 56,
  48879. 57,
  48880. 50,
  48881. 43,
  48882. 36,
  48883. 29,
  48884. 22,
  48885. 15,
  48886. 23,
  48887. 30,
  48888. 37,
  48889. 44,
  48890. 51,
  48891. 58,
  48892. 59,
  48893. 52,
  48894. 45,
  48895. 38,
  48896. 31,
  48897. 39,
  48898. 46,
  48899. 53,
  48900. 60,
  48901. 61,
  48902. 54,
  48903. 47,
  48904. 55,
  48905. 62,
  48906. 63
  48907. ]);
  48908. var dctCos1 = 4017;
  48909. var dctSin1 = 799;
  48910. var dctCos3 = 3406;
  48911. var dctSin3 = 2276;
  48912. var dctCos6 = 1567;
  48913. var dctSin6 = 3784;
  48914. var dctSqrt2 = 5793;
  48915. var dctSqrt1d2 = 2896;
  48916. function JpegImage() {
  48917. this.decodeTransform = null;
  48918. this.colorTransform = -1;
  48919. }
  48920. function buildHuffmanTable(codeLengths, values) {
  48921. var k = 0, code = [], i, j, length = 16;
  48922. while (length > 0 && !codeLengths[length - 1]) {
  48923. length--;
  48924. }
  48925. code.push({
  48926. children: [],
  48927. index: 0
  48928. });
  48929. var p = code[0], q;
  48930. for (i = 0; i < length; i++) {
  48931. for (j = 0; j < codeLengths[i]; j++) {
  48932. p = code.pop();
  48933. p.children[p.index] = values[k];
  48934. while (p.index > 0) {
  48935. p = code.pop();
  48936. }
  48937. p.index++;
  48938. code.push(p);
  48939. while (code.length <= i) {
  48940. code.push(q = {
  48941. children: [],
  48942. index: 0
  48943. });
  48944. p.children[p.index] = q.children;
  48945. p = q;
  48946. }
  48947. k++;
  48948. }
  48949. if (i + 1 < length) {
  48950. code.push(q = {
  48951. children: [],
  48952. index: 0
  48953. });
  48954. p.children[p.index] = q.children;
  48955. p = q;
  48956. }
  48957. }
  48958. return code[0].children;
  48959. }
  48960. function getBlockBufferOffset(component, row, col) {
  48961. return 64 * ((component.blocksPerLine + 1) * row + col);
  48962. }
  48963. function decodeScan(data, offset, frame, components, resetInterval, spectralStart, spectralEnd, successivePrev, successive) {
  48964. var mcusPerLine = frame.mcusPerLine;
  48965. var progressive = frame.progressive;
  48966. var startOffset = offset, bitsData = 0, bitsCount = 0;
  48967. function readBit() {
  48968. if (bitsCount > 0) {
  48969. bitsCount--;
  48970. return bitsData >> bitsCount & 1;
  48971. }
  48972. bitsData = data[offset++];
  48973. if (bitsData === 0xFF) {
  48974. var nextByte = data[offset++];
  48975. if (nextByte) {
  48976. error('JPEG error: unexpected marker ' + (bitsData << 8 | nextByte).toString(16));
  48977. }
  48978. }
  48979. bitsCount = 7;
  48980. return bitsData >>> 7;
  48981. }
  48982. function decodeHuffman(tree) {
  48983. var node = tree;
  48984. while (true) {
  48985. node = node[readBit()];
  48986. if (typeof node === 'number') {
  48987. return node;
  48988. }
  48989. if (typeof node !== 'object') {
  48990. error('JPEG error: invalid huffman sequence');
  48991. }
  48992. }
  48993. }
  48994. function receive(length) {
  48995. var n = 0;
  48996. while (length > 0) {
  48997. n = n << 1 | readBit();
  48998. length--;
  48999. }
  49000. return n;
  49001. }
  49002. function receiveAndExtend(length) {
  49003. if (length === 1) {
  49004. return readBit() === 1 ? 1 : -1;
  49005. }
  49006. var n = receive(length);
  49007. if (n >= 1 << length - 1) {
  49008. return n;
  49009. }
  49010. return n + (-1 << length) + 1;
  49011. }
  49012. function decodeBaseline(component, offset) {
  49013. var t = decodeHuffman(component.huffmanTableDC);
  49014. var diff = t === 0 ? 0 : receiveAndExtend(t);
  49015. component.blockData[offset] = component.pred += diff;
  49016. var k = 1;
  49017. while (k < 64) {
  49018. var rs = decodeHuffman(component.huffmanTableAC);
  49019. var s = rs & 15, r = rs >> 4;
  49020. if (s === 0) {
  49021. if (r < 15) {
  49022. break;
  49023. }
  49024. k += 16;
  49025. continue;
  49026. }
  49027. k += r;
  49028. var z = dctZigZag[k];
  49029. component.blockData[offset + z] = receiveAndExtend(s);
  49030. k++;
  49031. }
  49032. }
  49033. function decodeDCFirst(component, offset) {
  49034. var t = decodeHuffman(component.huffmanTableDC);
  49035. var diff = t === 0 ? 0 : receiveAndExtend(t) << successive;
  49036. component.blockData[offset] = component.pred += diff;
  49037. }
  49038. function decodeDCSuccessive(component, offset) {
  49039. component.blockData[offset] |= readBit() << successive;
  49040. }
  49041. var eobrun = 0;
  49042. function decodeACFirst(component, offset) {
  49043. if (eobrun > 0) {
  49044. eobrun--;
  49045. return;
  49046. }
  49047. var k = spectralStart, e = spectralEnd;
  49048. while (k <= e) {
  49049. var rs = decodeHuffman(component.huffmanTableAC);
  49050. var s = rs & 15, r = rs >> 4;
  49051. if (s === 0) {
  49052. if (r < 15) {
  49053. eobrun = receive(r) + (1 << r) - 1;
  49054. break;
  49055. }
  49056. k += 16;
  49057. continue;
  49058. }
  49059. k += r;
  49060. var z = dctZigZag[k];
  49061. component.blockData[offset + z] = receiveAndExtend(s) * (1 << successive);
  49062. k++;
  49063. }
  49064. }
  49065. var successiveACState = 0, successiveACNextValue;
  49066. function decodeACSuccessive(component, offset) {
  49067. var k = spectralStart;
  49068. var e = spectralEnd;
  49069. var r = 0;
  49070. var s;
  49071. var rs;
  49072. while (k <= e) {
  49073. var z = dctZigZag[k];
  49074. switch (successiveACState) {
  49075. case 0:
  49076. rs = decodeHuffman(component.huffmanTableAC);
  49077. s = rs & 15;
  49078. r = rs >> 4;
  49079. if (s === 0) {
  49080. if (r < 15) {
  49081. eobrun = receive(r) + (1 << r);
  49082. successiveACState = 4;
  49083. } else {
  49084. r = 16;
  49085. successiveACState = 1;
  49086. }
  49087. } else {
  49088. if (s !== 1) {
  49089. error('JPEG error: invalid ACn encoding');
  49090. }
  49091. successiveACNextValue = receiveAndExtend(s);
  49092. successiveACState = r ? 2 : 3;
  49093. }
  49094. continue;
  49095. case 1:
  49096. case 2:
  49097. if (component.blockData[offset + z]) {
  49098. component.blockData[offset + z] += readBit() << successive;
  49099. } else {
  49100. r--;
  49101. if (r === 0) {
  49102. successiveACState = successiveACState === 2 ? 3 : 0;
  49103. }
  49104. }
  49105. break;
  49106. case 3:
  49107. if (component.blockData[offset + z]) {
  49108. component.blockData[offset + z] += readBit() << successive;
  49109. } else {
  49110. component.blockData[offset + z] = successiveACNextValue << successive;
  49111. successiveACState = 0;
  49112. }
  49113. break;
  49114. case 4:
  49115. if (component.blockData[offset + z]) {
  49116. component.blockData[offset + z] += readBit() << successive;
  49117. }
  49118. break;
  49119. }
  49120. k++;
  49121. }
  49122. if (successiveACState === 4) {
  49123. eobrun--;
  49124. if (eobrun === 0) {
  49125. successiveACState = 0;
  49126. }
  49127. }
  49128. }
  49129. function decodeMcu(component, decode, mcu, row, col) {
  49130. var mcuRow = mcu / mcusPerLine | 0;
  49131. var mcuCol = mcu % mcusPerLine;
  49132. var blockRow = mcuRow * component.v + row;
  49133. var blockCol = mcuCol * component.h + col;
  49134. var offset = getBlockBufferOffset(component, blockRow, blockCol);
  49135. decode(component, offset);
  49136. }
  49137. function decodeBlock(component, decode, mcu) {
  49138. var blockRow = mcu / component.blocksPerLine | 0;
  49139. var blockCol = mcu % component.blocksPerLine;
  49140. var offset = getBlockBufferOffset(component, blockRow, blockCol);
  49141. decode(component, offset);
  49142. }
  49143. var componentsLength = components.length;
  49144. var component, i, j, k, n;
  49145. var decodeFn;
  49146. if (progressive) {
  49147. if (spectralStart === 0) {
  49148. decodeFn = successivePrev === 0 ? decodeDCFirst : decodeDCSuccessive;
  49149. } else {
  49150. decodeFn = successivePrev === 0 ? decodeACFirst : decodeACSuccessive;
  49151. }
  49152. } else {
  49153. decodeFn = decodeBaseline;
  49154. }
  49155. var mcu = 0, marker;
  49156. var mcuExpected;
  49157. if (componentsLength === 1) {
  49158. mcuExpected = components[0].blocksPerLine * components[0].blocksPerColumn;
  49159. } else {
  49160. mcuExpected = mcusPerLine * frame.mcusPerColumn;
  49161. }
  49162. if (!resetInterval) {
  49163. resetInterval = mcuExpected;
  49164. }
  49165. var h, v;
  49166. while (mcu < mcuExpected) {
  49167. for (i = 0; i < componentsLength; i++) {
  49168. components[i].pred = 0;
  49169. }
  49170. eobrun = 0;
  49171. if (componentsLength === 1) {
  49172. component = components[0];
  49173. for (n = 0; n < resetInterval; n++) {
  49174. decodeBlock(component, decodeFn, mcu);
  49175. mcu++;
  49176. }
  49177. } else {
  49178. for (n = 0; n < resetInterval; n++) {
  49179. for (i = 0; i < componentsLength; i++) {
  49180. component = components[i];
  49181. h = component.h;
  49182. v = component.v;
  49183. for (j = 0; j < v; j++) {
  49184. for (k = 0; k < h; k++) {
  49185. decodeMcu(component, decodeFn, mcu, j, k);
  49186. }
  49187. }
  49188. }
  49189. mcu++;
  49190. }
  49191. }
  49192. bitsCount = 0;
  49193. marker = data[offset] << 8 | data[offset + 1];
  49194. while (data[offset] === 0x00 && offset < data.length - 1) {
  49195. offset++;
  49196. marker = data[offset] << 8 | data[offset + 1];
  49197. }
  49198. if (marker <= 0xFF00) {
  49199. error('JPEG error: marker was not found');
  49200. }
  49201. if (marker >= 0xFFD0 && marker <= 0xFFD7) {
  49202. offset += 2;
  49203. } else {
  49204. break;
  49205. }
  49206. }
  49207. return offset - startOffset;
  49208. }
  49209. function quantizeAndInverse(component, blockBufferOffset, p) {
  49210. var qt = component.quantizationTable, blockData = component.blockData;
  49211. var v0, v1, v2, v3, v4, v5, v6, v7;
  49212. var p0, p1, p2, p3, p4, p5, p6, p7;
  49213. var t;
  49214. if (!qt) {
  49215. error('JPEG error: missing required Quantization Table.');
  49216. }
  49217. for (var row = 0; row < 64; row += 8) {
  49218. p0 = blockData[blockBufferOffset + row];
  49219. p1 = blockData[blockBufferOffset + row + 1];
  49220. p2 = blockData[blockBufferOffset + row + 2];
  49221. p3 = blockData[blockBufferOffset + row + 3];
  49222. p4 = blockData[blockBufferOffset + row + 4];
  49223. p5 = blockData[blockBufferOffset + row + 5];
  49224. p6 = blockData[blockBufferOffset + row + 6];
  49225. p7 = blockData[blockBufferOffset + row + 7];
  49226. p0 *= qt[row];
  49227. if ((p1 | p2 | p3 | p4 | p5 | p6 | p7) === 0) {
  49228. t = dctSqrt2 * p0 + 512 >> 10;
  49229. p[row] = t;
  49230. p[row + 1] = t;
  49231. p[row + 2] = t;
  49232. p[row + 3] = t;
  49233. p[row + 4] = t;
  49234. p[row + 5] = t;
  49235. p[row + 6] = t;
  49236. p[row + 7] = t;
  49237. continue;
  49238. }
  49239. p1 *= qt[row + 1];
  49240. p2 *= qt[row + 2];
  49241. p3 *= qt[row + 3];
  49242. p4 *= qt[row + 4];
  49243. p5 *= qt[row + 5];
  49244. p6 *= qt[row + 6];
  49245. p7 *= qt[row + 7];
  49246. v0 = dctSqrt2 * p0 + 128 >> 8;
  49247. v1 = dctSqrt2 * p4 + 128 >> 8;
  49248. v2 = p2;
  49249. v3 = p6;
  49250. v4 = dctSqrt1d2 * (p1 - p7) + 128 >> 8;
  49251. v7 = dctSqrt1d2 * (p1 + p7) + 128 >> 8;
  49252. v5 = p3 << 4;
  49253. v6 = p5 << 4;
  49254. v0 = v0 + v1 + 1 >> 1;
  49255. v1 = v0 - v1;
  49256. t = v2 * dctSin6 + v3 * dctCos6 + 128 >> 8;
  49257. v2 = v2 * dctCos6 - v3 * dctSin6 + 128 >> 8;
  49258. v3 = t;
  49259. v4 = v4 + v6 + 1 >> 1;
  49260. v6 = v4 - v6;
  49261. v7 = v7 + v5 + 1 >> 1;
  49262. v5 = v7 - v5;
  49263. v0 = v0 + v3 + 1 >> 1;
  49264. v3 = v0 - v3;
  49265. v1 = v1 + v2 + 1 >> 1;
  49266. v2 = v1 - v2;
  49267. t = v4 * dctSin3 + v7 * dctCos3 + 2048 >> 12;
  49268. v4 = v4 * dctCos3 - v7 * dctSin3 + 2048 >> 12;
  49269. v7 = t;
  49270. t = v5 * dctSin1 + v6 * dctCos1 + 2048 >> 12;
  49271. v5 = v5 * dctCos1 - v6 * dctSin1 + 2048 >> 12;
  49272. v6 = t;
  49273. p[row] = v0 + v7;
  49274. p[row + 7] = v0 - v7;
  49275. p[row + 1] = v1 + v6;
  49276. p[row + 6] = v1 - v6;
  49277. p[row + 2] = v2 + v5;
  49278. p[row + 5] = v2 - v5;
  49279. p[row + 3] = v3 + v4;
  49280. p[row + 4] = v3 - v4;
  49281. }
  49282. for (var col = 0; col < 8; ++col) {
  49283. p0 = p[col];
  49284. p1 = p[col + 8];
  49285. p2 = p[col + 16];
  49286. p3 = p[col + 24];
  49287. p4 = p[col + 32];
  49288. p5 = p[col + 40];
  49289. p6 = p[col + 48];
  49290. p7 = p[col + 56];
  49291. if ((p1 | p2 | p3 | p4 | p5 | p6 | p7) === 0) {
  49292. t = dctSqrt2 * p0 + 8192 >> 14;
  49293. t = t < -2040 ? 0 : t >= 2024 ? 255 : t + 2056 >> 4;
  49294. blockData[blockBufferOffset + col] = t;
  49295. blockData[blockBufferOffset + col + 8] = t;
  49296. blockData[blockBufferOffset + col + 16] = t;
  49297. blockData[blockBufferOffset + col + 24] = t;
  49298. blockData[blockBufferOffset + col + 32] = t;
  49299. blockData[blockBufferOffset + col + 40] = t;
  49300. blockData[blockBufferOffset + col + 48] = t;
  49301. blockData[blockBufferOffset + col + 56] = t;
  49302. continue;
  49303. }
  49304. v0 = dctSqrt2 * p0 + 2048 >> 12;
  49305. v1 = dctSqrt2 * p4 + 2048 >> 12;
  49306. v2 = p2;
  49307. v3 = p6;
  49308. v4 = dctSqrt1d2 * (p1 - p7) + 2048 >> 12;
  49309. v7 = dctSqrt1d2 * (p1 + p7) + 2048 >> 12;
  49310. v5 = p3;
  49311. v6 = p5;
  49312. v0 = (v0 + v1 + 1 >> 1) + 4112;
  49313. v1 = v0 - v1;
  49314. t = v2 * dctSin6 + v3 * dctCos6 + 2048 >> 12;
  49315. v2 = v2 * dctCos6 - v3 * dctSin6 + 2048 >> 12;
  49316. v3 = t;
  49317. v4 = v4 + v6 + 1 >> 1;
  49318. v6 = v4 - v6;
  49319. v7 = v7 + v5 + 1 >> 1;
  49320. v5 = v7 - v5;
  49321. v0 = v0 + v3 + 1 >> 1;
  49322. v3 = v0 - v3;
  49323. v1 = v1 + v2 + 1 >> 1;
  49324. v2 = v1 - v2;
  49325. t = v4 * dctSin3 + v7 * dctCos3 + 2048 >> 12;
  49326. v4 = v4 * dctCos3 - v7 * dctSin3 + 2048 >> 12;
  49327. v7 = t;
  49328. t = v5 * dctSin1 + v6 * dctCos1 + 2048 >> 12;
  49329. v5 = v5 * dctCos1 - v6 * dctSin1 + 2048 >> 12;
  49330. v6 = t;
  49331. p0 = v0 + v7;
  49332. p7 = v0 - v7;
  49333. p1 = v1 + v6;
  49334. p6 = v1 - v6;
  49335. p2 = v2 + v5;
  49336. p5 = v2 - v5;
  49337. p3 = v3 + v4;
  49338. p4 = v3 - v4;
  49339. p0 = p0 < 16 ? 0 : p0 >= 4080 ? 255 : p0 >> 4;
  49340. p1 = p1 < 16 ? 0 : p1 >= 4080 ? 255 : p1 >> 4;
  49341. p2 = p2 < 16 ? 0 : p2 >= 4080 ? 255 : p2 >> 4;
  49342. p3 = p3 < 16 ? 0 : p3 >= 4080 ? 255 : p3 >> 4;
  49343. p4 = p4 < 16 ? 0 : p4 >= 4080 ? 255 : p4 >> 4;
  49344. p5 = p5 < 16 ? 0 : p5 >= 4080 ? 255 : p5 >> 4;
  49345. p6 = p6 < 16 ? 0 : p6 >= 4080 ? 255 : p6 >> 4;
  49346. p7 = p7 < 16 ? 0 : p7 >= 4080 ? 255 : p7 >> 4;
  49347. blockData[blockBufferOffset + col] = p0;
  49348. blockData[blockBufferOffset + col + 8] = p1;
  49349. blockData[blockBufferOffset + col + 16] = p2;
  49350. blockData[blockBufferOffset + col + 24] = p3;
  49351. blockData[blockBufferOffset + col + 32] = p4;
  49352. blockData[blockBufferOffset + col + 40] = p5;
  49353. blockData[blockBufferOffset + col + 48] = p6;
  49354. blockData[blockBufferOffset + col + 56] = p7;
  49355. }
  49356. }
  49357. function buildComponentData(frame, component) {
  49358. var blocksPerLine = component.blocksPerLine;
  49359. var blocksPerColumn = component.blocksPerColumn;
  49360. var computationBuffer = new Int16Array(64);
  49361. for (var blockRow = 0; blockRow < blocksPerColumn; blockRow++) {
  49362. for (var blockCol = 0; blockCol < blocksPerLine; blockCol++) {
  49363. var offset = getBlockBufferOffset(component, blockRow, blockCol);
  49364. quantizeAndInverse(component, offset, computationBuffer);
  49365. }
  49366. }
  49367. return component.blockData;
  49368. }
  49369. function clamp0to255(a) {
  49370. return a <= 0 ? 0 : a >= 255 ? 255 : a;
  49371. }
  49372. JpegImage.prototype = {
  49373. parse: function parse(data) {
  49374. function readUint16() {
  49375. var value = data[offset] << 8 | data[offset + 1];
  49376. offset += 2;
  49377. return value;
  49378. }
  49379. function readDataBlock() {
  49380. var length = readUint16();
  49381. var array = data.subarray(offset, offset + length - 2);
  49382. offset += array.length;
  49383. return array;
  49384. }
  49385. function prepareComponents(frame) {
  49386. var mcusPerLine = Math.ceil(frame.samplesPerLine / 8 / frame.maxH);
  49387. var mcusPerColumn = Math.ceil(frame.scanLines / 8 / frame.maxV);
  49388. for (var i = 0; i < frame.components.length; i++) {
  49389. component = frame.components[i];
  49390. var blocksPerLine = Math.ceil(Math.ceil(frame.samplesPerLine / 8) * component.h / frame.maxH);
  49391. var blocksPerColumn = Math.ceil(Math.ceil(frame.scanLines / 8) * component.v / frame.maxV);
  49392. var blocksPerLineForMcu = mcusPerLine * component.h;
  49393. var blocksPerColumnForMcu = mcusPerColumn * component.v;
  49394. var blocksBufferSize = 64 * blocksPerColumnForMcu * (blocksPerLineForMcu + 1);
  49395. component.blockData = new Int16Array(blocksBufferSize);
  49396. component.blocksPerLine = blocksPerLine;
  49397. component.blocksPerColumn = blocksPerColumn;
  49398. }
  49399. frame.mcusPerLine = mcusPerLine;
  49400. frame.mcusPerColumn = mcusPerColumn;
  49401. }
  49402. var offset = 0;
  49403. var jfif = null;
  49404. var adobe = null;
  49405. var frame, resetInterval;
  49406. var quantizationTables = [];
  49407. var huffmanTablesAC = [], huffmanTablesDC = [];
  49408. var fileMarker = readUint16();
  49409. if (fileMarker !== 0xFFD8) {
  49410. error('JPEG error: SOI not found');
  49411. }
  49412. fileMarker = readUint16();
  49413. while (fileMarker !== 0xFFD9) {
  49414. var i, j, l;
  49415. switch (fileMarker) {
  49416. case 0xFFE0:
  49417. case 0xFFE1:
  49418. case 0xFFE2:
  49419. case 0xFFE3:
  49420. case 0xFFE4:
  49421. case 0xFFE5:
  49422. case 0xFFE6:
  49423. case 0xFFE7:
  49424. case 0xFFE8:
  49425. case 0xFFE9:
  49426. case 0xFFEA:
  49427. case 0xFFEB:
  49428. case 0xFFEC:
  49429. case 0xFFED:
  49430. case 0xFFEE:
  49431. case 0xFFEF:
  49432. case 0xFFFE:
  49433. var appData = readDataBlock();
  49434. if (fileMarker === 0xFFE0) {
  49435. if (appData[0] === 0x4A && appData[1] === 0x46 && appData[2] === 0x49 && appData[3] === 0x46 && appData[4] === 0) {
  49436. jfif = {
  49437. version: {
  49438. major: appData[5],
  49439. minor: appData[6]
  49440. },
  49441. densityUnits: appData[7],
  49442. xDensity: appData[8] << 8 | appData[9],
  49443. yDensity: appData[10] << 8 | appData[11],
  49444. thumbWidth: appData[12],
  49445. thumbHeight: appData[13],
  49446. thumbData: appData.subarray(14, 14 + 3 * appData[12] * appData[13])
  49447. };
  49448. }
  49449. }
  49450. if (fileMarker === 0xFFEE) {
  49451. if (appData[0] === 0x41 && appData[1] === 0x64 && appData[2] === 0x6F && appData[3] === 0x62 && appData[4] === 0x65) {
  49452. adobe = {
  49453. version: appData[5] << 8 | appData[6],
  49454. flags0: appData[7] << 8 | appData[8],
  49455. flags1: appData[9] << 8 | appData[10],
  49456. transformCode: appData[11]
  49457. };
  49458. }
  49459. }
  49460. break;
  49461. case 0xFFDB:
  49462. var quantizationTablesLength = readUint16();
  49463. var quantizationTablesEnd = quantizationTablesLength + offset - 2;
  49464. var z;
  49465. while (offset < quantizationTablesEnd) {
  49466. var quantizationTableSpec = data[offset++];
  49467. var tableData = new Uint16Array(64);
  49468. if (quantizationTableSpec >> 4 === 0) {
  49469. for (j = 0; j < 64; j++) {
  49470. z = dctZigZag[j];
  49471. tableData[z] = data[offset++];
  49472. }
  49473. } else if (quantizationTableSpec >> 4 === 1) {
  49474. for (j = 0; j < 64; j++) {
  49475. z = dctZigZag[j];
  49476. tableData[z] = readUint16();
  49477. }
  49478. } else {
  49479. error('JPEG error: DQT - invalid table spec');
  49480. }
  49481. quantizationTables[quantizationTableSpec & 15] = tableData;
  49482. }
  49483. break;
  49484. case 0xFFC0:
  49485. case 0xFFC1:
  49486. case 0xFFC2:
  49487. if (frame) {
  49488. error('JPEG error: Only single frame JPEGs supported');
  49489. }
  49490. readUint16();
  49491. frame = {};
  49492. frame.extended = fileMarker === 0xFFC1;
  49493. frame.progressive = fileMarker === 0xFFC2;
  49494. frame.precision = data[offset++];
  49495. frame.scanLines = readUint16();
  49496. frame.samplesPerLine = readUint16();
  49497. frame.components = [];
  49498. frame.componentIds = {};
  49499. var componentsCount = data[offset++], componentId;
  49500. var maxH = 0, maxV = 0;
  49501. for (i = 0; i < componentsCount; i++) {
  49502. componentId = data[offset];
  49503. var h = data[offset + 1] >> 4;
  49504. var v = data[offset + 1] & 15;
  49505. if (maxH < h) {
  49506. maxH = h;
  49507. }
  49508. if (maxV < v) {
  49509. maxV = v;
  49510. }
  49511. var qId = data[offset + 2];
  49512. l = frame.components.push({
  49513. h: h,
  49514. v: v,
  49515. quantizationId: qId,
  49516. quantizationTable: null
  49517. });
  49518. frame.componentIds[componentId] = l - 1;
  49519. offset += 3;
  49520. }
  49521. frame.maxH = maxH;
  49522. frame.maxV = maxV;
  49523. prepareComponents(frame);
  49524. break;
  49525. case 0xFFC4:
  49526. var huffmanLength = readUint16();
  49527. for (i = 2; i < huffmanLength;) {
  49528. var huffmanTableSpec = data[offset++];
  49529. var codeLengths = new Uint8Array(16);
  49530. var codeLengthSum = 0;
  49531. for (j = 0; j < 16; j++, offset++) {
  49532. codeLengthSum += codeLengths[j] = data[offset];
  49533. }
  49534. var huffmanValues = new Uint8Array(codeLengthSum);
  49535. for (j = 0; j < codeLengthSum; j++, offset++) {
  49536. huffmanValues[j] = data[offset];
  49537. }
  49538. i += 17 + codeLengthSum;
  49539. (huffmanTableSpec >> 4 === 0 ? huffmanTablesDC : huffmanTablesAC)[huffmanTableSpec & 15] = buildHuffmanTable(codeLengths, huffmanValues);
  49540. }
  49541. break;
  49542. case 0xFFDD:
  49543. readUint16();
  49544. resetInterval = readUint16();
  49545. break;
  49546. case 0xFFDA:
  49547. readUint16();
  49548. var selectorsCount = data[offset++];
  49549. var components = [], component;
  49550. for (i = 0; i < selectorsCount; i++) {
  49551. var componentIndex = frame.componentIds[data[offset++]];
  49552. component = frame.components[componentIndex];
  49553. var tableSpec = data[offset++];
  49554. component.huffmanTableDC = huffmanTablesDC[tableSpec >> 4];
  49555. component.huffmanTableAC = huffmanTablesAC[tableSpec & 15];
  49556. components.push(component);
  49557. }
  49558. var spectralStart = data[offset++];
  49559. var spectralEnd = data[offset++];
  49560. var successiveApproximation = data[offset++];
  49561. var processed = decodeScan(data, offset, frame, components, resetInterval, spectralStart, spectralEnd, successiveApproximation >> 4, successiveApproximation & 15);
  49562. offset += processed;
  49563. break;
  49564. case 0xFFFF:
  49565. if (data[offset] !== 0xFF) {
  49566. offset--;
  49567. }
  49568. break;
  49569. default:
  49570. if (data[offset - 3] === 0xFF && data[offset - 2] >= 0xC0 && data[offset - 2] <= 0xFE) {
  49571. offset -= 3;
  49572. break;
  49573. }
  49574. error('JPEG error: unknown marker ' + fileMarker.toString(16));
  49575. }
  49576. fileMarker = readUint16();
  49577. }
  49578. this.width = frame.samplesPerLine;
  49579. this.height = frame.scanLines;
  49580. this.jfif = jfif;
  49581. this.adobe = adobe;
  49582. this.components = [];
  49583. for (i = 0; i < frame.components.length; i++) {
  49584. component = frame.components[i];
  49585. var quantizationTable = quantizationTables[component.quantizationId];
  49586. if (quantizationTable) {
  49587. component.quantizationTable = quantizationTable;
  49588. }
  49589. this.components.push({
  49590. output: buildComponentData(frame, component),
  49591. scaleX: component.h / frame.maxH,
  49592. scaleY: component.v / frame.maxV,
  49593. blocksPerLine: component.blocksPerLine,
  49594. blocksPerColumn: component.blocksPerColumn
  49595. });
  49596. }
  49597. this.numComponents = this.components.length;
  49598. },
  49599. _getLinearizedBlockData: function getLinearizedBlockData(width, height) {
  49600. var scaleX = this.width / width, scaleY = this.height / height;
  49601. var component, componentScaleX, componentScaleY, blocksPerScanline;
  49602. var x, y, i, j, k;
  49603. var index;
  49604. var offset = 0;
  49605. var output;
  49606. var numComponents = this.components.length;
  49607. var dataLength = width * height * numComponents;
  49608. var data = new Uint8Array(dataLength);
  49609. var xScaleBlockOffset = new Uint32Array(width);
  49610. var mask3LSB = 0xfffffff8;
  49611. for (i = 0; i < numComponents; i++) {
  49612. component = this.components[i];
  49613. componentScaleX = component.scaleX * scaleX;
  49614. componentScaleY = component.scaleY * scaleY;
  49615. offset = i;
  49616. output = component.output;
  49617. blocksPerScanline = component.blocksPerLine + 1 << 3;
  49618. for (x = 0; x < width; x++) {
  49619. j = 0 | x * componentScaleX;
  49620. xScaleBlockOffset[x] = (j & mask3LSB) << 3 | j & 7;
  49621. }
  49622. for (y = 0; y < height; y++) {
  49623. j = 0 | y * componentScaleY;
  49624. index = blocksPerScanline * (j & mask3LSB) | (j & 7) << 3;
  49625. for (x = 0; x < width; x++) {
  49626. data[offset] = output[index + xScaleBlockOffset[x]];
  49627. offset += numComponents;
  49628. }
  49629. }
  49630. }
  49631. var transform = this.decodeTransform;
  49632. if (transform) {
  49633. for (i = 0; i < dataLength;) {
  49634. for (j = 0, k = 0; j < numComponents; j++, i++, k += 2) {
  49635. data[i] = (data[i] * transform[k] >> 8) + transform[k + 1];
  49636. }
  49637. }
  49638. }
  49639. return data;
  49640. },
  49641. _isColorConversionNeeded: function isColorConversionNeeded() {
  49642. if (this.adobe && this.adobe.transformCode) {
  49643. return true;
  49644. } else if (this.numComponents === 3) {
  49645. if (!this.adobe && this.colorTransform === 0) {
  49646. return false;
  49647. }
  49648. return true;
  49649. }
  49650. if (!this.adobe && this.colorTransform === 1) {
  49651. return true;
  49652. }
  49653. return false;
  49654. },
  49655. _convertYccToRgb: function convertYccToRgb(data) {
  49656. var Y, Cb, Cr;
  49657. for (var i = 0, length = data.length; i < length; i += 3) {
  49658. Y = data[i];
  49659. Cb = data[i + 1];
  49660. Cr = data[i + 2];
  49661. data[i] = clamp0to255(Y - 179.456 + 1.402 * Cr);
  49662. data[i + 1] = clamp0to255(Y + 135.459 - 0.344 * Cb - 0.714 * Cr);
  49663. data[i + 2] = clamp0to255(Y - 226.816 + 1.772 * Cb);
  49664. }
  49665. return data;
  49666. },
  49667. _convertYcckToRgb: function convertYcckToRgb(data) {
  49668. var Y, Cb, Cr, k;
  49669. var offset = 0;
  49670. for (var i = 0, length = data.length; i < length; i += 4) {
  49671. Y = data[i];
  49672. Cb = data[i + 1];
  49673. Cr = data[i + 2];
  49674. k = data[i + 3];
  49675. 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);
  49676. 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);
  49677. 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);
  49678. data[offset++] = clamp0to255(r);
  49679. data[offset++] = clamp0to255(g);
  49680. data[offset++] = clamp0to255(b);
  49681. }
  49682. return data;
  49683. },
  49684. _convertYcckToCmyk: function convertYcckToCmyk(data) {
  49685. var Y, Cb, Cr;
  49686. for (var i = 0, length = data.length; i < length; i += 4) {
  49687. Y = data[i];
  49688. Cb = data[i + 1];
  49689. Cr = data[i + 2];
  49690. data[i] = clamp0to255(434.456 - Y - 1.402 * Cr);
  49691. data[i + 1] = clamp0to255(119.541 - Y + 0.344 * Cb + 0.714 * Cr);
  49692. data[i + 2] = clamp0to255(481.816 - Y - 1.772 * Cb);
  49693. }
  49694. return data;
  49695. },
  49696. _convertCmykToRgb: function convertCmykToRgb(data) {
  49697. var c, m, y, k;
  49698. var offset = 0;
  49699. var min = -255 * 255 * 255;
  49700. var scale = 1 / 255 / 255;
  49701. for (var i = 0, length = data.length; i < length; i += 4) {
  49702. c = data[i];
  49703. m = data[i + 1];
  49704. y = data[i + 2];
  49705. k = data[i + 3];
  49706. 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);
  49707. 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);
  49708. 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);
  49709. data[offset++] = r >= 0 ? 255 : r <= min ? 0 : 255 + r * scale | 0;
  49710. data[offset++] = g >= 0 ? 255 : g <= min ? 0 : 255 + g * scale | 0;
  49711. data[offset++] = b >= 0 ? 255 : b <= min ? 0 : 255 + b * scale | 0;
  49712. }
  49713. return data;
  49714. },
  49715. getData: function getData(width, height, forceRGBoutput) {
  49716. if (this.numComponents > 4) {
  49717. error('JPEG error: Unsupported color mode');
  49718. }
  49719. var data = this._getLinearizedBlockData(width, height);
  49720. if (this.numComponents === 1 && forceRGBoutput) {
  49721. var dataLength = data.length;
  49722. var rgbData = new Uint8Array(dataLength * 3);
  49723. var offset = 0;
  49724. for (var i = 0; i < dataLength; i++) {
  49725. var grayColor = data[i];
  49726. rgbData[offset++] = grayColor;
  49727. rgbData[offset++] = grayColor;
  49728. rgbData[offset++] = grayColor;
  49729. }
  49730. return rgbData;
  49731. } else if (this.numComponents === 3 && this._isColorConversionNeeded()) {
  49732. return this._convertYccToRgb(data);
  49733. } else if (this.numComponents === 4) {
  49734. if (this._isColorConversionNeeded()) {
  49735. if (forceRGBoutput) {
  49736. return this._convertYcckToRgb(data);
  49737. }
  49738. return this._convertYcckToCmyk(data);
  49739. } else if (forceRGBoutput) {
  49740. return this._convertCmykToRgb(data);
  49741. }
  49742. }
  49743. return data;
  49744. }
  49745. };
  49746. return JpegImage;
  49747. }();
  49748. exports.JpegImage = JpegImage;
  49749. /***/ }),
  49750. /* 39 */
  49751. /***/ (function(module, exports, __w_pdfjs_require__) {
  49752. "use strict";
  49753. var sharedUtil = __w_pdfjs_require__(0);
  49754. var getLookupTableFactory = sharedUtil.getLookupTableFactory;
  49755. var getMetrics = getLookupTableFactory(function (t) {
  49756. t['Courier'] = 600;
  49757. t['Courier-Bold'] = 600;
  49758. t['Courier-BoldOblique'] = 600;
  49759. t['Courier-Oblique'] = 600;
  49760. t['Helvetica'] = getLookupTableFactory(function (t) {
  49761. t['space'] = 278;
  49762. t['exclam'] = 278;
  49763. t['quotedbl'] = 355;
  49764. t['numbersign'] = 556;
  49765. t['dollar'] = 556;
  49766. t['percent'] = 889;
  49767. t['ampersand'] = 667;
  49768. t['quoteright'] = 222;
  49769. t['parenleft'] = 333;
  49770. t['parenright'] = 333;
  49771. t['asterisk'] = 389;
  49772. t['plus'] = 584;
  49773. t['comma'] = 278;
  49774. t['hyphen'] = 333;
  49775. t['period'] = 278;
  49776. t['slash'] = 278;
  49777. t['zero'] = 556;
  49778. t['one'] = 556;
  49779. t['two'] = 556;
  49780. t['three'] = 556;
  49781. t['four'] = 556;
  49782. t['five'] = 556;
  49783. t['six'] = 556;
  49784. t['seven'] = 556;
  49785. t['eight'] = 556;
  49786. t['nine'] = 556;
  49787. t['colon'] = 278;
  49788. t['semicolon'] = 278;
  49789. t['less'] = 584;
  49790. t['equal'] = 584;
  49791. t['greater'] = 584;
  49792. t['question'] = 556;
  49793. t['at'] = 1015;
  49794. t['A'] = 667;
  49795. t['B'] = 667;
  49796. t['C'] = 722;
  49797. t['D'] = 722;
  49798. t['E'] = 667;
  49799. t['F'] = 611;
  49800. t['G'] = 778;
  49801. t['H'] = 722;
  49802. t['I'] = 278;
  49803. t['J'] = 500;
  49804. t['K'] = 667;
  49805. t['L'] = 556;
  49806. t['M'] = 833;
  49807. t['N'] = 722;
  49808. t['O'] = 778;
  49809. t['P'] = 667;
  49810. t['Q'] = 778;
  49811. t['R'] = 722;
  49812. t['S'] = 667;
  49813. t['T'] = 611;
  49814. t['U'] = 722;
  49815. t['V'] = 667;
  49816. t['W'] = 944;
  49817. t['X'] = 667;
  49818. t['Y'] = 667;
  49819. t['Z'] = 611;
  49820. t['bracketleft'] = 278;
  49821. t['backslash'] = 278;
  49822. t['bracketright'] = 278;
  49823. t['asciicircum'] = 469;
  49824. t['underscore'] = 556;
  49825. t['quoteleft'] = 222;
  49826. t['a'] = 556;
  49827. t['b'] = 556;
  49828. t['c'] = 500;
  49829. t['d'] = 556;
  49830. t['e'] = 556;
  49831. t['f'] = 278;
  49832. t['g'] = 556;
  49833. t['h'] = 556;
  49834. t['i'] = 222;
  49835. t['j'] = 222;
  49836. t['k'] = 500;
  49837. t['l'] = 222;
  49838. t['m'] = 833;
  49839. t['n'] = 556;
  49840. t['o'] = 556;
  49841. t['p'] = 556;
  49842. t['q'] = 556;
  49843. t['r'] = 333;
  49844. t['s'] = 500;
  49845. t['t'] = 278;
  49846. t['u'] = 556;
  49847. t['v'] = 500;
  49848. t['w'] = 722;
  49849. t['x'] = 500;
  49850. t['y'] = 500;
  49851. t['z'] = 500;
  49852. t['braceleft'] = 334;
  49853. t['bar'] = 260;
  49854. t['braceright'] = 334;
  49855. t['asciitilde'] = 584;
  49856. t['exclamdown'] = 333;
  49857. t['cent'] = 556;
  49858. t['sterling'] = 556;
  49859. t['fraction'] = 167;
  49860. t['yen'] = 556;
  49861. t['florin'] = 556;
  49862. t['section'] = 556;
  49863. t['currency'] = 556;
  49864. t['quotesingle'] = 191;
  49865. t['quotedblleft'] = 333;
  49866. t['guillemotleft'] = 556;
  49867. t['guilsinglleft'] = 333;
  49868. t['guilsinglright'] = 333;
  49869. t['fi'] = 500;
  49870. t['fl'] = 500;
  49871. t['endash'] = 556;
  49872. t['dagger'] = 556;
  49873. t['daggerdbl'] = 556;
  49874. t['periodcentered'] = 278;
  49875. t['paragraph'] = 537;
  49876. t['bullet'] = 350;
  49877. t['quotesinglbase'] = 222;
  49878. t['quotedblbase'] = 333;
  49879. t['quotedblright'] = 333;
  49880. t['guillemotright'] = 556;
  49881. t['ellipsis'] = 1000;
  49882. t['perthousand'] = 1000;
  49883. t['questiondown'] = 611;
  49884. t['grave'] = 333;
  49885. t['acute'] = 333;
  49886. t['circumflex'] = 333;
  49887. t['tilde'] = 333;
  49888. t['macron'] = 333;
  49889. t['breve'] = 333;
  49890. t['dotaccent'] = 333;
  49891. t['dieresis'] = 333;
  49892. t['ring'] = 333;
  49893. t['cedilla'] = 333;
  49894. t['hungarumlaut'] = 333;
  49895. t['ogonek'] = 333;
  49896. t['caron'] = 333;
  49897. t['emdash'] = 1000;
  49898. t['AE'] = 1000;
  49899. t['ordfeminine'] = 370;
  49900. t['Lslash'] = 556;
  49901. t['Oslash'] = 778;
  49902. t['OE'] = 1000;
  49903. t['ordmasculine'] = 365;
  49904. t['ae'] = 889;
  49905. t['dotlessi'] = 278;
  49906. t['lslash'] = 222;
  49907. t['oslash'] = 611;
  49908. t['oe'] = 944;
  49909. t['germandbls'] = 611;
  49910. t['Idieresis'] = 278;
  49911. t['eacute'] = 556;
  49912. t['abreve'] = 556;
  49913. t['uhungarumlaut'] = 556;
  49914. t['ecaron'] = 556;
  49915. t['Ydieresis'] = 667;
  49916. t['divide'] = 584;
  49917. t['Yacute'] = 667;
  49918. t['Acircumflex'] = 667;
  49919. t['aacute'] = 556;
  49920. t['Ucircumflex'] = 722;
  49921. t['yacute'] = 500;
  49922. t['scommaaccent'] = 500;
  49923. t['ecircumflex'] = 556;
  49924. t['Uring'] = 722;
  49925. t['Udieresis'] = 722;
  49926. t['aogonek'] = 556;
  49927. t['Uacute'] = 722;
  49928. t['uogonek'] = 556;
  49929. t['Edieresis'] = 667;
  49930. t['Dcroat'] = 722;
  49931. t['commaaccent'] = 250;
  49932. t['copyright'] = 737;
  49933. t['Emacron'] = 667;
  49934. t['ccaron'] = 500;
  49935. t['aring'] = 556;
  49936. t['Ncommaaccent'] = 722;
  49937. t['lacute'] = 222;
  49938. t['agrave'] = 556;
  49939. t['Tcommaaccent'] = 611;
  49940. t['Cacute'] = 722;
  49941. t['atilde'] = 556;
  49942. t['Edotaccent'] = 667;
  49943. t['scaron'] = 500;
  49944. t['scedilla'] = 500;
  49945. t['iacute'] = 278;
  49946. t['lozenge'] = 471;
  49947. t['Rcaron'] = 722;
  49948. t['Gcommaaccent'] = 778;
  49949. t['ucircumflex'] = 556;
  49950. t['acircumflex'] = 556;
  49951. t['Amacron'] = 667;
  49952. t['rcaron'] = 333;
  49953. t['ccedilla'] = 500;
  49954. t['Zdotaccent'] = 611;
  49955. t['Thorn'] = 667;
  49956. t['Omacron'] = 778;
  49957. t['Racute'] = 722;
  49958. t['Sacute'] = 667;
  49959. t['dcaron'] = 643;
  49960. t['Umacron'] = 722;
  49961. t['uring'] = 556;
  49962. t['threesuperior'] = 333;
  49963. t['Ograve'] = 778;
  49964. t['Agrave'] = 667;
  49965. t['Abreve'] = 667;
  49966. t['multiply'] = 584;
  49967. t['uacute'] = 556;
  49968. t['Tcaron'] = 611;
  49969. t['partialdiff'] = 476;
  49970. t['ydieresis'] = 500;
  49971. t['Nacute'] = 722;
  49972. t['icircumflex'] = 278;
  49973. t['Ecircumflex'] = 667;
  49974. t['adieresis'] = 556;
  49975. t['edieresis'] = 556;
  49976. t['cacute'] = 500;
  49977. t['nacute'] = 556;
  49978. t['umacron'] = 556;
  49979. t['Ncaron'] = 722;
  49980. t['Iacute'] = 278;
  49981. t['plusminus'] = 584;
  49982. t['brokenbar'] = 260;
  49983. t['registered'] = 737;
  49984. t['Gbreve'] = 778;
  49985. t['Idotaccent'] = 278;
  49986. t['summation'] = 600;
  49987. t['Egrave'] = 667;
  49988. t['racute'] = 333;
  49989. t['omacron'] = 556;
  49990. t['Zacute'] = 611;
  49991. t['Zcaron'] = 611;
  49992. t['greaterequal'] = 549;
  49993. t['Eth'] = 722;
  49994. t['Ccedilla'] = 722;
  49995. t['lcommaaccent'] = 222;
  49996. t['tcaron'] = 317;
  49997. t['eogonek'] = 556;
  49998. t['Uogonek'] = 722;
  49999. t['Aacute'] = 667;
  50000. t['Adieresis'] = 667;
  50001. t['egrave'] = 556;
  50002. t['zacute'] = 500;
  50003. t['iogonek'] = 222;
  50004. t['Oacute'] = 778;
  50005. t['oacute'] = 556;
  50006. t['amacron'] = 556;
  50007. t['sacute'] = 500;
  50008. t['idieresis'] = 278;
  50009. t['Ocircumflex'] = 778;
  50010. t['Ugrave'] = 722;
  50011. t['Delta'] = 612;
  50012. t['thorn'] = 556;
  50013. t['twosuperior'] = 333;
  50014. t['Odieresis'] = 778;
  50015. t['mu'] = 556;
  50016. t['igrave'] = 278;
  50017. t['ohungarumlaut'] = 556;
  50018. t['Eogonek'] = 667;
  50019. t['dcroat'] = 556;
  50020. t['threequarters'] = 834;
  50021. t['Scedilla'] = 667;
  50022. t['lcaron'] = 299;
  50023. t['Kcommaaccent'] = 667;
  50024. t['Lacute'] = 556;
  50025. t['trademark'] = 1000;
  50026. t['edotaccent'] = 556;
  50027. t['Igrave'] = 278;
  50028. t['Imacron'] = 278;
  50029. t['Lcaron'] = 556;
  50030. t['onehalf'] = 834;
  50031. t['lessequal'] = 549;
  50032. t['ocircumflex'] = 556;
  50033. t['ntilde'] = 556;
  50034. t['Uhungarumlaut'] = 722;
  50035. t['Eacute'] = 667;
  50036. t['emacron'] = 556;
  50037. t['gbreve'] = 556;
  50038. t['onequarter'] = 834;
  50039. t['Scaron'] = 667;
  50040. t['Scommaaccent'] = 667;
  50041. t['Ohungarumlaut'] = 778;
  50042. t['degree'] = 400;
  50043. t['ograve'] = 556;
  50044. t['Ccaron'] = 722;
  50045. t['ugrave'] = 556;
  50046. t['radical'] = 453;
  50047. t['Dcaron'] = 722;
  50048. t['rcommaaccent'] = 333;
  50049. t['Ntilde'] = 722;
  50050. t['otilde'] = 556;
  50051. t['Rcommaaccent'] = 722;
  50052. t['Lcommaaccent'] = 556;
  50053. t['Atilde'] = 667;
  50054. t['Aogonek'] = 667;
  50055. t['Aring'] = 667;
  50056. t['Otilde'] = 778;
  50057. t['zdotaccent'] = 500;
  50058. t['Ecaron'] = 667;
  50059. t['Iogonek'] = 278;
  50060. t['kcommaaccent'] = 500;
  50061. t['minus'] = 584;
  50062. t['Icircumflex'] = 278;
  50063. t['ncaron'] = 556;
  50064. t['tcommaaccent'] = 278;
  50065. t['logicalnot'] = 584;
  50066. t['odieresis'] = 556;
  50067. t['udieresis'] = 556;
  50068. t['notequal'] = 549;
  50069. t['gcommaaccent'] = 556;
  50070. t['eth'] = 556;
  50071. t['zcaron'] = 500;
  50072. t['ncommaaccent'] = 556;
  50073. t['onesuperior'] = 333;
  50074. t['imacron'] = 278;
  50075. t['Euro'] = 556;
  50076. });
  50077. t['Helvetica-Bold'] = getLookupTableFactory(function (t) {
  50078. t['space'] = 278;
  50079. t['exclam'] = 333;
  50080. t['quotedbl'] = 474;
  50081. t['numbersign'] = 556;
  50082. t['dollar'] = 556;
  50083. t['percent'] = 889;
  50084. t['ampersand'] = 722;
  50085. t['quoteright'] = 278;
  50086. t['parenleft'] = 333;
  50087. t['parenright'] = 333;
  50088. t['asterisk'] = 389;
  50089. t['plus'] = 584;
  50090. t['comma'] = 278;
  50091. t['hyphen'] = 333;
  50092. t['period'] = 278;
  50093. t['slash'] = 278;
  50094. t['zero'] = 556;
  50095. t['one'] = 556;
  50096. t['two'] = 556;
  50097. t['three'] = 556;
  50098. t['four'] = 556;
  50099. t['five'] = 556;
  50100. t['six'] = 556;
  50101. t['seven'] = 556;
  50102. t['eight'] = 556;
  50103. t['nine'] = 556;
  50104. t['colon'] = 333;
  50105. t['semicolon'] = 333;
  50106. t['less'] = 584;
  50107. t['equal'] = 584;
  50108. t['greater'] = 584;
  50109. t['question'] = 611;
  50110. t['at'] = 975;
  50111. t['A'] = 722;
  50112. t['B'] = 722;
  50113. t['C'] = 722;
  50114. t['D'] = 722;
  50115. t['E'] = 667;
  50116. t['F'] = 611;
  50117. t['G'] = 778;
  50118. t['H'] = 722;
  50119. t['I'] = 278;
  50120. t['J'] = 556;
  50121. t['K'] = 722;
  50122. t['L'] = 611;
  50123. t['M'] = 833;
  50124. t['N'] = 722;
  50125. t['O'] = 778;
  50126. t['P'] = 667;
  50127. t['Q'] = 778;
  50128. t['R'] = 722;
  50129. t['S'] = 667;
  50130. t['T'] = 611;
  50131. t['U'] = 722;
  50132. t['V'] = 667;
  50133. t['W'] = 944;
  50134. t['X'] = 667;
  50135. t['Y'] = 667;
  50136. t['Z'] = 611;
  50137. t['bracketleft'] = 333;
  50138. t['backslash'] = 278;
  50139. t['bracketright'] = 333;
  50140. t['asciicircum'] = 584;
  50141. t['underscore'] = 556;
  50142. t['quoteleft'] = 278;
  50143. t['a'] = 556;
  50144. t['b'] = 611;
  50145. t['c'] = 556;
  50146. t['d'] = 611;
  50147. t['e'] = 556;
  50148. t['f'] = 333;
  50149. t['g'] = 611;
  50150. t['h'] = 611;
  50151. t['i'] = 278;
  50152. t['j'] = 278;
  50153. t['k'] = 556;
  50154. t['l'] = 278;
  50155. t['m'] = 889;
  50156. t['n'] = 611;
  50157. t['o'] = 611;
  50158. t['p'] = 611;
  50159. t['q'] = 611;
  50160. t['r'] = 389;
  50161. t['s'] = 556;
  50162. t['t'] = 333;
  50163. t['u'] = 611;
  50164. t['v'] = 556;
  50165. t['w'] = 778;
  50166. t['x'] = 556;
  50167. t['y'] = 556;
  50168. t['z'] = 500;
  50169. t['braceleft'] = 389;
  50170. t['bar'] = 280;
  50171. t['braceright'] = 389;
  50172. t['asciitilde'] = 584;
  50173. t['exclamdown'] = 333;
  50174. t['cent'] = 556;
  50175. t['sterling'] = 556;
  50176. t['fraction'] = 167;
  50177. t['yen'] = 556;
  50178. t['florin'] = 556;
  50179. t['section'] = 556;
  50180. t['currency'] = 556;
  50181. t['quotesingle'] = 238;
  50182. t['quotedblleft'] = 500;
  50183. t['guillemotleft'] = 556;
  50184. t['guilsinglleft'] = 333;
  50185. t['guilsinglright'] = 333;
  50186. t['fi'] = 611;
  50187. t['fl'] = 611;
  50188. t['endash'] = 556;
  50189. t['dagger'] = 556;
  50190. t['daggerdbl'] = 556;
  50191. t['periodcentered'] = 278;
  50192. t['paragraph'] = 556;
  50193. t['bullet'] = 350;
  50194. t['quotesinglbase'] = 278;
  50195. t['quotedblbase'] = 500;
  50196. t['quotedblright'] = 500;
  50197. t['guillemotright'] = 556;
  50198. t['ellipsis'] = 1000;
  50199. t['perthousand'] = 1000;
  50200. t['questiondown'] = 611;
  50201. t['grave'] = 333;
  50202. t['acute'] = 333;
  50203. t['circumflex'] = 333;
  50204. t['tilde'] = 333;
  50205. t['macron'] = 333;
  50206. t['breve'] = 333;
  50207. t['dotaccent'] = 333;
  50208. t['dieresis'] = 333;
  50209. t['ring'] = 333;
  50210. t['cedilla'] = 333;
  50211. t['hungarumlaut'] = 333;
  50212. t['ogonek'] = 333;
  50213. t['caron'] = 333;
  50214. t['emdash'] = 1000;
  50215. t['AE'] = 1000;
  50216. t['ordfeminine'] = 370;
  50217. t['Lslash'] = 611;
  50218. t['Oslash'] = 778;
  50219. t['OE'] = 1000;
  50220. t['ordmasculine'] = 365;
  50221. t['ae'] = 889;
  50222. t['dotlessi'] = 278;
  50223. t['lslash'] = 278;
  50224. t['oslash'] = 611;
  50225. t['oe'] = 944;
  50226. t['germandbls'] = 611;
  50227. t['Idieresis'] = 278;
  50228. t['eacute'] = 556;
  50229. t['abreve'] = 556;
  50230. t['uhungarumlaut'] = 611;
  50231. t['ecaron'] = 556;
  50232. t['Ydieresis'] = 667;
  50233. t['divide'] = 584;
  50234. t['Yacute'] = 667;
  50235. t['Acircumflex'] = 722;
  50236. t['aacute'] = 556;
  50237. t['Ucircumflex'] = 722;
  50238. t['yacute'] = 556;
  50239. t['scommaaccent'] = 556;
  50240. t['ecircumflex'] = 556;
  50241. t['Uring'] = 722;
  50242. t['Udieresis'] = 722;
  50243. t['aogonek'] = 556;
  50244. t['Uacute'] = 722;
  50245. t['uogonek'] = 611;
  50246. t['Edieresis'] = 667;
  50247. t['Dcroat'] = 722;
  50248. t['commaaccent'] = 250;
  50249. t['copyright'] = 737;
  50250. t['Emacron'] = 667;
  50251. t['ccaron'] = 556;
  50252. t['aring'] = 556;
  50253. t['Ncommaaccent'] = 722;
  50254. t['lacute'] = 278;
  50255. t['agrave'] = 556;
  50256. t['Tcommaaccent'] = 611;
  50257. t['Cacute'] = 722;
  50258. t['atilde'] = 556;
  50259. t['Edotaccent'] = 667;
  50260. t['scaron'] = 556;
  50261. t['scedilla'] = 556;
  50262. t['iacute'] = 278;
  50263. t['lozenge'] = 494;
  50264. t['Rcaron'] = 722;
  50265. t['Gcommaaccent'] = 778;
  50266. t['ucircumflex'] = 611;
  50267. t['acircumflex'] = 556;
  50268. t['Amacron'] = 722;
  50269. t['rcaron'] = 389;
  50270. t['ccedilla'] = 556;
  50271. t['Zdotaccent'] = 611;
  50272. t['Thorn'] = 667;
  50273. t['Omacron'] = 778;
  50274. t['Racute'] = 722;
  50275. t['Sacute'] = 667;
  50276. t['dcaron'] = 743;
  50277. t['Umacron'] = 722;
  50278. t['uring'] = 611;
  50279. t['threesuperior'] = 333;
  50280. t['Ograve'] = 778;
  50281. t['Agrave'] = 722;
  50282. t['Abreve'] = 722;
  50283. t['multiply'] = 584;
  50284. t['uacute'] = 611;
  50285. t['Tcaron'] = 611;
  50286. t['partialdiff'] = 494;
  50287. t['ydieresis'] = 556;
  50288. t['Nacute'] = 722;
  50289. t['icircumflex'] = 278;
  50290. t['Ecircumflex'] = 667;
  50291. t['adieresis'] = 556;
  50292. t['edieresis'] = 556;
  50293. t['cacute'] = 556;
  50294. t['nacute'] = 611;
  50295. t['umacron'] = 611;
  50296. t['Ncaron'] = 722;
  50297. t['Iacute'] = 278;
  50298. t['plusminus'] = 584;
  50299. t['brokenbar'] = 280;
  50300. t['registered'] = 737;
  50301. t['Gbreve'] = 778;
  50302. t['Idotaccent'] = 278;
  50303. t['summation'] = 600;
  50304. t['Egrave'] = 667;
  50305. t['racute'] = 389;
  50306. t['omacron'] = 611;
  50307. t['Zacute'] = 611;
  50308. t['Zcaron'] = 611;
  50309. t['greaterequal'] = 549;
  50310. t['Eth'] = 722;
  50311. t['Ccedilla'] = 722;
  50312. t['lcommaaccent'] = 278;
  50313. t['tcaron'] = 389;
  50314. t['eogonek'] = 556;
  50315. t['Uogonek'] = 722;
  50316. t['Aacute'] = 722;
  50317. t['Adieresis'] = 722;
  50318. t['egrave'] = 556;
  50319. t['zacute'] = 500;
  50320. t['iogonek'] = 278;
  50321. t['Oacute'] = 778;
  50322. t['oacute'] = 611;
  50323. t['amacron'] = 556;
  50324. t['sacute'] = 556;
  50325. t['idieresis'] = 278;
  50326. t['Ocircumflex'] = 778;
  50327. t['Ugrave'] = 722;
  50328. t['Delta'] = 612;
  50329. t['thorn'] = 611;
  50330. t['twosuperior'] = 333;
  50331. t['Odieresis'] = 778;
  50332. t['mu'] = 611;
  50333. t['igrave'] = 278;
  50334. t['ohungarumlaut'] = 611;
  50335. t['Eogonek'] = 667;
  50336. t['dcroat'] = 611;
  50337. t['threequarters'] = 834;
  50338. t['Scedilla'] = 667;
  50339. t['lcaron'] = 400;
  50340. t['Kcommaaccent'] = 722;
  50341. t['Lacute'] = 611;
  50342. t['trademark'] = 1000;
  50343. t['edotaccent'] = 556;
  50344. t['Igrave'] = 278;
  50345. t['Imacron'] = 278;
  50346. t['Lcaron'] = 611;
  50347. t['onehalf'] = 834;
  50348. t['lessequal'] = 549;
  50349. t['ocircumflex'] = 611;
  50350. t['ntilde'] = 611;
  50351. t['Uhungarumlaut'] = 722;
  50352. t['Eacute'] = 667;
  50353. t['emacron'] = 556;
  50354. t['gbreve'] = 611;
  50355. t['onequarter'] = 834;
  50356. t['Scaron'] = 667;
  50357. t['Scommaaccent'] = 667;
  50358. t['Ohungarumlaut'] = 778;
  50359. t['degree'] = 400;
  50360. t['ograve'] = 611;
  50361. t['Ccaron'] = 722;
  50362. t['ugrave'] = 611;
  50363. t['radical'] = 549;
  50364. t['Dcaron'] = 722;
  50365. t['rcommaaccent'] = 389;
  50366. t['Ntilde'] = 722;
  50367. t['otilde'] = 611;
  50368. t['Rcommaaccent'] = 722;
  50369. t['Lcommaaccent'] = 611;
  50370. t['Atilde'] = 722;
  50371. t['Aogonek'] = 722;
  50372. t['Aring'] = 722;
  50373. t['Otilde'] = 778;
  50374. t['zdotaccent'] = 500;
  50375. t['Ecaron'] = 667;
  50376. t['Iogonek'] = 278;
  50377. t['kcommaaccent'] = 556;
  50378. t['minus'] = 584;
  50379. t['Icircumflex'] = 278;
  50380. t['ncaron'] = 611;
  50381. t['tcommaaccent'] = 333;
  50382. t['logicalnot'] = 584;
  50383. t['odieresis'] = 611;
  50384. t['udieresis'] = 611;
  50385. t['notequal'] = 549;
  50386. t['gcommaaccent'] = 611;
  50387. t['eth'] = 611;
  50388. t['zcaron'] = 500;
  50389. t['ncommaaccent'] = 611;
  50390. t['onesuperior'] = 333;
  50391. t['imacron'] = 278;
  50392. t['Euro'] = 556;
  50393. });
  50394. t['Helvetica-BoldOblique'] = getLookupTableFactory(function (t) {
  50395. t['space'] = 278;
  50396. t['exclam'] = 333;
  50397. t['quotedbl'] = 474;
  50398. t['numbersign'] = 556;
  50399. t['dollar'] = 556;
  50400. t['percent'] = 889;
  50401. t['ampersand'] = 722;
  50402. t['quoteright'] = 278;
  50403. t['parenleft'] = 333;
  50404. t['parenright'] = 333;
  50405. t['asterisk'] = 389;
  50406. t['plus'] = 584;
  50407. t['comma'] = 278;
  50408. t['hyphen'] = 333;
  50409. t['period'] = 278;
  50410. t['slash'] = 278;
  50411. t['zero'] = 556;
  50412. t['one'] = 556;
  50413. t['two'] = 556;
  50414. t['three'] = 556;
  50415. t['four'] = 556;
  50416. t['five'] = 556;
  50417. t['six'] = 556;
  50418. t['seven'] = 556;
  50419. t['eight'] = 556;
  50420. t['nine'] = 556;
  50421. t['colon'] = 333;
  50422. t['semicolon'] = 333;
  50423. t['less'] = 584;
  50424. t['equal'] = 584;
  50425. t['greater'] = 584;
  50426. t['question'] = 611;
  50427. t['at'] = 975;
  50428. t['A'] = 722;
  50429. t['B'] = 722;
  50430. t['C'] = 722;
  50431. t['D'] = 722;
  50432. t['E'] = 667;
  50433. t['F'] = 611;
  50434. t['G'] = 778;
  50435. t['H'] = 722;
  50436. t['I'] = 278;
  50437. t['J'] = 556;
  50438. t['K'] = 722;
  50439. t['L'] = 611;
  50440. t['M'] = 833;
  50441. t['N'] = 722;
  50442. t['O'] = 778;
  50443. t['P'] = 667;
  50444. t['Q'] = 778;
  50445. t['R'] = 722;
  50446. t['S'] = 667;
  50447. t['T'] = 611;
  50448. t['U'] = 722;
  50449. t['V'] = 667;
  50450. t['W'] = 944;
  50451. t['X'] = 667;
  50452. t['Y'] = 667;
  50453. t['Z'] = 611;
  50454. t['bracketleft'] = 333;
  50455. t['backslash'] = 278;
  50456. t['bracketright'] = 333;
  50457. t['asciicircum'] = 584;
  50458. t['underscore'] = 556;
  50459. t['quoteleft'] = 278;
  50460. t['a'] = 556;
  50461. t['b'] = 611;
  50462. t['c'] = 556;
  50463. t['d'] = 611;
  50464. t['e'] = 556;
  50465. t['f'] = 333;
  50466. t['g'] = 611;
  50467. t['h'] = 611;
  50468. t['i'] = 278;
  50469. t['j'] = 278;
  50470. t['k'] = 556;
  50471. t['l'] = 278;
  50472. t['m'] = 889;
  50473. t['n'] = 611;
  50474. t['o'] = 611;
  50475. t['p'] = 611;
  50476. t['q'] = 611;
  50477. t['r'] = 389;
  50478. t['s'] = 556;
  50479. t['t'] = 333;
  50480. t['u'] = 611;
  50481. t['v'] = 556;
  50482. t['w'] = 778;
  50483. t['x'] = 556;
  50484. t['y'] = 556;
  50485. t['z'] = 500;
  50486. t['braceleft'] = 389;
  50487. t['bar'] = 280;
  50488. t['braceright'] = 389;
  50489. t['asciitilde'] = 584;
  50490. t['exclamdown'] = 333;
  50491. t['cent'] = 556;
  50492. t['sterling'] = 556;
  50493. t['fraction'] = 167;
  50494. t['yen'] = 556;
  50495. t['florin'] = 556;
  50496. t['section'] = 556;
  50497. t['currency'] = 556;
  50498. t['quotesingle'] = 238;
  50499. t['quotedblleft'] = 500;
  50500. t['guillemotleft'] = 556;
  50501. t['guilsinglleft'] = 333;
  50502. t['guilsinglright'] = 333;
  50503. t['fi'] = 611;
  50504. t['fl'] = 611;
  50505. t['endash'] = 556;
  50506. t['dagger'] = 556;
  50507. t['daggerdbl'] = 556;
  50508. t['periodcentered'] = 278;
  50509. t['paragraph'] = 556;
  50510. t['bullet'] = 350;
  50511. t['quotesinglbase'] = 278;
  50512. t['quotedblbase'] = 500;
  50513. t['quotedblright'] = 500;
  50514. t['guillemotright'] = 556;
  50515. t['ellipsis'] = 1000;
  50516. t['perthousand'] = 1000;
  50517. t['questiondown'] = 611;
  50518. t['grave'] = 333;
  50519. t['acute'] = 333;
  50520. t['circumflex'] = 333;
  50521. t['tilde'] = 333;
  50522. t['macron'] = 333;
  50523. t['breve'] = 333;
  50524. t['dotaccent'] = 333;
  50525. t['dieresis'] = 333;
  50526. t['ring'] = 333;
  50527. t['cedilla'] = 333;
  50528. t['hungarumlaut'] = 333;
  50529. t['ogonek'] = 333;
  50530. t['caron'] = 333;
  50531. t['emdash'] = 1000;
  50532. t['AE'] = 1000;
  50533. t['ordfeminine'] = 370;
  50534. t['Lslash'] = 611;
  50535. t['Oslash'] = 778;
  50536. t['OE'] = 1000;
  50537. t['ordmasculine'] = 365;
  50538. t['ae'] = 889;
  50539. t['dotlessi'] = 278;
  50540. t['lslash'] = 278;
  50541. t['oslash'] = 611;
  50542. t['oe'] = 944;
  50543. t['germandbls'] = 611;
  50544. t['Idieresis'] = 278;
  50545. t['eacute'] = 556;
  50546. t['abreve'] = 556;
  50547. t['uhungarumlaut'] = 611;
  50548. t['ecaron'] = 556;
  50549. t['Ydieresis'] = 667;
  50550. t['divide'] = 584;
  50551. t['Yacute'] = 667;
  50552. t['Acircumflex'] = 722;
  50553. t['aacute'] = 556;
  50554. t['Ucircumflex'] = 722;
  50555. t['yacute'] = 556;
  50556. t['scommaaccent'] = 556;
  50557. t['ecircumflex'] = 556;
  50558. t['Uring'] = 722;
  50559. t['Udieresis'] = 722;
  50560. t['aogonek'] = 556;
  50561. t['Uacute'] = 722;
  50562. t['uogonek'] = 611;
  50563. t['Edieresis'] = 667;
  50564. t['Dcroat'] = 722;
  50565. t['commaaccent'] = 250;
  50566. t['copyright'] = 737;
  50567. t['Emacron'] = 667;
  50568. t['ccaron'] = 556;
  50569. t['aring'] = 556;
  50570. t['Ncommaaccent'] = 722;
  50571. t['lacute'] = 278;
  50572. t['agrave'] = 556;
  50573. t['Tcommaaccent'] = 611;
  50574. t['Cacute'] = 722;
  50575. t['atilde'] = 556;
  50576. t['Edotaccent'] = 667;
  50577. t['scaron'] = 556;
  50578. t['scedilla'] = 556;
  50579. t['iacute'] = 278;
  50580. t['lozenge'] = 494;
  50581. t['Rcaron'] = 722;
  50582. t['Gcommaaccent'] = 778;
  50583. t['ucircumflex'] = 611;
  50584. t['acircumflex'] = 556;
  50585. t['Amacron'] = 722;
  50586. t['rcaron'] = 389;
  50587. t['ccedilla'] = 556;
  50588. t['Zdotaccent'] = 611;
  50589. t['Thorn'] = 667;
  50590. t['Omacron'] = 778;
  50591. t['Racute'] = 722;
  50592. t['Sacute'] = 667;
  50593. t['dcaron'] = 743;
  50594. t['Umacron'] = 722;
  50595. t['uring'] = 611;
  50596. t['threesuperior'] = 333;
  50597. t['Ograve'] = 778;
  50598. t['Agrave'] = 722;
  50599. t['Abreve'] = 722;
  50600. t['multiply'] = 584;
  50601. t['uacute'] = 611;
  50602. t['Tcaron'] = 611;
  50603. t['partialdiff'] = 494;
  50604. t['ydieresis'] = 556;
  50605. t['Nacute'] = 722;
  50606. t['icircumflex'] = 278;
  50607. t['Ecircumflex'] = 667;
  50608. t['adieresis'] = 556;
  50609. t['edieresis'] = 556;
  50610. t['cacute'] = 556;
  50611. t['nacute'] = 611;
  50612. t['umacron'] = 611;
  50613. t['Ncaron'] = 722;
  50614. t['Iacute'] = 278;
  50615. t['plusminus'] = 584;
  50616. t['brokenbar'] = 280;
  50617. t['registered'] = 737;
  50618. t['Gbreve'] = 778;
  50619. t['Idotaccent'] = 278;
  50620. t['summation'] = 600;
  50621. t['Egrave'] = 667;
  50622. t['racute'] = 389;
  50623. t['omacron'] = 611;
  50624. t['Zacute'] = 611;
  50625. t['Zcaron'] = 611;
  50626. t['greaterequal'] = 549;
  50627. t['Eth'] = 722;
  50628. t['Ccedilla'] = 722;
  50629. t['lcommaaccent'] = 278;
  50630. t['tcaron'] = 389;
  50631. t['eogonek'] = 556;
  50632. t['Uogonek'] = 722;
  50633. t['Aacute'] = 722;
  50634. t['Adieresis'] = 722;
  50635. t['egrave'] = 556;
  50636. t['zacute'] = 500;
  50637. t['iogonek'] = 278;
  50638. t['Oacute'] = 778;
  50639. t['oacute'] = 611;
  50640. t['amacron'] = 556;
  50641. t['sacute'] = 556;
  50642. t['idieresis'] = 278;
  50643. t['Ocircumflex'] = 778;
  50644. t['Ugrave'] = 722;
  50645. t['Delta'] = 612;
  50646. t['thorn'] = 611;
  50647. t['twosuperior'] = 333;
  50648. t['Odieresis'] = 778;
  50649. t['mu'] = 611;
  50650. t['igrave'] = 278;
  50651. t['ohungarumlaut'] = 611;
  50652. t['Eogonek'] = 667;
  50653. t['dcroat'] = 611;
  50654. t['threequarters'] = 834;
  50655. t['Scedilla'] = 667;
  50656. t['lcaron'] = 400;
  50657. t['Kcommaaccent'] = 722;
  50658. t['Lacute'] = 611;
  50659. t['trademark'] = 1000;
  50660. t['edotaccent'] = 556;
  50661. t['Igrave'] = 278;
  50662. t['Imacron'] = 278;
  50663. t['Lcaron'] = 611;
  50664. t['onehalf'] = 834;
  50665. t['lessequal'] = 549;
  50666. t['ocircumflex'] = 611;
  50667. t['ntilde'] = 611;
  50668. t['Uhungarumlaut'] = 722;
  50669. t['Eacute'] = 667;
  50670. t['emacron'] = 556;
  50671. t['gbreve'] = 611;
  50672. t['onequarter'] = 834;
  50673. t['Scaron'] = 667;
  50674. t['Scommaaccent'] = 667;
  50675. t['Ohungarumlaut'] = 778;
  50676. t['degree'] = 400;
  50677. t['ograve'] = 611;
  50678. t['Ccaron'] = 722;
  50679. t['ugrave'] = 611;
  50680. t['radical'] = 549;
  50681. t['Dcaron'] = 722;
  50682. t['rcommaaccent'] = 389;
  50683. t['Ntilde'] = 722;
  50684. t['otilde'] = 611;
  50685. t['Rcommaaccent'] = 722;
  50686. t['Lcommaaccent'] = 611;
  50687. t['Atilde'] = 722;
  50688. t['Aogonek'] = 722;
  50689. t['Aring'] = 722;
  50690. t['Otilde'] = 778;
  50691. t['zdotaccent'] = 500;
  50692. t['Ecaron'] = 667;
  50693. t['Iogonek'] = 278;
  50694. t['kcommaaccent'] = 556;
  50695. t['minus'] = 584;
  50696. t['Icircumflex'] = 278;
  50697. t['ncaron'] = 611;
  50698. t['tcommaaccent'] = 333;
  50699. t['logicalnot'] = 584;
  50700. t['odieresis'] = 611;
  50701. t['udieresis'] = 611;
  50702. t['notequal'] = 549;
  50703. t['gcommaaccent'] = 611;
  50704. t['eth'] = 611;
  50705. t['zcaron'] = 500;
  50706. t['ncommaaccent'] = 611;
  50707. t['onesuperior'] = 333;
  50708. t['imacron'] = 278;
  50709. t['Euro'] = 556;
  50710. });
  50711. t['Helvetica-Oblique'] = getLookupTableFactory(function (t) {
  50712. t['space'] = 278;
  50713. t['exclam'] = 278;
  50714. t['quotedbl'] = 355;
  50715. t['numbersign'] = 556;
  50716. t['dollar'] = 556;
  50717. t['percent'] = 889;
  50718. t['ampersand'] = 667;
  50719. t['quoteright'] = 222;
  50720. t['parenleft'] = 333;
  50721. t['parenright'] = 333;
  50722. t['asterisk'] = 389;
  50723. t['plus'] = 584;
  50724. t['comma'] = 278;
  50725. t['hyphen'] = 333;
  50726. t['period'] = 278;
  50727. t['slash'] = 278;
  50728. t['zero'] = 556;
  50729. t['one'] = 556;
  50730. t['two'] = 556;
  50731. t['three'] = 556;
  50732. t['four'] = 556;
  50733. t['five'] = 556;
  50734. t['six'] = 556;
  50735. t['seven'] = 556;
  50736. t['eight'] = 556;
  50737. t['nine'] = 556;
  50738. t['colon'] = 278;
  50739. t['semicolon'] = 278;
  50740. t['less'] = 584;
  50741. t['equal'] = 584;
  50742. t['greater'] = 584;
  50743. t['question'] = 556;
  50744. t['at'] = 1015;
  50745. t['A'] = 667;
  50746. t['B'] = 667;
  50747. t['C'] = 722;
  50748. t['D'] = 722;
  50749. t['E'] = 667;
  50750. t['F'] = 611;
  50751. t['G'] = 778;
  50752. t['H'] = 722;
  50753. t['I'] = 278;
  50754. t['J'] = 500;
  50755. t['K'] = 667;
  50756. t['L'] = 556;
  50757. t['M'] = 833;
  50758. t['N'] = 722;
  50759. t['O'] = 778;
  50760. t['P'] = 667;
  50761. t['Q'] = 778;
  50762. t['R'] = 722;
  50763. t['S'] = 667;
  50764. t['T'] = 611;
  50765. t['U'] = 722;
  50766. t['V'] = 667;
  50767. t['W'] = 944;
  50768. t['X'] = 667;
  50769. t['Y'] = 667;
  50770. t['Z'] = 611;
  50771. t['bracketleft'] = 278;
  50772. t['backslash'] = 278;
  50773. t['bracketright'] = 278;
  50774. t['asciicircum'] = 469;
  50775. t['underscore'] = 556;
  50776. t['quoteleft'] = 222;
  50777. t['a'] = 556;
  50778. t['b'] = 556;
  50779. t['c'] = 500;
  50780. t['d'] = 556;
  50781. t['e'] = 556;
  50782. t['f'] = 278;
  50783. t['g'] = 556;
  50784. t['h'] = 556;
  50785. t['i'] = 222;
  50786. t['j'] = 222;
  50787. t['k'] = 500;
  50788. t['l'] = 222;
  50789. t['m'] = 833;
  50790. t['n'] = 556;
  50791. t['o'] = 556;
  50792. t['p'] = 556;
  50793. t['q'] = 556;
  50794. t['r'] = 333;
  50795. t['s'] = 500;
  50796. t['t'] = 278;
  50797. t['u'] = 556;
  50798. t['v'] = 500;
  50799. t['w'] = 722;
  50800. t['x'] = 500;
  50801. t['y'] = 500;
  50802. t['z'] = 500;
  50803. t['braceleft'] = 334;
  50804. t['bar'] = 260;
  50805. t['braceright'] = 334;
  50806. t['asciitilde'] = 584;
  50807. t['exclamdown'] = 333;
  50808. t['cent'] = 556;
  50809. t['sterling'] = 556;
  50810. t['fraction'] = 167;
  50811. t['yen'] = 556;
  50812. t['florin'] = 556;
  50813. t['section'] = 556;
  50814. t['currency'] = 556;
  50815. t['quotesingle'] = 191;
  50816. t['quotedblleft'] = 333;
  50817. t['guillemotleft'] = 556;
  50818. t['guilsinglleft'] = 333;
  50819. t['guilsinglright'] = 333;
  50820. t['fi'] = 500;
  50821. t['fl'] = 500;
  50822. t['endash'] = 556;
  50823. t['dagger'] = 556;
  50824. t['daggerdbl'] = 556;
  50825. t['periodcentered'] = 278;
  50826. t['paragraph'] = 537;
  50827. t['bullet'] = 350;
  50828. t['quotesinglbase'] = 222;
  50829. t['quotedblbase'] = 333;
  50830. t['quotedblright'] = 333;
  50831. t['guillemotright'] = 556;
  50832. t['ellipsis'] = 1000;
  50833. t['perthousand'] = 1000;
  50834. t['questiondown'] = 611;
  50835. t['grave'] = 333;
  50836. t['acute'] = 333;
  50837. t['circumflex'] = 333;
  50838. t['tilde'] = 333;
  50839. t['macron'] = 333;
  50840. t['breve'] = 333;
  50841. t['dotaccent'] = 333;
  50842. t['dieresis'] = 333;
  50843. t['ring'] = 333;
  50844. t['cedilla'] = 333;
  50845. t['hungarumlaut'] = 333;
  50846. t['ogonek'] = 333;
  50847. t['caron'] = 333;
  50848. t['emdash'] = 1000;
  50849. t['AE'] = 1000;
  50850. t['ordfeminine'] = 370;
  50851. t['Lslash'] = 556;
  50852. t['Oslash'] = 778;
  50853. t['OE'] = 1000;
  50854. t['ordmasculine'] = 365;
  50855. t['ae'] = 889;
  50856. t['dotlessi'] = 278;
  50857. t['lslash'] = 222;
  50858. t['oslash'] = 611;
  50859. t['oe'] = 944;
  50860. t['germandbls'] = 611;
  50861. t['Idieresis'] = 278;
  50862. t['eacute'] = 556;
  50863. t['abreve'] = 556;
  50864. t['uhungarumlaut'] = 556;
  50865. t['ecaron'] = 556;
  50866. t['Ydieresis'] = 667;
  50867. t['divide'] = 584;
  50868. t['Yacute'] = 667;
  50869. t['Acircumflex'] = 667;
  50870. t['aacute'] = 556;
  50871. t['Ucircumflex'] = 722;
  50872. t['yacute'] = 500;
  50873. t['scommaaccent'] = 500;
  50874. t['ecircumflex'] = 556;
  50875. t['Uring'] = 722;
  50876. t['Udieresis'] = 722;
  50877. t['aogonek'] = 556;
  50878. t['Uacute'] = 722;
  50879. t['uogonek'] = 556;
  50880. t['Edieresis'] = 667;
  50881. t['Dcroat'] = 722;
  50882. t['commaaccent'] = 250;
  50883. t['copyright'] = 737;
  50884. t['Emacron'] = 667;
  50885. t['ccaron'] = 500;
  50886. t['aring'] = 556;
  50887. t['Ncommaaccent'] = 722;
  50888. t['lacute'] = 222;
  50889. t['agrave'] = 556;
  50890. t['Tcommaaccent'] = 611;
  50891. t['Cacute'] = 722;
  50892. t['atilde'] = 556;
  50893. t['Edotaccent'] = 667;
  50894. t['scaron'] = 500;
  50895. t['scedilla'] = 500;
  50896. t['iacute'] = 278;
  50897. t['lozenge'] = 471;
  50898. t['Rcaron'] = 722;
  50899. t['Gcommaaccent'] = 778;
  50900. t['ucircumflex'] = 556;
  50901. t['acircumflex'] = 556;
  50902. t['Amacron'] = 667;
  50903. t['rcaron'] = 333;
  50904. t['ccedilla'] = 500;
  50905. t['Zdotaccent'] = 611;
  50906. t['Thorn'] = 667;
  50907. t['Omacron'] = 778;
  50908. t['Racute'] = 722;
  50909. t['Sacute'] = 667;
  50910. t['dcaron'] = 643;
  50911. t['Umacron'] = 722;
  50912. t['uring'] = 556;
  50913. t['threesuperior'] = 333;
  50914. t['Ograve'] = 778;
  50915. t['Agrave'] = 667;
  50916. t['Abreve'] = 667;
  50917. t['multiply'] = 584;
  50918. t['uacute'] = 556;
  50919. t['Tcaron'] = 611;
  50920. t['partialdiff'] = 476;
  50921. t['ydieresis'] = 500;
  50922. t['Nacute'] = 722;
  50923. t['icircumflex'] = 278;
  50924. t['Ecircumflex'] = 667;
  50925. t['adieresis'] = 556;
  50926. t['edieresis'] = 556;
  50927. t['cacute'] = 500;
  50928. t['nacute'] = 556;
  50929. t['umacron'] = 556;
  50930. t['Ncaron'] = 722;
  50931. t['Iacute'] = 278;
  50932. t['plusminus'] = 584;
  50933. t['brokenbar'] = 260;
  50934. t['registered'] = 737;
  50935. t['Gbreve'] = 778;
  50936. t['Idotaccent'] = 278;
  50937. t['summation'] = 600;
  50938. t['Egrave'] = 667;
  50939. t['racute'] = 333;
  50940. t['omacron'] = 556;
  50941. t['Zacute'] = 611;
  50942. t['Zcaron'] = 611;
  50943. t['greaterequal'] = 549;
  50944. t['Eth'] = 722;
  50945. t['Ccedilla'] = 722;
  50946. t['lcommaaccent'] = 222;
  50947. t['tcaron'] = 317;
  50948. t['eogonek'] = 556;
  50949. t['Uogonek'] = 722;
  50950. t['Aacute'] = 667;
  50951. t['Adieresis'] = 667;
  50952. t['egrave'] = 556;
  50953. t['zacute'] = 500;
  50954. t['iogonek'] = 222;
  50955. t['Oacute'] = 778;
  50956. t['oacute'] = 556;
  50957. t['amacron'] = 556;
  50958. t['sacute'] = 500;
  50959. t['idieresis'] = 278;
  50960. t['Ocircumflex'] = 778;
  50961. t['Ugrave'] = 722;
  50962. t['Delta'] = 612;
  50963. t['thorn'] = 556;
  50964. t['twosuperior'] = 333;
  50965. t['Odieresis'] = 778;
  50966. t['mu'] = 556;
  50967. t['igrave'] = 278;
  50968. t['ohungarumlaut'] = 556;
  50969. t['Eogonek'] = 667;
  50970. t['dcroat'] = 556;
  50971. t['threequarters'] = 834;
  50972. t['Scedilla'] = 667;
  50973. t['lcaron'] = 299;
  50974. t['Kcommaaccent'] = 667;
  50975. t['Lacute'] = 556;
  50976. t['trademark'] = 1000;
  50977. t['edotaccent'] = 556;
  50978. t['Igrave'] = 278;
  50979. t['Imacron'] = 278;
  50980. t['Lcaron'] = 556;
  50981. t['onehalf'] = 834;
  50982. t['lessequal'] = 549;
  50983. t['ocircumflex'] = 556;
  50984. t['ntilde'] = 556;
  50985. t['Uhungarumlaut'] = 722;
  50986. t['Eacute'] = 667;
  50987. t['emacron'] = 556;
  50988. t['gbreve'] = 556;
  50989. t['onequarter'] = 834;
  50990. t['Scaron'] = 667;
  50991. t['Scommaaccent'] = 667;
  50992. t['Ohungarumlaut'] = 778;
  50993. t['degree'] = 400;
  50994. t['ograve'] = 556;
  50995. t['Ccaron'] = 722;
  50996. t['ugrave'] = 556;
  50997. t['radical'] = 453;
  50998. t['Dcaron'] = 722;
  50999. t['rcommaaccent'] = 333;
  51000. t['Ntilde'] = 722;
  51001. t['otilde'] = 556;
  51002. t['Rcommaaccent'] = 722;
  51003. t['Lcommaaccent'] = 556;
  51004. t['Atilde'] = 667;
  51005. t['Aogonek'] = 667;
  51006. t['Aring'] = 667;
  51007. t['Otilde'] = 778;
  51008. t['zdotaccent'] = 500;
  51009. t['Ecaron'] = 667;
  51010. t['Iogonek'] = 278;
  51011. t['kcommaaccent'] = 500;
  51012. t['minus'] = 584;
  51013. t['Icircumflex'] = 278;
  51014. t['ncaron'] = 556;
  51015. t['tcommaaccent'] = 278;
  51016. t['logicalnot'] = 584;
  51017. t['odieresis'] = 556;
  51018. t['udieresis'] = 556;
  51019. t['notequal'] = 549;
  51020. t['gcommaaccent'] = 556;
  51021. t['eth'] = 556;
  51022. t['zcaron'] = 500;
  51023. t['ncommaaccent'] = 556;
  51024. t['onesuperior'] = 333;
  51025. t['imacron'] = 278;
  51026. t['Euro'] = 556;
  51027. });
  51028. t['Symbol'] = getLookupTableFactory(function (t) {
  51029. t['space'] = 250;
  51030. t['exclam'] = 333;
  51031. t['universal'] = 713;
  51032. t['numbersign'] = 500;
  51033. t['existential'] = 549;
  51034. t['percent'] = 833;
  51035. t['ampersand'] = 778;
  51036. t['suchthat'] = 439;
  51037. t['parenleft'] = 333;
  51038. t['parenright'] = 333;
  51039. t['asteriskmath'] = 500;
  51040. t['plus'] = 549;
  51041. t['comma'] = 250;
  51042. t['minus'] = 549;
  51043. t['period'] = 250;
  51044. t['slash'] = 278;
  51045. t['zero'] = 500;
  51046. t['one'] = 500;
  51047. t['two'] = 500;
  51048. t['three'] = 500;
  51049. t['four'] = 500;
  51050. t['five'] = 500;
  51051. t['six'] = 500;
  51052. t['seven'] = 500;
  51053. t['eight'] = 500;
  51054. t['nine'] = 500;
  51055. t['colon'] = 278;
  51056. t['semicolon'] = 278;
  51057. t['less'] = 549;
  51058. t['equal'] = 549;
  51059. t['greater'] = 549;
  51060. t['question'] = 444;
  51061. t['congruent'] = 549;
  51062. t['Alpha'] = 722;
  51063. t['Beta'] = 667;
  51064. t['Chi'] = 722;
  51065. t['Delta'] = 612;
  51066. t['Epsilon'] = 611;
  51067. t['Phi'] = 763;
  51068. t['Gamma'] = 603;
  51069. t['Eta'] = 722;
  51070. t['Iota'] = 333;
  51071. t['theta1'] = 631;
  51072. t['Kappa'] = 722;
  51073. t['Lambda'] = 686;
  51074. t['Mu'] = 889;
  51075. t['Nu'] = 722;
  51076. t['Omicron'] = 722;
  51077. t['Pi'] = 768;
  51078. t['Theta'] = 741;
  51079. t['Rho'] = 556;
  51080. t['Sigma'] = 592;
  51081. t['Tau'] = 611;
  51082. t['Upsilon'] = 690;
  51083. t['sigma1'] = 439;
  51084. t['Omega'] = 768;
  51085. t['Xi'] = 645;
  51086. t['Psi'] = 795;
  51087. t['Zeta'] = 611;
  51088. t['bracketleft'] = 333;
  51089. t['therefore'] = 863;
  51090. t['bracketright'] = 333;
  51091. t['perpendicular'] = 658;
  51092. t['underscore'] = 500;
  51093. t['radicalex'] = 500;
  51094. t['alpha'] = 631;
  51095. t['beta'] = 549;
  51096. t['chi'] = 549;
  51097. t['delta'] = 494;
  51098. t['epsilon'] = 439;
  51099. t['phi'] = 521;
  51100. t['gamma'] = 411;
  51101. t['eta'] = 603;
  51102. t['iota'] = 329;
  51103. t['phi1'] = 603;
  51104. t['kappa'] = 549;
  51105. t['lambda'] = 549;
  51106. t['mu'] = 576;
  51107. t['nu'] = 521;
  51108. t['omicron'] = 549;
  51109. t['pi'] = 549;
  51110. t['theta'] = 521;
  51111. t['rho'] = 549;
  51112. t['sigma'] = 603;
  51113. t['tau'] = 439;
  51114. t['upsilon'] = 576;
  51115. t['omega1'] = 713;
  51116. t['omega'] = 686;
  51117. t['xi'] = 493;
  51118. t['psi'] = 686;
  51119. t['zeta'] = 494;
  51120. t['braceleft'] = 480;
  51121. t['bar'] = 200;
  51122. t['braceright'] = 480;
  51123. t['similar'] = 549;
  51124. t['Euro'] = 750;
  51125. t['Upsilon1'] = 620;
  51126. t['minute'] = 247;
  51127. t['lessequal'] = 549;
  51128. t['fraction'] = 167;
  51129. t['infinity'] = 713;
  51130. t['florin'] = 500;
  51131. t['club'] = 753;
  51132. t['diamond'] = 753;
  51133. t['heart'] = 753;
  51134. t['spade'] = 753;
  51135. t['arrowboth'] = 1042;
  51136. t['arrowleft'] = 987;
  51137. t['arrowup'] = 603;
  51138. t['arrowright'] = 987;
  51139. t['arrowdown'] = 603;
  51140. t['degree'] = 400;
  51141. t['plusminus'] = 549;
  51142. t['second'] = 411;
  51143. t['greaterequal'] = 549;
  51144. t['multiply'] = 549;
  51145. t['proportional'] = 713;
  51146. t['partialdiff'] = 494;
  51147. t['bullet'] = 460;
  51148. t['divide'] = 549;
  51149. t['notequal'] = 549;
  51150. t['equivalence'] = 549;
  51151. t['approxequal'] = 549;
  51152. t['ellipsis'] = 1000;
  51153. t['arrowvertex'] = 603;
  51154. t['arrowhorizex'] = 1000;
  51155. t['carriagereturn'] = 658;
  51156. t['aleph'] = 823;
  51157. t['Ifraktur'] = 686;
  51158. t['Rfraktur'] = 795;
  51159. t['weierstrass'] = 987;
  51160. t['circlemultiply'] = 768;
  51161. t['circleplus'] = 768;
  51162. t['emptyset'] = 823;
  51163. t['intersection'] = 768;
  51164. t['union'] = 768;
  51165. t['propersuperset'] = 713;
  51166. t['reflexsuperset'] = 713;
  51167. t['notsubset'] = 713;
  51168. t['propersubset'] = 713;
  51169. t['reflexsubset'] = 713;
  51170. t['element'] = 713;
  51171. t['notelement'] = 713;
  51172. t['angle'] = 768;
  51173. t['gradient'] = 713;
  51174. t['registerserif'] = 790;
  51175. t['copyrightserif'] = 790;
  51176. t['trademarkserif'] = 890;
  51177. t['product'] = 823;
  51178. t['radical'] = 549;
  51179. t['dotmath'] = 250;
  51180. t['logicalnot'] = 713;
  51181. t['logicaland'] = 603;
  51182. t['logicalor'] = 603;
  51183. t['arrowdblboth'] = 1042;
  51184. t['arrowdblleft'] = 987;
  51185. t['arrowdblup'] = 603;
  51186. t['arrowdblright'] = 987;
  51187. t['arrowdbldown'] = 603;
  51188. t['lozenge'] = 494;
  51189. t['angleleft'] = 329;
  51190. t['registersans'] = 790;
  51191. t['copyrightsans'] = 790;
  51192. t['trademarksans'] = 786;
  51193. t['summation'] = 713;
  51194. t['parenlefttp'] = 384;
  51195. t['parenleftex'] = 384;
  51196. t['parenleftbt'] = 384;
  51197. t['bracketlefttp'] = 384;
  51198. t['bracketleftex'] = 384;
  51199. t['bracketleftbt'] = 384;
  51200. t['bracelefttp'] = 494;
  51201. t['braceleftmid'] = 494;
  51202. t['braceleftbt'] = 494;
  51203. t['braceex'] = 494;
  51204. t['angleright'] = 329;
  51205. t['integral'] = 274;
  51206. t['integraltp'] = 686;
  51207. t['integralex'] = 686;
  51208. t['integralbt'] = 686;
  51209. t['parenrighttp'] = 384;
  51210. t['parenrightex'] = 384;
  51211. t['parenrightbt'] = 384;
  51212. t['bracketrighttp'] = 384;
  51213. t['bracketrightex'] = 384;
  51214. t['bracketrightbt'] = 384;
  51215. t['bracerighttp'] = 494;
  51216. t['bracerightmid'] = 494;
  51217. t['bracerightbt'] = 494;
  51218. t['apple'] = 790;
  51219. });
  51220. t['Times-Roman'] = getLookupTableFactory(function (t) {
  51221. t['space'] = 250;
  51222. t['exclam'] = 333;
  51223. t['quotedbl'] = 408;
  51224. t['numbersign'] = 500;
  51225. t['dollar'] = 500;
  51226. t['percent'] = 833;
  51227. t['ampersand'] = 778;
  51228. t['quoteright'] = 333;
  51229. t['parenleft'] = 333;
  51230. t['parenright'] = 333;
  51231. t['asterisk'] = 500;
  51232. t['plus'] = 564;
  51233. t['comma'] = 250;
  51234. t['hyphen'] = 333;
  51235. t['period'] = 250;
  51236. t['slash'] = 278;
  51237. t['zero'] = 500;
  51238. t['one'] = 500;
  51239. t['two'] = 500;
  51240. t['three'] = 500;
  51241. t['four'] = 500;
  51242. t['five'] = 500;
  51243. t['six'] = 500;
  51244. t['seven'] = 500;
  51245. t['eight'] = 500;
  51246. t['nine'] = 500;
  51247. t['colon'] = 278;
  51248. t['semicolon'] = 278;
  51249. t['less'] = 564;
  51250. t['equal'] = 564;
  51251. t['greater'] = 564;
  51252. t['question'] = 444;
  51253. t['at'] = 921;
  51254. t['A'] = 722;
  51255. t['B'] = 667;
  51256. t['C'] = 667;
  51257. t['D'] = 722;
  51258. t['E'] = 611;
  51259. t['F'] = 556;
  51260. t['G'] = 722;
  51261. t['H'] = 722;
  51262. t['I'] = 333;
  51263. t['J'] = 389;
  51264. t['K'] = 722;
  51265. t['L'] = 611;
  51266. t['M'] = 889;
  51267. t['N'] = 722;
  51268. t['O'] = 722;
  51269. t['P'] = 556;
  51270. t['Q'] = 722;
  51271. t['R'] = 667;
  51272. t['S'] = 556;
  51273. t['T'] = 611;
  51274. t['U'] = 722;
  51275. t['V'] = 722;
  51276. t['W'] = 944;
  51277. t['X'] = 722;
  51278. t['Y'] = 722;
  51279. t['Z'] = 611;
  51280. t['bracketleft'] = 333;
  51281. t['backslash'] = 278;
  51282. t['bracketright'] = 333;
  51283. t['asciicircum'] = 469;
  51284. t['underscore'] = 500;
  51285. t['quoteleft'] = 333;
  51286. t['a'] = 444;
  51287. t['b'] = 500;
  51288. t['c'] = 444;
  51289. t['d'] = 500;
  51290. t['e'] = 444;
  51291. t['f'] = 333;
  51292. t['g'] = 500;
  51293. t['h'] = 500;
  51294. t['i'] = 278;
  51295. t['j'] = 278;
  51296. t['k'] = 500;
  51297. t['l'] = 278;
  51298. t['m'] = 778;
  51299. t['n'] = 500;
  51300. t['o'] = 500;
  51301. t['p'] = 500;
  51302. t['q'] = 500;
  51303. t['r'] = 333;
  51304. t['s'] = 389;
  51305. t['t'] = 278;
  51306. t['u'] = 500;
  51307. t['v'] = 500;
  51308. t['w'] = 722;
  51309. t['x'] = 500;
  51310. t['y'] = 500;
  51311. t['z'] = 444;
  51312. t['braceleft'] = 480;
  51313. t['bar'] = 200;
  51314. t['braceright'] = 480;
  51315. t['asciitilde'] = 541;
  51316. t['exclamdown'] = 333;
  51317. t['cent'] = 500;
  51318. t['sterling'] = 500;
  51319. t['fraction'] = 167;
  51320. t['yen'] = 500;
  51321. t['florin'] = 500;
  51322. t['section'] = 500;
  51323. t['currency'] = 500;
  51324. t['quotesingle'] = 180;
  51325. t['quotedblleft'] = 444;
  51326. t['guillemotleft'] = 500;
  51327. t['guilsinglleft'] = 333;
  51328. t['guilsinglright'] = 333;
  51329. t['fi'] = 556;
  51330. t['fl'] = 556;
  51331. t['endash'] = 500;
  51332. t['dagger'] = 500;
  51333. t['daggerdbl'] = 500;
  51334. t['periodcentered'] = 250;
  51335. t['paragraph'] = 453;
  51336. t['bullet'] = 350;
  51337. t['quotesinglbase'] = 333;
  51338. t['quotedblbase'] = 444;
  51339. t['quotedblright'] = 444;
  51340. t['guillemotright'] = 500;
  51341. t['ellipsis'] = 1000;
  51342. t['perthousand'] = 1000;
  51343. t['questiondown'] = 444;
  51344. t['grave'] = 333;
  51345. t['acute'] = 333;
  51346. t['circumflex'] = 333;
  51347. t['tilde'] = 333;
  51348. t['macron'] = 333;
  51349. t['breve'] = 333;
  51350. t['dotaccent'] = 333;
  51351. t['dieresis'] = 333;
  51352. t['ring'] = 333;
  51353. t['cedilla'] = 333;
  51354. t['hungarumlaut'] = 333;
  51355. t['ogonek'] = 333;
  51356. t['caron'] = 333;
  51357. t['emdash'] = 1000;
  51358. t['AE'] = 889;
  51359. t['ordfeminine'] = 276;
  51360. t['Lslash'] = 611;
  51361. t['Oslash'] = 722;
  51362. t['OE'] = 889;
  51363. t['ordmasculine'] = 310;
  51364. t['ae'] = 667;
  51365. t['dotlessi'] = 278;
  51366. t['lslash'] = 278;
  51367. t['oslash'] = 500;
  51368. t['oe'] = 722;
  51369. t['germandbls'] = 500;
  51370. t['Idieresis'] = 333;
  51371. t['eacute'] = 444;
  51372. t['abreve'] = 444;
  51373. t['uhungarumlaut'] = 500;
  51374. t['ecaron'] = 444;
  51375. t['Ydieresis'] = 722;
  51376. t['divide'] = 564;
  51377. t['Yacute'] = 722;
  51378. t['Acircumflex'] = 722;
  51379. t['aacute'] = 444;
  51380. t['Ucircumflex'] = 722;
  51381. t['yacute'] = 500;
  51382. t['scommaaccent'] = 389;
  51383. t['ecircumflex'] = 444;
  51384. t['Uring'] = 722;
  51385. t['Udieresis'] = 722;
  51386. t['aogonek'] = 444;
  51387. t['Uacute'] = 722;
  51388. t['uogonek'] = 500;
  51389. t['Edieresis'] = 611;
  51390. t['Dcroat'] = 722;
  51391. t['commaaccent'] = 250;
  51392. t['copyright'] = 760;
  51393. t['Emacron'] = 611;
  51394. t['ccaron'] = 444;
  51395. t['aring'] = 444;
  51396. t['Ncommaaccent'] = 722;
  51397. t['lacute'] = 278;
  51398. t['agrave'] = 444;
  51399. t['Tcommaaccent'] = 611;
  51400. t['Cacute'] = 667;
  51401. t['atilde'] = 444;
  51402. t['Edotaccent'] = 611;
  51403. t['scaron'] = 389;
  51404. t['scedilla'] = 389;
  51405. t['iacute'] = 278;
  51406. t['lozenge'] = 471;
  51407. t['Rcaron'] = 667;
  51408. t['Gcommaaccent'] = 722;
  51409. t['ucircumflex'] = 500;
  51410. t['acircumflex'] = 444;
  51411. t['Amacron'] = 722;
  51412. t['rcaron'] = 333;
  51413. t['ccedilla'] = 444;
  51414. t['Zdotaccent'] = 611;
  51415. t['Thorn'] = 556;
  51416. t['Omacron'] = 722;
  51417. t['Racute'] = 667;
  51418. t['Sacute'] = 556;
  51419. t['dcaron'] = 588;
  51420. t['Umacron'] = 722;
  51421. t['uring'] = 500;
  51422. t['threesuperior'] = 300;
  51423. t['Ograve'] = 722;
  51424. t['Agrave'] = 722;
  51425. t['Abreve'] = 722;
  51426. t['multiply'] = 564;
  51427. t['uacute'] = 500;
  51428. t['Tcaron'] = 611;
  51429. t['partialdiff'] = 476;
  51430. t['ydieresis'] = 500;
  51431. t['Nacute'] = 722;
  51432. t['icircumflex'] = 278;
  51433. t['Ecircumflex'] = 611;
  51434. t['adieresis'] = 444;
  51435. t['edieresis'] = 444;
  51436. t['cacute'] = 444;
  51437. t['nacute'] = 500;
  51438. t['umacron'] = 500;
  51439. t['Ncaron'] = 722;
  51440. t['Iacute'] = 333;
  51441. t['plusminus'] = 564;
  51442. t['brokenbar'] = 200;
  51443. t['registered'] = 760;
  51444. t['Gbreve'] = 722;
  51445. t['Idotaccent'] = 333;
  51446. t['summation'] = 600;
  51447. t['Egrave'] = 611;
  51448. t['racute'] = 333;
  51449. t['omacron'] = 500;
  51450. t['Zacute'] = 611;
  51451. t['Zcaron'] = 611;
  51452. t['greaterequal'] = 549;
  51453. t['Eth'] = 722;
  51454. t['Ccedilla'] = 667;
  51455. t['lcommaaccent'] = 278;
  51456. t['tcaron'] = 326;
  51457. t['eogonek'] = 444;
  51458. t['Uogonek'] = 722;
  51459. t['Aacute'] = 722;
  51460. t['Adieresis'] = 722;
  51461. t['egrave'] = 444;
  51462. t['zacute'] = 444;
  51463. t['iogonek'] = 278;
  51464. t['Oacute'] = 722;
  51465. t['oacute'] = 500;
  51466. t['amacron'] = 444;
  51467. t['sacute'] = 389;
  51468. t['idieresis'] = 278;
  51469. t['Ocircumflex'] = 722;
  51470. t['Ugrave'] = 722;
  51471. t['Delta'] = 612;
  51472. t['thorn'] = 500;
  51473. t['twosuperior'] = 300;
  51474. t['Odieresis'] = 722;
  51475. t['mu'] = 500;
  51476. t['igrave'] = 278;
  51477. t['ohungarumlaut'] = 500;
  51478. t['Eogonek'] = 611;
  51479. t['dcroat'] = 500;
  51480. t['threequarters'] = 750;
  51481. t['Scedilla'] = 556;
  51482. t['lcaron'] = 344;
  51483. t['Kcommaaccent'] = 722;
  51484. t['Lacute'] = 611;
  51485. t['trademark'] = 980;
  51486. t['edotaccent'] = 444;
  51487. t['Igrave'] = 333;
  51488. t['Imacron'] = 333;
  51489. t['Lcaron'] = 611;
  51490. t['onehalf'] = 750;
  51491. t['lessequal'] = 549;
  51492. t['ocircumflex'] = 500;
  51493. t['ntilde'] = 500;
  51494. t['Uhungarumlaut'] = 722;
  51495. t['Eacute'] = 611;
  51496. t['emacron'] = 444;
  51497. t['gbreve'] = 500;
  51498. t['onequarter'] = 750;
  51499. t['Scaron'] = 556;
  51500. t['Scommaaccent'] = 556;
  51501. t['Ohungarumlaut'] = 722;
  51502. t['degree'] = 400;
  51503. t['ograve'] = 500;
  51504. t['Ccaron'] = 667;
  51505. t['ugrave'] = 500;
  51506. t['radical'] = 453;
  51507. t['Dcaron'] = 722;
  51508. t['rcommaaccent'] = 333;
  51509. t['Ntilde'] = 722;
  51510. t['otilde'] = 500;
  51511. t['Rcommaaccent'] = 667;
  51512. t['Lcommaaccent'] = 611;
  51513. t['Atilde'] = 722;
  51514. t['Aogonek'] = 722;
  51515. t['Aring'] = 722;
  51516. t['Otilde'] = 722;
  51517. t['zdotaccent'] = 444;
  51518. t['Ecaron'] = 611;
  51519. t['Iogonek'] = 333;
  51520. t['kcommaaccent'] = 500;
  51521. t['minus'] = 564;
  51522. t['Icircumflex'] = 333;
  51523. t['ncaron'] = 500;
  51524. t['tcommaaccent'] = 278;
  51525. t['logicalnot'] = 564;
  51526. t['odieresis'] = 500;
  51527. t['udieresis'] = 500;
  51528. t['notequal'] = 549;
  51529. t['gcommaaccent'] = 500;
  51530. t['eth'] = 500;
  51531. t['zcaron'] = 444;
  51532. t['ncommaaccent'] = 500;
  51533. t['onesuperior'] = 300;
  51534. t['imacron'] = 278;
  51535. t['Euro'] = 500;
  51536. });
  51537. t['Times-Bold'] = getLookupTableFactory(function (t) {
  51538. t['space'] = 250;
  51539. t['exclam'] = 333;
  51540. t['quotedbl'] = 555;
  51541. t['numbersign'] = 500;
  51542. t['dollar'] = 500;
  51543. t['percent'] = 1000;
  51544. t['ampersand'] = 833;
  51545. t['quoteright'] = 333;
  51546. t['parenleft'] = 333;
  51547. t['parenright'] = 333;
  51548. t['asterisk'] = 500;
  51549. t['plus'] = 570;
  51550. t['comma'] = 250;
  51551. t['hyphen'] = 333;
  51552. t['period'] = 250;
  51553. t['slash'] = 278;
  51554. t['zero'] = 500;
  51555. t['one'] = 500;
  51556. t['two'] = 500;
  51557. t['three'] = 500;
  51558. t['four'] = 500;
  51559. t['five'] = 500;
  51560. t['six'] = 500;
  51561. t['seven'] = 500;
  51562. t['eight'] = 500;
  51563. t['nine'] = 500;
  51564. t['colon'] = 333;
  51565. t['semicolon'] = 333;
  51566. t['less'] = 570;
  51567. t['equal'] = 570;
  51568. t['greater'] = 570;
  51569. t['question'] = 500;
  51570. t['at'] = 930;
  51571. t['A'] = 722;
  51572. t['B'] = 667;
  51573. t['C'] = 722;
  51574. t['D'] = 722;
  51575. t['E'] = 667;
  51576. t['F'] = 611;
  51577. t['G'] = 778;
  51578. t['H'] = 778;
  51579. t['I'] = 389;
  51580. t['J'] = 500;
  51581. t['K'] = 778;
  51582. t['L'] = 667;
  51583. t['M'] = 944;
  51584. t['N'] = 722;
  51585. t['O'] = 778;
  51586. t['P'] = 611;
  51587. t['Q'] = 778;
  51588. t['R'] = 722;
  51589. t['S'] = 556;
  51590. t['T'] = 667;
  51591. t['U'] = 722;
  51592. t['V'] = 722;
  51593. t['W'] = 1000;
  51594. t['X'] = 722;
  51595. t['Y'] = 722;
  51596. t['Z'] = 667;
  51597. t['bracketleft'] = 333;
  51598. t['backslash'] = 278;
  51599. t['bracketright'] = 333;
  51600. t['asciicircum'] = 581;
  51601. t['underscore'] = 500;
  51602. t['quoteleft'] = 333;
  51603. t['a'] = 500;
  51604. t['b'] = 556;
  51605. t['c'] = 444;
  51606. t['d'] = 556;
  51607. t['e'] = 444;
  51608. t['f'] = 333;
  51609. t['g'] = 500;
  51610. t['h'] = 556;
  51611. t['i'] = 278;
  51612. t['j'] = 333;
  51613. t['k'] = 556;
  51614. t['l'] = 278;
  51615. t['m'] = 833;
  51616. t['n'] = 556;
  51617. t['o'] = 500;
  51618. t['p'] = 556;
  51619. t['q'] = 556;
  51620. t['r'] = 444;
  51621. t['s'] = 389;
  51622. t['t'] = 333;
  51623. t['u'] = 556;
  51624. t['v'] = 500;
  51625. t['w'] = 722;
  51626. t['x'] = 500;
  51627. t['y'] = 500;
  51628. t['z'] = 444;
  51629. t['braceleft'] = 394;
  51630. t['bar'] = 220;
  51631. t['braceright'] = 394;
  51632. t['asciitilde'] = 520;
  51633. t['exclamdown'] = 333;
  51634. t['cent'] = 500;
  51635. t['sterling'] = 500;
  51636. t['fraction'] = 167;
  51637. t['yen'] = 500;
  51638. t['florin'] = 500;
  51639. t['section'] = 500;
  51640. t['currency'] = 500;
  51641. t['quotesingle'] = 278;
  51642. t['quotedblleft'] = 500;
  51643. t['guillemotleft'] = 500;
  51644. t['guilsinglleft'] = 333;
  51645. t['guilsinglright'] = 333;
  51646. t['fi'] = 556;
  51647. t['fl'] = 556;
  51648. t['endash'] = 500;
  51649. t['dagger'] = 500;
  51650. t['daggerdbl'] = 500;
  51651. t['periodcentered'] = 250;
  51652. t['paragraph'] = 540;
  51653. t['bullet'] = 350;
  51654. t['quotesinglbase'] = 333;
  51655. t['quotedblbase'] = 500;
  51656. t['quotedblright'] = 500;
  51657. t['guillemotright'] = 500;
  51658. t['ellipsis'] = 1000;
  51659. t['perthousand'] = 1000;
  51660. t['questiondown'] = 500;
  51661. t['grave'] = 333;
  51662. t['acute'] = 333;
  51663. t['circumflex'] = 333;
  51664. t['tilde'] = 333;
  51665. t['macron'] = 333;
  51666. t['breve'] = 333;
  51667. t['dotaccent'] = 333;
  51668. t['dieresis'] = 333;
  51669. t['ring'] = 333;
  51670. t['cedilla'] = 333;
  51671. t['hungarumlaut'] = 333;
  51672. t['ogonek'] = 333;
  51673. t['caron'] = 333;
  51674. t['emdash'] = 1000;
  51675. t['AE'] = 1000;
  51676. t['ordfeminine'] = 300;
  51677. t['Lslash'] = 667;
  51678. t['Oslash'] = 778;
  51679. t['OE'] = 1000;
  51680. t['ordmasculine'] = 330;
  51681. t['ae'] = 722;
  51682. t['dotlessi'] = 278;
  51683. t['lslash'] = 278;
  51684. t['oslash'] = 500;
  51685. t['oe'] = 722;
  51686. t['germandbls'] = 556;
  51687. t['Idieresis'] = 389;
  51688. t['eacute'] = 444;
  51689. t['abreve'] = 500;
  51690. t['uhungarumlaut'] = 556;
  51691. t['ecaron'] = 444;
  51692. t['Ydieresis'] = 722;
  51693. t['divide'] = 570;
  51694. t['Yacute'] = 722;
  51695. t['Acircumflex'] = 722;
  51696. t['aacute'] = 500;
  51697. t['Ucircumflex'] = 722;
  51698. t['yacute'] = 500;
  51699. t['scommaaccent'] = 389;
  51700. t['ecircumflex'] = 444;
  51701. t['Uring'] = 722;
  51702. t['Udieresis'] = 722;
  51703. t['aogonek'] = 500;
  51704. t['Uacute'] = 722;
  51705. t['uogonek'] = 556;
  51706. t['Edieresis'] = 667;
  51707. t['Dcroat'] = 722;
  51708. t['commaaccent'] = 250;
  51709. t['copyright'] = 747;
  51710. t['Emacron'] = 667;
  51711. t['ccaron'] = 444;
  51712. t['aring'] = 500;
  51713. t['Ncommaaccent'] = 722;
  51714. t['lacute'] = 278;
  51715. t['agrave'] = 500;
  51716. t['Tcommaaccent'] = 667;
  51717. t['Cacute'] = 722;
  51718. t['atilde'] = 500;
  51719. t['Edotaccent'] = 667;
  51720. t['scaron'] = 389;
  51721. t['scedilla'] = 389;
  51722. t['iacute'] = 278;
  51723. t['lozenge'] = 494;
  51724. t['Rcaron'] = 722;
  51725. t['Gcommaaccent'] = 778;
  51726. t['ucircumflex'] = 556;
  51727. t['acircumflex'] = 500;
  51728. t['Amacron'] = 722;
  51729. t['rcaron'] = 444;
  51730. t['ccedilla'] = 444;
  51731. t['Zdotaccent'] = 667;
  51732. t['Thorn'] = 611;
  51733. t['Omacron'] = 778;
  51734. t['Racute'] = 722;
  51735. t['Sacute'] = 556;
  51736. t['dcaron'] = 672;
  51737. t['Umacron'] = 722;
  51738. t['uring'] = 556;
  51739. t['threesuperior'] = 300;
  51740. t['Ograve'] = 778;
  51741. t['Agrave'] = 722;
  51742. t['Abreve'] = 722;
  51743. t['multiply'] = 570;
  51744. t['uacute'] = 556;
  51745. t['Tcaron'] = 667;
  51746. t['partialdiff'] = 494;
  51747. t['ydieresis'] = 500;
  51748. t['Nacute'] = 722;
  51749. t['icircumflex'] = 278;
  51750. t['Ecircumflex'] = 667;
  51751. t['adieresis'] = 500;
  51752. t['edieresis'] = 444;
  51753. t['cacute'] = 444;
  51754. t['nacute'] = 556;
  51755. t['umacron'] = 556;
  51756. t['Ncaron'] = 722;
  51757. t['Iacute'] = 389;
  51758. t['plusminus'] = 570;
  51759. t['brokenbar'] = 220;
  51760. t['registered'] = 747;
  51761. t['Gbreve'] = 778;
  51762. t['Idotaccent'] = 389;
  51763. t['summation'] = 600;
  51764. t['Egrave'] = 667;
  51765. t['racute'] = 444;
  51766. t['omacron'] = 500;
  51767. t['Zacute'] = 667;
  51768. t['Zcaron'] = 667;
  51769. t['greaterequal'] = 549;
  51770. t['Eth'] = 722;
  51771. t['Ccedilla'] = 722;
  51772. t['lcommaaccent'] = 278;
  51773. t['tcaron'] = 416;
  51774. t['eogonek'] = 444;
  51775. t['Uogonek'] = 722;
  51776. t['Aacute'] = 722;
  51777. t['Adieresis'] = 722;
  51778. t['egrave'] = 444;
  51779. t['zacute'] = 444;
  51780. t['iogonek'] = 278;
  51781. t['Oacute'] = 778;
  51782. t['oacute'] = 500;
  51783. t['amacron'] = 500;
  51784. t['sacute'] = 389;
  51785. t['idieresis'] = 278;
  51786. t['Ocircumflex'] = 778;
  51787. t['Ugrave'] = 722;
  51788. t['Delta'] = 612;
  51789. t['thorn'] = 556;
  51790. t['twosuperior'] = 300;
  51791. t['Odieresis'] = 778;
  51792. t['mu'] = 556;
  51793. t['igrave'] = 278;
  51794. t['ohungarumlaut'] = 500;
  51795. t['Eogonek'] = 667;
  51796. t['dcroat'] = 556;
  51797. t['threequarters'] = 750;
  51798. t['Scedilla'] = 556;
  51799. t['lcaron'] = 394;
  51800. t['Kcommaaccent'] = 778;
  51801. t['Lacute'] = 667;
  51802. t['trademark'] = 1000;
  51803. t['edotaccent'] = 444;
  51804. t['Igrave'] = 389;
  51805. t['Imacron'] = 389;
  51806. t['Lcaron'] = 667;
  51807. t['onehalf'] = 750;
  51808. t['lessequal'] = 549;
  51809. t['ocircumflex'] = 500;
  51810. t['ntilde'] = 556;
  51811. t['Uhungarumlaut'] = 722;
  51812. t['Eacute'] = 667;
  51813. t['emacron'] = 444;
  51814. t['gbreve'] = 500;
  51815. t['onequarter'] = 750;
  51816. t['Scaron'] = 556;
  51817. t['Scommaaccent'] = 556;
  51818. t['Ohungarumlaut'] = 778;
  51819. t['degree'] = 400;
  51820. t['ograve'] = 500;
  51821. t['Ccaron'] = 722;
  51822. t['ugrave'] = 556;
  51823. t['radical'] = 549;
  51824. t['Dcaron'] = 722;
  51825. t['rcommaaccent'] = 444;
  51826. t['Ntilde'] = 722;
  51827. t['otilde'] = 500;
  51828. t['Rcommaaccent'] = 722;
  51829. t['Lcommaaccent'] = 667;
  51830. t['Atilde'] = 722;
  51831. t['Aogonek'] = 722;
  51832. t['Aring'] = 722;
  51833. t['Otilde'] = 778;
  51834. t['zdotaccent'] = 444;
  51835. t['Ecaron'] = 667;
  51836. t['Iogonek'] = 389;
  51837. t['kcommaaccent'] = 556;
  51838. t['minus'] = 570;
  51839. t['Icircumflex'] = 389;
  51840. t['ncaron'] = 556;
  51841. t['tcommaaccent'] = 333;
  51842. t['logicalnot'] = 570;
  51843. t['odieresis'] = 500;
  51844. t['udieresis'] = 556;
  51845. t['notequal'] = 549;
  51846. t['gcommaaccent'] = 500;
  51847. t['eth'] = 500;
  51848. t['zcaron'] = 444;
  51849. t['ncommaaccent'] = 556;
  51850. t['onesuperior'] = 300;
  51851. t['imacron'] = 278;
  51852. t['Euro'] = 500;
  51853. });
  51854. t['Times-BoldItalic'] = getLookupTableFactory(function (t) {
  51855. t['space'] = 250;
  51856. t['exclam'] = 389;
  51857. t['quotedbl'] = 555;
  51858. t['numbersign'] = 500;
  51859. t['dollar'] = 500;
  51860. t['percent'] = 833;
  51861. t['ampersand'] = 778;
  51862. t['quoteright'] = 333;
  51863. t['parenleft'] = 333;
  51864. t['parenright'] = 333;
  51865. t['asterisk'] = 500;
  51866. t['plus'] = 570;
  51867. t['comma'] = 250;
  51868. t['hyphen'] = 333;
  51869. t['period'] = 250;
  51870. t['slash'] = 278;
  51871. t['zero'] = 500;
  51872. t['one'] = 500;
  51873. t['two'] = 500;
  51874. t['three'] = 500;
  51875. t['four'] = 500;
  51876. t['five'] = 500;
  51877. t['six'] = 500;
  51878. t['seven'] = 500;
  51879. t['eight'] = 500;
  51880. t['nine'] = 500;
  51881. t['colon'] = 333;
  51882. t['semicolon'] = 333;
  51883. t['less'] = 570;
  51884. t['equal'] = 570;
  51885. t['greater'] = 570;
  51886. t['question'] = 500;
  51887. t['at'] = 832;
  51888. t['A'] = 667;
  51889. t['B'] = 667;
  51890. t['C'] = 667;
  51891. t['D'] = 722;
  51892. t['E'] = 667;
  51893. t['F'] = 667;
  51894. t['G'] = 722;
  51895. t['H'] = 778;
  51896. t['I'] = 389;
  51897. t['J'] = 500;
  51898. t['K'] = 667;
  51899. t['L'] = 611;
  51900. t['M'] = 889;
  51901. t['N'] = 722;
  51902. t['O'] = 722;
  51903. t['P'] = 611;
  51904. t['Q'] = 722;
  51905. t['R'] = 667;
  51906. t['S'] = 556;
  51907. t['T'] = 611;
  51908. t['U'] = 722;
  51909. t['V'] = 667;
  51910. t['W'] = 889;
  51911. t['X'] = 667;
  51912. t['Y'] = 611;
  51913. t['Z'] = 611;
  51914. t['bracketleft'] = 333;
  51915. t['backslash'] = 278;
  51916. t['bracketright'] = 333;
  51917. t['asciicircum'] = 570;
  51918. t['underscore'] = 500;
  51919. t['quoteleft'] = 333;
  51920. t['a'] = 500;
  51921. t['b'] = 500;
  51922. t['c'] = 444;
  51923. t['d'] = 500;
  51924. t['e'] = 444;
  51925. t['f'] = 333;
  51926. t['g'] = 500;
  51927. t['h'] = 556;
  51928. t['i'] = 278;
  51929. t['j'] = 278;
  51930. t['k'] = 500;
  51931. t['l'] = 278;
  51932. t['m'] = 778;
  51933. t['n'] = 556;
  51934. t['o'] = 500;
  51935. t['p'] = 500;
  51936. t['q'] = 500;
  51937. t['r'] = 389;
  51938. t['s'] = 389;
  51939. t['t'] = 278;
  51940. t['u'] = 556;
  51941. t['v'] = 444;
  51942. t['w'] = 667;
  51943. t['x'] = 500;
  51944. t['y'] = 444;
  51945. t['z'] = 389;
  51946. t['braceleft'] = 348;
  51947. t['bar'] = 220;
  51948. t['braceright'] = 348;
  51949. t['asciitilde'] = 570;
  51950. t['exclamdown'] = 389;
  51951. t['cent'] = 500;
  51952. t['sterling'] = 500;
  51953. t['fraction'] = 167;
  51954. t['yen'] = 500;
  51955. t['florin'] = 500;
  51956. t['section'] = 500;
  51957. t['currency'] = 500;
  51958. t['quotesingle'] = 278;
  51959. t['quotedblleft'] = 500;
  51960. t['guillemotleft'] = 500;
  51961. t['guilsinglleft'] = 333;
  51962. t['guilsinglright'] = 333;
  51963. t['fi'] = 556;
  51964. t['fl'] = 556;
  51965. t['endash'] = 500;
  51966. t['dagger'] = 500;
  51967. t['daggerdbl'] = 500;
  51968. t['periodcentered'] = 250;
  51969. t['paragraph'] = 500;
  51970. t['bullet'] = 350;
  51971. t['quotesinglbase'] = 333;
  51972. t['quotedblbase'] = 500;
  51973. t['quotedblright'] = 500;
  51974. t['guillemotright'] = 500;
  51975. t['ellipsis'] = 1000;
  51976. t['perthousand'] = 1000;
  51977. t['questiondown'] = 500;
  51978. t['grave'] = 333;
  51979. t['acute'] = 333;
  51980. t['circumflex'] = 333;
  51981. t['tilde'] = 333;
  51982. t['macron'] = 333;
  51983. t['breve'] = 333;
  51984. t['dotaccent'] = 333;
  51985. t['dieresis'] = 333;
  51986. t['ring'] = 333;
  51987. t['cedilla'] = 333;
  51988. t['hungarumlaut'] = 333;
  51989. t['ogonek'] = 333;
  51990. t['caron'] = 333;
  51991. t['emdash'] = 1000;
  51992. t['AE'] = 944;
  51993. t['ordfeminine'] = 266;
  51994. t['Lslash'] = 611;
  51995. t['Oslash'] = 722;
  51996. t['OE'] = 944;
  51997. t['ordmasculine'] = 300;
  51998. t['ae'] = 722;
  51999. t['dotlessi'] = 278;
  52000. t['lslash'] = 278;
  52001. t['oslash'] = 500;
  52002. t['oe'] = 722;
  52003. t['germandbls'] = 500;
  52004. t['Idieresis'] = 389;
  52005. t['eacute'] = 444;
  52006. t['abreve'] = 500;
  52007. t['uhungarumlaut'] = 556;
  52008. t['ecaron'] = 444;
  52009. t['Ydieresis'] = 611;
  52010. t['divide'] = 570;
  52011. t['Yacute'] = 611;
  52012. t['Acircumflex'] = 667;
  52013. t['aacute'] = 500;
  52014. t['Ucircumflex'] = 722;
  52015. t['yacute'] = 444;
  52016. t['scommaaccent'] = 389;
  52017. t['ecircumflex'] = 444;
  52018. t['Uring'] = 722;
  52019. t['Udieresis'] = 722;
  52020. t['aogonek'] = 500;
  52021. t['Uacute'] = 722;
  52022. t['uogonek'] = 556;
  52023. t['Edieresis'] = 667;
  52024. t['Dcroat'] = 722;
  52025. t['commaaccent'] = 250;
  52026. t['copyright'] = 747;
  52027. t['Emacron'] = 667;
  52028. t['ccaron'] = 444;
  52029. t['aring'] = 500;
  52030. t['Ncommaaccent'] = 722;
  52031. t['lacute'] = 278;
  52032. t['agrave'] = 500;
  52033. t['Tcommaaccent'] = 611;
  52034. t['Cacute'] = 667;
  52035. t['atilde'] = 500;
  52036. t['Edotaccent'] = 667;
  52037. t['scaron'] = 389;
  52038. t['scedilla'] = 389;
  52039. t['iacute'] = 278;
  52040. t['lozenge'] = 494;
  52041. t['Rcaron'] = 667;
  52042. t['Gcommaaccent'] = 722;
  52043. t['ucircumflex'] = 556;
  52044. t['acircumflex'] = 500;
  52045. t['Amacron'] = 667;
  52046. t['rcaron'] = 389;
  52047. t['ccedilla'] = 444;
  52048. t['Zdotaccent'] = 611;
  52049. t['Thorn'] = 611;
  52050. t['Omacron'] = 722;
  52051. t['Racute'] = 667;
  52052. t['Sacute'] = 556;
  52053. t['dcaron'] = 608;
  52054. t['Umacron'] = 722;
  52055. t['uring'] = 556;
  52056. t['threesuperior'] = 300;
  52057. t['Ograve'] = 722;
  52058. t['Agrave'] = 667;
  52059. t['Abreve'] = 667;
  52060. t['multiply'] = 570;
  52061. t['uacute'] = 556;
  52062. t['Tcaron'] = 611;
  52063. t['partialdiff'] = 494;
  52064. t['ydieresis'] = 444;
  52065. t['Nacute'] = 722;
  52066. t['icircumflex'] = 278;
  52067. t['Ecircumflex'] = 667;
  52068. t['adieresis'] = 500;
  52069. t['edieresis'] = 444;
  52070. t['cacute'] = 444;
  52071. t['nacute'] = 556;
  52072. t['umacron'] = 556;
  52073. t['Ncaron'] = 722;
  52074. t['Iacute'] = 389;
  52075. t['plusminus'] = 570;
  52076. t['brokenbar'] = 220;
  52077. t['registered'] = 747;
  52078. t['Gbreve'] = 722;
  52079. t['Idotaccent'] = 389;
  52080. t['summation'] = 600;
  52081. t['Egrave'] = 667;
  52082. t['racute'] = 389;
  52083. t['omacron'] = 500;
  52084. t['Zacute'] = 611;
  52085. t['Zcaron'] = 611;
  52086. t['greaterequal'] = 549;
  52087. t['Eth'] = 722;
  52088. t['Ccedilla'] = 667;
  52089. t['lcommaaccent'] = 278;
  52090. t['tcaron'] = 366;
  52091. t['eogonek'] = 444;
  52092. t['Uogonek'] = 722;
  52093. t['Aacute'] = 667;
  52094. t['Adieresis'] = 667;
  52095. t['egrave'] = 444;
  52096. t['zacute'] = 389;
  52097. t['iogonek'] = 278;
  52098. t['Oacute'] = 722;
  52099. t['oacute'] = 500;
  52100. t['amacron'] = 500;
  52101. t['sacute'] = 389;
  52102. t['idieresis'] = 278;
  52103. t['Ocircumflex'] = 722;
  52104. t['Ugrave'] = 722;
  52105. t['Delta'] = 612;
  52106. t['thorn'] = 500;
  52107. t['twosuperior'] = 300;
  52108. t['Odieresis'] = 722;
  52109. t['mu'] = 576;
  52110. t['igrave'] = 278;
  52111. t['ohungarumlaut'] = 500;
  52112. t['Eogonek'] = 667;
  52113. t['dcroat'] = 500;
  52114. t['threequarters'] = 750;
  52115. t['Scedilla'] = 556;
  52116. t['lcaron'] = 382;
  52117. t['Kcommaaccent'] = 667;
  52118. t['Lacute'] = 611;
  52119. t['trademark'] = 1000;
  52120. t['edotaccent'] = 444;
  52121. t['Igrave'] = 389;
  52122. t['Imacron'] = 389;
  52123. t['Lcaron'] = 611;
  52124. t['onehalf'] = 750;
  52125. t['lessequal'] = 549;
  52126. t['ocircumflex'] = 500;
  52127. t['ntilde'] = 556;
  52128. t['Uhungarumlaut'] = 722;
  52129. t['Eacute'] = 667;
  52130. t['emacron'] = 444;
  52131. t['gbreve'] = 500;
  52132. t['onequarter'] = 750;
  52133. t['Scaron'] = 556;
  52134. t['Scommaaccent'] = 556;
  52135. t['Ohungarumlaut'] = 722;
  52136. t['degree'] = 400;
  52137. t['ograve'] = 500;
  52138. t['Ccaron'] = 667;
  52139. t['ugrave'] = 556;
  52140. t['radical'] = 549;
  52141. t['Dcaron'] = 722;
  52142. t['rcommaaccent'] = 389;
  52143. t['Ntilde'] = 722;
  52144. t['otilde'] = 500;
  52145. t['Rcommaaccent'] = 667;
  52146. t['Lcommaaccent'] = 611;
  52147. t['Atilde'] = 667;
  52148. t['Aogonek'] = 667;
  52149. t['Aring'] = 667;
  52150. t['Otilde'] = 722;
  52151. t['zdotaccent'] = 389;
  52152. t['Ecaron'] = 667;
  52153. t['Iogonek'] = 389;
  52154. t['kcommaaccent'] = 500;
  52155. t['minus'] = 606;
  52156. t['Icircumflex'] = 389;
  52157. t['ncaron'] = 556;
  52158. t['tcommaaccent'] = 278;
  52159. t['logicalnot'] = 606;
  52160. t['odieresis'] = 500;
  52161. t['udieresis'] = 556;
  52162. t['notequal'] = 549;
  52163. t['gcommaaccent'] = 500;
  52164. t['eth'] = 500;
  52165. t['zcaron'] = 389;
  52166. t['ncommaaccent'] = 556;
  52167. t['onesuperior'] = 300;
  52168. t['imacron'] = 278;
  52169. t['Euro'] = 500;
  52170. });
  52171. t['Times-Italic'] = getLookupTableFactory(function (t) {
  52172. t['space'] = 250;
  52173. t['exclam'] = 333;
  52174. t['quotedbl'] = 420;
  52175. t['numbersign'] = 500;
  52176. t['dollar'] = 500;
  52177. t['percent'] = 833;
  52178. t['ampersand'] = 778;
  52179. t['quoteright'] = 333;
  52180. t['parenleft'] = 333;
  52181. t['parenright'] = 333;
  52182. t['asterisk'] = 500;
  52183. t['plus'] = 675;
  52184. t['comma'] = 250;
  52185. t['hyphen'] = 333;
  52186. t['period'] = 250;
  52187. t['slash'] = 278;
  52188. t['zero'] = 500;
  52189. t['one'] = 500;
  52190. t['two'] = 500;
  52191. t['three'] = 500;
  52192. t['four'] = 500;
  52193. t['five'] = 500;
  52194. t['six'] = 500;
  52195. t['seven'] = 500;
  52196. t['eight'] = 500;
  52197. t['nine'] = 500;
  52198. t['colon'] = 333;
  52199. t['semicolon'] = 333;
  52200. t['less'] = 675;
  52201. t['equal'] = 675;
  52202. t['greater'] = 675;
  52203. t['question'] = 500;
  52204. t['at'] = 920;
  52205. t['A'] = 611;
  52206. t['B'] = 611;
  52207. t['C'] = 667;
  52208. t['D'] = 722;
  52209. t['E'] = 611;
  52210. t['F'] = 611;
  52211. t['G'] = 722;
  52212. t['H'] = 722;
  52213. t['I'] = 333;
  52214. t['J'] = 444;
  52215. t['K'] = 667;
  52216. t['L'] = 556;
  52217. t['M'] = 833;
  52218. t['N'] = 667;
  52219. t['O'] = 722;
  52220. t['P'] = 611;
  52221. t['Q'] = 722;
  52222. t['R'] = 611;
  52223. t['S'] = 500;
  52224. t['T'] = 556;
  52225. t['U'] = 722;
  52226. t['V'] = 611;
  52227. t['W'] = 833;
  52228. t['X'] = 611;
  52229. t['Y'] = 556;
  52230. t['Z'] = 556;
  52231. t['bracketleft'] = 389;
  52232. t['backslash'] = 278;
  52233. t['bracketright'] = 389;
  52234. t['asciicircum'] = 422;
  52235. t['underscore'] = 500;
  52236. t['quoteleft'] = 333;
  52237. t['a'] = 500;
  52238. t['b'] = 500;
  52239. t['c'] = 444;
  52240. t['d'] = 500;
  52241. t['e'] = 444;
  52242. t['f'] = 278;
  52243. t['g'] = 500;
  52244. t['h'] = 500;
  52245. t['i'] = 278;
  52246. t['j'] = 278;
  52247. t['k'] = 444;
  52248. t['l'] = 278;
  52249. t['m'] = 722;
  52250. t['n'] = 500;
  52251. t['o'] = 500;
  52252. t['p'] = 500;
  52253. t['q'] = 500;
  52254. t['r'] = 389;
  52255. t['s'] = 389;
  52256. t['t'] = 278;
  52257. t['u'] = 500;
  52258. t['v'] = 444;
  52259. t['w'] = 667;
  52260. t['x'] = 444;
  52261. t['y'] = 444;
  52262. t['z'] = 389;
  52263. t['braceleft'] = 400;
  52264. t['bar'] = 275;
  52265. t['braceright'] = 400;
  52266. t['asciitilde'] = 541;
  52267. t['exclamdown'] = 389;
  52268. t['cent'] = 500;
  52269. t['sterling'] = 500;
  52270. t['fraction'] = 167;
  52271. t['yen'] = 500;
  52272. t['florin'] = 500;
  52273. t['section'] = 500;
  52274. t['currency'] = 500;
  52275. t['quotesingle'] = 214;
  52276. t['quotedblleft'] = 556;
  52277. t['guillemotleft'] = 500;
  52278. t['guilsinglleft'] = 333;
  52279. t['guilsinglright'] = 333;
  52280. t['fi'] = 500;
  52281. t['fl'] = 500;
  52282. t['endash'] = 500;
  52283. t['dagger'] = 500;
  52284. t['daggerdbl'] = 500;
  52285. t['periodcentered'] = 250;
  52286. t['paragraph'] = 523;
  52287. t['bullet'] = 350;
  52288. t['quotesinglbase'] = 333;
  52289. t['quotedblbase'] = 556;
  52290. t['quotedblright'] = 556;
  52291. t['guillemotright'] = 500;
  52292. t['ellipsis'] = 889;
  52293. t['perthousand'] = 1000;
  52294. t['questiondown'] = 500;
  52295. t['grave'] = 333;
  52296. t['acute'] = 333;
  52297. t['circumflex'] = 333;
  52298. t['tilde'] = 333;
  52299. t['macron'] = 333;
  52300. t['breve'] = 333;
  52301. t['dotaccent'] = 333;
  52302. t['dieresis'] = 333;
  52303. t['ring'] = 333;
  52304. t['cedilla'] = 333;
  52305. t['hungarumlaut'] = 333;
  52306. t['ogonek'] = 333;
  52307. t['caron'] = 333;
  52308. t['emdash'] = 889;
  52309. t['AE'] = 889;
  52310. t['ordfeminine'] = 276;
  52311. t['Lslash'] = 556;
  52312. t['Oslash'] = 722;
  52313. t['OE'] = 944;
  52314. t['ordmasculine'] = 310;
  52315. t['ae'] = 667;
  52316. t['dotlessi'] = 278;
  52317. t['lslash'] = 278;
  52318. t['oslash'] = 500;
  52319. t['oe'] = 667;
  52320. t['germandbls'] = 500;
  52321. t['Idieresis'] = 333;
  52322. t['eacute'] = 444;
  52323. t['abreve'] = 500;
  52324. t['uhungarumlaut'] = 500;
  52325. t['ecaron'] = 444;
  52326. t['Ydieresis'] = 556;
  52327. t['divide'] = 675;
  52328. t['Yacute'] = 556;
  52329. t['Acircumflex'] = 611;
  52330. t['aacute'] = 500;
  52331. t['Ucircumflex'] = 722;
  52332. t['yacute'] = 444;
  52333. t['scommaaccent'] = 389;
  52334. t['ecircumflex'] = 444;
  52335. t['Uring'] = 722;
  52336. t['Udieresis'] = 722;
  52337. t['aogonek'] = 500;
  52338. t['Uacute'] = 722;
  52339. t['uogonek'] = 500;
  52340. t['Edieresis'] = 611;
  52341. t['Dcroat'] = 722;
  52342. t['commaaccent'] = 250;
  52343. t['copyright'] = 760;
  52344. t['Emacron'] = 611;
  52345. t['ccaron'] = 444;
  52346. t['aring'] = 500;
  52347. t['Ncommaaccent'] = 667;
  52348. t['lacute'] = 278;
  52349. t['agrave'] = 500;
  52350. t['Tcommaaccent'] = 556;
  52351. t['Cacute'] = 667;
  52352. t['atilde'] = 500;
  52353. t['Edotaccent'] = 611;
  52354. t['scaron'] = 389;
  52355. t['scedilla'] = 389;
  52356. t['iacute'] = 278;
  52357. t['lozenge'] = 471;
  52358. t['Rcaron'] = 611;
  52359. t['Gcommaaccent'] = 722;
  52360. t['ucircumflex'] = 500;
  52361. t['acircumflex'] = 500;
  52362. t['Amacron'] = 611;
  52363. t['rcaron'] = 389;
  52364. t['ccedilla'] = 444;
  52365. t['Zdotaccent'] = 556;
  52366. t['Thorn'] = 611;
  52367. t['Omacron'] = 722;
  52368. t['Racute'] = 611;
  52369. t['Sacute'] = 500;
  52370. t['dcaron'] = 544;
  52371. t['Umacron'] = 722;
  52372. t['uring'] = 500;
  52373. t['threesuperior'] = 300;
  52374. t['Ograve'] = 722;
  52375. t['Agrave'] = 611;
  52376. t['Abreve'] = 611;
  52377. t['multiply'] = 675;
  52378. t['uacute'] = 500;
  52379. t['Tcaron'] = 556;
  52380. t['partialdiff'] = 476;
  52381. t['ydieresis'] = 444;
  52382. t['Nacute'] = 667;
  52383. t['icircumflex'] = 278;
  52384. t['Ecircumflex'] = 611;
  52385. t['adieresis'] = 500;
  52386. t['edieresis'] = 444;
  52387. t['cacute'] = 444;
  52388. t['nacute'] = 500;
  52389. t['umacron'] = 500;
  52390. t['Ncaron'] = 667;
  52391. t['Iacute'] = 333;
  52392. t['plusminus'] = 675;
  52393. t['brokenbar'] = 275;
  52394. t['registered'] = 760;
  52395. t['Gbreve'] = 722;
  52396. t['Idotaccent'] = 333;
  52397. t['summation'] = 600;
  52398. t['Egrave'] = 611;
  52399. t['racute'] = 389;
  52400. t['omacron'] = 500;
  52401. t['Zacute'] = 556;
  52402. t['Zcaron'] = 556;
  52403. t['greaterequal'] = 549;
  52404. t['Eth'] = 722;
  52405. t['Ccedilla'] = 667;
  52406. t['lcommaaccent'] = 278;
  52407. t['tcaron'] = 300;
  52408. t['eogonek'] = 444;
  52409. t['Uogonek'] = 722;
  52410. t['Aacute'] = 611;
  52411. t['Adieresis'] = 611;
  52412. t['egrave'] = 444;
  52413. t['zacute'] = 389;
  52414. t['iogonek'] = 278;
  52415. t['Oacute'] = 722;
  52416. t['oacute'] = 500;
  52417. t['amacron'] = 500;
  52418. t['sacute'] = 389;
  52419. t['idieresis'] = 278;
  52420. t['Ocircumflex'] = 722;
  52421. t['Ugrave'] = 722;
  52422. t['Delta'] = 612;
  52423. t['thorn'] = 500;
  52424. t['twosuperior'] = 300;
  52425. t['Odieresis'] = 722;
  52426. t['mu'] = 500;
  52427. t['igrave'] = 278;
  52428. t['ohungarumlaut'] = 500;
  52429. t['Eogonek'] = 611;
  52430. t['dcroat'] = 500;
  52431. t['threequarters'] = 750;
  52432. t['Scedilla'] = 500;
  52433. t['lcaron'] = 300;
  52434. t['Kcommaaccent'] = 667;
  52435. t['Lacute'] = 556;
  52436. t['trademark'] = 980;
  52437. t['edotaccent'] = 444;
  52438. t['Igrave'] = 333;
  52439. t['Imacron'] = 333;
  52440. t['Lcaron'] = 611;
  52441. t['onehalf'] = 750;
  52442. t['lessequal'] = 549;
  52443. t['ocircumflex'] = 500;
  52444. t['ntilde'] = 500;
  52445. t['Uhungarumlaut'] = 722;
  52446. t['Eacute'] = 611;
  52447. t['emacron'] = 444;
  52448. t['gbreve'] = 500;
  52449. t['onequarter'] = 750;
  52450. t['Scaron'] = 500;
  52451. t['Scommaaccent'] = 500;
  52452. t['Ohungarumlaut'] = 722;
  52453. t['degree'] = 400;
  52454. t['ograve'] = 500;
  52455. t['Ccaron'] = 667;
  52456. t['ugrave'] = 500;
  52457. t['radical'] = 453;
  52458. t['Dcaron'] = 722;
  52459. t['rcommaaccent'] = 389;
  52460. t['Ntilde'] = 667;
  52461. t['otilde'] = 500;
  52462. t['Rcommaaccent'] = 611;
  52463. t['Lcommaaccent'] = 556;
  52464. t['Atilde'] = 611;
  52465. t['Aogonek'] = 611;
  52466. t['Aring'] = 611;
  52467. t['Otilde'] = 722;
  52468. t['zdotaccent'] = 389;
  52469. t['Ecaron'] = 611;
  52470. t['Iogonek'] = 333;
  52471. t['kcommaaccent'] = 444;
  52472. t['minus'] = 675;
  52473. t['Icircumflex'] = 333;
  52474. t['ncaron'] = 500;
  52475. t['tcommaaccent'] = 278;
  52476. t['logicalnot'] = 675;
  52477. t['odieresis'] = 500;
  52478. t['udieresis'] = 500;
  52479. t['notequal'] = 549;
  52480. t['gcommaaccent'] = 500;
  52481. t['eth'] = 500;
  52482. t['zcaron'] = 389;
  52483. t['ncommaaccent'] = 500;
  52484. t['onesuperior'] = 300;
  52485. t['imacron'] = 278;
  52486. t['Euro'] = 500;
  52487. });
  52488. t['ZapfDingbats'] = getLookupTableFactory(function (t) {
  52489. t['space'] = 278;
  52490. t['a1'] = 974;
  52491. t['a2'] = 961;
  52492. t['a202'] = 974;
  52493. t['a3'] = 980;
  52494. t['a4'] = 719;
  52495. t['a5'] = 789;
  52496. t['a119'] = 790;
  52497. t['a118'] = 791;
  52498. t['a117'] = 690;
  52499. t['a11'] = 960;
  52500. t['a12'] = 939;
  52501. t['a13'] = 549;
  52502. t['a14'] = 855;
  52503. t['a15'] = 911;
  52504. t['a16'] = 933;
  52505. t['a105'] = 911;
  52506. t['a17'] = 945;
  52507. t['a18'] = 974;
  52508. t['a19'] = 755;
  52509. t['a20'] = 846;
  52510. t['a21'] = 762;
  52511. t['a22'] = 761;
  52512. t['a23'] = 571;
  52513. t['a24'] = 677;
  52514. t['a25'] = 763;
  52515. t['a26'] = 760;
  52516. t['a27'] = 759;
  52517. t['a28'] = 754;
  52518. t['a6'] = 494;
  52519. t['a7'] = 552;
  52520. t['a8'] = 537;
  52521. t['a9'] = 577;
  52522. t['a10'] = 692;
  52523. t['a29'] = 786;
  52524. t['a30'] = 788;
  52525. t['a31'] = 788;
  52526. t['a32'] = 790;
  52527. t['a33'] = 793;
  52528. t['a34'] = 794;
  52529. t['a35'] = 816;
  52530. t['a36'] = 823;
  52531. t['a37'] = 789;
  52532. t['a38'] = 841;
  52533. t['a39'] = 823;
  52534. t['a40'] = 833;
  52535. t['a41'] = 816;
  52536. t['a42'] = 831;
  52537. t['a43'] = 923;
  52538. t['a44'] = 744;
  52539. t['a45'] = 723;
  52540. t['a46'] = 749;
  52541. t['a47'] = 790;
  52542. t['a48'] = 792;
  52543. t['a49'] = 695;
  52544. t['a50'] = 776;
  52545. t['a51'] = 768;
  52546. t['a52'] = 792;
  52547. t['a53'] = 759;
  52548. t['a54'] = 707;
  52549. t['a55'] = 708;
  52550. t['a56'] = 682;
  52551. t['a57'] = 701;
  52552. t['a58'] = 826;
  52553. t['a59'] = 815;
  52554. t['a60'] = 789;
  52555. t['a61'] = 789;
  52556. t['a62'] = 707;
  52557. t['a63'] = 687;
  52558. t['a64'] = 696;
  52559. t['a65'] = 689;
  52560. t['a66'] = 786;
  52561. t['a67'] = 787;
  52562. t['a68'] = 713;
  52563. t['a69'] = 791;
  52564. t['a70'] = 785;
  52565. t['a71'] = 791;
  52566. t['a72'] = 873;
  52567. t['a73'] = 761;
  52568. t['a74'] = 762;
  52569. t['a203'] = 762;
  52570. t['a75'] = 759;
  52571. t['a204'] = 759;
  52572. t['a76'] = 892;
  52573. t['a77'] = 892;
  52574. t['a78'] = 788;
  52575. t['a79'] = 784;
  52576. t['a81'] = 438;
  52577. t['a82'] = 138;
  52578. t['a83'] = 277;
  52579. t['a84'] = 415;
  52580. t['a97'] = 392;
  52581. t['a98'] = 392;
  52582. t['a99'] = 668;
  52583. t['a100'] = 668;
  52584. t['a89'] = 390;
  52585. t['a90'] = 390;
  52586. t['a93'] = 317;
  52587. t['a94'] = 317;
  52588. t['a91'] = 276;
  52589. t['a92'] = 276;
  52590. t['a205'] = 509;
  52591. t['a85'] = 509;
  52592. t['a206'] = 410;
  52593. t['a86'] = 410;
  52594. t['a87'] = 234;
  52595. t['a88'] = 234;
  52596. t['a95'] = 334;
  52597. t['a96'] = 334;
  52598. t['a101'] = 732;
  52599. t['a102'] = 544;
  52600. t['a103'] = 544;
  52601. t['a104'] = 910;
  52602. t['a106'] = 667;
  52603. t['a107'] = 760;
  52604. t['a108'] = 760;
  52605. t['a112'] = 776;
  52606. t['a111'] = 595;
  52607. t['a110'] = 694;
  52608. t['a109'] = 626;
  52609. t['a120'] = 788;
  52610. t['a121'] = 788;
  52611. t['a122'] = 788;
  52612. t['a123'] = 788;
  52613. t['a124'] = 788;
  52614. t['a125'] = 788;
  52615. t['a126'] = 788;
  52616. t['a127'] = 788;
  52617. t['a128'] = 788;
  52618. t['a129'] = 788;
  52619. t['a130'] = 788;
  52620. t['a131'] = 788;
  52621. t['a132'] = 788;
  52622. t['a133'] = 788;
  52623. t['a134'] = 788;
  52624. t['a135'] = 788;
  52625. t['a136'] = 788;
  52626. t['a137'] = 788;
  52627. t['a138'] = 788;
  52628. t['a139'] = 788;
  52629. t['a140'] = 788;
  52630. t['a141'] = 788;
  52631. t['a142'] = 788;
  52632. t['a143'] = 788;
  52633. t['a144'] = 788;
  52634. t['a145'] = 788;
  52635. t['a146'] = 788;
  52636. t['a147'] = 788;
  52637. t['a148'] = 788;
  52638. t['a149'] = 788;
  52639. t['a150'] = 788;
  52640. t['a151'] = 788;
  52641. t['a152'] = 788;
  52642. t['a153'] = 788;
  52643. t['a154'] = 788;
  52644. t['a155'] = 788;
  52645. t['a156'] = 788;
  52646. t['a157'] = 788;
  52647. t['a158'] = 788;
  52648. t['a159'] = 788;
  52649. t['a160'] = 894;
  52650. t['a161'] = 838;
  52651. t['a163'] = 1016;
  52652. t['a164'] = 458;
  52653. t['a196'] = 748;
  52654. t['a165'] = 924;
  52655. t['a192'] = 748;
  52656. t['a166'] = 918;
  52657. t['a167'] = 927;
  52658. t['a168'] = 928;
  52659. t['a169'] = 928;
  52660. t['a170'] = 834;
  52661. t['a171'] = 873;
  52662. t['a172'] = 828;
  52663. t['a173'] = 924;
  52664. t['a162'] = 924;
  52665. t['a174'] = 917;
  52666. t['a175'] = 930;
  52667. t['a176'] = 931;
  52668. t['a177'] = 463;
  52669. t['a178'] = 883;
  52670. t['a179'] = 836;
  52671. t['a193'] = 836;
  52672. t['a180'] = 867;
  52673. t['a199'] = 867;
  52674. t['a181'] = 696;
  52675. t['a200'] = 696;
  52676. t['a182'] = 874;
  52677. t['a201'] = 874;
  52678. t['a183'] = 760;
  52679. t['a184'] = 946;
  52680. t['a197'] = 771;
  52681. t['a185'] = 865;
  52682. t['a194'] = 771;
  52683. t['a198'] = 888;
  52684. t['a186'] = 967;
  52685. t['a195'] = 888;
  52686. t['a187'] = 831;
  52687. t['a188'] = 873;
  52688. t['a189'] = 927;
  52689. t['a190'] = 970;
  52690. t['a191'] = 918;
  52691. });
  52692. });
  52693. exports.getMetrics = getMetrics;
  52694. /***/ }),
  52695. /* 40 */
  52696. /***/ (function(module, exports, __w_pdfjs_require__) {
  52697. "use strict";
  52698. var sharedUtil = __w_pdfjs_require__(0);
  52699. var Uint32ArrayView = sharedUtil.Uint32ArrayView;
  52700. var MurmurHash3_64 = function MurmurHash3_64Closure(seed) {
  52701. var MASK_HIGH = 0xffff0000;
  52702. var MASK_LOW = 0xffff;
  52703. function MurmurHash3_64(seed) {
  52704. var SEED = 0xc3d2e1f0;
  52705. this.h1 = seed ? seed & 0xffffffff : SEED;
  52706. this.h2 = seed ? seed & 0xffffffff : SEED;
  52707. }
  52708. var alwaysUseUint32ArrayView = false;
  52709. try {
  52710. new Uint32Array(new Uint8Array(5).buffer, 0, 1);
  52711. } catch (e) {
  52712. alwaysUseUint32ArrayView = true;
  52713. }
  52714. MurmurHash3_64.prototype = {
  52715. update: function MurmurHash3_64_update(input) {
  52716. var useUint32ArrayView = alwaysUseUint32ArrayView;
  52717. var i;
  52718. if (typeof input === 'string') {
  52719. var data = new Uint8Array(input.length * 2);
  52720. var length = 0;
  52721. for (i = 0; i < input.length; i++) {
  52722. var code = input.charCodeAt(i);
  52723. if (code <= 0xff) {
  52724. data[length++] = code;
  52725. } else {
  52726. data[length++] = code >>> 8;
  52727. data[length++] = code & 0xff;
  52728. }
  52729. }
  52730. } else if (input instanceof Uint8Array) {
  52731. data = input;
  52732. length = data.length;
  52733. } else if (typeof input === 'object' && 'length' in input) {
  52734. data = input;
  52735. length = data.length;
  52736. useUint32ArrayView = true;
  52737. } else {
  52738. throw new Error('Wrong data format in MurmurHash3_64_update. ' + 'Input must be a string or array.');
  52739. }
  52740. var blockCounts = length >> 2;
  52741. var tailLength = length - blockCounts * 4;
  52742. var dataUint32 = useUint32ArrayView ? new Uint32ArrayView(data, blockCounts) : new Uint32Array(data.buffer, 0, blockCounts);
  52743. var k1 = 0;
  52744. var k2 = 0;
  52745. var h1 = this.h1;
  52746. var h2 = this.h2;
  52747. var C1 = 0xcc9e2d51;
  52748. var C2 = 0x1b873593;
  52749. var C1_LOW = C1 & MASK_LOW;
  52750. var C2_LOW = C2 & MASK_LOW;
  52751. for (i = 0; i < blockCounts; i++) {
  52752. if (i & 1) {
  52753. k1 = dataUint32[i];
  52754. k1 = k1 * C1 & MASK_HIGH | k1 * C1_LOW & MASK_LOW;
  52755. k1 = k1 << 15 | k1 >>> 17;
  52756. k1 = k1 * C2 & MASK_HIGH | k1 * C2_LOW & MASK_LOW;
  52757. h1 ^= k1;
  52758. h1 = h1 << 13 | h1 >>> 19;
  52759. h1 = h1 * 5 + 0xe6546b64;
  52760. } else {
  52761. k2 = dataUint32[i];
  52762. k2 = k2 * C1 & MASK_HIGH | k2 * C1_LOW & MASK_LOW;
  52763. k2 = k2 << 15 | k2 >>> 17;
  52764. k2 = k2 * C2 & MASK_HIGH | k2 * C2_LOW & MASK_LOW;
  52765. h2 ^= k2;
  52766. h2 = h2 << 13 | h2 >>> 19;
  52767. h2 = h2 * 5 + 0xe6546b64;
  52768. }
  52769. }
  52770. k1 = 0;
  52771. switch (tailLength) {
  52772. case 3:
  52773. k1 ^= data[blockCounts * 4 + 2] << 16;
  52774. case 2:
  52775. k1 ^= data[blockCounts * 4 + 1] << 8;
  52776. case 1:
  52777. k1 ^= data[blockCounts * 4];
  52778. k1 = k1 * C1 & MASK_HIGH | k1 * C1_LOW & MASK_LOW;
  52779. k1 = k1 << 15 | k1 >>> 17;
  52780. k1 = k1 * C2 & MASK_HIGH | k1 * C2_LOW & MASK_LOW;
  52781. if (blockCounts & 1) {
  52782. h1 ^= k1;
  52783. } else {
  52784. h2 ^= k1;
  52785. }
  52786. }
  52787. this.h1 = h1;
  52788. this.h2 = h2;
  52789. return this;
  52790. },
  52791. hexdigest: function MurmurHash3_64_hexdigest() {
  52792. var h1 = this.h1;
  52793. var h2 = this.h2;
  52794. h1 ^= h2 >>> 1;
  52795. h1 = h1 * 0xed558ccd & MASK_HIGH | h1 * 0x8ccd & MASK_LOW;
  52796. h2 = h2 * 0xff51afd7 & MASK_HIGH | ((h2 << 16 | h1 >>> 16) * 0xafd7ed55 & MASK_HIGH) >>> 16;
  52797. h1 ^= h2 >>> 1;
  52798. h1 = h1 * 0x1a85ec53 & MASK_HIGH | h1 * 0xec53 & MASK_LOW;
  52799. h2 = h2 * 0xc4ceb9fe & MASK_HIGH | ((h2 << 16 | h1 >>> 16) * 0xb9fe1a85 & MASK_HIGH) >>> 16;
  52800. h1 ^= h2 >>> 1;
  52801. for (var i = 0, arr = [
  52802. h1,
  52803. h2
  52804. ], str = ''; i < arr.length; i++) {
  52805. var hex = (arr[i] >>> 0).toString(16);
  52806. while (hex.length < 8) {
  52807. hex = '0' + hex;
  52808. }
  52809. str += hex;
  52810. }
  52811. return str;
  52812. }
  52813. };
  52814. return MurmurHash3_64;
  52815. }();
  52816. exports.MurmurHash3_64 = MurmurHash3_64;
  52817. /***/ }),
  52818. /* 41 */
  52819. /***/ (function(module, exports, __w_pdfjs_require__) {
  52820. "use strict";
  52821. var sharedUtil = __w_pdfjs_require__(0);
  52822. var corePrimitives = __w_pdfjs_require__(1);
  52823. var coreFunction = __w_pdfjs_require__(7);
  52824. var coreColorSpace = __w_pdfjs_require__(4);
  52825. var UNSUPPORTED_FEATURES = sharedUtil.UNSUPPORTED_FEATURES;
  52826. var MissingDataException = sharedUtil.MissingDataException;
  52827. var Util = sharedUtil.Util;
  52828. var assert = sharedUtil.assert;
  52829. var error = sharedUtil.error;
  52830. var info = sharedUtil.info;
  52831. var warn = sharedUtil.warn;
  52832. var isStream = corePrimitives.isStream;
  52833. var PDFFunction = coreFunction.PDFFunction;
  52834. var ColorSpace = coreColorSpace.ColorSpace;
  52835. var ShadingType = {
  52836. FUNCTION_BASED: 1,
  52837. AXIAL: 2,
  52838. RADIAL: 3,
  52839. FREE_FORM_MESH: 4,
  52840. LATTICE_FORM_MESH: 5,
  52841. COONS_PATCH_MESH: 6,
  52842. TENSOR_PATCH_MESH: 7
  52843. };
  52844. var Pattern = function PatternClosure() {
  52845. function Pattern() {
  52846. error('should not call Pattern constructor');
  52847. }
  52848. Pattern.prototype = {
  52849. getPattern: function Pattern_getPattern(ctx) {
  52850. error('Should not call Pattern.getStyle: ' + ctx);
  52851. }
  52852. };
  52853. Pattern.parseShading = function Pattern_parseShading(shading, matrix, xref, res, handler) {
  52854. var dict = isStream(shading) ? shading.dict : shading;
  52855. var type = dict.get('ShadingType');
  52856. try {
  52857. switch (type) {
  52858. case ShadingType.AXIAL:
  52859. case ShadingType.RADIAL:
  52860. return new Shadings.RadialAxial(dict, matrix, xref, res);
  52861. case ShadingType.FREE_FORM_MESH:
  52862. case ShadingType.LATTICE_FORM_MESH:
  52863. case ShadingType.COONS_PATCH_MESH:
  52864. case ShadingType.TENSOR_PATCH_MESH:
  52865. return new Shadings.Mesh(shading, matrix, xref, res);
  52866. default:
  52867. throw new Error('Unsupported ShadingType: ' + type);
  52868. }
  52869. } catch (ex) {
  52870. if (ex instanceof MissingDataException) {
  52871. throw ex;
  52872. }
  52873. handler.send('UnsupportedFeature', { featureId: UNSUPPORTED_FEATURES.shadingPattern });
  52874. warn(ex);
  52875. return new Shadings.Dummy();
  52876. }
  52877. };
  52878. return Pattern;
  52879. }();
  52880. var Shadings = {};
  52881. Shadings.SMALL_NUMBER = 1e-6;
  52882. Shadings.RadialAxial = function RadialAxialClosure() {
  52883. function RadialAxial(dict, matrix, xref, res) {
  52884. this.matrix = matrix;
  52885. this.coordsArr = dict.getArray('Coords');
  52886. this.shadingType = dict.get('ShadingType');
  52887. this.type = 'Pattern';
  52888. var cs = dict.get('ColorSpace', 'CS');
  52889. cs = ColorSpace.parse(cs, xref, res);
  52890. this.cs = cs;
  52891. var t0 = 0.0, t1 = 1.0;
  52892. if (dict.has('Domain')) {
  52893. var domainArr = dict.getArray('Domain');
  52894. t0 = domainArr[0];
  52895. t1 = domainArr[1];
  52896. }
  52897. var extendStart = false, extendEnd = false;
  52898. if (dict.has('Extend')) {
  52899. var extendArr = dict.getArray('Extend');
  52900. extendStart = extendArr[0];
  52901. extendEnd = extendArr[1];
  52902. }
  52903. if (this.shadingType === ShadingType.RADIAL && (!extendStart || !extendEnd)) {
  52904. var x1 = this.coordsArr[0];
  52905. var y1 = this.coordsArr[1];
  52906. var r1 = this.coordsArr[2];
  52907. var x2 = this.coordsArr[3];
  52908. var y2 = this.coordsArr[4];
  52909. var r2 = this.coordsArr[5];
  52910. var distance = Math.sqrt((x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2));
  52911. if (r1 <= r2 + distance && r2 <= r1 + distance) {
  52912. warn('Unsupported radial gradient.');
  52913. }
  52914. }
  52915. this.extendStart = extendStart;
  52916. this.extendEnd = extendEnd;
  52917. var fnObj = dict.get('Function');
  52918. var fn = PDFFunction.parseArray(xref, fnObj);
  52919. var diff = t1 - t0;
  52920. var step = diff / 10;
  52921. var colorStops = this.colorStops = [];
  52922. if (t0 >= t1 || step <= 0) {
  52923. info('Bad shading domain.');
  52924. return;
  52925. }
  52926. var color = new Float32Array(cs.numComps), ratio = new Float32Array(1);
  52927. var rgbColor;
  52928. for (var i = t0; i <= t1; i += step) {
  52929. ratio[0] = i;
  52930. fn(ratio, 0, color, 0);
  52931. rgbColor = cs.getRgb(color, 0);
  52932. var cssColor = Util.makeCssRgb(rgbColor[0], rgbColor[1], rgbColor[2]);
  52933. colorStops.push([
  52934. (i - t0) / diff,
  52935. cssColor
  52936. ]);
  52937. }
  52938. var background = 'transparent';
  52939. if (dict.has('Background')) {
  52940. rgbColor = cs.getRgb(dict.get('Background'), 0);
  52941. background = Util.makeCssRgb(rgbColor[0], rgbColor[1], rgbColor[2]);
  52942. }
  52943. if (!extendStart) {
  52944. colorStops.unshift([
  52945. 0,
  52946. background
  52947. ]);
  52948. colorStops[1][0] += Shadings.SMALL_NUMBER;
  52949. }
  52950. if (!extendEnd) {
  52951. colorStops[colorStops.length - 1][0] -= Shadings.SMALL_NUMBER;
  52952. colorStops.push([
  52953. 1,
  52954. background
  52955. ]);
  52956. }
  52957. this.colorStops = colorStops;
  52958. }
  52959. RadialAxial.prototype = {
  52960. getIR: function RadialAxial_getIR() {
  52961. var coordsArr = this.coordsArr;
  52962. var shadingType = this.shadingType;
  52963. var type, p0, p1, r0, r1;
  52964. if (shadingType === ShadingType.AXIAL) {
  52965. p0 = [
  52966. coordsArr[0],
  52967. coordsArr[1]
  52968. ];
  52969. p1 = [
  52970. coordsArr[2],
  52971. coordsArr[3]
  52972. ];
  52973. r0 = null;
  52974. r1 = null;
  52975. type = 'axial';
  52976. } else if (shadingType === ShadingType.RADIAL) {
  52977. p0 = [
  52978. coordsArr[0],
  52979. coordsArr[1]
  52980. ];
  52981. p1 = [
  52982. coordsArr[3],
  52983. coordsArr[4]
  52984. ];
  52985. r0 = coordsArr[2];
  52986. r1 = coordsArr[5];
  52987. type = 'radial';
  52988. } else {
  52989. error('getPattern type unknown: ' + shadingType);
  52990. }
  52991. var matrix = this.matrix;
  52992. if (matrix) {
  52993. p0 = Util.applyTransform(p0, matrix);
  52994. p1 = Util.applyTransform(p1, matrix);
  52995. if (shadingType === ShadingType.RADIAL) {
  52996. var scale = Util.singularValueDecompose2dScale(matrix);
  52997. r0 *= scale[0];
  52998. r1 *= scale[1];
  52999. }
  53000. }
  53001. return [
  53002. 'RadialAxial',
  53003. type,
  53004. this.colorStops,
  53005. p0,
  53006. p1,
  53007. r0,
  53008. r1
  53009. ];
  53010. }
  53011. };
  53012. return RadialAxial;
  53013. }();
  53014. Shadings.Mesh = function MeshClosure() {
  53015. function MeshStreamReader(stream, context) {
  53016. this.stream = stream;
  53017. this.context = context;
  53018. this.buffer = 0;
  53019. this.bufferLength = 0;
  53020. var numComps = context.numComps;
  53021. this.tmpCompsBuf = new Float32Array(numComps);
  53022. var csNumComps = context.colorSpace.numComps;
  53023. this.tmpCsCompsBuf = context.colorFn ? new Float32Array(csNumComps) : this.tmpCompsBuf;
  53024. }
  53025. MeshStreamReader.prototype = {
  53026. get hasData() {
  53027. if (this.stream.end) {
  53028. return this.stream.pos < this.stream.end;
  53029. }
  53030. if (this.bufferLength > 0) {
  53031. return true;
  53032. }
  53033. var nextByte = this.stream.getByte();
  53034. if (nextByte < 0) {
  53035. return false;
  53036. }
  53037. this.buffer = nextByte;
  53038. this.bufferLength = 8;
  53039. return true;
  53040. },
  53041. readBits: function MeshStreamReader_readBits(n) {
  53042. var buffer = this.buffer;
  53043. var bufferLength = this.bufferLength;
  53044. if (n === 32) {
  53045. if (bufferLength === 0) {
  53046. return (this.stream.getByte() << 24 | this.stream.getByte() << 16 | this.stream.getByte() << 8 | this.stream.getByte()) >>> 0;
  53047. }
  53048. buffer = buffer << 24 | this.stream.getByte() << 16 | this.stream.getByte() << 8 | this.stream.getByte();
  53049. var nextByte = this.stream.getByte();
  53050. this.buffer = nextByte & (1 << bufferLength) - 1;
  53051. return (buffer << 8 - bufferLength | (nextByte & 0xFF) >> bufferLength) >>> 0;
  53052. }
  53053. if (n === 8 && bufferLength === 0) {
  53054. return this.stream.getByte();
  53055. }
  53056. while (bufferLength < n) {
  53057. buffer = buffer << 8 | this.stream.getByte();
  53058. bufferLength += 8;
  53059. }
  53060. bufferLength -= n;
  53061. this.bufferLength = bufferLength;
  53062. this.buffer = buffer & (1 << bufferLength) - 1;
  53063. return buffer >> bufferLength;
  53064. },
  53065. align: function MeshStreamReader_align() {
  53066. this.buffer = 0;
  53067. this.bufferLength = 0;
  53068. },
  53069. readFlag: function MeshStreamReader_readFlag() {
  53070. return this.readBits(this.context.bitsPerFlag);
  53071. },
  53072. readCoordinate: function MeshStreamReader_readCoordinate() {
  53073. var bitsPerCoordinate = this.context.bitsPerCoordinate;
  53074. var xi = this.readBits(bitsPerCoordinate);
  53075. var yi = this.readBits(bitsPerCoordinate);
  53076. var decode = this.context.decode;
  53077. var scale = bitsPerCoordinate < 32 ? 1 / ((1 << bitsPerCoordinate) - 1) : 2.3283064365386963e-10;
  53078. return [
  53079. xi * scale * (decode[1] - decode[0]) + decode[0],
  53080. yi * scale * (decode[3] - decode[2]) + decode[2]
  53081. ];
  53082. },
  53083. readComponents: function MeshStreamReader_readComponents() {
  53084. var numComps = this.context.numComps;
  53085. var bitsPerComponent = this.context.bitsPerComponent;
  53086. var scale = bitsPerComponent < 32 ? 1 / ((1 << bitsPerComponent) - 1) : 2.3283064365386963e-10;
  53087. var decode = this.context.decode;
  53088. var components = this.tmpCompsBuf;
  53089. for (var i = 0, j = 4; i < numComps; i++, j += 2) {
  53090. var ci = this.readBits(bitsPerComponent);
  53091. components[i] = ci * scale * (decode[j + 1] - decode[j]) + decode[j];
  53092. }
  53093. var color = this.tmpCsCompsBuf;
  53094. if (this.context.colorFn) {
  53095. this.context.colorFn(components, 0, color, 0);
  53096. }
  53097. return this.context.colorSpace.getRgb(color, 0);
  53098. }
  53099. };
  53100. function decodeType4Shading(mesh, reader) {
  53101. var coords = mesh.coords;
  53102. var colors = mesh.colors;
  53103. var operators = [];
  53104. var ps = [];
  53105. var verticesLeft = 0;
  53106. while (reader.hasData) {
  53107. var f = reader.readFlag();
  53108. var coord = reader.readCoordinate();
  53109. var color = reader.readComponents();
  53110. if (verticesLeft === 0) {
  53111. assert(0 <= f && f <= 2, 'Unknown type4 flag');
  53112. switch (f) {
  53113. case 0:
  53114. verticesLeft = 3;
  53115. break;
  53116. case 1:
  53117. ps.push(ps[ps.length - 2], ps[ps.length - 1]);
  53118. verticesLeft = 1;
  53119. break;
  53120. case 2:
  53121. ps.push(ps[ps.length - 3], ps[ps.length - 1]);
  53122. verticesLeft = 1;
  53123. break;
  53124. }
  53125. operators.push(f);
  53126. }
  53127. ps.push(coords.length);
  53128. coords.push(coord);
  53129. colors.push(color);
  53130. verticesLeft--;
  53131. reader.align();
  53132. }
  53133. mesh.figures.push({
  53134. type: 'triangles',
  53135. coords: new Int32Array(ps),
  53136. colors: new Int32Array(ps)
  53137. });
  53138. }
  53139. function decodeType5Shading(mesh, reader, verticesPerRow) {
  53140. var coords = mesh.coords;
  53141. var colors = mesh.colors;
  53142. var ps = [];
  53143. while (reader.hasData) {
  53144. var coord = reader.readCoordinate();
  53145. var color = reader.readComponents();
  53146. ps.push(coords.length);
  53147. coords.push(coord);
  53148. colors.push(color);
  53149. }
  53150. mesh.figures.push({
  53151. type: 'lattice',
  53152. coords: new Int32Array(ps),
  53153. colors: new Int32Array(ps),
  53154. verticesPerRow: verticesPerRow
  53155. });
  53156. }
  53157. var MIN_SPLIT_PATCH_CHUNKS_AMOUNT = 3;
  53158. var MAX_SPLIT_PATCH_CHUNKS_AMOUNT = 20;
  53159. var TRIANGLE_DENSITY = 20;
  53160. var getB = function getBClosure() {
  53161. function buildB(count) {
  53162. var lut = [];
  53163. for (var i = 0; i <= count; i++) {
  53164. var t = i / count, t_ = 1 - t;
  53165. lut.push(new Float32Array([
  53166. t_ * t_ * t_,
  53167. 3 * t * t_ * t_,
  53168. 3 * t * t * t_,
  53169. t * t * t
  53170. ]));
  53171. }
  53172. return lut;
  53173. }
  53174. var cache = [];
  53175. return function getB(count) {
  53176. if (!cache[count]) {
  53177. cache[count] = buildB(count);
  53178. }
  53179. return cache[count];
  53180. };
  53181. }();
  53182. function buildFigureFromPatch(mesh, index) {
  53183. var figure = mesh.figures[index];
  53184. assert(figure.type === 'patch', 'Unexpected patch mesh figure');
  53185. var coords = mesh.coords, colors = mesh.colors;
  53186. var pi = figure.coords;
  53187. var ci = figure.colors;
  53188. var figureMinX = Math.min(coords[pi[0]][0], coords[pi[3]][0], coords[pi[12]][0], coords[pi[15]][0]);
  53189. var figureMinY = Math.min(coords[pi[0]][1], coords[pi[3]][1], coords[pi[12]][1], coords[pi[15]][1]);
  53190. var figureMaxX = Math.max(coords[pi[0]][0], coords[pi[3]][0], coords[pi[12]][0], coords[pi[15]][0]);
  53191. var figureMaxY = Math.max(coords[pi[0]][1], coords[pi[3]][1], coords[pi[12]][1], coords[pi[15]][1]);
  53192. var splitXBy = Math.ceil((figureMaxX - figureMinX) * TRIANGLE_DENSITY / (mesh.bounds[2] - mesh.bounds[0]));
  53193. splitXBy = Math.max(MIN_SPLIT_PATCH_CHUNKS_AMOUNT, Math.min(MAX_SPLIT_PATCH_CHUNKS_AMOUNT, splitXBy));
  53194. var splitYBy = Math.ceil((figureMaxY - figureMinY) * TRIANGLE_DENSITY / (mesh.bounds[3] - mesh.bounds[1]));
  53195. splitYBy = Math.max(MIN_SPLIT_PATCH_CHUNKS_AMOUNT, Math.min(MAX_SPLIT_PATCH_CHUNKS_AMOUNT, splitYBy));
  53196. var verticesPerRow = splitXBy + 1;
  53197. var figureCoords = new Int32Array((splitYBy + 1) * verticesPerRow);
  53198. var figureColors = new Int32Array((splitYBy + 1) * verticesPerRow);
  53199. var k = 0;
  53200. var cl = new Uint8Array(3), cr = new Uint8Array(3);
  53201. var c0 = colors[ci[0]], c1 = colors[ci[1]], c2 = colors[ci[2]], c3 = colors[ci[3]];
  53202. var bRow = getB(splitYBy), bCol = getB(splitXBy);
  53203. for (var row = 0; row <= splitYBy; row++) {
  53204. cl[0] = (c0[0] * (splitYBy - row) + c2[0] * row) / splitYBy | 0;
  53205. cl[1] = (c0[1] * (splitYBy - row) + c2[1] * row) / splitYBy | 0;
  53206. cl[2] = (c0[2] * (splitYBy - row) + c2[2] * row) / splitYBy | 0;
  53207. cr[0] = (c1[0] * (splitYBy - row) + c3[0] * row) / splitYBy | 0;
  53208. cr[1] = (c1[1] * (splitYBy - row) + c3[1] * row) / splitYBy | 0;
  53209. cr[2] = (c1[2] * (splitYBy - row) + c3[2] * row) / splitYBy | 0;
  53210. for (var col = 0; col <= splitXBy; col++, k++) {
  53211. if ((row === 0 || row === splitYBy) && (col === 0 || col === splitXBy)) {
  53212. continue;
  53213. }
  53214. var x = 0, y = 0;
  53215. var q = 0;
  53216. for (var i = 0; i <= 3; i++) {
  53217. for (var j = 0; j <= 3; j++, q++) {
  53218. var m = bRow[row][i] * bCol[col][j];
  53219. x += coords[pi[q]][0] * m;
  53220. y += coords[pi[q]][1] * m;
  53221. }
  53222. }
  53223. figureCoords[k] = coords.length;
  53224. coords.push([
  53225. x,
  53226. y
  53227. ]);
  53228. figureColors[k] = colors.length;
  53229. var newColor = new Uint8Array(3);
  53230. newColor[0] = (cl[0] * (splitXBy - col) + cr[0] * col) / splitXBy | 0;
  53231. newColor[1] = (cl[1] * (splitXBy - col) + cr[1] * col) / splitXBy | 0;
  53232. newColor[2] = (cl[2] * (splitXBy - col) + cr[2] * col) / splitXBy | 0;
  53233. colors.push(newColor);
  53234. }
  53235. }
  53236. figureCoords[0] = pi[0];
  53237. figureColors[0] = ci[0];
  53238. figureCoords[splitXBy] = pi[3];
  53239. figureColors[splitXBy] = ci[1];
  53240. figureCoords[verticesPerRow * splitYBy] = pi[12];
  53241. figureColors[verticesPerRow * splitYBy] = ci[2];
  53242. figureCoords[verticesPerRow * splitYBy + splitXBy] = pi[15];
  53243. figureColors[verticesPerRow * splitYBy + splitXBy] = ci[3];
  53244. mesh.figures[index] = {
  53245. type: 'lattice',
  53246. coords: figureCoords,
  53247. colors: figureColors,
  53248. verticesPerRow: verticesPerRow
  53249. };
  53250. }
  53251. function decodeType6Shading(mesh, reader) {
  53252. var coords = mesh.coords;
  53253. var colors = mesh.colors;
  53254. var ps = new Int32Array(16);
  53255. var cs = new Int32Array(4);
  53256. while (reader.hasData) {
  53257. var f = reader.readFlag();
  53258. assert(0 <= f && f <= 3, 'Unknown type6 flag');
  53259. var i, ii;
  53260. var pi = coords.length;
  53261. for (i = 0, ii = f !== 0 ? 8 : 12; i < ii; i++) {
  53262. coords.push(reader.readCoordinate());
  53263. }
  53264. var ci = colors.length;
  53265. for (i = 0, ii = f !== 0 ? 2 : 4; i < ii; i++) {
  53266. colors.push(reader.readComponents());
  53267. }
  53268. var tmp1, tmp2, tmp3, tmp4;
  53269. switch (f) {
  53270. case 0:
  53271. ps[12] = pi + 3;
  53272. ps[13] = pi + 4;
  53273. ps[14] = pi + 5;
  53274. ps[15] = pi + 6;
  53275. ps[8] = pi + 2;
  53276. ps[11] = pi + 7;
  53277. ps[4] = pi + 1;
  53278. ps[7] = pi + 8;
  53279. ps[0] = pi;
  53280. ps[1] = pi + 11;
  53281. ps[2] = pi + 10;
  53282. ps[3] = pi + 9;
  53283. cs[2] = ci + 1;
  53284. cs[3] = ci + 2;
  53285. cs[0] = ci;
  53286. cs[1] = ci + 3;
  53287. break;
  53288. case 1:
  53289. tmp1 = ps[12];
  53290. tmp2 = ps[13];
  53291. tmp3 = ps[14];
  53292. tmp4 = ps[15];
  53293. ps[12] = tmp4;
  53294. ps[13] = pi + 0;
  53295. ps[14] = pi + 1;
  53296. ps[15] = pi + 2;
  53297. ps[8] = tmp3;
  53298. ps[11] = pi + 3;
  53299. ps[4] = tmp2;
  53300. ps[7] = pi + 4;
  53301. ps[0] = tmp1;
  53302. ps[1] = pi + 7;
  53303. ps[2] = pi + 6;
  53304. ps[3] = pi + 5;
  53305. tmp1 = cs[2];
  53306. tmp2 = cs[3];
  53307. cs[2] = tmp2;
  53308. cs[3] = ci;
  53309. cs[0] = tmp1;
  53310. cs[1] = ci + 1;
  53311. break;
  53312. case 2:
  53313. tmp1 = ps[15];
  53314. tmp2 = ps[11];
  53315. ps[12] = ps[3];
  53316. ps[13] = pi + 0;
  53317. ps[14] = pi + 1;
  53318. ps[15] = pi + 2;
  53319. ps[8] = ps[7];
  53320. ps[11] = pi + 3;
  53321. ps[4] = tmp2;
  53322. ps[7] = pi + 4;
  53323. ps[0] = tmp1;
  53324. ps[1] = pi + 7;
  53325. ps[2] = pi + 6;
  53326. ps[3] = pi + 5;
  53327. tmp1 = cs[3];
  53328. cs[2] = cs[1];
  53329. cs[3] = ci;
  53330. cs[0] = tmp1;
  53331. cs[1] = ci + 1;
  53332. break;
  53333. case 3:
  53334. ps[12] = ps[0];
  53335. ps[13] = pi + 0;
  53336. ps[14] = pi + 1;
  53337. ps[15] = pi + 2;
  53338. ps[8] = ps[1];
  53339. ps[11] = pi + 3;
  53340. ps[4] = ps[2];
  53341. ps[7] = pi + 4;
  53342. ps[0] = ps[3];
  53343. ps[1] = pi + 7;
  53344. ps[2] = pi + 6;
  53345. ps[3] = pi + 5;
  53346. cs[2] = cs[0];
  53347. cs[3] = ci;
  53348. cs[0] = cs[1];
  53349. cs[1] = ci + 1;
  53350. break;
  53351. }
  53352. ps[5] = coords.length;
  53353. coords.push([
  53354. (-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,
  53355. (-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
  53356. ]);
  53357. ps[6] = coords.length;
  53358. coords.push([
  53359. (-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,
  53360. (-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
  53361. ]);
  53362. ps[9] = coords.length;
  53363. coords.push([
  53364. (-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,
  53365. (-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
  53366. ]);
  53367. ps[10] = coords.length;
  53368. coords.push([
  53369. (-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,
  53370. (-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
  53371. ]);
  53372. mesh.figures.push({
  53373. type: 'patch',
  53374. coords: new Int32Array(ps),
  53375. colors: new Int32Array(cs)
  53376. });
  53377. }
  53378. }
  53379. function decodeType7Shading(mesh, reader) {
  53380. var coords = mesh.coords;
  53381. var colors = mesh.colors;
  53382. var ps = new Int32Array(16);
  53383. var cs = new Int32Array(4);
  53384. while (reader.hasData) {
  53385. var f = reader.readFlag();
  53386. assert(0 <= f && f <= 3, 'Unknown type7 flag');
  53387. var i, ii;
  53388. var pi = coords.length;
  53389. for (i = 0, ii = f !== 0 ? 12 : 16; i < ii; i++) {
  53390. coords.push(reader.readCoordinate());
  53391. }
  53392. var ci = colors.length;
  53393. for (i = 0, ii = f !== 0 ? 2 : 4; i < ii; i++) {
  53394. colors.push(reader.readComponents());
  53395. }
  53396. var tmp1, tmp2, tmp3, tmp4;
  53397. switch (f) {
  53398. case 0:
  53399. ps[12] = pi + 3;
  53400. ps[13] = pi + 4;
  53401. ps[14] = pi + 5;
  53402. ps[15] = pi + 6;
  53403. ps[8] = pi + 2;
  53404. ps[9] = pi + 13;
  53405. ps[10] = pi + 14;
  53406. ps[11] = pi + 7;
  53407. ps[4] = pi + 1;
  53408. ps[5] = pi + 12;
  53409. ps[6] = pi + 15;
  53410. ps[7] = pi + 8;
  53411. ps[0] = pi;
  53412. ps[1] = pi + 11;
  53413. ps[2] = pi + 10;
  53414. ps[3] = pi + 9;
  53415. cs[2] = ci + 1;
  53416. cs[3] = ci + 2;
  53417. cs[0] = ci;
  53418. cs[1] = ci + 3;
  53419. break;
  53420. case 1:
  53421. tmp1 = ps[12];
  53422. tmp2 = ps[13];
  53423. tmp3 = ps[14];
  53424. tmp4 = ps[15];
  53425. ps[12] = tmp4;
  53426. ps[13] = pi + 0;
  53427. ps[14] = pi + 1;
  53428. ps[15] = pi + 2;
  53429. ps[8] = tmp3;
  53430. ps[9] = pi + 9;
  53431. ps[10] = pi + 10;
  53432. ps[11] = pi + 3;
  53433. ps[4] = tmp2;
  53434. ps[5] = pi + 8;
  53435. ps[6] = pi + 11;
  53436. ps[7] = pi + 4;
  53437. ps[0] = tmp1;
  53438. ps[1] = pi + 7;
  53439. ps[2] = pi + 6;
  53440. ps[3] = pi + 5;
  53441. tmp1 = cs[2];
  53442. tmp2 = cs[3];
  53443. cs[2] = tmp2;
  53444. cs[3] = ci;
  53445. cs[0] = tmp1;
  53446. cs[1] = ci + 1;
  53447. break;
  53448. case 2:
  53449. tmp1 = ps[15];
  53450. tmp2 = ps[11];
  53451. ps[12] = ps[3];
  53452. ps[13] = pi + 0;
  53453. ps[14] = pi + 1;
  53454. ps[15] = pi + 2;
  53455. ps[8] = ps[7];
  53456. ps[9] = pi + 9;
  53457. ps[10] = pi + 10;
  53458. ps[11] = pi + 3;
  53459. ps[4] = tmp2;
  53460. ps[5] = pi + 8;
  53461. ps[6] = pi + 11;
  53462. ps[7] = pi + 4;
  53463. ps[0] = tmp1;
  53464. ps[1] = pi + 7;
  53465. ps[2] = pi + 6;
  53466. ps[3] = pi + 5;
  53467. tmp1 = cs[3];
  53468. cs[2] = cs[1];
  53469. cs[3] = ci;
  53470. cs[0] = tmp1;
  53471. cs[1] = ci + 1;
  53472. break;
  53473. case 3:
  53474. ps[12] = ps[0];
  53475. ps[13] = pi + 0;
  53476. ps[14] = pi + 1;
  53477. ps[15] = pi + 2;
  53478. ps[8] = ps[1];
  53479. ps[9] = pi + 9;
  53480. ps[10] = pi + 10;
  53481. ps[11] = pi + 3;
  53482. ps[4] = ps[2];
  53483. ps[5] = pi + 8;
  53484. ps[6] = pi + 11;
  53485. ps[7] = pi + 4;
  53486. ps[0] = ps[3];
  53487. ps[1] = pi + 7;
  53488. ps[2] = pi + 6;
  53489. ps[3] = pi + 5;
  53490. cs[2] = cs[0];
  53491. cs[3] = ci;
  53492. cs[0] = cs[1];
  53493. cs[1] = ci + 1;
  53494. break;
  53495. }
  53496. mesh.figures.push({
  53497. type: 'patch',
  53498. coords: new Int32Array(ps),
  53499. colors: new Int32Array(cs)
  53500. });
  53501. }
  53502. }
  53503. function updateBounds(mesh) {
  53504. var minX = mesh.coords[0][0], minY = mesh.coords[0][1], maxX = minX, maxY = minY;
  53505. for (var i = 1, ii = mesh.coords.length; i < ii; i++) {
  53506. var x = mesh.coords[i][0], y = mesh.coords[i][1];
  53507. minX = minX > x ? x : minX;
  53508. minY = minY > y ? y : minY;
  53509. maxX = maxX < x ? x : maxX;
  53510. maxY = maxY < y ? y : maxY;
  53511. }
  53512. mesh.bounds = [
  53513. minX,
  53514. minY,
  53515. maxX,
  53516. maxY
  53517. ];
  53518. }
  53519. function packData(mesh) {
  53520. var i, ii, j, jj;
  53521. var coords = mesh.coords;
  53522. var coordsPacked = new Float32Array(coords.length * 2);
  53523. for (i = 0, j = 0, ii = coords.length; i < ii; i++) {
  53524. var xy = coords[i];
  53525. coordsPacked[j++] = xy[0];
  53526. coordsPacked[j++] = xy[1];
  53527. }
  53528. mesh.coords = coordsPacked;
  53529. var colors = mesh.colors;
  53530. var colorsPacked = new Uint8Array(colors.length * 3);
  53531. for (i = 0, j = 0, ii = colors.length; i < ii; i++) {
  53532. var c = colors[i];
  53533. colorsPacked[j++] = c[0];
  53534. colorsPacked[j++] = c[1];
  53535. colorsPacked[j++] = c[2];
  53536. }
  53537. mesh.colors = colorsPacked;
  53538. var figures = mesh.figures;
  53539. for (i = 0, ii = figures.length; i < ii; i++) {
  53540. var figure = figures[i], ps = figure.coords, cs = figure.colors;
  53541. for (j = 0, jj = ps.length; j < jj; j++) {
  53542. ps[j] *= 2;
  53543. cs[j] *= 3;
  53544. }
  53545. }
  53546. }
  53547. function Mesh(stream, matrix, xref, res) {
  53548. assert(isStream(stream), 'Mesh data is not a stream');
  53549. var dict = stream.dict;
  53550. this.matrix = matrix;
  53551. this.shadingType = dict.get('ShadingType');
  53552. this.type = 'Pattern';
  53553. this.bbox = dict.getArray('BBox');
  53554. var cs = dict.get('ColorSpace', 'CS');
  53555. cs = ColorSpace.parse(cs, xref, res);
  53556. this.cs = cs;
  53557. this.background = dict.has('Background') ? cs.getRgb(dict.get('Background'), 0) : null;
  53558. var fnObj = dict.get('Function');
  53559. var fn = fnObj ? PDFFunction.parseArray(xref, fnObj) : null;
  53560. this.coords = [];
  53561. this.colors = [];
  53562. this.figures = [];
  53563. var decodeContext = {
  53564. bitsPerCoordinate: dict.get('BitsPerCoordinate'),
  53565. bitsPerComponent: dict.get('BitsPerComponent'),
  53566. bitsPerFlag: dict.get('BitsPerFlag'),
  53567. decode: dict.getArray('Decode'),
  53568. colorFn: fn,
  53569. colorSpace: cs,
  53570. numComps: fn ? 1 : cs.numComps
  53571. };
  53572. var reader = new MeshStreamReader(stream, decodeContext);
  53573. var patchMesh = false;
  53574. switch (this.shadingType) {
  53575. case ShadingType.FREE_FORM_MESH:
  53576. decodeType4Shading(this, reader);
  53577. break;
  53578. case ShadingType.LATTICE_FORM_MESH:
  53579. var verticesPerRow = dict.get('VerticesPerRow') | 0;
  53580. assert(verticesPerRow >= 2, 'Invalid VerticesPerRow');
  53581. decodeType5Shading(this, reader, verticesPerRow);
  53582. break;
  53583. case ShadingType.COONS_PATCH_MESH:
  53584. decodeType6Shading(this, reader);
  53585. patchMesh = true;
  53586. break;
  53587. case ShadingType.TENSOR_PATCH_MESH:
  53588. decodeType7Shading(this, reader);
  53589. patchMesh = true;
  53590. break;
  53591. default:
  53592. error('Unsupported mesh type.');
  53593. break;
  53594. }
  53595. if (patchMesh) {
  53596. updateBounds(this);
  53597. for (var i = 0, ii = this.figures.length; i < ii; i++) {
  53598. buildFigureFromPatch(this, i);
  53599. }
  53600. }
  53601. updateBounds(this);
  53602. packData(this);
  53603. }
  53604. Mesh.prototype = {
  53605. getIR: function Mesh_getIR() {
  53606. return [
  53607. 'Mesh',
  53608. this.shadingType,
  53609. this.coords,
  53610. this.colors,
  53611. this.figures,
  53612. this.bounds,
  53613. this.matrix,
  53614. this.bbox,
  53615. this.background
  53616. ];
  53617. }
  53618. };
  53619. return Mesh;
  53620. }();
  53621. Shadings.Dummy = function DummyClosure() {
  53622. function Dummy() {
  53623. this.type = 'Pattern';
  53624. }
  53625. Dummy.prototype = {
  53626. getIR: function Dummy_getIR() {
  53627. return ['Dummy'];
  53628. }
  53629. };
  53630. return Dummy;
  53631. }();
  53632. function getTilingPatternIR(operatorList, dict, args) {
  53633. var matrix = dict.getArray('Matrix');
  53634. var bbox = dict.getArray('BBox');
  53635. var xstep = dict.get('XStep');
  53636. var ystep = dict.get('YStep');
  53637. var paintType = dict.get('PaintType');
  53638. var tilingType = dict.get('TilingType');
  53639. return [
  53640. 'TilingPattern',
  53641. args,
  53642. operatorList,
  53643. matrix,
  53644. bbox,
  53645. xstep,
  53646. ystep,
  53647. paintType,
  53648. tilingType
  53649. ];
  53650. }
  53651. exports.Pattern = Pattern;
  53652. exports.getTilingPatternIR = getTilingPatternIR;
  53653. /***/ }),
  53654. /* 42 */
  53655. /***/ (function(module, exports, __w_pdfjs_require__) {
  53656. "use strict";
  53657. var sharedUtil = __w_pdfjs_require__(0);
  53658. var coreStream = __w_pdfjs_require__(2);
  53659. var coreChunkedStream = __w_pdfjs_require__(16);
  53660. var coreDocument = __w_pdfjs_require__(33);
  53661. var warn = sharedUtil.warn;
  53662. var createValidAbsoluteUrl = sharedUtil.createValidAbsoluteUrl;
  53663. var shadow = sharedUtil.shadow;
  53664. var NotImplementedException = sharedUtil.NotImplementedException;
  53665. var MissingDataException = sharedUtil.MissingDataException;
  53666. var createPromiseCapability = sharedUtil.createPromiseCapability;
  53667. var Util = sharedUtil.Util;
  53668. var Stream = coreStream.Stream;
  53669. var ChunkedStreamManager = coreChunkedStream.ChunkedStreamManager;
  53670. var PDFDocument = coreDocument.PDFDocument;
  53671. var BasePdfManager = function BasePdfManagerClosure() {
  53672. function BasePdfManager() {
  53673. throw new Error('Cannot initialize BaseManagerManager');
  53674. }
  53675. BasePdfManager.prototype = {
  53676. get docId() {
  53677. return this._docId;
  53678. },
  53679. get password() {
  53680. return this._password;
  53681. },
  53682. get docBaseUrl() {
  53683. var docBaseUrl = null;
  53684. if (this._docBaseUrl) {
  53685. var absoluteUrl = createValidAbsoluteUrl(this._docBaseUrl);
  53686. if (absoluteUrl) {
  53687. docBaseUrl = absoluteUrl.href;
  53688. } else {
  53689. warn('Invalid absolute docBaseUrl: "' + this._docBaseUrl + '".');
  53690. }
  53691. }
  53692. return shadow(this, 'docBaseUrl', docBaseUrl);
  53693. },
  53694. onLoadedStream: function BasePdfManager_onLoadedStream() {
  53695. throw new NotImplementedException();
  53696. },
  53697. ensureDoc: function BasePdfManager_ensureDoc(prop, args) {
  53698. return this.ensure(this.pdfDocument, prop, args);
  53699. },
  53700. ensureXRef: function BasePdfManager_ensureXRef(prop, args) {
  53701. return this.ensure(this.pdfDocument.xref, prop, args);
  53702. },
  53703. ensureCatalog: function BasePdfManager_ensureCatalog(prop, args) {
  53704. return this.ensure(this.pdfDocument.catalog, prop, args);
  53705. },
  53706. getPage: function BasePdfManager_getPage(pageIndex) {
  53707. return this.pdfDocument.getPage(pageIndex);
  53708. },
  53709. cleanup: function BasePdfManager_cleanup() {
  53710. return this.pdfDocument.cleanup();
  53711. },
  53712. ensure: function BasePdfManager_ensure(obj, prop, args) {
  53713. return new NotImplementedException();
  53714. },
  53715. requestRange: function BasePdfManager_requestRange(begin, end) {
  53716. return new NotImplementedException();
  53717. },
  53718. requestLoadedStream: function BasePdfManager_requestLoadedStream() {
  53719. return new NotImplementedException();
  53720. },
  53721. sendProgressiveData: function BasePdfManager_sendProgressiveData(chunk) {
  53722. return new NotImplementedException();
  53723. },
  53724. updatePassword: function BasePdfManager_updatePassword(password) {
  53725. this._password = password;
  53726. },
  53727. terminate: function BasePdfManager_terminate() {
  53728. return new NotImplementedException();
  53729. }
  53730. };
  53731. return BasePdfManager;
  53732. }();
  53733. var LocalPdfManager = function LocalPdfManagerClosure() {
  53734. function LocalPdfManager(docId, data, password, evaluatorOptions, docBaseUrl) {
  53735. this._docId = docId;
  53736. this._password = password;
  53737. this._docBaseUrl = docBaseUrl;
  53738. this.evaluatorOptions = evaluatorOptions;
  53739. var stream = new Stream(data);
  53740. this.pdfDocument = new PDFDocument(this, stream);
  53741. this._loadedStreamCapability = createPromiseCapability();
  53742. this._loadedStreamCapability.resolve(stream);
  53743. }
  53744. Util.inherit(LocalPdfManager, BasePdfManager, {
  53745. ensure: function LocalPdfManager_ensure(obj, prop, args) {
  53746. return new Promise(function (resolve, reject) {
  53747. try {
  53748. var value = obj[prop];
  53749. var result;
  53750. if (typeof value === 'function') {
  53751. result = value.apply(obj, args);
  53752. } else {
  53753. result = value;
  53754. }
  53755. resolve(result);
  53756. } catch (e) {
  53757. reject(e);
  53758. }
  53759. });
  53760. },
  53761. requestRange: function LocalPdfManager_requestRange(begin, end) {
  53762. return Promise.resolve();
  53763. },
  53764. requestLoadedStream: function LocalPdfManager_requestLoadedStream() {
  53765. },
  53766. onLoadedStream: function LocalPdfManager_onLoadedStream() {
  53767. return this._loadedStreamCapability.promise;
  53768. },
  53769. terminate: function LocalPdfManager_terminate() {
  53770. }
  53771. });
  53772. return LocalPdfManager;
  53773. }();
  53774. var NetworkPdfManager = function NetworkPdfManagerClosure() {
  53775. function NetworkPdfManager(docId, pdfNetworkStream, args, evaluatorOptions, docBaseUrl) {
  53776. this._docId = docId;
  53777. this._password = args.password;
  53778. this._docBaseUrl = docBaseUrl;
  53779. this.msgHandler = args.msgHandler;
  53780. this.evaluatorOptions = evaluatorOptions;
  53781. var params = {
  53782. msgHandler: args.msgHandler,
  53783. url: args.url,
  53784. length: args.length,
  53785. disableAutoFetch: args.disableAutoFetch,
  53786. rangeChunkSize: args.rangeChunkSize
  53787. };
  53788. this.streamManager = new ChunkedStreamManager(pdfNetworkStream, params);
  53789. this.pdfDocument = new PDFDocument(this, this.streamManager.getStream());
  53790. }
  53791. Util.inherit(NetworkPdfManager, BasePdfManager, {
  53792. ensure: function NetworkPdfManager_ensure(obj, prop, args) {
  53793. var pdfManager = this;
  53794. return new Promise(function (resolve, reject) {
  53795. function ensureHelper() {
  53796. try {
  53797. var result;
  53798. var value = obj[prop];
  53799. if (typeof value === 'function') {
  53800. result = value.apply(obj, args);
  53801. } else {
  53802. result = value;
  53803. }
  53804. resolve(result);
  53805. } catch (e) {
  53806. if (!(e instanceof MissingDataException)) {
  53807. reject(e);
  53808. return;
  53809. }
  53810. pdfManager.streamManager.requestRange(e.begin, e.end).then(ensureHelper, reject);
  53811. }
  53812. }
  53813. ensureHelper();
  53814. });
  53815. },
  53816. requestRange: function NetworkPdfManager_requestRange(begin, end) {
  53817. return this.streamManager.requestRange(begin, end);
  53818. },
  53819. requestLoadedStream: function NetworkPdfManager_requestLoadedStream() {
  53820. this.streamManager.requestAllChunks();
  53821. },
  53822. sendProgressiveData: function NetworkPdfManager_sendProgressiveData(chunk) {
  53823. this.streamManager.onReceiveData({ chunk: chunk });
  53824. },
  53825. onLoadedStream: function NetworkPdfManager_onLoadedStream() {
  53826. return this.streamManager.onLoadedStream();
  53827. },
  53828. terminate: function NetworkPdfManager_terminate() {
  53829. this.streamManager.abort();
  53830. }
  53831. });
  53832. return NetworkPdfManager;
  53833. }();
  53834. exports.LocalPdfManager = LocalPdfManager;
  53835. exports.NetworkPdfManager = NetworkPdfManager;
  53836. /***/ }),
  53837. /* 43 */
  53838. /***/ (function(module, exports, __w_pdfjs_require__) {
  53839. "use strict";
  53840. var sharedUtil = __w_pdfjs_require__(0);
  53841. var corePrimitives = __w_pdfjs_require__(1);
  53842. var error = sharedUtil.error;
  53843. var isSpace = sharedUtil.isSpace;
  53844. var EOF = corePrimitives.EOF;
  53845. var PostScriptParser = function PostScriptParserClosure() {
  53846. function PostScriptParser(lexer) {
  53847. this.lexer = lexer;
  53848. this.operators = [];
  53849. this.token = null;
  53850. this.prev = null;
  53851. }
  53852. PostScriptParser.prototype = {
  53853. nextToken: function PostScriptParser_nextToken() {
  53854. this.prev = this.token;
  53855. this.token = this.lexer.getToken();
  53856. },
  53857. accept: function PostScriptParser_accept(type) {
  53858. if (this.token.type === type) {
  53859. this.nextToken();
  53860. return true;
  53861. }
  53862. return false;
  53863. },
  53864. expect: function PostScriptParser_expect(type) {
  53865. if (this.accept(type)) {
  53866. return true;
  53867. }
  53868. error('Unexpected symbol: found ' + this.token.type + ' expected ' + type + '.');
  53869. },
  53870. parse: function PostScriptParser_parse() {
  53871. this.nextToken();
  53872. this.expect(PostScriptTokenTypes.LBRACE);
  53873. this.parseBlock();
  53874. this.expect(PostScriptTokenTypes.RBRACE);
  53875. return this.operators;
  53876. },
  53877. parseBlock: function PostScriptParser_parseBlock() {
  53878. while (true) {
  53879. if (this.accept(PostScriptTokenTypes.NUMBER)) {
  53880. this.operators.push(this.prev.value);
  53881. } else if (this.accept(PostScriptTokenTypes.OPERATOR)) {
  53882. this.operators.push(this.prev.value);
  53883. } else if (this.accept(PostScriptTokenTypes.LBRACE)) {
  53884. this.parseCondition();
  53885. } else {
  53886. return;
  53887. }
  53888. }
  53889. },
  53890. parseCondition: function PostScriptParser_parseCondition() {
  53891. var conditionLocation = this.operators.length;
  53892. this.operators.push(null, null);
  53893. this.parseBlock();
  53894. this.expect(PostScriptTokenTypes.RBRACE);
  53895. if (this.accept(PostScriptTokenTypes.IF)) {
  53896. this.operators[conditionLocation] = this.operators.length;
  53897. this.operators[conditionLocation + 1] = 'jz';
  53898. } else if (this.accept(PostScriptTokenTypes.LBRACE)) {
  53899. var jumpLocation = this.operators.length;
  53900. this.operators.push(null, null);
  53901. var endOfTrue = this.operators.length;
  53902. this.parseBlock();
  53903. this.expect(PostScriptTokenTypes.RBRACE);
  53904. this.expect(PostScriptTokenTypes.IFELSE);
  53905. this.operators[jumpLocation] = this.operators.length;
  53906. this.operators[jumpLocation + 1] = 'j';
  53907. this.operators[conditionLocation] = endOfTrue;
  53908. this.operators[conditionLocation + 1] = 'jz';
  53909. } else {
  53910. error('PS Function: error parsing conditional.');
  53911. }
  53912. }
  53913. };
  53914. return PostScriptParser;
  53915. }();
  53916. var PostScriptTokenTypes = {
  53917. LBRACE: 0,
  53918. RBRACE: 1,
  53919. NUMBER: 2,
  53920. OPERATOR: 3,
  53921. IF: 4,
  53922. IFELSE: 5
  53923. };
  53924. var PostScriptToken = function PostScriptTokenClosure() {
  53925. function PostScriptToken(type, value) {
  53926. this.type = type;
  53927. this.value = value;
  53928. }
  53929. var opCache = Object.create(null);
  53930. PostScriptToken.getOperator = function PostScriptToken_getOperator(op) {
  53931. var opValue = opCache[op];
  53932. if (opValue) {
  53933. return opValue;
  53934. }
  53935. return opCache[op] = new PostScriptToken(PostScriptTokenTypes.OPERATOR, op);
  53936. };
  53937. PostScriptToken.LBRACE = new PostScriptToken(PostScriptTokenTypes.LBRACE, '{');
  53938. PostScriptToken.RBRACE = new PostScriptToken(PostScriptTokenTypes.RBRACE, '}');
  53939. PostScriptToken.IF = new PostScriptToken(PostScriptTokenTypes.IF, 'IF');
  53940. PostScriptToken.IFELSE = new PostScriptToken(PostScriptTokenTypes.IFELSE, 'IFELSE');
  53941. return PostScriptToken;
  53942. }();
  53943. var PostScriptLexer = function PostScriptLexerClosure() {
  53944. function PostScriptLexer(stream) {
  53945. this.stream = stream;
  53946. this.nextChar();
  53947. this.strBuf = [];
  53948. }
  53949. PostScriptLexer.prototype = {
  53950. nextChar: function PostScriptLexer_nextChar() {
  53951. return this.currentChar = this.stream.getByte();
  53952. },
  53953. getToken: function PostScriptLexer_getToken() {
  53954. var comment = false;
  53955. var ch = this.currentChar;
  53956. while (true) {
  53957. if (ch < 0) {
  53958. return EOF;
  53959. }
  53960. if (comment) {
  53961. if (ch === 0x0A || ch === 0x0D) {
  53962. comment = false;
  53963. }
  53964. } else if (ch === 0x25) {
  53965. comment = true;
  53966. } else if (!isSpace(ch)) {
  53967. break;
  53968. }
  53969. ch = this.nextChar();
  53970. }
  53971. switch (ch | 0) {
  53972. case 0x30:
  53973. case 0x31:
  53974. case 0x32:
  53975. case 0x33:
  53976. case 0x34:
  53977. case 0x35:
  53978. case 0x36:
  53979. case 0x37:
  53980. case 0x38:
  53981. case 0x39:
  53982. case 0x2B:
  53983. case 0x2D:
  53984. case 0x2E:
  53985. return new PostScriptToken(PostScriptTokenTypes.NUMBER, this.getNumber());
  53986. case 0x7B:
  53987. this.nextChar();
  53988. return PostScriptToken.LBRACE;
  53989. case 0x7D:
  53990. this.nextChar();
  53991. return PostScriptToken.RBRACE;
  53992. }
  53993. var strBuf = this.strBuf;
  53994. strBuf.length = 0;
  53995. strBuf[0] = String.fromCharCode(ch);
  53996. while ((ch = this.nextChar()) >= 0 && (ch >= 0x41 && ch <= 0x5A || ch >= 0x61 && ch <= 0x7A)) {
  53997. strBuf.push(String.fromCharCode(ch));
  53998. }
  53999. var str = strBuf.join('');
  54000. switch (str.toLowerCase()) {
  54001. case 'if':
  54002. return PostScriptToken.IF;
  54003. case 'ifelse':
  54004. return PostScriptToken.IFELSE;
  54005. default:
  54006. return PostScriptToken.getOperator(str);
  54007. }
  54008. },
  54009. getNumber: function PostScriptLexer_getNumber() {
  54010. var ch = this.currentChar;
  54011. var strBuf = this.strBuf;
  54012. strBuf.length = 0;
  54013. strBuf[0] = String.fromCharCode(ch);
  54014. while ((ch = this.nextChar()) >= 0) {
  54015. if (ch >= 0x30 && ch <= 0x39 || ch === 0x2D || ch === 0x2E) {
  54016. strBuf.push(String.fromCharCode(ch));
  54017. } else {
  54018. break;
  54019. }
  54020. }
  54021. var value = parseFloat(strBuf.join(''));
  54022. if (isNaN(value)) {
  54023. error('Invalid floating point number: ' + value);
  54024. }
  54025. return value;
  54026. }
  54027. };
  54028. return PostScriptLexer;
  54029. }();
  54030. exports.PostScriptLexer = PostScriptLexer;
  54031. exports.PostScriptParser = PostScriptParser;
  54032. /***/ }),
  54033. /* 44 */
  54034. /***/ (function(module, exports, __w_pdfjs_require__) {
  54035. "use strict";
  54036. var sharedUtil = __w_pdfjs_require__(0);
  54037. var coreStream = __w_pdfjs_require__(2);
  54038. var coreEncodings = __w_pdfjs_require__(5);
  54039. var warn = sharedUtil.warn;
  54040. var isSpace = sharedUtil.isSpace;
  54041. var Stream = coreStream.Stream;
  54042. var getEncoding = coreEncodings.getEncoding;
  54043. var HINTING_ENABLED = false;
  54044. var Type1CharString = function Type1CharStringClosure() {
  54045. var COMMAND_MAP = {
  54046. 'hstem': [1],
  54047. 'vstem': [3],
  54048. 'vmoveto': [4],
  54049. 'rlineto': [5],
  54050. 'hlineto': [6],
  54051. 'vlineto': [7],
  54052. 'rrcurveto': [8],
  54053. 'callsubr': [10],
  54054. 'flex': [
  54055. 12,
  54056. 35
  54057. ],
  54058. 'drop': [
  54059. 12,
  54060. 18
  54061. ],
  54062. 'endchar': [14],
  54063. 'rmoveto': [21],
  54064. 'hmoveto': [22],
  54065. 'vhcurveto': [30],
  54066. 'hvcurveto': [31]
  54067. };
  54068. function Type1CharString() {
  54069. this.width = 0;
  54070. this.lsb = 0;
  54071. this.flexing = false;
  54072. this.output = [];
  54073. this.stack = [];
  54074. }
  54075. Type1CharString.prototype = {
  54076. convert: function Type1CharString_convert(encoded, subrs, seacAnalysisEnabled) {
  54077. var count = encoded.length;
  54078. var error = false;
  54079. var wx, sbx, subrNumber;
  54080. for (var i = 0; i < count; i++) {
  54081. var value = encoded[i];
  54082. if (value < 32) {
  54083. if (value === 12) {
  54084. value = (value << 8) + encoded[++i];
  54085. }
  54086. switch (value) {
  54087. case 1:
  54088. if (!HINTING_ENABLED) {
  54089. this.stack = [];
  54090. break;
  54091. }
  54092. error = this.executeCommand(2, COMMAND_MAP.hstem);
  54093. break;
  54094. case 3:
  54095. if (!HINTING_ENABLED) {
  54096. this.stack = [];
  54097. break;
  54098. }
  54099. error = this.executeCommand(2, COMMAND_MAP.vstem);
  54100. break;
  54101. case 4:
  54102. if (this.flexing) {
  54103. if (this.stack.length < 1) {
  54104. error = true;
  54105. break;
  54106. }
  54107. var dy = this.stack.pop();
  54108. this.stack.push(0, dy);
  54109. break;
  54110. }
  54111. error = this.executeCommand(1, COMMAND_MAP.vmoveto);
  54112. break;
  54113. case 5:
  54114. error = this.executeCommand(2, COMMAND_MAP.rlineto);
  54115. break;
  54116. case 6:
  54117. error = this.executeCommand(1, COMMAND_MAP.hlineto);
  54118. break;
  54119. case 7:
  54120. error = this.executeCommand(1, COMMAND_MAP.vlineto);
  54121. break;
  54122. case 8:
  54123. error = this.executeCommand(6, COMMAND_MAP.rrcurveto);
  54124. break;
  54125. case 9:
  54126. this.stack = [];
  54127. break;
  54128. case 10:
  54129. if (this.stack.length < 1) {
  54130. error = true;
  54131. break;
  54132. }
  54133. subrNumber = this.stack.pop();
  54134. error = this.convert(subrs[subrNumber], subrs, seacAnalysisEnabled);
  54135. break;
  54136. case 11:
  54137. return error;
  54138. case 13:
  54139. if (this.stack.length < 2) {
  54140. error = true;
  54141. break;
  54142. }
  54143. wx = this.stack.pop();
  54144. sbx = this.stack.pop();
  54145. this.lsb = sbx;
  54146. this.width = wx;
  54147. this.stack.push(wx, sbx);
  54148. error = this.executeCommand(2, COMMAND_MAP.hmoveto);
  54149. break;
  54150. case 14:
  54151. this.output.push(COMMAND_MAP.endchar[0]);
  54152. break;
  54153. case 21:
  54154. if (this.flexing) {
  54155. break;
  54156. }
  54157. error = this.executeCommand(2, COMMAND_MAP.rmoveto);
  54158. break;
  54159. case 22:
  54160. if (this.flexing) {
  54161. this.stack.push(0);
  54162. break;
  54163. }
  54164. error = this.executeCommand(1, COMMAND_MAP.hmoveto);
  54165. break;
  54166. case 30:
  54167. error = this.executeCommand(4, COMMAND_MAP.vhcurveto);
  54168. break;
  54169. case 31:
  54170. error = this.executeCommand(4, COMMAND_MAP.hvcurveto);
  54171. break;
  54172. case (12 << 8) + 0:
  54173. this.stack = [];
  54174. break;
  54175. case (12 << 8) + 1:
  54176. if (!HINTING_ENABLED) {
  54177. this.stack = [];
  54178. break;
  54179. }
  54180. error = this.executeCommand(2, COMMAND_MAP.vstem);
  54181. break;
  54182. case (12 << 8) + 2:
  54183. if (!HINTING_ENABLED) {
  54184. this.stack = [];
  54185. break;
  54186. }
  54187. error = this.executeCommand(2, COMMAND_MAP.hstem);
  54188. break;
  54189. case (12 << 8) + 6:
  54190. if (seacAnalysisEnabled) {
  54191. this.seac = this.stack.splice(-4, 4);
  54192. error = this.executeCommand(0, COMMAND_MAP.endchar);
  54193. } else {
  54194. error = this.executeCommand(4, COMMAND_MAP.endchar);
  54195. }
  54196. break;
  54197. case (12 << 8) + 7:
  54198. if (this.stack.length < 4) {
  54199. error = true;
  54200. break;
  54201. }
  54202. this.stack.pop();
  54203. wx = this.stack.pop();
  54204. var sby = this.stack.pop();
  54205. sbx = this.stack.pop();
  54206. this.lsb = sbx;
  54207. this.width = wx;
  54208. this.stack.push(wx, sbx, sby);
  54209. error = this.executeCommand(3, COMMAND_MAP.rmoveto);
  54210. break;
  54211. case (12 << 8) + 12:
  54212. if (this.stack.length < 2) {
  54213. error = true;
  54214. break;
  54215. }
  54216. var num2 = this.stack.pop();
  54217. var num1 = this.stack.pop();
  54218. this.stack.push(num1 / num2);
  54219. break;
  54220. case (12 << 8) + 16:
  54221. if (this.stack.length < 2) {
  54222. error = true;
  54223. break;
  54224. }
  54225. subrNumber = this.stack.pop();
  54226. var numArgs = this.stack.pop();
  54227. if (subrNumber === 0 && numArgs === 3) {
  54228. var flexArgs = this.stack.splice(this.stack.length - 17, 17);
  54229. 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]);
  54230. error = this.executeCommand(13, COMMAND_MAP.flex, true);
  54231. this.flexing = false;
  54232. this.stack.push(flexArgs[15], flexArgs[16]);
  54233. } else if (subrNumber === 1 && numArgs === 0) {
  54234. this.flexing = true;
  54235. }
  54236. break;
  54237. case (12 << 8) + 17:
  54238. break;
  54239. case (12 << 8) + 33:
  54240. this.stack = [];
  54241. break;
  54242. default:
  54243. warn('Unknown type 1 charstring command of "' + value + '"');
  54244. break;
  54245. }
  54246. if (error) {
  54247. break;
  54248. }
  54249. continue;
  54250. } else if (value <= 246) {
  54251. value = value - 139;
  54252. } else if (value <= 250) {
  54253. value = (value - 247) * 256 + encoded[++i] + 108;
  54254. } else if (value <= 254) {
  54255. value = -((value - 251) * 256) - encoded[++i] - 108;
  54256. } else {
  54257. value = (encoded[++i] & 0xff) << 24 | (encoded[++i] & 0xff) << 16 | (encoded[++i] & 0xff) << 8 | (encoded[++i] & 0xff) << 0;
  54258. }
  54259. this.stack.push(value);
  54260. }
  54261. return error;
  54262. },
  54263. executeCommand: function (howManyArgs, command, keepStack) {
  54264. var stackLength = this.stack.length;
  54265. if (howManyArgs > stackLength) {
  54266. return true;
  54267. }
  54268. var start = stackLength - howManyArgs;
  54269. for (var i = start; i < stackLength; i++) {
  54270. var value = this.stack[i];
  54271. if (value === (value | 0)) {
  54272. this.output.push(28, value >> 8 & 0xff, value & 0xff);
  54273. } else {
  54274. value = 65536 * value | 0;
  54275. this.output.push(255, value >> 24 & 0xFF, value >> 16 & 0xFF, value >> 8 & 0xFF, value & 0xFF);
  54276. }
  54277. }
  54278. this.output.push.apply(this.output, command);
  54279. if (keepStack) {
  54280. this.stack.splice(start, howManyArgs);
  54281. } else {
  54282. this.stack.length = 0;
  54283. }
  54284. return false;
  54285. }
  54286. };
  54287. return Type1CharString;
  54288. }();
  54289. var Type1Parser = function Type1ParserClosure() {
  54290. var EEXEC_ENCRYPT_KEY = 55665;
  54291. var CHAR_STRS_ENCRYPT_KEY = 4330;
  54292. function isHexDigit(code) {
  54293. return code >= 48 && code <= 57 || code >= 65 && code <= 70 || code >= 97 && code <= 102;
  54294. }
  54295. function decrypt(data, key, discardNumber) {
  54296. if (discardNumber >= data.length) {
  54297. return new Uint8Array(0);
  54298. }
  54299. var r = key | 0, c1 = 52845, c2 = 22719, i, j;
  54300. for (i = 0; i < discardNumber; i++) {
  54301. r = (data[i] + r) * c1 + c2 & (1 << 16) - 1;
  54302. }
  54303. var count = data.length - discardNumber;
  54304. var decrypted = new Uint8Array(count);
  54305. for (i = discardNumber, j = 0; j < count; i++, j++) {
  54306. var value = data[i];
  54307. decrypted[j] = value ^ r >> 8;
  54308. r = (value + r) * c1 + c2 & (1 << 16) - 1;
  54309. }
  54310. return decrypted;
  54311. }
  54312. function decryptAscii(data, key, discardNumber) {
  54313. var r = key | 0, c1 = 52845, c2 = 22719;
  54314. var count = data.length, maybeLength = count >>> 1;
  54315. var decrypted = new Uint8Array(maybeLength);
  54316. var i, j;
  54317. for (i = 0, j = 0; i < count; i++) {
  54318. var digit1 = data[i];
  54319. if (!isHexDigit(digit1)) {
  54320. continue;
  54321. }
  54322. i++;
  54323. var digit2;
  54324. while (i < count && !isHexDigit(digit2 = data[i])) {
  54325. i++;
  54326. }
  54327. if (i < count) {
  54328. var value = parseInt(String.fromCharCode(digit1, digit2), 16);
  54329. decrypted[j++] = value ^ r >> 8;
  54330. r = (value + r) * c1 + c2 & (1 << 16) - 1;
  54331. }
  54332. }
  54333. return Array.prototype.slice.call(decrypted, discardNumber, j);
  54334. }
  54335. function isSpecial(c) {
  54336. return c === 0x2F || c === 0x5B || c === 0x5D || c === 0x7B || c === 0x7D || c === 0x28 || c === 0x29;
  54337. }
  54338. function Type1Parser(stream, encrypted, seacAnalysisEnabled) {
  54339. if (encrypted) {
  54340. var data = stream.getBytes();
  54341. var isBinary = !(isHexDigit(data[0]) && isHexDigit(data[1]) && isHexDigit(data[2]) && isHexDigit(data[3]));
  54342. stream = new Stream(isBinary ? decrypt(data, EEXEC_ENCRYPT_KEY, 4) : decryptAscii(data, EEXEC_ENCRYPT_KEY, 4));
  54343. }
  54344. this.seacAnalysisEnabled = !!seacAnalysisEnabled;
  54345. this.stream = stream;
  54346. this.nextChar();
  54347. }
  54348. Type1Parser.prototype = {
  54349. readNumberArray: function Type1Parser_readNumberArray() {
  54350. this.getToken();
  54351. var array = [];
  54352. while (true) {
  54353. var token = this.getToken();
  54354. if (token === null || token === ']' || token === '}') {
  54355. break;
  54356. }
  54357. array.push(parseFloat(token || 0));
  54358. }
  54359. return array;
  54360. },
  54361. readNumber: function Type1Parser_readNumber() {
  54362. var token = this.getToken();
  54363. return parseFloat(token || 0);
  54364. },
  54365. readInt: function Type1Parser_readInt() {
  54366. var token = this.getToken();
  54367. return parseInt(token || 0, 10) | 0;
  54368. },
  54369. readBoolean: function Type1Parser_readBoolean() {
  54370. var token = this.getToken();
  54371. return token === 'true' ? 1 : 0;
  54372. },
  54373. nextChar: function Type1_nextChar() {
  54374. return this.currentChar = this.stream.getByte();
  54375. },
  54376. getToken: function Type1Parser_getToken() {
  54377. var comment = false;
  54378. var ch = this.currentChar;
  54379. while (true) {
  54380. if (ch === -1) {
  54381. return null;
  54382. }
  54383. if (comment) {
  54384. if (ch === 0x0A || ch === 0x0D) {
  54385. comment = false;
  54386. }
  54387. } else if (ch === 0x25) {
  54388. comment = true;
  54389. } else if (!isSpace(ch)) {
  54390. break;
  54391. }
  54392. ch = this.nextChar();
  54393. }
  54394. if (isSpecial(ch)) {
  54395. this.nextChar();
  54396. return String.fromCharCode(ch);
  54397. }
  54398. var token = '';
  54399. do {
  54400. token += String.fromCharCode(ch);
  54401. ch = this.nextChar();
  54402. } while (ch >= 0 && !isSpace(ch) && !isSpecial(ch));
  54403. return token;
  54404. },
  54405. extractFontProgram: function Type1Parser_extractFontProgram() {
  54406. var stream = this.stream;
  54407. var subrs = [], charstrings = [];
  54408. var privateData = Object.create(null);
  54409. privateData['lenIV'] = 4;
  54410. var program = {
  54411. subrs: [],
  54412. charstrings: [],
  54413. properties: { 'privateData': privateData }
  54414. };
  54415. var token, length, data, lenIV, encoded;
  54416. while ((token = this.getToken()) !== null) {
  54417. if (token !== '/') {
  54418. continue;
  54419. }
  54420. token = this.getToken();
  54421. switch (token) {
  54422. case 'CharStrings':
  54423. this.getToken();
  54424. this.getToken();
  54425. this.getToken();
  54426. this.getToken();
  54427. while (true) {
  54428. token = this.getToken();
  54429. if (token === null || token === 'end') {
  54430. break;
  54431. }
  54432. if (token !== '/') {
  54433. continue;
  54434. }
  54435. var glyph = this.getToken();
  54436. length = this.readInt();
  54437. this.getToken();
  54438. data = stream.makeSubStream(stream.pos, length);
  54439. lenIV = program.properties.privateData['lenIV'];
  54440. encoded = decrypt(data.getBytes(), CHAR_STRS_ENCRYPT_KEY, lenIV);
  54441. stream.skip(length);
  54442. this.nextChar();
  54443. token = this.getToken();
  54444. if (token === 'noaccess') {
  54445. this.getToken();
  54446. }
  54447. charstrings.push({
  54448. glyph: glyph,
  54449. encoded: encoded
  54450. });
  54451. }
  54452. break;
  54453. case 'Subrs':
  54454. this.readInt();
  54455. this.getToken();
  54456. while ((token = this.getToken()) === 'dup') {
  54457. var index = this.readInt();
  54458. length = this.readInt();
  54459. this.getToken();
  54460. data = stream.makeSubStream(stream.pos, length);
  54461. lenIV = program.properties.privateData['lenIV'];
  54462. encoded = decrypt(data.getBytes(), CHAR_STRS_ENCRYPT_KEY, lenIV);
  54463. stream.skip(length);
  54464. this.nextChar();
  54465. token = this.getToken();
  54466. if (token === 'noaccess') {
  54467. this.getToken();
  54468. }
  54469. subrs[index] = encoded;
  54470. }
  54471. break;
  54472. case 'BlueValues':
  54473. case 'OtherBlues':
  54474. case 'FamilyBlues':
  54475. case 'FamilyOtherBlues':
  54476. var blueArray = this.readNumberArray();
  54477. if (blueArray.length > 0 && blueArray.length % 2 === 0 && HINTING_ENABLED) {
  54478. program.properties.privateData[token] = blueArray;
  54479. }
  54480. break;
  54481. case 'StemSnapH':
  54482. case 'StemSnapV':
  54483. program.properties.privateData[token] = this.readNumberArray();
  54484. break;
  54485. case 'StdHW':
  54486. case 'StdVW':
  54487. program.properties.privateData[token] = this.readNumberArray()[0];
  54488. break;
  54489. case 'BlueShift':
  54490. case 'lenIV':
  54491. case 'BlueFuzz':
  54492. case 'BlueScale':
  54493. case 'LanguageGroup':
  54494. case 'ExpansionFactor':
  54495. program.properties.privateData[token] = this.readNumber();
  54496. break;
  54497. case 'ForceBold':
  54498. program.properties.privateData[token] = this.readBoolean();
  54499. break;
  54500. }
  54501. }
  54502. for (var i = 0; i < charstrings.length; i++) {
  54503. glyph = charstrings[i].glyph;
  54504. encoded = charstrings[i].encoded;
  54505. var charString = new Type1CharString();
  54506. var error = charString.convert(encoded, subrs, this.seacAnalysisEnabled);
  54507. var output = charString.output;
  54508. if (error) {
  54509. output = [14];
  54510. }
  54511. program.charstrings.push({
  54512. glyphName: glyph,
  54513. charstring: output,
  54514. width: charString.width,
  54515. lsb: charString.lsb,
  54516. seac: charString.seac
  54517. });
  54518. }
  54519. return program;
  54520. },
  54521. extractFontHeader: function Type1Parser_extractFontHeader(properties) {
  54522. var token;
  54523. while ((token = this.getToken()) !== null) {
  54524. if (token !== '/') {
  54525. continue;
  54526. }
  54527. token = this.getToken();
  54528. switch (token) {
  54529. case 'FontMatrix':
  54530. var matrix = this.readNumberArray();
  54531. properties.fontMatrix = matrix;
  54532. break;
  54533. case 'Encoding':
  54534. var encodingArg = this.getToken();
  54535. var encoding;
  54536. if (!/^\d+$/.test(encodingArg)) {
  54537. encoding = getEncoding(encodingArg);
  54538. } else {
  54539. encoding = [];
  54540. var size = parseInt(encodingArg, 10) | 0;
  54541. this.getToken();
  54542. for (var j = 0; j < size; j++) {
  54543. token = this.getToken();
  54544. while (token !== 'dup' && token !== 'def') {
  54545. token = this.getToken();
  54546. if (token === null) {
  54547. return;
  54548. }
  54549. }
  54550. if (token === 'def') {
  54551. break;
  54552. }
  54553. var index = this.readInt();
  54554. this.getToken();
  54555. var glyph = this.getToken();
  54556. encoding[index] = glyph;
  54557. this.getToken();
  54558. }
  54559. }
  54560. properties.builtInEncoding = encoding;
  54561. break;
  54562. case 'FontBBox':
  54563. var fontBBox = this.readNumberArray();
  54564. properties.ascent = fontBBox[3];
  54565. properties.descent = fontBBox[1];
  54566. properties.ascentScaled = true;
  54567. break;
  54568. }
  54569. }
  54570. }
  54571. };
  54572. return Type1Parser;
  54573. }();
  54574. exports.Type1Parser = Type1Parser;
  54575. /***/ }),
  54576. /* 45 */
  54577. /***/ (function(module, exports, __w_pdfjs_require__) {
  54578. "use strict";
  54579. var sharedUtil = __w_pdfjs_require__(0);
  54580. var displayDOMUtils = __w_pdfjs_require__(3);
  54581. var displayPatternHelper = __w_pdfjs_require__(47);
  54582. var displayWebGL = __w_pdfjs_require__(24);
  54583. var FONT_IDENTITY_MATRIX = sharedUtil.FONT_IDENTITY_MATRIX;
  54584. var IDENTITY_MATRIX = sharedUtil.IDENTITY_MATRIX;
  54585. var ImageKind = sharedUtil.ImageKind;
  54586. var OPS = sharedUtil.OPS;
  54587. var TextRenderingMode = sharedUtil.TextRenderingMode;
  54588. var Uint32ArrayView = sharedUtil.Uint32ArrayView;
  54589. var Util = sharedUtil.Util;
  54590. var assert = sharedUtil.assert;
  54591. var info = sharedUtil.info;
  54592. var isNum = sharedUtil.isNum;
  54593. var isArray = sharedUtil.isArray;
  54594. var isLittleEndian = sharedUtil.isLittleEndian;
  54595. var error = sharedUtil.error;
  54596. var shadow = sharedUtil.shadow;
  54597. var warn = sharedUtil.warn;
  54598. var TilingPattern = displayPatternHelper.TilingPattern;
  54599. var getShadingPatternFromIR = displayPatternHelper.getShadingPatternFromIR;
  54600. var WebGLUtils = displayWebGL.WebGLUtils;
  54601. var hasCanvasTypedArrays = displayDOMUtils.hasCanvasTypedArrays;
  54602. var MIN_FONT_SIZE = 16;
  54603. var MAX_FONT_SIZE = 100;
  54604. var MAX_GROUP_SIZE = 4096;
  54605. var MIN_WIDTH_FACTOR = 0.65;
  54606. var COMPILE_TYPE3_GLYPHS = true;
  54607. var MAX_SIZE_TO_COMPILE = 1000;
  54608. var FULL_CHUNK_HEIGHT = 16;
  54609. var HasCanvasTypedArraysCached = {
  54610. get value() {
  54611. return shadow(HasCanvasTypedArraysCached, 'value', hasCanvasTypedArrays());
  54612. }
  54613. };
  54614. var IsLittleEndianCached = {
  54615. get value() {
  54616. return shadow(IsLittleEndianCached, 'value', isLittleEndian());
  54617. }
  54618. };
  54619. function addContextCurrentTransform(ctx) {
  54620. if (!ctx.mozCurrentTransform) {
  54621. ctx._originalSave = ctx.save;
  54622. ctx._originalRestore = ctx.restore;
  54623. ctx._originalRotate = ctx.rotate;
  54624. ctx._originalScale = ctx.scale;
  54625. ctx._originalTranslate = ctx.translate;
  54626. ctx._originalTransform = ctx.transform;
  54627. ctx._originalSetTransform = ctx.setTransform;
  54628. ctx._transformMatrix = ctx._transformMatrix || [
  54629. 1,
  54630. 0,
  54631. 0,
  54632. 1,
  54633. 0,
  54634. 0
  54635. ];
  54636. ctx._transformStack = [];
  54637. Object.defineProperty(ctx, 'mozCurrentTransform', {
  54638. get: function getCurrentTransform() {
  54639. return this._transformMatrix;
  54640. }
  54641. });
  54642. Object.defineProperty(ctx, 'mozCurrentTransformInverse', {
  54643. get: function getCurrentTransformInverse() {
  54644. var m = this._transformMatrix;
  54645. var a = m[0], b = m[1], c = m[2], d = m[3], e = m[4], f = m[5];
  54646. var ad_bc = a * d - b * c;
  54647. var bc_ad = b * c - a * d;
  54648. return [
  54649. d / ad_bc,
  54650. b / bc_ad,
  54651. c / bc_ad,
  54652. a / ad_bc,
  54653. (d * e - c * f) / bc_ad,
  54654. (b * e - a * f) / ad_bc
  54655. ];
  54656. }
  54657. });
  54658. ctx.save = function ctxSave() {
  54659. var old = this._transformMatrix;
  54660. this._transformStack.push(old);
  54661. this._transformMatrix = old.slice(0, 6);
  54662. this._originalSave();
  54663. };
  54664. ctx.restore = function ctxRestore() {
  54665. var prev = this._transformStack.pop();
  54666. if (prev) {
  54667. this._transformMatrix = prev;
  54668. this._originalRestore();
  54669. }
  54670. };
  54671. ctx.translate = function ctxTranslate(x, y) {
  54672. var m = this._transformMatrix;
  54673. m[4] = m[0] * x + m[2] * y + m[4];
  54674. m[5] = m[1] * x + m[3] * y + m[5];
  54675. this._originalTranslate(x, y);
  54676. };
  54677. ctx.scale = function ctxScale(x, y) {
  54678. var m = this._transformMatrix;
  54679. m[0] = m[0] * x;
  54680. m[1] = m[1] * x;
  54681. m[2] = m[2] * y;
  54682. m[3] = m[3] * y;
  54683. this._originalScale(x, y);
  54684. };
  54685. ctx.transform = function ctxTransform(a, b, c, d, e, f) {
  54686. var m = this._transformMatrix;
  54687. this._transformMatrix = [
  54688. m[0] * a + m[2] * b,
  54689. m[1] * a + m[3] * b,
  54690. m[0] * c + m[2] * d,
  54691. m[1] * c + m[3] * d,
  54692. m[0] * e + m[2] * f + m[4],
  54693. m[1] * e + m[3] * f + m[5]
  54694. ];
  54695. ctx._originalTransform(a, b, c, d, e, f);
  54696. };
  54697. ctx.setTransform = function ctxSetTransform(a, b, c, d, e, f) {
  54698. this._transformMatrix = [
  54699. a,
  54700. b,
  54701. c,
  54702. d,
  54703. e,
  54704. f
  54705. ];
  54706. ctx._originalSetTransform(a, b, c, d, e, f);
  54707. };
  54708. ctx.rotate = function ctxRotate(angle) {
  54709. var cosValue = Math.cos(angle);
  54710. var sinValue = Math.sin(angle);
  54711. var m = this._transformMatrix;
  54712. this._transformMatrix = [
  54713. m[0] * cosValue + m[2] * sinValue,
  54714. m[1] * cosValue + m[3] * sinValue,
  54715. m[0] * -sinValue + m[2] * cosValue,
  54716. m[1] * -sinValue + m[3] * cosValue,
  54717. m[4],
  54718. m[5]
  54719. ];
  54720. this._originalRotate(angle);
  54721. };
  54722. }
  54723. }
  54724. var CachedCanvases = function CachedCanvasesClosure() {
  54725. function CachedCanvases(canvasFactory) {
  54726. this.canvasFactory = canvasFactory;
  54727. this.cache = Object.create(null);
  54728. }
  54729. CachedCanvases.prototype = {
  54730. getCanvas: function CachedCanvases_getCanvas(id, width, height, trackTransform) {
  54731. var canvasEntry;
  54732. if (this.cache[id] !== undefined) {
  54733. canvasEntry = this.cache[id];
  54734. this.canvasFactory.reset(canvasEntry, width, height);
  54735. canvasEntry.context.setTransform(1, 0, 0, 1, 0, 0);
  54736. } else {
  54737. canvasEntry = this.canvasFactory.create(width, height);
  54738. this.cache[id] = canvasEntry;
  54739. }
  54740. if (trackTransform) {
  54741. addContextCurrentTransform(canvasEntry.context);
  54742. }
  54743. return canvasEntry;
  54744. },
  54745. clear: function () {
  54746. for (var id in this.cache) {
  54747. var canvasEntry = this.cache[id];
  54748. this.canvasFactory.destroy(canvasEntry);
  54749. delete this.cache[id];
  54750. }
  54751. }
  54752. };
  54753. return CachedCanvases;
  54754. }();
  54755. function compileType3Glyph(imgData) {
  54756. var POINT_TO_PROCESS_LIMIT = 1000;
  54757. var width = imgData.width, height = imgData.height;
  54758. var i, j, j0, width1 = width + 1;
  54759. var points = new Uint8Array(width1 * (height + 1));
  54760. var POINT_TYPES = new Uint8Array([
  54761. 0,
  54762. 2,
  54763. 4,
  54764. 0,
  54765. 1,
  54766. 0,
  54767. 5,
  54768. 4,
  54769. 8,
  54770. 10,
  54771. 0,
  54772. 8,
  54773. 0,
  54774. 2,
  54775. 1,
  54776. 0
  54777. ]);
  54778. var lineSize = width + 7 & ~7, data0 = imgData.data;
  54779. var data = new Uint8Array(lineSize * height), pos = 0, ii;
  54780. for (i = 0, ii = data0.length; i < ii; i++) {
  54781. var mask = 128, elem = data0[i];
  54782. while (mask > 0) {
  54783. data[pos++] = elem & mask ? 0 : 255;
  54784. mask >>= 1;
  54785. }
  54786. }
  54787. var count = 0;
  54788. pos = 0;
  54789. if (data[pos] !== 0) {
  54790. points[0] = 1;
  54791. ++count;
  54792. }
  54793. for (j = 1; j < width; j++) {
  54794. if (data[pos] !== data[pos + 1]) {
  54795. points[j] = data[pos] ? 2 : 1;
  54796. ++count;
  54797. }
  54798. pos++;
  54799. }
  54800. if (data[pos] !== 0) {
  54801. points[j] = 2;
  54802. ++count;
  54803. }
  54804. for (i = 1; i < height; i++) {
  54805. pos = i * lineSize;
  54806. j0 = i * width1;
  54807. if (data[pos - lineSize] !== data[pos]) {
  54808. points[j0] = data[pos] ? 1 : 8;
  54809. ++count;
  54810. }
  54811. var sum = (data[pos] ? 4 : 0) + (data[pos - lineSize] ? 8 : 0);
  54812. for (j = 1; j < width; j++) {
  54813. sum = (sum >> 2) + (data[pos + 1] ? 4 : 0) + (data[pos - lineSize + 1] ? 8 : 0);
  54814. if (POINT_TYPES[sum]) {
  54815. points[j0 + j] = POINT_TYPES[sum];
  54816. ++count;
  54817. }
  54818. pos++;
  54819. }
  54820. if (data[pos - lineSize] !== data[pos]) {
  54821. points[j0 + j] = data[pos] ? 2 : 4;
  54822. ++count;
  54823. }
  54824. if (count > POINT_TO_PROCESS_LIMIT) {
  54825. return null;
  54826. }
  54827. }
  54828. pos = lineSize * (height - 1);
  54829. j0 = i * width1;
  54830. if (data[pos] !== 0) {
  54831. points[j0] = 8;
  54832. ++count;
  54833. }
  54834. for (j = 1; j < width; j++) {
  54835. if (data[pos] !== data[pos + 1]) {
  54836. points[j0 + j] = data[pos] ? 4 : 8;
  54837. ++count;
  54838. }
  54839. pos++;
  54840. }
  54841. if (data[pos] !== 0) {
  54842. points[j0 + j] = 4;
  54843. ++count;
  54844. }
  54845. if (count > POINT_TO_PROCESS_LIMIT) {
  54846. return null;
  54847. }
  54848. var steps = new Int32Array([
  54849. 0,
  54850. width1,
  54851. -1,
  54852. 0,
  54853. -width1,
  54854. 0,
  54855. 0,
  54856. 0,
  54857. 1
  54858. ]);
  54859. var outlines = [];
  54860. for (i = 0; count && i <= height; i++) {
  54861. var p = i * width1;
  54862. var end = p + width;
  54863. while (p < end && !points[p]) {
  54864. p++;
  54865. }
  54866. if (p === end) {
  54867. continue;
  54868. }
  54869. var coords = [
  54870. p % width1,
  54871. i
  54872. ];
  54873. var type = points[p], p0 = p, pp;
  54874. do {
  54875. var step = steps[type];
  54876. do {
  54877. p += step;
  54878. } while (!points[p]);
  54879. pp = points[p];
  54880. if (pp !== 5 && pp !== 10) {
  54881. type = pp;
  54882. points[p] = 0;
  54883. } else {
  54884. type = pp & 0x33 * type >> 4;
  54885. points[p] &= type >> 2 | type << 2;
  54886. }
  54887. coords.push(p % width1);
  54888. coords.push(p / width1 | 0);
  54889. --count;
  54890. } while (p0 !== p);
  54891. outlines.push(coords);
  54892. --i;
  54893. }
  54894. var drawOutline = function (c) {
  54895. c.save();
  54896. c.scale(1 / width, -1 / height);
  54897. c.translate(0, -height);
  54898. c.beginPath();
  54899. for (var i = 0, ii = outlines.length; i < ii; i++) {
  54900. var o = outlines[i];
  54901. c.moveTo(o[0], o[1]);
  54902. for (var j = 2, jj = o.length; j < jj; j += 2) {
  54903. c.lineTo(o[j], o[j + 1]);
  54904. }
  54905. }
  54906. c.fill();
  54907. c.beginPath();
  54908. c.restore();
  54909. };
  54910. return drawOutline;
  54911. }
  54912. var CanvasExtraState = function CanvasExtraStateClosure() {
  54913. function CanvasExtraState(old) {
  54914. this.alphaIsShape = false;
  54915. this.fontSize = 0;
  54916. this.fontSizeScale = 1;
  54917. this.textMatrix = IDENTITY_MATRIX;
  54918. this.textMatrixScale = 1;
  54919. this.fontMatrix = FONT_IDENTITY_MATRIX;
  54920. this.leading = 0;
  54921. this.x = 0;
  54922. this.y = 0;
  54923. this.lineX = 0;
  54924. this.lineY = 0;
  54925. this.charSpacing = 0;
  54926. this.wordSpacing = 0;
  54927. this.textHScale = 1;
  54928. this.textRenderingMode = TextRenderingMode.FILL;
  54929. this.textRise = 0;
  54930. this.fillColor = '#000000';
  54931. this.strokeColor = '#000000';
  54932. this.patternFill = false;
  54933. this.fillAlpha = 1;
  54934. this.strokeAlpha = 1;
  54935. this.lineWidth = 1;
  54936. this.activeSMask = null;
  54937. this.resumeSMaskCtx = null;
  54938. this.old = old;
  54939. }
  54940. CanvasExtraState.prototype = {
  54941. clone: function CanvasExtraState_clone() {
  54942. return Object.create(this);
  54943. },
  54944. setCurrentPoint: function CanvasExtraState_setCurrentPoint(x, y) {
  54945. this.x = x;
  54946. this.y = y;
  54947. }
  54948. };
  54949. return CanvasExtraState;
  54950. }();
  54951. var CanvasGraphics = function CanvasGraphicsClosure() {
  54952. var EXECUTION_TIME = 15;
  54953. var EXECUTION_STEPS = 10;
  54954. function CanvasGraphics(canvasCtx, commonObjs, objs, canvasFactory, imageLayer) {
  54955. this.ctx = canvasCtx;
  54956. this.current = new CanvasExtraState();
  54957. this.stateStack = [];
  54958. this.pendingClip = null;
  54959. this.pendingEOFill = false;
  54960. this.res = null;
  54961. this.xobjs = null;
  54962. this.commonObjs = commonObjs;
  54963. this.objs = objs;
  54964. this.canvasFactory = canvasFactory;
  54965. this.imageLayer = imageLayer;
  54966. this.groupStack = [];
  54967. this.processingType3 = null;
  54968. this.baseTransform = null;
  54969. this.baseTransformStack = [];
  54970. this.groupLevel = 0;
  54971. this.smaskStack = [];
  54972. this.smaskCounter = 0;
  54973. this.tempSMask = null;
  54974. this.cachedCanvases = new CachedCanvases(this.canvasFactory);
  54975. if (canvasCtx) {
  54976. addContextCurrentTransform(canvasCtx);
  54977. }
  54978. this.cachedGetSinglePixelWidth = null;
  54979. }
  54980. function putBinaryImageData(ctx, imgData) {
  54981. if (typeof ImageData !== 'undefined' && imgData instanceof ImageData) {
  54982. ctx.putImageData(imgData, 0, 0);
  54983. return;
  54984. }
  54985. var height = imgData.height, width = imgData.width;
  54986. var partialChunkHeight = height % FULL_CHUNK_HEIGHT;
  54987. var fullChunks = (height - partialChunkHeight) / FULL_CHUNK_HEIGHT;
  54988. var totalChunks = partialChunkHeight === 0 ? fullChunks : fullChunks + 1;
  54989. var chunkImgData = ctx.createImageData(width, FULL_CHUNK_HEIGHT);
  54990. var srcPos = 0, destPos;
  54991. var src = imgData.data;
  54992. var dest = chunkImgData.data;
  54993. var i, j, thisChunkHeight, elemsInThisChunk;
  54994. if (imgData.kind === ImageKind.GRAYSCALE_1BPP) {
  54995. var srcLength = src.byteLength;
  54996. var dest32 = HasCanvasTypedArraysCached.value ? new Uint32Array(dest.buffer) : new Uint32ArrayView(dest);
  54997. var dest32DataLength = dest32.length;
  54998. var fullSrcDiff = width + 7 >> 3;
  54999. var white = 0xFFFFFFFF;
  55000. var black = IsLittleEndianCached.value || !HasCanvasTypedArraysCached.value ? 0xFF000000 : 0x000000FF;
  55001. for (i = 0; i < totalChunks; i++) {
  55002. thisChunkHeight = i < fullChunks ? FULL_CHUNK_HEIGHT : partialChunkHeight;
  55003. destPos = 0;
  55004. for (j = 0; j < thisChunkHeight; j++) {
  55005. var srcDiff = srcLength - srcPos;
  55006. var k = 0;
  55007. var kEnd = srcDiff > fullSrcDiff ? width : srcDiff * 8 - 7;
  55008. var kEndUnrolled = kEnd & ~7;
  55009. var mask = 0;
  55010. var srcByte = 0;
  55011. for (; k < kEndUnrolled; k += 8) {
  55012. srcByte = src[srcPos++];
  55013. dest32[destPos++] = srcByte & 128 ? white : black;
  55014. dest32[destPos++] = srcByte & 64 ? white : black;
  55015. dest32[destPos++] = srcByte & 32 ? white : black;
  55016. dest32[destPos++] = srcByte & 16 ? white : black;
  55017. dest32[destPos++] = srcByte & 8 ? white : black;
  55018. dest32[destPos++] = srcByte & 4 ? white : black;
  55019. dest32[destPos++] = srcByte & 2 ? white : black;
  55020. dest32[destPos++] = srcByte & 1 ? white : black;
  55021. }
  55022. for (; k < kEnd; k++) {
  55023. if (mask === 0) {
  55024. srcByte = src[srcPos++];
  55025. mask = 128;
  55026. }
  55027. dest32[destPos++] = srcByte & mask ? white : black;
  55028. mask >>= 1;
  55029. }
  55030. }
  55031. while (destPos < dest32DataLength) {
  55032. dest32[destPos++] = 0;
  55033. }
  55034. ctx.putImageData(chunkImgData, 0, i * FULL_CHUNK_HEIGHT);
  55035. }
  55036. } else if (imgData.kind === ImageKind.RGBA_32BPP) {
  55037. j = 0;
  55038. elemsInThisChunk = width * FULL_CHUNK_HEIGHT * 4;
  55039. for (i = 0; i < fullChunks; i++) {
  55040. dest.set(src.subarray(srcPos, srcPos + elemsInThisChunk));
  55041. srcPos += elemsInThisChunk;
  55042. ctx.putImageData(chunkImgData, 0, j);
  55043. j += FULL_CHUNK_HEIGHT;
  55044. }
  55045. if (i < totalChunks) {
  55046. elemsInThisChunk = width * partialChunkHeight * 4;
  55047. dest.set(src.subarray(srcPos, srcPos + elemsInThisChunk));
  55048. ctx.putImageData(chunkImgData, 0, j);
  55049. }
  55050. } else if (imgData.kind === ImageKind.RGB_24BPP) {
  55051. thisChunkHeight = FULL_CHUNK_HEIGHT;
  55052. elemsInThisChunk = width * thisChunkHeight;
  55053. for (i = 0; i < totalChunks; i++) {
  55054. if (i >= fullChunks) {
  55055. thisChunkHeight = partialChunkHeight;
  55056. elemsInThisChunk = width * thisChunkHeight;
  55057. }
  55058. destPos = 0;
  55059. for (j = elemsInThisChunk; j--;) {
  55060. dest[destPos++] = src[srcPos++];
  55061. dest[destPos++] = src[srcPos++];
  55062. dest[destPos++] = src[srcPos++];
  55063. dest[destPos++] = 255;
  55064. }
  55065. ctx.putImageData(chunkImgData, 0, i * FULL_CHUNK_HEIGHT);
  55066. }
  55067. } else {
  55068. error('bad image kind: ' + imgData.kind);
  55069. }
  55070. }
  55071. function putBinaryImageMask(ctx, imgData) {
  55072. var height = imgData.height, width = imgData.width;
  55073. var partialChunkHeight = height % FULL_CHUNK_HEIGHT;
  55074. var fullChunks = (height - partialChunkHeight) / FULL_CHUNK_HEIGHT;
  55075. var totalChunks = partialChunkHeight === 0 ? fullChunks : fullChunks + 1;
  55076. var chunkImgData = ctx.createImageData(width, FULL_CHUNK_HEIGHT);
  55077. var srcPos = 0;
  55078. var src = imgData.data;
  55079. var dest = chunkImgData.data;
  55080. for (var i = 0; i < totalChunks; i++) {
  55081. var thisChunkHeight = i < fullChunks ? FULL_CHUNK_HEIGHT : partialChunkHeight;
  55082. var destPos = 3;
  55083. for (var j = 0; j < thisChunkHeight; j++) {
  55084. var mask = 0;
  55085. for (var k = 0; k < width; k++) {
  55086. if (!mask) {
  55087. var elem = src[srcPos++];
  55088. mask = 128;
  55089. }
  55090. dest[destPos] = elem & mask ? 0 : 255;
  55091. destPos += 4;
  55092. mask >>= 1;
  55093. }
  55094. }
  55095. ctx.putImageData(chunkImgData, 0, i * FULL_CHUNK_HEIGHT);
  55096. }
  55097. }
  55098. function copyCtxState(sourceCtx, destCtx) {
  55099. var properties = [
  55100. 'strokeStyle',
  55101. 'fillStyle',
  55102. 'fillRule',
  55103. 'globalAlpha',
  55104. 'lineWidth',
  55105. 'lineCap',
  55106. 'lineJoin',
  55107. 'miterLimit',
  55108. 'globalCompositeOperation',
  55109. 'font'
  55110. ];
  55111. for (var i = 0, ii = properties.length; i < ii; i++) {
  55112. var property = properties[i];
  55113. if (sourceCtx[property] !== undefined) {
  55114. destCtx[property] = sourceCtx[property];
  55115. }
  55116. }
  55117. if (sourceCtx.setLineDash !== undefined) {
  55118. destCtx.setLineDash(sourceCtx.getLineDash());
  55119. destCtx.lineDashOffset = sourceCtx.lineDashOffset;
  55120. }
  55121. }
  55122. function composeSMaskBackdrop(bytes, r0, g0, b0) {
  55123. var length = bytes.length;
  55124. for (var i = 3; i < length; i += 4) {
  55125. var alpha = bytes[i];
  55126. if (alpha === 0) {
  55127. bytes[i - 3] = r0;
  55128. bytes[i - 2] = g0;
  55129. bytes[i - 1] = b0;
  55130. } else if (alpha < 255) {
  55131. var alpha_ = 255 - alpha;
  55132. bytes[i - 3] = bytes[i - 3] * alpha + r0 * alpha_ >> 8;
  55133. bytes[i - 2] = bytes[i - 2] * alpha + g0 * alpha_ >> 8;
  55134. bytes[i - 1] = bytes[i - 1] * alpha + b0 * alpha_ >> 8;
  55135. }
  55136. }
  55137. }
  55138. function composeSMaskAlpha(maskData, layerData, transferMap) {
  55139. var length = maskData.length;
  55140. var scale = 1 / 255;
  55141. for (var i = 3; i < length; i += 4) {
  55142. var alpha = transferMap ? transferMap[maskData[i]] : maskData[i];
  55143. layerData[i] = layerData[i] * alpha * scale | 0;
  55144. }
  55145. }
  55146. function composeSMaskLuminosity(maskData, layerData, transferMap) {
  55147. var length = maskData.length;
  55148. for (var i = 3; i < length; i += 4) {
  55149. var y = maskData[i - 3] * 77 + maskData[i - 2] * 152 + maskData[i - 1] * 28;
  55150. layerData[i] = transferMap ? layerData[i] * transferMap[y >> 8] >> 8 : layerData[i] * y >> 16;
  55151. }
  55152. }
  55153. function genericComposeSMask(maskCtx, layerCtx, width, height, subtype, backdrop, transferMap) {
  55154. var hasBackdrop = !!backdrop;
  55155. var r0 = hasBackdrop ? backdrop[0] : 0;
  55156. var g0 = hasBackdrop ? backdrop[1] : 0;
  55157. var b0 = hasBackdrop ? backdrop[2] : 0;
  55158. var composeFn;
  55159. if (subtype === 'Luminosity') {
  55160. composeFn = composeSMaskLuminosity;
  55161. } else {
  55162. composeFn = composeSMaskAlpha;
  55163. }
  55164. var PIXELS_TO_PROCESS = 1048576;
  55165. var chunkSize = Math.min(height, Math.ceil(PIXELS_TO_PROCESS / width));
  55166. for (var row = 0; row < height; row += chunkSize) {
  55167. var chunkHeight = Math.min(chunkSize, height - row);
  55168. var maskData = maskCtx.getImageData(0, row, width, chunkHeight);
  55169. var layerData = layerCtx.getImageData(0, row, width, chunkHeight);
  55170. if (hasBackdrop) {
  55171. composeSMaskBackdrop(maskData.data, r0, g0, b0);
  55172. }
  55173. composeFn(maskData.data, layerData.data, transferMap);
  55174. maskCtx.putImageData(layerData, 0, row);
  55175. }
  55176. }
  55177. function composeSMask(ctx, smask, layerCtx) {
  55178. var mask = smask.canvas;
  55179. var maskCtx = smask.context;
  55180. ctx.setTransform(smask.scaleX, 0, 0, smask.scaleY, smask.offsetX, smask.offsetY);
  55181. var backdrop = smask.backdrop || null;
  55182. if (!smask.transferMap && WebGLUtils.isEnabled) {
  55183. var composed = WebGLUtils.composeSMask(layerCtx.canvas, mask, {
  55184. subtype: smask.subtype,
  55185. backdrop: backdrop
  55186. });
  55187. ctx.setTransform(1, 0, 0, 1, 0, 0);
  55188. ctx.drawImage(composed, smask.offsetX, smask.offsetY);
  55189. return;
  55190. }
  55191. genericComposeSMask(maskCtx, layerCtx, mask.width, mask.height, smask.subtype, backdrop, smask.transferMap);
  55192. ctx.drawImage(mask, 0, 0);
  55193. }
  55194. var LINE_CAP_STYLES = [
  55195. 'butt',
  55196. 'round',
  55197. 'square'
  55198. ];
  55199. var LINE_JOIN_STYLES = [
  55200. 'miter',
  55201. 'round',
  55202. 'bevel'
  55203. ];
  55204. var NORMAL_CLIP = {};
  55205. var EO_CLIP = {};
  55206. CanvasGraphics.prototype = {
  55207. beginDrawing: function CanvasGraphics_beginDrawing(transform, viewport, transparency) {
  55208. var width = this.ctx.canvas.width;
  55209. var height = this.ctx.canvas.height;
  55210. this.ctx.save();
  55211. this.ctx.fillStyle = 'rgb(255, 255, 255)';
  55212. this.ctx.fillRect(0, 0, width, height);
  55213. this.ctx.restore();
  55214. if (transparency) {
  55215. var transparentCanvas = this.cachedCanvases.getCanvas('transparent', width, height, true);
  55216. this.compositeCtx = this.ctx;
  55217. this.transparentCanvas = transparentCanvas.canvas;
  55218. this.ctx = transparentCanvas.context;
  55219. this.ctx.save();
  55220. this.ctx.transform.apply(this.ctx, this.compositeCtx.mozCurrentTransform);
  55221. }
  55222. this.ctx.save();
  55223. if (transform) {
  55224. this.ctx.transform.apply(this.ctx, transform);
  55225. }
  55226. this.ctx.transform.apply(this.ctx, viewport.transform);
  55227. this.baseTransform = this.ctx.mozCurrentTransform.slice();
  55228. if (this.imageLayer) {
  55229. this.imageLayer.beginLayout();
  55230. }
  55231. },
  55232. executeOperatorList: function CanvasGraphics_executeOperatorList(operatorList, executionStartIdx, continueCallback, stepper) {
  55233. var argsArray = operatorList.argsArray;
  55234. var fnArray = operatorList.fnArray;
  55235. var i = executionStartIdx || 0;
  55236. var argsArrayLen = argsArray.length;
  55237. if (argsArrayLen === i) {
  55238. return i;
  55239. }
  55240. var chunkOperations = argsArrayLen - i > EXECUTION_STEPS && typeof continueCallback === 'function';
  55241. var endTime = chunkOperations ? Date.now() + EXECUTION_TIME : 0;
  55242. var steps = 0;
  55243. var commonObjs = this.commonObjs;
  55244. var objs = this.objs;
  55245. var fnId;
  55246. while (true) {
  55247. if (stepper !== undefined && i === stepper.nextBreakPoint) {
  55248. stepper.breakIt(i, continueCallback);
  55249. return i;
  55250. }
  55251. fnId = fnArray[i];
  55252. if (fnId !== OPS.dependency) {
  55253. this[fnId].apply(this, argsArray[i]);
  55254. } else {
  55255. var deps = argsArray[i];
  55256. for (var n = 0, nn = deps.length; n < nn; n++) {
  55257. var depObjId = deps[n];
  55258. var common = depObjId[0] === 'g' && depObjId[1] === '_';
  55259. var objsPool = common ? commonObjs : objs;
  55260. if (!objsPool.isResolved(depObjId)) {
  55261. objsPool.get(depObjId, continueCallback);
  55262. return i;
  55263. }
  55264. }
  55265. }
  55266. i++;
  55267. if (i === argsArrayLen) {
  55268. return i;
  55269. }
  55270. if (chunkOperations && ++steps > EXECUTION_STEPS) {
  55271. if (Date.now() > endTime) {
  55272. continueCallback();
  55273. return i;
  55274. }
  55275. steps = 0;
  55276. }
  55277. }
  55278. },
  55279. endDrawing: function CanvasGraphics_endDrawing() {
  55280. if (this.current.activeSMask !== null) {
  55281. this.endSMaskGroup();
  55282. }
  55283. this.ctx.restore();
  55284. if (this.transparentCanvas) {
  55285. this.ctx = this.compositeCtx;
  55286. this.ctx.save();
  55287. this.ctx.setTransform(1, 0, 0, 1, 0, 0);
  55288. this.ctx.drawImage(this.transparentCanvas, 0, 0);
  55289. this.ctx.restore();
  55290. this.transparentCanvas = null;
  55291. }
  55292. this.cachedCanvases.clear();
  55293. WebGLUtils.clear();
  55294. if (this.imageLayer) {
  55295. this.imageLayer.endLayout();
  55296. }
  55297. },
  55298. setLineWidth: function CanvasGraphics_setLineWidth(width) {
  55299. this.current.lineWidth = width;
  55300. this.ctx.lineWidth = width;
  55301. },
  55302. setLineCap: function CanvasGraphics_setLineCap(style) {
  55303. this.ctx.lineCap = LINE_CAP_STYLES[style];
  55304. },
  55305. setLineJoin: function CanvasGraphics_setLineJoin(style) {
  55306. this.ctx.lineJoin = LINE_JOIN_STYLES[style];
  55307. },
  55308. setMiterLimit: function CanvasGraphics_setMiterLimit(limit) {
  55309. this.ctx.miterLimit = limit;
  55310. },
  55311. setDash: function CanvasGraphics_setDash(dashArray, dashPhase) {
  55312. var ctx = this.ctx;
  55313. if (ctx.setLineDash !== undefined) {
  55314. ctx.setLineDash(dashArray);
  55315. ctx.lineDashOffset = dashPhase;
  55316. }
  55317. },
  55318. setRenderingIntent: function CanvasGraphics_setRenderingIntent(intent) {
  55319. },
  55320. setFlatness: function CanvasGraphics_setFlatness(flatness) {
  55321. },
  55322. setGState: function CanvasGraphics_setGState(states) {
  55323. for (var i = 0, ii = states.length; i < ii; i++) {
  55324. var state = states[i];
  55325. var key = state[0];
  55326. var value = state[1];
  55327. switch (key) {
  55328. case 'LW':
  55329. this.setLineWidth(value);
  55330. break;
  55331. case 'LC':
  55332. this.setLineCap(value);
  55333. break;
  55334. case 'LJ':
  55335. this.setLineJoin(value);
  55336. break;
  55337. case 'ML':
  55338. this.setMiterLimit(value);
  55339. break;
  55340. case 'D':
  55341. this.setDash(value[0], value[1]);
  55342. break;
  55343. case 'RI':
  55344. this.setRenderingIntent(value);
  55345. break;
  55346. case 'FL':
  55347. this.setFlatness(value);
  55348. break;
  55349. case 'Font':
  55350. this.setFont(value[0], value[1]);
  55351. break;
  55352. case 'CA':
  55353. this.current.strokeAlpha = state[1];
  55354. break;
  55355. case 'ca':
  55356. this.current.fillAlpha = state[1];
  55357. this.ctx.globalAlpha = state[1];
  55358. break;
  55359. case 'BM':
  55360. if (value && value.name && value.name !== 'Normal') {
  55361. var mode = value.name.replace(/([A-Z])/g, function (c) {
  55362. return '-' + c.toLowerCase();
  55363. }).substring(1);
  55364. this.ctx.globalCompositeOperation = mode;
  55365. if (this.ctx.globalCompositeOperation !== mode) {
  55366. warn('globalCompositeOperation "' + mode + '" is not supported');
  55367. }
  55368. } else {
  55369. this.ctx.globalCompositeOperation = 'source-over';
  55370. }
  55371. break;
  55372. case 'SMask':
  55373. if (this.current.activeSMask) {
  55374. if (this.stateStack.length > 0 && this.stateStack[this.stateStack.length - 1].activeSMask === this.current.activeSMask) {
  55375. this.suspendSMaskGroup();
  55376. } else {
  55377. this.endSMaskGroup();
  55378. }
  55379. }
  55380. this.current.activeSMask = value ? this.tempSMask : null;
  55381. if (this.current.activeSMask) {
  55382. this.beginSMaskGroup();
  55383. }
  55384. this.tempSMask = null;
  55385. break;
  55386. }
  55387. }
  55388. },
  55389. beginSMaskGroup: function CanvasGraphics_beginSMaskGroup() {
  55390. var activeSMask = this.current.activeSMask;
  55391. var drawnWidth = activeSMask.canvas.width;
  55392. var drawnHeight = activeSMask.canvas.height;
  55393. var cacheId = 'smaskGroupAt' + this.groupLevel;
  55394. var scratchCanvas = this.cachedCanvases.getCanvas(cacheId, drawnWidth, drawnHeight, true);
  55395. var currentCtx = this.ctx;
  55396. var currentTransform = currentCtx.mozCurrentTransform;
  55397. this.ctx.save();
  55398. var groupCtx = scratchCanvas.context;
  55399. groupCtx.scale(1 / activeSMask.scaleX, 1 / activeSMask.scaleY);
  55400. groupCtx.translate(-activeSMask.offsetX, -activeSMask.offsetY);
  55401. groupCtx.transform.apply(groupCtx, currentTransform);
  55402. activeSMask.startTransformInverse = groupCtx.mozCurrentTransformInverse;
  55403. copyCtxState(currentCtx, groupCtx);
  55404. this.ctx = groupCtx;
  55405. this.setGState([
  55406. [
  55407. 'BM',
  55408. 'Normal'
  55409. ],
  55410. [
  55411. 'ca',
  55412. 1
  55413. ],
  55414. [
  55415. 'CA',
  55416. 1
  55417. ]
  55418. ]);
  55419. this.groupStack.push(currentCtx);
  55420. this.groupLevel++;
  55421. },
  55422. suspendSMaskGroup: function CanvasGraphics_endSMaskGroup() {
  55423. var groupCtx = this.ctx;
  55424. this.groupLevel--;
  55425. this.ctx = this.groupStack.pop();
  55426. composeSMask(this.ctx, this.current.activeSMask, groupCtx);
  55427. this.ctx.restore();
  55428. this.ctx.save();
  55429. copyCtxState(groupCtx, this.ctx);
  55430. this.current.resumeSMaskCtx = groupCtx;
  55431. var deltaTransform = Util.transform(this.current.activeSMask.startTransformInverse, groupCtx.mozCurrentTransform);
  55432. this.ctx.transform.apply(this.ctx, deltaTransform);
  55433. groupCtx.save();
  55434. groupCtx.setTransform(1, 0, 0, 1, 0, 0);
  55435. groupCtx.clearRect(0, 0, groupCtx.canvas.width, groupCtx.canvas.height);
  55436. groupCtx.restore();
  55437. },
  55438. resumeSMaskGroup: function CanvasGraphics_endSMaskGroup() {
  55439. var groupCtx = this.current.resumeSMaskCtx;
  55440. var currentCtx = this.ctx;
  55441. this.ctx = groupCtx;
  55442. this.groupStack.push(currentCtx);
  55443. this.groupLevel++;
  55444. },
  55445. endSMaskGroup: function CanvasGraphics_endSMaskGroup() {
  55446. var groupCtx = this.ctx;
  55447. this.groupLevel--;
  55448. this.ctx = this.groupStack.pop();
  55449. composeSMask(this.ctx, this.current.activeSMask, groupCtx);
  55450. this.ctx.restore();
  55451. copyCtxState(groupCtx, this.ctx);
  55452. var deltaTransform = Util.transform(this.current.activeSMask.startTransformInverse, groupCtx.mozCurrentTransform);
  55453. this.ctx.transform.apply(this.ctx, deltaTransform);
  55454. },
  55455. save: function CanvasGraphics_save() {
  55456. this.ctx.save();
  55457. var old = this.current;
  55458. this.stateStack.push(old);
  55459. this.current = old.clone();
  55460. this.current.resumeSMaskCtx = null;
  55461. },
  55462. restore: function CanvasGraphics_restore() {
  55463. if (this.current.resumeSMaskCtx) {
  55464. this.resumeSMaskGroup();
  55465. }
  55466. if (this.current.activeSMask !== null && (this.stateStack.length === 0 || this.stateStack[this.stateStack.length - 1].activeSMask !== this.current.activeSMask)) {
  55467. this.endSMaskGroup();
  55468. }
  55469. if (this.stateStack.length !== 0) {
  55470. this.current = this.stateStack.pop();
  55471. this.ctx.restore();
  55472. this.pendingClip = null;
  55473. this.cachedGetSinglePixelWidth = null;
  55474. }
  55475. },
  55476. transform: function CanvasGraphics_transform(a, b, c, d, e, f) {
  55477. this.ctx.transform(a, b, c, d, e, f);
  55478. this.cachedGetSinglePixelWidth = null;
  55479. },
  55480. constructPath: function CanvasGraphics_constructPath(ops, args) {
  55481. var ctx = this.ctx;
  55482. var current = this.current;
  55483. var x = current.x, y = current.y;
  55484. for (var i = 0, j = 0, ii = ops.length; i < ii; i++) {
  55485. switch (ops[i] | 0) {
  55486. case OPS.rectangle:
  55487. x = args[j++];
  55488. y = args[j++];
  55489. var width = args[j++];
  55490. var height = args[j++];
  55491. if (width === 0) {
  55492. width = this.getSinglePixelWidth();
  55493. }
  55494. if (height === 0) {
  55495. height = this.getSinglePixelWidth();
  55496. }
  55497. var xw = x + width;
  55498. var yh = y + height;
  55499. this.ctx.moveTo(x, y);
  55500. this.ctx.lineTo(xw, y);
  55501. this.ctx.lineTo(xw, yh);
  55502. this.ctx.lineTo(x, yh);
  55503. this.ctx.lineTo(x, y);
  55504. this.ctx.closePath();
  55505. break;
  55506. case OPS.moveTo:
  55507. x = args[j++];
  55508. y = args[j++];
  55509. ctx.moveTo(x, y);
  55510. break;
  55511. case OPS.lineTo:
  55512. x = args[j++];
  55513. y = args[j++];
  55514. ctx.lineTo(x, y);
  55515. break;
  55516. case OPS.curveTo:
  55517. x = args[j + 4];
  55518. y = args[j + 5];
  55519. ctx.bezierCurveTo(args[j], args[j + 1], args[j + 2], args[j + 3], x, y);
  55520. j += 6;
  55521. break;
  55522. case OPS.curveTo2:
  55523. ctx.bezierCurveTo(x, y, args[j], args[j + 1], args[j + 2], args[j + 3]);
  55524. x = args[j + 2];
  55525. y = args[j + 3];
  55526. j += 4;
  55527. break;
  55528. case OPS.curveTo3:
  55529. x = args[j + 2];
  55530. y = args[j + 3];
  55531. ctx.bezierCurveTo(args[j], args[j + 1], x, y, x, y);
  55532. j += 4;
  55533. break;
  55534. case OPS.closePath:
  55535. ctx.closePath();
  55536. break;
  55537. }
  55538. }
  55539. current.setCurrentPoint(x, y);
  55540. },
  55541. closePath: function CanvasGraphics_closePath() {
  55542. this.ctx.closePath();
  55543. },
  55544. stroke: function CanvasGraphics_stroke(consumePath) {
  55545. consumePath = typeof consumePath !== 'undefined' ? consumePath : true;
  55546. var ctx = this.ctx;
  55547. var strokeColor = this.current.strokeColor;
  55548. ctx.lineWidth = Math.max(this.getSinglePixelWidth() * MIN_WIDTH_FACTOR, this.current.lineWidth);
  55549. ctx.globalAlpha = this.current.strokeAlpha;
  55550. if (strokeColor && strokeColor.hasOwnProperty('type') && strokeColor.type === 'Pattern') {
  55551. ctx.save();
  55552. ctx.strokeStyle = strokeColor.getPattern(ctx, this);
  55553. ctx.stroke();
  55554. ctx.restore();
  55555. } else {
  55556. ctx.stroke();
  55557. }
  55558. if (consumePath) {
  55559. this.consumePath();
  55560. }
  55561. ctx.globalAlpha = this.current.fillAlpha;
  55562. },
  55563. closeStroke: function CanvasGraphics_closeStroke() {
  55564. this.closePath();
  55565. this.stroke();
  55566. },
  55567. fill: function CanvasGraphics_fill(consumePath) {
  55568. consumePath = typeof consumePath !== 'undefined' ? consumePath : true;
  55569. var ctx = this.ctx;
  55570. var fillColor = this.current.fillColor;
  55571. var isPatternFill = this.current.patternFill;
  55572. var needRestore = false;
  55573. if (isPatternFill) {
  55574. ctx.save();
  55575. if (this.baseTransform) {
  55576. ctx.setTransform.apply(ctx, this.baseTransform);
  55577. }
  55578. ctx.fillStyle = fillColor.getPattern(ctx, this);
  55579. needRestore = true;
  55580. }
  55581. if (this.pendingEOFill) {
  55582. ctx.fill('evenodd');
  55583. this.pendingEOFill = false;
  55584. } else {
  55585. ctx.fill();
  55586. }
  55587. if (needRestore) {
  55588. ctx.restore();
  55589. }
  55590. if (consumePath) {
  55591. this.consumePath();
  55592. }
  55593. },
  55594. eoFill: function CanvasGraphics_eoFill() {
  55595. this.pendingEOFill = true;
  55596. this.fill();
  55597. },
  55598. fillStroke: function CanvasGraphics_fillStroke() {
  55599. this.fill(false);
  55600. this.stroke(false);
  55601. this.consumePath();
  55602. },
  55603. eoFillStroke: function CanvasGraphics_eoFillStroke() {
  55604. this.pendingEOFill = true;
  55605. this.fillStroke();
  55606. },
  55607. closeFillStroke: function CanvasGraphics_closeFillStroke() {
  55608. this.closePath();
  55609. this.fillStroke();
  55610. },
  55611. closeEOFillStroke: function CanvasGraphics_closeEOFillStroke() {
  55612. this.pendingEOFill = true;
  55613. this.closePath();
  55614. this.fillStroke();
  55615. },
  55616. endPath: function CanvasGraphics_endPath() {
  55617. this.consumePath();
  55618. },
  55619. clip: function CanvasGraphics_clip() {
  55620. this.pendingClip = NORMAL_CLIP;
  55621. },
  55622. eoClip: function CanvasGraphics_eoClip() {
  55623. this.pendingClip = EO_CLIP;
  55624. },
  55625. beginText: function CanvasGraphics_beginText() {
  55626. this.current.textMatrix = IDENTITY_MATRIX;
  55627. this.current.textMatrixScale = 1;
  55628. this.current.x = this.current.lineX = 0;
  55629. this.current.y = this.current.lineY = 0;
  55630. },
  55631. endText: function CanvasGraphics_endText() {
  55632. var paths = this.pendingTextPaths;
  55633. var ctx = this.ctx;
  55634. if (paths === undefined) {
  55635. ctx.beginPath();
  55636. return;
  55637. }
  55638. ctx.save();
  55639. ctx.beginPath();
  55640. for (var i = 0; i < paths.length; i++) {
  55641. var path = paths[i];
  55642. ctx.setTransform.apply(ctx, path.transform);
  55643. ctx.translate(path.x, path.y);
  55644. path.addToPath(ctx, path.fontSize);
  55645. }
  55646. ctx.restore();
  55647. ctx.clip();
  55648. ctx.beginPath();
  55649. delete this.pendingTextPaths;
  55650. },
  55651. setCharSpacing: function CanvasGraphics_setCharSpacing(spacing) {
  55652. this.current.charSpacing = spacing;
  55653. },
  55654. setWordSpacing: function CanvasGraphics_setWordSpacing(spacing) {
  55655. this.current.wordSpacing = spacing;
  55656. },
  55657. setHScale: function CanvasGraphics_setHScale(scale) {
  55658. this.current.textHScale = scale / 100;
  55659. },
  55660. setLeading: function CanvasGraphics_setLeading(leading) {
  55661. this.current.leading = -leading;
  55662. },
  55663. setFont: function CanvasGraphics_setFont(fontRefName, size) {
  55664. var fontObj = this.commonObjs.get(fontRefName);
  55665. var current = this.current;
  55666. if (!fontObj) {
  55667. error('Can\'t find font for ' + fontRefName);
  55668. }
  55669. current.fontMatrix = fontObj.fontMatrix ? fontObj.fontMatrix : FONT_IDENTITY_MATRIX;
  55670. if (current.fontMatrix[0] === 0 || current.fontMatrix[3] === 0) {
  55671. warn('Invalid font matrix for font ' + fontRefName);
  55672. }
  55673. if (size < 0) {
  55674. size = -size;
  55675. current.fontDirection = -1;
  55676. } else {
  55677. current.fontDirection = 1;
  55678. }
  55679. this.current.font = fontObj;
  55680. this.current.fontSize = size;
  55681. if (fontObj.isType3Font) {
  55682. return;
  55683. }
  55684. var name = fontObj.loadedName || 'sans-serif';
  55685. var bold = fontObj.black ? '900' : fontObj.bold ? 'bold' : 'normal';
  55686. var italic = fontObj.italic ? 'italic' : 'normal';
  55687. var typeface = '"' + name + '", ' + fontObj.fallbackName;
  55688. var browserFontSize = size < MIN_FONT_SIZE ? MIN_FONT_SIZE : size > MAX_FONT_SIZE ? MAX_FONT_SIZE : size;
  55689. this.current.fontSizeScale = size / browserFontSize;
  55690. var rule = italic + ' ' + bold + ' ' + browserFontSize + 'px ' + typeface;
  55691. this.ctx.font = rule;
  55692. },
  55693. setTextRenderingMode: function CanvasGraphics_setTextRenderingMode(mode) {
  55694. this.current.textRenderingMode = mode;
  55695. },
  55696. setTextRise: function CanvasGraphics_setTextRise(rise) {
  55697. this.current.textRise = rise;
  55698. },
  55699. moveText: function CanvasGraphics_moveText(x, y) {
  55700. this.current.x = this.current.lineX += x;
  55701. this.current.y = this.current.lineY += y;
  55702. },
  55703. setLeadingMoveText: function CanvasGraphics_setLeadingMoveText(x, y) {
  55704. this.setLeading(-y);
  55705. this.moveText(x, y);
  55706. },
  55707. setTextMatrix: function CanvasGraphics_setTextMatrix(a, b, c, d, e, f) {
  55708. this.current.textMatrix = [
  55709. a,
  55710. b,
  55711. c,
  55712. d,
  55713. e,
  55714. f
  55715. ];
  55716. this.current.textMatrixScale = Math.sqrt(a * a + b * b);
  55717. this.current.x = this.current.lineX = 0;
  55718. this.current.y = this.current.lineY = 0;
  55719. },
  55720. nextLine: function CanvasGraphics_nextLine() {
  55721. this.moveText(0, this.current.leading);
  55722. },
  55723. paintChar: function CanvasGraphics_paintChar(character, x, y) {
  55724. var ctx = this.ctx;
  55725. var current = this.current;
  55726. var font = current.font;
  55727. var textRenderingMode = current.textRenderingMode;
  55728. var fontSize = current.fontSize / current.fontSizeScale;
  55729. var fillStrokeMode = textRenderingMode & TextRenderingMode.FILL_STROKE_MASK;
  55730. var isAddToPathSet = !!(textRenderingMode & TextRenderingMode.ADD_TO_PATH_FLAG);
  55731. var addToPath;
  55732. if (font.disableFontFace || isAddToPathSet) {
  55733. addToPath = font.getPathGenerator(this.commonObjs, character);
  55734. }
  55735. if (font.disableFontFace) {
  55736. ctx.save();
  55737. ctx.translate(x, y);
  55738. ctx.beginPath();
  55739. addToPath(ctx, fontSize);
  55740. if (fillStrokeMode === TextRenderingMode.FILL || fillStrokeMode === TextRenderingMode.FILL_STROKE) {
  55741. ctx.fill();
  55742. }
  55743. if (fillStrokeMode === TextRenderingMode.STROKE || fillStrokeMode === TextRenderingMode.FILL_STROKE) {
  55744. ctx.stroke();
  55745. }
  55746. ctx.restore();
  55747. } else {
  55748. if (fillStrokeMode === TextRenderingMode.FILL || fillStrokeMode === TextRenderingMode.FILL_STROKE) {
  55749. ctx.fillText(character, x, y);
  55750. }
  55751. if (fillStrokeMode === TextRenderingMode.STROKE || fillStrokeMode === TextRenderingMode.FILL_STROKE) {
  55752. ctx.strokeText(character, x, y);
  55753. }
  55754. }
  55755. if (isAddToPathSet) {
  55756. var paths = this.pendingTextPaths || (this.pendingTextPaths = []);
  55757. paths.push({
  55758. transform: ctx.mozCurrentTransform,
  55759. x: x,
  55760. y: y,
  55761. fontSize: fontSize,
  55762. addToPath: addToPath
  55763. });
  55764. }
  55765. },
  55766. get isFontSubpixelAAEnabled() {
  55767. var ctx = this.canvasFactory.create(10, 10).context;
  55768. ctx.scale(1.5, 1);
  55769. ctx.fillText('I', 0, 10);
  55770. var data = ctx.getImageData(0, 0, 10, 10).data;
  55771. var enabled = false;
  55772. for (var i = 3; i < data.length; i += 4) {
  55773. if (data[i] > 0 && data[i] < 255) {
  55774. enabled = true;
  55775. break;
  55776. }
  55777. }
  55778. return shadow(this, 'isFontSubpixelAAEnabled', enabled);
  55779. },
  55780. showText: function CanvasGraphics_showText(glyphs) {
  55781. var current = this.current;
  55782. var font = current.font;
  55783. if (font.isType3Font) {
  55784. return this.showType3Text(glyphs);
  55785. }
  55786. var fontSize = current.fontSize;
  55787. if (fontSize === 0) {
  55788. return;
  55789. }
  55790. var ctx = this.ctx;
  55791. var fontSizeScale = current.fontSizeScale;
  55792. var charSpacing = current.charSpacing;
  55793. var wordSpacing = current.wordSpacing;
  55794. var fontDirection = current.fontDirection;
  55795. var textHScale = current.textHScale * fontDirection;
  55796. var glyphsLength = glyphs.length;
  55797. var vertical = font.vertical;
  55798. var spacingDir = vertical ? 1 : -1;
  55799. var defaultVMetrics = font.defaultVMetrics;
  55800. var widthAdvanceScale = fontSize * current.fontMatrix[0];
  55801. var simpleFillText = current.textRenderingMode === TextRenderingMode.FILL && !font.disableFontFace;
  55802. ctx.save();
  55803. ctx.transform.apply(ctx, current.textMatrix);
  55804. ctx.translate(current.x, current.y + current.textRise);
  55805. if (current.patternFill) {
  55806. ctx.fillStyle = current.fillColor.getPattern(ctx, this);
  55807. }
  55808. if (fontDirection > 0) {
  55809. ctx.scale(textHScale, -1);
  55810. } else {
  55811. ctx.scale(textHScale, 1);
  55812. }
  55813. var lineWidth = current.lineWidth;
  55814. var scale = current.textMatrixScale;
  55815. if (scale === 0 || lineWidth === 0) {
  55816. var fillStrokeMode = current.textRenderingMode & TextRenderingMode.FILL_STROKE_MASK;
  55817. if (fillStrokeMode === TextRenderingMode.STROKE || fillStrokeMode === TextRenderingMode.FILL_STROKE) {
  55818. this.cachedGetSinglePixelWidth = null;
  55819. lineWidth = this.getSinglePixelWidth() * MIN_WIDTH_FACTOR;
  55820. }
  55821. } else {
  55822. lineWidth /= scale;
  55823. }
  55824. if (fontSizeScale !== 1.0) {
  55825. ctx.scale(fontSizeScale, fontSizeScale);
  55826. lineWidth /= fontSizeScale;
  55827. }
  55828. ctx.lineWidth = lineWidth;
  55829. var x = 0, i;
  55830. for (i = 0; i < glyphsLength; ++i) {
  55831. var glyph = glyphs[i];
  55832. if (isNum(glyph)) {
  55833. x += spacingDir * glyph * fontSize / 1000;
  55834. continue;
  55835. }
  55836. var restoreNeeded = false;
  55837. var spacing = (glyph.isSpace ? wordSpacing : 0) + charSpacing;
  55838. var character = glyph.fontChar;
  55839. var accent = glyph.accent;
  55840. var scaledX, scaledY, scaledAccentX, scaledAccentY;
  55841. var width = glyph.width;
  55842. if (vertical) {
  55843. var vmetric, vx, vy;
  55844. vmetric = glyph.vmetric || defaultVMetrics;
  55845. vx = glyph.vmetric ? vmetric[1] : width * 0.5;
  55846. vx = -vx * widthAdvanceScale;
  55847. vy = vmetric[2] * widthAdvanceScale;
  55848. width = vmetric ? -vmetric[0] : width;
  55849. scaledX = vx / fontSizeScale;
  55850. scaledY = (x + vy) / fontSizeScale;
  55851. } else {
  55852. scaledX = x / fontSizeScale;
  55853. scaledY = 0;
  55854. }
  55855. if (font.remeasure && width > 0) {
  55856. var measuredWidth = ctx.measureText(character).width * 1000 / fontSize * fontSizeScale;
  55857. if (width < measuredWidth && this.isFontSubpixelAAEnabled) {
  55858. var characterScaleX = width / measuredWidth;
  55859. restoreNeeded = true;
  55860. ctx.save();
  55861. ctx.scale(characterScaleX, 1);
  55862. scaledX /= characterScaleX;
  55863. } else if (width !== measuredWidth) {
  55864. scaledX += (width - measuredWidth) / 2000 * fontSize / fontSizeScale;
  55865. }
  55866. }
  55867. if (glyph.isInFont || font.missingFile) {
  55868. if (simpleFillText && !accent) {
  55869. ctx.fillText(character, scaledX, scaledY);
  55870. } else {
  55871. this.paintChar(character, scaledX, scaledY);
  55872. if (accent) {
  55873. scaledAccentX = scaledX + accent.offset.x / fontSizeScale;
  55874. scaledAccentY = scaledY - accent.offset.y / fontSizeScale;
  55875. this.paintChar(accent.fontChar, scaledAccentX, scaledAccentY);
  55876. }
  55877. }
  55878. }
  55879. var charWidth = width * widthAdvanceScale + spacing * fontDirection;
  55880. x += charWidth;
  55881. if (restoreNeeded) {
  55882. ctx.restore();
  55883. }
  55884. }
  55885. if (vertical) {
  55886. current.y -= x * textHScale;
  55887. } else {
  55888. current.x += x * textHScale;
  55889. }
  55890. ctx.restore();
  55891. },
  55892. showType3Text: function CanvasGraphics_showType3Text(glyphs) {
  55893. var ctx = this.ctx;
  55894. var current = this.current;
  55895. var font = current.font;
  55896. var fontSize = current.fontSize;
  55897. var fontDirection = current.fontDirection;
  55898. var spacingDir = font.vertical ? 1 : -1;
  55899. var charSpacing = current.charSpacing;
  55900. var wordSpacing = current.wordSpacing;
  55901. var textHScale = current.textHScale * fontDirection;
  55902. var fontMatrix = current.fontMatrix || FONT_IDENTITY_MATRIX;
  55903. var glyphsLength = glyphs.length;
  55904. var isTextInvisible = current.textRenderingMode === TextRenderingMode.INVISIBLE;
  55905. var i, glyph, width, spacingLength;
  55906. if (isTextInvisible || fontSize === 0) {
  55907. return;
  55908. }
  55909. this.cachedGetSinglePixelWidth = null;
  55910. ctx.save();
  55911. ctx.transform.apply(ctx, current.textMatrix);
  55912. ctx.translate(current.x, current.y);
  55913. ctx.scale(textHScale, fontDirection);
  55914. for (i = 0; i < glyphsLength; ++i) {
  55915. glyph = glyphs[i];
  55916. if (isNum(glyph)) {
  55917. spacingLength = spacingDir * glyph * fontSize / 1000;
  55918. this.ctx.translate(spacingLength, 0);
  55919. current.x += spacingLength * textHScale;
  55920. continue;
  55921. }
  55922. var spacing = (glyph.isSpace ? wordSpacing : 0) + charSpacing;
  55923. var operatorList = font.charProcOperatorList[glyph.operatorListId];
  55924. if (!operatorList) {
  55925. warn('Type3 character \"' + glyph.operatorListId + '\" is not available');
  55926. continue;
  55927. }
  55928. this.processingType3 = glyph;
  55929. this.save();
  55930. ctx.scale(fontSize, fontSize);
  55931. ctx.transform.apply(ctx, fontMatrix);
  55932. this.executeOperatorList(operatorList);
  55933. this.restore();
  55934. var transformed = Util.applyTransform([
  55935. glyph.width,
  55936. 0
  55937. ], fontMatrix);
  55938. width = transformed[0] * fontSize + spacing;
  55939. ctx.translate(width, 0);
  55940. current.x += width * textHScale;
  55941. }
  55942. ctx.restore();
  55943. this.processingType3 = null;
  55944. },
  55945. setCharWidth: function CanvasGraphics_setCharWidth(xWidth, yWidth) {
  55946. },
  55947. setCharWidthAndBounds: function CanvasGraphics_setCharWidthAndBounds(xWidth, yWidth, llx, lly, urx, ury) {
  55948. this.ctx.rect(llx, lly, urx - llx, ury - lly);
  55949. this.clip();
  55950. this.endPath();
  55951. },
  55952. getColorN_Pattern: function CanvasGraphics_getColorN_Pattern(IR) {
  55953. var pattern;
  55954. if (IR[0] === 'TilingPattern') {
  55955. var color = IR[1];
  55956. var baseTransform = this.baseTransform || this.ctx.mozCurrentTransform.slice();
  55957. var self = this;
  55958. var canvasGraphicsFactory = {
  55959. createCanvasGraphics: function (ctx) {
  55960. return new CanvasGraphics(ctx, self.commonObjs, self.objs, self.canvasFactory);
  55961. }
  55962. };
  55963. pattern = new TilingPattern(IR, color, this.ctx, canvasGraphicsFactory, baseTransform);
  55964. } else {
  55965. pattern = getShadingPatternFromIR(IR);
  55966. }
  55967. return pattern;
  55968. },
  55969. setStrokeColorN: function CanvasGraphics_setStrokeColorN() {
  55970. this.current.strokeColor = this.getColorN_Pattern(arguments);
  55971. },
  55972. setFillColorN: function CanvasGraphics_setFillColorN() {
  55973. this.current.fillColor = this.getColorN_Pattern(arguments);
  55974. this.current.patternFill = true;
  55975. },
  55976. setStrokeRGBColor: function CanvasGraphics_setStrokeRGBColor(r, g, b) {
  55977. var color = Util.makeCssRgb(r, g, b);
  55978. this.ctx.strokeStyle = color;
  55979. this.current.strokeColor = color;
  55980. },
  55981. setFillRGBColor: function CanvasGraphics_setFillRGBColor(r, g, b) {
  55982. var color = Util.makeCssRgb(r, g, b);
  55983. this.ctx.fillStyle = color;
  55984. this.current.fillColor = color;
  55985. this.current.patternFill = false;
  55986. },
  55987. shadingFill: function CanvasGraphics_shadingFill(patternIR) {
  55988. var ctx = this.ctx;
  55989. this.save();
  55990. var pattern = getShadingPatternFromIR(patternIR);
  55991. ctx.fillStyle = pattern.getPattern(ctx, this, true);
  55992. var inv = ctx.mozCurrentTransformInverse;
  55993. if (inv) {
  55994. var canvas = ctx.canvas;
  55995. var width = canvas.width;
  55996. var height = canvas.height;
  55997. var bl = Util.applyTransform([
  55998. 0,
  55999. 0
  56000. ], inv);
  56001. var br = Util.applyTransform([
  56002. 0,
  56003. height
  56004. ], inv);
  56005. var ul = Util.applyTransform([
  56006. width,
  56007. 0
  56008. ], inv);
  56009. var ur = Util.applyTransform([
  56010. width,
  56011. height
  56012. ], inv);
  56013. var x0 = Math.min(bl[0], br[0], ul[0], ur[0]);
  56014. var y0 = Math.min(bl[1], br[1], ul[1], ur[1]);
  56015. var x1 = Math.max(bl[0], br[0], ul[0], ur[0]);
  56016. var y1 = Math.max(bl[1], br[1], ul[1], ur[1]);
  56017. this.ctx.fillRect(x0, y0, x1 - x0, y1 - y0);
  56018. } else {
  56019. this.ctx.fillRect(-1e10, -1e10, 2e10, 2e10);
  56020. }
  56021. this.restore();
  56022. },
  56023. beginInlineImage: function CanvasGraphics_beginInlineImage() {
  56024. error('Should not call beginInlineImage');
  56025. },
  56026. beginImageData: function CanvasGraphics_beginImageData() {
  56027. error('Should not call beginImageData');
  56028. },
  56029. paintFormXObjectBegin: function CanvasGraphics_paintFormXObjectBegin(matrix, bbox) {
  56030. this.save();
  56031. this.baseTransformStack.push(this.baseTransform);
  56032. if (isArray(matrix) && matrix.length === 6) {
  56033. this.transform.apply(this, matrix);
  56034. }
  56035. this.baseTransform = this.ctx.mozCurrentTransform;
  56036. if (isArray(bbox) && bbox.length === 4) {
  56037. var width = bbox[2] - bbox[0];
  56038. var height = bbox[3] - bbox[1];
  56039. this.ctx.rect(bbox[0], bbox[1], width, height);
  56040. this.clip();
  56041. this.endPath();
  56042. }
  56043. },
  56044. paintFormXObjectEnd: function CanvasGraphics_paintFormXObjectEnd() {
  56045. this.restore();
  56046. this.baseTransform = this.baseTransformStack.pop();
  56047. },
  56048. beginGroup: function CanvasGraphics_beginGroup(group) {
  56049. this.save();
  56050. var currentCtx = this.ctx;
  56051. if (!group.isolated) {
  56052. info('TODO: Support non-isolated groups.');
  56053. }
  56054. if (group.knockout) {
  56055. warn('Knockout groups not supported.');
  56056. }
  56057. var currentTransform = currentCtx.mozCurrentTransform;
  56058. if (group.matrix) {
  56059. currentCtx.transform.apply(currentCtx, group.matrix);
  56060. }
  56061. assert(group.bbox, 'Bounding box is required.');
  56062. var bounds = Util.getAxialAlignedBoundingBox(group.bbox, currentCtx.mozCurrentTransform);
  56063. var canvasBounds = [
  56064. 0,
  56065. 0,
  56066. currentCtx.canvas.width,
  56067. currentCtx.canvas.height
  56068. ];
  56069. bounds = Util.intersect(bounds, canvasBounds) || [
  56070. 0,
  56071. 0,
  56072. 0,
  56073. 0
  56074. ];
  56075. var offsetX = Math.floor(bounds[0]);
  56076. var offsetY = Math.floor(bounds[1]);
  56077. var drawnWidth = Math.max(Math.ceil(bounds[2]) - offsetX, 1);
  56078. var drawnHeight = Math.max(Math.ceil(bounds[3]) - offsetY, 1);
  56079. var scaleX = 1, scaleY = 1;
  56080. if (drawnWidth > MAX_GROUP_SIZE) {
  56081. scaleX = drawnWidth / MAX_GROUP_SIZE;
  56082. drawnWidth = MAX_GROUP_SIZE;
  56083. }
  56084. if (drawnHeight > MAX_GROUP_SIZE) {
  56085. scaleY = drawnHeight / MAX_GROUP_SIZE;
  56086. drawnHeight = MAX_GROUP_SIZE;
  56087. }
  56088. var cacheId = 'groupAt' + this.groupLevel;
  56089. if (group.smask) {
  56090. cacheId += '_smask_' + this.smaskCounter++ % 2;
  56091. }
  56092. var scratchCanvas = this.cachedCanvases.getCanvas(cacheId, drawnWidth, drawnHeight, true);
  56093. var groupCtx = scratchCanvas.context;
  56094. groupCtx.scale(1 / scaleX, 1 / scaleY);
  56095. groupCtx.translate(-offsetX, -offsetY);
  56096. groupCtx.transform.apply(groupCtx, currentTransform);
  56097. if (group.smask) {
  56098. this.smaskStack.push({
  56099. canvas: scratchCanvas.canvas,
  56100. context: groupCtx,
  56101. offsetX: offsetX,
  56102. offsetY: offsetY,
  56103. scaleX: scaleX,
  56104. scaleY: scaleY,
  56105. subtype: group.smask.subtype,
  56106. backdrop: group.smask.backdrop,
  56107. transferMap: group.smask.transferMap || null,
  56108. startTransformInverse: null
  56109. });
  56110. } else {
  56111. currentCtx.setTransform(1, 0, 0, 1, 0, 0);
  56112. currentCtx.translate(offsetX, offsetY);
  56113. currentCtx.scale(scaleX, scaleY);
  56114. }
  56115. copyCtxState(currentCtx, groupCtx);
  56116. this.ctx = groupCtx;
  56117. this.setGState([
  56118. [
  56119. 'BM',
  56120. 'Normal'
  56121. ],
  56122. [
  56123. 'ca',
  56124. 1
  56125. ],
  56126. [
  56127. 'CA',
  56128. 1
  56129. ]
  56130. ]);
  56131. this.groupStack.push(currentCtx);
  56132. this.groupLevel++;
  56133. this.current.activeSMask = null;
  56134. },
  56135. endGroup: function CanvasGraphics_endGroup(group) {
  56136. this.groupLevel--;
  56137. var groupCtx = this.ctx;
  56138. this.ctx = this.groupStack.pop();
  56139. if (this.ctx.imageSmoothingEnabled !== undefined) {
  56140. this.ctx.imageSmoothingEnabled = false;
  56141. } else {
  56142. this.ctx.mozImageSmoothingEnabled = false;
  56143. }
  56144. if (group.smask) {
  56145. this.tempSMask = this.smaskStack.pop();
  56146. } else {
  56147. this.ctx.drawImage(groupCtx.canvas, 0, 0);
  56148. }
  56149. this.restore();
  56150. },
  56151. beginAnnotations: function CanvasGraphics_beginAnnotations() {
  56152. this.save();
  56153. this.current = new CanvasExtraState();
  56154. if (this.baseTransform) {
  56155. this.ctx.setTransform.apply(this.ctx, this.baseTransform);
  56156. }
  56157. },
  56158. endAnnotations: function CanvasGraphics_endAnnotations() {
  56159. this.restore();
  56160. },
  56161. beginAnnotation: function CanvasGraphics_beginAnnotation(rect, transform, matrix) {
  56162. this.save();
  56163. if (isArray(rect) && rect.length === 4) {
  56164. var width = rect[2] - rect[0];
  56165. var height = rect[3] - rect[1];
  56166. this.ctx.rect(rect[0], rect[1], width, height);
  56167. this.clip();
  56168. this.endPath();
  56169. }
  56170. this.transform.apply(this, transform);
  56171. this.transform.apply(this, matrix);
  56172. },
  56173. endAnnotation: function CanvasGraphics_endAnnotation() {
  56174. this.restore();
  56175. },
  56176. paintJpegXObject: function CanvasGraphics_paintJpegXObject(objId, w, h) {
  56177. var domImage = this.objs.get(objId);
  56178. if (!domImage) {
  56179. warn('Dependent image isn\'t ready yet');
  56180. return;
  56181. }
  56182. this.save();
  56183. var ctx = this.ctx;
  56184. ctx.scale(1 / w, -1 / h);
  56185. ctx.drawImage(domImage, 0, 0, domImage.width, domImage.height, 0, -h, w, h);
  56186. if (this.imageLayer) {
  56187. var currentTransform = ctx.mozCurrentTransformInverse;
  56188. var position = this.getCanvasPosition(0, 0);
  56189. this.imageLayer.appendImage({
  56190. objId: objId,
  56191. left: position[0],
  56192. top: position[1],
  56193. width: w / currentTransform[0],
  56194. height: h / currentTransform[3]
  56195. });
  56196. }
  56197. this.restore();
  56198. },
  56199. paintImageMaskXObject: function CanvasGraphics_paintImageMaskXObject(img) {
  56200. var ctx = this.ctx;
  56201. var width = img.width, height = img.height;
  56202. var fillColor = this.current.fillColor;
  56203. var isPatternFill = this.current.patternFill;
  56204. var glyph = this.processingType3;
  56205. if (COMPILE_TYPE3_GLYPHS && glyph && glyph.compiled === undefined) {
  56206. if (width <= MAX_SIZE_TO_COMPILE && height <= MAX_SIZE_TO_COMPILE) {
  56207. glyph.compiled = compileType3Glyph({
  56208. data: img.data,
  56209. width: width,
  56210. height: height
  56211. });
  56212. } else {
  56213. glyph.compiled = null;
  56214. }
  56215. }
  56216. if (glyph && glyph.compiled) {
  56217. glyph.compiled(ctx);
  56218. return;
  56219. }
  56220. var maskCanvas = this.cachedCanvases.getCanvas('maskCanvas', width, height);
  56221. var maskCtx = maskCanvas.context;
  56222. maskCtx.save();
  56223. putBinaryImageMask(maskCtx, img);
  56224. maskCtx.globalCompositeOperation = 'source-in';
  56225. maskCtx.fillStyle = isPatternFill ? fillColor.getPattern(maskCtx, this) : fillColor;
  56226. maskCtx.fillRect(0, 0, width, height);
  56227. maskCtx.restore();
  56228. this.paintInlineImageXObject(maskCanvas.canvas);
  56229. },
  56230. paintImageMaskXObjectRepeat: function CanvasGraphics_paintImageMaskXObjectRepeat(imgData, scaleX, scaleY, positions) {
  56231. var width = imgData.width;
  56232. var height = imgData.height;
  56233. var fillColor = this.current.fillColor;
  56234. var isPatternFill = this.current.patternFill;
  56235. var maskCanvas = this.cachedCanvases.getCanvas('maskCanvas', width, height);
  56236. var maskCtx = maskCanvas.context;
  56237. maskCtx.save();
  56238. putBinaryImageMask(maskCtx, imgData);
  56239. maskCtx.globalCompositeOperation = 'source-in';
  56240. maskCtx.fillStyle = isPatternFill ? fillColor.getPattern(maskCtx, this) : fillColor;
  56241. maskCtx.fillRect(0, 0, width, height);
  56242. maskCtx.restore();
  56243. var ctx = this.ctx;
  56244. for (var i = 0, ii = positions.length; i < ii; i += 2) {
  56245. ctx.save();
  56246. ctx.transform(scaleX, 0, 0, scaleY, positions[i], positions[i + 1]);
  56247. ctx.scale(1, -1);
  56248. ctx.drawImage(maskCanvas.canvas, 0, 0, width, height, 0, -1, 1, 1);
  56249. ctx.restore();
  56250. }
  56251. },
  56252. paintImageMaskXObjectGroup: function CanvasGraphics_paintImageMaskXObjectGroup(images) {
  56253. var ctx = this.ctx;
  56254. var fillColor = this.current.fillColor;
  56255. var isPatternFill = this.current.patternFill;
  56256. for (var i = 0, ii = images.length; i < ii; i++) {
  56257. var image = images[i];
  56258. var width = image.width, height = image.height;
  56259. var maskCanvas = this.cachedCanvases.getCanvas('maskCanvas', width, height);
  56260. var maskCtx = maskCanvas.context;
  56261. maskCtx.save();
  56262. putBinaryImageMask(maskCtx, image);
  56263. maskCtx.globalCompositeOperation = 'source-in';
  56264. maskCtx.fillStyle = isPatternFill ? fillColor.getPattern(maskCtx, this) : fillColor;
  56265. maskCtx.fillRect(0, 0, width, height);
  56266. maskCtx.restore();
  56267. ctx.save();
  56268. ctx.transform.apply(ctx, image.transform);
  56269. ctx.scale(1, -1);
  56270. ctx.drawImage(maskCanvas.canvas, 0, 0, width, height, 0, -1, 1, 1);
  56271. ctx.restore();
  56272. }
  56273. },
  56274. paintImageXObject: function CanvasGraphics_paintImageXObject(objId) {
  56275. var imgData = this.objs.get(objId);
  56276. if (!imgData) {
  56277. warn('Dependent image isn\'t ready yet');
  56278. return;
  56279. }
  56280. this.paintInlineImageXObject(imgData);
  56281. },
  56282. paintImageXObjectRepeat: function CanvasGraphics_paintImageXObjectRepeat(objId, scaleX, scaleY, positions) {
  56283. var imgData = this.objs.get(objId);
  56284. if (!imgData) {
  56285. warn('Dependent image isn\'t ready yet');
  56286. return;
  56287. }
  56288. var width = imgData.width;
  56289. var height = imgData.height;
  56290. var map = [];
  56291. for (var i = 0, ii = positions.length; i < ii; i += 2) {
  56292. map.push({
  56293. transform: [
  56294. scaleX,
  56295. 0,
  56296. 0,
  56297. scaleY,
  56298. positions[i],
  56299. positions[i + 1]
  56300. ],
  56301. x: 0,
  56302. y: 0,
  56303. w: width,
  56304. h: height
  56305. });
  56306. }
  56307. this.paintInlineImageXObjectGroup(imgData, map);
  56308. },
  56309. paintInlineImageXObject: function CanvasGraphics_paintInlineImageXObject(imgData) {
  56310. var width = imgData.width;
  56311. var height = imgData.height;
  56312. var ctx = this.ctx;
  56313. this.save();
  56314. ctx.scale(1 / width, -1 / height);
  56315. var currentTransform = ctx.mozCurrentTransformInverse;
  56316. var a = currentTransform[0], b = currentTransform[1];
  56317. var widthScale = Math.max(Math.sqrt(a * a + b * b), 1);
  56318. var c = currentTransform[2], d = currentTransform[3];
  56319. var heightScale = Math.max(Math.sqrt(c * c + d * d), 1);
  56320. var imgToPaint, tmpCanvas;
  56321. if (imgData instanceof HTMLElement || !imgData.data) {
  56322. imgToPaint = imgData;
  56323. } else {
  56324. tmpCanvas = this.cachedCanvases.getCanvas('inlineImage', width, height);
  56325. var tmpCtx = tmpCanvas.context;
  56326. putBinaryImageData(tmpCtx, imgData);
  56327. imgToPaint = tmpCanvas.canvas;
  56328. }
  56329. var paintWidth = width, paintHeight = height;
  56330. var tmpCanvasId = 'prescale1';
  56331. while (widthScale > 2 && paintWidth > 1 || heightScale > 2 && paintHeight > 1) {
  56332. var newWidth = paintWidth, newHeight = paintHeight;
  56333. if (widthScale > 2 && paintWidth > 1) {
  56334. newWidth = Math.ceil(paintWidth / 2);
  56335. widthScale /= paintWidth / newWidth;
  56336. }
  56337. if (heightScale > 2 && paintHeight > 1) {
  56338. newHeight = Math.ceil(paintHeight / 2);
  56339. heightScale /= paintHeight / newHeight;
  56340. }
  56341. tmpCanvas = this.cachedCanvases.getCanvas(tmpCanvasId, newWidth, newHeight);
  56342. tmpCtx = tmpCanvas.context;
  56343. tmpCtx.clearRect(0, 0, newWidth, newHeight);
  56344. tmpCtx.drawImage(imgToPaint, 0, 0, paintWidth, paintHeight, 0, 0, newWidth, newHeight);
  56345. imgToPaint = tmpCanvas.canvas;
  56346. paintWidth = newWidth;
  56347. paintHeight = newHeight;
  56348. tmpCanvasId = tmpCanvasId === 'prescale1' ? 'prescale2' : 'prescale1';
  56349. }
  56350. ctx.drawImage(imgToPaint, 0, 0, paintWidth, paintHeight, 0, -height, width, height);
  56351. if (this.imageLayer) {
  56352. var position = this.getCanvasPosition(0, -height);
  56353. this.imageLayer.appendImage({
  56354. imgData: imgData,
  56355. left: position[0],
  56356. top: position[1],
  56357. width: width / currentTransform[0],
  56358. height: height / currentTransform[3]
  56359. });
  56360. }
  56361. this.restore();
  56362. },
  56363. paintInlineImageXObjectGroup: function CanvasGraphics_paintInlineImageXObjectGroup(imgData, map) {
  56364. var ctx = this.ctx;
  56365. var w = imgData.width;
  56366. var h = imgData.height;
  56367. var tmpCanvas = this.cachedCanvases.getCanvas('inlineImage', w, h);
  56368. var tmpCtx = tmpCanvas.context;
  56369. putBinaryImageData(tmpCtx, imgData);
  56370. for (var i = 0, ii = map.length; i < ii; i++) {
  56371. var entry = map[i];
  56372. ctx.save();
  56373. ctx.transform.apply(ctx, entry.transform);
  56374. ctx.scale(1, -1);
  56375. ctx.drawImage(tmpCanvas.canvas, entry.x, entry.y, entry.w, entry.h, 0, -1, 1, 1);
  56376. if (this.imageLayer) {
  56377. var position = this.getCanvasPosition(entry.x, entry.y);
  56378. this.imageLayer.appendImage({
  56379. imgData: imgData,
  56380. left: position[0],
  56381. top: position[1],
  56382. width: w,
  56383. height: h
  56384. });
  56385. }
  56386. ctx.restore();
  56387. }
  56388. },
  56389. paintSolidColorImageMask: function CanvasGraphics_paintSolidColorImageMask() {
  56390. this.ctx.fillRect(0, 0, 1, 1);
  56391. },
  56392. paintXObject: function CanvasGraphics_paintXObject() {
  56393. warn('Unsupported \'paintXObject\' command.');
  56394. },
  56395. markPoint: function CanvasGraphics_markPoint(tag) {
  56396. },
  56397. markPointProps: function CanvasGraphics_markPointProps(tag, properties) {
  56398. },
  56399. beginMarkedContent: function CanvasGraphics_beginMarkedContent(tag) {
  56400. },
  56401. beginMarkedContentProps: function CanvasGraphics_beginMarkedContentProps(tag, properties) {
  56402. },
  56403. endMarkedContent: function CanvasGraphics_endMarkedContent() {
  56404. },
  56405. beginCompat: function CanvasGraphics_beginCompat() {
  56406. },
  56407. endCompat: function CanvasGraphics_endCompat() {
  56408. },
  56409. consumePath: function CanvasGraphics_consumePath() {
  56410. var ctx = this.ctx;
  56411. if (this.pendingClip) {
  56412. if (this.pendingClip === EO_CLIP) {
  56413. ctx.clip('evenodd');
  56414. } else {
  56415. ctx.clip();
  56416. }
  56417. this.pendingClip = null;
  56418. }
  56419. ctx.beginPath();
  56420. },
  56421. getSinglePixelWidth: function CanvasGraphics_getSinglePixelWidth(scale) {
  56422. if (this.cachedGetSinglePixelWidth === null) {
  56423. this.ctx.save();
  56424. var inverse = this.ctx.mozCurrentTransformInverse;
  56425. this.ctx.restore();
  56426. this.cachedGetSinglePixelWidth = Math.sqrt(Math.max(inverse[0] * inverse[0] + inverse[1] * inverse[1], inverse[2] * inverse[2] + inverse[3] * inverse[3]));
  56427. }
  56428. return this.cachedGetSinglePixelWidth;
  56429. },
  56430. getCanvasPosition: function CanvasGraphics_getCanvasPosition(x, y) {
  56431. var transform = this.ctx.mozCurrentTransform;
  56432. return [
  56433. transform[0] * x + transform[2] * y + transform[4],
  56434. transform[1] * x + transform[3] * y + transform[5]
  56435. ];
  56436. }
  56437. };
  56438. for (var op in OPS) {
  56439. CanvasGraphics.prototype[OPS[op]] = CanvasGraphics.prototype[op];
  56440. }
  56441. return CanvasGraphics;
  56442. }();
  56443. exports.CanvasGraphics = CanvasGraphics;
  56444. /***/ }),
  56445. /* 46 */
  56446. /***/ (function(module, exports, __w_pdfjs_require__) {
  56447. "use strict";
  56448. var sharedUtil = __w_pdfjs_require__(0);
  56449. var assert = sharedUtil.assert;
  56450. var bytesToString = sharedUtil.bytesToString;
  56451. var string32 = sharedUtil.string32;
  56452. var shadow = sharedUtil.shadow;
  56453. var warn = sharedUtil.warn;
  56454. function FontLoader(docId) {
  56455. this.docId = docId;
  56456. this.styleElement = null;
  56457. this.nativeFontFaces = [];
  56458. this.loadTestFontId = 0;
  56459. this.loadingContext = {
  56460. requests: [],
  56461. nextRequestId: 0
  56462. };
  56463. }
  56464. FontLoader.prototype = {
  56465. insertRule: function fontLoaderInsertRule(rule) {
  56466. var styleElement = this.styleElement;
  56467. if (!styleElement) {
  56468. styleElement = this.styleElement = document.createElement('style');
  56469. styleElement.id = 'PDFJS_FONT_STYLE_TAG_' + this.docId;
  56470. document.documentElement.getElementsByTagName('head')[0].appendChild(styleElement);
  56471. }
  56472. var styleSheet = styleElement.sheet;
  56473. styleSheet.insertRule(rule, styleSheet.cssRules.length);
  56474. },
  56475. clear: function fontLoaderClear() {
  56476. var styleElement = this.styleElement;
  56477. if (styleElement) {
  56478. if (styleElement.parentNode) {
  56479. styleElement.parentNode.removeChild(styleElement);
  56480. }
  56481. styleElement = this.styleElement = null;
  56482. }
  56483. this.nativeFontFaces.forEach(function (nativeFontFace) {
  56484. document.fonts.delete(nativeFontFace);
  56485. });
  56486. this.nativeFontFaces.length = 0;
  56487. }
  56488. };
  56489. var getLoadTestFont = function () {
  56490. 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==');
  56491. };
  56492. Object.defineProperty(FontLoader.prototype, 'loadTestFont', {
  56493. get: function () {
  56494. return shadow(this, 'loadTestFont', getLoadTestFont());
  56495. },
  56496. configurable: true
  56497. });
  56498. FontLoader.prototype.addNativeFontFace = function fontLoader_addNativeFontFace(nativeFontFace) {
  56499. this.nativeFontFaces.push(nativeFontFace);
  56500. document.fonts.add(nativeFontFace);
  56501. };
  56502. FontLoader.prototype.bind = function fontLoaderBind(fonts, callback) {
  56503. var rules = [];
  56504. var fontsToLoad = [];
  56505. var fontLoadPromises = [];
  56506. var getNativeFontPromise = function (nativeFontFace) {
  56507. return nativeFontFace.loaded.catch(function (e) {
  56508. warn('Failed to load font "' + nativeFontFace.family + '": ' + e);
  56509. });
  56510. };
  56511. var isFontLoadingAPISupported = FontLoader.isFontLoadingAPISupported && !FontLoader.isSyncFontLoadingSupported;
  56512. for (var i = 0, ii = fonts.length; i < ii; i++) {
  56513. var font = fonts[i];
  56514. if (font.attached || font.loading === false) {
  56515. continue;
  56516. }
  56517. font.attached = true;
  56518. if (isFontLoadingAPISupported) {
  56519. var nativeFontFace = font.createNativeFontFace();
  56520. if (nativeFontFace) {
  56521. this.addNativeFontFace(nativeFontFace);
  56522. fontLoadPromises.push(getNativeFontPromise(nativeFontFace));
  56523. }
  56524. } else {
  56525. var rule = font.createFontFaceRule();
  56526. if (rule) {
  56527. this.insertRule(rule);
  56528. rules.push(rule);
  56529. fontsToLoad.push(font);
  56530. }
  56531. }
  56532. }
  56533. var request = this.queueLoadingCallback(callback);
  56534. if (isFontLoadingAPISupported) {
  56535. Promise.all(fontLoadPromises).then(function () {
  56536. request.complete();
  56537. });
  56538. } else if (rules.length > 0 && !FontLoader.isSyncFontLoadingSupported) {
  56539. this.prepareFontLoadEvent(rules, fontsToLoad, request);
  56540. } else {
  56541. request.complete();
  56542. }
  56543. };
  56544. FontLoader.prototype.queueLoadingCallback = function FontLoader_queueLoadingCallback(callback) {
  56545. function LoadLoader_completeRequest() {
  56546. assert(!request.end, 'completeRequest() cannot be called twice');
  56547. request.end = Date.now();
  56548. while (context.requests.length > 0 && context.requests[0].end) {
  56549. var otherRequest = context.requests.shift();
  56550. setTimeout(otherRequest.callback, 0);
  56551. }
  56552. }
  56553. var context = this.loadingContext;
  56554. var requestId = 'pdfjs-font-loading-' + context.nextRequestId++;
  56555. var request = {
  56556. id: requestId,
  56557. complete: LoadLoader_completeRequest,
  56558. callback: callback,
  56559. started: Date.now()
  56560. };
  56561. context.requests.push(request);
  56562. return request;
  56563. };
  56564. FontLoader.prototype.prepareFontLoadEvent = function fontLoaderPrepareFontLoadEvent(rules, fonts, request) {
  56565. function int32(data, offset) {
  56566. return data.charCodeAt(offset) << 24 | data.charCodeAt(offset + 1) << 16 | data.charCodeAt(offset + 2) << 8 | data.charCodeAt(offset + 3) & 0xff;
  56567. }
  56568. function spliceString(s, offset, remove, insert) {
  56569. var chunk1 = s.substr(0, offset);
  56570. var chunk2 = s.substr(offset + remove);
  56571. return chunk1 + insert + chunk2;
  56572. }
  56573. var i, ii;
  56574. var canvas = document.createElement('canvas');
  56575. canvas.width = 1;
  56576. canvas.height = 1;
  56577. var ctx = canvas.getContext('2d');
  56578. var called = 0;
  56579. function isFontReady(name, callback) {
  56580. called++;
  56581. if (called > 30) {
  56582. warn('Load test font never loaded.');
  56583. callback();
  56584. return;
  56585. }
  56586. ctx.font = '30px ' + name;
  56587. ctx.fillText('.', 0, 20);
  56588. var imageData = ctx.getImageData(0, 0, 1, 1);
  56589. if (imageData.data[3] > 0) {
  56590. callback();
  56591. return;
  56592. }
  56593. setTimeout(isFontReady.bind(null, name, callback));
  56594. }
  56595. var loadTestFontId = 'lt' + Date.now() + this.loadTestFontId++;
  56596. var data = this.loadTestFont;
  56597. var COMMENT_OFFSET = 976;
  56598. data = spliceString(data, COMMENT_OFFSET, loadTestFontId.length, loadTestFontId);
  56599. var CFF_CHECKSUM_OFFSET = 16;
  56600. var XXXX_VALUE = 0x58585858;
  56601. var checksum = int32(data, CFF_CHECKSUM_OFFSET);
  56602. for (i = 0, ii = loadTestFontId.length - 3; i < ii; i += 4) {
  56603. checksum = checksum - XXXX_VALUE + int32(loadTestFontId, i) | 0;
  56604. }
  56605. if (i < loadTestFontId.length) {
  56606. checksum = checksum - XXXX_VALUE + int32(loadTestFontId + 'XXX', i) | 0;
  56607. }
  56608. data = spliceString(data, CFF_CHECKSUM_OFFSET, 4, string32(checksum));
  56609. var url = 'url(data:font/opentype;base64,' + btoa(data) + ');';
  56610. var rule = '@font-face { font-family:"' + loadTestFontId + '";src:' + url + '}';
  56611. this.insertRule(rule);
  56612. var names = [];
  56613. for (i = 0, ii = fonts.length; i < ii; i++) {
  56614. names.push(fonts[i].loadedName);
  56615. }
  56616. names.push(loadTestFontId);
  56617. var div = document.createElement('div');
  56618. div.setAttribute('style', 'visibility: hidden;' + 'width: 10px; height: 10px;' + 'position: absolute; top: 0px; left: 0px;');
  56619. for (i = 0, ii = names.length; i < ii; ++i) {
  56620. var span = document.createElement('span');
  56621. span.textContent = 'Hi';
  56622. span.style.fontFamily = names[i];
  56623. div.appendChild(span);
  56624. }
  56625. document.body.appendChild(div);
  56626. isFontReady(loadTestFontId, function () {
  56627. document.body.removeChild(div);
  56628. request.complete();
  56629. });
  56630. };
  56631. FontLoader.isFontLoadingAPISupported = typeof document !== 'undefined' && !!document.fonts;
  56632. var isSyncFontLoadingSupported = function isSyncFontLoadingSupported() {
  56633. if (typeof navigator === 'undefined') {
  56634. return true;
  56635. }
  56636. var supported = false;
  56637. var m = /Mozilla\/5.0.*?rv:(\d+).*? Gecko/.exec(navigator.userAgent);
  56638. if (m && m[1] >= 14) {
  56639. supported = true;
  56640. }
  56641. return supported;
  56642. };
  56643. Object.defineProperty(FontLoader, 'isSyncFontLoadingSupported', {
  56644. get: function () {
  56645. return shadow(FontLoader, 'isSyncFontLoadingSupported', isSyncFontLoadingSupported());
  56646. },
  56647. enumerable: true,
  56648. configurable: true
  56649. });
  56650. var IsEvalSupportedCached = {
  56651. get value() {
  56652. return shadow(this, 'value', sharedUtil.isEvalSupported());
  56653. }
  56654. };
  56655. var FontFaceObject = function FontFaceObjectClosure() {
  56656. function FontFaceObject(translatedData, options) {
  56657. this.compiledGlyphs = Object.create(null);
  56658. for (var i in translatedData) {
  56659. this[i] = translatedData[i];
  56660. }
  56661. this.options = options;
  56662. }
  56663. FontFaceObject.prototype = {
  56664. createNativeFontFace: function FontFaceObject_createNativeFontFace() {
  56665. if (!this.data) {
  56666. return null;
  56667. }
  56668. if (this.options.disableFontFace) {
  56669. this.disableFontFace = true;
  56670. return null;
  56671. }
  56672. var nativeFontFace = new FontFace(this.loadedName, this.data, {});
  56673. if (this.options.fontRegistry) {
  56674. this.options.fontRegistry.registerFont(this);
  56675. }
  56676. return nativeFontFace;
  56677. },
  56678. createFontFaceRule: function FontFaceObject_createFontFaceRule() {
  56679. if (!this.data) {
  56680. return null;
  56681. }
  56682. if (this.options.disableFontFace) {
  56683. this.disableFontFace = true;
  56684. return null;
  56685. }
  56686. var data = bytesToString(new Uint8Array(this.data));
  56687. var fontName = this.loadedName;
  56688. var url = 'url(data:' + this.mimetype + ';base64,' + btoa(data) + ');';
  56689. var rule = '@font-face { font-family:"' + fontName + '";src:' + url + '}';
  56690. if (this.options.fontRegistry) {
  56691. this.options.fontRegistry.registerFont(this, url);
  56692. }
  56693. return rule;
  56694. },
  56695. getPathGenerator: function FontFaceObject_getPathGenerator(objs, character) {
  56696. if (!(character in this.compiledGlyphs)) {
  56697. var cmds = objs.get(this.loadedName + '_path_' + character);
  56698. var current, i, len;
  56699. if (this.options.isEvalSupported && IsEvalSupportedCached.value) {
  56700. var args, js = '';
  56701. for (i = 0, len = cmds.length; i < len; i++) {
  56702. current = cmds[i];
  56703. if (current.args !== undefined) {
  56704. args = current.args.join(',');
  56705. } else {
  56706. args = '';
  56707. }
  56708. js += 'c.' + current.cmd + '(' + args + ');\n';
  56709. }
  56710. this.compiledGlyphs[character] = new Function('c', 'size', js);
  56711. } else {
  56712. this.compiledGlyphs[character] = function (c, size) {
  56713. for (i = 0, len = cmds.length; i < len; i++) {
  56714. current = cmds[i];
  56715. if (current.cmd === 'scale') {
  56716. current.args = [
  56717. size,
  56718. -size
  56719. ];
  56720. }
  56721. c[current.cmd].apply(c, current.args);
  56722. }
  56723. };
  56724. }
  56725. }
  56726. return this.compiledGlyphs[character];
  56727. }
  56728. };
  56729. return FontFaceObject;
  56730. }();
  56731. exports.FontFaceObject = FontFaceObject;
  56732. exports.FontLoader = FontLoader;
  56733. /***/ }),
  56734. /* 47 */
  56735. /***/ (function(module, exports, __w_pdfjs_require__) {
  56736. "use strict";
  56737. var sharedUtil = __w_pdfjs_require__(0);
  56738. var displayWebGL = __w_pdfjs_require__(24);
  56739. var Util = sharedUtil.Util;
  56740. var info = sharedUtil.info;
  56741. var isArray = sharedUtil.isArray;
  56742. var error = sharedUtil.error;
  56743. var WebGLUtils = displayWebGL.WebGLUtils;
  56744. var ShadingIRs = {};
  56745. ShadingIRs.RadialAxial = {
  56746. fromIR: function RadialAxial_fromIR(raw) {
  56747. var type = raw[1];
  56748. var colorStops = raw[2];
  56749. var p0 = raw[3];
  56750. var p1 = raw[4];
  56751. var r0 = raw[5];
  56752. var r1 = raw[6];
  56753. return {
  56754. type: 'Pattern',
  56755. getPattern: function RadialAxial_getPattern(ctx) {
  56756. var grad;
  56757. if (type === 'axial') {
  56758. grad = ctx.createLinearGradient(p0[0], p0[1], p1[0], p1[1]);
  56759. } else if (type === 'radial') {
  56760. grad = ctx.createRadialGradient(p0[0], p0[1], r0, p1[0], p1[1], r1);
  56761. }
  56762. for (var i = 0, ii = colorStops.length; i < ii; ++i) {
  56763. var c = colorStops[i];
  56764. grad.addColorStop(c[0], c[1]);
  56765. }
  56766. return grad;
  56767. }
  56768. };
  56769. }
  56770. };
  56771. var createMeshCanvas = function createMeshCanvasClosure() {
  56772. function drawTriangle(data, context, p1, p2, p3, c1, c2, c3) {
  56773. var coords = context.coords, colors = context.colors;
  56774. var bytes = data.data, rowSize = data.width * 4;
  56775. var tmp;
  56776. if (coords[p1 + 1] > coords[p2 + 1]) {
  56777. tmp = p1;
  56778. p1 = p2;
  56779. p2 = tmp;
  56780. tmp = c1;
  56781. c1 = c2;
  56782. c2 = tmp;
  56783. }
  56784. if (coords[p2 + 1] > coords[p3 + 1]) {
  56785. tmp = p2;
  56786. p2 = p3;
  56787. p3 = tmp;
  56788. tmp = c2;
  56789. c2 = c3;
  56790. c3 = tmp;
  56791. }
  56792. if (coords[p1 + 1] > coords[p2 + 1]) {
  56793. tmp = p1;
  56794. p1 = p2;
  56795. p2 = tmp;
  56796. tmp = c1;
  56797. c1 = c2;
  56798. c2 = tmp;
  56799. }
  56800. var x1 = (coords[p1] + context.offsetX) * context.scaleX;
  56801. var y1 = (coords[p1 + 1] + context.offsetY) * context.scaleY;
  56802. var x2 = (coords[p2] + context.offsetX) * context.scaleX;
  56803. var y2 = (coords[p2 + 1] + context.offsetY) * context.scaleY;
  56804. var x3 = (coords[p3] + context.offsetX) * context.scaleX;
  56805. var y3 = (coords[p3 + 1] + context.offsetY) * context.scaleY;
  56806. if (y1 >= y3) {
  56807. return;
  56808. }
  56809. var c1r = colors[c1], c1g = colors[c1 + 1], c1b = colors[c1 + 2];
  56810. var c2r = colors[c2], c2g = colors[c2 + 1], c2b = colors[c2 + 2];
  56811. var c3r = colors[c3], c3g = colors[c3 + 1], c3b = colors[c3 + 2];
  56812. var minY = Math.round(y1), maxY = Math.round(y3);
  56813. var xa, car, cag, cab;
  56814. var xb, cbr, cbg, cbb;
  56815. var k;
  56816. for (var y = minY; y <= maxY; y++) {
  56817. if (y < y2) {
  56818. k = y < y1 ? 0 : y1 === y2 ? 1 : (y1 - y) / (y1 - y2);
  56819. xa = x1 - (x1 - x2) * k;
  56820. car = c1r - (c1r - c2r) * k;
  56821. cag = c1g - (c1g - c2g) * k;
  56822. cab = c1b - (c1b - c2b) * k;
  56823. } else {
  56824. k = y > y3 ? 1 : y2 === y3 ? 0 : (y2 - y) / (y2 - y3);
  56825. xa = x2 - (x2 - x3) * k;
  56826. car = c2r - (c2r - c3r) * k;
  56827. cag = c2g - (c2g - c3g) * k;
  56828. cab = c2b - (c2b - c3b) * k;
  56829. }
  56830. k = y < y1 ? 0 : y > y3 ? 1 : (y1 - y) / (y1 - y3);
  56831. xb = x1 - (x1 - x3) * k;
  56832. cbr = c1r - (c1r - c3r) * k;
  56833. cbg = c1g - (c1g - c3g) * k;
  56834. cbb = c1b - (c1b - c3b) * k;
  56835. var x1_ = Math.round(Math.min(xa, xb));
  56836. var x2_ = Math.round(Math.max(xa, xb));
  56837. var j = rowSize * y + x1_ * 4;
  56838. for (var x = x1_; x <= x2_; x++) {
  56839. k = (xa - x) / (xa - xb);
  56840. k = k < 0 ? 0 : k > 1 ? 1 : k;
  56841. bytes[j++] = car - (car - cbr) * k | 0;
  56842. bytes[j++] = cag - (cag - cbg) * k | 0;
  56843. bytes[j++] = cab - (cab - cbb) * k | 0;
  56844. bytes[j++] = 255;
  56845. }
  56846. }
  56847. }
  56848. function drawFigure(data, figure, context) {
  56849. var ps = figure.coords;
  56850. var cs = figure.colors;
  56851. var i, ii;
  56852. switch (figure.type) {
  56853. case 'lattice':
  56854. var verticesPerRow = figure.verticesPerRow;
  56855. var rows = Math.floor(ps.length / verticesPerRow) - 1;
  56856. var cols = verticesPerRow - 1;
  56857. for (i = 0; i < rows; i++) {
  56858. var q = i * verticesPerRow;
  56859. for (var j = 0; j < cols; j++, q++) {
  56860. drawTriangle(data, context, ps[q], ps[q + 1], ps[q + verticesPerRow], cs[q], cs[q + 1], cs[q + verticesPerRow]);
  56861. drawTriangle(data, context, ps[q + verticesPerRow + 1], ps[q + 1], ps[q + verticesPerRow], cs[q + verticesPerRow + 1], cs[q + 1], cs[q + verticesPerRow]);
  56862. }
  56863. }
  56864. break;
  56865. case 'triangles':
  56866. for (i = 0, ii = ps.length; i < ii; i += 3) {
  56867. drawTriangle(data, context, ps[i], ps[i + 1], ps[i + 2], cs[i], cs[i + 1], cs[i + 2]);
  56868. }
  56869. break;
  56870. default:
  56871. error('illigal figure');
  56872. break;
  56873. }
  56874. }
  56875. function createMeshCanvas(bounds, combinesScale, coords, colors, figures, backgroundColor, cachedCanvases) {
  56876. var EXPECTED_SCALE = 1.1;
  56877. var MAX_PATTERN_SIZE = 3000;
  56878. var BORDER_SIZE = 2;
  56879. var offsetX = Math.floor(bounds[0]);
  56880. var offsetY = Math.floor(bounds[1]);
  56881. var boundsWidth = Math.ceil(bounds[2]) - offsetX;
  56882. var boundsHeight = Math.ceil(bounds[3]) - offsetY;
  56883. var width = Math.min(Math.ceil(Math.abs(boundsWidth * combinesScale[0] * EXPECTED_SCALE)), MAX_PATTERN_SIZE);
  56884. var height = Math.min(Math.ceil(Math.abs(boundsHeight * combinesScale[1] * EXPECTED_SCALE)), MAX_PATTERN_SIZE);
  56885. var scaleX = boundsWidth / width;
  56886. var scaleY = boundsHeight / height;
  56887. var context = {
  56888. coords: coords,
  56889. colors: colors,
  56890. offsetX: -offsetX,
  56891. offsetY: -offsetY,
  56892. scaleX: 1 / scaleX,
  56893. scaleY: 1 / scaleY
  56894. };
  56895. var paddedWidth = width + BORDER_SIZE * 2;
  56896. var paddedHeight = height + BORDER_SIZE * 2;
  56897. var canvas, tmpCanvas, i, ii;
  56898. if (WebGLUtils.isEnabled) {
  56899. canvas = WebGLUtils.drawFigures(width, height, backgroundColor, figures, context);
  56900. tmpCanvas = cachedCanvases.getCanvas('mesh', paddedWidth, paddedHeight, false);
  56901. tmpCanvas.context.drawImage(canvas, BORDER_SIZE, BORDER_SIZE);
  56902. canvas = tmpCanvas.canvas;
  56903. } else {
  56904. tmpCanvas = cachedCanvases.getCanvas('mesh', paddedWidth, paddedHeight, false);
  56905. var tmpCtx = tmpCanvas.context;
  56906. var data = tmpCtx.createImageData(width, height);
  56907. if (backgroundColor) {
  56908. var bytes = data.data;
  56909. for (i = 0, ii = bytes.length; i < ii; i += 4) {
  56910. bytes[i] = backgroundColor[0];
  56911. bytes[i + 1] = backgroundColor[1];
  56912. bytes[i + 2] = backgroundColor[2];
  56913. bytes[i + 3] = 255;
  56914. }
  56915. }
  56916. for (i = 0; i < figures.length; i++) {
  56917. drawFigure(data, figures[i], context);
  56918. }
  56919. tmpCtx.putImageData(data, BORDER_SIZE, BORDER_SIZE);
  56920. canvas = tmpCanvas.canvas;
  56921. }
  56922. return {
  56923. canvas: canvas,
  56924. offsetX: offsetX - BORDER_SIZE * scaleX,
  56925. offsetY: offsetY - BORDER_SIZE * scaleY,
  56926. scaleX: scaleX,
  56927. scaleY: scaleY
  56928. };
  56929. }
  56930. return createMeshCanvas;
  56931. }();
  56932. ShadingIRs.Mesh = {
  56933. fromIR: function Mesh_fromIR(raw) {
  56934. var coords = raw[2];
  56935. var colors = raw[3];
  56936. var figures = raw[4];
  56937. var bounds = raw[5];
  56938. var matrix = raw[6];
  56939. var background = raw[8];
  56940. return {
  56941. type: 'Pattern',
  56942. getPattern: function Mesh_getPattern(ctx, owner, shadingFill) {
  56943. var scale;
  56944. if (shadingFill) {
  56945. scale = Util.singularValueDecompose2dScale(ctx.mozCurrentTransform);
  56946. } else {
  56947. scale = Util.singularValueDecompose2dScale(owner.baseTransform);
  56948. if (matrix) {
  56949. var matrixScale = Util.singularValueDecompose2dScale(matrix);
  56950. scale = [
  56951. scale[0] * matrixScale[0],
  56952. scale[1] * matrixScale[1]
  56953. ];
  56954. }
  56955. }
  56956. var temporaryPatternCanvas = createMeshCanvas(bounds, scale, coords, colors, figures, shadingFill ? null : background, owner.cachedCanvases);
  56957. if (!shadingFill) {
  56958. ctx.setTransform.apply(ctx, owner.baseTransform);
  56959. if (matrix) {
  56960. ctx.transform.apply(ctx, matrix);
  56961. }
  56962. }
  56963. ctx.translate(temporaryPatternCanvas.offsetX, temporaryPatternCanvas.offsetY);
  56964. ctx.scale(temporaryPatternCanvas.scaleX, temporaryPatternCanvas.scaleY);
  56965. return ctx.createPattern(temporaryPatternCanvas.canvas, 'no-repeat');
  56966. }
  56967. };
  56968. }
  56969. };
  56970. ShadingIRs.Dummy = {
  56971. fromIR: function Dummy_fromIR() {
  56972. return {
  56973. type: 'Pattern',
  56974. getPattern: function Dummy_fromIR_getPattern() {
  56975. return 'hotpink';
  56976. }
  56977. };
  56978. }
  56979. };
  56980. function getShadingPatternFromIR(raw) {
  56981. var shadingIR = ShadingIRs[raw[0]];
  56982. if (!shadingIR) {
  56983. error('Unknown IR type: ' + raw[0]);
  56984. }
  56985. return shadingIR.fromIR(raw);
  56986. }
  56987. var TilingPattern = function TilingPatternClosure() {
  56988. var PaintType = {
  56989. COLORED: 1,
  56990. UNCOLORED: 2
  56991. };
  56992. var MAX_PATTERN_SIZE = 3000;
  56993. function TilingPattern(IR, color, ctx, canvasGraphicsFactory, baseTransform) {
  56994. this.operatorList = IR[2];
  56995. this.matrix = IR[3] || [
  56996. 1,
  56997. 0,
  56998. 0,
  56999. 1,
  57000. 0,
  57001. 0
  57002. ];
  57003. this.bbox = IR[4];
  57004. this.xstep = IR[5];
  57005. this.ystep = IR[6];
  57006. this.paintType = IR[7];
  57007. this.tilingType = IR[8];
  57008. this.color = color;
  57009. this.canvasGraphicsFactory = canvasGraphicsFactory;
  57010. this.baseTransform = baseTransform;
  57011. this.type = 'Pattern';
  57012. this.ctx = ctx;
  57013. }
  57014. TilingPattern.prototype = {
  57015. createPatternCanvas: function TilinPattern_createPatternCanvas(owner) {
  57016. var operatorList = this.operatorList;
  57017. var bbox = this.bbox;
  57018. var xstep = this.xstep;
  57019. var ystep = this.ystep;
  57020. var paintType = this.paintType;
  57021. var tilingType = this.tilingType;
  57022. var color = this.color;
  57023. var canvasGraphicsFactory = this.canvasGraphicsFactory;
  57024. info('TilingType: ' + tilingType);
  57025. var x0 = bbox[0], y0 = bbox[1], x1 = bbox[2], y1 = bbox[3];
  57026. var topLeft = [
  57027. x0,
  57028. y0
  57029. ];
  57030. var botRight = [
  57031. x0 + xstep,
  57032. y0 + ystep
  57033. ];
  57034. var width = botRight[0] - topLeft[0];
  57035. var height = botRight[1] - topLeft[1];
  57036. var matrixScale = Util.singularValueDecompose2dScale(this.matrix);
  57037. var curMatrixScale = Util.singularValueDecompose2dScale(this.baseTransform);
  57038. var combinedScale = [
  57039. matrixScale[0] * curMatrixScale[0],
  57040. matrixScale[1] * curMatrixScale[1]
  57041. ];
  57042. width = Math.min(Math.ceil(Math.abs(width * combinedScale[0])), MAX_PATTERN_SIZE);
  57043. height = Math.min(Math.ceil(Math.abs(height * combinedScale[1])), MAX_PATTERN_SIZE);
  57044. var tmpCanvas = owner.cachedCanvases.getCanvas('pattern', width, height, true);
  57045. var tmpCtx = tmpCanvas.context;
  57046. var graphics = canvasGraphicsFactory.createCanvasGraphics(tmpCtx);
  57047. graphics.groupLevel = owner.groupLevel;
  57048. this.setFillAndStrokeStyleToContext(tmpCtx, paintType, color);
  57049. this.setScale(width, height, xstep, ystep);
  57050. this.transformToScale(graphics);
  57051. var tmpTranslate = [
  57052. 1,
  57053. 0,
  57054. 0,
  57055. 1,
  57056. -topLeft[0],
  57057. -topLeft[1]
  57058. ];
  57059. graphics.transform.apply(graphics, tmpTranslate);
  57060. this.clipBbox(graphics, bbox, x0, y0, x1, y1);
  57061. graphics.executeOperatorList(operatorList);
  57062. return tmpCanvas.canvas;
  57063. },
  57064. setScale: function TilingPattern_setScale(width, height, xstep, ystep) {
  57065. this.scale = [
  57066. width / xstep,
  57067. height / ystep
  57068. ];
  57069. },
  57070. transformToScale: function TilingPattern_transformToScale(graphics) {
  57071. var scale = this.scale;
  57072. var tmpScale = [
  57073. scale[0],
  57074. 0,
  57075. 0,
  57076. scale[1],
  57077. 0,
  57078. 0
  57079. ];
  57080. graphics.transform.apply(graphics, tmpScale);
  57081. },
  57082. scaleToContext: function TilingPattern_scaleToContext() {
  57083. var scale = this.scale;
  57084. this.ctx.scale(1 / scale[0], 1 / scale[1]);
  57085. },
  57086. clipBbox: function clipBbox(graphics, bbox, x0, y0, x1, y1) {
  57087. if (bbox && isArray(bbox) && bbox.length === 4) {
  57088. var bboxWidth = x1 - x0;
  57089. var bboxHeight = y1 - y0;
  57090. graphics.ctx.rect(x0, y0, bboxWidth, bboxHeight);
  57091. graphics.clip();
  57092. graphics.endPath();
  57093. }
  57094. },
  57095. setFillAndStrokeStyleToContext: function setFillAndStrokeStyleToContext(context, paintType, color) {
  57096. switch (paintType) {
  57097. case PaintType.COLORED:
  57098. var ctx = this.ctx;
  57099. context.fillStyle = ctx.fillStyle;
  57100. context.strokeStyle = ctx.strokeStyle;
  57101. break;
  57102. case PaintType.UNCOLORED:
  57103. var cssColor = Util.makeCssRgb(color[0], color[1], color[2]);
  57104. context.fillStyle = cssColor;
  57105. context.strokeStyle = cssColor;
  57106. break;
  57107. default:
  57108. error('Unsupported paint type: ' + paintType);
  57109. }
  57110. },
  57111. getPattern: function TilingPattern_getPattern(ctx, owner) {
  57112. var temporaryPatternCanvas = this.createPatternCanvas(owner);
  57113. ctx = this.ctx;
  57114. ctx.setTransform.apply(ctx, this.baseTransform);
  57115. ctx.transform.apply(ctx, this.matrix);
  57116. this.scaleToContext();
  57117. return ctx.createPattern(temporaryPatternCanvas, 'repeat');
  57118. }
  57119. };
  57120. return TilingPattern;
  57121. }();
  57122. exports.getShadingPatternFromIR = getShadingPatternFromIR;
  57123. exports.TilingPattern = TilingPattern;
  57124. /***/ }),
  57125. /* 48 */
  57126. /***/ (function(module, exports, __w_pdfjs_require__) {
  57127. "use strict";
  57128. var pdfjsVersion = '1.7.276';
  57129. var pdfjsBuild = 'ba81b37b';
  57130. var pdfjsSharedUtil = __w_pdfjs_require__(0);
  57131. var pdfjsDisplayGlobal = __w_pdfjs_require__(26);
  57132. var pdfjsDisplayAPI = __w_pdfjs_require__(11);
  57133. var pdfjsDisplayTextLayer = __w_pdfjs_require__(13);
  57134. var pdfjsDisplayAnnotationLayer = __w_pdfjs_require__(10);
  57135. var pdfjsDisplayDOMUtils = __w_pdfjs_require__(3);
  57136. var pdfjsDisplaySVG = __w_pdfjs_require__(12);
  57137. {
  57138. __w_pdfjs_require__(9);
  57139. __w_pdfjs_require__(25);
  57140. }
  57141. exports.PDFJS = pdfjsDisplayGlobal.PDFJS;
  57142. exports.build = pdfjsDisplayAPI.build;
  57143. exports.version = pdfjsDisplayAPI.version;
  57144. exports.getDocument = pdfjsDisplayAPI.getDocument;
  57145. exports.PDFDataRangeTransport = pdfjsDisplayAPI.PDFDataRangeTransport;
  57146. exports.PDFWorker = pdfjsDisplayAPI.PDFWorker;
  57147. exports.renderTextLayer = pdfjsDisplayTextLayer.renderTextLayer;
  57148. exports.AnnotationLayer = pdfjsDisplayAnnotationLayer.AnnotationLayer;
  57149. exports.CustomStyle = pdfjsDisplayDOMUtils.CustomStyle;
  57150. exports.createPromiseCapability = pdfjsSharedUtil.createPromiseCapability;
  57151. exports.PasswordResponses = pdfjsSharedUtil.PasswordResponses;
  57152. exports.InvalidPDFException = pdfjsSharedUtil.InvalidPDFException;
  57153. exports.MissingPDFException = pdfjsSharedUtil.MissingPDFException;
  57154. exports.SVGGraphics = pdfjsDisplaySVG.SVGGraphics;
  57155. exports.UnexpectedResponseException = pdfjsSharedUtil.UnexpectedResponseException;
  57156. exports.OPS = pdfjsSharedUtil.OPS;
  57157. exports.UNSUPPORTED_FEATURES = pdfjsSharedUtil.UNSUPPORTED_FEATURES;
  57158. exports.isValidUrl = pdfjsDisplayDOMUtils.isValidUrl;
  57159. exports.createValidAbsoluteUrl = pdfjsSharedUtil.createValidAbsoluteUrl;
  57160. exports.createObjectURL = pdfjsSharedUtil.createObjectURL;
  57161. exports.removeNullCharacters = pdfjsSharedUtil.removeNullCharacters;
  57162. exports.shadow = pdfjsSharedUtil.shadow;
  57163. exports.createBlob = pdfjsSharedUtil.createBlob;
  57164. exports.getFilenameFromUrl = pdfjsDisplayDOMUtils.getFilenameFromUrl;
  57165. exports.addLinkAttributes = pdfjsDisplayDOMUtils.addLinkAttributes;
  57166. /***/ })
  57167. /******/ ]);
  57168. });