pdf.combined.js 1.3 MB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180818181828183818481858186818781888189819081918192819381948195819681978198819982008201820282038204820582068207820882098210821182128213821482158216821782188219822082218222822382248225822682278228822982308231823282338234823582368237823882398240824182428243824482458246824782488249825082518252825382548255825682578258825982608261826282638264826582668267826882698270827182728273827482758276827782788279828082818282828382848285828682878288828982908291829282938294829582968297829882998300830183028303830483058306830783088309831083118312831383148315831683178318831983208321832283238324832583268327832883298330833183328333833483358336833783388339834083418342834383448345834683478348834983508351835283538354835583568357835883598360836183628363836483658366836783688369837083718372837383748375837683778378837983808381838283838384838583868387838883898390839183928393839483958396839783988399840084018402840384048405840684078408840984108411841284138414841584168417841884198420842184228423842484258426842784288429843084318432843384348435843684378438843984408441844284438444844584468447844884498450845184528453845484558456845784588459846084618462846384648465846684678468846984708471847284738474847584768477847884798480848184828483848484858486848784888489849084918492849384948495849684978498849985008501850285038504850585068507850885098510851185128513851485158516851785188519852085218522852385248525852685278528852985308531853285338534853585368537853885398540854185428543854485458546854785488549855085518552855385548555855685578558855985608561856285638564856585668567856885698570857185728573857485758576857785788579858085818582858385848585858685878588858985908591859285938594859585968597859885998600860186028603860486058606860786088609861086118612861386148615861686178618861986208621862286238624862586268627862886298630863186328633863486358636863786388639864086418642864386448645864686478648864986508651865286538654865586568657865886598660866186628663866486658666866786688669867086718672867386748675867686778678867986808681868286838684868586868687868886898690869186928693869486958696869786988699870087018702870387048705870687078708870987108711871287138714871587168717871887198720872187228723872487258726872787288729873087318732873387348735873687378738873987408741874287438744874587468747874887498750875187528753875487558756875787588759876087618762876387648765876687678768876987708771877287738774877587768777877887798780878187828783878487858786878787888789879087918792879387948795879687978798879988008801880288038804880588068807880888098810881188128813881488158816881788188819882088218822882388248825882688278828882988308831883288338834883588368837883888398840884188428843884488458846884788488849885088518852885388548855885688578858885988608861886288638864886588668867886888698870887188728873887488758876887788788879888088818882888388848885888688878888888988908891889288938894889588968897889888998900890189028903890489058906890789088909891089118912891389148915891689178918891989208921892289238924892589268927892889298930893189328933893489358936893789388939894089418942894389448945894689478948894989508951895289538954895589568957895889598960896189628963896489658966896789688969897089718972897389748975897689778978897989808981898289838984898589868987898889898990899189928993899489958996899789988999900090019002900390049005900690079008900990109011901290139014901590169017901890199020902190229023902490259026902790289029903090319032903390349035903690379038903990409041904290439044904590469047904890499050905190529053905490559056905790589059906090619062906390649065906690679068906990709071907290739074907590769077907890799080908190829083908490859086908790889089909090919092909390949095909690979098909991009101910291039104910591069107910891099110911191129113911491159116911791189119912091219122912391249125912691279128912991309131913291339134913591369137913891399140914191429143914491459146914791489149915091519152915391549155915691579158915991609161916291639164916591669167916891699170917191729173917491759176917791789179918091819182918391849185918691879188918991909191919291939194919591969197919891999200920192029203920492059206920792089209921092119212921392149215921692179218921992209221922292239224922592269227922892299230923192329233923492359236923792389239924092419242924392449245924692479248924992509251925292539254925592569257925892599260926192629263926492659266926792689269927092719272927392749275927692779278927992809281928292839284928592869287928892899290929192929293929492959296929792989299930093019302930393049305930693079308930993109311931293139314931593169317931893199320932193229323932493259326932793289329933093319332933393349335933693379338933993409341934293439344934593469347934893499350935193529353935493559356935793589359936093619362936393649365936693679368936993709371937293739374937593769377937893799380938193829383938493859386938793889389939093919392939393949395939693979398939994009401940294039404940594069407940894099410941194129413941494159416941794189419942094219422942394249425942694279428942994309431943294339434943594369437943894399440944194429443944494459446944794489449945094519452945394549455945694579458945994609461946294639464946594669467946894699470947194729473947494759476947794789479948094819482948394849485948694879488948994909491949294939494949594969497949894999500950195029503950495059506950795089509951095119512951395149515951695179518951995209521952295239524952595269527952895299530953195329533953495359536953795389539954095419542954395449545954695479548954995509551955295539554955595569557955895599560956195629563956495659566956795689569957095719572957395749575957695779578957995809581958295839584958595869587958895899590959195929593959495959596959795989599960096019602960396049605960696079608960996109611961296139614961596169617961896199620962196229623962496259626962796289629963096319632963396349635963696379638963996409641964296439644964596469647964896499650965196529653965496559656965796589659966096619662966396649665966696679668966996709671967296739674967596769677967896799680968196829683968496859686968796889689969096919692969396949695969696979698969997009701970297039704970597069707970897099710971197129713971497159716971797189719972097219722972397249725972697279728972997309731973297339734973597369737973897399740974197429743974497459746974797489749975097519752975397549755975697579758975997609761976297639764976597669767976897699770977197729773977497759776977797789779978097819782978397849785978697879788978997909791979297939794979597969797979897999800980198029803980498059806980798089809981098119812981398149815981698179818981998209821982298239824982598269827982898299830983198329833983498359836983798389839984098419842984398449845984698479848984998509851985298539854985598569857985898599860986198629863986498659866986798689869987098719872987398749875987698779878987998809881988298839884988598869887988898899890989198929893989498959896989798989899990099019902990399049905990699079908990999109911991299139914991599169917991899199920992199229923992499259926992799289929993099319932993399349935993699379938993999409941994299439944994599469947994899499950995199529953995499559956995799589959996099619962996399649965996699679968996999709971997299739974997599769977997899799980998199829983998499859986998799889989999099919992999399949995999699979998999910000100011000210003100041000510006100071000810009100101001110012100131001410015100161001710018100191002010021100221002310024100251002610027100281002910030100311003210033100341003510036100371003810039100401004110042100431004410045100461004710048100491005010051100521005310054100551005610057100581005910060100611006210063100641006510066100671006810069100701007110072100731007410075100761007710078100791008010081100821008310084100851008610087100881008910090100911009210093100941009510096100971009810099101001010110102101031010410105101061010710108101091011010111101121011310114101151011610117101181011910120101211012210123101241012510126101271012810129101301013110132101331013410135101361013710138101391014010141101421014310144101451014610147101481014910150101511015210153101541015510156101571015810159101601016110162101631016410165101661016710168101691017010171101721017310174101751017610177101781017910180101811018210183101841018510186101871018810189101901019110192101931019410195101961019710198101991020010201102021020310204102051020610207102081020910210102111021210213102141021510216102171021810219102201022110222102231022410225102261022710228102291023010231102321023310234102351023610237102381023910240102411024210243102441024510246102471024810249102501025110252102531025410255102561025710258102591026010261102621026310264102651026610267102681026910270102711027210273102741027510276102771027810279102801028110282102831028410285102861028710288102891029010291102921029310294102951029610297102981029910300103011030210303103041030510306103071030810309103101031110312103131031410315103161031710318103191032010321103221032310324103251032610327103281032910330103311033210333103341033510336103371033810339103401034110342103431034410345103461034710348103491035010351103521035310354103551035610357103581035910360103611036210363103641036510366103671036810369103701037110372103731037410375103761037710378103791038010381103821038310384103851038610387103881038910390103911039210393103941039510396103971039810399104001040110402104031040410405104061040710408104091041010411104121041310414104151041610417104181041910420104211042210423104241042510426104271042810429104301043110432104331043410435104361043710438104391044010441104421044310444104451044610447104481044910450104511045210453104541045510456104571045810459104601046110462104631046410465104661046710468104691047010471104721047310474104751047610477104781047910480104811048210483104841048510486104871048810489104901049110492104931049410495104961049710498104991050010501105021050310504105051050610507105081050910510105111051210513105141051510516105171051810519105201052110522105231052410525105261052710528105291053010531105321053310534105351053610537105381053910540105411054210543105441054510546105471054810549105501055110552105531055410555105561055710558105591056010561105621056310564105651056610567105681056910570105711057210573105741057510576105771057810579105801058110582105831058410585105861058710588105891059010591105921059310594105951059610597105981059910600106011060210603106041060510606106071060810609106101061110612106131061410615106161061710618106191062010621106221062310624106251062610627106281062910630106311063210633106341063510636106371063810639106401064110642106431064410645106461064710648106491065010651106521065310654106551065610657106581065910660106611066210663106641066510666106671066810669106701067110672106731067410675106761067710678106791068010681106821068310684106851068610687106881068910690106911069210693106941069510696106971069810699107001070110702107031070410705107061070710708107091071010711107121071310714107151071610717107181071910720107211072210723107241072510726107271072810729107301073110732107331073410735107361073710738107391074010741107421074310744107451074610747107481074910750107511075210753107541075510756107571075810759107601076110762107631076410765107661076710768107691077010771107721077310774107751077610777107781077910780107811078210783107841078510786107871078810789107901079110792107931079410795107961079710798107991080010801108021080310804108051080610807108081080910810108111081210813108141081510816108171081810819108201082110822108231082410825108261082710828108291083010831108321083310834108351083610837108381083910840108411084210843108441084510846108471084810849108501085110852108531085410855108561085710858108591086010861108621086310864108651086610867108681086910870108711087210873108741087510876108771087810879108801088110882108831088410885108861088710888108891089010891108921089310894108951089610897108981089910900109011090210903109041090510906109071090810909109101091110912109131091410915109161091710918109191092010921109221092310924109251092610927109281092910930109311093210933109341093510936109371093810939109401094110942109431094410945109461094710948109491095010951109521095310954109551095610957109581095910960109611096210963109641096510966109671096810969109701097110972109731097410975109761097710978109791098010981109821098310984109851098610987109881098910990109911099210993109941099510996109971099810999110001100111002110031100411005110061100711008110091101011011110121101311014110151101611017110181101911020110211102211023110241102511026110271102811029110301103111032110331103411035110361103711038110391104011041110421104311044110451104611047110481104911050110511105211053110541105511056110571105811059110601106111062110631106411065110661106711068110691107011071110721107311074110751107611077110781107911080110811108211083110841108511086110871108811089110901109111092110931109411095110961109711098110991110011101111021110311104111051110611107111081110911110111111111211113111141111511116111171111811119111201112111122111231112411125111261112711128111291113011131111321113311134111351113611137111381113911140111411114211143111441114511146111471114811149111501115111152111531115411155111561115711158111591116011161111621116311164111651116611167111681116911170111711117211173111741117511176111771117811179111801118111182111831118411185111861118711188111891119011191111921119311194111951119611197111981119911200112011120211203112041120511206112071120811209112101121111212112131121411215112161121711218112191122011221112221122311224112251122611227112281122911230112311123211233112341123511236112371123811239112401124111242112431124411245112461124711248112491125011251112521125311254112551125611257112581125911260112611126211263112641126511266112671126811269112701127111272112731127411275112761127711278112791128011281112821128311284112851128611287112881128911290112911129211293112941129511296112971129811299113001130111302113031130411305113061130711308113091131011311113121131311314113151131611317113181131911320113211132211323113241132511326113271132811329113301133111332113331133411335113361133711338113391134011341113421134311344113451134611347113481134911350113511135211353113541135511356113571135811359113601136111362113631136411365113661136711368113691137011371113721137311374113751137611377113781137911380113811138211383113841138511386113871138811389113901139111392113931139411395113961139711398113991140011401114021140311404114051140611407114081140911410114111141211413114141141511416114171141811419114201142111422114231142411425114261142711428114291143011431114321143311434114351143611437114381143911440114411144211443114441144511446114471144811449114501145111452114531145411455114561145711458114591146011461114621146311464114651146611467114681146911470114711147211473114741147511476114771147811479114801148111482114831148411485114861148711488114891149011491114921149311494114951149611497114981149911500115011150211503115041150511506115071150811509115101151111512115131151411515115161151711518115191152011521115221152311524115251152611527115281152911530115311153211533115341153511536115371153811539115401154111542115431154411545115461154711548115491155011551115521155311554115551155611557115581155911560115611156211563115641156511566115671156811569115701157111572115731157411575115761157711578115791158011581115821158311584115851158611587115881158911590115911159211593115941159511596115971159811599116001160111602116031160411605116061160711608116091161011611116121161311614116151161611617116181161911620116211162211623116241162511626116271162811629116301163111632116331163411635116361163711638116391164011641116421164311644116451164611647116481164911650116511165211653116541165511656116571165811659116601166111662116631166411665116661166711668116691167011671116721167311674116751167611677116781167911680116811168211683116841168511686116871168811689116901169111692116931169411695116961169711698116991170011701117021170311704117051170611707117081170911710117111171211713117141171511716117171171811719117201172111722117231172411725117261172711728117291173011731117321173311734117351173611737117381173911740117411174211743117441174511746117471174811749117501175111752117531175411755117561175711758117591176011761117621176311764117651176611767117681176911770117711177211773117741177511776117771177811779117801178111782117831178411785117861178711788117891179011791117921179311794117951179611797117981179911800118011180211803118041180511806118071180811809118101181111812118131181411815118161181711818118191182011821118221182311824118251182611827118281182911830118311183211833118341183511836118371183811839118401184111842118431184411845118461184711848118491185011851118521185311854118551185611857118581185911860118611186211863118641186511866118671186811869118701187111872118731187411875118761187711878118791188011881118821188311884118851188611887118881188911890118911189211893118941189511896118971189811899119001190111902119031190411905119061190711908119091191011911119121191311914119151191611917119181191911920119211192211923119241192511926119271192811929119301193111932119331193411935119361193711938119391194011941119421194311944119451194611947119481194911950119511195211953119541195511956119571195811959119601196111962119631196411965119661196711968119691197011971119721197311974119751197611977119781197911980119811198211983119841198511986119871198811989119901199111992119931199411995119961199711998119991200012001120021200312004120051200612007120081200912010120111201212013120141201512016120171201812019120201202112022120231202412025120261202712028120291203012031120321203312034120351203612037120381203912040120411204212043120441204512046120471204812049120501205112052120531205412055120561205712058120591206012061120621206312064120651206612067120681206912070120711207212073120741207512076120771207812079120801208112082120831208412085120861208712088120891209012091120921209312094120951209612097120981209912100121011210212103121041210512106121071210812109121101211112112121131211412115121161211712118121191212012121121221212312124121251212612127121281212912130121311213212133121341213512136121371213812139121401214112142121431214412145121461214712148121491215012151121521215312154121551215612157121581215912160121611216212163121641216512166121671216812169121701217112172121731217412175121761217712178121791218012181121821218312184121851218612187121881218912190121911219212193121941219512196121971219812199122001220112202122031220412205122061220712208122091221012211122121221312214122151221612217122181221912220122211222212223122241222512226122271222812229122301223112232122331223412235122361223712238122391224012241122421224312244122451224612247122481224912250122511225212253122541225512256122571225812259122601226112262122631226412265122661226712268122691227012271122721227312274122751227612277122781227912280122811228212283122841228512286122871228812289122901229112292122931229412295122961229712298122991230012301123021230312304123051230612307123081230912310123111231212313123141231512316123171231812319123201232112322123231232412325123261232712328123291233012331123321233312334123351233612337123381233912340123411234212343123441234512346123471234812349123501235112352123531235412355123561235712358123591236012361123621236312364123651236612367123681236912370123711237212373123741237512376123771237812379123801238112382123831238412385123861238712388123891239012391123921239312394123951239612397123981239912400124011240212403124041240512406124071240812409124101241112412124131241412415124161241712418124191242012421124221242312424124251242612427124281242912430124311243212433124341243512436124371243812439124401244112442124431244412445124461244712448124491245012451124521245312454124551245612457124581245912460124611246212463124641246512466124671246812469124701247112472124731247412475124761247712478124791248012481124821248312484124851248612487124881248912490124911249212493124941249512496124971249812499125001250112502125031250412505125061250712508125091251012511125121251312514125151251612517125181251912520125211252212523125241252512526125271252812529125301253112532125331253412535125361253712538125391254012541125421254312544125451254612547125481254912550125511255212553125541255512556125571255812559125601256112562125631256412565125661256712568125691257012571125721257312574125751257612577125781257912580125811258212583125841258512586125871258812589125901259112592125931259412595125961259712598125991260012601126021260312604126051260612607126081260912610126111261212613126141261512616126171261812619126201262112622126231262412625126261262712628126291263012631126321263312634126351263612637126381263912640126411264212643126441264512646126471264812649126501265112652126531265412655126561265712658126591266012661126621266312664126651266612667126681266912670126711267212673126741267512676126771267812679126801268112682126831268412685126861268712688126891269012691126921269312694126951269612697126981269912700127011270212703127041270512706127071270812709127101271112712127131271412715127161271712718127191272012721127221272312724127251272612727127281272912730127311273212733127341273512736127371273812739127401274112742127431274412745127461274712748127491275012751127521275312754127551275612757127581275912760127611276212763127641276512766127671276812769127701277112772127731277412775127761277712778127791278012781127821278312784127851278612787127881278912790127911279212793127941279512796127971279812799128001280112802128031280412805128061280712808128091281012811128121281312814128151281612817128181281912820128211282212823128241282512826128271282812829128301283112832128331283412835128361283712838128391284012841128421284312844128451284612847128481284912850128511285212853128541285512856128571285812859128601286112862128631286412865128661286712868128691287012871128721287312874128751287612877128781287912880128811288212883128841288512886128871288812889128901289112892128931289412895128961289712898128991290012901129021290312904129051290612907129081290912910129111291212913129141291512916129171291812919129201292112922129231292412925129261292712928129291293012931129321293312934129351293612937129381293912940129411294212943129441294512946129471294812949129501295112952129531295412955129561295712958129591296012961129621296312964129651296612967129681296912970129711297212973129741297512976129771297812979129801298112982129831298412985129861298712988129891299012991129921299312994129951299612997129981299913000130011300213003130041300513006130071300813009130101301113012130131301413015130161301713018130191302013021130221302313024130251302613027130281302913030130311303213033130341303513036130371303813039130401304113042130431304413045130461304713048130491305013051130521305313054130551305613057130581305913060130611306213063130641306513066130671306813069130701307113072130731307413075130761307713078130791308013081130821308313084130851308613087130881308913090130911309213093130941309513096130971309813099131001310113102131031310413105131061310713108131091311013111131121311313114131151311613117131181311913120131211312213123131241312513126131271312813129131301313113132131331313413135131361313713138131391314013141131421314313144131451314613147131481314913150131511315213153131541315513156131571315813159131601316113162131631316413165131661316713168131691317013171131721317313174131751317613177131781317913180131811318213183131841318513186131871318813189131901319113192131931319413195131961319713198131991320013201132021320313204132051320613207132081320913210132111321213213132141321513216132171321813219132201322113222132231322413225132261322713228132291323013231132321323313234132351323613237132381323913240132411324213243132441324513246132471324813249132501325113252132531325413255132561325713258132591326013261132621326313264132651326613267132681326913270132711327213273132741327513276132771327813279132801328113282132831328413285132861328713288132891329013291132921329313294132951329613297132981329913300133011330213303133041330513306133071330813309133101331113312133131331413315133161331713318133191332013321133221332313324133251332613327133281332913330133311333213333133341333513336133371333813339133401334113342133431334413345133461334713348133491335013351133521335313354133551335613357133581335913360133611336213363133641336513366133671336813369133701337113372133731337413375133761337713378133791338013381133821338313384133851338613387133881338913390133911339213393133941339513396133971339813399134001340113402134031340413405134061340713408134091341013411134121341313414134151341613417134181341913420134211342213423134241342513426134271342813429134301343113432134331343413435134361343713438134391344013441134421344313444134451344613447134481344913450134511345213453134541345513456134571345813459134601346113462134631346413465134661346713468134691347013471134721347313474134751347613477134781347913480134811348213483134841348513486134871348813489134901349113492134931349413495134961349713498134991350013501135021350313504135051350613507135081350913510135111351213513135141351513516135171351813519135201352113522135231352413525135261352713528135291353013531135321353313534135351353613537135381353913540135411354213543135441354513546135471354813549135501355113552135531355413555135561355713558135591356013561135621356313564135651356613567135681356913570135711357213573135741357513576135771357813579135801358113582135831358413585135861358713588135891359013591135921359313594135951359613597135981359913600136011360213603136041360513606136071360813609136101361113612136131361413615136161361713618136191362013621136221362313624136251362613627136281362913630136311363213633136341363513636136371363813639136401364113642136431364413645136461364713648136491365013651136521365313654136551365613657136581365913660136611366213663136641366513666136671366813669136701367113672136731367413675136761367713678136791368013681136821368313684136851368613687136881368913690136911369213693136941369513696136971369813699137001370113702137031370413705137061370713708137091371013711137121371313714137151371613717137181371913720137211372213723137241372513726137271372813729137301373113732137331373413735137361373713738137391374013741137421374313744137451374613747137481374913750137511375213753137541375513756137571375813759137601376113762137631376413765137661376713768137691377013771137721377313774137751377613777137781377913780137811378213783137841378513786137871378813789137901379113792137931379413795137961379713798137991380013801138021380313804138051380613807138081380913810138111381213813138141381513816138171381813819138201382113822138231382413825138261382713828138291383013831138321383313834138351383613837138381383913840138411384213843138441384513846138471384813849138501385113852138531385413855138561385713858138591386013861138621386313864138651386613867138681386913870138711387213873138741387513876138771387813879138801388113882138831388413885138861388713888138891389013891138921389313894138951389613897138981389913900139011390213903139041390513906139071390813909139101391113912139131391413915139161391713918139191392013921139221392313924139251392613927139281392913930139311393213933139341393513936139371393813939139401394113942139431394413945139461394713948139491395013951139521395313954139551395613957139581395913960139611396213963139641396513966139671396813969139701397113972139731397413975139761397713978139791398013981139821398313984139851398613987139881398913990139911399213993139941399513996139971399813999140001400114002140031400414005140061400714008140091401014011140121401314014140151401614017140181401914020140211402214023140241402514026140271402814029140301403114032140331403414035140361403714038140391404014041140421404314044140451404614047140481404914050140511405214053140541405514056140571405814059140601406114062140631406414065140661406714068140691407014071140721407314074140751407614077140781407914080140811408214083140841408514086140871408814089140901409114092140931409414095140961409714098140991410014101141021410314104141051410614107141081410914110141111411214113141141411514116141171411814119141201412114122141231412414125141261412714128141291413014131141321413314134141351413614137141381413914140141411414214143141441414514146141471414814149141501415114152141531415414155141561415714158141591416014161141621416314164141651416614167141681416914170141711417214173141741417514176141771417814179141801418114182141831418414185141861418714188141891419014191141921419314194141951419614197141981419914200142011420214203142041420514206142071420814209142101421114212142131421414215142161421714218142191422014221142221422314224142251422614227142281422914230142311423214233142341423514236142371423814239142401424114242142431424414245142461424714248142491425014251142521425314254142551425614257142581425914260142611426214263142641426514266142671426814269142701427114272142731427414275142761427714278142791428014281142821428314284142851428614287142881428914290142911429214293142941429514296142971429814299143001430114302143031430414305143061430714308143091431014311143121431314314143151431614317143181431914320143211432214323143241432514326143271432814329143301433114332143331433414335143361433714338143391434014341143421434314344143451434614347143481434914350143511435214353143541435514356143571435814359143601436114362143631436414365143661436714368143691437014371143721437314374143751437614377143781437914380143811438214383143841438514386143871438814389143901439114392143931439414395143961439714398143991440014401144021440314404144051440614407144081440914410144111441214413144141441514416144171441814419144201442114422144231442414425144261442714428144291443014431144321443314434144351443614437144381443914440144411444214443144441444514446144471444814449144501445114452144531445414455144561445714458144591446014461144621446314464144651446614467144681446914470144711447214473144741447514476144771447814479144801448114482144831448414485144861448714488144891449014491144921449314494144951449614497144981449914500145011450214503145041450514506145071450814509145101451114512145131451414515145161451714518145191452014521145221452314524145251452614527145281452914530145311453214533145341453514536145371453814539145401454114542145431454414545145461454714548145491455014551145521455314554145551455614557145581455914560145611456214563145641456514566145671456814569145701457114572145731457414575145761457714578145791458014581145821458314584145851458614587145881458914590145911459214593145941459514596145971459814599146001460114602146031460414605146061460714608146091461014611146121461314614146151461614617146181461914620146211462214623146241462514626146271462814629146301463114632146331463414635146361463714638146391464014641146421464314644146451464614647146481464914650146511465214653146541465514656146571465814659146601466114662146631466414665146661466714668146691467014671146721467314674146751467614677146781467914680146811468214683146841468514686146871468814689146901469114692146931469414695146961469714698146991470014701147021470314704147051470614707147081470914710147111471214713147141471514716147171471814719147201472114722147231472414725147261472714728147291473014731147321473314734147351473614737147381473914740147411474214743147441474514746147471474814749147501475114752147531475414755147561475714758147591476014761147621476314764147651476614767147681476914770147711477214773147741477514776147771477814779147801478114782147831478414785147861478714788147891479014791147921479314794147951479614797147981479914800148011480214803148041480514806148071480814809148101481114812148131481414815148161481714818148191482014821148221482314824148251482614827148281482914830148311483214833148341483514836148371483814839148401484114842148431484414845148461484714848148491485014851148521485314854148551485614857148581485914860148611486214863148641486514866148671486814869148701487114872148731487414875148761487714878148791488014881148821488314884148851488614887148881488914890148911489214893148941489514896148971489814899149001490114902149031490414905149061490714908149091491014911149121491314914149151491614917149181491914920149211492214923149241492514926149271492814929149301493114932149331493414935149361493714938149391494014941149421494314944149451494614947149481494914950149511495214953149541495514956149571495814959149601496114962149631496414965149661496714968149691497014971149721497314974149751497614977149781497914980149811498214983149841498514986149871498814989149901499114992149931499414995149961499714998149991500015001150021500315004150051500615007150081500915010150111501215013150141501515016150171501815019150201502115022150231502415025150261502715028150291503015031150321503315034150351503615037150381503915040150411504215043150441504515046150471504815049150501505115052150531505415055150561505715058150591506015061150621506315064150651506615067150681506915070150711507215073150741507515076150771507815079150801508115082150831508415085150861508715088150891509015091150921509315094150951509615097150981509915100151011510215103151041510515106151071510815109151101511115112151131511415115151161511715118151191512015121151221512315124151251512615127151281512915130151311513215133151341513515136151371513815139151401514115142151431514415145151461514715148151491515015151151521515315154151551515615157151581515915160151611516215163151641516515166151671516815169151701517115172151731517415175151761517715178151791518015181151821518315184151851518615187151881518915190151911519215193151941519515196151971519815199152001520115202152031520415205152061520715208152091521015211152121521315214152151521615217152181521915220152211522215223152241522515226152271522815229152301523115232152331523415235152361523715238152391524015241152421524315244152451524615247152481524915250152511525215253152541525515256152571525815259152601526115262152631526415265152661526715268152691527015271152721527315274152751527615277152781527915280152811528215283152841528515286152871528815289152901529115292152931529415295152961529715298152991530015301153021530315304153051530615307153081530915310153111531215313153141531515316153171531815319153201532115322153231532415325153261532715328153291533015331153321533315334153351533615337153381533915340153411534215343153441534515346153471534815349153501535115352153531535415355153561535715358153591536015361153621536315364153651536615367153681536915370153711537215373153741537515376153771537815379153801538115382153831538415385153861538715388153891539015391153921539315394153951539615397153981539915400154011540215403154041540515406154071540815409154101541115412154131541415415154161541715418154191542015421154221542315424154251542615427154281542915430154311543215433154341543515436154371543815439154401544115442154431544415445154461544715448154491545015451154521545315454154551545615457154581545915460154611546215463154641546515466154671546815469154701547115472154731547415475154761547715478154791548015481154821548315484154851548615487154881548915490154911549215493154941549515496154971549815499155001550115502155031550415505155061550715508155091551015511155121551315514155151551615517155181551915520155211552215523155241552515526155271552815529155301553115532155331553415535155361553715538155391554015541155421554315544155451554615547155481554915550155511555215553155541555515556155571555815559155601556115562155631556415565155661556715568155691557015571155721557315574155751557615577155781557915580155811558215583155841558515586155871558815589155901559115592155931559415595155961559715598155991560015601156021560315604156051560615607156081560915610156111561215613156141561515616156171561815619156201562115622156231562415625156261562715628156291563015631156321563315634156351563615637156381563915640156411564215643156441564515646156471564815649156501565115652156531565415655156561565715658156591566015661156621566315664156651566615667156681566915670156711567215673156741567515676156771567815679156801568115682156831568415685156861568715688156891569015691156921569315694156951569615697156981569915700157011570215703157041570515706157071570815709157101571115712157131571415715157161571715718157191572015721157221572315724157251572615727157281572915730157311573215733157341573515736157371573815739157401574115742157431574415745157461574715748157491575015751157521575315754157551575615757157581575915760157611576215763157641576515766157671576815769157701577115772157731577415775157761577715778157791578015781157821578315784157851578615787157881578915790157911579215793157941579515796157971579815799158001580115802158031580415805158061580715808158091581015811158121581315814158151581615817158181581915820158211582215823158241582515826158271582815829158301583115832158331583415835158361583715838158391584015841158421584315844158451584615847158481584915850158511585215853158541585515856158571585815859158601586115862158631586415865158661586715868158691587015871158721587315874158751587615877158781587915880158811588215883158841588515886158871588815889158901589115892158931589415895158961589715898158991590015901159021590315904159051590615907159081590915910159111591215913159141591515916159171591815919159201592115922159231592415925159261592715928159291593015931159321593315934159351593615937159381593915940159411594215943159441594515946159471594815949159501595115952159531595415955159561595715958159591596015961159621596315964159651596615967159681596915970159711597215973159741597515976159771597815979159801598115982159831598415985159861598715988159891599015991159921599315994159951599615997159981599916000160011600216003160041600516006160071600816009160101601116012160131601416015160161601716018160191602016021160221602316024160251602616027160281602916030160311603216033160341603516036160371603816039160401604116042160431604416045160461604716048160491605016051160521605316054160551605616057160581605916060160611606216063160641606516066160671606816069160701607116072160731607416075160761607716078160791608016081160821608316084160851608616087160881608916090160911609216093160941609516096160971609816099161001610116102161031610416105161061610716108161091611016111161121611316114161151611616117161181611916120161211612216123161241612516126161271612816129161301613116132161331613416135161361613716138161391614016141161421614316144161451614616147161481614916150161511615216153161541615516156161571615816159161601616116162161631616416165161661616716168161691617016171161721617316174161751617616177161781617916180161811618216183161841618516186161871618816189161901619116192161931619416195161961619716198161991620016201162021620316204162051620616207162081620916210162111621216213162141621516216162171621816219162201622116222162231622416225162261622716228162291623016231162321623316234162351623616237162381623916240162411624216243162441624516246162471624816249162501625116252162531625416255162561625716258162591626016261162621626316264162651626616267162681626916270162711627216273162741627516276162771627816279162801628116282162831628416285162861628716288162891629016291162921629316294162951629616297162981629916300163011630216303163041630516306163071630816309163101631116312163131631416315163161631716318163191632016321163221632316324163251632616327163281632916330163311633216333163341633516336163371633816339163401634116342163431634416345163461634716348163491635016351163521635316354163551635616357163581635916360163611636216363163641636516366163671636816369163701637116372163731637416375163761637716378163791638016381163821638316384163851638616387163881638916390163911639216393163941639516396163971639816399164001640116402164031640416405164061640716408164091641016411164121641316414164151641616417164181641916420164211642216423164241642516426164271642816429164301643116432164331643416435164361643716438164391644016441164421644316444164451644616447164481644916450164511645216453164541645516456164571645816459164601646116462164631646416465164661646716468164691647016471164721647316474164751647616477164781647916480164811648216483164841648516486164871648816489164901649116492164931649416495164961649716498164991650016501165021650316504165051650616507165081650916510165111651216513165141651516516165171651816519165201652116522165231652416525165261652716528165291653016531165321653316534165351653616537165381653916540165411654216543165441654516546165471654816549165501655116552165531655416555165561655716558165591656016561165621656316564165651656616567165681656916570165711657216573165741657516576165771657816579165801658116582165831658416585165861658716588165891659016591165921659316594165951659616597165981659916600166011660216603166041660516606166071660816609166101661116612166131661416615166161661716618166191662016621166221662316624166251662616627166281662916630166311663216633166341663516636166371663816639166401664116642166431664416645166461664716648166491665016651166521665316654166551665616657166581665916660166611666216663166641666516666166671666816669166701667116672166731667416675166761667716678166791668016681166821668316684166851668616687166881668916690166911669216693166941669516696166971669816699167001670116702167031670416705167061670716708167091671016711167121671316714167151671616717167181671916720167211672216723167241672516726167271672816729167301673116732167331673416735167361673716738167391674016741167421674316744167451674616747167481674916750167511675216753167541675516756167571675816759167601676116762167631676416765167661676716768167691677016771167721677316774167751677616777167781677916780167811678216783167841678516786167871678816789167901679116792167931679416795167961679716798167991680016801168021680316804168051680616807168081680916810168111681216813168141681516816168171681816819168201682116822168231682416825168261682716828168291683016831168321683316834168351683616837168381683916840168411684216843168441684516846168471684816849168501685116852168531685416855168561685716858168591686016861168621686316864168651686616867168681686916870168711687216873168741687516876168771687816879168801688116882168831688416885168861688716888168891689016891168921689316894168951689616897168981689916900169011690216903169041690516906169071690816909169101691116912169131691416915169161691716918169191692016921169221692316924169251692616927169281692916930169311693216933169341693516936169371693816939169401694116942169431694416945169461694716948169491695016951169521695316954169551695616957169581695916960169611696216963169641696516966169671696816969169701697116972169731697416975169761697716978169791698016981169821698316984169851698616987169881698916990169911699216993169941699516996169971699816999170001700117002170031700417005170061700717008170091701017011170121701317014170151701617017170181701917020170211702217023170241702517026170271702817029170301703117032170331703417035170361703717038170391704017041170421704317044170451704617047170481704917050170511705217053170541705517056170571705817059170601706117062170631706417065170661706717068170691707017071170721707317074170751707617077170781707917080170811708217083170841708517086170871708817089170901709117092170931709417095170961709717098170991710017101171021710317104171051710617107171081710917110171111711217113171141711517116171171711817119171201712117122171231712417125171261712717128171291713017131171321713317134171351713617137171381713917140171411714217143171441714517146171471714817149171501715117152171531715417155171561715717158171591716017161171621716317164171651716617167171681716917170171711717217173171741717517176171771717817179171801718117182171831718417185171861718717188171891719017191171921719317194171951719617197171981719917200172011720217203172041720517206172071720817209172101721117212172131721417215172161721717218172191722017221172221722317224172251722617227172281722917230172311723217233172341723517236172371723817239172401724117242172431724417245172461724717248172491725017251172521725317254172551725617257172581725917260172611726217263172641726517266172671726817269172701727117272172731727417275172761727717278172791728017281172821728317284172851728617287172881728917290172911729217293172941729517296172971729817299173001730117302173031730417305173061730717308173091731017311173121731317314173151731617317173181731917320173211732217323173241732517326173271732817329173301733117332173331733417335173361733717338173391734017341173421734317344173451734617347173481734917350173511735217353173541735517356173571735817359173601736117362173631736417365173661736717368173691737017371173721737317374173751737617377173781737917380173811738217383173841738517386173871738817389173901739117392173931739417395173961739717398173991740017401174021740317404174051740617407174081740917410174111741217413174141741517416174171741817419174201742117422174231742417425174261742717428174291743017431174321743317434174351743617437174381743917440174411744217443174441744517446174471744817449174501745117452174531745417455174561745717458174591746017461174621746317464174651746617467174681746917470174711747217473174741747517476174771747817479174801748117482174831748417485174861748717488174891749017491174921749317494174951749617497174981749917500175011750217503175041750517506175071750817509175101751117512175131751417515175161751717518175191752017521175221752317524175251752617527175281752917530175311753217533175341753517536175371753817539175401754117542175431754417545175461754717548175491755017551175521755317554175551755617557175581755917560175611756217563175641756517566175671756817569175701757117572175731757417575175761757717578175791758017581175821758317584175851758617587175881758917590175911759217593175941759517596175971759817599176001760117602176031760417605176061760717608176091761017611176121761317614176151761617617176181761917620176211762217623176241762517626176271762817629176301763117632176331763417635176361763717638176391764017641176421764317644176451764617647176481764917650176511765217653176541765517656176571765817659176601766117662176631766417665176661766717668176691767017671176721767317674176751767617677176781767917680176811768217683176841768517686176871768817689176901769117692176931769417695176961769717698176991770017701177021770317704177051770617707177081770917710177111771217713177141771517716177171771817719177201772117722177231772417725177261772717728177291773017731177321773317734177351773617737177381773917740177411774217743177441774517746177471774817749177501775117752177531775417755177561775717758177591776017761177621776317764177651776617767177681776917770177711777217773177741777517776177771777817779177801778117782177831778417785177861778717788177891779017791177921779317794177951779617797177981779917800178011780217803178041780517806178071780817809178101781117812178131781417815178161781717818178191782017821178221782317824178251782617827178281782917830178311783217833178341783517836178371783817839178401784117842178431784417845178461784717848178491785017851178521785317854178551785617857178581785917860178611786217863178641786517866178671786817869178701787117872178731787417875178761787717878178791788017881178821788317884178851788617887178881788917890178911789217893178941789517896178971789817899179001790117902179031790417905179061790717908179091791017911179121791317914179151791617917179181791917920179211792217923179241792517926179271792817929179301793117932179331793417935179361793717938179391794017941179421794317944179451794617947179481794917950179511795217953179541795517956179571795817959179601796117962179631796417965179661796717968179691797017971179721797317974179751797617977179781797917980179811798217983179841798517986179871798817989179901799117992179931799417995179961799717998179991800018001180021800318004180051800618007180081800918010180111801218013180141801518016180171801818019180201802118022180231802418025180261802718028180291803018031180321803318034180351803618037180381803918040180411804218043180441804518046180471804818049180501805118052180531805418055180561805718058180591806018061180621806318064180651806618067180681806918070180711807218073180741807518076180771807818079180801808118082180831808418085180861808718088180891809018091180921809318094180951809618097180981809918100181011810218103181041810518106181071810818109181101811118112181131811418115181161811718118181191812018121181221812318124181251812618127181281812918130181311813218133181341813518136181371813818139181401814118142181431814418145181461814718148181491815018151181521815318154181551815618157181581815918160181611816218163181641816518166181671816818169181701817118172181731817418175181761817718178181791818018181181821818318184181851818618187181881818918190181911819218193181941819518196181971819818199182001820118202182031820418205182061820718208182091821018211182121821318214182151821618217182181821918220182211822218223182241822518226182271822818229182301823118232182331823418235182361823718238182391824018241182421824318244182451824618247182481824918250182511825218253182541825518256182571825818259182601826118262182631826418265182661826718268182691827018271182721827318274182751827618277182781827918280182811828218283182841828518286182871828818289182901829118292182931829418295182961829718298182991830018301183021830318304183051830618307183081830918310183111831218313183141831518316183171831818319183201832118322183231832418325183261832718328183291833018331183321833318334183351833618337183381833918340183411834218343183441834518346183471834818349183501835118352183531835418355183561835718358183591836018361183621836318364183651836618367183681836918370183711837218373183741837518376183771837818379183801838118382183831838418385183861838718388183891839018391183921839318394183951839618397183981839918400184011840218403184041840518406184071840818409184101841118412184131841418415184161841718418184191842018421184221842318424184251842618427184281842918430184311843218433184341843518436184371843818439184401844118442184431844418445184461844718448184491845018451184521845318454184551845618457184581845918460184611846218463184641846518466184671846818469184701847118472184731847418475184761847718478184791848018481184821848318484184851848618487184881848918490184911849218493184941849518496184971849818499185001850118502185031850418505185061850718508185091851018511185121851318514185151851618517185181851918520185211852218523185241852518526185271852818529185301853118532185331853418535185361853718538185391854018541185421854318544185451854618547185481854918550185511855218553185541855518556185571855818559185601856118562185631856418565185661856718568185691857018571185721857318574185751857618577185781857918580185811858218583185841858518586185871858818589185901859118592185931859418595185961859718598185991860018601186021860318604186051860618607186081860918610186111861218613186141861518616186171861818619186201862118622186231862418625186261862718628186291863018631186321863318634186351863618637186381863918640186411864218643186441864518646186471864818649186501865118652186531865418655186561865718658186591866018661186621866318664186651866618667186681866918670186711867218673186741867518676186771867818679186801868118682186831868418685186861868718688186891869018691186921869318694186951869618697186981869918700187011870218703187041870518706187071870818709187101871118712187131871418715187161871718718187191872018721187221872318724187251872618727187281872918730187311873218733187341873518736187371873818739187401874118742187431874418745187461874718748187491875018751187521875318754187551875618757187581875918760187611876218763187641876518766187671876818769187701877118772187731877418775187761877718778187791878018781187821878318784187851878618787187881878918790187911879218793187941879518796187971879818799188001880118802188031880418805188061880718808188091881018811188121881318814188151881618817188181881918820188211882218823188241882518826188271882818829188301883118832188331883418835188361883718838188391884018841188421884318844188451884618847188481884918850188511885218853188541885518856188571885818859188601886118862188631886418865188661886718868188691887018871188721887318874188751887618877188781887918880188811888218883188841888518886188871888818889188901889118892188931889418895188961889718898188991890018901189021890318904189051890618907189081890918910189111891218913189141891518916189171891818919189201892118922189231892418925189261892718928189291893018931189321893318934189351893618937189381893918940189411894218943189441894518946189471894818949189501895118952189531895418955189561895718958189591896018961189621896318964189651896618967189681896918970189711897218973189741897518976189771897818979189801898118982189831898418985189861898718988189891899018991189921899318994189951899618997189981899919000190011900219003190041900519006190071900819009190101901119012190131901419015190161901719018190191902019021190221902319024190251902619027190281902919030190311903219033190341903519036190371903819039190401904119042190431904419045190461904719048190491905019051190521905319054190551905619057190581905919060190611906219063190641906519066190671906819069190701907119072190731907419075190761907719078190791908019081190821908319084190851908619087190881908919090190911909219093190941909519096190971909819099191001910119102191031910419105191061910719108191091911019111191121911319114191151911619117191181911919120191211912219123191241912519126191271912819129191301913119132191331913419135191361913719138191391914019141191421914319144191451914619147191481914919150191511915219153191541915519156191571915819159191601916119162191631916419165191661916719168191691917019171191721917319174191751917619177191781917919180191811918219183191841918519186191871918819189191901919119192191931919419195191961919719198191991920019201192021920319204192051920619207192081920919210192111921219213192141921519216192171921819219192201922119222192231922419225192261922719228192291923019231192321923319234192351923619237192381923919240192411924219243192441924519246192471924819249192501925119252192531925419255192561925719258192591926019261192621926319264192651926619267192681926919270192711927219273192741927519276192771927819279192801928119282192831928419285192861928719288192891929019291192921929319294192951929619297192981929919300193011930219303193041930519306193071930819309193101931119312193131931419315193161931719318193191932019321193221932319324193251932619327193281932919330193311933219333193341933519336193371933819339193401934119342193431934419345193461934719348193491935019351193521935319354193551935619357193581935919360193611936219363193641936519366193671936819369193701937119372193731937419375193761937719378193791938019381193821938319384193851938619387193881938919390193911939219393193941939519396193971939819399194001940119402194031940419405194061940719408194091941019411194121941319414194151941619417194181941919420194211942219423194241942519426194271942819429194301943119432194331943419435194361943719438194391944019441194421944319444194451944619447194481944919450194511945219453194541945519456194571945819459194601946119462194631946419465194661946719468194691947019471194721947319474194751947619477194781947919480194811948219483194841948519486194871948819489194901949119492194931949419495194961949719498194991950019501195021950319504195051950619507195081950919510195111951219513195141951519516195171951819519195201952119522195231952419525195261952719528195291953019531195321953319534195351953619537195381953919540195411954219543195441954519546195471954819549195501955119552195531955419555195561955719558195591956019561195621956319564195651956619567195681956919570195711957219573195741957519576195771957819579195801958119582195831958419585195861958719588195891959019591195921959319594195951959619597195981959919600196011960219603196041960519606196071960819609196101961119612196131961419615196161961719618196191962019621196221962319624196251962619627196281962919630196311963219633196341963519636196371963819639196401964119642196431964419645196461964719648196491965019651196521965319654196551965619657196581965919660196611966219663196641966519666196671966819669196701967119672196731967419675196761967719678196791968019681196821968319684196851968619687196881968919690196911969219693196941969519696196971969819699197001970119702197031970419705197061970719708197091971019711197121971319714197151971619717197181971919720197211972219723197241972519726197271972819729197301973119732197331973419735197361973719738197391974019741197421974319744197451974619747197481974919750197511975219753197541975519756197571975819759197601976119762197631976419765197661976719768197691977019771197721977319774197751977619777197781977919780197811978219783197841978519786197871978819789197901979119792197931979419795197961979719798197991980019801198021980319804198051980619807198081980919810198111981219813198141981519816198171981819819198201982119822198231982419825198261982719828198291983019831198321983319834198351983619837198381983919840198411984219843198441984519846198471984819849198501985119852198531985419855198561985719858198591986019861198621986319864198651986619867198681986919870198711987219873198741987519876198771987819879198801988119882198831988419885198861988719888198891989019891198921989319894198951989619897198981989919900199011990219903199041990519906199071990819909199101991119912199131991419915199161991719918199191992019921199221992319924199251992619927199281992919930199311993219933199341993519936199371993819939199401994119942199431994419945199461994719948199491995019951199521995319954199551995619957199581995919960199611996219963199641996519966199671996819969199701997119972199731997419975199761997719978199791998019981199821998319984199851998619987199881998919990199911999219993199941999519996199971999819999200002000120002200032000420005200062000720008200092001020011200122001320014200152001620017200182001920020200212002220023200242002520026200272002820029200302003120032200332003420035200362003720038200392004020041200422004320044200452004620047200482004920050200512005220053200542005520056200572005820059200602006120062200632006420065200662006720068200692007020071200722007320074200752007620077200782007920080200812008220083200842008520086200872008820089200902009120092200932009420095200962009720098200992010020101201022010320104201052010620107201082010920110201112011220113201142011520116201172011820119201202012120122201232012420125201262012720128201292013020131201322013320134201352013620137201382013920140201412014220143201442014520146201472014820149201502015120152201532015420155201562015720158201592016020161201622016320164201652016620167201682016920170201712017220173201742017520176201772017820179201802018120182201832018420185201862018720188201892019020191201922019320194201952019620197201982019920200202012020220203202042020520206202072020820209202102021120212202132021420215202162021720218202192022020221202222022320224202252022620227202282022920230202312023220233202342023520236202372023820239202402024120242202432024420245202462024720248202492025020251202522025320254202552025620257202582025920260202612026220263202642026520266202672026820269202702027120272202732027420275202762027720278202792028020281202822028320284202852028620287202882028920290202912029220293202942029520296202972029820299203002030120302203032030420305203062030720308203092031020311203122031320314203152031620317203182031920320203212032220323203242032520326203272032820329203302033120332203332033420335203362033720338203392034020341203422034320344203452034620347203482034920350203512035220353203542035520356203572035820359203602036120362203632036420365203662036720368203692037020371203722037320374203752037620377203782037920380203812038220383203842038520386203872038820389203902039120392203932039420395203962039720398203992040020401204022040320404204052040620407204082040920410204112041220413204142041520416204172041820419204202042120422204232042420425204262042720428204292043020431204322043320434204352043620437204382043920440204412044220443204442044520446204472044820449204502045120452204532045420455204562045720458204592046020461204622046320464204652046620467204682046920470204712047220473204742047520476204772047820479204802048120482204832048420485204862048720488204892049020491204922049320494204952049620497204982049920500205012050220503205042050520506205072050820509205102051120512205132051420515205162051720518205192052020521205222052320524205252052620527205282052920530205312053220533205342053520536205372053820539205402054120542205432054420545205462054720548205492055020551205522055320554205552055620557205582055920560205612056220563205642056520566205672056820569205702057120572205732057420575205762057720578205792058020581205822058320584205852058620587205882058920590205912059220593205942059520596205972059820599206002060120602206032060420605206062060720608206092061020611206122061320614206152061620617206182061920620206212062220623206242062520626206272062820629206302063120632206332063420635206362063720638206392064020641206422064320644206452064620647206482064920650206512065220653206542065520656206572065820659206602066120662206632066420665206662066720668206692067020671206722067320674206752067620677206782067920680206812068220683206842068520686206872068820689206902069120692206932069420695206962069720698206992070020701207022070320704207052070620707207082070920710207112071220713207142071520716207172071820719207202072120722207232072420725207262072720728207292073020731207322073320734207352073620737207382073920740207412074220743207442074520746207472074820749207502075120752207532075420755207562075720758207592076020761207622076320764207652076620767207682076920770207712077220773207742077520776207772077820779207802078120782207832078420785207862078720788207892079020791207922079320794207952079620797207982079920800208012080220803208042080520806208072080820809208102081120812208132081420815208162081720818208192082020821208222082320824208252082620827208282082920830208312083220833208342083520836208372083820839208402084120842208432084420845208462084720848208492085020851208522085320854208552085620857208582085920860208612086220863208642086520866208672086820869208702087120872208732087420875208762087720878208792088020881208822088320884208852088620887208882088920890208912089220893208942089520896208972089820899209002090120902209032090420905209062090720908209092091020911209122091320914209152091620917209182091920920209212092220923209242092520926209272092820929209302093120932209332093420935209362093720938209392094020941209422094320944209452094620947209482094920950209512095220953209542095520956209572095820959209602096120962209632096420965209662096720968209692097020971209722097320974209752097620977209782097920980209812098220983209842098520986209872098820989209902099120992209932099420995209962099720998209992100021001210022100321004210052100621007210082100921010210112101221013210142101521016210172101821019210202102121022210232102421025210262102721028210292103021031210322103321034210352103621037210382103921040210412104221043210442104521046210472104821049210502105121052210532105421055210562105721058210592106021061210622106321064210652106621067210682106921070210712107221073210742107521076210772107821079210802108121082210832108421085210862108721088210892109021091210922109321094210952109621097210982109921100211012110221103211042110521106211072110821109211102111121112211132111421115211162111721118211192112021121211222112321124211252112621127211282112921130211312113221133211342113521136211372113821139211402114121142211432114421145211462114721148211492115021151211522115321154211552115621157211582115921160211612116221163211642116521166211672116821169211702117121172211732117421175211762117721178211792118021181211822118321184211852118621187211882118921190211912119221193211942119521196211972119821199212002120121202212032120421205212062120721208212092121021211212122121321214212152121621217212182121921220212212122221223212242122521226212272122821229212302123121232212332123421235212362123721238212392124021241212422124321244212452124621247212482124921250212512125221253212542125521256212572125821259212602126121262212632126421265212662126721268212692127021271212722127321274212752127621277212782127921280212812128221283212842128521286212872128821289212902129121292212932129421295212962129721298212992130021301213022130321304213052130621307213082130921310213112131221313213142131521316213172131821319213202132121322213232132421325213262132721328213292133021331213322133321334213352133621337213382133921340213412134221343213442134521346213472134821349213502135121352213532135421355213562135721358213592136021361213622136321364213652136621367213682136921370213712137221373213742137521376213772137821379213802138121382213832138421385213862138721388213892139021391213922139321394213952139621397213982139921400214012140221403214042140521406214072140821409214102141121412214132141421415214162141721418214192142021421214222142321424214252142621427214282142921430214312143221433214342143521436214372143821439214402144121442214432144421445214462144721448214492145021451214522145321454214552145621457214582145921460214612146221463214642146521466214672146821469214702147121472214732147421475214762147721478214792148021481214822148321484214852148621487214882148921490214912149221493214942149521496214972149821499215002150121502215032150421505215062150721508215092151021511215122151321514215152151621517215182151921520215212152221523215242152521526215272152821529215302153121532215332153421535215362153721538215392154021541215422154321544215452154621547215482154921550215512155221553215542155521556215572155821559215602156121562215632156421565215662156721568215692157021571215722157321574215752157621577215782157921580215812158221583215842158521586215872158821589215902159121592215932159421595215962159721598215992160021601216022160321604216052160621607216082160921610216112161221613216142161521616216172161821619216202162121622216232162421625216262162721628216292163021631216322163321634216352163621637216382163921640216412164221643216442164521646216472164821649216502165121652216532165421655216562165721658216592166021661216622166321664216652166621667216682166921670216712167221673216742167521676216772167821679216802168121682216832168421685216862168721688216892169021691216922169321694216952169621697216982169921700217012170221703217042170521706217072170821709217102171121712217132171421715217162171721718217192172021721217222172321724217252172621727217282172921730217312173221733217342173521736217372173821739217402174121742217432174421745217462174721748217492175021751217522175321754217552175621757217582175921760217612176221763217642176521766217672176821769217702177121772217732177421775217762177721778217792178021781217822178321784217852178621787217882178921790217912179221793217942179521796217972179821799218002180121802218032180421805218062180721808218092181021811218122181321814218152181621817218182181921820218212182221823218242182521826218272182821829218302183121832218332183421835218362183721838218392184021841218422184321844218452184621847218482184921850218512185221853218542185521856218572185821859218602186121862218632186421865218662186721868218692187021871218722187321874218752187621877218782187921880218812188221883218842188521886218872188821889218902189121892218932189421895218962189721898218992190021901219022190321904219052190621907219082190921910219112191221913219142191521916219172191821919219202192121922219232192421925219262192721928219292193021931219322193321934219352193621937219382193921940219412194221943219442194521946219472194821949219502195121952219532195421955219562195721958219592196021961219622196321964219652196621967219682196921970219712197221973219742197521976219772197821979219802198121982219832198421985219862198721988219892199021991219922199321994219952199621997219982199922000220012200222003220042200522006220072200822009220102201122012220132201422015220162201722018220192202022021220222202322024220252202622027220282202922030220312203222033220342203522036220372203822039220402204122042220432204422045220462204722048220492205022051220522205322054220552205622057220582205922060220612206222063220642206522066220672206822069220702207122072220732207422075220762207722078220792208022081220822208322084220852208622087220882208922090220912209222093220942209522096220972209822099221002210122102221032210422105221062210722108221092211022111221122211322114221152211622117221182211922120221212212222123221242212522126221272212822129221302213122132221332213422135221362213722138221392214022141221422214322144221452214622147221482214922150221512215222153221542215522156221572215822159221602216122162221632216422165221662216722168221692217022171221722217322174221752217622177221782217922180221812218222183221842218522186221872218822189221902219122192221932219422195221962219722198221992220022201222022220322204222052220622207222082220922210222112221222213222142221522216222172221822219222202222122222222232222422225222262222722228222292223022231222322223322234222352223622237222382223922240222412224222243222442224522246222472224822249222502225122252222532225422255222562225722258222592226022261222622226322264222652226622267222682226922270222712227222273222742227522276222772227822279222802228122282222832228422285222862228722288222892229022291222922229322294222952229622297222982229922300223012230222303223042230522306223072230822309223102231122312223132231422315223162231722318223192232022321223222232322324223252232622327223282232922330223312233222333223342233522336223372233822339223402234122342223432234422345223462234722348223492235022351223522235322354223552235622357223582235922360223612236222363223642236522366223672236822369223702237122372223732237422375223762237722378223792238022381223822238322384223852238622387223882238922390223912239222393223942239522396223972239822399224002240122402224032240422405224062240722408224092241022411224122241322414224152241622417224182241922420224212242222423224242242522426224272242822429224302243122432224332243422435224362243722438224392244022441224422244322444224452244622447224482244922450224512245222453224542245522456224572245822459224602246122462224632246422465224662246722468224692247022471224722247322474224752247622477224782247922480224812248222483224842248522486224872248822489224902249122492224932249422495224962249722498224992250022501225022250322504225052250622507225082250922510225112251222513225142251522516225172251822519225202252122522225232252422525225262252722528225292253022531225322253322534225352253622537225382253922540225412254222543225442254522546225472254822549225502255122552225532255422555225562255722558225592256022561225622256322564225652256622567225682256922570225712257222573225742257522576225772257822579225802258122582225832258422585225862258722588225892259022591225922259322594225952259622597225982259922600226012260222603226042260522606226072260822609226102261122612226132261422615226162261722618226192262022621226222262322624226252262622627226282262922630226312263222633226342263522636226372263822639226402264122642226432264422645226462264722648226492265022651226522265322654226552265622657226582265922660226612266222663226642266522666226672266822669226702267122672226732267422675226762267722678226792268022681226822268322684226852268622687226882268922690226912269222693226942269522696226972269822699227002270122702227032270422705227062270722708227092271022711227122271322714227152271622717227182271922720227212272222723227242272522726227272272822729227302273122732227332273422735227362273722738227392274022741227422274322744227452274622747227482274922750227512275222753227542275522756227572275822759227602276122762227632276422765227662276722768227692277022771227722277322774227752277622777227782277922780227812278222783227842278522786227872278822789227902279122792227932279422795227962279722798227992280022801228022280322804228052280622807228082280922810228112281222813228142281522816228172281822819228202282122822228232282422825228262282722828228292283022831228322283322834228352283622837228382283922840228412284222843228442284522846228472284822849228502285122852228532285422855228562285722858228592286022861228622286322864228652286622867228682286922870228712287222873228742287522876228772287822879228802288122882228832288422885228862288722888228892289022891228922289322894228952289622897228982289922900229012290222903229042290522906229072290822909229102291122912229132291422915229162291722918229192292022921229222292322924229252292622927229282292922930229312293222933229342293522936229372293822939229402294122942229432294422945229462294722948229492295022951229522295322954229552295622957229582295922960229612296222963229642296522966229672296822969229702297122972229732297422975229762297722978229792298022981229822298322984229852298622987229882298922990229912299222993229942299522996229972299822999230002300123002230032300423005230062300723008230092301023011230122301323014230152301623017230182301923020230212302223023230242302523026230272302823029230302303123032230332303423035230362303723038230392304023041230422304323044230452304623047230482304923050230512305223053230542305523056230572305823059230602306123062230632306423065230662306723068230692307023071230722307323074230752307623077230782307923080230812308223083230842308523086230872308823089230902309123092230932309423095230962309723098230992310023101231022310323104231052310623107231082310923110231112311223113231142311523116231172311823119231202312123122231232312423125231262312723128231292313023131231322313323134231352313623137231382313923140231412314223143231442314523146231472314823149231502315123152231532315423155231562315723158231592316023161231622316323164231652316623167231682316923170231712317223173231742317523176231772317823179231802318123182231832318423185231862318723188231892319023191231922319323194231952319623197231982319923200232012320223203232042320523206232072320823209232102321123212232132321423215232162321723218232192322023221232222322323224232252322623227232282322923230232312323223233232342323523236232372323823239232402324123242232432324423245232462324723248232492325023251232522325323254232552325623257232582325923260232612326223263232642326523266232672326823269232702327123272232732327423275232762327723278232792328023281232822328323284232852328623287232882328923290232912329223293232942329523296232972329823299233002330123302233032330423305233062330723308233092331023311233122331323314233152331623317233182331923320233212332223323233242332523326233272332823329233302333123332233332333423335233362333723338233392334023341233422334323344233452334623347233482334923350233512335223353233542335523356233572335823359233602336123362233632336423365233662336723368233692337023371233722337323374233752337623377233782337923380233812338223383233842338523386233872338823389233902339123392233932339423395233962339723398233992340023401234022340323404234052340623407234082340923410234112341223413234142341523416234172341823419234202342123422234232342423425234262342723428234292343023431234322343323434234352343623437234382343923440234412344223443234442344523446234472344823449234502345123452234532345423455234562345723458234592346023461234622346323464234652346623467234682346923470234712347223473234742347523476234772347823479234802348123482234832348423485234862348723488234892349023491234922349323494234952349623497234982349923500235012350223503235042350523506235072350823509235102351123512235132351423515235162351723518235192352023521235222352323524235252352623527235282352923530235312353223533235342353523536235372353823539235402354123542235432354423545235462354723548235492355023551235522355323554235552355623557235582355923560235612356223563235642356523566235672356823569235702357123572235732357423575235762357723578235792358023581235822358323584235852358623587235882358923590235912359223593235942359523596235972359823599236002360123602236032360423605236062360723608236092361023611236122361323614236152361623617236182361923620236212362223623236242362523626236272362823629236302363123632236332363423635236362363723638236392364023641236422364323644236452364623647236482364923650236512365223653236542365523656236572365823659236602366123662236632366423665236662366723668236692367023671236722367323674236752367623677236782367923680236812368223683236842368523686236872368823689236902369123692236932369423695236962369723698236992370023701237022370323704237052370623707237082370923710237112371223713237142371523716237172371823719237202372123722237232372423725237262372723728237292373023731237322373323734237352373623737237382373923740237412374223743237442374523746237472374823749237502375123752237532375423755237562375723758237592376023761237622376323764237652376623767237682376923770237712377223773237742377523776237772377823779237802378123782237832378423785237862378723788237892379023791237922379323794237952379623797237982379923800238012380223803238042380523806238072380823809238102381123812238132381423815238162381723818238192382023821238222382323824238252382623827238282382923830238312383223833238342383523836238372383823839238402384123842238432384423845238462384723848238492385023851238522385323854238552385623857238582385923860238612386223863238642386523866238672386823869238702387123872238732387423875238762387723878238792388023881238822388323884238852388623887238882388923890238912389223893238942389523896238972389823899239002390123902239032390423905239062390723908239092391023911239122391323914239152391623917239182391923920239212392223923239242392523926239272392823929239302393123932239332393423935239362393723938239392394023941239422394323944239452394623947239482394923950239512395223953239542395523956239572395823959239602396123962239632396423965239662396723968239692397023971239722397323974239752397623977239782397923980239812398223983239842398523986239872398823989239902399123992239932399423995239962399723998239992400024001240022400324004240052400624007240082400924010240112401224013240142401524016240172401824019240202402124022240232402424025240262402724028240292403024031240322403324034240352403624037240382403924040240412404224043240442404524046240472404824049240502405124052240532405424055240562405724058240592406024061240622406324064240652406624067240682406924070240712407224073240742407524076240772407824079240802408124082240832408424085240862408724088240892409024091240922409324094240952409624097240982409924100241012410224103241042410524106241072410824109241102411124112241132411424115241162411724118241192412024121241222412324124241252412624127241282412924130241312413224133241342413524136241372413824139241402414124142241432414424145241462414724148241492415024151241522415324154241552415624157241582415924160241612416224163241642416524166241672416824169241702417124172241732417424175241762417724178241792418024181241822418324184241852418624187241882418924190241912419224193241942419524196241972419824199242002420124202242032420424205242062420724208242092421024211242122421324214242152421624217242182421924220242212422224223242242422524226242272422824229242302423124232242332423424235242362423724238242392424024241242422424324244242452424624247242482424924250242512425224253242542425524256242572425824259242602426124262242632426424265242662426724268242692427024271242722427324274242752427624277242782427924280242812428224283242842428524286242872428824289242902429124292242932429424295242962429724298242992430024301243022430324304243052430624307243082430924310243112431224313243142431524316243172431824319243202432124322243232432424325243262432724328243292433024331243322433324334243352433624337243382433924340243412434224343243442434524346243472434824349243502435124352243532435424355243562435724358243592436024361243622436324364243652436624367243682436924370243712437224373243742437524376243772437824379243802438124382243832438424385243862438724388243892439024391243922439324394243952439624397243982439924400244012440224403244042440524406244072440824409244102441124412244132441424415244162441724418244192442024421244222442324424244252442624427244282442924430244312443224433244342443524436244372443824439244402444124442244432444424445244462444724448244492445024451244522445324454244552445624457244582445924460244612446224463244642446524466244672446824469244702447124472244732447424475244762447724478244792448024481244822448324484244852448624487244882448924490244912449224493244942449524496244972449824499245002450124502245032450424505245062450724508245092451024511245122451324514245152451624517245182451924520245212452224523245242452524526245272452824529245302453124532245332453424535245362453724538245392454024541245422454324544245452454624547245482454924550245512455224553245542455524556245572455824559245602456124562245632456424565245662456724568245692457024571245722457324574245752457624577245782457924580245812458224583245842458524586245872458824589245902459124592245932459424595245962459724598245992460024601246022460324604246052460624607246082460924610246112461224613246142461524616246172461824619246202462124622246232462424625246262462724628246292463024631246322463324634246352463624637246382463924640246412464224643246442464524646246472464824649246502465124652246532465424655246562465724658246592466024661246622466324664246652466624667246682466924670246712467224673246742467524676246772467824679246802468124682246832468424685246862468724688246892469024691246922469324694246952469624697246982469924700247012470224703247042470524706247072470824709247102471124712247132471424715247162471724718247192472024721247222472324724247252472624727247282472924730247312473224733247342473524736247372473824739247402474124742247432474424745247462474724748247492475024751247522475324754247552475624757247582475924760247612476224763247642476524766247672476824769247702477124772247732477424775247762477724778247792478024781247822478324784247852478624787247882478924790247912479224793247942479524796247972479824799248002480124802248032480424805248062480724808248092481024811248122481324814248152481624817248182481924820248212482224823248242482524826248272482824829248302483124832248332483424835248362483724838248392484024841248422484324844248452484624847248482484924850248512485224853248542485524856248572485824859248602486124862248632486424865248662486724868248692487024871248722487324874248752487624877248782487924880248812488224883248842488524886248872488824889248902489124892248932489424895248962489724898248992490024901249022490324904249052490624907249082490924910249112491224913249142491524916249172491824919249202492124922249232492424925249262492724928249292493024931249322493324934249352493624937249382493924940249412494224943249442494524946249472494824949249502495124952249532495424955249562495724958249592496024961249622496324964249652496624967249682496924970249712497224973249742497524976249772497824979249802498124982249832498424985249862498724988249892499024991249922499324994249952499624997249982499925000250012500225003250042500525006250072500825009250102501125012250132501425015250162501725018250192502025021250222502325024250252502625027250282502925030250312503225033250342503525036250372503825039250402504125042250432504425045250462504725048250492505025051250522505325054250552505625057250582505925060250612506225063250642506525066250672506825069250702507125072250732507425075250762507725078250792508025081250822508325084250852508625087250882508925090250912509225093250942509525096250972509825099251002510125102251032510425105251062510725108251092511025111251122511325114251152511625117251182511925120251212512225123251242512525126251272512825129251302513125132251332513425135251362513725138251392514025141251422514325144251452514625147251482514925150251512515225153251542515525156251572515825159251602516125162251632516425165251662516725168251692517025171251722517325174251752517625177251782517925180251812518225183251842518525186251872518825189251902519125192251932519425195251962519725198251992520025201252022520325204252052520625207252082520925210252112521225213252142521525216252172521825219252202522125222252232522425225252262522725228252292523025231252322523325234252352523625237252382523925240252412524225243252442524525246252472524825249252502525125252252532525425255252562525725258252592526025261252622526325264252652526625267252682526925270252712527225273252742527525276252772527825279252802528125282252832528425285252862528725288252892529025291252922529325294252952529625297252982529925300253012530225303253042530525306253072530825309253102531125312253132531425315253162531725318253192532025321253222532325324253252532625327253282532925330253312533225333253342533525336253372533825339253402534125342253432534425345253462534725348253492535025351253522535325354253552535625357253582535925360253612536225363253642536525366253672536825369253702537125372253732537425375253762537725378253792538025381253822538325384253852538625387253882538925390253912539225393253942539525396253972539825399254002540125402254032540425405254062540725408254092541025411254122541325414254152541625417254182541925420254212542225423254242542525426254272542825429254302543125432254332543425435254362543725438254392544025441254422544325444254452544625447254482544925450254512545225453254542545525456254572545825459254602546125462254632546425465254662546725468254692547025471254722547325474254752547625477254782547925480254812548225483254842548525486254872548825489254902549125492254932549425495254962549725498254992550025501255022550325504255052550625507255082550925510255112551225513255142551525516255172551825519255202552125522255232552425525255262552725528255292553025531255322553325534255352553625537255382553925540255412554225543255442554525546255472554825549255502555125552255532555425555255562555725558255592556025561255622556325564255652556625567255682556925570255712557225573255742557525576255772557825579255802558125582255832558425585255862558725588255892559025591255922559325594255952559625597255982559925600256012560225603256042560525606256072560825609256102561125612256132561425615256162561725618256192562025621256222562325624256252562625627256282562925630256312563225633256342563525636256372563825639256402564125642256432564425645256462564725648256492565025651256522565325654256552565625657256582565925660256612566225663256642566525666256672566825669256702567125672256732567425675256762567725678256792568025681256822568325684256852568625687256882568925690256912569225693256942569525696256972569825699257002570125702257032570425705257062570725708257092571025711257122571325714257152571625717257182571925720257212572225723257242572525726257272572825729257302573125732257332573425735257362573725738257392574025741257422574325744257452574625747257482574925750257512575225753257542575525756257572575825759257602576125762257632576425765257662576725768257692577025771257722577325774257752577625777257782577925780257812578225783257842578525786257872578825789257902579125792257932579425795257962579725798257992580025801258022580325804258052580625807258082580925810258112581225813258142581525816258172581825819258202582125822258232582425825258262582725828258292583025831258322583325834258352583625837258382583925840258412584225843258442584525846258472584825849258502585125852258532585425855258562585725858258592586025861258622586325864258652586625867258682586925870258712587225873258742587525876258772587825879258802588125882258832588425885258862588725888258892589025891258922589325894258952589625897258982589925900259012590225903259042590525906259072590825909259102591125912259132591425915259162591725918259192592025921259222592325924259252592625927259282592925930259312593225933259342593525936259372593825939259402594125942259432594425945259462594725948259492595025951259522595325954259552595625957259582595925960259612596225963259642596525966259672596825969259702597125972259732597425975259762597725978259792598025981259822598325984259852598625987259882598925990259912599225993259942599525996259972599825999260002600126002260032600426005260062600726008260092601026011260122601326014260152601626017260182601926020260212602226023260242602526026260272602826029260302603126032260332603426035260362603726038260392604026041260422604326044260452604626047260482604926050260512605226053260542605526056260572605826059260602606126062260632606426065260662606726068260692607026071260722607326074260752607626077260782607926080260812608226083260842608526086260872608826089260902609126092260932609426095260962609726098260992610026101261022610326104261052610626107261082610926110261112611226113261142611526116261172611826119261202612126122261232612426125261262612726128261292613026131261322613326134261352613626137261382613926140261412614226143261442614526146261472614826149261502615126152261532615426155261562615726158261592616026161261622616326164261652616626167261682616926170261712617226173261742617526176261772617826179261802618126182261832618426185261862618726188261892619026191261922619326194261952619626197261982619926200262012620226203262042620526206262072620826209262102621126212262132621426215262162621726218262192622026221262222622326224262252622626227262282622926230262312623226233262342623526236262372623826239262402624126242262432624426245262462624726248262492625026251262522625326254262552625626257262582625926260262612626226263262642626526266262672626826269262702627126272262732627426275262762627726278262792628026281262822628326284262852628626287262882628926290262912629226293262942629526296262972629826299263002630126302263032630426305263062630726308263092631026311263122631326314263152631626317263182631926320263212632226323263242632526326263272632826329263302633126332263332633426335263362633726338263392634026341263422634326344263452634626347263482634926350263512635226353263542635526356263572635826359263602636126362263632636426365263662636726368263692637026371263722637326374263752637626377263782637926380263812638226383263842638526386263872638826389263902639126392263932639426395263962639726398263992640026401264022640326404264052640626407264082640926410264112641226413264142641526416264172641826419264202642126422264232642426425264262642726428264292643026431264322643326434264352643626437264382643926440264412644226443264442644526446264472644826449264502645126452264532645426455264562645726458264592646026461264622646326464264652646626467264682646926470264712647226473264742647526476264772647826479264802648126482264832648426485264862648726488264892649026491264922649326494264952649626497264982649926500265012650226503265042650526506265072650826509265102651126512265132651426515265162651726518265192652026521265222652326524265252652626527265282652926530265312653226533265342653526536265372653826539265402654126542265432654426545265462654726548265492655026551265522655326554265552655626557265582655926560265612656226563265642656526566265672656826569265702657126572265732657426575265762657726578265792658026581265822658326584265852658626587265882658926590265912659226593265942659526596265972659826599266002660126602266032660426605266062660726608266092661026611266122661326614266152661626617266182661926620266212662226623266242662526626266272662826629266302663126632266332663426635266362663726638266392664026641266422664326644266452664626647266482664926650266512665226653266542665526656266572665826659266602666126662266632666426665266662666726668266692667026671266722667326674266752667626677266782667926680266812668226683266842668526686266872668826689266902669126692266932669426695266962669726698266992670026701267022670326704267052670626707267082670926710267112671226713267142671526716267172671826719267202672126722267232672426725267262672726728267292673026731267322673326734267352673626737267382673926740267412674226743267442674526746267472674826749267502675126752267532675426755267562675726758267592676026761267622676326764267652676626767267682676926770267712677226773267742677526776267772677826779267802678126782267832678426785267862678726788267892679026791267922679326794267952679626797267982679926800268012680226803268042680526806268072680826809268102681126812268132681426815268162681726818268192682026821268222682326824268252682626827268282682926830268312683226833268342683526836268372683826839268402684126842268432684426845268462684726848268492685026851268522685326854268552685626857268582685926860268612686226863268642686526866268672686826869268702687126872268732687426875268762687726878268792688026881268822688326884268852688626887268882688926890268912689226893268942689526896268972689826899269002690126902269032690426905269062690726908269092691026911269122691326914269152691626917269182691926920269212692226923269242692526926269272692826929269302693126932269332693426935269362693726938269392694026941269422694326944269452694626947269482694926950269512695226953269542695526956269572695826959269602696126962269632696426965269662696726968269692697026971269722697326974269752697626977269782697926980269812698226983269842698526986269872698826989269902699126992269932699426995269962699726998269992700027001270022700327004270052700627007270082700927010270112701227013270142701527016270172701827019270202702127022270232702427025270262702727028270292703027031270322703327034270352703627037270382703927040270412704227043270442704527046270472704827049270502705127052270532705427055270562705727058270592706027061270622706327064270652706627067270682706927070270712707227073270742707527076270772707827079270802708127082270832708427085270862708727088270892709027091270922709327094270952709627097270982709927100271012710227103271042710527106271072710827109271102711127112271132711427115271162711727118271192712027121271222712327124271252712627127271282712927130271312713227133271342713527136271372713827139271402714127142271432714427145271462714727148271492715027151271522715327154271552715627157271582715927160271612716227163271642716527166271672716827169271702717127172271732717427175271762717727178271792718027181271822718327184271852718627187271882718927190271912719227193271942719527196271972719827199272002720127202272032720427205272062720727208272092721027211272122721327214272152721627217272182721927220272212722227223272242722527226272272722827229272302723127232272332723427235272362723727238272392724027241272422724327244272452724627247272482724927250272512725227253272542725527256272572725827259272602726127262272632726427265272662726727268272692727027271272722727327274272752727627277272782727927280272812728227283272842728527286272872728827289272902729127292272932729427295272962729727298272992730027301273022730327304273052730627307273082730927310273112731227313273142731527316273172731827319273202732127322273232732427325273262732727328273292733027331273322733327334273352733627337273382733927340273412734227343273442734527346273472734827349273502735127352273532735427355273562735727358273592736027361273622736327364273652736627367273682736927370273712737227373273742737527376273772737827379273802738127382273832738427385273862738727388273892739027391273922739327394273952739627397273982739927400274012740227403274042740527406274072740827409274102741127412274132741427415274162741727418274192742027421274222742327424274252742627427274282742927430274312743227433274342743527436274372743827439274402744127442274432744427445274462744727448274492745027451274522745327454274552745627457274582745927460274612746227463274642746527466274672746827469274702747127472274732747427475274762747727478274792748027481274822748327484274852748627487274882748927490274912749227493274942749527496274972749827499275002750127502275032750427505275062750727508275092751027511275122751327514275152751627517275182751927520275212752227523275242752527526275272752827529275302753127532275332753427535275362753727538275392754027541275422754327544275452754627547275482754927550275512755227553275542755527556275572755827559275602756127562275632756427565275662756727568275692757027571275722757327574275752757627577275782757927580275812758227583275842758527586275872758827589275902759127592275932759427595275962759727598275992760027601276022760327604276052760627607276082760927610276112761227613276142761527616276172761827619276202762127622276232762427625276262762727628276292763027631276322763327634276352763627637276382763927640276412764227643276442764527646276472764827649276502765127652276532765427655276562765727658276592766027661276622766327664276652766627667276682766927670276712767227673276742767527676276772767827679276802768127682276832768427685276862768727688276892769027691276922769327694276952769627697276982769927700277012770227703277042770527706277072770827709277102771127712277132771427715277162771727718277192772027721277222772327724277252772627727277282772927730277312773227733277342773527736277372773827739277402774127742277432774427745277462774727748277492775027751277522775327754277552775627757277582775927760277612776227763277642776527766277672776827769277702777127772277732777427775277762777727778277792778027781277822778327784277852778627787277882778927790277912779227793277942779527796277972779827799278002780127802278032780427805278062780727808278092781027811278122781327814278152781627817278182781927820278212782227823278242782527826278272782827829278302783127832278332783427835278362783727838278392784027841278422784327844278452784627847278482784927850278512785227853278542785527856278572785827859278602786127862278632786427865278662786727868278692787027871278722787327874278752787627877278782787927880278812788227883278842788527886278872788827889278902789127892278932789427895278962789727898278992790027901279022790327904279052790627907279082790927910279112791227913279142791527916279172791827919279202792127922279232792427925279262792727928279292793027931279322793327934279352793627937279382793927940279412794227943279442794527946279472794827949279502795127952279532795427955279562795727958279592796027961279622796327964279652796627967279682796927970279712797227973279742797527976279772797827979279802798127982279832798427985279862798727988279892799027991279922799327994279952799627997279982799928000280012800228003280042800528006280072800828009280102801128012280132801428015280162801728018280192802028021280222802328024280252802628027280282802928030280312803228033280342803528036280372803828039280402804128042280432804428045280462804728048280492805028051280522805328054280552805628057280582805928060280612806228063280642806528066280672806828069280702807128072280732807428075280762807728078280792808028081280822808328084280852808628087280882808928090280912809228093280942809528096280972809828099281002810128102281032810428105281062810728108281092811028111281122811328114281152811628117281182811928120281212812228123281242812528126281272812828129281302813128132281332813428135281362813728138281392814028141281422814328144281452814628147281482814928150281512815228153281542815528156281572815828159281602816128162281632816428165281662816728168281692817028171281722817328174281752817628177281782817928180281812818228183281842818528186281872818828189281902819128192281932819428195281962819728198281992820028201282022820328204282052820628207282082820928210282112821228213282142821528216282172821828219282202822128222282232822428225282262822728228282292823028231282322823328234282352823628237282382823928240282412824228243282442824528246282472824828249282502825128252282532825428255282562825728258282592826028261282622826328264282652826628267282682826928270282712827228273282742827528276282772827828279282802828128282282832828428285282862828728288282892829028291282922829328294282952829628297282982829928300283012830228303283042830528306283072830828309283102831128312283132831428315283162831728318283192832028321283222832328324283252832628327283282832928330283312833228333283342833528336283372833828339283402834128342283432834428345283462834728348283492835028351283522835328354283552835628357283582835928360283612836228363283642836528366283672836828369283702837128372283732837428375283762837728378283792838028381283822838328384283852838628387283882838928390283912839228393283942839528396283972839828399284002840128402284032840428405284062840728408284092841028411284122841328414284152841628417284182841928420284212842228423284242842528426284272842828429284302843128432284332843428435284362843728438284392844028441284422844328444284452844628447284482844928450284512845228453284542845528456284572845828459284602846128462284632846428465284662846728468284692847028471284722847328474284752847628477284782847928480284812848228483284842848528486284872848828489284902849128492284932849428495284962849728498284992850028501285022850328504285052850628507285082850928510285112851228513285142851528516285172851828519285202852128522285232852428525285262852728528285292853028531285322853328534285352853628537285382853928540285412854228543285442854528546285472854828549285502855128552285532855428555285562855728558285592856028561285622856328564285652856628567285682856928570285712857228573285742857528576285772857828579285802858128582285832858428585285862858728588285892859028591285922859328594285952859628597285982859928600286012860228603286042860528606286072860828609286102861128612286132861428615286162861728618286192862028621286222862328624286252862628627286282862928630286312863228633286342863528636286372863828639286402864128642286432864428645286462864728648286492865028651286522865328654286552865628657286582865928660286612866228663286642866528666286672866828669286702867128672286732867428675286762867728678286792868028681286822868328684286852868628687286882868928690286912869228693286942869528696286972869828699287002870128702287032870428705287062870728708287092871028711287122871328714287152871628717287182871928720287212872228723287242872528726287272872828729287302873128732287332873428735287362873728738287392874028741287422874328744287452874628747287482874928750287512875228753287542875528756287572875828759287602876128762287632876428765287662876728768287692877028771287722877328774287752877628777287782877928780287812878228783287842878528786287872878828789287902879128792287932879428795287962879728798287992880028801288022880328804288052880628807288082880928810288112881228813288142881528816288172881828819288202882128822288232882428825288262882728828288292883028831288322883328834288352883628837288382883928840288412884228843288442884528846288472884828849288502885128852288532885428855288562885728858288592886028861288622886328864288652886628867288682886928870288712887228873288742887528876288772887828879288802888128882288832888428885288862888728888288892889028891288922889328894288952889628897288982889928900289012890228903289042890528906289072890828909289102891128912289132891428915289162891728918289192892028921289222892328924289252892628927289282892928930289312893228933289342893528936289372893828939289402894128942289432894428945289462894728948289492895028951289522895328954289552895628957289582895928960289612896228963289642896528966289672896828969289702897128972289732897428975289762897728978289792898028981289822898328984289852898628987289882898928990289912899228993289942899528996289972899828999290002900129002290032900429005290062900729008290092901029011290122901329014290152901629017290182901929020290212902229023290242902529026290272902829029290302903129032290332903429035290362903729038290392904029041290422904329044290452904629047290482904929050290512905229053290542905529056290572905829059290602906129062290632906429065290662906729068290692907029071290722907329074290752907629077290782907929080290812908229083290842908529086290872908829089290902909129092290932909429095290962909729098290992910029101291022910329104291052910629107291082910929110291112911229113291142911529116291172911829119291202912129122291232912429125291262912729128291292913029131291322913329134291352913629137291382913929140291412914229143291442914529146291472914829149291502915129152291532915429155291562915729158291592916029161291622916329164291652916629167291682916929170291712917229173291742917529176291772917829179291802918129182291832918429185291862918729188291892919029191291922919329194291952919629197291982919929200292012920229203292042920529206292072920829209292102921129212292132921429215292162921729218292192922029221292222922329224292252922629227292282922929230292312923229233292342923529236292372923829239292402924129242292432924429245292462924729248292492925029251292522925329254292552925629257292582925929260292612926229263292642926529266292672926829269292702927129272292732927429275292762927729278292792928029281292822928329284292852928629287292882928929290292912929229293292942929529296292972929829299293002930129302293032930429305293062930729308293092931029311293122931329314293152931629317293182931929320293212932229323293242932529326293272932829329293302933129332293332933429335293362933729338293392934029341293422934329344293452934629347293482934929350293512935229353293542935529356293572935829359293602936129362293632936429365293662936729368293692937029371293722937329374293752937629377293782937929380293812938229383293842938529386293872938829389293902939129392293932939429395293962939729398293992940029401294022940329404294052940629407294082940929410294112941229413294142941529416294172941829419294202942129422294232942429425294262942729428294292943029431294322943329434294352943629437294382943929440294412944229443294442944529446294472944829449294502945129452294532945429455294562945729458294592946029461294622946329464294652946629467294682946929470294712947229473294742947529476294772947829479294802948129482294832948429485294862948729488294892949029491294922949329494294952949629497294982949929500295012950229503295042950529506295072950829509295102951129512295132951429515295162951729518295192952029521295222952329524295252952629527295282952929530295312953229533295342953529536295372953829539295402954129542295432954429545295462954729548295492955029551295522955329554295552955629557295582955929560295612956229563295642956529566295672956829569295702957129572295732957429575295762957729578295792958029581295822958329584295852958629587295882958929590295912959229593295942959529596295972959829599296002960129602296032960429605296062960729608296092961029611296122961329614296152961629617296182961929620296212962229623296242962529626296272962829629296302963129632296332963429635296362963729638296392964029641296422964329644296452964629647296482964929650296512965229653296542965529656296572965829659296602966129662296632966429665296662966729668296692967029671296722967329674296752967629677296782967929680296812968229683296842968529686296872968829689296902969129692296932969429695296962969729698296992970029701297022970329704297052970629707297082970929710297112971229713297142971529716297172971829719297202972129722297232972429725297262972729728297292973029731297322973329734297352973629737297382973929740297412974229743297442974529746297472974829749297502975129752297532975429755297562975729758297592976029761297622976329764297652976629767297682976929770297712977229773297742977529776297772977829779297802978129782297832978429785297862978729788297892979029791297922979329794297952979629797297982979929800298012980229803298042980529806298072980829809298102981129812298132981429815298162981729818298192982029821298222982329824298252982629827298282982929830298312983229833298342983529836298372983829839298402984129842298432984429845298462984729848298492985029851298522985329854298552985629857298582985929860298612986229863298642986529866298672986829869298702987129872298732987429875298762987729878298792988029881298822988329884298852988629887298882988929890298912989229893298942989529896298972989829899299002990129902299032990429905299062990729908299092991029911299122991329914299152991629917299182991929920299212992229923299242992529926299272992829929299302993129932299332993429935299362993729938299392994029941299422994329944299452994629947299482994929950299512995229953299542995529956299572995829959299602996129962299632996429965299662996729968299692997029971299722997329974299752997629977299782997929980299812998229983299842998529986299872998829989299902999129992299932999429995299962999729998299993000030001300023000330004300053000630007300083000930010300113001230013300143001530016300173001830019300203002130022300233002430025300263002730028300293003030031300323003330034300353003630037300383003930040300413004230043300443004530046300473004830049300503005130052300533005430055300563005730058300593006030061300623006330064300653006630067300683006930070300713007230073300743007530076300773007830079300803008130082300833008430085300863008730088300893009030091300923009330094300953009630097300983009930100301013010230103301043010530106301073010830109301103011130112301133011430115301163011730118301193012030121301223012330124301253012630127301283012930130301313013230133301343013530136301373013830139301403014130142301433014430145301463014730148301493015030151301523015330154301553015630157301583015930160301613016230163301643016530166301673016830169301703017130172301733017430175301763017730178301793018030181301823018330184301853018630187301883018930190301913019230193301943019530196301973019830199302003020130202302033020430205302063020730208302093021030211302123021330214302153021630217302183021930220302213022230223302243022530226302273022830229302303023130232302333023430235302363023730238302393024030241302423024330244302453024630247302483024930250302513025230253302543025530256302573025830259302603026130262302633026430265302663026730268302693027030271302723027330274302753027630277302783027930280302813028230283302843028530286302873028830289302903029130292302933029430295302963029730298302993030030301303023030330304303053030630307303083030930310303113031230313303143031530316303173031830319303203032130322303233032430325303263032730328303293033030331303323033330334303353033630337303383033930340303413034230343303443034530346303473034830349303503035130352303533035430355303563035730358303593036030361303623036330364303653036630367303683036930370303713037230373303743037530376303773037830379303803038130382303833038430385303863038730388303893039030391303923039330394303953039630397303983039930400304013040230403304043040530406304073040830409304103041130412304133041430415304163041730418304193042030421304223042330424304253042630427304283042930430304313043230433304343043530436304373043830439304403044130442304433044430445304463044730448304493045030451304523045330454304553045630457304583045930460304613046230463304643046530466304673046830469304703047130472304733047430475304763047730478304793048030481304823048330484304853048630487304883048930490304913049230493304943049530496304973049830499305003050130502305033050430505305063050730508305093051030511305123051330514305153051630517305183051930520305213052230523305243052530526305273052830529305303053130532305333053430535305363053730538305393054030541305423054330544305453054630547305483054930550305513055230553305543055530556305573055830559305603056130562305633056430565305663056730568305693057030571305723057330574305753057630577305783057930580305813058230583305843058530586305873058830589305903059130592305933059430595305963059730598305993060030601306023060330604306053060630607306083060930610306113061230613306143061530616306173061830619306203062130622306233062430625306263062730628306293063030631306323063330634306353063630637306383063930640306413064230643306443064530646306473064830649306503065130652306533065430655306563065730658306593066030661306623066330664306653066630667306683066930670306713067230673306743067530676306773067830679306803068130682306833068430685306863068730688306893069030691306923069330694306953069630697306983069930700307013070230703307043070530706307073070830709307103071130712307133071430715307163071730718307193072030721307223072330724307253072630727307283072930730307313073230733307343073530736307373073830739307403074130742307433074430745307463074730748307493075030751307523075330754307553075630757307583075930760307613076230763307643076530766307673076830769307703077130772307733077430775307763077730778307793078030781307823078330784307853078630787307883078930790307913079230793307943079530796307973079830799308003080130802308033080430805308063080730808308093081030811308123081330814308153081630817308183081930820308213082230823308243082530826308273082830829308303083130832308333083430835308363083730838308393084030841308423084330844308453084630847308483084930850308513085230853308543085530856308573085830859308603086130862308633086430865308663086730868308693087030871308723087330874308753087630877308783087930880308813088230883308843088530886308873088830889308903089130892308933089430895308963089730898308993090030901309023090330904309053090630907309083090930910309113091230913309143091530916309173091830919309203092130922309233092430925309263092730928309293093030931309323093330934309353093630937309383093930940309413094230943309443094530946309473094830949309503095130952309533095430955309563095730958309593096030961309623096330964309653096630967309683096930970309713097230973309743097530976309773097830979309803098130982309833098430985309863098730988309893099030991309923099330994309953099630997309983099931000310013100231003310043100531006310073100831009310103101131012310133101431015310163101731018310193102031021310223102331024310253102631027310283102931030310313103231033310343103531036310373103831039310403104131042310433104431045310463104731048310493105031051310523105331054310553105631057310583105931060310613106231063310643106531066310673106831069310703107131072310733107431075310763107731078310793108031081310823108331084310853108631087310883108931090310913109231093310943109531096310973109831099311003110131102311033110431105311063110731108311093111031111311123111331114311153111631117311183111931120311213112231123311243112531126311273112831129311303113131132311333113431135311363113731138311393114031141311423114331144311453114631147311483114931150311513115231153311543115531156311573115831159311603116131162311633116431165311663116731168311693117031171311723117331174311753117631177311783117931180311813118231183311843118531186311873118831189311903119131192311933119431195311963119731198311993120031201312023120331204312053120631207312083120931210312113121231213312143121531216312173121831219312203122131222312233122431225312263122731228312293123031231312323123331234312353123631237312383123931240312413124231243312443124531246312473124831249312503125131252312533125431255312563125731258312593126031261312623126331264312653126631267312683126931270312713127231273312743127531276312773127831279312803128131282312833128431285312863128731288312893129031291312923129331294312953129631297312983129931300313013130231303313043130531306313073130831309313103131131312313133131431315313163131731318313193132031321313223132331324313253132631327313283132931330313313133231333313343133531336313373133831339313403134131342313433134431345313463134731348313493135031351313523135331354313553135631357313583135931360313613136231363313643136531366313673136831369313703137131372313733137431375313763137731378313793138031381313823138331384313853138631387313883138931390313913139231393313943139531396313973139831399314003140131402314033140431405314063140731408314093141031411314123141331414314153141631417314183141931420314213142231423314243142531426314273142831429314303143131432314333143431435314363143731438314393144031441314423144331444314453144631447314483144931450314513145231453314543145531456314573145831459314603146131462314633146431465314663146731468314693147031471314723147331474314753147631477314783147931480314813148231483314843148531486314873148831489314903149131492314933149431495314963149731498314993150031501315023150331504315053150631507315083150931510315113151231513315143151531516315173151831519315203152131522315233152431525315263152731528315293153031531315323153331534315353153631537315383153931540315413154231543315443154531546315473154831549315503155131552315533155431555315563155731558315593156031561315623156331564315653156631567315683156931570315713157231573315743157531576315773157831579315803158131582315833158431585315863158731588315893159031591315923159331594315953159631597315983159931600316013160231603316043160531606316073160831609316103161131612316133161431615316163161731618316193162031621316223162331624316253162631627316283162931630316313163231633316343163531636316373163831639316403164131642316433164431645316463164731648316493165031651316523165331654316553165631657316583165931660316613166231663316643166531666316673166831669316703167131672316733167431675316763167731678316793168031681316823168331684316853168631687316883168931690316913169231693316943169531696316973169831699317003170131702317033170431705317063170731708317093171031711317123171331714317153171631717317183171931720317213172231723317243172531726317273172831729317303173131732317333173431735317363173731738317393174031741317423174331744317453174631747317483174931750317513175231753317543175531756317573175831759317603176131762317633176431765317663176731768317693177031771317723177331774317753177631777317783177931780317813178231783317843178531786317873178831789317903179131792317933179431795317963179731798317993180031801318023180331804318053180631807318083180931810318113181231813318143181531816318173181831819318203182131822318233182431825318263182731828318293183031831318323183331834318353183631837318383183931840318413184231843318443184531846318473184831849318503185131852318533185431855318563185731858318593186031861318623186331864318653186631867318683186931870318713187231873318743187531876318773187831879318803188131882318833188431885318863188731888318893189031891318923189331894318953189631897318983189931900319013190231903319043190531906319073190831909319103191131912319133191431915319163191731918319193192031921319223192331924319253192631927319283192931930319313193231933319343193531936319373193831939319403194131942319433194431945319463194731948319493195031951319523195331954319553195631957319583195931960319613196231963319643196531966319673196831969319703197131972319733197431975319763197731978319793198031981319823198331984319853198631987319883198931990319913199231993319943199531996319973199831999320003200132002320033200432005320063200732008320093201032011320123201332014320153201632017320183201932020320213202232023320243202532026320273202832029320303203132032320333203432035320363203732038320393204032041320423204332044320453204632047320483204932050320513205232053320543205532056320573205832059320603206132062320633206432065320663206732068320693207032071320723207332074320753207632077320783207932080320813208232083320843208532086320873208832089320903209132092320933209432095320963209732098320993210032101321023210332104321053210632107321083210932110321113211232113321143211532116321173211832119321203212132122321233212432125321263212732128321293213032131321323213332134321353213632137321383213932140321413214232143321443214532146321473214832149321503215132152321533215432155321563215732158321593216032161321623216332164321653216632167321683216932170321713217232173321743217532176321773217832179321803218132182321833218432185321863218732188321893219032191321923219332194321953219632197321983219932200322013220232203322043220532206322073220832209322103221132212322133221432215322163221732218322193222032221322223222332224322253222632227322283222932230322313223232233322343223532236322373223832239322403224132242322433224432245322463224732248322493225032251322523225332254322553225632257322583225932260322613226232263322643226532266322673226832269322703227132272322733227432275322763227732278322793228032281322823228332284322853228632287322883228932290322913229232293322943229532296322973229832299323003230132302323033230432305323063230732308323093231032311323123231332314323153231632317323183231932320323213232232323323243232532326323273232832329323303233132332323333233432335323363233732338323393234032341323423234332344323453234632347323483234932350323513235232353323543235532356323573235832359323603236132362323633236432365323663236732368323693237032371323723237332374323753237632377323783237932380323813238232383323843238532386323873238832389323903239132392323933239432395323963239732398323993240032401324023240332404324053240632407324083240932410324113241232413324143241532416324173241832419324203242132422324233242432425324263242732428324293243032431324323243332434324353243632437324383243932440324413244232443324443244532446324473244832449324503245132452324533245432455324563245732458324593246032461324623246332464324653246632467324683246932470324713247232473324743247532476324773247832479324803248132482324833248432485324863248732488324893249032491324923249332494324953249632497324983249932500325013250232503325043250532506325073250832509325103251132512325133251432515325163251732518325193252032521325223252332524325253252632527325283252932530325313253232533325343253532536325373253832539325403254132542325433254432545325463254732548325493255032551325523255332554325553255632557325583255932560325613256232563325643256532566325673256832569325703257132572325733257432575325763257732578325793258032581325823258332584325853258632587325883258932590325913259232593325943259532596325973259832599326003260132602326033260432605326063260732608326093261032611326123261332614326153261632617326183261932620326213262232623326243262532626326273262832629326303263132632326333263432635326363263732638326393264032641326423264332644326453264632647326483264932650326513265232653326543265532656326573265832659326603266132662326633266432665326663266732668326693267032671326723267332674326753267632677326783267932680326813268232683326843268532686326873268832689326903269132692326933269432695326963269732698326993270032701327023270332704327053270632707327083270932710327113271232713327143271532716327173271832719327203272132722327233272432725327263272732728327293273032731327323273332734327353273632737327383273932740327413274232743327443274532746327473274832749327503275132752327533275432755327563275732758327593276032761327623276332764327653276632767327683276932770327713277232773327743277532776327773277832779327803278132782327833278432785327863278732788327893279032791327923279332794327953279632797327983279932800328013280232803328043280532806328073280832809328103281132812328133281432815328163281732818328193282032821328223282332824328253282632827328283282932830328313283232833328343283532836328373283832839328403284132842328433284432845328463284732848328493285032851328523285332854328553285632857328583285932860328613286232863328643286532866328673286832869328703287132872328733287432875328763287732878328793288032881328823288332884328853288632887328883288932890328913289232893328943289532896328973289832899329003290132902329033290432905329063290732908329093291032911329123291332914329153291632917329183291932920329213292232923329243292532926329273292832929329303293132932329333293432935329363293732938329393294032941329423294332944329453294632947329483294932950329513295232953329543295532956329573295832959329603296132962329633296432965329663296732968329693297032971329723297332974329753297632977329783297932980329813298232983329843298532986329873298832989329903299132992329933299432995329963299732998329993300033001330023300333004330053300633007330083300933010330113301233013330143301533016330173301833019330203302133022330233302433025330263302733028330293303033031330323303333034330353303633037330383303933040330413304233043330443304533046330473304833049330503305133052330533305433055330563305733058330593306033061330623306333064330653306633067330683306933070330713307233073330743307533076330773307833079330803308133082330833308433085330863308733088330893309033091330923309333094330953309633097330983309933100331013310233103331043310533106331073310833109331103311133112331133311433115331163311733118331193312033121331223312333124331253312633127331283312933130331313313233133331343313533136331373313833139331403314133142331433314433145331463314733148331493315033151331523315333154331553315633157331583315933160331613316233163331643316533166331673316833169331703317133172331733317433175331763317733178331793318033181331823318333184331853318633187331883318933190331913319233193331943319533196331973319833199332003320133202332033320433205332063320733208332093321033211332123321333214332153321633217332183321933220332213322233223332243322533226332273322833229332303323133232332333323433235332363323733238332393324033241332423324333244332453324633247332483324933250332513325233253332543325533256332573325833259332603326133262332633326433265332663326733268332693327033271332723327333274332753327633277332783327933280332813328233283332843328533286332873328833289332903329133292332933329433295332963329733298332993330033301333023330333304333053330633307333083330933310333113331233313333143331533316333173331833319333203332133322333233332433325333263332733328333293333033331333323333333334333353333633337333383333933340333413334233343333443334533346333473334833349333503335133352333533335433355333563335733358333593336033361333623336333364333653336633367333683336933370333713337233373333743337533376333773337833379333803338133382333833338433385333863338733388333893339033391333923339333394333953339633397333983339933400334013340233403334043340533406334073340833409334103341133412334133341433415334163341733418334193342033421334223342333424334253342633427334283342933430334313343233433334343343533436334373343833439334403344133442334433344433445334463344733448334493345033451334523345333454334553345633457334583345933460334613346233463334643346533466334673346833469334703347133472334733347433475334763347733478334793348033481334823348333484334853348633487334883348933490334913349233493334943349533496334973349833499335003350133502335033350433505335063350733508335093351033511335123351333514335153351633517335183351933520335213352233523335243352533526335273352833529335303353133532335333353433535335363353733538335393354033541335423354333544335453354633547335483354933550335513355233553335543355533556335573355833559335603356133562335633356433565335663356733568335693357033571335723357333574335753357633577335783357933580335813358233583335843358533586335873358833589335903359133592335933359433595335963359733598335993360033601336023360333604336053360633607336083360933610336113361233613336143361533616336173361833619336203362133622336233362433625336263362733628336293363033631336323363333634336353363633637336383363933640336413364233643336443364533646336473364833649336503365133652336533365433655336563365733658336593366033661336623366333664336653366633667336683366933670336713367233673336743367533676336773367833679336803368133682336833368433685336863368733688336893369033691336923369333694336953369633697336983369933700337013370233703337043370533706337073370833709337103371133712337133371433715337163371733718337193372033721337223372333724337253372633727337283372933730337313373233733337343373533736337373373833739337403374133742337433374433745337463374733748337493375033751337523375333754337553375633757337583375933760337613376233763337643376533766337673376833769337703377133772337733377433775337763377733778337793378033781337823378333784337853378633787337883378933790337913379233793337943379533796337973379833799338003380133802338033380433805338063380733808338093381033811338123381333814338153381633817338183381933820338213382233823338243382533826338273382833829338303383133832338333383433835338363383733838338393384033841338423384333844338453384633847338483384933850338513385233853338543385533856338573385833859338603386133862338633386433865338663386733868338693387033871338723387333874338753387633877338783387933880338813388233883338843388533886338873388833889338903389133892338933389433895338963389733898338993390033901339023390333904339053390633907339083390933910339113391233913339143391533916339173391833919339203392133922339233392433925339263392733928339293393033931339323393333934339353393633937339383393933940339413394233943339443394533946339473394833949339503395133952339533395433955339563395733958339593396033961339623396333964339653396633967339683396933970339713397233973339743397533976339773397833979339803398133982339833398433985339863398733988339893399033991339923399333994339953399633997339983399934000340013400234003340043400534006340073400834009340103401134012340133401434015340163401734018340193402034021340223402334024340253402634027340283402934030340313403234033340343403534036340373403834039340403404134042340433404434045340463404734048340493405034051340523405334054340553405634057340583405934060340613406234063340643406534066340673406834069340703407134072340733407434075340763407734078340793408034081340823408334084340853408634087340883408934090340913409234093340943409534096340973409834099341003410134102341033410434105341063410734108341093411034111341123411334114341153411634117341183411934120341213412234123341243412534126341273412834129341303413134132341333413434135341363413734138341393414034141341423414334144341453414634147341483414934150341513415234153341543415534156341573415834159341603416134162341633416434165341663416734168341693417034171341723417334174341753417634177341783417934180341813418234183341843418534186341873418834189341903419134192341933419434195341963419734198341993420034201342023420334204342053420634207342083420934210342113421234213342143421534216342173421834219342203422134222342233422434225342263422734228342293423034231342323423334234342353423634237342383423934240342413424234243342443424534246342473424834249342503425134252342533425434255342563425734258342593426034261342623426334264342653426634267342683426934270342713427234273342743427534276342773427834279342803428134282342833428434285342863428734288342893429034291342923429334294342953429634297342983429934300343013430234303343043430534306343073430834309343103431134312343133431434315343163431734318343193432034321343223432334324343253432634327343283432934330343313433234333343343433534336343373433834339343403434134342343433434434345343463434734348343493435034351343523435334354343553435634357343583435934360343613436234363343643436534366343673436834369343703437134372343733437434375343763437734378343793438034381343823438334384343853438634387343883438934390343913439234393343943439534396343973439834399344003440134402344033440434405344063440734408344093441034411344123441334414344153441634417344183441934420344213442234423344243442534426344273442834429344303443134432344333443434435344363443734438344393444034441344423444334444344453444634447344483444934450344513445234453344543445534456344573445834459344603446134462344633446434465344663446734468344693447034471344723447334474344753447634477344783447934480344813448234483344843448534486344873448834489344903449134492344933449434495344963449734498344993450034501345023450334504345053450634507345083450934510345113451234513345143451534516345173451834519345203452134522345233452434525345263452734528345293453034531345323453334534345353453634537345383453934540345413454234543345443454534546345473454834549345503455134552345533455434555345563455734558345593456034561345623456334564345653456634567345683456934570345713457234573345743457534576345773457834579345803458134582345833458434585345863458734588345893459034591345923459334594345953459634597345983459934600346013460234603346043460534606346073460834609346103461134612346133461434615346163461734618346193462034621346223462334624346253462634627346283462934630346313463234633346343463534636346373463834639346403464134642346433464434645346463464734648346493465034651346523465334654346553465634657346583465934660346613466234663346643466534666346673466834669346703467134672346733467434675346763467734678346793468034681346823468334684346853468634687346883468934690346913469234693346943469534696346973469834699347003470134702347033470434705347063470734708347093471034711347123471334714347153471634717347183471934720347213472234723347243472534726347273472834729347303473134732347333473434735347363473734738347393474034741347423474334744347453474634747347483474934750347513475234753347543475534756347573475834759347603476134762347633476434765347663476734768347693477034771347723477334774347753477634777347783477934780347813478234783347843478534786347873478834789347903479134792347933479434795347963479734798347993480034801348023480334804348053480634807348083480934810348113481234813348143481534816348173481834819348203482134822348233482434825348263482734828348293483034831348323483334834348353483634837348383483934840348413484234843348443484534846348473484834849348503485134852348533485434855348563485734858348593486034861348623486334864348653486634867348683486934870348713487234873348743487534876348773487834879348803488134882348833488434885348863488734888348893489034891348923489334894348953489634897348983489934900349013490234903349043490534906349073490834909349103491134912349133491434915349163491734918349193492034921349223492334924349253492634927349283492934930349313493234933349343493534936349373493834939349403494134942349433494434945349463494734948349493495034951349523495334954349553495634957349583495934960349613496234963349643496534966349673496834969349703497134972349733497434975349763497734978349793498034981349823498334984349853498634987349883498934990349913499234993349943499534996349973499834999350003500135002350033500435005350063500735008350093501035011350123501335014350153501635017350183501935020350213502235023350243502535026350273502835029350303503135032350333503435035350363503735038350393504035041350423504335044350453504635047350483504935050350513505235053350543505535056350573505835059350603506135062350633506435065350663506735068350693507035071350723507335074350753507635077350783507935080350813508235083350843508535086350873508835089350903509135092350933509435095350963509735098350993510035101351023510335104351053510635107351083510935110351113511235113351143511535116351173511835119351203512135122351233512435125351263512735128351293513035131351323513335134351353513635137351383513935140351413514235143351443514535146351473514835149351503515135152351533515435155351563515735158351593516035161351623516335164351653516635167351683516935170351713517235173351743517535176351773517835179351803518135182351833518435185351863518735188351893519035191351923519335194351953519635197351983519935200352013520235203352043520535206352073520835209352103521135212352133521435215352163521735218352193522035221352223522335224352253522635227352283522935230352313523235233352343523535236352373523835239352403524135242352433524435245352463524735248352493525035251352523525335254352553525635257352583525935260352613526235263352643526535266352673526835269352703527135272352733527435275352763527735278352793528035281352823528335284352853528635287352883528935290352913529235293352943529535296352973529835299353003530135302353033530435305353063530735308353093531035311353123531335314353153531635317353183531935320353213532235323353243532535326353273532835329353303533135332353333533435335353363533735338353393534035341353423534335344353453534635347353483534935350353513535235353353543535535356353573535835359353603536135362353633536435365353663536735368353693537035371353723537335374353753537635377353783537935380353813538235383353843538535386353873538835389353903539135392353933539435395353963539735398353993540035401354023540335404354053540635407354083540935410354113541235413354143541535416354173541835419354203542135422354233542435425354263542735428354293543035431354323543335434354353543635437354383543935440354413544235443354443544535446354473544835449354503545135452354533545435455354563545735458354593546035461354623546335464354653546635467354683546935470354713547235473354743547535476354773547835479354803548135482354833548435485354863548735488354893549035491354923549335494354953549635497354983549935500355013550235503355043550535506355073550835509355103551135512355133551435515355163551735518355193552035521355223552335524355253552635527355283552935530355313553235533355343553535536355373553835539355403554135542355433554435545355463554735548355493555035551355523555335554355553555635557355583555935560355613556235563355643556535566355673556835569355703557135572355733557435575355763557735578355793558035581355823558335584355853558635587355883558935590355913559235593355943559535596355973559835599356003560135602356033560435605356063560735608356093561035611356123561335614356153561635617356183561935620356213562235623356243562535626356273562835629356303563135632356333563435635356363563735638356393564035641356423564335644356453564635647356483564935650356513565235653356543565535656356573565835659356603566135662356633566435665356663566735668356693567035671356723567335674356753567635677356783567935680356813568235683356843568535686356873568835689356903569135692356933569435695356963569735698356993570035701357023570335704357053570635707357083570935710357113571235713357143571535716357173571835719357203572135722357233572435725357263572735728357293573035731357323573335734357353573635737357383573935740357413574235743357443574535746357473574835749357503575135752357533575435755357563575735758357593576035761357623576335764357653576635767357683576935770357713577235773357743577535776357773577835779357803578135782357833578435785357863578735788357893579035791357923579335794357953579635797357983579935800358013580235803358043580535806358073580835809358103581135812358133581435815358163581735818358193582035821358223582335824358253582635827358283582935830358313583235833358343583535836358373583835839358403584135842358433584435845358463584735848358493585035851358523585335854358553585635857358583585935860358613586235863358643586535866358673586835869358703587135872358733587435875358763587735878358793588035881358823588335884358853588635887358883588935890358913589235893358943589535896358973589835899359003590135902359033590435905359063590735908359093591035911359123591335914359153591635917359183591935920359213592235923359243592535926359273592835929359303593135932359333593435935359363593735938359393594035941359423594335944359453594635947359483594935950359513595235953359543595535956359573595835959359603596135962359633596435965359663596735968359693597035971359723597335974359753597635977359783597935980359813598235983359843598535986359873598835989359903599135992359933599435995359963599735998359993600036001360023600336004360053600636007360083600936010360113601236013360143601536016360173601836019360203602136022360233602436025360263602736028360293603036031360323603336034360353603636037360383603936040360413604236043360443604536046360473604836049360503605136052360533605436055360563605736058360593606036061360623606336064360653606636067360683606936070360713607236073360743607536076360773607836079360803608136082360833608436085360863608736088360893609036091360923609336094360953609636097360983609936100361013610236103361043610536106361073610836109361103611136112361133611436115361163611736118361193612036121361223612336124361253612636127361283612936130361313613236133361343613536136361373613836139361403614136142361433614436145361463614736148361493615036151361523615336154361553615636157361583615936160361613616236163361643616536166361673616836169361703617136172361733617436175361763617736178361793618036181361823618336184361853618636187361883618936190361913619236193361943619536196361973619836199362003620136202362033620436205362063620736208362093621036211362123621336214362153621636217362183621936220362213622236223362243622536226362273622836229362303623136232362333623436235362363623736238362393624036241362423624336244362453624636247362483624936250362513625236253362543625536256362573625836259362603626136262362633626436265362663626736268362693627036271362723627336274362753627636277362783627936280362813628236283362843628536286362873628836289362903629136292362933629436295362963629736298362993630036301363023630336304363053630636307363083630936310363113631236313363143631536316363173631836319363203632136322363233632436325363263632736328363293633036331363323633336334363353633636337363383633936340363413634236343363443634536346363473634836349363503635136352363533635436355363563635736358363593636036361363623636336364363653636636367363683636936370363713637236373363743637536376363773637836379363803638136382363833638436385363863638736388363893639036391363923639336394363953639636397363983639936400364013640236403364043640536406364073640836409364103641136412364133641436415364163641736418364193642036421364223642336424364253642636427364283642936430364313643236433364343643536436364373643836439364403644136442364433644436445364463644736448364493645036451364523645336454364553645636457364583645936460364613646236463364643646536466364673646836469364703647136472364733647436475364763647736478364793648036481364823648336484364853648636487364883648936490364913649236493364943649536496364973649836499365003650136502365033650436505365063650736508365093651036511365123651336514365153651636517365183651936520365213652236523365243652536526365273652836529365303653136532365333653436535365363653736538365393654036541365423654336544365453654636547365483654936550365513655236553365543655536556365573655836559365603656136562365633656436565365663656736568365693657036571365723657336574365753657636577365783657936580365813658236583365843658536586365873658836589365903659136592365933659436595365963659736598365993660036601366023660336604366053660636607366083660936610366113661236613366143661536616366173661836619366203662136622366233662436625366263662736628366293663036631366323663336634366353663636637366383663936640366413664236643366443664536646366473664836649366503665136652366533665436655366563665736658366593666036661366623666336664366653666636667366683666936670366713667236673366743667536676366773667836679366803668136682366833668436685366863668736688366893669036691366923669336694366953669636697366983669936700367013670236703367043670536706367073670836709367103671136712367133671436715367163671736718367193672036721367223672336724367253672636727367283672936730367313673236733367343673536736367373673836739367403674136742367433674436745367463674736748367493675036751367523675336754367553675636757367583675936760367613676236763367643676536766367673676836769367703677136772367733677436775367763677736778367793678036781367823678336784367853678636787367883678936790367913679236793367943679536796367973679836799368003680136802368033680436805368063680736808368093681036811368123681336814368153681636817368183681936820368213682236823368243682536826368273682836829368303683136832368333683436835368363683736838368393684036841368423684336844368453684636847368483684936850368513685236853368543685536856368573685836859368603686136862368633686436865368663686736868368693687036871368723687336874368753687636877368783687936880368813688236883368843688536886368873688836889368903689136892368933689436895368963689736898368993690036901369023690336904369053690636907369083690936910369113691236913369143691536916369173691836919369203692136922369233692436925369263692736928369293693036931369323693336934369353693636937369383693936940369413694236943369443694536946369473694836949369503695136952369533695436955369563695736958369593696036961369623696336964369653696636967369683696936970369713697236973369743697536976369773697836979369803698136982369833698436985369863698736988369893699036991369923699336994369953699636997369983699937000370013700237003370043700537006370073700837009370103701137012370133701437015370163701737018370193702037021370223702337024370253702637027370283702937030370313703237033370343703537036370373703837039370403704137042370433704437045370463704737048370493705037051370523705337054370553705637057370583705937060370613706237063370643706537066370673706837069370703707137072370733707437075370763707737078370793708037081370823708337084370853708637087370883708937090370913709237093370943709537096370973709837099371003710137102371033710437105371063710737108371093711037111371123711337114371153711637117371183711937120371213712237123371243712537126371273712837129371303713137132371333713437135371363713737138371393714037141371423714337144371453714637147371483714937150371513715237153371543715537156371573715837159371603716137162371633716437165371663716737168371693717037171371723717337174371753717637177371783717937180371813718237183371843718537186371873718837189371903719137192371933719437195371963719737198371993720037201372023720337204372053720637207372083720937210372113721237213372143721537216372173721837219372203722137222372233722437225372263722737228372293723037231372323723337234372353723637237372383723937240372413724237243372443724537246372473724837249372503725137252372533725437255372563725737258372593726037261372623726337264372653726637267372683726937270372713727237273372743727537276372773727837279372803728137282372833728437285372863728737288372893729037291372923729337294372953729637297372983729937300373013730237303373043730537306373073730837309373103731137312373133731437315373163731737318373193732037321373223732337324373253732637327373283732937330373313733237333373343733537336373373733837339373403734137342373433734437345373463734737348373493735037351373523735337354373553735637357373583735937360373613736237363373643736537366373673736837369373703737137372373733737437375373763737737378373793738037381373823738337384373853738637387373883738937390373913739237393373943739537396373973739837399374003740137402374033740437405374063740737408374093741037411374123741337414374153741637417374183741937420374213742237423374243742537426374273742837429374303743137432374333743437435374363743737438374393744037441374423744337444374453744637447374483744937450374513745237453374543745537456374573745837459374603746137462374633746437465374663746737468374693747037471374723747337474374753747637477374783747937480374813748237483374843748537486374873748837489374903749137492374933749437495374963749737498374993750037501375023750337504375053750637507375083750937510375113751237513375143751537516375173751837519375203752137522375233752437525375263752737528375293753037531375323753337534375353753637537375383753937540375413754237543375443754537546375473754837549375503755137552375533755437555375563755737558375593756037561375623756337564375653756637567375683756937570375713757237573375743757537576375773757837579375803758137582375833758437585375863758737588375893759037591375923759337594375953759637597375983759937600376013760237603376043760537606376073760837609376103761137612376133761437615376163761737618376193762037621376223762337624376253762637627376283762937630376313763237633376343763537636376373763837639376403764137642376433764437645376463764737648376493765037651376523765337654376553765637657376583765937660376613766237663376643766537666376673766837669376703767137672376733767437675376763767737678376793768037681376823768337684376853768637687376883768937690376913769237693376943769537696376973769837699377003770137702377033770437705377063770737708377093771037711377123771337714377153771637717377183771937720377213772237723377243772537726377273772837729377303773137732377333773437735377363773737738377393774037741377423774337744377453774637747377483774937750377513775237753377543775537756377573775837759377603776137762377633776437765377663776737768377693777037771377723777337774377753777637777377783777937780377813778237783377843778537786377873778837789377903779137792377933779437795377963779737798377993780037801378023780337804378053780637807378083780937810378113781237813378143781537816378173781837819378203782137822378233782437825378263782737828378293783037831378323783337834378353783637837378383783937840378413784237843378443784537846378473784837849378503785137852378533785437855378563785737858378593786037861378623786337864378653786637867378683786937870378713787237873378743787537876378773787837879378803788137882378833788437885378863788737888378893789037891378923789337894378953789637897378983789937900379013790237903379043790537906379073790837909379103791137912379133791437915379163791737918379193792037921379223792337924379253792637927379283792937930379313793237933379343793537936379373793837939379403794137942379433794437945379463794737948379493795037951379523795337954379553795637957379583795937960379613796237963379643796537966379673796837969379703797137972379733797437975379763797737978379793798037981379823798337984379853798637987379883798937990379913799237993379943799537996379973799837999380003800138002380033800438005380063800738008380093801038011380123801338014380153801638017380183801938020380213802238023380243802538026380273802838029380303803138032380333803438035380363803738038380393804038041380423804338044380453804638047380483804938050380513805238053380543805538056380573805838059380603806138062380633806438065380663806738068380693807038071380723807338074380753807638077380783807938080380813808238083380843808538086380873808838089380903809138092380933809438095380963809738098380993810038101381023810338104381053810638107381083810938110381113811238113381143811538116381173811838119381203812138122381233812438125381263812738128381293813038131381323813338134381353813638137381383813938140381413814238143381443814538146381473814838149381503815138152381533815438155381563815738158381593816038161381623816338164381653816638167381683816938170381713817238173381743817538176381773817838179381803818138182381833818438185381863818738188381893819038191381923819338194381953819638197381983819938200382013820238203382043820538206382073820838209382103821138212382133821438215382163821738218382193822038221382223822338224382253822638227382283822938230382313823238233382343823538236382373823838239382403824138242382433824438245382463824738248382493825038251382523825338254382553825638257382583825938260382613826238263382643826538266382673826838269382703827138272382733827438275382763827738278382793828038281382823828338284382853828638287382883828938290382913829238293382943829538296382973829838299383003830138302383033830438305383063830738308383093831038311383123831338314383153831638317383183831938320383213832238323383243832538326383273832838329383303833138332383333833438335383363833738338383393834038341383423834338344383453834638347383483834938350383513835238353383543835538356383573835838359383603836138362383633836438365383663836738368383693837038371383723837338374383753837638377383783837938380383813838238383383843838538386383873838838389383903839138392383933839438395383963839738398383993840038401384023840338404384053840638407384083840938410384113841238413384143841538416384173841838419384203842138422384233842438425384263842738428384293843038431384323843338434384353843638437384383843938440384413844238443384443844538446384473844838449384503845138452384533845438455384563845738458384593846038461384623846338464384653846638467384683846938470384713847238473384743847538476384773847838479384803848138482384833848438485384863848738488384893849038491384923849338494384953849638497384983849938500385013850238503385043850538506385073850838509385103851138512385133851438515385163851738518385193852038521385223852338524385253852638527385283852938530385313853238533385343853538536385373853838539385403854138542385433854438545385463854738548385493855038551385523855338554385553855638557385583855938560385613856238563385643856538566385673856838569385703857138572385733857438575385763857738578385793858038581385823858338584385853858638587385883858938590385913859238593385943859538596385973859838599386003860138602386033860438605386063860738608386093861038611386123861338614386153861638617386183861938620386213862238623386243862538626386273862838629386303863138632386333863438635386363863738638386393864038641386423864338644386453864638647386483864938650386513865238653386543865538656386573865838659386603866138662386633866438665386663866738668386693867038671386723867338674386753867638677386783867938680386813868238683386843868538686386873868838689386903869138692386933869438695386963869738698386993870038701387023870338704387053870638707387083870938710387113871238713387143871538716387173871838719387203872138722387233872438725387263872738728387293873038731387323873338734387353873638737387383873938740387413874238743387443874538746387473874838749387503875138752387533875438755387563875738758387593876038761387623876338764387653876638767387683876938770387713877238773387743877538776387773877838779387803878138782387833878438785387863878738788387893879038791387923879338794387953879638797387983879938800388013880238803388043880538806388073880838809388103881138812388133881438815388163881738818388193882038821388223882338824388253882638827388283882938830388313883238833388343883538836388373883838839388403884138842388433884438845388463884738848388493885038851388523885338854388553885638857388583885938860388613886238863388643886538866388673886838869388703887138872388733887438875388763887738878388793888038881388823888338884388853888638887388883888938890388913889238893388943889538896388973889838899389003890138902389033890438905389063890738908389093891038911389123891338914389153891638917389183891938920389213892238923389243892538926389273892838929389303893138932389333893438935389363893738938389393894038941389423894338944389453894638947389483894938950389513895238953389543895538956389573895838959389603896138962389633896438965389663896738968389693897038971389723897338974389753897638977389783897938980389813898238983389843898538986389873898838989389903899138992389933899438995389963899738998389993900039001390023900339004390053900639007390083900939010390113901239013390143901539016390173901839019390203902139022390233902439025390263902739028390293903039031390323903339034390353903639037390383903939040390413904239043390443904539046390473904839049390503905139052390533905439055390563905739058390593906039061390623906339064390653906639067390683906939070390713907239073390743907539076390773907839079390803908139082390833908439085390863908739088390893909039091390923909339094390953909639097390983909939100391013910239103391043910539106391073910839109391103911139112391133911439115391163911739118391193912039121391223912339124391253912639127391283912939130391313913239133391343913539136391373913839139391403914139142391433914439145391463914739148391493915039151391523915339154391553915639157391583915939160391613916239163391643916539166391673916839169391703917139172391733917439175391763917739178391793918039181391823918339184391853918639187391883918939190391913919239193391943919539196391973919839199392003920139202392033920439205392063920739208392093921039211392123921339214392153921639217392183921939220392213922239223392243922539226392273922839229392303923139232392333923439235392363923739238392393924039241392423924339244392453924639247392483924939250392513925239253392543925539256392573925839259392603926139262392633926439265392663926739268392693927039271392723927339274392753927639277392783927939280392813928239283392843928539286392873928839289392903929139292392933929439295392963929739298392993930039301393023930339304393053930639307393083930939310393113931239313393143931539316393173931839319393203932139322393233932439325393263932739328393293933039331393323933339334393353933639337393383933939340393413934239343393443934539346393473934839349393503935139352393533935439355393563935739358393593936039361393623936339364393653936639367393683936939370393713937239373393743937539376393773937839379393803938139382393833938439385393863938739388393893939039391393923939339394393953939639397393983939939400394013940239403394043940539406394073940839409394103941139412394133941439415394163941739418394193942039421394223942339424394253942639427394283942939430394313943239433394343943539436394373943839439394403944139442394433944439445394463944739448394493945039451394523945339454394553945639457394583945939460394613946239463394643946539466394673946839469394703947139472394733947439475394763947739478394793948039481394823948339484394853948639487394883948939490394913949239493394943949539496394973949839499395003950139502395033950439505395063950739508395093951039511395123951339514395153951639517395183951939520395213952239523395243952539526395273952839529395303953139532395333953439535395363953739538395393954039541395423954339544395453954639547395483954939550395513955239553395543955539556395573955839559395603956139562395633956439565395663956739568395693957039571395723957339574395753957639577395783957939580395813958239583395843958539586395873958839589395903959139592395933959439595395963959739598395993960039601396023960339604396053960639607396083960939610396113961239613396143961539616396173961839619396203962139622396233962439625396263962739628396293963039631396323963339634396353963639637396383963939640396413964239643396443964539646396473964839649396503965139652396533965439655396563965739658396593966039661396623966339664396653966639667396683966939670396713967239673396743967539676396773967839679396803968139682396833968439685396863968739688396893969039691396923969339694396953969639697396983969939700397013970239703397043970539706397073970839709397103971139712397133971439715397163971739718397193972039721397223972339724397253972639727397283972939730397313973239733397343973539736397373973839739397403974139742397433974439745397463974739748397493975039751397523975339754397553975639757397583975939760397613976239763397643976539766397673976839769397703977139772397733977439775397763977739778397793978039781397823978339784397853978639787397883978939790397913979239793397943979539796397973979839799398003980139802398033980439805398063980739808398093981039811398123981339814398153981639817398183981939820398213982239823398243982539826398273982839829398303983139832398333983439835398363983739838398393984039841398423984339844398453984639847398483984939850398513985239853398543985539856398573985839859398603986139862398633986439865398663986739868398693987039871398723987339874398753987639877398783987939880398813988239883398843988539886398873988839889398903989139892398933989439895398963989739898398993990039901399023990339904399053990639907399083990939910399113991239913399143991539916399173991839919399203992139922399233992439925399263992739928399293993039931399323993339934399353993639937399383993939940399413994239943399443994539946399473994839949399503995139952399533995439955399563995739958399593996039961399623996339964399653996639967399683996939970399713997239973399743997539976399773997839979399803998139982399833998439985399863998739988399893999039991399923999339994399953999639997399983999940000400014000240003400044000540006400074000840009400104001140012400134001440015400164001740018400194002040021400224002340024400254002640027400284002940030400314003240033400344003540036400374003840039400404004140042400434004440045400464004740048400494005040051400524005340054400554005640057400584005940060400614006240063400644006540066400674006840069400704007140072400734007440075400764007740078400794008040081400824008340084400854008640087400884008940090400914009240093400944009540096400974009840099401004010140102401034010440105401064010740108401094011040111401124011340114401154011640117401184011940120401214012240123401244012540126401274012840129401304013140132401334013440135401364013740138401394014040141401424014340144401454014640147401484014940150401514015240153401544015540156401574015840159401604016140162401634016440165401664016740168401694017040171401724017340174401754017640177401784017940180401814018240183401844018540186401874018840189401904019140192401934019440195401964019740198401994020040201402024020340204402054020640207402084020940210402114021240213402144021540216402174021840219402204022140222402234022440225402264022740228402294023040231402324023340234402354023640237402384023940240402414024240243402444024540246402474024840249402504025140252402534025440255402564025740258402594026040261402624026340264402654026640267402684026940270402714027240273402744027540276402774027840279402804028140282402834028440285402864028740288402894029040291402924029340294402954029640297402984029940300403014030240303403044030540306403074030840309403104031140312403134031440315403164031740318403194032040321403224032340324403254032640327403284032940330403314033240333403344033540336403374033840339403404034140342403434034440345403464034740348403494035040351403524035340354403554035640357403584035940360403614036240363403644036540366403674036840369403704037140372403734037440375403764037740378403794038040381403824038340384403854038640387403884038940390403914039240393403944039540396403974039840399404004040140402404034040440405404064040740408404094041040411404124041340414404154041640417404184041940420404214042240423404244042540426404274042840429404304043140432404334043440435404364043740438404394044040441404424044340444404454044640447404484044940450404514045240453404544045540456404574045840459404604046140462404634046440465404664046740468404694047040471404724047340474404754047640477404784047940480404814048240483404844048540486404874048840489404904049140492404934049440495404964049740498404994050040501405024050340504405054050640507405084050940510405114051240513405144051540516405174051840519405204052140522405234052440525405264052740528405294053040531405324053340534405354053640537405384053940540405414054240543405444054540546405474054840549405504055140552405534055440555405564055740558405594056040561405624056340564405654056640567405684056940570405714057240573405744057540576405774057840579405804058140582405834058440585405864058740588405894059040591405924059340594405954059640597405984059940600406014060240603406044060540606406074060840609406104061140612406134061440615406164061740618406194062040621406224062340624406254062640627406284062940630406314063240633406344063540636406374063840639406404064140642406434064440645406464064740648406494065040651406524065340654406554065640657406584065940660406614066240663406644066540666406674066840669406704067140672406734067440675406764067740678406794068040681406824068340684406854068640687406884068940690406914069240693406944069540696406974069840699407004070140702407034070440705407064070740708407094071040711407124071340714407154071640717407184071940720407214072240723407244072540726407274072840729407304073140732407334073440735407364073740738407394074040741407424074340744407454074640747407484074940750407514075240753407544075540756407574075840759407604076140762407634076440765407664076740768407694077040771407724077340774407754077640777407784077940780407814078240783407844078540786407874078840789407904079140792407934079440795407964079740798407994080040801408024080340804408054080640807408084080940810408114081240813408144081540816408174081840819408204082140822408234082440825408264082740828408294083040831408324083340834408354083640837408384083940840408414084240843408444084540846408474084840849408504085140852408534085440855408564085740858408594086040861408624086340864408654086640867408684086940870408714087240873408744087540876408774087840879408804088140882408834088440885408864088740888408894089040891408924089340894408954089640897408984089940900409014090240903409044090540906409074090840909409104091140912409134091440915409164091740918409194092040921409224092340924409254092640927409284092940930409314093240933409344093540936409374093840939409404094140942409434094440945409464094740948409494095040951409524095340954409554095640957409584095940960409614096240963409644096540966409674096840969409704097140972409734097440975409764097740978409794098040981409824098340984409854098640987409884098940990409914099240993409944099540996409974099840999410004100141002410034100441005410064100741008410094101041011410124101341014410154101641017410184101941020410214102241023410244102541026410274102841029410304103141032410334103441035410364103741038410394104041041410424104341044410454104641047410484104941050410514105241053410544105541056410574105841059410604106141062410634106441065410664106741068410694107041071410724107341074410754107641077410784107941080410814108241083410844108541086410874108841089410904109141092410934109441095410964109741098410994110041101411024110341104411054110641107411084110941110411114111241113411144111541116411174111841119411204112141122411234112441125411264112741128411294113041131411324113341134411354113641137411384113941140411414114241143411444114541146411474114841149411504115141152411534115441155411564115741158411594116041161411624116341164411654116641167411684116941170411714117241173411744117541176411774117841179411804118141182411834118441185411864118741188411894119041191411924119341194411954119641197411984119941200412014120241203412044120541206412074120841209412104121141212412134121441215412164121741218412194122041221412224122341224412254122641227412284122941230412314123241233412344123541236412374123841239412404124141242412434124441245412464124741248412494125041251412524125341254412554125641257412584125941260412614126241263412644126541266412674126841269412704127141272412734127441275412764127741278412794128041281412824128341284412854128641287412884128941290412914129241293412944129541296412974129841299413004130141302413034130441305413064130741308413094131041311413124131341314413154131641317413184131941320413214132241323413244132541326413274132841329413304133141332413334133441335413364133741338413394134041341413424134341344413454134641347413484134941350413514135241353413544135541356413574135841359413604136141362413634136441365413664136741368413694137041371413724137341374413754137641377413784137941380413814138241383413844138541386413874138841389413904139141392413934139441395413964139741398413994140041401414024140341404414054140641407414084140941410414114141241413414144141541416414174141841419414204142141422414234142441425414264142741428414294143041431414324143341434414354143641437414384143941440414414144241443414444144541446414474144841449414504145141452414534145441455414564145741458414594146041461414624146341464414654146641467414684146941470414714147241473414744147541476414774147841479414804148141482414834148441485414864148741488414894149041491414924149341494414954149641497414984149941500415014150241503415044150541506415074150841509415104151141512415134151441515415164151741518415194152041521415224152341524415254152641527415284152941530415314153241533415344153541536415374153841539415404154141542415434154441545415464154741548415494155041551415524155341554415554155641557415584155941560415614156241563415644156541566415674156841569415704157141572415734157441575415764157741578415794158041581415824158341584415854158641587415884158941590415914159241593415944159541596415974159841599416004160141602416034160441605416064160741608416094161041611416124161341614416154161641617416184161941620416214162241623416244162541626416274162841629416304163141632416334163441635416364163741638416394164041641416424164341644416454164641647416484164941650416514165241653416544165541656416574165841659416604166141662416634166441665416664166741668416694167041671416724167341674416754167641677416784167941680416814168241683416844168541686416874168841689416904169141692416934169441695416964169741698416994170041701417024170341704417054170641707417084170941710417114171241713417144171541716417174171841719417204172141722417234172441725417264172741728417294173041731417324173341734417354173641737417384173941740417414174241743417444174541746417474174841749417504175141752417534175441755417564175741758417594176041761417624176341764417654176641767417684176941770417714177241773417744177541776417774177841779417804178141782417834178441785417864178741788417894179041791417924179341794417954179641797417984179941800418014180241803418044180541806418074180841809418104181141812418134181441815418164181741818418194182041821418224182341824418254182641827418284182941830418314183241833418344183541836418374183841839418404184141842418434184441845418464184741848418494185041851418524185341854418554185641857418584185941860418614186241863418644186541866418674186841869418704187141872418734187441875418764187741878418794188041881418824188341884418854188641887418884188941890418914189241893418944189541896418974189841899419004190141902419034190441905419064190741908419094191041911419124191341914419154191641917419184191941920419214192241923419244192541926419274192841929419304193141932419334193441935419364193741938419394194041941419424194341944419454194641947419484194941950419514195241953419544195541956419574195841959419604196141962419634196441965419664196741968419694197041971419724197341974419754197641977419784197941980419814198241983419844198541986419874198841989419904199141992419934199441995419964199741998419994200042001420024200342004420054200642007420084200942010420114201242013420144201542016420174201842019420204202142022420234202442025420264202742028420294203042031420324203342034420354203642037420384203942040420414204242043420444204542046420474204842049420504205142052420534205442055420564205742058420594206042061420624206342064420654206642067420684206942070420714207242073420744207542076420774207842079420804208142082420834208442085420864208742088420894209042091420924209342094420954209642097420984209942100421014210242103421044210542106421074210842109421104211142112421134211442115421164211742118421194212042121421224212342124421254212642127421284212942130421314213242133421344213542136421374213842139421404214142142421434214442145421464214742148421494215042151421524215342154421554215642157421584215942160421614216242163421644216542166421674216842169421704217142172421734217442175421764217742178421794218042181421824218342184421854218642187421884218942190421914219242193421944219542196421974219842199422004220142202422034220442205422064220742208422094221042211422124221342214422154221642217422184221942220422214222242223422244222542226422274222842229422304223142232422334223442235422364223742238422394224042241422424224342244422454224642247422484224942250422514225242253422544225542256422574225842259422604226142262422634226442265422664226742268422694227042271422724227342274422754227642277422784227942280422814228242283422844228542286422874228842289422904229142292422934229442295422964229742298422994230042301423024230342304423054230642307423084230942310423114231242313423144231542316423174231842319423204232142322423234232442325423264232742328423294233042331423324233342334423354233642337423384233942340423414234242343423444234542346423474234842349423504235142352423534235442355423564235742358423594236042361423624236342364423654236642367423684236942370423714237242373423744237542376423774237842379423804238142382423834238442385423864238742388423894239042391423924239342394423954239642397423984239942400424014240242403424044240542406424074240842409424104241142412424134241442415424164241742418424194242042421424224242342424424254242642427424284242942430424314243242433424344243542436424374243842439424404244142442424434244442445424464244742448424494245042451424524245342454424554245642457424584245942460424614246242463424644246542466424674246842469424704247142472424734247442475424764247742478424794248042481424824248342484424854248642487424884248942490424914249242493424944249542496424974249842499425004250142502425034250442505425064250742508425094251042511425124251342514425154251642517425184251942520425214252242523425244252542526425274252842529425304253142532425334253442535425364253742538425394254042541425424254342544425454254642547425484254942550425514255242553425544255542556425574255842559425604256142562425634256442565425664256742568425694257042571425724257342574425754257642577425784257942580425814258242583425844258542586425874258842589425904259142592425934259442595425964259742598425994260042601426024260342604426054260642607426084260942610426114261242613426144261542616426174261842619426204262142622426234262442625426264262742628426294263042631426324263342634426354263642637426384263942640426414264242643426444264542646426474264842649426504265142652426534265442655426564265742658426594266042661426624266342664426654266642667426684266942670426714267242673426744267542676426774267842679426804268142682426834268442685426864268742688426894269042691426924269342694426954269642697426984269942700427014270242703427044270542706427074270842709427104271142712427134271442715427164271742718427194272042721427224272342724427254272642727427284272942730427314273242733427344273542736427374273842739427404274142742427434274442745427464274742748427494275042751427524275342754427554275642757427584275942760427614276242763427644276542766427674276842769427704277142772427734277442775427764277742778427794278042781427824278342784427854278642787427884278942790427914279242793427944279542796427974279842799428004280142802428034280442805428064280742808428094281042811428124281342814428154281642817428184281942820428214282242823428244282542826428274282842829428304283142832428334283442835428364283742838428394284042841428424284342844428454284642847428484284942850428514285242853428544285542856428574285842859428604286142862428634286442865428664286742868428694287042871428724287342874428754287642877428784287942880428814288242883428844288542886428874288842889428904289142892428934289442895428964289742898428994290042901429024290342904429054290642907429084290942910429114291242913429144291542916429174291842919429204292142922429234292442925429264292742928429294293042931429324293342934429354293642937429384293942940429414294242943429444294542946429474294842949429504295142952429534295442955429564295742958429594296042961429624296342964429654296642967429684296942970429714297242973429744297542976429774297842979429804298142982429834298442985429864298742988429894299042991429924299342994429954299642997429984299943000430014300243003430044300543006430074300843009430104301143012430134301443015430164301743018430194302043021430224302343024430254302643027430284302943030430314303243033430344303543036430374303843039430404304143042430434304443045430464304743048430494305043051430524305343054430554305643057430584305943060430614306243063430644306543066430674306843069430704307143072430734307443075430764307743078430794308043081430824308343084430854308643087430884308943090430914309243093430944309543096430974309843099431004310143102431034310443105431064310743108431094311043111431124311343114431154311643117431184311943120431214312243123431244312543126431274312843129431304313143132431334313443135431364313743138431394314043141431424314343144431454314643147431484314943150431514315243153431544315543156431574315843159431604316143162431634316443165431664316743168431694317043171431724317343174431754317643177431784317943180431814318243183431844318543186431874318843189431904319143192431934319443195431964319743198431994320043201432024320343204432054320643207432084320943210432114321243213432144321543216432174321843219432204322143222432234322443225432264322743228432294323043231432324323343234432354323643237432384323943240432414324243243432444324543246432474324843249432504325143252432534325443255432564325743258432594326043261432624326343264432654326643267432684326943270432714327243273432744327543276432774327843279432804328143282432834328443285432864328743288432894329043291432924329343294432954329643297432984329943300433014330243303433044330543306433074330843309433104331143312433134331443315433164331743318433194332043321433224332343324433254332643327433284332943330433314333243333433344333543336433374333843339433404334143342433434334443345433464334743348433494335043351433524335343354433554335643357433584335943360433614336243363433644336543366433674336843369433704337143372433734337443375433764337743378433794338043381433824338343384433854338643387433884338943390433914339243393433944339543396433974339843399434004340143402434034340443405434064340743408434094341043411434124341343414434154341643417434184341943420434214342243423434244342543426434274342843429434304343143432434334343443435434364343743438434394344043441434424344343444434454344643447434484344943450434514345243453434544345543456434574345843459434604346143462434634346443465434664346743468434694347043471434724347343474434754347643477434784347943480434814348243483434844348543486434874348843489434904349143492434934349443495434964349743498434994350043501435024350343504435054350643507435084350943510435114351243513435144351543516435174351843519435204352143522435234352443525435264352743528435294353043531435324353343534435354353643537435384353943540435414354243543435444354543546435474354843549435504355143552435534355443555435564355743558435594356043561435624356343564435654356643567435684356943570435714357243573435744357543576435774357843579435804358143582435834358443585435864358743588435894359043591435924359343594435954359643597435984359943600436014360243603436044360543606436074360843609436104361143612436134361443615436164361743618436194362043621436224362343624436254362643627436284362943630436314363243633436344363543636436374363843639436404364143642436434364443645436464364743648436494365043651436524365343654436554365643657436584365943660436614366243663436644366543666436674366843669436704367143672436734367443675436764367743678436794368043681436824368343684436854368643687436884368943690436914369243693436944369543696436974369843699437004370143702437034370443705437064370743708437094371043711437124371343714437154371643717437184371943720437214372243723437244372543726437274372843729437304373143732437334373443735437364373743738437394374043741437424374343744437454374643747437484374943750437514375243753437544375543756437574375843759437604376143762437634376443765437664376743768437694377043771437724377343774437754377643777437784377943780437814378243783437844378543786437874378843789437904379143792437934379443795437964379743798437994380043801438024380343804438054380643807438084380943810438114381243813438144381543816438174381843819438204382143822438234382443825438264382743828438294383043831438324383343834438354383643837438384383943840438414384243843438444384543846438474384843849438504385143852438534385443855438564385743858438594386043861438624386343864438654386643867438684386943870438714387243873438744387543876438774387843879438804388143882438834388443885438864388743888438894389043891438924389343894438954389643897438984389943900439014390243903439044390543906439074390843909439104391143912439134391443915439164391743918439194392043921439224392343924439254392643927439284392943930439314393243933439344393543936439374393843939439404394143942439434394443945439464394743948439494395043951439524395343954439554395643957439584395943960439614396243963439644396543966439674396843969439704397143972439734397443975439764397743978439794398043981439824398343984439854398643987439884398943990439914399243993439944399543996439974399843999440004400144002440034400444005440064400744008440094401044011440124401344014440154401644017440184401944020440214402244023440244402544026440274402844029440304403144032440334403444035440364403744038440394404044041440424404344044440454404644047440484404944050440514405244053440544405544056440574405844059440604406144062440634406444065440664406744068440694407044071440724407344074440754407644077440784407944080440814408244083440844408544086440874408844089440904409144092440934409444095440964409744098440994410044101441024410344104441054410644107441084410944110441114411244113441144411544116441174411844119441204412144122441234412444125441264412744128441294413044131441324413344134441354413644137441384413944140441414414244143441444414544146441474414844149441504415144152441534415444155441564415744158441594416044161441624416344164441654416644167441684416944170441714417244173441744417544176441774417844179441804418144182441834418444185441864418744188441894419044191441924419344194441954419644197441984419944200442014420244203442044420544206442074420844209442104421144212442134421444215442164421744218442194422044221442224422344224442254422644227442284422944230442314423244233442344423544236442374423844239442404424144242442434424444245442464424744248442494425044251442524425344254442554425644257442584425944260442614426244263442644426544266442674426844269442704427144272442734427444275442764427744278442794428044281442824428344284442854428644287442884428944290442914429244293442944429544296442974429844299443004430144302443034430444305443064430744308443094431044311443124431344314443154431644317443184431944320443214432244323443244432544326443274432844329443304433144332443334433444335443364433744338443394434044341443424434344344443454434644347443484434944350443514435244353443544435544356443574435844359443604436144362443634436444365443664436744368443694437044371443724437344374443754437644377443784437944380443814438244383443844438544386443874438844389443904439144392443934439444395443964439744398443994440044401444024440344404444054440644407444084440944410444114441244413444144441544416444174441844419444204442144422444234442444425444264442744428444294443044431444324443344434444354443644437444384443944440444414444244443444444444544446444474444844449444504445144452444534445444455444564445744458444594446044461444624446344464444654446644467444684446944470444714447244473444744447544476444774447844479444804448144482444834448444485444864448744488444894449044491444924449344494444954449644497444984449944500445014450244503445044450544506445074450844509445104451144512445134451444515445164451744518445194452044521445224452344524445254452644527445284452944530445314453244533445344453544536445374453844539445404454144542445434454444545445464454744548445494455044551445524455344554445554455644557445584455944560445614456244563445644456544566445674456844569445704457144572445734457444575445764457744578445794458044581445824458344584445854458644587445884458944590445914459244593445944459544596445974459844599446004460144602446034460444605446064460744608446094461044611446124461344614446154461644617446184461944620446214462244623446244462544626446274462844629446304463144632446334463444635446364463744638446394464044641446424464344644446454464644647446484464944650446514465244653446544465544656446574465844659446604466144662446634466444665446664466744668446694467044671446724467344674446754467644677446784467944680446814468244683446844468544686446874468844689446904469144692446934469444695446964469744698446994470044701447024470344704447054470644707447084470944710447114471244713447144471544716447174471844719447204472144722447234472444725447264472744728447294473044731447324473344734447354473644737447384473944740447414474244743447444474544746447474474844749447504475144752447534475444755447564475744758447594476044761447624476344764447654476644767447684476944770447714477244773447744477544776447774477844779447804478144782447834478444785447864478744788447894479044791447924479344794447954479644797447984479944800448014480244803448044480544806448074480844809448104481144812448134481444815448164481744818448194482044821448224482344824448254482644827448284482944830448314483244833448344483544836448374483844839448404484144842448434484444845448464484744848448494485044851448524485344854448554485644857448584485944860448614486244863448644486544866448674486844869448704487144872448734487444875448764487744878448794488044881448824488344884448854488644887448884488944890448914489244893448944489544896448974489844899449004490144902449034490444905449064490744908449094491044911449124491344914449154491644917449184491944920449214492244923449244492544926449274492844929449304493144932449334493444935449364493744938449394494044941449424494344944449454494644947449484494944950449514495244953449544495544956449574495844959449604496144962449634496444965449664496744968449694497044971449724497344974449754497644977449784497944980449814498244983449844498544986449874498844989449904499144992449934499444995449964499744998449994500045001450024500345004450054500645007450084500945010450114501245013450144501545016450174501845019450204502145022450234502445025450264502745028450294503045031450324503345034450354503645037450384503945040450414504245043450444504545046450474504845049450504505145052450534505445055450564505745058450594506045061450624506345064450654506645067450684506945070450714507245073450744507545076450774507845079450804508145082450834508445085450864508745088450894509045091450924509345094450954509645097450984509945100451014510245103451044510545106451074510845109451104511145112451134511445115451164511745118451194512045121451224512345124451254512645127451284512945130451314513245133451344513545136451374513845139451404514145142451434514445145451464514745148451494515045151451524515345154451554515645157451584515945160451614516245163451644516545166451674516845169451704517145172451734517445175451764517745178451794518045181451824518345184451854518645187451884518945190451914519245193451944519545196451974519845199452004520145202452034520445205452064520745208452094521045211452124521345214452154521645217452184521945220452214522245223452244522545226452274522845229452304523145232452334523445235452364523745238452394524045241452424524345244452454524645247452484524945250452514525245253452544525545256452574525845259452604526145262452634526445265452664526745268452694527045271452724527345274452754527645277452784527945280452814528245283452844528545286452874528845289452904529145292452934529445295452964529745298452994530045301453024530345304453054530645307453084530945310453114531245313453144531545316453174531845319453204532145322453234532445325453264532745328453294533045331453324533345334453354533645337453384533945340453414534245343453444534545346453474534845349453504535145352453534535445355453564535745358453594536045361453624536345364453654536645367453684536945370453714537245373453744537545376453774537845379453804538145382453834538445385453864538745388453894539045391453924539345394453954539645397453984539945400454014540245403454044540545406454074540845409454104541145412454134541445415454164541745418454194542045421454224542345424454254542645427454284542945430454314543245433454344543545436454374543845439454404544145442454434544445445454464544745448454494545045451454524545345454454554545645457454584545945460454614546245463454644546545466454674546845469454704547145472454734547445475454764547745478454794548045481454824548345484454854548645487454884548945490454914549245493454944549545496454974549845499455004550145502455034550445505455064550745508455094551045511455124551345514455154551645517455184551945520455214552245523455244552545526455274552845529455304553145532455334553445535455364553745538455394554045541455424554345544455454554645547455484554945550455514555245553455544555545556455574555845559455604556145562455634556445565455664556745568455694557045571455724557345574455754557645577455784557945580455814558245583455844558545586455874558845589455904559145592455934559445595455964559745598455994560045601456024560345604456054560645607456084560945610456114561245613456144561545616456174561845619456204562145622456234562445625456264562745628456294563045631456324563345634456354563645637456384563945640456414564245643456444564545646456474564845649456504565145652456534565445655456564565745658456594566045661456624566345664456654566645667456684566945670456714567245673456744567545676456774567845679456804568145682456834568445685456864568745688456894569045691456924569345694456954569645697456984569945700457014570245703457044570545706457074570845709457104571145712457134571445715457164571745718457194572045721457224572345724457254572645727457284572945730457314573245733457344573545736457374573845739457404574145742457434574445745457464574745748457494575045751457524575345754457554575645757457584575945760457614576245763457644576545766457674576845769457704577145772457734577445775457764577745778457794578045781457824578345784457854578645787457884578945790457914579245793457944579545796457974579845799458004580145802458034580445805458064580745808458094581045811458124581345814458154581645817458184581945820458214582245823458244582545826458274582845829458304583145832458334583445835458364583745838458394584045841458424584345844458454584645847458484584945850458514585245853458544585545856458574585845859458604586145862458634586445865458664586745868458694587045871458724587345874458754587645877458784587945880458814588245883458844588545886458874588845889458904589145892458934589445895458964589745898458994590045901459024590345904459054590645907459084590945910459114591245913459144591545916459174591845919459204592145922459234592445925459264592745928459294593045931459324593345934459354593645937459384593945940459414594245943459444594545946459474594845949459504595145952459534595445955459564595745958459594596045961459624596345964459654596645967459684596945970459714597245973459744597545976459774597845979459804598145982459834598445985459864598745988459894599045991459924599345994459954599645997459984599946000460014600246003460044600546006460074600846009460104601146012460134601446015460164601746018460194602046021460224602346024460254602646027460284602946030460314603246033460344603546036460374603846039460404604146042460434604446045460464604746048460494605046051460524605346054460554605646057460584605946060460614606246063460644606546066460674606846069460704607146072460734607446075460764607746078460794608046081460824608346084460854608646087460884608946090460914609246093460944609546096460974609846099461004610146102461034610446105461064610746108461094611046111461124611346114461154611646117461184611946120461214612246123461244612546126461274612846129461304613146132461334613446135461364613746138461394614046141461424614346144461454614646147461484614946150461514615246153461544615546156461574615846159461604616146162461634616446165461664616746168461694617046171461724617346174461754617646177461784617946180461814618246183461844618546186461874618846189461904619146192461934619446195461964619746198461994620046201462024620346204462054620646207462084620946210462114621246213462144621546216462174621846219462204622146222462234622446225462264622746228462294623046231462324623346234462354623646237462384623946240462414624246243462444624546246462474624846249462504625146252462534625446255462564625746258462594626046261462624626346264462654626646267462684626946270462714627246273462744627546276462774627846279462804628146282462834628446285462864628746288462894629046291462924629346294462954629646297462984629946300463014630246303463044630546306463074630846309463104631146312463134631446315463164631746318463194632046321463224632346324463254632646327463284632946330463314633246333463344633546336463374633846339463404634146342463434634446345463464634746348463494635046351463524635346354463554635646357463584635946360463614636246363463644636546366463674636846369463704637146372463734637446375463764637746378463794638046381463824638346384463854638646387463884638946390463914639246393463944639546396463974639846399464004640146402464034640446405464064640746408464094641046411464124641346414464154641646417464184641946420464214642246423464244642546426464274642846429464304643146432464334643446435464364643746438464394644046441464424644346444464454644646447464484644946450464514645246453464544645546456464574645846459464604646146462464634646446465464664646746468464694647046471464724647346474464754647646477464784647946480464814648246483464844648546486464874648846489464904649146492464934649446495464964649746498464994650046501465024650346504465054650646507465084650946510465114651246513465144651546516465174651846519465204652146522465234652446525465264652746528465294653046531465324653346534465354653646537465384653946540465414654246543465444654546546465474654846549465504655146552465534655446555465564655746558465594656046561465624656346564465654656646567465684656946570465714657246573465744657546576465774657846579465804658146582465834658446585465864658746588465894659046591465924659346594465954659646597465984659946600466014660246603466044660546606466074660846609466104661146612466134661446615466164661746618466194662046621466224662346624466254662646627466284662946630466314663246633466344663546636466374663846639466404664146642466434664446645466464664746648466494665046651466524665346654466554665646657466584665946660466614666246663466644666546666466674666846669466704667146672466734667446675466764667746678466794668046681466824668346684466854668646687466884668946690466914669246693466944669546696466974669846699467004670146702467034670446705467064670746708467094671046711467124671346714467154671646717467184671946720467214672246723467244672546726467274672846729467304673146732467334673446735467364673746738467394674046741467424674346744467454674646747467484674946750467514675246753467544675546756467574675846759467604676146762467634676446765467664676746768467694677046771467724677346774467754677646777467784677946780467814678246783467844678546786467874678846789467904679146792467934679446795467964679746798467994680046801468024680346804468054680646807468084680946810468114681246813468144681546816468174681846819468204682146822468234682446825468264682746828468294683046831468324683346834468354683646837468384683946840468414684246843468444684546846468474684846849468504685146852468534685446855468564685746858468594686046861468624686346864468654686646867468684686946870468714687246873468744687546876468774687846879468804688146882468834688446885468864688746888468894689046891468924689346894468954689646897468984689946900469014690246903469044690546906469074690846909469104691146912469134691446915469164691746918469194692046921469224692346924469254692646927469284692946930469314693246933469344693546936469374693846939469404694146942469434694446945469464694746948469494695046951469524695346954469554695646957469584695946960469614696246963469644696546966469674696846969469704697146972469734697446975469764697746978469794698046981469824698346984469854698646987469884698946990469914699246993469944699546996469974699846999470004700147002470034700447005470064700747008470094701047011470124701347014470154701647017470184701947020470214702247023470244702547026470274702847029470304703147032470334703447035470364703747038470394704047041470424704347044470454704647047470484704947050470514705247053470544705547056470574705847059470604706147062470634706447065470664706747068470694707047071470724707347074470754707647077470784707947080470814708247083470844708547086470874708847089470904709147092470934709447095470964709747098470994710047101471024710347104471054710647107471084710947110471114711247113471144711547116471174711847119471204712147122471234712447125471264712747128471294713047131471324713347134471354713647137471384713947140471414714247143471444714547146471474714847149471504715147152471534715447155471564715747158471594716047161471624716347164471654716647167471684716947170471714717247173471744717547176471774717847179471804718147182471834718447185471864718747188471894719047191471924719347194471954719647197471984719947200472014720247203472044720547206472074720847209472104721147212472134721447215472164721747218472194722047221472224722347224472254722647227472284722947230472314723247233472344723547236472374723847239472404724147242472434724447245472464724747248472494725047251472524725347254472554725647257472584725947260472614726247263472644726547266472674726847269472704727147272472734727447275472764727747278472794728047281472824728347284472854728647287472884728947290472914729247293472944729547296472974729847299473004730147302473034730447305473064730747308473094731047311473124731347314473154731647317473184731947320473214732247323473244732547326473274732847329473304733147332473334733447335473364733747338473394734047341473424734347344473454734647347473484734947350473514735247353473544735547356473574735847359473604736147362473634736447365473664736747368473694737047371473724737347374473754737647377473784737947380473814738247383473844738547386473874738847389473904739147392473934739447395473964739747398473994740047401474024740347404474054740647407474084740947410474114741247413474144741547416474174741847419474204742147422474234742447425474264742747428474294743047431474324743347434474354743647437474384743947440474414744247443474444744547446474474744847449474504745147452474534745447455474564745747458474594746047461474624746347464474654746647467474684746947470474714747247473474744747547476474774747847479474804748147482474834748447485474864748747488474894749047491474924749347494474954749647497474984749947500475014750247503475044750547506475074750847509475104751147512475134751447515475164751747518475194752047521475224752347524475254752647527475284752947530475314753247533475344753547536475374753847539475404754147542475434754447545475464754747548475494755047551475524755347554475554755647557475584755947560475614756247563475644756547566475674756847569475704757147572475734757447575475764757747578475794758047581475824758347584475854758647587475884758947590475914759247593475944759547596475974759847599476004760147602476034760447605476064760747608476094761047611476124761347614476154761647617476184761947620476214762247623476244762547626476274762847629476304763147632476334763447635476364763747638476394764047641476424764347644476454764647647476484764947650476514765247653476544765547656476574765847659476604766147662476634766447665476664766747668476694767047671476724767347674476754767647677476784767947680476814768247683476844768547686476874768847689476904769147692476934769447695476964769747698476994770047701477024770347704477054770647707477084770947710477114771247713477144771547716477174771847719477204772147722477234772447725477264772747728477294773047731477324773347734477354773647737477384773947740477414774247743477444774547746477474774847749477504775147752477534775447755477564775747758477594776047761477624776347764477654776647767477684776947770477714777247773477744777547776477774777847779477804778147782477834778447785477864778747788477894779047791477924779347794477954779647797477984779947800478014780247803478044780547806478074780847809478104781147812478134781447815478164781747818478194782047821478224782347824478254782647827478284782947830478314783247833478344783547836478374783847839478404784147842478434784447845478464784747848478494785047851478524785347854478554785647857478584785947860478614786247863478644786547866478674786847869478704787147872478734787447875478764787747878478794788047881478824788347884478854788647887478884788947890478914789247893478944789547896478974789847899479004790147902479034790447905479064790747908479094791047911479124791347914479154791647917479184791947920479214792247923479244792547926479274792847929479304793147932479334793447935479364793747938479394794047941479424794347944479454794647947479484794947950479514795247953479544795547956479574795847959479604796147962479634796447965479664796747968479694797047971479724797347974479754797647977479784797947980479814798247983479844798547986479874798847989479904799147992479934799447995479964799747998479994800048001480024800348004480054800648007480084800948010480114801248013480144801548016480174801848019480204802148022480234802448025480264802748028480294803048031480324803348034480354803648037480384803948040480414804248043480444804548046480474804848049480504805148052480534805448055480564805748058480594806048061480624806348064480654806648067480684806948070480714807248073480744807548076480774807848079480804808148082480834808448085480864808748088480894809048091480924809348094480954809648097480984809948100481014810248103481044810548106481074810848109481104811148112481134811448115481164811748118481194812048121481224812348124481254812648127481284812948130481314813248133481344813548136481374813848139481404814148142481434814448145481464814748148481494815048151481524815348154481554815648157481584815948160481614816248163481644816548166481674816848169481704817148172481734817448175481764817748178481794818048181481824818348184481854818648187481884818948190481914819248193481944819548196481974819848199482004820148202482034820448205482064820748208482094821048211482124821348214482154821648217482184821948220482214822248223482244822548226482274822848229482304823148232482334823448235482364823748238482394824048241482424824348244482454824648247482484824948250482514825248253482544825548256482574825848259482604826148262482634826448265482664826748268482694827048271482724827348274482754827648277482784827948280482814828248283482844828548286482874828848289482904829148292482934829448295482964829748298482994830048301483024830348304483054830648307483084830948310483114831248313483144831548316483174831848319483204832148322483234832448325483264832748328483294833048331483324833348334483354833648337483384833948340483414834248343483444834548346483474834848349483504835148352483534835448355483564835748358483594836048361483624836348364483654836648367483684836948370483714837248373483744837548376483774837848379483804838148382483834838448385483864838748388483894839048391483924839348394483954839648397483984839948400484014840248403484044840548406484074840848409484104841148412484134841448415484164841748418484194842048421484224842348424484254842648427484284842948430484314843248433484344843548436484374843848439484404844148442484434844448445484464844748448484494845048451484524845348454484554845648457484584845948460484614846248463484644846548466484674846848469484704847148472484734847448475484764847748478484794848048481484824848348484484854848648487484884848948490484914849248493484944849548496484974849848499485004850148502485034850448505485064850748508485094851048511485124851348514485154851648517485184851948520485214852248523485244852548526485274852848529485304853148532485334853448535485364853748538485394854048541485424854348544485454854648547485484854948550485514855248553485544855548556485574855848559485604856148562485634856448565485664856748568485694857048571485724857348574485754857648577485784857948580485814858248583485844858548586485874858848589485904859148592485934859448595485964859748598485994860048601486024860348604486054860648607486084860948610486114861248613486144861548616486174861848619486204862148622486234862448625486264862748628486294863048631486324863348634486354863648637486384863948640486414864248643486444864548646486474864848649486504865148652486534865448655486564865748658486594866048661486624866348664486654866648667486684866948670486714867248673486744867548676486774867848679486804868148682486834868448685486864868748688486894869048691486924869348694486954869648697486984869948700487014870248703487044870548706487074870848709487104871148712487134871448715487164871748718487194872048721487224872348724487254872648727487284872948730487314873248733487344873548736487374873848739487404874148742487434874448745487464874748748487494875048751487524875348754487554875648757487584875948760487614876248763487644876548766487674876848769487704877148772487734877448775487764877748778487794878048781487824878348784487854878648787487884878948790487914879248793487944879548796487974879848799488004880148802488034880448805488064880748808488094881048811488124881348814488154881648817488184881948820488214882248823488244882548826488274882848829488304883148832488334883448835488364883748838488394884048841488424884348844488454884648847488484884948850488514885248853488544885548856488574885848859488604886148862488634886448865488664886748868488694887048871488724887348874488754887648877488784887948880488814888248883488844888548886488874888848889488904889148892488934889448895488964889748898488994890048901489024890348904489054890648907489084890948910489114891248913489144891548916489174891848919489204892148922489234892448925489264892748928489294893048931489324893348934489354893648937489384893948940489414894248943489444894548946489474894848949489504895148952489534895448955489564895748958489594896048961489624896348964489654896648967489684896948970489714897248973489744897548976489774897848979489804898148982489834898448985489864898748988489894899048991489924899348994489954899648997489984899949000490014900249003490044900549006490074900849009490104901149012490134901449015490164901749018490194902049021490224902349024490254902649027490284902949030490314903249033490344903549036490374903849039490404904149042490434904449045490464904749048490494905049051490524905349054490554905649057490584905949060490614906249063490644906549066490674906849069490704907149072490734907449075490764907749078490794908049081490824908349084490854908649087490884908949090490914909249093490944909549096490974909849099491004910149102491034910449105491064910749108491094911049111491124911349114491154911649117491184911949120491214912249123491244912549126491274912849129491304913149132491334913449135491364913749138491394914049141491424914349144491454914649147491484914949150491514915249153491544915549156491574915849159491604916149162491634916449165491664916749168491694917049171491724917349174491754917649177491784917949180491814918249183491844918549186491874918849189491904919149192491934919449195491964919749198491994920049201492024920349204492054920649207492084920949210492114921249213492144921549216492174921849219492204922149222492234922449225492264922749228492294923049231492324923349234492354923649237492384923949240492414924249243492444924549246492474924849249492504925149252492534925449255492564925749258492594926049261492624926349264492654926649267492684926949270492714927249273492744927549276492774927849279492804928149282492834928449285492864928749288492894929049291492924929349294492954929649297492984929949300493014930249303493044930549306493074930849309493104931149312493134931449315493164931749318493194932049321493224932349324493254932649327493284932949330493314933249333493344933549336493374933849339493404934149342493434934449345493464934749348493494935049351493524935349354493554935649357493584935949360493614936249363493644936549366493674936849369493704937149372493734937449375493764937749378493794938049381493824938349384493854938649387493884938949390493914939249393493944939549396493974939849399494004940149402494034940449405494064940749408494094941049411494124941349414494154941649417494184941949420494214942249423494244942549426494274942849429494304943149432494334943449435494364943749438494394944049441494424944349444494454944649447494484944949450494514945249453494544945549456494574945849459494604946149462494634946449465494664946749468494694947049471494724947349474494754947649477494784947949480494814948249483494844948549486494874948849489494904949149492494934949449495494964949749498494994950049501495024950349504495054950649507495084950949510495114951249513495144951549516495174951849519495204952149522495234952449525495264952749528495294953049531495324953349534495354953649537495384953949540495414954249543495444954549546495474954849549495504955149552495534955449555495564955749558495594956049561495624956349564495654956649567495684956949570495714957249573495744957549576495774957849579495804958149582495834958449585495864958749588495894959049591495924959349594495954959649597495984959949600496014960249603496044960549606496074960849609496104961149612496134961449615496164961749618496194962049621496224962349624496254962649627496284962949630496314963249633496344963549636496374963849639496404964149642496434964449645496464964749648496494965049651496524965349654496554965649657496584965949660496614966249663496644966549666496674966849669496704967149672496734967449675496764967749678496794968049681496824968349684496854968649687496884968949690496914969249693496944969549696496974969849699497004970149702497034970449705497064970749708497094971049711497124971349714497154971649717497184971949720497214972249723497244972549726497274972849729497304973149732497334973449735497364973749738497394974049741497424974349744497454974649747497484974949750497514975249753497544975549756497574975849759497604976149762497634976449765497664976749768497694977049771497724977349774497754977649777497784977949780497814978249783497844978549786497874978849789497904979149792497934979449795497964979749798497994980049801498024980349804498054980649807498084980949810498114981249813498144981549816498174981849819498204982149822498234982449825498264982749828498294983049831498324983349834498354983649837498384983949840498414984249843498444984549846498474984849849498504985149852498534985449855498564985749858498594986049861498624986349864498654986649867498684986949870498714987249873498744987549876498774987849879498804988149882498834988449885498864988749888498894989049891498924989349894498954989649897498984989949900499014990249903499044990549906499074990849909499104991149912499134991449915499164991749918499194992049921499224992349924499254992649927499284992949930499314993249933499344993549936499374993849939499404994149942499434994449945499464994749948499494995049951499524995349954499554995649957499584995949960499614996249963499644996549966499674996849969499704997149972499734997449975499764997749978499794998049981499824998349984499854998649987499884998949990499914999249993499944999549996499974999849999500005000150002500035000450005500065000750008500095001050011500125001350014500155001650017500185001950020500215002250023500245002550026500275002850029500305003150032500335003450035500365003750038500395004050041500425004350044500455004650047500485004950050500515005250053500545005550056500575005850059500605006150062500635006450065500665006750068500695007050071500725007350074500755007650077500785007950080500815008250083500845008550086500875008850089500905009150092500935009450095500965009750098500995010050101501025010350104501055010650107501085010950110501115011250113501145011550116501175011850119501205012150122501235012450125501265012750128501295013050131501325013350134501355013650137501385013950140501415014250143501445014550146501475014850149501505015150152501535015450155501565015750158501595016050161501625016350164501655016650167501685016950170501715017250173501745017550176501775017850179501805018150182501835018450185501865018750188501895019050191501925019350194501955019650197501985019950200502015020250203502045020550206502075020850209502105021150212502135021450215502165021750218502195022050221502225022350224502255022650227502285022950230502315023250233502345023550236502375023850239502405024150242502435024450245502465024750248502495025050251502525025350254502555025650257502585025950260502615026250263502645026550266502675026850269502705027150272502735027450275502765027750278502795028050281502825028350284502855028650287502885028950290502915029250293502945029550296502975029850299503005030150302503035030450305503065030750308503095031050311503125031350314503155031650317503185031950320503215032250323503245032550326503275032850329503305033150332503335033450335503365033750338503395034050341503425034350344503455034650347503485034950350503515035250353503545035550356503575035850359503605036150362503635036450365503665036750368503695037050371503725037350374503755037650377503785037950380503815038250383503845038550386503875038850389503905039150392503935039450395503965039750398503995040050401504025040350404504055040650407504085040950410504115041250413504145041550416504175041850419504205042150422504235042450425504265042750428504295043050431504325043350434504355043650437504385043950440504415044250443504445044550446504475044850449504505045150452504535045450455504565045750458504595046050461504625046350464504655046650467504685046950470504715047250473504745047550476504775047850479504805048150482504835048450485504865048750488504895049050491504925049350494504955049650497504985049950500505015050250503505045050550506505075050850509505105051150512505135051450515505165051750518505195052050521505225052350524505255052650527505285052950530505315053250533505345053550536505375053850539505405054150542505435054450545505465054750548505495055050551505525055350554505555055650557505585055950560505615056250563505645056550566505675056850569505705057150572505735057450575505765057750578505795058050581505825058350584505855058650587505885058950590505915059250593505945059550596505975059850599506005060150602506035060450605506065060750608506095061050611506125061350614506155061650617506185061950620506215062250623506245062550626506275062850629506305063150632506335063450635506365063750638506395064050641506425064350644506455064650647506485064950650506515065250653506545065550656506575065850659506605066150662506635066450665506665066750668506695067050671506725067350674506755067650677506785067950680506815068250683506845068550686506875068850689506905069150692506935069450695506965069750698506995070050701507025070350704507055070650707507085070950710507115071250713507145071550716507175071850719507205072150722507235072450725507265072750728507295073050731507325073350734507355073650737507385073950740507415074250743507445074550746507475074850749507505075150752507535075450755507565075750758507595076050761507625076350764507655076650767507685076950770507715077250773507745077550776507775077850779507805078150782507835078450785507865078750788507895079050791507925079350794507955079650797507985079950800508015080250803508045080550806508075080850809508105081150812508135081450815508165081750818508195082050821508225082350824508255082650827508285082950830508315083250833508345083550836508375083850839508405084150842508435084450845508465084750848508495085050851508525085350854508555085650857508585085950860508615086250863508645086550866508675086850869508705087150872508735087450875508765087750878508795088050881508825088350884508855088650887508885088950890508915089250893508945089550896508975089850899509005090150902509035090450905509065090750908509095091050911509125091350914509155091650917509185091950920509215092250923509245092550926509275092850929509305093150932509335093450935509365093750938509395094050941509425094350944509455094650947509485094950950509515095250953509545095550956509575095850959509605096150962509635096450965509665096750968509695097050971509725097350974509755097650977509785097950980509815098250983509845098550986509875098850989509905099150992509935099450995509965099750998509995100051001510025100351004510055100651007510085100951010510115101251013510145101551016510175101851019510205102151022510235102451025510265102751028510295103051031510325103351034510355103651037510385103951040510415104251043510445104551046510475104851049510505105151052510535105451055510565105751058510595106051061510625106351064510655106651067510685106951070510715107251073510745107551076510775107851079510805108151082510835108451085510865108751088510895109051091510925109351094510955109651097510985109951100511015110251103511045110551106511075110851109511105111151112511135111451115511165111751118511195112051121511225112351124511255112651127511285112951130511315113251133511345113551136511375113851139511405114151142511435114451145511465114751148511495115051151511525115351154511555115651157511585115951160511615116251163511645116551166511675116851169511705117151172511735117451175511765117751178511795118051181511825118351184511855118651187511885118951190511915119251193511945119551196511975119851199512005120151202512035120451205512065120751208512095121051211512125121351214512155121651217512185121951220512215122251223512245122551226512275122851229512305123151232512335123451235512365123751238512395124051241512425124351244512455124651247512485124951250512515125251253512545125551256512575125851259512605126151262512635126451265512665126751268512695127051271512725127351274512755127651277512785127951280512815128251283512845128551286512875128851289512905129151292512935129451295512965129751298512995130051301513025130351304513055130651307513085130951310513115131251313513145131551316513175131851319513205132151322513235132451325513265132751328513295133051331513325133351334513355133651337513385133951340513415134251343513445134551346513475134851349513505135151352513535135451355513565135751358513595136051361513625136351364513655136651367513685136951370513715137251373513745137551376513775137851379513805138151382513835138451385513865138751388513895139051391513925139351394513955139651397513985139951400514015140251403514045140551406514075140851409514105141151412514135141451415514165141751418514195142051421514225142351424514255142651427514285142951430514315143251433514345143551436514375143851439514405144151442514435144451445514465144751448514495145051451514525145351454514555145651457514585145951460514615146251463514645146551466514675146851469514705147151472514735147451475514765147751478514795148051481514825148351484514855148651487514885148951490514915149251493514945149551496514975149851499515005150151502515035150451505515065150751508515095151051511515125151351514515155151651517515185151951520515215152251523515245152551526515275152851529515305153151532515335153451535515365153751538515395154051541515425154351544515455154651547515485154951550515515155251553515545155551556515575155851559515605156151562515635156451565515665156751568515695157051571515725157351574515755157651577515785157951580515815158251583515845158551586515875158851589515905159151592515935159451595515965159751598515995160051601516025160351604516055160651607516085160951610516115161251613516145161551616516175161851619516205162151622516235162451625516265162751628516295163051631516325163351634516355163651637516385163951640516415164251643516445164551646516475164851649516505165151652516535165451655516565165751658516595166051661516625166351664516655166651667516685166951670516715167251673516745167551676516775167851679516805168151682516835168451685516865168751688516895169051691516925169351694516955169651697516985169951700517015170251703517045170551706517075170851709517105171151712517135171451715517165171751718517195172051721517225172351724517255172651727517285172951730517315173251733517345173551736517375173851739517405174151742517435174451745517465174751748517495175051751517525175351754517555175651757517585175951760517615176251763517645176551766517675176851769517705177151772517735177451775517765177751778517795178051781517825178351784517855178651787517885178951790517915179251793517945179551796517975179851799518005180151802518035180451805518065180751808518095181051811518125181351814518155181651817518185181951820518215182251823518245182551826518275182851829518305183151832518335183451835518365183751838518395184051841518425184351844518455184651847518485184951850518515185251853518545185551856518575185851859518605186151862518635186451865518665186751868518695187051871518725187351874518755187651877518785187951880518815188251883518845188551886518875188851889518905189151892518935189451895518965189751898518995190051901519025190351904519055190651907519085190951910519115191251913519145191551916519175191851919519205192151922519235192451925519265192751928519295193051931519325193351934519355193651937519385193951940519415194251943519445194551946519475194851949519505195151952519535195451955519565195751958519595196051961519625196351964519655196651967519685196951970519715197251973519745197551976519775197851979519805198151982519835198451985519865198751988519895199051991519925199351994519955199651997519985199952000520015200252003520045200552006520075200852009520105201152012520135201452015520165201752018520195202052021520225202352024520255202652027520285202952030520315203252033520345203552036520375203852039520405204152042520435204452045520465204752048520495205052051520525205352054520555205652057520585205952060520615206252063520645206552066520675206852069520705207152072520735207452075520765207752078520795208052081520825208352084520855208652087520885208952090520915209252093520945209552096520975209852099521005210152102521035210452105521065210752108521095211052111521125211352114521155211652117521185211952120521215212252123521245212552126521275212852129521305213152132521335213452135521365213752138521395214052141521425214352144521455214652147521485214952150521515215252153521545215552156521575215852159521605216152162521635216452165521665216752168521695217052171521725217352174521755217652177521785217952180521815218252183521845218552186521875218852189521905219152192521935219452195521965219752198521995220052201522025220352204522055220652207522085220952210522115221252213522145221552216522175221852219522205222152222522235222452225522265222752228522295223052231522325223352234522355223652237522385223952240522415224252243522445224552246522475224852249522505225152252522535225452255522565225752258522595226052261522625226352264522655226652267522685226952270522715227252273522745227552276522775227852279522805228152282522835228452285522865228752288522895229052291522925229352294522955229652297522985229952300523015230252303523045230552306523075230852309523105231152312523135231452315523165231752318523195232052321523225232352324523255232652327523285232952330523315233252333523345233552336523375233852339523405234152342523435234452345523465234752348523495235052351523525235352354523555235652357523585235952360523615236252363523645236552366523675236852369523705237152372523735237452375523765237752378523795238052381523825238352384523855238652387523885238952390523915239252393523945239552396523975239852399524005240152402524035240452405524065240752408524095241052411524125241352414524155241652417524185241952420524215242252423524245242552426524275242852429524305243152432524335243452435524365243752438524395244052441524425244352444524455244652447524485244952450524515245252453524545245552456524575245852459524605246152462524635246452465524665246752468524695247052471524725247352474524755247652477524785247952480524815248252483524845248552486524875248852489524905249152492524935249452495524965249752498524995250052501525025250352504525055250652507525085250952510525115251252513525145251552516525175251852519525205252152522525235252452525525265252752528525295253052531525325253352534525355253652537525385253952540525415254252543525445254552546525475254852549525505255152552525535255452555525565255752558525595256052561525625256352564525655256652567525685256952570525715257252573525745257552576525775257852579525805258152582525835258452585525865258752588525895259052591525925259352594525955259652597525985259952600526015260252603526045260552606526075260852609526105261152612526135261452615526165261752618526195262052621526225262352624526255262652627526285262952630526315263252633526345263552636526375263852639526405264152642526435264452645526465264752648526495265052651526525265352654526555265652657526585265952660526615266252663526645266552666526675266852669526705267152672526735267452675526765267752678526795268052681526825268352684526855268652687526885268952690526915269252693526945269552696526975269852699527005270152702527035270452705527065270752708527095271052711527125271352714527155271652717527185271952720527215272252723527245272552726527275272852729527305273152732527335273452735527365273752738527395274052741527425274352744527455274652747527485274952750527515275252753527545275552756527575275852759527605276152762527635276452765527665276752768527695277052771527725277352774527755277652777527785277952780527815278252783527845278552786527875278852789527905279152792527935279452795527965279752798527995280052801528025280352804528055280652807528085280952810528115281252813528145281552816528175281852819528205282152822528235282452825528265282752828528295283052831528325283352834528355283652837528385283952840528415284252843528445284552846528475284852849528505285152852528535285452855528565285752858528595286052861528625286352864528655286652867528685286952870528715287252873528745287552876528775287852879528805288152882528835288452885528865288752888528895289052891528925289352894528955289652897528985289952900529015290252903529045290552906529075290852909529105291152912529135291452915529165291752918529195292052921529225292352924529255292652927529285292952930529315293252933529345293552936529375293852939529405294152942529435294452945529465294752948529495295052951529525295352954529555295652957529585295952960529615296252963529645296552966529675296852969529705297152972529735297452975529765297752978529795298052981529825298352984529855298652987529885298952990529915299252993529945299552996529975299852999530005300153002530035300453005530065300753008530095301053011530125301353014530155301653017530185301953020530215302253023530245302553026530275302853029530305303153032530335303453035530365303753038530395304053041530425304353044530455304653047530485304953050530515305253053530545305553056530575305853059530605306153062530635306453065530665306753068530695307053071530725307353074530755307653077530785307953080530815308253083530845308553086530875308853089530905309153092530935309453095530965309753098530995310053101531025310353104531055310653107531085310953110531115311253113531145311553116531175311853119531205312153122531235312453125531265312753128531295313053131531325313353134531355313653137531385313953140531415314253143531445314553146531475314853149531505315153152531535315453155531565315753158531595316053161531625316353164531655316653167531685316953170531715317253173531745317553176531775317853179531805318153182531835318453185531865318753188531895319053191531925319353194531955319653197531985319953200532015320253203532045320553206532075320853209532105321153212532135321453215532165321753218532195322053221532225322353224532255322653227532285322953230532315323253233532345323553236532375323853239532405324153242532435324453245532465324753248532495325053251532525325353254532555325653257532585325953260532615326253263532645326553266532675326853269532705327153272532735327453275532765327753278532795328053281532825328353284532855328653287532885328953290532915329253293532945329553296532975329853299533005330153302533035330453305533065330753308533095331053311533125331353314533155331653317533185331953320533215332253323533245332553326533275332853329533305333153332533335333453335533365333753338533395334053341533425334353344533455334653347533485334953350533515335253353533545335553356533575335853359533605336153362533635336453365533665336753368533695337053371533725337353374533755337653377533785337953380533815338253383533845338553386533875338853389533905339153392533935339453395533965339753398533995340053401534025340353404534055340653407534085340953410534115341253413534145341553416534175341853419534205342153422534235342453425534265342753428534295343053431534325343353434534355343653437534385343953440534415344253443534445344553446534475344853449534505345153452534535345453455534565345753458534595346053461534625346353464534655346653467534685346953470534715347253473534745347553476534775347853479534805348153482534835348453485534865348753488534895349053491534925349353494534955349653497534985349953500535015350253503535045350553506535075350853509535105351153512535135351453515535165351753518535195352053521535225352353524535255352653527535285352953530535315353253533535345353553536535375353853539535405354153542535435354453545535465354753548535495355053551535525355353554535555355653557535585355953560535615356253563535645356553566535675356853569535705357153572535735357453575535765357753578535795358053581535825358353584535855358653587535885358953590535915359253593535945359553596535975359853599536005360153602536035360453605536065360753608536095361053611536125361353614536155361653617536185361953620536215362253623536245362553626536275362853629536305363153632536335363453635536365363753638536395364053641536425364353644536455364653647536485364953650536515365253653536545365553656536575365853659536605366153662536635366453665536665366753668536695367053671536725367353674536755367653677536785367953680536815368253683536845368553686536875368853689536905369153692536935369453695536965369753698536995370053701537025370353704537055370653707537085370953710537115371253713537145371553716537175371853719537205372153722537235372453725537265372753728537295373053731537325373353734537355373653737537385373953740537415374253743537445374553746537475374853749537505375153752537535375453755537565375753758537595376053761537625376353764537655376653767537685376953770537715377253773537745377553776537775377853779537805378153782537835378453785537865378753788537895379053791537925379353794537955379653797537985379953800538015380253803538045380553806538075380853809538105381153812538135381453815538165381753818538195382053821538225382353824538255382653827538285382953830538315383253833538345383553836538375383853839538405384153842538435384453845538465384753848538495385053851538525385353854538555385653857538585385953860538615386253863538645386553866538675386853869538705387153872538735387453875538765387753878538795388053881538825388353884538855388653887538885388953890538915389253893538945389553896538975389853899539005390153902539035390453905539065390753908539095391053911539125391353914539155391653917539185391953920539215392253923539245392553926539275392853929539305393153932539335393453935539365393753938539395394053941539425394353944539455394653947539485394953950539515395253953539545395553956539575395853959539605396153962539635396453965539665396753968539695397053971539725397353974539755397653977539785397953980539815398253983539845398553986539875398853989539905399153992539935399453995539965399753998539995400054001540025400354004540055400654007540085400954010540115401254013540145401554016540175401854019540205402154022540235402454025540265402754028540295403054031540325403354034540355403654037540385403954040540415404254043540445404554046540475404854049540505405154052540535405454055540565405754058540595406054061540625406354064540655406654067540685406954070540715407254073540745407554076540775407854079540805408154082540835408454085540865408754088540895409054091540925409354094540955409654097540985409954100541015410254103541045410554106541075410854109541105411154112541135411454115541165411754118541195412054121541225412354124541255412654127541285412954130541315413254133541345413554136541375413854139541405414154142541435414454145541465414754148541495415054151541525415354154541555415654157541585415954160541615416254163541645416554166541675416854169541705417154172541735417454175541765417754178541795418054181541825418354184541855418654187541885418954190541915419254193541945419554196541975419854199542005420154202542035420454205542065420754208542095421054211542125421354214542155421654217542185421954220542215422254223542245422554226542275422854229542305423154232542335423454235542365423754238542395424054241542425424354244542455424654247542485424954250542515425254253542545425554256542575425854259542605426154262542635426454265542665426754268542695427054271542725427354274542755427654277542785427954280542815428254283542845428554286542875428854289542905429154292542935429454295542965429754298542995430054301543025430354304543055430654307543085430954310543115431254313543145431554316543175431854319543205432154322543235432454325543265432754328543295433054331543325433354334543355433654337543385433954340543415434254343543445434554346543475434854349543505435154352543535435454355543565435754358543595436054361543625436354364543655436654367543685436954370543715437254373543745437554376543775437854379543805438154382543835438454385543865438754388543895439054391543925439354394543955439654397543985439954400544015440254403544045440554406544075440854409544105441154412544135441454415544165441754418544195442054421544225442354424544255442654427544285442954430544315443254433544345443554436544375443854439544405444154442544435444454445544465444754448544495445054451544525445354454544555445654457544585445954460544615446254463544645446554466544675446854469544705447154472544735447454475544765447754478544795448054481544825448354484544855448654487544885448954490544915449254493544945449554496544975449854499545005450154502545035450454505545065450754508545095451054511545125451354514545155451654517545185451954520545215452254523545245452554526545275452854529545305453154532545335453454535545365453754538545395454054541545425454354544545455454654547545485454954550545515455254553545545455554556545575455854559545605456154562545635456454565545665456754568545695457054571545725457354574545755457654577545785457954580545815458254583545845458554586545875458854589545905459154592545935459454595545965459754598545995460054601546025460354604546055460654607546085460954610546115461254613546145461554616546175461854619546205462154622546235462454625546265462754628546295463054631546325463354634546355463654637546385463954640546415464254643546445464554646546475464854649546505465154652546535465454655546565465754658546595466054661546625466354664546655466654667546685466954670546715467254673546745467554676546775467854679546805468154682546835468454685546865468754688546895469054691546925469354694546955469654697546985469954700547015470254703547045470554706547075470854709547105471154712547135471454715547165471754718547195472054721547225472354724547255472654727547285472954730547315473254733547345473554736547375473854739547405474154742547435474454745547465474754748547495475054751547525475354754547555475654757547585475954760547615476254763547645476554766547675476854769547705477154772547735477454775547765477754778547795478054781547825478354784547855478654787547885478954790547915479254793547945479554796547975479854799548005480154802548035480454805548065480754808548095481054811548125481354814548155481654817548185481954820548215482254823548245482554826548275482854829548305483154832548335483454835548365483754838548395484054841548425484354844548455484654847548485484954850548515485254853548545485554856548575485854859548605486154862548635486454865548665486754868548695487054871548725487354874548755487654877548785487954880548815488254883548845488554886548875488854889548905489154892548935489454895548965489754898548995490054901549025490354904549055490654907549085490954910549115491254913549145491554916549175491854919549205492154922549235492454925549265492754928549295493054931549325493354934549355493654937549385493954940549415494254943549445494554946549475494854949549505495154952549535495454955549565495754958549595496054961549625496354964549655496654967549685496954970549715497254973549745497554976549775497854979549805498154982549835498454985549865498754988549895499054991549925499354994549955499654997549985499955000550015500255003550045500555006550075500855009550105501155012550135501455015550165501755018550195502055021550225502355024550255502655027550285502955030550315503255033550345503555036550375503855039550405504155042550435504455045550465504755048550495505055051550525505355054550555505655057550585505955060550615506255063550645506555066550675506855069550705507155072550735507455075550765507755078550795508055081550825508355084550855508655087550885508955090550915509255093550945509555096550975509855099551005510155102551035510455105551065510755108551095511055111551125511355114551155511655117551185511955120551215512255123551245512555126551275512855129551305513155132551335513455135551365513755138551395514055141551425514355144551455514655147551485514955150551515515255153551545515555156551575515855159551605516155162551635516455165551665516755168551695517055171551725517355174551755517655177551785517955180551815518255183551845518555186551875518855189551905519155192551935519455195551965519755198551995520055201552025520355204552055520655207552085520955210552115521255213552145521555216552175521855219552205522155222552235522455225552265522755228552295523055231552325523355234552355523655237552385523955240552415524255243552445524555246552475524855249552505525155252552535525455255552565525755258552595526055261552625526355264552655526655267552685526955270552715527255273552745527555276552775527855279552805528155282552835528455285552865528755288552895529055291552925529355294552955529655297552985529955300553015530255303553045530555306553075530855309553105531155312553135531455315553165531755318553195532055321553225532355324553255532655327553285532955330553315533255333553345533555336553375533855339553405534155342553435534455345553465534755348553495535055351553525535355354553555535655357553585535955360553615536255363553645536555366553675536855369553705537155372553735537455375553765537755378553795538055381553825538355384553855538655387553885538955390553915539255393553945539555396553975539855399554005540155402554035540455405554065540755408554095541055411554125541355414554155541655417554185541955420554215542255423554245542555426554275542855429554305543155432554335543455435554365543755438554395544055441554425544355444554455544655447554485544955450554515545255453554545545555456554575545855459554605546155462554635546455465554665546755468554695547055471554725547355474554755547655477554785547955480554815548255483554845548555486554875548855489554905549155492554935549455495554965549755498554995550055501555025550355504555055550655507555085550955510555115551255513555145551555516555175551855519555205552155522555235552455525555265552755528555295553055531555325553355534555355553655537555385553955540555415554255543555445554555546555475554855549555505555155552555535555455555555565555755558555595556055561555625556355564555655556655567555685556955570555715557255573555745557555576555775557855579555805558155582555835558455585555865558755588555895559055591555925559355594555955559655597555985559955600556015560255603556045560555606556075560855609556105561155612556135561455615556165561755618556195562055621556225562355624556255562655627556285562955630556315563255633556345563555636556375563855639556405564155642556435564455645556465564755648556495565055651556525565355654556555565655657556585565955660556615566255663556645566555666556675566855669556705567155672556735567455675556765567755678556795568055681556825568355684556855568655687556885568955690556915569255693556945569555696556975569855699557005570155702557035570455705557065570755708557095571055711557125571355714557155571655717557185571955720557215572255723557245572555726557275572855729557305573155732557335573455735557365573755738557395574055741557425574355744557455574655747557485574955750557515575255753557545575555756557575575855759557605576155762557635576455765557665576755768557695577055771557725577355774557755577655777557785577955780557815578255783557845578555786557875578855789557905579155792557935579455795557965579755798557995580055801558025580355804558055580655807558085580955810558115581255813558145581555816558175581855819558205582155822558235582455825558265582755828558295583055831558325583355834558355583655837558385583955840558415584255843558445584555846558475584855849558505585155852558535585455855558565585755858558595586055861558625586355864558655586655867558685586955870558715587255873558745587555876558775587855879558805588155882558835588455885558865588755888558895589055891558925589355894558955589655897558985589955900559015590255903559045590555906559075590855909559105591155912559135591455915559165591755918559195592055921559225592355924559255592655927559285592955930559315593255933559345593555936559375593855939559405594155942559435594455945559465594755948559495595055951559525595355954559555595655957559585595955960559615596255963559645596555966559675596855969559705597155972559735597455975559765597755978559795598055981559825598355984559855598655987559885598955990559915599255993559945599555996559975599855999560005600156002560035600456005560065600756008560095601056011560125601356014560155601656017560185601956020560215602256023560245602556026560275602856029560305603156032560335603456035560365603756038560395604056041560425604356044560455604656047560485604956050560515605256053560545605556056560575605856059560605606156062560635606456065560665606756068560695607056071560725607356074560755607656077560785607956080560815608256083560845608556086560875608856089560905609156092560935609456095560965609756098560995610056101561025610356104561055610656107561085610956110561115611256113561145611556116561175611856119561205612156122561235612456125561265612756128561295613056131561325613356134561355613656137561385613956140561415614256143561445614556146561475614856149561505615156152561535615456155561565615756158561595616056161561625616356164561655616656167561685616956170561715617256173561745617556176561775617856179561805618156182561835618456185561865618756188561895619056191561925619356194561955619656197561985619956200562015620256203562045620556206562075620856209562105621156212562135621456215562165621756218562195622056221562225622356224562255622656227562285622956230562315623256233562345623556236562375623856239562405624156242562435624456245562465624756248562495625056251562525625356254562555625656257562585625956260562615626256263562645626556266562675626856269562705627156272562735627456275562765627756278562795628056281562825628356284562855628656287562885628956290562915629256293562945629556296562975629856299563005630156302563035630456305563065630756308563095631056311563125631356314563155631656317563185631956320563215632256323563245632556326563275632856329563305633156332563335633456335563365633756338563395634056341563425634356344563455634656347563485634956350563515635256353563545635556356563575635856359563605636156362563635636456365563665636756368563695637056371563725637356374563755637656377563785637956380563815638256383563845638556386563875638856389563905639156392563935639456395563965639756398563995640056401564025640356404564055640656407564085640956410564115641256413564145641556416564175641856419564205642156422564235642456425564265642756428564295643056431564325643356434564355643656437564385643956440564415644256443564445644556446564475644856449564505645156452564535645456455564565645756458564595646056461564625646356464564655646656467564685646956470564715647256473564745647556476564775647856479564805648156482564835648456485564865648756488564895649056491564925649356494564955649656497564985649956500565015650256503565045650556506565075650856509565105651156512565135651456515565165651756518565195652056521565225652356524565255652656527565285652956530565315653256533565345653556536565375653856539565405654156542565435654456545565465654756548565495655056551565525655356554565555655656557565585655956560565615656256563565645656556566565675656856569565705657156572565735657456575565765657756578565795658056581565825658356584565855658656587565885658956590565915659256593565945659556596565975659856599566005660156602566035660456605566065660756608566095661056611566125661356614566155661656617566185661956620566215662256623566245662556626566275662856629566305663156632566335663456635566365663756638566395664056641566425664356644566455664656647566485664956650566515665256653566545665556656566575665856659566605666156662566635666456665566665666756668566695667056671566725667356674566755667656677566785667956680566815668256683566845668556686566875668856689566905669156692566935669456695566965669756698566995670056701567025670356704567055670656707567085670956710567115671256713567145671556716567175671856719567205672156722567235672456725567265672756728567295673056731567325673356734567355673656737567385673956740567415674256743567445674556746567475674856749567505675156752567535675456755567565675756758567595676056761567625676356764567655676656767567685676956770567715677256773567745677556776567775677856779567805678156782567835678456785567865678756788567895679056791567925679356794567955679656797567985679956800568015680256803568045680556806568075680856809568105681156812568135681456815568165681756818568195682056821568225682356824568255682656827568285682956830568315683256833568345683556836568375683856839568405684156842568435684456845568465684756848568495685056851568525685356854568555685656857568585685956860568615686256863568645686556866568675686856869568705687156872568735687456875568765687756878568795688056881568825688356884568855688656887568885688956890568915689256893568945689556896568975689856899569005690156902569035690456905569065690756908569095691056911569125691356914569155691656917569185691956920569215692256923569245692556926569275692856929569305693156932569335693456935569365693756938569395694056941569425694356944569455694656947569485694956950569515695256953569545695556956569575695856959569605696156962569635696456965569665696756968569695697056971569725697356974569755697656977569785697956980569815698256983569845698556986569875698856989569905699156992569935699456995569965699756998569995700057001570025700357004570055700657007570085700957010570115701257013570145701557016570175701857019570205702157022570235702457025570265702757028570295703057031570325703357034570355703657037570385703957040570415704257043570445704557046570475704857049570505705157052570535705457055570565705757058570595706057061570625706357064570655706657067570685706957070570715707257073570745707557076570775707857079570805708157082570835708457085570865708757088570895709057091570925709357094570955709657097570985709957100571015710257103571045710557106571075710857109571105711157112571135711457115571165711757118571195712057121571225712357124571255712657127571285712957130571315713257133571345713557136571375713857139571405714157142571435714457145571465714757148571495715057151571525715357154571555715657157571585715957160571615716257163571645716557166571675716857169571705717157172571735717457175571765717757178571795718057181571825718357184571855718657187571885718957190571915719257193571945719557196571975719857199572005720157202572035720457205572065720757208572095721057211572125721357214572155721657217572185721957220572215722257223572245722557226572275722857229572305723157232572335723457235572365723757238572395724057241572425724357244572455724657247572485724957250572515725257253572545725557256572575725857259572605726157262572635726457265572665726757268572695727057271572725727357274572755727657277572785727957280572815728257283572845728557286572875728857289572905729157292572935729457295572965729757298572995730057301573025730357304573055730657307573085730957310573115731257313573145731557316573175731857319573205732157322573235732457325
  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__(26)))
  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__(36);
  2531. var coreJpg = __w_pdfjs_require__(37);
  2532. var coreJpx = __w_pdfjs_require__(18);
  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. var sharedUtil = __w_pdfjs_require__(0);
  18877. var displayDOMUtils = __w_pdfjs_require__(3);
  18878. var AnnotationBorderStyleType = sharedUtil.AnnotationBorderStyleType;
  18879. var AnnotationType = sharedUtil.AnnotationType;
  18880. var stringToPDFString = sharedUtil.stringToPDFString;
  18881. var Util = sharedUtil.Util;
  18882. var addLinkAttributes = displayDOMUtils.addLinkAttributes;
  18883. var LinkTarget = displayDOMUtils.LinkTarget;
  18884. var getFilenameFromUrl = displayDOMUtils.getFilenameFromUrl;
  18885. var warn = sharedUtil.warn;
  18886. var CustomStyle = displayDOMUtils.CustomStyle;
  18887. var getDefaultSetting = displayDOMUtils.getDefaultSetting;
  18888. function AnnotationElementFactory() {
  18889. }
  18890. AnnotationElementFactory.prototype = {
  18891. create: function AnnotationElementFactory_create(parameters) {
  18892. var subtype = parameters.data.annotationType;
  18893. switch (subtype) {
  18894. case AnnotationType.LINK:
  18895. return new LinkAnnotationElement(parameters);
  18896. case AnnotationType.TEXT:
  18897. return new TextAnnotationElement(parameters);
  18898. case AnnotationType.WIDGET:
  18899. var fieldType = parameters.data.fieldType;
  18900. switch (fieldType) {
  18901. case 'Tx':
  18902. return new TextWidgetAnnotationElement(parameters);
  18903. case 'Btn':
  18904. if (parameters.data.radioButton) {
  18905. return new RadioButtonWidgetAnnotationElement(parameters);
  18906. } else if (parameters.data.checkBox) {
  18907. return new CheckboxWidgetAnnotationElement(parameters);
  18908. }
  18909. warn('Unimplemented button widget annotation: pushbutton');
  18910. break;
  18911. case 'Ch':
  18912. return new ChoiceWidgetAnnotationElement(parameters);
  18913. }
  18914. return new WidgetAnnotationElement(parameters);
  18915. case AnnotationType.POPUP:
  18916. return new PopupAnnotationElement(parameters);
  18917. case AnnotationType.HIGHLIGHT:
  18918. return new HighlightAnnotationElement(parameters);
  18919. case AnnotationType.UNDERLINE:
  18920. return new UnderlineAnnotationElement(parameters);
  18921. case AnnotationType.SQUIGGLY:
  18922. return new SquigglyAnnotationElement(parameters);
  18923. case AnnotationType.STRIKEOUT:
  18924. return new StrikeOutAnnotationElement(parameters);
  18925. case AnnotationType.FILEATTACHMENT:
  18926. return new FileAttachmentAnnotationElement(parameters);
  18927. default:
  18928. return new AnnotationElement(parameters);
  18929. }
  18930. }
  18931. };
  18932. var AnnotationElement = function AnnotationElementClosure() {
  18933. function AnnotationElement(parameters, isRenderable) {
  18934. this.isRenderable = isRenderable || false;
  18935. this.data = parameters.data;
  18936. this.layer = parameters.layer;
  18937. this.page = parameters.page;
  18938. this.viewport = parameters.viewport;
  18939. this.linkService = parameters.linkService;
  18940. this.downloadManager = parameters.downloadManager;
  18941. this.imageResourcesPath = parameters.imageResourcesPath;
  18942. this.renderInteractiveForms = parameters.renderInteractiveForms;
  18943. if (isRenderable) {
  18944. this.container = this._createContainer();
  18945. }
  18946. }
  18947. AnnotationElement.prototype = {
  18948. _createContainer: function AnnotationElement_createContainer() {
  18949. var data = this.data, page = this.page, viewport = this.viewport;
  18950. var container = document.createElement('section');
  18951. var width = data.rect[2] - data.rect[0];
  18952. var height = data.rect[3] - data.rect[1];
  18953. container.setAttribute('data-annotation-id', data.id);
  18954. var rect = Util.normalizeRect([
  18955. data.rect[0],
  18956. page.view[3] - data.rect[1] + page.view[1],
  18957. data.rect[2],
  18958. page.view[3] - data.rect[3] + page.view[1]
  18959. ]);
  18960. CustomStyle.setProp('transform', container, 'matrix(' + viewport.transform.join(',') + ')');
  18961. CustomStyle.setProp('transformOrigin', container, -rect[0] + 'px ' + -rect[1] + 'px');
  18962. if (data.borderStyle.width > 0) {
  18963. container.style.borderWidth = data.borderStyle.width + 'px';
  18964. if (data.borderStyle.style !== AnnotationBorderStyleType.UNDERLINE) {
  18965. width = width - 2 * data.borderStyle.width;
  18966. height = height - 2 * data.borderStyle.width;
  18967. }
  18968. var horizontalRadius = data.borderStyle.horizontalCornerRadius;
  18969. var verticalRadius = data.borderStyle.verticalCornerRadius;
  18970. if (horizontalRadius > 0 || verticalRadius > 0) {
  18971. var radius = horizontalRadius + 'px / ' + verticalRadius + 'px';
  18972. CustomStyle.setProp('borderRadius', container, radius);
  18973. }
  18974. switch (data.borderStyle.style) {
  18975. case AnnotationBorderStyleType.SOLID:
  18976. container.style.borderStyle = 'solid';
  18977. break;
  18978. case AnnotationBorderStyleType.DASHED:
  18979. container.style.borderStyle = 'dashed';
  18980. break;
  18981. case AnnotationBorderStyleType.BEVELED:
  18982. warn('Unimplemented border style: beveled');
  18983. break;
  18984. case AnnotationBorderStyleType.INSET:
  18985. warn('Unimplemented border style: inset');
  18986. break;
  18987. case AnnotationBorderStyleType.UNDERLINE:
  18988. container.style.borderBottomStyle = 'solid';
  18989. break;
  18990. default:
  18991. break;
  18992. }
  18993. if (data.color) {
  18994. container.style.borderColor = Util.makeCssRgb(data.color[0] | 0, data.color[1] | 0, data.color[2] | 0);
  18995. } else {
  18996. container.style.borderWidth = 0;
  18997. }
  18998. }
  18999. container.style.left = rect[0] + 'px';
  19000. container.style.top = rect[1] + 'px';
  19001. container.style.width = width + 'px';
  19002. container.style.height = height + 'px';
  19003. return container;
  19004. },
  19005. _createPopup: function AnnotationElement_createPopup(container, trigger, data) {
  19006. if (!trigger) {
  19007. trigger = document.createElement('div');
  19008. trigger.style.height = container.style.height;
  19009. trigger.style.width = container.style.width;
  19010. container.appendChild(trigger);
  19011. }
  19012. var popupElement = new PopupElement({
  19013. container: container,
  19014. trigger: trigger,
  19015. color: data.color,
  19016. title: data.title,
  19017. contents: data.contents,
  19018. hideWrapper: true
  19019. });
  19020. var popup = popupElement.render();
  19021. popup.style.left = container.style.width;
  19022. container.appendChild(popup);
  19023. },
  19024. render: function AnnotationElement_render() {
  19025. throw new Error('Abstract method AnnotationElement.render called');
  19026. }
  19027. };
  19028. return AnnotationElement;
  19029. }();
  19030. var LinkAnnotationElement = function LinkAnnotationElementClosure() {
  19031. function LinkAnnotationElement(parameters) {
  19032. AnnotationElement.call(this, parameters, true);
  19033. }
  19034. Util.inherit(LinkAnnotationElement, AnnotationElement, {
  19035. render: function LinkAnnotationElement_render() {
  19036. this.container.className = 'linkAnnotation';
  19037. var link = document.createElement('a');
  19038. addLinkAttributes(link, {
  19039. url: this.data.url,
  19040. target: this.data.newWindow ? LinkTarget.BLANK : undefined
  19041. });
  19042. if (!this.data.url) {
  19043. if (this.data.action) {
  19044. this._bindNamedAction(link, this.data.action);
  19045. } else {
  19046. this._bindLink(link, this.data.dest);
  19047. }
  19048. }
  19049. this.container.appendChild(link);
  19050. return this.container;
  19051. },
  19052. _bindLink: function LinkAnnotationElement_bindLink(link, destination) {
  19053. var self = this;
  19054. link.href = this.linkService.getDestinationHash(destination);
  19055. link.onclick = function () {
  19056. if (destination) {
  19057. self.linkService.navigateTo(destination);
  19058. }
  19059. return false;
  19060. };
  19061. if (destination) {
  19062. link.className = 'internalLink';
  19063. }
  19064. },
  19065. _bindNamedAction: function LinkAnnotationElement_bindNamedAction(link, action) {
  19066. var self = this;
  19067. link.href = this.linkService.getAnchorUrl('');
  19068. link.onclick = function () {
  19069. self.linkService.executeNamedAction(action);
  19070. return false;
  19071. };
  19072. link.className = 'internalLink';
  19073. }
  19074. });
  19075. return LinkAnnotationElement;
  19076. }();
  19077. var TextAnnotationElement = function TextAnnotationElementClosure() {
  19078. function TextAnnotationElement(parameters) {
  19079. var isRenderable = !!(parameters.data.hasPopup || parameters.data.title || parameters.data.contents);
  19080. AnnotationElement.call(this, parameters, isRenderable);
  19081. }
  19082. Util.inherit(TextAnnotationElement, AnnotationElement, {
  19083. render: function TextAnnotationElement_render() {
  19084. this.container.className = 'textAnnotation';
  19085. var image = document.createElement('img');
  19086. image.style.height = this.container.style.height;
  19087. image.style.width = this.container.style.width;
  19088. image.src = this.imageResourcesPath + 'annotation-' + this.data.name.toLowerCase() + '.svg';
  19089. image.alt = '[{{type}} Annotation]';
  19090. image.dataset.l10nId = 'text_annotation_type';
  19091. image.dataset.l10nArgs = JSON.stringify({ type: this.data.name });
  19092. if (!this.data.hasPopup) {
  19093. this._createPopup(this.container, image, this.data);
  19094. }
  19095. this.container.appendChild(image);
  19096. return this.container;
  19097. }
  19098. });
  19099. return TextAnnotationElement;
  19100. }();
  19101. var WidgetAnnotationElement = function WidgetAnnotationElementClosure() {
  19102. function WidgetAnnotationElement(parameters, isRenderable) {
  19103. AnnotationElement.call(this, parameters, isRenderable);
  19104. }
  19105. Util.inherit(WidgetAnnotationElement, AnnotationElement, {
  19106. render: function WidgetAnnotationElement_render() {
  19107. return this.container;
  19108. }
  19109. });
  19110. return WidgetAnnotationElement;
  19111. }();
  19112. var TextWidgetAnnotationElement = function TextWidgetAnnotationElementClosure() {
  19113. var TEXT_ALIGNMENT = [
  19114. 'left',
  19115. 'center',
  19116. 'right'
  19117. ];
  19118. function TextWidgetAnnotationElement(parameters) {
  19119. var isRenderable = parameters.renderInteractiveForms || !parameters.data.hasAppearance && !!parameters.data.fieldValue;
  19120. WidgetAnnotationElement.call(this, parameters, isRenderable);
  19121. }
  19122. Util.inherit(TextWidgetAnnotationElement, WidgetAnnotationElement, {
  19123. render: function TextWidgetAnnotationElement_render() {
  19124. this.container.className = 'textWidgetAnnotation';
  19125. var element = null;
  19126. if (this.renderInteractiveForms) {
  19127. if (this.data.multiLine) {
  19128. element = document.createElement('textarea');
  19129. element.textContent = this.data.fieldValue;
  19130. } else {
  19131. element = document.createElement('input');
  19132. element.type = 'text';
  19133. element.setAttribute('value', this.data.fieldValue);
  19134. }
  19135. element.disabled = this.data.readOnly;
  19136. if (this.data.maxLen !== null) {
  19137. element.maxLength = this.data.maxLen;
  19138. }
  19139. if (this.data.comb) {
  19140. var fieldWidth = this.data.rect[2] - this.data.rect[0];
  19141. var combWidth = fieldWidth / this.data.maxLen;
  19142. element.classList.add('comb');
  19143. element.style.letterSpacing = 'calc(' + combWidth + 'px - 1ch)';
  19144. }
  19145. } else {
  19146. element = document.createElement('div');
  19147. element.textContent = this.data.fieldValue;
  19148. element.style.verticalAlign = 'middle';
  19149. element.style.display = 'table-cell';
  19150. var font = null;
  19151. if (this.data.fontRefName) {
  19152. font = this.page.commonObjs.getData(this.data.fontRefName);
  19153. }
  19154. this._setTextStyle(element, font);
  19155. }
  19156. if (this.data.textAlignment !== null) {
  19157. element.style.textAlign = TEXT_ALIGNMENT[this.data.textAlignment];
  19158. }
  19159. this.container.appendChild(element);
  19160. return this.container;
  19161. },
  19162. _setTextStyle: function TextWidgetAnnotationElement_setTextStyle(element, font) {
  19163. var style = element.style;
  19164. style.fontSize = this.data.fontSize + 'px';
  19165. style.direction = this.data.fontDirection < 0 ? 'rtl' : 'ltr';
  19166. if (!font) {
  19167. return;
  19168. }
  19169. style.fontWeight = font.black ? font.bold ? '900' : 'bold' : font.bold ? 'bold' : 'normal';
  19170. style.fontStyle = font.italic ? 'italic' : 'normal';
  19171. var fontFamily = font.loadedName ? '"' + font.loadedName + '", ' : '';
  19172. var fallbackName = font.fallbackName || 'Helvetica, sans-serif';
  19173. style.fontFamily = fontFamily + fallbackName;
  19174. }
  19175. });
  19176. return TextWidgetAnnotationElement;
  19177. }();
  19178. var CheckboxWidgetAnnotationElement = function CheckboxWidgetAnnotationElementClosure() {
  19179. function CheckboxWidgetAnnotationElement(parameters) {
  19180. WidgetAnnotationElement.call(this, parameters, parameters.renderInteractiveForms);
  19181. }
  19182. Util.inherit(CheckboxWidgetAnnotationElement, WidgetAnnotationElement, {
  19183. render: function CheckboxWidgetAnnotationElement_render() {
  19184. this.container.className = 'buttonWidgetAnnotation checkBox';
  19185. var element = document.createElement('input');
  19186. element.disabled = this.data.readOnly;
  19187. element.type = 'checkbox';
  19188. if (this.data.fieldValue && this.data.fieldValue !== 'Off') {
  19189. element.setAttribute('checked', true);
  19190. }
  19191. this.container.appendChild(element);
  19192. return this.container;
  19193. }
  19194. });
  19195. return CheckboxWidgetAnnotationElement;
  19196. }();
  19197. var RadioButtonWidgetAnnotationElement = function RadioButtonWidgetAnnotationElementClosure() {
  19198. function RadioButtonWidgetAnnotationElement(parameters) {
  19199. WidgetAnnotationElement.call(this, parameters, parameters.renderInteractiveForms);
  19200. }
  19201. Util.inherit(RadioButtonWidgetAnnotationElement, WidgetAnnotationElement, {
  19202. render: function RadioButtonWidgetAnnotationElement_render() {
  19203. this.container.className = 'buttonWidgetAnnotation radioButton';
  19204. var element = document.createElement('input');
  19205. element.disabled = this.data.readOnly;
  19206. element.type = 'radio';
  19207. element.name = this.data.fieldName;
  19208. if (this.data.fieldValue === this.data.buttonValue) {
  19209. element.setAttribute('checked', true);
  19210. }
  19211. this.container.appendChild(element);
  19212. return this.container;
  19213. }
  19214. });
  19215. return RadioButtonWidgetAnnotationElement;
  19216. }();
  19217. var ChoiceWidgetAnnotationElement = function ChoiceWidgetAnnotationElementClosure() {
  19218. function ChoiceWidgetAnnotationElement(parameters) {
  19219. WidgetAnnotationElement.call(this, parameters, parameters.renderInteractiveForms);
  19220. }
  19221. Util.inherit(ChoiceWidgetAnnotationElement, WidgetAnnotationElement, {
  19222. render: function ChoiceWidgetAnnotationElement_render() {
  19223. this.container.className = 'choiceWidgetAnnotation';
  19224. var selectElement = document.createElement('select');
  19225. selectElement.disabled = this.data.readOnly;
  19226. if (!this.data.combo) {
  19227. selectElement.size = this.data.options.length;
  19228. if (this.data.multiSelect) {
  19229. selectElement.multiple = true;
  19230. }
  19231. }
  19232. for (var i = 0, ii = this.data.options.length; i < ii; i++) {
  19233. var option = this.data.options[i];
  19234. var optionElement = document.createElement('option');
  19235. optionElement.textContent = option.displayValue;
  19236. optionElement.value = option.exportValue;
  19237. if (this.data.fieldValue.indexOf(option.displayValue) >= 0) {
  19238. optionElement.setAttribute('selected', true);
  19239. }
  19240. selectElement.appendChild(optionElement);
  19241. }
  19242. this.container.appendChild(selectElement);
  19243. return this.container;
  19244. }
  19245. });
  19246. return ChoiceWidgetAnnotationElement;
  19247. }();
  19248. var PopupAnnotationElement = function PopupAnnotationElementClosure() {
  19249. function PopupAnnotationElement(parameters) {
  19250. var isRenderable = !!(parameters.data.title || parameters.data.contents);
  19251. AnnotationElement.call(this, parameters, isRenderable);
  19252. }
  19253. Util.inherit(PopupAnnotationElement, AnnotationElement, {
  19254. render: function PopupAnnotationElement_render() {
  19255. this.container.className = 'popupAnnotation';
  19256. var selector = '[data-annotation-id="' + this.data.parentId + '"]';
  19257. var parentElement = this.layer.querySelector(selector);
  19258. if (!parentElement) {
  19259. return this.container;
  19260. }
  19261. var popup = new PopupElement({
  19262. container: this.container,
  19263. trigger: parentElement,
  19264. color: this.data.color,
  19265. title: this.data.title,
  19266. contents: this.data.contents
  19267. });
  19268. var parentLeft = parseFloat(parentElement.style.left);
  19269. var parentWidth = parseFloat(parentElement.style.width);
  19270. CustomStyle.setProp('transformOrigin', this.container, -(parentLeft + parentWidth) + 'px -' + parentElement.style.top);
  19271. this.container.style.left = parentLeft + parentWidth + 'px';
  19272. this.container.appendChild(popup.render());
  19273. return this.container;
  19274. }
  19275. });
  19276. return PopupAnnotationElement;
  19277. }();
  19278. var PopupElement = function PopupElementClosure() {
  19279. var BACKGROUND_ENLIGHT = 0.7;
  19280. function PopupElement(parameters) {
  19281. this.container = parameters.container;
  19282. this.trigger = parameters.trigger;
  19283. this.color = parameters.color;
  19284. this.title = parameters.title;
  19285. this.contents = parameters.contents;
  19286. this.hideWrapper = parameters.hideWrapper || false;
  19287. this.pinned = false;
  19288. }
  19289. PopupElement.prototype = {
  19290. render: function PopupElement_render() {
  19291. var wrapper = document.createElement('div');
  19292. wrapper.className = 'popupWrapper';
  19293. this.hideElement = this.hideWrapper ? wrapper : this.container;
  19294. this.hideElement.setAttribute('hidden', true);
  19295. var popup = document.createElement('div');
  19296. popup.className = 'popup';
  19297. var color = this.color;
  19298. if (color) {
  19299. var r = BACKGROUND_ENLIGHT * (255 - color[0]) + color[0];
  19300. var g = BACKGROUND_ENLIGHT * (255 - color[1]) + color[1];
  19301. var b = BACKGROUND_ENLIGHT * (255 - color[2]) + color[2];
  19302. popup.style.backgroundColor = Util.makeCssRgb(r | 0, g | 0, b | 0);
  19303. }
  19304. var contents = this._formatContents(this.contents);
  19305. var title = document.createElement('h1');
  19306. title.textContent = this.title;
  19307. this.trigger.addEventListener('click', this._toggle.bind(this));
  19308. this.trigger.addEventListener('mouseover', this._show.bind(this, false));
  19309. this.trigger.addEventListener('mouseout', this._hide.bind(this, false));
  19310. popup.addEventListener('click', this._hide.bind(this, true));
  19311. popup.appendChild(title);
  19312. popup.appendChild(contents);
  19313. wrapper.appendChild(popup);
  19314. return wrapper;
  19315. },
  19316. _formatContents: function PopupElement_formatContents(contents) {
  19317. var p = document.createElement('p');
  19318. var lines = contents.split(/(?:\r\n?|\n)/);
  19319. for (var i = 0, ii = lines.length; i < ii; ++i) {
  19320. var line = lines[i];
  19321. p.appendChild(document.createTextNode(line));
  19322. if (i < ii - 1) {
  19323. p.appendChild(document.createElement('br'));
  19324. }
  19325. }
  19326. return p;
  19327. },
  19328. _toggle: function PopupElement_toggle() {
  19329. if (this.pinned) {
  19330. this._hide(true);
  19331. } else {
  19332. this._show(true);
  19333. }
  19334. },
  19335. _show: function PopupElement_show(pin) {
  19336. if (pin) {
  19337. this.pinned = true;
  19338. }
  19339. if (this.hideElement.hasAttribute('hidden')) {
  19340. this.hideElement.removeAttribute('hidden');
  19341. this.container.style.zIndex += 1;
  19342. }
  19343. },
  19344. _hide: function PopupElement_hide(unpin) {
  19345. if (unpin) {
  19346. this.pinned = false;
  19347. }
  19348. if (!this.hideElement.hasAttribute('hidden') && !this.pinned) {
  19349. this.hideElement.setAttribute('hidden', true);
  19350. this.container.style.zIndex -= 1;
  19351. }
  19352. }
  19353. };
  19354. return PopupElement;
  19355. }();
  19356. var HighlightAnnotationElement = function HighlightAnnotationElementClosure() {
  19357. function HighlightAnnotationElement(parameters) {
  19358. var isRenderable = !!(parameters.data.hasPopup || parameters.data.title || parameters.data.contents);
  19359. AnnotationElement.call(this, parameters, isRenderable);
  19360. }
  19361. Util.inherit(HighlightAnnotationElement, AnnotationElement, {
  19362. render: function HighlightAnnotationElement_render() {
  19363. this.container.className = 'highlightAnnotation';
  19364. if (!this.data.hasPopup) {
  19365. this._createPopup(this.container, null, this.data);
  19366. }
  19367. return this.container;
  19368. }
  19369. });
  19370. return HighlightAnnotationElement;
  19371. }();
  19372. var UnderlineAnnotationElement = function UnderlineAnnotationElementClosure() {
  19373. function UnderlineAnnotationElement(parameters) {
  19374. var isRenderable = !!(parameters.data.hasPopup || parameters.data.title || parameters.data.contents);
  19375. AnnotationElement.call(this, parameters, isRenderable);
  19376. }
  19377. Util.inherit(UnderlineAnnotationElement, AnnotationElement, {
  19378. render: function UnderlineAnnotationElement_render() {
  19379. this.container.className = 'underlineAnnotation';
  19380. if (!this.data.hasPopup) {
  19381. this._createPopup(this.container, null, this.data);
  19382. }
  19383. return this.container;
  19384. }
  19385. });
  19386. return UnderlineAnnotationElement;
  19387. }();
  19388. var SquigglyAnnotationElement = function SquigglyAnnotationElementClosure() {
  19389. function SquigglyAnnotationElement(parameters) {
  19390. var isRenderable = !!(parameters.data.hasPopup || parameters.data.title || parameters.data.contents);
  19391. AnnotationElement.call(this, parameters, isRenderable);
  19392. }
  19393. Util.inherit(SquigglyAnnotationElement, AnnotationElement, {
  19394. render: function SquigglyAnnotationElement_render() {
  19395. this.container.className = 'squigglyAnnotation';
  19396. if (!this.data.hasPopup) {
  19397. this._createPopup(this.container, null, this.data);
  19398. }
  19399. return this.container;
  19400. }
  19401. });
  19402. return SquigglyAnnotationElement;
  19403. }();
  19404. var StrikeOutAnnotationElement = function StrikeOutAnnotationElementClosure() {
  19405. function StrikeOutAnnotationElement(parameters) {
  19406. var isRenderable = !!(parameters.data.hasPopup || parameters.data.title || parameters.data.contents);
  19407. AnnotationElement.call(this, parameters, isRenderable);
  19408. }
  19409. Util.inherit(StrikeOutAnnotationElement, AnnotationElement, {
  19410. render: function StrikeOutAnnotationElement_render() {
  19411. this.container.className = 'strikeoutAnnotation';
  19412. if (!this.data.hasPopup) {
  19413. this._createPopup(this.container, null, this.data);
  19414. }
  19415. return this.container;
  19416. }
  19417. });
  19418. return StrikeOutAnnotationElement;
  19419. }();
  19420. var FileAttachmentAnnotationElement = function FileAttachmentAnnotationElementClosure() {
  19421. function FileAttachmentAnnotationElement(parameters) {
  19422. AnnotationElement.call(this, parameters, true);
  19423. var file = this.data.file;
  19424. this.filename = getFilenameFromUrl(file.filename);
  19425. this.content = file.content;
  19426. this.linkService.onFileAttachmentAnnotation({
  19427. id: stringToPDFString(file.filename),
  19428. filename: file.filename,
  19429. content: file.content
  19430. });
  19431. }
  19432. Util.inherit(FileAttachmentAnnotationElement, AnnotationElement, {
  19433. render: function FileAttachmentAnnotationElement_render() {
  19434. this.container.className = 'fileAttachmentAnnotation';
  19435. var trigger = document.createElement('div');
  19436. trigger.style.height = this.container.style.height;
  19437. trigger.style.width = this.container.style.width;
  19438. trigger.addEventListener('dblclick', this._download.bind(this));
  19439. if (!this.data.hasPopup && (this.data.title || this.data.contents)) {
  19440. this._createPopup(this.container, trigger, this.data);
  19441. }
  19442. this.container.appendChild(trigger);
  19443. return this.container;
  19444. },
  19445. _download: function FileAttachmentAnnotationElement_download() {
  19446. if (!this.downloadManager) {
  19447. warn('Download cannot be started due to unavailable download manager');
  19448. return;
  19449. }
  19450. this.downloadManager.downloadData(this.content, this.filename, '');
  19451. }
  19452. });
  19453. return FileAttachmentAnnotationElement;
  19454. }();
  19455. var AnnotationLayer = function AnnotationLayerClosure() {
  19456. return {
  19457. render: function AnnotationLayer_render(parameters) {
  19458. var annotationElementFactory = new AnnotationElementFactory();
  19459. for (var i = 0, ii = parameters.annotations.length; i < ii; i++) {
  19460. var data = parameters.annotations[i];
  19461. if (!data) {
  19462. continue;
  19463. }
  19464. var element = annotationElementFactory.create({
  19465. data: data,
  19466. layer: parameters.div,
  19467. page: parameters.page,
  19468. viewport: parameters.viewport,
  19469. linkService: parameters.linkService,
  19470. downloadManager: parameters.downloadManager,
  19471. imageResourcesPath: parameters.imageResourcesPath || getDefaultSetting('imageResourcesPath'),
  19472. renderInteractiveForms: parameters.renderInteractiveForms || false
  19473. });
  19474. if (element.isRenderable) {
  19475. parameters.div.appendChild(element.render());
  19476. }
  19477. }
  19478. },
  19479. update: function AnnotationLayer_update(parameters) {
  19480. for (var i = 0, ii = parameters.annotations.length; i < ii; i++) {
  19481. var data = parameters.annotations[i];
  19482. var element = parameters.div.querySelector('[data-annotation-id="' + data.id + '"]');
  19483. if (element) {
  19484. CustomStyle.setProp('transform', element, 'matrix(' + parameters.viewport.transform.join(',') + ')');
  19485. }
  19486. }
  19487. parameters.div.removeAttribute('hidden');
  19488. }
  19489. };
  19490. }();
  19491. exports.AnnotationLayer = AnnotationLayer;
  19492. /***/ }),
  19493. /* 10 */
  19494. /***/ (function(module, exports, __w_pdfjs_require__) {
  19495. "use strict";
  19496. var sharedUtil = __w_pdfjs_require__(0);
  19497. var displayFontLoader = __w_pdfjs_require__(46);
  19498. var displayCanvas = __w_pdfjs_require__(45);
  19499. var displayMetadata = __w_pdfjs_require__(23);
  19500. var displayDOMUtils = __w_pdfjs_require__(3);
  19501. var amdRequire;
  19502. var InvalidPDFException = sharedUtil.InvalidPDFException;
  19503. var MessageHandler = sharedUtil.MessageHandler;
  19504. var MissingPDFException = sharedUtil.MissingPDFException;
  19505. var PageViewport = sharedUtil.PageViewport;
  19506. var PasswordException = sharedUtil.PasswordException;
  19507. var StatTimer = sharedUtil.StatTimer;
  19508. var UnexpectedResponseException = sharedUtil.UnexpectedResponseException;
  19509. var UnknownErrorException = sharedUtil.UnknownErrorException;
  19510. var Util = sharedUtil.Util;
  19511. var createPromiseCapability = sharedUtil.createPromiseCapability;
  19512. var error = sharedUtil.error;
  19513. var deprecated = sharedUtil.deprecated;
  19514. var getVerbosityLevel = sharedUtil.getVerbosityLevel;
  19515. var info = sharedUtil.info;
  19516. var isInt = sharedUtil.isInt;
  19517. var isArray = sharedUtil.isArray;
  19518. var isArrayBuffer = sharedUtil.isArrayBuffer;
  19519. var isSameOrigin = sharedUtil.isSameOrigin;
  19520. var loadJpegStream = sharedUtil.loadJpegStream;
  19521. var stringToBytes = sharedUtil.stringToBytes;
  19522. var globalScope = sharedUtil.globalScope;
  19523. var warn = sharedUtil.warn;
  19524. var FontFaceObject = displayFontLoader.FontFaceObject;
  19525. var FontLoader = displayFontLoader.FontLoader;
  19526. var CanvasGraphics = displayCanvas.CanvasGraphics;
  19527. var Metadata = displayMetadata.Metadata;
  19528. var getDefaultSetting = displayDOMUtils.getDefaultSetting;
  19529. var DOMCanvasFactory = displayDOMUtils.DOMCanvasFactory;
  19530. var DEFAULT_RANGE_CHUNK_SIZE = 65536;
  19531. var isWorkerDisabled = false;
  19532. var workerSrc;
  19533. var isPostMessageTransfersDisabled = false;
  19534. var pdfjsFilePath = typeof document !== 'undefined' && document.currentScript ? document.currentScript.src : null;
  19535. var fakeWorkerFilesLoader = null;
  19536. var useRequireEnsure = false;
  19537. function getDocument(src, pdfDataRangeTransport, passwordCallback, progressCallback) {
  19538. var task = new PDFDocumentLoadingTask();
  19539. if (arguments.length > 1) {
  19540. deprecated('getDocument is called with pdfDataRangeTransport, ' + 'passwordCallback or progressCallback argument');
  19541. }
  19542. if (pdfDataRangeTransport) {
  19543. if (!(pdfDataRangeTransport instanceof PDFDataRangeTransport)) {
  19544. pdfDataRangeTransport = Object.create(pdfDataRangeTransport);
  19545. pdfDataRangeTransport.length = src.length;
  19546. pdfDataRangeTransport.initialData = src.initialData;
  19547. if (!pdfDataRangeTransport.abort) {
  19548. pdfDataRangeTransport.abort = function () {
  19549. };
  19550. }
  19551. }
  19552. src = Object.create(src);
  19553. src.range = pdfDataRangeTransport;
  19554. }
  19555. task.onPassword = passwordCallback || null;
  19556. task.onProgress = progressCallback || null;
  19557. var source;
  19558. if (typeof src === 'string') {
  19559. source = { url: src };
  19560. } else if (isArrayBuffer(src)) {
  19561. source = { data: src };
  19562. } else if (src instanceof PDFDataRangeTransport) {
  19563. source = { range: src };
  19564. } else {
  19565. if (typeof src !== 'object') {
  19566. error('Invalid parameter in getDocument, need either Uint8Array, ' + 'string or a parameter object');
  19567. }
  19568. if (!src.url && !src.data && !src.range) {
  19569. error('Invalid parameter object: need either .data, .range or .url');
  19570. }
  19571. source = src;
  19572. }
  19573. var params = {};
  19574. var rangeTransport = null;
  19575. var worker = null;
  19576. for (var key in source) {
  19577. if (key === 'url' && typeof window !== 'undefined') {
  19578. params[key] = new URL(source[key], window.location).href;
  19579. continue;
  19580. } else if (key === 'range') {
  19581. rangeTransport = source[key];
  19582. continue;
  19583. } else if (key === 'worker') {
  19584. worker = source[key];
  19585. continue;
  19586. } else if (key === 'data' && !(source[key] instanceof Uint8Array)) {
  19587. var pdfBytes = source[key];
  19588. if (typeof pdfBytes === 'string') {
  19589. params[key] = stringToBytes(pdfBytes);
  19590. } else if (typeof pdfBytes === 'object' && pdfBytes !== null && !isNaN(pdfBytes.length)) {
  19591. params[key] = new Uint8Array(pdfBytes);
  19592. } else if (isArrayBuffer(pdfBytes)) {
  19593. params[key] = new Uint8Array(pdfBytes);
  19594. } else {
  19595. error('Invalid PDF binary data: either typed array, string or ' + 'array-like object is expected in the data property.');
  19596. }
  19597. continue;
  19598. }
  19599. params[key] = source[key];
  19600. }
  19601. params.rangeChunkSize = params.rangeChunkSize || DEFAULT_RANGE_CHUNK_SIZE;
  19602. params.disableNativeImageDecoder = params.disableNativeImageDecoder === true;
  19603. if (!worker) {
  19604. worker = new PDFWorker();
  19605. task._worker = worker;
  19606. }
  19607. var docId = task.docId;
  19608. worker.promise.then(function () {
  19609. if (task.destroyed) {
  19610. throw new Error('Loading aborted');
  19611. }
  19612. return _fetchDocument(worker, params, rangeTransport, docId).then(function (workerId) {
  19613. if (task.destroyed) {
  19614. throw new Error('Loading aborted');
  19615. }
  19616. var messageHandler = new MessageHandler(docId, workerId, worker.port);
  19617. var transport = new WorkerTransport(messageHandler, task, rangeTransport);
  19618. task._transport = transport;
  19619. messageHandler.send('Ready', null);
  19620. });
  19621. }).catch(task._capability.reject);
  19622. return task;
  19623. }
  19624. function _fetchDocument(worker, source, pdfDataRangeTransport, docId) {
  19625. if (worker.destroyed) {
  19626. return Promise.reject(new Error('Worker was destroyed'));
  19627. }
  19628. source.disableAutoFetch = getDefaultSetting('disableAutoFetch');
  19629. source.disableStream = getDefaultSetting('disableStream');
  19630. source.chunkedViewerLoading = !!pdfDataRangeTransport;
  19631. if (pdfDataRangeTransport) {
  19632. source.length = pdfDataRangeTransport.length;
  19633. source.initialData = pdfDataRangeTransport.initialData;
  19634. }
  19635. return worker.messageHandler.sendWithPromise('GetDocRequest', {
  19636. docId: docId,
  19637. source: source,
  19638. disableRange: getDefaultSetting('disableRange'),
  19639. maxImageSize: getDefaultSetting('maxImageSize'),
  19640. cMapUrl: getDefaultSetting('cMapUrl'),
  19641. cMapPacked: getDefaultSetting('cMapPacked'),
  19642. disableFontFace: getDefaultSetting('disableFontFace'),
  19643. disableCreateObjectURL: getDefaultSetting('disableCreateObjectURL'),
  19644. postMessageTransfers: getDefaultSetting('postMessageTransfers') && !isPostMessageTransfersDisabled,
  19645. docBaseUrl: source.docBaseUrl,
  19646. disableNativeImageDecoder: source.disableNativeImageDecoder
  19647. }).then(function (workerId) {
  19648. if (worker.destroyed) {
  19649. throw new Error('Worker was destroyed');
  19650. }
  19651. return workerId;
  19652. });
  19653. }
  19654. var PDFDocumentLoadingTask = function PDFDocumentLoadingTaskClosure() {
  19655. var nextDocumentId = 0;
  19656. function PDFDocumentLoadingTask() {
  19657. this._capability = createPromiseCapability();
  19658. this._transport = null;
  19659. this._worker = null;
  19660. this.docId = 'd' + nextDocumentId++;
  19661. this.destroyed = false;
  19662. this.onPassword = null;
  19663. this.onProgress = null;
  19664. this.onUnsupportedFeature = null;
  19665. }
  19666. PDFDocumentLoadingTask.prototype = {
  19667. get promise() {
  19668. return this._capability.promise;
  19669. },
  19670. destroy: function () {
  19671. this.destroyed = true;
  19672. var transportDestroyed = !this._transport ? Promise.resolve() : this._transport.destroy();
  19673. return transportDestroyed.then(function () {
  19674. this._transport = null;
  19675. if (this._worker) {
  19676. this._worker.destroy();
  19677. this._worker = null;
  19678. }
  19679. }.bind(this));
  19680. },
  19681. then: function PDFDocumentLoadingTask_then(onFulfilled, onRejected) {
  19682. return this.promise.then.apply(this.promise, arguments);
  19683. }
  19684. };
  19685. return PDFDocumentLoadingTask;
  19686. }();
  19687. var PDFDataRangeTransport = function pdfDataRangeTransportClosure() {
  19688. function PDFDataRangeTransport(length, initialData) {
  19689. this.length = length;
  19690. this.initialData = initialData;
  19691. this._rangeListeners = [];
  19692. this._progressListeners = [];
  19693. this._progressiveReadListeners = [];
  19694. this._readyCapability = createPromiseCapability();
  19695. }
  19696. PDFDataRangeTransport.prototype = {
  19697. addRangeListener: function PDFDataRangeTransport_addRangeListener(listener) {
  19698. this._rangeListeners.push(listener);
  19699. },
  19700. addProgressListener: function PDFDataRangeTransport_addProgressListener(listener) {
  19701. this._progressListeners.push(listener);
  19702. },
  19703. addProgressiveReadListener: function PDFDataRangeTransport_addProgressiveReadListener(listener) {
  19704. this._progressiveReadListeners.push(listener);
  19705. },
  19706. onDataRange: function PDFDataRangeTransport_onDataRange(begin, chunk) {
  19707. var listeners = this._rangeListeners;
  19708. for (var i = 0, n = listeners.length; i < n; ++i) {
  19709. listeners[i](begin, chunk);
  19710. }
  19711. },
  19712. onDataProgress: function PDFDataRangeTransport_onDataProgress(loaded) {
  19713. this._readyCapability.promise.then(function () {
  19714. var listeners = this._progressListeners;
  19715. for (var i = 0, n = listeners.length; i < n; ++i) {
  19716. listeners[i](loaded);
  19717. }
  19718. }.bind(this));
  19719. },
  19720. onDataProgressiveRead: function PDFDataRangeTransport_onDataProgress(chunk) {
  19721. this._readyCapability.promise.then(function () {
  19722. var listeners = this._progressiveReadListeners;
  19723. for (var i = 0, n = listeners.length; i < n; ++i) {
  19724. listeners[i](chunk);
  19725. }
  19726. }.bind(this));
  19727. },
  19728. transportReady: function PDFDataRangeTransport_transportReady() {
  19729. this._readyCapability.resolve();
  19730. },
  19731. requestDataRange: function PDFDataRangeTransport_requestDataRange(begin, end) {
  19732. throw new Error('Abstract method PDFDataRangeTransport.requestDataRange');
  19733. },
  19734. abort: function PDFDataRangeTransport_abort() {
  19735. }
  19736. };
  19737. return PDFDataRangeTransport;
  19738. }();
  19739. var PDFDocumentProxy = function PDFDocumentProxyClosure() {
  19740. function PDFDocumentProxy(pdfInfo, transport, loadingTask) {
  19741. this.pdfInfo = pdfInfo;
  19742. this.transport = transport;
  19743. this.loadingTask = loadingTask;
  19744. }
  19745. PDFDocumentProxy.prototype = {
  19746. get numPages() {
  19747. return this.pdfInfo.numPages;
  19748. },
  19749. get fingerprint() {
  19750. return this.pdfInfo.fingerprint;
  19751. },
  19752. getPage: function PDFDocumentProxy_getPage(pageNumber) {
  19753. return this.transport.getPage(pageNumber);
  19754. },
  19755. getPageIndex: function PDFDocumentProxy_getPageIndex(ref) {
  19756. return this.transport.getPageIndex(ref);
  19757. },
  19758. getDestinations: function PDFDocumentProxy_getDestinations() {
  19759. return this.transport.getDestinations();
  19760. },
  19761. getDestination: function PDFDocumentProxy_getDestination(id) {
  19762. return this.transport.getDestination(id);
  19763. },
  19764. getPageLabels: function PDFDocumentProxy_getPageLabels() {
  19765. return this.transport.getPageLabels();
  19766. },
  19767. getAttachments: function PDFDocumentProxy_getAttachments() {
  19768. return this.transport.getAttachments();
  19769. },
  19770. getJavaScript: function PDFDocumentProxy_getJavaScript() {
  19771. return this.transport.getJavaScript();
  19772. },
  19773. getOutline: function PDFDocumentProxy_getOutline() {
  19774. return this.transport.getOutline();
  19775. },
  19776. getMetadata: function PDFDocumentProxy_getMetadata() {
  19777. return this.transport.getMetadata();
  19778. },
  19779. getData: function PDFDocumentProxy_getData() {
  19780. return this.transport.getData();
  19781. },
  19782. getDownloadInfo: function PDFDocumentProxy_getDownloadInfo() {
  19783. return this.transport.downloadInfoCapability.promise;
  19784. },
  19785. getStats: function PDFDocumentProxy_getStats() {
  19786. return this.transport.getStats();
  19787. },
  19788. cleanup: function PDFDocumentProxy_cleanup() {
  19789. this.transport.startCleanup();
  19790. },
  19791. destroy: function PDFDocumentProxy_destroy() {
  19792. return this.loadingTask.destroy();
  19793. }
  19794. };
  19795. return PDFDocumentProxy;
  19796. }();
  19797. var PDFPageProxy = function PDFPageProxyClosure() {
  19798. function PDFPageProxy(pageIndex, pageInfo, transport) {
  19799. this.pageIndex = pageIndex;
  19800. this.pageInfo = pageInfo;
  19801. this.transport = transport;
  19802. this.stats = new StatTimer();
  19803. this.stats.enabled = getDefaultSetting('enableStats');
  19804. this.commonObjs = transport.commonObjs;
  19805. this.objs = new PDFObjects();
  19806. this.cleanupAfterRender = false;
  19807. this.pendingCleanup = false;
  19808. this.intentStates = Object.create(null);
  19809. this.destroyed = false;
  19810. }
  19811. PDFPageProxy.prototype = {
  19812. get pageNumber() {
  19813. return this.pageIndex + 1;
  19814. },
  19815. get rotate() {
  19816. return this.pageInfo.rotate;
  19817. },
  19818. get ref() {
  19819. return this.pageInfo.ref;
  19820. },
  19821. get userUnit() {
  19822. return this.pageInfo.userUnit;
  19823. },
  19824. get view() {
  19825. return this.pageInfo.view;
  19826. },
  19827. getViewport: function PDFPageProxy_getViewport(scale, rotate) {
  19828. if (arguments.length < 2) {
  19829. rotate = this.rotate;
  19830. }
  19831. return new PageViewport(this.view, scale, rotate, 0, 0);
  19832. },
  19833. getAnnotations: function PDFPageProxy_getAnnotations(params) {
  19834. var intent = params && params.intent || null;
  19835. if (!this.annotationsPromise || this.annotationsIntent !== intent) {
  19836. this.annotationsPromise = this.transport.getAnnotations(this.pageIndex, intent);
  19837. this.annotationsIntent = intent;
  19838. }
  19839. return this.annotationsPromise;
  19840. },
  19841. render: function PDFPageProxy_render(params) {
  19842. var stats = this.stats;
  19843. stats.time('Overall');
  19844. this.pendingCleanup = false;
  19845. var renderingIntent = params.intent === 'print' ? 'print' : 'display';
  19846. var renderInteractiveForms = params.renderInteractiveForms === true ? true : false;
  19847. var canvasFactory = params.canvasFactory || new DOMCanvasFactory();
  19848. if (!this.intentStates[renderingIntent]) {
  19849. this.intentStates[renderingIntent] = Object.create(null);
  19850. }
  19851. var intentState = this.intentStates[renderingIntent];
  19852. if (!intentState.displayReadyCapability) {
  19853. intentState.receivingOperatorList = true;
  19854. intentState.displayReadyCapability = createPromiseCapability();
  19855. intentState.operatorList = {
  19856. fnArray: [],
  19857. argsArray: [],
  19858. lastChunk: false
  19859. };
  19860. this.stats.time('Page Request');
  19861. this.transport.messageHandler.send('RenderPageRequest', {
  19862. pageIndex: this.pageNumber - 1,
  19863. intent: renderingIntent,
  19864. renderInteractiveForms: renderInteractiveForms
  19865. });
  19866. }
  19867. var internalRenderTask = new InternalRenderTask(complete, params, this.objs, this.commonObjs, intentState.operatorList, this.pageNumber, canvasFactory);
  19868. internalRenderTask.useRequestAnimationFrame = renderingIntent !== 'print';
  19869. if (!intentState.renderTasks) {
  19870. intentState.renderTasks = [];
  19871. }
  19872. intentState.renderTasks.push(internalRenderTask);
  19873. var renderTask = internalRenderTask.task;
  19874. if (params.continueCallback) {
  19875. deprecated('render is used with continueCallback parameter');
  19876. renderTask.onContinue = params.continueCallback;
  19877. }
  19878. var self = this;
  19879. intentState.displayReadyCapability.promise.then(function pageDisplayReadyPromise(transparency) {
  19880. if (self.pendingCleanup) {
  19881. complete();
  19882. return;
  19883. }
  19884. stats.time('Rendering');
  19885. internalRenderTask.initializeGraphics(transparency);
  19886. internalRenderTask.operatorListChanged();
  19887. }, function pageDisplayReadPromiseError(reason) {
  19888. complete(reason);
  19889. });
  19890. function complete(error) {
  19891. var i = intentState.renderTasks.indexOf(internalRenderTask);
  19892. if (i >= 0) {
  19893. intentState.renderTasks.splice(i, 1);
  19894. }
  19895. if (self.cleanupAfterRender) {
  19896. self.pendingCleanup = true;
  19897. }
  19898. self._tryCleanup();
  19899. if (error) {
  19900. internalRenderTask.capability.reject(error);
  19901. } else {
  19902. internalRenderTask.capability.resolve();
  19903. }
  19904. stats.timeEnd('Rendering');
  19905. stats.timeEnd('Overall');
  19906. }
  19907. return renderTask;
  19908. },
  19909. getOperatorList: function PDFPageProxy_getOperatorList() {
  19910. function operatorListChanged() {
  19911. if (intentState.operatorList.lastChunk) {
  19912. intentState.opListReadCapability.resolve(intentState.operatorList);
  19913. var i = intentState.renderTasks.indexOf(opListTask);
  19914. if (i >= 0) {
  19915. intentState.renderTasks.splice(i, 1);
  19916. }
  19917. }
  19918. }
  19919. var renderingIntent = 'oplist';
  19920. if (!this.intentStates[renderingIntent]) {
  19921. this.intentStates[renderingIntent] = Object.create(null);
  19922. }
  19923. var intentState = this.intentStates[renderingIntent];
  19924. var opListTask;
  19925. if (!intentState.opListReadCapability) {
  19926. opListTask = {};
  19927. opListTask.operatorListChanged = operatorListChanged;
  19928. intentState.receivingOperatorList = true;
  19929. intentState.opListReadCapability = createPromiseCapability();
  19930. intentState.renderTasks = [];
  19931. intentState.renderTasks.push(opListTask);
  19932. intentState.operatorList = {
  19933. fnArray: [],
  19934. argsArray: [],
  19935. lastChunk: false
  19936. };
  19937. this.transport.messageHandler.send('RenderPageRequest', {
  19938. pageIndex: this.pageIndex,
  19939. intent: renderingIntent
  19940. });
  19941. }
  19942. return intentState.opListReadCapability.promise;
  19943. },
  19944. getTextContent: function PDFPageProxy_getTextContent(params) {
  19945. return this.transport.messageHandler.sendWithPromise('GetTextContent', {
  19946. pageIndex: this.pageNumber - 1,
  19947. normalizeWhitespace: params && params.normalizeWhitespace === true ? true : false,
  19948. combineTextItems: params && params.disableCombineTextItems === true ? false : true
  19949. });
  19950. },
  19951. _destroy: function PDFPageProxy_destroy() {
  19952. this.destroyed = true;
  19953. this.transport.pageCache[this.pageIndex] = null;
  19954. var waitOn = [];
  19955. Object.keys(this.intentStates).forEach(function (intent) {
  19956. if (intent === 'oplist') {
  19957. return;
  19958. }
  19959. var intentState = this.intentStates[intent];
  19960. intentState.renderTasks.forEach(function (renderTask) {
  19961. var renderCompleted = renderTask.capability.promise.catch(function () {
  19962. });
  19963. waitOn.push(renderCompleted);
  19964. renderTask.cancel();
  19965. });
  19966. }, this);
  19967. this.objs.clear();
  19968. this.annotationsPromise = null;
  19969. this.pendingCleanup = false;
  19970. return Promise.all(waitOn);
  19971. },
  19972. destroy: function () {
  19973. deprecated('page destroy method, use cleanup() instead');
  19974. this.cleanup();
  19975. },
  19976. cleanup: function PDFPageProxy_cleanup() {
  19977. this.pendingCleanup = true;
  19978. this._tryCleanup();
  19979. },
  19980. _tryCleanup: function PDFPageProxy_tryCleanup() {
  19981. if (!this.pendingCleanup || Object.keys(this.intentStates).some(function (intent) {
  19982. var intentState = this.intentStates[intent];
  19983. return intentState.renderTasks.length !== 0 || intentState.receivingOperatorList;
  19984. }, this)) {
  19985. return;
  19986. }
  19987. Object.keys(this.intentStates).forEach(function (intent) {
  19988. delete this.intentStates[intent];
  19989. }, this);
  19990. this.objs.clear();
  19991. this.annotationsPromise = null;
  19992. this.pendingCleanup = false;
  19993. },
  19994. _startRenderPage: function PDFPageProxy_startRenderPage(transparency, intent) {
  19995. var intentState = this.intentStates[intent];
  19996. if (intentState.displayReadyCapability) {
  19997. intentState.displayReadyCapability.resolve(transparency);
  19998. }
  19999. },
  20000. _renderPageChunk: function PDFPageProxy_renderPageChunk(operatorListChunk, intent) {
  20001. var intentState = this.intentStates[intent];
  20002. var i, ii;
  20003. for (i = 0, ii = operatorListChunk.length; i < ii; i++) {
  20004. intentState.operatorList.fnArray.push(operatorListChunk.fnArray[i]);
  20005. intentState.operatorList.argsArray.push(operatorListChunk.argsArray[i]);
  20006. }
  20007. intentState.operatorList.lastChunk = operatorListChunk.lastChunk;
  20008. for (i = 0; i < intentState.renderTasks.length; i++) {
  20009. intentState.renderTasks[i].operatorListChanged();
  20010. }
  20011. if (operatorListChunk.lastChunk) {
  20012. intentState.receivingOperatorList = false;
  20013. this._tryCleanup();
  20014. }
  20015. }
  20016. };
  20017. return PDFPageProxy;
  20018. }();
  20019. var PDFWorker = function PDFWorkerClosure() {
  20020. var nextFakeWorkerId = 0;
  20021. function getWorkerSrc() {
  20022. if (typeof workerSrc !== 'undefined') {
  20023. return workerSrc;
  20024. }
  20025. if (getDefaultSetting('workerSrc')) {
  20026. return getDefaultSetting('workerSrc');
  20027. }
  20028. if (pdfjsFilePath) {
  20029. return pdfjsFilePath.replace(/\.js$/i, '.worker.js');
  20030. }
  20031. error('No PDFJS.workerSrc specified');
  20032. }
  20033. var fakeWorkerFilesLoadedCapability;
  20034. function setupFakeWorkerGlobal() {
  20035. var WorkerMessageHandler;
  20036. if (fakeWorkerFilesLoadedCapability) {
  20037. return fakeWorkerFilesLoadedCapability.promise;
  20038. }
  20039. fakeWorkerFilesLoadedCapability = createPromiseCapability();
  20040. var pdfjsCoreWorker = __w_pdfjs_require__(22);
  20041. __w_pdfjs_require__(40);
  20042. WorkerMessageHandler = pdfjsCoreWorker.WorkerMessageHandler;
  20043. fakeWorkerFilesLoadedCapability.resolve(WorkerMessageHandler);
  20044. return fakeWorkerFilesLoadedCapability.promise;
  20045. }
  20046. function FakeWorkerPort(defer) {
  20047. this._listeners = [];
  20048. this._defer = defer;
  20049. this._deferred = Promise.resolve(undefined);
  20050. }
  20051. FakeWorkerPort.prototype = {
  20052. postMessage: function (obj, transfers) {
  20053. function cloneValue(value) {
  20054. if (typeof value !== 'object' || value === null) {
  20055. return value;
  20056. }
  20057. if (cloned.has(value)) {
  20058. return cloned.get(value);
  20059. }
  20060. var result;
  20061. var buffer;
  20062. if ((buffer = value.buffer) && isArrayBuffer(buffer)) {
  20063. var transferable = transfers && transfers.indexOf(buffer) >= 0;
  20064. if (value === buffer) {
  20065. result = value;
  20066. } else if (transferable) {
  20067. result = new value.constructor(buffer, value.byteOffset, value.byteLength);
  20068. } else {
  20069. result = new value.constructor(value);
  20070. }
  20071. cloned.set(value, result);
  20072. return result;
  20073. }
  20074. result = isArray(value) ? [] : {};
  20075. cloned.set(value, result);
  20076. for (var i in value) {
  20077. var desc, p = value;
  20078. while (!(desc = Object.getOwnPropertyDescriptor(p, i))) {
  20079. p = Object.getPrototypeOf(p);
  20080. }
  20081. if (typeof desc.value === 'undefined' || typeof desc.value === 'function') {
  20082. continue;
  20083. }
  20084. result[i] = cloneValue(desc.value);
  20085. }
  20086. return result;
  20087. }
  20088. if (!this._defer) {
  20089. this._listeners.forEach(function (listener) {
  20090. listener.call(this, { data: obj });
  20091. }, this);
  20092. return;
  20093. }
  20094. var cloned = new WeakMap();
  20095. var e = { data: cloneValue(obj) };
  20096. this._deferred.then(function () {
  20097. this._listeners.forEach(function (listener) {
  20098. listener.call(this, e);
  20099. }, this);
  20100. }.bind(this));
  20101. },
  20102. addEventListener: function (name, listener) {
  20103. this._listeners.push(listener);
  20104. },
  20105. removeEventListener: function (name, listener) {
  20106. var i = this._listeners.indexOf(listener);
  20107. this._listeners.splice(i, 1);
  20108. },
  20109. terminate: function () {
  20110. this._listeners = [];
  20111. }
  20112. };
  20113. function createCDNWrapper(url) {
  20114. var wrapper = 'importScripts(\'' + url + '\');';
  20115. return URL.createObjectURL(new Blob([wrapper]));
  20116. }
  20117. function PDFWorker(name) {
  20118. this.name = name;
  20119. this.destroyed = false;
  20120. this._readyCapability = createPromiseCapability();
  20121. this._port = null;
  20122. this._webWorker = null;
  20123. this._messageHandler = null;
  20124. this._initialize();
  20125. }
  20126. PDFWorker.prototype = {
  20127. get promise() {
  20128. return this._readyCapability.promise;
  20129. },
  20130. get port() {
  20131. return this._port;
  20132. },
  20133. get messageHandler() {
  20134. return this._messageHandler;
  20135. },
  20136. _initialize: function PDFWorker_initialize() {
  20137. this._setupFakeWorker();
  20138. },
  20139. _setupFakeWorker: function PDFWorker_setupFakeWorker() {
  20140. if (!isWorkerDisabled && !getDefaultSetting('disableWorker')) {
  20141. warn('Setting up fake worker.');
  20142. isWorkerDisabled = true;
  20143. }
  20144. setupFakeWorkerGlobal().then(function (WorkerMessageHandler) {
  20145. if (this.destroyed) {
  20146. this._readyCapability.reject(new Error('Worker was destroyed'));
  20147. return;
  20148. }
  20149. var isTypedArraysPresent = Uint8Array !== Float32Array;
  20150. var port = new FakeWorkerPort(isTypedArraysPresent);
  20151. this._port = port;
  20152. var id = 'fake' + nextFakeWorkerId++;
  20153. var workerHandler = new MessageHandler(id + '_worker', id, port);
  20154. WorkerMessageHandler.setup(workerHandler, port);
  20155. var messageHandler = new MessageHandler(id, id + '_worker', port);
  20156. this._messageHandler = messageHandler;
  20157. this._readyCapability.resolve();
  20158. }.bind(this));
  20159. },
  20160. destroy: function PDFWorker_destroy() {
  20161. this.destroyed = true;
  20162. if (this._webWorker) {
  20163. this._webWorker.terminate();
  20164. this._webWorker = null;
  20165. }
  20166. this._port = null;
  20167. if (this._messageHandler) {
  20168. this._messageHandler.destroy();
  20169. this._messageHandler = null;
  20170. }
  20171. }
  20172. };
  20173. return PDFWorker;
  20174. }();
  20175. var WorkerTransport = function WorkerTransportClosure() {
  20176. function WorkerTransport(messageHandler, loadingTask, pdfDataRangeTransport) {
  20177. this.messageHandler = messageHandler;
  20178. this.loadingTask = loadingTask;
  20179. this.pdfDataRangeTransport = pdfDataRangeTransport;
  20180. this.commonObjs = new PDFObjects();
  20181. this.fontLoader = new FontLoader(loadingTask.docId);
  20182. this.destroyed = false;
  20183. this.destroyCapability = null;
  20184. this._passwordCapability = null;
  20185. this.pageCache = [];
  20186. this.pagePromises = [];
  20187. this.downloadInfoCapability = createPromiseCapability();
  20188. this.setupMessageHandler();
  20189. }
  20190. WorkerTransport.prototype = {
  20191. destroy: function WorkerTransport_destroy() {
  20192. if (this.destroyCapability) {
  20193. return this.destroyCapability.promise;
  20194. }
  20195. this.destroyed = true;
  20196. this.destroyCapability = createPromiseCapability();
  20197. if (this._passwordCapability) {
  20198. this._passwordCapability.reject(new Error('Worker was destroyed during onPassword callback'));
  20199. }
  20200. var waitOn = [];
  20201. this.pageCache.forEach(function (page) {
  20202. if (page) {
  20203. waitOn.push(page._destroy());
  20204. }
  20205. });
  20206. this.pageCache = [];
  20207. this.pagePromises = [];
  20208. var self = this;
  20209. var terminated = this.messageHandler.sendWithPromise('Terminate', null);
  20210. waitOn.push(terminated);
  20211. Promise.all(waitOn).then(function () {
  20212. self.fontLoader.clear();
  20213. if (self.pdfDataRangeTransport) {
  20214. self.pdfDataRangeTransport.abort();
  20215. self.pdfDataRangeTransport = null;
  20216. }
  20217. if (self.messageHandler) {
  20218. self.messageHandler.destroy();
  20219. self.messageHandler = null;
  20220. }
  20221. self.destroyCapability.resolve();
  20222. }, this.destroyCapability.reject);
  20223. return this.destroyCapability.promise;
  20224. },
  20225. setupMessageHandler: function WorkerTransport_setupMessageHandler() {
  20226. var messageHandler = this.messageHandler;
  20227. var loadingTask = this.loadingTask;
  20228. var pdfDataRangeTransport = this.pdfDataRangeTransport;
  20229. if (pdfDataRangeTransport) {
  20230. pdfDataRangeTransport.addRangeListener(function (begin, chunk) {
  20231. messageHandler.send('OnDataRange', {
  20232. begin: begin,
  20233. chunk: chunk
  20234. });
  20235. });
  20236. pdfDataRangeTransport.addProgressListener(function (loaded) {
  20237. messageHandler.send('OnDataProgress', { loaded: loaded });
  20238. });
  20239. pdfDataRangeTransport.addProgressiveReadListener(function (chunk) {
  20240. messageHandler.send('OnDataRange', { chunk: chunk });
  20241. });
  20242. messageHandler.on('RequestDataRange', function transportDataRange(data) {
  20243. pdfDataRangeTransport.requestDataRange(data.begin, data.end);
  20244. }, this);
  20245. }
  20246. messageHandler.on('GetDoc', function transportDoc(data) {
  20247. var pdfInfo = data.pdfInfo;
  20248. this.numPages = data.pdfInfo.numPages;
  20249. var loadingTask = this.loadingTask;
  20250. var pdfDocument = new PDFDocumentProxy(pdfInfo, this, loadingTask);
  20251. this.pdfDocument = pdfDocument;
  20252. loadingTask._capability.resolve(pdfDocument);
  20253. }, this);
  20254. messageHandler.on('PasswordRequest', function transportPasswordRequest(exception) {
  20255. this._passwordCapability = createPromiseCapability();
  20256. if (loadingTask.onPassword) {
  20257. var updatePassword = function (password) {
  20258. this._passwordCapability.resolve({ password: password });
  20259. }.bind(this);
  20260. loadingTask.onPassword(updatePassword, exception.code);
  20261. } else {
  20262. this._passwordCapability.reject(new PasswordException(exception.message, exception.code));
  20263. }
  20264. return this._passwordCapability.promise;
  20265. }, this);
  20266. messageHandler.on('PasswordException', function transportPasswordException(exception) {
  20267. loadingTask._capability.reject(new PasswordException(exception.message, exception.code));
  20268. }, this);
  20269. messageHandler.on('InvalidPDF', function transportInvalidPDF(exception) {
  20270. this.loadingTask._capability.reject(new InvalidPDFException(exception.message));
  20271. }, this);
  20272. messageHandler.on('MissingPDF', function transportMissingPDF(exception) {
  20273. this.loadingTask._capability.reject(new MissingPDFException(exception.message));
  20274. }, this);
  20275. messageHandler.on('UnexpectedResponse', function transportUnexpectedResponse(exception) {
  20276. this.loadingTask._capability.reject(new UnexpectedResponseException(exception.message, exception.status));
  20277. }, this);
  20278. messageHandler.on('UnknownError', function transportUnknownError(exception) {
  20279. this.loadingTask._capability.reject(new UnknownErrorException(exception.message, exception.details));
  20280. }, this);
  20281. messageHandler.on('DataLoaded', function transportPage(data) {
  20282. this.downloadInfoCapability.resolve(data);
  20283. }, this);
  20284. messageHandler.on('PDFManagerReady', function transportPage(data) {
  20285. if (this.pdfDataRangeTransport) {
  20286. this.pdfDataRangeTransport.transportReady();
  20287. }
  20288. }, this);
  20289. messageHandler.on('StartRenderPage', function transportRender(data) {
  20290. if (this.destroyed) {
  20291. return;
  20292. }
  20293. var page = this.pageCache[data.pageIndex];
  20294. page.stats.timeEnd('Page Request');
  20295. page._startRenderPage(data.transparency, data.intent);
  20296. }, this);
  20297. messageHandler.on('RenderPageChunk', function transportRender(data) {
  20298. if (this.destroyed) {
  20299. return;
  20300. }
  20301. var page = this.pageCache[data.pageIndex];
  20302. page._renderPageChunk(data.operatorList, data.intent);
  20303. }, this);
  20304. messageHandler.on('commonobj', function transportObj(data) {
  20305. if (this.destroyed) {
  20306. return;
  20307. }
  20308. var id = data[0];
  20309. var type = data[1];
  20310. if (this.commonObjs.hasData(id)) {
  20311. return;
  20312. }
  20313. switch (type) {
  20314. case 'Font':
  20315. var exportedData = data[2];
  20316. if ('error' in exportedData) {
  20317. var exportedError = exportedData.error;
  20318. warn('Error during font loading: ' + exportedError);
  20319. this.commonObjs.resolve(id, exportedError);
  20320. break;
  20321. }
  20322. var fontRegistry = null;
  20323. if (getDefaultSetting('pdfBug') && globalScope.FontInspector && globalScope['FontInspector'].enabled) {
  20324. fontRegistry = {
  20325. registerFont: function (font, url) {
  20326. globalScope['FontInspector'].fontAdded(font, url);
  20327. }
  20328. };
  20329. }
  20330. var font = new FontFaceObject(exportedData, {
  20331. isEvalSuported: getDefaultSetting('isEvalSupported'),
  20332. disableFontFace: getDefaultSetting('disableFontFace'),
  20333. fontRegistry: fontRegistry
  20334. });
  20335. this.fontLoader.bind([font], function fontReady(fontObjs) {
  20336. this.commonObjs.resolve(id, font);
  20337. }.bind(this));
  20338. break;
  20339. case 'FontPath':
  20340. this.commonObjs.resolve(id, data[2]);
  20341. break;
  20342. default:
  20343. error('Got unknown common object type ' + type);
  20344. }
  20345. }, this);
  20346. messageHandler.on('obj', function transportObj(data) {
  20347. if (this.destroyed) {
  20348. return;
  20349. }
  20350. var id = data[0];
  20351. var pageIndex = data[1];
  20352. var type = data[2];
  20353. var pageProxy = this.pageCache[pageIndex];
  20354. var imageData;
  20355. if (pageProxy.objs.hasData(id)) {
  20356. return;
  20357. }
  20358. switch (type) {
  20359. case 'JpegStream':
  20360. imageData = data[3];
  20361. loadJpegStream(id, imageData, pageProxy.objs);
  20362. break;
  20363. case 'Image':
  20364. imageData = data[3];
  20365. pageProxy.objs.resolve(id, imageData);
  20366. var MAX_IMAGE_SIZE_TO_STORE = 8000000;
  20367. if (imageData && 'data' in imageData && imageData.data.length > MAX_IMAGE_SIZE_TO_STORE) {
  20368. pageProxy.cleanupAfterRender = true;
  20369. }
  20370. break;
  20371. default:
  20372. error('Got unknown object type ' + type);
  20373. }
  20374. }, this);
  20375. messageHandler.on('DocProgress', function transportDocProgress(data) {
  20376. if (this.destroyed) {
  20377. return;
  20378. }
  20379. var loadingTask = this.loadingTask;
  20380. if (loadingTask.onProgress) {
  20381. loadingTask.onProgress({
  20382. loaded: data.loaded,
  20383. total: data.total
  20384. });
  20385. }
  20386. }, this);
  20387. messageHandler.on('PageError', function transportError(data) {
  20388. if (this.destroyed) {
  20389. return;
  20390. }
  20391. var page = this.pageCache[data.pageNum - 1];
  20392. var intentState = page.intentStates[data.intent];
  20393. if (intentState.displayReadyCapability) {
  20394. intentState.displayReadyCapability.reject(data.error);
  20395. } else {
  20396. error(data.error);
  20397. }
  20398. if (intentState.operatorList) {
  20399. intentState.operatorList.lastChunk = true;
  20400. for (var i = 0; i < intentState.renderTasks.length; i++) {
  20401. intentState.renderTasks[i].operatorListChanged();
  20402. }
  20403. }
  20404. }, this);
  20405. messageHandler.on('UnsupportedFeature', function transportUnsupportedFeature(data) {
  20406. if (this.destroyed) {
  20407. return;
  20408. }
  20409. var featureId = data.featureId;
  20410. var loadingTask = this.loadingTask;
  20411. if (loadingTask.onUnsupportedFeature) {
  20412. loadingTask.onUnsupportedFeature(featureId);
  20413. }
  20414. _UnsupportedManager.notify(featureId);
  20415. }, this);
  20416. messageHandler.on('JpegDecode', function (data) {
  20417. if (this.destroyed) {
  20418. return Promise.reject(new Error('Worker was destroyed'));
  20419. }
  20420. if (typeof document === 'undefined') {
  20421. return Promise.reject(new Error('"document" is not defined.'));
  20422. }
  20423. var imageUrl = data[0];
  20424. var components = data[1];
  20425. if (components !== 3 && components !== 1) {
  20426. return Promise.reject(new Error('Only 3 components or 1 component can be returned'));
  20427. }
  20428. return new Promise(function (resolve, reject) {
  20429. var img = new Image();
  20430. img.onload = function () {
  20431. var width = img.width;
  20432. var height = img.height;
  20433. var size = width * height;
  20434. var rgbaLength = size * 4;
  20435. var buf = new Uint8Array(size * components);
  20436. var tmpCanvas = document.createElement('canvas');
  20437. tmpCanvas.width = width;
  20438. tmpCanvas.height = height;
  20439. var tmpCtx = tmpCanvas.getContext('2d');
  20440. tmpCtx.drawImage(img, 0, 0);
  20441. var data = tmpCtx.getImageData(0, 0, width, height).data;
  20442. var i, j;
  20443. if (components === 3) {
  20444. for (i = 0, j = 0; i < rgbaLength; i += 4, j += 3) {
  20445. buf[j] = data[i];
  20446. buf[j + 1] = data[i + 1];
  20447. buf[j + 2] = data[i + 2];
  20448. }
  20449. } else if (components === 1) {
  20450. for (i = 0, j = 0; i < rgbaLength; i += 4, j++) {
  20451. buf[j] = data[i];
  20452. }
  20453. }
  20454. resolve({
  20455. data: buf,
  20456. width: width,
  20457. height: height
  20458. });
  20459. };
  20460. img.onerror = function () {
  20461. reject(new Error('JpegDecode failed to load image'));
  20462. };
  20463. img.src = imageUrl;
  20464. });
  20465. }, this);
  20466. },
  20467. getData: function WorkerTransport_getData() {
  20468. return this.messageHandler.sendWithPromise('GetData', null);
  20469. },
  20470. getPage: function WorkerTransport_getPage(pageNumber, capability) {
  20471. if (!isInt(pageNumber) || pageNumber <= 0 || pageNumber > this.numPages) {
  20472. return Promise.reject(new Error('Invalid page request'));
  20473. }
  20474. var pageIndex = pageNumber - 1;
  20475. if (pageIndex in this.pagePromises) {
  20476. return this.pagePromises[pageIndex];
  20477. }
  20478. var promise = this.messageHandler.sendWithPromise('GetPage', { pageIndex: pageIndex }).then(function (pageInfo) {
  20479. if (this.destroyed) {
  20480. throw new Error('Transport destroyed');
  20481. }
  20482. var page = new PDFPageProxy(pageIndex, pageInfo, this);
  20483. this.pageCache[pageIndex] = page;
  20484. return page;
  20485. }.bind(this));
  20486. this.pagePromises[pageIndex] = promise;
  20487. return promise;
  20488. },
  20489. getPageIndex: function WorkerTransport_getPageIndexByRef(ref) {
  20490. return this.messageHandler.sendWithPromise('GetPageIndex', { ref: ref }).catch(function (reason) {
  20491. return Promise.reject(new Error(reason));
  20492. });
  20493. },
  20494. getAnnotations: function WorkerTransport_getAnnotations(pageIndex, intent) {
  20495. return this.messageHandler.sendWithPromise('GetAnnotations', {
  20496. pageIndex: pageIndex,
  20497. intent: intent
  20498. });
  20499. },
  20500. getDestinations: function WorkerTransport_getDestinations() {
  20501. return this.messageHandler.sendWithPromise('GetDestinations', null);
  20502. },
  20503. getDestination: function WorkerTransport_getDestination(id) {
  20504. return this.messageHandler.sendWithPromise('GetDestination', { id: id });
  20505. },
  20506. getPageLabels: function WorkerTransport_getPageLabels() {
  20507. return this.messageHandler.sendWithPromise('GetPageLabels', null);
  20508. },
  20509. getAttachments: function WorkerTransport_getAttachments() {
  20510. return this.messageHandler.sendWithPromise('GetAttachments', null);
  20511. },
  20512. getJavaScript: function WorkerTransport_getJavaScript() {
  20513. return this.messageHandler.sendWithPromise('GetJavaScript', null);
  20514. },
  20515. getOutline: function WorkerTransport_getOutline() {
  20516. return this.messageHandler.sendWithPromise('GetOutline', null);
  20517. },
  20518. getMetadata: function WorkerTransport_getMetadata() {
  20519. return this.messageHandler.sendWithPromise('GetMetadata', null).then(function transportMetadata(results) {
  20520. return {
  20521. info: results[0],
  20522. metadata: results[1] ? new Metadata(results[1]) : null
  20523. };
  20524. });
  20525. },
  20526. getStats: function WorkerTransport_getStats() {
  20527. return this.messageHandler.sendWithPromise('GetStats', null);
  20528. },
  20529. startCleanup: function WorkerTransport_startCleanup() {
  20530. this.messageHandler.sendWithPromise('Cleanup', null).then(function endCleanup() {
  20531. for (var i = 0, ii = this.pageCache.length; i < ii; i++) {
  20532. var page = this.pageCache[i];
  20533. if (page) {
  20534. page.cleanup();
  20535. }
  20536. }
  20537. this.commonObjs.clear();
  20538. this.fontLoader.clear();
  20539. }.bind(this));
  20540. }
  20541. };
  20542. return WorkerTransport;
  20543. }();
  20544. var PDFObjects = function PDFObjectsClosure() {
  20545. function PDFObjects() {
  20546. this.objs = Object.create(null);
  20547. }
  20548. PDFObjects.prototype = {
  20549. ensureObj: function PDFObjects_ensureObj(objId) {
  20550. if (this.objs[objId]) {
  20551. return this.objs[objId];
  20552. }
  20553. var obj = {
  20554. capability: createPromiseCapability(),
  20555. data: null,
  20556. resolved: false
  20557. };
  20558. this.objs[objId] = obj;
  20559. return obj;
  20560. },
  20561. get: function PDFObjects_get(objId, callback) {
  20562. if (callback) {
  20563. this.ensureObj(objId).capability.promise.then(callback);
  20564. return null;
  20565. }
  20566. var obj = this.objs[objId];
  20567. if (!obj || !obj.resolved) {
  20568. error('Requesting object that isn\'t resolved yet ' + objId);
  20569. }
  20570. return obj.data;
  20571. },
  20572. resolve: function PDFObjects_resolve(objId, data) {
  20573. var obj = this.ensureObj(objId);
  20574. obj.resolved = true;
  20575. obj.data = data;
  20576. obj.capability.resolve(data);
  20577. },
  20578. isResolved: function PDFObjects_isResolved(objId) {
  20579. var objs = this.objs;
  20580. if (!objs[objId]) {
  20581. return false;
  20582. }
  20583. return objs[objId].resolved;
  20584. },
  20585. hasData: function PDFObjects_hasData(objId) {
  20586. return this.isResolved(objId);
  20587. },
  20588. getData: function PDFObjects_getData(objId) {
  20589. var objs = this.objs;
  20590. if (!objs[objId] || !objs[objId].resolved) {
  20591. return null;
  20592. }
  20593. return objs[objId].data;
  20594. },
  20595. clear: function PDFObjects_clear() {
  20596. this.objs = Object.create(null);
  20597. }
  20598. };
  20599. return PDFObjects;
  20600. }();
  20601. var RenderTask = function RenderTaskClosure() {
  20602. function RenderTask(internalRenderTask) {
  20603. this._internalRenderTask = internalRenderTask;
  20604. this.onContinue = null;
  20605. }
  20606. RenderTask.prototype = {
  20607. get promise() {
  20608. return this._internalRenderTask.capability.promise;
  20609. },
  20610. cancel: function RenderTask_cancel() {
  20611. this._internalRenderTask.cancel();
  20612. },
  20613. then: function RenderTask_then(onFulfilled, onRejected) {
  20614. return this.promise.then.apply(this.promise, arguments);
  20615. }
  20616. };
  20617. return RenderTask;
  20618. }();
  20619. var InternalRenderTask = function InternalRenderTaskClosure() {
  20620. function InternalRenderTask(callback, params, objs, commonObjs, operatorList, pageNumber, canvasFactory) {
  20621. this.callback = callback;
  20622. this.params = params;
  20623. this.objs = objs;
  20624. this.commonObjs = commonObjs;
  20625. this.operatorListIdx = null;
  20626. this.operatorList = operatorList;
  20627. this.pageNumber = pageNumber;
  20628. this.canvasFactory = canvasFactory;
  20629. this.running = false;
  20630. this.graphicsReadyCallback = null;
  20631. this.graphicsReady = false;
  20632. this.useRequestAnimationFrame = false;
  20633. this.cancelled = false;
  20634. this.capability = createPromiseCapability();
  20635. this.task = new RenderTask(this);
  20636. this._continueBound = this._continue.bind(this);
  20637. this._scheduleNextBound = this._scheduleNext.bind(this);
  20638. this._nextBound = this._next.bind(this);
  20639. }
  20640. InternalRenderTask.prototype = {
  20641. initializeGraphics: function InternalRenderTask_initializeGraphics(transparency) {
  20642. if (this.cancelled) {
  20643. return;
  20644. }
  20645. if (getDefaultSetting('pdfBug') && globalScope.StepperManager && globalScope.StepperManager.enabled) {
  20646. this.stepper = globalScope.StepperManager.create(this.pageNumber - 1);
  20647. this.stepper.init(this.operatorList);
  20648. this.stepper.nextBreakPoint = this.stepper.getNextBreakPoint();
  20649. }
  20650. var params = this.params;
  20651. this.gfx = new CanvasGraphics(params.canvasContext, this.commonObjs, this.objs, this.canvasFactory, params.imageLayer);
  20652. this.gfx.beginDrawing(params.transform, params.viewport, transparency);
  20653. this.operatorListIdx = 0;
  20654. this.graphicsReady = true;
  20655. if (this.graphicsReadyCallback) {
  20656. this.graphicsReadyCallback();
  20657. }
  20658. },
  20659. cancel: function InternalRenderTask_cancel() {
  20660. this.running = false;
  20661. this.cancelled = true;
  20662. this.callback('cancelled');
  20663. },
  20664. operatorListChanged: function InternalRenderTask_operatorListChanged() {
  20665. if (!this.graphicsReady) {
  20666. if (!this.graphicsReadyCallback) {
  20667. this.graphicsReadyCallback = this._continueBound;
  20668. }
  20669. return;
  20670. }
  20671. if (this.stepper) {
  20672. this.stepper.updateOperatorList(this.operatorList);
  20673. }
  20674. if (this.running) {
  20675. return;
  20676. }
  20677. this._continue();
  20678. },
  20679. _continue: function InternalRenderTask__continue() {
  20680. this.running = true;
  20681. if (this.cancelled) {
  20682. return;
  20683. }
  20684. if (this.task.onContinue) {
  20685. this.task.onContinue(this._scheduleNextBound);
  20686. } else {
  20687. this._scheduleNext();
  20688. }
  20689. },
  20690. _scheduleNext: function InternalRenderTask__scheduleNext() {
  20691. if (this.useRequestAnimationFrame && typeof window !== 'undefined') {
  20692. window.requestAnimationFrame(this._nextBound);
  20693. } else {
  20694. Promise.resolve(undefined).then(this._nextBound);
  20695. }
  20696. },
  20697. _next: function InternalRenderTask__next() {
  20698. if (this.cancelled) {
  20699. return;
  20700. }
  20701. this.operatorListIdx = this.gfx.executeOperatorList(this.operatorList, this.operatorListIdx, this._continueBound, this.stepper);
  20702. if (this.operatorListIdx === this.operatorList.argsArray.length) {
  20703. this.running = false;
  20704. if (this.operatorList.lastChunk) {
  20705. this.gfx.endDrawing();
  20706. this.callback();
  20707. }
  20708. }
  20709. }
  20710. };
  20711. return InternalRenderTask;
  20712. }();
  20713. var _UnsupportedManager = function UnsupportedManagerClosure() {
  20714. var listeners = [];
  20715. return {
  20716. listen: function (cb) {
  20717. deprecated('Global UnsupportedManager.listen is used: ' + ' use PDFDocumentLoadingTask.onUnsupportedFeature instead');
  20718. listeners.push(cb);
  20719. },
  20720. notify: function (featureId) {
  20721. for (var i = 0, ii = listeners.length; i < ii; i++) {
  20722. listeners[i](featureId);
  20723. }
  20724. }
  20725. };
  20726. }();
  20727. exports.version = '1.7.280';
  20728. exports.build = '1549a46e';
  20729. exports.getDocument = getDocument;
  20730. exports.PDFDataRangeTransport = PDFDataRangeTransport;
  20731. exports.PDFWorker = PDFWorker;
  20732. exports.PDFDocumentProxy = PDFDocumentProxy;
  20733. exports.PDFPageProxy = PDFPageProxy;
  20734. exports._UnsupportedManager = _UnsupportedManager;
  20735. /***/ }),
  20736. /* 11 */
  20737. /***/ (function(module, exports, __w_pdfjs_require__) {
  20738. "use strict";
  20739. var sharedUtil = __w_pdfjs_require__(0);
  20740. var FONT_IDENTITY_MATRIX = sharedUtil.FONT_IDENTITY_MATRIX;
  20741. var IDENTITY_MATRIX = sharedUtil.IDENTITY_MATRIX;
  20742. var ImageKind = sharedUtil.ImageKind;
  20743. var OPS = sharedUtil.OPS;
  20744. var Util = sharedUtil.Util;
  20745. var isNum = sharedUtil.isNum;
  20746. var isArray = sharedUtil.isArray;
  20747. var warn = sharedUtil.warn;
  20748. var createObjectURL = sharedUtil.createObjectURL;
  20749. var SVG_DEFAULTS = {
  20750. fontStyle: 'normal',
  20751. fontWeight: 'normal',
  20752. fillColor: '#000000'
  20753. };
  20754. var convertImgDataToPng = function convertImgDataToPngClosure() {
  20755. var PNG_HEADER = new Uint8Array([
  20756. 0x89,
  20757. 0x50,
  20758. 0x4e,
  20759. 0x47,
  20760. 0x0d,
  20761. 0x0a,
  20762. 0x1a,
  20763. 0x0a
  20764. ]);
  20765. var CHUNK_WRAPPER_SIZE = 12;
  20766. var crcTable = new Int32Array(256);
  20767. for (var i = 0; i < 256; i++) {
  20768. var c = i;
  20769. for (var h = 0; h < 8; h++) {
  20770. if (c & 1) {
  20771. c = 0xedB88320 ^ c >> 1 & 0x7fffffff;
  20772. } else {
  20773. c = c >> 1 & 0x7fffffff;
  20774. }
  20775. }
  20776. crcTable[i] = c;
  20777. }
  20778. function crc32(data, start, end) {
  20779. var crc = -1;
  20780. for (var i = start; i < end; i++) {
  20781. var a = (crc ^ data[i]) & 0xff;
  20782. var b = crcTable[a];
  20783. crc = crc >>> 8 ^ b;
  20784. }
  20785. return crc ^ -1;
  20786. }
  20787. function writePngChunk(type, body, data, offset) {
  20788. var p = offset;
  20789. var len = body.length;
  20790. data[p] = len >> 24 & 0xff;
  20791. data[p + 1] = len >> 16 & 0xff;
  20792. data[p + 2] = len >> 8 & 0xff;
  20793. data[p + 3] = len & 0xff;
  20794. p += 4;
  20795. data[p] = type.charCodeAt(0) & 0xff;
  20796. data[p + 1] = type.charCodeAt(1) & 0xff;
  20797. data[p + 2] = type.charCodeAt(2) & 0xff;
  20798. data[p + 3] = type.charCodeAt(3) & 0xff;
  20799. p += 4;
  20800. data.set(body, p);
  20801. p += body.length;
  20802. var crc = crc32(data, offset + 4, p);
  20803. data[p] = crc >> 24 & 0xff;
  20804. data[p + 1] = crc >> 16 & 0xff;
  20805. data[p + 2] = crc >> 8 & 0xff;
  20806. data[p + 3] = crc & 0xff;
  20807. }
  20808. function adler32(data, start, end) {
  20809. var a = 1;
  20810. var b = 0;
  20811. for (var i = start; i < end; ++i) {
  20812. a = (a + (data[i] & 0xff)) % 65521;
  20813. b = (b + a) % 65521;
  20814. }
  20815. return b << 16 | a;
  20816. }
  20817. function encode(imgData, kind, forceDataSchema) {
  20818. var width = imgData.width;
  20819. var height = imgData.height;
  20820. var bitDepth, colorType, lineSize;
  20821. var bytes = imgData.data;
  20822. switch (kind) {
  20823. case ImageKind.GRAYSCALE_1BPP:
  20824. colorType = 0;
  20825. bitDepth = 1;
  20826. lineSize = width + 7 >> 3;
  20827. break;
  20828. case ImageKind.RGB_24BPP:
  20829. colorType = 2;
  20830. bitDepth = 8;
  20831. lineSize = width * 3;
  20832. break;
  20833. case ImageKind.RGBA_32BPP:
  20834. colorType = 6;
  20835. bitDepth = 8;
  20836. lineSize = width * 4;
  20837. break;
  20838. default:
  20839. throw new Error('invalid format');
  20840. }
  20841. var literals = new Uint8Array((1 + lineSize) * height);
  20842. var offsetLiterals = 0, offsetBytes = 0;
  20843. var y, i;
  20844. for (y = 0; y < height; ++y) {
  20845. literals[offsetLiterals++] = 0;
  20846. literals.set(bytes.subarray(offsetBytes, offsetBytes + lineSize), offsetLiterals);
  20847. offsetBytes += lineSize;
  20848. offsetLiterals += lineSize;
  20849. }
  20850. if (kind === ImageKind.GRAYSCALE_1BPP) {
  20851. offsetLiterals = 0;
  20852. for (y = 0; y < height; y++) {
  20853. offsetLiterals++;
  20854. for (i = 0; i < lineSize; i++) {
  20855. literals[offsetLiterals++] ^= 0xFF;
  20856. }
  20857. }
  20858. }
  20859. var ihdr = new Uint8Array([
  20860. width >> 24 & 0xff,
  20861. width >> 16 & 0xff,
  20862. width >> 8 & 0xff,
  20863. width & 0xff,
  20864. height >> 24 & 0xff,
  20865. height >> 16 & 0xff,
  20866. height >> 8 & 0xff,
  20867. height & 0xff,
  20868. bitDepth,
  20869. colorType,
  20870. 0x00,
  20871. 0x00,
  20872. 0x00
  20873. ]);
  20874. var len = literals.length;
  20875. var maxBlockLength = 0xFFFF;
  20876. var deflateBlocks = Math.ceil(len / maxBlockLength);
  20877. var idat = new Uint8Array(2 + len + deflateBlocks * 5 + 4);
  20878. var pi = 0;
  20879. idat[pi++] = 0x78;
  20880. idat[pi++] = 0x9c;
  20881. var pos = 0;
  20882. while (len > maxBlockLength) {
  20883. idat[pi++] = 0x00;
  20884. idat[pi++] = 0xff;
  20885. idat[pi++] = 0xff;
  20886. idat[pi++] = 0x00;
  20887. idat[pi++] = 0x00;
  20888. idat.set(literals.subarray(pos, pos + maxBlockLength), pi);
  20889. pi += maxBlockLength;
  20890. pos += maxBlockLength;
  20891. len -= maxBlockLength;
  20892. }
  20893. idat[pi++] = 0x01;
  20894. idat[pi++] = len & 0xff;
  20895. idat[pi++] = len >> 8 & 0xff;
  20896. idat[pi++] = ~len & 0xffff & 0xff;
  20897. idat[pi++] = (~len & 0xffff) >> 8 & 0xff;
  20898. idat.set(literals.subarray(pos), pi);
  20899. pi += literals.length - pos;
  20900. var adler = adler32(literals, 0, literals.length);
  20901. idat[pi++] = adler >> 24 & 0xff;
  20902. idat[pi++] = adler >> 16 & 0xff;
  20903. idat[pi++] = adler >> 8 & 0xff;
  20904. idat[pi++] = adler & 0xff;
  20905. var pngLength = PNG_HEADER.length + CHUNK_WRAPPER_SIZE * 3 + ihdr.length + idat.length;
  20906. var data = new Uint8Array(pngLength);
  20907. var offset = 0;
  20908. data.set(PNG_HEADER, offset);
  20909. offset += PNG_HEADER.length;
  20910. writePngChunk('IHDR', ihdr, data, offset);
  20911. offset += CHUNK_WRAPPER_SIZE + ihdr.length;
  20912. writePngChunk('IDATA', idat, data, offset);
  20913. offset += CHUNK_WRAPPER_SIZE + idat.length;
  20914. writePngChunk('IEND', new Uint8Array(0), data, offset);
  20915. return createObjectURL(data, 'image/png', forceDataSchema);
  20916. }
  20917. return function convertImgDataToPng(imgData, forceDataSchema) {
  20918. var kind = imgData.kind === undefined ? ImageKind.GRAYSCALE_1BPP : imgData.kind;
  20919. return encode(imgData, kind, forceDataSchema);
  20920. };
  20921. }();
  20922. var SVGExtraState = function SVGExtraStateClosure() {
  20923. function SVGExtraState() {
  20924. this.fontSizeScale = 1;
  20925. this.fontWeight = SVG_DEFAULTS.fontWeight;
  20926. this.fontSize = 0;
  20927. this.textMatrix = IDENTITY_MATRIX;
  20928. this.fontMatrix = FONT_IDENTITY_MATRIX;
  20929. this.leading = 0;
  20930. this.x = 0;
  20931. this.y = 0;
  20932. this.lineX = 0;
  20933. this.lineY = 0;
  20934. this.charSpacing = 0;
  20935. this.wordSpacing = 0;
  20936. this.textHScale = 1;
  20937. this.textRise = 0;
  20938. this.fillColor = SVG_DEFAULTS.fillColor;
  20939. this.strokeColor = '#000000';
  20940. this.fillAlpha = 1;
  20941. this.strokeAlpha = 1;
  20942. this.lineWidth = 1;
  20943. this.lineJoin = '';
  20944. this.lineCap = '';
  20945. this.miterLimit = 0;
  20946. this.dashArray = [];
  20947. this.dashPhase = 0;
  20948. this.dependencies = [];
  20949. this.activeClipUrl = null;
  20950. this.clipGroup = null;
  20951. this.maskId = '';
  20952. }
  20953. SVGExtraState.prototype = {
  20954. clone: function SVGExtraState_clone() {
  20955. return Object.create(this);
  20956. },
  20957. setCurrentPoint: function SVGExtraState_setCurrentPoint(x, y) {
  20958. this.x = x;
  20959. this.y = y;
  20960. }
  20961. };
  20962. return SVGExtraState;
  20963. }();
  20964. var SVGGraphics = function SVGGraphicsClosure() {
  20965. function opListToTree(opList) {
  20966. var opTree = [];
  20967. var tmp = [];
  20968. var opListLen = opList.length;
  20969. for (var x = 0; x < opListLen; x++) {
  20970. if (opList[x].fn === 'save') {
  20971. opTree.push({
  20972. 'fnId': 92,
  20973. 'fn': 'group',
  20974. 'items': []
  20975. });
  20976. tmp.push(opTree);
  20977. opTree = opTree[opTree.length - 1].items;
  20978. continue;
  20979. }
  20980. if (opList[x].fn === 'restore') {
  20981. opTree = tmp.pop();
  20982. } else {
  20983. opTree.push(opList[x]);
  20984. }
  20985. }
  20986. return opTree;
  20987. }
  20988. function pf(value) {
  20989. if (value === (value | 0)) {
  20990. return value.toString();
  20991. }
  20992. var s = value.toFixed(10);
  20993. var i = s.length - 1;
  20994. if (s[i] !== '0') {
  20995. return s;
  20996. }
  20997. do {
  20998. i--;
  20999. } while (s[i] === '0');
  21000. return s.substr(0, s[i] === '.' ? i : i + 1);
  21001. }
  21002. function pm(m) {
  21003. if (m[4] === 0 && m[5] === 0) {
  21004. if (m[1] === 0 && m[2] === 0) {
  21005. if (m[0] === 1 && m[3] === 1) {
  21006. return '';
  21007. }
  21008. return 'scale(' + pf(m[0]) + ' ' + pf(m[3]) + ')';
  21009. }
  21010. if (m[0] === m[3] && m[1] === -m[2]) {
  21011. var a = Math.acos(m[0]) * 180 / Math.PI;
  21012. return 'rotate(' + pf(a) + ')';
  21013. }
  21014. } else {
  21015. if (m[0] === 1 && m[1] === 0 && m[2] === 0 && m[3] === 1) {
  21016. return 'translate(' + pf(m[4]) + ' ' + pf(m[5]) + ')';
  21017. }
  21018. }
  21019. return 'matrix(' + pf(m[0]) + ' ' + pf(m[1]) + ' ' + pf(m[2]) + ' ' + pf(m[3]) + ' ' + pf(m[4]) + ' ' + pf(m[5]) + ')';
  21020. }
  21021. function SVGGraphics(commonObjs, objs, forceDataSchema) {
  21022. this.current = new SVGExtraState();
  21023. this.transformMatrix = IDENTITY_MATRIX;
  21024. this.transformStack = [];
  21025. this.extraStack = [];
  21026. this.commonObjs = commonObjs;
  21027. this.objs = objs;
  21028. this.pendingEOFill = false;
  21029. this.embedFonts = false;
  21030. this.embeddedFonts = Object.create(null);
  21031. this.cssStyle = null;
  21032. this.forceDataSchema = !!forceDataSchema;
  21033. }
  21034. var NS = 'http://www.w3.org/2000/svg';
  21035. var XML_NS = 'http://www.w3.org/XML/1998/namespace';
  21036. var XLINK_NS = 'http://www.w3.org/1999/xlink';
  21037. var LINE_CAP_STYLES = [
  21038. 'butt',
  21039. 'round',
  21040. 'square'
  21041. ];
  21042. var LINE_JOIN_STYLES = [
  21043. 'miter',
  21044. 'round',
  21045. 'bevel'
  21046. ];
  21047. var clipCount = 0;
  21048. var maskCount = 0;
  21049. SVGGraphics.prototype = {
  21050. save: function SVGGraphics_save() {
  21051. this.transformStack.push(this.transformMatrix);
  21052. var old = this.current;
  21053. this.extraStack.push(old);
  21054. this.current = old.clone();
  21055. },
  21056. restore: function SVGGraphics_restore() {
  21057. this.transformMatrix = this.transformStack.pop();
  21058. this.current = this.extraStack.pop();
  21059. this.tgrp = null;
  21060. },
  21061. group: function SVGGraphics_group(items) {
  21062. this.save();
  21063. this.executeOpTree(items);
  21064. this.restore();
  21065. },
  21066. loadDependencies: function SVGGraphics_loadDependencies(operatorList) {
  21067. var fnArray = operatorList.fnArray;
  21068. var fnArrayLen = fnArray.length;
  21069. var argsArray = operatorList.argsArray;
  21070. var self = this;
  21071. for (var i = 0; i < fnArrayLen; i++) {
  21072. if (OPS.dependency === fnArray[i]) {
  21073. var deps = argsArray[i];
  21074. for (var n = 0, nn = deps.length; n < nn; n++) {
  21075. var obj = deps[n];
  21076. var common = obj.substring(0, 2) === 'g_';
  21077. var promise;
  21078. if (common) {
  21079. promise = new Promise(function (resolve) {
  21080. self.commonObjs.get(obj, resolve);
  21081. });
  21082. } else {
  21083. promise = new Promise(function (resolve) {
  21084. self.objs.get(obj, resolve);
  21085. });
  21086. }
  21087. this.current.dependencies.push(promise);
  21088. }
  21089. }
  21090. }
  21091. return Promise.all(this.current.dependencies);
  21092. },
  21093. transform: function SVGGraphics_transform(a, b, c, d, e, f) {
  21094. var transformMatrix = [
  21095. a,
  21096. b,
  21097. c,
  21098. d,
  21099. e,
  21100. f
  21101. ];
  21102. this.transformMatrix = Util.transform(this.transformMatrix, transformMatrix);
  21103. this.tgrp = null;
  21104. },
  21105. getSVG: function SVGGraphics_getSVG(operatorList, viewport) {
  21106. this.viewport = viewport;
  21107. var svgElement = this._initialize(viewport);
  21108. return this.loadDependencies(operatorList).then(function () {
  21109. this.transformMatrix = IDENTITY_MATRIX;
  21110. var opTree = this.convertOpList(operatorList);
  21111. this.executeOpTree(opTree);
  21112. return svgElement;
  21113. }.bind(this));
  21114. },
  21115. convertOpList: function SVGGraphics_convertOpList(operatorList) {
  21116. var argsArray = operatorList.argsArray;
  21117. var fnArray = operatorList.fnArray;
  21118. var fnArrayLen = fnArray.length;
  21119. var REVOPS = [];
  21120. var opList = [];
  21121. for (var op in OPS) {
  21122. REVOPS[OPS[op]] = op;
  21123. }
  21124. for (var x = 0; x < fnArrayLen; x++) {
  21125. var fnId = fnArray[x];
  21126. opList.push({
  21127. 'fnId': fnId,
  21128. 'fn': REVOPS[fnId],
  21129. 'args': argsArray[x]
  21130. });
  21131. }
  21132. return opListToTree(opList);
  21133. },
  21134. executeOpTree: function SVGGraphics_executeOpTree(opTree) {
  21135. var opTreeLen = opTree.length;
  21136. for (var x = 0; x < opTreeLen; x++) {
  21137. var fn = opTree[x].fn;
  21138. var fnId = opTree[x].fnId;
  21139. var args = opTree[x].args;
  21140. switch (fnId | 0) {
  21141. case OPS.beginText:
  21142. this.beginText();
  21143. break;
  21144. case OPS.setLeading:
  21145. this.setLeading(args);
  21146. break;
  21147. case OPS.setLeadingMoveText:
  21148. this.setLeadingMoveText(args[0], args[1]);
  21149. break;
  21150. case OPS.setFont:
  21151. this.setFont(args);
  21152. break;
  21153. case OPS.showText:
  21154. this.showText(args[0]);
  21155. break;
  21156. case OPS.showSpacedText:
  21157. this.showText(args[0]);
  21158. break;
  21159. case OPS.endText:
  21160. this.endText();
  21161. break;
  21162. case OPS.moveText:
  21163. this.moveText(args[0], args[1]);
  21164. break;
  21165. case OPS.setCharSpacing:
  21166. this.setCharSpacing(args[0]);
  21167. break;
  21168. case OPS.setWordSpacing:
  21169. this.setWordSpacing(args[0]);
  21170. break;
  21171. case OPS.setHScale:
  21172. this.setHScale(args[0]);
  21173. break;
  21174. case OPS.setTextMatrix:
  21175. this.setTextMatrix(args[0], args[1], args[2], args[3], args[4], args[5]);
  21176. break;
  21177. case OPS.setLineWidth:
  21178. this.setLineWidth(args[0]);
  21179. break;
  21180. case OPS.setLineJoin:
  21181. this.setLineJoin(args[0]);
  21182. break;
  21183. case OPS.setLineCap:
  21184. this.setLineCap(args[0]);
  21185. break;
  21186. case OPS.setMiterLimit:
  21187. this.setMiterLimit(args[0]);
  21188. break;
  21189. case OPS.setFillRGBColor:
  21190. this.setFillRGBColor(args[0], args[1], args[2]);
  21191. break;
  21192. case OPS.setStrokeRGBColor:
  21193. this.setStrokeRGBColor(args[0], args[1], args[2]);
  21194. break;
  21195. case OPS.setDash:
  21196. this.setDash(args[0], args[1]);
  21197. break;
  21198. case OPS.setGState:
  21199. this.setGState(args[0]);
  21200. break;
  21201. case OPS.fill:
  21202. this.fill();
  21203. break;
  21204. case OPS.eoFill:
  21205. this.eoFill();
  21206. break;
  21207. case OPS.stroke:
  21208. this.stroke();
  21209. break;
  21210. case OPS.fillStroke:
  21211. this.fillStroke();
  21212. break;
  21213. case OPS.eoFillStroke:
  21214. this.eoFillStroke();
  21215. break;
  21216. case OPS.clip:
  21217. this.clip('nonzero');
  21218. break;
  21219. case OPS.eoClip:
  21220. this.clip('evenodd');
  21221. break;
  21222. case OPS.paintSolidColorImageMask:
  21223. this.paintSolidColorImageMask();
  21224. break;
  21225. case OPS.paintJpegXObject:
  21226. this.paintJpegXObject(args[0], args[1], args[2]);
  21227. break;
  21228. case OPS.paintImageXObject:
  21229. this.paintImageXObject(args[0]);
  21230. break;
  21231. case OPS.paintInlineImageXObject:
  21232. this.paintInlineImageXObject(args[0]);
  21233. break;
  21234. case OPS.paintImageMaskXObject:
  21235. this.paintImageMaskXObject(args[0]);
  21236. break;
  21237. case OPS.paintFormXObjectBegin:
  21238. this.paintFormXObjectBegin(args[0], args[1]);
  21239. break;
  21240. case OPS.paintFormXObjectEnd:
  21241. this.paintFormXObjectEnd();
  21242. break;
  21243. case OPS.closePath:
  21244. this.closePath();
  21245. break;
  21246. case OPS.closeStroke:
  21247. this.closeStroke();
  21248. break;
  21249. case OPS.closeFillStroke:
  21250. this.closeFillStroke();
  21251. break;
  21252. case OPS.nextLine:
  21253. this.nextLine();
  21254. break;
  21255. case OPS.transform:
  21256. this.transform(args[0], args[1], args[2], args[3], args[4], args[5]);
  21257. break;
  21258. case OPS.constructPath:
  21259. this.constructPath(args[0], args[1]);
  21260. break;
  21261. case OPS.endPath:
  21262. this.endPath();
  21263. break;
  21264. case 92:
  21265. this.group(opTree[x].items);
  21266. break;
  21267. default:
  21268. warn('Unimplemented operator ' + fn);
  21269. break;
  21270. }
  21271. }
  21272. },
  21273. setWordSpacing: function SVGGraphics_setWordSpacing(wordSpacing) {
  21274. this.current.wordSpacing = wordSpacing;
  21275. },
  21276. setCharSpacing: function SVGGraphics_setCharSpacing(charSpacing) {
  21277. this.current.charSpacing = charSpacing;
  21278. },
  21279. nextLine: function SVGGraphics_nextLine() {
  21280. this.moveText(0, this.current.leading);
  21281. },
  21282. setTextMatrix: function SVGGraphics_setTextMatrix(a, b, c, d, e, f) {
  21283. var current = this.current;
  21284. this.current.textMatrix = this.current.lineMatrix = [
  21285. a,
  21286. b,
  21287. c,
  21288. d,
  21289. e,
  21290. f
  21291. ];
  21292. this.current.x = this.current.lineX = 0;
  21293. this.current.y = this.current.lineY = 0;
  21294. current.xcoords = [];
  21295. current.tspan = document.createElementNS(NS, 'svg:tspan');
  21296. current.tspan.setAttributeNS(null, 'font-family', current.fontFamily);
  21297. current.tspan.setAttributeNS(null, 'font-size', pf(current.fontSize) + 'px');
  21298. current.tspan.setAttributeNS(null, 'y', pf(-current.y));
  21299. current.txtElement = document.createElementNS(NS, 'svg:text');
  21300. current.txtElement.appendChild(current.tspan);
  21301. },
  21302. beginText: function SVGGraphics_beginText() {
  21303. this.current.x = this.current.lineX = 0;
  21304. this.current.y = this.current.lineY = 0;
  21305. this.current.textMatrix = IDENTITY_MATRIX;
  21306. this.current.lineMatrix = IDENTITY_MATRIX;
  21307. this.current.tspan = document.createElementNS(NS, 'svg:tspan');
  21308. this.current.txtElement = document.createElementNS(NS, 'svg:text');
  21309. this.current.txtgrp = document.createElementNS(NS, 'svg:g');
  21310. this.current.xcoords = [];
  21311. },
  21312. moveText: function SVGGraphics_moveText(x, y) {
  21313. var current = this.current;
  21314. this.current.x = this.current.lineX += x;
  21315. this.current.y = this.current.lineY += y;
  21316. current.xcoords = [];
  21317. current.tspan = document.createElementNS(NS, 'svg:tspan');
  21318. current.tspan.setAttributeNS(null, 'font-family', current.fontFamily);
  21319. current.tspan.setAttributeNS(null, 'font-size', pf(current.fontSize) + 'px');
  21320. current.tspan.setAttributeNS(null, 'y', pf(-current.y));
  21321. },
  21322. showText: function SVGGraphics_showText(glyphs) {
  21323. var current = this.current;
  21324. var font = current.font;
  21325. var fontSize = current.fontSize;
  21326. if (fontSize === 0) {
  21327. return;
  21328. }
  21329. var charSpacing = current.charSpacing;
  21330. var wordSpacing = current.wordSpacing;
  21331. var fontDirection = current.fontDirection;
  21332. var textHScale = current.textHScale * fontDirection;
  21333. var glyphsLength = glyphs.length;
  21334. var vertical = font.vertical;
  21335. var widthAdvanceScale = fontSize * current.fontMatrix[0];
  21336. var x = 0, i;
  21337. for (i = 0; i < glyphsLength; ++i) {
  21338. var glyph = glyphs[i];
  21339. if (glyph === null) {
  21340. x += fontDirection * wordSpacing;
  21341. continue;
  21342. } else if (isNum(glyph)) {
  21343. x += -glyph * fontSize * 0.001;
  21344. continue;
  21345. }
  21346. current.xcoords.push(current.x + x * textHScale);
  21347. var width = glyph.width;
  21348. var character = glyph.fontChar;
  21349. var charWidth = width * widthAdvanceScale + charSpacing * fontDirection;
  21350. x += charWidth;
  21351. current.tspan.textContent += character;
  21352. }
  21353. if (vertical) {
  21354. current.y -= x * textHScale;
  21355. } else {
  21356. current.x += x * textHScale;
  21357. }
  21358. current.tspan.setAttributeNS(null, 'x', current.xcoords.map(pf).join(' '));
  21359. current.tspan.setAttributeNS(null, 'y', pf(-current.y));
  21360. current.tspan.setAttributeNS(null, 'font-family', current.fontFamily);
  21361. current.tspan.setAttributeNS(null, 'font-size', pf(current.fontSize) + 'px');
  21362. if (current.fontStyle !== SVG_DEFAULTS.fontStyle) {
  21363. current.tspan.setAttributeNS(null, 'font-style', current.fontStyle);
  21364. }
  21365. if (current.fontWeight !== SVG_DEFAULTS.fontWeight) {
  21366. current.tspan.setAttributeNS(null, 'font-weight', current.fontWeight);
  21367. }
  21368. if (current.fillColor !== SVG_DEFAULTS.fillColor) {
  21369. current.tspan.setAttributeNS(null, 'fill', current.fillColor);
  21370. }
  21371. current.txtElement.setAttributeNS(null, 'transform', pm(current.textMatrix) + ' scale(1, -1)');
  21372. current.txtElement.setAttributeNS(XML_NS, 'xml:space', 'preserve');
  21373. current.txtElement.appendChild(current.tspan);
  21374. current.txtgrp.appendChild(current.txtElement);
  21375. this._ensureTransformGroup().appendChild(current.txtElement);
  21376. },
  21377. setLeadingMoveText: function SVGGraphics_setLeadingMoveText(x, y) {
  21378. this.setLeading(-y);
  21379. this.moveText(x, y);
  21380. },
  21381. addFontStyle: function SVGGraphics_addFontStyle(fontObj) {
  21382. if (!this.cssStyle) {
  21383. this.cssStyle = document.createElementNS(NS, 'svg:style');
  21384. this.cssStyle.setAttributeNS(null, 'type', 'text/css');
  21385. this.defs.appendChild(this.cssStyle);
  21386. }
  21387. var url = createObjectURL(fontObj.data, fontObj.mimetype, this.forceDataSchema);
  21388. this.cssStyle.textContent += '@font-face { font-family: "' + fontObj.loadedName + '";' + ' src: url(' + url + '); }\n';
  21389. },
  21390. setFont: function SVGGraphics_setFont(details) {
  21391. var current = this.current;
  21392. var fontObj = this.commonObjs.get(details[0]);
  21393. var size = details[1];
  21394. this.current.font = fontObj;
  21395. if (this.embedFonts && fontObj.data && !this.embeddedFonts[fontObj.loadedName]) {
  21396. this.addFontStyle(fontObj);
  21397. this.embeddedFonts[fontObj.loadedName] = fontObj;
  21398. }
  21399. current.fontMatrix = fontObj.fontMatrix ? fontObj.fontMatrix : FONT_IDENTITY_MATRIX;
  21400. var bold = fontObj.black ? fontObj.bold ? 'bolder' : 'bold' : fontObj.bold ? 'bold' : 'normal';
  21401. var italic = fontObj.italic ? 'italic' : 'normal';
  21402. if (size < 0) {
  21403. size = -size;
  21404. current.fontDirection = -1;
  21405. } else {
  21406. current.fontDirection = 1;
  21407. }
  21408. current.fontSize = size;
  21409. current.fontFamily = fontObj.loadedName;
  21410. current.fontWeight = bold;
  21411. current.fontStyle = italic;
  21412. current.tspan = document.createElementNS(NS, 'svg:tspan');
  21413. current.tspan.setAttributeNS(null, 'y', pf(-current.y));
  21414. current.xcoords = [];
  21415. },
  21416. endText: function SVGGraphics_endText() {
  21417. },
  21418. setLineWidth: function SVGGraphics_setLineWidth(width) {
  21419. this.current.lineWidth = width;
  21420. },
  21421. setLineCap: function SVGGraphics_setLineCap(style) {
  21422. this.current.lineCap = LINE_CAP_STYLES[style];
  21423. },
  21424. setLineJoin: function SVGGraphics_setLineJoin(style) {
  21425. this.current.lineJoin = LINE_JOIN_STYLES[style];
  21426. },
  21427. setMiterLimit: function SVGGraphics_setMiterLimit(limit) {
  21428. this.current.miterLimit = limit;
  21429. },
  21430. setStrokeRGBColor: function SVGGraphics_setStrokeRGBColor(r, g, b) {
  21431. var color = Util.makeCssRgb(r, g, b);
  21432. this.current.strokeColor = color;
  21433. },
  21434. setFillRGBColor: function SVGGraphics_setFillRGBColor(r, g, b) {
  21435. var color = Util.makeCssRgb(r, g, b);
  21436. this.current.fillColor = color;
  21437. this.current.tspan = document.createElementNS(NS, 'svg:tspan');
  21438. this.current.xcoords = [];
  21439. },
  21440. setDash: function SVGGraphics_setDash(dashArray, dashPhase) {
  21441. this.current.dashArray = dashArray;
  21442. this.current.dashPhase = dashPhase;
  21443. },
  21444. constructPath: function SVGGraphics_constructPath(ops, args) {
  21445. var current = this.current;
  21446. var x = current.x, y = current.y;
  21447. current.path = document.createElementNS(NS, 'svg:path');
  21448. var d = [];
  21449. var opLength = ops.length;
  21450. for (var i = 0, j = 0; i < opLength; i++) {
  21451. switch (ops[i] | 0) {
  21452. case OPS.rectangle:
  21453. x = args[j++];
  21454. y = args[j++];
  21455. var width = args[j++];
  21456. var height = args[j++];
  21457. var xw = x + width;
  21458. var yh = y + height;
  21459. d.push('M', pf(x), pf(y), 'L', pf(xw), pf(y), 'L', pf(xw), pf(yh), 'L', pf(x), pf(yh), 'Z');
  21460. break;
  21461. case OPS.moveTo:
  21462. x = args[j++];
  21463. y = args[j++];
  21464. d.push('M', pf(x), pf(y));
  21465. break;
  21466. case OPS.lineTo:
  21467. x = args[j++];
  21468. y = args[j++];
  21469. d.push('L', pf(x), pf(y));
  21470. break;
  21471. case OPS.curveTo:
  21472. x = args[j + 4];
  21473. y = args[j + 5];
  21474. d.push('C', pf(args[j]), pf(args[j + 1]), pf(args[j + 2]), pf(args[j + 3]), pf(x), pf(y));
  21475. j += 6;
  21476. break;
  21477. case OPS.curveTo2:
  21478. x = args[j + 2];
  21479. y = args[j + 3];
  21480. d.push('C', pf(x), pf(y), pf(args[j]), pf(args[j + 1]), pf(args[j + 2]), pf(args[j + 3]));
  21481. j += 4;
  21482. break;
  21483. case OPS.curveTo3:
  21484. x = args[j + 2];
  21485. y = args[j + 3];
  21486. d.push('C', pf(args[j]), pf(args[j + 1]), pf(x), pf(y), pf(x), pf(y));
  21487. j += 4;
  21488. break;
  21489. case OPS.closePath:
  21490. d.push('Z');
  21491. break;
  21492. }
  21493. }
  21494. current.path.setAttributeNS(null, 'd', d.join(' '));
  21495. current.path.setAttributeNS(null, 'stroke-miterlimit', pf(current.miterLimit));
  21496. current.path.setAttributeNS(null, 'stroke-linecap', current.lineCap);
  21497. current.path.setAttributeNS(null, 'stroke-linejoin', current.lineJoin);
  21498. current.path.setAttributeNS(null, 'stroke-width', pf(current.lineWidth) + 'px');
  21499. current.path.setAttributeNS(null, 'stroke-dasharray', current.dashArray.map(pf).join(' '));
  21500. current.path.setAttributeNS(null, 'stroke-dashoffset', pf(current.dashPhase) + 'px');
  21501. current.path.setAttributeNS(null, 'fill', 'none');
  21502. this._ensureTransformGroup().appendChild(current.path);
  21503. current.element = current.path;
  21504. current.setCurrentPoint(x, y);
  21505. },
  21506. endPath: function SVGGraphics_endPath() {
  21507. },
  21508. clip: function SVGGraphics_clip(type) {
  21509. var current = this.current;
  21510. var clipId = 'clippath' + clipCount;
  21511. clipCount++;
  21512. var clipPath = document.createElementNS(NS, 'svg:clipPath');
  21513. clipPath.setAttributeNS(null, 'id', clipId);
  21514. clipPath.setAttributeNS(null, 'transform', pm(this.transformMatrix));
  21515. var clipElement = current.element.cloneNode();
  21516. if (type === 'evenodd') {
  21517. clipElement.setAttributeNS(null, 'clip-rule', 'evenodd');
  21518. } else {
  21519. clipElement.setAttributeNS(null, 'clip-rule', 'nonzero');
  21520. }
  21521. clipPath.appendChild(clipElement);
  21522. this.defs.appendChild(clipPath);
  21523. if (current.activeClipUrl) {
  21524. current.clipGroup = null;
  21525. this.extraStack.forEach(function (prev) {
  21526. prev.clipGroup = null;
  21527. });
  21528. }
  21529. current.activeClipUrl = 'url(#' + clipId + ')';
  21530. this.tgrp = null;
  21531. },
  21532. closePath: function SVGGraphics_closePath() {
  21533. var current = this.current;
  21534. var d = current.path.getAttributeNS(null, 'd');
  21535. d += 'Z';
  21536. current.path.setAttributeNS(null, 'd', d);
  21537. },
  21538. setLeading: function SVGGraphics_setLeading(leading) {
  21539. this.current.leading = -leading;
  21540. },
  21541. setTextRise: function SVGGraphics_setTextRise(textRise) {
  21542. this.current.textRise = textRise;
  21543. },
  21544. setHScale: function SVGGraphics_setHScale(scale) {
  21545. this.current.textHScale = scale / 100;
  21546. },
  21547. setGState: function SVGGraphics_setGState(states) {
  21548. for (var i = 0, ii = states.length; i < ii; i++) {
  21549. var state = states[i];
  21550. var key = state[0];
  21551. var value = state[1];
  21552. switch (key) {
  21553. case 'LW':
  21554. this.setLineWidth(value);
  21555. break;
  21556. case 'LC':
  21557. this.setLineCap(value);
  21558. break;
  21559. case 'LJ':
  21560. this.setLineJoin(value);
  21561. break;
  21562. case 'ML':
  21563. this.setMiterLimit(value);
  21564. break;
  21565. case 'D':
  21566. this.setDash(value[0], value[1]);
  21567. break;
  21568. case 'Font':
  21569. this.setFont(value);
  21570. break;
  21571. default:
  21572. warn('Unimplemented graphic state ' + key);
  21573. break;
  21574. }
  21575. }
  21576. },
  21577. fill: function SVGGraphics_fill() {
  21578. var current = this.current;
  21579. current.element.setAttributeNS(null, 'fill', current.fillColor);
  21580. },
  21581. stroke: function SVGGraphics_stroke() {
  21582. var current = this.current;
  21583. current.element.setAttributeNS(null, 'stroke', current.strokeColor);
  21584. current.element.setAttributeNS(null, 'fill', 'none');
  21585. },
  21586. eoFill: function SVGGraphics_eoFill() {
  21587. var current = this.current;
  21588. current.element.setAttributeNS(null, 'fill', current.fillColor);
  21589. current.element.setAttributeNS(null, 'fill-rule', 'evenodd');
  21590. },
  21591. fillStroke: function SVGGraphics_fillStroke() {
  21592. this.stroke();
  21593. this.fill();
  21594. },
  21595. eoFillStroke: function SVGGraphics_eoFillStroke() {
  21596. this.current.element.setAttributeNS(null, 'fill-rule', 'evenodd');
  21597. this.fillStroke();
  21598. },
  21599. closeStroke: function SVGGraphics_closeStroke() {
  21600. this.closePath();
  21601. this.stroke();
  21602. },
  21603. closeFillStroke: function SVGGraphics_closeFillStroke() {
  21604. this.closePath();
  21605. this.fillStroke();
  21606. },
  21607. paintSolidColorImageMask: function SVGGraphics_paintSolidColorImageMask() {
  21608. var current = this.current;
  21609. var rect = document.createElementNS(NS, 'svg:rect');
  21610. rect.setAttributeNS(null, 'x', '0');
  21611. rect.setAttributeNS(null, 'y', '0');
  21612. rect.setAttributeNS(null, 'width', '1px');
  21613. rect.setAttributeNS(null, 'height', '1px');
  21614. rect.setAttributeNS(null, 'fill', current.fillColor);
  21615. this._ensureTransformGroup().appendChild(rect);
  21616. },
  21617. paintJpegXObject: function SVGGraphics_paintJpegXObject(objId, w, h) {
  21618. var imgObj = this.objs.get(objId);
  21619. var imgEl = document.createElementNS(NS, 'svg:image');
  21620. imgEl.setAttributeNS(XLINK_NS, 'xlink:href', imgObj.src);
  21621. imgEl.setAttributeNS(null, 'width', imgObj.width + 'px');
  21622. imgEl.setAttributeNS(null, 'height', imgObj.height + 'px');
  21623. imgEl.setAttributeNS(null, 'x', '0');
  21624. imgEl.setAttributeNS(null, 'y', pf(-h));
  21625. imgEl.setAttributeNS(null, 'transform', 'scale(' + pf(1 / w) + ' ' + pf(-1 / h) + ')');
  21626. this._ensureTransformGroup().appendChild(imgEl);
  21627. },
  21628. paintImageXObject: function SVGGraphics_paintImageXObject(objId) {
  21629. var imgData = this.objs.get(objId);
  21630. if (!imgData) {
  21631. warn('Dependent image isn\'t ready yet');
  21632. return;
  21633. }
  21634. this.paintInlineImageXObject(imgData);
  21635. },
  21636. paintInlineImageXObject: function SVGGraphics_paintInlineImageXObject(imgData, mask) {
  21637. var width = imgData.width;
  21638. var height = imgData.height;
  21639. var imgSrc = convertImgDataToPng(imgData, this.forceDataSchema);
  21640. var cliprect = document.createElementNS(NS, 'svg:rect');
  21641. cliprect.setAttributeNS(null, 'x', '0');
  21642. cliprect.setAttributeNS(null, 'y', '0');
  21643. cliprect.setAttributeNS(null, 'width', pf(width));
  21644. cliprect.setAttributeNS(null, 'height', pf(height));
  21645. this.current.element = cliprect;
  21646. this.clip('nonzero');
  21647. var imgEl = document.createElementNS(NS, 'svg:image');
  21648. imgEl.setAttributeNS(XLINK_NS, 'xlink:href', imgSrc);
  21649. imgEl.setAttributeNS(null, 'x', '0');
  21650. imgEl.setAttributeNS(null, 'y', pf(-height));
  21651. imgEl.setAttributeNS(null, 'width', pf(width) + 'px');
  21652. imgEl.setAttributeNS(null, 'height', pf(height) + 'px');
  21653. imgEl.setAttributeNS(null, 'transform', 'scale(' + pf(1 / width) + ' ' + pf(-1 / height) + ')');
  21654. if (mask) {
  21655. mask.appendChild(imgEl);
  21656. } else {
  21657. this._ensureTransformGroup().appendChild(imgEl);
  21658. }
  21659. },
  21660. paintImageMaskXObject: function SVGGraphics_paintImageMaskXObject(imgData) {
  21661. var current = this.current;
  21662. var width = imgData.width;
  21663. var height = imgData.height;
  21664. var fillColor = current.fillColor;
  21665. current.maskId = 'mask' + maskCount++;
  21666. var mask = document.createElementNS(NS, 'svg:mask');
  21667. mask.setAttributeNS(null, 'id', current.maskId);
  21668. var rect = document.createElementNS(NS, 'svg:rect');
  21669. rect.setAttributeNS(null, 'x', '0');
  21670. rect.setAttributeNS(null, 'y', '0');
  21671. rect.setAttributeNS(null, 'width', pf(width));
  21672. rect.setAttributeNS(null, 'height', pf(height));
  21673. rect.setAttributeNS(null, 'fill', fillColor);
  21674. rect.setAttributeNS(null, 'mask', 'url(#' + current.maskId + ')');
  21675. this.defs.appendChild(mask);
  21676. this._ensureTransformGroup().appendChild(rect);
  21677. this.paintInlineImageXObject(imgData, mask);
  21678. },
  21679. paintFormXObjectBegin: function SVGGraphics_paintFormXObjectBegin(matrix, bbox) {
  21680. if (isArray(matrix) && matrix.length === 6) {
  21681. this.transform(matrix[0], matrix[1], matrix[2], matrix[3], matrix[4], matrix[5]);
  21682. }
  21683. if (isArray(bbox) && bbox.length === 4) {
  21684. var width = bbox[2] - bbox[0];
  21685. var height = bbox[3] - bbox[1];
  21686. var cliprect = document.createElementNS(NS, 'svg:rect');
  21687. cliprect.setAttributeNS(null, 'x', bbox[0]);
  21688. cliprect.setAttributeNS(null, 'y', bbox[1]);
  21689. cliprect.setAttributeNS(null, 'width', pf(width));
  21690. cliprect.setAttributeNS(null, 'height', pf(height));
  21691. this.current.element = cliprect;
  21692. this.clip('nonzero');
  21693. this.endPath();
  21694. }
  21695. },
  21696. paintFormXObjectEnd: function SVGGraphics_paintFormXObjectEnd() {
  21697. },
  21698. _initialize: function SVGGraphics_initialize(viewport) {
  21699. var svg = document.createElementNS(NS, 'svg:svg');
  21700. svg.setAttributeNS(null, 'version', '1.1');
  21701. svg.setAttributeNS(null, 'width', viewport.width + 'px');
  21702. svg.setAttributeNS(null, 'height', viewport.height + 'px');
  21703. svg.setAttributeNS(null, 'preserveAspectRatio', 'none');
  21704. svg.setAttributeNS(null, 'viewBox', '0 0 ' + viewport.width + ' ' + viewport.height);
  21705. var definitions = document.createElementNS(NS, 'svg:defs');
  21706. svg.appendChild(definitions);
  21707. this.defs = definitions;
  21708. var rootGroup = document.createElementNS(NS, 'svg:g');
  21709. rootGroup.setAttributeNS(null, 'transform', pm(viewport.transform));
  21710. svg.appendChild(rootGroup);
  21711. this.svg = rootGroup;
  21712. return svg;
  21713. },
  21714. _ensureClipGroup: function SVGGraphics_ensureClipGroup() {
  21715. if (!this.current.clipGroup) {
  21716. var clipGroup = document.createElementNS(NS, 'svg:g');
  21717. clipGroup.setAttributeNS(null, 'clip-path', this.current.activeClipUrl);
  21718. this.svg.appendChild(clipGroup);
  21719. this.current.clipGroup = clipGroup;
  21720. }
  21721. return this.current.clipGroup;
  21722. },
  21723. _ensureTransformGroup: function SVGGraphics_ensureTransformGroup() {
  21724. if (!this.tgrp) {
  21725. this.tgrp = document.createElementNS(NS, 'svg:g');
  21726. this.tgrp.setAttributeNS(null, 'transform', pm(this.transformMatrix));
  21727. if (this.current.activeClipUrl) {
  21728. this._ensureClipGroup().appendChild(this.tgrp);
  21729. } else {
  21730. this.svg.appendChild(this.tgrp);
  21731. }
  21732. }
  21733. return this.tgrp;
  21734. }
  21735. };
  21736. return SVGGraphics;
  21737. }();
  21738. exports.SVGGraphics = SVGGraphics;
  21739. /***/ }),
  21740. /* 12 */
  21741. /***/ (function(module, exports, __w_pdfjs_require__) {
  21742. "use strict";
  21743. var sharedUtil = __w_pdfjs_require__(0);
  21744. var displayDOMUtils = __w_pdfjs_require__(3);
  21745. var Util = sharedUtil.Util;
  21746. var createPromiseCapability = sharedUtil.createPromiseCapability;
  21747. var CustomStyle = displayDOMUtils.CustomStyle;
  21748. var getDefaultSetting = displayDOMUtils.getDefaultSetting;
  21749. var renderTextLayer = function renderTextLayerClosure() {
  21750. var MAX_TEXT_DIVS_TO_RENDER = 100000;
  21751. var NonWhitespaceRegexp = /\S/;
  21752. function isAllWhitespace(str) {
  21753. return !NonWhitespaceRegexp.test(str);
  21754. }
  21755. var styleBuf = [
  21756. 'left: ',
  21757. 0,
  21758. 'px; top: ',
  21759. 0,
  21760. 'px; font-size: ',
  21761. 0,
  21762. 'px; font-family: ',
  21763. '',
  21764. ';'
  21765. ];
  21766. function appendText(task, geom, styles) {
  21767. var textDiv = document.createElement('div');
  21768. var textDivProperties = {
  21769. style: null,
  21770. angle: 0,
  21771. canvasWidth: 0,
  21772. isWhitespace: false,
  21773. originalTransform: null,
  21774. paddingBottom: 0,
  21775. paddingLeft: 0,
  21776. paddingRight: 0,
  21777. paddingTop: 0,
  21778. scale: 1
  21779. };
  21780. task._textDivs.push(textDiv);
  21781. if (isAllWhitespace(geom.str)) {
  21782. textDivProperties.isWhitespace = true;
  21783. task._textDivProperties.set(textDiv, textDivProperties);
  21784. return;
  21785. }
  21786. var tx = Util.transform(task._viewport.transform, geom.transform);
  21787. var angle = Math.atan2(tx[1], tx[0]);
  21788. var style = styles[geom.fontName];
  21789. if (style.vertical) {
  21790. angle += Math.PI / 2;
  21791. }
  21792. var fontHeight = Math.sqrt(tx[2] * tx[2] + tx[3] * tx[3]);
  21793. var fontAscent = fontHeight;
  21794. if (style.ascent) {
  21795. fontAscent = style.ascent * fontAscent;
  21796. } else if (style.descent) {
  21797. fontAscent = (1 + style.descent) * fontAscent;
  21798. }
  21799. var left;
  21800. var top;
  21801. if (angle === 0) {
  21802. left = tx[4];
  21803. top = tx[5] - fontAscent;
  21804. } else {
  21805. left = tx[4] + fontAscent * Math.sin(angle);
  21806. top = tx[5] - fontAscent * Math.cos(angle);
  21807. }
  21808. styleBuf[1] = left;
  21809. styleBuf[3] = top;
  21810. styleBuf[5] = fontHeight;
  21811. styleBuf[7] = style.fontFamily;
  21812. textDivProperties.style = styleBuf.join('');
  21813. textDiv.setAttribute('style', textDivProperties.style);
  21814. textDiv.textContent = geom.str;
  21815. if (getDefaultSetting('pdfBug')) {
  21816. textDiv.dataset.fontName = geom.fontName;
  21817. }
  21818. if (angle !== 0) {
  21819. textDivProperties.angle = angle * (180 / Math.PI);
  21820. }
  21821. if (geom.str.length > 1) {
  21822. if (style.vertical) {
  21823. textDivProperties.canvasWidth = geom.height * task._viewport.scale;
  21824. } else {
  21825. textDivProperties.canvasWidth = geom.width * task._viewport.scale;
  21826. }
  21827. }
  21828. task._textDivProperties.set(textDiv, textDivProperties);
  21829. if (task._enhanceTextSelection) {
  21830. var angleCos = 1, angleSin = 0;
  21831. if (angle !== 0) {
  21832. angleCos = Math.cos(angle);
  21833. angleSin = Math.sin(angle);
  21834. }
  21835. var divWidth = (style.vertical ? geom.height : geom.width) * task._viewport.scale;
  21836. var divHeight = fontHeight;
  21837. var m, b;
  21838. if (angle !== 0) {
  21839. m = [
  21840. angleCos,
  21841. angleSin,
  21842. -angleSin,
  21843. angleCos,
  21844. left,
  21845. top
  21846. ];
  21847. b = Util.getAxialAlignedBoundingBox([
  21848. 0,
  21849. 0,
  21850. divWidth,
  21851. divHeight
  21852. ], m);
  21853. } else {
  21854. b = [
  21855. left,
  21856. top,
  21857. left + divWidth,
  21858. top + divHeight
  21859. ];
  21860. }
  21861. task._bounds.push({
  21862. left: b[0],
  21863. top: b[1],
  21864. right: b[2],
  21865. bottom: b[3],
  21866. div: textDiv,
  21867. size: [
  21868. divWidth,
  21869. divHeight
  21870. ],
  21871. m: m
  21872. });
  21873. }
  21874. }
  21875. function render(task) {
  21876. if (task._canceled) {
  21877. return;
  21878. }
  21879. var textLayerFrag = task._container;
  21880. var textDivs = task._textDivs;
  21881. var capability = task._capability;
  21882. var textDivsLength = textDivs.length;
  21883. if (textDivsLength > MAX_TEXT_DIVS_TO_RENDER) {
  21884. task._renderingDone = true;
  21885. capability.resolve();
  21886. return;
  21887. }
  21888. var canvas = document.createElement('canvas');
  21889. var ctx = canvas.getContext('2d', { alpha: false });
  21890. var lastFontSize;
  21891. var lastFontFamily;
  21892. for (var i = 0; i < textDivsLength; i++) {
  21893. var textDiv = textDivs[i];
  21894. var textDivProperties = task._textDivProperties.get(textDiv);
  21895. if (textDivProperties.isWhitespace) {
  21896. continue;
  21897. }
  21898. var fontSize = textDiv.style.fontSize;
  21899. var fontFamily = textDiv.style.fontFamily;
  21900. if (fontSize !== lastFontSize || fontFamily !== lastFontFamily) {
  21901. ctx.font = fontSize + ' ' + fontFamily;
  21902. lastFontSize = fontSize;
  21903. lastFontFamily = fontFamily;
  21904. }
  21905. var width = ctx.measureText(textDiv.textContent).width;
  21906. textLayerFrag.appendChild(textDiv);
  21907. var transform = '';
  21908. if (textDivProperties.canvasWidth !== 0 && width > 0) {
  21909. textDivProperties.scale = textDivProperties.canvasWidth / width;
  21910. transform = 'scaleX(' + textDivProperties.scale + ')';
  21911. }
  21912. if (textDivProperties.angle !== 0) {
  21913. transform = 'rotate(' + textDivProperties.angle + 'deg) ' + transform;
  21914. }
  21915. if (transform !== '') {
  21916. textDivProperties.originalTransform = transform;
  21917. CustomStyle.setProp('transform', textDiv, transform);
  21918. }
  21919. task._textDivProperties.set(textDiv, textDivProperties);
  21920. }
  21921. task._renderingDone = true;
  21922. capability.resolve();
  21923. }
  21924. function expand(task) {
  21925. var bounds = task._bounds;
  21926. var viewport = task._viewport;
  21927. var expanded = expandBounds(viewport.width, viewport.height, bounds);
  21928. for (var i = 0; i < expanded.length; i++) {
  21929. var div = bounds[i].div;
  21930. var divProperties = task._textDivProperties.get(div);
  21931. if (divProperties.angle === 0) {
  21932. divProperties.paddingLeft = bounds[i].left - expanded[i].left;
  21933. divProperties.paddingTop = bounds[i].top - expanded[i].top;
  21934. divProperties.paddingRight = expanded[i].right - bounds[i].right;
  21935. divProperties.paddingBottom = expanded[i].bottom - bounds[i].bottom;
  21936. task._textDivProperties.set(div, divProperties);
  21937. continue;
  21938. }
  21939. var e = expanded[i], b = bounds[i];
  21940. var m = b.m, c = m[0], s = m[1];
  21941. var points = [
  21942. [
  21943. 0,
  21944. 0
  21945. ],
  21946. [
  21947. 0,
  21948. b.size[1]
  21949. ],
  21950. [
  21951. b.size[0],
  21952. 0
  21953. ],
  21954. b.size
  21955. ];
  21956. var ts = new Float64Array(64);
  21957. points.forEach(function (p, i) {
  21958. var t = Util.applyTransform(p, m);
  21959. ts[i + 0] = c && (e.left - t[0]) / c;
  21960. ts[i + 4] = s && (e.top - t[1]) / s;
  21961. ts[i + 8] = c && (e.right - t[0]) / c;
  21962. ts[i + 12] = s && (e.bottom - t[1]) / s;
  21963. ts[i + 16] = s && (e.left - t[0]) / -s;
  21964. ts[i + 20] = c && (e.top - t[1]) / c;
  21965. ts[i + 24] = s && (e.right - t[0]) / -s;
  21966. ts[i + 28] = c && (e.bottom - t[1]) / c;
  21967. ts[i + 32] = c && (e.left - t[0]) / -c;
  21968. ts[i + 36] = s && (e.top - t[1]) / -s;
  21969. ts[i + 40] = c && (e.right - t[0]) / -c;
  21970. ts[i + 44] = s && (e.bottom - t[1]) / -s;
  21971. ts[i + 48] = s && (e.left - t[0]) / s;
  21972. ts[i + 52] = c && (e.top - t[1]) / -c;
  21973. ts[i + 56] = s && (e.right - t[0]) / s;
  21974. ts[i + 60] = c && (e.bottom - t[1]) / -c;
  21975. });
  21976. var findPositiveMin = function (ts, offset, count) {
  21977. var result = 0;
  21978. for (var i = 0; i < count; i++) {
  21979. var t = ts[offset++];
  21980. if (t > 0) {
  21981. result = result ? Math.min(t, result) : t;
  21982. }
  21983. }
  21984. return result;
  21985. };
  21986. var boxScale = 1 + Math.min(Math.abs(c), Math.abs(s));
  21987. divProperties.paddingLeft = findPositiveMin(ts, 32, 16) / boxScale;
  21988. divProperties.paddingTop = findPositiveMin(ts, 48, 16) / boxScale;
  21989. divProperties.paddingRight = findPositiveMin(ts, 0, 16) / boxScale;
  21990. divProperties.paddingBottom = findPositiveMin(ts, 16, 16) / boxScale;
  21991. task._textDivProperties.set(div, divProperties);
  21992. }
  21993. }
  21994. function expandBounds(width, height, boxes) {
  21995. var bounds = boxes.map(function (box, i) {
  21996. return {
  21997. x1: box.left,
  21998. y1: box.top,
  21999. x2: box.right,
  22000. y2: box.bottom,
  22001. index: i,
  22002. x1New: undefined,
  22003. x2New: undefined
  22004. };
  22005. });
  22006. expandBoundsLTR(width, bounds);
  22007. var expanded = new Array(boxes.length);
  22008. bounds.forEach(function (b) {
  22009. var i = b.index;
  22010. expanded[i] = {
  22011. left: b.x1New,
  22012. top: 0,
  22013. right: b.x2New,
  22014. bottom: 0
  22015. };
  22016. });
  22017. boxes.map(function (box, i) {
  22018. var e = expanded[i], b = bounds[i];
  22019. b.x1 = box.top;
  22020. b.y1 = width - e.right;
  22021. b.x2 = box.bottom;
  22022. b.y2 = width - e.left;
  22023. b.index = i;
  22024. b.x1New = undefined;
  22025. b.x2New = undefined;
  22026. });
  22027. expandBoundsLTR(height, bounds);
  22028. bounds.forEach(function (b) {
  22029. var i = b.index;
  22030. expanded[i].top = b.x1New;
  22031. expanded[i].bottom = b.x2New;
  22032. });
  22033. return expanded;
  22034. }
  22035. function expandBoundsLTR(width, bounds) {
  22036. bounds.sort(function (a, b) {
  22037. return a.x1 - b.x1 || a.index - b.index;
  22038. });
  22039. var fakeBoundary = {
  22040. x1: -Infinity,
  22041. y1: -Infinity,
  22042. x2: 0,
  22043. y2: Infinity,
  22044. index: -1,
  22045. x1New: 0,
  22046. x2New: 0
  22047. };
  22048. var horizon = [{
  22049. start: -Infinity,
  22050. end: Infinity,
  22051. boundary: fakeBoundary
  22052. }];
  22053. bounds.forEach(function (boundary) {
  22054. var i = 0;
  22055. while (i < horizon.length && horizon[i].end <= boundary.y1) {
  22056. i++;
  22057. }
  22058. var j = horizon.length - 1;
  22059. while (j >= 0 && horizon[j].start >= boundary.y2) {
  22060. j--;
  22061. }
  22062. var horizonPart, affectedBoundary;
  22063. var q, k, maxXNew = -Infinity;
  22064. for (q = i; q <= j; q++) {
  22065. horizonPart = horizon[q];
  22066. affectedBoundary = horizonPart.boundary;
  22067. var xNew;
  22068. if (affectedBoundary.x2 > boundary.x1) {
  22069. xNew = affectedBoundary.index > boundary.index ? affectedBoundary.x1New : boundary.x1;
  22070. } else if (affectedBoundary.x2New === undefined) {
  22071. xNew = (affectedBoundary.x2 + boundary.x1) / 2;
  22072. } else {
  22073. xNew = affectedBoundary.x2New;
  22074. }
  22075. if (xNew > maxXNew) {
  22076. maxXNew = xNew;
  22077. }
  22078. }
  22079. boundary.x1New = maxXNew;
  22080. for (q = i; q <= j; q++) {
  22081. horizonPart = horizon[q];
  22082. affectedBoundary = horizonPart.boundary;
  22083. if (affectedBoundary.x2New === undefined) {
  22084. if (affectedBoundary.x2 > boundary.x1) {
  22085. if (affectedBoundary.index > boundary.index) {
  22086. affectedBoundary.x2New = affectedBoundary.x2;
  22087. }
  22088. } else {
  22089. affectedBoundary.x2New = maxXNew;
  22090. }
  22091. } else if (affectedBoundary.x2New > maxXNew) {
  22092. affectedBoundary.x2New = Math.max(maxXNew, affectedBoundary.x2);
  22093. }
  22094. }
  22095. var changedHorizon = [], lastBoundary = null;
  22096. for (q = i; q <= j; q++) {
  22097. horizonPart = horizon[q];
  22098. affectedBoundary = horizonPart.boundary;
  22099. var useBoundary = affectedBoundary.x2 > boundary.x2 ? affectedBoundary : boundary;
  22100. if (lastBoundary === useBoundary) {
  22101. changedHorizon[changedHorizon.length - 1].end = horizonPart.end;
  22102. } else {
  22103. changedHorizon.push({
  22104. start: horizonPart.start,
  22105. end: horizonPart.end,
  22106. boundary: useBoundary
  22107. });
  22108. lastBoundary = useBoundary;
  22109. }
  22110. }
  22111. if (horizon[i].start < boundary.y1) {
  22112. changedHorizon[0].start = boundary.y1;
  22113. changedHorizon.unshift({
  22114. start: horizon[i].start,
  22115. end: boundary.y1,
  22116. boundary: horizon[i].boundary
  22117. });
  22118. }
  22119. if (boundary.y2 < horizon[j].end) {
  22120. changedHorizon[changedHorizon.length - 1].end = boundary.y2;
  22121. changedHorizon.push({
  22122. start: boundary.y2,
  22123. end: horizon[j].end,
  22124. boundary: horizon[j].boundary
  22125. });
  22126. }
  22127. for (q = i; q <= j; q++) {
  22128. horizonPart = horizon[q];
  22129. affectedBoundary = horizonPart.boundary;
  22130. if (affectedBoundary.x2New !== undefined) {
  22131. continue;
  22132. }
  22133. var used = false;
  22134. for (k = i - 1; !used && k >= 0 && horizon[k].start >= affectedBoundary.y1; k--) {
  22135. used = horizon[k].boundary === affectedBoundary;
  22136. }
  22137. for (k = j + 1; !used && k < horizon.length && horizon[k].end <= affectedBoundary.y2; k++) {
  22138. used = horizon[k].boundary === affectedBoundary;
  22139. }
  22140. for (k = 0; !used && k < changedHorizon.length; k++) {
  22141. used = changedHorizon[k].boundary === affectedBoundary;
  22142. }
  22143. if (!used) {
  22144. affectedBoundary.x2New = maxXNew;
  22145. }
  22146. }
  22147. Array.prototype.splice.apply(horizon, [
  22148. i,
  22149. j - i + 1
  22150. ].concat(changedHorizon));
  22151. });
  22152. horizon.forEach(function (horizonPart) {
  22153. var affectedBoundary = horizonPart.boundary;
  22154. if (affectedBoundary.x2New === undefined) {
  22155. affectedBoundary.x2New = Math.max(width, affectedBoundary.x2);
  22156. }
  22157. });
  22158. }
  22159. function TextLayerRenderTask(textContent, container, viewport, textDivs, enhanceTextSelection) {
  22160. this._textContent = textContent;
  22161. this._container = container;
  22162. this._viewport = viewport;
  22163. this._textDivs = textDivs || [];
  22164. this._textDivProperties = new WeakMap();
  22165. this._renderingDone = false;
  22166. this._canceled = false;
  22167. this._capability = createPromiseCapability();
  22168. this._renderTimer = null;
  22169. this._bounds = [];
  22170. this._enhanceTextSelection = !!enhanceTextSelection;
  22171. }
  22172. TextLayerRenderTask.prototype = {
  22173. get promise() {
  22174. return this._capability.promise;
  22175. },
  22176. cancel: function TextLayer_cancel() {
  22177. this._canceled = true;
  22178. if (this._renderTimer !== null) {
  22179. clearTimeout(this._renderTimer);
  22180. this._renderTimer = null;
  22181. }
  22182. this._capability.reject('canceled');
  22183. },
  22184. _render: function TextLayer_render(timeout) {
  22185. var textItems = this._textContent.items;
  22186. var textStyles = this._textContent.styles;
  22187. for (var i = 0, len = textItems.length; i < len; i++) {
  22188. appendText(this, textItems[i], textStyles);
  22189. }
  22190. if (!timeout) {
  22191. render(this);
  22192. } else {
  22193. var self = this;
  22194. this._renderTimer = setTimeout(function () {
  22195. render(self);
  22196. self._renderTimer = null;
  22197. }, timeout);
  22198. }
  22199. },
  22200. expandTextDivs: function TextLayer_expandTextDivs(expandDivs) {
  22201. if (!this._enhanceTextSelection || !this._renderingDone) {
  22202. return;
  22203. }
  22204. if (this._bounds !== null) {
  22205. expand(this);
  22206. this._bounds = null;
  22207. }
  22208. for (var i = 0, ii = this._textDivs.length; i < ii; i++) {
  22209. var div = this._textDivs[i];
  22210. var divProperties = this._textDivProperties.get(div);
  22211. if (divProperties.isWhitespace) {
  22212. continue;
  22213. }
  22214. if (expandDivs) {
  22215. var transform = '', padding = '';
  22216. if (divProperties.scale !== 1) {
  22217. transform = 'scaleX(' + divProperties.scale + ')';
  22218. }
  22219. if (divProperties.angle !== 0) {
  22220. transform = 'rotate(' + divProperties.angle + 'deg) ' + transform;
  22221. }
  22222. if (divProperties.paddingLeft !== 0) {
  22223. padding += ' padding-left: ' + divProperties.paddingLeft / divProperties.scale + 'px;';
  22224. transform += ' translateX(' + -divProperties.paddingLeft / divProperties.scale + 'px)';
  22225. }
  22226. if (divProperties.paddingTop !== 0) {
  22227. padding += ' padding-top: ' + divProperties.paddingTop + 'px;';
  22228. transform += ' translateY(' + -divProperties.paddingTop + 'px)';
  22229. }
  22230. if (divProperties.paddingRight !== 0) {
  22231. padding += ' padding-right: ' + divProperties.paddingRight / divProperties.scale + 'px;';
  22232. }
  22233. if (divProperties.paddingBottom !== 0) {
  22234. padding += ' padding-bottom: ' + divProperties.paddingBottom + 'px;';
  22235. }
  22236. if (padding !== '') {
  22237. div.setAttribute('style', divProperties.style + padding);
  22238. }
  22239. if (transform !== '') {
  22240. CustomStyle.setProp('transform', div, transform);
  22241. }
  22242. } else {
  22243. div.style.padding = 0;
  22244. CustomStyle.setProp('transform', div, divProperties.originalTransform || '');
  22245. }
  22246. }
  22247. }
  22248. };
  22249. function renderTextLayer(renderParameters) {
  22250. var task = new TextLayerRenderTask(renderParameters.textContent, renderParameters.container, renderParameters.viewport, renderParameters.textDivs, renderParameters.enhanceTextSelection);
  22251. task._render(renderParameters.timeout);
  22252. return task;
  22253. }
  22254. return renderTextLayer;
  22255. }();
  22256. exports.renderTextLayer = renderTextLayer;
  22257. /***/ }),
  22258. /* 13 */
  22259. /***/ (function(module, exports, __w_pdfjs_require__) {
  22260. "use strict";
  22261. var ArithmeticDecoder = function ArithmeticDecoderClosure() {
  22262. var QeTable = [
  22263. {
  22264. qe: 0x5601,
  22265. nmps: 1,
  22266. nlps: 1,
  22267. switchFlag: 1
  22268. },
  22269. {
  22270. qe: 0x3401,
  22271. nmps: 2,
  22272. nlps: 6,
  22273. switchFlag: 0
  22274. },
  22275. {
  22276. qe: 0x1801,
  22277. nmps: 3,
  22278. nlps: 9,
  22279. switchFlag: 0
  22280. },
  22281. {
  22282. qe: 0x0AC1,
  22283. nmps: 4,
  22284. nlps: 12,
  22285. switchFlag: 0
  22286. },
  22287. {
  22288. qe: 0x0521,
  22289. nmps: 5,
  22290. nlps: 29,
  22291. switchFlag: 0
  22292. },
  22293. {
  22294. qe: 0x0221,
  22295. nmps: 38,
  22296. nlps: 33,
  22297. switchFlag: 0
  22298. },
  22299. {
  22300. qe: 0x5601,
  22301. nmps: 7,
  22302. nlps: 6,
  22303. switchFlag: 1
  22304. },
  22305. {
  22306. qe: 0x5401,
  22307. nmps: 8,
  22308. nlps: 14,
  22309. switchFlag: 0
  22310. },
  22311. {
  22312. qe: 0x4801,
  22313. nmps: 9,
  22314. nlps: 14,
  22315. switchFlag: 0
  22316. },
  22317. {
  22318. qe: 0x3801,
  22319. nmps: 10,
  22320. nlps: 14,
  22321. switchFlag: 0
  22322. },
  22323. {
  22324. qe: 0x3001,
  22325. nmps: 11,
  22326. nlps: 17,
  22327. switchFlag: 0
  22328. },
  22329. {
  22330. qe: 0x2401,
  22331. nmps: 12,
  22332. nlps: 18,
  22333. switchFlag: 0
  22334. },
  22335. {
  22336. qe: 0x1C01,
  22337. nmps: 13,
  22338. nlps: 20,
  22339. switchFlag: 0
  22340. },
  22341. {
  22342. qe: 0x1601,
  22343. nmps: 29,
  22344. nlps: 21,
  22345. switchFlag: 0
  22346. },
  22347. {
  22348. qe: 0x5601,
  22349. nmps: 15,
  22350. nlps: 14,
  22351. switchFlag: 1
  22352. },
  22353. {
  22354. qe: 0x5401,
  22355. nmps: 16,
  22356. nlps: 14,
  22357. switchFlag: 0
  22358. },
  22359. {
  22360. qe: 0x5101,
  22361. nmps: 17,
  22362. nlps: 15,
  22363. switchFlag: 0
  22364. },
  22365. {
  22366. qe: 0x4801,
  22367. nmps: 18,
  22368. nlps: 16,
  22369. switchFlag: 0
  22370. },
  22371. {
  22372. qe: 0x3801,
  22373. nmps: 19,
  22374. nlps: 17,
  22375. switchFlag: 0
  22376. },
  22377. {
  22378. qe: 0x3401,
  22379. nmps: 20,
  22380. nlps: 18,
  22381. switchFlag: 0
  22382. },
  22383. {
  22384. qe: 0x3001,
  22385. nmps: 21,
  22386. nlps: 19,
  22387. switchFlag: 0
  22388. },
  22389. {
  22390. qe: 0x2801,
  22391. nmps: 22,
  22392. nlps: 19,
  22393. switchFlag: 0
  22394. },
  22395. {
  22396. qe: 0x2401,
  22397. nmps: 23,
  22398. nlps: 20,
  22399. switchFlag: 0
  22400. },
  22401. {
  22402. qe: 0x2201,
  22403. nmps: 24,
  22404. nlps: 21,
  22405. switchFlag: 0
  22406. },
  22407. {
  22408. qe: 0x1C01,
  22409. nmps: 25,
  22410. nlps: 22,
  22411. switchFlag: 0
  22412. },
  22413. {
  22414. qe: 0x1801,
  22415. nmps: 26,
  22416. nlps: 23,
  22417. switchFlag: 0
  22418. },
  22419. {
  22420. qe: 0x1601,
  22421. nmps: 27,
  22422. nlps: 24,
  22423. switchFlag: 0
  22424. },
  22425. {
  22426. qe: 0x1401,
  22427. nmps: 28,
  22428. nlps: 25,
  22429. switchFlag: 0
  22430. },
  22431. {
  22432. qe: 0x1201,
  22433. nmps: 29,
  22434. nlps: 26,
  22435. switchFlag: 0
  22436. },
  22437. {
  22438. qe: 0x1101,
  22439. nmps: 30,
  22440. nlps: 27,
  22441. switchFlag: 0
  22442. },
  22443. {
  22444. qe: 0x0AC1,
  22445. nmps: 31,
  22446. nlps: 28,
  22447. switchFlag: 0
  22448. },
  22449. {
  22450. qe: 0x09C1,
  22451. nmps: 32,
  22452. nlps: 29,
  22453. switchFlag: 0
  22454. },
  22455. {
  22456. qe: 0x08A1,
  22457. nmps: 33,
  22458. nlps: 30,
  22459. switchFlag: 0
  22460. },
  22461. {
  22462. qe: 0x0521,
  22463. nmps: 34,
  22464. nlps: 31,
  22465. switchFlag: 0
  22466. },
  22467. {
  22468. qe: 0x0441,
  22469. nmps: 35,
  22470. nlps: 32,
  22471. switchFlag: 0
  22472. },
  22473. {
  22474. qe: 0x02A1,
  22475. nmps: 36,
  22476. nlps: 33,
  22477. switchFlag: 0
  22478. },
  22479. {
  22480. qe: 0x0221,
  22481. nmps: 37,
  22482. nlps: 34,
  22483. switchFlag: 0
  22484. },
  22485. {
  22486. qe: 0x0141,
  22487. nmps: 38,
  22488. nlps: 35,
  22489. switchFlag: 0
  22490. },
  22491. {
  22492. qe: 0x0111,
  22493. nmps: 39,
  22494. nlps: 36,
  22495. switchFlag: 0
  22496. },
  22497. {
  22498. qe: 0x0085,
  22499. nmps: 40,
  22500. nlps: 37,
  22501. switchFlag: 0
  22502. },
  22503. {
  22504. qe: 0x0049,
  22505. nmps: 41,
  22506. nlps: 38,
  22507. switchFlag: 0
  22508. },
  22509. {
  22510. qe: 0x0025,
  22511. nmps: 42,
  22512. nlps: 39,
  22513. switchFlag: 0
  22514. },
  22515. {
  22516. qe: 0x0015,
  22517. nmps: 43,
  22518. nlps: 40,
  22519. switchFlag: 0
  22520. },
  22521. {
  22522. qe: 0x0009,
  22523. nmps: 44,
  22524. nlps: 41,
  22525. switchFlag: 0
  22526. },
  22527. {
  22528. qe: 0x0005,
  22529. nmps: 45,
  22530. nlps: 42,
  22531. switchFlag: 0
  22532. },
  22533. {
  22534. qe: 0x0001,
  22535. nmps: 45,
  22536. nlps: 43,
  22537. switchFlag: 0
  22538. },
  22539. {
  22540. qe: 0x5601,
  22541. nmps: 46,
  22542. nlps: 46,
  22543. switchFlag: 0
  22544. }
  22545. ];
  22546. function ArithmeticDecoder(data, start, end) {
  22547. this.data = data;
  22548. this.bp = start;
  22549. this.dataEnd = end;
  22550. this.chigh = data[start];
  22551. this.clow = 0;
  22552. this.byteIn();
  22553. this.chigh = this.chigh << 7 & 0xFFFF | this.clow >> 9 & 0x7F;
  22554. this.clow = this.clow << 7 & 0xFFFF;
  22555. this.ct -= 7;
  22556. this.a = 0x8000;
  22557. }
  22558. ArithmeticDecoder.prototype = {
  22559. byteIn: function ArithmeticDecoder_byteIn() {
  22560. var data = this.data;
  22561. var bp = this.bp;
  22562. if (data[bp] === 0xFF) {
  22563. var b1 = data[bp + 1];
  22564. if (b1 > 0x8F) {
  22565. this.clow += 0xFF00;
  22566. this.ct = 8;
  22567. } else {
  22568. bp++;
  22569. this.clow += data[bp] << 9;
  22570. this.ct = 7;
  22571. this.bp = bp;
  22572. }
  22573. } else {
  22574. bp++;
  22575. this.clow += bp < this.dataEnd ? data[bp] << 8 : 0xFF00;
  22576. this.ct = 8;
  22577. this.bp = bp;
  22578. }
  22579. if (this.clow > 0xFFFF) {
  22580. this.chigh += this.clow >> 16;
  22581. this.clow &= 0xFFFF;
  22582. }
  22583. },
  22584. readBit: function ArithmeticDecoder_readBit(contexts, pos) {
  22585. var cx_index = contexts[pos] >> 1, cx_mps = contexts[pos] & 1;
  22586. var qeTableIcx = QeTable[cx_index];
  22587. var qeIcx = qeTableIcx.qe;
  22588. var d;
  22589. var a = this.a - qeIcx;
  22590. if (this.chigh < qeIcx) {
  22591. if (a < qeIcx) {
  22592. a = qeIcx;
  22593. d = cx_mps;
  22594. cx_index = qeTableIcx.nmps;
  22595. } else {
  22596. a = qeIcx;
  22597. d = 1 ^ cx_mps;
  22598. if (qeTableIcx.switchFlag === 1) {
  22599. cx_mps = d;
  22600. }
  22601. cx_index = qeTableIcx.nlps;
  22602. }
  22603. } else {
  22604. this.chigh -= qeIcx;
  22605. if ((a & 0x8000) !== 0) {
  22606. this.a = a;
  22607. return cx_mps;
  22608. }
  22609. if (a < qeIcx) {
  22610. d = 1 ^ cx_mps;
  22611. if (qeTableIcx.switchFlag === 1) {
  22612. cx_mps = d;
  22613. }
  22614. cx_index = qeTableIcx.nlps;
  22615. } else {
  22616. d = cx_mps;
  22617. cx_index = qeTableIcx.nmps;
  22618. }
  22619. }
  22620. do {
  22621. if (this.ct === 0) {
  22622. this.byteIn();
  22623. }
  22624. a <<= 1;
  22625. this.chigh = this.chigh << 1 & 0xFFFF | this.clow >> 15 & 1;
  22626. this.clow = this.clow << 1 & 0xFFFF;
  22627. this.ct--;
  22628. } while ((a & 0x8000) === 0);
  22629. this.a = a;
  22630. contexts[pos] = cx_index << 1 | cx_mps;
  22631. return d;
  22632. }
  22633. };
  22634. return ArithmeticDecoder;
  22635. }();
  22636. exports.ArithmeticDecoder = ArithmeticDecoder;
  22637. /***/ }),
  22638. /* 14 */
  22639. /***/ (function(module, exports, __w_pdfjs_require__) {
  22640. "use strict";
  22641. var sharedUtil = __w_pdfjs_require__(0);
  22642. var coreCharsets = __w_pdfjs_require__(30);
  22643. var coreEncodings = __w_pdfjs_require__(5);
  22644. var error = sharedUtil.error;
  22645. var info = sharedUtil.info;
  22646. var bytesToString = sharedUtil.bytesToString;
  22647. var warn = sharedUtil.warn;
  22648. var isArray = sharedUtil.isArray;
  22649. var Util = sharedUtil.Util;
  22650. var stringToBytes = sharedUtil.stringToBytes;
  22651. var assert = sharedUtil.assert;
  22652. var ISOAdobeCharset = coreCharsets.ISOAdobeCharset;
  22653. var ExpertCharset = coreCharsets.ExpertCharset;
  22654. var ExpertSubsetCharset = coreCharsets.ExpertSubsetCharset;
  22655. var StandardEncoding = coreEncodings.StandardEncoding;
  22656. var ExpertEncoding = coreEncodings.ExpertEncoding;
  22657. var MAX_SUBR_NESTING = 10;
  22658. var CFFStandardStrings = [
  22659. '.notdef',
  22660. 'space',
  22661. 'exclam',
  22662. 'quotedbl',
  22663. 'numbersign',
  22664. 'dollar',
  22665. 'percent',
  22666. 'ampersand',
  22667. 'quoteright',
  22668. 'parenleft',
  22669. 'parenright',
  22670. 'asterisk',
  22671. 'plus',
  22672. 'comma',
  22673. 'hyphen',
  22674. 'period',
  22675. 'slash',
  22676. 'zero',
  22677. 'one',
  22678. 'two',
  22679. 'three',
  22680. 'four',
  22681. 'five',
  22682. 'six',
  22683. 'seven',
  22684. 'eight',
  22685. 'nine',
  22686. 'colon',
  22687. 'semicolon',
  22688. 'less',
  22689. 'equal',
  22690. 'greater',
  22691. 'question',
  22692. 'at',
  22693. 'A',
  22694. 'B',
  22695. 'C',
  22696. 'D',
  22697. 'E',
  22698. 'F',
  22699. 'G',
  22700. 'H',
  22701. 'I',
  22702. 'J',
  22703. 'K',
  22704. 'L',
  22705. 'M',
  22706. 'N',
  22707. 'O',
  22708. 'P',
  22709. 'Q',
  22710. 'R',
  22711. 'S',
  22712. 'T',
  22713. 'U',
  22714. 'V',
  22715. 'W',
  22716. 'X',
  22717. 'Y',
  22718. 'Z',
  22719. 'bracketleft',
  22720. 'backslash',
  22721. 'bracketright',
  22722. 'asciicircum',
  22723. 'underscore',
  22724. 'quoteleft',
  22725. 'a',
  22726. 'b',
  22727. 'c',
  22728. 'd',
  22729. 'e',
  22730. 'f',
  22731. 'g',
  22732. 'h',
  22733. 'i',
  22734. 'j',
  22735. 'k',
  22736. 'l',
  22737. 'm',
  22738. 'n',
  22739. 'o',
  22740. 'p',
  22741. 'q',
  22742. 'r',
  22743. 's',
  22744. 't',
  22745. 'u',
  22746. 'v',
  22747. 'w',
  22748. 'x',
  22749. 'y',
  22750. 'z',
  22751. 'braceleft',
  22752. 'bar',
  22753. 'braceright',
  22754. 'asciitilde',
  22755. 'exclamdown',
  22756. 'cent',
  22757. 'sterling',
  22758. 'fraction',
  22759. 'yen',
  22760. 'florin',
  22761. 'section',
  22762. 'currency',
  22763. 'quotesingle',
  22764. 'quotedblleft',
  22765. 'guillemotleft',
  22766. 'guilsinglleft',
  22767. 'guilsinglright',
  22768. 'fi',
  22769. 'fl',
  22770. 'endash',
  22771. 'dagger',
  22772. 'daggerdbl',
  22773. 'periodcentered',
  22774. 'paragraph',
  22775. 'bullet',
  22776. 'quotesinglbase',
  22777. 'quotedblbase',
  22778. 'quotedblright',
  22779. 'guillemotright',
  22780. 'ellipsis',
  22781. 'perthousand',
  22782. 'questiondown',
  22783. 'grave',
  22784. 'acute',
  22785. 'circumflex',
  22786. 'tilde',
  22787. 'macron',
  22788. 'breve',
  22789. 'dotaccent',
  22790. 'dieresis',
  22791. 'ring',
  22792. 'cedilla',
  22793. 'hungarumlaut',
  22794. 'ogonek',
  22795. 'caron',
  22796. 'emdash',
  22797. 'AE',
  22798. 'ordfeminine',
  22799. 'Lslash',
  22800. 'Oslash',
  22801. 'OE',
  22802. 'ordmasculine',
  22803. 'ae',
  22804. 'dotlessi',
  22805. 'lslash',
  22806. 'oslash',
  22807. 'oe',
  22808. 'germandbls',
  22809. 'onesuperior',
  22810. 'logicalnot',
  22811. 'mu',
  22812. 'trademark',
  22813. 'Eth',
  22814. 'onehalf',
  22815. 'plusminus',
  22816. 'Thorn',
  22817. 'onequarter',
  22818. 'divide',
  22819. 'brokenbar',
  22820. 'degree',
  22821. 'thorn',
  22822. 'threequarters',
  22823. 'twosuperior',
  22824. 'registered',
  22825. 'minus',
  22826. 'eth',
  22827. 'multiply',
  22828. 'threesuperior',
  22829. 'copyright',
  22830. 'Aacute',
  22831. 'Acircumflex',
  22832. 'Adieresis',
  22833. 'Agrave',
  22834. 'Aring',
  22835. 'Atilde',
  22836. 'Ccedilla',
  22837. 'Eacute',
  22838. 'Ecircumflex',
  22839. 'Edieresis',
  22840. 'Egrave',
  22841. 'Iacute',
  22842. 'Icircumflex',
  22843. 'Idieresis',
  22844. 'Igrave',
  22845. 'Ntilde',
  22846. 'Oacute',
  22847. 'Ocircumflex',
  22848. 'Odieresis',
  22849. 'Ograve',
  22850. 'Otilde',
  22851. 'Scaron',
  22852. 'Uacute',
  22853. 'Ucircumflex',
  22854. 'Udieresis',
  22855. 'Ugrave',
  22856. 'Yacute',
  22857. 'Ydieresis',
  22858. 'Zcaron',
  22859. 'aacute',
  22860. 'acircumflex',
  22861. 'adieresis',
  22862. 'agrave',
  22863. 'aring',
  22864. 'atilde',
  22865. 'ccedilla',
  22866. 'eacute',
  22867. 'ecircumflex',
  22868. 'edieresis',
  22869. 'egrave',
  22870. 'iacute',
  22871. 'icircumflex',
  22872. 'idieresis',
  22873. 'igrave',
  22874. 'ntilde',
  22875. 'oacute',
  22876. 'ocircumflex',
  22877. 'odieresis',
  22878. 'ograve',
  22879. 'otilde',
  22880. 'scaron',
  22881. 'uacute',
  22882. 'ucircumflex',
  22883. 'udieresis',
  22884. 'ugrave',
  22885. 'yacute',
  22886. 'ydieresis',
  22887. 'zcaron',
  22888. 'exclamsmall',
  22889. 'Hungarumlautsmall',
  22890. 'dollaroldstyle',
  22891. 'dollarsuperior',
  22892. 'ampersandsmall',
  22893. 'Acutesmall',
  22894. 'parenleftsuperior',
  22895. 'parenrightsuperior',
  22896. 'twodotenleader',
  22897. 'onedotenleader',
  22898. 'zerooldstyle',
  22899. 'oneoldstyle',
  22900. 'twooldstyle',
  22901. 'threeoldstyle',
  22902. 'fouroldstyle',
  22903. 'fiveoldstyle',
  22904. 'sixoldstyle',
  22905. 'sevenoldstyle',
  22906. 'eightoldstyle',
  22907. 'nineoldstyle',
  22908. 'commasuperior',
  22909. 'threequartersemdash',
  22910. 'periodsuperior',
  22911. 'questionsmall',
  22912. 'asuperior',
  22913. 'bsuperior',
  22914. 'centsuperior',
  22915. 'dsuperior',
  22916. 'esuperior',
  22917. 'isuperior',
  22918. 'lsuperior',
  22919. 'msuperior',
  22920. 'nsuperior',
  22921. 'osuperior',
  22922. 'rsuperior',
  22923. 'ssuperior',
  22924. 'tsuperior',
  22925. 'ff',
  22926. 'ffi',
  22927. 'ffl',
  22928. 'parenleftinferior',
  22929. 'parenrightinferior',
  22930. 'Circumflexsmall',
  22931. 'hyphensuperior',
  22932. 'Gravesmall',
  22933. 'Asmall',
  22934. 'Bsmall',
  22935. 'Csmall',
  22936. 'Dsmall',
  22937. 'Esmall',
  22938. 'Fsmall',
  22939. 'Gsmall',
  22940. 'Hsmall',
  22941. 'Ismall',
  22942. 'Jsmall',
  22943. 'Ksmall',
  22944. 'Lsmall',
  22945. 'Msmall',
  22946. 'Nsmall',
  22947. 'Osmall',
  22948. 'Psmall',
  22949. 'Qsmall',
  22950. 'Rsmall',
  22951. 'Ssmall',
  22952. 'Tsmall',
  22953. 'Usmall',
  22954. 'Vsmall',
  22955. 'Wsmall',
  22956. 'Xsmall',
  22957. 'Ysmall',
  22958. 'Zsmall',
  22959. 'colonmonetary',
  22960. 'onefitted',
  22961. 'rupiah',
  22962. 'Tildesmall',
  22963. 'exclamdownsmall',
  22964. 'centoldstyle',
  22965. 'Lslashsmall',
  22966. 'Scaronsmall',
  22967. 'Zcaronsmall',
  22968. 'Dieresissmall',
  22969. 'Brevesmall',
  22970. 'Caronsmall',
  22971. 'Dotaccentsmall',
  22972. 'Macronsmall',
  22973. 'figuredash',
  22974. 'hypheninferior',
  22975. 'Ogoneksmall',
  22976. 'Ringsmall',
  22977. 'Cedillasmall',
  22978. 'questiondownsmall',
  22979. 'oneeighth',
  22980. 'threeeighths',
  22981. 'fiveeighths',
  22982. 'seveneighths',
  22983. 'onethird',
  22984. 'twothirds',
  22985. 'zerosuperior',
  22986. 'foursuperior',
  22987. 'fivesuperior',
  22988. 'sixsuperior',
  22989. 'sevensuperior',
  22990. 'eightsuperior',
  22991. 'ninesuperior',
  22992. 'zeroinferior',
  22993. 'oneinferior',
  22994. 'twoinferior',
  22995. 'threeinferior',
  22996. 'fourinferior',
  22997. 'fiveinferior',
  22998. 'sixinferior',
  22999. 'seveninferior',
  23000. 'eightinferior',
  23001. 'nineinferior',
  23002. 'centinferior',
  23003. 'dollarinferior',
  23004. 'periodinferior',
  23005. 'commainferior',
  23006. 'Agravesmall',
  23007. 'Aacutesmall',
  23008. 'Acircumflexsmall',
  23009. 'Atildesmall',
  23010. 'Adieresissmall',
  23011. 'Aringsmall',
  23012. 'AEsmall',
  23013. 'Ccedillasmall',
  23014. 'Egravesmall',
  23015. 'Eacutesmall',
  23016. 'Ecircumflexsmall',
  23017. 'Edieresissmall',
  23018. 'Igravesmall',
  23019. 'Iacutesmall',
  23020. 'Icircumflexsmall',
  23021. 'Idieresissmall',
  23022. 'Ethsmall',
  23023. 'Ntildesmall',
  23024. 'Ogravesmall',
  23025. 'Oacutesmall',
  23026. 'Ocircumflexsmall',
  23027. 'Otildesmall',
  23028. 'Odieresissmall',
  23029. 'OEsmall',
  23030. 'Oslashsmall',
  23031. 'Ugravesmall',
  23032. 'Uacutesmall',
  23033. 'Ucircumflexsmall',
  23034. 'Udieresissmall',
  23035. 'Yacutesmall',
  23036. 'Thornsmall',
  23037. 'Ydieresissmall',
  23038. '001.000',
  23039. '001.001',
  23040. '001.002',
  23041. '001.003',
  23042. 'Black',
  23043. 'Bold',
  23044. 'Book',
  23045. 'Light',
  23046. 'Medium',
  23047. 'Regular',
  23048. 'Roman',
  23049. 'Semibold'
  23050. ];
  23051. var CFFParser = function CFFParserClosure() {
  23052. var CharstringValidationData = [
  23053. null,
  23054. {
  23055. id: 'hstem',
  23056. min: 2,
  23057. stackClearing: true,
  23058. stem: true
  23059. },
  23060. null,
  23061. {
  23062. id: 'vstem',
  23063. min: 2,
  23064. stackClearing: true,
  23065. stem: true
  23066. },
  23067. {
  23068. id: 'vmoveto',
  23069. min: 1,
  23070. stackClearing: true
  23071. },
  23072. {
  23073. id: 'rlineto',
  23074. min: 2,
  23075. resetStack: true
  23076. },
  23077. {
  23078. id: 'hlineto',
  23079. min: 1,
  23080. resetStack: true
  23081. },
  23082. {
  23083. id: 'vlineto',
  23084. min: 1,
  23085. resetStack: true
  23086. },
  23087. {
  23088. id: 'rrcurveto',
  23089. min: 6,
  23090. resetStack: true
  23091. },
  23092. null,
  23093. {
  23094. id: 'callsubr',
  23095. min: 1,
  23096. undefStack: true
  23097. },
  23098. {
  23099. id: 'return',
  23100. min: 0,
  23101. undefStack: true
  23102. },
  23103. null,
  23104. null,
  23105. {
  23106. id: 'endchar',
  23107. min: 0,
  23108. stackClearing: true
  23109. },
  23110. null,
  23111. null,
  23112. null,
  23113. {
  23114. id: 'hstemhm',
  23115. min: 2,
  23116. stackClearing: true,
  23117. stem: true
  23118. },
  23119. {
  23120. id: 'hintmask',
  23121. min: 0,
  23122. stackClearing: true
  23123. },
  23124. {
  23125. id: 'cntrmask',
  23126. min: 0,
  23127. stackClearing: true
  23128. },
  23129. {
  23130. id: 'rmoveto',
  23131. min: 2,
  23132. stackClearing: true
  23133. },
  23134. {
  23135. id: 'hmoveto',
  23136. min: 1,
  23137. stackClearing: true
  23138. },
  23139. {
  23140. id: 'vstemhm',
  23141. min: 2,
  23142. stackClearing: true,
  23143. stem: true
  23144. },
  23145. {
  23146. id: 'rcurveline',
  23147. min: 8,
  23148. resetStack: true
  23149. },
  23150. {
  23151. id: 'rlinecurve',
  23152. min: 8,
  23153. resetStack: true
  23154. },
  23155. {
  23156. id: 'vvcurveto',
  23157. min: 4,
  23158. resetStack: true
  23159. },
  23160. {
  23161. id: 'hhcurveto',
  23162. min: 4,
  23163. resetStack: true
  23164. },
  23165. null,
  23166. {
  23167. id: 'callgsubr',
  23168. min: 1,
  23169. undefStack: true
  23170. },
  23171. {
  23172. id: 'vhcurveto',
  23173. min: 4,
  23174. resetStack: true
  23175. },
  23176. {
  23177. id: 'hvcurveto',
  23178. min: 4,
  23179. resetStack: true
  23180. }
  23181. ];
  23182. var CharstringValidationData12 = [
  23183. null,
  23184. null,
  23185. null,
  23186. {
  23187. id: 'and',
  23188. min: 2,
  23189. stackDelta: -1
  23190. },
  23191. {
  23192. id: 'or',
  23193. min: 2,
  23194. stackDelta: -1
  23195. },
  23196. {
  23197. id: 'not',
  23198. min: 1,
  23199. stackDelta: 0
  23200. },
  23201. null,
  23202. null,
  23203. null,
  23204. {
  23205. id: 'abs',
  23206. min: 1,
  23207. stackDelta: 0
  23208. },
  23209. {
  23210. id: 'add',
  23211. min: 2,
  23212. stackDelta: -1,
  23213. stackFn: function stack_div(stack, index) {
  23214. stack[index - 2] = stack[index - 2] + stack[index - 1];
  23215. }
  23216. },
  23217. {
  23218. id: 'sub',
  23219. min: 2,
  23220. stackDelta: -1,
  23221. stackFn: function stack_div(stack, index) {
  23222. stack[index - 2] = stack[index - 2] - stack[index - 1];
  23223. }
  23224. },
  23225. {
  23226. id: 'div',
  23227. min: 2,
  23228. stackDelta: -1,
  23229. stackFn: function stack_div(stack, index) {
  23230. stack[index - 2] = stack[index - 2] / stack[index - 1];
  23231. }
  23232. },
  23233. null,
  23234. {
  23235. id: 'neg',
  23236. min: 1,
  23237. stackDelta: 0,
  23238. stackFn: function stack_div(stack, index) {
  23239. stack[index - 1] = -stack[index - 1];
  23240. }
  23241. },
  23242. {
  23243. id: 'eq',
  23244. min: 2,
  23245. stackDelta: -1
  23246. },
  23247. null,
  23248. null,
  23249. {
  23250. id: 'drop',
  23251. min: 1,
  23252. stackDelta: -1
  23253. },
  23254. null,
  23255. {
  23256. id: 'put',
  23257. min: 2,
  23258. stackDelta: -2
  23259. },
  23260. {
  23261. id: 'get',
  23262. min: 1,
  23263. stackDelta: 0
  23264. },
  23265. {
  23266. id: 'ifelse',
  23267. min: 4,
  23268. stackDelta: -3
  23269. },
  23270. {
  23271. id: 'random',
  23272. min: 0,
  23273. stackDelta: 1
  23274. },
  23275. {
  23276. id: 'mul',
  23277. min: 2,
  23278. stackDelta: -1,
  23279. stackFn: function stack_div(stack, index) {
  23280. stack[index - 2] = stack[index - 2] * stack[index - 1];
  23281. }
  23282. },
  23283. null,
  23284. {
  23285. id: 'sqrt',
  23286. min: 1,
  23287. stackDelta: 0
  23288. },
  23289. {
  23290. id: 'dup',
  23291. min: 1,
  23292. stackDelta: 1
  23293. },
  23294. {
  23295. id: 'exch',
  23296. min: 2,
  23297. stackDelta: 0
  23298. },
  23299. {
  23300. id: 'index',
  23301. min: 2,
  23302. stackDelta: 0
  23303. },
  23304. {
  23305. id: 'roll',
  23306. min: 3,
  23307. stackDelta: -2
  23308. },
  23309. null,
  23310. null,
  23311. null,
  23312. {
  23313. id: 'hflex',
  23314. min: 7,
  23315. resetStack: true
  23316. },
  23317. {
  23318. id: 'flex',
  23319. min: 13,
  23320. resetStack: true
  23321. },
  23322. {
  23323. id: 'hflex1',
  23324. min: 9,
  23325. resetStack: true
  23326. },
  23327. {
  23328. id: 'flex1',
  23329. min: 11,
  23330. resetStack: true
  23331. }
  23332. ];
  23333. function CFFParser(file, properties, seacAnalysisEnabled) {
  23334. this.bytes = file.getBytes();
  23335. this.properties = properties;
  23336. this.seacAnalysisEnabled = !!seacAnalysisEnabled;
  23337. }
  23338. CFFParser.prototype = {
  23339. parse: function CFFParser_parse() {
  23340. var properties = this.properties;
  23341. var cff = new CFF();
  23342. this.cff = cff;
  23343. var header = this.parseHeader();
  23344. var nameIndex = this.parseIndex(header.endPos);
  23345. var topDictIndex = this.parseIndex(nameIndex.endPos);
  23346. var stringIndex = this.parseIndex(topDictIndex.endPos);
  23347. var globalSubrIndex = this.parseIndex(stringIndex.endPos);
  23348. var topDictParsed = this.parseDict(topDictIndex.obj.get(0));
  23349. var topDict = this.createDict(CFFTopDict, topDictParsed, cff.strings);
  23350. cff.header = header.obj;
  23351. cff.names = this.parseNameIndex(nameIndex.obj);
  23352. cff.strings = this.parseStringIndex(stringIndex.obj);
  23353. cff.topDict = topDict;
  23354. cff.globalSubrIndex = globalSubrIndex.obj;
  23355. this.parsePrivateDict(cff.topDict);
  23356. cff.isCIDFont = topDict.hasName('ROS');
  23357. var charStringOffset = topDict.getByName('CharStrings');
  23358. var charStringIndex = this.parseIndex(charStringOffset).obj;
  23359. var fontMatrix = topDict.getByName('FontMatrix');
  23360. if (fontMatrix) {
  23361. properties.fontMatrix = fontMatrix;
  23362. }
  23363. var fontBBox = topDict.getByName('FontBBox');
  23364. if (fontBBox) {
  23365. properties.ascent = fontBBox[3];
  23366. properties.descent = fontBBox[1];
  23367. properties.ascentScaled = true;
  23368. }
  23369. var charset, encoding;
  23370. if (cff.isCIDFont) {
  23371. var fdArrayIndex = this.parseIndex(topDict.getByName('FDArray')).obj;
  23372. for (var i = 0, ii = fdArrayIndex.count; i < ii; ++i) {
  23373. var dictRaw = fdArrayIndex.get(i);
  23374. var fontDict = this.createDict(CFFTopDict, this.parseDict(dictRaw), cff.strings);
  23375. this.parsePrivateDict(fontDict);
  23376. cff.fdArray.push(fontDict);
  23377. }
  23378. encoding = null;
  23379. charset = this.parseCharsets(topDict.getByName('charset'), charStringIndex.count, cff.strings, true);
  23380. cff.fdSelect = this.parseFDSelect(topDict.getByName('FDSelect'), charStringIndex.count);
  23381. } else {
  23382. charset = this.parseCharsets(topDict.getByName('charset'), charStringIndex.count, cff.strings, false);
  23383. encoding = this.parseEncoding(topDict.getByName('Encoding'), properties, cff.strings, charset.charset);
  23384. }
  23385. cff.charset = charset;
  23386. cff.encoding = encoding;
  23387. var charStringsAndSeacs = this.parseCharStrings(charStringIndex, topDict.privateDict.subrsIndex, globalSubrIndex.obj, cff.fdSelect, cff.fdArray);
  23388. cff.charStrings = charStringsAndSeacs.charStrings;
  23389. cff.seacs = charStringsAndSeacs.seacs;
  23390. cff.widths = charStringsAndSeacs.widths;
  23391. return cff;
  23392. },
  23393. parseHeader: function CFFParser_parseHeader() {
  23394. var bytes = this.bytes;
  23395. var bytesLength = bytes.length;
  23396. var offset = 0;
  23397. while (offset < bytesLength && bytes[offset] !== 1) {
  23398. ++offset;
  23399. }
  23400. if (offset >= bytesLength) {
  23401. error('Invalid CFF header');
  23402. } else if (offset !== 0) {
  23403. info('cff data is shifted');
  23404. bytes = bytes.subarray(offset);
  23405. this.bytes = bytes;
  23406. }
  23407. var major = bytes[0];
  23408. var minor = bytes[1];
  23409. var hdrSize = bytes[2];
  23410. var offSize = bytes[3];
  23411. var header = new CFFHeader(major, minor, hdrSize, offSize);
  23412. return {
  23413. obj: header,
  23414. endPos: hdrSize
  23415. };
  23416. },
  23417. parseDict: function CFFParser_parseDict(dict) {
  23418. var pos = 0;
  23419. function parseOperand() {
  23420. var value = dict[pos++];
  23421. if (value === 30) {
  23422. return parseFloatOperand();
  23423. } else if (value === 28) {
  23424. value = dict[pos++];
  23425. value = (value << 24 | dict[pos++] << 16) >> 16;
  23426. return value;
  23427. } else if (value === 29) {
  23428. value = dict[pos++];
  23429. value = value << 8 | dict[pos++];
  23430. value = value << 8 | dict[pos++];
  23431. value = value << 8 | dict[pos++];
  23432. return value;
  23433. } else if (value >= 32 && value <= 246) {
  23434. return value - 139;
  23435. } else if (value >= 247 && value <= 250) {
  23436. return (value - 247) * 256 + dict[pos++] + 108;
  23437. } else if (value >= 251 && value <= 254) {
  23438. return -((value - 251) * 256) - dict[pos++] - 108;
  23439. }
  23440. warn('CFFParser_parseDict: "' + value + '" is a reserved command.');
  23441. return NaN;
  23442. }
  23443. function parseFloatOperand() {
  23444. var str = '';
  23445. var eof = 15;
  23446. var lookup = [
  23447. '0',
  23448. '1',
  23449. '2',
  23450. '3',
  23451. '4',
  23452. '5',
  23453. '6',
  23454. '7',
  23455. '8',
  23456. '9',
  23457. '.',
  23458. 'E',
  23459. 'E-',
  23460. null,
  23461. '-'
  23462. ];
  23463. var length = dict.length;
  23464. while (pos < length) {
  23465. var b = dict[pos++];
  23466. var b1 = b >> 4;
  23467. var b2 = b & 15;
  23468. if (b1 === eof) {
  23469. break;
  23470. }
  23471. str += lookup[b1];
  23472. if (b2 === eof) {
  23473. break;
  23474. }
  23475. str += lookup[b2];
  23476. }
  23477. return parseFloat(str);
  23478. }
  23479. var operands = [];
  23480. var entries = [];
  23481. pos = 0;
  23482. var end = dict.length;
  23483. while (pos < end) {
  23484. var b = dict[pos];
  23485. if (b <= 21) {
  23486. if (b === 12) {
  23487. b = b << 8 | dict[++pos];
  23488. }
  23489. entries.push([
  23490. b,
  23491. operands
  23492. ]);
  23493. operands = [];
  23494. ++pos;
  23495. } else {
  23496. operands.push(parseOperand());
  23497. }
  23498. }
  23499. return entries;
  23500. },
  23501. parseIndex: function CFFParser_parseIndex(pos) {
  23502. var cffIndex = new CFFIndex();
  23503. var bytes = this.bytes;
  23504. var count = bytes[pos++] << 8 | bytes[pos++];
  23505. var offsets = [];
  23506. var end = pos;
  23507. var i, ii;
  23508. if (count !== 0) {
  23509. var offsetSize = bytes[pos++];
  23510. var startPos = pos + (count + 1) * offsetSize - 1;
  23511. for (i = 0, ii = count + 1; i < ii; ++i) {
  23512. var offset = 0;
  23513. for (var j = 0; j < offsetSize; ++j) {
  23514. offset <<= 8;
  23515. offset += bytes[pos++];
  23516. }
  23517. offsets.push(startPos + offset);
  23518. }
  23519. end = offsets[count];
  23520. }
  23521. for (i = 0, ii = offsets.length - 1; i < ii; ++i) {
  23522. var offsetStart = offsets[i];
  23523. var offsetEnd = offsets[i + 1];
  23524. cffIndex.add(bytes.subarray(offsetStart, offsetEnd));
  23525. }
  23526. return {
  23527. obj: cffIndex,
  23528. endPos: end
  23529. };
  23530. },
  23531. parseNameIndex: function CFFParser_parseNameIndex(index) {
  23532. var names = [];
  23533. for (var i = 0, ii = index.count; i < ii; ++i) {
  23534. var name = index.get(i);
  23535. var length = Math.min(name.length, 127);
  23536. var data = [];
  23537. for (var j = 0; j < length; ++j) {
  23538. var c = name[j];
  23539. if (j === 0 && c === 0) {
  23540. data[j] = c;
  23541. continue;
  23542. }
  23543. 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) {
  23544. data[j] = 95;
  23545. continue;
  23546. }
  23547. data[j] = c;
  23548. }
  23549. names.push(bytesToString(data));
  23550. }
  23551. return names;
  23552. },
  23553. parseStringIndex: function CFFParser_parseStringIndex(index) {
  23554. var strings = new CFFStrings();
  23555. for (var i = 0, ii = index.count; i < ii; ++i) {
  23556. var data = index.get(i);
  23557. strings.add(bytesToString(data));
  23558. }
  23559. return strings;
  23560. },
  23561. createDict: function CFFParser_createDict(Type, dict, strings) {
  23562. var cffDict = new Type(strings);
  23563. for (var i = 0, ii = dict.length; i < ii; ++i) {
  23564. var pair = dict[i];
  23565. var key = pair[0];
  23566. var value = pair[1];
  23567. cffDict.setByKey(key, value);
  23568. }
  23569. return cffDict;
  23570. },
  23571. parseCharString: function CFFParser_parseCharString(state, data, localSubrIndex, globalSubrIndex) {
  23572. if (state.callDepth > MAX_SUBR_NESTING) {
  23573. return false;
  23574. }
  23575. var stackSize = state.stackSize;
  23576. var stack = state.stack;
  23577. var length = data.length;
  23578. for (var j = 0; j < length;) {
  23579. var value = data[j++];
  23580. var validationCommand = null;
  23581. if (value === 12) {
  23582. var q = data[j++];
  23583. if (q === 0) {
  23584. data[j - 2] = 139;
  23585. data[j - 1] = 22;
  23586. stackSize = 0;
  23587. } else {
  23588. validationCommand = CharstringValidationData12[q];
  23589. }
  23590. } else if (value === 28) {
  23591. stack[stackSize] = (data[j] << 24 | data[j + 1] << 16) >> 16;
  23592. j += 2;
  23593. stackSize++;
  23594. } else if (value === 14) {
  23595. if (stackSize >= 4) {
  23596. stackSize -= 4;
  23597. if (this.seacAnalysisEnabled) {
  23598. state.seac = stack.slice(stackSize, stackSize + 4);
  23599. return false;
  23600. }
  23601. }
  23602. validationCommand = CharstringValidationData[value];
  23603. } else if (value >= 32 && value <= 246) {
  23604. stack[stackSize] = value - 139;
  23605. stackSize++;
  23606. } else if (value >= 247 && value <= 254) {
  23607. stack[stackSize] = value < 251 ? (value - 247 << 8) + data[j] + 108 : -(value - 251 << 8) - data[j] - 108;
  23608. j++;
  23609. stackSize++;
  23610. } else if (value === 255) {
  23611. stack[stackSize] = (data[j] << 24 | data[j + 1] << 16 | data[j + 2] << 8 | data[j + 3]) / 65536;
  23612. j += 4;
  23613. stackSize++;
  23614. } else if (value === 19 || value === 20) {
  23615. state.hints += stackSize >> 1;
  23616. j += state.hints + 7 >> 3;
  23617. stackSize %= 2;
  23618. validationCommand = CharstringValidationData[value];
  23619. } else if (value === 10 || value === 29) {
  23620. var subrsIndex;
  23621. if (value === 10) {
  23622. subrsIndex = localSubrIndex;
  23623. } else {
  23624. subrsIndex = globalSubrIndex;
  23625. }
  23626. if (!subrsIndex) {
  23627. validationCommand = CharstringValidationData[value];
  23628. warn('Missing subrsIndex for ' + validationCommand.id);
  23629. return false;
  23630. }
  23631. var bias = 32768;
  23632. if (subrsIndex.count < 1240) {
  23633. bias = 107;
  23634. } else if (subrsIndex.count < 33900) {
  23635. bias = 1131;
  23636. }
  23637. var subrNumber = stack[--stackSize] + bias;
  23638. if (subrNumber < 0 || subrNumber >= subrsIndex.count) {
  23639. validationCommand = CharstringValidationData[value];
  23640. warn('Out of bounds subrIndex for ' + validationCommand.id);
  23641. return false;
  23642. }
  23643. state.stackSize = stackSize;
  23644. state.callDepth++;
  23645. var valid = this.parseCharString(state, subrsIndex.get(subrNumber), localSubrIndex, globalSubrIndex);
  23646. if (!valid) {
  23647. return false;
  23648. }
  23649. state.callDepth--;
  23650. stackSize = state.stackSize;
  23651. continue;
  23652. } else if (value === 11) {
  23653. state.stackSize = stackSize;
  23654. return true;
  23655. } else {
  23656. validationCommand = CharstringValidationData[value];
  23657. }
  23658. if (validationCommand) {
  23659. if (validationCommand.stem) {
  23660. state.hints += stackSize >> 1;
  23661. }
  23662. if ('min' in validationCommand) {
  23663. if (!state.undefStack && stackSize < validationCommand.min) {
  23664. warn('Not enough parameters for ' + validationCommand.id + '; actual: ' + stackSize + ', expected: ' + validationCommand.min);
  23665. return false;
  23666. }
  23667. }
  23668. if (state.firstStackClearing && validationCommand.stackClearing) {
  23669. state.firstStackClearing = false;
  23670. stackSize -= validationCommand.min;
  23671. if (stackSize >= 2 && validationCommand.stem) {
  23672. stackSize %= 2;
  23673. } else if (stackSize > 1) {
  23674. warn('Found too many parameters for stack-clearing command');
  23675. }
  23676. if (stackSize > 0 && stack[stackSize - 1] >= 0) {
  23677. state.width = stack[stackSize - 1];
  23678. }
  23679. }
  23680. if ('stackDelta' in validationCommand) {
  23681. if ('stackFn' in validationCommand) {
  23682. validationCommand.stackFn(stack, stackSize);
  23683. }
  23684. stackSize += validationCommand.stackDelta;
  23685. } else if (validationCommand.stackClearing) {
  23686. stackSize = 0;
  23687. } else if (validationCommand.resetStack) {
  23688. stackSize = 0;
  23689. state.undefStack = false;
  23690. } else if (validationCommand.undefStack) {
  23691. stackSize = 0;
  23692. state.undefStack = true;
  23693. state.firstStackClearing = false;
  23694. }
  23695. }
  23696. }
  23697. state.stackSize = stackSize;
  23698. return true;
  23699. },
  23700. parseCharStrings: function CFFParser_parseCharStrings(charStrings, localSubrIndex, globalSubrIndex, fdSelect, fdArray) {
  23701. var seacs = [];
  23702. var widths = [];
  23703. var count = charStrings.count;
  23704. for (var i = 0; i < count; i++) {
  23705. var charstring = charStrings.get(i);
  23706. var state = {
  23707. callDepth: 0,
  23708. stackSize: 0,
  23709. stack: [],
  23710. undefStack: true,
  23711. hints: 0,
  23712. firstStackClearing: true,
  23713. seac: null,
  23714. width: null
  23715. };
  23716. var valid = true;
  23717. var localSubrToUse = null;
  23718. if (fdSelect && fdArray.length) {
  23719. var fdIndex = fdSelect.getFDIndex(i);
  23720. if (fdIndex === -1) {
  23721. warn('Glyph index is not in fd select.');
  23722. valid = false;
  23723. }
  23724. if (fdIndex >= fdArray.length) {
  23725. warn('Invalid fd index for glyph index.');
  23726. valid = false;
  23727. }
  23728. if (valid) {
  23729. localSubrToUse = fdArray[fdIndex].privateDict.subrsIndex;
  23730. }
  23731. } else if (localSubrIndex) {
  23732. localSubrToUse = localSubrIndex;
  23733. }
  23734. if (valid) {
  23735. valid = this.parseCharString(state, charstring, localSubrToUse, globalSubrIndex);
  23736. }
  23737. if (state.width !== null) {
  23738. widths[i] = state.width;
  23739. }
  23740. if (state.seac !== null) {
  23741. seacs[i] = state.seac;
  23742. }
  23743. if (!valid) {
  23744. charStrings.set(i, new Uint8Array([14]));
  23745. }
  23746. }
  23747. return {
  23748. charStrings: charStrings,
  23749. seacs: seacs,
  23750. widths: widths
  23751. };
  23752. },
  23753. emptyPrivateDictionary: function CFFParser_emptyPrivateDictionary(parentDict) {
  23754. var privateDict = this.createDict(CFFPrivateDict, [], parentDict.strings);
  23755. parentDict.setByKey(18, [
  23756. 0,
  23757. 0
  23758. ]);
  23759. parentDict.privateDict = privateDict;
  23760. },
  23761. parsePrivateDict: function CFFParser_parsePrivateDict(parentDict) {
  23762. if (!parentDict.hasName('Private')) {
  23763. this.emptyPrivateDictionary(parentDict);
  23764. return;
  23765. }
  23766. var privateOffset = parentDict.getByName('Private');
  23767. if (!isArray(privateOffset) || privateOffset.length !== 2) {
  23768. parentDict.removeByName('Private');
  23769. return;
  23770. }
  23771. var size = privateOffset[0];
  23772. var offset = privateOffset[1];
  23773. if (size === 0 || offset >= this.bytes.length) {
  23774. this.emptyPrivateDictionary(parentDict);
  23775. return;
  23776. }
  23777. var privateDictEnd = offset + size;
  23778. var dictData = this.bytes.subarray(offset, privateDictEnd);
  23779. var dict = this.parseDict(dictData);
  23780. var privateDict = this.createDict(CFFPrivateDict, dict, parentDict.strings);
  23781. parentDict.privateDict = privateDict;
  23782. if (!privateDict.getByName('Subrs')) {
  23783. return;
  23784. }
  23785. var subrsOffset = privateDict.getByName('Subrs');
  23786. var relativeOffset = offset + subrsOffset;
  23787. if (subrsOffset === 0 || relativeOffset >= this.bytes.length) {
  23788. this.emptyPrivateDictionary(parentDict);
  23789. return;
  23790. }
  23791. var subrsIndex = this.parseIndex(relativeOffset);
  23792. privateDict.subrsIndex = subrsIndex.obj;
  23793. },
  23794. parseCharsets: function CFFParser_parseCharsets(pos, length, strings, cid) {
  23795. if (pos === 0) {
  23796. return new CFFCharset(true, CFFCharsetPredefinedTypes.ISO_ADOBE, ISOAdobeCharset);
  23797. } else if (pos === 1) {
  23798. return new CFFCharset(true, CFFCharsetPredefinedTypes.EXPERT, ExpertCharset);
  23799. } else if (pos === 2) {
  23800. return new CFFCharset(true, CFFCharsetPredefinedTypes.EXPERT_SUBSET, ExpertSubsetCharset);
  23801. }
  23802. var bytes = this.bytes;
  23803. var start = pos;
  23804. var format = bytes[pos++];
  23805. var charset = ['.notdef'];
  23806. var id, count, i;
  23807. length -= 1;
  23808. switch (format) {
  23809. case 0:
  23810. for (i = 0; i < length; i++) {
  23811. id = bytes[pos++] << 8 | bytes[pos++];
  23812. charset.push(cid ? id : strings.get(id));
  23813. }
  23814. break;
  23815. case 1:
  23816. while (charset.length <= length) {
  23817. id = bytes[pos++] << 8 | bytes[pos++];
  23818. count = bytes[pos++];
  23819. for (i = 0; i <= count; i++) {
  23820. charset.push(cid ? id++ : strings.get(id++));
  23821. }
  23822. }
  23823. break;
  23824. case 2:
  23825. while (charset.length <= length) {
  23826. id = bytes[pos++] << 8 | bytes[pos++];
  23827. count = bytes[pos++] << 8 | bytes[pos++];
  23828. for (i = 0; i <= count; i++) {
  23829. charset.push(cid ? id++ : strings.get(id++));
  23830. }
  23831. }
  23832. break;
  23833. default:
  23834. error('Unknown charset format');
  23835. }
  23836. var end = pos;
  23837. var raw = bytes.subarray(start, end);
  23838. return new CFFCharset(false, format, charset, raw);
  23839. },
  23840. parseEncoding: function CFFParser_parseEncoding(pos, properties, strings, charset) {
  23841. var encoding = Object.create(null);
  23842. var bytes = this.bytes;
  23843. var predefined = false;
  23844. var format, i, ii;
  23845. var raw = null;
  23846. function readSupplement() {
  23847. var supplementsCount = bytes[pos++];
  23848. for (i = 0; i < supplementsCount; i++) {
  23849. var code = bytes[pos++];
  23850. var sid = (bytes[pos++] << 8) + (bytes[pos++] & 0xff);
  23851. encoding[code] = charset.indexOf(strings.get(sid));
  23852. }
  23853. }
  23854. if (pos === 0 || pos === 1) {
  23855. predefined = true;
  23856. format = pos;
  23857. var baseEncoding = pos ? ExpertEncoding : StandardEncoding;
  23858. for (i = 0, ii = charset.length; i < ii; i++) {
  23859. var index = baseEncoding.indexOf(charset[i]);
  23860. if (index !== -1) {
  23861. encoding[index] = i;
  23862. }
  23863. }
  23864. } else {
  23865. var dataStart = pos;
  23866. format = bytes[pos++];
  23867. switch (format & 0x7f) {
  23868. case 0:
  23869. var glyphsCount = bytes[pos++];
  23870. for (i = 1; i <= glyphsCount; i++) {
  23871. encoding[bytes[pos++]] = i;
  23872. }
  23873. break;
  23874. case 1:
  23875. var rangesCount = bytes[pos++];
  23876. var gid = 1;
  23877. for (i = 0; i < rangesCount; i++) {
  23878. var start = bytes[pos++];
  23879. var left = bytes[pos++];
  23880. for (var j = start; j <= start + left; j++) {
  23881. encoding[j] = gid++;
  23882. }
  23883. }
  23884. break;
  23885. default:
  23886. error('Unknown encoding format: ' + format + ' in CFF');
  23887. break;
  23888. }
  23889. var dataEnd = pos;
  23890. if (format & 0x80) {
  23891. bytes[dataStart] &= 0x7f;
  23892. readSupplement();
  23893. }
  23894. raw = bytes.subarray(dataStart, dataEnd);
  23895. }
  23896. format = format & 0x7f;
  23897. return new CFFEncoding(predefined, format, encoding, raw);
  23898. },
  23899. parseFDSelect: function CFFParser_parseFDSelect(pos, length) {
  23900. var start = pos;
  23901. var bytes = this.bytes;
  23902. var format = bytes[pos++];
  23903. var fdSelect = [], rawBytes;
  23904. var i, invalidFirstGID = false;
  23905. switch (format) {
  23906. case 0:
  23907. for (i = 0; i < length; ++i) {
  23908. var id = bytes[pos++];
  23909. fdSelect.push(id);
  23910. }
  23911. rawBytes = bytes.subarray(start, pos);
  23912. break;
  23913. case 3:
  23914. var rangesCount = bytes[pos++] << 8 | bytes[pos++];
  23915. for (i = 0; i < rangesCount; ++i) {
  23916. var first = bytes[pos++] << 8 | bytes[pos++];
  23917. if (i === 0 && first !== 0) {
  23918. warn('parseFDSelect: The first range must have a first GID of 0' + ' -- trying to recover.');
  23919. invalidFirstGID = true;
  23920. first = 0;
  23921. }
  23922. var fdIndex = bytes[pos++];
  23923. var next = bytes[pos] << 8 | bytes[pos + 1];
  23924. for (var j = first; j < next; ++j) {
  23925. fdSelect.push(fdIndex);
  23926. }
  23927. }
  23928. pos += 2;
  23929. rawBytes = bytes.subarray(start, pos);
  23930. if (invalidFirstGID) {
  23931. rawBytes[3] = rawBytes[4] = 0;
  23932. }
  23933. break;
  23934. default:
  23935. error('parseFDSelect: Unknown format "' + format + '".');
  23936. break;
  23937. }
  23938. assert(fdSelect.length === length, 'parseFDSelect: Invalid font data.');
  23939. return new CFFFDSelect(fdSelect, rawBytes);
  23940. }
  23941. };
  23942. return CFFParser;
  23943. }();
  23944. var CFF = function CFFClosure() {
  23945. function CFF() {
  23946. this.header = null;
  23947. this.names = [];
  23948. this.topDict = null;
  23949. this.strings = new CFFStrings();
  23950. this.globalSubrIndex = null;
  23951. this.encoding = null;
  23952. this.charset = null;
  23953. this.charStrings = null;
  23954. this.fdArray = [];
  23955. this.fdSelect = null;
  23956. this.isCIDFont = false;
  23957. }
  23958. return CFF;
  23959. }();
  23960. var CFFHeader = function CFFHeaderClosure() {
  23961. function CFFHeader(major, minor, hdrSize, offSize) {
  23962. this.major = major;
  23963. this.minor = minor;
  23964. this.hdrSize = hdrSize;
  23965. this.offSize = offSize;
  23966. }
  23967. return CFFHeader;
  23968. }();
  23969. var CFFStrings = function CFFStringsClosure() {
  23970. function CFFStrings() {
  23971. this.strings = [];
  23972. }
  23973. CFFStrings.prototype = {
  23974. get: function CFFStrings_get(index) {
  23975. if (index >= 0 && index <= 390) {
  23976. return CFFStandardStrings[index];
  23977. }
  23978. if (index - 391 <= this.strings.length) {
  23979. return this.strings[index - 391];
  23980. }
  23981. return CFFStandardStrings[0];
  23982. },
  23983. add: function CFFStrings_add(value) {
  23984. this.strings.push(value);
  23985. },
  23986. get count() {
  23987. return this.strings.length;
  23988. }
  23989. };
  23990. return CFFStrings;
  23991. }();
  23992. var CFFIndex = function CFFIndexClosure() {
  23993. function CFFIndex() {
  23994. this.objects = [];
  23995. this.length = 0;
  23996. }
  23997. CFFIndex.prototype = {
  23998. add: function CFFIndex_add(data) {
  23999. this.length += data.length;
  24000. this.objects.push(data);
  24001. },
  24002. set: function CFFIndex_set(index, data) {
  24003. this.length += data.length - this.objects[index].length;
  24004. this.objects[index] = data;
  24005. },
  24006. get: function CFFIndex_get(index) {
  24007. return this.objects[index];
  24008. },
  24009. get count() {
  24010. return this.objects.length;
  24011. }
  24012. };
  24013. return CFFIndex;
  24014. }();
  24015. var CFFDict = function CFFDictClosure() {
  24016. function CFFDict(tables, strings) {
  24017. this.keyToNameMap = tables.keyToNameMap;
  24018. this.nameToKeyMap = tables.nameToKeyMap;
  24019. this.defaults = tables.defaults;
  24020. this.types = tables.types;
  24021. this.opcodes = tables.opcodes;
  24022. this.order = tables.order;
  24023. this.strings = strings;
  24024. this.values = Object.create(null);
  24025. }
  24026. CFFDict.prototype = {
  24027. setByKey: function CFFDict_setByKey(key, value) {
  24028. if (!(key in this.keyToNameMap)) {
  24029. return false;
  24030. }
  24031. var valueLength = value.length;
  24032. if (valueLength === 0) {
  24033. return true;
  24034. }
  24035. for (var i = 0; i < valueLength; i++) {
  24036. if (isNaN(value[i])) {
  24037. warn('Invalid CFFDict value: "' + value + '" for key "' + key + '".');
  24038. return true;
  24039. }
  24040. }
  24041. var type = this.types[key];
  24042. if (type === 'num' || type === 'sid' || type === 'offset') {
  24043. value = value[0];
  24044. }
  24045. this.values[key] = value;
  24046. return true;
  24047. },
  24048. setByName: function CFFDict_setByName(name, value) {
  24049. if (!(name in this.nameToKeyMap)) {
  24050. error('Invalid dictionary name "' + name + '"');
  24051. }
  24052. this.values[this.nameToKeyMap[name]] = value;
  24053. },
  24054. hasName: function CFFDict_hasName(name) {
  24055. return this.nameToKeyMap[name] in this.values;
  24056. },
  24057. getByName: function CFFDict_getByName(name) {
  24058. if (!(name in this.nameToKeyMap)) {
  24059. error('Invalid dictionary name "' + name + '"');
  24060. }
  24061. var key = this.nameToKeyMap[name];
  24062. if (!(key in this.values)) {
  24063. return this.defaults[key];
  24064. }
  24065. return this.values[key];
  24066. },
  24067. removeByName: function CFFDict_removeByName(name) {
  24068. delete this.values[this.nameToKeyMap[name]];
  24069. }
  24070. };
  24071. CFFDict.createTables = function CFFDict_createTables(layout) {
  24072. var tables = {
  24073. keyToNameMap: {},
  24074. nameToKeyMap: {},
  24075. defaults: {},
  24076. types: {},
  24077. opcodes: {},
  24078. order: []
  24079. };
  24080. for (var i = 0, ii = layout.length; i < ii; ++i) {
  24081. var entry = layout[i];
  24082. var key = isArray(entry[0]) ? (entry[0][0] << 8) + entry[0][1] : entry[0];
  24083. tables.keyToNameMap[key] = entry[1];
  24084. tables.nameToKeyMap[entry[1]] = key;
  24085. tables.types[key] = entry[2];
  24086. tables.defaults[key] = entry[3];
  24087. tables.opcodes[key] = isArray(entry[0]) ? entry[0] : [entry[0]];
  24088. tables.order.push(key);
  24089. }
  24090. return tables;
  24091. };
  24092. return CFFDict;
  24093. }();
  24094. var CFFTopDict = function CFFTopDictClosure() {
  24095. var layout = [
  24096. [
  24097. [
  24098. 12,
  24099. 30
  24100. ],
  24101. 'ROS',
  24102. [
  24103. 'sid',
  24104. 'sid',
  24105. 'num'
  24106. ],
  24107. null
  24108. ],
  24109. [
  24110. [
  24111. 12,
  24112. 20
  24113. ],
  24114. 'SyntheticBase',
  24115. 'num',
  24116. null
  24117. ],
  24118. [
  24119. 0,
  24120. 'version',
  24121. 'sid',
  24122. null
  24123. ],
  24124. [
  24125. 1,
  24126. 'Notice',
  24127. 'sid',
  24128. null
  24129. ],
  24130. [
  24131. [
  24132. 12,
  24133. 0
  24134. ],
  24135. 'Copyright',
  24136. 'sid',
  24137. null
  24138. ],
  24139. [
  24140. 2,
  24141. 'FullName',
  24142. 'sid',
  24143. null
  24144. ],
  24145. [
  24146. 3,
  24147. 'FamilyName',
  24148. 'sid',
  24149. null
  24150. ],
  24151. [
  24152. 4,
  24153. 'Weight',
  24154. 'sid',
  24155. null
  24156. ],
  24157. [
  24158. [
  24159. 12,
  24160. 1
  24161. ],
  24162. 'isFixedPitch',
  24163. 'num',
  24164. 0
  24165. ],
  24166. [
  24167. [
  24168. 12,
  24169. 2
  24170. ],
  24171. 'ItalicAngle',
  24172. 'num',
  24173. 0
  24174. ],
  24175. [
  24176. [
  24177. 12,
  24178. 3
  24179. ],
  24180. 'UnderlinePosition',
  24181. 'num',
  24182. -100
  24183. ],
  24184. [
  24185. [
  24186. 12,
  24187. 4
  24188. ],
  24189. 'UnderlineThickness',
  24190. 'num',
  24191. 50
  24192. ],
  24193. [
  24194. [
  24195. 12,
  24196. 5
  24197. ],
  24198. 'PaintType',
  24199. 'num',
  24200. 0
  24201. ],
  24202. [
  24203. [
  24204. 12,
  24205. 6
  24206. ],
  24207. 'CharstringType',
  24208. 'num',
  24209. 2
  24210. ],
  24211. [
  24212. [
  24213. 12,
  24214. 7
  24215. ],
  24216. 'FontMatrix',
  24217. [
  24218. 'num',
  24219. 'num',
  24220. 'num',
  24221. 'num',
  24222. 'num',
  24223. 'num'
  24224. ],
  24225. [
  24226. 0.001,
  24227. 0,
  24228. 0,
  24229. 0.001,
  24230. 0,
  24231. 0
  24232. ]
  24233. ],
  24234. [
  24235. 13,
  24236. 'UniqueID',
  24237. 'num',
  24238. null
  24239. ],
  24240. [
  24241. 5,
  24242. 'FontBBox',
  24243. [
  24244. 'num',
  24245. 'num',
  24246. 'num',
  24247. 'num'
  24248. ],
  24249. [
  24250. 0,
  24251. 0,
  24252. 0,
  24253. 0
  24254. ]
  24255. ],
  24256. [
  24257. [
  24258. 12,
  24259. 8
  24260. ],
  24261. 'StrokeWidth',
  24262. 'num',
  24263. 0
  24264. ],
  24265. [
  24266. 14,
  24267. 'XUID',
  24268. 'array',
  24269. null
  24270. ],
  24271. [
  24272. 15,
  24273. 'charset',
  24274. 'offset',
  24275. 0
  24276. ],
  24277. [
  24278. 16,
  24279. 'Encoding',
  24280. 'offset',
  24281. 0
  24282. ],
  24283. [
  24284. 17,
  24285. 'CharStrings',
  24286. 'offset',
  24287. 0
  24288. ],
  24289. [
  24290. 18,
  24291. 'Private',
  24292. [
  24293. 'offset',
  24294. 'offset'
  24295. ],
  24296. null
  24297. ],
  24298. [
  24299. [
  24300. 12,
  24301. 21
  24302. ],
  24303. 'PostScript',
  24304. 'sid',
  24305. null
  24306. ],
  24307. [
  24308. [
  24309. 12,
  24310. 22
  24311. ],
  24312. 'BaseFontName',
  24313. 'sid',
  24314. null
  24315. ],
  24316. [
  24317. [
  24318. 12,
  24319. 23
  24320. ],
  24321. 'BaseFontBlend',
  24322. 'delta',
  24323. null
  24324. ],
  24325. [
  24326. [
  24327. 12,
  24328. 31
  24329. ],
  24330. 'CIDFontVersion',
  24331. 'num',
  24332. 0
  24333. ],
  24334. [
  24335. [
  24336. 12,
  24337. 32
  24338. ],
  24339. 'CIDFontRevision',
  24340. 'num',
  24341. 0
  24342. ],
  24343. [
  24344. [
  24345. 12,
  24346. 33
  24347. ],
  24348. 'CIDFontType',
  24349. 'num',
  24350. 0
  24351. ],
  24352. [
  24353. [
  24354. 12,
  24355. 34
  24356. ],
  24357. 'CIDCount',
  24358. 'num',
  24359. 8720
  24360. ],
  24361. [
  24362. [
  24363. 12,
  24364. 35
  24365. ],
  24366. 'UIDBase',
  24367. 'num',
  24368. null
  24369. ],
  24370. [
  24371. [
  24372. 12,
  24373. 37
  24374. ],
  24375. 'FDSelect',
  24376. 'offset',
  24377. null
  24378. ],
  24379. [
  24380. [
  24381. 12,
  24382. 36
  24383. ],
  24384. 'FDArray',
  24385. 'offset',
  24386. null
  24387. ],
  24388. [
  24389. [
  24390. 12,
  24391. 38
  24392. ],
  24393. 'FontName',
  24394. 'sid',
  24395. null
  24396. ]
  24397. ];
  24398. var tables = null;
  24399. function CFFTopDict(strings) {
  24400. if (tables === null) {
  24401. tables = CFFDict.createTables(layout);
  24402. }
  24403. CFFDict.call(this, tables, strings);
  24404. this.privateDict = null;
  24405. }
  24406. CFFTopDict.prototype = Object.create(CFFDict.prototype);
  24407. return CFFTopDict;
  24408. }();
  24409. var CFFPrivateDict = function CFFPrivateDictClosure() {
  24410. var layout = [
  24411. [
  24412. 6,
  24413. 'BlueValues',
  24414. 'delta',
  24415. null
  24416. ],
  24417. [
  24418. 7,
  24419. 'OtherBlues',
  24420. 'delta',
  24421. null
  24422. ],
  24423. [
  24424. 8,
  24425. 'FamilyBlues',
  24426. 'delta',
  24427. null
  24428. ],
  24429. [
  24430. 9,
  24431. 'FamilyOtherBlues',
  24432. 'delta',
  24433. null
  24434. ],
  24435. [
  24436. [
  24437. 12,
  24438. 9
  24439. ],
  24440. 'BlueScale',
  24441. 'num',
  24442. 0.039625
  24443. ],
  24444. [
  24445. [
  24446. 12,
  24447. 10
  24448. ],
  24449. 'BlueShift',
  24450. 'num',
  24451. 7
  24452. ],
  24453. [
  24454. [
  24455. 12,
  24456. 11
  24457. ],
  24458. 'BlueFuzz',
  24459. 'num',
  24460. 1
  24461. ],
  24462. [
  24463. 10,
  24464. 'StdHW',
  24465. 'num',
  24466. null
  24467. ],
  24468. [
  24469. 11,
  24470. 'StdVW',
  24471. 'num',
  24472. null
  24473. ],
  24474. [
  24475. [
  24476. 12,
  24477. 12
  24478. ],
  24479. 'StemSnapH',
  24480. 'delta',
  24481. null
  24482. ],
  24483. [
  24484. [
  24485. 12,
  24486. 13
  24487. ],
  24488. 'StemSnapV',
  24489. 'delta',
  24490. null
  24491. ],
  24492. [
  24493. [
  24494. 12,
  24495. 14
  24496. ],
  24497. 'ForceBold',
  24498. 'num',
  24499. 0
  24500. ],
  24501. [
  24502. [
  24503. 12,
  24504. 17
  24505. ],
  24506. 'LanguageGroup',
  24507. 'num',
  24508. 0
  24509. ],
  24510. [
  24511. [
  24512. 12,
  24513. 18
  24514. ],
  24515. 'ExpansionFactor',
  24516. 'num',
  24517. 0.06
  24518. ],
  24519. [
  24520. [
  24521. 12,
  24522. 19
  24523. ],
  24524. 'initialRandomSeed',
  24525. 'num',
  24526. 0
  24527. ],
  24528. [
  24529. 20,
  24530. 'defaultWidthX',
  24531. 'num',
  24532. 0
  24533. ],
  24534. [
  24535. 21,
  24536. 'nominalWidthX',
  24537. 'num',
  24538. 0
  24539. ],
  24540. [
  24541. 19,
  24542. 'Subrs',
  24543. 'offset',
  24544. null
  24545. ]
  24546. ];
  24547. var tables = null;
  24548. function CFFPrivateDict(strings) {
  24549. if (tables === null) {
  24550. tables = CFFDict.createTables(layout);
  24551. }
  24552. CFFDict.call(this, tables, strings);
  24553. this.subrsIndex = null;
  24554. }
  24555. CFFPrivateDict.prototype = Object.create(CFFDict.prototype);
  24556. return CFFPrivateDict;
  24557. }();
  24558. var CFFCharsetPredefinedTypes = {
  24559. ISO_ADOBE: 0,
  24560. EXPERT: 1,
  24561. EXPERT_SUBSET: 2
  24562. };
  24563. var CFFCharset = function CFFCharsetClosure() {
  24564. function CFFCharset(predefined, format, charset, raw) {
  24565. this.predefined = predefined;
  24566. this.format = format;
  24567. this.charset = charset;
  24568. this.raw = raw;
  24569. }
  24570. return CFFCharset;
  24571. }();
  24572. var CFFEncoding = function CFFEncodingClosure() {
  24573. function CFFEncoding(predefined, format, encoding, raw) {
  24574. this.predefined = predefined;
  24575. this.format = format;
  24576. this.encoding = encoding;
  24577. this.raw = raw;
  24578. }
  24579. return CFFEncoding;
  24580. }();
  24581. var CFFFDSelect = function CFFFDSelectClosure() {
  24582. function CFFFDSelect(fdSelect, raw) {
  24583. this.fdSelect = fdSelect;
  24584. this.raw = raw;
  24585. }
  24586. CFFFDSelect.prototype = {
  24587. getFDIndex: function CFFFDSelect_get(glyphIndex) {
  24588. if (glyphIndex < 0 || glyphIndex >= this.fdSelect.length) {
  24589. return -1;
  24590. }
  24591. return this.fdSelect[glyphIndex];
  24592. }
  24593. };
  24594. return CFFFDSelect;
  24595. }();
  24596. var CFFOffsetTracker = function CFFOffsetTrackerClosure() {
  24597. function CFFOffsetTracker() {
  24598. this.offsets = Object.create(null);
  24599. }
  24600. CFFOffsetTracker.prototype = {
  24601. isTracking: function CFFOffsetTracker_isTracking(key) {
  24602. return key in this.offsets;
  24603. },
  24604. track: function CFFOffsetTracker_track(key, location) {
  24605. if (key in this.offsets) {
  24606. error('Already tracking location of ' + key);
  24607. }
  24608. this.offsets[key] = location;
  24609. },
  24610. offset: function CFFOffsetTracker_offset(value) {
  24611. for (var key in this.offsets) {
  24612. this.offsets[key] += value;
  24613. }
  24614. },
  24615. setEntryLocation: function CFFOffsetTracker_setEntryLocation(key, values, output) {
  24616. if (!(key in this.offsets)) {
  24617. error('Not tracking location of ' + key);
  24618. }
  24619. var data = output.data;
  24620. var dataOffset = this.offsets[key];
  24621. var size = 5;
  24622. for (var i = 0, ii = values.length; i < ii; ++i) {
  24623. var offset0 = i * size + dataOffset;
  24624. var offset1 = offset0 + 1;
  24625. var offset2 = offset0 + 2;
  24626. var offset3 = offset0 + 3;
  24627. var offset4 = offset0 + 4;
  24628. if (data[offset0] !== 0x1d || data[offset1] !== 0 || data[offset2] !== 0 || data[offset3] !== 0 || data[offset4] !== 0) {
  24629. error('writing to an offset that is not empty');
  24630. }
  24631. var value = values[i];
  24632. data[offset0] = 0x1d;
  24633. data[offset1] = value >> 24 & 0xFF;
  24634. data[offset2] = value >> 16 & 0xFF;
  24635. data[offset3] = value >> 8 & 0xFF;
  24636. data[offset4] = value & 0xFF;
  24637. }
  24638. }
  24639. };
  24640. return CFFOffsetTracker;
  24641. }();
  24642. var CFFCompiler = function CFFCompilerClosure() {
  24643. function CFFCompiler(cff) {
  24644. this.cff = cff;
  24645. }
  24646. CFFCompiler.prototype = {
  24647. compile: function CFFCompiler_compile() {
  24648. var cff = this.cff;
  24649. var output = {
  24650. data: [],
  24651. length: 0,
  24652. add: function CFFCompiler_add(data) {
  24653. this.data = this.data.concat(data);
  24654. this.length = this.data.length;
  24655. }
  24656. };
  24657. var header = this.compileHeader(cff.header);
  24658. output.add(header);
  24659. var nameIndex = this.compileNameIndex(cff.names);
  24660. output.add(nameIndex);
  24661. if (cff.isCIDFont) {
  24662. if (cff.topDict.hasName('FontMatrix')) {
  24663. var base = cff.topDict.getByName('FontMatrix');
  24664. cff.topDict.removeByName('FontMatrix');
  24665. for (var i = 0, ii = cff.fdArray.length; i < ii; i++) {
  24666. var subDict = cff.fdArray[i];
  24667. var matrix = base.slice(0);
  24668. if (subDict.hasName('FontMatrix')) {
  24669. matrix = Util.transform(matrix, subDict.getByName('FontMatrix'));
  24670. }
  24671. subDict.setByName('FontMatrix', matrix);
  24672. }
  24673. }
  24674. }
  24675. var compiled = this.compileTopDicts([cff.topDict], output.length, cff.isCIDFont);
  24676. output.add(compiled.output);
  24677. var topDictTracker = compiled.trackers[0];
  24678. var stringIndex = this.compileStringIndex(cff.strings.strings);
  24679. output.add(stringIndex);
  24680. var globalSubrIndex = this.compileIndex(cff.globalSubrIndex);
  24681. output.add(globalSubrIndex);
  24682. if (cff.encoding && cff.topDict.hasName('Encoding')) {
  24683. if (cff.encoding.predefined) {
  24684. topDictTracker.setEntryLocation('Encoding', [cff.encoding.format], output);
  24685. } else {
  24686. var encoding = this.compileEncoding(cff.encoding);
  24687. topDictTracker.setEntryLocation('Encoding', [output.length], output);
  24688. output.add(encoding);
  24689. }
  24690. }
  24691. if (cff.charset && cff.topDict.hasName('charset')) {
  24692. if (cff.charset.predefined) {
  24693. topDictTracker.setEntryLocation('charset', [cff.charset.format], output);
  24694. } else {
  24695. var charset = this.compileCharset(cff.charset);
  24696. topDictTracker.setEntryLocation('charset', [output.length], output);
  24697. output.add(charset);
  24698. }
  24699. }
  24700. var charStrings = this.compileCharStrings(cff.charStrings);
  24701. topDictTracker.setEntryLocation('CharStrings', [output.length], output);
  24702. output.add(charStrings);
  24703. if (cff.isCIDFont) {
  24704. topDictTracker.setEntryLocation('FDSelect', [output.length], output);
  24705. var fdSelect = this.compileFDSelect(cff.fdSelect.raw);
  24706. output.add(fdSelect);
  24707. compiled = this.compileTopDicts(cff.fdArray, output.length, true);
  24708. topDictTracker.setEntryLocation('FDArray', [output.length], output);
  24709. output.add(compiled.output);
  24710. var fontDictTrackers = compiled.trackers;
  24711. this.compilePrivateDicts(cff.fdArray, fontDictTrackers, output);
  24712. }
  24713. this.compilePrivateDicts([cff.topDict], [topDictTracker], output);
  24714. output.add([0]);
  24715. return output.data;
  24716. },
  24717. encodeNumber: function CFFCompiler_encodeNumber(value) {
  24718. if (parseFloat(value) === parseInt(value, 10) && !isNaN(value)) {
  24719. return this.encodeInteger(value);
  24720. }
  24721. return this.encodeFloat(value);
  24722. },
  24723. encodeFloat: function CFFCompiler_encodeFloat(num) {
  24724. var value = num.toString();
  24725. var m = /\.(\d*?)(?:9{5,20}|0{5,20})\d{0,2}(?:e(.+)|$)/.exec(value);
  24726. if (m) {
  24727. var epsilon = parseFloat('1e' + ((m[2] ? +m[2] : 0) + m[1].length));
  24728. value = (Math.round(num * epsilon) / epsilon).toString();
  24729. }
  24730. var nibbles = '';
  24731. var i, ii;
  24732. for (i = 0, ii = value.length; i < ii; ++i) {
  24733. var a = value[i];
  24734. if (a === 'e') {
  24735. nibbles += value[++i] === '-' ? 'c' : 'b';
  24736. } else if (a === '.') {
  24737. nibbles += 'a';
  24738. } else if (a === '-') {
  24739. nibbles += 'e';
  24740. } else {
  24741. nibbles += a;
  24742. }
  24743. }
  24744. nibbles += nibbles.length & 1 ? 'f' : 'ff';
  24745. var out = [30];
  24746. for (i = 0, ii = nibbles.length; i < ii; i += 2) {
  24747. out.push(parseInt(nibbles.substr(i, 2), 16));
  24748. }
  24749. return out;
  24750. },
  24751. encodeInteger: function CFFCompiler_encodeInteger(value) {
  24752. var code;
  24753. if (value >= -107 && value <= 107) {
  24754. code = [value + 139];
  24755. } else if (value >= 108 && value <= 1131) {
  24756. value = value - 108;
  24757. code = [
  24758. (value >> 8) + 247,
  24759. value & 0xFF
  24760. ];
  24761. } else if (value >= -1131 && value <= -108) {
  24762. value = -value - 108;
  24763. code = [
  24764. (value >> 8) + 251,
  24765. value & 0xFF
  24766. ];
  24767. } else if (value >= -32768 && value <= 32767) {
  24768. code = [
  24769. 0x1c,
  24770. value >> 8 & 0xFF,
  24771. value & 0xFF
  24772. ];
  24773. } else {
  24774. code = [
  24775. 0x1d,
  24776. value >> 24 & 0xFF,
  24777. value >> 16 & 0xFF,
  24778. value >> 8 & 0xFF,
  24779. value & 0xFF
  24780. ];
  24781. }
  24782. return code;
  24783. },
  24784. compileHeader: function CFFCompiler_compileHeader(header) {
  24785. return [
  24786. header.major,
  24787. header.minor,
  24788. header.hdrSize,
  24789. header.offSize
  24790. ];
  24791. },
  24792. compileNameIndex: function CFFCompiler_compileNameIndex(names) {
  24793. var nameIndex = new CFFIndex();
  24794. for (var i = 0, ii = names.length; i < ii; ++i) {
  24795. nameIndex.add(stringToBytes(names[i]));
  24796. }
  24797. return this.compileIndex(nameIndex);
  24798. },
  24799. compileTopDicts: function CFFCompiler_compileTopDicts(dicts, length, removeCidKeys) {
  24800. var fontDictTrackers = [];
  24801. var fdArrayIndex = new CFFIndex();
  24802. for (var i = 0, ii = dicts.length; i < ii; ++i) {
  24803. var fontDict = dicts[i];
  24804. if (removeCidKeys) {
  24805. fontDict.removeByName('CIDFontVersion');
  24806. fontDict.removeByName('CIDFontRevision');
  24807. fontDict.removeByName('CIDFontType');
  24808. fontDict.removeByName('CIDCount');
  24809. fontDict.removeByName('UIDBase');
  24810. }
  24811. var fontDictTracker = new CFFOffsetTracker();
  24812. var fontDictData = this.compileDict(fontDict, fontDictTracker);
  24813. fontDictTrackers.push(fontDictTracker);
  24814. fdArrayIndex.add(fontDictData);
  24815. fontDictTracker.offset(length);
  24816. }
  24817. fdArrayIndex = this.compileIndex(fdArrayIndex, fontDictTrackers);
  24818. return {
  24819. trackers: fontDictTrackers,
  24820. output: fdArrayIndex
  24821. };
  24822. },
  24823. compilePrivateDicts: function CFFCompiler_compilePrivateDicts(dicts, trackers, output) {
  24824. for (var i = 0, ii = dicts.length; i < ii; ++i) {
  24825. var fontDict = dicts[i];
  24826. assert(fontDict.privateDict && fontDict.hasName('Private'), 'There must be an private dictionary.');
  24827. var privateDict = fontDict.privateDict;
  24828. var privateDictTracker = new CFFOffsetTracker();
  24829. var privateDictData = this.compileDict(privateDict, privateDictTracker);
  24830. var outputLength = output.length;
  24831. privateDictTracker.offset(outputLength);
  24832. if (!privateDictData.length) {
  24833. outputLength = 0;
  24834. }
  24835. trackers[i].setEntryLocation('Private', [
  24836. privateDictData.length,
  24837. outputLength
  24838. ], output);
  24839. output.add(privateDictData);
  24840. if (privateDict.subrsIndex && privateDict.hasName('Subrs')) {
  24841. var subrs = this.compileIndex(privateDict.subrsIndex);
  24842. privateDictTracker.setEntryLocation('Subrs', [privateDictData.length], output);
  24843. output.add(subrs);
  24844. }
  24845. }
  24846. },
  24847. compileDict: function CFFCompiler_compileDict(dict, offsetTracker) {
  24848. var out = [];
  24849. var order = dict.order;
  24850. for (var i = 0; i < order.length; ++i) {
  24851. var key = order[i];
  24852. if (!(key in dict.values)) {
  24853. continue;
  24854. }
  24855. var values = dict.values[key];
  24856. var types = dict.types[key];
  24857. if (!isArray(types)) {
  24858. types = [types];
  24859. }
  24860. if (!isArray(values)) {
  24861. values = [values];
  24862. }
  24863. if (values.length === 0) {
  24864. continue;
  24865. }
  24866. for (var j = 0, jj = types.length; j < jj; ++j) {
  24867. var type = types[j];
  24868. var value = values[j];
  24869. switch (type) {
  24870. case 'num':
  24871. case 'sid':
  24872. out = out.concat(this.encodeNumber(value));
  24873. break;
  24874. case 'offset':
  24875. var name = dict.keyToNameMap[key];
  24876. if (!offsetTracker.isTracking(name)) {
  24877. offsetTracker.track(name, out.length);
  24878. }
  24879. out = out.concat([
  24880. 0x1d,
  24881. 0,
  24882. 0,
  24883. 0,
  24884. 0
  24885. ]);
  24886. break;
  24887. case 'array':
  24888. case 'delta':
  24889. out = out.concat(this.encodeNumber(value));
  24890. for (var k = 1, kk = values.length; k < kk; ++k) {
  24891. out = out.concat(this.encodeNumber(values[k]));
  24892. }
  24893. break;
  24894. default:
  24895. error('Unknown data type of ' + type);
  24896. break;
  24897. }
  24898. }
  24899. out = out.concat(dict.opcodes[key]);
  24900. }
  24901. return out;
  24902. },
  24903. compileStringIndex: function CFFCompiler_compileStringIndex(strings) {
  24904. var stringIndex = new CFFIndex();
  24905. for (var i = 0, ii = strings.length; i < ii; ++i) {
  24906. stringIndex.add(stringToBytes(strings[i]));
  24907. }
  24908. return this.compileIndex(stringIndex);
  24909. },
  24910. compileGlobalSubrIndex: function CFFCompiler_compileGlobalSubrIndex() {
  24911. var globalSubrIndex = this.cff.globalSubrIndex;
  24912. this.out.writeByteArray(this.compileIndex(globalSubrIndex));
  24913. },
  24914. compileCharStrings: function CFFCompiler_compileCharStrings(charStrings) {
  24915. return this.compileIndex(charStrings);
  24916. },
  24917. compileCharset: function CFFCompiler_compileCharset(charset) {
  24918. return this.compileTypedArray(charset.raw);
  24919. },
  24920. compileEncoding: function CFFCompiler_compileEncoding(encoding) {
  24921. return this.compileTypedArray(encoding.raw);
  24922. },
  24923. compileFDSelect: function CFFCompiler_compileFDSelect(fdSelect) {
  24924. return this.compileTypedArray(fdSelect);
  24925. },
  24926. compileTypedArray: function CFFCompiler_compileTypedArray(data) {
  24927. var out = [];
  24928. for (var i = 0, ii = data.length; i < ii; ++i) {
  24929. out[i] = data[i];
  24930. }
  24931. return out;
  24932. },
  24933. compileIndex: function CFFCompiler_compileIndex(index, trackers) {
  24934. trackers = trackers || [];
  24935. var objects = index.objects;
  24936. var count = objects.length;
  24937. if (count === 0) {
  24938. return [
  24939. 0,
  24940. 0,
  24941. 0
  24942. ];
  24943. }
  24944. var data = [
  24945. count >> 8 & 0xFF,
  24946. count & 0xff
  24947. ];
  24948. var lastOffset = 1, i;
  24949. for (i = 0; i < count; ++i) {
  24950. lastOffset += objects[i].length;
  24951. }
  24952. var offsetSize;
  24953. if (lastOffset < 0x100) {
  24954. offsetSize = 1;
  24955. } else if (lastOffset < 0x10000) {
  24956. offsetSize = 2;
  24957. } else if (lastOffset < 0x1000000) {
  24958. offsetSize = 3;
  24959. } else {
  24960. offsetSize = 4;
  24961. }
  24962. data.push(offsetSize);
  24963. var relativeOffset = 1;
  24964. for (i = 0; i < count + 1; i++) {
  24965. if (offsetSize === 1) {
  24966. data.push(relativeOffset & 0xFF);
  24967. } else if (offsetSize === 2) {
  24968. data.push(relativeOffset >> 8 & 0xFF, relativeOffset & 0xFF);
  24969. } else if (offsetSize === 3) {
  24970. data.push(relativeOffset >> 16 & 0xFF, relativeOffset >> 8 & 0xFF, relativeOffset & 0xFF);
  24971. } else {
  24972. data.push(relativeOffset >>> 24 & 0xFF, relativeOffset >> 16 & 0xFF, relativeOffset >> 8 & 0xFF, relativeOffset & 0xFF);
  24973. }
  24974. if (objects[i]) {
  24975. relativeOffset += objects[i].length;
  24976. }
  24977. }
  24978. for (i = 0; i < count; i++) {
  24979. if (trackers[i]) {
  24980. trackers[i].offset(data.length);
  24981. }
  24982. for (var j = 0, jj = objects[i].length; j < jj; j++) {
  24983. data.push(objects[i][j]);
  24984. }
  24985. }
  24986. return data;
  24987. }
  24988. };
  24989. return CFFCompiler;
  24990. }();
  24991. exports.CFFStandardStrings = CFFStandardStrings;
  24992. exports.CFFParser = CFFParser;
  24993. exports.CFF = CFF;
  24994. exports.CFFHeader = CFFHeader;
  24995. exports.CFFStrings = CFFStrings;
  24996. exports.CFFIndex = CFFIndex;
  24997. exports.CFFCharset = CFFCharset;
  24998. exports.CFFTopDict = CFFTopDict;
  24999. exports.CFFPrivateDict = CFFPrivateDict;
  25000. exports.CFFCompiler = CFFCompiler;
  25001. /***/ }),
  25002. /* 15 */
  25003. /***/ (function(module, exports, __w_pdfjs_require__) {
  25004. "use strict";
  25005. var sharedUtil = __w_pdfjs_require__(0);
  25006. var MissingDataException = sharedUtil.MissingDataException;
  25007. var arrayByteLength = sharedUtil.arrayByteLength;
  25008. var arraysToBytes = sharedUtil.arraysToBytes;
  25009. var assert = sharedUtil.assert;
  25010. var createPromiseCapability = sharedUtil.createPromiseCapability;
  25011. var isInt = sharedUtil.isInt;
  25012. var isEmptyObj = sharedUtil.isEmptyObj;
  25013. var ChunkedStream = function ChunkedStreamClosure() {
  25014. function ChunkedStream(length, chunkSize, manager) {
  25015. this.bytes = new Uint8Array(length);
  25016. this.start = 0;
  25017. this.pos = 0;
  25018. this.end = length;
  25019. this.chunkSize = chunkSize;
  25020. this.loadedChunks = [];
  25021. this.numChunksLoaded = 0;
  25022. this.numChunks = Math.ceil(length / chunkSize);
  25023. this.manager = manager;
  25024. this.progressiveDataLength = 0;
  25025. this.lastSuccessfulEnsureByteChunk = -1;
  25026. }
  25027. ChunkedStream.prototype = {
  25028. getMissingChunks: function ChunkedStream_getMissingChunks() {
  25029. var chunks = [];
  25030. for (var chunk = 0, n = this.numChunks; chunk < n; ++chunk) {
  25031. if (!this.loadedChunks[chunk]) {
  25032. chunks.push(chunk);
  25033. }
  25034. }
  25035. return chunks;
  25036. },
  25037. getBaseStreams: function ChunkedStream_getBaseStreams() {
  25038. return [this];
  25039. },
  25040. allChunksLoaded: function ChunkedStream_allChunksLoaded() {
  25041. return this.numChunksLoaded === this.numChunks;
  25042. },
  25043. onReceiveData: function ChunkedStream_onReceiveData(begin, chunk) {
  25044. var end = begin + chunk.byteLength;
  25045. assert(begin % this.chunkSize === 0, 'Bad begin offset: ' + begin);
  25046. var length = this.bytes.length;
  25047. assert(end % this.chunkSize === 0 || end === length, 'Bad end offset: ' + end);
  25048. this.bytes.set(new Uint8Array(chunk), begin);
  25049. var chunkSize = this.chunkSize;
  25050. var beginChunk = Math.floor(begin / chunkSize);
  25051. var endChunk = Math.floor((end - 1) / chunkSize) + 1;
  25052. var curChunk;
  25053. for (curChunk = beginChunk; curChunk < endChunk; ++curChunk) {
  25054. if (!this.loadedChunks[curChunk]) {
  25055. this.loadedChunks[curChunk] = true;
  25056. ++this.numChunksLoaded;
  25057. }
  25058. }
  25059. },
  25060. onReceiveProgressiveData: function ChunkedStream_onReceiveProgressiveData(data) {
  25061. var position = this.progressiveDataLength;
  25062. var beginChunk = Math.floor(position / this.chunkSize);
  25063. this.bytes.set(new Uint8Array(data), position);
  25064. position += data.byteLength;
  25065. this.progressiveDataLength = position;
  25066. var endChunk = position >= this.end ? this.numChunks : Math.floor(position / this.chunkSize);
  25067. var curChunk;
  25068. for (curChunk = beginChunk; curChunk < endChunk; ++curChunk) {
  25069. if (!this.loadedChunks[curChunk]) {
  25070. this.loadedChunks[curChunk] = true;
  25071. ++this.numChunksLoaded;
  25072. }
  25073. }
  25074. },
  25075. ensureByte: function ChunkedStream_ensureByte(pos) {
  25076. var chunk = Math.floor(pos / this.chunkSize);
  25077. if (chunk === this.lastSuccessfulEnsureByteChunk) {
  25078. return;
  25079. }
  25080. if (!this.loadedChunks[chunk]) {
  25081. throw new MissingDataException(pos, pos + 1);
  25082. }
  25083. this.lastSuccessfulEnsureByteChunk = chunk;
  25084. },
  25085. ensureRange: function ChunkedStream_ensureRange(begin, end) {
  25086. if (begin >= end) {
  25087. return;
  25088. }
  25089. if (end <= this.progressiveDataLength) {
  25090. return;
  25091. }
  25092. var chunkSize = this.chunkSize;
  25093. var beginChunk = Math.floor(begin / chunkSize);
  25094. var endChunk = Math.floor((end - 1) / chunkSize) + 1;
  25095. for (var chunk = beginChunk; chunk < endChunk; ++chunk) {
  25096. if (!this.loadedChunks[chunk]) {
  25097. throw new MissingDataException(begin, end);
  25098. }
  25099. }
  25100. },
  25101. nextEmptyChunk: function ChunkedStream_nextEmptyChunk(beginChunk) {
  25102. var chunk, numChunks = this.numChunks;
  25103. for (var i = 0; i < numChunks; ++i) {
  25104. chunk = (beginChunk + i) % numChunks;
  25105. if (!this.loadedChunks[chunk]) {
  25106. return chunk;
  25107. }
  25108. }
  25109. return null;
  25110. },
  25111. hasChunk: function ChunkedStream_hasChunk(chunk) {
  25112. return !!this.loadedChunks[chunk];
  25113. },
  25114. get length() {
  25115. return this.end - this.start;
  25116. },
  25117. get isEmpty() {
  25118. return this.length === 0;
  25119. },
  25120. getByte: function ChunkedStream_getByte() {
  25121. var pos = this.pos;
  25122. if (pos >= this.end) {
  25123. return -1;
  25124. }
  25125. this.ensureByte(pos);
  25126. return this.bytes[this.pos++];
  25127. },
  25128. getUint16: function ChunkedStream_getUint16() {
  25129. var b0 = this.getByte();
  25130. var b1 = this.getByte();
  25131. if (b0 === -1 || b1 === -1) {
  25132. return -1;
  25133. }
  25134. return (b0 << 8) + b1;
  25135. },
  25136. getInt32: function ChunkedStream_getInt32() {
  25137. var b0 = this.getByte();
  25138. var b1 = this.getByte();
  25139. var b2 = this.getByte();
  25140. var b3 = this.getByte();
  25141. return (b0 << 24) + (b1 << 16) + (b2 << 8) + b3;
  25142. },
  25143. getBytes: function ChunkedStream_getBytes(length) {
  25144. var bytes = this.bytes;
  25145. var pos = this.pos;
  25146. var strEnd = this.end;
  25147. if (!length) {
  25148. this.ensureRange(pos, strEnd);
  25149. return bytes.subarray(pos, strEnd);
  25150. }
  25151. var end = pos + length;
  25152. if (end > strEnd) {
  25153. end = strEnd;
  25154. }
  25155. this.ensureRange(pos, end);
  25156. this.pos = end;
  25157. return bytes.subarray(pos, end);
  25158. },
  25159. peekByte: function ChunkedStream_peekByte() {
  25160. var peekedByte = this.getByte();
  25161. this.pos--;
  25162. return peekedByte;
  25163. },
  25164. peekBytes: function ChunkedStream_peekBytes(length) {
  25165. var bytes = this.getBytes(length);
  25166. this.pos -= bytes.length;
  25167. return bytes;
  25168. },
  25169. getByteRange: function ChunkedStream_getBytes(begin, end) {
  25170. this.ensureRange(begin, end);
  25171. return this.bytes.subarray(begin, end);
  25172. },
  25173. skip: function ChunkedStream_skip(n) {
  25174. if (!n) {
  25175. n = 1;
  25176. }
  25177. this.pos += n;
  25178. },
  25179. reset: function ChunkedStream_reset() {
  25180. this.pos = this.start;
  25181. },
  25182. moveStart: function ChunkedStream_moveStart() {
  25183. this.start = this.pos;
  25184. },
  25185. makeSubStream: function ChunkedStream_makeSubStream(start, length, dict) {
  25186. this.ensureRange(start, start + length);
  25187. function ChunkedStreamSubstream() {
  25188. }
  25189. ChunkedStreamSubstream.prototype = Object.create(this);
  25190. ChunkedStreamSubstream.prototype.getMissingChunks = function () {
  25191. var chunkSize = this.chunkSize;
  25192. var beginChunk = Math.floor(this.start / chunkSize);
  25193. var endChunk = Math.floor((this.end - 1) / chunkSize) + 1;
  25194. var missingChunks = [];
  25195. for (var chunk = beginChunk; chunk < endChunk; ++chunk) {
  25196. if (!this.loadedChunks[chunk]) {
  25197. missingChunks.push(chunk);
  25198. }
  25199. }
  25200. return missingChunks;
  25201. };
  25202. var subStream = new ChunkedStreamSubstream();
  25203. subStream.pos = subStream.start = start;
  25204. subStream.end = start + length || this.end;
  25205. subStream.dict = dict;
  25206. return subStream;
  25207. }
  25208. };
  25209. return ChunkedStream;
  25210. }();
  25211. var ChunkedStreamManager = function ChunkedStreamManagerClosure() {
  25212. function ChunkedStreamManager(pdfNetworkStream, args) {
  25213. var chunkSize = args.rangeChunkSize;
  25214. var length = args.length;
  25215. this.stream = new ChunkedStream(length, chunkSize, this);
  25216. this.length = length;
  25217. this.chunkSize = chunkSize;
  25218. this.pdfNetworkStream = pdfNetworkStream;
  25219. this.url = args.url;
  25220. this.disableAutoFetch = args.disableAutoFetch;
  25221. this.msgHandler = args.msgHandler;
  25222. this.currRequestId = 0;
  25223. this.chunksNeededByRequest = Object.create(null);
  25224. this.requestsByChunk = Object.create(null);
  25225. this.promisesByRequest = Object.create(null);
  25226. this.progressiveDataLength = 0;
  25227. this.aborted = false;
  25228. this._loadedStreamCapability = createPromiseCapability();
  25229. }
  25230. ChunkedStreamManager.prototype = {
  25231. onLoadedStream: function ChunkedStreamManager_getLoadedStream() {
  25232. return this._loadedStreamCapability.promise;
  25233. },
  25234. sendRequest: function ChunkedStreamManager_sendRequest(begin, end) {
  25235. var rangeReader = this.pdfNetworkStream.getRangeReader(begin, end);
  25236. if (!rangeReader.isStreamingSupported) {
  25237. rangeReader.onProgress = this.onProgress.bind(this);
  25238. }
  25239. var chunks = [], loaded = 0;
  25240. var manager = this;
  25241. var promise = new Promise(function (resolve, reject) {
  25242. var readChunk = function (chunk) {
  25243. try {
  25244. if (!chunk.done) {
  25245. var data = chunk.value;
  25246. chunks.push(data);
  25247. loaded += arrayByteLength(data);
  25248. if (rangeReader.isStreamingSupported) {
  25249. manager.onProgress({ loaded: loaded });
  25250. }
  25251. rangeReader.read().then(readChunk, reject);
  25252. return;
  25253. }
  25254. var chunkData = arraysToBytes(chunks);
  25255. chunks = null;
  25256. resolve(chunkData);
  25257. } catch (e) {
  25258. reject(e);
  25259. }
  25260. };
  25261. rangeReader.read().then(readChunk, reject);
  25262. });
  25263. promise.then(function (data) {
  25264. if (this.aborted) {
  25265. return;
  25266. }
  25267. this.onReceiveData({
  25268. chunk: data,
  25269. begin: begin
  25270. });
  25271. }.bind(this));
  25272. },
  25273. requestAllChunks: function ChunkedStreamManager_requestAllChunks() {
  25274. var missingChunks = this.stream.getMissingChunks();
  25275. this._requestChunks(missingChunks);
  25276. return this._loadedStreamCapability.promise;
  25277. },
  25278. _requestChunks: function ChunkedStreamManager_requestChunks(chunks) {
  25279. var requestId = this.currRequestId++;
  25280. var i, ii;
  25281. var chunksNeeded = Object.create(null);
  25282. this.chunksNeededByRequest[requestId] = chunksNeeded;
  25283. for (i = 0, ii = chunks.length; i < ii; i++) {
  25284. if (!this.stream.hasChunk(chunks[i])) {
  25285. chunksNeeded[chunks[i]] = true;
  25286. }
  25287. }
  25288. if (isEmptyObj(chunksNeeded)) {
  25289. return Promise.resolve();
  25290. }
  25291. var capability = createPromiseCapability();
  25292. this.promisesByRequest[requestId] = capability;
  25293. var chunksToRequest = [];
  25294. for (var chunk in chunksNeeded) {
  25295. chunk = chunk | 0;
  25296. if (!(chunk in this.requestsByChunk)) {
  25297. this.requestsByChunk[chunk] = [];
  25298. chunksToRequest.push(chunk);
  25299. }
  25300. this.requestsByChunk[chunk].push(requestId);
  25301. }
  25302. if (!chunksToRequest.length) {
  25303. return capability.promise;
  25304. }
  25305. var groupedChunksToRequest = this.groupChunks(chunksToRequest);
  25306. for (i = 0; i < groupedChunksToRequest.length; ++i) {
  25307. var groupedChunk = groupedChunksToRequest[i];
  25308. var begin = groupedChunk.beginChunk * this.chunkSize;
  25309. var end = Math.min(groupedChunk.endChunk * this.chunkSize, this.length);
  25310. this.sendRequest(begin, end);
  25311. }
  25312. return capability.promise;
  25313. },
  25314. getStream: function ChunkedStreamManager_getStream() {
  25315. return this.stream;
  25316. },
  25317. requestRange: function ChunkedStreamManager_requestRange(begin, end) {
  25318. end = Math.min(end, this.length);
  25319. var beginChunk = this.getBeginChunk(begin);
  25320. var endChunk = this.getEndChunk(end);
  25321. var chunks = [];
  25322. for (var chunk = beginChunk; chunk < endChunk; ++chunk) {
  25323. chunks.push(chunk);
  25324. }
  25325. return this._requestChunks(chunks);
  25326. },
  25327. requestRanges: function ChunkedStreamManager_requestRanges(ranges) {
  25328. ranges = ranges || [];
  25329. var chunksToRequest = [];
  25330. for (var i = 0; i < ranges.length; i++) {
  25331. var beginChunk = this.getBeginChunk(ranges[i].begin);
  25332. var endChunk = this.getEndChunk(ranges[i].end);
  25333. for (var chunk = beginChunk; chunk < endChunk; ++chunk) {
  25334. if (chunksToRequest.indexOf(chunk) < 0) {
  25335. chunksToRequest.push(chunk);
  25336. }
  25337. }
  25338. }
  25339. chunksToRequest.sort(function (a, b) {
  25340. return a - b;
  25341. });
  25342. return this._requestChunks(chunksToRequest);
  25343. },
  25344. groupChunks: function ChunkedStreamManager_groupChunks(chunks) {
  25345. var groupedChunks = [];
  25346. var beginChunk = -1;
  25347. var prevChunk = -1;
  25348. for (var i = 0; i < chunks.length; ++i) {
  25349. var chunk = chunks[i];
  25350. if (beginChunk < 0) {
  25351. beginChunk = chunk;
  25352. }
  25353. if (prevChunk >= 0 && prevChunk + 1 !== chunk) {
  25354. groupedChunks.push({
  25355. beginChunk: beginChunk,
  25356. endChunk: prevChunk + 1
  25357. });
  25358. beginChunk = chunk;
  25359. }
  25360. if (i + 1 === chunks.length) {
  25361. groupedChunks.push({
  25362. beginChunk: beginChunk,
  25363. endChunk: chunk + 1
  25364. });
  25365. }
  25366. prevChunk = chunk;
  25367. }
  25368. return groupedChunks;
  25369. },
  25370. onProgress: function ChunkedStreamManager_onProgress(args) {
  25371. var bytesLoaded = this.stream.numChunksLoaded * this.chunkSize + args.loaded;
  25372. this.msgHandler.send('DocProgress', {
  25373. loaded: bytesLoaded,
  25374. total: this.length
  25375. });
  25376. },
  25377. onReceiveData: function ChunkedStreamManager_onReceiveData(args) {
  25378. var chunk = args.chunk;
  25379. var isProgressive = args.begin === undefined;
  25380. var begin = isProgressive ? this.progressiveDataLength : args.begin;
  25381. var end = begin + chunk.byteLength;
  25382. var beginChunk = Math.floor(begin / this.chunkSize);
  25383. var endChunk = end < this.length ? Math.floor(end / this.chunkSize) : Math.ceil(end / this.chunkSize);
  25384. if (isProgressive) {
  25385. this.stream.onReceiveProgressiveData(chunk);
  25386. this.progressiveDataLength = end;
  25387. } else {
  25388. this.stream.onReceiveData(begin, chunk);
  25389. }
  25390. if (this.stream.allChunksLoaded()) {
  25391. this._loadedStreamCapability.resolve(this.stream);
  25392. }
  25393. var loadedRequests = [];
  25394. var i, requestId;
  25395. for (chunk = beginChunk; chunk < endChunk; ++chunk) {
  25396. var requestIds = this.requestsByChunk[chunk] || [];
  25397. delete this.requestsByChunk[chunk];
  25398. for (i = 0; i < requestIds.length; ++i) {
  25399. requestId = requestIds[i];
  25400. var chunksNeeded = this.chunksNeededByRequest[requestId];
  25401. if (chunk in chunksNeeded) {
  25402. delete chunksNeeded[chunk];
  25403. }
  25404. if (!isEmptyObj(chunksNeeded)) {
  25405. continue;
  25406. }
  25407. loadedRequests.push(requestId);
  25408. }
  25409. }
  25410. if (!this.disableAutoFetch && isEmptyObj(this.requestsByChunk)) {
  25411. var nextEmptyChunk;
  25412. if (this.stream.numChunksLoaded === 1) {
  25413. var lastChunk = this.stream.numChunks - 1;
  25414. if (!this.stream.hasChunk(lastChunk)) {
  25415. nextEmptyChunk = lastChunk;
  25416. }
  25417. } else {
  25418. nextEmptyChunk = this.stream.nextEmptyChunk(endChunk);
  25419. }
  25420. if (isInt(nextEmptyChunk)) {
  25421. this._requestChunks([nextEmptyChunk]);
  25422. }
  25423. }
  25424. for (i = 0; i < loadedRequests.length; ++i) {
  25425. requestId = loadedRequests[i];
  25426. var capability = this.promisesByRequest[requestId];
  25427. delete this.promisesByRequest[requestId];
  25428. capability.resolve();
  25429. }
  25430. this.msgHandler.send('DocProgress', {
  25431. loaded: this.stream.numChunksLoaded * this.chunkSize,
  25432. total: this.length
  25433. });
  25434. },
  25435. onError: function ChunkedStreamManager_onError(err) {
  25436. this._loadedStreamCapability.reject(err);
  25437. },
  25438. getBeginChunk: function ChunkedStreamManager_getBeginChunk(begin) {
  25439. var chunk = Math.floor(begin / this.chunkSize);
  25440. return chunk;
  25441. },
  25442. getEndChunk: function ChunkedStreamManager_getEndChunk(end) {
  25443. var chunk = Math.floor((end - 1) / this.chunkSize) + 1;
  25444. return chunk;
  25445. },
  25446. abort: function ChunkedStreamManager_abort() {
  25447. this.aborted = true;
  25448. if (this.pdfNetworkStream) {
  25449. this.pdfNetworkStream.cancelAllRequests('abort');
  25450. }
  25451. for (var requestId in this.promisesByRequest) {
  25452. var capability = this.promisesByRequest[requestId];
  25453. capability.reject(new Error('Request was aborted'));
  25454. }
  25455. }
  25456. };
  25457. return ChunkedStreamManager;
  25458. }();
  25459. exports.ChunkedStream = ChunkedStream;
  25460. exports.ChunkedStreamManager = ChunkedStreamManager;
  25461. /***/ }),
  25462. /* 16 */
  25463. /***/ (function(module, exports, __w_pdfjs_require__) {
  25464. "use strict";
  25465. var sharedUtil = __w_pdfjs_require__(0);
  25466. var corePrimitives = __w_pdfjs_require__(1);
  25467. var coreStream = __w_pdfjs_require__(2);
  25468. var PasswordException = sharedUtil.PasswordException;
  25469. var PasswordResponses = sharedUtil.PasswordResponses;
  25470. var bytesToString = sharedUtil.bytesToString;
  25471. var warn = sharedUtil.warn;
  25472. var error = sharedUtil.error;
  25473. var assert = sharedUtil.assert;
  25474. var isInt = sharedUtil.isInt;
  25475. var stringToBytes = sharedUtil.stringToBytes;
  25476. var utf8StringToString = sharedUtil.utf8StringToString;
  25477. var Name = corePrimitives.Name;
  25478. var isName = corePrimitives.isName;
  25479. var isDict = corePrimitives.isDict;
  25480. var DecryptStream = coreStream.DecryptStream;
  25481. var ARCFourCipher = function ARCFourCipherClosure() {
  25482. function ARCFourCipher(key) {
  25483. this.a = 0;
  25484. this.b = 0;
  25485. var s = new Uint8Array(256);
  25486. var i, j = 0, tmp, keyLength = key.length;
  25487. for (i = 0; i < 256; ++i) {
  25488. s[i] = i;
  25489. }
  25490. for (i = 0; i < 256; ++i) {
  25491. tmp = s[i];
  25492. j = j + tmp + key[i % keyLength] & 0xFF;
  25493. s[i] = s[j];
  25494. s[j] = tmp;
  25495. }
  25496. this.s = s;
  25497. }
  25498. ARCFourCipher.prototype = {
  25499. encryptBlock: function ARCFourCipher_encryptBlock(data) {
  25500. var i, n = data.length, tmp, tmp2;
  25501. var a = this.a, b = this.b, s = this.s;
  25502. var output = new Uint8Array(n);
  25503. for (i = 0; i < n; ++i) {
  25504. a = a + 1 & 0xFF;
  25505. tmp = s[a];
  25506. b = b + tmp & 0xFF;
  25507. tmp2 = s[b];
  25508. s[a] = tmp2;
  25509. s[b] = tmp;
  25510. output[i] = data[i] ^ s[tmp + tmp2 & 0xFF];
  25511. }
  25512. this.a = a;
  25513. this.b = b;
  25514. return output;
  25515. }
  25516. };
  25517. ARCFourCipher.prototype.decryptBlock = ARCFourCipher.prototype.encryptBlock;
  25518. return ARCFourCipher;
  25519. }();
  25520. var calculateMD5 = function calculateMD5Closure() {
  25521. var r = new Uint8Array([
  25522. 7,
  25523. 12,
  25524. 17,
  25525. 22,
  25526. 7,
  25527. 12,
  25528. 17,
  25529. 22,
  25530. 7,
  25531. 12,
  25532. 17,
  25533. 22,
  25534. 7,
  25535. 12,
  25536. 17,
  25537. 22,
  25538. 5,
  25539. 9,
  25540. 14,
  25541. 20,
  25542. 5,
  25543. 9,
  25544. 14,
  25545. 20,
  25546. 5,
  25547. 9,
  25548. 14,
  25549. 20,
  25550. 5,
  25551. 9,
  25552. 14,
  25553. 20,
  25554. 4,
  25555. 11,
  25556. 16,
  25557. 23,
  25558. 4,
  25559. 11,
  25560. 16,
  25561. 23,
  25562. 4,
  25563. 11,
  25564. 16,
  25565. 23,
  25566. 4,
  25567. 11,
  25568. 16,
  25569. 23,
  25570. 6,
  25571. 10,
  25572. 15,
  25573. 21,
  25574. 6,
  25575. 10,
  25576. 15,
  25577. 21,
  25578. 6,
  25579. 10,
  25580. 15,
  25581. 21,
  25582. 6,
  25583. 10,
  25584. 15,
  25585. 21
  25586. ]);
  25587. var k = new Int32Array([
  25588. -680876936,
  25589. -389564586,
  25590. 606105819,
  25591. -1044525330,
  25592. -176418897,
  25593. 1200080426,
  25594. -1473231341,
  25595. -45705983,
  25596. 1770035416,
  25597. -1958414417,
  25598. -42063,
  25599. -1990404162,
  25600. 1804603682,
  25601. -40341101,
  25602. -1502002290,
  25603. 1236535329,
  25604. -165796510,
  25605. -1069501632,
  25606. 643717713,
  25607. -373897302,
  25608. -701558691,
  25609. 38016083,
  25610. -660478335,
  25611. -405537848,
  25612. 568446438,
  25613. -1019803690,
  25614. -187363961,
  25615. 1163531501,
  25616. -1444681467,
  25617. -51403784,
  25618. 1735328473,
  25619. -1926607734,
  25620. -378558,
  25621. -2022574463,
  25622. 1839030562,
  25623. -35309556,
  25624. -1530992060,
  25625. 1272893353,
  25626. -155497632,
  25627. -1094730640,
  25628. 681279174,
  25629. -358537222,
  25630. -722521979,
  25631. 76029189,
  25632. -640364487,
  25633. -421815835,
  25634. 530742520,
  25635. -995338651,
  25636. -198630844,
  25637. 1126891415,
  25638. -1416354905,
  25639. -57434055,
  25640. 1700485571,
  25641. -1894986606,
  25642. -1051523,
  25643. -2054922799,
  25644. 1873313359,
  25645. -30611744,
  25646. -1560198380,
  25647. 1309151649,
  25648. -145523070,
  25649. -1120210379,
  25650. 718787259,
  25651. -343485551
  25652. ]);
  25653. function hash(data, offset, length) {
  25654. var h0 = 1732584193, h1 = -271733879, h2 = -1732584194, h3 = 271733878;
  25655. var paddedLength = length + 72 & ~63;
  25656. var padded = new Uint8Array(paddedLength);
  25657. var i, j, n;
  25658. for (i = 0; i < length; ++i) {
  25659. padded[i] = data[offset++];
  25660. }
  25661. padded[i++] = 0x80;
  25662. n = paddedLength - 8;
  25663. while (i < n) {
  25664. padded[i++] = 0;
  25665. }
  25666. padded[i++] = length << 3 & 0xFF;
  25667. padded[i++] = length >> 5 & 0xFF;
  25668. padded[i++] = length >> 13 & 0xFF;
  25669. padded[i++] = length >> 21 & 0xFF;
  25670. padded[i++] = length >>> 29 & 0xFF;
  25671. padded[i++] = 0;
  25672. padded[i++] = 0;
  25673. padded[i++] = 0;
  25674. var w = new Int32Array(16);
  25675. for (i = 0; i < paddedLength;) {
  25676. for (j = 0; j < 16; ++j, i += 4) {
  25677. w[j] = padded[i] | padded[i + 1] << 8 | padded[i + 2] << 16 | padded[i + 3] << 24;
  25678. }
  25679. var a = h0, b = h1, c = h2, d = h3, f, g;
  25680. for (j = 0; j < 64; ++j) {
  25681. if (j < 16) {
  25682. f = b & c | ~b & d;
  25683. g = j;
  25684. } else if (j < 32) {
  25685. f = d & b | ~d & c;
  25686. g = 5 * j + 1 & 15;
  25687. } else if (j < 48) {
  25688. f = b ^ c ^ d;
  25689. g = 3 * j + 5 & 15;
  25690. } else {
  25691. f = c ^ (b | ~d);
  25692. g = 7 * j & 15;
  25693. }
  25694. var tmp = d, rotateArg = a + f + k[j] + w[g] | 0, rotate = r[j];
  25695. d = c;
  25696. c = b;
  25697. b = b + (rotateArg << rotate | rotateArg >>> 32 - rotate) | 0;
  25698. a = tmp;
  25699. }
  25700. h0 = h0 + a | 0;
  25701. h1 = h1 + b | 0;
  25702. h2 = h2 + c | 0;
  25703. h3 = h3 + d | 0;
  25704. }
  25705. return new Uint8Array([
  25706. h0 & 0xFF,
  25707. h0 >> 8 & 0xFF,
  25708. h0 >> 16 & 0xFF,
  25709. h0 >>> 24 & 0xFF,
  25710. h1 & 0xFF,
  25711. h1 >> 8 & 0xFF,
  25712. h1 >> 16 & 0xFF,
  25713. h1 >>> 24 & 0xFF,
  25714. h2 & 0xFF,
  25715. h2 >> 8 & 0xFF,
  25716. h2 >> 16 & 0xFF,
  25717. h2 >>> 24 & 0xFF,
  25718. h3 & 0xFF,
  25719. h3 >> 8 & 0xFF,
  25720. h3 >> 16 & 0xFF,
  25721. h3 >>> 24 & 0xFF
  25722. ]);
  25723. }
  25724. return hash;
  25725. }();
  25726. var Word64 = function Word64Closure() {
  25727. function Word64(highInteger, lowInteger) {
  25728. this.high = highInteger | 0;
  25729. this.low = lowInteger | 0;
  25730. }
  25731. Word64.prototype = {
  25732. and: function Word64_and(word) {
  25733. this.high &= word.high;
  25734. this.low &= word.low;
  25735. },
  25736. xor: function Word64_xor(word) {
  25737. this.high ^= word.high;
  25738. this.low ^= word.low;
  25739. },
  25740. or: function Word64_or(word) {
  25741. this.high |= word.high;
  25742. this.low |= word.low;
  25743. },
  25744. shiftRight: function Word64_shiftRight(places) {
  25745. if (places >= 32) {
  25746. this.low = this.high >>> places - 32 | 0;
  25747. this.high = 0;
  25748. } else {
  25749. this.low = this.low >>> places | this.high << 32 - places;
  25750. this.high = this.high >>> places | 0;
  25751. }
  25752. },
  25753. shiftLeft: function Word64_shiftLeft(places) {
  25754. if (places >= 32) {
  25755. this.high = this.low << places - 32;
  25756. this.low = 0;
  25757. } else {
  25758. this.high = this.high << places | this.low >>> 32 - places;
  25759. this.low = this.low << places;
  25760. }
  25761. },
  25762. rotateRight: function Word64_rotateRight(places) {
  25763. var low, high;
  25764. if (places & 32) {
  25765. high = this.low;
  25766. low = this.high;
  25767. } else {
  25768. low = this.low;
  25769. high = this.high;
  25770. }
  25771. places &= 31;
  25772. this.low = low >>> places | high << 32 - places;
  25773. this.high = high >>> places | low << 32 - places;
  25774. },
  25775. not: function Word64_not() {
  25776. this.high = ~this.high;
  25777. this.low = ~this.low;
  25778. },
  25779. add: function Word64_add(word) {
  25780. var lowAdd = (this.low >>> 0) + (word.low >>> 0);
  25781. var highAdd = (this.high >>> 0) + (word.high >>> 0);
  25782. if (lowAdd > 0xFFFFFFFF) {
  25783. highAdd += 1;
  25784. }
  25785. this.low = lowAdd | 0;
  25786. this.high = highAdd | 0;
  25787. },
  25788. copyTo: function Word64_copyTo(bytes, offset) {
  25789. bytes[offset] = this.high >>> 24 & 0xFF;
  25790. bytes[offset + 1] = this.high >> 16 & 0xFF;
  25791. bytes[offset + 2] = this.high >> 8 & 0xFF;
  25792. bytes[offset + 3] = this.high & 0xFF;
  25793. bytes[offset + 4] = this.low >>> 24 & 0xFF;
  25794. bytes[offset + 5] = this.low >> 16 & 0xFF;
  25795. bytes[offset + 6] = this.low >> 8 & 0xFF;
  25796. bytes[offset + 7] = this.low & 0xFF;
  25797. },
  25798. assign: function Word64_assign(word) {
  25799. this.high = word.high;
  25800. this.low = word.low;
  25801. }
  25802. };
  25803. return Word64;
  25804. }();
  25805. var calculateSHA256 = function calculateSHA256Closure() {
  25806. function rotr(x, n) {
  25807. return x >>> n | x << 32 - n;
  25808. }
  25809. function ch(x, y, z) {
  25810. return x & y ^ ~x & z;
  25811. }
  25812. function maj(x, y, z) {
  25813. return x & y ^ x & z ^ y & z;
  25814. }
  25815. function sigma(x) {
  25816. return rotr(x, 2) ^ rotr(x, 13) ^ rotr(x, 22);
  25817. }
  25818. function sigmaPrime(x) {
  25819. return rotr(x, 6) ^ rotr(x, 11) ^ rotr(x, 25);
  25820. }
  25821. function littleSigma(x) {
  25822. return rotr(x, 7) ^ rotr(x, 18) ^ x >>> 3;
  25823. }
  25824. function littleSigmaPrime(x) {
  25825. return rotr(x, 17) ^ rotr(x, 19) ^ x >>> 10;
  25826. }
  25827. var k = [
  25828. 0x428a2f98,
  25829. 0x71374491,
  25830. 0xb5c0fbcf,
  25831. 0xe9b5dba5,
  25832. 0x3956c25b,
  25833. 0x59f111f1,
  25834. 0x923f82a4,
  25835. 0xab1c5ed5,
  25836. 0xd807aa98,
  25837. 0x12835b01,
  25838. 0x243185be,
  25839. 0x550c7dc3,
  25840. 0x72be5d74,
  25841. 0x80deb1fe,
  25842. 0x9bdc06a7,
  25843. 0xc19bf174,
  25844. 0xe49b69c1,
  25845. 0xefbe4786,
  25846. 0x0fc19dc6,
  25847. 0x240ca1cc,
  25848. 0x2de92c6f,
  25849. 0x4a7484aa,
  25850. 0x5cb0a9dc,
  25851. 0x76f988da,
  25852. 0x983e5152,
  25853. 0xa831c66d,
  25854. 0xb00327c8,
  25855. 0xbf597fc7,
  25856. 0xc6e00bf3,
  25857. 0xd5a79147,
  25858. 0x06ca6351,
  25859. 0x14292967,
  25860. 0x27b70a85,
  25861. 0x2e1b2138,
  25862. 0x4d2c6dfc,
  25863. 0x53380d13,
  25864. 0x650a7354,
  25865. 0x766a0abb,
  25866. 0x81c2c92e,
  25867. 0x92722c85,
  25868. 0xa2bfe8a1,
  25869. 0xa81a664b,
  25870. 0xc24b8b70,
  25871. 0xc76c51a3,
  25872. 0xd192e819,
  25873. 0xd6990624,
  25874. 0xf40e3585,
  25875. 0x106aa070,
  25876. 0x19a4c116,
  25877. 0x1e376c08,
  25878. 0x2748774c,
  25879. 0x34b0bcb5,
  25880. 0x391c0cb3,
  25881. 0x4ed8aa4a,
  25882. 0x5b9cca4f,
  25883. 0x682e6ff3,
  25884. 0x748f82ee,
  25885. 0x78a5636f,
  25886. 0x84c87814,
  25887. 0x8cc70208,
  25888. 0x90befffa,
  25889. 0xa4506ceb,
  25890. 0xbef9a3f7,
  25891. 0xc67178f2
  25892. ];
  25893. function hash(data, offset, length) {
  25894. var h0 = 0x6a09e667, h1 = 0xbb67ae85, h2 = 0x3c6ef372, h3 = 0xa54ff53a, h4 = 0x510e527f, h5 = 0x9b05688c, h6 = 0x1f83d9ab, h7 = 0x5be0cd19;
  25895. var paddedLength = Math.ceil((length + 9) / 64) * 64;
  25896. var padded = new Uint8Array(paddedLength);
  25897. var i, j, n;
  25898. for (i = 0; i < length; ++i) {
  25899. padded[i] = data[offset++];
  25900. }
  25901. padded[i++] = 0x80;
  25902. n = paddedLength - 8;
  25903. while (i < n) {
  25904. padded[i++] = 0;
  25905. }
  25906. padded[i++] = 0;
  25907. padded[i++] = 0;
  25908. padded[i++] = 0;
  25909. padded[i++] = length >>> 29 & 0xFF;
  25910. padded[i++] = length >> 21 & 0xFF;
  25911. padded[i++] = length >> 13 & 0xFF;
  25912. padded[i++] = length >> 5 & 0xFF;
  25913. padded[i++] = length << 3 & 0xFF;
  25914. var w = new Uint32Array(64);
  25915. for (i = 0; i < paddedLength;) {
  25916. for (j = 0; j < 16; ++j) {
  25917. w[j] = padded[i] << 24 | padded[i + 1] << 16 | padded[i + 2] << 8 | padded[i + 3];
  25918. i += 4;
  25919. }
  25920. for (j = 16; j < 64; ++j) {
  25921. w[j] = littleSigmaPrime(w[j - 2]) + w[j - 7] + littleSigma(w[j - 15]) + w[j - 16] | 0;
  25922. }
  25923. var a = h0, b = h1, c = h2, d = h3, e = h4, f = h5, g = h6, h = h7, t1, t2;
  25924. for (j = 0; j < 64; ++j) {
  25925. t1 = h + sigmaPrime(e) + ch(e, f, g) + k[j] + w[j];
  25926. t2 = sigma(a) + maj(a, b, c);
  25927. h = g;
  25928. g = f;
  25929. f = e;
  25930. e = d + t1 | 0;
  25931. d = c;
  25932. c = b;
  25933. b = a;
  25934. a = t1 + t2 | 0;
  25935. }
  25936. h0 = h0 + a | 0;
  25937. h1 = h1 + b | 0;
  25938. h2 = h2 + c | 0;
  25939. h3 = h3 + d | 0;
  25940. h4 = h4 + e | 0;
  25941. h5 = h5 + f | 0;
  25942. h6 = h6 + g | 0;
  25943. h7 = h7 + h | 0;
  25944. }
  25945. return new Uint8Array([
  25946. h0 >> 24 & 0xFF,
  25947. h0 >> 16 & 0xFF,
  25948. h0 >> 8 & 0xFF,
  25949. h0 & 0xFF,
  25950. h1 >> 24 & 0xFF,
  25951. h1 >> 16 & 0xFF,
  25952. h1 >> 8 & 0xFF,
  25953. h1 & 0xFF,
  25954. h2 >> 24 & 0xFF,
  25955. h2 >> 16 & 0xFF,
  25956. h2 >> 8 & 0xFF,
  25957. h2 & 0xFF,
  25958. h3 >> 24 & 0xFF,
  25959. h3 >> 16 & 0xFF,
  25960. h3 >> 8 & 0xFF,
  25961. h3 & 0xFF,
  25962. h4 >> 24 & 0xFF,
  25963. h4 >> 16 & 0xFF,
  25964. h4 >> 8 & 0xFF,
  25965. h4 & 0xFF,
  25966. h5 >> 24 & 0xFF,
  25967. h5 >> 16 & 0xFF,
  25968. h5 >> 8 & 0xFF,
  25969. h5 & 0xFF,
  25970. h6 >> 24 & 0xFF,
  25971. h6 >> 16 & 0xFF,
  25972. h6 >> 8 & 0xFF,
  25973. h6 & 0xFF,
  25974. h7 >> 24 & 0xFF,
  25975. h7 >> 16 & 0xFF,
  25976. h7 >> 8 & 0xFF,
  25977. h7 & 0xFF
  25978. ]);
  25979. }
  25980. return hash;
  25981. }();
  25982. var calculateSHA512 = function calculateSHA512Closure() {
  25983. function ch(result, x, y, z, tmp) {
  25984. result.assign(x);
  25985. result.and(y);
  25986. tmp.assign(x);
  25987. tmp.not();
  25988. tmp.and(z);
  25989. result.xor(tmp);
  25990. }
  25991. function maj(result, x, y, z, tmp) {
  25992. result.assign(x);
  25993. result.and(y);
  25994. tmp.assign(x);
  25995. tmp.and(z);
  25996. result.xor(tmp);
  25997. tmp.assign(y);
  25998. tmp.and(z);
  25999. result.xor(tmp);
  26000. }
  26001. function sigma(result, x, tmp) {
  26002. result.assign(x);
  26003. result.rotateRight(28);
  26004. tmp.assign(x);
  26005. tmp.rotateRight(34);
  26006. result.xor(tmp);
  26007. tmp.assign(x);
  26008. tmp.rotateRight(39);
  26009. result.xor(tmp);
  26010. }
  26011. function sigmaPrime(result, x, tmp) {
  26012. result.assign(x);
  26013. result.rotateRight(14);
  26014. tmp.assign(x);
  26015. tmp.rotateRight(18);
  26016. result.xor(tmp);
  26017. tmp.assign(x);
  26018. tmp.rotateRight(41);
  26019. result.xor(tmp);
  26020. }
  26021. function littleSigma(result, x, tmp) {
  26022. result.assign(x);
  26023. result.rotateRight(1);
  26024. tmp.assign(x);
  26025. tmp.rotateRight(8);
  26026. result.xor(tmp);
  26027. tmp.assign(x);
  26028. tmp.shiftRight(7);
  26029. result.xor(tmp);
  26030. }
  26031. function littleSigmaPrime(result, x, tmp) {
  26032. result.assign(x);
  26033. result.rotateRight(19);
  26034. tmp.assign(x);
  26035. tmp.rotateRight(61);
  26036. result.xor(tmp);
  26037. tmp.assign(x);
  26038. tmp.shiftRight(6);
  26039. result.xor(tmp);
  26040. }
  26041. var k = [
  26042. new Word64(0x428a2f98, 0xd728ae22),
  26043. new Word64(0x71374491, 0x23ef65cd),
  26044. new Word64(0xb5c0fbcf, 0xec4d3b2f),
  26045. new Word64(0xe9b5dba5, 0x8189dbbc),
  26046. new Word64(0x3956c25b, 0xf348b538),
  26047. new Word64(0x59f111f1, 0xb605d019),
  26048. new Word64(0x923f82a4, 0xaf194f9b),
  26049. new Word64(0xab1c5ed5, 0xda6d8118),
  26050. new Word64(0xd807aa98, 0xa3030242),
  26051. new Word64(0x12835b01, 0x45706fbe),
  26052. new Word64(0x243185be, 0x4ee4b28c),
  26053. new Word64(0x550c7dc3, 0xd5ffb4e2),
  26054. new Word64(0x72be5d74, 0xf27b896f),
  26055. new Word64(0x80deb1fe, 0x3b1696b1),
  26056. new Word64(0x9bdc06a7, 0x25c71235),
  26057. new Word64(0xc19bf174, 0xcf692694),
  26058. new Word64(0xe49b69c1, 0x9ef14ad2),
  26059. new Word64(0xefbe4786, 0x384f25e3),
  26060. new Word64(0x0fc19dc6, 0x8b8cd5b5),
  26061. new Word64(0x240ca1cc, 0x77ac9c65),
  26062. new Word64(0x2de92c6f, 0x592b0275),
  26063. new Word64(0x4a7484aa, 0x6ea6e483),
  26064. new Word64(0x5cb0a9dc, 0xbd41fbd4),
  26065. new Word64(0x76f988da, 0x831153b5),
  26066. new Word64(0x983e5152, 0xee66dfab),
  26067. new Word64(0xa831c66d, 0x2db43210),
  26068. new Word64(0xb00327c8, 0x98fb213f),
  26069. new Word64(0xbf597fc7, 0xbeef0ee4),
  26070. new Word64(0xc6e00bf3, 0x3da88fc2),
  26071. new Word64(0xd5a79147, 0x930aa725),
  26072. new Word64(0x06ca6351, 0xe003826f),
  26073. new Word64(0x14292967, 0x0a0e6e70),
  26074. new Word64(0x27b70a85, 0x46d22ffc),
  26075. new Word64(0x2e1b2138, 0x5c26c926),
  26076. new Word64(0x4d2c6dfc, 0x5ac42aed),
  26077. new Word64(0x53380d13, 0x9d95b3df),
  26078. new Word64(0x650a7354, 0x8baf63de),
  26079. new Word64(0x766a0abb, 0x3c77b2a8),
  26080. new Word64(0x81c2c92e, 0x47edaee6),
  26081. new Word64(0x92722c85, 0x1482353b),
  26082. new Word64(0xa2bfe8a1, 0x4cf10364),
  26083. new Word64(0xa81a664b, 0xbc423001),
  26084. new Word64(0xc24b8b70, 0xd0f89791),
  26085. new Word64(0xc76c51a3, 0x0654be30),
  26086. new Word64(0xd192e819, 0xd6ef5218),
  26087. new Word64(0xd6990624, 0x5565a910),
  26088. new Word64(0xf40e3585, 0x5771202a),
  26089. new Word64(0x106aa070, 0x32bbd1b8),
  26090. new Word64(0x19a4c116, 0xb8d2d0c8),
  26091. new Word64(0x1e376c08, 0x5141ab53),
  26092. new Word64(0x2748774c, 0xdf8eeb99),
  26093. new Word64(0x34b0bcb5, 0xe19b48a8),
  26094. new Word64(0x391c0cb3, 0xc5c95a63),
  26095. new Word64(0x4ed8aa4a, 0xe3418acb),
  26096. new Word64(0x5b9cca4f, 0x7763e373),
  26097. new Word64(0x682e6ff3, 0xd6b2b8a3),
  26098. new Word64(0x748f82ee, 0x5defb2fc),
  26099. new Word64(0x78a5636f, 0x43172f60),
  26100. new Word64(0x84c87814, 0xa1f0ab72),
  26101. new Word64(0x8cc70208, 0x1a6439ec),
  26102. new Word64(0x90befffa, 0x23631e28),
  26103. new Word64(0xa4506ceb, 0xde82bde9),
  26104. new Word64(0xbef9a3f7, 0xb2c67915),
  26105. new Word64(0xc67178f2, 0xe372532b),
  26106. new Word64(0xca273ece, 0xea26619c),
  26107. new Word64(0xd186b8c7, 0x21c0c207),
  26108. new Word64(0xeada7dd6, 0xcde0eb1e),
  26109. new Word64(0xf57d4f7f, 0xee6ed178),
  26110. new Word64(0x06f067aa, 0x72176fba),
  26111. new Word64(0x0a637dc5, 0xa2c898a6),
  26112. new Word64(0x113f9804, 0xbef90dae),
  26113. new Word64(0x1b710b35, 0x131c471b),
  26114. new Word64(0x28db77f5, 0x23047d84),
  26115. new Word64(0x32caab7b, 0x40c72493),
  26116. new Word64(0x3c9ebe0a, 0x15c9bebc),
  26117. new Word64(0x431d67c4, 0x9c100d4c),
  26118. new Word64(0x4cc5d4be, 0xcb3e42b6),
  26119. new Word64(0x597f299c, 0xfc657e2a),
  26120. new Word64(0x5fcb6fab, 0x3ad6faec),
  26121. new Word64(0x6c44198c, 0x4a475817)
  26122. ];
  26123. function hash(data, offset, length, mode384) {
  26124. mode384 = !!mode384;
  26125. var h0, h1, h2, h3, h4, h5, h6, h7;
  26126. if (!mode384) {
  26127. h0 = new Word64(0x6a09e667, 0xf3bcc908);
  26128. h1 = new Word64(0xbb67ae85, 0x84caa73b);
  26129. h2 = new Word64(0x3c6ef372, 0xfe94f82b);
  26130. h3 = new Word64(0xa54ff53a, 0x5f1d36f1);
  26131. h4 = new Word64(0x510e527f, 0xade682d1);
  26132. h5 = new Word64(0x9b05688c, 0x2b3e6c1f);
  26133. h6 = new Word64(0x1f83d9ab, 0xfb41bd6b);
  26134. h7 = new Word64(0x5be0cd19, 0x137e2179);
  26135. } else {
  26136. h0 = new Word64(0xcbbb9d5d, 0xc1059ed8);
  26137. h1 = new Word64(0x629a292a, 0x367cd507);
  26138. h2 = new Word64(0x9159015a, 0x3070dd17);
  26139. h3 = new Word64(0x152fecd8, 0xf70e5939);
  26140. h4 = new Word64(0x67332667, 0xffc00b31);
  26141. h5 = new Word64(0x8eb44a87, 0x68581511);
  26142. h6 = new Word64(0xdb0c2e0d, 0x64f98fa7);
  26143. h7 = new Word64(0x47b5481d, 0xbefa4fa4);
  26144. }
  26145. var paddedLength = Math.ceil((length + 17) / 128) * 128;
  26146. var padded = new Uint8Array(paddedLength);
  26147. var i, j, n;
  26148. for (i = 0; i < length; ++i) {
  26149. padded[i] = data[offset++];
  26150. }
  26151. padded[i++] = 0x80;
  26152. n = paddedLength - 16;
  26153. while (i < n) {
  26154. padded[i++] = 0;
  26155. }
  26156. padded[i++] = 0;
  26157. padded[i++] = 0;
  26158. padded[i++] = 0;
  26159. padded[i++] = 0;
  26160. padded[i++] = 0;
  26161. padded[i++] = 0;
  26162. padded[i++] = 0;
  26163. padded[i++] = 0;
  26164. padded[i++] = 0;
  26165. padded[i++] = 0;
  26166. padded[i++] = 0;
  26167. padded[i++] = length >>> 29 & 0xFF;
  26168. padded[i++] = length >> 21 & 0xFF;
  26169. padded[i++] = length >> 13 & 0xFF;
  26170. padded[i++] = length >> 5 & 0xFF;
  26171. padded[i++] = length << 3 & 0xFF;
  26172. var w = new Array(80);
  26173. for (i = 0; i < 80; i++) {
  26174. w[i] = new Word64(0, 0);
  26175. }
  26176. var a = new Word64(0, 0), b = new Word64(0, 0), c = new Word64(0, 0);
  26177. var d = new Word64(0, 0), e = new Word64(0, 0), f = new Word64(0, 0);
  26178. var g = new Word64(0, 0), h = new Word64(0, 0);
  26179. var t1 = new Word64(0, 0), t2 = new Word64(0, 0);
  26180. var tmp1 = new Word64(0, 0), tmp2 = new Word64(0, 0), tmp3;
  26181. for (i = 0; i < paddedLength;) {
  26182. for (j = 0; j < 16; ++j) {
  26183. w[j].high = padded[i] << 24 | padded[i + 1] << 16 | padded[i + 2] << 8 | padded[i + 3];
  26184. w[j].low = padded[i + 4] << 24 | padded[i + 5] << 16 | padded[i + 6] << 8 | padded[i + 7];
  26185. i += 8;
  26186. }
  26187. for (j = 16; j < 80; ++j) {
  26188. tmp3 = w[j];
  26189. littleSigmaPrime(tmp3, w[j - 2], tmp2);
  26190. tmp3.add(w[j - 7]);
  26191. littleSigma(tmp1, w[j - 15], tmp2);
  26192. tmp3.add(tmp1);
  26193. tmp3.add(w[j - 16]);
  26194. }
  26195. a.assign(h0);
  26196. b.assign(h1);
  26197. c.assign(h2);
  26198. d.assign(h3);
  26199. e.assign(h4);
  26200. f.assign(h5);
  26201. g.assign(h6);
  26202. h.assign(h7);
  26203. for (j = 0; j < 80; ++j) {
  26204. t1.assign(h);
  26205. sigmaPrime(tmp1, e, tmp2);
  26206. t1.add(tmp1);
  26207. ch(tmp1, e, f, g, tmp2);
  26208. t1.add(tmp1);
  26209. t1.add(k[j]);
  26210. t1.add(w[j]);
  26211. sigma(t2, a, tmp2);
  26212. maj(tmp1, a, b, c, tmp2);
  26213. t2.add(tmp1);
  26214. tmp3 = h;
  26215. h = g;
  26216. g = f;
  26217. f = e;
  26218. d.add(t1);
  26219. e = d;
  26220. d = c;
  26221. c = b;
  26222. b = a;
  26223. tmp3.assign(t1);
  26224. tmp3.add(t2);
  26225. a = tmp3;
  26226. }
  26227. h0.add(a);
  26228. h1.add(b);
  26229. h2.add(c);
  26230. h3.add(d);
  26231. h4.add(e);
  26232. h5.add(f);
  26233. h6.add(g);
  26234. h7.add(h);
  26235. }
  26236. var result;
  26237. if (!mode384) {
  26238. result = new Uint8Array(64);
  26239. h0.copyTo(result, 0);
  26240. h1.copyTo(result, 8);
  26241. h2.copyTo(result, 16);
  26242. h3.copyTo(result, 24);
  26243. h4.copyTo(result, 32);
  26244. h5.copyTo(result, 40);
  26245. h6.copyTo(result, 48);
  26246. h7.copyTo(result, 56);
  26247. } else {
  26248. result = new Uint8Array(48);
  26249. h0.copyTo(result, 0);
  26250. h1.copyTo(result, 8);
  26251. h2.copyTo(result, 16);
  26252. h3.copyTo(result, 24);
  26253. h4.copyTo(result, 32);
  26254. h5.copyTo(result, 40);
  26255. }
  26256. return result;
  26257. }
  26258. return hash;
  26259. }();
  26260. var calculateSHA384 = function calculateSHA384Closure() {
  26261. function hash(data, offset, length) {
  26262. return calculateSHA512(data, offset, length, true);
  26263. }
  26264. return hash;
  26265. }();
  26266. var NullCipher = function NullCipherClosure() {
  26267. function NullCipher() {
  26268. }
  26269. NullCipher.prototype = {
  26270. decryptBlock: function NullCipher_decryptBlock(data) {
  26271. return data;
  26272. }
  26273. };
  26274. return NullCipher;
  26275. }();
  26276. var AES128Cipher = function AES128CipherClosure() {
  26277. var rcon = new Uint8Array([
  26278. 0x8d,
  26279. 0x01,
  26280. 0x02,
  26281. 0x04,
  26282. 0x08,
  26283. 0x10,
  26284. 0x20,
  26285. 0x40,
  26286. 0x80,
  26287. 0x1b,
  26288. 0x36,
  26289. 0x6c,
  26290. 0xd8,
  26291. 0xab,
  26292. 0x4d,
  26293. 0x9a,
  26294. 0x2f,
  26295. 0x5e,
  26296. 0xbc,
  26297. 0x63,
  26298. 0xc6,
  26299. 0x97,
  26300. 0x35,
  26301. 0x6a,
  26302. 0xd4,
  26303. 0xb3,
  26304. 0x7d,
  26305. 0xfa,
  26306. 0xef,
  26307. 0xc5,
  26308. 0x91,
  26309. 0x39,
  26310. 0x72,
  26311. 0xe4,
  26312. 0xd3,
  26313. 0xbd,
  26314. 0x61,
  26315. 0xc2,
  26316. 0x9f,
  26317. 0x25,
  26318. 0x4a,
  26319. 0x94,
  26320. 0x33,
  26321. 0x66,
  26322. 0xcc,
  26323. 0x83,
  26324. 0x1d,
  26325. 0x3a,
  26326. 0x74,
  26327. 0xe8,
  26328. 0xcb,
  26329. 0x8d,
  26330. 0x01,
  26331. 0x02,
  26332. 0x04,
  26333. 0x08,
  26334. 0x10,
  26335. 0x20,
  26336. 0x40,
  26337. 0x80,
  26338. 0x1b,
  26339. 0x36,
  26340. 0x6c,
  26341. 0xd8,
  26342. 0xab,
  26343. 0x4d,
  26344. 0x9a,
  26345. 0x2f,
  26346. 0x5e,
  26347. 0xbc,
  26348. 0x63,
  26349. 0xc6,
  26350. 0x97,
  26351. 0x35,
  26352. 0x6a,
  26353. 0xd4,
  26354. 0xb3,
  26355. 0x7d,
  26356. 0xfa,
  26357. 0xef,
  26358. 0xc5,
  26359. 0x91,
  26360. 0x39,
  26361. 0x72,
  26362. 0xe4,
  26363. 0xd3,
  26364. 0xbd,
  26365. 0x61,
  26366. 0xc2,
  26367. 0x9f,
  26368. 0x25,
  26369. 0x4a,
  26370. 0x94,
  26371. 0x33,
  26372. 0x66,
  26373. 0xcc,
  26374. 0x83,
  26375. 0x1d,
  26376. 0x3a,
  26377. 0x74,
  26378. 0xe8,
  26379. 0xcb,
  26380. 0x8d,
  26381. 0x01,
  26382. 0x02,
  26383. 0x04,
  26384. 0x08,
  26385. 0x10,
  26386. 0x20,
  26387. 0x40,
  26388. 0x80,
  26389. 0x1b,
  26390. 0x36,
  26391. 0x6c,
  26392. 0xd8,
  26393. 0xab,
  26394. 0x4d,
  26395. 0x9a,
  26396. 0x2f,
  26397. 0x5e,
  26398. 0xbc,
  26399. 0x63,
  26400. 0xc6,
  26401. 0x97,
  26402. 0x35,
  26403. 0x6a,
  26404. 0xd4,
  26405. 0xb3,
  26406. 0x7d,
  26407. 0xfa,
  26408. 0xef,
  26409. 0xc5,
  26410. 0x91,
  26411. 0x39,
  26412. 0x72,
  26413. 0xe4,
  26414. 0xd3,
  26415. 0xbd,
  26416. 0x61,
  26417. 0xc2,
  26418. 0x9f,
  26419. 0x25,
  26420. 0x4a,
  26421. 0x94,
  26422. 0x33,
  26423. 0x66,
  26424. 0xcc,
  26425. 0x83,
  26426. 0x1d,
  26427. 0x3a,
  26428. 0x74,
  26429. 0xe8,
  26430. 0xcb,
  26431. 0x8d,
  26432. 0x01,
  26433. 0x02,
  26434. 0x04,
  26435. 0x08,
  26436. 0x10,
  26437. 0x20,
  26438. 0x40,
  26439. 0x80,
  26440. 0x1b,
  26441. 0x36,
  26442. 0x6c,
  26443. 0xd8,
  26444. 0xab,
  26445. 0x4d,
  26446. 0x9a,
  26447. 0x2f,
  26448. 0x5e,
  26449. 0xbc,
  26450. 0x63,
  26451. 0xc6,
  26452. 0x97,
  26453. 0x35,
  26454. 0x6a,
  26455. 0xd4,
  26456. 0xb3,
  26457. 0x7d,
  26458. 0xfa,
  26459. 0xef,
  26460. 0xc5,
  26461. 0x91,
  26462. 0x39,
  26463. 0x72,
  26464. 0xe4,
  26465. 0xd3,
  26466. 0xbd,
  26467. 0x61,
  26468. 0xc2,
  26469. 0x9f,
  26470. 0x25,
  26471. 0x4a,
  26472. 0x94,
  26473. 0x33,
  26474. 0x66,
  26475. 0xcc,
  26476. 0x83,
  26477. 0x1d,
  26478. 0x3a,
  26479. 0x74,
  26480. 0xe8,
  26481. 0xcb,
  26482. 0x8d,
  26483. 0x01,
  26484. 0x02,
  26485. 0x04,
  26486. 0x08,
  26487. 0x10,
  26488. 0x20,
  26489. 0x40,
  26490. 0x80,
  26491. 0x1b,
  26492. 0x36,
  26493. 0x6c,
  26494. 0xd8,
  26495. 0xab,
  26496. 0x4d,
  26497. 0x9a,
  26498. 0x2f,
  26499. 0x5e,
  26500. 0xbc,
  26501. 0x63,
  26502. 0xc6,
  26503. 0x97,
  26504. 0x35,
  26505. 0x6a,
  26506. 0xd4,
  26507. 0xb3,
  26508. 0x7d,
  26509. 0xfa,
  26510. 0xef,
  26511. 0xc5,
  26512. 0x91,
  26513. 0x39,
  26514. 0x72,
  26515. 0xe4,
  26516. 0xd3,
  26517. 0xbd,
  26518. 0x61,
  26519. 0xc2,
  26520. 0x9f,
  26521. 0x25,
  26522. 0x4a,
  26523. 0x94,
  26524. 0x33,
  26525. 0x66,
  26526. 0xcc,
  26527. 0x83,
  26528. 0x1d,
  26529. 0x3a,
  26530. 0x74,
  26531. 0xe8,
  26532. 0xcb,
  26533. 0x8d
  26534. ]);
  26535. var s = new Uint8Array([
  26536. 0x63,
  26537. 0x7c,
  26538. 0x77,
  26539. 0x7b,
  26540. 0xf2,
  26541. 0x6b,
  26542. 0x6f,
  26543. 0xc5,
  26544. 0x30,
  26545. 0x01,
  26546. 0x67,
  26547. 0x2b,
  26548. 0xfe,
  26549. 0xd7,
  26550. 0xab,
  26551. 0x76,
  26552. 0xca,
  26553. 0x82,
  26554. 0xc9,
  26555. 0x7d,
  26556. 0xfa,
  26557. 0x59,
  26558. 0x47,
  26559. 0xf0,
  26560. 0xad,
  26561. 0xd4,
  26562. 0xa2,
  26563. 0xaf,
  26564. 0x9c,
  26565. 0xa4,
  26566. 0x72,
  26567. 0xc0,
  26568. 0xb7,
  26569. 0xfd,
  26570. 0x93,
  26571. 0x26,
  26572. 0x36,
  26573. 0x3f,
  26574. 0xf7,
  26575. 0xcc,
  26576. 0x34,
  26577. 0xa5,
  26578. 0xe5,
  26579. 0xf1,
  26580. 0x71,
  26581. 0xd8,
  26582. 0x31,
  26583. 0x15,
  26584. 0x04,
  26585. 0xc7,
  26586. 0x23,
  26587. 0xc3,
  26588. 0x18,
  26589. 0x96,
  26590. 0x05,
  26591. 0x9a,
  26592. 0x07,
  26593. 0x12,
  26594. 0x80,
  26595. 0xe2,
  26596. 0xeb,
  26597. 0x27,
  26598. 0xb2,
  26599. 0x75,
  26600. 0x09,
  26601. 0x83,
  26602. 0x2c,
  26603. 0x1a,
  26604. 0x1b,
  26605. 0x6e,
  26606. 0x5a,
  26607. 0xa0,
  26608. 0x52,
  26609. 0x3b,
  26610. 0xd6,
  26611. 0xb3,
  26612. 0x29,
  26613. 0xe3,
  26614. 0x2f,
  26615. 0x84,
  26616. 0x53,
  26617. 0xd1,
  26618. 0x00,
  26619. 0xed,
  26620. 0x20,
  26621. 0xfc,
  26622. 0xb1,
  26623. 0x5b,
  26624. 0x6a,
  26625. 0xcb,
  26626. 0xbe,
  26627. 0x39,
  26628. 0x4a,
  26629. 0x4c,
  26630. 0x58,
  26631. 0xcf,
  26632. 0xd0,
  26633. 0xef,
  26634. 0xaa,
  26635. 0xfb,
  26636. 0x43,
  26637. 0x4d,
  26638. 0x33,
  26639. 0x85,
  26640. 0x45,
  26641. 0xf9,
  26642. 0x02,
  26643. 0x7f,
  26644. 0x50,
  26645. 0x3c,
  26646. 0x9f,
  26647. 0xa8,
  26648. 0x51,
  26649. 0xa3,
  26650. 0x40,
  26651. 0x8f,
  26652. 0x92,
  26653. 0x9d,
  26654. 0x38,
  26655. 0xf5,
  26656. 0xbc,
  26657. 0xb6,
  26658. 0xda,
  26659. 0x21,
  26660. 0x10,
  26661. 0xff,
  26662. 0xf3,
  26663. 0xd2,
  26664. 0xcd,
  26665. 0x0c,
  26666. 0x13,
  26667. 0xec,
  26668. 0x5f,
  26669. 0x97,
  26670. 0x44,
  26671. 0x17,
  26672. 0xc4,
  26673. 0xa7,
  26674. 0x7e,
  26675. 0x3d,
  26676. 0x64,
  26677. 0x5d,
  26678. 0x19,
  26679. 0x73,
  26680. 0x60,
  26681. 0x81,
  26682. 0x4f,
  26683. 0xdc,
  26684. 0x22,
  26685. 0x2a,
  26686. 0x90,
  26687. 0x88,
  26688. 0x46,
  26689. 0xee,
  26690. 0xb8,
  26691. 0x14,
  26692. 0xde,
  26693. 0x5e,
  26694. 0x0b,
  26695. 0xdb,
  26696. 0xe0,
  26697. 0x32,
  26698. 0x3a,
  26699. 0x0a,
  26700. 0x49,
  26701. 0x06,
  26702. 0x24,
  26703. 0x5c,
  26704. 0xc2,
  26705. 0xd3,
  26706. 0xac,
  26707. 0x62,
  26708. 0x91,
  26709. 0x95,
  26710. 0xe4,
  26711. 0x79,
  26712. 0xe7,
  26713. 0xc8,
  26714. 0x37,
  26715. 0x6d,
  26716. 0x8d,
  26717. 0xd5,
  26718. 0x4e,
  26719. 0xa9,
  26720. 0x6c,
  26721. 0x56,
  26722. 0xf4,
  26723. 0xea,
  26724. 0x65,
  26725. 0x7a,
  26726. 0xae,
  26727. 0x08,
  26728. 0xba,
  26729. 0x78,
  26730. 0x25,
  26731. 0x2e,
  26732. 0x1c,
  26733. 0xa6,
  26734. 0xb4,
  26735. 0xc6,
  26736. 0xe8,
  26737. 0xdd,
  26738. 0x74,
  26739. 0x1f,
  26740. 0x4b,
  26741. 0xbd,
  26742. 0x8b,
  26743. 0x8a,
  26744. 0x70,
  26745. 0x3e,
  26746. 0xb5,
  26747. 0x66,
  26748. 0x48,
  26749. 0x03,
  26750. 0xf6,
  26751. 0x0e,
  26752. 0x61,
  26753. 0x35,
  26754. 0x57,
  26755. 0xb9,
  26756. 0x86,
  26757. 0xc1,
  26758. 0x1d,
  26759. 0x9e,
  26760. 0xe1,
  26761. 0xf8,
  26762. 0x98,
  26763. 0x11,
  26764. 0x69,
  26765. 0xd9,
  26766. 0x8e,
  26767. 0x94,
  26768. 0x9b,
  26769. 0x1e,
  26770. 0x87,
  26771. 0xe9,
  26772. 0xce,
  26773. 0x55,
  26774. 0x28,
  26775. 0xdf,
  26776. 0x8c,
  26777. 0xa1,
  26778. 0x89,
  26779. 0x0d,
  26780. 0xbf,
  26781. 0xe6,
  26782. 0x42,
  26783. 0x68,
  26784. 0x41,
  26785. 0x99,
  26786. 0x2d,
  26787. 0x0f,
  26788. 0xb0,
  26789. 0x54,
  26790. 0xbb,
  26791. 0x16
  26792. ]);
  26793. var inv_s = new Uint8Array([
  26794. 0x52,
  26795. 0x09,
  26796. 0x6a,
  26797. 0xd5,
  26798. 0x30,
  26799. 0x36,
  26800. 0xa5,
  26801. 0x38,
  26802. 0xbf,
  26803. 0x40,
  26804. 0xa3,
  26805. 0x9e,
  26806. 0x81,
  26807. 0xf3,
  26808. 0xd7,
  26809. 0xfb,
  26810. 0x7c,
  26811. 0xe3,
  26812. 0x39,
  26813. 0x82,
  26814. 0x9b,
  26815. 0x2f,
  26816. 0xff,
  26817. 0x87,
  26818. 0x34,
  26819. 0x8e,
  26820. 0x43,
  26821. 0x44,
  26822. 0xc4,
  26823. 0xde,
  26824. 0xe9,
  26825. 0xcb,
  26826. 0x54,
  26827. 0x7b,
  26828. 0x94,
  26829. 0x32,
  26830. 0xa6,
  26831. 0xc2,
  26832. 0x23,
  26833. 0x3d,
  26834. 0xee,
  26835. 0x4c,
  26836. 0x95,
  26837. 0x0b,
  26838. 0x42,
  26839. 0xfa,
  26840. 0xc3,
  26841. 0x4e,
  26842. 0x08,
  26843. 0x2e,
  26844. 0xa1,
  26845. 0x66,
  26846. 0x28,
  26847. 0xd9,
  26848. 0x24,
  26849. 0xb2,
  26850. 0x76,
  26851. 0x5b,
  26852. 0xa2,
  26853. 0x49,
  26854. 0x6d,
  26855. 0x8b,
  26856. 0xd1,
  26857. 0x25,
  26858. 0x72,
  26859. 0xf8,
  26860. 0xf6,
  26861. 0x64,
  26862. 0x86,
  26863. 0x68,
  26864. 0x98,
  26865. 0x16,
  26866. 0xd4,
  26867. 0xa4,
  26868. 0x5c,
  26869. 0xcc,
  26870. 0x5d,
  26871. 0x65,
  26872. 0xb6,
  26873. 0x92,
  26874. 0x6c,
  26875. 0x70,
  26876. 0x48,
  26877. 0x50,
  26878. 0xfd,
  26879. 0xed,
  26880. 0xb9,
  26881. 0xda,
  26882. 0x5e,
  26883. 0x15,
  26884. 0x46,
  26885. 0x57,
  26886. 0xa7,
  26887. 0x8d,
  26888. 0x9d,
  26889. 0x84,
  26890. 0x90,
  26891. 0xd8,
  26892. 0xab,
  26893. 0x00,
  26894. 0x8c,
  26895. 0xbc,
  26896. 0xd3,
  26897. 0x0a,
  26898. 0xf7,
  26899. 0xe4,
  26900. 0x58,
  26901. 0x05,
  26902. 0xb8,
  26903. 0xb3,
  26904. 0x45,
  26905. 0x06,
  26906. 0xd0,
  26907. 0x2c,
  26908. 0x1e,
  26909. 0x8f,
  26910. 0xca,
  26911. 0x3f,
  26912. 0x0f,
  26913. 0x02,
  26914. 0xc1,
  26915. 0xaf,
  26916. 0xbd,
  26917. 0x03,
  26918. 0x01,
  26919. 0x13,
  26920. 0x8a,
  26921. 0x6b,
  26922. 0x3a,
  26923. 0x91,
  26924. 0x11,
  26925. 0x41,
  26926. 0x4f,
  26927. 0x67,
  26928. 0xdc,
  26929. 0xea,
  26930. 0x97,
  26931. 0xf2,
  26932. 0xcf,
  26933. 0xce,
  26934. 0xf0,
  26935. 0xb4,
  26936. 0xe6,
  26937. 0x73,
  26938. 0x96,
  26939. 0xac,
  26940. 0x74,
  26941. 0x22,
  26942. 0xe7,
  26943. 0xad,
  26944. 0x35,
  26945. 0x85,
  26946. 0xe2,
  26947. 0xf9,
  26948. 0x37,
  26949. 0xe8,
  26950. 0x1c,
  26951. 0x75,
  26952. 0xdf,
  26953. 0x6e,
  26954. 0x47,
  26955. 0xf1,
  26956. 0x1a,
  26957. 0x71,
  26958. 0x1d,
  26959. 0x29,
  26960. 0xc5,
  26961. 0x89,
  26962. 0x6f,
  26963. 0xb7,
  26964. 0x62,
  26965. 0x0e,
  26966. 0xaa,
  26967. 0x18,
  26968. 0xbe,
  26969. 0x1b,
  26970. 0xfc,
  26971. 0x56,
  26972. 0x3e,
  26973. 0x4b,
  26974. 0xc6,
  26975. 0xd2,
  26976. 0x79,
  26977. 0x20,
  26978. 0x9a,
  26979. 0xdb,
  26980. 0xc0,
  26981. 0xfe,
  26982. 0x78,
  26983. 0xcd,
  26984. 0x5a,
  26985. 0xf4,
  26986. 0x1f,
  26987. 0xdd,
  26988. 0xa8,
  26989. 0x33,
  26990. 0x88,
  26991. 0x07,
  26992. 0xc7,
  26993. 0x31,
  26994. 0xb1,
  26995. 0x12,
  26996. 0x10,
  26997. 0x59,
  26998. 0x27,
  26999. 0x80,
  27000. 0xec,
  27001. 0x5f,
  27002. 0x60,
  27003. 0x51,
  27004. 0x7f,
  27005. 0xa9,
  27006. 0x19,
  27007. 0xb5,
  27008. 0x4a,
  27009. 0x0d,
  27010. 0x2d,
  27011. 0xe5,
  27012. 0x7a,
  27013. 0x9f,
  27014. 0x93,
  27015. 0xc9,
  27016. 0x9c,
  27017. 0xef,
  27018. 0xa0,
  27019. 0xe0,
  27020. 0x3b,
  27021. 0x4d,
  27022. 0xae,
  27023. 0x2a,
  27024. 0xf5,
  27025. 0xb0,
  27026. 0xc8,
  27027. 0xeb,
  27028. 0xbb,
  27029. 0x3c,
  27030. 0x83,
  27031. 0x53,
  27032. 0x99,
  27033. 0x61,
  27034. 0x17,
  27035. 0x2b,
  27036. 0x04,
  27037. 0x7e,
  27038. 0xba,
  27039. 0x77,
  27040. 0xd6,
  27041. 0x26,
  27042. 0xe1,
  27043. 0x69,
  27044. 0x14,
  27045. 0x63,
  27046. 0x55,
  27047. 0x21,
  27048. 0x0c,
  27049. 0x7d
  27050. ]);
  27051. var mixCol = new Uint8Array(256);
  27052. for (var i = 0; i < 256; i++) {
  27053. if (i < 128) {
  27054. mixCol[i] = i << 1;
  27055. } else {
  27056. mixCol[i] = i << 1 ^ 0x1b;
  27057. }
  27058. }
  27059. var mix = new Uint32Array([
  27060. 0x00000000,
  27061. 0x0e090d0b,
  27062. 0x1c121a16,
  27063. 0x121b171d,
  27064. 0x3824342c,
  27065. 0x362d3927,
  27066. 0x24362e3a,
  27067. 0x2a3f2331,
  27068. 0x70486858,
  27069. 0x7e416553,
  27070. 0x6c5a724e,
  27071. 0x62537f45,
  27072. 0x486c5c74,
  27073. 0x4665517f,
  27074. 0x547e4662,
  27075. 0x5a774b69,
  27076. 0xe090d0b0,
  27077. 0xee99ddbb,
  27078. 0xfc82caa6,
  27079. 0xf28bc7ad,
  27080. 0xd8b4e49c,
  27081. 0xd6bde997,
  27082. 0xc4a6fe8a,
  27083. 0xcaaff381,
  27084. 0x90d8b8e8,
  27085. 0x9ed1b5e3,
  27086. 0x8ccaa2fe,
  27087. 0x82c3aff5,
  27088. 0xa8fc8cc4,
  27089. 0xa6f581cf,
  27090. 0xb4ee96d2,
  27091. 0xbae79bd9,
  27092. 0xdb3bbb7b,
  27093. 0xd532b670,
  27094. 0xc729a16d,
  27095. 0xc920ac66,
  27096. 0xe31f8f57,
  27097. 0xed16825c,
  27098. 0xff0d9541,
  27099. 0xf104984a,
  27100. 0xab73d323,
  27101. 0xa57ade28,
  27102. 0xb761c935,
  27103. 0xb968c43e,
  27104. 0x9357e70f,
  27105. 0x9d5eea04,
  27106. 0x8f45fd19,
  27107. 0x814cf012,
  27108. 0x3bab6bcb,
  27109. 0x35a266c0,
  27110. 0x27b971dd,
  27111. 0x29b07cd6,
  27112. 0x038f5fe7,
  27113. 0x0d8652ec,
  27114. 0x1f9d45f1,
  27115. 0x119448fa,
  27116. 0x4be30393,
  27117. 0x45ea0e98,
  27118. 0x57f11985,
  27119. 0x59f8148e,
  27120. 0x73c737bf,
  27121. 0x7dce3ab4,
  27122. 0x6fd52da9,
  27123. 0x61dc20a2,
  27124. 0xad766df6,
  27125. 0xa37f60fd,
  27126. 0xb16477e0,
  27127. 0xbf6d7aeb,
  27128. 0x955259da,
  27129. 0x9b5b54d1,
  27130. 0x894043cc,
  27131. 0x87494ec7,
  27132. 0xdd3e05ae,
  27133. 0xd33708a5,
  27134. 0xc12c1fb8,
  27135. 0xcf2512b3,
  27136. 0xe51a3182,
  27137. 0xeb133c89,
  27138. 0xf9082b94,
  27139. 0xf701269f,
  27140. 0x4de6bd46,
  27141. 0x43efb04d,
  27142. 0x51f4a750,
  27143. 0x5ffdaa5b,
  27144. 0x75c2896a,
  27145. 0x7bcb8461,
  27146. 0x69d0937c,
  27147. 0x67d99e77,
  27148. 0x3daed51e,
  27149. 0x33a7d815,
  27150. 0x21bccf08,
  27151. 0x2fb5c203,
  27152. 0x058ae132,
  27153. 0x0b83ec39,
  27154. 0x1998fb24,
  27155. 0x1791f62f,
  27156. 0x764dd68d,
  27157. 0x7844db86,
  27158. 0x6a5fcc9b,
  27159. 0x6456c190,
  27160. 0x4e69e2a1,
  27161. 0x4060efaa,
  27162. 0x527bf8b7,
  27163. 0x5c72f5bc,
  27164. 0x0605bed5,
  27165. 0x080cb3de,
  27166. 0x1a17a4c3,
  27167. 0x141ea9c8,
  27168. 0x3e218af9,
  27169. 0x302887f2,
  27170. 0x223390ef,
  27171. 0x2c3a9de4,
  27172. 0x96dd063d,
  27173. 0x98d40b36,
  27174. 0x8acf1c2b,
  27175. 0x84c61120,
  27176. 0xaef93211,
  27177. 0xa0f03f1a,
  27178. 0xb2eb2807,
  27179. 0xbce2250c,
  27180. 0xe6956e65,
  27181. 0xe89c636e,
  27182. 0xfa877473,
  27183. 0xf48e7978,
  27184. 0xdeb15a49,
  27185. 0xd0b85742,
  27186. 0xc2a3405f,
  27187. 0xccaa4d54,
  27188. 0x41ecdaf7,
  27189. 0x4fe5d7fc,
  27190. 0x5dfec0e1,
  27191. 0x53f7cdea,
  27192. 0x79c8eedb,
  27193. 0x77c1e3d0,
  27194. 0x65daf4cd,
  27195. 0x6bd3f9c6,
  27196. 0x31a4b2af,
  27197. 0x3fadbfa4,
  27198. 0x2db6a8b9,
  27199. 0x23bfa5b2,
  27200. 0x09808683,
  27201. 0x07898b88,
  27202. 0x15929c95,
  27203. 0x1b9b919e,
  27204. 0xa17c0a47,
  27205. 0xaf75074c,
  27206. 0xbd6e1051,
  27207. 0xb3671d5a,
  27208. 0x99583e6b,
  27209. 0x97513360,
  27210. 0x854a247d,
  27211. 0x8b432976,
  27212. 0xd134621f,
  27213. 0xdf3d6f14,
  27214. 0xcd267809,
  27215. 0xc32f7502,
  27216. 0xe9105633,
  27217. 0xe7195b38,
  27218. 0xf5024c25,
  27219. 0xfb0b412e,
  27220. 0x9ad7618c,
  27221. 0x94de6c87,
  27222. 0x86c57b9a,
  27223. 0x88cc7691,
  27224. 0xa2f355a0,
  27225. 0xacfa58ab,
  27226. 0xbee14fb6,
  27227. 0xb0e842bd,
  27228. 0xea9f09d4,
  27229. 0xe49604df,
  27230. 0xf68d13c2,
  27231. 0xf8841ec9,
  27232. 0xd2bb3df8,
  27233. 0xdcb230f3,
  27234. 0xcea927ee,
  27235. 0xc0a02ae5,
  27236. 0x7a47b13c,
  27237. 0x744ebc37,
  27238. 0x6655ab2a,
  27239. 0x685ca621,
  27240. 0x42638510,
  27241. 0x4c6a881b,
  27242. 0x5e719f06,
  27243. 0x5078920d,
  27244. 0x0a0fd964,
  27245. 0x0406d46f,
  27246. 0x161dc372,
  27247. 0x1814ce79,
  27248. 0x322bed48,
  27249. 0x3c22e043,
  27250. 0x2e39f75e,
  27251. 0x2030fa55,
  27252. 0xec9ab701,
  27253. 0xe293ba0a,
  27254. 0xf088ad17,
  27255. 0xfe81a01c,
  27256. 0xd4be832d,
  27257. 0xdab78e26,
  27258. 0xc8ac993b,
  27259. 0xc6a59430,
  27260. 0x9cd2df59,
  27261. 0x92dbd252,
  27262. 0x80c0c54f,
  27263. 0x8ec9c844,
  27264. 0xa4f6eb75,
  27265. 0xaaffe67e,
  27266. 0xb8e4f163,
  27267. 0xb6edfc68,
  27268. 0x0c0a67b1,
  27269. 0x02036aba,
  27270. 0x10187da7,
  27271. 0x1e1170ac,
  27272. 0x342e539d,
  27273. 0x3a275e96,
  27274. 0x283c498b,
  27275. 0x26354480,
  27276. 0x7c420fe9,
  27277. 0x724b02e2,
  27278. 0x605015ff,
  27279. 0x6e5918f4,
  27280. 0x44663bc5,
  27281. 0x4a6f36ce,
  27282. 0x587421d3,
  27283. 0x567d2cd8,
  27284. 0x37a10c7a,
  27285. 0x39a80171,
  27286. 0x2bb3166c,
  27287. 0x25ba1b67,
  27288. 0x0f853856,
  27289. 0x018c355d,
  27290. 0x13972240,
  27291. 0x1d9e2f4b,
  27292. 0x47e96422,
  27293. 0x49e06929,
  27294. 0x5bfb7e34,
  27295. 0x55f2733f,
  27296. 0x7fcd500e,
  27297. 0x71c45d05,
  27298. 0x63df4a18,
  27299. 0x6dd64713,
  27300. 0xd731dcca,
  27301. 0xd938d1c1,
  27302. 0xcb23c6dc,
  27303. 0xc52acbd7,
  27304. 0xef15e8e6,
  27305. 0xe11ce5ed,
  27306. 0xf307f2f0,
  27307. 0xfd0efffb,
  27308. 0xa779b492,
  27309. 0xa970b999,
  27310. 0xbb6bae84,
  27311. 0xb562a38f,
  27312. 0x9f5d80be,
  27313. 0x91548db5,
  27314. 0x834f9aa8,
  27315. 0x8d4697a3
  27316. ]);
  27317. function expandKey128(cipherKey) {
  27318. var b = 176, result = new Uint8Array(b);
  27319. result.set(cipherKey);
  27320. for (var j = 16, i = 1; j < b; ++i) {
  27321. var t1 = result[j - 3], t2 = result[j - 2], t3 = result[j - 1], t4 = result[j - 4];
  27322. t1 = s[t1];
  27323. t2 = s[t2];
  27324. t3 = s[t3];
  27325. t4 = s[t4];
  27326. t1 = t1 ^ rcon[i];
  27327. for (var n = 0; n < 4; ++n) {
  27328. result[j] = t1 ^= result[j - 16];
  27329. j++;
  27330. result[j] = t2 ^= result[j - 16];
  27331. j++;
  27332. result[j] = t3 ^= result[j - 16];
  27333. j++;
  27334. result[j] = t4 ^= result[j - 16];
  27335. j++;
  27336. }
  27337. }
  27338. return result;
  27339. }
  27340. function decrypt128(input, key) {
  27341. var state = new Uint8Array(16);
  27342. state.set(input);
  27343. var i, j, k;
  27344. var t, u, v;
  27345. for (j = 0, k = 160; j < 16; ++j, ++k) {
  27346. state[j] ^= key[k];
  27347. }
  27348. for (i = 9; i >= 1; --i) {
  27349. t = state[13];
  27350. state[13] = state[9];
  27351. state[9] = state[5];
  27352. state[5] = state[1];
  27353. state[1] = t;
  27354. t = state[14];
  27355. u = state[10];
  27356. state[14] = state[6];
  27357. state[10] = state[2];
  27358. state[6] = t;
  27359. state[2] = u;
  27360. t = state[15];
  27361. u = state[11];
  27362. v = state[7];
  27363. state[15] = state[3];
  27364. state[11] = t;
  27365. state[7] = u;
  27366. state[3] = v;
  27367. for (j = 0; j < 16; ++j) {
  27368. state[j] = inv_s[state[j]];
  27369. }
  27370. for (j = 0, k = i * 16; j < 16; ++j, ++k) {
  27371. state[j] ^= key[k];
  27372. }
  27373. for (j = 0; j < 16; j += 4) {
  27374. var s0 = mix[state[j]], s1 = mix[state[j + 1]], s2 = mix[state[j + 2]], s3 = mix[state[j + 3]];
  27375. t = s0 ^ s1 >>> 8 ^ s1 << 24 ^ s2 >>> 16 ^ s2 << 16 ^ s3 >>> 24 ^ s3 << 8;
  27376. state[j] = t >>> 24 & 0xFF;
  27377. state[j + 1] = t >> 16 & 0xFF;
  27378. state[j + 2] = t >> 8 & 0xFF;
  27379. state[j + 3] = t & 0xFF;
  27380. }
  27381. }
  27382. t = state[13];
  27383. state[13] = state[9];
  27384. state[9] = state[5];
  27385. state[5] = state[1];
  27386. state[1] = t;
  27387. t = state[14];
  27388. u = state[10];
  27389. state[14] = state[6];
  27390. state[10] = state[2];
  27391. state[6] = t;
  27392. state[2] = u;
  27393. t = state[15];
  27394. u = state[11];
  27395. v = state[7];
  27396. state[15] = state[3];
  27397. state[11] = t;
  27398. state[7] = u;
  27399. state[3] = v;
  27400. for (j = 0; j < 16; ++j) {
  27401. state[j] = inv_s[state[j]];
  27402. state[j] ^= key[j];
  27403. }
  27404. return state;
  27405. }
  27406. function encrypt128(input, key) {
  27407. var t, u, v, k;
  27408. var state = new Uint8Array(16);
  27409. state.set(input);
  27410. for (j = 0; j < 16; ++j) {
  27411. state[j] ^= key[j];
  27412. }
  27413. for (i = 1; i < 10; i++) {
  27414. for (j = 0; j < 16; ++j) {
  27415. state[j] = s[state[j]];
  27416. }
  27417. v = state[1];
  27418. state[1] = state[5];
  27419. state[5] = state[9];
  27420. state[9] = state[13];
  27421. state[13] = v;
  27422. v = state[2];
  27423. u = state[6];
  27424. state[2] = state[10];
  27425. state[6] = state[14];
  27426. state[10] = v;
  27427. state[14] = u;
  27428. v = state[3];
  27429. u = state[7];
  27430. t = state[11];
  27431. state[3] = state[15];
  27432. state[7] = v;
  27433. state[11] = u;
  27434. state[15] = t;
  27435. for (var j = 0; j < 16; j += 4) {
  27436. var s0 = state[j + 0], s1 = state[j + 1];
  27437. var s2 = state[j + 2], s3 = state[j + 3];
  27438. t = s0 ^ s1 ^ s2 ^ s3;
  27439. state[j + 0] ^= t ^ mixCol[s0 ^ s1];
  27440. state[j + 1] ^= t ^ mixCol[s1 ^ s2];
  27441. state[j + 2] ^= t ^ mixCol[s2 ^ s3];
  27442. state[j + 3] ^= t ^ mixCol[s3 ^ s0];
  27443. }
  27444. for (j = 0, k = i * 16; j < 16; ++j, ++k) {
  27445. state[j] ^= key[k];
  27446. }
  27447. }
  27448. for (j = 0; j < 16; ++j) {
  27449. state[j] = s[state[j]];
  27450. }
  27451. v = state[1];
  27452. state[1] = state[5];
  27453. state[5] = state[9];
  27454. state[9] = state[13];
  27455. state[13] = v;
  27456. v = state[2];
  27457. u = state[6];
  27458. state[2] = state[10];
  27459. state[6] = state[14];
  27460. state[10] = v;
  27461. state[14] = u;
  27462. v = state[3];
  27463. u = state[7];
  27464. t = state[11];
  27465. state[3] = state[15];
  27466. state[7] = v;
  27467. state[11] = u;
  27468. state[15] = t;
  27469. for (j = 0, k = 160; j < 16; ++j, ++k) {
  27470. state[j] ^= key[k];
  27471. }
  27472. return state;
  27473. }
  27474. function AES128Cipher(key) {
  27475. this.key = expandKey128(key);
  27476. this.buffer = new Uint8Array(16);
  27477. this.bufferPosition = 0;
  27478. }
  27479. function decryptBlock2(data, finalize) {
  27480. var i, j, ii, sourceLength = data.length, buffer = this.buffer, bufferLength = this.bufferPosition, result = [], iv = this.iv;
  27481. for (i = 0; i < sourceLength; ++i) {
  27482. buffer[bufferLength] = data[i];
  27483. ++bufferLength;
  27484. if (bufferLength < 16) {
  27485. continue;
  27486. }
  27487. var plain = decrypt128(buffer, this.key);
  27488. for (j = 0; j < 16; ++j) {
  27489. plain[j] ^= iv[j];
  27490. }
  27491. iv = buffer;
  27492. result.push(plain);
  27493. buffer = new Uint8Array(16);
  27494. bufferLength = 0;
  27495. }
  27496. this.buffer = buffer;
  27497. this.bufferLength = bufferLength;
  27498. this.iv = iv;
  27499. if (result.length === 0) {
  27500. return new Uint8Array([]);
  27501. }
  27502. var outputLength = 16 * result.length;
  27503. if (finalize) {
  27504. var lastBlock = result[result.length - 1];
  27505. var psLen = lastBlock[15];
  27506. if (psLen <= 16) {
  27507. for (i = 15, ii = 16 - psLen; i >= ii; --i) {
  27508. if (lastBlock[i] !== psLen) {
  27509. psLen = 0;
  27510. break;
  27511. }
  27512. }
  27513. outputLength -= psLen;
  27514. result[result.length - 1] = lastBlock.subarray(0, 16 - psLen);
  27515. }
  27516. }
  27517. var output = new Uint8Array(outputLength);
  27518. for (i = 0, j = 0, ii = result.length; i < ii; ++i, j += 16) {
  27519. output.set(result[i], j);
  27520. }
  27521. return output;
  27522. }
  27523. AES128Cipher.prototype = {
  27524. decryptBlock: function AES128Cipher_decryptBlock(data, finalize) {
  27525. var i, sourceLength = data.length;
  27526. var buffer = this.buffer, bufferLength = this.bufferPosition;
  27527. for (i = 0; bufferLength < 16 && i < sourceLength; ++i, ++bufferLength) {
  27528. buffer[bufferLength] = data[i];
  27529. }
  27530. if (bufferLength < 16) {
  27531. this.bufferLength = bufferLength;
  27532. return new Uint8Array([]);
  27533. }
  27534. this.iv = buffer;
  27535. this.buffer = new Uint8Array(16);
  27536. this.bufferLength = 0;
  27537. this.decryptBlock = decryptBlock2;
  27538. return this.decryptBlock(data.subarray(16), finalize);
  27539. },
  27540. encrypt: function AES128Cipher_encrypt(data, iv) {
  27541. var i, j, ii, sourceLength = data.length, buffer = this.buffer, bufferLength = this.bufferPosition, result = [];
  27542. if (!iv) {
  27543. iv = new Uint8Array(16);
  27544. }
  27545. for (i = 0; i < sourceLength; ++i) {
  27546. buffer[bufferLength] = data[i];
  27547. ++bufferLength;
  27548. if (bufferLength < 16) {
  27549. continue;
  27550. }
  27551. for (j = 0; j < 16; ++j) {
  27552. buffer[j] ^= iv[j];
  27553. }
  27554. var cipher = encrypt128(buffer, this.key);
  27555. iv = cipher;
  27556. result.push(cipher);
  27557. buffer = new Uint8Array(16);
  27558. bufferLength = 0;
  27559. }
  27560. this.buffer = buffer;
  27561. this.bufferLength = bufferLength;
  27562. this.iv = iv;
  27563. if (result.length === 0) {
  27564. return new Uint8Array([]);
  27565. }
  27566. var outputLength = 16 * result.length;
  27567. var output = new Uint8Array(outputLength);
  27568. for (i = 0, j = 0, ii = result.length; i < ii; ++i, j += 16) {
  27569. output.set(result[i], j);
  27570. }
  27571. return output;
  27572. }
  27573. };
  27574. return AES128Cipher;
  27575. }();
  27576. var AES256Cipher = function AES256CipherClosure() {
  27577. var s = new Uint8Array([
  27578. 0x63,
  27579. 0x7c,
  27580. 0x77,
  27581. 0x7b,
  27582. 0xf2,
  27583. 0x6b,
  27584. 0x6f,
  27585. 0xc5,
  27586. 0x30,
  27587. 0x01,
  27588. 0x67,
  27589. 0x2b,
  27590. 0xfe,
  27591. 0xd7,
  27592. 0xab,
  27593. 0x76,
  27594. 0xca,
  27595. 0x82,
  27596. 0xc9,
  27597. 0x7d,
  27598. 0xfa,
  27599. 0x59,
  27600. 0x47,
  27601. 0xf0,
  27602. 0xad,
  27603. 0xd4,
  27604. 0xa2,
  27605. 0xaf,
  27606. 0x9c,
  27607. 0xa4,
  27608. 0x72,
  27609. 0xc0,
  27610. 0xb7,
  27611. 0xfd,
  27612. 0x93,
  27613. 0x26,
  27614. 0x36,
  27615. 0x3f,
  27616. 0xf7,
  27617. 0xcc,
  27618. 0x34,
  27619. 0xa5,
  27620. 0xe5,
  27621. 0xf1,
  27622. 0x71,
  27623. 0xd8,
  27624. 0x31,
  27625. 0x15,
  27626. 0x04,
  27627. 0xc7,
  27628. 0x23,
  27629. 0xc3,
  27630. 0x18,
  27631. 0x96,
  27632. 0x05,
  27633. 0x9a,
  27634. 0x07,
  27635. 0x12,
  27636. 0x80,
  27637. 0xe2,
  27638. 0xeb,
  27639. 0x27,
  27640. 0xb2,
  27641. 0x75,
  27642. 0x09,
  27643. 0x83,
  27644. 0x2c,
  27645. 0x1a,
  27646. 0x1b,
  27647. 0x6e,
  27648. 0x5a,
  27649. 0xa0,
  27650. 0x52,
  27651. 0x3b,
  27652. 0xd6,
  27653. 0xb3,
  27654. 0x29,
  27655. 0xe3,
  27656. 0x2f,
  27657. 0x84,
  27658. 0x53,
  27659. 0xd1,
  27660. 0x00,
  27661. 0xed,
  27662. 0x20,
  27663. 0xfc,
  27664. 0xb1,
  27665. 0x5b,
  27666. 0x6a,
  27667. 0xcb,
  27668. 0xbe,
  27669. 0x39,
  27670. 0x4a,
  27671. 0x4c,
  27672. 0x58,
  27673. 0xcf,
  27674. 0xd0,
  27675. 0xef,
  27676. 0xaa,
  27677. 0xfb,
  27678. 0x43,
  27679. 0x4d,
  27680. 0x33,
  27681. 0x85,
  27682. 0x45,
  27683. 0xf9,
  27684. 0x02,
  27685. 0x7f,
  27686. 0x50,
  27687. 0x3c,
  27688. 0x9f,
  27689. 0xa8,
  27690. 0x51,
  27691. 0xa3,
  27692. 0x40,
  27693. 0x8f,
  27694. 0x92,
  27695. 0x9d,
  27696. 0x38,
  27697. 0xf5,
  27698. 0xbc,
  27699. 0xb6,
  27700. 0xda,
  27701. 0x21,
  27702. 0x10,
  27703. 0xff,
  27704. 0xf3,
  27705. 0xd2,
  27706. 0xcd,
  27707. 0x0c,
  27708. 0x13,
  27709. 0xec,
  27710. 0x5f,
  27711. 0x97,
  27712. 0x44,
  27713. 0x17,
  27714. 0xc4,
  27715. 0xa7,
  27716. 0x7e,
  27717. 0x3d,
  27718. 0x64,
  27719. 0x5d,
  27720. 0x19,
  27721. 0x73,
  27722. 0x60,
  27723. 0x81,
  27724. 0x4f,
  27725. 0xdc,
  27726. 0x22,
  27727. 0x2a,
  27728. 0x90,
  27729. 0x88,
  27730. 0x46,
  27731. 0xee,
  27732. 0xb8,
  27733. 0x14,
  27734. 0xde,
  27735. 0x5e,
  27736. 0x0b,
  27737. 0xdb,
  27738. 0xe0,
  27739. 0x32,
  27740. 0x3a,
  27741. 0x0a,
  27742. 0x49,
  27743. 0x06,
  27744. 0x24,
  27745. 0x5c,
  27746. 0xc2,
  27747. 0xd3,
  27748. 0xac,
  27749. 0x62,
  27750. 0x91,
  27751. 0x95,
  27752. 0xe4,
  27753. 0x79,
  27754. 0xe7,
  27755. 0xc8,
  27756. 0x37,
  27757. 0x6d,
  27758. 0x8d,
  27759. 0xd5,
  27760. 0x4e,
  27761. 0xa9,
  27762. 0x6c,
  27763. 0x56,
  27764. 0xf4,
  27765. 0xea,
  27766. 0x65,
  27767. 0x7a,
  27768. 0xae,
  27769. 0x08,
  27770. 0xba,
  27771. 0x78,
  27772. 0x25,
  27773. 0x2e,
  27774. 0x1c,
  27775. 0xa6,
  27776. 0xb4,
  27777. 0xc6,
  27778. 0xe8,
  27779. 0xdd,
  27780. 0x74,
  27781. 0x1f,
  27782. 0x4b,
  27783. 0xbd,
  27784. 0x8b,
  27785. 0x8a,
  27786. 0x70,
  27787. 0x3e,
  27788. 0xb5,
  27789. 0x66,
  27790. 0x48,
  27791. 0x03,
  27792. 0xf6,
  27793. 0x0e,
  27794. 0x61,
  27795. 0x35,
  27796. 0x57,
  27797. 0xb9,
  27798. 0x86,
  27799. 0xc1,
  27800. 0x1d,
  27801. 0x9e,
  27802. 0xe1,
  27803. 0xf8,
  27804. 0x98,
  27805. 0x11,
  27806. 0x69,
  27807. 0xd9,
  27808. 0x8e,
  27809. 0x94,
  27810. 0x9b,
  27811. 0x1e,
  27812. 0x87,
  27813. 0xe9,
  27814. 0xce,
  27815. 0x55,
  27816. 0x28,
  27817. 0xdf,
  27818. 0x8c,
  27819. 0xa1,
  27820. 0x89,
  27821. 0x0d,
  27822. 0xbf,
  27823. 0xe6,
  27824. 0x42,
  27825. 0x68,
  27826. 0x41,
  27827. 0x99,
  27828. 0x2d,
  27829. 0x0f,
  27830. 0xb0,
  27831. 0x54,
  27832. 0xbb,
  27833. 0x16
  27834. ]);
  27835. var inv_s = new Uint8Array([
  27836. 0x52,
  27837. 0x09,
  27838. 0x6a,
  27839. 0xd5,
  27840. 0x30,
  27841. 0x36,
  27842. 0xa5,
  27843. 0x38,
  27844. 0xbf,
  27845. 0x40,
  27846. 0xa3,
  27847. 0x9e,
  27848. 0x81,
  27849. 0xf3,
  27850. 0xd7,
  27851. 0xfb,
  27852. 0x7c,
  27853. 0xe3,
  27854. 0x39,
  27855. 0x82,
  27856. 0x9b,
  27857. 0x2f,
  27858. 0xff,
  27859. 0x87,
  27860. 0x34,
  27861. 0x8e,
  27862. 0x43,
  27863. 0x44,
  27864. 0xc4,
  27865. 0xde,
  27866. 0xe9,
  27867. 0xcb,
  27868. 0x54,
  27869. 0x7b,
  27870. 0x94,
  27871. 0x32,
  27872. 0xa6,
  27873. 0xc2,
  27874. 0x23,
  27875. 0x3d,
  27876. 0xee,
  27877. 0x4c,
  27878. 0x95,
  27879. 0x0b,
  27880. 0x42,
  27881. 0xfa,
  27882. 0xc3,
  27883. 0x4e,
  27884. 0x08,
  27885. 0x2e,
  27886. 0xa1,
  27887. 0x66,
  27888. 0x28,
  27889. 0xd9,
  27890. 0x24,
  27891. 0xb2,
  27892. 0x76,
  27893. 0x5b,
  27894. 0xa2,
  27895. 0x49,
  27896. 0x6d,
  27897. 0x8b,
  27898. 0xd1,
  27899. 0x25,
  27900. 0x72,
  27901. 0xf8,
  27902. 0xf6,
  27903. 0x64,
  27904. 0x86,
  27905. 0x68,
  27906. 0x98,
  27907. 0x16,
  27908. 0xd4,
  27909. 0xa4,
  27910. 0x5c,
  27911. 0xcc,
  27912. 0x5d,
  27913. 0x65,
  27914. 0xb6,
  27915. 0x92,
  27916. 0x6c,
  27917. 0x70,
  27918. 0x48,
  27919. 0x50,
  27920. 0xfd,
  27921. 0xed,
  27922. 0xb9,
  27923. 0xda,
  27924. 0x5e,
  27925. 0x15,
  27926. 0x46,
  27927. 0x57,
  27928. 0xa7,
  27929. 0x8d,
  27930. 0x9d,
  27931. 0x84,
  27932. 0x90,
  27933. 0xd8,
  27934. 0xab,
  27935. 0x00,
  27936. 0x8c,
  27937. 0xbc,
  27938. 0xd3,
  27939. 0x0a,
  27940. 0xf7,
  27941. 0xe4,
  27942. 0x58,
  27943. 0x05,
  27944. 0xb8,
  27945. 0xb3,
  27946. 0x45,
  27947. 0x06,
  27948. 0xd0,
  27949. 0x2c,
  27950. 0x1e,
  27951. 0x8f,
  27952. 0xca,
  27953. 0x3f,
  27954. 0x0f,
  27955. 0x02,
  27956. 0xc1,
  27957. 0xaf,
  27958. 0xbd,
  27959. 0x03,
  27960. 0x01,
  27961. 0x13,
  27962. 0x8a,
  27963. 0x6b,
  27964. 0x3a,
  27965. 0x91,
  27966. 0x11,
  27967. 0x41,
  27968. 0x4f,
  27969. 0x67,
  27970. 0xdc,
  27971. 0xea,
  27972. 0x97,
  27973. 0xf2,
  27974. 0xcf,
  27975. 0xce,
  27976. 0xf0,
  27977. 0xb4,
  27978. 0xe6,
  27979. 0x73,
  27980. 0x96,
  27981. 0xac,
  27982. 0x74,
  27983. 0x22,
  27984. 0xe7,
  27985. 0xad,
  27986. 0x35,
  27987. 0x85,
  27988. 0xe2,
  27989. 0xf9,
  27990. 0x37,
  27991. 0xe8,
  27992. 0x1c,
  27993. 0x75,
  27994. 0xdf,
  27995. 0x6e,
  27996. 0x47,
  27997. 0xf1,
  27998. 0x1a,
  27999. 0x71,
  28000. 0x1d,
  28001. 0x29,
  28002. 0xc5,
  28003. 0x89,
  28004. 0x6f,
  28005. 0xb7,
  28006. 0x62,
  28007. 0x0e,
  28008. 0xaa,
  28009. 0x18,
  28010. 0xbe,
  28011. 0x1b,
  28012. 0xfc,
  28013. 0x56,
  28014. 0x3e,
  28015. 0x4b,
  28016. 0xc6,
  28017. 0xd2,
  28018. 0x79,
  28019. 0x20,
  28020. 0x9a,
  28021. 0xdb,
  28022. 0xc0,
  28023. 0xfe,
  28024. 0x78,
  28025. 0xcd,
  28026. 0x5a,
  28027. 0xf4,
  28028. 0x1f,
  28029. 0xdd,
  28030. 0xa8,
  28031. 0x33,
  28032. 0x88,
  28033. 0x07,
  28034. 0xc7,
  28035. 0x31,
  28036. 0xb1,
  28037. 0x12,
  28038. 0x10,
  28039. 0x59,
  28040. 0x27,
  28041. 0x80,
  28042. 0xec,
  28043. 0x5f,
  28044. 0x60,
  28045. 0x51,
  28046. 0x7f,
  28047. 0xa9,
  28048. 0x19,
  28049. 0xb5,
  28050. 0x4a,
  28051. 0x0d,
  28052. 0x2d,
  28053. 0xe5,
  28054. 0x7a,
  28055. 0x9f,
  28056. 0x93,
  28057. 0xc9,
  28058. 0x9c,
  28059. 0xef,
  28060. 0xa0,
  28061. 0xe0,
  28062. 0x3b,
  28063. 0x4d,
  28064. 0xae,
  28065. 0x2a,
  28066. 0xf5,
  28067. 0xb0,
  28068. 0xc8,
  28069. 0xeb,
  28070. 0xbb,
  28071. 0x3c,
  28072. 0x83,
  28073. 0x53,
  28074. 0x99,
  28075. 0x61,
  28076. 0x17,
  28077. 0x2b,
  28078. 0x04,
  28079. 0x7e,
  28080. 0xba,
  28081. 0x77,
  28082. 0xd6,
  28083. 0x26,
  28084. 0xe1,
  28085. 0x69,
  28086. 0x14,
  28087. 0x63,
  28088. 0x55,
  28089. 0x21,
  28090. 0x0c,
  28091. 0x7d
  28092. ]);
  28093. var mixCol = new Uint8Array(256);
  28094. for (var i = 0; i < 256; i++) {
  28095. if (i < 128) {
  28096. mixCol[i] = i << 1;
  28097. } else {
  28098. mixCol[i] = i << 1 ^ 0x1b;
  28099. }
  28100. }
  28101. var mix = new Uint32Array([
  28102. 0x00000000,
  28103. 0x0e090d0b,
  28104. 0x1c121a16,
  28105. 0x121b171d,
  28106. 0x3824342c,
  28107. 0x362d3927,
  28108. 0x24362e3a,
  28109. 0x2a3f2331,
  28110. 0x70486858,
  28111. 0x7e416553,
  28112. 0x6c5a724e,
  28113. 0x62537f45,
  28114. 0x486c5c74,
  28115. 0x4665517f,
  28116. 0x547e4662,
  28117. 0x5a774b69,
  28118. 0xe090d0b0,
  28119. 0xee99ddbb,
  28120. 0xfc82caa6,
  28121. 0xf28bc7ad,
  28122. 0xd8b4e49c,
  28123. 0xd6bde997,
  28124. 0xc4a6fe8a,
  28125. 0xcaaff381,
  28126. 0x90d8b8e8,
  28127. 0x9ed1b5e3,
  28128. 0x8ccaa2fe,
  28129. 0x82c3aff5,
  28130. 0xa8fc8cc4,
  28131. 0xa6f581cf,
  28132. 0xb4ee96d2,
  28133. 0xbae79bd9,
  28134. 0xdb3bbb7b,
  28135. 0xd532b670,
  28136. 0xc729a16d,
  28137. 0xc920ac66,
  28138. 0xe31f8f57,
  28139. 0xed16825c,
  28140. 0xff0d9541,
  28141. 0xf104984a,
  28142. 0xab73d323,
  28143. 0xa57ade28,
  28144. 0xb761c935,
  28145. 0xb968c43e,
  28146. 0x9357e70f,
  28147. 0x9d5eea04,
  28148. 0x8f45fd19,
  28149. 0x814cf012,
  28150. 0x3bab6bcb,
  28151. 0x35a266c0,
  28152. 0x27b971dd,
  28153. 0x29b07cd6,
  28154. 0x038f5fe7,
  28155. 0x0d8652ec,
  28156. 0x1f9d45f1,
  28157. 0x119448fa,
  28158. 0x4be30393,
  28159. 0x45ea0e98,
  28160. 0x57f11985,
  28161. 0x59f8148e,
  28162. 0x73c737bf,
  28163. 0x7dce3ab4,
  28164. 0x6fd52da9,
  28165. 0x61dc20a2,
  28166. 0xad766df6,
  28167. 0xa37f60fd,
  28168. 0xb16477e0,
  28169. 0xbf6d7aeb,
  28170. 0x955259da,
  28171. 0x9b5b54d1,
  28172. 0x894043cc,
  28173. 0x87494ec7,
  28174. 0xdd3e05ae,
  28175. 0xd33708a5,
  28176. 0xc12c1fb8,
  28177. 0xcf2512b3,
  28178. 0xe51a3182,
  28179. 0xeb133c89,
  28180. 0xf9082b94,
  28181. 0xf701269f,
  28182. 0x4de6bd46,
  28183. 0x43efb04d,
  28184. 0x51f4a750,
  28185. 0x5ffdaa5b,
  28186. 0x75c2896a,
  28187. 0x7bcb8461,
  28188. 0x69d0937c,
  28189. 0x67d99e77,
  28190. 0x3daed51e,
  28191. 0x33a7d815,
  28192. 0x21bccf08,
  28193. 0x2fb5c203,
  28194. 0x058ae132,
  28195. 0x0b83ec39,
  28196. 0x1998fb24,
  28197. 0x1791f62f,
  28198. 0x764dd68d,
  28199. 0x7844db86,
  28200. 0x6a5fcc9b,
  28201. 0x6456c190,
  28202. 0x4e69e2a1,
  28203. 0x4060efaa,
  28204. 0x527bf8b7,
  28205. 0x5c72f5bc,
  28206. 0x0605bed5,
  28207. 0x080cb3de,
  28208. 0x1a17a4c3,
  28209. 0x141ea9c8,
  28210. 0x3e218af9,
  28211. 0x302887f2,
  28212. 0x223390ef,
  28213. 0x2c3a9de4,
  28214. 0x96dd063d,
  28215. 0x98d40b36,
  28216. 0x8acf1c2b,
  28217. 0x84c61120,
  28218. 0xaef93211,
  28219. 0xa0f03f1a,
  28220. 0xb2eb2807,
  28221. 0xbce2250c,
  28222. 0xe6956e65,
  28223. 0xe89c636e,
  28224. 0xfa877473,
  28225. 0xf48e7978,
  28226. 0xdeb15a49,
  28227. 0xd0b85742,
  28228. 0xc2a3405f,
  28229. 0xccaa4d54,
  28230. 0x41ecdaf7,
  28231. 0x4fe5d7fc,
  28232. 0x5dfec0e1,
  28233. 0x53f7cdea,
  28234. 0x79c8eedb,
  28235. 0x77c1e3d0,
  28236. 0x65daf4cd,
  28237. 0x6bd3f9c6,
  28238. 0x31a4b2af,
  28239. 0x3fadbfa4,
  28240. 0x2db6a8b9,
  28241. 0x23bfa5b2,
  28242. 0x09808683,
  28243. 0x07898b88,
  28244. 0x15929c95,
  28245. 0x1b9b919e,
  28246. 0xa17c0a47,
  28247. 0xaf75074c,
  28248. 0xbd6e1051,
  28249. 0xb3671d5a,
  28250. 0x99583e6b,
  28251. 0x97513360,
  28252. 0x854a247d,
  28253. 0x8b432976,
  28254. 0xd134621f,
  28255. 0xdf3d6f14,
  28256. 0xcd267809,
  28257. 0xc32f7502,
  28258. 0xe9105633,
  28259. 0xe7195b38,
  28260. 0xf5024c25,
  28261. 0xfb0b412e,
  28262. 0x9ad7618c,
  28263. 0x94de6c87,
  28264. 0x86c57b9a,
  28265. 0x88cc7691,
  28266. 0xa2f355a0,
  28267. 0xacfa58ab,
  28268. 0xbee14fb6,
  28269. 0xb0e842bd,
  28270. 0xea9f09d4,
  28271. 0xe49604df,
  28272. 0xf68d13c2,
  28273. 0xf8841ec9,
  28274. 0xd2bb3df8,
  28275. 0xdcb230f3,
  28276. 0xcea927ee,
  28277. 0xc0a02ae5,
  28278. 0x7a47b13c,
  28279. 0x744ebc37,
  28280. 0x6655ab2a,
  28281. 0x685ca621,
  28282. 0x42638510,
  28283. 0x4c6a881b,
  28284. 0x5e719f06,
  28285. 0x5078920d,
  28286. 0x0a0fd964,
  28287. 0x0406d46f,
  28288. 0x161dc372,
  28289. 0x1814ce79,
  28290. 0x322bed48,
  28291. 0x3c22e043,
  28292. 0x2e39f75e,
  28293. 0x2030fa55,
  28294. 0xec9ab701,
  28295. 0xe293ba0a,
  28296. 0xf088ad17,
  28297. 0xfe81a01c,
  28298. 0xd4be832d,
  28299. 0xdab78e26,
  28300. 0xc8ac993b,
  28301. 0xc6a59430,
  28302. 0x9cd2df59,
  28303. 0x92dbd252,
  28304. 0x80c0c54f,
  28305. 0x8ec9c844,
  28306. 0xa4f6eb75,
  28307. 0xaaffe67e,
  28308. 0xb8e4f163,
  28309. 0xb6edfc68,
  28310. 0x0c0a67b1,
  28311. 0x02036aba,
  28312. 0x10187da7,
  28313. 0x1e1170ac,
  28314. 0x342e539d,
  28315. 0x3a275e96,
  28316. 0x283c498b,
  28317. 0x26354480,
  28318. 0x7c420fe9,
  28319. 0x724b02e2,
  28320. 0x605015ff,
  28321. 0x6e5918f4,
  28322. 0x44663bc5,
  28323. 0x4a6f36ce,
  28324. 0x587421d3,
  28325. 0x567d2cd8,
  28326. 0x37a10c7a,
  28327. 0x39a80171,
  28328. 0x2bb3166c,
  28329. 0x25ba1b67,
  28330. 0x0f853856,
  28331. 0x018c355d,
  28332. 0x13972240,
  28333. 0x1d9e2f4b,
  28334. 0x47e96422,
  28335. 0x49e06929,
  28336. 0x5bfb7e34,
  28337. 0x55f2733f,
  28338. 0x7fcd500e,
  28339. 0x71c45d05,
  28340. 0x63df4a18,
  28341. 0x6dd64713,
  28342. 0xd731dcca,
  28343. 0xd938d1c1,
  28344. 0xcb23c6dc,
  28345. 0xc52acbd7,
  28346. 0xef15e8e6,
  28347. 0xe11ce5ed,
  28348. 0xf307f2f0,
  28349. 0xfd0efffb,
  28350. 0xa779b492,
  28351. 0xa970b999,
  28352. 0xbb6bae84,
  28353. 0xb562a38f,
  28354. 0x9f5d80be,
  28355. 0x91548db5,
  28356. 0x834f9aa8,
  28357. 0x8d4697a3
  28358. ]);
  28359. function expandKey256(cipherKey) {
  28360. var b = 240, result = new Uint8Array(b);
  28361. var r = 1;
  28362. result.set(cipherKey);
  28363. for (var j = 32, i = 1; j < b; ++i) {
  28364. if (j % 32 === 16) {
  28365. t1 = s[t1];
  28366. t2 = s[t2];
  28367. t3 = s[t3];
  28368. t4 = s[t4];
  28369. } else if (j % 32 === 0) {
  28370. var t1 = result[j - 3], t2 = result[j - 2], t3 = result[j - 1], t4 = result[j - 4];
  28371. t1 = s[t1];
  28372. t2 = s[t2];
  28373. t3 = s[t3];
  28374. t4 = s[t4];
  28375. t1 = t1 ^ r;
  28376. if ((r <<= 1) >= 256) {
  28377. r = (r ^ 0x1b) & 0xFF;
  28378. }
  28379. }
  28380. for (var n = 0; n < 4; ++n) {
  28381. result[j] = t1 ^= result[j - 32];
  28382. j++;
  28383. result[j] = t2 ^= result[j - 32];
  28384. j++;
  28385. result[j] = t3 ^= result[j - 32];
  28386. j++;
  28387. result[j] = t4 ^= result[j - 32];
  28388. j++;
  28389. }
  28390. }
  28391. return result;
  28392. }
  28393. function decrypt256(input, key) {
  28394. var state = new Uint8Array(16);
  28395. state.set(input);
  28396. var i, j, k;
  28397. var t, u, v;
  28398. for (j = 0, k = 224; j < 16; ++j, ++k) {
  28399. state[j] ^= key[k];
  28400. }
  28401. for (i = 13; i >= 1; --i) {
  28402. t = state[13];
  28403. state[13] = state[9];
  28404. state[9] = state[5];
  28405. state[5] = state[1];
  28406. state[1] = t;
  28407. t = state[14];
  28408. u = state[10];
  28409. state[14] = state[6];
  28410. state[10] = state[2];
  28411. state[6] = t;
  28412. state[2] = u;
  28413. t = state[15];
  28414. u = state[11];
  28415. v = state[7];
  28416. state[15] = state[3];
  28417. state[11] = t;
  28418. state[7] = u;
  28419. state[3] = v;
  28420. for (j = 0; j < 16; ++j) {
  28421. state[j] = inv_s[state[j]];
  28422. }
  28423. for (j = 0, k = i * 16; j < 16; ++j, ++k) {
  28424. state[j] ^= key[k];
  28425. }
  28426. for (j = 0; j < 16; j += 4) {
  28427. var s0 = mix[state[j]], s1 = mix[state[j + 1]], s2 = mix[state[j + 2]], s3 = mix[state[j + 3]];
  28428. t = s0 ^ s1 >>> 8 ^ s1 << 24 ^ s2 >>> 16 ^ s2 << 16 ^ s3 >>> 24 ^ s3 << 8;
  28429. state[j] = t >>> 24 & 0xFF;
  28430. state[j + 1] = t >> 16 & 0xFF;
  28431. state[j + 2] = t >> 8 & 0xFF;
  28432. state[j + 3] = t & 0xFF;
  28433. }
  28434. }
  28435. t = state[13];
  28436. state[13] = state[9];
  28437. state[9] = state[5];
  28438. state[5] = state[1];
  28439. state[1] = t;
  28440. t = state[14];
  28441. u = state[10];
  28442. state[14] = state[6];
  28443. state[10] = state[2];
  28444. state[6] = t;
  28445. state[2] = u;
  28446. t = state[15];
  28447. u = state[11];
  28448. v = state[7];
  28449. state[15] = state[3];
  28450. state[11] = t;
  28451. state[7] = u;
  28452. state[3] = v;
  28453. for (j = 0; j < 16; ++j) {
  28454. state[j] = inv_s[state[j]];
  28455. state[j] ^= key[j];
  28456. }
  28457. return state;
  28458. }
  28459. function encrypt256(input, key) {
  28460. var t, u, v, k;
  28461. var state = new Uint8Array(16);
  28462. state.set(input);
  28463. for (j = 0; j < 16; ++j) {
  28464. state[j] ^= key[j];
  28465. }
  28466. for (i = 1; i < 14; i++) {
  28467. for (j = 0; j < 16; ++j) {
  28468. state[j] = s[state[j]];
  28469. }
  28470. v = state[1];
  28471. state[1] = state[5];
  28472. state[5] = state[9];
  28473. state[9] = state[13];
  28474. state[13] = v;
  28475. v = state[2];
  28476. u = state[6];
  28477. state[2] = state[10];
  28478. state[6] = state[14];
  28479. state[10] = v;
  28480. state[14] = u;
  28481. v = state[3];
  28482. u = state[7];
  28483. t = state[11];
  28484. state[3] = state[15];
  28485. state[7] = v;
  28486. state[11] = u;
  28487. state[15] = t;
  28488. for (var j = 0; j < 16; j += 4) {
  28489. var s0 = state[j + 0], s1 = state[j + 1];
  28490. var s2 = state[j + 2], s3 = state[j + 3];
  28491. t = s0 ^ s1 ^ s2 ^ s3;
  28492. state[j + 0] ^= t ^ mixCol[s0 ^ s1];
  28493. state[j + 1] ^= t ^ mixCol[s1 ^ s2];
  28494. state[j + 2] ^= t ^ mixCol[s2 ^ s3];
  28495. state[j + 3] ^= t ^ mixCol[s3 ^ s0];
  28496. }
  28497. for (j = 0, k = i * 16; j < 16; ++j, ++k) {
  28498. state[j] ^= key[k];
  28499. }
  28500. }
  28501. for (j = 0; j < 16; ++j) {
  28502. state[j] = s[state[j]];
  28503. }
  28504. v = state[1];
  28505. state[1] = state[5];
  28506. state[5] = state[9];
  28507. state[9] = state[13];
  28508. state[13] = v;
  28509. v = state[2];
  28510. u = state[6];
  28511. state[2] = state[10];
  28512. state[6] = state[14];
  28513. state[10] = v;
  28514. state[14] = u;
  28515. v = state[3];
  28516. u = state[7];
  28517. t = state[11];
  28518. state[3] = state[15];
  28519. state[7] = v;
  28520. state[11] = u;
  28521. state[15] = t;
  28522. for (j = 0, k = 224; j < 16; ++j, ++k) {
  28523. state[j] ^= key[k];
  28524. }
  28525. return state;
  28526. }
  28527. function AES256Cipher(key) {
  28528. this.key = expandKey256(key);
  28529. this.buffer = new Uint8Array(16);
  28530. this.bufferPosition = 0;
  28531. }
  28532. function decryptBlock2(data, finalize) {
  28533. var i, j, ii, sourceLength = data.length, buffer = this.buffer, bufferLength = this.bufferPosition, result = [], iv = this.iv;
  28534. for (i = 0; i < sourceLength; ++i) {
  28535. buffer[bufferLength] = data[i];
  28536. ++bufferLength;
  28537. if (bufferLength < 16) {
  28538. continue;
  28539. }
  28540. var plain = decrypt256(buffer, this.key);
  28541. for (j = 0; j < 16; ++j) {
  28542. plain[j] ^= iv[j];
  28543. }
  28544. iv = buffer;
  28545. result.push(plain);
  28546. buffer = new Uint8Array(16);
  28547. bufferLength = 0;
  28548. }
  28549. this.buffer = buffer;
  28550. this.bufferLength = bufferLength;
  28551. this.iv = iv;
  28552. if (result.length === 0) {
  28553. return new Uint8Array([]);
  28554. }
  28555. var outputLength = 16 * result.length;
  28556. if (finalize) {
  28557. var lastBlock = result[result.length - 1];
  28558. var psLen = lastBlock[15];
  28559. if (psLen <= 16) {
  28560. for (i = 15, ii = 16 - psLen; i >= ii; --i) {
  28561. if (lastBlock[i] !== psLen) {
  28562. psLen = 0;
  28563. break;
  28564. }
  28565. }
  28566. outputLength -= psLen;
  28567. result[result.length - 1] = lastBlock.subarray(0, 16 - psLen);
  28568. }
  28569. }
  28570. var output = new Uint8Array(outputLength);
  28571. for (i = 0, j = 0, ii = result.length; i < ii; ++i, j += 16) {
  28572. output.set(result[i], j);
  28573. }
  28574. return output;
  28575. }
  28576. AES256Cipher.prototype = {
  28577. decryptBlock: function AES256Cipher_decryptBlock(data, finalize, iv) {
  28578. var i, sourceLength = data.length;
  28579. var buffer = this.buffer, bufferLength = this.bufferPosition;
  28580. if (iv) {
  28581. this.iv = iv;
  28582. } else {
  28583. for (i = 0; bufferLength < 16 && i < sourceLength; ++i, ++bufferLength) {
  28584. buffer[bufferLength] = data[i];
  28585. }
  28586. if (bufferLength < 16) {
  28587. this.bufferLength = bufferLength;
  28588. return new Uint8Array([]);
  28589. }
  28590. this.iv = buffer;
  28591. data = data.subarray(16);
  28592. }
  28593. this.buffer = new Uint8Array(16);
  28594. this.bufferLength = 0;
  28595. this.decryptBlock = decryptBlock2;
  28596. return this.decryptBlock(data, finalize);
  28597. },
  28598. encrypt: function AES256Cipher_encrypt(data, iv) {
  28599. var i, j, ii, sourceLength = data.length, buffer = this.buffer, bufferLength = this.bufferPosition, result = [];
  28600. if (!iv) {
  28601. iv = new Uint8Array(16);
  28602. }
  28603. for (i = 0; i < sourceLength; ++i) {
  28604. buffer[bufferLength] = data[i];
  28605. ++bufferLength;
  28606. if (bufferLength < 16) {
  28607. continue;
  28608. }
  28609. for (j = 0; j < 16; ++j) {
  28610. buffer[j] ^= iv[j];
  28611. }
  28612. var cipher = encrypt256(buffer, this.key);
  28613. this.iv = cipher;
  28614. result.push(cipher);
  28615. buffer = new Uint8Array(16);
  28616. bufferLength = 0;
  28617. }
  28618. this.buffer = buffer;
  28619. this.bufferLength = bufferLength;
  28620. this.iv = iv;
  28621. if (result.length === 0) {
  28622. return new Uint8Array([]);
  28623. }
  28624. var outputLength = 16 * result.length;
  28625. var output = new Uint8Array(outputLength);
  28626. for (i = 0, j = 0, ii = result.length; i < ii; ++i, j += 16) {
  28627. output.set(result[i], j);
  28628. }
  28629. return output;
  28630. }
  28631. };
  28632. return AES256Cipher;
  28633. }();
  28634. var PDF17 = function PDF17Closure() {
  28635. function compareByteArrays(array1, array2) {
  28636. if (array1.length !== array2.length) {
  28637. return false;
  28638. }
  28639. for (var i = 0; i < array1.length; i++) {
  28640. if (array1[i] !== array2[i]) {
  28641. return false;
  28642. }
  28643. }
  28644. return true;
  28645. }
  28646. function PDF17() {
  28647. }
  28648. PDF17.prototype = {
  28649. checkOwnerPassword: function PDF17_checkOwnerPassword(password, ownerValidationSalt, userBytes, ownerPassword) {
  28650. var hashData = new Uint8Array(password.length + 56);
  28651. hashData.set(password, 0);
  28652. hashData.set(ownerValidationSalt, password.length);
  28653. hashData.set(userBytes, password.length + ownerValidationSalt.length);
  28654. var result = calculateSHA256(hashData, 0, hashData.length);
  28655. return compareByteArrays(result, ownerPassword);
  28656. },
  28657. checkUserPassword: function PDF17_checkUserPassword(password, userValidationSalt, userPassword) {
  28658. var hashData = new Uint8Array(password.length + 8);
  28659. hashData.set(password, 0);
  28660. hashData.set(userValidationSalt, password.length);
  28661. var result = calculateSHA256(hashData, 0, hashData.length);
  28662. return compareByteArrays(result, userPassword);
  28663. },
  28664. getOwnerKey: function PDF17_getOwnerKey(password, ownerKeySalt, userBytes, ownerEncryption) {
  28665. var hashData = new Uint8Array(password.length + 56);
  28666. hashData.set(password, 0);
  28667. hashData.set(ownerKeySalt, password.length);
  28668. hashData.set(userBytes, password.length + ownerKeySalt.length);
  28669. var key = calculateSHA256(hashData, 0, hashData.length);
  28670. var cipher = new AES256Cipher(key);
  28671. return cipher.decryptBlock(ownerEncryption, false, new Uint8Array(16));
  28672. },
  28673. getUserKey: function PDF17_getUserKey(password, userKeySalt, userEncryption) {
  28674. var hashData = new Uint8Array(password.length + 8);
  28675. hashData.set(password, 0);
  28676. hashData.set(userKeySalt, password.length);
  28677. var key = calculateSHA256(hashData, 0, hashData.length);
  28678. var cipher = new AES256Cipher(key);
  28679. return cipher.decryptBlock(userEncryption, false, new Uint8Array(16));
  28680. }
  28681. };
  28682. return PDF17;
  28683. }();
  28684. var PDF20 = function PDF20Closure() {
  28685. function concatArrays(array1, array2) {
  28686. var t = new Uint8Array(array1.length + array2.length);
  28687. t.set(array1, 0);
  28688. t.set(array2, array1.length);
  28689. return t;
  28690. }
  28691. function calculatePDF20Hash(password, input, userBytes) {
  28692. var k = calculateSHA256(input, 0, input.length).subarray(0, 32);
  28693. var e = [0];
  28694. var i = 0;
  28695. while (i < 64 || e[e.length - 1] > i - 32) {
  28696. var arrayLength = password.length + k.length + userBytes.length;
  28697. var k1 = new Uint8Array(arrayLength * 64);
  28698. var array = concatArrays(password, k);
  28699. array = concatArrays(array, userBytes);
  28700. for (var j = 0, pos = 0; j < 64; j++, pos += arrayLength) {
  28701. k1.set(array, pos);
  28702. }
  28703. var cipher = new AES128Cipher(k.subarray(0, 16));
  28704. e = cipher.encrypt(k1, k.subarray(16, 32));
  28705. var remainder = 0;
  28706. for (var z = 0; z < 16; z++) {
  28707. remainder *= 256 % 3;
  28708. remainder %= 3;
  28709. remainder += (e[z] >>> 0) % 3;
  28710. remainder %= 3;
  28711. }
  28712. if (remainder === 0) {
  28713. k = calculateSHA256(e, 0, e.length);
  28714. } else if (remainder === 1) {
  28715. k = calculateSHA384(e, 0, e.length);
  28716. } else if (remainder === 2) {
  28717. k = calculateSHA512(e, 0, e.length);
  28718. }
  28719. i++;
  28720. }
  28721. return k.subarray(0, 32);
  28722. }
  28723. function PDF20() {
  28724. }
  28725. function compareByteArrays(array1, array2) {
  28726. if (array1.length !== array2.length) {
  28727. return false;
  28728. }
  28729. for (var i = 0; i < array1.length; i++) {
  28730. if (array1[i] !== array2[i]) {
  28731. return false;
  28732. }
  28733. }
  28734. return true;
  28735. }
  28736. PDF20.prototype = {
  28737. hash: function PDF20_hash(password, concatBytes, userBytes) {
  28738. return calculatePDF20Hash(password, concatBytes, userBytes);
  28739. },
  28740. checkOwnerPassword: function PDF20_checkOwnerPassword(password, ownerValidationSalt, userBytes, ownerPassword) {
  28741. var hashData = new Uint8Array(password.length + 56);
  28742. hashData.set(password, 0);
  28743. hashData.set(ownerValidationSalt, password.length);
  28744. hashData.set(userBytes, password.length + ownerValidationSalt.length);
  28745. var result = calculatePDF20Hash(password, hashData, userBytes);
  28746. return compareByteArrays(result, ownerPassword);
  28747. },
  28748. checkUserPassword: function PDF20_checkUserPassword(password, userValidationSalt, userPassword) {
  28749. var hashData = new Uint8Array(password.length + 8);
  28750. hashData.set(password, 0);
  28751. hashData.set(userValidationSalt, password.length);
  28752. var result = calculatePDF20Hash(password, hashData, []);
  28753. return compareByteArrays(result, userPassword);
  28754. },
  28755. getOwnerKey: function PDF20_getOwnerKey(password, ownerKeySalt, userBytes, ownerEncryption) {
  28756. var hashData = new Uint8Array(password.length + 56);
  28757. hashData.set(password, 0);
  28758. hashData.set(ownerKeySalt, password.length);
  28759. hashData.set(userBytes, password.length + ownerKeySalt.length);
  28760. var key = calculatePDF20Hash(password, hashData, userBytes);
  28761. var cipher = new AES256Cipher(key);
  28762. return cipher.decryptBlock(ownerEncryption, false, new Uint8Array(16));
  28763. },
  28764. getUserKey: function PDF20_getUserKey(password, userKeySalt, userEncryption) {
  28765. var hashData = new Uint8Array(password.length + 8);
  28766. hashData.set(password, 0);
  28767. hashData.set(userKeySalt, password.length);
  28768. var key = calculatePDF20Hash(password, hashData, []);
  28769. var cipher = new AES256Cipher(key);
  28770. return cipher.decryptBlock(userEncryption, false, new Uint8Array(16));
  28771. }
  28772. };
  28773. return PDF20;
  28774. }();
  28775. var CipherTransform = function CipherTransformClosure() {
  28776. function CipherTransform(stringCipherConstructor, streamCipherConstructor) {
  28777. this.StringCipherConstructor = stringCipherConstructor;
  28778. this.StreamCipherConstructor = streamCipherConstructor;
  28779. }
  28780. CipherTransform.prototype = {
  28781. createStream: function CipherTransform_createStream(stream, length) {
  28782. var cipher = new this.StreamCipherConstructor();
  28783. return new DecryptStream(stream, length, function cipherTransformDecryptStream(data, finalize) {
  28784. return cipher.decryptBlock(data, finalize);
  28785. });
  28786. },
  28787. decryptString: function CipherTransform_decryptString(s) {
  28788. var cipher = new this.StringCipherConstructor();
  28789. var data = stringToBytes(s);
  28790. data = cipher.decryptBlock(data, true);
  28791. return bytesToString(data);
  28792. }
  28793. };
  28794. return CipherTransform;
  28795. }();
  28796. var CipherTransformFactory = function CipherTransformFactoryClosure() {
  28797. var defaultPasswordBytes = new Uint8Array([
  28798. 0x28,
  28799. 0xBF,
  28800. 0x4E,
  28801. 0x5E,
  28802. 0x4E,
  28803. 0x75,
  28804. 0x8A,
  28805. 0x41,
  28806. 0x64,
  28807. 0x00,
  28808. 0x4E,
  28809. 0x56,
  28810. 0xFF,
  28811. 0xFA,
  28812. 0x01,
  28813. 0x08,
  28814. 0x2E,
  28815. 0x2E,
  28816. 0x00,
  28817. 0xB6,
  28818. 0xD0,
  28819. 0x68,
  28820. 0x3E,
  28821. 0x80,
  28822. 0x2F,
  28823. 0x0C,
  28824. 0xA9,
  28825. 0xFE,
  28826. 0x64,
  28827. 0x53,
  28828. 0x69,
  28829. 0x7A
  28830. ]);
  28831. function createEncryptionKey20(revision, password, ownerPassword, ownerValidationSalt, ownerKeySalt, uBytes, userPassword, userValidationSalt, userKeySalt, ownerEncryption, userEncryption, perms) {
  28832. if (password) {
  28833. var passwordLength = Math.min(127, password.length);
  28834. password = password.subarray(0, passwordLength);
  28835. } else {
  28836. password = [];
  28837. }
  28838. var pdfAlgorithm;
  28839. if (revision === 6) {
  28840. pdfAlgorithm = new PDF20();
  28841. } else {
  28842. pdfAlgorithm = new PDF17();
  28843. }
  28844. if (pdfAlgorithm.checkUserPassword(password, userValidationSalt, userPassword)) {
  28845. return pdfAlgorithm.getUserKey(password, userKeySalt, userEncryption);
  28846. } else if (password.length && pdfAlgorithm.checkOwnerPassword(password, ownerValidationSalt, uBytes, ownerPassword)) {
  28847. return pdfAlgorithm.getOwnerKey(password, ownerKeySalt, uBytes, ownerEncryption);
  28848. }
  28849. return null;
  28850. }
  28851. function prepareKeyData(fileId, password, ownerPassword, userPassword, flags, revision, keyLength, encryptMetadata) {
  28852. var hashDataSize = 40 + ownerPassword.length + fileId.length;
  28853. var hashData = new Uint8Array(hashDataSize), i = 0, j, n;
  28854. if (password) {
  28855. n = Math.min(32, password.length);
  28856. for (; i < n; ++i) {
  28857. hashData[i] = password[i];
  28858. }
  28859. }
  28860. j = 0;
  28861. while (i < 32) {
  28862. hashData[i++] = defaultPasswordBytes[j++];
  28863. }
  28864. for (j = 0, n = ownerPassword.length; j < n; ++j) {
  28865. hashData[i++] = ownerPassword[j];
  28866. }
  28867. hashData[i++] = flags & 0xFF;
  28868. hashData[i++] = flags >> 8 & 0xFF;
  28869. hashData[i++] = flags >> 16 & 0xFF;
  28870. hashData[i++] = flags >>> 24 & 0xFF;
  28871. for (j = 0, n = fileId.length; j < n; ++j) {
  28872. hashData[i++] = fileId[j];
  28873. }
  28874. if (revision >= 4 && !encryptMetadata) {
  28875. hashData[i++] = 0xFF;
  28876. hashData[i++] = 0xFF;
  28877. hashData[i++] = 0xFF;
  28878. hashData[i++] = 0xFF;
  28879. }
  28880. var hash = calculateMD5(hashData, 0, i);
  28881. var keyLengthInBytes = keyLength >> 3;
  28882. if (revision >= 3) {
  28883. for (j = 0; j < 50; ++j) {
  28884. hash = calculateMD5(hash, 0, keyLengthInBytes);
  28885. }
  28886. }
  28887. var encryptionKey = hash.subarray(0, keyLengthInBytes);
  28888. var cipher, checkData;
  28889. if (revision >= 3) {
  28890. for (i = 0; i < 32; ++i) {
  28891. hashData[i] = defaultPasswordBytes[i];
  28892. }
  28893. for (j = 0, n = fileId.length; j < n; ++j) {
  28894. hashData[i++] = fileId[j];
  28895. }
  28896. cipher = new ARCFourCipher(encryptionKey);
  28897. checkData = cipher.encryptBlock(calculateMD5(hashData, 0, i));
  28898. n = encryptionKey.length;
  28899. var derivedKey = new Uint8Array(n), k;
  28900. for (j = 1; j <= 19; ++j) {
  28901. for (k = 0; k < n; ++k) {
  28902. derivedKey[k] = encryptionKey[k] ^ j;
  28903. }
  28904. cipher = new ARCFourCipher(derivedKey);
  28905. checkData = cipher.encryptBlock(checkData);
  28906. }
  28907. for (j = 0, n = checkData.length; j < n; ++j) {
  28908. if (userPassword[j] !== checkData[j]) {
  28909. return null;
  28910. }
  28911. }
  28912. } else {
  28913. cipher = new ARCFourCipher(encryptionKey);
  28914. checkData = cipher.encryptBlock(defaultPasswordBytes);
  28915. for (j = 0, n = checkData.length; j < n; ++j) {
  28916. if (userPassword[j] !== checkData[j]) {
  28917. return null;
  28918. }
  28919. }
  28920. }
  28921. return encryptionKey;
  28922. }
  28923. function decodeUserPassword(password, ownerPassword, revision, keyLength) {
  28924. var hashData = new Uint8Array(32), i = 0, j, n;
  28925. n = Math.min(32, password.length);
  28926. for (; i < n; ++i) {
  28927. hashData[i] = password[i];
  28928. }
  28929. j = 0;
  28930. while (i < 32) {
  28931. hashData[i++] = defaultPasswordBytes[j++];
  28932. }
  28933. var hash = calculateMD5(hashData, 0, i);
  28934. var keyLengthInBytes = keyLength >> 3;
  28935. if (revision >= 3) {
  28936. for (j = 0; j < 50; ++j) {
  28937. hash = calculateMD5(hash, 0, hash.length);
  28938. }
  28939. }
  28940. var cipher, userPassword;
  28941. if (revision >= 3) {
  28942. userPassword = ownerPassword;
  28943. var derivedKey = new Uint8Array(keyLengthInBytes), k;
  28944. for (j = 19; j >= 0; j--) {
  28945. for (k = 0; k < keyLengthInBytes; ++k) {
  28946. derivedKey[k] = hash[k] ^ j;
  28947. }
  28948. cipher = new ARCFourCipher(derivedKey);
  28949. userPassword = cipher.encryptBlock(userPassword);
  28950. }
  28951. } else {
  28952. cipher = new ARCFourCipher(hash.subarray(0, keyLengthInBytes));
  28953. userPassword = cipher.encryptBlock(ownerPassword);
  28954. }
  28955. return userPassword;
  28956. }
  28957. var identityName = Name.get('Identity');
  28958. function CipherTransformFactory(dict, fileId, password) {
  28959. var filter = dict.get('Filter');
  28960. if (!isName(filter, 'Standard')) {
  28961. error('unknown encryption method');
  28962. }
  28963. this.dict = dict;
  28964. var algorithm = dict.get('V');
  28965. if (!isInt(algorithm) || algorithm !== 1 && algorithm !== 2 && algorithm !== 4 && algorithm !== 5) {
  28966. error('unsupported encryption algorithm');
  28967. }
  28968. this.algorithm = algorithm;
  28969. var keyLength = dict.get('Length');
  28970. if (!keyLength) {
  28971. if (algorithm <= 3) {
  28972. keyLength = 40;
  28973. } else {
  28974. var cfDict = dict.get('CF');
  28975. var streamCryptoName = dict.get('StmF');
  28976. if (isDict(cfDict) && isName(streamCryptoName)) {
  28977. cfDict.suppressEncryption = true;
  28978. var handlerDict = cfDict.get(streamCryptoName.name);
  28979. keyLength = handlerDict && handlerDict.get('Length') || 128;
  28980. if (keyLength < 40) {
  28981. keyLength <<= 3;
  28982. }
  28983. }
  28984. }
  28985. }
  28986. if (!isInt(keyLength) || keyLength < 40 || keyLength % 8 !== 0) {
  28987. error('invalid key length');
  28988. }
  28989. var ownerPassword = stringToBytes(dict.get('O')).subarray(0, 32);
  28990. var userPassword = stringToBytes(dict.get('U')).subarray(0, 32);
  28991. var flags = dict.get('P');
  28992. var revision = dict.get('R');
  28993. var encryptMetadata = (algorithm === 4 || algorithm === 5) && dict.get('EncryptMetadata') !== false;
  28994. this.encryptMetadata = encryptMetadata;
  28995. var fileIdBytes = stringToBytes(fileId);
  28996. var passwordBytes;
  28997. if (password) {
  28998. if (revision === 6) {
  28999. try {
  29000. password = utf8StringToString(password);
  29001. } catch (ex) {
  29002. warn('CipherTransformFactory: ' + 'Unable to convert UTF8 encoded password.');
  29003. }
  29004. }
  29005. passwordBytes = stringToBytes(password);
  29006. }
  29007. var encryptionKey;
  29008. if (algorithm !== 5) {
  29009. encryptionKey = prepareKeyData(fileIdBytes, passwordBytes, ownerPassword, userPassword, flags, revision, keyLength, encryptMetadata);
  29010. } else {
  29011. var ownerValidationSalt = stringToBytes(dict.get('O')).subarray(32, 40);
  29012. var ownerKeySalt = stringToBytes(dict.get('O')).subarray(40, 48);
  29013. var uBytes = stringToBytes(dict.get('U')).subarray(0, 48);
  29014. var userValidationSalt = stringToBytes(dict.get('U')).subarray(32, 40);
  29015. var userKeySalt = stringToBytes(dict.get('U')).subarray(40, 48);
  29016. var ownerEncryption = stringToBytes(dict.get('OE'));
  29017. var userEncryption = stringToBytes(dict.get('UE'));
  29018. var perms = stringToBytes(dict.get('Perms'));
  29019. encryptionKey = createEncryptionKey20(revision, passwordBytes, ownerPassword, ownerValidationSalt, ownerKeySalt, uBytes, userPassword, userValidationSalt, userKeySalt, ownerEncryption, userEncryption, perms);
  29020. }
  29021. if (!encryptionKey && !password) {
  29022. throw new PasswordException('No password given', PasswordResponses.NEED_PASSWORD);
  29023. } else if (!encryptionKey && password) {
  29024. var decodedPassword = decodeUserPassword(passwordBytes, ownerPassword, revision, keyLength);
  29025. encryptionKey = prepareKeyData(fileIdBytes, decodedPassword, ownerPassword, userPassword, flags, revision, keyLength, encryptMetadata);
  29026. }
  29027. if (!encryptionKey) {
  29028. throw new PasswordException('Incorrect Password', PasswordResponses.INCORRECT_PASSWORD);
  29029. }
  29030. this.encryptionKey = encryptionKey;
  29031. if (algorithm >= 4) {
  29032. var cf = dict.get('CF');
  29033. if (isDict(cf)) {
  29034. cf.suppressEncryption = true;
  29035. }
  29036. this.cf = cf;
  29037. this.stmf = dict.get('StmF') || identityName;
  29038. this.strf = dict.get('StrF') || identityName;
  29039. this.eff = dict.get('EFF') || this.stmf;
  29040. }
  29041. }
  29042. function buildObjectKey(num, gen, encryptionKey, isAes) {
  29043. var key = new Uint8Array(encryptionKey.length + 9), i, n;
  29044. for (i = 0, n = encryptionKey.length; i < n; ++i) {
  29045. key[i] = encryptionKey[i];
  29046. }
  29047. key[i++] = num & 0xFF;
  29048. key[i++] = num >> 8 & 0xFF;
  29049. key[i++] = num >> 16 & 0xFF;
  29050. key[i++] = gen & 0xFF;
  29051. key[i++] = gen >> 8 & 0xFF;
  29052. if (isAes) {
  29053. key[i++] = 0x73;
  29054. key[i++] = 0x41;
  29055. key[i++] = 0x6C;
  29056. key[i++] = 0x54;
  29057. }
  29058. var hash = calculateMD5(key, 0, i);
  29059. return hash.subarray(0, Math.min(encryptionKey.length + 5, 16));
  29060. }
  29061. function buildCipherConstructor(cf, name, num, gen, key) {
  29062. assert(isName(name), 'Invalid crypt filter name.');
  29063. var cryptFilter = cf.get(name.name);
  29064. var cfm;
  29065. if (cryptFilter !== null && cryptFilter !== undefined) {
  29066. cfm = cryptFilter.get('CFM');
  29067. }
  29068. if (!cfm || cfm.name === 'None') {
  29069. return function cipherTransformFactoryBuildCipherConstructorNone() {
  29070. return new NullCipher();
  29071. };
  29072. }
  29073. if (cfm.name === 'V2') {
  29074. return function cipherTransformFactoryBuildCipherConstructorV2() {
  29075. return new ARCFourCipher(buildObjectKey(num, gen, key, false));
  29076. };
  29077. }
  29078. if (cfm.name === 'AESV2') {
  29079. return function cipherTransformFactoryBuildCipherConstructorAESV2() {
  29080. return new AES128Cipher(buildObjectKey(num, gen, key, true));
  29081. };
  29082. }
  29083. if (cfm.name === 'AESV3') {
  29084. return function cipherTransformFactoryBuildCipherConstructorAESV3() {
  29085. return new AES256Cipher(key);
  29086. };
  29087. }
  29088. error('Unknown crypto method');
  29089. }
  29090. CipherTransformFactory.prototype = {
  29091. createCipherTransform: function CipherTransformFactory_createCipherTransform(num, gen) {
  29092. if (this.algorithm === 4 || this.algorithm === 5) {
  29093. return new CipherTransform(buildCipherConstructor(this.cf, this.stmf, num, gen, this.encryptionKey), buildCipherConstructor(this.cf, this.strf, num, gen, this.encryptionKey));
  29094. }
  29095. var key = buildObjectKey(num, gen, this.encryptionKey, false);
  29096. var cipherConstructor = function buildCipherCipherConstructor() {
  29097. return new ARCFourCipher(key);
  29098. };
  29099. return new CipherTransform(cipherConstructor, cipherConstructor);
  29100. }
  29101. };
  29102. return CipherTransformFactory;
  29103. }();
  29104. exports.AES128Cipher = AES128Cipher;
  29105. exports.AES256Cipher = AES256Cipher;
  29106. exports.ARCFourCipher = ARCFourCipher;
  29107. exports.CipherTransformFactory = CipherTransformFactory;
  29108. exports.PDF17 = PDF17;
  29109. exports.PDF20 = PDF20;
  29110. exports.calculateMD5 = calculateMD5;
  29111. exports.calculateSHA256 = calculateSHA256;
  29112. exports.calculateSHA384 = calculateSHA384;
  29113. exports.calculateSHA512 = calculateSHA512;
  29114. /***/ }),
  29115. /* 17 */
  29116. /***/ (function(module, exports, __w_pdfjs_require__) {
  29117. "use strict";
  29118. var sharedUtil = __w_pdfjs_require__(0);
  29119. var corePrimitives = __w_pdfjs_require__(1);
  29120. var coreStream = __w_pdfjs_require__(2);
  29121. var coreParser = __w_pdfjs_require__(6);
  29122. var coreImage = __w_pdfjs_require__(35);
  29123. var coreColorSpace = __w_pdfjs_require__(4);
  29124. var coreMurmurHash3 = __w_pdfjs_require__(39);
  29125. var coreFonts = __w_pdfjs_require__(34);
  29126. var coreFunction = __w_pdfjs_require__(7);
  29127. var corePattern = __w_pdfjs_require__(41);
  29128. var coreCMap = __w_pdfjs_require__(31);
  29129. var coreMetrics = __w_pdfjs_require__(38);
  29130. var coreBidi = __w_pdfjs_require__(29);
  29131. var coreEncodings = __w_pdfjs_require__(5);
  29132. var coreStandardFonts = __w_pdfjs_require__(20);
  29133. var coreUnicode = __w_pdfjs_require__(21);
  29134. var coreGlyphList = __w_pdfjs_require__(8);
  29135. var FONT_IDENTITY_MATRIX = sharedUtil.FONT_IDENTITY_MATRIX;
  29136. var IDENTITY_MATRIX = sharedUtil.IDENTITY_MATRIX;
  29137. var UNSUPPORTED_FEATURES = sharedUtil.UNSUPPORTED_FEATURES;
  29138. var ImageKind = sharedUtil.ImageKind;
  29139. var OPS = sharedUtil.OPS;
  29140. var TextRenderingMode = sharedUtil.TextRenderingMode;
  29141. var Util = sharedUtil.Util;
  29142. var assert = sharedUtil.assert;
  29143. var createPromiseCapability = sharedUtil.createPromiseCapability;
  29144. var error = sharedUtil.error;
  29145. var info = sharedUtil.info;
  29146. var isArray = sharedUtil.isArray;
  29147. var isNum = sharedUtil.isNum;
  29148. var isString = sharedUtil.isString;
  29149. var getLookupTableFactory = sharedUtil.getLookupTableFactory;
  29150. var warn = sharedUtil.warn;
  29151. var Dict = corePrimitives.Dict;
  29152. var Name = corePrimitives.Name;
  29153. var isEOF = corePrimitives.isEOF;
  29154. var isCmd = corePrimitives.isCmd;
  29155. var isDict = corePrimitives.isDict;
  29156. var isName = corePrimitives.isName;
  29157. var isRef = corePrimitives.isRef;
  29158. var isStream = corePrimitives.isStream;
  29159. var DecodeStream = coreStream.DecodeStream;
  29160. var JpegStream = coreStream.JpegStream;
  29161. var Stream = coreStream.Stream;
  29162. var Lexer = coreParser.Lexer;
  29163. var Parser = coreParser.Parser;
  29164. var PDFImage = coreImage.PDFImage;
  29165. var ColorSpace = coreColorSpace.ColorSpace;
  29166. var MurmurHash3_64 = coreMurmurHash3.MurmurHash3_64;
  29167. var ErrorFont = coreFonts.ErrorFont;
  29168. var FontFlags = coreFonts.FontFlags;
  29169. var Font = coreFonts.Font;
  29170. var IdentityToUnicodeMap = coreFonts.IdentityToUnicodeMap;
  29171. var ToUnicodeMap = coreFonts.ToUnicodeMap;
  29172. var getFontType = coreFonts.getFontType;
  29173. var isPDFFunction = coreFunction.isPDFFunction;
  29174. var PDFFunction = coreFunction.PDFFunction;
  29175. var Pattern = corePattern.Pattern;
  29176. var getTilingPatternIR = corePattern.getTilingPatternIR;
  29177. var CMapFactory = coreCMap.CMapFactory;
  29178. var IdentityCMap = coreCMap.IdentityCMap;
  29179. var getMetrics = coreMetrics.getMetrics;
  29180. var bidi = coreBidi.bidi;
  29181. var WinAnsiEncoding = coreEncodings.WinAnsiEncoding;
  29182. var StandardEncoding = coreEncodings.StandardEncoding;
  29183. var MacRomanEncoding = coreEncodings.MacRomanEncoding;
  29184. var SymbolSetEncoding = coreEncodings.SymbolSetEncoding;
  29185. var ZapfDingbatsEncoding = coreEncodings.ZapfDingbatsEncoding;
  29186. var getEncoding = coreEncodings.getEncoding;
  29187. var getStdFontMap = coreStandardFonts.getStdFontMap;
  29188. var getSerifFonts = coreStandardFonts.getSerifFonts;
  29189. var getSymbolsFonts = coreStandardFonts.getSymbolsFonts;
  29190. var getNormalizedUnicodes = coreUnicode.getNormalizedUnicodes;
  29191. var reverseIfRtl = coreUnicode.reverseIfRtl;
  29192. var getUnicodeForGlyph = coreUnicode.getUnicodeForGlyph;
  29193. var getGlyphsUnicode = coreGlyphList.getGlyphsUnicode;
  29194. var PartialEvaluator = function PartialEvaluatorClosure() {
  29195. var DefaultPartialEvaluatorOptions = {
  29196. forceDataSchema: false,
  29197. maxImageSize: -1,
  29198. disableFontFace: false,
  29199. cMapOptions: {
  29200. url: null,
  29201. packed: false
  29202. },
  29203. disableNativeImageDecoder: false
  29204. };
  29205. function NativeImageDecoder(xref, resources, handler, forceDataSchema) {
  29206. this.xref = xref;
  29207. this.resources = resources;
  29208. this.handler = handler;
  29209. this.forceDataSchema = forceDataSchema;
  29210. }
  29211. NativeImageDecoder.prototype = {
  29212. canDecode: function (image) {
  29213. return image instanceof JpegStream && NativeImageDecoder.isDecodable(image, this.xref, this.resources);
  29214. },
  29215. decode: function (image) {
  29216. var dict = image.dict;
  29217. var colorSpace = dict.get('ColorSpace', 'CS');
  29218. colorSpace = ColorSpace.parse(colorSpace, this.xref, this.resources);
  29219. var numComps = colorSpace.numComps;
  29220. var decodePromise = this.handler.sendWithPromise('JpegDecode', [
  29221. image.getIR(this.forceDataSchema),
  29222. numComps
  29223. ]);
  29224. return decodePromise.then(function (message) {
  29225. var data = message.data;
  29226. return new Stream(data, 0, data.length, image.dict);
  29227. });
  29228. }
  29229. };
  29230. NativeImageDecoder.isSupported = function NativeImageDecoder_isSupported(image, xref, res) {
  29231. var dict = image.dict;
  29232. if (dict.has('DecodeParms') || dict.has('DP')) {
  29233. return false;
  29234. }
  29235. var cs = ColorSpace.parse(dict.get('ColorSpace', 'CS'), xref, res);
  29236. return (cs.name === 'DeviceGray' || cs.name === 'DeviceRGB') && cs.isDefaultDecode(dict.getArray('Decode', 'D'));
  29237. };
  29238. NativeImageDecoder.isDecodable = function NativeImageDecoder_isDecodable(image, xref, res) {
  29239. var dict = image.dict;
  29240. if (dict.has('DecodeParms') || dict.has('DP')) {
  29241. return false;
  29242. }
  29243. var cs = ColorSpace.parse(dict.get('ColorSpace', 'CS'), xref, res);
  29244. return (cs.numComps === 1 || cs.numComps === 3) && cs.isDefaultDecode(dict.getArray('Decode', 'D'));
  29245. };
  29246. function PartialEvaluator(pdfManager, xref, handler, pageIndex, idFactory, fontCache, options) {
  29247. this.pdfManager = pdfManager;
  29248. this.xref = xref;
  29249. this.handler = handler;
  29250. this.pageIndex = pageIndex;
  29251. this.idFactory = idFactory;
  29252. this.fontCache = fontCache;
  29253. this.options = options || DefaultPartialEvaluatorOptions;
  29254. }
  29255. var TIME_SLOT_DURATION_MS = 20;
  29256. var CHECK_TIME_EVERY = 100;
  29257. function TimeSlotManager() {
  29258. this.reset();
  29259. }
  29260. TimeSlotManager.prototype = {
  29261. check: function TimeSlotManager_check() {
  29262. if (++this.checked < CHECK_TIME_EVERY) {
  29263. return false;
  29264. }
  29265. this.checked = 0;
  29266. return this.endTime <= Date.now();
  29267. },
  29268. reset: function TimeSlotManager_reset() {
  29269. this.endTime = Date.now() + TIME_SLOT_DURATION_MS;
  29270. this.checked = 0;
  29271. }
  29272. };
  29273. var deferred = Promise.resolve();
  29274. var TILING_PATTERN = 1, SHADING_PATTERN = 2;
  29275. PartialEvaluator.prototype = {
  29276. hasBlendModes: function PartialEvaluator_hasBlendModes(resources) {
  29277. if (!isDict(resources)) {
  29278. return false;
  29279. }
  29280. var processed = Object.create(null);
  29281. if (resources.objId) {
  29282. processed[resources.objId] = true;
  29283. }
  29284. var nodes = [resources], xref = this.xref;
  29285. while (nodes.length) {
  29286. var key, i, ii;
  29287. var node = nodes.shift();
  29288. var graphicStates = node.get('ExtGState');
  29289. if (isDict(graphicStates)) {
  29290. var graphicStatesKeys = graphicStates.getKeys();
  29291. for (i = 0, ii = graphicStatesKeys.length; i < ii; i++) {
  29292. key = graphicStatesKeys[i];
  29293. var graphicState = graphicStates.get(key);
  29294. var bm = graphicState.get('BM');
  29295. if (isName(bm) && bm.name !== 'Normal') {
  29296. return true;
  29297. }
  29298. }
  29299. }
  29300. var xObjects = node.get('XObject');
  29301. if (!isDict(xObjects)) {
  29302. continue;
  29303. }
  29304. var xObjectsKeys = xObjects.getKeys();
  29305. for (i = 0, ii = xObjectsKeys.length; i < ii; i++) {
  29306. key = xObjectsKeys[i];
  29307. var xObject = xObjects.getRaw(key);
  29308. if (isRef(xObject)) {
  29309. if (processed[xObject.toString()]) {
  29310. continue;
  29311. }
  29312. xObject = xref.fetch(xObject);
  29313. }
  29314. if (!isStream(xObject)) {
  29315. continue;
  29316. }
  29317. if (xObject.dict.objId) {
  29318. if (processed[xObject.dict.objId]) {
  29319. continue;
  29320. }
  29321. processed[xObject.dict.objId] = true;
  29322. }
  29323. var xResources = xObject.dict.get('Resources');
  29324. if (isDict(xResources) && (!xResources.objId || !processed[xResources.objId])) {
  29325. nodes.push(xResources);
  29326. if (xResources.objId) {
  29327. processed[xResources.objId] = true;
  29328. }
  29329. }
  29330. }
  29331. }
  29332. return false;
  29333. },
  29334. buildFormXObject: function PartialEvaluator_buildFormXObject(resources, xobj, smask, operatorList, task, initialState) {
  29335. var matrix = xobj.dict.getArray('Matrix');
  29336. var bbox = xobj.dict.getArray('BBox');
  29337. var group = xobj.dict.get('Group');
  29338. if (group) {
  29339. var groupOptions = {
  29340. matrix: matrix,
  29341. bbox: bbox,
  29342. smask: smask,
  29343. isolated: false,
  29344. knockout: false
  29345. };
  29346. var groupSubtype = group.get('S');
  29347. var colorSpace;
  29348. if (isName(groupSubtype, 'Transparency')) {
  29349. groupOptions.isolated = group.get('I') || false;
  29350. groupOptions.knockout = group.get('K') || false;
  29351. colorSpace = group.has('CS') ? ColorSpace.parse(group.get('CS'), this.xref, resources) : null;
  29352. }
  29353. if (smask && smask.backdrop) {
  29354. colorSpace = colorSpace || ColorSpace.singletons.rgb;
  29355. smask.backdrop = colorSpace.getRgb(smask.backdrop, 0);
  29356. }
  29357. operatorList.addOp(OPS.beginGroup, [groupOptions]);
  29358. }
  29359. operatorList.addOp(OPS.paintFormXObjectBegin, [
  29360. matrix,
  29361. bbox
  29362. ]);
  29363. return this.getOperatorList(xobj, task, xobj.dict.get('Resources') || resources, operatorList, initialState).then(function () {
  29364. operatorList.addOp(OPS.paintFormXObjectEnd, []);
  29365. if (group) {
  29366. operatorList.addOp(OPS.endGroup, [groupOptions]);
  29367. }
  29368. });
  29369. },
  29370. buildPaintImageXObject: function PartialEvaluator_buildPaintImageXObject(resources, image, inline, operatorList, cacheKey, imageCache) {
  29371. var self = this;
  29372. var dict = image.dict;
  29373. var w = dict.get('Width', 'W');
  29374. var h = dict.get('Height', 'H');
  29375. if (!(w && isNum(w)) || !(h && isNum(h))) {
  29376. warn('Image dimensions are missing, or not numbers.');
  29377. return;
  29378. }
  29379. var maxImageSize = this.options.maxImageSize;
  29380. if (maxImageSize !== -1 && w * h > maxImageSize) {
  29381. warn('Image exceeded maximum allowed size and was removed.');
  29382. return;
  29383. }
  29384. var imageMask = dict.get('ImageMask', 'IM') || false;
  29385. var imgData, args;
  29386. if (imageMask) {
  29387. var width = dict.get('Width', 'W');
  29388. var height = dict.get('Height', 'H');
  29389. var bitStrideLength = width + 7 >> 3;
  29390. var imgArray = image.getBytes(bitStrideLength * height);
  29391. var decode = dict.getArray('Decode', 'D');
  29392. var inverseDecode = !!decode && decode[0] > 0;
  29393. imgData = PDFImage.createMask(imgArray, width, height, image instanceof DecodeStream, inverseDecode);
  29394. imgData.cached = true;
  29395. args = [imgData];
  29396. operatorList.addOp(OPS.paintImageMaskXObject, args);
  29397. if (cacheKey) {
  29398. imageCache[cacheKey] = {
  29399. fn: OPS.paintImageMaskXObject,
  29400. args: args
  29401. };
  29402. }
  29403. return;
  29404. }
  29405. var softMask = dict.get('SMask', 'SM') || false;
  29406. var mask = dict.get('Mask') || false;
  29407. var SMALL_IMAGE_DIMENSIONS = 200;
  29408. if (inline && !softMask && !mask && !(image instanceof JpegStream) && w + h < SMALL_IMAGE_DIMENSIONS) {
  29409. var imageObj = new PDFImage(this.xref, resources, image, inline, null, null);
  29410. imgData = imageObj.createImageData(true);
  29411. operatorList.addOp(OPS.paintInlineImageXObject, [imgData]);
  29412. return;
  29413. }
  29414. var useNativeImageDecoder = !this.options.disableNativeImageDecoder;
  29415. var objId = 'img_' + this.idFactory.createObjId();
  29416. operatorList.addDependency(objId);
  29417. args = [
  29418. objId,
  29419. w,
  29420. h
  29421. ];
  29422. if (useNativeImageDecoder && !softMask && !mask && image instanceof JpegStream && NativeImageDecoder.isSupported(image, this.xref, resources)) {
  29423. operatorList.addOp(OPS.paintJpegXObject, args);
  29424. this.handler.send('obj', [
  29425. objId,
  29426. this.pageIndex,
  29427. 'JpegStream',
  29428. image.getIR(this.options.forceDataSchema)
  29429. ]);
  29430. return;
  29431. }
  29432. var nativeImageDecoder = null;
  29433. if (useNativeImageDecoder && (image instanceof JpegStream || mask instanceof JpegStream || softMask instanceof JpegStream)) {
  29434. nativeImageDecoder = new NativeImageDecoder(self.xref, resources, self.handler, self.options.forceDataSchema);
  29435. }
  29436. PDFImage.buildImage(self.handler, self.xref, resources, image, inline, nativeImageDecoder).then(function (imageObj) {
  29437. var imgData = imageObj.createImageData(false);
  29438. self.handler.send('obj', [
  29439. objId,
  29440. self.pageIndex,
  29441. 'Image',
  29442. imgData
  29443. ], [imgData.data.buffer]);
  29444. }).then(undefined, function (reason) {
  29445. warn('Unable to decode image: ' + reason);
  29446. self.handler.send('obj', [
  29447. objId,
  29448. self.pageIndex,
  29449. 'Image',
  29450. null
  29451. ]);
  29452. });
  29453. operatorList.addOp(OPS.paintImageXObject, args);
  29454. if (cacheKey) {
  29455. imageCache[cacheKey] = {
  29456. fn: OPS.paintImageXObject,
  29457. args: args
  29458. };
  29459. }
  29460. },
  29461. handleSMask: function PartialEvaluator_handleSmask(smask, resources, operatorList, task, stateManager) {
  29462. var smaskContent = smask.get('G');
  29463. var smaskOptions = {
  29464. subtype: smask.get('S').name,
  29465. backdrop: smask.get('BC')
  29466. };
  29467. var transferObj = smask.get('TR');
  29468. if (isPDFFunction(transferObj)) {
  29469. var transferFn = PDFFunction.parse(this.xref, transferObj);
  29470. var transferMap = new Uint8Array(256);
  29471. var tmp = new Float32Array(1);
  29472. for (var i = 0; i < 256; i++) {
  29473. tmp[0] = i / 255;
  29474. transferFn(tmp, 0, tmp, 0);
  29475. transferMap[i] = tmp[0] * 255 | 0;
  29476. }
  29477. smaskOptions.transferMap = transferMap;
  29478. }
  29479. return this.buildFormXObject(resources, smaskContent, smaskOptions, operatorList, task, stateManager.state.clone());
  29480. },
  29481. handleTilingType: function PartialEvaluator_handleTilingType(fn, args, resources, pattern, patternDict, operatorList, task) {
  29482. var tilingOpList = new OperatorList();
  29483. var resourcesArray = [
  29484. patternDict.get('Resources'),
  29485. resources
  29486. ];
  29487. var patternResources = Dict.merge(this.xref, resourcesArray);
  29488. return this.getOperatorList(pattern, task, patternResources, tilingOpList).then(function () {
  29489. operatorList.addDependencies(tilingOpList.dependencies);
  29490. operatorList.addOp(fn, getTilingPatternIR({
  29491. fnArray: tilingOpList.fnArray,
  29492. argsArray: tilingOpList.argsArray
  29493. }, patternDict, args));
  29494. });
  29495. },
  29496. handleSetFont: function PartialEvaluator_handleSetFont(resources, fontArgs, fontRef, operatorList, task, state) {
  29497. var fontName;
  29498. if (fontArgs) {
  29499. fontArgs = fontArgs.slice();
  29500. fontName = fontArgs[0].name;
  29501. }
  29502. var self = this;
  29503. return this.loadFont(fontName, fontRef, this.xref, resources).then(function (translated) {
  29504. if (!translated.font.isType3Font) {
  29505. return translated;
  29506. }
  29507. return translated.loadType3Data(self, resources, operatorList, task).then(function () {
  29508. return translated;
  29509. }, function (reason) {
  29510. self.handler.send('UnsupportedFeature', { featureId: UNSUPPORTED_FEATURES.font });
  29511. return new TranslatedFont('g_font_error', new ErrorFont('Type3 font load error: ' + reason), translated.font);
  29512. });
  29513. }).then(function (translated) {
  29514. state.font = translated.font;
  29515. translated.send(self.handler);
  29516. return translated.loadedName;
  29517. });
  29518. },
  29519. handleText: function PartialEvaluator_handleText(chars, state) {
  29520. var font = state.font;
  29521. var glyphs = font.charsToGlyphs(chars);
  29522. var isAddToPathSet = !!(state.textRenderingMode & TextRenderingMode.ADD_TO_PATH_FLAG);
  29523. if (font.data && (isAddToPathSet || this.options.disableFontFace)) {
  29524. var buildPath = function (fontChar) {
  29525. if (!font.renderer.hasBuiltPath(fontChar)) {
  29526. var path = font.renderer.getPathJs(fontChar);
  29527. this.handler.send('commonobj', [
  29528. font.loadedName + '_path_' + fontChar,
  29529. 'FontPath',
  29530. path
  29531. ]);
  29532. }
  29533. }.bind(this);
  29534. for (var i = 0, ii = glyphs.length; i < ii; i++) {
  29535. var glyph = glyphs[i];
  29536. buildPath(glyph.fontChar);
  29537. var accent = glyph.accent;
  29538. if (accent && accent.fontChar) {
  29539. buildPath(accent.fontChar);
  29540. }
  29541. }
  29542. }
  29543. return glyphs;
  29544. },
  29545. setGState: function PartialEvaluator_setGState(resources, gState, operatorList, task, xref, stateManager) {
  29546. var gStateObj = [];
  29547. var gStateKeys = gState.getKeys();
  29548. var self = this;
  29549. var promise = Promise.resolve();
  29550. for (var i = 0, ii = gStateKeys.length; i < ii; i++) {
  29551. var key = gStateKeys[i];
  29552. var value = gState.get(key);
  29553. switch (key) {
  29554. case 'Type':
  29555. break;
  29556. case 'LW':
  29557. case 'LC':
  29558. case 'LJ':
  29559. case 'ML':
  29560. case 'D':
  29561. case 'RI':
  29562. case 'FL':
  29563. case 'CA':
  29564. case 'ca':
  29565. gStateObj.push([
  29566. key,
  29567. value
  29568. ]);
  29569. break;
  29570. case 'Font':
  29571. promise = promise.then(function () {
  29572. return self.handleSetFont(resources, null, value[0], operatorList, task, stateManager.state).then(function (loadedName) {
  29573. operatorList.addDependency(loadedName);
  29574. gStateObj.push([
  29575. key,
  29576. [
  29577. loadedName,
  29578. value[1]
  29579. ]
  29580. ]);
  29581. });
  29582. });
  29583. break;
  29584. case 'BM':
  29585. gStateObj.push([
  29586. key,
  29587. value
  29588. ]);
  29589. break;
  29590. case 'SMask':
  29591. if (isName(value, 'None')) {
  29592. gStateObj.push([
  29593. key,
  29594. false
  29595. ]);
  29596. break;
  29597. }
  29598. if (isDict(value)) {
  29599. promise = promise.then(function (dict) {
  29600. return self.handleSMask(dict, resources, operatorList, task, stateManager);
  29601. }.bind(this, value));
  29602. gStateObj.push([
  29603. key,
  29604. true
  29605. ]);
  29606. } else {
  29607. warn('Unsupported SMask type');
  29608. }
  29609. break;
  29610. case 'OP':
  29611. case 'op':
  29612. case 'OPM':
  29613. case 'BG':
  29614. case 'BG2':
  29615. case 'UCR':
  29616. case 'UCR2':
  29617. case 'TR':
  29618. case 'TR2':
  29619. case 'HT':
  29620. case 'SM':
  29621. case 'SA':
  29622. case 'AIS':
  29623. case 'TK':
  29624. info('graphic state operator ' + key);
  29625. break;
  29626. default:
  29627. info('Unknown graphic state operator ' + key);
  29628. break;
  29629. }
  29630. }
  29631. return promise.then(function () {
  29632. if (gStateObj.length > 0) {
  29633. operatorList.addOp(OPS.setGState, [gStateObj]);
  29634. }
  29635. });
  29636. },
  29637. loadFont: function PartialEvaluator_loadFont(fontName, font, xref, resources) {
  29638. function errorFont() {
  29639. return Promise.resolve(new TranslatedFont('g_font_error', new ErrorFont('Font ' + fontName + ' is not available'), font));
  29640. }
  29641. var fontRef;
  29642. if (font) {
  29643. assert(isRef(font));
  29644. fontRef = font;
  29645. } else {
  29646. var fontRes = resources.get('Font');
  29647. if (fontRes) {
  29648. fontRef = fontRes.getRaw(fontName);
  29649. } else {
  29650. warn('fontRes not available');
  29651. return errorFont();
  29652. }
  29653. }
  29654. if (!fontRef) {
  29655. warn('fontRef not available');
  29656. return errorFont();
  29657. }
  29658. if (this.fontCache.has(fontRef)) {
  29659. return this.fontCache.get(fontRef);
  29660. }
  29661. font = xref.fetchIfRef(fontRef);
  29662. if (!isDict(font)) {
  29663. return errorFont();
  29664. }
  29665. if (font.translated) {
  29666. return font.translated;
  29667. }
  29668. var fontCapability = createPromiseCapability();
  29669. var preEvaluatedFont = this.preEvaluateFont(font, xref);
  29670. var descriptor = preEvaluatedFont.descriptor;
  29671. var fontRefIsRef = isRef(fontRef), fontID;
  29672. if (fontRefIsRef) {
  29673. fontID = fontRef.toString();
  29674. }
  29675. if (isDict(descriptor)) {
  29676. if (!descriptor.fontAliases) {
  29677. descriptor.fontAliases = Object.create(null);
  29678. }
  29679. var fontAliases = descriptor.fontAliases;
  29680. var hash = preEvaluatedFont.hash;
  29681. if (fontAliases[hash]) {
  29682. var aliasFontRef = fontAliases[hash].aliasRef;
  29683. if (fontRefIsRef && aliasFontRef && this.fontCache.has(aliasFontRef)) {
  29684. this.fontCache.putAlias(fontRef, aliasFontRef);
  29685. return this.fontCache.get(fontRef);
  29686. }
  29687. } else {
  29688. fontAliases[hash] = { fontID: Font.getFontID() };
  29689. }
  29690. if (fontRefIsRef) {
  29691. fontAliases[hash].aliasRef = fontRef;
  29692. }
  29693. fontID = fontAliases[hash].fontID;
  29694. }
  29695. if (fontRefIsRef) {
  29696. this.fontCache.put(fontRef, fontCapability.promise);
  29697. } else {
  29698. if (!fontID) {
  29699. fontID = this.idFactory.createObjId();
  29700. }
  29701. this.fontCache.put('id_' + fontID, fontCapability.promise);
  29702. }
  29703. assert(fontID, 'The "fontID" must be defined.');
  29704. font.loadedName = 'g_' + this.pdfManager.docId + '_f' + fontID;
  29705. font.translated = fontCapability.promise;
  29706. var translatedPromise;
  29707. try {
  29708. translatedPromise = this.translateFont(preEvaluatedFont, xref);
  29709. } catch (e) {
  29710. translatedPromise = Promise.reject(e);
  29711. }
  29712. var self = this;
  29713. translatedPromise.then(function (translatedFont) {
  29714. if (translatedFont.fontType !== undefined) {
  29715. var xrefFontStats = xref.stats.fontTypes;
  29716. xrefFontStats[translatedFont.fontType] = true;
  29717. }
  29718. fontCapability.resolve(new TranslatedFont(font.loadedName, translatedFont, font));
  29719. }, function (reason) {
  29720. self.handler.send('UnsupportedFeature', { featureId: UNSUPPORTED_FEATURES.font });
  29721. try {
  29722. var descriptor = preEvaluatedFont.descriptor;
  29723. var fontFile3 = descriptor && descriptor.get('FontFile3');
  29724. var subtype = fontFile3 && fontFile3.get('Subtype');
  29725. var fontType = getFontType(preEvaluatedFont.type, subtype && subtype.name);
  29726. var xrefFontStats = xref.stats.fontTypes;
  29727. xrefFontStats[fontType] = true;
  29728. } catch (ex) {
  29729. }
  29730. fontCapability.resolve(new TranslatedFont(font.loadedName, new ErrorFont(reason instanceof Error ? reason.message : reason), font));
  29731. });
  29732. return fontCapability.promise;
  29733. },
  29734. buildPath: function PartialEvaluator_buildPath(operatorList, fn, args) {
  29735. var lastIndex = operatorList.length - 1;
  29736. if (!args) {
  29737. args = [];
  29738. }
  29739. if (lastIndex < 0 || operatorList.fnArray[lastIndex] !== OPS.constructPath) {
  29740. operatorList.addOp(OPS.constructPath, [
  29741. [fn],
  29742. args
  29743. ]);
  29744. } else {
  29745. var opArgs = operatorList.argsArray[lastIndex];
  29746. opArgs[0].push(fn);
  29747. Array.prototype.push.apply(opArgs[1], args);
  29748. }
  29749. },
  29750. handleColorN: function PartialEvaluator_handleColorN(operatorList, fn, args, cs, patterns, resources, task, xref) {
  29751. var patternName = args[args.length - 1];
  29752. var pattern;
  29753. if (isName(patternName) && (pattern = patterns.get(patternName.name))) {
  29754. var dict = isStream(pattern) ? pattern.dict : pattern;
  29755. var typeNum = dict.get('PatternType');
  29756. if (typeNum === TILING_PATTERN) {
  29757. var color = cs.base ? cs.base.getRgb(args, 0) : null;
  29758. return this.handleTilingType(fn, color, resources, pattern, dict, operatorList, task);
  29759. } else if (typeNum === SHADING_PATTERN) {
  29760. var shading = dict.get('Shading');
  29761. var matrix = dict.getArray('Matrix');
  29762. pattern = Pattern.parseShading(shading, matrix, xref, resources, this.handler);
  29763. operatorList.addOp(fn, pattern.getIR());
  29764. return Promise.resolve();
  29765. }
  29766. return Promise.reject('Unknown PatternType: ' + typeNum);
  29767. }
  29768. operatorList.addOp(fn, args);
  29769. return Promise.resolve();
  29770. },
  29771. getOperatorList: function PartialEvaluator_getOperatorList(stream, task, resources, operatorList, initialState) {
  29772. var self = this;
  29773. var xref = this.xref;
  29774. var imageCache = Object.create(null);
  29775. assert(operatorList);
  29776. resources = resources || Dict.empty;
  29777. var xobjs = resources.get('XObject') || Dict.empty;
  29778. var patterns = resources.get('Pattern') || Dict.empty;
  29779. var stateManager = new StateManager(initialState || new EvalState());
  29780. var preprocessor = new EvaluatorPreprocessor(stream, xref, stateManager);
  29781. var timeSlotManager = new TimeSlotManager();
  29782. return new Promise(function promiseBody(resolve, reject) {
  29783. var next = function (promise) {
  29784. promise.then(function () {
  29785. try {
  29786. promiseBody(resolve, reject);
  29787. } catch (ex) {
  29788. reject(ex);
  29789. }
  29790. }, reject);
  29791. };
  29792. task.ensureNotTerminated();
  29793. timeSlotManager.reset();
  29794. var stop, operation = {}, i, ii, cs;
  29795. while (!(stop = timeSlotManager.check())) {
  29796. operation.args = null;
  29797. if (!preprocessor.read(operation)) {
  29798. break;
  29799. }
  29800. var args = operation.args;
  29801. var fn = operation.fn;
  29802. switch (fn | 0) {
  29803. case OPS.paintXObject:
  29804. if (args[0].code) {
  29805. break;
  29806. }
  29807. var name = args[0].name;
  29808. if (!name) {
  29809. warn('XObject must be referred to by name.');
  29810. continue;
  29811. }
  29812. if (imageCache[name] !== undefined) {
  29813. operatorList.addOp(imageCache[name].fn, imageCache[name].args);
  29814. args = null;
  29815. continue;
  29816. }
  29817. var xobj = xobjs.get(name);
  29818. if (xobj) {
  29819. assert(isStream(xobj), 'XObject should be a stream');
  29820. var type = xobj.dict.get('Subtype');
  29821. assert(isName(type), 'XObject should have a Name subtype');
  29822. if (type.name === 'Form') {
  29823. stateManager.save();
  29824. next(self.buildFormXObject(resources, xobj, null, operatorList, task, stateManager.state.clone()).then(function () {
  29825. stateManager.restore();
  29826. }));
  29827. return;
  29828. } else if (type.name === 'Image') {
  29829. self.buildPaintImageXObject(resources, xobj, false, operatorList, name, imageCache);
  29830. args = null;
  29831. continue;
  29832. } else if (type.name === 'PS') {
  29833. info('Ignored XObject subtype PS');
  29834. continue;
  29835. } else {
  29836. error('Unhandled XObject subtype ' + type.name);
  29837. }
  29838. }
  29839. break;
  29840. case OPS.setFont:
  29841. var fontSize = args[1];
  29842. next(self.handleSetFont(resources, args, null, operatorList, task, stateManager.state).then(function (loadedName) {
  29843. operatorList.addDependency(loadedName);
  29844. operatorList.addOp(OPS.setFont, [
  29845. loadedName,
  29846. fontSize
  29847. ]);
  29848. }));
  29849. return;
  29850. case OPS.endInlineImage:
  29851. var cacheKey = args[0].cacheKey;
  29852. if (cacheKey) {
  29853. var cacheEntry = imageCache[cacheKey];
  29854. if (cacheEntry !== undefined) {
  29855. operatorList.addOp(cacheEntry.fn, cacheEntry.args);
  29856. args = null;
  29857. continue;
  29858. }
  29859. }
  29860. self.buildPaintImageXObject(resources, args[0], true, operatorList, cacheKey, imageCache);
  29861. args = null;
  29862. continue;
  29863. case OPS.showText:
  29864. args[0] = self.handleText(args[0], stateManager.state);
  29865. break;
  29866. case OPS.showSpacedText:
  29867. var arr = args[0];
  29868. var combinedGlyphs = [];
  29869. var arrLength = arr.length;
  29870. var state = stateManager.state;
  29871. for (i = 0; i < arrLength; ++i) {
  29872. var arrItem = arr[i];
  29873. if (isString(arrItem)) {
  29874. Array.prototype.push.apply(combinedGlyphs, self.handleText(arrItem, state));
  29875. } else if (isNum(arrItem)) {
  29876. combinedGlyphs.push(arrItem);
  29877. }
  29878. }
  29879. args[0] = combinedGlyphs;
  29880. fn = OPS.showText;
  29881. break;
  29882. case OPS.nextLineShowText:
  29883. operatorList.addOp(OPS.nextLine);
  29884. args[0] = self.handleText(args[0], stateManager.state);
  29885. fn = OPS.showText;
  29886. break;
  29887. case OPS.nextLineSetSpacingShowText:
  29888. operatorList.addOp(OPS.nextLine);
  29889. operatorList.addOp(OPS.setWordSpacing, [args.shift()]);
  29890. operatorList.addOp(OPS.setCharSpacing, [args.shift()]);
  29891. args[0] = self.handleText(args[0], stateManager.state);
  29892. fn = OPS.showText;
  29893. break;
  29894. case OPS.setTextRenderingMode:
  29895. stateManager.state.textRenderingMode = args[0];
  29896. break;
  29897. case OPS.setFillColorSpace:
  29898. stateManager.state.fillColorSpace = ColorSpace.parse(args[0], xref, resources);
  29899. continue;
  29900. case OPS.setStrokeColorSpace:
  29901. stateManager.state.strokeColorSpace = ColorSpace.parse(args[0], xref, resources);
  29902. continue;
  29903. case OPS.setFillColor:
  29904. cs = stateManager.state.fillColorSpace;
  29905. args = cs.getRgb(args, 0);
  29906. fn = OPS.setFillRGBColor;
  29907. break;
  29908. case OPS.setStrokeColor:
  29909. cs = stateManager.state.strokeColorSpace;
  29910. args = cs.getRgb(args, 0);
  29911. fn = OPS.setStrokeRGBColor;
  29912. break;
  29913. case OPS.setFillGray:
  29914. stateManager.state.fillColorSpace = ColorSpace.singletons.gray;
  29915. args = ColorSpace.singletons.gray.getRgb(args, 0);
  29916. fn = OPS.setFillRGBColor;
  29917. break;
  29918. case OPS.setStrokeGray:
  29919. stateManager.state.strokeColorSpace = ColorSpace.singletons.gray;
  29920. args = ColorSpace.singletons.gray.getRgb(args, 0);
  29921. fn = OPS.setStrokeRGBColor;
  29922. break;
  29923. case OPS.setFillCMYKColor:
  29924. stateManager.state.fillColorSpace = ColorSpace.singletons.cmyk;
  29925. args = ColorSpace.singletons.cmyk.getRgb(args, 0);
  29926. fn = OPS.setFillRGBColor;
  29927. break;
  29928. case OPS.setStrokeCMYKColor:
  29929. stateManager.state.strokeColorSpace = ColorSpace.singletons.cmyk;
  29930. args = ColorSpace.singletons.cmyk.getRgb(args, 0);
  29931. fn = OPS.setStrokeRGBColor;
  29932. break;
  29933. case OPS.setFillRGBColor:
  29934. stateManager.state.fillColorSpace = ColorSpace.singletons.rgb;
  29935. args = ColorSpace.singletons.rgb.getRgb(args, 0);
  29936. break;
  29937. case OPS.setStrokeRGBColor:
  29938. stateManager.state.strokeColorSpace = ColorSpace.singletons.rgb;
  29939. args = ColorSpace.singletons.rgb.getRgb(args, 0);
  29940. break;
  29941. case OPS.setFillColorN:
  29942. cs = stateManager.state.fillColorSpace;
  29943. if (cs.name === 'Pattern') {
  29944. next(self.handleColorN(operatorList, OPS.setFillColorN, args, cs, patterns, resources, task, xref));
  29945. return;
  29946. }
  29947. args = cs.getRgb(args, 0);
  29948. fn = OPS.setFillRGBColor;
  29949. break;
  29950. case OPS.setStrokeColorN:
  29951. cs = stateManager.state.strokeColorSpace;
  29952. if (cs.name === 'Pattern') {
  29953. next(self.handleColorN(operatorList, OPS.setStrokeColorN, args, cs, patterns, resources, task, xref));
  29954. return;
  29955. }
  29956. args = cs.getRgb(args, 0);
  29957. fn = OPS.setStrokeRGBColor;
  29958. break;
  29959. case OPS.shadingFill:
  29960. var shadingRes = resources.get('Shading');
  29961. if (!shadingRes) {
  29962. error('No shading resource found');
  29963. }
  29964. var shading = shadingRes.get(args[0].name);
  29965. if (!shading) {
  29966. error('No shading object found');
  29967. }
  29968. var shadingFill = Pattern.parseShading(shading, null, xref, resources, self.handler);
  29969. var patternIR = shadingFill.getIR();
  29970. args = [patternIR];
  29971. fn = OPS.shadingFill;
  29972. break;
  29973. case OPS.setGState:
  29974. var dictName = args[0];
  29975. var extGState = resources.get('ExtGState');
  29976. if (!isDict(extGState) || !extGState.has(dictName.name)) {
  29977. break;
  29978. }
  29979. var gState = extGState.get(dictName.name);
  29980. next(self.setGState(resources, gState, operatorList, task, xref, stateManager));
  29981. return;
  29982. case OPS.moveTo:
  29983. case OPS.lineTo:
  29984. case OPS.curveTo:
  29985. case OPS.curveTo2:
  29986. case OPS.curveTo3:
  29987. case OPS.closePath:
  29988. self.buildPath(operatorList, fn, args);
  29989. continue;
  29990. case OPS.rectangle:
  29991. self.buildPath(operatorList, fn, args);
  29992. continue;
  29993. case OPS.markPoint:
  29994. case OPS.markPointProps:
  29995. case OPS.beginMarkedContent:
  29996. case OPS.beginMarkedContentProps:
  29997. case OPS.endMarkedContent:
  29998. case OPS.beginCompat:
  29999. case OPS.endCompat:
  30000. continue;
  30001. default:
  30002. if (args !== null) {
  30003. for (i = 0, ii = args.length; i < ii; i++) {
  30004. if (args[i] instanceof Dict) {
  30005. break;
  30006. }
  30007. }
  30008. if (i < ii) {
  30009. warn('getOperatorList - ignoring operator: ' + fn);
  30010. continue;
  30011. }
  30012. }
  30013. }
  30014. operatorList.addOp(fn, args);
  30015. }
  30016. if (stop) {
  30017. next(deferred);
  30018. return;
  30019. }
  30020. for (i = 0, ii = preprocessor.savedStatesDepth; i < ii; i++) {
  30021. operatorList.addOp(OPS.restore, []);
  30022. }
  30023. resolve();
  30024. });
  30025. },
  30026. getTextContent: function PartialEvaluator_getTextContent(stream, task, resources, stateManager, normalizeWhitespace, combineTextItems) {
  30027. stateManager = stateManager || new StateManager(new TextState());
  30028. var WhitespaceRegexp = /\s/g;
  30029. var textContent = {
  30030. items: [],
  30031. styles: Object.create(null)
  30032. };
  30033. var textContentItem = {
  30034. initialized: false,
  30035. str: [],
  30036. width: 0,
  30037. height: 0,
  30038. vertical: false,
  30039. lastAdvanceWidth: 0,
  30040. lastAdvanceHeight: 0,
  30041. textAdvanceScale: 0,
  30042. spaceWidth: 0,
  30043. fakeSpaceMin: Infinity,
  30044. fakeMultiSpaceMin: Infinity,
  30045. fakeMultiSpaceMax: -0,
  30046. textRunBreakAllowed: false,
  30047. transform: null,
  30048. fontName: null
  30049. };
  30050. var SPACE_FACTOR = 0.3;
  30051. var MULTI_SPACE_FACTOR = 1.5;
  30052. var MULTI_SPACE_FACTOR_MAX = 4;
  30053. var self = this;
  30054. var xref = this.xref;
  30055. resources = xref.fetchIfRef(resources) || Dict.empty;
  30056. var xobjs = null;
  30057. var xobjsCache = Object.create(null);
  30058. var preprocessor = new EvaluatorPreprocessor(stream, xref, stateManager);
  30059. var textState;
  30060. function ensureTextContentItem() {
  30061. if (textContentItem.initialized) {
  30062. return textContentItem;
  30063. }
  30064. var font = textState.font;
  30065. if (!(font.loadedName in textContent.styles)) {
  30066. textContent.styles[font.loadedName] = {
  30067. fontFamily: font.fallbackName,
  30068. ascent: font.ascent,
  30069. descent: font.descent,
  30070. vertical: font.vertical
  30071. };
  30072. }
  30073. textContentItem.fontName = font.loadedName;
  30074. var tsm = [
  30075. textState.fontSize * textState.textHScale,
  30076. 0,
  30077. 0,
  30078. textState.fontSize,
  30079. 0,
  30080. textState.textRise
  30081. ];
  30082. if (font.isType3Font && textState.fontMatrix !== FONT_IDENTITY_MATRIX && textState.fontSize === 1) {
  30083. var glyphHeight = font.bbox[3] - font.bbox[1];
  30084. if (glyphHeight > 0) {
  30085. glyphHeight = glyphHeight * textState.fontMatrix[3];
  30086. tsm[3] *= glyphHeight;
  30087. }
  30088. }
  30089. var trm = Util.transform(textState.ctm, Util.transform(textState.textMatrix, tsm));
  30090. textContentItem.transform = trm;
  30091. if (!font.vertical) {
  30092. textContentItem.width = 0;
  30093. textContentItem.height = Math.sqrt(trm[2] * trm[2] + trm[3] * trm[3]);
  30094. textContentItem.vertical = false;
  30095. } else {
  30096. textContentItem.width = Math.sqrt(trm[0] * trm[0] + trm[1] * trm[1]);
  30097. textContentItem.height = 0;
  30098. textContentItem.vertical = true;
  30099. }
  30100. var a = textState.textLineMatrix[0];
  30101. var b = textState.textLineMatrix[1];
  30102. var scaleLineX = Math.sqrt(a * a + b * b);
  30103. a = textState.ctm[0];
  30104. b = textState.ctm[1];
  30105. var scaleCtmX = Math.sqrt(a * a + b * b);
  30106. textContentItem.textAdvanceScale = scaleCtmX * scaleLineX;
  30107. textContentItem.lastAdvanceWidth = 0;
  30108. textContentItem.lastAdvanceHeight = 0;
  30109. var spaceWidth = font.spaceWidth / 1000 * textState.fontSize;
  30110. if (spaceWidth) {
  30111. textContentItem.spaceWidth = spaceWidth;
  30112. textContentItem.fakeSpaceMin = spaceWidth * SPACE_FACTOR;
  30113. textContentItem.fakeMultiSpaceMin = spaceWidth * MULTI_SPACE_FACTOR;
  30114. textContentItem.fakeMultiSpaceMax = spaceWidth * MULTI_SPACE_FACTOR_MAX;
  30115. textContentItem.textRunBreakAllowed = !font.isMonospace;
  30116. } else {
  30117. textContentItem.spaceWidth = 0;
  30118. textContentItem.fakeSpaceMin = Infinity;
  30119. textContentItem.fakeMultiSpaceMin = Infinity;
  30120. textContentItem.fakeMultiSpaceMax = 0;
  30121. textContentItem.textRunBreakAllowed = false;
  30122. }
  30123. textContentItem.initialized = true;
  30124. return textContentItem;
  30125. }
  30126. function replaceWhitespace(str) {
  30127. var i = 0, ii = str.length, code;
  30128. while (i < ii && (code = str.charCodeAt(i)) >= 0x20 && code <= 0x7F) {
  30129. i++;
  30130. }
  30131. return i < ii ? str.replace(WhitespaceRegexp, ' ') : str;
  30132. }
  30133. function runBidiTransform(textChunk) {
  30134. var str = textChunk.str.join('');
  30135. var bidiResult = bidi(str, -1, textChunk.vertical);
  30136. return {
  30137. str: normalizeWhitespace ? replaceWhitespace(bidiResult.str) : bidiResult.str,
  30138. dir: bidiResult.dir,
  30139. width: textChunk.width,
  30140. height: textChunk.height,
  30141. transform: textChunk.transform,
  30142. fontName: textChunk.fontName
  30143. };
  30144. }
  30145. function handleSetFont(fontName, fontRef) {
  30146. return self.loadFont(fontName, fontRef, xref, resources).then(function (translated) {
  30147. textState.font = translated.font;
  30148. textState.fontMatrix = translated.font.fontMatrix || FONT_IDENTITY_MATRIX;
  30149. });
  30150. }
  30151. function buildTextContentItem(chars) {
  30152. var font = textState.font;
  30153. var textChunk = ensureTextContentItem();
  30154. var width = 0;
  30155. var height = 0;
  30156. var glyphs = font.charsToGlyphs(chars);
  30157. for (var i = 0; i < glyphs.length; i++) {
  30158. var glyph = glyphs[i];
  30159. var glyphWidth = null;
  30160. if (font.vertical && glyph.vmetric) {
  30161. glyphWidth = glyph.vmetric[0];
  30162. } else {
  30163. glyphWidth = glyph.width;
  30164. }
  30165. var glyphUnicode = glyph.unicode;
  30166. var NormalizedUnicodes = getNormalizedUnicodes();
  30167. if (NormalizedUnicodes[glyphUnicode] !== undefined) {
  30168. glyphUnicode = NormalizedUnicodes[glyphUnicode];
  30169. }
  30170. glyphUnicode = reverseIfRtl(glyphUnicode);
  30171. var charSpacing = textState.charSpacing;
  30172. if (glyph.isSpace) {
  30173. var wordSpacing = textState.wordSpacing;
  30174. charSpacing += wordSpacing;
  30175. if (wordSpacing > 0) {
  30176. addFakeSpaces(wordSpacing, textChunk.str);
  30177. }
  30178. }
  30179. var tx = 0;
  30180. var ty = 0;
  30181. if (!font.vertical) {
  30182. var w0 = glyphWidth * textState.fontMatrix[0];
  30183. tx = (w0 * textState.fontSize + charSpacing) * textState.textHScale;
  30184. width += tx;
  30185. } else {
  30186. var w1 = glyphWidth * textState.fontMatrix[0];
  30187. ty = w1 * textState.fontSize + charSpacing;
  30188. height += ty;
  30189. }
  30190. textState.translateTextMatrix(tx, ty);
  30191. textChunk.str.push(glyphUnicode);
  30192. }
  30193. if (!font.vertical) {
  30194. textChunk.lastAdvanceWidth = width;
  30195. textChunk.width += width;
  30196. } else {
  30197. textChunk.lastAdvanceHeight = height;
  30198. textChunk.height += Math.abs(height);
  30199. }
  30200. return textChunk;
  30201. }
  30202. function addFakeSpaces(width, strBuf) {
  30203. if (width < textContentItem.fakeSpaceMin) {
  30204. return;
  30205. }
  30206. if (width < textContentItem.fakeMultiSpaceMin) {
  30207. strBuf.push(' ');
  30208. return;
  30209. }
  30210. var fakeSpaces = Math.round(width / textContentItem.spaceWidth);
  30211. while (fakeSpaces-- > 0) {
  30212. strBuf.push(' ');
  30213. }
  30214. }
  30215. function flushTextContentItem() {
  30216. if (!textContentItem.initialized) {
  30217. return;
  30218. }
  30219. textContentItem.width *= textContentItem.textAdvanceScale;
  30220. textContentItem.height *= textContentItem.textAdvanceScale;
  30221. textContent.items.push(runBidiTransform(textContentItem));
  30222. textContentItem.initialized = false;
  30223. textContentItem.str.length = 0;
  30224. }
  30225. var timeSlotManager = new TimeSlotManager();
  30226. return new Promise(function promiseBody(resolve, reject) {
  30227. var next = function (promise) {
  30228. promise.then(function () {
  30229. try {
  30230. promiseBody(resolve, reject);
  30231. } catch (ex) {
  30232. reject(ex);
  30233. }
  30234. }, reject);
  30235. };
  30236. task.ensureNotTerminated();
  30237. timeSlotManager.reset();
  30238. var stop, operation = {}, args = [];
  30239. while (!(stop = timeSlotManager.check())) {
  30240. args.length = 0;
  30241. operation.args = args;
  30242. if (!preprocessor.read(operation)) {
  30243. break;
  30244. }
  30245. textState = stateManager.state;
  30246. var fn = operation.fn;
  30247. args = operation.args;
  30248. var advance, diff;
  30249. switch (fn | 0) {
  30250. case OPS.setFont:
  30251. var fontNameArg = args[0].name, fontSizeArg = args[1];
  30252. if (textState.font && fontNameArg === textState.fontName && fontSizeArg === textState.fontSize) {
  30253. break;
  30254. }
  30255. flushTextContentItem();
  30256. textState.fontName = fontNameArg;
  30257. textState.fontSize = fontSizeArg;
  30258. next(handleSetFont(fontNameArg, null));
  30259. return;
  30260. case OPS.setTextRise:
  30261. flushTextContentItem();
  30262. textState.textRise = args[0];
  30263. break;
  30264. case OPS.setHScale:
  30265. flushTextContentItem();
  30266. textState.textHScale = args[0] / 100;
  30267. break;
  30268. case OPS.setLeading:
  30269. flushTextContentItem();
  30270. textState.leading = args[0];
  30271. break;
  30272. case OPS.moveText:
  30273. var isSameTextLine = !textState.font ? false : (textState.font.vertical ? args[0] : args[1]) === 0;
  30274. advance = args[0] - args[1];
  30275. if (combineTextItems && isSameTextLine && textContentItem.initialized && advance > 0 && advance <= textContentItem.fakeMultiSpaceMax) {
  30276. textState.translateTextLineMatrix(args[0], args[1]);
  30277. textContentItem.width += args[0] - textContentItem.lastAdvanceWidth;
  30278. textContentItem.height += args[1] - textContentItem.lastAdvanceHeight;
  30279. diff = args[0] - textContentItem.lastAdvanceWidth - (args[1] - textContentItem.lastAdvanceHeight);
  30280. addFakeSpaces(diff, textContentItem.str);
  30281. break;
  30282. }
  30283. flushTextContentItem();
  30284. textState.translateTextLineMatrix(args[0], args[1]);
  30285. textState.textMatrix = textState.textLineMatrix.slice();
  30286. break;
  30287. case OPS.setLeadingMoveText:
  30288. flushTextContentItem();
  30289. textState.leading = -args[1];
  30290. textState.translateTextLineMatrix(args[0], args[1]);
  30291. textState.textMatrix = textState.textLineMatrix.slice();
  30292. break;
  30293. case OPS.nextLine:
  30294. flushTextContentItem();
  30295. textState.carriageReturn();
  30296. break;
  30297. case OPS.setTextMatrix:
  30298. advance = textState.calcTextLineMatrixAdvance(args[0], args[1], args[2], args[3], args[4], args[5]);
  30299. if (combineTextItems && advance !== null && textContentItem.initialized && advance.value > 0 && advance.value <= textContentItem.fakeMultiSpaceMax) {
  30300. textState.translateTextLineMatrix(advance.width, advance.height);
  30301. textContentItem.width += advance.width - textContentItem.lastAdvanceWidth;
  30302. textContentItem.height += advance.height - textContentItem.lastAdvanceHeight;
  30303. diff = advance.width - textContentItem.lastAdvanceWidth - (advance.height - textContentItem.lastAdvanceHeight);
  30304. addFakeSpaces(diff, textContentItem.str);
  30305. break;
  30306. }
  30307. flushTextContentItem();
  30308. textState.setTextMatrix(args[0], args[1], args[2], args[3], args[4], args[5]);
  30309. textState.setTextLineMatrix(args[0], args[1], args[2], args[3], args[4], args[5]);
  30310. break;
  30311. case OPS.setCharSpacing:
  30312. textState.charSpacing = args[0];
  30313. break;
  30314. case OPS.setWordSpacing:
  30315. textState.wordSpacing = args[0];
  30316. break;
  30317. case OPS.beginText:
  30318. flushTextContentItem();
  30319. textState.textMatrix = IDENTITY_MATRIX.slice();
  30320. textState.textLineMatrix = IDENTITY_MATRIX.slice();
  30321. break;
  30322. case OPS.showSpacedText:
  30323. var items = args[0];
  30324. var offset;
  30325. for (var j = 0, jj = items.length; j < jj; j++) {
  30326. if (typeof items[j] === 'string') {
  30327. buildTextContentItem(items[j]);
  30328. } else if (isNum(items[j])) {
  30329. ensureTextContentItem();
  30330. advance = items[j] * textState.fontSize / 1000;
  30331. var breakTextRun = false;
  30332. if (textState.font.vertical) {
  30333. offset = advance;
  30334. textState.translateTextMatrix(0, offset);
  30335. breakTextRun = textContentItem.textRunBreakAllowed && advance > textContentItem.fakeMultiSpaceMax;
  30336. if (!breakTextRun) {
  30337. textContentItem.height += offset;
  30338. }
  30339. } else {
  30340. advance = -advance;
  30341. offset = advance * textState.textHScale;
  30342. textState.translateTextMatrix(offset, 0);
  30343. breakTextRun = textContentItem.textRunBreakAllowed && advance > textContentItem.fakeMultiSpaceMax;
  30344. if (!breakTextRun) {
  30345. textContentItem.width += offset;
  30346. }
  30347. }
  30348. if (breakTextRun) {
  30349. flushTextContentItem();
  30350. } else if (advance > 0) {
  30351. addFakeSpaces(advance, textContentItem.str);
  30352. }
  30353. }
  30354. }
  30355. break;
  30356. case OPS.showText:
  30357. buildTextContentItem(args[0]);
  30358. break;
  30359. case OPS.nextLineShowText:
  30360. flushTextContentItem();
  30361. textState.carriageReturn();
  30362. buildTextContentItem(args[0]);
  30363. break;
  30364. case OPS.nextLineSetSpacingShowText:
  30365. flushTextContentItem();
  30366. textState.wordSpacing = args[0];
  30367. textState.charSpacing = args[1];
  30368. textState.carriageReturn();
  30369. buildTextContentItem(args[2]);
  30370. break;
  30371. case OPS.paintXObject:
  30372. flushTextContentItem();
  30373. if (args[0].code) {
  30374. break;
  30375. }
  30376. if (!xobjs) {
  30377. xobjs = resources.get('XObject') || Dict.empty;
  30378. }
  30379. var name = args[0].name;
  30380. if (xobjsCache.key === name) {
  30381. if (xobjsCache.texts) {
  30382. Util.appendToArray(textContent.items, xobjsCache.texts.items);
  30383. Util.extendObj(textContent.styles, xobjsCache.texts.styles);
  30384. }
  30385. break;
  30386. }
  30387. var xobj = xobjs.get(name);
  30388. if (!xobj) {
  30389. break;
  30390. }
  30391. assert(isStream(xobj), 'XObject should be a stream');
  30392. var type = xobj.dict.get('Subtype');
  30393. assert(isName(type), 'XObject should have a Name subtype');
  30394. if ('Form' !== type.name) {
  30395. xobjsCache.key = name;
  30396. xobjsCache.texts = null;
  30397. break;
  30398. }
  30399. stateManager.save();
  30400. var matrix = xobj.dict.getArray('Matrix');
  30401. if (isArray(matrix) && matrix.length === 6) {
  30402. stateManager.transform(matrix);
  30403. }
  30404. next(self.getTextContent(xobj, task, xobj.dict.get('Resources') || resources, stateManager, normalizeWhitespace, combineTextItems).then(function (formTextContent) {
  30405. Util.appendToArray(textContent.items, formTextContent.items);
  30406. Util.extendObj(textContent.styles, formTextContent.styles);
  30407. stateManager.restore();
  30408. xobjsCache.key = name;
  30409. xobjsCache.texts = formTextContent;
  30410. }));
  30411. return;
  30412. case OPS.setGState:
  30413. flushTextContentItem();
  30414. var dictName = args[0];
  30415. var extGState = resources.get('ExtGState');
  30416. if (!isDict(extGState) || !isName(dictName)) {
  30417. break;
  30418. }
  30419. var gState = extGState.get(dictName.name);
  30420. if (!isDict(gState)) {
  30421. break;
  30422. }
  30423. var gStateFont = gState.get('Font');
  30424. if (gStateFont) {
  30425. textState.fontName = null;
  30426. textState.fontSize = gStateFont[1];
  30427. next(handleSetFont(null, gStateFont[0]));
  30428. return;
  30429. }
  30430. break;
  30431. }
  30432. }
  30433. if (stop) {
  30434. next(deferred);
  30435. return;
  30436. }
  30437. flushTextContentItem();
  30438. resolve(textContent);
  30439. });
  30440. },
  30441. extractDataStructures: function PartialEvaluator_extractDataStructures(dict, baseDict, xref, properties) {
  30442. var toUnicode = dict.get('ToUnicode') || baseDict.get('ToUnicode');
  30443. var toUnicodePromise = toUnicode ? this.readToUnicode(toUnicode) : Promise.resolve(undefined);
  30444. if (properties.composite) {
  30445. var cidSystemInfo = dict.get('CIDSystemInfo');
  30446. if (isDict(cidSystemInfo)) {
  30447. properties.cidSystemInfo = {
  30448. registry: cidSystemInfo.get('Registry'),
  30449. ordering: cidSystemInfo.get('Ordering'),
  30450. supplement: cidSystemInfo.get('Supplement')
  30451. };
  30452. }
  30453. var cidToGidMap = dict.get('CIDToGIDMap');
  30454. if (isStream(cidToGidMap)) {
  30455. properties.cidToGidMap = this.readCidToGidMap(cidToGidMap);
  30456. }
  30457. }
  30458. var differences = [];
  30459. var baseEncodingName = null;
  30460. var encoding;
  30461. if (dict.has('Encoding')) {
  30462. encoding = dict.get('Encoding');
  30463. if (isDict(encoding)) {
  30464. baseEncodingName = encoding.get('BaseEncoding');
  30465. baseEncodingName = isName(baseEncodingName) ? baseEncodingName.name : null;
  30466. if (encoding.has('Differences')) {
  30467. var diffEncoding = encoding.get('Differences');
  30468. var index = 0;
  30469. for (var j = 0, jj = diffEncoding.length; j < jj; j++) {
  30470. var data = xref.fetchIfRef(diffEncoding[j]);
  30471. if (isNum(data)) {
  30472. index = data;
  30473. } else if (isName(data)) {
  30474. differences[index++] = data.name;
  30475. } else {
  30476. error('Invalid entry in \'Differences\' array: ' + data);
  30477. }
  30478. }
  30479. }
  30480. } else if (isName(encoding)) {
  30481. baseEncodingName = encoding.name;
  30482. } else {
  30483. error('Encoding is not a Name nor a Dict');
  30484. }
  30485. if (baseEncodingName !== 'MacRomanEncoding' && baseEncodingName !== 'MacExpertEncoding' && baseEncodingName !== 'WinAnsiEncoding') {
  30486. baseEncodingName = null;
  30487. }
  30488. }
  30489. if (baseEncodingName) {
  30490. properties.defaultEncoding = getEncoding(baseEncodingName).slice();
  30491. } else {
  30492. var isSymbolicFont = !!(properties.flags & FontFlags.Symbolic);
  30493. var isNonsymbolicFont = !!(properties.flags & FontFlags.Nonsymbolic);
  30494. encoding = StandardEncoding;
  30495. if (properties.type === 'TrueType' && !isNonsymbolicFont) {
  30496. encoding = WinAnsiEncoding;
  30497. }
  30498. if (isSymbolicFont) {
  30499. encoding = MacRomanEncoding;
  30500. if (!properties.file) {
  30501. if (/Symbol/i.test(properties.name)) {
  30502. encoding = SymbolSetEncoding;
  30503. } else if (/Dingbats/i.test(properties.name)) {
  30504. encoding = ZapfDingbatsEncoding;
  30505. }
  30506. }
  30507. }
  30508. properties.defaultEncoding = encoding;
  30509. }
  30510. properties.differences = differences;
  30511. properties.baseEncodingName = baseEncodingName;
  30512. properties.hasEncoding = !!baseEncodingName || differences.length > 0;
  30513. properties.dict = dict;
  30514. return toUnicodePromise.then(function (toUnicode) {
  30515. properties.toUnicode = toUnicode;
  30516. return this.buildToUnicode(properties);
  30517. }.bind(this)).then(function (toUnicode) {
  30518. properties.toUnicode = toUnicode;
  30519. return properties;
  30520. });
  30521. },
  30522. buildToUnicode: function PartialEvaluator_buildToUnicode(properties) {
  30523. properties.hasIncludedToUnicodeMap = !!properties.toUnicode && properties.toUnicode.length > 0;
  30524. if (properties.hasIncludedToUnicodeMap) {
  30525. return Promise.resolve(properties.toUnicode);
  30526. }
  30527. var toUnicode, charcode, glyphName;
  30528. if (!properties.composite) {
  30529. toUnicode = [];
  30530. var encoding = properties.defaultEncoding.slice();
  30531. var baseEncodingName = properties.baseEncodingName;
  30532. var differences = properties.differences;
  30533. for (charcode in differences) {
  30534. glyphName = differences[charcode];
  30535. if (glyphName === '.notdef') {
  30536. continue;
  30537. }
  30538. encoding[charcode] = glyphName;
  30539. }
  30540. var glyphsUnicodeMap = getGlyphsUnicode();
  30541. for (charcode in encoding) {
  30542. glyphName = encoding[charcode];
  30543. if (glyphName === '') {
  30544. continue;
  30545. } else if (glyphsUnicodeMap[glyphName] === undefined) {
  30546. var code = 0;
  30547. switch (glyphName[0]) {
  30548. case 'G':
  30549. if (glyphName.length === 3) {
  30550. code = parseInt(glyphName.substr(1), 16);
  30551. }
  30552. break;
  30553. case 'g':
  30554. if (glyphName.length === 5) {
  30555. code = parseInt(glyphName.substr(1), 16);
  30556. }
  30557. break;
  30558. case 'C':
  30559. case 'c':
  30560. if (glyphName.length >= 3) {
  30561. code = +glyphName.substr(1);
  30562. }
  30563. break;
  30564. default:
  30565. var unicode = getUnicodeForGlyph(glyphName, glyphsUnicodeMap);
  30566. if (unicode !== -1) {
  30567. code = unicode;
  30568. }
  30569. }
  30570. if (code) {
  30571. if (baseEncodingName && code === +charcode) {
  30572. var baseEncoding = getEncoding(baseEncodingName);
  30573. if (baseEncoding && (glyphName = baseEncoding[charcode])) {
  30574. toUnicode[charcode] = String.fromCharCode(glyphsUnicodeMap[glyphName]);
  30575. continue;
  30576. }
  30577. }
  30578. toUnicode[charcode] = String.fromCharCode(code);
  30579. }
  30580. continue;
  30581. }
  30582. toUnicode[charcode] = String.fromCharCode(glyphsUnicodeMap[glyphName]);
  30583. }
  30584. return Promise.resolve(new ToUnicodeMap(toUnicode));
  30585. }
  30586. 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'))) {
  30587. var registry = properties.cidSystemInfo.registry;
  30588. var ordering = properties.cidSystemInfo.ordering;
  30589. var ucs2CMapName = Name.get(registry + '-' + ordering + '-UCS2');
  30590. return CMapFactory.create(ucs2CMapName, this.options.cMapOptions, null).then(function (ucs2CMap) {
  30591. var cMap = properties.cMap;
  30592. toUnicode = [];
  30593. cMap.forEach(function (charcode, cid) {
  30594. assert(cid <= 0xffff, 'Max size of CID is 65,535');
  30595. var ucs2 = ucs2CMap.lookup(cid);
  30596. if (ucs2) {
  30597. toUnicode[charcode] = String.fromCharCode((ucs2.charCodeAt(0) << 8) + ucs2.charCodeAt(1));
  30598. }
  30599. });
  30600. return new ToUnicodeMap(toUnicode);
  30601. });
  30602. }
  30603. return Promise.resolve(new IdentityToUnicodeMap(properties.firstChar, properties.lastChar));
  30604. },
  30605. readToUnicode: function PartialEvaluator_readToUnicode(toUnicode) {
  30606. var cmapObj = toUnicode;
  30607. if (isName(cmapObj)) {
  30608. return CMapFactory.create(cmapObj, this.options.cMapOptions, null).then(function (cmap) {
  30609. if (cmap instanceof IdentityCMap) {
  30610. return new IdentityToUnicodeMap(0, 0xFFFF);
  30611. }
  30612. return new ToUnicodeMap(cmap.getMap());
  30613. });
  30614. } else if (isStream(cmapObj)) {
  30615. return CMapFactory.create(cmapObj, this.options.cMapOptions, null).then(function (cmap) {
  30616. if (cmap instanceof IdentityCMap) {
  30617. return new IdentityToUnicodeMap(0, 0xFFFF);
  30618. }
  30619. var map = new Array(cmap.length);
  30620. cmap.forEach(function (charCode, token) {
  30621. var str = [];
  30622. for (var k = 0; k < token.length; k += 2) {
  30623. var w1 = token.charCodeAt(k) << 8 | token.charCodeAt(k + 1);
  30624. if ((w1 & 0xF800) !== 0xD800) {
  30625. str.push(w1);
  30626. continue;
  30627. }
  30628. k += 2;
  30629. var w2 = token.charCodeAt(k) << 8 | token.charCodeAt(k + 1);
  30630. str.push(((w1 & 0x3ff) << 10) + (w2 & 0x3ff) + 0x10000);
  30631. }
  30632. map[charCode] = String.fromCharCode.apply(String, str);
  30633. });
  30634. return new ToUnicodeMap(map);
  30635. });
  30636. }
  30637. return Promise.resolve(null);
  30638. },
  30639. readCidToGidMap: function PartialEvaluator_readCidToGidMap(cidToGidStream) {
  30640. var glyphsData = cidToGidStream.getBytes();
  30641. var result = [];
  30642. for (var j = 0, jj = glyphsData.length; j < jj; j++) {
  30643. var glyphID = glyphsData[j++] << 8 | glyphsData[j];
  30644. if (glyphID === 0) {
  30645. continue;
  30646. }
  30647. var code = j >> 1;
  30648. result[code] = glyphID;
  30649. }
  30650. return result;
  30651. },
  30652. extractWidths: function PartialEvaluator_extractWidths(dict, xref, descriptor, properties) {
  30653. var glyphsWidths = [];
  30654. var defaultWidth = 0;
  30655. var glyphsVMetrics = [];
  30656. var defaultVMetrics;
  30657. var i, ii, j, jj, start, code, widths;
  30658. if (properties.composite) {
  30659. defaultWidth = dict.get('DW') || 1000;
  30660. widths = dict.get('W');
  30661. if (widths) {
  30662. for (i = 0, ii = widths.length; i < ii; i++) {
  30663. start = xref.fetchIfRef(widths[i++]);
  30664. code = xref.fetchIfRef(widths[i]);
  30665. if (isArray(code)) {
  30666. for (j = 0, jj = code.length; j < jj; j++) {
  30667. glyphsWidths[start++] = xref.fetchIfRef(code[j]);
  30668. }
  30669. } else {
  30670. var width = xref.fetchIfRef(widths[++i]);
  30671. for (j = start; j <= code; j++) {
  30672. glyphsWidths[j] = width;
  30673. }
  30674. }
  30675. }
  30676. }
  30677. if (properties.vertical) {
  30678. var vmetrics = dict.getArray('DW2') || [
  30679. 880,
  30680. -1000
  30681. ];
  30682. defaultVMetrics = [
  30683. vmetrics[1],
  30684. defaultWidth * 0.5,
  30685. vmetrics[0]
  30686. ];
  30687. vmetrics = dict.get('W2');
  30688. if (vmetrics) {
  30689. for (i = 0, ii = vmetrics.length; i < ii; i++) {
  30690. start = xref.fetchIfRef(vmetrics[i++]);
  30691. code = xref.fetchIfRef(vmetrics[i]);
  30692. if (isArray(code)) {
  30693. for (j = 0, jj = code.length; j < jj; j++) {
  30694. glyphsVMetrics[start++] = [
  30695. xref.fetchIfRef(code[j++]),
  30696. xref.fetchIfRef(code[j++]),
  30697. xref.fetchIfRef(code[j])
  30698. ];
  30699. }
  30700. } else {
  30701. var vmetric = [
  30702. xref.fetchIfRef(vmetrics[++i]),
  30703. xref.fetchIfRef(vmetrics[++i]),
  30704. xref.fetchIfRef(vmetrics[++i])
  30705. ];
  30706. for (j = start; j <= code; j++) {
  30707. glyphsVMetrics[j] = vmetric;
  30708. }
  30709. }
  30710. }
  30711. }
  30712. }
  30713. } else {
  30714. var firstChar = properties.firstChar;
  30715. widths = dict.get('Widths');
  30716. if (widths) {
  30717. j = firstChar;
  30718. for (i = 0, ii = widths.length; i < ii; i++) {
  30719. glyphsWidths[j++] = xref.fetchIfRef(widths[i]);
  30720. }
  30721. defaultWidth = parseFloat(descriptor.get('MissingWidth')) || 0;
  30722. } else {
  30723. var baseFontName = dict.get('BaseFont');
  30724. if (isName(baseFontName)) {
  30725. var metrics = this.getBaseFontMetrics(baseFontName.name);
  30726. glyphsWidths = this.buildCharCodeToWidth(metrics.widths, properties);
  30727. defaultWidth = metrics.defaultWidth;
  30728. }
  30729. }
  30730. }
  30731. var isMonospace = true;
  30732. var firstWidth = defaultWidth;
  30733. for (var glyph in glyphsWidths) {
  30734. var glyphWidth = glyphsWidths[glyph];
  30735. if (!glyphWidth) {
  30736. continue;
  30737. }
  30738. if (!firstWidth) {
  30739. firstWidth = glyphWidth;
  30740. continue;
  30741. }
  30742. if (firstWidth !== glyphWidth) {
  30743. isMonospace = false;
  30744. break;
  30745. }
  30746. }
  30747. if (isMonospace) {
  30748. properties.flags |= FontFlags.FixedPitch;
  30749. }
  30750. properties.defaultWidth = defaultWidth;
  30751. properties.widths = glyphsWidths;
  30752. properties.defaultVMetrics = defaultVMetrics;
  30753. properties.vmetrics = glyphsVMetrics;
  30754. },
  30755. isSerifFont: function PartialEvaluator_isSerifFont(baseFontName) {
  30756. var fontNameWoStyle = baseFontName.split('-')[0];
  30757. return fontNameWoStyle in getSerifFonts() || fontNameWoStyle.search(/serif/gi) !== -1;
  30758. },
  30759. getBaseFontMetrics: function PartialEvaluator_getBaseFontMetrics(name) {
  30760. var defaultWidth = 0;
  30761. var widths = [];
  30762. var monospace = false;
  30763. var stdFontMap = getStdFontMap();
  30764. var lookupName = stdFontMap[name] || name;
  30765. var Metrics = getMetrics();
  30766. if (!(lookupName in Metrics)) {
  30767. if (this.isSerifFont(name)) {
  30768. lookupName = 'Times-Roman';
  30769. } else {
  30770. lookupName = 'Helvetica';
  30771. }
  30772. }
  30773. var glyphWidths = Metrics[lookupName];
  30774. if (isNum(glyphWidths)) {
  30775. defaultWidth = glyphWidths;
  30776. monospace = true;
  30777. } else {
  30778. widths = glyphWidths();
  30779. }
  30780. return {
  30781. defaultWidth: defaultWidth,
  30782. monospace: monospace,
  30783. widths: widths
  30784. };
  30785. },
  30786. buildCharCodeToWidth: function PartialEvaluator_bulildCharCodeToWidth(widthsByGlyphName, properties) {
  30787. var widths = Object.create(null);
  30788. var differences = properties.differences;
  30789. var encoding = properties.defaultEncoding;
  30790. for (var charCode = 0; charCode < 256; charCode++) {
  30791. if (charCode in differences && widthsByGlyphName[differences[charCode]]) {
  30792. widths[charCode] = widthsByGlyphName[differences[charCode]];
  30793. continue;
  30794. }
  30795. if (charCode in encoding && widthsByGlyphName[encoding[charCode]]) {
  30796. widths[charCode] = widthsByGlyphName[encoding[charCode]];
  30797. continue;
  30798. }
  30799. }
  30800. return widths;
  30801. },
  30802. preEvaluateFont: function PartialEvaluator_preEvaluateFont(dict, xref) {
  30803. var baseDict = dict;
  30804. var type = dict.get('Subtype');
  30805. assert(isName(type), 'invalid font Subtype');
  30806. var composite = false;
  30807. var uint8array;
  30808. if (type.name === 'Type0') {
  30809. var df = dict.get('DescendantFonts');
  30810. if (!df) {
  30811. error('Descendant fonts are not specified');
  30812. }
  30813. dict = isArray(df) ? xref.fetchIfRef(df[0]) : df;
  30814. type = dict.get('Subtype');
  30815. assert(isName(type), 'invalid font Subtype');
  30816. composite = true;
  30817. }
  30818. var descriptor = dict.get('FontDescriptor');
  30819. if (descriptor) {
  30820. var hash = new MurmurHash3_64();
  30821. var encoding = baseDict.getRaw('Encoding');
  30822. if (isName(encoding)) {
  30823. hash.update(encoding.name);
  30824. } else if (isRef(encoding)) {
  30825. hash.update(encoding.toString());
  30826. } else if (isDict(encoding)) {
  30827. var keys = encoding.getKeys();
  30828. for (var i = 0, ii = keys.length; i < ii; i++) {
  30829. var entry = encoding.getRaw(keys[i]);
  30830. if (isName(entry)) {
  30831. hash.update(entry.name);
  30832. } else if (isRef(entry)) {
  30833. hash.update(entry.toString());
  30834. } else if (isArray(entry)) {
  30835. var diffLength = entry.length, diffBuf = new Array(diffLength);
  30836. for (var j = 0; j < diffLength; j++) {
  30837. var diffEntry = entry[j];
  30838. if (isName(diffEntry)) {
  30839. diffBuf[j] = diffEntry.name;
  30840. } else if (isNum(diffEntry) || isRef(diffEntry)) {
  30841. diffBuf[j] = diffEntry.toString();
  30842. }
  30843. }
  30844. hash.update(diffBuf.join());
  30845. }
  30846. }
  30847. }
  30848. var toUnicode = dict.get('ToUnicode') || baseDict.get('ToUnicode');
  30849. if (isStream(toUnicode)) {
  30850. var stream = toUnicode.str || toUnicode;
  30851. uint8array = stream.buffer ? new Uint8Array(stream.buffer.buffer, 0, stream.bufferLength) : new Uint8Array(stream.bytes.buffer, stream.start, stream.end - stream.start);
  30852. hash.update(uint8array);
  30853. } else if (isName(toUnicode)) {
  30854. hash.update(toUnicode.name);
  30855. }
  30856. var widths = dict.get('Widths') || baseDict.get('Widths');
  30857. if (widths) {
  30858. uint8array = new Uint8Array(new Uint32Array(widths).buffer);
  30859. hash.update(uint8array);
  30860. }
  30861. }
  30862. return {
  30863. descriptor: descriptor,
  30864. dict: dict,
  30865. baseDict: baseDict,
  30866. composite: composite,
  30867. type: type.name,
  30868. hash: hash ? hash.hexdigest() : ''
  30869. };
  30870. },
  30871. translateFont: function PartialEvaluator_translateFont(preEvaluatedFont, xref) {
  30872. var baseDict = preEvaluatedFont.baseDict;
  30873. var dict = preEvaluatedFont.dict;
  30874. var composite = preEvaluatedFont.composite;
  30875. var descriptor = preEvaluatedFont.descriptor;
  30876. var type = preEvaluatedFont.type;
  30877. var maxCharIndex = composite ? 0xFFFF : 0xFF;
  30878. var cMapOptions = this.options.cMapOptions;
  30879. var properties;
  30880. if (!descriptor) {
  30881. if (type === 'Type3') {
  30882. descriptor = new Dict(null);
  30883. descriptor.set('FontName', Name.get(type));
  30884. descriptor.set('FontBBox', dict.getArray('FontBBox'));
  30885. } else {
  30886. var baseFontName = dict.get('BaseFont');
  30887. if (!isName(baseFontName)) {
  30888. error('Base font is not specified');
  30889. }
  30890. baseFontName = baseFontName.name.replace(/[,_]/g, '-');
  30891. var metrics = this.getBaseFontMetrics(baseFontName);
  30892. var fontNameWoStyle = baseFontName.split('-')[0];
  30893. var flags = (this.isSerifFont(fontNameWoStyle) ? FontFlags.Serif : 0) | (metrics.monospace ? FontFlags.FixedPitch : 0) | (getSymbolsFonts()[fontNameWoStyle] ? FontFlags.Symbolic : FontFlags.Nonsymbolic);
  30894. properties = {
  30895. type: type,
  30896. name: baseFontName,
  30897. widths: metrics.widths,
  30898. defaultWidth: metrics.defaultWidth,
  30899. flags: flags,
  30900. firstChar: 0,
  30901. lastChar: maxCharIndex
  30902. };
  30903. return this.extractDataStructures(dict, dict, xref, properties).then(function (properties) {
  30904. properties.widths = this.buildCharCodeToWidth(metrics.widths, properties);
  30905. return new Font(baseFontName, null, properties);
  30906. }.bind(this));
  30907. }
  30908. }
  30909. var firstChar = dict.get('FirstChar') || 0;
  30910. var lastChar = dict.get('LastChar') || maxCharIndex;
  30911. var fontName = descriptor.get('FontName');
  30912. var baseFont = dict.get('BaseFont');
  30913. if (isString(fontName)) {
  30914. fontName = Name.get(fontName);
  30915. }
  30916. if (isString(baseFont)) {
  30917. baseFont = Name.get(baseFont);
  30918. }
  30919. if (type !== 'Type3') {
  30920. var fontNameStr = fontName && fontName.name;
  30921. var baseFontStr = baseFont && baseFont.name;
  30922. if (fontNameStr !== baseFontStr) {
  30923. info('The FontDescriptor\'s FontName is "' + fontNameStr + '" but should be the same as the Font\'s BaseFont "' + baseFontStr + '"');
  30924. if (fontNameStr && baseFontStr && baseFontStr.indexOf(fontNameStr) === 0) {
  30925. fontName = baseFont;
  30926. }
  30927. }
  30928. }
  30929. fontName = fontName || baseFont;
  30930. assert(isName(fontName), 'invalid font name');
  30931. var fontFile = descriptor.get('FontFile', 'FontFile2', 'FontFile3');
  30932. if (fontFile) {
  30933. if (fontFile.dict) {
  30934. var subtype = fontFile.dict.get('Subtype');
  30935. if (subtype) {
  30936. subtype = subtype.name;
  30937. }
  30938. var length1 = fontFile.dict.get('Length1');
  30939. var length2 = fontFile.dict.get('Length2');
  30940. var length3 = fontFile.dict.get('Length3');
  30941. }
  30942. }
  30943. properties = {
  30944. type: type,
  30945. name: fontName.name,
  30946. subtype: subtype,
  30947. file: fontFile,
  30948. length1: length1,
  30949. length2: length2,
  30950. length3: length3,
  30951. loadedName: baseDict.loadedName,
  30952. composite: composite,
  30953. wideChars: composite,
  30954. fixedPitch: false,
  30955. fontMatrix: dict.getArray('FontMatrix') || FONT_IDENTITY_MATRIX,
  30956. firstChar: firstChar || 0,
  30957. lastChar: lastChar || maxCharIndex,
  30958. bbox: descriptor.getArray('FontBBox'),
  30959. ascent: descriptor.get('Ascent'),
  30960. descent: descriptor.get('Descent'),
  30961. xHeight: descriptor.get('XHeight'),
  30962. capHeight: descriptor.get('CapHeight'),
  30963. flags: descriptor.get('Flags'),
  30964. italicAngle: descriptor.get('ItalicAngle'),
  30965. coded: false
  30966. };
  30967. var cMapPromise;
  30968. if (composite) {
  30969. var cidEncoding = baseDict.get('Encoding');
  30970. if (isName(cidEncoding)) {
  30971. properties.cidEncoding = cidEncoding.name;
  30972. }
  30973. cMapPromise = CMapFactory.create(cidEncoding, cMapOptions, null).then(function (cMap) {
  30974. properties.cMap = cMap;
  30975. properties.vertical = properties.cMap.vertical;
  30976. });
  30977. } else {
  30978. cMapPromise = Promise.resolve(undefined);
  30979. }
  30980. return cMapPromise.then(function () {
  30981. return this.extractDataStructures(dict, baseDict, xref, properties);
  30982. }.bind(this)).then(function (properties) {
  30983. this.extractWidths(dict, xref, descriptor, properties);
  30984. if (type === 'Type3') {
  30985. properties.isType3Font = true;
  30986. }
  30987. return new Font(fontName.name, fontFile, properties);
  30988. }.bind(this));
  30989. }
  30990. };
  30991. return PartialEvaluator;
  30992. }();
  30993. var TranslatedFont = function TranslatedFontClosure() {
  30994. function TranslatedFont(loadedName, font, dict) {
  30995. this.loadedName = loadedName;
  30996. this.font = font;
  30997. this.dict = dict;
  30998. this.type3Loaded = null;
  30999. this.sent = false;
  31000. }
  31001. TranslatedFont.prototype = {
  31002. send: function (handler) {
  31003. if (this.sent) {
  31004. return;
  31005. }
  31006. var fontData = this.font.exportData();
  31007. handler.send('commonobj', [
  31008. this.loadedName,
  31009. 'Font',
  31010. fontData
  31011. ]);
  31012. this.sent = true;
  31013. },
  31014. loadType3Data: function (evaluator, resources, parentOperatorList, task) {
  31015. assert(this.font.isType3Font);
  31016. if (this.type3Loaded) {
  31017. return this.type3Loaded;
  31018. }
  31019. var translatedFont = this.font;
  31020. var loadCharProcsPromise = Promise.resolve();
  31021. var charProcs = this.dict.get('CharProcs');
  31022. var fontResources = this.dict.get('Resources') || resources;
  31023. var charProcKeys = charProcs.getKeys();
  31024. var charProcOperatorList = Object.create(null);
  31025. for (var i = 0, n = charProcKeys.length; i < n; ++i) {
  31026. loadCharProcsPromise = loadCharProcsPromise.then(function (key) {
  31027. var glyphStream = charProcs.get(key);
  31028. var operatorList = new OperatorList();
  31029. return evaluator.getOperatorList(glyphStream, task, fontResources, operatorList).then(function () {
  31030. charProcOperatorList[key] = operatorList.getIR();
  31031. parentOperatorList.addDependencies(operatorList.dependencies);
  31032. }, function (reason) {
  31033. warn('Type3 font resource \"' + key + '\" is not available');
  31034. var operatorList = new OperatorList();
  31035. charProcOperatorList[key] = operatorList.getIR();
  31036. });
  31037. }.bind(this, charProcKeys[i]));
  31038. }
  31039. this.type3Loaded = loadCharProcsPromise.then(function () {
  31040. translatedFont.charProcOperatorList = charProcOperatorList;
  31041. });
  31042. return this.type3Loaded;
  31043. }
  31044. };
  31045. return TranslatedFont;
  31046. }();
  31047. var OperatorList = function OperatorListClosure() {
  31048. var CHUNK_SIZE = 1000;
  31049. var CHUNK_SIZE_ABOUT = CHUNK_SIZE - 5;
  31050. function getTransfers(queue) {
  31051. var transfers = [];
  31052. var fnArray = queue.fnArray, argsArray = queue.argsArray;
  31053. for (var i = 0, ii = queue.length; i < ii; i++) {
  31054. switch (fnArray[i]) {
  31055. case OPS.paintInlineImageXObject:
  31056. case OPS.paintInlineImageXObjectGroup:
  31057. case OPS.paintImageMaskXObject:
  31058. var arg = argsArray[i][0];
  31059. if (!arg.cached) {
  31060. transfers.push(arg.data.buffer);
  31061. }
  31062. break;
  31063. }
  31064. }
  31065. return transfers;
  31066. }
  31067. function OperatorList(intent, messageHandler, pageIndex) {
  31068. this.messageHandler = messageHandler;
  31069. this.fnArray = [];
  31070. this.argsArray = [];
  31071. this.dependencies = Object.create(null);
  31072. this._totalLength = 0;
  31073. this.pageIndex = pageIndex;
  31074. this.intent = intent;
  31075. }
  31076. OperatorList.prototype = {
  31077. get length() {
  31078. return this.argsArray.length;
  31079. },
  31080. get totalLength() {
  31081. return this._totalLength + this.length;
  31082. },
  31083. addOp: function (fn, args) {
  31084. this.fnArray.push(fn);
  31085. this.argsArray.push(args);
  31086. if (this.messageHandler) {
  31087. if (this.fnArray.length >= CHUNK_SIZE) {
  31088. this.flush();
  31089. } else if (this.fnArray.length >= CHUNK_SIZE_ABOUT && (fn === OPS.restore || fn === OPS.endText)) {
  31090. this.flush();
  31091. }
  31092. }
  31093. },
  31094. addDependency: function (dependency) {
  31095. if (dependency in this.dependencies) {
  31096. return;
  31097. }
  31098. this.dependencies[dependency] = true;
  31099. this.addOp(OPS.dependency, [dependency]);
  31100. },
  31101. addDependencies: function (dependencies) {
  31102. for (var key in dependencies) {
  31103. this.addDependency(key);
  31104. }
  31105. },
  31106. addOpList: function (opList) {
  31107. Util.extendObj(this.dependencies, opList.dependencies);
  31108. for (var i = 0, ii = opList.length; i < ii; i++) {
  31109. this.addOp(opList.fnArray[i], opList.argsArray[i]);
  31110. }
  31111. },
  31112. getIR: function () {
  31113. return {
  31114. fnArray: this.fnArray,
  31115. argsArray: this.argsArray,
  31116. length: this.length
  31117. };
  31118. },
  31119. flush: function (lastChunk) {
  31120. if (this.intent !== 'oplist') {
  31121. new QueueOptimizer().optimize(this);
  31122. }
  31123. var transfers = getTransfers(this);
  31124. var length = this.length;
  31125. this._totalLength += length;
  31126. this.messageHandler.send('RenderPageChunk', {
  31127. operatorList: {
  31128. fnArray: this.fnArray,
  31129. argsArray: this.argsArray,
  31130. lastChunk: lastChunk,
  31131. length: length
  31132. },
  31133. pageIndex: this.pageIndex,
  31134. intent: this.intent
  31135. }, transfers);
  31136. this.dependencies = Object.create(null);
  31137. this.fnArray.length = 0;
  31138. this.argsArray.length = 0;
  31139. }
  31140. };
  31141. return OperatorList;
  31142. }();
  31143. var StateManager = function StateManagerClosure() {
  31144. function StateManager(initialState) {
  31145. this.state = initialState;
  31146. this.stateStack = [];
  31147. }
  31148. StateManager.prototype = {
  31149. save: function () {
  31150. var old = this.state;
  31151. this.stateStack.push(this.state);
  31152. this.state = old.clone();
  31153. },
  31154. restore: function () {
  31155. var prev = this.stateStack.pop();
  31156. if (prev) {
  31157. this.state = prev;
  31158. }
  31159. },
  31160. transform: function (args) {
  31161. this.state.ctm = Util.transform(this.state.ctm, args);
  31162. }
  31163. };
  31164. return StateManager;
  31165. }();
  31166. var TextState = function TextStateClosure() {
  31167. function TextState() {
  31168. this.ctm = new Float32Array(IDENTITY_MATRIX);
  31169. this.fontName = null;
  31170. this.fontSize = 0;
  31171. this.font = null;
  31172. this.fontMatrix = FONT_IDENTITY_MATRIX;
  31173. this.textMatrix = IDENTITY_MATRIX.slice();
  31174. this.textLineMatrix = IDENTITY_MATRIX.slice();
  31175. this.charSpacing = 0;
  31176. this.wordSpacing = 0;
  31177. this.leading = 0;
  31178. this.textHScale = 1;
  31179. this.textRise = 0;
  31180. }
  31181. TextState.prototype = {
  31182. setTextMatrix: function TextState_setTextMatrix(a, b, c, d, e, f) {
  31183. var m = this.textMatrix;
  31184. m[0] = a;
  31185. m[1] = b;
  31186. m[2] = c;
  31187. m[3] = d;
  31188. m[4] = e;
  31189. m[5] = f;
  31190. },
  31191. setTextLineMatrix: function TextState_setTextMatrix(a, b, c, d, e, f) {
  31192. var m = this.textLineMatrix;
  31193. m[0] = a;
  31194. m[1] = b;
  31195. m[2] = c;
  31196. m[3] = d;
  31197. m[4] = e;
  31198. m[5] = f;
  31199. },
  31200. translateTextMatrix: function TextState_translateTextMatrix(x, y) {
  31201. var m = this.textMatrix;
  31202. m[4] = m[0] * x + m[2] * y + m[4];
  31203. m[5] = m[1] * x + m[3] * y + m[5];
  31204. },
  31205. translateTextLineMatrix: function TextState_translateTextMatrix(x, y) {
  31206. var m = this.textLineMatrix;
  31207. m[4] = m[0] * x + m[2] * y + m[4];
  31208. m[5] = m[1] * x + m[3] * y + m[5];
  31209. },
  31210. calcTextLineMatrixAdvance: function TextState_calcTextLineMatrixAdvance(a, b, c, d, e, f) {
  31211. var font = this.font;
  31212. if (!font) {
  31213. return null;
  31214. }
  31215. var m = this.textLineMatrix;
  31216. if (!(a === m[0] && b === m[1] && c === m[2] && d === m[3])) {
  31217. return null;
  31218. }
  31219. var txDiff = e - m[4], tyDiff = f - m[5];
  31220. if (font.vertical && txDiff !== 0 || !font.vertical && tyDiff !== 0) {
  31221. return null;
  31222. }
  31223. var tx, ty, denominator = a * d - b * c;
  31224. if (font.vertical) {
  31225. tx = -tyDiff * c / denominator;
  31226. ty = tyDiff * a / denominator;
  31227. } else {
  31228. tx = txDiff * d / denominator;
  31229. ty = -txDiff * b / denominator;
  31230. }
  31231. return {
  31232. width: tx,
  31233. height: ty,
  31234. value: font.vertical ? ty : tx
  31235. };
  31236. },
  31237. calcRenderMatrix: function TextState_calcRendeMatrix(ctm) {
  31238. var tsm = [
  31239. this.fontSize * this.textHScale,
  31240. 0,
  31241. 0,
  31242. this.fontSize,
  31243. 0,
  31244. this.textRise
  31245. ];
  31246. return Util.transform(ctm, Util.transform(this.textMatrix, tsm));
  31247. },
  31248. carriageReturn: function TextState_carriageReturn() {
  31249. this.translateTextLineMatrix(0, -this.leading);
  31250. this.textMatrix = this.textLineMatrix.slice();
  31251. },
  31252. clone: function TextState_clone() {
  31253. var clone = Object.create(this);
  31254. clone.textMatrix = this.textMatrix.slice();
  31255. clone.textLineMatrix = this.textLineMatrix.slice();
  31256. clone.fontMatrix = this.fontMatrix.slice();
  31257. return clone;
  31258. }
  31259. };
  31260. return TextState;
  31261. }();
  31262. var EvalState = function EvalStateClosure() {
  31263. function EvalState() {
  31264. this.ctm = new Float32Array(IDENTITY_MATRIX);
  31265. this.font = null;
  31266. this.textRenderingMode = TextRenderingMode.FILL;
  31267. this.fillColorSpace = ColorSpace.singletons.gray;
  31268. this.strokeColorSpace = ColorSpace.singletons.gray;
  31269. }
  31270. EvalState.prototype = {
  31271. clone: function CanvasExtraState_clone() {
  31272. return Object.create(this);
  31273. }
  31274. };
  31275. return EvalState;
  31276. }();
  31277. var EvaluatorPreprocessor = function EvaluatorPreprocessorClosure() {
  31278. var getOPMap = getLookupTableFactory(function (t) {
  31279. t['w'] = {
  31280. id: OPS.setLineWidth,
  31281. numArgs: 1,
  31282. variableArgs: false
  31283. };
  31284. t['J'] = {
  31285. id: OPS.setLineCap,
  31286. numArgs: 1,
  31287. variableArgs: false
  31288. };
  31289. t['j'] = {
  31290. id: OPS.setLineJoin,
  31291. numArgs: 1,
  31292. variableArgs: false
  31293. };
  31294. t['M'] = {
  31295. id: OPS.setMiterLimit,
  31296. numArgs: 1,
  31297. variableArgs: false
  31298. };
  31299. t['d'] = {
  31300. id: OPS.setDash,
  31301. numArgs: 2,
  31302. variableArgs: false
  31303. };
  31304. t['ri'] = {
  31305. id: OPS.setRenderingIntent,
  31306. numArgs: 1,
  31307. variableArgs: false
  31308. };
  31309. t['i'] = {
  31310. id: OPS.setFlatness,
  31311. numArgs: 1,
  31312. variableArgs: false
  31313. };
  31314. t['gs'] = {
  31315. id: OPS.setGState,
  31316. numArgs: 1,
  31317. variableArgs: false
  31318. };
  31319. t['q'] = {
  31320. id: OPS.save,
  31321. numArgs: 0,
  31322. variableArgs: false
  31323. };
  31324. t['Q'] = {
  31325. id: OPS.restore,
  31326. numArgs: 0,
  31327. variableArgs: false
  31328. };
  31329. t['cm'] = {
  31330. id: OPS.transform,
  31331. numArgs: 6,
  31332. variableArgs: false
  31333. };
  31334. t['m'] = {
  31335. id: OPS.moveTo,
  31336. numArgs: 2,
  31337. variableArgs: false
  31338. };
  31339. t['l'] = {
  31340. id: OPS.lineTo,
  31341. numArgs: 2,
  31342. variableArgs: false
  31343. };
  31344. t['c'] = {
  31345. id: OPS.curveTo,
  31346. numArgs: 6,
  31347. variableArgs: false
  31348. };
  31349. t['v'] = {
  31350. id: OPS.curveTo2,
  31351. numArgs: 4,
  31352. variableArgs: false
  31353. };
  31354. t['y'] = {
  31355. id: OPS.curveTo3,
  31356. numArgs: 4,
  31357. variableArgs: false
  31358. };
  31359. t['h'] = {
  31360. id: OPS.closePath,
  31361. numArgs: 0,
  31362. variableArgs: false
  31363. };
  31364. t['re'] = {
  31365. id: OPS.rectangle,
  31366. numArgs: 4,
  31367. variableArgs: false
  31368. };
  31369. t['S'] = {
  31370. id: OPS.stroke,
  31371. numArgs: 0,
  31372. variableArgs: false
  31373. };
  31374. t['s'] = {
  31375. id: OPS.closeStroke,
  31376. numArgs: 0,
  31377. variableArgs: false
  31378. };
  31379. t['f'] = {
  31380. id: OPS.fill,
  31381. numArgs: 0,
  31382. variableArgs: false
  31383. };
  31384. t['F'] = {
  31385. id: OPS.fill,
  31386. numArgs: 0,
  31387. variableArgs: false
  31388. };
  31389. t['f*'] = {
  31390. id: OPS.eoFill,
  31391. numArgs: 0,
  31392. variableArgs: false
  31393. };
  31394. t['B'] = {
  31395. id: OPS.fillStroke,
  31396. numArgs: 0,
  31397. variableArgs: false
  31398. };
  31399. t['B*'] = {
  31400. id: OPS.eoFillStroke,
  31401. numArgs: 0,
  31402. variableArgs: false
  31403. };
  31404. t['b'] = {
  31405. id: OPS.closeFillStroke,
  31406. numArgs: 0,
  31407. variableArgs: false
  31408. };
  31409. t['b*'] = {
  31410. id: OPS.closeEOFillStroke,
  31411. numArgs: 0,
  31412. variableArgs: false
  31413. };
  31414. t['n'] = {
  31415. id: OPS.endPath,
  31416. numArgs: 0,
  31417. variableArgs: false
  31418. };
  31419. t['W'] = {
  31420. id: OPS.clip,
  31421. numArgs: 0,
  31422. variableArgs: false
  31423. };
  31424. t['W*'] = {
  31425. id: OPS.eoClip,
  31426. numArgs: 0,
  31427. variableArgs: false
  31428. };
  31429. t['BT'] = {
  31430. id: OPS.beginText,
  31431. numArgs: 0,
  31432. variableArgs: false
  31433. };
  31434. t['ET'] = {
  31435. id: OPS.endText,
  31436. numArgs: 0,
  31437. variableArgs: false
  31438. };
  31439. t['Tc'] = {
  31440. id: OPS.setCharSpacing,
  31441. numArgs: 1,
  31442. variableArgs: false
  31443. };
  31444. t['Tw'] = {
  31445. id: OPS.setWordSpacing,
  31446. numArgs: 1,
  31447. variableArgs: false
  31448. };
  31449. t['Tz'] = {
  31450. id: OPS.setHScale,
  31451. numArgs: 1,
  31452. variableArgs: false
  31453. };
  31454. t['TL'] = {
  31455. id: OPS.setLeading,
  31456. numArgs: 1,
  31457. variableArgs: false
  31458. };
  31459. t['Tf'] = {
  31460. id: OPS.setFont,
  31461. numArgs: 2,
  31462. variableArgs: false
  31463. };
  31464. t['Tr'] = {
  31465. id: OPS.setTextRenderingMode,
  31466. numArgs: 1,
  31467. variableArgs: false
  31468. };
  31469. t['Ts'] = {
  31470. id: OPS.setTextRise,
  31471. numArgs: 1,
  31472. variableArgs: false
  31473. };
  31474. t['Td'] = {
  31475. id: OPS.moveText,
  31476. numArgs: 2,
  31477. variableArgs: false
  31478. };
  31479. t['TD'] = {
  31480. id: OPS.setLeadingMoveText,
  31481. numArgs: 2,
  31482. variableArgs: false
  31483. };
  31484. t['Tm'] = {
  31485. id: OPS.setTextMatrix,
  31486. numArgs: 6,
  31487. variableArgs: false
  31488. };
  31489. t['T*'] = {
  31490. id: OPS.nextLine,
  31491. numArgs: 0,
  31492. variableArgs: false
  31493. };
  31494. t['Tj'] = {
  31495. id: OPS.showText,
  31496. numArgs: 1,
  31497. variableArgs: false
  31498. };
  31499. t['TJ'] = {
  31500. id: OPS.showSpacedText,
  31501. numArgs: 1,
  31502. variableArgs: false
  31503. };
  31504. t['\''] = {
  31505. id: OPS.nextLineShowText,
  31506. numArgs: 1,
  31507. variableArgs: false
  31508. };
  31509. t['"'] = {
  31510. id: OPS.nextLineSetSpacingShowText,
  31511. numArgs: 3,
  31512. variableArgs: false
  31513. };
  31514. t['d0'] = {
  31515. id: OPS.setCharWidth,
  31516. numArgs: 2,
  31517. variableArgs: false
  31518. };
  31519. t['d1'] = {
  31520. id: OPS.setCharWidthAndBounds,
  31521. numArgs: 6,
  31522. variableArgs: false
  31523. };
  31524. t['CS'] = {
  31525. id: OPS.setStrokeColorSpace,
  31526. numArgs: 1,
  31527. variableArgs: false
  31528. };
  31529. t['cs'] = {
  31530. id: OPS.setFillColorSpace,
  31531. numArgs: 1,
  31532. variableArgs: false
  31533. };
  31534. t['SC'] = {
  31535. id: OPS.setStrokeColor,
  31536. numArgs: 4,
  31537. variableArgs: true
  31538. };
  31539. t['SCN'] = {
  31540. id: OPS.setStrokeColorN,
  31541. numArgs: 33,
  31542. variableArgs: true
  31543. };
  31544. t['sc'] = {
  31545. id: OPS.setFillColor,
  31546. numArgs: 4,
  31547. variableArgs: true
  31548. };
  31549. t['scn'] = {
  31550. id: OPS.setFillColorN,
  31551. numArgs: 33,
  31552. variableArgs: true
  31553. };
  31554. t['G'] = {
  31555. id: OPS.setStrokeGray,
  31556. numArgs: 1,
  31557. variableArgs: false
  31558. };
  31559. t['g'] = {
  31560. id: OPS.setFillGray,
  31561. numArgs: 1,
  31562. variableArgs: false
  31563. };
  31564. t['RG'] = {
  31565. id: OPS.setStrokeRGBColor,
  31566. numArgs: 3,
  31567. variableArgs: false
  31568. };
  31569. t['rg'] = {
  31570. id: OPS.setFillRGBColor,
  31571. numArgs: 3,
  31572. variableArgs: false
  31573. };
  31574. t['K'] = {
  31575. id: OPS.setStrokeCMYKColor,
  31576. numArgs: 4,
  31577. variableArgs: false
  31578. };
  31579. t['k'] = {
  31580. id: OPS.setFillCMYKColor,
  31581. numArgs: 4,
  31582. variableArgs: false
  31583. };
  31584. t['sh'] = {
  31585. id: OPS.shadingFill,
  31586. numArgs: 1,
  31587. variableArgs: false
  31588. };
  31589. t['BI'] = {
  31590. id: OPS.beginInlineImage,
  31591. numArgs: 0,
  31592. variableArgs: false
  31593. };
  31594. t['ID'] = {
  31595. id: OPS.beginImageData,
  31596. numArgs: 0,
  31597. variableArgs: false
  31598. };
  31599. t['EI'] = {
  31600. id: OPS.endInlineImage,
  31601. numArgs: 1,
  31602. variableArgs: false
  31603. };
  31604. t['Do'] = {
  31605. id: OPS.paintXObject,
  31606. numArgs: 1,
  31607. variableArgs: false
  31608. };
  31609. t['MP'] = {
  31610. id: OPS.markPoint,
  31611. numArgs: 1,
  31612. variableArgs: false
  31613. };
  31614. t['DP'] = {
  31615. id: OPS.markPointProps,
  31616. numArgs: 2,
  31617. variableArgs: false
  31618. };
  31619. t['BMC'] = {
  31620. id: OPS.beginMarkedContent,
  31621. numArgs: 1,
  31622. variableArgs: false
  31623. };
  31624. t['BDC'] = {
  31625. id: OPS.beginMarkedContentProps,
  31626. numArgs: 2,
  31627. variableArgs: false
  31628. };
  31629. t['EMC'] = {
  31630. id: OPS.endMarkedContent,
  31631. numArgs: 0,
  31632. variableArgs: false
  31633. };
  31634. t['BX'] = {
  31635. id: OPS.beginCompat,
  31636. numArgs: 0,
  31637. variableArgs: false
  31638. };
  31639. t['EX'] = {
  31640. id: OPS.endCompat,
  31641. numArgs: 0,
  31642. variableArgs: false
  31643. };
  31644. t['BM'] = null;
  31645. t['BD'] = null;
  31646. t['true'] = null;
  31647. t['fa'] = null;
  31648. t['fal'] = null;
  31649. t['fals'] = null;
  31650. t['false'] = null;
  31651. t['nu'] = null;
  31652. t['nul'] = null;
  31653. t['null'] = null;
  31654. });
  31655. function EvaluatorPreprocessor(stream, xref, stateManager) {
  31656. this.opMap = getOPMap();
  31657. this.parser = new Parser(new Lexer(stream, this.opMap), false, xref);
  31658. this.stateManager = stateManager;
  31659. this.nonProcessedArgs = [];
  31660. }
  31661. EvaluatorPreprocessor.prototype = {
  31662. get savedStatesDepth() {
  31663. return this.stateManager.stateStack.length;
  31664. },
  31665. read: function EvaluatorPreprocessor_read(operation) {
  31666. var args = operation.args;
  31667. while (true) {
  31668. var obj = this.parser.getObj();
  31669. if (isCmd(obj)) {
  31670. var cmd = obj.cmd;
  31671. var opSpec = this.opMap[cmd];
  31672. if (!opSpec) {
  31673. warn('Unknown command "' + cmd + '"');
  31674. continue;
  31675. }
  31676. var fn = opSpec.id;
  31677. var numArgs = opSpec.numArgs;
  31678. var argsLength = args !== null ? args.length : 0;
  31679. if (!opSpec.variableArgs) {
  31680. if (argsLength !== numArgs) {
  31681. var nonProcessedArgs = this.nonProcessedArgs;
  31682. while (argsLength > numArgs) {
  31683. nonProcessedArgs.push(args.shift());
  31684. argsLength--;
  31685. }
  31686. while (argsLength < numArgs && nonProcessedArgs.length !== 0) {
  31687. if (args === null) {
  31688. args = [];
  31689. }
  31690. args.unshift(nonProcessedArgs.pop());
  31691. argsLength++;
  31692. }
  31693. }
  31694. if (argsLength < numArgs) {
  31695. warn('Skipping command ' + fn + ': expected ' + numArgs + ' args, but received ' + argsLength + ' args.');
  31696. if (args !== null) {
  31697. args.length = 0;
  31698. }
  31699. continue;
  31700. }
  31701. } else if (argsLength > numArgs) {
  31702. info('Command ' + fn + ': expected [0,' + numArgs + '] args, but received ' + argsLength + ' args.');
  31703. }
  31704. this.preprocessCommand(fn, args);
  31705. operation.fn = fn;
  31706. operation.args = args;
  31707. return true;
  31708. }
  31709. if (isEOF(obj)) {
  31710. return false;
  31711. }
  31712. if (obj !== null) {
  31713. if (args === null) {
  31714. args = [];
  31715. }
  31716. args.push(obj);
  31717. assert(args.length <= 33, 'Too many arguments');
  31718. }
  31719. }
  31720. },
  31721. preprocessCommand: function EvaluatorPreprocessor_preprocessCommand(fn, args) {
  31722. switch (fn | 0) {
  31723. case OPS.save:
  31724. this.stateManager.save();
  31725. break;
  31726. case OPS.restore:
  31727. this.stateManager.restore();
  31728. break;
  31729. case OPS.transform:
  31730. this.stateManager.transform(args);
  31731. break;
  31732. }
  31733. }
  31734. };
  31735. return EvaluatorPreprocessor;
  31736. }();
  31737. var QueueOptimizer = function QueueOptimizerClosure() {
  31738. function addState(parentState, pattern, fn) {
  31739. var state = parentState;
  31740. for (var i = 0, ii = pattern.length - 1; i < ii; i++) {
  31741. var item = pattern[i];
  31742. state = state[item] || (state[item] = []);
  31743. }
  31744. state[pattern[pattern.length - 1]] = fn;
  31745. }
  31746. function handlePaintSolidColorImageMask(iFirstSave, count, fnArray, argsArray) {
  31747. var iFirstPIMXO = iFirstSave + 2;
  31748. for (var i = 0; i < count; i++) {
  31749. var arg = argsArray[iFirstPIMXO + 4 * i];
  31750. var imageMask = arg.length === 1 && arg[0];
  31751. if (imageMask && imageMask.width === 1 && imageMask.height === 1 && (!imageMask.data.length || imageMask.data.length === 1 && imageMask.data[0] === 0)) {
  31752. fnArray[iFirstPIMXO + 4 * i] = OPS.paintSolidColorImageMask;
  31753. continue;
  31754. }
  31755. break;
  31756. }
  31757. return count - i;
  31758. }
  31759. var InitialState = [];
  31760. addState(InitialState, [
  31761. OPS.save,
  31762. OPS.transform,
  31763. OPS.paintInlineImageXObject,
  31764. OPS.restore
  31765. ], function foundInlineImageGroup(context) {
  31766. var MIN_IMAGES_IN_INLINE_IMAGES_BLOCK = 10;
  31767. var MAX_IMAGES_IN_INLINE_IMAGES_BLOCK = 200;
  31768. var MAX_WIDTH = 1000;
  31769. var IMAGE_PADDING = 1;
  31770. var fnArray = context.fnArray, argsArray = context.argsArray;
  31771. var curr = context.iCurr;
  31772. var iFirstSave = curr - 3;
  31773. var iFirstTransform = curr - 2;
  31774. var iFirstPIIXO = curr - 1;
  31775. var i = iFirstSave + 4;
  31776. var ii = fnArray.length;
  31777. while (i + 3 < ii) {
  31778. if (fnArray[i] !== OPS.save || fnArray[i + 1] !== OPS.transform || fnArray[i + 2] !== OPS.paintInlineImageXObject || fnArray[i + 3] !== OPS.restore) {
  31779. break;
  31780. }
  31781. i += 4;
  31782. }
  31783. var count = Math.min((i - iFirstSave) / 4, MAX_IMAGES_IN_INLINE_IMAGES_BLOCK);
  31784. if (count < MIN_IMAGES_IN_INLINE_IMAGES_BLOCK) {
  31785. return i;
  31786. }
  31787. var maxX = 0;
  31788. var map = [], maxLineHeight = 0;
  31789. var currentX = IMAGE_PADDING, currentY = IMAGE_PADDING;
  31790. var q;
  31791. for (q = 0; q < count; q++) {
  31792. var transform = argsArray[iFirstTransform + (q << 2)];
  31793. var img = argsArray[iFirstPIIXO + (q << 2)][0];
  31794. if (currentX + img.width > MAX_WIDTH) {
  31795. maxX = Math.max(maxX, currentX);
  31796. currentY += maxLineHeight + 2 * IMAGE_PADDING;
  31797. currentX = 0;
  31798. maxLineHeight = 0;
  31799. }
  31800. map.push({
  31801. transform: transform,
  31802. x: currentX,
  31803. y: currentY,
  31804. w: img.width,
  31805. h: img.height
  31806. });
  31807. currentX += img.width + 2 * IMAGE_PADDING;
  31808. maxLineHeight = Math.max(maxLineHeight, img.height);
  31809. }
  31810. var imgWidth = Math.max(maxX, currentX) + IMAGE_PADDING;
  31811. var imgHeight = currentY + maxLineHeight + IMAGE_PADDING;
  31812. var imgData = new Uint8Array(imgWidth * imgHeight * 4);
  31813. var imgRowSize = imgWidth << 2;
  31814. for (q = 0; q < count; q++) {
  31815. var data = argsArray[iFirstPIIXO + (q << 2)][0].data;
  31816. var rowSize = map[q].w << 2;
  31817. var dataOffset = 0;
  31818. var offset = map[q].x + map[q].y * imgWidth << 2;
  31819. imgData.set(data.subarray(0, rowSize), offset - imgRowSize);
  31820. for (var k = 0, kk = map[q].h; k < kk; k++) {
  31821. imgData.set(data.subarray(dataOffset, dataOffset + rowSize), offset);
  31822. dataOffset += rowSize;
  31823. offset += imgRowSize;
  31824. }
  31825. imgData.set(data.subarray(dataOffset - rowSize, dataOffset), offset);
  31826. while (offset >= 0) {
  31827. data[offset - 4] = data[offset];
  31828. data[offset - 3] = data[offset + 1];
  31829. data[offset - 2] = data[offset + 2];
  31830. data[offset - 1] = data[offset + 3];
  31831. data[offset + rowSize] = data[offset + rowSize - 4];
  31832. data[offset + rowSize + 1] = data[offset + rowSize - 3];
  31833. data[offset + rowSize + 2] = data[offset + rowSize - 2];
  31834. data[offset + rowSize + 3] = data[offset + rowSize - 1];
  31835. offset -= imgRowSize;
  31836. }
  31837. }
  31838. fnArray.splice(iFirstSave, count * 4, OPS.paintInlineImageXObjectGroup);
  31839. argsArray.splice(iFirstSave, count * 4, [
  31840. {
  31841. width: imgWidth,
  31842. height: imgHeight,
  31843. kind: ImageKind.RGBA_32BPP,
  31844. data: imgData
  31845. },
  31846. map
  31847. ]);
  31848. return iFirstSave + 1;
  31849. });
  31850. addState(InitialState, [
  31851. OPS.save,
  31852. OPS.transform,
  31853. OPS.paintImageMaskXObject,
  31854. OPS.restore
  31855. ], function foundImageMaskGroup(context) {
  31856. var MIN_IMAGES_IN_MASKS_BLOCK = 10;
  31857. var MAX_IMAGES_IN_MASKS_BLOCK = 100;
  31858. var MAX_SAME_IMAGES_IN_MASKS_BLOCK = 1000;
  31859. var fnArray = context.fnArray, argsArray = context.argsArray;
  31860. var curr = context.iCurr;
  31861. var iFirstSave = curr - 3;
  31862. var iFirstTransform = curr - 2;
  31863. var iFirstPIMXO = curr - 1;
  31864. var i = iFirstSave + 4;
  31865. var ii = fnArray.length;
  31866. while (i + 3 < ii) {
  31867. if (fnArray[i] !== OPS.save || fnArray[i + 1] !== OPS.transform || fnArray[i + 2] !== OPS.paintImageMaskXObject || fnArray[i + 3] !== OPS.restore) {
  31868. break;
  31869. }
  31870. i += 4;
  31871. }
  31872. var count = (i - iFirstSave) / 4;
  31873. count = handlePaintSolidColorImageMask(iFirstSave, count, fnArray, argsArray);
  31874. if (count < MIN_IMAGES_IN_MASKS_BLOCK) {
  31875. return i;
  31876. }
  31877. var q;
  31878. var isSameImage = false;
  31879. var iTransform, transformArgs;
  31880. var firstPIMXOArg0 = argsArray[iFirstPIMXO][0];
  31881. if (argsArray[iFirstTransform][1] === 0 && argsArray[iFirstTransform][2] === 0) {
  31882. isSameImage = true;
  31883. var firstTransformArg0 = argsArray[iFirstTransform][0];
  31884. var firstTransformArg3 = argsArray[iFirstTransform][3];
  31885. iTransform = iFirstTransform + 4;
  31886. var iPIMXO = iFirstPIMXO + 4;
  31887. for (q = 1; q < count; q++, iTransform += 4, iPIMXO += 4) {
  31888. transformArgs = argsArray[iTransform];
  31889. if (argsArray[iPIMXO][0] !== firstPIMXOArg0 || transformArgs[0] !== firstTransformArg0 || transformArgs[1] !== 0 || transformArgs[2] !== 0 || transformArgs[3] !== firstTransformArg3) {
  31890. if (q < MIN_IMAGES_IN_MASKS_BLOCK) {
  31891. isSameImage = false;
  31892. } else {
  31893. count = q;
  31894. }
  31895. break;
  31896. }
  31897. }
  31898. }
  31899. if (isSameImage) {
  31900. count = Math.min(count, MAX_SAME_IMAGES_IN_MASKS_BLOCK);
  31901. var positions = new Float32Array(count * 2);
  31902. iTransform = iFirstTransform;
  31903. for (q = 0; q < count; q++, iTransform += 4) {
  31904. transformArgs = argsArray[iTransform];
  31905. positions[q << 1] = transformArgs[4];
  31906. positions[(q << 1) + 1] = transformArgs[5];
  31907. }
  31908. fnArray.splice(iFirstSave, count * 4, OPS.paintImageMaskXObjectRepeat);
  31909. argsArray.splice(iFirstSave, count * 4, [
  31910. firstPIMXOArg0,
  31911. firstTransformArg0,
  31912. firstTransformArg3,
  31913. positions
  31914. ]);
  31915. } else {
  31916. count = Math.min(count, MAX_IMAGES_IN_MASKS_BLOCK);
  31917. var images = [];
  31918. for (q = 0; q < count; q++) {
  31919. transformArgs = argsArray[iFirstTransform + (q << 2)];
  31920. var maskParams = argsArray[iFirstPIMXO + (q << 2)][0];
  31921. images.push({
  31922. data: maskParams.data,
  31923. width: maskParams.width,
  31924. height: maskParams.height,
  31925. transform: transformArgs
  31926. });
  31927. }
  31928. fnArray.splice(iFirstSave, count * 4, OPS.paintImageMaskXObjectGroup);
  31929. argsArray.splice(iFirstSave, count * 4, [images]);
  31930. }
  31931. return iFirstSave + 1;
  31932. });
  31933. addState(InitialState, [
  31934. OPS.save,
  31935. OPS.transform,
  31936. OPS.paintImageXObject,
  31937. OPS.restore
  31938. ], function (context) {
  31939. var MIN_IMAGES_IN_BLOCK = 3;
  31940. var MAX_IMAGES_IN_BLOCK = 1000;
  31941. var fnArray = context.fnArray, argsArray = context.argsArray;
  31942. var curr = context.iCurr;
  31943. var iFirstSave = curr - 3;
  31944. var iFirstTransform = curr - 2;
  31945. var iFirstPIXO = curr - 1;
  31946. var iFirstRestore = curr;
  31947. if (argsArray[iFirstTransform][1] !== 0 || argsArray[iFirstTransform][2] !== 0) {
  31948. return iFirstRestore + 1;
  31949. }
  31950. var firstPIXOArg0 = argsArray[iFirstPIXO][0];
  31951. var firstTransformArg0 = argsArray[iFirstTransform][0];
  31952. var firstTransformArg3 = argsArray[iFirstTransform][3];
  31953. var i = iFirstSave + 4;
  31954. var ii = fnArray.length;
  31955. while (i + 3 < ii) {
  31956. if (fnArray[i] !== OPS.save || fnArray[i + 1] !== OPS.transform || fnArray[i + 2] !== OPS.paintImageXObject || fnArray[i + 3] !== OPS.restore) {
  31957. break;
  31958. }
  31959. if (argsArray[i + 1][0] !== firstTransformArg0 || argsArray[i + 1][1] !== 0 || argsArray[i + 1][2] !== 0 || argsArray[i + 1][3] !== firstTransformArg3) {
  31960. break;
  31961. }
  31962. if (argsArray[i + 2][0] !== firstPIXOArg0) {
  31963. break;
  31964. }
  31965. i += 4;
  31966. }
  31967. var count = Math.min((i - iFirstSave) / 4, MAX_IMAGES_IN_BLOCK);
  31968. if (count < MIN_IMAGES_IN_BLOCK) {
  31969. return i;
  31970. }
  31971. var positions = new Float32Array(count * 2);
  31972. var iTransform = iFirstTransform;
  31973. for (var q = 0; q < count; q++, iTransform += 4) {
  31974. var transformArgs = argsArray[iTransform];
  31975. positions[q << 1] = transformArgs[4];
  31976. positions[(q << 1) + 1] = transformArgs[5];
  31977. }
  31978. var args = [
  31979. firstPIXOArg0,
  31980. firstTransformArg0,
  31981. firstTransformArg3,
  31982. positions
  31983. ];
  31984. fnArray.splice(iFirstSave, count * 4, OPS.paintImageXObjectRepeat);
  31985. argsArray.splice(iFirstSave, count * 4, args);
  31986. return iFirstSave + 1;
  31987. });
  31988. addState(InitialState, [
  31989. OPS.beginText,
  31990. OPS.setFont,
  31991. OPS.setTextMatrix,
  31992. OPS.showText,
  31993. OPS.endText
  31994. ], function (context) {
  31995. var MIN_CHARS_IN_BLOCK = 3;
  31996. var MAX_CHARS_IN_BLOCK = 1000;
  31997. var fnArray = context.fnArray, argsArray = context.argsArray;
  31998. var curr = context.iCurr;
  31999. var iFirstBeginText = curr - 4;
  32000. var iFirstSetFont = curr - 3;
  32001. var iFirstSetTextMatrix = curr - 2;
  32002. var iFirstShowText = curr - 1;
  32003. var iFirstEndText = curr;
  32004. var firstSetFontArg0 = argsArray[iFirstSetFont][0];
  32005. var firstSetFontArg1 = argsArray[iFirstSetFont][1];
  32006. var i = iFirstBeginText + 5;
  32007. var ii = fnArray.length;
  32008. while (i + 4 < ii) {
  32009. 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) {
  32010. break;
  32011. }
  32012. if (argsArray[i + 1][0] !== firstSetFontArg0 || argsArray[i + 1][1] !== firstSetFontArg1) {
  32013. break;
  32014. }
  32015. i += 5;
  32016. }
  32017. var count = Math.min((i - iFirstBeginText) / 5, MAX_CHARS_IN_BLOCK);
  32018. if (count < MIN_CHARS_IN_BLOCK) {
  32019. return i;
  32020. }
  32021. var iFirst = iFirstBeginText;
  32022. 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) {
  32023. count++;
  32024. iFirst -= 5;
  32025. }
  32026. var iEndText = iFirst + 4;
  32027. for (var q = 1; q < count; q++) {
  32028. fnArray.splice(iEndText, 3);
  32029. argsArray.splice(iEndText, 3);
  32030. iEndText += 2;
  32031. }
  32032. return iEndText + 1;
  32033. });
  32034. function QueueOptimizer() {
  32035. }
  32036. QueueOptimizer.prototype = {
  32037. optimize: function QueueOptimizer_optimize(queue) {
  32038. var fnArray = queue.fnArray, argsArray = queue.argsArray;
  32039. var context = {
  32040. iCurr: 0,
  32041. fnArray: fnArray,
  32042. argsArray: argsArray
  32043. };
  32044. var state;
  32045. var i = 0, ii = fnArray.length;
  32046. while (i < ii) {
  32047. state = (state || InitialState)[fnArray[i]];
  32048. if (typeof state === 'function') {
  32049. context.iCurr = i;
  32050. i = state(context);
  32051. state = undefined;
  32052. ii = context.fnArray.length;
  32053. } else {
  32054. i++;
  32055. }
  32056. }
  32057. }
  32058. };
  32059. return QueueOptimizer;
  32060. }();
  32061. exports.OperatorList = OperatorList;
  32062. exports.PartialEvaluator = PartialEvaluator;
  32063. /***/ }),
  32064. /* 18 */
  32065. /***/ (function(module, exports, __w_pdfjs_require__) {
  32066. "use strict";
  32067. var sharedUtil = __w_pdfjs_require__(0);
  32068. var coreArithmeticDecoder = __w_pdfjs_require__(13);
  32069. var info = sharedUtil.info;
  32070. var warn = sharedUtil.warn;
  32071. var error = sharedUtil.error;
  32072. var log2 = sharedUtil.log2;
  32073. var readUint16 = sharedUtil.readUint16;
  32074. var readUint32 = sharedUtil.readUint32;
  32075. var ArithmeticDecoder = coreArithmeticDecoder.ArithmeticDecoder;
  32076. var JpxImage = function JpxImageClosure() {
  32077. var SubbandsGainLog2 = {
  32078. 'LL': 0,
  32079. 'LH': 1,
  32080. 'HL': 1,
  32081. 'HH': 2
  32082. };
  32083. function JpxImage() {
  32084. this.failOnCorruptedImage = false;
  32085. }
  32086. JpxImage.prototype = {
  32087. parse: function JpxImage_parse(data) {
  32088. var head = readUint16(data, 0);
  32089. if (head === 0xFF4F) {
  32090. this.parseCodestream(data, 0, data.length);
  32091. return;
  32092. }
  32093. var position = 0, length = data.length;
  32094. while (position < length) {
  32095. var headerSize = 8;
  32096. var lbox = readUint32(data, position);
  32097. var tbox = readUint32(data, position + 4);
  32098. position += headerSize;
  32099. if (lbox === 1) {
  32100. lbox = readUint32(data, position) * 4294967296 + readUint32(data, position + 4);
  32101. position += 8;
  32102. headerSize += 8;
  32103. }
  32104. if (lbox === 0) {
  32105. lbox = length - position + headerSize;
  32106. }
  32107. if (lbox < headerSize) {
  32108. error('JPX Error: Invalid box field size');
  32109. }
  32110. var dataLength = lbox - headerSize;
  32111. var jumpDataLength = true;
  32112. switch (tbox) {
  32113. case 0x6A703268:
  32114. jumpDataLength = false;
  32115. break;
  32116. case 0x636F6C72:
  32117. var method = data[position];
  32118. if (method === 1) {
  32119. var colorspace = readUint32(data, position + 3);
  32120. switch (colorspace) {
  32121. case 16:
  32122. case 17:
  32123. case 18:
  32124. break;
  32125. default:
  32126. warn('Unknown colorspace ' + colorspace);
  32127. break;
  32128. }
  32129. } else if (method === 2) {
  32130. info('ICC profile not supported');
  32131. }
  32132. break;
  32133. case 0x6A703263:
  32134. this.parseCodestream(data, position, position + dataLength);
  32135. break;
  32136. case 0x6A502020:
  32137. if (0x0d0a870a !== readUint32(data, position)) {
  32138. warn('Invalid JP2 signature');
  32139. }
  32140. break;
  32141. case 0x6A501A1A:
  32142. case 0x66747970:
  32143. case 0x72726571:
  32144. case 0x72657320:
  32145. case 0x69686472:
  32146. break;
  32147. default:
  32148. var headerType = String.fromCharCode(tbox >> 24 & 0xFF, tbox >> 16 & 0xFF, tbox >> 8 & 0xFF, tbox & 0xFF);
  32149. warn('Unsupported header type ' + tbox + ' (' + headerType + ')');
  32150. break;
  32151. }
  32152. if (jumpDataLength) {
  32153. position += dataLength;
  32154. }
  32155. }
  32156. },
  32157. parseImageProperties: function JpxImage_parseImageProperties(stream) {
  32158. var newByte = stream.getByte();
  32159. while (newByte >= 0) {
  32160. var oldByte = newByte;
  32161. newByte = stream.getByte();
  32162. var code = oldByte << 8 | newByte;
  32163. if (code === 0xFF51) {
  32164. stream.skip(4);
  32165. var Xsiz = stream.getInt32() >>> 0;
  32166. var Ysiz = stream.getInt32() >>> 0;
  32167. var XOsiz = stream.getInt32() >>> 0;
  32168. var YOsiz = stream.getInt32() >>> 0;
  32169. stream.skip(16);
  32170. var Csiz = stream.getUint16();
  32171. this.width = Xsiz - XOsiz;
  32172. this.height = Ysiz - YOsiz;
  32173. this.componentsCount = Csiz;
  32174. this.bitsPerComponent = 8;
  32175. return;
  32176. }
  32177. }
  32178. error('JPX Error: No size marker found in JPX stream');
  32179. },
  32180. parseCodestream: function JpxImage_parseCodestream(data, start, end) {
  32181. var context = {};
  32182. var doNotRecover = false;
  32183. try {
  32184. var position = start;
  32185. while (position + 1 < end) {
  32186. var code = readUint16(data, position);
  32187. position += 2;
  32188. var length = 0, j, sqcd, spqcds, spqcdSize, scalarExpounded, tile;
  32189. switch (code) {
  32190. case 0xFF4F:
  32191. context.mainHeader = true;
  32192. break;
  32193. case 0xFFD9:
  32194. break;
  32195. case 0xFF51:
  32196. length = readUint16(data, position);
  32197. var siz = {};
  32198. siz.Xsiz = readUint32(data, position + 4);
  32199. siz.Ysiz = readUint32(data, position + 8);
  32200. siz.XOsiz = readUint32(data, position + 12);
  32201. siz.YOsiz = readUint32(data, position + 16);
  32202. siz.XTsiz = readUint32(data, position + 20);
  32203. siz.YTsiz = readUint32(data, position + 24);
  32204. siz.XTOsiz = readUint32(data, position + 28);
  32205. siz.YTOsiz = readUint32(data, position + 32);
  32206. var componentsCount = readUint16(data, position + 36);
  32207. siz.Csiz = componentsCount;
  32208. var components = [];
  32209. j = position + 38;
  32210. for (var i = 0; i < componentsCount; i++) {
  32211. var component = {
  32212. precision: (data[j] & 0x7F) + 1,
  32213. isSigned: !!(data[j] & 0x80),
  32214. XRsiz: data[j + 1],
  32215. YRsiz: data[j + 1]
  32216. };
  32217. calculateComponentDimensions(component, siz);
  32218. components.push(component);
  32219. }
  32220. context.SIZ = siz;
  32221. context.components = components;
  32222. calculateTileGrids(context, components);
  32223. context.QCC = [];
  32224. context.COC = [];
  32225. break;
  32226. case 0xFF5C:
  32227. length = readUint16(data, position);
  32228. var qcd = {};
  32229. j = position + 2;
  32230. sqcd = data[j++];
  32231. switch (sqcd & 0x1F) {
  32232. case 0:
  32233. spqcdSize = 8;
  32234. scalarExpounded = true;
  32235. break;
  32236. case 1:
  32237. spqcdSize = 16;
  32238. scalarExpounded = false;
  32239. break;
  32240. case 2:
  32241. spqcdSize = 16;
  32242. scalarExpounded = true;
  32243. break;
  32244. default:
  32245. throw new Error('Invalid SQcd value ' + sqcd);
  32246. }
  32247. qcd.noQuantization = spqcdSize === 8;
  32248. qcd.scalarExpounded = scalarExpounded;
  32249. qcd.guardBits = sqcd >> 5;
  32250. spqcds = [];
  32251. while (j < length + position) {
  32252. var spqcd = {};
  32253. if (spqcdSize === 8) {
  32254. spqcd.epsilon = data[j++] >> 3;
  32255. spqcd.mu = 0;
  32256. } else {
  32257. spqcd.epsilon = data[j] >> 3;
  32258. spqcd.mu = (data[j] & 0x7) << 8 | data[j + 1];
  32259. j += 2;
  32260. }
  32261. spqcds.push(spqcd);
  32262. }
  32263. qcd.SPqcds = spqcds;
  32264. if (context.mainHeader) {
  32265. context.QCD = qcd;
  32266. } else {
  32267. context.currentTile.QCD = qcd;
  32268. context.currentTile.QCC = [];
  32269. }
  32270. break;
  32271. case 0xFF5D:
  32272. length = readUint16(data, position);
  32273. var qcc = {};
  32274. j = position + 2;
  32275. var cqcc;
  32276. if (context.SIZ.Csiz < 257) {
  32277. cqcc = data[j++];
  32278. } else {
  32279. cqcc = readUint16(data, j);
  32280. j += 2;
  32281. }
  32282. sqcd = data[j++];
  32283. switch (sqcd & 0x1F) {
  32284. case 0:
  32285. spqcdSize = 8;
  32286. scalarExpounded = true;
  32287. break;
  32288. case 1:
  32289. spqcdSize = 16;
  32290. scalarExpounded = false;
  32291. break;
  32292. case 2:
  32293. spqcdSize = 16;
  32294. scalarExpounded = true;
  32295. break;
  32296. default:
  32297. throw new Error('Invalid SQcd value ' + sqcd);
  32298. }
  32299. qcc.noQuantization = spqcdSize === 8;
  32300. qcc.scalarExpounded = scalarExpounded;
  32301. qcc.guardBits = sqcd >> 5;
  32302. spqcds = [];
  32303. while (j < length + position) {
  32304. spqcd = {};
  32305. if (spqcdSize === 8) {
  32306. spqcd.epsilon = data[j++] >> 3;
  32307. spqcd.mu = 0;
  32308. } else {
  32309. spqcd.epsilon = data[j] >> 3;
  32310. spqcd.mu = (data[j] & 0x7) << 8 | data[j + 1];
  32311. j += 2;
  32312. }
  32313. spqcds.push(spqcd);
  32314. }
  32315. qcc.SPqcds = spqcds;
  32316. if (context.mainHeader) {
  32317. context.QCC[cqcc] = qcc;
  32318. } else {
  32319. context.currentTile.QCC[cqcc] = qcc;
  32320. }
  32321. break;
  32322. case 0xFF52:
  32323. length = readUint16(data, position);
  32324. var cod = {};
  32325. j = position + 2;
  32326. var scod = data[j++];
  32327. cod.entropyCoderWithCustomPrecincts = !!(scod & 1);
  32328. cod.sopMarkerUsed = !!(scod & 2);
  32329. cod.ephMarkerUsed = !!(scod & 4);
  32330. cod.progressionOrder = data[j++];
  32331. cod.layersCount = readUint16(data, j);
  32332. j += 2;
  32333. cod.multipleComponentTransform = data[j++];
  32334. cod.decompositionLevelsCount = data[j++];
  32335. cod.xcb = (data[j++] & 0xF) + 2;
  32336. cod.ycb = (data[j++] & 0xF) + 2;
  32337. var blockStyle = data[j++];
  32338. cod.selectiveArithmeticCodingBypass = !!(blockStyle & 1);
  32339. cod.resetContextProbabilities = !!(blockStyle & 2);
  32340. cod.terminationOnEachCodingPass = !!(blockStyle & 4);
  32341. cod.verticalyStripe = !!(blockStyle & 8);
  32342. cod.predictableTermination = !!(blockStyle & 16);
  32343. cod.segmentationSymbolUsed = !!(blockStyle & 32);
  32344. cod.reversibleTransformation = data[j++];
  32345. if (cod.entropyCoderWithCustomPrecincts) {
  32346. var precinctsSizes = [];
  32347. while (j < length + position) {
  32348. var precinctsSize = data[j++];
  32349. precinctsSizes.push({
  32350. PPx: precinctsSize & 0xF,
  32351. PPy: precinctsSize >> 4
  32352. });
  32353. }
  32354. cod.precinctsSizes = precinctsSizes;
  32355. }
  32356. var unsupported = [];
  32357. if (cod.selectiveArithmeticCodingBypass) {
  32358. unsupported.push('selectiveArithmeticCodingBypass');
  32359. }
  32360. if (cod.resetContextProbabilities) {
  32361. unsupported.push('resetContextProbabilities');
  32362. }
  32363. if (cod.terminationOnEachCodingPass) {
  32364. unsupported.push('terminationOnEachCodingPass');
  32365. }
  32366. if (cod.verticalyStripe) {
  32367. unsupported.push('verticalyStripe');
  32368. }
  32369. if (cod.predictableTermination) {
  32370. unsupported.push('predictableTermination');
  32371. }
  32372. if (unsupported.length > 0) {
  32373. doNotRecover = true;
  32374. throw new Error('Unsupported COD options (' + unsupported.join(', ') + ')');
  32375. }
  32376. if (context.mainHeader) {
  32377. context.COD = cod;
  32378. } else {
  32379. context.currentTile.COD = cod;
  32380. context.currentTile.COC = [];
  32381. }
  32382. break;
  32383. case 0xFF90:
  32384. length = readUint16(data, position);
  32385. tile = {};
  32386. tile.index = readUint16(data, position + 2);
  32387. tile.length = readUint32(data, position + 4);
  32388. tile.dataEnd = tile.length + position - 2;
  32389. tile.partIndex = data[position + 8];
  32390. tile.partsCount = data[position + 9];
  32391. context.mainHeader = false;
  32392. if (tile.partIndex === 0) {
  32393. tile.COD = context.COD;
  32394. tile.COC = context.COC.slice(0);
  32395. tile.QCD = context.QCD;
  32396. tile.QCC = context.QCC.slice(0);
  32397. }
  32398. context.currentTile = tile;
  32399. break;
  32400. case 0xFF93:
  32401. tile = context.currentTile;
  32402. if (tile.partIndex === 0) {
  32403. initializeTile(context, tile.index);
  32404. buildPackets(context);
  32405. }
  32406. length = tile.dataEnd - position;
  32407. parseTilePackets(context, data, position, length);
  32408. break;
  32409. case 0xFF55:
  32410. case 0xFF57:
  32411. case 0xFF58:
  32412. case 0xFF64:
  32413. length = readUint16(data, position);
  32414. break;
  32415. case 0xFF53:
  32416. throw new Error('Codestream code 0xFF53 (COC) is ' + 'not implemented');
  32417. default:
  32418. throw new Error('Unknown codestream code: ' + code.toString(16));
  32419. }
  32420. position += length;
  32421. }
  32422. } catch (e) {
  32423. if (doNotRecover || this.failOnCorruptedImage) {
  32424. error('JPX Error: ' + e.message);
  32425. } else {
  32426. warn('JPX: Trying to recover from: ' + e.message);
  32427. }
  32428. }
  32429. this.tiles = transformComponents(context);
  32430. this.width = context.SIZ.Xsiz - context.SIZ.XOsiz;
  32431. this.height = context.SIZ.Ysiz - context.SIZ.YOsiz;
  32432. this.componentsCount = context.SIZ.Csiz;
  32433. }
  32434. };
  32435. function calculateComponentDimensions(component, siz) {
  32436. component.x0 = Math.ceil(siz.XOsiz / component.XRsiz);
  32437. component.x1 = Math.ceil(siz.Xsiz / component.XRsiz);
  32438. component.y0 = Math.ceil(siz.YOsiz / component.YRsiz);
  32439. component.y1 = Math.ceil(siz.Ysiz / component.YRsiz);
  32440. component.width = component.x1 - component.x0;
  32441. component.height = component.y1 - component.y0;
  32442. }
  32443. function calculateTileGrids(context, components) {
  32444. var siz = context.SIZ;
  32445. var tile, tiles = [];
  32446. var numXtiles = Math.ceil((siz.Xsiz - siz.XTOsiz) / siz.XTsiz);
  32447. var numYtiles = Math.ceil((siz.Ysiz - siz.YTOsiz) / siz.YTsiz);
  32448. for (var q = 0; q < numYtiles; q++) {
  32449. for (var p = 0; p < numXtiles; p++) {
  32450. tile = {};
  32451. tile.tx0 = Math.max(siz.XTOsiz + p * siz.XTsiz, siz.XOsiz);
  32452. tile.ty0 = Math.max(siz.YTOsiz + q * siz.YTsiz, siz.YOsiz);
  32453. tile.tx1 = Math.min(siz.XTOsiz + (p + 1) * siz.XTsiz, siz.Xsiz);
  32454. tile.ty1 = Math.min(siz.YTOsiz + (q + 1) * siz.YTsiz, siz.Ysiz);
  32455. tile.width = tile.tx1 - tile.tx0;
  32456. tile.height = tile.ty1 - tile.ty0;
  32457. tile.components = [];
  32458. tiles.push(tile);
  32459. }
  32460. }
  32461. context.tiles = tiles;
  32462. var componentsCount = siz.Csiz;
  32463. for (var i = 0, ii = componentsCount; i < ii; i++) {
  32464. var component = components[i];
  32465. for (var j = 0, jj = tiles.length; j < jj; j++) {
  32466. var tileComponent = {};
  32467. tile = tiles[j];
  32468. tileComponent.tcx0 = Math.ceil(tile.tx0 / component.XRsiz);
  32469. tileComponent.tcy0 = Math.ceil(tile.ty0 / component.YRsiz);
  32470. tileComponent.tcx1 = Math.ceil(tile.tx1 / component.XRsiz);
  32471. tileComponent.tcy1 = Math.ceil(tile.ty1 / component.YRsiz);
  32472. tileComponent.width = tileComponent.tcx1 - tileComponent.tcx0;
  32473. tileComponent.height = tileComponent.tcy1 - tileComponent.tcy0;
  32474. tile.components[i] = tileComponent;
  32475. }
  32476. }
  32477. }
  32478. function getBlocksDimensions(context, component, r) {
  32479. var codOrCoc = component.codingStyleParameters;
  32480. var result = {};
  32481. if (!codOrCoc.entropyCoderWithCustomPrecincts) {
  32482. result.PPx = 15;
  32483. result.PPy = 15;
  32484. } else {
  32485. result.PPx = codOrCoc.precinctsSizes[r].PPx;
  32486. result.PPy = codOrCoc.precinctsSizes[r].PPy;
  32487. }
  32488. result.xcb_ = r > 0 ? Math.min(codOrCoc.xcb, result.PPx - 1) : Math.min(codOrCoc.xcb, result.PPx);
  32489. result.ycb_ = r > 0 ? Math.min(codOrCoc.ycb, result.PPy - 1) : Math.min(codOrCoc.ycb, result.PPy);
  32490. return result;
  32491. }
  32492. function buildPrecincts(context, resolution, dimensions) {
  32493. var precinctWidth = 1 << dimensions.PPx;
  32494. var precinctHeight = 1 << dimensions.PPy;
  32495. var isZeroRes = resolution.resLevel === 0;
  32496. var precinctWidthInSubband = 1 << dimensions.PPx + (isZeroRes ? 0 : -1);
  32497. var precinctHeightInSubband = 1 << dimensions.PPy + (isZeroRes ? 0 : -1);
  32498. var numprecinctswide = resolution.trx1 > resolution.trx0 ? Math.ceil(resolution.trx1 / precinctWidth) - Math.floor(resolution.trx0 / precinctWidth) : 0;
  32499. var numprecinctshigh = resolution.try1 > resolution.try0 ? Math.ceil(resolution.try1 / precinctHeight) - Math.floor(resolution.try0 / precinctHeight) : 0;
  32500. var numprecincts = numprecinctswide * numprecinctshigh;
  32501. resolution.precinctParameters = {
  32502. precinctWidth: precinctWidth,
  32503. precinctHeight: precinctHeight,
  32504. numprecinctswide: numprecinctswide,
  32505. numprecinctshigh: numprecinctshigh,
  32506. numprecincts: numprecincts,
  32507. precinctWidthInSubband: precinctWidthInSubband,
  32508. precinctHeightInSubband: precinctHeightInSubband
  32509. };
  32510. }
  32511. function buildCodeblocks(context, subband, dimensions) {
  32512. var xcb_ = dimensions.xcb_;
  32513. var ycb_ = dimensions.ycb_;
  32514. var codeblockWidth = 1 << xcb_;
  32515. var codeblockHeight = 1 << ycb_;
  32516. var cbx0 = subband.tbx0 >> xcb_;
  32517. var cby0 = subband.tby0 >> ycb_;
  32518. var cbx1 = subband.tbx1 + codeblockWidth - 1 >> xcb_;
  32519. var cby1 = subband.tby1 + codeblockHeight - 1 >> ycb_;
  32520. var precinctParameters = subband.resolution.precinctParameters;
  32521. var codeblocks = [];
  32522. var precincts = [];
  32523. var i, j, codeblock, precinctNumber;
  32524. for (j = cby0; j < cby1; j++) {
  32525. for (i = cbx0; i < cbx1; i++) {
  32526. codeblock = {
  32527. cbx: i,
  32528. cby: j,
  32529. tbx0: codeblockWidth * i,
  32530. tby0: codeblockHeight * j,
  32531. tbx1: codeblockWidth * (i + 1),
  32532. tby1: codeblockHeight * (j + 1)
  32533. };
  32534. codeblock.tbx0_ = Math.max(subband.tbx0, codeblock.tbx0);
  32535. codeblock.tby0_ = Math.max(subband.tby0, codeblock.tby0);
  32536. codeblock.tbx1_ = Math.min(subband.tbx1, codeblock.tbx1);
  32537. codeblock.tby1_ = Math.min(subband.tby1, codeblock.tby1);
  32538. var pi = Math.floor((codeblock.tbx0_ - subband.tbx0) / precinctParameters.precinctWidthInSubband);
  32539. var pj = Math.floor((codeblock.tby0_ - subband.tby0) / precinctParameters.precinctHeightInSubband);
  32540. precinctNumber = pi + pj * precinctParameters.numprecinctswide;
  32541. codeblock.precinctNumber = precinctNumber;
  32542. codeblock.subbandType = subband.type;
  32543. codeblock.Lblock = 3;
  32544. if (codeblock.tbx1_ <= codeblock.tbx0_ || codeblock.tby1_ <= codeblock.tby0_) {
  32545. continue;
  32546. }
  32547. codeblocks.push(codeblock);
  32548. var precinct = precincts[precinctNumber];
  32549. if (precinct !== undefined) {
  32550. if (i < precinct.cbxMin) {
  32551. precinct.cbxMin = i;
  32552. } else if (i > precinct.cbxMax) {
  32553. precinct.cbxMax = i;
  32554. }
  32555. if (j < precinct.cbyMin) {
  32556. precinct.cbxMin = j;
  32557. } else if (j > precinct.cbyMax) {
  32558. precinct.cbyMax = j;
  32559. }
  32560. } else {
  32561. precincts[precinctNumber] = precinct = {
  32562. cbxMin: i,
  32563. cbyMin: j,
  32564. cbxMax: i,
  32565. cbyMax: j
  32566. };
  32567. }
  32568. codeblock.precinct = precinct;
  32569. }
  32570. }
  32571. subband.codeblockParameters = {
  32572. codeblockWidth: xcb_,
  32573. codeblockHeight: ycb_,
  32574. numcodeblockwide: cbx1 - cbx0 + 1,
  32575. numcodeblockhigh: cby1 - cby0 + 1
  32576. };
  32577. subband.codeblocks = codeblocks;
  32578. subband.precincts = precincts;
  32579. }
  32580. function createPacket(resolution, precinctNumber, layerNumber) {
  32581. var precinctCodeblocks = [];
  32582. var subbands = resolution.subbands;
  32583. for (var i = 0, ii = subbands.length; i < ii; i++) {
  32584. var subband = subbands[i];
  32585. var codeblocks = subband.codeblocks;
  32586. for (var j = 0, jj = codeblocks.length; j < jj; j++) {
  32587. var codeblock = codeblocks[j];
  32588. if (codeblock.precinctNumber !== precinctNumber) {
  32589. continue;
  32590. }
  32591. precinctCodeblocks.push(codeblock);
  32592. }
  32593. }
  32594. return {
  32595. layerNumber: layerNumber,
  32596. codeblocks: precinctCodeblocks
  32597. };
  32598. }
  32599. function LayerResolutionComponentPositionIterator(context) {
  32600. var siz = context.SIZ;
  32601. var tileIndex = context.currentTile.index;
  32602. var tile = context.tiles[tileIndex];
  32603. var layersCount = tile.codingStyleDefaultParameters.layersCount;
  32604. var componentsCount = siz.Csiz;
  32605. var maxDecompositionLevelsCount = 0;
  32606. for (var q = 0; q < componentsCount; q++) {
  32607. maxDecompositionLevelsCount = Math.max(maxDecompositionLevelsCount, tile.components[q].codingStyleParameters.decompositionLevelsCount);
  32608. }
  32609. var l = 0, r = 0, i = 0, k = 0;
  32610. this.nextPacket = function JpxImage_nextPacket() {
  32611. for (; l < layersCount; l++) {
  32612. for (; r <= maxDecompositionLevelsCount; r++) {
  32613. for (; i < componentsCount; i++) {
  32614. var component = tile.components[i];
  32615. if (r > component.codingStyleParameters.decompositionLevelsCount) {
  32616. continue;
  32617. }
  32618. var resolution = component.resolutions[r];
  32619. var numprecincts = resolution.precinctParameters.numprecincts;
  32620. for (; k < numprecincts;) {
  32621. var packet = createPacket(resolution, k, l);
  32622. k++;
  32623. return packet;
  32624. }
  32625. k = 0;
  32626. }
  32627. i = 0;
  32628. }
  32629. r = 0;
  32630. }
  32631. error('JPX Error: Out of packets');
  32632. };
  32633. }
  32634. function ResolutionLayerComponentPositionIterator(context) {
  32635. var siz = context.SIZ;
  32636. var tileIndex = context.currentTile.index;
  32637. var tile = context.tiles[tileIndex];
  32638. var layersCount = tile.codingStyleDefaultParameters.layersCount;
  32639. var componentsCount = siz.Csiz;
  32640. var maxDecompositionLevelsCount = 0;
  32641. for (var q = 0; q < componentsCount; q++) {
  32642. maxDecompositionLevelsCount = Math.max(maxDecompositionLevelsCount, tile.components[q].codingStyleParameters.decompositionLevelsCount);
  32643. }
  32644. var r = 0, l = 0, i = 0, k = 0;
  32645. this.nextPacket = function JpxImage_nextPacket() {
  32646. for (; r <= maxDecompositionLevelsCount; r++) {
  32647. for (; l < layersCount; l++) {
  32648. for (; i < componentsCount; i++) {
  32649. var component = tile.components[i];
  32650. if (r > component.codingStyleParameters.decompositionLevelsCount) {
  32651. continue;
  32652. }
  32653. var resolution = component.resolutions[r];
  32654. var numprecincts = resolution.precinctParameters.numprecincts;
  32655. for (; k < numprecincts;) {
  32656. var packet = createPacket(resolution, k, l);
  32657. k++;
  32658. return packet;
  32659. }
  32660. k = 0;
  32661. }
  32662. i = 0;
  32663. }
  32664. l = 0;
  32665. }
  32666. error('JPX Error: Out of packets');
  32667. };
  32668. }
  32669. function ResolutionPositionComponentLayerIterator(context) {
  32670. var siz = context.SIZ;
  32671. var tileIndex = context.currentTile.index;
  32672. var tile = context.tiles[tileIndex];
  32673. var layersCount = tile.codingStyleDefaultParameters.layersCount;
  32674. var componentsCount = siz.Csiz;
  32675. var l, r, c, p;
  32676. var maxDecompositionLevelsCount = 0;
  32677. for (c = 0; c < componentsCount; c++) {
  32678. var component = tile.components[c];
  32679. maxDecompositionLevelsCount = Math.max(maxDecompositionLevelsCount, component.codingStyleParameters.decompositionLevelsCount);
  32680. }
  32681. var maxNumPrecinctsInLevel = new Int32Array(maxDecompositionLevelsCount + 1);
  32682. for (r = 0; r <= maxDecompositionLevelsCount; ++r) {
  32683. var maxNumPrecincts = 0;
  32684. for (c = 0; c < componentsCount; ++c) {
  32685. var resolutions = tile.components[c].resolutions;
  32686. if (r < resolutions.length) {
  32687. maxNumPrecincts = Math.max(maxNumPrecincts, resolutions[r].precinctParameters.numprecincts);
  32688. }
  32689. }
  32690. maxNumPrecinctsInLevel[r] = maxNumPrecincts;
  32691. }
  32692. l = 0;
  32693. r = 0;
  32694. c = 0;
  32695. p = 0;
  32696. this.nextPacket = function JpxImage_nextPacket() {
  32697. for (; r <= maxDecompositionLevelsCount; r++) {
  32698. for (; p < maxNumPrecinctsInLevel[r]; p++) {
  32699. for (; c < componentsCount; c++) {
  32700. var component = tile.components[c];
  32701. if (r > component.codingStyleParameters.decompositionLevelsCount) {
  32702. continue;
  32703. }
  32704. var resolution = component.resolutions[r];
  32705. var numprecincts = resolution.precinctParameters.numprecincts;
  32706. if (p >= numprecincts) {
  32707. continue;
  32708. }
  32709. for (; l < layersCount;) {
  32710. var packet = createPacket(resolution, p, l);
  32711. l++;
  32712. return packet;
  32713. }
  32714. l = 0;
  32715. }
  32716. c = 0;
  32717. }
  32718. p = 0;
  32719. }
  32720. error('JPX Error: Out of packets');
  32721. };
  32722. }
  32723. function PositionComponentResolutionLayerIterator(context) {
  32724. var siz = context.SIZ;
  32725. var tileIndex = context.currentTile.index;
  32726. var tile = context.tiles[tileIndex];
  32727. var layersCount = tile.codingStyleDefaultParameters.layersCount;
  32728. var componentsCount = siz.Csiz;
  32729. var precinctsSizes = getPrecinctSizesInImageScale(tile);
  32730. var precinctsIterationSizes = precinctsSizes;
  32731. var l = 0, r = 0, c = 0, px = 0, py = 0;
  32732. this.nextPacket = function JpxImage_nextPacket() {
  32733. for (; py < precinctsIterationSizes.maxNumHigh; py++) {
  32734. for (; px < precinctsIterationSizes.maxNumWide; px++) {
  32735. for (; c < componentsCount; c++) {
  32736. var component = tile.components[c];
  32737. var decompositionLevelsCount = component.codingStyleParameters.decompositionLevelsCount;
  32738. for (; r <= decompositionLevelsCount; r++) {
  32739. var resolution = component.resolutions[r];
  32740. var sizeInImageScale = precinctsSizes.components[c].resolutions[r];
  32741. var k = getPrecinctIndexIfExist(px, py, sizeInImageScale, precinctsIterationSizes, resolution);
  32742. if (k === null) {
  32743. continue;
  32744. }
  32745. for (; l < layersCount;) {
  32746. var packet = createPacket(resolution, k, l);
  32747. l++;
  32748. return packet;
  32749. }
  32750. l = 0;
  32751. }
  32752. r = 0;
  32753. }
  32754. c = 0;
  32755. }
  32756. px = 0;
  32757. }
  32758. error('JPX Error: Out of packets');
  32759. };
  32760. }
  32761. function ComponentPositionResolutionLayerIterator(context) {
  32762. var siz = context.SIZ;
  32763. var tileIndex = context.currentTile.index;
  32764. var tile = context.tiles[tileIndex];
  32765. var layersCount = tile.codingStyleDefaultParameters.layersCount;
  32766. var componentsCount = siz.Csiz;
  32767. var precinctsSizes = getPrecinctSizesInImageScale(tile);
  32768. var l = 0, r = 0, c = 0, px = 0, py = 0;
  32769. this.nextPacket = function JpxImage_nextPacket() {
  32770. for (; c < componentsCount; ++c) {
  32771. var component = tile.components[c];
  32772. var precinctsIterationSizes = precinctsSizes.components[c];
  32773. var decompositionLevelsCount = component.codingStyleParameters.decompositionLevelsCount;
  32774. for (; py < precinctsIterationSizes.maxNumHigh; py++) {
  32775. for (; px < precinctsIterationSizes.maxNumWide; px++) {
  32776. for (; r <= decompositionLevelsCount; r++) {
  32777. var resolution = component.resolutions[r];
  32778. var sizeInImageScale = precinctsIterationSizes.resolutions[r];
  32779. var k = getPrecinctIndexIfExist(px, py, sizeInImageScale, precinctsIterationSizes, resolution);
  32780. if (k === null) {
  32781. continue;
  32782. }
  32783. for (; l < layersCount;) {
  32784. var packet = createPacket(resolution, k, l);
  32785. l++;
  32786. return packet;
  32787. }
  32788. l = 0;
  32789. }
  32790. r = 0;
  32791. }
  32792. px = 0;
  32793. }
  32794. py = 0;
  32795. }
  32796. error('JPX Error: Out of packets');
  32797. };
  32798. }
  32799. function getPrecinctIndexIfExist(pxIndex, pyIndex, sizeInImageScale, precinctIterationSizes, resolution) {
  32800. var posX = pxIndex * precinctIterationSizes.minWidth;
  32801. var posY = pyIndex * precinctIterationSizes.minHeight;
  32802. if (posX % sizeInImageScale.width !== 0 || posY % sizeInImageScale.height !== 0) {
  32803. return null;
  32804. }
  32805. var startPrecinctRowIndex = posY / sizeInImageScale.width * resolution.precinctParameters.numprecinctswide;
  32806. return posX / sizeInImageScale.height + startPrecinctRowIndex;
  32807. }
  32808. function getPrecinctSizesInImageScale(tile) {
  32809. var componentsCount = tile.components.length;
  32810. var minWidth = Number.MAX_VALUE;
  32811. var minHeight = Number.MAX_VALUE;
  32812. var maxNumWide = 0;
  32813. var maxNumHigh = 0;
  32814. var sizePerComponent = new Array(componentsCount);
  32815. for (var c = 0; c < componentsCount; c++) {
  32816. var component = tile.components[c];
  32817. var decompositionLevelsCount = component.codingStyleParameters.decompositionLevelsCount;
  32818. var sizePerResolution = new Array(decompositionLevelsCount + 1);
  32819. var minWidthCurrentComponent = Number.MAX_VALUE;
  32820. var minHeightCurrentComponent = Number.MAX_VALUE;
  32821. var maxNumWideCurrentComponent = 0;
  32822. var maxNumHighCurrentComponent = 0;
  32823. var scale = 1;
  32824. for (var r = decompositionLevelsCount; r >= 0; --r) {
  32825. var resolution = component.resolutions[r];
  32826. var widthCurrentResolution = scale * resolution.precinctParameters.precinctWidth;
  32827. var heightCurrentResolution = scale * resolution.precinctParameters.precinctHeight;
  32828. minWidthCurrentComponent = Math.min(minWidthCurrentComponent, widthCurrentResolution);
  32829. minHeightCurrentComponent = Math.min(minHeightCurrentComponent, heightCurrentResolution);
  32830. maxNumWideCurrentComponent = Math.max(maxNumWideCurrentComponent, resolution.precinctParameters.numprecinctswide);
  32831. maxNumHighCurrentComponent = Math.max(maxNumHighCurrentComponent, resolution.precinctParameters.numprecinctshigh);
  32832. sizePerResolution[r] = {
  32833. width: widthCurrentResolution,
  32834. height: heightCurrentResolution
  32835. };
  32836. scale <<= 1;
  32837. }
  32838. minWidth = Math.min(minWidth, minWidthCurrentComponent);
  32839. minHeight = Math.min(minHeight, minHeightCurrentComponent);
  32840. maxNumWide = Math.max(maxNumWide, maxNumWideCurrentComponent);
  32841. maxNumHigh = Math.max(maxNumHigh, maxNumHighCurrentComponent);
  32842. sizePerComponent[c] = {
  32843. resolutions: sizePerResolution,
  32844. minWidth: minWidthCurrentComponent,
  32845. minHeight: minHeightCurrentComponent,
  32846. maxNumWide: maxNumWideCurrentComponent,
  32847. maxNumHigh: maxNumHighCurrentComponent
  32848. };
  32849. }
  32850. return {
  32851. components: sizePerComponent,
  32852. minWidth: minWidth,
  32853. minHeight: minHeight,
  32854. maxNumWide: maxNumWide,
  32855. maxNumHigh: maxNumHigh
  32856. };
  32857. }
  32858. function buildPackets(context) {
  32859. var siz = context.SIZ;
  32860. var tileIndex = context.currentTile.index;
  32861. var tile = context.tiles[tileIndex];
  32862. var componentsCount = siz.Csiz;
  32863. for (var c = 0; c < componentsCount; c++) {
  32864. var component = tile.components[c];
  32865. var decompositionLevelsCount = component.codingStyleParameters.decompositionLevelsCount;
  32866. var resolutions = [];
  32867. var subbands = [];
  32868. for (var r = 0; r <= decompositionLevelsCount; r++) {
  32869. var blocksDimensions = getBlocksDimensions(context, component, r);
  32870. var resolution = {};
  32871. var scale = 1 << decompositionLevelsCount - r;
  32872. resolution.trx0 = Math.ceil(component.tcx0 / scale);
  32873. resolution.try0 = Math.ceil(component.tcy0 / scale);
  32874. resolution.trx1 = Math.ceil(component.tcx1 / scale);
  32875. resolution.try1 = Math.ceil(component.tcy1 / scale);
  32876. resolution.resLevel = r;
  32877. buildPrecincts(context, resolution, blocksDimensions);
  32878. resolutions.push(resolution);
  32879. var subband;
  32880. if (r === 0) {
  32881. subband = {};
  32882. subband.type = 'LL';
  32883. subband.tbx0 = Math.ceil(component.tcx0 / scale);
  32884. subband.tby0 = Math.ceil(component.tcy0 / scale);
  32885. subband.tbx1 = Math.ceil(component.tcx1 / scale);
  32886. subband.tby1 = Math.ceil(component.tcy1 / scale);
  32887. subband.resolution = resolution;
  32888. buildCodeblocks(context, subband, blocksDimensions);
  32889. subbands.push(subband);
  32890. resolution.subbands = [subband];
  32891. } else {
  32892. var bscale = 1 << decompositionLevelsCount - r + 1;
  32893. var resolutionSubbands = [];
  32894. subband = {};
  32895. subband.type = 'HL';
  32896. subband.tbx0 = Math.ceil(component.tcx0 / bscale - 0.5);
  32897. subband.tby0 = Math.ceil(component.tcy0 / bscale);
  32898. subband.tbx1 = Math.ceil(component.tcx1 / bscale - 0.5);
  32899. subband.tby1 = Math.ceil(component.tcy1 / bscale);
  32900. subband.resolution = resolution;
  32901. buildCodeblocks(context, subband, blocksDimensions);
  32902. subbands.push(subband);
  32903. resolutionSubbands.push(subband);
  32904. subband = {};
  32905. subband.type = 'LH';
  32906. subband.tbx0 = Math.ceil(component.tcx0 / bscale);
  32907. subband.tby0 = Math.ceil(component.tcy0 / bscale - 0.5);
  32908. subband.tbx1 = Math.ceil(component.tcx1 / bscale);
  32909. subband.tby1 = Math.ceil(component.tcy1 / bscale - 0.5);
  32910. subband.resolution = resolution;
  32911. buildCodeblocks(context, subband, blocksDimensions);
  32912. subbands.push(subband);
  32913. resolutionSubbands.push(subband);
  32914. subband = {};
  32915. subband.type = 'HH';
  32916. subband.tbx0 = Math.ceil(component.tcx0 / bscale - 0.5);
  32917. subband.tby0 = Math.ceil(component.tcy0 / bscale - 0.5);
  32918. subband.tbx1 = Math.ceil(component.tcx1 / bscale - 0.5);
  32919. subband.tby1 = Math.ceil(component.tcy1 / bscale - 0.5);
  32920. subband.resolution = resolution;
  32921. buildCodeblocks(context, subband, blocksDimensions);
  32922. subbands.push(subband);
  32923. resolutionSubbands.push(subband);
  32924. resolution.subbands = resolutionSubbands;
  32925. }
  32926. }
  32927. component.resolutions = resolutions;
  32928. component.subbands = subbands;
  32929. }
  32930. var progressionOrder = tile.codingStyleDefaultParameters.progressionOrder;
  32931. switch (progressionOrder) {
  32932. case 0:
  32933. tile.packetsIterator = new LayerResolutionComponentPositionIterator(context);
  32934. break;
  32935. case 1:
  32936. tile.packetsIterator = new ResolutionLayerComponentPositionIterator(context);
  32937. break;
  32938. case 2:
  32939. tile.packetsIterator = new ResolutionPositionComponentLayerIterator(context);
  32940. break;
  32941. case 3:
  32942. tile.packetsIterator = new PositionComponentResolutionLayerIterator(context);
  32943. break;
  32944. case 4:
  32945. tile.packetsIterator = new ComponentPositionResolutionLayerIterator(context);
  32946. break;
  32947. default:
  32948. error('JPX Error: Unsupported progression order ' + progressionOrder);
  32949. }
  32950. }
  32951. function parseTilePackets(context, data, offset, dataLength) {
  32952. var position = 0;
  32953. var buffer, bufferSize = 0, skipNextBit = false;
  32954. function readBits(count) {
  32955. while (bufferSize < count) {
  32956. var b = data[offset + position];
  32957. position++;
  32958. if (skipNextBit) {
  32959. buffer = buffer << 7 | b;
  32960. bufferSize += 7;
  32961. skipNextBit = false;
  32962. } else {
  32963. buffer = buffer << 8 | b;
  32964. bufferSize += 8;
  32965. }
  32966. if (b === 0xFF) {
  32967. skipNextBit = true;
  32968. }
  32969. }
  32970. bufferSize -= count;
  32971. return buffer >>> bufferSize & (1 << count) - 1;
  32972. }
  32973. function skipMarkerIfEqual(value) {
  32974. if (data[offset + position - 1] === 0xFF && data[offset + position] === value) {
  32975. skipBytes(1);
  32976. return true;
  32977. } else if (data[offset + position] === 0xFF && data[offset + position + 1] === value) {
  32978. skipBytes(2);
  32979. return true;
  32980. }
  32981. return false;
  32982. }
  32983. function skipBytes(count) {
  32984. position += count;
  32985. }
  32986. function alignToByte() {
  32987. bufferSize = 0;
  32988. if (skipNextBit) {
  32989. position++;
  32990. skipNextBit = false;
  32991. }
  32992. }
  32993. function readCodingpasses() {
  32994. if (readBits(1) === 0) {
  32995. return 1;
  32996. }
  32997. if (readBits(1) === 0) {
  32998. return 2;
  32999. }
  33000. var value = readBits(2);
  33001. if (value < 3) {
  33002. return value + 3;
  33003. }
  33004. value = readBits(5);
  33005. if (value < 31) {
  33006. return value + 6;
  33007. }
  33008. value = readBits(7);
  33009. return value + 37;
  33010. }
  33011. var tileIndex = context.currentTile.index;
  33012. var tile = context.tiles[tileIndex];
  33013. var sopMarkerUsed = context.COD.sopMarkerUsed;
  33014. var ephMarkerUsed = context.COD.ephMarkerUsed;
  33015. var packetsIterator = tile.packetsIterator;
  33016. while (position < dataLength) {
  33017. alignToByte();
  33018. if (sopMarkerUsed && skipMarkerIfEqual(0x91)) {
  33019. skipBytes(4);
  33020. }
  33021. var packet = packetsIterator.nextPacket();
  33022. if (!readBits(1)) {
  33023. continue;
  33024. }
  33025. var layerNumber = packet.layerNumber;
  33026. var queue = [], codeblock;
  33027. for (var i = 0, ii = packet.codeblocks.length; i < ii; i++) {
  33028. codeblock = packet.codeblocks[i];
  33029. var precinct = codeblock.precinct;
  33030. var codeblockColumn = codeblock.cbx - precinct.cbxMin;
  33031. var codeblockRow = codeblock.cby - precinct.cbyMin;
  33032. var codeblockIncluded = false;
  33033. var firstTimeInclusion = false;
  33034. var valueReady;
  33035. if (codeblock['included'] !== undefined) {
  33036. codeblockIncluded = !!readBits(1);
  33037. } else {
  33038. precinct = codeblock.precinct;
  33039. var inclusionTree, zeroBitPlanesTree;
  33040. if (precinct['inclusionTree'] !== undefined) {
  33041. inclusionTree = precinct.inclusionTree;
  33042. } else {
  33043. var width = precinct.cbxMax - precinct.cbxMin + 1;
  33044. var height = precinct.cbyMax - precinct.cbyMin + 1;
  33045. inclusionTree = new InclusionTree(width, height, layerNumber);
  33046. zeroBitPlanesTree = new TagTree(width, height);
  33047. precinct.inclusionTree = inclusionTree;
  33048. precinct.zeroBitPlanesTree = zeroBitPlanesTree;
  33049. }
  33050. if (inclusionTree.reset(codeblockColumn, codeblockRow, layerNumber)) {
  33051. while (true) {
  33052. if (readBits(1)) {
  33053. valueReady = !inclusionTree.nextLevel();
  33054. if (valueReady) {
  33055. codeblock.included = true;
  33056. codeblockIncluded = firstTimeInclusion = true;
  33057. break;
  33058. }
  33059. } else {
  33060. inclusionTree.incrementValue(layerNumber);
  33061. break;
  33062. }
  33063. }
  33064. }
  33065. }
  33066. if (!codeblockIncluded) {
  33067. continue;
  33068. }
  33069. if (firstTimeInclusion) {
  33070. zeroBitPlanesTree = precinct.zeroBitPlanesTree;
  33071. zeroBitPlanesTree.reset(codeblockColumn, codeblockRow);
  33072. while (true) {
  33073. if (readBits(1)) {
  33074. valueReady = !zeroBitPlanesTree.nextLevel();
  33075. if (valueReady) {
  33076. break;
  33077. }
  33078. } else {
  33079. zeroBitPlanesTree.incrementValue();
  33080. }
  33081. }
  33082. codeblock.zeroBitPlanes = zeroBitPlanesTree.value;
  33083. }
  33084. var codingpasses = readCodingpasses();
  33085. while (readBits(1)) {
  33086. codeblock.Lblock++;
  33087. }
  33088. var codingpassesLog2 = log2(codingpasses);
  33089. var bits = (codingpasses < 1 << codingpassesLog2 ? codingpassesLog2 - 1 : codingpassesLog2) + codeblock.Lblock;
  33090. var codedDataLength = readBits(bits);
  33091. queue.push({
  33092. codeblock: codeblock,
  33093. codingpasses: codingpasses,
  33094. dataLength: codedDataLength
  33095. });
  33096. }
  33097. alignToByte();
  33098. if (ephMarkerUsed) {
  33099. skipMarkerIfEqual(0x92);
  33100. }
  33101. while (queue.length > 0) {
  33102. var packetItem = queue.shift();
  33103. codeblock = packetItem.codeblock;
  33104. if (codeblock['data'] === undefined) {
  33105. codeblock.data = [];
  33106. }
  33107. codeblock.data.push({
  33108. data: data,
  33109. start: offset + position,
  33110. end: offset + position + packetItem.dataLength,
  33111. codingpasses: packetItem.codingpasses
  33112. });
  33113. position += packetItem.dataLength;
  33114. }
  33115. }
  33116. return position;
  33117. }
  33118. function copyCoefficients(coefficients, levelWidth, levelHeight, subband, delta, mb, reversible, segmentationSymbolUsed) {
  33119. var x0 = subband.tbx0;
  33120. var y0 = subband.tby0;
  33121. var width = subband.tbx1 - subband.tbx0;
  33122. var codeblocks = subband.codeblocks;
  33123. var right = subband.type.charAt(0) === 'H' ? 1 : 0;
  33124. var bottom = subband.type.charAt(1) === 'H' ? levelWidth : 0;
  33125. for (var i = 0, ii = codeblocks.length; i < ii; ++i) {
  33126. var codeblock = codeblocks[i];
  33127. var blockWidth = codeblock.tbx1_ - codeblock.tbx0_;
  33128. var blockHeight = codeblock.tby1_ - codeblock.tby0_;
  33129. if (blockWidth === 0 || blockHeight === 0) {
  33130. continue;
  33131. }
  33132. if (codeblock['data'] === undefined) {
  33133. continue;
  33134. }
  33135. var bitModel, currentCodingpassType;
  33136. bitModel = new BitModel(blockWidth, blockHeight, codeblock.subbandType, codeblock.zeroBitPlanes, mb);
  33137. currentCodingpassType = 2;
  33138. var data = codeblock.data, totalLength = 0, codingpasses = 0;
  33139. var j, jj, dataItem;
  33140. for (j = 0, jj = data.length; j < jj; j++) {
  33141. dataItem = data[j];
  33142. totalLength += dataItem.end - dataItem.start;
  33143. codingpasses += dataItem.codingpasses;
  33144. }
  33145. var encodedData = new Uint8Array(totalLength);
  33146. var position = 0;
  33147. for (j = 0, jj = data.length; j < jj; j++) {
  33148. dataItem = data[j];
  33149. var chunk = dataItem.data.subarray(dataItem.start, dataItem.end);
  33150. encodedData.set(chunk, position);
  33151. position += chunk.length;
  33152. }
  33153. var decoder = new ArithmeticDecoder(encodedData, 0, totalLength);
  33154. bitModel.setDecoder(decoder);
  33155. for (j = 0; j < codingpasses; j++) {
  33156. switch (currentCodingpassType) {
  33157. case 0:
  33158. bitModel.runSignificancePropagationPass();
  33159. break;
  33160. case 1:
  33161. bitModel.runMagnitudeRefinementPass();
  33162. break;
  33163. case 2:
  33164. bitModel.runCleanupPass();
  33165. if (segmentationSymbolUsed) {
  33166. bitModel.checkSegmentationSymbol();
  33167. }
  33168. break;
  33169. }
  33170. currentCodingpassType = (currentCodingpassType + 1) % 3;
  33171. }
  33172. var offset = codeblock.tbx0_ - x0 + (codeblock.tby0_ - y0) * width;
  33173. var sign = bitModel.coefficentsSign;
  33174. var magnitude = bitModel.coefficentsMagnitude;
  33175. var bitsDecoded = bitModel.bitsDecoded;
  33176. var magnitudeCorrection = reversible ? 0 : 0.5;
  33177. var k, n, nb;
  33178. position = 0;
  33179. var interleave = subband.type !== 'LL';
  33180. for (j = 0; j < blockHeight; j++) {
  33181. var row = offset / width | 0;
  33182. var levelOffset = 2 * row * (levelWidth - width) + right + bottom;
  33183. for (k = 0; k < blockWidth; k++) {
  33184. n = magnitude[position];
  33185. if (n !== 0) {
  33186. n = (n + magnitudeCorrection) * delta;
  33187. if (sign[position] !== 0) {
  33188. n = -n;
  33189. }
  33190. nb = bitsDecoded[position];
  33191. var pos = interleave ? levelOffset + (offset << 1) : offset;
  33192. if (reversible && nb >= mb) {
  33193. coefficients[pos] = n;
  33194. } else {
  33195. coefficients[pos] = n * (1 << mb - nb);
  33196. }
  33197. }
  33198. offset++;
  33199. position++;
  33200. }
  33201. offset += width - blockWidth;
  33202. }
  33203. }
  33204. }
  33205. function transformTile(context, tile, c) {
  33206. var component = tile.components[c];
  33207. var codingStyleParameters = component.codingStyleParameters;
  33208. var quantizationParameters = component.quantizationParameters;
  33209. var decompositionLevelsCount = codingStyleParameters.decompositionLevelsCount;
  33210. var spqcds = quantizationParameters.SPqcds;
  33211. var scalarExpounded = quantizationParameters.scalarExpounded;
  33212. var guardBits = quantizationParameters.guardBits;
  33213. var segmentationSymbolUsed = codingStyleParameters.segmentationSymbolUsed;
  33214. var precision = context.components[c].precision;
  33215. var reversible = codingStyleParameters.reversibleTransformation;
  33216. var transform = reversible ? new ReversibleTransform() : new IrreversibleTransform();
  33217. var subbandCoefficients = [];
  33218. var b = 0;
  33219. for (var i = 0; i <= decompositionLevelsCount; i++) {
  33220. var resolution = component.resolutions[i];
  33221. var width = resolution.trx1 - resolution.trx0;
  33222. var height = resolution.try1 - resolution.try0;
  33223. var coefficients = new Float32Array(width * height);
  33224. for (var j = 0, jj = resolution.subbands.length; j < jj; j++) {
  33225. var mu, epsilon;
  33226. if (!scalarExpounded) {
  33227. mu = spqcds[0].mu;
  33228. epsilon = spqcds[0].epsilon + (i > 0 ? 1 - i : 0);
  33229. } else {
  33230. mu = spqcds[b].mu;
  33231. epsilon = spqcds[b].epsilon;
  33232. b++;
  33233. }
  33234. var subband = resolution.subbands[j];
  33235. var gainLog2 = SubbandsGainLog2[subband.type];
  33236. var delta = reversible ? 1 : Math.pow(2, precision + gainLog2 - epsilon) * (1 + mu / 2048);
  33237. var mb = guardBits + epsilon - 1;
  33238. copyCoefficients(coefficients, width, height, subband, delta, mb, reversible, segmentationSymbolUsed);
  33239. }
  33240. subbandCoefficients.push({
  33241. width: width,
  33242. height: height,
  33243. items: coefficients
  33244. });
  33245. }
  33246. var result = transform.calculate(subbandCoefficients, component.tcx0, component.tcy0);
  33247. return {
  33248. left: component.tcx0,
  33249. top: component.tcy0,
  33250. width: result.width,
  33251. height: result.height,
  33252. items: result.items
  33253. };
  33254. }
  33255. function transformComponents(context) {
  33256. var siz = context.SIZ;
  33257. var components = context.components;
  33258. var componentsCount = siz.Csiz;
  33259. var resultImages = [];
  33260. for (var i = 0, ii = context.tiles.length; i < ii; i++) {
  33261. var tile = context.tiles[i];
  33262. var transformedTiles = [];
  33263. var c;
  33264. for (c = 0; c < componentsCount; c++) {
  33265. transformedTiles[c] = transformTile(context, tile, c);
  33266. }
  33267. var tile0 = transformedTiles[0];
  33268. var out = new Uint8Array(tile0.items.length * componentsCount);
  33269. var result = {
  33270. left: tile0.left,
  33271. top: tile0.top,
  33272. width: tile0.width,
  33273. height: tile0.height,
  33274. items: out
  33275. };
  33276. var shift, offset, max, min, maxK;
  33277. var pos = 0, j, jj, y0, y1, y2, r, g, b, k, val;
  33278. if (tile.codingStyleDefaultParameters.multipleComponentTransform) {
  33279. var fourComponents = componentsCount === 4;
  33280. var y0items = transformedTiles[0].items;
  33281. var y1items = transformedTiles[1].items;
  33282. var y2items = transformedTiles[2].items;
  33283. var y3items = fourComponents ? transformedTiles[3].items : null;
  33284. shift = components[0].precision - 8;
  33285. offset = (128 << shift) + 0.5;
  33286. max = 255 * (1 << shift);
  33287. maxK = max * 0.5;
  33288. min = -maxK;
  33289. var component0 = tile.components[0];
  33290. var alpha01 = componentsCount - 3;
  33291. jj = y0items.length;
  33292. if (!component0.codingStyleParameters.reversibleTransformation) {
  33293. for (j = 0; j < jj; j++, pos += alpha01) {
  33294. y0 = y0items[j] + offset;
  33295. y1 = y1items[j];
  33296. y2 = y2items[j];
  33297. r = y0 + 1.402 * y2;
  33298. g = y0 - 0.34413 * y1 - 0.71414 * y2;
  33299. b = y0 + 1.772 * y1;
  33300. out[pos++] = r <= 0 ? 0 : r >= max ? 255 : r >> shift;
  33301. out[pos++] = g <= 0 ? 0 : g >= max ? 255 : g >> shift;
  33302. out[pos++] = b <= 0 ? 0 : b >= max ? 255 : b >> shift;
  33303. }
  33304. } else {
  33305. for (j = 0; j < jj; j++, pos += alpha01) {
  33306. y0 = y0items[j] + offset;
  33307. y1 = y1items[j];
  33308. y2 = y2items[j];
  33309. g = y0 - (y2 + y1 >> 2);
  33310. r = g + y2;
  33311. b = g + y1;
  33312. out[pos++] = r <= 0 ? 0 : r >= max ? 255 : r >> shift;
  33313. out[pos++] = g <= 0 ? 0 : g >= max ? 255 : g >> shift;
  33314. out[pos++] = b <= 0 ? 0 : b >= max ? 255 : b >> shift;
  33315. }
  33316. }
  33317. if (fourComponents) {
  33318. for (j = 0, pos = 3; j < jj; j++, pos += 4) {
  33319. k = y3items[j];
  33320. out[pos] = k <= min ? 0 : k >= maxK ? 255 : k + offset >> shift;
  33321. }
  33322. }
  33323. } else {
  33324. for (c = 0; c < componentsCount; c++) {
  33325. var items = transformedTiles[c].items;
  33326. shift = components[c].precision - 8;
  33327. offset = (128 << shift) + 0.5;
  33328. max = 127.5 * (1 << shift);
  33329. min = -max;
  33330. for (pos = c, j = 0, jj = items.length; j < jj; j++) {
  33331. val = items[j];
  33332. out[pos] = val <= min ? 0 : val >= max ? 255 : val + offset >> shift;
  33333. pos += componentsCount;
  33334. }
  33335. }
  33336. }
  33337. resultImages.push(result);
  33338. }
  33339. return resultImages;
  33340. }
  33341. function initializeTile(context, tileIndex) {
  33342. var siz = context.SIZ;
  33343. var componentsCount = siz.Csiz;
  33344. var tile = context.tiles[tileIndex];
  33345. for (var c = 0; c < componentsCount; c++) {
  33346. var component = tile.components[c];
  33347. var qcdOrQcc = context.currentTile.QCC[c] !== undefined ? context.currentTile.QCC[c] : context.currentTile.QCD;
  33348. component.quantizationParameters = qcdOrQcc;
  33349. var codOrCoc = context.currentTile.COC[c] !== undefined ? context.currentTile.COC[c] : context.currentTile.COD;
  33350. component.codingStyleParameters = codOrCoc;
  33351. }
  33352. tile.codingStyleDefaultParameters = context.currentTile.COD;
  33353. }
  33354. var TagTree = function TagTreeClosure() {
  33355. function TagTree(width, height) {
  33356. var levelsLength = log2(Math.max(width, height)) + 1;
  33357. this.levels = [];
  33358. for (var i = 0; i < levelsLength; i++) {
  33359. var level = {
  33360. width: width,
  33361. height: height,
  33362. items: []
  33363. };
  33364. this.levels.push(level);
  33365. width = Math.ceil(width / 2);
  33366. height = Math.ceil(height / 2);
  33367. }
  33368. }
  33369. TagTree.prototype = {
  33370. reset: function TagTree_reset(i, j) {
  33371. var currentLevel = 0, value = 0, level;
  33372. while (currentLevel < this.levels.length) {
  33373. level = this.levels[currentLevel];
  33374. var index = i + j * level.width;
  33375. if (level.items[index] !== undefined) {
  33376. value = level.items[index];
  33377. break;
  33378. }
  33379. level.index = index;
  33380. i >>= 1;
  33381. j >>= 1;
  33382. currentLevel++;
  33383. }
  33384. currentLevel--;
  33385. level = this.levels[currentLevel];
  33386. level.items[level.index] = value;
  33387. this.currentLevel = currentLevel;
  33388. delete this.value;
  33389. },
  33390. incrementValue: function TagTree_incrementValue() {
  33391. var level = this.levels[this.currentLevel];
  33392. level.items[level.index]++;
  33393. },
  33394. nextLevel: function TagTree_nextLevel() {
  33395. var currentLevel = this.currentLevel;
  33396. var level = this.levels[currentLevel];
  33397. var value = level.items[level.index];
  33398. currentLevel--;
  33399. if (currentLevel < 0) {
  33400. this.value = value;
  33401. return false;
  33402. }
  33403. this.currentLevel = currentLevel;
  33404. level = this.levels[currentLevel];
  33405. level.items[level.index] = value;
  33406. return true;
  33407. }
  33408. };
  33409. return TagTree;
  33410. }();
  33411. var InclusionTree = function InclusionTreeClosure() {
  33412. function InclusionTree(width, height, defaultValue) {
  33413. var levelsLength = log2(Math.max(width, height)) + 1;
  33414. this.levels = [];
  33415. for (var i = 0; i < levelsLength; i++) {
  33416. var items = new Uint8Array(width * height);
  33417. for (var j = 0, jj = items.length; j < jj; j++) {
  33418. items[j] = defaultValue;
  33419. }
  33420. var level = {
  33421. width: width,
  33422. height: height,
  33423. items: items
  33424. };
  33425. this.levels.push(level);
  33426. width = Math.ceil(width / 2);
  33427. height = Math.ceil(height / 2);
  33428. }
  33429. }
  33430. InclusionTree.prototype = {
  33431. reset: function InclusionTree_reset(i, j, stopValue) {
  33432. var currentLevel = 0;
  33433. while (currentLevel < this.levels.length) {
  33434. var level = this.levels[currentLevel];
  33435. var index = i + j * level.width;
  33436. level.index = index;
  33437. var value = level.items[index];
  33438. if (value === 0xFF) {
  33439. break;
  33440. }
  33441. if (value > stopValue) {
  33442. this.currentLevel = currentLevel;
  33443. this.propagateValues();
  33444. return false;
  33445. }
  33446. i >>= 1;
  33447. j >>= 1;
  33448. currentLevel++;
  33449. }
  33450. this.currentLevel = currentLevel - 1;
  33451. return true;
  33452. },
  33453. incrementValue: function InclusionTree_incrementValue(stopValue) {
  33454. var level = this.levels[this.currentLevel];
  33455. level.items[level.index] = stopValue + 1;
  33456. this.propagateValues();
  33457. },
  33458. propagateValues: function InclusionTree_propagateValues() {
  33459. var levelIndex = this.currentLevel;
  33460. var level = this.levels[levelIndex];
  33461. var currentValue = level.items[level.index];
  33462. while (--levelIndex >= 0) {
  33463. level = this.levels[levelIndex];
  33464. level.items[level.index] = currentValue;
  33465. }
  33466. },
  33467. nextLevel: function InclusionTree_nextLevel() {
  33468. var currentLevel = this.currentLevel;
  33469. var level = this.levels[currentLevel];
  33470. var value = level.items[level.index];
  33471. level.items[level.index] = 0xFF;
  33472. currentLevel--;
  33473. if (currentLevel < 0) {
  33474. return false;
  33475. }
  33476. this.currentLevel = currentLevel;
  33477. level = this.levels[currentLevel];
  33478. level.items[level.index] = value;
  33479. return true;
  33480. }
  33481. };
  33482. return InclusionTree;
  33483. }();
  33484. var BitModel = function BitModelClosure() {
  33485. var UNIFORM_CONTEXT = 17;
  33486. var RUNLENGTH_CONTEXT = 18;
  33487. var LLAndLHContextsLabel = new Uint8Array([
  33488. 0,
  33489. 5,
  33490. 8,
  33491. 0,
  33492. 3,
  33493. 7,
  33494. 8,
  33495. 0,
  33496. 4,
  33497. 7,
  33498. 8,
  33499. 0,
  33500. 0,
  33501. 0,
  33502. 0,
  33503. 0,
  33504. 1,
  33505. 6,
  33506. 8,
  33507. 0,
  33508. 3,
  33509. 7,
  33510. 8,
  33511. 0,
  33512. 4,
  33513. 7,
  33514. 8,
  33515. 0,
  33516. 0,
  33517. 0,
  33518. 0,
  33519. 0,
  33520. 2,
  33521. 6,
  33522. 8,
  33523. 0,
  33524. 3,
  33525. 7,
  33526. 8,
  33527. 0,
  33528. 4,
  33529. 7,
  33530. 8,
  33531. 0,
  33532. 0,
  33533. 0,
  33534. 0,
  33535. 0,
  33536. 2,
  33537. 6,
  33538. 8,
  33539. 0,
  33540. 3,
  33541. 7,
  33542. 8,
  33543. 0,
  33544. 4,
  33545. 7,
  33546. 8,
  33547. 0,
  33548. 0,
  33549. 0,
  33550. 0,
  33551. 0,
  33552. 2,
  33553. 6,
  33554. 8,
  33555. 0,
  33556. 3,
  33557. 7,
  33558. 8,
  33559. 0,
  33560. 4,
  33561. 7,
  33562. 8
  33563. ]);
  33564. var HLContextLabel = new Uint8Array([
  33565. 0,
  33566. 3,
  33567. 4,
  33568. 0,
  33569. 5,
  33570. 7,
  33571. 7,
  33572. 0,
  33573. 8,
  33574. 8,
  33575. 8,
  33576. 0,
  33577. 0,
  33578. 0,
  33579. 0,
  33580. 0,
  33581. 1,
  33582. 3,
  33583. 4,
  33584. 0,
  33585. 6,
  33586. 7,
  33587. 7,
  33588. 0,
  33589. 8,
  33590. 8,
  33591. 8,
  33592. 0,
  33593. 0,
  33594. 0,
  33595. 0,
  33596. 0,
  33597. 2,
  33598. 3,
  33599. 4,
  33600. 0,
  33601. 6,
  33602. 7,
  33603. 7,
  33604. 0,
  33605. 8,
  33606. 8,
  33607. 8,
  33608. 0,
  33609. 0,
  33610. 0,
  33611. 0,
  33612. 0,
  33613. 2,
  33614. 3,
  33615. 4,
  33616. 0,
  33617. 6,
  33618. 7,
  33619. 7,
  33620. 0,
  33621. 8,
  33622. 8,
  33623. 8,
  33624. 0,
  33625. 0,
  33626. 0,
  33627. 0,
  33628. 0,
  33629. 2,
  33630. 3,
  33631. 4,
  33632. 0,
  33633. 6,
  33634. 7,
  33635. 7,
  33636. 0,
  33637. 8,
  33638. 8,
  33639. 8
  33640. ]);
  33641. var HHContextLabel = new Uint8Array([
  33642. 0,
  33643. 1,
  33644. 2,
  33645. 0,
  33646. 1,
  33647. 2,
  33648. 2,
  33649. 0,
  33650. 2,
  33651. 2,
  33652. 2,
  33653. 0,
  33654. 0,
  33655. 0,
  33656. 0,
  33657. 0,
  33658. 3,
  33659. 4,
  33660. 5,
  33661. 0,
  33662. 4,
  33663. 5,
  33664. 5,
  33665. 0,
  33666. 5,
  33667. 5,
  33668. 5,
  33669. 0,
  33670. 0,
  33671. 0,
  33672. 0,
  33673. 0,
  33674. 6,
  33675. 7,
  33676. 7,
  33677. 0,
  33678. 7,
  33679. 7,
  33680. 7,
  33681. 0,
  33682. 7,
  33683. 7,
  33684. 7,
  33685. 0,
  33686. 0,
  33687. 0,
  33688. 0,
  33689. 0,
  33690. 8,
  33691. 8,
  33692. 8,
  33693. 0,
  33694. 8,
  33695. 8,
  33696. 8,
  33697. 0,
  33698. 8,
  33699. 8,
  33700. 8,
  33701. 0,
  33702. 0,
  33703. 0,
  33704. 0,
  33705. 0,
  33706. 8,
  33707. 8,
  33708. 8,
  33709. 0,
  33710. 8,
  33711. 8,
  33712. 8,
  33713. 0,
  33714. 8,
  33715. 8,
  33716. 8
  33717. ]);
  33718. function BitModel(width, height, subband, zeroBitPlanes, mb) {
  33719. this.width = width;
  33720. this.height = height;
  33721. this.contextLabelTable = subband === 'HH' ? HHContextLabel : subband === 'HL' ? HLContextLabel : LLAndLHContextsLabel;
  33722. var coefficientCount = width * height;
  33723. this.neighborsSignificance = new Uint8Array(coefficientCount);
  33724. this.coefficentsSign = new Uint8Array(coefficientCount);
  33725. this.coefficentsMagnitude = mb > 14 ? new Uint32Array(coefficientCount) : mb > 6 ? new Uint16Array(coefficientCount) : new Uint8Array(coefficientCount);
  33726. this.processingFlags = new Uint8Array(coefficientCount);
  33727. var bitsDecoded = new Uint8Array(coefficientCount);
  33728. if (zeroBitPlanes !== 0) {
  33729. for (var i = 0; i < coefficientCount; i++) {
  33730. bitsDecoded[i] = zeroBitPlanes;
  33731. }
  33732. }
  33733. this.bitsDecoded = bitsDecoded;
  33734. this.reset();
  33735. }
  33736. BitModel.prototype = {
  33737. setDecoder: function BitModel_setDecoder(decoder) {
  33738. this.decoder = decoder;
  33739. },
  33740. reset: function BitModel_reset() {
  33741. this.contexts = new Int8Array(19);
  33742. this.contexts[0] = 4 << 1 | 0;
  33743. this.contexts[UNIFORM_CONTEXT] = 46 << 1 | 0;
  33744. this.contexts[RUNLENGTH_CONTEXT] = 3 << 1 | 0;
  33745. },
  33746. setNeighborsSignificance: function BitModel_setNeighborsSignificance(row, column, index) {
  33747. var neighborsSignificance = this.neighborsSignificance;
  33748. var width = this.width, height = this.height;
  33749. var left = column > 0;
  33750. var right = column + 1 < width;
  33751. var i;
  33752. if (row > 0) {
  33753. i = index - width;
  33754. if (left) {
  33755. neighborsSignificance[i - 1] += 0x10;
  33756. }
  33757. if (right) {
  33758. neighborsSignificance[i + 1] += 0x10;
  33759. }
  33760. neighborsSignificance[i] += 0x04;
  33761. }
  33762. if (row + 1 < height) {
  33763. i = index + width;
  33764. if (left) {
  33765. neighborsSignificance[i - 1] += 0x10;
  33766. }
  33767. if (right) {
  33768. neighborsSignificance[i + 1] += 0x10;
  33769. }
  33770. neighborsSignificance[i] += 0x04;
  33771. }
  33772. if (left) {
  33773. neighborsSignificance[index - 1] += 0x01;
  33774. }
  33775. if (right) {
  33776. neighborsSignificance[index + 1] += 0x01;
  33777. }
  33778. neighborsSignificance[index] |= 0x80;
  33779. },
  33780. runSignificancePropagationPass: function BitModel_runSignificancePropagationPass() {
  33781. var decoder = this.decoder;
  33782. var width = this.width, height = this.height;
  33783. var coefficentsMagnitude = this.coefficentsMagnitude;
  33784. var coefficentsSign = this.coefficentsSign;
  33785. var neighborsSignificance = this.neighborsSignificance;
  33786. var processingFlags = this.processingFlags;
  33787. var contexts = this.contexts;
  33788. var labels = this.contextLabelTable;
  33789. var bitsDecoded = this.bitsDecoded;
  33790. var processedInverseMask = ~1;
  33791. var processedMask = 1;
  33792. var firstMagnitudeBitMask = 2;
  33793. for (var i0 = 0; i0 < height; i0 += 4) {
  33794. for (var j = 0; j < width; j++) {
  33795. var index = i0 * width + j;
  33796. for (var i1 = 0; i1 < 4; i1++, index += width) {
  33797. var i = i0 + i1;
  33798. if (i >= height) {
  33799. break;
  33800. }
  33801. processingFlags[index] &= processedInverseMask;
  33802. if (coefficentsMagnitude[index] || !neighborsSignificance[index]) {
  33803. continue;
  33804. }
  33805. var contextLabel = labels[neighborsSignificance[index]];
  33806. var decision = decoder.readBit(contexts, contextLabel);
  33807. if (decision) {
  33808. var sign = this.decodeSignBit(i, j, index);
  33809. coefficentsSign[index] = sign;
  33810. coefficentsMagnitude[index] = 1;
  33811. this.setNeighborsSignificance(i, j, index);
  33812. processingFlags[index] |= firstMagnitudeBitMask;
  33813. }
  33814. bitsDecoded[index]++;
  33815. processingFlags[index] |= processedMask;
  33816. }
  33817. }
  33818. }
  33819. },
  33820. decodeSignBit: function BitModel_decodeSignBit(row, column, index) {
  33821. var width = this.width, height = this.height;
  33822. var coefficentsMagnitude = this.coefficentsMagnitude;
  33823. var coefficentsSign = this.coefficentsSign;
  33824. var contribution, sign0, sign1, significance1;
  33825. var contextLabel, decoded;
  33826. significance1 = column > 0 && coefficentsMagnitude[index - 1] !== 0;
  33827. if (column + 1 < width && coefficentsMagnitude[index + 1] !== 0) {
  33828. sign1 = coefficentsSign[index + 1];
  33829. if (significance1) {
  33830. sign0 = coefficentsSign[index - 1];
  33831. contribution = 1 - sign1 - sign0;
  33832. } else {
  33833. contribution = 1 - sign1 - sign1;
  33834. }
  33835. } else if (significance1) {
  33836. sign0 = coefficentsSign[index - 1];
  33837. contribution = 1 - sign0 - sign0;
  33838. } else {
  33839. contribution = 0;
  33840. }
  33841. var horizontalContribution = 3 * contribution;
  33842. significance1 = row > 0 && coefficentsMagnitude[index - width] !== 0;
  33843. if (row + 1 < height && coefficentsMagnitude[index + width] !== 0) {
  33844. sign1 = coefficentsSign[index + width];
  33845. if (significance1) {
  33846. sign0 = coefficentsSign[index - width];
  33847. contribution = 1 - sign1 - sign0 + horizontalContribution;
  33848. } else {
  33849. contribution = 1 - sign1 - sign1 + horizontalContribution;
  33850. }
  33851. } else if (significance1) {
  33852. sign0 = coefficentsSign[index - width];
  33853. contribution = 1 - sign0 - sign0 + horizontalContribution;
  33854. } else {
  33855. contribution = horizontalContribution;
  33856. }
  33857. if (contribution >= 0) {
  33858. contextLabel = 9 + contribution;
  33859. decoded = this.decoder.readBit(this.contexts, contextLabel);
  33860. } else {
  33861. contextLabel = 9 - contribution;
  33862. decoded = this.decoder.readBit(this.contexts, contextLabel) ^ 1;
  33863. }
  33864. return decoded;
  33865. },
  33866. runMagnitudeRefinementPass: function BitModel_runMagnitudeRefinementPass() {
  33867. var decoder = this.decoder;
  33868. var width = this.width, height = this.height;
  33869. var coefficentsMagnitude = this.coefficentsMagnitude;
  33870. var neighborsSignificance = this.neighborsSignificance;
  33871. var contexts = this.contexts;
  33872. var bitsDecoded = this.bitsDecoded;
  33873. var processingFlags = this.processingFlags;
  33874. var processedMask = 1;
  33875. var firstMagnitudeBitMask = 2;
  33876. var length = width * height;
  33877. var width4 = width * 4;
  33878. for (var index0 = 0, indexNext; index0 < length; index0 = indexNext) {
  33879. indexNext = Math.min(length, index0 + width4);
  33880. for (var j = 0; j < width; j++) {
  33881. for (var index = index0 + j; index < indexNext; index += width) {
  33882. if (!coefficentsMagnitude[index] || (processingFlags[index] & processedMask) !== 0) {
  33883. continue;
  33884. }
  33885. var contextLabel = 16;
  33886. if ((processingFlags[index] & firstMagnitudeBitMask) !== 0) {
  33887. processingFlags[index] ^= firstMagnitudeBitMask;
  33888. var significance = neighborsSignificance[index] & 127;
  33889. contextLabel = significance === 0 ? 15 : 14;
  33890. }
  33891. var bit = decoder.readBit(contexts, contextLabel);
  33892. coefficentsMagnitude[index] = coefficentsMagnitude[index] << 1 | bit;
  33893. bitsDecoded[index]++;
  33894. processingFlags[index] |= processedMask;
  33895. }
  33896. }
  33897. }
  33898. },
  33899. runCleanupPass: function BitModel_runCleanupPass() {
  33900. var decoder = this.decoder;
  33901. var width = this.width, height = this.height;
  33902. var neighborsSignificance = this.neighborsSignificance;
  33903. var coefficentsMagnitude = this.coefficentsMagnitude;
  33904. var coefficentsSign = this.coefficentsSign;
  33905. var contexts = this.contexts;
  33906. var labels = this.contextLabelTable;
  33907. var bitsDecoded = this.bitsDecoded;
  33908. var processingFlags = this.processingFlags;
  33909. var processedMask = 1;
  33910. var firstMagnitudeBitMask = 2;
  33911. var oneRowDown = width;
  33912. var twoRowsDown = width * 2;
  33913. var threeRowsDown = width * 3;
  33914. var iNext;
  33915. for (var i0 = 0; i0 < height; i0 = iNext) {
  33916. iNext = Math.min(i0 + 4, height);
  33917. var indexBase = i0 * width;
  33918. var checkAllEmpty = i0 + 3 < height;
  33919. for (var j = 0; j < width; j++) {
  33920. var index0 = indexBase + j;
  33921. 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;
  33922. var i1 = 0, index = index0;
  33923. var i = i0, sign;
  33924. if (allEmpty) {
  33925. var hasSignificantCoefficent = decoder.readBit(contexts, RUNLENGTH_CONTEXT);
  33926. if (!hasSignificantCoefficent) {
  33927. bitsDecoded[index0]++;
  33928. bitsDecoded[index0 + oneRowDown]++;
  33929. bitsDecoded[index0 + twoRowsDown]++;
  33930. bitsDecoded[index0 + threeRowsDown]++;
  33931. continue;
  33932. }
  33933. i1 = decoder.readBit(contexts, UNIFORM_CONTEXT) << 1 | decoder.readBit(contexts, UNIFORM_CONTEXT);
  33934. if (i1 !== 0) {
  33935. i = i0 + i1;
  33936. index += i1 * width;
  33937. }
  33938. sign = this.decodeSignBit(i, j, index);
  33939. coefficentsSign[index] = sign;
  33940. coefficentsMagnitude[index] = 1;
  33941. this.setNeighborsSignificance(i, j, index);
  33942. processingFlags[index] |= firstMagnitudeBitMask;
  33943. index = index0;
  33944. for (var i2 = i0; i2 <= i; i2++, index += width) {
  33945. bitsDecoded[index]++;
  33946. }
  33947. i1++;
  33948. }
  33949. for (i = i0 + i1; i < iNext; i++, index += width) {
  33950. if (coefficentsMagnitude[index] || (processingFlags[index] & processedMask) !== 0) {
  33951. continue;
  33952. }
  33953. var contextLabel = labels[neighborsSignificance[index]];
  33954. var decision = decoder.readBit(contexts, contextLabel);
  33955. if (decision === 1) {
  33956. sign = this.decodeSignBit(i, j, index);
  33957. coefficentsSign[index] = sign;
  33958. coefficentsMagnitude[index] = 1;
  33959. this.setNeighborsSignificance(i, j, index);
  33960. processingFlags[index] |= firstMagnitudeBitMask;
  33961. }
  33962. bitsDecoded[index]++;
  33963. }
  33964. }
  33965. }
  33966. },
  33967. checkSegmentationSymbol: function BitModel_checkSegmentationSymbol() {
  33968. var decoder = this.decoder;
  33969. var contexts = this.contexts;
  33970. 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);
  33971. if (symbol !== 0xA) {
  33972. error('JPX Error: Invalid segmentation symbol');
  33973. }
  33974. }
  33975. };
  33976. return BitModel;
  33977. }();
  33978. var Transform = function TransformClosure() {
  33979. function Transform() {
  33980. }
  33981. Transform.prototype.calculate = function transformCalculate(subbands, u0, v0) {
  33982. var ll = subbands[0];
  33983. for (var i = 1, ii = subbands.length; i < ii; i++) {
  33984. ll = this.iterate(ll, subbands[i], u0, v0);
  33985. }
  33986. return ll;
  33987. };
  33988. Transform.prototype.extend = function extend(buffer, offset, size) {
  33989. var i1 = offset - 1, j1 = offset + 1;
  33990. var i2 = offset + size - 2, j2 = offset + size;
  33991. buffer[i1--] = buffer[j1++];
  33992. buffer[j2++] = buffer[i2--];
  33993. buffer[i1--] = buffer[j1++];
  33994. buffer[j2++] = buffer[i2--];
  33995. buffer[i1--] = buffer[j1++];
  33996. buffer[j2++] = buffer[i2--];
  33997. buffer[i1] = buffer[j1];
  33998. buffer[j2] = buffer[i2];
  33999. };
  34000. Transform.prototype.iterate = function Transform_iterate(ll, hl_lh_hh, u0, v0) {
  34001. var llWidth = ll.width, llHeight = ll.height, llItems = ll.items;
  34002. var width = hl_lh_hh.width;
  34003. var height = hl_lh_hh.height;
  34004. var items = hl_lh_hh.items;
  34005. var i, j, k, l, u, v;
  34006. for (k = 0, i = 0; i < llHeight; i++) {
  34007. l = i * 2 * width;
  34008. for (j = 0; j < llWidth; j++, k++, l += 2) {
  34009. items[l] = llItems[k];
  34010. }
  34011. }
  34012. llItems = ll.items = null;
  34013. var bufferPadding = 4;
  34014. var rowBuffer = new Float32Array(width + 2 * bufferPadding);
  34015. if (width === 1) {
  34016. if ((u0 & 1) !== 0) {
  34017. for (v = 0, k = 0; v < height; v++, k += width) {
  34018. items[k] *= 0.5;
  34019. }
  34020. }
  34021. } else {
  34022. for (v = 0, k = 0; v < height; v++, k += width) {
  34023. rowBuffer.set(items.subarray(k, k + width), bufferPadding);
  34024. this.extend(rowBuffer, bufferPadding, width);
  34025. this.filter(rowBuffer, bufferPadding, width);
  34026. items.set(rowBuffer.subarray(bufferPadding, bufferPadding + width), k);
  34027. }
  34028. }
  34029. var numBuffers = 16;
  34030. var colBuffers = [];
  34031. for (i = 0; i < numBuffers; i++) {
  34032. colBuffers.push(new Float32Array(height + 2 * bufferPadding));
  34033. }
  34034. var b, currentBuffer = 0;
  34035. ll = bufferPadding + height;
  34036. if (height === 1) {
  34037. if ((v0 & 1) !== 0) {
  34038. for (u = 0; u < width; u++) {
  34039. items[u] *= 0.5;
  34040. }
  34041. }
  34042. } else {
  34043. for (u = 0; u < width; u++) {
  34044. if (currentBuffer === 0) {
  34045. numBuffers = Math.min(width - u, numBuffers);
  34046. for (k = u, l = bufferPadding; l < ll; k += width, l++) {
  34047. for (b = 0; b < numBuffers; b++) {
  34048. colBuffers[b][l] = items[k + b];
  34049. }
  34050. }
  34051. currentBuffer = numBuffers;
  34052. }
  34053. currentBuffer--;
  34054. var buffer = colBuffers[currentBuffer];
  34055. this.extend(buffer, bufferPadding, height);
  34056. this.filter(buffer, bufferPadding, height);
  34057. if (currentBuffer === 0) {
  34058. k = u - numBuffers + 1;
  34059. for (l = bufferPadding; l < ll; k += width, l++) {
  34060. for (b = 0; b < numBuffers; b++) {
  34061. items[k + b] = colBuffers[b][l];
  34062. }
  34063. }
  34064. }
  34065. }
  34066. }
  34067. return {
  34068. width: width,
  34069. height: height,
  34070. items: items
  34071. };
  34072. };
  34073. return Transform;
  34074. }();
  34075. var IrreversibleTransform = function IrreversibleTransformClosure() {
  34076. function IrreversibleTransform() {
  34077. Transform.call(this);
  34078. }
  34079. IrreversibleTransform.prototype = Object.create(Transform.prototype);
  34080. IrreversibleTransform.prototype.filter = function irreversibleTransformFilter(x, offset, length) {
  34081. var len = length >> 1;
  34082. offset = offset | 0;
  34083. var j, n, current, next;
  34084. var alpha = -1.586134342059924;
  34085. var beta = -0.052980118572961;
  34086. var gamma = 0.882911075530934;
  34087. var delta = 0.443506852043971;
  34088. var K = 1.230174104914001;
  34089. var K_ = 1 / K;
  34090. j = offset - 3;
  34091. for (n = len + 4; n--; j += 2) {
  34092. x[j] *= K_;
  34093. }
  34094. j = offset - 2;
  34095. current = delta * x[j - 1];
  34096. for (n = len + 3; n--; j += 2) {
  34097. next = delta * x[j + 1];
  34098. x[j] = K * x[j] - current - next;
  34099. if (n--) {
  34100. j += 2;
  34101. current = delta * x[j + 1];
  34102. x[j] = K * x[j] - current - next;
  34103. } else {
  34104. break;
  34105. }
  34106. }
  34107. j = offset - 1;
  34108. current = gamma * x[j - 1];
  34109. for (n = len + 2; n--; j += 2) {
  34110. next = gamma * x[j + 1];
  34111. x[j] -= current + next;
  34112. if (n--) {
  34113. j += 2;
  34114. current = gamma * x[j + 1];
  34115. x[j] -= current + next;
  34116. } else {
  34117. break;
  34118. }
  34119. }
  34120. j = offset;
  34121. current = beta * x[j - 1];
  34122. for (n = len + 1; n--; j += 2) {
  34123. next = beta * x[j + 1];
  34124. x[j] -= current + next;
  34125. if (n--) {
  34126. j += 2;
  34127. current = beta * x[j + 1];
  34128. x[j] -= current + next;
  34129. } else {
  34130. break;
  34131. }
  34132. }
  34133. if (len !== 0) {
  34134. j = offset + 1;
  34135. current = alpha * x[j - 1];
  34136. for (n = len; n--; j += 2) {
  34137. next = alpha * x[j + 1];
  34138. x[j] -= current + next;
  34139. if (n--) {
  34140. j += 2;
  34141. current = alpha * x[j + 1];
  34142. x[j] -= current + next;
  34143. } else {
  34144. break;
  34145. }
  34146. }
  34147. }
  34148. };
  34149. return IrreversibleTransform;
  34150. }();
  34151. var ReversibleTransform = function ReversibleTransformClosure() {
  34152. function ReversibleTransform() {
  34153. Transform.call(this);
  34154. }
  34155. ReversibleTransform.prototype = Object.create(Transform.prototype);
  34156. ReversibleTransform.prototype.filter = function reversibleTransformFilter(x, offset, length) {
  34157. var len = length >> 1;
  34158. offset = offset | 0;
  34159. var j, n;
  34160. for (j = offset, n = len + 1; n--; j += 2) {
  34161. x[j] -= x[j - 1] + x[j + 1] + 2 >> 2;
  34162. }
  34163. for (j = offset + 1, n = len; n--; j += 2) {
  34164. x[j] += x[j - 1] + x[j + 1] >> 1;
  34165. }
  34166. };
  34167. return ReversibleTransform;
  34168. }();
  34169. return JpxImage;
  34170. }();
  34171. exports.JpxImage = JpxImage;
  34172. /***/ }),
  34173. /* 19 */
  34174. /***/ (function(module, exports, __w_pdfjs_require__) {
  34175. "use strict";
  34176. var sharedUtil = __w_pdfjs_require__(0);
  34177. var corePrimitives = __w_pdfjs_require__(1);
  34178. var coreCrypto = __w_pdfjs_require__(16);
  34179. var coreParser = __w_pdfjs_require__(6);
  34180. var coreChunkedStream = __w_pdfjs_require__(15);
  34181. var coreColorSpace = __w_pdfjs_require__(4);
  34182. var InvalidPDFException = sharedUtil.InvalidPDFException;
  34183. var MissingDataException = sharedUtil.MissingDataException;
  34184. var XRefParseException = sharedUtil.XRefParseException;
  34185. var assert = sharedUtil.assert;
  34186. var bytesToString = sharedUtil.bytesToString;
  34187. var createPromiseCapability = sharedUtil.createPromiseCapability;
  34188. var error = sharedUtil.error;
  34189. var info = sharedUtil.info;
  34190. var isArray = sharedUtil.isArray;
  34191. var isBool = sharedUtil.isBool;
  34192. var isInt = sharedUtil.isInt;
  34193. var isString = sharedUtil.isString;
  34194. var shadow = sharedUtil.shadow;
  34195. var stringToPDFString = sharedUtil.stringToPDFString;
  34196. var stringToUTF8String = sharedUtil.stringToUTF8String;
  34197. var warn = sharedUtil.warn;
  34198. var createValidAbsoluteUrl = sharedUtil.createValidAbsoluteUrl;
  34199. var Util = sharedUtil.Util;
  34200. var Ref = corePrimitives.Ref;
  34201. var RefSet = corePrimitives.RefSet;
  34202. var RefSetCache = corePrimitives.RefSetCache;
  34203. var isName = corePrimitives.isName;
  34204. var isCmd = corePrimitives.isCmd;
  34205. var isDict = corePrimitives.isDict;
  34206. var isRef = corePrimitives.isRef;
  34207. var isRefsEqual = corePrimitives.isRefsEqual;
  34208. var isStream = corePrimitives.isStream;
  34209. var CipherTransformFactory = coreCrypto.CipherTransformFactory;
  34210. var Lexer = coreParser.Lexer;
  34211. var Parser = coreParser.Parser;
  34212. var ChunkedStream = coreChunkedStream.ChunkedStream;
  34213. var ColorSpace = coreColorSpace.ColorSpace;
  34214. var Catalog = function CatalogClosure() {
  34215. function Catalog(pdfManager, xref, pageFactory) {
  34216. this.pdfManager = pdfManager;
  34217. this.xref = xref;
  34218. this.catDict = xref.getCatalogObj();
  34219. this.fontCache = new RefSetCache();
  34220. assert(isDict(this.catDict), 'catalog object is not a dictionary');
  34221. this.pageFactory = pageFactory;
  34222. this.pagePromises = [];
  34223. }
  34224. Catalog.prototype = {
  34225. get metadata() {
  34226. var streamRef = this.catDict.getRaw('Metadata');
  34227. if (!isRef(streamRef)) {
  34228. return shadow(this, 'metadata', null);
  34229. }
  34230. var encryptMetadata = !this.xref.encrypt ? false : this.xref.encrypt.encryptMetadata;
  34231. var stream = this.xref.fetch(streamRef, !encryptMetadata);
  34232. var metadata;
  34233. if (stream && isDict(stream.dict)) {
  34234. var type = stream.dict.get('Type');
  34235. var subtype = stream.dict.get('Subtype');
  34236. if (isName(type, 'Metadata') && isName(subtype, 'XML')) {
  34237. try {
  34238. metadata = stringToUTF8String(bytesToString(stream.getBytes()));
  34239. } catch (e) {
  34240. info('Skipping invalid metadata.');
  34241. }
  34242. }
  34243. }
  34244. return shadow(this, 'metadata', metadata);
  34245. },
  34246. get toplevelPagesDict() {
  34247. var pagesObj = this.catDict.get('Pages');
  34248. assert(isDict(pagesObj), 'invalid top-level pages dictionary');
  34249. return shadow(this, 'toplevelPagesDict', pagesObj);
  34250. },
  34251. get documentOutline() {
  34252. var obj = null;
  34253. try {
  34254. obj = this.readDocumentOutline();
  34255. } catch (ex) {
  34256. if (ex instanceof MissingDataException) {
  34257. throw ex;
  34258. }
  34259. warn('Unable to read document outline');
  34260. }
  34261. return shadow(this, 'documentOutline', obj);
  34262. },
  34263. readDocumentOutline: function Catalog_readDocumentOutline() {
  34264. var obj = this.catDict.get('Outlines');
  34265. if (!isDict(obj)) {
  34266. return null;
  34267. }
  34268. obj = obj.getRaw('First');
  34269. if (!isRef(obj)) {
  34270. return null;
  34271. }
  34272. var root = { items: [] };
  34273. var queue = [{
  34274. obj: obj,
  34275. parent: root
  34276. }];
  34277. var processed = new RefSet();
  34278. processed.put(obj);
  34279. var xref = this.xref, blackColor = new Uint8Array(3);
  34280. while (queue.length > 0) {
  34281. var i = queue.shift();
  34282. var outlineDict = xref.fetchIfRef(i.obj);
  34283. if (outlineDict === null) {
  34284. continue;
  34285. }
  34286. assert(outlineDict.has('Title'), 'Invalid outline item');
  34287. var data = {
  34288. url: null,
  34289. dest: null
  34290. };
  34291. Catalog.parseDestDictionary({
  34292. destDict: outlineDict,
  34293. resultObj: data,
  34294. docBaseUrl: this.pdfManager.docBaseUrl
  34295. });
  34296. var title = outlineDict.get('Title');
  34297. var flags = outlineDict.get('F') || 0;
  34298. var color = outlineDict.getArray('C'), rgbColor = blackColor;
  34299. if (isArray(color) && color.length === 3 && (color[0] !== 0 || color[1] !== 0 || color[2] !== 0)) {
  34300. rgbColor = ColorSpace.singletons.rgb.getRgb(color, 0);
  34301. }
  34302. var outlineItem = {
  34303. dest: data.dest,
  34304. url: data.url,
  34305. unsafeUrl: data.unsafeUrl,
  34306. newWindow: data.newWindow,
  34307. title: stringToPDFString(title),
  34308. color: rgbColor,
  34309. count: outlineDict.get('Count'),
  34310. bold: !!(flags & 2),
  34311. italic: !!(flags & 1),
  34312. items: []
  34313. };
  34314. i.parent.items.push(outlineItem);
  34315. obj = outlineDict.getRaw('First');
  34316. if (isRef(obj) && !processed.has(obj)) {
  34317. queue.push({
  34318. obj: obj,
  34319. parent: outlineItem
  34320. });
  34321. processed.put(obj);
  34322. }
  34323. obj = outlineDict.getRaw('Next');
  34324. if (isRef(obj) && !processed.has(obj)) {
  34325. queue.push({
  34326. obj: obj,
  34327. parent: i.parent
  34328. });
  34329. processed.put(obj);
  34330. }
  34331. }
  34332. return root.items.length > 0 ? root.items : null;
  34333. },
  34334. get numPages() {
  34335. var obj = this.toplevelPagesDict.get('Count');
  34336. assert(isInt(obj), 'page count in top level pages object is not an integer');
  34337. return shadow(this, 'num', obj);
  34338. },
  34339. get destinations() {
  34340. function fetchDestination(dest) {
  34341. return isDict(dest) ? dest.get('D') : dest;
  34342. }
  34343. var xref = this.xref;
  34344. var dests = {}, nameTreeRef, nameDictionaryRef;
  34345. var obj = this.catDict.get('Names');
  34346. if (obj && obj.has('Dests')) {
  34347. nameTreeRef = obj.getRaw('Dests');
  34348. } else if (this.catDict.has('Dests')) {
  34349. nameDictionaryRef = this.catDict.get('Dests');
  34350. }
  34351. if (nameDictionaryRef) {
  34352. obj = nameDictionaryRef;
  34353. obj.forEach(function catalogForEach(key, value) {
  34354. if (!value) {
  34355. return;
  34356. }
  34357. dests[key] = fetchDestination(value);
  34358. });
  34359. }
  34360. if (nameTreeRef) {
  34361. var nameTree = new NameTree(nameTreeRef, xref);
  34362. var names = nameTree.getAll();
  34363. for (var name in names) {
  34364. dests[name] = fetchDestination(names[name]);
  34365. }
  34366. }
  34367. return shadow(this, 'destinations', dests);
  34368. },
  34369. getDestination: function Catalog_getDestination(destinationId) {
  34370. function fetchDestination(dest) {
  34371. return isDict(dest) ? dest.get('D') : dest;
  34372. }
  34373. var xref = this.xref;
  34374. var dest = null, nameTreeRef, nameDictionaryRef;
  34375. var obj = this.catDict.get('Names');
  34376. if (obj && obj.has('Dests')) {
  34377. nameTreeRef = obj.getRaw('Dests');
  34378. } else if (this.catDict.has('Dests')) {
  34379. nameDictionaryRef = this.catDict.get('Dests');
  34380. }
  34381. if (nameDictionaryRef) {
  34382. var value = nameDictionaryRef.get(destinationId);
  34383. if (value) {
  34384. dest = fetchDestination(value);
  34385. }
  34386. }
  34387. if (nameTreeRef) {
  34388. var nameTree = new NameTree(nameTreeRef, xref);
  34389. dest = fetchDestination(nameTree.get(destinationId));
  34390. }
  34391. return dest;
  34392. },
  34393. get pageLabels() {
  34394. var obj = null;
  34395. try {
  34396. obj = this.readPageLabels();
  34397. } catch (ex) {
  34398. if (ex instanceof MissingDataException) {
  34399. throw ex;
  34400. }
  34401. warn('Unable to read page labels.');
  34402. }
  34403. return shadow(this, 'pageLabels', obj);
  34404. },
  34405. readPageLabels: function Catalog_readPageLabels() {
  34406. var obj = this.catDict.getRaw('PageLabels');
  34407. if (!obj) {
  34408. return null;
  34409. }
  34410. var pageLabels = new Array(this.numPages);
  34411. var style = null;
  34412. var prefix = '';
  34413. var numberTree = new NumberTree(obj, this.xref);
  34414. var nums = numberTree.getAll();
  34415. var currentLabel = '', currentIndex = 1;
  34416. for (var i = 0, ii = this.numPages; i < ii; i++) {
  34417. if (i in nums) {
  34418. var labelDict = nums[i];
  34419. assert(isDict(labelDict), 'The PageLabel is not a dictionary.');
  34420. var type = labelDict.get('Type');
  34421. assert(!type || isName(type, 'PageLabel'), 'Invalid type in PageLabel dictionary.');
  34422. var s = labelDict.get('S');
  34423. assert(!s || isName(s), 'Invalid style in PageLabel dictionary.');
  34424. style = s ? s.name : null;
  34425. var p = labelDict.get('P');
  34426. assert(!p || isString(p), 'Invalid prefix in PageLabel dictionary.');
  34427. prefix = p ? stringToPDFString(p) : '';
  34428. var st = labelDict.get('St');
  34429. assert(!st || isInt(st) && st >= 1, 'Invalid start in PageLabel dictionary.');
  34430. currentIndex = st || 1;
  34431. }
  34432. switch (style) {
  34433. case 'D':
  34434. currentLabel = currentIndex;
  34435. break;
  34436. case 'R':
  34437. case 'r':
  34438. currentLabel = Util.toRoman(currentIndex, style === 'r');
  34439. break;
  34440. case 'A':
  34441. case 'a':
  34442. var LIMIT = 26;
  34443. var A_UPPER_CASE = 0x41, A_LOWER_CASE = 0x61;
  34444. var baseCharCode = style === 'a' ? A_LOWER_CASE : A_UPPER_CASE;
  34445. var letterIndex = currentIndex - 1;
  34446. var character = String.fromCharCode(baseCharCode + letterIndex % LIMIT);
  34447. var charBuf = [];
  34448. for (var j = 0, jj = letterIndex / LIMIT | 0; j <= jj; j++) {
  34449. charBuf.push(character);
  34450. }
  34451. currentLabel = charBuf.join('');
  34452. break;
  34453. default:
  34454. assert(!style, 'Invalid style "' + style + '" in PageLabel dictionary.');
  34455. }
  34456. pageLabels[i] = prefix + currentLabel;
  34457. currentLabel = '';
  34458. currentIndex++;
  34459. }
  34460. return pageLabels;
  34461. },
  34462. get attachments() {
  34463. var xref = this.xref;
  34464. var attachments = null, nameTreeRef;
  34465. var obj = this.catDict.get('Names');
  34466. if (obj) {
  34467. nameTreeRef = obj.getRaw('EmbeddedFiles');
  34468. }
  34469. if (nameTreeRef) {
  34470. var nameTree = new NameTree(nameTreeRef, xref);
  34471. var names = nameTree.getAll();
  34472. for (var name in names) {
  34473. var fs = new FileSpec(names[name], xref);
  34474. if (!attachments) {
  34475. attachments = Object.create(null);
  34476. }
  34477. attachments[stringToPDFString(name)] = fs.serializable;
  34478. }
  34479. }
  34480. return shadow(this, 'attachments', attachments);
  34481. },
  34482. get javaScript() {
  34483. var xref = this.xref;
  34484. var obj = this.catDict.get('Names');
  34485. var javaScript = [];
  34486. function appendIfJavaScriptDict(jsDict) {
  34487. var type = jsDict.get('S');
  34488. if (!isName(type, 'JavaScript')) {
  34489. return;
  34490. }
  34491. var js = jsDict.get('JS');
  34492. if (isStream(js)) {
  34493. js = bytesToString(js.getBytes());
  34494. } else if (!isString(js)) {
  34495. return;
  34496. }
  34497. javaScript.push(stringToPDFString(js));
  34498. }
  34499. if (obj && obj.has('JavaScript')) {
  34500. var nameTree = new NameTree(obj.getRaw('JavaScript'), xref);
  34501. var names = nameTree.getAll();
  34502. for (var name in names) {
  34503. var jsDict = names[name];
  34504. if (isDict(jsDict)) {
  34505. appendIfJavaScriptDict(jsDict);
  34506. }
  34507. }
  34508. }
  34509. var openactionDict = this.catDict.get('OpenAction');
  34510. if (isDict(openactionDict, 'Action')) {
  34511. var actionType = openactionDict.get('S');
  34512. if (isName(actionType, 'Named')) {
  34513. var action = openactionDict.get('N');
  34514. if (isName(action, 'Print')) {
  34515. javaScript.push('print({});');
  34516. }
  34517. } else {
  34518. appendIfJavaScriptDict(openactionDict);
  34519. }
  34520. }
  34521. return shadow(this, 'javaScript', javaScript);
  34522. },
  34523. cleanup: function Catalog_cleanup() {
  34524. var promises = [];
  34525. this.fontCache.forEach(function (promise) {
  34526. promises.push(promise);
  34527. });
  34528. return Promise.all(promises).then(function (translatedFonts) {
  34529. for (var i = 0, ii = translatedFonts.length; i < ii; i++) {
  34530. var font = translatedFonts[i].dict;
  34531. delete font.translated;
  34532. }
  34533. this.fontCache.clear();
  34534. }.bind(this));
  34535. },
  34536. getPage: function Catalog_getPage(pageIndex) {
  34537. if (!(pageIndex in this.pagePromises)) {
  34538. this.pagePromises[pageIndex] = this.getPageDict(pageIndex).then(function (a) {
  34539. var dict = a[0];
  34540. var ref = a[1];
  34541. return this.pageFactory.createPage(pageIndex, dict, ref, this.fontCache);
  34542. }.bind(this));
  34543. }
  34544. return this.pagePromises[pageIndex];
  34545. },
  34546. getPageDict: function Catalog_getPageDict(pageIndex) {
  34547. var capability = createPromiseCapability();
  34548. var nodesToVisit = [this.catDict.getRaw('Pages')];
  34549. var currentPageIndex = 0;
  34550. var xref = this.xref;
  34551. var checkAllKids = false;
  34552. function next() {
  34553. while (nodesToVisit.length) {
  34554. var currentNode = nodesToVisit.pop();
  34555. if (isRef(currentNode)) {
  34556. xref.fetchAsync(currentNode).then(function (obj) {
  34557. if (isDict(obj, 'Page') || isDict(obj) && !obj.has('Kids')) {
  34558. if (pageIndex === currentPageIndex) {
  34559. capability.resolve([
  34560. obj,
  34561. currentNode
  34562. ]);
  34563. } else {
  34564. currentPageIndex++;
  34565. next();
  34566. }
  34567. return;
  34568. }
  34569. nodesToVisit.push(obj);
  34570. next();
  34571. }, capability.reject);
  34572. return;
  34573. }
  34574. assert(isDict(currentNode), 'page dictionary kid reference points to wrong type of object');
  34575. var count = currentNode.get('Count');
  34576. if (count === 0) {
  34577. checkAllKids = true;
  34578. }
  34579. if (currentPageIndex + count <= pageIndex) {
  34580. currentPageIndex += count;
  34581. continue;
  34582. }
  34583. var kids = currentNode.get('Kids');
  34584. assert(isArray(kids), 'page dictionary kids object is not an array');
  34585. if (!checkAllKids && count === kids.length) {
  34586. nodesToVisit = [kids[pageIndex - currentPageIndex]];
  34587. currentPageIndex = pageIndex;
  34588. continue;
  34589. } else {
  34590. for (var last = kids.length - 1; last >= 0; last--) {
  34591. nodesToVisit.push(kids[last]);
  34592. }
  34593. }
  34594. }
  34595. capability.reject('Page index ' + pageIndex + ' not found.');
  34596. }
  34597. next();
  34598. return capability.promise;
  34599. },
  34600. getPageIndex: function Catalog_getPageIndex(pageRef) {
  34601. var xref = this.xref;
  34602. function pagesBeforeRef(kidRef) {
  34603. var total = 0;
  34604. var parentRef;
  34605. return xref.fetchAsync(kidRef).then(function (node) {
  34606. if (isRefsEqual(kidRef, pageRef) && !isDict(node, 'Page') && !(isDict(node) && !node.has('Type') && node.has('Contents'))) {
  34607. throw new Error('The reference does not point to a /Page Dict.');
  34608. }
  34609. if (!node) {
  34610. return null;
  34611. }
  34612. assert(isDict(node), 'node must be a Dict.');
  34613. parentRef = node.getRaw('Parent');
  34614. return node.getAsync('Parent');
  34615. }).then(function (parent) {
  34616. if (!parent) {
  34617. return null;
  34618. }
  34619. assert(isDict(parent), 'parent must be a Dict.');
  34620. return parent.getAsync('Kids');
  34621. }).then(function (kids) {
  34622. if (!kids) {
  34623. return null;
  34624. }
  34625. var kidPromises = [];
  34626. var found = false;
  34627. for (var i = 0; i < kids.length; i++) {
  34628. var kid = kids[i];
  34629. assert(isRef(kid), 'kid must be a Ref.');
  34630. if (kid.num === kidRef.num) {
  34631. found = true;
  34632. break;
  34633. }
  34634. kidPromises.push(xref.fetchAsync(kid).then(function (kid) {
  34635. if (kid.has('Count')) {
  34636. var count = kid.get('Count');
  34637. total += count;
  34638. } else {
  34639. total++;
  34640. }
  34641. }));
  34642. }
  34643. if (!found) {
  34644. error('kid ref not found in parents kids');
  34645. }
  34646. return Promise.all(kidPromises).then(function () {
  34647. return [
  34648. total,
  34649. parentRef
  34650. ];
  34651. });
  34652. });
  34653. }
  34654. var total = 0;
  34655. function next(ref) {
  34656. return pagesBeforeRef(ref).then(function (args) {
  34657. if (!args) {
  34658. return total;
  34659. }
  34660. var count = args[0];
  34661. var parentRef = args[1];
  34662. total += count;
  34663. return next(parentRef);
  34664. });
  34665. }
  34666. return next(pageRef);
  34667. }
  34668. };
  34669. Catalog.parseDestDictionary = function Catalog_parseDestDictionary(params) {
  34670. function addDefaultProtocolToUrl(url) {
  34671. if (url.indexOf('www.') === 0) {
  34672. return 'http://' + url;
  34673. }
  34674. return url;
  34675. }
  34676. function tryConvertUrlEncoding(url) {
  34677. try {
  34678. return stringToUTF8String(url);
  34679. } catch (e) {
  34680. return url;
  34681. }
  34682. }
  34683. var destDict = params.destDict;
  34684. if (!isDict(destDict)) {
  34685. warn('Catalog_parseDestDictionary: "destDict" must be a dictionary.');
  34686. return;
  34687. }
  34688. var resultObj = params.resultObj;
  34689. if (typeof resultObj !== 'object') {
  34690. warn('Catalog_parseDestDictionary: "resultObj" must be an object.');
  34691. return;
  34692. }
  34693. var docBaseUrl = params.docBaseUrl || null;
  34694. var action = destDict.get('A'), url, dest;
  34695. if (isDict(action)) {
  34696. var linkType = action.get('S').name;
  34697. switch (linkType) {
  34698. case 'URI':
  34699. url = action.get('URI');
  34700. if (isName(url)) {
  34701. url = '/' + url.name;
  34702. } else if (isString(url)) {
  34703. url = addDefaultProtocolToUrl(url);
  34704. }
  34705. break;
  34706. case 'GoTo':
  34707. dest = action.get('D');
  34708. break;
  34709. case 'Launch':
  34710. case 'GoToR':
  34711. var urlDict = action.get('F');
  34712. if (isDict(urlDict)) {
  34713. url = urlDict.get('F') || null;
  34714. } else if (isString(urlDict)) {
  34715. url = urlDict;
  34716. }
  34717. var remoteDest = action.get('D');
  34718. if (remoteDest) {
  34719. if (isName(remoteDest)) {
  34720. remoteDest = remoteDest.name;
  34721. }
  34722. if (isString(url)) {
  34723. var baseUrl = url.split('#')[0];
  34724. if (isString(remoteDest)) {
  34725. url = baseUrl + '#' + (/^\d+$/.test(remoteDest) ? 'nameddest=' : '') + remoteDest;
  34726. } else if (isArray(remoteDest)) {
  34727. url = baseUrl + '#' + JSON.stringify(remoteDest);
  34728. }
  34729. }
  34730. }
  34731. var newWindow = action.get('NewWindow');
  34732. if (isBool(newWindow)) {
  34733. resultObj.newWindow = newWindow;
  34734. }
  34735. break;
  34736. case 'Named':
  34737. var namedAction = action.get('N');
  34738. if (isName(namedAction)) {
  34739. resultObj.action = namedAction.name;
  34740. }
  34741. break;
  34742. case 'JavaScript':
  34743. var jsAction = action.get('JS'), js;
  34744. if (isStream(jsAction)) {
  34745. js = bytesToString(jsAction.getBytes());
  34746. } else if (isString(jsAction)) {
  34747. js = jsAction;
  34748. }
  34749. if (js) {
  34750. var URL_OPEN_METHODS = [
  34751. 'app.launchURL',
  34752. 'window.open'
  34753. ];
  34754. var regex = new RegExp('^(?:' + URL_OPEN_METHODS.join('|') + ')' + '\\((?:\'|\")(\\S+)(?:\'|\")(?:,|\\))');
  34755. var jsUrl = regex.exec(stringToPDFString(js), 'i');
  34756. if (jsUrl && jsUrl[1]) {
  34757. url = jsUrl[1];
  34758. break;
  34759. }
  34760. }
  34761. default:
  34762. warn('Catalog_parseDestDictionary: Unrecognized link type "' + linkType + '".');
  34763. break;
  34764. }
  34765. } else if (destDict.has('Dest')) {
  34766. dest = destDict.get('Dest');
  34767. }
  34768. if (isString(url)) {
  34769. url = tryConvertUrlEncoding(url);
  34770. var absoluteUrl = createValidAbsoluteUrl(url, docBaseUrl);
  34771. if (absoluteUrl) {
  34772. resultObj.url = absoluteUrl.href;
  34773. }
  34774. resultObj.unsafeUrl = url;
  34775. }
  34776. if (dest) {
  34777. if (isName(dest)) {
  34778. dest = dest.name;
  34779. }
  34780. if (isString(dest) || isArray(dest)) {
  34781. resultObj.dest = dest;
  34782. }
  34783. }
  34784. };
  34785. return Catalog;
  34786. }();
  34787. var XRef = function XRefClosure() {
  34788. function XRef(stream, pdfManager) {
  34789. this.stream = stream;
  34790. this.pdfManager = pdfManager;
  34791. this.entries = [];
  34792. this.xrefstms = Object.create(null);
  34793. this.cache = [];
  34794. this.stats = {
  34795. streamTypes: [],
  34796. fontTypes: []
  34797. };
  34798. }
  34799. XRef.prototype = {
  34800. setStartXRef: function XRef_setStartXRef(startXRef) {
  34801. this.startXRefQueue = [startXRef];
  34802. },
  34803. parse: function XRef_parse(recoveryMode) {
  34804. var trailerDict;
  34805. if (!recoveryMode) {
  34806. trailerDict = this.readXRef();
  34807. } else {
  34808. warn('Indexing all PDF objects');
  34809. trailerDict = this.indexObjects();
  34810. }
  34811. trailerDict.assignXref(this);
  34812. this.trailer = trailerDict;
  34813. var encrypt = trailerDict.get('Encrypt');
  34814. if (isDict(encrypt)) {
  34815. var ids = trailerDict.get('ID');
  34816. var fileId = ids && ids.length ? ids[0] : '';
  34817. encrypt.suppressEncryption = true;
  34818. this.encrypt = new CipherTransformFactory(encrypt, fileId, this.pdfManager.password);
  34819. }
  34820. if (!(this.root = trailerDict.get('Root'))) {
  34821. error('Invalid root reference');
  34822. }
  34823. },
  34824. processXRefTable: function XRef_processXRefTable(parser) {
  34825. if (!('tableState' in this)) {
  34826. this.tableState = {
  34827. entryNum: 0,
  34828. streamPos: parser.lexer.stream.pos,
  34829. parserBuf1: parser.buf1,
  34830. parserBuf2: parser.buf2
  34831. };
  34832. }
  34833. var obj = this.readXRefTable(parser);
  34834. if (!isCmd(obj, 'trailer')) {
  34835. error('Invalid XRef table: could not find trailer dictionary');
  34836. }
  34837. var dict = parser.getObj();
  34838. if (!isDict(dict) && dict.dict) {
  34839. dict = dict.dict;
  34840. }
  34841. if (!isDict(dict)) {
  34842. error('Invalid XRef table: could not parse trailer dictionary');
  34843. }
  34844. delete this.tableState;
  34845. return dict;
  34846. },
  34847. readXRefTable: function XRef_readXRefTable(parser) {
  34848. var stream = parser.lexer.stream;
  34849. var tableState = this.tableState;
  34850. stream.pos = tableState.streamPos;
  34851. parser.buf1 = tableState.parserBuf1;
  34852. parser.buf2 = tableState.parserBuf2;
  34853. var obj;
  34854. while (true) {
  34855. if (!('firstEntryNum' in tableState) || !('entryCount' in tableState)) {
  34856. if (isCmd(obj = parser.getObj(), 'trailer')) {
  34857. break;
  34858. }
  34859. tableState.firstEntryNum = obj;
  34860. tableState.entryCount = parser.getObj();
  34861. }
  34862. var first = tableState.firstEntryNum;
  34863. var count = tableState.entryCount;
  34864. if (!isInt(first) || !isInt(count)) {
  34865. error('Invalid XRef table: wrong types in subsection header');
  34866. }
  34867. for (var i = tableState.entryNum; i < count; i++) {
  34868. tableState.streamPos = stream.pos;
  34869. tableState.entryNum = i;
  34870. tableState.parserBuf1 = parser.buf1;
  34871. tableState.parserBuf2 = parser.buf2;
  34872. var entry = {};
  34873. entry.offset = parser.getObj();
  34874. entry.gen = parser.getObj();
  34875. var type = parser.getObj();
  34876. if (isCmd(type, 'f')) {
  34877. entry.free = true;
  34878. } else if (isCmd(type, 'n')) {
  34879. entry.uncompressed = true;
  34880. }
  34881. if (!isInt(entry.offset) || !isInt(entry.gen) || !(entry.free || entry.uncompressed)) {
  34882. error('Invalid entry in XRef subsection: ' + first + ', ' + count);
  34883. }
  34884. if (i === 0 && entry.free && first === 1) {
  34885. first = 0;
  34886. }
  34887. if (!this.entries[i + first]) {
  34888. this.entries[i + first] = entry;
  34889. }
  34890. }
  34891. tableState.entryNum = 0;
  34892. tableState.streamPos = stream.pos;
  34893. tableState.parserBuf1 = parser.buf1;
  34894. tableState.parserBuf2 = parser.buf2;
  34895. delete tableState.firstEntryNum;
  34896. delete tableState.entryCount;
  34897. }
  34898. if (this.entries[0] && !this.entries[0].free) {
  34899. error('Invalid XRef table: unexpected first object');
  34900. }
  34901. return obj;
  34902. },
  34903. processXRefStream: function XRef_processXRefStream(stream) {
  34904. if (!('streamState' in this)) {
  34905. var streamParameters = stream.dict;
  34906. var byteWidths = streamParameters.get('W');
  34907. var range = streamParameters.get('Index');
  34908. if (!range) {
  34909. range = [
  34910. 0,
  34911. streamParameters.get('Size')
  34912. ];
  34913. }
  34914. this.streamState = {
  34915. entryRanges: range,
  34916. byteWidths: byteWidths,
  34917. entryNum: 0,
  34918. streamPos: stream.pos
  34919. };
  34920. }
  34921. this.readXRefStream(stream);
  34922. delete this.streamState;
  34923. return stream.dict;
  34924. },
  34925. readXRefStream: function XRef_readXRefStream(stream) {
  34926. var i, j;
  34927. var streamState = this.streamState;
  34928. stream.pos = streamState.streamPos;
  34929. var byteWidths = streamState.byteWidths;
  34930. var typeFieldWidth = byteWidths[0];
  34931. var offsetFieldWidth = byteWidths[1];
  34932. var generationFieldWidth = byteWidths[2];
  34933. var entryRanges = streamState.entryRanges;
  34934. while (entryRanges.length > 0) {
  34935. var first = entryRanges[0];
  34936. var n = entryRanges[1];
  34937. if (!isInt(first) || !isInt(n)) {
  34938. error('Invalid XRef range fields: ' + first + ', ' + n);
  34939. }
  34940. if (!isInt(typeFieldWidth) || !isInt(offsetFieldWidth) || !isInt(generationFieldWidth)) {
  34941. error('Invalid XRef entry fields length: ' + first + ', ' + n);
  34942. }
  34943. for (i = streamState.entryNum; i < n; ++i) {
  34944. streamState.entryNum = i;
  34945. streamState.streamPos = stream.pos;
  34946. var type = 0, offset = 0, generation = 0;
  34947. for (j = 0; j < typeFieldWidth; ++j) {
  34948. type = type << 8 | stream.getByte();
  34949. }
  34950. if (typeFieldWidth === 0) {
  34951. type = 1;
  34952. }
  34953. for (j = 0; j < offsetFieldWidth; ++j) {
  34954. offset = offset << 8 | stream.getByte();
  34955. }
  34956. for (j = 0; j < generationFieldWidth; ++j) {
  34957. generation = generation << 8 | stream.getByte();
  34958. }
  34959. var entry = {};
  34960. entry.offset = offset;
  34961. entry.gen = generation;
  34962. switch (type) {
  34963. case 0:
  34964. entry.free = true;
  34965. break;
  34966. case 1:
  34967. entry.uncompressed = true;
  34968. break;
  34969. case 2:
  34970. break;
  34971. default:
  34972. error('Invalid XRef entry type: ' + type);
  34973. }
  34974. if (!this.entries[first + i]) {
  34975. this.entries[first + i] = entry;
  34976. }
  34977. }
  34978. streamState.entryNum = 0;
  34979. streamState.streamPos = stream.pos;
  34980. entryRanges.splice(0, 2);
  34981. }
  34982. },
  34983. indexObjects: function XRef_indexObjects() {
  34984. var TAB = 0x9, LF = 0xA, CR = 0xD, SPACE = 0x20;
  34985. var PERCENT = 0x25, LT = 0x3C;
  34986. function readToken(data, offset) {
  34987. var token = '', ch = data[offset];
  34988. while (ch !== LF && ch !== CR && ch !== LT) {
  34989. if (++offset >= data.length) {
  34990. break;
  34991. }
  34992. token += String.fromCharCode(ch);
  34993. ch = data[offset];
  34994. }
  34995. return token;
  34996. }
  34997. function skipUntil(data, offset, what) {
  34998. var length = what.length, dataLength = data.length;
  34999. var skipped = 0;
  35000. while (offset < dataLength) {
  35001. var i = 0;
  35002. while (i < length && data[offset + i] === what[i]) {
  35003. ++i;
  35004. }
  35005. if (i >= length) {
  35006. break;
  35007. }
  35008. offset++;
  35009. skipped++;
  35010. }
  35011. return skipped;
  35012. }
  35013. var objRegExp = /^(\d+)\s+(\d+)\s+obj\b/;
  35014. var trailerBytes = new Uint8Array([
  35015. 116,
  35016. 114,
  35017. 97,
  35018. 105,
  35019. 108,
  35020. 101,
  35021. 114
  35022. ]);
  35023. var startxrefBytes = new Uint8Array([
  35024. 115,
  35025. 116,
  35026. 97,
  35027. 114,
  35028. 116,
  35029. 120,
  35030. 114,
  35031. 101,
  35032. 102
  35033. ]);
  35034. var endobjBytes = new Uint8Array([
  35035. 101,
  35036. 110,
  35037. 100,
  35038. 111,
  35039. 98,
  35040. 106
  35041. ]);
  35042. var xrefBytes = new Uint8Array([
  35043. 47,
  35044. 88,
  35045. 82,
  35046. 101,
  35047. 102
  35048. ]);
  35049. this.entries.length = 0;
  35050. var stream = this.stream;
  35051. stream.pos = 0;
  35052. var buffer = stream.getBytes();
  35053. var position = stream.start, length = buffer.length;
  35054. var trailers = [], xrefStms = [];
  35055. while (position < length) {
  35056. var ch = buffer[position];
  35057. if (ch === TAB || ch === LF || ch === CR || ch === SPACE) {
  35058. ++position;
  35059. continue;
  35060. }
  35061. if (ch === PERCENT) {
  35062. do {
  35063. ++position;
  35064. if (position >= length) {
  35065. break;
  35066. }
  35067. ch = buffer[position];
  35068. } while (ch !== LF && ch !== CR);
  35069. continue;
  35070. }
  35071. var token = readToken(buffer, position);
  35072. var m;
  35073. if (token.indexOf('xref') === 0 && (token.length === 4 || /\s/.test(token[4]))) {
  35074. position += skipUntil(buffer, position, trailerBytes);
  35075. trailers.push(position);
  35076. position += skipUntil(buffer, position, startxrefBytes);
  35077. } else if (m = objRegExp.exec(token)) {
  35078. if (typeof this.entries[m[1]] === 'undefined') {
  35079. this.entries[m[1]] = {
  35080. offset: position - stream.start,
  35081. gen: m[2] | 0,
  35082. uncompressed: true
  35083. };
  35084. }
  35085. var contentLength = skipUntil(buffer, position, endobjBytes) + 7;
  35086. var content = buffer.subarray(position, position + contentLength);
  35087. var xrefTagOffset = skipUntil(content, 0, xrefBytes);
  35088. if (xrefTagOffset < contentLength && content[xrefTagOffset + 5] < 64) {
  35089. xrefStms.push(position - stream.start);
  35090. this.xrefstms[position - stream.start] = 1;
  35091. }
  35092. position += contentLength;
  35093. } else if (token.indexOf('trailer') === 0 && (token.length === 7 || /\s/.test(token[7]))) {
  35094. trailers.push(position);
  35095. position += skipUntil(buffer, position, startxrefBytes);
  35096. } else {
  35097. position += token.length + 1;
  35098. }
  35099. }
  35100. var i, ii;
  35101. for (i = 0, ii = xrefStms.length; i < ii; ++i) {
  35102. this.startXRefQueue.push(xrefStms[i]);
  35103. this.readXRef(true);
  35104. }
  35105. var dict;
  35106. for (i = 0, ii = trailers.length; i < ii; ++i) {
  35107. stream.pos = trailers[i];
  35108. var parser = new Parser(new Lexer(stream), true, this, true);
  35109. var obj = parser.getObj();
  35110. if (!isCmd(obj, 'trailer')) {
  35111. continue;
  35112. }
  35113. dict = parser.getObj();
  35114. if (!isDict(dict)) {
  35115. continue;
  35116. }
  35117. if (dict.has('ID')) {
  35118. return dict;
  35119. }
  35120. }
  35121. if (dict) {
  35122. return dict;
  35123. }
  35124. throw new InvalidPDFException('Invalid PDF structure');
  35125. },
  35126. readXRef: function XRef_readXRef(recoveryMode) {
  35127. var stream = this.stream;
  35128. try {
  35129. while (this.startXRefQueue.length) {
  35130. var startXRef = this.startXRefQueue[0];
  35131. stream.pos = startXRef + stream.start;
  35132. var parser = new Parser(new Lexer(stream), true, this);
  35133. var obj = parser.getObj();
  35134. var dict;
  35135. if (isCmd(obj, 'xref')) {
  35136. dict = this.processXRefTable(parser);
  35137. if (!this.topDict) {
  35138. this.topDict = dict;
  35139. }
  35140. obj = dict.get('XRefStm');
  35141. if (isInt(obj)) {
  35142. var pos = obj;
  35143. if (!(pos in this.xrefstms)) {
  35144. this.xrefstms[pos] = 1;
  35145. this.startXRefQueue.push(pos);
  35146. }
  35147. }
  35148. } else if (isInt(obj)) {
  35149. if (!isInt(parser.getObj()) || !isCmd(parser.getObj(), 'obj') || !isStream(obj = parser.getObj())) {
  35150. error('Invalid XRef stream');
  35151. }
  35152. dict = this.processXRefStream(obj);
  35153. if (!this.topDict) {
  35154. this.topDict = dict;
  35155. }
  35156. if (!dict) {
  35157. error('Failed to read XRef stream');
  35158. }
  35159. } else {
  35160. error('Invalid XRef stream header');
  35161. }
  35162. obj = dict.get('Prev');
  35163. if (isInt(obj)) {
  35164. this.startXRefQueue.push(obj);
  35165. } else if (isRef(obj)) {
  35166. this.startXRefQueue.push(obj.num);
  35167. }
  35168. this.startXRefQueue.shift();
  35169. }
  35170. return this.topDict;
  35171. } catch (e) {
  35172. if (e instanceof MissingDataException) {
  35173. throw e;
  35174. }
  35175. info('(while reading XRef): ' + e);
  35176. }
  35177. if (recoveryMode) {
  35178. return;
  35179. }
  35180. throw new XRefParseException();
  35181. },
  35182. getEntry: function XRef_getEntry(i) {
  35183. var xrefEntry = this.entries[i];
  35184. if (xrefEntry && !xrefEntry.free && xrefEntry.offset) {
  35185. return xrefEntry;
  35186. }
  35187. return null;
  35188. },
  35189. fetchIfRef: function XRef_fetchIfRef(obj, suppressEncryption) {
  35190. if (!isRef(obj)) {
  35191. return obj;
  35192. }
  35193. return this.fetch(obj, suppressEncryption);
  35194. },
  35195. fetch: function XRef_fetch(ref, suppressEncryption) {
  35196. assert(isRef(ref), 'ref object is not a reference');
  35197. var num = ref.num;
  35198. if (num in this.cache) {
  35199. var cacheEntry = this.cache[num];
  35200. return cacheEntry;
  35201. }
  35202. var xrefEntry = this.getEntry(num);
  35203. if (xrefEntry === null) {
  35204. return this.cache[num] = null;
  35205. }
  35206. if (xrefEntry.uncompressed) {
  35207. xrefEntry = this.fetchUncompressed(ref, xrefEntry, suppressEncryption);
  35208. } else {
  35209. xrefEntry = this.fetchCompressed(xrefEntry, suppressEncryption);
  35210. }
  35211. if (isDict(xrefEntry)) {
  35212. xrefEntry.objId = ref.toString();
  35213. } else if (isStream(xrefEntry)) {
  35214. xrefEntry.dict.objId = ref.toString();
  35215. }
  35216. return xrefEntry;
  35217. },
  35218. fetchUncompressed: function XRef_fetchUncompressed(ref, xrefEntry, suppressEncryption) {
  35219. var gen = ref.gen;
  35220. var num = ref.num;
  35221. if (xrefEntry.gen !== gen) {
  35222. error('inconsistent generation in XRef');
  35223. }
  35224. var stream = this.stream.makeSubStream(xrefEntry.offset + this.stream.start);
  35225. var parser = new Parser(new Lexer(stream), true, this);
  35226. var obj1 = parser.getObj();
  35227. var obj2 = parser.getObj();
  35228. var obj3 = parser.getObj();
  35229. if (!isInt(obj1) || parseInt(obj1, 10) !== num || !isInt(obj2) || parseInt(obj2, 10) !== gen || !isCmd(obj3)) {
  35230. error('bad XRef entry');
  35231. }
  35232. if (!isCmd(obj3, 'obj')) {
  35233. if (obj3.cmd.indexOf('obj') === 0) {
  35234. num = parseInt(obj3.cmd.substring(3), 10);
  35235. if (!isNaN(num)) {
  35236. return num;
  35237. }
  35238. }
  35239. error('bad XRef entry');
  35240. }
  35241. if (this.encrypt && !suppressEncryption) {
  35242. xrefEntry = parser.getObj(this.encrypt.createCipherTransform(num, gen));
  35243. } else {
  35244. xrefEntry = parser.getObj();
  35245. }
  35246. if (!isStream(xrefEntry)) {
  35247. this.cache[num] = xrefEntry;
  35248. }
  35249. return xrefEntry;
  35250. },
  35251. fetchCompressed: function XRef_fetchCompressed(xrefEntry, suppressEncryption) {
  35252. var tableOffset = xrefEntry.offset;
  35253. var stream = this.fetch(new Ref(tableOffset, 0));
  35254. if (!isStream(stream)) {
  35255. error('bad ObjStm stream');
  35256. }
  35257. var first = stream.dict.get('First');
  35258. var n = stream.dict.get('N');
  35259. if (!isInt(first) || !isInt(n)) {
  35260. error('invalid first and n parameters for ObjStm stream');
  35261. }
  35262. var parser = new Parser(new Lexer(stream), false, this);
  35263. parser.allowStreams = true;
  35264. var i, entries = [], num, nums = [];
  35265. for (i = 0; i < n; ++i) {
  35266. num = parser.getObj();
  35267. if (!isInt(num)) {
  35268. error('invalid object number in the ObjStm stream: ' + num);
  35269. }
  35270. nums.push(num);
  35271. var offset = parser.getObj();
  35272. if (!isInt(offset)) {
  35273. error('invalid object offset in the ObjStm stream: ' + offset);
  35274. }
  35275. }
  35276. for (i = 0; i < n; ++i) {
  35277. entries.push(parser.getObj());
  35278. if (isCmd(parser.buf1, 'endobj')) {
  35279. parser.shift();
  35280. }
  35281. num = nums[i];
  35282. var entry = this.entries[num];
  35283. if (entry && entry.offset === tableOffset && entry.gen === i) {
  35284. this.cache[num] = entries[i];
  35285. }
  35286. }
  35287. xrefEntry = entries[xrefEntry.gen];
  35288. if (xrefEntry === undefined) {
  35289. error('bad XRef entry for compressed object');
  35290. }
  35291. return xrefEntry;
  35292. },
  35293. fetchIfRefAsync: function XRef_fetchIfRefAsync(obj, suppressEncryption) {
  35294. if (!isRef(obj)) {
  35295. return Promise.resolve(obj);
  35296. }
  35297. return this.fetchAsync(obj, suppressEncryption);
  35298. },
  35299. fetchAsync: function XRef_fetchAsync(ref, suppressEncryption) {
  35300. var streamManager = this.stream.manager;
  35301. var xref = this;
  35302. return new Promise(function tryFetch(resolve, reject) {
  35303. try {
  35304. resolve(xref.fetch(ref, suppressEncryption));
  35305. } catch (e) {
  35306. if (e instanceof MissingDataException) {
  35307. streamManager.requestRange(e.begin, e.end).then(function () {
  35308. tryFetch(resolve, reject);
  35309. }, reject);
  35310. return;
  35311. }
  35312. reject(e);
  35313. }
  35314. });
  35315. },
  35316. getCatalogObj: function XRef_getCatalogObj() {
  35317. return this.root;
  35318. }
  35319. };
  35320. return XRef;
  35321. }();
  35322. var NameOrNumberTree = function NameOrNumberTreeClosure() {
  35323. function NameOrNumberTree(root, xref) {
  35324. throw new Error('Cannot initialize NameOrNumberTree.');
  35325. }
  35326. NameOrNumberTree.prototype = {
  35327. getAll: function NameOrNumberTree_getAll() {
  35328. var dict = Object.create(null);
  35329. if (!this.root) {
  35330. return dict;
  35331. }
  35332. var xref = this.xref;
  35333. var processed = new RefSet();
  35334. processed.put(this.root);
  35335. var queue = [this.root];
  35336. while (queue.length > 0) {
  35337. var i, n;
  35338. var obj = xref.fetchIfRef(queue.shift());
  35339. if (!isDict(obj)) {
  35340. continue;
  35341. }
  35342. if (obj.has('Kids')) {
  35343. var kids = obj.get('Kids');
  35344. for (i = 0, n = kids.length; i < n; i++) {
  35345. var kid = kids[i];
  35346. assert(!processed.has(kid), 'Duplicate entry in "' + this._type + '" tree.');
  35347. queue.push(kid);
  35348. processed.put(kid);
  35349. }
  35350. continue;
  35351. }
  35352. var entries = obj.get(this._type);
  35353. if (isArray(entries)) {
  35354. for (i = 0, n = entries.length; i < n; i += 2) {
  35355. dict[xref.fetchIfRef(entries[i])] = xref.fetchIfRef(entries[i + 1]);
  35356. }
  35357. }
  35358. }
  35359. return dict;
  35360. },
  35361. get: function NameOrNumberTree_get(key) {
  35362. if (!this.root) {
  35363. return null;
  35364. }
  35365. var xref = this.xref;
  35366. var kidsOrEntries = xref.fetchIfRef(this.root);
  35367. var loopCount = 0;
  35368. var MAX_LEVELS = 10;
  35369. var l, r, m;
  35370. while (kidsOrEntries.has('Kids')) {
  35371. if (++loopCount > MAX_LEVELS) {
  35372. warn('Search depth limit reached for "' + this._type + '" tree.');
  35373. return null;
  35374. }
  35375. var kids = kidsOrEntries.get('Kids');
  35376. if (!isArray(kids)) {
  35377. return null;
  35378. }
  35379. l = 0;
  35380. r = kids.length - 1;
  35381. while (l <= r) {
  35382. m = l + r >> 1;
  35383. var kid = xref.fetchIfRef(kids[m]);
  35384. var limits = kid.get('Limits');
  35385. if (key < xref.fetchIfRef(limits[0])) {
  35386. r = m - 1;
  35387. } else if (key > xref.fetchIfRef(limits[1])) {
  35388. l = m + 1;
  35389. } else {
  35390. kidsOrEntries = xref.fetchIfRef(kids[m]);
  35391. break;
  35392. }
  35393. }
  35394. if (l > r) {
  35395. return null;
  35396. }
  35397. }
  35398. var entries = kidsOrEntries.get(this._type);
  35399. if (isArray(entries)) {
  35400. l = 0;
  35401. r = entries.length - 2;
  35402. while (l <= r) {
  35403. m = l + r & ~1;
  35404. var currentKey = xref.fetchIfRef(entries[m]);
  35405. if (key < currentKey) {
  35406. r = m - 2;
  35407. } else if (key > currentKey) {
  35408. l = m + 2;
  35409. } else {
  35410. return xref.fetchIfRef(entries[m + 1]);
  35411. }
  35412. }
  35413. }
  35414. return null;
  35415. }
  35416. };
  35417. return NameOrNumberTree;
  35418. }();
  35419. var NameTree = function NameTreeClosure() {
  35420. function NameTree(root, xref) {
  35421. this.root = root;
  35422. this.xref = xref;
  35423. this._type = 'Names';
  35424. }
  35425. Util.inherit(NameTree, NameOrNumberTree, {});
  35426. return NameTree;
  35427. }();
  35428. var NumberTree = function NumberTreeClosure() {
  35429. function NumberTree(root, xref) {
  35430. this.root = root;
  35431. this.xref = xref;
  35432. this._type = 'Nums';
  35433. }
  35434. Util.inherit(NumberTree, NameOrNumberTree, {});
  35435. return NumberTree;
  35436. }();
  35437. var FileSpec = function FileSpecClosure() {
  35438. function FileSpec(root, xref) {
  35439. if (!root || !isDict(root)) {
  35440. return;
  35441. }
  35442. this.xref = xref;
  35443. this.root = root;
  35444. if (root.has('FS')) {
  35445. this.fs = root.get('FS');
  35446. }
  35447. this.description = root.has('Desc') ? stringToPDFString(root.get('Desc')) : '';
  35448. if (root.has('RF')) {
  35449. warn('Related file specifications are not supported');
  35450. }
  35451. this.contentAvailable = true;
  35452. if (!root.has('EF')) {
  35453. this.contentAvailable = false;
  35454. warn('Non-embedded file specifications are not supported');
  35455. }
  35456. }
  35457. function pickPlatformItem(dict) {
  35458. if (dict.has('UF')) {
  35459. return dict.get('UF');
  35460. } else if (dict.has('F')) {
  35461. return dict.get('F');
  35462. } else if (dict.has('Unix')) {
  35463. return dict.get('Unix');
  35464. } else if (dict.has('Mac')) {
  35465. return dict.get('Mac');
  35466. } else if (dict.has('DOS')) {
  35467. return dict.get('DOS');
  35468. }
  35469. return null;
  35470. }
  35471. FileSpec.prototype = {
  35472. get filename() {
  35473. if (!this._filename && this.root) {
  35474. var filename = pickPlatformItem(this.root) || 'unnamed';
  35475. this._filename = stringToPDFString(filename).replace(/\\\\/g, '\\').replace(/\\\//g, '/').replace(/\\/g, '/');
  35476. }
  35477. return this._filename;
  35478. },
  35479. get content() {
  35480. if (!this.contentAvailable) {
  35481. return null;
  35482. }
  35483. if (!this.contentRef && this.root) {
  35484. this.contentRef = pickPlatformItem(this.root.get('EF'));
  35485. }
  35486. var content = null;
  35487. if (this.contentRef) {
  35488. var xref = this.xref;
  35489. var fileObj = xref.fetchIfRef(this.contentRef);
  35490. if (fileObj && isStream(fileObj)) {
  35491. content = fileObj.getBytes();
  35492. } else {
  35493. warn('Embedded file specification points to non-existing/invalid ' + 'content');
  35494. }
  35495. } else {
  35496. warn('Embedded file specification does not have a content');
  35497. }
  35498. return content;
  35499. },
  35500. get serializable() {
  35501. return {
  35502. filename: this.filename,
  35503. content: this.content
  35504. };
  35505. }
  35506. };
  35507. return FileSpec;
  35508. }();
  35509. var ObjectLoader = function () {
  35510. function mayHaveChildren(value) {
  35511. return isRef(value) || isDict(value) || isArray(value) || isStream(value);
  35512. }
  35513. function addChildren(node, nodesToVisit) {
  35514. var value;
  35515. if (isDict(node) || isStream(node)) {
  35516. var map;
  35517. if (isDict(node)) {
  35518. map = node.map;
  35519. } else {
  35520. map = node.dict.map;
  35521. }
  35522. for (var key in map) {
  35523. value = map[key];
  35524. if (mayHaveChildren(value)) {
  35525. nodesToVisit.push(value);
  35526. }
  35527. }
  35528. } else if (isArray(node)) {
  35529. for (var i = 0, ii = node.length; i < ii; i++) {
  35530. value = node[i];
  35531. if (mayHaveChildren(value)) {
  35532. nodesToVisit.push(value);
  35533. }
  35534. }
  35535. }
  35536. }
  35537. function ObjectLoader(obj, keys, xref) {
  35538. this.obj = obj;
  35539. this.keys = keys;
  35540. this.xref = xref;
  35541. this.refSet = null;
  35542. this.capability = null;
  35543. }
  35544. ObjectLoader.prototype = {
  35545. load: function ObjectLoader_load() {
  35546. var keys = this.keys;
  35547. this.capability = createPromiseCapability();
  35548. if (!(this.xref.stream instanceof ChunkedStream) || this.xref.stream.getMissingChunks().length === 0) {
  35549. this.capability.resolve();
  35550. return this.capability.promise;
  35551. }
  35552. this.refSet = new RefSet();
  35553. var nodesToVisit = [];
  35554. for (var i = 0; i < keys.length; i++) {
  35555. nodesToVisit.push(this.obj[keys[i]]);
  35556. }
  35557. this._walk(nodesToVisit);
  35558. return this.capability.promise;
  35559. },
  35560. _walk: function ObjectLoader_walk(nodesToVisit) {
  35561. var nodesToRevisit = [];
  35562. var pendingRequests = [];
  35563. while (nodesToVisit.length) {
  35564. var currentNode = nodesToVisit.pop();
  35565. if (isRef(currentNode)) {
  35566. if (this.refSet.has(currentNode)) {
  35567. continue;
  35568. }
  35569. try {
  35570. var ref = currentNode;
  35571. this.refSet.put(ref);
  35572. currentNode = this.xref.fetch(currentNode);
  35573. } catch (e) {
  35574. if (!(e instanceof MissingDataException)) {
  35575. throw e;
  35576. }
  35577. nodesToRevisit.push(currentNode);
  35578. pendingRequests.push({
  35579. begin: e.begin,
  35580. end: e.end
  35581. });
  35582. }
  35583. }
  35584. if (currentNode && currentNode.getBaseStreams) {
  35585. var baseStreams = currentNode.getBaseStreams();
  35586. var foundMissingData = false;
  35587. for (var i = 0; i < baseStreams.length; i++) {
  35588. var stream = baseStreams[i];
  35589. if (stream.getMissingChunks && stream.getMissingChunks().length) {
  35590. foundMissingData = true;
  35591. pendingRequests.push({
  35592. begin: stream.start,
  35593. end: stream.end
  35594. });
  35595. }
  35596. }
  35597. if (foundMissingData) {
  35598. nodesToRevisit.push(currentNode);
  35599. }
  35600. }
  35601. addChildren(currentNode, nodesToVisit);
  35602. }
  35603. if (pendingRequests.length) {
  35604. this.xref.stream.manager.requestRanges(pendingRequests).then(function pendingRequestCallback() {
  35605. nodesToVisit = nodesToRevisit;
  35606. for (var i = 0; i < nodesToRevisit.length; i++) {
  35607. var node = nodesToRevisit[i];
  35608. if (isRef(node)) {
  35609. this.refSet.remove(node);
  35610. }
  35611. }
  35612. this._walk(nodesToVisit);
  35613. }.bind(this), this.capability.reject);
  35614. return;
  35615. }
  35616. this.refSet = null;
  35617. this.capability.resolve();
  35618. }
  35619. };
  35620. return ObjectLoader;
  35621. }();
  35622. exports.Catalog = Catalog;
  35623. exports.ObjectLoader = ObjectLoader;
  35624. exports.XRef = XRef;
  35625. exports.FileSpec = FileSpec;
  35626. /***/ }),
  35627. /* 20 */
  35628. /***/ (function(module, exports, __w_pdfjs_require__) {
  35629. "use strict";
  35630. var sharedUtil = __w_pdfjs_require__(0);
  35631. var getLookupTableFactory = sharedUtil.getLookupTableFactory;
  35632. var getStdFontMap = getLookupTableFactory(function (t) {
  35633. t['ArialNarrow'] = 'Helvetica';
  35634. t['ArialNarrow-Bold'] = 'Helvetica-Bold';
  35635. t['ArialNarrow-BoldItalic'] = 'Helvetica-BoldOblique';
  35636. t['ArialNarrow-Italic'] = 'Helvetica-Oblique';
  35637. t['ArialBlack'] = 'Helvetica';
  35638. t['ArialBlack-Bold'] = 'Helvetica-Bold';
  35639. t['ArialBlack-BoldItalic'] = 'Helvetica-BoldOblique';
  35640. t['ArialBlack-Italic'] = 'Helvetica-Oblique';
  35641. t['Arial-Black'] = 'Helvetica';
  35642. t['Arial-Black-Bold'] = 'Helvetica-Bold';
  35643. t['Arial-Black-BoldItalic'] = 'Helvetica-BoldOblique';
  35644. t['Arial-Black-Italic'] = 'Helvetica-Oblique';
  35645. t['Arial'] = 'Helvetica';
  35646. t['Arial-Bold'] = 'Helvetica-Bold';
  35647. t['Arial-BoldItalic'] = 'Helvetica-BoldOblique';
  35648. t['Arial-Italic'] = 'Helvetica-Oblique';
  35649. t['Arial-BoldItalicMT'] = 'Helvetica-BoldOblique';
  35650. t['Arial-BoldMT'] = 'Helvetica-Bold';
  35651. t['Arial-ItalicMT'] = 'Helvetica-Oblique';
  35652. t['ArialMT'] = 'Helvetica';
  35653. t['Courier-Bold'] = 'Courier-Bold';
  35654. t['Courier-BoldItalic'] = 'Courier-BoldOblique';
  35655. t['Courier-Italic'] = 'Courier-Oblique';
  35656. t['CourierNew'] = 'Courier';
  35657. t['CourierNew-Bold'] = 'Courier-Bold';
  35658. t['CourierNew-BoldItalic'] = 'Courier-BoldOblique';
  35659. t['CourierNew-Italic'] = 'Courier-Oblique';
  35660. t['CourierNewPS-BoldItalicMT'] = 'Courier-BoldOblique';
  35661. t['CourierNewPS-BoldMT'] = 'Courier-Bold';
  35662. t['CourierNewPS-ItalicMT'] = 'Courier-Oblique';
  35663. t['CourierNewPSMT'] = 'Courier';
  35664. t['Helvetica'] = 'Helvetica';
  35665. t['Helvetica-Bold'] = 'Helvetica-Bold';
  35666. t['Helvetica-BoldItalic'] = 'Helvetica-BoldOblique';
  35667. t['Helvetica-BoldOblique'] = 'Helvetica-BoldOblique';
  35668. t['Helvetica-Italic'] = 'Helvetica-Oblique';
  35669. t['Helvetica-Oblique'] = 'Helvetica-Oblique';
  35670. t['Symbol-Bold'] = 'Symbol';
  35671. t['Symbol-BoldItalic'] = 'Symbol';
  35672. t['Symbol-Italic'] = 'Symbol';
  35673. t['TimesNewRoman'] = 'Times-Roman';
  35674. t['TimesNewRoman-Bold'] = 'Times-Bold';
  35675. t['TimesNewRoman-BoldItalic'] = 'Times-BoldItalic';
  35676. t['TimesNewRoman-Italic'] = 'Times-Italic';
  35677. t['TimesNewRomanPS'] = 'Times-Roman';
  35678. t['TimesNewRomanPS-Bold'] = 'Times-Bold';
  35679. t['TimesNewRomanPS-BoldItalic'] = 'Times-BoldItalic';
  35680. t['TimesNewRomanPS-BoldItalicMT'] = 'Times-BoldItalic';
  35681. t['TimesNewRomanPS-BoldMT'] = 'Times-Bold';
  35682. t['TimesNewRomanPS-Italic'] = 'Times-Italic';
  35683. t['TimesNewRomanPS-ItalicMT'] = 'Times-Italic';
  35684. t['TimesNewRomanPSMT'] = 'Times-Roman';
  35685. t['TimesNewRomanPSMT-Bold'] = 'Times-Bold';
  35686. t['TimesNewRomanPSMT-BoldItalic'] = 'Times-BoldItalic';
  35687. t['TimesNewRomanPSMT-Italic'] = 'Times-Italic';
  35688. });
  35689. var getNonStdFontMap = getLookupTableFactory(function (t) {
  35690. t['CenturyGothic'] = 'Helvetica';
  35691. t['CenturyGothic-Bold'] = 'Helvetica-Bold';
  35692. t['CenturyGothic-BoldItalic'] = 'Helvetica-BoldOblique';
  35693. t['CenturyGothic-Italic'] = 'Helvetica-Oblique';
  35694. t['ComicSansMS'] = 'Comic Sans MS';
  35695. t['ComicSansMS-Bold'] = 'Comic Sans MS-Bold';
  35696. t['ComicSansMS-BoldItalic'] = 'Comic Sans MS-BoldItalic';
  35697. t['ComicSansMS-Italic'] = 'Comic Sans MS-Italic';
  35698. t['LucidaConsole'] = 'Courier';
  35699. t['LucidaConsole-Bold'] = 'Courier-Bold';
  35700. t['LucidaConsole-BoldItalic'] = 'Courier-BoldOblique';
  35701. t['LucidaConsole-Italic'] = 'Courier-Oblique';
  35702. t['MS-Gothic'] = 'MS Gothic';
  35703. t['MS-Gothic-Bold'] = 'MS Gothic-Bold';
  35704. t['MS-Gothic-BoldItalic'] = 'MS Gothic-BoldItalic';
  35705. t['MS-Gothic-Italic'] = 'MS Gothic-Italic';
  35706. t['MS-Mincho'] = 'MS Mincho';
  35707. t['MS-Mincho-Bold'] = 'MS Mincho-Bold';
  35708. t['MS-Mincho-BoldItalic'] = 'MS Mincho-BoldItalic';
  35709. t['MS-Mincho-Italic'] = 'MS Mincho-Italic';
  35710. t['MS-PGothic'] = 'MS PGothic';
  35711. t['MS-PGothic-Bold'] = 'MS PGothic-Bold';
  35712. t['MS-PGothic-BoldItalic'] = 'MS PGothic-BoldItalic';
  35713. t['MS-PGothic-Italic'] = 'MS PGothic-Italic';
  35714. t['MS-PMincho'] = 'MS PMincho';
  35715. t['MS-PMincho-Bold'] = 'MS PMincho-Bold';
  35716. t['MS-PMincho-BoldItalic'] = 'MS PMincho-BoldItalic';
  35717. t['MS-PMincho-Italic'] = 'MS PMincho-Italic';
  35718. t['NuptialScript'] = 'Times-Italic';
  35719. t['Wingdings'] = 'ZapfDingbats';
  35720. });
  35721. var getSerifFonts = getLookupTableFactory(function (t) {
  35722. t['Adobe Jenson'] = true;
  35723. t['Adobe Text'] = true;
  35724. t['Albertus'] = true;
  35725. t['Aldus'] = true;
  35726. t['Alexandria'] = true;
  35727. t['Algerian'] = true;
  35728. t['American Typewriter'] = true;
  35729. t['Antiqua'] = true;
  35730. t['Apex'] = true;
  35731. t['Arno'] = true;
  35732. t['Aster'] = true;
  35733. t['Aurora'] = true;
  35734. t['Baskerville'] = true;
  35735. t['Bell'] = true;
  35736. t['Bembo'] = true;
  35737. t['Bembo Schoolbook'] = true;
  35738. t['Benguiat'] = true;
  35739. t['Berkeley Old Style'] = true;
  35740. t['Bernhard Modern'] = true;
  35741. t['Berthold City'] = true;
  35742. t['Bodoni'] = true;
  35743. t['Bauer Bodoni'] = true;
  35744. t['Book Antiqua'] = true;
  35745. t['Bookman'] = true;
  35746. t['Bordeaux Roman'] = true;
  35747. t['Californian FB'] = true;
  35748. t['Calisto'] = true;
  35749. t['Calvert'] = true;
  35750. t['Capitals'] = true;
  35751. t['Cambria'] = true;
  35752. t['Cartier'] = true;
  35753. t['Caslon'] = true;
  35754. t['Catull'] = true;
  35755. t['Centaur'] = true;
  35756. t['Century Old Style'] = true;
  35757. t['Century Schoolbook'] = true;
  35758. t['Chaparral'] = true;
  35759. t['Charis SIL'] = true;
  35760. t['Cheltenham'] = true;
  35761. t['Cholla Slab'] = true;
  35762. t['Clarendon'] = true;
  35763. t['Clearface'] = true;
  35764. t['Cochin'] = true;
  35765. t['Colonna'] = true;
  35766. t['Computer Modern'] = true;
  35767. t['Concrete Roman'] = true;
  35768. t['Constantia'] = true;
  35769. t['Cooper Black'] = true;
  35770. t['Corona'] = true;
  35771. t['Ecotype'] = true;
  35772. t['Egyptienne'] = true;
  35773. t['Elephant'] = true;
  35774. t['Excelsior'] = true;
  35775. t['Fairfield'] = true;
  35776. t['FF Scala'] = true;
  35777. t['Folkard'] = true;
  35778. t['Footlight'] = true;
  35779. t['FreeSerif'] = true;
  35780. t['Friz Quadrata'] = true;
  35781. t['Garamond'] = true;
  35782. t['Gentium'] = true;
  35783. t['Georgia'] = true;
  35784. t['Gloucester'] = true;
  35785. t['Goudy Old Style'] = true;
  35786. t['Goudy Schoolbook'] = true;
  35787. t['Goudy Pro Font'] = true;
  35788. t['Granjon'] = true;
  35789. t['Guardian Egyptian'] = true;
  35790. t['Heather'] = true;
  35791. t['Hercules'] = true;
  35792. t['High Tower Text'] = true;
  35793. t['Hiroshige'] = true;
  35794. t['Hoefler Text'] = true;
  35795. t['Humana Serif'] = true;
  35796. t['Imprint'] = true;
  35797. t['Ionic No. 5'] = true;
  35798. t['Janson'] = true;
  35799. t['Joanna'] = true;
  35800. t['Korinna'] = true;
  35801. t['Lexicon'] = true;
  35802. t['Liberation Serif'] = true;
  35803. t['Linux Libertine'] = true;
  35804. t['Literaturnaya'] = true;
  35805. t['Lucida'] = true;
  35806. t['Lucida Bright'] = true;
  35807. t['Melior'] = true;
  35808. t['Memphis'] = true;
  35809. t['Miller'] = true;
  35810. t['Minion'] = true;
  35811. t['Modern'] = true;
  35812. t['Mona Lisa'] = true;
  35813. t['Mrs Eaves'] = true;
  35814. t['MS Serif'] = true;
  35815. t['Museo Slab'] = true;
  35816. t['New York'] = true;
  35817. t['Nimbus Roman'] = true;
  35818. t['NPS Rawlinson Roadway'] = true;
  35819. t['NuptialScript'] = true;
  35820. t['Palatino'] = true;
  35821. t['Perpetua'] = true;
  35822. t['Plantin'] = true;
  35823. t['Plantin Schoolbook'] = true;
  35824. t['Playbill'] = true;
  35825. t['Poor Richard'] = true;
  35826. t['Rawlinson Roadway'] = true;
  35827. t['Renault'] = true;
  35828. t['Requiem'] = true;
  35829. t['Rockwell'] = true;
  35830. t['Roman'] = true;
  35831. t['Rotis Serif'] = true;
  35832. t['Sabon'] = true;
  35833. t['Scala'] = true;
  35834. t['Seagull'] = true;
  35835. t['Sistina'] = true;
  35836. t['Souvenir'] = true;
  35837. t['STIX'] = true;
  35838. t['Stone Informal'] = true;
  35839. t['Stone Serif'] = true;
  35840. t['Sylfaen'] = true;
  35841. t['Times'] = true;
  35842. t['Trajan'] = true;
  35843. t['Trinité'] = true;
  35844. t['Trump Mediaeval'] = true;
  35845. t['Utopia'] = true;
  35846. t['Vale Type'] = true;
  35847. t['Bitstream Vera'] = true;
  35848. t['Vera Serif'] = true;
  35849. t['Versailles'] = true;
  35850. t['Wanted'] = true;
  35851. t['Weiss'] = true;
  35852. t['Wide Latin'] = true;
  35853. t['Windsor'] = true;
  35854. t['XITS'] = true;
  35855. });
  35856. var getSymbolsFonts = getLookupTableFactory(function (t) {
  35857. t['Dingbats'] = true;
  35858. t['Symbol'] = true;
  35859. t['ZapfDingbats'] = true;
  35860. });
  35861. var getGlyphMapForStandardFonts = getLookupTableFactory(function (t) {
  35862. t[2] = 10;
  35863. t[3] = 32;
  35864. t[4] = 33;
  35865. t[5] = 34;
  35866. t[6] = 35;
  35867. t[7] = 36;
  35868. t[8] = 37;
  35869. t[9] = 38;
  35870. t[10] = 39;
  35871. t[11] = 40;
  35872. t[12] = 41;
  35873. t[13] = 42;
  35874. t[14] = 43;
  35875. t[15] = 44;
  35876. t[16] = 45;
  35877. t[17] = 46;
  35878. t[18] = 47;
  35879. t[19] = 48;
  35880. t[20] = 49;
  35881. t[21] = 50;
  35882. t[22] = 51;
  35883. t[23] = 52;
  35884. t[24] = 53;
  35885. t[25] = 54;
  35886. t[26] = 55;
  35887. t[27] = 56;
  35888. t[28] = 57;
  35889. t[29] = 58;
  35890. t[30] = 894;
  35891. t[31] = 60;
  35892. t[32] = 61;
  35893. t[33] = 62;
  35894. t[34] = 63;
  35895. t[35] = 64;
  35896. t[36] = 65;
  35897. t[37] = 66;
  35898. t[38] = 67;
  35899. t[39] = 68;
  35900. t[40] = 69;
  35901. t[41] = 70;
  35902. t[42] = 71;
  35903. t[43] = 72;
  35904. t[44] = 73;
  35905. t[45] = 74;
  35906. t[46] = 75;
  35907. t[47] = 76;
  35908. t[48] = 77;
  35909. t[49] = 78;
  35910. t[50] = 79;
  35911. t[51] = 80;
  35912. t[52] = 81;
  35913. t[53] = 82;
  35914. t[54] = 83;
  35915. t[55] = 84;
  35916. t[56] = 85;
  35917. t[57] = 86;
  35918. t[58] = 87;
  35919. t[59] = 88;
  35920. t[60] = 89;
  35921. t[61] = 90;
  35922. t[62] = 91;
  35923. t[63] = 92;
  35924. t[64] = 93;
  35925. t[65] = 94;
  35926. t[66] = 95;
  35927. t[67] = 96;
  35928. t[68] = 97;
  35929. t[69] = 98;
  35930. t[70] = 99;
  35931. t[71] = 100;
  35932. t[72] = 101;
  35933. t[73] = 102;
  35934. t[74] = 103;
  35935. t[75] = 104;
  35936. t[76] = 105;
  35937. t[77] = 106;
  35938. t[78] = 107;
  35939. t[79] = 108;
  35940. t[80] = 109;
  35941. t[81] = 110;
  35942. t[82] = 111;
  35943. t[83] = 112;
  35944. t[84] = 113;
  35945. t[85] = 114;
  35946. t[86] = 115;
  35947. t[87] = 116;
  35948. t[88] = 117;
  35949. t[89] = 118;
  35950. t[90] = 119;
  35951. t[91] = 120;
  35952. t[92] = 121;
  35953. t[93] = 122;
  35954. t[94] = 123;
  35955. t[95] = 124;
  35956. t[96] = 125;
  35957. t[97] = 126;
  35958. t[98] = 196;
  35959. t[99] = 197;
  35960. t[100] = 199;
  35961. t[101] = 201;
  35962. t[102] = 209;
  35963. t[103] = 214;
  35964. t[104] = 220;
  35965. t[105] = 225;
  35966. t[106] = 224;
  35967. t[107] = 226;
  35968. t[108] = 228;
  35969. t[109] = 227;
  35970. t[110] = 229;
  35971. t[111] = 231;
  35972. t[112] = 233;
  35973. t[113] = 232;
  35974. t[114] = 234;
  35975. t[115] = 235;
  35976. t[116] = 237;
  35977. t[117] = 236;
  35978. t[118] = 238;
  35979. t[119] = 239;
  35980. t[120] = 241;
  35981. t[121] = 243;
  35982. t[122] = 242;
  35983. t[123] = 244;
  35984. t[124] = 246;
  35985. t[125] = 245;
  35986. t[126] = 250;
  35987. t[127] = 249;
  35988. t[128] = 251;
  35989. t[129] = 252;
  35990. t[130] = 8224;
  35991. t[131] = 176;
  35992. t[132] = 162;
  35993. t[133] = 163;
  35994. t[134] = 167;
  35995. t[135] = 8226;
  35996. t[136] = 182;
  35997. t[137] = 223;
  35998. t[138] = 174;
  35999. t[139] = 169;
  36000. t[140] = 8482;
  36001. t[141] = 180;
  36002. t[142] = 168;
  36003. t[143] = 8800;
  36004. t[144] = 198;
  36005. t[145] = 216;
  36006. t[146] = 8734;
  36007. t[147] = 177;
  36008. t[148] = 8804;
  36009. t[149] = 8805;
  36010. t[150] = 165;
  36011. t[151] = 181;
  36012. t[152] = 8706;
  36013. t[153] = 8721;
  36014. t[154] = 8719;
  36015. t[156] = 8747;
  36016. t[157] = 170;
  36017. t[158] = 186;
  36018. t[159] = 8486;
  36019. t[160] = 230;
  36020. t[161] = 248;
  36021. t[162] = 191;
  36022. t[163] = 161;
  36023. t[164] = 172;
  36024. t[165] = 8730;
  36025. t[166] = 402;
  36026. t[167] = 8776;
  36027. t[168] = 8710;
  36028. t[169] = 171;
  36029. t[170] = 187;
  36030. t[171] = 8230;
  36031. t[210] = 218;
  36032. t[223] = 711;
  36033. t[224] = 321;
  36034. t[225] = 322;
  36035. t[227] = 353;
  36036. t[229] = 382;
  36037. t[234] = 253;
  36038. t[252] = 263;
  36039. t[253] = 268;
  36040. t[254] = 269;
  36041. t[258] = 258;
  36042. t[260] = 260;
  36043. t[261] = 261;
  36044. t[265] = 280;
  36045. t[266] = 281;
  36046. t[268] = 283;
  36047. t[269] = 313;
  36048. t[275] = 323;
  36049. t[276] = 324;
  36050. t[278] = 328;
  36051. t[284] = 345;
  36052. t[285] = 346;
  36053. t[286] = 347;
  36054. t[292] = 367;
  36055. t[295] = 377;
  36056. t[296] = 378;
  36057. t[298] = 380;
  36058. t[305] = 963;
  36059. t[306] = 964;
  36060. t[307] = 966;
  36061. t[308] = 8215;
  36062. t[309] = 8252;
  36063. t[310] = 8319;
  36064. t[311] = 8359;
  36065. t[312] = 8592;
  36066. t[313] = 8593;
  36067. t[337] = 9552;
  36068. t[493] = 1039;
  36069. t[494] = 1040;
  36070. t[705] = 1524;
  36071. t[706] = 8362;
  36072. t[710] = 64288;
  36073. t[711] = 64298;
  36074. t[759] = 1617;
  36075. t[761] = 1776;
  36076. t[763] = 1778;
  36077. t[775] = 1652;
  36078. t[777] = 1764;
  36079. t[778] = 1780;
  36080. t[779] = 1781;
  36081. t[780] = 1782;
  36082. t[782] = 771;
  36083. t[783] = 64726;
  36084. t[786] = 8363;
  36085. t[788] = 8532;
  36086. t[790] = 768;
  36087. t[791] = 769;
  36088. t[792] = 768;
  36089. t[795] = 803;
  36090. t[797] = 64336;
  36091. t[798] = 64337;
  36092. t[799] = 64342;
  36093. t[800] = 64343;
  36094. t[801] = 64344;
  36095. t[802] = 64345;
  36096. t[803] = 64362;
  36097. t[804] = 64363;
  36098. t[805] = 64364;
  36099. t[2424] = 7821;
  36100. t[2425] = 7822;
  36101. t[2426] = 7823;
  36102. t[2427] = 7824;
  36103. t[2428] = 7825;
  36104. t[2429] = 7826;
  36105. t[2430] = 7827;
  36106. t[2433] = 7682;
  36107. t[2678] = 8045;
  36108. t[2679] = 8046;
  36109. t[2830] = 1552;
  36110. t[2838] = 686;
  36111. t[2840] = 751;
  36112. t[2842] = 753;
  36113. t[2843] = 754;
  36114. t[2844] = 755;
  36115. t[2846] = 757;
  36116. t[2856] = 767;
  36117. t[2857] = 848;
  36118. t[2858] = 849;
  36119. t[2862] = 853;
  36120. t[2863] = 854;
  36121. t[2864] = 855;
  36122. t[2865] = 861;
  36123. t[2866] = 862;
  36124. t[2906] = 7460;
  36125. t[2908] = 7462;
  36126. t[2909] = 7463;
  36127. t[2910] = 7464;
  36128. t[2912] = 7466;
  36129. t[2913] = 7467;
  36130. t[2914] = 7468;
  36131. t[2916] = 7470;
  36132. t[2917] = 7471;
  36133. t[2918] = 7472;
  36134. t[2920] = 7474;
  36135. t[2921] = 7475;
  36136. t[2922] = 7476;
  36137. t[2924] = 7478;
  36138. t[2925] = 7479;
  36139. t[2926] = 7480;
  36140. t[2928] = 7482;
  36141. t[2929] = 7483;
  36142. t[2930] = 7484;
  36143. t[2932] = 7486;
  36144. t[2933] = 7487;
  36145. t[2934] = 7488;
  36146. t[2936] = 7490;
  36147. t[2937] = 7491;
  36148. t[2938] = 7492;
  36149. t[2940] = 7494;
  36150. t[2941] = 7495;
  36151. t[2942] = 7496;
  36152. t[2944] = 7498;
  36153. t[2946] = 7500;
  36154. t[2948] = 7502;
  36155. t[2950] = 7504;
  36156. t[2951] = 7505;
  36157. t[2952] = 7506;
  36158. t[2954] = 7508;
  36159. t[2955] = 7509;
  36160. t[2956] = 7510;
  36161. t[2958] = 7512;
  36162. t[2959] = 7513;
  36163. t[2960] = 7514;
  36164. t[2962] = 7516;
  36165. t[2963] = 7517;
  36166. t[2964] = 7518;
  36167. t[2966] = 7520;
  36168. t[2967] = 7521;
  36169. t[2968] = 7522;
  36170. t[2970] = 7524;
  36171. t[2971] = 7525;
  36172. t[2972] = 7526;
  36173. t[2974] = 7528;
  36174. t[2975] = 7529;
  36175. t[2976] = 7530;
  36176. t[2978] = 1537;
  36177. t[2979] = 1538;
  36178. t[2980] = 1539;
  36179. t[2982] = 1549;
  36180. t[2983] = 1551;
  36181. t[2984] = 1552;
  36182. t[2986] = 1554;
  36183. t[2987] = 1555;
  36184. t[2988] = 1556;
  36185. t[2990] = 1623;
  36186. t[2991] = 1624;
  36187. t[2995] = 1775;
  36188. t[2999] = 1791;
  36189. t[3002] = 64290;
  36190. t[3003] = 64291;
  36191. t[3004] = 64292;
  36192. t[3006] = 64294;
  36193. t[3007] = 64295;
  36194. t[3008] = 64296;
  36195. t[3011] = 1900;
  36196. t[3014] = 8223;
  36197. t[3015] = 8244;
  36198. t[3017] = 7532;
  36199. t[3018] = 7533;
  36200. t[3019] = 7534;
  36201. t[3075] = 7590;
  36202. t[3076] = 7591;
  36203. t[3079] = 7594;
  36204. t[3080] = 7595;
  36205. t[3083] = 7598;
  36206. t[3084] = 7599;
  36207. t[3087] = 7602;
  36208. t[3088] = 7603;
  36209. t[3091] = 7606;
  36210. t[3092] = 7607;
  36211. t[3095] = 7610;
  36212. t[3096] = 7611;
  36213. t[3099] = 7614;
  36214. t[3100] = 7615;
  36215. t[3103] = 7618;
  36216. t[3104] = 7619;
  36217. t[3107] = 8337;
  36218. t[3108] = 8338;
  36219. t[3116] = 1884;
  36220. t[3119] = 1885;
  36221. t[3120] = 1885;
  36222. t[3123] = 1886;
  36223. t[3124] = 1886;
  36224. t[3127] = 1887;
  36225. t[3128] = 1887;
  36226. t[3131] = 1888;
  36227. t[3132] = 1888;
  36228. t[3135] = 1889;
  36229. t[3136] = 1889;
  36230. t[3139] = 1890;
  36231. t[3140] = 1890;
  36232. t[3143] = 1891;
  36233. t[3144] = 1891;
  36234. t[3147] = 1892;
  36235. t[3148] = 1892;
  36236. t[3153] = 580;
  36237. t[3154] = 581;
  36238. t[3157] = 584;
  36239. t[3158] = 585;
  36240. t[3161] = 588;
  36241. t[3162] = 589;
  36242. t[3165] = 891;
  36243. t[3166] = 892;
  36244. t[3169] = 1274;
  36245. t[3170] = 1275;
  36246. t[3173] = 1278;
  36247. t[3174] = 1279;
  36248. t[3181] = 7622;
  36249. t[3182] = 7623;
  36250. t[3282] = 11799;
  36251. t[3316] = 578;
  36252. t[3379] = 42785;
  36253. t[3393] = 1159;
  36254. t[3416] = 8377;
  36255. });
  36256. var getSupplementalGlyphMapForArialBlack = getLookupTableFactory(function (t) {
  36257. t[227] = 322;
  36258. t[264] = 261;
  36259. t[291] = 346;
  36260. });
  36261. exports.getStdFontMap = getStdFontMap;
  36262. exports.getNonStdFontMap = getNonStdFontMap;
  36263. exports.getSerifFonts = getSerifFonts;
  36264. exports.getSymbolsFonts = getSymbolsFonts;
  36265. exports.getGlyphMapForStandardFonts = getGlyphMapForStandardFonts;
  36266. exports.getSupplementalGlyphMapForArialBlack = getSupplementalGlyphMapForArialBlack;
  36267. /***/ }),
  36268. /* 21 */
  36269. /***/ (function(module, exports, __w_pdfjs_require__) {
  36270. "use strict";
  36271. var sharedUtil = __w_pdfjs_require__(0);
  36272. var getLookupTableFactory = sharedUtil.getLookupTableFactory;
  36273. var getSpecialPUASymbols = getLookupTableFactory(function (t) {
  36274. t[63721] = 0x00A9;
  36275. t[63193] = 0x00A9;
  36276. t[63720] = 0x00AE;
  36277. t[63194] = 0x00AE;
  36278. t[63722] = 0x2122;
  36279. t[63195] = 0x2122;
  36280. t[63729] = 0x23A7;
  36281. t[63730] = 0x23A8;
  36282. t[63731] = 0x23A9;
  36283. t[63740] = 0x23AB;
  36284. t[63741] = 0x23AC;
  36285. t[63742] = 0x23AD;
  36286. t[63726] = 0x23A1;
  36287. t[63727] = 0x23A2;
  36288. t[63728] = 0x23A3;
  36289. t[63737] = 0x23A4;
  36290. t[63738] = 0x23A5;
  36291. t[63739] = 0x23A6;
  36292. t[63723] = 0x239B;
  36293. t[63724] = 0x239C;
  36294. t[63725] = 0x239D;
  36295. t[63734] = 0x239E;
  36296. t[63735] = 0x239F;
  36297. t[63736] = 0x23A0;
  36298. });
  36299. function mapSpecialUnicodeValues(code) {
  36300. if (code >= 0xFFF0 && code <= 0xFFFF) {
  36301. return 0;
  36302. } else if (code >= 0xF600 && code <= 0xF8FF) {
  36303. return getSpecialPUASymbols()[code] || code;
  36304. }
  36305. return code;
  36306. }
  36307. function getUnicodeForGlyph(name, glyphsUnicodeMap) {
  36308. var unicode = glyphsUnicodeMap[name];
  36309. if (unicode !== undefined) {
  36310. return unicode;
  36311. }
  36312. if (!name) {
  36313. return -1;
  36314. }
  36315. if (name[0] === 'u') {
  36316. var nameLen = name.length, hexStr;
  36317. if (nameLen === 7 && name[1] === 'n' && name[2] === 'i') {
  36318. hexStr = name.substr(3);
  36319. } else if (nameLen >= 5 && nameLen <= 7) {
  36320. hexStr = name.substr(1);
  36321. } else {
  36322. return -1;
  36323. }
  36324. if (hexStr === hexStr.toUpperCase()) {
  36325. unicode = parseInt(hexStr, 16);
  36326. if (unicode >= 0) {
  36327. return unicode;
  36328. }
  36329. }
  36330. }
  36331. return -1;
  36332. }
  36333. var UnicodeRanges = [
  36334. {
  36335. 'begin': 0x0000,
  36336. 'end': 0x007F
  36337. },
  36338. {
  36339. 'begin': 0x0080,
  36340. 'end': 0x00FF
  36341. },
  36342. {
  36343. 'begin': 0x0100,
  36344. 'end': 0x017F
  36345. },
  36346. {
  36347. 'begin': 0x0180,
  36348. 'end': 0x024F
  36349. },
  36350. {
  36351. 'begin': 0x0250,
  36352. 'end': 0x02AF
  36353. },
  36354. {
  36355. 'begin': 0x02B0,
  36356. 'end': 0x02FF
  36357. },
  36358. {
  36359. 'begin': 0x0300,
  36360. 'end': 0x036F
  36361. },
  36362. {
  36363. 'begin': 0x0370,
  36364. 'end': 0x03FF
  36365. },
  36366. {
  36367. 'begin': 0x2C80,
  36368. 'end': 0x2CFF
  36369. },
  36370. {
  36371. 'begin': 0x0400,
  36372. 'end': 0x04FF
  36373. },
  36374. {
  36375. 'begin': 0x0530,
  36376. 'end': 0x058F
  36377. },
  36378. {
  36379. 'begin': 0x0590,
  36380. 'end': 0x05FF
  36381. },
  36382. {
  36383. 'begin': 0xA500,
  36384. 'end': 0xA63F
  36385. },
  36386. {
  36387. 'begin': 0x0600,
  36388. 'end': 0x06FF
  36389. },
  36390. {
  36391. 'begin': 0x07C0,
  36392. 'end': 0x07FF
  36393. },
  36394. {
  36395. 'begin': 0x0900,
  36396. 'end': 0x097F
  36397. },
  36398. {
  36399. 'begin': 0x0980,
  36400. 'end': 0x09FF
  36401. },
  36402. {
  36403. 'begin': 0x0A00,
  36404. 'end': 0x0A7F
  36405. },
  36406. {
  36407. 'begin': 0x0A80,
  36408. 'end': 0x0AFF
  36409. },
  36410. {
  36411. 'begin': 0x0B00,
  36412. 'end': 0x0B7F
  36413. },
  36414. {
  36415. 'begin': 0x0B80,
  36416. 'end': 0x0BFF
  36417. },
  36418. {
  36419. 'begin': 0x0C00,
  36420. 'end': 0x0C7F
  36421. },
  36422. {
  36423. 'begin': 0x0C80,
  36424. 'end': 0x0CFF
  36425. },
  36426. {
  36427. 'begin': 0x0D00,
  36428. 'end': 0x0D7F
  36429. },
  36430. {
  36431. 'begin': 0x0E00,
  36432. 'end': 0x0E7F
  36433. },
  36434. {
  36435. 'begin': 0x0E80,
  36436. 'end': 0x0EFF
  36437. },
  36438. {
  36439. 'begin': 0x10A0,
  36440. 'end': 0x10FF
  36441. },
  36442. {
  36443. 'begin': 0x1B00,
  36444. 'end': 0x1B7F
  36445. },
  36446. {
  36447. 'begin': 0x1100,
  36448. 'end': 0x11FF
  36449. },
  36450. {
  36451. 'begin': 0x1E00,
  36452. 'end': 0x1EFF
  36453. },
  36454. {
  36455. 'begin': 0x1F00,
  36456. 'end': 0x1FFF
  36457. },
  36458. {
  36459. 'begin': 0x2000,
  36460. 'end': 0x206F
  36461. },
  36462. {
  36463. 'begin': 0x2070,
  36464. 'end': 0x209F
  36465. },
  36466. {
  36467. 'begin': 0x20A0,
  36468. 'end': 0x20CF
  36469. },
  36470. {
  36471. 'begin': 0x20D0,
  36472. 'end': 0x20FF
  36473. },
  36474. {
  36475. 'begin': 0x2100,
  36476. 'end': 0x214F
  36477. },
  36478. {
  36479. 'begin': 0x2150,
  36480. 'end': 0x218F
  36481. },
  36482. {
  36483. 'begin': 0x2190,
  36484. 'end': 0x21FF
  36485. },
  36486. {
  36487. 'begin': 0x2200,
  36488. 'end': 0x22FF
  36489. },
  36490. {
  36491. 'begin': 0x2300,
  36492. 'end': 0x23FF
  36493. },
  36494. {
  36495. 'begin': 0x2400,
  36496. 'end': 0x243F
  36497. },
  36498. {
  36499. 'begin': 0x2440,
  36500. 'end': 0x245F
  36501. },
  36502. {
  36503. 'begin': 0x2460,
  36504. 'end': 0x24FF
  36505. },
  36506. {
  36507. 'begin': 0x2500,
  36508. 'end': 0x257F
  36509. },
  36510. {
  36511. 'begin': 0x2580,
  36512. 'end': 0x259F
  36513. },
  36514. {
  36515. 'begin': 0x25A0,
  36516. 'end': 0x25FF
  36517. },
  36518. {
  36519. 'begin': 0x2600,
  36520. 'end': 0x26FF
  36521. },
  36522. {
  36523. 'begin': 0x2700,
  36524. 'end': 0x27BF
  36525. },
  36526. {
  36527. 'begin': 0x3000,
  36528. 'end': 0x303F
  36529. },
  36530. {
  36531. 'begin': 0x3040,
  36532. 'end': 0x309F
  36533. },
  36534. {
  36535. 'begin': 0x30A0,
  36536. 'end': 0x30FF
  36537. },
  36538. {
  36539. 'begin': 0x3100,
  36540. 'end': 0x312F
  36541. },
  36542. {
  36543. 'begin': 0x3130,
  36544. 'end': 0x318F
  36545. },
  36546. {
  36547. 'begin': 0xA840,
  36548. 'end': 0xA87F
  36549. },
  36550. {
  36551. 'begin': 0x3200,
  36552. 'end': 0x32FF
  36553. },
  36554. {
  36555. 'begin': 0x3300,
  36556. 'end': 0x33FF
  36557. },
  36558. {
  36559. 'begin': 0xAC00,
  36560. 'end': 0xD7AF
  36561. },
  36562. {
  36563. 'begin': 0xD800,
  36564. 'end': 0xDFFF
  36565. },
  36566. {
  36567. 'begin': 0x10900,
  36568. 'end': 0x1091F
  36569. },
  36570. {
  36571. 'begin': 0x4E00,
  36572. 'end': 0x9FFF
  36573. },
  36574. {
  36575. 'begin': 0xE000,
  36576. 'end': 0xF8FF
  36577. },
  36578. {
  36579. 'begin': 0x31C0,
  36580. 'end': 0x31EF
  36581. },
  36582. {
  36583. 'begin': 0xFB00,
  36584. 'end': 0xFB4F
  36585. },
  36586. {
  36587. 'begin': 0xFB50,
  36588. 'end': 0xFDFF
  36589. },
  36590. {
  36591. 'begin': 0xFE20,
  36592. 'end': 0xFE2F
  36593. },
  36594. {
  36595. 'begin': 0xFE10,
  36596. 'end': 0xFE1F
  36597. },
  36598. {
  36599. 'begin': 0xFE50,
  36600. 'end': 0xFE6F
  36601. },
  36602. {
  36603. 'begin': 0xFE70,
  36604. 'end': 0xFEFF
  36605. },
  36606. {
  36607. 'begin': 0xFF00,
  36608. 'end': 0xFFEF
  36609. },
  36610. {
  36611. 'begin': 0xFFF0,
  36612. 'end': 0xFFFF
  36613. },
  36614. {
  36615. 'begin': 0x0F00,
  36616. 'end': 0x0FFF
  36617. },
  36618. {
  36619. 'begin': 0x0700,
  36620. 'end': 0x074F
  36621. },
  36622. {
  36623. 'begin': 0x0780,
  36624. 'end': 0x07BF
  36625. },
  36626. {
  36627. 'begin': 0x0D80,
  36628. 'end': 0x0DFF
  36629. },
  36630. {
  36631. 'begin': 0x1000,
  36632. 'end': 0x109F
  36633. },
  36634. {
  36635. 'begin': 0x1200,
  36636. 'end': 0x137F
  36637. },
  36638. {
  36639. 'begin': 0x13A0,
  36640. 'end': 0x13FF
  36641. },
  36642. {
  36643. 'begin': 0x1400,
  36644. 'end': 0x167F
  36645. },
  36646. {
  36647. 'begin': 0x1680,
  36648. 'end': 0x169F
  36649. },
  36650. {
  36651. 'begin': 0x16A0,
  36652. 'end': 0x16FF
  36653. },
  36654. {
  36655. 'begin': 0x1780,
  36656. 'end': 0x17FF
  36657. },
  36658. {
  36659. 'begin': 0x1800,
  36660. 'end': 0x18AF
  36661. },
  36662. {
  36663. 'begin': 0x2800,
  36664. 'end': 0x28FF
  36665. },
  36666. {
  36667. 'begin': 0xA000,
  36668. 'end': 0xA48F
  36669. },
  36670. {
  36671. 'begin': 0x1700,
  36672. 'end': 0x171F
  36673. },
  36674. {
  36675. 'begin': 0x10300,
  36676. 'end': 0x1032F
  36677. },
  36678. {
  36679. 'begin': 0x10330,
  36680. 'end': 0x1034F
  36681. },
  36682. {
  36683. 'begin': 0x10400,
  36684. 'end': 0x1044F
  36685. },
  36686. {
  36687. 'begin': 0x1D000,
  36688. 'end': 0x1D0FF
  36689. },
  36690. {
  36691. 'begin': 0x1D400,
  36692. 'end': 0x1D7FF
  36693. },
  36694. {
  36695. 'begin': 0xFF000,
  36696. 'end': 0xFFFFD
  36697. },
  36698. {
  36699. 'begin': 0xFE00,
  36700. 'end': 0xFE0F
  36701. },
  36702. {
  36703. 'begin': 0xE0000,
  36704. 'end': 0xE007F
  36705. },
  36706. {
  36707. 'begin': 0x1900,
  36708. 'end': 0x194F
  36709. },
  36710. {
  36711. 'begin': 0x1950,
  36712. 'end': 0x197F
  36713. },
  36714. {
  36715. 'begin': 0x1980,
  36716. 'end': 0x19DF
  36717. },
  36718. {
  36719. 'begin': 0x1A00,
  36720. 'end': 0x1A1F
  36721. },
  36722. {
  36723. 'begin': 0x2C00,
  36724. 'end': 0x2C5F
  36725. },
  36726. {
  36727. 'begin': 0x2D30,
  36728. 'end': 0x2D7F
  36729. },
  36730. {
  36731. 'begin': 0x4DC0,
  36732. 'end': 0x4DFF
  36733. },
  36734. {
  36735. 'begin': 0xA800,
  36736. 'end': 0xA82F
  36737. },
  36738. {
  36739. 'begin': 0x10000,
  36740. 'end': 0x1007F
  36741. },
  36742. {
  36743. 'begin': 0x10140,
  36744. 'end': 0x1018F
  36745. },
  36746. {
  36747. 'begin': 0x10380,
  36748. 'end': 0x1039F
  36749. },
  36750. {
  36751. 'begin': 0x103A0,
  36752. 'end': 0x103DF
  36753. },
  36754. {
  36755. 'begin': 0x10450,
  36756. 'end': 0x1047F
  36757. },
  36758. {
  36759. 'begin': 0x10480,
  36760. 'end': 0x104AF
  36761. },
  36762. {
  36763. 'begin': 0x10800,
  36764. 'end': 0x1083F
  36765. },
  36766. {
  36767. 'begin': 0x10A00,
  36768. 'end': 0x10A5F
  36769. },
  36770. {
  36771. 'begin': 0x1D300,
  36772. 'end': 0x1D35F
  36773. },
  36774. {
  36775. 'begin': 0x12000,
  36776. 'end': 0x123FF
  36777. },
  36778. {
  36779. 'begin': 0x1D360,
  36780. 'end': 0x1D37F
  36781. },
  36782. {
  36783. 'begin': 0x1B80,
  36784. 'end': 0x1BBF
  36785. },
  36786. {
  36787. 'begin': 0x1C00,
  36788. 'end': 0x1C4F
  36789. },
  36790. {
  36791. 'begin': 0x1C50,
  36792. 'end': 0x1C7F
  36793. },
  36794. {
  36795. 'begin': 0xA880,
  36796. 'end': 0xA8DF
  36797. },
  36798. {
  36799. 'begin': 0xA900,
  36800. 'end': 0xA92F
  36801. },
  36802. {
  36803. 'begin': 0xA930,
  36804. 'end': 0xA95F
  36805. },
  36806. {
  36807. 'begin': 0xAA00,
  36808. 'end': 0xAA5F
  36809. },
  36810. {
  36811. 'begin': 0x10190,
  36812. 'end': 0x101CF
  36813. },
  36814. {
  36815. 'begin': 0x101D0,
  36816. 'end': 0x101FF
  36817. },
  36818. {
  36819. 'begin': 0x102A0,
  36820. 'end': 0x102DF
  36821. },
  36822. {
  36823. 'begin': 0x1F030,
  36824. 'end': 0x1F09F
  36825. }
  36826. ];
  36827. function getUnicodeRangeFor(value) {
  36828. for (var i = 0, ii = UnicodeRanges.length; i < ii; i++) {
  36829. var range = UnicodeRanges[i];
  36830. if (value >= range.begin && value < range.end) {
  36831. return i;
  36832. }
  36833. }
  36834. return -1;
  36835. }
  36836. function isRTLRangeFor(value) {
  36837. var range = UnicodeRanges[13];
  36838. if (value >= range.begin && value < range.end) {
  36839. return true;
  36840. }
  36841. range = UnicodeRanges[11];
  36842. if (value >= range.begin && value < range.end) {
  36843. return true;
  36844. }
  36845. return false;
  36846. }
  36847. var getNormalizedUnicodes = getLookupTableFactory(function (t) {
  36848. t['\u00A8'] = '\u0020\u0308';
  36849. t['\u00AF'] = '\u0020\u0304';
  36850. t['\u00B4'] = '\u0020\u0301';
  36851. t['\u00B5'] = '\u03BC';
  36852. t['\u00B8'] = '\u0020\u0327';
  36853. t['\u0132'] = '\u0049\u004A';
  36854. t['\u0133'] = '\u0069\u006A';
  36855. t['\u013F'] = '\u004C\u00B7';
  36856. t['\u0140'] = '\u006C\u00B7';
  36857. t['\u0149'] = '\u02BC\u006E';
  36858. t['\u017F'] = '\u0073';
  36859. t['\u01C4'] = '\u0044\u017D';
  36860. t['\u01C5'] = '\u0044\u017E';
  36861. t['\u01C6'] = '\u0064\u017E';
  36862. t['\u01C7'] = '\u004C\u004A';
  36863. t['\u01C8'] = '\u004C\u006A';
  36864. t['\u01C9'] = '\u006C\u006A';
  36865. t['\u01CA'] = '\u004E\u004A';
  36866. t['\u01CB'] = '\u004E\u006A';
  36867. t['\u01CC'] = '\u006E\u006A';
  36868. t['\u01F1'] = '\u0044\u005A';
  36869. t['\u01F2'] = '\u0044\u007A';
  36870. t['\u01F3'] = '\u0064\u007A';
  36871. t['\u02D8'] = '\u0020\u0306';
  36872. t['\u02D9'] = '\u0020\u0307';
  36873. t['\u02DA'] = '\u0020\u030A';
  36874. t['\u02DB'] = '\u0020\u0328';
  36875. t['\u02DC'] = '\u0020\u0303';
  36876. t['\u02DD'] = '\u0020\u030B';
  36877. t['\u037A'] = '\u0020\u0345';
  36878. t['\u0384'] = '\u0020\u0301';
  36879. t['\u03D0'] = '\u03B2';
  36880. t['\u03D1'] = '\u03B8';
  36881. t['\u03D2'] = '\u03A5';
  36882. t['\u03D5'] = '\u03C6';
  36883. t['\u03D6'] = '\u03C0';
  36884. t['\u03F0'] = '\u03BA';
  36885. t['\u03F1'] = '\u03C1';
  36886. t['\u03F2'] = '\u03C2';
  36887. t['\u03F4'] = '\u0398';
  36888. t['\u03F5'] = '\u03B5';
  36889. t['\u03F9'] = '\u03A3';
  36890. t['\u0587'] = '\u0565\u0582';
  36891. t['\u0675'] = '\u0627\u0674';
  36892. t['\u0676'] = '\u0648\u0674';
  36893. t['\u0677'] = '\u06C7\u0674';
  36894. t['\u0678'] = '\u064A\u0674';
  36895. t['\u0E33'] = '\u0E4D\u0E32';
  36896. t['\u0EB3'] = '\u0ECD\u0EB2';
  36897. t['\u0EDC'] = '\u0EAB\u0E99';
  36898. t['\u0EDD'] = '\u0EAB\u0EA1';
  36899. t['\u0F77'] = '\u0FB2\u0F81';
  36900. t['\u0F79'] = '\u0FB3\u0F81';
  36901. t['\u1E9A'] = '\u0061\u02BE';
  36902. t['\u1FBD'] = '\u0020\u0313';
  36903. t['\u1FBF'] = '\u0020\u0313';
  36904. t['\u1FC0'] = '\u0020\u0342';
  36905. t['\u1FFE'] = '\u0020\u0314';
  36906. t['\u2002'] = '\u0020';
  36907. t['\u2003'] = '\u0020';
  36908. t['\u2004'] = '\u0020';
  36909. t['\u2005'] = '\u0020';
  36910. t['\u2006'] = '\u0020';
  36911. t['\u2008'] = '\u0020';
  36912. t['\u2009'] = '\u0020';
  36913. t['\u200A'] = '\u0020';
  36914. t['\u2017'] = '\u0020\u0333';
  36915. t['\u2024'] = '\u002E';
  36916. t['\u2025'] = '\u002E\u002E';
  36917. t['\u2026'] = '\u002E\u002E\u002E';
  36918. t['\u2033'] = '\u2032\u2032';
  36919. t['\u2034'] = '\u2032\u2032\u2032';
  36920. t['\u2036'] = '\u2035\u2035';
  36921. t['\u2037'] = '\u2035\u2035\u2035';
  36922. t['\u203C'] = '\u0021\u0021';
  36923. t['\u203E'] = '\u0020\u0305';
  36924. t['\u2047'] = '\u003F\u003F';
  36925. t['\u2048'] = '\u003F\u0021';
  36926. t['\u2049'] = '\u0021\u003F';
  36927. t['\u2057'] = '\u2032\u2032\u2032\u2032';
  36928. t['\u205F'] = '\u0020';
  36929. t['\u20A8'] = '\u0052\u0073';
  36930. t['\u2100'] = '\u0061\u002F\u0063';
  36931. t['\u2101'] = '\u0061\u002F\u0073';
  36932. t['\u2103'] = '\u00B0\u0043';
  36933. t['\u2105'] = '\u0063\u002F\u006F';
  36934. t['\u2106'] = '\u0063\u002F\u0075';
  36935. t['\u2107'] = '\u0190';
  36936. t['\u2109'] = '\u00B0\u0046';
  36937. t['\u2116'] = '\u004E\u006F';
  36938. t['\u2121'] = '\u0054\u0045\u004C';
  36939. t['\u2135'] = '\u05D0';
  36940. t['\u2136'] = '\u05D1';
  36941. t['\u2137'] = '\u05D2';
  36942. t['\u2138'] = '\u05D3';
  36943. t['\u213B'] = '\u0046\u0041\u0058';
  36944. t['\u2160'] = '\u0049';
  36945. t['\u2161'] = '\u0049\u0049';
  36946. t['\u2162'] = '\u0049\u0049\u0049';
  36947. t['\u2163'] = '\u0049\u0056';
  36948. t['\u2164'] = '\u0056';
  36949. t['\u2165'] = '\u0056\u0049';
  36950. t['\u2166'] = '\u0056\u0049\u0049';
  36951. t['\u2167'] = '\u0056\u0049\u0049\u0049';
  36952. t['\u2168'] = '\u0049\u0058';
  36953. t['\u2169'] = '\u0058';
  36954. t['\u216A'] = '\u0058\u0049';
  36955. t['\u216B'] = '\u0058\u0049\u0049';
  36956. t['\u216C'] = '\u004C';
  36957. t['\u216D'] = '\u0043';
  36958. t['\u216E'] = '\u0044';
  36959. t['\u216F'] = '\u004D';
  36960. t['\u2170'] = '\u0069';
  36961. t['\u2171'] = '\u0069\u0069';
  36962. t['\u2172'] = '\u0069\u0069\u0069';
  36963. t['\u2173'] = '\u0069\u0076';
  36964. t['\u2174'] = '\u0076';
  36965. t['\u2175'] = '\u0076\u0069';
  36966. t['\u2176'] = '\u0076\u0069\u0069';
  36967. t['\u2177'] = '\u0076\u0069\u0069\u0069';
  36968. t['\u2178'] = '\u0069\u0078';
  36969. t['\u2179'] = '\u0078';
  36970. t['\u217A'] = '\u0078\u0069';
  36971. t['\u217B'] = '\u0078\u0069\u0069';
  36972. t['\u217C'] = '\u006C';
  36973. t['\u217D'] = '\u0063';
  36974. t['\u217E'] = '\u0064';
  36975. t['\u217F'] = '\u006D';
  36976. t['\u222C'] = '\u222B\u222B';
  36977. t['\u222D'] = '\u222B\u222B\u222B';
  36978. t['\u222F'] = '\u222E\u222E';
  36979. t['\u2230'] = '\u222E\u222E\u222E';
  36980. t['\u2474'] = '\u0028\u0031\u0029';
  36981. t['\u2475'] = '\u0028\u0032\u0029';
  36982. t['\u2476'] = '\u0028\u0033\u0029';
  36983. t['\u2477'] = '\u0028\u0034\u0029';
  36984. t['\u2478'] = '\u0028\u0035\u0029';
  36985. t['\u2479'] = '\u0028\u0036\u0029';
  36986. t['\u247A'] = '\u0028\u0037\u0029';
  36987. t['\u247B'] = '\u0028\u0038\u0029';
  36988. t['\u247C'] = '\u0028\u0039\u0029';
  36989. t['\u247D'] = '\u0028\u0031\u0030\u0029';
  36990. t['\u247E'] = '\u0028\u0031\u0031\u0029';
  36991. t['\u247F'] = '\u0028\u0031\u0032\u0029';
  36992. t['\u2480'] = '\u0028\u0031\u0033\u0029';
  36993. t['\u2481'] = '\u0028\u0031\u0034\u0029';
  36994. t['\u2482'] = '\u0028\u0031\u0035\u0029';
  36995. t['\u2483'] = '\u0028\u0031\u0036\u0029';
  36996. t['\u2484'] = '\u0028\u0031\u0037\u0029';
  36997. t['\u2485'] = '\u0028\u0031\u0038\u0029';
  36998. t['\u2486'] = '\u0028\u0031\u0039\u0029';
  36999. t['\u2487'] = '\u0028\u0032\u0030\u0029';
  37000. t['\u2488'] = '\u0031\u002E';
  37001. t['\u2489'] = '\u0032\u002E';
  37002. t['\u248A'] = '\u0033\u002E';
  37003. t['\u248B'] = '\u0034\u002E';
  37004. t['\u248C'] = '\u0035\u002E';
  37005. t['\u248D'] = '\u0036\u002E';
  37006. t['\u248E'] = '\u0037\u002E';
  37007. t['\u248F'] = '\u0038\u002E';
  37008. t['\u2490'] = '\u0039\u002E';
  37009. t['\u2491'] = '\u0031\u0030\u002E';
  37010. t['\u2492'] = '\u0031\u0031\u002E';
  37011. t['\u2493'] = '\u0031\u0032\u002E';
  37012. t['\u2494'] = '\u0031\u0033\u002E';
  37013. t['\u2495'] = '\u0031\u0034\u002E';
  37014. t['\u2496'] = '\u0031\u0035\u002E';
  37015. t['\u2497'] = '\u0031\u0036\u002E';
  37016. t['\u2498'] = '\u0031\u0037\u002E';
  37017. t['\u2499'] = '\u0031\u0038\u002E';
  37018. t['\u249A'] = '\u0031\u0039\u002E';
  37019. t['\u249B'] = '\u0032\u0030\u002E';
  37020. t['\u249C'] = '\u0028\u0061\u0029';
  37021. t['\u249D'] = '\u0028\u0062\u0029';
  37022. t['\u249E'] = '\u0028\u0063\u0029';
  37023. t['\u249F'] = '\u0028\u0064\u0029';
  37024. t['\u24A0'] = '\u0028\u0065\u0029';
  37025. t['\u24A1'] = '\u0028\u0066\u0029';
  37026. t['\u24A2'] = '\u0028\u0067\u0029';
  37027. t['\u24A3'] = '\u0028\u0068\u0029';
  37028. t['\u24A4'] = '\u0028\u0069\u0029';
  37029. t['\u24A5'] = '\u0028\u006A\u0029';
  37030. t['\u24A6'] = '\u0028\u006B\u0029';
  37031. t['\u24A7'] = '\u0028\u006C\u0029';
  37032. t['\u24A8'] = '\u0028\u006D\u0029';
  37033. t['\u24A9'] = '\u0028\u006E\u0029';
  37034. t['\u24AA'] = '\u0028\u006F\u0029';
  37035. t['\u24AB'] = '\u0028\u0070\u0029';
  37036. t['\u24AC'] = '\u0028\u0071\u0029';
  37037. t['\u24AD'] = '\u0028\u0072\u0029';
  37038. t['\u24AE'] = '\u0028\u0073\u0029';
  37039. t['\u24AF'] = '\u0028\u0074\u0029';
  37040. t['\u24B0'] = '\u0028\u0075\u0029';
  37041. t['\u24B1'] = '\u0028\u0076\u0029';
  37042. t['\u24B2'] = '\u0028\u0077\u0029';
  37043. t['\u24B3'] = '\u0028\u0078\u0029';
  37044. t['\u24B4'] = '\u0028\u0079\u0029';
  37045. t['\u24B5'] = '\u0028\u007A\u0029';
  37046. t['\u2A0C'] = '\u222B\u222B\u222B\u222B';
  37047. t['\u2A74'] = '\u003A\u003A\u003D';
  37048. t['\u2A75'] = '\u003D\u003D';
  37049. t['\u2A76'] = '\u003D\u003D\u003D';
  37050. t['\u2E9F'] = '\u6BCD';
  37051. t['\u2EF3'] = '\u9F9F';
  37052. t['\u2F00'] = '\u4E00';
  37053. t['\u2F01'] = '\u4E28';
  37054. t['\u2F02'] = '\u4E36';
  37055. t['\u2F03'] = '\u4E3F';
  37056. t['\u2F04'] = '\u4E59';
  37057. t['\u2F05'] = '\u4E85';
  37058. t['\u2F06'] = '\u4E8C';
  37059. t['\u2F07'] = '\u4EA0';
  37060. t['\u2F08'] = '\u4EBA';
  37061. t['\u2F09'] = '\u513F';
  37062. t['\u2F0A'] = '\u5165';
  37063. t['\u2F0B'] = '\u516B';
  37064. t['\u2F0C'] = '\u5182';
  37065. t['\u2F0D'] = '\u5196';
  37066. t['\u2F0E'] = '\u51AB';
  37067. t['\u2F0F'] = '\u51E0';
  37068. t['\u2F10'] = '\u51F5';
  37069. t['\u2F11'] = '\u5200';
  37070. t['\u2F12'] = '\u529B';
  37071. t['\u2F13'] = '\u52F9';
  37072. t['\u2F14'] = '\u5315';
  37073. t['\u2F15'] = '\u531A';
  37074. t['\u2F16'] = '\u5338';
  37075. t['\u2F17'] = '\u5341';
  37076. t['\u2F18'] = '\u535C';
  37077. t['\u2F19'] = '\u5369';
  37078. t['\u2F1A'] = '\u5382';
  37079. t['\u2F1B'] = '\u53B6';
  37080. t['\u2F1C'] = '\u53C8';
  37081. t['\u2F1D'] = '\u53E3';
  37082. t['\u2F1E'] = '\u56D7';
  37083. t['\u2F1F'] = '\u571F';
  37084. t['\u2F20'] = '\u58EB';
  37085. t['\u2F21'] = '\u5902';
  37086. t['\u2F22'] = '\u590A';
  37087. t['\u2F23'] = '\u5915';
  37088. t['\u2F24'] = '\u5927';
  37089. t['\u2F25'] = '\u5973';
  37090. t['\u2F26'] = '\u5B50';
  37091. t['\u2F27'] = '\u5B80';
  37092. t['\u2F28'] = '\u5BF8';
  37093. t['\u2F29'] = '\u5C0F';
  37094. t['\u2F2A'] = '\u5C22';
  37095. t['\u2F2B'] = '\u5C38';
  37096. t['\u2F2C'] = '\u5C6E';
  37097. t['\u2F2D'] = '\u5C71';
  37098. t['\u2F2E'] = '\u5DDB';
  37099. t['\u2F2F'] = '\u5DE5';
  37100. t['\u2F30'] = '\u5DF1';
  37101. t['\u2F31'] = '\u5DFE';
  37102. t['\u2F32'] = '\u5E72';
  37103. t['\u2F33'] = '\u5E7A';
  37104. t['\u2F34'] = '\u5E7F';
  37105. t['\u2F35'] = '\u5EF4';
  37106. t['\u2F36'] = '\u5EFE';
  37107. t['\u2F37'] = '\u5F0B';
  37108. t['\u2F38'] = '\u5F13';
  37109. t['\u2F39'] = '\u5F50';
  37110. t['\u2F3A'] = '\u5F61';
  37111. t['\u2F3B'] = '\u5F73';
  37112. t['\u2F3C'] = '\u5FC3';
  37113. t['\u2F3D'] = '\u6208';
  37114. t['\u2F3E'] = '\u6236';
  37115. t['\u2F3F'] = '\u624B';
  37116. t['\u2F40'] = '\u652F';
  37117. t['\u2F41'] = '\u6534';
  37118. t['\u2F42'] = '\u6587';
  37119. t['\u2F43'] = '\u6597';
  37120. t['\u2F44'] = '\u65A4';
  37121. t['\u2F45'] = '\u65B9';
  37122. t['\u2F46'] = '\u65E0';
  37123. t['\u2F47'] = '\u65E5';
  37124. t['\u2F48'] = '\u66F0';
  37125. t['\u2F49'] = '\u6708';
  37126. t['\u2F4A'] = '\u6728';
  37127. t['\u2F4B'] = '\u6B20';
  37128. t['\u2F4C'] = '\u6B62';
  37129. t['\u2F4D'] = '\u6B79';
  37130. t['\u2F4E'] = '\u6BB3';
  37131. t['\u2F4F'] = '\u6BCB';
  37132. t['\u2F50'] = '\u6BD4';
  37133. t['\u2F51'] = '\u6BDB';
  37134. t['\u2F52'] = '\u6C0F';
  37135. t['\u2F53'] = '\u6C14';
  37136. t['\u2F54'] = '\u6C34';
  37137. t['\u2F55'] = '\u706B';
  37138. t['\u2F56'] = '\u722A';
  37139. t['\u2F57'] = '\u7236';
  37140. t['\u2F58'] = '\u723B';
  37141. t['\u2F59'] = '\u723F';
  37142. t['\u2F5A'] = '\u7247';
  37143. t['\u2F5B'] = '\u7259';
  37144. t['\u2F5C'] = '\u725B';
  37145. t['\u2F5D'] = '\u72AC';
  37146. t['\u2F5E'] = '\u7384';
  37147. t['\u2F5F'] = '\u7389';
  37148. t['\u2F60'] = '\u74DC';
  37149. t['\u2F61'] = '\u74E6';
  37150. t['\u2F62'] = '\u7518';
  37151. t['\u2F63'] = '\u751F';
  37152. t['\u2F64'] = '\u7528';
  37153. t['\u2F65'] = '\u7530';
  37154. t['\u2F66'] = '\u758B';
  37155. t['\u2F67'] = '\u7592';
  37156. t['\u2F68'] = '\u7676';
  37157. t['\u2F69'] = '\u767D';
  37158. t['\u2F6A'] = '\u76AE';
  37159. t['\u2F6B'] = '\u76BF';
  37160. t['\u2F6C'] = '\u76EE';
  37161. t['\u2F6D'] = '\u77DB';
  37162. t['\u2F6E'] = '\u77E2';
  37163. t['\u2F6F'] = '\u77F3';
  37164. t['\u2F70'] = '\u793A';
  37165. t['\u2F71'] = '\u79B8';
  37166. t['\u2F72'] = '\u79BE';
  37167. t['\u2F73'] = '\u7A74';
  37168. t['\u2F74'] = '\u7ACB';
  37169. t['\u2F75'] = '\u7AF9';
  37170. t['\u2F76'] = '\u7C73';
  37171. t['\u2F77'] = '\u7CF8';
  37172. t['\u2F78'] = '\u7F36';
  37173. t['\u2F79'] = '\u7F51';
  37174. t['\u2F7A'] = '\u7F8A';
  37175. t['\u2F7B'] = '\u7FBD';
  37176. t['\u2F7C'] = '\u8001';
  37177. t['\u2F7D'] = '\u800C';
  37178. t['\u2F7E'] = '\u8012';
  37179. t['\u2F7F'] = '\u8033';
  37180. t['\u2F80'] = '\u807F';
  37181. t['\u2F81'] = '\u8089';
  37182. t['\u2F82'] = '\u81E3';
  37183. t['\u2F83'] = '\u81EA';
  37184. t['\u2F84'] = '\u81F3';
  37185. t['\u2F85'] = '\u81FC';
  37186. t['\u2F86'] = '\u820C';
  37187. t['\u2F87'] = '\u821B';
  37188. t['\u2F88'] = '\u821F';
  37189. t['\u2F89'] = '\u826E';
  37190. t['\u2F8A'] = '\u8272';
  37191. t['\u2F8B'] = '\u8278';
  37192. t['\u2F8C'] = '\u864D';
  37193. t['\u2F8D'] = '\u866B';
  37194. t['\u2F8E'] = '\u8840';
  37195. t['\u2F8F'] = '\u884C';
  37196. t['\u2F90'] = '\u8863';
  37197. t['\u2F91'] = '\u897E';
  37198. t['\u2F92'] = '\u898B';
  37199. t['\u2F93'] = '\u89D2';
  37200. t['\u2F94'] = '\u8A00';
  37201. t['\u2F95'] = '\u8C37';
  37202. t['\u2F96'] = '\u8C46';
  37203. t['\u2F97'] = '\u8C55';
  37204. t['\u2F98'] = '\u8C78';
  37205. t['\u2F99'] = '\u8C9D';
  37206. t['\u2F9A'] = '\u8D64';
  37207. t['\u2F9B'] = '\u8D70';
  37208. t['\u2F9C'] = '\u8DB3';
  37209. t['\u2F9D'] = '\u8EAB';
  37210. t['\u2F9E'] = '\u8ECA';
  37211. t['\u2F9F'] = '\u8F9B';
  37212. t['\u2FA0'] = '\u8FB0';
  37213. t['\u2FA1'] = '\u8FB5';
  37214. t['\u2FA2'] = '\u9091';
  37215. t['\u2FA3'] = '\u9149';
  37216. t['\u2FA4'] = '\u91C6';
  37217. t['\u2FA5'] = '\u91CC';
  37218. t['\u2FA6'] = '\u91D1';
  37219. t['\u2FA7'] = '\u9577';
  37220. t['\u2FA8'] = '\u9580';
  37221. t['\u2FA9'] = '\u961C';
  37222. t['\u2FAA'] = '\u96B6';
  37223. t['\u2FAB'] = '\u96B9';
  37224. t['\u2FAC'] = '\u96E8';
  37225. t['\u2FAD'] = '\u9751';
  37226. t['\u2FAE'] = '\u975E';
  37227. t['\u2FAF'] = '\u9762';
  37228. t['\u2FB0'] = '\u9769';
  37229. t['\u2FB1'] = '\u97CB';
  37230. t['\u2FB2'] = '\u97ED';
  37231. t['\u2FB3'] = '\u97F3';
  37232. t['\u2FB4'] = '\u9801';
  37233. t['\u2FB5'] = '\u98A8';
  37234. t['\u2FB6'] = '\u98DB';
  37235. t['\u2FB7'] = '\u98DF';
  37236. t['\u2FB8'] = '\u9996';
  37237. t['\u2FB9'] = '\u9999';
  37238. t['\u2FBA'] = '\u99AC';
  37239. t['\u2FBB'] = '\u9AA8';
  37240. t['\u2FBC'] = '\u9AD8';
  37241. t['\u2FBD'] = '\u9ADF';
  37242. t['\u2FBE'] = '\u9B25';
  37243. t['\u2FBF'] = '\u9B2F';
  37244. t['\u2FC0'] = '\u9B32';
  37245. t['\u2FC1'] = '\u9B3C';
  37246. t['\u2FC2'] = '\u9B5A';
  37247. t['\u2FC3'] = '\u9CE5';
  37248. t['\u2FC4'] = '\u9E75';
  37249. t['\u2FC5'] = '\u9E7F';
  37250. t['\u2FC6'] = '\u9EA5';
  37251. t['\u2FC7'] = '\u9EBB';
  37252. t['\u2FC8'] = '\u9EC3';
  37253. t['\u2FC9'] = '\u9ECD';
  37254. t['\u2FCA'] = '\u9ED1';
  37255. t['\u2FCB'] = '\u9EF9';
  37256. t['\u2FCC'] = '\u9EFD';
  37257. t['\u2FCD'] = '\u9F0E';
  37258. t['\u2FCE'] = '\u9F13';
  37259. t['\u2FCF'] = '\u9F20';
  37260. t['\u2FD0'] = '\u9F3B';
  37261. t['\u2FD1'] = '\u9F4A';
  37262. t['\u2FD2'] = '\u9F52';
  37263. t['\u2FD3'] = '\u9F8D';
  37264. t['\u2FD4'] = '\u9F9C';
  37265. t['\u2FD5'] = '\u9FA0';
  37266. t['\u3036'] = '\u3012';
  37267. t['\u3038'] = '\u5341';
  37268. t['\u3039'] = '\u5344';
  37269. t['\u303A'] = '\u5345';
  37270. t['\u309B'] = '\u0020\u3099';
  37271. t['\u309C'] = '\u0020\u309A';
  37272. t['\u3131'] = '\u1100';
  37273. t['\u3132'] = '\u1101';
  37274. t['\u3133'] = '\u11AA';
  37275. t['\u3134'] = '\u1102';
  37276. t['\u3135'] = '\u11AC';
  37277. t['\u3136'] = '\u11AD';
  37278. t['\u3137'] = '\u1103';
  37279. t['\u3138'] = '\u1104';
  37280. t['\u3139'] = '\u1105';
  37281. t['\u313A'] = '\u11B0';
  37282. t['\u313B'] = '\u11B1';
  37283. t['\u313C'] = '\u11B2';
  37284. t['\u313D'] = '\u11B3';
  37285. t['\u313E'] = '\u11B4';
  37286. t['\u313F'] = '\u11B5';
  37287. t['\u3140'] = '\u111A';
  37288. t['\u3141'] = '\u1106';
  37289. t['\u3142'] = '\u1107';
  37290. t['\u3143'] = '\u1108';
  37291. t['\u3144'] = '\u1121';
  37292. t['\u3145'] = '\u1109';
  37293. t['\u3146'] = '\u110A';
  37294. t['\u3147'] = '\u110B';
  37295. t['\u3148'] = '\u110C';
  37296. t['\u3149'] = '\u110D';
  37297. t['\u314A'] = '\u110E';
  37298. t['\u314B'] = '\u110F';
  37299. t['\u314C'] = '\u1110';
  37300. t['\u314D'] = '\u1111';
  37301. t['\u314E'] = '\u1112';
  37302. t['\u314F'] = '\u1161';
  37303. t['\u3150'] = '\u1162';
  37304. t['\u3151'] = '\u1163';
  37305. t['\u3152'] = '\u1164';
  37306. t['\u3153'] = '\u1165';
  37307. t['\u3154'] = '\u1166';
  37308. t['\u3155'] = '\u1167';
  37309. t['\u3156'] = '\u1168';
  37310. t['\u3157'] = '\u1169';
  37311. t['\u3158'] = '\u116A';
  37312. t['\u3159'] = '\u116B';
  37313. t['\u315A'] = '\u116C';
  37314. t['\u315B'] = '\u116D';
  37315. t['\u315C'] = '\u116E';
  37316. t['\u315D'] = '\u116F';
  37317. t['\u315E'] = '\u1170';
  37318. t['\u315F'] = '\u1171';
  37319. t['\u3160'] = '\u1172';
  37320. t['\u3161'] = '\u1173';
  37321. t['\u3162'] = '\u1174';
  37322. t['\u3163'] = '\u1175';
  37323. t['\u3164'] = '\u1160';
  37324. t['\u3165'] = '\u1114';
  37325. t['\u3166'] = '\u1115';
  37326. t['\u3167'] = '\u11C7';
  37327. t['\u3168'] = '\u11C8';
  37328. t['\u3169'] = '\u11CC';
  37329. t['\u316A'] = '\u11CE';
  37330. t['\u316B'] = '\u11D3';
  37331. t['\u316C'] = '\u11D7';
  37332. t['\u316D'] = '\u11D9';
  37333. t['\u316E'] = '\u111C';
  37334. t['\u316F'] = '\u11DD';
  37335. t['\u3170'] = '\u11DF';
  37336. t['\u3171'] = '\u111D';
  37337. t['\u3172'] = '\u111E';
  37338. t['\u3173'] = '\u1120';
  37339. t['\u3174'] = '\u1122';
  37340. t['\u3175'] = '\u1123';
  37341. t['\u3176'] = '\u1127';
  37342. t['\u3177'] = '\u1129';
  37343. t['\u3178'] = '\u112B';
  37344. t['\u3179'] = '\u112C';
  37345. t['\u317A'] = '\u112D';
  37346. t['\u317B'] = '\u112E';
  37347. t['\u317C'] = '\u112F';
  37348. t['\u317D'] = '\u1132';
  37349. t['\u317E'] = '\u1136';
  37350. t['\u317F'] = '\u1140';
  37351. t['\u3180'] = '\u1147';
  37352. t['\u3181'] = '\u114C';
  37353. t['\u3182'] = '\u11F1';
  37354. t['\u3183'] = '\u11F2';
  37355. t['\u3184'] = '\u1157';
  37356. t['\u3185'] = '\u1158';
  37357. t['\u3186'] = '\u1159';
  37358. t['\u3187'] = '\u1184';
  37359. t['\u3188'] = '\u1185';
  37360. t['\u3189'] = '\u1188';
  37361. t['\u318A'] = '\u1191';
  37362. t['\u318B'] = '\u1192';
  37363. t['\u318C'] = '\u1194';
  37364. t['\u318D'] = '\u119E';
  37365. t['\u318E'] = '\u11A1';
  37366. t['\u3200'] = '\u0028\u1100\u0029';
  37367. t['\u3201'] = '\u0028\u1102\u0029';
  37368. t['\u3202'] = '\u0028\u1103\u0029';
  37369. t['\u3203'] = '\u0028\u1105\u0029';
  37370. t['\u3204'] = '\u0028\u1106\u0029';
  37371. t['\u3205'] = '\u0028\u1107\u0029';
  37372. t['\u3206'] = '\u0028\u1109\u0029';
  37373. t['\u3207'] = '\u0028\u110B\u0029';
  37374. t['\u3208'] = '\u0028\u110C\u0029';
  37375. t['\u3209'] = '\u0028\u110E\u0029';
  37376. t['\u320A'] = '\u0028\u110F\u0029';
  37377. t['\u320B'] = '\u0028\u1110\u0029';
  37378. t['\u320C'] = '\u0028\u1111\u0029';
  37379. t['\u320D'] = '\u0028\u1112\u0029';
  37380. t['\u320E'] = '\u0028\u1100\u1161\u0029';
  37381. t['\u320F'] = '\u0028\u1102\u1161\u0029';
  37382. t['\u3210'] = '\u0028\u1103\u1161\u0029';
  37383. t['\u3211'] = '\u0028\u1105\u1161\u0029';
  37384. t['\u3212'] = '\u0028\u1106\u1161\u0029';
  37385. t['\u3213'] = '\u0028\u1107\u1161\u0029';
  37386. t['\u3214'] = '\u0028\u1109\u1161\u0029';
  37387. t['\u3215'] = '\u0028\u110B\u1161\u0029';
  37388. t['\u3216'] = '\u0028\u110C\u1161\u0029';
  37389. t['\u3217'] = '\u0028\u110E\u1161\u0029';
  37390. t['\u3218'] = '\u0028\u110F\u1161\u0029';
  37391. t['\u3219'] = '\u0028\u1110\u1161\u0029';
  37392. t['\u321A'] = '\u0028\u1111\u1161\u0029';
  37393. t['\u321B'] = '\u0028\u1112\u1161\u0029';
  37394. t['\u321C'] = '\u0028\u110C\u116E\u0029';
  37395. t['\u321D'] = '\u0028\u110B\u1169\u110C\u1165\u11AB\u0029';
  37396. t['\u321E'] = '\u0028\u110B\u1169\u1112\u116E\u0029';
  37397. t['\u3220'] = '\u0028\u4E00\u0029';
  37398. t['\u3221'] = '\u0028\u4E8C\u0029';
  37399. t['\u3222'] = '\u0028\u4E09\u0029';
  37400. t['\u3223'] = '\u0028\u56DB\u0029';
  37401. t['\u3224'] = '\u0028\u4E94\u0029';
  37402. t['\u3225'] = '\u0028\u516D\u0029';
  37403. t['\u3226'] = '\u0028\u4E03\u0029';
  37404. t['\u3227'] = '\u0028\u516B\u0029';
  37405. t['\u3228'] = '\u0028\u4E5D\u0029';
  37406. t['\u3229'] = '\u0028\u5341\u0029';
  37407. t['\u322A'] = '\u0028\u6708\u0029';
  37408. t['\u322B'] = '\u0028\u706B\u0029';
  37409. t['\u322C'] = '\u0028\u6C34\u0029';
  37410. t['\u322D'] = '\u0028\u6728\u0029';
  37411. t['\u322E'] = '\u0028\u91D1\u0029';
  37412. t['\u322F'] = '\u0028\u571F\u0029';
  37413. t['\u3230'] = '\u0028\u65E5\u0029';
  37414. t['\u3231'] = '\u0028\u682A\u0029';
  37415. t['\u3232'] = '\u0028\u6709\u0029';
  37416. t['\u3233'] = '\u0028\u793E\u0029';
  37417. t['\u3234'] = '\u0028\u540D\u0029';
  37418. t['\u3235'] = '\u0028\u7279\u0029';
  37419. t['\u3236'] = '\u0028\u8CA1\u0029';
  37420. t['\u3237'] = '\u0028\u795D\u0029';
  37421. t['\u3238'] = '\u0028\u52B4\u0029';
  37422. t['\u3239'] = '\u0028\u4EE3\u0029';
  37423. t['\u323A'] = '\u0028\u547C\u0029';
  37424. t['\u323B'] = '\u0028\u5B66\u0029';
  37425. t['\u323C'] = '\u0028\u76E3\u0029';
  37426. t['\u323D'] = '\u0028\u4F01\u0029';
  37427. t['\u323E'] = '\u0028\u8CC7\u0029';
  37428. t['\u323F'] = '\u0028\u5354\u0029';
  37429. t['\u3240'] = '\u0028\u796D\u0029';
  37430. t['\u3241'] = '\u0028\u4F11\u0029';
  37431. t['\u3242'] = '\u0028\u81EA\u0029';
  37432. t['\u3243'] = '\u0028\u81F3\u0029';
  37433. t['\u32C0'] = '\u0031\u6708';
  37434. t['\u32C1'] = '\u0032\u6708';
  37435. t['\u32C2'] = '\u0033\u6708';
  37436. t['\u32C3'] = '\u0034\u6708';
  37437. t['\u32C4'] = '\u0035\u6708';
  37438. t['\u32C5'] = '\u0036\u6708';
  37439. t['\u32C6'] = '\u0037\u6708';
  37440. t['\u32C7'] = '\u0038\u6708';
  37441. t['\u32C8'] = '\u0039\u6708';
  37442. t['\u32C9'] = '\u0031\u0030\u6708';
  37443. t['\u32CA'] = '\u0031\u0031\u6708';
  37444. t['\u32CB'] = '\u0031\u0032\u6708';
  37445. t['\u3358'] = '\u0030\u70B9';
  37446. t['\u3359'] = '\u0031\u70B9';
  37447. t['\u335A'] = '\u0032\u70B9';
  37448. t['\u335B'] = '\u0033\u70B9';
  37449. t['\u335C'] = '\u0034\u70B9';
  37450. t['\u335D'] = '\u0035\u70B9';
  37451. t['\u335E'] = '\u0036\u70B9';
  37452. t['\u335F'] = '\u0037\u70B9';
  37453. t['\u3360'] = '\u0038\u70B9';
  37454. t['\u3361'] = '\u0039\u70B9';
  37455. t['\u3362'] = '\u0031\u0030\u70B9';
  37456. t['\u3363'] = '\u0031\u0031\u70B9';
  37457. t['\u3364'] = '\u0031\u0032\u70B9';
  37458. t['\u3365'] = '\u0031\u0033\u70B9';
  37459. t['\u3366'] = '\u0031\u0034\u70B9';
  37460. t['\u3367'] = '\u0031\u0035\u70B9';
  37461. t['\u3368'] = '\u0031\u0036\u70B9';
  37462. t['\u3369'] = '\u0031\u0037\u70B9';
  37463. t['\u336A'] = '\u0031\u0038\u70B9';
  37464. t['\u336B'] = '\u0031\u0039\u70B9';
  37465. t['\u336C'] = '\u0032\u0030\u70B9';
  37466. t['\u336D'] = '\u0032\u0031\u70B9';
  37467. t['\u336E'] = '\u0032\u0032\u70B9';
  37468. t['\u336F'] = '\u0032\u0033\u70B9';
  37469. t['\u3370'] = '\u0032\u0034\u70B9';
  37470. t['\u33E0'] = '\u0031\u65E5';
  37471. t['\u33E1'] = '\u0032\u65E5';
  37472. t['\u33E2'] = '\u0033\u65E5';
  37473. t['\u33E3'] = '\u0034\u65E5';
  37474. t['\u33E4'] = '\u0035\u65E5';
  37475. t['\u33E5'] = '\u0036\u65E5';
  37476. t['\u33E6'] = '\u0037\u65E5';
  37477. t['\u33E7'] = '\u0038\u65E5';
  37478. t['\u33E8'] = '\u0039\u65E5';
  37479. t['\u33E9'] = '\u0031\u0030\u65E5';
  37480. t['\u33EA'] = '\u0031\u0031\u65E5';
  37481. t['\u33EB'] = '\u0031\u0032\u65E5';
  37482. t['\u33EC'] = '\u0031\u0033\u65E5';
  37483. t['\u33ED'] = '\u0031\u0034\u65E5';
  37484. t['\u33EE'] = '\u0031\u0035\u65E5';
  37485. t['\u33EF'] = '\u0031\u0036\u65E5';
  37486. t['\u33F0'] = '\u0031\u0037\u65E5';
  37487. t['\u33F1'] = '\u0031\u0038\u65E5';
  37488. t['\u33F2'] = '\u0031\u0039\u65E5';
  37489. t['\u33F3'] = '\u0032\u0030\u65E5';
  37490. t['\u33F4'] = '\u0032\u0031\u65E5';
  37491. t['\u33F5'] = '\u0032\u0032\u65E5';
  37492. t['\u33F6'] = '\u0032\u0033\u65E5';
  37493. t['\u33F7'] = '\u0032\u0034\u65E5';
  37494. t['\u33F8'] = '\u0032\u0035\u65E5';
  37495. t['\u33F9'] = '\u0032\u0036\u65E5';
  37496. t['\u33FA'] = '\u0032\u0037\u65E5';
  37497. t['\u33FB'] = '\u0032\u0038\u65E5';
  37498. t['\u33FC'] = '\u0032\u0039\u65E5';
  37499. t['\u33FD'] = '\u0033\u0030\u65E5';
  37500. t['\u33FE'] = '\u0033\u0031\u65E5';
  37501. t['\uFB00'] = '\u0066\u0066';
  37502. t['\uFB01'] = '\u0066\u0069';
  37503. t['\uFB02'] = '\u0066\u006C';
  37504. t['\uFB03'] = '\u0066\u0066\u0069';
  37505. t['\uFB04'] = '\u0066\u0066\u006C';
  37506. t['\uFB05'] = '\u017F\u0074';
  37507. t['\uFB06'] = '\u0073\u0074';
  37508. t['\uFB13'] = '\u0574\u0576';
  37509. t['\uFB14'] = '\u0574\u0565';
  37510. t['\uFB15'] = '\u0574\u056B';
  37511. t['\uFB16'] = '\u057E\u0576';
  37512. t['\uFB17'] = '\u0574\u056D';
  37513. t['\uFB4F'] = '\u05D0\u05DC';
  37514. t['\uFB50'] = '\u0671';
  37515. t['\uFB51'] = '\u0671';
  37516. t['\uFB52'] = '\u067B';
  37517. t['\uFB53'] = '\u067B';
  37518. t['\uFB54'] = '\u067B';
  37519. t['\uFB55'] = '\u067B';
  37520. t['\uFB56'] = '\u067E';
  37521. t['\uFB57'] = '\u067E';
  37522. t['\uFB58'] = '\u067E';
  37523. t['\uFB59'] = '\u067E';
  37524. t['\uFB5A'] = '\u0680';
  37525. t['\uFB5B'] = '\u0680';
  37526. t['\uFB5C'] = '\u0680';
  37527. t['\uFB5D'] = '\u0680';
  37528. t['\uFB5E'] = '\u067A';
  37529. t['\uFB5F'] = '\u067A';
  37530. t['\uFB60'] = '\u067A';
  37531. t['\uFB61'] = '\u067A';
  37532. t['\uFB62'] = '\u067F';
  37533. t['\uFB63'] = '\u067F';
  37534. t['\uFB64'] = '\u067F';
  37535. t['\uFB65'] = '\u067F';
  37536. t['\uFB66'] = '\u0679';
  37537. t['\uFB67'] = '\u0679';
  37538. t['\uFB68'] = '\u0679';
  37539. t['\uFB69'] = '\u0679';
  37540. t['\uFB6A'] = '\u06A4';
  37541. t['\uFB6B'] = '\u06A4';
  37542. t['\uFB6C'] = '\u06A4';
  37543. t['\uFB6D'] = '\u06A4';
  37544. t['\uFB6E'] = '\u06A6';
  37545. t['\uFB6F'] = '\u06A6';
  37546. t['\uFB70'] = '\u06A6';
  37547. t['\uFB71'] = '\u06A6';
  37548. t['\uFB72'] = '\u0684';
  37549. t['\uFB73'] = '\u0684';
  37550. t['\uFB74'] = '\u0684';
  37551. t['\uFB75'] = '\u0684';
  37552. t['\uFB76'] = '\u0683';
  37553. t['\uFB77'] = '\u0683';
  37554. t['\uFB78'] = '\u0683';
  37555. t['\uFB79'] = '\u0683';
  37556. t['\uFB7A'] = '\u0686';
  37557. t['\uFB7B'] = '\u0686';
  37558. t['\uFB7C'] = '\u0686';
  37559. t['\uFB7D'] = '\u0686';
  37560. t['\uFB7E'] = '\u0687';
  37561. t['\uFB7F'] = '\u0687';
  37562. t['\uFB80'] = '\u0687';
  37563. t['\uFB81'] = '\u0687';
  37564. t['\uFB82'] = '\u068D';
  37565. t['\uFB83'] = '\u068D';
  37566. t['\uFB84'] = '\u068C';
  37567. t['\uFB85'] = '\u068C';
  37568. t['\uFB86'] = '\u068E';
  37569. t['\uFB87'] = '\u068E';
  37570. t['\uFB88'] = '\u0688';
  37571. t['\uFB89'] = '\u0688';
  37572. t['\uFB8A'] = '\u0698';
  37573. t['\uFB8B'] = '\u0698';
  37574. t['\uFB8C'] = '\u0691';
  37575. t['\uFB8D'] = '\u0691';
  37576. t['\uFB8E'] = '\u06A9';
  37577. t['\uFB8F'] = '\u06A9';
  37578. t['\uFB90'] = '\u06A9';
  37579. t['\uFB91'] = '\u06A9';
  37580. t['\uFB92'] = '\u06AF';
  37581. t['\uFB93'] = '\u06AF';
  37582. t['\uFB94'] = '\u06AF';
  37583. t['\uFB95'] = '\u06AF';
  37584. t['\uFB96'] = '\u06B3';
  37585. t['\uFB97'] = '\u06B3';
  37586. t['\uFB98'] = '\u06B3';
  37587. t['\uFB99'] = '\u06B3';
  37588. t['\uFB9A'] = '\u06B1';
  37589. t['\uFB9B'] = '\u06B1';
  37590. t['\uFB9C'] = '\u06B1';
  37591. t['\uFB9D'] = '\u06B1';
  37592. t['\uFB9E'] = '\u06BA';
  37593. t['\uFB9F'] = '\u06BA';
  37594. t['\uFBA0'] = '\u06BB';
  37595. t['\uFBA1'] = '\u06BB';
  37596. t['\uFBA2'] = '\u06BB';
  37597. t['\uFBA3'] = '\u06BB';
  37598. t['\uFBA4'] = '\u06C0';
  37599. t['\uFBA5'] = '\u06C0';
  37600. t['\uFBA6'] = '\u06C1';
  37601. t['\uFBA7'] = '\u06C1';
  37602. t['\uFBA8'] = '\u06C1';
  37603. t['\uFBA9'] = '\u06C1';
  37604. t['\uFBAA'] = '\u06BE';
  37605. t['\uFBAB'] = '\u06BE';
  37606. t['\uFBAC'] = '\u06BE';
  37607. t['\uFBAD'] = '\u06BE';
  37608. t['\uFBAE'] = '\u06D2';
  37609. t['\uFBAF'] = '\u06D2';
  37610. t['\uFBB0'] = '\u06D3';
  37611. t['\uFBB1'] = '\u06D3';
  37612. t['\uFBD3'] = '\u06AD';
  37613. t['\uFBD4'] = '\u06AD';
  37614. t['\uFBD5'] = '\u06AD';
  37615. t['\uFBD6'] = '\u06AD';
  37616. t['\uFBD7'] = '\u06C7';
  37617. t['\uFBD8'] = '\u06C7';
  37618. t['\uFBD9'] = '\u06C6';
  37619. t['\uFBDA'] = '\u06C6';
  37620. t['\uFBDB'] = '\u06C8';
  37621. t['\uFBDC'] = '\u06C8';
  37622. t['\uFBDD'] = '\u0677';
  37623. t['\uFBDE'] = '\u06CB';
  37624. t['\uFBDF'] = '\u06CB';
  37625. t['\uFBE0'] = '\u06C5';
  37626. t['\uFBE1'] = '\u06C5';
  37627. t['\uFBE2'] = '\u06C9';
  37628. t['\uFBE3'] = '\u06C9';
  37629. t['\uFBE4'] = '\u06D0';
  37630. t['\uFBE5'] = '\u06D0';
  37631. t['\uFBE6'] = '\u06D0';
  37632. t['\uFBE7'] = '\u06D0';
  37633. t['\uFBE8'] = '\u0649';
  37634. t['\uFBE9'] = '\u0649';
  37635. t['\uFBEA'] = '\u0626\u0627';
  37636. t['\uFBEB'] = '\u0626\u0627';
  37637. t['\uFBEC'] = '\u0626\u06D5';
  37638. t['\uFBED'] = '\u0626\u06D5';
  37639. t['\uFBEE'] = '\u0626\u0648';
  37640. t['\uFBEF'] = '\u0626\u0648';
  37641. t['\uFBF0'] = '\u0626\u06C7';
  37642. t['\uFBF1'] = '\u0626\u06C7';
  37643. t['\uFBF2'] = '\u0626\u06C6';
  37644. t['\uFBF3'] = '\u0626\u06C6';
  37645. t['\uFBF4'] = '\u0626\u06C8';
  37646. t['\uFBF5'] = '\u0626\u06C8';
  37647. t['\uFBF6'] = '\u0626\u06D0';
  37648. t['\uFBF7'] = '\u0626\u06D0';
  37649. t['\uFBF8'] = '\u0626\u06D0';
  37650. t['\uFBF9'] = '\u0626\u0649';
  37651. t['\uFBFA'] = '\u0626\u0649';
  37652. t['\uFBFB'] = '\u0626\u0649';
  37653. t['\uFBFC'] = '\u06CC';
  37654. t['\uFBFD'] = '\u06CC';
  37655. t['\uFBFE'] = '\u06CC';
  37656. t['\uFBFF'] = '\u06CC';
  37657. t['\uFC00'] = '\u0626\u062C';
  37658. t['\uFC01'] = '\u0626\u062D';
  37659. t['\uFC02'] = '\u0626\u0645';
  37660. t['\uFC03'] = '\u0626\u0649';
  37661. t['\uFC04'] = '\u0626\u064A';
  37662. t['\uFC05'] = '\u0628\u062C';
  37663. t['\uFC06'] = '\u0628\u062D';
  37664. t['\uFC07'] = '\u0628\u062E';
  37665. t['\uFC08'] = '\u0628\u0645';
  37666. t['\uFC09'] = '\u0628\u0649';
  37667. t['\uFC0A'] = '\u0628\u064A';
  37668. t['\uFC0B'] = '\u062A\u062C';
  37669. t['\uFC0C'] = '\u062A\u062D';
  37670. t['\uFC0D'] = '\u062A\u062E';
  37671. t['\uFC0E'] = '\u062A\u0645';
  37672. t['\uFC0F'] = '\u062A\u0649';
  37673. t['\uFC10'] = '\u062A\u064A';
  37674. t['\uFC11'] = '\u062B\u062C';
  37675. t['\uFC12'] = '\u062B\u0645';
  37676. t['\uFC13'] = '\u062B\u0649';
  37677. t['\uFC14'] = '\u062B\u064A';
  37678. t['\uFC15'] = '\u062C\u062D';
  37679. t['\uFC16'] = '\u062C\u0645';
  37680. t['\uFC17'] = '\u062D\u062C';
  37681. t['\uFC18'] = '\u062D\u0645';
  37682. t['\uFC19'] = '\u062E\u062C';
  37683. t['\uFC1A'] = '\u062E\u062D';
  37684. t['\uFC1B'] = '\u062E\u0645';
  37685. t['\uFC1C'] = '\u0633\u062C';
  37686. t['\uFC1D'] = '\u0633\u062D';
  37687. t['\uFC1E'] = '\u0633\u062E';
  37688. t['\uFC1F'] = '\u0633\u0645';
  37689. t['\uFC20'] = '\u0635\u062D';
  37690. t['\uFC21'] = '\u0635\u0645';
  37691. t['\uFC22'] = '\u0636\u062C';
  37692. t['\uFC23'] = '\u0636\u062D';
  37693. t['\uFC24'] = '\u0636\u062E';
  37694. t['\uFC25'] = '\u0636\u0645';
  37695. t['\uFC26'] = '\u0637\u062D';
  37696. t['\uFC27'] = '\u0637\u0645';
  37697. t['\uFC28'] = '\u0638\u0645';
  37698. t['\uFC29'] = '\u0639\u062C';
  37699. t['\uFC2A'] = '\u0639\u0645';
  37700. t['\uFC2B'] = '\u063A\u062C';
  37701. t['\uFC2C'] = '\u063A\u0645';
  37702. t['\uFC2D'] = '\u0641\u062C';
  37703. t['\uFC2E'] = '\u0641\u062D';
  37704. t['\uFC2F'] = '\u0641\u062E';
  37705. t['\uFC30'] = '\u0641\u0645';
  37706. t['\uFC31'] = '\u0641\u0649';
  37707. t['\uFC32'] = '\u0641\u064A';
  37708. t['\uFC33'] = '\u0642\u062D';
  37709. t['\uFC34'] = '\u0642\u0645';
  37710. t['\uFC35'] = '\u0642\u0649';
  37711. t['\uFC36'] = '\u0642\u064A';
  37712. t['\uFC37'] = '\u0643\u0627';
  37713. t['\uFC38'] = '\u0643\u062C';
  37714. t['\uFC39'] = '\u0643\u062D';
  37715. t['\uFC3A'] = '\u0643\u062E';
  37716. t['\uFC3B'] = '\u0643\u0644';
  37717. t['\uFC3C'] = '\u0643\u0645';
  37718. t['\uFC3D'] = '\u0643\u0649';
  37719. t['\uFC3E'] = '\u0643\u064A';
  37720. t['\uFC3F'] = '\u0644\u062C';
  37721. t['\uFC40'] = '\u0644\u062D';
  37722. t['\uFC41'] = '\u0644\u062E';
  37723. t['\uFC42'] = '\u0644\u0645';
  37724. t['\uFC43'] = '\u0644\u0649';
  37725. t['\uFC44'] = '\u0644\u064A';
  37726. t['\uFC45'] = '\u0645\u062C';
  37727. t['\uFC46'] = '\u0645\u062D';
  37728. t['\uFC47'] = '\u0645\u062E';
  37729. t['\uFC48'] = '\u0645\u0645';
  37730. t['\uFC49'] = '\u0645\u0649';
  37731. t['\uFC4A'] = '\u0645\u064A';
  37732. t['\uFC4B'] = '\u0646\u062C';
  37733. t['\uFC4C'] = '\u0646\u062D';
  37734. t['\uFC4D'] = '\u0646\u062E';
  37735. t['\uFC4E'] = '\u0646\u0645';
  37736. t['\uFC4F'] = '\u0646\u0649';
  37737. t['\uFC50'] = '\u0646\u064A';
  37738. t['\uFC51'] = '\u0647\u062C';
  37739. t['\uFC52'] = '\u0647\u0645';
  37740. t['\uFC53'] = '\u0647\u0649';
  37741. t['\uFC54'] = '\u0647\u064A';
  37742. t['\uFC55'] = '\u064A\u062C';
  37743. t['\uFC56'] = '\u064A\u062D';
  37744. t['\uFC57'] = '\u064A\u062E';
  37745. t['\uFC58'] = '\u064A\u0645';
  37746. t['\uFC59'] = '\u064A\u0649';
  37747. t['\uFC5A'] = '\u064A\u064A';
  37748. t['\uFC5B'] = '\u0630\u0670';
  37749. t['\uFC5C'] = '\u0631\u0670';
  37750. t['\uFC5D'] = '\u0649\u0670';
  37751. t['\uFC5E'] = '\u0020\u064C\u0651';
  37752. t['\uFC5F'] = '\u0020\u064D\u0651';
  37753. t['\uFC60'] = '\u0020\u064E\u0651';
  37754. t['\uFC61'] = '\u0020\u064F\u0651';
  37755. t['\uFC62'] = '\u0020\u0650\u0651';
  37756. t['\uFC63'] = '\u0020\u0651\u0670';
  37757. t['\uFC64'] = '\u0626\u0631';
  37758. t['\uFC65'] = '\u0626\u0632';
  37759. t['\uFC66'] = '\u0626\u0645';
  37760. t['\uFC67'] = '\u0626\u0646';
  37761. t['\uFC68'] = '\u0626\u0649';
  37762. t['\uFC69'] = '\u0626\u064A';
  37763. t['\uFC6A'] = '\u0628\u0631';
  37764. t['\uFC6B'] = '\u0628\u0632';
  37765. t['\uFC6C'] = '\u0628\u0645';
  37766. t['\uFC6D'] = '\u0628\u0646';
  37767. t['\uFC6E'] = '\u0628\u0649';
  37768. t['\uFC6F'] = '\u0628\u064A';
  37769. t['\uFC70'] = '\u062A\u0631';
  37770. t['\uFC71'] = '\u062A\u0632';
  37771. t['\uFC72'] = '\u062A\u0645';
  37772. t['\uFC73'] = '\u062A\u0646';
  37773. t['\uFC74'] = '\u062A\u0649';
  37774. t['\uFC75'] = '\u062A\u064A';
  37775. t['\uFC76'] = '\u062B\u0631';
  37776. t['\uFC77'] = '\u062B\u0632';
  37777. t['\uFC78'] = '\u062B\u0645';
  37778. t['\uFC79'] = '\u062B\u0646';
  37779. t['\uFC7A'] = '\u062B\u0649';
  37780. t['\uFC7B'] = '\u062B\u064A';
  37781. t['\uFC7C'] = '\u0641\u0649';
  37782. t['\uFC7D'] = '\u0641\u064A';
  37783. t['\uFC7E'] = '\u0642\u0649';
  37784. t['\uFC7F'] = '\u0642\u064A';
  37785. t['\uFC80'] = '\u0643\u0627';
  37786. t['\uFC81'] = '\u0643\u0644';
  37787. t['\uFC82'] = '\u0643\u0645';
  37788. t['\uFC83'] = '\u0643\u0649';
  37789. t['\uFC84'] = '\u0643\u064A';
  37790. t['\uFC85'] = '\u0644\u0645';
  37791. t['\uFC86'] = '\u0644\u0649';
  37792. t['\uFC87'] = '\u0644\u064A';
  37793. t['\uFC88'] = '\u0645\u0627';
  37794. t['\uFC89'] = '\u0645\u0645';
  37795. t['\uFC8A'] = '\u0646\u0631';
  37796. t['\uFC8B'] = '\u0646\u0632';
  37797. t['\uFC8C'] = '\u0646\u0645';
  37798. t['\uFC8D'] = '\u0646\u0646';
  37799. t['\uFC8E'] = '\u0646\u0649';
  37800. t['\uFC8F'] = '\u0646\u064A';
  37801. t['\uFC90'] = '\u0649\u0670';
  37802. t['\uFC91'] = '\u064A\u0631';
  37803. t['\uFC92'] = '\u064A\u0632';
  37804. t['\uFC93'] = '\u064A\u0645';
  37805. t['\uFC94'] = '\u064A\u0646';
  37806. t['\uFC95'] = '\u064A\u0649';
  37807. t['\uFC96'] = '\u064A\u064A';
  37808. t['\uFC97'] = '\u0626\u062C';
  37809. t['\uFC98'] = '\u0626\u062D';
  37810. t['\uFC99'] = '\u0626\u062E';
  37811. t['\uFC9A'] = '\u0626\u0645';
  37812. t['\uFC9B'] = '\u0626\u0647';
  37813. t['\uFC9C'] = '\u0628\u062C';
  37814. t['\uFC9D'] = '\u0628\u062D';
  37815. t['\uFC9E'] = '\u0628\u062E';
  37816. t['\uFC9F'] = '\u0628\u0645';
  37817. t['\uFCA0'] = '\u0628\u0647';
  37818. t['\uFCA1'] = '\u062A\u062C';
  37819. t['\uFCA2'] = '\u062A\u062D';
  37820. t['\uFCA3'] = '\u062A\u062E';
  37821. t['\uFCA4'] = '\u062A\u0645';
  37822. t['\uFCA5'] = '\u062A\u0647';
  37823. t['\uFCA6'] = '\u062B\u0645';
  37824. t['\uFCA7'] = '\u062C\u062D';
  37825. t['\uFCA8'] = '\u062C\u0645';
  37826. t['\uFCA9'] = '\u062D\u062C';
  37827. t['\uFCAA'] = '\u062D\u0645';
  37828. t['\uFCAB'] = '\u062E\u062C';
  37829. t['\uFCAC'] = '\u062E\u0645';
  37830. t['\uFCAD'] = '\u0633\u062C';
  37831. t['\uFCAE'] = '\u0633\u062D';
  37832. t['\uFCAF'] = '\u0633\u062E';
  37833. t['\uFCB0'] = '\u0633\u0645';
  37834. t['\uFCB1'] = '\u0635\u062D';
  37835. t['\uFCB2'] = '\u0635\u062E';
  37836. t['\uFCB3'] = '\u0635\u0645';
  37837. t['\uFCB4'] = '\u0636\u062C';
  37838. t['\uFCB5'] = '\u0636\u062D';
  37839. t['\uFCB6'] = '\u0636\u062E';
  37840. t['\uFCB7'] = '\u0636\u0645';
  37841. t['\uFCB8'] = '\u0637\u062D';
  37842. t['\uFCB9'] = '\u0638\u0645';
  37843. t['\uFCBA'] = '\u0639\u062C';
  37844. t['\uFCBB'] = '\u0639\u0645';
  37845. t['\uFCBC'] = '\u063A\u062C';
  37846. t['\uFCBD'] = '\u063A\u0645';
  37847. t['\uFCBE'] = '\u0641\u062C';
  37848. t['\uFCBF'] = '\u0641\u062D';
  37849. t['\uFCC0'] = '\u0641\u062E';
  37850. t['\uFCC1'] = '\u0641\u0645';
  37851. t['\uFCC2'] = '\u0642\u062D';
  37852. t['\uFCC3'] = '\u0642\u0645';
  37853. t['\uFCC4'] = '\u0643\u062C';
  37854. t['\uFCC5'] = '\u0643\u062D';
  37855. t['\uFCC6'] = '\u0643\u062E';
  37856. t['\uFCC7'] = '\u0643\u0644';
  37857. t['\uFCC8'] = '\u0643\u0645';
  37858. t['\uFCC9'] = '\u0644\u062C';
  37859. t['\uFCCA'] = '\u0644\u062D';
  37860. t['\uFCCB'] = '\u0644\u062E';
  37861. t['\uFCCC'] = '\u0644\u0645';
  37862. t['\uFCCD'] = '\u0644\u0647';
  37863. t['\uFCCE'] = '\u0645\u062C';
  37864. t['\uFCCF'] = '\u0645\u062D';
  37865. t['\uFCD0'] = '\u0645\u062E';
  37866. t['\uFCD1'] = '\u0645\u0645';
  37867. t['\uFCD2'] = '\u0646\u062C';
  37868. t['\uFCD3'] = '\u0646\u062D';
  37869. t['\uFCD4'] = '\u0646\u062E';
  37870. t['\uFCD5'] = '\u0646\u0645';
  37871. t['\uFCD6'] = '\u0646\u0647';
  37872. t['\uFCD7'] = '\u0647\u062C';
  37873. t['\uFCD8'] = '\u0647\u0645';
  37874. t['\uFCD9'] = '\u0647\u0670';
  37875. t['\uFCDA'] = '\u064A\u062C';
  37876. t['\uFCDB'] = '\u064A\u062D';
  37877. t['\uFCDC'] = '\u064A\u062E';
  37878. t['\uFCDD'] = '\u064A\u0645';
  37879. t['\uFCDE'] = '\u064A\u0647';
  37880. t['\uFCDF'] = '\u0626\u0645';
  37881. t['\uFCE0'] = '\u0626\u0647';
  37882. t['\uFCE1'] = '\u0628\u0645';
  37883. t['\uFCE2'] = '\u0628\u0647';
  37884. t['\uFCE3'] = '\u062A\u0645';
  37885. t['\uFCE4'] = '\u062A\u0647';
  37886. t['\uFCE5'] = '\u062B\u0645';
  37887. t['\uFCE6'] = '\u062B\u0647';
  37888. t['\uFCE7'] = '\u0633\u0645';
  37889. t['\uFCE8'] = '\u0633\u0647';
  37890. t['\uFCE9'] = '\u0634\u0645';
  37891. t['\uFCEA'] = '\u0634\u0647';
  37892. t['\uFCEB'] = '\u0643\u0644';
  37893. t['\uFCEC'] = '\u0643\u0645';
  37894. t['\uFCED'] = '\u0644\u0645';
  37895. t['\uFCEE'] = '\u0646\u0645';
  37896. t['\uFCEF'] = '\u0646\u0647';
  37897. t['\uFCF0'] = '\u064A\u0645';
  37898. t['\uFCF1'] = '\u064A\u0647';
  37899. t['\uFCF2'] = '\u0640\u064E\u0651';
  37900. t['\uFCF3'] = '\u0640\u064F\u0651';
  37901. t['\uFCF4'] = '\u0640\u0650\u0651';
  37902. t['\uFCF5'] = '\u0637\u0649';
  37903. t['\uFCF6'] = '\u0637\u064A';
  37904. t['\uFCF7'] = '\u0639\u0649';
  37905. t['\uFCF8'] = '\u0639\u064A';
  37906. t['\uFCF9'] = '\u063A\u0649';
  37907. t['\uFCFA'] = '\u063A\u064A';
  37908. t['\uFCFB'] = '\u0633\u0649';
  37909. t['\uFCFC'] = '\u0633\u064A';
  37910. t['\uFCFD'] = '\u0634\u0649';
  37911. t['\uFCFE'] = '\u0634\u064A';
  37912. t['\uFCFF'] = '\u062D\u0649';
  37913. t['\uFD00'] = '\u062D\u064A';
  37914. t['\uFD01'] = '\u062C\u0649';
  37915. t['\uFD02'] = '\u062C\u064A';
  37916. t['\uFD03'] = '\u062E\u0649';
  37917. t['\uFD04'] = '\u062E\u064A';
  37918. t['\uFD05'] = '\u0635\u0649';
  37919. t['\uFD06'] = '\u0635\u064A';
  37920. t['\uFD07'] = '\u0636\u0649';
  37921. t['\uFD08'] = '\u0636\u064A';
  37922. t['\uFD09'] = '\u0634\u062C';
  37923. t['\uFD0A'] = '\u0634\u062D';
  37924. t['\uFD0B'] = '\u0634\u062E';
  37925. t['\uFD0C'] = '\u0634\u0645';
  37926. t['\uFD0D'] = '\u0634\u0631';
  37927. t['\uFD0E'] = '\u0633\u0631';
  37928. t['\uFD0F'] = '\u0635\u0631';
  37929. t['\uFD10'] = '\u0636\u0631';
  37930. t['\uFD11'] = '\u0637\u0649';
  37931. t['\uFD12'] = '\u0637\u064A';
  37932. t['\uFD13'] = '\u0639\u0649';
  37933. t['\uFD14'] = '\u0639\u064A';
  37934. t['\uFD15'] = '\u063A\u0649';
  37935. t['\uFD16'] = '\u063A\u064A';
  37936. t['\uFD17'] = '\u0633\u0649';
  37937. t['\uFD18'] = '\u0633\u064A';
  37938. t['\uFD19'] = '\u0634\u0649';
  37939. t['\uFD1A'] = '\u0634\u064A';
  37940. t['\uFD1B'] = '\u062D\u0649';
  37941. t['\uFD1C'] = '\u062D\u064A';
  37942. t['\uFD1D'] = '\u062C\u0649';
  37943. t['\uFD1E'] = '\u062C\u064A';
  37944. t['\uFD1F'] = '\u062E\u0649';
  37945. t['\uFD20'] = '\u062E\u064A';
  37946. t['\uFD21'] = '\u0635\u0649';
  37947. t['\uFD22'] = '\u0635\u064A';
  37948. t['\uFD23'] = '\u0636\u0649';
  37949. t['\uFD24'] = '\u0636\u064A';
  37950. t['\uFD25'] = '\u0634\u062C';
  37951. t['\uFD26'] = '\u0634\u062D';
  37952. t['\uFD27'] = '\u0634\u062E';
  37953. t['\uFD28'] = '\u0634\u0645';
  37954. t['\uFD29'] = '\u0634\u0631';
  37955. t['\uFD2A'] = '\u0633\u0631';
  37956. t['\uFD2B'] = '\u0635\u0631';
  37957. t['\uFD2C'] = '\u0636\u0631';
  37958. t['\uFD2D'] = '\u0634\u062C';
  37959. t['\uFD2E'] = '\u0634\u062D';
  37960. t['\uFD2F'] = '\u0634\u062E';
  37961. t['\uFD30'] = '\u0634\u0645';
  37962. t['\uFD31'] = '\u0633\u0647';
  37963. t['\uFD32'] = '\u0634\u0647';
  37964. t['\uFD33'] = '\u0637\u0645';
  37965. t['\uFD34'] = '\u0633\u062C';
  37966. t['\uFD35'] = '\u0633\u062D';
  37967. t['\uFD36'] = '\u0633\u062E';
  37968. t['\uFD37'] = '\u0634\u062C';
  37969. t['\uFD38'] = '\u0634\u062D';
  37970. t['\uFD39'] = '\u0634\u062E';
  37971. t['\uFD3A'] = '\u0637\u0645';
  37972. t['\uFD3B'] = '\u0638\u0645';
  37973. t['\uFD3C'] = '\u0627\u064B';
  37974. t['\uFD3D'] = '\u0627\u064B';
  37975. t['\uFD50'] = '\u062A\u062C\u0645';
  37976. t['\uFD51'] = '\u062A\u062D\u062C';
  37977. t['\uFD52'] = '\u062A\u062D\u062C';
  37978. t['\uFD53'] = '\u062A\u062D\u0645';
  37979. t['\uFD54'] = '\u062A\u062E\u0645';
  37980. t['\uFD55'] = '\u062A\u0645\u062C';
  37981. t['\uFD56'] = '\u062A\u0645\u062D';
  37982. t['\uFD57'] = '\u062A\u0645\u062E';
  37983. t['\uFD58'] = '\u062C\u0645\u062D';
  37984. t['\uFD59'] = '\u062C\u0645\u062D';
  37985. t['\uFD5A'] = '\u062D\u0645\u064A';
  37986. t['\uFD5B'] = '\u062D\u0645\u0649';
  37987. t['\uFD5C'] = '\u0633\u062D\u062C';
  37988. t['\uFD5D'] = '\u0633\u062C\u062D';
  37989. t['\uFD5E'] = '\u0633\u062C\u0649';
  37990. t['\uFD5F'] = '\u0633\u0645\u062D';
  37991. t['\uFD60'] = '\u0633\u0645\u062D';
  37992. t['\uFD61'] = '\u0633\u0645\u062C';
  37993. t['\uFD62'] = '\u0633\u0645\u0645';
  37994. t['\uFD63'] = '\u0633\u0645\u0645';
  37995. t['\uFD64'] = '\u0635\u062D\u062D';
  37996. t['\uFD65'] = '\u0635\u062D\u062D';
  37997. t['\uFD66'] = '\u0635\u0645\u0645';
  37998. t['\uFD67'] = '\u0634\u062D\u0645';
  37999. t['\uFD68'] = '\u0634\u062D\u0645';
  38000. t['\uFD69'] = '\u0634\u062C\u064A';
  38001. t['\uFD6A'] = '\u0634\u0645\u062E';
  38002. t['\uFD6B'] = '\u0634\u0645\u062E';
  38003. t['\uFD6C'] = '\u0634\u0645\u0645';
  38004. t['\uFD6D'] = '\u0634\u0645\u0645';
  38005. t['\uFD6E'] = '\u0636\u062D\u0649';
  38006. t['\uFD6F'] = '\u0636\u062E\u0645';
  38007. t['\uFD70'] = '\u0636\u062E\u0645';
  38008. t['\uFD71'] = '\u0637\u0645\u062D';
  38009. t['\uFD72'] = '\u0637\u0645\u062D';
  38010. t['\uFD73'] = '\u0637\u0645\u0645';
  38011. t['\uFD74'] = '\u0637\u0645\u064A';
  38012. t['\uFD75'] = '\u0639\u062C\u0645';
  38013. t['\uFD76'] = '\u0639\u0645\u0645';
  38014. t['\uFD77'] = '\u0639\u0645\u0645';
  38015. t['\uFD78'] = '\u0639\u0645\u0649';
  38016. t['\uFD79'] = '\u063A\u0645\u0645';
  38017. t['\uFD7A'] = '\u063A\u0645\u064A';
  38018. t['\uFD7B'] = '\u063A\u0645\u0649';
  38019. t['\uFD7C'] = '\u0641\u062E\u0645';
  38020. t['\uFD7D'] = '\u0641\u062E\u0645';
  38021. t['\uFD7E'] = '\u0642\u0645\u062D';
  38022. t['\uFD7F'] = '\u0642\u0645\u0645';
  38023. t['\uFD80'] = '\u0644\u062D\u0645';
  38024. t['\uFD81'] = '\u0644\u062D\u064A';
  38025. t['\uFD82'] = '\u0644\u062D\u0649';
  38026. t['\uFD83'] = '\u0644\u062C\u062C';
  38027. t['\uFD84'] = '\u0644\u062C\u062C';
  38028. t['\uFD85'] = '\u0644\u062E\u0645';
  38029. t['\uFD86'] = '\u0644\u062E\u0645';
  38030. t['\uFD87'] = '\u0644\u0645\u062D';
  38031. t['\uFD88'] = '\u0644\u0645\u062D';
  38032. t['\uFD89'] = '\u0645\u062D\u062C';
  38033. t['\uFD8A'] = '\u0645\u062D\u0645';
  38034. t['\uFD8B'] = '\u0645\u062D\u064A';
  38035. t['\uFD8C'] = '\u0645\u062C\u062D';
  38036. t['\uFD8D'] = '\u0645\u062C\u0645';
  38037. t['\uFD8E'] = '\u0645\u062E\u062C';
  38038. t['\uFD8F'] = '\u0645\u062E\u0645';
  38039. t['\uFD92'] = '\u0645\u062C\u062E';
  38040. t['\uFD93'] = '\u0647\u0645\u062C';
  38041. t['\uFD94'] = '\u0647\u0645\u0645';
  38042. t['\uFD95'] = '\u0646\u062D\u0645';
  38043. t['\uFD96'] = '\u0646\u062D\u0649';
  38044. t['\uFD97'] = '\u0646\u062C\u0645';
  38045. t['\uFD98'] = '\u0646\u062C\u0645';
  38046. t['\uFD99'] = '\u0646\u062C\u0649';
  38047. t['\uFD9A'] = '\u0646\u0645\u064A';
  38048. t['\uFD9B'] = '\u0646\u0645\u0649';
  38049. t['\uFD9C'] = '\u064A\u0645\u0645';
  38050. t['\uFD9D'] = '\u064A\u0645\u0645';
  38051. t['\uFD9E'] = '\u0628\u062E\u064A';
  38052. t['\uFD9F'] = '\u062A\u062C\u064A';
  38053. t['\uFDA0'] = '\u062A\u062C\u0649';
  38054. t['\uFDA1'] = '\u062A\u062E\u064A';
  38055. t['\uFDA2'] = '\u062A\u062E\u0649';
  38056. t['\uFDA3'] = '\u062A\u0645\u064A';
  38057. t['\uFDA4'] = '\u062A\u0645\u0649';
  38058. t['\uFDA5'] = '\u062C\u0645\u064A';
  38059. t['\uFDA6'] = '\u062C\u062D\u0649';
  38060. t['\uFDA7'] = '\u062C\u0645\u0649';
  38061. t['\uFDA8'] = '\u0633\u062E\u0649';
  38062. t['\uFDA9'] = '\u0635\u062D\u064A';
  38063. t['\uFDAA'] = '\u0634\u062D\u064A';
  38064. t['\uFDAB'] = '\u0636\u062D\u064A';
  38065. t['\uFDAC'] = '\u0644\u062C\u064A';
  38066. t['\uFDAD'] = '\u0644\u0645\u064A';
  38067. t['\uFDAE'] = '\u064A\u062D\u064A';
  38068. t['\uFDAF'] = '\u064A\u062C\u064A';
  38069. t['\uFDB0'] = '\u064A\u0645\u064A';
  38070. t['\uFDB1'] = '\u0645\u0645\u064A';
  38071. t['\uFDB2'] = '\u0642\u0645\u064A';
  38072. t['\uFDB3'] = '\u0646\u062D\u064A';
  38073. t['\uFDB4'] = '\u0642\u0645\u062D';
  38074. t['\uFDB5'] = '\u0644\u062D\u0645';
  38075. t['\uFDB6'] = '\u0639\u0645\u064A';
  38076. t['\uFDB7'] = '\u0643\u0645\u064A';
  38077. t['\uFDB8'] = '\u0646\u062C\u062D';
  38078. t['\uFDB9'] = '\u0645\u062E\u064A';
  38079. t['\uFDBA'] = '\u0644\u062C\u0645';
  38080. t['\uFDBB'] = '\u0643\u0645\u0645';
  38081. t['\uFDBC'] = '\u0644\u062C\u0645';
  38082. t['\uFDBD'] = '\u0646\u062C\u062D';
  38083. t['\uFDBE'] = '\u062C\u062D\u064A';
  38084. t['\uFDBF'] = '\u062D\u062C\u064A';
  38085. t['\uFDC0'] = '\u0645\u062C\u064A';
  38086. t['\uFDC1'] = '\u0641\u0645\u064A';
  38087. t['\uFDC2'] = '\u0628\u062D\u064A';
  38088. t['\uFDC3'] = '\u0643\u0645\u0645';
  38089. t['\uFDC4'] = '\u0639\u062C\u0645';
  38090. t['\uFDC5'] = '\u0635\u0645\u0645';
  38091. t['\uFDC6'] = '\u0633\u062E\u064A';
  38092. t['\uFDC7'] = '\u0646\u062C\u064A';
  38093. t['\uFE49'] = '\u203E';
  38094. t['\uFE4A'] = '\u203E';
  38095. t['\uFE4B'] = '\u203E';
  38096. t['\uFE4C'] = '\u203E';
  38097. t['\uFE4D'] = '\u005F';
  38098. t['\uFE4E'] = '\u005F';
  38099. t['\uFE4F'] = '\u005F';
  38100. t['\uFE80'] = '\u0621';
  38101. t['\uFE81'] = '\u0622';
  38102. t['\uFE82'] = '\u0622';
  38103. t['\uFE83'] = '\u0623';
  38104. t['\uFE84'] = '\u0623';
  38105. t['\uFE85'] = '\u0624';
  38106. t['\uFE86'] = '\u0624';
  38107. t['\uFE87'] = '\u0625';
  38108. t['\uFE88'] = '\u0625';
  38109. t['\uFE89'] = '\u0626';
  38110. t['\uFE8A'] = '\u0626';
  38111. t['\uFE8B'] = '\u0626';
  38112. t['\uFE8C'] = '\u0626';
  38113. t['\uFE8D'] = '\u0627';
  38114. t['\uFE8E'] = '\u0627';
  38115. t['\uFE8F'] = '\u0628';
  38116. t['\uFE90'] = '\u0628';
  38117. t['\uFE91'] = '\u0628';
  38118. t['\uFE92'] = '\u0628';
  38119. t['\uFE93'] = '\u0629';
  38120. t['\uFE94'] = '\u0629';
  38121. t['\uFE95'] = '\u062A';
  38122. t['\uFE96'] = '\u062A';
  38123. t['\uFE97'] = '\u062A';
  38124. t['\uFE98'] = '\u062A';
  38125. t['\uFE99'] = '\u062B';
  38126. t['\uFE9A'] = '\u062B';
  38127. t['\uFE9B'] = '\u062B';
  38128. t['\uFE9C'] = '\u062B';
  38129. t['\uFE9D'] = '\u062C';
  38130. t['\uFE9E'] = '\u062C';
  38131. t['\uFE9F'] = '\u062C';
  38132. t['\uFEA0'] = '\u062C';
  38133. t['\uFEA1'] = '\u062D';
  38134. t['\uFEA2'] = '\u062D';
  38135. t['\uFEA3'] = '\u062D';
  38136. t['\uFEA4'] = '\u062D';
  38137. t['\uFEA5'] = '\u062E';
  38138. t['\uFEA6'] = '\u062E';
  38139. t['\uFEA7'] = '\u062E';
  38140. t['\uFEA8'] = '\u062E';
  38141. t['\uFEA9'] = '\u062F';
  38142. t['\uFEAA'] = '\u062F';
  38143. t['\uFEAB'] = '\u0630';
  38144. t['\uFEAC'] = '\u0630';
  38145. t['\uFEAD'] = '\u0631';
  38146. t['\uFEAE'] = '\u0631';
  38147. t['\uFEAF'] = '\u0632';
  38148. t['\uFEB0'] = '\u0632';
  38149. t['\uFEB1'] = '\u0633';
  38150. t['\uFEB2'] = '\u0633';
  38151. t['\uFEB3'] = '\u0633';
  38152. t['\uFEB4'] = '\u0633';
  38153. t['\uFEB5'] = '\u0634';
  38154. t['\uFEB6'] = '\u0634';
  38155. t['\uFEB7'] = '\u0634';
  38156. t['\uFEB8'] = '\u0634';
  38157. t['\uFEB9'] = '\u0635';
  38158. t['\uFEBA'] = '\u0635';
  38159. t['\uFEBB'] = '\u0635';
  38160. t['\uFEBC'] = '\u0635';
  38161. t['\uFEBD'] = '\u0636';
  38162. t['\uFEBE'] = '\u0636';
  38163. t['\uFEBF'] = '\u0636';
  38164. t['\uFEC0'] = '\u0636';
  38165. t['\uFEC1'] = '\u0637';
  38166. t['\uFEC2'] = '\u0637';
  38167. t['\uFEC3'] = '\u0637';
  38168. t['\uFEC4'] = '\u0637';
  38169. t['\uFEC5'] = '\u0638';
  38170. t['\uFEC6'] = '\u0638';
  38171. t['\uFEC7'] = '\u0638';
  38172. t['\uFEC8'] = '\u0638';
  38173. t['\uFEC9'] = '\u0639';
  38174. t['\uFECA'] = '\u0639';
  38175. t['\uFECB'] = '\u0639';
  38176. t['\uFECC'] = '\u0639';
  38177. t['\uFECD'] = '\u063A';
  38178. t['\uFECE'] = '\u063A';
  38179. t['\uFECF'] = '\u063A';
  38180. t['\uFED0'] = '\u063A';
  38181. t['\uFED1'] = '\u0641';
  38182. t['\uFED2'] = '\u0641';
  38183. t['\uFED3'] = '\u0641';
  38184. t['\uFED4'] = '\u0641';
  38185. t['\uFED5'] = '\u0642';
  38186. t['\uFED6'] = '\u0642';
  38187. t['\uFED7'] = '\u0642';
  38188. t['\uFED8'] = '\u0642';
  38189. t['\uFED9'] = '\u0643';
  38190. t['\uFEDA'] = '\u0643';
  38191. t['\uFEDB'] = '\u0643';
  38192. t['\uFEDC'] = '\u0643';
  38193. t['\uFEDD'] = '\u0644';
  38194. t['\uFEDE'] = '\u0644';
  38195. t['\uFEDF'] = '\u0644';
  38196. t['\uFEE0'] = '\u0644';
  38197. t['\uFEE1'] = '\u0645';
  38198. t['\uFEE2'] = '\u0645';
  38199. t['\uFEE3'] = '\u0645';
  38200. t['\uFEE4'] = '\u0645';
  38201. t['\uFEE5'] = '\u0646';
  38202. t['\uFEE6'] = '\u0646';
  38203. t['\uFEE7'] = '\u0646';
  38204. t['\uFEE8'] = '\u0646';
  38205. t['\uFEE9'] = '\u0647';
  38206. t['\uFEEA'] = '\u0647';
  38207. t['\uFEEB'] = '\u0647';
  38208. t['\uFEEC'] = '\u0647';
  38209. t['\uFEED'] = '\u0648';
  38210. t['\uFEEE'] = '\u0648';
  38211. t['\uFEEF'] = '\u0649';
  38212. t['\uFEF0'] = '\u0649';
  38213. t['\uFEF1'] = '\u064A';
  38214. t['\uFEF2'] = '\u064A';
  38215. t['\uFEF3'] = '\u064A';
  38216. t['\uFEF4'] = '\u064A';
  38217. t['\uFEF5'] = '\u0644\u0622';
  38218. t['\uFEF6'] = '\u0644\u0622';
  38219. t['\uFEF7'] = '\u0644\u0623';
  38220. t['\uFEF8'] = '\u0644\u0623';
  38221. t['\uFEF9'] = '\u0644\u0625';
  38222. t['\uFEFA'] = '\u0644\u0625';
  38223. t['\uFEFB'] = '\u0644\u0627';
  38224. t['\uFEFC'] = '\u0644\u0627';
  38225. });
  38226. function reverseIfRtl(chars) {
  38227. var charsLength = chars.length;
  38228. if (charsLength <= 1 || !isRTLRangeFor(chars.charCodeAt(0))) {
  38229. return chars;
  38230. }
  38231. var s = '';
  38232. for (var ii = charsLength - 1; ii >= 0; ii--) {
  38233. s += chars[ii];
  38234. }
  38235. return s;
  38236. }
  38237. exports.mapSpecialUnicodeValues = mapSpecialUnicodeValues;
  38238. exports.reverseIfRtl = reverseIfRtl;
  38239. exports.getUnicodeRangeFor = getUnicodeRangeFor;
  38240. exports.getNormalizedUnicodes = getNormalizedUnicodes;
  38241. exports.getUnicodeForGlyph = getUnicodeForGlyph;
  38242. /***/ }),
  38243. /* 22 */
  38244. /***/ (function(module, exports, __w_pdfjs_require__) {
  38245. "use strict";
  38246. /* WEBPACK VAR INJECTION */(function(module) {
  38247. var sharedUtil = __w_pdfjs_require__(0);
  38248. var corePrimitives = __w_pdfjs_require__(1);
  38249. var corePdfManager = __w_pdfjs_require__(42);
  38250. var UNSUPPORTED_FEATURES = sharedUtil.UNSUPPORTED_FEATURES;
  38251. var InvalidPDFException = sharedUtil.InvalidPDFException;
  38252. var MessageHandler = sharedUtil.MessageHandler;
  38253. var MissingPDFException = sharedUtil.MissingPDFException;
  38254. var UnexpectedResponseException = sharedUtil.UnexpectedResponseException;
  38255. var PasswordException = sharedUtil.PasswordException;
  38256. var UnknownErrorException = sharedUtil.UnknownErrorException;
  38257. var XRefParseException = sharedUtil.XRefParseException;
  38258. var arrayByteLength = sharedUtil.arrayByteLength;
  38259. var arraysToBytes = sharedUtil.arraysToBytes;
  38260. var assert = sharedUtil.assert;
  38261. var createPromiseCapability = sharedUtil.createPromiseCapability;
  38262. var error = sharedUtil.error;
  38263. var info = sharedUtil.info;
  38264. var warn = sharedUtil.warn;
  38265. var setVerbosityLevel = sharedUtil.setVerbosityLevel;
  38266. var Ref = corePrimitives.Ref;
  38267. var LocalPdfManager = corePdfManager.LocalPdfManager;
  38268. var NetworkPdfManager = corePdfManager.NetworkPdfManager;
  38269. var globalScope = sharedUtil.globalScope;
  38270. var WorkerTask = function WorkerTaskClosure() {
  38271. function WorkerTask(name) {
  38272. this.name = name;
  38273. this.terminated = false;
  38274. this._capability = createPromiseCapability();
  38275. }
  38276. WorkerTask.prototype = {
  38277. get finished() {
  38278. return this._capability.promise;
  38279. },
  38280. finish: function () {
  38281. this._capability.resolve();
  38282. },
  38283. terminate: function () {
  38284. this.terminated = true;
  38285. },
  38286. ensureNotTerminated: function () {
  38287. if (this.terminated) {
  38288. throw new Error('Worker task was terminated');
  38289. }
  38290. }
  38291. };
  38292. return WorkerTask;
  38293. }();
  38294. var PDFWorkerStream = function PDFWorkerStreamClosure() {
  38295. function PDFWorkerStream(params, msgHandler) {
  38296. this._queuedChunks = [];
  38297. var initialData = params.initialData;
  38298. if (initialData && initialData.length > 0) {
  38299. this._queuedChunks.push(initialData);
  38300. }
  38301. this._msgHandler = msgHandler;
  38302. this._isRangeSupported = !params.disableRange;
  38303. this._isStreamingSupported = !params.disableStream;
  38304. this._contentLength = params.length;
  38305. this._fullRequestReader = null;
  38306. this._rangeReaders = [];
  38307. msgHandler.on('OnDataRange', this._onReceiveData.bind(this));
  38308. msgHandler.on('OnDataProgress', this._onProgress.bind(this));
  38309. }
  38310. PDFWorkerStream.prototype = {
  38311. _onReceiveData: function PDFWorkerStream_onReceiveData(args) {
  38312. if (args.begin === undefined) {
  38313. if (this._fullRequestReader) {
  38314. this._fullRequestReader._enqueue(args.chunk);
  38315. } else {
  38316. this._queuedChunks.push(args.chunk);
  38317. }
  38318. } else {
  38319. var found = this._rangeReaders.some(function (rangeReader) {
  38320. if (rangeReader._begin !== args.begin) {
  38321. return false;
  38322. }
  38323. rangeReader._enqueue(args.chunk);
  38324. return true;
  38325. });
  38326. assert(found);
  38327. }
  38328. },
  38329. _onProgress: function PDFWorkerStream_onProgress(evt) {
  38330. if (this._rangeReaders.length > 0) {
  38331. var firstReader = this._rangeReaders[0];
  38332. if (firstReader.onProgress) {
  38333. firstReader.onProgress({ loaded: evt.loaded });
  38334. }
  38335. }
  38336. },
  38337. _removeRangeReader: function PDFWorkerStream_removeRangeReader(reader) {
  38338. var i = this._rangeReaders.indexOf(reader);
  38339. if (i >= 0) {
  38340. this._rangeReaders.splice(i, 1);
  38341. }
  38342. },
  38343. getFullReader: function PDFWorkerStream_getFullReader() {
  38344. assert(!this._fullRequestReader);
  38345. var queuedChunks = this._queuedChunks;
  38346. this._queuedChunks = null;
  38347. return new PDFWorkerStreamReader(this, queuedChunks);
  38348. },
  38349. getRangeReader: function PDFWorkerStream_getRangeReader(begin, end) {
  38350. var reader = new PDFWorkerStreamRangeReader(this, begin, end);
  38351. this._msgHandler.send('RequestDataRange', {
  38352. begin: begin,
  38353. end: end
  38354. });
  38355. this._rangeReaders.push(reader);
  38356. return reader;
  38357. },
  38358. cancelAllRequests: function PDFWorkerStream_cancelAllRequests(reason) {
  38359. if (this._fullRequestReader) {
  38360. this._fullRequestReader.cancel(reason);
  38361. }
  38362. var readers = this._rangeReaders.slice(0);
  38363. readers.forEach(function (rangeReader) {
  38364. rangeReader.cancel(reason);
  38365. });
  38366. }
  38367. };
  38368. function PDFWorkerStreamReader(stream, queuedChunks) {
  38369. this._stream = stream;
  38370. this._done = false;
  38371. this._queuedChunks = queuedChunks || [];
  38372. this._requests = [];
  38373. this._headersReady = Promise.resolve();
  38374. stream._fullRequestReader = this;
  38375. this.onProgress = null;
  38376. }
  38377. PDFWorkerStreamReader.prototype = {
  38378. _enqueue: function PDFWorkerStreamReader_enqueue(chunk) {
  38379. if (this._done) {
  38380. return;
  38381. }
  38382. if (this._requests.length > 0) {
  38383. var requestCapability = this._requests.shift();
  38384. requestCapability.resolve({
  38385. value: chunk,
  38386. done: false
  38387. });
  38388. return;
  38389. }
  38390. this._queuedChunks.push(chunk);
  38391. },
  38392. get headersReady() {
  38393. return this._headersReady;
  38394. },
  38395. get isRangeSupported() {
  38396. return this._stream._isRangeSupported;
  38397. },
  38398. get isStreamingSupported() {
  38399. return this._stream._isStreamingSupported;
  38400. },
  38401. get contentLength() {
  38402. return this._stream._contentLength;
  38403. },
  38404. read: function PDFWorkerStreamReader_read() {
  38405. if (this._queuedChunks.length > 0) {
  38406. var chunk = this._queuedChunks.shift();
  38407. return Promise.resolve({
  38408. value: chunk,
  38409. done: false
  38410. });
  38411. }
  38412. if (this._done) {
  38413. return Promise.resolve({
  38414. value: undefined,
  38415. done: true
  38416. });
  38417. }
  38418. var requestCapability = createPromiseCapability();
  38419. this._requests.push(requestCapability);
  38420. return requestCapability.promise;
  38421. },
  38422. cancel: function PDFWorkerStreamReader_cancel(reason) {
  38423. this._done = true;
  38424. this._requests.forEach(function (requestCapability) {
  38425. requestCapability.resolve({
  38426. value: undefined,
  38427. done: true
  38428. });
  38429. });
  38430. this._requests = [];
  38431. }
  38432. };
  38433. function PDFWorkerStreamRangeReader(stream, begin, end) {
  38434. this._stream = stream;
  38435. this._begin = begin;
  38436. this._end = end;
  38437. this._queuedChunk = null;
  38438. this._requests = [];
  38439. this._done = false;
  38440. this.onProgress = null;
  38441. }
  38442. PDFWorkerStreamRangeReader.prototype = {
  38443. _enqueue: function PDFWorkerStreamRangeReader_enqueue(chunk) {
  38444. if (this._done) {
  38445. return;
  38446. }
  38447. if (this._requests.length === 0) {
  38448. this._queuedChunk = chunk;
  38449. } else {
  38450. var requestsCapability = this._requests.shift();
  38451. requestsCapability.resolve({
  38452. value: chunk,
  38453. done: false
  38454. });
  38455. this._requests.forEach(function (requestCapability) {
  38456. requestCapability.resolve({
  38457. value: undefined,
  38458. done: true
  38459. });
  38460. });
  38461. this._requests = [];
  38462. }
  38463. this._done = true;
  38464. this._stream._removeRangeReader(this);
  38465. },
  38466. get isStreamingSupported() {
  38467. return false;
  38468. },
  38469. read: function PDFWorkerStreamRangeReader_read() {
  38470. if (this._queuedChunk) {
  38471. return Promise.resolve({
  38472. value: this._queuedChunk,
  38473. done: false
  38474. });
  38475. }
  38476. if (this._done) {
  38477. return Promise.resolve({
  38478. value: undefined,
  38479. done: true
  38480. });
  38481. }
  38482. var requestCapability = createPromiseCapability();
  38483. this._requests.push(requestCapability);
  38484. return requestCapability.promise;
  38485. },
  38486. cancel: function PDFWorkerStreamRangeReader_cancel(reason) {
  38487. this._done = true;
  38488. this._requests.forEach(function (requestCapability) {
  38489. requestCapability.resolve({
  38490. value: undefined,
  38491. done: true
  38492. });
  38493. });
  38494. this._requests = [];
  38495. this._stream._removeRangeReader(this);
  38496. }
  38497. };
  38498. return PDFWorkerStream;
  38499. }();
  38500. var PDFNetworkStream;
  38501. function setPDFNetworkStreamClass(cls) {
  38502. PDFNetworkStream = cls;
  38503. }
  38504. var WorkerMessageHandler = {
  38505. setup: function wphSetup(handler, port) {
  38506. var testMessageProcessed = false;
  38507. handler.on('test', function wphSetupTest(data) {
  38508. if (testMessageProcessed) {
  38509. return;
  38510. }
  38511. testMessageProcessed = true;
  38512. if (!(data instanceof Uint8Array)) {
  38513. handler.send('test', 'main', false);
  38514. return;
  38515. }
  38516. var supportTransfers = data[0] === 255;
  38517. handler.postMessageTransfers = supportTransfers;
  38518. var xhr = new XMLHttpRequest();
  38519. var responseExists = 'response' in xhr;
  38520. try {
  38521. xhr.responseType;
  38522. } catch (e) {
  38523. responseExists = false;
  38524. }
  38525. if (!responseExists) {
  38526. handler.send('test', false);
  38527. return;
  38528. }
  38529. handler.send('test', {
  38530. supportTypedArray: true,
  38531. supportTransfers: supportTransfers
  38532. });
  38533. });
  38534. handler.on('configure', function wphConfigure(data) {
  38535. setVerbosityLevel(data.verbosity);
  38536. });
  38537. handler.on('GetDocRequest', function wphSetupDoc(data) {
  38538. return WorkerMessageHandler.createDocumentHandler(data, port);
  38539. });
  38540. },
  38541. createDocumentHandler: function wphCreateDocumentHandler(docParams, port) {
  38542. var pdfManager;
  38543. var terminated = false;
  38544. var cancelXHRs = null;
  38545. var WorkerTasks = [];
  38546. var docId = docParams.docId;
  38547. var docBaseUrl = docParams.docBaseUrl;
  38548. var workerHandlerName = docParams.docId + '_worker';
  38549. var handler = new MessageHandler(workerHandlerName, docId, port);
  38550. handler.postMessageTransfers = docParams.postMessageTransfers;
  38551. function ensureNotTerminated() {
  38552. if (terminated) {
  38553. throw new Error('Worker was terminated');
  38554. }
  38555. }
  38556. function startWorkerTask(task) {
  38557. WorkerTasks.push(task);
  38558. }
  38559. function finishWorkerTask(task) {
  38560. task.finish();
  38561. var i = WorkerTasks.indexOf(task);
  38562. WorkerTasks.splice(i, 1);
  38563. }
  38564. function loadDocument(recoveryMode) {
  38565. var loadDocumentCapability = createPromiseCapability();
  38566. var parseSuccess = function parseSuccess() {
  38567. var numPagesPromise = pdfManager.ensureDoc('numPages');
  38568. var fingerprintPromise = pdfManager.ensureDoc('fingerprint');
  38569. var encryptedPromise = pdfManager.ensureXRef('encrypt');
  38570. Promise.all([
  38571. numPagesPromise,
  38572. fingerprintPromise,
  38573. encryptedPromise
  38574. ]).then(function onDocReady(results) {
  38575. var doc = {
  38576. numPages: results[0],
  38577. fingerprint: results[1],
  38578. encrypted: !!results[2]
  38579. };
  38580. loadDocumentCapability.resolve(doc);
  38581. }, parseFailure);
  38582. };
  38583. var parseFailure = function parseFailure(e) {
  38584. loadDocumentCapability.reject(e);
  38585. };
  38586. pdfManager.ensureDoc('checkHeader', []).then(function () {
  38587. pdfManager.ensureDoc('parseStartXRef', []).then(function () {
  38588. pdfManager.ensureDoc('parse', [recoveryMode]).then(parseSuccess, parseFailure);
  38589. }, parseFailure);
  38590. }, parseFailure);
  38591. return loadDocumentCapability.promise;
  38592. }
  38593. function getPdfManager(data, evaluatorOptions) {
  38594. var pdfManagerCapability = createPromiseCapability();
  38595. var pdfManager;
  38596. var source = data.source;
  38597. if (source.data) {
  38598. try {
  38599. pdfManager = new LocalPdfManager(docId, source.data, source.password, evaluatorOptions, docBaseUrl);
  38600. pdfManagerCapability.resolve(pdfManager);
  38601. } catch (ex) {
  38602. pdfManagerCapability.reject(ex);
  38603. }
  38604. return pdfManagerCapability.promise;
  38605. }
  38606. var pdfStream;
  38607. try {
  38608. if (source.chunkedViewerLoading) {
  38609. pdfStream = new PDFWorkerStream(source, handler);
  38610. } else {
  38611. assert(PDFNetworkStream, 'pdfjs/core/network module is not loaded');
  38612. pdfStream = new PDFNetworkStream(data);
  38613. }
  38614. } catch (ex) {
  38615. pdfManagerCapability.reject(ex);
  38616. return pdfManagerCapability.promise;
  38617. }
  38618. var fullRequest = pdfStream.getFullReader();
  38619. fullRequest.headersReady.then(function () {
  38620. if (!fullRequest.isStreamingSupported || !fullRequest.isRangeSupported) {
  38621. fullRequest.onProgress = function (evt) {
  38622. handler.send('DocProgress', {
  38623. loaded: evt.loaded,
  38624. total: evt.total
  38625. });
  38626. };
  38627. }
  38628. if (!fullRequest.isRangeSupported) {
  38629. return;
  38630. }
  38631. var disableAutoFetch = source.disableAutoFetch || fullRequest.isStreamingSupported;
  38632. pdfManager = new NetworkPdfManager(docId, pdfStream, {
  38633. msgHandler: handler,
  38634. url: source.url,
  38635. password: source.password,
  38636. length: fullRequest.contentLength,
  38637. disableAutoFetch: disableAutoFetch,
  38638. rangeChunkSize: source.rangeChunkSize
  38639. }, evaluatorOptions, docBaseUrl);
  38640. pdfManagerCapability.resolve(pdfManager);
  38641. cancelXHRs = null;
  38642. }).catch(function (reason) {
  38643. pdfManagerCapability.reject(reason);
  38644. cancelXHRs = null;
  38645. });
  38646. var cachedChunks = [], loaded = 0;
  38647. var flushChunks = function () {
  38648. var pdfFile = arraysToBytes(cachedChunks);
  38649. if (source.length && pdfFile.length !== source.length) {
  38650. warn('reported HTTP length is different from actual');
  38651. }
  38652. try {
  38653. pdfManager = new LocalPdfManager(docId, pdfFile, source.password, evaluatorOptions, docBaseUrl);
  38654. pdfManagerCapability.resolve(pdfManager);
  38655. } catch (ex) {
  38656. pdfManagerCapability.reject(ex);
  38657. }
  38658. cachedChunks = [];
  38659. };
  38660. var readPromise = new Promise(function (resolve, reject) {
  38661. var readChunk = function (chunk) {
  38662. try {
  38663. ensureNotTerminated();
  38664. if (chunk.done) {
  38665. if (!pdfManager) {
  38666. flushChunks();
  38667. }
  38668. cancelXHRs = null;
  38669. return;
  38670. }
  38671. var data = chunk.value;
  38672. loaded += arrayByteLength(data);
  38673. if (!fullRequest.isStreamingSupported) {
  38674. handler.send('DocProgress', {
  38675. loaded: loaded,
  38676. total: Math.max(loaded, fullRequest.contentLength || 0)
  38677. });
  38678. }
  38679. if (pdfManager) {
  38680. pdfManager.sendProgressiveData(data);
  38681. } else {
  38682. cachedChunks.push(data);
  38683. }
  38684. fullRequest.read().then(readChunk, reject);
  38685. } catch (e) {
  38686. reject(e);
  38687. }
  38688. };
  38689. fullRequest.read().then(readChunk, reject);
  38690. });
  38691. readPromise.catch(function (e) {
  38692. pdfManagerCapability.reject(e);
  38693. cancelXHRs = null;
  38694. });
  38695. cancelXHRs = function () {
  38696. pdfStream.cancelAllRequests('abort');
  38697. };
  38698. return pdfManagerCapability.promise;
  38699. }
  38700. function setupDoc(data) {
  38701. function onSuccess(doc) {
  38702. ensureNotTerminated();
  38703. handler.send('GetDoc', { pdfInfo: doc });
  38704. }
  38705. function onFailure(e) {
  38706. if (e instanceof PasswordException) {
  38707. var task = new WorkerTask('PasswordException: response ' + e.code);
  38708. startWorkerTask(task);
  38709. handler.sendWithPromise('PasswordRequest', e).then(function (data) {
  38710. finishWorkerTask(task);
  38711. pdfManager.updatePassword(data.password);
  38712. pdfManagerReady();
  38713. }).catch(function (ex) {
  38714. finishWorkerTask(task);
  38715. handler.send('PasswordException', ex);
  38716. }.bind(null, e));
  38717. } else if (e instanceof InvalidPDFException) {
  38718. handler.send('InvalidPDF', e);
  38719. } else if (e instanceof MissingPDFException) {
  38720. handler.send('MissingPDF', e);
  38721. } else if (e instanceof UnexpectedResponseException) {
  38722. handler.send('UnexpectedResponse', e);
  38723. } else {
  38724. handler.send('UnknownError', new UnknownErrorException(e.message, e.toString()));
  38725. }
  38726. }
  38727. function pdfManagerReady() {
  38728. ensureNotTerminated();
  38729. loadDocument(false).then(onSuccess, function loadFailure(ex) {
  38730. ensureNotTerminated();
  38731. if (!(ex instanceof XRefParseException)) {
  38732. onFailure(ex);
  38733. return;
  38734. }
  38735. pdfManager.requestLoadedStream();
  38736. pdfManager.onLoadedStream().then(function () {
  38737. ensureNotTerminated();
  38738. loadDocument(true).then(onSuccess, onFailure);
  38739. });
  38740. }, onFailure);
  38741. }
  38742. ensureNotTerminated();
  38743. var cMapOptions = {
  38744. url: data.cMapUrl === undefined ? null : data.cMapUrl,
  38745. packed: data.cMapPacked === true
  38746. };
  38747. var evaluatorOptions = {
  38748. forceDataSchema: data.disableCreateObjectURL,
  38749. maxImageSize: data.maxImageSize === undefined ? -1 : data.maxImageSize,
  38750. disableFontFace: data.disableFontFace,
  38751. cMapOptions: cMapOptions,
  38752. disableNativeImageDecoder: data.disableNativeImageDecoder
  38753. };
  38754. getPdfManager(data, evaluatorOptions).then(function (newPdfManager) {
  38755. if (terminated) {
  38756. newPdfManager.terminate();
  38757. throw new Error('Worker was terminated');
  38758. }
  38759. pdfManager = newPdfManager;
  38760. handler.send('PDFManagerReady', null);
  38761. pdfManager.onLoadedStream().then(function (stream) {
  38762. handler.send('DataLoaded', { length: stream.bytes.byteLength });
  38763. });
  38764. }).then(pdfManagerReady, onFailure);
  38765. }
  38766. handler.on('GetPage', function wphSetupGetPage(data) {
  38767. return pdfManager.getPage(data.pageIndex).then(function (page) {
  38768. var rotatePromise = pdfManager.ensure(page, 'rotate');
  38769. var refPromise = pdfManager.ensure(page, 'ref');
  38770. var userUnitPromise = pdfManager.ensure(page, 'userUnit');
  38771. var viewPromise = pdfManager.ensure(page, 'view');
  38772. return Promise.all([
  38773. rotatePromise,
  38774. refPromise,
  38775. userUnitPromise,
  38776. viewPromise
  38777. ]).then(function (results) {
  38778. return {
  38779. rotate: results[0],
  38780. ref: results[1],
  38781. userUnit: results[2],
  38782. view: results[3]
  38783. };
  38784. });
  38785. });
  38786. });
  38787. handler.on('GetPageIndex', function wphSetupGetPageIndex(data) {
  38788. var ref = new Ref(data.ref.num, data.ref.gen);
  38789. var catalog = pdfManager.pdfDocument.catalog;
  38790. return catalog.getPageIndex(ref);
  38791. });
  38792. handler.on('GetDestinations', function wphSetupGetDestinations(data) {
  38793. return pdfManager.ensureCatalog('destinations');
  38794. });
  38795. handler.on('GetDestination', function wphSetupGetDestination(data) {
  38796. return pdfManager.ensureCatalog('getDestination', [data.id]);
  38797. });
  38798. handler.on('GetPageLabels', function wphSetupGetPageLabels(data) {
  38799. return pdfManager.ensureCatalog('pageLabels');
  38800. });
  38801. handler.on('GetAttachments', function wphSetupGetAttachments(data) {
  38802. return pdfManager.ensureCatalog('attachments');
  38803. });
  38804. handler.on('GetJavaScript', function wphSetupGetJavaScript(data) {
  38805. return pdfManager.ensureCatalog('javaScript');
  38806. });
  38807. handler.on('GetOutline', function wphSetupGetOutline(data) {
  38808. return pdfManager.ensureCatalog('documentOutline');
  38809. });
  38810. handler.on('GetMetadata', function wphSetupGetMetadata(data) {
  38811. return Promise.all([
  38812. pdfManager.ensureDoc('documentInfo'),
  38813. pdfManager.ensureCatalog('metadata')
  38814. ]);
  38815. });
  38816. handler.on('GetData', function wphSetupGetData(data) {
  38817. pdfManager.requestLoadedStream();
  38818. return pdfManager.onLoadedStream().then(function (stream) {
  38819. return stream.bytes;
  38820. });
  38821. });
  38822. handler.on('GetStats', function wphSetupGetStats(data) {
  38823. return pdfManager.pdfDocument.xref.stats;
  38824. });
  38825. handler.on('GetAnnotations', function wphSetupGetAnnotations(data) {
  38826. return pdfManager.getPage(data.pageIndex).then(function (page) {
  38827. return pdfManager.ensure(page, 'getAnnotationsData', [data.intent]);
  38828. });
  38829. });
  38830. handler.on('RenderPageRequest', function wphSetupRenderPage(data) {
  38831. var pageIndex = data.pageIndex;
  38832. pdfManager.getPage(pageIndex).then(function (page) {
  38833. var task = new WorkerTask('RenderPageRequest: page ' + pageIndex);
  38834. startWorkerTask(task);
  38835. var pageNum = pageIndex + 1;
  38836. var start = Date.now();
  38837. page.getOperatorList(handler, task, data.intent, data.renderInteractiveForms).then(function (operatorList) {
  38838. finishWorkerTask(task);
  38839. info('page=' + pageNum + ' - getOperatorList: time=' + (Date.now() - start) + 'ms, len=' + operatorList.totalLength);
  38840. }, function (e) {
  38841. finishWorkerTask(task);
  38842. if (task.terminated) {
  38843. return;
  38844. }
  38845. handler.send('UnsupportedFeature', { featureId: UNSUPPORTED_FEATURES.unknown });
  38846. var minimumStackMessage = 'worker.js: while trying to getPage() and getOperatorList()';
  38847. var wrappedException;
  38848. if (typeof e === 'string') {
  38849. wrappedException = {
  38850. message: e,
  38851. stack: minimumStackMessage
  38852. };
  38853. } else if (typeof e === 'object') {
  38854. wrappedException = {
  38855. message: e.message || e.toString(),
  38856. stack: e.stack || minimumStackMessage
  38857. };
  38858. } else {
  38859. wrappedException = {
  38860. message: 'Unknown exception type: ' + typeof e,
  38861. stack: minimumStackMessage
  38862. };
  38863. }
  38864. handler.send('PageError', {
  38865. pageNum: pageNum,
  38866. error: wrappedException,
  38867. intent: data.intent
  38868. });
  38869. });
  38870. });
  38871. }, this);
  38872. handler.on('GetTextContent', function wphExtractText(data) {
  38873. var pageIndex = data.pageIndex;
  38874. var normalizeWhitespace = data.normalizeWhitespace;
  38875. var combineTextItems = data.combineTextItems;
  38876. return pdfManager.getPage(pageIndex).then(function (page) {
  38877. var task = new WorkerTask('GetTextContent: page ' + pageIndex);
  38878. startWorkerTask(task);
  38879. var pageNum = pageIndex + 1;
  38880. var start = Date.now();
  38881. return page.extractTextContent(task, normalizeWhitespace, combineTextItems).then(function (textContent) {
  38882. finishWorkerTask(task);
  38883. info('text indexing: page=' + pageNum + ' - time=' + (Date.now() - start) + 'ms');
  38884. return textContent;
  38885. }, function (reason) {
  38886. finishWorkerTask(task);
  38887. if (task.terminated) {
  38888. return;
  38889. }
  38890. throw reason;
  38891. });
  38892. });
  38893. });
  38894. handler.on('Cleanup', function wphCleanup(data) {
  38895. return pdfManager.cleanup();
  38896. });
  38897. handler.on('Terminate', function wphTerminate(data) {
  38898. terminated = true;
  38899. if (pdfManager) {
  38900. pdfManager.terminate();
  38901. pdfManager = null;
  38902. }
  38903. if (cancelXHRs) {
  38904. cancelXHRs();
  38905. }
  38906. var waitOn = [];
  38907. WorkerTasks.forEach(function (task) {
  38908. waitOn.push(task.finished);
  38909. task.terminate();
  38910. });
  38911. return Promise.all(waitOn).then(function () {
  38912. handler.destroy();
  38913. handler = null;
  38914. });
  38915. });
  38916. handler.on('Ready', function wphReady(data) {
  38917. setupDoc(docParams);
  38918. docParams = null;
  38919. });
  38920. return workerHandlerName;
  38921. }
  38922. };
  38923. function initializeWorker() {
  38924. if (!('console' in globalScope)) {
  38925. var consoleTimer = {};
  38926. var workerConsole = {
  38927. log: function log() {
  38928. var args = Array.prototype.slice.call(arguments);
  38929. globalScope.postMessage({
  38930. targetName: 'main',
  38931. action: 'console_log',
  38932. data: args
  38933. });
  38934. },
  38935. error: function error() {
  38936. var args = Array.prototype.slice.call(arguments);
  38937. globalScope.postMessage({
  38938. targetName: 'main',
  38939. action: 'console_error',
  38940. data: args
  38941. });
  38942. throw 'pdf.js execution error';
  38943. },
  38944. time: function time(name) {
  38945. consoleTimer[name] = Date.now();
  38946. },
  38947. timeEnd: function timeEnd(name) {
  38948. var time = consoleTimer[name];
  38949. if (!time) {
  38950. error('Unknown timer name ' + name);
  38951. }
  38952. this.log('Timer:', name, Date.now() - time);
  38953. }
  38954. };
  38955. globalScope.console = workerConsole;
  38956. }
  38957. var handler = new MessageHandler('worker', 'main', self);
  38958. WorkerMessageHandler.setup(handler, self);
  38959. handler.send('ready', null);
  38960. }
  38961. if (typeof window === 'undefined' && !(typeof module !== 'undefined' && module.require)) {
  38962. initializeWorker();
  38963. }
  38964. exports.setPDFNetworkStreamClass = setPDFNetworkStreamClass;
  38965. exports.WorkerTask = WorkerTask;
  38966. exports.WorkerMessageHandler = WorkerMessageHandler;
  38967. /* WEBPACK VAR INJECTION */}.call(exports, __w_pdfjs_require__(27)(module)))
  38968. /***/ }),
  38969. /* 23 */
  38970. /***/ (function(module, exports, __w_pdfjs_require__) {
  38971. "use strict";
  38972. var sharedUtil = __w_pdfjs_require__(0);
  38973. var error = sharedUtil.error;
  38974. function fixMetadata(meta) {
  38975. return meta.replace(/>\\376\\377([^<]+)/g, function (all, codes) {
  38976. var bytes = codes.replace(/\\([0-3])([0-7])([0-7])/g, function (code, d1, d2, d3) {
  38977. return String.fromCharCode(d1 * 64 + d2 * 8 + d3 * 1);
  38978. });
  38979. var chars = '';
  38980. for (var i = 0; i < bytes.length; i += 2) {
  38981. var code = bytes.charCodeAt(i) * 256 + bytes.charCodeAt(i + 1);
  38982. chars += code >= 32 && code < 127 && code !== 60 && code !== 62 && code !== 38 ? String.fromCharCode(code) : '&#x' + (0x10000 + code).toString(16).substring(1) + ';';
  38983. }
  38984. return '>' + chars;
  38985. });
  38986. }
  38987. function Metadata(meta) {
  38988. if (typeof meta === 'string') {
  38989. meta = fixMetadata(meta);
  38990. var parser = new DOMParser();
  38991. meta = parser.parseFromString(meta, 'application/xml');
  38992. } else if (!(meta instanceof Document)) {
  38993. error('Metadata: Invalid metadata object');
  38994. }
  38995. this.metaDocument = meta;
  38996. this.metadata = Object.create(null);
  38997. this.parse();
  38998. }
  38999. Metadata.prototype = {
  39000. parse: function Metadata_parse() {
  39001. var doc = this.metaDocument;
  39002. var rdf = doc.documentElement;
  39003. if (rdf.nodeName.toLowerCase() !== 'rdf:rdf') {
  39004. rdf = rdf.firstChild;
  39005. while (rdf && rdf.nodeName.toLowerCase() !== 'rdf:rdf') {
  39006. rdf = rdf.nextSibling;
  39007. }
  39008. }
  39009. var nodeName = rdf ? rdf.nodeName.toLowerCase() : null;
  39010. if (!rdf || nodeName !== 'rdf:rdf' || !rdf.hasChildNodes()) {
  39011. return;
  39012. }
  39013. var children = rdf.childNodes, desc, entry, name, i, ii, length, iLength;
  39014. for (i = 0, length = children.length; i < length; i++) {
  39015. desc = children[i];
  39016. if (desc.nodeName.toLowerCase() !== 'rdf:description') {
  39017. continue;
  39018. }
  39019. for (ii = 0, iLength = desc.childNodes.length; ii < iLength; ii++) {
  39020. if (desc.childNodes[ii].nodeName.toLowerCase() !== '#text') {
  39021. entry = desc.childNodes[ii];
  39022. name = entry.nodeName.toLowerCase();
  39023. this.metadata[name] = entry.textContent.trim();
  39024. }
  39025. }
  39026. }
  39027. },
  39028. get: function Metadata_get(name) {
  39029. return this.metadata[name] || null;
  39030. },
  39031. has: function Metadata_has(name) {
  39032. return typeof this.metadata[name] !== 'undefined';
  39033. }
  39034. };
  39035. exports.Metadata = Metadata;
  39036. /***/ }),
  39037. /* 24 */
  39038. /***/ (function(module, exports, __w_pdfjs_require__) {
  39039. "use strict";
  39040. var sharedUtil = __w_pdfjs_require__(0);
  39041. var displayDOMUtils = __w_pdfjs_require__(3);
  39042. var shadow = sharedUtil.shadow;
  39043. var getDefaultSetting = displayDOMUtils.getDefaultSetting;
  39044. var WebGLUtils = function WebGLUtilsClosure() {
  39045. function loadShader(gl, code, shaderType) {
  39046. var shader = gl.createShader(shaderType);
  39047. gl.shaderSource(shader, code);
  39048. gl.compileShader(shader);
  39049. var compiled = gl.getShaderParameter(shader, gl.COMPILE_STATUS);
  39050. if (!compiled) {
  39051. var errorMsg = gl.getShaderInfoLog(shader);
  39052. throw new Error('Error during shader compilation: ' + errorMsg);
  39053. }
  39054. return shader;
  39055. }
  39056. function createVertexShader(gl, code) {
  39057. return loadShader(gl, code, gl.VERTEX_SHADER);
  39058. }
  39059. function createFragmentShader(gl, code) {
  39060. return loadShader(gl, code, gl.FRAGMENT_SHADER);
  39061. }
  39062. function createProgram(gl, shaders) {
  39063. var program = gl.createProgram();
  39064. for (var i = 0, ii = shaders.length; i < ii; ++i) {
  39065. gl.attachShader(program, shaders[i]);
  39066. }
  39067. gl.linkProgram(program);
  39068. var linked = gl.getProgramParameter(program, gl.LINK_STATUS);
  39069. if (!linked) {
  39070. var errorMsg = gl.getProgramInfoLog(program);
  39071. throw new Error('Error during program linking: ' + errorMsg);
  39072. }
  39073. return program;
  39074. }
  39075. function createTexture(gl, image, textureId) {
  39076. gl.activeTexture(textureId);
  39077. var texture = gl.createTexture();
  39078. gl.bindTexture(gl.TEXTURE_2D, texture);
  39079. gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE);
  39080. gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE);
  39081. gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.NEAREST);
  39082. gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.NEAREST);
  39083. gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, gl.RGBA, gl.UNSIGNED_BYTE, image);
  39084. return texture;
  39085. }
  39086. var currentGL, currentCanvas;
  39087. function generateGL() {
  39088. if (currentGL) {
  39089. return;
  39090. }
  39091. currentCanvas = document.createElement('canvas');
  39092. currentGL = currentCanvas.getContext('webgl', { premultipliedalpha: false });
  39093. }
  39094. var smaskVertexShaderCode = '\
  39095. attribute vec2 a_position; \
  39096. attribute vec2 a_texCoord; \
  39097. \
  39098. uniform vec2 u_resolution; \
  39099. \
  39100. varying vec2 v_texCoord; \
  39101. \
  39102. void main() { \
  39103. vec2 clipSpace = (a_position / u_resolution) * 2.0 - 1.0; \
  39104. gl_Position = vec4(clipSpace * vec2(1, -1), 0, 1); \
  39105. \
  39106. v_texCoord = a_texCoord; \
  39107. } ';
  39108. var smaskFragmentShaderCode = '\
  39109. precision mediump float; \
  39110. \
  39111. uniform vec4 u_backdrop; \
  39112. uniform int u_subtype; \
  39113. uniform sampler2D u_image; \
  39114. uniform sampler2D u_mask; \
  39115. \
  39116. varying vec2 v_texCoord; \
  39117. \
  39118. void main() { \
  39119. vec4 imageColor = texture2D(u_image, v_texCoord); \
  39120. vec4 maskColor = texture2D(u_mask, v_texCoord); \
  39121. if (u_backdrop.a > 0.0) { \
  39122. maskColor.rgb = maskColor.rgb * maskColor.a + \
  39123. u_backdrop.rgb * (1.0 - maskColor.a); \
  39124. } \
  39125. float lum; \
  39126. if (u_subtype == 0) { \
  39127. lum = maskColor.a; \
  39128. } else { \
  39129. lum = maskColor.r * 0.3 + maskColor.g * 0.59 + \
  39130. maskColor.b * 0.11; \
  39131. } \
  39132. imageColor.a *= lum; \
  39133. imageColor.rgb *= imageColor.a; \
  39134. gl_FragColor = imageColor; \
  39135. } ';
  39136. var smaskCache = null;
  39137. function initSmaskGL() {
  39138. var canvas, gl;
  39139. generateGL();
  39140. canvas = currentCanvas;
  39141. currentCanvas = null;
  39142. gl = currentGL;
  39143. currentGL = null;
  39144. var vertexShader = createVertexShader(gl, smaskVertexShaderCode);
  39145. var fragmentShader = createFragmentShader(gl, smaskFragmentShaderCode);
  39146. var program = createProgram(gl, [
  39147. vertexShader,
  39148. fragmentShader
  39149. ]);
  39150. gl.useProgram(program);
  39151. var cache = {};
  39152. cache.gl = gl;
  39153. cache.canvas = canvas;
  39154. cache.resolutionLocation = gl.getUniformLocation(program, 'u_resolution');
  39155. cache.positionLocation = gl.getAttribLocation(program, 'a_position');
  39156. cache.backdropLocation = gl.getUniformLocation(program, 'u_backdrop');
  39157. cache.subtypeLocation = gl.getUniformLocation(program, 'u_subtype');
  39158. var texCoordLocation = gl.getAttribLocation(program, 'a_texCoord');
  39159. var texLayerLocation = gl.getUniformLocation(program, 'u_image');
  39160. var texMaskLocation = gl.getUniformLocation(program, 'u_mask');
  39161. var texCoordBuffer = gl.createBuffer();
  39162. gl.bindBuffer(gl.ARRAY_BUFFER, texCoordBuffer);
  39163. gl.bufferData(gl.ARRAY_BUFFER, new Float32Array([
  39164. 0.0,
  39165. 0.0,
  39166. 1.0,
  39167. 0.0,
  39168. 0.0,
  39169. 1.0,
  39170. 0.0,
  39171. 1.0,
  39172. 1.0,
  39173. 0.0,
  39174. 1.0,
  39175. 1.0
  39176. ]), gl.STATIC_DRAW);
  39177. gl.enableVertexAttribArray(texCoordLocation);
  39178. gl.vertexAttribPointer(texCoordLocation, 2, gl.FLOAT, false, 0, 0);
  39179. gl.uniform1i(texLayerLocation, 0);
  39180. gl.uniform1i(texMaskLocation, 1);
  39181. smaskCache = cache;
  39182. }
  39183. function composeSMask(layer, mask, properties) {
  39184. var width = layer.width, height = layer.height;
  39185. if (!smaskCache) {
  39186. initSmaskGL();
  39187. }
  39188. var cache = smaskCache, canvas = cache.canvas, gl = cache.gl;
  39189. canvas.width = width;
  39190. canvas.height = height;
  39191. gl.viewport(0, 0, gl.drawingBufferWidth, gl.drawingBufferHeight);
  39192. gl.uniform2f(cache.resolutionLocation, width, height);
  39193. if (properties.backdrop) {
  39194. gl.uniform4f(cache.resolutionLocation, properties.backdrop[0], properties.backdrop[1], properties.backdrop[2], 1);
  39195. } else {
  39196. gl.uniform4f(cache.resolutionLocation, 0, 0, 0, 0);
  39197. }
  39198. gl.uniform1i(cache.subtypeLocation, properties.subtype === 'Luminosity' ? 1 : 0);
  39199. var texture = createTexture(gl, layer, gl.TEXTURE0);
  39200. var maskTexture = createTexture(gl, mask, gl.TEXTURE1);
  39201. var buffer = gl.createBuffer();
  39202. gl.bindBuffer(gl.ARRAY_BUFFER, buffer);
  39203. gl.bufferData(gl.ARRAY_BUFFER, new Float32Array([
  39204. 0,
  39205. 0,
  39206. width,
  39207. 0,
  39208. 0,
  39209. height,
  39210. 0,
  39211. height,
  39212. width,
  39213. 0,
  39214. width,
  39215. height
  39216. ]), gl.STATIC_DRAW);
  39217. gl.enableVertexAttribArray(cache.positionLocation);
  39218. gl.vertexAttribPointer(cache.positionLocation, 2, gl.FLOAT, false, 0, 0);
  39219. gl.clearColor(0, 0, 0, 0);
  39220. gl.enable(gl.BLEND);
  39221. gl.blendFunc(gl.ONE, gl.ONE_MINUS_SRC_ALPHA);
  39222. gl.clear(gl.COLOR_BUFFER_BIT);
  39223. gl.drawArrays(gl.TRIANGLES, 0, 6);
  39224. gl.flush();
  39225. gl.deleteTexture(texture);
  39226. gl.deleteTexture(maskTexture);
  39227. gl.deleteBuffer(buffer);
  39228. return canvas;
  39229. }
  39230. var figuresVertexShaderCode = '\
  39231. attribute vec2 a_position; \
  39232. attribute vec3 a_color; \
  39233. \
  39234. uniform vec2 u_resolution; \
  39235. uniform vec2 u_scale; \
  39236. uniform vec2 u_offset; \
  39237. \
  39238. varying vec4 v_color; \
  39239. \
  39240. void main() { \
  39241. vec2 position = (a_position + u_offset) * u_scale; \
  39242. vec2 clipSpace = (position / u_resolution) * 2.0 - 1.0; \
  39243. gl_Position = vec4(clipSpace * vec2(1, -1), 0, 1); \
  39244. \
  39245. v_color = vec4(a_color / 255.0, 1.0); \
  39246. } ';
  39247. var figuresFragmentShaderCode = '\
  39248. precision mediump float; \
  39249. \
  39250. varying vec4 v_color; \
  39251. \
  39252. void main() { \
  39253. gl_FragColor = v_color; \
  39254. } ';
  39255. var figuresCache = null;
  39256. function initFiguresGL() {
  39257. var canvas, gl;
  39258. generateGL();
  39259. canvas = currentCanvas;
  39260. currentCanvas = null;
  39261. gl = currentGL;
  39262. currentGL = null;
  39263. var vertexShader = createVertexShader(gl, figuresVertexShaderCode);
  39264. var fragmentShader = createFragmentShader(gl, figuresFragmentShaderCode);
  39265. var program = createProgram(gl, [
  39266. vertexShader,
  39267. fragmentShader
  39268. ]);
  39269. gl.useProgram(program);
  39270. var cache = {};
  39271. cache.gl = gl;
  39272. cache.canvas = canvas;
  39273. cache.resolutionLocation = gl.getUniformLocation(program, 'u_resolution');
  39274. cache.scaleLocation = gl.getUniformLocation(program, 'u_scale');
  39275. cache.offsetLocation = gl.getUniformLocation(program, 'u_offset');
  39276. cache.positionLocation = gl.getAttribLocation(program, 'a_position');
  39277. cache.colorLocation = gl.getAttribLocation(program, 'a_color');
  39278. figuresCache = cache;
  39279. }
  39280. function drawFigures(width, height, backgroundColor, figures, context) {
  39281. if (!figuresCache) {
  39282. initFiguresGL();
  39283. }
  39284. var cache = figuresCache, canvas = cache.canvas, gl = cache.gl;
  39285. canvas.width = width;
  39286. canvas.height = height;
  39287. gl.viewport(0, 0, gl.drawingBufferWidth, gl.drawingBufferHeight);
  39288. gl.uniform2f(cache.resolutionLocation, width, height);
  39289. var count = 0;
  39290. var i, ii, rows;
  39291. for (i = 0, ii = figures.length; i < ii; i++) {
  39292. switch (figures[i].type) {
  39293. case 'lattice':
  39294. rows = figures[i].coords.length / figures[i].verticesPerRow | 0;
  39295. count += (rows - 1) * (figures[i].verticesPerRow - 1) * 6;
  39296. break;
  39297. case 'triangles':
  39298. count += figures[i].coords.length;
  39299. break;
  39300. }
  39301. }
  39302. var coords = new Float32Array(count * 2);
  39303. var colors = new Uint8Array(count * 3);
  39304. var coordsMap = context.coords, colorsMap = context.colors;
  39305. var pIndex = 0, cIndex = 0;
  39306. for (i = 0, ii = figures.length; i < ii; i++) {
  39307. var figure = figures[i], ps = figure.coords, cs = figure.colors;
  39308. switch (figure.type) {
  39309. case 'lattice':
  39310. var cols = figure.verticesPerRow;
  39311. rows = ps.length / cols | 0;
  39312. for (var row = 1; row < rows; row++) {
  39313. var offset = row * cols + 1;
  39314. for (var col = 1; col < cols; col++, offset++) {
  39315. coords[pIndex] = coordsMap[ps[offset - cols - 1]];
  39316. coords[pIndex + 1] = coordsMap[ps[offset - cols - 1] + 1];
  39317. coords[pIndex + 2] = coordsMap[ps[offset - cols]];
  39318. coords[pIndex + 3] = coordsMap[ps[offset - cols] + 1];
  39319. coords[pIndex + 4] = coordsMap[ps[offset - 1]];
  39320. coords[pIndex + 5] = coordsMap[ps[offset - 1] + 1];
  39321. colors[cIndex] = colorsMap[cs[offset - cols - 1]];
  39322. colors[cIndex + 1] = colorsMap[cs[offset - cols - 1] + 1];
  39323. colors[cIndex + 2] = colorsMap[cs[offset - cols - 1] + 2];
  39324. colors[cIndex + 3] = colorsMap[cs[offset - cols]];
  39325. colors[cIndex + 4] = colorsMap[cs[offset - cols] + 1];
  39326. colors[cIndex + 5] = colorsMap[cs[offset - cols] + 2];
  39327. colors[cIndex + 6] = colorsMap[cs[offset - 1]];
  39328. colors[cIndex + 7] = colorsMap[cs[offset - 1] + 1];
  39329. colors[cIndex + 8] = colorsMap[cs[offset - 1] + 2];
  39330. coords[pIndex + 6] = coords[pIndex + 2];
  39331. coords[pIndex + 7] = coords[pIndex + 3];
  39332. coords[pIndex + 8] = coords[pIndex + 4];
  39333. coords[pIndex + 9] = coords[pIndex + 5];
  39334. coords[pIndex + 10] = coordsMap[ps[offset]];
  39335. coords[pIndex + 11] = coordsMap[ps[offset] + 1];
  39336. colors[cIndex + 9] = colors[cIndex + 3];
  39337. colors[cIndex + 10] = colors[cIndex + 4];
  39338. colors[cIndex + 11] = colors[cIndex + 5];
  39339. colors[cIndex + 12] = colors[cIndex + 6];
  39340. colors[cIndex + 13] = colors[cIndex + 7];
  39341. colors[cIndex + 14] = colors[cIndex + 8];
  39342. colors[cIndex + 15] = colorsMap[cs[offset]];
  39343. colors[cIndex + 16] = colorsMap[cs[offset] + 1];
  39344. colors[cIndex + 17] = colorsMap[cs[offset] + 2];
  39345. pIndex += 12;
  39346. cIndex += 18;
  39347. }
  39348. }
  39349. break;
  39350. case 'triangles':
  39351. for (var j = 0, jj = ps.length; j < jj; j++) {
  39352. coords[pIndex] = coordsMap[ps[j]];
  39353. coords[pIndex + 1] = coordsMap[ps[j] + 1];
  39354. colors[cIndex] = colorsMap[cs[j]];
  39355. colors[cIndex + 1] = colorsMap[cs[j] + 1];
  39356. colors[cIndex + 2] = colorsMap[cs[j] + 2];
  39357. pIndex += 2;
  39358. cIndex += 3;
  39359. }
  39360. break;
  39361. }
  39362. }
  39363. if (backgroundColor) {
  39364. gl.clearColor(backgroundColor[0] / 255, backgroundColor[1] / 255, backgroundColor[2] / 255, 1.0);
  39365. } else {
  39366. gl.clearColor(0, 0, 0, 0);
  39367. }
  39368. gl.clear(gl.COLOR_BUFFER_BIT);
  39369. var coordsBuffer = gl.createBuffer();
  39370. gl.bindBuffer(gl.ARRAY_BUFFER, coordsBuffer);
  39371. gl.bufferData(gl.ARRAY_BUFFER, coords, gl.STATIC_DRAW);
  39372. gl.enableVertexAttribArray(cache.positionLocation);
  39373. gl.vertexAttribPointer(cache.positionLocation, 2, gl.FLOAT, false, 0, 0);
  39374. var colorsBuffer = gl.createBuffer();
  39375. gl.bindBuffer(gl.ARRAY_BUFFER, colorsBuffer);
  39376. gl.bufferData(gl.ARRAY_BUFFER, colors, gl.STATIC_DRAW);
  39377. gl.enableVertexAttribArray(cache.colorLocation);
  39378. gl.vertexAttribPointer(cache.colorLocation, 3, gl.UNSIGNED_BYTE, false, 0, 0);
  39379. gl.uniform2f(cache.scaleLocation, context.scaleX, context.scaleY);
  39380. gl.uniform2f(cache.offsetLocation, context.offsetX, context.offsetY);
  39381. gl.drawArrays(gl.TRIANGLES, 0, count);
  39382. gl.flush();
  39383. gl.deleteBuffer(coordsBuffer);
  39384. gl.deleteBuffer(colorsBuffer);
  39385. return canvas;
  39386. }
  39387. function cleanup() {
  39388. if (smaskCache && smaskCache.canvas) {
  39389. smaskCache.canvas.width = 0;
  39390. smaskCache.canvas.height = 0;
  39391. }
  39392. if (figuresCache && figuresCache.canvas) {
  39393. figuresCache.canvas.width = 0;
  39394. figuresCache.canvas.height = 0;
  39395. }
  39396. smaskCache = null;
  39397. figuresCache = null;
  39398. }
  39399. return {
  39400. get isEnabled() {
  39401. if (getDefaultSetting('disableWebGL')) {
  39402. return false;
  39403. }
  39404. var enabled = false;
  39405. try {
  39406. generateGL();
  39407. enabled = !!currentGL;
  39408. } catch (e) {
  39409. }
  39410. return shadow(this, 'isEnabled', enabled);
  39411. },
  39412. composeSMask: composeSMask,
  39413. drawFigures: drawFigures,
  39414. clear: cleanup
  39415. };
  39416. }();
  39417. exports.WebGLUtils = WebGLUtils;
  39418. /***/ }),
  39419. /* 25 */
  39420. /***/ (function(module, exports, __w_pdfjs_require__) {
  39421. "use strict";
  39422. var sharedUtil = __w_pdfjs_require__(0);
  39423. var displayDOMUtils = __w_pdfjs_require__(3);
  39424. var displayAPI = __w_pdfjs_require__(10);
  39425. var displayAnnotationLayer = __w_pdfjs_require__(9);
  39426. var displayTextLayer = __w_pdfjs_require__(12);
  39427. var displayMetadata = __w_pdfjs_require__(23);
  39428. var displaySVG = __w_pdfjs_require__(11);
  39429. var globalScope = sharedUtil.globalScope;
  39430. var deprecated = sharedUtil.deprecated;
  39431. var warn = sharedUtil.warn;
  39432. var LinkTarget = displayDOMUtils.LinkTarget;
  39433. var DEFAULT_LINK_REL = displayDOMUtils.DEFAULT_LINK_REL;
  39434. var isWorker = typeof window === 'undefined';
  39435. if (!globalScope.PDFJS) {
  39436. globalScope.PDFJS = {};
  39437. }
  39438. var PDFJS = globalScope.PDFJS;
  39439. PDFJS.version = '1.7.280';
  39440. PDFJS.build = '1549a46e';
  39441. PDFJS.pdfBug = false;
  39442. if (PDFJS.verbosity !== undefined) {
  39443. sharedUtil.setVerbosityLevel(PDFJS.verbosity);
  39444. }
  39445. delete PDFJS.verbosity;
  39446. Object.defineProperty(PDFJS, 'verbosity', {
  39447. get: function () {
  39448. return sharedUtil.getVerbosityLevel();
  39449. },
  39450. set: function (level) {
  39451. sharedUtil.setVerbosityLevel(level);
  39452. },
  39453. enumerable: true,
  39454. configurable: true
  39455. });
  39456. PDFJS.VERBOSITY_LEVELS = sharedUtil.VERBOSITY_LEVELS;
  39457. PDFJS.OPS = sharedUtil.OPS;
  39458. PDFJS.UNSUPPORTED_FEATURES = sharedUtil.UNSUPPORTED_FEATURES;
  39459. PDFJS.isValidUrl = displayDOMUtils.isValidUrl;
  39460. PDFJS.shadow = sharedUtil.shadow;
  39461. PDFJS.createBlob = sharedUtil.createBlob;
  39462. PDFJS.createObjectURL = function PDFJS_createObjectURL(data, contentType) {
  39463. return sharedUtil.createObjectURL(data, contentType, PDFJS.disableCreateObjectURL);
  39464. };
  39465. Object.defineProperty(PDFJS, 'isLittleEndian', {
  39466. configurable: true,
  39467. get: function PDFJS_isLittleEndian() {
  39468. var value = sharedUtil.isLittleEndian();
  39469. return sharedUtil.shadow(PDFJS, 'isLittleEndian', value);
  39470. }
  39471. });
  39472. PDFJS.removeNullCharacters = sharedUtil.removeNullCharacters;
  39473. PDFJS.PasswordResponses = sharedUtil.PasswordResponses;
  39474. PDFJS.PasswordException = sharedUtil.PasswordException;
  39475. PDFJS.UnknownErrorException = sharedUtil.UnknownErrorException;
  39476. PDFJS.InvalidPDFException = sharedUtil.InvalidPDFException;
  39477. PDFJS.MissingPDFException = sharedUtil.MissingPDFException;
  39478. PDFJS.UnexpectedResponseException = sharedUtil.UnexpectedResponseException;
  39479. PDFJS.Util = sharedUtil.Util;
  39480. PDFJS.PageViewport = sharedUtil.PageViewport;
  39481. PDFJS.createPromiseCapability = sharedUtil.createPromiseCapability;
  39482. PDFJS.maxImageSize = PDFJS.maxImageSize === undefined ? -1 : PDFJS.maxImageSize;
  39483. PDFJS.cMapUrl = PDFJS.cMapUrl === undefined ? null : PDFJS.cMapUrl;
  39484. PDFJS.cMapPacked = PDFJS.cMapPacked === undefined ? false : PDFJS.cMapPacked;
  39485. PDFJS.disableFontFace = PDFJS.disableFontFace === undefined ? false : PDFJS.disableFontFace;
  39486. PDFJS.imageResourcesPath = PDFJS.imageResourcesPath === undefined ? '' : PDFJS.imageResourcesPath;
  39487. PDFJS.disableWorker = PDFJS.disableWorker === undefined ? false : PDFJS.disableWorker;
  39488. PDFJS.workerSrc = PDFJS.workerSrc === undefined ? null : PDFJS.workerSrc;
  39489. PDFJS.disableRange = PDFJS.disableRange === undefined ? false : PDFJS.disableRange;
  39490. PDFJS.disableStream = PDFJS.disableStream === undefined ? false : PDFJS.disableStream;
  39491. PDFJS.disableAutoFetch = PDFJS.disableAutoFetch === undefined ? false : PDFJS.disableAutoFetch;
  39492. PDFJS.pdfBug = PDFJS.pdfBug === undefined ? false : PDFJS.pdfBug;
  39493. PDFJS.postMessageTransfers = PDFJS.postMessageTransfers === undefined ? true : PDFJS.postMessageTransfers;
  39494. PDFJS.disableCreateObjectURL = PDFJS.disableCreateObjectURL === undefined ? false : PDFJS.disableCreateObjectURL;
  39495. PDFJS.disableWebGL = PDFJS.disableWebGL === undefined ? true : PDFJS.disableWebGL;
  39496. PDFJS.externalLinkTarget = PDFJS.externalLinkTarget === undefined ? LinkTarget.NONE : PDFJS.externalLinkTarget;
  39497. PDFJS.externalLinkRel = PDFJS.externalLinkRel === undefined ? DEFAULT_LINK_REL : PDFJS.externalLinkRel;
  39498. PDFJS.isEvalSupported = PDFJS.isEvalSupported === undefined ? true : PDFJS.isEvalSupported;
  39499. var savedOpenExternalLinksInNewWindow = PDFJS.openExternalLinksInNewWindow;
  39500. delete PDFJS.openExternalLinksInNewWindow;
  39501. Object.defineProperty(PDFJS, 'openExternalLinksInNewWindow', {
  39502. get: function () {
  39503. return PDFJS.externalLinkTarget === LinkTarget.BLANK;
  39504. },
  39505. set: function (value) {
  39506. if (value) {
  39507. deprecated('PDFJS.openExternalLinksInNewWindow, please use ' + '"PDFJS.externalLinkTarget = PDFJS.LinkTarget.BLANK" instead.');
  39508. }
  39509. if (PDFJS.externalLinkTarget !== LinkTarget.NONE) {
  39510. warn('PDFJS.externalLinkTarget is already initialized');
  39511. return;
  39512. }
  39513. PDFJS.externalLinkTarget = value ? LinkTarget.BLANK : LinkTarget.NONE;
  39514. },
  39515. enumerable: true,
  39516. configurable: true
  39517. });
  39518. if (savedOpenExternalLinksInNewWindow) {
  39519. PDFJS.openExternalLinksInNewWindow = savedOpenExternalLinksInNewWindow;
  39520. }
  39521. PDFJS.getDocument = displayAPI.getDocument;
  39522. PDFJS.PDFDataRangeTransport = displayAPI.PDFDataRangeTransport;
  39523. PDFJS.PDFWorker = displayAPI.PDFWorker;
  39524. Object.defineProperty(PDFJS, 'hasCanvasTypedArrays', {
  39525. configurable: true,
  39526. get: function PDFJS_hasCanvasTypedArrays() {
  39527. var value = displayDOMUtils.hasCanvasTypedArrays();
  39528. return sharedUtil.shadow(PDFJS, 'hasCanvasTypedArrays', value);
  39529. }
  39530. });
  39531. PDFJS.CustomStyle = displayDOMUtils.CustomStyle;
  39532. PDFJS.LinkTarget = LinkTarget;
  39533. PDFJS.addLinkAttributes = displayDOMUtils.addLinkAttributes;
  39534. PDFJS.getFilenameFromUrl = displayDOMUtils.getFilenameFromUrl;
  39535. PDFJS.isExternalLinkTargetSet = displayDOMUtils.isExternalLinkTargetSet;
  39536. PDFJS.AnnotationLayer = displayAnnotationLayer.AnnotationLayer;
  39537. PDFJS.renderTextLayer = displayTextLayer.renderTextLayer;
  39538. PDFJS.Metadata = displayMetadata.Metadata;
  39539. PDFJS.SVGGraphics = displaySVG.SVGGraphics;
  39540. PDFJS.UnsupportedManager = displayAPI._UnsupportedManager;
  39541. exports.globalScope = globalScope;
  39542. exports.isWorker = isWorker;
  39543. exports.PDFJS = globalScope.PDFJS;
  39544. /***/ }),
  39545. /* 26 */
  39546. /***/ (function(module, exports) {
  39547. var g;
  39548. g = function () {
  39549. return this;
  39550. }();
  39551. try {
  39552. g = g || Function("return this")() || (1, eval)("this");
  39553. } catch (e) {
  39554. if (typeof window === "object")
  39555. g = window;
  39556. }
  39557. module.exports = g;
  39558. /***/ }),
  39559. /* 27 */
  39560. /***/ (function(module, exports) {
  39561. module.exports = function (module) {
  39562. if (!module.webpackPolyfill) {
  39563. module.deprecate = function () {
  39564. };
  39565. module.paths = [];
  39566. if (!module.children)
  39567. module.children = [];
  39568. Object.defineProperty(module, "loaded", {
  39569. enumerable: true,
  39570. get: function () {
  39571. return module.l;
  39572. }
  39573. });
  39574. Object.defineProperty(module, "id", {
  39575. enumerable: true,
  39576. get: function () {
  39577. return module.i;
  39578. }
  39579. });
  39580. module.webpackPolyfill = 1;
  39581. }
  39582. return module;
  39583. };
  39584. /***/ }),
  39585. /* 28 */
  39586. /***/ (function(module, exports, __w_pdfjs_require__) {
  39587. "use strict";
  39588. var sharedUtil = __w_pdfjs_require__(0);
  39589. var corePrimitives = __w_pdfjs_require__(1);
  39590. var coreStream = __w_pdfjs_require__(2);
  39591. var coreColorSpace = __w_pdfjs_require__(4);
  39592. var coreObj = __w_pdfjs_require__(19);
  39593. var coreEvaluator = __w_pdfjs_require__(17);
  39594. var AnnotationBorderStyleType = sharedUtil.AnnotationBorderStyleType;
  39595. var AnnotationFieldFlag = sharedUtil.AnnotationFieldFlag;
  39596. var AnnotationFlag = sharedUtil.AnnotationFlag;
  39597. var AnnotationType = sharedUtil.AnnotationType;
  39598. var OPS = sharedUtil.OPS;
  39599. var Util = sharedUtil.Util;
  39600. var isArray = sharedUtil.isArray;
  39601. var isInt = sharedUtil.isInt;
  39602. var stringToBytes = sharedUtil.stringToBytes;
  39603. var stringToPDFString = sharedUtil.stringToPDFString;
  39604. var warn = sharedUtil.warn;
  39605. var Dict = corePrimitives.Dict;
  39606. var isDict = corePrimitives.isDict;
  39607. var isName = corePrimitives.isName;
  39608. var isRef = corePrimitives.isRef;
  39609. var Stream = coreStream.Stream;
  39610. var ColorSpace = coreColorSpace.ColorSpace;
  39611. var Catalog = coreObj.Catalog;
  39612. var ObjectLoader = coreObj.ObjectLoader;
  39613. var FileSpec = coreObj.FileSpec;
  39614. var OperatorList = coreEvaluator.OperatorList;
  39615. function AnnotationFactory() {
  39616. }
  39617. AnnotationFactory.prototype = {
  39618. create: function AnnotationFactory_create(xref, ref, pdfManager, idFactory) {
  39619. var dict = xref.fetchIfRef(ref);
  39620. if (!isDict(dict)) {
  39621. return;
  39622. }
  39623. var id = isRef(ref) ? ref.toString() : 'annot_' + idFactory.createObjId();
  39624. var subtype = dict.get('Subtype');
  39625. subtype = isName(subtype) ? subtype.name : null;
  39626. var parameters = {
  39627. xref: xref,
  39628. dict: dict,
  39629. ref: isRef(ref) ? ref : null,
  39630. subtype: subtype,
  39631. id: id,
  39632. pdfManager: pdfManager
  39633. };
  39634. switch (subtype) {
  39635. case 'Link':
  39636. return new LinkAnnotation(parameters);
  39637. case 'Text':
  39638. return new TextAnnotation(parameters);
  39639. case 'Widget':
  39640. var fieldType = Util.getInheritableProperty(dict, 'FT');
  39641. fieldType = isName(fieldType) ? fieldType.name : null;
  39642. switch (fieldType) {
  39643. case 'Tx':
  39644. return new TextWidgetAnnotation(parameters);
  39645. case 'Btn':
  39646. return new ButtonWidgetAnnotation(parameters);
  39647. case 'Ch':
  39648. return new ChoiceWidgetAnnotation(parameters);
  39649. }
  39650. warn('Unimplemented widget field type "' + fieldType + '", ' + 'falling back to base field type.');
  39651. return new WidgetAnnotation(parameters);
  39652. case 'Popup':
  39653. return new PopupAnnotation(parameters);
  39654. case 'Highlight':
  39655. return new HighlightAnnotation(parameters);
  39656. case 'Underline':
  39657. return new UnderlineAnnotation(parameters);
  39658. case 'Squiggly':
  39659. return new SquigglyAnnotation(parameters);
  39660. case 'StrikeOut':
  39661. return new StrikeOutAnnotation(parameters);
  39662. case 'FileAttachment':
  39663. return new FileAttachmentAnnotation(parameters);
  39664. default:
  39665. if (!subtype) {
  39666. warn('Annotation is missing the required /Subtype.');
  39667. } else {
  39668. warn('Unimplemented annotation type "' + subtype + '", ' + 'falling back to base annotation.');
  39669. }
  39670. return new Annotation(parameters);
  39671. }
  39672. }
  39673. };
  39674. var Annotation = function AnnotationClosure() {
  39675. function getTransformMatrix(rect, bbox, matrix) {
  39676. var bounds = Util.getAxialAlignedBoundingBox(bbox, matrix);
  39677. var minX = bounds[0];
  39678. var minY = bounds[1];
  39679. var maxX = bounds[2];
  39680. var maxY = bounds[3];
  39681. if (minX === maxX || minY === maxY) {
  39682. return [
  39683. 1,
  39684. 0,
  39685. 0,
  39686. 1,
  39687. rect[0],
  39688. rect[1]
  39689. ];
  39690. }
  39691. var xRatio = (rect[2] - rect[0]) / (maxX - minX);
  39692. var yRatio = (rect[3] - rect[1]) / (maxY - minY);
  39693. return [
  39694. xRatio,
  39695. 0,
  39696. 0,
  39697. yRatio,
  39698. rect[0] - minX * xRatio,
  39699. rect[1] - minY * yRatio
  39700. ];
  39701. }
  39702. function getDefaultAppearance(dict) {
  39703. var appearanceState = dict.get('AP');
  39704. if (!isDict(appearanceState)) {
  39705. return;
  39706. }
  39707. var appearance;
  39708. var appearances = appearanceState.get('N');
  39709. if (isDict(appearances)) {
  39710. var as = dict.get('AS');
  39711. if (as && appearances.has(as.name)) {
  39712. appearance = appearances.get(as.name);
  39713. }
  39714. } else {
  39715. appearance = appearances;
  39716. }
  39717. return appearance;
  39718. }
  39719. function Annotation(params) {
  39720. var dict = params.dict;
  39721. this.setFlags(dict.get('F'));
  39722. this.setRectangle(dict.getArray('Rect'));
  39723. this.setColor(dict.getArray('C'));
  39724. this.setBorderStyle(dict);
  39725. this.appearance = getDefaultAppearance(dict);
  39726. this.data = {};
  39727. this.data.id = params.id;
  39728. this.data.subtype = params.subtype;
  39729. this.data.annotationFlags = this.flags;
  39730. this.data.rect = this.rectangle;
  39731. this.data.color = this.color;
  39732. this.data.borderStyle = this.borderStyle;
  39733. this.data.hasAppearance = !!this.appearance;
  39734. }
  39735. Annotation.prototype = {
  39736. _hasFlag: function Annotation_hasFlag(flags, flag) {
  39737. return !!(flags & flag);
  39738. },
  39739. _isViewable: function Annotation_isViewable(flags) {
  39740. return !this._hasFlag(flags, AnnotationFlag.INVISIBLE) && !this._hasFlag(flags, AnnotationFlag.HIDDEN) && !this._hasFlag(flags, AnnotationFlag.NOVIEW);
  39741. },
  39742. _isPrintable: function AnnotationFlag_isPrintable(flags) {
  39743. return this._hasFlag(flags, AnnotationFlag.PRINT) && !this._hasFlag(flags, AnnotationFlag.INVISIBLE) && !this._hasFlag(flags, AnnotationFlag.HIDDEN);
  39744. },
  39745. get viewable() {
  39746. if (this.flags === 0) {
  39747. return true;
  39748. }
  39749. return this._isViewable(this.flags);
  39750. },
  39751. get printable() {
  39752. if (this.flags === 0) {
  39753. return false;
  39754. }
  39755. return this._isPrintable(this.flags);
  39756. },
  39757. setFlags: function Annotation_setFlags(flags) {
  39758. this.flags = isInt(flags) && flags > 0 ? flags : 0;
  39759. },
  39760. hasFlag: function Annotation_hasFlag(flag) {
  39761. return this._hasFlag(this.flags, flag);
  39762. },
  39763. setRectangle: function Annotation_setRectangle(rectangle) {
  39764. if (isArray(rectangle) && rectangle.length === 4) {
  39765. this.rectangle = Util.normalizeRect(rectangle);
  39766. } else {
  39767. this.rectangle = [
  39768. 0,
  39769. 0,
  39770. 0,
  39771. 0
  39772. ];
  39773. }
  39774. },
  39775. setColor: function Annotation_setColor(color) {
  39776. var rgbColor = new Uint8Array(3);
  39777. if (!isArray(color)) {
  39778. this.color = rgbColor;
  39779. return;
  39780. }
  39781. switch (color.length) {
  39782. case 0:
  39783. this.color = null;
  39784. break;
  39785. case 1:
  39786. ColorSpace.singletons.gray.getRgbItem(color, 0, rgbColor, 0);
  39787. this.color = rgbColor;
  39788. break;
  39789. case 3:
  39790. ColorSpace.singletons.rgb.getRgbItem(color, 0, rgbColor, 0);
  39791. this.color = rgbColor;
  39792. break;
  39793. case 4:
  39794. ColorSpace.singletons.cmyk.getRgbItem(color, 0, rgbColor, 0);
  39795. this.color = rgbColor;
  39796. break;
  39797. default:
  39798. this.color = rgbColor;
  39799. break;
  39800. }
  39801. },
  39802. setBorderStyle: function Annotation_setBorderStyle(borderStyle) {
  39803. this.borderStyle = new AnnotationBorderStyle();
  39804. if (!isDict(borderStyle)) {
  39805. return;
  39806. }
  39807. if (borderStyle.has('BS')) {
  39808. var dict = borderStyle.get('BS');
  39809. var dictType = dict.get('Type');
  39810. if (!dictType || isName(dictType, 'Border')) {
  39811. this.borderStyle.setWidth(dict.get('W'));
  39812. this.borderStyle.setStyle(dict.get('S'));
  39813. this.borderStyle.setDashArray(dict.getArray('D'));
  39814. }
  39815. } else if (borderStyle.has('Border')) {
  39816. var array = borderStyle.getArray('Border');
  39817. if (isArray(array) && array.length >= 3) {
  39818. this.borderStyle.setHorizontalCornerRadius(array[0]);
  39819. this.borderStyle.setVerticalCornerRadius(array[1]);
  39820. this.borderStyle.setWidth(array[2]);
  39821. if (array.length === 4) {
  39822. this.borderStyle.setDashArray(array[3]);
  39823. }
  39824. }
  39825. } else {
  39826. this.borderStyle.setWidth(0);
  39827. }
  39828. },
  39829. _preparePopup: function Annotation_preparePopup(dict) {
  39830. if (!dict.has('C')) {
  39831. this.data.color = null;
  39832. }
  39833. this.data.hasPopup = dict.has('Popup');
  39834. this.data.title = stringToPDFString(dict.get('T') || '');
  39835. this.data.contents = stringToPDFString(dict.get('Contents') || '');
  39836. },
  39837. loadResources: function Annotation_loadResources(keys) {
  39838. return new Promise(function (resolve, reject) {
  39839. this.appearance.dict.getAsync('Resources').then(function (resources) {
  39840. if (!resources) {
  39841. resolve();
  39842. return;
  39843. }
  39844. var objectLoader = new ObjectLoader(resources.map, keys, resources.xref);
  39845. objectLoader.load().then(function () {
  39846. resolve(resources);
  39847. }, reject);
  39848. }, reject);
  39849. }.bind(this));
  39850. },
  39851. getOperatorList: function Annotation_getOperatorList(evaluator, task, renderForms) {
  39852. if (!this.appearance) {
  39853. return Promise.resolve(new OperatorList());
  39854. }
  39855. var data = this.data;
  39856. var appearanceDict = this.appearance.dict;
  39857. var resourcesPromise = this.loadResources([
  39858. 'ExtGState',
  39859. 'ColorSpace',
  39860. 'Pattern',
  39861. 'Shading',
  39862. 'XObject',
  39863. 'Font'
  39864. ]);
  39865. var bbox = appearanceDict.getArray('BBox') || [
  39866. 0,
  39867. 0,
  39868. 1,
  39869. 1
  39870. ];
  39871. var matrix = appearanceDict.getArray('Matrix') || [
  39872. 1,
  39873. 0,
  39874. 0,
  39875. 1,
  39876. 0,
  39877. 0
  39878. ];
  39879. var transform = getTransformMatrix(data.rect, bbox, matrix);
  39880. var self = this;
  39881. return resourcesPromise.then(function (resources) {
  39882. var opList = new OperatorList();
  39883. opList.addOp(OPS.beginAnnotation, [
  39884. data.rect,
  39885. transform,
  39886. matrix
  39887. ]);
  39888. return evaluator.getOperatorList(self.appearance, task, resources, opList).then(function () {
  39889. opList.addOp(OPS.endAnnotation, []);
  39890. self.appearance.reset();
  39891. return opList;
  39892. });
  39893. });
  39894. }
  39895. };
  39896. Annotation.appendToOperatorList = function Annotation_appendToOperatorList(annotations, opList, partialEvaluator, task, intent, renderForms) {
  39897. var annotationPromises = [];
  39898. for (var i = 0, n = annotations.length; i < n; ++i) {
  39899. if (intent === 'display' && annotations[i].viewable || intent === 'print' && annotations[i].printable) {
  39900. annotationPromises.push(annotations[i].getOperatorList(partialEvaluator, task, renderForms));
  39901. }
  39902. }
  39903. return Promise.all(annotationPromises).then(function (operatorLists) {
  39904. opList.addOp(OPS.beginAnnotations, []);
  39905. for (var i = 0, n = operatorLists.length; i < n; ++i) {
  39906. opList.addOpList(operatorLists[i]);
  39907. }
  39908. opList.addOp(OPS.endAnnotations, []);
  39909. });
  39910. };
  39911. return Annotation;
  39912. }();
  39913. var AnnotationBorderStyle = function AnnotationBorderStyleClosure() {
  39914. function AnnotationBorderStyle() {
  39915. this.width = 1;
  39916. this.style = AnnotationBorderStyleType.SOLID;
  39917. this.dashArray = [3];
  39918. this.horizontalCornerRadius = 0;
  39919. this.verticalCornerRadius = 0;
  39920. }
  39921. AnnotationBorderStyle.prototype = {
  39922. setWidth: function AnnotationBorderStyle_setWidth(width) {
  39923. if (width === (width | 0)) {
  39924. this.width = width;
  39925. }
  39926. },
  39927. setStyle: function AnnotationBorderStyle_setStyle(style) {
  39928. if (!style) {
  39929. return;
  39930. }
  39931. switch (style.name) {
  39932. case 'S':
  39933. this.style = AnnotationBorderStyleType.SOLID;
  39934. break;
  39935. case 'D':
  39936. this.style = AnnotationBorderStyleType.DASHED;
  39937. break;
  39938. case 'B':
  39939. this.style = AnnotationBorderStyleType.BEVELED;
  39940. break;
  39941. case 'I':
  39942. this.style = AnnotationBorderStyleType.INSET;
  39943. break;
  39944. case 'U':
  39945. this.style = AnnotationBorderStyleType.UNDERLINE;
  39946. break;
  39947. default:
  39948. break;
  39949. }
  39950. },
  39951. setDashArray: function AnnotationBorderStyle_setDashArray(dashArray) {
  39952. if (isArray(dashArray) && dashArray.length > 0) {
  39953. var isValid = true;
  39954. var allZeros = true;
  39955. for (var i = 0, len = dashArray.length; i < len; i++) {
  39956. var element = dashArray[i];
  39957. var validNumber = +element >= 0;
  39958. if (!validNumber) {
  39959. isValid = false;
  39960. break;
  39961. } else if (element > 0) {
  39962. allZeros = false;
  39963. }
  39964. }
  39965. if (isValid && !allZeros) {
  39966. this.dashArray = dashArray;
  39967. } else {
  39968. this.width = 0;
  39969. }
  39970. } else if (dashArray) {
  39971. this.width = 0;
  39972. }
  39973. },
  39974. setHorizontalCornerRadius: function AnnotationBorderStyle_setHorizontalCornerRadius(radius) {
  39975. if (radius === (radius | 0)) {
  39976. this.horizontalCornerRadius = radius;
  39977. }
  39978. },
  39979. setVerticalCornerRadius: function AnnotationBorderStyle_setVerticalCornerRadius(radius) {
  39980. if (radius === (radius | 0)) {
  39981. this.verticalCornerRadius = radius;
  39982. }
  39983. }
  39984. };
  39985. return AnnotationBorderStyle;
  39986. }();
  39987. var WidgetAnnotation = function WidgetAnnotationClosure() {
  39988. function WidgetAnnotation(params) {
  39989. Annotation.call(this, params);
  39990. var dict = params.dict;
  39991. var data = this.data;
  39992. data.annotationType = AnnotationType.WIDGET;
  39993. data.fieldName = this._constructFieldName(dict);
  39994. data.fieldValue = Util.getInheritableProperty(dict, 'V', true);
  39995. data.alternativeText = stringToPDFString(dict.get('TU') || '');
  39996. data.defaultAppearance = Util.getInheritableProperty(dict, 'DA') || '';
  39997. var fieldType = Util.getInheritableProperty(dict, 'FT');
  39998. data.fieldType = isName(fieldType) ? fieldType.name : null;
  39999. this.fieldResources = Util.getInheritableProperty(dict, 'DR') || Dict.empty;
  40000. data.fieldFlags = Util.getInheritableProperty(dict, 'Ff');
  40001. if (!isInt(data.fieldFlags) || data.fieldFlags < 0) {
  40002. data.fieldFlags = 0;
  40003. }
  40004. data.readOnly = this.hasFieldFlag(AnnotationFieldFlag.READONLY);
  40005. if (data.fieldType === 'Sig') {
  40006. this.setFlags(AnnotationFlag.HIDDEN);
  40007. }
  40008. }
  40009. Util.inherit(WidgetAnnotation, Annotation, {
  40010. _constructFieldName: function WidgetAnnotation_constructFieldName(dict) {
  40011. if (!dict.has('T') && !dict.has('Parent')) {
  40012. warn('Unknown field name, falling back to empty field name.');
  40013. return '';
  40014. }
  40015. if (!dict.has('Parent')) {
  40016. return stringToPDFString(dict.get('T'));
  40017. }
  40018. var fieldName = [];
  40019. if (dict.has('T')) {
  40020. fieldName.unshift(stringToPDFString(dict.get('T')));
  40021. }
  40022. var loopDict = dict;
  40023. while (loopDict.has('Parent')) {
  40024. loopDict = loopDict.get('Parent');
  40025. if (loopDict.has('T')) {
  40026. fieldName.unshift(stringToPDFString(loopDict.get('T')));
  40027. }
  40028. }
  40029. return fieldName.join('.');
  40030. },
  40031. hasFieldFlag: function WidgetAnnotation_hasFieldFlag(flag) {
  40032. return !!(this.data.fieldFlags & flag);
  40033. }
  40034. });
  40035. return WidgetAnnotation;
  40036. }();
  40037. var TextWidgetAnnotation = function TextWidgetAnnotationClosure() {
  40038. function TextWidgetAnnotation(params) {
  40039. WidgetAnnotation.call(this, params);
  40040. this.data.fieldValue = stringToPDFString(this.data.fieldValue || '');
  40041. var alignment = Util.getInheritableProperty(params.dict, 'Q');
  40042. if (!isInt(alignment) || alignment < 0 || alignment > 2) {
  40043. alignment = null;
  40044. }
  40045. this.data.textAlignment = alignment;
  40046. var maximumLength = Util.getInheritableProperty(params.dict, 'MaxLen');
  40047. if (!isInt(maximumLength) || maximumLength < 0) {
  40048. maximumLength = null;
  40049. }
  40050. this.data.maxLen = maximumLength;
  40051. this.data.multiLine = this.hasFieldFlag(AnnotationFieldFlag.MULTILINE);
  40052. this.data.comb = this.hasFieldFlag(AnnotationFieldFlag.COMB) && !this.hasFieldFlag(AnnotationFieldFlag.MULTILINE) && !this.hasFieldFlag(AnnotationFieldFlag.PASSWORD) && !this.hasFieldFlag(AnnotationFieldFlag.FILESELECT) && this.data.maxLen !== null;
  40053. }
  40054. Util.inherit(TextWidgetAnnotation, WidgetAnnotation, {
  40055. getOperatorList: function TextWidgetAnnotation_getOperatorList(evaluator, task, renderForms) {
  40056. var operatorList = new OperatorList();
  40057. if (renderForms) {
  40058. return Promise.resolve(operatorList);
  40059. }
  40060. if (this.appearance) {
  40061. return Annotation.prototype.getOperatorList.call(this, evaluator, task, renderForms);
  40062. }
  40063. if (!this.data.defaultAppearance) {
  40064. return Promise.resolve(operatorList);
  40065. }
  40066. var stream = new Stream(stringToBytes(this.data.defaultAppearance));
  40067. return evaluator.getOperatorList(stream, task, this.fieldResources, operatorList).then(function () {
  40068. return operatorList;
  40069. });
  40070. }
  40071. });
  40072. return TextWidgetAnnotation;
  40073. }();
  40074. var ButtonWidgetAnnotation = function ButtonWidgetAnnotationClosure() {
  40075. function ButtonWidgetAnnotation(params) {
  40076. WidgetAnnotation.call(this, params);
  40077. this.data.checkBox = !this.hasFieldFlag(AnnotationFieldFlag.RADIO) && !this.hasFieldFlag(AnnotationFieldFlag.PUSHBUTTON);
  40078. if (this.data.checkBox) {
  40079. if (!isName(this.data.fieldValue)) {
  40080. return;
  40081. }
  40082. this.data.fieldValue = this.data.fieldValue.name;
  40083. }
  40084. this.data.radioButton = this.hasFieldFlag(AnnotationFieldFlag.RADIO) && !this.hasFieldFlag(AnnotationFieldFlag.PUSHBUTTON);
  40085. if (this.data.radioButton) {
  40086. this.data.fieldValue = this.data.buttonValue = null;
  40087. var fieldParent = params.dict.get('Parent');
  40088. if (isDict(fieldParent) && fieldParent.has('V')) {
  40089. var fieldParentValue = fieldParent.get('V');
  40090. if (isName(fieldParentValue)) {
  40091. this.data.fieldValue = fieldParentValue.name;
  40092. }
  40093. }
  40094. var appearanceStates = params.dict.get('AP');
  40095. if (!isDict(appearanceStates)) {
  40096. return;
  40097. }
  40098. var normalAppearanceState = appearanceStates.get('N');
  40099. if (!isDict(normalAppearanceState)) {
  40100. return;
  40101. }
  40102. var keys = normalAppearanceState.getKeys();
  40103. for (var i = 0, ii = keys.length; i < ii; i++) {
  40104. if (keys[i] !== 'Off') {
  40105. this.data.buttonValue = keys[i];
  40106. break;
  40107. }
  40108. }
  40109. }
  40110. }
  40111. Util.inherit(ButtonWidgetAnnotation, WidgetAnnotation, {
  40112. getOperatorList: function ButtonWidgetAnnotation_getOperatorList(evaluator, task, renderForms) {
  40113. var operatorList = new OperatorList();
  40114. if (renderForms) {
  40115. return Promise.resolve(operatorList);
  40116. }
  40117. if (this.appearance) {
  40118. return Annotation.prototype.getOperatorList.call(this, evaluator, task, renderForms);
  40119. }
  40120. return Promise.resolve(operatorList);
  40121. }
  40122. });
  40123. return ButtonWidgetAnnotation;
  40124. }();
  40125. var ChoiceWidgetAnnotation = function ChoiceWidgetAnnotationClosure() {
  40126. function ChoiceWidgetAnnotation(params) {
  40127. WidgetAnnotation.call(this, params);
  40128. this.data.options = [];
  40129. var options = params.dict.get('Opt');
  40130. if (isArray(options)) {
  40131. var xref = params.xref;
  40132. for (var i = 0, ii = options.length; i < ii; i++) {
  40133. var option = xref.fetchIfRef(options[i]);
  40134. var isOptionArray = isArray(option);
  40135. this.data.options[i] = {
  40136. exportValue: isOptionArray ? xref.fetchIfRef(option[0]) : option,
  40137. displayValue: isOptionArray ? xref.fetchIfRef(option[1]) : option
  40138. };
  40139. }
  40140. }
  40141. if (!isArray(this.data.fieldValue)) {
  40142. this.data.fieldValue = [this.data.fieldValue];
  40143. }
  40144. this.data.combo = this.hasFieldFlag(AnnotationFieldFlag.COMBO);
  40145. this.data.multiSelect = this.hasFieldFlag(AnnotationFieldFlag.MULTISELECT);
  40146. }
  40147. Util.inherit(ChoiceWidgetAnnotation, WidgetAnnotation, {
  40148. getOperatorList: function ChoiceWidgetAnnotation_getOperatorList(evaluator, task, renderForms) {
  40149. var operatorList = new OperatorList();
  40150. if (renderForms) {
  40151. return Promise.resolve(operatorList);
  40152. }
  40153. return Annotation.prototype.getOperatorList.call(this, evaluator, task, renderForms);
  40154. }
  40155. });
  40156. return ChoiceWidgetAnnotation;
  40157. }();
  40158. var TextAnnotation = function TextAnnotationClosure() {
  40159. var DEFAULT_ICON_SIZE = 22;
  40160. function TextAnnotation(parameters) {
  40161. Annotation.call(this, parameters);
  40162. this.data.annotationType = AnnotationType.TEXT;
  40163. if (this.data.hasAppearance) {
  40164. this.data.name = 'NoIcon';
  40165. } else {
  40166. this.data.rect[1] = this.data.rect[3] - DEFAULT_ICON_SIZE;
  40167. this.data.rect[2] = this.data.rect[0] + DEFAULT_ICON_SIZE;
  40168. this.data.name = parameters.dict.has('Name') ? parameters.dict.get('Name').name : 'Note';
  40169. }
  40170. this._preparePopup(parameters.dict);
  40171. }
  40172. Util.inherit(TextAnnotation, Annotation, {});
  40173. return TextAnnotation;
  40174. }();
  40175. var LinkAnnotation = function LinkAnnotationClosure() {
  40176. function LinkAnnotation(params) {
  40177. Annotation.call(this, params);
  40178. var data = this.data;
  40179. data.annotationType = AnnotationType.LINK;
  40180. Catalog.parseDestDictionary({
  40181. destDict: params.dict,
  40182. resultObj: data,
  40183. docBaseUrl: params.pdfManager.docBaseUrl
  40184. });
  40185. }
  40186. Util.inherit(LinkAnnotation, Annotation, {});
  40187. return LinkAnnotation;
  40188. }();
  40189. var PopupAnnotation = function PopupAnnotationClosure() {
  40190. function PopupAnnotation(parameters) {
  40191. Annotation.call(this, parameters);
  40192. this.data.annotationType = AnnotationType.POPUP;
  40193. var dict = parameters.dict;
  40194. var parentItem = dict.get('Parent');
  40195. if (!parentItem) {
  40196. warn('Popup annotation has a missing or invalid parent annotation.');
  40197. return;
  40198. }
  40199. this.data.parentId = dict.getRaw('Parent').toString();
  40200. this.data.title = stringToPDFString(parentItem.get('T') || '');
  40201. this.data.contents = stringToPDFString(parentItem.get('Contents') || '');
  40202. if (!parentItem.has('C')) {
  40203. this.data.color = null;
  40204. } else {
  40205. this.setColor(parentItem.getArray('C'));
  40206. this.data.color = this.color;
  40207. }
  40208. if (!this.viewable) {
  40209. var parentFlags = parentItem.get('F');
  40210. if (this._isViewable(parentFlags)) {
  40211. this.setFlags(parentFlags);
  40212. }
  40213. }
  40214. }
  40215. Util.inherit(PopupAnnotation, Annotation, {});
  40216. return PopupAnnotation;
  40217. }();
  40218. var HighlightAnnotation = function HighlightAnnotationClosure() {
  40219. function HighlightAnnotation(parameters) {
  40220. Annotation.call(this, parameters);
  40221. this.data.annotationType = AnnotationType.HIGHLIGHT;
  40222. this._preparePopup(parameters.dict);
  40223. this.data.borderStyle.setWidth(0);
  40224. }
  40225. Util.inherit(HighlightAnnotation, Annotation, {});
  40226. return HighlightAnnotation;
  40227. }();
  40228. var UnderlineAnnotation = function UnderlineAnnotationClosure() {
  40229. function UnderlineAnnotation(parameters) {
  40230. Annotation.call(this, parameters);
  40231. this.data.annotationType = AnnotationType.UNDERLINE;
  40232. this._preparePopup(parameters.dict);
  40233. this.data.borderStyle.setWidth(0);
  40234. }
  40235. Util.inherit(UnderlineAnnotation, Annotation, {});
  40236. return UnderlineAnnotation;
  40237. }();
  40238. var SquigglyAnnotation = function SquigglyAnnotationClosure() {
  40239. function SquigglyAnnotation(parameters) {
  40240. Annotation.call(this, parameters);
  40241. this.data.annotationType = AnnotationType.SQUIGGLY;
  40242. this._preparePopup(parameters.dict);
  40243. this.data.borderStyle.setWidth(0);
  40244. }
  40245. Util.inherit(SquigglyAnnotation, Annotation, {});
  40246. return SquigglyAnnotation;
  40247. }();
  40248. var StrikeOutAnnotation = function StrikeOutAnnotationClosure() {
  40249. function StrikeOutAnnotation(parameters) {
  40250. Annotation.call(this, parameters);
  40251. this.data.annotationType = AnnotationType.STRIKEOUT;
  40252. this._preparePopup(parameters.dict);
  40253. this.data.borderStyle.setWidth(0);
  40254. }
  40255. Util.inherit(StrikeOutAnnotation, Annotation, {});
  40256. return StrikeOutAnnotation;
  40257. }();
  40258. var FileAttachmentAnnotation = function FileAttachmentAnnotationClosure() {
  40259. function FileAttachmentAnnotation(parameters) {
  40260. Annotation.call(this, parameters);
  40261. var file = new FileSpec(parameters.dict.get('FS'), parameters.xref);
  40262. this.data.annotationType = AnnotationType.FILEATTACHMENT;
  40263. this.data.file = file.serializable;
  40264. this._preparePopup(parameters.dict);
  40265. }
  40266. Util.inherit(FileAttachmentAnnotation, Annotation, {});
  40267. return FileAttachmentAnnotation;
  40268. }();
  40269. exports.Annotation = Annotation;
  40270. exports.AnnotationBorderStyle = AnnotationBorderStyle;
  40271. exports.AnnotationFactory = AnnotationFactory;
  40272. /***/ }),
  40273. /* 29 */
  40274. /***/ (function(module, exports, __w_pdfjs_require__) {
  40275. "use strict";
  40276. var sharedUtil = __w_pdfjs_require__(0);
  40277. var warn = sharedUtil.warn;
  40278. var baseTypes = [
  40279. 'BN',
  40280. 'BN',
  40281. 'BN',
  40282. 'BN',
  40283. 'BN',
  40284. 'BN',
  40285. 'BN',
  40286. 'BN',
  40287. 'BN',
  40288. 'S',
  40289. 'B',
  40290. 'S',
  40291. 'WS',
  40292. 'B',
  40293. 'BN',
  40294. 'BN',
  40295. 'BN',
  40296. 'BN',
  40297. 'BN',
  40298. 'BN',
  40299. 'BN',
  40300. 'BN',
  40301. 'BN',
  40302. 'BN',
  40303. 'BN',
  40304. 'BN',
  40305. 'BN',
  40306. 'BN',
  40307. 'B',
  40308. 'B',
  40309. 'B',
  40310. 'S',
  40311. 'WS',
  40312. 'ON',
  40313. 'ON',
  40314. 'ET',
  40315. 'ET',
  40316. 'ET',
  40317. 'ON',
  40318. 'ON',
  40319. 'ON',
  40320. 'ON',
  40321. 'ON',
  40322. 'ES',
  40323. 'CS',
  40324. 'ES',
  40325. 'CS',
  40326. 'CS',
  40327. 'EN',
  40328. 'EN',
  40329. 'EN',
  40330. 'EN',
  40331. 'EN',
  40332. 'EN',
  40333. 'EN',
  40334. 'EN',
  40335. 'EN',
  40336. 'EN',
  40337. 'CS',
  40338. 'ON',
  40339. 'ON',
  40340. 'ON',
  40341. 'ON',
  40342. 'ON',
  40343. 'ON',
  40344. 'L',
  40345. 'L',
  40346. 'L',
  40347. 'L',
  40348. 'L',
  40349. 'L',
  40350. 'L',
  40351. 'L',
  40352. 'L',
  40353. 'L',
  40354. 'L',
  40355. 'L',
  40356. 'L',
  40357. 'L',
  40358. 'L',
  40359. 'L',
  40360. 'L',
  40361. 'L',
  40362. 'L',
  40363. 'L',
  40364. 'L',
  40365. 'L',
  40366. 'L',
  40367. 'L',
  40368. 'L',
  40369. 'L',
  40370. 'ON',
  40371. 'ON',
  40372. 'ON',
  40373. 'ON',
  40374. 'ON',
  40375. 'ON',
  40376. 'L',
  40377. 'L',
  40378. 'L',
  40379. 'L',
  40380. 'L',
  40381. 'L',
  40382. 'L',
  40383. 'L',
  40384. 'L',
  40385. 'L',
  40386. 'L',
  40387. 'L',
  40388. 'L',
  40389. 'L',
  40390. 'L',
  40391. 'L',
  40392. 'L',
  40393. 'L',
  40394. 'L',
  40395. 'L',
  40396. 'L',
  40397. 'L',
  40398. 'L',
  40399. 'L',
  40400. 'L',
  40401. 'L',
  40402. 'ON',
  40403. 'ON',
  40404. 'ON',
  40405. 'ON',
  40406. 'BN',
  40407. 'BN',
  40408. 'BN',
  40409. 'BN',
  40410. 'BN',
  40411. 'BN',
  40412. 'B',
  40413. 'BN',
  40414. 'BN',
  40415. 'BN',
  40416. 'BN',
  40417. 'BN',
  40418. 'BN',
  40419. 'BN',
  40420. 'BN',
  40421. 'BN',
  40422. 'BN',
  40423. 'BN',
  40424. 'BN',
  40425. 'BN',
  40426. 'BN',
  40427. 'BN',
  40428. 'BN',
  40429. 'BN',
  40430. 'BN',
  40431. 'BN',
  40432. 'BN',
  40433. 'BN',
  40434. 'BN',
  40435. 'BN',
  40436. 'BN',
  40437. 'BN',
  40438. 'BN',
  40439. 'CS',
  40440. 'ON',
  40441. 'ET',
  40442. 'ET',
  40443. 'ET',
  40444. 'ET',
  40445. 'ON',
  40446. 'ON',
  40447. 'ON',
  40448. 'ON',
  40449. 'L',
  40450. 'ON',
  40451. 'ON',
  40452. 'BN',
  40453. 'ON',
  40454. 'ON',
  40455. 'ET',
  40456. 'ET',
  40457. 'EN',
  40458. 'EN',
  40459. 'ON',
  40460. 'L',
  40461. 'ON',
  40462. 'ON',
  40463. 'ON',
  40464. 'EN',
  40465. 'L',
  40466. 'ON',
  40467. 'ON',
  40468. 'ON',
  40469. 'ON',
  40470. 'ON',
  40471. 'L',
  40472. 'L',
  40473. 'L',
  40474. 'L',
  40475. 'L',
  40476. 'L',
  40477. 'L',
  40478. 'L',
  40479. 'L',
  40480. 'L',
  40481. 'L',
  40482. 'L',
  40483. 'L',
  40484. 'L',
  40485. 'L',
  40486. 'L',
  40487. 'L',
  40488. 'L',
  40489. 'L',
  40490. 'L',
  40491. 'L',
  40492. 'L',
  40493. 'L',
  40494. 'ON',
  40495. 'L',
  40496. 'L',
  40497. 'L',
  40498. 'L',
  40499. 'L',
  40500. 'L',
  40501. 'L',
  40502. 'L',
  40503. 'L',
  40504. 'L',
  40505. 'L',
  40506. 'L',
  40507. 'L',
  40508. 'L',
  40509. 'L',
  40510. 'L',
  40511. 'L',
  40512. 'L',
  40513. 'L',
  40514. 'L',
  40515. 'L',
  40516. 'L',
  40517. 'L',
  40518. 'L',
  40519. 'L',
  40520. 'L',
  40521. 'L',
  40522. 'L',
  40523. 'L',
  40524. 'L',
  40525. 'L',
  40526. 'ON',
  40527. 'L',
  40528. 'L',
  40529. 'L',
  40530. 'L',
  40531. 'L',
  40532. 'L',
  40533. 'L',
  40534. 'L'
  40535. ];
  40536. var arabicTypes = [
  40537. 'AN',
  40538. 'AN',
  40539. 'AN',
  40540. 'AN',
  40541. 'AN',
  40542. 'AN',
  40543. 'ON',
  40544. 'ON',
  40545. 'AL',
  40546. 'ET',
  40547. 'ET',
  40548. 'AL',
  40549. 'CS',
  40550. 'AL',
  40551. 'ON',
  40552. 'ON',
  40553. 'NSM',
  40554. 'NSM',
  40555. 'NSM',
  40556. 'NSM',
  40557. 'NSM',
  40558. 'NSM',
  40559. 'NSM',
  40560. 'NSM',
  40561. 'NSM',
  40562. 'NSM',
  40563. 'NSM',
  40564. 'AL',
  40565. 'AL',
  40566. '',
  40567. 'AL',
  40568. 'AL',
  40569. 'AL',
  40570. 'AL',
  40571. 'AL',
  40572. 'AL',
  40573. 'AL',
  40574. 'AL',
  40575. 'AL',
  40576. 'AL',
  40577. 'AL',
  40578. 'AL',
  40579. 'AL',
  40580. 'AL',
  40581. 'AL',
  40582. 'AL',
  40583. 'AL',
  40584. 'AL',
  40585. 'AL',
  40586. 'AL',
  40587. 'AL',
  40588. 'AL',
  40589. 'AL',
  40590. 'AL',
  40591. 'AL',
  40592. 'AL',
  40593. 'AL',
  40594. 'AL',
  40595. 'AL',
  40596. 'AL',
  40597. 'AL',
  40598. 'AL',
  40599. 'AL',
  40600. 'AL',
  40601. 'AL',
  40602. 'AL',
  40603. 'AL',
  40604. 'AL',
  40605. 'AL',
  40606. 'AL',
  40607. 'AL',
  40608. 'AL',
  40609. 'AL',
  40610. 'AL',
  40611. 'AL',
  40612. 'NSM',
  40613. 'NSM',
  40614. 'NSM',
  40615. 'NSM',
  40616. 'NSM',
  40617. 'NSM',
  40618. 'NSM',
  40619. 'NSM',
  40620. 'NSM',
  40621. 'NSM',
  40622. 'NSM',
  40623. 'NSM',
  40624. 'NSM',
  40625. 'NSM',
  40626. 'NSM',
  40627. 'NSM',
  40628. 'NSM',
  40629. 'NSM',
  40630. 'NSM',
  40631. 'NSM',
  40632. 'NSM',
  40633. 'AN',
  40634. 'AN',
  40635. 'AN',
  40636. 'AN',
  40637. 'AN',
  40638. 'AN',
  40639. 'AN',
  40640. 'AN',
  40641. 'AN',
  40642. 'AN',
  40643. 'ET',
  40644. 'AN',
  40645. 'AN',
  40646. 'AL',
  40647. 'AL',
  40648. 'AL',
  40649. 'NSM',
  40650. 'AL',
  40651. 'AL',
  40652. 'AL',
  40653. 'AL',
  40654. 'AL',
  40655. 'AL',
  40656. 'AL',
  40657. 'AL',
  40658. 'AL',
  40659. 'AL',
  40660. 'AL',
  40661. 'AL',
  40662. 'AL',
  40663. 'AL',
  40664. 'AL',
  40665. 'AL',
  40666. 'AL',
  40667. 'AL',
  40668. 'AL',
  40669. 'AL',
  40670. 'AL',
  40671. 'AL',
  40672. 'AL',
  40673. 'AL',
  40674. 'AL',
  40675. 'AL',
  40676. 'AL',
  40677. 'AL',
  40678. 'AL',
  40679. 'AL',
  40680. 'AL',
  40681. 'AL',
  40682. 'AL',
  40683. 'AL',
  40684. 'AL',
  40685. 'AL',
  40686. 'AL',
  40687. 'AL',
  40688. 'AL',
  40689. 'AL',
  40690. 'AL',
  40691. 'AL',
  40692. 'AL',
  40693. 'AL',
  40694. 'AL',
  40695. 'AL',
  40696. 'AL',
  40697. 'AL',
  40698. 'AL',
  40699. 'AL',
  40700. 'AL',
  40701. 'AL',
  40702. 'AL',
  40703. 'AL',
  40704. 'AL',
  40705. 'AL',
  40706. 'AL',
  40707. 'AL',
  40708. 'AL',
  40709. 'AL',
  40710. 'AL',
  40711. 'AL',
  40712. 'AL',
  40713. 'AL',
  40714. 'AL',
  40715. 'AL',
  40716. 'AL',
  40717. 'AL',
  40718. 'AL',
  40719. 'AL',
  40720. 'AL',
  40721. 'AL',
  40722. 'AL',
  40723. 'AL',
  40724. 'AL',
  40725. 'AL',
  40726. 'AL',
  40727. 'AL',
  40728. 'AL',
  40729. 'AL',
  40730. 'AL',
  40731. 'AL',
  40732. 'AL',
  40733. 'AL',
  40734. 'AL',
  40735. 'AL',
  40736. 'AL',
  40737. 'AL',
  40738. 'AL',
  40739. 'AL',
  40740. 'AL',
  40741. 'AL',
  40742. 'AL',
  40743. 'AL',
  40744. 'AL',
  40745. 'AL',
  40746. 'AL',
  40747. 'AL',
  40748. 'AL',
  40749. 'AL',
  40750. 'AL',
  40751. 'NSM',
  40752. 'NSM',
  40753. 'NSM',
  40754. 'NSM',
  40755. 'NSM',
  40756. 'NSM',
  40757. 'NSM',
  40758. 'AN',
  40759. 'ON',
  40760. 'NSM',
  40761. 'NSM',
  40762. 'NSM',
  40763. 'NSM',
  40764. 'NSM',
  40765. 'NSM',
  40766. 'AL',
  40767. 'AL',
  40768. 'NSM',
  40769. 'NSM',
  40770. 'ON',
  40771. 'NSM',
  40772. 'NSM',
  40773. 'NSM',
  40774. 'NSM',
  40775. 'AL',
  40776. 'AL',
  40777. 'EN',
  40778. 'EN',
  40779. 'EN',
  40780. 'EN',
  40781. 'EN',
  40782. 'EN',
  40783. 'EN',
  40784. 'EN',
  40785. 'EN',
  40786. 'EN',
  40787. 'AL',
  40788. 'AL',
  40789. 'AL',
  40790. 'AL',
  40791. 'AL',
  40792. 'AL'
  40793. ];
  40794. function isOdd(i) {
  40795. return (i & 1) !== 0;
  40796. }
  40797. function isEven(i) {
  40798. return (i & 1) === 0;
  40799. }
  40800. function findUnequal(arr, start, value) {
  40801. for (var j = start, jj = arr.length; j < jj; ++j) {
  40802. if (arr[j] !== value) {
  40803. return j;
  40804. }
  40805. }
  40806. return j;
  40807. }
  40808. function setValues(arr, start, end, value) {
  40809. for (var j = start; j < end; ++j) {
  40810. arr[j] = value;
  40811. }
  40812. }
  40813. function reverseValues(arr, start, end) {
  40814. for (var i = start, j = end - 1; i < j; ++i, --j) {
  40815. var temp = arr[i];
  40816. arr[i] = arr[j];
  40817. arr[j] = temp;
  40818. }
  40819. }
  40820. function createBidiText(str, isLTR, vertical) {
  40821. return {
  40822. str: str,
  40823. dir: vertical ? 'ttb' : isLTR ? 'ltr' : 'rtl'
  40824. };
  40825. }
  40826. var chars = [];
  40827. var types = [];
  40828. function bidi(str, startLevel, vertical) {
  40829. var isLTR = true;
  40830. var strLength = str.length;
  40831. if (strLength === 0 || vertical) {
  40832. return createBidiText(str, isLTR, vertical);
  40833. }
  40834. chars.length = strLength;
  40835. types.length = strLength;
  40836. var numBidi = 0;
  40837. var i, ii;
  40838. for (i = 0; i < strLength; ++i) {
  40839. chars[i] = str.charAt(i);
  40840. var charCode = str.charCodeAt(i);
  40841. var charType = 'L';
  40842. if (charCode <= 0x00ff) {
  40843. charType = baseTypes[charCode];
  40844. } else if (0x0590 <= charCode && charCode <= 0x05f4) {
  40845. charType = 'R';
  40846. } else if (0x0600 <= charCode && charCode <= 0x06ff) {
  40847. charType = arabicTypes[charCode & 0xff];
  40848. if (!charType) {
  40849. warn('Bidi: invalid Unicode character ' + charCode.toString(16));
  40850. }
  40851. } else if (0x0700 <= charCode && charCode <= 0x08AC) {
  40852. charType = 'AL';
  40853. }
  40854. if (charType === 'R' || charType === 'AL' || charType === 'AN') {
  40855. numBidi++;
  40856. }
  40857. types[i] = charType;
  40858. }
  40859. if (numBidi === 0) {
  40860. isLTR = true;
  40861. return createBidiText(str, isLTR);
  40862. }
  40863. if (startLevel === -1) {
  40864. if (numBidi / strLength < 0.3) {
  40865. isLTR = true;
  40866. startLevel = 0;
  40867. } else {
  40868. isLTR = false;
  40869. startLevel = 1;
  40870. }
  40871. }
  40872. var levels = [];
  40873. for (i = 0; i < strLength; ++i) {
  40874. levels[i] = startLevel;
  40875. }
  40876. var e = isOdd(startLevel) ? 'R' : 'L';
  40877. var sor = e;
  40878. var eor = sor;
  40879. var lastType = sor;
  40880. for (i = 0; i < strLength; ++i) {
  40881. if (types[i] === 'NSM') {
  40882. types[i] = lastType;
  40883. } else {
  40884. lastType = types[i];
  40885. }
  40886. }
  40887. lastType = sor;
  40888. var t;
  40889. for (i = 0; i < strLength; ++i) {
  40890. t = types[i];
  40891. if (t === 'EN') {
  40892. types[i] = lastType === 'AL' ? 'AN' : 'EN';
  40893. } else if (t === 'R' || t === 'L' || t === 'AL') {
  40894. lastType = t;
  40895. }
  40896. }
  40897. for (i = 0; i < strLength; ++i) {
  40898. t = types[i];
  40899. if (t === 'AL') {
  40900. types[i] = 'R';
  40901. }
  40902. }
  40903. for (i = 1; i < strLength - 1; ++i) {
  40904. if (types[i] === 'ES' && types[i - 1] === 'EN' && types[i + 1] === 'EN') {
  40905. types[i] = 'EN';
  40906. }
  40907. if (types[i] === 'CS' && (types[i - 1] === 'EN' || types[i - 1] === 'AN') && types[i + 1] === types[i - 1]) {
  40908. types[i] = types[i - 1];
  40909. }
  40910. }
  40911. for (i = 0; i < strLength; ++i) {
  40912. if (types[i] === 'EN') {
  40913. var j;
  40914. for (j = i - 1; j >= 0; --j) {
  40915. if (types[j] !== 'ET') {
  40916. break;
  40917. }
  40918. types[j] = 'EN';
  40919. }
  40920. for (j = i + 1; j < strLength; ++j) {
  40921. if (types[j] !== 'ET') {
  40922. break;
  40923. }
  40924. types[j] = 'EN';
  40925. }
  40926. }
  40927. }
  40928. for (i = 0; i < strLength; ++i) {
  40929. t = types[i];
  40930. if (t === 'WS' || t === 'ES' || t === 'ET' || t === 'CS') {
  40931. types[i] = 'ON';
  40932. }
  40933. }
  40934. lastType = sor;
  40935. for (i = 0; i < strLength; ++i) {
  40936. t = types[i];
  40937. if (t === 'EN') {
  40938. types[i] = lastType === 'L' ? 'L' : 'EN';
  40939. } else if (t === 'R' || t === 'L') {
  40940. lastType = t;
  40941. }
  40942. }
  40943. for (i = 0; i < strLength; ++i) {
  40944. if (types[i] === 'ON') {
  40945. var end = findUnequal(types, i + 1, 'ON');
  40946. var before = sor;
  40947. if (i > 0) {
  40948. before = types[i - 1];
  40949. }
  40950. var after = eor;
  40951. if (end + 1 < strLength) {
  40952. after = types[end + 1];
  40953. }
  40954. if (before !== 'L') {
  40955. before = 'R';
  40956. }
  40957. if (after !== 'L') {
  40958. after = 'R';
  40959. }
  40960. if (before === after) {
  40961. setValues(types, i, end, before);
  40962. }
  40963. i = end - 1;
  40964. }
  40965. }
  40966. for (i = 0; i < strLength; ++i) {
  40967. if (types[i] === 'ON') {
  40968. types[i] = e;
  40969. }
  40970. }
  40971. for (i = 0; i < strLength; ++i) {
  40972. t = types[i];
  40973. if (isEven(levels[i])) {
  40974. if (t === 'R') {
  40975. levels[i] += 1;
  40976. } else if (t === 'AN' || t === 'EN') {
  40977. levels[i] += 2;
  40978. }
  40979. } else {
  40980. if (t === 'L' || t === 'AN' || t === 'EN') {
  40981. levels[i] += 1;
  40982. }
  40983. }
  40984. }
  40985. var highestLevel = -1;
  40986. var lowestOddLevel = 99;
  40987. var level;
  40988. for (i = 0, ii = levels.length; i < ii; ++i) {
  40989. level = levels[i];
  40990. if (highestLevel < level) {
  40991. highestLevel = level;
  40992. }
  40993. if (lowestOddLevel > level && isOdd(level)) {
  40994. lowestOddLevel = level;
  40995. }
  40996. }
  40997. for (level = highestLevel; level >= lowestOddLevel; --level) {
  40998. var start = -1;
  40999. for (i = 0, ii = levels.length; i < ii; ++i) {
  41000. if (levels[i] < level) {
  41001. if (start >= 0) {
  41002. reverseValues(chars, start, i);
  41003. start = -1;
  41004. }
  41005. } else if (start < 0) {
  41006. start = i;
  41007. }
  41008. }
  41009. if (start >= 0) {
  41010. reverseValues(chars, start, levels.length);
  41011. }
  41012. }
  41013. for (i = 0, ii = chars.length; i < ii; ++i) {
  41014. var ch = chars[i];
  41015. if (ch === '<' || ch === '>') {
  41016. chars[i] = '';
  41017. }
  41018. }
  41019. return createBidiText(chars.join(''), isLTR);
  41020. }
  41021. exports.bidi = bidi;
  41022. /***/ }),
  41023. /* 30 */
  41024. /***/ (function(module, exports, __w_pdfjs_require__) {
  41025. "use strict";
  41026. var ISOAdobeCharset = [
  41027. '.notdef',
  41028. 'space',
  41029. 'exclam',
  41030. 'quotedbl',
  41031. 'numbersign',
  41032. 'dollar',
  41033. 'percent',
  41034. 'ampersand',
  41035. 'quoteright',
  41036. 'parenleft',
  41037. 'parenright',
  41038. 'asterisk',
  41039. 'plus',
  41040. 'comma',
  41041. 'hyphen',
  41042. 'period',
  41043. 'slash',
  41044. 'zero',
  41045. 'one',
  41046. 'two',
  41047. 'three',
  41048. 'four',
  41049. 'five',
  41050. 'six',
  41051. 'seven',
  41052. 'eight',
  41053. 'nine',
  41054. 'colon',
  41055. 'semicolon',
  41056. 'less',
  41057. 'equal',
  41058. 'greater',
  41059. 'question',
  41060. 'at',
  41061. 'A',
  41062. 'B',
  41063. 'C',
  41064. 'D',
  41065. 'E',
  41066. 'F',
  41067. 'G',
  41068. 'H',
  41069. 'I',
  41070. 'J',
  41071. 'K',
  41072. 'L',
  41073. 'M',
  41074. 'N',
  41075. 'O',
  41076. 'P',
  41077. 'Q',
  41078. 'R',
  41079. 'S',
  41080. 'T',
  41081. 'U',
  41082. 'V',
  41083. 'W',
  41084. 'X',
  41085. 'Y',
  41086. 'Z',
  41087. 'bracketleft',
  41088. 'backslash',
  41089. 'bracketright',
  41090. 'asciicircum',
  41091. 'underscore',
  41092. 'quoteleft',
  41093. 'a',
  41094. 'b',
  41095. 'c',
  41096. 'd',
  41097. 'e',
  41098. 'f',
  41099. 'g',
  41100. 'h',
  41101. 'i',
  41102. 'j',
  41103. 'k',
  41104. 'l',
  41105. 'm',
  41106. 'n',
  41107. 'o',
  41108. 'p',
  41109. 'q',
  41110. 'r',
  41111. 's',
  41112. 't',
  41113. 'u',
  41114. 'v',
  41115. 'w',
  41116. 'x',
  41117. 'y',
  41118. 'z',
  41119. 'braceleft',
  41120. 'bar',
  41121. 'braceright',
  41122. 'asciitilde',
  41123. 'exclamdown',
  41124. 'cent',
  41125. 'sterling',
  41126. 'fraction',
  41127. 'yen',
  41128. 'florin',
  41129. 'section',
  41130. 'currency',
  41131. 'quotesingle',
  41132. 'quotedblleft',
  41133. 'guillemotleft',
  41134. 'guilsinglleft',
  41135. 'guilsinglright',
  41136. 'fi',
  41137. 'fl',
  41138. 'endash',
  41139. 'dagger',
  41140. 'daggerdbl',
  41141. 'periodcentered',
  41142. 'paragraph',
  41143. 'bullet',
  41144. 'quotesinglbase',
  41145. 'quotedblbase',
  41146. 'quotedblright',
  41147. 'guillemotright',
  41148. 'ellipsis',
  41149. 'perthousand',
  41150. 'questiondown',
  41151. 'grave',
  41152. 'acute',
  41153. 'circumflex',
  41154. 'tilde',
  41155. 'macron',
  41156. 'breve',
  41157. 'dotaccent',
  41158. 'dieresis',
  41159. 'ring',
  41160. 'cedilla',
  41161. 'hungarumlaut',
  41162. 'ogonek',
  41163. 'caron',
  41164. 'emdash',
  41165. 'AE',
  41166. 'ordfeminine',
  41167. 'Lslash',
  41168. 'Oslash',
  41169. 'OE',
  41170. 'ordmasculine',
  41171. 'ae',
  41172. 'dotlessi',
  41173. 'lslash',
  41174. 'oslash',
  41175. 'oe',
  41176. 'germandbls',
  41177. 'onesuperior',
  41178. 'logicalnot',
  41179. 'mu',
  41180. 'trademark',
  41181. 'Eth',
  41182. 'onehalf',
  41183. 'plusminus',
  41184. 'Thorn',
  41185. 'onequarter',
  41186. 'divide',
  41187. 'brokenbar',
  41188. 'degree',
  41189. 'thorn',
  41190. 'threequarters',
  41191. 'twosuperior',
  41192. 'registered',
  41193. 'minus',
  41194. 'eth',
  41195. 'multiply',
  41196. 'threesuperior',
  41197. 'copyright',
  41198. 'Aacute',
  41199. 'Acircumflex',
  41200. 'Adieresis',
  41201. 'Agrave',
  41202. 'Aring',
  41203. 'Atilde',
  41204. 'Ccedilla',
  41205. 'Eacute',
  41206. 'Ecircumflex',
  41207. 'Edieresis',
  41208. 'Egrave',
  41209. 'Iacute',
  41210. 'Icircumflex',
  41211. 'Idieresis',
  41212. 'Igrave',
  41213. 'Ntilde',
  41214. 'Oacute',
  41215. 'Ocircumflex',
  41216. 'Odieresis',
  41217. 'Ograve',
  41218. 'Otilde',
  41219. 'Scaron',
  41220. 'Uacute',
  41221. 'Ucircumflex',
  41222. 'Udieresis',
  41223. 'Ugrave',
  41224. 'Yacute',
  41225. 'Ydieresis',
  41226. 'Zcaron',
  41227. 'aacute',
  41228. 'acircumflex',
  41229. 'adieresis',
  41230. 'agrave',
  41231. 'aring',
  41232. 'atilde',
  41233. 'ccedilla',
  41234. 'eacute',
  41235. 'ecircumflex',
  41236. 'edieresis',
  41237. 'egrave',
  41238. 'iacute',
  41239. 'icircumflex',
  41240. 'idieresis',
  41241. 'igrave',
  41242. 'ntilde',
  41243. 'oacute',
  41244. 'ocircumflex',
  41245. 'odieresis',
  41246. 'ograve',
  41247. 'otilde',
  41248. 'scaron',
  41249. 'uacute',
  41250. 'ucircumflex',
  41251. 'udieresis',
  41252. 'ugrave',
  41253. 'yacute',
  41254. 'ydieresis',
  41255. 'zcaron'
  41256. ];
  41257. var ExpertCharset = [
  41258. '.notdef',
  41259. 'space',
  41260. 'exclamsmall',
  41261. 'Hungarumlautsmall',
  41262. 'dollaroldstyle',
  41263. 'dollarsuperior',
  41264. 'ampersandsmall',
  41265. 'Acutesmall',
  41266. 'parenleftsuperior',
  41267. 'parenrightsuperior',
  41268. 'twodotenleader',
  41269. 'onedotenleader',
  41270. 'comma',
  41271. 'hyphen',
  41272. 'period',
  41273. 'fraction',
  41274. 'zerooldstyle',
  41275. 'oneoldstyle',
  41276. 'twooldstyle',
  41277. 'threeoldstyle',
  41278. 'fouroldstyle',
  41279. 'fiveoldstyle',
  41280. 'sixoldstyle',
  41281. 'sevenoldstyle',
  41282. 'eightoldstyle',
  41283. 'nineoldstyle',
  41284. 'colon',
  41285. 'semicolon',
  41286. 'commasuperior',
  41287. 'threequartersemdash',
  41288. 'periodsuperior',
  41289. 'questionsmall',
  41290. 'asuperior',
  41291. 'bsuperior',
  41292. 'centsuperior',
  41293. 'dsuperior',
  41294. 'esuperior',
  41295. 'isuperior',
  41296. 'lsuperior',
  41297. 'msuperior',
  41298. 'nsuperior',
  41299. 'osuperior',
  41300. 'rsuperior',
  41301. 'ssuperior',
  41302. 'tsuperior',
  41303. 'ff',
  41304. 'fi',
  41305. 'fl',
  41306. 'ffi',
  41307. 'ffl',
  41308. 'parenleftinferior',
  41309. 'parenrightinferior',
  41310. 'Circumflexsmall',
  41311. 'hyphensuperior',
  41312. 'Gravesmall',
  41313. 'Asmall',
  41314. 'Bsmall',
  41315. 'Csmall',
  41316. 'Dsmall',
  41317. 'Esmall',
  41318. 'Fsmall',
  41319. 'Gsmall',
  41320. 'Hsmall',
  41321. 'Ismall',
  41322. 'Jsmall',
  41323. 'Ksmall',
  41324. 'Lsmall',
  41325. 'Msmall',
  41326. 'Nsmall',
  41327. 'Osmall',
  41328. 'Psmall',
  41329. 'Qsmall',
  41330. 'Rsmall',
  41331. 'Ssmall',
  41332. 'Tsmall',
  41333. 'Usmall',
  41334. 'Vsmall',
  41335. 'Wsmall',
  41336. 'Xsmall',
  41337. 'Ysmall',
  41338. 'Zsmall',
  41339. 'colonmonetary',
  41340. 'onefitted',
  41341. 'rupiah',
  41342. 'Tildesmall',
  41343. 'exclamdownsmall',
  41344. 'centoldstyle',
  41345. 'Lslashsmall',
  41346. 'Scaronsmall',
  41347. 'Zcaronsmall',
  41348. 'Dieresissmall',
  41349. 'Brevesmall',
  41350. 'Caronsmall',
  41351. 'Dotaccentsmall',
  41352. 'Macronsmall',
  41353. 'figuredash',
  41354. 'hypheninferior',
  41355. 'Ogoneksmall',
  41356. 'Ringsmall',
  41357. 'Cedillasmall',
  41358. 'onequarter',
  41359. 'onehalf',
  41360. 'threequarters',
  41361. 'questiondownsmall',
  41362. 'oneeighth',
  41363. 'threeeighths',
  41364. 'fiveeighths',
  41365. 'seveneighths',
  41366. 'onethird',
  41367. 'twothirds',
  41368. 'zerosuperior',
  41369. 'onesuperior',
  41370. 'twosuperior',
  41371. 'threesuperior',
  41372. 'foursuperior',
  41373. 'fivesuperior',
  41374. 'sixsuperior',
  41375. 'sevensuperior',
  41376. 'eightsuperior',
  41377. 'ninesuperior',
  41378. 'zeroinferior',
  41379. 'oneinferior',
  41380. 'twoinferior',
  41381. 'threeinferior',
  41382. 'fourinferior',
  41383. 'fiveinferior',
  41384. 'sixinferior',
  41385. 'seveninferior',
  41386. 'eightinferior',
  41387. 'nineinferior',
  41388. 'centinferior',
  41389. 'dollarinferior',
  41390. 'periodinferior',
  41391. 'commainferior',
  41392. 'Agravesmall',
  41393. 'Aacutesmall',
  41394. 'Acircumflexsmall',
  41395. 'Atildesmall',
  41396. 'Adieresissmall',
  41397. 'Aringsmall',
  41398. 'AEsmall',
  41399. 'Ccedillasmall',
  41400. 'Egravesmall',
  41401. 'Eacutesmall',
  41402. 'Ecircumflexsmall',
  41403. 'Edieresissmall',
  41404. 'Igravesmall',
  41405. 'Iacutesmall',
  41406. 'Icircumflexsmall',
  41407. 'Idieresissmall',
  41408. 'Ethsmall',
  41409. 'Ntildesmall',
  41410. 'Ogravesmall',
  41411. 'Oacutesmall',
  41412. 'Ocircumflexsmall',
  41413. 'Otildesmall',
  41414. 'Odieresissmall',
  41415. 'OEsmall',
  41416. 'Oslashsmall',
  41417. 'Ugravesmall',
  41418. 'Uacutesmall',
  41419. 'Ucircumflexsmall',
  41420. 'Udieresissmall',
  41421. 'Yacutesmall',
  41422. 'Thornsmall',
  41423. 'Ydieresissmall'
  41424. ];
  41425. var ExpertSubsetCharset = [
  41426. '.notdef',
  41427. 'space',
  41428. 'dollaroldstyle',
  41429. 'dollarsuperior',
  41430. 'parenleftsuperior',
  41431. 'parenrightsuperior',
  41432. 'twodotenleader',
  41433. 'onedotenleader',
  41434. 'comma',
  41435. 'hyphen',
  41436. 'period',
  41437. 'fraction',
  41438. 'zerooldstyle',
  41439. 'oneoldstyle',
  41440. 'twooldstyle',
  41441. 'threeoldstyle',
  41442. 'fouroldstyle',
  41443. 'fiveoldstyle',
  41444. 'sixoldstyle',
  41445. 'sevenoldstyle',
  41446. 'eightoldstyle',
  41447. 'nineoldstyle',
  41448. 'colon',
  41449. 'semicolon',
  41450. 'commasuperior',
  41451. 'threequartersemdash',
  41452. 'periodsuperior',
  41453. 'asuperior',
  41454. 'bsuperior',
  41455. 'centsuperior',
  41456. 'dsuperior',
  41457. 'esuperior',
  41458. 'isuperior',
  41459. 'lsuperior',
  41460. 'msuperior',
  41461. 'nsuperior',
  41462. 'osuperior',
  41463. 'rsuperior',
  41464. 'ssuperior',
  41465. 'tsuperior',
  41466. 'ff',
  41467. 'fi',
  41468. 'fl',
  41469. 'ffi',
  41470. 'ffl',
  41471. 'parenleftinferior',
  41472. 'parenrightinferior',
  41473. 'hyphensuperior',
  41474. 'colonmonetary',
  41475. 'onefitted',
  41476. 'rupiah',
  41477. 'centoldstyle',
  41478. 'figuredash',
  41479. 'hypheninferior',
  41480. 'onequarter',
  41481. 'onehalf',
  41482. 'threequarters',
  41483. 'oneeighth',
  41484. 'threeeighths',
  41485. 'fiveeighths',
  41486. 'seveneighths',
  41487. 'onethird',
  41488. 'twothirds',
  41489. 'zerosuperior',
  41490. 'onesuperior',
  41491. 'twosuperior',
  41492. 'threesuperior',
  41493. 'foursuperior',
  41494. 'fivesuperior',
  41495. 'sixsuperior',
  41496. 'sevensuperior',
  41497. 'eightsuperior',
  41498. 'ninesuperior',
  41499. 'zeroinferior',
  41500. 'oneinferior',
  41501. 'twoinferior',
  41502. 'threeinferior',
  41503. 'fourinferior',
  41504. 'fiveinferior',
  41505. 'sixinferior',
  41506. 'seveninferior',
  41507. 'eightinferior',
  41508. 'nineinferior',
  41509. 'centinferior',
  41510. 'dollarinferior',
  41511. 'periodinferior',
  41512. 'commainferior'
  41513. ];
  41514. exports.ISOAdobeCharset = ISOAdobeCharset;
  41515. exports.ExpertCharset = ExpertCharset;
  41516. exports.ExpertSubsetCharset = ExpertSubsetCharset;
  41517. /***/ }),
  41518. /* 31 */
  41519. /***/ (function(module, exports, __w_pdfjs_require__) {
  41520. "use strict";
  41521. var sharedUtil = __w_pdfjs_require__(0);
  41522. var corePrimitives = __w_pdfjs_require__(1);
  41523. var coreStream = __w_pdfjs_require__(2);
  41524. var coreParser = __w_pdfjs_require__(6);
  41525. var Util = sharedUtil.Util;
  41526. var assert = sharedUtil.assert;
  41527. var warn = sharedUtil.warn;
  41528. var error = sharedUtil.error;
  41529. var isInt = sharedUtil.isInt;
  41530. var isString = sharedUtil.isString;
  41531. var MissingDataException = sharedUtil.MissingDataException;
  41532. var isEOF = corePrimitives.isEOF;
  41533. var isName = corePrimitives.isName;
  41534. var isCmd = corePrimitives.isCmd;
  41535. var isStream = corePrimitives.isStream;
  41536. var StringStream = coreStream.StringStream;
  41537. var Lexer = coreParser.Lexer;
  41538. var BUILT_IN_CMAPS = [
  41539. 'Adobe-GB1-UCS2',
  41540. 'Adobe-CNS1-UCS2',
  41541. 'Adobe-Japan1-UCS2',
  41542. 'Adobe-Korea1-UCS2',
  41543. '78-EUC-H',
  41544. '78-EUC-V',
  41545. '78-H',
  41546. '78-RKSJ-H',
  41547. '78-RKSJ-V',
  41548. '78-V',
  41549. '78ms-RKSJ-H',
  41550. '78ms-RKSJ-V',
  41551. '83pv-RKSJ-H',
  41552. '90ms-RKSJ-H',
  41553. '90ms-RKSJ-V',
  41554. '90msp-RKSJ-H',
  41555. '90msp-RKSJ-V',
  41556. '90pv-RKSJ-H',
  41557. '90pv-RKSJ-V',
  41558. 'Add-H',
  41559. 'Add-RKSJ-H',
  41560. 'Add-RKSJ-V',
  41561. 'Add-V',
  41562. 'Adobe-CNS1-0',
  41563. 'Adobe-CNS1-1',
  41564. 'Adobe-CNS1-2',
  41565. 'Adobe-CNS1-3',
  41566. 'Adobe-CNS1-4',
  41567. 'Adobe-CNS1-5',
  41568. 'Adobe-CNS1-6',
  41569. 'Adobe-GB1-0',
  41570. 'Adobe-GB1-1',
  41571. 'Adobe-GB1-2',
  41572. 'Adobe-GB1-3',
  41573. 'Adobe-GB1-4',
  41574. 'Adobe-GB1-5',
  41575. 'Adobe-Japan1-0',
  41576. 'Adobe-Japan1-1',
  41577. 'Adobe-Japan1-2',
  41578. 'Adobe-Japan1-3',
  41579. 'Adobe-Japan1-4',
  41580. 'Adobe-Japan1-5',
  41581. 'Adobe-Japan1-6',
  41582. 'Adobe-Korea1-0',
  41583. 'Adobe-Korea1-1',
  41584. 'Adobe-Korea1-2',
  41585. 'B5-H',
  41586. 'B5-V',
  41587. 'B5pc-H',
  41588. 'B5pc-V',
  41589. 'CNS-EUC-H',
  41590. 'CNS-EUC-V',
  41591. 'CNS1-H',
  41592. 'CNS1-V',
  41593. 'CNS2-H',
  41594. 'CNS2-V',
  41595. 'ETHK-B5-H',
  41596. 'ETHK-B5-V',
  41597. 'ETen-B5-H',
  41598. 'ETen-B5-V',
  41599. 'ETenms-B5-H',
  41600. 'ETenms-B5-V',
  41601. 'EUC-H',
  41602. 'EUC-V',
  41603. 'Ext-H',
  41604. 'Ext-RKSJ-H',
  41605. 'Ext-RKSJ-V',
  41606. 'Ext-V',
  41607. 'GB-EUC-H',
  41608. 'GB-EUC-V',
  41609. 'GB-H',
  41610. 'GB-V',
  41611. 'GBK-EUC-H',
  41612. 'GBK-EUC-V',
  41613. 'GBK2K-H',
  41614. 'GBK2K-V',
  41615. 'GBKp-EUC-H',
  41616. 'GBKp-EUC-V',
  41617. 'GBT-EUC-H',
  41618. 'GBT-EUC-V',
  41619. 'GBT-H',
  41620. 'GBT-V',
  41621. 'GBTpc-EUC-H',
  41622. 'GBTpc-EUC-V',
  41623. 'GBpc-EUC-H',
  41624. 'GBpc-EUC-V',
  41625. 'H',
  41626. 'HKdla-B5-H',
  41627. 'HKdla-B5-V',
  41628. 'HKdlb-B5-H',
  41629. 'HKdlb-B5-V',
  41630. 'HKgccs-B5-H',
  41631. 'HKgccs-B5-V',
  41632. 'HKm314-B5-H',
  41633. 'HKm314-B5-V',
  41634. 'HKm471-B5-H',
  41635. 'HKm471-B5-V',
  41636. 'HKscs-B5-H',
  41637. 'HKscs-B5-V',
  41638. 'Hankaku',
  41639. 'Hiragana',
  41640. 'KSC-EUC-H',
  41641. 'KSC-EUC-V',
  41642. 'KSC-H',
  41643. 'KSC-Johab-H',
  41644. 'KSC-Johab-V',
  41645. 'KSC-V',
  41646. 'KSCms-UHC-H',
  41647. 'KSCms-UHC-HW-H',
  41648. 'KSCms-UHC-HW-V',
  41649. 'KSCms-UHC-V',
  41650. 'KSCpc-EUC-H',
  41651. 'KSCpc-EUC-V',
  41652. 'Katakana',
  41653. 'NWP-H',
  41654. 'NWP-V',
  41655. 'RKSJ-H',
  41656. 'RKSJ-V',
  41657. 'Roman',
  41658. 'UniCNS-UCS2-H',
  41659. 'UniCNS-UCS2-V',
  41660. 'UniCNS-UTF16-H',
  41661. 'UniCNS-UTF16-V',
  41662. 'UniCNS-UTF32-H',
  41663. 'UniCNS-UTF32-V',
  41664. 'UniCNS-UTF8-H',
  41665. 'UniCNS-UTF8-V',
  41666. 'UniGB-UCS2-H',
  41667. 'UniGB-UCS2-V',
  41668. 'UniGB-UTF16-H',
  41669. 'UniGB-UTF16-V',
  41670. 'UniGB-UTF32-H',
  41671. 'UniGB-UTF32-V',
  41672. 'UniGB-UTF8-H',
  41673. 'UniGB-UTF8-V',
  41674. 'UniJIS-UCS2-H',
  41675. 'UniJIS-UCS2-HW-H',
  41676. 'UniJIS-UCS2-HW-V',
  41677. 'UniJIS-UCS2-V',
  41678. 'UniJIS-UTF16-H',
  41679. 'UniJIS-UTF16-V',
  41680. 'UniJIS-UTF32-H',
  41681. 'UniJIS-UTF32-V',
  41682. 'UniJIS-UTF8-H',
  41683. 'UniJIS-UTF8-V',
  41684. 'UniJIS2004-UTF16-H',
  41685. 'UniJIS2004-UTF16-V',
  41686. 'UniJIS2004-UTF32-H',
  41687. 'UniJIS2004-UTF32-V',
  41688. 'UniJIS2004-UTF8-H',
  41689. 'UniJIS2004-UTF8-V',
  41690. 'UniJISPro-UCS2-HW-V',
  41691. 'UniJISPro-UCS2-V',
  41692. 'UniJISPro-UTF8-V',
  41693. 'UniJISX0213-UTF32-H',
  41694. 'UniJISX0213-UTF32-V',
  41695. 'UniJISX02132004-UTF32-H',
  41696. 'UniJISX02132004-UTF32-V',
  41697. 'UniKS-UCS2-H',
  41698. 'UniKS-UCS2-V',
  41699. 'UniKS-UTF16-H',
  41700. 'UniKS-UTF16-V',
  41701. 'UniKS-UTF32-H',
  41702. 'UniKS-UTF32-V',
  41703. 'UniKS-UTF8-H',
  41704. 'UniKS-UTF8-V',
  41705. 'V',
  41706. 'WP-Symbol'
  41707. ];
  41708. var CMap = function CMapClosure() {
  41709. function CMap(builtInCMap) {
  41710. this.codespaceRanges = [
  41711. [],
  41712. [],
  41713. [],
  41714. []
  41715. ];
  41716. this.numCodespaceRanges = 0;
  41717. this._map = [];
  41718. this.name = '';
  41719. this.vertical = false;
  41720. this.useCMap = null;
  41721. this.builtInCMap = builtInCMap;
  41722. }
  41723. CMap.prototype = {
  41724. addCodespaceRange: function (n, low, high) {
  41725. this.codespaceRanges[n - 1].push(low, high);
  41726. this.numCodespaceRanges++;
  41727. },
  41728. mapCidRange: function (low, high, dstLow) {
  41729. while (low <= high) {
  41730. this._map[low++] = dstLow++;
  41731. }
  41732. },
  41733. mapBfRange: function (low, high, dstLow) {
  41734. var lastByte = dstLow.length - 1;
  41735. while (low <= high) {
  41736. this._map[low++] = dstLow;
  41737. dstLow = dstLow.substr(0, lastByte) + String.fromCharCode(dstLow.charCodeAt(lastByte) + 1);
  41738. }
  41739. },
  41740. mapBfRangeToArray: function (low, high, array) {
  41741. var i = 0, ii = array.length;
  41742. while (low <= high && i < ii) {
  41743. this._map[low] = array[i++];
  41744. ++low;
  41745. }
  41746. },
  41747. mapOne: function (src, dst) {
  41748. this._map[src] = dst;
  41749. },
  41750. lookup: function (code) {
  41751. return this._map[code];
  41752. },
  41753. contains: function (code) {
  41754. return this._map[code] !== undefined;
  41755. },
  41756. forEach: function (callback) {
  41757. var map = this._map;
  41758. var length = map.length;
  41759. var i;
  41760. if (length <= 0x10000) {
  41761. for (i = 0; i < length; i++) {
  41762. if (map[i] !== undefined) {
  41763. callback(i, map[i]);
  41764. }
  41765. }
  41766. } else {
  41767. for (i in this._map) {
  41768. callback(i, map[i]);
  41769. }
  41770. }
  41771. },
  41772. charCodeOf: function (value) {
  41773. return this._map.indexOf(value);
  41774. },
  41775. getMap: function () {
  41776. return this._map;
  41777. },
  41778. readCharCode: function (str, offset, out) {
  41779. var c = 0;
  41780. var codespaceRanges = this.codespaceRanges;
  41781. var codespaceRangesLen = this.codespaceRanges.length;
  41782. for (var n = 0; n < codespaceRangesLen; n++) {
  41783. c = (c << 8 | str.charCodeAt(offset + n)) >>> 0;
  41784. var codespaceRange = codespaceRanges[n];
  41785. for (var k = 0, kk = codespaceRange.length; k < kk;) {
  41786. var low = codespaceRange[k++];
  41787. var high = codespaceRange[k++];
  41788. if (c >= low && c <= high) {
  41789. out.charcode = c;
  41790. out.length = n + 1;
  41791. return;
  41792. }
  41793. }
  41794. }
  41795. out.charcode = 0;
  41796. out.length = 1;
  41797. },
  41798. get length() {
  41799. return this._map.length;
  41800. },
  41801. get isIdentityCMap() {
  41802. if (!(this.name === 'Identity-H' || this.name === 'Identity-V')) {
  41803. return false;
  41804. }
  41805. if (this._map.length !== 0x10000) {
  41806. return false;
  41807. }
  41808. for (var i = 0; i < 0x10000; i++) {
  41809. if (this._map[i] !== i) {
  41810. return false;
  41811. }
  41812. }
  41813. return true;
  41814. }
  41815. };
  41816. return CMap;
  41817. }();
  41818. var IdentityCMap = function IdentityCMapClosure() {
  41819. function IdentityCMap(vertical, n) {
  41820. CMap.call(this);
  41821. this.vertical = vertical;
  41822. this.addCodespaceRange(n, 0, 0xffff);
  41823. }
  41824. Util.inherit(IdentityCMap, CMap, {});
  41825. IdentityCMap.prototype = {
  41826. addCodespaceRange: CMap.prototype.addCodespaceRange,
  41827. mapCidRange: function (low, high, dstLow) {
  41828. error('should not call mapCidRange');
  41829. },
  41830. mapBfRange: function (low, high, dstLow) {
  41831. error('should not call mapBfRange');
  41832. },
  41833. mapBfRangeToArray: function (low, high, array) {
  41834. error('should not call mapBfRangeToArray');
  41835. },
  41836. mapOne: function (src, dst) {
  41837. error('should not call mapCidOne');
  41838. },
  41839. lookup: function (code) {
  41840. return isInt(code) && code <= 0xffff ? code : undefined;
  41841. },
  41842. contains: function (code) {
  41843. return isInt(code) && code <= 0xffff;
  41844. },
  41845. forEach: function (callback) {
  41846. for (var i = 0; i <= 0xffff; i++) {
  41847. callback(i, i);
  41848. }
  41849. },
  41850. charCodeOf: function (value) {
  41851. return isInt(value) && value <= 0xffff ? value : -1;
  41852. },
  41853. getMap: function () {
  41854. var map = new Array(0x10000);
  41855. for (var i = 0; i <= 0xffff; i++) {
  41856. map[i] = i;
  41857. }
  41858. return map;
  41859. },
  41860. readCharCode: CMap.prototype.readCharCode,
  41861. get length() {
  41862. return 0x10000;
  41863. },
  41864. get isIdentityCMap() {
  41865. error('should not access .isIdentityCMap');
  41866. }
  41867. };
  41868. return IdentityCMap;
  41869. }();
  41870. var BinaryCMapReader = function BinaryCMapReaderClosure() {
  41871. function fetchBinaryData(url) {
  41872. return new Promise(function (resolve, reject) {
  41873. var request = new XMLHttpRequest();
  41874. request.open('GET', url, true);
  41875. request.responseType = 'arraybuffer';
  41876. request.onreadystatechange = function () {
  41877. if (request.readyState === XMLHttpRequest.DONE) {
  41878. if (!request.response || request.status !== 200 && request.status !== 0) {
  41879. reject(new Error('Unable to get binary cMap at: ' + url));
  41880. } else {
  41881. resolve(new Uint8Array(request.response));
  41882. }
  41883. }
  41884. };
  41885. request.send(null);
  41886. });
  41887. }
  41888. function hexToInt(a, size) {
  41889. var n = 0;
  41890. for (var i = 0; i <= size; i++) {
  41891. n = n << 8 | a[i];
  41892. }
  41893. return n >>> 0;
  41894. }
  41895. function hexToStr(a, size) {
  41896. if (size === 1) {
  41897. return String.fromCharCode(a[0], a[1]);
  41898. }
  41899. if (size === 3) {
  41900. return String.fromCharCode(a[0], a[1], a[2], a[3]);
  41901. }
  41902. return String.fromCharCode.apply(null, a.subarray(0, size + 1));
  41903. }
  41904. function addHex(a, b, size) {
  41905. var c = 0;
  41906. for (var i = size; i >= 0; i--) {
  41907. c += a[i] + b[i];
  41908. a[i] = c & 255;
  41909. c >>= 8;
  41910. }
  41911. }
  41912. function incHex(a, size) {
  41913. var c = 1;
  41914. for (var i = size; i >= 0 && c > 0; i--) {
  41915. c += a[i];
  41916. a[i] = c & 255;
  41917. c >>= 8;
  41918. }
  41919. }
  41920. var MAX_NUM_SIZE = 16;
  41921. var MAX_ENCODED_NUM_SIZE = 19;
  41922. function BinaryCMapStream(data) {
  41923. this.buffer = data;
  41924. this.pos = 0;
  41925. this.end = data.length;
  41926. this.tmpBuf = new Uint8Array(MAX_ENCODED_NUM_SIZE);
  41927. }
  41928. BinaryCMapStream.prototype = {
  41929. readByte: function () {
  41930. if (this.pos >= this.end) {
  41931. return -1;
  41932. }
  41933. return this.buffer[this.pos++];
  41934. },
  41935. readNumber: function () {
  41936. var n = 0;
  41937. var last;
  41938. do {
  41939. var b = this.readByte();
  41940. if (b < 0) {
  41941. error('unexpected EOF in bcmap');
  41942. }
  41943. last = !(b & 0x80);
  41944. n = n << 7 | b & 0x7F;
  41945. } while (!last);
  41946. return n;
  41947. },
  41948. readSigned: function () {
  41949. var n = this.readNumber();
  41950. return n & 1 ? ~(n >>> 1) : n >>> 1;
  41951. },
  41952. readHex: function (num, size) {
  41953. num.set(this.buffer.subarray(this.pos, this.pos + size + 1));
  41954. this.pos += size + 1;
  41955. },
  41956. readHexNumber: function (num, size) {
  41957. var last;
  41958. var stack = this.tmpBuf, sp = 0;
  41959. do {
  41960. var b = this.readByte();
  41961. if (b < 0) {
  41962. error('unexpected EOF in bcmap');
  41963. }
  41964. last = !(b & 0x80);
  41965. stack[sp++] = b & 0x7F;
  41966. } while (!last);
  41967. var i = size, buffer = 0, bufferSize = 0;
  41968. while (i >= 0) {
  41969. while (bufferSize < 8 && stack.length > 0) {
  41970. buffer = stack[--sp] << bufferSize | buffer;
  41971. bufferSize += 7;
  41972. }
  41973. num[i] = buffer & 255;
  41974. i--;
  41975. buffer >>= 8;
  41976. bufferSize -= 8;
  41977. }
  41978. },
  41979. readHexSigned: function (num, size) {
  41980. this.readHexNumber(num, size);
  41981. var sign = num[size] & 1 ? 255 : 0;
  41982. var c = 0;
  41983. for (var i = 0; i <= size; i++) {
  41984. c = (c & 1) << 8 | num[i];
  41985. num[i] = c >> 1 ^ sign;
  41986. }
  41987. },
  41988. readString: function () {
  41989. var len = this.readNumber();
  41990. var s = '';
  41991. for (var i = 0; i < len; i++) {
  41992. s += String.fromCharCode(this.readNumber());
  41993. }
  41994. return s;
  41995. }
  41996. };
  41997. function processBinaryCMap(url, cMap, extend) {
  41998. return fetchBinaryData(url).then(function (data) {
  41999. var stream = new BinaryCMapStream(data);
  42000. var header = stream.readByte();
  42001. cMap.vertical = !!(header & 1);
  42002. var useCMap = null;
  42003. var start = new Uint8Array(MAX_NUM_SIZE);
  42004. var end = new Uint8Array(MAX_NUM_SIZE);
  42005. var char = new Uint8Array(MAX_NUM_SIZE);
  42006. var charCode = new Uint8Array(MAX_NUM_SIZE);
  42007. var tmp = new Uint8Array(MAX_NUM_SIZE);
  42008. var code;
  42009. var b;
  42010. while ((b = stream.readByte()) >= 0) {
  42011. var type = b >> 5;
  42012. if (type === 7) {
  42013. switch (b & 0x1F) {
  42014. case 0:
  42015. stream.readString();
  42016. break;
  42017. case 1:
  42018. useCMap = stream.readString();
  42019. break;
  42020. }
  42021. continue;
  42022. }
  42023. var sequence = !!(b & 0x10);
  42024. var dataSize = b & 15;
  42025. assert(dataSize + 1 <= MAX_NUM_SIZE);
  42026. var ucs2DataSize = 1;
  42027. var subitemsCount = stream.readNumber();
  42028. var i;
  42029. switch (type) {
  42030. case 0:
  42031. stream.readHex(start, dataSize);
  42032. stream.readHexNumber(end, dataSize);
  42033. addHex(end, start, dataSize);
  42034. cMap.addCodespaceRange(dataSize + 1, hexToInt(start, dataSize), hexToInt(end, dataSize));
  42035. for (i = 1; i < subitemsCount; i++) {
  42036. incHex(end, dataSize);
  42037. stream.readHexNumber(start, dataSize);
  42038. addHex(start, end, dataSize);
  42039. stream.readHexNumber(end, dataSize);
  42040. addHex(end, start, dataSize);
  42041. cMap.addCodespaceRange(dataSize + 1, hexToInt(start, dataSize), hexToInt(end, dataSize));
  42042. }
  42043. break;
  42044. case 1:
  42045. stream.readHex(start, dataSize);
  42046. stream.readHexNumber(end, dataSize);
  42047. addHex(end, start, dataSize);
  42048. code = stream.readNumber();
  42049. for (i = 1; i < subitemsCount; i++) {
  42050. incHex(end, dataSize);
  42051. stream.readHexNumber(start, dataSize);
  42052. addHex(start, end, dataSize);
  42053. stream.readHexNumber(end, dataSize);
  42054. addHex(end, start, dataSize);
  42055. code = stream.readNumber();
  42056. }
  42057. break;
  42058. case 2:
  42059. stream.readHex(char, dataSize);
  42060. code = stream.readNumber();
  42061. cMap.mapOne(hexToInt(char, dataSize), code);
  42062. for (i = 1; i < subitemsCount; i++) {
  42063. incHex(char, dataSize);
  42064. if (!sequence) {
  42065. stream.readHexNumber(tmp, dataSize);
  42066. addHex(char, tmp, dataSize);
  42067. }
  42068. code = stream.readSigned() + (code + 1);
  42069. cMap.mapOne(hexToInt(char, dataSize), code);
  42070. }
  42071. break;
  42072. case 3:
  42073. stream.readHex(start, dataSize);
  42074. stream.readHexNumber(end, dataSize);
  42075. addHex(end, start, dataSize);
  42076. code = stream.readNumber();
  42077. cMap.mapCidRange(hexToInt(start, dataSize), hexToInt(end, dataSize), code);
  42078. for (i = 1; i < subitemsCount; i++) {
  42079. incHex(end, dataSize);
  42080. if (!sequence) {
  42081. stream.readHexNumber(start, dataSize);
  42082. addHex(start, end, dataSize);
  42083. } else {
  42084. start.set(end);
  42085. }
  42086. stream.readHexNumber(end, dataSize);
  42087. addHex(end, start, dataSize);
  42088. code = stream.readNumber();
  42089. cMap.mapCidRange(hexToInt(start, dataSize), hexToInt(end, dataSize), code);
  42090. }
  42091. break;
  42092. case 4:
  42093. stream.readHex(char, ucs2DataSize);
  42094. stream.readHex(charCode, dataSize);
  42095. cMap.mapOne(hexToInt(char, ucs2DataSize), hexToStr(charCode, dataSize));
  42096. for (i = 1; i < subitemsCount; i++) {
  42097. incHex(char, ucs2DataSize);
  42098. if (!sequence) {
  42099. stream.readHexNumber(tmp, ucs2DataSize);
  42100. addHex(char, tmp, ucs2DataSize);
  42101. }
  42102. incHex(charCode, dataSize);
  42103. stream.readHexSigned(tmp, dataSize);
  42104. addHex(charCode, tmp, dataSize);
  42105. cMap.mapOne(hexToInt(char, ucs2DataSize), hexToStr(charCode, dataSize));
  42106. }
  42107. break;
  42108. case 5:
  42109. stream.readHex(start, ucs2DataSize);
  42110. stream.readHexNumber(end, ucs2DataSize);
  42111. addHex(end, start, ucs2DataSize);
  42112. stream.readHex(charCode, dataSize);
  42113. cMap.mapBfRange(hexToInt(start, ucs2DataSize), hexToInt(end, ucs2DataSize), hexToStr(charCode, dataSize));
  42114. for (i = 1; i < subitemsCount; i++) {
  42115. incHex(end, ucs2DataSize);
  42116. if (!sequence) {
  42117. stream.readHexNumber(start, ucs2DataSize);
  42118. addHex(start, end, ucs2DataSize);
  42119. } else {
  42120. start.set(end);
  42121. }
  42122. stream.readHexNumber(end, ucs2DataSize);
  42123. addHex(end, start, ucs2DataSize);
  42124. stream.readHex(charCode, dataSize);
  42125. cMap.mapBfRange(hexToInt(start, ucs2DataSize), hexToInt(end, ucs2DataSize), hexToStr(charCode, dataSize));
  42126. }
  42127. break;
  42128. default:
  42129. error('Unknown type: ' + type);
  42130. break;
  42131. }
  42132. }
  42133. if (useCMap) {
  42134. return extend(useCMap);
  42135. }
  42136. return cMap;
  42137. });
  42138. }
  42139. function BinaryCMapReader() {
  42140. }
  42141. BinaryCMapReader.prototype = { read: processBinaryCMap };
  42142. return BinaryCMapReader;
  42143. }();
  42144. var CMapFactory = function CMapFactoryClosure() {
  42145. function strToInt(str) {
  42146. var a = 0;
  42147. for (var i = 0; i < str.length; i++) {
  42148. a = a << 8 | str.charCodeAt(i);
  42149. }
  42150. return a >>> 0;
  42151. }
  42152. function expectString(obj) {
  42153. if (!isString(obj)) {
  42154. error('Malformed CMap: expected string.');
  42155. }
  42156. }
  42157. function expectInt(obj) {
  42158. if (!isInt(obj)) {
  42159. error('Malformed CMap: expected int.');
  42160. }
  42161. }
  42162. function parseBfChar(cMap, lexer) {
  42163. while (true) {
  42164. var obj = lexer.getObj();
  42165. if (isEOF(obj)) {
  42166. break;
  42167. }
  42168. if (isCmd(obj, 'endbfchar')) {
  42169. return;
  42170. }
  42171. expectString(obj);
  42172. var src = strToInt(obj);
  42173. obj = lexer.getObj();
  42174. expectString(obj);
  42175. var dst = obj;
  42176. cMap.mapOne(src, dst);
  42177. }
  42178. }
  42179. function parseBfRange(cMap, lexer) {
  42180. while (true) {
  42181. var obj = lexer.getObj();
  42182. if (isEOF(obj)) {
  42183. break;
  42184. }
  42185. if (isCmd(obj, 'endbfrange')) {
  42186. return;
  42187. }
  42188. expectString(obj);
  42189. var low = strToInt(obj);
  42190. obj = lexer.getObj();
  42191. expectString(obj);
  42192. var high = strToInt(obj);
  42193. obj = lexer.getObj();
  42194. if (isInt(obj) || isString(obj)) {
  42195. var dstLow = isInt(obj) ? String.fromCharCode(obj) : obj;
  42196. cMap.mapBfRange(low, high, dstLow);
  42197. } else if (isCmd(obj, '[')) {
  42198. obj = lexer.getObj();
  42199. var array = [];
  42200. while (!isCmd(obj, ']') && !isEOF(obj)) {
  42201. array.push(obj);
  42202. obj = lexer.getObj();
  42203. }
  42204. cMap.mapBfRangeToArray(low, high, array);
  42205. } else {
  42206. break;
  42207. }
  42208. }
  42209. error('Invalid bf range.');
  42210. }
  42211. function parseCidChar(cMap, lexer) {
  42212. while (true) {
  42213. var obj = lexer.getObj();
  42214. if (isEOF(obj)) {
  42215. break;
  42216. }
  42217. if (isCmd(obj, 'endcidchar')) {
  42218. return;
  42219. }
  42220. expectString(obj);
  42221. var src = strToInt(obj);
  42222. obj = lexer.getObj();
  42223. expectInt(obj);
  42224. var dst = obj;
  42225. cMap.mapOne(src, dst);
  42226. }
  42227. }
  42228. function parseCidRange(cMap, lexer) {
  42229. while (true) {
  42230. var obj = lexer.getObj();
  42231. if (isEOF(obj)) {
  42232. break;
  42233. }
  42234. if (isCmd(obj, 'endcidrange')) {
  42235. return;
  42236. }
  42237. expectString(obj);
  42238. var low = strToInt(obj);
  42239. obj = lexer.getObj();
  42240. expectString(obj);
  42241. var high = strToInt(obj);
  42242. obj = lexer.getObj();
  42243. expectInt(obj);
  42244. var dstLow = obj;
  42245. cMap.mapCidRange(low, high, dstLow);
  42246. }
  42247. }
  42248. function parseCodespaceRange(cMap, lexer) {
  42249. while (true) {
  42250. var obj = lexer.getObj();
  42251. if (isEOF(obj)) {
  42252. break;
  42253. }
  42254. if (isCmd(obj, 'endcodespacerange')) {
  42255. return;
  42256. }
  42257. if (!isString(obj)) {
  42258. break;
  42259. }
  42260. var low = strToInt(obj);
  42261. obj = lexer.getObj();
  42262. if (!isString(obj)) {
  42263. break;
  42264. }
  42265. var high = strToInt(obj);
  42266. cMap.addCodespaceRange(obj.length, low, high);
  42267. }
  42268. error('Invalid codespace range.');
  42269. }
  42270. function parseWMode(cMap, lexer) {
  42271. var obj = lexer.getObj();
  42272. if (isInt(obj)) {
  42273. cMap.vertical = !!obj;
  42274. }
  42275. }
  42276. function parseCMapName(cMap, lexer) {
  42277. var obj = lexer.getObj();
  42278. if (isName(obj) && isString(obj.name)) {
  42279. cMap.name = obj.name;
  42280. }
  42281. }
  42282. function parseCMap(cMap, lexer, builtInCMapParams, useCMap) {
  42283. var previous;
  42284. var embededUseCMap;
  42285. objLoop:
  42286. while (true) {
  42287. try {
  42288. var obj = lexer.getObj();
  42289. if (isEOF(obj)) {
  42290. break;
  42291. } else if (isName(obj)) {
  42292. if (obj.name === 'WMode') {
  42293. parseWMode(cMap, lexer);
  42294. } else if (obj.name === 'CMapName') {
  42295. parseCMapName(cMap, lexer);
  42296. }
  42297. previous = obj;
  42298. } else if (isCmd(obj)) {
  42299. switch (obj.cmd) {
  42300. case 'endcmap':
  42301. break objLoop;
  42302. case 'usecmap':
  42303. if (isName(previous)) {
  42304. embededUseCMap = previous.name;
  42305. }
  42306. break;
  42307. case 'begincodespacerange':
  42308. parseCodespaceRange(cMap, lexer);
  42309. break;
  42310. case 'beginbfchar':
  42311. parseBfChar(cMap, lexer);
  42312. break;
  42313. case 'begincidchar':
  42314. parseCidChar(cMap, lexer);
  42315. break;
  42316. case 'beginbfrange':
  42317. parseBfRange(cMap, lexer);
  42318. break;
  42319. case 'begincidrange':
  42320. parseCidRange(cMap, lexer);
  42321. break;
  42322. }
  42323. }
  42324. } catch (ex) {
  42325. if (ex instanceof MissingDataException) {
  42326. throw ex;
  42327. }
  42328. warn('Invalid cMap data: ' + ex);
  42329. continue;
  42330. }
  42331. }
  42332. if (!useCMap && embededUseCMap) {
  42333. useCMap = embededUseCMap;
  42334. }
  42335. if (useCMap) {
  42336. return extendCMap(cMap, builtInCMapParams, useCMap);
  42337. }
  42338. return Promise.resolve(cMap);
  42339. }
  42340. function extendCMap(cMap, builtInCMapParams, useCMap) {
  42341. return createBuiltInCMap(useCMap, builtInCMapParams).then(function (newCMap) {
  42342. cMap.useCMap = newCMap;
  42343. if (cMap.numCodespaceRanges === 0) {
  42344. var useCodespaceRanges = cMap.useCMap.codespaceRanges;
  42345. for (var i = 0; i < useCodespaceRanges.length; i++) {
  42346. cMap.codespaceRanges[i] = useCodespaceRanges[i].slice();
  42347. }
  42348. cMap.numCodespaceRanges = cMap.useCMap.numCodespaceRanges;
  42349. }
  42350. cMap.useCMap.forEach(function (key, value) {
  42351. if (!cMap.contains(key)) {
  42352. cMap.mapOne(key, cMap.useCMap.lookup(key));
  42353. }
  42354. });
  42355. return cMap;
  42356. });
  42357. }
  42358. function parseBinaryCMap(name, builtInCMapParams) {
  42359. var url = builtInCMapParams.url + name + '.bcmap';
  42360. var cMap = new CMap(true);
  42361. return new BinaryCMapReader().read(url, cMap, function (useCMap) {
  42362. return extendCMap(cMap, builtInCMapParams, useCMap);
  42363. });
  42364. }
  42365. function createBuiltInCMap(name, builtInCMapParams) {
  42366. if (name === 'Identity-H') {
  42367. return Promise.resolve(new IdentityCMap(false, 2));
  42368. } else if (name === 'Identity-V') {
  42369. return Promise.resolve(new IdentityCMap(true, 2));
  42370. }
  42371. if (BUILT_IN_CMAPS.indexOf(name) === -1) {
  42372. return Promise.reject(new Error('Unknown cMap name: ' + name));
  42373. }
  42374. assert(builtInCMapParams, 'built-in cMap parameters are not provided');
  42375. if (builtInCMapParams.packed) {
  42376. return parseBinaryCMap(name, builtInCMapParams);
  42377. }
  42378. return new Promise(function (resolve, reject) {
  42379. var url = builtInCMapParams.url + name;
  42380. var request = new XMLHttpRequest();
  42381. request.onreadystatechange = function () {
  42382. if (request.readyState === XMLHttpRequest.DONE) {
  42383. if (request.status === 200 || request.status === 0) {
  42384. var cMap = new CMap(true);
  42385. var lexer = new Lexer(new StringStream(request.responseText));
  42386. parseCMap(cMap, lexer, builtInCMapParams, null).then(function (parsedCMap) {
  42387. resolve(parsedCMap);
  42388. });
  42389. } else {
  42390. reject(new Error('Unable to get cMap at: ' + url));
  42391. }
  42392. }
  42393. };
  42394. request.open('GET', url, true);
  42395. request.send(null);
  42396. });
  42397. }
  42398. return {
  42399. create: function (encoding, builtInCMapParams, useCMap) {
  42400. if (isName(encoding)) {
  42401. return createBuiltInCMap(encoding.name, builtInCMapParams);
  42402. } else if (isStream(encoding)) {
  42403. var cMap = new CMap();
  42404. var lexer = new Lexer(encoding);
  42405. return parseCMap(cMap, lexer, builtInCMapParams, useCMap).then(function (parsedCMap) {
  42406. if (parsedCMap.isIdentityCMap) {
  42407. return createBuiltInCMap(parsedCMap.name, builtInCMapParams);
  42408. }
  42409. return parsedCMap;
  42410. });
  42411. }
  42412. return Promise.reject(new Error('Encoding required.'));
  42413. }
  42414. };
  42415. }();
  42416. exports.CMap = CMap;
  42417. exports.CMapFactory = CMapFactory;
  42418. exports.IdentityCMap = IdentityCMap;
  42419. /***/ }),
  42420. /* 32 */
  42421. /***/ (function(module, exports, __w_pdfjs_require__) {
  42422. "use strict";
  42423. var sharedUtil = __w_pdfjs_require__(0);
  42424. var corePrimitives = __w_pdfjs_require__(1);
  42425. var coreStream = __w_pdfjs_require__(2);
  42426. var coreObj = __w_pdfjs_require__(19);
  42427. var coreParser = __w_pdfjs_require__(6);
  42428. var coreCrypto = __w_pdfjs_require__(16);
  42429. var coreEvaluator = __w_pdfjs_require__(17);
  42430. var coreAnnotation = __w_pdfjs_require__(28);
  42431. var MissingDataException = sharedUtil.MissingDataException;
  42432. var Util = sharedUtil.Util;
  42433. var assert = sharedUtil.assert;
  42434. var error = sharedUtil.error;
  42435. var info = sharedUtil.info;
  42436. var isArray = sharedUtil.isArray;
  42437. var isArrayBuffer = sharedUtil.isArrayBuffer;
  42438. var isNum = sharedUtil.isNum;
  42439. var isString = sharedUtil.isString;
  42440. var shadow = sharedUtil.shadow;
  42441. var stringToBytes = sharedUtil.stringToBytes;
  42442. var stringToPDFString = sharedUtil.stringToPDFString;
  42443. var warn = sharedUtil.warn;
  42444. var isSpace = sharedUtil.isSpace;
  42445. var Dict = corePrimitives.Dict;
  42446. var isDict = corePrimitives.isDict;
  42447. var isName = corePrimitives.isName;
  42448. var isStream = corePrimitives.isStream;
  42449. var NullStream = coreStream.NullStream;
  42450. var Stream = coreStream.Stream;
  42451. var StreamsSequenceStream = coreStream.StreamsSequenceStream;
  42452. var Catalog = coreObj.Catalog;
  42453. var ObjectLoader = coreObj.ObjectLoader;
  42454. var XRef = coreObj.XRef;
  42455. var Linearization = coreParser.Linearization;
  42456. var calculateMD5 = coreCrypto.calculateMD5;
  42457. var OperatorList = coreEvaluator.OperatorList;
  42458. var PartialEvaluator = coreEvaluator.PartialEvaluator;
  42459. var Annotation = coreAnnotation.Annotation;
  42460. var AnnotationFactory = coreAnnotation.AnnotationFactory;
  42461. var Page = function PageClosure() {
  42462. var DEFAULT_USER_UNIT = 1.0;
  42463. var LETTER_SIZE_MEDIABOX = [
  42464. 0,
  42465. 0,
  42466. 612,
  42467. 792
  42468. ];
  42469. function Page(pdfManager, xref, pageIndex, pageDict, ref, fontCache) {
  42470. this.pdfManager = pdfManager;
  42471. this.pageIndex = pageIndex;
  42472. this.pageDict = pageDict;
  42473. this.xref = xref;
  42474. this.ref = ref;
  42475. this.fontCache = fontCache;
  42476. this.evaluatorOptions = pdfManager.evaluatorOptions;
  42477. this.resourcesPromise = null;
  42478. var uniquePrefix = 'p' + this.pageIndex + '_';
  42479. var idCounters = { obj: 0 };
  42480. this.idFactory = {
  42481. createObjId: function () {
  42482. return uniquePrefix + ++idCounters.obj;
  42483. }
  42484. };
  42485. }
  42486. Page.prototype = {
  42487. getPageProp: function Page_getPageProp(key) {
  42488. return this.pageDict.get(key);
  42489. },
  42490. getInheritedPageProp: function Page_getInheritedPageProp(key, getArray) {
  42491. var dict = this.pageDict, valueArray = null, loopCount = 0;
  42492. var MAX_LOOP_COUNT = 100;
  42493. getArray = getArray || false;
  42494. while (dict) {
  42495. var value = getArray ? dict.getArray(key) : dict.get(key);
  42496. if (value) {
  42497. if (!valueArray) {
  42498. valueArray = [];
  42499. }
  42500. valueArray.push(value);
  42501. }
  42502. if (++loopCount > MAX_LOOP_COUNT) {
  42503. warn('Page_getInheritedPageProp: maximum loop count exceeded.');
  42504. break;
  42505. }
  42506. dict = dict.get('Parent');
  42507. }
  42508. if (!valueArray) {
  42509. return Dict.empty;
  42510. }
  42511. if (valueArray.length === 1 || !isDict(valueArray[0]) || loopCount > MAX_LOOP_COUNT) {
  42512. return valueArray[0];
  42513. }
  42514. return Dict.merge(this.xref, valueArray);
  42515. },
  42516. get content() {
  42517. return this.getPageProp('Contents');
  42518. },
  42519. get resources() {
  42520. return shadow(this, 'resources', this.getInheritedPageProp('Resources'));
  42521. },
  42522. get mediaBox() {
  42523. var mediaBox = this.getInheritedPageProp('MediaBox', true);
  42524. if (!isArray(mediaBox) || mediaBox.length !== 4) {
  42525. return shadow(this, 'mediaBox', LETTER_SIZE_MEDIABOX);
  42526. }
  42527. return shadow(this, 'mediaBox', mediaBox);
  42528. },
  42529. get cropBox() {
  42530. var cropBox = this.getInheritedPageProp('CropBox', true);
  42531. if (!isArray(cropBox) || cropBox.length !== 4) {
  42532. return shadow(this, 'cropBox', this.mediaBox);
  42533. }
  42534. return shadow(this, 'cropBox', cropBox);
  42535. },
  42536. get userUnit() {
  42537. var obj = this.getPageProp('UserUnit');
  42538. if (!isNum(obj) || obj <= 0) {
  42539. obj = DEFAULT_USER_UNIT;
  42540. }
  42541. return shadow(this, 'userUnit', obj);
  42542. },
  42543. get view() {
  42544. var mediaBox = this.mediaBox, cropBox = this.cropBox;
  42545. if (mediaBox === cropBox) {
  42546. return shadow(this, 'view', mediaBox);
  42547. }
  42548. var intersection = Util.intersect(cropBox, mediaBox);
  42549. return shadow(this, 'view', intersection || mediaBox);
  42550. },
  42551. get rotate() {
  42552. var rotate = this.getInheritedPageProp('Rotate') || 0;
  42553. if (rotate % 90 !== 0) {
  42554. rotate = 0;
  42555. } else if (rotate >= 360) {
  42556. rotate = rotate % 360;
  42557. } else if (rotate < 0) {
  42558. rotate = (rotate % 360 + 360) % 360;
  42559. }
  42560. return shadow(this, 'rotate', rotate);
  42561. },
  42562. getContentStream: function Page_getContentStream() {
  42563. var content = this.content;
  42564. var stream;
  42565. if (isArray(content)) {
  42566. var xref = this.xref;
  42567. var i, n = content.length;
  42568. var streams = [];
  42569. for (i = 0; i < n; ++i) {
  42570. streams.push(xref.fetchIfRef(content[i]));
  42571. }
  42572. stream = new StreamsSequenceStream(streams);
  42573. } else if (isStream(content)) {
  42574. stream = content;
  42575. } else {
  42576. stream = new NullStream();
  42577. }
  42578. return stream;
  42579. },
  42580. loadResources: function Page_loadResources(keys) {
  42581. if (!this.resourcesPromise) {
  42582. this.resourcesPromise = this.pdfManager.ensure(this, 'resources');
  42583. }
  42584. return this.resourcesPromise.then(function resourceSuccess() {
  42585. var objectLoader = new ObjectLoader(this.resources.map, keys, this.xref);
  42586. return objectLoader.load();
  42587. }.bind(this));
  42588. },
  42589. getOperatorList: function Page_getOperatorList(handler, task, intent, renderInteractiveForms) {
  42590. var self = this;
  42591. var pdfManager = this.pdfManager;
  42592. var contentStreamPromise = pdfManager.ensure(this, 'getContentStream', []);
  42593. var resourcesPromise = this.loadResources([
  42594. 'ExtGState',
  42595. 'ColorSpace',
  42596. 'Pattern',
  42597. 'Shading',
  42598. 'XObject',
  42599. 'Font'
  42600. ]);
  42601. var partialEvaluator = new PartialEvaluator(pdfManager, this.xref, handler, this.pageIndex, this.idFactory, this.fontCache, this.evaluatorOptions);
  42602. var dataPromises = Promise.all([
  42603. contentStreamPromise,
  42604. resourcesPromise
  42605. ]);
  42606. var pageListPromise = dataPromises.then(function (data) {
  42607. var contentStream = data[0];
  42608. var opList = new OperatorList(intent, handler, self.pageIndex);
  42609. handler.send('StartRenderPage', {
  42610. transparency: partialEvaluator.hasBlendModes(self.resources),
  42611. pageIndex: self.pageIndex,
  42612. intent: intent
  42613. });
  42614. return partialEvaluator.getOperatorList(contentStream, task, self.resources, opList).then(function () {
  42615. return opList;
  42616. });
  42617. });
  42618. var annotationsPromise = pdfManager.ensure(this, 'annotations');
  42619. return Promise.all([
  42620. pageListPromise,
  42621. annotationsPromise
  42622. ]).then(function (datas) {
  42623. var pageOpList = datas[0];
  42624. var annotations = datas[1];
  42625. if (annotations.length === 0) {
  42626. pageOpList.flush(true);
  42627. return pageOpList;
  42628. }
  42629. var annotationsReadyPromise = Annotation.appendToOperatorList(annotations, pageOpList, partialEvaluator, task, intent, renderInteractiveForms);
  42630. return annotationsReadyPromise.then(function () {
  42631. pageOpList.flush(true);
  42632. return pageOpList;
  42633. });
  42634. });
  42635. },
  42636. extractTextContent: function Page_extractTextContent(task, normalizeWhitespace, combineTextItems) {
  42637. var handler = {
  42638. on: function nullHandlerOn() {
  42639. },
  42640. send: function nullHandlerSend() {
  42641. }
  42642. };
  42643. var self = this;
  42644. var pdfManager = this.pdfManager;
  42645. var contentStreamPromise = pdfManager.ensure(this, 'getContentStream', []);
  42646. var resourcesPromise = this.loadResources([
  42647. 'ExtGState',
  42648. 'XObject',
  42649. 'Font'
  42650. ]);
  42651. var dataPromises = Promise.all([
  42652. contentStreamPromise,
  42653. resourcesPromise
  42654. ]);
  42655. return dataPromises.then(function (data) {
  42656. var contentStream = data[0];
  42657. var partialEvaluator = new PartialEvaluator(pdfManager, self.xref, handler, self.pageIndex, self.idFactory, self.fontCache, self.evaluatorOptions);
  42658. return partialEvaluator.getTextContent(contentStream, task, self.resources, null, normalizeWhitespace, combineTextItems);
  42659. });
  42660. },
  42661. getAnnotationsData: function Page_getAnnotationsData(intent) {
  42662. var annotations = this.annotations;
  42663. var annotationsData = [];
  42664. for (var i = 0, n = annotations.length; i < n; ++i) {
  42665. if (intent) {
  42666. if (!(intent === 'display' && annotations[i].viewable) && !(intent === 'print' && annotations[i].printable)) {
  42667. continue;
  42668. }
  42669. }
  42670. annotationsData.push(annotations[i].data);
  42671. }
  42672. return annotationsData;
  42673. },
  42674. get annotations() {
  42675. var annotations = [];
  42676. var annotationRefs = this.getInheritedPageProp('Annots') || [];
  42677. var annotationFactory = new AnnotationFactory();
  42678. for (var i = 0, n = annotationRefs.length; i < n; ++i) {
  42679. var annotationRef = annotationRefs[i];
  42680. var annotation = annotationFactory.create(this.xref, annotationRef, this.pdfManager, this.idFactory);
  42681. if (annotation) {
  42682. annotations.push(annotation);
  42683. }
  42684. }
  42685. return shadow(this, 'annotations', annotations);
  42686. }
  42687. };
  42688. return Page;
  42689. }();
  42690. var PDFDocument = function PDFDocumentClosure() {
  42691. var FINGERPRINT_FIRST_BYTES = 1024;
  42692. var EMPTY_FINGERPRINT = '\x00\x00\x00\x00\x00\x00\x00' + '\x00\x00\x00\x00\x00\x00\x00\x00\x00';
  42693. function PDFDocument(pdfManager, arg) {
  42694. var stream;
  42695. if (isStream(arg)) {
  42696. stream = arg;
  42697. } else if (isArrayBuffer(arg)) {
  42698. stream = new Stream(arg);
  42699. } else {
  42700. error('PDFDocument: Unknown argument type');
  42701. }
  42702. assert(stream.length > 0, 'stream must have data');
  42703. this.pdfManager = pdfManager;
  42704. this.stream = stream;
  42705. this.xref = new XRef(stream, pdfManager);
  42706. }
  42707. function find(stream, needle, limit, backwards) {
  42708. var pos = stream.pos;
  42709. var end = stream.end;
  42710. var strBuf = [];
  42711. if (pos + limit > end) {
  42712. limit = end - pos;
  42713. }
  42714. for (var n = 0; n < limit; ++n) {
  42715. strBuf.push(String.fromCharCode(stream.getByte()));
  42716. }
  42717. var str = strBuf.join('');
  42718. stream.pos = pos;
  42719. var index = backwards ? str.lastIndexOf(needle) : str.indexOf(needle);
  42720. if (index === -1) {
  42721. return false;
  42722. }
  42723. stream.pos += index;
  42724. return true;
  42725. }
  42726. var DocumentInfoValidators = {
  42727. get entries() {
  42728. return shadow(this, 'entries', {
  42729. Title: isString,
  42730. Author: isString,
  42731. Subject: isString,
  42732. Keywords: isString,
  42733. Creator: isString,
  42734. Producer: isString,
  42735. CreationDate: isString,
  42736. ModDate: isString,
  42737. Trapped: isName
  42738. });
  42739. }
  42740. };
  42741. PDFDocument.prototype = {
  42742. parse: function PDFDocument_parse(recoveryMode) {
  42743. this.setup(recoveryMode);
  42744. var version = this.catalog.catDict.get('Version');
  42745. if (isName(version)) {
  42746. this.pdfFormatVersion = version.name;
  42747. }
  42748. try {
  42749. this.acroForm = this.catalog.catDict.get('AcroForm');
  42750. if (this.acroForm) {
  42751. this.xfa = this.acroForm.get('XFA');
  42752. var fields = this.acroForm.get('Fields');
  42753. if ((!fields || !isArray(fields) || fields.length === 0) && !this.xfa) {
  42754. this.acroForm = null;
  42755. }
  42756. }
  42757. } catch (ex) {
  42758. info('Something wrong with AcroForm entry');
  42759. this.acroForm = null;
  42760. }
  42761. },
  42762. get linearization() {
  42763. var linearization = null;
  42764. if (this.stream.length) {
  42765. try {
  42766. linearization = Linearization.create(this.stream);
  42767. } catch (err) {
  42768. if (err instanceof MissingDataException) {
  42769. throw err;
  42770. }
  42771. info(err);
  42772. }
  42773. }
  42774. return shadow(this, 'linearization', linearization);
  42775. },
  42776. get startXRef() {
  42777. var stream = this.stream;
  42778. var startXRef = 0;
  42779. var linearization = this.linearization;
  42780. if (linearization) {
  42781. stream.reset();
  42782. if (find(stream, 'endobj', 1024)) {
  42783. startXRef = stream.pos + 6;
  42784. }
  42785. } else {
  42786. var step = 1024;
  42787. var found = false, pos = stream.end;
  42788. while (!found && pos > 0) {
  42789. pos -= step - 'startxref'.length;
  42790. if (pos < 0) {
  42791. pos = 0;
  42792. }
  42793. stream.pos = pos;
  42794. found = find(stream, 'startxref', step, true);
  42795. }
  42796. if (found) {
  42797. stream.skip(9);
  42798. var ch;
  42799. do {
  42800. ch = stream.getByte();
  42801. } while (isSpace(ch));
  42802. var str = '';
  42803. while (ch >= 0x20 && ch <= 0x39) {
  42804. str += String.fromCharCode(ch);
  42805. ch = stream.getByte();
  42806. }
  42807. startXRef = parseInt(str, 10);
  42808. if (isNaN(startXRef)) {
  42809. startXRef = 0;
  42810. }
  42811. }
  42812. }
  42813. return shadow(this, 'startXRef', startXRef);
  42814. },
  42815. get mainXRefEntriesOffset() {
  42816. var mainXRefEntriesOffset = 0;
  42817. var linearization = this.linearization;
  42818. if (linearization) {
  42819. mainXRefEntriesOffset = linearization.mainXRefEntriesOffset;
  42820. }
  42821. return shadow(this, 'mainXRefEntriesOffset', mainXRefEntriesOffset);
  42822. },
  42823. checkHeader: function PDFDocument_checkHeader() {
  42824. var stream = this.stream;
  42825. stream.reset();
  42826. if (find(stream, '%PDF-', 1024)) {
  42827. stream.moveStart();
  42828. var MAX_VERSION_LENGTH = 12;
  42829. var version = '', ch;
  42830. while ((ch = stream.getByte()) > 0x20) {
  42831. if (version.length >= MAX_VERSION_LENGTH) {
  42832. break;
  42833. }
  42834. version += String.fromCharCode(ch);
  42835. }
  42836. if (!this.pdfFormatVersion) {
  42837. this.pdfFormatVersion = version.substring(5);
  42838. }
  42839. return;
  42840. }
  42841. },
  42842. parseStartXRef: function PDFDocument_parseStartXRef() {
  42843. var startXRef = this.startXRef;
  42844. this.xref.setStartXRef(startXRef);
  42845. },
  42846. setup: function PDFDocument_setup(recoveryMode) {
  42847. this.xref.parse(recoveryMode);
  42848. var self = this;
  42849. var pageFactory = {
  42850. createPage: function (pageIndex, dict, ref, fontCache) {
  42851. return new Page(self.pdfManager, self.xref, pageIndex, dict, ref, fontCache);
  42852. }
  42853. };
  42854. this.catalog = new Catalog(this.pdfManager, this.xref, pageFactory);
  42855. },
  42856. get numPages() {
  42857. var linearization = this.linearization;
  42858. var num = linearization ? linearization.numPages : this.catalog.numPages;
  42859. return shadow(this, 'numPages', num);
  42860. },
  42861. get documentInfo() {
  42862. var docInfo = {
  42863. PDFFormatVersion: this.pdfFormatVersion,
  42864. IsAcroFormPresent: !!this.acroForm,
  42865. IsXFAPresent: !!this.xfa
  42866. };
  42867. var infoDict;
  42868. try {
  42869. infoDict = this.xref.trailer.get('Info');
  42870. } catch (err) {
  42871. info('The document information dictionary is invalid.');
  42872. }
  42873. if (infoDict) {
  42874. var validEntries = DocumentInfoValidators.entries;
  42875. for (var key in validEntries) {
  42876. if (infoDict.has(key)) {
  42877. var value = infoDict.get(key);
  42878. if (validEntries[key](value)) {
  42879. docInfo[key] = typeof value !== 'string' ? value : stringToPDFString(value);
  42880. } else {
  42881. info('Bad value in document info for "' + key + '"');
  42882. }
  42883. }
  42884. }
  42885. }
  42886. return shadow(this, 'documentInfo', docInfo);
  42887. },
  42888. get fingerprint() {
  42889. var xref = this.xref, hash, fileID = '';
  42890. var idArray = xref.trailer.get('ID');
  42891. if (idArray && isArray(idArray) && idArray[0] && isString(idArray[0]) && idArray[0] !== EMPTY_FINGERPRINT) {
  42892. hash = stringToBytes(idArray[0]);
  42893. } else {
  42894. if (this.stream.ensureRange) {
  42895. this.stream.ensureRange(0, Math.min(FINGERPRINT_FIRST_BYTES, this.stream.end));
  42896. }
  42897. hash = calculateMD5(this.stream.bytes.subarray(0, FINGERPRINT_FIRST_BYTES), 0, FINGERPRINT_FIRST_BYTES);
  42898. }
  42899. for (var i = 0, n = hash.length; i < n; i++) {
  42900. var hex = hash[i].toString(16);
  42901. fileID += hex.length === 1 ? '0' + hex : hex;
  42902. }
  42903. return shadow(this, 'fingerprint', fileID);
  42904. },
  42905. getPage: function PDFDocument_getPage(pageIndex) {
  42906. return this.catalog.getPage(pageIndex);
  42907. },
  42908. cleanup: function PDFDocument_cleanup() {
  42909. return this.catalog.cleanup();
  42910. }
  42911. };
  42912. return PDFDocument;
  42913. }();
  42914. exports.Page = Page;
  42915. exports.PDFDocument = PDFDocument;
  42916. /***/ }),
  42917. /* 33 */
  42918. /***/ (function(module, exports, __w_pdfjs_require__) {
  42919. "use strict";
  42920. var sharedUtil = __w_pdfjs_require__(0);
  42921. var coreStream = __w_pdfjs_require__(2);
  42922. var coreGlyphList = __w_pdfjs_require__(8);
  42923. var coreEncodings = __w_pdfjs_require__(5);
  42924. var coreCFFParser = __w_pdfjs_require__(14);
  42925. var Util = sharedUtil.Util;
  42926. var bytesToString = sharedUtil.bytesToString;
  42927. var error = sharedUtil.error;
  42928. var Stream = coreStream.Stream;
  42929. var getGlyphsUnicode = coreGlyphList.getGlyphsUnicode;
  42930. var StandardEncoding = coreEncodings.StandardEncoding;
  42931. var CFFParser = coreCFFParser.CFFParser;
  42932. var FontRendererFactory = function FontRendererFactoryClosure() {
  42933. function getLong(data, offset) {
  42934. return data[offset] << 24 | data[offset + 1] << 16 | data[offset + 2] << 8 | data[offset + 3];
  42935. }
  42936. function getUshort(data, offset) {
  42937. return data[offset] << 8 | data[offset + 1];
  42938. }
  42939. function parseCmap(data, start, end) {
  42940. var offset = getUshort(data, start + 2) === 1 ? getLong(data, start + 8) : getLong(data, start + 16);
  42941. var format = getUshort(data, start + offset);
  42942. var ranges, p, i;
  42943. if (format === 4) {
  42944. getUshort(data, start + offset + 2);
  42945. var segCount = getUshort(data, start + offset + 6) >> 1;
  42946. p = start + offset + 14;
  42947. ranges = [];
  42948. for (i = 0; i < segCount; i++, p += 2) {
  42949. ranges[i] = { end: getUshort(data, p) };
  42950. }
  42951. p += 2;
  42952. for (i = 0; i < segCount; i++, p += 2) {
  42953. ranges[i].start = getUshort(data, p);
  42954. }
  42955. for (i = 0; i < segCount; i++, p += 2) {
  42956. ranges[i].idDelta = getUshort(data, p);
  42957. }
  42958. for (i = 0; i < segCount; i++, p += 2) {
  42959. var idOffset = getUshort(data, p);
  42960. if (idOffset === 0) {
  42961. continue;
  42962. }
  42963. ranges[i].ids = [];
  42964. for (var j = 0, jj = ranges[i].end - ranges[i].start + 1; j < jj; j++) {
  42965. ranges[i].ids[j] = getUshort(data, p + idOffset);
  42966. idOffset += 2;
  42967. }
  42968. }
  42969. return ranges;
  42970. } else if (format === 12) {
  42971. getLong(data, start + offset + 4);
  42972. var groups = getLong(data, start + offset + 12);
  42973. p = start + offset + 16;
  42974. ranges = [];
  42975. for (i = 0; i < groups; i++) {
  42976. ranges.push({
  42977. start: getLong(data, p),
  42978. end: getLong(data, p + 4),
  42979. idDelta: getLong(data, p + 8) - getLong(data, p)
  42980. });
  42981. p += 12;
  42982. }
  42983. return ranges;
  42984. }
  42985. error('not supported cmap: ' + format);
  42986. }
  42987. function parseCff(data, start, end, seacAnalysisEnabled) {
  42988. var properties = {};
  42989. var parser = new CFFParser(new Stream(data, start, end - start), properties, seacAnalysisEnabled);
  42990. var cff = parser.parse();
  42991. return {
  42992. glyphs: cff.charStrings.objects,
  42993. subrs: cff.topDict.privateDict && cff.topDict.privateDict.subrsIndex && cff.topDict.privateDict.subrsIndex.objects,
  42994. gsubrs: cff.globalSubrIndex && cff.globalSubrIndex.objects
  42995. };
  42996. }
  42997. function parseGlyfTable(glyf, loca, isGlyphLocationsLong) {
  42998. var itemSize, itemDecode;
  42999. if (isGlyphLocationsLong) {
  43000. itemSize = 4;
  43001. itemDecode = function fontItemDecodeLong(data, offset) {
  43002. return data[offset] << 24 | data[offset + 1] << 16 | data[offset + 2] << 8 | data[offset + 3];
  43003. };
  43004. } else {
  43005. itemSize = 2;
  43006. itemDecode = function fontItemDecode(data, offset) {
  43007. return data[offset] << 9 | data[offset + 1] << 1;
  43008. };
  43009. }
  43010. var glyphs = [];
  43011. var startOffset = itemDecode(loca, 0);
  43012. for (var j = itemSize; j < loca.length; j += itemSize) {
  43013. var endOffset = itemDecode(loca, j);
  43014. glyphs.push(glyf.subarray(startOffset, endOffset));
  43015. startOffset = endOffset;
  43016. }
  43017. return glyphs;
  43018. }
  43019. function lookupCmap(ranges, unicode) {
  43020. var code = unicode.charCodeAt(0), gid = 0;
  43021. var l = 0, r = ranges.length - 1;
  43022. while (l < r) {
  43023. var c = l + r + 1 >> 1;
  43024. if (code < ranges[c].start) {
  43025. r = c - 1;
  43026. } else {
  43027. l = c;
  43028. }
  43029. }
  43030. if (ranges[l].start <= code && code <= ranges[l].end) {
  43031. gid = ranges[l].idDelta + (ranges[l].ids ? ranges[l].ids[code - ranges[l].start] : code) & 0xFFFF;
  43032. }
  43033. return {
  43034. charCode: code,
  43035. glyphId: gid
  43036. };
  43037. }
  43038. function compileGlyf(code, cmds, font) {
  43039. function moveTo(x, y) {
  43040. cmds.push({
  43041. cmd: 'moveTo',
  43042. args: [
  43043. x,
  43044. y
  43045. ]
  43046. });
  43047. }
  43048. function lineTo(x, y) {
  43049. cmds.push({
  43050. cmd: 'lineTo',
  43051. args: [
  43052. x,
  43053. y
  43054. ]
  43055. });
  43056. }
  43057. function quadraticCurveTo(xa, ya, x, y) {
  43058. cmds.push({
  43059. cmd: 'quadraticCurveTo',
  43060. args: [
  43061. xa,
  43062. ya,
  43063. x,
  43064. y
  43065. ]
  43066. });
  43067. }
  43068. var i = 0;
  43069. var numberOfContours = (code[i] << 24 | code[i + 1] << 16) >> 16;
  43070. var flags;
  43071. var x = 0, y = 0;
  43072. i += 10;
  43073. if (numberOfContours < 0) {
  43074. do {
  43075. flags = code[i] << 8 | code[i + 1];
  43076. var glyphIndex = code[i + 2] << 8 | code[i + 3];
  43077. i += 4;
  43078. var arg1, arg2;
  43079. if (flags & 0x01) {
  43080. arg1 = (code[i] << 24 | code[i + 1] << 16) >> 16;
  43081. arg2 = (code[i + 2] << 24 | code[i + 3] << 16) >> 16;
  43082. i += 4;
  43083. } else {
  43084. arg1 = code[i++];
  43085. arg2 = code[i++];
  43086. }
  43087. if (flags & 0x02) {
  43088. x = arg1;
  43089. y = arg2;
  43090. } else {
  43091. x = 0;
  43092. y = 0;
  43093. }
  43094. var scaleX = 1, scaleY = 1, scale01 = 0, scale10 = 0;
  43095. if (flags & 0x08) {
  43096. scaleX = scaleY = (code[i] << 24 | code[i + 1] << 16) / 1073741824;
  43097. i += 2;
  43098. } else if (flags & 0x40) {
  43099. scaleX = (code[i] << 24 | code[i + 1] << 16) / 1073741824;
  43100. scaleY = (code[i + 2] << 24 | code[i + 3] << 16) / 1073741824;
  43101. i += 4;
  43102. } else if (flags & 0x80) {
  43103. scaleX = (code[i] << 24 | code[i + 1] << 16) / 1073741824;
  43104. scale01 = (code[i + 2] << 24 | code[i + 3] << 16) / 1073741824;
  43105. scale10 = (code[i + 4] << 24 | code[i + 5] << 16) / 1073741824;
  43106. scaleY = (code[i + 6] << 24 | code[i + 7] << 16) / 1073741824;
  43107. i += 8;
  43108. }
  43109. var subglyph = font.glyphs[glyphIndex];
  43110. if (subglyph) {
  43111. cmds.push({ cmd: 'save' });
  43112. cmds.push({
  43113. cmd: 'transform',
  43114. args: [
  43115. scaleX,
  43116. scale01,
  43117. scale10,
  43118. scaleY,
  43119. x,
  43120. y
  43121. ]
  43122. });
  43123. compileGlyf(subglyph, cmds, font);
  43124. cmds.push({ cmd: 'restore' });
  43125. }
  43126. } while (flags & 0x20);
  43127. } else {
  43128. var endPtsOfContours = [];
  43129. var j, jj;
  43130. for (j = 0; j < numberOfContours; j++) {
  43131. endPtsOfContours.push(code[i] << 8 | code[i + 1]);
  43132. i += 2;
  43133. }
  43134. var instructionLength = code[i] << 8 | code[i + 1];
  43135. i += 2 + instructionLength;
  43136. var numberOfPoints = endPtsOfContours[endPtsOfContours.length - 1] + 1;
  43137. var points = [];
  43138. while (points.length < numberOfPoints) {
  43139. flags = code[i++];
  43140. var repeat = 1;
  43141. if (flags & 0x08) {
  43142. repeat += code[i++];
  43143. }
  43144. while (repeat-- > 0) {
  43145. points.push({ flags: flags });
  43146. }
  43147. }
  43148. for (j = 0; j < numberOfPoints; j++) {
  43149. switch (points[j].flags & 0x12) {
  43150. case 0x00:
  43151. x += (code[i] << 24 | code[i + 1] << 16) >> 16;
  43152. i += 2;
  43153. break;
  43154. case 0x02:
  43155. x -= code[i++];
  43156. break;
  43157. case 0x12:
  43158. x += code[i++];
  43159. break;
  43160. }
  43161. points[j].x = x;
  43162. }
  43163. for (j = 0; j < numberOfPoints; j++) {
  43164. switch (points[j].flags & 0x24) {
  43165. case 0x00:
  43166. y += (code[i] << 24 | code[i + 1] << 16) >> 16;
  43167. i += 2;
  43168. break;
  43169. case 0x04:
  43170. y -= code[i++];
  43171. break;
  43172. case 0x24:
  43173. y += code[i++];
  43174. break;
  43175. }
  43176. points[j].y = y;
  43177. }
  43178. var startPoint = 0;
  43179. for (i = 0; i < numberOfContours; i++) {
  43180. var endPoint = endPtsOfContours[i];
  43181. var contour = points.slice(startPoint, endPoint + 1);
  43182. if (contour[0].flags & 1) {
  43183. contour.push(contour[0]);
  43184. } else if (contour[contour.length - 1].flags & 1) {
  43185. contour.unshift(contour[contour.length - 1]);
  43186. } else {
  43187. var p = {
  43188. flags: 1,
  43189. x: (contour[0].x + contour[contour.length - 1].x) / 2,
  43190. y: (contour[0].y + contour[contour.length - 1].y) / 2
  43191. };
  43192. contour.unshift(p);
  43193. contour.push(p);
  43194. }
  43195. moveTo(contour[0].x, contour[0].y);
  43196. for (j = 1, jj = contour.length; j < jj; j++) {
  43197. if (contour[j].flags & 1) {
  43198. lineTo(contour[j].x, contour[j].y);
  43199. } else if (contour[j + 1].flags & 1) {
  43200. quadraticCurveTo(contour[j].x, contour[j].y, contour[j + 1].x, contour[j + 1].y);
  43201. j++;
  43202. } else {
  43203. quadraticCurveTo(contour[j].x, contour[j].y, (contour[j].x + contour[j + 1].x) / 2, (contour[j].y + contour[j + 1].y) / 2);
  43204. }
  43205. }
  43206. startPoint = endPoint + 1;
  43207. }
  43208. }
  43209. }
  43210. function compileCharString(code, cmds, font) {
  43211. var stack = [];
  43212. var x = 0, y = 0;
  43213. var stems = 0;
  43214. function moveTo(x, y) {
  43215. cmds.push({
  43216. cmd: 'moveTo',
  43217. args: [
  43218. x,
  43219. y
  43220. ]
  43221. });
  43222. }
  43223. function lineTo(x, y) {
  43224. cmds.push({
  43225. cmd: 'lineTo',
  43226. args: [
  43227. x,
  43228. y
  43229. ]
  43230. });
  43231. }
  43232. function bezierCurveTo(x1, y1, x2, y2, x, y) {
  43233. cmds.push({
  43234. cmd: 'bezierCurveTo',
  43235. args: [
  43236. x1,
  43237. y1,
  43238. x2,
  43239. y2,
  43240. x,
  43241. y
  43242. ]
  43243. });
  43244. }
  43245. function parse(code) {
  43246. var i = 0;
  43247. while (i < code.length) {
  43248. var stackClean = false;
  43249. var v = code[i++];
  43250. var xa, xb, ya, yb, y1, y2, y3, n, subrCode;
  43251. switch (v) {
  43252. case 1:
  43253. stems += stack.length >> 1;
  43254. stackClean = true;
  43255. break;
  43256. case 3:
  43257. stems += stack.length >> 1;
  43258. stackClean = true;
  43259. break;
  43260. case 4:
  43261. y += stack.pop();
  43262. moveTo(x, y);
  43263. stackClean = true;
  43264. break;
  43265. case 5:
  43266. while (stack.length > 0) {
  43267. x += stack.shift();
  43268. y += stack.shift();
  43269. lineTo(x, y);
  43270. }
  43271. break;
  43272. case 6:
  43273. while (stack.length > 0) {
  43274. x += stack.shift();
  43275. lineTo(x, y);
  43276. if (stack.length === 0) {
  43277. break;
  43278. }
  43279. y += stack.shift();
  43280. lineTo(x, y);
  43281. }
  43282. break;
  43283. case 7:
  43284. while (stack.length > 0) {
  43285. y += stack.shift();
  43286. lineTo(x, y);
  43287. if (stack.length === 0) {
  43288. break;
  43289. }
  43290. x += stack.shift();
  43291. lineTo(x, y);
  43292. }
  43293. break;
  43294. case 8:
  43295. while (stack.length > 0) {
  43296. xa = x + stack.shift();
  43297. ya = y + stack.shift();
  43298. xb = xa + stack.shift();
  43299. yb = ya + stack.shift();
  43300. x = xb + stack.shift();
  43301. y = yb + stack.shift();
  43302. bezierCurveTo(xa, ya, xb, yb, x, y);
  43303. }
  43304. break;
  43305. case 10:
  43306. n = stack.pop() + font.subrsBias;
  43307. subrCode = font.subrs[n];
  43308. if (subrCode) {
  43309. parse(subrCode);
  43310. }
  43311. break;
  43312. case 11:
  43313. return;
  43314. case 12:
  43315. v = code[i++];
  43316. switch (v) {
  43317. case 34:
  43318. xa = x + stack.shift();
  43319. xb = xa + stack.shift();
  43320. y1 = y + stack.shift();
  43321. x = xb + stack.shift();
  43322. bezierCurveTo(xa, y, xb, y1, x, y1);
  43323. xa = x + stack.shift();
  43324. xb = xa + stack.shift();
  43325. x = xb + stack.shift();
  43326. bezierCurveTo(xa, y1, xb, y, x, y);
  43327. break;
  43328. case 35:
  43329. xa = x + stack.shift();
  43330. ya = y + stack.shift();
  43331. xb = xa + stack.shift();
  43332. yb = ya + stack.shift();
  43333. x = xb + stack.shift();
  43334. y = yb + stack.shift();
  43335. bezierCurveTo(xa, ya, xb, yb, x, y);
  43336. xa = x + stack.shift();
  43337. ya = y + stack.shift();
  43338. xb = xa + stack.shift();
  43339. yb = ya + stack.shift();
  43340. x = xb + stack.shift();
  43341. y = yb + stack.shift();
  43342. bezierCurveTo(xa, ya, xb, yb, x, y);
  43343. stack.pop();
  43344. break;
  43345. case 36:
  43346. xa = x + stack.shift();
  43347. y1 = y + stack.shift();
  43348. xb = xa + stack.shift();
  43349. y2 = y1 + stack.shift();
  43350. x = xb + stack.shift();
  43351. bezierCurveTo(xa, y1, xb, y2, x, y2);
  43352. xa = x + stack.shift();
  43353. xb = xa + stack.shift();
  43354. y3 = y2 + stack.shift();
  43355. x = xb + stack.shift();
  43356. bezierCurveTo(xa, y2, xb, y3, x, y);
  43357. break;
  43358. case 37:
  43359. var x0 = x, y0 = y;
  43360. xa = x + stack.shift();
  43361. ya = y + stack.shift();
  43362. xb = xa + stack.shift();
  43363. yb = ya + stack.shift();
  43364. x = xb + stack.shift();
  43365. y = yb + stack.shift();
  43366. bezierCurveTo(xa, ya, xb, yb, x, y);
  43367. xa = x + stack.shift();
  43368. ya = y + stack.shift();
  43369. xb = xa + stack.shift();
  43370. yb = ya + stack.shift();
  43371. x = xb;
  43372. y = yb;
  43373. if (Math.abs(x - x0) > Math.abs(y - y0)) {
  43374. x += stack.shift();
  43375. } else {
  43376. y += stack.shift();
  43377. }
  43378. bezierCurveTo(xa, ya, xb, yb, x, y);
  43379. break;
  43380. default:
  43381. error('unknown operator: 12 ' + v);
  43382. }
  43383. break;
  43384. case 14:
  43385. if (stack.length >= 4) {
  43386. var achar = stack.pop();
  43387. var bchar = stack.pop();
  43388. y = stack.pop();
  43389. x = stack.pop();
  43390. cmds.push({ cmd: 'save' });
  43391. cmds.push({
  43392. cmd: 'translate',
  43393. args: [
  43394. x,
  43395. y
  43396. ]
  43397. });
  43398. var cmap = lookupCmap(font.cmap, String.fromCharCode(font.glyphNameMap[StandardEncoding[achar]]));
  43399. compileCharString(font.glyphs[cmap.glyphId], cmds, font);
  43400. cmds.push({ cmd: 'restore' });
  43401. cmap = lookupCmap(font.cmap, String.fromCharCode(font.glyphNameMap[StandardEncoding[bchar]]));
  43402. compileCharString(font.glyphs[cmap.glyphId], cmds, font);
  43403. }
  43404. return;
  43405. case 18:
  43406. stems += stack.length >> 1;
  43407. stackClean = true;
  43408. break;
  43409. case 19:
  43410. stems += stack.length >> 1;
  43411. i += stems + 7 >> 3;
  43412. stackClean = true;
  43413. break;
  43414. case 20:
  43415. stems += stack.length >> 1;
  43416. i += stems + 7 >> 3;
  43417. stackClean = true;
  43418. break;
  43419. case 21:
  43420. y += stack.pop();
  43421. x += stack.pop();
  43422. moveTo(x, y);
  43423. stackClean = true;
  43424. break;
  43425. case 22:
  43426. x += stack.pop();
  43427. moveTo(x, y);
  43428. stackClean = true;
  43429. break;
  43430. case 23:
  43431. stems += stack.length >> 1;
  43432. stackClean = true;
  43433. break;
  43434. case 24:
  43435. while (stack.length > 2) {
  43436. xa = x + stack.shift();
  43437. ya = y + stack.shift();
  43438. xb = xa + stack.shift();
  43439. yb = ya + stack.shift();
  43440. x = xb + stack.shift();
  43441. y = yb + stack.shift();
  43442. bezierCurveTo(xa, ya, xb, yb, x, y);
  43443. }
  43444. x += stack.shift();
  43445. y += stack.shift();
  43446. lineTo(x, y);
  43447. break;
  43448. case 25:
  43449. while (stack.length > 6) {
  43450. x += stack.shift();
  43451. y += stack.shift();
  43452. lineTo(x, y);
  43453. }
  43454. xa = x + stack.shift();
  43455. ya = y + stack.shift();
  43456. xb = xa + stack.shift();
  43457. yb = ya + stack.shift();
  43458. x = xb + stack.shift();
  43459. y = yb + stack.shift();
  43460. bezierCurveTo(xa, ya, xb, yb, x, y);
  43461. break;
  43462. case 26:
  43463. if (stack.length % 2) {
  43464. x += stack.shift();
  43465. }
  43466. while (stack.length > 0) {
  43467. xa = x;
  43468. ya = y + stack.shift();
  43469. xb = xa + stack.shift();
  43470. yb = ya + stack.shift();
  43471. x = xb;
  43472. y = yb + stack.shift();
  43473. bezierCurveTo(xa, ya, xb, yb, x, y);
  43474. }
  43475. break;
  43476. case 27:
  43477. if (stack.length % 2) {
  43478. y += stack.shift();
  43479. }
  43480. while (stack.length > 0) {
  43481. xa = x + stack.shift();
  43482. ya = y;
  43483. xb = xa + stack.shift();
  43484. yb = ya + stack.shift();
  43485. x = xb + stack.shift();
  43486. y = yb;
  43487. bezierCurveTo(xa, ya, xb, yb, x, y);
  43488. }
  43489. break;
  43490. case 28:
  43491. stack.push((code[i] << 24 | code[i + 1] << 16) >> 16);
  43492. i += 2;
  43493. break;
  43494. case 29:
  43495. n = stack.pop() + font.gsubrsBias;
  43496. subrCode = font.gsubrs[n];
  43497. if (subrCode) {
  43498. parse(subrCode);
  43499. }
  43500. break;
  43501. case 30:
  43502. while (stack.length > 0) {
  43503. xa = x;
  43504. ya = y + stack.shift();
  43505. xb = xa + stack.shift();
  43506. yb = ya + stack.shift();
  43507. x = xb + stack.shift();
  43508. y = yb + (stack.length === 1 ? stack.shift() : 0);
  43509. bezierCurveTo(xa, ya, xb, yb, x, y);
  43510. if (stack.length === 0) {
  43511. break;
  43512. }
  43513. xa = x + stack.shift();
  43514. ya = y;
  43515. xb = xa + stack.shift();
  43516. yb = ya + stack.shift();
  43517. y = yb + stack.shift();
  43518. x = xb + (stack.length === 1 ? stack.shift() : 0);
  43519. bezierCurveTo(xa, ya, xb, yb, x, y);
  43520. }
  43521. break;
  43522. case 31:
  43523. while (stack.length > 0) {
  43524. xa = x + stack.shift();
  43525. ya = y;
  43526. xb = xa + stack.shift();
  43527. yb = ya + stack.shift();
  43528. y = yb + stack.shift();
  43529. x = xb + (stack.length === 1 ? stack.shift() : 0);
  43530. bezierCurveTo(xa, ya, xb, yb, x, y);
  43531. if (stack.length === 0) {
  43532. break;
  43533. }
  43534. xa = x;
  43535. ya = y + stack.shift();
  43536. xb = xa + stack.shift();
  43537. yb = ya + stack.shift();
  43538. x = xb + stack.shift();
  43539. y = yb + (stack.length === 1 ? stack.shift() : 0);
  43540. bezierCurveTo(xa, ya, xb, yb, x, y);
  43541. }
  43542. break;
  43543. default:
  43544. if (v < 32) {
  43545. error('unknown operator: ' + v);
  43546. }
  43547. if (v < 247) {
  43548. stack.push(v - 139);
  43549. } else if (v < 251) {
  43550. stack.push((v - 247) * 256 + code[i++] + 108);
  43551. } else if (v < 255) {
  43552. stack.push(-(v - 251) * 256 - code[i++] - 108);
  43553. } else {
  43554. stack.push((code[i] << 24 | code[i + 1] << 16 | code[i + 2] << 8 | code[i + 3]) / 65536);
  43555. i += 4;
  43556. }
  43557. break;
  43558. }
  43559. if (stackClean) {
  43560. stack.length = 0;
  43561. }
  43562. }
  43563. }
  43564. parse(code);
  43565. }
  43566. var noop = '';
  43567. function CompiledFont(fontMatrix) {
  43568. this.compiledGlyphs = Object.create(null);
  43569. this.compiledCharCodeToGlyphId = Object.create(null);
  43570. this.fontMatrix = fontMatrix;
  43571. }
  43572. CompiledFont.prototype = {
  43573. getPathJs: function (unicode) {
  43574. var cmap = lookupCmap(this.cmap, unicode);
  43575. var fn = this.compiledGlyphs[cmap.glyphId];
  43576. if (!fn) {
  43577. fn = this.compileGlyph(this.glyphs[cmap.glyphId]);
  43578. this.compiledGlyphs[cmap.glyphId] = fn;
  43579. }
  43580. if (this.compiledCharCodeToGlyphId[cmap.charCode] === undefined) {
  43581. this.compiledCharCodeToGlyphId[cmap.charCode] = cmap.glyphId;
  43582. }
  43583. return fn;
  43584. },
  43585. compileGlyph: function (code) {
  43586. if (!code || code.length === 0 || code[0] === 14) {
  43587. return noop;
  43588. }
  43589. var cmds = [];
  43590. cmds.push({ cmd: 'save' });
  43591. cmds.push({
  43592. cmd: 'transform',
  43593. args: this.fontMatrix.slice()
  43594. });
  43595. cmds.push({
  43596. cmd: 'scale',
  43597. args: [
  43598. 'size',
  43599. '-size'
  43600. ]
  43601. });
  43602. this.compileGlyphImpl(code, cmds);
  43603. cmds.push({ cmd: 'restore' });
  43604. return cmds;
  43605. },
  43606. compileGlyphImpl: function () {
  43607. error('Children classes should implement this.');
  43608. },
  43609. hasBuiltPath: function (unicode) {
  43610. var cmap = lookupCmap(this.cmap, unicode);
  43611. return this.compiledGlyphs[cmap.glyphId] !== undefined && this.compiledCharCodeToGlyphId[cmap.charCode] !== undefined;
  43612. }
  43613. };
  43614. function TrueTypeCompiled(glyphs, cmap, fontMatrix) {
  43615. fontMatrix = fontMatrix || [
  43616. 0.000488,
  43617. 0,
  43618. 0,
  43619. 0.000488,
  43620. 0,
  43621. 0
  43622. ];
  43623. CompiledFont.call(this, fontMatrix);
  43624. this.glyphs = glyphs;
  43625. this.cmap = cmap;
  43626. }
  43627. Util.inherit(TrueTypeCompiled, CompiledFont, {
  43628. compileGlyphImpl: function (code, cmds) {
  43629. compileGlyf(code, cmds, this);
  43630. }
  43631. });
  43632. function Type2Compiled(cffInfo, cmap, fontMatrix, glyphNameMap) {
  43633. fontMatrix = fontMatrix || [
  43634. 0.001,
  43635. 0,
  43636. 0,
  43637. 0.001,
  43638. 0,
  43639. 0
  43640. ];
  43641. CompiledFont.call(this, fontMatrix);
  43642. this.glyphs = cffInfo.glyphs;
  43643. this.gsubrs = cffInfo.gsubrs || [];
  43644. this.subrs = cffInfo.subrs || [];
  43645. this.cmap = cmap;
  43646. this.glyphNameMap = glyphNameMap || getGlyphsUnicode();
  43647. this.gsubrsBias = this.gsubrs.length < 1240 ? 107 : this.gsubrs.length < 33900 ? 1131 : 32768;
  43648. this.subrsBias = this.subrs.length < 1240 ? 107 : this.subrs.length < 33900 ? 1131 : 32768;
  43649. }
  43650. Util.inherit(Type2Compiled, CompiledFont, {
  43651. compileGlyphImpl: function (code, cmds) {
  43652. compileCharString(code, cmds, this);
  43653. }
  43654. });
  43655. return {
  43656. create: function FontRendererFactory_create(font, seacAnalysisEnabled) {
  43657. var data = new Uint8Array(font.data);
  43658. var cmap, glyf, loca, cff, indexToLocFormat, unitsPerEm;
  43659. var numTables = getUshort(data, 4);
  43660. for (var i = 0, p = 12; i < numTables; i++, p += 16) {
  43661. var tag = bytesToString(data.subarray(p, p + 4));
  43662. var offset = getLong(data, p + 8);
  43663. var length = getLong(data, p + 12);
  43664. switch (tag) {
  43665. case 'cmap':
  43666. cmap = parseCmap(data, offset, offset + length);
  43667. break;
  43668. case 'glyf':
  43669. glyf = data.subarray(offset, offset + length);
  43670. break;
  43671. case 'loca':
  43672. loca = data.subarray(offset, offset + length);
  43673. break;
  43674. case 'head':
  43675. unitsPerEm = getUshort(data, offset + 18);
  43676. indexToLocFormat = getUshort(data, offset + 50);
  43677. break;
  43678. case 'CFF ':
  43679. cff = parseCff(data, offset, offset + length, seacAnalysisEnabled);
  43680. break;
  43681. }
  43682. }
  43683. if (glyf) {
  43684. var fontMatrix = !unitsPerEm ? font.fontMatrix : [
  43685. 1 / unitsPerEm,
  43686. 0,
  43687. 0,
  43688. 1 / unitsPerEm,
  43689. 0,
  43690. 0
  43691. ];
  43692. return new TrueTypeCompiled(parseGlyfTable(glyf, loca, indexToLocFormat), cmap, fontMatrix);
  43693. }
  43694. return new Type2Compiled(cff, cmap, font.fontMatrix, font.glyphNameMap);
  43695. }
  43696. };
  43697. }();
  43698. exports.FontRendererFactory = FontRendererFactory;
  43699. /***/ }),
  43700. /* 34 */
  43701. /***/ (function(module, exports, __w_pdfjs_require__) {
  43702. "use strict";
  43703. var sharedUtil = __w_pdfjs_require__(0);
  43704. var corePrimitives = __w_pdfjs_require__(1);
  43705. var coreStream = __w_pdfjs_require__(2);
  43706. var coreGlyphList = __w_pdfjs_require__(8);
  43707. var coreFontRenderer = __w_pdfjs_require__(33);
  43708. var coreEncodings = __w_pdfjs_require__(5);
  43709. var coreStandardFonts = __w_pdfjs_require__(20);
  43710. var coreUnicode = __w_pdfjs_require__(21);
  43711. var coreType1Parser = __w_pdfjs_require__(44);
  43712. var coreCFFParser = __w_pdfjs_require__(14);
  43713. var FONT_IDENTITY_MATRIX = sharedUtil.FONT_IDENTITY_MATRIX;
  43714. var FontType = sharedUtil.FontType;
  43715. var assert = sharedUtil.assert;
  43716. var bytesToString = sharedUtil.bytesToString;
  43717. var error = sharedUtil.error;
  43718. var info = sharedUtil.info;
  43719. var isArray = sharedUtil.isArray;
  43720. var isInt = sharedUtil.isInt;
  43721. var isNum = sharedUtil.isNum;
  43722. var readUint32 = sharedUtil.readUint32;
  43723. var shadow = sharedUtil.shadow;
  43724. var string32 = sharedUtil.string32;
  43725. var warn = sharedUtil.warn;
  43726. var MissingDataException = sharedUtil.MissingDataException;
  43727. var isSpace = sharedUtil.isSpace;
  43728. var Stream = coreStream.Stream;
  43729. var getGlyphsUnicode = coreGlyphList.getGlyphsUnicode;
  43730. var getDingbatsGlyphsUnicode = coreGlyphList.getDingbatsGlyphsUnicode;
  43731. var FontRendererFactory = coreFontRenderer.FontRendererFactory;
  43732. var StandardEncoding = coreEncodings.StandardEncoding;
  43733. var MacRomanEncoding = coreEncodings.MacRomanEncoding;
  43734. var SymbolSetEncoding = coreEncodings.SymbolSetEncoding;
  43735. var ZapfDingbatsEncoding = coreEncodings.ZapfDingbatsEncoding;
  43736. var getEncoding = coreEncodings.getEncoding;
  43737. var getStdFontMap = coreStandardFonts.getStdFontMap;
  43738. var getNonStdFontMap = coreStandardFonts.getNonStdFontMap;
  43739. var getGlyphMapForStandardFonts = coreStandardFonts.getGlyphMapForStandardFonts;
  43740. var getSupplementalGlyphMapForArialBlack = coreStandardFonts.getSupplementalGlyphMapForArialBlack;
  43741. var getUnicodeRangeFor = coreUnicode.getUnicodeRangeFor;
  43742. var mapSpecialUnicodeValues = coreUnicode.mapSpecialUnicodeValues;
  43743. var getUnicodeForGlyph = coreUnicode.getUnicodeForGlyph;
  43744. var Type1Parser = coreType1Parser.Type1Parser;
  43745. var CFFStandardStrings = coreCFFParser.CFFStandardStrings;
  43746. var CFFParser = coreCFFParser.CFFParser;
  43747. var CFFCompiler = coreCFFParser.CFFCompiler;
  43748. var CFF = coreCFFParser.CFF;
  43749. var CFFHeader = coreCFFParser.CFFHeader;
  43750. var CFFTopDict = coreCFFParser.CFFTopDict;
  43751. var CFFPrivateDict = coreCFFParser.CFFPrivateDict;
  43752. var CFFStrings = coreCFFParser.CFFStrings;
  43753. var CFFIndex = coreCFFParser.CFFIndex;
  43754. var CFFCharset = coreCFFParser.CFFCharset;
  43755. var PRIVATE_USE_OFFSET_START = 0xE000;
  43756. var PRIVATE_USE_OFFSET_END = 0xF8FF;
  43757. var SKIP_PRIVATE_USE_RANGE_F000_TO_F01F = false;
  43758. var PDF_GLYPH_SPACE_UNITS = 1000;
  43759. var SEAC_ANALYSIS_ENABLED = false;
  43760. var FontFlags = {
  43761. FixedPitch: 1,
  43762. Serif: 2,
  43763. Symbolic: 4,
  43764. Script: 8,
  43765. Nonsymbolic: 32,
  43766. Italic: 64,
  43767. AllCap: 65536,
  43768. SmallCap: 131072,
  43769. ForceBold: 262144
  43770. };
  43771. var MacStandardGlyphOrdering = [
  43772. '.notdef',
  43773. '.null',
  43774. 'nonmarkingreturn',
  43775. 'space',
  43776. 'exclam',
  43777. 'quotedbl',
  43778. 'numbersign',
  43779. 'dollar',
  43780. 'percent',
  43781. 'ampersand',
  43782. 'quotesingle',
  43783. 'parenleft',
  43784. 'parenright',
  43785. 'asterisk',
  43786. 'plus',
  43787. 'comma',
  43788. 'hyphen',
  43789. 'period',
  43790. 'slash',
  43791. 'zero',
  43792. 'one',
  43793. 'two',
  43794. 'three',
  43795. 'four',
  43796. 'five',
  43797. 'six',
  43798. 'seven',
  43799. 'eight',
  43800. 'nine',
  43801. 'colon',
  43802. 'semicolon',
  43803. 'less',
  43804. 'equal',
  43805. 'greater',
  43806. 'question',
  43807. 'at',
  43808. 'A',
  43809. 'B',
  43810. 'C',
  43811. 'D',
  43812. 'E',
  43813. 'F',
  43814. 'G',
  43815. 'H',
  43816. 'I',
  43817. 'J',
  43818. 'K',
  43819. 'L',
  43820. 'M',
  43821. 'N',
  43822. 'O',
  43823. 'P',
  43824. 'Q',
  43825. 'R',
  43826. 'S',
  43827. 'T',
  43828. 'U',
  43829. 'V',
  43830. 'W',
  43831. 'X',
  43832. 'Y',
  43833. 'Z',
  43834. 'bracketleft',
  43835. 'backslash',
  43836. 'bracketright',
  43837. 'asciicircum',
  43838. 'underscore',
  43839. 'grave',
  43840. 'a',
  43841. 'b',
  43842. 'c',
  43843. 'd',
  43844. 'e',
  43845. 'f',
  43846. 'g',
  43847. 'h',
  43848. 'i',
  43849. 'j',
  43850. 'k',
  43851. 'l',
  43852. 'm',
  43853. 'n',
  43854. 'o',
  43855. 'p',
  43856. 'q',
  43857. 'r',
  43858. 's',
  43859. 't',
  43860. 'u',
  43861. 'v',
  43862. 'w',
  43863. 'x',
  43864. 'y',
  43865. 'z',
  43866. 'braceleft',
  43867. 'bar',
  43868. 'braceright',
  43869. 'asciitilde',
  43870. 'Adieresis',
  43871. 'Aring',
  43872. 'Ccedilla',
  43873. 'Eacute',
  43874. 'Ntilde',
  43875. 'Odieresis',
  43876. 'Udieresis',
  43877. 'aacute',
  43878. 'agrave',
  43879. 'acircumflex',
  43880. 'adieresis',
  43881. 'atilde',
  43882. 'aring',
  43883. 'ccedilla',
  43884. 'eacute',
  43885. 'egrave',
  43886. 'ecircumflex',
  43887. 'edieresis',
  43888. 'iacute',
  43889. 'igrave',
  43890. 'icircumflex',
  43891. 'idieresis',
  43892. 'ntilde',
  43893. 'oacute',
  43894. 'ograve',
  43895. 'ocircumflex',
  43896. 'odieresis',
  43897. 'otilde',
  43898. 'uacute',
  43899. 'ugrave',
  43900. 'ucircumflex',
  43901. 'udieresis',
  43902. 'dagger',
  43903. 'degree',
  43904. 'cent',
  43905. 'sterling',
  43906. 'section',
  43907. 'bullet',
  43908. 'paragraph',
  43909. 'germandbls',
  43910. 'registered',
  43911. 'copyright',
  43912. 'trademark',
  43913. 'acute',
  43914. 'dieresis',
  43915. 'notequal',
  43916. 'AE',
  43917. 'Oslash',
  43918. 'infinity',
  43919. 'plusminus',
  43920. 'lessequal',
  43921. 'greaterequal',
  43922. 'yen',
  43923. 'mu',
  43924. 'partialdiff',
  43925. 'summation',
  43926. 'product',
  43927. 'pi',
  43928. 'integral',
  43929. 'ordfeminine',
  43930. 'ordmasculine',
  43931. 'Omega',
  43932. 'ae',
  43933. 'oslash',
  43934. 'questiondown',
  43935. 'exclamdown',
  43936. 'logicalnot',
  43937. 'radical',
  43938. 'florin',
  43939. 'approxequal',
  43940. 'Delta',
  43941. 'guillemotleft',
  43942. 'guillemotright',
  43943. 'ellipsis',
  43944. 'nonbreakingspace',
  43945. 'Agrave',
  43946. 'Atilde',
  43947. 'Otilde',
  43948. 'OE',
  43949. 'oe',
  43950. 'endash',
  43951. 'emdash',
  43952. 'quotedblleft',
  43953. 'quotedblright',
  43954. 'quoteleft',
  43955. 'quoteright',
  43956. 'divide',
  43957. 'lozenge',
  43958. 'ydieresis',
  43959. 'Ydieresis',
  43960. 'fraction',
  43961. 'currency',
  43962. 'guilsinglleft',
  43963. 'guilsinglright',
  43964. 'fi',
  43965. 'fl',
  43966. 'daggerdbl',
  43967. 'periodcentered',
  43968. 'quotesinglbase',
  43969. 'quotedblbase',
  43970. 'perthousand',
  43971. 'Acircumflex',
  43972. 'Ecircumflex',
  43973. 'Aacute',
  43974. 'Edieresis',
  43975. 'Egrave',
  43976. 'Iacute',
  43977. 'Icircumflex',
  43978. 'Idieresis',
  43979. 'Igrave',
  43980. 'Oacute',
  43981. 'Ocircumflex',
  43982. 'apple',
  43983. 'Ograve',
  43984. 'Uacute',
  43985. 'Ucircumflex',
  43986. 'Ugrave',
  43987. 'dotlessi',
  43988. 'circumflex',
  43989. 'tilde',
  43990. 'macron',
  43991. 'breve',
  43992. 'dotaccent',
  43993. 'ring',
  43994. 'cedilla',
  43995. 'hungarumlaut',
  43996. 'ogonek',
  43997. 'caron',
  43998. 'Lslash',
  43999. 'lslash',
  44000. 'Scaron',
  44001. 'scaron',
  44002. 'Zcaron',
  44003. 'zcaron',
  44004. 'brokenbar',
  44005. 'Eth',
  44006. 'eth',
  44007. 'Yacute',
  44008. 'yacute',
  44009. 'Thorn',
  44010. 'thorn',
  44011. 'minus',
  44012. 'multiply',
  44013. 'onesuperior',
  44014. 'twosuperior',
  44015. 'threesuperior',
  44016. 'onehalf',
  44017. 'onequarter',
  44018. 'threequarters',
  44019. 'franc',
  44020. 'Gbreve',
  44021. 'gbreve',
  44022. 'Idotaccent',
  44023. 'Scedilla',
  44024. 'scedilla',
  44025. 'Cacute',
  44026. 'cacute',
  44027. 'Ccaron',
  44028. 'ccaron',
  44029. 'dcroat'
  44030. ];
  44031. function adjustWidths(properties) {
  44032. if (!properties.fontMatrix) {
  44033. return;
  44034. }
  44035. if (properties.fontMatrix[0] === FONT_IDENTITY_MATRIX[0]) {
  44036. return;
  44037. }
  44038. var scale = 0.001 / properties.fontMatrix[0];
  44039. var glyphsWidths = properties.widths;
  44040. for (var glyph in glyphsWidths) {
  44041. glyphsWidths[glyph] *= scale;
  44042. }
  44043. properties.defaultWidth *= scale;
  44044. }
  44045. function adjustToUnicode(properties, builtInEncoding) {
  44046. if (properties.hasIncludedToUnicodeMap) {
  44047. return;
  44048. }
  44049. if (properties.hasEncoding) {
  44050. return;
  44051. }
  44052. if (builtInEncoding === properties.defaultEncoding) {
  44053. return;
  44054. }
  44055. if (properties.toUnicode instanceof IdentityToUnicodeMap) {
  44056. return;
  44057. }
  44058. var toUnicode = [], glyphsUnicodeMap = getGlyphsUnicode();
  44059. for (var charCode in builtInEncoding) {
  44060. var glyphName = builtInEncoding[charCode];
  44061. var unicode = getUnicodeForGlyph(glyphName, glyphsUnicodeMap);
  44062. if (unicode !== -1) {
  44063. toUnicode[charCode] = String.fromCharCode(unicode);
  44064. }
  44065. }
  44066. properties.toUnicode.amend(toUnicode);
  44067. }
  44068. function getFontType(type, subtype) {
  44069. switch (type) {
  44070. case 'Type1':
  44071. return subtype === 'Type1C' ? FontType.TYPE1C : FontType.TYPE1;
  44072. case 'CIDFontType0':
  44073. return subtype === 'CIDFontType0C' ? FontType.CIDFONTTYPE0C : FontType.CIDFONTTYPE0;
  44074. case 'OpenType':
  44075. return FontType.OPENTYPE;
  44076. case 'TrueType':
  44077. return FontType.TRUETYPE;
  44078. case 'CIDFontType2':
  44079. return FontType.CIDFONTTYPE2;
  44080. case 'MMType1':
  44081. return FontType.MMTYPE1;
  44082. case 'Type0':
  44083. return FontType.TYPE0;
  44084. default:
  44085. return FontType.UNKNOWN;
  44086. }
  44087. }
  44088. function recoverGlyphName(name, glyphsUnicodeMap) {
  44089. if (glyphsUnicodeMap[name] !== undefined) {
  44090. return name;
  44091. }
  44092. var unicode = getUnicodeForGlyph(name, glyphsUnicodeMap);
  44093. if (unicode !== -1) {
  44094. for (var key in glyphsUnicodeMap) {
  44095. if (glyphsUnicodeMap[key] === unicode) {
  44096. return key;
  44097. }
  44098. }
  44099. }
  44100. info('Unable to recover a standard glyph name for: ' + name);
  44101. return name;
  44102. }
  44103. var Glyph = function GlyphClosure() {
  44104. function Glyph(fontChar, unicode, accent, width, vmetric, operatorListId, isSpace, isInFont) {
  44105. this.fontChar = fontChar;
  44106. this.unicode = unicode;
  44107. this.accent = accent;
  44108. this.width = width;
  44109. this.vmetric = vmetric;
  44110. this.operatorListId = operatorListId;
  44111. this.isSpace = isSpace;
  44112. this.isInFont = isInFont;
  44113. }
  44114. Glyph.prototype.matchesForCache = function (fontChar, unicode, accent, width, vmetric, operatorListId, isSpace, isInFont) {
  44115. 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;
  44116. };
  44117. return Glyph;
  44118. }();
  44119. var ToUnicodeMap = function ToUnicodeMapClosure() {
  44120. function ToUnicodeMap(cmap) {
  44121. this._map = cmap;
  44122. }
  44123. ToUnicodeMap.prototype = {
  44124. get length() {
  44125. return this._map.length;
  44126. },
  44127. forEach: function (callback) {
  44128. for (var charCode in this._map) {
  44129. callback(charCode, this._map[charCode].charCodeAt(0));
  44130. }
  44131. },
  44132. has: function (i) {
  44133. return this._map[i] !== undefined;
  44134. },
  44135. get: function (i) {
  44136. return this._map[i];
  44137. },
  44138. charCodeOf: function (v) {
  44139. return this._map.indexOf(v);
  44140. },
  44141. amend: function (map) {
  44142. for (var charCode in map) {
  44143. this._map[charCode] = map[charCode];
  44144. }
  44145. }
  44146. };
  44147. return ToUnicodeMap;
  44148. }();
  44149. var IdentityToUnicodeMap = function IdentityToUnicodeMapClosure() {
  44150. function IdentityToUnicodeMap(firstChar, lastChar) {
  44151. this.firstChar = firstChar;
  44152. this.lastChar = lastChar;
  44153. }
  44154. IdentityToUnicodeMap.prototype = {
  44155. get length() {
  44156. return this.lastChar + 1 - this.firstChar;
  44157. },
  44158. forEach: function (callback) {
  44159. for (var i = this.firstChar, ii = this.lastChar; i <= ii; i++) {
  44160. callback(i, i);
  44161. }
  44162. },
  44163. has: function (i) {
  44164. return this.firstChar <= i && i <= this.lastChar;
  44165. },
  44166. get: function (i) {
  44167. if (this.firstChar <= i && i <= this.lastChar) {
  44168. return String.fromCharCode(i);
  44169. }
  44170. return undefined;
  44171. },
  44172. charCodeOf: function (v) {
  44173. return isInt(v) && v >= this.firstChar && v <= this.lastChar ? v : -1;
  44174. },
  44175. amend: function (map) {
  44176. error('Should not call amend()');
  44177. }
  44178. };
  44179. return IdentityToUnicodeMap;
  44180. }();
  44181. var OpenTypeFileBuilder = function OpenTypeFileBuilderClosure() {
  44182. function writeInt16(dest, offset, num) {
  44183. dest[offset] = num >> 8 & 0xFF;
  44184. dest[offset + 1] = num & 0xFF;
  44185. }
  44186. function writeInt32(dest, offset, num) {
  44187. dest[offset] = num >> 24 & 0xFF;
  44188. dest[offset + 1] = num >> 16 & 0xFF;
  44189. dest[offset + 2] = num >> 8 & 0xFF;
  44190. dest[offset + 3] = num & 0xFF;
  44191. }
  44192. function writeData(dest, offset, data) {
  44193. var i, ii;
  44194. if (data instanceof Uint8Array) {
  44195. dest.set(data, offset);
  44196. } else if (typeof data === 'string') {
  44197. for (i = 0, ii = data.length; i < ii; i++) {
  44198. dest[offset++] = data.charCodeAt(i) & 0xFF;
  44199. }
  44200. } else {
  44201. for (i = 0, ii = data.length; i < ii; i++) {
  44202. dest[offset++] = data[i] & 0xFF;
  44203. }
  44204. }
  44205. }
  44206. function OpenTypeFileBuilder(sfnt) {
  44207. this.sfnt = sfnt;
  44208. this.tables = Object.create(null);
  44209. }
  44210. OpenTypeFileBuilder.getSearchParams = function OpenTypeFileBuilder_getSearchParams(entriesCount, entrySize) {
  44211. var maxPower2 = 1, log2 = 0;
  44212. while ((maxPower2 ^ entriesCount) > maxPower2) {
  44213. maxPower2 <<= 1;
  44214. log2++;
  44215. }
  44216. var searchRange = maxPower2 * entrySize;
  44217. return {
  44218. range: searchRange,
  44219. entry: log2,
  44220. rangeShift: entrySize * entriesCount - searchRange
  44221. };
  44222. };
  44223. var OTF_HEADER_SIZE = 12;
  44224. var OTF_TABLE_ENTRY_SIZE = 16;
  44225. OpenTypeFileBuilder.prototype = {
  44226. toArray: function OpenTypeFileBuilder_toArray() {
  44227. var sfnt = this.sfnt;
  44228. var tables = this.tables;
  44229. var tablesNames = Object.keys(tables);
  44230. tablesNames.sort();
  44231. var numTables = tablesNames.length;
  44232. var i, j, jj, table, tableName;
  44233. var offset = OTF_HEADER_SIZE + numTables * OTF_TABLE_ENTRY_SIZE;
  44234. var tableOffsets = [offset];
  44235. for (i = 0; i < numTables; i++) {
  44236. table = tables[tablesNames[i]];
  44237. var paddedLength = (table.length + 3 & ~3) >>> 0;
  44238. offset += paddedLength;
  44239. tableOffsets.push(offset);
  44240. }
  44241. var file = new Uint8Array(offset);
  44242. for (i = 0; i < numTables; i++) {
  44243. table = tables[tablesNames[i]];
  44244. writeData(file, tableOffsets[i], table);
  44245. }
  44246. if (sfnt === 'true') {
  44247. sfnt = string32(0x00010000);
  44248. }
  44249. file[0] = sfnt.charCodeAt(0) & 0xFF;
  44250. file[1] = sfnt.charCodeAt(1) & 0xFF;
  44251. file[2] = sfnt.charCodeAt(2) & 0xFF;
  44252. file[3] = sfnt.charCodeAt(3) & 0xFF;
  44253. writeInt16(file, 4, numTables);
  44254. var searchParams = OpenTypeFileBuilder.getSearchParams(numTables, 16);
  44255. writeInt16(file, 6, searchParams.range);
  44256. writeInt16(file, 8, searchParams.entry);
  44257. writeInt16(file, 10, searchParams.rangeShift);
  44258. offset = OTF_HEADER_SIZE;
  44259. for (i = 0; i < numTables; i++) {
  44260. tableName = tablesNames[i];
  44261. file[offset] = tableName.charCodeAt(0) & 0xFF;
  44262. file[offset + 1] = tableName.charCodeAt(1) & 0xFF;
  44263. file[offset + 2] = tableName.charCodeAt(2) & 0xFF;
  44264. file[offset + 3] = tableName.charCodeAt(3) & 0xFF;
  44265. var checksum = 0;
  44266. for (j = tableOffsets[i], jj = tableOffsets[i + 1]; j < jj; j += 4) {
  44267. var quad = readUint32(file, j);
  44268. checksum = checksum + quad >>> 0;
  44269. }
  44270. writeInt32(file, offset + 4, checksum);
  44271. writeInt32(file, offset + 8, tableOffsets[i]);
  44272. writeInt32(file, offset + 12, tables[tableName].length);
  44273. offset += OTF_TABLE_ENTRY_SIZE;
  44274. }
  44275. return file;
  44276. },
  44277. addTable: function OpenTypeFileBuilder_addTable(tag, data) {
  44278. if (tag in this.tables) {
  44279. throw new Error('Table ' + tag + ' already exists');
  44280. }
  44281. this.tables[tag] = data;
  44282. }
  44283. };
  44284. return OpenTypeFileBuilder;
  44285. }();
  44286. var ProblematicCharRanges = new Int32Array([
  44287. 0x0000,
  44288. 0x0020,
  44289. 0x007F,
  44290. 0x00A1,
  44291. 0x00AD,
  44292. 0x00AE,
  44293. 0x0600,
  44294. 0x0780,
  44295. 0x08A0,
  44296. 0x10A0,
  44297. 0x1780,
  44298. 0x1800,
  44299. 0x1C00,
  44300. 0x1C50,
  44301. 0x2000,
  44302. 0x2010,
  44303. 0x2011,
  44304. 0x2012,
  44305. 0x2028,
  44306. 0x2030,
  44307. 0x205F,
  44308. 0x2070,
  44309. 0x25CC,
  44310. 0x25CD,
  44311. 0x3000,
  44312. 0x3001,
  44313. 0xAA60,
  44314. 0xAA80,
  44315. 0xFFF0,
  44316. 0x10000
  44317. ]);
  44318. var Font = function FontClosure() {
  44319. function Font(name, file, properties) {
  44320. var charCode, glyphName, unicode;
  44321. this.name = name;
  44322. this.loadedName = properties.loadedName;
  44323. this.isType3Font = properties.isType3Font;
  44324. this.sizes = [];
  44325. this.missingFile = false;
  44326. this.glyphCache = Object.create(null);
  44327. this.isSerifFont = !!(properties.flags & FontFlags.Serif);
  44328. this.isSymbolicFont = !!(properties.flags & FontFlags.Symbolic);
  44329. this.isMonospace = !!(properties.flags & FontFlags.FixedPitch);
  44330. var type = properties.type;
  44331. var subtype = properties.subtype;
  44332. this.type = type;
  44333. this.fallbackName = this.isMonospace ? 'monospace' : this.isSerifFont ? 'serif' : 'sans-serif';
  44334. this.differences = properties.differences;
  44335. this.widths = properties.widths;
  44336. this.defaultWidth = properties.defaultWidth;
  44337. this.composite = properties.composite;
  44338. this.wideChars = properties.wideChars;
  44339. this.cMap = properties.cMap;
  44340. this.ascent = properties.ascent / PDF_GLYPH_SPACE_UNITS;
  44341. this.descent = properties.descent / PDF_GLYPH_SPACE_UNITS;
  44342. this.fontMatrix = properties.fontMatrix;
  44343. this.bbox = properties.bbox;
  44344. this.toUnicode = properties.toUnicode;
  44345. this.toFontChar = [];
  44346. if (properties.type === 'Type3') {
  44347. for (charCode = 0; charCode < 256; charCode++) {
  44348. this.toFontChar[charCode] = this.differences[charCode] || properties.defaultEncoding[charCode];
  44349. }
  44350. this.fontType = FontType.TYPE3;
  44351. return;
  44352. }
  44353. this.cidEncoding = properties.cidEncoding;
  44354. this.vertical = properties.vertical;
  44355. if (this.vertical) {
  44356. this.vmetrics = properties.vmetrics;
  44357. this.defaultVMetrics = properties.defaultVMetrics;
  44358. }
  44359. var glyphsUnicodeMap;
  44360. if (!file || file.isEmpty) {
  44361. if (file) {
  44362. warn('Font file is empty in "' + name + '" (' + this.loadedName + ')');
  44363. }
  44364. this.missingFile = true;
  44365. var fontName = name.replace(/[,_]/g, '-');
  44366. var stdFontMap = getStdFontMap(), nonStdFontMap = getNonStdFontMap();
  44367. var isStandardFont = !!stdFontMap[fontName] || !!(nonStdFontMap[fontName] && stdFontMap[nonStdFontMap[fontName]]);
  44368. fontName = stdFontMap[fontName] || nonStdFontMap[fontName] || fontName;
  44369. this.bold = fontName.search(/bold/gi) !== -1;
  44370. this.italic = fontName.search(/oblique/gi) !== -1 || fontName.search(/italic/gi) !== -1;
  44371. this.black = name.search(/Black/g) !== -1;
  44372. this.remeasure = Object.keys(this.widths).length > 0;
  44373. if (isStandardFont && type === 'CIDFontType2' && properties.cidEncoding.indexOf('Identity-') === 0) {
  44374. var GlyphMapForStandardFonts = getGlyphMapForStandardFonts();
  44375. var map = [];
  44376. for (charCode in GlyphMapForStandardFonts) {
  44377. map[+charCode] = GlyphMapForStandardFonts[charCode];
  44378. }
  44379. if (/Arial-?Black/i.test(name)) {
  44380. var SupplementalGlyphMapForArialBlack = getSupplementalGlyphMapForArialBlack();
  44381. for (charCode in SupplementalGlyphMapForArialBlack) {
  44382. map[+charCode] = SupplementalGlyphMapForArialBlack[charCode];
  44383. }
  44384. }
  44385. var isIdentityUnicode = this.toUnicode instanceof IdentityToUnicodeMap;
  44386. if (!isIdentityUnicode) {
  44387. this.toUnicode.forEach(function (charCode, unicodeCharCode) {
  44388. map[+charCode] = unicodeCharCode;
  44389. });
  44390. }
  44391. this.toFontChar = map;
  44392. this.toUnicode = new ToUnicodeMap(map);
  44393. } else if (/Symbol/i.test(fontName)) {
  44394. this.toFontChar = buildToFontChar(SymbolSetEncoding, getGlyphsUnicode(), properties.differences);
  44395. } else if (/Dingbats/i.test(fontName)) {
  44396. if (/Wingdings/i.test(name)) {
  44397. warn('Non-embedded Wingdings font, falling back to ZapfDingbats.');
  44398. }
  44399. this.toFontChar = buildToFontChar(ZapfDingbatsEncoding, getDingbatsGlyphsUnicode(), properties.differences);
  44400. } else if (isStandardFont) {
  44401. this.toFontChar = buildToFontChar(properties.defaultEncoding, getGlyphsUnicode(), properties.differences);
  44402. } else {
  44403. glyphsUnicodeMap = getGlyphsUnicode();
  44404. this.toUnicode.forEach(function (charCode, unicodeCharCode) {
  44405. if (!this.composite) {
  44406. glyphName = properties.differences[charCode] || properties.defaultEncoding[charCode];
  44407. unicode = getUnicodeForGlyph(glyphName, glyphsUnicodeMap);
  44408. if (unicode !== -1) {
  44409. unicodeCharCode = unicode;
  44410. }
  44411. }
  44412. this.toFontChar[charCode] = unicodeCharCode;
  44413. }.bind(this));
  44414. }
  44415. this.loadedName = fontName.split('-')[0];
  44416. this.loading = false;
  44417. this.fontType = getFontType(type, subtype);
  44418. return;
  44419. }
  44420. if (subtype === 'Type1C') {
  44421. if (type !== 'Type1' && type !== 'MMType1') {
  44422. if (isTrueTypeFile(file)) {
  44423. subtype = 'TrueType';
  44424. } else {
  44425. type = 'Type1';
  44426. }
  44427. } else if (isOpenTypeFile(file)) {
  44428. type = subtype = 'OpenType';
  44429. }
  44430. }
  44431. if (subtype === 'CIDFontType0C' && type !== 'CIDFontType0') {
  44432. type = 'CIDFontType0';
  44433. }
  44434. if (subtype === 'OpenType') {
  44435. type = 'OpenType';
  44436. }
  44437. if (type === 'CIDFontType0') {
  44438. if (isType1File(file)) {
  44439. subtype = 'CIDFontType0';
  44440. } else if (isOpenTypeFile(file)) {
  44441. type = subtype = 'OpenType';
  44442. } else {
  44443. subtype = 'CIDFontType0C';
  44444. }
  44445. }
  44446. var data;
  44447. switch (type) {
  44448. case 'MMType1':
  44449. info('MMType1 font (' + name + '), falling back to Type1.');
  44450. case 'Type1':
  44451. case 'CIDFontType0':
  44452. this.mimetype = 'font/opentype';
  44453. var cff = subtype === 'Type1C' || subtype === 'CIDFontType0C' ? new CFFFont(file, properties) : new Type1Font(name, file, properties);
  44454. adjustWidths(properties);
  44455. data = this.convert(name, cff, properties);
  44456. break;
  44457. case 'OpenType':
  44458. case 'TrueType':
  44459. case 'CIDFontType2':
  44460. this.mimetype = 'font/opentype';
  44461. data = this.checkAndRepair(name, file, properties);
  44462. if (this.isOpenType) {
  44463. adjustWidths(properties);
  44464. type = 'OpenType';
  44465. }
  44466. break;
  44467. default:
  44468. error('Font ' + type + ' is not supported');
  44469. break;
  44470. }
  44471. this.data = data;
  44472. this.fontType = getFontType(type, subtype);
  44473. this.fontMatrix = properties.fontMatrix;
  44474. this.widths = properties.widths;
  44475. this.defaultWidth = properties.defaultWidth;
  44476. this.toUnicode = properties.toUnicode;
  44477. this.encoding = properties.baseEncoding;
  44478. this.seacMap = properties.seacMap;
  44479. this.loading = true;
  44480. }
  44481. Font.getFontID = function () {
  44482. var ID = 1;
  44483. return function Font_getFontID() {
  44484. return String(ID++);
  44485. };
  44486. }();
  44487. function int16(b0, b1) {
  44488. return (b0 << 8) + b1;
  44489. }
  44490. function signedInt16(b0, b1) {
  44491. var value = (b0 << 8) + b1;
  44492. return value & 1 << 15 ? value - 0x10000 : value;
  44493. }
  44494. function int32(b0, b1, b2, b3) {
  44495. return (b0 << 24) + (b1 << 16) + (b2 << 8) + b3;
  44496. }
  44497. function string16(value) {
  44498. return String.fromCharCode(value >> 8 & 0xff, value & 0xff);
  44499. }
  44500. function safeString16(value) {
  44501. value = value > 0x7FFF ? 0x7FFF : value < -0x8000 ? -0x8000 : value;
  44502. return String.fromCharCode(value >> 8 & 0xff, value & 0xff);
  44503. }
  44504. function isTrueTypeFile(file) {
  44505. var header = file.peekBytes(4);
  44506. return readUint32(header, 0) === 0x00010000;
  44507. }
  44508. function isOpenTypeFile(file) {
  44509. var header = file.peekBytes(4);
  44510. return bytesToString(header) === 'OTTO';
  44511. }
  44512. function isType1File(file) {
  44513. var header = file.peekBytes(2);
  44514. if (header[0] === 0x25 && header[1] === 0x21) {
  44515. return true;
  44516. }
  44517. if (header[0] === 0x80 && header[1] === 0x01) {
  44518. return true;
  44519. }
  44520. return false;
  44521. }
  44522. function buildToFontChar(encoding, glyphsUnicodeMap, differences) {
  44523. var toFontChar = [], unicode;
  44524. for (var i = 0, ii = encoding.length; i < ii; i++) {
  44525. unicode = getUnicodeForGlyph(encoding[i], glyphsUnicodeMap);
  44526. if (unicode !== -1) {
  44527. toFontChar[i] = unicode;
  44528. }
  44529. }
  44530. for (var charCode in differences) {
  44531. unicode = getUnicodeForGlyph(differences[charCode], glyphsUnicodeMap);
  44532. if (unicode !== -1) {
  44533. toFontChar[+charCode] = unicode;
  44534. }
  44535. }
  44536. return toFontChar;
  44537. }
  44538. function isProblematicUnicodeLocation(code) {
  44539. var i = 0, j = ProblematicCharRanges.length - 1;
  44540. while (i < j) {
  44541. var c = i + j + 1 >> 1;
  44542. if (code < ProblematicCharRanges[c]) {
  44543. j = c - 1;
  44544. } else {
  44545. i = c;
  44546. }
  44547. }
  44548. return !(i & 1);
  44549. }
  44550. function adjustMapping(charCodeToGlyphId, properties) {
  44551. var toUnicode = properties.toUnicode;
  44552. var isSymbolic = !!(properties.flags & FontFlags.Symbolic);
  44553. var isIdentityUnicode = properties.toUnicode instanceof IdentityToUnicodeMap;
  44554. var newMap = Object.create(null);
  44555. var toFontChar = [];
  44556. var usedFontCharCodes = [];
  44557. var nextAvailableFontCharCode = PRIVATE_USE_OFFSET_START;
  44558. for (var originalCharCode in charCodeToGlyphId) {
  44559. originalCharCode |= 0;
  44560. var glyphId = charCodeToGlyphId[originalCharCode];
  44561. var fontCharCode = originalCharCode;
  44562. var hasUnicodeValue = false;
  44563. if (!isIdentityUnicode && toUnicode.has(originalCharCode)) {
  44564. hasUnicodeValue = true;
  44565. var unicode = toUnicode.get(fontCharCode);
  44566. if (unicode.length === 1) {
  44567. fontCharCode = unicode.charCodeAt(0);
  44568. }
  44569. }
  44570. if ((usedFontCharCodes[fontCharCode] !== undefined || isProblematicUnicodeLocation(fontCharCode) || isSymbolic && !hasUnicodeValue) && nextAvailableFontCharCode <= PRIVATE_USE_OFFSET_END) {
  44571. do {
  44572. fontCharCode = nextAvailableFontCharCode++;
  44573. if (SKIP_PRIVATE_USE_RANGE_F000_TO_F01F && fontCharCode === 0xF000) {
  44574. fontCharCode = 0xF020;
  44575. nextAvailableFontCharCode = fontCharCode + 1;
  44576. }
  44577. } while (usedFontCharCodes[fontCharCode] !== undefined && nextAvailableFontCharCode <= PRIVATE_USE_OFFSET_END);
  44578. }
  44579. newMap[fontCharCode] = glyphId;
  44580. toFontChar[originalCharCode] = fontCharCode;
  44581. usedFontCharCodes[fontCharCode] = true;
  44582. }
  44583. return {
  44584. toFontChar: toFontChar,
  44585. charCodeToGlyphId: newMap,
  44586. nextAvailableFontCharCode: nextAvailableFontCharCode
  44587. };
  44588. }
  44589. function getRanges(glyphs, numGlyphs) {
  44590. var codes = [];
  44591. for (var charCode in glyphs) {
  44592. if (glyphs[charCode] >= numGlyphs) {
  44593. continue;
  44594. }
  44595. codes.push({
  44596. fontCharCode: charCode | 0,
  44597. glyphId: glyphs[charCode]
  44598. });
  44599. }
  44600. codes.sort(function fontGetRangesSort(a, b) {
  44601. return a.fontCharCode - b.fontCharCode;
  44602. });
  44603. var ranges = [];
  44604. var length = codes.length;
  44605. for (var n = 0; n < length;) {
  44606. var start = codes[n].fontCharCode;
  44607. var codeIndices = [codes[n].glyphId];
  44608. ++n;
  44609. var end = start;
  44610. while (n < length && end + 1 === codes[n].fontCharCode) {
  44611. codeIndices.push(codes[n].glyphId);
  44612. ++end;
  44613. ++n;
  44614. if (end === 0xFFFF) {
  44615. break;
  44616. }
  44617. }
  44618. ranges.push([
  44619. start,
  44620. end,
  44621. codeIndices
  44622. ]);
  44623. }
  44624. return ranges;
  44625. }
  44626. function createCmapTable(glyphs, numGlyphs) {
  44627. var ranges = getRanges(glyphs, numGlyphs);
  44628. var numTables = ranges[ranges.length - 1][1] > 0xFFFF ? 2 : 1;
  44629. var cmap = '\x00\x00' + string16(numTables) + '\x00\x03' + '\x00\x01' + string32(4 + numTables * 8);
  44630. var i, ii, j, jj;
  44631. for (i = ranges.length - 1; i >= 0; --i) {
  44632. if (ranges[i][0] <= 0xFFFF) {
  44633. break;
  44634. }
  44635. }
  44636. var bmpLength = i + 1;
  44637. if (ranges[i][0] < 0xFFFF && ranges[i][1] === 0xFFFF) {
  44638. ranges[i][1] = 0xFFFE;
  44639. }
  44640. var trailingRangesCount = ranges[i][1] < 0xFFFF ? 1 : 0;
  44641. var segCount = bmpLength + trailingRangesCount;
  44642. var searchParams = OpenTypeFileBuilder.getSearchParams(segCount, 2);
  44643. var startCount = '';
  44644. var endCount = '';
  44645. var idDeltas = '';
  44646. var idRangeOffsets = '';
  44647. var glyphsIds = '';
  44648. var bias = 0;
  44649. var range, start, end, codes;
  44650. for (i = 0, ii = bmpLength; i < ii; i++) {
  44651. range = ranges[i];
  44652. start = range[0];
  44653. end = range[1];
  44654. startCount += string16(start);
  44655. endCount += string16(end);
  44656. codes = range[2];
  44657. var contiguous = true;
  44658. for (j = 1, jj = codes.length; j < jj; ++j) {
  44659. if (codes[j] !== codes[j - 1] + 1) {
  44660. contiguous = false;
  44661. break;
  44662. }
  44663. }
  44664. if (!contiguous) {
  44665. var offset = (segCount - i) * 2 + bias * 2;
  44666. bias += end - start + 1;
  44667. idDeltas += string16(0);
  44668. idRangeOffsets += string16(offset);
  44669. for (j = 0, jj = codes.length; j < jj; ++j) {
  44670. glyphsIds += string16(codes[j]);
  44671. }
  44672. } else {
  44673. var startCode = codes[0];
  44674. idDeltas += string16(startCode - start & 0xFFFF);
  44675. idRangeOffsets += string16(0);
  44676. }
  44677. }
  44678. if (trailingRangesCount > 0) {
  44679. endCount += '\xFF\xFF';
  44680. startCount += '\xFF\xFF';
  44681. idDeltas += '\x00\x01';
  44682. idRangeOffsets += '\x00\x00';
  44683. }
  44684. var format314 = '\x00\x00' + string16(2 * segCount) + string16(searchParams.range) + string16(searchParams.entry) + string16(searchParams.rangeShift) + endCount + '\x00\x00' + startCount + idDeltas + idRangeOffsets + glyphsIds;
  44685. var format31012 = '';
  44686. var header31012 = '';
  44687. if (numTables > 1) {
  44688. cmap += '\x00\x03' + '\x00\x0A' + string32(4 + numTables * 8 + 4 + format314.length);
  44689. format31012 = '';
  44690. for (i = 0, ii = ranges.length; i < ii; i++) {
  44691. range = ranges[i];
  44692. start = range[0];
  44693. codes = range[2];
  44694. var code = codes[0];
  44695. for (j = 1, jj = codes.length; j < jj; ++j) {
  44696. if (codes[j] !== codes[j - 1] + 1) {
  44697. end = range[0] + j - 1;
  44698. format31012 += string32(start) + string32(end) + string32(code);
  44699. start = end + 1;
  44700. code = codes[j];
  44701. }
  44702. }
  44703. format31012 += string32(start) + string32(range[1]) + string32(code);
  44704. }
  44705. header31012 = '\x00\x0C' + '\x00\x00' + string32(format31012.length + 16) + '\x00\x00\x00\x00' + string32(format31012.length / 12);
  44706. }
  44707. return cmap + '\x00\x04' + string16(format314.length + 4) + format314 + header31012 + format31012;
  44708. }
  44709. function validateOS2Table(os2) {
  44710. var stream = new Stream(os2.data);
  44711. var version = stream.getUint16();
  44712. stream.getBytes(60);
  44713. var selection = stream.getUint16();
  44714. if (version < 4 && selection & 0x0300) {
  44715. return false;
  44716. }
  44717. var firstChar = stream.getUint16();
  44718. var lastChar = stream.getUint16();
  44719. if (firstChar > lastChar) {
  44720. return false;
  44721. }
  44722. stream.getBytes(6);
  44723. var usWinAscent = stream.getUint16();
  44724. if (usWinAscent === 0) {
  44725. return false;
  44726. }
  44727. os2.data[8] = os2.data[9] = 0;
  44728. return true;
  44729. }
  44730. function createOS2Table(properties, charstrings, override) {
  44731. override = override || {
  44732. unitsPerEm: 0,
  44733. yMax: 0,
  44734. yMin: 0,
  44735. ascent: 0,
  44736. descent: 0
  44737. };
  44738. var ulUnicodeRange1 = 0;
  44739. var ulUnicodeRange2 = 0;
  44740. var ulUnicodeRange3 = 0;
  44741. var ulUnicodeRange4 = 0;
  44742. var firstCharIndex = null;
  44743. var lastCharIndex = 0;
  44744. if (charstrings) {
  44745. for (var code in charstrings) {
  44746. code |= 0;
  44747. if (firstCharIndex > code || !firstCharIndex) {
  44748. firstCharIndex = code;
  44749. }
  44750. if (lastCharIndex < code) {
  44751. lastCharIndex = code;
  44752. }
  44753. var position = getUnicodeRangeFor(code);
  44754. if (position < 32) {
  44755. ulUnicodeRange1 |= 1 << position;
  44756. } else if (position < 64) {
  44757. ulUnicodeRange2 |= 1 << position - 32;
  44758. } else if (position < 96) {
  44759. ulUnicodeRange3 |= 1 << position - 64;
  44760. } else if (position < 123) {
  44761. ulUnicodeRange4 |= 1 << position - 96;
  44762. } else {
  44763. error('Unicode ranges Bits > 123 are reserved for internal usage');
  44764. }
  44765. }
  44766. } else {
  44767. firstCharIndex = 0;
  44768. lastCharIndex = 255;
  44769. }
  44770. var bbox = properties.bbox || [
  44771. 0,
  44772. 0,
  44773. 0,
  44774. 0
  44775. ];
  44776. var unitsPerEm = override.unitsPerEm || 1 / (properties.fontMatrix || FONT_IDENTITY_MATRIX)[0];
  44777. var scale = properties.ascentScaled ? 1.0 : unitsPerEm / PDF_GLYPH_SPACE_UNITS;
  44778. var typoAscent = override.ascent || Math.round(scale * (properties.ascent || bbox[3]));
  44779. var typoDescent = override.descent || Math.round(scale * (properties.descent || bbox[1]));
  44780. if (typoDescent > 0 && properties.descent > 0 && bbox[1] < 0) {
  44781. typoDescent = -typoDescent;
  44782. }
  44783. var winAscent = override.yMax || typoAscent;
  44784. var winDescent = -override.yMin || -typoDescent;
  44785. 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';
  44786. }
  44787. function createPostTable(properties) {
  44788. var angle = Math.floor(properties.italicAngle * Math.pow(2, 16));
  44789. 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';
  44790. }
  44791. function createNameTable(name, proto) {
  44792. if (!proto) {
  44793. proto = [
  44794. [],
  44795. []
  44796. ];
  44797. }
  44798. var strings = [
  44799. proto[0][0] || 'Original licence',
  44800. proto[0][1] || name,
  44801. proto[0][2] || 'Unknown',
  44802. proto[0][3] || 'uniqueID',
  44803. proto[0][4] || name,
  44804. proto[0][5] || 'Version 0.11',
  44805. proto[0][6] || '',
  44806. proto[0][7] || 'Unknown',
  44807. proto[0][8] || 'Unknown',
  44808. proto[0][9] || 'Unknown'
  44809. ];
  44810. var stringsUnicode = [];
  44811. var i, ii, j, jj, str;
  44812. for (i = 0, ii = strings.length; i < ii; i++) {
  44813. str = proto[1][i] || strings[i];
  44814. var strBufUnicode = [];
  44815. for (j = 0, jj = str.length; j < jj; j++) {
  44816. strBufUnicode.push(string16(str.charCodeAt(j)));
  44817. }
  44818. stringsUnicode.push(strBufUnicode.join(''));
  44819. }
  44820. var names = [
  44821. strings,
  44822. stringsUnicode
  44823. ];
  44824. var platforms = [
  44825. '\x00\x01',
  44826. '\x00\x03'
  44827. ];
  44828. var encodings = [
  44829. '\x00\x00',
  44830. '\x00\x01'
  44831. ];
  44832. var languages = [
  44833. '\x00\x00',
  44834. '\x04\x09'
  44835. ];
  44836. var namesRecordCount = strings.length * platforms.length;
  44837. var nameTable = '\x00\x00' + string16(namesRecordCount) + string16(namesRecordCount * 12 + 6);
  44838. var strOffset = 0;
  44839. for (i = 0, ii = platforms.length; i < ii; i++) {
  44840. var strs = names[i];
  44841. for (j = 0, jj = strs.length; j < jj; j++) {
  44842. str = strs[j];
  44843. var nameRecord = platforms[i] + encodings[i] + languages[i] + string16(j) + string16(str.length) + string16(strOffset);
  44844. nameTable += nameRecord;
  44845. strOffset += str.length;
  44846. }
  44847. }
  44848. nameTable += strings.join('') + stringsUnicode.join('');
  44849. return nameTable;
  44850. }
  44851. Font.prototype = {
  44852. name: null,
  44853. font: null,
  44854. mimetype: null,
  44855. encoding: null,
  44856. get renderer() {
  44857. var renderer = FontRendererFactory.create(this, SEAC_ANALYSIS_ENABLED);
  44858. return shadow(this, 'renderer', renderer);
  44859. },
  44860. exportData: function Font_exportData() {
  44861. var data = {};
  44862. for (var i in this) {
  44863. if (this.hasOwnProperty(i)) {
  44864. data[i] = this[i];
  44865. }
  44866. }
  44867. return data;
  44868. },
  44869. checkAndRepair: function Font_checkAndRepair(name, font, properties) {
  44870. function readTableEntry(file) {
  44871. var tag = bytesToString(file.getBytes(4));
  44872. var checksum = file.getInt32() >>> 0;
  44873. var offset = file.getInt32() >>> 0;
  44874. var length = file.getInt32() >>> 0;
  44875. var previousPosition = file.pos;
  44876. file.pos = file.start ? file.start : 0;
  44877. file.skip(offset);
  44878. var data = file.getBytes(length);
  44879. file.pos = previousPosition;
  44880. if (tag === 'head') {
  44881. data[8] = data[9] = data[10] = data[11] = 0;
  44882. data[17] |= 0x20;
  44883. }
  44884. return {
  44885. tag: tag,
  44886. checksum: checksum,
  44887. length: length,
  44888. offset: offset,
  44889. data: data
  44890. };
  44891. }
  44892. function readOpenTypeHeader(ttf) {
  44893. return {
  44894. version: bytesToString(ttf.getBytes(4)),
  44895. numTables: ttf.getUint16(),
  44896. searchRange: ttf.getUint16(),
  44897. entrySelector: ttf.getUint16(),
  44898. rangeShift: ttf.getUint16()
  44899. };
  44900. }
  44901. function readCmapTable(cmap, font, isSymbolicFont, hasEncoding) {
  44902. if (!cmap) {
  44903. warn('No cmap table available.');
  44904. return {
  44905. platformId: -1,
  44906. encodingId: -1,
  44907. mappings: [],
  44908. hasShortCmap: false
  44909. };
  44910. }
  44911. var segment;
  44912. var start = (font.start ? font.start : 0) + cmap.offset;
  44913. font.pos = start;
  44914. font.getUint16();
  44915. var numTables = font.getUint16();
  44916. var potentialTable;
  44917. var canBreak = false;
  44918. for (var i = 0; i < numTables; i++) {
  44919. var platformId = font.getUint16();
  44920. var encodingId = font.getUint16();
  44921. var offset = font.getInt32() >>> 0;
  44922. var useTable = false;
  44923. if (platformId === 0 && encodingId === 0) {
  44924. useTable = true;
  44925. } else if (platformId === 1 && encodingId === 0) {
  44926. useTable = true;
  44927. } else if (platformId === 3 && encodingId === 1 && (!isSymbolicFont && hasEncoding || !potentialTable)) {
  44928. useTable = true;
  44929. if (!isSymbolicFont) {
  44930. canBreak = true;
  44931. }
  44932. } else if (isSymbolicFont && platformId === 3 && encodingId === 0) {
  44933. useTable = true;
  44934. canBreak = true;
  44935. }
  44936. if (useTable) {
  44937. potentialTable = {
  44938. platformId: platformId,
  44939. encodingId: encodingId,
  44940. offset: offset
  44941. };
  44942. }
  44943. if (canBreak) {
  44944. break;
  44945. }
  44946. }
  44947. if (potentialTable) {
  44948. font.pos = start + potentialTable.offset;
  44949. }
  44950. if (!potentialTable || font.peekByte() === -1) {
  44951. warn('Could not find a preferred cmap table.');
  44952. return {
  44953. platformId: -1,
  44954. encodingId: -1,
  44955. mappings: [],
  44956. hasShortCmap: false
  44957. };
  44958. }
  44959. var format = font.getUint16();
  44960. font.getUint16();
  44961. font.getUint16();
  44962. var hasShortCmap = false;
  44963. var mappings = [];
  44964. var j, glyphId;
  44965. if (format === 0) {
  44966. for (j = 0; j < 256; j++) {
  44967. var index = font.getByte();
  44968. if (!index) {
  44969. continue;
  44970. }
  44971. mappings.push({
  44972. charCode: j,
  44973. glyphId: index
  44974. });
  44975. }
  44976. hasShortCmap = true;
  44977. } else if (format === 4) {
  44978. var segCount = font.getUint16() >> 1;
  44979. font.getBytes(6);
  44980. var segIndex, segments = [];
  44981. for (segIndex = 0; segIndex < segCount; segIndex++) {
  44982. segments.push({ end: font.getUint16() });
  44983. }
  44984. font.getUint16();
  44985. for (segIndex = 0; segIndex < segCount; segIndex++) {
  44986. segments[segIndex].start = font.getUint16();
  44987. }
  44988. for (segIndex = 0; segIndex < segCount; segIndex++) {
  44989. segments[segIndex].delta = font.getUint16();
  44990. }
  44991. var offsetsCount = 0;
  44992. for (segIndex = 0; segIndex < segCount; segIndex++) {
  44993. segment = segments[segIndex];
  44994. var rangeOffset = font.getUint16();
  44995. if (!rangeOffset) {
  44996. segment.offsetIndex = -1;
  44997. continue;
  44998. }
  44999. var offsetIndex = (rangeOffset >> 1) - (segCount - segIndex);
  45000. segment.offsetIndex = offsetIndex;
  45001. offsetsCount = Math.max(offsetsCount, offsetIndex + segment.end - segment.start + 1);
  45002. }
  45003. var offsets = [];
  45004. for (j = 0; j < offsetsCount; j++) {
  45005. offsets.push(font.getUint16());
  45006. }
  45007. for (segIndex = 0; segIndex < segCount; segIndex++) {
  45008. segment = segments[segIndex];
  45009. start = segment.start;
  45010. var end = segment.end;
  45011. var delta = segment.delta;
  45012. offsetIndex = segment.offsetIndex;
  45013. for (j = start; j <= end; j++) {
  45014. if (j === 0xFFFF) {
  45015. continue;
  45016. }
  45017. glyphId = offsetIndex < 0 ? j : offsets[offsetIndex + j - start];
  45018. glyphId = glyphId + delta & 0xFFFF;
  45019. if (glyphId === 0) {
  45020. continue;
  45021. }
  45022. mappings.push({
  45023. charCode: j,
  45024. glyphId: glyphId
  45025. });
  45026. }
  45027. }
  45028. } else if (format === 6) {
  45029. var firstCode = font.getUint16();
  45030. var entryCount = font.getUint16();
  45031. for (j = 0; j < entryCount; j++) {
  45032. glyphId = font.getUint16();
  45033. var charCode = firstCode + j;
  45034. mappings.push({
  45035. charCode: charCode,
  45036. glyphId: glyphId
  45037. });
  45038. }
  45039. } else {
  45040. warn('cmap table has unsupported format: ' + format);
  45041. return {
  45042. platformId: -1,
  45043. encodingId: -1,
  45044. mappings: [],
  45045. hasShortCmap: false
  45046. };
  45047. }
  45048. mappings.sort(function (a, b) {
  45049. return a.charCode - b.charCode;
  45050. });
  45051. for (i = 1; i < mappings.length; i++) {
  45052. if (mappings[i - 1].charCode === mappings[i].charCode) {
  45053. mappings.splice(i, 1);
  45054. i--;
  45055. }
  45056. }
  45057. return {
  45058. platformId: potentialTable.platformId,
  45059. encodingId: potentialTable.encodingId,
  45060. mappings: mappings,
  45061. hasShortCmap: hasShortCmap
  45062. };
  45063. }
  45064. function sanitizeMetrics(font, header, metrics, numGlyphs) {
  45065. if (!header) {
  45066. if (metrics) {
  45067. metrics.data = null;
  45068. }
  45069. return;
  45070. }
  45071. font.pos = (font.start ? font.start : 0) + header.offset;
  45072. font.pos += header.length - 2;
  45073. var numOfMetrics = font.getUint16();
  45074. if (numOfMetrics > numGlyphs) {
  45075. info('The numOfMetrics (' + numOfMetrics + ') should not be ' + 'greater than the numGlyphs (' + numGlyphs + ')');
  45076. numOfMetrics = numGlyphs;
  45077. header.data[34] = (numOfMetrics & 0xff00) >> 8;
  45078. header.data[35] = numOfMetrics & 0x00ff;
  45079. }
  45080. var numOfSidebearings = numGlyphs - numOfMetrics;
  45081. var numMissing = numOfSidebearings - (metrics.length - numOfMetrics * 4 >> 1);
  45082. if (numMissing > 0) {
  45083. var entries = new Uint8Array(metrics.length + numMissing * 2);
  45084. entries.set(metrics.data);
  45085. metrics.data = entries;
  45086. }
  45087. }
  45088. function sanitizeGlyph(source, sourceStart, sourceEnd, dest, destStart, hintsValid) {
  45089. if (sourceEnd - sourceStart <= 12) {
  45090. return 0;
  45091. }
  45092. var glyf = source.subarray(sourceStart, sourceEnd);
  45093. var contoursCount = glyf[0] << 8 | glyf[1];
  45094. if (contoursCount & 0x8000) {
  45095. dest.set(glyf, destStart);
  45096. return glyf.length;
  45097. }
  45098. var i, j = 10, flagsCount = 0;
  45099. for (i = 0; i < contoursCount; i++) {
  45100. var endPoint = glyf[j] << 8 | glyf[j + 1];
  45101. flagsCount = endPoint + 1;
  45102. j += 2;
  45103. }
  45104. var instructionsStart = j;
  45105. var instructionsLength = glyf[j] << 8 | glyf[j + 1];
  45106. j += 2 + instructionsLength;
  45107. var instructionsEnd = j;
  45108. var coordinatesLength = 0;
  45109. for (i = 0; i < flagsCount; i++) {
  45110. var flag = glyf[j++];
  45111. if (flag & 0xC0) {
  45112. glyf[j - 1] = flag & 0x3F;
  45113. }
  45114. var xyLength = (flag & 2 ? 1 : flag & 16 ? 0 : 2) + (flag & 4 ? 1 : flag & 32 ? 0 : 2);
  45115. coordinatesLength += xyLength;
  45116. if (flag & 8) {
  45117. var repeat = glyf[j++];
  45118. i += repeat;
  45119. coordinatesLength += repeat * xyLength;
  45120. }
  45121. }
  45122. if (coordinatesLength === 0) {
  45123. return 0;
  45124. }
  45125. var glyphDataLength = j + coordinatesLength;
  45126. if (glyphDataLength > glyf.length) {
  45127. return 0;
  45128. }
  45129. if (!hintsValid && instructionsLength > 0) {
  45130. dest.set(glyf.subarray(0, instructionsStart), destStart);
  45131. dest.set([
  45132. 0,
  45133. 0
  45134. ], destStart + instructionsStart);
  45135. dest.set(glyf.subarray(instructionsEnd, glyphDataLength), destStart + instructionsStart + 2);
  45136. glyphDataLength -= instructionsLength;
  45137. if (glyf.length - glyphDataLength > 3) {
  45138. glyphDataLength = glyphDataLength + 3 & ~3;
  45139. }
  45140. return glyphDataLength;
  45141. }
  45142. if (glyf.length - glyphDataLength > 3) {
  45143. glyphDataLength = glyphDataLength + 3 & ~3;
  45144. dest.set(glyf.subarray(0, glyphDataLength), destStart);
  45145. return glyphDataLength;
  45146. }
  45147. dest.set(glyf, destStart);
  45148. return glyf.length;
  45149. }
  45150. function sanitizeHead(head, numGlyphs, locaLength) {
  45151. var data = head.data;
  45152. var version = int32(data[0], data[1], data[2], data[3]);
  45153. if (version >> 16 !== 1) {
  45154. info('Attempting to fix invalid version in head table: ' + version);
  45155. data[0] = 0;
  45156. data[1] = 1;
  45157. data[2] = 0;
  45158. data[3] = 0;
  45159. }
  45160. var indexToLocFormat = int16(data[50], data[51]);
  45161. if (indexToLocFormat < 0 || indexToLocFormat > 1) {
  45162. info('Attempting to fix invalid indexToLocFormat in head table: ' + indexToLocFormat);
  45163. var numGlyphsPlusOne = numGlyphs + 1;
  45164. if (locaLength === numGlyphsPlusOne << 1) {
  45165. data[50] = 0;
  45166. data[51] = 0;
  45167. } else if (locaLength === numGlyphsPlusOne << 2) {
  45168. data[50] = 0;
  45169. data[51] = 1;
  45170. } else {
  45171. warn('Could not fix indexToLocFormat: ' + indexToLocFormat);
  45172. }
  45173. }
  45174. }
  45175. function sanitizeGlyphLocations(loca, glyf, numGlyphs, isGlyphLocationsLong, hintsValid, dupFirstEntry) {
  45176. var itemSize, itemDecode, itemEncode;
  45177. if (isGlyphLocationsLong) {
  45178. itemSize = 4;
  45179. itemDecode = function fontItemDecodeLong(data, offset) {
  45180. return data[offset] << 24 | data[offset + 1] << 16 | data[offset + 2] << 8 | data[offset + 3];
  45181. };
  45182. itemEncode = function fontItemEncodeLong(data, offset, value) {
  45183. data[offset] = value >>> 24 & 0xFF;
  45184. data[offset + 1] = value >> 16 & 0xFF;
  45185. data[offset + 2] = value >> 8 & 0xFF;
  45186. data[offset + 3] = value & 0xFF;
  45187. };
  45188. } else {
  45189. itemSize = 2;
  45190. itemDecode = function fontItemDecode(data, offset) {
  45191. return data[offset] << 9 | data[offset + 1] << 1;
  45192. };
  45193. itemEncode = function fontItemEncode(data, offset, value) {
  45194. data[offset] = value >> 9 & 0xFF;
  45195. data[offset + 1] = value >> 1 & 0xFF;
  45196. };
  45197. }
  45198. var locaData = loca.data;
  45199. var locaDataSize = itemSize * (1 + numGlyphs);
  45200. if (locaData.length !== locaDataSize) {
  45201. locaData = new Uint8Array(locaDataSize);
  45202. locaData.set(loca.data.subarray(0, locaDataSize));
  45203. loca.data = locaData;
  45204. }
  45205. var oldGlyfData = glyf.data;
  45206. var oldGlyfDataLength = oldGlyfData.length;
  45207. var newGlyfData = new Uint8Array(oldGlyfDataLength);
  45208. var startOffset = itemDecode(locaData, 0);
  45209. var writeOffset = 0;
  45210. var missingGlyphData = Object.create(null);
  45211. itemEncode(locaData, 0, writeOffset);
  45212. var i, j;
  45213. for (i = 0, j = itemSize; i < numGlyphs; i++, j += itemSize) {
  45214. var endOffset = itemDecode(locaData, j);
  45215. if (endOffset > oldGlyfDataLength && (oldGlyfDataLength + 3 & ~3) === endOffset) {
  45216. endOffset = oldGlyfDataLength;
  45217. }
  45218. if (endOffset > oldGlyfDataLength) {
  45219. itemEncode(locaData, j, writeOffset);
  45220. startOffset = endOffset;
  45221. continue;
  45222. }
  45223. if (startOffset === endOffset) {
  45224. missingGlyphData[i] = true;
  45225. }
  45226. var newLength = sanitizeGlyph(oldGlyfData, startOffset, endOffset, newGlyfData, writeOffset, hintsValid);
  45227. writeOffset += newLength;
  45228. itemEncode(locaData, j, writeOffset);
  45229. startOffset = endOffset;
  45230. }
  45231. if (writeOffset === 0) {
  45232. var simpleGlyph = new Uint8Array([
  45233. 0,
  45234. 1,
  45235. 0,
  45236. 0,
  45237. 0,
  45238. 0,
  45239. 0,
  45240. 0,
  45241. 0,
  45242. 0,
  45243. 0,
  45244. 0,
  45245. 0,
  45246. 0,
  45247. 49,
  45248. 0
  45249. ]);
  45250. for (i = 0, j = itemSize; i < numGlyphs; i++, j += itemSize) {
  45251. itemEncode(locaData, j, simpleGlyph.length);
  45252. }
  45253. glyf.data = simpleGlyph;
  45254. return missingGlyphData;
  45255. }
  45256. if (dupFirstEntry) {
  45257. var firstEntryLength = itemDecode(locaData, itemSize);
  45258. if (newGlyfData.length > firstEntryLength + writeOffset) {
  45259. glyf.data = newGlyfData.subarray(0, firstEntryLength + writeOffset);
  45260. } else {
  45261. glyf.data = new Uint8Array(firstEntryLength + writeOffset);
  45262. glyf.data.set(newGlyfData.subarray(0, writeOffset));
  45263. }
  45264. glyf.data.set(newGlyfData.subarray(0, firstEntryLength), writeOffset);
  45265. itemEncode(loca.data, locaData.length - itemSize, writeOffset + firstEntryLength);
  45266. } else {
  45267. glyf.data = newGlyfData.subarray(0, writeOffset);
  45268. }
  45269. return missingGlyphData;
  45270. }
  45271. function readPostScriptTable(post, properties, maxpNumGlyphs) {
  45272. var start = (font.start ? font.start : 0) + post.offset;
  45273. font.pos = start;
  45274. var length = post.length, end = start + length;
  45275. var version = font.getInt32();
  45276. font.getBytes(28);
  45277. var glyphNames;
  45278. var valid = true;
  45279. var i;
  45280. switch (version) {
  45281. case 0x00010000:
  45282. glyphNames = MacStandardGlyphOrdering;
  45283. break;
  45284. case 0x00020000:
  45285. var numGlyphs = font.getUint16();
  45286. if (numGlyphs !== maxpNumGlyphs) {
  45287. valid = false;
  45288. break;
  45289. }
  45290. var glyphNameIndexes = [];
  45291. for (i = 0; i < numGlyphs; ++i) {
  45292. var index = font.getUint16();
  45293. if (index >= 32768) {
  45294. valid = false;
  45295. break;
  45296. }
  45297. glyphNameIndexes.push(index);
  45298. }
  45299. if (!valid) {
  45300. break;
  45301. }
  45302. var customNames = [];
  45303. var strBuf = [];
  45304. while (font.pos < end) {
  45305. var stringLength = font.getByte();
  45306. strBuf.length = stringLength;
  45307. for (i = 0; i < stringLength; ++i) {
  45308. strBuf[i] = String.fromCharCode(font.getByte());
  45309. }
  45310. customNames.push(strBuf.join(''));
  45311. }
  45312. glyphNames = [];
  45313. for (i = 0; i < numGlyphs; ++i) {
  45314. var j = glyphNameIndexes[i];
  45315. if (j < 258) {
  45316. glyphNames.push(MacStandardGlyphOrdering[j]);
  45317. continue;
  45318. }
  45319. glyphNames.push(customNames[j - 258]);
  45320. }
  45321. break;
  45322. case 0x00030000:
  45323. break;
  45324. default:
  45325. warn('Unknown/unsupported post table version ' + version);
  45326. valid = false;
  45327. if (properties.defaultEncoding) {
  45328. glyphNames = properties.defaultEncoding;
  45329. }
  45330. break;
  45331. }
  45332. properties.glyphNames = glyphNames;
  45333. return valid;
  45334. }
  45335. function readNameTable(nameTable) {
  45336. var start = (font.start ? font.start : 0) + nameTable.offset;
  45337. font.pos = start;
  45338. var names = [
  45339. [],
  45340. []
  45341. ];
  45342. var length = nameTable.length, end = start + length;
  45343. var format = font.getUint16();
  45344. var FORMAT_0_HEADER_LENGTH = 6;
  45345. if (format !== 0 || length < FORMAT_0_HEADER_LENGTH) {
  45346. return names;
  45347. }
  45348. var numRecords = font.getUint16();
  45349. var stringsStart = font.getUint16();
  45350. var records = [];
  45351. var NAME_RECORD_LENGTH = 12;
  45352. var i, ii;
  45353. for (i = 0; i < numRecords && font.pos + NAME_RECORD_LENGTH <= end; i++) {
  45354. var r = {
  45355. platform: font.getUint16(),
  45356. encoding: font.getUint16(),
  45357. language: font.getUint16(),
  45358. name: font.getUint16(),
  45359. length: font.getUint16(),
  45360. offset: font.getUint16()
  45361. };
  45362. if (r.platform === 1 && r.encoding === 0 && r.language === 0 || r.platform === 3 && r.encoding === 1 && r.language === 0x409) {
  45363. records.push(r);
  45364. }
  45365. }
  45366. for (i = 0, ii = records.length; i < ii; i++) {
  45367. var record = records[i];
  45368. if (record.length <= 0) {
  45369. continue;
  45370. }
  45371. var pos = start + stringsStart + record.offset;
  45372. if (pos + record.length > end) {
  45373. continue;
  45374. }
  45375. font.pos = pos;
  45376. var nameIndex = record.name;
  45377. if (record.encoding) {
  45378. var str = '';
  45379. for (var j = 0, jj = record.length; j < jj; j += 2) {
  45380. str += String.fromCharCode(font.getUint16());
  45381. }
  45382. names[1][nameIndex] = str;
  45383. } else {
  45384. names[0][nameIndex] = bytesToString(font.getBytes(record.length));
  45385. }
  45386. }
  45387. return names;
  45388. }
  45389. var TTOpsStackDeltas = [
  45390. 0,
  45391. 0,
  45392. 0,
  45393. 0,
  45394. 0,
  45395. 0,
  45396. 0,
  45397. 0,
  45398. -2,
  45399. -2,
  45400. -2,
  45401. -2,
  45402. 0,
  45403. 0,
  45404. -2,
  45405. -5,
  45406. -1,
  45407. -1,
  45408. -1,
  45409. -1,
  45410. -1,
  45411. -1,
  45412. -1,
  45413. -1,
  45414. 0,
  45415. 0,
  45416. -1,
  45417. 0,
  45418. -1,
  45419. -1,
  45420. -1,
  45421. -1,
  45422. 1,
  45423. -1,
  45424. -999,
  45425. 0,
  45426. 1,
  45427. 0,
  45428. -1,
  45429. -2,
  45430. 0,
  45431. -1,
  45432. -2,
  45433. -1,
  45434. -1,
  45435. 0,
  45436. -1,
  45437. -1,
  45438. 0,
  45439. 0,
  45440. -999,
  45441. -999,
  45442. -1,
  45443. -1,
  45444. -1,
  45445. -1,
  45446. -2,
  45447. -999,
  45448. -2,
  45449. -2,
  45450. -999,
  45451. 0,
  45452. -2,
  45453. -2,
  45454. 0,
  45455. 0,
  45456. -2,
  45457. 0,
  45458. -2,
  45459. 0,
  45460. 0,
  45461. 0,
  45462. -2,
  45463. -1,
  45464. -1,
  45465. 1,
  45466. 1,
  45467. 0,
  45468. 0,
  45469. -1,
  45470. -1,
  45471. -1,
  45472. -1,
  45473. -1,
  45474. -1,
  45475. -1,
  45476. 0,
  45477. 0,
  45478. -1,
  45479. 0,
  45480. -1,
  45481. -1,
  45482. 0,
  45483. -999,
  45484. -1,
  45485. -1,
  45486. -1,
  45487. -1,
  45488. -1,
  45489. -1,
  45490. 0,
  45491. 0,
  45492. 0,
  45493. 0,
  45494. 0,
  45495. 0,
  45496. 0,
  45497. 0,
  45498. 0,
  45499. 0,
  45500. 0,
  45501. 0,
  45502. -2,
  45503. -999,
  45504. -999,
  45505. -999,
  45506. -999,
  45507. -999,
  45508. -1,
  45509. -1,
  45510. -2,
  45511. -2,
  45512. 0,
  45513. 0,
  45514. 0,
  45515. 0,
  45516. -1,
  45517. -1,
  45518. -999,
  45519. -2,
  45520. -2,
  45521. 0,
  45522. 0,
  45523. -1,
  45524. -2,
  45525. -2,
  45526. 0,
  45527. 0,
  45528. 0,
  45529. -1,
  45530. -1,
  45531. -1,
  45532. -2
  45533. ];
  45534. function sanitizeTTProgram(table, ttContext) {
  45535. var data = table.data;
  45536. var i = 0, j, n, b, funcId, pc, lastEndf = 0, lastDeff = 0;
  45537. var stack = [];
  45538. var callstack = [];
  45539. var functionsCalled = [];
  45540. var tooComplexToFollowFunctions = ttContext.tooComplexToFollowFunctions;
  45541. var inFDEF = false, ifLevel = 0, inELSE = 0;
  45542. for (var ii = data.length; i < ii;) {
  45543. var op = data[i++];
  45544. if (op === 0x40) {
  45545. n = data[i++];
  45546. if (inFDEF || inELSE) {
  45547. i += n;
  45548. } else {
  45549. for (j = 0; j < n; j++) {
  45550. stack.push(data[i++]);
  45551. }
  45552. }
  45553. } else if (op === 0x41) {
  45554. n = data[i++];
  45555. if (inFDEF || inELSE) {
  45556. i += n * 2;
  45557. } else {
  45558. for (j = 0; j < n; j++) {
  45559. b = data[i++];
  45560. stack.push(b << 8 | data[i++]);
  45561. }
  45562. }
  45563. } else if ((op & 0xF8) === 0xB0) {
  45564. n = op - 0xB0 + 1;
  45565. if (inFDEF || inELSE) {
  45566. i += n;
  45567. } else {
  45568. for (j = 0; j < n; j++) {
  45569. stack.push(data[i++]);
  45570. }
  45571. }
  45572. } else if ((op & 0xF8) === 0xB8) {
  45573. n = op - 0xB8 + 1;
  45574. if (inFDEF || inELSE) {
  45575. i += n * 2;
  45576. } else {
  45577. for (j = 0; j < n; j++) {
  45578. b = data[i++];
  45579. stack.push(b << 8 | data[i++]);
  45580. }
  45581. }
  45582. } else if (op === 0x2B && !tooComplexToFollowFunctions) {
  45583. if (!inFDEF && !inELSE) {
  45584. funcId = stack[stack.length - 1];
  45585. ttContext.functionsUsed[funcId] = true;
  45586. if (funcId in ttContext.functionsStackDeltas) {
  45587. stack.length += ttContext.functionsStackDeltas[funcId];
  45588. } else if (funcId in ttContext.functionsDefined && functionsCalled.indexOf(funcId) < 0) {
  45589. callstack.push({
  45590. data: data,
  45591. i: i,
  45592. stackTop: stack.length - 1
  45593. });
  45594. functionsCalled.push(funcId);
  45595. pc = ttContext.functionsDefined[funcId];
  45596. if (!pc) {
  45597. warn('TT: CALL non-existent function');
  45598. ttContext.hintsValid = false;
  45599. return;
  45600. }
  45601. data = pc.data;
  45602. i = pc.i;
  45603. }
  45604. }
  45605. } else if (op === 0x2C && !tooComplexToFollowFunctions) {
  45606. if (inFDEF || inELSE) {
  45607. warn('TT: nested FDEFs not allowed');
  45608. tooComplexToFollowFunctions = true;
  45609. }
  45610. inFDEF = true;
  45611. lastDeff = i;
  45612. funcId = stack.pop();
  45613. ttContext.functionsDefined[funcId] = {
  45614. data: data,
  45615. i: i
  45616. };
  45617. } else if (op === 0x2D) {
  45618. if (inFDEF) {
  45619. inFDEF = false;
  45620. lastEndf = i;
  45621. } else {
  45622. pc = callstack.pop();
  45623. if (!pc) {
  45624. warn('TT: ENDF bad stack');
  45625. ttContext.hintsValid = false;
  45626. return;
  45627. }
  45628. funcId = functionsCalled.pop();
  45629. data = pc.data;
  45630. i = pc.i;
  45631. ttContext.functionsStackDeltas[funcId] = stack.length - pc.stackTop;
  45632. }
  45633. } else if (op === 0x89) {
  45634. if (inFDEF || inELSE) {
  45635. warn('TT: nested IDEFs not allowed');
  45636. tooComplexToFollowFunctions = true;
  45637. }
  45638. inFDEF = true;
  45639. lastDeff = i;
  45640. } else if (op === 0x58) {
  45641. ++ifLevel;
  45642. } else if (op === 0x1B) {
  45643. inELSE = ifLevel;
  45644. } else if (op === 0x59) {
  45645. if (inELSE === ifLevel) {
  45646. inELSE = 0;
  45647. }
  45648. --ifLevel;
  45649. } else if (op === 0x1C) {
  45650. if (!inFDEF && !inELSE) {
  45651. var offset = stack[stack.length - 1];
  45652. if (offset > 0) {
  45653. i += offset - 1;
  45654. }
  45655. }
  45656. }
  45657. if (!inFDEF && !inELSE) {
  45658. var stackDelta = op <= 0x8E ? TTOpsStackDeltas[op] : op >= 0xC0 && op <= 0xDF ? -1 : op >= 0xE0 ? -2 : 0;
  45659. if (op >= 0x71 && op <= 0x75) {
  45660. n = stack.pop();
  45661. if (!isNaN(n)) {
  45662. stackDelta = -n * 2;
  45663. }
  45664. }
  45665. while (stackDelta < 0 && stack.length > 0) {
  45666. stack.pop();
  45667. stackDelta++;
  45668. }
  45669. while (stackDelta > 0) {
  45670. stack.push(NaN);
  45671. stackDelta--;
  45672. }
  45673. }
  45674. }
  45675. ttContext.tooComplexToFollowFunctions = tooComplexToFollowFunctions;
  45676. var content = [data];
  45677. if (i > data.length) {
  45678. content.push(new Uint8Array(i - data.length));
  45679. }
  45680. if (lastDeff > lastEndf) {
  45681. warn('TT: complementing a missing function tail');
  45682. content.push(new Uint8Array([
  45683. 0x22,
  45684. 0x2D
  45685. ]));
  45686. }
  45687. foldTTTable(table, content);
  45688. }
  45689. function checkInvalidFunctions(ttContext, maxFunctionDefs) {
  45690. if (ttContext.tooComplexToFollowFunctions) {
  45691. return;
  45692. }
  45693. if (ttContext.functionsDefined.length > maxFunctionDefs) {
  45694. warn('TT: more functions defined than expected');
  45695. ttContext.hintsValid = false;
  45696. return;
  45697. }
  45698. for (var j = 0, jj = ttContext.functionsUsed.length; j < jj; j++) {
  45699. if (j > maxFunctionDefs) {
  45700. warn('TT: invalid function id: ' + j);
  45701. ttContext.hintsValid = false;
  45702. return;
  45703. }
  45704. if (ttContext.functionsUsed[j] && !ttContext.functionsDefined[j]) {
  45705. warn('TT: undefined function: ' + j);
  45706. ttContext.hintsValid = false;
  45707. return;
  45708. }
  45709. }
  45710. }
  45711. function foldTTTable(table, content) {
  45712. if (content.length > 1) {
  45713. var newLength = 0;
  45714. var j, jj;
  45715. for (j = 0, jj = content.length; j < jj; j++) {
  45716. newLength += content[j].length;
  45717. }
  45718. newLength = newLength + 3 & ~3;
  45719. var result = new Uint8Array(newLength);
  45720. var pos = 0;
  45721. for (j = 0, jj = content.length; j < jj; j++) {
  45722. result.set(content[j], pos);
  45723. pos += content[j].length;
  45724. }
  45725. table.data = result;
  45726. table.length = newLength;
  45727. }
  45728. }
  45729. function sanitizeTTPrograms(fpgm, prep, cvt, maxFunctionDefs) {
  45730. var ttContext = {
  45731. functionsDefined: [],
  45732. functionsUsed: [],
  45733. functionsStackDeltas: [],
  45734. tooComplexToFollowFunctions: false,
  45735. hintsValid: true
  45736. };
  45737. if (fpgm) {
  45738. sanitizeTTProgram(fpgm, ttContext);
  45739. }
  45740. if (prep) {
  45741. sanitizeTTProgram(prep, ttContext);
  45742. }
  45743. if (fpgm) {
  45744. checkInvalidFunctions(ttContext, maxFunctionDefs);
  45745. }
  45746. if (cvt && cvt.length & 1) {
  45747. var cvtData = new Uint8Array(cvt.length + 1);
  45748. cvtData.set(cvt.data);
  45749. cvt.data = cvtData;
  45750. }
  45751. return ttContext.hintsValid;
  45752. }
  45753. font = new Stream(new Uint8Array(font.getBytes()));
  45754. var VALID_TABLES = [
  45755. 'OS/2',
  45756. 'cmap',
  45757. 'head',
  45758. 'hhea',
  45759. 'hmtx',
  45760. 'maxp',
  45761. 'name',
  45762. 'post',
  45763. 'loca',
  45764. 'glyf',
  45765. 'fpgm',
  45766. 'prep',
  45767. 'cvt ',
  45768. 'CFF '
  45769. ];
  45770. var header = readOpenTypeHeader(font);
  45771. var numTables = header.numTables;
  45772. var cff, cffFile;
  45773. var tables = Object.create(null);
  45774. tables['OS/2'] = null;
  45775. tables['cmap'] = null;
  45776. tables['head'] = null;
  45777. tables['hhea'] = null;
  45778. tables['hmtx'] = null;
  45779. tables['maxp'] = null;
  45780. tables['name'] = null;
  45781. tables['post'] = null;
  45782. var table;
  45783. for (var i = 0; i < numTables; i++) {
  45784. table = readTableEntry(font);
  45785. if (VALID_TABLES.indexOf(table.tag) < 0) {
  45786. continue;
  45787. }
  45788. if (table.length === 0) {
  45789. continue;
  45790. }
  45791. tables[table.tag] = table;
  45792. }
  45793. var isTrueType = !tables['CFF '];
  45794. if (!isTrueType) {
  45795. if (header.version === 'OTTO' && !properties.composite || !tables['head'] || !tables['hhea'] || !tables['maxp'] || !tables['post']) {
  45796. cffFile = new Stream(tables['CFF '].data);
  45797. cff = new CFFFont(cffFile, properties);
  45798. adjustWidths(properties);
  45799. return this.convert(name, cff, properties);
  45800. }
  45801. delete tables['glyf'];
  45802. delete tables['loca'];
  45803. delete tables['fpgm'];
  45804. delete tables['prep'];
  45805. delete tables['cvt '];
  45806. this.isOpenType = true;
  45807. } else {
  45808. if (!tables['loca']) {
  45809. error('Required "loca" table is not found');
  45810. }
  45811. if (!tables['glyf']) {
  45812. warn('Required "glyf" table is not found -- trying to recover.');
  45813. tables['glyf'] = {
  45814. tag: 'glyf',
  45815. data: new Uint8Array(0)
  45816. };
  45817. }
  45818. this.isOpenType = false;
  45819. }
  45820. if (!tables['maxp']) {
  45821. error('Required "maxp" table is not found');
  45822. }
  45823. font.pos = (font.start || 0) + tables['maxp'].offset;
  45824. var version = font.getInt32();
  45825. var numGlyphs = font.getUint16();
  45826. var maxFunctionDefs = 0;
  45827. if (version >= 0x00010000 && tables['maxp'].length >= 22) {
  45828. font.pos += 8;
  45829. var maxZones = font.getUint16();
  45830. if (maxZones > 2) {
  45831. tables['maxp'].data[14] = 0;
  45832. tables['maxp'].data[15] = 2;
  45833. }
  45834. font.pos += 4;
  45835. maxFunctionDefs = font.getUint16();
  45836. }
  45837. var dupFirstEntry = false;
  45838. if (properties.type === 'CIDFontType2' && properties.toUnicode && properties.toUnicode.get(0) > '\u0000') {
  45839. dupFirstEntry = true;
  45840. numGlyphs++;
  45841. tables['maxp'].data[4] = numGlyphs >> 8;
  45842. tables['maxp'].data[5] = numGlyphs & 255;
  45843. }
  45844. var hintsValid = sanitizeTTPrograms(tables['fpgm'], tables['prep'], tables['cvt '], maxFunctionDefs);
  45845. if (!hintsValid) {
  45846. delete tables['fpgm'];
  45847. delete tables['prep'];
  45848. delete tables['cvt '];
  45849. }
  45850. sanitizeMetrics(font, tables['hhea'], tables['hmtx'], numGlyphs);
  45851. if (!tables['head']) {
  45852. error('Required "head" table is not found');
  45853. }
  45854. sanitizeHead(tables['head'], numGlyphs, isTrueType ? tables['loca'].length : 0);
  45855. var missingGlyphs = Object.create(null);
  45856. if (isTrueType) {
  45857. var isGlyphLocationsLong = int16(tables['head'].data[50], tables['head'].data[51]);
  45858. missingGlyphs = sanitizeGlyphLocations(tables['loca'], tables['glyf'], numGlyphs, isGlyphLocationsLong, hintsValid, dupFirstEntry);
  45859. }
  45860. if (!tables['hhea']) {
  45861. error('Required "hhea" table is not found');
  45862. }
  45863. if (tables['hhea'].data[10] === 0 && tables['hhea'].data[11] === 0) {
  45864. tables['hhea'].data[10] = 0xFF;
  45865. tables['hhea'].data[11] = 0xFF;
  45866. }
  45867. var metricsOverride = {
  45868. unitsPerEm: int16(tables['head'].data[18], tables['head'].data[19]),
  45869. yMax: int16(tables['head'].data[42], tables['head'].data[43]),
  45870. yMin: signedInt16(tables['head'].data[38], tables['head'].data[39]),
  45871. ascent: int16(tables['hhea'].data[4], tables['hhea'].data[5]),
  45872. descent: signedInt16(tables['hhea'].data[6], tables['hhea'].data[7])
  45873. };
  45874. this.ascent = metricsOverride.ascent / metricsOverride.unitsPerEm;
  45875. this.descent = metricsOverride.descent / metricsOverride.unitsPerEm;
  45876. if (tables['post']) {
  45877. var valid = readPostScriptTable(tables['post'], properties, numGlyphs);
  45878. if (!valid) {
  45879. tables['post'] = null;
  45880. }
  45881. }
  45882. var charCodeToGlyphId = [], charCode;
  45883. var toUnicode = properties.toUnicode, widths = properties.widths;
  45884. var skipToUnicode = toUnicode instanceof IdentityToUnicodeMap || toUnicode.length === 0x10000;
  45885. function hasGlyph(glyphId, charCode, widthCode) {
  45886. if (!missingGlyphs[glyphId]) {
  45887. return true;
  45888. }
  45889. if (!skipToUnicode && charCode >= 0 && toUnicode.has(charCode)) {
  45890. return true;
  45891. }
  45892. if (widths && widthCode >= 0 && isNum(widths[widthCode])) {
  45893. return true;
  45894. }
  45895. return false;
  45896. }
  45897. if (properties.composite) {
  45898. var cidToGidMap = properties.cidToGidMap || [];
  45899. var isCidToGidMapEmpty = cidToGidMap.length === 0;
  45900. properties.cMap.forEach(function (charCode, cid) {
  45901. assert(cid <= 0xffff, 'Max size of CID is 65,535');
  45902. var glyphId = -1;
  45903. if (isCidToGidMapEmpty) {
  45904. glyphId = cid;
  45905. } else if (cidToGidMap[cid] !== undefined) {
  45906. glyphId = cidToGidMap[cid];
  45907. }
  45908. if (glyphId >= 0 && glyphId < numGlyphs && hasGlyph(glyphId, charCode, cid)) {
  45909. charCodeToGlyphId[charCode] = glyphId;
  45910. }
  45911. });
  45912. if (dupFirstEntry && (isCidToGidMapEmpty || !charCodeToGlyphId[0])) {
  45913. charCodeToGlyphId[0] = numGlyphs - 1;
  45914. }
  45915. } else {
  45916. var cmapTable = readCmapTable(tables['cmap'], font, this.isSymbolicFont, properties.hasEncoding);
  45917. var cmapPlatformId = cmapTable.platformId;
  45918. var cmapEncodingId = cmapTable.encodingId;
  45919. var cmapMappings = cmapTable.mappings;
  45920. var cmapMappingsLength = cmapMappings.length;
  45921. if (properties.hasEncoding && (cmapPlatformId === 3 && cmapEncodingId === 1 || cmapPlatformId === 1 && cmapEncodingId === 0) || cmapPlatformId === -1 && cmapEncodingId === -1 && !!getEncoding(properties.baseEncodingName)) {
  45922. var baseEncoding = [];
  45923. if (properties.baseEncodingName === 'MacRomanEncoding' || properties.baseEncodingName === 'WinAnsiEncoding') {
  45924. baseEncoding = getEncoding(properties.baseEncodingName);
  45925. }
  45926. var glyphsUnicodeMap = getGlyphsUnicode();
  45927. for (charCode = 0; charCode < 256; charCode++) {
  45928. var glyphName, standardGlyphName;
  45929. if (this.differences && charCode in this.differences) {
  45930. glyphName = this.differences[charCode];
  45931. } else if (charCode in baseEncoding && baseEncoding[charCode] !== '') {
  45932. glyphName = baseEncoding[charCode];
  45933. } else {
  45934. glyphName = StandardEncoding[charCode];
  45935. }
  45936. if (!glyphName) {
  45937. continue;
  45938. }
  45939. standardGlyphName = recoverGlyphName(glyphName, glyphsUnicodeMap);
  45940. var unicodeOrCharCode, isUnicode = false;
  45941. if (cmapPlatformId === 3 && cmapEncodingId === 1) {
  45942. unicodeOrCharCode = glyphsUnicodeMap[standardGlyphName];
  45943. isUnicode = true;
  45944. } else if (cmapPlatformId === 1 && cmapEncodingId === 0) {
  45945. unicodeOrCharCode = MacRomanEncoding.indexOf(standardGlyphName);
  45946. }
  45947. var found = false;
  45948. for (i = 0; i < cmapMappingsLength; ++i) {
  45949. if (cmapMappings[i].charCode !== unicodeOrCharCode) {
  45950. continue;
  45951. }
  45952. var code = isUnicode ? charCode : unicodeOrCharCode;
  45953. if (hasGlyph(cmapMappings[i].glyphId, code, -1)) {
  45954. charCodeToGlyphId[charCode] = cmapMappings[i].glyphId;
  45955. found = true;
  45956. break;
  45957. }
  45958. }
  45959. if (!found && properties.glyphNames) {
  45960. var glyphId = properties.glyphNames.indexOf(glyphName);
  45961. if (glyphId === -1 && standardGlyphName !== glyphName) {
  45962. glyphId = properties.glyphNames.indexOf(standardGlyphName);
  45963. }
  45964. if (glyphId > 0 && hasGlyph(glyphId, -1, -1)) {
  45965. charCodeToGlyphId[charCode] = glyphId;
  45966. found = true;
  45967. }
  45968. }
  45969. if (!found) {
  45970. charCodeToGlyphId[charCode] = 0;
  45971. }
  45972. }
  45973. } else if (cmapPlatformId === 0 && cmapEncodingId === 0) {
  45974. for (i = 0; i < cmapMappingsLength; ++i) {
  45975. charCodeToGlyphId[cmapMappings[i].charCode] = cmapMappings[i].glyphId;
  45976. }
  45977. } else {
  45978. for (i = 0; i < cmapMappingsLength; ++i) {
  45979. charCode = cmapMappings[i].charCode & 0xFF;
  45980. charCodeToGlyphId[charCode] = cmapMappings[i].glyphId;
  45981. }
  45982. }
  45983. }
  45984. if (charCodeToGlyphId.length === 0) {
  45985. charCodeToGlyphId[0] = 0;
  45986. }
  45987. var newMapping = adjustMapping(charCodeToGlyphId, properties);
  45988. this.toFontChar = newMapping.toFontChar;
  45989. tables['cmap'] = {
  45990. tag: 'cmap',
  45991. data: createCmapTable(newMapping.charCodeToGlyphId, numGlyphs)
  45992. };
  45993. if (!tables['OS/2'] || !validateOS2Table(tables['OS/2'])) {
  45994. tables['OS/2'] = {
  45995. tag: 'OS/2',
  45996. data: createOS2Table(properties, newMapping.charCodeToGlyphId, metricsOverride)
  45997. };
  45998. }
  45999. if (!tables['post']) {
  46000. tables['post'] = {
  46001. tag: 'post',
  46002. data: createPostTable(properties)
  46003. };
  46004. }
  46005. if (!isTrueType) {
  46006. try {
  46007. cffFile = new Stream(tables['CFF '].data);
  46008. var parser = new CFFParser(cffFile, properties, SEAC_ANALYSIS_ENABLED);
  46009. cff = parser.parse();
  46010. var compiler = new CFFCompiler(cff);
  46011. tables['CFF '].data = compiler.compile();
  46012. } catch (e) {
  46013. warn('Failed to compile font ' + properties.loadedName);
  46014. }
  46015. }
  46016. if (!tables['name']) {
  46017. tables['name'] = {
  46018. tag: 'name',
  46019. data: createNameTable(this.name)
  46020. };
  46021. } else {
  46022. var namePrototype = readNameTable(tables['name']);
  46023. tables['name'].data = createNameTable(name, namePrototype);
  46024. }
  46025. var builder = new OpenTypeFileBuilder(header.version);
  46026. for (var tableTag in tables) {
  46027. builder.addTable(tableTag, tables[tableTag].data);
  46028. }
  46029. return builder.toArray();
  46030. },
  46031. convert: function Font_convert(fontName, font, properties) {
  46032. properties.fixedPitch = false;
  46033. if (properties.builtInEncoding) {
  46034. adjustToUnicode(properties, properties.builtInEncoding);
  46035. }
  46036. var mapping = font.getGlyphMapping(properties);
  46037. var newMapping = adjustMapping(mapping, properties);
  46038. this.toFontChar = newMapping.toFontChar;
  46039. var numGlyphs = font.numGlyphs;
  46040. function getCharCodes(charCodeToGlyphId, glyphId) {
  46041. var charCodes = null;
  46042. for (var charCode in charCodeToGlyphId) {
  46043. if (glyphId === charCodeToGlyphId[charCode]) {
  46044. if (!charCodes) {
  46045. charCodes = [];
  46046. }
  46047. charCodes.push(charCode | 0);
  46048. }
  46049. }
  46050. return charCodes;
  46051. }
  46052. function createCharCode(charCodeToGlyphId, glyphId) {
  46053. for (var charCode in charCodeToGlyphId) {
  46054. if (glyphId === charCodeToGlyphId[charCode]) {
  46055. return charCode | 0;
  46056. }
  46057. }
  46058. newMapping.charCodeToGlyphId[newMapping.nextAvailableFontCharCode] = glyphId;
  46059. return newMapping.nextAvailableFontCharCode++;
  46060. }
  46061. var seacs = font.seacs;
  46062. if (SEAC_ANALYSIS_ENABLED && seacs && seacs.length) {
  46063. var matrix = properties.fontMatrix || FONT_IDENTITY_MATRIX;
  46064. var charset = font.getCharset();
  46065. var seacMap = Object.create(null);
  46066. for (var glyphId in seacs) {
  46067. glyphId |= 0;
  46068. var seac = seacs[glyphId];
  46069. var baseGlyphName = StandardEncoding[seac[2]];
  46070. var accentGlyphName = StandardEncoding[seac[3]];
  46071. var baseGlyphId = charset.indexOf(baseGlyphName);
  46072. var accentGlyphId = charset.indexOf(accentGlyphName);
  46073. if (baseGlyphId < 0 || accentGlyphId < 0) {
  46074. continue;
  46075. }
  46076. var accentOffset = {
  46077. x: seac[0] * matrix[0] + seac[1] * matrix[2] + matrix[4],
  46078. y: seac[0] * matrix[1] + seac[1] * matrix[3] + matrix[5]
  46079. };
  46080. var charCodes = getCharCodes(mapping, glyphId);
  46081. if (!charCodes) {
  46082. continue;
  46083. }
  46084. for (var i = 0, ii = charCodes.length; i < ii; i++) {
  46085. var charCode = charCodes[i];
  46086. var charCodeToGlyphId = newMapping.charCodeToGlyphId;
  46087. var baseFontCharCode = createCharCode(charCodeToGlyphId, baseGlyphId);
  46088. var accentFontCharCode = createCharCode(charCodeToGlyphId, accentGlyphId);
  46089. seacMap[charCode] = {
  46090. baseFontCharCode: baseFontCharCode,
  46091. accentFontCharCode: accentFontCharCode,
  46092. accentOffset: accentOffset
  46093. };
  46094. }
  46095. }
  46096. properties.seacMap = seacMap;
  46097. }
  46098. var unitsPerEm = 1 / (properties.fontMatrix || FONT_IDENTITY_MATRIX)[0];
  46099. var builder = new OpenTypeFileBuilder('\x4F\x54\x54\x4F');
  46100. builder.addTable('CFF ', font.data);
  46101. builder.addTable('OS/2', createOS2Table(properties, newMapping.charCodeToGlyphId));
  46102. builder.addTable('cmap', createCmapTable(newMapping.charCodeToGlyphId, numGlyphs));
  46103. 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');
  46104. 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));
  46105. builder.addTable('hmtx', function fontFieldsHmtx() {
  46106. var charstrings = font.charstrings;
  46107. var cffWidths = font.cff ? font.cff.widths : null;
  46108. var hmtx = '\x00\x00\x00\x00';
  46109. for (var i = 1, ii = numGlyphs; i < ii; i++) {
  46110. var width = 0;
  46111. if (charstrings) {
  46112. var charstring = charstrings[i - 1];
  46113. width = 'width' in charstring ? charstring.width : 0;
  46114. } else if (cffWidths) {
  46115. width = Math.ceil(cffWidths[i] || 0);
  46116. }
  46117. hmtx += string16(width) + string16(0);
  46118. }
  46119. return hmtx;
  46120. }());
  46121. builder.addTable('maxp', '\x00\x00\x50\x00' + string16(numGlyphs));
  46122. builder.addTable('name', createNameTable(fontName));
  46123. builder.addTable('post', createPostTable(properties));
  46124. return builder.toArray();
  46125. },
  46126. get spaceWidth() {
  46127. if ('_shadowWidth' in this) {
  46128. return this._shadowWidth;
  46129. }
  46130. var possibleSpaceReplacements = [
  46131. 'space',
  46132. 'minus',
  46133. 'one',
  46134. 'i',
  46135. 'I'
  46136. ];
  46137. var width;
  46138. for (var i = 0, ii = possibleSpaceReplacements.length; i < ii; i++) {
  46139. var glyphName = possibleSpaceReplacements[i];
  46140. if (glyphName in this.widths) {
  46141. width = this.widths[glyphName];
  46142. break;
  46143. }
  46144. var glyphsUnicodeMap = getGlyphsUnicode();
  46145. var glyphUnicode = glyphsUnicodeMap[glyphName];
  46146. var charcode = 0;
  46147. if (this.composite) {
  46148. if (this.cMap.contains(glyphUnicode)) {
  46149. charcode = this.cMap.lookup(glyphUnicode);
  46150. }
  46151. }
  46152. if (!charcode && this.toUnicode) {
  46153. charcode = this.toUnicode.charCodeOf(glyphUnicode);
  46154. }
  46155. if (charcode <= 0) {
  46156. charcode = glyphUnicode;
  46157. }
  46158. width = this.widths[charcode];
  46159. if (width) {
  46160. break;
  46161. }
  46162. }
  46163. width = width || this.defaultWidth;
  46164. this._shadowWidth = width;
  46165. return width;
  46166. },
  46167. charToGlyph: function Font_charToGlyph(charcode, isSpace) {
  46168. var fontCharCode, width, operatorListId;
  46169. var widthCode = charcode;
  46170. if (this.cMap && this.cMap.contains(charcode)) {
  46171. widthCode = this.cMap.lookup(charcode);
  46172. }
  46173. width = this.widths[widthCode];
  46174. width = isNum(width) ? width : this.defaultWidth;
  46175. var vmetric = this.vmetrics && this.vmetrics[widthCode];
  46176. var unicode = this.toUnicode.get(charcode) || charcode;
  46177. if (typeof unicode === 'number') {
  46178. unicode = String.fromCharCode(unicode);
  46179. }
  46180. var isInFont = charcode in this.toFontChar;
  46181. fontCharCode = this.toFontChar[charcode] || charcode;
  46182. if (this.missingFile) {
  46183. fontCharCode = mapSpecialUnicodeValues(fontCharCode);
  46184. }
  46185. if (this.isType3Font) {
  46186. operatorListId = fontCharCode;
  46187. }
  46188. var accent = null;
  46189. if (this.seacMap && this.seacMap[charcode]) {
  46190. isInFont = true;
  46191. var seac = this.seacMap[charcode];
  46192. fontCharCode = seac.baseFontCharCode;
  46193. accent = {
  46194. fontChar: String.fromCharCode(seac.accentFontCharCode),
  46195. offset: seac.accentOffset
  46196. };
  46197. }
  46198. var fontChar = String.fromCharCode(fontCharCode);
  46199. var glyph = this.glyphCache[charcode];
  46200. if (!glyph || !glyph.matchesForCache(fontChar, unicode, accent, width, vmetric, operatorListId, isSpace, isInFont)) {
  46201. glyph = new Glyph(fontChar, unicode, accent, width, vmetric, operatorListId, isSpace, isInFont);
  46202. this.glyphCache[charcode] = glyph;
  46203. }
  46204. return glyph;
  46205. },
  46206. charsToGlyphs: function Font_charsToGlyphs(chars) {
  46207. var charsCache = this.charsCache;
  46208. var glyphs, glyph, charcode;
  46209. if (charsCache) {
  46210. glyphs = charsCache[chars];
  46211. if (glyphs) {
  46212. return glyphs;
  46213. }
  46214. }
  46215. if (!charsCache) {
  46216. charsCache = this.charsCache = Object.create(null);
  46217. }
  46218. glyphs = [];
  46219. var charsCacheKey = chars;
  46220. var i = 0, ii;
  46221. if (this.cMap) {
  46222. var c = Object.create(null);
  46223. while (i < chars.length) {
  46224. this.cMap.readCharCode(chars, i, c);
  46225. charcode = c.charcode;
  46226. var length = c.length;
  46227. i += length;
  46228. var isSpace = length === 1 && chars.charCodeAt(i - 1) === 0x20;
  46229. glyph = this.charToGlyph(charcode, isSpace);
  46230. glyphs.push(glyph);
  46231. }
  46232. } else {
  46233. for (i = 0, ii = chars.length; i < ii; ++i) {
  46234. charcode = chars.charCodeAt(i);
  46235. glyph = this.charToGlyph(charcode, charcode === 0x20);
  46236. glyphs.push(glyph);
  46237. }
  46238. }
  46239. return charsCache[charsCacheKey] = glyphs;
  46240. }
  46241. };
  46242. return Font;
  46243. }();
  46244. var ErrorFont = function ErrorFontClosure() {
  46245. function ErrorFont(error) {
  46246. this.error = error;
  46247. this.loadedName = 'g_font_error';
  46248. this.loading = false;
  46249. }
  46250. ErrorFont.prototype = {
  46251. charsToGlyphs: function ErrorFont_charsToGlyphs() {
  46252. return [];
  46253. },
  46254. exportData: function ErrorFont_exportData() {
  46255. return { error: this.error };
  46256. }
  46257. };
  46258. return ErrorFont;
  46259. }();
  46260. function type1FontGlyphMapping(properties, builtInEncoding, glyphNames) {
  46261. var charCodeToGlyphId = Object.create(null);
  46262. var glyphId, charCode, baseEncoding;
  46263. var isSymbolicFont = !!(properties.flags & FontFlags.Symbolic);
  46264. if (properties.baseEncodingName) {
  46265. baseEncoding = getEncoding(properties.baseEncodingName);
  46266. for (charCode = 0; charCode < baseEncoding.length; charCode++) {
  46267. glyphId = glyphNames.indexOf(baseEncoding[charCode]);
  46268. if (glyphId >= 0) {
  46269. charCodeToGlyphId[charCode] = glyphId;
  46270. } else {
  46271. charCodeToGlyphId[charCode] = 0;
  46272. }
  46273. }
  46274. } else if (isSymbolicFont) {
  46275. for (charCode in builtInEncoding) {
  46276. charCodeToGlyphId[charCode] = builtInEncoding[charCode];
  46277. }
  46278. } else {
  46279. baseEncoding = StandardEncoding;
  46280. for (charCode = 0; charCode < baseEncoding.length; charCode++) {
  46281. glyphId = glyphNames.indexOf(baseEncoding[charCode]);
  46282. if (glyphId >= 0) {
  46283. charCodeToGlyphId[charCode] = glyphId;
  46284. } else {
  46285. charCodeToGlyphId[charCode] = 0;
  46286. }
  46287. }
  46288. }
  46289. var differences = properties.differences, glyphsUnicodeMap;
  46290. if (differences) {
  46291. for (charCode in differences) {
  46292. var glyphName = differences[charCode];
  46293. glyphId = glyphNames.indexOf(glyphName);
  46294. if (glyphId === -1) {
  46295. if (!glyphsUnicodeMap) {
  46296. glyphsUnicodeMap = getGlyphsUnicode();
  46297. }
  46298. var standardGlyphName = recoverGlyphName(glyphName, glyphsUnicodeMap);
  46299. if (standardGlyphName !== glyphName) {
  46300. glyphId = glyphNames.indexOf(standardGlyphName);
  46301. }
  46302. }
  46303. if (glyphId >= 0) {
  46304. charCodeToGlyphId[charCode] = glyphId;
  46305. } else {
  46306. charCodeToGlyphId[charCode] = 0;
  46307. }
  46308. }
  46309. }
  46310. return charCodeToGlyphId;
  46311. }
  46312. var Type1Font = function Type1FontClosure() {
  46313. function findBlock(streamBytes, signature, startIndex) {
  46314. var streamBytesLength = streamBytes.length;
  46315. var signatureLength = signature.length;
  46316. var scanLength = streamBytesLength - signatureLength;
  46317. var i = startIndex, j, found = false;
  46318. while (i < scanLength) {
  46319. j = 0;
  46320. while (j < signatureLength && streamBytes[i + j] === signature[j]) {
  46321. j++;
  46322. }
  46323. if (j >= signatureLength) {
  46324. i += j;
  46325. while (i < streamBytesLength && isSpace(streamBytes[i])) {
  46326. i++;
  46327. }
  46328. found = true;
  46329. break;
  46330. }
  46331. i++;
  46332. }
  46333. return {
  46334. found: found,
  46335. length: i
  46336. };
  46337. }
  46338. function getHeaderBlock(stream, suggestedLength) {
  46339. var EEXEC_SIGNATURE = [
  46340. 0x65,
  46341. 0x65,
  46342. 0x78,
  46343. 0x65,
  46344. 0x63
  46345. ];
  46346. var streamStartPos = stream.pos;
  46347. var headerBytes, headerBytesLength, block;
  46348. try {
  46349. headerBytes = stream.getBytes(suggestedLength);
  46350. headerBytesLength = headerBytes.length;
  46351. } catch (ex) {
  46352. if (ex instanceof MissingDataException) {
  46353. throw ex;
  46354. }
  46355. }
  46356. if (headerBytesLength === suggestedLength) {
  46357. block = findBlock(headerBytes, EEXEC_SIGNATURE, suggestedLength - 2 * EEXEC_SIGNATURE.length);
  46358. if (block.found && block.length === suggestedLength) {
  46359. return {
  46360. stream: new Stream(headerBytes),
  46361. length: suggestedLength
  46362. };
  46363. }
  46364. }
  46365. warn('Invalid "Length1" property in Type1 font -- trying to recover.');
  46366. stream.pos = streamStartPos;
  46367. var SCAN_BLOCK_LENGTH = 2048;
  46368. var actualLength;
  46369. while (true) {
  46370. var scanBytes = stream.peekBytes(SCAN_BLOCK_LENGTH);
  46371. block = findBlock(scanBytes, EEXEC_SIGNATURE, 0);
  46372. if (block.length === 0) {
  46373. break;
  46374. }
  46375. stream.pos += block.length;
  46376. if (block.found) {
  46377. actualLength = stream.pos - streamStartPos;
  46378. break;
  46379. }
  46380. }
  46381. stream.pos = streamStartPos;
  46382. if (actualLength) {
  46383. return {
  46384. stream: new Stream(stream.getBytes(actualLength)),
  46385. length: actualLength
  46386. };
  46387. }
  46388. warn('Unable to recover "Length1" property in Type1 font -- using as is.');
  46389. return {
  46390. stream: new Stream(stream.getBytes(suggestedLength)),
  46391. length: suggestedLength
  46392. };
  46393. }
  46394. function getEexecBlock(stream, suggestedLength) {
  46395. var eexecBytes = stream.getBytes();
  46396. return {
  46397. stream: new Stream(eexecBytes),
  46398. length: eexecBytes.length
  46399. };
  46400. }
  46401. function Type1Font(name, file, properties) {
  46402. var PFB_HEADER_SIZE = 6;
  46403. var headerBlockLength = properties.length1;
  46404. var eexecBlockLength = properties.length2;
  46405. var pfbHeader = file.peekBytes(PFB_HEADER_SIZE);
  46406. var pfbHeaderPresent = pfbHeader[0] === 0x80 && pfbHeader[1] === 0x01;
  46407. if (pfbHeaderPresent) {
  46408. file.skip(PFB_HEADER_SIZE);
  46409. headerBlockLength = pfbHeader[5] << 24 | pfbHeader[4] << 16 | pfbHeader[3] << 8 | pfbHeader[2];
  46410. }
  46411. var headerBlock = getHeaderBlock(file, headerBlockLength);
  46412. headerBlockLength = headerBlock.length;
  46413. var headerBlockParser = new Type1Parser(headerBlock.stream, false, SEAC_ANALYSIS_ENABLED);
  46414. headerBlockParser.extractFontHeader(properties);
  46415. if (pfbHeaderPresent) {
  46416. pfbHeader = file.getBytes(PFB_HEADER_SIZE);
  46417. eexecBlockLength = pfbHeader[5] << 24 | pfbHeader[4] << 16 | pfbHeader[3] << 8 | pfbHeader[2];
  46418. }
  46419. var eexecBlock = getEexecBlock(file, eexecBlockLength);
  46420. eexecBlockLength = eexecBlock.length;
  46421. var eexecBlockParser = new Type1Parser(eexecBlock.stream, true, SEAC_ANALYSIS_ENABLED);
  46422. var data = eexecBlockParser.extractFontProgram();
  46423. for (var info in data.properties) {
  46424. properties[info] = data.properties[info];
  46425. }
  46426. var charstrings = data.charstrings;
  46427. var type2Charstrings = this.getType2Charstrings(charstrings);
  46428. var subrs = this.getType2Subrs(data.subrs);
  46429. this.charstrings = charstrings;
  46430. this.data = this.wrap(name, type2Charstrings, this.charstrings, subrs, properties);
  46431. this.seacs = this.getSeacs(data.charstrings);
  46432. }
  46433. Type1Font.prototype = {
  46434. get numGlyphs() {
  46435. return this.charstrings.length + 1;
  46436. },
  46437. getCharset: function Type1Font_getCharset() {
  46438. var charset = ['.notdef'];
  46439. var charstrings = this.charstrings;
  46440. for (var glyphId = 0; glyphId < charstrings.length; glyphId++) {
  46441. charset.push(charstrings[glyphId].glyphName);
  46442. }
  46443. return charset;
  46444. },
  46445. getGlyphMapping: function Type1Font_getGlyphMapping(properties) {
  46446. var charstrings = this.charstrings;
  46447. var glyphNames = ['.notdef'], glyphId;
  46448. for (glyphId = 0; glyphId < charstrings.length; glyphId++) {
  46449. glyphNames.push(charstrings[glyphId].glyphName);
  46450. }
  46451. var encoding = properties.builtInEncoding;
  46452. if (encoding) {
  46453. var builtInEncoding = Object.create(null);
  46454. for (var charCode in encoding) {
  46455. glyphId = glyphNames.indexOf(encoding[charCode]);
  46456. if (glyphId >= 0) {
  46457. builtInEncoding[charCode] = glyphId;
  46458. }
  46459. }
  46460. }
  46461. return type1FontGlyphMapping(properties, builtInEncoding, glyphNames);
  46462. },
  46463. getSeacs: function Type1Font_getSeacs(charstrings) {
  46464. var i, ii;
  46465. var seacMap = [];
  46466. for (i = 0, ii = charstrings.length; i < ii; i++) {
  46467. var charstring = charstrings[i];
  46468. if (charstring.seac) {
  46469. seacMap[i + 1] = charstring.seac;
  46470. }
  46471. }
  46472. return seacMap;
  46473. },
  46474. getType2Charstrings: function Type1Font_getType2Charstrings(type1Charstrings) {
  46475. var type2Charstrings = [];
  46476. for (var i = 0, ii = type1Charstrings.length; i < ii; i++) {
  46477. type2Charstrings.push(type1Charstrings[i].charstring);
  46478. }
  46479. return type2Charstrings;
  46480. },
  46481. getType2Subrs: function Type1Font_getType2Subrs(type1Subrs) {
  46482. var bias = 0;
  46483. var count = type1Subrs.length;
  46484. if (count < 1133) {
  46485. bias = 107;
  46486. } else if (count < 33769) {
  46487. bias = 1131;
  46488. } else {
  46489. bias = 32768;
  46490. }
  46491. var type2Subrs = [];
  46492. var i;
  46493. for (i = 0; i < bias; i++) {
  46494. type2Subrs.push([0x0B]);
  46495. }
  46496. for (i = 0; i < count; i++) {
  46497. type2Subrs.push(type1Subrs[i]);
  46498. }
  46499. return type2Subrs;
  46500. },
  46501. wrap: function Type1Font_wrap(name, glyphs, charstrings, subrs, properties) {
  46502. var cff = new CFF();
  46503. cff.header = new CFFHeader(1, 0, 4, 4);
  46504. cff.names = [name];
  46505. var topDict = new CFFTopDict();
  46506. topDict.setByName('version', 391);
  46507. topDict.setByName('Notice', 392);
  46508. topDict.setByName('FullName', 393);
  46509. topDict.setByName('FamilyName', 394);
  46510. topDict.setByName('Weight', 395);
  46511. topDict.setByName('Encoding', null);
  46512. topDict.setByName('FontMatrix', properties.fontMatrix);
  46513. topDict.setByName('FontBBox', properties.bbox);
  46514. topDict.setByName('charset', null);
  46515. topDict.setByName('CharStrings', null);
  46516. topDict.setByName('Private', null);
  46517. cff.topDict = topDict;
  46518. var strings = new CFFStrings();
  46519. strings.add('Version 0.11');
  46520. strings.add('See original notice');
  46521. strings.add(name);
  46522. strings.add(name);
  46523. strings.add('Medium');
  46524. cff.strings = strings;
  46525. cff.globalSubrIndex = new CFFIndex();
  46526. var count = glyphs.length;
  46527. var charsetArray = [0];
  46528. var i, ii;
  46529. for (i = 0; i < count; i++) {
  46530. var index = CFFStandardStrings.indexOf(charstrings[i].glyphName);
  46531. if (index === -1) {
  46532. index = 0;
  46533. }
  46534. charsetArray.push(index >> 8 & 0xff, index & 0xff);
  46535. }
  46536. cff.charset = new CFFCharset(false, 0, [], charsetArray);
  46537. var charStringsIndex = new CFFIndex();
  46538. charStringsIndex.add([
  46539. 0x8B,
  46540. 0x0E
  46541. ]);
  46542. for (i = 0; i < count; i++) {
  46543. var glyph = glyphs[i];
  46544. if (glyph.length === 0) {
  46545. charStringsIndex.add([
  46546. 0x8B,
  46547. 0x0E
  46548. ]);
  46549. continue;
  46550. }
  46551. charStringsIndex.add(glyph);
  46552. }
  46553. cff.charStrings = charStringsIndex;
  46554. var privateDict = new CFFPrivateDict();
  46555. privateDict.setByName('Subrs', null);
  46556. var fields = [
  46557. 'BlueValues',
  46558. 'OtherBlues',
  46559. 'FamilyBlues',
  46560. 'FamilyOtherBlues',
  46561. 'StemSnapH',
  46562. 'StemSnapV',
  46563. 'BlueShift',
  46564. 'BlueFuzz',
  46565. 'BlueScale',
  46566. 'LanguageGroup',
  46567. 'ExpansionFactor',
  46568. 'ForceBold',
  46569. 'StdHW',
  46570. 'StdVW'
  46571. ];
  46572. for (i = 0, ii = fields.length; i < ii; i++) {
  46573. var field = fields[i];
  46574. if (!(field in properties.privateData)) {
  46575. continue;
  46576. }
  46577. var value = properties.privateData[field];
  46578. if (isArray(value)) {
  46579. for (var j = value.length - 1; j > 0; j--) {
  46580. value[j] -= value[j - 1];
  46581. }
  46582. }
  46583. privateDict.setByName(field, value);
  46584. }
  46585. cff.topDict.privateDict = privateDict;
  46586. var subrIndex = new CFFIndex();
  46587. for (i = 0, ii = subrs.length; i < ii; i++) {
  46588. subrIndex.add(subrs[i]);
  46589. }
  46590. privateDict.subrsIndex = subrIndex;
  46591. var compiler = new CFFCompiler(cff);
  46592. return compiler.compile();
  46593. }
  46594. };
  46595. return Type1Font;
  46596. }();
  46597. var CFFFont = function CFFFontClosure() {
  46598. function CFFFont(file, properties) {
  46599. this.properties = properties;
  46600. var parser = new CFFParser(file, properties, SEAC_ANALYSIS_ENABLED);
  46601. this.cff = parser.parse();
  46602. var compiler = new CFFCompiler(this.cff);
  46603. this.seacs = this.cff.seacs;
  46604. try {
  46605. this.data = compiler.compile();
  46606. } catch (e) {
  46607. warn('Failed to compile font ' + properties.loadedName);
  46608. this.data = file;
  46609. }
  46610. }
  46611. CFFFont.prototype = {
  46612. get numGlyphs() {
  46613. return this.cff.charStrings.count;
  46614. },
  46615. getCharset: function CFFFont_getCharset() {
  46616. return this.cff.charset.charset;
  46617. },
  46618. getGlyphMapping: function CFFFont_getGlyphMapping() {
  46619. var cff = this.cff;
  46620. var properties = this.properties;
  46621. var charsets = cff.charset.charset;
  46622. var charCodeToGlyphId;
  46623. var glyphId;
  46624. if (properties.composite) {
  46625. charCodeToGlyphId = Object.create(null);
  46626. if (cff.isCIDFont) {
  46627. for (glyphId = 0; glyphId < charsets.length; glyphId++) {
  46628. var cid = charsets[glyphId];
  46629. var charCode = properties.cMap.charCodeOf(cid);
  46630. charCodeToGlyphId[charCode] = glyphId;
  46631. }
  46632. } else {
  46633. for (glyphId = 0; glyphId < cff.charStrings.count; glyphId++) {
  46634. charCodeToGlyphId[glyphId] = glyphId;
  46635. }
  46636. }
  46637. return charCodeToGlyphId;
  46638. }
  46639. var encoding = cff.encoding ? cff.encoding.encoding : null;
  46640. charCodeToGlyphId = type1FontGlyphMapping(properties, encoding, charsets);
  46641. return charCodeToGlyphId;
  46642. }
  46643. };
  46644. return CFFFont;
  46645. }();
  46646. (function checkSeacSupport() {
  46647. if (typeof navigator !== 'undefined' && /Windows/.test(navigator.userAgent)) {
  46648. SEAC_ANALYSIS_ENABLED = true;
  46649. }
  46650. }());
  46651. (function checkChromeWindows() {
  46652. if (typeof navigator !== 'undefined' && /Windows.*Chrome/.test(navigator.userAgent)) {
  46653. SKIP_PRIVATE_USE_RANGE_F000_TO_F01F = true;
  46654. }
  46655. }());
  46656. exports.ErrorFont = ErrorFont;
  46657. exports.Font = Font;
  46658. exports.FontFlags = FontFlags;
  46659. exports.IdentityToUnicodeMap = IdentityToUnicodeMap;
  46660. exports.ToUnicodeMap = ToUnicodeMap;
  46661. exports.getFontType = getFontType;
  46662. /***/ }),
  46663. /* 35 */
  46664. /***/ (function(module, exports, __w_pdfjs_require__) {
  46665. "use strict";
  46666. var sharedUtil = __w_pdfjs_require__(0);
  46667. var corePrimitives = __w_pdfjs_require__(1);
  46668. var coreColorSpace = __w_pdfjs_require__(4);
  46669. var coreStream = __w_pdfjs_require__(2);
  46670. var coreJpx = __w_pdfjs_require__(18);
  46671. var ImageKind = sharedUtil.ImageKind;
  46672. var assert = sharedUtil.assert;
  46673. var error = sharedUtil.error;
  46674. var info = sharedUtil.info;
  46675. var isArray = sharedUtil.isArray;
  46676. var warn = sharedUtil.warn;
  46677. var Name = corePrimitives.Name;
  46678. var isStream = corePrimitives.isStream;
  46679. var ColorSpace = coreColorSpace.ColorSpace;
  46680. var DecodeStream = coreStream.DecodeStream;
  46681. var JpegStream = coreStream.JpegStream;
  46682. var JpxImage = coreJpx.JpxImage;
  46683. var PDFImage = function PDFImageClosure() {
  46684. function handleImageData(image, nativeDecoder) {
  46685. if (nativeDecoder && nativeDecoder.canDecode(image)) {
  46686. return nativeDecoder.decode(image);
  46687. }
  46688. return Promise.resolve(image);
  46689. }
  46690. function decodeAndClamp(value, addend, coefficient, max) {
  46691. value = addend + value * coefficient;
  46692. return value < 0 ? 0 : value > max ? max : value;
  46693. }
  46694. function resizeImageMask(src, bpc, w1, h1, w2, h2) {
  46695. var length = w2 * h2;
  46696. var dest = bpc <= 8 ? new Uint8Array(length) : bpc <= 16 ? new Uint16Array(length) : new Uint32Array(length);
  46697. var xRatio = w1 / w2;
  46698. var yRatio = h1 / h2;
  46699. var i, j, py, newIndex = 0, oldIndex;
  46700. var xScaled = new Uint16Array(w2);
  46701. var w1Scanline = w1;
  46702. for (i = 0; i < w2; i++) {
  46703. xScaled[i] = Math.floor(i * xRatio);
  46704. }
  46705. for (i = 0; i < h2; i++) {
  46706. py = Math.floor(i * yRatio) * w1Scanline;
  46707. for (j = 0; j < w2; j++) {
  46708. oldIndex = py + xScaled[j];
  46709. dest[newIndex++] = src[oldIndex];
  46710. }
  46711. }
  46712. return dest;
  46713. }
  46714. function PDFImage(xref, res, image, inline, smask, mask, isMask) {
  46715. this.image = image;
  46716. var dict = image.dict;
  46717. if (dict.has('Filter')) {
  46718. var filter = dict.get('Filter').name;
  46719. if (filter === 'JPXDecode') {
  46720. var jpxImage = new JpxImage();
  46721. jpxImage.parseImageProperties(image.stream);
  46722. image.stream.reset();
  46723. image.bitsPerComponent = jpxImage.bitsPerComponent;
  46724. image.numComps = jpxImage.componentsCount;
  46725. } else if (filter === 'JBIG2Decode') {
  46726. image.bitsPerComponent = 1;
  46727. image.numComps = 1;
  46728. }
  46729. }
  46730. this.width = dict.get('Width', 'W');
  46731. this.height = dict.get('Height', 'H');
  46732. if (this.width < 1 || this.height < 1) {
  46733. error('Invalid image width: ' + this.width + ' or height: ' + this.height);
  46734. }
  46735. this.interpolate = dict.get('Interpolate', 'I') || false;
  46736. this.imageMask = dict.get('ImageMask', 'IM') || false;
  46737. this.matte = dict.get('Matte') || false;
  46738. var bitsPerComponent = image.bitsPerComponent;
  46739. if (!bitsPerComponent) {
  46740. bitsPerComponent = dict.get('BitsPerComponent', 'BPC');
  46741. if (!bitsPerComponent) {
  46742. if (this.imageMask) {
  46743. bitsPerComponent = 1;
  46744. } else {
  46745. error('Bits per component missing in image: ' + this.imageMask);
  46746. }
  46747. }
  46748. }
  46749. this.bpc = bitsPerComponent;
  46750. if (!this.imageMask) {
  46751. var colorSpace = dict.get('ColorSpace', 'CS');
  46752. if (!colorSpace) {
  46753. info('JPX images (which do not require color spaces)');
  46754. switch (image.numComps) {
  46755. case 1:
  46756. colorSpace = Name.get('DeviceGray');
  46757. break;
  46758. case 3:
  46759. colorSpace = Name.get('DeviceRGB');
  46760. break;
  46761. case 4:
  46762. colorSpace = Name.get('DeviceCMYK');
  46763. break;
  46764. default:
  46765. error('JPX images with ' + this.numComps + ' color components not supported.');
  46766. }
  46767. }
  46768. this.colorSpace = ColorSpace.parse(colorSpace, xref, res);
  46769. this.numComps = this.colorSpace.numComps;
  46770. }
  46771. this.decode = dict.getArray('Decode', 'D');
  46772. this.needsDecode = false;
  46773. if (this.decode && (this.colorSpace && !this.colorSpace.isDefaultDecode(this.decode) || isMask && !ColorSpace.isDefaultDecode(this.decode, 1))) {
  46774. this.needsDecode = true;
  46775. var max = (1 << bitsPerComponent) - 1;
  46776. this.decodeCoefficients = [];
  46777. this.decodeAddends = [];
  46778. for (var i = 0, j = 0; i < this.decode.length; i += 2, ++j) {
  46779. var dmin = this.decode[i];
  46780. var dmax = this.decode[i + 1];
  46781. this.decodeCoefficients[j] = dmax - dmin;
  46782. this.decodeAddends[j] = max * dmin;
  46783. }
  46784. }
  46785. if (smask) {
  46786. this.smask = new PDFImage(xref, res, smask, false);
  46787. } else if (mask) {
  46788. if (isStream(mask)) {
  46789. var maskDict = mask.dict, imageMask = maskDict.get('ImageMask', 'IM');
  46790. if (!imageMask) {
  46791. warn('Ignoring /Mask in image without /ImageMask.');
  46792. } else {
  46793. this.mask = new PDFImage(xref, res, mask, false, null, null, true);
  46794. }
  46795. } else {
  46796. this.mask = mask;
  46797. }
  46798. }
  46799. }
  46800. PDFImage.buildImage = function PDFImage_buildImage(handler, xref, res, image, inline, nativeDecoder) {
  46801. var imagePromise = handleImageData(image, nativeDecoder);
  46802. var smaskPromise;
  46803. var maskPromise;
  46804. var smask = image.dict.get('SMask');
  46805. var mask = image.dict.get('Mask');
  46806. if (smask) {
  46807. smaskPromise = handleImageData(smask, nativeDecoder);
  46808. maskPromise = Promise.resolve(null);
  46809. } else {
  46810. smaskPromise = Promise.resolve(null);
  46811. if (mask) {
  46812. if (isStream(mask)) {
  46813. maskPromise = handleImageData(mask, nativeDecoder);
  46814. } else if (isArray(mask)) {
  46815. maskPromise = Promise.resolve(mask);
  46816. } else {
  46817. warn('Unsupported mask format.');
  46818. maskPromise = Promise.resolve(null);
  46819. }
  46820. } else {
  46821. maskPromise = Promise.resolve(null);
  46822. }
  46823. }
  46824. return Promise.all([
  46825. imagePromise,
  46826. smaskPromise,
  46827. maskPromise
  46828. ]).then(function (results) {
  46829. var imageData = results[0];
  46830. var smaskData = results[1];
  46831. var maskData = results[2];
  46832. return new PDFImage(xref, res, imageData, inline, smaskData, maskData);
  46833. });
  46834. };
  46835. PDFImage.createMask = function PDFImage_createMask(imgArray, width, height, imageIsFromDecodeStream, inverseDecode) {
  46836. var computedLength = (width + 7 >> 3) * height;
  46837. var actualLength = imgArray.byteLength;
  46838. var haveFullData = computedLength === actualLength;
  46839. var data, i;
  46840. if (imageIsFromDecodeStream && (!inverseDecode || haveFullData)) {
  46841. data = imgArray;
  46842. } else if (!inverseDecode) {
  46843. data = new Uint8Array(actualLength);
  46844. data.set(imgArray);
  46845. } else {
  46846. data = new Uint8Array(computedLength);
  46847. data.set(imgArray);
  46848. for (i = actualLength; i < computedLength; i++) {
  46849. data[i] = 0xff;
  46850. }
  46851. }
  46852. if (inverseDecode) {
  46853. for (i = 0; i < actualLength; i++) {
  46854. data[i] = ~data[i];
  46855. }
  46856. }
  46857. return {
  46858. data: data,
  46859. width: width,
  46860. height: height
  46861. };
  46862. };
  46863. PDFImage.prototype = {
  46864. get drawWidth() {
  46865. return Math.max(this.width, this.smask && this.smask.width || 0, this.mask && this.mask.width || 0);
  46866. },
  46867. get drawHeight() {
  46868. return Math.max(this.height, this.smask && this.smask.height || 0, this.mask && this.mask.height || 0);
  46869. },
  46870. decodeBuffer: function PDFImage_decodeBuffer(buffer) {
  46871. var bpc = this.bpc;
  46872. var numComps = this.numComps;
  46873. var decodeAddends = this.decodeAddends;
  46874. var decodeCoefficients = this.decodeCoefficients;
  46875. var max = (1 << bpc) - 1;
  46876. var i, ii;
  46877. if (bpc === 1) {
  46878. for (i = 0, ii = buffer.length; i < ii; i++) {
  46879. buffer[i] = +!buffer[i];
  46880. }
  46881. return;
  46882. }
  46883. var index = 0;
  46884. for (i = 0, ii = this.width * this.height; i < ii; i++) {
  46885. for (var j = 0; j < numComps; j++) {
  46886. buffer[index] = decodeAndClamp(buffer[index], decodeAddends[j], decodeCoefficients[j], max);
  46887. index++;
  46888. }
  46889. }
  46890. },
  46891. getComponents: function PDFImage_getComponents(buffer) {
  46892. var bpc = this.bpc;
  46893. if (bpc === 8) {
  46894. return buffer;
  46895. }
  46896. var width = this.width;
  46897. var height = this.height;
  46898. var numComps = this.numComps;
  46899. var length = width * height * numComps;
  46900. var bufferPos = 0;
  46901. var output = bpc <= 8 ? new Uint8Array(length) : bpc <= 16 ? new Uint16Array(length) : new Uint32Array(length);
  46902. var rowComps = width * numComps;
  46903. var max = (1 << bpc) - 1;
  46904. var i = 0, ii, buf;
  46905. if (bpc === 1) {
  46906. var mask, loop1End, loop2End;
  46907. for (var j = 0; j < height; j++) {
  46908. loop1End = i + (rowComps & ~7);
  46909. loop2End = i + rowComps;
  46910. while (i < loop1End) {
  46911. buf = buffer[bufferPos++];
  46912. output[i] = buf >> 7 & 1;
  46913. output[i + 1] = buf >> 6 & 1;
  46914. output[i + 2] = buf >> 5 & 1;
  46915. output[i + 3] = buf >> 4 & 1;
  46916. output[i + 4] = buf >> 3 & 1;
  46917. output[i + 5] = buf >> 2 & 1;
  46918. output[i + 6] = buf >> 1 & 1;
  46919. output[i + 7] = buf & 1;
  46920. i += 8;
  46921. }
  46922. if (i < loop2End) {
  46923. buf = buffer[bufferPos++];
  46924. mask = 128;
  46925. while (i < loop2End) {
  46926. output[i++] = +!!(buf & mask);
  46927. mask >>= 1;
  46928. }
  46929. }
  46930. }
  46931. } else {
  46932. var bits = 0;
  46933. buf = 0;
  46934. for (i = 0, ii = length; i < ii; ++i) {
  46935. if (i % rowComps === 0) {
  46936. buf = 0;
  46937. bits = 0;
  46938. }
  46939. while (bits < bpc) {
  46940. buf = buf << 8 | buffer[bufferPos++];
  46941. bits += 8;
  46942. }
  46943. var remainingBits = bits - bpc;
  46944. var value = buf >> remainingBits;
  46945. output[i] = value < 0 ? 0 : value > max ? max : value;
  46946. buf = buf & (1 << remainingBits) - 1;
  46947. bits = remainingBits;
  46948. }
  46949. }
  46950. return output;
  46951. },
  46952. fillOpacity: function PDFImage_fillOpacity(rgbaBuf, width, height, actualHeight, image) {
  46953. var smask = this.smask;
  46954. var mask = this.mask;
  46955. var alphaBuf, sw, sh, i, ii, j;
  46956. if (smask) {
  46957. sw = smask.width;
  46958. sh = smask.height;
  46959. alphaBuf = new Uint8Array(sw * sh);
  46960. smask.fillGrayBuffer(alphaBuf);
  46961. if (sw !== width || sh !== height) {
  46962. alphaBuf = resizeImageMask(alphaBuf, smask.bpc, sw, sh, width, height);
  46963. }
  46964. } else if (mask) {
  46965. if (mask instanceof PDFImage) {
  46966. sw = mask.width;
  46967. sh = mask.height;
  46968. alphaBuf = new Uint8Array(sw * sh);
  46969. mask.numComps = 1;
  46970. mask.fillGrayBuffer(alphaBuf);
  46971. for (i = 0, ii = sw * sh; i < ii; ++i) {
  46972. alphaBuf[i] = 255 - alphaBuf[i];
  46973. }
  46974. if (sw !== width || sh !== height) {
  46975. alphaBuf = resizeImageMask(alphaBuf, mask.bpc, sw, sh, width, height);
  46976. }
  46977. } else if (isArray(mask)) {
  46978. alphaBuf = new Uint8Array(width * height);
  46979. var numComps = this.numComps;
  46980. for (i = 0, ii = width * height; i < ii; ++i) {
  46981. var opacity = 0;
  46982. var imageOffset = i * numComps;
  46983. for (j = 0; j < numComps; ++j) {
  46984. var color = image[imageOffset + j];
  46985. var maskOffset = j * 2;
  46986. if (color < mask[maskOffset] || color > mask[maskOffset + 1]) {
  46987. opacity = 255;
  46988. break;
  46989. }
  46990. }
  46991. alphaBuf[i] = opacity;
  46992. }
  46993. } else {
  46994. error('Unknown mask format.');
  46995. }
  46996. }
  46997. if (alphaBuf) {
  46998. for (i = 0, j = 3, ii = width * actualHeight; i < ii; ++i, j += 4) {
  46999. rgbaBuf[j] = alphaBuf[i];
  47000. }
  47001. } else {
  47002. for (i = 0, j = 3, ii = width * actualHeight; i < ii; ++i, j += 4) {
  47003. rgbaBuf[j] = 255;
  47004. }
  47005. }
  47006. },
  47007. undoPreblend: function PDFImage_undoPreblend(buffer, width, height) {
  47008. var matte = this.smask && this.smask.matte;
  47009. if (!matte) {
  47010. return;
  47011. }
  47012. var matteRgb = this.colorSpace.getRgb(matte, 0);
  47013. var matteR = matteRgb[0];
  47014. var matteG = matteRgb[1];
  47015. var matteB = matteRgb[2];
  47016. var length = width * height * 4;
  47017. var r, g, b;
  47018. for (var i = 0; i < length; i += 4) {
  47019. var alpha = buffer[i + 3];
  47020. if (alpha === 0) {
  47021. buffer[i] = 255;
  47022. buffer[i + 1] = 255;
  47023. buffer[i + 2] = 255;
  47024. continue;
  47025. }
  47026. var k = 255 / alpha;
  47027. r = (buffer[i] - matteR) * k + matteR;
  47028. g = (buffer[i + 1] - matteG) * k + matteG;
  47029. b = (buffer[i + 2] - matteB) * k + matteB;
  47030. buffer[i] = r <= 0 ? 0 : r >= 255 ? 255 : r | 0;
  47031. buffer[i + 1] = g <= 0 ? 0 : g >= 255 ? 255 : g | 0;
  47032. buffer[i + 2] = b <= 0 ? 0 : b >= 255 ? 255 : b | 0;
  47033. }
  47034. },
  47035. createImageData: function PDFImage_createImageData(forceRGBA) {
  47036. var drawWidth = this.drawWidth;
  47037. var drawHeight = this.drawHeight;
  47038. var imgData = {
  47039. width: drawWidth,
  47040. height: drawHeight
  47041. };
  47042. var numComps = this.numComps;
  47043. var originalWidth = this.width;
  47044. var originalHeight = this.height;
  47045. var bpc = this.bpc;
  47046. var rowBytes = originalWidth * numComps * bpc + 7 >> 3;
  47047. var imgArray;
  47048. if (!forceRGBA) {
  47049. var kind;
  47050. if (this.colorSpace.name === 'DeviceGray' && bpc === 1) {
  47051. kind = ImageKind.GRAYSCALE_1BPP;
  47052. } else if (this.colorSpace.name === 'DeviceRGB' && bpc === 8 && !this.needsDecode) {
  47053. kind = ImageKind.RGB_24BPP;
  47054. }
  47055. if (kind && !this.smask && !this.mask && drawWidth === originalWidth && drawHeight === originalHeight) {
  47056. imgData.kind = kind;
  47057. imgArray = this.getImageBytes(originalHeight * rowBytes);
  47058. if (this.image instanceof DecodeStream) {
  47059. imgData.data = imgArray;
  47060. } else {
  47061. var newArray = new Uint8Array(imgArray.length);
  47062. newArray.set(imgArray);
  47063. imgData.data = newArray;
  47064. }
  47065. if (this.needsDecode) {
  47066. assert(kind === ImageKind.GRAYSCALE_1BPP);
  47067. var buffer = imgData.data;
  47068. for (var i = 0, ii = buffer.length; i < ii; i++) {
  47069. buffer[i] ^= 0xff;
  47070. }
  47071. }
  47072. return imgData;
  47073. }
  47074. if (this.image instanceof JpegStream && !this.smask && !this.mask && (this.colorSpace.name === 'DeviceGray' || this.colorSpace.name === 'DeviceRGB' || this.colorSpace.name === 'DeviceCMYK')) {
  47075. imgData.kind = ImageKind.RGB_24BPP;
  47076. imgData.data = this.getImageBytes(originalHeight * rowBytes, drawWidth, drawHeight, true);
  47077. return imgData;
  47078. }
  47079. }
  47080. imgArray = this.getImageBytes(originalHeight * rowBytes);
  47081. var actualHeight = 0 | imgArray.length / rowBytes * drawHeight / originalHeight;
  47082. var comps = this.getComponents(imgArray);
  47083. var alpha01, maybeUndoPreblend;
  47084. if (!forceRGBA && !this.smask && !this.mask) {
  47085. imgData.kind = ImageKind.RGB_24BPP;
  47086. imgData.data = new Uint8Array(drawWidth * drawHeight * 3);
  47087. alpha01 = 0;
  47088. maybeUndoPreblend = false;
  47089. } else {
  47090. imgData.kind = ImageKind.RGBA_32BPP;
  47091. imgData.data = new Uint8Array(drawWidth * drawHeight * 4);
  47092. alpha01 = 1;
  47093. maybeUndoPreblend = true;
  47094. this.fillOpacity(imgData.data, drawWidth, drawHeight, actualHeight, comps);
  47095. }
  47096. if (this.needsDecode) {
  47097. this.decodeBuffer(comps);
  47098. }
  47099. this.colorSpace.fillRgb(imgData.data, originalWidth, originalHeight, drawWidth, drawHeight, actualHeight, bpc, comps, alpha01);
  47100. if (maybeUndoPreblend) {
  47101. this.undoPreblend(imgData.data, drawWidth, actualHeight);
  47102. }
  47103. return imgData;
  47104. },
  47105. fillGrayBuffer: function PDFImage_fillGrayBuffer(buffer) {
  47106. var numComps = this.numComps;
  47107. if (numComps !== 1) {
  47108. error('Reading gray scale from a color image: ' + numComps);
  47109. }
  47110. var width = this.width;
  47111. var height = this.height;
  47112. var bpc = this.bpc;
  47113. var rowBytes = width * numComps * bpc + 7 >> 3;
  47114. var imgArray = this.getImageBytes(height * rowBytes);
  47115. var comps = this.getComponents(imgArray);
  47116. var i, length;
  47117. if (bpc === 1) {
  47118. length = width * height;
  47119. if (this.needsDecode) {
  47120. for (i = 0; i < length; ++i) {
  47121. buffer[i] = comps[i] - 1 & 255;
  47122. }
  47123. } else {
  47124. for (i = 0; i < length; ++i) {
  47125. buffer[i] = -comps[i] & 255;
  47126. }
  47127. }
  47128. return;
  47129. }
  47130. if (this.needsDecode) {
  47131. this.decodeBuffer(comps);
  47132. }
  47133. length = width * height;
  47134. var scale = 255 / ((1 << bpc) - 1);
  47135. for (i = 0; i < length; ++i) {
  47136. buffer[i] = scale * comps[i] | 0;
  47137. }
  47138. },
  47139. getImageBytes: function PDFImage_getImageBytes(length, drawWidth, drawHeight, forceRGB) {
  47140. this.image.reset();
  47141. this.image.drawWidth = drawWidth || this.width;
  47142. this.image.drawHeight = drawHeight || this.height;
  47143. this.image.forceRGB = !!forceRGB;
  47144. return this.image.getBytes(length);
  47145. }
  47146. };
  47147. return PDFImage;
  47148. }();
  47149. exports.PDFImage = PDFImage;
  47150. /***/ }),
  47151. /* 36 */
  47152. /***/ (function(module, exports, __w_pdfjs_require__) {
  47153. "use strict";
  47154. var sharedUtil = __w_pdfjs_require__(0);
  47155. var coreArithmeticDecoder = __w_pdfjs_require__(13);
  47156. var error = sharedUtil.error;
  47157. var log2 = sharedUtil.log2;
  47158. var readInt8 = sharedUtil.readInt8;
  47159. var readUint16 = sharedUtil.readUint16;
  47160. var readUint32 = sharedUtil.readUint32;
  47161. var shadow = sharedUtil.shadow;
  47162. var ArithmeticDecoder = coreArithmeticDecoder.ArithmeticDecoder;
  47163. var Jbig2Image = function Jbig2ImageClosure() {
  47164. function ContextCache() {
  47165. }
  47166. ContextCache.prototype = {
  47167. getContexts: function (id) {
  47168. if (id in this) {
  47169. return this[id];
  47170. }
  47171. return this[id] = new Int8Array(1 << 16);
  47172. }
  47173. };
  47174. function DecodingContext(data, start, end) {
  47175. this.data = data;
  47176. this.start = start;
  47177. this.end = end;
  47178. }
  47179. DecodingContext.prototype = {
  47180. get decoder() {
  47181. var decoder = new ArithmeticDecoder(this.data, this.start, this.end);
  47182. return shadow(this, 'decoder', decoder);
  47183. },
  47184. get contextCache() {
  47185. var cache = new ContextCache();
  47186. return shadow(this, 'contextCache', cache);
  47187. }
  47188. };
  47189. function decodeInteger(contextCache, procedure, decoder) {
  47190. var contexts = contextCache.getContexts(procedure);
  47191. var prev = 1;
  47192. function readBits(length) {
  47193. var v = 0;
  47194. for (var i = 0; i < length; i++) {
  47195. var bit = decoder.readBit(contexts, prev);
  47196. prev = prev < 256 ? prev << 1 | bit : (prev << 1 | bit) & 511 | 256;
  47197. v = v << 1 | bit;
  47198. }
  47199. return v >>> 0;
  47200. }
  47201. var sign = readBits(1);
  47202. 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);
  47203. return sign === 0 ? value : value > 0 ? -value : null;
  47204. }
  47205. function decodeIAID(contextCache, decoder, codeLength) {
  47206. var contexts = contextCache.getContexts('IAID');
  47207. var prev = 1;
  47208. for (var i = 0; i < codeLength; i++) {
  47209. var bit = decoder.readBit(contexts, prev);
  47210. prev = prev << 1 | bit;
  47211. }
  47212. if (codeLength < 31) {
  47213. return prev & (1 << codeLength) - 1;
  47214. }
  47215. return prev & 0x7FFFFFFF;
  47216. }
  47217. var SegmentTypes = [
  47218. 'SymbolDictionary',
  47219. null,
  47220. null,
  47221. null,
  47222. 'IntermediateTextRegion',
  47223. null,
  47224. 'ImmediateTextRegion',
  47225. 'ImmediateLosslessTextRegion',
  47226. null,
  47227. null,
  47228. null,
  47229. null,
  47230. null,
  47231. null,
  47232. null,
  47233. null,
  47234. 'patternDictionary',
  47235. null,
  47236. null,
  47237. null,
  47238. 'IntermediateHalftoneRegion',
  47239. null,
  47240. 'ImmediateHalftoneRegion',
  47241. 'ImmediateLosslessHalftoneRegion',
  47242. null,
  47243. null,
  47244. null,
  47245. null,
  47246. null,
  47247. null,
  47248. null,
  47249. null,
  47250. null,
  47251. null,
  47252. null,
  47253. null,
  47254. 'IntermediateGenericRegion',
  47255. null,
  47256. 'ImmediateGenericRegion',
  47257. 'ImmediateLosslessGenericRegion',
  47258. 'IntermediateGenericRefinementRegion',
  47259. null,
  47260. 'ImmediateGenericRefinementRegion',
  47261. 'ImmediateLosslessGenericRefinementRegion',
  47262. null,
  47263. null,
  47264. null,
  47265. null,
  47266. 'PageInformation',
  47267. 'EndOfPage',
  47268. 'EndOfStripe',
  47269. 'EndOfFile',
  47270. 'Profiles',
  47271. 'Tables',
  47272. null,
  47273. null,
  47274. null,
  47275. null,
  47276. null,
  47277. null,
  47278. null,
  47279. null,
  47280. 'Extension'
  47281. ];
  47282. var CodingTemplates = [
  47283. [
  47284. {
  47285. x: -1,
  47286. y: -2
  47287. },
  47288. {
  47289. x: 0,
  47290. y: -2
  47291. },
  47292. {
  47293. x: 1,
  47294. y: -2
  47295. },
  47296. {
  47297. x: -2,
  47298. y: -1
  47299. },
  47300. {
  47301. x: -1,
  47302. y: -1
  47303. },
  47304. {
  47305. x: 0,
  47306. y: -1
  47307. },
  47308. {
  47309. x: 1,
  47310. y: -1
  47311. },
  47312. {
  47313. x: 2,
  47314. y: -1
  47315. },
  47316. {
  47317. x: -4,
  47318. y: 0
  47319. },
  47320. {
  47321. x: -3,
  47322. y: 0
  47323. },
  47324. {
  47325. x: -2,
  47326. y: 0
  47327. },
  47328. {
  47329. x: -1,
  47330. y: 0
  47331. }
  47332. ],
  47333. [
  47334. {
  47335. x: -1,
  47336. y: -2
  47337. },
  47338. {
  47339. x: 0,
  47340. y: -2
  47341. },
  47342. {
  47343. x: 1,
  47344. y: -2
  47345. },
  47346. {
  47347. x: 2,
  47348. y: -2
  47349. },
  47350. {
  47351. x: -2,
  47352. y: -1
  47353. },
  47354. {
  47355. x: -1,
  47356. y: -1
  47357. },
  47358. {
  47359. x: 0,
  47360. y: -1
  47361. },
  47362. {
  47363. x: 1,
  47364. y: -1
  47365. },
  47366. {
  47367. x: 2,
  47368. y: -1
  47369. },
  47370. {
  47371. x: -3,
  47372. y: 0
  47373. },
  47374. {
  47375. x: -2,
  47376. y: 0
  47377. },
  47378. {
  47379. x: -1,
  47380. y: 0
  47381. }
  47382. ],
  47383. [
  47384. {
  47385. x: -1,
  47386. y: -2
  47387. },
  47388. {
  47389. x: 0,
  47390. y: -2
  47391. },
  47392. {
  47393. x: 1,
  47394. y: -2
  47395. },
  47396. {
  47397. x: -2,
  47398. y: -1
  47399. },
  47400. {
  47401. x: -1,
  47402. y: -1
  47403. },
  47404. {
  47405. x: 0,
  47406. y: -1
  47407. },
  47408. {
  47409. x: 1,
  47410. y: -1
  47411. },
  47412. {
  47413. x: -2,
  47414. y: 0
  47415. },
  47416. {
  47417. x: -1,
  47418. y: 0
  47419. }
  47420. ],
  47421. [
  47422. {
  47423. x: -3,
  47424. y: -1
  47425. },
  47426. {
  47427. x: -2,
  47428. y: -1
  47429. },
  47430. {
  47431. x: -1,
  47432. y: -1
  47433. },
  47434. {
  47435. x: 0,
  47436. y: -1
  47437. },
  47438. {
  47439. x: 1,
  47440. y: -1
  47441. },
  47442. {
  47443. x: -4,
  47444. y: 0
  47445. },
  47446. {
  47447. x: -3,
  47448. y: 0
  47449. },
  47450. {
  47451. x: -2,
  47452. y: 0
  47453. },
  47454. {
  47455. x: -1,
  47456. y: 0
  47457. }
  47458. ]
  47459. ];
  47460. var RefinementTemplates = [
  47461. {
  47462. coding: [
  47463. {
  47464. x: 0,
  47465. y: -1
  47466. },
  47467. {
  47468. x: 1,
  47469. y: -1
  47470. },
  47471. {
  47472. x: -1,
  47473. y: 0
  47474. }
  47475. ],
  47476. reference: [
  47477. {
  47478. x: 0,
  47479. y: -1
  47480. },
  47481. {
  47482. x: 1,
  47483. y: -1
  47484. },
  47485. {
  47486. x: -1,
  47487. y: 0
  47488. },
  47489. {
  47490. x: 0,
  47491. y: 0
  47492. },
  47493. {
  47494. x: 1,
  47495. y: 0
  47496. },
  47497. {
  47498. x: -1,
  47499. y: 1
  47500. },
  47501. {
  47502. x: 0,
  47503. y: 1
  47504. },
  47505. {
  47506. x: 1,
  47507. y: 1
  47508. }
  47509. ]
  47510. },
  47511. {
  47512. coding: [
  47513. {
  47514. x: -1,
  47515. y: -1
  47516. },
  47517. {
  47518. x: 0,
  47519. y: -1
  47520. },
  47521. {
  47522. x: 1,
  47523. y: -1
  47524. },
  47525. {
  47526. x: -1,
  47527. y: 0
  47528. }
  47529. ],
  47530. reference: [
  47531. {
  47532. x: 0,
  47533. y: -1
  47534. },
  47535. {
  47536. x: -1,
  47537. y: 0
  47538. },
  47539. {
  47540. x: 0,
  47541. y: 0
  47542. },
  47543. {
  47544. x: 1,
  47545. y: 0
  47546. },
  47547. {
  47548. x: 0,
  47549. y: 1
  47550. },
  47551. {
  47552. x: 1,
  47553. y: 1
  47554. }
  47555. ]
  47556. }
  47557. ];
  47558. var ReusedContexts = [
  47559. 0x9B25,
  47560. 0x0795,
  47561. 0x00E5,
  47562. 0x0195
  47563. ];
  47564. var RefinementReusedContexts = [
  47565. 0x0020,
  47566. 0x0008
  47567. ];
  47568. function decodeBitmapTemplate0(width, height, decodingContext) {
  47569. var decoder = decodingContext.decoder;
  47570. var contexts = decodingContext.contextCache.getContexts('GB');
  47571. var contextLabel, i, j, pixel, row, row1, row2, bitmap = [];
  47572. var OLD_PIXEL_MASK = 0x7BF7;
  47573. for (i = 0; i < height; i++) {
  47574. row = bitmap[i] = new Uint8Array(width);
  47575. row1 = i < 1 ? row : bitmap[i - 1];
  47576. row2 = i < 2 ? row : bitmap[i - 2];
  47577. contextLabel = row2[0] << 13 | row2[1] << 12 | row2[2] << 11 | row1[0] << 7 | row1[1] << 6 | row1[2] << 5 | row1[3] << 4;
  47578. for (j = 0; j < width; j++) {
  47579. row[j] = pixel = decoder.readBit(contexts, contextLabel);
  47580. contextLabel = (contextLabel & OLD_PIXEL_MASK) << 1 | (j + 3 < width ? row2[j + 3] << 11 : 0) | (j + 4 < width ? row1[j + 4] << 4 : 0) | pixel;
  47581. }
  47582. }
  47583. return bitmap;
  47584. }
  47585. function decodeBitmap(mmr, width, height, templateIndex, prediction, skip, at, decodingContext) {
  47586. if (mmr) {
  47587. error('JBIG2 error: MMR encoding is not supported');
  47588. }
  47589. 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) {
  47590. return decodeBitmapTemplate0(width, height, decodingContext);
  47591. }
  47592. var useskip = !!skip;
  47593. var template = CodingTemplates[templateIndex].concat(at);
  47594. template.sort(function (a, b) {
  47595. return a.y - b.y || a.x - b.x;
  47596. });
  47597. var templateLength = template.length;
  47598. var templateX = new Int8Array(templateLength);
  47599. var templateY = new Int8Array(templateLength);
  47600. var changingTemplateEntries = [];
  47601. var reuseMask = 0, minX = 0, maxX = 0, minY = 0;
  47602. var c, k;
  47603. for (k = 0; k < templateLength; k++) {
  47604. templateX[k] = template[k].x;
  47605. templateY[k] = template[k].y;
  47606. minX = Math.min(minX, template[k].x);
  47607. maxX = Math.max(maxX, template[k].x);
  47608. minY = Math.min(minY, template[k].y);
  47609. if (k < templateLength - 1 && template[k].y === template[k + 1].y && template[k].x === template[k + 1].x - 1) {
  47610. reuseMask |= 1 << templateLength - 1 - k;
  47611. } else {
  47612. changingTemplateEntries.push(k);
  47613. }
  47614. }
  47615. var changingEntriesLength = changingTemplateEntries.length;
  47616. var changingTemplateX = new Int8Array(changingEntriesLength);
  47617. var changingTemplateY = new Int8Array(changingEntriesLength);
  47618. var changingTemplateBit = new Uint16Array(changingEntriesLength);
  47619. for (c = 0; c < changingEntriesLength; c++) {
  47620. k = changingTemplateEntries[c];
  47621. changingTemplateX[c] = template[k].x;
  47622. changingTemplateY[c] = template[k].y;
  47623. changingTemplateBit[c] = 1 << templateLength - 1 - k;
  47624. }
  47625. var sbb_left = -minX;
  47626. var sbb_top = -minY;
  47627. var sbb_right = width - maxX;
  47628. var pseudoPixelContext = ReusedContexts[templateIndex];
  47629. var row = new Uint8Array(width);
  47630. var bitmap = [];
  47631. var decoder = decodingContext.decoder;
  47632. var contexts = decodingContext.contextCache.getContexts('GB');
  47633. var ltp = 0, j, i0, j0, contextLabel = 0, bit, shift;
  47634. for (var i = 0; i < height; i++) {
  47635. if (prediction) {
  47636. var sltp = decoder.readBit(contexts, pseudoPixelContext);
  47637. ltp ^= sltp;
  47638. if (ltp) {
  47639. bitmap.push(row);
  47640. continue;
  47641. }
  47642. }
  47643. row = new Uint8Array(row);
  47644. bitmap.push(row);
  47645. for (j = 0; j < width; j++) {
  47646. if (useskip && skip[i][j]) {
  47647. row[j] = 0;
  47648. continue;
  47649. }
  47650. if (j >= sbb_left && j < sbb_right && i >= sbb_top) {
  47651. contextLabel = contextLabel << 1 & reuseMask;
  47652. for (k = 0; k < changingEntriesLength; k++) {
  47653. i0 = i + changingTemplateY[k];
  47654. j0 = j + changingTemplateX[k];
  47655. bit = bitmap[i0][j0];
  47656. if (bit) {
  47657. bit = changingTemplateBit[k];
  47658. contextLabel |= bit;
  47659. }
  47660. }
  47661. } else {
  47662. contextLabel = 0;
  47663. shift = templateLength - 1;
  47664. for (k = 0; k < templateLength; k++, shift--) {
  47665. j0 = j + templateX[k];
  47666. if (j0 >= 0 && j0 < width) {
  47667. i0 = i + templateY[k];
  47668. if (i0 >= 0) {
  47669. bit = bitmap[i0][j0];
  47670. if (bit) {
  47671. contextLabel |= bit << shift;
  47672. }
  47673. }
  47674. }
  47675. }
  47676. }
  47677. var pixel = decoder.readBit(contexts, contextLabel);
  47678. row[j] = pixel;
  47679. }
  47680. }
  47681. return bitmap;
  47682. }
  47683. function decodeRefinement(width, height, templateIndex, referenceBitmap, offsetX, offsetY, prediction, at, decodingContext) {
  47684. var codingTemplate = RefinementTemplates[templateIndex].coding;
  47685. if (templateIndex === 0) {
  47686. codingTemplate = codingTemplate.concat([at[0]]);
  47687. }
  47688. var codingTemplateLength = codingTemplate.length;
  47689. var codingTemplateX = new Int32Array(codingTemplateLength);
  47690. var codingTemplateY = new Int32Array(codingTemplateLength);
  47691. var k;
  47692. for (k = 0; k < codingTemplateLength; k++) {
  47693. codingTemplateX[k] = codingTemplate[k].x;
  47694. codingTemplateY[k] = codingTemplate[k].y;
  47695. }
  47696. var referenceTemplate = RefinementTemplates[templateIndex].reference;
  47697. if (templateIndex === 0) {
  47698. referenceTemplate = referenceTemplate.concat([at[1]]);
  47699. }
  47700. var referenceTemplateLength = referenceTemplate.length;
  47701. var referenceTemplateX = new Int32Array(referenceTemplateLength);
  47702. var referenceTemplateY = new Int32Array(referenceTemplateLength);
  47703. for (k = 0; k < referenceTemplateLength; k++) {
  47704. referenceTemplateX[k] = referenceTemplate[k].x;
  47705. referenceTemplateY[k] = referenceTemplate[k].y;
  47706. }
  47707. var referenceWidth = referenceBitmap[0].length;
  47708. var referenceHeight = referenceBitmap.length;
  47709. var pseudoPixelContext = RefinementReusedContexts[templateIndex];
  47710. var bitmap = [];
  47711. var decoder = decodingContext.decoder;
  47712. var contexts = decodingContext.contextCache.getContexts('GR');
  47713. var ltp = 0;
  47714. for (var i = 0; i < height; i++) {
  47715. if (prediction) {
  47716. var sltp = decoder.readBit(contexts, pseudoPixelContext);
  47717. ltp ^= sltp;
  47718. if (ltp) {
  47719. error('JBIG2 error: prediction is not supported');
  47720. }
  47721. }
  47722. var row = new Uint8Array(width);
  47723. bitmap.push(row);
  47724. for (var j = 0; j < width; j++) {
  47725. var i0, j0;
  47726. var contextLabel = 0;
  47727. for (k = 0; k < codingTemplateLength; k++) {
  47728. i0 = i + codingTemplateY[k];
  47729. j0 = j + codingTemplateX[k];
  47730. if (i0 < 0 || j0 < 0 || j0 >= width) {
  47731. contextLabel <<= 1;
  47732. } else {
  47733. contextLabel = contextLabel << 1 | bitmap[i0][j0];
  47734. }
  47735. }
  47736. for (k = 0; k < referenceTemplateLength; k++) {
  47737. i0 = i + referenceTemplateY[k] + offsetY;
  47738. j0 = j + referenceTemplateX[k] + offsetX;
  47739. if (i0 < 0 || i0 >= referenceHeight || j0 < 0 || j0 >= referenceWidth) {
  47740. contextLabel <<= 1;
  47741. } else {
  47742. contextLabel = contextLabel << 1 | referenceBitmap[i0][j0];
  47743. }
  47744. }
  47745. var pixel = decoder.readBit(contexts, contextLabel);
  47746. row[j] = pixel;
  47747. }
  47748. }
  47749. return bitmap;
  47750. }
  47751. function decodeSymbolDictionary(huffman, refinement, symbols, numberOfNewSymbols, numberOfExportedSymbols, huffmanTables, templateIndex, at, refinementTemplateIndex, refinementAt, decodingContext) {
  47752. if (huffman) {
  47753. error('JBIG2 error: huffman is not supported');
  47754. }
  47755. var newSymbols = [];
  47756. var currentHeight = 0;
  47757. var symbolCodeLength = log2(symbols.length + numberOfNewSymbols);
  47758. var decoder = decodingContext.decoder;
  47759. var contextCache = decodingContext.contextCache;
  47760. while (newSymbols.length < numberOfNewSymbols) {
  47761. var deltaHeight = decodeInteger(contextCache, 'IADH', decoder);
  47762. currentHeight += deltaHeight;
  47763. var currentWidth = 0;
  47764. while (true) {
  47765. var deltaWidth = decodeInteger(contextCache, 'IADW', decoder);
  47766. if (deltaWidth === null) {
  47767. break;
  47768. }
  47769. currentWidth += deltaWidth;
  47770. var bitmap;
  47771. if (refinement) {
  47772. var numberOfInstances = decodeInteger(contextCache, 'IAAI', decoder);
  47773. if (numberOfInstances > 1) {
  47774. bitmap = decodeTextRegion(huffman, refinement, currentWidth, currentHeight, 0, numberOfInstances, 1, symbols.concat(newSymbols), symbolCodeLength, 0, 0, 1, 0, huffmanTables, refinementTemplateIndex, refinementAt, decodingContext);
  47775. } else {
  47776. var symbolId = decodeIAID(contextCache, decoder, symbolCodeLength);
  47777. var rdx = decodeInteger(contextCache, 'IARDX', decoder);
  47778. var rdy = decodeInteger(contextCache, 'IARDY', decoder);
  47779. var symbol = symbolId < symbols.length ? symbols[symbolId] : newSymbols[symbolId - symbols.length];
  47780. bitmap = decodeRefinement(currentWidth, currentHeight, refinementTemplateIndex, symbol, rdx, rdy, false, refinementAt, decodingContext);
  47781. }
  47782. } else {
  47783. bitmap = decodeBitmap(false, currentWidth, currentHeight, templateIndex, false, null, at, decodingContext);
  47784. }
  47785. newSymbols.push(bitmap);
  47786. }
  47787. }
  47788. var exportedSymbols = [];
  47789. var flags = [], currentFlag = false;
  47790. var totalSymbolsLength = symbols.length + numberOfNewSymbols;
  47791. while (flags.length < totalSymbolsLength) {
  47792. var runLength = decodeInteger(contextCache, 'IAEX', decoder);
  47793. while (runLength--) {
  47794. flags.push(currentFlag);
  47795. }
  47796. currentFlag = !currentFlag;
  47797. }
  47798. for (var i = 0, ii = symbols.length; i < ii; i++) {
  47799. if (flags[i]) {
  47800. exportedSymbols.push(symbols[i]);
  47801. }
  47802. }
  47803. for (var j = 0; j < numberOfNewSymbols; i++, j++) {
  47804. if (flags[i]) {
  47805. exportedSymbols.push(newSymbols[j]);
  47806. }
  47807. }
  47808. return exportedSymbols;
  47809. }
  47810. function decodeTextRegion(huffman, refinement, width, height, defaultPixelValue, numberOfSymbolInstances, stripSize, inputSymbols, symbolCodeLength, transposed, dsOffset, referenceCorner, combinationOperator, huffmanTables, refinementTemplateIndex, refinementAt, decodingContext) {
  47811. if (huffman) {
  47812. error('JBIG2 error: huffman is not supported');
  47813. }
  47814. var bitmap = [];
  47815. var i, row;
  47816. for (i = 0; i < height; i++) {
  47817. row = new Uint8Array(width);
  47818. if (defaultPixelValue) {
  47819. for (var j = 0; j < width; j++) {
  47820. row[j] = defaultPixelValue;
  47821. }
  47822. }
  47823. bitmap.push(row);
  47824. }
  47825. var decoder = decodingContext.decoder;
  47826. var contextCache = decodingContext.contextCache;
  47827. var stripT = -decodeInteger(contextCache, 'IADT', decoder);
  47828. var firstS = 0;
  47829. i = 0;
  47830. while (i < numberOfSymbolInstances) {
  47831. var deltaT = decodeInteger(contextCache, 'IADT', decoder);
  47832. stripT += deltaT;
  47833. var deltaFirstS = decodeInteger(contextCache, 'IAFS', decoder);
  47834. firstS += deltaFirstS;
  47835. var currentS = firstS;
  47836. do {
  47837. var currentT = stripSize === 1 ? 0 : decodeInteger(contextCache, 'IAIT', decoder);
  47838. var t = stripSize * stripT + currentT;
  47839. var symbolId = decodeIAID(contextCache, decoder, symbolCodeLength);
  47840. var applyRefinement = refinement && decodeInteger(contextCache, 'IARI', decoder);
  47841. var symbolBitmap = inputSymbols[symbolId];
  47842. var symbolWidth = symbolBitmap[0].length;
  47843. var symbolHeight = symbolBitmap.length;
  47844. if (applyRefinement) {
  47845. var rdw = decodeInteger(contextCache, 'IARDW', decoder);
  47846. var rdh = decodeInteger(contextCache, 'IARDH', decoder);
  47847. var rdx = decodeInteger(contextCache, 'IARDX', decoder);
  47848. var rdy = decodeInteger(contextCache, 'IARDY', decoder);
  47849. symbolWidth += rdw;
  47850. symbolHeight += rdh;
  47851. symbolBitmap = decodeRefinement(symbolWidth, symbolHeight, refinementTemplateIndex, symbolBitmap, (rdw >> 1) + rdx, (rdh >> 1) + rdy, false, refinementAt, decodingContext);
  47852. }
  47853. var offsetT = t - (referenceCorner & 1 ? 0 : symbolHeight);
  47854. var offsetS = currentS - (referenceCorner & 2 ? symbolWidth : 0);
  47855. var s2, t2, symbolRow;
  47856. if (transposed) {
  47857. for (s2 = 0; s2 < symbolHeight; s2++) {
  47858. row = bitmap[offsetS + s2];
  47859. if (!row) {
  47860. continue;
  47861. }
  47862. symbolRow = symbolBitmap[s2];
  47863. var maxWidth = Math.min(width - offsetT, symbolWidth);
  47864. switch (combinationOperator) {
  47865. case 0:
  47866. for (t2 = 0; t2 < maxWidth; t2++) {
  47867. row[offsetT + t2] |= symbolRow[t2];
  47868. }
  47869. break;
  47870. case 2:
  47871. for (t2 = 0; t2 < maxWidth; t2++) {
  47872. row[offsetT + t2] ^= symbolRow[t2];
  47873. }
  47874. break;
  47875. default:
  47876. error('JBIG2 error: operator ' + combinationOperator + ' is not supported');
  47877. }
  47878. }
  47879. currentS += symbolHeight - 1;
  47880. } else {
  47881. for (t2 = 0; t2 < symbolHeight; t2++) {
  47882. row = bitmap[offsetT + t2];
  47883. if (!row) {
  47884. continue;
  47885. }
  47886. symbolRow = symbolBitmap[t2];
  47887. switch (combinationOperator) {
  47888. case 0:
  47889. for (s2 = 0; s2 < symbolWidth; s2++) {
  47890. row[offsetS + s2] |= symbolRow[s2];
  47891. }
  47892. break;
  47893. case 2:
  47894. for (s2 = 0; s2 < symbolWidth; s2++) {
  47895. row[offsetS + s2] ^= symbolRow[s2];
  47896. }
  47897. break;
  47898. default:
  47899. error('JBIG2 error: operator ' + combinationOperator + ' is not supported');
  47900. }
  47901. }
  47902. currentS += symbolWidth - 1;
  47903. }
  47904. i++;
  47905. var deltaS = decodeInteger(contextCache, 'IADS', decoder);
  47906. if (deltaS === null) {
  47907. break;
  47908. }
  47909. currentS += deltaS + dsOffset;
  47910. } while (true);
  47911. }
  47912. return bitmap;
  47913. }
  47914. function readSegmentHeader(data, start) {
  47915. var segmentHeader = {};
  47916. segmentHeader.number = readUint32(data, start);
  47917. var flags = data[start + 4];
  47918. var segmentType = flags & 0x3F;
  47919. if (!SegmentTypes[segmentType]) {
  47920. error('JBIG2 error: invalid segment type: ' + segmentType);
  47921. }
  47922. segmentHeader.type = segmentType;
  47923. segmentHeader.typeName = SegmentTypes[segmentType];
  47924. segmentHeader.deferredNonRetain = !!(flags & 0x80);
  47925. var pageAssociationFieldSize = !!(flags & 0x40);
  47926. var referredFlags = data[start + 5];
  47927. var referredToCount = referredFlags >> 5 & 7;
  47928. var retainBits = [referredFlags & 31];
  47929. var position = start + 6;
  47930. if (referredFlags === 7) {
  47931. referredToCount = readUint32(data, position - 1) & 0x1FFFFFFF;
  47932. position += 3;
  47933. var bytes = referredToCount + 7 >> 3;
  47934. retainBits[0] = data[position++];
  47935. while (--bytes > 0) {
  47936. retainBits.push(data[position++]);
  47937. }
  47938. } else if (referredFlags === 5 || referredFlags === 6) {
  47939. error('JBIG2 error: invalid referred-to flags');
  47940. }
  47941. segmentHeader.retainBits = retainBits;
  47942. var referredToSegmentNumberSize = segmentHeader.number <= 256 ? 1 : segmentHeader.number <= 65536 ? 2 : 4;
  47943. var referredTo = [];
  47944. var i, ii;
  47945. for (i = 0; i < referredToCount; i++) {
  47946. var number = referredToSegmentNumberSize === 1 ? data[position] : referredToSegmentNumberSize === 2 ? readUint16(data, position) : readUint32(data, position);
  47947. referredTo.push(number);
  47948. position += referredToSegmentNumberSize;
  47949. }
  47950. segmentHeader.referredTo = referredTo;
  47951. if (!pageAssociationFieldSize) {
  47952. segmentHeader.pageAssociation = data[position++];
  47953. } else {
  47954. segmentHeader.pageAssociation = readUint32(data, position);
  47955. position += 4;
  47956. }
  47957. segmentHeader.length = readUint32(data, position);
  47958. position += 4;
  47959. if (segmentHeader.length === 0xFFFFFFFF) {
  47960. if (segmentType === 38) {
  47961. var genericRegionInfo = readRegionSegmentInformation(data, position);
  47962. var genericRegionSegmentFlags = data[position + RegionSegmentInformationFieldLength];
  47963. var genericRegionMmr = !!(genericRegionSegmentFlags & 1);
  47964. var searchPatternLength = 6;
  47965. var searchPattern = new Uint8Array(searchPatternLength);
  47966. if (!genericRegionMmr) {
  47967. searchPattern[0] = 0xFF;
  47968. searchPattern[1] = 0xAC;
  47969. }
  47970. searchPattern[2] = genericRegionInfo.height >>> 24 & 0xFF;
  47971. searchPattern[3] = genericRegionInfo.height >> 16 & 0xFF;
  47972. searchPattern[4] = genericRegionInfo.height >> 8 & 0xFF;
  47973. searchPattern[5] = genericRegionInfo.height & 0xFF;
  47974. for (i = position, ii = data.length; i < ii; i++) {
  47975. var j = 0;
  47976. while (j < searchPatternLength && searchPattern[j] === data[i + j]) {
  47977. j++;
  47978. }
  47979. if (j === searchPatternLength) {
  47980. segmentHeader.length = i + searchPatternLength;
  47981. break;
  47982. }
  47983. }
  47984. if (segmentHeader.length === 0xFFFFFFFF) {
  47985. error('JBIG2 error: segment end was not found');
  47986. }
  47987. } else {
  47988. error('JBIG2 error: invalid unknown segment length');
  47989. }
  47990. }
  47991. segmentHeader.headerEnd = position;
  47992. return segmentHeader;
  47993. }
  47994. function readSegments(header, data, start, end) {
  47995. var segments = [];
  47996. var position = start;
  47997. while (position < end) {
  47998. var segmentHeader = readSegmentHeader(data, position);
  47999. position = segmentHeader.headerEnd;
  48000. var segment = {
  48001. header: segmentHeader,
  48002. data: data
  48003. };
  48004. if (!header.randomAccess) {
  48005. segment.start = position;
  48006. position += segmentHeader.length;
  48007. segment.end = position;
  48008. }
  48009. segments.push(segment);
  48010. if (segmentHeader.type === 51) {
  48011. break;
  48012. }
  48013. }
  48014. if (header.randomAccess) {
  48015. for (var i = 0, ii = segments.length; i < ii; i++) {
  48016. segments[i].start = position;
  48017. position += segments[i].header.length;
  48018. segments[i].end = position;
  48019. }
  48020. }
  48021. return segments;
  48022. }
  48023. function readRegionSegmentInformation(data, start) {
  48024. return {
  48025. width: readUint32(data, start),
  48026. height: readUint32(data, start + 4),
  48027. x: readUint32(data, start + 8),
  48028. y: readUint32(data, start + 12),
  48029. combinationOperator: data[start + 16] & 7
  48030. };
  48031. }
  48032. var RegionSegmentInformationFieldLength = 17;
  48033. function processSegment(segment, visitor) {
  48034. var header = segment.header;
  48035. var data = segment.data, position = segment.start, end = segment.end;
  48036. var args, at, i, atLength;
  48037. switch (header.type) {
  48038. case 0:
  48039. var dictionary = {};
  48040. var dictionaryFlags = readUint16(data, position);
  48041. dictionary.huffman = !!(dictionaryFlags & 1);
  48042. dictionary.refinement = !!(dictionaryFlags & 2);
  48043. dictionary.huffmanDHSelector = dictionaryFlags >> 2 & 3;
  48044. dictionary.huffmanDWSelector = dictionaryFlags >> 4 & 3;
  48045. dictionary.bitmapSizeSelector = dictionaryFlags >> 6 & 1;
  48046. dictionary.aggregationInstancesSelector = dictionaryFlags >> 7 & 1;
  48047. dictionary.bitmapCodingContextUsed = !!(dictionaryFlags & 256);
  48048. dictionary.bitmapCodingContextRetained = !!(dictionaryFlags & 512);
  48049. dictionary.template = dictionaryFlags >> 10 & 3;
  48050. dictionary.refinementTemplate = dictionaryFlags >> 12 & 1;
  48051. position += 2;
  48052. if (!dictionary.huffman) {
  48053. atLength = dictionary.template === 0 ? 4 : 1;
  48054. at = [];
  48055. for (i = 0; i < atLength; i++) {
  48056. at.push({
  48057. x: readInt8(data, position),
  48058. y: readInt8(data, position + 1)
  48059. });
  48060. position += 2;
  48061. }
  48062. dictionary.at = at;
  48063. }
  48064. if (dictionary.refinement && !dictionary.refinementTemplate) {
  48065. at = [];
  48066. for (i = 0; i < 2; i++) {
  48067. at.push({
  48068. x: readInt8(data, position),
  48069. y: readInt8(data, position + 1)
  48070. });
  48071. position += 2;
  48072. }
  48073. dictionary.refinementAt = at;
  48074. }
  48075. dictionary.numberOfExportedSymbols = readUint32(data, position);
  48076. position += 4;
  48077. dictionary.numberOfNewSymbols = readUint32(data, position);
  48078. position += 4;
  48079. args = [
  48080. dictionary,
  48081. header.number,
  48082. header.referredTo,
  48083. data,
  48084. position,
  48085. end
  48086. ];
  48087. break;
  48088. case 6:
  48089. case 7:
  48090. var textRegion = {};
  48091. textRegion.info = readRegionSegmentInformation(data, position);
  48092. position += RegionSegmentInformationFieldLength;
  48093. var textRegionSegmentFlags = readUint16(data, position);
  48094. position += 2;
  48095. textRegion.huffman = !!(textRegionSegmentFlags & 1);
  48096. textRegion.refinement = !!(textRegionSegmentFlags & 2);
  48097. textRegion.stripSize = 1 << (textRegionSegmentFlags >> 2 & 3);
  48098. textRegion.referenceCorner = textRegionSegmentFlags >> 4 & 3;
  48099. textRegion.transposed = !!(textRegionSegmentFlags & 64);
  48100. textRegion.combinationOperator = textRegionSegmentFlags >> 7 & 3;
  48101. textRegion.defaultPixelValue = textRegionSegmentFlags >> 9 & 1;
  48102. textRegion.dsOffset = textRegionSegmentFlags << 17 >> 27;
  48103. textRegion.refinementTemplate = textRegionSegmentFlags >> 15 & 1;
  48104. if (textRegion.huffman) {
  48105. var textRegionHuffmanFlags = readUint16(data, position);
  48106. position += 2;
  48107. textRegion.huffmanFS = textRegionHuffmanFlags & 3;
  48108. textRegion.huffmanDS = textRegionHuffmanFlags >> 2 & 3;
  48109. textRegion.huffmanDT = textRegionHuffmanFlags >> 4 & 3;
  48110. textRegion.huffmanRefinementDW = textRegionHuffmanFlags >> 6 & 3;
  48111. textRegion.huffmanRefinementDH = textRegionHuffmanFlags >> 8 & 3;
  48112. textRegion.huffmanRefinementDX = textRegionHuffmanFlags >> 10 & 3;
  48113. textRegion.huffmanRefinementDY = textRegionHuffmanFlags >> 12 & 3;
  48114. textRegion.huffmanRefinementSizeSelector = !!(textRegionHuffmanFlags & 14);
  48115. }
  48116. if (textRegion.refinement && !textRegion.refinementTemplate) {
  48117. at = [];
  48118. for (i = 0; i < 2; i++) {
  48119. at.push({
  48120. x: readInt8(data, position),
  48121. y: readInt8(data, position + 1)
  48122. });
  48123. position += 2;
  48124. }
  48125. textRegion.refinementAt = at;
  48126. }
  48127. textRegion.numberOfSymbolInstances = readUint32(data, position);
  48128. position += 4;
  48129. if (textRegion.huffman) {
  48130. error('JBIG2 error: huffman is not supported');
  48131. }
  48132. args = [
  48133. textRegion,
  48134. header.referredTo,
  48135. data,
  48136. position,
  48137. end
  48138. ];
  48139. break;
  48140. case 38:
  48141. case 39:
  48142. var genericRegion = {};
  48143. genericRegion.info = readRegionSegmentInformation(data, position);
  48144. position += RegionSegmentInformationFieldLength;
  48145. var genericRegionSegmentFlags = data[position++];
  48146. genericRegion.mmr = !!(genericRegionSegmentFlags & 1);
  48147. genericRegion.template = genericRegionSegmentFlags >> 1 & 3;
  48148. genericRegion.prediction = !!(genericRegionSegmentFlags & 8);
  48149. if (!genericRegion.mmr) {
  48150. atLength = genericRegion.template === 0 ? 4 : 1;
  48151. at = [];
  48152. for (i = 0; i < atLength; i++) {
  48153. at.push({
  48154. x: readInt8(data, position),
  48155. y: readInt8(data, position + 1)
  48156. });
  48157. position += 2;
  48158. }
  48159. genericRegion.at = at;
  48160. }
  48161. args = [
  48162. genericRegion,
  48163. data,
  48164. position,
  48165. end
  48166. ];
  48167. break;
  48168. case 48:
  48169. var pageInfo = {
  48170. width: readUint32(data, position),
  48171. height: readUint32(data, position + 4),
  48172. resolutionX: readUint32(data, position + 8),
  48173. resolutionY: readUint32(data, position + 12)
  48174. };
  48175. if (pageInfo.height === 0xFFFFFFFF) {
  48176. delete pageInfo.height;
  48177. }
  48178. var pageSegmentFlags = data[position + 16];
  48179. readUint16(data, position + 17);
  48180. pageInfo.lossless = !!(pageSegmentFlags & 1);
  48181. pageInfo.refinement = !!(pageSegmentFlags & 2);
  48182. pageInfo.defaultPixelValue = pageSegmentFlags >> 2 & 1;
  48183. pageInfo.combinationOperator = pageSegmentFlags >> 3 & 3;
  48184. pageInfo.requiresBuffer = !!(pageSegmentFlags & 32);
  48185. pageInfo.combinationOperatorOverride = !!(pageSegmentFlags & 64);
  48186. args = [pageInfo];
  48187. break;
  48188. case 49:
  48189. break;
  48190. case 50:
  48191. break;
  48192. case 51:
  48193. break;
  48194. case 62:
  48195. break;
  48196. default:
  48197. error('JBIG2 error: segment type ' + header.typeName + '(' + header.type + ') is not implemented');
  48198. }
  48199. var callbackName = 'on' + header.typeName;
  48200. if (callbackName in visitor) {
  48201. visitor[callbackName].apply(visitor, args);
  48202. }
  48203. }
  48204. function processSegments(segments, visitor) {
  48205. for (var i = 0, ii = segments.length; i < ii; i++) {
  48206. processSegment(segments[i], visitor);
  48207. }
  48208. }
  48209. function parseJbig2(data, start, end) {
  48210. var position = start;
  48211. 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) {
  48212. error('JBIG2 error: invalid header');
  48213. }
  48214. var header = {};
  48215. position += 8;
  48216. var flags = data[position++];
  48217. header.randomAccess = !(flags & 1);
  48218. if (!(flags & 2)) {
  48219. header.numberOfPages = readUint32(data, position);
  48220. position += 4;
  48221. }
  48222. readSegments(header, data, position, end);
  48223. error('Not implemented');
  48224. }
  48225. function parseJbig2Chunks(chunks) {
  48226. var visitor = new SimpleSegmentVisitor();
  48227. for (var i = 0, ii = chunks.length; i < ii; i++) {
  48228. var chunk = chunks[i];
  48229. var segments = readSegments({}, chunk.data, chunk.start, chunk.end);
  48230. processSegments(segments, visitor);
  48231. }
  48232. return visitor.buffer;
  48233. }
  48234. function SimpleSegmentVisitor() {
  48235. }
  48236. SimpleSegmentVisitor.prototype = {
  48237. onPageInformation: function SimpleSegmentVisitor_onPageInformation(info) {
  48238. this.currentPageInfo = info;
  48239. var rowSize = info.width + 7 >> 3;
  48240. var buffer = new Uint8Array(rowSize * info.height);
  48241. if (info.defaultPixelValue) {
  48242. for (var i = 0, ii = buffer.length; i < ii; i++) {
  48243. buffer[i] = 0xFF;
  48244. }
  48245. }
  48246. this.buffer = buffer;
  48247. },
  48248. drawBitmap: function SimpleSegmentVisitor_drawBitmap(regionInfo, bitmap) {
  48249. var pageInfo = this.currentPageInfo;
  48250. var width = regionInfo.width, height = regionInfo.height;
  48251. var rowSize = pageInfo.width + 7 >> 3;
  48252. var combinationOperator = pageInfo.combinationOperatorOverride ? regionInfo.combinationOperator : pageInfo.combinationOperator;
  48253. var buffer = this.buffer;
  48254. var mask0 = 128 >> (regionInfo.x & 7);
  48255. var offset0 = regionInfo.y * rowSize + (regionInfo.x >> 3);
  48256. var i, j, mask, offset;
  48257. switch (combinationOperator) {
  48258. case 0:
  48259. for (i = 0; i < height; i++) {
  48260. mask = mask0;
  48261. offset = offset0;
  48262. for (j = 0; j < width; j++) {
  48263. if (bitmap[i][j]) {
  48264. buffer[offset] |= mask;
  48265. }
  48266. mask >>= 1;
  48267. if (!mask) {
  48268. mask = 128;
  48269. offset++;
  48270. }
  48271. }
  48272. offset0 += rowSize;
  48273. }
  48274. break;
  48275. case 2:
  48276. for (i = 0; i < height; i++) {
  48277. mask = mask0;
  48278. offset = offset0;
  48279. for (j = 0; j < width; j++) {
  48280. if (bitmap[i][j]) {
  48281. buffer[offset] ^= mask;
  48282. }
  48283. mask >>= 1;
  48284. if (!mask) {
  48285. mask = 128;
  48286. offset++;
  48287. }
  48288. }
  48289. offset0 += rowSize;
  48290. }
  48291. break;
  48292. default:
  48293. error('JBIG2 error: operator ' + combinationOperator + ' is not supported');
  48294. }
  48295. },
  48296. onImmediateGenericRegion: function SimpleSegmentVisitor_onImmediateGenericRegion(region, data, start, end) {
  48297. var regionInfo = region.info;
  48298. var decodingContext = new DecodingContext(data, start, end);
  48299. var bitmap = decodeBitmap(region.mmr, regionInfo.width, regionInfo.height, region.template, region.prediction, null, region.at, decodingContext);
  48300. this.drawBitmap(regionInfo, bitmap);
  48301. },
  48302. onImmediateLosslessGenericRegion: function SimpleSegmentVisitor_onImmediateLosslessGenericRegion() {
  48303. this.onImmediateGenericRegion.apply(this, arguments);
  48304. },
  48305. onSymbolDictionary: function SimpleSegmentVisitor_onSymbolDictionary(dictionary, currentSegment, referredSegments, data, start, end) {
  48306. var huffmanTables;
  48307. if (dictionary.huffman) {
  48308. error('JBIG2 error: huffman is not supported');
  48309. }
  48310. var symbols = this.symbols;
  48311. if (!symbols) {
  48312. this.symbols = symbols = {};
  48313. }
  48314. var inputSymbols = [];
  48315. for (var i = 0, ii = referredSegments.length; i < ii; i++) {
  48316. inputSymbols = inputSymbols.concat(symbols[referredSegments[i]]);
  48317. }
  48318. var decodingContext = new DecodingContext(data, start, end);
  48319. symbols[currentSegment] = decodeSymbolDictionary(dictionary.huffman, dictionary.refinement, inputSymbols, dictionary.numberOfNewSymbols, dictionary.numberOfExportedSymbols, huffmanTables, dictionary.template, dictionary.at, dictionary.refinementTemplate, dictionary.refinementAt, decodingContext);
  48320. },
  48321. onImmediateTextRegion: function SimpleSegmentVisitor_onImmediateTextRegion(region, referredSegments, data, start, end) {
  48322. var regionInfo = region.info;
  48323. var huffmanTables;
  48324. var symbols = this.symbols;
  48325. var inputSymbols = [];
  48326. for (var i = 0, ii = referredSegments.length; i < ii; i++) {
  48327. inputSymbols = inputSymbols.concat(symbols[referredSegments[i]]);
  48328. }
  48329. var symbolCodeLength = log2(inputSymbols.length);
  48330. var decodingContext = new DecodingContext(data, start, end);
  48331. 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);
  48332. this.drawBitmap(regionInfo, bitmap);
  48333. },
  48334. onImmediateLosslessTextRegion: function SimpleSegmentVisitor_onImmediateLosslessTextRegion() {
  48335. this.onImmediateTextRegion.apply(this, arguments);
  48336. }
  48337. };
  48338. function Jbig2Image() {
  48339. }
  48340. Jbig2Image.prototype = {
  48341. parseChunks: function Jbig2Image_parseChunks(chunks) {
  48342. return parseJbig2Chunks(chunks);
  48343. }
  48344. };
  48345. return Jbig2Image;
  48346. }();
  48347. exports.Jbig2Image = Jbig2Image;
  48348. /***/ }),
  48349. /* 37 */
  48350. /***/ (function(module, exports, __w_pdfjs_require__) {
  48351. "use strict";
  48352. var sharedUtil = __w_pdfjs_require__(0);
  48353. var error = sharedUtil.error;
  48354. var JpegImage = function JpegImageClosure() {
  48355. var dctZigZag = new Uint8Array([
  48356. 0,
  48357. 1,
  48358. 8,
  48359. 16,
  48360. 9,
  48361. 2,
  48362. 3,
  48363. 10,
  48364. 17,
  48365. 24,
  48366. 32,
  48367. 25,
  48368. 18,
  48369. 11,
  48370. 4,
  48371. 5,
  48372. 12,
  48373. 19,
  48374. 26,
  48375. 33,
  48376. 40,
  48377. 48,
  48378. 41,
  48379. 34,
  48380. 27,
  48381. 20,
  48382. 13,
  48383. 6,
  48384. 7,
  48385. 14,
  48386. 21,
  48387. 28,
  48388. 35,
  48389. 42,
  48390. 49,
  48391. 56,
  48392. 57,
  48393. 50,
  48394. 43,
  48395. 36,
  48396. 29,
  48397. 22,
  48398. 15,
  48399. 23,
  48400. 30,
  48401. 37,
  48402. 44,
  48403. 51,
  48404. 58,
  48405. 59,
  48406. 52,
  48407. 45,
  48408. 38,
  48409. 31,
  48410. 39,
  48411. 46,
  48412. 53,
  48413. 60,
  48414. 61,
  48415. 54,
  48416. 47,
  48417. 55,
  48418. 62,
  48419. 63
  48420. ]);
  48421. var dctCos1 = 4017;
  48422. var dctSin1 = 799;
  48423. var dctCos3 = 3406;
  48424. var dctSin3 = 2276;
  48425. var dctCos6 = 1567;
  48426. var dctSin6 = 3784;
  48427. var dctSqrt2 = 5793;
  48428. var dctSqrt1d2 = 2896;
  48429. function JpegImage() {
  48430. this.decodeTransform = null;
  48431. this.colorTransform = -1;
  48432. }
  48433. function buildHuffmanTable(codeLengths, values) {
  48434. var k = 0, code = [], i, j, length = 16;
  48435. while (length > 0 && !codeLengths[length - 1]) {
  48436. length--;
  48437. }
  48438. code.push({
  48439. children: [],
  48440. index: 0
  48441. });
  48442. var p = code[0], q;
  48443. for (i = 0; i < length; i++) {
  48444. for (j = 0; j < codeLengths[i]; j++) {
  48445. p = code.pop();
  48446. p.children[p.index] = values[k];
  48447. while (p.index > 0) {
  48448. p = code.pop();
  48449. }
  48450. p.index++;
  48451. code.push(p);
  48452. while (code.length <= i) {
  48453. code.push(q = {
  48454. children: [],
  48455. index: 0
  48456. });
  48457. p.children[p.index] = q.children;
  48458. p = q;
  48459. }
  48460. k++;
  48461. }
  48462. if (i + 1 < length) {
  48463. code.push(q = {
  48464. children: [],
  48465. index: 0
  48466. });
  48467. p.children[p.index] = q.children;
  48468. p = q;
  48469. }
  48470. }
  48471. return code[0].children;
  48472. }
  48473. function getBlockBufferOffset(component, row, col) {
  48474. return 64 * ((component.blocksPerLine + 1) * row + col);
  48475. }
  48476. function decodeScan(data, offset, frame, components, resetInterval, spectralStart, spectralEnd, successivePrev, successive) {
  48477. var mcusPerLine = frame.mcusPerLine;
  48478. var progressive = frame.progressive;
  48479. var startOffset = offset, bitsData = 0, bitsCount = 0;
  48480. function readBit() {
  48481. if (bitsCount > 0) {
  48482. bitsCount--;
  48483. return bitsData >> bitsCount & 1;
  48484. }
  48485. bitsData = data[offset++];
  48486. if (bitsData === 0xFF) {
  48487. var nextByte = data[offset++];
  48488. if (nextByte) {
  48489. error('JPEG error: unexpected marker ' + (bitsData << 8 | nextByte).toString(16));
  48490. }
  48491. }
  48492. bitsCount = 7;
  48493. return bitsData >>> 7;
  48494. }
  48495. function decodeHuffman(tree) {
  48496. var node = tree;
  48497. while (true) {
  48498. node = node[readBit()];
  48499. if (typeof node === 'number') {
  48500. return node;
  48501. }
  48502. if (typeof node !== 'object') {
  48503. error('JPEG error: invalid huffman sequence');
  48504. }
  48505. }
  48506. }
  48507. function receive(length) {
  48508. var n = 0;
  48509. while (length > 0) {
  48510. n = n << 1 | readBit();
  48511. length--;
  48512. }
  48513. return n;
  48514. }
  48515. function receiveAndExtend(length) {
  48516. if (length === 1) {
  48517. return readBit() === 1 ? 1 : -1;
  48518. }
  48519. var n = receive(length);
  48520. if (n >= 1 << length - 1) {
  48521. return n;
  48522. }
  48523. return n + (-1 << length) + 1;
  48524. }
  48525. function decodeBaseline(component, offset) {
  48526. var t = decodeHuffman(component.huffmanTableDC);
  48527. var diff = t === 0 ? 0 : receiveAndExtend(t);
  48528. component.blockData[offset] = component.pred += diff;
  48529. var k = 1;
  48530. while (k < 64) {
  48531. var rs = decodeHuffman(component.huffmanTableAC);
  48532. var s = rs & 15, r = rs >> 4;
  48533. if (s === 0) {
  48534. if (r < 15) {
  48535. break;
  48536. }
  48537. k += 16;
  48538. continue;
  48539. }
  48540. k += r;
  48541. var z = dctZigZag[k];
  48542. component.blockData[offset + z] = receiveAndExtend(s);
  48543. k++;
  48544. }
  48545. }
  48546. function decodeDCFirst(component, offset) {
  48547. var t = decodeHuffman(component.huffmanTableDC);
  48548. var diff = t === 0 ? 0 : receiveAndExtend(t) << successive;
  48549. component.blockData[offset] = component.pred += diff;
  48550. }
  48551. function decodeDCSuccessive(component, offset) {
  48552. component.blockData[offset] |= readBit() << successive;
  48553. }
  48554. var eobrun = 0;
  48555. function decodeACFirst(component, offset) {
  48556. if (eobrun > 0) {
  48557. eobrun--;
  48558. return;
  48559. }
  48560. var k = spectralStart, e = spectralEnd;
  48561. while (k <= e) {
  48562. var rs = decodeHuffman(component.huffmanTableAC);
  48563. var s = rs & 15, r = rs >> 4;
  48564. if (s === 0) {
  48565. if (r < 15) {
  48566. eobrun = receive(r) + (1 << r) - 1;
  48567. break;
  48568. }
  48569. k += 16;
  48570. continue;
  48571. }
  48572. k += r;
  48573. var z = dctZigZag[k];
  48574. component.blockData[offset + z] = receiveAndExtend(s) * (1 << successive);
  48575. k++;
  48576. }
  48577. }
  48578. var successiveACState = 0, successiveACNextValue;
  48579. function decodeACSuccessive(component, offset) {
  48580. var k = spectralStart;
  48581. var e = spectralEnd;
  48582. var r = 0;
  48583. var s;
  48584. var rs;
  48585. while (k <= e) {
  48586. var z = dctZigZag[k];
  48587. switch (successiveACState) {
  48588. case 0:
  48589. rs = decodeHuffman(component.huffmanTableAC);
  48590. s = rs & 15;
  48591. r = rs >> 4;
  48592. if (s === 0) {
  48593. if (r < 15) {
  48594. eobrun = receive(r) + (1 << r);
  48595. successiveACState = 4;
  48596. } else {
  48597. r = 16;
  48598. successiveACState = 1;
  48599. }
  48600. } else {
  48601. if (s !== 1) {
  48602. error('JPEG error: invalid ACn encoding');
  48603. }
  48604. successiveACNextValue = receiveAndExtend(s);
  48605. successiveACState = r ? 2 : 3;
  48606. }
  48607. continue;
  48608. case 1:
  48609. case 2:
  48610. if (component.blockData[offset + z]) {
  48611. component.blockData[offset + z] += readBit() << successive;
  48612. } else {
  48613. r--;
  48614. if (r === 0) {
  48615. successiveACState = successiveACState === 2 ? 3 : 0;
  48616. }
  48617. }
  48618. break;
  48619. case 3:
  48620. if (component.blockData[offset + z]) {
  48621. component.blockData[offset + z] += readBit() << successive;
  48622. } else {
  48623. component.blockData[offset + z] = successiveACNextValue << successive;
  48624. successiveACState = 0;
  48625. }
  48626. break;
  48627. case 4:
  48628. if (component.blockData[offset + z]) {
  48629. component.blockData[offset + z] += readBit() << successive;
  48630. }
  48631. break;
  48632. }
  48633. k++;
  48634. }
  48635. if (successiveACState === 4) {
  48636. eobrun--;
  48637. if (eobrun === 0) {
  48638. successiveACState = 0;
  48639. }
  48640. }
  48641. }
  48642. function decodeMcu(component, decode, mcu, row, col) {
  48643. var mcuRow = mcu / mcusPerLine | 0;
  48644. var mcuCol = mcu % mcusPerLine;
  48645. var blockRow = mcuRow * component.v + row;
  48646. var blockCol = mcuCol * component.h + col;
  48647. var offset = getBlockBufferOffset(component, blockRow, blockCol);
  48648. decode(component, offset);
  48649. }
  48650. function decodeBlock(component, decode, mcu) {
  48651. var blockRow = mcu / component.blocksPerLine | 0;
  48652. var blockCol = mcu % component.blocksPerLine;
  48653. var offset = getBlockBufferOffset(component, blockRow, blockCol);
  48654. decode(component, offset);
  48655. }
  48656. var componentsLength = components.length;
  48657. var component, i, j, k, n;
  48658. var decodeFn;
  48659. if (progressive) {
  48660. if (spectralStart === 0) {
  48661. decodeFn = successivePrev === 0 ? decodeDCFirst : decodeDCSuccessive;
  48662. } else {
  48663. decodeFn = successivePrev === 0 ? decodeACFirst : decodeACSuccessive;
  48664. }
  48665. } else {
  48666. decodeFn = decodeBaseline;
  48667. }
  48668. var mcu = 0, marker;
  48669. var mcuExpected;
  48670. if (componentsLength === 1) {
  48671. mcuExpected = components[0].blocksPerLine * components[0].blocksPerColumn;
  48672. } else {
  48673. mcuExpected = mcusPerLine * frame.mcusPerColumn;
  48674. }
  48675. if (!resetInterval) {
  48676. resetInterval = mcuExpected;
  48677. }
  48678. var h, v;
  48679. while (mcu < mcuExpected) {
  48680. for (i = 0; i < componentsLength; i++) {
  48681. components[i].pred = 0;
  48682. }
  48683. eobrun = 0;
  48684. if (componentsLength === 1) {
  48685. component = components[0];
  48686. for (n = 0; n < resetInterval; n++) {
  48687. decodeBlock(component, decodeFn, mcu);
  48688. mcu++;
  48689. }
  48690. } else {
  48691. for (n = 0; n < resetInterval; n++) {
  48692. for (i = 0; i < componentsLength; i++) {
  48693. component = components[i];
  48694. h = component.h;
  48695. v = component.v;
  48696. for (j = 0; j < v; j++) {
  48697. for (k = 0; k < h; k++) {
  48698. decodeMcu(component, decodeFn, mcu, j, k);
  48699. }
  48700. }
  48701. }
  48702. mcu++;
  48703. }
  48704. }
  48705. bitsCount = 0;
  48706. marker = data[offset] << 8 | data[offset + 1];
  48707. while (data[offset] === 0x00 && offset < data.length - 1) {
  48708. offset++;
  48709. marker = data[offset] << 8 | data[offset + 1];
  48710. }
  48711. if (marker <= 0xFF00) {
  48712. error('JPEG error: marker was not found');
  48713. }
  48714. if (marker >= 0xFFD0 && marker <= 0xFFD7) {
  48715. offset += 2;
  48716. } else {
  48717. break;
  48718. }
  48719. }
  48720. return offset - startOffset;
  48721. }
  48722. function quantizeAndInverse(component, blockBufferOffset, p) {
  48723. var qt = component.quantizationTable, blockData = component.blockData;
  48724. var v0, v1, v2, v3, v4, v5, v6, v7;
  48725. var p0, p1, p2, p3, p4, p5, p6, p7;
  48726. var t;
  48727. if (!qt) {
  48728. error('JPEG error: missing required Quantization Table.');
  48729. }
  48730. for (var row = 0; row < 64; row += 8) {
  48731. p0 = blockData[blockBufferOffset + row];
  48732. p1 = blockData[blockBufferOffset + row + 1];
  48733. p2 = blockData[blockBufferOffset + row + 2];
  48734. p3 = blockData[blockBufferOffset + row + 3];
  48735. p4 = blockData[blockBufferOffset + row + 4];
  48736. p5 = blockData[blockBufferOffset + row + 5];
  48737. p6 = blockData[blockBufferOffset + row + 6];
  48738. p7 = blockData[blockBufferOffset + row + 7];
  48739. p0 *= qt[row];
  48740. if ((p1 | p2 | p3 | p4 | p5 | p6 | p7) === 0) {
  48741. t = dctSqrt2 * p0 + 512 >> 10;
  48742. p[row] = t;
  48743. p[row + 1] = t;
  48744. p[row + 2] = t;
  48745. p[row + 3] = t;
  48746. p[row + 4] = t;
  48747. p[row + 5] = t;
  48748. p[row + 6] = t;
  48749. p[row + 7] = t;
  48750. continue;
  48751. }
  48752. p1 *= qt[row + 1];
  48753. p2 *= qt[row + 2];
  48754. p3 *= qt[row + 3];
  48755. p4 *= qt[row + 4];
  48756. p5 *= qt[row + 5];
  48757. p6 *= qt[row + 6];
  48758. p7 *= qt[row + 7];
  48759. v0 = dctSqrt2 * p0 + 128 >> 8;
  48760. v1 = dctSqrt2 * p4 + 128 >> 8;
  48761. v2 = p2;
  48762. v3 = p6;
  48763. v4 = dctSqrt1d2 * (p1 - p7) + 128 >> 8;
  48764. v7 = dctSqrt1d2 * (p1 + p7) + 128 >> 8;
  48765. v5 = p3 << 4;
  48766. v6 = p5 << 4;
  48767. v0 = v0 + v1 + 1 >> 1;
  48768. v1 = v0 - v1;
  48769. t = v2 * dctSin6 + v3 * dctCos6 + 128 >> 8;
  48770. v2 = v2 * dctCos6 - v3 * dctSin6 + 128 >> 8;
  48771. v3 = t;
  48772. v4 = v4 + v6 + 1 >> 1;
  48773. v6 = v4 - v6;
  48774. v7 = v7 + v5 + 1 >> 1;
  48775. v5 = v7 - v5;
  48776. v0 = v0 + v3 + 1 >> 1;
  48777. v3 = v0 - v3;
  48778. v1 = v1 + v2 + 1 >> 1;
  48779. v2 = v1 - v2;
  48780. t = v4 * dctSin3 + v7 * dctCos3 + 2048 >> 12;
  48781. v4 = v4 * dctCos3 - v7 * dctSin3 + 2048 >> 12;
  48782. v7 = t;
  48783. t = v5 * dctSin1 + v6 * dctCos1 + 2048 >> 12;
  48784. v5 = v5 * dctCos1 - v6 * dctSin1 + 2048 >> 12;
  48785. v6 = t;
  48786. p[row] = v0 + v7;
  48787. p[row + 7] = v0 - v7;
  48788. p[row + 1] = v1 + v6;
  48789. p[row + 6] = v1 - v6;
  48790. p[row + 2] = v2 + v5;
  48791. p[row + 5] = v2 - v5;
  48792. p[row + 3] = v3 + v4;
  48793. p[row + 4] = v3 - v4;
  48794. }
  48795. for (var col = 0; col < 8; ++col) {
  48796. p0 = p[col];
  48797. p1 = p[col + 8];
  48798. p2 = p[col + 16];
  48799. p3 = p[col + 24];
  48800. p4 = p[col + 32];
  48801. p5 = p[col + 40];
  48802. p6 = p[col + 48];
  48803. p7 = p[col + 56];
  48804. if ((p1 | p2 | p3 | p4 | p5 | p6 | p7) === 0) {
  48805. t = dctSqrt2 * p0 + 8192 >> 14;
  48806. t = t < -2040 ? 0 : t >= 2024 ? 255 : t + 2056 >> 4;
  48807. blockData[blockBufferOffset + col] = t;
  48808. blockData[blockBufferOffset + col + 8] = t;
  48809. blockData[blockBufferOffset + col + 16] = t;
  48810. blockData[blockBufferOffset + col + 24] = t;
  48811. blockData[blockBufferOffset + col + 32] = t;
  48812. blockData[blockBufferOffset + col + 40] = t;
  48813. blockData[blockBufferOffset + col + 48] = t;
  48814. blockData[blockBufferOffset + col + 56] = t;
  48815. continue;
  48816. }
  48817. v0 = dctSqrt2 * p0 + 2048 >> 12;
  48818. v1 = dctSqrt2 * p4 + 2048 >> 12;
  48819. v2 = p2;
  48820. v3 = p6;
  48821. v4 = dctSqrt1d2 * (p1 - p7) + 2048 >> 12;
  48822. v7 = dctSqrt1d2 * (p1 + p7) + 2048 >> 12;
  48823. v5 = p3;
  48824. v6 = p5;
  48825. v0 = (v0 + v1 + 1 >> 1) + 4112;
  48826. v1 = v0 - v1;
  48827. t = v2 * dctSin6 + v3 * dctCos6 + 2048 >> 12;
  48828. v2 = v2 * dctCos6 - v3 * dctSin6 + 2048 >> 12;
  48829. v3 = t;
  48830. v4 = v4 + v6 + 1 >> 1;
  48831. v6 = v4 - v6;
  48832. v7 = v7 + v5 + 1 >> 1;
  48833. v5 = v7 - v5;
  48834. v0 = v0 + v3 + 1 >> 1;
  48835. v3 = v0 - v3;
  48836. v1 = v1 + v2 + 1 >> 1;
  48837. v2 = v1 - v2;
  48838. t = v4 * dctSin3 + v7 * dctCos3 + 2048 >> 12;
  48839. v4 = v4 * dctCos3 - v7 * dctSin3 + 2048 >> 12;
  48840. v7 = t;
  48841. t = v5 * dctSin1 + v6 * dctCos1 + 2048 >> 12;
  48842. v5 = v5 * dctCos1 - v6 * dctSin1 + 2048 >> 12;
  48843. v6 = t;
  48844. p0 = v0 + v7;
  48845. p7 = v0 - v7;
  48846. p1 = v1 + v6;
  48847. p6 = v1 - v6;
  48848. p2 = v2 + v5;
  48849. p5 = v2 - v5;
  48850. p3 = v3 + v4;
  48851. p4 = v3 - v4;
  48852. p0 = p0 < 16 ? 0 : p0 >= 4080 ? 255 : p0 >> 4;
  48853. p1 = p1 < 16 ? 0 : p1 >= 4080 ? 255 : p1 >> 4;
  48854. p2 = p2 < 16 ? 0 : p2 >= 4080 ? 255 : p2 >> 4;
  48855. p3 = p3 < 16 ? 0 : p3 >= 4080 ? 255 : p3 >> 4;
  48856. p4 = p4 < 16 ? 0 : p4 >= 4080 ? 255 : p4 >> 4;
  48857. p5 = p5 < 16 ? 0 : p5 >= 4080 ? 255 : p5 >> 4;
  48858. p6 = p6 < 16 ? 0 : p6 >= 4080 ? 255 : p6 >> 4;
  48859. p7 = p7 < 16 ? 0 : p7 >= 4080 ? 255 : p7 >> 4;
  48860. blockData[blockBufferOffset + col] = p0;
  48861. blockData[blockBufferOffset + col + 8] = p1;
  48862. blockData[blockBufferOffset + col + 16] = p2;
  48863. blockData[blockBufferOffset + col + 24] = p3;
  48864. blockData[blockBufferOffset + col + 32] = p4;
  48865. blockData[blockBufferOffset + col + 40] = p5;
  48866. blockData[blockBufferOffset + col + 48] = p6;
  48867. blockData[blockBufferOffset + col + 56] = p7;
  48868. }
  48869. }
  48870. function buildComponentData(frame, component) {
  48871. var blocksPerLine = component.blocksPerLine;
  48872. var blocksPerColumn = component.blocksPerColumn;
  48873. var computationBuffer = new Int16Array(64);
  48874. for (var blockRow = 0; blockRow < blocksPerColumn; blockRow++) {
  48875. for (var blockCol = 0; blockCol < blocksPerLine; blockCol++) {
  48876. var offset = getBlockBufferOffset(component, blockRow, blockCol);
  48877. quantizeAndInverse(component, offset, computationBuffer);
  48878. }
  48879. }
  48880. return component.blockData;
  48881. }
  48882. function clamp0to255(a) {
  48883. return a <= 0 ? 0 : a >= 255 ? 255 : a;
  48884. }
  48885. JpegImage.prototype = {
  48886. parse: function parse(data) {
  48887. function readUint16() {
  48888. var value = data[offset] << 8 | data[offset + 1];
  48889. offset += 2;
  48890. return value;
  48891. }
  48892. function readDataBlock() {
  48893. var length = readUint16();
  48894. var array = data.subarray(offset, offset + length - 2);
  48895. offset += array.length;
  48896. return array;
  48897. }
  48898. function prepareComponents(frame) {
  48899. var mcusPerLine = Math.ceil(frame.samplesPerLine / 8 / frame.maxH);
  48900. var mcusPerColumn = Math.ceil(frame.scanLines / 8 / frame.maxV);
  48901. for (var i = 0; i < frame.components.length; i++) {
  48902. component = frame.components[i];
  48903. var blocksPerLine = Math.ceil(Math.ceil(frame.samplesPerLine / 8) * component.h / frame.maxH);
  48904. var blocksPerColumn = Math.ceil(Math.ceil(frame.scanLines / 8) * component.v / frame.maxV);
  48905. var blocksPerLineForMcu = mcusPerLine * component.h;
  48906. var blocksPerColumnForMcu = mcusPerColumn * component.v;
  48907. var blocksBufferSize = 64 * blocksPerColumnForMcu * (blocksPerLineForMcu + 1);
  48908. component.blockData = new Int16Array(blocksBufferSize);
  48909. component.blocksPerLine = blocksPerLine;
  48910. component.blocksPerColumn = blocksPerColumn;
  48911. }
  48912. frame.mcusPerLine = mcusPerLine;
  48913. frame.mcusPerColumn = mcusPerColumn;
  48914. }
  48915. var offset = 0;
  48916. var jfif = null;
  48917. var adobe = null;
  48918. var frame, resetInterval;
  48919. var quantizationTables = [];
  48920. var huffmanTablesAC = [], huffmanTablesDC = [];
  48921. var fileMarker = readUint16();
  48922. if (fileMarker !== 0xFFD8) {
  48923. error('JPEG error: SOI not found');
  48924. }
  48925. fileMarker = readUint16();
  48926. while (fileMarker !== 0xFFD9) {
  48927. var i, j, l;
  48928. switch (fileMarker) {
  48929. case 0xFFE0:
  48930. case 0xFFE1:
  48931. case 0xFFE2:
  48932. case 0xFFE3:
  48933. case 0xFFE4:
  48934. case 0xFFE5:
  48935. case 0xFFE6:
  48936. case 0xFFE7:
  48937. case 0xFFE8:
  48938. case 0xFFE9:
  48939. case 0xFFEA:
  48940. case 0xFFEB:
  48941. case 0xFFEC:
  48942. case 0xFFED:
  48943. case 0xFFEE:
  48944. case 0xFFEF:
  48945. case 0xFFFE:
  48946. var appData = readDataBlock();
  48947. if (fileMarker === 0xFFE0) {
  48948. if (appData[0] === 0x4A && appData[1] === 0x46 && appData[2] === 0x49 && appData[3] === 0x46 && appData[4] === 0) {
  48949. jfif = {
  48950. version: {
  48951. major: appData[5],
  48952. minor: appData[6]
  48953. },
  48954. densityUnits: appData[7],
  48955. xDensity: appData[8] << 8 | appData[9],
  48956. yDensity: appData[10] << 8 | appData[11],
  48957. thumbWidth: appData[12],
  48958. thumbHeight: appData[13],
  48959. thumbData: appData.subarray(14, 14 + 3 * appData[12] * appData[13])
  48960. };
  48961. }
  48962. }
  48963. if (fileMarker === 0xFFEE) {
  48964. if (appData[0] === 0x41 && appData[1] === 0x64 && appData[2] === 0x6F && appData[3] === 0x62 && appData[4] === 0x65) {
  48965. adobe = {
  48966. version: appData[5] << 8 | appData[6],
  48967. flags0: appData[7] << 8 | appData[8],
  48968. flags1: appData[9] << 8 | appData[10],
  48969. transformCode: appData[11]
  48970. };
  48971. }
  48972. }
  48973. break;
  48974. case 0xFFDB:
  48975. var quantizationTablesLength = readUint16();
  48976. var quantizationTablesEnd = quantizationTablesLength + offset - 2;
  48977. var z;
  48978. while (offset < quantizationTablesEnd) {
  48979. var quantizationTableSpec = data[offset++];
  48980. var tableData = new Uint16Array(64);
  48981. if (quantizationTableSpec >> 4 === 0) {
  48982. for (j = 0; j < 64; j++) {
  48983. z = dctZigZag[j];
  48984. tableData[z] = data[offset++];
  48985. }
  48986. } else if (quantizationTableSpec >> 4 === 1) {
  48987. for (j = 0; j < 64; j++) {
  48988. z = dctZigZag[j];
  48989. tableData[z] = readUint16();
  48990. }
  48991. } else {
  48992. error('JPEG error: DQT - invalid table spec');
  48993. }
  48994. quantizationTables[quantizationTableSpec & 15] = tableData;
  48995. }
  48996. break;
  48997. case 0xFFC0:
  48998. case 0xFFC1:
  48999. case 0xFFC2:
  49000. if (frame) {
  49001. error('JPEG error: Only single frame JPEGs supported');
  49002. }
  49003. readUint16();
  49004. frame = {};
  49005. frame.extended = fileMarker === 0xFFC1;
  49006. frame.progressive = fileMarker === 0xFFC2;
  49007. frame.precision = data[offset++];
  49008. frame.scanLines = readUint16();
  49009. frame.samplesPerLine = readUint16();
  49010. frame.components = [];
  49011. frame.componentIds = {};
  49012. var componentsCount = data[offset++], componentId;
  49013. var maxH = 0, maxV = 0;
  49014. for (i = 0; i < componentsCount; i++) {
  49015. componentId = data[offset];
  49016. var h = data[offset + 1] >> 4;
  49017. var v = data[offset + 1] & 15;
  49018. if (maxH < h) {
  49019. maxH = h;
  49020. }
  49021. if (maxV < v) {
  49022. maxV = v;
  49023. }
  49024. var qId = data[offset + 2];
  49025. l = frame.components.push({
  49026. h: h,
  49027. v: v,
  49028. quantizationId: qId,
  49029. quantizationTable: null
  49030. });
  49031. frame.componentIds[componentId] = l - 1;
  49032. offset += 3;
  49033. }
  49034. frame.maxH = maxH;
  49035. frame.maxV = maxV;
  49036. prepareComponents(frame);
  49037. break;
  49038. case 0xFFC4:
  49039. var huffmanLength = readUint16();
  49040. for (i = 2; i < huffmanLength;) {
  49041. var huffmanTableSpec = data[offset++];
  49042. var codeLengths = new Uint8Array(16);
  49043. var codeLengthSum = 0;
  49044. for (j = 0; j < 16; j++, offset++) {
  49045. codeLengthSum += codeLengths[j] = data[offset];
  49046. }
  49047. var huffmanValues = new Uint8Array(codeLengthSum);
  49048. for (j = 0; j < codeLengthSum; j++, offset++) {
  49049. huffmanValues[j] = data[offset];
  49050. }
  49051. i += 17 + codeLengthSum;
  49052. (huffmanTableSpec >> 4 === 0 ? huffmanTablesDC : huffmanTablesAC)[huffmanTableSpec & 15] = buildHuffmanTable(codeLengths, huffmanValues);
  49053. }
  49054. break;
  49055. case 0xFFDD:
  49056. readUint16();
  49057. resetInterval = readUint16();
  49058. break;
  49059. case 0xFFDA:
  49060. readUint16();
  49061. var selectorsCount = data[offset++];
  49062. var components = [], component;
  49063. for (i = 0; i < selectorsCount; i++) {
  49064. var componentIndex = frame.componentIds[data[offset++]];
  49065. component = frame.components[componentIndex];
  49066. var tableSpec = data[offset++];
  49067. component.huffmanTableDC = huffmanTablesDC[tableSpec >> 4];
  49068. component.huffmanTableAC = huffmanTablesAC[tableSpec & 15];
  49069. components.push(component);
  49070. }
  49071. var spectralStart = data[offset++];
  49072. var spectralEnd = data[offset++];
  49073. var successiveApproximation = data[offset++];
  49074. var processed = decodeScan(data, offset, frame, components, resetInterval, spectralStart, spectralEnd, successiveApproximation >> 4, successiveApproximation & 15);
  49075. offset += processed;
  49076. break;
  49077. case 0xFFFF:
  49078. if (data[offset] !== 0xFF) {
  49079. offset--;
  49080. }
  49081. break;
  49082. default:
  49083. if (data[offset - 3] === 0xFF && data[offset - 2] >= 0xC0 && data[offset - 2] <= 0xFE) {
  49084. offset -= 3;
  49085. break;
  49086. }
  49087. error('JPEG error: unknown marker ' + fileMarker.toString(16));
  49088. }
  49089. fileMarker = readUint16();
  49090. }
  49091. this.width = frame.samplesPerLine;
  49092. this.height = frame.scanLines;
  49093. this.jfif = jfif;
  49094. this.adobe = adobe;
  49095. this.components = [];
  49096. for (i = 0; i < frame.components.length; i++) {
  49097. component = frame.components[i];
  49098. var quantizationTable = quantizationTables[component.quantizationId];
  49099. if (quantizationTable) {
  49100. component.quantizationTable = quantizationTable;
  49101. }
  49102. this.components.push({
  49103. output: buildComponentData(frame, component),
  49104. scaleX: component.h / frame.maxH,
  49105. scaleY: component.v / frame.maxV,
  49106. blocksPerLine: component.blocksPerLine,
  49107. blocksPerColumn: component.blocksPerColumn
  49108. });
  49109. }
  49110. this.numComponents = this.components.length;
  49111. },
  49112. _getLinearizedBlockData: function getLinearizedBlockData(width, height) {
  49113. var scaleX = this.width / width, scaleY = this.height / height;
  49114. var component, componentScaleX, componentScaleY, blocksPerScanline;
  49115. var x, y, i, j, k;
  49116. var index;
  49117. var offset = 0;
  49118. var output;
  49119. var numComponents = this.components.length;
  49120. var dataLength = width * height * numComponents;
  49121. var data = new Uint8Array(dataLength);
  49122. var xScaleBlockOffset = new Uint32Array(width);
  49123. var mask3LSB = 0xfffffff8;
  49124. for (i = 0; i < numComponents; i++) {
  49125. component = this.components[i];
  49126. componentScaleX = component.scaleX * scaleX;
  49127. componentScaleY = component.scaleY * scaleY;
  49128. offset = i;
  49129. output = component.output;
  49130. blocksPerScanline = component.blocksPerLine + 1 << 3;
  49131. for (x = 0; x < width; x++) {
  49132. j = 0 | x * componentScaleX;
  49133. xScaleBlockOffset[x] = (j & mask3LSB) << 3 | j & 7;
  49134. }
  49135. for (y = 0; y < height; y++) {
  49136. j = 0 | y * componentScaleY;
  49137. index = blocksPerScanline * (j & mask3LSB) | (j & 7) << 3;
  49138. for (x = 0; x < width; x++) {
  49139. data[offset] = output[index + xScaleBlockOffset[x]];
  49140. offset += numComponents;
  49141. }
  49142. }
  49143. }
  49144. var transform = this.decodeTransform;
  49145. if (transform) {
  49146. for (i = 0; i < dataLength;) {
  49147. for (j = 0, k = 0; j < numComponents; j++, i++, k += 2) {
  49148. data[i] = (data[i] * transform[k] >> 8) + transform[k + 1];
  49149. }
  49150. }
  49151. }
  49152. return data;
  49153. },
  49154. _isColorConversionNeeded: function isColorConversionNeeded() {
  49155. if (this.adobe && this.adobe.transformCode) {
  49156. return true;
  49157. } else if (this.numComponents === 3) {
  49158. if (!this.adobe && this.colorTransform === 0) {
  49159. return false;
  49160. }
  49161. return true;
  49162. }
  49163. if (!this.adobe && this.colorTransform === 1) {
  49164. return true;
  49165. }
  49166. return false;
  49167. },
  49168. _convertYccToRgb: function convertYccToRgb(data) {
  49169. var Y, Cb, Cr;
  49170. for (var i = 0, length = data.length; i < length; i += 3) {
  49171. Y = data[i];
  49172. Cb = data[i + 1];
  49173. Cr = data[i + 2];
  49174. data[i] = clamp0to255(Y - 179.456 + 1.402 * Cr);
  49175. data[i + 1] = clamp0to255(Y + 135.459 - 0.344 * Cb - 0.714 * Cr);
  49176. data[i + 2] = clamp0to255(Y - 226.816 + 1.772 * Cb);
  49177. }
  49178. return data;
  49179. },
  49180. _convertYcckToRgb: function convertYcckToRgb(data) {
  49181. var Y, Cb, Cr, k;
  49182. var offset = 0;
  49183. for (var i = 0, length = data.length; i < length; i += 4) {
  49184. Y = data[i];
  49185. Cb = data[i + 1];
  49186. Cr = data[i + 2];
  49187. k = data[i + 3];
  49188. 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);
  49189. 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);
  49190. 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);
  49191. data[offset++] = clamp0to255(r);
  49192. data[offset++] = clamp0to255(g);
  49193. data[offset++] = clamp0to255(b);
  49194. }
  49195. return data;
  49196. },
  49197. _convertYcckToCmyk: function convertYcckToCmyk(data) {
  49198. var Y, Cb, Cr;
  49199. for (var i = 0, length = data.length; i < length; i += 4) {
  49200. Y = data[i];
  49201. Cb = data[i + 1];
  49202. Cr = data[i + 2];
  49203. data[i] = clamp0to255(434.456 - Y - 1.402 * Cr);
  49204. data[i + 1] = clamp0to255(119.541 - Y + 0.344 * Cb + 0.714 * Cr);
  49205. data[i + 2] = clamp0to255(481.816 - Y - 1.772 * Cb);
  49206. }
  49207. return data;
  49208. },
  49209. _convertCmykToRgb: function convertCmykToRgb(data) {
  49210. var c, m, y, k;
  49211. var offset = 0;
  49212. var min = -255 * 255 * 255;
  49213. var scale = 1 / 255 / 255;
  49214. for (var i = 0, length = data.length; i < length; i += 4) {
  49215. c = data[i];
  49216. m = data[i + 1];
  49217. y = data[i + 2];
  49218. k = data[i + 3];
  49219. 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);
  49220. 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);
  49221. 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);
  49222. data[offset++] = r >= 0 ? 255 : r <= min ? 0 : 255 + r * scale | 0;
  49223. data[offset++] = g >= 0 ? 255 : g <= min ? 0 : 255 + g * scale | 0;
  49224. data[offset++] = b >= 0 ? 255 : b <= min ? 0 : 255 + b * scale | 0;
  49225. }
  49226. return data;
  49227. },
  49228. getData: function getData(width, height, forceRGBoutput) {
  49229. if (this.numComponents > 4) {
  49230. error('JPEG error: Unsupported color mode');
  49231. }
  49232. var data = this._getLinearizedBlockData(width, height);
  49233. if (this.numComponents === 1 && forceRGBoutput) {
  49234. var dataLength = data.length;
  49235. var rgbData = new Uint8Array(dataLength * 3);
  49236. var offset = 0;
  49237. for (var i = 0; i < dataLength; i++) {
  49238. var grayColor = data[i];
  49239. rgbData[offset++] = grayColor;
  49240. rgbData[offset++] = grayColor;
  49241. rgbData[offset++] = grayColor;
  49242. }
  49243. return rgbData;
  49244. } else if (this.numComponents === 3 && this._isColorConversionNeeded()) {
  49245. return this._convertYccToRgb(data);
  49246. } else if (this.numComponents === 4) {
  49247. if (this._isColorConversionNeeded()) {
  49248. if (forceRGBoutput) {
  49249. return this._convertYcckToRgb(data);
  49250. }
  49251. return this._convertYcckToCmyk(data);
  49252. } else if (forceRGBoutput) {
  49253. return this._convertCmykToRgb(data);
  49254. }
  49255. }
  49256. return data;
  49257. }
  49258. };
  49259. return JpegImage;
  49260. }();
  49261. exports.JpegImage = JpegImage;
  49262. /***/ }),
  49263. /* 38 */
  49264. /***/ (function(module, exports, __w_pdfjs_require__) {
  49265. "use strict";
  49266. var sharedUtil = __w_pdfjs_require__(0);
  49267. var getLookupTableFactory = sharedUtil.getLookupTableFactory;
  49268. var getMetrics = getLookupTableFactory(function (t) {
  49269. t['Courier'] = 600;
  49270. t['Courier-Bold'] = 600;
  49271. t['Courier-BoldOblique'] = 600;
  49272. t['Courier-Oblique'] = 600;
  49273. t['Helvetica'] = getLookupTableFactory(function (t) {
  49274. t['space'] = 278;
  49275. t['exclam'] = 278;
  49276. t['quotedbl'] = 355;
  49277. t['numbersign'] = 556;
  49278. t['dollar'] = 556;
  49279. t['percent'] = 889;
  49280. t['ampersand'] = 667;
  49281. t['quoteright'] = 222;
  49282. t['parenleft'] = 333;
  49283. t['parenright'] = 333;
  49284. t['asterisk'] = 389;
  49285. t['plus'] = 584;
  49286. t['comma'] = 278;
  49287. t['hyphen'] = 333;
  49288. t['period'] = 278;
  49289. t['slash'] = 278;
  49290. t['zero'] = 556;
  49291. t['one'] = 556;
  49292. t['two'] = 556;
  49293. t['three'] = 556;
  49294. t['four'] = 556;
  49295. t['five'] = 556;
  49296. t['six'] = 556;
  49297. t['seven'] = 556;
  49298. t['eight'] = 556;
  49299. t['nine'] = 556;
  49300. t['colon'] = 278;
  49301. t['semicolon'] = 278;
  49302. t['less'] = 584;
  49303. t['equal'] = 584;
  49304. t['greater'] = 584;
  49305. t['question'] = 556;
  49306. t['at'] = 1015;
  49307. t['A'] = 667;
  49308. t['B'] = 667;
  49309. t['C'] = 722;
  49310. t['D'] = 722;
  49311. t['E'] = 667;
  49312. t['F'] = 611;
  49313. t['G'] = 778;
  49314. t['H'] = 722;
  49315. t['I'] = 278;
  49316. t['J'] = 500;
  49317. t['K'] = 667;
  49318. t['L'] = 556;
  49319. t['M'] = 833;
  49320. t['N'] = 722;
  49321. t['O'] = 778;
  49322. t['P'] = 667;
  49323. t['Q'] = 778;
  49324. t['R'] = 722;
  49325. t['S'] = 667;
  49326. t['T'] = 611;
  49327. t['U'] = 722;
  49328. t['V'] = 667;
  49329. t['W'] = 944;
  49330. t['X'] = 667;
  49331. t['Y'] = 667;
  49332. t['Z'] = 611;
  49333. t['bracketleft'] = 278;
  49334. t['backslash'] = 278;
  49335. t['bracketright'] = 278;
  49336. t['asciicircum'] = 469;
  49337. t['underscore'] = 556;
  49338. t['quoteleft'] = 222;
  49339. t['a'] = 556;
  49340. t['b'] = 556;
  49341. t['c'] = 500;
  49342. t['d'] = 556;
  49343. t['e'] = 556;
  49344. t['f'] = 278;
  49345. t['g'] = 556;
  49346. t['h'] = 556;
  49347. t['i'] = 222;
  49348. t['j'] = 222;
  49349. t['k'] = 500;
  49350. t['l'] = 222;
  49351. t['m'] = 833;
  49352. t['n'] = 556;
  49353. t['o'] = 556;
  49354. t['p'] = 556;
  49355. t['q'] = 556;
  49356. t['r'] = 333;
  49357. t['s'] = 500;
  49358. t['t'] = 278;
  49359. t['u'] = 556;
  49360. t['v'] = 500;
  49361. t['w'] = 722;
  49362. t['x'] = 500;
  49363. t['y'] = 500;
  49364. t['z'] = 500;
  49365. t['braceleft'] = 334;
  49366. t['bar'] = 260;
  49367. t['braceright'] = 334;
  49368. t['asciitilde'] = 584;
  49369. t['exclamdown'] = 333;
  49370. t['cent'] = 556;
  49371. t['sterling'] = 556;
  49372. t['fraction'] = 167;
  49373. t['yen'] = 556;
  49374. t['florin'] = 556;
  49375. t['section'] = 556;
  49376. t['currency'] = 556;
  49377. t['quotesingle'] = 191;
  49378. t['quotedblleft'] = 333;
  49379. t['guillemotleft'] = 556;
  49380. t['guilsinglleft'] = 333;
  49381. t['guilsinglright'] = 333;
  49382. t['fi'] = 500;
  49383. t['fl'] = 500;
  49384. t['endash'] = 556;
  49385. t['dagger'] = 556;
  49386. t['daggerdbl'] = 556;
  49387. t['periodcentered'] = 278;
  49388. t['paragraph'] = 537;
  49389. t['bullet'] = 350;
  49390. t['quotesinglbase'] = 222;
  49391. t['quotedblbase'] = 333;
  49392. t['quotedblright'] = 333;
  49393. t['guillemotright'] = 556;
  49394. t['ellipsis'] = 1000;
  49395. t['perthousand'] = 1000;
  49396. t['questiondown'] = 611;
  49397. t['grave'] = 333;
  49398. t['acute'] = 333;
  49399. t['circumflex'] = 333;
  49400. t['tilde'] = 333;
  49401. t['macron'] = 333;
  49402. t['breve'] = 333;
  49403. t['dotaccent'] = 333;
  49404. t['dieresis'] = 333;
  49405. t['ring'] = 333;
  49406. t['cedilla'] = 333;
  49407. t['hungarumlaut'] = 333;
  49408. t['ogonek'] = 333;
  49409. t['caron'] = 333;
  49410. t['emdash'] = 1000;
  49411. t['AE'] = 1000;
  49412. t['ordfeminine'] = 370;
  49413. t['Lslash'] = 556;
  49414. t['Oslash'] = 778;
  49415. t['OE'] = 1000;
  49416. t['ordmasculine'] = 365;
  49417. t['ae'] = 889;
  49418. t['dotlessi'] = 278;
  49419. t['lslash'] = 222;
  49420. t['oslash'] = 611;
  49421. t['oe'] = 944;
  49422. t['germandbls'] = 611;
  49423. t['Idieresis'] = 278;
  49424. t['eacute'] = 556;
  49425. t['abreve'] = 556;
  49426. t['uhungarumlaut'] = 556;
  49427. t['ecaron'] = 556;
  49428. t['Ydieresis'] = 667;
  49429. t['divide'] = 584;
  49430. t['Yacute'] = 667;
  49431. t['Acircumflex'] = 667;
  49432. t['aacute'] = 556;
  49433. t['Ucircumflex'] = 722;
  49434. t['yacute'] = 500;
  49435. t['scommaaccent'] = 500;
  49436. t['ecircumflex'] = 556;
  49437. t['Uring'] = 722;
  49438. t['Udieresis'] = 722;
  49439. t['aogonek'] = 556;
  49440. t['Uacute'] = 722;
  49441. t['uogonek'] = 556;
  49442. t['Edieresis'] = 667;
  49443. t['Dcroat'] = 722;
  49444. t['commaaccent'] = 250;
  49445. t['copyright'] = 737;
  49446. t['Emacron'] = 667;
  49447. t['ccaron'] = 500;
  49448. t['aring'] = 556;
  49449. t['Ncommaaccent'] = 722;
  49450. t['lacute'] = 222;
  49451. t['agrave'] = 556;
  49452. t['Tcommaaccent'] = 611;
  49453. t['Cacute'] = 722;
  49454. t['atilde'] = 556;
  49455. t['Edotaccent'] = 667;
  49456. t['scaron'] = 500;
  49457. t['scedilla'] = 500;
  49458. t['iacute'] = 278;
  49459. t['lozenge'] = 471;
  49460. t['Rcaron'] = 722;
  49461. t['Gcommaaccent'] = 778;
  49462. t['ucircumflex'] = 556;
  49463. t['acircumflex'] = 556;
  49464. t['Amacron'] = 667;
  49465. t['rcaron'] = 333;
  49466. t['ccedilla'] = 500;
  49467. t['Zdotaccent'] = 611;
  49468. t['Thorn'] = 667;
  49469. t['Omacron'] = 778;
  49470. t['Racute'] = 722;
  49471. t['Sacute'] = 667;
  49472. t['dcaron'] = 643;
  49473. t['Umacron'] = 722;
  49474. t['uring'] = 556;
  49475. t['threesuperior'] = 333;
  49476. t['Ograve'] = 778;
  49477. t['Agrave'] = 667;
  49478. t['Abreve'] = 667;
  49479. t['multiply'] = 584;
  49480. t['uacute'] = 556;
  49481. t['Tcaron'] = 611;
  49482. t['partialdiff'] = 476;
  49483. t['ydieresis'] = 500;
  49484. t['Nacute'] = 722;
  49485. t['icircumflex'] = 278;
  49486. t['Ecircumflex'] = 667;
  49487. t['adieresis'] = 556;
  49488. t['edieresis'] = 556;
  49489. t['cacute'] = 500;
  49490. t['nacute'] = 556;
  49491. t['umacron'] = 556;
  49492. t['Ncaron'] = 722;
  49493. t['Iacute'] = 278;
  49494. t['plusminus'] = 584;
  49495. t['brokenbar'] = 260;
  49496. t['registered'] = 737;
  49497. t['Gbreve'] = 778;
  49498. t['Idotaccent'] = 278;
  49499. t['summation'] = 600;
  49500. t['Egrave'] = 667;
  49501. t['racute'] = 333;
  49502. t['omacron'] = 556;
  49503. t['Zacute'] = 611;
  49504. t['Zcaron'] = 611;
  49505. t['greaterequal'] = 549;
  49506. t['Eth'] = 722;
  49507. t['Ccedilla'] = 722;
  49508. t['lcommaaccent'] = 222;
  49509. t['tcaron'] = 317;
  49510. t['eogonek'] = 556;
  49511. t['Uogonek'] = 722;
  49512. t['Aacute'] = 667;
  49513. t['Adieresis'] = 667;
  49514. t['egrave'] = 556;
  49515. t['zacute'] = 500;
  49516. t['iogonek'] = 222;
  49517. t['Oacute'] = 778;
  49518. t['oacute'] = 556;
  49519. t['amacron'] = 556;
  49520. t['sacute'] = 500;
  49521. t['idieresis'] = 278;
  49522. t['Ocircumflex'] = 778;
  49523. t['Ugrave'] = 722;
  49524. t['Delta'] = 612;
  49525. t['thorn'] = 556;
  49526. t['twosuperior'] = 333;
  49527. t['Odieresis'] = 778;
  49528. t['mu'] = 556;
  49529. t['igrave'] = 278;
  49530. t['ohungarumlaut'] = 556;
  49531. t['Eogonek'] = 667;
  49532. t['dcroat'] = 556;
  49533. t['threequarters'] = 834;
  49534. t['Scedilla'] = 667;
  49535. t['lcaron'] = 299;
  49536. t['Kcommaaccent'] = 667;
  49537. t['Lacute'] = 556;
  49538. t['trademark'] = 1000;
  49539. t['edotaccent'] = 556;
  49540. t['Igrave'] = 278;
  49541. t['Imacron'] = 278;
  49542. t['Lcaron'] = 556;
  49543. t['onehalf'] = 834;
  49544. t['lessequal'] = 549;
  49545. t['ocircumflex'] = 556;
  49546. t['ntilde'] = 556;
  49547. t['Uhungarumlaut'] = 722;
  49548. t['Eacute'] = 667;
  49549. t['emacron'] = 556;
  49550. t['gbreve'] = 556;
  49551. t['onequarter'] = 834;
  49552. t['Scaron'] = 667;
  49553. t['Scommaaccent'] = 667;
  49554. t['Ohungarumlaut'] = 778;
  49555. t['degree'] = 400;
  49556. t['ograve'] = 556;
  49557. t['Ccaron'] = 722;
  49558. t['ugrave'] = 556;
  49559. t['radical'] = 453;
  49560. t['Dcaron'] = 722;
  49561. t['rcommaaccent'] = 333;
  49562. t['Ntilde'] = 722;
  49563. t['otilde'] = 556;
  49564. t['Rcommaaccent'] = 722;
  49565. t['Lcommaaccent'] = 556;
  49566. t['Atilde'] = 667;
  49567. t['Aogonek'] = 667;
  49568. t['Aring'] = 667;
  49569. t['Otilde'] = 778;
  49570. t['zdotaccent'] = 500;
  49571. t['Ecaron'] = 667;
  49572. t['Iogonek'] = 278;
  49573. t['kcommaaccent'] = 500;
  49574. t['minus'] = 584;
  49575. t['Icircumflex'] = 278;
  49576. t['ncaron'] = 556;
  49577. t['tcommaaccent'] = 278;
  49578. t['logicalnot'] = 584;
  49579. t['odieresis'] = 556;
  49580. t['udieresis'] = 556;
  49581. t['notequal'] = 549;
  49582. t['gcommaaccent'] = 556;
  49583. t['eth'] = 556;
  49584. t['zcaron'] = 500;
  49585. t['ncommaaccent'] = 556;
  49586. t['onesuperior'] = 333;
  49587. t['imacron'] = 278;
  49588. t['Euro'] = 556;
  49589. });
  49590. t['Helvetica-Bold'] = getLookupTableFactory(function (t) {
  49591. t['space'] = 278;
  49592. t['exclam'] = 333;
  49593. t['quotedbl'] = 474;
  49594. t['numbersign'] = 556;
  49595. t['dollar'] = 556;
  49596. t['percent'] = 889;
  49597. t['ampersand'] = 722;
  49598. t['quoteright'] = 278;
  49599. t['parenleft'] = 333;
  49600. t['parenright'] = 333;
  49601. t['asterisk'] = 389;
  49602. t['plus'] = 584;
  49603. t['comma'] = 278;
  49604. t['hyphen'] = 333;
  49605. t['period'] = 278;
  49606. t['slash'] = 278;
  49607. t['zero'] = 556;
  49608. t['one'] = 556;
  49609. t['two'] = 556;
  49610. t['three'] = 556;
  49611. t['four'] = 556;
  49612. t['five'] = 556;
  49613. t['six'] = 556;
  49614. t['seven'] = 556;
  49615. t['eight'] = 556;
  49616. t['nine'] = 556;
  49617. t['colon'] = 333;
  49618. t['semicolon'] = 333;
  49619. t['less'] = 584;
  49620. t['equal'] = 584;
  49621. t['greater'] = 584;
  49622. t['question'] = 611;
  49623. t['at'] = 975;
  49624. t['A'] = 722;
  49625. t['B'] = 722;
  49626. t['C'] = 722;
  49627. t['D'] = 722;
  49628. t['E'] = 667;
  49629. t['F'] = 611;
  49630. t['G'] = 778;
  49631. t['H'] = 722;
  49632. t['I'] = 278;
  49633. t['J'] = 556;
  49634. t['K'] = 722;
  49635. t['L'] = 611;
  49636. t['M'] = 833;
  49637. t['N'] = 722;
  49638. t['O'] = 778;
  49639. t['P'] = 667;
  49640. t['Q'] = 778;
  49641. t['R'] = 722;
  49642. t['S'] = 667;
  49643. t['T'] = 611;
  49644. t['U'] = 722;
  49645. t['V'] = 667;
  49646. t['W'] = 944;
  49647. t['X'] = 667;
  49648. t['Y'] = 667;
  49649. t['Z'] = 611;
  49650. t['bracketleft'] = 333;
  49651. t['backslash'] = 278;
  49652. t['bracketright'] = 333;
  49653. t['asciicircum'] = 584;
  49654. t['underscore'] = 556;
  49655. t['quoteleft'] = 278;
  49656. t['a'] = 556;
  49657. t['b'] = 611;
  49658. t['c'] = 556;
  49659. t['d'] = 611;
  49660. t['e'] = 556;
  49661. t['f'] = 333;
  49662. t['g'] = 611;
  49663. t['h'] = 611;
  49664. t['i'] = 278;
  49665. t['j'] = 278;
  49666. t['k'] = 556;
  49667. t['l'] = 278;
  49668. t['m'] = 889;
  49669. t['n'] = 611;
  49670. t['o'] = 611;
  49671. t['p'] = 611;
  49672. t['q'] = 611;
  49673. t['r'] = 389;
  49674. t['s'] = 556;
  49675. t['t'] = 333;
  49676. t['u'] = 611;
  49677. t['v'] = 556;
  49678. t['w'] = 778;
  49679. t['x'] = 556;
  49680. t['y'] = 556;
  49681. t['z'] = 500;
  49682. t['braceleft'] = 389;
  49683. t['bar'] = 280;
  49684. t['braceright'] = 389;
  49685. t['asciitilde'] = 584;
  49686. t['exclamdown'] = 333;
  49687. t['cent'] = 556;
  49688. t['sterling'] = 556;
  49689. t['fraction'] = 167;
  49690. t['yen'] = 556;
  49691. t['florin'] = 556;
  49692. t['section'] = 556;
  49693. t['currency'] = 556;
  49694. t['quotesingle'] = 238;
  49695. t['quotedblleft'] = 500;
  49696. t['guillemotleft'] = 556;
  49697. t['guilsinglleft'] = 333;
  49698. t['guilsinglright'] = 333;
  49699. t['fi'] = 611;
  49700. t['fl'] = 611;
  49701. t['endash'] = 556;
  49702. t['dagger'] = 556;
  49703. t['daggerdbl'] = 556;
  49704. t['periodcentered'] = 278;
  49705. t['paragraph'] = 556;
  49706. t['bullet'] = 350;
  49707. t['quotesinglbase'] = 278;
  49708. t['quotedblbase'] = 500;
  49709. t['quotedblright'] = 500;
  49710. t['guillemotright'] = 556;
  49711. t['ellipsis'] = 1000;
  49712. t['perthousand'] = 1000;
  49713. t['questiondown'] = 611;
  49714. t['grave'] = 333;
  49715. t['acute'] = 333;
  49716. t['circumflex'] = 333;
  49717. t['tilde'] = 333;
  49718. t['macron'] = 333;
  49719. t['breve'] = 333;
  49720. t['dotaccent'] = 333;
  49721. t['dieresis'] = 333;
  49722. t['ring'] = 333;
  49723. t['cedilla'] = 333;
  49724. t['hungarumlaut'] = 333;
  49725. t['ogonek'] = 333;
  49726. t['caron'] = 333;
  49727. t['emdash'] = 1000;
  49728. t['AE'] = 1000;
  49729. t['ordfeminine'] = 370;
  49730. t['Lslash'] = 611;
  49731. t['Oslash'] = 778;
  49732. t['OE'] = 1000;
  49733. t['ordmasculine'] = 365;
  49734. t['ae'] = 889;
  49735. t['dotlessi'] = 278;
  49736. t['lslash'] = 278;
  49737. t['oslash'] = 611;
  49738. t['oe'] = 944;
  49739. t['germandbls'] = 611;
  49740. t['Idieresis'] = 278;
  49741. t['eacute'] = 556;
  49742. t['abreve'] = 556;
  49743. t['uhungarumlaut'] = 611;
  49744. t['ecaron'] = 556;
  49745. t['Ydieresis'] = 667;
  49746. t['divide'] = 584;
  49747. t['Yacute'] = 667;
  49748. t['Acircumflex'] = 722;
  49749. t['aacute'] = 556;
  49750. t['Ucircumflex'] = 722;
  49751. t['yacute'] = 556;
  49752. t['scommaaccent'] = 556;
  49753. t['ecircumflex'] = 556;
  49754. t['Uring'] = 722;
  49755. t['Udieresis'] = 722;
  49756. t['aogonek'] = 556;
  49757. t['Uacute'] = 722;
  49758. t['uogonek'] = 611;
  49759. t['Edieresis'] = 667;
  49760. t['Dcroat'] = 722;
  49761. t['commaaccent'] = 250;
  49762. t['copyright'] = 737;
  49763. t['Emacron'] = 667;
  49764. t['ccaron'] = 556;
  49765. t['aring'] = 556;
  49766. t['Ncommaaccent'] = 722;
  49767. t['lacute'] = 278;
  49768. t['agrave'] = 556;
  49769. t['Tcommaaccent'] = 611;
  49770. t['Cacute'] = 722;
  49771. t['atilde'] = 556;
  49772. t['Edotaccent'] = 667;
  49773. t['scaron'] = 556;
  49774. t['scedilla'] = 556;
  49775. t['iacute'] = 278;
  49776. t['lozenge'] = 494;
  49777. t['Rcaron'] = 722;
  49778. t['Gcommaaccent'] = 778;
  49779. t['ucircumflex'] = 611;
  49780. t['acircumflex'] = 556;
  49781. t['Amacron'] = 722;
  49782. t['rcaron'] = 389;
  49783. t['ccedilla'] = 556;
  49784. t['Zdotaccent'] = 611;
  49785. t['Thorn'] = 667;
  49786. t['Omacron'] = 778;
  49787. t['Racute'] = 722;
  49788. t['Sacute'] = 667;
  49789. t['dcaron'] = 743;
  49790. t['Umacron'] = 722;
  49791. t['uring'] = 611;
  49792. t['threesuperior'] = 333;
  49793. t['Ograve'] = 778;
  49794. t['Agrave'] = 722;
  49795. t['Abreve'] = 722;
  49796. t['multiply'] = 584;
  49797. t['uacute'] = 611;
  49798. t['Tcaron'] = 611;
  49799. t['partialdiff'] = 494;
  49800. t['ydieresis'] = 556;
  49801. t['Nacute'] = 722;
  49802. t['icircumflex'] = 278;
  49803. t['Ecircumflex'] = 667;
  49804. t['adieresis'] = 556;
  49805. t['edieresis'] = 556;
  49806. t['cacute'] = 556;
  49807. t['nacute'] = 611;
  49808. t['umacron'] = 611;
  49809. t['Ncaron'] = 722;
  49810. t['Iacute'] = 278;
  49811. t['plusminus'] = 584;
  49812. t['brokenbar'] = 280;
  49813. t['registered'] = 737;
  49814. t['Gbreve'] = 778;
  49815. t['Idotaccent'] = 278;
  49816. t['summation'] = 600;
  49817. t['Egrave'] = 667;
  49818. t['racute'] = 389;
  49819. t['omacron'] = 611;
  49820. t['Zacute'] = 611;
  49821. t['Zcaron'] = 611;
  49822. t['greaterequal'] = 549;
  49823. t['Eth'] = 722;
  49824. t['Ccedilla'] = 722;
  49825. t['lcommaaccent'] = 278;
  49826. t['tcaron'] = 389;
  49827. t['eogonek'] = 556;
  49828. t['Uogonek'] = 722;
  49829. t['Aacute'] = 722;
  49830. t['Adieresis'] = 722;
  49831. t['egrave'] = 556;
  49832. t['zacute'] = 500;
  49833. t['iogonek'] = 278;
  49834. t['Oacute'] = 778;
  49835. t['oacute'] = 611;
  49836. t['amacron'] = 556;
  49837. t['sacute'] = 556;
  49838. t['idieresis'] = 278;
  49839. t['Ocircumflex'] = 778;
  49840. t['Ugrave'] = 722;
  49841. t['Delta'] = 612;
  49842. t['thorn'] = 611;
  49843. t['twosuperior'] = 333;
  49844. t['Odieresis'] = 778;
  49845. t['mu'] = 611;
  49846. t['igrave'] = 278;
  49847. t['ohungarumlaut'] = 611;
  49848. t['Eogonek'] = 667;
  49849. t['dcroat'] = 611;
  49850. t['threequarters'] = 834;
  49851. t['Scedilla'] = 667;
  49852. t['lcaron'] = 400;
  49853. t['Kcommaaccent'] = 722;
  49854. t['Lacute'] = 611;
  49855. t['trademark'] = 1000;
  49856. t['edotaccent'] = 556;
  49857. t['Igrave'] = 278;
  49858. t['Imacron'] = 278;
  49859. t['Lcaron'] = 611;
  49860. t['onehalf'] = 834;
  49861. t['lessequal'] = 549;
  49862. t['ocircumflex'] = 611;
  49863. t['ntilde'] = 611;
  49864. t['Uhungarumlaut'] = 722;
  49865. t['Eacute'] = 667;
  49866. t['emacron'] = 556;
  49867. t['gbreve'] = 611;
  49868. t['onequarter'] = 834;
  49869. t['Scaron'] = 667;
  49870. t['Scommaaccent'] = 667;
  49871. t['Ohungarumlaut'] = 778;
  49872. t['degree'] = 400;
  49873. t['ograve'] = 611;
  49874. t['Ccaron'] = 722;
  49875. t['ugrave'] = 611;
  49876. t['radical'] = 549;
  49877. t['Dcaron'] = 722;
  49878. t['rcommaaccent'] = 389;
  49879. t['Ntilde'] = 722;
  49880. t['otilde'] = 611;
  49881. t['Rcommaaccent'] = 722;
  49882. t['Lcommaaccent'] = 611;
  49883. t['Atilde'] = 722;
  49884. t['Aogonek'] = 722;
  49885. t['Aring'] = 722;
  49886. t['Otilde'] = 778;
  49887. t['zdotaccent'] = 500;
  49888. t['Ecaron'] = 667;
  49889. t['Iogonek'] = 278;
  49890. t['kcommaaccent'] = 556;
  49891. t['minus'] = 584;
  49892. t['Icircumflex'] = 278;
  49893. t['ncaron'] = 611;
  49894. t['tcommaaccent'] = 333;
  49895. t['logicalnot'] = 584;
  49896. t['odieresis'] = 611;
  49897. t['udieresis'] = 611;
  49898. t['notequal'] = 549;
  49899. t['gcommaaccent'] = 611;
  49900. t['eth'] = 611;
  49901. t['zcaron'] = 500;
  49902. t['ncommaaccent'] = 611;
  49903. t['onesuperior'] = 333;
  49904. t['imacron'] = 278;
  49905. t['Euro'] = 556;
  49906. });
  49907. t['Helvetica-BoldOblique'] = getLookupTableFactory(function (t) {
  49908. t['space'] = 278;
  49909. t['exclam'] = 333;
  49910. t['quotedbl'] = 474;
  49911. t['numbersign'] = 556;
  49912. t['dollar'] = 556;
  49913. t['percent'] = 889;
  49914. t['ampersand'] = 722;
  49915. t['quoteright'] = 278;
  49916. t['parenleft'] = 333;
  49917. t['parenright'] = 333;
  49918. t['asterisk'] = 389;
  49919. t['plus'] = 584;
  49920. t['comma'] = 278;
  49921. t['hyphen'] = 333;
  49922. t['period'] = 278;
  49923. t['slash'] = 278;
  49924. t['zero'] = 556;
  49925. t['one'] = 556;
  49926. t['two'] = 556;
  49927. t['three'] = 556;
  49928. t['four'] = 556;
  49929. t['five'] = 556;
  49930. t['six'] = 556;
  49931. t['seven'] = 556;
  49932. t['eight'] = 556;
  49933. t['nine'] = 556;
  49934. t['colon'] = 333;
  49935. t['semicolon'] = 333;
  49936. t['less'] = 584;
  49937. t['equal'] = 584;
  49938. t['greater'] = 584;
  49939. t['question'] = 611;
  49940. t['at'] = 975;
  49941. t['A'] = 722;
  49942. t['B'] = 722;
  49943. t['C'] = 722;
  49944. t['D'] = 722;
  49945. t['E'] = 667;
  49946. t['F'] = 611;
  49947. t['G'] = 778;
  49948. t['H'] = 722;
  49949. t['I'] = 278;
  49950. t['J'] = 556;
  49951. t['K'] = 722;
  49952. t['L'] = 611;
  49953. t['M'] = 833;
  49954. t['N'] = 722;
  49955. t['O'] = 778;
  49956. t['P'] = 667;
  49957. t['Q'] = 778;
  49958. t['R'] = 722;
  49959. t['S'] = 667;
  49960. t['T'] = 611;
  49961. t['U'] = 722;
  49962. t['V'] = 667;
  49963. t['W'] = 944;
  49964. t['X'] = 667;
  49965. t['Y'] = 667;
  49966. t['Z'] = 611;
  49967. t['bracketleft'] = 333;
  49968. t['backslash'] = 278;
  49969. t['bracketright'] = 333;
  49970. t['asciicircum'] = 584;
  49971. t['underscore'] = 556;
  49972. t['quoteleft'] = 278;
  49973. t['a'] = 556;
  49974. t['b'] = 611;
  49975. t['c'] = 556;
  49976. t['d'] = 611;
  49977. t['e'] = 556;
  49978. t['f'] = 333;
  49979. t['g'] = 611;
  49980. t['h'] = 611;
  49981. t['i'] = 278;
  49982. t['j'] = 278;
  49983. t['k'] = 556;
  49984. t['l'] = 278;
  49985. t['m'] = 889;
  49986. t['n'] = 611;
  49987. t['o'] = 611;
  49988. t['p'] = 611;
  49989. t['q'] = 611;
  49990. t['r'] = 389;
  49991. t['s'] = 556;
  49992. t['t'] = 333;
  49993. t['u'] = 611;
  49994. t['v'] = 556;
  49995. t['w'] = 778;
  49996. t['x'] = 556;
  49997. t['y'] = 556;
  49998. t['z'] = 500;
  49999. t['braceleft'] = 389;
  50000. t['bar'] = 280;
  50001. t['braceright'] = 389;
  50002. t['asciitilde'] = 584;
  50003. t['exclamdown'] = 333;
  50004. t['cent'] = 556;
  50005. t['sterling'] = 556;
  50006. t['fraction'] = 167;
  50007. t['yen'] = 556;
  50008. t['florin'] = 556;
  50009. t['section'] = 556;
  50010. t['currency'] = 556;
  50011. t['quotesingle'] = 238;
  50012. t['quotedblleft'] = 500;
  50013. t['guillemotleft'] = 556;
  50014. t['guilsinglleft'] = 333;
  50015. t['guilsinglright'] = 333;
  50016. t['fi'] = 611;
  50017. t['fl'] = 611;
  50018. t['endash'] = 556;
  50019. t['dagger'] = 556;
  50020. t['daggerdbl'] = 556;
  50021. t['periodcentered'] = 278;
  50022. t['paragraph'] = 556;
  50023. t['bullet'] = 350;
  50024. t['quotesinglbase'] = 278;
  50025. t['quotedblbase'] = 500;
  50026. t['quotedblright'] = 500;
  50027. t['guillemotright'] = 556;
  50028. t['ellipsis'] = 1000;
  50029. t['perthousand'] = 1000;
  50030. t['questiondown'] = 611;
  50031. t['grave'] = 333;
  50032. t['acute'] = 333;
  50033. t['circumflex'] = 333;
  50034. t['tilde'] = 333;
  50035. t['macron'] = 333;
  50036. t['breve'] = 333;
  50037. t['dotaccent'] = 333;
  50038. t['dieresis'] = 333;
  50039. t['ring'] = 333;
  50040. t['cedilla'] = 333;
  50041. t['hungarumlaut'] = 333;
  50042. t['ogonek'] = 333;
  50043. t['caron'] = 333;
  50044. t['emdash'] = 1000;
  50045. t['AE'] = 1000;
  50046. t['ordfeminine'] = 370;
  50047. t['Lslash'] = 611;
  50048. t['Oslash'] = 778;
  50049. t['OE'] = 1000;
  50050. t['ordmasculine'] = 365;
  50051. t['ae'] = 889;
  50052. t['dotlessi'] = 278;
  50053. t['lslash'] = 278;
  50054. t['oslash'] = 611;
  50055. t['oe'] = 944;
  50056. t['germandbls'] = 611;
  50057. t['Idieresis'] = 278;
  50058. t['eacute'] = 556;
  50059. t['abreve'] = 556;
  50060. t['uhungarumlaut'] = 611;
  50061. t['ecaron'] = 556;
  50062. t['Ydieresis'] = 667;
  50063. t['divide'] = 584;
  50064. t['Yacute'] = 667;
  50065. t['Acircumflex'] = 722;
  50066. t['aacute'] = 556;
  50067. t['Ucircumflex'] = 722;
  50068. t['yacute'] = 556;
  50069. t['scommaaccent'] = 556;
  50070. t['ecircumflex'] = 556;
  50071. t['Uring'] = 722;
  50072. t['Udieresis'] = 722;
  50073. t['aogonek'] = 556;
  50074. t['Uacute'] = 722;
  50075. t['uogonek'] = 611;
  50076. t['Edieresis'] = 667;
  50077. t['Dcroat'] = 722;
  50078. t['commaaccent'] = 250;
  50079. t['copyright'] = 737;
  50080. t['Emacron'] = 667;
  50081. t['ccaron'] = 556;
  50082. t['aring'] = 556;
  50083. t['Ncommaaccent'] = 722;
  50084. t['lacute'] = 278;
  50085. t['agrave'] = 556;
  50086. t['Tcommaaccent'] = 611;
  50087. t['Cacute'] = 722;
  50088. t['atilde'] = 556;
  50089. t['Edotaccent'] = 667;
  50090. t['scaron'] = 556;
  50091. t['scedilla'] = 556;
  50092. t['iacute'] = 278;
  50093. t['lozenge'] = 494;
  50094. t['Rcaron'] = 722;
  50095. t['Gcommaaccent'] = 778;
  50096. t['ucircumflex'] = 611;
  50097. t['acircumflex'] = 556;
  50098. t['Amacron'] = 722;
  50099. t['rcaron'] = 389;
  50100. t['ccedilla'] = 556;
  50101. t['Zdotaccent'] = 611;
  50102. t['Thorn'] = 667;
  50103. t['Omacron'] = 778;
  50104. t['Racute'] = 722;
  50105. t['Sacute'] = 667;
  50106. t['dcaron'] = 743;
  50107. t['Umacron'] = 722;
  50108. t['uring'] = 611;
  50109. t['threesuperior'] = 333;
  50110. t['Ograve'] = 778;
  50111. t['Agrave'] = 722;
  50112. t['Abreve'] = 722;
  50113. t['multiply'] = 584;
  50114. t['uacute'] = 611;
  50115. t['Tcaron'] = 611;
  50116. t['partialdiff'] = 494;
  50117. t['ydieresis'] = 556;
  50118. t['Nacute'] = 722;
  50119. t['icircumflex'] = 278;
  50120. t['Ecircumflex'] = 667;
  50121. t['adieresis'] = 556;
  50122. t['edieresis'] = 556;
  50123. t['cacute'] = 556;
  50124. t['nacute'] = 611;
  50125. t['umacron'] = 611;
  50126. t['Ncaron'] = 722;
  50127. t['Iacute'] = 278;
  50128. t['plusminus'] = 584;
  50129. t['brokenbar'] = 280;
  50130. t['registered'] = 737;
  50131. t['Gbreve'] = 778;
  50132. t['Idotaccent'] = 278;
  50133. t['summation'] = 600;
  50134. t['Egrave'] = 667;
  50135. t['racute'] = 389;
  50136. t['omacron'] = 611;
  50137. t['Zacute'] = 611;
  50138. t['Zcaron'] = 611;
  50139. t['greaterequal'] = 549;
  50140. t['Eth'] = 722;
  50141. t['Ccedilla'] = 722;
  50142. t['lcommaaccent'] = 278;
  50143. t['tcaron'] = 389;
  50144. t['eogonek'] = 556;
  50145. t['Uogonek'] = 722;
  50146. t['Aacute'] = 722;
  50147. t['Adieresis'] = 722;
  50148. t['egrave'] = 556;
  50149. t['zacute'] = 500;
  50150. t['iogonek'] = 278;
  50151. t['Oacute'] = 778;
  50152. t['oacute'] = 611;
  50153. t['amacron'] = 556;
  50154. t['sacute'] = 556;
  50155. t['idieresis'] = 278;
  50156. t['Ocircumflex'] = 778;
  50157. t['Ugrave'] = 722;
  50158. t['Delta'] = 612;
  50159. t['thorn'] = 611;
  50160. t['twosuperior'] = 333;
  50161. t['Odieresis'] = 778;
  50162. t['mu'] = 611;
  50163. t['igrave'] = 278;
  50164. t['ohungarumlaut'] = 611;
  50165. t['Eogonek'] = 667;
  50166. t['dcroat'] = 611;
  50167. t['threequarters'] = 834;
  50168. t['Scedilla'] = 667;
  50169. t['lcaron'] = 400;
  50170. t['Kcommaaccent'] = 722;
  50171. t['Lacute'] = 611;
  50172. t['trademark'] = 1000;
  50173. t['edotaccent'] = 556;
  50174. t['Igrave'] = 278;
  50175. t['Imacron'] = 278;
  50176. t['Lcaron'] = 611;
  50177. t['onehalf'] = 834;
  50178. t['lessequal'] = 549;
  50179. t['ocircumflex'] = 611;
  50180. t['ntilde'] = 611;
  50181. t['Uhungarumlaut'] = 722;
  50182. t['Eacute'] = 667;
  50183. t['emacron'] = 556;
  50184. t['gbreve'] = 611;
  50185. t['onequarter'] = 834;
  50186. t['Scaron'] = 667;
  50187. t['Scommaaccent'] = 667;
  50188. t['Ohungarumlaut'] = 778;
  50189. t['degree'] = 400;
  50190. t['ograve'] = 611;
  50191. t['Ccaron'] = 722;
  50192. t['ugrave'] = 611;
  50193. t['radical'] = 549;
  50194. t['Dcaron'] = 722;
  50195. t['rcommaaccent'] = 389;
  50196. t['Ntilde'] = 722;
  50197. t['otilde'] = 611;
  50198. t['Rcommaaccent'] = 722;
  50199. t['Lcommaaccent'] = 611;
  50200. t['Atilde'] = 722;
  50201. t['Aogonek'] = 722;
  50202. t['Aring'] = 722;
  50203. t['Otilde'] = 778;
  50204. t['zdotaccent'] = 500;
  50205. t['Ecaron'] = 667;
  50206. t['Iogonek'] = 278;
  50207. t['kcommaaccent'] = 556;
  50208. t['minus'] = 584;
  50209. t['Icircumflex'] = 278;
  50210. t['ncaron'] = 611;
  50211. t['tcommaaccent'] = 333;
  50212. t['logicalnot'] = 584;
  50213. t['odieresis'] = 611;
  50214. t['udieresis'] = 611;
  50215. t['notequal'] = 549;
  50216. t['gcommaaccent'] = 611;
  50217. t['eth'] = 611;
  50218. t['zcaron'] = 500;
  50219. t['ncommaaccent'] = 611;
  50220. t['onesuperior'] = 333;
  50221. t['imacron'] = 278;
  50222. t['Euro'] = 556;
  50223. });
  50224. t['Helvetica-Oblique'] = getLookupTableFactory(function (t) {
  50225. t['space'] = 278;
  50226. t['exclam'] = 278;
  50227. t['quotedbl'] = 355;
  50228. t['numbersign'] = 556;
  50229. t['dollar'] = 556;
  50230. t['percent'] = 889;
  50231. t['ampersand'] = 667;
  50232. t['quoteright'] = 222;
  50233. t['parenleft'] = 333;
  50234. t['parenright'] = 333;
  50235. t['asterisk'] = 389;
  50236. t['plus'] = 584;
  50237. t['comma'] = 278;
  50238. t['hyphen'] = 333;
  50239. t['period'] = 278;
  50240. t['slash'] = 278;
  50241. t['zero'] = 556;
  50242. t['one'] = 556;
  50243. t['two'] = 556;
  50244. t['three'] = 556;
  50245. t['four'] = 556;
  50246. t['five'] = 556;
  50247. t['six'] = 556;
  50248. t['seven'] = 556;
  50249. t['eight'] = 556;
  50250. t['nine'] = 556;
  50251. t['colon'] = 278;
  50252. t['semicolon'] = 278;
  50253. t['less'] = 584;
  50254. t['equal'] = 584;
  50255. t['greater'] = 584;
  50256. t['question'] = 556;
  50257. t['at'] = 1015;
  50258. t['A'] = 667;
  50259. t['B'] = 667;
  50260. t['C'] = 722;
  50261. t['D'] = 722;
  50262. t['E'] = 667;
  50263. t['F'] = 611;
  50264. t['G'] = 778;
  50265. t['H'] = 722;
  50266. t['I'] = 278;
  50267. t['J'] = 500;
  50268. t['K'] = 667;
  50269. t['L'] = 556;
  50270. t['M'] = 833;
  50271. t['N'] = 722;
  50272. t['O'] = 778;
  50273. t['P'] = 667;
  50274. t['Q'] = 778;
  50275. t['R'] = 722;
  50276. t['S'] = 667;
  50277. t['T'] = 611;
  50278. t['U'] = 722;
  50279. t['V'] = 667;
  50280. t['W'] = 944;
  50281. t['X'] = 667;
  50282. t['Y'] = 667;
  50283. t['Z'] = 611;
  50284. t['bracketleft'] = 278;
  50285. t['backslash'] = 278;
  50286. t['bracketright'] = 278;
  50287. t['asciicircum'] = 469;
  50288. t['underscore'] = 556;
  50289. t['quoteleft'] = 222;
  50290. t['a'] = 556;
  50291. t['b'] = 556;
  50292. t['c'] = 500;
  50293. t['d'] = 556;
  50294. t['e'] = 556;
  50295. t['f'] = 278;
  50296. t['g'] = 556;
  50297. t['h'] = 556;
  50298. t['i'] = 222;
  50299. t['j'] = 222;
  50300. t['k'] = 500;
  50301. t['l'] = 222;
  50302. t['m'] = 833;
  50303. t['n'] = 556;
  50304. t['o'] = 556;
  50305. t['p'] = 556;
  50306. t['q'] = 556;
  50307. t['r'] = 333;
  50308. t['s'] = 500;
  50309. t['t'] = 278;
  50310. t['u'] = 556;
  50311. t['v'] = 500;
  50312. t['w'] = 722;
  50313. t['x'] = 500;
  50314. t['y'] = 500;
  50315. t['z'] = 500;
  50316. t['braceleft'] = 334;
  50317. t['bar'] = 260;
  50318. t['braceright'] = 334;
  50319. t['asciitilde'] = 584;
  50320. t['exclamdown'] = 333;
  50321. t['cent'] = 556;
  50322. t['sterling'] = 556;
  50323. t['fraction'] = 167;
  50324. t['yen'] = 556;
  50325. t['florin'] = 556;
  50326. t['section'] = 556;
  50327. t['currency'] = 556;
  50328. t['quotesingle'] = 191;
  50329. t['quotedblleft'] = 333;
  50330. t['guillemotleft'] = 556;
  50331. t['guilsinglleft'] = 333;
  50332. t['guilsinglright'] = 333;
  50333. t['fi'] = 500;
  50334. t['fl'] = 500;
  50335. t['endash'] = 556;
  50336. t['dagger'] = 556;
  50337. t['daggerdbl'] = 556;
  50338. t['periodcentered'] = 278;
  50339. t['paragraph'] = 537;
  50340. t['bullet'] = 350;
  50341. t['quotesinglbase'] = 222;
  50342. t['quotedblbase'] = 333;
  50343. t['quotedblright'] = 333;
  50344. t['guillemotright'] = 556;
  50345. t['ellipsis'] = 1000;
  50346. t['perthousand'] = 1000;
  50347. t['questiondown'] = 611;
  50348. t['grave'] = 333;
  50349. t['acute'] = 333;
  50350. t['circumflex'] = 333;
  50351. t['tilde'] = 333;
  50352. t['macron'] = 333;
  50353. t['breve'] = 333;
  50354. t['dotaccent'] = 333;
  50355. t['dieresis'] = 333;
  50356. t['ring'] = 333;
  50357. t['cedilla'] = 333;
  50358. t['hungarumlaut'] = 333;
  50359. t['ogonek'] = 333;
  50360. t['caron'] = 333;
  50361. t['emdash'] = 1000;
  50362. t['AE'] = 1000;
  50363. t['ordfeminine'] = 370;
  50364. t['Lslash'] = 556;
  50365. t['Oslash'] = 778;
  50366. t['OE'] = 1000;
  50367. t['ordmasculine'] = 365;
  50368. t['ae'] = 889;
  50369. t['dotlessi'] = 278;
  50370. t['lslash'] = 222;
  50371. t['oslash'] = 611;
  50372. t['oe'] = 944;
  50373. t['germandbls'] = 611;
  50374. t['Idieresis'] = 278;
  50375. t['eacute'] = 556;
  50376. t['abreve'] = 556;
  50377. t['uhungarumlaut'] = 556;
  50378. t['ecaron'] = 556;
  50379. t['Ydieresis'] = 667;
  50380. t['divide'] = 584;
  50381. t['Yacute'] = 667;
  50382. t['Acircumflex'] = 667;
  50383. t['aacute'] = 556;
  50384. t['Ucircumflex'] = 722;
  50385. t['yacute'] = 500;
  50386. t['scommaaccent'] = 500;
  50387. t['ecircumflex'] = 556;
  50388. t['Uring'] = 722;
  50389. t['Udieresis'] = 722;
  50390. t['aogonek'] = 556;
  50391. t['Uacute'] = 722;
  50392. t['uogonek'] = 556;
  50393. t['Edieresis'] = 667;
  50394. t['Dcroat'] = 722;
  50395. t['commaaccent'] = 250;
  50396. t['copyright'] = 737;
  50397. t['Emacron'] = 667;
  50398. t['ccaron'] = 500;
  50399. t['aring'] = 556;
  50400. t['Ncommaaccent'] = 722;
  50401. t['lacute'] = 222;
  50402. t['agrave'] = 556;
  50403. t['Tcommaaccent'] = 611;
  50404. t['Cacute'] = 722;
  50405. t['atilde'] = 556;
  50406. t['Edotaccent'] = 667;
  50407. t['scaron'] = 500;
  50408. t['scedilla'] = 500;
  50409. t['iacute'] = 278;
  50410. t['lozenge'] = 471;
  50411. t['Rcaron'] = 722;
  50412. t['Gcommaaccent'] = 778;
  50413. t['ucircumflex'] = 556;
  50414. t['acircumflex'] = 556;
  50415. t['Amacron'] = 667;
  50416. t['rcaron'] = 333;
  50417. t['ccedilla'] = 500;
  50418. t['Zdotaccent'] = 611;
  50419. t['Thorn'] = 667;
  50420. t['Omacron'] = 778;
  50421. t['Racute'] = 722;
  50422. t['Sacute'] = 667;
  50423. t['dcaron'] = 643;
  50424. t['Umacron'] = 722;
  50425. t['uring'] = 556;
  50426. t['threesuperior'] = 333;
  50427. t['Ograve'] = 778;
  50428. t['Agrave'] = 667;
  50429. t['Abreve'] = 667;
  50430. t['multiply'] = 584;
  50431. t['uacute'] = 556;
  50432. t['Tcaron'] = 611;
  50433. t['partialdiff'] = 476;
  50434. t['ydieresis'] = 500;
  50435. t['Nacute'] = 722;
  50436. t['icircumflex'] = 278;
  50437. t['Ecircumflex'] = 667;
  50438. t['adieresis'] = 556;
  50439. t['edieresis'] = 556;
  50440. t['cacute'] = 500;
  50441. t['nacute'] = 556;
  50442. t['umacron'] = 556;
  50443. t['Ncaron'] = 722;
  50444. t['Iacute'] = 278;
  50445. t['plusminus'] = 584;
  50446. t['brokenbar'] = 260;
  50447. t['registered'] = 737;
  50448. t['Gbreve'] = 778;
  50449. t['Idotaccent'] = 278;
  50450. t['summation'] = 600;
  50451. t['Egrave'] = 667;
  50452. t['racute'] = 333;
  50453. t['omacron'] = 556;
  50454. t['Zacute'] = 611;
  50455. t['Zcaron'] = 611;
  50456. t['greaterequal'] = 549;
  50457. t['Eth'] = 722;
  50458. t['Ccedilla'] = 722;
  50459. t['lcommaaccent'] = 222;
  50460. t['tcaron'] = 317;
  50461. t['eogonek'] = 556;
  50462. t['Uogonek'] = 722;
  50463. t['Aacute'] = 667;
  50464. t['Adieresis'] = 667;
  50465. t['egrave'] = 556;
  50466. t['zacute'] = 500;
  50467. t['iogonek'] = 222;
  50468. t['Oacute'] = 778;
  50469. t['oacute'] = 556;
  50470. t['amacron'] = 556;
  50471. t['sacute'] = 500;
  50472. t['idieresis'] = 278;
  50473. t['Ocircumflex'] = 778;
  50474. t['Ugrave'] = 722;
  50475. t['Delta'] = 612;
  50476. t['thorn'] = 556;
  50477. t['twosuperior'] = 333;
  50478. t['Odieresis'] = 778;
  50479. t['mu'] = 556;
  50480. t['igrave'] = 278;
  50481. t['ohungarumlaut'] = 556;
  50482. t['Eogonek'] = 667;
  50483. t['dcroat'] = 556;
  50484. t['threequarters'] = 834;
  50485. t['Scedilla'] = 667;
  50486. t['lcaron'] = 299;
  50487. t['Kcommaaccent'] = 667;
  50488. t['Lacute'] = 556;
  50489. t['trademark'] = 1000;
  50490. t['edotaccent'] = 556;
  50491. t['Igrave'] = 278;
  50492. t['Imacron'] = 278;
  50493. t['Lcaron'] = 556;
  50494. t['onehalf'] = 834;
  50495. t['lessequal'] = 549;
  50496. t['ocircumflex'] = 556;
  50497. t['ntilde'] = 556;
  50498. t['Uhungarumlaut'] = 722;
  50499. t['Eacute'] = 667;
  50500. t['emacron'] = 556;
  50501. t['gbreve'] = 556;
  50502. t['onequarter'] = 834;
  50503. t['Scaron'] = 667;
  50504. t['Scommaaccent'] = 667;
  50505. t['Ohungarumlaut'] = 778;
  50506. t['degree'] = 400;
  50507. t['ograve'] = 556;
  50508. t['Ccaron'] = 722;
  50509. t['ugrave'] = 556;
  50510. t['radical'] = 453;
  50511. t['Dcaron'] = 722;
  50512. t['rcommaaccent'] = 333;
  50513. t['Ntilde'] = 722;
  50514. t['otilde'] = 556;
  50515. t['Rcommaaccent'] = 722;
  50516. t['Lcommaaccent'] = 556;
  50517. t['Atilde'] = 667;
  50518. t['Aogonek'] = 667;
  50519. t['Aring'] = 667;
  50520. t['Otilde'] = 778;
  50521. t['zdotaccent'] = 500;
  50522. t['Ecaron'] = 667;
  50523. t['Iogonek'] = 278;
  50524. t['kcommaaccent'] = 500;
  50525. t['minus'] = 584;
  50526. t['Icircumflex'] = 278;
  50527. t['ncaron'] = 556;
  50528. t['tcommaaccent'] = 278;
  50529. t['logicalnot'] = 584;
  50530. t['odieresis'] = 556;
  50531. t['udieresis'] = 556;
  50532. t['notequal'] = 549;
  50533. t['gcommaaccent'] = 556;
  50534. t['eth'] = 556;
  50535. t['zcaron'] = 500;
  50536. t['ncommaaccent'] = 556;
  50537. t['onesuperior'] = 333;
  50538. t['imacron'] = 278;
  50539. t['Euro'] = 556;
  50540. });
  50541. t['Symbol'] = getLookupTableFactory(function (t) {
  50542. t['space'] = 250;
  50543. t['exclam'] = 333;
  50544. t['universal'] = 713;
  50545. t['numbersign'] = 500;
  50546. t['existential'] = 549;
  50547. t['percent'] = 833;
  50548. t['ampersand'] = 778;
  50549. t['suchthat'] = 439;
  50550. t['parenleft'] = 333;
  50551. t['parenright'] = 333;
  50552. t['asteriskmath'] = 500;
  50553. t['plus'] = 549;
  50554. t['comma'] = 250;
  50555. t['minus'] = 549;
  50556. t['period'] = 250;
  50557. t['slash'] = 278;
  50558. t['zero'] = 500;
  50559. t['one'] = 500;
  50560. t['two'] = 500;
  50561. t['three'] = 500;
  50562. t['four'] = 500;
  50563. t['five'] = 500;
  50564. t['six'] = 500;
  50565. t['seven'] = 500;
  50566. t['eight'] = 500;
  50567. t['nine'] = 500;
  50568. t['colon'] = 278;
  50569. t['semicolon'] = 278;
  50570. t['less'] = 549;
  50571. t['equal'] = 549;
  50572. t['greater'] = 549;
  50573. t['question'] = 444;
  50574. t['congruent'] = 549;
  50575. t['Alpha'] = 722;
  50576. t['Beta'] = 667;
  50577. t['Chi'] = 722;
  50578. t['Delta'] = 612;
  50579. t['Epsilon'] = 611;
  50580. t['Phi'] = 763;
  50581. t['Gamma'] = 603;
  50582. t['Eta'] = 722;
  50583. t['Iota'] = 333;
  50584. t['theta1'] = 631;
  50585. t['Kappa'] = 722;
  50586. t['Lambda'] = 686;
  50587. t['Mu'] = 889;
  50588. t['Nu'] = 722;
  50589. t['Omicron'] = 722;
  50590. t['Pi'] = 768;
  50591. t['Theta'] = 741;
  50592. t['Rho'] = 556;
  50593. t['Sigma'] = 592;
  50594. t['Tau'] = 611;
  50595. t['Upsilon'] = 690;
  50596. t['sigma1'] = 439;
  50597. t['Omega'] = 768;
  50598. t['Xi'] = 645;
  50599. t['Psi'] = 795;
  50600. t['Zeta'] = 611;
  50601. t['bracketleft'] = 333;
  50602. t['therefore'] = 863;
  50603. t['bracketright'] = 333;
  50604. t['perpendicular'] = 658;
  50605. t['underscore'] = 500;
  50606. t['radicalex'] = 500;
  50607. t['alpha'] = 631;
  50608. t['beta'] = 549;
  50609. t['chi'] = 549;
  50610. t['delta'] = 494;
  50611. t['epsilon'] = 439;
  50612. t['phi'] = 521;
  50613. t['gamma'] = 411;
  50614. t['eta'] = 603;
  50615. t['iota'] = 329;
  50616. t['phi1'] = 603;
  50617. t['kappa'] = 549;
  50618. t['lambda'] = 549;
  50619. t['mu'] = 576;
  50620. t['nu'] = 521;
  50621. t['omicron'] = 549;
  50622. t['pi'] = 549;
  50623. t['theta'] = 521;
  50624. t['rho'] = 549;
  50625. t['sigma'] = 603;
  50626. t['tau'] = 439;
  50627. t['upsilon'] = 576;
  50628. t['omega1'] = 713;
  50629. t['omega'] = 686;
  50630. t['xi'] = 493;
  50631. t['psi'] = 686;
  50632. t['zeta'] = 494;
  50633. t['braceleft'] = 480;
  50634. t['bar'] = 200;
  50635. t['braceright'] = 480;
  50636. t['similar'] = 549;
  50637. t['Euro'] = 750;
  50638. t['Upsilon1'] = 620;
  50639. t['minute'] = 247;
  50640. t['lessequal'] = 549;
  50641. t['fraction'] = 167;
  50642. t['infinity'] = 713;
  50643. t['florin'] = 500;
  50644. t['club'] = 753;
  50645. t['diamond'] = 753;
  50646. t['heart'] = 753;
  50647. t['spade'] = 753;
  50648. t['arrowboth'] = 1042;
  50649. t['arrowleft'] = 987;
  50650. t['arrowup'] = 603;
  50651. t['arrowright'] = 987;
  50652. t['arrowdown'] = 603;
  50653. t['degree'] = 400;
  50654. t['plusminus'] = 549;
  50655. t['second'] = 411;
  50656. t['greaterequal'] = 549;
  50657. t['multiply'] = 549;
  50658. t['proportional'] = 713;
  50659. t['partialdiff'] = 494;
  50660. t['bullet'] = 460;
  50661. t['divide'] = 549;
  50662. t['notequal'] = 549;
  50663. t['equivalence'] = 549;
  50664. t['approxequal'] = 549;
  50665. t['ellipsis'] = 1000;
  50666. t['arrowvertex'] = 603;
  50667. t['arrowhorizex'] = 1000;
  50668. t['carriagereturn'] = 658;
  50669. t['aleph'] = 823;
  50670. t['Ifraktur'] = 686;
  50671. t['Rfraktur'] = 795;
  50672. t['weierstrass'] = 987;
  50673. t['circlemultiply'] = 768;
  50674. t['circleplus'] = 768;
  50675. t['emptyset'] = 823;
  50676. t['intersection'] = 768;
  50677. t['union'] = 768;
  50678. t['propersuperset'] = 713;
  50679. t['reflexsuperset'] = 713;
  50680. t['notsubset'] = 713;
  50681. t['propersubset'] = 713;
  50682. t['reflexsubset'] = 713;
  50683. t['element'] = 713;
  50684. t['notelement'] = 713;
  50685. t['angle'] = 768;
  50686. t['gradient'] = 713;
  50687. t['registerserif'] = 790;
  50688. t['copyrightserif'] = 790;
  50689. t['trademarkserif'] = 890;
  50690. t['product'] = 823;
  50691. t['radical'] = 549;
  50692. t['dotmath'] = 250;
  50693. t['logicalnot'] = 713;
  50694. t['logicaland'] = 603;
  50695. t['logicalor'] = 603;
  50696. t['arrowdblboth'] = 1042;
  50697. t['arrowdblleft'] = 987;
  50698. t['arrowdblup'] = 603;
  50699. t['arrowdblright'] = 987;
  50700. t['arrowdbldown'] = 603;
  50701. t['lozenge'] = 494;
  50702. t['angleleft'] = 329;
  50703. t['registersans'] = 790;
  50704. t['copyrightsans'] = 790;
  50705. t['trademarksans'] = 786;
  50706. t['summation'] = 713;
  50707. t['parenlefttp'] = 384;
  50708. t['parenleftex'] = 384;
  50709. t['parenleftbt'] = 384;
  50710. t['bracketlefttp'] = 384;
  50711. t['bracketleftex'] = 384;
  50712. t['bracketleftbt'] = 384;
  50713. t['bracelefttp'] = 494;
  50714. t['braceleftmid'] = 494;
  50715. t['braceleftbt'] = 494;
  50716. t['braceex'] = 494;
  50717. t['angleright'] = 329;
  50718. t['integral'] = 274;
  50719. t['integraltp'] = 686;
  50720. t['integralex'] = 686;
  50721. t['integralbt'] = 686;
  50722. t['parenrighttp'] = 384;
  50723. t['parenrightex'] = 384;
  50724. t['parenrightbt'] = 384;
  50725. t['bracketrighttp'] = 384;
  50726. t['bracketrightex'] = 384;
  50727. t['bracketrightbt'] = 384;
  50728. t['bracerighttp'] = 494;
  50729. t['bracerightmid'] = 494;
  50730. t['bracerightbt'] = 494;
  50731. t['apple'] = 790;
  50732. });
  50733. t['Times-Roman'] = getLookupTableFactory(function (t) {
  50734. t['space'] = 250;
  50735. t['exclam'] = 333;
  50736. t['quotedbl'] = 408;
  50737. t['numbersign'] = 500;
  50738. t['dollar'] = 500;
  50739. t['percent'] = 833;
  50740. t['ampersand'] = 778;
  50741. t['quoteright'] = 333;
  50742. t['parenleft'] = 333;
  50743. t['parenright'] = 333;
  50744. t['asterisk'] = 500;
  50745. t['plus'] = 564;
  50746. t['comma'] = 250;
  50747. t['hyphen'] = 333;
  50748. t['period'] = 250;
  50749. t['slash'] = 278;
  50750. t['zero'] = 500;
  50751. t['one'] = 500;
  50752. t['two'] = 500;
  50753. t['three'] = 500;
  50754. t['four'] = 500;
  50755. t['five'] = 500;
  50756. t['six'] = 500;
  50757. t['seven'] = 500;
  50758. t['eight'] = 500;
  50759. t['nine'] = 500;
  50760. t['colon'] = 278;
  50761. t['semicolon'] = 278;
  50762. t['less'] = 564;
  50763. t['equal'] = 564;
  50764. t['greater'] = 564;
  50765. t['question'] = 444;
  50766. t['at'] = 921;
  50767. t['A'] = 722;
  50768. t['B'] = 667;
  50769. t['C'] = 667;
  50770. t['D'] = 722;
  50771. t['E'] = 611;
  50772. t['F'] = 556;
  50773. t['G'] = 722;
  50774. t['H'] = 722;
  50775. t['I'] = 333;
  50776. t['J'] = 389;
  50777. t['K'] = 722;
  50778. t['L'] = 611;
  50779. t['M'] = 889;
  50780. t['N'] = 722;
  50781. t['O'] = 722;
  50782. t['P'] = 556;
  50783. t['Q'] = 722;
  50784. t['R'] = 667;
  50785. t['S'] = 556;
  50786. t['T'] = 611;
  50787. t['U'] = 722;
  50788. t['V'] = 722;
  50789. t['W'] = 944;
  50790. t['X'] = 722;
  50791. t['Y'] = 722;
  50792. t['Z'] = 611;
  50793. t['bracketleft'] = 333;
  50794. t['backslash'] = 278;
  50795. t['bracketright'] = 333;
  50796. t['asciicircum'] = 469;
  50797. t['underscore'] = 500;
  50798. t['quoteleft'] = 333;
  50799. t['a'] = 444;
  50800. t['b'] = 500;
  50801. t['c'] = 444;
  50802. t['d'] = 500;
  50803. t['e'] = 444;
  50804. t['f'] = 333;
  50805. t['g'] = 500;
  50806. t['h'] = 500;
  50807. t['i'] = 278;
  50808. t['j'] = 278;
  50809. t['k'] = 500;
  50810. t['l'] = 278;
  50811. t['m'] = 778;
  50812. t['n'] = 500;
  50813. t['o'] = 500;
  50814. t['p'] = 500;
  50815. t['q'] = 500;
  50816. t['r'] = 333;
  50817. t['s'] = 389;
  50818. t['t'] = 278;
  50819. t['u'] = 500;
  50820. t['v'] = 500;
  50821. t['w'] = 722;
  50822. t['x'] = 500;
  50823. t['y'] = 500;
  50824. t['z'] = 444;
  50825. t['braceleft'] = 480;
  50826. t['bar'] = 200;
  50827. t['braceright'] = 480;
  50828. t['asciitilde'] = 541;
  50829. t['exclamdown'] = 333;
  50830. t['cent'] = 500;
  50831. t['sterling'] = 500;
  50832. t['fraction'] = 167;
  50833. t['yen'] = 500;
  50834. t['florin'] = 500;
  50835. t['section'] = 500;
  50836. t['currency'] = 500;
  50837. t['quotesingle'] = 180;
  50838. t['quotedblleft'] = 444;
  50839. t['guillemotleft'] = 500;
  50840. t['guilsinglleft'] = 333;
  50841. t['guilsinglright'] = 333;
  50842. t['fi'] = 556;
  50843. t['fl'] = 556;
  50844. t['endash'] = 500;
  50845. t['dagger'] = 500;
  50846. t['daggerdbl'] = 500;
  50847. t['periodcentered'] = 250;
  50848. t['paragraph'] = 453;
  50849. t['bullet'] = 350;
  50850. t['quotesinglbase'] = 333;
  50851. t['quotedblbase'] = 444;
  50852. t['quotedblright'] = 444;
  50853. t['guillemotright'] = 500;
  50854. t['ellipsis'] = 1000;
  50855. t['perthousand'] = 1000;
  50856. t['questiondown'] = 444;
  50857. t['grave'] = 333;
  50858. t['acute'] = 333;
  50859. t['circumflex'] = 333;
  50860. t['tilde'] = 333;
  50861. t['macron'] = 333;
  50862. t['breve'] = 333;
  50863. t['dotaccent'] = 333;
  50864. t['dieresis'] = 333;
  50865. t['ring'] = 333;
  50866. t['cedilla'] = 333;
  50867. t['hungarumlaut'] = 333;
  50868. t['ogonek'] = 333;
  50869. t['caron'] = 333;
  50870. t['emdash'] = 1000;
  50871. t['AE'] = 889;
  50872. t['ordfeminine'] = 276;
  50873. t['Lslash'] = 611;
  50874. t['Oslash'] = 722;
  50875. t['OE'] = 889;
  50876. t['ordmasculine'] = 310;
  50877. t['ae'] = 667;
  50878. t['dotlessi'] = 278;
  50879. t['lslash'] = 278;
  50880. t['oslash'] = 500;
  50881. t['oe'] = 722;
  50882. t['germandbls'] = 500;
  50883. t['Idieresis'] = 333;
  50884. t['eacute'] = 444;
  50885. t['abreve'] = 444;
  50886. t['uhungarumlaut'] = 500;
  50887. t['ecaron'] = 444;
  50888. t['Ydieresis'] = 722;
  50889. t['divide'] = 564;
  50890. t['Yacute'] = 722;
  50891. t['Acircumflex'] = 722;
  50892. t['aacute'] = 444;
  50893. t['Ucircumflex'] = 722;
  50894. t['yacute'] = 500;
  50895. t['scommaaccent'] = 389;
  50896. t['ecircumflex'] = 444;
  50897. t['Uring'] = 722;
  50898. t['Udieresis'] = 722;
  50899. t['aogonek'] = 444;
  50900. t['Uacute'] = 722;
  50901. t['uogonek'] = 500;
  50902. t['Edieresis'] = 611;
  50903. t['Dcroat'] = 722;
  50904. t['commaaccent'] = 250;
  50905. t['copyright'] = 760;
  50906. t['Emacron'] = 611;
  50907. t['ccaron'] = 444;
  50908. t['aring'] = 444;
  50909. t['Ncommaaccent'] = 722;
  50910. t['lacute'] = 278;
  50911. t['agrave'] = 444;
  50912. t['Tcommaaccent'] = 611;
  50913. t['Cacute'] = 667;
  50914. t['atilde'] = 444;
  50915. t['Edotaccent'] = 611;
  50916. t['scaron'] = 389;
  50917. t['scedilla'] = 389;
  50918. t['iacute'] = 278;
  50919. t['lozenge'] = 471;
  50920. t['Rcaron'] = 667;
  50921. t['Gcommaaccent'] = 722;
  50922. t['ucircumflex'] = 500;
  50923. t['acircumflex'] = 444;
  50924. t['Amacron'] = 722;
  50925. t['rcaron'] = 333;
  50926. t['ccedilla'] = 444;
  50927. t['Zdotaccent'] = 611;
  50928. t['Thorn'] = 556;
  50929. t['Omacron'] = 722;
  50930. t['Racute'] = 667;
  50931. t['Sacute'] = 556;
  50932. t['dcaron'] = 588;
  50933. t['Umacron'] = 722;
  50934. t['uring'] = 500;
  50935. t['threesuperior'] = 300;
  50936. t['Ograve'] = 722;
  50937. t['Agrave'] = 722;
  50938. t['Abreve'] = 722;
  50939. t['multiply'] = 564;
  50940. t['uacute'] = 500;
  50941. t['Tcaron'] = 611;
  50942. t['partialdiff'] = 476;
  50943. t['ydieresis'] = 500;
  50944. t['Nacute'] = 722;
  50945. t['icircumflex'] = 278;
  50946. t['Ecircumflex'] = 611;
  50947. t['adieresis'] = 444;
  50948. t['edieresis'] = 444;
  50949. t['cacute'] = 444;
  50950. t['nacute'] = 500;
  50951. t['umacron'] = 500;
  50952. t['Ncaron'] = 722;
  50953. t['Iacute'] = 333;
  50954. t['plusminus'] = 564;
  50955. t['brokenbar'] = 200;
  50956. t['registered'] = 760;
  50957. t['Gbreve'] = 722;
  50958. t['Idotaccent'] = 333;
  50959. t['summation'] = 600;
  50960. t['Egrave'] = 611;
  50961. t['racute'] = 333;
  50962. t['omacron'] = 500;
  50963. t['Zacute'] = 611;
  50964. t['Zcaron'] = 611;
  50965. t['greaterequal'] = 549;
  50966. t['Eth'] = 722;
  50967. t['Ccedilla'] = 667;
  50968. t['lcommaaccent'] = 278;
  50969. t['tcaron'] = 326;
  50970. t['eogonek'] = 444;
  50971. t['Uogonek'] = 722;
  50972. t['Aacute'] = 722;
  50973. t['Adieresis'] = 722;
  50974. t['egrave'] = 444;
  50975. t['zacute'] = 444;
  50976. t['iogonek'] = 278;
  50977. t['Oacute'] = 722;
  50978. t['oacute'] = 500;
  50979. t['amacron'] = 444;
  50980. t['sacute'] = 389;
  50981. t['idieresis'] = 278;
  50982. t['Ocircumflex'] = 722;
  50983. t['Ugrave'] = 722;
  50984. t['Delta'] = 612;
  50985. t['thorn'] = 500;
  50986. t['twosuperior'] = 300;
  50987. t['Odieresis'] = 722;
  50988. t['mu'] = 500;
  50989. t['igrave'] = 278;
  50990. t['ohungarumlaut'] = 500;
  50991. t['Eogonek'] = 611;
  50992. t['dcroat'] = 500;
  50993. t['threequarters'] = 750;
  50994. t['Scedilla'] = 556;
  50995. t['lcaron'] = 344;
  50996. t['Kcommaaccent'] = 722;
  50997. t['Lacute'] = 611;
  50998. t['trademark'] = 980;
  50999. t['edotaccent'] = 444;
  51000. t['Igrave'] = 333;
  51001. t['Imacron'] = 333;
  51002. t['Lcaron'] = 611;
  51003. t['onehalf'] = 750;
  51004. t['lessequal'] = 549;
  51005. t['ocircumflex'] = 500;
  51006. t['ntilde'] = 500;
  51007. t['Uhungarumlaut'] = 722;
  51008. t['Eacute'] = 611;
  51009. t['emacron'] = 444;
  51010. t['gbreve'] = 500;
  51011. t['onequarter'] = 750;
  51012. t['Scaron'] = 556;
  51013. t['Scommaaccent'] = 556;
  51014. t['Ohungarumlaut'] = 722;
  51015. t['degree'] = 400;
  51016. t['ograve'] = 500;
  51017. t['Ccaron'] = 667;
  51018. t['ugrave'] = 500;
  51019. t['radical'] = 453;
  51020. t['Dcaron'] = 722;
  51021. t['rcommaaccent'] = 333;
  51022. t['Ntilde'] = 722;
  51023. t['otilde'] = 500;
  51024. t['Rcommaaccent'] = 667;
  51025. t['Lcommaaccent'] = 611;
  51026. t['Atilde'] = 722;
  51027. t['Aogonek'] = 722;
  51028. t['Aring'] = 722;
  51029. t['Otilde'] = 722;
  51030. t['zdotaccent'] = 444;
  51031. t['Ecaron'] = 611;
  51032. t['Iogonek'] = 333;
  51033. t['kcommaaccent'] = 500;
  51034. t['minus'] = 564;
  51035. t['Icircumflex'] = 333;
  51036. t['ncaron'] = 500;
  51037. t['tcommaaccent'] = 278;
  51038. t['logicalnot'] = 564;
  51039. t['odieresis'] = 500;
  51040. t['udieresis'] = 500;
  51041. t['notequal'] = 549;
  51042. t['gcommaaccent'] = 500;
  51043. t['eth'] = 500;
  51044. t['zcaron'] = 444;
  51045. t['ncommaaccent'] = 500;
  51046. t['onesuperior'] = 300;
  51047. t['imacron'] = 278;
  51048. t['Euro'] = 500;
  51049. });
  51050. t['Times-Bold'] = getLookupTableFactory(function (t) {
  51051. t['space'] = 250;
  51052. t['exclam'] = 333;
  51053. t['quotedbl'] = 555;
  51054. t['numbersign'] = 500;
  51055. t['dollar'] = 500;
  51056. t['percent'] = 1000;
  51057. t['ampersand'] = 833;
  51058. t['quoteright'] = 333;
  51059. t['parenleft'] = 333;
  51060. t['parenright'] = 333;
  51061. t['asterisk'] = 500;
  51062. t['plus'] = 570;
  51063. t['comma'] = 250;
  51064. t['hyphen'] = 333;
  51065. t['period'] = 250;
  51066. t['slash'] = 278;
  51067. t['zero'] = 500;
  51068. t['one'] = 500;
  51069. t['two'] = 500;
  51070. t['three'] = 500;
  51071. t['four'] = 500;
  51072. t['five'] = 500;
  51073. t['six'] = 500;
  51074. t['seven'] = 500;
  51075. t['eight'] = 500;
  51076. t['nine'] = 500;
  51077. t['colon'] = 333;
  51078. t['semicolon'] = 333;
  51079. t['less'] = 570;
  51080. t['equal'] = 570;
  51081. t['greater'] = 570;
  51082. t['question'] = 500;
  51083. t['at'] = 930;
  51084. t['A'] = 722;
  51085. t['B'] = 667;
  51086. t['C'] = 722;
  51087. t['D'] = 722;
  51088. t['E'] = 667;
  51089. t['F'] = 611;
  51090. t['G'] = 778;
  51091. t['H'] = 778;
  51092. t['I'] = 389;
  51093. t['J'] = 500;
  51094. t['K'] = 778;
  51095. t['L'] = 667;
  51096. t['M'] = 944;
  51097. t['N'] = 722;
  51098. t['O'] = 778;
  51099. t['P'] = 611;
  51100. t['Q'] = 778;
  51101. t['R'] = 722;
  51102. t['S'] = 556;
  51103. t['T'] = 667;
  51104. t['U'] = 722;
  51105. t['V'] = 722;
  51106. t['W'] = 1000;
  51107. t['X'] = 722;
  51108. t['Y'] = 722;
  51109. t['Z'] = 667;
  51110. t['bracketleft'] = 333;
  51111. t['backslash'] = 278;
  51112. t['bracketright'] = 333;
  51113. t['asciicircum'] = 581;
  51114. t['underscore'] = 500;
  51115. t['quoteleft'] = 333;
  51116. t['a'] = 500;
  51117. t['b'] = 556;
  51118. t['c'] = 444;
  51119. t['d'] = 556;
  51120. t['e'] = 444;
  51121. t['f'] = 333;
  51122. t['g'] = 500;
  51123. t['h'] = 556;
  51124. t['i'] = 278;
  51125. t['j'] = 333;
  51126. t['k'] = 556;
  51127. t['l'] = 278;
  51128. t['m'] = 833;
  51129. t['n'] = 556;
  51130. t['o'] = 500;
  51131. t['p'] = 556;
  51132. t['q'] = 556;
  51133. t['r'] = 444;
  51134. t['s'] = 389;
  51135. t['t'] = 333;
  51136. t['u'] = 556;
  51137. t['v'] = 500;
  51138. t['w'] = 722;
  51139. t['x'] = 500;
  51140. t['y'] = 500;
  51141. t['z'] = 444;
  51142. t['braceleft'] = 394;
  51143. t['bar'] = 220;
  51144. t['braceright'] = 394;
  51145. t['asciitilde'] = 520;
  51146. t['exclamdown'] = 333;
  51147. t['cent'] = 500;
  51148. t['sterling'] = 500;
  51149. t['fraction'] = 167;
  51150. t['yen'] = 500;
  51151. t['florin'] = 500;
  51152. t['section'] = 500;
  51153. t['currency'] = 500;
  51154. t['quotesingle'] = 278;
  51155. t['quotedblleft'] = 500;
  51156. t['guillemotleft'] = 500;
  51157. t['guilsinglleft'] = 333;
  51158. t['guilsinglright'] = 333;
  51159. t['fi'] = 556;
  51160. t['fl'] = 556;
  51161. t['endash'] = 500;
  51162. t['dagger'] = 500;
  51163. t['daggerdbl'] = 500;
  51164. t['periodcentered'] = 250;
  51165. t['paragraph'] = 540;
  51166. t['bullet'] = 350;
  51167. t['quotesinglbase'] = 333;
  51168. t['quotedblbase'] = 500;
  51169. t['quotedblright'] = 500;
  51170. t['guillemotright'] = 500;
  51171. t['ellipsis'] = 1000;
  51172. t['perthousand'] = 1000;
  51173. t['questiondown'] = 500;
  51174. t['grave'] = 333;
  51175. t['acute'] = 333;
  51176. t['circumflex'] = 333;
  51177. t['tilde'] = 333;
  51178. t['macron'] = 333;
  51179. t['breve'] = 333;
  51180. t['dotaccent'] = 333;
  51181. t['dieresis'] = 333;
  51182. t['ring'] = 333;
  51183. t['cedilla'] = 333;
  51184. t['hungarumlaut'] = 333;
  51185. t['ogonek'] = 333;
  51186. t['caron'] = 333;
  51187. t['emdash'] = 1000;
  51188. t['AE'] = 1000;
  51189. t['ordfeminine'] = 300;
  51190. t['Lslash'] = 667;
  51191. t['Oslash'] = 778;
  51192. t['OE'] = 1000;
  51193. t['ordmasculine'] = 330;
  51194. t['ae'] = 722;
  51195. t['dotlessi'] = 278;
  51196. t['lslash'] = 278;
  51197. t['oslash'] = 500;
  51198. t['oe'] = 722;
  51199. t['germandbls'] = 556;
  51200. t['Idieresis'] = 389;
  51201. t['eacute'] = 444;
  51202. t['abreve'] = 500;
  51203. t['uhungarumlaut'] = 556;
  51204. t['ecaron'] = 444;
  51205. t['Ydieresis'] = 722;
  51206. t['divide'] = 570;
  51207. t['Yacute'] = 722;
  51208. t['Acircumflex'] = 722;
  51209. t['aacute'] = 500;
  51210. t['Ucircumflex'] = 722;
  51211. t['yacute'] = 500;
  51212. t['scommaaccent'] = 389;
  51213. t['ecircumflex'] = 444;
  51214. t['Uring'] = 722;
  51215. t['Udieresis'] = 722;
  51216. t['aogonek'] = 500;
  51217. t['Uacute'] = 722;
  51218. t['uogonek'] = 556;
  51219. t['Edieresis'] = 667;
  51220. t['Dcroat'] = 722;
  51221. t['commaaccent'] = 250;
  51222. t['copyright'] = 747;
  51223. t['Emacron'] = 667;
  51224. t['ccaron'] = 444;
  51225. t['aring'] = 500;
  51226. t['Ncommaaccent'] = 722;
  51227. t['lacute'] = 278;
  51228. t['agrave'] = 500;
  51229. t['Tcommaaccent'] = 667;
  51230. t['Cacute'] = 722;
  51231. t['atilde'] = 500;
  51232. t['Edotaccent'] = 667;
  51233. t['scaron'] = 389;
  51234. t['scedilla'] = 389;
  51235. t['iacute'] = 278;
  51236. t['lozenge'] = 494;
  51237. t['Rcaron'] = 722;
  51238. t['Gcommaaccent'] = 778;
  51239. t['ucircumflex'] = 556;
  51240. t['acircumflex'] = 500;
  51241. t['Amacron'] = 722;
  51242. t['rcaron'] = 444;
  51243. t['ccedilla'] = 444;
  51244. t['Zdotaccent'] = 667;
  51245. t['Thorn'] = 611;
  51246. t['Omacron'] = 778;
  51247. t['Racute'] = 722;
  51248. t['Sacute'] = 556;
  51249. t['dcaron'] = 672;
  51250. t['Umacron'] = 722;
  51251. t['uring'] = 556;
  51252. t['threesuperior'] = 300;
  51253. t['Ograve'] = 778;
  51254. t['Agrave'] = 722;
  51255. t['Abreve'] = 722;
  51256. t['multiply'] = 570;
  51257. t['uacute'] = 556;
  51258. t['Tcaron'] = 667;
  51259. t['partialdiff'] = 494;
  51260. t['ydieresis'] = 500;
  51261. t['Nacute'] = 722;
  51262. t['icircumflex'] = 278;
  51263. t['Ecircumflex'] = 667;
  51264. t['adieresis'] = 500;
  51265. t['edieresis'] = 444;
  51266. t['cacute'] = 444;
  51267. t['nacute'] = 556;
  51268. t['umacron'] = 556;
  51269. t['Ncaron'] = 722;
  51270. t['Iacute'] = 389;
  51271. t['plusminus'] = 570;
  51272. t['brokenbar'] = 220;
  51273. t['registered'] = 747;
  51274. t['Gbreve'] = 778;
  51275. t['Idotaccent'] = 389;
  51276. t['summation'] = 600;
  51277. t['Egrave'] = 667;
  51278. t['racute'] = 444;
  51279. t['omacron'] = 500;
  51280. t['Zacute'] = 667;
  51281. t['Zcaron'] = 667;
  51282. t['greaterequal'] = 549;
  51283. t['Eth'] = 722;
  51284. t['Ccedilla'] = 722;
  51285. t['lcommaaccent'] = 278;
  51286. t['tcaron'] = 416;
  51287. t['eogonek'] = 444;
  51288. t['Uogonek'] = 722;
  51289. t['Aacute'] = 722;
  51290. t['Adieresis'] = 722;
  51291. t['egrave'] = 444;
  51292. t['zacute'] = 444;
  51293. t['iogonek'] = 278;
  51294. t['Oacute'] = 778;
  51295. t['oacute'] = 500;
  51296. t['amacron'] = 500;
  51297. t['sacute'] = 389;
  51298. t['idieresis'] = 278;
  51299. t['Ocircumflex'] = 778;
  51300. t['Ugrave'] = 722;
  51301. t['Delta'] = 612;
  51302. t['thorn'] = 556;
  51303. t['twosuperior'] = 300;
  51304. t['Odieresis'] = 778;
  51305. t['mu'] = 556;
  51306. t['igrave'] = 278;
  51307. t['ohungarumlaut'] = 500;
  51308. t['Eogonek'] = 667;
  51309. t['dcroat'] = 556;
  51310. t['threequarters'] = 750;
  51311. t['Scedilla'] = 556;
  51312. t['lcaron'] = 394;
  51313. t['Kcommaaccent'] = 778;
  51314. t['Lacute'] = 667;
  51315. t['trademark'] = 1000;
  51316. t['edotaccent'] = 444;
  51317. t['Igrave'] = 389;
  51318. t['Imacron'] = 389;
  51319. t['Lcaron'] = 667;
  51320. t['onehalf'] = 750;
  51321. t['lessequal'] = 549;
  51322. t['ocircumflex'] = 500;
  51323. t['ntilde'] = 556;
  51324. t['Uhungarumlaut'] = 722;
  51325. t['Eacute'] = 667;
  51326. t['emacron'] = 444;
  51327. t['gbreve'] = 500;
  51328. t['onequarter'] = 750;
  51329. t['Scaron'] = 556;
  51330. t['Scommaaccent'] = 556;
  51331. t['Ohungarumlaut'] = 778;
  51332. t['degree'] = 400;
  51333. t['ograve'] = 500;
  51334. t['Ccaron'] = 722;
  51335. t['ugrave'] = 556;
  51336. t['radical'] = 549;
  51337. t['Dcaron'] = 722;
  51338. t['rcommaaccent'] = 444;
  51339. t['Ntilde'] = 722;
  51340. t['otilde'] = 500;
  51341. t['Rcommaaccent'] = 722;
  51342. t['Lcommaaccent'] = 667;
  51343. t['Atilde'] = 722;
  51344. t['Aogonek'] = 722;
  51345. t['Aring'] = 722;
  51346. t['Otilde'] = 778;
  51347. t['zdotaccent'] = 444;
  51348. t['Ecaron'] = 667;
  51349. t['Iogonek'] = 389;
  51350. t['kcommaaccent'] = 556;
  51351. t['minus'] = 570;
  51352. t['Icircumflex'] = 389;
  51353. t['ncaron'] = 556;
  51354. t['tcommaaccent'] = 333;
  51355. t['logicalnot'] = 570;
  51356. t['odieresis'] = 500;
  51357. t['udieresis'] = 556;
  51358. t['notequal'] = 549;
  51359. t['gcommaaccent'] = 500;
  51360. t['eth'] = 500;
  51361. t['zcaron'] = 444;
  51362. t['ncommaaccent'] = 556;
  51363. t['onesuperior'] = 300;
  51364. t['imacron'] = 278;
  51365. t['Euro'] = 500;
  51366. });
  51367. t['Times-BoldItalic'] = getLookupTableFactory(function (t) {
  51368. t['space'] = 250;
  51369. t['exclam'] = 389;
  51370. t['quotedbl'] = 555;
  51371. t['numbersign'] = 500;
  51372. t['dollar'] = 500;
  51373. t['percent'] = 833;
  51374. t['ampersand'] = 778;
  51375. t['quoteright'] = 333;
  51376. t['parenleft'] = 333;
  51377. t['parenright'] = 333;
  51378. t['asterisk'] = 500;
  51379. t['plus'] = 570;
  51380. t['comma'] = 250;
  51381. t['hyphen'] = 333;
  51382. t['period'] = 250;
  51383. t['slash'] = 278;
  51384. t['zero'] = 500;
  51385. t['one'] = 500;
  51386. t['two'] = 500;
  51387. t['three'] = 500;
  51388. t['four'] = 500;
  51389. t['five'] = 500;
  51390. t['six'] = 500;
  51391. t['seven'] = 500;
  51392. t['eight'] = 500;
  51393. t['nine'] = 500;
  51394. t['colon'] = 333;
  51395. t['semicolon'] = 333;
  51396. t['less'] = 570;
  51397. t['equal'] = 570;
  51398. t['greater'] = 570;
  51399. t['question'] = 500;
  51400. t['at'] = 832;
  51401. t['A'] = 667;
  51402. t['B'] = 667;
  51403. t['C'] = 667;
  51404. t['D'] = 722;
  51405. t['E'] = 667;
  51406. t['F'] = 667;
  51407. t['G'] = 722;
  51408. t['H'] = 778;
  51409. t['I'] = 389;
  51410. t['J'] = 500;
  51411. t['K'] = 667;
  51412. t['L'] = 611;
  51413. t['M'] = 889;
  51414. t['N'] = 722;
  51415. t['O'] = 722;
  51416. t['P'] = 611;
  51417. t['Q'] = 722;
  51418. t['R'] = 667;
  51419. t['S'] = 556;
  51420. t['T'] = 611;
  51421. t['U'] = 722;
  51422. t['V'] = 667;
  51423. t['W'] = 889;
  51424. t['X'] = 667;
  51425. t['Y'] = 611;
  51426. t['Z'] = 611;
  51427. t['bracketleft'] = 333;
  51428. t['backslash'] = 278;
  51429. t['bracketright'] = 333;
  51430. t['asciicircum'] = 570;
  51431. t['underscore'] = 500;
  51432. t['quoteleft'] = 333;
  51433. t['a'] = 500;
  51434. t['b'] = 500;
  51435. t['c'] = 444;
  51436. t['d'] = 500;
  51437. t['e'] = 444;
  51438. t['f'] = 333;
  51439. t['g'] = 500;
  51440. t['h'] = 556;
  51441. t['i'] = 278;
  51442. t['j'] = 278;
  51443. t['k'] = 500;
  51444. t['l'] = 278;
  51445. t['m'] = 778;
  51446. t['n'] = 556;
  51447. t['o'] = 500;
  51448. t['p'] = 500;
  51449. t['q'] = 500;
  51450. t['r'] = 389;
  51451. t['s'] = 389;
  51452. t['t'] = 278;
  51453. t['u'] = 556;
  51454. t['v'] = 444;
  51455. t['w'] = 667;
  51456. t['x'] = 500;
  51457. t['y'] = 444;
  51458. t['z'] = 389;
  51459. t['braceleft'] = 348;
  51460. t['bar'] = 220;
  51461. t['braceright'] = 348;
  51462. t['asciitilde'] = 570;
  51463. t['exclamdown'] = 389;
  51464. t['cent'] = 500;
  51465. t['sterling'] = 500;
  51466. t['fraction'] = 167;
  51467. t['yen'] = 500;
  51468. t['florin'] = 500;
  51469. t['section'] = 500;
  51470. t['currency'] = 500;
  51471. t['quotesingle'] = 278;
  51472. t['quotedblleft'] = 500;
  51473. t['guillemotleft'] = 500;
  51474. t['guilsinglleft'] = 333;
  51475. t['guilsinglright'] = 333;
  51476. t['fi'] = 556;
  51477. t['fl'] = 556;
  51478. t['endash'] = 500;
  51479. t['dagger'] = 500;
  51480. t['daggerdbl'] = 500;
  51481. t['periodcentered'] = 250;
  51482. t['paragraph'] = 500;
  51483. t['bullet'] = 350;
  51484. t['quotesinglbase'] = 333;
  51485. t['quotedblbase'] = 500;
  51486. t['quotedblright'] = 500;
  51487. t['guillemotright'] = 500;
  51488. t['ellipsis'] = 1000;
  51489. t['perthousand'] = 1000;
  51490. t['questiondown'] = 500;
  51491. t['grave'] = 333;
  51492. t['acute'] = 333;
  51493. t['circumflex'] = 333;
  51494. t['tilde'] = 333;
  51495. t['macron'] = 333;
  51496. t['breve'] = 333;
  51497. t['dotaccent'] = 333;
  51498. t['dieresis'] = 333;
  51499. t['ring'] = 333;
  51500. t['cedilla'] = 333;
  51501. t['hungarumlaut'] = 333;
  51502. t['ogonek'] = 333;
  51503. t['caron'] = 333;
  51504. t['emdash'] = 1000;
  51505. t['AE'] = 944;
  51506. t['ordfeminine'] = 266;
  51507. t['Lslash'] = 611;
  51508. t['Oslash'] = 722;
  51509. t['OE'] = 944;
  51510. t['ordmasculine'] = 300;
  51511. t['ae'] = 722;
  51512. t['dotlessi'] = 278;
  51513. t['lslash'] = 278;
  51514. t['oslash'] = 500;
  51515. t['oe'] = 722;
  51516. t['germandbls'] = 500;
  51517. t['Idieresis'] = 389;
  51518. t['eacute'] = 444;
  51519. t['abreve'] = 500;
  51520. t['uhungarumlaut'] = 556;
  51521. t['ecaron'] = 444;
  51522. t['Ydieresis'] = 611;
  51523. t['divide'] = 570;
  51524. t['Yacute'] = 611;
  51525. t['Acircumflex'] = 667;
  51526. t['aacute'] = 500;
  51527. t['Ucircumflex'] = 722;
  51528. t['yacute'] = 444;
  51529. t['scommaaccent'] = 389;
  51530. t['ecircumflex'] = 444;
  51531. t['Uring'] = 722;
  51532. t['Udieresis'] = 722;
  51533. t['aogonek'] = 500;
  51534. t['Uacute'] = 722;
  51535. t['uogonek'] = 556;
  51536. t['Edieresis'] = 667;
  51537. t['Dcroat'] = 722;
  51538. t['commaaccent'] = 250;
  51539. t['copyright'] = 747;
  51540. t['Emacron'] = 667;
  51541. t['ccaron'] = 444;
  51542. t['aring'] = 500;
  51543. t['Ncommaaccent'] = 722;
  51544. t['lacute'] = 278;
  51545. t['agrave'] = 500;
  51546. t['Tcommaaccent'] = 611;
  51547. t['Cacute'] = 667;
  51548. t['atilde'] = 500;
  51549. t['Edotaccent'] = 667;
  51550. t['scaron'] = 389;
  51551. t['scedilla'] = 389;
  51552. t['iacute'] = 278;
  51553. t['lozenge'] = 494;
  51554. t['Rcaron'] = 667;
  51555. t['Gcommaaccent'] = 722;
  51556. t['ucircumflex'] = 556;
  51557. t['acircumflex'] = 500;
  51558. t['Amacron'] = 667;
  51559. t['rcaron'] = 389;
  51560. t['ccedilla'] = 444;
  51561. t['Zdotaccent'] = 611;
  51562. t['Thorn'] = 611;
  51563. t['Omacron'] = 722;
  51564. t['Racute'] = 667;
  51565. t['Sacute'] = 556;
  51566. t['dcaron'] = 608;
  51567. t['Umacron'] = 722;
  51568. t['uring'] = 556;
  51569. t['threesuperior'] = 300;
  51570. t['Ograve'] = 722;
  51571. t['Agrave'] = 667;
  51572. t['Abreve'] = 667;
  51573. t['multiply'] = 570;
  51574. t['uacute'] = 556;
  51575. t['Tcaron'] = 611;
  51576. t['partialdiff'] = 494;
  51577. t['ydieresis'] = 444;
  51578. t['Nacute'] = 722;
  51579. t['icircumflex'] = 278;
  51580. t['Ecircumflex'] = 667;
  51581. t['adieresis'] = 500;
  51582. t['edieresis'] = 444;
  51583. t['cacute'] = 444;
  51584. t['nacute'] = 556;
  51585. t['umacron'] = 556;
  51586. t['Ncaron'] = 722;
  51587. t['Iacute'] = 389;
  51588. t['plusminus'] = 570;
  51589. t['brokenbar'] = 220;
  51590. t['registered'] = 747;
  51591. t['Gbreve'] = 722;
  51592. t['Idotaccent'] = 389;
  51593. t['summation'] = 600;
  51594. t['Egrave'] = 667;
  51595. t['racute'] = 389;
  51596. t['omacron'] = 500;
  51597. t['Zacute'] = 611;
  51598. t['Zcaron'] = 611;
  51599. t['greaterequal'] = 549;
  51600. t['Eth'] = 722;
  51601. t['Ccedilla'] = 667;
  51602. t['lcommaaccent'] = 278;
  51603. t['tcaron'] = 366;
  51604. t['eogonek'] = 444;
  51605. t['Uogonek'] = 722;
  51606. t['Aacute'] = 667;
  51607. t['Adieresis'] = 667;
  51608. t['egrave'] = 444;
  51609. t['zacute'] = 389;
  51610. t['iogonek'] = 278;
  51611. t['Oacute'] = 722;
  51612. t['oacute'] = 500;
  51613. t['amacron'] = 500;
  51614. t['sacute'] = 389;
  51615. t['idieresis'] = 278;
  51616. t['Ocircumflex'] = 722;
  51617. t['Ugrave'] = 722;
  51618. t['Delta'] = 612;
  51619. t['thorn'] = 500;
  51620. t['twosuperior'] = 300;
  51621. t['Odieresis'] = 722;
  51622. t['mu'] = 576;
  51623. t['igrave'] = 278;
  51624. t['ohungarumlaut'] = 500;
  51625. t['Eogonek'] = 667;
  51626. t['dcroat'] = 500;
  51627. t['threequarters'] = 750;
  51628. t['Scedilla'] = 556;
  51629. t['lcaron'] = 382;
  51630. t['Kcommaaccent'] = 667;
  51631. t['Lacute'] = 611;
  51632. t['trademark'] = 1000;
  51633. t['edotaccent'] = 444;
  51634. t['Igrave'] = 389;
  51635. t['Imacron'] = 389;
  51636. t['Lcaron'] = 611;
  51637. t['onehalf'] = 750;
  51638. t['lessequal'] = 549;
  51639. t['ocircumflex'] = 500;
  51640. t['ntilde'] = 556;
  51641. t['Uhungarumlaut'] = 722;
  51642. t['Eacute'] = 667;
  51643. t['emacron'] = 444;
  51644. t['gbreve'] = 500;
  51645. t['onequarter'] = 750;
  51646. t['Scaron'] = 556;
  51647. t['Scommaaccent'] = 556;
  51648. t['Ohungarumlaut'] = 722;
  51649. t['degree'] = 400;
  51650. t['ograve'] = 500;
  51651. t['Ccaron'] = 667;
  51652. t['ugrave'] = 556;
  51653. t['radical'] = 549;
  51654. t['Dcaron'] = 722;
  51655. t['rcommaaccent'] = 389;
  51656. t['Ntilde'] = 722;
  51657. t['otilde'] = 500;
  51658. t['Rcommaaccent'] = 667;
  51659. t['Lcommaaccent'] = 611;
  51660. t['Atilde'] = 667;
  51661. t['Aogonek'] = 667;
  51662. t['Aring'] = 667;
  51663. t['Otilde'] = 722;
  51664. t['zdotaccent'] = 389;
  51665. t['Ecaron'] = 667;
  51666. t['Iogonek'] = 389;
  51667. t['kcommaaccent'] = 500;
  51668. t['minus'] = 606;
  51669. t['Icircumflex'] = 389;
  51670. t['ncaron'] = 556;
  51671. t['tcommaaccent'] = 278;
  51672. t['logicalnot'] = 606;
  51673. t['odieresis'] = 500;
  51674. t['udieresis'] = 556;
  51675. t['notequal'] = 549;
  51676. t['gcommaaccent'] = 500;
  51677. t['eth'] = 500;
  51678. t['zcaron'] = 389;
  51679. t['ncommaaccent'] = 556;
  51680. t['onesuperior'] = 300;
  51681. t['imacron'] = 278;
  51682. t['Euro'] = 500;
  51683. });
  51684. t['Times-Italic'] = getLookupTableFactory(function (t) {
  51685. t['space'] = 250;
  51686. t['exclam'] = 333;
  51687. t['quotedbl'] = 420;
  51688. t['numbersign'] = 500;
  51689. t['dollar'] = 500;
  51690. t['percent'] = 833;
  51691. t['ampersand'] = 778;
  51692. t['quoteright'] = 333;
  51693. t['parenleft'] = 333;
  51694. t['parenright'] = 333;
  51695. t['asterisk'] = 500;
  51696. t['plus'] = 675;
  51697. t['comma'] = 250;
  51698. t['hyphen'] = 333;
  51699. t['period'] = 250;
  51700. t['slash'] = 278;
  51701. t['zero'] = 500;
  51702. t['one'] = 500;
  51703. t['two'] = 500;
  51704. t['three'] = 500;
  51705. t['four'] = 500;
  51706. t['five'] = 500;
  51707. t['six'] = 500;
  51708. t['seven'] = 500;
  51709. t['eight'] = 500;
  51710. t['nine'] = 500;
  51711. t['colon'] = 333;
  51712. t['semicolon'] = 333;
  51713. t['less'] = 675;
  51714. t['equal'] = 675;
  51715. t['greater'] = 675;
  51716. t['question'] = 500;
  51717. t['at'] = 920;
  51718. t['A'] = 611;
  51719. t['B'] = 611;
  51720. t['C'] = 667;
  51721. t['D'] = 722;
  51722. t['E'] = 611;
  51723. t['F'] = 611;
  51724. t['G'] = 722;
  51725. t['H'] = 722;
  51726. t['I'] = 333;
  51727. t['J'] = 444;
  51728. t['K'] = 667;
  51729. t['L'] = 556;
  51730. t['M'] = 833;
  51731. t['N'] = 667;
  51732. t['O'] = 722;
  51733. t['P'] = 611;
  51734. t['Q'] = 722;
  51735. t['R'] = 611;
  51736. t['S'] = 500;
  51737. t['T'] = 556;
  51738. t['U'] = 722;
  51739. t['V'] = 611;
  51740. t['W'] = 833;
  51741. t['X'] = 611;
  51742. t['Y'] = 556;
  51743. t['Z'] = 556;
  51744. t['bracketleft'] = 389;
  51745. t['backslash'] = 278;
  51746. t['bracketright'] = 389;
  51747. t['asciicircum'] = 422;
  51748. t['underscore'] = 500;
  51749. t['quoteleft'] = 333;
  51750. t['a'] = 500;
  51751. t['b'] = 500;
  51752. t['c'] = 444;
  51753. t['d'] = 500;
  51754. t['e'] = 444;
  51755. t['f'] = 278;
  51756. t['g'] = 500;
  51757. t['h'] = 500;
  51758. t['i'] = 278;
  51759. t['j'] = 278;
  51760. t['k'] = 444;
  51761. t['l'] = 278;
  51762. t['m'] = 722;
  51763. t['n'] = 500;
  51764. t['o'] = 500;
  51765. t['p'] = 500;
  51766. t['q'] = 500;
  51767. t['r'] = 389;
  51768. t['s'] = 389;
  51769. t['t'] = 278;
  51770. t['u'] = 500;
  51771. t['v'] = 444;
  51772. t['w'] = 667;
  51773. t['x'] = 444;
  51774. t['y'] = 444;
  51775. t['z'] = 389;
  51776. t['braceleft'] = 400;
  51777. t['bar'] = 275;
  51778. t['braceright'] = 400;
  51779. t['asciitilde'] = 541;
  51780. t['exclamdown'] = 389;
  51781. t['cent'] = 500;
  51782. t['sterling'] = 500;
  51783. t['fraction'] = 167;
  51784. t['yen'] = 500;
  51785. t['florin'] = 500;
  51786. t['section'] = 500;
  51787. t['currency'] = 500;
  51788. t['quotesingle'] = 214;
  51789. t['quotedblleft'] = 556;
  51790. t['guillemotleft'] = 500;
  51791. t['guilsinglleft'] = 333;
  51792. t['guilsinglright'] = 333;
  51793. t['fi'] = 500;
  51794. t['fl'] = 500;
  51795. t['endash'] = 500;
  51796. t['dagger'] = 500;
  51797. t['daggerdbl'] = 500;
  51798. t['periodcentered'] = 250;
  51799. t['paragraph'] = 523;
  51800. t['bullet'] = 350;
  51801. t['quotesinglbase'] = 333;
  51802. t['quotedblbase'] = 556;
  51803. t['quotedblright'] = 556;
  51804. t['guillemotright'] = 500;
  51805. t['ellipsis'] = 889;
  51806. t['perthousand'] = 1000;
  51807. t['questiondown'] = 500;
  51808. t['grave'] = 333;
  51809. t['acute'] = 333;
  51810. t['circumflex'] = 333;
  51811. t['tilde'] = 333;
  51812. t['macron'] = 333;
  51813. t['breve'] = 333;
  51814. t['dotaccent'] = 333;
  51815. t['dieresis'] = 333;
  51816. t['ring'] = 333;
  51817. t['cedilla'] = 333;
  51818. t['hungarumlaut'] = 333;
  51819. t['ogonek'] = 333;
  51820. t['caron'] = 333;
  51821. t['emdash'] = 889;
  51822. t['AE'] = 889;
  51823. t['ordfeminine'] = 276;
  51824. t['Lslash'] = 556;
  51825. t['Oslash'] = 722;
  51826. t['OE'] = 944;
  51827. t['ordmasculine'] = 310;
  51828. t['ae'] = 667;
  51829. t['dotlessi'] = 278;
  51830. t['lslash'] = 278;
  51831. t['oslash'] = 500;
  51832. t['oe'] = 667;
  51833. t['germandbls'] = 500;
  51834. t['Idieresis'] = 333;
  51835. t['eacute'] = 444;
  51836. t['abreve'] = 500;
  51837. t['uhungarumlaut'] = 500;
  51838. t['ecaron'] = 444;
  51839. t['Ydieresis'] = 556;
  51840. t['divide'] = 675;
  51841. t['Yacute'] = 556;
  51842. t['Acircumflex'] = 611;
  51843. t['aacute'] = 500;
  51844. t['Ucircumflex'] = 722;
  51845. t['yacute'] = 444;
  51846. t['scommaaccent'] = 389;
  51847. t['ecircumflex'] = 444;
  51848. t['Uring'] = 722;
  51849. t['Udieresis'] = 722;
  51850. t['aogonek'] = 500;
  51851. t['Uacute'] = 722;
  51852. t['uogonek'] = 500;
  51853. t['Edieresis'] = 611;
  51854. t['Dcroat'] = 722;
  51855. t['commaaccent'] = 250;
  51856. t['copyright'] = 760;
  51857. t['Emacron'] = 611;
  51858. t['ccaron'] = 444;
  51859. t['aring'] = 500;
  51860. t['Ncommaaccent'] = 667;
  51861. t['lacute'] = 278;
  51862. t['agrave'] = 500;
  51863. t['Tcommaaccent'] = 556;
  51864. t['Cacute'] = 667;
  51865. t['atilde'] = 500;
  51866. t['Edotaccent'] = 611;
  51867. t['scaron'] = 389;
  51868. t['scedilla'] = 389;
  51869. t['iacute'] = 278;
  51870. t['lozenge'] = 471;
  51871. t['Rcaron'] = 611;
  51872. t['Gcommaaccent'] = 722;
  51873. t['ucircumflex'] = 500;
  51874. t['acircumflex'] = 500;
  51875. t['Amacron'] = 611;
  51876. t['rcaron'] = 389;
  51877. t['ccedilla'] = 444;
  51878. t['Zdotaccent'] = 556;
  51879. t['Thorn'] = 611;
  51880. t['Omacron'] = 722;
  51881. t['Racute'] = 611;
  51882. t['Sacute'] = 500;
  51883. t['dcaron'] = 544;
  51884. t['Umacron'] = 722;
  51885. t['uring'] = 500;
  51886. t['threesuperior'] = 300;
  51887. t['Ograve'] = 722;
  51888. t['Agrave'] = 611;
  51889. t['Abreve'] = 611;
  51890. t['multiply'] = 675;
  51891. t['uacute'] = 500;
  51892. t['Tcaron'] = 556;
  51893. t['partialdiff'] = 476;
  51894. t['ydieresis'] = 444;
  51895. t['Nacute'] = 667;
  51896. t['icircumflex'] = 278;
  51897. t['Ecircumflex'] = 611;
  51898. t['adieresis'] = 500;
  51899. t['edieresis'] = 444;
  51900. t['cacute'] = 444;
  51901. t['nacute'] = 500;
  51902. t['umacron'] = 500;
  51903. t['Ncaron'] = 667;
  51904. t['Iacute'] = 333;
  51905. t['plusminus'] = 675;
  51906. t['brokenbar'] = 275;
  51907. t['registered'] = 760;
  51908. t['Gbreve'] = 722;
  51909. t['Idotaccent'] = 333;
  51910. t['summation'] = 600;
  51911. t['Egrave'] = 611;
  51912. t['racute'] = 389;
  51913. t['omacron'] = 500;
  51914. t['Zacute'] = 556;
  51915. t['Zcaron'] = 556;
  51916. t['greaterequal'] = 549;
  51917. t['Eth'] = 722;
  51918. t['Ccedilla'] = 667;
  51919. t['lcommaaccent'] = 278;
  51920. t['tcaron'] = 300;
  51921. t['eogonek'] = 444;
  51922. t['Uogonek'] = 722;
  51923. t['Aacute'] = 611;
  51924. t['Adieresis'] = 611;
  51925. t['egrave'] = 444;
  51926. t['zacute'] = 389;
  51927. t['iogonek'] = 278;
  51928. t['Oacute'] = 722;
  51929. t['oacute'] = 500;
  51930. t['amacron'] = 500;
  51931. t['sacute'] = 389;
  51932. t['idieresis'] = 278;
  51933. t['Ocircumflex'] = 722;
  51934. t['Ugrave'] = 722;
  51935. t['Delta'] = 612;
  51936. t['thorn'] = 500;
  51937. t['twosuperior'] = 300;
  51938. t['Odieresis'] = 722;
  51939. t['mu'] = 500;
  51940. t['igrave'] = 278;
  51941. t['ohungarumlaut'] = 500;
  51942. t['Eogonek'] = 611;
  51943. t['dcroat'] = 500;
  51944. t['threequarters'] = 750;
  51945. t['Scedilla'] = 500;
  51946. t['lcaron'] = 300;
  51947. t['Kcommaaccent'] = 667;
  51948. t['Lacute'] = 556;
  51949. t['trademark'] = 980;
  51950. t['edotaccent'] = 444;
  51951. t['Igrave'] = 333;
  51952. t['Imacron'] = 333;
  51953. t['Lcaron'] = 611;
  51954. t['onehalf'] = 750;
  51955. t['lessequal'] = 549;
  51956. t['ocircumflex'] = 500;
  51957. t['ntilde'] = 500;
  51958. t['Uhungarumlaut'] = 722;
  51959. t['Eacute'] = 611;
  51960. t['emacron'] = 444;
  51961. t['gbreve'] = 500;
  51962. t['onequarter'] = 750;
  51963. t['Scaron'] = 500;
  51964. t['Scommaaccent'] = 500;
  51965. t['Ohungarumlaut'] = 722;
  51966. t['degree'] = 400;
  51967. t['ograve'] = 500;
  51968. t['Ccaron'] = 667;
  51969. t['ugrave'] = 500;
  51970. t['radical'] = 453;
  51971. t['Dcaron'] = 722;
  51972. t['rcommaaccent'] = 389;
  51973. t['Ntilde'] = 667;
  51974. t['otilde'] = 500;
  51975. t['Rcommaaccent'] = 611;
  51976. t['Lcommaaccent'] = 556;
  51977. t['Atilde'] = 611;
  51978. t['Aogonek'] = 611;
  51979. t['Aring'] = 611;
  51980. t['Otilde'] = 722;
  51981. t['zdotaccent'] = 389;
  51982. t['Ecaron'] = 611;
  51983. t['Iogonek'] = 333;
  51984. t['kcommaaccent'] = 444;
  51985. t['minus'] = 675;
  51986. t['Icircumflex'] = 333;
  51987. t['ncaron'] = 500;
  51988. t['tcommaaccent'] = 278;
  51989. t['logicalnot'] = 675;
  51990. t['odieresis'] = 500;
  51991. t['udieresis'] = 500;
  51992. t['notequal'] = 549;
  51993. t['gcommaaccent'] = 500;
  51994. t['eth'] = 500;
  51995. t['zcaron'] = 389;
  51996. t['ncommaaccent'] = 500;
  51997. t['onesuperior'] = 300;
  51998. t['imacron'] = 278;
  51999. t['Euro'] = 500;
  52000. });
  52001. t['ZapfDingbats'] = getLookupTableFactory(function (t) {
  52002. t['space'] = 278;
  52003. t['a1'] = 974;
  52004. t['a2'] = 961;
  52005. t['a202'] = 974;
  52006. t['a3'] = 980;
  52007. t['a4'] = 719;
  52008. t['a5'] = 789;
  52009. t['a119'] = 790;
  52010. t['a118'] = 791;
  52011. t['a117'] = 690;
  52012. t['a11'] = 960;
  52013. t['a12'] = 939;
  52014. t['a13'] = 549;
  52015. t['a14'] = 855;
  52016. t['a15'] = 911;
  52017. t['a16'] = 933;
  52018. t['a105'] = 911;
  52019. t['a17'] = 945;
  52020. t['a18'] = 974;
  52021. t['a19'] = 755;
  52022. t['a20'] = 846;
  52023. t['a21'] = 762;
  52024. t['a22'] = 761;
  52025. t['a23'] = 571;
  52026. t['a24'] = 677;
  52027. t['a25'] = 763;
  52028. t['a26'] = 760;
  52029. t['a27'] = 759;
  52030. t['a28'] = 754;
  52031. t['a6'] = 494;
  52032. t['a7'] = 552;
  52033. t['a8'] = 537;
  52034. t['a9'] = 577;
  52035. t['a10'] = 692;
  52036. t['a29'] = 786;
  52037. t['a30'] = 788;
  52038. t['a31'] = 788;
  52039. t['a32'] = 790;
  52040. t['a33'] = 793;
  52041. t['a34'] = 794;
  52042. t['a35'] = 816;
  52043. t['a36'] = 823;
  52044. t['a37'] = 789;
  52045. t['a38'] = 841;
  52046. t['a39'] = 823;
  52047. t['a40'] = 833;
  52048. t['a41'] = 816;
  52049. t['a42'] = 831;
  52050. t['a43'] = 923;
  52051. t['a44'] = 744;
  52052. t['a45'] = 723;
  52053. t['a46'] = 749;
  52054. t['a47'] = 790;
  52055. t['a48'] = 792;
  52056. t['a49'] = 695;
  52057. t['a50'] = 776;
  52058. t['a51'] = 768;
  52059. t['a52'] = 792;
  52060. t['a53'] = 759;
  52061. t['a54'] = 707;
  52062. t['a55'] = 708;
  52063. t['a56'] = 682;
  52064. t['a57'] = 701;
  52065. t['a58'] = 826;
  52066. t['a59'] = 815;
  52067. t['a60'] = 789;
  52068. t['a61'] = 789;
  52069. t['a62'] = 707;
  52070. t['a63'] = 687;
  52071. t['a64'] = 696;
  52072. t['a65'] = 689;
  52073. t['a66'] = 786;
  52074. t['a67'] = 787;
  52075. t['a68'] = 713;
  52076. t['a69'] = 791;
  52077. t['a70'] = 785;
  52078. t['a71'] = 791;
  52079. t['a72'] = 873;
  52080. t['a73'] = 761;
  52081. t['a74'] = 762;
  52082. t['a203'] = 762;
  52083. t['a75'] = 759;
  52084. t['a204'] = 759;
  52085. t['a76'] = 892;
  52086. t['a77'] = 892;
  52087. t['a78'] = 788;
  52088. t['a79'] = 784;
  52089. t['a81'] = 438;
  52090. t['a82'] = 138;
  52091. t['a83'] = 277;
  52092. t['a84'] = 415;
  52093. t['a97'] = 392;
  52094. t['a98'] = 392;
  52095. t['a99'] = 668;
  52096. t['a100'] = 668;
  52097. t['a89'] = 390;
  52098. t['a90'] = 390;
  52099. t['a93'] = 317;
  52100. t['a94'] = 317;
  52101. t['a91'] = 276;
  52102. t['a92'] = 276;
  52103. t['a205'] = 509;
  52104. t['a85'] = 509;
  52105. t['a206'] = 410;
  52106. t['a86'] = 410;
  52107. t['a87'] = 234;
  52108. t['a88'] = 234;
  52109. t['a95'] = 334;
  52110. t['a96'] = 334;
  52111. t['a101'] = 732;
  52112. t['a102'] = 544;
  52113. t['a103'] = 544;
  52114. t['a104'] = 910;
  52115. t['a106'] = 667;
  52116. t['a107'] = 760;
  52117. t['a108'] = 760;
  52118. t['a112'] = 776;
  52119. t['a111'] = 595;
  52120. t['a110'] = 694;
  52121. t['a109'] = 626;
  52122. t['a120'] = 788;
  52123. t['a121'] = 788;
  52124. t['a122'] = 788;
  52125. t['a123'] = 788;
  52126. t['a124'] = 788;
  52127. t['a125'] = 788;
  52128. t['a126'] = 788;
  52129. t['a127'] = 788;
  52130. t['a128'] = 788;
  52131. t['a129'] = 788;
  52132. t['a130'] = 788;
  52133. t['a131'] = 788;
  52134. t['a132'] = 788;
  52135. t['a133'] = 788;
  52136. t['a134'] = 788;
  52137. t['a135'] = 788;
  52138. t['a136'] = 788;
  52139. t['a137'] = 788;
  52140. t['a138'] = 788;
  52141. t['a139'] = 788;
  52142. t['a140'] = 788;
  52143. t['a141'] = 788;
  52144. t['a142'] = 788;
  52145. t['a143'] = 788;
  52146. t['a144'] = 788;
  52147. t['a145'] = 788;
  52148. t['a146'] = 788;
  52149. t['a147'] = 788;
  52150. t['a148'] = 788;
  52151. t['a149'] = 788;
  52152. t['a150'] = 788;
  52153. t['a151'] = 788;
  52154. t['a152'] = 788;
  52155. t['a153'] = 788;
  52156. t['a154'] = 788;
  52157. t['a155'] = 788;
  52158. t['a156'] = 788;
  52159. t['a157'] = 788;
  52160. t['a158'] = 788;
  52161. t['a159'] = 788;
  52162. t['a160'] = 894;
  52163. t['a161'] = 838;
  52164. t['a163'] = 1016;
  52165. t['a164'] = 458;
  52166. t['a196'] = 748;
  52167. t['a165'] = 924;
  52168. t['a192'] = 748;
  52169. t['a166'] = 918;
  52170. t['a167'] = 927;
  52171. t['a168'] = 928;
  52172. t['a169'] = 928;
  52173. t['a170'] = 834;
  52174. t['a171'] = 873;
  52175. t['a172'] = 828;
  52176. t['a173'] = 924;
  52177. t['a162'] = 924;
  52178. t['a174'] = 917;
  52179. t['a175'] = 930;
  52180. t['a176'] = 931;
  52181. t['a177'] = 463;
  52182. t['a178'] = 883;
  52183. t['a179'] = 836;
  52184. t['a193'] = 836;
  52185. t['a180'] = 867;
  52186. t['a199'] = 867;
  52187. t['a181'] = 696;
  52188. t['a200'] = 696;
  52189. t['a182'] = 874;
  52190. t['a201'] = 874;
  52191. t['a183'] = 760;
  52192. t['a184'] = 946;
  52193. t['a197'] = 771;
  52194. t['a185'] = 865;
  52195. t['a194'] = 771;
  52196. t['a198'] = 888;
  52197. t['a186'] = 967;
  52198. t['a195'] = 888;
  52199. t['a187'] = 831;
  52200. t['a188'] = 873;
  52201. t['a189'] = 927;
  52202. t['a190'] = 970;
  52203. t['a191'] = 918;
  52204. });
  52205. });
  52206. exports.getMetrics = getMetrics;
  52207. /***/ }),
  52208. /* 39 */
  52209. /***/ (function(module, exports, __w_pdfjs_require__) {
  52210. "use strict";
  52211. var sharedUtil = __w_pdfjs_require__(0);
  52212. var Uint32ArrayView = sharedUtil.Uint32ArrayView;
  52213. var MurmurHash3_64 = function MurmurHash3_64Closure(seed) {
  52214. var MASK_HIGH = 0xffff0000;
  52215. var MASK_LOW = 0xffff;
  52216. function MurmurHash3_64(seed) {
  52217. var SEED = 0xc3d2e1f0;
  52218. this.h1 = seed ? seed & 0xffffffff : SEED;
  52219. this.h2 = seed ? seed & 0xffffffff : SEED;
  52220. }
  52221. var alwaysUseUint32ArrayView = false;
  52222. try {
  52223. new Uint32Array(new Uint8Array(5).buffer, 0, 1);
  52224. } catch (e) {
  52225. alwaysUseUint32ArrayView = true;
  52226. }
  52227. MurmurHash3_64.prototype = {
  52228. update: function MurmurHash3_64_update(input) {
  52229. var useUint32ArrayView = alwaysUseUint32ArrayView;
  52230. var i;
  52231. if (typeof input === 'string') {
  52232. var data = new Uint8Array(input.length * 2);
  52233. var length = 0;
  52234. for (i = 0; i < input.length; i++) {
  52235. var code = input.charCodeAt(i);
  52236. if (code <= 0xff) {
  52237. data[length++] = code;
  52238. } else {
  52239. data[length++] = code >>> 8;
  52240. data[length++] = code & 0xff;
  52241. }
  52242. }
  52243. } else if (input instanceof Uint8Array) {
  52244. data = input;
  52245. length = data.length;
  52246. } else if (typeof input === 'object' && 'length' in input) {
  52247. data = input;
  52248. length = data.length;
  52249. useUint32ArrayView = true;
  52250. } else {
  52251. throw new Error('Wrong data format in MurmurHash3_64_update. ' + 'Input must be a string or array.');
  52252. }
  52253. var blockCounts = length >> 2;
  52254. var tailLength = length - blockCounts * 4;
  52255. var dataUint32 = useUint32ArrayView ? new Uint32ArrayView(data, blockCounts) : new Uint32Array(data.buffer, 0, blockCounts);
  52256. var k1 = 0;
  52257. var k2 = 0;
  52258. var h1 = this.h1;
  52259. var h2 = this.h2;
  52260. var C1 = 0xcc9e2d51;
  52261. var C2 = 0x1b873593;
  52262. var C1_LOW = C1 & MASK_LOW;
  52263. var C2_LOW = C2 & MASK_LOW;
  52264. for (i = 0; i < blockCounts; i++) {
  52265. if (i & 1) {
  52266. k1 = dataUint32[i];
  52267. k1 = k1 * C1 & MASK_HIGH | k1 * C1_LOW & MASK_LOW;
  52268. k1 = k1 << 15 | k1 >>> 17;
  52269. k1 = k1 * C2 & MASK_HIGH | k1 * C2_LOW & MASK_LOW;
  52270. h1 ^= k1;
  52271. h1 = h1 << 13 | h1 >>> 19;
  52272. h1 = h1 * 5 + 0xe6546b64;
  52273. } else {
  52274. k2 = dataUint32[i];
  52275. k2 = k2 * C1 & MASK_HIGH | k2 * C1_LOW & MASK_LOW;
  52276. k2 = k2 << 15 | k2 >>> 17;
  52277. k2 = k2 * C2 & MASK_HIGH | k2 * C2_LOW & MASK_LOW;
  52278. h2 ^= k2;
  52279. h2 = h2 << 13 | h2 >>> 19;
  52280. h2 = h2 * 5 + 0xe6546b64;
  52281. }
  52282. }
  52283. k1 = 0;
  52284. switch (tailLength) {
  52285. case 3:
  52286. k1 ^= data[blockCounts * 4 + 2] << 16;
  52287. case 2:
  52288. k1 ^= data[blockCounts * 4 + 1] << 8;
  52289. case 1:
  52290. k1 ^= data[blockCounts * 4];
  52291. k1 = k1 * C1 & MASK_HIGH | k1 * C1_LOW & MASK_LOW;
  52292. k1 = k1 << 15 | k1 >>> 17;
  52293. k1 = k1 * C2 & MASK_HIGH | k1 * C2_LOW & MASK_LOW;
  52294. if (blockCounts & 1) {
  52295. h1 ^= k1;
  52296. } else {
  52297. h2 ^= k1;
  52298. }
  52299. }
  52300. this.h1 = h1;
  52301. this.h2 = h2;
  52302. return this;
  52303. },
  52304. hexdigest: function MurmurHash3_64_hexdigest() {
  52305. var h1 = this.h1;
  52306. var h2 = this.h2;
  52307. h1 ^= h2 >>> 1;
  52308. h1 = h1 * 0xed558ccd & MASK_HIGH | h1 * 0x8ccd & MASK_LOW;
  52309. h2 = h2 * 0xff51afd7 & MASK_HIGH | ((h2 << 16 | h1 >>> 16) * 0xafd7ed55 & MASK_HIGH) >>> 16;
  52310. h1 ^= h2 >>> 1;
  52311. h1 = h1 * 0x1a85ec53 & MASK_HIGH | h1 * 0xec53 & MASK_LOW;
  52312. h2 = h2 * 0xc4ceb9fe & MASK_HIGH | ((h2 << 16 | h1 >>> 16) * 0xb9fe1a85 & MASK_HIGH) >>> 16;
  52313. h1 ^= h2 >>> 1;
  52314. for (var i = 0, arr = [
  52315. h1,
  52316. h2
  52317. ], str = ''; i < arr.length; i++) {
  52318. var hex = (arr[i] >>> 0).toString(16);
  52319. while (hex.length < 8) {
  52320. hex = '0' + hex;
  52321. }
  52322. str += hex;
  52323. }
  52324. return str;
  52325. }
  52326. };
  52327. return MurmurHash3_64;
  52328. }();
  52329. exports.MurmurHash3_64 = MurmurHash3_64;
  52330. /***/ }),
  52331. /* 40 */
  52332. /***/ (function(module, exports, __w_pdfjs_require__) {
  52333. "use strict";
  52334. var sharedUtil = __w_pdfjs_require__(0);
  52335. var coreWorker = __w_pdfjs_require__(22);
  52336. var OK_RESPONSE = 200;
  52337. var PARTIAL_CONTENT_RESPONSE = 206;
  52338. function NetworkManager(url, args) {
  52339. this.url = url;
  52340. args = args || {};
  52341. this.isHttp = /^https?:/i.test(url);
  52342. this.httpHeaders = this.isHttp && args.httpHeaders || {};
  52343. this.withCredentials = args.withCredentials || false;
  52344. this.getXhr = args.getXhr || function NetworkManager_getXhr() {
  52345. return new XMLHttpRequest();
  52346. };
  52347. this.currXhrId = 0;
  52348. this.pendingRequests = Object.create(null);
  52349. this.loadedRequests = Object.create(null);
  52350. }
  52351. function getArrayBuffer(xhr) {
  52352. var data = xhr.response;
  52353. if (typeof data !== 'string') {
  52354. return data;
  52355. }
  52356. var length = data.length;
  52357. var array = new Uint8Array(length);
  52358. for (var i = 0; i < length; i++) {
  52359. array[i] = data.charCodeAt(i) & 0xFF;
  52360. }
  52361. return array.buffer;
  52362. }
  52363. var supportsMozChunked = function supportsMozChunkedClosure() {
  52364. try {
  52365. var x = new XMLHttpRequest();
  52366. x.open('GET', 'https://example.com');
  52367. x.responseType = 'moz-chunked-arraybuffer';
  52368. return x.responseType === 'moz-chunked-arraybuffer';
  52369. } catch (e) {
  52370. return false;
  52371. }
  52372. }();
  52373. NetworkManager.prototype = {
  52374. requestRange: function NetworkManager_requestRange(begin, end, listeners) {
  52375. var args = {
  52376. begin: begin,
  52377. end: end
  52378. };
  52379. for (var prop in listeners) {
  52380. args[prop] = listeners[prop];
  52381. }
  52382. return this.request(args);
  52383. },
  52384. requestFull: function NetworkManager_requestFull(listeners) {
  52385. return this.request(listeners);
  52386. },
  52387. request: function NetworkManager_request(args) {
  52388. var xhr = this.getXhr();
  52389. var xhrId = this.currXhrId++;
  52390. var pendingRequest = this.pendingRequests[xhrId] = { xhr: xhr };
  52391. xhr.open('GET', this.url);
  52392. xhr.withCredentials = this.withCredentials;
  52393. for (var property in this.httpHeaders) {
  52394. var value = this.httpHeaders[property];
  52395. if (typeof value === 'undefined') {
  52396. continue;
  52397. }
  52398. xhr.setRequestHeader(property, value);
  52399. }
  52400. if (this.isHttp && 'begin' in args && 'end' in args) {
  52401. var rangeStr = args.begin + '-' + (args.end - 1);
  52402. xhr.setRequestHeader('Range', 'bytes=' + rangeStr);
  52403. pendingRequest.expectedStatus = 206;
  52404. } else {
  52405. pendingRequest.expectedStatus = 200;
  52406. }
  52407. var useMozChunkedLoading = supportsMozChunked && !!args.onProgressiveData;
  52408. if (useMozChunkedLoading) {
  52409. xhr.responseType = 'moz-chunked-arraybuffer';
  52410. pendingRequest.onProgressiveData = args.onProgressiveData;
  52411. pendingRequest.mozChunked = true;
  52412. } else {
  52413. xhr.responseType = 'arraybuffer';
  52414. }
  52415. if (args.onError) {
  52416. xhr.onerror = function (evt) {
  52417. args.onError(xhr.status);
  52418. };
  52419. }
  52420. xhr.onreadystatechange = this.onStateChange.bind(this, xhrId);
  52421. xhr.onprogress = this.onProgress.bind(this, xhrId);
  52422. pendingRequest.onHeadersReceived = args.onHeadersReceived;
  52423. pendingRequest.onDone = args.onDone;
  52424. pendingRequest.onError = args.onError;
  52425. pendingRequest.onProgress = args.onProgress;
  52426. xhr.send(null);
  52427. return xhrId;
  52428. },
  52429. onProgress: function NetworkManager_onProgress(xhrId, evt) {
  52430. var pendingRequest = this.pendingRequests[xhrId];
  52431. if (!pendingRequest) {
  52432. return;
  52433. }
  52434. if (pendingRequest.mozChunked) {
  52435. var chunk = getArrayBuffer(pendingRequest.xhr);
  52436. pendingRequest.onProgressiveData(chunk);
  52437. }
  52438. var onProgress = pendingRequest.onProgress;
  52439. if (onProgress) {
  52440. onProgress(evt);
  52441. }
  52442. },
  52443. onStateChange: function NetworkManager_onStateChange(xhrId, evt) {
  52444. var pendingRequest = this.pendingRequests[xhrId];
  52445. if (!pendingRequest) {
  52446. return;
  52447. }
  52448. var xhr = pendingRequest.xhr;
  52449. if (xhr.readyState >= 2 && pendingRequest.onHeadersReceived) {
  52450. pendingRequest.onHeadersReceived();
  52451. delete pendingRequest.onHeadersReceived;
  52452. }
  52453. if (xhr.readyState !== 4) {
  52454. return;
  52455. }
  52456. if (!(xhrId in this.pendingRequests)) {
  52457. return;
  52458. }
  52459. delete this.pendingRequests[xhrId];
  52460. if (xhr.status === 0 && this.isHttp) {
  52461. if (pendingRequest.onError) {
  52462. pendingRequest.onError(xhr.status);
  52463. }
  52464. return;
  52465. }
  52466. var xhrStatus = xhr.status || OK_RESPONSE;
  52467. var ok_response_on_range_request = xhrStatus === OK_RESPONSE && pendingRequest.expectedStatus === PARTIAL_CONTENT_RESPONSE;
  52468. if (!ok_response_on_range_request && xhrStatus !== pendingRequest.expectedStatus) {
  52469. if (pendingRequest.onError) {
  52470. pendingRequest.onError(xhr.status);
  52471. }
  52472. return;
  52473. }
  52474. this.loadedRequests[xhrId] = true;
  52475. var chunk = getArrayBuffer(xhr);
  52476. if (xhrStatus === PARTIAL_CONTENT_RESPONSE) {
  52477. var rangeHeader = xhr.getResponseHeader('Content-Range');
  52478. var matches = /bytes (\d+)-(\d+)\/(\d+)/.exec(rangeHeader);
  52479. var begin = parseInt(matches[1], 10);
  52480. pendingRequest.onDone({
  52481. begin: begin,
  52482. chunk: chunk
  52483. });
  52484. } else if (pendingRequest.onProgressiveData) {
  52485. pendingRequest.onDone(null);
  52486. } else if (chunk) {
  52487. pendingRequest.onDone({
  52488. begin: 0,
  52489. chunk: chunk
  52490. });
  52491. } else if (pendingRequest.onError) {
  52492. pendingRequest.onError(xhr.status);
  52493. }
  52494. },
  52495. hasPendingRequests: function NetworkManager_hasPendingRequests() {
  52496. for (var xhrId in this.pendingRequests) {
  52497. return true;
  52498. }
  52499. return false;
  52500. },
  52501. getRequestXhr: function NetworkManager_getXhr(xhrId) {
  52502. return this.pendingRequests[xhrId].xhr;
  52503. },
  52504. isStreamingRequest: function NetworkManager_isStreamingRequest(xhrId) {
  52505. return !!this.pendingRequests[xhrId].onProgressiveData;
  52506. },
  52507. isPendingRequest: function NetworkManager_isPendingRequest(xhrId) {
  52508. return xhrId in this.pendingRequests;
  52509. },
  52510. isLoadedRequest: function NetworkManager_isLoadedRequest(xhrId) {
  52511. return xhrId in this.loadedRequests;
  52512. },
  52513. abortAllRequests: function NetworkManager_abortAllRequests() {
  52514. for (var xhrId in this.pendingRequests) {
  52515. this.abortRequest(xhrId | 0);
  52516. }
  52517. },
  52518. abortRequest: function NetworkManager_abortRequest(xhrId) {
  52519. var xhr = this.pendingRequests[xhrId].xhr;
  52520. delete this.pendingRequests[xhrId];
  52521. xhr.abort();
  52522. }
  52523. };
  52524. var assert = sharedUtil.assert;
  52525. var createPromiseCapability = sharedUtil.createPromiseCapability;
  52526. var isInt = sharedUtil.isInt;
  52527. var MissingPDFException = sharedUtil.MissingPDFException;
  52528. var UnexpectedResponseException = sharedUtil.UnexpectedResponseException;
  52529. function PDFNetworkStream(options) {
  52530. this._options = options;
  52531. var source = options.source;
  52532. this._manager = new NetworkManager(source.url, {
  52533. httpHeaders: source.httpHeaders,
  52534. withCredentials: source.withCredentials
  52535. });
  52536. this._rangeChunkSize = source.rangeChunkSize;
  52537. this._fullRequestReader = null;
  52538. this._rangeRequestReaders = [];
  52539. }
  52540. PDFNetworkStream.prototype = {
  52541. _onRangeRequestReaderClosed: function PDFNetworkStream_onRangeRequestReaderClosed(reader) {
  52542. var i = this._rangeRequestReaders.indexOf(reader);
  52543. if (i >= 0) {
  52544. this._rangeRequestReaders.splice(i, 1);
  52545. }
  52546. },
  52547. getFullReader: function PDFNetworkStream_getFullReader() {
  52548. assert(!this._fullRequestReader);
  52549. this._fullRequestReader = new PDFNetworkStreamFullRequestReader(this._manager, this._options);
  52550. return this._fullRequestReader;
  52551. },
  52552. getRangeReader: function PDFNetworkStream_getRangeReader(begin, end) {
  52553. var reader = new PDFNetworkStreamRangeRequestReader(this._manager, begin, end);
  52554. reader.onClosed = this._onRangeRequestReaderClosed.bind(this);
  52555. this._rangeRequestReaders.push(reader);
  52556. return reader;
  52557. },
  52558. cancelAllRequests: function PDFNetworkStream_cancelAllRequests(reason) {
  52559. if (this._fullRequestReader) {
  52560. this._fullRequestReader.cancel(reason);
  52561. }
  52562. var readers = this._rangeRequestReaders.slice(0);
  52563. readers.forEach(function (reader) {
  52564. reader.cancel(reason);
  52565. });
  52566. }
  52567. };
  52568. function PDFNetworkStreamFullRequestReader(manager, options) {
  52569. this._manager = manager;
  52570. var source = options.source;
  52571. var args = {
  52572. onHeadersReceived: this._onHeadersReceived.bind(this),
  52573. onProgressiveData: source.disableStream ? null : this._onProgressiveData.bind(this),
  52574. onDone: this._onDone.bind(this),
  52575. onError: this._onError.bind(this),
  52576. onProgress: this._onProgress.bind(this)
  52577. };
  52578. this._url = source.url;
  52579. this._fullRequestId = manager.requestFull(args);
  52580. this._headersReceivedCapability = createPromiseCapability();
  52581. this._disableRange = options.disableRange || false;
  52582. this._contentLength = source.length;
  52583. this._rangeChunkSize = source.rangeChunkSize;
  52584. if (!this._rangeChunkSize && !this._disableRange) {
  52585. this._disableRange = true;
  52586. }
  52587. this._isStreamingSupported = false;
  52588. this._isRangeSupported = false;
  52589. this._cachedChunks = [];
  52590. this._requests = [];
  52591. this._done = false;
  52592. this._storedError = undefined;
  52593. this.onProgress = null;
  52594. }
  52595. PDFNetworkStreamFullRequestReader.prototype = {
  52596. _validateRangeRequestCapabilities: function PDFNetworkStreamFullRequestReader_validateRangeRequestCapabilities() {
  52597. if (this._disableRange) {
  52598. return false;
  52599. }
  52600. var networkManager = this._manager;
  52601. if (!networkManager.isHttp) {
  52602. return false;
  52603. }
  52604. var fullRequestXhrId = this._fullRequestId;
  52605. var fullRequestXhr = networkManager.getRequestXhr(fullRequestXhrId);
  52606. if (fullRequestXhr.getResponseHeader('Accept-Ranges') !== 'bytes') {
  52607. return false;
  52608. }
  52609. var contentEncoding = fullRequestXhr.getResponseHeader('Content-Encoding') || 'identity';
  52610. if (contentEncoding !== 'identity') {
  52611. return false;
  52612. }
  52613. var length = fullRequestXhr.getResponseHeader('Content-Length');
  52614. length = parseInt(length, 10);
  52615. if (!isInt(length)) {
  52616. return false;
  52617. }
  52618. this._contentLength = length;
  52619. if (length <= 2 * this._rangeChunkSize) {
  52620. return false;
  52621. }
  52622. return true;
  52623. },
  52624. _onHeadersReceived: function PDFNetworkStreamFullRequestReader_onHeadersReceived() {
  52625. if (this._validateRangeRequestCapabilities()) {
  52626. this._isRangeSupported = true;
  52627. }
  52628. var networkManager = this._manager;
  52629. var fullRequestXhrId = this._fullRequestId;
  52630. if (networkManager.isStreamingRequest(fullRequestXhrId)) {
  52631. this._isStreamingSupported = true;
  52632. } else if (this._isRangeSupported) {
  52633. networkManager.abortRequest(fullRequestXhrId);
  52634. }
  52635. this._headersReceivedCapability.resolve();
  52636. },
  52637. _onProgressiveData: function PDFNetworkStreamFullRequestReader_onProgressiveData(chunk) {
  52638. if (this._requests.length > 0) {
  52639. var requestCapability = this._requests.shift();
  52640. requestCapability.resolve({
  52641. value: chunk,
  52642. done: false
  52643. });
  52644. } else {
  52645. this._cachedChunks.push(chunk);
  52646. }
  52647. },
  52648. _onDone: function PDFNetworkStreamFullRequestReader_onDone(args) {
  52649. if (args) {
  52650. this._onProgressiveData(args.chunk);
  52651. }
  52652. this._done = true;
  52653. if (this._cachedChunks.length > 0) {
  52654. return;
  52655. }
  52656. this._requests.forEach(function (requestCapability) {
  52657. requestCapability.resolve({
  52658. value: undefined,
  52659. done: true
  52660. });
  52661. });
  52662. this._requests = [];
  52663. },
  52664. _onError: function PDFNetworkStreamFullRequestReader_onError(status) {
  52665. var url = this._url;
  52666. var exception;
  52667. if (status === 404 || status === 0 && /^file:/.test(url)) {
  52668. exception = new MissingPDFException('Missing PDF "' + url + '".');
  52669. } else {
  52670. exception = new UnexpectedResponseException('Unexpected server response (' + status + ') while retrieving PDF "' + url + '".', status);
  52671. }
  52672. this._storedError = exception;
  52673. this._headersReceivedCapability.reject(exception);
  52674. this._requests.forEach(function (requestCapability) {
  52675. requestCapability.reject(exception);
  52676. });
  52677. this._requests = [];
  52678. this._cachedChunks = [];
  52679. },
  52680. _onProgress: function PDFNetworkStreamFullRequestReader_onProgress(data) {
  52681. if (this.onProgress) {
  52682. this.onProgress({
  52683. loaded: data.loaded,
  52684. total: data.lengthComputable ? data.total : this._contentLength
  52685. });
  52686. }
  52687. },
  52688. get isRangeSupported() {
  52689. return this._isRangeSupported;
  52690. },
  52691. get isStreamingSupported() {
  52692. return this._isStreamingSupported;
  52693. },
  52694. get contentLength() {
  52695. return this._contentLength;
  52696. },
  52697. get headersReady() {
  52698. return this._headersReceivedCapability.promise;
  52699. },
  52700. read: function PDFNetworkStreamFullRequestReader_read() {
  52701. if (this._storedError) {
  52702. return Promise.reject(this._storedError);
  52703. }
  52704. if (this._cachedChunks.length > 0) {
  52705. var chunk = this._cachedChunks.shift();
  52706. return Promise.resolve(chunk);
  52707. }
  52708. if (this._done) {
  52709. return Promise.resolve({
  52710. value: undefined,
  52711. done: true
  52712. });
  52713. }
  52714. var requestCapability = createPromiseCapability();
  52715. this._requests.push(requestCapability);
  52716. return requestCapability.promise;
  52717. },
  52718. cancel: function PDFNetworkStreamFullRequestReader_cancel(reason) {
  52719. this._done = true;
  52720. this._headersReceivedCapability.reject(reason);
  52721. this._requests.forEach(function (requestCapability) {
  52722. requestCapability.resolve({
  52723. value: undefined,
  52724. done: true
  52725. });
  52726. });
  52727. this._requests = [];
  52728. if (this._manager.isPendingRequest(this._fullRequestId)) {
  52729. this._manager.abortRequest(this._fullRequestId);
  52730. }
  52731. this._fullRequestReader = null;
  52732. }
  52733. };
  52734. function PDFNetworkStreamRangeRequestReader(manager, begin, end) {
  52735. this._manager = manager;
  52736. var args = {
  52737. onDone: this._onDone.bind(this),
  52738. onProgress: this._onProgress.bind(this)
  52739. };
  52740. this._requestId = manager.requestRange(begin, end, args);
  52741. this._requests = [];
  52742. this._queuedChunk = null;
  52743. this._done = false;
  52744. this.onProgress = null;
  52745. this.onClosed = null;
  52746. }
  52747. PDFNetworkStreamRangeRequestReader.prototype = {
  52748. _close: function PDFNetworkStreamRangeRequestReader_close() {
  52749. if (this.onClosed) {
  52750. this.onClosed(this);
  52751. }
  52752. },
  52753. _onDone: function PDFNetworkStreamRangeRequestReader_onDone(data) {
  52754. var chunk = data.chunk;
  52755. if (this._requests.length > 0) {
  52756. var requestCapability = this._requests.shift();
  52757. requestCapability.resolve({
  52758. value: chunk,
  52759. done: false
  52760. });
  52761. } else {
  52762. this._queuedChunk = chunk;
  52763. }
  52764. this._done = true;
  52765. this._requests.forEach(function (requestCapability) {
  52766. requestCapability.resolve({
  52767. value: undefined,
  52768. done: true
  52769. });
  52770. });
  52771. this._requests = [];
  52772. this._close();
  52773. },
  52774. _onProgress: function PDFNetworkStreamRangeRequestReader_onProgress(evt) {
  52775. if (!this.isStreamingSupported && this.onProgress) {
  52776. this.onProgress({ loaded: evt.loaded });
  52777. }
  52778. },
  52779. get isStreamingSupported() {
  52780. return false;
  52781. },
  52782. read: function PDFNetworkStreamRangeRequestReader_read() {
  52783. if (this._queuedChunk !== null) {
  52784. var chunk = this._queuedChunk;
  52785. this._queuedChunk = null;
  52786. return Promise.resolve({
  52787. value: chunk,
  52788. done: false
  52789. });
  52790. }
  52791. if (this._done) {
  52792. return Promise.resolve({
  52793. value: undefined,
  52794. done: true
  52795. });
  52796. }
  52797. var requestCapability = createPromiseCapability();
  52798. this._requests.push(requestCapability);
  52799. return requestCapability.promise;
  52800. },
  52801. cancel: function PDFNetworkStreamRangeRequestReader_cancel(reason) {
  52802. this._done = true;
  52803. this._requests.forEach(function (requestCapability) {
  52804. requestCapability.resolve({
  52805. value: undefined,
  52806. done: true
  52807. });
  52808. });
  52809. this._requests = [];
  52810. if (this._manager.isPendingRequest(this._requestId)) {
  52811. this._manager.abortRequest(this._requestId);
  52812. }
  52813. this._close();
  52814. }
  52815. };
  52816. coreWorker.setPDFNetworkStreamClass(PDFNetworkStream);
  52817. exports.PDFNetworkStream = PDFNetworkStream;
  52818. exports.NetworkManager = NetworkManager;
  52819. /***/ }),
  52820. /* 41 */
  52821. /***/ (function(module, exports, __w_pdfjs_require__) {
  52822. "use strict";
  52823. var sharedUtil = __w_pdfjs_require__(0);
  52824. var corePrimitives = __w_pdfjs_require__(1);
  52825. var coreFunction = __w_pdfjs_require__(7);
  52826. var coreColorSpace = __w_pdfjs_require__(4);
  52827. var UNSUPPORTED_FEATURES = sharedUtil.UNSUPPORTED_FEATURES;
  52828. var MissingDataException = sharedUtil.MissingDataException;
  52829. var Util = sharedUtil.Util;
  52830. var assert = sharedUtil.assert;
  52831. var error = sharedUtil.error;
  52832. var info = sharedUtil.info;
  52833. var warn = sharedUtil.warn;
  52834. var isStream = corePrimitives.isStream;
  52835. var PDFFunction = coreFunction.PDFFunction;
  52836. var ColorSpace = coreColorSpace.ColorSpace;
  52837. var ShadingType = {
  52838. FUNCTION_BASED: 1,
  52839. AXIAL: 2,
  52840. RADIAL: 3,
  52841. FREE_FORM_MESH: 4,
  52842. LATTICE_FORM_MESH: 5,
  52843. COONS_PATCH_MESH: 6,
  52844. TENSOR_PATCH_MESH: 7
  52845. };
  52846. var Pattern = function PatternClosure() {
  52847. function Pattern() {
  52848. error('should not call Pattern constructor');
  52849. }
  52850. Pattern.prototype = {
  52851. getPattern: function Pattern_getPattern(ctx) {
  52852. error('Should not call Pattern.getStyle: ' + ctx);
  52853. }
  52854. };
  52855. Pattern.parseShading = function Pattern_parseShading(shading, matrix, xref, res, handler) {
  52856. var dict = isStream(shading) ? shading.dict : shading;
  52857. var type = dict.get('ShadingType');
  52858. try {
  52859. switch (type) {
  52860. case ShadingType.AXIAL:
  52861. case ShadingType.RADIAL:
  52862. return new Shadings.RadialAxial(dict, matrix, xref, res);
  52863. case ShadingType.FREE_FORM_MESH:
  52864. case ShadingType.LATTICE_FORM_MESH:
  52865. case ShadingType.COONS_PATCH_MESH:
  52866. case ShadingType.TENSOR_PATCH_MESH:
  52867. return new Shadings.Mesh(shading, matrix, xref, res);
  52868. default:
  52869. throw new Error('Unsupported ShadingType: ' + type);
  52870. }
  52871. } catch (ex) {
  52872. if (ex instanceof MissingDataException) {
  52873. throw ex;
  52874. }
  52875. handler.send('UnsupportedFeature', { featureId: UNSUPPORTED_FEATURES.shadingPattern });
  52876. warn(ex);
  52877. return new Shadings.Dummy();
  52878. }
  52879. };
  52880. return Pattern;
  52881. }();
  52882. var Shadings = {};
  52883. Shadings.SMALL_NUMBER = 1e-6;
  52884. Shadings.RadialAxial = function RadialAxialClosure() {
  52885. function RadialAxial(dict, matrix, xref, res) {
  52886. this.matrix = matrix;
  52887. this.coordsArr = dict.getArray('Coords');
  52888. this.shadingType = dict.get('ShadingType');
  52889. this.type = 'Pattern';
  52890. var cs = dict.get('ColorSpace', 'CS');
  52891. cs = ColorSpace.parse(cs, xref, res);
  52892. this.cs = cs;
  52893. var t0 = 0.0, t1 = 1.0;
  52894. if (dict.has('Domain')) {
  52895. var domainArr = dict.getArray('Domain');
  52896. t0 = domainArr[0];
  52897. t1 = domainArr[1];
  52898. }
  52899. var extendStart = false, extendEnd = false;
  52900. if (dict.has('Extend')) {
  52901. var extendArr = dict.getArray('Extend');
  52902. extendStart = extendArr[0];
  52903. extendEnd = extendArr[1];
  52904. }
  52905. if (this.shadingType === ShadingType.RADIAL && (!extendStart || !extendEnd)) {
  52906. var x1 = this.coordsArr[0];
  52907. var y1 = this.coordsArr[1];
  52908. var r1 = this.coordsArr[2];
  52909. var x2 = this.coordsArr[3];
  52910. var y2 = this.coordsArr[4];
  52911. var r2 = this.coordsArr[5];
  52912. var distance = Math.sqrt((x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2));
  52913. if (r1 <= r2 + distance && r2 <= r1 + distance) {
  52914. warn('Unsupported radial gradient.');
  52915. }
  52916. }
  52917. this.extendStart = extendStart;
  52918. this.extendEnd = extendEnd;
  52919. var fnObj = dict.get('Function');
  52920. var fn = PDFFunction.parseArray(xref, fnObj);
  52921. var diff = t1 - t0;
  52922. var step = diff / 10;
  52923. var colorStops = this.colorStops = [];
  52924. if (t0 >= t1 || step <= 0) {
  52925. info('Bad shading domain.');
  52926. return;
  52927. }
  52928. var color = new Float32Array(cs.numComps), ratio = new Float32Array(1);
  52929. var rgbColor;
  52930. for (var i = t0; i <= t1; i += step) {
  52931. ratio[0] = i;
  52932. fn(ratio, 0, color, 0);
  52933. rgbColor = cs.getRgb(color, 0);
  52934. var cssColor = Util.makeCssRgb(rgbColor[0], rgbColor[1], rgbColor[2]);
  52935. colorStops.push([
  52936. (i - t0) / diff,
  52937. cssColor
  52938. ]);
  52939. }
  52940. var background = 'transparent';
  52941. if (dict.has('Background')) {
  52942. rgbColor = cs.getRgb(dict.get('Background'), 0);
  52943. background = Util.makeCssRgb(rgbColor[0], rgbColor[1], rgbColor[2]);
  52944. }
  52945. if (!extendStart) {
  52946. colorStops.unshift([
  52947. 0,
  52948. background
  52949. ]);
  52950. colorStops[1][0] += Shadings.SMALL_NUMBER;
  52951. }
  52952. if (!extendEnd) {
  52953. colorStops[colorStops.length - 1][0] -= Shadings.SMALL_NUMBER;
  52954. colorStops.push([
  52955. 1,
  52956. background
  52957. ]);
  52958. }
  52959. this.colorStops = colorStops;
  52960. }
  52961. RadialAxial.prototype = {
  52962. getIR: function RadialAxial_getIR() {
  52963. var coordsArr = this.coordsArr;
  52964. var shadingType = this.shadingType;
  52965. var type, p0, p1, r0, r1;
  52966. if (shadingType === ShadingType.AXIAL) {
  52967. p0 = [
  52968. coordsArr[0],
  52969. coordsArr[1]
  52970. ];
  52971. p1 = [
  52972. coordsArr[2],
  52973. coordsArr[3]
  52974. ];
  52975. r0 = null;
  52976. r1 = null;
  52977. type = 'axial';
  52978. } else if (shadingType === ShadingType.RADIAL) {
  52979. p0 = [
  52980. coordsArr[0],
  52981. coordsArr[1]
  52982. ];
  52983. p1 = [
  52984. coordsArr[3],
  52985. coordsArr[4]
  52986. ];
  52987. r0 = coordsArr[2];
  52988. r1 = coordsArr[5];
  52989. type = 'radial';
  52990. } else {
  52991. error('getPattern type unknown: ' + shadingType);
  52992. }
  52993. var matrix = this.matrix;
  52994. if (matrix) {
  52995. p0 = Util.applyTransform(p0, matrix);
  52996. p1 = Util.applyTransform(p1, matrix);
  52997. if (shadingType === ShadingType.RADIAL) {
  52998. var scale = Util.singularValueDecompose2dScale(matrix);
  52999. r0 *= scale[0];
  53000. r1 *= scale[1];
  53001. }
  53002. }
  53003. return [
  53004. 'RadialAxial',
  53005. type,
  53006. this.colorStops,
  53007. p0,
  53008. p1,
  53009. r0,
  53010. r1
  53011. ];
  53012. }
  53013. };
  53014. return RadialAxial;
  53015. }();
  53016. Shadings.Mesh = function MeshClosure() {
  53017. function MeshStreamReader(stream, context) {
  53018. this.stream = stream;
  53019. this.context = context;
  53020. this.buffer = 0;
  53021. this.bufferLength = 0;
  53022. var numComps = context.numComps;
  53023. this.tmpCompsBuf = new Float32Array(numComps);
  53024. var csNumComps = context.colorSpace.numComps;
  53025. this.tmpCsCompsBuf = context.colorFn ? new Float32Array(csNumComps) : this.tmpCompsBuf;
  53026. }
  53027. MeshStreamReader.prototype = {
  53028. get hasData() {
  53029. if (this.stream.end) {
  53030. return this.stream.pos < this.stream.end;
  53031. }
  53032. if (this.bufferLength > 0) {
  53033. return true;
  53034. }
  53035. var nextByte = this.stream.getByte();
  53036. if (nextByte < 0) {
  53037. return false;
  53038. }
  53039. this.buffer = nextByte;
  53040. this.bufferLength = 8;
  53041. return true;
  53042. },
  53043. readBits: function MeshStreamReader_readBits(n) {
  53044. var buffer = this.buffer;
  53045. var bufferLength = this.bufferLength;
  53046. if (n === 32) {
  53047. if (bufferLength === 0) {
  53048. return (this.stream.getByte() << 24 | this.stream.getByte() << 16 | this.stream.getByte() << 8 | this.stream.getByte()) >>> 0;
  53049. }
  53050. buffer = buffer << 24 | this.stream.getByte() << 16 | this.stream.getByte() << 8 | this.stream.getByte();
  53051. var nextByte = this.stream.getByte();
  53052. this.buffer = nextByte & (1 << bufferLength) - 1;
  53053. return (buffer << 8 - bufferLength | (nextByte & 0xFF) >> bufferLength) >>> 0;
  53054. }
  53055. if (n === 8 && bufferLength === 0) {
  53056. return this.stream.getByte();
  53057. }
  53058. while (bufferLength < n) {
  53059. buffer = buffer << 8 | this.stream.getByte();
  53060. bufferLength += 8;
  53061. }
  53062. bufferLength -= n;
  53063. this.bufferLength = bufferLength;
  53064. this.buffer = buffer & (1 << bufferLength) - 1;
  53065. return buffer >> bufferLength;
  53066. },
  53067. align: function MeshStreamReader_align() {
  53068. this.buffer = 0;
  53069. this.bufferLength = 0;
  53070. },
  53071. readFlag: function MeshStreamReader_readFlag() {
  53072. return this.readBits(this.context.bitsPerFlag);
  53073. },
  53074. readCoordinate: function MeshStreamReader_readCoordinate() {
  53075. var bitsPerCoordinate = this.context.bitsPerCoordinate;
  53076. var xi = this.readBits(bitsPerCoordinate);
  53077. var yi = this.readBits(bitsPerCoordinate);
  53078. var decode = this.context.decode;
  53079. var scale = bitsPerCoordinate < 32 ? 1 / ((1 << bitsPerCoordinate) - 1) : 2.3283064365386963e-10;
  53080. return [
  53081. xi * scale * (decode[1] - decode[0]) + decode[0],
  53082. yi * scale * (decode[3] - decode[2]) + decode[2]
  53083. ];
  53084. },
  53085. readComponents: function MeshStreamReader_readComponents() {
  53086. var numComps = this.context.numComps;
  53087. var bitsPerComponent = this.context.bitsPerComponent;
  53088. var scale = bitsPerComponent < 32 ? 1 / ((1 << bitsPerComponent) - 1) : 2.3283064365386963e-10;
  53089. var decode = this.context.decode;
  53090. var components = this.tmpCompsBuf;
  53091. for (var i = 0, j = 4; i < numComps; i++, j += 2) {
  53092. var ci = this.readBits(bitsPerComponent);
  53093. components[i] = ci * scale * (decode[j + 1] - decode[j]) + decode[j];
  53094. }
  53095. var color = this.tmpCsCompsBuf;
  53096. if (this.context.colorFn) {
  53097. this.context.colorFn(components, 0, color, 0);
  53098. }
  53099. return this.context.colorSpace.getRgb(color, 0);
  53100. }
  53101. };
  53102. function decodeType4Shading(mesh, reader) {
  53103. var coords = mesh.coords;
  53104. var colors = mesh.colors;
  53105. var operators = [];
  53106. var ps = [];
  53107. var verticesLeft = 0;
  53108. while (reader.hasData) {
  53109. var f = reader.readFlag();
  53110. var coord = reader.readCoordinate();
  53111. var color = reader.readComponents();
  53112. if (verticesLeft === 0) {
  53113. assert(0 <= f && f <= 2, 'Unknown type4 flag');
  53114. switch (f) {
  53115. case 0:
  53116. verticesLeft = 3;
  53117. break;
  53118. case 1:
  53119. ps.push(ps[ps.length - 2], ps[ps.length - 1]);
  53120. verticesLeft = 1;
  53121. break;
  53122. case 2:
  53123. ps.push(ps[ps.length - 3], ps[ps.length - 1]);
  53124. verticesLeft = 1;
  53125. break;
  53126. }
  53127. operators.push(f);
  53128. }
  53129. ps.push(coords.length);
  53130. coords.push(coord);
  53131. colors.push(color);
  53132. verticesLeft--;
  53133. reader.align();
  53134. }
  53135. mesh.figures.push({
  53136. type: 'triangles',
  53137. coords: new Int32Array(ps),
  53138. colors: new Int32Array(ps)
  53139. });
  53140. }
  53141. function decodeType5Shading(mesh, reader, verticesPerRow) {
  53142. var coords = mesh.coords;
  53143. var colors = mesh.colors;
  53144. var ps = [];
  53145. while (reader.hasData) {
  53146. var coord = reader.readCoordinate();
  53147. var color = reader.readComponents();
  53148. ps.push(coords.length);
  53149. coords.push(coord);
  53150. colors.push(color);
  53151. }
  53152. mesh.figures.push({
  53153. type: 'lattice',
  53154. coords: new Int32Array(ps),
  53155. colors: new Int32Array(ps),
  53156. verticesPerRow: verticesPerRow
  53157. });
  53158. }
  53159. var MIN_SPLIT_PATCH_CHUNKS_AMOUNT = 3;
  53160. var MAX_SPLIT_PATCH_CHUNKS_AMOUNT = 20;
  53161. var TRIANGLE_DENSITY = 20;
  53162. var getB = function getBClosure() {
  53163. function buildB(count) {
  53164. var lut = [];
  53165. for (var i = 0; i <= count; i++) {
  53166. var t = i / count, t_ = 1 - t;
  53167. lut.push(new Float32Array([
  53168. t_ * t_ * t_,
  53169. 3 * t * t_ * t_,
  53170. 3 * t * t * t_,
  53171. t * t * t
  53172. ]));
  53173. }
  53174. return lut;
  53175. }
  53176. var cache = [];
  53177. return function getB(count) {
  53178. if (!cache[count]) {
  53179. cache[count] = buildB(count);
  53180. }
  53181. return cache[count];
  53182. };
  53183. }();
  53184. function buildFigureFromPatch(mesh, index) {
  53185. var figure = mesh.figures[index];
  53186. assert(figure.type === 'patch', 'Unexpected patch mesh figure');
  53187. var coords = mesh.coords, colors = mesh.colors;
  53188. var pi = figure.coords;
  53189. var ci = figure.colors;
  53190. var figureMinX = Math.min(coords[pi[0]][0], coords[pi[3]][0], coords[pi[12]][0], coords[pi[15]][0]);
  53191. var figureMinY = Math.min(coords[pi[0]][1], coords[pi[3]][1], coords[pi[12]][1], coords[pi[15]][1]);
  53192. var figureMaxX = Math.max(coords[pi[0]][0], coords[pi[3]][0], coords[pi[12]][0], coords[pi[15]][0]);
  53193. var figureMaxY = Math.max(coords[pi[0]][1], coords[pi[3]][1], coords[pi[12]][1], coords[pi[15]][1]);
  53194. var splitXBy = Math.ceil((figureMaxX - figureMinX) * TRIANGLE_DENSITY / (mesh.bounds[2] - mesh.bounds[0]));
  53195. splitXBy = Math.max(MIN_SPLIT_PATCH_CHUNKS_AMOUNT, Math.min(MAX_SPLIT_PATCH_CHUNKS_AMOUNT, splitXBy));
  53196. var splitYBy = Math.ceil((figureMaxY - figureMinY) * TRIANGLE_DENSITY / (mesh.bounds[3] - mesh.bounds[1]));
  53197. splitYBy = Math.max(MIN_SPLIT_PATCH_CHUNKS_AMOUNT, Math.min(MAX_SPLIT_PATCH_CHUNKS_AMOUNT, splitYBy));
  53198. var verticesPerRow = splitXBy + 1;
  53199. var figureCoords = new Int32Array((splitYBy + 1) * verticesPerRow);
  53200. var figureColors = new Int32Array((splitYBy + 1) * verticesPerRow);
  53201. var k = 0;
  53202. var cl = new Uint8Array(3), cr = new Uint8Array(3);
  53203. var c0 = colors[ci[0]], c1 = colors[ci[1]], c2 = colors[ci[2]], c3 = colors[ci[3]];
  53204. var bRow = getB(splitYBy), bCol = getB(splitXBy);
  53205. for (var row = 0; row <= splitYBy; row++) {
  53206. cl[0] = (c0[0] * (splitYBy - row) + c2[0] * row) / splitYBy | 0;
  53207. cl[1] = (c0[1] * (splitYBy - row) + c2[1] * row) / splitYBy | 0;
  53208. cl[2] = (c0[2] * (splitYBy - row) + c2[2] * row) / splitYBy | 0;
  53209. cr[0] = (c1[0] * (splitYBy - row) + c3[0] * row) / splitYBy | 0;
  53210. cr[1] = (c1[1] * (splitYBy - row) + c3[1] * row) / splitYBy | 0;
  53211. cr[2] = (c1[2] * (splitYBy - row) + c3[2] * row) / splitYBy | 0;
  53212. for (var col = 0; col <= splitXBy; col++, k++) {
  53213. if ((row === 0 || row === splitYBy) && (col === 0 || col === splitXBy)) {
  53214. continue;
  53215. }
  53216. var x = 0, y = 0;
  53217. var q = 0;
  53218. for (var i = 0; i <= 3; i++) {
  53219. for (var j = 0; j <= 3; j++, q++) {
  53220. var m = bRow[row][i] * bCol[col][j];
  53221. x += coords[pi[q]][0] * m;
  53222. y += coords[pi[q]][1] * m;
  53223. }
  53224. }
  53225. figureCoords[k] = coords.length;
  53226. coords.push([
  53227. x,
  53228. y
  53229. ]);
  53230. figureColors[k] = colors.length;
  53231. var newColor = new Uint8Array(3);
  53232. newColor[0] = (cl[0] * (splitXBy - col) + cr[0] * col) / splitXBy | 0;
  53233. newColor[1] = (cl[1] * (splitXBy - col) + cr[1] * col) / splitXBy | 0;
  53234. newColor[2] = (cl[2] * (splitXBy - col) + cr[2] * col) / splitXBy | 0;
  53235. colors.push(newColor);
  53236. }
  53237. }
  53238. figureCoords[0] = pi[0];
  53239. figureColors[0] = ci[0];
  53240. figureCoords[splitXBy] = pi[3];
  53241. figureColors[splitXBy] = ci[1];
  53242. figureCoords[verticesPerRow * splitYBy] = pi[12];
  53243. figureColors[verticesPerRow * splitYBy] = ci[2];
  53244. figureCoords[verticesPerRow * splitYBy + splitXBy] = pi[15];
  53245. figureColors[verticesPerRow * splitYBy + splitXBy] = ci[3];
  53246. mesh.figures[index] = {
  53247. type: 'lattice',
  53248. coords: figureCoords,
  53249. colors: figureColors,
  53250. verticesPerRow: verticesPerRow
  53251. };
  53252. }
  53253. function decodeType6Shading(mesh, reader) {
  53254. var coords = mesh.coords;
  53255. var colors = mesh.colors;
  53256. var ps = new Int32Array(16);
  53257. var cs = new Int32Array(4);
  53258. while (reader.hasData) {
  53259. var f = reader.readFlag();
  53260. assert(0 <= f && f <= 3, 'Unknown type6 flag');
  53261. var i, ii;
  53262. var pi = coords.length;
  53263. for (i = 0, ii = f !== 0 ? 8 : 12; i < ii; i++) {
  53264. coords.push(reader.readCoordinate());
  53265. }
  53266. var ci = colors.length;
  53267. for (i = 0, ii = f !== 0 ? 2 : 4; i < ii; i++) {
  53268. colors.push(reader.readComponents());
  53269. }
  53270. var tmp1, tmp2, tmp3, tmp4;
  53271. switch (f) {
  53272. case 0:
  53273. ps[12] = pi + 3;
  53274. ps[13] = pi + 4;
  53275. ps[14] = pi + 5;
  53276. ps[15] = pi + 6;
  53277. ps[8] = pi + 2;
  53278. ps[11] = pi + 7;
  53279. ps[4] = pi + 1;
  53280. ps[7] = pi + 8;
  53281. ps[0] = pi;
  53282. ps[1] = pi + 11;
  53283. ps[2] = pi + 10;
  53284. ps[3] = pi + 9;
  53285. cs[2] = ci + 1;
  53286. cs[3] = ci + 2;
  53287. cs[0] = ci;
  53288. cs[1] = ci + 3;
  53289. break;
  53290. case 1:
  53291. tmp1 = ps[12];
  53292. tmp2 = ps[13];
  53293. tmp3 = ps[14];
  53294. tmp4 = ps[15];
  53295. ps[12] = tmp4;
  53296. ps[13] = pi + 0;
  53297. ps[14] = pi + 1;
  53298. ps[15] = pi + 2;
  53299. ps[8] = tmp3;
  53300. ps[11] = pi + 3;
  53301. ps[4] = tmp2;
  53302. ps[7] = pi + 4;
  53303. ps[0] = tmp1;
  53304. ps[1] = pi + 7;
  53305. ps[2] = pi + 6;
  53306. ps[3] = pi + 5;
  53307. tmp1 = cs[2];
  53308. tmp2 = cs[3];
  53309. cs[2] = tmp2;
  53310. cs[3] = ci;
  53311. cs[0] = tmp1;
  53312. cs[1] = ci + 1;
  53313. break;
  53314. case 2:
  53315. tmp1 = ps[15];
  53316. tmp2 = ps[11];
  53317. ps[12] = ps[3];
  53318. ps[13] = pi + 0;
  53319. ps[14] = pi + 1;
  53320. ps[15] = pi + 2;
  53321. ps[8] = ps[7];
  53322. ps[11] = pi + 3;
  53323. ps[4] = tmp2;
  53324. ps[7] = pi + 4;
  53325. ps[0] = tmp1;
  53326. ps[1] = pi + 7;
  53327. ps[2] = pi + 6;
  53328. ps[3] = pi + 5;
  53329. tmp1 = cs[3];
  53330. cs[2] = cs[1];
  53331. cs[3] = ci;
  53332. cs[0] = tmp1;
  53333. cs[1] = ci + 1;
  53334. break;
  53335. case 3:
  53336. ps[12] = ps[0];
  53337. ps[13] = pi + 0;
  53338. ps[14] = pi + 1;
  53339. ps[15] = pi + 2;
  53340. ps[8] = ps[1];
  53341. ps[11] = pi + 3;
  53342. ps[4] = ps[2];
  53343. ps[7] = pi + 4;
  53344. ps[0] = ps[3];
  53345. ps[1] = pi + 7;
  53346. ps[2] = pi + 6;
  53347. ps[3] = pi + 5;
  53348. cs[2] = cs[0];
  53349. cs[3] = ci;
  53350. cs[0] = cs[1];
  53351. cs[1] = ci + 1;
  53352. break;
  53353. }
  53354. ps[5] = coords.length;
  53355. coords.push([
  53356. (-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,
  53357. (-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
  53358. ]);
  53359. ps[6] = coords.length;
  53360. coords.push([
  53361. (-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,
  53362. (-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
  53363. ]);
  53364. ps[9] = coords.length;
  53365. coords.push([
  53366. (-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,
  53367. (-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
  53368. ]);
  53369. ps[10] = coords.length;
  53370. coords.push([
  53371. (-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,
  53372. (-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
  53373. ]);
  53374. mesh.figures.push({
  53375. type: 'patch',
  53376. coords: new Int32Array(ps),
  53377. colors: new Int32Array(cs)
  53378. });
  53379. }
  53380. }
  53381. function decodeType7Shading(mesh, reader) {
  53382. var coords = mesh.coords;
  53383. var colors = mesh.colors;
  53384. var ps = new Int32Array(16);
  53385. var cs = new Int32Array(4);
  53386. while (reader.hasData) {
  53387. var f = reader.readFlag();
  53388. assert(0 <= f && f <= 3, 'Unknown type7 flag');
  53389. var i, ii;
  53390. var pi = coords.length;
  53391. for (i = 0, ii = f !== 0 ? 12 : 16; i < ii; i++) {
  53392. coords.push(reader.readCoordinate());
  53393. }
  53394. var ci = colors.length;
  53395. for (i = 0, ii = f !== 0 ? 2 : 4; i < ii; i++) {
  53396. colors.push(reader.readComponents());
  53397. }
  53398. var tmp1, tmp2, tmp3, tmp4;
  53399. switch (f) {
  53400. case 0:
  53401. ps[12] = pi + 3;
  53402. ps[13] = pi + 4;
  53403. ps[14] = pi + 5;
  53404. ps[15] = pi + 6;
  53405. ps[8] = pi + 2;
  53406. ps[9] = pi + 13;
  53407. ps[10] = pi + 14;
  53408. ps[11] = pi + 7;
  53409. ps[4] = pi + 1;
  53410. ps[5] = pi + 12;
  53411. ps[6] = pi + 15;
  53412. ps[7] = pi + 8;
  53413. ps[0] = pi;
  53414. ps[1] = pi + 11;
  53415. ps[2] = pi + 10;
  53416. ps[3] = pi + 9;
  53417. cs[2] = ci + 1;
  53418. cs[3] = ci + 2;
  53419. cs[0] = ci;
  53420. cs[1] = ci + 3;
  53421. break;
  53422. case 1:
  53423. tmp1 = ps[12];
  53424. tmp2 = ps[13];
  53425. tmp3 = ps[14];
  53426. tmp4 = ps[15];
  53427. ps[12] = tmp4;
  53428. ps[13] = pi + 0;
  53429. ps[14] = pi + 1;
  53430. ps[15] = pi + 2;
  53431. ps[8] = tmp3;
  53432. ps[9] = pi + 9;
  53433. ps[10] = pi + 10;
  53434. ps[11] = pi + 3;
  53435. ps[4] = tmp2;
  53436. ps[5] = pi + 8;
  53437. ps[6] = pi + 11;
  53438. ps[7] = pi + 4;
  53439. ps[0] = tmp1;
  53440. ps[1] = pi + 7;
  53441. ps[2] = pi + 6;
  53442. ps[3] = pi + 5;
  53443. tmp1 = cs[2];
  53444. tmp2 = cs[3];
  53445. cs[2] = tmp2;
  53446. cs[3] = ci;
  53447. cs[0] = tmp1;
  53448. cs[1] = ci + 1;
  53449. break;
  53450. case 2:
  53451. tmp1 = ps[15];
  53452. tmp2 = ps[11];
  53453. ps[12] = ps[3];
  53454. ps[13] = pi + 0;
  53455. ps[14] = pi + 1;
  53456. ps[15] = pi + 2;
  53457. ps[8] = ps[7];
  53458. ps[9] = pi + 9;
  53459. ps[10] = pi + 10;
  53460. ps[11] = pi + 3;
  53461. ps[4] = tmp2;
  53462. ps[5] = pi + 8;
  53463. ps[6] = pi + 11;
  53464. ps[7] = pi + 4;
  53465. ps[0] = tmp1;
  53466. ps[1] = pi + 7;
  53467. ps[2] = pi + 6;
  53468. ps[3] = pi + 5;
  53469. tmp1 = cs[3];
  53470. cs[2] = cs[1];
  53471. cs[3] = ci;
  53472. cs[0] = tmp1;
  53473. cs[1] = ci + 1;
  53474. break;
  53475. case 3:
  53476. ps[12] = ps[0];
  53477. ps[13] = pi + 0;
  53478. ps[14] = pi + 1;
  53479. ps[15] = pi + 2;
  53480. ps[8] = ps[1];
  53481. ps[9] = pi + 9;
  53482. ps[10] = pi + 10;
  53483. ps[11] = pi + 3;
  53484. ps[4] = ps[2];
  53485. ps[5] = pi + 8;
  53486. ps[6] = pi + 11;
  53487. ps[7] = pi + 4;
  53488. ps[0] = ps[3];
  53489. ps[1] = pi + 7;
  53490. ps[2] = pi + 6;
  53491. ps[3] = pi + 5;
  53492. cs[2] = cs[0];
  53493. cs[3] = ci;
  53494. cs[0] = cs[1];
  53495. cs[1] = ci + 1;
  53496. break;
  53497. }
  53498. mesh.figures.push({
  53499. type: 'patch',
  53500. coords: new Int32Array(ps),
  53501. colors: new Int32Array(cs)
  53502. });
  53503. }
  53504. }
  53505. function updateBounds(mesh) {
  53506. var minX = mesh.coords[0][0], minY = mesh.coords[0][1], maxX = minX, maxY = minY;
  53507. for (var i = 1, ii = mesh.coords.length; i < ii; i++) {
  53508. var x = mesh.coords[i][0], y = mesh.coords[i][1];
  53509. minX = minX > x ? x : minX;
  53510. minY = minY > y ? y : minY;
  53511. maxX = maxX < x ? x : maxX;
  53512. maxY = maxY < y ? y : maxY;
  53513. }
  53514. mesh.bounds = [
  53515. minX,
  53516. minY,
  53517. maxX,
  53518. maxY
  53519. ];
  53520. }
  53521. function packData(mesh) {
  53522. var i, ii, j, jj;
  53523. var coords = mesh.coords;
  53524. var coordsPacked = new Float32Array(coords.length * 2);
  53525. for (i = 0, j = 0, ii = coords.length; i < ii; i++) {
  53526. var xy = coords[i];
  53527. coordsPacked[j++] = xy[0];
  53528. coordsPacked[j++] = xy[1];
  53529. }
  53530. mesh.coords = coordsPacked;
  53531. var colors = mesh.colors;
  53532. var colorsPacked = new Uint8Array(colors.length * 3);
  53533. for (i = 0, j = 0, ii = colors.length; i < ii; i++) {
  53534. var c = colors[i];
  53535. colorsPacked[j++] = c[0];
  53536. colorsPacked[j++] = c[1];
  53537. colorsPacked[j++] = c[2];
  53538. }
  53539. mesh.colors = colorsPacked;
  53540. var figures = mesh.figures;
  53541. for (i = 0, ii = figures.length; i < ii; i++) {
  53542. var figure = figures[i], ps = figure.coords, cs = figure.colors;
  53543. for (j = 0, jj = ps.length; j < jj; j++) {
  53544. ps[j] *= 2;
  53545. cs[j] *= 3;
  53546. }
  53547. }
  53548. }
  53549. function Mesh(stream, matrix, xref, res) {
  53550. assert(isStream(stream), 'Mesh data is not a stream');
  53551. var dict = stream.dict;
  53552. this.matrix = matrix;
  53553. this.shadingType = dict.get('ShadingType');
  53554. this.type = 'Pattern';
  53555. this.bbox = dict.getArray('BBox');
  53556. var cs = dict.get('ColorSpace', 'CS');
  53557. cs = ColorSpace.parse(cs, xref, res);
  53558. this.cs = cs;
  53559. this.background = dict.has('Background') ? cs.getRgb(dict.get('Background'), 0) : null;
  53560. var fnObj = dict.get('Function');
  53561. var fn = fnObj ? PDFFunction.parseArray(xref, fnObj) : null;
  53562. this.coords = [];
  53563. this.colors = [];
  53564. this.figures = [];
  53565. var decodeContext = {
  53566. bitsPerCoordinate: dict.get('BitsPerCoordinate'),
  53567. bitsPerComponent: dict.get('BitsPerComponent'),
  53568. bitsPerFlag: dict.get('BitsPerFlag'),
  53569. decode: dict.getArray('Decode'),
  53570. colorFn: fn,
  53571. colorSpace: cs,
  53572. numComps: fn ? 1 : cs.numComps
  53573. };
  53574. var reader = new MeshStreamReader(stream, decodeContext);
  53575. var patchMesh = false;
  53576. switch (this.shadingType) {
  53577. case ShadingType.FREE_FORM_MESH:
  53578. decodeType4Shading(this, reader);
  53579. break;
  53580. case ShadingType.LATTICE_FORM_MESH:
  53581. var verticesPerRow = dict.get('VerticesPerRow') | 0;
  53582. assert(verticesPerRow >= 2, 'Invalid VerticesPerRow');
  53583. decodeType5Shading(this, reader, verticesPerRow);
  53584. break;
  53585. case ShadingType.COONS_PATCH_MESH:
  53586. decodeType6Shading(this, reader);
  53587. patchMesh = true;
  53588. break;
  53589. case ShadingType.TENSOR_PATCH_MESH:
  53590. decodeType7Shading(this, reader);
  53591. patchMesh = true;
  53592. break;
  53593. default:
  53594. error('Unsupported mesh type.');
  53595. break;
  53596. }
  53597. if (patchMesh) {
  53598. updateBounds(this);
  53599. for (var i = 0, ii = this.figures.length; i < ii; i++) {
  53600. buildFigureFromPatch(this, i);
  53601. }
  53602. }
  53603. updateBounds(this);
  53604. packData(this);
  53605. }
  53606. Mesh.prototype = {
  53607. getIR: function Mesh_getIR() {
  53608. return [
  53609. 'Mesh',
  53610. this.shadingType,
  53611. this.coords,
  53612. this.colors,
  53613. this.figures,
  53614. this.bounds,
  53615. this.matrix,
  53616. this.bbox,
  53617. this.background
  53618. ];
  53619. }
  53620. };
  53621. return Mesh;
  53622. }();
  53623. Shadings.Dummy = function DummyClosure() {
  53624. function Dummy() {
  53625. this.type = 'Pattern';
  53626. }
  53627. Dummy.prototype = {
  53628. getIR: function Dummy_getIR() {
  53629. return ['Dummy'];
  53630. }
  53631. };
  53632. return Dummy;
  53633. }();
  53634. function getTilingPatternIR(operatorList, dict, args) {
  53635. var matrix = dict.getArray('Matrix');
  53636. var bbox = dict.getArray('BBox');
  53637. var xstep = dict.get('XStep');
  53638. var ystep = dict.get('YStep');
  53639. var paintType = dict.get('PaintType');
  53640. var tilingType = dict.get('TilingType');
  53641. return [
  53642. 'TilingPattern',
  53643. args,
  53644. operatorList,
  53645. matrix,
  53646. bbox,
  53647. xstep,
  53648. ystep,
  53649. paintType,
  53650. tilingType
  53651. ];
  53652. }
  53653. exports.Pattern = Pattern;
  53654. exports.getTilingPatternIR = getTilingPatternIR;
  53655. /***/ }),
  53656. /* 42 */
  53657. /***/ (function(module, exports, __w_pdfjs_require__) {
  53658. "use strict";
  53659. var sharedUtil = __w_pdfjs_require__(0);
  53660. var coreStream = __w_pdfjs_require__(2);
  53661. var coreChunkedStream = __w_pdfjs_require__(15);
  53662. var coreDocument = __w_pdfjs_require__(32);
  53663. var warn = sharedUtil.warn;
  53664. var createValidAbsoluteUrl = sharedUtil.createValidAbsoluteUrl;
  53665. var shadow = sharedUtil.shadow;
  53666. var NotImplementedException = sharedUtil.NotImplementedException;
  53667. var MissingDataException = sharedUtil.MissingDataException;
  53668. var createPromiseCapability = sharedUtil.createPromiseCapability;
  53669. var Util = sharedUtil.Util;
  53670. var Stream = coreStream.Stream;
  53671. var ChunkedStreamManager = coreChunkedStream.ChunkedStreamManager;
  53672. var PDFDocument = coreDocument.PDFDocument;
  53673. var BasePdfManager = function BasePdfManagerClosure() {
  53674. function BasePdfManager() {
  53675. throw new Error('Cannot initialize BaseManagerManager');
  53676. }
  53677. BasePdfManager.prototype = {
  53678. get docId() {
  53679. return this._docId;
  53680. },
  53681. get password() {
  53682. return this._password;
  53683. },
  53684. get docBaseUrl() {
  53685. var docBaseUrl = null;
  53686. if (this._docBaseUrl) {
  53687. var absoluteUrl = createValidAbsoluteUrl(this._docBaseUrl);
  53688. if (absoluteUrl) {
  53689. docBaseUrl = absoluteUrl.href;
  53690. } else {
  53691. warn('Invalid absolute docBaseUrl: "' + this._docBaseUrl + '".');
  53692. }
  53693. }
  53694. return shadow(this, 'docBaseUrl', docBaseUrl);
  53695. },
  53696. onLoadedStream: function BasePdfManager_onLoadedStream() {
  53697. throw new NotImplementedException();
  53698. },
  53699. ensureDoc: function BasePdfManager_ensureDoc(prop, args) {
  53700. return this.ensure(this.pdfDocument, prop, args);
  53701. },
  53702. ensureXRef: function BasePdfManager_ensureXRef(prop, args) {
  53703. return this.ensure(this.pdfDocument.xref, prop, args);
  53704. },
  53705. ensureCatalog: function BasePdfManager_ensureCatalog(prop, args) {
  53706. return this.ensure(this.pdfDocument.catalog, prop, args);
  53707. },
  53708. getPage: function BasePdfManager_getPage(pageIndex) {
  53709. return this.pdfDocument.getPage(pageIndex);
  53710. },
  53711. cleanup: function BasePdfManager_cleanup() {
  53712. return this.pdfDocument.cleanup();
  53713. },
  53714. ensure: function BasePdfManager_ensure(obj, prop, args) {
  53715. return new NotImplementedException();
  53716. },
  53717. requestRange: function BasePdfManager_requestRange(begin, end) {
  53718. return new NotImplementedException();
  53719. },
  53720. requestLoadedStream: function BasePdfManager_requestLoadedStream() {
  53721. return new NotImplementedException();
  53722. },
  53723. sendProgressiveData: function BasePdfManager_sendProgressiveData(chunk) {
  53724. return new NotImplementedException();
  53725. },
  53726. updatePassword: function BasePdfManager_updatePassword(password) {
  53727. this._password = password;
  53728. },
  53729. terminate: function BasePdfManager_terminate() {
  53730. return new NotImplementedException();
  53731. }
  53732. };
  53733. return BasePdfManager;
  53734. }();
  53735. var LocalPdfManager = function LocalPdfManagerClosure() {
  53736. function LocalPdfManager(docId, data, password, evaluatorOptions, docBaseUrl) {
  53737. this._docId = docId;
  53738. this._password = password;
  53739. this._docBaseUrl = docBaseUrl;
  53740. this.evaluatorOptions = evaluatorOptions;
  53741. var stream = new Stream(data);
  53742. this.pdfDocument = new PDFDocument(this, stream);
  53743. this._loadedStreamCapability = createPromiseCapability();
  53744. this._loadedStreamCapability.resolve(stream);
  53745. }
  53746. Util.inherit(LocalPdfManager, BasePdfManager, {
  53747. ensure: function LocalPdfManager_ensure(obj, prop, args) {
  53748. return new Promise(function (resolve, reject) {
  53749. try {
  53750. var value = obj[prop];
  53751. var result;
  53752. if (typeof value === 'function') {
  53753. result = value.apply(obj, args);
  53754. } else {
  53755. result = value;
  53756. }
  53757. resolve(result);
  53758. } catch (e) {
  53759. reject(e);
  53760. }
  53761. });
  53762. },
  53763. requestRange: function LocalPdfManager_requestRange(begin, end) {
  53764. return Promise.resolve();
  53765. },
  53766. requestLoadedStream: function LocalPdfManager_requestLoadedStream() {
  53767. },
  53768. onLoadedStream: function LocalPdfManager_onLoadedStream() {
  53769. return this._loadedStreamCapability.promise;
  53770. },
  53771. terminate: function LocalPdfManager_terminate() {
  53772. }
  53773. });
  53774. return LocalPdfManager;
  53775. }();
  53776. var NetworkPdfManager = function NetworkPdfManagerClosure() {
  53777. function NetworkPdfManager(docId, pdfNetworkStream, args, evaluatorOptions, docBaseUrl) {
  53778. this._docId = docId;
  53779. this._password = args.password;
  53780. this._docBaseUrl = docBaseUrl;
  53781. this.msgHandler = args.msgHandler;
  53782. this.evaluatorOptions = evaluatorOptions;
  53783. var params = {
  53784. msgHandler: args.msgHandler,
  53785. url: args.url,
  53786. length: args.length,
  53787. disableAutoFetch: args.disableAutoFetch,
  53788. rangeChunkSize: args.rangeChunkSize
  53789. };
  53790. this.streamManager = new ChunkedStreamManager(pdfNetworkStream, params);
  53791. this.pdfDocument = new PDFDocument(this, this.streamManager.getStream());
  53792. }
  53793. Util.inherit(NetworkPdfManager, BasePdfManager, {
  53794. ensure: function NetworkPdfManager_ensure(obj, prop, args) {
  53795. var pdfManager = this;
  53796. return new Promise(function (resolve, reject) {
  53797. function ensureHelper() {
  53798. try {
  53799. var result;
  53800. var value = obj[prop];
  53801. if (typeof value === 'function') {
  53802. result = value.apply(obj, args);
  53803. } else {
  53804. result = value;
  53805. }
  53806. resolve(result);
  53807. } catch (e) {
  53808. if (!(e instanceof MissingDataException)) {
  53809. reject(e);
  53810. return;
  53811. }
  53812. pdfManager.streamManager.requestRange(e.begin, e.end).then(ensureHelper, reject);
  53813. }
  53814. }
  53815. ensureHelper();
  53816. });
  53817. },
  53818. requestRange: function NetworkPdfManager_requestRange(begin, end) {
  53819. return this.streamManager.requestRange(begin, end);
  53820. },
  53821. requestLoadedStream: function NetworkPdfManager_requestLoadedStream() {
  53822. this.streamManager.requestAllChunks();
  53823. },
  53824. sendProgressiveData: function NetworkPdfManager_sendProgressiveData(chunk) {
  53825. this.streamManager.onReceiveData({ chunk: chunk });
  53826. },
  53827. onLoadedStream: function NetworkPdfManager_onLoadedStream() {
  53828. return this.streamManager.onLoadedStream();
  53829. },
  53830. terminate: function NetworkPdfManager_terminate() {
  53831. this.streamManager.abort();
  53832. }
  53833. });
  53834. return NetworkPdfManager;
  53835. }();
  53836. exports.LocalPdfManager = LocalPdfManager;
  53837. exports.NetworkPdfManager = NetworkPdfManager;
  53838. /***/ }),
  53839. /* 43 */
  53840. /***/ (function(module, exports, __w_pdfjs_require__) {
  53841. "use strict";
  53842. var sharedUtil = __w_pdfjs_require__(0);
  53843. var corePrimitives = __w_pdfjs_require__(1);
  53844. var error = sharedUtil.error;
  53845. var isSpace = sharedUtil.isSpace;
  53846. var EOF = corePrimitives.EOF;
  53847. var PostScriptParser = function PostScriptParserClosure() {
  53848. function PostScriptParser(lexer) {
  53849. this.lexer = lexer;
  53850. this.operators = [];
  53851. this.token = null;
  53852. this.prev = null;
  53853. }
  53854. PostScriptParser.prototype = {
  53855. nextToken: function PostScriptParser_nextToken() {
  53856. this.prev = this.token;
  53857. this.token = this.lexer.getToken();
  53858. },
  53859. accept: function PostScriptParser_accept(type) {
  53860. if (this.token.type === type) {
  53861. this.nextToken();
  53862. return true;
  53863. }
  53864. return false;
  53865. },
  53866. expect: function PostScriptParser_expect(type) {
  53867. if (this.accept(type)) {
  53868. return true;
  53869. }
  53870. error('Unexpected symbol: found ' + this.token.type + ' expected ' + type + '.');
  53871. },
  53872. parse: function PostScriptParser_parse() {
  53873. this.nextToken();
  53874. this.expect(PostScriptTokenTypes.LBRACE);
  53875. this.parseBlock();
  53876. this.expect(PostScriptTokenTypes.RBRACE);
  53877. return this.operators;
  53878. },
  53879. parseBlock: function PostScriptParser_parseBlock() {
  53880. while (true) {
  53881. if (this.accept(PostScriptTokenTypes.NUMBER)) {
  53882. this.operators.push(this.prev.value);
  53883. } else if (this.accept(PostScriptTokenTypes.OPERATOR)) {
  53884. this.operators.push(this.prev.value);
  53885. } else if (this.accept(PostScriptTokenTypes.LBRACE)) {
  53886. this.parseCondition();
  53887. } else {
  53888. return;
  53889. }
  53890. }
  53891. },
  53892. parseCondition: function PostScriptParser_parseCondition() {
  53893. var conditionLocation = this.operators.length;
  53894. this.operators.push(null, null);
  53895. this.parseBlock();
  53896. this.expect(PostScriptTokenTypes.RBRACE);
  53897. if (this.accept(PostScriptTokenTypes.IF)) {
  53898. this.operators[conditionLocation] = this.operators.length;
  53899. this.operators[conditionLocation + 1] = 'jz';
  53900. } else if (this.accept(PostScriptTokenTypes.LBRACE)) {
  53901. var jumpLocation = this.operators.length;
  53902. this.operators.push(null, null);
  53903. var endOfTrue = this.operators.length;
  53904. this.parseBlock();
  53905. this.expect(PostScriptTokenTypes.RBRACE);
  53906. this.expect(PostScriptTokenTypes.IFELSE);
  53907. this.operators[jumpLocation] = this.operators.length;
  53908. this.operators[jumpLocation + 1] = 'j';
  53909. this.operators[conditionLocation] = endOfTrue;
  53910. this.operators[conditionLocation + 1] = 'jz';
  53911. } else {
  53912. error('PS Function: error parsing conditional.');
  53913. }
  53914. }
  53915. };
  53916. return PostScriptParser;
  53917. }();
  53918. var PostScriptTokenTypes = {
  53919. LBRACE: 0,
  53920. RBRACE: 1,
  53921. NUMBER: 2,
  53922. OPERATOR: 3,
  53923. IF: 4,
  53924. IFELSE: 5
  53925. };
  53926. var PostScriptToken = function PostScriptTokenClosure() {
  53927. function PostScriptToken(type, value) {
  53928. this.type = type;
  53929. this.value = value;
  53930. }
  53931. var opCache = Object.create(null);
  53932. PostScriptToken.getOperator = function PostScriptToken_getOperator(op) {
  53933. var opValue = opCache[op];
  53934. if (opValue) {
  53935. return opValue;
  53936. }
  53937. return opCache[op] = new PostScriptToken(PostScriptTokenTypes.OPERATOR, op);
  53938. };
  53939. PostScriptToken.LBRACE = new PostScriptToken(PostScriptTokenTypes.LBRACE, '{');
  53940. PostScriptToken.RBRACE = new PostScriptToken(PostScriptTokenTypes.RBRACE, '}');
  53941. PostScriptToken.IF = new PostScriptToken(PostScriptTokenTypes.IF, 'IF');
  53942. PostScriptToken.IFELSE = new PostScriptToken(PostScriptTokenTypes.IFELSE, 'IFELSE');
  53943. return PostScriptToken;
  53944. }();
  53945. var PostScriptLexer = function PostScriptLexerClosure() {
  53946. function PostScriptLexer(stream) {
  53947. this.stream = stream;
  53948. this.nextChar();
  53949. this.strBuf = [];
  53950. }
  53951. PostScriptLexer.prototype = {
  53952. nextChar: function PostScriptLexer_nextChar() {
  53953. return this.currentChar = this.stream.getByte();
  53954. },
  53955. getToken: function PostScriptLexer_getToken() {
  53956. var comment = false;
  53957. var ch = this.currentChar;
  53958. while (true) {
  53959. if (ch < 0) {
  53960. return EOF;
  53961. }
  53962. if (comment) {
  53963. if (ch === 0x0A || ch === 0x0D) {
  53964. comment = false;
  53965. }
  53966. } else if (ch === 0x25) {
  53967. comment = true;
  53968. } else if (!isSpace(ch)) {
  53969. break;
  53970. }
  53971. ch = this.nextChar();
  53972. }
  53973. switch (ch | 0) {
  53974. case 0x30:
  53975. case 0x31:
  53976. case 0x32:
  53977. case 0x33:
  53978. case 0x34:
  53979. case 0x35:
  53980. case 0x36:
  53981. case 0x37:
  53982. case 0x38:
  53983. case 0x39:
  53984. case 0x2B:
  53985. case 0x2D:
  53986. case 0x2E:
  53987. return new PostScriptToken(PostScriptTokenTypes.NUMBER, this.getNumber());
  53988. case 0x7B:
  53989. this.nextChar();
  53990. return PostScriptToken.LBRACE;
  53991. case 0x7D:
  53992. this.nextChar();
  53993. return PostScriptToken.RBRACE;
  53994. }
  53995. var strBuf = this.strBuf;
  53996. strBuf.length = 0;
  53997. strBuf[0] = String.fromCharCode(ch);
  53998. while ((ch = this.nextChar()) >= 0 && (ch >= 0x41 && ch <= 0x5A || ch >= 0x61 && ch <= 0x7A)) {
  53999. strBuf.push(String.fromCharCode(ch));
  54000. }
  54001. var str = strBuf.join('');
  54002. switch (str.toLowerCase()) {
  54003. case 'if':
  54004. return PostScriptToken.IF;
  54005. case 'ifelse':
  54006. return PostScriptToken.IFELSE;
  54007. default:
  54008. return PostScriptToken.getOperator(str);
  54009. }
  54010. },
  54011. getNumber: function PostScriptLexer_getNumber() {
  54012. var ch = this.currentChar;
  54013. var strBuf = this.strBuf;
  54014. strBuf.length = 0;
  54015. strBuf[0] = String.fromCharCode(ch);
  54016. while ((ch = this.nextChar()) >= 0) {
  54017. if (ch >= 0x30 && ch <= 0x39 || ch === 0x2D || ch === 0x2E) {
  54018. strBuf.push(String.fromCharCode(ch));
  54019. } else {
  54020. break;
  54021. }
  54022. }
  54023. var value = parseFloat(strBuf.join(''));
  54024. if (isNaN(value)) {
  54025. error('Invalid floating point number: ' + value);
  54026. }
  54027. return value;
  54028. }
  54029. };
  54030. return PostScriptLexer;
  54031. }();
  54032. exports.PostScriptLexer = PostScriptLexer;
  54033. exports.PostScriptParser = PostScriptParser;
  54034. /***/ }),
  54035. /* 44 */
  54036. /***/ (function(module, exports, __w_pdfjs_require__) {
  54037. "use strict";
  54038. var sharedUtil = __w_pdfjs_require__(0);
  54039. var coreStream = __w_pdfjs_require__(2);
  54040. var coreEncodings = __w_pdfjs_require__(5);
  54041. var warn = sharedUtil.warn;
  54042. var isSpace = sharedUtil.isSpace;
  54043. var Stream = coreStream.Stream;
  54044. var getEncoding = coreEncodings.getEncoding;
  54045. var HINTING_ENABLED = false;
  54046. var Type1CharString = function Type1CharStringClosure() {
  54047. var COMMAND_MAP = {
  54048. 'hstem': [1],
  54049. 'vstem': [3],
  54050. 'vmoveto': [4],
  54051. 'rlineto': [5],
  54052. 'hlineto': [6],
  54053. 'vlineto': [7],
  54054. 'rrcurveto': [8],
  54055. 'callsubr': [10],
  54056. 'flex': [
  54057. 12,
  54058. 35
  54059. ],
  54060. 'drop': [
  54061. 12,
  54062. 18
  54063. ],
  54064. 'endchar': [14],
  54065. 'rmoveto': [21],
  54066. 'hmoveto': [22],
  54067. 'vhcurveto': [30],
  54068. 'hvcurveto': [31]
  54069. };
  54070. function Type1CharString() {
  54071. this.width = 0;
  54072. this.lsb = 0;
  54073. this.flexing = false;
  54074. this.output = [];
  54075. this.stack = [];
  54076. }
  54077. Type1CharString.prototype = {
  54078. convert: function Type1CharString_convert(encoded, subrs, seacAnalysisEnabled) {
  54079. var count = encoded.length;
  54080. var error = false;
  54081. var wx, sbx, subrNumber;
  54082. for (var i = 0; i < count; i++) {
  54083. var value = encoded[i];
  54084. if (value < 32) {
  54085. if (value === 12) {
  54086. value = (value << 8) + encoded[++i];
  54087. }
  54088. switch (value) {
  54089. case 1:
  54090. if (!HINTING_ENABLED) {
  54091. this.stack = [];
  54092. break;
  54093. }
  54094. error = this.executeCommand(2, COMMAND_MAP.hstem);
  54095. break;
  54096. case 3:
  54097. if (!HINTING_ENABLED) {
  54098. this.stack = [];
  54099. break;
  54100. }
  54101. error = this.executeCommand(2, COMMAND_MAP.vstem);
  54102. break;
  54103. case 4:
  54104. if (this.flexing) {
  54105. if (this.stack.length < 1) {
  54106. error = true;
  54107. break;
  54108. }
  54109. var dy = this.stack.pop();
  54110. this.stack.push(0, dy);
  54111. break;
  54112. }
  54113. error = this.executeCommand(1, COMMAND_MAP.vmoveto);
  54114. break;
  54115. case 5:
  54116. error = this.executeCommand(2, COMMAND_MAP.rlineto);
  54117. break;
  54118. case 6:
  54119. error = this.executeCommand(1, COMMAND_MAP.hlineto);
  54120. break;
  54121. case 7:
  54122. error = this.executeCommand(1, COMMAND_MAP.vlineto);
  54123. break;
  54124. case 8:
  54125. error = this.executeCommand(6, COMMAND_MAP.rrcurveto);
  54126. break;
  54127. case 9:
  54128. this.stack = [];
  54129. break;
  54130. case 10:
  54131. if (this.stack.length < 1) {
  54132. error = true;
  54133. break;
  54134. }
  54135. subrNumber = this.stack.pop();
  54136. error = this.convert(subrs[subrNumber], subrs, seacAnalysisEnabled);
  54137. break;
  54138. case 11:
  54139. return error;
  54140. case 13:
  54141. if (this.stack.length < 2) {
  54142. error = true;
  54143. break;
  54144. }
  54145. wx = this.stack.pop();
  54146. sbx = this.stack.pop();
  54147. this.lsb = sbx;
  54148. this.width = wx;
  54149. this.stack.push(wx, sbx);
  54150. error = this.executeCommand(2, COMMAND_MAP.hmoveto);
  54151. break;
  54152. case 14:
  54153. this.output.push(COMMAND_MAP.endchar[0]);
  54154. break;
  54155. case 21:
  54156. if (this.flexing) {
  54157. break;
  54158. }
  54159. error = this.executeCommand(2, COMMAND_MAP.rmoveto);
  54160. break;
  54161. case 22:
  54162. if (this.flexing) {
  54163. this.stack.push(0);
  54164. break;
  54165. }
  54166. error = this.executeCommand(1, COMMAND_MAP.hmoveto);
  54167. break;
  54168. case 30:
  54169. error = this.executeCommand(4, COMMAND_MAP.vhcurveto);
  54170. break;
  54171. case 31:
  54172. error = this.executeCommand(4, COMMAND_MAP.hvcurveto);
  54173. break;
  54174. case (12 << 8) + 0:
  54175. this.stack = [];
  54176. break;
  54177. case (12 << 8) + 1:
  54178. if (!HINTING_ENABLED) {
  54179. this.stack = [];
  54180. break;
  54181. }
  54182. error = this.executeCommand(2, COMMAND_MAP.vstem);
  54183. break;
  54184. case (12 << 8) + 2:
  54185. if (!HINTING_ENABLED) {
  54186. this.stack = [];
  54187. break;
  54188. }
  54189. error = this.executeCommand(2, COMMAND_MAP.hstem);
  54190. break;
  54191. case (12 << 8) + 6:
  54192. if (seacAnalysisEnabled) {
  54193. this.seac = this.stack.splice(-4, 4);
  54194. error = this.executeCommand(0, COMMAND_MAP.endchar);
  54195. } else {
  54196. error = this.executeCommand(4, COMMAND_MAP.endchar);
  54197. }
  54198. break;
  54199. case (12 << 8) + 7:
  54200. if (this.stack.length < 4) {
  54201. error = true;
  54202. break;
  54203. }
  54204. this.stack.pop();
  54205. wx = this.stack.pop();
  54206. var sby = this.stack.pop();
  54207. sbx = this.stack.pop();
  54208. this.lsb = sbx;
  54209. this.width = wx;
  54210. this.stack.push(wx, sbx, sby);
  54211. error = this.executeCommand(3, COMMAND_MAP.rmoveto);
  54212. break;
  54213. case (12 << 8) + 12:
  54214. if (this.stack.length < 2) {
  54215. error = true;
  54216. break;
  54217. }
  54218. var num2 = this.stack.pop();
  54219. var num1 = this.stack.pop();
  54220. this.stack.push(num1 / num2);
  54221. break;
  54222. case (12 << 8) + 16:
  54223. if (this.stack.length < 2) {
  54224. error = true;
  54225. break;
  54226. }
  54227. subrNumber = this.stack.pop();
  54228. var numArgs = this.stack.pop();
  54229. if (subrNumber === 0 && numArgs === 3) {
  54230. var flexArgs = this.stack.splice(this.stack.length - 17, 17);
  54231. 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]);
  54232. error = this.executeCommand(13, COMMAND_MAP.flex, true);
  54233. this.flexing = false;
  54234. this.stack.push(flexArgs[15], flexArgs[16]);
  54235. } else if (subrNumber === 1 && numArgs === 0) {
  54236. this.flexing = true;
  54237. }
  54238. break;
  54239. case (12 << 8) + 17:
  54240. break;
  54241. case (12 << 8) + 33:
  54242. this.stack = [];
  54243. break;
  54244. default:
  54245. warn('Unknown type 1 charstring command of "' + value + '"');
  54246. break;
  54247. }
  54248. if (error) {
  54249. break;
  54250. }
  54251. continue;
  54252. } else if (value <= 246) {
  54253. value = value - 139;
  54254. } else if (value <= 250) {
  54255. value = (value - 247) * 256 + encoded[++i] + 108;
  54256. } else if (value <= 254) {
  54257. value = -((value - 251) * 256) - encoded[++i] - 108;
  54258. } else {
  54259. value = (encoded[++i] & 0xff) << 24 | (encoded[++i] & 0xff) << 16 | (encoded[++i] & 0xff) << 8 | (encoded[++i] & 0xff) << 0;
  54260. }
  54261. this.stack.push(value);
  54262. }
  54263. return error;
  54264. },
  54265. executeCommand: function (howManyArgs, command, keepStack) {
  54266. var stackLength = this.stack.length;
  54267. if (howManyArgs > stackLength) {
  54268. return true;
  54269. }
  54270. var start = stackLength - howManyArgs;
  54271. for (var i = start; i < stackLength; i++) {
  54272. var value = this.stack[i];
  54273. if (value === (value | 0)) {
  54274. this.output.push(28, value >> 8 & 0xff, value & 0xff);
  54275. } else {
  54276. value = 65536 * value | 0;
  54277. this.output.push(255, value >> 24 & 0xFF, value >> 16 & 0xFF, value >> 8 & 0xFF, value & 0xFF);
  54278. }
  54279. }
  54280. this.output.push.apply(this.output, command);
  54281. if (keepStack) {
  54282. this.stack.splice(start, howManyArgs);
  54283. } else {
  54284. this.stack.length = 0;
  54285. }
  54286. return false;
  54287. }
  54288. };
  54289. return Type1CharString;
  54290. }();
  54291. var Type1Parser = function Type1ParserClosure() {
  54292. var EEXEC_ENCRYPT_KEY = 55665;
  54293. var CHAR_STRS_ENCRYPT_KEY = 4330;
  54294. function isHexDigit(code) {
  54295. return code >= 48 && code <= 57 || code >= 65 && code <= 70 || code >= 97 && code <= 102;
  54296. }
  54297. function decrypt(data, key, discardNumber) {
  54298. if (discardNumber >= data.length) {
  54299. return new Uint8Array(0);
  54300. }
  54301. var r = key | 0, c1 = 52845, c2 = 22719, i, j;
  54302. for (i = 0; i < discardNumber; i++) {
  54303. r = (data[i] + r) * c1 + c2 & (1 << 16) - 1;
  54304. }
  54305. var count = data.length - discardNumber;
  54306. var decrypted = new Uint8Array(count);
  54307. for (i = discardNumber, j = 0; j < count; i++, j++) {
  54308. var value = data[i];
  54309. decrypted[j] = value ^ r >> 8;
  54310. r = (value + r) * c1 + c2 & (1 << 16) - 1;
  54311. }
  54312. return decrypted;
  54313. }
  54314. function decryptAscii(data, key, discardNumber) {
  54315. var r = key | 0, c1 = 52845, c2 = 22719;
  54316. var count = data.length, maybeLength = count >>> 1;
  54317. var decrypted = new Uint8Array(maybeLength);
  54318. var i, j;
  54319. for (i = 0, j = 0; i < count; i++) {
  54320. var digit1 = data[i];
  54321. if (!isHexDigit(digit1)) {
  54322. continue;
  54323. }
  54324. i++;
  54325. var digit2;
  54326. while (i < count && !isHexDigit(digit2 = data[i])) {
  54327. i++;
  54328. }
  54329. if (i < count) {
  54330. var value = parseInt(String.fromCharCode(digit1, digit2), 16);
  54331. decrypted[j++] = value ^ r >> 8;
  54332. r = (value + r) * c1 + c2 & (1 << 16) - 1;
  54333. }
  54334. }
  54335. return Array.prototype.slice.call(decrypted, discardNumber, j);
  54336. }
  54337. function isSpecial(c) {
  54338. return c === 0x2F || c === 0x5B || c === 0x5D || c === 0x7B || c === 0x7D || c === 0x28 || c === 0x29;
  54339. }
  54340. function Type1Parser(stream, encrypted, seacAnalysisEnabled) {
  54341. if (encrypted) {
  54342. var data = stream.getBytes();
  54343. var isBinary = !(isHexDigit(data[0]) && isHexDigit(data[1]) && isHexDigit(data[2]) && isHexDigit(data[3]));
  54344. stream = new Stream(isBinary ? decrypt(data, EEXEC_ENCRYPT_KEY, 4) : decryptAscii(data, EEXEC_ENCRYPT_KEY, 4));
  54345. }
  54346. this.seacAnalysisEnabled = !!seacAnalysisEnabled;
  54347. this.stream = stream;
  54348. this.nextChar();
  54349. }
  54350. Type1Parser.prototype = {
  54351. readNumberArray: function Type1Parser_readNumberArray() {
  54352. this.getToken();
  54353. var array = [];
  54354. while (true) {
  54355. var token = this.getToken();
  54356. if (token === null || token === ']' || token === '}') {
  54357. break;
  54358. }
  54359. array.push(parseFloat(token || 0));
  54360. }
  54361. return array;
  54362. },
  54363. readNumber: function Type1Parser_readNumber() {
  54364. var token = this.getToken();
  54365. return parseFloat(token || 0);
  54366. },
  54367. readInt: function Type1Parser_readInt() {
  54368. var token = this.getToken();
  54369. return parseInt(token || 0, 10) | 0;
  54370. },
  54371. readBoolean: function Type1Parser_readBoolean() {
  54372. var token = this.getToken();
  54373. return token === 'true' ? 1 : 0;
  54374. },
  54375. nextChar: function Type1_nextChar() {
  54376. return this.currentChar = this.stream.getByte();
  54377. },
  54378. getToken: function Type1Parser_getToken() {
  54379. var comment = false;
  54380. var ch = this.currentChar;
  54381. while (true) {
  54382. if (ch === -1) {
  54383. return null;
  54384. }
  54385. if (comment) {
  54386. if (ch === 0x0A || ch === 0x0D) {
  54387. comment = false;
  54388. }
  54389. } else if (ch === 0x25) {
  54390. comment = true;
  54391. } else if (!isSpace(ch)) {
  54392. break;
  54393. }
  54394. ch = this.nextChar();
  54395. }
  54396. if (isSpecial(ch)) {
  54397. this.nextChar();
  54398. return String.fromCharCode(ch);
  54399. }
  54400. var token = '';
  54401. do {
  54402. token += String.fromCharCode(ch);
  54403. ch = this.nextChar();
  54404. } while (ch >= 0 && !isSpace(ch) && !isSpecial(ch));
  54405. return token;
  54406. },
  54407. extractFontProgram: function Type1Parser_extractFontProgram() {
  54408. var stream = this.stream;
  54409. var subrs = [], charstrings = [];
  54410. var privateData = Object.create(null);
  54411. privateData['lenIV'] = 4;
  54412. var program = {
  54413. subrs: [],
  54414. charstrings: [],
  54415. properties: { 'privateData': privateData }
  54416. };
  54417. var token, length, data, lenIV, encoded;
  54418. while ((token = this.getToken()) !== null) {
  54419. if (token !== '/') {
  54420. continue;
  54421. }
  54422. token = this.getToken();
  54423. switch (token) {
  54424. case 'CharStrings':
  54425. this.getToken();
  54426. this.getToken();
  54427. this.getToken();
  54428. this.getToken();
  54429. while (true) {
  54430. token = this.getToken();
  54431. if (token === null || token === 'end') {
  54432. break;
  54433. }
  54434. if (token !== '/') {
  54435. continue;
  54436. }
  54437. var glyph = this.getToken();
  54438. length = this.readInt();
  54439. this.getToken();
  54440. data = stream.makeSubStream(stream.pos, length);
  54441. lenIV = program.properties.privateData['lenIV'];
  54442. encoded = decrypt(data.getBytes(), CHAR_STRS_ENCRYPT_KEY, lenIV);
  54443. stream.skip(length);
  54444. this.nextChar();
  54445. token = this.getToken();
  54446. if (token === 'noaccess') {
  54447. this.getToken();
  54448. }
  54449. charstrings.push({
  54450. glyph: glyph,
  54451. encoded: encoded
  54452. });
  54453. }
  54454. break;
  54455. case 'Subrs':
  54456. this.readInt();
  54457. this.getToken();
  54458. while ((token = this.getToken()) === 'dup') {
  54459. var index = this.readInt();
  54460. length = this.readInt();
  54461. this.getToken();
  54462. data = stream.makeSubStream(stream.pos, length);
  54463. lenIV = program.properties.privateData['lenIV'];
  54464. encoded = decrypt(data.getBytes(), CHAR_STRS_ENCRYPT_KEY, lenIV);
  54465. stream.skip(length);
  54466. this.nextChar();
  54467. token = this.getToken();
  54468. if (token === 'noaccess') {
  54469. this.getToken();
  54470. }
  54471. subrs[index] = encoded;
  54472. }
  54473. break;
  54474. case 'BlueValues':
  54475. case 'OtherBlues':
  54476. case 'FamilyBlues':
  54477. case 'FamilyOtherBlues':
  54478. var blueArray = this.readNumberArray();
  54479. if (blueArray.length > 0 && blueArray.length % 2 === 0 && HINTING_ENABLED) {
  54480. program.properties.privateData[token] = blueArray;
  54481. }
  54482. break;
  54483. case 'StemSnapH':
  54484. case 'StemSnapV':
  54485. program.properties.privateData[token] = this.readNumberArray();
  54486. break;
  54487. case 'StdHW':
  54488. case 'StdVW':
  54489. program.properties.privateData[token] = this.readNumberArray()[0];
  54490. break;
  54491. case 'BlueShift':
  54492. case 'lenIV':
  54493. case 'BlueFuzz':
  54494. case 'BlueScale':
  54495. case 'LanguageGroup':
  54496. case 'ExpansionFactor':
  54497. program.properties.privateData[token] = this.readNumber();
  54498. break;
  54499. case 'ForceBold':
  54500. program.properties.privateData[token] = this.readBoolean();
  54501. break;
  54502. }
  54503. }
  54504. for (var i = 0; i < charstrings.length; i++) {
  54505. glyph = charstrings[i].glyph;
  54506. encoded = charstrings[i].encoded;
  54507. var charString = new Type1CharString();
  54508. var error = charString.convert(encoded, subrs, this.seacAnalysisEnabled);
  54509. var output = charString.output;
  54510. if (error) {
  54511. output = [14];
  54512. }
  54513. program.charstrings.push({
  54514. glyphName: glyph,
  54515. charstring: output,
  54516. width: charString.width,
  54517. lsb: charString.lsb,
  54518. seac: charString.seac
  54519. });
  54520. }
  54521. return program;
  54522. },
  54523. extractFontHeader: function Type1Parser_extractFontHeader(properties) {
  54524. var token;
  54525. while ((token = this.getToken()) !== null) {
  54526. if (token !== '/') {
  54527. continue;
  54528. }
  54529. token = this.getToken();
  54530. switch (token) {
  54531. case 'FontMatrix':
  54532. var matrix = this.readNumberArray();
  54533. properties.fontMatrix = matrix;
  54534. break;
  54535. case 'Encoding':
  54536. var encodingArg = this.getToken();
  54537. var encoding;
  54538. if (!/^\d+$/.test(encodingArg)) {
  54539. encoding = getEncoding(encodingArg);
  54540. } else {
  54541. encoding = [];
  54542. var size = parseInt(encodingArg, 10) | 0;
  54543. this.getToken();
  54544. for (var j = 0; j < size; j++) {
  54545. token = this.getToken();
  54546. while (token !== 'dup' && token !== 'def') {
  54547. token = this.getToken();
  54548. if (token === null) {
  54549. return;
  54550. }
  54551. }
  54552. if (token === 'def') {
  54553. break;
  54554. }
  54555. var index = this.readInt();
  54556. this.getToken();
  54557. var glyph = this.getToken();
  54558. encoding[index] = glyph;
  54559. this.getToken();
  54560. }
  54561. }
  54562. properties.builtInEncoding = encoding;
  54563. break;
  54564. case 'FontBBox':
  54565. var fontBBox = this.readNumberArray();
  54566. properties.ascent = fontBBox[3];
  54567. properties.descent = fontBBox[1];
  54568. properties.ascentScaled = true;
  54569. break;
  54570. }
  54571. }
  54572. }
  54573. };
  54574. return Type1Parser;
  54575. }();
  54576. exports.Type1Parser = Type1Parser;
  54577. /***/ }),
  54578. /* 45 */
  54579. /***/ (function(module, exports, __w_pdfjs_require__) {
  54580. "use strict";
  54581. var sharedUtil = __w_pdfjs_require__(0);
  54582. var displayDOMUtils = __w_pdfjs_require__(3);
  54583. var displayPatternHelper = __w_pdfjs_require__(47);
  54584. var displayWebGL = __w_pdfjs_require__(24);
  54585. var FONT_IDENTITY_MATRIX = sharedUtil.FONT_IDENTITY_MATRIX;
  54586. var IDENTITY_MATRIX = sharedUtil.IDENTITY_MATRIX;
  54587. var ImageKind = sharedUtil.ImageKind;
  54588. var OPS = sharedUtil.OPS;
  54589. var TextRenderingMode = sharedUtil.TextRenderingMode;
  54590. var Uint32ArrayView = sharedUtil.Uint32ArrayView;
  54591. var Util = sharedUtil.Util;
  54592. var assert = sharedUtil.assert;
  54593. var info = sharedUtil.info;
  54594. var isNum = sharedUtil.isNum;
  54595. var isArray = sharedUtil.isArray;
  54596. var isLittleEndian = sharedUtil.isLittleEndian;
  54597. var error = sharedUtil.error;
  54598. var shadow = sharedUtil.shadow;
  54599. var warn = sharedUtil.warn;
  54600. var TilingPattern = displayPatternHelper.TilingPattern;
  54601. var getShadingPatternFromIR = displayPatternHelper.getShadingPatternFromIR;
  54602. var WebGLUtils = displayWebGL.WebGLUtils;
  54603. var hasCanvasTypedArrays = displayDOMUtils.hasCanvasTypedArrays;
  54604. var MIN_FONT_SIZE = 16;
  54605. var MAX_FONT_SIZE = 100;
  54606. var MAX_GROUP_SIZE = 4096;
  54607. var MIN_WIDTH_FACTOR = 0.65;
  54608. var COMPILE_TYPE3_GLYPHS = true;
  54609. var MAX_SIZE_TO_COMPILE = 1000;
  54610. var FULL_CHUNK_HEIGHT = 16;
  54611. var HasCanvasTypedArraysCached = {
  54612. get value() {
  54613. return shadow(HasCanvasTypedArraysCached, 'value', hasCanvasTypedArrays());
  54614. }
  54615. };
  54616. var IsLittleEndianCached = {
  54617. get value() {
  54618. return shadow(IsLittleEndianCached, 'value', isLittleEndian());
  54619. }
  54620. };
  54621. function addContextCurrentTransform(ctx) {
  54622. if (!ctx.mozCurrentTransform) {
  54623. ctx._originalSave = ctx.save;
  54624. ctx._originalRestore = ctx.restore;
  54625. ctx._originalRotate = ctx.rotate;
  54626. ctx._originalScale = ctx.scale;
  54627. ctx._originalTranslate = ctx.translate;
  54628. ctx._originalTransform = ctx.transform;
  54629. ctx._originalSetTransform = ctx.setTransform;
  54630. ctx._transformMatrix = ctx._transformMatrix || [
  54631. 1,
  54632. 0,
  54633. 0,
  54634. 1,
  54635. 0,
  54636. 0
  54637. ];
  54638. ctx._transformStack = [];
  54639. Object.defineProperty(ctx, 'mozCurrentTransform', {
  54640. get: function getCurrentTransform() {
  54641. return this._transformMatrix;
  54642. }
  54643. });
  54644. Object.defineProperty(ctx, 'mozCurrentTransformInverse', {
  54645. get: function getCurrentTransformInverse() {
  54646. var m = this._transformMatrix;
  54647. var a = m[0], b = m[1], c = m[2], d = m[3], e = m[4], f = m[5];
  54648. var ad_bc = a * d - b * c;
  54649. var bc_ad = b * c - a * d;
  54650. return [
  54651. d / ad_bc,
  54652. b / bc_ad,
  54653. c / bc_ad,
  54654. a / ad_bc,
  54655. (d * e - c * f) / bc_ad,
  54656. (b * e - a * f) / ad_bc
  54657. ];
  54658. }
  54659. });
  54660. ctx.save = function ctxSave() {
  54661. var old = this._transformMatrix;
  54662. this._transformStack.push(old);
  54663. this._transformMatrix = old.slice(0, 6);
  54664. this._originalSave();
  54665. };
  54666. ctx.restore = function ctxRestore() {
  54667. var prev = this._transformStack.pop();
  54668. if (prev) {
  54669. this._transformMatrix = prev;
  54670. this._originalRestore();
  54671. }
  54672. };
  54673. ctx.translate = function ctxTranslate(x, y) {
  54674. var m = this._transformMatrix;
  54675. m[4] = m[0] * x + m[2] * y + m[4];
  54676. m[5] = m[1] * x + m[3] * y + m[5];
  54677. this._originalTranslate(x, y);
  54678. };
  54679. ctx.scale = function ctxScale(x, y) {
  54680. var m = this._transformMatrix;
  54681. m[0] = m[0] * x;
  54682. m[1] = m[1] * x;
  54683. m[2] = m[2] * y;
  54684. m[3] = m[3] * y;
  54685. this._originalScale(x, y);
  54686. };
  54687. ctx.transform = function ctxTransform(a, b, c, d, e, f) {
  54688. var m = this._transformMatrix;
  54689. this._transformMatrix = [
  54690. m[0] * a + m[2] * b,
  54691. m[1] * a + m[3] * b,
  54692. m[0] * c + m[2] * d,
  54693. m[1] * c + m[3] * d,
  54694. m[0] * e + m[2] * f + m[4],
  54695. m[1] * e + m[3] * f + m[5]
  54696. ];
  54697. ctx._originalTransform(a, b, c, d, e, f);
  54698. };
  54699. ctx.setTransform = function ctxSetTransform(a, b, c, d, e, f) {
  54700. this._transformMatrix = [
  54701. a,
  54702. b,
  54703. c,
  54704. d,
  54705. e,
  54706. f
  54707. ];
  54708. ctx._originalSetTransform(a, b, c, d, e, f);
  54709. };
  54710. ctx.rotate = function ctxRotate(angle) {
  54711. var cosValue = Math.cos(angle);
  54712. var sinValue = Math.sin(angle);
  54713. var m = this._transformMatrix;
  54714. this._transformMatrix = [
  54715. m[0] * cosValue + m[2] * sinValue,
  54716. m[1] * cosValue + m[3] * sinValue,
  54717. m[0] * -sinValue + m[2] * cosValue,
  54718. m[1] * -sinValue + m[3] * cosValue,
  54719. m[4],
  54720. m[5]
  54721. ];
  54722. this._originalRotate(angle);
  54723. };
  54724. }
  54725. }
  54726. var CachedCanvases = function CachedCanvasesClosure() {
  54727. function CachedCanvases(canvasFactory) {
  54728. this.canvasFactory = canvasFactory;
  54729. this.cache = Object.create(null);
  54730. }
  54731. CachedCanvases.prototype = {
  54732. getCanvas: function CachedCanvases_getCanvas(id, width, height, trackTransform) {
  54733. var canvasEntry;
  54734. if (this.cache[id] !== undefined) {
  54735. canvasEntry = this.cache[id];
  54736. this.canvasFactory.reset(canvasEntry, width, height);
  54737. canvasEntry.context.setTransform(1, 0, 0, 1, 0, 0);
  54738. } else {
  54739. canvasEntry = this.canvasFactory.create(width, height);
  54740. this.cache[id] = canvasEntry;
  54741. }
  54742. if (trackTransform) {
  54743. addContextCurrentTransform(canvasEntry.context);
  54744. }
  54745. return canvasEntry;
  54746. },
  54747. clear: function () {
  54748. for (var id in this.cache) {
  54749. var canvasEntry = this.cache[id];
  54750. this.canvasFactory.destroy(canvasEntry);
  54751. delete this.cache[id];
  54752. }
  54753. }
  54754. };
  54755. return CachedCanvases;
  54756. }();
  54757. function compileType3Glyph(imgData) {
  54758. var POINT_TO_PROCESS_LIMIT = 1000;
  54759. var width = imgData.width, height = imgData.height;
  54760. var i, j, j0, width1 = width + 1;
  54761. var points = new Uint8Array(width1 * (height + 1));
  54762. var POINT_TYPES = new Uint8Array([
  54763. 0,
  54764. 2,
  54765. 4,
  54766. 0,
  54767. 1,
  54768. 0,
  54769. 5,
  54770. 4,
  54771. 8,
  54772. 10,
  54773. 0,
  54774. 8,
  54775. 0,
  54776. 2,
  54777. 1,
  54778. 0
  54779. ]);
  54780. var lineSize = width + 7 & ~7, data0 = imgData.data;
  54781. var data = new Uint8Array(lineSize * height), pos = 0, ii;
  54782. for (i = 0, ii = data0.length; i < ii; i++) {
  54783. var mask = 128, elem = data0[i];
  54784. while (mask > 0) {
  54785. data[pos++] = elem & mask ? 0 : 255;
  54786. mask >>= 1;
  54787. }
  54788. }
  54789. var count = 0;
  54790. pos = 0;
  54791. if (data[pos] !== 0) {
  54792. points[0] = 1;
  54793. ++count;
  54794. }
  54795. for (j = 1; j < width; j++) {
  54796. if (data[pos] !== data[pos + 1]) {
  54797. points[j] = data[pos] ? 2 : 1;
  54798. ++count;
  54799. }
  54800. pos++;
  54801. }
  54802. if (data[pos] !== 0) {
  54803. points[j] = 2;
  54804. ++count;
  54805. }
  54806. for (i = 1; i < height; i++) {
  54807. pos = i * lineSize;
  54808. j0 = i * width1;
  54809. if (data[pos - lineSize] !== data[pos]) {
  54810. points[j0] = data[pos] ? 1 : 8;
  54811. ++count;
  54812. }
  54813. var sum = (data[pos] ? 4 : 0) + (data[pos - lineSize] ? 8 : 0);
  54814. for (j = 1; j < width; j++) {
  54815. sum = (sum >> 2) + (data[pos + 1] ? 4 : 0) + (data[pos - lineSize + 1] ? 8 : 0);
  54816. if (POINT_TYPES[sum]) {
  54817. points[j0 + j] = POINT_TYPES[sum];
  54818. ++count;
  54819. }
  54820. pos++;
  54821. }
  54822. if (data[pos - lineSize] !== data[pos]) {
  54823. points[j0 + j] = data[pos] ? 2 : 4;
  54824. ++count;
  54825. }
  54826. if (count > POINT_TO_PROCESS_LIMIT) {
  54827. return null;
  54828. }
  54829. }
  54830. pos = lineSize * (height - 1);
  54831. j0 = i * width1;
  54832. if (data[pos] !== 0) {
  54833. points[j0] = 8;
  54834. ++count;
  54835. }
  54836. for (j = 1; j < width; j++) {
  54837. if (data[pos] !== data[pos + 1]) {
  54838. points[j0 + j] = data[pos] ? 4 : 8;
  54839. ++count;
  54840. }
  54841. pos++;
  54842. }
  54843. if (data[pos] !== 0) {
  54844. points[j0 + j] = 4;
  54845. ++count;
  54846. }
  54847. if (count > POINT_TO_PROCESS_LIMIT) {
  54848. return null;
  54849. }
  54850. var steps = new Int32Array([
  54851. 0,
  54852. width1,
  54853. -1,
  54854. 0,
  54855. -width1,
  54856. 0,
  54857. 0,
  54858. 0,
  54859. 1
  54860. ]);
  54861. var outlines = [];
  54862. for (i = 0; count && i <= height; i++) {
  54863. var p = i * width1;
  54864. var end = p + width;
  54865. while (p < end && !points[p]) {
  54866. p++;
  54867. }
  54868. if (p === end) {
  54869. continue;
  54870. }
  54871. var coords = [
  54872. p % width1,
  54873. i
  54874. ];
  54875. var type = points[p], p0 = p, pp;
  54876. do {
  54877. var step = steps[type];
  54878. do {
  54879. p += step;
  54880. } while (!points[p]);
  54881. pp = points[p];
  54882. if (pp !== 5 && pp !== 10) {
  54883. type = pp;
  54884. points[p] = 0;
  54885. } else {
  54886. type = pp & 0x33 * type >> 4;
  54887. points[p] &= type >> 2 | type << 2;
  54888. }
  54889. coords.push(p % width1);
  54890. coords.push(p / width1 | 0);
  54891. --count;
  54892. } while (p0 !== p);
  54893. outlines.push(coords);
  54894. --i;
  54895. }
  54896. var drawOutline = function (c) {
  54897. c.save();
  54898. c.scale(1 / width, -1 / height);
  54899. c.translate(0, -height);
  54900. c.beginPath();
  54901. for (var i = 0, ii = outlines.length; i < ii; i++) {
  54902. var o = outlines[i];
  54903. c.moveTo(o[0], o[1]);
  54904. for (var j = 2, jj = o.length; j < jj; j += 2) {
  54905. c.lineTo(o[j], o[j + 1]);
  54906. }
  54907. }
  54908. c.fill();
  54909. c.beginPath();
  54910. c.restore();
  54911. };
  54912. return drawOutline;
  54913. }
  54914. var CanvasExtraState = function CanvasExtraStateClosure() {
  54915. function CanvasExtraState(old) {
  54916. this.alphaIsShape = false;
  54917. this.fontSize = 0;
  54918. this.fontSizeScale = 1;
  54919. this.textMatrix = IDENTITY_MATRIX;
  54920. this.textMatrixScale = 1;
  54921. this.fontMatrix = FONT_IDENTITY_MATRIX;
  54922. this.leading = 0;
  54923. this.x = 0;
  54924. this.y = 0;
  54925. this.lineX = 0;
  54926. this.lineY = 0;
  54927. this.charSpacing = 0;
  54928. this.wordSpacing = 0;
  54929. this.textHScale = 1;
  54930. this.textRenderingMode = TextRenderingMode.FILL;
  54931. this.textRise = 0;
  54932. this.fillColor = '#000000';
  54933. this.strokeColor = '#000000';
  54934. this.patternFill = false;
  54935. this.fillAlpha = 1;
  54936. this.strokeAlpha = 1;
  54937. this.lineWidth = 1;
  54938. this.activeSMask = null;
  54939. this.resumeSMaskCtx = null;
  54940. this.old = old;
  54941. }
  54942. CanvasExtraState.prototype = {
  54943. clone: function CanvasExtraState_clone() {
  54944. return Object.create(this);
  54945. },
  54946. setCurrentPoint: function CanvasExtraState_setCurrentPoint(x, y) {
  54947. this.x = x;
  54948. this.y = y;
  54949. }
  54950. };
  54951. return CanvasExtraState;
  54952. }();
  54953. var CanvasGraphics = function CanvasGraphicsClosure() {
  54954. var EXECUTION_TIME = 15;
  54955. var EXECUTION_STEPS = 10;
  54956. function CanvasGraphics(canvasCtx, commonObjs, objs, canvasFactory, imageLayer) {
  54957. this.ctx = canvasCtx;
  54958. this.current = new CanvasExtraState();
  54959. this.stateStack = [];
  54960. this.pendingClip = null;
  54961. this.pendingEOFill = false;
  54962. this.res = null;
  54963. this.xobjs = null;
  54964. this.commonObjs = commonObjs;
  54965. this.objs = objs;
  54966. this.canvasFactory = canvasFactory;
  54967. this.imageLayer = imageLayer;
  54968. this.groupStack = [];
  54969. this.processingType3 = null;
  54970. this.baseTransform = null;
  54971. this.baseTransformStack = [];
  54972. this.groupLevel = 0;
  54973. this.smaskStack = [];
  54974. this.smaskCounter = 0;
  54975. this.tempSMask = null;
  54976. this.cachedCanvases = new CachedCanvases(this.canvasFactory);
  54977. if (canvasCtx) {
  54978. addContextCurrentTransform(canvasCtx);
  54979. }
  54980. this.cachedGetSinglePixelWidth = null;
  54981. }
  54982. function putBinaryImageData(ctx, imgData) {
  54983. if (typeof ImageData !== 'undefined' && imgData instanceof ImageData) {
  54984. ctx.putImageData(imgData, 0, 0);
  54985. return;
  54986. }
  54987. var height = imgData.height, width = imgData.width;
  54988. var partialChunkHeight = height % FULL_CHUNK_HEIGHT;
  54989. var fullChunks = (height - partialChunkHeight) / FULL_CHUNK_HEIGHT;
  54990. var totalChunks = partialChunkHeight === 0 ? fullChunks : fullChunks + 1;
  54991. var chunkImgData = ctx.createImageData(width, FULL_CHUNK_HEIGHT);
  54992. var srcPos = 0, destPos;
  54993. var src = imgData.data;
  54994. var dest = chunkImgData.data;
  54995. var i, j, thisChunkHeight, elemsInThisChunk;
  54996. if (imgData.kind === ImageKind.GRAYSCALE_1BPP) {
  54997. var srcLength = src.byteLength;
  54998. var dest32 = HasCanvasTypedArraysCached.value ? new Uint32Array(dest.buffer) : new Uint32ArrayView(dest);
  54999. var dest32DataLength = dest32.length;
  55000. var fullSrcDiff = width + 7 >> 3;
  55001. var white = 0xFFFFFFFF;
  55002. var black = IsLittleEndianCached.value || !HasCanvasTypedArraysCached.value ? 0xFF000000 : 0x000000FF;
  55003. for (i = 0; i < totalChunks; i++) {
  55004. thisChunkHeight = i < fullChunks ? FULL_CHUNK_HEIGHT : partialChunkHeight;
  55005. destPos = 0;
  55006. for (j = 0; j < thisChunkHeight; j++) {
  55007. var srcDiff = srcLength - srcPos;
  55008. var k = 0;
  55009. var kEnd = srcDiff > fullSrcDiff ? width : srcDiff * 8 - 7;
  55010. var kEndUnrolled = kEnd & ~7;
  55011. var mask = 0;
  55012. var srcByte = 0;
  55013. for (; k < kEndUnrolled; k += 8) {
  55014. srcByte = src[srcPos++];
  55015. dest32[destPos++] = srcByte & 128 ? white : black;
  55016. dest32[destPos++] = srcByte & 64 ? white : black;
  55017. dest32[destPos++] = srcByte & 32 ? white : black;
  55018. dest32[destPos++] = srcByte & 16 ? white : black;
  55019. dest32[destPos++] = srcByte & 8 ? white : black;
  55020. dest32[destPos++] = srcByte & 4 ? white : black;
  55021. dest32[destPos++] = srcByte & 2 ? white : black;
  55022. dest32[destPos++] = srcByte & 1 ? white : black;
  55023. }
  55024. for (; k < kEnd; k++) {
  55025. if (mask === 0) {
  55026. srcByte = src[srcPos++];
  55027. mask = 128;
  55028. }
  55029. dest32[destPos++] = srcByte & mask ? white : black;
  55030. mask >>= 1;
  55031. }
  55032. }
  55033. while (destPos < dest32DataLength) {
  55034. dest32[destPos++] = 0;
  55035. }
  55036. ctx.putImageData(chunkImgData, 0, i * FULL_CHUNK_HEIGHT);
  55037. }
  55038. } else if (imgData.kind === ImageKind.RGBA_32BPP) {
  55039. j = 0;
  55040. elemsInThisChunk = width * FULL_CHUNK_HEIGHT * 4;
  55041. for (i = 0; i < fullChunks; i++) {
  55042. dest.set(src.subarray(srcPos, srcPos + elemsInThisChunk));
  55043. srcPos += elemsInThisChunk;
  55044. ctx.putImageData(chunkImgData, 0, j);
  55045. j += FULL_CHUNK_HEIGHT;
  55046. }
  55047. if (i < totalChunks) {
  55048. elemsInThisChunk = width * partialChunkHeight * 4;
  55049. dest.set(src.subarray(srcPos, srcPos + elemsInThisChunk));
  55050. ctx.putImageData(chunkImgData, 0, j);
  55051. }
  55052. } else if (imgData.kind === ImageKind.RGB_24BPP) {
  55053. thisChunkHeight = FULL_CHUNK_HEIGHT;
  55054. elemsInThisChunk = width * thisChunkHeight;
  55055. for (i = 0; i < totalChunks; i++) {
  55056. if (i >= fullChunks) {
  55057. thisChunkHeight = partialChunkHeight;
  55058. elemsInThisChunk = width * thisChunkHeight;
  55059. }
  55060. destPos = 0;
  55061. for (j = elemsInThisChunk; j--;) {
  55062. dest[destPos++] = src[srcPos++];
  55063. dest[destPos++] = src[srcPos++];
  55064. dest[destPos++] = src[srcPos++];
  55065. dest[destPos++] = 255;
  55066. }
  55067. ctx.putImageData(chunkImgData, 0, i * FULL_CHUNK_HEIGHT);
  55068. }
  55069. } else {
  55070. error('bad image kind: ' + imgData.kind);
  55071. }
  55072. }
  55073. function putBinaryImageMask(ctx, imgData) {
  55074. var height = imgData.height, width = imgData.width;
  55075. var partialChunkHeight = height % FULL_CHUNK_HEIGHT;
  55076. var fullChunks = (height - partialChunkHeight) / FULL_CHUNK_HEIGHT;
  55077. var totalChunks = partialChunkHeight === 0 ? fullChunks : fullChunks + 1;
  55078. var chunkImgData = ctx.createImageData(width, FULL_CHUNK_HEIGHT);
  55079. var srcPos = 0;
  55080. var src = imgData.data;
  55081. var dest = chunkImgData.data;
  55082. for (var i = 0; i < totalChunks; i++) {
  55083. var thisChunkHeight = i < fullChunks ? FULL_CHUNK_HEIGHT : partialChunkHeight;
  55084. var destPos = 3;
  55085. for (var j = 0; j < thisChunkHeight; j++) {
  55086. var mask = 0;
  55087. for (var k = 0; k < width; k++) {
  55088. if (!mask) {
  55089. var elem = src[srcPos++];
  55090. mask = 128;
  55091. }
  55092. dest[destPos] = elem & mask ? 0 : 255;
  55093. destPos += 4;
  55094. mask >>= 1;
  55095. }
  55096. }
  55097. ctx.putImageData(chunkImgData, 0, i * FULL_CHUNK_HEIGHT);
  55098. }
  55099. }
  55100. function copyCtxState(sourceCtx, destCtx) {
  55101. var properties = [
  55102. 'strokeStyle',
  55103. 'fillStyle',
  55104. 'fillRule',
  55105. 'globalAlpha',
  55106. 'lineWidth',
  55107. 'lineCap',
  55108. 'lineJoin',
  55109. 'miterLimit',
  55110. 'globalCompositeOperation',
  55111. 'font'
  55112. ];
  55113. for (var i = 0, ii = properties.length; i < ii; i++) {
  55114. var property = properties[i];
  55115. if (sourceCtx[property] !== undefined) {
  55116. destCtx[property] = sourceCtx[property];
  55117. }
  55118. }
  55119. if (sourceCtx.setLineDash !== undefined) {
  55120. destCtx.setLineDash(sourceCtx.getLineDash());
  55121. destCtx.lineDashOffset = sourceCtx.lineDashOffset;
  55122. }
  55123. }
  55124. function composeSMaskBackdrop(bytes, r0, g0, b0) {
  55125. var length = bytes.length;
  55126. for (var i = 3; i < length; i += 4) {
  55127. var alpha = bytes[i];
  55128. if (alpha === 0) {
  55129. bytes[i - 3] = r0;
  55130. bytes[i - 2] = g0;
  55131. bytes[i - 1] = b0;
  55132. } else if (alpha < 255) {
  55133. var alpha_ = 255 - alpha;
  55134. bytes[i - 3] = bytes[i - 3] * alpha + r0 * alpha_ >> 8;
  55135. bytes[i - 2] = bytes[i - 2] * alpha + g0 * alpha_ >> 8;
  55136. bytes[i - 1] = bytes[i - 1] * alpha + b0 * alpha_ >> 8;
  55137. }
  55138. }
  55139. }
  55140. function composeSMaskAlpha(maskData, layerData, transferMap) {
  55141. var length = maskData.length;
  55142. var scale = 1 / 255;
  55143. for (var i = 3; i < length; i += 4) {
  55144. var alpha = transferMap ? transferMap[maskData[i]] : maskData[i];
  55145. layerData[i] = layerData[i] * alpha * scale | 0;
  55146. }
  55147. }
  55148. function composeSMaskLuminosity(maskData, layerData, transferMap) {
  55149. var length = maskData.length;
  55150. for (var i = 3; i < length; i += 4) {
  55151. var y = maskData[i - 3] * 77 + maskData[i - 2] * 152 + maskData[i - 1] * 28;
  55152. layerData[i] = transferMap ? layerData[i] * transferMap[y >> 8] >> 8 : layerData[i] * y >> 16;
  55153. }
  55154. }
  55155. function genericComposeSMask(maskCtx, layerCtx, width, height, subtype, backdrop, transferMap) {
  55156. var hasBackdrop = !!backdrop;
  55157. var r0 = hasBackdrop ? backdrop[0] : 0;
  55158. var g0 = hasBackdrop ? backdrop[1] : 0;
  55159. var b0 = hasBackdrop ? backdrop[2] : 0;
  55160. var composeFn;
  55161. if (subtype === 'Luminosity') {
  55162. composeFn = composeSMaskLuminosity;
  55163. } else {
  55164. composeFn = composeSMaskAlpha;
  55165. }
  55166. var PIXELS_TO_PROCESS = 1048576;
  55167. var chunkSize = Math.min(height, Math.ceil(PIXELS_TO_PROCESS / width));
  55168. for (var row = 0; row < height; row += chunkSize) {
  55169. var chunkHeight = Math.min(chunkSize, height - row);
  55170. var maskData = maskCtx.getImageData(0, row, width, chunkHeight);
  55171. var layerData = layerCtx.getImageData(0, row, width, chunkHeight);
  55172. if (hasBackdrop) {
  55173. composeSMaskBackdrop(maskData.data, r0, g0, b0);
  55174. }
  55175. composeFn(maskData.data, layerData.data, transferMap);
  55176. maskCtx.putImageData(layerData, 0, row);
  55177. }
  55178. }
  55179. function composeSMask(ctx, smask, layerCtx) {
  55180. var mask = smask.canvas;
  55181. var maskCtx = smask.context;
  55182. ctx.setTransform(smask.scaleX, 0, 0, smask.scaleY, smask.offsetX, smask.offsetY);
  55183. var backdrop = smask.backdrop || null;
  55184. if (!smask.transferMap && WebGLUtils.isEnabled) {
  55185. var composed = WebGLUtils.composeSMask(layerCtx.canvas, mask, {
  55186. subtype: smask.subtype,
  55187. backdrop: backdrop
  55188. });
  55189. ctx.setTransform(1, 0, 0, 1, 0, 0);
  55190. ctx.drawImage(composed, smask.offsetX, smask.offsetY);
  55191. return;
  55192. }
  55193. genericComposeSMask(maskCtx, layerCtx, mask.width, mask.height, smask.subtype, backdrop, smask.transferMap);
  55194. ctx.drawImage(mask, 0, 0);
  55195. }
  55196. var LINE_CAP_STYLES = [
  55197. 'butt',
  55198. 'round',
  55199. 'square'
  55200. ];
  55201. var LINE_JOIN_STYLES = [
  55202. 'miter',
  55203. 'round',
  55204. 'bevel'
  55205. ];
  55206. var NORMAL_CLIP = {};
  55207. var EO_CLIP = {};
  55208. CanvasGraphics.prototype = {
  55209. beginDrawing: function CanvasGraphics_beginDrawing(transform, viewport, transparency) {
  55210. var width = this.ctx.canvas.width;
  55211. var height = this.ctx.canvas.height;
  55212. this.ctx.save();
  55213. this.ctx.fillStyle = 'rgb(255, 255, 255)';
  55214. this.ctx.fillRect(0, 0, width, height);
  55215. this.ctx.restore();
  55216. if (transparency) {
  55217. var transparentCanvas = this.cachedCanvases.getCanvas('transparent', width, height, true);
  55218. this.compositeCtx = this.ctx;
  55219. this.transparentCanvas = transparentCanvas.canvas;
  55220. this.ctx = transparentCanvas.context;
  55221. this.ctx.save();
  55222. this.ctx.transform.apply(this.ctx, this.compositeCtx.mozCurrentTransform);
  55223. }
  55224. this.ctx.save();
  55225. if (transform) {
  55226. this.ctx.transform.apply(this.ctx, transform);
  55227. }
  55228. this.ctx.transform.apply(this.ctx, viewport.transform);
  55229. this.baseTransform = this.ctx.mozCurrentTransform.slice();
  55230. if (this.imageLayer) {
  55231. this.imageLayer.beginLayout();
  55232. }
  55233. },
  55234. executeOperatorList: function CanvasGraphics_executeOperatorList(operatorList, executionStartIdx, continueCallback, stepper) {
  55235. var argsArray = operatorList.argsArray;
  55236. var fnArray = operatorList.fnArray;
  55237. var i = executionStartIdx || 0;
  55238. var argsArrayLen = argsArray.length;
  55239. if (argsArrayLen === i) {
  55240. return i;
  55241. }
  55242. var chunkOperations = argsArrayLen - i > EXECUTION_STEPS && typeof continueCallback === 'function';
  55243. var endTime = chunkOperations ? Date.now() + EXECUTION_TIME : 0;
  55244. var steps = 0;
  55245. var commonObjs = this.commonObjs;
  55246. var objs = this.objs;
  55247. var fnId;
  55248. while (true) {
  55249. if (stepper !== undefined && i === stepper.nextBreakPoint) {
  55250. stepper.breakIt(i, continueCallback);
  55251. return i;
  55252. }
  55253. fnId = fnArray[i];
  55254. if (fnId !== OPS.dependency) {
  55255. this[fnId].apply(this, argsArray[i]);
  55256. } else {
  55257. var deps = argsArray[i];
  55258. for (var n = 0, nn = deps.length; n < nn; n++) {
  55259. var depObjId = deps[n];
  55260. var common = depObjId[0] === 'g' && depObjId[1] === '_';
  55261. var objsPool = common ? commonObjs : objs;
  55262. if (!objsPool.isResolved(depObjId)) {
  55263. objsPool.get(depObjId, continueCallback);
  55264. return i;
  55265. }
  55266. }
  55267. }
  55268. i++;
  55269. if (i === argsArrayLen) {
  55270. return i;
  55271. }
  55272. if (chunkOperations && ++steps > EXECUTION_STEPS) {
  55273. if (Date.now() > endTime) {
  55274. continueCallback();
  55275. return i;
  55276. }
  55277. steps = 0;
  55278. }
  55279. }
  55280. },
  55281. endDrawing: function CanvasGraphics_endDrawing() {
  55282. if (this.current.activeSMask !== null) {
  55283. this.endSMaskGroup();
  55284. }
  55285. this.ctx.restore();
  55286. if (this.transparentCanvas) {
  55287. this.ctx = this.compositeCtx;
  55288. this.ctx.save();
  55289. this.ctx.setTransform(1, 0, 0, 1, 0, 0);
  55290. this.ctx.drawImage(this.transparentCanvas, 0, 0);
  55291. this.ctx.restore();
  55292. this.transparentCanvas = null;
  55293. }
  55294. this.cachedCanvases.clear();
  55295. WebGLUtils.clear();
  55296. if (this.imageLayer) {
  55297. this.imageLayer.endLayout();
  55298. }
  55299. },
  55300. setLineWidth: function CanvasGraphics_setLineWidth(width) {
  55301. this.current.lineWidth = width;
  55302. this.ctx.lineWidth = width;
  55303. },
  55304. setLineCap: function CanvasGraphics_setLineCap(style) {
  55305. this.ctx.lineCap = LINE_CAP_STYLES[style];
  55306. },
  55307. setLineJoin: function CanvasGraphics_setLineJoin(style) {
  55308. this.ctx.lineJoin = LINE_JOIN_STYLES[style];
  55309. },
  55310. setMiterLimit: function CanvasGraphics_setMiterLimit(limit) {
  55311. this.ctx.miterLimit = limit;
  55312. },
  55313. setDash: function CanvasGraphics_setDash(dashArray, dashPhase) {
  55314. var ctx = this.ctx;
  55315. if (ctx.setLineDash !== undefined) {
  55316. ctx.setLineDash(dashArray);
  55317. ctx.lineDashOffset = dashPhase;
  55318. }
  55319. },
  55320. setRenderingIntent: function CanvasGraphics_setRenderingIntent(intent) {
  55321. },
  55322. setFlatness: function CanvasGraphics_setFlatness(flatness) {
  55323. },
  55324. setGState: function CanvasGraphics_setGState(states) {
  55325. for (var i = 0, ii = states.length; i < ii; i++) {
  55326. var state = states[i];
  55327. var key = state[0];
  55328. var value = state[1];
  55329. switch (key) {
  55330. case 'LW':
  55331. this.setLineWidth(value);
  55332. break;
  55333. case 'LC':
  55334. this.setLineCap(value);
  55335. break;
  55336. case 'LJ':
  55337. this.setLineJoin(value);
  55338. break;
  55339. case 'ML':
  55340. this.setMiterLimit(value);
  55341. break;
  55342. case 'D':
  55343. this.setDash(value[0], value[1]);
  55344. break;
  55345. case 'RI':
  55346. this.setRenderingIntent(value);
  55347. break;
  55348. case 'FL':
  55349. this.setFlatness(value);
  55350. break;
  55351. case 'Font':
  55352. this.setFont(value[0], value[1]);
  55353. break;
  55354. case 'CA':
  55355. this.current.strokeAlpha = state[1];
  55356. break;
  55357. case 'ca':
  55358. this.current.fillAlpha = state[1];
  55359. this.ctx.globalAlpha = state[1];
  55360. break;
  55361. case 'BM':
  55362. if (value && value.name && value.name !== 'Normal') {
  55363. var mode = value.name.replace(/([A-Z])/g, function (c) {
  55364. return '-' + c.toLowerCase();
  55365. }).substring(1);
  55366. this.ctx.globalCompositeOperation = mode;
  55367. if (this.ctx.globalCompositeOperation !== mode) {
  55368. warn('globalCompositeOperation "' + mode + '" is not supported');
  55369. }
  55370. } else {
  55371. this.ctx.globalCompositeOperation = 'source-over';
  55372. }
  55373. break;
  55374. case 'SMask':
  55375. if (this.current.activeSMask) {
  55376. if (this.stateStack.length > 0 && this.stateStack[this.stateStack.length - 1].activeSMask === this.current.activeSMask) {
  55377. this.suspendSMaskGroup();
  55378. } else {
  55379. this.endSMaskGroup();
  55380. }
  55381. }
  55382. this.current.activeSMask = value ? this.tempSMask : null;
  55383. if (this.current.activeSMask) {
  55384. this.beginSMaskGroup();
  55385. }
  55386. this.tempSMask = null;
  55387. break;
  55388. }
  55389. }
  55390. },
  55391. beginSMaskGroup: function CanvasGraphics_beginSMaskGroup() {
  55392. var activeSMask = this.current.activeSMask;
  55393. var drawnWidth = activeSMask.canvas.width;
  55394. var drawnHeight = activeSMask.canvas.height;
  55395. var cacheId = 'smaskGroupAt' + this.groupLevel;
  55396. var scratchCanvas = this.cachedCanvases.getCanvas(cacheId, drawnWidth, drawnHeight, true);
  55397. var currentCtx = this.ctx;
  55398. var currentTransform = currentCtx.mozCurrentTransform;
  55399. this.ctx.save();
  55400. var groupCtx = scratchCanvas.context;
  55401. groupCtx.scale(1 / activeSMask.scaleX, 1 / activeSMask.scaleY);
  55402. groupCtx.translate(-activeSMask.offsetX, -activeSMask.offsetY);
  55403. groupCtx.transform.apply(groupCtx, currentTransform);
  55404. activeSMask.startTransformInverse = groupCtx.mozCurrentTransformInverse;
  55405. copyCtxState(currentCtx, groupCtx);
  55406. this.ctx = groupCtx;
  55407. this.setGState([
  55408. [
  55409. 'BM',
  55410. 'Normal'
  55411. ],
  55412. [
  55413. 'ca',
  55414. 1
  55415. ],
  55416. [
  55417. 'CA',
  55418. 1
  55419. ]
  55420. ]);
  55421. this.groupStack.push(currentCtx);
  55422. this.groupLevel++;
  55423. },
  55424. suspendSMaskGroup: function CanvasGraphics_endSMaskGroup() {
  55425. var groupCtx = this.ctx;
  55426. this.groupLevel--;
  55427. this.ctx = this.groupStack.pop();
  55428. composeSMask(this.ctx, this.current.activeSMask, groupCtx);
  55429. this.ctx.restore();
  55430. this.ctx.save();
  55431. copyCtxState(groupCtx, this.ctx);
  55432. this.current.resumeSMaskCtx = groupCtx;
  55433. var deltaTransform = Util.transform(this.current.activeSMask.startTransformInverse, groupCtx.mozCurrentTransform);
  55434. this.ctx.transform.apply(this.ctx, deltaTransform);
  55435. groupCtx.save();
  55436. groupCtx.setTransform(1, 0, 0, 1, 0, 0);
  55437. groupCtx.clearRect(0, 0, groupCtx.canvas.width, groupCtx.canvas.height);
  55438. groupCtx.restore();
  55439. },
  55440. resumeSMaskGroup: function CanvasGraphics_endSMaskGroup() {
  55441. var groupCtx = this.current.resumeSMaskCtx;
  55442. var currentCtx = this.ctx;
  55443. this.ctx = groupCtx;
  55444. this.groupStack.push(currentCtx);
  55445. this.groupLevel++;
  55446. },
  55447. endSMaskGroup: function CanvasGraphics_endSMaskGroup() {
  55448. var groupCtx = this.ctx;
  55449. this.groupLevel--;
  55450. this.ctx = this.groupStack.pop();
  55451. composeSMask(this.ctx, this.current.activeSMask, groupCtx);
  55452. this.ctx.restore();
  55453. copyCtxState(groupCtx, this.ctx);
  55454. var deltaTransform = Util.transform(this.current.activeSMask.startTransformInverse, groupCtx.mozCurrentTransform);
  55455. this.ctx.transform.apply(this.ctx, deltaTransform);
  55456. },
  55457. save: function CanvasGraphics_save() {
  55458. this.ctx.save();
  55459. var old = this.current;
  55460. this.stateStack.push(old);
  55461. this.current = old.clone();
  55462. this.current.resumeSMaskCtx = null;
  55463. },
  55464. restore: function CanvasGraphics_restore() {
  55465. if (this.current.resumeSMaskCtx) {
  55466. this.resumeSMaskGroup();
  55467. }
  55468. if (this.current.activeSMask !== null && (this.stateStack.length === 0 || this.stateStack[this.stateStack.length - 1].activeSMask !== this.current.activeSMask)) {
  55469. this.endSMaskGroup();
  55470. }
  55471. if (this.stateStack.length !== 0) {
  55472. this.current = this.stateStack.pop();
  55473. this.ctx.restore();
  55474. this.pendingClip = null;
  55475. this.cachedGetSinglePixelWidth = null;
  55476. }
  55477. },
  55478. transform: function CanvasGraphics_transform(a, b, c, d, e, f) {
  55479. this.ctx.transform(a, b, c, d, e, f);
  55480. this.cachedGetSinglePixelWidth = null;
  55481. },
  55482. constructPath: function CanvasGraphics_constructPath(ops, args) {
  55483. var ctx = this.ctx;
  55484. var current = this.current;
  55485. var x = current.x, y = current.y;
  55486. for (var i = 0, j = 0, ii = ops.length; i < ii; i++) {
  55487. switch (ops[i] | 0) {
  55488. case OPS.rectangle:
  55489. x = args[j++];
  55490. y = args[j++];
  55491. var width = args[j++];
  55492. var height = args[j++];
  55493. if (width === 0) {
  55494. width = this.getSinglePixelWidth();
  55495. }
  55496. if (height === 0) {
  55497. height = this.getSinglePixelWidth();
  55498. }
  55499. var xw = x + width;
  55500. var yh = y + height;
  55501. this.ctx.moveTo(x, y);
  55502. this.ctx.lineTo(xw, y);
  55503. this.ctx.lineTo(xw, yh);
  55504. this.ctx.lineTo(x, yh);
  55505. this.ctx.lineTo(x, y);
  55506. this.ctx.closePath();
  55507. break;
  55508. case OPS.moveTo:
  55509. x = args[j++];
  55510. y = args[j++];
  55511. ctx.moveTo(x, y);
  55512. break;
  55513. case OPS.lineTo:
  55514. x = args[j++];
  55515. y = args[j++];
  55516. ctx.lineTo(x, y);
  55517. break;
  55518. case OPS.curveTo:
  55519. x = args[j + 4];
  55520. y = args[j + 5];
  55521. ctx.bezierCurveTo(args[j], args[j + 1], args[j + 2], args[j + 3], x, y);
  55522. j += 6;
  55523. break;
  55524. case OPS.curveTo2:
  55525. ctx.bezierCurveTo(x, y, args[j], args[j + 1], args[j + 2], args[j + 3]);
  55526. x = args[j + 2];
  55527. y = args[j + 3];
  55528. j += 4;
  55529. break;
  55530. case OPS.curveTo3:
  55531. x = args[j + 2];
  55532. y = args[j + 3];
  55533. ctx.bezierCurveTo(args[j], args[j + 1], x, y, x, y);
  55534. j += 4;
  55535. break;
  55536. case OPS.closePath:
  55537. ctx.closePath();
  55538. break;
  55539. }
  55540. }
  55541. current.setCurrentPoint(x, y);
  55542. },
  55543. closePath: function CanvasGraphics_closePath() {
  55544. this.ctx.closePath();
  55545. },
  55546. stroke: function CanvasGraphics_stroke(consumePath) {
  55547. consumePath = typeof consumePath !== 'undefined' ? consumePath : true;
  55548. var ctx = this.ctx;
  55549. var strokeColor = this.current.strokeColor;
  55550. ctx.lineWidth = Math.max(this.getSinglePixelWidth() * MIN_WIDTH_FACTOR, this.current.lineWidth);
  55551. ctx.globalAlpha = this.current.strokeAlpha;
  55552. if (strokeColor && strokeColor.hasOwnProperty('type') && strokeColor.type === 'Pattern') {
  55553. ctx.save();
  55554. ctx.strokeStyle = strokeColor.getPattern(ctx, this);
  55555. ctx.stroke();
  55556. ctx.restore();
  55557. } else {
  55558. ctx.stroke();
  55559. }
  55560. if (consumePath) {
  55561. this.consumePath();
  55562. }
  55563. ctx.globalAlpha = this.current.fillAlpha;
  55564. },
  55565. closeStroke: function CanvasGraphics_closeStroke() {
  55566. this.closePath();
  55567. this.stroke();
  55568. },
  55569. fill: function CanvasGraphics_fill(consumePath) {
  55570. consumePath = typeof consumePath !== 'undefined' ? consumePath : true;
  55571. var ctx = this.ctx;
  55572. var fillColor = this.current.fillColor;
  55573. var isPatternFill = this.current.patternFill;
  55574. var needRestore = false;
  55575. if (isPatternFill) {
  55576. ctx.save();
  55577. if (this.baseTransform) {
  55578. ctx.setTransform.apply(ctx, this.baseTransform);
  55579. }
  55580. ctx.fillStyle = fillColor.getPattern(ctx, this);
  55581. needRestore = true;
  55582. }
  55583. if (this.pendingEOFill) {
  55584. ctx.fill('evenodd');
  55585. this.pendingEOFill = false;
  55586. } else {
  55587. ctx.fill();
  55588. }
  55589. if (needRestore) {
  55590. ctx.restore();
  55591. }
  55592. if (consumePath) {
  55593. this.consumePath();
  55594. }
  55595. },
  55596. eoFill: function CanvasGraphics_eoFill() {
  55597. this.pendingEOFill = true;
  55598. this.fill();
  55599. },
  55600. fillStroke: function CanvasGraphics_fillStroke() {
  55601. this.fill(false);
  55602. this.stroke(false);
  55603. this.consumePath();
  55604. },
  55605. eoFillStroke: function CanvasGraphics_eoFillStroke() {
  55606. this.pendingEOFill = true;
  55607. this.fillStroke();
  55608. },
  55609. closeFillStroke: function CanvasGraphics_closeFillStroke() {
  55610. this.closePath();
  55611. this.fillStroke();
  55612. },
  55613. closeEOFillStroke: function CanvasGraphics_closeEOFillStroke() {
  55614. this.pendingEOFill = true;
  55615. this.closePath();
  55616. this.fillStroke();
  55617. },
  55618. endPath: function CanvasGraphics_endPath() {
  55619. this.consumePath();
  55620. },
  55621. clip: function CanvasGraphics_clip() {
  55622. this.pendingClip = NORMAL_CLIP;
  55623. },
  55624. eoClip: function CanvasGraphics_eoClip() {
  55625. this.pendingClip = EO_CLIP;
  55626. },
  55627. beginText: function CanvasGraphics_beginText() {
  55628. this.current.textMatrix = IDENTITY_MATRIX;
  55629. this.current.textMatrixScale = 1;
  55630. this.current.x = this.current.lineX = 0;
  55631. this.current.y = this.current.lineY = 0;
  55632. },
  55633. endText: function CanvasGraphics_endText() {
  55634. var paths = this.pendingTextPaths;
  55635. var ctx = this.ctx;
  55636. if (paths === undefined) {
  55637. ctx.beginPath();
  55638. return;
  55639. }
  55640. ctx.save();
  55641. ctx.beginPath();
  55642. for (var i = 0; i < paths.length; i++) {
  55643. var path = paths[i];
  55644. ctx.setTransform.apply(ctx, path.transform);
  55645. ctx.translate(path.x, path.y);
  55646. path.addToPath(ctx, path.fontSize);
  55647. }
  55648. ctx.restore();
  55649. ctx.clip();
  55650. ctx.beginPath();
  55651. delete this.pendingTextPaths;
  55652. },
  55653. setCharSpacing: function CanvasGraphics_setCharSpacing(spacing) {
  55654. this.current.charSpacing = spacing;
  55655. },
  55656. setWordSpacing: function CanvasGraphics_setWordSpacing(spacing) {
  55657. this.current.wordSpacing = spacing;
  55658. },
  55659. setHScale: function CanvasGraphics_setHScale(scale) {
  55660. this.current.textHScale = scale / 100;
  55661. },
  55662. setLeading: function CanvasGraphics_setLeading(leading) {
  55663. this.current.leading = -leading;
  55664. },
  55665. setFont: function CanvasGraphics_setFont(fontRefName, size) {
  55666. var fontObj = this.commonObjs.get(fontRefName);
  55667. var current = this.current;
  55668. if (!fontObj) {
  55669. error('Can\'t find font for ' + fontRefName);
  55670. }
  55671. current.fontMatrix = fontObj.fontMatrix ? fontObj.fontMatrix : FONT_IDENTITY_MATRIX;
  55672. if (current.fontMatrix[0] === 0 || current.fontMatrix[3] === 0) {
  55673. warn('Invalid font matrix for font ' + fontRefName);
  55674. }
  55675. if (size < 0) {
  55676. size = -size;
  55677. current.fontDirection = -1;
  55678. } else {
  55679. current.fontDirection = 1;
  55680. }
  55681. this.current.font = fontObj;
  55682. this.current.fontSize = size;
  55683. if (fontObj.isType3Font) {
  55684. return;
  55685. }
  55686. var name = fontObj.loadedName || 'sans-serif';
  55687. var bold = fontObj.black ? '900' : fontObj.bold ? 'bold' : 'normal';
  55688. var italic = fontObj.italic ? 'italic' : 'normal';
  55689. var typeface = '"' + name + '", ' + fontObj.fallbackName;
  55690. var browserFontSize = size < MIN_FONT_SIZE ? MIN_FONT_SIZE : size > MAX_FONT_SIZE ? MAX_FONT_SIZE : size;
  55691. this.current.fontSizeScale = size / browserFontSize;
  55692. var rule = italic + ' ' + bold + ' ' + browserFontSize + 'px ' + typeface;
  55693. this.ctx.font = rule;
  55694. },
  55695. setTextRenderingMode: function CanvasGraphics_setTextRenderingMode(mode) {
  55696. this.current.textRenderingMode = mode;
  55697. },
  55698. setTextRise: function CanvasGraphics_setTextRise(rise) {
  55699. this.current.textRise = rise;
  55700. },
  55701. moveText: function CanvasGraphics_moveText(x, y) {
  55702. this.current.x = this.current.lineX += x;
  55703. this.current.y = this.current.lineY += y;
  55704. },
  55705. setLeadingMoveText: function CanvasGraphics_setLeadingMoveText(x, y) {
  55706. this.setLeading(-y);
  55707. this.moveText(x, y);
  55708. },
  55709. setTextMatrix: function CanvasGraphics_setTextMatrix(a, b, c, d, e, f) {
  55710. this.current.textMatrix = [
  55711. a,
  55712. b,
  55713. c,
  55714. d,
  55715. e,
  55716. f
  55717. ];
  55718. this.current.textMatrixScale = Math.sqrt(a * a + b * b);
  55719. this.current.x = this.current.lineX = 0;
  55720. this.current.y = this.current.lineY = 0;
  55721. },
  55722. nextLine: function CanvasGraphics_nextLine() {
  55723. this.moveText(0, this.current.leading);
  55724. },
  55725. paintChar: function CanvasGraphics_paintChar(character, x, y) {
  55726. var ctx = this.ctx;
  55727. var current = this.current;
  55728. var font = current.font;
  55729. var textRenderingMode = current.textRenderingMode;
  55730. var fontSize = current.fontSize / current.fontSizeScale;
  55731. var fillStrokeMode = textRenderingMode & TextRenderingMode.FILL_STROKE_MASK;
  55732. var isAddToPathSet = !!(textRenderingMode & TextRenderingMode.ADD_TO_PATH_FLAG);
  55733. var addToPath;
  55734. if (font.disableFontFace || isAddToPathSet) {
  55735. addToPath = font.getPathGenerator(this.commonObjs, character);
  55736. }
  55737. if (font.disableFontFace) {
  55738. ctx.save();
  55739. ctx.translate(x, y);
  55740. ctx.beginPath();
  55741. addToPath(ctx, fontSize);
  55742. if (fillStrokeMode === TextRenderingMode.FILL || fillStrokeMode === TextRenderingMode.FILL_STROKE) {
  55743. ctx.fill();
  55744. }
  55745. if (fillStrokeMode === TextRenderingMode.STROKE || fillStrokeMode === TextRenderingMode.FILL_STROKE) {
  55746. ctx.stroke();
  55747. }
  55748. ctx.restore();
  55749. } else {
  55750. if (fillStrokeMode === TextRenderingMode.FILL || fillStrokeMode === TextRenderingMode.FILL_STROKE) {
  55751. ctx.fillText(character, x, y);
  55752. }
  55753. if (fillStrokeMode === TextRenderingMode.STROKE || fillStrokeMode === TextRenderingMode.FILL_STROKE) {
  55754. ctx.strokeText(character, x, y);
  55755. }
  55756. }
  55757. if (isAddToPathSet) {
  55758. var paths = this.pendingTextPaths || (this.pendingTextPaths = []);
  55759. paths.push({
  55760. transform: ctx.mozCurrentTransform,
  55761. x: x,
  55762. y: y,
  55763. fontSize: fontSize,
  55764. addToPath: addToPath
  55765. });
  55766. }
  55767. },
  55768. get isFontSubpixelAAEnabled() {
  55769. var ctx = this.canvasFactory.create(10, 10).context;
  55770. ctx.scale(1.5, 1);
  55771. ctx.fillText('I', 0, 10);
  55772. var data = ctx.getImageData(0, 0, 10, 10).data;
  55773. var enabled = false;
  55774. for (var i = 3; i < data.length; i += 4) {
  55775. if (data[i] > 0 && data[i] < 255) {
  55776. enabled = true;
  55777. break;
  55778. }
  55779. }
  55780. return shadow(this, 'isFontSubpixelAAEnabled', enabled);
  55781. },
  55782. showText: function CanvasGraphics_showText(glyphs) {
  55783. var current = this.current;
  55784. var font = current.font;
  55785. if (font.isType3Font) {
  55786. return this.showType3Text(glyphs);
  55787. }
  55788. var fontSize = current.fontSize;
  55789. if (fontSize === 0) {
  55790. return;
  55791. }
  55792. var ctx = this.ctx;
  55793. var fontSizeScale = current.fontSizeScale;
  55794. var charSpacing = current.charSpacing;
  55795. var wordSpacing = current.wordSpacing;
  55796. var fontDirection = current.fontDirection;
  55797. var textHScale = current.textHScale * fontDirection;
  55798. var glyphsLength = glyphs.length;
  55799. var vertical = font.vertical;
  55800. var spacingDir = vertical ? 1 : -1;
  55801. var defaultVMetrics = font.defaultVMetrics;
  55802. var widthAdvanceScale = fontSize * current.fontMatrix[0];
  55803. var simpleFillText = current.textRenderingMode === TextRenderingMode.FILL && !font.disableFontFace;
  55804. ctx.save();
  55805. ctx.transform.apply(ctx, current.textMatrix);
  55806. ctx.translate(current.x, current.y + current.textRise);
  55807. if (current.patternFill) {
  55808. ctx.fillStyle = current.fillColor.getPattern(ctx, this);
  55809. }
  55810. if (fontDirection > 0) {
  55811. ctx.scale(textHScale, -1);
  55812. } else {
  55813. ctx.scale(textHScale, 1);
  55814. }
  55815. var lineWidth = current.lineWidth;
  55816. var scale = current.textMatrixScale;
  55817. if (scale === 0 || lineWidth === 0) {
  55818. var fillStrokeMode = current.textRenderingMode & TextRenderingMode.FILL_STROKE_MASK;
  55819. if (fillStrokeMode === TextRenderingMode.STROKE || fillStrokeMode === TextRenderingMode.FILL_STROKE) {
  55820. this.cachedGetSinglePixelWidth = null;
  55821. lineWidth = this.getSinglePixelWidth() * MIN_WIDTH_FACTOR;
  55822. }
  55823. } else {
  55824. lineWidth /= scale;
  55825. }
  55826. if (fontSizeScale !== 1.0) {
  55827. ctx.scale(fontSizeScale, fontSizeScale);
  55828. lineWidth /= fontSizeScale;
  55829. }
  55830. ctx.lineWidth = lineWidth;
  55831. var x = 0, i;
  55832. for (i = 0; i < glyphsLength; ++i) {
  55833. var glyph = glyphs[i];
  55834. if (isNum(glyph)) {
  55835. x += spacingDir * glyph * fontSize / 1000;
  55836. continue;
  55837. }
  55838. var restoreNeeded = false;
  55839. var spacing = (glyph.isSpace ? wordSpacing : 0) + charSpacing;
  55840. var character = glyph.fontChar;
  55841. var accent = glyph.accent;
  55842. var scaledX, scaledY, scaledAccentX, scaledAccentY;
  55843. var width = glyph.width;
  55844. if (vertical) {
  55845. var vmetric, vx, vy;
  55846. vmetric = glyph.vmetric || defaultVMetrics;
  55847. vx = glyph.vmetric ? vmetric[1] : width * 0.5;
  55848. vx = -vx * widthAdvanceScale;
  55849. vy = vmetric[2] * widthAdvanceScale;
  55850. width = vmetric ? -vmetric[0] : width;
  55851. scaledX = vx / fontSizeScale;
  55852. scaledY = (x + vy) / fontSizeScale;
  55853. } else {
  55854. scaledX = x / fontSizeScale;
  55855. scaledY = 0;
  55856. }
  55857. if (font.remeasure && width > 0) {
  55858. var measuredWidth = ctx.measureText(character).width * 1000 / fontSize * fontSizeScale;
  55859. if (width < measuredWidth && this.isFontSubpixelAAEnabled) {
  55860. var characterScaleX = width / measuredWidth;
  55861. restoreNeeded = true;
  55862. ctx.save();
  55863. ctx.scale(characterScaleX, 1);
  55864. scaledX /= characterScaleX;
  55865. } else if (width !== measuredWidth) {
  55866. scaledX += (width - measuredWidth) / 2000 * fontSize / fontSizeScale;
  55867. }
  55868. }
  55869. if (glyph.isInFont || font.missingFile) {
  55870. if (simpleFillText && !accent) {
  55871. ctx.fillText(character, scaledX, scaledY);
  55872. } else {
  55873. this.paintChar(character, scaledX, scaledY);
  55874. if (accent) {
  55875. scaledAccentX = scaledX + accent.offset.x / fontSizeScale;
  55876. scaledAccentY = scaledY - accent.offset.y / fontSizeScale;
  55877. this.paintChar(accent.fontChar, scaledAccentX, scaledAccentY);
  55878. }
  55879. }
  55880. }
  55881. var charWidth = width * widthAdvanceScale + spacing * fontDirection;
  55882. x += charWidth;
  55883. if (restoreNeeded) {
  55884. ctx.restore();
  55885. }
  55886. }
  55887. if (vertical) {
  55888. current.y -= x * textHScale;
  55889. } else {
  55890. current.x += x * textHScale;
  55891. }
  55892. ctx.restore();
  55893. },
  55894. showType3Text: function CanvasGraphics_showType3Text(glyphs) {
  55895. var ctx = this.ctx;
  55896. var current = this.current;
  55897. var font = current.font;
  55898. var fontSize = current.fontSize;
  55899. var fontDirection = current.fontDirection;
  55900. var spacingDir = font.vertical ? 1 : -1;
  55901. var charSpacing = current.charSpacing;
  55902. var wordSpacing = current.wordSpacing;
  55903. var textHScale = current.textHScale * fontDirection;
  55904. var fontMatrix = current.fontMatrix || FONT_IDENTITY_MATRIX;
  55905. var glyphsLength = glyphs.length;
  55906. var isTextInvisible = current.textRenderingMode === TextRenderingMode.INVISIBLE;
  55907. var i, glyph, width, spacingLength;
  55908. if (isTextInvisible || fontSize === 0) {
  55909. return;
  55910. }
  55911. this.cachedGetSinglePixelWidth = null;
  55912. ctx.save();
  55913. ctx.transform.apply(ctx, current.textMatrix);
  55914. ctx.translate(current.x, current.y);
  55915. ctx.scale(textHScale, fontDirection);
  55916. for (i = 0; i < glyphsLength; ++i) {
  55917. glyph = glyphs[i];
  55918. if (isNum(glyph)) {
  55919. spacingLength = spacingDir * glyph * fontSize / 1000;
  55920. this.ctx.translate(spacingLength, 0);
  55921. current.x += spacingLength * textHScale;
  55922. continue;
  55923. }
  55924. var spacing = (glyph.isSpace ? wordSpacing : 0) + charSpacing;
  55925. var operatorList = font.charProcOperatorList[glyph.operatorListId];
  55926. if (!operatorList) {
  55927. warn('Type3 character \"' + glyph.operatorListId + '\" is not available');
  55928. continue;
  55929. }
  55930. this.processingType3 = glyph;
  55931. this.save();
  55932. ctx.scale(fontSize, fontSize);
  55933. ctx.transform.apply(ctx, fontMatrix);
  55934. this.executeOperatorList(operatorList);
  55935. this.restore();
  55936. var transformed = Util.applyTransform([
  55937. glyph.width,
  55938. 0
  55939. ], fontMatrix);
  55940. width = transformed[0] * fontSize + spacing;
  55941. ctx.translate(width, 0);
  55942. current.x += width * textHScale;
  55943. }
  55944. ctx.restore();
  55945. this.processingType3 = null;
  55946. },
  55947. setCharWidth: function CanvasGraphics_setCharWidth(xWidth, yWidth) {
  55948. },
  55949. setCharWidthAndBounds: function CanvasGraphics_setCharWidthAndBounds(xWidth, yWidth, llx, lly, urx, ury) {
  55950. this.ctx.rect(llx, lly, urx - llx, ury - lly);
  55951. this.clip();
  55952. this.endPath();
  55953. },
  55954. getColorN_Pattern: function CanvasGraphics_getColorN_Pattern(IR) {
  55955. var pattern;
  55956. if (IR[0] === 'TilingPattern') {
  55957. var color = IR[1];
  55958. var baseTransform = this.baseTransform || this.ctx.mozCurrentTransform.slice();
  55959. var self = this;
  55960. var canvasGraphicsFactory = {
  55961. createCanvasGraphics: function (ctx) {
  55962. return new CanvasGraphics(ctx, self.commonObjs, self.objs, self.canvasFactory);
  55963. }
  55964. };
  55965. pattern = new TilingPattern(IR, color, this.ctx, canvasGraphicsFactory, baseTransform);
  55966. } else {
  55967. pattern = getShadingPatternFromIR(IR);
  55968. }
  55969. return pattern;
  55970. },
  55971. setStrokeColorN: function CanvasGraphics_setStrokeColorN() {
  55972. this.current.strokeColor = this.getColorN_Pattern(arguments);
  55973. },
  55974. setFillColorN: function CanvasGraphics_setFillColorN() {
  55975. this.current.fillColor = this.getColorN_Pattern(arguments);
  55976. this.current.patternFill = true;
  55977. },
  55978. setStrokeRGBColor: function CanvasGraphics_setStrokeRGBColor(r, g, b) {
  55979. var color = Util.makeCssRgb(r, g, b);
  55980. this.ctx.strokeStyle = color;
  55981. this.current.strokeColor = color;
  55982. },
  55983. setFillRGBColor: function CanvasGraphics_setFillRGBColor(r, g, b) {
  55984. var color = Util.makeCssRgb(r, g, b);
  55985. this.ctx.fillStyle = color;
  55986. this.current.fillColor = color;
  55987. this.current.patternFill = false;
  55988. },
  55989. shadingFill: function CanvasGraphics_shadingFill(patternIR) {
  55990. var ctx = this.ctx;
  55991. this.save();
  55992. var pattern = getShadingPatternFromIR(patternIR);
  55993. ctx.fillStyle = pattern.getPattern(ctx, this, true);
  55994. var inv = ctx.mozCurrentTransformInverse;
  55995. if (inv) {
  55996. var canvas = ctx.canvas;
  55997. var width = canvas.width;
  55998. var height = canvas.height;
  55999. var bl = Util.applyTransform([
  56000. 0,
  56001. 0
  56002. ], inv);
  56003. var br = Util.applyTransform([
  56004. 0,
  56005. height
  56006. ], inv);
  56007. var ul = Util.applyTransform([
  56008. width,
  56009. 0
  56010. ], inv);
  56011. var ur = Util.applyTransform([
  56012. width,
  56013. height
  56014. ], inv);
  56015. var x0 = Math.min(bl[0], br[0], ul[0], ur[0]);
  56016. var y0 = Math.min(bl[1], br[1], ul[1], ur[1]);
  56017. var x1 = Math.max(bl[0], br[0], ul[0], ur[0]);
  56018. var y1 = Math.max(bl[1], br[1], ul[1], ur[1]);
  56019. this.ctx.fillRect(x0, y0, x1 - x0, y1 - y0);
  56020. } else {
  56021. this.ctx.fillRect(-1e10, -1e10, 2e10, 2e10);
  56022. }
  56023. this.restore();
  56024. },
  56025. beginInlineImage: function CanvasGraphics_beginInlineImage() {
  56026. error('Should not call beginInlineImage');
  56027. },
  56028. beginImageData: function CanvasGraphics_beginImageData() {
  56029. error('Should not call beginImageData');
  56030. },
  56031. paintFormXObjectBegin: function CanvasGraphics_paintFormXObjectBegin(matrix, bbox) {
  56032. this.save();
  56033. this.baseTransformStack.push(this.baseTransform);
  56034. if (isArray(matrix) && matrix.length === 6) {
  56035. this.transform.apply(this, matrix);
  56036. }
  56037. this.baseTransform = this.ctx.mozCurrentTransform;
  56038. if (isArray(bbox) && bbox.length === 4) {
  56039. var width = bbox[2] - bbox[0];
  56040. var height = bbox[3] - bbox[1];
  56041. this.ctx.rect(bbox[0], bbox[1], width, height);
  56042. this.clip();
  56043. this.endPath();
  56044. }
  56045. },
  56046. paintFormXObjectEnd: function CanvasGraphics_paintFormXObjectEnd() {
  56047. this.restore();
  56048. this.baseTransform = this.baseTransformStack.pop();
  56049. },
  56050. beginGroup: function CanvasGraphics_beginGroup(group) {
  56051. this.save();
  56052. var currentCtx = this.ctx;
  56053. if (!group.isolated) {
  56054. info('TODO: Support non-isolated groups.');
  56055. }
  56056. if (group.knockout) {
  56057. warn('Knockout groups not supported.');
  56058. }
  56059. var currentTransform = currentCtx.mozCurrentTransform;
  56060. if (group.matrix) {
  56061. currentCtx.transform.apply(currentCtx, group.matrix);
  56062. }
  56063. assert(group.bbox, 'Bounding box is required.');
  56064. var bounds = Util.getAxialAlignedBoundingBox(group.bbox, currentCtx.mozCurrentTransform);
  56065. var canvasBounds = [
  56066. 0,
  56067. 0,
  56068. currentCtx.canvas.width,
  56069. currentCtx.canvas.height
  56070. ];
  56071. bounds = Util.intersect(bounds, canvasBounds) || [
  56072. 0,
  56073. 0,
  56074. 0,
  56075. 0
  56076. ];
  56077. var offsetX = Math.floor(bounds[0]);
  56078. var offsetY = Math.floor(bounds[1]);
  56079. var drawnWidth = Math.max(Math.ceil(bounds[2]) - offsetX, 1);
  56080. var drawnHeight = Math.max(Math.ceil(bounds[3]) - offsetY, 1);
  56081. var scaleX = 1, scaleY = 1;
  56082. if (drawnWidth > MAX_GROUP_SIZE) {
  56083. scaleX = drawnWidth / MAX_GROUP_SIZE;
  56084. drawnWidth = MAX_GROUP_SIZE;
  56085. }
  56086. if (drawnHeight > MAX_GROUP_SIZE) {
  56087. scaleY = drawnHeight / MAX_GROUP_SIZE;
  56088. drawnHeight = MAX_GROUP_SIZE;
  56089. }
  56090. var cacheId = 'groupAt' + this.groupLevel;
  56091. if (group.smask) {
  56092. cacheId += '_smask_' + this.smaskCounter++ % 2;
  56093. }
  56094. var scratchCanvas = this.cachedCanvases.getCanvas(cacheId, drawnWidth, drawnHeight, true);
  56095. var groupCtx = scratchCanvas.context;
  56096. groupCtx.scale(1 / scaleX, 1 / scaleY);
  56097. groupCtx.translate(-offsetX, -offsetY);
  56098. groupCtx.transform.apply(groupCtx, currentTransform);
  56099. if (group.smask) {
  56100. this.smaskStack.push({
  56101. canvas: scratchCanvas.canvas,
  56102. context: groupCtx,
  56103. offsetX: offsetX,
  56104. offsetY: offsetY,
  56105. scaleX: scaleX,
  56106. scaleY: scaleY,
  56107. subtype: group.smask.subtype,
  56108. backdrop: group.smask.backdrop,
  56109. transferMap: group.smask.transferMap || null,
  56110. startTransformInverse: null
  56111. });
  56112. } else {
  56113. currentCtx.setTransform(1, 0, 0, 1, 0, 0);
  56114. currentCtx.translate(offsetX, offsetY);
  56115. currentCtx.scale(scaleX, scaleY);
  56116. }
  56117. copyCtxState(currentCtx, groupCtx);
  56118. this.ctx = groupCtx;
  56119. this.setGState([
  56120. [
  56121. 'BM',
  56122. 'Normal'
  56123. ],
  56124. [
  56125. 'ca',
  56126. 1
  56127. ],
  56128. [
  56129. 'CA',
  56130. 1
  56131. ]
  56132. ]);
  56133. this.groupStack.push(currentCtx);
  56134. this.groupLevel++;
  56135. this.current.activeSMask = null;
  56136. },
  56137. endGroup: function CanvasGraphics_endGroup(group) {
  56138. this.groupLevel--;
  56139. var groupCtx = this.ctx;
  56140. this.ctx = this.groupStack.pop();
  56141. if (this.ctx.imageSmoothingEnabled !== undefined) {
  56142. this.ctx.imageSmoothingEnabled = false;
  56143. } else {
  56144. this.ctx.mozImageSmoothingEnabled = false;
  56145. }
  56146. if (group.smask) {
  56147. this.tempSMask = this.smaskStack.pop();
  56148. } else {
  56149. this.ctx.drawImage(groupCtx.canvas, 0, 0);
  56150. }
  56151. this.restore();
  56152. },
  56153. beginAnnotations: function CanvasGraphics_beginAnnotations() {
  56154. this.save();
  56155. this.current = new CanvasExtraState();
  56156. if (this.baseTransform) {
  56157. this.ctx.setTransform.apply(this.ctx, this.baseTransform);
  56158. }
  56159. },
  56160. endAnnotations: function CanvasGraphics_endAnnotations() {
  56161. this.restore();
  56162. },
  56163. beginAnnotation: function CanvasGraphics_beginAnnotation(rect, transform, matrix) {
  56164. this.save();
  56165. if (isArray(rect) && rect.length === 4) {
  56166. var width = rect[2] - rect[0];
  56167. var height = rect[3] - rect[1];
  56168. this.ctx.rect(rect[0], rect[1], width, height);
  56169. this.clip();
  56170. this.endPath();
  56171. }
  56172. this.transform.apply(this, transform);
  56173. this.transform.apply(this, matrix);
  56174. },
  56175. endAnnotation: function CanvasGraphics_endAnnotation() {
  56176. this.restore();
  56177. },
  56178. paintJpegXObject: function CanvasGraphics_paintJpegXObject(objId, w, h) {
  56179. var domImage = this.objs.get(objId);
  56180. if (!domImage) {
  56181. warn('Dependent image isn\'t ready yet');
  56182. return;
  56183. }
  56184. this.save();
  56185. var ctx = this.ctx;
  56186. ctx.scale(1 / w, -1 / h);
  56187. ctx.drawImage(domImage, 0, 0, domImage.width, domImage.height, 0, -h, w, h);
  56188. if (this.imageLayer) {
  56189. var currentTransform = ctx.mozCurrentTransformInverse;
  56190. var position = this.getCanvasPosition(0, 0);
  56191. this.imageLayer.appendImage({
  56192. objId: objId,
  56193. left: position[0],
  56194. top: position[1],
  56195. width: w / currentTransform[0],
  56196. height: h / currentTransform[3]
  56197. });
  56198. }
  56199. this.restore();
  56200. },
  56201. paintImageMaskXObject: function CanvasGraphics_paintImageMaskXObject(img) {
  56202. var ctx = this.ctx;
  56203. var width = img.width, height = img.height;
  56204. var fillColor = this.current.fillColor;
  56205. var isPatternFill = this.current.patternFill;
  56206. var glyph = this.processingType3;
  56207. if (COMPILE_TYPE3_GLYPHS && glyph && glyph.compiled === undefined) {
  56208. if (width <= MAX_SIZE_TO_COMPILE && height <= MAX_SIZE_TO_COMPILE) {
  56209. glyph.compiled = compileType3Glyph({
  56210. data: img.data,
  56211. width: width,
  56212. height: height
  56213. });
  56214. } else {
  56215. glyph.compiled = null;
  56216. }
  56217. }
  56218. if (glyph && glyph.compiled) {
  56219. glyph.compiled(ctx);
  56220. return;
  56221. }
  56222. var maskCanvas = this.cachedCanvases.getCanvas('maskCanvas', width, height);
  56223. var maskCtx = maskCanvas.context;
  56224. maskCtx.save();
  56225. putBinaryImageMask(maskCtx, img);
  56226. maskCtx.globalCompositeOperation = 'source-in';
  56227. maskCtx.fillStyle = isPatternFill ? fillColor.getPattern(maskCtx, this) : fillColor;
  56228. maskCtx.fillRect(0, 0, width, height);
  56229. maskCtx.restore();
  56230. this.paintInlineImageXObject(maskCanvas.canvas);
  56231. },
  56232. paintImageMaskXObjectRepeat: function CanvasGraphics_paintImageMaskXObjectRepeat(imgData, scaleX, scaleY, positions) {
  56233. var width = imgData.width;
  56234. var height = imgData.height;
  56235. var fillColor = this.current.fillColor;
  56236. var isPatternFill = this.current.patternFill;
  56237. var maskCanvas = this.cachedCanvases.getCanvas('maskCanvas', width, height);
  56238. var maskCtx = maskCanvas.context;
  56239. maskCtx.save();
  56240. putBinaryImageMask(maskCtx, imgData);
  56241. maskCtx.globalCompositeOperation = 'source-in';
  56242. maskCtx.fillStyle = isPatternFill ? fillColor.getPattern(maskCtx, this) : fillColor;
  56243. maskCtx.fillRect(0, 0, width, height);
  56244. maskCtx.restore();
  56245. var ctx = this.ctx;
  56246. for (var i = 0, ii = positions.length; i < ii; i += 2) {
  56247. ctx.save();
  56248. ctx.transform(scaleX, 0, 0, scaleY, positions[i], positions[i + 1]);
  56249. ctx.scale(1, -1);
  56250. ctx.drawImage(maskCanvas.canvas, 0, 0, width, height, 0, -1, 1, 1);
  56251. ctx.restore();
  56252. }
  56253. },
  56254. paintImageMaskXObjectGroup: function CanvasGraphics_paintImageMaskXObjectGroup(images) {
  56255. var ctx = this.ctx;
  56256. var fillColor = this.current.fillColor;
  56257. var isPatternFill = this.current.patternFill;
  56258. for (var i = 0, ii = images.length; i < ii; i++) {
  56259. var image = images[i];
  56260. var width = image.width, height = image.height;
  56261. var maskCanvas = this.cachedCanvases.getCanvas('maskCanvas', width, height);
  56262. var maskCtx = maskCanvas.context;
  56263. maskCtx.save();
  56264. putBinaryImageMask(maskCtx, image);
  56265. maskCtx.globalCompositeOperation = 'source-in';
  56266. maskCtx.fillStyle = isPatternFill ? fillColor.getPattern(maskCtx, this) : fillColor;
  56267. maskCtx.fillRect(0, 0, width, height);
  56268. maskCtx.restore();
  56269. ctx.save();
  56270. ctx.transform.apply(ctx, image.transform);
  56271. ctx.scale(1, -1);
  56272. ctx.drawImage(maskCanvas.canvas, 0, 0, width, height, 0, -1, 1, 1);
  56273. ctx.restore();
  56274. }
  56275. },
  56276. paintImageXObject: function CanvasGraphics_paintImageXObject(objId) {
  56277. var imgData = this.objs.get(objId);
  56278. if (!imgData) {
  56279. warn('Dependent image isn\'t ready yet');
  56280. return;
  56281. }
  56282. this.paintInlineImageXObject(imgData);
  56283. },
  56284. paintImageXObjectRepeat: function CanvasGraphics_paintImageXObjectRepeat(objId, scaleX, scaleY, positions) {
  56285. var imgData = this.objs.get(objId);
  56286. if (!imgData) {
  56287. warn('Dependent image isn\'t ready yet');
  56288. return;
  56289. }
  56290. var width = imgData.width;
  56291. var height = imgData.height;
  56292. var map = [];
  56293. for (var i = 0, ii = positions.length; i < ii; i += 2) {
  56294. map.push({
  56295. transform: [
  56296. scaleX,
  56297. 0,
  56298. 0,
  56299. scaleY,
  56300. positions[i],
  56301. positions[i + 1]
  56302. ],
  56303. x: 0,
  56304. y: 0,
  56305. w: width,
  56306. h: height
  56307. });
  56308. }
  56309. this.paintInlineImageXObjectGroup(imgData, map);
  56310. },
  56311. paintInlineImageXObject: function CanvasGraphics_paintInlineImageXObject(imgData) {
  56312. var width = imgData.width;
  56313. var height = imgData.height;
  56314. var ctx = this.ctx;
  56315. this.save();
  56316. ctx.scale(1 / width, -1 / height);
  56317. var currentTransform = ctx.mozCurrentTransformInverse;
  56318. var a = currentTransform[0], b = currentTransform[1];
  56319. var widthScale = Math.max(Math.sqrt(a * a + b * b), 1);
  56320. var c = currentTransform[2], d = currentTransform[3];
  56321. var heightScale = Math.max(Math.sqrt(c * c + d * d), 1);
  56322. var imgToPaint, tmpCanvas;
  56323. if (imgData instanceof HTMLElement || !imgData.data) {
  56324. imgToPaint = imgData;
  56325. } else {
  56326. tmpCanvas = this.cachedCanvases.getCanvas('inlineImage', width, height);
  56327. var tmpCtx = tmpCanvas.context;
  56328. putBinaryImageData(tmpCtx, imgData);
  56329. imgToPaint = tmpCanvas.canvas;
  56330. }
  56331. var paintWidth = width, paintHeight = height;
  56332. var tmpCanvasId = 'prescale1';
  56333. while (widthScale > 2 && paintWidth > 1 || heightScale > 2 && paintHeight > 1) {
  56334. var newWidth = paintWidth, newHeight = paintHeight;
  56335. if (widthScale > 2 && paintWidth > 1) {
  56336. newWidth = Math.ceil(paintWidth / 2);
  56337. widthScale /= paintWidth / newWidth;
  56338. }
  56339. if (heightScale > 2 && paintHeight > 1) {
  56340. newHeight = Math.ceil(paintHeight / 2);
  56341. heightScale /= paintHeight / newHeight;
  56342. }
  56343. tmpCanvas = this.cachedCanvases.getCanvas(tmpCanvasId, newWidth, newHeight);
  56344. tmpCtx = tmpCanvas.context;
  56345. tmpCtx.clearRect(0, 0, newWidth, newHeight);
  56346. tmpCtx.drawImage(imgToPaint, 0, 0, paintWidth, paintHeight, 0, 0, newWidth, newHeight);
  56347. imgToPaint = tmpCanvas.canvas;
  56348. paintWidth = newWidth;
  56349. paintHeight = newHeight;
  56350. tmpCanvasId = tmpCanvasId === 'prescale1' ? 'prescale2' : 'prescale1';
  56351. }
  56352. ctx.drawImage(imgToPaint, 0, 0, paintWidth, paintHeight, 0, -height, width, height);
  56353. if (this.imageLayer) {
  56354. var position = this.getCanvasPosition(0, -height);
  56355. this.imageLayer.appendImage({
  56356. imgData: imgData,
  56357. left: position[0],
  56358. top: position[1],
  56359. width: width / currentTransform[0],
  56360. height: height / currentTransform[3]
  56361. });
  56362. }
  56363. this.restore();
  56364. },
  56365. paintInlineImageXObjectGroup: function CanvasGraphics_paintInlineImageXObjectGroup(imgData, map) {
  56366. var ctx = this.ctx;
  56367. var w = imgData.width;
  56368. var h = imgData.height;
  56369. var tmpCanvas = this.cachedCanvases.getCanvas('inlineImage', w, h);
  56370. var tmpCtx = tmpCanvas.context;
  56371. putBinaryImageData(tmpCtx, imgData);
  56372. for (var i = 0, ii = map.length; i < ii; i++) {
  56373. var entry = map[i];
  56374. ctx.save();
  56375. ctx.transform.apply(ctx, entry.transform);
  56376. ctx.scale(1, -1);
  56377. ctx.drawImage(tmpCanvas.canvas, entry.x, entry.y, entry.w, entry.h, 0, -1, 1, 1);
  56378. if (this.imageLayer) {
  56379. var position = this.getCanvasPosition(entry.x, entry.y);
  56380. this.imageLayer.appendImage({
  56381. imgData: imgData,
  56382. left: position[0],
  56383. top: position[1],
  56384. width: w,
  56385. height: h
  56386. });
  56387. }
  56388. ctx.restore();
  56389. }
  56390. },
  56391. paintSolidColorImageMask: function CanvasGraphics_paintSolidColorImageMask() {
  56392. this.ctx.fillRect(0, 0, 1, 1);
  56393. },
  56394. paintXObject: function CanvasGraphics_paintXObject() {
  56395. warn('Unsupported \'paintXObject\' command.');
  56396. },
  56397. markPoint: function CanvasGraphics_markPoint(tag) {
  56398. },
  56399. markPointProps: function CanvasGraphics_markPointProps(tag, properties) {
  56400. },
  56401. beginMarkedContent: function CanvasGraphics_beginMarkedContent(tag) {
  56402. },
  56403. beginMarkedContentProps: function CanvasGraphics_beginMarkedContentProps(tag, properties) {
  56404. },
  56405. endMarkedContent: function CanvasGraphics_endMarkedContent() {
  56406. },
  56407. beginCompat: function CanvasGraphics_beginCompat() {
  56408. },
  56409. endCompat: function CanvasGraphics_endCompat() {
  56410. },
  56411. consumePath: function CanvasGraphics_consumePath() {
  56412. var ctx = this.ctx;
  56413. if (this.pendingClip) {
  56414. if (this.pendingClip === EO_CLIP) {
  56415. ctx.clip('evenodd');
  56416. } else {
  56417. ctx.clip();
  56418. }
  56419. this.pendingClip = null;
  56420. }
  56421. ctx.beginPath();
  56422. },
  56423. getSinglePixelWidth: function CanvasGraphics_getSinglePixelWidth(scale) {
  56424. if (this.cachedGetSinglePixelWidth === null) {
  56425. this.ctx.save();
  56426. var inverse = this.ctx.mozCurrentTransformInverse;
  56427. this.ctx.restore();
  56428. this.cachedGetSinglePixelWidth = Math.sqrt(Math.max(inverse[0] * inverse[0] + inverse[1] * inverse[1], inverse[2] * inverse[2] + inverse[3] * inverse[3]));
  56429. }
  56430. return this.cachedGetSinglePixelWidth;
  56431. },
  56432. getCanvasPosition: function CanvasGraphics_getCanvasPosition(x, y) {
  56433. var transform = this.ctx.mozCurrentTransform;
  56434. return [
  56435. transform[0] * x + transform[2] * y + transform[4],
  56436. transform[1] * x + transform[3] * y + transform[5]
  56437. ];
  56438. }
  56439. };
  56440. for (var op in OPS) {
  56441. CanvasGraphics.prototype[OPS[op]] = CanvasGraphics.prototype[op];
  56442. }
  56443. return CanvasGraphics;
  56444. }();
  56445. exports.CanvasGraphics = CanvasGraphics;
  56446. /***/ }),
  56447. /* 46 */
  56448. /***/ (function(module, exports, __w_pdfjs_require__) {
  56449. "use strict";
  56450. var sharedUtil = __w_pdfjs_require__(0);
  56451. var assert = sharedUtil.assert;
  56452. var bytesToString = sharedUtil.bytesToString;
  56453. var string32 = sharedUtil.string32;
  56454. var shadow = sharedUtil.shadow;
  56455. var warn = sharedUtil.warn;
  56456. function FontLoader(docId) {
  56457. this.docId = docId;
  56458. this.styleElement = null;
  56459. this.nativeFontFaces = [];
  56460. this.loadTestFontId = 0;
  56461. this.loadingContext = {
  56462. requests: [],
  56463. nextRequestId: 0
  56464. };
  56465. }
  56466. FontLoader.prototype = {
  56467. insertRule: function fontLoaderInsertRule(rule) {
  56468. var styleElement = this.styleElement;
  56469. if (!styleElement) {
  56470. styleElement = this.styleElement = document.createElement('style');
  56471. styleElement.id = 'PDFJS_FONT_STYLE_TAG_' + this.docId;
  56472. document.documentElement.getElementsByTagName('head')[0].appendChild(styleElement);
  56473. }
  56474. var styleSheet = styleElement.sheet;
  56475. styleSheet.insertRule(rule, styleSheet.cssRules.length);
  56476. },
  56477. clear: function fontLoaderClear() {
  56478. var styleElement = this.styleElement;
  56479. if (styleElement) {
  56480. if (styleElement.parentNode) {
  56481. styleElement.parentNode.removeChild(styleElement);
  56482. }
  56483. styleElement = this.styleElement = null;
  56484. }
  56485. this.nativeFontFaces.forEach(function (nativeFontFace) {
  56486. document.fonts.delete(nativeFontFace);
  56487. });
  56488. this.nativeFontFaces.length = 0;
  56489. }
  56490. };
  56491. var getLoadTestFont = function () {
  56492. 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==');
  56493. };
  56494. Object.defineProperty(FontLoader.prototype, 'loadTestFont', {
  56495. get: function () {
  56496. return shadow(this, 'loadTestFont', getLoadTestFont());
  56497. },
  56498. configurable: true
  56499. });
  56500. FontLoader.prototype.addNativeFontFace = function fontLoader_addNativeFontFace(nativeFontFace) {
  56501. this.nativeFontFaces.push(nativeFontFace);
  56502. document.fonts.add(nativeFontFace);
  56503. };
  56504. FontLoader.prototype.bind = function fontLoaderBind(fonts, callback) {
  56505. var rules = [];
  56506. var fontsToLoad = [];
  56507. var fontLoadPromises = [];
  56508. var getNativeFontPromise = function (nativeFontFace) {
  56509. return nativeFontFace.loaded.catch(function (e) {
  56510. warn('Failed to load font "' + nativeFontFace.family + '": ' + e);
  56511. });
  56512. };
  56513. var isFontLoadingAPISupported = FontLoader.isFontLoadingAPISupported && !FontLoader.isSyncFontLoadingSupported;
  56514. for (var i = 0, ii = fonts.length; i < ii; i++) {
  56515. var font = fonts[i];
  56516. if (font.attached || font.loading === false) {
  56517. continue;
  56518. }
  56519. font.attached = true;
  56520. if (isFontLoadingAPISupported) {
  56521. var nativeFontFace = font.createNativeFontFace();
  56522. if (nativeFontFace) {
  56523. this.addNativeFontFace(nativeFontFace);
  56524. fontLoadPromises.push(getNativeFontPromise(nativeFontFace));
  56525. }
  56526. } else {
  56527. var rule = font.createFontFaceRule();
  56528. if (rule) {
  56529. this.insertRule(rule);
  56530. rules.push(rule);
  56531. fontsToLoad.push(font);
  56532. }
  56533. }
  56534. }
  56535. var request = this.queueLoadingCallback(callback);
  56536. if (isFontLoadingAPISupported) {
  56537. Promise.all(fontLoadPromises).then(function () {
  56538. request.complete();
  56539. });
  56540. } else if (rules.length > 0 && !FontLoader.isSyncFontLoadingSupported) {
  56541. this.prepareFontLoadEvent(rules, fontsToLoad, request);
  56542. } else {
  56543. request.complete();
  56544. }
  56545. };
  56546. FontLoader.prototype.queueLoadingCallback = function FontLoader_queueLoadingCallback(callback) {
  56547. function LoadLoader_completeRequest() {
  56548. assert(!request.end, 'completeRequest() cannot be called twice');
  56549. request.end = Date.now();
  56550. while (context.requests.length > 0 && context.requests[0].end) {
  56551. var otherRequest = context.requests.shift();
  56552. setTimeout(otherRequest.callback, 0);
  56553. }
  56554. }
  56555. var context = this.loadingContext;
  56556. var requestId = 'pdfjs-font-loading-' + context.nextRequestId++;
  56557. var request = {
  56558. id: requestId,
  56559. complete: LoadLoader_completeRequest,
  56560. callback: callback,
  56561. started: Date.now()
  56562. };
  56563. context.requests.push(request);
  56564. return request;
  56565. };
  56566. FontLoader.prototype.prepareFontLoadEvent = function fontLoaderPrepareFontLoadEvent(rules, fonts, request) {
  56567. function int32(data, offset) {
  56568. return data.charCodeAt(offset) << 24 | data.charCodeAt(offset + 1) << 16 | data.charCodeAt(offset + 2) << 8 | data.charCodeAt(offset + 3) & 0xff;
  56569. }
  56570. function spliceString(s, offset, remove, insert) {
  56571. var chunk1 = s.substr(0, offset);
  56572. var chunk2 = s.substr(offset + remove);
  56573. return chunk1 + insert + chunk2;
  56574. }
  56575. var i, ii;
  56576. var canvas = document.createElement('canvas');
  56577. canvas.width = 1;
  56578. canvas.height = 1;
  56579. var ctx = canvas.getContext('2d');
  56580. var called = 0;
  56581. function isFontReady(name, callback) {
  56582. called++;
  56583. if (called > 30) {
  56584. warn('Load test font never loaded.');
  56585. callback();
  56586. return;
  56587. }
  56588. ctx.font = '30px ' + name;
  56589. ctx.fillText('.', 0, 20);
  56590. var imageData = ctx.getImageData(0, 0, 1, 1);
  56591. if (imageData.data[3] > 0) {
  56592. callback();
  56593. return;
  56594. }
  56595. setTimeout(isFontReady.bind(null, name, callback));
  56596. }
  56597. var loadTestFontId = 'lt' + Date.now() + this.loadTestFontId++;
  56598. var data = this.loadTestFont;
  56599. var COMMENT_OFFSET = 976;
  56600. data = spliceString(data, COMMENT_OFFSET, loadTestFontId.length, loadTestFontId);
  56601. var CFF_CHECKSUM_OFFSET = 16;
  56602. var XXXX_VALUE = 0x58585858;
  56603. var checksum = int32(data, CFF_CHECKSUM_OFFSET);
  56604. for (i = 0, ii = loadTestFontId.length - 3; i < ii; i += 4) {
  56605. checksum = checksum - XXXX_VALUE + int32(loadTestFontId, i) | 0;
  56606. }
  56607. if (i < loadTestFontId.length) {
  56608. checksum = checksum - XXXX_VALUE + int32(loadTestFontId + 'XXX', i) | 0;
  56609. }
  56610. data = spliceString(data, CFF_CHECKSUM_OFFSET, 4, string32(checksum));
  56611. var url = 'url(data:font/opentype;base64,' + btoa(data) + ');';
  56612. var rule = '@font-face { font-family:"' + loadTestFontId + '";src:' + url + '}';
  56613. this.insertRule(rule);
  56614. var names = [];
  56615. for (i = 0, ii = fonts.length; i < ii; i++) {
  56616. names.push(fonts[i].loadedName);
  56617. }
  56618. names.push(loadTestFontId);
  56619. var div = document.createElement('div');
  56620. div.setAttribute('style', 'visibility: hidden;' + 'width: 10px; height: 10px;' + 'position: absolute; top: 0px; left: 0px;');
  56621. for (i = 0, ii = names.length; i < ii; ++i) {
  56622. var span = document.createElement('span');
  56623. span.textContent = 'Hi';
  56624. span.style.fontFamily = names[i];
  56625. div.appendChild(span);
  56626. }
  56627. document.body.appendChild(div);
  56628. isFontReady(loadTestFontId, function () {
  56629. document.body.removeChild(div);
  56630. request.complete();
  56631. });
  56632. };
  56633. FontLoader.isFontLoadingAPISupported = typeof document !== 'undefined' && !!document.fonts;
  56634. var isSyncFontLoadingSupported = function isSyncFontLoadingSupported() {
  56635. if (typeof navigator === 'undefined') {
  56636. return true;
  56637. }
  56638. var supported = false;
  56639. var m = /Mozilla\/5.0.*?rv:(\d+).*? Gecko/.exec(navigator.userAgent);
  56640. if (m && m[1] >= 14) {
  56641. supported = true;
  56642. }
  56643. return supported;
  56644. };
  56645. Object.defineProperty(FontLoader, 'isSyncFontLoadingSupported', {
  56646. get: function () {
  56647. return shadow(FontLoader, 'isSyncFontLoadingSupported', isSyncFontLoadingSupported());
  56648. },
  56649. enumerable: true,
  56650. configurable: true
  56651. });
  56652. var IsEvalSupportedCached = {
  56653. get value() {
  56654. return shadow(this, 'value', sharedUtil.isEvalSupported());
  56655. }
  56656. };
  56657. var FontFaceObject = function FontFaceObjectClosure() {
  56658. function FontFaceObject(translatedData, options) {
  56659. this.compiledGlyphs = Object.create(null);
  56660. for (var i in translatedData) {
  56661. this[i] = translatedData[i];
  56662. }
  56663. this.options = options;
  56664. }
  56665. FontFaceObject.prototype = {
  56666. createNativeFontFace: function FontFaceObject_createNativeFontFace() {
  56667. if (!this.data) {
  56668. return null;
  56669. }
  56670. if (this.options.disableFontFace) {
  56671. this.disableFontFace = true;
  56672. return null;
  56673. }
  56674. var nativeFontFace = new FontFace(this.loadedName, this.data, {});
  56675. if (this.options.fontRegistry) {
  56676. this.options.fontRegistry.registerFont(this);
  56677. }
  56678. return nativeFontFace;
  56679. },
  56680. createFontFaceRule: function FontFaceObject_createFontFaceRule() {
  56681. if (!this.data) {
  56682. return null;
  56683. }
  56684. if (this.options.disableFontFace) {
  56685. this.disableFontFace = true;
  56686. return null;
  56687. }
  56688. var data = bytesToString(new Uint8Array(this.data));
  56689. var fontName = this.loadedName;
  56690. var url = 'url(data:' + this.mimetype + ';base64,' + btoa(data) + ');';
  56691. var rule = '@font-face { font-family:"' + fontName + '";src:' + url + '}';
  56692. if (this.options.fontRegistry) {
  56693. this.options.fontRegistry.registerFont(this, url);
  56694. }
  56695. return rule;
  56696. },
  56697. getPathGenerator: function FontFaceObject_getPathGenerator(objs, character) {
  56698. if (!(character in this.compiledGlyphs)) {
  56699. var cmds = objs.get(this.loadedName + '_path_' + character);
  56700. var current, i, len;
  56701. if (this.options.isEvalSupported && IsEvalSupportedCached.value) {
  56702. var args, js = '';
  56703. for (i = 0, len = cmds.length; i < len; i++) {
  56704. current = cmds[i];
  56705. if (current.args !== undefined) {
  56706. args = current.args.join(',');
  56707. } else {
  56708. args = '';
  56709. }
  56710. js += 'c.' + current.cmd + '(' + args + ');\n';
  56711. }
  56712. this.compiledGlyphs[character] = new Function('c', 'size', js);
  56713. } else {
  56714. this.compiledGlyphs[character] = function (c, size) {
  56715. for (i = 0, len = cmds.length; i < len; i++) {
  56716. current = cmds[i];
  56717. if (current.cmd === 'scale') {
  56718. current.args = [
  56719. size,
  56720. -size
  56721. ];
  56722. }
  56723. c[current.cmd].apply(c, current.args);
  56724. }
  56725. };
  56726. }
  56727. }
  56728. return this.compiledGlyphs[character];
  56729. }
  56730. };
  56731. return FontFaceObject;
  56732. }();
  56733. exports.FontFaceObject = FontFaceObject;
  56734. exports.FontLoader = FontLoader;
  56735. /***/ }),
  56736. /* 47 */
  56737. /***/ (function(module, exports, __w_pdfjs_require__) {
  56738. "use strict";
  56739. var sharedUtil = __w_pdfjs_require__(0);
  56740. var displayWebGL = __w_pdfjs_require__(24);
  56741. var Util = sharedUtil.Util;
  56742. var info = sharedUtil.info;
  56743. var isArray = sharedUtil.isArray;
  56744. var error = sharedUtil.error;
  56745. var WebGLUtils = displayWebGL.WebGLUtils;
  56746. var ShadingIRs = {};
  56747. ShadingIRs.RadialAxial = {
  56748. fromIR: function RadialAxial_fromIR(raw) {
  56749. var type = raw[1];
  56750. var colorStops = raw[2];
  56751. var p0 = raw[3];
  56752. var p1 = raw[4];
  56753. var r0 = raw[5];
  56754. var r1 = raw[6];
  56755. return {
  56756. type: 'Pattern',
  56757. getPattern: function RadialAxial_getPattern(ctx) {
  56758. var grad;
  56759. if (type === 'axial') {
  56760. grad = ctx.createLinearGradient(p0[0], p0[1], p1[0], p1[1]);
  56761. } else if (type === 'radial') {
  56762. grad = ctx.createRadialGradient(p0[0], p0[1], r0, p1[0], p1[1], r1);
  56763. }
  56764. for (var i = 0, ii = colorStops.length; i < ii; ++i) {
  56765. var c = colorStops[i];
  56766. grad.addColorStop(c[0], c[1]);
  56767. }
  56768. return grad;
  56769. }
  56770. };
  56771. }
  56772. };
  56773. var createMeshCanvas = function createMeshCanvasClosure() {
  56774. function drawTriangle(data, context, p1, p2, p3, c1, c2, c3) {
  56775. var coords = context.coords, colors = context.colors;
  56776. var bytes = data.data, rowSize = data.width * 4;
  56777. var tmp;
  56778. if (coords[p1 + 1] > coords[p2 + 1]) {
  56779. tmp = p1;
  56780. p1 = p2;
  56781. p2 = tmp;
  56782. tmp = c1;
  56783. c1 = c2;
  56784. c2 = tmp;
  56785. }
  56786. if (coords[p2 + 1] > coords[p3 + 1]) {
  56787. tmp = p2;
  56788. p2 = p3;
  56789. p3 = tmp;
  56790. tmp = c2;
  56791. c2 = c3;
  56792. c3 = tmp;
  56793. }
  56794. if (coords[p1 + 1] > coords[p2 + 1]) {
  56795. tmp = p1;
  56796. p1 = p2;
  56797. p2 = tmp;
  56798. tmp = c1;
  56799. c1 = c2;
  56800. c2 = tmp;
  56801. }
  56802. var x1 = (coords[p1] + context.offsetX) * context.scaleX;
  56803. var y1 = (coords[p1 + 1] + context.offsetY) * context.scaleY;
  56804. var x2 = (coords[p2] + context.offsetX) * context.scaleX;
  56805. var y2 = (coords[p2 + 1] + context.offsetY) * context.scaleY;
  56806. var x3 = (coords[p3] + context.offsetX) * context.scaleX;
  56807. var y3 = (coords[p3 + 1] + context.offsetY) * context.scaleY;
  56808. if (y1 >= y3) {
  56809. return;
  56810. }
  56811. var c1r = colors[c1], c1g = colors[c1 + 1], c1b = colors[c1 + 2];
  56812. var c2r = colors[c2], c2g = colors[c2 + 1], c2b = colors[c2 + 2];
  56813. var c3r = colors[c3], c3g = colors[c3 + 1], c3b = colors[c3 + 2];
  56814. var minY = Math.round(y1), maxY = Math.round(y3);
  56815. var xa, car, cag, cab;
  56816. var xb, cbr, cbg, cbb;
  56817. var k;
  56818. for (var y = minY; y <= maxY; y++) {
  56819. if (y < y2) {
  56820. k = y < y1 ? 0 : y1 === y2 ? 1 : (y1 - y) / (y1 - y2);
  56821. xa = x1 - (x1 - x2) * k;
  56822. car = c1r - (c1r - c2r) * k;
  56823. cag = c1g - (c1g - c2g) * k;
  56824. cab = c1b - (c1b - c2b) * k;
  56825. } else {
  56826. k = y > y3 ? 1 : y2 === y3 ? 0 : (y2 - y) / (y2 - y3);
  56827. xa = x2 - (x2 - x3) * k;
  56828. car = c2r - (c2r - c3r) * k;
  56829. cag = c2g - (c2g - c3g) * k;
  56830. cab = c2b - (c2b - c3b) * k;
  56831. }
  56832. k = y < y1 ? 0 : y > y3 ? 1 : (y1 - y) / (y1 - y3);
  56833. xb = x1 - (x1 - x3) * k;
  56834. cbr = c1r - (c1r - c3r) * k;
  56835. cbg = c1g - (c1g - c3g) * k;
  56836. cbb = c1b - (c1b - c3b) * k;
  56837. var x1_ = Math.round(Math.min(xa, xb));
  56838. var x2_ = Math.round(Math.max(xa, xb));
  56839. var j = rowSize * y + x1_ * 4;
  56840. for (var x = x1_; x <= x2_; x++) {
  56841. k = (xa - x) / (xa - xb);
  56842. k = k < 0 ? 0 : k > 1 ? 1 : k;
  56843. bytes[j++] = car - (car - cbr) * k | 0;
  56844. bytes[j++] = cag - (cag - cbg) * k | 0;
  56845. bytes[j++] = cab - (cab - cbb) * k | 0;
  56846. bytes[j++] = 255;
  56847. }
  56848. }
  56849. }
  56850. function drawFigure(data, figure, context) {
  56851. var ps = figure.coords;
  56852. var cs = figure.colors;
  56853. var i, ii;
  56854. switch (figure.type) {
  56855. case 'lattice':
  56856. var verticesPerRow = figure.verticesPerRow;
  56857. var rows = Math.floor(ps.length / verticesPerRow) - 1;
  56858. var cols = verticesPerRow - 1;
  56859. for (i = 0; i < rows; i++) {
  56860. var q = i * verticesPerRow;
  56861. for (var j = 0; j < cols; j++, q++) {
  56862. drawTriangle(data, context, ps[q], ps[q + 1], ps[q + verticesPerRow], cs[q], cs[q + 1], cs[q + verticesPerRow]);
  56863. drawTriangle(data, context, ps[q + verticesPerRow + 1], ps[q + 1], ps[q + verticesPerRow], cs[q + verticesPerRow + 1], cs[q + 1], cs[q + verticesPerRow]);
  56864. }
  56865. }
  56866. break;
  56867. case 'triangles':
  56868. for (i = 0, ii = ps.length; i < ii; i += 3) {
  56869. drawTriangle(data, context, ps[i], ps[i + 1], ps[i + 2], cs[i], cs[i + 1], cs[i + 2]);
  56870. }
  56871. break;
  56872. default:
  56873. error('illigal figure');
  56874. break;
  56875. }
  56876. }
  56877. function createMeshCanvas(bounds, combinesScale, coords, colors, figures, backgroundColor, cachedCanvases) {
  56878. var EXPECTED_SCALE = 1.1;
  56879. var MAX_PATTERN_SIZE = 3000;
  56880. var BORDER_SIZE = 2;
  56881. var offsetX = Math.floor(bounds[0]);
  56882. var offsetY = Math.floor(bounds[1]);
  56883. var boundsWidth = Math.ceil(bounds[2]) - offsetX;
  56884. var boundsHeight = Math.ceil(bounds[3]) - offsetY;
  56885. var width = Math.min(Math.ceil(Math.abs(boundsWidth * combinesScale[0] * EXPECTED_SCALE)), MAX_PATTERN_SIZE);
  56886. var height = Math.min(Math.ceil(Math.abs(boundsHeight * combinesScale[1] * EXPECTED_SCALE)), MAX_PATTERN_SIZE);
  56887. var scaleX = boundsWidth / width;
  56888. var scaleY = boundsHeight / height;
  56889. var context = {
  56890. coords: coords,
  56891. colors: colors,
  56892. offsetX: -offsetX,
  56893. offsetY: -offsetY,
  56894. scaleX: 1 / scaleX,
  56895. scaleY: 1 / scaleY
  56896. };
  56897. var paddedWidth = width + BORDER_SIZE * 2;
  56898. var paddedHeight = height + BORDER_SIZE * 2;
  56899. var canvas, tmpCanvas, i, ii;
  56900. if (WebGLUtils.isEnabled) {
  56901. canvas = WebGLUtils.drawFigures(width, height, backgroundColor, figures, context);
  56902. tmpCanvas = cachedCanvases.getCanvas('mesh', paddedWidth, paddedHeight, false);
  56903. tmpCanvas.context.drawImage(canvas, BORDER_SIZE, BORDER_SIZE);
  56904. canvas = tmpCanvas.canvas;
  56905. } else {
  56906. tmpCanvas = cachedCanvases.getCanvas('mesh', paddedWidth, paddedHeight, false);
  56907. var tmpCtx = tmpCanvas.context;
  56908. var data = tmpCtx.createImageData(width, height);
  56909. if (backgroundColor) {
  56910. var bytes = data.data;
  56911. for (i = 0, ii = bytes.length; i < ii; i += 4) {
  56912. bytes[i] = backgroundColor[0];
  56913. bytes[i + 1] = backgroundColor[1];
  56914. bytes[i + 2] = backgroundColor[2];
  56915. bytes[i + 3] = 255;
  56916. }
  56917. }
  56918. for (i = 0; i < figures.length; i++) {
  56919. drawFigure(data, figures[i], context);
  56920. }
  56921. tmpCtx.putImageData(data, BORDER_SIZE, BORDER_SIZE);
  56922. canvas = tmpCanvas.canvas;
  56923. }
  56924. return {
  56925. canvas: canvas,
  56926. offsetX: offsetX - BORDER_SIZE * scaleX,
  56927. offsetY: offsetY - BORDER_SIZE * scaleY,
  56928. scaleX: scaleX,
  56929. scaleY: scaleY
  56930. };
  56931. }
  56932. return createMeshCanvas;
  56933. }();
  56934. ShadingIRs.Mesh = {
  56935. fromIR: function Mesh_fromIR(raw) {
  56936. var coords = raw[2];
  56937. var colors = raw[3];
  56938. var figures = raw[4];
  56939. var bounds = raw[5];
  56940. var matrix = raw[6];
  56941. var background = raw[8];
  56942. return {
  56943. type: 'Pattern',
  56944. getPattern: function Mesh_getPattern(ctx, owner, shadingFill) {
  56945. var scale;
  56946. if (shadingFill) {
  56947. scale = Util.singularValueDecompose2dScale(ctx.mozCurrentTransform);
  56948. } else {
  56949. scale = Util.singularValueDecompose2dScale(owner.baseTransform);
  56950. if (matrix) {
  56951. var matrixScale = Util.singularValueDecompose2dScale(matrix);
  56952. scale = [
  56953. scale[0] * matrixScale[0],
  56954. scale[1] * matrixScale[1]
  56955. ];
  56956. }
  56957. }
  56958. var temporaryPatternCanvas = createMeshCanvas(bounds, scale, coords, colors, figures, shadingFill ? null : background, owner.cachedCanvases);
  56959. if (!shadingFill) {
  56960. ctx.setTransform.apply(ctx, owner.baseTransform);
  56961. if (matrix) {
  56962. ctx.transform.apply(ctx, matrix);
  56963. }
  56964. }
  56965. ctx.translate(temporaryPatternCanvas.offsetX, temporaryPatternCanvas.offsetY);
  56966. ctx.scale(temporaryPatternCanvas.scaleX, temporaryPatternCanvas.scaleY);
  56967. return ctx.createPattern(temporaryPatternCanvas.canvas, 'no-repeat');
  56968. }
  56969. };
  56970. }
  56971. };
  56972. ShadingIRs.Dummy = {
  56973. fromIR: function Dummy_fromIR() {
  56974. return {
  56975. type: 'Pattern',
  56976. getPattern: function Dummy_fromIR_getPattern() {
  56977. return 'hotpink';
  56978. }
  56979. };
  56980. }
  56981. };
  56982. function getShadingPatternFromIR(raw) {
  56983. var shadingIR = ShadingIRs[raw[0]];
  56984. if (!shadingIR) {
  56985. error('Unknown IR type: ' + raw[0]);
  56986. }
  56987. return shadingIR.fromIR(raw);
  56988. }
  56989. var TilingPattern = function TilingPatternClosure() {
  56990. var PaintType = {
  56991. COLORED: 1,
  56992. UNCOLORED: 2
  56993. };
  56994. var MAX_PATTERN_SIZE = 3000;
  56995. function TilingPattern(IR, color, ctx, canvasGraphicsFactory, baseTransform) {
  56996. this.operatorList = IR[2];
  56997. this.matrix = IR[3] || [
  56998. 1,
  56999. 0,
  57000. 0,
  57001. 1,
  57002. 0,
  57003. 0
  57004. ];
  57005. this.bbox = IR[4];
  57006. this.xstep = IR[5];
  57007. this.ystep = IR[6];
  57008. this.paintType = IR[7];
  57009. this.tilingType = IR[8];
  57010. this.color = color;
  57011. this.canvasGraphicsFactory = canvasGraphicsFactory;
  57012. this.baseTransform = baseTransform;
  57013. this.type = 'Pattern';
  57014. this.ctx = ctx;
  57015. }
  57016. TilingPattern.prototype = {
  57017. createPatternCanvas: function TilinPattern_createPatternCanvas(owner) {
  57018. var operatorList = this.operatorList;
  57019. var bbox = this.bbox;
  57020. var xstep = this.xstep;
  57021. var ystep = this.ystep;
  57022. var paintType = this.paintType;
  57023. var tilingType = this.tilingType;
  57024. var color = this.color;
  57025. var canvasGraphicsFactory = this.canvasGraphicsFactory;
  57026. info('TilingType: ' + tilingType);
  57027. var x0 = bbox[0], y0 = bbox[1], x1 = bbox[2], y1 = bbox[3];
  57028. var topLeft = [
  57029. x0,
  57030. y0
  57031. ];
  57032. var botRight = [
  57033. x0 + xstep,
  57034. y0 + ystep
  57035. ];
  57036. var width = botRight[0] - topLeft[0];
  57037. var height = botRight[1] - topLeft[1];
  57038. var matrixScale = Util.singularValueDecompose2dScale(this.matrix);
  57039. var curMatrixScale = Util.singularValueDecompose2dScale(this.baseTransform);
  57040. var combinedScale = [
  57041. matrixScale[0] * curMatrixScale[0],
  57042. matrixScale[1] * curMatrixScale[1]
  57043. ];
  57044. width = Math.min(Math.ceil(Math.abs(width * combinedScale[0])), MAX_PATTERN_SIZE);
  57045. height = Math.min(Math.ceil(Math.abs(height * combinedScale[1])), MAX_PATTERN_SIZE);
  57046. var tmpCanvas = owner.cachedCanvases.getCanvas('pattern', width, height, true);
  57047. var tmpCtx = tmpCanvas.context;
  57048. var graphics = canvasGraphicsFactory.createCanvasGraphics(tmpCtx);
  57049. graphics.groupLevel = owner.groupLevel;
  57050. this.setFillAndStrokeStyleToContext(tmpCtx, paintType, color);
  57051. this.setScale(width, height, xstep, ystep);
  57052. this.transformToScale(graphics);
  57053. var tmpTranslate = [
  57054. 1,
  57055. 0,
  57056. 0,
  57057. 1,
  57058. -topLeft[0],
  57059. -topLeft[1]
  57060. ];
  57061. graphics.transform.apply(graphics, tmpTranslate);
  57062. this.clipBbox(graphics, bbox, x0, y0, x1, y1);
  57063. graphics.executeOperatorList(operatorList);
  57064. return tmpCanvas.canvas;
  57065. },
  57066. setScale: function TilingPattern_setScale(width, height, xstep, ystep) {
  57067. this.scale = [
  57068. width / xstep,
  57069. height / ystep
  57070. ];
  57071. },
  57072. transformToScale: function TilingPattern_transformToScale(graphics) {
  57073. var scale = this.scale;
  57074. var tmpScale = [
  57075. scale[0],
  57076. 0,
  57077. 0,
  57078. scale[1],
  57079. 0,
  57080. 0
  57081. ];
  57082. graphics.transform.apply(graphics, tmpScale);
  57083. },
  57084. scaleToContext: function TilingPattern_scaleToContext() {
  57085. var scale = this.scale;
  57086. this.ctx.scale(1 / scale[0], 1 / scale[1]);
  57087. },
  57088. clipBbox: function clipBbox(graphics, bbox, x0, y0, x1, y1) {
  57089. if (bbox && isArray(bbox) && bbox.length === 4) {
  57090. var bboxWidth = x1 - x0;
  57091. var bboxHeight = y1 - y0;
  57092. graphics.ctx.rect(x0, y0, bboxWidth, bboxHeight);
  57093. graphics.clip();
  57094. graphics.endPath();
  57095. }
  57096. },
  57097. setFillAndStrokeStyleToContext: function setFillAndStrokeStyleToContext(context, paintType, color) {
  57098. switch (paintType) {
  57099. case PaintType.COLORED:
  57100. var ctx = this.ctx;
  57101. context.fillStyle = ctx.fillStyle;
  57102. context.strokeStyle = ctx.strokeStyle;
  57103. break;
  57104. case PaintType.UNCOLORED:
  57105. var cssColor = Util.makeCssRgb(color[0], color[1], color[2]);
  57106. context.fillStyle = cssColor;
  57107. context.strokeStyle = cssColor;
  57108. break;
  57109. default:
  57110. error('Unsupported paint type: ' + paintType);
  57111. }
  57112. },
  57113. getPattern: function TilingPattern_getPattern(ctx, owner) {
  57114. var temporaryPatternCanvas = this.createPatternCanvas(owner);
  57115. ctx = this.ctx;
  57116. ctx.setTransform.apply(ctx, this.baseTransform);
  57117. ctx.transform.apply(ctx, this.matrix);
  57118. this.scaleToContext();
  57119. return ctx.createPattern(temporaryPatternCanvas, 'repeat');
  57120. }
  57121. };
  57122. return TilingPattern;
  57123. }();
  57124. exports.getShadingPatternFromIR = getShadingPatternFromIR;
  57125. exports.TilingPattern = TilingPattern;
  57126. /***/ }),
  57127. /* 48 */
  57128. /***/ (function(module, exports, __w_pdfjs_require__) {
  57129. "use strict";
  57130. var pdfjsVersion = '1.7.280';
  57131. var pdfjsBuild = '1549a46e';
  57132. var pdfjsSharedUtil = __w_pdfjs_require__(0);
  57133. var pdfjsDisplayGlobal = __w_pdfjs_require__(25);
  57134. var pdfjsDisplayAPI = __w_pdfjs_require__(10);
  57135. var pdfjsDisplayTextLayer = __w_pdfjs_require__(12);
  57136. var pdfjsDisplayAnnotationLayer = __w_pdfjs_require__(9);
  57137. var pdfjsDisplayDOMUtils = __w_pdfjs_require__(3);
  57138. var pdfjsDisplaySVG = __w_pdfjs_require__(11);
  57139. exports.PDFJS = pdfjsDisplayGlobal.PDFJS;
  57140. exports.build = pdfjsDisplayAPI.build;
  57141. exports.version = pdfjsDisplayAPI.version;
  57142. exports.getDocument = pdfjsDisplayAPI.getDocument;
  57143. exports.PDFDataRangeTransport = pdfjsDisplayAPI.PDFDataRangeTransport;
  57144. exports.PDFWorker = pdfjsDisplayAPI.PDFWorker;
  57145. exports.renderTextLayer = pdfjsDisplayTextLayer.renderTextLayer;
  57146. exports.AnnotationLayer = pdfjsDisplayAnnotationLayer.AnnotationLayer;
  57147. exports.CustomStyle = pdfjsDisplayDOMUtils.CustomStyle;
  57148. exports.createPromiseCapability = pdfjsSharedUtil.createPromiseCapability;
  57149. exports.PasswordResponses = pdfjsSharedUtil.PasswordResponses;
  57150. exports.InvalidPDFException = pdfjsSharedUtil.InvalidPDFException;
  57151. exports.MissingPDFException = pdfjsSharedUtil.MissingPDFException;
  57152. exports.SVGGraphics = pdfjsDisplaySVG.SVGGraphics;
  57153. exports.UnexpectedResponseException = pdfjsSharedUtil.UnexpectedResponseException;
  57154. exports.OPS = pdfjsSharedUtil.OPS;
  57155. exports.UNSUPPORTED_FEATURES = pdfjsSharedUtil.UNSUPPORTED_FEATURES;
  57156. exports.isValidUrl = pdfjsDisplayDOMUtils.isValidUrl;
  57157. exports.createValidAbsoluteUrl = pdfjsSharedUtil.createValidAbsoluteUrl;
  57158. exports.createObjectURL = pdfjsSharedUtil.createObjectURL;
  57159. exports.removeNullCharacters = pdfjsSharedUtil.removeNullCharacters;
  57160. exports.shadow = pdfjsSharedUtil.shadow;
  57161. exports.createBlob = pdfjsSharedUtil.createBlob;
  57162. exports.getFilenameFromUrl = pdfjsDisplayDOMUtils.getFilenameFromUrl;
  57163. exports.addLinkAttributes = pdfjsDisplayDOMUtils.addLinkAttributes;
  57164. /***/ })
  57165. /******/ ]);
  57166. });