pdf.combined.js 1.3 MB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180818181828183818481858186818781888189819081918192819381948195819681978198819982008201820282038204820582068207820882098210821182128213821482158216821782188219822082218222822382248225822682278228822982308231823282338234823582368237823882398240824182428243824482458246824782488249825082518252825382548255825682578258825982608261826282638264826582668267826882698270827182728273827482758276827782788279828082818282828382848285828682878288828982908291829282938294829582968297829882998300830183028303830483058306830783088309831083118312831383148315831683178318831983208321832283238324832583268327832883298330833183328333833483358336833783388339834083418342834383448345834683478348834983508351835283538354835583568357835883598360836183628363836483658366836783688369837083718372837383748375837683778378837983808381838283838384838583868387838883898390839183928393839483958396839783988399840084018402840384048405840684078408840984108411841284138414841584168417841884198420842184228423842484258426842784288429843084318432843384348435843684378438843984408441844284438444844584468447844884498450845184528453845484558456845784588459846084618462846384648465846684678468846984708471847284738474847584768477847884798480848184828483848484858486848784888489849084918492849384948495849684978498849985008501850285038504850585068507850885098510851185128513851485158516851785188519852085218522852385248525852685278528852985308531853285338534853585368537853885398540854185428543854485458546854785488549855085518552855385548555855685578558855985608561856285638564856585668567856885698570857185728573857485758576857785788579858085818582858385848585858685878588858985908591859285938594859585968597859885998600860186028603860486058606860786088609861086118612861386148615861686178618861986208621862286238624862586268627862886298630863186328633863486358636863786388639864086418642864386448645864686478648864986508651865286538654865586568657865886598660866186628663866486658666866786688669867086718672867386748675867686778678867986808681868286838684868586868687868886898690869186928693869486958696869786988699870087018702870387048705870687078708870987108711871287138714871587168717871887198720872187228723872487258726872787288729873087318732873387348735873687378738873987408741874287438744874587468747874887498750875187528753875487558756875787588759876087618762876387648765876687678768876987708771877287738774877587768777877887798780878187828783878487858786878787888789879087918792879387948795879687978798879988008801880288038804880588068807880888098810881188128813881488158816881788188819882088218822882388248825882688278828882988308831883288338834883588368837883888398840884188428843884488458846884788488849885088518852885388548855885688578858885988608861886288638864886588668867886888698870887188728873887488758876887788788879888088818882888388848885888688878888888988908891889288938894889588968897889888998900890189028903890489058906890789088909891089118912891389148915891689178918891989208921892289238924892589268927892889298930893189328933893489358936893789388939894089418942894389448945894689478948894989508951895289538954895589568957895889598960896189628963896489658966896789688969897089718972897389748975897689778978897989808981898289838984898589868987898889898990899189928993899489958996899789988999900090019002900390049005900690079008900990109011901290139014901590169017901890199020902190229023902490259026902790289029903090319032903390349035903690379038903990409041904290439044904590469047904890499050905190529053905490559056905790589059906090619062906390649065906690679068906990709071907290739074907590769077907890799080908190829083908490859086908790889089909090919092909390949095909690979098909991009101910291039104910591069107910891099110911191129113911491159116911791189119912091219122912391249125912691279128912991309131913291339134913591369137913891399140914191429143914491459146914791489149915091519152915391549155915691579158915991609161916291639164916591669167916891699170917191729173917491759176917791789179918091819182918391849185918691879188918991909191919291939194919591969197919891999200920192029203920492059206920792089209921092119212921392149215921692179218921992209221922292239224922592269227922892299230923192329233923492359236923792389239924092419242924392449245924692479248924992509251925292539254925592569257925892599260926192629263926492659266926792689269927092719272927392749275927692779278927992809281928292839284928592869287928892899290929192929293929492959296929792989299930093019302930393049305930693079308930993109311931293139314931593169317931893199320932193229323932493259326932793289329933093319332933393349335933693379338933993409341934293439344934593469347934893499350935193529353935493559356935793589359936093619362936393649365936693679368936993709371937293739374937593769377937893799380938193829383938493859386938793889389939093919392939393949395939693979398939994009401940294039404940594069407940894099410941194129413941494159416941794189419942094219422942394249425942694279428942994309431943294339434943594369437943894399440944194429443944494459446944794489449945094519452945394549455945694579458945994609461946294639464946594669467946894699470947194729473947494759476947794789479948094819482948394849485948694879488948994909491949294939494949594969497949894999500950195029503950495059506950795089509951095119512951395149515951695179518951995209521952295239524952595269527952895299530953195329533953495359536953795389539954095419542954395449545954695479548954995509551955295539554955595569557955895599560956195629563956495659566956795689569957095719572957395749575957695779578957995809581958295839584958595869587958895899590959195929593959495959596959795989599960096019602960396049605960696079608960996109611961296139614961596169617961896199620962196229623962496259626962796289629963096319632963396349635963696379638963996409641964296439644964596469647964896499650965196529653965496559656965796589659966096619662966396649665966696679668966996709671967296739674967596769677967896799680968196829683968496859686968796889689969096919692969396949695969696979698969997009701970297039704970597069707970897099710971197129713971497159716971797189719972097219722972397249725972697279728972997309731973297339734973597369737973897399740974197429743974497459746974797489749975097519752975397549755975697579758975997609761976297639764976597669767976897699770977197729773977497759776977797789779978097819782978397849785978697879788978997909791979297939794979597969797979897999800980198029803980498059806980798089809981098119812981398149815981698179818981998209821982298239824982598269827982898299830983198329833983498359836983798389839984098419842984398449845984698479848984998509851985298539854985598569857985898599860986198629863986498659866986798689869987098719872987398749875987698779878987998809881988298839884988598869887988898899890989198929893989498959896989798989899990099019902990399049905990699079908990999109911991299139914991599169917991899199920992199229923992499259926992799289929993099319932993399349935993699379938993999409941994299439944994599469947994899499950995199529953995499559956995799589959996099619962996399649965996699679968996999709971997299739974997599769977997899799980998199829983998499859986998799889989999099919992999399949995999699979998999910000100011000210003100041000510006100071000810009100101001110012100131001410015100161001710018100191002010021100221002310024100251002610027100281002910030100311003210033100341003510036100371003810039100401004110042100431004410045100461004710048100491005010051100521005310054100551005610057100581005910060100611006210063100641006510066100671006810069100701007110072100731007410075100761007710078100791008010081100821008310084100851008610087100881008910090100911009210093100941009510096100971009810099101001010110102101031010410105101061010710108101091011010111101121011310114101151011610117101181011910120101211012210123101241012510126101271012810129101301013110132101331013410135101361013710138101391014010141101421014310144101451014610147101481014910150101511015210153101541015510156101571015810159101601016110162101631016410165101661016710168101691017010171101721017310174101751017610177101781017910180101811018210183101841018510186101871018810189101901019110192101931019410195101961019710198101991020010201102021020310204102051020610207102081020910210102111021210213102141021510216102171021810219102201022110222102231022410225102261022710228102291023010231102321023310234102351023610237102381023910240102411024210243102441024510246102471024810249102501025110252102531025410255102561025710258102591026010261102621026310264102651026610267102681026910270102711027210273102741027510276102771027810279102801028110282102831028410285102861028710288102891029010291102921029310294102951029610297102981029910300103011030210303103041030510306103071030810309103101031110312103131031410315103161031710318103191032010321103221032310324103251032610327103281032910330103311033210333103341033510336103371033810339103401034110342103431034410345103461034710348103491035010351103521035310354103551035610357103581035910360103611036210363103641036510366103671036810369103701037110372103731037410375103761037710378103791038010381103821038310384103851038610387103881038910390103911039210393103941039510396103971039810399104001040110402104031040410405104061040710408104091041010411104121041310414104151041610417104181041910420104211042210423104241042510426104271042810429104301043110432104331043410435104361043710438104391044010441104421044310444104451044610447104481044910450104511045210453104541045510456104571045810459104601046110462104631046410465104661046710468104691047010471104721047310474104751047610477104781047910480104811048210483104841048510486104871048810489104901049110492104931049410495104961049710498104991050010501105021050310504105051050610507105081050910510105111051210513105141051510516105171051810519105201052110522105231052410525105261052710528105291053010531105321053310534105351053610537105381053910540105411054210543105441054510546105471054810549105501055110552105531055410555105561055710558105591056010561105621056310564105651056610567105681056910570105711057210573105741057510576105771057810579105801058110582105831058410585105861058710588105891059010591105921059310594105951059610597105981059910600106011060210603106041060510606106071060810609106101061110612106131061410615106161061710618106191062010621106221062310624106251062610627106281062910630106311063210633106341063510636106371063810639106401064110642106431064410645106461064710648106491065010651106521065310654106551065610657106581065910660106611066210663106641066510666106671066810669106701067110672106731067410675106761067710678106791068010681106821068310684106851068610687106881068910690106911069210693106941069510696106971069810699107001070110702107031070410705107061070710708107091071010711107121071310714107151071610717107181071910720107211072210723107241072510726107271072810729107301073110732107331073410735107361073710738107391074010741107421074310744107451074610747107481074910750107511075210753107541075510756107571075810759107601076110762107631076410765107661076710768107691077010771107721077310774107751077610777107781077910780107811078210783107841078510786107871078810789107901079110792107931079410795107961079710798107991080010801108021080310804108051080610807108081080910810108111081210813108141081510816108171081810819108201082110822108231082410825108261082710828108291083010831108321083310834108351083610837108381083910840108411084210843108441084510846108471084810849108501085110852108531085410855108561085710858108591086010861108621086310864108651086610867108681086910870108711087210873108741087510876108771087810879108801088110882108831088410885108861088710888108891089010891108921089310894108951089610897108981089910900109011090210903109041090510906109071090810909109101091110912109131091410915109161091710918109191092010921109221092310924109251092610927109281092910930109311093210933109341093510936109371093810939109401094110942109431094410945109461094710948109491095010951109521095310954109551095610957109581095910960109611096210963109641096510966109671096810969109701097110972109731097410975109761097710978109791098010981109821098310984109851098610987109881098910990109911099210993109941099510996109971099810999110001100111002110031100411005110061100711008110091101011011110121101311014110151101611017110181101911020110211102211023110241102511026110271102811029110301103111032110331103411035110361103711038110391104011041110421104311044110451104611047110481104911050110511105211053110541105511056110571105811059110601106111062110631106411065110661106711068110691107011071110721107311074110751107611077110781107911080110811108211083110841108511086110871108811089110901109111092110931109411095110961109711098110991110011101111021110311104111051110611107111081110911110111111111211113111141111511116111171111811119111201112111122111231112411125111261112711128111291113011131111321113311134111351113611137111381113911140111411114211143111441114511146111471114811149111501115111152111531115411155111561115711158111591116011161111621116311164111651116611167111681116911170111711117211173111741117511176111771117811179111801118111182111831118411185111861118711188111891119011191111921119311194111951119611197111981119911200112011120211203112041120511206112071120811209112101121111212112131121411215112161121711218112191122011221112221122311224112251122611227112281122911230112311123211233112341123511236112371123811239112401124111242112431124411245112461124711248112491125011251112521125311254112551125611257112581125911260112611126211263112641126511266112671126811269112701127111272112731127411275112761127711278112791128011281112821128311284112851128611287112881128911290112911129211293112941129511296112971129811299113001130111302113031130411305113061130711308113091131011311113121131311314113151131611317113181131911320113211132211323113241132511326113271132811329113301133111332113331133411335113361133711338113391134011341113421134311344113451134611347113481134911350113511135211353113541135511356113571135811359113601136111362113631136411365113661136711368113691137011371113721137311374113751137611377113781137911380113811138211383113841138511386113871138811389113901139111392113931139411395113961139711398113991140011401114021140311404114051140611407114081140911410114111141211413114141141511416114171141811419114201142111422114231142411425114261142711428114291143011431114321143311434114351143611437114381143911440114411144211443114441144511446114471144811449114501145111452114531145411455114561145711458114591146011461114621146311464114651146611467114681146911470114711147211473114741147511476114771147811479114801148111482114831148411485114861148711488114891149011491114921149311494114951149611497114981149911500115011150211503115041150511506115071150811509115101151111512115131151411515115161151711518115191152011521115221152311524115251152611527115281152911530115311153211533115341153511536115371153811539115401154111542115431154411545115461154711548115491155011551115521155311554115551155611557115581155911560115611156211563115641156511566115671156811569115701157111572115731157411575115761157711578115791158011581115821158311584115851158611587115881158911590115911159211593115941159511596115971159811599116001160111602116031160411605116061160711608116091161011611116121161311614116151161611617116181161911620116211162211623116241162511626116271162811629116301163111632116331163411635116361163711638116391164011641116421164311644116451164611647116481164911650116511165211653116541165511656116571165811659116601166111662116631166411665116661166711668116691167011671116721167311674116751167611677116781167911680116811168211683116841168511686116871168811689116901169111692116931169411695116961169711698116991170011701117021170311704117051170611707117081170911710117111171211713117141171511716117171171811719117201172111722117231172411725117261172711728117291173011731117321173311734117351173611737117381173911740117411174211743117441174511746117471174811749117501175111752117531175411755117561175711758117591176011761117621176311764117651176611767117681176911770117711177211773117741177511776117771177811779117801178111782117831178411785117861178711788117891179011791117921179311794117951179611797117981179911800118011180211803118041180511806118071180811809118101181111812118131181411815118161181711818118191182011821118221182311824118251182611827118281182911830118311183211833118341183511836118371183811839118401184111842118431184411845118461184711848118491185011851118521185311854118551185611857118581185911860118611186211863118641186511866118671186811869118701187111872118731187411875118761187711878118791188011881118821188311884118851188611887118881188911890118911189211893118941189511896118971189811899119001190111902119031190411905119061190711908119091191011911119121191311914119151191611917119181191911920119211192211923119241192511926119271192811929119301193111932119331193411935119361193711938119391194011941119421194311944119451194611947119481194911950119511195211953119541195511956119571195811959119601196111962119631196411965119661196711968119691197011971119721197311974119751197611977119781197911980119811198211983119841198511986119871198811989119901199111992119931199411995119961199711998119991200012001120021200312004120051200612007120081200912010120111201212013120141201512016120171201812019120201202112022120231202412025120261202712028120291203012031120321203312034120351203612037120381203912040120411204212043120441204512046120471204812049120501205112052120531205412055120561205712058120591206012061120621206312064120651206612067120681206912070120711207212073120741207512076120771207812079120801208112082120831208412085120861208712088120891209012091120921209312094120951209612097120981209912100121011210212103121041210512106121071210812109121101211112112121131211412115121161211712118121191212012121121221212312124121251212612127121281212912130121311213212133121341213512136121371213812139121401214112142121431214412145121461214712148121491215012151121521215312154121551215612157121581215912160121611216212163121641216512166121671216812169121701217112172121731217412175121761217712178121791218012181121821218312184121851218612187121881218912190121911219212193121941219512196121971219812199122001220112202122031220412205122061220712208122091221012211122121221312214122151221612217122181221912220122211222212223122241222512226122271222812229122301223112232122331223412235122361223712238122391224012241122421224312244122451224612247122481224912250122511225212253122541225512256122571225812259122601226112262122631226412265122661226712268122691227012271122721227312274122751227612277122781227912280122811228212283122841228512286122871228812289122901229112292122931229412295122961229712298122991230012301123021230312304123051230612307123081230912310123111231212313123141231512316123171231812319123201232112322123231232412325123261232712328123291233012331123321233312334123351233612337123381233912340123411234212343123441234512346123471234812349123501235112352123531235412355123561235712358123591236012361123621236312364123651236612367123681236912370123711237212373123741237512376123771237812379123801238112382123831238412385123861238712388123891239012391123921239312394123951239612397123981239912400124011240212403124041240512406124071240812409124101241112412124131241412415124161241712418124191242012421124221242312424124251242612427124281242912430124311243212433124341243512436124371243812439124401244112442124431244412445124461244712448124491245012451124521245312454124551245612457124581245912460124611246212463124641246512466124671246812469124701247112472124731247412475124761247712478124791248012481124821248312484124851248612487124881248912490124911249212493124941249512496124971249812499125001250112502125031250412505125061250712508125091251012511125121251312514125151251612517125181251912520125211252212523125241252512526125271252812529125301253112532125331253412535125361253712538125391254012541125421254312544125451254612547125481254912550125511255212553125541255512556125571255812559125601256112562125631256412565125661256712568125691257012571125721257312574125751257612577125781257912580125811258212583125841258512586125871258812589125901259112592125931259412595125961259712598125991260012601126021260312604126051260612607126081260912610126111261212613126141261512616126171261812619126201262112622126231262412625126261262712628126291263012631126321263312634126351263612637126381263912640126411264212643126441264512646126471264812649126501265112652126531265412655126561265712658126591266012661126621266312664126651266612667126681266912670126711267212673126741267512676126771267812679126801268112682126831268412685126861268712688126891269012691126921269312694126951269612697126981269912700127011270212703127041270512706127071270812709127101271112712127131271412715127161271712718127191272012721127221272312724127251272612727127281272912730127311273212733127341273512736127371273812739127401274112742127431274412745127461274712748127491275012751127521275312754127551275612757127581275912760127611276212763127641276512766127671276812769127701277112772127731277412775127761277712778127791278012781127821278312784127851278612787127881278912790127911279212793127941279512796127971279812799128001280112802128031280412805128061280712808128091281012811128121281312814128151281612817128181281912820128211282212823128241282512826128271282812829128301283112832128331283412835128361283712838128391284012841128421284312844128451284612847128481284912850128511285212853128541285512856128571285812859128601286112862128631286412865128661286712868128691287012871128721287312874128751287612877128781287912880128811288212883128841288512886128871288812889128901289112892128931289412895128961289712898128991290012901129021290312904129051290612907129081290912910129111291212913129141291512916129171291812919129201292112922129231292412925129261292712928129291293012931129321293312934129351293612937129381293912940129411294212943129441294512946129471294812949129501295112952129531295412955129561295712958129591296012961129621296312964129651296612967129681296912970129711297212973129741297512976129771297812979129801298112982129831298412985129861298712988129891299012991129921299312994129951299612997129981299913000130011300213003130041300513006130071300813009130101301113012130131301413015130161301713018130191302013021130221302313024130251302613027130281302913030130311303213033130341303513036130371303813039130401304113042130431304413045130461304713048130491305013051130521305313054130551305613057130581305913060130611306213063130641306513066130671306813069130701307113072130731307413075130761307713078130791308013081130821308313084130851308613087130881308913090130911309213093130941309513096130971309813099131001310113102131031310413105131061310713108131091311013111131121311313114131151311613117131181311913120131211312213123131241312513126131271312813129131301313113132131331313413135131361313713138131391314013141131421314313144131451314613147131481314913150131511315213153131541315513156131571315813159131601316113162131631316413165131661316713168131691317013171131721317313174131751317613177131781317913180131811318213183131841318513186131871318813189131901319113192131931319413195131961319713198131991320013201132021320313204132051320613207132081320913210132111321213213132141321513216132171321813219132201322113222132231322413225132261322713228132291323013231132321323313234132351323613237132381323913240132411324213243132441324513246132471324813249132501325113252132531325413255132561325713258132591326013261132621326313264132651326613267132681326913270132711327213273132741327513276132771327813279132801328113282132831328413285132861328713288132891329013291132921329313294132951329613297132981329913300133011330213303133041330513306133071330813309133101331113312133131331413315133161331713318133191332013321133221332313324133251332613327133281332913330133311333213333133341333513336133371333813339133401334113342133431334413345133461334713348133491335013351133521335313354133551335613357133581335913360133611336213363133641336513366133671336813369133701337113372133731337413375133761337713378133791338013381133821338313384133851338613387133881338913390133911339213393133941339513396133971339813399134001340113402134031340413405134061340713408134091341013411134121341313414134151341613417134181341913420134211342213423134241342513426134271342813429134301343113432134331343413435134361343713438134391344013441134421344313444134451344613447134481344913450134511345213453134541345513456134571345813459134601346113462134631346413465134661346713468134691347013471134721347313474134751347613477134781347913480134811348213483134841348513486134871348813489134901349113492134931349413495134961349713498134991350013501135021350313504135051350613507135081350913510135111351213513135141351513516135171351813519135201352113522135231352413525135261352713528135291353013531135321353313534135351353613537135381353913540135411354213543135441354513546135471354813549135501355113552135531355413555135561355713558135591356013561135621356313564135651356613567135681356913570135711357213573135741357513576135771357813579135801358113582135831358413585135861358713588135891359013591135921359313594135951359613597135981359913600136011360213603136041360513606136071360813609136101361113612136131361413615136161361713618136191362013621136221362313624136251362613627136281362913630136311363213633136341363513636136371363813639136401364113642136431364413645136461364713648136491365013651136521365313654136551365613657136581365913660136611366213663136641366513666136671366813669136701367113672136731367413675136761367713678136791368013681136821368313684136851368613687136881368913690136911369213693136941369513696136971369813699137001370113702137031370413705137061370713708137091371013711137121371313714137151371613717137181371913720137211372213723137241372513726137271372813729137301373113732137331373413735137361373713738137391374013741137421374313744137451374613747137481374913750137511375213753137541375513756137571375813759137601376113762137631376413765137661376713768137691377013771137721377313774137751377613777137781377913780137811378213783137841378513786137871378813789137901379113792137931379413795137961379713798137991380013801138021380313804138051380613807138081380913810138111381213813138141381513816138171381813819138201382113822138231382413825138261382713828138291383013831138321383313834138351383613837138381383913840138411384213843138441384513846138471384813849138501385113852138531385413855138561385713858138591386013861138621386313864138651386613867138681386913870138711387213873138741387513876138771387813879138801388113882138831388413885138861388713888138891389013891138921389313894138951389613897138981389913900139011390213903139041390513906139071390813909139101391113912139131391413915139161391713918139191392013921139221392313924139251392613927139281392913930139311393213933139341393513936139371393813939139401394113942139431394413945139461394713948139491395013951139521395313954139551395613957139581395913960139611396213963139641396513966139671396813969139701397113972139731397413975139761397713978139791398013981139821398313984139851398613987139881398913990139911399213993139941399513996139971399813999140001400114002140031400414005140061400714008140091401014011140121401314014140151401614017140181401914020140211402214023140241402514026140271402814029140301403114032140331403414035140361403714038140391404014041140421404314044140451404614047140481404914050140511405214053140541405514056140571405814059140601406114062140631406414065140661406714068140691407014071140721407314074140751407614077140781407914080140811408214083140841408514086140871408814089140901409114092140931409414095140961409714098140991410014101141021410314104141051410614107141081410914110141111411214113141141411514116141171411814119141201412114122141231412414125141261412714128141291413014131141321413314134141351413614137141381413914140141411414214143141441414514146141471414814149141501415114152141531415414155141561415714158141591416014161141621416314164141651416614167141681416914170141711417214173141741417514176141771417814179141801418114182141831418414185141861418714188141891419014191141921419314194141951419614197141981419914200142011420214203142041420514206142071420814209142101421114212142131421414215142161421714218142191422014221142221422314224142251422614227142281422914230142311423214233142341423514236142371423814239142401424114242142431424414245142461424714248142491425014251142521425314254142551425614257142581425914260142611426214263142641426514266142671426814269142701427114272142731427414275142761427714278142791428014281142821428314284142851428614287142881428914290142911429214293142941429514296142971429814299143001430114302143031430414305143061430714308143091431014311143121431314314143151431614317143181431914320143211432214323143241432514326143271432814329143301433114332143331433414335143361433714338143391434014341143421434314344143451434614347143481434914350143511435214353143541435514356143571435814359143601436114362143631436414365143661436714368143691437014371143721437314374143751437614377143781437914380143811438214383143841438514386143871438814389143901439114392143931439414395143961439714398143991440014401144021440314404144051440614407144081440914410144111441214413144141441514416144171441814419144201442114422144231442414425144261442714428144291443014431144321443314434144351443614437144381443914440144411444214443144441444514446144471444814449144501445114452144531445414455144561445714458144591446014461144621446314464144651446614467144681446914470144711447214473144741447514476144771447814479144801448114482144831448414485144861448714488144891449014491144921449314494144951449614497144981449914500145011450214503145041450514506145071450814509145101451114512145131451414515145161451714518145191452014521145221452314524145251452614527145281452914530145311453214533145341453514536145371453814539145401454114542145431454414545145461454714548145491455014551145521455314554145551455614557145581455914560145611456214563145641456514566145671456814569145701457114572145731457414575145761457714578145791458014581145821458314584145851458614587145881458914590145911459214593145941459514596145971459814599146001460114602146031460414605146061460714608146091461014611146121461314614146151461614617146181461914620146211462214623146241462514626146271462814629146301463114632146331463414635146361463714638146391464014641146421464314644146451464614647146481464914650146511465214653146541465514656146571465814659146601466114662146631466414665146661466714668146691467014671146721467314674146751467614677146781467914680146811468214683146841468514686146871468814689146901469114692146931469414695146961469714698146991470014701147021470314704147051470614707147081470914710147111471214713147141471514716147171471814719147201472114722147231472414725147261472714728147291473014731147321473314734147351473614737147381473914740147411474214743147441474514746147471474814749147501475114752147531475414755147561475714758147591476014761147621476314764147651476614767147681476914770147711477214773147741477514776147771477814779147801478114782147831478414785147861478714788147891479014791147921479314794147951479614797147981479914800148011480214803148041480514806148071480814809148101481114812148131481414815148161481714818148191482014821148221482314824148251482614827148281482914830148311483214833148341483514836148371483814839148401484114842148431484414845148461484714848148491485014851148521485314854148551485614857148581485914860148611486214863148641486514866148671486814869148701487114872148731487414875148761487714878148791488014881148821488314884148851488614887148881488914890148911489214893148941489514896148971489814899149001490114902149031490414905149061490714908149091491014911149121491314914149151491614917149181491914920149211492214923149241492514926149271492814929149301493114932149331493414935149361493714938149391494014941149421494314944149451494614947149481494914950149511495214953149541495514956149571495814959149601496114962149631496414965149661496714968149691497014971149721497314974149751497614977149781497914980149811498214983149841498514986149871498814989149901499114992149931499414995149961499714998149991500015001150021500315004150051500615007150081500915010150111501215013150141501515016150171501815019150201502115022150231502415025150261502715028150291503015031150321503315034150351503615037150381503915040150411504215043150441504515046150471504815049150501505115052150531505415055150561505715058150591506015061150621506315064150651506615067150681506915070150711507215073150741507515076150771507815079150801508115082150831508415085150861508715088150891509015091150921509315094150951509615097150981509915100151011510215103151041510515106151071510815109151101511115112151131511415115151161511715118151191512015121151221512315124151251512615127151281512915130151311513215133151341513515136151371513815139151401514115142151431514415145151461514715148151491515015151151521515315154151551515615157151581515915160151611516215163151641516515166151671516815169151701517115172151731517415175151761517715178151791518015181151821518315184151851518615187151881518915190151911519215193151941519515196151971519815199152001520115202152031520415205152061520715208152091521015211152121521315214152151521615217152181521915220152211522215223152241522515226152271522815229152301523115232152331523415235152361523715238152391524015241152421524315244152451524615247152481524915250152511525215253152541525515256152571525815259152601526115262152631526415265152661526715268152691527015271152721527315274152751527615277152781527915280152811528215283152841528515286152871528815289152901529115292152931529415295152961529715298152991530015301153021530315304153051530615307153081530915310153111531215313153141531515316153171531815319153201532115322153231532415325153261532715328153291533015331153321533315334153351533615337153381533915340153411534215343153441534515346153471534815349153501535115352153531535415355153561535715358153591536015361153621536315364153651536615367153681536915370153711537215373153741537515376153771537815379153801538115382153831538415385153861538715388153891539015391153921539315394153951539615397153981539915400154011540215403154041540515406154071540815409154101541115412154131541415415154161541715418154191542015421154221542315424154251542615427154281542915430154311543215433154341543515436154371543815439154401544115442154431544415445154461544715448154491545015451154521545315454154551545615457154581545915460154611546215463154641546515466154671546815469154701547115472154731547415475154761547715478154791548015481154821548315484154851548615487154881548915490154911549215493154941549515496154971549815499155001550115502155031550415505155061550715508155091551015511155121551315514155151551615517155181551915520155211552215523155241552515526155271552815529155301553115532155331553415535155361553715538155391554015541155421554315544155451554615547155481554915550155511555215553155541555515556155571555815559155601556115562155631556415565155661556715568155691557015571155721557315574155751557615577155781557915580155811558215583155841558515586155871558815589155901559115592155931559415595155961559715598155991560015601156021560315604156051560615607156081560915610156111561215613156141561515616156171561815619156201562115622156231562415625156261562715628156291563015631156321563315634156351563615637156381563915640156411564215643156441564515646156471564815649156501565115652156531565415655156561565715658156591566015661156621566315664156651566615667156681566915670156711567215673156741567515676156771567815679156801568115682156831568415685156861568715688156891569015691156921569315694156951569615697156981569915700157011570215703157041570515706157071570815709157101571115712157131571415715157161571715718157191572015721157221572315724157251572615727157281572915730157311573215733157341573515736157371573815739157401574115742157431574415745157461574715748157491575015751157521575315754157551575615757157581575915760157611576215763157641576515766157671576815769157701577115772157731577415775157761577715778157791578015781157821578315784157851578615787157881578915790157911579215793157941579515796157971579815799158001580115802158031580415805158061580715808158091581015811158121581315814158151581615817158181581915820158211582215823158241582515826158271582815829158301583115832158331583415835158361583715838158391584015841158421584315844158451584615847158481584915850158511585215853158541585515856158571585815859158601586115862158631586415865158661586715868158691587015871158721587315874158751587615877158781587915880158811588215883158841588515886158871588815889158901589115892158931589415895158961589715898158991590015901159021590315904159051590615907159081590915910159111591215913159141591515916159171591815919159201592115922159231592415925159261592715928159291593015931159321593315934159351593615937159381593915940159411594215943159441594515946159471594815949159501595115952159531595415955159561595715958159591596015961159621596315964159651596615967159681596915970159711597215973159741597515976159771597815979159801598115982159831598415985159861598715988159891599015991159921599315994159951599615997159981599916000160011600216003160041600516006160071600816009160101601116012160131601416015160161601716018160191602016021160221602316024160251602616027160281602916030160311603216033160341603516036160371603816039160401604116042160431604416045160461604716048160491605016051160521605316054160551605616057160581605916060160611606216063160641606516066160671606816069160701607116072160731607416075160761607716078160791608016081160821608316084160851608616087160881608916090160911609216093160941609516096160971609816099161001610116102161031610416105161061610716108161091611016111161121611316114161151611616117161181611916120161211612216123161241612516126161271612816129161301613116132161331613416135161361613716138161391614016141161421614316144161451614616147161481614916150161511615216153161541615516156161571615816159161601616116162161631616416165161661616716168161691617016171161721617316174161751617616177161781617916180161811618216183161841618516186161871618816189161901619116192161931619416195161961619716198161991620016201162021620316204162051620616207162081620916210162111621216213162141621516216162171621816219162201622116222162231622416225162261622716228162291623016231162321623316234162351623616237162381623916240162411624216243162441624516246162471624816249162501625116252162531625416255162561625716258162591626016261162621626316264162651626616267162681626916270162711627216273162741627516276162771627816279162801628116282162831628416285162861628716288162891629016291162921629316294162951629616297162981629916300163011630216303163041630516306163071630816309163101631116312163131631416315163161631716318163191632016321163221632316324163251632616327163281632916330163311633216333163341633516336163371633816339163401634116342163431634416345163461634716348163491635016351163521635316354163551635616357163581635916360163611636216363163641636516366163671636816369163701637116372163731637416375163761637716378163791638016381163821638316384163851638616387163881638916390163911639216393163941639516396163971639816399164001640116402164031640416405164061640716408164091641016411164121641316414164151641616417164181641916420164211642216423164241642516426164271642816429164301643116432164331643416435164361643716438164391644016441164421644316444164451644616447164481644916450164511645216453164541645516456164571645816459164601646116462164631646416465164661646716468164691647016471164721647316474164751647616477164781647916480164811648216483164841648516486164871648816489164901649116492164931649416495164961649716498164991650016501165021650316504165051650616507165081650916510165111651216513165141651516516165171651816519165201652116522165231652416525165261652716528165291653016531165321653316534165351653616537165381653916540165411654216543165441654516546165471654816549165501655116552165531655416555165561655716558165591656016561165621656316564165651656616567165681656916570165711657216573165741657516576165771657816579165801658116582165831658416585165861658716588165891659016591165921659316594165951659616597165981659916600166011660216603166041660516606166071660816609166101661116612166131661416615166161661716618166191662016621166221662316624166251662616627166281662916630166311663216633166341663516636166371663816639166401664116642166431664416645166461664716648166491665016651166521665316654166551665616657166581665916660166611666216663166641666516666166671666816669166701667116672166731667416675166761667716678166791668016681166821668316684166851668616687166881668916690166911669216693166941669516696166971669816699167001670116702167031670416705167061670716708167091671016711167121671316714167151671616717167181671916720167211672216723167241672516726167271672816729167301673116732167331673416735167361673716738167391674016741167421674316744167451674616747167481674916750167511675216753167541675516756167571675816759167601676116762167631676416765167661676716768167691677016771167721677316774167751677616777167781677916780167811678216783167841678516786167871678816789167901679116792167931679416795167961679716798167991680016801168021680316804168051680616807168081680916810168111681216813168141681516816168171681816819168201682116822168231682416825168261682716828168291683016831168321683316834168351683616837168381683916840168411684216843168441684516846168471684816849168501685116852168531685416855168561685716858168591686016861168621686316864168651686616867168681686916870168711687216873168741687516876168771687816879168801688116882168831688416885168861688716888168891689016891168921689316894168951689616897168981689916900169011690216903169041690516906169071690816909169101691116912169131691416915169161691716918169191692016921169221692316924169251692616927169281692916930169311693216933169341693516936169371693816939169401694116942169431694416945169461694716948169491695016951169521695316954169551695616957169581695916960169611696216963169641696516966169671696816969169701697116972169731697416975169761697716978169791698016981169821698316984169851698616987169881698916990169911699216993169941699516996169971699816999170001700117002170031700417005170061700717008170091701017011170121701317014170151701617017170181701917020170211702217023170241702517026170271702817029170301703117032170331703417035170361703717038170391704017041170421704317044170451704617047170481704917050170511705217053170541705517056170571705817059170601706117062170631706417065170661706717068170691707017071170721707317074170751707617077170781707917080170811708217083170841708517086170871708817089170901709117092170931709417095170961709717098170991710017101171021710317104171051710617107171081710917110171111711217113171141711517116171171711817119171201712117122171231712417125171261712717128171291713017131171321713317134171351713617137171381713917140171411714217143171441714517146171471714817149171501715117152171531715417155171561715717158171591716017161171621716317164171651716617167171681716917170171711717217173171741717517176171771717817179171801718117182171831718417185171861718717188171891719017191171921719317194171951719617197171981719917200172011720217203172041720517206172071720817209172101721117212172131721417215172161721717218172191722017221172221722317224172251722617227172281722917230172311723217233172341723517236172371723817239172401724117242172431724417245172461724717248172491725017251172521725317254172551725617257172581725917260172611726217263172641726517266172671726817269172701727117272172731727417275172761727717278172791728017281172821728317284172851728617287172881728917290172911729217293172941729517296172971729817299173001730117302173031730417305173061730717308173091731017311173121731317314173151731617317173181731917320173211732217323173241732517326173271732817329173301733117332173331733417335173361733717338173391734017341173421734317344173451734617347173481734917350173511735217353173541735517356173571735817359173601736117362173631736417365173661736717368173691737017371173721737317374173751737617377173781737917380173811738217383173841738517386173871738817389173901739117392173931739417395173961739717398173991740017401174021740317404174051740617407174081740917410174111741217413174141741517416174171741817419174201742117422174231742417425174261742717428174291743017431174321743317434174351743617437174381743917440174411744217443174441744517446174471744817449174501745117452174531745417455174561745717458174591746017461174621746317464174651746617467174681746917470174711747217473174741747517476174771747817479174801748117482174831748417485174861748717488174891749017491174921749317494174951749617497174981749917500175011750217503175041750517506175071750817509175101751117512175131751417515175161751717518175191752017521175221752317524175251752617527175281752917530175311753217533175341753517536175371753817539175401754117542175431754417545175461754717548175491755017551175521755317554175551755617557175581755917560175611756217563175641756517566175671756817569175701757117572175731757417575175761757717578175791758017581175821758317584175851758617587175881758917590175911759217593175941759517596175971759817599176001760117602176031760417605176061760717608176091761017611176121761317614176151761617617176181761917620176211762217623176241762517626176271762817629176301763117632176331763417635176361763717638176391764017641176421764317644176451764617647176481764917650176511765217653176541765517656176571765817659176601766117662176631766417665176661766717668176691767017671176721767317674176751767617677176781767917680176811768217683176841768517686176871768817689176901769117692176931769417695176961769717698176991770017701177021770317704177051770617707177081770917710177111771217713177141771517716177171771817719177201772117722177231772417725177261772717728177291773017731177321773317734177351773617737177381773917740177411774217743177441774517746177471774817749177501775117752177531775417755177561775717758177591776017761177621776317764177651776617767177681776917770177711777217773177741777517776177771777817779177801778117782177831778417785177861778717788177891779017791177921779317794177951779617797177981779917800178011780217803178041780517806178071780817809178101781117812178131781417815178161781717818178191782017821178221782317824178251782617827178281782917830178311783217833178341783517836178371783817839178401784117842178431784417845178461784717848178491785017851178521785317854178551785617857178581785917860178611786217863178641786517866178671786817869178701787117872178731787417875178761787717878178791788017881178821788317884178851788617887178881788917890178911789217893178941789517896178971789817899179001790117902179031790417905179061790717908179091791017911179121791317914179151791617917179181791917920179211792217923179241792517926179271792817929179301793117932179331793417935179361793717938179391794017941179421794317944179451794617947179481794917950179511795217953179541795517956179571795817959179601796117962179631796417965179661796717968179691797017971179721797317974179751797617977179781797917980179811798217983179841798517986179871798817989179901799117992179931799417995179961799717998179991800018001180021800318004180051800618007180081800918010180111801218013180141801518016180171801818019180201802118022180231802418025180261802718028180291803018031180321803318034180351803618037180381803918040180411804218043180441804518046180471804818049180501805118052180531805418055180561805718058180591806018061180621806318064180651806618067180681806918070180711807218073180741807518076180771807818079180801808118082180831808418085180861808718088180891809018091180921809318094180951809618097180981809918100181011810218103181041810518106181071810818109181101811118112181131811418115181161811718118181191812018121181221812318124181251812618127181281812918130181311813218133181341813518136181371813818139181401814118142181431814418145181461814718148181491815018151181521815318154181551815618157181581815918160181611816218163181641816518166181671816818169181701817118172181731817418175181761817718178181791818018181181821818318184181851818618187181881818918190181911819218193181941819518196181971819818199182001820118202182031820418205182061820718208182091821018211182121821318214182151821618217182181821918220182211822218223182241822518226182271822818229182301823118232182331823418235182361823718238182391824018241182421824318244182451824618247182481824918250182511825218253182541825518256182571825818259182601826118262182631826418265182661826718268182691827018271182721827318274182751827618277182781827918280182811828218283182841828518286182871828818289182901829118292182931829418295182961829718298182991830018301183021830318304183051830618307183081830918310183111831218313183141831518316183171831818319183201832118322183231832418325183261832718328183291833018331183321833318334183351833618337183381833918340183411834218343183441834518346183471834818349183501835118352183531835418355183561835718358183591836018361183621836318364183651836618367183681836918370183711837218373183741837518376183771837818379183801838118382183831838418385183861838718388183891839018391183921839318394183951839618397183981839918400184011840218403184041840518406184071840818409184101841118412184131841418415184161841718418184191842018421184221842318424184251842618427184281842918430184311843218433184341843518436184371843818439184401844118442184431844418445184461844718448184491845018451184521845318454184551845618457184581845918460184611846218463184641846518466184671846818469184701847118472184731847418475184761847718478184791848018481184821848318484184851848618487184881848918490184911849218493184941849518496184971849818499185001850118502185031850418505185061850718508185091851018511185121851318514185151851618517185181851918520185211852218523185241852518526185271852818529185301853118532185331853418535185361853718538185391854018541185421854318544185451854618547185481854918550185511855218553185541855518556185571855818559185601856118562185631856418565185661856718568185691857018571185721857318574185751857618577185781857918580185811858218583185841858518586185871858818589185901859118592185931859418595185961859718598185991860018601186021860318604186051860618607186081860918610186111861218613186141861518616186171861818619186201862118622186231862418625186261862718628186291863018631186321863318634186351863618637186381863918640186411864218643186441864518646186471864818649186501865118652186531865418655186561865718658186591866018661186621866318664186651866618667186681866918670186711867218673186741867518676186771867818679186801868118682186831868418685186861868718688186891869018691186921869318694186951869618697186981869918700187011870218703187041870518706187071870818709187101871118712187131871418715187161871718718187191872018721187221872318724187251872618727187281872918730187311873218733187341873518736187371873818739187401874118742187431874418745187461874718748187491875018751187521875318754187551875618757187581875918760187611876218763187641876518766187671876818769187701877118772187731877418775187761877718778187791878018781187821878318784187851878618787187881878918790187911879218793187941879518796187971879818799188001880118802188031880418805188061880718808188091881018811188121881318814188151881618817188181881918820188211882218823188241882518826188271882818829188301883118832188331883418835188361883718838188391884018841188421884318844188451884618847188481884918850188511885218853188541885518856188571885818859188601886118862188631886418865188661886718868188691887018871188721887318874188751887618877188781887918880188811888218883188841888518886188871888818889188901889118892188931889418895188961889718898188991890018901189021890318904189051890618907189081890918910189111891218913189141891518916189171891818919189201892118922189231892418925189261892718928189291893018931189321893318934189351893618937189381893918940189411894218943189441894518946189471894818949189501895118952189531895418955189561895718958189591896018961189621896318964189651896618967189681896918970189711897218973189741897518976189771897818979189801898118982189831898418985189861898718988189891899018991189921899318994189951899618997189981899919000190011900219003190041900519006190071900819009190101901119012190131901419015190161901719018190191902019021190221902319024190251902619027190281902919030190311903219033190341903519036190371903819039190401904119042190431904419045190461904719048190491905019051190521905319054190551905619057190581905919060190611906219063190641906519066190671906819069190701907119072190731907419075190761907719078190791908019081190821908319084190851908619087190881908919090190911909219093190941909519096190971909819099191001910119102191031910419105191061910719108191091911019111191121911319114191151911619117191181911919120191211912219123191241912519126191271912819129191301913119132191331913419135191361913719138191391914019141191421914319144191451914619147191481914919150191511915219153191541915519156191571915819159191601916119162191631916419165191661916719168191691917019171191721917319174191751917619177191781917919180191811918219183191841918519186191871918819189191901919119192191931919419195191961919719198191991920019201192021920319204192051920619207192081920919210192111921219213192141921519216192171921819219192201922119222192231922419225192261922719228192291923019231192321923319234192351923619237192381923919240192411924219243192441924519246192471924819249192501925119252192531925419255192561925719258192591926019261192621926319264192651926619267192681926919270192711927219273192741927519276192771927819279192801928119282192831928419285192861928719288192891929019291192921929319294192951929619297192981929919300193011930219303193041930519306193071930819309193101931119312193131931419315193161931719318193191932019321193221932319324193251932619327193281932919330193311933219333193341933519336193371933819339193401934119342193431934419345193461934719348193491935019351193521935319354193551935619357193581935919360193611936219363193641936519366193671936819369193701937119372193731937419375193761937719378193791938019381193821938319384193851938619387193881938919390193911939219393193941939519396193971939819399194001940119402194031940419405194061940719408194091941019411194121941319414194151941619417194181941919420194211942219423194241942519426194271942819429194301943119432194331943419435194361943719438194391944019441194421944319444194451944619447194481944919450194511945219453194541945519456194571945819459194601946119462194631946419465194661946719468194691947019471194721947319474194751947619477194781947919480194811948219483194841948519486194871948819489194901949119492194931949419495194961949719498194991950019501195021950319504195051950619507195081950919510195111951219513195141951519516195171951819519195201952119522195231952419525195261952719528195291953019531195321953319534195351953619537195381953919540195411954219543195441954519546195471954819549195501955119552195531955419555195561955719558195591956019561195621956319564195651956619567195681956919570195711957219573195741957519576195771957819579195801958119582195831958419585195861958719588195891959019591195921959319594195951959619597195981959919600196011960219603196041960519606196071960819609196101961119612196131961419615196161961719618196191962019621196221962319624196251962619627196281962919630196311963219633196341963519636196371963819639196401964119642196431964419645196461964719648196491965019651196521965319654196551965619657196581965919660196611966219663196641966519666196671966819669196701967119672196731967419675196761967719678196791968019681196821968319684196851968619687196881968919690196911969219693196941969519696196971969819699197001970119702197031970419705197061970719708197091971019711197121971319714197151971619717197181971919720197211972219723197241972519726197271972819729197301973119732197331973419735197361973719738197391974019741197421974319744197451974619747197481974919750197511975219753197541975519756197571975819759197601976119762197631976419765197661976719768197691977019771197721977319774197751977619777197781977919780197811978219783197841978519786197871978819789197901979119792197931979419795197961979719798197991980019801198021980319804198051980619807198081980919810198111981219813198141981519816198171981819819198201982119822198231982419825198261982719828198291983019831198321983319834198351983619837198381983919840198411984219843198441984519846198471984819849198501985119852198531985419855198561985719858198591986019861198621986319864198651986619867198681986919870198711987219873198741987519876198771987819879198801988119882198831988419885198861988719888198891989019891198921989319894198951989619897198981989919900199011990219903199041990519906199071990819909199101991119912199131991419915199161991719918199191992019921199221992319924199251992619927199281992919930199311993219933199341993519936199371993819939199401994119942199431994419945199461994719948199491995019951199521995319954199551995619957199581995919960199611996219963199641996519966199671996819969199701997119972199731997419975199761997719978199791998019981199821998319984199851998619987199881998919990199911999219993199941999519996199971999819999200002000120002200032000420005200062000720008200092001020011200122001320014200152001620017200182001920020200212002220023200242002520026200272002820029200302003120032200332003420035200362003720038200392004020041200422004320044200452004620047200482004920050200512005220053200542005520056200572005820059200602006120062200632006420065200662006720068200692007020071200722007320074200752007620077200782007920080200812008220083200842008520086200872008820089200902009120092200932009420095200962009720098200992010020101201022010320104201052010620107201082010920110201112011220113201142011520116201172011820119201202012120122201232012420125201262012720128201292013020131201322013320134201352013620137201382013920140201412014220143201442014520146201472014820149201502015120152201532015420155201562015720158201592016020161201622016320164201652016620167201682016920170201712017220173201742017520176201772017820179201802018120182201832018420185201862018720188201892019020191201922019320194201952019620197201982019920200202012020220203202042020520206202072020820209202102021120212202132021420215202162021720218202192022020221202222022320224202252022620227202282022920230202312023220233202342023520236202372023820239202402024120242202432024420245202462024720248202492025020251202522025320254202552025620257202582025920260202612026220263202642026520266202672026820269202702027120272202732027420275202762027720278202792028020281202822028320284202852028620287202882028920290202912029220293202942029520296202972029820299203002030120302203032030420305203062030720308203092031020311203122031320314203152031620317203182031920320203212032220323203242032520326203272032820329203302033120332203332033420335203362033720338203392034020341203422034320344203452034620347203482034920350203512035220353203542035520356203572035820359203602036120362203632036420365203662036720368203692037020371203722037320374203752037620377203782037920380203812038220383203842038520386203872038820389203902039120392203932039420395203962039720398203992040020401204022040320404204052040620407204082040920410204112041220413204142041520416204172041820419204202042120422204232042420425204262042720428204292043020431204322043320434204352043620437204382043920440204412044220443204442044520446204472044820449204502045120452204532045420455204562045720458204592046020461204622046320464204652046620467204682046920470204712047220473204742047520476204772047820479204802048120482204832048420485204862048720488204892049020491204922049320494204952049620497204982049920500205012050220503205042050520506205072050820509205102051120512205132051420515205162051720518205192052020521205222052320524205252052620527205282052920530205312053220533205342053520536205372053820539205402054120542205432054420545205462054720548205492055020551205522055320554205552055620557205582055920560205612056220563205642056520566205672056820569205702057120572205732057420575205762057720578205792058020581205822058320584205852058620587205882058920590205912059220593205942059520596205972059820599206002060120602206032060420605206062060720608206092061020611206122061320614206152061620617206182061920620206212062220623206242062520626206272062820629206302063120632206332063420635206362063720638206392064020641206422064320644206452064620647206482064920650206512065220653206542065520656206572065820659206602066120662206632066420665206662066720668206692067020671206722067320674206752067620677206782067920680206812068220683206842068520686206872068820689206902069120692206932069420695206962069720698206992070020701207022070320704207052070620707207082070920710207112071220713207142071520716207172071820719207202072120722207232072420725207262072720728207292073020731207322073320734207352073620737207382073920740207412074220743207442074520746207472074820749207502075120752207532075420755207562075720758207592076020761207622076320764207652076620767207682076920770207712077220773207742077520776207772077820779207802078120782207832078420785207862078720788207892079020791207922079320794207952079620797207982079920800208012080220803208042080520806208072080820809208102081120812208132081420815208162081720818208192082020821208222082320824208252082620827208282082920830208312083220833208342083520836208372083820839208402084120842208432084420845208462084720848208492085020851208522085320854208552085620857208582085920860208612086220863208642086520866208672086820869208702087120872208732087420875208762087720878208792088020881208822088320884208852088620887208882088920890208912089220893208942089520896208972089820899209002090120902209032090420905209062090720908209092091020911209122091320914209152091620917209182091920920209212092220923209242092520926209272092820929209302093120932209332093420935209362093720938209392094020941209422094320944209452094620947209482094920950209512095220953209542095520956209572095820959209602096120962209632096420965209662096720968209692097020971209722097320974209752097620977209782097920980209812098220983209842098520986209872098820989209902099120992209932099420995209962099720998209992100021001210022100321004210052100621007210082100921010210112101221013210142101521016210172101821019210202102121022210232102421025210262102721028210292103021031210322103321034210352103621037210382103921040210412104221043210442104521046210472104821049210502105121052210532105421055210562105721058210592106021061210622106321064210652106621067210682106921070210712107221073210742107521076210772107821079210802108121082210832108421085210862108721088210892109021091210922109321094210952109621097210982109921100211012110221103211042110521106211072110821109211102111121112211132111421115211162111721118211192112021121211222112321124211252112621127211282112921130211312113221133211342113521136211372113821139211402114121142211432114421145211462114721148211492115021151211522115321154211552115621157211582115921160211612116221163211642116521166211672116821169211702117121172211732117421175211762117721178211792118021181211822118321184211852118621187211882118921190211912119221193211942119521196211972119821199212002120121202212032120421205212062120721208212092121021211212122121321214212152121621217212182121921220212212122221223212242122521226212272122821229212302123121232212332123421235212362123721238212392124021241212422124321244212452124621247212482124921250212512125221253212542125521256212572125821259212602126121262212632126421265212662126721268212692127021271212722127321274212752127621277212782127921280212812128221283212842128521286212872128821289212902129121292212932129421295212962129721298212992130021301213022130321304213052130621307213082130921310213112131221313213142131521316213172131821319213202132121322213232132421325213262132721328213292133021331213322133321334213352133621337213382133921340213412134221343213442134521346213472134821349213502135121352213532135421355213562135721358213592136021361213622136321364213652136621367213682136921370213712137221373213742137521376213772137821379213802138121382213832138421385213862138721388213892139021391213922139321394213952139621397213982139921400214012140221403214042140521406214072140821409214102141121412214132141421415214162141721418214192142021421214222142321424214252142621427214282142921430214312143221433214342143521436214372143821439214402144121442214432144421445214462144721448214492145021451214522145321454214552145621457214582145921460214612146221463214642146521466214672146821469214702147121472214732147421475214762147721478214792148021481214822148321484214852148621487214882148921490214912149221493214942149521496214972149821499215002150121502215032150421505215062150721508215092151021511215122151321514215152151621517215182151921520215212152221523215242152521526215272152821529215302153121532215332153421535215362153721538215392154021541215422154321544215452154621547215482154921550215512155221553215542155521556215572155821559215602156121562215632156421565215662156721568215692157021571215722157321574215752157621577215782157921580215812158221583215842158521586215872158821589215902159121592215932159421595215962159721598215992160021601216022160321604216052160621607216082160921610216112161221613216142161521616216172161821619216202162121622216232162421625216262162721628216292163021631216322163321634216352163621637216382163921640216412164221643216442164521646216472164821649216502165121652216532165421655216562165721658216592166021661216622166321664216652166621667216682166921670216712167221673216742167521676216772167821679216802168121682216832168421685216862168721688216892169021691216922169321694216952169621697216982169921700217012170221703217042170521706217072170821709217102171121712217132171421715217162171721718217192172021721217222172321724217252172621727217282172921730217312173221733217342173521736217372173821739217402174121742217432174421745217462174721748217492175021751217522175321754217552175621757217582175921760217612176221763217642176521766217672176821769217702177121772217732177421775217762177721778217792178021781217822178321784217852178621787217882178921790217912179221793217942179521796217972179821799218002180121802218032180421805218062180721808218092181021811218122181321814218152181621817218182181921820218212182221823218242182521826218272182821829218302183121832218332183421835218362183721838218392184021841218422184321844218452184621847218482184921850218512185221853218542185521856218572185821859218602186121862218632186421865218662186721868218692187021871218722187321874218752187621877218782187921880218812188221883218842188521886218872188821889218902189121892218932189421895218962189721898218992190021901219022190321904219052190621907219082190921910219112191221913219142191521916219172191821919219202192121922219232192421925219262192721928219292193021931219322193321934219352193621937219382193921940219412194221943219442194521946219472194821949219502195121952219532195421955219562195721958219592196021961219622196321964219652196621967219682196921970219712197221973219742197521976219772197821979219802198121982219832198421985219862198721988219892199021991219922199321994219952199621997219982199922000220012200222003220042200522006220072200822009220102201122012220132201422015220162201722018220192202022021220222202322024220252202622027220282202922030220312203222033220342203522036220372203822039220402204122042220432204422045220462204722048220492205022051220522205322054220552205622057220582205922060220612206222063220642206522066220672206822069220702207122072220732207422075220762207722078220792208022081220822208322084220852208622087220882208922090220912209222093220942209522096220972209822099221002210122102221032210422105221062210722108221092211022111221122211322114221152211622117221182211922120221212212222123221242212522126221272212822129221302213122132221332213422135221362213722138221392214022141221422214322144221452214622147221482214922150221512215222153221542215522156221572215822159221602216122162221632216422165221662216722168221692217022171221722217322174221752217622177221782217922180221812218222183221842218522186221872218822189221902219122192221932219422195221962219722198221992220022201222022220322204222052220622207222082220922210222112221222213222142221522216222172221822219222202222122222222232222422225222262222722228222292223022231222322223322234222352223622237222382223922240222412224222243222442224522246222472224822249222502225122252222532225422255222562225722258222592226022261222622226322264222652226622267222682226922270222712227222273222742227522276222772227822279222802228122282222832228422285222862228722288222892229022291222922229322294222952229622297222982229922300223012230222303223042230522306223072230822309223102231122312223132231422315223162231722318223192232022321223222232322324223252232622327223282232922330223312233222333223342233522336223372233822339223402234122342223432234422345223462234722348223492235022351223522235322354223552235622357223582235922360223612236222363223642236522366223672236822369223702237122372223732237422375223762237722378223792238022381223822238322384223852238622387223882238922390223912239222393223942239522396223972239822399224002240122402224032240422405224062240722408224092241022411224122241322414224152241622417224182241922420224212242222423224242242522426224272242822429224302243122432224332243422435224362243722438224392244022441224422244322444224452244622447224482244922450224512245222453224542245522456224572245822459224602246122462224632246422465224662246722468224692247022471224722247322474224752247622477224782247922480224812248222483224842248522486224872248822489224902249122492224932249422495224962249722498224992250022501225022250322504225052250622507225082250922510225112251222513225142251522516225172251822519225202252122522225232252422525225262252722528225292253022531225322253322534225352253622537225382253922540225412254222543225442254522546225472254822549225502255122552225532255422555225562255722558225592256022561225622256322564225652256622567225682256922570225712257222573225742257522576225772257822579225802258122582225832258422585225862258722588225892259022591225922259322594225952259622597225982259922600226012260222603226042260522606226072260822609226102261122612226132261422615226162261722618226192262022621226222262322624226252262622627226282262922630226312263222633226342263522636226372263822639226402264122642226432264422645226462264722648226492265022651226522265322654226552265622657226582265922660226612266222663226642266522666226672266822669226702267122672226732267422675226762267722678226792268022681226822268322684226852268622687226882268922690226912269222693226942269522696226972269822699227002270122702227032270422705227062270722708227092271022711227122271322714227152271622717227182271922720227212272222723227242272522726227272272822729227302273122732227332273422735227362273722738227392274022741227422274322744227452274622747227482274922750227512275222753227542275522756227572275822759227602276122762227632276422765227662276722768227692277022771227722277322774227752277622777227782277922780227812278222783227842278522786227872278822789227902279122792227932279422795227962279722798227992280022801228022280322804228052280622807228082280922810228112281222813228142281522816228172281822819228202282122822228232282422825228262282722828228292283022831228322283322834228352283622837228382283922840228412284222843228442284522846228472284822849228502285122852228532285422855228562285722858228592286022861228622286322864228652286622867228682286922870228712287222873228742287522876228772287822879228802288122882228832288422885228862288722888228892289022891228922289322894228952289622897228982289922900229012290222903229042290522906229072290822909229102291122912229132291422915229162291722918229192292022921229222292322924229252292622927229282292922930229312293222933229342293522936229372293822939229402294122942229432294422945229462294722948229492295022951229522295322954229552295622957229582295922960229612296222963229642296522966229672296822969229702297122972229732297422975229762297722978229792298022981229822298322984229852298622987229882298922990229912299222993229942299522996229972299822999230002300123002230032300423005230062300723008230092301023011230122301323014230152301623017230182301923020230212302223023230242302523026230272302823029230302303123032230332303423035230362303723038230392304023041230422304323044230452304623047230482304923050230512305223053230542305523056230572305823059230602306123062230632306423065230662306723068230692307023071230722307323074230752307623077230782307923080230812308223083230842308523086230872308823089230902309123092230932309423095230962309723098230992310023101231022310323104231052310623107231082310923110231112311223113231142311523116231172311823119231202312123122231232312423125231262312723128231292313023131231322313323134231352313623137231382313923140231412314223143231442314523146231472314823149231502315123152231532315423155231562315723158231592316023161231622316323164231652316623167231682316923170231712317223173231742317523176231772317823179231802318123182231832318423185231862318723188231892319023191231922319323194231952319623197231982319923200232012320223203232042320523206232072320823209232102321123212232132321423215232162321723218232192322023221232222322323224232252322623227232282322923230232312323223233232342323523236232372323823239232402324123242232432324423245232462324723248232492325023251232522325323254232552325623257232582325923260232612326223263232642326523266232672326823269232702327123272232732327423275232762327723278232792328023281232822328323284232852328623287232882328923290232912329223293232942329523296232972329823299233002330123302233032330423305233062330723308233092331023311233122331323314233152331623317233182331923320233212332223323233242332523326233272332823329233302333123332233332333423335233362333723338233392334023341233422334323344233452334623347233482334923350233512335223353233542335523356233572335823359233602336123362233632336423365233662336723368233692337023371233722337323374233752337623377233782337923380233812338223383233842338523386233872338823389233902339123392233932339423395233962339723398233992340023401234022340323404234052340623407234082340923410234112341223413234142341523416234172341823419234202342123422234232342423425234262342723428234292343023431234322343323434234352343623437234382343923440234412344223443234442344523446234472344823449234502345123452234532345423455234562345723458234592346023461234622346323464234652346623467234682346923470234712347223473234742347523476234772347823479234802348123482234832348423485234862348723488234892349023491234922349323494234952349623497234982349923500235012350223503235042350523506235072350823509235102351123512235132351423515235162351723518235192352023521235222352323524235252352623527235282352923530235312353223533235342353523536235372353823539235402354123542235432354423545235462354723548235492355023551235522355323554235552355623557235582355923560235612356223563235642356523566235672356823569235702357123572235732357423575235762357723578235792358023581235822358323584235852358623587235882358923590235912359223593235942359523596235972359823599236002360123602236032360423605236062360723608236092361023611236122361323614236152361623617236182361923620236212362223623236242362523626236272362823629236302363123632236332363423635236362363723638236392364023641236422364323644236452364623647236482364923650236512365223653236542365523656236572365823659236602366123662236632366423665236662366723668236692367023671236722367323674236752367623677236782367923680236812368223683236842368523686236872368823689236902369123692236932369423695236962369723698236992370023701237022370323704237052370623707237082370923710237112371223713237142371523716237172371823719237202372123722237232372423725237262372723728237292373023731237322373323734237352373623737237382373923740237412374223743237442374523746237472374823749237502375123752237532375423755237562375723758237592376023761237622376323764237652376623767237682376923770237712377223773237742377523776237772377823779237802378123782237832378423785237862378723788237892379023791237922379323794237952379623797237982379923800238012380223803238042380523806238072380823809238102381123812238132381423815238162381723818238192382023821238222382323824238252382623827238282382923830238312383223833238342383523836238372383823839238402384123842238432384423845238462384723848238492385023851238522385323854238552385623857238582385923860238612386223863238642386523866238672386823869238702387123872238732387423875238762387723878238792388023881238822388323884238852388623887238882388923890238912389223893238942389523896238972389823899239002390123902239032390423905239062390723908239092391023911239122391323914239152391623917239182391923920239212392223923239242392523926239272392823929239302393123932239332393423935239362393723938239392394023941239422394323944239452394623947239482394923950239512395223953239542395523956239572395823959239602396123962239632396423965239662396723968239692397023971239722397323974239752397623977239782397923980239812398223983239842398523986239872398823989239902399123992239932399423995239962399723998239992400024001240022400324004240052400624007240082400924010240112401224013240142401524016240172401824019240202402124022240232402424025240262402724028240292403024031240322403324034240352403624037240382403924040240412404224043240442404524046240472404824049240502405124052240532405424055240562405724058240592406024061240622406324064240652406624067240682406924070240712407224073240742407524076240772407824079240802408124082240832408424085240862408724088240892409024091240922409324094240952409624097240982409924100241012410224103241042410524106241072410824109241102411124112241132411424115241162411724118241192412024121241222412324124241252412624127241282412924130241312413224133241342413524136241372413824139241402414124142241432414424145241462414724148241492415024151241522415324154241552415624157241582415924160241612416224163241642416524166241672416824169241702417124172241732417424175241762417724178241792418024181241822418324184241852418624187241882418924190241912419224193241942419524196241972419824199242002420124202242032420424205242062420724208242092421024211242122421324214242152421624217242182421924220242212422224223242242422524226242272422824229242302423124232242332423424235242362423724238242392424024241242422424324244242452424624247242482424924250242512425224253242542425524256242572425824259242602426124262242632426424265242662426724268242692427024271242722427324274242752427624277242782427924280242812428224283242842428524286242872428824289242902429124292242932429424295242962429724298242992430024301243022430324304243052430624307243082430924310243112431224313243142431524316243172431824319243202432124322243232432424325243262432724328243292433024331243322433324334243352433624337243382433924340243412434224343243442434524346243472434824349243502435124352243532435424355243562435724358243592436024361243622436324364243652436624367243682436924370243712437224373243742437524376243772437824379243802438124382243832438424385243862438724388243892439024391243922439324394243952439624397243982439924400244012440224403244042440524406244072440824409244102441124412244132441424415244162441724418244192442024421244222442324424244252442624427244282442924430244312443224433244342443524436244372443824439244402444124442244432444424445244462444724448244492445024451244522445324454244552445624457244582445924460244612446224463244642446524466244672446824469244702447124472244732447424475244762447724478244792448024481244822448324484244852448624487244882448924490244912449224493244942449524496244972449824499245002450124502245032450424505245062450724508245092451024511245122451324514245152451624517245182451924520245212452224523245242452524526245272452824529245302453124532245332453424535245362453724538245392454024541245422454324544245452454624547245482454924550245512455224553245542455524556245572455824559245602456124562245632456424565245662456724568245692457024571245722457324574245752457624577245782457924580245812458224583245842458524586245872458824589245902459124592245932459424595245962459724598245992460024601246022460324604246052460624607246082460924610246112461224613246142461524616246172461824619246202462124622246232462424625246262462724628246292463024631246322463324634246352463624637246382463924640246412464224643246442464524646246472464824649246502465124652246532465424655246562465724658246592466024661246622466324664246652466624667246682466924670246712467224673246742467524676246772467824679246802468124682246832468424685246862468724688246892469024691246922469324694246952469624697246982469924700247012470224703247042470524706247072470824709247102471124712247132471424715247162471724718247192472024721247222472324724247252472624727247282472924730247312473224733247342473524736247372473824739247402474124742247432474424745247462474724748247492475024751247522475324754247552475624757247582475924760247612476224763247642476524766247672476824769247702477124772247732477424775247762477724778247792478024781247822478324784247852478624787247882478924790247912479224793247942479524796247972479824799248002480124802248032480424805248062480724808248092481024811248122481324814248152481624817248182481924820248212482224823248242482524826248272482824829248302483124832248332483424835248362483724838248392484024841248422484324844248452484624847248482484924850248512485224853248542485524856248572485824859248602486124862248632486424865248662486724868248692487024871248722487324874248752487624877248782487924880248812488224883248842488524886248872488824889248902489124892248932489424895248962489724898248992490024901249022490324904249052490624907249082490924910249112491224913249142491524916249172491824919249202492124922249232492424925249262492724928249292493024931249322493324934249352493624937249382493924940249412494224943249442494524946249472494824949249502495124952249532495424955249562495724958249592496024961249622496324964249652496624967249682496924970249712497224973249742497524976249772497824979249802498124982249832498424985249862498724988249892499024991249922499324994249952499624997249982499925000250012500225003250042500525006250072500825009250102501125012250132501425015250162501725018250192502025021250222502325024250252502625027250282502925030250312503225033250342503525036250372503825039250402504125042250432504425045250462504725048250492505025051250522505325054250552505625057250582505925060250612506225063250642506525066250672506825069250702507125072250732507425075250762507725078250792508025081250822508325084250852508625087250882508925090250912509225093250942509525096250972509825099251002510125102251032510425105251062510725108251092511025111251122511325114251152511625117251182511925120251212512225123251242512525126251272512825129251302513125132251332513425135251362513725138251392514025141251422514325144251452514625147251482514925150251512515225153251542515525156251572515825159251602516125162251632516425165251662516725168251692517025171251722517325174251752517625177251782517925180251812518225183251842518525186251872518825189251902519125192251932519425195251962519725198251992520025201252022520325204252052520625207252082520925210252112521225213252142521525216252172521825219252202522125222252232522425225252262522725228252292523025231252322523325234252352523625237252382523925240252412524225243252442524525246252472524825249252502525125252252532525425255252562525725258252592526025261252622526325264252652526625267252682526925270252712527225273252742527525276252772527825279252802528125282252832528425285252862528725288252892529025291252922529325294252952529625297252982529925300253012530225303253042530525306253072530825309253102531125312253132531425315253162531725318253192532025321253222532325324253252532625327253282532925330253312533225333253342533525336253372533825339253402534125342253432534425345253462534725348253492535025351253522535325354253552535625357253582535925360253612536225363253642536525366253672536825369253702537125372253732537425375253762537725378253792538025381253822538325384253852538625387253882538925390253912539225393253942539525396253972539825399254002540125402254032540425405254062540725408254092541025411254122541325414254152541625417254182541925420254212542225423254242542525426254272542825429254302543125432254332543425435254362543725438254392544025441254422544325444254452544625447254482544925450254512545225453254542545525456254572545825459254602546125462254632546425465254662546725468254692547025471254722547325474254752547625477254782547925480254812548225483254842548525486254872548825489254902549125492254932549425495254962549725498254992550025501255022550325504255052550625507255082550925510255112551225513255142551525516255172551825519255202552125522255232552425525255262552725528255292553025531255322553325534255352553625537255382553925540255412554225543255442554525546255472554825549255502555125552255532555425555255562555725558255592556025561255622556325564255652556625567255682556925570255712557225573255742557525576255772557825579255802558125582255832558425585255862558725588255892559025591255922559325594255952559625597255982559925600256012560225603256042560525606256072560825609256102561125612256132561425615256162561725618256192562025621256222562325624256252562625627256282562925630256312563225633256342563525636256372563825639256402564125642256432564425645256462564725648256492565025651256522565325654256552565625657256582565925660256612566225663256642566525666256672566825669256702567125672256732567425675256762567725678256792568025681256822568325684256852568625687256882568925690256912569225693256942569525696256972569825699257002570125702257032570425705257062570725708257092571025711257122571325714257152571625717257182571925720257212572225723257242572525726257272572825729257302573125732257332573425735257362573725738257392574025741257422574325744257452574625747257482574925750257512575225753257542575525756257572575825759257602576125762257632576425765257662576725768257692577025771257722577325774257752577625777257782577925780257812578225783257842578525786257872578825789257902579125792257932579425795257962579725798257992580025801258022580325804258052580625807258082580925810258112581225813258142581525816258172581825819258202582125822258232582425825258262582725828258292583025831258322583325834258352583625837258382583925840258412584225843258442584525846258472584825849258502585125852258532585425855258562585725858258592586025861258622586325864258652586625867258682586925870258712587225873258742587525876258772587825879258802588125882258832588425885258862588725888258892589025891258922589325894258952589625897258982589925900259012590225903259042590525906259072590825909259102591125912259132591425915259162591725918259192592025921259222592325924259252592625927259282592925930259312593225933259342593525936259372593825939259402594125942259432594425945259462594725948259492595025951259522595325954259552595625957259582595925960259612596225963259642596525966259672596825969259702597125972259732597425975259762597725978259792598025981259822598325984259852598625987259882598925990259912599225993259942599525996259972599825999260002600126002260032600426005260062600726008260092601026011260122601326014260152601626017260182601926020260212602226023260242602526026260272602826029260302603126032260332603426035260362603726038260392604026041260422604326044260452604626047260482604926050260512605226053260542605526056260572605826059260602606126062260632606426065260662606726068260692607026071260722607326074260752607626077260782607926080260812608226083260842608526086260872608826089260902609126092260932609426095260962609726098260992610026101261022610326104261052610626107261082610926110261112611226113261142611526116261172611826119261202612126122261232612426125261262612726128261292613026131261322613326134261352613626137261382613926140261412614226143261442614526146261472614826149261502615126152261532615426155261562615726158261592616026161261622616326164261652616626167261682616926170261712617226173261742617526176261772617826179261802618126182261832618426185261862618726188261892619026191261922619326194261952619626197261982619926200262012620226203262042620526206262072620826209262102621126212262132621426215262162621726218262192622026221262222622326224262252622626227262282622926230262312623226233262342623526236262372623826239262402624126242262432624426245262462624726248262492625026251262522625326254262552625626257262582625926260262612626226263262642626526266262672626826269262702627126272262732627426275262762627726278262792628026281262822628326284262852628626287262882628926290262912629226293262942629526296262972629826299263002630126302263032630426305263062630726308263092631026311263122631326314263152631626317263182631926320263212632226323263242632526326263272632826329263302633126332263332633426335263362633726338263392634026341263422634326344263452634626347263482634926350263512635226353263542635526356263572635826359263602636126362263632636426365263662636726368263692637026371263722637326374263752637626377263782637926380263812638226383263842638526386263872638826389263902639126392263932639426395263962639726398263992640026401264022640326404264052640626407264082640926410264112641226413264142641526416264172641826419264202642126422264232642426425264262642726428264292643026431264322643326434264352643626437264382643926440264412644226443264442644526446264472644826449264502645126452264532645426455264562645726458264592646026461264622646326464264652646626467264682646926470264712647226473264742647526476264772647826479264802648126482264832648426485264862648726488264892649026491264922649326494264952649626497264982649926500265012650226503265042650526506265072650826509265102651126512265132651426515265162651726518265192652026521265222652326524265252652626527265282652926530265312653226533265342653526536265372653826539265402654126542265432654426545265462654726548265492655026551265522655326554265552655626557265582655926560265612656226563265642656526566265672656826569265702657126572265732657426575265762657726578265792658026581265822658326584265852658626587265882658926590265912659226593265942659526596265972659826599266002660126602266032660426605266062660726608266092661026611266122661326614266152661626617266182661926620266212662226623266242662526626266272662826629266302663126632266332663426635266362663726638266392664026641266422664326644266452664626647266482664926650266512665226653266542665526656266572665826659266602666126662266632666426665266662666726668266692667026671266722667326674266752667626677266782667926680266812668226683266842668526686266872668826689266902669126692266932669426695266962669726698266992670026701267022670326704267052670626707267082670926710267112671226713267142671526716267172671826719267202672126722267232672426725267262672726728267292673026731267322673326734267352673626737267382673926740267412674226743267442674526746267472674826749267502675126752267532675426755267562675726758267592676026761267622676326764267652676626767267682676926770267712677226773267742677526776267772677826779267802678126782267832678426785267862678726788267892679026791267922679326794267952679626797267982679926800268012680226803268042680526806268072680826809268102681126812268132681426815268162681726818268192682026821268222682326824268252682626827268282682926830268312683226833268342683526836268372683826839268402684126842268432684426845268462684726848268492685026851268522685326854268552685626857268582685926860268612686226863268642686526866268672686826869268702687126872268732687426875268762687726878268792688026881268822688326884268852688626887268882688926890268912689226893268942689526896268972689826899269002690126902269032690426905269062690726908269092691026911269122691326914269152691626917269182691926920269212692226923269242692526926269272692826929269302693126932269332693426935269362693726938269392694026941269422694326944269452694626947269482694926950269512695226953269542695526956269572695826959269602696126962269632696426965269662696726968269692697026971269722697326974269752697626977269782697926980269812698226983269842698526986269872698826989269902699126992269932699426995269962699726998269992700027001270022700327004270052700627007270082700927010270112701227013270142701527016270172701827019270202702127022270232702427025270262702727028270292703027031270322703327034270352703627037270382703927040270412704227043270442704527046270472704827049270502705127052270532705427055270562705727058270592706027061270622706327064270652706627067270682706927070270712707227073270742707527076270772707827079270802708127082270832708427085270862708727088270892709027091270922709327094270952709627097270982709927100271012710227103271042710527106271072710827109271102711127112271132711427115271162711727118271192712027121271222712327124271252712627127271282712927130271312713227133271342713527136271372713827139271402714127142271432714427145271462714727148271492715027151271522715327154271552715627157271582715927160271612716227163271642716527166271672716827169271702717127172271732717427175271762717727178271792718027181271822718327184271852718627187271882718927190271912719227193271942719527196271972719827199272002720127202272032720427205272062720727208272092721027211272122721327214272152721627217272182721927220272212722227223272242722527226272272722827229272302723127232272332723427235272362723727238272392724027241272422724327244272452724627247272482724927250272512725227253272542725527256272572725827259272602726127262272632726427265272662726727268272692727027271272722727327274272752727627277272782727927280272812728227283272842728527286272872728827289272902729127292272932729427295272962729727298272992730027301273022730327304273052730627307273082730927310273112731227313273142731527316273172731827319273202732127322273232732427325273262732727328273292733027331273322733327334273352733627337273382733927340273412734227343273442734527346273472734827349273502735127352273532735427355273562735727358273592736027361273622736327364273652736627367273682736927370273712737227373273742737527376273772737827379273802738127382273832738427385273862738727388273892739027391273922739327394273952739627397273982739927400274012740227403274042740527406274072740827409274102741127412274132741427415274162741727418274192742027421274222742327424274252742627427274282742927430274312743227433274342743527436274372743827439274402744127442274432744427445274462744727448274492745027451274522745327454274552745627457274582745927460274612746227463274642746527466274672746827469274702747127472274732747427475274762747727478274792748027481274822748327484274852748627487274882748927490274912749227493274942749527496274972749827499275002750127502275032750427505275062750727508275092751027511275122751327514275152751627517275182751927520275212752227523275242752527526275272752827529275302753127532275332753427535275362753727538275392754027541275422754327544275452754627547275482754927550275512755227553275542755527556275572755827559275602756127562275632756427565275662756727568275692757027571275722757327574275752757627577275782757927580275812758227583275842758527586275872758827589275902759127592275932759427595275962759727598275992760027601276022760327604276052760627607276082760927610276112761227613276142761527616276172761827619276202762127622276232762427625276262762727628276292763027631276322763327634276352763627637276382763927640276412764227643276442764527646276472764827649276502765127652276532765427655276562765727658276592766027661276622766327664276652766627667276682766927670276712767227673276742767527676276772767827679276802768127682276832768427685276862768727688276892769027691276922769327694276952769627697276982769927700277012770227703277042770527706277072770827709277102771127712277132771427715277162771727718277192772027721277222772327724277252772627727277282772927730277312773227733277342773527736277372773827739277402774127742277432774427745277462774727748277492775027751277522775327754277552775627757277582775927760277612776227763277642776527766277672776827769277702777127772277732777427775277762777727778277792778027781277822778327784277852778627787277882778927790277912779227793277942779527796277972779827799278002780127802278032780427805278062780727808278092781027811278122781327814278152781627817278182781927820278212782227823278242782527826278272782827829278302783127832278332783427835278362783727838278392784027841278422784327844278452784627847278482784927850278512785227853278542785527856278572785827859278602786127862278632786427865278662786727868278692787027871278722787327874278752787627877278782787927880278812788227883278842788527886278872788827889278902789127892278932789427895278962789727898278992790027901279022790327904279052790627907279082790927910279112791227913279142791527916279172791827919279202792127922279232792427925279262792727928279292793027931279322793327934279352793627937279382793927940279412794227943279442794527946279472794827949279502795127952279532795427955279562795727958279592796027961279622796327964279652796627967279682796927970279712797227973279742797527976279772797827979279802798127982279832798427985279862798727988279892799027991279922799327994279952799627997279982799928000280012800228003280042800528006280072800828009280102801128012280132801428015280162801728018280192802028021280222802328024280252802628027280282802928030280312803228033280342803528036280372803828039280402804128042280432804428045280462804728048280492805028051280522805328054280552805628057280582805928060280612806228063280642806528066280672806828069280702807128072280732807428075280762807728078280792808028081280822808328084280852808628087280882808928090280912809228093280942809528096280972809828099281002810128102281032810428105281062810728108281092811028111281122811328114281152811628117281182811928120281212812228123281242812528126281272812828129281302813128132281332813428135281362813728138281392814028141281422814328144281452814628147281482814928150281512815228153281542815528156281572815828159281602816128162281632816428165281662816728168281692817028171281722817328174281752817628177281782817928180281812818228183281842818528186281872818828189281902819128192281932819428195281962819728198281992820028201282022820328204282052820628207282082820928210282112821228213282142821528216282172821828219282202822128222282232822428225282262822728228282292823028231282322823328234282352823628237282382823928240282412824228243282442824528246282472824828249282502825128252282532825428255282562825728258282592826028261282622826328264282652826628267282682826928270282712827228273282742827528276282772827828279282802828128282282832828428285282862828728288282892829028291282922829328294282952829628297282982829928300283012830228303283042830528306283072830828309283102831128312283132831428315283162831728318283192832028321283222832328324283252832628327283282832928330283312833228333283342833528336283372833828339283402834128342283432834428345283462834728348283492835028351283522835328354283552835628357283582835928360283612836228363283642836528366283672836828369283702837128372283732837428375283762837728378283792838028381283822838328384283852838628387283882838928390283912839228393283942839528396283972839828399284002840128402284032840428405284062840728408284092841028411284122841328414284152841628417284182841928420284212842228423284242842528426284272842828429284302843128432284332843428435284362843728438284392844028441284422844328444284452844628447284482844928450284512845228453284542845528456284572845828459284602846128462284632846428465284662846728468284692847028471284722847328474284752847628477284782847928480284812848228483284842848528486284872848828489284902849128492284932849428495284962849728498284992850028501285022850328504285052850628507285082850928510285112851228513285142851528516285172851828519285202852128522285232852428525285262852728528285292853028531285322853328534285352853628537285382853928540285412854228543285442854528546285472854828549285502855128552285532855428555285562855728558285592856028561285622856328564285652856628567285682856928570285712857228573285742857528576285772857828579285802858128582285832858428585285862858728588285892859028591285922859328594285952859628597285982859928600286012860228603286042860528606286072860828609286102861128612286132861428615286162861728618286192862028621286222862328624286252862628627286282862928630286312863228633286342863528636286372863828639286402864128642286432864428645286462864728648286492865028651286522865328654286552865628657286582865928660286612866228663286642866528666286672866828669286702867128672286732867428675286762867728678286792868028681286822868328684286852868628687286882868928690286912869228693286942869528696286972869828699287002870128702287032870428705287062870728708287092871028711287122871328714287152871628717287182871928720287212872228723287242872528726287272872828729287302873128732287332873428735287362873728738287392874028741287422874328744287452874628747287482874928750287512875228753287542875528756287572875828759287602876128762287632876428765287662876728768287692877028771287722877328774287752877628777287782877928780287812878228783287842878528786287872878828789287902879128792287932879428795287962879728798287992880028801288022880328804288052880628807288082880928810288112881228813288142881528816288172881828819288202882128822288232882428825288262882728828288292883028831288322883328834288352883628837288382883928840288412884228843288442884528846288472884828849288502885128852288532885428855288562885728858288592886028861288622886328864288652886628867288682886928870288712887228873288742887528876288772887828879288802888128882288832888428885288862888728888288892889028891288922889328894288952889628897288982889928900289012890228903289042890528906289072890828909289102891128912289132891428915289162891728918289192892028921289222892328924289252892628927289282892928930289312893228933289342893528936289372893828939289402894128942289432894428945289462894728948289492895028951289522895328954289552895628957289582895928960289612896228963289642896528966289672896828969289702897128972289732897428975289762897728978289792898028981289822898328984289852898628987289882898928990289912899228993289942899528996289972899828999290002900129002290032900429005290062900729008290092901029011290122901329014290152901629017290182901929020290212902229023290242902529026290272902829029290302903129032290332903429035290362903729038290392904029041290422904329044290452904629047290482904929050290512905229053290542905529056290572905829059290602906129062290632906429065290662906729068290692907029071290722907329074290752907629077290782907929080290812908229083290842908529086290872908829089290902909129092290932909429095290962909729098290992910029101291022910329104291052910629107291082910929110291112911229113291142911529116291172911829119291202912129122291232912429125291262912729128291292913029131291322913329134291352913629137291382913929140291412914229143291442914529146291472914829149291502915129152291532915429155291562915729158291592916029161291622916329164291652916629167291682916929170291712917229173291742917529176291772917829179291802918129182291832918429185291862918729188291892919029191291922919329194291952919629197291982919929200292012920229203292042920529206292072920829209292102921129212292132921429215292162921729218292192922029221292222922329224292252922629227292282922929230292312923229233292342923529236292372923829239292402924129242292432924429245292462924729248292492925029251292522925329254292552925629257292582925929260292612926229263292642926529266292672926829269292702927129272292732927429275292762927729278292792928029281292822928329284292852928629287292882928929290292912929229293292942929529296292972929829299293002930129302293032930429305293062930729308293092931029311293122931329314293152931629317293182931929320293212932229323293242932529326293272932829329293302933129332293332933429335293362933729338293392934029341293422934329344293452934629347293482934929350293512935229353293542935529356293572935829359293602936129362293632936429365293662936729368293692937029371293722937329374293752937629377293782937929380293812938229383293842938529386293872938829389293902939129392293932939429395293962939729398293992940029401294022940329404294052940629407294082940929410294112941229413294142941529416294172941829419294202942129422294232942429425294262942729428294292943029431294322943329434294352943629437294382943929440294412944229443294442944529446294472944829449294502945129452294532945429455294562945729458294592946029461294622946329464294652946629467294682946929470294712947229473294742947529476294772947829479294802948129482294832948429485294862948729488294892949029491294922949329494294952949629497294982949929500295012950229503295042950529506295072950829509295102951129512295132951429515295162951729518295192952029521295222952329524295252952629527295282952929530295312953229533295342953529536295372953829539295402954129542295432954429545295462954729548295492955029551295522955329554295552955629557295582955929560295612956229563295642956529566295672956829569295702957129572295732957429575295762957729578295792958029581295822958329584295852958629587295882958929590295912959229593295942959529596295972959829599296002960129602296032960429605296062960729608296092961029611296122961329614296152961629617296182961929620296212962229623296242962529626296272962829629296302963129632296332963429635296362963729638296392964029641296422964329644296452964629647296482964929650296512965229653296542965529656296572965829659296602966129662296632966429665296662966729668296692967029671296722967329674296752967629677296782967929680296812968229683296842968529686296872968829689296902969129692296932969429695296962969729698296992970029701297022970329704297052970629707297082970929710297112971229713297142971529716297172971829719297202972129722297232972429725297262972729728297292973029731297322973329734297352973629737297382973929740297412974229743297442974529746297472974829749297502975129752297532975429755297562975729758297592976029761297622976329764297652976629767297682976929770297712977229773297742977529776297772977829779297802978129782297832978429785297862978729788297892979029791297922979329794297952979629797297982979929800298012980229803298042980529806298072980829809298102981129812298132981429815298162981729818298192982029821298222982329824298252982629827298282982929830298312983229833298342983529836298372983829839298402984129842298432984429845298462984729848298492985029851298522985329854298552985629857298582985929860298612986229863298642986529866298672986829869298702987129872298732987429875298762987729878298792988029881298822988329884298852988629887298882988929890298912989229893298942989529896298972989829899299002990129902299032990429905299062990729908299092991029911299122991329914299152991629917299182991929920299212992229923299242992529926299272992829929299302993129932299332993429935299362993729938299392994029941299422994329944299452994629947299482994929950299512995229953299542995529956299572995829959299602996129962299632996429965299662996729968299692997029971299722997329974299752997629977299782997929980299812998229983299842998529986299872998829989299902999129992299932999429995299962999729998299993000030001300023000330004300053000630007300083000930010300113001230013300143001530016300173001830019300203002130022300233002430025300263002730028300293003030031300323003330034300353003630037300383003930040300413004230043300443004530046300473004830049300503005130052300533005430055300563005730058300593006030061300623006330064300653006630067300683006930070300713007230073300743007530076300773007830079300803008130082300833008430085300863008730088300893009030091300923009330094300953009630097300983009930100301013010230103301043010530106301073010830109301103011130112301133011430115301163011730118301193012030121301223012330124301253012630127301283012930130301313013230133301343013530136301373013830139301403014130142301433014430145301463014730148301493015030151301523015330154301553015630157301583015930160301613016230163301643016530166301673016830169301703017130172301733017430175301763017730178301793018030181301823018330184301853018630187301883018930190301913019230193301943019530196301973019830199302003020130202302033020430205302063020730208302093021030211302123021330214302153021630217302183021930220302213022230223302243022530226302273022830229302303023130232302333023430235302363023730238302393024030241302423024330244302453024630247302483024930250302513025230253302543025530256302573025830259302603026130262302633026430265302663026730268302693027030271302723027330274302753027630277302783027930280302813028230283302843028530286302873028830289302903029130292302933029430295302963029730298302993030030301303023030330304303053030630307303083030930310303113031230313303143031530316303173031830319303203032130322303233032430325303263032730328303293033030331303323033330334303353033630337303383033930340303413034230343303443034530346303473034830349303503035130352303533035430355303563035730358303593036030361303623036330364303653036630367303683036930370303713037230373303743037530376303773037830379303803038130382303833038430385303863038730388303893039030391303923039330394303953039630397303983039930400304013040230403304043040530406304073040830409304103041130412304133041430415304163041730418304193042030421304223042330424304253042630427304283042930430304313043230433304343043530436304373043830439304403044130442304433044430445304463044730448304493045030451304523045330454304553045630457304583045930460304613046230463304643046530466304673046830469304703047130472304733047430475304763047730478304793048030481304823048330484304853048630487304883048930490304913049230493304943049530496304973049830499305003050130502305033050430505305063050730508305093051030511305123051330514305153051630517305183051930520305213052230523305243052530526305273052830529305303053130532305333053430535305363053730538305393054030541305423054330544305453054630547305483054930550305513055230553305543055530556305573055830559305603056130562305633056430565305663056730568305693057030571305723057330574305753057630577305783057930580305813058230583305843058530586305873058830589305903059130592305933059430595305963059730598305993060030601306023060330604306053060630607306083060930610306113061230613306143061530616306173061830619306203062130622306233062430625306263062730628306293063030631306323063330634306353063630637306383063930640306413064230643306443064530646306473064830649306503065130652306533065430655306563065730658306593066030661306623066330664306653066630667306683066930670306713067230673306743067530676306773067830679306803068130682306833068430685306863068730688306893069030691306923069330694306953069630697306983069930700307013070230703307043070530706307073070830709307103071130712307133071430715307163071730718307193072030721307223072330724307253072630727307283072930730307313073230733307343073530736307373073830739307403074130742307433074430745307463074730748307493075030751307523075330754307553075630757307583075930760307613076230763307643076530766307673076830769307703077130772307733077430775307763077730778307793078030781307823078330784307853078630787307883078930790307913079230793307943079530796307973079830799308003080130802308033080430805308063080730808308093081030811308123081330814308153081630817308183081930820308213082230823308243082530826308273082830829308303083130832308333083430835308363083730838308393084030841308423084330844308453084630847308483084930850308513085230853308543085530856308573085830859308603086130862308633086430865308663086730868308693087030871308723087330874308753087630877308783087930880308813088230883308843088530886308873088830889308903089130892308933089430895308963089730898308993090030901309023090330904309053090630907309083090930910309113091230913309143091530916309173091830919309203092130922309233092430925309263092730928309293093030931309323093330934309353093630937309383093930940309413094230943309443094530946309473094830949309503095130952309533095430955309563095730958309593096030961309623096330964309653096630967309683096930970309713097230973309743097530976309773097830979309803098130982309833098430985309863098730988309893099030991309923099330994309953099630997309983099931000310013100231003310043100531006310073100831009310103101131012310133101431015310163101731018310193102031021310223102331024310253102631027310283102931030310313103231033310343103531036310373103831039310403104131042310433104431045310463104731048310493105031051310523105331054310553105631057310583105931060310613106231063310643106531066310673106831069310703107131072310733107431075310763107731078310793108031081310823108331084310853108631087310883108931090310913109231093310943109531096310973109831099311003110131102311033110431105311063110731108311093111031111311123111331114311153111631117311183111931120311213112231123311243112531126311273112831129311303113131132311333113431135311363113731138311393114031141311423114331144311453114631147311483114931150311513115231153311543115531156311573115831159311603116131162311633116431165311663116731168311693117031171311723117331174311753117631177311783117931180311813118231183311843118531186311873118831189311903119131192311933119431195311963119731198311993120031201312023120331204312053120631207312083120931210312113121231213312143121531216312173121831219312203122131222312233122431225312263122731228312293123031231312323123331234312353123631237312383123931240312413124231243312443124531246312473124831249312503125131252312533125431255312563125731258312593126031261312623126331264312653126631267312683126931270312713127231273312743127531276312773127831279312803128131282312833128431285312863128731288312893129031291312923129331294312953129631297312983129931300313013130231303313043130531306313073130831309313103131131312313133131431315313163131731318313193132031321313223132331324313253132631327313283132931330313313133231333313343133531336313373133831339313403134131342313433134431345313463134731348313493135031351313523135331354313553135631357313583135931360313613136231363313643136531366313673136831369313703137131372313733137431375313763137731378313793138031381313823138331384313853138631387313883138931390313913139231393313943139531396313973139831399314003140131402314033140431405314063140731408314093141031411314123141331414314153141631417314183141931420314213142231423314243142531426314273142831429314303143131432314333143431435314363143731438314393144031441314423144331444314453144631447314483144931450314513145231453314543145531456314573145831459314603146131462314633146431465314663146731468314693147031471314723147331474314753147631477314783147931480314813148231483314843148531486314873148831489314903149131492314933149431495314963149731498314993150031501315023150331504315053150631507315083150931510315113151231513315143151531516315173151831519315203152131522315233152431525315263152731528315293153031531315323153331534315353153631537315383153931540315413154231543315443154531546315473154831549315503155131552315533155431555315563155731558315593156031561315623156331564315653156631567315683156931570315713157231573315743157531576315773157831579315803158131582315833158431585315863158731588315893159031591315923159331594315953159631597315983159931600316013160231603316043160531606316073160831609316103161131612316133161431615316163161731618316193162031621316223162331624316253162631627316283162931630316313163231633316343163531636316373163831639316403164131642316433164431645316463164731648316493165031651316523165331654316553165631657316583165931660316613166231663316643166531666316673166831669316703167131672316733167431675316763167731678316793168031681316823168331684316853168631687316883168931690316913169231693316943169531696316973169831699317003170131702317033170431705317063170731708317093171031711317123171331714317153171631717317183171931720317213172231723317243172531726317273172831729317303173131732317333173431735317363173731738317393174031741317423174331744317453174631747317483174931750317513175231753317543175531756317573175831759317603176131762317633176431765317663176731768317693177031771317723177331774317753177631777317783177931780317813178231783317843178531786317873178831789317903179131792317933179431795317963179731798317993180031801318023180331804318053180631807318083180931810318113181231813318143181531816318173181831819318203182131822318233182431825318263182731828318293183031831318323183331834318353183631837318383183931840318413184231843318443184531846318473184831849318503185131852318533185431855318563185731858318593186031861318623186331864318653186631867318683186931870318713187231873318743187531876318773187831879318803188131882318833188431885318863188731888318893189031891318923189331894318953189631897318983189931900319013190231903319043190531906319073190831909319103191131912319133191431915319163191731918319193192031921319223192331924319253192631927319283192931930319313193231933319343193531936319373193831939319403194131942319433194431945319463194731948319493195031951319523195331954319553195631957319583195931960319613196231963319643196531966319673196831969319703197131972319733197431975319763197731978319793198031981319823198331984319853198631987319883198931990319913199231993319943199531996319973199831999320003200132002320033200432005320063200732008320093201032011320123201332014320153201632017320183201932020320213202232023320243202532026320273202832029320303203132032320333203432035320363203732038320393204032041320423204332044320453204632047320483204932050320513205232053320543205532056320573205832059320603206132062320633206432065320663206732068320693207032071320723207332074320753207632077320783207932080320813208232083320843208532086320873208832089320903209132092320933209432095320963209732098320993210032101321023210332104321053210632107321083210932110321113211232113321143211532116321173211832119321203212132122321233212432125321263212732128321293213032131321323213332134321353213632137321383213932140321413214232143321443214532146321473214832149321503215132152321533215432155321563215732158321593216032161321623216332164321653216632167321683216932170321713217232173321743217532176321773217832179321803218132182321833218432185321863218732188321893219032191321923219332194321953219632197321983219932200322013220232203322043220532206322073220832209322103221132212322133221432215322163221732218322193222032221322223222332224322253222632227322283222932230322313223232233322343223532236322373223832239322403224132242322433224432245322463224732248322493225032251322523225332254322553225632257322583225932260322613226232263322643226532266322673226832269322703227132272322733227432275322763227732278322793228032281322823228332284322853228632287322883228932290322913229232293322943229532296322973229832299323003230132302323033230432305323063230732308323093231032311323123231332314323153231632317323183231932320323213232232323323243232532326323273232832329323303233132332323333233432335323363233732338323393234032341323423234332344323453234632347323483234932350323513235232353323543235532356323573235832359323603236132362323633236432365323663236732368323693237032371323723237332374323753237632377323783237932380323813238232383323843238532386323873238832389323903239132392323933239432395323963239732398323993240032401324023240332404324053240632407324083240932410324113241232413324143241532416324173241832419324203242132422324233242432425324263242732428324293243032431324323243332434324353243632437324383243932440324413244232443324443244532446324473244832449324503245132452324533245432455324563245732458324593246032461324623246332464324653246632467324683246932470324713247232473324743247532476324773247832479324803248132482324833248432485324863248732488324893249032491324923249332494324953249632497324983249932500325013250232503325043250532506325073250832509325103251132512325133251432515325163251732518325193252032521325223252332524325253252632527325283252932530325313253232533325343253532536325373253832539325403254132542325433254432545325463254732548325493255032551325523255332554325553255632557325583255932560325613256232563325643256532566325673256832569325703257132572325733257432575325763257732578325793258032581325823258332584325853258632587325883258932590325913259232593325943259532596325973259832599326003260132602326033260432605326063260732608326093261032611326123261332614326153261632617326183261932620326213262232623326243262532626326273262832629326303263132632326333263432635326363263732638326393264032641326423264332644326453264632647326483264932650326513265232653326543265532656326573265832659326603266132662326633266432665326663266732668326693267032671326723267332674326753267632677326783267932680326813268232683326843268532686326873268832689326903269132692326933269432695326963269732698326993270032701327023270332704327053270632707327083270932710327113271232713327143271532716327173271832719327203272132722327233272432725327263272732728327293273032731327323273332734327353273632737327383273932740327413274232743327443274532746327473274832749327503275132752327533275432755327563275732758327593276032761327623276332764327653276632767327683276932770327713277232773327743277532776327773277832779327803278132782327833278432785327863278732788327893279032791327923279332794327953279632797327983279932800328013280232803328043280532806328073280832809328103281132812328133281432815328163281732818328193282032821328223282332824328253282632827328283282932830328313283232833328343283532836328373283832839328403284132842328433284432845328463284732848328493285032851328523285332854328553285632857328583285932860328613286232863328643286532866328673286832869328703287132872328733287432875328763287732878328793288032881328823288332884328853288632887328883288932890328913289232893328943289532896328973289832899329003290132902329033290432905329063290732908329093291032911329123291332914329153291632917329183291932920329213292232923329243292532926329273292832929329303293132932329333293432935329363293732938329393294032941329423294332944329453294632947329483294932950329513295232953329543295532956329573295832959329603296132962329633296432965329663296732968329693297032971329723297332974329753297632977329783297932980329813298232983329843298532986329873298832989329903299132992329933299432995329963299732998329993300033001330023300333004330053300633007330083300933010330113301233013330143301533016330173301833019330203302133022330233302433025330263302733028330293303033031330323303333034330353303633037330383303933040330413304233043330443304533046330473304833049330503305133052330533305433055330563305733058330593306033061330623306333064330653306633067330683306933070330713307233073330743307533076330773307833079330803308133082330833308433085330863308733088330893309033091330923309333094330953309633097330983309933100331013310233103331043310533106331073310833109331103311133112331133311433115331163311733118331193312033121331223312333124331253312633127331283312933130331313313233133331343313533136331373313833139331403314133142331433314433145331463314733148331493315033151331523315333154331553315633157331583315933160331613316233163331643316533166331673316833169331703317133172331733317433175331763317733178331793318033181331823318333184331853318633187331883318933190331913319233193331943319533196331973319833199332003320133202332033320433205332063320733208332093321033211332123321333214332153321633217332183321933220332213322233223332243322533226332273322833229332303323133232332333323433235332363323733238332393324033241332423324333244332453324633247332483324933250332513325233253332543325533256332573325833259332603326133262332633326433265332663326733268332693327033271332723327333274332753327633277332783327933280332813328233283332843328533286332873328833289332903329133292332933329433295332963329733298332993330033301333023330333304333053330633307333083330933310333113331233313333143331533316333173331833319333203332133322333233332433325333263332733328333293333033331333323333333334333353333633337333383333933340333413334233343333443334533346333473334833349333503335133352333533335433355333563335733358333593336033361333623336333364333653336633367333683336933370333713337233373333743337533376333773337833379333803338133382333833338433385333863338733388333893339033391333923339333394333953339633397333983339933400334013340233403334043340533406334073340833409334103341133412334133341433415334163341733418334193342033421334223342333424334253342633427334283342933430334313343233433334343343533436334373343833439334403344133442334433344433445334463344733448334493345033451334523345333454334553345633457334583345933460334613346233463334643346533466334673346833469334703347133472334733347433475334763347733478334793348033481334823348333484334853348633487334883348933490334913349233493334943349533496334973349833499335003350133502335033350433505335063350733508335093351033511335123351333514335153351633517335183351933520335213352233523335243352533526335273352833529335303353133532335333353433535335363353733538335393354033541335423354333544335453354633547335483354933550335513355233553335543355533556335573355833559335603356133562335633356433565335663356733568335693357033571335723357333574335753357633577335783357933580335813358233583335843358533586335873358833589335903359133592335933359433595335963359733598335993360033601336023360333604336053360633607336083360933610336113361233613336143361533616336173361833619336203362133622336233362433625336263362733628336293363033631336323363333634336353363633637336383363933640336413364233643336443364533646336473364833649336503365133652336533365433655336563365733658336593366033661336623366333664336653366633667336683366933670336713367233673336743367533676336773367833679336803368133682336833368433685336863368733688336893369033691336923369333694336953369633697336983369933700337013370233703337043370533706337073370833709337103371133712337133371433715337163371733718337193372033721337223372333724337253372633727337283372933730337313373233733337343373533736337373373833739337403374133742337433374433745337463374733748337493375033751337523375333754337553375633757337583375933760337613376233763337643376533766337673376833769337703377133772337733377433775337763377733778337793378033781337823378333784337853378633787337883378933790337913379233793337943379533796337973379833799338003380133802338033380433805338063380733808338093381033811338123381333814338153381633817338183381933820338213382233823338243382533826338273382833829338303383133832338333383433835338363383733838338393384033841338423384333844338453384633847338483384933850338513385233853338543385533856338573385833859338603386133862338633386433865338663386733868338693387033871338723387333874338753387633877338783387933880338813388233883338843388533886338873388833889338903389133892338933389433895338963389733898338993390033901339023390333904339053390633907339083390933910339113391233913339143391533916339173391833919339203392133922339233392433925339263392733928339293393033931339323393333934339353393633937339383393933940339413394233943339443394533946339473394833949339503395133952339533395433955339563395733958339593396033961339623396333964339653396633967339683396933970339713397233973339743397533976339773397833979339803398133982339833398433985339863398733988339893399033991339923399333994339953399633997339983399934000340013400234003340043400534006340073400834009340103401134012340133401434015340163401734018340193402034021340223402334024340253402634027340283402934030340313403234033340343403534036340373403834039340403404134042340433404434045340463404734048340493405034051340523405334054340553405634057340583405934060340613406234063340643406534066340673406834069340703407134072340733407434075340763407734078340793408034081340823408334084340853408634087340883408934090340913409234093340943409534096340973409834099341003410134102341033410434105341063410734108341093411034111341123411334114341153411634117341183411934120341213412234123341243412534126341273412834129341303413134132341333413434135341363413734138341393414034141341423414334144341453414634147341483414934150341513415234153341543415534156341573415834159341603416134162341633416434165341663416734168341693417034171341723417334174341753417634177341783417934180341813418234183341843418534186341873418834189341903419134192341933419434195341963419734198341993420034201342023420334204342053420634207342083420934210342113421234213342143421534216342173421834219342203422134222342233422434225342263422734228342293423034231342323423334234342353423634237342383423934240342413424234243342443424534246342473424834249342503425134252342533425434255342563425734258342593426034261342623426334264342653426634267342683426934270342713427234273342743427534276342773427834279342803428134282342833428434285342863428734288342893429034291342923429334294342953429634297342983429934300343013430234303343043430534306343073430834309343103431134312343133431434315343163431734318343193432034321343223432334324343253432634327343283432934330343313433234333343343433534336343373433834339343403434134342343433434434345343463434734348343493435034351343523435334354343553435634357343583435934360343613436234363343643436534366343673436834369343703437134372343733437434375343763437734378343793438034381343823438334384343853438634387343883438934390343913439234393343943439534396343973439834399344003440134402344033440434405344063440734408344093441034411344123441334414344153441634417344183441934420344213442234423344243442534426344273442834429344303443134432344333443434435344363443734438344393444034441344423444334444344453444634447344483444934450344513445234453344543445534456344573445834459344603446134462344633446434465344663446734468344693447034471344723447334474344753447634477344783447934480344813448234483344843448534486344873448834489344903449134492344933449434495344963449734498344993450034501345023450334504345053450634507345083450934510345113451234513345143451534516345173451834519345203452134522345233452434525345263452734528345293453034531345323453334534345353453634537345383453934540345413454234543345443454534546345473454834549345503455134552345533455434555345563455734558345593456034561345623456334564345653456634567345683456934570345713457234573345743457534576345773457834579345803458134582345833458434585345863458734588345893459034591345923459334594345953459634597345983459934600346013460234603346043460534606346073460834609346103461134612346133461434615346163461734618346193462034621346223462334624346253462634627346283462934630346313463234633346343463534636346373463834639346403464134642346433464434645346463464734648346493465034651346523465334654346553465634657346583465934660346613466234663346643466534666346673466834669346703467134672346733467434675346763467734678346793468034681346823468334684346853468634687346883468934690346913469234693346943469534696346973469834699347003470134702347033470434705347063470734708347093471034711347123471334714347153471634717347183471934720347213472234723347243472534726347273472834729347303473134732347333473434735347363473734738347393474034741347423474334744347453474634747347483474934750347513475234753347543475534756347573475834759347603476134762347633476434765347663476734768347693477034771347723477334774347753477634777347783477934780347813478234783347843478534786347873478834789347903479134792347933479434795347963479734798347993480034801348023480334804348053480634807348083480934810348113481234813348143481534816348173481834819348203482134822348233482434825348263482734828348293483034831348323483334834348353483634837348383483934840348413484234843348443484534846348473484834849348503485134852348533485434855348563485734858348593486034861348623486334864348653486634867348683486934870348713487234873348743487534876348773487834879348803488134882348833488434885348863488734888348893489034891348923489334894348953489634897348983489934900349013490234903349043490534906349073490834909349103491134912349133491434915349163491734918349193492034921349223492334924349253492634927349283492934930349313493234933349343493534936349373493834939349403494134942349433494434945349463494734948349493495034951349523495334954349553495634957349583495934960349613496234963349643496534966349673496834969349703497134972349733497434975349763497734978349793498034981349823498334984349853498634987349883498934990349913499234993349943499534996349973499834999350003500135002350033500435005350063500735008350093501035011350123501335014350153501635017350183501935020350213502235023350243502535026350273502835029350303503135032350333503435035350363503735038350393504035041350423504335044350453504635047350483504935050350513505235053350543505535056350573505835059350603506135062350633506435065350663506735068350693507035071350723507335074350753507635077350783507935080350813508235083350843508535086350873508835089350903509135092350933509435095350963509735098350993510035101351023510335104351053510635107351083510935110351113511235113351143511535116351173511835119351203512135122351233512435125351263512735128351293513035131351323513335134351353513635137351383513935140351413514235143351443514535146351473514835149351503515135152351533515435155351563515735158351593516035161351623516335164351653516635167351683516935170351713517235173351743517535176351773517835179351803518135182351833518435185351863518735188351893519035191351923519335194351953519635197351983519935200352013520235203352043520535206352073520835209352103521135212352133521435215352163521735218352193522035221352223522335224352253522635227352283522935230352313523235233352343523535236352373523835239352403524135242352433524435245352463524735248352493525035251352523525335254352553525635257352583525935260352613526235263352643526535266352673526835269352703527135272352733527435275352763527735278352793528035281352823528335284352853528635287352883528935290352913529235293352943529535296352973529835299353003530135302353033530435305353063530735308353093531035311353123531335314353153531635317353183531935320353213532235323353243532535326353273532835329353303533135332353333533435335353363533735338353393534035341353423534335344353453534635347353483534935350353513535235353353543535535356353573535835359353603536135362353633536435365353663536735368353693537035371353723537335374353753537635377353783537935380353813538235383353843538535386353873538835389353903539135392353933539435395353963539735398353993540035401354023540335404354053540635407354083540935410354113541235413354143541535416354173541835419354203542135422354233542435425354263542735428354293543035431354323543335434354353543635437354383543935440354413544235443354443544535446354473544835449354503545135452354533545435455354563545735458354593546035461354623546335464354653546635467354683546935470354713547235473354743547535476354773547835479354803548135482354833548435485354863548735488354893549035491354923549335494354953549635497354983549935500355013550235503355043550535506355073550835509355103551135512355133551435515355163551735518355193552035521355223552335524355253552635527355283552935530355313553235533355343553535536355373553835539355403554135542355433554435545355463554735548355493555035551355523555335554355553555635557355583555935560355613556235563355643556535566355673556835569355703557135572355733557435575355763557735578355793558035581355823558335584355853558635587355883558935590355913559235593355943559535596355973559835599356003560135602356033560435605356063560735608356093561035611356123561335614356153561635617356183561935620356213562235623356243562535626356273562835629356303563135632356333563435635356363563735638356393564035641356423564335644356453564635647356483564935650356513565235653356543565535656356573565835659356603566135662356633566435665356663566735668356693567035671356723567335674356753567635677356783567935680356813568235683356843568535686356873568835689356903569135692356933569435695356963569735698356993570035701357023570335704357053570635707357083570935710357113571235713357143571535716357173571835719357203572135722357233572435725357263572735728357293573035731357323573335734357353573635737357383573935740357413574235743357443574535746357473574835749357503575135752357533575435755357563575735758357593576035761357623576335764357653576635767357683576935770357713577235773357743577535776357773577835779357803578135782357833578435785357863578735788357893579035791357923579335794357953579635797357983579935800358013580235803358043580535806358073580835809358103581135812358133581435815358163581735818358193582035821358223582335824358253582635827358283582935830358313583235833358343583535836358373583835839358403584135842358433584435845358463584735848358493585035851358523585335854358553585635857358583585935860358613586235863358643586535866358673586835869358703587135872358733587435875358763587735878358793588035881358823588335884358853588635887358883588935890358913589235893358943589535896358973589835899359003590135902359033590435905359063590735908359093591035911359123591335914359153591635917359183591935920359213592235923359243592535926359273592835929359303593135932359333593435935359363593735938359393594035941359423594335944359453594635947359483594935950359513595235953359543595535956359573595835959359603596135962359633596435965359663596735968359693597035971359723597335974359753597635977359783597935980359813598235983359843598535986359873598835989359903599135992359933599435995359963599735998359993600036001360023600336004360053600636007360083600936010360113601236013360143601536016360173601836019360203602136022360233602436025360263602736028360293603036031360323603336034360353603636037360383603936040360413604236043360443604536046360473604836049360503605136052360533605436055360563605736058360593606036061360623606336064360653606636067360683606936070360713607236073360743607536076360773607836079360803608136082360833608436085360863608736088360893609036091360923609336094360953609636097360983609936100361013610236103361043610536106361073610836109361103611136112361133611436115361163611736118361193612036121361223612336124361253612636127361283612936130361313613236133361343613536136361373613836139361403614136142361433614436145361463614736148361493615036151361523615336154361553615636157361583615936160361613616236163361643616536166361673616836169361703617136172361733617436175361763617736178361793618036181361823618336184361853618636187361883618936190361913619236193361943619536196361973619836199362003620136202362033620436205362063620736208362093621036211362123621336214362153621636217362183621936220362213622236223362243622536226362273622836229362303623136232362333623436235362363623736238362393624036241362423624336244362453624636247362483624936250362513625236253362543625536256362573625836259362603626136262362633626436265362663626736268362693627036271362723627336274362753627636277362783627936280362813628236283362843628536286362873628836289362903629136292362933629436295362963629736298362993630036301363023630336304363053630636307363083630936310363113631236313363143631536316363173631836319363203632136322363233632436325363263632736328363293633036331363323633336334363353633636337363383633936340363413634236343363443634536346363473634836349363503635136352363533635436355363563635736358363593636036361363623636336364363653636636367363683636936370363713637236373363743637536376363773637836379363803638136382363833638436385363863638736388363893639036391363923639336394363953639636397363983639936400364013640236403364043640536406364073640836409364103641136412364133641436415364163641736418364193642036421364223642336424364253642636427364283642936430364313643236433364343643536436364373643836439364403644136442364433644436445364463644736448364493645036451364523645336454364553645636457364583645936460364613646236463364643646536466364673646836469364703647136472364733647436475364763647736478364793648036481364823648336484364853648636487364883648936490364913649236493364943649536496364973649836499365003650136502365033650436505365063650736508365093651036511365123651336514365153651636517365183651936520365213652236523365243652536526365273652836529365303653136532365333653436535365363653736538365393654036541365423654336544365453654636547365483654936550365513655236553365543655536556365573655836559365603656136562365633656436565365663656736568365693657036571365723657336574365753657636577365783657936580365813658236583365843658536586365873658836589365903659136592365933659436595365963659736598365993660036601366023660336604366053660636607366083660936610366113661236613366143661536616366173661836619366203662136622366233662436625366263662736628366293663036631366323663336634366353663636637366383663936640366413664236643366443664536646366473664836649366503665136652366533665436655366563665736658366593666036661366623666336664366653666636667366683666936670366713667236673366743667536676366773667836679366803668136682366833668436685366863668736688366893669036691366923669336694366953669636697366983669936700367013670236703367043670536706367073670836709367103671136712367133671436715367163671736718367193672036721367223672336724367253672636727367283672936730367313673236733367343673536736367373673836739367403674136742367433674436745367463674736748367493675036751367523675336754367553675636757367583675936760367613676236763367643676536766367673676836769367703677136772367733677436775367763677736778367793678036781367823678336784367853678636787367883678936790367913679236793367943679536796367973679836799368003680136802368033680436805368063680736808368093681036811368123681336814368153681636817368183681936820368213682236823368243682536826368273682836829368303683136832368333683436835368363683736838368393684036841368423684336844368453684636847368483684936850368513685236853368543685536856368573685836859368603686136862368633686436865368663686736868368693687036871368723687336874368753687636877368783687936880368813688236883368843688536886368873688836889368903689136892368933689436895368963689736898368993690036901369023690336904369053690636907369083690936910369113691236913369143691536916369173691836919369203692136922369233692436925369263692736928369293693036931369323693336934369353693636937369383693936940369413694236943369443694536946369473694836949369503695136952369533695436955369563695736958369593696036961369623696336964369653696636967369683696936970369713697236973369743697536976369773697836979369803698136982369833698436985369863698736988369893699036991369923699336994369953699636997369983699937000370013700237003370043700537006370073700837009370103701137012370133701437015370163701737018370193702037021370223702337024370253702637027370283702937030370313703237033370343703537036370373703837039370403704137042370433704437045370463704737048370493705037051370523705337054370553705637057370583705937060370613706237063370643706537066370673706837069370703707137072370733707437075370763707737078370793708037081370823708337084370853708637087370883708937090370913709237093370943709537096370973709837099371003710137102371033710437105371063710737108371093711037111371123711337114371153711637117371183711937120371213712237123371243712537126371273712837129371303713137132371333713437135371363713737138371393714037141371423714337144371453714637147371483714937150371513715237153371543715537156371573715837159371603716137162371633716437165371663716737168371693717037171371723717337174371753717637177371783717937180371813718237183371843718537186371873718837189371903719137192371933719437195371963719737198371993720037201372023720337204372053720637207372083720937210372113721237213372143721537216372173721837219372203722137222372233722437225372263722737228372293723037231372323723337234372353723637237372383723937240372413724237243372443724537246372473724837249372503725137252372533725437255372563725737258372593726037261372623726337264372653726637267372683726937270372713727237273372743727537276372773727837279372803728137282372833728437285372863728737288372893729037291372923729337294372953729637297372983729937300373013730237303373043730537306373073730837309373103731137312373133731437315373163731737318373193732037321373223732337324373253732637327373283732937330373313733237333373343733537336373373733837339373403734137342373433734437345373463734737348373493735037351373523735337354373553735637357373583735937360373613736237363373643736537366373673736837369373703737137372373733737437375373763737737378373793738037381373823738337384373853738637387373883738937390373913739237393373943739537396373973739837399374003740137402374033740437405374063740737408374093741037411374123741337414374153741637417374183741937420374213742237423374243742537426374273742837429374303743137432374333743437435374363743737438374393744037441374423744337444374453744637447374483744937450374513745237453374543745537456374573745837459374603746137462374633746437465374663746737468374693747037471374723747337474374753747637477374783747937480374813748237483374843748537486374873748837489374903749137492374933749437495374963749737498374993750037501375023750337504375053750637507375083750937510375113751237513375143751537516375173751837519375203752137522375233752437525375263752737528375293753037531375323753337534375353753637537375383753937540375413754237543375443754537546375473754837549375503755137552375533755437555375563755737558375593756037561375623756337564375653756637567375683756937570375713757237573375743757537576375773757837579375803758137582375833758437585375863758737588375893759037591375923759337594375953759637597375983759937600376013760237603376043760537606376073760837609376103761137612376133761437615376163761737618376193762037621376223762337624376253762637627376283762937630376313763237633376343763537636376373763837639376403764137642376433764437645376463764737648376493765037651376523765337654376553765637657376583765937660376613766237663376643766537666376673766837669376703767137672376733767437675376763767737678376793768037681376823768337684376853768637687376883768937690376913769237693376943769537696376973769837699377003770137702377033770437705377063770737708377093771037711377123771337714377153771637717377183771937720377213772237723377243772537726377273772837729377303773137732377333773437735377363773737738377393774037741377423774337744377453774637747377483774937750377513775237753377543775537756377573775837759377603776137762377633776437765377663776737768377693777037771377723777337774377753777637777377783777937780377813778237783377843778537786377873778837789377903779137792377933779437795377963779737798377993780037801378023780337804378053780637807378083780937810378113781237813378143781537816378173781837819378203782137822378233782437825378263782737828378293783037831378323783337834378353783637837378383783937840378413784237843378443784537846378473784837849378503785137852378533785437855378563785737858378593786037861378623786337864378653786637867378683786937870378713787237873378743787537876378773787837879378803788137882378833788437885378863788737888378893789037891378923789337894378953789637897378983789937900379013790237903379043790537906379073790837909379103791137912379133791437915379163791737918379193792037921379223792337924379253792637927379283792937930379313793237933379343793537936379373793837939379403794137942379433794437945379463794737948379493795037951379523795337954379553795637957379583795937960379613796237963379643796537966379673796837969379703797137972379733797437975379763797737978379793798037981379823798337984379853798637987379883798937990379913799237993379943799537996379973799837999380003800138002380033800438005380063800738008380093801038011380123801338014380153801638017380183801938020380213802238023380243802538026380273802838029380303803138032380333803438035380363803738038380393804038041380423804338044380453804638047380483804938050380513805238053380543805538056380573805838059380603806138062380633806438065380663806738068380693807038071380723807338074380753807638077380783807938080380813808238083380843808538086380873808838089380903809138092380933809438095380963809738098380993810038101381023810338104381053810638107381083810938110381113811238113381143811538116381173811838119381203812138122381233812438125381263812738128381293813038131381323813338134381353813638137381383813938140381413814238143381443814538146381473814838149381503815138152381533815438155381563815738158381593816038161381623816338164381653816638167381683816938170381713817238173381743817538176381773817838179381803818138182381833818438185381863818738188381893819038191381923819338194381953819638197381983819938200382013820238203382043820538206382073820838209382103821138212382133821438215382163821738218382193822038221382223822338224382253822638227382283822938230382313823238233382343823538236382373823838239382403824138242382433824438245382463824738248382493825038251382523825338254382553825638257382583825938260382613826238263382643826538266382673826838269382703827138272382733827438275382763827738278382793828038281382823828338284382853828638287382883828938290382913829238293382943829538296382973829838299383003830138302383033830438305383063830738308383093831038311383123831338314383153831638317383183831938320383213832238323383243832538326383273832838329383303833138332383333833438335383363833738338383393834038341383423834338344383453834638347383483834938350383513835238353383543835538356383573835838359383603836138362383633836438365383663836738368383693837038371383723837338374383753837638377383783837938380383813838238383383843838538386383873838838389383903839138392383933839438395383963839738398383993840038401384023840338404384053840638407384083840938410384113841238413384143841538416384173841838419384203842138422384233842438425384263842738428384293843038431384323843338434384353843638437384383843938440384413844238443384443844538446384473844838449384503845138452384533845438455384563845738458384593846038461384623846338464384653846638467384683846938470384713847238473384743847538476384773847838479384803848138482384833848438485384863848738488384893849038491384923849338494384953849638497384983849938500385013850238503385043850538506385073850838509385103851138512385133851438515385163851738518385193852038521385223852338524385253852638527385283852938530385313853238533385343853538536385373853838539385403854138542385433854438545385463854738548385493855038551385523855338554385553855638557385583855938560385613856238563385643856538566385673856838569385703857138572385733857438575385763857738578385793858038581385823858338584385853858638587385883858938590385913859238593385943859538596385973859838599386003860138602386033860438605386063860738608386093861038611386123861338614386153861638617386183861938620386213862238623386243862538626386273862838629386303863138632386333863438635386363863738638386393864038641386423864338644386453864638647386483864938650386513865238653386543865538656386573865838659386603866138662386633866438665386663866738668386693867038671386723867338674386753867638677386783867938680386813868238683386843868538686386873868838689386903869138692386933869438695386963869738698386993870038701387023870338704387053870638707387083870938710387113871238713387143871538716387173871838719387203872138722387233872438725387263872738728387293873038731387323873338734387353873638737387383873938740387413874238743387443874538746387473874838749387503875138752387533875438755387563875738758387593876038761387623876338764387653876638767387683876938770387713877238773387743877538776387773877838779387803878138782387833878438785387863878738788387893879038791387923879338794387953879638797387983879938800388013880238803388043880538806388073880838809388103881138812388133881438815388163881738818388193882038821388223882338824388253882638827388283882938830388313883238833388343883538836388373883838839388403884138842388433884438845388463884738848388493885038851388523885338854388553885638857388583885938860388613886238863388643886538866388673886838869388703887138872388733887438875388763887738878388793888038881388823888338884388853888638887388883888938890388913889238893388943889538896388973889838899389003890138902389033890438905389063890738908389093891038911389123891338914389153891638917389183891938920389213892238923389243892538926389273892838929389303893138932389333893438935389363893738938389393894038941389423894338944389453894638947389483894938950389513895238953389543895538956389573895838959389603896138962389633896438965389663896738968389693897038971389723897338974389753897638977389783897938980389813898238983389843898538986389873898838989389903899138992389933899438995389963899738998389993900039001390023900339004390053900639007390083900939010390113901239013390143901539016390173901839019390203902139022390233902439025390263902739028390293903039031390323903339034390353903639037390383903939040390413904239043390443904539046390473904839049390503905139052390533905439055390563905739058390593906039061390623906339064390653906639067390683906939070390713907239073390743907539076390773907839079390803908139082390833908439085390863908739088390893909039091390923909339094390953909639097390983909939100391013910239103391043910539106391073910839109391103911139112391133911439115391163911739118391193912039121391223912339124391253912639127391283912939130391313913239133391343913539136391373913839139391403914139142391433914439145391463914739148391493915039151391523915339154391553915639157391583915939160391613916239163391643916539166391673916839169391703917139172391733917439175391763917739178391793918039181391823918339184391853918639187391883918939190391913919239193391943919539196391973919839199392003920139202392033920439205392063920739208392093921039211392123921339214392153921639217392183921939220392213922239223392243922539226392273922839229392303923139232392333923439235392363923739238392393924039241392423924339244392453924639247392483924939250392513925239253392543925539256392573925839259392603926139262392633926439265392663926739268392693927039271392723927339274392753927639277392783927939280392813928239283392843928539286392873928839289392903929139292392933929439295392963929739298392993930039301393023930339304393053930639307393083930939310393113931239313393143931539316393173931839319393203932139322393233932439325393263932739328393293933039331393323933339334393353933639337393383933939340393413934239343393443934539346393473934839349393503935139352393533935439355393563935739358393593936039361393623936339364393653936639367393683936939370393713937239373393743937539376393773937839379393803938139382393833938439385393863938739388393893939039391393923939339394393953939639397393983939939400394013940239403394043940539406394073940839409394103941139412394133941439415394163941739418394193942039421394223942339424394253942639427394283942939430394313943239433394343943539436394373943839439394403944139442394433944439445394463944739448394493945039451394523945339454394553945639457394583945939460394613946239463394643946539466394673946839469394703947139472394733947439475394763947739478394793948039481394823948339484394853948639487394883948939490394913949239493394943949539496394973949839499395003950139502395033950439505395063950739508395093951039511395123951339514395153951639517395183951939520395213952239523395243952539526395273952839529395303953139532395333953439535395363953739538395393954039541395423954339544395453954639547395483954939550395513955239553395543955539556395573955839559395603956139562395633956439565395663956739568395693957039571395723957339574395753957639577395783957939580395813958239583395843958539586395873958839589395903959139592395933959439595395963959739598395993960039601396023960339604396053960639607396083960939610396113961239613396143961539616396173961839619396203962139622396233962439625396263962739628396293963039631396323963339634396353963639637396383963939640396413964239643396443964539646396473964839649396503965139652396533965439655396563965739658396593966039661396623966339664396653966639667396683966939670396713967239673396743967539676396773967839679396803968139682396833968439685396863968739688396893969039691396923969339694396953969639697396983969939700397013970239703397043970539706397073970839709397103971139712397133971439715397163971739718397193972039721397223972339724397253972639727397283972939730397313973239733397343973539736397373973839739397403974139742397433974439745397463974739748397493975039751397523975339754397553975639757397583975939760397613976239763397643976539766397673976839769397703977139772397733977439775397763977739778397793978039781397823978339784397853978639787397883978939790397913979239793397943979539796397973979839799398003980139802398033980439805398063980739808398093981039811398123981339814398153981639817398183981939820398213982239823398243982539826398273982839829398303983139832398333983439835398363983739838398393984039841398423984339844398453984639847398483984939850398513985239853398543985539856398573985839859398603986139862398633986439865398663986739868398693987039871398723987339874398753987639877398783987939880398813988239883398843988539886398873988839889398903989139892398933989439895398963989739898398993990039901399023990339904399053990639907399083990939910399113991239913399143991539916399173991839919399203992139922399233992439925399263992739928399293993039931399323993339934399353993639937399383993939940399413994239943399443994539946399473994839949399503995139952399533995439955399563995739958399593996039961399623996339964399653996639967399683996939970399713997239973399743997539976399773997839979399803998139982399833998439985399863998739988399893999039991399923999339994399953999639997399983999940000400014000240003400044000540006400074000840009400104001140012400134001440015400164001740018400194002040021400224002340024400254002640027400284002940030400314003240033400344003540036400374003840039400404004140042400434004440045400464004740048400494005040051400524005340054400554005640057400584005940060400614006240063400644006540066400674006840069400704007140072400734007440075400764007740078400794008040081400824008340084400854008640087400884008940090400914009240093400944009540096400974009840099401004010140102401034010440105401064010740108401094011040111401124011340114401154011640117401184011940120401214012240123401244012540126401274012840129401304013140132401334013440135401364013740138401394014040141401424014340144401454014640147401484014940150401514015240153401544015540156401574015840159401604016140162401634016440165401664016740168401694017040171401724017340174401754017640177401784017940180401814018240183401844018540186401874018840189401904019140192401934019440195401964019740198401994020040201402024020340204402054020640207402084020940210402114021240213402144021540216402174021840219402204022140222402234022440225402264022740228402294023040231402324023340234402354023640237402384023940240402414024240243402444024540246402474024840249402504025140252402534025440255402564025740258402594026040261402624026340264402654026640267402684026940270402714027240273402744027540276402774027840279402804028140282402834028440285402864028740288402894029040291402924029340294402954029640297402984029940300403014030240303403044030540306403074030840309403104031140312403134031440315403164031740318403194032040321403224032340324403254032640327403284032940330403314033240333403344033540336403374033840339403404034140342403434034440345403464034740348403494035040351403524035340354403554035640357403584035940360403614036240363403644036540366403674036840369403704037140372403734037440375403764037740378403794038040381403824038340384403854038640387403884038940390403914039240393403944039540396403974039840399404004040140402404034040440405404064040740408404094041040411404124041340414404154041640417404184041940420404214042240423404244042540426404274042840429404304043140432404334043440435404364043740438404394044040441404424044340444404454044640447404484044940450404514045240453404544045540456404574045840459404604046140462404634046440465404664046740468404694047040471404724047340474404754047640477404784047940480404814048240483404844048540486404874048840489404904049140492404934049440495404964049740498404994050040501405024050340504405054050640507405084050940510405114051240513405144051540516405174051840519405204052140522405234052440525405264052740528405294053040531405324053340534405354053640537405384053940540405414054240543405444054540546405474054840549405504055140552405534055440555405564055740558405594056040561405624056340564405654056640567405684056940570405714057240573405744057540576405774057840579405804058140582405834058440585405864058740588405894059040591405924059340594405954059640597405984059940600406014060240603406044060540606406074060840609406104061140612406134061440615406164061740618406194062040621406224062340624406254062640627406284062940630406314063240633406344063540636406374063840639406404064140642406434064440645406464064740648406494065040651406524065340654406554065640657406584065940660406614066240663406644066540666406674066840669406704067140672406734067440675406764067740678406794068040681406824068340684406854068640687406884068940690406914069240693406944069540696406974069840699407004070140702407034070440705407064070740708407094071040711407124071340714407154071640717407184071940720407214072240723407244072540726407274072840729407304073140732407334073440735407364073740738407394074040741407424074340744407454074640747407484074940750407514075240753407544075540756407574075840759407604076140762407634076440765407664076740768407694077040771407724077340774407754077640777407784077940780407814078240783407844078540786407874078840789407904079140792407934079440795407964079740798407994080040801408024080340804408054080640807408084080940810408114081240813408144081540816408174081840819408204082140822408234082440825408264082740828408294083040831408324083340834408354083640837408384083940840408414084240843408444084540846408474084840849408504085140852408534085440855408564085740858408594086040861408624086340864408654086640867408684086940870408714087240873408744087540876408774087840879408804088140882408834088440885408864088740888408894089040891408924089340894408954089640897408984089940900409014090240903409044090540906409074090840909409104091140912409134091440915409164091740918409194092040921409224092340924409254092640927409284092940930409314093240933409344093540936409374093840939409404094140942409434094440945409464094740948409494095040951409524095340954409554095640957409584095940960409614096240963409644096540966409674096840969409704097140972409734097440975409764097740978409794098040981409824098340984409854098640987409884098940990409914099240993409944099540996409974099840999410004100141002410034100441005410064100741008410094101041011410124101341014410154101641017410184101941020410214102241023410244102541026410274102841029410304103141032410334103441035410364103741038410394104041041410424104341044410454104641047410484104941050410514105241053410544105541056410574105841059410604106141062410634106441065410664106741068410694107041071410724107341074410754107641077410784107941080410814108241083410844108541086410874108841089410904109141092410934109441095410964109741098410994110041101411024110341104411054110641107411084110941110411114111241113411144111541116411174111841119411204112141122411234112441125411264112741128411294113041131411324113341134411354113641137411384113941140411414114241143411444114541146411474114841149411504115141152411534115441155411564115741158411594116041161411624116341164411654116641167411684116941170411714117241173411744117541176411774117841179411804118141182411834118441185411864118741188411894119041191411924119341194411954119641197411984119941200412014120241203412044120541206412074120841209412104121141212412134121441215412164121741218412194122041221412224122341224412254122641227412284122941230412314123241233412344123541236412374123841239412404124141242412434124441245412464124741248412494125041251412524125341254412554125641257412584125941260412614126241263412644126541266412674126841269412704127141272412734127441275412764127741278412794128041281412824128341284412854128641287412884128941290412914129241293412944129541296412974129841299413004130141302413034130441305413064130741308413094131041311413124131341314413154131641317413184131941320413214132241323413244132541326413274132841329413304133141332413334133441335413364133741338413394134041341413424134341344413454134641347413484134941350413514135241353413544135541356413574135841359413604136141362413634136441365413664136741368413694137041371413724137341374413754137641377413784137941380413814138241383413844138541386413874138841389413904139141392413934139441395413964139741398413994140041401414024140341404414054140641407414084140941410414114141241413414144141541416414174141841419414204142141422414234142441425414264142741428414294143041431414324143341434414354143641437414384143941440414414144241443414444144541446414474144841449414504145141452414534145441455414564145741458414594146041461414624146341464414654146641467414684146941470414714147241473414744147541476414774147841479414804148141482414834148441485414864148741488414894149041491414924149341494414954149641497414984149941500415014150241503415044150541506415074150841509415104151141512415134151441515415164151741518415194152041521415224152341524415254152641527415284152941530415314153241533415344153541536415374153841539415404154141542415434154441545415464154741548415494155041551415524155341554415554155641557415584155941560415614156241563415644156541566415674156841569415704157141572415734157441575415764157741578415794158041581415824158341584415854158641587415884158941590415914159241593415944159541596415974159841599416004160141602416034160441605416064160741608416094161041611416124161341614416154161641617416184161941620416214162241623416244162541626416274162841629416304163141632416334163441635416364163741638416394164041641416424164341644416454164641647416484164941650416514165241653416544165541656416574165841659416604166141662416634166441665416664166741668416694167041671416724167341674416754167641677416784167941680416814168241683416844168541686416874168841689416904169141692416934169441695416964169741698416994170041701417024170341704417054170641707417084170941710417114171241713417144171541716417174171841719417204172141722417234172441725417264172741728417294173041731417324173341734417354173641737417384173941740417414174241743417444174541746417474174841749417504175141752417534175441755417564175741758417594176041761417624176341764417654176641767417684176941770417714177241773417744177541776417774177841779417804178141782417834178441785417864178741788417894179041791417924179341794417954179641797417984179941800418014180241803418044180541806418074180841809418104181141812418134181441815418164181741818418194182041821418224182341824418254182641827418284182941830418314183241833418344183541836418374183841839418404184141842418434184441845418464184741848418494185041851418524185341854418554185641857418584185941860418614186241863418644186541866418674186841869418704187141872418734187441875418764187741878418794188041881418824188341884418854188641887418884188941890418914189241893418944189541896418974189841899419004190141902419034190441905419064190741908419094191041911419124191341914419154191641917419184191941920419214192241923419244192541926419274192841929419304193141932419334193441935419364193741938419394194041941419424194341944419454194641947419484194941950419514195241953419544195541956419574195841959419604196141962419634196441965419664196741968419694197041971419724197341974419754197641977419784197941980419814198241983419844198541986419874198841989419904199141992419934199441995419964199741998419994200042001420024200342004420054200642007420084200942010420114201242013420144201542016420174201842019420204202142022420234202442025420264202742028420294203042031420324203342034420354203642037420384203942040420414204242043420444204542046420474204842049420504205142052420534205442055420564205742058420594206042061420624206342064420654206642067420684206942070420714207242073420744207542076420774207842079420804208142082420834208442085420864208742088420894209042091420924209342094420954209642097420984209942100421014210242103421044210542106421074210842109421104211142112421134211442115421164211742118421194212042121421224212342124421254212642127421284212942130421314213242133421344213542136421374213842139421404214142142421434214442145421464214742148421494215042151421524215342154421554215642157421584215942160421614216242163421644216542166421674216842169421704217142172421734217442175421764217742178421794218042181421824218342184421854218642187421884218942190421914219242193421944219542196421974219842199422004220142202422034220442205422064220742208422094221042211422124221342214422154221642217422184221942220422214222242223422244222542226422274222842229422304223142232422334223442235422364223742238422394224042241422424224342244422454224642247422484224942250422514225242253422544225542256422574225842259422604226142262422634226442265422664226742268422694227042271422724227342274422754227642277422784227942280422814228242283422844228542286422874228842289422904229142292422934229442295422964229742298422994230042301423024230342304423054230642307423084230942310423114231242313423144231542316423174231842319423204232142322423234232442325423264232742328423294233042331423324233342334423354233642337423384233942340423414234242343423444234542346423474234842349423504235142352423534235442355423564235742358423594236042361423624236342364423654236642367423684236942370423714237242373423744237542376423774237842379423804238142382423834238442385423864238742388423894239042391423924239342394423954239642397423984239942400424014240242403424044240542406424074240842409424104241142412424134241442415424164241742418424194242042421424224242342424424254242642427424284242942430424314243242433424344243542436424374243842439424404244142442424434244442445424464244742448424494245042451424524245342454424554245642457424584245942460424614246242463424644246542466424674246842469424704247142472424734247442475424764247742478424794248042481424824248342484424854248642487424884248942490424914249242493424944249542496424974249842499425004250142502425034250442505425064250742508425094251042511425124251342514425154251642517425184251942520425214252242523425244252542526425274252842529425304253142532425334253442535425364253742538425394254042541425424254342544425454254642547425484254942550425514255242553425544255542556425574255842559425604256142562425634256442565425664256742568425694257042571425724257342574425754257642577425784257942580425814258242583425844258542586425874258842589425904259142592425934259442595425964259742598425994260042601426024260342604426054260642607426084260942610426114261242613426144261542616426174261842619426204262142622426234262442625426264262742628426294263042631426324263342634426354263642637426384263942640426414264242643426444264542646426474264842649426504265142652426534265442655426564265742658426594266042661426624266342664426654266642667426684266942670426714267242673426744267542676426774267842679426804268142682426834268442685426864268742688426894269042691426924269342694426954269642697426984269942700427014270242703427044270542706427074270842709427104271142712427134271442715427164271742718427194272042721427224272342724427254272642727427284272942730427314273242733427344273542736427374273842739427404274142742427434274442745427464274742748427494275042751427524275342754427554275642757427584275942760427614276242763427644276542766427674276842769427704277142772427734277442775427764277742778427794278042781427824278342784427854278642787427884278942790427914279242793427944279542796427974279842799428004280142802428034280442805428064280742808428094281042811428124281342814428154281642817428184281942820428214282242823428244282542826428274282842829428304283142832428334283442835428364283742838428394284042841428424284342844428454284642847428484284942850428514285242853428544285542856428574285842859428604286142862428634286442865428664286742868428694287042871428724287342874428754287642877428784287942880428814288242883428844288542886428874288842889428904289142892428934289442895428964289742898428994290042901429024290342904429054290642907429084290942910429114291242913429144291542916429174291842919429204292142922429234292442925429264292742928429294293042931429324293342934429354293642937429384293942940429414294242943429444294542946429474294842949429504295142952429534295442955429564295742958429594296042961429624296342964429654296642967429684296942970429714297242973429744297542976429774297842979429804298142982429834298442985429864298742988429894299042991429924299342994429954299642997429984299943000430014300243003430044300543006430074300843009430104301143012430134301443015430164301743018430194302043021430224302343024430254302643027430284302943030430314303243033430344303543036430374303843039430404304143042430434304443045430464304743048430494305043051430524305343054430554305643057430584305943060430614306243063430644306543066430674306843069430704307143072430734307443075430764307743078430794308043081430824308343084430854308643087430884308943090430914309243093430944309543096430974309843099431004310143102431034310443105431064310743108431094311043111431124311343114431154311643117431184311943120431214312243123431244312543126431274312843129431304313143132431334313443135431364313743138431394314043141431424314343144431454314643147431484314943150431514315243153431544315543156431574315843159431604316143162431634316443165431664316743168431694317043171431724317343174431754317643177431784317943180431814318243183431844318543186431874318843189431904319143192431934319443195431964319743198431994320043201432024320343204432054320643207432084320943210432114321243213432144321543216432174321843219432204322143222432234322443225432264322743228432294323043231432324323343234432354323643237432384323943240432414324243243432444324543246432474324843249432504325143252432534325443255432564325743258432594326043261432624326343264432654326643267432684326943270432714327243273432744327543276432774327843279432804328143282432834328443285432864328743288432894329043291432924329343294432954329643297432984329943300433014330243303433044330543306433074330843309433104331143312433134331443315433164331743318433194332043321433224332343324433254332643327433284332943330433314333243333433344333543336433374333843339433404334143342433434334443345433464334743348433494335043351433524335343354433554335643357433584335943360433614336243363433644336543366433674336843369433704337143372433734337443375433764337743378433794338043381433824338343384433854338643387433884338943390433914339243393433944339543396433974339843399434004340143402434034340443405434064340743408434094341043411434124341343414434154341643417434184341943420434214342243423434244342543426434274342843429434304343143432434334343443435434364343743438434394344043441434424344343444434454344643447434484344943450434514345243453434544345543456434574345843459434604346143462434634346443465434664346743468434694347043471434724347343474434754347643477434784347943480434814348243483434844348543486434874348843489434904349143492434934349443495434964349743498434994350043501435024350343504435054350643507435084350943510435114351243513435144351543516435174351843519435204352143522435234352443525435264352743528435294353043531435324353343534435354353643537435384353943540435414354243543435444354543546435474354843549435504355143552435534355443555435564355743558435594356043561435624356343564435654356643567435684356943570435714357243573435744357543576435774357843579435804358143582435834358443585435864358743588435894359043591435924359343594435954359643597435984359943600436014360243603436044360543606436074360843609436104361143612436134361443615436164361743618436194362043621436224362343624436254362643627436284362943630436314363243633436344363543636436374363843639436404364143642436434364443645436464364743648436494365043651436524365343654436554365643657436584365943660436614366243663436644366543666436674366843669436704367143672436734367443675436764367743678436794368043681436824368343684436854368643687436884368943690436914369243693436944369543696436974369843699437004370143702437034370443705437064370743708437094371043711437124371343714437154371643717437184371943720437214372243723437244372543726437274372843729437304373143732437334373443735437364373743738437394374043741437424374343744437454374643747437484374943750437514375243753437544375543756437574375843759437604376143762437634376443765437664376743768437694377043771437724377343774437754377643777437784377943780437814378243783437844378543786437874378843789437904379143792437934379443795437964379743798437994380043801438024380343804438054380643807438084380943810438114381243813438144381543816438174381843819438204382143822438234382443825438264382743828438294383043831438324383343834438354383643837438384383943840438414384243843438444384543846438474384843849438504385143852438534385443855438564385743858438594386043861438624386343864438654386643867438684386943870438714387243873438744387543876438774387843879438804388143882438834388443885438864388743888438894389043891438924389343894438954389643897438984389943900439014390243903439044390543906439074390843909439104391143912439134391443915439164391743918439194392043921439224392343924439254392643927439284392943930439314393243933439344393543936439374393843939439404394143942439434394443945439464394743948439494395043951439524395343954439554395643957439584395943960439614396243963439644396543966439674396843969439704397143972439734397443975439764397743978439794398043981439824398343984439854398643987439884398943990439914399243993439944399543996439974399843999440004400144002440034400444005440064400744008440094401044011440124401344014440154401644017440184401944020440214402244023440244402544026440274402844029440304403144032440334403444035440364403744038440394404044041440424404344044440454404644047440484404944050440514405244053440544405544056440574405844059440604406144062440634406444065440664406744068440694407044071440724407344074440754407644077440784407944080440814408244083440844408544086440874408844089440904409144092440934409444095440964409744098440994410044101441024410344104441054410644107441084410944110441114411244113441144411544116441174411844119441204412144122441234412444125441264412744128441294413044131441324413344134441354413644137441384413944140441414414244143441444414544146441474414844149441504415144152441534415444155441564415744158441594416044161441624416344164441654416644167441684416944170441714417244173441744417544176441774417844179441804418144182441834418444185441864418744188441894419044191441924419344194441954419644197441984419944200442014420244203442044420544206442074420844209442104421144212442134421444215442164421744218442194422044221442224422344224442254422644227442284422944230442314423244233442344423544236442374423844239442404424144242442434424444245442464424744248442494425044251442524425344254442554425644257442584425944260442614426244263442644426544266442674426844269442704427144272442734427444275442764427744278442794428044281442824428344284442854428644287442884428944290442914429244293442944429544296442974429844299443004430144302443034430444305443064430744308443094431044311443124431344314443154431644317443184431944320443214432244323443244432544326443274432844329443304433144332443334433444335443364433744338443394434044341443424434344344443454434644347443484434944350443514435244353443544435544356443574435844359443604436144362443634436444365443664436744368443694437044371443724437344374443754437644377443784437944380443814438244383443844438544386443874438844389443904439144392443934439444395443964439744398443994440044401444024440344404444054440644407444084440944410444114441244413444144441544416444174441844419444204442144422444234442444425444264442744428444294443044431444324443344434444354443644437444384443944440444414444244443444444444544446444474444844449444504445144452444534445444455444564445744458444594446044461444624446344464444654446644467444684446944470444714447244473444744447544476444774447844479444804448144482444834448444485444864448744488444894449044491444924449344494444954449644497444984449944500445014450244503445044450544506445074450844509445104451144512445134451444515445164451744518445194452044521445224452344524445254452644527445284452944530445314453244533445344453544536445374453844539445404454144542445434454444545445464454744548445494455044551445524455344554445554455644557445584455944560445614456244563445644456544566445674456844569445704457144572445734457444575445764457744578445794458044581445824458344584445854458644587445884458944590445914459244593445944459544596445974459844599446004460144602446034460444605446064460744608446094461044611446124461344614446154461644617446184461944620446214462244623446244462544626446274462844629446304463144632446334463444635446364463744638446394464044641446424464344644446454464644647446484464944650446514465244653446544465544656446574465844659446604466144662446634466444665446664466744668446694467044671446724467344674446754467644677446784467944680446814468244683446844468544686446874468844689446904469144692446934469444695446964469744698446994470044701447024470344704447054470644707447084470944710447114471244713447144471544716447174471844719447204472144722447234472444725447264472744728447294473044731447324473344734447354473644737447384473944740447414474244743447444474544746447474474844749447504475144752447534475444755447564475744758447594476044761447624476344764447654476644767447684476944770447714477244773447744477544776447774477844779447804478144782447834478444785447864478744788447894479044791447924479344794447954479644797447984479944800448014480244803448044480544806448074480844809448104481144812448134481444815448164481744818448194482044821448224482344824448254482644827448284482944830448314483244833448344483544836448374483844839448404484144842448434484444845448464484744848448494485044851448524485344854448554485644857448584485944860448614486244863448644486544866448674486844869448704487144872448734487444875448764487744878448794488044881448824488344884448854488644887448884488944890448914489244893448944489544896448974489844899449004490144902449034490444905449064490744908449094491044911449124491344914449154491644917449184491944920449214492244923449244492544926449274492844929449304493144932449334493444935449364493744938449394494044941449424494344944449454494644947449484494944950449514495244953449544495544956449574495844959449604496144962449634496444965449664496744968449694497044971449724497344974449754497644977449784497944980449814498244983449844498544986449874498844989449904499144992449934499444995449964499744998449994500045001450024500345004450054500645007450084500945010450114501245013450144501545016450174501845019450204502145022450234502445025450264502745028450294503045031450324503345034450354503645037450384503945040450414504245043450444504545046450474504845049450504505145052450534505445055450564505745058450594506045061450624506345064450654506645067450684506945070450714507245073450744507545076450774507845079450804508145082450834508445085450864508745088450894509045091450924509345094450954509645097450984509945100451014510245103451044510545106451074510845109451104511145112451134511445115451164511745118451194512045121451224512345124451254512645127451284512945130451314513245133451344513545136451374513845139451404514145142451434514445145451464514745148451494515045151451524515345154451554515645157451584515945160451614516245163451644516545166451674516845169451704517145172451734517445175451764517745178451794518045181451824518345184451854518645187451884518945190451914519245193451944519545196451974519845199452004520145202452034520445205452064520745208452094521045211452124521345214452154521645217452184521945220452214522245223452244522545226452274522845229452304523145232452334523445235452364523745238452394524045241452424524345244452454524645247452484524945250452514525245253452544525545256452574525845259452604526145262452634526445265452664526745268452694527045271452724527345274452754527645277452784527945280452814528245283452844528545286452874528845289452904529145292452934529445295452964529745298452994530045301453024530345304453054530645307453084530945310453114531245313453144531545316453174531845319453204532145322453234532445325453264532745328453294533045331453324533345334453354533645337453384533945340453414534245343453444534545346453474534845349453504535145352453534535445355453564535745358453594536045361453624536345364453654536645367453684536945370453714537245373453744537545376453774537845379453804538145382453834538445385453864538745388453894539045391453924539345394453954539645397453984539945400454014540245403454044540545406454074540845409454104541145412454134541445415454164541745418454194542045421454224542345424454254542645427454284542945430454314543245433454344543545436454374543845439454404544145442454434544445445454464544745448454494545045451454524545345454454554545645457454584545945460454614546245463454644546545466454674546845469454704547145472454734547445475454764547745478454794548045481454824548345484454854548645487454884548945490454914549245493454944549545496454974549845499455004550145502455034550445505455064550745508455094551045511455124551345514455154551645517455184551945520455214552245523455244552545526455274552845529455304553145532455334553445535455364553745538455394554045541455424554345544455454554645547455484554945550455514555245553455544555545556455574555845559455604556145562455634556445565455664556745568455694557045571455724557345574455754557645577455784557945580455814558245583455844558545586455874558845589455904559145592455934559445595455964559745598455994560045601456024560345604456054560645607456084560945610456114561245613456144561545616456174561845619456204562145622456234562445625456264562745628456294563045631456324563345634456354563645637456384563945640456414564245643456444564545646456474564845649456504565145652456534565445655456564565745658456594566045661456624566345664456654566645667456684566945670456714567245673456744567545676456774567845679456804568145682456834568445685456864568745688456894569045691456924569345694456954569645697456984569945700457014570245703457044570545706457074570845709457104571145712457134571445715457164571745718457194572045721457224572345724457254572645727457284572945730457314573245733457344573545736457374573845739457404574145742457434574445745457464574745748457494575045751457524575345754457554575645757457584575945760457614576245763457644576545766457674576845769457704577145772457734577445775457764577745778457794578045781457824578345784457854578645787457884578945790457914579245793457944579545796457974579845799458004580145802458034580445805458064580745808458094581045811458124581345814458154581645817458184581945820458214582245823458244582545826458274582845829458304583145832458334583445835458364583745838458394584045841458424584345844458454584645847458484584945850458514585245853458544585545856458574585845859458604586145862458634586445865458664586745868458694587045871458724587345874458754587645877458784587945880458814588245883458844588545886458874588845889458904589145892458934589445895458964589745898458994590045901459024590345904459054590645907459084590945910459114591245913459144591545916459174591845919459204592145922459234592445925459264592745928459294593045931459324593345934459354593645937459384593945940459414594245943459444594545946459474594845949459504595145952459534595445955459564595745958459594596045961459624596345964459654596645967459684596945970459714597245973459744597545976459774597845979459804598145982459834598445985459864598745988459894599045991459924599345994459954599645997459984599946000460014600246003460044600546006460074600846009460104601146012460134601446015460164601746018460194602046021460224602346024460254602646027460284602946030460314603246033460344603546036460374603846039460404604146042460434604446045460464604746048460494605046051460524605346054460554605646057460584605946060460614606246063460644606546066460674606846069460704607146072460734607446075460764607746078460794608046081460824608346084460854608646087460884608946090460914609246093460944609546096460974609846099461004610146102461034610446105461064610746108461094611046111461124611346114461154611646117461184611946120461214612246123461244612546126461274612846129461304613146132461334613446135461364613746138461394614046141461424614346144461454614646147461484614946150461514615246153461544615546156461574615846159461604616146162461634616446165461664616746168461694617046171461724617346174461754617646177461784617946180461814618246183461844618546186461874618846189461904619146192461934619446195461964619746198461994620046201462024620346204462054620646207462084620946210462114621246213462144621546216462174621846219462204622146222462234622446225462264622746228462294623046231462324623346234462354623646237462384623946240462414624246243462444624546246462474624846249462504625146252462534625446255462564625746258462594626046261462624626346264462654626646267462684626946270462714627246273462744627546276462774627846279462804628146282462834628446285462864628746288462894629046291462924629346294462954629646297462984629946300463014630246303463044630546306463074630846309463104631146312463134631446315463164631746318463194632046321463224632346324463254632646327463284632946330463314633246333463344633546336463374633846339463404634146342463434634446345463464634746348463494635046351463524635346354463554635646357463584635946360463614636246363463644636546366463674636846369463704637146372463734637446375463764637746378463794638046381463824638346384463854638646387463884638946390463914639246393463944639546396463974639846399464004640146402464034640446405464064640746408464094641046411464124641346414464154641646417464184641946420464214642246423464244642546426464274642846429464304643146432464334643446435464364643746438464394644046441464424644346444464454644646447464484644946450464514645246453464544645546456464574645846459464604646146462464634646446465464664646746468464694647046471464724647346474464754647646477464784647946480464814648246483464844648546486464874648846489464904649146492464934649446495464964649746498464994650046501465024650346504465054650646507465084650946510465114651246513465144651546516465174651846519465204652146522465234652446525465264652746528465294653046531465324653346534465354653646537465384653946540465414654246543465444654546546465474654846549465504655146552465534655446555465564655746558465594656046561465624656346564465654656646567465684656946570465714657246573465744657546576465774657846579465804658146582465834658446585465864658746588465894659046591465924659346594465954659646597465984659946600466014660246603466044660546606466074660846609466104661146612466134661446615466164661746618466194662046621466224662346624466254662646627466284662946630466314663246633466344663546636466374663846639466404664146642466434664446645466464664746648466494665046651466524665346654466554665646657466584665946660466614666246663466644666546666466674666846669466704667146672466734667446675466764667746678466794668046681466824668346684466854668646687466884668946690466914669246693466944669546696466974669846699467004670146702467034670446705467064670746708467094671046711467124671346714467154671646717467184671946720467214672246723467244672546726467274672846729467304673146732467334673446735467364673746738467394674046741467424674346744467454674646747467484674946750467514675246753467544675546756467574675846759467604676146762467634676446765467664676746768467694677046771467724677346774467754677646777467784677946780467814678246783467844678546786467874678846789467904679146792467934679446795467964679746798467994680046801468024680346804468054680646807468084680946810468114681246813468144681546816468174681846819468204682146822468234682446825468264682746828468294683046831468324683346834468354683646837468384683946840468414684246843468444684546846468474684846849468504685146852468534685446855468564685746858468594686046861468624686346864468654686646867468684686946870468714687246873468744687546876468774687846879468804688146882468834688446885468864688746888468894689046891468924689346894468954689646897468984689946900469014690246903469044690546906469074690846909469104691146912469134691446915469164691746918469194692046921469224692346924469254692646927469284692946930469314693246933469344693546936469374693846939469404694146942469434694446945469464694746948469494695046951469524695346954469554695646957469584695946960469614696246963469644696546966469674696846969469704697146972469734697446975469764697746978469794698046981469824698346984469854698646987469884698946990469914699246993469944699546996469974699846999470004700147002470034700447005470064700747008470094701047011470124701347014470154701647017470184701947020470214702247023470244702547026470274702847029470304703147032470334703447035470364703747038470394704047041470424704347044470454704647047470484704947050470514705247053470544705547056470574705847059470604706147062470634706447065470664706747068470694707047071470724707347074470754707647077470784707947080470814708247083470844708547086470874708847089470904709147092470934709447095470964709747098470994710047101471024710347104471054710647107471084710947110471114711247113471144711547116471174711847119471204712147122471234712447125471264712747128471294713047131471324713347134471354713647137471384713947140471414714247143471444714547146471474714847149471504715147152471534715447155471564715747158471594716047161471624716347164471654716647167471684716947170471714717247173471744717547176471774717847179471804718147182471834718447185471864718747188471894719047191471924719347194471954719647197471984719947200472014720247203472044720547206472074720847209472104721147212472134721447215472164721747218472194722047221472224722347224472254722647227472284722947230472314723247233472344723547236472374723847239472404724147242472434724447245472464724747248472494725047251472524725347254472554725647257472584725947260472614726247263472644726547266472674726847269472704727147272472734727447275472764727747278472794728047281472824728347284472854728647287472884728947290472914729247293472944729547296472974729847299473004730147302473034730447305473064730747308473094731047311473124731347314473154731647317473184731947320473214732247323473244732547326473274732847329473304733147332473334733447335473364733747338473394734047341473424734347344473454734647347473484734947350473514735247353473544735547356473574735847359473604736147362473634736447365473664736747368473694737047371473724737347374473754737647377473784737947380473814738247383473844738547386473874738847389473904739147392473934739447395473964739747398473994740047401474024740347404474054740647407474084740947410474114741247413474144741547416474174741847419474204742147422474234742447425474264742747428474294743047431474324743347434474354743647437474384743947440474414744247443474444744547446474474744847449474504745147452474534745447455474564745747458474594746047461474624746347464474654746647467474684746947470474714747247473474744747547476474774747847479474804748147482474834748447485474864748747488474894749047491474924749347494474954749647497474984749947500475014750247503475044750547506475074750847509475104751147512475134751447515475164751747518475194752047521475224752347524475254752647527475284752947530475314753247533475344753547536475374753847539475404754147542475434754447545475464754747548475494755047551475524755347554475554755647557475584755947560475614756247563475644756547566475674756847569475704757147572475734757447575475764757747578475794758047581475824758347584475854758647587475884758947590475914759247593475944759547596475974759847599476004760147602476034760447605476064760747608476094761047611476124761347614476154761647617476184761947620476214762247623476244762547626476274762847629476304763147632476334763447635476364763747638476394764047641476424764347644476454764647647476484764947650476514765247653476544765547656476574765847659476604766147662476634766447665476664766747668476694767047671476724767347674476754767647677476784767947680476814768247683476844768547686476874768847689476904769147692476934769447695476964769747698476994770047701477024770347704477054770647707477084770947710477114771247713477144771547716477174771847719477204772147722477234772447725477264772747728477294773047731477324773347734477354773647737477384773947740477414774247743477444774547746477474774847749477504775147752477534775447755477564775747758477594776047761477624776347764477654776647767477684776947770477714777247773477744777547776477774777847779477804778147782477834778447785477864778747788477894779047791477924779347794477954779647797477984779947800478014780247803478044780547806478074780847809478104781147812478134781447815478164781747818478194782047821478224782347824478254782647827478284782947830478314783247833478344783547836478374783847839478404784147842478434784447845478464784747848478494785047851478524785347854478554785647857478584785947860478614786247863478644786547866478674786847869478704787147872478734787447875478764787747878478794788047881478824788347884478854788647887478884788947890478914789247893478944789547896478974789847899479004790147902479034790447905479064790747908479094791047911479124791347914479154791647917479184791947920479214792247923479244792547926479274792847929479304793147932479334793447935479364793747938479394794047941479424794347944479454794647947479484794947950479514795247953479544795547956479574795847959479604796147962479634796447965479664796747968479694797047971479724797347974479754797647977479784797947980479814798247983479844798547986479874798847989479904799147992479934799447995479964799747998479994800048001480024800348004480054800648007480084800948010480114801248013480144801548016480174801848019480204802148022480234802448025480264802748028480294803048031480324803348034480354803648037480384803948040480414804248043480444804548046480474804848049480504805148052480534805448055480564805748058480594806048061480624806348064480654806648067480684806948070480714807248073480744807548076480774807848079480804808148082480834808448085480864808748088480894809048091480924809348094480954809648097480984809948100481014810248103481044810548106481074810848109481104811148112481134811448115481164811748118481194812048121481224812348124481254812648127481284812948130481314813248133481344813548136481374813848139481404814148142481434814448145481464814748148481494815048151481524815348154481554815648157481584815948160481614816248163481644816548166481674816848169481704817148172481734817448175481764817748178481794818048181481824818348184481854818648187481884818948190481914819248193481944819548196481974819848199482004820148202482034820448205482064820748208482094821048211482124821348214482154821648217482184821948220482214822248223482244822548226482274822848229482304823148232482334823448235482364823748238482394824048241482424824348244482454824648247482484824948250482514825248253482544825548256482574825848259482604826148262482634826448265482664826748268482694827048271482724827348274482754827648277482784827948280482814828248283482844828548286482874828848289482904829148292482934829448295482964829748298482994830048301483024830348304483054830648307483084830948310483114831248313483144831548316483174831848319483204832148322483234832448325483264832748328483294833048331483324833348334483354833648337483384833948340483414834248343483444834548346483474834848349483504835148352483534835448355483564835748358483594836048361483624836348364483654836648367483684836948370483714837248373483744837548376483774837848379483804838148382483834838448385483864838748388483894839048391483924839348394483954839648397483984839948400484014840248403484044840548406484074840848409484104841148412484134841448415484164841748418484194842048421484224842348424484254842648427484284842948430484314843248433484344843548436484374843848439484404844148442484434844448445484464844748448484494845048451484524845348454484554845648457484584845948460484614846248463484644846548466484674846848469484704847148472484734847448475484764847748478484794848048481484824848348484484854848648487484884848948490484914849248493484944849548496484974849848499485004850148502485034850448505485064850748508485094851048511485124851348514485154851648517485184851948520485214852248523485244852548526485274852848529485304853148532485334853448535485364853748538485394854048541485424854348544485454854648547485484854948550485514855248553485544855548556485574855848559485604856148562485634856448565485664856748568485694857048571485724857348574485754857648577485784857948580485814858248583485844858548586485874858848589485904859148592485934859448595485964859748598485994860048601486024860348604486054860648607486084860948610486114861248613486144861548616486174861848619486204862148622486234862448625486264862748628486294863048631486324863348634486354863648637486384863948640486414864248643486444864548646486474864848649486504865148652486534865448655486564865748658486594866048661486624866348664486654866648667486684866948670486714867248673486744867548676486774867848679486804868148682486834868448685486864868748688486894869048691486924869348694486954869648697486984869948700487014870248703487044870548706487074870848709487104871148712487134871448715487164871748718487194872048721487224872348724487254872648727487284872948730487314873248733487344873548736487374873848739487404874148742487434874448745487464874748748487494875048751487524875348754487554875648757487584875948760487614876248763487644876548766487674876848769487704877148772487734877448775487764877748778487794878048781487824878348784487854878648787487884878948790487914879248793487944879548796487974879848799488004880148802488034880448805488064880748808488094881048811488124881348814488154881648817488184881948820488214882248823488244882548826488274882848829488304883148832488334883448835488364883748838488394884048841488424884348844488454884648847488484884948850488514885248853488544885548856488574885848859488604886148862488634886448865488664886748868488694887048871488724887348874488754887648877488784887948880488814888248883488844888548886488874888848889488904889148892488934889448895488964889748898488994890048901489024890348904489054890648907489084890948910489114891248913489144891548916489174891848919489204892148922489234892448925489264892748928489294893048931489324893348934489354893648937489384893948940489414894248943489444894548946489474894848949489504895148952489534895448955489564895748958489594896048961489624896348964489654896648967489684896948970489714897248973489744897548976489774897848979489804898148982489834898448985489864898748988489894899048991489924899348994489954899648997489984899949000490014900249003490044900549006490074900849009490104901149012490134901449015490164901749018490194902049021490224902349024490254902649027490284902949030490314903249033490344903549036490374903849039490404904149042490434904449045490464904749048490494905049051490524905349054490554905649057490584905949060490614906249063490644906549066490674906849069490704907149072490734907449075490764907749078490794908049081490824908349084490854908649087490884908949090490914909249093490944909549096490974909849099491004910149102491034910449105491064910749108491094911049111491124911349114491154911649117491184911949120491214912249123491244912549126491274912849129491304913149132491334913449135491364913749138491394914049141491424914349144491454914649147491484914949150491514915249153491544915549156491574915849159491604916149162491634916449165491664916749168491694917049171491724917349174491754917649177491784917949180491814918249183491844918549186491874918849189491904919149192491934919449195491964919749198491994920049201492024920349204492054920649207492084920949210492114921249213492144921549216492174921849219492204922149222492234922449225492264922749228492294923049231492324923349234492354923649237492384923949240492414924249243492444924549246492474924849249492504925149252492534925449255492564925749258492594926049261492624926349264492654926649267492684926949270492714927249273492744927549276492774927849279492804928149282492834928449285492864928749288492894929049291492924929349294492954929649297492984929949300493014930249303493044930549306493074930849309493104931149312493134931449315493164931749318493194932049321493224932349324493254932649327493284932949330493314933249333493344933549336493374933849339493404934149342493434934449345493464934749348493494935049351493524935349354493554935649357493584935949360493614936249363493644936549366493674936849369493704937149372493734937449375493764937749378493794938049381493824938349384493854938649387493884938949390493914939249393493944939549396493974939849399494004940149402494034940449405494064940749408494094941049411494124941349414494154941649417494184941949420494214942249423494244942549426494274942849429494304943149432494334943449435494364943749438494394944049441494424944349444494454944649447494484944949450494514945249453494544945549456494574945849459494604946149462494634946449465494664946749468494694947049471494724947349474494754947649477494784947949480494814948249483494844948549486494874948849489494904949149492494934949449495494964949749498494994950049501495024950349504495054950649507495084950949510495114951249513495144951549516495174951849519495204952149522495234952449525495264952749528495294953049531495324953349534495354953649537495384953949540495414954249543495444954549546495474954849549495504955149552495534955449555495564955749558495594956049561495624956349564495654956649567495684956949570495714957249573495744957549576495774957849579495804958149582495834958449585495864958749588495894959049591495924959349594495954959649597495984959949600496014960249603496044960549606496074960849609496104961149612496134961449615496164961749618496194962049621496224962349624496254962649627496284962949630496314963249633496344963549636496374963849639496404964149642496434964449645496464964749648496494965049651496524965349654496554965649657496584965949660496614966249663496644966549666496674966849669496704967149672496734967449675496764967749678496794968049681496824968349684496854968649687496884968949690496914969249693496944969549696496974969849699497004970149702497034970449705497064970749708497094971049711497124971349714497154971649717497184971949720497214972249723497244972549726497274972849729497304973149732497334973449735497364973749738497394974049741497424974349744497454974649747497484974949750497514975249753497544975549756497574975849759497604976149762497634976449765497664976749768497694977049771497724977349774497754977649777497784977949780497814978249783497844978549786497874978849789497904979149792497934979449795497964979749798497994980049801498024980349804498054980649807498084980949810498114981249813498144981549816498174981849819498204982149822498234982449825498264982749828498294983049831498324983349834498354983649837498384983949840498414984249843498444984549846498474984849849498504985149852498534985449855498564985749858498594986049861498624986349864498654986649867498684986949870498714987249873498744987549876498774987849879498804988149882498834988449885498864988749888498894989049891498924989349894498954989649897498984989949900499014990249903499044990549906499074990849909499104991149912499134991449915499164991749918499194992049921499224992349924499254992649927499284992949930499314993249933499344993549936499374993849939499404994149942499434994449945499464994749948499494995049951499524995349954499554995649957499584995949960499614996249963499644996549966499674996849969499704997149972499734997449975499764997749978499794998049981499824998349984499854998649987499884998949990499914999249993499944999549996499974999849999500005000150002500035000450005500065000750008500095001050011500125001350014500155001650017500185001950020500215002250023500245002550026500275002850029500305003150032500335003450035500365003750038500395004050041500425004350044500455004650047500485004950050500515005250053500545005550056500575005850059500605006150062500635006450065500665006750068500695007050071500725007350074500755007650077500785007950080500815008250083500845008550086500875008850089500905009150092500935009450095500965009750098500995010050101501025010350104501055010650107501085010950110501115011250113501145011550116501175011850119501205012150122501235012450125501265012750128501295013050131501325013350134501355013650137501385013950140501415014250143501445014550146501475014850149501505015150152501535015450155501565015750158501595016050161501625016350164501655016650167501685016950170501715017250173501745017550176501775017850179501805018150182501835018450185501865018750188501895019050191501925019350194501955019650197501985019950200502015020250203502045020550206502075020850209502105021150212502135021450215502165021750218502195022050221502225022350224502255022650227502285022950230502315023250233502345023550236502375023850239502405024150242502435024450245502465024750248502495025050251502525025350254502555025650257502585025950260502615026250263502645026550266502675026850269502705027150272502735027450275502765027750278502795028050281502825028350284502855028650287502885028950290502915029250293502945029550296502975029850299503005030150302503035030450305503065030750308503095031050311503125031350314503155031650317503185031950320503215032250323503245032550326503275032850329503305033150332503335033450335503365033750338503395034050341503425034350344503455034650347503485034950350503515035250353503545035550356503575035850359503605036150362503635036450365503665036750368503695037050371503725037350374503755037650377503785037950380503815038250383503845038550386503875038850389503905039150392503935039450395503965039750398503995040050401504025040350404504055040650407504085040950410504115041250413504145041550416504175041850419504205042150422504235042450425504265042750428504295043050431504325043350434504355043650437504385043950440504415044250443504445044550446504475044850449504505045150452504535045450455504565045750458504595046050461504625046350464504655046650467504685046950470504715047250473504745047550476504775047850479504805048150482504835048450485504865048750488504895049050491504925049350494504955049650497504985049950500505015050250503505045050550506505075050850509505105051150512505135051450515505165051750518505195052050521505225052350524505255052650527505285052950530505315053250533505345053550536505375053850539505405054150542505435054450545505465054750548505495055050551505525055350554505555055650557505585055950560505615056250563505645056550566505675056850569505705057150572505735057450575505765057750578505795058050581505825058350584505855058650587505885058950590505915059250593505945059550596505975059850599506005060150602506035060450605506065060750608506095061050611506125061350614506155061650617506185061950620506215062250623506245062550626506275062850629506305063150632506335063450635506365063750638506395064050641506425064350644506455064650647506485064950650506515065250653506545065550656506575065850659506605066150662506635066450665506665066750668506695067050671506725067350674506755067650677506785067950680506815068250683506845068550686506875068850689506905069150692506935069450695506965069750698506995070050701507025070350704507055070650707507085070950710507115071250713507145071550716507175071850719507205072150722507235072450725507265072750728507295073050731507325073350734507355073650737507385073950740507415074250743507445074550746507475074850749507505075150752507535075450755507565075750758507595076050761507625076350764507655076650767507685076950770507715077250773507745077550776507775077850779507805078150782507835078450785507865078750788507895079050791507925079350794507955079650797507985079950800508015080250803508045080550806508075080850809508105081150812508135081450815508165081750818508195082050821508225082350824508255082650827508285082950830508315083250833508345083550836508375083850839508405084150842508435084450845508465084750848508495085050851508525085350854508555085650857508585085950860508615086250863508645086550866508675086850869508705087150872508735087450875508765087750878508795088050881508825088350884508855088650887508885088950890508915089250893508945089550896508975089850899509005090150902509035090450905509065090750908509095091050911509125091350914509155091650917509185091950920509215092250923509245092550926509275092850929509305093150932509335093450935509365093750938509395094050941509425094350944509455094650947509485094950950509515095250953509545095550956509575095850959509605096150962509635096450965509665096750968509695097050971509725097350974509755097650977509785097950980509815098250983509845098550986509875098850989509905099150992509935099450995509965099750998509995100051001510025100351004510055100651007510085100951010510115101251013510145101551016510175101851019510205102151022510235102451025510265102751028510295103051031510325103351034510355103651037510385103951040510415104251043510445104551046510475104851049510505105151052510535105451055510565105751058510595106051061510625106351064510655106651067510685106951070510715107251073510745107551076510775107851079510805108151082510835108451085510865108751088510895109051091510925109351094510955109651097510985109951100511015110251103511045110551106511075110851109511105111151112511135111451115511165111751118511195112051121511225112351124511255112651127511285112951130511315113251133511345113551136511375113851139511405114151142511435114451145511465114751148511495115051151511525115351154511555115651157511585115951160511615116251163511645116551166511675116851169511705117151172511735117451175511765117751178511795118051181511825118351184511855118651187511885118951190511915119251193511945119551196511975119851199512005120151202512035120451205512065120751208512095121051211512125121351214512155121651217512185121951220512215122251223512245122551226512275122851229512305123151232512335123451235512365123751238512395124051241512425124351244512455124651247512485124951250512515125251253512545125551256512575125851259512605126151262512635126451265512665126751268512695127051271512725127351274512755127651277512785127951280512815128251283512845128551286512875128851289512905129151292512935129451295512965129751298512995130051301513025130351304513055130651307513085130951310513115131251313513145131551316513175131851319513205132151322513235132451325513265132751328513295133051331513325133351334513355133651337513385133951340513415134251343513445134551346513475134851349513505135151352513535135451355513565135751358513595136051361513625136351364513655136651367513685136951370513715137251373513745137551376513775137851379513805138151382513835138451385513865138751388513895139051391513925139351394513955139651397513985139951400514015140251403514045140551406514075140851409514105141151412514135141451415514165141751418514195142051421514225142351424514255142651427514285142951430514315143251433514345143551436514375143851439514405144151442514435144451445514465144751448514495145051451514525145351454514555145651457514585145951460514615146251463514645146551466514675146851469514705147151472514735147451475514765147751478514795148051481514825148351484514855148651487514885148951490514915149251493514945149551496514975149851499515005150151502515035150451505515065150751508515095151051511515125151351514515155151651517515185151951520515215152251523515245152551526515275152851529515305153151532515335153451535515365153751538515395154051541515425154351544515455154651547515485154951550515515155251553515545155551556515575155851559515605156151562515635156451565515665156751568515695157051571515725157351574515755157651577515785157951580515815158251583515845158551586515875158851589515905159151592515935159451595515965159751598515995160051601516025160351604516055160651607516085160951610516115161251613516145161551616516175161851619516205162151622516235162451625516265162751628516295163051631516325163351634516355163651637516385163951640516415164251643516445164551646516475164851649516505165151652516535165451655516565165751658516595166051661516625166351664516655166651667516685166951670516715167251673516745167551676516775167851679516805168151682516835168451685516865168751688516895169051691516925169351694516955169651697516985169951700517015170251703517045170551706517075170851709517105171151712517135171451715517165171751718517195172051721517225172351724517255172651727517285172951730517315173251733517345173551736517375173851739517405174151742517435174451745517465174751748517495175051751517525175351754517555175651757517585175951760517615176251763517645176551766517675176851769517705177151772517735177451775517765177751778517795178051781517825178351784517855178651787517885178951790517915179251793517945179551796517975179851799518005180151802518035180451805518065180751808518095181051811518125181351814518155181651817518185181951820518215182251823518245182551826518275182851829518305183151832518335183451835518365183751838518395184051841518425184351844518455184651847518485184951850518515185251853518545185551856518575185851859518605186151862518635186451865518665186751868518695187051871518725187351874518755187651877518785187951880518815188251883518845188551886518875188851889518905189151892518935189451895518965189751898518995190051901519025190351904519055190651907519085190951910519115191251913519145191551916519175191851919519205192151922519235192451925519265192751928519295193051931519325193351934519355193651937519385193951940519415194251943519445194551946519475194851949519505195151952519535195451955519565195751958519595196051961519625196351964519655196651967519685196951970519715197251973519745197551976519775197851979519805198151982519835198451985519865198751988519895199051991519925199351994519955199651997519985199952000520015200252003520045200552006520075200852009520105201152012520135201452015520165201752018520195202052021520225202352024520255202652027520285202952030520315203252033520345203552036520375203852039520405204152042520435204452045520465204752048520495205052051520525205352054520555205652057520585205952060520615206252063520645206552066520675206852069520705207152072520735207452075520765207752078520795208052081520825208352084520855208652087520885208952090520915209252093520945209552096520975209852099521005210152102521035210452105521065210752108521095211052111521125211352114521155211652117521185211952120521215212252123521245212552126521275212852129521305213152132521335213452135521365213752138521395214052141521425214352144521455214652147521485214952150521515215252153521545215552156521575215852159521605216152162521635216452165521665216752168521695217052171521725217352174521755217652177521785217952180521815218252183521845218552186521875218852189521905219152192521935219452195521965219752198521995220052201522025220352204522055220652207522085220952210522115221252213522145221552216522175221852219522205222152222522235222452225522265222752228522295223052231522325223352234522355223652237522385223952240522415224252243522445224552246522475224852249522505225152252522535225452255522565225752258522595226052261522625226352264522655226652267522685226952270522715227252273522745227552276522775227852279522805228152282522835228452285522865228752288522895229052291522925229352294522955229652297522985229952300523015230252303523045230552306523075230852309523105231152312523135231452315523165231752318523195232052321523225232352324523255232652327523285232952330523315233252333523345233552336523375233852339523405234152342523435234452345523465234752348523495235052351523525235352354523555235652357523585235952360523615236252363523645236552366523675236852369523705237152372523735237452375523765237752378523795238052381523825238352384523855238652387523885238952390523915239252393523945239552396523975239852399524005240152402524035240452405524065240752408524095241052411524125241352414524155241652417524185241952420524215242252423524245242552426524275242852429524305243152432524335243452435524365243752438524395244052441524425244352444524455244652447524485244952450524515245252453524545245552456524575245852459524605246152462524635246452465524665246752468524695247052471524725247352474524755247652477524785247952480524815248252483524845248552486524875248852489524905249152492524935249452495524965249752498524995250052501525025250352504525055250652507525085250952510525115251252513525145251552516525175251852519525205252152522525235252452525525265252752528525295253052531525325253352534525355253652537525385253952540525415254252543525445254552546525475254852549525505255152552525535255452555525565255752558525595256052561525625256352564525655256652567525685256952570525715257252573525745257552576525775257852579525805258152582525835258452585525865258752588525895259052591525925259352594525955259652597525985259952600526015260252603526045260552606526075260852609526105261152612526135261452615526165261752618526195262052621526225262352624526255262652627526285262952630526315263252633526345263552636526375263852639526405264152642526435264452645526465264752648526495265052651526525265352654526555265652657526585265952660526615266252663526645266552666526675266852669526705267152672526735267452675526765267752678526795268052681526825268352684526855268652687526885268952690526915269252693526945269552696526975269852699527005270152702527035270452705527065270752708527095271052711527125271352714527155271652717527185271952720527215272252723527245272552726527275272852729527305273152732527335273452735527365273752738527395274052741527425274352744527455274652747527485274952750527515275252753527545275552756527575275852759527605276152762527635276452765527665276752768527695277052771527725277352774527755277652777527785277952780527815278252783527845278552786527875278852789527905279152792527935279452795527965279752798527995280052801528025280352804528055280652807528085280952810528115281252813528145281552816528175281852819528205282152822528235282452825528265282752828528295283052831528325283352834528355283652837528385283952840528415284252843528445284552846528475284852849528505285152852528535285452855528565285752858528595286052861528625286352864528655286652867528685286952870528715287252873528745287552876528775287852879528805288152882528835288452885528865288752888528895289052891528925289352894528955289652897528985289952900529015290252903529045290552906529075290852909529105291152912529135291452915529165291752918529195292052921529225292352924529255292652927529285292952930529315293252933529345293552936529375293852939529405294152942529435294452945529465294752948529495295052951529525295352954529555295652957529585295952960529615296252963529645296552966529675296852969529705297152972529735297452975529765297752978529795298052981529825298352984529855298652987529885298952990529915299252993529945299552996529975299852999530005300153002530035300453005530065300753008530095301053011530125301353014530155301653017530185301953020530215302253023530245302553026530275302853029530305303153032530335303453035530365303753038530395304053041530425304353044530455304653047530485304953050530515305253053530545305553056530575305853059530605306153062530635306453065530665306753068530695307053071530725307353074530755307653077530785307953080530815308253083530845308553086530875308853089530905309153092530935309453095530965309753098530995310053101531025310353104531055310653107531085310953110531115311253113531145311553116531175311853119531205312153122531235312453125531265312753128531295313053131531325313353134531355313653137531385313953140531415314253143531445314553146531475314853149531505315153152531535315453155531565315753158531595316053161531625316353164531655316653167531685316953170531715317253173531745317553176531775317853179531805318153182531835318453185531865318753188531895319053191531925319353194531955319653197531985319953200532015320253203532045320553206532075320853209532105321153212532135321453215532165321753218532195322053221532225322353224532255322653227532285322953230532315323253233532345323553236532375323853239532405324153242532435324453245532465324753248532495325053251532525325353254532555325653257532585325953260532615326253263532645326553266532675326853269532705327153272532735327453275532765327753278532795328053281532825328353284532855328653287532885328953290532915329253293532945329553296532975329853299533005330153302533035330453305533065330753308533095331053311533125331353314533155331653317533185331953320533215332253323533245332553326533275332853329533305333153332533335333453335533365333753338533395334053341533425334353344533455334653347533485334953350533515335253353533545335553356533575335853359533605336153362533635336453365533665336753368533695337053371533725337353374533755337653377533785337953380533815338253383533845338553386533875338853389533905339153392533935339453395533965339753398533995340053401534025340353404534055340653407534085340953410534115341253413534145341553416534175341853419534205342153422534235342453425534265342753428534295343053431534325343353434534355343653437534385343953440534415344253443534445344553446534475344853449534505345153452534535345453455534565345753458534595346053461534625346353464534655346653467534685346953470534715347253473534745347553476534775347853479534805348153482534835348453485534865348753488534895349053491534925349353494534955349653497534985349953500535015350253503535045350553506535075350853509535105351153512535135351453515535165351753518535195352053521535225352353524535255352653527535285352953530535315353253533535345353553536535375353853539535405354153542535435354453545535465354753548535495355053551535525355353554535555355653557535585355953560535615356253563535645356553566535675356853569535705357153572535735357453575535765357753578535795358053581535825358353584535855358653587535885358953590535915359253593535945359553596535975359853599536005360153602536035360453605536065360753608536095361053611536125361353614536155361653617536185361953620536215362253623536245362553626536275362853629536305363153632536335363453635536365363753638536395364053641536425364353644536455364653647536485364953650536515365253653536545365553656536575365853659536605366153662536635366453665536665366753668536695367053671536725367353674536755367653677536785367953680536815368253683536845368553686536875368853689536905369153692536935369453695536965369753698536995370053701537025370353704537055370653707537085370953710537115371253713537145371553716537175371853719537205372153722537235372453725537265372753728537295373053731537325373353734537355373653737537385373953740537415374253743537445374553746537475374853749537505375153752537535375453755537565375753758537595376053761537625376353764537655376653767537685376953770537715377253773537745377553776537775377853779537805378153782537835378453785537865378753788537895379053791537925379353794537955379653797537985379953800538015380253803538045380553806538075380853809538105381153812538135381453815538165381753818538195382053821538225382353824538255382653827538285382953830538315383253833538345383553836538375383853839538405384153842538435384453845538465384753848538495385053851538525385353854538555385653857538585385953860538615386253863538645386553866538675386853869538705387153872538735387453875538765387753878538795388053881538825388353884538855388653887538885388953890538915389253893538945389553896538975389853899539005390153902539035390453905539065390753908539095391053911539125391353914539155391653917539185391953920539215392253923539245392553926539275392853929539305393153932539335393453935539365393753938539395394053941539425394353944539455394653947539485394953950539515395253953539545395553956539575395853959539605396153962539635396453965539665396753968539695397053971539725397353974539755397653977539785397953980539815398253983539845398553986539875398853989539905399153992539935399453995539965399753998539995400054001540025400354004540055400654007540085400954010540115401254013540145401554016540175401854019540205402154022540235402454025540265402754028540295403054031540325403354034540355403654037540385403954040540415404254043540445404554046540475404854049540505405154052540535405454055540565405754058540595406054061540625406354064540655406654067540685406954070540715407254073540745407554076540775407854079540805408154082540835408454085540865408754088540895409054091540925409354094540955409654097540985409954100541015410254103541045410554106541075410854109541105411154112541135411454115541165411754118541195412054121541225412354124541255412654127541285412954130541315413254133541345413554136541375413854139541405414154142541435414454145541465414754148541495415054151541525415354154541555415654157541585415954160541615416254163541645416554166541675416854169541705417154172541735417454175541765417754178541795418054181541825418354184541855418654187541885418954190541915419254193541945419554196541975419854199542005420154202542035420454205542065420754208542095421054211542125421354214542155421654217542185421954220542215422254223542245422554226542275422854229542305423154232542335423454235542365423754238542395424054241542425424354244542455424654247542485424954250542515425254253542545425554256542575425854259542605426154262542635426454265542665426754268542695427054271542725427354274542755427654277542785427954280542815428254283542845428554286542875428854289542905429154292542935429454295542965429754298542995430054301543025430354304543055430654307543085430954310543115431254313543145431554316543175431854319543205432154322543235432454325543265432754328543295433054331543325433354334543355433654337543385433954340543415434254343543445434554346543475434854349543505435154352543535435454355543565435754358543595436054361543625436354364543655436654367543685436954370543715437254373543745437554376543775437854379543805438154382543835438454385543865438754388543895439054391543925439354394543955439654397543985439954400544015440254403544045440554406544075440854409544105441154412544135441454415544165441754418544195442054421544225442354424544255442654427544285442954430544315443254433544345443554436544375443854439544405444154442544435444454445544465444754448544495445054451544525445354454544555445654457544585445954460544615446254463544645446554466544675446854469544705447154472544735447454475544765447754478544795448054481544825448354484544855448654487544885448954490544915449254493544945449554496544975449854499545005450154502545035450454505545065450754508545095451054511545125451354514545155451654517545185451954520545215452254523545245452554526545275452854529545305453154532545335453454535545365453754538545395454054541545425454354544545455454654547545485454954550545515455254553545545455554556545575455854559545605456154562545635456454565545665456754568545695457054571545725457354574545755457654577545785457954580545815458254583545845458554586545875458854589545905459154592545935459454595545965459754598545995460054601546025460354604546055460654607546085460954610546115461254613546145461554616546175461854619546205462154622546235462454625546265462754628546295463054631546325463354634546355463654637546385463954640546415464254643546445464554646546475464854649546505465154652546535465454655546565465754658546595466054661546625466354664546655466654667546685466954670546715467254673546745467554676546775467854679546805468154682546835468454685546865468754688546895469054691546925469354694546955469654697546985469954700547015470254703547045470554706547075470854709547105471154712547135471454715547165471754718547195472054721547225472354724547255472654727547285472954730547315473254733547345473554736547375473854739547405474154742547435474454745547465474754748547495475054751547525475354754547555475654757547585475954760547615476254763547645476554766547675476854769547705477154772547735477454775547765477754778547795478054781547825478354784547855478654787547885478954790547915479254793547945479554796547975479854799548005480154802548035480454805548065480754808548095481054811548125481354814548155481654817548185481954820548215482254823548245482554826548275482854829548305483154832548335483454835548365483754838548395484054841548425484354844548455484654847548485484954850548515485254853548545485554856548575485854859548605486154862548635486454865548665486754868548695487054871548725487354874548755487654877548785487954880548815488254883548845488554886548875488854889548905489154892548935489454895548965489754898548995490054901549025490354904549055490654907549085490954910549115491254913549145491554916549175491854919549205492154922549235492454925549265492754928549295493054931549325493354934549355493654937549385493954940549415494254943549445494554946549475494854949549505495154952549535495454955549565495754958549595496054961549625496354964549655496654967549685496954970549715497254973549745497554976549775497854979549805498154982549835498454985549865498754988549895499054991549925499354994549955499654997549985499955000550015500255003550045500555006550075500855009550105501155012550135501455015550165501755018550195502055021550225502355024550255502655027550285502955030550315503255033550345503555036550375503855039550405504155042550435504455045550465504755048550495505055051550525505355054550555505655057550585505955060550615506255063550645506555066550675506855069550705507155072550735507455075550765507755078550795508055081550825508355084550855508655087550885508955090550915509255093550945509555096550975509855099551005510155102551035510455105551065510755108551095511055111551125511355114551155511655117551185511955120551215512255123551245512555126551275512855129551305513155132551335513455135551365513755138551395514055141551425514355144551455514655147551485514955150551515515255153551545515555156551575515855159551605516155162551635516455165551665516755168551695517055171551725517355174551755517655177551785517955180551815518255183551845518555186551875518855189551905519155192551935519455195551965519755198551995520055201552025520355204552055520655207552085520955210552115521255213552145521555216552175521855219552205522155222552235522455225552265522755228552295523055231552325523355234552355523655237552385523955240552415524255243552445524555246552475524855249552505525155252552535525455255552565525755258552595526055261552625526355264552655526655267552685526955270552715527255273552745527555276552775527855279552805528155282552835528455285552865528755288552895529055291552925529355294552955529655297552985529955300553015530255303553045530555306553075530855309553105531155312553135531455315553165531755318553195532055321553225532355324553255532655327553285532955330553315533255333553345533555336553375533855339553405534155342553435534455345553465534755348553495535055351553525535355354553555535655357553585535955360553615536255363553645536555366553675536855369553705537155372553735537455375553765537755378553795538055381553825538355384553855538655387553885538955390553915539255393553945539555396553975539855399554005540155402554035540455405554065540755408554095541055411554125541355414554155541655417554185541955420554215542255423554245542555426554275542855429554305543155432554335543455435554365543755438554395544055441554425544355444554455544655447554485544955450554515545255453554545545555456554575545855459554605546155462554635546455465554665546755468554695547055471554725547355474554755547655477554785547955480554815548255483554845548555486554875548855489554905549155492554935549455495554965549755498554995550055501555025550355504555055550655507555085550955510555115551255513555145551555516555175551855519555205552155522555235552455525555265552755528555295553055531555325553355534555355553655537555385553955540555415554255543555445554555546555475554855549555505555155552555535555455555555565555755558555595556055561555625556355564555655556655567555685556955570555715557255573555745557555576555775557855579555805558155582555835558455585555865558755588555895559055591555925559355594555955559655597555985559955600556015560255603556045560555606556075560855609556105561155612556135561455615556165561755618556195562055621556225562355624556255562655627556285562955630556315563255633556345563555636556375563855639556405564155642556435564455645556465564755648556495565055651556525565355654556555565655657556585565955660556615566255663556645566555666556675566855669556705567155672556735567455675556765567755678556795568055681556825568355684556855568655687556885568955690556915569255693556945569555696556975569855699557005570155702557035570455705557065570755708557095571055711557125571355714557155571655717557185571955720557215572255723557245572555726557275572855729557305573155732557335573455735557365573755738557395574055741557425574355744557455574655747557485574955750557515575255753557545575555756557575575855759557605576155762557635576455765557665576755768557695577055771557725577355774557755577655777557785577955780557815578255783557845578555786557875578855789557905579155792557935579455795557965579755798557995580055801558025580355804558055580655807558085580955810558115581255813558145581555816558175581855819558205582155822558235582455825558265582755828558295583055831558325583355834558355583655837558385583955840558415584255843558445584555846558475584855849558505585155852558535585455855558565585755858558595586055861558625586355864558655586655867558685586955870558715587255873558745587555876558775587855879558805588155882558835588455885558865588755888558895589055891558925589355894558955589655897558985589955900559015590255903559045590555906559075590855909559105591155912559135591455915559165591755918559195592055921559225592355924559255592655927559285592955930559315593255933559345593555936559375593855939559405594155942559435594455945559465594755948559495595055951559525595355954559555595655957559585595955960559615596255963559645596555966559675596855969559705597155972559735597455975559765597755978559795598055981559825598355984559855598655987559885598955990559915599255993559945599555996559975599855999560005600156002560035600456005560065600756008560095601056011560125601356014560155601656017560185601956020560215602256023560245602556026560275602856029560305603156032560335603456035560365603756038560395604056041560425604356044560455604656047560485604956050560515605256053560545605556056560575605856059560605606156062560635606456065560665606756068560695607056071560725607356074560755607656077560785607956080560815608256083560845608556086560875608856089560905609156092560935609456095560965609756098560995610056101561025610356104561055610656107561085610956110561115611256113561145611556116561175611856119561205612156122561235612456125561265612756128561295613056131561325613356134561355613656137561385613956140561415614256143561445614556146561475614856149561505615156152561535615456155561565615756158561595616056161561625616356164561655616656167561685616956170561715617256173561745617556176561775617856179561805618156182561835618456185561865618756188561895619056191561925619356194561955619656197561985619956200562015620256203562045620556206562075620856209562105621156212562135621456215562165621756218562195622056221562225622356224562255622656227562285622956230562315623256233562345623556236562375623856239562405624156242562435624456245562465624756248562495625056251562525625356254562555625656257562585625956260562615626256263562645626556266562675626856269562705627156272562735627456275562765627756278562795628056281562825628356284562855628656287562885628956290562915629256293562945629556296562975629856299563005630156302563035630456305563065630756308563095631056311563125631356314563155631656317563185631956320563215632256323563245632556326563275632856329563305633156332563335633456335563365633756338563395634056341563425634356344563455634656347563485634956350563515635256353563545635556356563575635856359563605636156362563635636456365563665636756368563695637056371563725637356374563755637656377563785637956380563815638256383563845638556386563875638856389563905639156392563935639456395563965639756398563995640056401564025640356404564055640656407564085640956410564115641256413564145641556416564175641856419564205642156422564235642456425564265642756428564295643056431564325643356434564355643656437564385643956440564415644256443564445644556446564475644856449564505645156452564535645456455564565645756458564595646056461564625646356464564655646656467564685646956470564715647256473564745647556476564775647856479564805648156482564835648456485564865648756488564895649056491564925649356494564955649656497564985649956500565015650256503565045650556506565075650856509565105651156512565135651456515565165651756518565195652056521565225652356524565255652656527565285652956530565315653256533565345653556536565375653856539565405654156542565435654456545565465654756548565495655056551565525655356554565555655656557565585655956560565615656256563565645656556566565675656856569565705657156572565735657456575565765657756578565795658056581565825658356584565855658656587565885658956590565915659256593565945659556596565975659856599566005660156602566035660456605566065660756608566095661056611566125661356614566155661656617566185661956620566215662256623566245662556626566275662856629566305663156632566335663456635566365663756638566395664056641566425664356644566455664656647566485664956650566515665256653566545665556656566575665856659566605666156662566635666456665566665666756668566695667056671566725667356674566755667656677566785667956680566815668256683566845668556686566875668856689566905669156692566935669456695566965669756698566995670056701567025670356704567055670656707567085670956710567115671256713567145671556716567175671856719567205672156722567235672456725567265672756728567295673056731567325673356734567355673656737567385673956740567415674256743567445674556746567475674856749567505675156752567535675456755567565675756758567595676056761567625676356764567655676656767567685676956770567715677256773567745677556776567775677856779567805678156782567835678456785567865678756788567895679056791567925679356794567955679656797567985679956800568015680256803568045680556806568075680856809568105681156812568135681456815568165681756818568195682056821568225682356824568255682656827568285682956830568315683256833568345683556836568375683856839568405684156842568435684456845568465684756848568495685056851568525685356854568555685656857568585685956860568615686256863568645686556866568675686856869568705687156872568735687456875568765687756878568795688056881568825688356884568855688656887568885688956890568915689256893568945689556896568975689856899569005690156902569035690456905569065690756908569095691056911569125691356914569155691656917569185691956920569215692256923569245692556926569275692856929569305693156932569335693456935569365693756938569395694056941569425694356944569455694656947569485694956950569515695256953569545695556956569575695856959569605696156962569635696456965569665696756968569695697056971569725697356974569755697656977569785697956980569815698256983569845698556986569875698856989569905699156992569935699456995569965699756998569995700057001570025700357004570055700657007570085700957010570115701257013570145701557016570175701857019570205702157022570235702457025570265702757028570295703057031570325703357034570355703657037570385703957040570415704257043570445704557046570475704857049570505705157052570535705457055570565705757058570595706057061570625706357064570655706657067570685706957070570715707257073570745707557076570775707857079570805708157082570835708457085570865708757088570895709057091570925709357094570955709657097570985709957100571015710257103571045710557106571075710857109571105711157112571135711457115571165711757118571195712057121571225712357124571255712657127571285712957130571315713257133571345713557136571375713857139571405714157142571435714457145571465714757148571495715057151571525715357154571555715657157571585715957160571615716257163571645716557166571675716857169571705717157172571735717457175571765717757178571795718057181571825718357184571855718657187571885718957190571915719257193571945719557196571975719857199572005720157202572035720457205572065720757208572095721057211572125721357214572155721657217572185721957220572215722257223572245722557226572275722857229572305723157232572335723457235572365723757238572395724057241572425724357244572455724657247572485724957250572515725257253572545725557256572575725857259572605726157262572635726457265572665726757268572695727057271572725727357274572755727657277572785727957280572815728257283572845728557286572875728857289572905729157292572935729457295572965729757298572995730057301573025730357304
  1. /* Copyright 2017 Mozilla Foundation
  2. *
  3. * Licensed under the Apache License, Version 2.0 (the "License");
  4. * you may not use this file except in compliance with the License.
  5. * You may obtain a copy of the License at
  6. *
  7. * http://www.apache.org/licenses/LICENSE-2.0
  8. *
  9. * Unless required by applicable law or agreed to in writing, software
  10. * distributed under the License is distributed on an "AS IS" BASIS,
  11. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. * See the License for the specific language governing permissions and
  13. * limitations under the License.
  14. */
  15. (function webpackUniversalModuleDefinition(root, factory) {
  16. if(typeof exports === 'object' && typeof module === 'object')
  17. module.exports = factory();
  18. else if(typeof define === 'function' && define.amd)
  19. define("pdfjs-dist/build/pdf.combined", [], factory);
  20. else if(typeof exports === 'object')
  21. exports["pdfjs-dist/build/pdf.combined"] = factory();
  22. else
  23. root["pdfjs-dist/build/pdf.combined"] = root.pdfjsDistBuildPdfCombined = factory();
  24. })(this, function() {
  25. return /******/ (function(modules) { // webpackBootstrap
  26. /******/ // The module cache
  27. /******/ var installedModules = {};
  28. /******/ // The require function
  29. /******/ function __w_pdfjs_require__(moduleId) {
  30. /******/ // Check if module is in cache
  31. /******/ if(installedModules[moduleId])
  32. /******/ return installedModules[moduleId].exports;
  33. /******/ // Create a new module (and put it into the cache)
  34. /******/ var module = installedModules[moduleId] = {
  35. /******/ i: moduleId,
  36. /******/ l: false,
  37. /******/ exports: {}
  38. /******/ };
  39. /******/ // Execute the module function
  40. /******/ modules[moduleId].call(module.exports, module, module.exports, __w_pdfjs_require__);
  41. /******/ // Flag the module as loaded
  42. /******/ module.l = true;
  43. /******/ // Return the exports of the module
  44. /******/ return module.exports;
  45. /******/ }
  46. /******/ // expose the modules object (__webpack_modules__)
  47. /******/ __w_pdfjs_require__.m = modules;
  48. /******/ // expose the module cache
  49. /******/ __w_pdfjs_require__.c = installedModules;
  50. /******/ // identity function for calling harmony imports with the correct context
  51. /******/ __w_pdfjs_require__.i = function(value) { return value; };
  52. /******/ // define getter function for harmony exports
  53. /******/ __w_pdfjs_require__.d = function(exports, name, getter) {
  54. /******/ if(!__w_pdfjs_require__.o(exports, name)) {
  55. /******/ Object.defineProperty(exports, name, {
  56. /******/ configurable: false,
  57. /******/ enumerable: true,
  58. /******/ get: getter
  59. /******/ });
  60. /******/ }
  61. /******/ };
  62. /******/ // getDefaultExport function for compatibility with non-harmony modules
  63. /******/ __w_pdfjs_require__.n = function(module) {
  64. /******/ var getter = module && module.__esModule ?
  65. /******/ function getDefault() { return module['default']; } :
  66. /******/ function getModuleExports() { return module; };
  67. /******/ __w_pdfjs_require__.d(getter, 'a', getter);
  68. /******/ return getter;
  69. /******/ };
  70. /******/ // Object.prototype.hasOwnProperty.call
  71. /******/ __w_pdfjs_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
  72. /******/ // __webpack_public_path__
  73. /******/ __w_pdfjs_require__.p = "";
  74. /******/ // Load entry module and return exports
  75. /******/ return __w_pdfjs_require__(__w_pdfjs_require__.s = 47);
  76. /******/ })
  77. /************************************************************************/
  78. /******/ ([
  79. /* 0 */
  80. /***/ (function(module, exports, __w_pdfjs_require__) {
  81. "use strict";
  82. /* WEBPACK VAR INJECTION */(function(global) {
  83. var globalScope = typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : this;
  84. var FONT_IDENTITY_MATRIX = [
  85. 0.001,
  86. 0,
  87. 0,
  88. 0.001,
  89. 0,
  90. 0
  91. ];
  92. var TextRenderingMode = {
  93. FILL: 0,
  94. STROKE: 1,
  95. FILL_STROKE: 2,
  96. INVISIBLE: 3,
  97. FILL_ADD_TO_PATH: 4,
  98. STROKE_ADD_TO_PATH: 5,
  99. FILL_STROKE_ADD_TO_PATH: 6,
  100. ADD_TO_PATH: 7,
  101. FILL_STROKE_MASK: 3,
  102. ADD_TO_PATH_FLAG: 4
  103. };
  104. var ImageKind = {
  105. GRAYSCALE_1BPP: 1,
  106. RGB_24BPP: 2,
  107. RGBA_32BPP: 3
  108. };
  109. var AnnotationType = {
  110. TEXT: 1,
  111. LINK: 2,
  112. FREETEXT: 3,
  113. LINE: 4,
  114. SQUARE: 5,
  115. CIRCLE: 6,
  116. POLYGON: 7,
  117. POLYLINE: 8,
  118. HIGHLIGHT: 9,
  119. UNDERLINE: 10,
  120. SQUIGGLY: 11,
  121. STRIKEOUT: 12,
  122. STAMP: 13,
  123. CARET: 14,
  124. INK: 15,
  125. POPUP: 16,
  126. FILEATTACHMENT: 17,
  127. SOUND: 18,
  128. MOVIE: 19,
  129. WIDGET: 20,
  130. SCREEN: 21,
  131. PRINTERMARK: 22,
  132. TRAPNET: 23,
  133. WATERMARK: 24,
  134. THREED: 25,
  135. REDACT: 26
  136. };
  137. var AnnotationFlag = {
  138. INVISIBLE: 0x01,
  139. HIDDEN: 0x02,
  140. PRINT: 0x04,
  141. NOZOOM: 0x08,
  142. NOROTATE: 0x10,
  143. NOVIEW: 0x20,
  144. READONLY: 0x40,
  145. LOCKED: 0x80,
  146. TOGGLENOVIEW: 0x100,
  147. LOCKEDCONTENTS: 0x200
  148. };
  149. var AnnotationFieldFlag = {
  150. READONLY: 0x0000001,
  151. REQUIRED: 0x0000002,
  152. NOEXPORT: 0x0000004,
  153. MULTILINE: 0x0001000,
  154. PASSWORD: 0x0002000,
  155. NOTOGGLETOOFF: 0x0004000,
  156. RADIO: 0x0008000,
  157. PUSHBUTTON: 0x0010000,
  158. COMBO: 0x0020000,
  159. EDIT: 0x0040000,
  160. SORT: 0x0080000,
  161. FILESELECT: 0x0100000,
  162. MULTISELECT: 0x0200000,
  163. DONOTSPELLCHECK: 0x0400000,
  164. DONOTSCROLL: 0x0800000,
  165. COMB: 0x1000000,
  166. RICHTEXT: 0x2000000,
  167. RADIOSINUNISON: 0x2000000,
  168. COMMITONSELCHANGE: 0x4000000
  169. };
  170. var AnnotationBorderStyleType = {
  171. SOLID: 1,
  172. DASHED: 2,
  173. BEVELED: 3,
  174. INSET: 4,
  175. UNDERLINE: 5
  176. };
  177. var StreamType = {
  178. UNKNOWN: 0,
  179. FLATE: 1,
  180. LZW: 2,
  181. DCT: 3,
  182. JPX: 4,
  183. JBIG: 5,
  184. A85: 6,
  185. AHX: 7,
  186. CCF: 8,
  187. RL: 9
  188. };
  189. var FontType = {
  190. UNKNOWN: 0,
  191. TYPE1: 1,
  192. TYPE1C: 2,
  193. CIDFONTTYPE0: 3,
  194. CIDFONTTYPE0C: 4,
  195. TRUETYPE: 5,
  196. CIDFONTTYPE2: 6,
  197. TYPE3: 7,
  198. OPENTYPE: 8,
  199. TYPE0: 9,
  200. MMTYPE1: 10
  201. };
  202. var VERBOSITY_LEVELS = {
  203. errors: 0,
  204. warnings: 1,
  205. infos: 5
  206. };
  207. var 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__(35);
  2531. var coreJpg = __w_pdfjs_require__(36);
  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. this.nextChar();
  13246. error('Illegal character: ' + ch);
  13247. break;
  13248. }
  13249. var str = String.fromCharCode(ch);
  13250. var knownCommands = this.knownCommands;
  13251. var knownCommandFound = knownCommands && knownCommands[str] !== undefined;
  13252. while ((ch = this.nextChar()) >= 0 && !specialChars[ch]) {
  13253. var possibleCommand = str + String.fromCharCode(ch);
  13254. if (knownCommandFound && knownCommands[possibleCommand] === undefined) {
  13255. break;
  13256. }
  13257. if (str.length === 128) {
  13258. error('Command token too long: ' + str.length);
  13259. }
  13260. str = possibleCommand;
  13261. knownCommandFound = knownCommands && knownCommands[str] !== undefined;
  13262. }
  13263. if (str === 'true') {
  13264. return true;
  13265. }
  13266. if (str === 'false') {
  13267. return false;
  13268. }
  13269. if (str === 'null') {
  13270. return null;
  13271. }
  13272. return Cmd.get(str);
  13273. },
  13274. skipToNextLine: function Lexer_skipToNextLine() {
  13275. var ch = this.currentChar;
  13276. while (ch >= 0) {
  13277. if (ch === 0x0D) {
  13278. ch = this.nextChar();
  13279. if (ch === 0x0A) {
  13280. this.nextChar();
  13281. }
  13282. break;
  13283. } else if (ch === 0x0A) {
  13284. this.nextChar();
  13285. break;
  13286. }
  13287. ch = this.nextChar();
  13288. }
  13289. }
  13290. };
  13291. return Lexer;
  13292. }();
  13293. var Linearization = {
  13294. create: function LinearizationCreate(stream) {
  13295. function getInt(name, allowZeroValue) {
  13296. var obj = linDict.get(name);
  13297. if (isInt(obj) && (allowZeroValue ? obj >= 0 : obj > 0)) {
  13298. return obj;
  13299. }
  13300. throw new Error('The "' + name + '" parameter in the linearization ' + 'dictionary is invalid.');
  13301. }
  13302. function getHints() {
  13303. var hints = linDict.get('H'), hintsLength, item;
  13304. if (isArray(hints) && ((hintsLength = hints.length) === 2 || hintsLength === 4)) {
  13305. for (var index = 0; index < hintsLength; index++) {
  13306. if (!(isInt(item = hints[index]) && item > 0)) {
  13307. throw new Error('Hint (' + index + ') in the linearization dictionary is invalid.');
  13308. }
  13309. }
  13310. return hints;
  13311. }
  13312. throw new Error('Hint array in the linearization dictionary is invalid.');
  13313. }
  13314. var parser = new Parser(new Lexer(stream), false, null);
  13315. var obj1 = parser.getObj();
  13316. var obj2 = parser.getObj();
  13317. var obj3 = parser.getObj();
  13318. var linDict = parser.getObj();
  13319. var obj, length;
  13320. if (!(isInt(obj1) && isInt(obj2) && isCmd(obj3, 'obj') && isDict(linDict) && isNum(obj = linDict.get('Linearized')) && obj > 0)) {
  13321. return null;
  13322. } else if ((length = getInt('L')) !== stream.length) {
  13323. throw new Error('The "L" parameter in the linearization dictionary ' + 'does not equal the stream length.');
  13324. }
  13325. return {
  13326. length: length,
  13327. hints: getHints(),
  13328. objectNumberFirst: getInt('O'),
  13329. endFirst: getInt('E'),
  13330. numPages: getInt('N'),
  13331. mainXRefEntriesOffset: getInt('T'),
  13332. pageFirst: linDict.has('P') ? getInt('P', true) : 0
  13333. };
  13334. }
  13335. };
  13336. exports.Lexer = Lexer;
  13337. exports.Linearization = Linearization;
  13338. exports.Parser = Parser;
  13339. /***/ }),
  13340. /* 7 */
  13341. /***/ (function(module, exports, __w_pdfjs_require__) {
  13342. "use strict";
  13343. var sharedUtil = __w_pdfjs_require__(0);
  13344. var corePrimitives = __w_pdfjs_require__(1);
  13345. var corePsParser = __w_pdfjs_require__(42);
  13346. var error = sharedUtil.error;
  13347. var info = sharedUtil.info;
  13348. var isArray = sharedUtil.isArray;
  13349. var isBool = sharedUtil.isBool;
  13350. var isDict = corePrimitives.isDict;
  13351. var isStream = corePrimitives.isStream;
  13352. var PostScriptLexer = corePsParser.PostScriptLexer;
  13353. var PostScriptParser = corePsParser.PostScriptParser;
  13354. var PDFFunction = function PDFFunctionClosure() {
  13355. var CONSTRUCT_SAMPLED = 0;
  13356. var CONSTRUCT_INTERPOLATED = 2;
  13357. var CONSTRUCT_STICHED = 3;
  13358. var CONSTRUCT_POSTSCRIPT = 4;
  13359. return {
  13360. getSampleArray: function PDFFunction_getSampleArray(size, outputSize, bps, str) {
  13361. var i, ii;
  13362. var length = 1;
  13363. for (i = 0, ii = size.length; i < ii; i++) {
  13364. length *= size[i];
  13365. }
  13366. length *= outputSize;
  13367. var array = new Array(length);
  13368. var codeSize = 0;
  13369. var codeBuf = 0;
  13370. var sampleMul = 1.0 / (Math.pow(2.0, bps) - 1);
  13371. var strBytes = str.getBytes((length * bps + 7) / 8);
  13372. var strIdx = 0;
  13373. for (i = 0; i < length; i++) {
  13374. while (codeSize < bps) {
  13375. codeBuf <<= 8;
  13376. codeBuf |= strBytes[strIdx++];
  13377. codeSize += 8;
  13378. }
  13379. codeSize -= bps;
  13380. array[i] = (codeBuf >> codeSize) * sampleMul;
  13381. codeBuf &= (1 << codeSize) - 1;
  13382. }
  13383. return array;
  13384. },
  13385. getIR: function PDFFunction_getIR(xref, fn) {
  13386. var dict = fn.dict;
  13387. if (!dict) {
  13388. dict = fn;
  13389. }
  13390. var types = [
  13391. this.constructSampled,
  13392. null,
  13393. this.constructInterpolated,
  13394. this.constructStiched,
  13395. this.constructPostScript
  13396. ];
  13397. var typeNum = dict.get('FunctionType');
  13398. var typeFn = types[typeNum];
  13399. if (!typeFn) {
  13400. error('Unknown type of function');
  13401. }
  13402. return typeFn.call(this, fn, dict, xref);
  13403. },
  13404. fromIR: function PDFFunction_fromIR(IR) {
  13405. var type = IR[0];
  13406. switch (type) {
  13407. case CONSTRUCT_SAMPLED:
  13408. return this.constructSampledFromIR(IR);
  13409. case CONSTRUCT_INTERPOLATED:
  13410. return this.constructInterpolatedFromIR(IR);
  13411. case CONSTRUCT_STICHED:
  13412. return this.constructStichedFromIR(IR);
  13413. default:
  13414. return this.constructPostScriptFromIR(IR);
  13415. }
  13416. },
  13417. parse: function PDFFunction_parse(xref, fn) {
  13418. var IR = this.getIR(xref, fn);
  13419. return this.fromIR(IR);
  13420. },
  13421. parseArray: function PDFFunction_parseArray(xref, fnObj) {
  13422. if (!isArray(fnObj)) {
  13423. return this.parse(xref, fnObj);
  13424. }
  13425. var fnArray = [];
  13426. for (var j = 0, jj = fnObj.length; j < jj; j++) {
  13427. var obj = xref.fetchIfRef(fnObj[j]);
  13428. fnArray.push(PDFFunction.parse(xref, obj));
  13429. }
  13430. return function (src, srcOffset, dest, destOffset) {
  13431. for (var i = 0, ii = fnArray.length; i < ii; i++) {
  13432. fnArray[i](src, srcOffset, dest, destOffset + i);
  13433. }
  13434. };
  13435. },
  13436. constructSampled: function PDFFunction_constructSampled(str, dict) {
  13437. function toMultiArray(arr) {
  13438. var inputLength = arr.length;
  13439. var out = [];
  13440. var index = 0;
  13441. for (var i = 0; i < inputLength; i += 2) {
  13442. out[index] = [
  13443. arr[i],
  13444. arr[i + 1]
  13445. ];
  13446. ++index;
  13447. }
  13448. return out;
  13449. }
  13450. var domain = dict.getArray('Domain');
  13451. var range = dict.getArray('Range');
  13452. if (!domain || !range) {
  13453. error('No domain or range');
  13454. }
  13455. var inputSize = domain.length / 2;
  13456. var outputSize = range.length / 2;
  13457. domain = toMultiArray(domain);
  13458. range = toMultiArray(range);
  13459. var size = dict.get('Size');
  13460. var bps = dict.get('BitsPerSample');
  13461. var order = dict.get('Order') || 1;
  13462. if (order !== 1) {
  13463. info('No support for cubic spline interpolation: ' + order);
  13464. }
  13465. var encode = dict.getArray('Encode');
  13466. if (!encode) {
  13467. encode = [];
  13468. for (var i = 0; i < inputSize; ++i) {
  13469. encode.push(0);
  13470. encode.push(size[i] - 1);
  13471. }
  13472. }
  13473. encode = toMultiArray(encode);
  13474. var decode = dict.getArray('Decode');
  13475. if (!decode) {
  13476. decode = range;
  13477. } else {
  13478. decode = toMultiArray(decode);
  13479. }
  13480. var samples = this.getSampleArray(size, outputSize, bps, str);
  13481. return [
  13482. CONSTRUCT_SAMPLED,
  13483. inputSize,
  13484. domain,
  13485. encode,
  13486. decode,
  13487. samples,
  13488. size,
  13489. outputSize,
  13490. Math.pow(2, bps) - 1,
  13491. range
  13492. ];
  13493. },
  13494. constructSampledFromIR: function PDFFunction_constructSampledFromIR(IR) {
  13495. function interpolate(x, xmin, xmax, ymin, ymax) {
  13496. return ymin + (x - xmin) * ((ymax - ymin) / (xmax - xmin));
  13497. }
  13498. return function constructSampledFromIRResult(src, srcOffset, dest, destOffset) {
  13499. var m = IR[1];
  13500. var domain = IR[2];
  13501. var encode = IR[3];
  13502. var decode = IR[4];
  13503. var samples = IR[5];
  13504. var size = IR[6];
  13505. var n = IR[7];
  13506. var range = IR[9];
  13507. var cubeVertices = 1 << m;
  13508. var cubeN = new Float64Array(cubeVertices);
  13509. var cubeVertex = new Uint32Array(cubeVertices);
  13510. var i, j;
  13511. for (j = 0; j < cubeVertices; j++) {
  13512. cubeN[j] = 1;
  13513. }
  13514. var k = n, pos = 1;
  13515. for (i = 0; i < m; ++i) {
  13516. var domain_2i = domain[i][0];
  13517. var domain_2i_1 = domain[i][1];
  13518. var xi = Math.min(Math.max(src[srcOffset + i], domain_2i), domain_2i_1);
  13519. var e = interpolate(xi, domain_2i, domain_2i_1, encode[i][0], encode[i][1]);
  13520. var size_i = size[i];
  13521. e = Math.min(Math.max(e, 0), size_i - 1);
  13522. var e0 = e < size_i - 1 ? Math.floor(e) : e - 1;
  13523. var n0 = e0 + 1 - e;
  13524. var n1 = e - e0;
  13525. var offset0 = e0 * k;
  13526. var offset1 = offset0 + k;
  13527. for (j = 0; j < cubeVertices; j++) {
  13528. if (j & pos) {
  13529. cubeN[j] *= n1;
  13530. cubeVertex[j] += offset1;
  13531. } else {
  13532. cubeN[j] *= n0;
  13533. cubeVertex[j] += offset0;
  13534. }
  13535. }
  13536. k *= size_i;
  13537. pos <<= 1;
  13538. }
  13539. for (j = 0; j < n; ++j) {
  13540. var rj = 0;
  13541. for (i = 0; i < cubeVertices; i++) {
  13542. rj += samples[cubeVertex[i] + j] * cubeN[i];
  13543. }
  13544. rj = interpolate(rj, 0, 1, decode[j][0], decode[j][1]);
  13545. dest[destOffset + j] = Math.min(Math.max(rj, range[j][0]), range[j][1]);
  13546. }
  13547. };
  13548. },
  13549. constructInterpolated: function PDFFunction_constructInterpolated(str, dict) {
  13550. var c0 = dict.getArray('C0') || [0];
  13551. var c1 = dict.getArray('C1') || [1];
  13552. var n = dict.get('N');
  13553. if (!isArray(c0) || !isArray(c1)) {
  13554. error('Illegal dictionary for interpolated function');
  13555. }
  13556. var length = c0.length;
  13557. var diff = [];
  13558. for (var i = 0; i < length; ++i) {
  13559. diff.push(c1[i] - c0[i]);
  13560. }
  13561. return [
  13562. CONSTRUCT_INTERPOLATED,
  13563. c0,
  13564. diff,
  13565. n
  13566. ];
  13567. },
  13568. constructInterpolatedFromIR: function PDFFunction_constructInterpolatedFromIR(IR) {
  13569. var c0 = IR[1];
  13570. var diff = IR[2];
  13571. var n = IR[3];
  13572. var length = diff.length;
  13573. return function constructInterpolatedFromIRResult(src, srcOffset, dest, destOffset) {
  13574. var x = n === 1 ? src[srcOffset] : Math.pow(src[srcOffset], n);
  13575. for (var j = 0; j < length; ++j) {
  13576. dest[destOffset + j] = c0[j] + x * diff[j];
  13577. }
  13578. };
  13579. },
  13580. constructStiched: function PDFFunction_constructStiched(fn, dict, xref) {
  13581. var domain = dict.getArray('Domain');
  13582. if (!domain) {
  13583. error('No domain');
  13584. }
  13585. var inputSize = domain.length / 2;
  13586. if (inputSize !== 1) {
  13587. error('Bad domain for stiched function');
  13588. }
  13589. var fnRefs = dict.get('Functions');
  13590. var fns = [];
  13591. for (var i = 0, ii = fnRefs.length; i < ii; ++i) {
  13592. fns.push(PDFFunction.getIR(xref, xref.fetchIfRef(fnRefs[i])));
  13593. }
  13594. var bounds = dict.getArray('Bounds');
  13595. var encode = dict.getArray('Encode');
  13596. return [
  13597. CONSTRUCT_STICHED,
  13598. domain,
  13599. bounds,
  13600. encode,
  13601. fns
  13602. ];
  13603. },
  13604. constructStichedFromIR: function PDFFunction_constructStichedFromIR(IR) {
  13605. var domain = IR[1];
  13606. var bounds = IR[2];
  13607. var encode = IR[3];
  13608. var fnsIR = IR[4];
  13609. var fns = [];
  13610. var tmpBuf = new Float32Array(1);
  13611. for (var i = 0, ii = fnsIR.length; i < ii; i++) {
  13612. fns.push(PDFFunction.fromIR(fnsIR[i]));
  13613. }
  13614. return function constructStichedFromIRResult(src, srcOffset, dest, destOffset) {
  13615. var clip = function constructStichedFromIRClip(v, min, max) {
  13616. if (v > max) {
  13617. v = max;
  13618. } else if (v < min) {
  13619. v = min;
  13620. }
  13621. return v;
  13622. };
  13623. var v = clip(src[srcOffset], domain[0], domain[1]);
  13624. for (var i = 0, ii = bounds.length; i < ii; ++i) {
  13625. if (v < bounds[i]) {
  13626. break;
  13627. }
  13628. }
  13629. var dmin = domain[0];
  13630. if (i > 0) {
  13631. dmin = bounds[i - 1];
  13632. }
  13633. var dmax = domain[1];
  13634. if (i < bounds.length) {
  13635. dmax = bounds[i];
  13636. }
  13637. var rmin = encode[2 * i];
  13638. var rmax = encode[2 * i + 1];
  13639. tmpBuf[0] = dmin === dmax ? rmin : rmin + (v - dmin) * (rmax - rmin) / (dmax - dmin);
  13640. fns[i](tmpBuf, 0, dest, destOffset);
  13641. };
  13642. },
  13643. constructPostScript: function PDFFunction_constructPostScript(fn, dict, xref) {
  13644. var domain = dict.getArray('Domain');
  13645. var range = dict.getArray('Range');
  13646. if (!domain) {
  13647. error('No domain.');
  13648. }
  13649. if (!range) {
  13650. error('No range.');
  13651. }
  13652. var lexer = new PostScriptLexer(fn);
  13653. var parser = new PostScriptParser(lexer);
  13654. var code = parser.parse();
  13655. return [
  13656. CONSTRUCT_POSTSCRIPT,
  13657. domain,
  13658. range,
  13659. code
  13660. ];
  13661. },
  13662. constructPostScriptFromIR: function PDFFunction_constructPostScriptFromIR(IR) {
  13663. var domain = IR[1];
  13664. var range = IR[2];
  13665. var code = IR[3];
  13666. var compiled = new PostScriptCompiler().compile(code, domain, range);
  13667. if (compiled) {
  13668. return new Function('src', 'srcOffset', 'dest', 'destOffset', compiled);
  13669. }
  13670. info('Unable to compile PS function');
  13671. var numOutputs = range.length >> 1;
  13672. var numInputs = domain.length >> 1;
  13673. var evaluator = new PostScriptEvaluator(code);
  13674. var cache = Object.create(null);
  13675. var MAX_CACHE_SIZE = 2048 * 4;
  13676. var cache_available = MAX_CACHE_SIZE;
  13677. var tmpBuf = new Float32Array(numInputs);
  13678. return function constructPostScriptFromIRResult(src, srcOffset, dest, destOffset) {
  13679. var i, value;
  13680. var key = '';
  13681. var input = tmpBuf;
  13682. for (i = 0; i < numInputs; i++) {
  13683. value = src[srcOffset + i];
  13684. input[i] = value;
  13685. key += value + '_';
  13686. }
  13687. var cachedValue = cache[key];
  13688. if (cachedValue !== undefined) {
  13689. dest.set(cachedValue, destOffset);
  13690. return;
  13691. }
  13692. var output = new Float32Array(numOutputs);
  13693. var stack = evaluator.execute(input);
  13694. var stackIndex = stack.length - numOutputs;
  13695. for (i = 0; i < numOutputs; i++) {
  13696. value = stack[stackIndex + i];
  13697. var bound = range[i * 2];
  13698. if (value < bound) {
  13699. value = bound;
  13700. } else {
  13701. bound = range[i * 2 + 1];
  13702. if (value > bound) {
  13703. value = bound;
  13704. }
  13705. }
  13706. output[i] = value;
  13707. }
  13708. if (cache_available > 0) {
  13709. cache_available--;
  13710. cache[key] = output;
  13711. }
  13712. dest.set(output, destOffset);
  13713. };
  13714. }
  13715. };
  13716. }();
  13717. function isPDFFunction(v) {
  13718. var fnDict;
  13719. if (typeof v !== 'object') {
  13720. return false;
  13721. } else if (isDict(v)) {
  13722. fnDict = v;
  13723. } else if (isStream(v)) {
  13724. fnDict = v.dict;
  13725. } else {
  13726. return false;
  13727. }
  13728. return fnDict.has('FunctionType');
  13729. }
  13730. var PostScriptStack = function PostScriptStackClosure() {
  13731. var MAX_STACK_SIZE = 100;
  13732. function PostScriptStack(initialStack) {
  13733. this.stack = !initialStack ? [] : Array.prototype.slice.call(initialStack, 0);
  13734. }
  13735. PostScriptStack.prototype = {
  13736. push: function PostScriptStack_push(value) {
  13737. if (this.stack.length >= MAX_STACK_SIZE) {
  13738. error('PostScript function stack overflow.');
  13739. }
  13740. this.stack.push(value);
  13741. },
  13742. pop: function PostScriptStack_pop() {
  13743. if (this.stack.length <= 0) {
  13744. error('PostScript function stack underflow.');
  13745. }
  13746. return this.stack.pop();
  13747. },
  13748. copy: function PostScriptStack_copy(n) {
  13749. if (this.stack.length + n >= MAX_STACK_SIZE) {
  13750. error('PostScript function stack overflow.');
  13751. }
  13752. var stack = this.stack;
  13753. for (var i = stack.length - n, j = n - 1; j >= 0; j--, i++) {
  13754. stack.push(stack[i]);
  13755. }
  13756. },
  13757. index: function PostScriptStack_index(n) {
  13758. this.push(this.stack[this.stack.length - n - 1]);
  13759. },
  13760. roll: function PostScriptStack_roll(n, p) {
  13761. var stack = this.stack;
  13762. var l = stack.length - n;
  13763. var r = stack.length - 1, c = l + (p - Math.floor(p / n) * n), i, j, t;
  13764. for (i = l, j = r; i < j; i++, j--) {
  13765. t = stack[i];
  13766. stack[i] = stack[j];
  13767. stack[j] = t;
  13768. }
  13769. for (i = l, j = c - 1; i < j; i++, j--) {
  13770. t = stack[i];
  13771. stack[i] = stack[j];
  13772. stack[j] = t;
  13773. }
  13774. for (i = c, j = r; i < j; i++, j--) {
  13775. t = stack[i];
  13776. stack[i] = stack[j];
  13777. stack[j] = t;
  13778. }
  13779. }
  13780. };
  13781. return PostScriptStack;
  13782. }();
  13783. var PostScriptEvaluator = function PostScriptEvaluatorClosure() {
  13784. function PostScriptEvaluator(operators) {
  13785. this.operators = operators;
  13786. }
  13787. PostScriptEvaluator.prototype = {
  13788. execute: function PostScriptEvaluator_execute(initialStack) {
  13789. var stack = new PostScriptStack(initialStack);
  13790. var counter = 0;
  13791. var operators = this.operators;
  13792. var length = operators.length;
  13793. var operator, a, b;
  13794. while (counter < length) {
  13795. operator = operators[counter++];
  13796. if (typeof operator === 'number') {
  13797. stack.push(operator);
  13798. continue;
  13799. }
  13800. switch (operator) {
  13801. case 'jz':
  13802. b = stack.pop();
  13803. a = stack.pop();
  13804. if (!a) {
  13805. counter = b;
  13806. }
  13807. break;
  13808. case 'j':
  13809. a = stack.pop();
  13810. counter = a;
  13811. break;
  13812. case 'abs':
  13813. a = stack.pop();
  13814. stack.push(Math.abs(a));
  13815. break;
  13816. case 'add':
  13817. b = stack.pop();
  13818. a = stack.pop();
  13819. stack.push(a + b);
  13820. break;
  13821. case 'and':
  13822. b = stack.pop();
  13823. a = stack.pop();
  13824. if (isBool(a) && isBool(b)) {
  13825. stack.push(a && b);
  13826. } else {
  13827. stack.push(a & b);
  13828. }
  13829. break;
  13830. case 'atan':
  13831. a = stack.pop();
  13832. stack.push(Math.atan(a));
  13833. break;
  13834. case 'bitshift':
  13835. b = stack.pop();
  13836. a = stack.pop();
  13837. if (a > 0) {
  13838. stack.push(a << b);
  13839. } else {
  13840. stack.push(a >> b);
  13841. }
  13842. break;
  13843. case 'ceiling':
  13844. a = stack.pop();
  13845. stack.push(Math.ceil(a));
  13846. break;
  13847. case 'copy':
  13848. a = stack.pop();
  13849. stack.copy(a);
  13850. break;
  13851. case 'cos':
  13852. a = stack.pop();
  13853. stack.push(Math.cos(a));
  13854. break;
  13855. case 'cvi':
  13856. a = stack.pop() | 0;
  13857. stack.push(a);
  13858. break;
  13859. case 'cvr':
  13860. break;
  13861. case 'div':
  13862. b = stack.pop();
  13863. a = stack.pop();
  13864. stack.push(a / b);
  13865. break;
  13866. case 'dup':
  13867. stack.copy(1);
  13868. break;
  13869. case 'eq':
  13870. b = stack.pop();
  13871. a = stack.pop();
  13872. stack.push(a === b);
  13873. break;
  13874. case 'exch':
  13875. stack.roll(2, 1);
  13876. break;
  13877. case 'exp':
  13878. b = stack.pop();
  13879. a = stack.pop();
  13880. stack.push(Math.pow(a, b));
  13881. break;
  13882. case 'false':
  13883. stack.push(false);
  13884. break;
  13885. case 'floor':
  13886. a = stack.pop();
  13887. stack.push(Math.floor(a));
  13888. break;
  13889. case 'ge':
  13890. b = stack.pop();
  13891. a = stack.pop();
  13892. stack.push(a >= b);
  13893. break;
  13894. case 'gt':
  13895. b = stack.pop();
  13896. a = stack.pop();
  13897. stack.push(a > b);
  13898. break;
  13899. case 'idiv':
  13900. b = stack.pop();
  13901. a = stack.pop();
  13902. stack.push(a / b | 0);
  13903. break;
  13904. case 'index':
  13905. a = stack.pop();
  13906. stack.index(a);
  13907. break;
  13908. case 'le':
  13909. b = stack.pop();
  13910. a = stack.pop();
  13911. stack.push(a <= b);
  13912. break;
  13913. case 'ln':
  13914. a = stack.pop();
  13915. stack.push(Math.log(a));
  13916. break;
  13917. case 'log':
  13918. a = stack.pop();
  13919. stack.push(Math.log(a) / Math.LN10);
  13920. break;
  13921. case 'lt':
  13922. b = stack.pop();
  13923. a = stack.pop();
  13924. stack.push(a < b);
  13925. break;
  13926. case 'mod':
  13927. b = stack.pop();
  13928. a = stack.pop();
  13929. stack.push(a % b);
  13930. break;
  13931. case 'mul':
  13932. b = stack.pop();
  13933. a = stack.pop();
  13934. stack.push(a * b);
  13935. break;
  13936. case 'ne':
  13937. b = stack.pop();
  13938. a = stack.pop();
  13939. stack.push(a !== b);
  13940. break;
  13941. case 'neg':
  13942. a = stack.pop();
  13943. stack.push(-a);
  13944. break;
  13945. case 'not':
  13946. a = stack.pop();
  13947. if (isBool(a)) {
  13948. stack.push(!a);
  13949. } else {
  13950. stack.push(~a);
  13951. }
  13952. break;
  13953. case 'or':
  13954. b = stack.pop();
  13955. a = stack.pop();
  13956. if (isBool(a) && isBool(b)) {
  13957. stack.push(a || b);
  13958. } else {
  13959. stack.push(a | b);
  13960. }
  13961. break;
  13962. case 'pop':
  13963. stack.pop();
  13964. break;
  13965. case 'roll':
  13966. b = stack.pop();
  13967. a = stack.pop();
  13968. stack.roll(a, b);
  13969. break;
  13970. case 'round':
  13971. a = stack.pop();
  13972. stack.push(Math.round(a));
  13973. break;
  13974. case 'sin':
  13975. a = stack.pop();
  13976. stack.push(Math.sin(a));
  13977. break;
  13978. case 'sqrt':
  13979. a = stack.pop();
  13980. stack.push(Math.sqrt(a));
  13981. break;
  13982. case 'sub':
  13983. b = stack.pop();
  13984. a = stack.pop();
  13985. stack.push(a - b);
  13986. break;
  13987. case 'true':
  13988. stack.push(true);
  13989. break;
  13990. case 'truncate':
  13991. a = stack.pop();
  13992. a = a < 0 ? Math.ceil(a) : Math.floor(a);
  13993. stack.push(a);
  13994. break;
  13995. case 'xor':
  13996. b = stack.pop();
  13997. a = stack.pop();
  13998. if (isBool(a) && isBool(b)) {
  13999. stack.push(a !== b);
  14000. } else {
  14001. stack.push(a ^ b);
  14002. }
  14003. break;
  14004. default:
  14005. error('Unknown operator ' + operator);
  14006. break;
  14007. }
  14008. }
  14009. return stack.stack;
  14010. }
  14011. };
  14012. return PostScriptEvaluator;
  14013. }();
  14014. var PostScriptCompiler = function PostScriptCompilerClosure() {
  14015. function AstNode(type) {
  14016. this.type = type;
  14017. }
  14018. AstNode.prototype.visit = function (visitor) {
  14019. throw new Error('abstract method');
  14020. };
  14021. function AstArgument(index, min, max) {
  14022. AstNode.call(this, 'args');
  14023. this.index = index;
  14024. this.min = min;
  14025. this.max = max;
  14026. }
  14027. AstArgument.prototype = Object.create(AstNode.prototype);
  14028. AstArgument.prototype.visit = function (visitor) {
  14029. visitor.visitArgument(this);
  14030. };
  14031. function AstLiteral(number) {
  14032. AstNode.call(this, 'literal');
  14033. this.number = number;
  14034. this.min = number;
  14035. this.max = number;
  14036. }
  14037. AstLiteral.prototype = Object.create(AstNode.prototype);
  14038. AstLiteral.prototype.visit = function (visitor) {
  14039. visitor.visitLiteral(this);
  14040. };
  14041. function AstBinaryOperation(op, arg1, arg2, min, max) {
  14042. AstNode.call(this, 'binary');
  14043. this.op = op;
  14044. this.arg1 = arg1;
  14045. this.arg2 = arg2;
  14046. this.min = min;
  14047. this.max = max;
  14048. }
  14049. AstBinaryOperation.prototype = Object.create(AstNode.prototype);
  14050. AstBinaryOperation.prototype.visit = function (visitor) {
  14051. visitor.visitBinaryOperation(this);
  14052. };
  14053. function AstMin(arg, max) {
  14054. AstNode.call(this, 'max');
  14055. this.arg = arg;
  14056. this.min = arg.min;
  14057. this.max = max;
  14058. }
  14059. AstMin.prototype = Object.create(AstNode.prototype);
  14060. AstMin.prototype.visit = function (visitor) {
  14061. visitor.visitMin(this);
  14062. };
  14063. function AstVariable(index, min, max) {
  14064. AstNode.call(this, 'var');
  14065. this.index = index;
  14066. this.min = min;
  14067. this.max = max;
  14068. }
  14069. AstVariable.prototype = Object.create(AstNode.prototype);
  14070. AstVariable.prototype.visit = function (visitor) {
  14071. visitor.visitVariable(this);
  14072. };
  14073. function AstVariableDefinition(variable, arg) {
  14074. AstNode.call(this, 'definition');
  14075. this.variable = variable;
  14076. this.arg = arg;
  14077. }
  14078. AstVariableDefinition.prototype = Object.create(AstNode.prototype);
  14079. AstVariableDefinition.prototype.visit = function (visitor) {
  14080. visitor.visitVariableDefinition(this);
  14081. };
  14082. function ExpressionBuilderVisitor() {
  14083. this.parts = [];
  14084. }
  14085. ExpressionBuilderVisitor.prototype = {
  14086. visitArgument: function (arg) {
  14087. this.parts.push('Math.max(', arg.min, ', Math.min(', arg.max, ', src[srcOffset + ', arg.index, ']))');
  14088. },
  14089. visitVariable: function (variable) {
  14090. this.parts.push('v', variable.index);
  14091. },
  14092. visitLiteral: function (literal) {
  14093. this.parts.push(literal.number);
  14094. },
  14095. visitBinaryOperation: function (operation) {
  14096. this.parts.push('(');
  14097. operation.arg1.visit(this);
  14098. this.parts.push(' ', operation.op, ' ');
  14099. operation.arg2.visit(this);
  14100. this.parts.push(')');
  14101. },
  14102. visitVariableDefinition: function (definition) {
  14103. this.parts.push('var ');
  14104. definition.variable.visit(this);
  14105. this.parts.push(' = ');
  14106. definition.arg.visit(this);
  14107. this.parts.push(';');
  14108. },
  14109. visitMin: function (max) {
  14110. this.parts.push('Math.min(');
  14111. max.arg.visit(this);
  14112. this.parts.push(', ', max.max, ')');
  14113. },
  14114. toString: function () {
  14115. return this.parts.join('');
  14116. }
  14117. };
  14118. function buildAddOperation(num1, num2) {
  14119. if (num2.type === 'literal' && num2.number === 0) {
  14120. return num1;
  14121. }
  14122. if (num1.type === 'literal' && num1.number === 0) {
  14123. return num2;
  14124. }
  14125. if (num2.type === 'literal' && num1.type === 'literal') {
  14126. return new AstLiteral(num1.number + num2.number);
  14127. }
  14128. return new AstBinaryOperation('+', num1, num2, num1.min + num2.min, num1.max + num2.max);
  14129. }
  14130. function buildMulOperation(num1, num2) {
  14131. if (num2.type === 'literal') {
  14132. if (num2.number === 0) {
  14133. return new AstLiteral(0);
  14134. } else if (num2.number === 1) {
  14135. return num1;
  14136. } else if (num1.type === 'literal') {
  14137. return new AstLiteral(num1.number * num2.number);
  14138. }
  14139. }
  14140. if (num1.type === 'literal') {
  14141. if (num1.number === 0) {
  14142. return new AstLiteral(0);
  14143. } else if (num1.number === 1) {
  14144. return num2;
  14145. }
  14146. }
  14147. var min = Math.min(num1.min * num2.min, num1.min * num2.max, num1.max * num2.min, num1.max * num2.max);
  14148. var max = Math.max(num1.min * num2.min, num1.min * num2.max, num1.max * num2.min, num1.max * num2.max);
  14149. return new AstBinaryOperation('*', num1, num2, min, max);
  14150. }
  14151. function buildSubOperation(num1, num2) {
  14152. if (num2.type === 'literal') {
  14153. if (num2.number === 0) {
  14154. return num1;
  14155. } else if (num1.type === 'literal') {
  14156. return new AstLiteral(num1.number - num2.number);
  14157. }
  14158. }
  14159. if (num2.type === 'binary' && num2.op === '-' && num1.type === 'literal' && num1.number === 1 && num2.arg1.type === 'literal' && num2.arg1.number === 1) {
  14160. return num2.arg2;
  14161. }
  14162. return new AstBinaryOperation('-', num1, num2, num1.min - num2.max, num1.max - num2.min);
  14163. }
  14164. function buildMinOperation(num1, max) {
  14165. if (num1.min >= max) {
  14166. return new AstLiteral(max);
  14167. } else if (num1.max <= max) {
  14168. return num1;
  14169. }
  14170. return new AstMin(num1, max);
  14171. }
  14172. function PostScriptCompiler() {
  14173. }
  14174. PostScriptCompiler.prototype = {
  14175. compile: function PostScriptCompiler_compile(code, domain, range) {
  14176. var stack = [];
  14177. var i, ii;
  14178. var instructions = [];
  14179. var inputSize = domain.length >> 1, outputSize = range.length >> 1;
  14180. var lastRegister = 0;
  14181. var n, j;
  14182. var num1, num2, ast1, ast2, tmpVar, item;
  14183. for (i = 0; i < inputSize; i++) {
  14184. stack.push(new AstArgument(i, domain[i * 2], domain[i * 2 + 1]));
  14185. }
  14186. for (i = 0, ii = code.length; i < ii; i++) {
  14187. item = code[i];
  14188. if (typeof item === 'number') {
  14189. stack.push(new AstLiteral(item));
  14190. continue;
  14191. }
  14192. switch (item) {
  14193. case 'add':
  14194. if (stack.length < 2) {
  14195. return null;
  14196. }
  14197. num2 = stack.pop();
  14198. num1 = stack.pop();
  14199. stack.push(buildAddOperation(num1, num2));
  14200. break;
  14201. case 'cvr':
  14202. if (stack.length < 1) {
  14203. return null;
  14204. }
  14205. break;
  14206. case 'mul':
  14207. if (stack.length < 2) {
  14208. return null;
  14209. }
  14210. num2 = stack.pop();
  14211. num1 = stack.pop();
  14212. stack.push(buildMulOperation(num1, num2));
  14213. break;
  14214. case 'sub':
  14215. if (stack.length < 2) {
  14216. return null;
  14217. }
  14218. num2 = stack.pop();
  14219. num1 = stack.pop();
  14220. stack.push(buildSubOperation(num1, num2));
  14221. break;
  14222. case 'exch':
  14223. if (stack.length < 2) {
  14224. return null;
  14225. }
  14226. ast1 = stack.pop();
  14227. ast2 = stack.pop();
  14228. stack.push(ast1, ast2);
  14229. break;
  14230. case 'pop':
  14231. if (stack.length < 1) {
  14232. return null;
  14233. }
  14234. stack.pop();
  14235. break;
  14236. case 'index':
  14237. if (stack.length < 1) {
  14238. return null;
  14239. }
  14240. num1 = stack.pop();
  14241. if (num1.type !== 'literal') {
  14242. return null;
  14243. }
  14244. n = num1.number;
  14245. if (n < 0 || (n | 0) !== n || stack.length < n) {
  14246. return null;
  14247. }
  14248. ast1 = stack[stack.length - n - 1];
  14249. if (ast1.type === 'literal' || ast1.type === 'var') {
  14250. stack.push(ast1);
  14251. break;
  14252. }
  14253. tmpVar = new AstVariable(lastRegister++, ast1.min, ast1.max);
  14254. stack[stack.length - n - 1] = tmpVar;
  14255. stack.push(tmpVar);
  14256. instructions.push(new AstVariableDefinition(tmpVar, ast1));
  14257. break;
  14258. case 'dup':
  14259. if (stack.length < 1) {
  14260. return null;
  14261. }
  14262. 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]) {
  14263. num1 = stack.pop();
  14264. stack.push(buildMinOperation(num1, code[i + 1]));
  14265. i += 6;
  14266. break;
  14267. }
  14268. ast1 = stack[stack.length - 1];
  14269. if (ast1.type === 'literal' || ast1.type === 'var') {
  14270. stack.push(ast1);
  14271. break;
  14272. }
  14273. tmpVar = new AstVariable(lastRegister++, ast1.min, ast1.max);
  14274. stack[stack.length - 1] = tmpVar;
  14275. stack.push(tmpVar);
  14276. instructions.push(new AstVariableDefinition(tmpVar, ast1));
  14277. break;
  14278. case 'roll':
  14279. if (stack.length < 2) {
  14280. return null;
  14281. }
  14282. num2 = stack.pop();
  14283. num1 = stack.pop();
  14284. if (num2.type !== 'literal' || num1.type !== 'literal') {
  14285. return null;
  14286. }
  14287. j = num2.number;
  14288. n = num1.number;
  14289. if (n <= 0 || (n | 0) !== n || (j | 0) !== j || stack.length < n) {
  14290. return null;
  14291. }
  14292. j = (j % n + n) % n;
  14293. if (j === 0) {
  14294. break;
  14295. }
  14296. Array.prototype.push.apply(stack, stack.splice(stack.length - n, n - j));
  14297. break;
  14298. default:
  14299. return null;
  14300. }
  14301. }
  14302. if (stack.length !== outputSize) {
  14303. return null;
  14304. }
  14305. var result = [];
  14306. instructions.forEach(function (instruction) {
  14307. var statementBuilder = new ExpressionBuilderVisitor();
  14308. instruction.visit(statementBuilder);
  14309. result.push(statementBuilder.toString());
  14310. });
  14311. stack.forEach(function (expr, i) {
  14312. var statementBuilder = new ExpressionBuilderVisitor();
  14313. expr.visit(statementBuilder);
  14314. var min = range[i * 2], max = range[i * 2 + 1];
  14315. var out = [statementBuilder.toString()];
  14316. if (min > expr.min) {
  14317. out.unshift('Math.max(', min, ', ');
  14318. out.push(')');
  14319. }
  14320. if (max < expr.max) {
  14321. out.unshift('Math.min(', max, ', ');
  14322. out.push(')');
  14323. }
  14324. out.unshift('dest[destOffset + ', i, '] = ');
  14325. out.push(';');
  14326. result.push(out.join(''));
  14327. });
  14328. return result.join('\n');
  14329. }
  14330. };
  14331. return PostScriptCompiler;
  14332. }();
  14333. exports.isPDFFunction = isPDFFunction;
  14334. exports.PDFFunction = PDFFunction;
  14335. exports.PostScriptEvaluator = PostScriptEvaluator;
  14336. exports.PostScriptCompiler = PostScriptCompiler;
  14337. /***/ }),
  14338. /* 8 */
  14339. /***/ (function(module, exports, __w_pdfjs_require__) {
  14340. "use strict";
  14341. var sharedUtil = __w_pdfjs_require__(0);
  14342. var getLookupTableFactory = sharedUtil.getLookupTableFactory;
  14343. var getGlyphsUnicode = getLookupTableFactory(function (t) {
  14344. t['A'] = 0x0041;
  14345. t['AE'] = 0x00C6;
  14346. t['AEacute'] = 0x01FC;
  14347. t['AEmacron'] = 0x01E2;
  14348. t['AEsmall'] = 0xF7E6;
  14349. t['Aacute'] = 0x00C1;
  14350. t['Aacutesmall'] = 0xF7E1;
  14351. t['Abreve'] = 0x0102;
  14352. t['Abreveacute'] = 0x1EAE;
  14353. t['Abrevecyrillic'] = 0x04D0;
  14354. t['Abrevedotbelow'] = 0x1EB6;
  14355. t['Abrevegrave'] = 0x1EB0;
  14356. t['Abrevehookabove'] = 0x1EB2;
  14357. t['Abrevetilde'] = 0x1EB4;
  14358. t['Acaron'] = 0x01CD;
  14359. t['Acircle'] = 0x24B6;
  14360. t['Acircumflex'] = 0x00C2;
  14361. t['Acircumflexacute'] = 0x1EA4;
  14362. t['Acircumflexdotbelow'] = 0x1EAC;
  14363. t['Acircumflexgrave'] = 0x1EA6;
  14364. t['Acircumflexhookabove'] = 0x1EA8;
  14365. t['Acircumflexsmall'] = 0xF7E2;
  14366. t['Acircumflextilde'] = 0x1EAA;
  14367. t['Acute'] = 0xF6C9;
  14368. t['Acutesmall'] = 0xF7B4;
  14369. t['Acyrillic'] = 0x0410;
  14370. t['Adblgrave'] = 0x0200;
  14371. t['Adieresis'] = 0x00C4;
  14372. t['Adieresiscyrillic'] = 0x04D2;
  14373. t['Adieresismacron'] = 0x01DE;
  14374. t['Adieresissmall'] = 0xF7E4;
  14375. t['Adotbelow'] = 0x1EA0;
  14376. t['Adotmacron'] = 0x01E0;
  14377. t['Agrave'] = 0x00C0;
  14378. t['Agravesmall'] = 0xF7E0;
  14379. t['Ahookabove'] = 0x1EA2;
  14380. t['Aiecyrillic'] = 0x04D4;
  14381. t['Ainvertedbreve'] = 0x0202;
  14382. t['Alpha'] = 0x0391;
  14383. t['Alphatonos'] = 0x0386;
  14384. t['Amacron'] = 0x0100;
  14385. t['Amonospace'] = 0xFF21;
  14386. t['Aogonek'] = 0x0104;
  14387. t['Aring'] = 0x00C5;
  14388. t['Aringacute'] = 0x01FA;
  14389. t['Aringbelow'] = 0x1E00;
  14390. t['Aringsmall'] = 0xF7E5;
  14391. t['Asmall'] = 0xF761;
  14392. t['Atilde'] = 0x00C3;
  14393. t['Atildesmall'] = 0xF7E3;
  14394. t['Aybarmenian'] = 0x0531;
  14395. t['B'] = 0x0042;
  14396. t['Bcircle'] = 0x24B7;
  14397. t['Bdotaccent'] = 0x1E02;
  14398. t['Bdotbelow'] = 0x1E04;
  14399. t['Becyrillic'] = 0x0411;
  14400. t['Benarmenian'] = 0x0532;
  14401. t['Beta'] = 0x0392;
  14402. t['Bhook'] = 0x0181;
  14403. t['Blinebelow'] = 0x1E06;
  14404. t['Bmonospace'] = 0xFF22;
  14405. t['Brevesmall'] = 0xF6F4;
  14406. t['Bsmall'] = 0xF762;
  14407. t['Btopbar'] = 0x0182;
  14408. t['C'] = 0x0043;
  14409. t['Caarmenian'] = 0x053E;
  14410. t['Cacute'] = 0x0106;
  14411. t['Caron'] = 0xF6CA;
  14412. t['Caronsmall'] = 0xF6F5;
  14413. t['Ccaron'] = 0x010C;
  14414. t['Ccedilla'] = 0x00C7;
  14415. t['Ccedillaacute'] = 0x1E08;
  14416. t['Ccedillasmall'] = 0xF7E7;
  14417. t['Ccircle'] = 0x24B8;
  14418. t['Ccircumflex'] = 0x0108;
  14419. t['Cdot'] = 0x010A;
  14420. t['Cdotaccent'] = 0x010A;
  14421. t['Cedillasmall'] = 0xF7B8;
  14422. t['Chaarmenian'] = 0x0549;
  14423. t['Cheabkhasiancyrillic'] = 0x04BC;
  14424. t['Checyrillic'] = 0x0427;
  14425. t['Chedescenderabkhasiancyrillic'] = 0x04BE;
  14426. t['Chedescendercyrillic'] = 0x04B6;
  14427. t['Chedieresiscyrillic'] = 0x04F4;
  14428. t['Cheharmenian'] = 0x0543;
  14429. t['Chekhakassiancyrillic'] = 0x04CB;
  14430. t['Cheverticalstrokecyrillic'] = 0x04B8;
  14431. t['Chi'] = 0x03A7;
  14432. t['Chook'] = 0x0187;
  14433. t['Circumflexsmall'] = 0xF6F6;
  14434. t['Cmonospace'] = 0xFF23;
  14435. t['Coarmenian'] = 0x0551;
  14436. t['Csmall'] = 0xF763;
  14437. t['D'] = 0x0044;
  14438. t['DZ'] = 0x01F1;
  14439. t['DZcaron'] = 0x01C4;
  14440. t['Daarmenian'] = 0x0534;
  14441. t['Dafrican'] = 0x0189;
  14442. t['Dcaron'] = 0x010E;
  14443. t['Dcedilla'] = 0x1E10;
  14444. t['Dcircle'] = 0x24B9;
  14445. t['Dcircumflexbelow'] = 0x1E12;
  14446. t['Dcroat'] = 0x0110;
  14447. t['Ddotaccent'] = 0x1E0A;
  14448. t['Ddotbelow'] = 0x1E0C;
  14449. t['Decyrillic'] = 0x0414;
  14450. t['Deicoptic'] = 0x03EE;
  14451. t['Delta'] = 0x2206;
  14452. t['Deltagreek'] = 0x0394;
  14453. t['Dhook'] = 0x018A;
  14454. t['Dieresis'] = 0xF6CB;
  14455. t['DieresisAcute'] = 0xF6CC;
  14456. t['DieresisGrave'] = 0xF6CD;
  14457. t['Dieresissmall'] = 0xF7A8;
  14458. t['Digammagreek'] = 0x03DC;
  14459. t['Djecyrillic'] = 0x0402;
  14460. t['Dlinebelow'] = 0x1E0E;
  14461. t['Dmonospace'] = 0xFF24;
  14462. t['Dotaccentsmall'] = 0xF6F7;
  14463. t['Dslash'] = 0x0110;
  14464. t['Dsmall'] = 0xF764;
  14465. t['Dtopbar'] = 0x018B;
  14466. t['Dz'] = 0x01F2;
  14467. t['Dzcaron'] = 0x01C5;
  14468. t['Dzeabkhasiancyrillic'] = 0x04E0;
  14469. t['Dzecyrillic'] = 0x0405;
  14470. t['Dzhecyrillic'] = 0x040F;
  14471. t['E'] = 0x0045;
  14472. t['Eacute'] = 0x00C9;
  14473. t['Eacutesmall'] = 0xF7E9;
  14474. t['Ebreve'] = 0x0114;
  14475. t['Ecaron'] = 0x011A;
  14476. t['Ecedillabreve'] = 0x1E1C;
  14477. t['Echarmenian'] = 0x0535;
  14478. t['Ecircle'] = 0x24BA;
  14479. t['Ecircumflex'] = 0x00CA;
  14480. t['Ecircumflexacute'] = 0x1EBE;
  14481. t['Ecircumflexbelow'] = 0x1E18;
  14482. t['Ecircumflexdotbelow'] = 0x1EC6;
  14483. t['Ecircumflexgrave'] = 0x1EC0;
  14484. t['Ecircumflexhookabove'] = 0x1EC2;
  14485. t['Ecircumflexsmall'] = 0xF7EA;
  14486. t['Ecircumflextilde'] = 0x1EC4;
  14487. t['Ecyrillic'] = 0x0404;
  14488. t['Edblgrave'] = 0x0204;
  14489. t['Edieresis'] = 0x00CB;
  14490. t['Edieresissmall'] = 0xF7EB;
  14491. t['Edot'] = 0x0116;
  14492. t['Edotaccent'] = 0x0116;
  14493. t['Edotbelow'] = 0x1EB8;
  14494. t['Efcyrillic'] = 0x0424;
  14495. t['Egrave'] = 0x00C8;
  14496. t['Egravesmall'] = 0xF7E8;
  14497. t['Eharmenian'] = 0x0537;
  14498. t['Ehookabove'] = 0x1EBA;
  14499. t['Eightroman'] = 0x2167;
  14500. t['Einvertedbreve'] = 0x0206;
  14501. t['Eiotifiedcyrillic'] = 0x0464;
  14502. t['Elcyrillic'] = 0x041B;
  14503. t['Elevenroman'] = 0x216A;
  14504. t['Emacron'] = 0x0112;
  14505. t['Emacronacute'] = 0x1E16;
  14506. t['Emacrongrave'] = 0x1E14;
  14507. t['Emcyrillic'] = 0x041C;
  14508. t['Emonospace'] = 0xFF25;
  14509. t['Encyrillic'] = 0x041D;
  14510. t['Endescendercyrillic'] = 0x04A2;
  14511. t['Eng'] = 0x014A;
  14512. t['Enghecyrillic'] = 0x04A4;
  14513. t['Enhookcyrillic'] = 0x04C7;
  14514. t['Eogonek'] = 0x0118;
  14515. t['Eopen'] = 0x0190;
  14516. t['Epsilon'] = 0x0395;
  14517. t['Epsilontonos'] = 0x0388;
  14518. t['Ercyrillic'] = 0x0420;
  14519. t['Ereversed'] = 0x018E;
  14520. t['Ereversedcyrillic'] = 0x042D;
  14521. t['Escyrillic'] = 0x0421;
  14522. t['Esdescendercyrillic'] = 0x04AA;
  14523. t['Esh'] = 0x01A9;
  14524. t['Esmall'] = 0xF765;
  14525. t['Eta'] = 0x0397;
  14526. t['Etarmenian'] = 0x0538;
  14527. t['Etatonos'] = 0x0389;
  14528. t['Eth'] = 0x00D0;
  14529. t['Ethsmall'] = 0xF7F0;
  14530. t['Etilde'] = 0x1EBC;
  14531. t['Etildebelow'] = 0x1E1A;
  14532. t['Euro'] = 0x20AC;
  14533. t['Ezh'] = 0x01B7;
  14534. t['Ezhcaron'] = 0x01EE;
  14535. t['Ezhreversed'] = 0x01B8;
  14536. t['F'] = 0x0046;
  14537. t['Fcircle'] = 0x24BB;
  14538. t['Fdotaccent'] = 0x1E1E;
  14539. t['Feharmenian'] = 0x0556;
  14540. t['Feicoptic'] = 0x03E4;
  14541. t['Fhook'] = 0x0191;
  14542. t['Fitacyrillic'] = 0x0472;
  14543. t['Fiveroman'] = 0x2164;
  14544. t['Fmonospace'] = 0xFF26;
  14545. t['Fourroman'] = 0x2163;
  14546. t['Fsmall'] = 0xF766;
  14547. t['G'] = 0x0047;
  14548. t['GBsquare'] = 0x3387;
  14549. t['Gacute'] = 0x01F4;
  14550. t['Gamma'] = 0x0393;
  14551. t['Gammaafrican'] = 0x0194;
  14552. t['Gangiacoptic'] = 0x03EA;
  14553. t['Gbreve'] = 0x011E;
  14554. t['Gcaron'] = 0x01E6;
  14555. t['Gcedilla'] = 0x0122;
  14556. t['Gcircle'] = 0x24BC;
  14557. t['Gcircumflex'] = 0x011C;
  14558. t['Gcommaaccent'] = 0x0122;
  14559. t['Gdot'] = 0x0120;
  14560. t['Gdotaccent'] = 0x0120;
  14561. t['Gecyrillic'] = 0x0413;
  14562. t['Ghadarmenian'] = 0x0542;
  14563. t['Ghemiddlehookcyrillic'] = 0x0494;
  14564. t['Ghestrokecyrillic'] = 0x0492;
  14565. t['Gheupturncyrillic'] = 0x0490;
  14566. t['Ghook'] = 0x0193;
  14567. t['Gimarmenian'] = 0x0533;
  14568. t['Gjecyrillic'] = 0x0403;
  14569. t['Gmacron'] = 0x1E20;
  14570. t['Gmonospace'] = 0xFF27;
  14571. t['Grave'] = 0xF6CE;
  14572. t['Gravesmall'] = 0xF760;
  14573. t['Gsmall'] = 0xF767;
  14574. t['Gsmallhook'] = 0x029B;
  14575. t['Gstroke'] = 0x01E4;
  14576. t['H'] = 0x0048;
  14577. t['H18533'] = 0x25CF;
  14578. t['H18543'] = 0x25AA;
  14579. t['H18551'] = 0x25AB;
  14580. t['H22073'] = 0x25A1;
  14581. t['HPsquare'] = 0x33CB;
  14582. t['Haabkhasiancyrillic'] = 0x04A8;
  14583. t['Hadescendercyrillic'] = 0x04B2;
  14584. t['Hardsigncyrillic'] = 0x042A;
  14585. t['Hbar'] = 0x0126;
  14586. t['Hbrevebelow'] = 0x1E2A;
  14587. t['Hcedilla'] = 0x1E28;
  14588. t['Hcircle'] = 0x24BD;
  14589. t['Hcircumflex'] = 0x0124;
  14590. t['Hdieresis'] = 0x1E26;
  14591. t['Hdotaccent'] = 0x1E22;
  14592. t['Hdotbelow'] = 0x1E24;
  14593. t['Hmonospace'] = 0xFF28;
  14594. t['Hoarmenian'] = 0x0540;
  14595. t['Horicoptic'] = 0x03E8;
  14596. t['Hsmall'] = 0xF768;
  14597. t['Hungarumlaut'] = 0xF6CF;
  14598. t['Hungarumlautsmall'] = 0xF6F8;
  14599. t['Hzsquare'] = 0x3390;
  14600. t['I'] = 0x0049;
  14601. t['IAcyrillic'] = 0x042F;
  14602. t['IJ'] = 0x0132;
  14603. t['IUcyrillic'] = 0x042E;
  14604. t['Iacute'] = 0x00CD;
  14605. t['Iacutesmall'] = 0xF7ED;
  14606. t['Ibreve'] = 0x012C;
  14607. t['Icaron'] = 0x01CF;
  14608. t['Icircle'] = 0x24BE;
  14609. t['Icircumflex'] = 0x00CE;
  14610. t['Icircumflexsmall'] = 0xF7EE;
  14611. t['Icyrillic'] = 0x0406;
  14612. t['Idblgrave'] = 0x0208;
  14613. t['Idieresis'] = 0x00CF;
  14614. t['Idieresisacute'] = 0x1E2E;
  14615. t['Idieresiscyrillic'] = 0x04E4;
  14616. t['Idieresissmall'] = 0xF7EF;
  14617. t['Idot'] = 0x0130;
  14618. t['Idotaccent'] = 0x0130;
  14619. t['Idotbelow'] = 0x1ECA;
  14620. t['Iebrevecyrillic'] = 0x04D6;
  14621. t['Iecyrillic'] = 0x0415;
  14622. t['Ifraktur'] = 0x2111;
  14623. t['Igrave'] = 0x00CC;
  14624. t['Igravesmall'] = 0xF7EC;
  14625. t['Ihookabove'] = 0x1EC8;
  14626. t['Iicyrillic'] = 0x0418;
  14627. t['Iinvertedbreve'] = 0x020A;
  14628. t['Iishortcyrillic'] = 0x0419;
  14629. t['Imacron'] = 0x012A;
  14630. t['Imacroncyrillic'] = 0x04E2;
  14631. t['Imonospace'] = 0xFF29;
  14632. t['Iniarmenian'] = 0x053B;
  14633. t['Iocyrillic'] = 0x0401;
  14634. t['Iogonek'] = 0x012E;
  14635. t['Iota'] = 0x0399;
  14636. t['Iotaafrican'] = 0x0196;
  14637. t['Iotadieresis'] = 0x03AA;
  14638. t['Iotatonos'] = 0x038A;
  14639. t['Ismall'] = 0xF769;
  14640. t['Istroke'] = 0x0197;
  14641. t['Itilde'] = 0x0128;
  14642. t['Itildebelow'] = 0x1E2C;
  14643. t['Izhitsacyrillic'] = 0x0474;
  14644. t['Izhitsadblgravecyrillic'] = 0x0476;
  14645. t['J'] = 0x004A;
  14646. t['Jaarmenian'] = 0x0541;
  14647. t['Jcircle'] = 0x24BF;
  14648. t['Jcircumflex'] = 0x0134;
  14649. t['Jecyrillic'] = 0x0408;
  14650. t['Jheharmenian'] = 0x054B;
  14651. t['Jmonospace'] = 0xFF2A;
  14652. t['Jsmall'] = 0xF76A;
  14653. t['K'] = 0x004B;
  14654. t['KBsquare'] = 0x3385;
  14655. t['KKsquare'] = 0x33CD;
  14656. t['Kabashkircyrillic'] = 0x04A0;
  14657. t['Kacute'] = 0x1E30;
  14658. t['Kacyrillic'] = 0x041A;
  14659. t['Kadescendercyrillic'] = 0x049A;
  14660. t['Kahookcyrillic'] = 0x04C3;
  14661. t['Kappa'] = 0x039A;
  14662. t['Kastrokecyrillic'] = 0x049E;
  14663. t['Kaverticalstrokecyrillic'] = 0x049C;
  14664. t['Kcaron'] = 0x01E8;
  14665. t['Kcedilla'] = 0x0136;
  14666. t['Kcircle'] = 0x24C0;
  14667. t['Kcommaaccent'] = 0x0136;
  14668. t['Kdotbelow'] = 0x1E32;
  14669. t['Keharmenian'] = 0x0554;
  14670. t['Kenarmenian'] = 0x053F;
  14671. t['Khacyrillic'] = 0x0425;
  14672. t['Kheicoptic'] = 0x03E6;
  14673. t['Khook'] = 0x0198;
  14674. t['Kjecyrillic'] = 0x040C;
  14675. t['Klinebelow'] = 0x1E34;
  14676. t['Kmonospace'] = 0xFF2B;
  14677. t['Koppacyrillic'] = 0x0480;
  14678. t['Koppagreek'] = 0x03DE;
  14679. t['Ksicyrillic'] = 0x046E;
  14680. t['Ksmall'] = 0xF76B;
  14681. t['L'] = 0x004C;
  14682. t['LJ'] = 0x01C7;
  14683. t['LL'] = 0xF6BF;
  14684. t['Lacute'] = 0x0139;
  14685. t['Lambda'] = 0x039B;
  14686. t['Lcaron'] = 0x013D;
  14687. t['Lcedilla'] = 0x013B;
  14688. t['Lcircle'] = 0x24C1;
  14689. t['Lcircumflexbelow'] = 0x1E3C;
  14690. t['Lcommaaccent'] = 0x013B;
  14691. t['Ldot'] = 0x013F;
  14692. t['Ldotaccent'] = 0x013F;
  14693. t['Ldotbelow'] = 0x1E36;
  14694. t['Ldotbelowmacron'] = 0x1E38;
  14695. t['Liwnarmenian'] = 0x053C;
  14696. t['Lj'] = 0x01C8;
  14697. t['Ljecyrillic'] = 0x0409;
  14698. t['Llinebelow'] = 0x1E3A;
  14699. t['Lmonospace'] = 0xFF2C;
  14700. t['Lslash'] = 0x0141;
  14701. t['Lslashsmall'] = 0xF6F9;
  14702. t['Lsmall'] = 0xF76C;
  14703. t['M'] = 0x004D;
  14704. t['MBsquare'] = 0x3386;
  14705. t['Macron'] = 0xF6D0;
  14706. t['Macronsmall'] = 0xF7AF;
  14707. t['Macute'] = 0x1E3E;
  14708. t['Mcircle'] = 0x24C2;
  14709. t['Mdotaccent'] = 0x1E40;
  14710. t['Mdotbelow'] = 0x1E42;
  14711. t['Menarmenian'] = 0x0544;
  14712. t['Mmonospace'] = 0xFF2D;
  14713. t['Msmall'] = 0xF76D;
  14714. t['Mturned'] = 0x019C;
  14715. t['Mu'] = 0x039C;
  14716. t['N'] = 0x004E;
  14717. t['NJ'] = 0x01CA;
  14718. t['Nacute'] = 0x0143;
  14719. t['Ncaron'] = 0x0147;
  14720. t['Ncedilla'] = 0x0145;
  14721. t['Ncircle'] = 0x24C3;
  14722. t['Ncircumflexbelow'] = 0x1E4A;
  14723. t['Ncommaaccent'] = 0x0145;
  14724. t['Ndotaccent'] = 0x1E44;
  14725. t['Ndotbelow'] = 0x1E46;
  14726. t['Nhookleft'] = 0x019D;
  14727. t['Nineroman'] = 0x2168;
  14728. t['Nj'] = 0x01CB;
  14729. t['Njecyrillic'] = 0x040A;
  14730. t['Nlinebelow'] = 0x1E48;
  14731. t['Nmonospace'] = 0xFF2E;
  14732. t['Nowarmenian'] = 0x0546;
  14733. t['Nsmall'] = 0xF76E;
  14734. t['Ntilde'] = 0x00D1;
  14735. t['Ntildesmall'] = 0xF7F1;
  14736. t['Nu'] = 0x039D;
  14737. t['O'] = 0x004F;
  14738. t['OE'] = 0x0152;
  14739. t['OEsmall'] = 0xF6FA;
  14740. t['Oacute'] = 0x00D3;
  14741. t['Oacutesmall'] = 0xF7F3;
  14742. t['Obarredcyrillic'] = 0x04E8;
  14743. t['Obarreddieresiscyrillic'] = 0x04EA;
  14744. t['Obreve'] = 0x014E;
  14745. t['Ocaron'] = 0x01D1;
  14746. t['Ocenteredtilde'] = 0x019F;
  14747. t['Ocircle'] = 0x24C4;
  14748. t['Ocircumflex'] = 0x00D4;
  14749. t['Ocircumflexacute'] = 0x1ED0;
  14750. t['Ocircumflexdotbelow'] = 0x1ED8;
  14751. t['Ocircumflexgrave'] = 0x1ED2;
  14752. t['Ocircumflexhookabove'] = 0x1ED4;
  14753. t['Ocircumflexsmall'] = 0xF7F4;
  14754. t['Ocircumflextilde'] = 0x1ED6;
  14755. t['Ocyrillic'] = 0x041E;
  14756. t['Odblacute'] = 0x0150;
  14757. t['Odblgrave'] = 0x020C;
  14758. t['Odieresis'] = 0x00D6;
  14759. t['Odieresiscyrillic'] = 0x04E6;
  14760. t['Odieresissmall'] = 0xF7F6;
  14761. t['Odotbelow'] = 0x1ECC;
  14762. t['Ogoneksmall'] = 0xF6FB;
  14763. t['Ograve'] = 0x00D2;
  14764. t['Ogravesmall'] = 0xF7F2;
  14765. t['Oharmenian'] = 0x0555;
  14766. t['Ohm'] = 0x2126;
  14767. t['Ohookabove'] = 0x1ECE;
  14768. t['Ohorn'] = 0x01A0;
  14769. t['Ohornacute'] = 0x1EDA;
  14770. t['Ohorndotbelow'] = 0x1EE2;
  14771. t['Ohorngrave'] = 0x1EDC;
  14772. t['Ohornhookabove'] = 0x1EDE;
  14773. t['Ohorntilde'] = 0x1EE0;
  14774. t['Ohungarumlaut'] = 0x0150;
  14775. t['Oi'] = 0x01A2;
  14776. t['Oinvertedbreve'] = 0x020E;
  14777. t['Omacron'] = 0x014C;
  14778. t['Omacronacute'] = 0x1E52;
  14779. t['Omacrongrave'] = 0x1E50;
  14780. t['Omega'] = 0x2126;
  14781. t['Omegacyrillic'] = 0x0460;
  14782. t['Omegagreek'] = 0x03A9;
  14783. t['Omegaroundcyrillic'] = 0x047A;
  14784. t['Omegatitlocyrillic'] = 0x047C;
  14785. t['Omegatonos'] = 0x038F;
  14786. t['Omicron'] = 0x039F;
  14787. t['Omicrontonos'] = 0x038C;
  14788. t['Omonospace'] = 0xFF2F;
  14789. t['Oneroman'] = 0x2160;
  14790. t['Oogonek'] = 0x01EA;
  14791. t['Oogonekmacron'] = 0x01EC;
  14792. t['Oopen'] = 0x0186;
  14793. t['Oslash'] = 0x00D8;
  14794. t['Oslashacute'] = 0x01FE;
  14795. t['Oslashsmall'] = 0xF7F8;
  14796. t['Osmall'] = 0xF76F;
  14797. t['Ostrokeacute'] = 0x01FE;
  14798. t['Otcyrillic'] = 0x047E;
  14799. t['Otilde'] = 0x00D5;
  14800. t['Otildeacute'] = 0x1E4C;
  14801. t['Otildedieresis'] = 0x1E4E;
  14802. t['Otildesmall'] = 0xF7F5;
  14803. t['P'] = 0x0050;
  14804. t['Pacute'] = 0x1E54;
  14805. t['Pcircle'] = 0x24C5;
  14806. t['Pdotaccent'] = 0x1E56;
  14807. t['Pecyrillic'] = 0x041F;
  14808. t['Peharmenian'] = 0x054A;
  14809. t['Pemiddlehookcyrillic'] = 0x04A6;
  14810. t['Phi'] = 0x03A6;
  14811. t['Phook'] = 0x01A4;
  14812. t['Pi'] = 0x03A0;
  14813. t['Piwrarmenian'] = 0x0553;
  14814. t['Pmonospace'] = 0xFF30;
  14815. t['Psi'] = 0x03A8;
  14816. t['Psicyrillic'] = 0x0470;
  14817. t['Psmall'] = 0xF770;
  14818. t['Q'] = 0x0051;
  14819. t['Qcircle'] = 0x24C6;
  14820. t['Qmonospace'] = 0xFF31;
  14821. t['Qsmall'] = 0xF771;
  14822. t['R'] = 0x0052;
  14823. t['Raarmenian'] = 0x054C;
  14824. t['Racute'] = 0x0154;
  14825. t['Rcaron'] = 0x0158;
  14826. t['Rcedilla'] = 0x0156;
  14827. t['Rcircle'] = 0x24C7;
  14828. t['Rcommaaccent'] = 0x0156;
  14829. t['Rdblgrave'] = 0x0210;
  14830. t['Rdotaccent'] = 0x1E58;
  14831. t['Rdotbelow'] = 0x1E5A;
  14832. t['Rdotbelowmacron'] = 0x1E5C;
  14833. t['Reharmenian'] = 0x0550;
  14834. t['Rfraktur'] = 0x211C;
  14835. t['Rho'] = 0x03A1;
  14836. t['Ringsmall'] = 0xF6FC;
  14837. t['Rinvertedbreve'] = 0x0212;
  14838. t['Rlinebelow'] = 0x1E5E;
  14839. t['Rmonospace'] = 0xFF32;
  14840. t['Rsmall'] = 0xF772;
  14841. t['Rsmallinverted'] = 0x0281;
  14842. t['Rsmallinvertedsuperior'] = 0x02B6;
  14843. t['S'] = 0x0053;
  14844. t['SF010000'] = 0x250C;
  14845. t['SF020000'] = 0x2514;
  14846. t['SF030000'] = 0x2510;
  14847. t['SF040000'] = 0x2518;
  14848. t['SF050000'] = 0x253C;
  14849. t['SF060000'] = 0x252C;
  14850. t['SF070000'] = 0x2534;
  14851. t['SF080000'] = 0x251C;
  14852. t['SF090000'] = 0x2524;
  14853. t['SF100000'] = 0x2500;
  14854. t['SF110000'] = 0x2502;
  14855. t['SF190000'] = 0x2561;
  14856. t['SF200000'] = 0x2562;
  14857. t['SF210000'] = 0x2556;
  14858. t['SF220000'] = 0x2555;
  14859. t['SF230000'] = 0x2563;
  14860. t['SF240000'] = 0x2551;
  14861. t['SF250000'] = 0x2557;
  14862. t['SF260000'] = 0x255D;
  14863. t['SF270000'] = 0x255C;
  14864. t['SF280000'] = 0x255B;
  14865. t['SF360000'] = 0x255E;
  14866. t['SF370000'] = 0x255F;
  14867. t['SF380000'] = 0x255A;
  14868. t['SF390000'] = 0x2554;
  14869. t['SF400000'] = 0x2569;
  14870. t['SF410000'] = 0x2566;
  14871. t['SF420000'] = 0x2560;
  14872. t['SF430000'] = 0x2550;
  14873. t['SF440000'] = 0x256C;
  14874. t['SF450000'] = 0x2567;
  14875. t['SF460000'] = 0x2568;
  14876. t['SF470000'] = 0x2564;
  14877. t['SF480000'] = 0x2565;
  14878. t['SF490000'] = 0x2559;
  14879. t['SF500000'] = 0x2558;
  14880. t['SF510000'] = 0x2552;
  14881. t['SF520000'] = 0x2553;
  14882. t['SF530000'] = 0x256B;
  14883. t['SF540000'] = 0x256A;
  14884. t['Sacute'] = 0x015A;
  14885. t['Sacutedotaccent'] = 0x1E64;
  14886. t['Sampigreek'] = 0x03E0;
  14887. t['Scaron'] = 0x0160;
  14888. t['Scarondotaccent'] = 0x1E66;
  14889. t['Scaronsmall'] = 0xF6FD;
  14890. t['Scedilla'] = 0x015E;
  14891. t['Schwa'] = 0x018F;
  14892. t['Schwacyrillic'] = 0x04D8;
  14893. t['Schwadieresiscyrillic'] = 0x04DA;
  14894. t['Scircle'] = 0x24C8;
  14895. t['Scircumflex'] = 0x015C;
  14896. t['Scommaaccent'] = 0x0218;
  14897. t['Sdotaccent'] = 0x1E60;
  14898. t['Sdotbelow'] = 0x1E62;
  14899. t['Sdotbelowdotaccent'] = 0x1E68;
  14900. t['Seharmenian'] = 0x054D;
  14901. t['Sevenroman'] = 0x2166;
  14902. t['Shaarmenian'] = 0x0547;
  14903. t['Shacyrillic'] = 0x0428;
  14904. t['Shchacyrillic'] = 0x0429;
  14905. t['Sheicoptic'] = 0x03E2;
  14906. t['Shhacyrillic'] = 0x04BA;
  14907. t['Shimacoptic'] = 0x03EC;
  14908. t['Sigma'] = 0x03A3;
  14909. t['Sixroman'] = 0x2165;
  14910. t['Smonospace'] = 0xFF33;
  14911. t['Softsigncyrillic'] = 0x042C;
  14912. t['Ssmall'] = 0xF773;
  14913. t['Stigmagreek'] = 0x03DA;
  14914. t['T'] = 0x0054;
  14915. t['Tau'] = 0x03A4;
  14916. t['Tbar'] = 0x0166;
  14917. t['Tcaron'] = 0x0164;
  14918. t['Tcedilla'] = 0x0162;
  14919. t['Tcircle'] = 0x24C9;
  14920. t['Tcircumflexbelow'] = 0x1E70;
  14921. t['Tcommaaccent'] = 0x0162;
  14922. t['Tdotaccent'] = 0x1E6A;
  14923. t['Tdotbelow'] = 0x1E6C;
  14924. t['Tecyrillic'] = 0x0422;
  14925. t['Tedescendercyrillic'] = 0x04AC;
  14926. t['Tenroman'] = 0x2169;
  14927. t['Tetsecyrillic'] = 0x04B4;
  14928. t['Theta'] = 0x0398;
  14929. t['Thook'] = 0x01AC;
  14930. t['Thorn'] = 0x00DE;
  14931. t['Thornsmall'] = 0xF7FE;
  14932. t['Threeroman'] = 0x2162;
  14933. t['Tildesmall'] = 0xF6FE;
  14934. t['Tiwnarmenian'] = 0x054F;
  14935. t['Tlinebelow'] = 0x1E6E;
  14936. t['Tmonospace'] = 0xFF34;
  14937. t['Toarmenian'] = 0x0539;
  14938. t['Tonefive'] = 0x01BC;
  14939. t['Tonesix'] = 0x0184;
  14940. t['Tonetwo'] = 0x01A7;
  14941. t['Tretroflexhook'] = 0x01AE;
  14942. t['Tsecyrillic'] = 0x0426;
  14943. t['Tshecyrillic'] = 0x040B;
  14944. t['Tsmall'] = 0xF774;
  14945. t['Twelveroman'] = 0x216B;
  14946. t['Tworoman'] = 0x2161;
  14947. t['U'] = 0x0055;
  14948. t['Uacute'] = 0x00DA;
  14949. t['Uacutesmall'] = 0xF7FA;
  14950. t['Ubreve'] = 0x016C;
  14951. t['Ucaron'] = 0x01D3;
  14952. t['Ucircle'] = 0x24CA;
  14953. t['Ucircumflex'] = 0x00DB;
  14954. t['Ucircumflexbelow'] = 0x1E76;
  14955. t['Ucircumflexsmall'] = 0xF7FB;
  14956. t['Ucyrillic'] = 0x0423;
  14957. t['Udblacute'] = 0x0170;
  14958. t['Udblgrave'] = 0x0214;
  14959. t['Udieresis'] = 0x00DC;
  14960. t['Udieresisacute'] = 0x01D7;
  14961. t['Udieresisbelow'] = 0x1E72;
  14962. t['Udieresiscaron'] = 0x01D9;
  14963. t['Udieresiscyrillic'] = 0x04F0;
  14964. t['Udieresisgrave'] = 0x01DB;
  14965. t['Udieresismacron'] = 0x01D5;
  14966. t['Udieresissmall'] = 0xF7FC;
  14967. t['Udotbelow'] = 0x1EE4;
  14968. t['Ugrave'] = 0x00D9;
  14969. t['Ugravesmall'] = 0xF7F9;
  14970. t['Uhookabove'] = 0x1EE6;
  14971. t['Uhorn'] = 0x01AF;
  14972. t['Uhornacute'] = 0x1EE8;
  14973. t['Uhorndotbelow'] = 0x1EF0;
  14974. t['Uhorngrave'] = 0x1EEA;
  14975. t['Uhornhookabove'] = 0x1EEC;
  14976. t['Uhorntilde'] = 0x1EEE;
  14977. t['Uhungarumlaut'] = 0x0170;
  14978. t['Uhungarumlautcyrillic'] = 0x04F2;
  14979. t['Uinvertedbreve'] = 0x0216;
  14980. t['Ukcyrillic'] = 0x0478;
  14981. t['Umacron'] = 0x016A;
  14982. t['Umacroncyrillic'] = 0x04EE;
  14983. t['Umacrondieresis'] = 0x1E7A;
  14984. t['Umonospace'] = 0xFF35;
  14985. t['Uogonek'] = 0x0172;
  14986. t['Upsilon'] = 0x03A5;
  14987. t['Upsilon1'] = 0x03D2;
  14988. t['Upsilonacutehooksymbolgreek'] = 0x03D3;
  14989. t['Upsilonafrican'] = 0x01B1;
  14990. t['Upsilondieresis'] = 0x03AB;
  14991. t['Upsilondieresishooksymbolgreek'] = 0x03D4;
  14992. t['Upsilonhooksymbol'] = 0x03D2;
  14993. t['Upsilontonos'] = 0x038E;
  14994. t['Uring'] = 0x016E;
  14995. t['Ushortcyrillic'] = 0x040E;
  14996. t['Usmall'] = 0xF775;
  14997. t['Ustraightcyrillic'] = 0x04AE;
  14998. t['Ustraightstrokecyrillic'] = 0x04B0;
  14999. t['Utilde'] = 0x0168;
  15000. t['Utildeacute'] = 0x1E78;
  15001. t['Utildebelow'] = 0x1E74;
  15002. t['V'] = 0x0056;
  15003. t['Vcircle'] = 0x24CB;
  15004. t['Vdotbelow'] = 0x1E7E;
  15005. t['Vecyrillic'] = 0x0412;
  15006. t['Vewarmenian'] = 0x054E;
  15007. t['Vhook'] = 0x01B2;
  15008. t['Vmonospace'] = 0xFF36;
  15009. t['Voarmenian'] = 0x0548;
  15010. t['Vsmall'] = 0xF776;
  15011. t['Vtilde'] = 0x1E7C;
  15012. t['W'] = 0x0057;
  15013. t['Wacute'] = 0x1E82;
  15014. t['Wcircle'] = 0x24CC;
  15015. t['Wcircumflex'] = 0x0174;
  15016. t['Wdieresis'] = 0x1E84;
  15017. t['Wdotaccent'] = 0x1E86;
  15018. t['Wdotbelow'] = 0x1E88;
  15019. t['Wgrave'] = 0x1E80;
  15020. t['Wmonospace'] = 0xFF37;
  15021. t['Wsmall'] = 0xF777;
  15022. t['X'] = 0x0058;
  15023. t['Xcircle'] = 0x24CD;
  15024. t['Xdieresis'] = 0x1E8C;
  15025. t['Xdotaccent'] = 0x1E8A;
  15026. t['Xeharmenian'] = 0x053D;
  15027. t['Xi'] = 0x039E;
  15028. t['Xmonospace'] = 0xFF38;
  15029. t['Xsmall'] = 0xF778;
  15030. t['Y'] = 0x0059;
  15031. t['Yacute'] = 0x00DD;
  15032. t['Yacutesmall'] = 0xF7FD;
  15033. t['Yatcyrillic'] = 0x0462;
  15034. t['Ycircle'] = 0x24CE;
  15035. t['Ycircumflex'] = 0x0176;
  15036. t['Ydieresis'] = 0x0178;
  15037. t['Ydieresissmall'] = 0xF7FF;
  15038. t['Ydotaccent'] = 0x1E8E;
  15039. t['Ydotbelow'] = 0x1EF4;
  15040. t['Yericyrillic'] = 0x042B;
  15041. t['Yerudieresiscyrillic'] = 0x04F8;
  15042. t['Ygrave'] = 0x1EF2;
  15043. t['Yhook'] = 0x01B3;
  15044. t['Yhookabove'] = 0x1EF6;
  15045. t['Yiarmenian'] = 0x0545;
  15046. t['Yicyrillic'] = 0x0407;
  15047. t['Yiwnarmenian'] = 0x0552;
  15048. t['Ymonospace'] = 0xFF39;
  15049. t['Ysmall'] = 0xF779;
  15050. t['Ytilde'] = 0x1EF8;
  15051. t['Yusbigcyrillic'] = 0x046A;
  15052. t['Yusbigiotifiedcyrillic'] = 0x046C;
  15053. t['Yuslittlecyrillic'] = 0x0466;
  15054. t['Yuslittleiotifiedcyrillic'] = 0x0468;
  15055. t['Z'] = 0x005A;
  15056. t['Zaarmenian'] = 0x0536;
  15057. t['Zacute'] = 0x0179;
  15058. t['Zcaron'] = 0x017D;
  15059. t['Zcaronsmall'] = 0xF6FF;
  15060. t['Zcircle'] = 0x24CF;
  15061. t['Zcircumflex'] = 0x1E90;
  15062. t['Zdot'] = 0x017B;
  15063. t['Zdotaccent'] = 0x017B;
  15064. t['Zdotbelow'] = 0x1E92;
  15065. t['Zecyrillic'] = 0x0417;
  15066. t['Zedescendercyrillic'] = 0x0498;
  15067. t['Zedieresiscyrillic'] = 0x04DE;
  15068. t['Zeta'] = 0x0396;
  15069. t['Zhearmenian'] = 0x053A;
  15070. t['Zhebrevecyrillic'] = 0x04C1;
  15071. t['Zhecyrillic'] = 0x0416;
  15072. t['Zhedescendercyrillic'] = 0x0496;
  15073. t['Zhedieresiscyrillic'] = 0x04DC;
  15074. t['Zlinebelow'] = 0x1E94;
  15075. t['Zmonospace'] = 0xFF3A;
  15076. t['Zsmall'] = 0xF77A;
  15077. t['Zstroke'] = 0x01B5;
  15078. t['a'] = 0x0061;
  15079. t['aabengali'] = 0x0986;
  15080. t['aacute'] = 0x00E1;
  15081. t['aadeva'] = 0x0906;
  15082. t['aagujarati'] = 0x0A86;
  15083. t['aagurmukhi'] = 0x0A06;
  15084. t['aamatragurmukhi'] = 0x0A3E;
  15085. t['aarusquare'] = 0x3303;
  15086. t['aavowelsignbengali'] = 0x09BE;
  15087. t['aavowelsigndeva'] = 0x093E;
  15088. t['aavowelsigngujarati'] = 0x0ABE;
  15089. t['abbreviationmarkarmenian'] = 0x055F;
  15090. t['abbreviationsigndeva'] = 0x0970;
  15091. t['abengali'] = 0x0985;
  15092. t['abopomofo'] = 0x311A;
  15093. t['abreve'] = 0x0103;
  15094. t['abreveacute'] = 0x1EAF;
  15095. t['abrevecyrillic'] = 0x04D1;
  15096. t['abrevedotbelow'] = 0x1EB7;
  15097. t['abrevegrave'] = 0x1EB1;
  15098. t['abrevehookabove'] = 0x1EB3;
  15099. t['abrevetilde'] = 0x1EB5;
  15100. t['acaron'] = 0x01CE;
  15101. t['acircle'] = 0x24D0;
  15102. t['acircumflex'] = 0x00E2;
  15103. t['acircumflexacute'] = 0x1EA5;
  15104. t['acircumflexdotbelow'] = 0x1EAD;
  15105. t['acircumflexgrave'] = 0x1EA7;
  15106. t['acircumflexhookabove'] = 0x1EA9;
  15107. t['acircumflextilde'] = 0x1EAB;
  15108. t['acute'] = 0x00B4;
  15109. t['acutebelowcmb'] = 0x0317;
  15110. t['acutecmb'] = 0x0301;
  15111. t['acutecomb'] = 0x0301;
  15112. t['acutedeva'] = 0x0954;
  15113. t['acutelowmod'] = 0x02CF;
  15114. t['acutetonecmb'] = 0x0341;
  15115. t['acyrillic'] = 0x0430;
  15116. t['adblgrave'] = 0x0201;
  15117. t['addakgurmukhi'] = 0x0A71;
  15118. t['adeva'] = 0x0905;
  15119. t['adieresis'] = 0x00E4;
  15120. t['adieresiscyrillic'] = 0x04D3;
  15121. t['adieresismacron'] = 0x01DF;
  15122. t['adotbelow'] = 0x1EA1;
  15123. t['adotmacron'] = 0x01E1;
  15124. t['ae'] = 0x00E6;
  15125. t['aeacute'] = 0x01FD;
  15126. t['aekorean'] = 0x3150;
  15127. t['aemacron'] = 0x01E3;
  15128. t['afii00208'] = 0x2015;
  15129. t['afii08941'] = 0x20A4;
  15130. t['afii10017'] = 0x0410;
  15131. t['afii10018'] = 0x0411;
  15132. t['afii10019'] = 0x0412;
  15133. t['afii10020'] = 0x0413;
  15134. t['afii10021'] = 0x0414;
  15135. t['afii10022'] = 0x0415;
  15136. t['afii10023'] = 0x0401;
  15137. t['afii10024'] = 0x0416;
  15138. t['afii10025'] = 0x0417;
  15139. t['afii10026'] = 0x0418;
  15140. t['afii10027'] = 0x0419;
  15141. t['afii10028'] = 0x041A;
  15142. t['afii10029'] = 0x041B;
  15143. t['afii10030'] = 0x041C;
  15144. t['afii10031'] = 0x041D;
  15145. t['afii10032'] = 0x041E;
  15146. t['afii10033'] = 0x041F;
  15147. t['afii10034'] = 0x0420;
  15148. t['afii10035'] = 0x0421;
  15149. t['afii10036'] = 0x0422;
  15150. t['afii10037'] = 0x0423;
  15151. t['afii10038'] = 0x0424;
  15152. t['afii10039'] = 0x0425;
  15153. t['afii10040'] = 0x0426;
  15154. t['afii10041'] = 0x0427;
  15155. t['afii10042'] = 0x0428;
  15156. t['afii10043'] = 0x0429;
  15157. t['afii10044'] = 0x042A;
  15158. t['afii10045'] = 0x042B;
  15159. t['afii10046'] = 0x042C;
  15160. t['afii10047'] = 0x042D;
  15161. t['afii10048'] = 0x042E;
  15162. t['afii10049'] = 0x042F;
  15163. t['afii10050'] = 0x0490;
  15164. t['afii10051'] = 0x0402;
  15165. t['afii10052'] = 0x0403;
  15166. t['afii10053'] = 0x0404;
  15167. t['afii10054'] = 0x0405;
  15168. t['afii10055'] = 0x0406;
  15169. t['afii10056'] = 0x0407;
  15170. t['afii10057'] = 0x0408;
  15171. t['afii10058'] = 0x0409;
  15172. t['afii10059'] = 0x040A;
  15173. t['afii10060'] = 0x040B;
  15174. t['afii10061'] = 0x040C;
  15175. t['afii10062'] = 0x040E;
  15176. t['afii10063'] = 0xF6C4;
  15177. t['afii10064'] = 0xF6C5;
  15178. t['afii10065'] = 0x0430;
  15179. t['afii10066'] = 0x0431;
  15180. t['afii10067'] = 0x0432;
  15181. t['afii10068'] = 0x0433;
  15182. t['afii10069'] = 0x0434;
  15183. t['afii10070'] = 0x0435;
  15184. t['afii10071'] = 0x0451;
  15185. t['afii10072'] = 0x0436;
  15186. t['afii10073'] = 0x0437;
  15187. t['afii10074'] = 0x0438;
  15188. t['afii10075'] = 0x0439;
  15189. t['afii10076'] = 0x043A;
  15190. t['afii10077'] = 0x043B;
  15191. t['afii10078'] = 0x043C;
  15192. t['afii10079'] = 0x043D;
  15193. t['afii10080'] = 0x043E;
  15194. t['afii10081'] = 0x043F;
  15195. t['afii10082'] = 0x0440;
  15196. t['afii10083'] = 0x0441;
  15197. t['afii10084'] = 0x0442;
  15198. t['afii10085'] = 0x0443;
  15199. t['afii10086'] = 0x0444;
  15200. t['afii10087'] = 0x0445;
  15201. t['afii10088'] = 0x0446;
  15202. t['afii10089'] = 0x0447;
  15203. t['afii10090'] = 0x0448;
  15204. t['afii10091'] = 0x0449;
  15205. t['afii10092'] = 0x044A;
  15206. t['afii10093'] = 0x044B;
  15207. t['afii10094'] = 0x044C;
  15208. t['afii10095'] = 0x044D;
  15209. t['afii10096'] = 0x044E;
  15210. t['afii10097'] = 0x044F;
  15211. t['afii10098'] = 0x0491;
  15212. t['afii10099'] = 0x0452;
  15213. t['afii10100'] = 0x0453;
  15214. t['afii10101'] = 0x0454;
  15215. t['afii10102'] = 0x0455;
  15216. t['afii10103'] = 0x0456;
  15217. t['afii10104'] = 0x0457;
  15218. t['afii10105'] = 0x0458;
  15219. t['afii10106'] = 0x0459;
  15220. t['afii10107'] = 0x045A;
  15221. t['afii10108'] = 0x045B;
  15222. t['afii10109'] = 0x045C;
  15223. t['afii10110'] = 0x045E;
  15224. t['afii10145'] = 0x040F;
  15225. t['afii10146'] = 0x0462;
  15226. t['afii10147'] = 0x0472;
  15227. t['afii10148'] = 0x0474;
  15228. t['afii10192'] = 0xF6C6;
  15229. t['afii10193'] = 0x045F;
  15230. t['afii10194'] = 0x0463;
  15231. t['afii10195'] = 0x0473;
  15232. t['afii10196'] = 0x0475;
  15233. t['afii10831'] = 0xF6C7;
  15234. t['afii10832'] = 0xF6C8;
  15235. t['afii10846'] = 0x04D9;
  15236. t['afii299'] = 0x200E;
  15237. t['afii300'] = 0x200F;
  15238. t['afii301'] = 0x200D;
  15239. t['afii57381'] = 0x066A;
  15240. t['afii57388'] = 0x060C;
  15241. t['afii57392'] = 0x0660;
  15242. t['afii57393'] = 0x0661;
  15243. t['afii57394'] = 0x0662;
  15244. t['afii57395'] = 0x0663;
  15245. t['afii57396'] = 0x0664;
  15246. t['afii57397'] = 0x0665;
  15247. t['afii57398'] = 0x0666;
  15248. t['afii57399'] = 0x0667;
  15249. t['afii57400'] = 0x0668;
  15250. t['afii57401'] = 0x0669;
  15251. t['afii57403'] = 0x061B;
  15252. t['afii57407'] = 0x061F;
  15253. t['afii57409'] = 0x0621;
  15254. t['afii57410'] = 0x0622;
  15255. t['afii57411'] = 0x0623;
  15256. t['afii57412'] = 0x0624;
  15257. t['afii57413'] = 0x0625;
  15258. t['afii57414'] = 0x0626;
  15259. t['afii57415'] = 0x0627;
  15260. t['afii57416'] = 0x0628;
  15261. t['afii57417'] = 0x0629;
  15262. t['afii57418'] = 0x062A;
  15263. t['afii57419'] = 0x062B;
  15264. t['afii57420'] = 0x062C;
  15265. t['afii57421'] = 0x062D;
  15266. t['afii57422'] = 0x062E;
  15267. t['afii57423'] = 0x062F;
  15268. t['afii57424'] = 0x0630;
  15269. t['afii57425'] = 0x0631;
  15270. t['afii57426'] = 0x0632;
  15271. t['afii57427'] = 0x0633;
  15272. t['afii57428'] = 0x0634;
  15273. t['afii57429'] = 0x0635;
  15274. t['afii57430'] = 0x0636;
  15275. t['afii57431'] = 0x0637;
  15276. t['afii57432'] = 0x0638;
  15277. t['afii57433'] = 0x0639;
  15278. t['afii57434'] = 0x063A;
  15279. t['afii57440'] = 0x0640;
  15280. t['afii57441'] = 0x0641;
  15281. t['afii57442'] = 0x0642;
  15282. t['afii57443'] = 0x0643;
  15283. t['afii57444'] = 0x0644;
  15284. t['afii57445'] = 0x0645;
  15285. t['afii57446'] = 0x0646;
  15286. t['afii57448'] = 0x0648;
  15287. t['afii57449'] = 0x0649;
  15288. t['afii57450'] = 0x064A;
  15289. t['afii57451'] = 0x064B;
  15290. t['afii57452'] = 0x064C;
  15291. t['afii57453'] = 0x064D;
  15292. t['afii57454'] = 0x064E;
  15293. t['afii57455'] = 0x064F;
  15294. t['afii57456'] = 0x0650;
  15295. t['afii57457'] = 0x0651;
  15296. t['afii57458'] = 0x0652;
  15297. t['afii57470'] = 0x0647;
  15298. t['afii57505'] = 0x06A4;
  15299. t['afii57506'] = 0x067E;
  15300. t['afii57507'] = 0x0686;
  15301. t['afii57508'] = 0x0698;
  15302. t['afii57509'] = 0x06AF;
  15303. t['afii57511'] = 0x0679;
  15304. t['afii57512'] = 0x0688;
  15305. t['afii57513'] = 0x0691;
  15306. t['afii57514'] = 0x06BA;
  15307. t['afii57519'] = 0x06D2;
  15308. t['afii57534'] = 0x06D5;
  15309. t['afii57636'] = 0x20AA;
  15310. t['afii57645'] = 0x05BE;
  15311. t['afii57658'] = 0x05C3;
  15312. t['afii57664'] = 0x05D0;
  15313. t['afii57665'] = 0x05D1;
  15314. t['afii57666'] = 0x05D2;
  15315. t['afii57667'] = 0x05D3;
  15316. t['afii57668'] = 0x05D4;
  15317. t['afii57669'] = 0x05D5;
  15318. t['afii57670'] = 0x05D6;
  15319. t['afii57671'] = 0x05D7;
  15320. t['afii57672'] = 0x05D8;
  15321. t['afii57673'] = 0x05D9;
  15322. t['afii57674'] = 0x05DA;
  15323. t['afii57675'] = 0x05DB;
  15324. t['afii57676'] = 0x05DC;
  15325. t['afii57677'] = 0x05DD;
  15326. t['afii57678'] = 0x05DE;
  15327. t['afii57679'] = 0x05DF;
  15328. t['afii57680'] = 0x05E0;
  15329. t['afii57681'] = 0x05E1;
  15330. t['afii57682'] = 0x05E2;
  15331. t['afii57683'] = 0x05E3;
  15332. t['afii57684'] = 0x05E4;
  15333. t['afii57685'] = 0x05E5;
  15334. t['afii57686'] = 0x05E6;
  15335. t['afii57687'] = 0x05E7;
  15336. t['afii57688'] = 0x05E8;
  15337. t['afii57689'] = 0x05E9;
  15338. t['afii57690'] = 0x05EA;
  15339. t['afii57694'] = 0xFB2A;
  15340. t['afii57695'] = 0xFB2B;
  15341. t['afii57700'] = 0xFB4B;
  15342. t['afii57705'] = 0xFB1F;
  15343. t['afii57716'] = 0x05F0;
  15344. t['afii57717'] = 0x05F1;
  15345. t['afii57718'] = 0x05F2;
  15346. t['afii57723'] = 0xFB35;
  15347. t['afii57793'] = 0x05B4;
  15348. t['afii57794'] = 0x05B5;
  15349. t['afii57795'] = 0x05B6;
  15350. t['afii57796'] = 0x05BB;
  15351. t['afii57797'] = 0x05B8;
  15352. t['afii57798'] = 0x05B7;
  15353. t['afii57799'] = 0x05B0;
  15354. t['afii57800'] = 0x05B2;
  15355. t['afii57801'] = 0x05B1;
  15356. t['afii57802'] = 0x05B3;
  15357. t['afii57803'] = 0x05C2;
  15358. t['afii57804'] = 0x05C1;
  15359. t['afii57806'] = 0x05B9;
  15360. t['afii57807'] = 0x05BC;
  15361. t['afii57839'] = 0x05BD;
  15362. t['afii57841'] = 0x05BF;
  15363. t['afii57842'] = 0x05C0;
  15364. t['afii57929'] = 0x02BC;
  15365. t['afii61248'] = 0x2105;
  15366. t['afii61289'] = 0x2113;
  15367. t['afii61352'] = 0x2116;
  15368. t['afii61573'] = 0x202C;
  15369. t['afii61574'] = 0x202D;
  15370. t['afii61575'] = 0x202E;
  15371. t['afii61664'] = 0x200C;
  15372. t['afii63167'] = 0x066D;
  15373. t['afii64937'] = 0x02BD;
  15374. t['agrave'] = 0x00E0;
  15375. t['agujarati'] = 0x0A85;
  15376. t['agurmukhi'] = 0x0A05;
  15377. t['ahiragana'] = 0x3042;
  15378. t['ahookabove'] = 0x1EA3;
  15379. t['aibengali'] = 0x0990;
  15380. t['aibopomofo'] = 0x311E;
  15381. t['aideva'] = 0x0910;
  15382. t['aiecyrillic'] = 0x04D5;
  15383. t['aigujarati'] = 0x0A90;
  15384. t['aigurmukhi'] = 0x0A10;
  15385. t['aimatragurmukhi'] = 0x0A48;
  15386. t['ainarabic'] = 0x0639;
  15387. t['ainfinalarabic'] = 0xFECA;
  15388. t['aininitialarabic'] = 0xFECB;
  15389. t['ainmedialarabic'] = 0xFECC;
  15390. t['ainvertedbreve'] = 0x0203;
  15391. t['aivowelsignbengali'] = 0x09C8;
  15392. t['aivowelsigndeva'] = 0x0948;
  15393. t['aivowelsigngujarati'] = 0x0AC8;
  15394. t['akatakana'] = 0x30A2;
  15395. t['akatakanahalfwidth'] = 0xFF71;
  15396. t['akorean'] = 0x314F;
  15397. t['alef'] = 0x05D0;
  15398. t['alefarabic'] = 0x0627;
  15399. t['alefdageshhebrew'] = 0xFB30;
  15400. t['aleffinalarabic'] = 0xFE8E;
  15401. t['alefhamzaabovearabic'] = 0x0623;
  15402. t['alefhamzaabovefinalarabic'] = 0xFE84;
  15403. t['alefhamzabelowarabic'] = 0x0625;
  15404. t['alefhamzabelowfinalarabic'] = 0xFE88;
  15405. t['alefhebrew'] = 0x05D0;
  15406. t['aleflamedhebrew'] = 0xFB4F;
  15407. t['alefmaddaabovearabic'] = 0x0622;
  15408. t['alefmaddaabovefinalarabic'] = 0xFE82;
  15409. t['alefmaksuraarabic'] = 0x0649;
  15410. t['alefmaksurafinalarabic'] = 0xFEF0;
  15411. t['alefmaksurainitialarabic'] = 0xFEF3;
  15412. t['alefmaksuramedialarabic'] = 0xFEF4;
  15413. t['alefpatahhebrew'] = 0xFB2E;
  15414. t['alefqamatshebrew'] = 0xFB2F;
  15415. t['aleph'] = 0x2135;
  15416. t['allequal'] = 0x224C;
  15417. t['alpha'] = 0x03B1;
  15418. t['alphatonos'] = 0x03AC;
  15419. t['amacron'] = 0x0101;
  15420. t['amonospace'] = 0xFF41;
  15421. t['ampersand'] = 0x0026;
  15422. t['ampersandmonospace'] = 0xFF06;
  15423. t['ampersandsmall'] = 0xF726;
  15424. t['amsquare'] = 0x33C2;
  15425. t['anbopomofo'] = 0x3122;
  15426. t['angbopomofo'] = 0x3124;
  15427. t['angbracketleft'] = 0x3008;
  15428. t['angbracketright'] = 0x3009;
  15429. t['angkhankhuthai'] = 0x0E5A;
  15430. t['angle'] = 0x2220;
  15431. t['anglebracketleft'] = 0x3008;
  15432. t['anglebracketleftvertical'] = 0xFE3F;
  15433. t['anglebracketright'] = 0x3009;
  15434. t['anglebracketrightvertical'] = 0xFE40;
  15435. t['angleleft'] = 0x2329;
  15436. t['angleright'] = 0x232A;
  15437. t['angstrom'] = 0x212B;
  15438. t['anoteleia'] = 0x0387;
  15439. t['anudattadeva'] = 0x0952;
  15440. t['anusvarabengali'] = 0x0982;
  15441. t['anusvaradeva'] = 0x0902;
  15442. t['anusvaragujarati'] = 0x0A82;
  15443. t['aogonek'] = 0x0105;
  15444. t['apaatosquare'] = 0x3300;
  15445. t['aparen'] = 0x249C;
  15446. t['apostrophearmenian'] = 0x055A;
  15447. t['apostrophemod'] = 0x02BC;
  15448. t['apple'] = 0xF8FF;
  15449. t['approaches'] = 0x2250;
  15450. t['approxequal'] = 0x2248;
  15451. t['approxequalorimage'] = 0x2252;
  15452. t['approximatelyequal'] = 0x2245;
  15453. t['araeaekorean'] = 0x318E;
  15454. t['araeakorean'] = 0x318D;
  15455. t['arc'] = 0x2312;
  15456. t['arighthalfring'] = 0x1E9A;
  15457. t['aring'] = 0x00E5;
  15458. t['aringacute'] = 0x01FB;
  15459. t['aringbelow'] = 0x1E01;
  15460. t['arrowboth'] = 0x2194;
  15461. t['arrowdashdown'] = 0x21E3;
  15462. t['arrowdashleft'] = 0x21E0;
  15463. t['arrowdashright'] = 0x21E2;
  15464. t['arrowdashup'] = 0x21E1;
  15465. t['arrowdblboth'] = 0x21D4;
  15466. t['arrowdbldown'] = 0x21D3;
  15467. t['arrowdblleft'] = 0x21D0;
  15468. t['arrowdblright'] = 0x21D2;
  15469. t['arrowdblup'] = 0x21D1;
  15470. t['arrowdown'] = 0x2193;
  15471. t['arrowdownleft'] = 0x2199;
  15472. t['arrowdownright'] = 0x2198;
  15473. t['arrowdownwhite'] = 0x21E9;
  15474. t['arrowheaddownmod'] = 0x02C5;
  15475. t['arrowheadleftmod'] = 0x02C2;
  15476. t['arrowheadrightmod'] = 0x02C3;
  15477. t['arrowheadupmod'] = 0x02C4;
  15478. t['arrowhorizex'] = 0xF8E7;
  15479. t['arrowleft'] = 0x2190;
  15480. t['arrowleftdbl'] = 0x21D0;
  15481. t['arrowleftdblstroke'] = 0x21CD;
  15482. t['arrowleftoverright'] = 0x21C6;
  15483. t['arrowleftwhite'] = 0x21E6;
  15484. t['arrowright'] = 0x2192;
  15485. t['arrowrightdblstroke'] = 0x21CF;
  15486. t['arrowrightheavy'] = 0x279E;
  15487. t['arrowrightoverleft'] = 0x21C4;
  15488. t['arrowrightwhite'] = 0x21E8;
  15489. t['arrowtableft'] = 0x21E4;
  15490. t['arrowtabright'] = 0x21E5;
  15491. t['arrowup'] = 0x2191;
  15492. t['arrowupdn'] = 0x2195;
  15493. t['arrowupdnbse'] = 0x21A8;
  15494. t['arrowupdownbase'] = 0x21A8;
  15495. t['arrowupleft'] = 0x2196;
  15496. t['arrowupleftofdown'] = 0x21C5;
  15497. t['arrowupright'] = 0x2197;
  15498. t['arrowupwhite'] = 0x21E7;
  15499. t['arrowvertex'] = 0xF8E6;
  15500. t['asciicircum'] = 0x005E;
  15501. t['asciicircummonospace'] = 0xFF3E;
  15502. t['asciitilde'] = 0x007E;
  15503. t['asciitildemonospace'] = 0xFF5E;
  15504. t['ascript'] = 0x0251;
  15505. t['ascriptturned'] = 0x0252;
  15506. t['asmallhiragana'] = 0x3041;
  15507. t['asmallkatakana'] = 0x30A1;
  15508. t['asmallkatakanahalfwidth'] = 0xFF67;
  15509. t['asterisk'] = 0x002A;
  15510. t['asteriskaltonearabic'] = 0x066D;
  15511. t['asteriskarabic'] = 0x066D;
  15512. t['asteriskmath'] = 0x2217;
  15513. t['asteriskmonospace'] = 0xFF0A;
  15514. t['asterisksmall'] = 0xFE61;
  15515. t['asterism'] = 0x2042;
  15516. t['asuperior'] = 0xF6E9;
  15517. t['asymptoticallyequal'] = 0x2243;
  15518. t['at'] = 0x0040;
  15519. t['atilde'] = 0x00E3;
  15520. t['atmonospace'] = 0xFF20;
  15521. t['atsmall'] = 0xFE6B;
  15522. t['aturned'] = 0x0250;
  15523. t['aubengali'] = 0x0994;
  15524. t['aubopomofo'] = 0x3120;
  15525. t['audeva'] = 0x0914;
  15526. t['augujarati'] = 0x0A94;
  15527. t['augurmukhi'] = 0x0A14;
  15528. t['aulengthmarkbengali'] = 0x09D7;
  15529. t['aumatragurmukhi'] = 0x0A4C;
  15530. t['auvowelsignbengali'] = 0x09CC;
  15531. t['auvowelsigndeva'] = 0x094C;
  15532. t['auvowelsigngujarati'] = 0x0ACC;
  15533. t['avagrahadeva'] = 0x093D;
  15534. t['aybarmenian'] = 0x0561;
  15535. t['ayin'] = 0x05E2;
  15536. t['ayinaltonehebrew'] = 0xFB20;
  15537. t['ayinhebrew'] = 0x05E2;
  15538. t['b'] = 0x0062;
  15539. t['babengali'] = 0x09AC;
  15540. t['backslash'] = 0x005C;
  15541. t['backslashmonospace'] = 0xFF3C;
  15542. t['badeva'] = 0x092C;
  15543. t['bagujarati'] = 0x0AAC;
  15544. t['bagurmukhi'] = 0x0A2C;
  15545. t['bahiragana'] = 0x3070;
  15546. t['bahtthai'] = 0x0E3F;
  15547. t['bakatakana'] = 0x30D0;
  15548. t['bar'] = 0x007C;
  15549. t['barmonospace'] = 0xFF5C;
  15550. t['bbopomofo'] = 0x3105;
  15551. t['bcircle'] = 0x24D1;
  15552. t['bdotaccent'] = 0x1E03;
  15553. t['bdotbelow'] = 0x1E05;
  15554. t['beamedsixteenthnotes'] = 0x266C;
  15555. t['because'] = 0x2235;
  15556. t['becyrillic'] = 0x0431;
  15557. t['beharabic'] = 0x0628;
  15558. t['behfinalarabic'] = 0xFE90;
  15559. t['behinitialarabic'] = 0xFE91;
  15560. t['behiragana'] = 0x3079;
  15561. t['behmedialarabic'] = 0xFE92;
  15562. t['behmeeminitialarabic'] = 0xFC9F;
  15563. t['behmeemisolatedarabic'] = 0xFC08;
  15564. t['behnoonfinalarabic'] = 0xFC6D;
  15565. t['bekatakana'] = 0x30D9;
  15566. t['benarmenian'] = 0x0562;
  15567. t['bet'] = 0x05D1;
  15568. t['beta'] = 0x03B2;
  15569. t['betasymbolgreek'] = 0x03D0;
  15570. t['betdagesh'] = 0xFB31;
  15571. t['betdageshhebrew'] = 0xFB31;
  15572. t['bethebrew'] = 0x05D1;
  15573. t['betrafehebrew'] = 0xFB4C;
  15574. t['bhabengali'] = 0x09AD;
  15575. t['bhadeva'] = 0x092D;
  15576. t['bhagujarati'] = 0x0AAD;
  15577. t['bhagurmukhi'] = 0x0A2D;
  15578. t['bhook'] = 0x0253;
  15579. t['bihiragana'] = 0x3073;
  15580. t['bikatakana'] = 0x30D3;
  15581. t['bilabialclick'] = 0x0298;
  15582. t['bindigurmukhi'] = 0x0A02;
  15583. t['birusquare'] = 0x3331;
  15584. t['blackcircle'] = 0x25CF;
  15585. t['blackdiamond'] = 0x25C6;
  15586. t['blackdownpointingtriangle'] = 0x25BC;
  15587. t['blackleftpointingpointer'] = 0x25C4;
  15588. t['blackleftpointingtriangle'] = 0x25C0;
  15589. t['blacklenticularbracketleft'] = 0x3010;
  15590. t['blacklenticularbracketleftvertical'] = 0xFE3B;
  15591. t['blacklenticularbracketright'] = 0x3011;
  15592. t['blacklenticularbracketrightvertical'] = 0xFE3C;
  15593. t['blacklowerlefttriangle'] = 0x25E3;
  15594. t['blacklowerrighttriangle'] = 0x25E2;
  15595. t['blackrectangle'] = 0x25AC;
  15596. t['blackrightpointingpointer'] = 0x25BA;
  15597. t['blackrightpointingtriangle'] = 0x25B6;
  15598. t['blacksmallsquare'] = 0x25AA;
  15599. t['blacksmilingface'] = 0x263B;
  15600. t['blacksquare'] = 0x25A0;
  15601. t['blackstar'] = 0x2605;
  15602. t['blackupperlefttriangle'] = 0x25E4;
  15603. t['blackupperrighttriangle'] = 0x25E5;
  15604. t['blackuppointingsmalltriangle'] = 0x25B4;
  15605. t['blackuppointingtriangle'] = 0x25B2;
  15606. t['blank'] = 0x2423;
  15607. t['blinebelow'] = 0x1E07;
  15608. t['block'] = 0x2588;
  15609. t['bmonospace'] = 0xFF42;
  15610. t['bobaimaithai'] = 0x0E1A;
  15611. t['bohiragana'] = 0x307C;
  15612. t['bokatakana'] = 0x30DC;
  15613. t['bparen'] = 0x249D;
  15614. t['bqsquare'] = 0x33C3;
  15615. t['braceex'] = 0xF8F4;
  15616. t['braceleft'] = 0x007B;
  15617. t['braceleftbt'] = 0xF8F3;
  15618. t['braceleftmid'] = 0xF8F2;
  15619. t['braceleftmonospace'] = 0xFF5B;
  15620. t['braceleftsmall'] = 0xFE5B;
  15621. t['bracelefttp'] = 0xF8F1;
  15622. t['braceleftvertical'] = 0xFE37;
  15623. t['braceright'] = 0x007D;
  15624. t['bracerightbt'] = 0xF8FE;
  15625. t['bracerightmid'] = 0xF8FD;
  15626. t['bracerightmonospace'] = 0xFF5D;
  15627. t['bracerightsmall'] = 0xFE5C;
  15628. t['bracerighttp'] = 0xF8FC;
  15629. t['bracerightvertical'] = 0xFE38;
  15630. t['bracketleft'] = 0x005B;
  15631. t['bracketleftbt'] = 0xF8F0;
  15632. t['bracketleftex'] = 0xF8EF;
  15633. t['bracketleftmonospace'] = 0xFF3B;
  15634. t['bracketlefttp'] = 0xF8EE;
  15635. t['bracketright'] = 0x005D;
  15636. t['bracketrightbt'] = 0xF8FB;
  15637. t['bracketrightex'] = 0xF8FA;
  15638. t['bracketrightmonospace'] = 0xFF3D;
  15639. t['bracketrighttp'] = 0xF8F9;
  15640. t['breve'] = 0x02D8;
  15641. t['brevebelowcmb'] = 0x032E;
  15642. t['brevecmb'] = 0x0306;
  15643. t['breveinvertedbelowcmb'] = 0x032F;
  15644. t['breveinvertedcmb'] = 0x0311;
  15645. t['breveinverteddoublecmb'] = 0x0361;
  15646. t['bridgebelowcmb'] = 0x032A;
  15647. t['bridgeinvertedbelowcmb'] = 0x033A;
  15648. t['brokenbar'] = 0x00A6;
  15649. t['bstroke'] = 0x0180;
  15650. t['bsuperior'] = 0xF6EA;
  15651. t['btopbar'] = 0x0183;
  15652. t['buhiragana'] = 0x3076;
  15653. t['bukatakana'] = 0x30D6;
  15654. t['bullet'] = 0x2022;
  15655. t['bulletinverse'] = 0x25D8;
  15656. t['bulletoperator'] = 0x2219;
  15657. t['bullseye'] = 0x25CE;
  15658. t['c'] = 0x0063;
  15659. t['caarmenian'] = 0x056E;
  15660. t['cabengali'] = 0x099A;
  15661. t['cacute'] = 0x0107;
  15662. t['cadeva'] = 0x091A;
  15663. t['cagujarati'] = 0x0A9A;
  15664. t['cagurmukhi'] = 0x0A1A;
  15665. t['calsquare'] = 0x3388;
  15666. t['candrabindubengali'] = 0x0981;
  15667. t['candrabinducmb'] = 0x0310;
  15668. t['candrabindudeva'] = 0x0901;
  15669. t['candrabindugujarati'] = 0x0A81;
  15670. t['capslock'] = 0x21EA;
  15671. t['careof'] = 0x2105;
  15672. t['caron'] = 0x02C7;
  15673. t['caronbelowcmb'] = 0x032C;
  15674. t['caroncmb'] = 0x030C;
  15675. t['carriagereturn'] = 0x21B5;
  15676. t['cbopomofo'] = 0x3118;
  15677. t['ccaron'] = 0x010D;
  15678. t['ccedilla'] = 0x00E7;
  15679. t['ccedillaacute'] = 0x1E09;
  15680. t['ccircle'] = 0x24D2;
  15681. t['ccircumflex'] = 0x0109;
  15682. t['ccurl'] = 0x0255;
  15683. t['cdot'] = 0x010B;
  15684. t['cdotaccent'] = 0x010B;
  15685. t['cdsquare'] = 0x33C5;
  15686. t['cedilla'] = 0x00B8;
  15687. t['cedillacmb'] = 0x0327;
  15688. t['cent'] = 0x00A2;
  15689. t['centigrade'] = 0x2103;
  15690. t['centinferior'] = 0xF6DF;
  15691. t['centmonospace'] = 0xFFE0;
  15692. t['centoldstyle'] = 0xF7A2;
  15693. t['centsuperior'] = 0xF6E0;
  15694. t['chaarmenian'] = 0x0579;
  15695. t['chabengali'] = 0x099B;
  15696. t['chadeva'] = 0x091B;
  15697. t['chagujarati'] = 0x0A9B;
  15698. t['chagurmukhi'] = 0x0A1B;
  15699. t['chbopomofo'] = 0x3114;
  15700. t['cheabkhasiancyrillic'] = 0x04BD;
  15701. t['checkmark'] = 0x2713;
  15702. t['checyrillic'] = 0x0447;
  15703. t['chedescenderabkhasiancyrillic'] = 0x04BF;
  15704. t['chedescendercyrillic'] = 0x04B7;
  15705. t['chedieresiscyrillic'] = 0x04F5;
  15706. t['cheharmenian'] = 0x0573;
  15707. t['chekhakassiancyrillic'] = 0x04CC;
  15708. t['cheverticalstrokecyrillic'] = 0x04B9;
  15709. t['chi'] = 0x03C7;
  15710. t['chieuchacirclekorean'] = 0x3277;
  15711. t['chieuchaparenkorean'] = 0x3217;
  15712. t['chieuchcirclekorean'] = 0x3269;
  15713. t['chieuchkorean'] = 0x314A;
  15714. t['chieuchparenkorean'] = 0x3209;
  15715. t['chochangthai'] = 0x0E0A;
  15716. t['chochanthai'] = 0x0E08;
  15717. t['chochingthai'] = 0x0E09;
  15718. t['chochoethai'] = 0x0E0C;
  15719. t['chook'] = 0x0188;
  15720. t['cieucacirclekorean'] = 0x3276;
  15721. t['cieucaparenkorean'] = 0x3216;
  15722. t['cieuccirclekorean'] = 0x3268;
  15723. t['cieuckorean'] = 0x3148;
  15724. t['cieucparenkorean'] = 0x3208;
  15725. t['cieucuparenkorean'] = 0x321C;
  15726. t['circle'] = 0x25CB;
  15727. t['circlecopyrt'] = 0x00A9;
  15728. t['circlemultiply'] = 0x2297;
  15729. t['circleot'] = 0x2299;
  15730. t['circleplus'] = 0x2295;
  15731. t['circlepostalmark'] = 0x3036;
  15732. t['circlewithlefthalfblack'] = 0x25D0;
  15733. t['circlewithrighthalfblack'] = 0x25D1;
  15734. t['circumflex'] = 0x02C6;
  15735. t['circumflexbelowcmb'] = 0x032D;
  15736. t['circumflexcmb'] = 0x0302;
  15737. t['clear'] = 0x2327;
  15738. t['clickalveolar'] = 0x01C2;
  15739. t['clickdental'] = 0x01C0;
  15740. t['clicklateral'] = 0x01C1;
  15741. t['clickretroflex'] = 0x01C3;
  15742. t['club'] = 0x2663;
  15743. t['clubsuitblack'] = 0x2663;
  15744. t['clubsuitwhite'] = 0x2667;
  15745. t['cmcubedsquare'] = 0x33A4;
  15746. t['cmonospace'] = 0xFF43;
  15747. t['cmsquaredsquare'] = 0x33A0;
  15748. t['coarmenian'] = 0x0581;
  15749. t['colon'] = 0x003A;
  15750. t['colonmonetary'] = 0x20A1;
  15751. t['colonmonospace'] = 0xFF1A;
  15752. t['colonsign'] = 0x20A1;
  15753. t['colonsmall'] = 0xFE55;
  15754. t['colontriangularhalfmod'] = 0x02D1;
  15755. t['colontriangularmod'] = 0x02D0;
  15756. t['comma'] = 0x002C;
  15757. t['commaabovecmb'] = 0x0313;
  15758. t['commaaboverightcmb'] = 0x0315;
  15759. t['commaaccent'] = 0xF6C3;
  15760. t['commaarabic'] = 0x060C;
  15761. t['commaarmenian'] = 0x055D;
  15762. t['commainferior'] = 0xF6E1;
  15763. t['commamonospace'] = 0xFF0C;
  15764. t['commareversedabovecmb'] = 0x0314;
  15765. t['commareversedmod'] = 0x02BD;
  15766. t['commasmall'] = 0xFE50;
  15767. t['commasuperior'] = 0xF6E2;
  15768. t['commaturnedabovecmb'] = 0x0312;
  15769. t['commaturnedmod'] = 0x02BB;
  15770. t['compass'] = 0x263C;
  15771. t['congruent'] = 0x2245;
  15772. t['contourintegral'] = 0x222E;
  15773. t['control'] = 0x2303;
  15774. t['controlACK'] = 0x0006;
  15775. t['controlBEL'] = 0x0007;
  15776. t['controlBS'] = 0x0008;
  15777. t['controlCAN'] = 0x0018;
  15778. t['controlCR'] = 0x000D;
  15779. t['controlDC1'] = 0x0011;
  15780. t['controlDC2'] = 0x0012;
  15781. t['controlDC3'] = 0x0013;
  15782. t['controlDC4'] = 0x0014;
  15783. t['controlDEL'] = 0x007F;
  15784. t['controlDLE'] = 0x0010;
  15785. t['controlEM'] = 0x0019;
  15786. t['controlENQ'] = 0x0005;
  15787. t['controlEOT'] = 0x0004;
  15788. t['controlESC'] = 0x001B;
  15789. t['controlETB'] = 0x0017;
  15790. t['controlETX'] = 0x0003;
  15791. t['controlFF'] = 0x000C;
  15792. t['controlFS'] = 0x001C;
  15793. t['controlGS'] = 0x001D;
  15794. t['controlHT'] = 0x0009;
  15795. t['controlLF'] = 0x000A;
  15796. t['controlNAK'] = 0x0015;
  15797. t['controlNULL'] = 0x0000;
  15798. t['controlRS'] = 0x001E;
  15799. t['controlSI'] = 0x000F;
  15800. t['controlSO'] = 0x000E;
  15801. t['controlSOT'] = 0x0002;
  15802. t['controlSTX'] = 0x0001;
  15803. t['controlSUB'] = 0x001A;
  15804. t['controlSYN'] = 0x0016;
  15805. t['controlUS'] = 0x001F;
  15806. t['controlVT'] = 0x000B;
  15807. t['copyright'] = 0x00A9;
  15808. t['copyrightsans'] = 0xF8E9;
  15809. t['copyrightserif'] = 0xF6D9;
  15810. t['cornerbracketleft'] = 0x300C;
  15811. t['cornerbracketlefthalfwidth'] = 0xFF62;
  15812. t['cornerbracketleftvertical'] = 0xFE41;
  15813. t['cornerbracketright'] = 0x300D;
  15814. t['cornerbracketrighthalfwidth'] = 0xFF63;
  15815. t['cornerbracketrightvertical'] = 0xFE42;
  15816. t['corporationsquare'] = 0x337F;
  15817. t['cosquare'] = 0x33C7;
  15818. t['coverkgsquare'] = 0x33C6;
  15819. t['cparen'] = 0x249E;
  15820. t['cruzeiro'] = 0x20A2;
  15821. t['cstretched'] = 0x0297;
  15822. t['curlyand'] = 0x22CF;
  15823. t['curlyor'] = 0x22CE;
  15824. t['currency'] = 0x00A4;
  15825. t['cyrBreve'] = 0xF6D1;
  15826. t['cyrFlex'] = 0xF6D2;
  15827. t['cyrbreve'] = 0xF6D4;
  15828. t['cyrflex'] = 0xF6D5;
  15829. t['d'] = 0x0064;
  15830. t['daarmenian'] = 0x0564;
  15831. t['dabengali'] = 0x09A6;
  15832. t['dadarabic'] = 0x0636;
  15833. t['dadeva'] = 0x0926;
  15834. t['dadfinalarabic'] = 0xFEBE;
  15835. t['dadinitialarabic'] = 0xFEBF;
  15836. t['dadmedialarabic'] = 0xFEC0;
  15837. t['dagesh'] = 0x05BC;
  15838. t['dageshhebrew'] = 0x05BC;
  15839. t['dagger'] = 0x2020;
  15840. t['daggerdbl'] = 0x2021;
  15841. t['dagujarati'] = 0x0AA6;
  15842. t['dagurmukhi'] = 0x0A26;
  15843. t['dahiragana'] = 0x3060;
  15844. t['dakatakana'] = 0x30C0;
  15845. t['dalarabic'] = 0x062F;
  15846. t['dalet'] = 0x05D3;
  15847. t['daletdagesh'] = 0xFB33;
  15848. t['daletdageshhebrew'] = 0xFB33;
  15849. t['dalethebrew'] = 0x05D3;
  15850. t['dalfinalarabic'] = 0xFEAA;
  15851. t['dammaarabic'] = 0x064F;
  15852. t['dammalowarabic'] = 0x064F;
  15853. t['dammatanaltonearabic'] = 0x064C;
  15854. t['dammatanarabic'] = 0x064C;
  15855. t['danda'] = 0x0964;
  15856. t['dargahebrew'] = 0x05A7;
  15857. t['dargalefthebrew'] = 0x05A7;
  15858. t['dasiapneumatacyrilliccmb'] = 0x0485;
  15859. t['dblGrave'] = 0xF6D3;
  15860. t['dblanglebracketleft'] = 0x300A;
  15861. t['dblanglebracketleftvertical'] = 0xFE3D;
  15862. t['dblanglebracketright'] = 0x300B;
  15863. t['dblanglebracketrightvertical'] = 0xFE3E;
  15864. t['dblarchinvertedbelowcmb'] = 0x032B;
  15865. t['dblarrowleft'] = 0x21D4;
  15866. t['dblarrowright'] = 0x21D2;
  15867. t['dbldanda'] = 0x0965;
  15868. t['dblgrave'] = 0xF6D6;
  15869. t['dblgravecmb'] = 0x030F;
  15870. t['dblintegral'] = 0x222C;
  15871. t['dbllowline'] = 0x2017;
  15872. t['dbllowlinecmb'] = 0x0333;
  15873. t['dbloverlinecmb'] = 0x033F;
  15874. t['dblprimemod'] = 0x02BA;
  15875. t['dblverticalbar'] = 0x2016;
  15876. t['dblverticallineabovecmb'] = 0x030E;
  15877. t['dbopomofo'] = 0x3109;
  15878. t['dbsquare'] = 0x33C8;
  15879. t['dcaron'] = 0x010F;
  15880. t['dcedilla'] = 0x1E11;
  15881. t['dcircle'] = 0x24D3;
  15882. t['dcircumflexbelow'] = 0x1E13;
  15883. t['dcroat'] = 0x0111;
  15884. t['ddabengali'] = 0x09A1;
  15885. t['ddadeva'] = 0x0921;
  15886. t['ddagujarati'] = 0x0AA1;
  15887. t['ddagurmukhi'] = 0x0A21;
  15888. t['ddalarabic'] = 0x0688;
  15889. t['ddalfinalarabic'] = 0xFB89;
  15890. t['dddhadeva'] = 0x095C;
  15891. t['ddhabengali'] = 0x09A2;
  15892. t['ddhadeva'] = 0x0922;
  15893. t['ddhagujarati'] = 0x0AA2;
  15894. t['ddhagurmukhi'] = 0x0A22;
  15895. t['ddotaccent'] = 0x1E0B;
  15896. t['ddotbelow'] = 0x1E0D;
  15897. t['decimalseparatorarabic'] = 0x066B;
  15898. t['decimalseparatorpersian'] = 0x066B;
  15899. t['decyrillic'] = 0x0434;
  15900. t['degree'] = 0x00B0;
  15901. t['dehihebrew'] = 0x05AD;
  15902. t['dehiragana'] = 0x3067;
  15903. t['deicoptic'] = 0x03EF;
  15904. t['dekatakana'] = 0x30C7;
  15905. t['deleteleft'] = 0x232B;
  15906. t['deleteright'] = 0x2326;
  15907. t['delta'] = 0x03B4;
  15908. t['deltaturned'] = 0x018D;
  15909. t['denominatorminusonenumeratorbengali'] = 0x09F8;
  15910. t['dezh'] = 0x02A4;
  15911. t['dhabengali'] = 0x09A7;
  15912. t['dhadeva'] = 0x0927;
  15913. t['dhagujarati'] = 0x0AA7;
  15914. t['dhagurmukhi'] = 0x0A27;
  15915. t['dhook'] = 0x0257;
  15916. t['dialytikatonos'] = 0x0385;
  15917. t['dialytikatonoscmb'] = 0x0344;
  15918. t['diamond'] = 0x2666;
  15919. t['diamondsuitwhite'] = 0x2662;
  15920. t['dieresis'] = 0x00A8;
  15921. t['dieresisacute'] = 0xF6D7;
  15922. t['dieresisbelowcmb'] = 0x0324;
  15923. t['dieresiscmb'] = 0x0308;
  15924. t['dieresisgrave'] = 0xF6D8;
  15925. t['dieresistonos'] = 0x0385;
  15926. t['dihiragana'] = 0x3062;
  15927. t['dikatakana'] = 0x30C2;
  15928. t['dittomark'] = 0x3003;
  15929. t['divide'] = 0x00F7;
  15930. t['divides'] = 0x2223;
  15931. t['divisionslash'] = 0x2215;
  15932. t['djecyrillic'] = 0x0452;
  15933. t['dkshade'] = 0x2593;
  15934. t['dlinebelow'] = 0x1E0F;
  15935. t['dlsquare'] = 0x3397;
  15936. t['dmacron'] = 0x0111;
  15937. t['dmonospace'] = 0xFF44;
  15938. t['dnblock'] = 0x2584;
  15939. t['dochadathai'] = 0x0E0E;
  15940. t['dodekthai'] = 0x0E14;
  15941. t['dohiragana'] = 0x3069;
  15942. t['dokatakana'] = 0x30C9;
  15943. t['dollar'] = 0x0024;
  15944. t['dollarinferior'] = 0xF6E3;
  15945. t['dollarmonospace'] = 0xFF04;
  15946. t['dollaroldstyle'] = 0xF724;
  15947. t['dollarsmall'] = 0xFE69;
  15948. t['dollarsuperior'] = 0xF6E4;
  15949. t['dong'] = 0x20AB;
  15950. t['dorusquare'] = 0x3326;
  15951. t['dotaccent'] = 0x02D9;
  15952. t['dotaccentcmb'] = 0x0307;
  15953. t['dotbelowcmb'] = 0x0323;
  15954. t['dotbelowcomb'] = 0x0323;
  15955. t['dotkatakana'] = 0x30FB;
  15956. t['dotlessi'] = 0x0131;
  15957. t['dotlessj'] = 0xF6BE;
  15958. t['dotlessjstrokehook'] = 0x0284;
  15959. t['dotmath'] = 0x22C5;
  15960. t['dottedcircle'] = 0x25CC;
  15961. t['doubleyodpatah'] = 0xFB1F;
  15962. t['doubleyodpatahhebrew'] = 0xFB1F;
  15963. t['downtackbelowcmb'] = 0x031E;
  15964. t['downtackmod'] = 0x02D5;
  15965. t['dparen'] = 0x249F;
  15966. t['dsuperior'] = 0xF6EB;
  15967. t['dtail'] = 0x0256;
  15968. t['dtopbar'] = 0x018C;
  15969. t['duhiragana'] = 0x3065;
  15970. t['dukatakana'] = 0x30C5;
  15971. t['dz'] = 0x01F3;
  15972. t['dzaltone'] = 0x02A3;
  15973. t['dzcaron'] = 0x01C6;
  15974. t['dzcurl'] = 0x02A5;
  15975. t['dzeabkhasiancyrillic'] = 0x04E1;
  15976. t['dzecyrillic'] = 0x0455;
  15977. t['dzhecyrillic'] = 0x045F;
  15978. t['e'] = 0x0065;
  15979. t['eacute'] = 0x00E9;
  15980. t['earth'] = 0x2641;
  15981. t['ebengali'] = 0x098F;
  15982. t['ebopomofo'] = 0x311C;
  15983. t['ebreve'] = 0x0115;
  15984. t['ecandradeva'] = 0x090D;
  15985. t['ecandragujarati'] = 0x0A8D;
  15986. t['ecandravowelsigndeva'] = 0x0945;
  15987. t['ecandravowelsigngujarati'] = 0x0AC5;
  15988. t['ecaron'] = 0x011B;
  15989. t['ecedillabreve'] = 0x1E1D;
  15990. t['echarmenian'] = 0x0565;
  15991. t['echyiwnarmenian'] = 0x0587;
  15992. t['ecircle'] = 0x24D4;
  15993. t['ecircumflex'] = 0x00EA;
  15994. t['ecircumflexacute'] = 0x1EBF;
  15995. t['ecircumflexbelow'] = 0x1E19;
  15996. t['ecircumflexdotbelow'] = 0x1EC7;
  15997. t['ecircumflexgrave'] = 0x1EC1;
  15998. t['ecircumflexhookabove'] = 0x1EC3;
  15999. t['ecircumflextilde'] = 0x1EC5;
  16000. t['ecyrillic'] = 0x0454;
  16001. t['edblgrave'] = 0x0205;
  16002. t['edeva'] = 0x090F;
  16003. t['edieresis'] = 0x00EB;
  16004. t['edot'] = 0x0117;
  16005. t['edotaccent'] = 0x0117;
  16006. t['edotbelow'] = 0x1EB9;
  16007. t['eegurmukhi'] = 0x0A0F;
  16008. t['eematragurmukhi'] = 0x0A47;
  16009. t['efcyrillic'] = 0x0444;
  16010. t['egrave'] = 0x00E8;
  16011. t['egujarati'] = 0x0A8F;
  16012. t['eharmenian'] = 0x0567;
  16013. t['ehbopomofo'] = 0x311D;
  16014. t['ehiragana'] = 0x3048;
  16015. t['ehookabove'] = 0x1EBB;
  16016. t['eibopomofo'] = 0x311F;
  16017. t['eight'] = 0x0038;
  16018. t['eightarabic'] = 0x0668;
  16019. t['eightbengali'] = 0x09EE;
  16020. t['eightcircle'] = 0x2467;
  16021. t['eightcircleinversesansserif'] = 0x2791;
  16022. t['eightdeva'] = 0x096E;
  16023. t['eighteencircle'] = 0x2471;
  16024. t['eighteenparen'] = 0x2485;
  16025. t['eighteenperiod'] = 0x2499;
  16026. t['eightgujarati'] = 0x0AEE;
  16027. t['eightgurmukhi'] = 0x0A6E;
  16028. t['eighthackarabic'] = 0x0668;
  16029. t['eighthangzhou'] = 0x3028;
  16030. t['eighthnotebeamed'] = 0x266B;
  16031. t['eightideographicparen'] = 0x3227;
  16032. t['eightinferior'] = 0x2088;
  16033. t['eightmonospace'] = 0xFF18;
  16034. t['eightoldstyle'] = 0xF738;
  16035. t['eightparen'] = 0x247B;
  16036. t['eightperiod'] = 0x248F;
  16037. t['eightpersian'] = 0x06F8;
  16038. t['eightroman'] = 0x2177;
  16039. t['eightsuperior'] = 0x2078;
  16040. t['eightthai'] = 0x0E58;
  16041. t['einvertedbreve'] = 0x0207;
  16042. t['eiotifiedcyrillic'] = 0x0465;
  16043. t['ekatakana'] = 0x30A8;
  16044. t['ekatakanahalfwidth'] = 0xFF74;
  16045. t['ekonkargurmukhi'] = 0x0A74;
  16046. t['ekorean'] = 0x3154;
  16047. t['elcyrillic'] = 0x043B;
  16048. t['element'] = 0x2208;
  16049. t['elevencircle'] = 0x246A;
  16050. t['elevenparen'] = 0x247E;
  16051. t['elevenperiod'] = 0x2492;
  16052. t['elevenroman'] = 0x217A;
  16053. t['ellipsis'] = 0x2026;
  16054. t['ellipsisvertical'] = 0x22EE;
  16055. t['emacron'] = 0x0113;
  16056. t['emacronacute'] = 0x1E17;
  16057. t['emacrongrave'] = 0x1E15;
  16058. t['emcyrillic'] = 0x043C;
  16059. t['emdash'] = 0x2014;
  16060. t['emdashvertical'] = 0xFE31;
  16061. t['emonospace'] = 0xFF45;
  16062. t['emphasismarkarmenian'] = 0x055B;
  16063. t['emptyset'] = 0x2205;
  16064. t['enbopomofo'] = 0x3123;
  16065. t['encyrillic'] = 0x043D;
  16066. t['endash'] = 0x2013;
  16067. t['endashvertical'] = 0xFE32;
  16068. t['endescendercyrillic'] = 0x04A3;
  16069. t['eng'] = 0x014B;
  16070. t['engbopomofo'] = 0x3125;
  16071. t['enghecyrillic'] = 0x04A5;
  16072. t['enhookcyrillic'] = 0x04C8;
  16073. t['enspace'] = 0x2002;
  16074. t['eogonek'] = 0x0119;
  16075. t['eokorean'] = 0x3153;
  16076. t['eopen'] = 0x025B;
  16077. t['eopenclosed'] = 0x029A;
  16078. t['eopenreversed'] = 0x025C;
  16079. t['eopenreversedclosed'] = 0x025E;
  16080. t['eopenreversedhook'] = 0x025D;
  16081. t['eparen'] = 0x24A0;
  16082. t['epsilon'] = 0x03B5;
  16083. t['epsilontonos'] = 0x03AD;
  16084. t['equal'] = 0x003D;
  16085. t['equalmonospace'] = 0xFF1D;
  16086. t['equalsmall'] = 0xFE66;
  16087. t['equalsuperior'] = 0x207C;
  16088. t['equivalence'] = 0x2261;
  16089. t['erbopomofo'] = 0x3126;
  16090. t['ercyrillic'] = 0x0440;
  16091. t['ereversed'] = 0x0258;
  16092. t['ereversedcyrillic'] = 0x044D;
  16093. t['escyrillic'] = 0x0441;
  16094. t['esdescendercyrillic'] = 0x04AB;
  16095. t['esh'] = 0x0283;
  16096. t['eshcurl'] = 0x0286;
  16097. t['eshortdeva'] = 0x090E;
  16098. t['eshortvowelsigndeva'] = 0x0946;
  16099. t['eshreversedloop'] = 0x01AA;
  16100. t['eshsquatreversed'] = 0x0285;
  16101. t['esmallhiragana'] = 0x3047;
  16102. t['esmallkatakana'] = 0x30A7;
  16103. t['esmallkatakanahalfwidth'] = 0xFF6A;
  16104. t['estimated'] = 0x212E;
  16105. t['esuperior'] = 0xF6EC;
  16106. t['eta'] = 0x03B7;
  16107. t['etarmenian'] = 0x0568;
  16108. t['etatonos'] = 0x03AE;
  16109. t['eth'] = 0x00F0;
  16110. t['etilde'] = 0x1EBD;
  16111. t['etildebelow'] = 0x1E1B;
  16112. t['etnahtafoukhhebrew'] = 0x0591;
  16113. t['etnahtafoukhlefthebrew'] = 0x0591;
  16114. t['etnahtahebrew'] = 0x0591;
  16115. t['etnahtalefthebrew'] = 0x0591;
  16116. t['eturned'] = 0x01DD;
  16117. t['eukorean'] = 0x3161;
  16118. t['euro'] = 0x20AC;
  16119. t['evowelsignbengali'] = 0x09C7;
  16120. t['evowelsigndeva'] = 0x0947;
  16121. t['evowelsigngujarati'] = 0x0AC7;
  16122. t['exclam'] = 0x0021;
  16123. t['exclamarmenian'] = 0x055C;
  16124. t['exclamdbl'] = 0x203C;
  16125. t['exclamdown'] = 0x00A1;
  16126. t['exclamdownsmall'] = 0xF7A1;
  16127. t['exclammonospace'] = 0xFF01;
  16128. t['exclamsmall'] = 0xF721;
  16129. t['existential'] = 0x2203;
  16130. t['ezh'] = 0x0292;
  16131. t['ezhcaron'] = 0x01EF;
  16132. t['ezhcurl'] = 0x0293;
  16133. t['ezhreversed'] = 0x01B9;
  16134. t['ezhtail'] = 0x01BA;
  16135. t['f'] = 0x0066;
  16136. t['fadeva'] = 0x095E;
  16137. t['fagurmukhi'] = 0x0A5E;
  16138. t['fahrenheit'] = 0x2109;
  16139. t['fathaarabic'] = 0x064E;
  16140. t['fathalowarabic'] = 0x064E;
  16141. t['fathatanarabic'] = 0x064B;
  16142. t['fbopomofo'] = 0x3108;
  16143. t['fcircle'] = 0x24D5;
  16144. t['fdotaccent'] = 0x1E1F;
  16145. t['feharabic'] = 0x0641;
  16146. t['feharmenian'] = 0x0586;
  16147. t['fehfinalarabic'] = 0xFED2;
  16148. t['fehinitialarabic'] = 0xFED3;
  16149. t['fehmedialarabic'] = 0xFED4;
  16150. t['feicoptic'] = 0x03E5;
  16151. t['female'] = 0x2640;
  16152. t['ff'] = 0xFB00;
  16153. t['ffi'] = 0xFB03;
  16154. t['ffl'] = 0xFB04;
  16155. t['fi'] = 0xFB01;
  16156. t['fifteencircle'] = 0x246E;
  16157. t['fifteenparen'] = 0x2482;
  16158. t['fifteenperiod'] = 0x2496;
  16159. t['figuredash'] = 0x2012;
  16160. t['filledbox'] = 0x25A0;
  16161. t['filledrect'] = 0x25AC;
  16162. t['finalkaf'] = 0x05DA;
  16163. t['finalkafdagesh'] = 0xFB3A;
  16164. t['finalkafdageshhebrew'] = 0xFB3A;
  16165. t['finalkafhebrew'] = 0x05DA;
  16166. t['finalmem'] = 0x05DD;
  16167. t['finalmemhebrew'] = 0x05DD;
  16168. t['finalnun'] = 0x05DF;
  16169. t['finalnunhebrew'] = 0x05DF;
  16170. t['finalpe'] = 0x05E3;
  16171. t['finalpehebrew'] = 0x05E3;
  16172. t['finaltsadi'] = 0x05E5;
  16173. t['finaltsadihebrew'] = 0x05E5;
  16174. t['firsttonechinese'] = 0x02C9;
  16175. t['fisheye'] = 0x25C9;
  16176. t['fitacyrillic'] = 0x0473;
  16177. t['five'] = 0x0035;
  16178. t['fivearabic'] = 0x0665;
  16179. t['fivebengali'] = 0x09EB;
  16180. t['fivecircle'] = 0x2464;
  16181. t['fivecircleinversesansserif'] = 0x278E;
  16182. t['fivedeva'] = 0x096B;
  16183. t['fiveeighths'] = 0x215D;
  16184. t['fivegujarati'] = 0x0AEB;
  16185. t['fivegurmukhi'] = 0x0A6B;
  16186. t['fivehackarabic'] = 0x0665;
  16187. t['fivehangzhou'] = 0x3025;
  16188. t['fiveideographicparen'] = 0x3224;
  16189. t['fiveinferior'] = 0x2085;
  16190. t['fivemonospace'] = 0xFF15;
  16191. t['fiveoldstyle'] = 0xF735;
  16192. t['fiveparen'] = 0x2478;
  16193. t['fiveperiod'] = 0x248C;
  16194. t['fivepersian'] = 0x06F5;
  16195. t['fiveroman'] = 0x2174;
  16196. t['fivesuperior'] = 0x2075;
  16197. t['fivethai'] = 0x0E55;
  16198. t['fl'] = 0xFB02;
  16199. t['florin'] = 0x0192;
  16200. t['fmonospace'] = 0xFF46;
  16201. t['fmsquare'] = 0x3399;
  16202. t['fofanthai'] = 0x0E1F;
  16203. t['fofathai'] = 0x0E1D;
  16204. t['fongmanthai'] = 0x0E4F;
  16205. t['forall'] = 0x2200;
  16206. t['four'] = 0x0034;
  16207. t['fourarabic'] = 0x0664;
  16208. t['fourbengali'] = 0x09EA;
  16209. t['fourcircle'] = 0x2463;
  16210. t['fourcircleinversesansserif'] = 0x278D;
  16211. t['fourdeva'] = 0x096A;
  16212. t['fourgujarati'] = 0x0AEA;
  16213. t['fourgurmukhi'] = 0x0A6A;
  16214. t['fourhackarabic'] = 0x0664;
  16215. t['fourhangzhou'] = 0x3024;
  16216. t['fourideographicparen'] = 0x3223;
  16217. t['fourinferior'] = 0x2084;
  16218. t['fourmonospace'] = 0xFF14;
  16219. t['fournumeratorbengali'] = 0x09F7;
  16220. t['fouroldstyle'] = 0xF734;
  16221. t['fourparen'] = 0x2477;
  16222. t['fourperiod'] = 0x248B;
  16223. t['fourpersian'] = 0x06F4;
  16224. t['fourroman'] = 0x2173;
  16225. t['foursuperior'] = 0x2074;
  16226. t['fourteencircle'] = 0x246D;
  16227. t['fourteenparen'] = 0x2481;
  16228. t['fourteenperiod'] = 0x2495;
  16229. t['fourthai'] = 0x0E54;
  16230. t['fourthtonechinese'] = 0x02CB;
  16231. t['fparen'] = 0x24A1;
  16232. t['fraction'] = 0x2044;
  16233. t['franc'] = 0x20A3;
  16234. t['g'] = 0x0067;
  16235. t['gabengali'] = 0x0997;
  16236. t['gacute'] = 0x01F5;
  16237. t['gadeva'] = 0x0917;
  16238. t['gafarabic'] = 0x06AF;
  16239. t['gaffinalarabic'] = 0xFB93;
  16240. t['gafinitialarabic'] = 0xFB94;
  16241. t['gafmedialarabic'] = 0xFB95;
  16242. t['gagujarati'] = 0x0A97;
  16243. t['gagurmukhi'] = 0x0A17;
  16244. t['gahiragana'] = 0x304C;
  16245. t['gakatakana'] = 0x30AC;
  16246. t['gamma'] = 0x03B3;
  16247. t['gammalatinsmall'] = 0x0263;
  16248. t['gammasuperior'] = 0x02E0;
  16249. t['gangiacoptic'] = 0x03EB;
  16250. t['gbopomofo'] = 0x310D;
  16251. t['gbreve'] = 0x011F;
  16252. t['gcaron'] = 0x01E7;
  16253. t['gcedilla'] = 0x0123;
  16254. t['gcircle'] = 0x24D6;
  16255. t['gcircumflex'] = 0x011D;
  16256. t['gcommaaccent'] = 0x0123;
  16257. t['gdot'] = 0x0121;
  16258. t['gdotaccent'] = 0x0121;
  16259. t['gecyrillic'] = 0x0433;
  16260. t['gehiragana'] = 0x3052;
  16261. t['gekatakana'] = 0x30B2;
  16262. t['geometricallyequal'] = 0x2251;
  16263. t['gereshaccenthebrew'] = 0x059C;
  16264. t['gereshhebrew'] = 0x05F3;
  16265. t['gereshmuqdamhebrew'] = 0x059D;
  16266. t['germandbls'] = 0x00DF;
  16267. t['gershayimaccenthebrew'] = 0x059E;
  16268. t['gershayimhebrew'] = 0x05F4;
  16269. t['getamark'] = 0x3013;
  16270. t['ghabengali'] = 0x0998;
  16271. t['ghadarmenian'] = 0x0572;
  16272. t['ghadeva'] = 0x0918;
  16273. t['ghagujarati'] = 0x0A98;
  16274. t['ghagurmukhi'] = 0x0A18;
  16275. t['ghainarabic'] = 0x063A;
  16276. t['ghainfinalarabic'] = 0xFECE;
  16277. t['ghaininitialarabic'] = 0xFECF;
  16278. t['ghainmedialarabic'] = 0xFED0;
  16279. t['ghemiddlehookcyrillic'] = 0x0495;
  16280. t['ghestrokecyrillic'] = 0x0493;
  16281. t['gheupturncyrillic'] = 0x0491;
  16282. t['ghhadeva'] = 0x095A;
  16283. t['ghhagurmukhi'] = 0x0A5A;
  16284. t['ghook'] = 0x0260;
  16285. t['ghzsquare'] = 0x3393;
  16286. t['gihiragana'] = 0x304E;
  16287. t['gikatakana'] = 0x30AE;
  16288. t['gimarmenian'] = 0x0563;
  16289. t['gimel'] = 0x05D2;
  16290. t['gimeldagesh'] = 0xFB32;
  16291. t['gimeldageshhebrew'] = 0xFB32;
  16292. t['gimelhebrew'] = 0x05D2;
  16293. t['gjecyrillic'] = 0x0453;
  16294. t['glottalinvertedstroke'] = 0x01BE;
  16295. t['glottalstop'] = 0x0294;
  16296. t['glottalstopinverted'] = 0x0296;
  16297. t['glottalstopmod'] = 0x02C0;
  16298. t['glottalstopreversed'] = 0x0295;
  16299. t['glottalstopreversedmod'] = 0x02C1;
  16300. t['glottalstopreversedsuperior'] = 0x02E4;
  16301. t['glottalstopstroke'] = 0x02A1;
  16302. t['glottalstopstrokereversed'] = 0x02A2;
  16303. t['gmacron'] = 0x1E21;
  16304. t['gmonospace'] = 0xFF47;
  16305. t['gohiragana'] = 0x3054;
  16306. t['gokatakana'] = 0x30B4;
  16307. t['gparen'] = 0x24A2;
  16308. t['gpasquare'] = 0x33AC;
  16309. t['gradient'] = 0x2207;
  16310. t['grave'] = 0x0060;
  16311. t['gravebelowcmb'] = 0x0316;
  16312. t['gravecmb'] = 0x0300;
  16313. t['gravecomb'] = 0x0300;
  16314. t['gravedeva'] = 0x0953;
  16315. t['gravelowmod'] = 0x02CE;
  16316. t['gravemonospace'] = 0xFF40;
  16317. t['gravetonecmb'] = 0x0340;
  16318. t['greater'] = 0x003E;
  16319. t['greaterequal'] = 0x2265;
  16320. t['greaterequalorless'] = 0x22DB;
  16321. t['greatermonospace'] = 0xFF1E;
  16322. t['greaterorequivalent'] = 0x2273;
  16323. t['greaterorless'] = 0x2277;
  16324. t['greateroverequal'] = 0x2267;
  16325. t['greatersmall'] = 0xFE65;
  16326. t['gscript'] = 0x0261;
  16327. t['gstroke'] = 0x01E5;
  16328. t['guhiragana'] = 0x3050;
  16329. t['guillemotleft'] = 0x00AB;
  16330. t['guillemotright'] = 0x00BB;
  16331. t['guilsinglleft'] = 0x2039;
  16332. t['guilsinglright'] = 0x203A;
  16333. t['gukatakana'] = 0x30B0;
  16334. t['guramusquare'] = 0x3318;
  16335. t['gysquare'] = 0x33C9;
  16336. t['h'] = 0x0068;
  16337. t['haabkhasiancyrillic'] = 0x04A9;
  16338. t['haaltonearabic'] = 0x06C1;
  16339. t['habengali'] = 0x09B9;
  16340. t['hadescendercyrillic'] = 0x04B3;
  16341. t['hadeva'] = 0x0939;
  16342. t['hagujarati'] = 0x0AB9;
  16343. t['hagurmukhi'] = 0x0A39;
  16344. t['haharabic'] = 0x062D;
  16345. t['hahfinalarabic'] = 0xFEA2;
  16346. t['hahinitialarabic'] = 0xFEA3;
  16347. t['hahiragana'] = 0x306F;
  16348. t['hahmedialarabic'] = 0xFEA4;
  16349. t['haitusquare'] = 0x332A;
  16350. t['hakatakana'] = 0x30CF;
  16351. t['hakatakanahalfwidth'] = 0xFF8A;
  16352. t['halantgurmukhi'] = 0x0A4D;
  16353. t['hamzaarabic'] = 0x0621;
  16354. t['hamzalowarabic'] = 0x0621;
  16355. t['hangulfiller'] = 0x3164;
  16356. t['hardsigncyrillic'] = 0x044A;
  16357. t['harpoonleftbarbup'] = 0x21BC;
  16358. t['harpoonrightbarbup'] = 0x21C0;
  16359. t['hasquare'] = 0x33CA;
  16360. t['hatafpatah'] = 0x05B2;
  16361. t['hatafpatah16'] = 0x05B2;
  16362. t['hatafpatah23'] = 0x05B2;
  16363. t['hatafpatah2f'] = 0x05B2;
  16364. t['hatafpatahhebrew'] = 0x05B2;
  16365. t['hatafpatahnarrowhebrew'] = 0x05B2;
  16366. t['hatafpatahquarterhebrew'] = 0x05B2;
  16367. t['hatafpatahwidehebrew'] = 0x05B2;
  16368. t['hatafqamats'] = 0x05B3;
  16369. t['hatafqamats1b'] = 0x05B3;
  16370. t['hatafqamats28'] = 0x05B3;
  16371. t['hatafqamats34'] = 0x05B3;
  16372. t['hatafqamatshebrew'] = 0x05B3;
  16373. t['hatafqamatsnarrowhebrew'] = 0x05B3;
  16374. t['hatafqamatsquarterhebrew'] = 0x05B3;
  16375. t['hatafqamatswidehebrew'] = 0x05B3;
  16376. t['hatafsegol'] = 0x05B1;
  16377. t['hatafsegol17'] = 0x05B1;
  16378. t['hatafsegol24'] = 0x05B1;
  16379. t['hatafsegol30'] = 0x05B1;
  16380. t['hatafsegolhebrew'] = 0x05B1;
  16381. t['hatafsegolnarrowhebrew'] = 0x05B1;
  16382. t['hatafsegolquarterhebrew'] = 0x05B1;
  16383. t['hatafsegolwidehebrew'] = 0x05B1;
  16384. t['hbar'] = 0x0127;
  16385. t['hbopomofo'] = 0x310F;
  16386. t['hbrevebelow'] = 0x1E2B;
  16387. t['hcedilla'] = 0x1E29;
  16388. t['hcircle'] = 0x24D7;
  16389. t['hcircumflex'] = 0x0125;
  16390. t['hdieresis'] = 0x1E27;
  16391. t['hdotaccent'] = 0x1E23;
  16392. t['hdotbelow'] = 0x1E25;
  16393. t['he'] = 0x05D4;
  16394. t['heart'] = 0x2665;
  16395. t['heartsuitblack'] = 0x2665;
  16396. t['heartsuitwhite'] = 0x2661;
  16397. t['hedagesh'] = 0xFB34;
  16398. t['hedageshhebrew'] = 0xFB34;
  16399. t['hehaltonearabic'] = 0x06C1;
  16400. t['heharabic'] = 0x0647;
  16401. t['hehebrew'] = 0x05D4;
  16402. t['hehfinalaltonearabic'] = 0xFBA7;
  16403. t['hehfinalalttwoarabic'] = 0xFEEA;
  16404. t['hehfinalarabic'] = 0xFEEA;
  16405. t['hehhamzaabovefinalarabic'] = 0xFBA5;
  16406. t['hehhamzaaboveisolatedarabic'] = 0xFBA4;
  16407. t['hehinitialaltonearabic'] = 0xFBA8;
  16408. t['hehinitialarabic'] = 0xFEEB;
  16409. t['hehiragana'] = 0x3078;
  16410. t['hehmedialaltonearabic'] = 0xFBA9;
  16411. t['hehmedialarabic'] = 0xFEEC;
  16412. t['heiseierasquare'] = 0x337B;
  16413. t['hekatakana'] = 0x30D8;
  16414. t['hekatakanahalfwidth'] = 0xFF8D;
  16415. t['hekutaarusquare'] = 0x3336;
  16416. t['henghook'] = 0x0267;
  16417. t['herutusquare'] = 0x3339;
  16418. t['het'] = 0x05D7;
  16419. t['hethebrew'] = 0x05D7;
  16420. t['hhook'] = 0x0266;
  16421. t['hhooksuperior'] = 0x02B1;
  16422. t['hieuhacirclekorean'] = 0x327B;
  16423. t['hieuhaparenkorean'] = 0x321B;
  16424. t['hieuhcirclekorean'] = 0x326D;
  16425. t['hieuhkorean'] = 0x314E;
  16426. t['hieuhparenkorean'] = 0x320D;
  16427. t['hihiragana'] = 0x3072;
  16428. t['hikatakana'] = 0x30D2;
  16429. t['hikatakanahalfwidth'] = 0xFF8B;
  16430. t['hiriq'] = 0x05B4;
  16431. t['hiriq14'] = 0x05B4;
  16432. t['hiriq21'] = 0x05B4;
  16433. t['hiriq2d'] = 0x05B4;
  16434. t['hiriqhebrew'] = 0x05B4;
  16435. t['hiriqnarrowhebrew'] = 0x05B4;
  16436. t['hiriqquarterhebrew'] = 0x05B4;
  16437. t['hiriqwidehebrew'] = 0x05B4;
  16438. t['hlinebelow'] = 0x1E96;
  16439. t['hmonospace'] = 0xFF48;
  16440. t['hoarmenian'] = 0x0570;
  16441. t['hohipthai'] = 0x0E2B;
  16442. t['hohiragana'] = 0x307B;
  16443. t['hokatakana'] = 0x30DB;
  16444. t['hokatakanahalfwidth'] = 0xFF8E;
  16445. t['holam'] = 0x05B9;
  16446. t['holam19'] = 0x05B9;
  16447. t['holam26'] = 0x05B9;
  16448. t['holam32'] = 0x05B9;
  16449. t['holamhebrew'] = 0x05B9;
  16450. t['holamnarrowhebrew'] = 0x05B9;
  16451. t['holamquarterhebrew'] = 0x05B9;
  16452. t['holamwidehebrew'] = 0x05B9;
  16453. t['honokhukthai'] = 0x0E2E;
  16454. t['hookabovecomb'] = 0x0309;
  16455. t['hookcmb'] = 0x0309;
  16456. t['hookpalatalizedbelowcmb'] = 0x0321;
  16457. t['hookretroflexbelowcmb'] = 0x0322;
  16458. t['hoonsquare'] = 0x3342;
  16459. t['horicoptic'] = 0x03E9;
  16460. t['horizontalbar'] = 0x2015;
  16461. t['horncmb'] = 0x031B;
  16462. t['hotsprings'] = 0x2668;
  16463. t['house'] = 0x2302;
  16464. t['hparen'] = 0x24A3;
  16465. t['hsuperior'] = 0x02B0;
  16466. t['hturned'] = 0x0265;
  16467. t['huhiragana'] = 0x3075;
  16468. t['huiitosquare'] = 0x3333;
  16469. t['hukatakana'] = 0x30D5;
  16470. t['hukatakanahalfwidth'] = 0xFF8C;
  16471. t['hungarumlaut'] = 0x02DD;
  16472. t['hungarumlautcmb'] = 0x030B;
  16473. t['hv'] = 0x0195;
  16474. t['hyphen'] = 0x002D;
  16475. t['hypheninferior'] = 0xF6E5;
  16476. t['hyphenmonospace'] = 0xFF0D;
  16477. t['hyphensmall'] = 0xFE63;
  16478. t['hyphensuperior'] = 0xF6E6;
  16479. t['hyphentwo'] = 0x2010;
  16480. t['i'] = 0x0069;
  16481. t['iacute'] = 0x00ED;
  16482. t['iacyrillic'] = 0x044F;
  16483. t['ibengali'] = 0x0987;
  16484. t['ibopomofo'] = 0x3127;
  16485. t['ibreve'] = 0x012D;
  16486. t['icaron'] = 0x01D0;
  16487. t['icircle'] = 0x24D8;
  16488. t['icircumflex'] = 0x00EE;
  16489. t['icyrillic'] = 0x0456;
  16490. t['idblgrave'] = 0x0209;
  16491. t['ideographearthcircle'] = 0x328F;
  16492. t['ideographfirecircle'] = 0x328B;
  16493. t['ideographicallianceparen'] = 0x323F;
  16494. t['ideographiccallparen'] = 0x323A;
  16495. t['ideographiccentrecircle'] = 0x32A5;
  16496. t['ideographicclose'] = 0x3006;
  16497. t['ideographiccomma'] = 0x3001;
  16498. t['ideographiccommaleft'] = 0xFF64;
  16499. t['ideographiccongratulationparen'] = 0x3237;
  16500. t['ideographiccorrectcircle'] = 0x32A3;
  16501. t['ideographicearthparen'] = 0x322F;
  16502. t['ideographicenterpriseparen'] = 0x323D;
  16503. t['ideographicexcellentcircle'] = 0x329D;
  16504. t['ideographicfestivalparen'] = 0x3240;
  16505. t['ideographicfinancialcircle'] = 0x3296;
  16506. t['ideographicfinancialparen'] = 0x3236;
  16507. t['ideographicfireparen'] = 0x322B;
  16508. t['ideographichaveparen'] = 0x3232;
  16509. t['ideographichighcircle'] = 0x32A4;
  16510. t['ideographiciterationmark'] = 0x3005;
  16511. t['ideographiclaborcircle'] = 0x3298;
  16512. t['ideographiclaborparen'] = 0x3238;
  16513. t['ideographicleftcircle'] = 0x32A7;
  16514. t['ideographiclowcircle'] = 0x32A6;
  16515. t['ideographicmedicinecircle'] = 0x32A9;
  16516. t['ideographicmetalparen'] = 0x322E;
  16517. t['ideographicmoonparen'] = 0x322A;
  16518. t['ideographicnameparen'] = 0x3234;
  16519. t['ideographicperiod'] = 0x3002;
  16520. t['ideographicprintcircle'] = 0x329E;
  16521. t['ideographicreachparen'] = 0x3243;
  16522. t['ideographicrepresentparen'] = 0x3239;
  16523. t['ideographicresourceparen'] = 0x323E;
  16524. t['ideographicrightcircle'] = 0x32A8;
  16525. t['ideographicsecretcircle'] = 0x3299;
  16526. t['ideographicselfparen'] = 0x3242;
  16527. t['ideographicsocietyparen'] = 0x3233;
  16528. t['ideographicspace'] = 0x3000;
  16529. t['ideographicspecialparen'] = 0x3235;
  16530. t['ideographicstockparen'] = 0x3231;
  16531. t['ideographicstudyparen'] = 0x323B;
  16532. t['ideographicsunparen'] = 0x3230;
  16533. t['ideographicsuperviseparen'] = 0x323C;
  16534. t['ideographicwaterparen'] = 0x322C;
  16535. t['ideographicwoodparen'] = 0x322D;
  16536. t['ideographiczero'] = 0x3007;
  16537. t['ideographmetalcircle'] = 0x328E;
  16538. t['ideographmooncircle'] = 0x328A;
  16539. t['ideographnamecircle'] = 0x3294;
  16540. t['ideographsuncircle'] = 0x3290;
  16541. t['ideographwatercircle'] = 0x328C;
  16542. t['ideographwoodcircle'] = 0x328D;
  16543. t['ideva'] = 0x0907;
  16544. t['idieresis'] = 0x00EF;
  16545. t['idieresisacute'] = 0x1E2F;
  16546. t['idieresiscyrillic'] = 0x04E5;
  16547. t['idotbelow'] = 0x1ECB;
  16548. t['iebrevecyrillic'] = 0x04D7;
  16549. t['iecyrillic'] = 0x0435;
  16550. t['ieungacirclekorean'] = 0x3275;
  16551. t['ieungaparenkorean'] = 0x3215;
  16552. t['ieungcirclekorean'] = 0x3267;
  16553. t['ieungkorean'] = 0x3147;
  16554. t['ieungparenkorean'] = 0x3207;
  16555. t['igrave'] = 0x00EC;
  16556. t['igujarati'] = 0x0A87;
  16557. t['igurmukhi'] = 0x0A07;
  16558. t['ihiragana'] = 0x3044;
  16559. t['ihookabove'] = 0x1EC9;
  16560. t['iibengali'] = 0x0988;
  16561. t['iicyrillic'] = 0x0438;
  16562. t['iideva'] = 0x0908;
  16563. t['iigujarati'] = 0x0A88;
  16564. t['iigurmukhi'] = 0x0A08;
  16565. t['iimatragurmukhi'] = 0x0A40;
  16566. t['iinvertedbreve'] = 0x020B;
  16567. t['iishortcyrillic'] = 0x0439;
  16568. t['iivowelsignbengali'] = 0x09C0;
  16569. t['iivowelsigndeva'] = 0x0940;
  16570. t['iivowelsigngujarati'] = 0x0AC0;
  16571. t['ij'] = 0x0133;
  16572. t['ikatakana'] = 0x30A4;
  16573. t['ikatakanahalfwidth'] = 0xFF72;
  16574. t['ikorean'] = 0x3163;
  16575. t['ilde'] = 0x02DC;
  16576. t['iluyhebrew'] = 0x05AC;
  16577. t['imacron'] = 0x012B;
  16578. t['imacroncyrillic'] = 0x04E3;
  16579. t['imageorapproximatelyequal'] = 0x2253;
  16580. t['imatragurmukhi'] = 0x0A3F;
  16581. t['imonospace'] = 0xFF49;
  16582. t['increment'] = 0x2206;
  16583. t['infinity'] = 0x221E;
  16584. t['iniarmenian'] = 0x056B;
  16585. t['integral'] = 0x222B;
  16586. t['integralbottom'] = 0x2321;
  16587. t['integralbt'] = 0x2321;
  16588. t['integralex'] = 0xF8F5;
  16589. t['integraltop'] = 0x2320;
  16590. t['integraltp'] = 0x2320;
  16591. t['intersection'] = 0x2229;
  16592. t['intisquare'] = 0x3305;
  16593. t['invbullet'] = 0x25D8;
  16594. t['invcircle'] = 0x25D9;
  16595. t['invsmileface'] = 0x263B;
  16596. t['iocyrillic'] = 0x0451;
  16597. t['iogonek'] = 0x012F;
  16598. t['iota'] = 0x03B9;
  16599. t['iotadieresis'] = 0x03CA;
  16600. t['iotadieresistonos'] = 0x0390;
  16601. t['iotalatin'] = 0x0269;
  16602. t['iotatonos'] = 0x03AF;
  16603. t['iparen'] = 0x24A4;
  16604. t['irigurmukhi'] = 0x0A72;
  16605. t['ismallhiragana'] = 0x3043;
  16606. t['ismallkatakana'] = 0x30A3;
  16607. t['ismallkatakanahalfwidth'] = 0xFF68;
  16608. t['issharbengali'] = 0x09FA;
  16609. t['istroke'] = 0x0268;
  16610. t['isuperior'] = 0xF6ED;
  16611. t['iterationhiragana'] = 0x309D;
  16612. t['iterationkatakana'] = 0x30FD;
  16613. t['itilde'] = 0x0129;
  16614. t['itildebelow'] = 0x1E2D;
  16615. t['iubopomofo'] = 0x3129;
  16616. t['iucyrillic'] = 0x044E;
  16617. t['ivowelsignbengali'] = 0x09BF;
  16618. t['ivowelsigndeva'] = 0x093F;
  16619. t['ivowelsigngujarati'] = 0x0ABF;
  16620. t['izhitsacyrillic'] = 0x0475;
  16621. t['izhitsadblgravecyrillic'] = 0x0477;
  16622. t['j'] = 0x006A;
  16623. t['jaarmenian'] = 0x0571;
  16624. t['jabengali'] = 0x099C;
  16625. t['jadeva'] = 0x091C;
  16626. t['jagujarati'] = 0x0A9C;
  16627. t['jagurmukhi'] = 0x0A1C;
  16628. t['jbopomofo'] = 0x3110;
  16629. t['jcaron'] = 0x01F0;
  16630. t['jcircle'] = 0x24D9;
  16631. t['jcircumflex'] = 0x0135;
  16632. t['jcrossedtail'] = 0x029D;
  16633. t['jdotlessstroke'] = 0x025F;
  16634. t['jecyrillic'] = 0x0458;
  16635. t['jeemarabic'] = 0x062C;
  16636. t['jeemfinalarabic'] = 0xFE9E;
  16637. t['jeeminitialarabic'] = 0xFE9F;
  16638. t['jeemmedialarabic'] = 0xFEA0;
  16639. t['jeharabic'] = 0x0698;
  16640. t['jehfinalarabic'] = 0xFB8B;
  16641. t['jhabengali'] = 0x099D;
  16642. t['jhadeva'] = 0x091D;
  16643. t['jhagujarati'] = 0x0A9D;
  16644. t['jhagurmukhi'] = 0x0A1D;
  16645. t['jheharmenian'] = 0x057B;
  16646. t['jis'] = 0x3004;
  16647. t['jmonospace'] = 0xFF4A;
  16648. t['jparen'] = 0x24A5;
  16649. t['jsuperior'] = 0x02B2;
  16650. t['k'] = 0x006B;
  16651. t['kabashkircyrillic'] = 0x04A1;
  16652. t['kabengali'] = 0x0995;
  16653. t['kacute'] = 0x1E31;
  16654. t['kacyrillic'] = 0x043A;
  16655. t['kadescendercyrillic'] = 0x049B;
  16656. t['kadeva'] = 0x0915;
  16657. t['kaf'] = 0x05DB;
  16658. t['kafarabic'] = 0x0643;
  16659. t['kafdagesh'] = 0xFB3B;
  16660. t['kafdageshhebrew'] = 0xFB3B;
  16661. t['kaffinalarabic'] = 0xFEDA;
  16662. t['kafhebrew'] = 0x05DB;
  16663. t['kafinitialarabic'] = 0xFEDB;
  16664. t['kafmedialarabic'] = 0xFEDC;
  16665. t['kafrafehebrew'] = 0xFB4D;
  16666. t['kagujarati'] = 0x0A95;
  16667. t['kagurmukhi'] = 0x0A15;
  16668. t['kahiragana'] = 0x304B;
  16669. t['kahookcyrillic'] = 0x04C4;
  16670. t['kakatakana'] = 0x30AB;
  16671. t['kakatakanahalfwidth'] = 0xFF76;
  16672. t['kappa'] = 0x03BA;
  16673. t['kappasymbolgreek'] = 0x03F0;
  16674. t['kapyeounmieumkorean'] = 0x3171;
  16675. t['kapyeounphieuphkorean'] = 0x3184;
  16676. t['kapyeounpieupkorean'] = 0x3178;
  16677. t['kapyeounssangpieupkorean'] = 0x3179;
  16678. t['karoriisquare'] = 0x330D;
  16679. t['kashidaautoarabic'] = 0x0640;
  16680. t['kashidaautonosidebearingarabic'] = 0x0640;
  16681. t['kasmallkatakana'] = 0x30F5;
  16682. t['kasquare'] = 0x3384;
  16683. t['kasraarabic'] = 0x0650;
  16684. t['kasratanarabic'] = 0x064D;
  16685. t['kastrokecyrillic'] = 0x049F;
  16686. t['katahiraprolongmarkhalfwidth'] = 0xFF70;
  16687. t['kaverticalstrokecyrillic'] = 0x049D;
  16688. t['kbopomofo'] = 0x310E;
  16689. t['kcalsquare'] = 0x3389;
  16690. t['kcaron'] = 0x01E9;
  16691. t['kcedilla'] = 0x0137;
  16692. t['kcircle'] = 0x24DA;
  16693. t['kcommaaccent'] = 0x0137;
  16694. t['kdotbelow'] = 0x1E33;
  16695. t['keharmenian'] = 0x0584;
  16696. t['kehiragana'] = 0x3051;
  16697. t['kekatakana'] = 0x30B1;
  16698. t['kekatakanahalfwidth'] = 0xFF79;
  16699. t['kenarmenian'] = 0x056F;
  16700. t['kesmallkatakana'] = 0x30F6;
  16701. t['kgreenlandic'] = 0x0138;
  16702. t['khabengali'] = 0x0996;
  16703. t['khacyrillic'] = 0x0445;
  16704. t['khadeva'] = 0x0916;
  16705. t['khagujarati'] = 0x0A96;
  16706. t['khagurmukhi'] = 0x0A16;
  16707. t['khaharabic'] = 0x062E;
  16708. t['khahfinalarabic'] = 0xFEA6;
  16709. t['khahinitialarabic'] = 0xFEA7;
  16710. t['khahmedialarabic'] = 0xFEA8;
  16711. t['kheicoptic'] = 0x03E7;
  16712. t['khhadeva'] = 0x0959;
  16713. t['khhagurmukhi'] = 0x0A59;
  16714. t['khieukhacirclekorean'] = 0x3278;
  16715. t['khieukhaparenkorean'] = 0x3218;
  16716. t['khieukhcirclekorean'] = 0x326A;
  16717. t['khieukhkorean'] = 0x314B;
  16718. t['khieukhparenkorean'] = 0x320A;
  16719. t['khokhaithai'] = 0x0E02;
  16720. t['khokhonthai'] = 0x0E05;
  16721. t['khokhuatthai'] = 0x0E03;
  16722. t['khokhwaithai'] = 0x0E04;
  16723. t['khomutthai'] = 0x0E5B;
  16724. t['khook'] = 0x0199;
  16725. t['khorakhangthai'] = 0x0E06;
  16726. t['khzsquare'] = 0x3391;
  16727. t['kihiragana'] = 0x304D;
  16728. t['kikatakana'] = 0x30AD;
  16729. t['kikatakanahalfwidth'] = 0xFF77;
  16730. t['kiroguramusquare'] = 0x3315;
  16731. t['kiromeetorusquare'] = 0x3316;
  16732. t['kirosquare'] = 0x3314;
  16733. t['kiyeokacirclekorean'] = 0x326E;
  16734. t['kiyeokaparenkorean'] = 0x320E;
  16735. t['kiyeokcirclekorean'] = 0x3260;
  16736. t['kiyeokkorean'] = 0x3131;
  16737. t['kiyeokparenkorean'] = 0x3200;
  16738. t['kiyeoksioskorean'] = 0x3133;
  16739. t['kjecyrillic'] = 0x045C;
  16740. t['klinebelow'] = 0x1E35;
  16741. t['klsquare'] = 0x3398;
  16742. t['kmcubedsquare'] = 0x33A6;
  16743. t['kmonospace'] = 0xFF4B;
  16744. t['kmsquaredsquare'] = 0x33A2;
  16745. t['kohiragana'] = 0x3053;
  16746. t['kohmsquare'] = 0x33C0;
  16747. t['kokaithai'] = 0x0E01;
  16748. t['kokatakana'] = 0x30B3;
  16749. t['kokatakanahalfwidth'] = 0xFF7A;
  16750. t['kooposquare'] = 0x331E;
  16751. t['koppacyrillic'] = 0x0481;
  16752. t['koreanstandardsymbol'] = 0x327F;
  16753. t['koroniscmb'] = 0x0343;
  16754. t['kparen'] = 0x24A6;
  16755. t['kpasquare'] = 0x33AA;
  16756. t['ksicyrillic'] = 0x046F;
  16757. t['ktsquare'] = 0x33CF;
  16758. t['kturned'] = 0x029E;
  16759. t['kuhiragana'] = 0x304F;
  16760. t['kukatakana'] = 0x30AF;
  16761. t['kukatakanahalfwidth'] = 0xFF78;
  16762. t['kvsquare'] = 0x33B8;
  16763. t['kwsquare'] = 0x33BE;
  16764. t['l'] = 0x006C;
  16765. t['labengali'] = 0x09B2;
  16766. t['lacute'] = 0x013A;
  16767. t['ladeva'] = 0x0932;
  16768. t['lagujarati'] = 0x0AB2;
  16769. t['lagurmukhi'] = 0x0A32;
  16770. t['lakkhangyaothai'] = 0x0E45;
  16771. t['lamaleffinalarabic'] = 0xFEFC;
  16772. t['lamalefhamzaabovefinalarabic'] = 0xFEF8;
  16773. t['lamalefhamzaaboveisolatedarabic'] = 0xFEF7;
  16774. t['lamalefhamzabelowfinalarabic'] = 0xFEFA;
  16775. t['lamalefhamzabelowisolatedarabic'] = 0xFEF9;
  16776. t['lamalefisolatedarabic'] = 0xFEFB;
  16777. t['lamalefmaddaabovefinalarabic'] = 0xFEF6;
  16778. t['lamalefmaddaaboveisolatedarabic'] = 0xFEF5;
  16779. t['lamarabic'] = 0x0644;
  16780. t['lambda'] = 0x03BB;
  16781. t['lambdastroke'] = 0x019B;
  16782. t['lamed'] = 0x05DC;
  16783. t['lameddagesh'] = 0xFB3C;
  16784. t['lameddageshhebrew'] = 0xFB3C;
  16785. t['lamedhebrew'] = 0x05DC;
  16786. t['lamfinalarabic'] = 0xFEDE;
  16787. t['lamhahinitialarabic'] = 0xFCCA;
  16788. t['laminitialarabic'] = 0xFEDF;
  16789. t['lamjeeminitialarabic'] = 0xFCC9;
  16790. t['lamkhahinitialarabic'] = 0xFCCB;
  16791. t['lamlamhehisolatedarabic'] = 0xFDF2;
  16792. t['lammedialarabic'] = 0xFEE0;
  16793. t['lammeemhahinitialarabic'] = 0xFD88;
  16794. t['lammeeminitialarabic'] = 0xFCCC;
  16795. t['largecircle'] = 0x25EF;
  16796. t['lbar'] = 0x019A;
  16797. t['lbelt'] = 0x026C;
  16798. t['lbopomofo'] = 0x310C;
  16799. t['lcaron'] = 0x013E;
  16800. t['lcedilla'] = 0x013C;
  16801. t['lcircle'] = 0x24DB;
  16802. t['lcircumflexbelow'] = 0x1E3D;
  16803. t['lcommaaccent'] = 0x013C;
  16804. t['ldot'] = 0x0140;
  16805. t['ldotaccent'] = 0x0140;
  16806. t['ldotbelow'] = 0x1E37;
  16807. t['ldotbelowmacron'] = 0x1E39;
  16808. t['leftangleabovecmb'] = 0x031A;
  16809. t['lefttackbelowcmb'] = 0x0318;
  16810. t['less'] = 0x003C;
  16811. t['lessequal'] = 0x2264;
  16812. t['lessequalorgreater'] = 0x22DA;
  16813. t['lessmonospace'] = 0xFF1C;
  16814. t['lessorequivalent'] = 0x2272;
  16815. t['lessorgreater'] = 0x2276;
  16816. t['lessoverequal'] = 0x2266;
  16817. t['lesssmall'] = 0xFE64;
  16818. t['lezh'] = 0x026E;
  16819. t['lfblock'] = 0x258C;
  16820. t['lhookretroflex'] = 0x026D;
  16821. t['lira'] = 0x20A4;
  16822. t['liwnarmenian'] = 0x056C;
  16823. t['lj'] = 0x01C9;
  16824. t['ljecyrillic'] = 0x0459;
  16825. t['ll'] = 0xF6C0;
  16826. t['lladeva'] = 0x0933;
  16827. t['llagujarati'] = 0x0AB3;
  16828. t['llinebelow'] = 0x1E3B;
  16829. t['llladeva'] = 0x0934;
  16830. t['llvocalicbengali'] = 0x09E1;
  16831. t['llvocalicdeva'] = 0x0961;
  16832. t['llvocalicvowelsignbengali'] = 0x09E3;
  16833. t['llvocalicvowelsigndeva'] = 0x0963;
  16834. t['lmiddletilde'] = 0x026B;
  16835. t['lmonospace'] = 0xFF4C;
  16836. t['lmsquare'] = 0x33D0;
  16837. t['lochulathai'] = 0x0E2C;
  16838. t['logicaland'] = 0x2227;
  16839. t['logicalnot'] = 0x00AC;
  16840. t['logicalnotreversed'] = 0x2310;
  16841. t['logicalor'] = 0x2228;
  16842. t['lolingthai'] = 0x0E25;
  16843. t['longs'] = 0x017F;
  16844. t['lowlinecenterline'] = 0xFE4E;
  16845. t['lowlinecmb'] = 0x0332;
  16846. t['lowlinedashed'] = 0xFE4D;
  16847. t['lozenge'] = 0x25CA;
  16848. t['lparen'] = 0x24A7;
  16849. t['lslash'] = 0x0142;
  16850. t['lsquare'] = 0x2113;
  16851. t['lsuperior'] = 0xF6EE;
  16852. t['ltshade'] = 0x2591;
  16853. t['luthai'] = 0x0E26;
  16854. t['lvocalicbengali'] = 0x098C;
  16855. t['lvocalicdeva'] = 0x090C;
  16856. t['lvocalicvowelsignbengali'] = 0x09E2;
  16857. t['lvocalicvowelsigndeva'] = 0x0962;
  16858. t['lxsquare'] = 0x33D3;
  16859. t['m'] = 0x006D;
  16860. t['mabengali'] = 0x09AE;
  16861. t['macron'] = 0x00AF;
  16862. t['macronbelowcmb'] = 0x0331;
  16863. t['macroncmb'] = 0x0304;
  16864. t['macronlowmod'] = 0x02CD;
  16865. t['macronmonospace'] = 0xFFE3;
  16866. t['macute'] = 0x1E3F;
  16867. t['madeva'] = 0x092E;
  16868. t['magujarati'] = 0x0AAE;
  16869. t['magurmukhi'] = 0x0A2E;
  16870. t['mahapakhhebrew'] = 0x05A4;
  16871. t['mahapakhlefthebrew'] = 0x05A4;
  16872. t['mahiragana'] = 0x307E;
  16873. t['maichattawalowleftthai'] = 0xF895;
  16874. t['maichattawalowrightthai'] = 0xF894;
  16875. t['maichattawathai'] = 0x0E4B;
  16876. t['maichattawaupperleftthai'] = 0xF893;
  16877. t['maieklowleftthai'] = 0xF88C;
  16878. t['maieklowrightthai'] = 0xF88B;
  16879. t['maiekthai'] = 0x0E48;
  16880. t['maiekupperleftthai'] = 0xF88A;
  16881. t['maihanakatleftthai'] = 0xF884;
  16882. t['maihanakatthai'] = 0x0E31;
  16883. t['maitaikhuleftthai'] = 0xF889;
  16884. t['maitaikhuthai'] = 0x0E47;
  16885. t['maitholowleftthai'] = 0xF88F;
  16886. t['maitholowrightthai'] = 0xF88E;
  16887. t['maithothai'] = 0x0E49;
  16888. t['maithoupperleftthai'] = 0xF88D;
  16889. t['maitrilowleftthai'] = 0xF892;
  16890. t['maitrilowrightthai'] = 0xF891;
  16891. t['maitrithai'] = 0x0E4A;
  16892. t['maitriupperleftthai'] = 0xF890;
  16893. t['maiyamokthai'] = 0x0E46;
  16894. t['makatakana'] = 0x30DE;
  16895. t['makatakanahalfwidth'] = 0xFF8F;
  16896. t['male'] = 0x2642;
  16897. t['mansyonsquare'] = 0x3347;
  16898. t['maqafhebrew'] = 0x05BE;
  16899. t['mars'] = 0x2642;
  16900. t['masoracirclehebrew'] = 0x05AF;
  16901. t['masquare'] = 0x3383;
  16902. t['mbopomofo'] = 0x3107;
  16903. t['mbsquare'] = 0x33D4;
  16904. t['mcircle'] = 0x24DC;
  16905. t['mcubedsquare'] = 0x33A5;
  16906. t['mdotaccent'] = 0x1E41;
  16907. t['mdotbelow'] = 0x1E43;
  16908. t['meemarabic'] = 0x0645;
  16909. t['meemfinalarabic'] = 0xFEE2;
  16910. t['meeminitialarabic'] = 0xFEE3;
  16911. t['meemmedialarabic'] = 0xFEE4;
  16912. t['meemmeeminitialarabic'] = 0xFCD1;
  16913. t['meemmeemisolatedarabic'] = 0xFC48;
  16914. t['meetorusquare'] = 0x334D;
  16915. t['mehiragana'] = 0x3081;
  16916. t['meizierasquare'] = 0x337E;
  16917. t['mekatakana'] = 0x30E1;
  16918. t['mekatakanahalfwidth'] = 0xFF92;
  16919. t['mem'] = 0x05DE;
  16920. t['memdagesh'] = 0xFB3E;
  16921. t['memdageshhebrew'] = 0xFB3E;
  16922. t['memhebrew'] = 0x05DE;
  16923. t['menarmenian'] = 0x0574;
  16924. t['merkhahebrew'] = 0x05A5;
  16925. t['merkhakefulahebrew'] = 0x05A6;
  16926. t['merkhakefulalefthebrew'] = 0x05A6;
  16927. t['merkhalefthebrew'] = 0x05A5;
  16928. t['mhook'] = 0x0271;
  16929. t['mhzsquare'] = 0x3392;
  16930. t['middledotkatakanahalfwidth'] = 0xFF65;
  16931. t['middot'] = 0x00B7;
  16932. t['mieumacirclekorean'] = 0x3272;
  16933. t['mieumaparenkorean'] = 0x3212;
  16934. t['mieumcirclekorean'] = 0x3264;
  16935. t['mieumkorean'] = 0x3141;
  16936. t['mieumpansioskorean'] = 0x3170;
  16937. t['mieumparenkorean'] = 0x3204;
  16938. t['mieumpieupkorean'] = 0x316E;
  16939. t['mieumsioskorean'] = 0x316F;
  16940. t['mihiragana'] = 0x307F;
  16941. t['mikatakana'] = 0x30DF;
  16942. t['mikatakanahalfwidth'] = 0xFF90;
  16943. t['minus'] = 0x2212;
  16944. t['minusbelowcmb'] = 0x0320;
  16945. t['minuscircle'] = 0x2296;
  16946. t['minusmod'] = 0x02D7;
  16947. t['minusplus'] = 0x2213;
  16948. t['minute'] = 0x2032;
  16949. t['miribaarusquare'] = 0x334A;
  16950. t['mirisquare'] = 0x3349;
  16951. t['mlonglegturned'] = 0x0270;
  16952. t['mlsquare'] = 0x3396;
  16953. t['mmcubedsquare'] = 0x33A3;
  16954. t['mmonospace'] = 0xFF4D;
  16955. t['mmsquaredsquare'] = 0x339F;
  16956. t['mohiragana'] = 0x3082;
  16957. t['mohmsquare'] = 0x33C1;
  16958. t['mokatakana'] = 0x30E2;
  16959. t['mokatakanahalfwidth'] = 0xFF93;
  16960. t['molsquare'] = 0x33D6;
  16961. t['momathai'] = 0x0E21;
  16962. t['moverssquare'] = 0x33A7;
  16963. t['moverssquaredsquare'] = 0x33A8;
  16964. t['mparen'] = 0x24A8;
  16965. t['mpasquare'] = 0x33AB;
  16966. t['mssquare'] = 0x33B3;
  16967. t['msuperior'] = 0xF6EF;
  16968. t['mturned'] = 0x026F;
  16969. t['mu'] = 0x00B5;
  16970. t['mu1'] = 0x00B5;
  16971. t['muasquare'] = 0x3382;
  16972. t['muchgreater'] = 0x226B;
  16973. t['muchless'] = 0x226A;
  16974. t['mufsquare'] = 0x338C;
  16975. t['mugreek'] = 0x03BC;
  16976. t['mugsquare'] = 0x338D;
  16977. t['muhiragana'] = 0x3080;
  16978. t['mukatakana'] = 0x30E0;
  16979. t['mukatakanahalfwidth'] = 0xFF91;
  16980. t['mulsquare'] = 0x3395;
  16981. t['multiply'] = 0x00D7;
  16982. t['mumsquare'] = 0x339B;
  16983. t['munahhebrew'] = 0x05A3;
  16984. t['munahlefthebrew'] = 0x05A3;
  16985. t['musicalnote'] = 0x266A;
  16986. t['musicalnotedbl'] = 0x266B;
  16987. t['musicflatsign'] = 0x266D;
  16988. t['musicsharpsign'] = 0x266F;
  16989. t['mussquare'] = 0x33B2;
  16990. t['muvsquare'] = 0x33B6;
  16991. t['muwsquare'] = 0x33BC;
  16992. t['mvmegasquare'] = 0x33B9;
  16993. t['mvsquare'] = 0x33B7;
  16994. t['mwmegasquare'] = 0x33BF;
  16995. t['mwsquare'] = 0x33BD;
  16996. t['n'] = 0x006E;
  16997. t['nabengali'] = 0x09A8;
  16998. t['nabla'] = 0x2207;
  16999. t['nacute'] = 0x0144;
  17000. t['nadeva'] = 0x0928;
  17001. t['nagujarati'] = 0x0AA8;
  17002. t['nagurmukhi'] = 0x0A28;
  17003. t['nahiragana'] = 0x306A;
  17004. t['nakatakana'] = 0x30CA;
  17005. t['nakatakanahalfwidth'] = 0xFF85;
  17006. t['napostrophe'] = 0x0149;
  17007. t['nasquare'] = 0x3381;
  17008. t['nbopomofo'] = 0x310B;
  17009. t['nbspace'] = 0x00A0;
  17010. t['ncaron'] = 0x0148;
  17011. t['ncedilla'] = 0x0146;
  17012. t['ncircle'] = 0x24DD;
  17013. t['ncircumflexbelow'] = 0x1E4B;
  17014. t['ncommaaccent'] = 0x0146;
  17015. t['ndotaccent'] = 0x1E45;
  17016. t['ndotbelow'] = 0x1E47;
  17017. t['nehiragana'] = 0x306D;
  17018. t['nekatakana'] = 0x30CD;
  17019. t['nekatakanahalfwidth'] = 0xFF88;
  17020. t['newsheqelsign'] = 0x20AA;
  17021. t['nfsquare'] = 0x338B;
  17022. t['ngabengali'] = 0x0999;
  17023. t['ngadeva'] = 0x0919;
  17024. t['ngagujarati'] = 0x0A99;
  17025. t['ngagurmukhi'] = 0x0A19;
  17026. t['ngonguthai'] = 0x0E07;
  17027. t['nhiragana'] = 0x3093;
  17028. t['nhookleft'] = 0x0272;
  17029. t['nhookretroflex'] = 0x0273;
  17030. t['nieunacirclekorean'] = 0x326F;
  17031. t['nieunaparenkorean'] = 0x320F;
  17032. t['nieuncieuckorean'] = 0x3135;
  17033. t['nieuncirclekorean'] = 0x3261;
  17034. t['nieunhieuhkorean'] = 0x3136;
  17035. t['nieunkorean'] = 0x3134;
  17036. t['nieunpansioskorean'] = 0x3168;
  17037. t['nieunparenkorean'] = 0x3201;
  17038. t['nieunsioskorean'] = 0x3167;
  17039. t['nieuntikeutkorean'] = 0x3166;
  17040. t['nihiragana'] = 0x306B;
  17041. t['nikatakana'] = 0x30CB;
  17042. t['nikatakanahalfwidth'] = 0xFF86;
  17043. t['nikhahitleftthai'] = 0xF899;
  17044. t['nikhahitthai'] = 0x0E4D;
  17045. t['nine'] = 0x0039;
  17046. t['ninearabic'] = 0x0669;
  17047. t['ninebengali'] = 0x09EF;
  17048. t['ninecircle'] = 0x2468;
  17049. t['ninecircleinversesansserif'] = 0x2792;
  17050. t['ninedeva'] = 0x096F;
  17051. t['ninegujarati'] = 0x0AEF;
  17052. t['ninegurmukhi'] = 0x0A6F;
  17053. t['ninehackarabic'] = 0x0669;
  17054. t['ninehangzhou'] = 0x3029;
  17055. t['nineideographicparen'] = 0x3228;
  17056. t['nineinferior'] = 0x2089;
  17057. t['ninemonospace'] = 0xFF19;
  17058. t['nineoldstyle'] = 0xF739;
  17059. t['nineparen'] = 0x247C;
  17060. t['nineperiod'] = 0x2490;
  17061. t['ninepersian'] = 0x06F9;
  17062. t['nineroman'] = 0x2178;
  17063. t['ninesuperior'] = 0x2079;
  17064. t['nineteencircle'] = 0x2472;
  17065. t['nineteenparen'] = 0x2486;
  17066. t['nineteenperiod'] = 0x249A;
  17067. t['ninethai'] = 0x0E59;
  17068. t['nj'] = 0x01CC;
  17069. t['njecyrillic'] = 0x045A;
  17070. t['nkatakana'] = 0x30F3;
  17071. t['nkatakanahalfwidth'] = 0xFF9D;
  17072. t['nlegrightlong'] = 0x019E;
  17073. t['nlinebelow'] = 0x1E49;
  17074. t['nmonospace'] = 0xFF4E;
  17075. t['nmsquare'] = 0x339A;
  17076. t['nnabengali'] = 0x09A3;
  17077. t['nnadeva'] = 0x0923;
  17078. t['nnagujarati'] = 0x0AA3;
  17079. t['nnagurmukhi'] = 0x0A23;
  17080. t['nnnadeva'] = 0x0929;
  17081. t['nohiragana'] = 0x306E;
  17082. t['nokatakana'] = 0x30CE;
  17083. t['nokatakanahalfwidth'] = 0xFF89;
  17084. t['nonbreakingspace'] = 0x00A0;
  17085. t['nonenthai'] = 0x0E13;
  17086. t['nonuthai'] = 0x0E19;
  17087. t['noonarabic'] = 0x0646;
  17088. t['noonfinalarabic'] = 0xFEE6;
  17089. t['noonghunnaarabic'] = 0x06BA;
  17090. t['noonghunnafinalarabic'] = 0xFB9F;
  17091. t['nooninitialarabic'] = 0xFEE7;
  17092. t['noonjeeminitialarabic'] = 0xFCD2;
  17093. t['noonjeemisolatedarabic'] = 0xFC4B;
  17094. t['noonmedialarabic'] = 0xFEE8;
  17095. t['noonmeeminitialarabic'] = 0xFCD5;
  17096. t['noonmeemisolatedarabic'] = 0xFC4E;
  17097. t['noonnoonfinalarabic'] = 0xFC8D;
  17098. t['notcontains'] = 0x220C;
  17099. t['notelement'] = 0x2209;
  17100. t['notelementof'] = 0x2209;
  17101. t['notequal'] = 0x2260;
  17102. t['notgreater'] = 0x226F;
  17103. t['notgreaternorequal'] = 0x2271;
  17104. t['notgreaternorless'] = 0x2279;
  17105. t['notidentical'] = 0x2262;
  17106. t['notless'] = 0x226E;
  17107. t['notlessnorequal'] = 0x2270;
  17108. t['notparallel'] = 0x2226;
  17109. t['notprecedes'] = 0x2280;
  17110. t['notsubset'] = 0x2284;
  17111. t['notsucceeds'] = 0x2281;
  17112. t['notsuperset'] = 0x2285;
  17113. t['nowarmenian'] = 0x0576;
  17114. t['nparen'] = 0x24A9;
  17115. t['nssquare'] = 0x33B1;
  17116. t['nsuperior'] = 0x207F;
  17117. t['ntilde'] = 0x00F1;
  17118. t['nu'] = 0x03BD;
  17119. t['nuhiragana'] = 0x306C;
  17120. t['nukatakana'] = 0x30CC;
  17121. t['nukatakanahalfwidth'] = 0xFF87;
  17122. t['nuktabengali'] = 0x09BC;
  17123. t['nuktadeva'] = 0x093C;
  17124. t['nuktagujarati'] = 0x0ABC;
  17125. t['nuktagurmukhi'] = 0x0A3C;
  17126. t['numbersign'] = 0x0023;
  17127. t['numbersignmonospace'] = 0xFF03;
  17128. t['numbersignsmall'] = 0xFE5F;
  17129. t['numeralsigngreek'] = 0x0374;
  17130. t['numeralsignlowergreek'] = 0x0375;
  17131. t['numero'] = 0x2116;
  17132. t['nun'] = 0x05E0;
  17133. t['nundagesh'] = 0xFB40;
  17134. t['nundageshhebrew'] = 0xFB40;
  17135. t['nunhebrew'] = 0x05E0;
  17136. t['nvsquare'] = 0x33B5;
  17137. t['nwsquare'] = 0x33BB;
  17138. t['nyabengali'] = 0x099E;
  17139. t['nyadeva'] = 0x091E;
  17140. t['nyagujarati'] = 0x0A9E;
  17141. t['nyagurmukhi'] = 0x0A1E;
  17142. t['o'] = 0x006F;
  17143. t['oacute'] = 0x00F3;
  17144. t['oangthai'] = 0x0E2D;
  17145. t['obarred'] = 0x0275;
  17146. t['obarredcyrillic'] = 0x04E9;
  17147. t['obarreddieresiscyrillic'] = 0x04EB;
  17148. t['obengali'] = 0x0993;
  17149. t['obopomofo'] = 0x311B;
  17150. t['obreve'] = 0x014F;
  17151. t['ocandradeva'] = 0x0911;
  17152. t['ocandragujarati'] = 0x0A91;
  17153. t['ocandravowelsigndeva'] = 0x0949;
  17154. t['ocandravowelsigngujarati'] = 0x0AC9;
  17155. t['ocaron'] = 0x01D2;
  17156. t['ocircle'] = 0x24DE;
  17157. t['ocircumflex'] = 0x00F4;
  17158. t['ocircumflexacute'] = 0x1ED1;
  17159. t['ocircumflexdotbelow'] = 0x1ED9;
  17160. t['ocircumflexgrave'] = 0x1ED3;
  17161. t['ocircumflexhookabove'] = 0x1ED5;
  17162. t['ocircumflextilde'] = 0x1ED7;
  17163. t['ocyrillic'] = 0x043E;
  17164. t['odblacute'] = 0x0151;
  17165. t['odblgrave'] = 0x020D;
  17166. t['odeva'] = 0x0913;
  17167. t['odieresis'] = 0x00F6;
  17168. t['odieresiscyrillic'] = 0x04E7;
  17169. t['odotbelow'] = 0x1ECD;
  17170. t['oe'] = 0x0153;
  17171. t['oekorean'] = 0x315A;
  17172. t['ogonek'] = 0x02DB;
  17173. t['ogonekcmb'] = 0x0328;
  17174. t['ograve'] = 0x00F2;
  17175. t['ogujarati'] = 0x0A93;
  17176. t['oharmenian'] = 0x0585;
  17177. t['ohiragana'] = 0x304A;
  17178. t['ohookabove'] = 0x1ECF;
  17179. t['ohorn'] = 0x01A1;
  17180. t['ohornacute'] = 0x1EDB;
  17181. t['ohorndotbelow'] = 0x1EE3;
  17182. t['ohorngrave'] = 0x1EDD;
  17183. t['ohornhookabove'] = 0x1EDF;
  17184. t['ohorntilde'] = 0x1EE1;
  17185. t['ohungarumlaut'] = 0x0151;
  17186. t['oi'] = 0x01A3;
  17187. t['oinvertedbreve'] = 0x020F;
  17188. t['okatakana'] = 0x30AA;
  17189. t['okatakanahalfwidth'] = 0xFF75;
  17190. t['okorean'] = 0x3157;
  17191. t['olehebrew'] = 0x05AB;
  17192. t['omacron'] = 0x014D;
  17193. t['omacronacute'] = 0x1E53;
  17194. t['omacrongrave'] = 0x1E51;
  17195. t['omdeva'] = 0x0950;
  17196. t['omega'] = 0x03C9;
  17197. t['omega1'] = 0x03D6;
  17198. t['omegacyrillic'] = 0x0461;
  17199. t['omegalatinclosed'] = 0x0277;
  17200. t['omegaroundcyrillic'] = 0x047B;
  17201. t['omegatitlocyrillic'] = 0x047D;
  17202. t['omegatonos'] = 0x03CE;
  17203. t['omgujarati'] = 0x0AD0;
  17204. t['omicron'] = 0x03BF;
  17205. t['omicrontonos'] = 0x03CC;
  17206. t['omonospace'] = 0xFF4F;
  17207. t['one'] = 0x0031;
  17208. t['onearabic'] = 0x0661;
  17209. t['onebengali'] = 0x09E7;
  17210. t['onecircle'] = 0x2460;
  17211. t['onecircleinversesansserif'] = 0x278A;
  17212. t['onedeva'] = 0x0967;
  17213. t['onedotenleader'] = 0x2024;
  17214. t['oneeighth'] = 0x215B;
  17215. t['onefitted'] = 0xF6DC;
  17216. t['onegujarati'] = 0x0AE7;
  17217. t['onegurmukhi'] = 0x0A67;
  17218. t['onehackarabic'] = 0x0661;
  17219. t['onehalf'] = 0x00BD;
  17220. t['onehangzhou'] = 0x3021;
  17221. t['oneideographicparen'] = 0x3220;
  17222. t['oneinferior'] = 0x2081;
  17223. t['onemonospace'] = 0xFF11;
  17224. t['onenumeratorbengali'] = 0x09F4;
  17225. t['oneoldstyle'] = 0xF731;
  17226. t['oneparen'] = 0x2474;
  17227. t['oneperiod'] = 0x2488;
  17228. t['onepersian'] = 0x06F1;
  17229. t['onequarter'] = 0x00BC;
  17230. t['oneroman'] = 0x2170;
  17231. t['onesuperior'] = 0x00B9;
  17232. t['onethai'] = 0x0E51;
  17233. t['onethird'] = 0x2153;
  17234. t['oogonek'] = 0x01EB;
  17235. t['oogonekmacron'] = 0x01ED;
  17236. t['oogurmukhi'] = 0x0A13;
  17237. t['oomatragurmukhi'] = 0x0A4B;
  17238. t['oopen'] = 0x0254;
  17239. t['oparen'] = 0x24AA;
  17240. t['openbullet'] = 0x25E6;
  17241. t['option'] = 0x2325;
  17242. t['ordfeminine'] = 0x00AA;
  17243. t['ordmasculine'] = 0x00BA;
  17244. t['orthogonal'] = 0x221F;
  17245. t['oshortdeva'] = 0x0912;
  17246. t['oshortvowelsigndeva'] = 0x094A;
  17247. t['oslash'] = 0x00F8;
  17248. t['oslashacute'] = 0x01FF;
  17249. t['osmallhiragana'] = 0x3049;
  17250. t['osmallkatakana'] = 0x30A9;
  17251. t['osmallkatakanahalfwidth'] = 0xFF6B;
  17252. t['ostrokeacute'] = 0x01FF;
  17253. t['osuperior'] = 0xF6F0;
  17254. t['otcyrillic'] = 0x047F;
  17255. t['otilde'] = 0x00F5;
  17256. t['otildeacute'] = 0x1E4D;
  17257. t['otildedieresis'] = 0x1E4F;
  17258. t['oubopomofo'] = 0x3121;
  17259. t['overline'] = 0x203E;
  17260. t['overlinecenterline'] = 0xFE4A;
  17261. t['overlinecmb'] = 0x0305;
  17262. t['overlinedashed'] = 0xFE49;
  17263. t['overlinedblwavy'] = 0xFE4C;
  17264. t['overlinewavy'] = 0xFE4B;
  17265. t['overscore'] = 0x00AF;
  17266. t['ovowelsignbengali'] = 0x09CB;
  17267. t['ovowelsigndeva'] = 0x094B;
  17268. t['ovowelsigngujarati'] = 0x0ACB;
  17269. t['p'] = 0x0070;
  17270. t['paampssquare'] = 0x3380;
  17271. t['paasentosquare'] = 0x332B;
  17272. t['pabengali'] = 0x09AA;
  17273. t['pacute'] = 0x1E55;
  17274. t['padeva'] = 0x092A;
  17275. t['pagedown'] = 0x21DF;
  17276. t['pageup'] = 0x21DE;
  17277. t['pagujarati'] = 0x0AAA;
  17278. t['pagurmukhi'] = 0x0A2A;
  17279. t['pahiragana'] = 0x3071;
  17280. t['paiyannoithai'] = 0x0E2F;
  17281. t['pakatakana'] = 0x30D1;
  17282. t['palatalizationcyrilliccmb'] = 0x0484;
  17283. t['palochkacyrillic'] = 0x04C0;
  17284. t['pansioskorean'] = 0x317F;
  17285. t['paragraph'] = 0x00B6;
  17286. t['parallel'] = 0x2225;
  17287. t['parenleft'] = 0x0028;
  17288. t['parenleftaltonearabic'] = 0xFD3E;
  17289. t['parenleftbt'] = 0xF8ED;
  17290. t['parenleftex'] = 0xF8EC;
  17291. t['parenleftinferior'] = 0x208D;
  17292. t['parenleftmonospace'] = 0xFF08;
  17293. t['parenleftsmall'] = 0xFE59;
  17294. t['parenleftsuperior'] = 0x207D;
  17295. t['parenlefttp'] = 0xF8EB;
  17296. t['parenleftvertical'] = 0xFE35;
  17297. t['parenright'] = 0x0029;
  17298. t['parenrightaltonearabic'] = 0xFD3F;
  17299. t['parenrightbt'] = 0xF8F8;
  17300. t['parenrightex'] = 0xF8F7;
  17301. t['parenrightinferior'] = 0x208E;
  17302. t['parenrightmonospace'] = 0xFF09;
  17303. t['parenrightsmall'] = 0xFE5A;
  17304. t['parenrightsuperior'] = 0x207E;
  17305. t['parenrighttp'] = 0xF8F6;
  17306. t['parenrightvertical'] = 0xFE36;
  17307. t['partialdiff'] = 0x2202;
  17308. t['paseqhebrew'] = 0x05C0;
  17309. t['pashtahebrew'] = 0x0599;
  17310. t['pasquare'] = 0x33A9;
  17311. t['patah'] = 0x05B7;
  17312. t['patah11'] = 0x05B7;
  17313. t['patah1d'] = 0x05B7;
  17314. t['patah2a'] = 0x05B7;
  17315. t['patahhebrew'] = 0x05B7;
  17316. t['patahnarrowhebrew'] = 0x05B7;
  17317. t['patahquarterhebrew'] = 0x05B7;
  17318. t['patahwidehebrew'] = 0x05B7;
  17319. t['pazerhebrew'] = 0x05A1;
  17320. t['pbopomofo'] = 0x3106;
  17321. t['pcircle'] = 0x24DF;
  17322. t['pdotaccent'] = 0x1E57;
  17323. t['pe'] = 0x05E4;
  17324. t['pecyrillic'] = 0x043F;
  17325. t['pedagesh'] = 0xFB44;
  17326. t['pedageshhebrew'] = 0xFB44;
  17327. t['peezisquare'] = 0x333B;
  17328. t['pefinaldageshhebrew'] = 0xFB43;
  17329. t['peharabic'] = 0x067E;
  17330. t['peharmenian'] = 0x057A;
  17331. t['pehebrew'] = 0x05E4;
  17332. t['pehfinalarabic'] = 0xFB57;
  17333. t['pehinitialarabic'] = 0xFB58;
  17334. t['pehiragana'] = 0x307A;
  17335. t['pehmedialarabic'] = 0xFB59;
  17336. t['pekatakana'] = 0x30DA;
  17337. t['pemiddlehookcyrillic'] = 0x04A7;
  17338. t['perafehebrew'] = 0xFB4E;
  17339. t['percent'] = 0x0025;
  17340. t['percentarabic'] = 0x066A;
  17341. t['percentmonospace'] = 0xFF05;
  17342. t['percentsmall'] = 0xFE6A;
  17343. t['period'] = 0x002E;
  17344. t['periodarmenian'] = 0x0589;
  17345. t['periodcentered'] = 0x00B7;
  17346. t['periodhalfwidth'] = 0xFF61;
  17347. t['periodinferior'] = 0xF6E7;
  17348. t['periodmonospace'] = 0xFF0E;
  17349. t['periodsmall'] = 0xFE52;
  17350. t['periodsuperior'] = 0xF6E8;
  17351. t['perispomenigreekcmb'] = 0x0342;
  17352. t['perpendicular'] = 0x22A5;
  17353. t['perthousand'] = 0x2030;
  17354. t['peseta'] = 0x20A7;
  17355. t['pfsquare'] = 0x338A;
  17356. t['phabengali'] = 0x09AB;
  17357. t['phadeva'] = 0x092B;
  17358. t['phagujarati'] = 0x0AAB;
  17359. t['phagurmukhi'] = 0x0A2B;
  17360. t['phi'] = 0x03C6;
  17361. t['phi1'] = 0x03D5;
  17362. t['phieuphacirclekorean'] = 0x327A;
  17363. t['phieuphaparenkorean'] = 0x321A;
  17364. t['phieuphcirclekorean'] = 0x326C;
  17365. t['phieuphkorean'] = 0x314D;
  17366. t['phieuphparenkorean'] = 0x320C;
  17367. t['philatin'] = 0x0278;
  17368. t['phinthuthai'] = 0x0E3A;
  17369. t['phisymbolgreek'] = 0x03D5;
  17370. t['phook'] = 0x01A5;
  17371. t['phophanthai'] = 0x0E1E;
  17372. t['phophungthai'] = 0x0E1C;
  17373. t['phosamphaothai'] = 0x0E20;
  17374. t['pi'] = 0x03C0;
  17375. t['pieupacirclekorean'] = 0x3273;
  17376. t['pieupaparenkorean'] = 0x3213;
  17377. t['pieupcieuckorean'] = 0x3176;
  17378. t['pieupcirclekorean'] = 0x3265;
  17379. t['pieupkiyeokkorean'] = 0x3172;
  17380. t['pieupkorean'] = 0x3142;
  17381. t['pieupparenkorean'] = 0x3205;
  17382. t['pieupsioskiyeokkorean'] = 0x3174;
  17383. t['pieupsioskorean'] = 0x3144;
  17384. t['pieupsiostikeutkorean'] = 0x3175;
  17385. t['pieupthieuthkorean'] = 0x3177;
  17386. t['pieuptikeutkorean'] = 0x3173;
  17387. t['pihiragana'] = 0x3074;
  17388. t['pikatakana'] = 0x30D4;
  17389. t['pisymbolgreek'] = 0x03D6;
  17390. t['piwrarmenian'] = 0x0583;
  17391. t['plus'] = 0x002B;
  17392. t['plusbelowcmb'] = 0x031F;
  17393. t['pluscircle'] = 0x2295;
  17394. t['plusminus'] = 0x00B1;
  17395. t['plusmod'] = 0x02D6;
  17396. t['plusmonospace'] = 0xFF0B;
  17397. t['plussmall'] = 0xFE62;
  17398. t['plussuperior'] = 0x207A;
  17399. t['pmonospace'] = 0xFF50;
  17400. t['pmsquare'] = 0x33D8;
  17401. t['pohiragana'] = 0x307D;
  17402. t['pointingindexdownwhite'] = 0x261F;
  17403. t['pointingindexleftwhite'] = 0x261C;
  17404. t['pointingindexrightwhite'] = 0x261E;
  17405. t['pointingindexupwhite'] = 0x261D;
  17406. t['pokatakana'] = 0x30DD;
  17407. t['poplathai'] = 0x0E1B;
  17408. t['postalmark'] = 0x3012;
  17409. t['postalmarkface'] = 0x3020;
  17410. t['pparen'] = 0x24AB;
  17411. t['precedes'] = 0x227A;
  17412. t['prescription'] = 0x211E;
  17413. t['primemod'] = 0x02B9;
  17414. t['primereversed'] = 0x2035;
  17415. t['product'] = 0x220F;
  17416. t['projective'] = 0x2305;
  17417. t['prolongedkana'] = 0x30FC;
  17418. t['propellor'] = 0x2318;
  17419. t['propersubset'] = 0x2282;
  17420. t['propersuperset'] = 0x2283;
  17421. t['proportion'] = 0x2237;
  17422. t['proportional'] = 0x221D;
  17423. t['psi'] = 0x03C8;
  17424. t['psicyrillic'] = 0x0471;
  17425. t['psilipneumatacyrilliccmb'] = 0x0486;
  17426. t['pssquare'] = 0x33B0;
  17427. t['puhiragana'] = 0x3077;
  17428. t['pukatakana'] = 0x30D7;
  17429. t['pvsquare'] = 0x33B4;
  17430. t['pwsquare'] = 0x33BA;
  17431. t['q'] = 0x0071;
  17432. t['qadeva'] = 0x0958;
  17433. t['qadmahebrew'] = 0x05A8;
  17434. t['qafarabic'] = 0x0642;
  17435. t['qaffinalarabic'] = 0xFED6;
  17436. t['qafinitialarabic'] = 0xFED7;
  17437. t['qafmedialarabic'] = 0xFED8;
  17438. t['qamats'] = 0x05B8;
  17439. t['qamats10'] = 0x05B8;
  17440. t['qamats1a'] = 0x05B8;
  17441. t['qamats1c'] = 0x05B8;
  17442. t['qamats27'] = 0x05B8;
  17443. t['qamats29'] = 0x05B8;
  17444. t['qamats33'] = 0x05B8;
  17445. t['qamatsde'] = 0x05B8;
  17446. t['qamatshebrew'] = 0x05B8;
  17447. t['qamatsnarrowhebrew'] = 0x05B8;
  17448. t['qamatsqatanhebrew'] = 0x05B8;
  17449. t['qamatsqatannarrowhebrew'] = 0x05B8;
  17450. t['qamatsqatanquarterhebrew'] = 0x05B8;
  17451. t['qamatsqatanwidehebrew'] = 0x05B8;
  17452. t['qamatsquarterhebrew'] = 0x05B8;
  17453. t['qamatswidehebrew'] = 0x05B8;
  17454. t['qarneyparahebrew'] = 0x059F;
  17455. t['qbopomofo'] = 0x3111;
  17456. t['qcircle'] = 0x24E0;
  17457. t['qhook'] = 0x02A0;
  17458. t['qmonospace'] = 0xFF51;
  17459. t['qof'] = 0x05E7;
  17460. t['qofdagesh'] = 0xFB47;
  17461. t['qofdageshhebrew'] = 0xFB47;
  17462. t['qofhebrew'] = 0x05E7;
  17463. t['qparen'] = 0x24AC;
  17464. t['quarternote'] = 0x2669;
  17465. t['qubuts'] = 0x05BB;
  17466. t['qubuts18'] = 0x05BB;
  17467. t['qubuts25'] = 0x05BB;
  17468. t['qubuts31'] = 0x05BB;
  17469. t['qubutshebrew'] = 0x05BB;
  17470. t['qubutsnarrowhebrew'] = 0x05BB;
  17471. t['qubutsquarterhebrew'] = 0x05BB;
  17472. t['qubutswidehebrew'] = 0x05BB;
  17473. t['question'] = 0x003F;
  17474. t['questionarabic'] = 0x061F;
  17475. t['questionarmenian'] = 0x055E;
  17476. t['questiondown'] = 0x00BF;
  17477. t['questiondownsmall'] = 0xF7BF;
  17478. t['questiongreek'] = 0x037E;
  17479. t['questionmonospace'] = 0xFF1F;
  17480. t['questionsmall'] = 0xF73F;
  17481. t['quotedbl'] = 0x0022;
  17482. t['quotedblbase'] = 0x201E;
  17483. t['quotedblleft'] = 0x201C;
  17484. t['quotedblmonospace'] = 0xFF02;
  17485. t['quotedblprime'] = 0x301E;
  17486. t['quotedblprimereversed'] = 0x301D;
  17487. t['quotedblright'] = 0x201D;
  17488. t['quoteleft'] = 0x2018;
  17489. t['quoteleftreversed'] = 0x201B;
  17490. t['quotereversed'] = 0x201B;
  17491. t['quoteright'] = 0x2019;
  17492. t['quoterightn'] = 0x0149;
  17493. t['quotesinglbase'] = 0x201A;
  17494. t['quotesingle'] = 0x0027;
  17495. t['quotesinglemonospace'] = 0xFF07;
  17496. t['r'] = 0x0072;
  17497. t['raarmenian'] = 0x057C;
  17498. t['rabengali'] = 0x09B0;
  17499. t['racute'] = 0x0155;
  17500. t['radeva'] = 0x0930;
  17501. t['radical'] = 0x221A;
  17502. t['radicalex'] = 0xF8E5;
  17503. t['radoverssquare'] = 0x33AE;
  17504. t['radoverssquaredsquare'] = 0x33AF;
  17505. t['radsquare'] = 0x33AD;
  17506. t['rafe'] = 0x05BF;
  17507. t['rafehebrew'] = 0x05BF;
  17508. t['ragujarati'] = 0x0AB0;
  17509. t['ragurmukhi'] = 0x0A30;
  17510. t['rahiragana'] = 0x3089;
  17511. t['rakatakana'] = 0x30E9;
  17512. t['rakatakanahalfwidth'] = 0xFF97;
  17513. t['ralowerdiagonalbengali'] = 0x09F1;
  17514. t['ramiddlediagonalbengali'] = 0x09F0;
  17515. t['ramshorn'] = 0x0264;
  17516. t['ratio'] = 0x2236;
  17517. t['rbopomofo'] = 0x3116;
  17518. t['rcaron'] = 0x0159;
  17519. t['rcedilla'] = 0x0157;
  17520. t['rcircle'] = 0x24E1;
  17521. t['rcommaaccent'] = 0x0157;
  17522. t['rdblgrave'] = 0x0211;
  17523. t['rdotaccent'] = 0x1E59;
  17524. t['rdotbelow'] = 0x1E5B;
  17525. t['rdotbelowmacron'] = 0x1E5D;
  17526. t['referencemark'] = 0x203B;
  17527. t['reflexsubset'] = 0x2286;
  17528. t['reflexsuperset'] = 0x2287;
  17529. t['registered'] = 0x00AE;
  17530. t['registersans'] = 0xF8E8;
  17531. t['registerserif'] = 0xF6DA;
  17532. t['reharabic'] = 0x0631;
  17533. t['reharmenian'] = 0x0580;
  17534. t['rehfinalarabic'] = 0xFEAE;
  17535. t['rehiragana'] = 0x308C;
  17536. t['rekatakana'] = 0x30EC;
  17537. t['rekatakanahalfwidth'] = 0xFF9A;
  17538. t['resh'] = 0x05E8;
  17539. t['reshdageshhebrew'] = 0xFB48;
  17540. t['reshhebrew'] = 0x05E8;
  17541. t['reversedtilde'] = 0x223D;
  17542. t['reviahebrew'] = 0x0597;
  17543. t['reviamugrashhebrew'] = 0x0597;
  17544. t['revlogicalnot'] = 0x2310;
  17545. t['rfishhook'] = 0x027E;
  17546. t['rfishhookreversed'] = 0x027F;
  17547. t['rhabengali'] = 0x09DD;
  17548. t['rhadeva'] = 0x095D;
  17549. t['rho'] = 0x03C1;
  17550. t['rhook'] = 0x027D;
  17551. t['rhookturned'] = 0x027B;
  17552. t['rhookturnedsuperior'] = 0x02B5;
  17553. t['rhosymbolgreek'] = 0x03F1;
  17554. t['rhotichookmod'] = 0x02DE;
  17555. t['rieulacirclekorean'] = 0x3271;
  17556. t['rieulaparenkorean'] = 0x3211;
  17557. t['rieulcirclekorean'] = 0x3263;
  17558. t['rieulhieuhkorean'] = 0x3140;
  17559. t['rieulkiyeokkorean'] = 0x313A;
  17560. t['rieulkiyeoksioskorean'] = 0x3169;
  17561. t['rieulkorean'] = 0x3139;
  17562. t['rieulmieumkorean'] = 0x313B;
  17563. t['rieulpansioskorean'] = 0x316C;
  17564. t['rieulparenkorean'] = 0x3203;
  17565. t['rieulphieuphkorean'] = 0x313F;
  17566. t['rieulpieupkorean'] = 0x313C;
  17567. t['rieulpieupsioskorean'] = 0x316B;
  17568. t['rieulsioskorean'] = 0x313D;
  17569. t['rieulthieuthkorean'] = 0x313E;
  17570. t['rieultikeutkorean'] = 0x316A;
  17571. t['rieulyeorinhieuhkorean'] = 0x316D;
  17572. t['rightangle'] = 0x221F;
  17573. t['righttackbelowcmb'] = 0x0319;
  17574. t['righttriangle'] = 0x22BF;
  17575. t['rihiragana'] = 0x308A;
  17576. t['rikatakana'] = 0x30EA;
  17577. t['rikatakanahalfwidth'] = 0xFF98;
  17578. t['ring'] = 0x02DA;
  17579. t['ringbelowcmb'] = 0x0325;
  17580. t['ringcmb'] = 0x030A;
  17581. t['ringhalfleft'] = 0x02BF;
  17582. t['ringhalfleftarmenian'] = 0x0559;
  17583. t['ringhalfleftbelowcmb'] = 0x031C;
  17584. t['ringhalfleftcentered'] = 0x02D3;
  17585. t['ringhalfright'] = 0x02BE;
  17586. t['ringhalfrightbelowcmb'] = 0x0339;
  17587. t['ringhalfrightcentered'] = 0x02D2;
  17588. t['rinvertedbreve'] = 0x0213;
  17589. t['rittorusquare'] = 0x3351;
  17590. t['rlinebelow'] = 0x1E5F;
  17591. t['rlongleg'] = 0x027C;
  17592. t['rlonglegturned'] = 0x027A;
  17593. t['rmonospace'] = 0xFF52;
  17594. t['rohiragana'] = 0x308D;
  17595. t['rokatakana'] = 0x30ED;
  17596. t['rokatakanahalfwidth'] = 0xFF9B;
  17597. t['roruathai'] = 0x0E23;
  17598. t['rparen'] = 0x24AD;
  17599. t['rrabengali'] = 0x09DC;
  17600. t['rradeva'] = 0x0931;
  17601. t['rragurmukhi'] = 0x0A5C;
  17602. t['rreharabic'] = 0x0691;
  17603. t['rrehfinalarabic'] = 0xFB8D;
  17604. t['rrvocalicbengali'] = 0x09E0;
  17605. t['rrvocalicdeva'] = 0x0960;
  17606. t['rrvocalicgujarati'] = 0x0AE0;
  17607. t['rrvocalicvowelsignbengali'] = 0x09C4;
  17608. t['rrvocalicvowelsigndeva'] = 0x0944;
  17609. t['rrvocalicvowelsigngujarati'] = 0x0AC4;
  17610. t['rsuperior'] = 0xF6F1;
  17611. t['rtblock'] = 0x2590;
  17612. t['rturned'] = 0x0279;
  17613. t['rturnedsuperior'] = 0x02B4;
  17614. t['ruhiragana'] = 0x308B;
  17615. t['rukatakana'] = 0x30EB;
  17616. t['rukatakanahalfwidth'] = 0xFF99;
  17617. t['rupeemarkbengali'] = 0x09F2;
  17618. t['rupeesignbengali'] = 0x09F3;
  17619. t['rupiah'] = 0xF6DD;
  17620. t['ruthai'] = 0x0E24;
  17621. t['rvocalicbengali'] = 0x098B;
  17622. t['rvocalicdeva'] = 0x090B;
  17623. t['rvocalicgujarati'] = 0x0A8B;
  17624. t['rvocalicvowelsignbengali'] = 0x09C3;
  17625. t['rvocalicvowelsigndeva'] = 0x0943;
  17626. t['rvocalicvowelsigngujarati'] = 0x0AC3;
  17627. t['s'] = 0x0073;
  17628. t['sabengali'] = 0x09B8;
  17629. t['sacute'] = 0x015B;
  17630. t['sacutedotaccent'] = 0x1E65;
  17631. t['sadarabic'] = 0x0635;
  17632. t['sadeva'] = 0x0938;
  17633. t['sadfinalarabic'] = 0xFEBA;
  17634. t['sadinitialarabic'] = 0xFEBB;
  17635. t['sadmedialarabic'] = 0xFEBC;
  17636. t['sagujarati'] = 0x0AB8;
  17637. t['sagurmukhi'] = 0x0A38;
  17638. t['sahiragana'] = 0x3055;
  17639. t['sakatakana'] = 0x30B5;
  17640. t['sakatakanahalfwidth'] = 0xFF7B;
  17641. t['sallallahoualayhewasallamarabic'] = 0xFDFA;
  17642. t['samekh'] = 0x05E1;
  17643. t['samekhdagesh'] = 0xFB41;
  17644. t['samekhdageshhebrew'] = 0xFB41;
  17645. t['samekhhebrew'] = 0x05E1;
  17646. t['saraaathai'] = 0x0E32;
  17647. t['saraaethai'] = 0x0E41;
  17648. t['saraaimaimalaithai'] = 0x0E44;
  17649. t['saraaimaimuanthai'] = 0x0E43;
  17650. t['saraamthai'] = 0x0E33;
  17651. t['saraathai'] = 0x0E30;
  17652. t['saraethai'] = 0x0E40;
  17653. t['saraiileftthai'] = 0xF886;
  17654. t['saraiithai'] = 0x0E35;
  17655. t['saraileftthai'] = 0xF885;
  17656. t['saraithai'] = 0x0E34;
  17657. t['saraothai'] = 0x0E42;
  17658. t['saraueeleftthai'] = 0xF888;
  17659. t['saraueethai'] = 0x0E37;
  17660. t['saraueleftthai'] = 0xF887;
  17661. t['sarauethai'] = 0x0E36;
  17662. t['sarauthai'] = 0x0E38;
  17663. t['sarauuthai'] = 0x0E39;
  17664. t['sbopomofo'] = 0x3119;
  17665. t['scaron'] = 0x0161;
  17666. t['scarondotaccent'] = 0x1E67;
  17667. t['scedilla'] = 0x015F;
  17668. t['schwa'] = 0x0259;
  17669. t['schwacyrillic'] = 0x04D9;
  17670. t['schwadieresiscyrillic'] = 0x04DB;
  17671. t['schwahook'] = 0x025A;
  17672. t['scircle'] = 0x24E2;
  17673. t['scircumflex'] = 0x015D;
  17674. t['scommaaccent'] = 0x0219;
  17675. t['sdotaccent'] = 0x1E61;
  17676. t['sdotbelow'] = 0x1E63;
  17677. t['sdotbelowdotaccent'] = 0x1E69;
  17678. t['seagullbelowcmb'] = 0x033C;
  17679. t['second'] = 0x2033;
  17680. t['secondtonechinese'] = 0x02CA;
  17681. t['section'] = 0x00A7;
  17682. t['seenarabic'] = 0x0633;
  17683. t['seenfinalarabic'] = 0xFEB2;
  17684. t['seeninitialarabic'] = 0xFEB3;
  17685. t['seenmedialarabic'] = 0xFEB4;
  17686. t['segol'] = 0x05B6;
  17687. t['segol13'] = 0x05B6;
  17688. t['segol1f'] = 0x05B6;
  17689. t['segol2c'] = 0x05B6;
  17690. t['segolhebrew'] = 0x05B6;
  17691. t['segolnarrowhebrew'] = 0x05B6;
  17692. t['segolquarterhebrew'] = 0x05B6;
  17693. t['segoltahebrew'] = 0x0592;
  17694. t['segolwidehebrew'] = 0x05B6;
  17695. t['seharmenian'] = 0x057D;
  17696. t['sehiragana'] = 0x305B;
  17697. t['sekatakana'] = 0x30BB;
  17698. t['sekatakanahalfwidth'] = 0xFF7E;
  17699. t['semicolon'] = 0x003B;
  17700. t['semicolonarabic'] = 0x061B;
  17701. t['semicolonmonospace'] = 0xFF1B;
  17702. t['semicolonsmall'] = 0xFE54;
  17703. t['semivoicedmarkkana'] = 0x309C;
  17704. t['semivoicedmarkkanahalfwidth'] = 0xFF9F;
  17705. t['sentisquare'] = 0x3322;
  17706. t['sentosquare'] = 0x3323;
  17707. t['seven'] = 0x0037;
  17708. t['sevenarabic'] = 0x0667;
  17709. t['sevenbengali'] = 0x09ED;
  17710. t['sevencircle'] = 0x2466;
  17711. t['sevencircleinversesansserif'] = 0x2790;
  17712. t['sevendeva'] = 0x096D;
  17713. t['seveneighths'] = 0x215E;
  17714. t['sevengujarati'] = 0x0AED;
  17715. t['sevengurmukhi'] = 0x0A6D;
  17716. t['sevenhackarabic'] = 0x0667;
  17717. t['sevenhangzhou'] = 0x3027;
  17718. t['sevenideographicparen'] = 0x3226;
  17719. t['seveninferior'] = 0x2087;
  17720. t['sevenmonospace'] = 0xFF17;
  17721. t['sevenoldstyle'] = 0xF737;
  17722. t['sevenparen'] = 0x247A;
  17723. t['sevenperiod'] = 0x248E;
  17724. t['sevenpersian'] = 0x06F7;
  17725. t['sevenroman'] = 0x2176;
  17726. t['sevensuperior'] = 0x2077;
  17727. t['seventeencircle'] = 0x2470;
  17728. t['seventeenparen'] = 0x2484;
  17729. t['seventeenperiod'] = 0x2498;
  17730. t['seventhai'] = 0x0E57;
  17731. t['sfthyphen'] = 0x00AD;
  17732. t['shaarmenian'] = 0x0577;
  17733. t['shabengali'] = 0x09B6;
  17734. t['shacyrillic'] = 0x0448;
  17735. t['shaddaarabic'] = 0x0651;
  17736. t['shaddadammaarabic'] = 0xFC61;
  17737. t['shaddadammatanarabic'] = 0xFC5E;
  17738. t['shaddafathaarabic'] = 0xFC60;
  17739. t['shaddakasraarabic'] = 0xFC62;
  17740. t['shaddakasratanarabic'] = 0xFC5F;
  17741. t['shade'] = 0x2592;
  17742. t['shadedark'] = 0x2593;
  17743. t['shadelight'] = 0x2591;
  17744. t['shademedium'] = 0x2592;
  17745. t['shadeva'] = 0x0936;
  17746. t['shagujarati'] = 0x0AB6;
  17747. t['shagurmukhi'] = 0x0A36;
  17748. t['shalshelethebrew'] = 0x0593;
  17749. t['shbopomofo'] = 0x3115;
  17750. t['shchacyrillic'] = 0x0449;
  17751. t['sheenarabic'] = 0x0634;
  17752. t['sheenfinalarabic'] = 0xFEB6;
  17753. t['sheeninitialarabic'] = 0xFEB7;
  17754. t['sheenmedialarabic'] = 0xFEB8;
  17755. t['sheicoptic'] = 0x03E3;
  17756. t['sheqel'] = 0x20AA;
  17757. t['sheqelhebrew'] = 0x20AA;
  17758. t['sheva'] = 0x05B0;
  17759. t['sheva115'] = 0x05B0;
  17760. t['sheva15'] = 0x05B0;
  17761. t['sheva22'] = 0x05B0;
  17762. t['sheva2e'] = 0x05B0;
  17763. t['shevahebrew'] = 0x05B0;
  17764. t['shevanarrowhebrew'] = 0x05B0;
  17765. t['shevaquarterhebrew'] = 0x05B0;
  17766. t['shevawidehebrew'] = 0x05B0;
  17767. t['shhacyrillic'] = 0x04BB;
  17768. t['shimacoptic'] = 0x03ED;
  17769. t['shin'] = 0x05E9;
  17770. t['shindagesh'] = 0xFB49;
  17771. t['shindageshhebrew'] = 0xFB49;
  17772. t['shindageshshindot'] = 0xFB2C;
  17773. t['shindageshshindothebrew'] = 0xFB2C;
  17774. t['shindageshsindot'] = 0xFB2D;
  17775. t['shindageshsindothebrew'] = 0xFB2D;
  17776. t['shindothebrew'] = 0x05C1;
  17777. t['shinhebrew'] = 0x05E9;
  17778. t['shinshindot'] = 0xFB2A;
  17779. t['shinshindothebrew'] = 0xFB2A;
  17780. t['shinsindot'] = 0xFB2B;
  17781. t['shinsindothebrew'] = 0xFB2B;
  17782. t['shook'] = 0x0282;
  17783. t['sigma'] = 0x03C3;
  17784. t['sigma1'] = 0x03C2;
  17785. t['sigmafinal'] = 0x03C2;
  17786. t['sigmalunatesymbolgreek'] = 0x03F2;
  17787. t['sihiragana'] = 0x3057;
  17788. t['sikatakana'] = 0x30B7;
  17789. t['sikatakanahalfwidth'] = 0xFF7C;
  17790. t['siluqhebrew'] = 0x05BD;
  17791. t['siluqlefthebrew'] = 0x05BD;
  17792. t['similar'] = 0x223C;
  17793. t['sindothebrew'] = 0x05C2;
  17794. t['siosacirclekorean'] = 0x3274;
  17795. t['siosaparenkorean'] = 0x3214;
  17796. t['sioscieuckorean'] = 0x317E;
  17797. t['sioscirclekorean'] = 0x3266;
  17798. t['sioskiyeokkorean'] = 0x317A;
  17799. t['sioskorean'] = 0x3145;
  17800. t['siosnieunkorean'] = 0x317B;
  17801. t['siosparenkorean'] = 0x3206;
  17802. t['siospieupkorean'] = 0x317D;
  17803. t['siostikeutkorean'] = 0x317C;
  17804. t['six'] = 0x0036;
  17805. t['sixarabic'] = 0x0666;
  17806. t['sixbengali'] = 0x09EC;
  17807. t['sixcircle'] = 0x2465;
  17808. t['sixcircleinversesansserif'] = 0x278F;
  17809. t['sixdeva'] = 0x096C;
  17810. t['sixgujarati'] = 0x0AEC;
  17811. t['sixgurmukhi'] = 0x0A6C;
  17812. t['sixhackarabic'] = 0x0666;
  17813. t['sixhangzhou'] = 0x3026;
  17814. t['sixideographicparen'] = 0x3225;
  17815. t['sixinferior'] = 0x2086;
  17816. t['sixmonospace'] = 0xFF16;
  17817. t['sixoldstyle'] = 0xF736;
  17818. t['sixparen'] = 0x2479;
  17819. t['sixperiod'] = 0x248D;
  17820. t['sixpersian'] = 0x06F6;
  17821. t['sixroman'] = 0x2175;
  17822. t['sixsuperior'] = 0x2076;
  17823. t['sixteencircle'] = 0x246F;
  17824. t['sixteencurrencydenominatorbengali'] = 0x09F9;
  17825. t['sixteenparen'] = 0x2483;
  17826. t['sixteenperiod'] = 0x2497;
  17827. t['sixthai'] = 0x0E56;
  17828. t['slash'] = 0x002F;
  17829. t['slashmonospace'] = 0xFF0F;
  17830. t['slong'] = 0x017F;
  17831. t['slongdotaccent'] = 0x1E9B;
  17832. t['smileface'] = 0x263A;
  17833. t['smonospace'] = 0xFF53;
  17834. t['sofpasuqhebrew'] = 0x05C3;
  17835. t['softhyphen'] = 0x00AD;
  17836. t['softsigncyrillic'] = 0x044C;
  17837. t['sohiragana'] = 0x305D;
  17838. t['sokatakana'] = 0x30BD;
  17839. t['sokatakanahalfwidth'] = 0xFF7F;
  17840. t['soliduslongoverlaycmb'] = 0x0338;
  17841. t['solidusshortoverlaycmb'] = 0x0337;
  17842. t['sorusithai'] = 0x0E29;
  17843. t['sosalathai'] = 0x0E28;
  17844. t['sosothai'] = 0x0E0B;
  17845. t['sosuathai'] = 0x0E2A;
  17846. t['space'] = 0x0020;
  17847. t['spacehackarabic'] = 0x0020;
  17848. t['spade'] = 0x2660;
  17849. t['spadesuitblack'] = 0x2660;
  17850. t['spadesuitwhite'] = 0x2664;
  17851. t['sparen'] = 0x24AE;
  17852. t['squarebelowcmb'] = 0x033B;
  17853. t['squarecc'] = 0x33C4;
  17854. t['squarecm'] = 0x339D;
  17855. t['squarediagonalcrosshatchfill'] = 0x25A9;
  17856. t['squarehorizontalfill'] = 0x25A4;
  17857. t['squarekg'] = 0x338F;
  17858. t['squarekm'] = 0x339E;
  17859. t['squarekmcapital'] = 0x33CE;
  17860. t['squareln'] = 0x33D1;
  17861. t['squarelog'] = 0x33D2;
  17862. t['squaremg'] = 0x338E;
  17863. t['squaremil'] = 0x33D5;
  17864. t['squaremm'] = 0x339C;
  17865. t['squaremsquared'] = 0x33A1;
  17866. t['squareorthogonalcrosshatchfill'] = 0x25A6;
  17867. t['squareupperlefttolowerrightfill'] = 0x25A7;
  17868. t['squareupperrighttolowerleftfill'] = 0x25A8;
  17869. t['squareverticalfill'] = 0x25A5;
  17870. t['squarewhitewithsmallblack'] = 0x25A3;
  17871. t['srsquare'] = 0x33DB;
  17872. t['ssabengali'] = 0x09B7;
  17873. t['ssadeva'] = 0x0937;
  17874. t['ssagujarati'] = 0x0AB7;
  17875. t['ssangcieuckorean'] = 0x3149;
  17876. t['ssanghieuhkorean'] = 0x3185;
  17877. t['ssangieungkorean'] = 0x3180;
  17878. t['ssangkiyeokkorean'] = 0x3132;
  17879. t['ssangnieunkorean'] = 0x3165;
  17880. t['ssangpieupkorean'] = 0x3143;
  17881. t['ssangsioskorean'] = 0x3146;
  17882. t['ssangtikeutkorean'] = 0x3138;
  17883. t['ssuperior'] = 0xF6F2;
  17884. t['sterling'] = 0x00A3;
  17885. t['sterlingmonospace'] = 0xFFE1;
  17886. t['strokelongoverlaycmb'] = 0x0336;
  17887. t['strokeshortoverlaycmb'] = 0x0335;
  17888. t['subset'] = 0x2282;
  17889. t['subsetnotequal'] = 0x228A;
  17890. t['subsetorequal'] = 0x2286;
  17891. t['succeeds'] = 0x227B;
  17892. t['suchthat'] = 0x220B;
  17893. t['suhiragana'] = 0x3059;
  17894. t['sukatakana'] = 0x30B9;
  17895. t['sukatakanahalfwidth'] = 0xFF7D;
  17896. t['sukunarabic'] = 0x0652;
  17897. t['summation'] = 0x2211;
  17898. t['sun'] = 0x263C;
  17899. t['superset'] = 0x2283;
  17900. t['supersetnotequal'] = 0x228B;
  17901. t['supersetorequal'] = 0x2287;
  17902. t['svsquare'] = 0x33DC;
  17903. t['syouwaerasquare'] = 0x337C;
  17904. t['t'] = 0x0074;
  17905. t['tabengali'] = 0x09A4;
  17906. t['tackdown'] = 0x22A4;
  17907. t['tackleft'] = 0x22A3;
  17908. t['tadeva'] = 0x0924;
  17909. t['tagujarati'] = 0x0AA4;
  17910. t['tagurmukhi'] = 0x0A24;
  17911. t['taharabic'] = 0x0637;
  17912. t['tahfinalarabic'] = 0xFEC2;
  17913. t['tahinitialarabic'] = 0xFEC3;
  17914. t['tahiragana'] = 0x305F;
  17915. t['tahmedialarabic'] = 0xFEC4;
  17916. t['taisyouerasquare'] = 0x337D;
  17917. t['takatakana'] = 0x30BF;
  17918. t['takatakanahalfwidth'] = 0xFF80;
  17919. t['tatweelarabic'] = 0x0640;
  17920. t['tau'] = 0x03C4;
  17921. t['tav'] = 0x05EA;
  17922. t['tavdages'] = 0xFB4A;
  17923. t['tavdagesh'] = 0xFB4A;
  17924. t['tavdageshhebrew'] = 0xFB4A;
  17925. t['tavhebrew'] = 0x05EA;
  17926. t['tbar'] = 0x0167;
  17927. t['tbopomofo'] = 0x310A;
  17928. t['tcaron'] = 0x0165;
  17929. t['tccurl'] = 0x02A8;
  17930. t['tcedilla'] = 0x0163;
  17931. t['tcheharabic'] = 0x0686;
  17932. t['tchehfinalarabic'] = 0xFB7B;
  17933. t['tchehinitialarabic'] = 0xFB7C;
  17934. t['tchehmedialarabic'] = 0xFB7D;
  17935. t['tcircle'] = 0x24E3;
  17936. t['tcircumflexbelow'] = 0x1E71;
  17937. t['tcommaaccent'] = 0x0163;
  17938. t['tdieresis'] = 0x1E97;
  17939. t['tdotaccent'] = 0x1E6B;
  17940. t['tdotbelow'] = 0x1E6D;
  17941. t['tecyrillic'] = 0x0442;
  17942. t['tedescendercyrillic'] = 0x04AD;
  17943. t['teharabic'] = 0x062A;
  17944. t['tehfinalarabic'] = 0xFE96;
  17945. t['tehhahinitialarabic'] = 0xFCA2;
  17946. t['tehhahisolatedarabic'] = 0xFC0C;
  17947. t['tehinitialarabic'] = 0xFE97;
  17948. t['tehiragana'] = 0x3066;
  17949. t['tehjeeminitialarabic'] = 0xFCA1;
  17950. t['tehjeemisolatedarabic'] = 0xFC0B;
  17951. t['tehmarbutaarabic'] = 0x0629;
  17952. t['tehmarbutafinalarabic'] = 0xFE94;
  17953. t['tehmedialarabic'] = 0xFE98;
  17954. t['tehmeeminitialarabic'] = 0xFCA4;
  17955. t['tehmeemisolatedarabic'] = 0xFC0E;
  17956. t['tehnoonfinalarabic'] = 0xFC73;
  17957. t['tekatakana'] = 0x30C6;
  17958. t['tekatakanahalfwidth'] = 0xFF83;
  17959. t['telephone'] = 0x2121;
  17960. t['telephoneblack'] = 0x260E;
  17961. t['telishagedolahebrew'] = 0x05A0;
  17962. t['telishaqetanahebrew'] = 0x05A9;
  17963. t['tencircle'] = 0x2469;
  17964. t['tenideographicparen'] = 0x3229;
  17965. t['tenparen'] = 0x247D;
  17966. t['tenperiod'] = 0x2491;
  17967. t['tenroman'] = 0x2179;
  17968. t['tesh'] = 0x02A7;
  17969. t['tet'] = 0x05D8;
  17970. t['tetdagesh'] = 0xFB38;
  17971. t['tetdageshhebrew'] = 0xFB38;
  17972. t['tethebrew'] = 0x05D8;
  17973. t['tetsecyrillic'] = 0x04B5;
  17974. t['tevirhebrew'] = 0x059B;
  17975. t['tevirlefthebrew'] = 0x059B;
  17976. t['thabengali'] = 0x09A5;
  17977. t['thadeva'] = 0x0925;
  17978. t['thagujarati'] = 0x0AA5;
  17979. t['thagurmukhi'] = 0x0A25;
  17980. t['thalarabic'] = 0x0630;
  17981. t['thalfinalarabic'] = 0xFEAC;
  17982. t['thanthakhatlowleftthai'] = 0xF898;
  17983. t['thanthakhatlowrightthai'] = 0xF897;
  17984. t['thanthakhatthai'] = 0x0E4C;
  17985. t['thanthakhatupperleftthai'] = 0xF896;
  17986. t['theharabic'] = 0x062B;
  17987. t['thehfinalarabic'] = 0xFE9A;
  17988. t['thehinitialarabic'] = 0xFE9B;
  17989. t['thehmedialarabic'] = 0xFE9C;
  17990. t['thereexists'] = 0x2203;
  17991. t['therefore'] = 0x2234;
  17992. t['theta'] = 0x03B8;
  17993. t['theta1'] = 0x03D1;
  17994. t['thetasymbolgreek'] = 0x03D1;
  17995. t['thieuthacirclekorean'] = 0x3279;
  17996. t['thieuthaparenkorean'] = 0x3219;
  17997. t['thieuthcirclekorean'] = 0x326B;
  17998. t['thieuthkorean'] = 0x314C;
  17999. t['thieuthparenkorean'] = 0x320B;
  18000. t['thirteencircle'] = 0x246C;
  18001. t['thirteenparen'] = 0x2480;
  18002. t['thirteenperiod'] = 0x2494;
  18003. t['thonangmonthothai'] = 0x0E11;
  18004. t['thook'] = 0x01AD;
  18005. t['thophuthaothai'] = 0x0E12;
  18006. t['thorn'] = 0x00FE;
  18007. t['thothahanthai'] = 0x0E17;
  18008. t['thothanthai'] = 0x0E10;
  18009. t['thothongthai'] = 0x0E18;
  18010. t['thothungthai'] = 0x0E16;
  18011. t['thousandcyrillic'] = 0x0482;
  18012. t['thousandsseparatorarabic'] = 0x066C;
  18013. t['thousandsseparatorpersian'] = 0x066C;
  18014. t['three'] = 0x0033;
  18015. t['threearabic'] = 0x0663;
  18016. t['threebengali'] = 0x09E9;
  18017. t['threecircle'] = 0x2462;
  18018. t['threecircleinversesansserif'] = 0x278C;
  18019. t['threedeva'] = 0x0969;
  18020. t['threeeighths'] = 0x215C;
  18021. t['threegujarati'] = 0x0AE9;
  18022. t['threegurmukhi'] = 0x0A69;
  18023. t['threehackarabic'] = 0x0663;
  18024. t['threehangzhou'] = 0x3023;
  18025. t['threeideographicparen'] = 0x3222;
  18026. t['threeinferior'] = 0x2083;
  18027. t['threemonospace'] = 0xFF13;
  18028. t['threenumeratorbengali'] = 0x09F6;
  18029. t['threeoldstyle'] = 0xF733;
  18030. t['threeparen'] = 0x2476;
  18031. t['threeperiod'] = 0x248A;
  18032. t['threepersian'] = 0x06F3;
  18033. t['threequarters'] = 0x00BE;
  18034. t['threequartersemdash'] = 0xF6DE;
  18035. t['threeroman'] = 0x2172;
  18036. t['threesuperior'] = 0x00B3;
  18037. t['threethai'] = 0x0E53;
  18038. t['thzsquare'] = 0x3394;
  18039. t['tihiragana'] = 0x3061;
  18040. t['tikatakana'] = 0x30C1;
  18041. t['tikatakanahalfwidth'] = 0xFF81;
  18042. t['tikeutacirclekorean'] = 0x3270;
  18043. t['tikeutaparenkorean'] = 0x3210;
  18044. t['tikeutcirclekorean'] = 0x3262;
  18045. t['tikeutkorean'] = 0x3137;
  18046. t['tikeutparenkorean'] = 0x3202;
  18047. t['tilde'] = 0x02DC;
  18048. t['tildebelowcmb'] = 0x0330;
  18049. t['tildecmb'] = 0x0303;
  18050. t['tildecomb'] = 0x0303;
  18051. t['tildedoublecmb'] = 0x0360;
  18052. t['tildeoperator'] = 0x223C;
  18053. t['tildeoverlaycmb'] = 0x0334;
  18054. t['tildeverticalcmb'] = 0x033E;
  18055. t['timescircle'] = 0x2297;
  18056. t['tipehahebrew'] = 0x0596;
  18057. t['tipehalefthebrew'] = 0x0596;
  18058. t['tippigurmukhi'] = 0x0A70;
  18059. t['titlocyrilliccmb'] = 0x0483;
  18060. t['tiwnarmenian'] = 0x057F;
  18061. t['tlinebelow'] = 0x1E6F;
  18062. t['tmonospace'] = 0xFF54;
  18063. t['toarmenian'] = 0x0569;
  18064. t['tohiragana'] = 0x3068;
  18065. t['tokatakana'] = 0x30C8;
  18066. t['tokatakanahalfwidth'] = 0xFF84;
  18067. t['tonebarextrahighmod'] = 0x02E5;
  18068. t['tonebarextralowmod'] = 0x02E9;
  18069. t['tonebarhighmod'] = 0x02E6;
  18070. t['tonebarlowmod'] = 0x02E8;
  18071. t['tonebarmidmod'] = 0x02E7;
  18072. t['tonefive'] = 0x01BD;
  18073. t['tonesix'] = 0x0185;
  18074. t['tonetwo'] = 0x01A8;
  18075. t['tonos'] = 0x0384;
  18076. t['tonsquare'] = 0x3327;
  18077. t['topatakthai'] = 0x0E0F;
  18078. t['tortoiseshellbracketleft'] = 0x3014;
  18079. t['tortoiseshellbracketleftsmall'] = 0xFE5D;
  18080. t['tortoiseshellbracketleftvertical'] = 0xFE39;
  18081. t['tortoiseshellbracketright'] = 0x3015;
  18082. t['tortoiseshellbracketrightsmall'] = 0xFE5E;
  18083. t['tortoiseshellbracketrightvertical'] = 0xFE3A;
  18084. t['totaothai'] = 0x0E15;
  18085. t['tpalatalhook'] = 0x01AB;
  18086. t['tparen'] = 0x24AF;
  18087. t['trademark'] = 0x2122;
  18088. t['trademarksans'] = 0xF8EA;
  18089. t['trademarkserif'] = 0xF6DB;
  18090. t['tretroflexhook'] = 0x0288;
  18091. t['triagdn'] = 0x25BC;
  18092. t['triaglf'] = 0x25C4;
  18093. t['triagrt'] = 0x25BA;
  18094. t['triagup'] = 0x25B2;
  18095. t['ts'] = 0x02A6;
  18096. t['tsadi'] = 0x05E6;
  18097. t['tsadidagesh'] = 0xFB46;
  18098. t['tsadidageshhebrew'] = 0xFB46;
  18099. t['tsadihebrew'] = 0x05E6;
  18100. t['tsecyrillic'] = 0x0446;
  18101. t['tsere'] = 0x05B5;
  18102. t['tsere12'] = 0x05B5;
  18103. t['tsere1e'] = 0x05B5;
  18104. t['tsere2b'] = 0x05B5;
  18105. t['tserehebrew'] = 0x05B5;
  18106. t['tserenarrowhebrew'] = 0x05B5;
  18107. t['tserequarterhebrew'] = 0x05B5;
  18108. t['tserewidehebrew'] = 0x05B5;
  18109. t['tshecyrillic'] = 0x045B;
  18110. t['tsuperior'] = 0xF6F3;
  18111. t['ttabengali'] = 0x099F;
  18112. t['ttadeva'] = 0x091F;
  18113. t['ttagujarati'] = 0x0A9F;
  18114. t['ttagurmukhi'] = 0x0A1F;
  18115. t['tteharabic'] = 0x0679;
  18116. t['ttehfinalarabic'] = 0xFB67;
  18117. t['ttehinitialarabic'] = 0xFB68;
  18118. t['ttehmedialarabic'] = 0xFB69;
  18119. t['tthabengali'] = 0x09A0;
  18120. t['tthadeva'] = 0x0920;
  18121. t['tthagujarati'] = 0x0AA0;
  18122. t['tthagurmukhi'] = 0x0A20;
  18123. t['tturned'] = 0x0287;
  18124. t['tuhiragana'] = 0x3064;
  18125. t['tukatakana'] = 0x30C4;
  18126. t['tukatakanahalfwidth'] = 0xFF82;
  18127. t['tusmallhiragana'] = 0x3063;
  18128. t['tusmallkatakana'] = 0x30C3;
  18129. t['tusmallkatakanahalfwidth'] = 0xFF6F;
  18130. t['twelvecircle'] = 0x246B;
  18131. t['twelveparen'] = 0x247F;
  18132. t['twelveperiod'] = 0x2493;
  18133. t['twelveroman'] = 0x217B;
  18134. t['twentycircle'] = 0x2473;
  18135. t['twentyhangzhou'] = 0x5344;
  18136. t['twentyparen'] = 0x2487;
  18137. t['twentyperiod'] = 0x249B;
  18138. t['two'] = 0x0032;
  18139. t['twoarabic'] = 0x0662;
  18140. t['twobengali'] = 0x09E8;
  18141. t['twocircle'] = 0x2461;
  18142. t['twocircleinversesansserif'] = 0x278B;
  18143. t['twodeva'] = 0x0968;
  18144. t['twodotenleader'] = 0x2025;
  18145. t['twodotleader'] = 0x2025;
  18146. t['twodotleadervertical'] = 0xFE30;
  18147. t['twogujarati'] = 0x0AE8;
  18148. t['twogurmukhi'] = 0x0A68;
  18149. t['twohackarabic'] = 0x0662;
  18150. t['twohangzhou'] = 0x3022;
  18151. t['twoideographicparen'] = 0x3221;
  18152. t['twoinferior'] = 0x2082;
  18153. t['twomonospace'] = 0xFF12;
  18154. t['twonumeratorbengali'] = 0x09F5;
  18155. t['twooldstyle'] = 0xF732;
  18156. t['twoparen'] = 0x2475;
  18157. t['twoperiod'] = 0x2489;
  18158. t['twopersian'] = 0x06F2;
  18159. t['tworoman'] = 0x2171;
  18160. t['twostroke'] = 0x01BB;
  18161. t['twosuperior'] = 0x00B2;
  18162. t['twothai'] = 0x0E52;
  18163. t['twothirds'] = 0x2154;
  18164. t['u'] = 0x0075;
  18165. t['uacute'] = 0x00FA;
  18166. t['ubar'] = 0x0289;
  18167. t['ubengali'] = 0x0989;
  18168. t['ubopomofo'] = 0x3128;
  18169. t['ubreve'] = 0x016D;
  18170. t['ucaron'] = 0x01D4;
  18171. t['ucircle'] = 0x24E4;
  18172. t['ucircumflex'] = 0x00FB;
  18173. t['ucircumflexbelow'] = 0x1E77;
  18174. t['ucyrillic'] = 0x0443;
  18175. t['udattadeva'] = 0x0951;
  18176. t['udblacute'] = 0x0171;
  18177. t['udblgrave'] = 0x0215;
  18178. t['udeva'] = 0x0909;
  18179. t['udieresis'] = 0x00FC;
  18180. t['udieresisacute'] = 0x01D8;
  18181. t['udieresisbelow'] = 0x1E73;
  18182. t['udieresiscaron'] = 0x01DA;
  18183. t['udieresiscyrillic'] = 0x04F1;
  18184. t['udieresisgrave'] = 0x01DC;
  18185. t['udieresismacron'] = 0x01D6;
  18186. t['udotbelow'] = 0x1EE5;
  18187. t['ugrave'] = 0x00F9;
  18188. t['ugujarati'] = 0x0A89;
  18189. t['ugurmukhi'] = 0x0A09;
  18190. t['uhiragana'] = 0x3046;
  18191. t['uhookabove'] = 0x1EE7;
  18192. t['uhorn'] = 0x01B0;
  18193. t['uhornacute'] = 0x1EE9;
  18194. t['uhorndotbelow'] = 0x1EF1;
  18195. t['uhorngrave'] = 0x1EEB;
  18196. t['uhornhookabove'] = 0x1EED;
  18197. t['uhorntilde'] = 0x1EEF;
  18198. t['uhungarumlaut'] = 0x0171;
  18199. t['uhungarumlautcyrillic'] = 0x04F3;
  18200. t['uinvertedbreve'] = 0x0217;
  18201. t['ukatakana'] = 0x30A6;
  18202. t['ukatakanahalfwidth'] = 0xFF73;
  18203. t['ukcyrillic'] = 0x0479;
  18204. t['ukorean'] = 0x315C;
  18205. t['umacron'] = 0x016B;
  18206. t['umacroncyrillic'] = 0x04EF;
  18207. t['umacrondieresis'] = 0x1E7B;
  18208. t['umatragurmukhi'] = 0x0A41;
  18209. t['umonospace'] = 0xFF55;
  18210. t['underscore'] = 0x005F;
  18211. t['underscoredbl'] = 0x2017;
  18212. t['underscoremonospace'] = 0xFF3F;
  18213. t['underscorevertical'] = 0xFE33;
  18214. t['underscorewavy'] = 0xFE4F;
  18215. t['union'] = 0x222A;
  18216. t['universal'] = 0x2200;
  18217. t['uogonek'] = 0x0173;
  18218. t['uparen'] = 0x24B0;
  18219. t['upblock'] = 0x2580;
  18220. t['upperdothebrew'] = 0x05C4;
  18221. t['upsilon'] = 0x03C5;
  18222. t['upsilondieresis'] = 0x03CB;
  18223. t['upsilondieresistonos'] = 0x03B0;
  18224. t['upsilonlatin'] = 0x028A;
  18225. t['upsilontonos'] = 0x03CD;
  18226. t['uptackbelowcmb'] = 0x031D;
  18227. t['uptackmod'] = 0x02D4;
  18228. t['uragurmukhi'] = 0x0A73;
  18229. t['uring'] = 0x016F;
  18230. t['ushortcyrillic'] = 0x045E;
  18231. t['usmallhiragana'] = 0x3045;
  18232. t['usmallkatakana'] = 0x30A5;
  18233. t['usmallkatakanahalfwidth'] = 0xFF69;
  18234. t['ustraightcyrillic'] = 0x04AF;
  18235. t['ustraightstrokecyrillic'] = 0x04B1;
  18236. t['utilde'] = 0x0169;
  18237. t['utildeacute'] = 0x1E79;
  18238. t['utildebelow'] = 0x1E75;
  18239. t['uubengali'] = 0x098A;
  18240. t['uudeva'] = 0x090A;
  18241. t['uugujarati'] = 0x0A8A;
  18242. t['uugurmukhi'] = 0x0A0A;
  18243. t['uumatragurmukhi'] = 0x0A42;
  18244. t['uuvowelsignbengali'] = 0x09C2;
  18245. t['uuvowelsigndeva'] = 0x0942;
  18246. t['uuvowelsigngujarati'] = 0x0AC2;
  18247. t['uvowelsignbengali'] = 0x09C1;
  18248. t['uvowelsigndeva'] = 0x0941;
  18249. t['uvowelsigngujarati'] = 0x0AC1;
  18250. t['v'] = 0x0076;
  18251. t['vadeva'] = 0x0935;
  18252. t['vagujarati'] = 0x0AB5;
  18253. t['vagurmukhi'] = 0x0A35;
  18254. t['vakatakana'] = 0x30F7;
  18255. t['vav'] = 0x05D5;
  18256. t['vavdagesh'] = 0xFB35;
  18257. t['vavdagesh65'] = 0xFB35;
  18258. t['vavdageshhebrew'] = 0xFB35;
  18259. t['vavhebrew'] = 0x05D5;
  18260. t['vavholam'] = 0xFB4B;
  18261. t['vavholamhebrew'] = 0xFB4B;
  18262. t['vavvavhebrew'] = 0x05F0;
  18263. t['vavyodhebrew'] = 0x05F1;
  18264. t['vcircle'] = 0x24E5;
  18265. t['vdotbelow'] = 0x1E7F;
  18266. t['vecyrillic'] = 0x0432;
  18267. t['veharabic'] = 0x06A4;
  18268. t['vehfinalarabic'] = 0xFB6B;
  18269. t['vehinitialarabic'] = 0xFB6C;
  18270. t['vehmedialarabic'] = 0xFB6D;
  18271. t['vekatakana'] = 0x30F9;
  18272. t['venus'] = 0x2640;
  18273. t['verticalbar'] = 0x007C;
  18274. t['verticallineabovecmb'] = 0x030D;
  18275. t['verticallinebelowcmb'] = 0x0329;
  18276. t['verticallinelowmod'] = 0x02CC;
  18277. t['verticallinemod'] = 0x02C8;
  18278. t['vewarmenian'] = 0x057E;
  18279. t['vhook'] = 0x028B;
  18280. t['vikatakana'] = 0x30F8;
  18281. t['viramabengali'] = 0x09CD;
  18282. t['viramadeva'] = 0x094D;
  18283. t['viramagujarati'] = 0x0ACD;
  18284. t['visargabengali'] = 0x0983;
  18285. t['visargadeva'] = 0x0903;
  18286. t['visargagujarati'] = 0x0A83;
  18287. t['vmonospace'] = 0xFF56;
  18288. t['voarmenian'] = 0x0578;
  18289. t['voicediterationhiragana'] = 0x309E;
  18290. t['voicediterationkatakana'] = 0x30FE;
  18291. t['voicedmarkkana'] = 0x309B;
  18292. t['voicedmarkkanahalfwidth'] = 0xFF9E;
  18293. t['vokatakana'] = 0x30FA;
  18294. t['vparen'] = 0x24B1;
  18295. t['vtilde'] = 0x1E7D;
  18296. t['vturned'] = 0x028C;
  18297. t['vuhiragana'] = 0x3094;
  18298. t['vukatakana'] = 0x30F4;
  18299. t['w'] = 0x0077;
  18300. t['wacute'] = 0x1E83;
  18301. t['waekorean'] = 0x3159;
  18302. t['wahiragana'] = 0x308F;
  18303. t['wakatakana'] = 0x30EF;
  18304. t['wakatakanahalfwidth'] = 0xFF9C;
  18305. t['wakorean'] = 0x3158;
  18306. t['wasmallhiragana'] = 0x308E;
  18307. t['wasmallkatakana'] = 0x30EE;
  18308. t['wattosquare'] = 0x3357;
  18309. t['wavedash'] = 0x301C;
  18310. t['wavyunderscorevertical'] = 0xFE34;
  18311. t['wawarabic'] = 0x0648;
  18312. t['wawfinalarabic'] = 0xFEEE;
  18313. t['wawhamzaabovearabic'] = 0x0624;
  18314. t['wawhamzaabovefinalarabic'] = 0xFE86;
  18315. t['wbsquare'] = 0x33DD;
  18316. t['wcircle'] = 0x24E6;
  18317. t['wcircumflex'] = 0x0175;
  18318. t['wdieresis'] = 0x1E85;
  18319. t['wdotaccent'] = 0x1E87;
  18320. t['wdotbelow'] = 0x1E89;
  18321. t['wehiragana'] = 0x3091;
  18322. t['weierstrass'] = 0x2118;
  18323. t['wekatakana'] = 0x30F1;
  18324. t['wekorean'] = 0x315E;
  18325. t['weokorean'] = 0x315D;
  18326. t['wgrave'] = 0x1E81;
  18327. t['whitebullet'] = 0x25E6;
  18328. t['whitecircle'] = 0x25CB;
  18329. t['whitecircleinverse'] = 0x25D9;
  18330. t['whitecornerbracketleft'] = 0x300E;
  18331. t['whitecornerbracketleftvertical'] = 0xFE43;
  18332. t['whitecornerbracketright'] = 0x300F;
  18333. t['whitecornerbracketrightvertical'] = 0xFE44;
  18334. t['whitediamond'] = 0x25C7;
  18335. t['whitediamondcontainingblacksmalldiamond'] = 0x25C8;
  18336. t['whitedownpointingsmalltriangle'] = 0x25BF;
  18337. t['whitedownpointingtriangle'] = 0x25BD;
  18338. t['whiteleftpointingsmalltriangle'] = 0x25C3;
  18339. t['whiteleftpointingtriangle'] = 0x25C1;
  18340. t['whitelenticularbracketleft'] = 0x3016;
  18341. t['whitelenticularbracketright'] = 0x3017;
  18342. t['whiterightpointingsmalltriangle'] = 0x25B9;
  18343. t['whiterightpointingtriangle'] = 0x25B7;
  18344. t['whitesmallsquare'] = 0x25AB;
  18345. t['whitesmilingface'] = 0x263A;
  18346. t['whitesquare'] = 0x25A1;
  18347. t['whitestar'] = 0x2606;
  18348. t['whitetelephone'] = 0x260F;
  18349. t['whitetortoiseshellbracketleft'] = 0x3018;
  18350. t['whitetortoiseshellbracketright'] = 0x3019;
  18351. t['whiteuppointingsmalltriangle'] = 0x25B5;
  18352. t['whiteuppointingtriangle'] = 0x25B3;
  18353. t['wihiragana'] = 0x3090;
  18354. t['wikatakana'] = 0x30F0;
  18355. t['wikorean'] = 0x315F;
  18356. t['wmonospace'] = 0xFF57;
  18357. t['wohiragana'] = 0x3092;
  18358. t['wokatakana'] = 0x30F2;
  18359. t['wokatakanahalfwidth'] = 0xFF66;
  18360. t['won'] = 0x20A9;
  18361. t['wonmonospace'] = 0xFFE6;
  18362. t['wowaenthai'] = 0x0E27;
  18363. t['wparen'] = 0x24B2;
  18364. t['wring'] = 0x1E98;
  18365. t['wsuperior'] = 0x02B7;
  18366. t['wturned'] = 0x028D;
  18367. t['wynn'] = 0x01BF;
  18368. t['x'] = 0x0078;
  18369. t['xabovecmb'] = 0x033D;
  18370. t['xbopomofo'] = 0x3112;
  18371. t['xcircle'] = 0x24E7;
  18372. t['xdieresis'] = 0x1E8D;
  18373. t['xdotaccent'] = 0x1E8B;
  18374. t['xeharmenian'] = 0x056D;
  18375. t['xi'] = 0x03BE;
  18376. t['xmonospace'] = 0xFF58;
  18377. t['xparen'] = 0x24B3;
  18378. t['xsuperior'] = 0x02E3;
  18379. t['y'] = 0x0079;
  18380. t['yaadosquare'] = 0x334E;
  18381. t['yabengali'] = 0x09AF;
  18382. t['yacute'] = 0x00FD;
  18383. t['yadeva'] = 0x092F;
  18384. t['yaekorean'] = 0x3152;
  18385. t['yagujarati'] = 0x0AAF;
  18386. t['yagurmukhi'] = 0x0A2F;
  18387. t['yahiragana'] = 0x3084;
  18388. t['yakatakana'] = 0x30E4;
  18389. t['yakatakanahalfwidth'] = 0xFF94;
  18390. t['yakorean'] = 0x3151;
  18391. t['yamakkanthai'] = 0x0E4E;
  18392. t['yasmallhiragana'] = 0x3083;
  18393. t['yasmallkatakana'] = 0x30E3;
  18394. t['yasmallkatakanahalfwidth'] = 0xFF6C;
  18395. t['yatcyrillic'] = 0x0463;
  18396. t['ycircle'] = 0x24E8;
  18397. t['ycircumflex'] = 0x0177;
  18398. t['ydieresis'] = 0x00FF;
  18399. t['ydotaccent'] = 0x1E8F;
  18400. t['ydotbelow'] = 0x1EF5;
  18401. t['yeharabic'] = 0x064A;
  18402. t['yehbarreearabic'] = 0x06D2;
  18403. t['yehbarreefinalarabic'] = 0xFBAF;
  18404. t['yehfinalarabic'] = 0xFEF2;
  18405. t['yehhamzaabovearabic'] = 0x0626;
  18406. t['yehhamzaabovefinalarabic'] = 0xFE8A;
  18407. t['yehhamzaaboveinitialarabic'] = 0xFE8B;
  18408. t['yehhamzaabovemedialarabic'] = 0xFE8C;
  18409. t['yehinitialarabic'] = 0xFEF3;
  18410. t['yehmedialarabic'] = 0xFEF4;
  18411. t['yehmeeminitialarabic'] = 0xFCDD;
  18412. t['yehmeemisolatedarabic'] = 0xFC58;
  18413. t['yehnoonfinalarabic'] = 0xFC94;
  18414. t['yehthreedotsbelowarabic'] = 0x06D1;
  18415. t['yekorean'] = 0x3156;
  18416. t['yen'] = 0x00A5;
  18417. t['yenmonospace'] = 0xFFE5;
  18418. t['yeokorean'] = 0x3155;
  18419. t['yeorinhieuhkorean'] = 0x3186;
  18420. t['yerahbenyomohebrew'] = 0x05AA;
  18421. t['yerahbenyomolefthebrew'] = 0x05AA;
  18422. t['yericyrillic'] = 0x044B;
  18423. t['yerudieresiscyrillic'] = 0x04F9;
  18424. t['yesieungkorean'] = 0x3181;
  18425. t['yesieungpansioskorean'] = 0x3183;
  18426. t['yesieungsioskorean'] = 0x3182;
  18427. t['yetivhebrew'] = 0x059A;
  18428. t['ygrave'] = 0x1EF3;
  18429. t['yhook'] = 0x01B4;
  18430. t['yhookabove'] = 0x1EF7;
  18431. t['yiarmenian'] = 0x0575;
  18432. t['yicyrillic'] = 0x0457;
  18433. t['yikorean'] = 0x3162;
  18434. t['yinyang'] = 0x262F;
  18435. t['yiwnarmenian'] = 0x0582;
  18436. t['ymonospace'] = 0xFF59;
  18437. t['yod'] = 0x05D9;
  18438. t['yoddagesh'] = 0xFB39;
  18439. t['yoddageshhebrew'] = 0xFB39;
  18440. t['yodhebrew'] = 0x05D9;
  18441. t['yodyodhebrew'] = 0x05F2;
  18442. t['yodyodpatahhebrew'] = 0xFB1F;
  18443. t['yohiragana'] = 0x3088;
  18444. t['yoikorean'] = 0x3189;
  18445. t['yokatakana'] = 0x30E8;
  18446. t['yokatakanahalfwidth'] = 0xFF96;
  18447. t['yokorean'] = 0x315B;
  18448. t['yosmallhiragana'] = 0x3087;
  18449. t['yosmallkatakana'] = 0x30E7;
  18450. t['yosmallkatakanahalfwidth'] = 0xFF6E;
  18451. t['yotgreek'] = 0x03F3;
  18452. t['yoyaekorean'] = 0x3188;
  18453. t['yoyakorean'] = 0x3187;
  18454. t['yoyakthai'] = 0x0E22;
  18455. t['yoyingthai'] = 0x0E0D;
  18456. t['yparen'] = 0x24B4;
  18457. t['ypogegrammeni'] = 0x037A;
  18458. t['ypogegrammenigreekcmb'] = 0x0345;
  18459. t['yr'] = 0x01A6;
  18460. t['yring'] = 0x1E99;
  18461. t['ysuperior'] = 0x02B8;
  18462. t['ytilde'] = 0x1EF9;
  18463. t['yturned'] = 0x028E;
  18464. t['yuhiragana'] = 0x3086;
  18465. t['yuikorean'] = 0x318C;
  18466. t['yukatakana'] = 0x30E6;
  18467. t['yukatakanahalfwidth'] = 0xFF95;
  18468. t['yukorean'] = 0x3160;
  18469. t['yusbigcyrillic'] = 0x046B;
  18470. t['yusbigiotifiedcyrillic'] = 0x046D;
  18471. t['yuslittlecyrillic'] = 0x0467;
  18472. t['yuslittleiotifiedcyrillic'] = 0x0469;
  18473. t['yusmallhiragana'] = 0x3085;
  18474. t['yusmallkatakana'] = 0x30E5;
  18475. t['yusmallkatakanahalfwidth'] = 0xFF6D;
  18476. t['yuyekorean'] = 0x318B;
  18477. t['yuyeokorean'] = 0x318A;
  18478. t['yyabengali'] = 0x09DF;
  18479. t['yyadeva'] = 0x095F;
  18480. t['z'] = 0x007A;
  18481. t['zaarmenian'] = 0x0566;
  18482. t['zacute'] = 0x017A;
  18483. t['zadeva'] = 0x095B;
  18484. t['zagurmukhi'] = 0x0A5B;
  18485. t['zaharabic'] = 0x0638;
  18486. t['zahfinalarabic'] = 0xFEC6;
  18487. t['zahinitialarabic'] = 0xFEC7;
  18488. t['zahiragana'] = 0x3056;
  18489. t['zahmedialarabic'] = 0xFEC8;
  18490. t['zainarabic'] = 0x0632;
  18491. t['zainfinalarabic'] = 0xFEB0;
  18492. t['zakatakana'] = 0x30B6;
  18493. t['zaqefgadolhebrew'] = 0x0595;
  18494. t['zaqefqatanhebrew'] = 0x0594;
  18495. t['zarqahebrew'] = 0x0598;
  18496. t['zayin'] = 0x05D6;
  18497. t['zayindagesh'] = 0xFB36;
  18498. t['zayindageshhebrew'] = 0xFB36;
  18499. t['zayinhebrew'] = 0x05D6;
  18500. t['zbopomofo'] = 0x3117;
  18501. t['zcaron'] = 0x017E;
  18502. t['zcircle'] = 0x24E9;
  18503. t['zcircumflex'] = 0x1E91;
  18504. t['zcurl'] = 0x0291;
  18505. t['zdot'] = 0x017C;
  18506. t['zdotaccent'] = 0x017C;
  18507. t['zdotbelow'] = 0x1E93;
  18508. t['zecyrillic'] = 0x0437;
  18509. t['zedescendercyrillic'] = 0x0499;
  18510. t['zedieresiscyrillic'] = 0x04DF;
  18511. t['zehiragana'] = 0x305C;
  18512. t['zekatakana'] = 0x30BC;
  18513. t['zero'] = 0x0030;
  18514. t['zeroarabic'] = 0x0660;
  18515. t['zerobengali'] = 0x09E6;
  18516. t['zerodeva'] = 0x0966;
  18517. t['zerogujarati'] = 0x0AE6;
  18518. t['zerogurmukhi'] = 0x0A66;
  18519. t['zerohackarabic'] = 0x0660;
  18520. t['zeroinferior'] = 0x2080;
  18521. t['zeromonospace'] = 0xFF10;
  18522. t['zerooldstyle'] = 0xF730;
  18523. t['zeropersian'] = 0x06F0;
  18524. t['zerosuperior'] = 0x2070;
  18525. t['zerothai'] = 0x0E50;
  18526. t['zerowidthjoiner'] = 0xFEFF;
  18527. t['zerowidthnonjoiner'] = 0x200C;
  18528. t['zerowidthspace'] = 0x200B;
  18529. t['zeta'] = 0x03B6;
  18530. t['zhbopomofo'] = 0x3113;
  18531. t['zhearmenian'] = 0x056A;
  18532. t['zhebrevecyrillic'] = 0x04C2;
  18533. t['zhecyrillic'] = 0x0436;
  18534. t['zhedescendercyrillic'] = 0x0497;
  18535. t['zhedieresiscyrillic'] = 0x04DD;
  18536. t['zihiragana'] = 0x3058;
  18537. t['zikatakana'] = 0x30B8;
  18538. t['zinorhebrew'] = 0x05AE;
  18539. t['zlinebelow'] = 0x1E95;
  18540. t['zmonospace'] = 0xFF5A;
  18541. t['zohiragana'] = 0x305E;
  18542. t['zokatakana'] = 0x30BE;
  18543. t['zparen'] = 0x24B5;
  18544. t['zretroflexhook'] = 0x0290;
  18545. t['zstroke'] = 0x01B6;
  18546. t['zuhiragana'] = 0x305A;
  18547. t['zukatakana'] = 0x30BA;
  18548. t['.notdef'] = 0x0000;
  18549. t['angbracketleftbig'] = 0x2329;
  18550. t['angbracketleftBig'] = 0x2329;
  18551. t['angbracketleftbigg'] = 0x2329;
  18552. t['angbracketleftBigg'] = 0x2329;
  18553. t['angbracketrightBig'] = 0x232A;
  18554. t['angbracketrightbig'] = 0x232A;
  18555. t['angbracketrightBigg'] = 0x232A;
  18556. t['angbracketrightbigg'] = 0x232A;
  18557. t['arrowhookleft'] = 0x21AA;
  18558. t['arrowhookright'] = 0x21A9;
  18559. t['arrowlefttophalf'] = 0x21BC;
  18560. t['arrowleftbothalf'] = 0x21BD;
  18561. t['arrownortheast'] = 0x2197;
  18562. t['arrownorthwest'] = 0x2196;
  18563. t['arrowrighttophalf'] = 0x21C0;
  18564. t['arrowrightbothalf'] = 0x21C1;
  18565. t['arrowsoutheast'] = 0x2198;
  18566. t['arrowsouthwest'] = 0x2199;
  18567. t['backslashbig'] = 0x2216;
  18568. t['backslashBig'] = 0x2216;
  18569. t['backslashBigg'] = 0x2216;
  18570. t['backslashbigg'] = 0x2216;
  18571. t['bardbl'] = 0x2016;
  18572. t['bracehtipdownleft'] = 0xFE37;
  18573. t['bracehtipdownright'] = 0xFE37;
  18574. t['bracehtipupleft'] = 0xFE38;
  18575. t['bracehtipupright'] = 0xFE38;
  18576. t['braceleftBig'] = 0x007B;
  18577. t['braceleftbig'] = 0x007B;
  18578. t['braceleftbigg'] = 0x007B;
  18579. t['braceleftBigg'] = 0x007B;
  18580. t['bracerightBig'] = 0x007D;
  18581. t['bracerightbig'] = 0x007D;
  18582. t['bracerightbigg'] = 0x007D;
  18583. t['bracerightBigg'] = 0x007D;
  18584. t['bracketleftbig'] = 0x005B;
  18585. t['bracketleftBig'] = 0x005B;
  18586. t['bracketleftbigg'] = 0x005B;
  18587. t['bracketleftBigg'] = 0x005B;
  18588. t['bracketrightBig'] = 0x005D;
  18589. t['bracketrightbig'] = 0x005D;
  18590. t['bracketrightbigg'] = 0x005D;
  18591. t['bracketrightBigg'] = 0x005D;
  18592. t['ceilingleftbig'] = 0x2308;
  18593. t['ceilingleftBig'] = 0x2308;
  18594. t['ceilingleftBigg'] = 0x2308;
  18595. t['ceilingleftbigg'] = 0x2308;
  18596. t['ceilingrightbig'] = 0x2309;
  18597. t['ceilingrightBig'] = 0x2309;
  18598. t['ceilingrightbigg'] = 0x2309;
  18599. t['ceilingrightBigg'] = 0x2309;
  18600. t['circledotdisplay'] = 0x2299;
  18601. t['circledottext'] = 0x2299;
  18602. t['circlemultiplydisplay'] = 0x2297;
  18603. t['circlemultiplytext'] = 0x2297;
  18604. t['circleplusdisplay'] = 0x2295;
  18605. t['circleplustext'] = 0x2295;
  18606. t['contintegraldisplay'] = 0x222E;
  18607. t['contintegraltext'] = 0x222E;
  18608. t['coproductdisplay'] = 0x2210;
  18609. t['coproducttext'] = 0x2210;
  18610. t['floorleftBig'] = 0x230A;
  18611. t['floorleftbig'] = 0x230A;
  18612. t['floorleftbigg'] = 0x230A;
  18613. t['floorleftBigg'] = 0x230A;
  18614. t['floorrightbig'] = 0x230B;
  18615. t['floorrightBig'] = 0x230B;
  18616. t['floorrightBigg'] = 0x230B;
  18617. t['floorrightbigg'] = 0x230B;
  18618. t['hatwide'] = 0x0302;
  18619. t['hatwider'] = 0x0302;
  18620. t['hatwidest'] = 0x0302;
  18621. t['intercal'] = 0x1D40;
  18622. t['integraldisplay'] = 0x222B;
  18623. t['integraltext'] = 0x222B;
  18624. t['intersectiondisplay'] = 0x22C2;
  18625. t['intersectiontext'] = 0x22C2;
  18626. t['logicalanddisplay'] = 0x2227;
  18627. t['logicalandtext'] = 0x2227;
  18628. t['logicalordisplay'] = 0x2228;
  18629. t['logicalortext'] = 0x2228;
  18630. t['parenleftBig'] = 0x0028;
  18631. t['parenleftbig'] = 0x0028;
  18632. t['parenleftBigg'] = 0x0028;
  18633. t['parenleftbigg'] = 0x0028;
  18634. t['parenrightBig'] = 0x0029;
  18635. t['parenrightbig'] = 0x0029;
  18636. t['parenrightBigg'] = 0x0029;
  18637. t['parenrightbigg'] = 0x0029;
  18638. t['prime'] = 0x2032;
  18639. t['productdisplay'] = 0x220F;
  18640. t['producttext'] = 0x220F;
  18641. t['radicalbig'] = 0x221A;
  18642. t['radicalBig'] = 0x221A;
  18643. t['radicalBigg'] = 0x221A;
  18644. t['radicalbigg'] = 0x221A;
  18645. t['radicalbt'] = 0x221A;
  18646. t['radicaltp'] = 0x221A;
  18647. t['radicalvertex'] = 0x221A;
  18648. t['slashbig'] = 0x002F;
  18649. t['slashBig'] = 0x002F;
  18650. t['slashBigg'] = 0x002F;
  18651. t['slashbigg'] = 0x002F;
  18652. t['summationdisplay'] = 0x2211;
  18653. t['summationtext'] = 0x2211;
  18654. t['tildewide'] = 0x02DC;
  18655. t['tildewider'] = 0x02DC;
  18656. t['tildewidest'] = 0x02DC;
  18657. t['uniondisplay'] = 0x22C3;
  18658. t['unionmultidisplay'] = 0x228E;
  18659. t['unionmultitext'] = 0x228E;
  18660. t['unionsqdisplay'] = 0x2294;
  18661. t['unionsqtext'] = 0x2294;
  18662. t['uniontext'] = 0x22C3;
  18663. t['vextenddouble'] = 0x2225;
  18664. t['vextendsingle'] = 0x2223;
  18665. });
  18666. var getDingbatsGlyphsUnicode = getLookupTableFactory(function (t) {
  18667. t['space'] = 0x0020;
  18668. t['a1'] = 0x2701;
  18669. t['a2'] = 0x2702;
  18670. t['a202'] = 0x2703;
  18671. t['a3'] = 0x2704;
  18672. t['a4'] = 0x260E;
  18673. t['a5'] = 0x2706;
  18674. t['a119'] = 0x2707;
  18675. t['a118'] = 0x2708;
  18676. t['a117'] = 0x2709;
  18677. t['a11'] = 0x261B;
  18678. t['a12'] = 0x261E;
  18679. t['a13'] = 0x270C;
  18680. t['a14'] = 0x270D;
  18681. t['a15'] = 0x270E;
  18682. t['a16'] = 0x270F;
  18683. t['a105'] = 0x2710;
  18684. t['a17'] = 0x2711;
  18685. t['a18'] = 0x2712;
  18686. t['a19'] = 0x2713;
  18687. t['a20'] = 0x2714;
  18688. t['a21'] = 0x2715;
  18689. t['a22'] = 0x2716;
  18690. t['a23'] = 0x2717;
  18691. t['a24'] = 0x2718;
  18692. t['a25'] = 0x2719;
  18693. t['a26'] = 0x271A;
  18694. t['a27'] = 0x271B;
  18695. t['a28'] = 0x271C;
  18696. t['a6'] = 0x271D;
  18697. t['a7'] = 0x271E;
  18698. t['a8'] = 0x271F;
  18699. t['a9'] = 0x2720;
  18700. t['a10'] = 0x2721;
  18701. t['a29'] = 0x2722;
  18702. t['a30'] = 0x2723;
  18703. t['a31'] = 0x2724;
  18704. t['a32'] = 0x2725;
  18705. t['a33'] = 0x2726;
  18706. t['a34'] = 0x2727;
  18707. t['a35'] = 0x2605;
  18708. t['a36'] = 0x2729;
  18709. t['a37'] = 0x272A;
  18710. t['a38'] = 0x272B;
  18711. t['a39'] = 0x272C;
  18712. t['a40'] = 0x272D;
  18713. t['a41'] = 0x272E;
  18714. t['a42'] = 0x272F;
  18715. t['a43'] = 0x2730;
  18716. t['a44'] = 0x2731;
  18717. t['a45'] = 0x2732;
  18718. t['a46'] = 0x2733;
  18719. t['a47'] = 0x2734;
  18720. t['a48'] = 0x2735;
  18721. t['a49'] = 0x2736;
  18722. t['a50'] = 0x2737;
  18723. t['a51'] = 0x2738;
  18724. t['a52'] = 0x2739;
  18725. t['a53'] = 0x273A;
  18726. t['a54'] = 0x273B;
  18727. t['a55'] = 0x273C;
  18728. t['a56'] = 0x273D;
  18729. t['a57'] = 0x273E;
  18730. t['a58'] = 0x273F;
  18731. t['a59'] = 0x2740;
  18732. t['a60'] = 0x2741;
  18733. t['a61'] = 0x2742;
  18734. t['a62'] = 0x2743;
  18735. t['a63'] = 0x2744;
  18736. t['a64'] = 0x2745;
  18737. t['a65'] = 0x2746;
  18738. t['a66'] = 0x2747;
  18739. t['a67'] = 0x2748;
  18740. t['a68'] = 0x2749;
  18741. t['a69'] = 0x274A;
  18742. t['a70'] = 0x274B;
  18743. t['a71'] = 0x25CF;
  18744. t['a72'] = 0x274D;
  18745. t['a73'] = 0x25A0;
  18746. t['a74'] = 0x274F;
  18747. t['a203'] = 0x2750;
  18748. t['a75'] = 0x2751;
  18749. t['a204'] = 0x2752;
  18750. t['a76'] = 0x25B2;
  18751. t['a77'] = 0x25BC;
  18752. t['a78'] = 0x25C6;
  18753. t['a79'] = 0x2756;
  18754. t['a81'] = 0x25D7;
  18755. t['a82'] = 0x2758;
  18756. t['a83'] = 0x2759;
  18757. t['a84'] = 0x275A;
  18758. t['a97'] = 0x275B;
  18759. t['a98'] = 0x275C;
  18760. t['a99'] = 0x275D;
  18761. t['a100'] = 0x275E;
  18762. t['a101'] = 0x2761;
  18763. t['a102'] = 0x2762;
  18764. t['a103'] = 0x2763;
  18765. t['a104'] = 0x2764;
  18766. t['a106'] = 0x2765;
  18767. t['a107'] = 0x2766;
  18768. t['a108'] = 0x2767;
  18769. t['a112'] = 0x2663;
  18770. t['a111'] = 0x2666;
  18771. t['a110'] = 0x2665;
  18772. t['a109'] = 0x2660;
  18773. t['a120'] = 0x2460;
  18774. t['a121'] = 0x2461;
  18775. t['a122'] = 0x2462;
  18776. t['a123'] = 0x2463;
  18777. t['a124'] = 0x2464;
  18778. t['a125'] = 0x2465;
  18779. t['a126'] = 0x2466;
  18780. t['a127'] = 0x2467;
  18781. t['a128'] = 0x2468;
  18782. t['a129'] = 0x2469;
  18783. t['a130'] = 0x2776;
  18784. t['a131'] = 0x2777;
  18785. t['a132'] = 0x2778;
  18786. t['a133'] = 0x2779;
  18787. t['a134'] = 0x277A;
  18788. t['a135'] = 0x277B;
  18789. t['a136'] = 0x277C;
  18790. t['a137'] = 0x277D;
  18791. t['a138'] = 0x277E;
  18792. t['a139'] = 0x277F;
  18793. t['a140'] = 0x2780;
  18794. t['a141'] = 0x2781;
  18795. t['a142'] = 0x2782;
  18796. t['a143'] = 0x2783;
  18797. t['a144'] = 0x2784;
  18798. t['a145'] = 0x2785;
  18799. t['a146'] = 0x2786;
  18800. t['a147'] = 0x2787;
  18801. t['a148'] = 0x2788;
  18802. t['a149'] = 0x2789;
  18803. t['a150'] = 0x278A;
  18804. t['a151'] = 0x278B;
  18805. t['a152'] = 0x278C;
  18806. t['a153'] = 0x278D;
  18807. t['a154'] = 0x278E;
  18808. t['a155'] = 0x278F;
  18809. t['a156'] = 0x2790;
  18810. t['a157'] = 0x2791;
  18811. t['a158'] = 0x2792;
  18812. t['a159'] = 0x2793;
  18813. t['a160'] = 0x2794;
  18814. t['a161'] = 0x2192;
  18815. t['a163'] = 0x2194;
  18816. t['a164'] = 0x2195;
  18817. t['a196'] = 0x2798;
  18818. t['a165'] = 0x2799;
  18819. t['a192'] = 0x279A;
  18820. t['a166'] = 0x279B;
  18821. t['a167'] = 0x279C;
  18822. t['a168'] = 0x279D;
  18823. t['a169'] = 0x279E;
  18824. t['a170'] = 0x279F;
  18825. t['a171'] = 0x27A0;
  18826. t['a172'] = 0x27A1;
  18827. t['a173'] = 0x27A2;
  18828. t['a162'] = 0x27A3;
  18829. t['a174'] = 0x27A4;
  18830. t['a175'] = 0x27A5;
  18831. t['a176'] = 0x27A6;
  18832. t['a177'] = 0x27A7;
  18833. t['a178'] = 0x27A8;
  18834. t['a179'] = 0x27A9;
  18835. t['a193'] = 0x27AA;
  18836. t['a180'] = 0x27AB;
  18837. t['a199'] = 0x27AC;
  18838. t['a181'] = 0x27AD;
  18839. t['a200'] = 0x27AE;
  18840. t['a182'] = 0x27AF;
  18841. t['a201'] = 0x27B1;
  18842. t['a183'] = 0x27B2;
  18843. t['a184'] = 0x27B3;
  18844. t['a197'] = 0x27B4;
  18845. t['a185'] = 0x27B5;
  18846. t['a194'] = 0x27B6;
  18847. t['a198'] = 0x27B7;
  18848. t['a186'] = 0x27B8;
  18849. t['a195'] = 0x27B9;
  18850. t['a187'] = 0x27BA;
  18851. t['a188'] = 0x27BB;
  18852. t['a189'] = 0x27BC;
  18853. t['a190'] = 0x27BD;
  18854. t['a191'] = 0x27BE;
  18855. t['a89'] = 0x2768;
  18856. t['a90'] = 0x2769;
  18857. t['a93'] = 0x276A;
  18858. t['a94'] = 0x276B;
  18859. t['a91'] = 0x276C;
  18860. t['a92'] = 0x276D;
  18861. t['a205'] = 0x276E;
  18862. t['a85'] = 0x276F;
  18863. t['a206'] = 0x2770;
  18864. t['a86'] = 0x2771;
  18865. t['a87'] = 0x2772;
  18866. t['a88'] = 0x2773;
  18867. t['a95'] = 0x2774;
  18868. t['a96'] = 0x2775;
  18869. t['.notdef'] = 0x0000;
  18870. });
  18871. exports.getGlyphsUnicode = getGlyphsUnicode;
  18872. exports.getDingbatsGlyphsUnicode = getDingbatsGlyphsUnicode;
  18873. /***/ }),
  18874. /* 9 */
  18875. /***/ (function(module, exports, __w_pdfjs_require__) {
  18876. "use strict";
  18877. var sharedUtil = __w_pdfjs_require__(0);
  18878. var displayDOMUtils = __w_pdfjs_require__(3);
  18879. var AnnotationBorderStyleType = sharedUtil.AnnotationBorderStyleType;
  18880. var AnnotationType = sharedUtil.AnnotationType;
  18881. var stringToPDFString = sharedUtil.stringToPDFString;
  18882. var Util = sharedUtil.Util;
  18883. var addLinkAttributes = displayDOMUtils.addLinkAttributes;
  18884. var LinkTarget = displayDOMUtils.LinkTarget;
  18885. var getFilenameFromUrl = displayDOMUtils.getFilenameFromUrl;
  18886. var warn = sharedUtil.warn;
  18887. var CustomStyle = displayDOMUtils.CustomStyle;
  18888. var getDefaultSetting = displayDOMUtils.getDefaultSetting;
  18889. function AnnotationElementFactory() {
  18890. }
  18891. AnnotationElementFactory.prototype = {
  18892. create: function AnnotationElementFactory_create(parameters) {
  18893. var subtype = parameters.data.annotationType;
  18894. switch (subtype) {
  18895. case AnnotationType.LINK:
  18896. return new LinkAnnotationElement(parameters);
  18897. case AnnotationType.TEXT:
  18898. return new TextAnnotationElement(parameters);
  18899. case AnnotationType.WIDGET:
  18900. var fieldType = parameters.data.fieldType;
  18901. switch (fieldType) {
  18902. case 'Tx':
  18903. return new TextWidgetAnnotationElement(parameters);
  18904. case 'Btn':
  18905. if (parameters.data.radioButton) {
  18906. return new RadioButtonWidgetAnnotationElement(parameters);
  18907. } else if (parameters.data.checkBox) {
  18908. return new CheckboxWidgetAnnotationElement(parameters);
  18909. }
  18910. warn('Unimplemented button widget annotation: pushbutton');
  18911. break;
  18912. case 'Ch':
  18913. return new ChoiceWidgetAnnotationElement(parameters);
  18914. }
  18915. return new WidgetAnnotationElement(parameters);
  18916. case AnnotationType.POPUP:
  18917. return new PopupAnnotationElement(parameters);
  18918. case AnnotationType.HIGHLIGHT:
  18919. return new HighlightAnnotationElement(parameters);
  18920. case AnnotationType.UNDERLINE:
  18921. return new UnderlineAnnotationElement(parameters);
  18922. case AnnotationType.SQUIGGLY:
  18923. return new SquigglyAnnotationElement(parameters);
  18924. case AnnotationType.STRIKEOUT:
  18925. return new StrikeOutAnnotationElement(parameters);
  18926. case AnnotationType.FILEATTACHMENT:
  18927. return new FileAttachmentAnnotationElement(parameters);
  18928. default:
  18929. return new AnnotationElement(parameters);
  18930. }
  18931. }
  18932. };
  18933. var AnnotationElement = function AnnotationElementClosure() {
  18934. function AnnotationElement(parameters, isRenderable) {
  18935. this.isRenderable = isRenderable || false;
  18936. this.data = parameters.data;
  18937. this.layer = parameters.layer;
  18938. this.page = parameters.page;
  18939. this.viewport = parameters.viewport;
  18940. this.linkService = parameters.linkService;
  18941. this.downloadManager = parameters.downloadManager;
  18942. this.imageResourcesPath = parameters.imageResourcesPath;
  18943. this.renderInteractiveForms = parameters.renderInteractiveForms;
  18944. if (isRenderable) {
  18945. this.container = this._createContainer();
  18946. }
  18947. }
  18948. AnnotationElement.prototype = {
  18949. _createContainer: function AnnotationElement_createContainer() {
  18950. var data = this.data, page = this.page, viewport = this.viewport;
  18951. var container = document.createElement('section');
  18952. var width = data.rect[2] - data.rect[0];
  18953. var height = data.rect[3] - data.rect[1];
  18954. container.setAttribute('data-annotation-id', data.id);
  18955. var rect = Util.normalizeRect([
  18956. data.rect[0],
  18957. page.view[3] - data.rect[1] + page.view[1],
  18958. data.rect[2],
  18959. page.view[3] - data.rect[3] + page.view[1]
  18960. ]);
  18961. CustomStyle.setProp('transform', container, 'matrix(' + viewport.transform.join(',') + ')');
  18962. CustomStyle.setProp('transformOrigin', container, -rect[0] + 'px ' + -rect[1] + 'px');
  18963. if (data.borderStyle.width > 0) {
  18964. container.style.borderWidth = data.borderStyle.width + 'px';
  18965. if (data.borderStyle.style !== AnnotationBorderStyleType.UNDERLINE) {
  18966. width = width - 2 * data.borderStyle.width;
  18967. height = height - 2 * data.borderStyle.width;
  18968. }
  18969. var horizontalRadius = data.borderStyle.horizontalCornerRadius;
  18970. var verticalRadius = data.borderStyle.verticalCornerRadius;
  18971. if (horizontalRadius > 0 || verticalRadius > 0) {
  18972. var radius = horizontalRadius + 'px / ' + verticalRadius + 'px';
  18973. CustomStyle.setProp('borderRadius', container, radius);
  18974. }
  18975. switch (data.borderStyle.style) {
  18976. case AnnotationBorderStyleType.SOLID:
  18977. container.style.borderStyle = 'solid';
  18978. break;
  18979. case AnnotationBorderStyleType.DASHED:
  18980. container.style.borderStyle = 'dashed';
  18981. break;
  18982. case AnnotationBorderStyleType.BEVELED:
  18983. warn('Unimplemented border style: beveled');
  18984. break;
  18985. case AnnotationBorderStyleType.INSET:
  18986. warn('Unimplemented border style: inset');
  18987. break;
  18988. case AnnotationBorderStyleType.UNDERLINE:
  18989. container.style.borderBottomStyle = 'solid';
  18990. break;
  18991. default:
  18992. break;
  18993. }
  18994. if (data.color) {
  18995. container.style.borderColor = Util.makeCssRgb(data.color[0] | 0, data.color[1] | 0, data.color[2] | 0);
  18996. } else {
  18997. container.style.borderWidth = 0;
  18998. }
  18999. }
  19000. container.style.left = rect[0] + 'px';
  19001. container.style.top = rect[1] + 'px';
  19002. container.style.width = width + 'px';
  19003. container.style.height = height + 'px';
  19004. return container;
  19005. },
  19006. _createPopup: function AnnotationElement_createPopup(container, trigger, data) {
  19007. if (!trigger) {
  19008. trigger = document.createElement('div');
  19009. trigger.style.height = container.style.height;
  19010. trigger.style.width = container.style.width;
  19011. container.appendChild(trigger);
  19012. }
  19013. var popupElement = new PopupElement({
  19014. container: container,
  19015. trigger: trigger,
  19016. color: data.color,
  19017. title: data.title,
  19018. contents: data.contents,
  19019. hideWrapper: true
  19020. });
  19021. var popup = popupElement.render();
  19022. popup.style.left = container.style.width;
  19023. container.appendChild(popup);
  19024. },
  19025. render: function AnnotationElement_render() {
  19026. throw new Error('Abstract method AnnotationElement.render called');
  19027. }
  19028. };
  19029. return AnnotationElement;
  19030. }();
  19031. var LinkAnnotationElement = function LinkAnnotationElementClosure() {
  19032. function LinkAnnotationElement(parameters) {
  19033. AnnotationElement.call(this, parameters, true);
  19034. }
  19035. Util.inherit(LinkAnnotationElement, AnnotationElement, {
  19036. render: function LinkAnnotationElement_render() {
  19037. this.container.className = 'linkAnnotation';
  19038. var link = document.createElement('a');
  19039. addLinkAttributes(link, {
  19040. url: this.data.url,
  19041. target: this.data.newWindow ? LinkTarget.BLANK : undefined
  19042. });
  19043. if (!this.data.url) {
  19044. if (this.data.action) {
  19045. this._bindNamedAction(link, this.data.action);
  19046. } else {
  19047. this._bindLink(link, this.data.dest);
  19048. }
  19049. }
  19050. this.container.appendChild(link);
  19051. return this.container;
  19052. },
  19053. _bindLink: function LinkAnnotationElement_bindLink(link, destination) {
  19054. var self = this;
  19055. link.href = this.linkService.getDestinationHash(destination);
  19056. link.onclick = function () {
  19057. if (destination) {
  19058. self.linkService.navigateTo(destination);
  19059. }
  19060. return false;
  19061. };
  19062. if (destination) {
  19063. link.className = 'internalLink';
  19064. }
  19065. },
  19066. _bindNamedAction: function LinkAnnotationElement_bindNamedAction(link, action) {
  19067. var self = this;
  19068. link.href = this.linkService.getAnchorUrl('');
  19069. link.onclick = function () {
  19070. self.linkService.executeNamedAction(action);
  19071. return false;
  19072. };
  19073. link.className = 'internalLink';
  19074. }
  19075. });
  19076. return LinkAnnotationElement;
  19077. }();
  19078. var TextAnnotationElement = function TextAnnotationElementClosure() {
  19079. function TextAnnotationElement(parameters) {
  19080. var isRenderable = !!(parameters.data.hasPopup || parameters.data.title || parameters.data.contents);
  19081. AnnotationElement.call(this, parameters, isRenderable);
  19082. }
  19083. Util.inherit(TextAnnotationElement, AnnotationElement, {
  19084. render: function TextAnnotationElement_render() {
  19085. this.container.className = 'textAnnotation';
  19086. var image = document.createElement('img');
  19087. image.style.height = this.container.style.height;
  19088. image.style.width = this.container.style.width;
  19089. image.src = this.imageResourcesPath + 'annotation-' + this.data.name.toLowerCase() + '.svg';
  19090. image.alt = '[{{type}} Annotation]';
  19091. image.dataset.l10nId = 'text_annotation_type';
  19092. image.dataset.l10nArgs = JSON.stringify({ type: this.data.name });
  19093. if (!this.data.hasPopup) {
  19094. this._createPopup(this.container, image, this.data);
  19095. }
  19096. this.container.appendChild(image);
  19097. return this.container;
  19098. }
  19099. });
  19100. return TextAnnotationElement;
  19101. }();
  19102. var WidgetAnnotationElement = function WidgetAnnotationElementClosure() {
  19103. function WidgetAnnotationElement(parameters, isRenderable) {
  19104. AnnotationElement.call(this, parameters, isRenderable);
  19105. }
  19106. Util.inherit(WidgetAnnotationElement, AnnotationElement, {
  19107. render: function WidgetAnnotationElement_render() {
  19108. return this.container;
  19109. }
  19110. });
  19111. return WidgetAnnotationElement;
  19112. }();
  19113. var TextWidgetAnnotationElement = function TextWidgetAnnotationElementClosure() {
  19114. var TEXT_ALIGNMENT = [
  19115. 'left',
  19116. 'center',
  19117. 'right'
  19118. ];
  19119. function TextWidgetAnnotationElement(parameters) {
  19120. var isRenderable = parameters.renderInteractiveForms || !parameters.data.hasAppearance && !!parameters.data.fieldValue;
  19121. WidgetAnnotationElement.call(this, parameters, isRenderable);
  19122. }
  19123. Util.inherit(TextWidgetAnnotationElement, WidgetAnnotationElement, {
  19124. render: function TextWidgetAnnotationElement_render() {
  19125. this.container.className = 'textWidgetAnnotation';
  19126. var element = null;
  19127. if (this.renderInteractiveForms) {
  19128. if (this.data.multiLine) {
  19129. element = document.createElement('textarea');
  19130. element.textContent = this.data.fieldValue;
  19131. } else {
  19132. element = document.createElement('input');
  19133. element.type = 'text';
  19134. element.setAttribute('value', this.data.fieldValue);
  19135. }
  19136. element.disabled = this.data.readOnly;
  19137. if (this.data.maxLen !== null) {
  19138. element.maxLength = this.data.maxLen;
  19139. }
  19140. if (this.data.comb) {
  19141. var fieldWidth = this.data.rect[2] - this.data.rect[0];
  19142. var combWidth = fieldWidth / this.data.maxLen;
  19143. element.classList.add('comb');
  19144. element.style.letterSpacing = 'calc(' + combWidth + 'px - 1ch)';
  19145. }
  19146. } else {
  19147. element = document.createElement('div');
  19148. element.textContent = this.data.fieldValue;
  19149. element.style.verticalAlign = 'middle';
  19150. element.style.display = 'table-cell';
  19151. var font = null;
  19152. if (this.data.fontRefName) {
  19153. font = this.page.commonObjs.getData(this.data.fontRefName);
  19154. }
  19155. this._setTextStyle(element, font);
  19156. }
  19157. if (this.data.textAlignment !== null) {
  19158. element.style.textAlign = TEXT_ALIGNMENT[this.data.textAlignment];
  19159. }
  19160. this.container.appendChild(element);
  19161. return this.container;
  19162. },
  19163. _setTextStyle: function TextWidgetAnnotationElement_setTextStyle(element, font) {
  19164. var style = element.style;
  19165. style.fontSize = this.data.fontSize + 'px';
  19166. style.direction = this.data.fontDirection < 0 ? 'rtl' : 'ltr';
  19167. if (!font) {
  19168. return;
  19169. }
  19170. style.fontWeight = font.black ? font.bold ? '900' : 'bold' : font.bold ? 'bold' : 'normal';
  19171. style.fontStyle = font.italic ? 'italic' : 'normal';
  19172. var fontFamily = font.loadedName ? '"' + font.loadedName + '", ' : '';
  19173. var fallbackName = font.fallbackName || 'Helvetica, sans-serif';
  19174. style.fontFamily = fontFamily + fallbackName;
  19175. }
  19176. });
  19177. return TextWidgetAnnotationElement;
  19178. }();
  19179. var CheckboxWidgetAnnotationElement = function CheckboxWidgetAnnotationElementClosure() {
  19180. function CheckboxWidgetAnnotationElement(parameters) {
  19181. WidgetAnnotationElement.call(this, parameters, parameters.renderInteractiveForms);
  19182. }
  19183. Util.inherit(CheckboxWidgetAnnotationElement, WidgetAnnotationElement, {
  19184. render: function CheckboxWidgetAnnotationElement_render() {
  19185. this.container.className = 'buttonWidgetAnnotation checkBox';
  19186. var element = document.createElement('input');
  19187. element.disabled = this.data.readOnly;
  19188. element.type = 'checkbox';
  19189. if (this.data.fieldValue && this.data.fieldValue !== 'Off') {
  19190. element.setAttribute('checked', true);
  19191. }
  19192. this.container.appendChild(element);
  19193. return this.container;
  19194. }
  19195. });
  19196. return CheckboxWidgetAnnotationElement;
  19197. }();
  19198. var RadioButtonWidgetAnnotationElement = function RadioButtonWidgetAnnotationElementClosure() {
  19199. function RadioButtonWidgetAnnotationElement(parameters) {
  19200. WidgetAnnotationElement.call(this, parameters, parameters.renderInteractiveForms);
  19201. }
  19202. Util.inherit(RadioButtonWidgetAnnotationElement, WidgetAnnotationElement, {
  19203. render: function RadioButtonWidgetAnnotationElement_render() {
  19204. this.container.className = 'buttonWidgetAnnotation radioButton';
  19205. var element = document.createElement('input');
  19206. element.disabled = this.data.readOnly;
  19207. element.type = 'radio';
  19208. element.name = this.data.fieldName;
  19209. if (this.data.fieldValue === this.data.buttonValue) {
  19210. element.setAttribute('checked', true);
  19211. }
  19212. this.container.appendChild(element);
  19213. return this.container;
  19214. }
  19215. });
  19216. return RadioButtonWidgetAnnotationElement;
  19217. }();
  19218. var ChoiceWidgetAnnotationElement = function ChoiceWidgetAnnotationElementClosure() {
  19219. function ChoiceWidgetAnnotationElement(parameters) {
  19220. WidgetAnnotationElement.call(this, parameters, parameters.renderInteractiveForms);
  19221. }
  19222. Util.inherit(ChoiceWidgetAnnotationElement, WidgetAnnotationElement, {
  19223. render: function ChoiceWidgetAnnotationElement_render() {
  19224. this.container.className = 'choiceWidgetAnnotation';
  19225. var selectElement = document.createElement('select');
  19226. selectElement.disabled = this.data.readOnly;
  19227. if (!this.data.combo) {
  19228. selectElement.size = this.data.options.length;
  19229. if (this.data.multiSelect) {
  19230. selectElement.multiple = true;
  19231. }
  19232. }
  19233. for (var i = 0, ii = this.data.options.length; i < ii; i++) {
  19234. var option = this.data.options[i];
  19235. var optionElement = document.createElement('option');
  19236. optionElement.textContent = option.displayValue;
  19237. optionElement.value = option.exportValue;
  19238. if (this.data.fieldValue.indexOf(option.displayValue) >= 0) {
  19239. optionElement.setAttribute('selected', true);
  19240. }
  19241. selectElement.appendChild(optionElement);
  19242. }
  19243. this.container.appendChild(selectElement);
  19244. return this.container;
  19245. }
  19246. });
  19247. return ChoiceWidgetAnnotationElement;
  19248. }();
  19249. var PopupAnnotationElement = function PopupAnnotationElementClosure() {
  19250. function PopupAnnotationElement(parameters) {
  19251. var isRenderable = !!(parameters.data.title || parameters.data.contents);
  19252. AnnotationElement.call(this, parameters, isRenderable);
  19253. }
  19254. Util.inherit(PopupAnnotationElement, AnnotationElement, {
  19255. render: function PopupAnnotationElement_render() {
  19256. this.container.className = 'popupAnnotation';
  19257. var selector = '[data-annotation-id="' + this.data.parentId + '"]';
  19258. var parentElement = this.layer.querySelector(selector);
  19259. if (!parentElement) {
  19260. return this.container;
  19261. }
  19262. var popup = new PopupElement({
  19263. container: this.container,
  19264. trigger: parentElement,
  19265. color: this.data.color,
  19266. title: this.data.title,
  19267. contents: this.data.contents
  19268. });
  19269. var parentLeft = parseFloat(parentElement.style.left);
  19270. var parentWidth = parseFloat(parentElement.style.width);
  19271. CustomStyle.setProp('transformOrigin', this.container, -(parentLeft + parentWidth) + 'px -' + parentElement.style.top);
  19272. this.container.style.left = parentLeft + parentWidth + 'px';
  19273. this.container.appendChild(popup.render());
  19274. return this.container;
  19275. }
  19276. });
  19277. return PopupAnnotationElement;
  19278. }();
  19279. var PopupElement = function PopupElementClosure() {
  19280. var BACKGROUND_ENLIGHT = 0.7;
  19281. function PopupElement(parameters) {
  19282. this.container = parameters.container;
  19283. this.trigger = parameters.trigger;
  19284. this.color = parameters.color;
  19285. this.title = parameters.title;
  19286. this.contents = parameters.contents;
  19287. this.hideWrapper = parameters.hideWrapper || false;
  19288. this.pinned = false;
  19289. }
  19290. PopupElement.prototype = {
  19291. render: function PopupElement_render() {
  19292. var wrapper = document.createElement('div');
  19293. wrapper.className = 'popupWrapper';
  19294. this.hideElement = this.hideWrapper ? wrapper : this.container;
  19295. this.hideElement.setAttribute('hidden', true);
  19296. var popup = document.createElement('div');
  19297. popup.className = 'popup';
  19298. var color = this.color;
  19299. if (color) {
  19300. var r = BACKGROUND_ENLIGHT * (255 - color[0]) + color[0];
  19301. var g = BACKGROUND_ENLIGHT * (255 - color[1]) + color[1];
  19302. var b = BACKGROUND_ENLIGHT * (255 - color[2]) + color[2];
  19303. popup.style.backgroundColor = Util.makeCssRgb(r | 0, g | 0, b | 0);
  19304. }
  19305. var contents = this._formatContents(this.contents);
  19306. var title = document.createElement('h1');
  19307. title.textContent = this.title;
  19308. this.trigger.addEventListener('click', this._toggle.bind(this));
  19309. this.trigger.addEventListener('mouseover', this._show.bind(this, false));
  19310. this.trigger.addEventListener('mouseout', this._hide.bind(this, false));
  19311. popup.addEventListener('click', this._hide.bind(this, true));
  19312. popup.appendChild(title);
  19313. popup.appendChild(contents);
  19314. wrapper.appendChild(popup);
  19315. return wrapper;
  19316. },
  19317. _formatContents: function PopupElement_formatContents(contents) {
  19318. var p = document.createElement('p');
  19319. var lines = contents.split(/(?:\r\n?|\n)/);
  19320. for (var i = 0, ii = lines.length; i < ii; ++i) {
  19321. var line = lines[i];
  19322. p.appendChild(document.createTextNode(line));
  19323. if (i < ii - 1) {
  19324. p.appendChild(document.createElement('br'));
  19325. }
  19326. }
  19327. return p;
  19328. },
  19329. _toggle: function PopupElement_toggle() {
  19330. if (this.pinned) {
  19331. this._hide(true);
  19332. } else {
  19333. this._show(true);
  19334. }
  19335. },
  19336. _show: function PopupElement_show(pin) {
  19337. if (pin) {
  19338. this.pinned = true;
  19339. }
  19340. if (this.hideElement.hasAttribute('hidden')) {
  19341. this.hideElement.removeAttribute('hidden');
  19342. this.container.style.zIndex += 1;
  19343. }
  19344. },
  19345. _hide: function PopupElement_hide(unpin) {
  19346. if (unpin) {
  19347. this.pinned = false;
  19348. }
  19349. if (!this.hideElement.hasAttribute('hidden') && !this.pinned) {
  19350. this.hideElement.setAttribute('hidden', true);
  19351. this.container.style.zIndex -= 1;
  19352. }
  19353. }
  19354. };
  19355. return PopupElement;
  19356. }();
  19357. var HighlightAnnotationElement = function HighlightAnnotationElementClosure() {
  19358. function HighlightAnnotationElement(parameters) {
  19359. var isRenderable = !!(parameters.data.hasPopup || parameters.data.title || parameters.data.contents);
  19360. AnnotationElement.call(this, parameters, isRenderable);
  19361. }
  19362. Util.inherit(HighlightAnnotationElement, AnnotationElement, {
  19363. render: function HighlightAnnotationElement_render() {
  19364. this.container.className = 'highlightAnnotation';
  19365. if (!this.data.hasPopup) {
  19366. this._createPopup(this.container, null, this.data);
  19367. }
  19368. return this.container;
  19369. }
  19370. });
  19371. return HighlightAnnotationElement;
  19372. }();
  19373. var UnderlineAnnotationElement = function UnderlineAnnotationElementClosure() {
  19374. function UnderlineAnnotationElement(parameters) {
  19375. var isRenderable = !!(parameters.data.hasPopup || parameters.data.title || parameters.data.contents);
  19376. AnnotationElement.call(this, parameters, isRenderable);
  19377. }
  19378. Util.inherit(UnderlineAnnotationElement, AnnotationElement, {
  19379. render: function UnderlineAnnotationElement_render() {
  19380. this.container.className = 'underlineAnnotation';
  19381. if (!this.data.hasPopup) {
  19382. this._createPopup(this.container, null, this.data);
  19383. }
  19384. return this.container;
  19385. }
  19386. });
  19387. return UnderlineAnnotationElement;
  19388. }();
  19389. var SquigglyAnnotationElement = function SquigglyAnnotationElementClosure() {
  19390. function SquigglyAnnotationElement(parameters) {
  19391. var isRenderable = !!(parameters.data.hasPopup || parameters.data.title || parameters.data.contents);
  19392. AnnotationElement.call(this, parameters, isRenderable);
  19393. }
  19394. Util.inherit(SquigglyAnnotationElement, AnnotationElement, {
  19395. render: function SquigglyAnnotationElement_render() {
  19396. this.container.className = 'squigglyAnnotation';
  19397. if (!this.data.hasPopup) {
  19398. this._createPopup(this.container, null, this.data);
  19399. }
  19400. return this.container;
  19401. }
  19402. });
  19403. return SquigglyAnnotationElement;
  19404. }();
  19405. var StrikeOutAnnotationElement = function StrikeOutAnnotationElementClosure() {
  19406. function StrikeOutAnnotationElement(parameters) {
  19407. var isRenderable = !!(parameters.data.hasPopup || parameters.data.title || parameters.data.contents);
  19408. AnnotationElement.call(this, parameters, isRenderable);
  19409. }
  19410. Util.inherit(StrikeOutAnnotationElement, AnnotationElement, {
  19411. render: function StrikeOutAnnotationElement_render() {
  19412. this.container.className = 'strikeoutAnnotation';
  19413. if (!this.data.hasPopup) {
  19414. this._createPopup(this.container, null, this.data);
  19415. }
  19416. return this.container;
  19417. }
  19418. });
  19419. return StrikeOutAnnotationElement;
  19420. }();
  19421. var FileAttachmentAnnotationElement = function FileAttachmentAnnotationElementClosure() {
  19422. function FileAttachmentAnnotationElement(parameters) {
  19423. AnnotationElement.call(this, parameters, true);
  19424. var file = this.data.file;
  19425. this.filename = getFilenameFromUrl(file.filename);
  19426. this.content = file.content;
  19427. this.linkService.onFileAttachmentAnnotation({
  19428. id: stringToPDFString(file.filename),
  19429. filename: file.filename,
  19430. content: file.content
  19431. });
  19432. }
  19433. Util.inherit(FileAttachmentAnnotationElement, AnnotationElement, {
  19434. render: function FileAttachmentAnnotationElement_render() {
  19435. this.container.className = 'fileAttachmentAnnotation';
  19436. var trigger = document.createElement('div');
  19437. trigger.style.height = this.container.style.height;
  19438. trigger.style.width = this.container.style.width;
  19439. trigger.addEventListener('dblclick', this._download.bind(this));
  19440. if (!this.data.hasPopup && (this.data.title || this.data.contents)) {
  19441. this._createPopup(this.container, trigger, this.data);
  19442. }
  19443. this.container.appendChild(trigger);
  19444. return this.container;
  19445. },
  19446. _download: function FileAttachmentAnnotationElement_download() {
  19447. if (!this.downloadManager) {
  19448. warn('Download cannot be started due to unavailable download manager');
  19449. return;
  19450. }
  19451. this.downloadManager.downloadData(this.content, this.filename, '');
  19452. }
  19453. });
  19454. return FileAttachmentAnnotationElement;
  19455. }();
  19456. var AnnotationLayer = function AnnotationLayerClosure() {
  19457. return {
  19458. render: function AnnotationLayer_render(parameters) {
  19459. var annotationElementFactory = new AnnotationElementFactory();
  19460. for (var i = 0, ii = parameters.annotations.length; i < ii; i++) {
  19461. var data = parameters.annotations[i];
  19462. if (!data) {
  19463. continue;
  19464. }
  19465. var element = annotationElementFactory.create({
  19466. data: data,
  19467. layer: parameters.div,
  19468. page: parameters.page,
  19469. viewport: parameters.viewport,
  19470. linkService: parameters.linkService,
  19471. downloadManager: parameters.downloadManager,
  19472. imageResourcesPath: parameters.imageResourcesPath || getDefaultSetting('imageResourcesPath'),
  19473. renderInteractiveForms: parameters.renderInteractiveForms || false
  19474. });
  19475. if (element.isRenderable) {
  19476. parameters.div.appendChild(element.render());
  19477. }
  19478. }
  19479. },
  19480. update: function AnnotationLayer_update(parameters) {
  19481. for (var i = 0, ii = parameters.annotations.length; i < ii; i++) {
  19482. var data = parameters.annotations[i];
  19483. var element = parameters.div.querySelector('[data-annotation-id="' + data.id + '"]');
  19484. if (element) {
  19485. CustomStyle.setProp('transform', element, 'matrix(' + parameters.viewport.transform.join(',') + ')');
  19486. }
  19487. }
  19488. parameters.div.removeAttribute('hidden');
  19489. }
  19490. };
  19491. }();
  19492. exports.AnnotationLayer = AnnotationLayer;
  19493. /***/ }),
  19494. /* 10 */
  19495. /***/ (function(module, exports, __w_pdfjs_require__) {
  19496. "use strict";
  19497. var sharedUtil = __w_pdfjs_require__(0);
  19498. var displayFontLoader = __w_pdfjs_require__(45);
  19499. var displayCanvas = __w_pdfjs_require__(44);
  19500. var displayMetadata = __w_pdfjs_require__(23);
  19501. var displayDOMUtils = __w_pdfjs_require__(3);
  19502. var amdRequire;
  19503. var InvalidPDFException = sharedUtil.InvalidPDFException;
  19504. var MessageHandler = sharedUtil.MessageHandler;
  19505. var MissingPDFException = sharedUtil.MissingPDFException;
  19506. var PageViewport = sharedUtil.PageViewport;
  19507. var PasswordException = sharedUtil.PasswordException;
  19508. var StatTimer = sharedUtil.StatTimer;
  19509. var UnexpectedResponseException = sharedUtil.UnexpectedResponseException;
  19510. var UnknownErrorException = sharedUtil.UnknownErrorException;
  19511. var Util = sharedUtil.Util;
  19512. var createPromiseCapability = sharedUtil.createPromiseCapability;
  19513. var error = sharedUtil.error;
  19514. var deprecated = sharedUtil.deprecated;
  19515. var getVerbosityLevel = sharedUtil.getVerbosityLevel;
  19516. var info = sharedUtil.info;
  19517. var isInt = sharedUtil.isInt;
  19518. var isArray = sharedUtil.isArray;
  19519. var isArrayBuffer = sharedUtil.isArrayBuffer;
  19520. var isSameOrigin = sharedUtil.isSameOrigin;
  19521. var loadJpegStream = sharedUtil.loadJpegStream;
  19522. var stringToBytes = sharedUtil.stringToBytes;
  19523. var globalScope = sharedUtil.globalScope;
  19524. var warn = sharedUtil.warn;
  19525. var FontFaceObject = displayFontLoader.FontFaceObject;
  19526. var FontLoader = displayFontLoader.FontLoader;
  19527. var CanvasGraphics = displayCanvas.CanvasGraphics;
  19528. var Metadata = displayMetadata.Metadata;
  19529. var getDefaultSetting = displayDOMUtils.getDefaultSetting;
  19530. var DOMCanvasFactory = displayDOMUtils.DOMCanvasFactory;
  19531. var DEFAULT_RANGE_CHUNK_SIZE = 65536;
  19532. var isWorkerDisabled = false;
  19533. var workerSrc;
  19534. var isPostMessageTransfersDisabled = false;
  19535. var pdfjsFilePath = typeof document !== 'undefined' && document.currentScript ? document.currentScript.src : null;
  19536. var fakeWorkerFilesLoader = null;
  19537. var useRequireEnsure = false;
  19538. function getDocument(src, pdfDataRangeTransport, passwordCallback, progressCallback) {
  19539. var task = new PDFDocumentLoadingTask();
  19540. if (arguments.length > 1) {
  19541. deprecated('getDocument is called with pdfDataRangeTransport, ' + 'passwordCallback or progressCallback argument');
  19542. }
  19543. if (pdfDataRangeTransport) {
  19544. if (!(pdfDataRangeTransport instanceof PDFDataRangeTransport)) {
  19545. pdfDataRangeTransport = Object.create(pdfDataRangeTransport);
  19546. pdfDataRangeTransport.length = src.length;
  19547. pdfDataRangeTransport.initialData = src.initialData;
  19548. if (!pdfDataRangeTransport.abort) {
  19549. pdfDataRangeTransport.abort = function () {
  19550. };
  19551. }
  19552. }
  19553. src = Object.create(src);
  19554. src.range = pdfDataRangeTransport;
  19555. }
  19556. task.onPassword = passwordCallback || null;
  19557. task.onProgress = progressCallback || null;
  19558. var source;
  19559. if (typeof src === 'string') {
  19560. source = { url: src };
  19561. } else if (isArrayBuffer(src)) {
  19562. source = { data: src };
  19563. } else if (src instanceof PDFDataRangeTransport) {
  19564. source = { range: src };
  19565. } else {
  19566. if (typeof src !== 'object') {
  19567. error('Invalid parameter in getDocument, need either Uint8Array, ' + 'string or a parameter object');
  19568. }
  19569. if (!src.url && !src.data && !src.range) {
  19570. error('Invalid parameter object: need either .data, .range or .url');
  19571. }
  19572. source = src;
  19573. }
  19574. var params = {};
  19575. var rangeTransport = null;
  19576. var worker = null;
  19577. for (var key in source) {
  19578. if (key === 'url' && typeof window !== 'undefined') {
  19579. params[key] = new URL(source[key], window.location).href;
  19580. continue;
  19581. } else if (key === 'range') {
  19582. rangeTransport = source[key];
  19583. continue;
  19584. } else if (key === 'worker') {
  19585. worker = source[key];
  19586. continue;
  19587. } else if (key === 'data' && !(source[key] instanceof Uint8Array)) {
  19588. var pdfBytes = source[key];
  19589. if (typeof pdfBytes === 'string') {
  19590. params[key] = stringToBytes(pdfBytes);
  19591. } else if (typeof pdfBytes === 'object' && pdfBytes !== null && !isNaN(pdfBytes.length)) {
  19592. params[key] = new Uint8Array(pdfBytes);
  19593. } else if (isArrayBuffer(pdfBytes)) {
  19594. params[key] = new Uint8Array(pdfBytes);
  19595. } else {
  19596. error('Invalid PDF binary data: either typed array, string or ' + 'array-like object is expected in the data property.');
  19597. }
  19598. continue;
  19599. }
  19600. params[key] = source[key];
  19601. }
  19602. params.rangeChunkSize = params.rangeChunkSize || DEFAULT_RANGE_CHUNK_SIZE;
  19603. params.disableNativeImageDecoder = params.disableNativeImageDecoder === true;
  19604. if (!worker) {
  19605. worker = new PDFWorker();
  19606. task._worker = worker;
  19607. }
  19608. var docId = task.docId;
  19609. worker.promise.then(function () {
  19610. if (task.destroyed) {
  19611. throw new Error('Loading aborted');
  19612. }
  19613. return _fetchDocument(worker, params, rangeTransport, docId).then(function (workerId) {
  19614. if (task.destroyed) {
  19615. throw new Error('Loading aborted');
  19616. }
  19617. var messageHandler = new MessageHandler(docId, workerId, worker.port);
  19618. var transport = new WorkerTransport(messageHandler, task, rangeTransport);
  19619. task._transport = transport;
  19620. messageHandler.send('Ready', null);
  19621. });
  19622. }).catch(task._capability.reject);
  19623. return task;
  19624. }
  19625. function _fetchDocument(worker, source, pdfDataRangeTransport, docId) {
  19626. if (worker.destroyed) {
  19627. return Promise.reject(new Error('Worker was destroyed'));
  19628. }
  19629. source.disableAutoFetch = getDefaultSetting('disableAutoFetch');
  19630. source.disableStream = getDefaultSetting('disableStream');
  19631. source.chunkedViewerLoading = !!pdfDataRangeTransport;
  19632. if (pdfDataRangeTransport) {
  19633. source.length = pdfDataRangeTransport.length;
  19634. source.initialData = pdfDataRangeTransport.initialData;
  19635. }
  19636. return worker.messageHandler.sendWithPromise('GetDocRequest', {
  19637. docId: docId,
  19638. source: source,
  19639. disableRange: getDefaultSetting('disableRange'),
  19640. maxImageSize: getDefaultSetting('maxImageSize'),
  19641. cMapUrl: getDefaultSetting('cMapUrl'),
  19642. cMapPacked: getDefaultSetting('cMapPacked'),
  19643. disableFontFace: getDefaultSetting('disableFontFace'),
  19644. disableCreateObjectURL: getDefaultSetting('disableCreateObjectURL'),
  19645. postMessageTransfers: getDefaultSetting('postMessageTransfers') && !isPostMessageTransfersDisabled,
  19646. docBaseUrl: source.docBaseUrl,
  19647. disableNativeImageDecoder: source.disableNativeImageDecoder
  19648. }).then(function (workerId) {
  19649. if (worker.destroyed) {
  19650. throw new Error('Worker was destroyed');
  19651. }
  19652. return workerId;
  19653. });
  19654. }
  19655. var PDFDocumentLoadingTask = function PDFDocumentLoadingTaskClosure() {
  19656. var nextDocumentId = 0;
  19657. function PDFDocumentLoadingTask() {
  19658. this._capability = createPromiseCapability();
  19659. this._transport = null;
  19660. this._worker = null;
  19661. this.docId = 'd' + nextDocumentId++;
  19662. this.destroyed = false;
  19663. this.onPassword = null;
  19664. this.onProgress = null;
  19665. this.onUnsupportedFeature = null;
  19666. }
  19667. PDFDocumentLoadingTask.prototype = {
  19668. get promise() {
  19669. return this._capability.promise;
  19670. },
  19671. destroy: function () {
  19672. this.destroyed = true;
  19673. var transportDestroyed = !this._transport ? Promise.resolve() : this._transport.destroy();
  19674. return transportDestroyed.then(function () {
  19675. this._transport = null;
  19676. if (this._worker) {
  19677. this._worker.destroy();
  19678. this._worker = null;
  19679. }
  19680. }.bind(this));
  19681. },
  19682. then: function PDFDocumentLoadingTask_then(onFulfilled, onRejected) {
  19683. return this.promise.then.apply(this.promise, arguments);
  19684. }
  19685. };
  19686. return PDFDocumentLoadingTask;
  19687. }();
  19688. var PDFDataRangeTransport = function pdfDataRangeTransportClosure() {
  19689. function PDFDataRangeTransport(length, initialData) {
  19690. this.length = length;
  19691. this.initialData = initialData;
  19692. this._rangeListeners = [];
  19693. this._progressListeners = [];
  19694. this._progressiveReadListeners = [];
  19695. this._readyCapability = createPromiseCapability();
  19696. }
  19697. PDFDataRangeTransport.prototype = {
  19698. addRangeListener: function PDFDataRangeTransport_addRangeListener(listener) {
  19699. this._rangeListeners.push(listener);
  19700. },
  19701. addProgressListener: function PDFDataRangeTransport_addProgressListener(listener) {
  19702. this._progressListeners.push(listener);
  19703. },
  19704. addProgressiveReadListener: function PDFDataRangeTransport_addProgressiveReadListener(listener) {
  19705. this._progressiveReadListeners.push(listener);
  19706. },
  19707. onDataRange: function PDFDataRangeTransport_onDataRange(begin, chunk) {
  19708. var listeners = this._rangeListeners;
  19709. for (var i = 0, n = listeners.length; i < n; ++i) {
  19710. listeners[i](begin, chunk);
  19711. }
  19712. },
  19713. onDataProgress: function PDFDataRangeTransport_onDataProgress(loaded) {
  19714. this._readyCapability.promise.then(function () {
  19715. var listeners = this._progressListeners;
  19716. for (var i = 0, n = listeners.length; i < n; ++i) {
  19717. listeners[i](loaded);
  19718. }
  19719. }.bind(this));
  19720. },
  19721. onDataProgressiveRead: function PDFDataRangeTransport_onDataProgress(chunk) {
  19722. this._readyCapability.promise.then(function () {
  19723. var listeners = this._progressiveReadListeners;
  19724. for (var i = 0, n = listeners.length; i < n; ++i) {
  19725. listeners[i](chunk);
  19726. }
  19727. }.bind(this));
  19728. },
  19729. transportReady: function PDFDataRangeTransport_transportReady() {
  19730. this._readyCapability.resolve();
  19731. },
  19732. requestDataRange: function PDFDataRangeTransport_requestDataRange(begin, end) {
  19733. throw new Error('Abstract method PDFDataRangeTransport.requestDataRange');
  19734. },
  19735. abort: function PDFDataRangeTransport_abort() {
  19736. }
  19737. };
  19738. return PDFDataRangeTransport;
  19739. }();
  19740. var PDFDocumentProxy = function PDFDocumentProxyClosure() {
  19741. function PDFDocumentProxy(pdfInfo, transport, loadingTask) {
  19742. this.pdfInfo = pdfInfo;
  19743. this.transport = transport;
  19744. this.loadingTask = loadingTask;
  19745. }
  19746. PDFDocumentProxy.prototype = {
  19747. get numPages() {
  19748. return this.pdfInfo.numPages;
  19749. },
  19750. get fingerprint() {
  19751. return this.pdfInfo.fingerprint;
  19752. },
  19753. getPage: function PDFDocumentProxy_getPage(pageNumber) {
  19754. return this.transport.getPage(pageNumber);
  19755. },
  19756. getPageIndex: function PDFDocumentProxy_getPageIndex(ref) {
  19757. return this.transport.getPageIndex(ref);
  19758. },
  19759. getDestinations: function PDFDocumentProxy_getDestinations() {
  19760. return this.transport.getDestinations();
  19761. },
  19762. getDestination: function PDFDocumentProxy_getDestination(id) {
  19763. return this.transport.getDestination(id);
  19764. },
  19765. getPageLabels: function PDFDocumentProxy_getPageLabels() {
  19766. return this.transport.getPageLabels();
  19767. },
  19768. getAttachments: function PDFDocumentProxy_getAttachments() {
  19769. return this.transport.getAttachments();
  19770. },
  19771. getJavaScript: function PDFDocumentProxy_getJavaScript() {
  19772. return this.transport.getJavaScript();
  19773. },
  19774. getOutline: function PDFDocumentProxy_getOutline() {
  19775. return this.transport.getOutline();
  19776. },
  19777. getMetadata: function PDFDocumentProxy_getMetadata() {
  19778. return this.transport.getMetadata();
  19779. },
  19780. getData: function PDFDocumentProxy_getData() {
  19781. return this.transport.getData();
  19782. },
  19783. getDownloadInfo: function PDFDocumentProxy_getDownloadInfo() {
  19784. return this.transport.downloadInfoCapability.promise;
  19785. },
  19786. getStats: function PDFDocumentProxy_getStats() {
  19787. return this.transport.getStats();
  19788. },
  19789. cleanup: function PDFDocumentProxy_cleanup() {
  19790. this.transport.startCleanup();
  19791. },
  19792. destroy: function PDFDocumentProxy_destroy() {
  19793. return this.loadingTask.destroy();
  19794. }
  19795. };
  19796. return PDFDocumentProxy;
  19797. }();
  19798. var PDFPageProxy = function PDFPageProxyClosure() {
  19799. function PDFPageProxy(pageIndex, pageInfo, transport) {
  19800. this.pageIndex = pageIndex;
  19801. this.pageInfo = pageInfo;
  19802. this.transport = transport;
  19803. this.stats = new StatTimer();
  19804. this.stats.enabled = getDefaultSetting('enableStats');
  19805. this.commonObjs = transport.commonObjs;
  19806. this.objs = new PDFObjects();
  19807. this.cleanupAfterRender = false;
  19808. this.pendingCleanup = false;
  19809. this.intentStates = Object.create(null);
  19810. this.destroyed = false;
  19811. }
  19812. PDFPageProxy.prototype = {
  19813. get pageNumber() {
  19814. return this.pageIndex + 1;
  19815. },
  19816. get rotate() {
  19817. return this.pageInfo.rotate;
  19818. },
  19819. get ref() {
  19820. return this.pageInfo.ref;
  19821. },
  19822. get userUnit() {
  19823. return this.pageInfo.userUnit;
  19824. },
  19825. get view() {
  19826. return this.pageInfo.view;
  19827. },
  19828. getViewport: function PDFPageProxy_getViewport(scale, rotate) {
  19829. if (arguments.length < 2) {
  19830. rotate = this.rotate;
  19831. }
  19832. return new PageViewport(this.view, scale, rotate, 0, 0);
  19833. },
  19834. getAnnotations: function PDFPageProxy_getAnnotations(params) {
  19835. var intent = params && params.intent || null;
  19836. if (!this.annotationsPromise || this.annotationsIntent !== intent) {
  19837. this.annotationsPromise = this.transport.getAnnotations(this.pageIndex, intent);
  19838. this.annotationsIntent = intent;
  19839. }
  19840. return this.annotationsPromise;
  19841. },
  19842. render: function PDFPageProxy_render(params) {
  19843. var stats = this.stats;
  19844. stats.time('Overall');
  19845. this.pendingCleanup = false;
  19846. var renderingIntent = params.intent === 'print' ? 'print' : 'display';
  19847. var renderInteractiveForms = params.renderInteractiveForms === true ? true : false;
  19848. var canvasFactory = params.canvasFactory || new DOMCanvasFactory();
  19849. if (!this.intentStates[renderingIntent]) {
  19850. this.intentStates[renderingIntent] = Object.create(null);
  19851. }
  19852. var intentState = this.intentStates[renderingIntent];
  19853. if (!intentState.displayReadyCapability) {
  19854. intentState.receivingOperatorList = true;
  19855. intentState.displayReadyCapability = createPromiseCapability();
  19856. intentState.operatorList = {
  19857. fnArray: [],
  19858. argsArray: [],
  19859. lastChunk: false
  19860. };
  19861. this.stats.time('Page Request');
  19862. this.transport.messageHandler.send('RenderPageRequest', {
  19863. pageIndex: this.pageNumber - 1,
  19864. intent: renderingIntent,
  19865. renderInteractiveForms: renderInteractiveForms
  19866. });
  19867. }
  19868. var internalRenderTask = new InternalRenderTask(complete, params, this.objs, this.commonObjs, intentState.operatorList, this.pageNumber, canvasFactory);
  19869. internalRenderTask.useRequestAnimationFrame = renderingIntent !== 'print';
  19870. if (!intentState.renderTasks) {
  19871. intentState.renderTasks = [];
  19872. }
  19873. intentState.renderTasks.push(internalRenderTask);
  19874. var renderTask = internalRenderTask.task;
  19875. if (params.continueCallback) {
  19876. deprecated('render is used with continueCallback parameter');
  19877. renderTask.onContinue = params.continueCallback;
  19878. }
  19879. var self = this;
  19880. intentState.displayReadyCapability.promise.then(function pageDisplayReadyPromise(transparency) {
  19881. if (self.pendingCleanup) {
  19882. complete();
  19883. return;
  19884. }
  19885. stats.time('Rendering');
  19886. internalRenderTask.initializeGraphics(transparency);
  19887. internalRenderTask.operatorListChanged();
  19888. }, function pageDisplayReadPromiseError(reason) {
  19889. complete(reason);
  19890. });
  19891. function complete(error) {
  19892. var i = intentState.renderTasks.indexOf(internalRenderTask);
  19893. if (i >= 0) {
  19894. intentState.renderTasks.splice(i, 1);
  19895. }
  19896. if (self.cleanupAfterRender) {
  19897. self.pendingCleanup = true;
  19898. }
  19899. self._tryCleanup();
  19900. if (error) {
  19901. internalRenderTask.capability.reject(error);
  19902. } else {
  19903. internalRenderTask.capability.resolve();
  19904. }
  19905. stats.timeEnd('Rendering');
  19906. stats.timeEnd('Overall');
  19907. }
  19908. return renderTask;
  19909. },
  19910. getOperatorList: function PDFPageProxy_getOperatorList() {
  19911. function operatorListChanged() {
  19912. if (intentState.operatorList.lastChunk) {
  19913. intentState.opListReadCapability.resolve(intentState.operatorList);
  19914. var i = intentState.renderTasks.indexOf(opListTask);
  19915. if (i >= 0) {
  19916. intentState.renderTasks.splice(i, 1);
  19917. }
  19918. }
  19919. }
  19920. var renderingIntent = 'oplist';
  19921. if (!this.intentStates[renderingIntent]) {
  19922. this.intentStates[renderingIntent] = Object.create(null);
  19923. }
  19924. var intentState = this.intentStates[renderingIntent];
  19925. var opListTask;
  19926. if (!intentState.opListReadCapability) {
  19927. opListTask = {};
  19928. opListTask.operatorListChanged = operatorListChanged;
  19929. intentState.receivingOperatorList = true;
  19930. intentState.opListReadCapability = createPromiseCapability();
  19931. intentState.renderTasks = [];
  19932. intentState.renderTasks.push(opListTask);
  19933. intentState.operatorList = {
  19934. fnArray: [],
  19935. argsArray: [],
  19936. lastChunk: false
  19937. };
  19938. this.transport.messageHandler.send('RenderPageRequest', {
  19939. pageIndex: this.pageIndex,
  19940. intent: renderingIntent
  19941. });
  19942. }
  19943. return intentState.opListReadCapability.promise;
  19944. },
  19945. getTextContent: function PDFPageProxy_getTextContent(params) {
  19946. return this.transport.messageHandler.sendWithPromise('GetTextContent', {
  19947. pageIndex: this.pageNumber - 1,
  19948. normalizeWhitespace: params && params.normalizeWhitespace === true ? true : false,
  19949. combineTextItems: params && params.disableCombineTextItems === true ? false : true
  19950. });
  19951. },
  19952. _destroy: function PDFPageProxy_destroy() {
  19953. this.destroyed = true;
  19954. this.transport.pageCache[this.pageIndex] = null;
  19955. var waitOn = [];
  19956. Object.keys(this.intentStates).forEach(function (intent) {
  19957. if (intent === 'oplist') {
  19958. return;
  19959. }
  19960. var intentState = this.intentStates[intent];
  19961. intentState.renderTasks.forEach(function (renderTask) {
  19962. var renderCompleted = renderTask.capability.promise.catch(function () {
  19963. });
  19964. waitOn.push(renderCompleted);
  19965. renderTask.cancel();
  19966. });
  19967. }, this);
  19968. this.objs.clear();
  19969. this.annotationsPromise = null;
  19970. this.pendingCleanup = false;
  19971. return Promise.all(waitOn);
  19972. },
  19973. destroy: function () {
  19974. deprecated('page destroy method, use cleanup() instead');
  19975. this.cleanup();
  19976. },
  19977. cleanup: function PDFPageProxy_cleanup() {
  19978. this.pendingCleanup = true;
  19979. this._tryCleanup();
  19980. },
  19981. _tryCleanup: function PDFPageProxy_tryCleanup() {
  19982. if (!this.pendingCleanup || Object.keys(this.intentStates).some(function (intent) {
  19983. var intentState = this.intentStates[intent];
  19984. return intentState.renderTasks.length !== 0 || intentState.receivingOperatorList;
  19985. }, this)) {
  19986. return;
  19987. }
  19988. Object.keys(this.intentStates).forEach(function (intent) {
  19989. delete this.intentStates[intent];
  19990. }, this);
  19991. this.objs.clear();
  19992. this.annotationsPromise = null;
  19993. this.pendingCleanup = false;
  19994. },
  19995. _startRenderPage: function PDFPageProxy_startRenderPage(transparency, intent) {
  19996. var intentState = this.intentStates[intent];
  19997. if (intentState.displayReadyCapability) {
  19998. intentState.displayReadyCapability.resolve(transparency);
  19999. }
  20000. },
  20001. _renderPageChunk: function PDFPageProxy_renderPageChunk(operatorListChunk, intent) {
  20002. var intentState = this.intentStates[intent];
  20003. var i, ii;
  20004. for (i = 0, ii = operatorListChunk.length; i < ii; i++) {
  20005. intentState.operatorList.fnArray.push(operatorListChunk.fnArray[i]);
  20006. intentState.operatorList.argsArray.push(operatorListChunk.argsArray[i]);
  20007. }
  20008. intentState.operatorList.lastChunk = operatorListChunk.lastChunk;
  20009. for (i = 0; i < intentState.renderTasks.length; i++) {
  20010. intentState.renderTasks[i].operatorListChanged();
  20011. }
  20012. if (operatorListChunk.lastChunk) {
  20013. intentState.receivingOperatorList = false;
  20014. this._tryCleanup();
  20015. }
  20016. }
  20017. };
  20018. return PDFPageProxy;
  20019. }();
  20020. var PDFWorker = function PDFWorkerClosure() {
  20021. var nextFakeWorkerId = 0;
  20022. function getWorkerSrc() {
  20023. if (typeof workerSrc !== 'undefined') {
  20024. return workerSrc;
  20025. }
  20026. if (getDefaultSetting('workerSrc')) {
  20027. return getDefaultSetting('workerSrc');
  20028. }
  20029. if (pdfjsFilePath) {
  20030. return pdfjsFilePath.replace(/\.js$/i, '.worker.js');
  20031. }
  20032. error('No PDFJS.workerSrc specified');
  20033. }
  20034. var fakeWorkerFilesLoadedCapability;
  20035. function setupFakeWorkerGlobal() {
  20036. var WorkerMessageHandler;
  20037. if (fakeWorkerFilesLoadedCapability) {
  20038. return fakeWorkerFilesLoadedCapability.promise;
  20039. }
  20040. fakeWorkerFilesLoadedCapability = createPromiseCapability();
  20041. var pdfjsCoreWorker = __w_pdfjs_require__(22);
  20042. __w_pdfjs_require__(39);
  20043. WorkerMessageHandler = pdfjsCoreWorker.WorkerMessageHandler;
  20044. fakeWorkerFilesLoadedCapability.resolve(WorkerMessageHandler);
  20045. return fakeWorkerFilesLoadedCapability.promise;
  20046. }
  20047. function FakeWorkerPort(defer) {
  20048. this._listeners = [];
  20049. this._defer = defer;
  20050. this._deferred = Promise.resolve(undefined);
  20051. }
  20052. FakeWorkerPort.prototype = {
  20053. postMessage: function (obj, transfers) {
  20054. function cloneValue(value) {
  20055. if (typeof value !== 'object' || value === null) {
  20056. return value;
  20057. }
  20058. if (cloned.has(value)) {
  20059. return cloned.get(value);
  20060. }
  20061. var result;
  20062. var buffer;
  20063. if ((buffer = value.buffer) && isArrayBuffer(buffer)) {
  20064. var transferable = transfers && transfers.indexOf(buffer) >= 0;
  20065. if (value === buffer) {
  20066. result = value;
  20067. } else if (transferable) {
  20068. result = new value.constructor(buffer, value.byteOffset, value.byteLength);
  20069. } else {
  20070. result = new value.constructor(value);
  20071. }
  20072. cloned.set(value, result);
  20073. return result;
  20074. }
  20075. result = isArray(value) ? [] : {};
  20076. cloned.set(value, result);
  20077. for (var i in value) {
  20078. var desc, p = value;
  20079. while (!(desc = Object.getOwnPropertyDescriptor(p, i))) {
  20080. p = Object.getPrototypeOf(p);
  20081. }
  20082. if (typeof desc.value === 'undefined' || typeof desc.value === 'function') {
  20083. continue;
  20084. }
  20085. result[i] = cloneValue(desc.value);
  20086. }
  20087. return result;
  20088. }
  20089. if (!this._defer) {
  20090. this._listeners.forEach(function (listener) {
  20091. listener.call(this, { data: obj });
  20092. }, this);
  20093. return;
  20094. }
  20095. var cloned = new WeakMap();
  20096. var e = { data: cloneValue(obj) };
  20097. this._deferred.then(function () {
  20098. this._listeners.forEach(function (listener) {
  20099. listener.call(this, e);
  20100. }, this);
  20101. }.bind(this));
  20102. },
  20103. addEventListener: function (name, listener) {
  20104. this._listeners.push(listener);
  20105. },
  20106. removeEventListener: function (name, listener) {
  20107. var i = this._listeners.indexOf(listener);
  20108. this._listeners.splice(i, 1);
  20109. },
  20110. terminate: function () {
  20111. this._listeners = [];
  20112. }
  20113. };
  20114. function createCDNWrapper(url) {
  20115. var wrapper = 'importScripts(\'' + url + '\');';
  20116. return URL.createObjectURL(new Blob([wrapper]));
  20117. }
  20118. function PDFWorker(name) {
  20119. this.name = name;
  20120. this.destroyed = false;
  20121. this._readyCapability = createPromiseCapability();
  20122. this._port = null;
  20123. this._webWorker = null;
  20124. this._messageHandler = null;
  20125. this._initialize();
  20126. }
  20127. PDFWorker.prototype = {
  20128. get promise() {
  20129. return this._readyCapability.promise;
  20130. },
  20131. get port() {
  20132. return this._port;
  20133. },
  20134. get messageHandler() {
  20135. return this._messageHandler;
  20136. },
  20137. _initialize: function PDFWorker_initialize() {
  20138. this._setupFakeWorker();
  20139. },
  20140. _setupFakeWorker: function PDFWorker_setupFakeWorker() {
  20141. if (!isWorkerDisabled && !getDefaultSetting('disableWorker')) {
  20142. warn('Setting up fake worker.');
  20143. isWorkerDisabled = true;
  20144. }
  20145. setupFakeWorkerGlobal().then(function (WorkerMessageHandler) {
  20146. if (this.destroyed) {
  20147. this._readyCapability.reject(new Error('Worker was destroyed'));
  20148. return;
  20149. }
  20150. var isTypedArraysPresent = Uint8Array !== Float32Array;
  20151. var port = new FakeWorkerPort(isTypedArraysPresent);
  20152. this._port = port;
  20153. var id = 'fake' + nextFakeWorkerId++;
  20154. var workerHandler = new MessageHandler(id + '_worker', id, port);
  20155. WorkerMessageHandler.setup(workerHandler, port);
  20156. var messageHandler = new MessageHandler(id, id + '_worker', port);
  20157. this._messageHandler = messageHandler;
  20158. this._readyCapability.resolve();
  20159. }.bind(this));
  20160. },
  20161. destroy: function PDFWorker_destroy() {
  20162. this.destroyed = true;
  20163. if (this._webWorker) {
  20164. this._webWorker.terminate();
  20165. this._webWorker = null;
  20166. }
  20167. this._port = null;
  20168. if (this._messageHandler) {
  20169. this._messageHandler.destroy();
  20170. this._messageHandler = null;
  20171. }
  20172. }
  20173. };
  20174. return PDFWorker;
  20175. }();
  20176. var WorkerTransport = function WorkerTransportClosure() {
  20177. function WorkerTransport(messageHandler, loadingTask, pdfDataRangeTransport) {
  20178. this.messageHandler = messageHandler;
  20179. this.loadingTask = loadingTask;
  20180. this.pdfDataRangeTransport = pdfDataRangeTransport;
  20181. this.commonObjs = new PDFObjects();
  20182. this.fontLoader = new FontLoader(loadingTask.docId);
  20183. this.destroyed = false;
  20184. this.destroyCapability = null;
  20185. this._passwordCapability = null;
  20186. this.pageCache = [];
  20187. this.pagePromises = [];
  20188. this.downloadInfoCapability = createPromiseCapability();
  20189. this.setupMessageHandler();
  20190. }
  20191. WorkerTransport.prototype = {
  20192. destroy: function WorkerTransport_destroy() {
  20193. if (this.destroyCapability) {
  20194. return this.destroyCapability.promise;
  20195. }
  20196. this.destroyed = true;
  20197. this.destroyCapability = createPromiseCapability();
  20198. if (this._passwordCapability) {
  20199. this._passwordCapability.reject(new Error('Worker was destroyed during onPassword callback'));
  20200. }
  20201. var waitOn = [];
  20202. this.pageCache.forEach(function (page) {
  20203. if (page) {
  20204. waitOn.push(page._destroy());
  20205. }
  20206. });
  20207. this.pageCache = [];
  20208. this.pagePromises = [];
  20209. var self = this;
  20210. var terminated = this.messageHandler.sendWithPromise('Terminate', null);
  20211. waitOn.push(terminated);
  20212. Promise.all(waitOn).then(function () {
  20213. self.fontLoader.clear();
  20214. if (self.pdfDataRangeTransport) {
  20215. self.pdfDataRangeTransport.abort();
  20216. self.pdfDataRangeTransport = null;
  20217. }
  20218. if (self.messageHandler) {
  20219. self.messageHandler.destroy();
  20220. self.messageHandler = null;
  20221. }
  20222. self.destroyCapability.resolve();
  20223. }, this.destroyCapability.reject);
  20224. return this.destroyCapability.promise;
  20225. },
  20226. setupMessageHandler: function WorkerTransport_setupMessageHandler() {
  20227. var messageHandler = this.messageHandler;
  20228. var loadingTask = this.loadingTask;
  20229. var pdfDataRangeTransport = this.pdfDataRangeTransport;
  20230. if (pdfDataRangeTransport) {
  20231. pdfDataRangeTransport.addRangeListener(function (begin, chunk) {
  20232. messageHandler.send('OnDataRange', {
  20233. begin: begin,
  20234. chunk: chunk
  20235. });
  20236. });
  20237. pdfDataRangeTransport.addProgressListener(function (loaded) {
  20238. messageHandler.send('OnDataProgress', { loaded: loaded });
  20239. });
  20240. pdfDataRangeTransport.addProgressiveReadListener(function (chunk) {
  20241. messageHandler.send('OnDataRange', { chunk: chunk });
  20242. });
  20243. messageHandler.on('RequestDataRange', function transportDataRange(data) {
  20244. pdfDataRangeTransport.requestDataRange(data.begin, data.end);
  20245. }, this);
  20246. }
  20247. messageHandler.on('GetDoc', function transportDoc(data) {
  20248. var pdfInfo = data.pdfInfo;
  20249. this.numPages = data.pdfInfo.numPages;
  20250. var loadingTask = this.loadingTask;
  20251. var pdfDocument = new PDFDocumentProxy(pdfInfo, this, loadingTask);
  20252. this.pdfDocument = pdfDocument;
  20253. loadingTask._capability.resolve(pdfDocument);
  20254. }, this);
  20255. messageHandler.on('PasswordRequest', function transportPasswordRequest(exception) {
  20256. this._passwordCapability = createPromiseCapability();
  20257. if (loadingTask.onPassword) {
  20258. var updatePassword = function (password) {
  20259. this._passwordCapability.resolve({ password: password });
  20260. }.bind(this);
  20261. loadingTask.onPassword(updatePassword, exception.code);
  20262. } else {
  20263. this._passwordCapability.reject(new PasswordException(exception.message, exception.code));
  20264. }
  20265. return this._passwordCapability.promise;
  20266. }, this);
  20267. messageHandler.on('PasswordException', function transportPasswordException(exception) {
  20268. loadingTask._capability.reject(new PasswordException(exception.message, exception.code));
  20269. }, this);
  20270. messageHandler.on('InvalidPDF', function transportInvalidPDF(exception) {
  20271. this.loadingTask._capability.reject(new InvalidPDFException(exception.message));
  20272. }, this);
  20273. messageHandler.on('MissingPDF', function transportMissingPDF(exception) {
  20274. this.loadingTask._capability.reject(new MissingPDFException(exception.message));
  20275. }, this);
  20276. messageHandler.on('UnexpectedResponse', function transportUnexpectedResponse(exception) {
  20277. this.loadingTask._capability.reject(new UnexpectedResponseException(exception.message, exception.status));
  20278. }, this);
  20279. messageHandler.on('UnknownError', function transportUnknownError(exception) {
  20280. this.loadingTask._capability.reject(new UnknownErrorException(exception.message, exception.details));
  20281. }, this);
  20282. messageHandler.on('DataLoaded', function transportPage(data) {
  20283. this.downloadInfoCapability.resolve(data);
  20284. }, this);
  20285. messageHandler.on('PDFManagerReady', function transportPage(data) {
  20286. if (this.pdfDataRangeTransport) {
  20287. this.pdfDataRangeTransport.transportReady();
  20288. }
  20289. }, this);
  20290. messageHandler.on('StartRenderPage', function transportRender(data) {
  20291. if (this.destroyed) {
  20292. return;
  20293. }
  20294. var page = this.pageCache[data.pageIndex];
  20295. page.stats.timeEnd('Page Request');
  20296. page._startRenderPage(data.transparency, data.intent);
  20297. }, this);
  20298. messageHandler.on('RenderPageChunk', function transportRender(data) {
  20299. if (this.destroyed) {
  20300. return;
  20301. }
  20302. var page = this.pageCache[data.pageIndex];
  20303. page._renderPageChunk(data.operatorList, data.intent);
  20304. }, this);
  20305. messageHandler.on('commonobj', function transportObj(data) {
  20306. if (this.destroyed) {
  20307. return;
  20308. }
  20309. var id = data[0];
  20310. var type = data[1];
  20311. if (this.commonObjs.hasData(id)) {
  20312. return;
  20313. }
  20314. switch (type) {
  20315. case 'Font':
  20316. var exportedData = data[2];
  20317. if ('error' in exportedData) {
  20318. var exportedError = exportedData.error;
  20319. warn('Error during font loading: ' + exportedError);
  20320. this.commonObjs.resolve(id, exportedError);
  20321. break;
  20322. }
  20323. var fontRegistry = null;
  20324. if (getDefaultSetting('pdfBug') && globalScope.FontInspector && globalScope['FontInspector'].enabled) {
  20325. fontRegistry = {
  20326. registerFont: function (font, url) {
  20327. globalScope['FontInspector'].fontAdded(font, url);
  20328. }
  20329. };
  20330. }
  20331. var font = new FontFaceObject(exportedData, {
  20332. isEvalSuported: getDefaultSetting('isEvalSupported'),
  20333. disableFontFace: getDefaultSetting('disableFontFace'),
  20334. fontRegistry: fontRegistry
  20335. });
  20336. this.fontLoader.bind([font], function fontReady(fontObjs) {
  20337. this.commonObjs.resolve(id, font);
  20338. }.bind(this));
  20339. break;
  20340. case 'FontPath':
  20341. this.commonObjs.resolve(id, data[2]);
  20342. break;
  20343. default:
  20344. error('Got unknown common object type ' + type);
  20345. }
  20346. }, this);
  20347. messageHandler.on('obj', function transportObj(data) {
  20348. if (this.destroyed) {
  20349. return;
  20350. }
  20351. var id = data[0];
  20352. var pageIndex = data[1];
  20353. var type = data[2];
  20354. var pageProxy = this.pageCache[pageIndex];
  20355. var imageData;
  20356. if (pageProxy.objs.hasData(id)) {
  20357. return;
  20358. }
  20359. switch (type) {
  20360. case 'JpegStream':
  20361. imageData = data[3];
  20362. loadJpegStream(id, imageData, pageProxy.objs);
  20363. break;
  20364. case 'Image':
  20365. imageData = data[3];
  20366. pageProxy.objs.resolve(id, imageData);
  20367. var MAX_IMAGE_SIZE_TO_STORE = 8000000;
  20368. if (imageData && 'data' in imageData && imageData.data.length > MAX_IMAGE_SIZE_TO_STORE) {
  20369. pageProxy.cleanupAfterRender = true;
  20370. }
  20371. break;
  20372. default:
  20373. error('Got unknown object type ' + type);
  20374. }
  20375. }, this);
  20376. messageHandler.on('DocProgress', function transportDocProgress(data) {
  20377. if (this.destroyed) {
  20378. return;
  20379. }
  20380. var loadingTask = this.loadingTask;
  20381. if (loadingTask.onProgress) {
  20382. loadingTask.onProgress({
  20383. loaded: data.loaded,
  20384. total: data.total
  20385. });
  20386. }
  20387. }, this);
  20388. messageHandler.on('PageError', function transportError(data) {
  20389. if (this.destroyed) {
  20390. return;
  20391. }
  20392. var page = this.pageCache[data.pageNum - 1];
  20393. var intentState = page.intentStates[data.intent];
  20394. if (intentState.displayReadyCapability) {
  20395. intentState.displayReadyCapability.reject(data.error);
  20396. } else {
  20397. error(data.error);
  20398. }
  20399. if (intentState.operatorList) {
  20400. intentState.operatorList.lastChunk = true;
  20401. for (var i = 0; i < intentState.renderTasks.length; i++) {
  20402. intentState.renderTasks[i].operatorListChanged();
  20403. }
  20404. }
  20405. }, this);
  20406. messageHandler.on('UnsupportedFeature', function transportUnsupportedFeature(data) {
  20407. if (this.destroyed) {
  20408. return;
  20409. }
  20410. var featureId = data.featureId;
  20411. var loadingTask = this.loadingTask;
  20412. if (loadingTask.onUnsupportedFeature) {
  20413. loadingTask.onUnsupportedFeature(featureId);
  20414. }
  20415. _UnsupportedManager.notify(featureId);
  20416. }, this);
  20417. messageHandler.on('JpegDecode', function (data) {
  20418. if (this.destroyed) {
  20419. return Promise.reject(new Error('Worker was destroyed'));
  20420. }
  20421. if (typeof document === 'undefined') {
  20422. return Promise.reject(new Error('"document" is not defined.'));
  20423. }
  20424. var imageUrl = data[0];
  20425. var components = data[1];
  20426. if (components !== 3 && components !== 1) {
  20427. return Promise.reject(new Error('Only 3 components or 1 component can be returned'));
  20428. }
  20429. return new Promise(function (resolve, reject) {
  20430. var img = new Image();
  20431. img.onload = function () {
  20432. var width = img.width;
  20433. var height = img.height;
  20434. var size = width * height;
  20435. var rgbaLength = size * 4;
  20436. var buf = new Uint8Array(size * components);
  20437. var tmpCanvas = document.createElement('canvas');
  20438. tmpCanvas.width = width;
  20439. tmpCanvas.height = height;
  20440. var tmpCtx = tmpCanvas.getContext('2d');
  20441. tmpCtx.drawImage(img, 0, 0);
  20442. var data = tmpCtx.getImageData(0, 0, width, height).data;
  20443. var i, j;
  20444. if (components === 3) {
  20445. for (i = 0, j = 0; i < rgbaLength; i += 4, j += 3) {
  20446. buf[j] = data[i];
  20447. buf[j + 1] = data[i + 1];
  20448. buf[j + 2] = data[i + 2];
  20449. }
  20450. } else if (components === 1) {
  20451. for (i = 0, j = 0; i < rgbaLength; i += 4, j++) {
  20452. buf[j] = data[i];
  20453. }
  20454. }
  20455. resolve({
  20456. data: buf,
  20457. width: width,
  20458. height: height
  20459. });
  20460. };
  20461. img.onerror = function () {
  20462. reject(new Error('JpegDecode failed to load image'));
  20463. };
  20464. img.src = imageUrl;
  20465. });
  20466. }, this);
  20467. },
  20468. getData: function WorkerTransport_getData() {
  20469. return this.messageHandler.sendWithPromise('GetData', null);
  20470. },
  20471. getPage: function WorkerTransport_getPage(pageNumber, capability) {
  20472. if (!isInt(pageNumber) || pageNumber <= 0 || pageNumber > this.numPages) {
  20473. return Promise.reject(new Error('Invalid page request'));
  20474. }
  20475. var pageIndex = pageNumber - 1;
  20476. if (pageIndex in this.pagePromises) {
  20477. return this.pagePromises[pageIndex];
  20478. }
  20479. var promise = this.messageHandler.sendWithPromise('GetPage', { pageIndex: pageIndex }).then(function (pageInfo) {
  20480. if (this.destroyed) {
  20481. throw new Error('Transport destroyed');
  20482. }
  20483. var page = new PDFPageProxy(pageIndex, pageInfo, this);
  20484. this.pageCache[pageIndex] = page;
  20485. return page;
  20486. }.bind(this));
  20487. this.pagePromises[pageIndex] = promise;
  20488. return promise;
  20489. },
  20490. getPageIndex: function WorkerTransport_getPageIndexByRef(ref) {
  20491. return this.messageHandler.sendWithPromise('GetPageIndex', { ref: ref }).catch(function (reason) {
  20492. return Promise.reject(new Error(reason));
  20493. });
  20494. },
  20495. getAnnotations: function WorkerTransport_getAnnotations(pageIndex, intent) {
  20496. return this.messageHandler.sendWithPromise('GetAnnotations', {
  20497. pageIndex: pageIndex,
  20498. intent: intent
  20499. });
  20500. },
  20501. getDestinations: function WorkerTransport_getDestinations() {
  20502. return this.messageHandler.sendWithPromise('GetDestinations', null);
  20503. },
  20504. getDestination: function WorkerTransport_getDestination(id) {
  20505. return this.messageHandler.sendWithPromise('GetDestination', { id: id });
  20506. },
  20507. getPageLabels: function WorkerTransport_getPageLabels() {
  20508. return this.messageHandler.sendWithPromise('GetPageLabels', null);
  20509. },
  20510. getAttachments: function WorkerTransport_getAttachments() {
  20511. return this.messageHandler.sendWithPromise('GetAttachments', null);
  20512. },
  20513. getJavaScript: function WorkerTransport_getJavaScript() {
  20514. return this.messageHandler.sendWithPromise('GetJavaScript', null);
  20515. },
  20516. getOutline: function WorkerTransport_getOutline() {
  20517. return this.messageHandler.sendWithPromise('GetOutline', null);
  20518. },
  20519. getMetadata: function WorkerTransport_getMetadata() {
  20520. return this.messageHandler.sendWithPromise('GetMetadata', null).then(function transportMetadata(results) {
  20521. return {
  20522. info: results[0],
  20523. metadata: results[1] ? new Metadata(results[1]) : null
  20524. };
  20525. });
  20526. },
  20527. getStats: function WorkerTransport_getStats() {
  20528. return this.messageHandler.sendWithPromise('GetStats', null);
  20529. },
  20530. startCleanup: function WorkerTransport_startCleanup() {
  20531. this.messageHandler.sendWithPromise('Cleanup', null).then(function endCleanup() {
  20532. for (var i = 0, ii = this.pageCache.length; i < ii; i++) {
  20533. var page = this.pageCache[i];
  20534. if (page) {
  20535. page.cleanup();
  20536. }
  20537. }
  20538. this.commonObjs.clear();
  20539. this.fontLoader.clear();
  20540. }.bind(this));
  20541. }
  20542. };
  20543. return WorkerTransport;
  20544. }();
  20545. var PDFObjects = function PDFObjectsClosure() {
  20546. function PDFObjects() {
  20547. this.objs = Object.create(null);
  20548. }
  20549. PDFObjects.prototype = {
  20550. ensureObj: function PDFObjects_ensureObj(objId) {
  20551. if (this.objs[objId]) {
  20552. return this.objs[objId];
  20553. }
  20554. var obj = {
  20555. capability: createPromiseCapability(),
  20556. data: null,
  20557. resolved: false
  20558. };
  20559. this.objs[objId] = obj;
  20560. return obj;
  20561. },
  20562. get: function PDFObjects_get(objId, callback) {
  20563. if (callback) {
  20564. this.ensureObj(objId).capability.promise.then(callback);
  20565. return null;
  20566. }
  20567. var obj = this.objs[objId];
  20568. if (!obj || !obj.resolved) {
  20569. error('Requesting object that isn\'t resolved yet ' + objId);
  20570. }
  20571. return obj.data;
  20572. },
  20573. resolve: function PDFObjects_resolve(objId, data) {
  20574. var obj = this.ensureObj(objId);
  20575. obj.resolved = true;
  20576. obj.data = data;
  20577. obj.capability.resolve(data);
  20578. },
  20579. isResolved: function PDFObjects_isResolved(objId) {
  20580. var objs = this.objs;
  20581. if (!objs[objId]) {
  20582. return false;
  20583. }
  20584. return objs[objId].resolved;
  20585. },
  20586. hasData: function PDFObjects_hasData(objId) {
  20587. return this.isResolved(objId);
  20588. },
  20589. getData: function PDFObjects_getData(objId) {
  20590. var objs = this.objs;
  20591. if (!objs[objId] || !objs[objId].resolved) {
  20592. return null;
  20593. }
  20594. return objs[objId].data;
  20595. },
  20596. clear: function PDFObjects_clear() {
  20597. this.objs = Object.create(null);
  20598. }
  20599. };
  20600. return PDFObjects;
  20601. }();
  20602. var RenderTask = function RenderTaskClosure() {
  20603. function RenderTask(internalRenderTask) {
  20604. this._internalRenderTask = internalRenderTask;
  20605. this.onContinue = null;
  20606. }
  20607. RenderTask.prototype = {
  20608. get promise() {
  20609. return this._internalRenderTask.capability.promise;
  20610. },
  20611. cancel: function RenderTask_cancel() {
  20612. this._internalRenderTask.cancel();
  20613. },
  20614. then: function RenderTask_then(onFulfilled, onRejected) {
  20615. return this.promise.then.apply(this.promise, arguments);
  20616. }
  20617. };
  20618. return RenderTask;
  20619. }();
  20620. var InternalRenderTask = function InternalRenderTaskClosure() {
  20621. function InternalRenderTask(callback, params, objs, commonObjs, operatorList, pageNumber, canvasFactory) {
  20622. this.callback = callback;
  20623. this.params = params;
  20624. this.objs = objs;
  20625. this.commonObjs = commonObjs;
  20626. this.operatorListIdx = null;
  20627. this.operatorList = operatorList;
  20628. this.pageNumber = pageNumber;
  20629. this.canvasFactory = canvasFactory;
  20630. this.running = false;
  20631. this.graphicsReadyCallback = null;
  20632. this.graphicsReady = false;
  20633. this.useRequestAnimationFrame = false;
  20634. this.cancelled = false;
  20635. this.capability = createPromiseCapability();
  20636. this.task = new RenderTask(this);
  20637. this._continueBound = this._continue.bind(this);
  20638. this._scheduleNextBound = this._scheduleNext.bind(this);
  20639. this._nextBound = this._next.bind(this);
  20640. }
  20641. InternalRenderTask.prototype = {
  20642. initializeGraphics: function InternalRenderTask_initializeGraphics(transparency) {
  20643. if (this.cancelled) {
  20644. return;
  20645. }
  20646. if (getDefaultSetting('pdfBug') && globalScope.StepperManager && globalScope.StepperManager.enabled) {
  20647. this.stepper = globalScope.StepperManager.create(this.pageNumber - 1);
  20648. this.stepper.init(this.operatorList);
  20649. this.stepper.nextBreakPoint = this.stepper.getNextBreakPoint();
  20650. }
  20651. var params = this.params;
  20652. this.gfx = new CanvasGraphics(params.canvasContext, this.commonObjs, this.objs, this.canvasFactory, params.imageLayer);
  20653. this.gfx.beginDrawing(params.transform, params.viewport, transparency);
  20654. this.operatorListIdx = 0;
  20655. this.graphicsReady = true;
  20656. if (this.graphicsReadyCallback) {
  20657. this.graphicsReadyCallback();
  20658. }
  20659. },
  20660. cancel: function InternalRenderTask_cancel() {
  20661. this.running = false;
  20662. this.cancelled = true;
  20663. this.callback('cancelled');
  20664. },
  20665. operatorListChanged: function InternalRenderTask_operatorListChanged() {
  20666. if (!this.graphicsReady) {
  20667. if (!this.graphicsReadyCallback) {
  20668. this.graphicsReadyCallback = this._continueBound;
  20669. }
  20670. return;
  20671. }
  20672. if (this.stepper) {
  20673. this.stepper.updateOperatorList(this.operatorList);
  20674. }
  20675. if (this.running) {
  20676. return;
  20677. }
  20678. this._continue();
  20679. },
  20680. _continue: function InternalRenderTask__continue() {
  20681. this.running = true;
  20682. if (this.cancelled) {
  20683. return;
  20684. }
  20685. if (this.task.onContinue) {
  20686. this.task.onContinue(this._scheduleNextBound);
  20687. } else {
  20688. this._scheduleNext();
  20689. }
  20690. },
  20691. _scheduleNext: function InternalRenderTask__scheduleNext() {
  20692. if (this.useRequestAnimationFrame && typeof window !== 'undefined') {
  20693. window.requestAnimationFrame(this._nextBound);
  20694. } else {
  20695. Promise.resolve(undefined).then(this._nextBound);
  20696. }
  20697. },
  20698. _next: function InternalRenderTask__next() {
  20699. if (this.cancelled) {
  20700. return;
  20701. }
  20702. this.operatorListIdx = this.gfx.executeOperatorList(this.operatorList, this.operatorListIdx, this._continueBound, this.stepper);
  20703. if (this.operatorListIdx === this.operatorList.argsArray.length) {
  20704. this.running = false;
  20705. if (this.operatorList.lastChunk) {
  20706. this.gfx.endDrawing();
  20707. this.callback();
  20708. }
  20709. }
  20710. }
  20711. };
  20712. return InternalRenderTask;
  20713. }();
  20714. var _UnsupportedManager = function UnsupportedManagerClosure() {
  20715. var listeners = [];
  20716. return {
  20717. listen: function (cb) {
  20718. deprecated('Global UnsupportedManager.listen is used: ' + ' use PDFDocumentLoadingTask.onUnsupportedFeature instead');
  20719. listeners.push(cb);
  20720. },
  20721. notify: function (featureId) {
  20722. for (var i = 0, ii = listeners.length; i < ii; i++) {
  20723. listeners[i](featureId);
  20724. }
  20725. }
  20726. };
  20727. }();
  20728. exports.version = '1.7.297';
  20729. exports.build = '425ad309';
  20730. exports.getDocument = getDocument;
  20731. exports.PDFDataRangeTransport = PDFDataRangeTransport;
  20732. exports.PDFWorker = PDFWorker;
  20733. exports.PDFDocumentProxy = PDFDocumentProxy;
  20734. exports.PDFPageProxy = PDFPageProxy;
  20735. exports._UnsupportedManager = _UnsupportedManager;
  20736. /***/ }),
  20737. /* 11 */
  20738. /***/ (function(module, exports, __w_pdfjs_require__) {
  20739. "use strict";
  20740. var sharedUtil = __w_pdfjs_require__(0);
  20741. var FONT_IDENTITY_MATRIX = sharedUtil.FONT_IDENTITY_MATRIX;
  20742. var IDENTITY_MATRIX = sharedUtil.IDENTITY_MATRIX;
  20743. var ImageKind = sharedUtil.ImageKind;
  20744. var OPS = sharedUtil.OPS;
  20745. var Util = sharedUtil.Util;
  20746. var isNum = sharedUtil.isNum;
  20747. var isArray = sharedUtil.isArray;
  20748. var warn = sharedUtil.warn;
  20749. var createObjectURL = sharedUtil.createObjectURL;
  20750. var SVG_DEFAULTS = {
  20751. fontStyle: 'normal',
  20752. fontWeight: 'normal',
  20753. fillColor: '#000000'
  20754. };
  20755. var convertImgDataToPng = function convertImgDataToPngClosure() {
  20756. var PNG_HEADER = new Uint8Array([
  20757. 0x89,
  20758. 0x50,
  20759. 0x4e,
  20760. 0x47,
  20761. 0x0d,
  20762. 0x0a,
  20763. 0x1a,
  20764. 0x0a
  20765. ]);
  20766. var CHUNK_WRAPPER_SIZE = 12;
  20767. var crcTable = new Int32Array(256);
  20768. for (var i = 0; i < 256; i++) {
  20769. var c = i;
  20770. for (var h = 0; h < 8; h++) {
  20771. if (c & 1) {
  20772. c = 0xedB88320 ^ c >> 1 & 0x7fffffff;
  20773. } else {
  20774. c = c >> 1 & 0x7fffffff;
  20775. }
  20776. }
  20777. crcTable[i] = c;
  20778. }
  20779. function crc32(data, start, end) {
  20780. var crc = -1;
  20781. for (var i = start; i < end; i++) {
  20782. var a = (crc ^ data[i]) & 0xff;
  20783. var b = crcTable[a];
  20784. crc = crc >>> 8 ^ b;
  20785. }
  20786. return crc ^ -1;
  20787. }
  20788. function writePngChunk(type, body, data, offset) {
  20789. var p = offset;
  20790. var len = body.length;
  20791. data[p] = len >> 24 & 0xff;
  20792. data[p + 1] = len >> 16 & 0xff;
  20793. data[p + 2] = len >> 8 & 0xff;
  20794. data[p + 3] = len & 0xff;
  20795. p += 4;
  20796. data[p] = type.charCodeAt(0) & 0xff;
  20797. data[p + 1] = type.charCodeAt(1) & 0xff;
  20798. data[p + 2] = type.charCodeAt(2) & 0xff;
  20799. data[p + 3] = type.charCodeAt(3) & 0xff;
  20800. p += 4;
  20801. data.set(body, p);
  20802. p += body.length;
  20803. var crc = crc32(data, offset + 4, p);
  20804. data[p] = crc >> 24 & 0xff;
  20805. data[p + 1] = crc >> 16 & 0xff;
  20806. data[p + 2] = crc >> 8 & 0xff;
  20807. data[p + 3] = crc & 0xff;
  20808. }
  20809. function adler32(data, start, end) {
  20810. var a = 1;
  20811. var b = 0;
  20812. for (var i = start; i < end; ++i) {
  20813. a = (a + (data[i] & 0xff)) % 65521;
  20814. b = (b + a) % 65521;
  20815. }
  20816. return b << 16 | a;
  20817. }
  20818. function encode(imgData, kind, forceDataSchema) {
  20819. var width = imgData.width;
  20820. var height = imgData.height;
  20821. var bitDepth, colorType, lineSize;
  20822. var bytes = imgData.data;
  20823. switch (kind) {
  20824. case ImageKind.GRAYSCALE_1BPP:
  20825. colorType = 0;
  20826. bitDepth = 1;
  20827. lineSize = width + 7 >> 3;
  20828. break;
  20829. case ImageKind.RGB_24BPP:
  20830. colorType = 2;
  20831. bitDepth = 8;
  20832. lineSize = width * 3;
  20833. break;
  20834. case ImageKind.RGBA_32BPP:
  20835. colorType = 6;
  20836. bitDepth = 8;
  20837. lineSize = width * 4;
  20838. break;
  20839. default:
  20840. throw new Error('invalid format');
  20841. }
  20842. var literals = new Uint8Array((1 + lineSize) * height);
  20843. var offsetLiterals = 0, offsetBytes = 0;
  20844. var y, i;
  20845. for (y = 0; y < height; ++y) {
  20846. literals[offsetLiterals++] = 0;
  20847. literals.set(bytes.subarray(offsetBytes, offsetBytes + lineSize), offsetLiterals);
  20848. offsetBytes += lineSize;
  20849. offsetLiterals += lineSize;
  20850. }
  20851. if (kind === ImageKind.GRAYSCALE_1BPP) {
  20852. offsetLiterals = 0;
  20853. for (y = 0; y < height; y++) {
  20854. offsetLiterals++;
  20855. for (i = 0; i < lineSize; i++) {
  20856. literals[offsetLiterals++] ^= 0xFF;
  20857. }
  20858. }
  20859. }
  20860. var ihdr = new Uint8Array([
  20861. width >> 24 & 0xff,
  20862. width >> 16 & 0xff,
  20863. width >> 8 & 0xff,
  20864. width & 0xff,
  20865. height >> 24 & 0xff,
  20866. height >> 16 & 0xff,
  20867. height >> 8 & 0xff,
  20868. height & 0xff,
  20869. bitDepth,
  20870. colorType,
  20871. 0x00,
  20872. 0x00,
  20873. 0x00
  20874. ]);
  20875. var len = literals.length;
  20876. var maxBlockLength = 0xFFFF;
  20877. var deflateBlocks = Math.ceil(len / maxBlockLength);
  20878. var idat = new Uint8Array(2 + len + deflateBlocks * 5 + 4);
  20879. var pi = 0;
  20880. idat[pi++] = 0x78;
  20881. idat[pi++] = 0x9c;
  20882. var pos = 0;
  20883. while (len > maxBlockLength) {
  20884. idat[pi++] = 0x00;
  20885. idat[pi++] = 0xff;
  20886. idat[pi++] = 0xff;
  20887. idat[pi++] = 0x00;
  20888. idat[pi++] = 0x00;
  20889. idat.set(literals.subarray(pos, pos + maxBlockLength), pi);
  20890. pi += maxBlockLength;
  20891. pos += maxBlockLength;
  20892. len -= maxBlockLength;
  20893. }
  20894. idat[pi++] = 0x01;
  20895. idat[pi++] = len & 0xff;
  20896. idat[pi++] = len >> 8 & 0xff;
  20897. idat[pi++] = ~len & 0xffff & 0xff;
  20898. idat[pi++] = (~len & 0xffff) >> 8 & 0xff;
  20899. idat.set(literals.subarray(pos), pi);
  20900. pi += literals.length - pos;
  20901. var adler = adler32(literals, 0, literals.length);
  20902. idat[pi++] = adler >> 24 & 0xff;
  20903. idat[pi++] = adler >> 16 & 0xff;
  20904. idat[pi++] = adler >> 8 & 0xff;
  20905. idat[pi++] = adler & 0xff;
  20906. var pngLength = PNG_HEADER.length + CHUNK_WRAPPER_SIZE * 3 + ihdr.length + idat.length;
  20907. var data = new Uint8Array(pngLength);
  20908. var offset = 0;
  20909. data.set(PNG_HEADER, offset);
  20910. offset += PNG_HEADER.length;
  20911. writePngChunk('IHDR', ihdr, data, offset);
  20912. offset += CHUNK_WRAPPER_SIZE + ihdr.length;
  20913. writePngChunk('IDATA', idat, data, offset);
  20914. offset += CHUNK_WRAPPER_SIZE + idat.length;
  20915. writePngChunk('IEND', new Uint8Array(0), data, offset);
  20916. return createObjectURL(data, 'image/png', forceDataSchema);
  20917. }
  20918. return function convertImgDataToPng(imgData, forceDataSchema) {
  20919. var kind = imgData.kind === undefined ? ImageKind.GRAYSCALE_1BPP : imgData.kind;
  20920. return encode(imgData, kind, forceDataSchema);
  20921. };
  20922. }();
  20923. var SVGExtraState = function SVGExtraStateClosure() {
  20924. function SVGExtraState() {
  20925. this.fontSizeScale = 1;
  20926. this.fontWeight = SVG_DEFAULTS.fontWeight;
  20927. this.fontSize = 0;
  20928. this.textMatrix = IDENTITY_MATRIX;
  20929. this.fontMatrix = FONT_IDENTITY_MATRIX;
  20930. this.leading = 0;
  20931. this.x = 0;
  20932. this.y = 0;
  20933. this.lineX = 0;
  20934. this.lineY = 0;
  20935. this.charSpacing = 0;
  20936. this.wordSpacing = 0;
  20937. this.textHScale = 1;
  20938. this.textRise = 0;
  20939. this.fillColor = SVG_DEFAULTS.fillColor;
  20940. this.strokeColor = '#000000';
  20941. this.fillAlpha = 1;
  20942. this.strokeAlpha = 1;
  20943. this.lineWidth = 1;
  20944. this.lineJoin = '';
  20945. this.lineCap = '';
  20946. this.miterLimit = 0;
  20947. this.dashArray = [];
  20948. this.dashPhase = 0;
  20949. this.dependencies = [];
  20950. this.activeClipUrl = null;
  20951. this.clipGroup = null;
  20952. this.maskId = '';
  20953. }
  20954. SVGExtraState.prototype = {
  20955. clone: function SVGExtraState_clone() {
  20956. return Object.create(this);
  20957. },
  20958. setCurrentPoint: function SVGExtraState_setCurrentPoint(x, y) {
  20959. this.x = x;
  20960. this.y = y;
  20961. }
  20962. };
  20963. return SVGExtraState;
  20964. }();
  20965. var SVGGraphics = function SVGGraphicsClosure() {
  20966. function opListToTree(opList) {
  20967. var opTree = [];
  20968. var tmp = [];
  20969. var opListLen = opList.length;
  20970. for (var x = 0; x < opListLen; x++) {
  20971. if (opList[x].fn === 'save') {
  20972. opTree.push({
  20973. 'fnId': 92,
  20974. 'fn': 'group',
  20975. 'items': []
  20976. });
  20977. tmp.push(opTree);
  20978. opTree = opTree[opTree.length - 1].items;
  20979. continue;
  20980. }
  20981. if (opList[x].fn === 'restore') {
  20982. opTree = tmp.pop();
  20983. } else {
  20984. opTree.push(opList[x]);
  20985. }
  20986. }
  20987. return opTree;
  20988. }
  20989. function pf(value) {
  20990. if (value === (value | 0)) {
  20991. return value.toString();
  20992. }
  20993. var s = value.toFixed(10);
  20994. var i = s.length - 1;
  20995. if (s[i] !== '0') {
  20996. return s;
  20997. }
  20998. do {
  20999. i--;
  21000. } while (s[i] === '0');
  21001. return s.substr(0, s[i] === '.' ? i : i + 1);
  21002. }
  21003. function pm(m) {
  21004. if (m[4] === 0 && m[5] === 0) {
  21005. if (m[1] === 0 && m[2] === 0) {
  21006. if (m[0] === 1 && m[3] === 1) {
  21007. return '';
  21008. }
  21009. return 'scale(' + pf(m[0]) + ' ' + pf(m[3]) + ')';
  21010. }
  21011. if (m[0] === m[3] && m[1] === -m[2]) {
  21012. var a = Math.acos(m[0]) * 180 / Math.PI;
  21013. return 'rotate(' + pf(a) + ')';
  21014. }
  21015. } else {
  21016. if (m[0] === 1 && m[1] === 0 && m[2] === 0 && m[3] === 1) {
  21017. return 'translate(' + pf(m[4]) + ' ' + pf(m[5]) + ')';
  21018. }
  21019. }
  21020. return 'matrix(' + pf(m[0]) + ' ' + pf(m[1]) + ' ' + pf(m[2]) + ' ' + pf(m[3]) + ' ' + pf(m[4]) + ' ' + pf(m[5]) + ')';
  21021. }
  21022. function SVGGraphics(commonObjs, objs, forceDataSchema) {
  21023. this.current = new SVGExtraState();
  21024. this.transformMatrix = IDENTITY_MATRIX;
  21025. this.transformStack = [];
  21026. this.extraStack = [];
  21027. this.commonObjs = commonObjs;
  21028. this.objs = objs;
  21029. this.pendingEOFill = false;
  21030. this.embedFonts = false;
  21031. this.embeddedFonts = Object.create(null);
  21032. this.cssStyle = null;
  21033. this.forceDataSchema = !!forceDataSchema;
  21034. }
  21035. var NS = 'http://www.w3.org/2000/svg';
  21036. var XML_NS = 'http://www.w3.org/XML/1998/namespace';
  21037. var XLINK_NS = 'http://www.w3.org/1999/xlink';
  21038. var LINE_CAP_STYLES = [
  21039. 'butt',
  21040. 'round',
  21041. 'square'
  21042. ];
  21043. var LINE_JOIN_STYLES = [
  21044. 'miter',
  21045. 'round',
  21046. 'bevel'
  21047. ];
  21048. var clipCount = 0;
  21049. var maskCount = 0;
  21050. SVGGraphics.prototype = {
  21051. save: function SVGGraphics_save() {
  21052. this.transformStack.push(this.transformMatrix);
  21053. var old = this.current;
  21054. this.extraStack.push(old);
  21055. this.current = old.clone();
  21056. },
  21057. restore: function SVGGraphics_restore() {
  21058. this.transformMatrix = this.transformStack.pop();
  21059. this.current = this.extraStack.pop();
  21060. this.tgrp = null;
  21061. },
  21062. group: function SVGGraphics_group(items) {
  21063. this.save();
  21064. this.executeOpTree(items);
  21065. this.restore();
  21066. },
  21067. loadDependencies: function SVGGraphics_loadDependencies(operatorList) {
  21068. var fnArray = operatorList.fnArray;
  21069. var fnArrayLen = fnArray.length;
  21070. var argsArray = operatorList.argsArray;
  21071. var self = this;
  21072. for (var i = 0; i < fnArrayLen; i++) {
  21073. if (OPS.dependency === fnArray[i]) {
  21074. var deps = argsArray[i];
  21075. for (var n = 0, nn = deps.length; n < nn; n++) {
  21076. var obj = deps[n];
  21077. var common = obj.substring(0, 2) === 'g_';
  21078. var promise;
  21079. if (common) {
  21080. promise = new Promise(function (resolve) {
  21081. self.commonObjs.get(obj, resolve);
  21082. });
  21083. } else {
  21084. promise = new Promise(function (resolve) {
  21085. self.objs.get(obj, resolve);
  21086. });
  21087. }
  21088. this.current.dependencies.push(promise);
  21089. }
  21090. }
  21091. }
  21092. return Promise.all(this.current.dependencies);
  21093. },
  21094. transform: function SVGGraphics_transform(a, b, c, d, e, f) {
  21095. var transformMatrix = [
  21096. a,
  21097. b,
  21098. c,
  21099. d,
  21100. e,
  21101. f
  21102. ];
  21103. this.transformMatrix = Util.transform(this.transformMatrix, transformMatrix);
  21104. this.tgrp = null;
  21105. },
  21106. getSVG: function SVGGraphics_getSVG(operatorList, viewport) {
  21107. this.viewport = viewport;
  21108. var svgElement = this._initialize(viewport);
  21109. return this.loadDependencies(operatorList).then(function () {
  21110. this.transformMatrix = IDENTITY_MATRIX;
  21111. var opTree = this.convertOpList(operatorList);
  21112. this.executeOpTree(opTree);
  21113. return svgElement;
  21114. }.bind(this));
  21115. },
  21116. convertOpList: function SVGGraphics_convertOpList(operatorList) {
  21117. var argsArray = operatorList.argsArray;
  21118. var fnArray = operatorList.fnArray;
  21119. var fnArrayLen = fnArray.length;
  21120. var REVOPS = [];
  21121. var opList = [];
  21122. for (var op in OPS) {
  21123. REVOPS[OPS[op]] = op;
  21124. }
  21125. for (var x = 0; x < fnArrayLen; x++) {
  21126. var fnId = fnArray[x];
  21127. opList.push({
  21128. 'fnId': fnId,
  21129. 'fn': REVOPS[fnId],
  21130. 'args': argsArray[x]
  21131. });
  21132. }
  21133. return opListToTree(opList);
  21134. },
  21135. executeOpTree: function SVGGraphics_executeOpTree(opTree) {
  21136. var opTreeLen = opTree.length;
  21137. for (var x = 0; x < opTreeLen; x++) {
  21138. var fn = opTree[x].fn;
  21139. var fnId = opTree[x].fnId;
  21140. var args = opTree[x].args;
  21141. switch (fnId | 0) {
  21142. case OPS.beginText:
  21143. this.beginText();
  21144. break;
  21145. case OPS.setLeading:
  21146. this.setLeading(args);
  21147. break;
  21148. case OPS.setLeadingMoveText:
  21149. this.setLeadingMoveText(args[0], args[1]);
  21150. break;
  21151. case OPS.setFont:
  21152. this.setFont(args);
  21153. break;
  21154. case OPS.showText:
  21155. this.showText(args[0]);
  21156. break;
  21157. case OPS.showSpacedText:
  21158. this.showText(args[0]);
  21159. break;
  21160. case OPS.endText:
  21161. this.endText();
  21162. break;
  21163. case OPS.moveText:
  21164. this.moveText(args[0], args[1]);
  21165. break;
  21166. case OPS.setCharSpacing:
  21167. this.setCharSpacing(args[0]);
  21168. break;
  21169. case OPS.setWordSpacing:
  21170. this.setWordSpacing(args[0]);
  21171. break;
  21172. case OPS.setHScale:
  21173. this.setHScale(args[0]);
  21174. break;
  21175. case OPS.setTextMatrix:
  21176. this.setTextMatrix(args[0], args[1], args[2], args[3], args[4], args[5]);
  21177. break;
  21178. case OPS.setLineWidth:
  21179. this.setLineWidth(args[0]);
  21180. break;
  21181. case OPS.setLineJoin:
  21182. this.setLineJoin(args[0]);
  21183. break;
  21184. case OPS.setLineCap:
  21185. this.setLineCap(args[0]);
  21186. break;
  21187. case OPS.setMiterLimit:
  21188. this.setMiterLimit(args[0]);
  21189. break;
  21190. case OPS.setFillRGBColor:
  21191. this.setFillRGBColor(args[0], args[1], args[2]);
  21192. break;
  21193. case OPS.setStrokeRGBColor:
  21194. this.setStrokeRGBColor(args[0], args[1], args[2]);
  21195. break;
  21196. case OPS.setDash:
  21197. this.setDash(args[0], args[1]);
  21198. break;
  21199. case OPS.setGState:
  21200. this.setGState(args[0]);
  21201. break;
  21202. case OPS.fill:
  21203. this.fill();
  21204. break;
  21205. case OPS.eoFill:
  21206. this.eoFill();
  21207. break;
  21208. case OPS.stroke:
  21209. this.stroke();
  21210. break;
  21211. case OPS.fillStroke:
  21212. this.fillStroke();
  21213. break;
  21214. case OPS.eoFillStroke:
  21215. this.eoFillStroke();
  21216. break;
  21217. case OPS.clip:
  21218. this.clip('nonzero');
  21219. break;
  21220. case OPS.eoClip:
  21221. this.clip('evenodd');
  21222. break;
  21223. case OPS.paintSolidColorImageMask:
  21224. this.paintSolidColorImageMask();
  21225. break;
  21226. case OPS.paintJpegXObject:
  21227. this.paintJpegXObject(args[0], args[1], args[2]);
  21228. break;
  21229. case OPS.paintImageXObject:
  21230. this.paintImageXObject(args[0]);
  21231. break;
  21232. case OPS.paintInlineImageXObject:
  21233. this.paintInlineImageXObject(args[0]);
  21234. break;
  21235. case OPS.paintImageMaskXObject:
  21236. this.paintImageMaskXObject(args[0]);
  21237. break;
  21238. case OPS.paintFormXObjectBegin:
  21239. this.paintFormXObjectBegin(args[0], args[1]);
  21240. break;
  21241. case OPS.paintFormXObjectEnd:
  21242. this.paintFormXObjectEnd();
  21243. break;
  21244. case OPS.closePath:
  21245. this.closePath();
  21246. break;
  21247. case OPS.closeStroke:
  21248. this.closeStroke();
  21249. break;
  21250. case OPS.closeFillStroke:
  21251. this.closeFillStroke();
  21252. break;
  21253. case OPS.nextLine:
  21254. this.nextLine();
  21255. break;
  21256. case OPS.transform:
  21257. this.transform(args[0], args[1], args[2], args[3], args[4], args[5]);
  21258. break;
  21259. case OPS.constructPath:
  21260. this.constructPath(args[0], args[1]);
  21261. break;
  21262. case OPS.endPath:
  21263. this.endPath();
  21264. break;
  21265. case 92:
  21266. this.group(opTree[x].items);
  21267. break;
  21268. default:
  21269. warn('Unimplemented operator ' + fn);
  21270. break;
  21271. }
  21272. }
  21273. },
  21274. setWordSpacing: function SVGGraphics_setWordSpacing(wordSpacing) {
  21275. this.current.wordSpacing = wordSpacing;
  21276. },
  21277. setCharSpacing: function SVGGraphics_setCharSpacing(charSpacing) {
  21278. this.current.charSpacing = charSpacing;
  21279. },
  21280. nextLine: function SVGGraphics_nextLine() {
  21281. this.moveText(0, this.current.leading);
  21282. },
  21283. setTextMatrix: function SVGGraphics_setTextMatrix(a, b, c, d, e, f) {
  21284. var current = this.current;
  21285. this.current.textMatrix = this.current.lineMatrix = [
  21286. a,
  21287. b,
  21288. c,
  21289. d,
  21290. e,
  21291. f
  21292. ];
  21293. this.current.x = this.current.lineX = 0;
  21294. this.current.y = this.current.lineY = 0;
  21295. current.xcoords = [];
  21296. current.tspan = document.createElementNS(NS, 'svg:tspan');
  21297. current.tspan.setAttributeNS(null, 'font-family', current.fontFamily);
  21298. current.tspan.setAttributeNS(null, 'font-size', pf(current.fontSize) + 'px');
  21299. current.tspan.setAttributeNS(null, 'y', pf(-current.y));
  21300. current.txtElement = document.createElementNS(NS, 'svg:text');
  21301. current.txtElement.appendChild(current.tspan);
  21302. },
  21303. beginText: function SVGGraphics_beginText() {
  21304. this.current.x = this.current.lineX = 0;
  21305. this.current.y = this.current.lineY = 0;
  21306. this.current.textMatrix = IDENTITY_MATRIX;
  21307. this.current.lineMatrix = IDENTITY_MATRIX;
  21308. this.current.tspan = document.createElementNS(NS, 'svg:tspan');
  21309. this.current.txtElement = document.createElementNS(NS, 'svg:text');
  21310. this.current.txtgrp = document.createElementNS(NS, 'svg:g');
  21311. this.current.xcoords = [];
  21312. },
  21313. moveText: function SVGGraphics_moveText(x, y) {
  21314. var current = this.current;
  21315. this.current.x = this.current.lineX += x;
  21316. this.current.y = this.current.lineY += y;
  21317. current.xcoords = [];
  21318. current.tspan = document.createElementNS(NS, 'svg:tspan');
  21319. current.tspan.setAttributeNS(null, 'font-family', current.fontFamily);
  21320. current.tspan.setAttributeNS(null, 'font-size', pf(current.fontSize) + 'px');
  21321. current.tspan.setAttributeNS(null, 'y', pf(-current.y));
  21322. },
  21323. showText: function SVGGraphics_showText(glyphs) {
  21324. var current = this.current;
  21325. var font = current.font;
  21326. var fontSize = current.fontSize;
  21327. if (fontSize === 0) {
  21328. return;
  21329. }
  21330. var charSpacing = current.charSpacing;
  21331. var wordSpacing = current.wordSpacing;
  21332. var fontDirection = current.fontDirection;
  21333. var textHScale = current.textHScale * fontDirection;
  21334. var glyphsLength = glyphs.length;
  21335. var vertical = font.vertical;
  21336. var widthAdvanceScale = fontSize * current.fontMatrix[0];
  21337. var x = 0, i;
  21338. for (i = 0; i < glyphsLength; ++i) {
  21339. var glyph = glyphs[i];
  21340. if (glyph === null) {
  21341. x += fontDirection * wordSpacing;
  21342. continue;
  21343. } else if (isNum(glyph)) {
  21344. x += -glyph * fontSize * 0.001;
  21345. continue;
  21346. }
  21347. current.xcoords.push(current.x + x * textHScale);
  21348. var width = glyph.width;
  21349. var character = glyph.fontChar;
  21350. var charWidth = width * widthAdvanceScale + charSpacing * fontDirection;
  21351. x += charWidth;
  21352. current.tspan.textContent += character;
  21353. }
  21354. if (vertical) {
  21355. current.y -= x * textHScale;
  21356. } else {
  21357. current.x += x * textHScale;
  21358. }
  21359. current.tspan.setAttributeNS(null, 'x', current.xcoords.map(pf).join(' '));
  21360. current.tspan.setAttributeNS(null, 'y', pf(-current.y));
  21361. current.tspan.setAttributeNS(null, 'font-family', current.fontFamily);
  21362. current.tspan.setAttributeNS(null, 'font-size', pf(current.fontSize) + 'px');
  21363. if (current.fontStyle !== SVG_DEFAULTS.fontStyle) {
  21364. current.tspan.setAttributeNS(null, 'font-style', current.fontStyle);
  21365. }
  21366. if (current.fontWeight !== SVG_DEFAULTS.fontWeight) {
  21367. current.tspan.setAttributeNS(null, 'font-weight', current.fontWeight);
  21368. }
  21369. if (current.fillColor !== SVG_DEFAULTS.fillColor) {
  21370. current.tspan.setAttributeNS(null, 'fill', current.fillColor);
  21371. }
  21372. current.txtElement.setAttributeNS(null, 'transform', pm(current.textMatrix) + ' scale(1, -1)');
  21373. current.txtElement.setAttributeNS(XML_NS, 'xml:space', 'preserve');
  21374. current.txtElement.appendChild(current.tspan);
  21375. current.txtgrp.appendChild(current.txtElement);
  21376. this._ensureTransformGroup().appendChild(current.txtElement);
  21377. },
  21378. setLeadingMoveText: function SVGGraphics_setLeadingMoveText(x, y) {
  21379. this.setLeading(-y);
  21380. this.moveText(x, y);
  21381. },
  21382. addFontStyle: function SVGGraphics_addFontStyle(fontObj) {
  21383. if (!this.cssStyle) {
  21384. this.cssStyle = document.createElementNS(NS, 'svg:style');
  21385. this.cssStyle.setAttributeNS(null, 'type', 'text/css');
  21386. this.defs.appendChild(this.cssStyle);
  21387. }
  21388. var url = createObjectURL(fontObj.data, fontObj.mimetype, this.forceDataSchema);
  21389. this.cssStyle.textContent += '@font-face { font-family: "' + fontObj.loadedName + '";' + ' src: url(' + url + '); }\n';
  21390. },
  21391. setFont: function SVGGraphics_setFont(details) {
  21392. var current = this.current;
  21393. var fontObj = this.commonObjs.get(details[0]);
  21394. var size = details[1];
  21395. this.current.font = fontObj;
  21396. if (this.embedFonts && fontObj.data && !this.embeddedFonts[fontObj.loadedName]) {
  21397. this.addFontStyle(fontObj);
  21398. this.embeddedFonts[fontObj.loadedName] = fontObj;
  21399. }
  21400. current.fontMatrix = fontObj.fontMatrix ? fontObj.fontMatrix : FONT_IDENTITY_MATRIX;
  21401. var bold = fontObj.black ? fontObj.bold ? 'bolder' : 'bold' : fontObj.bold ? 'bold' : 'normal';
  21402. var italic = fontObj.italic ? 'italic' : 'normal';
  21403. if (size < 0) {
  21404. size = -size;
  21405. current.fontDirection = -1;
  21406. } else {
  21407. current.fontDirection = 1;
  21408. }
  21409. current.fontSize = size;
  21410. current.fontFamily = fontObj.loadedName;
  21411. current.fontWeight = bold;
  21412. current.fontStyle = italic;
  21413. current.tspan = document.createElementNS(NS, 'svg:tspan');
  21414. current.tspan.setAttributeNS(null, 'y', pf(-current.y));
  21415. current.xcoords = [];
  21416. },
  21417. endText: function SVGGraphics_endText() {
  21418. },
  21419. setLineWidth: function SVGGraphics_setLineWidth(width) {
  21420. this.current.lineWidth = width;
  21421. },
  21422. setLineCap: function SVGGraphics_setLineCap(style) {
  21423. this.current.lineCap = LINE_CAP_STYLES[style];
  21424. },
  21425. setLineJoin: function SVGGraphics_setLineJoin(style) {
  21426. this.current.lineJoin = LINE_JOIN_STYLES[style];
  21427. },
  21428. setMiterLimit: function SVGGraphics_setMiterLimit(limit) {
  21429. this.current.miterLimit = limit;
  21430. },
  21431. setStrokeRGBColor: function SVGGraphics_setStrokeRGBColor(r, g, b) {
  21432. var color = Util.makeCssRgb(r, g, b);
  21433. this.current.strokeColor = color;
  21434. },
  21435. setFillRGBColor: function SVGGraphics_setFillRGBColor(r, g, b) {
  21436. var color = Util.makeCssRgb(r, g, b);
  21437. this.current.fillColor = color;
  21438. this.current.tspan = document.createElementNS(NS, 'svg:tspan');
  21439. this.current.xcoords = [];
  21440. },
  21441. setDash: function SVGGraphics_setDash(dashArray, dashPhase) {
  21442. this.current.dashArray = dashArray;
  21443. this.current.dashPhase = dashPhase;
  21444. },
  21445. constructPath: function SVGGraphics_constructPath(ops, args) {
  21446. var current = this.current;
  21447. var x = current.x, y = current.y;
  21448. current.path = document.createElementNS(NS, 'svg:path');
  21449. var d = [];
  21450. var opLength = ops.length;
  21451. for (var i = 0, j = 0; i < opLength; i++) {
  21452. switch (ops[i] | 0) {
  21453. case OPS.rectangle:
  21454. x = args[j++];
  21455. y = args[j++];
  21456. var width = args[j++];
  21457. var height = args[j++];
  21458. var xw = x + width;
  21459. var yh = y + height;
  21460. d.push('M', pf(x), pf(y), 'L', pf(xw), pf(y), 'L', pf(xw), pf(yh), 'L', pf(x), pf(yh), 'Z');
  21461. break;
  21462. case OPS.moveTo:
  21463. x = args[j++];
  21464. y = args[j++];
  21465. d.push('M', pf(x), pf(y));
  21466. break;
  21467. case OPS.lineTo:
  21468. x = args[j++];
  21469. y = args[j++];
  21470. d.push('L', pf(x), pf(y));
  21471. break;
  21472. case OPS.curveTo:
  21473. x = args[j + 4];
  21474. y = args[j + 5];
  21475. d.push('C', pf(args[j]), pf(args[j + 1]), pf(args[j + 2]), pf(args[j + 3]), pf(x), pf(y));
  21476. j += 6;
  21477. break;
  21478. case OPS.curveTo2:
  21479. x = args[j + 2];
  21480. y = args[j + 3];
  21481. d.push('C', pf(x), pf(y), pf(args[j]), pf(args[j + 1]), pf(args[j + 2]), pf(args[j + 3]));
  21482. j += 4;
  21483. break;
  21484. case OPS.curveTo3:
  21485. x = args[j + 2];
  21486. y = args[j + 3];
  21487. d.push('C', pf(args[j]), pf(args[j + 1]), pf(x), pf(y), pf(x), pf(y));
  21488. j += 4;
  21489. break;
  21490. case OPS.closePath:
  21491. d.push('Z');
  21492. break;
  21493. }
  21494. }
  21495. current.path.setAttributeNS(null, 'd', d.join(' '));
  21496. current.path.setAttributeNS(null, 'stroke-miterlimit', pf(current.miterLimit));
  21497. current.path.setAttributeNS(null, 'stroke-linecap', current.lineCap);
  21498. current.path.setAttributeNS(null, 'stroke-linejoin', current.lineJoin);
  21499. current.path.setAttributeNS(null, 'stroke-width', pf(current.lineWidth) + 'px');
  21500. current.path.setAttributeNS(null, 'stroke-dasharray', current.dashArray.map(pf).join(' '));
  21501. current.path.setAttributeNS(null, 'stroke-dashoffset', pf(current.dashPhase) + 'px');
  21502. current.path.setAttributeNS(null, 'fill', 'none');
  21503. this._ensureTransformGroup().appendChild(current.path);
  21504. current.element = current.path;
  21505. current.setCurrentPoint(x, y);
  21506. },
  21507. endPath: function SVGGraphics_endPath() {
  21508. },
  21509. clip: function SVGGraphics_clip(type) {
  21510. var current = this.current;
  21511. var clipId = 'clippath' + clipCount;
  21512. clipCount++;
  21513. var clipPath = document.createElementNS(NS, 'svg:clipPath');
  21514. clipPath.setAttributeNS(null, 'id', clipId);
  21515. clipPath.setAttributeNS(null, 'transform', pm(this.transformMatrix));
  21516. var clipElement = current.element.cloneNode();
  21517. if (type === 'evenodd') {
  21518. clipElement.setAttributeNS(null, 'clip-rule', 'evenodd');
  21519. } else {
  21520. clipElement.setAttributeNS(null, 'clip-rule', 'nonzero');
  21521. }
  21522. clipPath.appendChild(clipElement);
  21523. this.defs.appendChild(clipPath);
  21524. if (current.activeClipUrl) {
  21525. current.clipGroup = null;
  21526. this.extraStack.forEach(function (prev) {
  21527. prev.clipGroup = null;
  21528. });
  21529. }
  21530. current.activeClipUrl = 'url(#' + clipId + ')';
  21531. this.tgrp = null;
  21532. },
  21533. closePath: function SVGGraphics_closePath() {
  21534. var current = this.current;
  21535. var d = current.path.getAttributeNS(null, 'd');
  21536. d += 'Z';
  21537. current.path.setAttributeNS(null, 'd', d);
  21538. },
  21539. setLeading: function SVGGraphics_setLeading(leading) {
  21540. this.current.leading = -leading;
  21541. },
  21542. setTextRise: function SVGGraphics_setTextRise(textRise) {
  21543. this.current.textRise = textRise;
  21544. },
  21545. setHScale: function SVGGraphics_setHScale(scale) {
  21546. this.current.textHScale = scale / 100;
  21547. },
  21548. setGState: function SVGGraphics_setGState(states) {
  21549. for (var i = 0, ii = states.length; i < ii; i++) {
  21550. var state = states[i];
  21551. var key = state[0];
  21552. var value = state[1];
  21553. switch (key) {
  21554. case 'LW':
  21555. this.setLineWidth(value);
  21556. break;
  21557. case 'LC':
  21558. this.setLineCap(value);
  21559. break;
  21560. case 'LJ':
  21561. this.setLineJoin(value);
  21562. break;
  21563. case 'ML':
  21564. this.setMiterLimit(value);
  21565. break;
  21566. case 'D':
  21567. this.setDash(value[0], value[1]);
  21568. break;
  21569. case 'Font':
  21570. this.setFont(value);
  21571. break;
  21572. default:
  21573. warn('Unimplemented graphic state ' + key);
  21574. break;
  21575. }
  21576. }
  21577. },
  21578. fill: function SVGGraphics_fill() {
  21579. var current = this.current;
  21580. current.element.setAttributeNS(null, 'fill', current.fillColor);
  21581. },
  21582. stroke: function SVGGraphics_stroke() {
  21583. var current = this.current;
  21584. current.element.setAttributeNS(null, 'stroke', current.strokeColor);
  21585. current.element.setAttributeNS(null, 'fill', 'none');
  21586. },
  21587. eoFill: function SVGGraphics_eoFill() {
  21588. var current = this.current;
  21589. current.element.setAttributeNS(null, 'fill', current.fillColor);
  21590. current.element.setAttributeNS(null, 'fill-rule', 'evenodd');
  21591. },
  21592. fillStroke: function SVGGraphics_fillStroke() {
  21593. this.stroke();
  21594. this.fill();
  21595. },
  21596. eoFillStroke: function SVGGraphics_eoFillStroke() {
  21597. this.current.element.setAttributeNS(null, 'fill-rule', 'evenodd');
  21598. this.fillStroke();
  21599. },
  21600. closeStroke: function SVGGraphics_closeStroke() {
  21601. this.closePath();
  21602. this.stroke();
  21603. },
  21604. closeFillStroke: function SVGGraphics_closeFillStroke() {
  21605. this.closePath();
  21606. this.fillStroke();
  21607. },
  21608. paintSolidColorImageMask: function SVGGraphics_paintSolidColorImageMask() {
  21609. var current = this.current;
  21610. var rect = document.createElementNS(NS, 'svg:rect');
  21611. rect.setAttributeNS(null, 'x', '0');
  21612. rect.setAttributeNS(null, 'y', '0');
  21613. rect.setAttributeNS(null, 'width', '1px');
  21614. rect.setAttributeNS(null, 'height', '1px');
  21615. rect.setAttributeNS(null, 'fill', current.fillColor);
  21616. this._ensureTransformGroup().appendChild(rect);
  21617. },
  21618. paintJpegXObject: function SVGGraphics_paintJpegXObject(objId, w, h) {
  21619. var imgObj = this.objs.get(objId);
  21620. var imgEl = document.createElementNS(NS, 'svg:image');
  21621. imgEl.setAttributeNS(XLINK_NS, 'xlink:href', imgObj.src);
  21622. imgEl.setAttributeNS(null, 'width', imgObj.width + 'px');
  21623. imgEl.setAttributeNS(null, 'height', imgObj.height + 'px');
  21624. imgEl.setAttributeNS(null, 'x', '0');
  21625. imgEl.setAttributeNS(null, 'y', pf(-h));
  21626. imgEl.setAttributeNS(null, 'transform', 'scale(' + pf(1 / w) + ' ' + pf(-1 / h) + ')');
  21627. this._ensureTransformGroup().appendChild(imgEl);
  21628. },
  21629. paintImageXObject: function SVGGraphics_paintImageXObject(objId) {
  21630. var imgData = this.objs.get(objId);
  21631. if (!imgData) {
  21632. warn('Dependent image isn\'t ready yet');
  21633. return;
  21634. }
  21635. this.paintInlineImageXObject(imgData);
  21636. },
  21637. paintInlineImageXObject: function SVGGraphics_paintInlineImageXObject(imgData, mask) {
  21638. var width = imgData.width;
  21639. var height = imgData.height;
  21640. var imgSrc = convertImgDataToPng(imgData, this.forceDataSchema);
  21641. var cliprect = document.createElementNS(NS, 'svg:rect');
  21642. cliprect.setAttributeNS(null, 'x', '0');
  21643. cliprect.setAttributeNS(null, 'y', '0');
  21644. cliprect.setAttributeNS(null, 'width', pf(width));
  21645. cliprect.setAttributeNS(null, 'height', pf(height));
  21646. this.current.element = cliprect;
  21647. this.clip('nonzero');
  21648. var imgEl = document.createElementNS(NS, 'svg:image');
  21649. imgEl.setAttributeNS(XLINK_NS, 'xlink:href', imgSrc);
  21650. imgEl.setAttributeNS(null, 'x', '0');
  21651. imgEl.setAttributeNS(null, 'y', pf(-height));
  21652. imgEl.setAttributeNS(null, 'width', pf(width) + 'px');
  21653. imgEl.setAttributeNS(null, 'height', pf(height) + 'px');
  21654. imgEl.setAttributeNS(null, 'transform', 'scale(' + pf(1 / width) + ' ' + pf(-1 / height) + ')');
  21655. if (mask) {
  21656. mask.appendChild(imgEl);
  21657. } else {
  21658. this._ensureTransformGroup().appendChild(imgEl);
  21659. }
  21660. },
  21661. paintImageMaskXObject: function SVGGraphics_paintImageMaskXObject(imgData) {
  21662. var current = this.current;
  21663. var width = imgData.width;
  21664. var height = imgData.height;
  21665. var fillColor = current.fillColor;
  21666. current.maskId = 'mask' + maskCount++;
  21667. var mask = document.createElementNS(NS, 'svg:mask');
  21668. mask.setAttributeNS(null, 'id', current.maskId);
  21669. var rect = document.createElementNS(NS, 'svg:rect');
  21670. rect.setAttributeNS(null, 'x', '0');
  21671. rect.setAttributeNS(null, 'y', '0');
  21672. rect.setAttributeNS(null, 'width', pf(width));
  21673. rect.setAttributeNS(null, 'height', pf(height));
  21674. rect.setAttributeNS(null, 'fill', fillColor);
  21675. rect.setAttributeNS(null, 'mask', 'url(#' + current.maskId + ')');
  21676. this.defs.appendChild(mask);
  21677. this._ensureTransformGroup().appendChild(rect);
  21678. this.paintInlineImageXObject(imgData, mask);
  21679. },
  21680. paintFormXObjectBegin: function SVGGraphics_paintFormXObjectBegin(matrix, bbox) {
  21681. if (isArray(matrix) && matrix.length === 6) {
  21682. this.transform(matrix[0], matrix[1], matrix[2], matrix[3], matrix[4], matrix[5]);
  21683. }
  21684. if (isArray(bbox) && bbox.length === 4) {
  21685. var width = bbox[2] - bbox[0];
  21686. var height = bbox[3] - bbox[1];
  21687. var cliprect = document.createElementNS(NS, 'svg:rect');
  21688. cliprect.setAttributeNS(null, 'x', bbox[0]);
  21689. cliprect.setAttributeNS(null, 'y', bbox[1]);
  21690. cliprect.setAttributeNS(null, 'width', pf(width));
  21691. cliprect.setAttributeNS(null, 'height', pf(height));
  21692. this.current.element = cliprect;
  21693. this.clip('nonzero');
  21694. this.endPath();
  21695. }
  21696. },
  21697. paintFormXObjectEnd: function SVGGraphics_paintFormXObjectEnd() {
  21698. },
  21699. _initialize: function SVGGraphics_initialize(viewport) {
  21700. var svg = document.createElementNS(NS, 'svg:svg');
  21701. svg.setAttributeNS(null, 'version', '1.1');
  21702. svg.setAttributeNS(null, 'width', viewport.width + 'px');
  21703. svg.setAttributeNS(null, 'height', viewport.height + 'px');
  21704. svg.setAttributeNS(null, 'preserveAspectRatio', 'none');
  21705. svg.setAttributeNS(null, 'viewBox', '0 0 ' + viewport.width + ' ' + viewport.height);
  21706. var definitions = document.createElementNS(NS, 'svg:defs');
  21707. svg.appendChild(definitions);
  21708. this.defs = definitions;
  21709. var rootGroup = document.createElementNS(NS, 'svg:g');
  21710. rootGroup.setAttributeNS(null, 'transform', pm(viewport.transform));
  21711. svg.appendChild(rootGroup);
  21712. this.svg = rootGroup;
  21713. return svg;
  21714. },
  21715. _ensureClipGroup: function SVGGraphics_ensureClipGroup() {
  21716. if (!this.current.clipGroup) {
  21717. var clipGroup = document.createElementNS(NS, 'svg:g');
  21718. clipGroup.setAttributeNS(null, 'clip-path', this.current.activeClipUrl);
  21719. this.svg.appendChild(clipGroup);
  21720. this.current.clipGroup = clipGroup;
  21721. }
  21722. return this.current.clipGroup;
  21723. },
  21724. _ensureTransformGroup: function SVGGraphics_ensureTransformGroup() {
  21725. if (!this.tgrp) {
  21726. this.tgrp = document.createElementNS(NS, 'svg:g');
  21727. this.tgrp.setAttributeNS(null, 'transform', pm(this.transformMatrix));
  21728. if (this.current.activeClipUrl) {
  21729. this._ensureClipGroup().appendChild(this.tgrp);
  21730. } else {
  21731. this.svg.appendChild(this.tgrp);
  21732. }
  21733. }
  21734. return this.tgrp;
  21735. }
  21736. };
  21737. return SVGGraphics;
  21738. }();
  21739. exports.SVGGraphics = SVGGraphics;
  21740. /***/ }),
  21741. /* 12 */
  21742. /***/ (function(module, exports, __w_pdfjs_require__) {
  21743. "use strict";
  21744. var sharedUtil = __w_pdfjs_require__(0);
  21745. var displayDOMUtils = __w_pdfjs_require__(3);
  21746. var Util = sharedUtil.Util;
  21747. var createPromiseCapability = sharedUtil.createPromiseCapability;
  21748. var CustomStyle = displayDOMUtils.CustomStyle;
  21749. var getDefaultSetting = displayDOMUtils.getDefaultSetting;
  21750. var renderTextLayer = function renderTextLayerClosure() {
  21751. var MAX_TEXT_DIVS_TO_RENDER = 100000;
  21752. var NonWhitespaceRegexp = /\S/;
  21753. function isAllWhitespace(str) {
  21754. return !NonWhitespaceRegexp.test(str);
  21755. }
  21756. var styleBuf = [
  21757. 'left: ',
  21758. 0,
  21759. 'px; top: ',
  21760. 0,
  21761. 'px; font-size: ',
  21762. 0,
  21763. 'px; font-family: ',
  21764. '',
  21765. ';'
  21766. ];
  21767. function appendText(task, geom, styles) {
  21768. var textDiv = document.createElement('div');
  21769. var textDivProperties = {
  21770. style: null,
  21771. angle: 0,
  21772. canvasWidth: 0,
  21773. isWhitespace: false,
  21774. originalTransform: null,
  21775. paddingBottom: 0,
  21776. paddingLeft: 0,
  21777. paddingRight: 0,
  21778. paddingTop: 0,
  21779. scale: 1
  21780. };
  21781. task._textDivs.push(textDiv);
  21782. if (isAllWhitespace(geom.str)) {
  21783. textDivProperties.isWhitespace = true;
  21784. task._textDivProperties.set(textDiv, textDivProperties);
  21785. return;
  21786. }
  21787. var tx = Util.transform(task._viewport.transform, geom.transform);
  21788. var angle = Math.atan2(tx[1], tx[0]);
  21789. var style = styles[geom.fontName];
  21790. if (style.vertical) {
  21791. angle += Math.PI / 2;
  21792. }
  21793. var fontHeight = Math.sqrt(tx[2] * tx[2] + tx[3] * tx[3]);
  21794. var fontAscent = fontHeight;
  21795. if (style.ascent) {
  21796. fontAscent = style.ascent * fontAscent;
  21797. } else if (style.descent) {
  21798. fontAscent = (1 + style.descent) * fontAscent;
  21799. }
  21800. var left;
  21801. var top;
  21802. if (angle === 0) {
  21803. left = tx[4];
  21804. top = tx[5] - fontAscent;
  21805. } else {
  21806. left = tx[4] + fontAscent * Math.sin(angle);
  21807. top = tx[5] - fontAscent * Math.cos(angle);
  21808. }
  21809. styleBuf[1] = left;
  21810. styleBuf[3] = top;
  21811. styleBuf[5] = fontHeight;
  21812. styleBuf[7] = style.fontFamily;
  21813. textDivProperties.style = styleBuf.join('');
  21814. textDiv.setAttribute('style', textDivProperties.style);
  21815. textDiv.textContent = geom.str;
  21816. if (getDefaultSetting('pdfBug')) {
  21817. textDiv.dataset.fontName = geom.fontName;
  21818. }
  21819. if (angle !== 0) {
  21820. textDivProperties.angle = angle * (180 / Math.PI);
  21821. }
  21822. if (geom.str.length > 1) {
  21823. if (style.vertical) {
  21824. textDivProperties.canvasWidth = geom.height * task._viewport.scale;
  21825. } else {
  21826. textDivProperties.canvasWidth = geom.width * task._viewport.scale;
  21827. }
  21828. }
  21829. task._textDivProperties.set(textDiv, textDivProperties);
  21830. if (task._enhanceTextSelection) {
  21831. var angleCos = 1, angleSin = 0;
  21832. if (angle !== 0) {
  21833. angleCos = Math.cos(angle);
  21834. angleSin = Math.sin(angle);
  21835. }
  21836. var divWidth = (style.vertical ? geom.height : geom.width) * task._viewport.scale;
  21837. var divHeight = fontHeight;
  21838. var m, b;
  21839. if (angle !== 0) {
  21840. m = [
  21841. angleCos,
  21842. angleSin,
  21843. -angleSin,
  21844. angleCos,
  21845. left,
  21846. top
  21847. ];
  21848. b = Util.getAxialAlignedBoundingBox([
  21849. 0,
  21850. 0,
  21851. divWidth,
  21852. divHeight
  21853. ], m);
  21854. } else {
  21855. b = [
  21856. left,
  21857. top,
  21858. left + divWidth,
  21859. top + divHeight
  21860. ];
  21861. }
  21862. task._bounds.push({
  21863. left: b[0],
  21864. top: b[1],
  21865. right: b[2],
  21866. bottom: b[3],
  21867. div: textDiv,
  21868. size: [
  21869. divWidth,
  21870. divHeight
  21871. ],
  21872. m: m
  21873. });
  21874. }
  21875. }
  21876. function render(task) {
  21877. if (task._canceled) {
  21878. return;
  21879. }
  21880. var textLayerFrag = task._container;
  21881. var textDivs = task._textDivs;
  21882. var capability = task._capability;
  21883. var textDivsLength = textDivs.length;
  21884. if (textDivsLength > MAX_TEXT_DIVS_TO_RENDER) {
  21885. task._renderingDone = true;
  21886. capability.resolve();
  21887. return;
  21888. }
  21889. var canvas = document.createElement('canvas');
  21890. var ctx = canvas.getContext('2d', { alpha: false });
  21891. var lastFontSize;
  21892. var lastFontFamily;
  21893. for (var i = 0; i < textDivsLength; i++) {
  21894. var textDiv = textDivs[i];
  21895. var textDivProperties = task._textDivProperties.get(textDiv);
  21896. if (textDivProperties.isWhitespace) {
  21897. continue;
  21898. }
  21899. var fontSize = textDiv.style.fontSize;
  21900. var fontFamily = textDiv.style.fontFamily;
  21901. if (fontSize !== lastFontSize || fontFamily !== lastFontFamily) {
  21902. ctx.font = fontSize + ' ' + fontFamily;
  21903. lastFontSize = fontSize;
  21904. lastFontFamily = fontFamily;
  21905. }
  21906. var width = ctx.measureText(textDiv.textContent).width;
  21907. textLayerFrag.appendChild(textDiv);
  21908. var transform = '';
  21909. if (textDivProperties.canvasWidth !== 0 && width > 0) {
  21910. textDivProperties.scale = textDivProperties.canvasWidth / width;
  21911. transform = 'scaleX(' + textDivProperties.scale + ')';
  21912. }
  21913. if (textDivProperties.angle !== 0) {
  21914. transform = 'rotate(' + textDivProperties.angle + 'deg) ' + transform;
  21915. }
  21916. if (transform !== '') {
  21917. textDivProperties.originalTransform = transform;
  21918. CustomStyle.setProp('transform', textDiv, transform);
  21919. }
  21920. task._textDivProperties.set(textDiv, textDivProperties);
  21921. }
  21922. task._renderingDone = true;
  21923. capability.resolve();
  21924. }
  21925. function expand(task) {
  21926. var bounds = task._bounds;
  21927. var viewport = task._viewport;
  21928. var expanded = expandBounds(viewport.width, viewport.height, bounds);
  21929. for (var i = 0; i < expanded.length; i++) {
  21930. var div = bounds[i].div;
  21931. var divProperties = task._textDivProperties.get(div);
  21932. if (divProperties.angle === 0) {
  21933. divProperties.paddingLeft = bounds[i].left - expanded[i].left;
  21934. divProperties.paddingTop = bounds[i].top - expanded[i].top;
  21935. divProperties.paddingRight = expanded[i].right - bounds[i].right;
  21936. divProperties.paddingBottom = expanded[i].bottom - bounds[i].bottom;
  21937. task._textDivProperties.set(div, divProperties);
  21938. continue;
  21939. }
  21940. var e = expanded[i], b = bounds[i];
  21941. var m = b.m, c = m[0], s = m[1];
  21942. var points = [
  21943. [
  21944. 0,
  21945. 0
  21946. ],
  21947. [
  21948. 0,
  21949. b.size[1]
  21950. ],
  21951. [
  21952. b.size[0],
  21953. 0
  21954. ],
  21955. b.size
  21956. ];
  21957. var ts = new Float64Array(64);
  21958. points.forEach(function (p, i) {
  21959. var t = Util.applyTransform(p, m);
  21960. ts[i + 0] = c && (e.left - t[0]) / c;
  21961. ts[i + 4] = s && (e.top - t[1]) / s;
  21962. ts[i + 8] = c && (e.right - t[0]) / c;
  21963. ts[i + 12] = s && (e.bottom - t[1]) / s;
  21964. ts[i + 16] = s && (e.left - t[0]) / -s;
  21965. ts[i + 20] = c && (e.top - t[1]) / c;
  21966. ts[i + 24] = s && (e.right - t[0]) / -s;
  21967. ts[i + 28] = c && (e.bottom - t[1]) / c;
  21968. ts[i + 32] = c && (e.left - t[0]) / -c;
  21969. ts[i + 36] = s && (e.top - t[1]) / -s;
  21970. ts[i + 40] = c && (e.right - t[0]) / -c;
  21971. ts[i + 44] = s && (e.bottom - t[1]) / -s;
  21972. ts[i + 48] = s && (e.left - t[0]) / s;
  21973. ts[i + 52] = c && (e.top - t[1]) / -c;
  21974. ts[i + 56] = s && (e.right - t[0]) / s;
  21975. ts[i + 60] = c && (e.bottom - t[1]) / -c;
  21976. });
  21977. var findPositiveMin = function (ts, offset, count) {
  21978. var result = 0;
  21979. for (var i = 0; i < count; i++) {
  21980. var t = ts[offset++];
  21981. if (t > 0) {
  21982. result = result ? Math.min(t, result) : t;
  21983. }
  21984. }
  21985. return result;
  21986. };
  21987. var boxScale = 1 + Math.min(Math.abs(c), Math.abs(s));
  21988. divProperties.paddingLeft = findPositiveMin(ts, 32, 16) / boxScale;
  21989. divProperties.paddingTop = findPositiveMin(ts, 48, 16) / boxScale;
  21990. divProperties.paddingRight = findPositiveMin(ts, 0, 16) / boxScale;
  21991. divProperties.paddingBottom = findPositiveMin(ts, 16, 16) / boxScale;
  21992. task._textDivProperties.set(div, divProperties);
  21993. }
  21994. }
  21995. function expandBounds(width, height, boxes) {
  21996. var bounds = boxes.map(function (box, i) {
  21997. return {
  21998. x1: box.left,
  21999. y1: box.top,
  22000. x2: box.right,
  22001. y2: box.bottom,
  22002. index: i,
  22003. x1New: undefined,
  22004. x2New: undefined
  22005. };
  22006. });
  22007. expandBoundsLTR(width, bounds);
  22008. var expanded = new Array(boxes.length);
  22009. bounds.forEach(function (b) {
  22010. var i = b.index;
  22011. expanded[i] = {
  22012. left: b.x1New,
  22013. top: 0,
  22014. right: b.x2New,
  22015. bottom: 0
  22016. };
  22017. });
  22018. boxes.map(function (box, i) {
  22019. var e = expanded[i], b = bounds[i];
  22020. b.x1 = box.top;
  22021. b.y1 = width - e.right;
  22022. b.x2 = box.bottom;
  22023. b.y2 = width - e.left;
  22024. b.index = i;
  22025. b.x1New = undefined;
  22026. b.x2New = undefined;
  22027. });
  22028. expandBoundsLTR(height, bounds);
  22029. bounds.forEach(function (b) {
  22030. var i = b.index;
  22031. expanded[i].top = b.x1New;
  22032. expanded[i].bottom = b.x2New;
  22033. });
  22034. return expanded;
  22035. }
  22036. function expandBoundsLTR(width, bounds) {
  22037. bounds.sort(function (a, b) {
  22038. return a.x1 - b.x1 || a.index - b.index;
  22039. });
  22040. var fakeBoundary = {
  22041. x1: -Infinity,
  22042. y1: -Infinity,
  22043. x2: 0,
  22044. y2: Infinity,
  22045. index: -1,
  22046. x1New: 0,
  22047. x2New: 0
  22048. };
  22049. var horizon = [{
  22050. start: -Infinity,
  22051. end: Infinity,
  22052. boundary: fakeBoundary
  22053. }];
  22054. bounds.forEach(function (boundary) {
  22055. var i = 0;
  22056. while (i < horizon.length && horizon[i].end <= boundary.y1) {
  22057. i++;
  22058. }
  22059. var j = horizon.length - 1;
  22060. while (j >= 0 && horizon[j].start >= boundary.y2) {
  22061. j--;
  22062. }
  22063. var horizonPart, affectedBoundary;
  22064. var q, k, maxXNew = -Infinity;
  22065. for (q = i; q <= j; q++) {
  22066. horizonPart = horizon[q];
  22067. affectedBoundary = horizonPart.boundary;
  22068. var xNew;
  22069. if (affectedBoundary.x2 > boundary.x1) {
  22070. xNew = affectedBoundary.index > boundary.index ? affectedBoundary.x1New : boundary.x1;
  22071. } else if (affectedBoundary.x2New === undefined) {
  22072. xNew = (affectedBoundary.x2 + boundary.x1) / 2;
  22073. } else {
  22074. xNew = affectedBoundary.x2New;
  22075. }
  22076. if (xNew > maxXNew) {
  22077. maxXNew = xNew;
  22078. }
  22079. }
  22080. boundary.x1New = maxXNew;
  22081. for (q = i; q <= j; q++) {
  22082. horizonPart = horizon[q];
  22083. affectedBoundary = horizonPart.boundary;
  22084. if (affectedBoundary.x2New === undefined) {
  22085. if (affectedBoundary.x2 > boundary.x1) {
  22086. if (affectedBoundary.index > boundary.index) {
  22087. affectedBoundary.x2New = affectedBoundary.x2;
  22088. }
  22089. } else {
  22090. affectedBoundary.x2New = maxXNew;
  22091. }
  22092. } else if (affectedBoundary.x2New > maxXNew) {
  22093. affectedBoundary.x2New = Math.max(maxXNew, affectedBoundary.x2);
  22094. }
  22095. }
  22096. var changedHorizon = [], lastBoundary = null;
  22097. for (q = i; q <= j; q++) {
  22098. horizonPart = horizon[q];
  22099. affectedBoundary = horizonPart.boundary;
  22100. var useBoundary = affectedBoundary.x2 > boundary.x2 ? affectedBoundary : boundary;
  22101. if (lastBoundary === useBoundary) {
  22102. changedHorizon[changedHorizon.length - 1].end = horizonPart.end;
  22103. } else {
  22104. changedHorizon.push({
  22105. start: horizonPart.start,
  22106. end: horizonPart.end,
  22107. boundary: useBoundary
  22108. });
  22109. lastBoundary = useBoundary;
  22110. }
  22111. }
  22112. if (horizon[i].start < boundary.y1) {
  22113. changedHorizon[0].start = boundary.y1;
  22114. changedHorizon.unshift({
  22115. start: horizon[i].start,
  22116. end: boundary.y1,
  22117. boundary: horizon[i].boundary
  22118. });
  22119. }
  22120. if (boundary.y2 < horizon[j].end) {
  22121. changedHorizon[changedHorizon.length - 1].end = boundary.y2;
  22122. changedHorizon.push({
  22123. start: boundary.y2,
  22124. end: horizon[j].end,
  22125. boundary: horizon[j].boundary
  22126. });
  22127. }
  22128. for (q = i; q <= j; q++) {
  22129. horizonPart = horizon[q];
  22130. affectedBoundary = horizonPart.boundary;
  22131. if (affectedBoundary.x2New !== undefined) {
  22132. continue;
  22133. }
  22134. var used = false;
  22135. for (k = i - 1; !used && k >= 0 && horizon[k].start >= affectedBoundary.y1; k--) {
  22136. used = horizon[k].boundary === affectedBoundary;
  22137. }
  22138. for (k = j + 1; !used && k < horizon.length && horizon[k].end <= affectedBoundary.y2; k++) {
  22139. used = horizon[k].boundary === affectedBoundary;
  22140. }
  22141. for (k = 0; !used && k < changedHorizon.length; k++) {
  22142. used = changedHorizon[k].boundary === affectedBoundary;
  22143. }
  22144. if (!used) {
  22145. affectedBoundary.x2New = maxXNew;
  22146. }
  22147. }
  22148. Array.prototype.splice.apply(horizon, [
  22149. i,
  22150. j - i + 1
  22151. ].concat(changedHorizon));
  22152. });
  22153. horizon.forEach(function (horizonPart) {
  22154. var affectedBoundary = horizonPart.boundary;
  22155. if (affectedBoundary.x2New === undefined) {
  22156. affectedBoundary.x2New = Math.max(width, affectedBoundary.x2);
  22157. }
  22158. });
  22159. }
  22160. function TextLayerRenderTask(textContent, container, viewport, textDivs, enhanceTextSelection) {
  22161. this._textContent = textContent;
  22162. this._container = container;
  22163. this._viewport = viewport;
  22164. this._textDivs = textDivs || [];
  22165. this._textDivProperties = new WeakMap();
  22166. this._renderingDone = false;
  22167. this._canceled = false;
  22168. this._capability = createPromiseCapability();
  22169. this._renderTimer = null;
  22170. this._bounds = [];
  22171. this._enhanceTextSelection = !!enhanceTextSelection;
  22172. }
  22173. TextLayerRenderTask.prototype = {
  22174. get promise() {
  22175. return this._capability.promise;
  22176. },
  22177. cancel: function TextLayer_cancel() {
  22178. this._canceled = true;
  22179. if (this._renderTimer !== null) {
  22180. clearTimeout(this._renderTimer);
  22181. this._renderTimer = null;
  22182. }
  22183. this._capability.reject('canceled');
  22184. },
  22185. _render: function TextLayer_render(timeout) {
  22186. var textItems = this._textContent.items;
  22187. var textStyles = this._textContent.styles;
  22188. for (var i = 0, len = textItems.length; i < len; i++) {
  22189. appendText(this, textItems[i], textStyles);
  22190. }
  22191. if (!timeout) {
  22192. render(this);
  22193. } else {
  22194. var self = this;
  22195. this._renderTimer = setTimeout(function () {
  22196. render(self);
  22197. self._renderTimer = null;
  22198. }, timeout);
  22199. }
  22200. },
  22201. expandTextDivs: function TextLayer_expandTextDivs(expandDivs) {
  22202. if (!this._enhanceTextSelection || !this._renderingDone) {
  22203. return;
  22204. }
  22205. if (this._bounds !== null) {
  22206. expand(this);
  22207. this._bounds = null;
  22208. }
  22209. for (var i = 0, ii = this._textDivs.length; i < ii; i++) {
  22210. var div = this._textDivs[i];
  22211. var divProperties = this._textDivProperties.get(div);
  22212. if (divProperties.isWhitespace) {
  22213. continue;
  22214. }
  22215. if (expandDivs) {
  22216. var transform = '', padding = '';
  22217. if (divProperties.scale !== 1) {
  22218. transform = 'scaleX(' + divProperties.scale + ')';
  22219. }
  22220. if (divProperties.angle !== 0) {
  22221. transform = 'rotate(' + divProperties.angle + 'deg) ' + transform;
  22222. }
  22223. if (divProperties.paddingLeft !== 0) {
  22224. padding += ' padding-left: ' + divProperties.paddingLeft / divProperties.scale + 'px;';
  22225. transform += ' translateX(' + -divProperties.paddingLeft / divProperties.scale + 'px)';
  22226. }
  22227. if (divProperties.paddingTop !== 0) {
  22228. padding += ' padding-top: ' + divProperties.paddingTop + 'px;';
  22229. transform += ' translateY(' + -divProperties.paddingTop + 'px)';
  22230. }
  22231. if (divProperties.paddingRight !== 0) {
  22232. padding += ' padding-right: ' + divProperties.paddingRight / divProperties.scale + 'px;';
  22233. }
  22234. if (divProperties.paddingBottom !== 0) {
  22235. padding += ' padding-bottom: ' + divProperties.paddingBottom + 'px;';
  22236. }
  22237. if (padding !== '') {
  22238. div.setAttribute('style', divProperties.style + padding);
  22239. }
  22240. if (transform !== '') {
  22241. CustomStyle.setProp('transform', div, transform);
  22242. }
  22243. } else {
  22244. div.style.padding = 0;
  22245. CustomStyle.setProp('transform', div, divProperties.originalTransform || '');
  22246. }
  22247. }
  22248. }
  22249. };
  22250. function renderTextLayer(renderParameters) {
  22251. var task = new TextLayerRenderTask(renderParameters.textContent, renderParameters.container, renderParameters.viewport, renderParameters.textDivs, renderParameters.enhanceTextSelection);
  22252. task._render(renderParameters.timeout);
  22253. return task;
  22254. }
  22255. return renderTextLayer;
  22256. }();
  22257. exports.renderTextLayer = renderTextLayer;
  22258. /***/ }),
  22259. /* 13 */
  22260. /***/ (function(module, exports, __w_pdfjs_require__) {
  22261. "use strict";
  22262. var ArithmeticDecoder = function ArithmeticDecoderClosure() {
  22263. var QeTable = [
  22264. {
  22265. qe: 0x5601,
  22266. nmps: 1,
  22267. nlps: 1,
  22268. switchFlag: 1
  22269. },
  22270. {
  22271. qe: 0x3401,
  22272. nmps: 2,
  22273. nlps: 6,
  22274. switchFlag: 0
  22275. },
  22276. {
  22277. qe: 0x1801,
  22278. nmps: 3,
  22279. nlps: 9,
  22280. switchFlag: 0
  22281. },
  22282. {
  22283. qe: 0x0AC1,
  22284. nmps: 4,
  22285. nlps: 12,
  22286. switchFlag: 0
  22287. },
  22288. {
  22289. qe: 0x0521,
  22290. nmps: 5,
  22291. nlps: 29,
  22292. switchFlag: 0
  22293. },
  22294. {
  22295. qe: 0x0221,
  22296. nmps: 38,
  22297. nlps: 33,
  22298. switchFlag: 0
  22299. },
  22300. {
  22301. qe: 0x5601,
  22302. nmps: 7,
  22303. nlps: 6,
  22304. switchFlag: 1
  22305. },
  22306. {
  22307. qe: 0x5401,
  22308. nmps: 8,
  22309. nlps: 14,
  22310. switchFlag: 0
  22311. },
  22312. {
  22313. qe: 0x4801,
  22314. nmps: 9,
  22315. nlps: 14,
  22316. switchFlag: 0
  22317. },
  22318. {
  22319. qe: 0x3801,
  22320. nmps: 10,
  22321. nlps: 14,
  22322. switchFlag: 0
  22323. },
  22324. {
  22325. qe: 0x3001,
  22326. nmps: 11,
  22327. nlps: 17,
  22328. switchFlag: 0
  22329. },
  22330. {
  22331. qe: 0x2401,
  22332. nmps: 12,
  22333. nlps: 18,
  22334. switchFlag: 0
  22335. },
  22336. {
  22337. qe: 0x1C01,
  22338. nmps: 13,
  22339. nlps: 20,
  22340. switchFlag: 0
  22341. },
  22342. {
  22343. qe: 0x1601,
  22344. nmps: 29,
  22345. nlps: 21,
  22346. switchFlag: 0
  22347. },
  22348. {
  22349. qe: 0x5601,
  22350. nmps: 15,
  22351. nlps: 14,
  22352. switchFlag: 1
  22353. },
  22354. {
  22355. qe: 0x5401,
  22356. nmps: 16,
  22357. nlps: 14,
  22358. switchFlag: 0
  22359. },
  22360. {
  22361. qe: 0x5101,
  22362. nmps: 17,
  22363. nlps: 15,
  22364. switchFlag: 0
  22365. },
  22366. {
  22367. qe: 0x4801,
  22368. nmps: 18,
  22369. nlps: 16,
  22370. switchFlag: 0
  22371. },
  22372. {
  22373. qe: 0x3801,
  22374. nmps: 19,
  22375. nlps: 17,
  22376. switchFlag: 0
  22377. },
  22378. {
  22379. qe: 0x3401,
  22380. nmps: 20,
  22381. nlps: 18,
  22382. switchFlag: 0
  22383. },
  22384. {
  22385. qe: 0x3001,
  22386. nmps: 21,
  22387. nlps: 19,
  22388. switchFlag: 0
  22389. },
  22390. {
  22391. qe: 0x2801,
  22392. nmps: 22,
  22393. nlps: 19,
  22394. switchFlag: 0
  22395. },
  22396. {
  22397. qe: 0x2401,
  22398. nmps: 23,
  22399. nlps: 20,
  22400. switchFlag: 0
  22401. },
  22402. {
  22403. qe: 0x2201,
  22404. nmps: 24,
  22405. nlps: 21,
  22406. switchFlag: 0
  22407. },
  22408. {
  22409. qe: 0x1C01,
  22410. nmps: 25,
  22411. nlps: 22,
  22412. switchFlag: 0
  22413. },
  22414. {
  22415. qe: 0x1801,
  22416. nmps: 26,
  22417. nlps: 23,
  22418. switchFlag: 0
  22419. },
  22420. {
  22421. qe: 0x1601,
  22422. nmps: 27,
  22423. nlps: 24,
  22424. switchFlag: 0
  22425. },
  22426. {
  22427. qe: 0x1401,
  22428. nmps: 28,
  22429. nlps: 25,
  22430. switchFlag: 0
  22431. },
  22432. {
  22433. qe: 0x1201,
  22434. nmps: 29,
  22435. nlps: 26,
  22436. switchFlag: 0
  22437. },
  22438. {
  22439. qe: 0x1101,
  22440. nmps: 30,
  22441. nlps: 27,
  22442. switchFlag: 0
  22443. },
  22444. {
  22445. qe: 0x0AC1,
  22446. nmps: 31,
  22447. nlps: 28,
  22448. switchFlag: 0
  22449. },
  22450. {
  22451. qe: 0x09C1,
  22452. nmps: 32,
  22453. nlps: 29,
  22454. switchFlag: 0
  22455. },
  22456. {
  22457. qe: 0x08A1,
  22458. nmps: 33,
  22459. nlps: 30,
  22460. switchFlag: 0
  22461. },
  22462. {
  22463. qe: 0x0521,
  22464. nmps: 34,
  22465. nlps: 31,
  22466. switchFlag: 0
  22467. },
  22468. {
  22469. qe: 0x0441,
  22470. nmps: 35,
  22471. nlps: 32,
  22472. switchFlag: 0
  22473. },
  22474. {
  22475. qe: 0x02A1,
  22476. nmps: 36,
  22477. nlps: 33,
  22478. switchFlag: 0
  22479. },
  22480. {
  22481. qe: 0x0221,
  22482. nmps: 37,
  22483. nlps: 34,
  22484. switchFlag: 0
  22485. },
  22486. {
  22487. qe: 0x0141,
  22488. nmps: 38,
  22489. nlps: 35,
  22490. switchFlag: 0
  22491. },
  22492. {
  22493. qe: 0x0111,
  22494. nmps: 39,
  22495. nlps: 36,
  22496. switchFlag: 0
  22497. },
  22498. {
  22499. qe: 0x0085,
  22500. nmps: 40,
  22501. nlps: 37,
  22502. switchFlag: 0
  22503. },
  22504. {
  22505. qe: 0x0049,
  22506. nmps: 41,
  22507. nlps: 38,
  22508. switchFlag: 0
  22509. },
  22510. {
  22511. qe: 0x0025,
  22512. nmps: 42,
  22513. nlps: 39,
  22514. switchFlag: 0
  22515. },
  22516. {
  22517. qe: 0x0015,
  22518. nmps: 43,
  22519. nlps: 40,
  22520. switchFlag: 0
  22521. },
  22522. {
  22523. qe: 0x0009,
  22524. nmps: 44,
  22525. nlps: 41,
  22526. switchFlag: 0
  22527. },
  22528. {
  22529. qe: 0x0005,
  22530. nmps: 45,
  22531. nlps: 42,
  22532. switchFlag: 0
  22533. },
  22534. {
  22535. qe: 0x0001,
  22536. nmps: 45,
  22537. nlps: 43,
  22538. switchFlag: 0
  22539. },
  22540. {
  22541. qe: 0x5601,
  22542. nmps: 46,
  22543. nlps: 46,
  22544. switchFlag: 0
  22545. }
  22546. ];
  22547. function ArithmeticDecoder(data, start, end) {
  22548. this.data = data;
  22549. this.bp = start;
  22550. this.dataEnd = end;
  22551. this.chigh = data[start];
  22552. this.clow = 0;
  22553. this.byteIn();
  22554. this.chigh = this.chigh << 7 & 0xFFFF | this.clow >> 9 & 0x7F;
  22555. this.clow = this.clow << 7 & 0xFFFF;
  22556. this.ct -= 7;
  22557. this.a = 0x8000;
  22558. }
  22559. ArithmeticDecoder.prototype = {
  22560. byteIn: function ArithmeticDecoder_byteIn() {
  22561. var data = this.data;
  22562. var bp = this.bp;
  22563. if (data[bp] === 0xFF) {
  22564. var b1 = data[bp + 1];
  22565. if (b1 > 0x8F) {
  22566. this.clow += 0xFF00;
  22567. this.ct = 8;
  22568. } else {
  22569. bp++;
  22570. this.clow += data[bp] << 9;
  22571. this.ct = 7;
  22572. this.bp = bp;
  22573. }
  22574. } else {
  22575. bp++;
  22576. this.clow += bp < this.dataEnd ? data[bp] << 8 : 0xFF00;
  22577. this.ct = 8;
  22578. this.bp = bp;
  22579. }
  22580. if (this.clow > 0xFFFF) {
  22581. this.chigh += this.clow >> 16;
  22582. this.clow &= 0xFFFF;
  22583. }
  22584. },
  22585. readBit: function ArithmeticDecoder_readBit(contexts, pos) {
  22586. var cx_index = contexts[pos] >> 1, cx_mps = contexts[pos] & 1;
  22587. var qeTableIcx = QeTable[cx_index];
  22588. var qeIcx = qeTableIcx.qe;
  22589. var d;
  22590. var a = this.a - qeIcx;
  22591. if (this.chigh < qeIcx) {
  22592. if (a < qeIcx) {
  22593. a = qeIcx;
  22594. d = cx_mps;
  22595. cx_index = qeTableIcx.nmps;
  22596. } else {
  22597. a = qeIcx;
  22598. d = 1 ^ cx_mps;
  22599. if (qeTableIcx.switchFlag === 1) {
  22600. cx_mps = d;
  22601. }
  22602. cx_index = qeTableIcx.nlps;
  22603. }
  22604. } else {
  22605. this.chigh -= qeIcx;
  22606. if ((a & 0x8000) !== 0) {
  22607. this.a = a;
  22608. return cx_mps;
  22609. }
  22610. if (a < qeIcx) {
  22611. d = 1 ^ cx_mps;
  22612. if (qeTableIcx.switchFlag === 1) {
  22613. cx_mps = d;
  22614. }
  22615. cx_index = qeTableIcx.nlps;
  22616. } else {
  22617. d = cx_mps;
  22618. cx_index = qeTableIcx.nmps;
  22619. }
  22620. }
  22621. do {
  22622. if (this.ct === 0) {
  22623. this.byteIn();
  22624. }
  22625. a <<= 1;
  22626. this.chigh = this.chigh << 1 & 0xFFFF | this.clow >> 15 & 1;
  22627. this.clow = this.clow << 1 & 0xFFFF;
  22628. this.ct--;
  22629. } while ((a & 0x8000) === 0);
  22630. this.a = a;
  22631. contexts[pos] = cx_index << 1 | cx_mps;
  22632. return d;
  22633. }
  22634. };
  22635. return ArithmeticDecoder;
  22636. }();
  22637. exports.ArithmeticDecoder = ArithmeticDecoder;
  22638. /***/ }),
  22639. /* 14 */
  22640. /***/ (function(module, exports, __w_pdfjs_require__) {
  22641. "use strict";
  22642. var sharedUtil = __w_pdfjs_require__(0);
  22643. var coreCharsets = __w_pdfjs_require__(29);
  22644. var coreEncodings = __w_pdfjs_require__(5);
  22645. var error = sharedUtil.error;
  22646. var info = sharedUtil.info;
  22647. var bytesToString = sharedUtil.bytesToString;
  22648. var warn = sharedUtil.warn;
  22649. var isArray = sharedUtil.isArray;
  22650. var Util = sharedUtil.Util;
  22651. var stringToBytes = sharedUtil.stringToBytes;
  22652. var assert = sharedUtil.assert;
  22653. var ISOAdobeCharset = coreCharsets.ISOAdobeCharset;
  22654. var ExpertCharset = coreCharsets.ExpertCharset;
  22655. var ExpertSubsetCharset = coreCharsets.ExpertSubsetCharset;
  22656. var StandardEncoding = coreEncodings.StandardEncoding;
  22657. var ExpertEncoding = coreEncodings.ExpertEncoding;
  22658. var MAX_SUBR_NESTING = 10;
  22659. var CFFStandardStrings = [
  22660. '.notdef',
  22661. 'space',
  22662. 'exclam',
  22663. 'quotedbl',
  22664. 'numbersign',
  22665. 'dollar',
  22666. 'percent',
  22667. 'ampersand',
  22668. 'quoteright',
  22669. 'parenleft',
  22670. 'parenright',
  22671. 'asterisk',
  22672. 'plus',
  22673. 'comma',
  22674. 'hyphen',
  22675. 'period',
  22676. 'slash',
  22677. 'zero',
  22678. 'one',
  22679. 'two',
  22680. 'three',
  22681. 'four',
  22682. 'five',
  22683. 'six',
  22684. 'seven',
  22685. 'eight',
  22686. 'nine',
  22687. 'colon',
  22688. 'semicolon',
  22689. 'less',
  22690. 'equal',
  22691. 'greater',
  22692. 'question',
  22693. 'at',
  22694. 'A',
  22695. 'B',
  22696. 'C',
  22697. 'D',
  22698. 'E',
  22699. 'F',
  22700. 'G',
  22701. 'H',
  22702. 'I',
  22703. 'J',
  22704. 'K',
  22705. 'L',
  22706. 'M',
  22707. 'N',
  22708. 'O',
  22709. 'P',
  22710. 'Q',
  22711. 'R',
  22712. 'S',
  22713. 'T',
  22714. 'U',
  22715. 'V',
  22716. 'W',
  22717. 'X',
  22718. 'Y',
  22719. 'Z',
  22720. 'bracketleft',
  22721. 'backslash',
  22722. 'bracketright',
  22723. 'asciicircum',
  22724. 'underscore',
  22725. 'quoteleft',
  22726. 'a',
  22727. 'b',
  22728. 'c',
  22729. 'd',
  22730. 'e',
  22731. 'f',
  22732. 'g',
  22733. 'h',
  22734. 'i',
  22735. 'j',
  22736. 'k',
  22737. 'l',
  22738. 'm',
  22739. 'n',
  22740. 'o',
  22741. 'p',
  22742. 'q',
  22743. 'r',
  22744. 's',
  22745. 't',
  22746. 'u',
  22747. 'v',
  22748. 'w',
  22749. 'x',
  22750. 'y',
  22751. 'z',
  22752. 'braceleft',
  22753. 'bar',
  22754. 'braceright',
  22755. 'asciitilde',
  22756. 'exclamdown',
  22757. 'cent',
  22758. 'sterling',
  22759. 'fraction',
  22760. 'yen',
  22761. 'florin',
  22762. 'section',
  22763. 'currency',
  22764. 'quotesingle',
  22765. 'quotedblleft',
  22766. 'guillemotleft',
  22767. 'guilsinglleft',
  22768. 'guilsinglright',
  22769. 'fi',
  22770. 'fl',
  22771. 'endash',
  22772. 'dagger',
  22773. 'daggerdbl',
  22774. 'periodcentered',
  22775. 'paragraph',
  22776. 'bullet',
  22777. 'quotesinglbase',
  22778. 'quotedblbase',
  22779. 'quotedblright',
  22780. 'guillemotright',
  22781. 'ellipsis',
  22782. 'perthousand',
  22783. 'questiondown',
  22784. 'grave',
  22785. 'acute',
  22786. 'circumflex',
  22787. 'tilde',
  22788. 'macron',
  22789. 'breve',
  22790. 'dotaccent',
  22791. 'dieresis',
  22792. 'ring',
  22793. 'cedilla',
  22794. 'hungarumlaut',
  22795. 'ogonek',
  22796. 'caron',
  22797. 'emdash',
  22798. 'AE',
  22799. 'ordfeminine',
  22800. 'Lslash',
  22801. 'Oslash',
  22802. 'OE',
  22803. 'ordmasculine',
  22804. 'ae',
  22805. 'dotlessi',
  22806. 'lslash',
  22807. 'oslash',
  22808. 'oe',
  22809. 'germandbls',
  22810. 'onesuperior',
  22811. 'logicalnot',
  22812. 'mu',
  22813. 'trademark',
  22814. 'Eth',
  22815. 'onehalf',
  22816. 'plusminus',
  22817. 'Thorn',
  22818. 'onequarter',
  22819. 'divide',
  22820. 'brokenbar',
  22821. 'degree',
  22822. 'thorn',
  22823. 'threequarters',
  22824. 'twosuperior',
  22825. 'registered',
  22826. 'minus',
  22827. 'eth',
  22828. 'multiply',
  22829. 'threesuperior',
  22830. 'copyright',
  22831. 'Aacute',
  22832. 'Acircumflex',
  22833. 'Adieresis',
  22834. 'Agrave',
  22835. 'Aring',
  22836. 'Atilde',
  22837. 'Ccedilla',
  22838. 'Eacute',
  22839. 'Ecircumflex',
  22840. 'Edieresis',
  22841. 'Egrave',
  22842. 'Iacute',
  22843. 'Icircumflex',
  22844. 'Idieresis',
  22845. 'Igrave',
  22846. 'Ntilde',
  22847. 'Oacute',
  22848. 'Ocircumflex',
  22849. 'Odieresis',
  22850. 'Ograve',
  22851. 'Otilde',
  22852. 'Scaron',
  22853. 'Uacute',
  22854. 'Ucircumflex',
  22855. 'Udieresis',
  22856. 'Ugrave',
  22857. 'Yacute',
  22858. 'Ydieresis',
  22859. 'Zcaron',
  22860. 'aacute',
  22861. 'acircumflex',
  22862. 'adieresis',
  22863. 'agrave',
  22864. 'aring',
  22865. 'atilde',
  22866. 'ccedilla',
  22867. 'eacute',
  22868. 'ecircumflex',
  22869. 'edieresis',
  22870. 'egrave',
  22871. 'iacute',
  22872. 'icircumflex',
  22873. 'idieresis',
  22874. 'igrave',
  22875. 'ntilde',
  22876. 'oacute',
  22877. 'ocircumflex',
  22878. 'odieresis',
  22879. 'ograve',
  22880. 'otilde',
  22881. 'scaron',
  22882. 'uacute',
  22883. 'ucircumflex',
  22884. 'udieresis',
  22885. 'ugrave',
  22886. 'yacute',
  22887. 'ydieresis',
  22888. 'zcaron',
  22889. 'exclamsmall',
  22890. 'Hungarumlautsmall',
  22891. 'dollaroldstyle',
  22892. 'dollarsuperior',
  22893. 'ampersandsmall',
  22894. 'Acutesmall',
  22895. 'parenleftsuperior',
  22896. 'parenrightsuperior',
  22897. 'twodotenleader',
  22898. 'onedotenleader',
  22899. 'zerooldstyle',
  22900. 'oneoldstyle',
  22901. 'twooldstyle',
  22902. 'threeoldstyle',
  22903. 'fouroldstyle',
  22904. 'fiveoldstyle',
  22905. 'sixoldstyle',
  22906. 'sevenoldstyle',
  22907. 'eightoldstyle',
  22908. 'nineoldstyle',
  22909. 'commasuperior',
  22910. 'threequartersemdash',
  22911. 'periodsuperior',
  22912. 'questionsmall',
  22913. 'asuperior',
  22914. 'bsuperior',
  22915. 'centsuperior',
  22916. 'dsuperior',
  22917. 'esuperior',
  22918. 'isuperior',
  22919. 'lsuperior',
  22920. 'msuperior',
  22921. 'nsuperior',
  22922. 'osuperior',
  22923. 'rsuperior',
  22924. 'ssuperior',
  22925. 'tsuperior',
  22926. 'ff',
  22927. 'ffi',
  22928. 'ffl',
  22929. 'parenleftinferior',
  22930. 'parenrightinferior',
  22931. 'Circumflexsmall',
  22932. 'hyphensuperior',
  22933. 'Gravesmall',
  22934. 'Asmall',
  22935. 'Bsmall',
  22936. 'Csmall',
  22937. 'Dsmall',
  22938. 'Esmall',
  22939. 'Fsmall',
  22940. 'Gsmall',
  22941. 'Hsmall',
  22942. 'Ismall',
  22943. 'Jsmall',
  22944. 'Ksmall',
  22945. 'Lsmall',
  22946. 'Msmall',
  22947. 'Nsmall',
  22948. 'Osmall',
  22949. 'Psmall',
  22950. 'Qsmall',
  22951. 'Rsmall',
  22952. 'Ssmall',
  22953. 'Tsmall',
  22954. 'Usmall',
  22955. 'Vsmall',
  22956. 'Wsmall',
  22957. 'Xsmall',
  22958. 'Ysmall',
  22959. 'Zsmall',
  22960. 'colonmonetary',
  22961. 'onefitted',
  22962. 'rupiah',
  22963. 'Tildesmall',
  22964. 'exclamdownsmall',
  22965. 'centoldstyle',
  22966. 'Lslashsmall',
  22967. 'Scaronsmall',
  22968. 'Zcaronsmall',
  22969. 'Dieresissmall',
  22970. 'Brevesmall',
  22971. 'Caronsmall',
  22972. 'Dotaccentsmall',
  22973. 'Macronsmall',
  22974. 'figuredash',
  22975. 'hypheninferior',
  22976. 'Ogoneksmall',
  22977. 'Ringsmall',
  22978. 'Cedillasmall',
  22979. 'questiondownsmall',
  22980. 'oneeighth',
  22981. 'threeeighths',
  22982. 'fiveeighths',
  22983. 'seveneighths',
  22984. 'onethird',
  22985. 'twothirds',
  22986. 'zerosuperior',
  22987. 'foursuperior',
  22988. 'fivesuperior',
  22989. 'sixsuperior',
  22990. 'sevensuperior',
  22991. 'eightsuperior',
  22992. 'ninesuperior',
  22993. 'zeroinferior',
  22994. 'oneinferior',
  22995. 'twoinferior',
  22996. 'threeinferior',
  22997. 'fourinferior',
  22998. 'fiveinferior',
  22999. 'sixinferior',
  23000. 'seveninferior',
  23001. 'eightinferior',
  23002. 'nineinferior',
  23003. 'centinferior',
  23004. 'dollarinferior',
  23005. 'periodinferior',
  23006. 'commainferior',
  23007. 'Agravesmall',
  23008. 'Aacutesmall',
  23009. 'Acircumflexsmall',
  23010. 'Atildesmall',
  23011. 'Adieresissmall',
  23012. 'Aringsmall',
  23013. 'AEsmall',
  23014. 'Ccedillasmall',
  23015. 'Egravesmall',
  23016. 'Eacutesmall',
  23017. 'Ecircumflexsmall',
  23018. 'Edieresissmall',
  23019. 'Igravesmall',
  23020. 'Iacutesmall',
  23021. 'Icircumflexsmall',
  23022. 'Idieresissmall',
  23023. 'Ethsmall',
  23024. 'Ntildesmall',
  23025. 'Ogravesmall',
  23026. 'Oacutesmall',
  23027. 'Ocircumflexsmall',
  23028. 'Otildesmall',
  23029. 'Odieresissmall',
  23030. 'OEsmall',
  23031. 'Oslashsmall',
  23032. 'Ugravesmall',
  23033. 'Uacutesmall',
  23034. 'Ucircumflexsmall',
  23035. 'Udieresissmall',
  23036. 'Yacutesmall',
  23037. 'Thornsmall',
  23038. 'Ydieresissmall',
  23039. '001.000',
  23040. '001.001',
  23041. '001.002',
  23042. '001.003',
  23043. 'Black',
  23044. 'Bold',
  23045. 'Book',
  23046. 'Light',
  23047. 'Medium',
  23048. 'Regular',
  23049. 'Roman',
  23050. 'Semibold'
  23051. ];
  23052. var CFFParser = function CFFParserClosure() {
  23053. var CharstringValidationData = [
  23054. null,
  23055. {
  23056. id: 'hstem',
  23057. min: 2,
  23058. stackClearing: true,
  23059. stem: true
  23060. },
  23061. null,
  23062. {
  23063. id: 'vstem',
  23064. min: 2,
  23065. stackClearing: true,
  23066. stem: true
  23067. },
  23068. {
  23069. id: 'vmoveto',
  23070. min: 1,
  23071. stackClearing: true
  23072. },
  23073. {
  23074. id: 'rlineto',
  23075. min: 2,
  23076. resetStack: true
  23077. },
  23078. {
  23079. id: 'hlineto',
  23080. min: 1,
  23081. resetStack: true
  23082. },
  23083. {
  23084. id: 'vlineto',
  23085. min: 1,
  23086. resetStack: true
  23087. },
  23088. {
  23089. id: 'rrcurveto',
  23090. min: 6,
  23091. resetStack: true
  23092. },
  23093. null,
  23094. {
  23095. id: 'callsubr',
  23096. min: 1,
  23097. undefStack: true
  23098. },
  23099. {
  23100. id: 'return',
  23101. min: 0,
  23102. undefStack: true
  23103. },
  23104. null,
  23105. null,
  23106. {
  23107. id: 'endchar',
  23108. min: 0,
  23109. stackClearing: true
  23110. },
  23111. null,
  23112. null,
  23113. null,
  23114. {
  23115. id: 'hstemhm',
  23116. min: 2,
  23117. stackClearing: true,
  23118. stem: true
  23119. },
  23120. {
  23121. id: 'hintmask',
  23122. min: 0,
  23123. stackClearing: true
  23124. },
  23125. {
  23126. id: 'cntrmask',
  23127. min: 0,
  23128. stackClearing: true
  23129. },
  23130. {
  23131. id: 'rmoveto',
  23132. min: 2,
  23133. stackClearing: true
  23134. },
  23135. {
  23136. id: 'hmoveto',
  23137. min: 1,
  23138. stackClearing: true
  23139. },
  23140. {
  23141. id: 'vstemhm',
  23142. min: 2,
  23143. stackClearing: true,
  23144. stem: true
  23145. },
  23146. {
  23147. id: 'rcurveline',
  23148. min: 8,
  23149. resetStack: true
  23150. },
  23151. {
  23152. id: 'rlinecurve',
  23153. min: 8,
  23154. resetStack: true
  23155. },
  23156. {
  23157. id: 'vvcurveto',
  23158. min: 4,
  23159. resetStack: true
  23160. },
  23161. {
  23162. id: 'hhcurveto',
  23163. min: 4,
  23164. resetStack: true
  23165. },
  23166. null,
  23167. {
  23168. id: 'callgsubr',
  23169. min: 1,
  23170. undefStack: true
  23171. },
  23172. {
  23173. id: 'vhcurveto',
  23174. min: 4,
  23175. resetStack: true
  23176. },
  23177. {
  23178. id: 'hvcurveto',
  23179. min: 4,
  23180. resetStack: true
  23181. }
  23182. ];
  23183. var CharstringValidationData12 = [
  23184. null,
  23185. null,
  23186. null,
  23187. {
  23188. id: 'and',
  23189. min: 2,
  23190. stackDelta: -1
  23191. },
  23192. {
  23193. id: 'or',
  23194. min: 2,
  23195. stackDelta: -1
  23196. },
  23197. {
  23198. id: 'not',
  23199. min: 1,
  23200. stackDelta: 0
  23201. },
  23202. null,
  23203. null,
  23204. null,
  23205. {
  23206. id: 'abs',
  23207. min: 1,
  23208. stackDelta: 0
  23209. },
  23210. {
  23211. id: 'add',
  23212. min: 2,
  23213. stackDelta: -1,
  23214. stackFn: function stack_div(stack, index) {
  23215. stack[index - 2] = stack[index - 2] + stack[index - 1];
  23216. }
  23217. },
  23218. {
  23219. id: 'sub',
  23220. min: 2,
  23221. stackDelta: -1,
  23222. stackFn: function stack_div(stack, index) {
  23223. stack[index - 2] = stack[index - 2] - stack[index - 1];
  23224. }
  23225. },
  23226. {
  23227. id: 'div',
  23228. min: 2,
  23229. stackDelta: -1,
  23230. stackFn: function stack_div(stack, index) {
  23231. stack[index - 2] = stack[index - 2] / stack[index - 1];
  23232. }
  23233. },
  23234. null,
  23235. {
  23236. id: 'neg',
  23237. min: 1,
  23238. stackDelta: 0,
  23239. stackFn: function stack_div(stack, index) {
  23240. stack[index - 1] = -stack[index - 1];
  23241. }
  23242. },
  23243. {
  23244. id: 'eq',
  23245. min: 2,
  23246. stackDelta: -1
  23247. },
  23248. null,
  23249. null,
  23250. {
  23251. id: 'drop',
  23252. min: 1,
  23253. stackDelta: -1
  23254. },
  23255. null,
  23256. {
  23257. id: 'put',
  23258. min: 2,
  23259. stackDelta: -2
  23260. },
  23261. {
  23262. id: 'get',
  23263. min: 1,
  23264. stackDelta: 0
  23265. },
  23266. {
  23267. id: 'ifelse',
  23268. min: 4,
  23269. stackDelta: -3
  23270. },
  23271. {
  23272. id: 'random',
  23273. min: 0,
  23274. stackDelta: 1
  23275. },
  23276. {
  23277. id: 'mul',
  23278. min: 2,
  23279. stackDelta: -1,
  23280. stackFn: function stack_div(stack, index) {
  23281. stack[index - 2] = stack[index - 2] * stack[index - 1];
  23282. }
  23283. },
  23284. null,
  23285. {
  23286. id: 'sqrt',
  23287. min: 1,
  23288. stackDelta: 0
  23289. },
  23290. {
  23291. id: 'dup',
  23292. min: 1,
  23293. stackDelta: 1
  23294. },
  23295. {
  23296. id: 'exch',
  23297. min: 2,
  23298. stackDelta: 0
  23299. },
  23300. {
  23301. id: 'index',
  23302. min: 2,
  23303. stackDelta: 0
  23304. },
  23305. {
  23306. id: 'roll',
  23307. min: 3,
  23308. stackDelta: -2
  23309. },
  23310. null,
  23311. null,
  23312. null,
  23313. {
  23314. id: 'hflex',
  23315. min: 7,
  23316. resetStack: true
  23317. },
  23318. {
  23319. id: 'flex',
  23320. min: 13,
  23321. resetStack: true
  23322. },
  23323. {
  23324. id: 'hflex1',
  23325. min: 9,
  23326. resetStack: true
  23327. },
  23328. {
  23329. id: 'flex1',
  23330. min: 11,
  23331. resetStack: true
  23332. }
  23333. ];
  23334. function CFFParser(file, properties, seacAnalysisEnabled) {
  23335. this.bytes = file.getBytes();
  23336. this.properties = properties;
  23337. this.seacAnalysisEnabled = !!seacAnalysisEnabled;
  23338. }
  23339. CFFParser.prototype = {
  23340. parse: function CFFParser_parse() {
  23341. var properties = this.properties;
  23342. var cff = new CFF();
  23343. this.cff = cff;
  23344. var header = this.parseHeader();
  23345. var nameIndex = this.parseIndex(header.endPos);
  23346. var topDictIndex = this.parseIndex(nameIndex.endPos);
  23347. var stringIndex = this.parseIndex(topDictIndex.endPos);
  23348. var globalSubrIndex = this.parseIndex(stringIndex.endPos);
  23349. var topDictParsed = this.parseDict(topDictIndex.obj.get(0));
  23350. var topDict = this.createDict(CFFTopDict, topDictParsed, cff.strings);
  23351. cff.header = header.obj;
  23352. cff.names = this.parseNameIndex(nameIndex.obj);
  23353. cff.strings = this.parseStringIndex(stringIndex.obj);
  23354. cff.topDict = topDict;
  23355. cff.globalSubrIndex = globalSubrIndex.obj;
  23356. this.parsePrivateDict(cff.topDict);
  23357. cff.isCIDFont = topDict.hasName('ROS');
  23358. var charStringOffset = topDict.getByName('CharStrings');
  23359. var charStringIndex = this.parseIndex(charStringOffset).obj;
  23360. var fontMatrix = topDict.getByName('FontMatrix');
  23361. if (fontMatrix) {
  23362. properties.fontMatrix = fontMatrix;
  23363. }
  23364. var fontBBox = topDict.getByName('FontBBox');
  23365. if (fontBBox) {
  23366. properties.ascent = Math.max(fontBBox[3], fontBBox[1]);
  23367. properties.descent = Math.min(fontBBox[1], fontBBox[3]);
  23368. properties.ascentScaled = true;
  23369. }
  23370. var charset, encoding;
  23371. if (cff.isCIDFont) {
  23372. var fdArrayIndex = this.parseIndex(topDict.getByName('FDArray')).obj;
  23373. for (var i = 0, ii = fdArrayIndex.count; i < ii; ++i) {
  23374. var dictRaw = fdArrayIndex.get(i);
  23375. var fontDict = this.createDict(CFFTopDict, this.parseDict(dictRaw), cff.strings);
  23376. this.parsePrivateDict(fontDict);
  23377. cff.fdArray.push(fontDict);
  23378. }
  23379. encoding = null;
  23380. charset = this.parseCharsets(topDict.getByName('charset'), charStringIndex.count, cff.strings, true);
  23381. cff.fdSelect = this.parseFDSelect(topDict.getByName('FDSelect'), charStringIndex.count);
  23382. } else {
  23383. charset = this.parseCharsets(topDict.getByName('charset'), charStringIndex.count, cff.strings, false);
  23384. encoding = this.parseEncoding(topDict.getByName('Encoding'), properties, cff.strings, charset.charset);
  23385. }
  23386. cff.charset = charset;
  23387. cff.encoding = encoding;
  23388. var charStringsAndSeacs = this.parseCharStrings(charStringIndex, topDict.privateDict.subrsIndex, globalSubrIndex.obj, cff.fdSelect, cff.fdArray);
  23389. cff.charStrings = charStringsAndSeacs.charStrings;
  23390. cff.seacs = charStringsAndSeacs.seacs;
  23391. cff.widths = charStringsAndSeacs.widths;
  23392. return cff;
  23393. },
  23394. parseHeader: function CFFParser_parseHeader() {
  23395. var bytes = this.bytes;
  23396. var bytesLength = bytes.length;
  23397. var offset = 0;
  23398. while (offset < bytesLength && bytes[offset] !== 1) {
  23399. ++offset;
  23400. }
  23401. if (offset >= bytesLength) {
  23402. error('Invalid CFF header');
  23403. } else if (offset !== 0) {
  23404. info('cff data is shifted');
  23405. bytes = bytes.subarray(offset);
  23406. this.bytes = bytes;
  23407. }
  23408. var major = bytes[0];
  23409. var minor = bytes[1];
  23410. var hdrSize = bytes[2];
  23411. var offSize = bytes[3];
  23412. var header = new CFFHeader(major, minor, hdrSize, offSize);
  23413. return {
  23414. obj: header,
  23415. endPos: hdrSize
  23416. };
  23417. },
  23418. parseDict: function CFFParser_parseDict(dict) {
  23419. var pos = 0;
  23420. function parseOperand() {
  23421. var value = dict[pos++];
  23422. if (value === 30) {
  23423. return parseFloatOperand();
  23424. } else if (value === 28) {
  23425. value = dict[pos++];
  23426. value = (value << 24 | dict[pos++] << 16) >> 16;
  23427. return value;
  23428. } else if (value === 29) {
  23429. value = dict[pos++];
  23430. value = value << 8 | dict[pos++];
  23431. value = value << 8 | dict[pos++];
  23432. value = value << 8 | dict[pos++];
  23433. return value;
  23434. } else if (value >= 32 && value <= 246) {
  23435. return value - 139;
  23436. } else if (value >= 247 && value <= 250) {
  23437. return (value - 247) * 256 + dict[pos++] + 108;
  23438. } else if (value >= 251 && value <= 254) {
  23439. return -((value - 251) * 256) - dict[pos++] - 108;
  23440. }
  23441. warn('CFFParser_parseDict: "' + value + '" is a reserved command.');
  23442. return NaN;
  23443. }
  23444. function parseFloatOperand() {
  23445. var str = '';
  23446. var eof = 15;
  23447. var lookup = [
  23448. '0',
  23449. '1',
  23450. '2',
  23451. '3',
  23452. '4',
  23453. '5',
  23454. '6',
  23455. '7',
  23456. '8',
  23457. '9',
  23458. '.',
  23459. 'E',
  23460. 'E-',
  23461. null,
  23462. '-'
  23463. ];
  23464. var length = dict.length;
  23465. while (pos < length) {
  23466. var b = dict[pos++];
  23467. var b1 = b >> 4;
  23468. var b2 = b & 15;
  23469. if (b1 === eof) {
  23470. break;
  23471. }
  23472. str += lookup[b1];
  23473. if (b2 === eof) {
  23474. break;
  23475. }
  23476. str += lookup[b2];
  23477. }
  23478. return parseFloat(str);
  23479. }
  23480. var operands = [];
  23481. var entries = [];
  23482. pos = 0;
  23483. var end = dict.length;
  23484. while (pos < end) {
  23485. var b = dict[pos];
  23486. if (b <= 21) {
  23487. if (b === 12) {
  23488. b = b << 8 | dict[++pos];
  23489. }
  23490. entries.push([
  23491. b,
  23492. operands
  23493. ]);
  23494. operands = [];
  23495. ++pos;
  23496. } else {
  23497. operands.push(parseOperand());
  23498. }
  23499. }
  23500. return entries;
  23501. },
  23502. parseIndex: function CFFParser_parseIndex(pos) {
  23503. var cffIndex = new CFFIndex();
  23504. var bytes = this.bytes;
  23505. var count = bytes[pos++] << 8 | bytes[pos++];
  23506. var offsets = [];
  23507. var end = pos;
  23508. var i, ii;
  23509. if (count !== 0) {
  23510. var offsetSize = bytes[pos++];
  23511. var startPos = pos + (count + 1) * offsetSize - 1;
  23512. for (i = 0, ii = count + 1; i < ii; ++i) {
  23513. var offset = 0;
  23514. for (var j = 0; j < offsetSize; ++j) {
  23515. offset <<= 8;
  23516. offset += bytes[pos++];
  23517. }
  23518. offsets.push(startPos + offset);
  23519. }
  23520. end = offsets[count];
  23521. }
  23522. for (i = 0, ii = offsets.length - 1; i < ii; ++i) {
  23523. var offsetStart = offsets[i];
  23524. var offsetEnd = offsets[i + 1];
  23525. cffIndex.add(bytes.subarray(offsetStart, offsetEnd));
  23526. }
  23527. return {
  23528. obj: cffIndex,
  23529. endPos: end
  23530. };
  23531. },
  23532. parseNameIndex: function CFFParser_parseNameIndex(index) {
  23533. var names = [];
  23534. for (var i = 0, ii = index.count; i < ii; ++i) {
  23535. var name = index.get(i);
  23536. var length = Math.min(name.length, 127);
  23537. var data = [];
  23538. for (var j = 0; j < length; ++j) {
  23539. var c = name[j];
  23540. if (j === 0 && c === 0) {
  23541. data[j] = c;
  23542. continue;
  23543. }
  23544. 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) {
  23545. data[j] = 95;
  23546. continue;
  23547. }
  23548. data[j] = c;
  23549. }
  23550. names.push(bytesToString(data));
  23551. }
  23552. return names;
  23553. },
  23554. parseStringIndex: function CFFParser_parseStringIndex(index) {
  23555. var strings = new CFFStrings();
  23556. for (var i = 0, ii = index.count; i < ii; ++i) {
  23557. var data = index.get(i);
  23558. strings.add(bytesToString(data));
  23559. }
  23560. return strings;
  23561. },
  23562. createDict: function CFFParser_createDict(Type, dict, strings) {
  23563. var cffDict = new Type(strings);
  23564. for (var i = 0, ii = dict.length; i < ii; ++i) {
  23565. var pair = dict[i];
  23566. var key = pair[0];
  23567. var value = pair[1];
  23568. cffDict.setByKey(key, value);
  23569. }
  23570. return cffDict;
  23571. },
  23572. parseCharString: function CFFParser_parseCharString(state, data, localSubrIndex, globalSubrIndex) {
  23573. if (state.callDepth > MAX_SUBR_NESTING) {
  23574. return false;
  23575. }
  23576. var stackSize = state.stackSize;
  23577. var stack = state.stack;
  23578. var length = data.length;
  23579. for (var j = 0; j < length;) {
  23580. var value = data[j++];
  23581. var validationCommand = null;
  23582. if (value === 12) {
  23583. var q = data[j++];
  23584. if (q === 0) {
  23585. data[j - 2] = 139;
  23586. data[j - 1] = 22;
  23587. stackSize = 0;
  23588. } else {
  23589. validationCommand = CharstringValidationData12[q];
  23590. }
  23591. } else if (value === 28) {
  23592. stack[stackSize] = (data[j] << 24 | data[j + 1] << 16) >> 16;
  23593. j += 2;
  23594. stackSize++;
  23595. } else if (value === 14) {
  23596. if (stackSize >= 4) {
  23597. stackSize -= 4;
  23598. if (this.seacAnalysisEnabled) {
  23599. state.seac = stack.slice(stackSize, stackSize + 4);
  23600. return false;
  23601. }
  23602. }
  23603. validationCommand = CharstringValidationData[value];
  23604. } else if (value >= 32 && value <= 246) {
  23605. stack[stackSize] = value - 139;
  23606. stackSize++;
  23607. } else if (value >= 247 && value <= 254) {
  23608. stack[stackSize] = value < 251 ? (value - 247 << 8) + data[j] + 108 : -(value - 251 << 8) - data[j] - 108;
  23609. j++;
  23610. stackSize++;
  23611. } else if (value === 255) {
  23612. stack[stackSize] = (data[j] << 24 | data[j + 1] << 16 | data[j + 2] << 8 | data[j + 3]) / 65536;
  23613. j += 4;
  23614. stackSize++;
  23615. } else if (value === 19 || value === 20) {
  23616. state.hints += stackSize >> 1;
  23617. j += state.hints + 7 >> 3;
  23618. stackSize %= 2;
  23619. validationCommand = CharstringValidationData[value];
  23620. } else if (value === 10 || value === 29) {
  23621. var subrsIndex;
  23622. if (value === 10) {
  23623. subrsIndex = localSubrIndex;
  23624. } else {
  23625. subrsIndex = globalSubrIndex;
  23626. }
  23627. if (!subrsIndex) {
  23628. validationCommand = CharstringValidationData[value];
  23629. warn('Missing subrsIndex for ' + validationCommand.id);
  23630. return false;
  23631. }
  23632. var bias = 32768;
  23633. if (subrsIndex.count < 1240) {
  23634. bias = 107;
  23635. } else if (subrsIndex.count < 33900) {
  23636. bias = 1131;
  23637. }
  23638. var subrNumber = stack[--stackSize] + bias;
  23639. if (subrNumber < 0 || subrNumber >= subrsIndex.count) {
  23640. validationCommand = CharstringValidationData[value];
  23641. warn('Out of bounds subrIndex for ' + validationCommand.id);
  23642. return false;
  23643. }
  23644. state.stackSize = stackSize;
  23645. state.callDepth++;
  23646. var valid = this.parseCharString(state, subrsIndex.get(subrNumber), localSubrIndex, globalSubrIndex);
  23647. if (!valid) {
  23648. return false;
  23649. }
  23650. state.callDepth--;
  23651. stackSize = state.stackSize;
  23652. continue;
  23653. } else if (value === 11) {
  23654. state.stackSize = stackSize;
  23655. return true;
  23656. } else {
  23657. validationCommand = CharstringValidationData[value];
  23658. }
  23659. if (validationCommand) {
  23660. if (validationCommand.stem) {
  23661. state.hints += stackSize >> 1;
  23662. }
  23663. if ('min' in validationCommand) {
  23664. if (!state.undefStack && stackSize < validationCommand.min) {
  23665. warn('Not enough parameters for ' + validationCommand.id + '; actual: ' + stackSize + ', expected: ' + validationCommand.min);
  23666. return false;
  23667. }
  23668. }
  23669. if (state.firstStackClearing && validationCommand.stackClearing) {
  23670. state.firstStackClearing = false;
  23671. stackSize -= validationCommand.min;
  23672. if (stackSize >= 2 && validationCommand.stem) {
  23673. stackSize %= 2;
  23674. } else if (stackSize > 1) {
  23675. warn('Found too many parameters for stack-clearing command');
  23676. }
  23677. if (stackSize > 0 && stack[stackSize - 1] >= 0) {
  23678. state.width = stack[stackSize - 1];
  23679. }
  23680. }
  23681. if ('stackDelta' in validationCommand) {
  23682. if ('stackFn' in validationCommand) {
  23683. validationCommand.stackFn(stack, stackSize);
  23684. }
  23685. stackSize += validationCommand.stackDelta;
  23686. } else if (validationCommand.stackClearing) {
  23687. stackSize = 0;
  23688. } else if (validationCommand.resetStack) {
  23689. stackSize = 0;
  23690. state.undefStack = false;
  23691. } else if (validationCommand.undefStack) {
  23692. stackSize = 0;
  23693. state.undefStack = true;
  23694. state.firstStackClearing = false;
  23695. }
  23696. }
  23697. }
  23698. state.stackSize = stackSize;
  23699. return true;
  23700. },
  23701. parseCharStrings: function CFFParser_parseCharStrings(charStrings, localSubrIndex, globalSubrIndex, fdSelect, fdArray) {
  23702. var seacs = [];
  23703. var widths = [];
  23704. var count = charStrings.count;
  23705. for (var i = 0; i < count; i++) {
  23706. var charstring = charStrings.get(i);
  23707. var state = {
  23708. callDepth: 0,
  23709. stackSize: 0,
  23710. stack: [],
  23711. undefStack: true,
  23712. hints: 0,
  23713. firstStackClearing: true,
  23714. seac: null,
  23715. width: null
  23716. };
  23717. var valid = true;
  23718. var localSubrToUse = null;
  23719. if (fdSelect && fdArray.length) {
  23720. var fdIndex = fdSelect.getFDIndex(i);
  23721. if (fdIndex === -1) {
  23722. warn('Glyph index is not in fd select.');
  23723. valid = false;
  23724. }
  23725. if (fdIndex >= fdArray.length) {
  23726. warn('Invalid fd index for glyph index.');
  23727. valid = false;
  23728. }
  23729. if (valid) {
  23730. localSubrToUse = fdArray[fdIndex].privateDict.subrsIndex;
  23731. }
  23732. } else if (localSubrIndex) {
  23733. localSubrToUse = localSubrIndex;
  23734. }
  23735. if (valid) {
  23736. valid = this.parseCharString(state, charstring, localSubrToUse, globalSubrIndex);
  23737. }
  23738. if (state.width !== null) {
  23739. widths[i] = state.width;
  23740. }
  23741. if (state.seac !== null) {
  23742. seacs[i] = state.seac;
  23743. }
  23744. if (!valid) {
  23745. charStrings.set(i, new Uint8Array([14]));
  23746. }
  23747. }
  23748. return {
  23749. charStrings: charStrings,
  23750. seacs: seacs,
  23751. widths: widths
  23752. };
  23753. },
  23754. emptyPrivateDictionary: function CFFParser_emptyPrivateDictionary(parentDict) {
  23755. var privateDict = this.createDict(CFFPrivateDict, [], parentDict.strings);
  23756. parentDict.setByKey(18, [
  23757. 0,
  23758. 0
  23759. ]);
  23760. parentDict.privateDict = privateDict;
  23761. },
  23762. parsePrivateDict: function CFFParser_parsePrivateDict(parentDict) {
  23763. if (!parentDict.hasName('Private')) {
  23764. this.emptyPrivateDictionary(parentDict);
  23765. return;
  23766. }
  23767. var privateOffset = parentDict.getByName('Private');
  23768. if (!isArray(privateOffset) || privateOffset.length !== 2) {
  23769. parentDict.removeByName('Private');
  23770. return;
  23771. }
  23772. var size = privateOffset[0];
  23773. var offset = privateOffset[1];
  23774. if (size === 0 || offset >= this.bytes.length) {
  23775. this.emptyPrivateDictionary(parentDict);
  23776. return;
  23777. }
  23778. var privateDictEnd = offset + size;
  23779. var dictData = this.bytes.subarray(offset, privateDictEnd);
  23780. var dict = this.parseDict(dictData);
  23781. var privateDict = this.createDict(CFFPrivateDict, dict, parentDict.strings);
  23782. parentDict.privateDict = privateDict;
  23783. if (!privateDict.getByName('Subrs')) {
  23784. return;
  23785. }
  23786. var subrsOffset = privateDict.getByName('Subrs');
  23787. var relativeOffset = offset + subrsOffset;
  23788. if (subrsOffset === 0 || relativeOffset >= this.bytes.length) {
  23789. this.emptyPrivateDictionary(parentDict);
  23790. return;
  23791. }
  23792. var subrsIndex = this.parseIndex(relativeOffset);
  23793. privateDict.subrsIndex = subrsIndex.obj;
  23794. },
  23795. parseCharsets: function CFFParser_parseCharsets(pos, length, strings, cid) {
  23796. if (pos === 0) {
  23797. return new CFFCharset(true, CFFCharsetPredefinedTypes.ISO_ADOBE, ISOAdobeCharset);
  23798. } else if (pos === 1) {
  23799. return new CFFCharset(true, CFFCharsetPredefinedTypes.EXPERT, ExpertCharset);
  23800. } else if (pos === 2) {
  23801. return new CFFCharset(true, CFFCharsetPredefinedTypes.EXPERT_SUBSET, ExpertSubsetCharset);
  23802. }
  23803. var bytes = this.bytes;
  23804. var start = pos;
  23805. var format = bytes[pos++];
  23806. var charset = ['.notdef'];
  23807. var id, count, i;
  23808. length -= 1;
  23809. switch (format) {
  23810. case 0:
  23811. for (i = 0; i < length; i++) {
  23812. id = bytes[pos++] << 8 | bytes[pos++];
  23813. charset.push(cid ? id : strings.get(id));
  23814. }
  23815. break;
  23816. case 1:
  23817. while (charset.length <= length) {
  23818. id = bytes[pos++] << 8 | bytes[pos++];
  23819. count = bytes[pos++];
  23820. for (i = 0; i <= count; i++) {
  23821. charset.push(cid ? id++ : strings.get(id++));
  23822. }
  23823. }
  23824. break;
  23825. case 2:
  23826. while (charset.length <= length) {
  23827. id = bytes[pos++] << 8 | bytes[pos++];
  23828. count = bytes[pos++] << 8 | bytes[pos++];
  23829. for (i = 0; i <= count; i++) {
  23830. charset.push(cid ? id++ : strings.get(id++));
  23831. }
  23832. }
  23833. break;
  23834. default:
  23835. error('Unknown charset format');
  23836. }
  23837. var end = pos;
  23838. var raw = bytes.subarray(start, end);
  23839. return new CFFCharset(false, format, charset, raw);
  23840. },
  23841. parseEncoding: function CFFParser_parseEncoding(pos, properties, strings, charset) {
  23842. var encoding = Object.create(null);
  23843. var bytes = this.bytes;
  23844. var predefined = false;
  23845. var format, i, ii;
  23846. var raw = null;
  23847. function readSupplement() {
  23848. var supplementsCount = bytes[pos++];
  23849. for (i = 0; i < supplementsCount; i++) {
  23850. var code = bytes[pos++];
  23851. var sid = (bytes[pos++] << 8) + (bytes[pos++] & 0xff);
  23852. encoding[code] = charset.indexOf(strings.get(sid));
  23853. }
  23854. }
  23855. if (pos === 0 || pos === 1) {
  23856. predefined = true;
  23857. format = pos;
  23858. var baseEncoding = pos ? ExpertEncoding : StandardEncoding;
  23859. for (i = 0, ii = charset.length; i < ii; i++) {
  23860. var index = baseEncoding.indexOf(charset[i]);
  23861. if (index !== -1) {
  23862. encoding[index] = i;
  23863. }
  23864. }
  23865. } else {
  23866. var dataStart = pos;
  23867. format = bytes[pos++];
  23868. switch (format & 0x7f) {
  23869. case 0:
  23870. var glyphsCount = bytes[pos++];
  23871. for (i = 1; i <= glyphsCount; i++) {
  23872. encoding[bytes[pos++]] = i;
  23873. }
  23874. break;
  23875. case 1:
  23876. var rangesCount = bytes[pos++];
  23877. var gid = 1;
  23878. for (i = 0; i < rangesCount; i++) {
  23879. var start = bytes[pos++];
  23880. var left = bytes[pos++];
  23881. for (var j = start; j <= start + left; j++) {
  23882. encoding[j] = gid++;
  23883. }
  23884. }
  23885. break;
  23886. default:
  23887. error('Unknown encoding format: ' + format + ' in CFF');
  23888. break;
  23889. }
  23890. var dataEnd = pos;
  23891. if (format & 0x80) {
  23892. bytes[dataStart] &= 0x7f;
  23893. readSupplement();
  23894. }
  23895. raw = bytes.subarray(dataStart, dataEnd);
  23896. }
  23897. format = format & 0x7f;
  23898. return new CFFEncoding(predefined, format, encoding, raw);
  23899. },
  23900. parseFDSelect: function CFFParser_parseFDSelect(pos, length) {
  23901. var start = pos;
  23902. var bytes = this.bytes;
  23903. var format = bytes[pos++];
  23904. var fdSelect = [], rawBytes;
  23905. var i, invalidFirstGID = false;
  23906. switch (format) {
  23907. case 0:
  23908. for (i = 0; i < length; ++i) {
  23909. var id = bytes[pos++];
  23910. fdSelect.push(id);
  23911. }
  23912. rawBytes = bytes.subarray(start, pos);
  23913. break;
  23914. case 3:
  23915. var rangesCount = bytes[pos++] << 8 | bytes[pos++];
  23916. for (i = 0; i < rangesCount; ++i) {
  23917. var first = bytes[pos++] << 8 | bytes[pos++];
  23918. if (i === 0 && first !== 0) {
  23919. warn('parseFDSelect: The first range must have a first GID of 0' + ' -- trying to recover.');
  23920. invalidFirstGID = true;
  23921. first = 0;
  23922. }
  23923. var fdIndex = bytes[pos++];
  23924. var next = bytes[pos] << 8 | bytes[pos + 1];
  23925. for (var j = first; j < next; ++j) {
  23926. fdSelect.push(fdIndex);
  23927. }
  23928. }
  23929. pos += 2;
  23930. rawBytes = bytes.subarray(start, pos);
  23931. if (invalidFirstGID) {
  23932. rawBytes[3] = rawBytes[4] = 0;
  23933. }
  23934. break;
  23935. default:
  23936. error('parseFDSelect: Unknown format "' + format + '".');
  23937. break;
  23938. }
  23939. assert(fdSelect.length === length, 'parseFDSelect: Invalid font data.');
  23940. return new CFFFDSelect(fdSelect, rawBytes);
  23941. }
  23942. };
  23943. return CFFParser;
  23944. }();
  23945. var CFF = function CFFClosure() {
  23946. function CFF() {
  23947. this.header = null;
  23948. this.names = [];
  23949. this.topDict = null;
  23950. this.strings = new CFFStrings();
  23951. this.globalSubrIndex = null;
  23952. this.encoding = null;
  23953. this.charset = null;
  23954. this.charStrings = null;
  23955. this.fdArray = [];
  23956. this.fdSelect = null;
  23957. this.isCIDFont = false;
  23958. }
  23959. return CFF;
  23960. }();
  23961. var CFFHeader = function CFFHeaderClosure() {
  23962. function CFFHeader(major, minor, hdrSize, offSize) {
  23963. this.major = major;
  23964. this.minor = minor;
  23965. this.hdrSize = hdrSize;
  23966. this.offSize = offSize;
  23967. }
  23968. return CFFHeader;
  23969. }();
  23970. var CFFStrings = function CFFStringsClosure() {
  23971. function CFFStrings() {
  23972. this.strings = [];
  23973. }
  23974. CFFStrings.prototype = {
  23975. get: function CFFStrings_get(index) {
  23976. if (index >= 0 && index <= 390) {
  23977. return CFFStandardStrings[index];
  23978. }
  23979. if (index - 391 <= this.strings.length) {
  23980. return this.strings[index - 391];
  23981. }
  23982. return CFFStandardStrings[0];
  23983. },
  23984. add: function CFFStrings_add(value) {
  23985. this.strings.push(value);
  23986. },
  23987. get count() {
  23988. return this.strings.length;
  23989. }
  23990. };
  23991. return CFFStrings;
  23992. }();
  23993. var CFFIndex = function CFFIndexClosure() {
  23994. function CFFIndex() {
  23995. this.objects = [];
  23996. this.length = 0;
  23997. }
  23998. CFFIndex.prototype = {
  23999. add: function CFFIndex_add(data) {
  24000. this.length += data.length;
  24001. this.objects.push(data);
  24002. },
  24003. set: function CFFIndex_set(index, data) {
  24004. this.length += data.length - this.objects[index].length;
  24005. this.objects[index] = data;
  24006. },
  24007. get: function CFFIndex_get(index) {
  24008. return this.objects[index];
  24009. },
  24010. get count() {
  24011. return this.objects.length;
  24012. }
  24013. };
  24014. return CFFIndex;
  24015. }();
  24016. var CFFDict = function CFFDictClosure() {
  24017. function CFFDict(tables, strings) {
  24018. this.keyToNameMap = tables.keyToNameMap;
  24019. this.nameToKeyMap = tables.nameToKeyMap;
  24020. this.defaults = tables.defaults;
  24021. this.types = tables.types;
  24022. this.opcodes = tables.opcodes;
  24023. this.order = tables.order;
  24024. this.strings = strings;
  24025. this.values = Object.create(null);
  24026. }
  24027. CFFDict.prototype = {
  24028. setByKey: function CFFDict_setByKey(key, value) {
  24029. if (!(key in this.keyToNameMap)) {
  24030. return false;
  24031. }
  24032. var valueLength = value.length;
  24033. if (valueLength === 0) {
  24034. return true;
  24035. }
  24036. for (var i = 0; i < valueLength; i++) {
  24037. if (isNaN(value[i])) {
  24038. warn('Invalid CFFDict value: "' + value + '" for key "' + key + '".');
  24039. return true;
  24040. }
  24041. }
  24042. var type = this.types[key];
  24043. if (type === 'num' || type === 'sid' || type === 'offset') {
  24044. value = value[0];
  24045. }
  24046. this.values[key] = value;
  24047. return true;
  24048. },
  24049. setByName: function CFFDict_setByName(name, value) {
  24050. if (!(name in this.nameToKeyMap)) {
  24051. error('Invalid dictionary name "' + name + '"');
  24052. }
  24053. this.values[this.nameToKeyMap[name]] = value;
  24054. },
  24055. hasName: function CFFDict_hasName(name) {
  24056. return this.nameToKeyMap[name] in this.values;
  24057. },
  24058. getByName: function CFFDict_getByName(name) {
  24059. if (!(name in this.nameToKeyMap)) {
  24060. error('Invalid dictionary name "' + name + '"');
  24061. }
  24062. var key = this.nameToKeyMap[name];
  24063. if (!(key in this.values)) {
  24064. return this.defaults[key];
  24065. }
  24066. return this.values[key];
  24067. },
  24068. removeByName: function CFFDict_removeByName(name) {
  24069. delete this.values[this.nameToKeyMap[name]];
  24070. }
  24071. };
  24072. CFFDict.createTables = function CFFDict_createTables(layout) {
  24073. var tables = {
  24074. keyToNameMap: {},
  24075. nameToKeyMap: {},
  24076. defaults: {},
  24077. types: {},
  24078. opcodes: {},
  24079. order: []
  24080. };
  24081. for (var i = 0, ii = layout.length; i < ii; ++i) {
  24082. var entry = layout[i];
  24083. var key = isArray(entry[0]) ? (entry[0][0] << 8) + entry[0][1] : entry[0];
  24084. tables.keyToNameMap[key] = entry[1];
  24085. tables.nameToKeyMap[entry[1]] = key;
  24086. tables.types[key] = entry[2];
  24087. tables.defaults[key] = entry[3];
  24088. tables.opcodes[key] = isArray(entry[0]) ? entry[0] : [entry[0]];
  24089. tables.order.push(key);
  24090. }
  24091. return tables;
  24092. };
  24093. return CFFDict;
  24094. }();
  24095. var CFFTopDict = function CFFTopDictClosure() {
  24096. var layout = [
  24097. [
  24098. [
  24099. 12,
  24100. 30
  24101. ],
  24102. 'ROS',
  24103. [
  24104. 'sid',
  24105. 'sid',
  24106. 'num'
  24107. ],
  24108. null
  24109. ],
  24110. [
  24111. [
  24112. 12,
  24113. 20
  24114. ],
  24115. 'SyntheticBase',
  24116. 'num',
  24117. null
  24118. ],
  24119. [
  24120. 0,
  24121. 'version',
  24122. 'sid',
  24123. null
  24124. ],
  24125. [
  24126. 1,
  24127. 'Notice',
  24128. 'sid',
  24129. null
  24130. ],
  24131. [
  24132. [
  24133. 12,
  24134. 0
  24135. ],
  24136. 'Copyright',
  24137. 'sid',
  24138. null
  24139. ],
  24140. [
  24141. 2,
  24142. 'FullName',
  24143. 'sid',
  24144. null
  24145. ],
  24146. [
  24147. 3,
  24148. 'FamilyName',
  24149. 'sid',
  24150. null
  24151. ],
  24152. [
  24153. 4,
  24154. 'Weight',
  24155. 'sid',
  24156. null
  24157. ],
  24158. [
  24159. [
  24160. 12,
  24161. 1
  24162. ],
  24163. 'isFixedPitch',
  24164. 'num',
  24165. 0
  24166. ],
  24167. [
  24168. [
  24169. 12,
  24170. 2
  24171. ],
  24172. 'ItalicAngle',
  24173. 'num',
  24174. 0
  24175. ],
  24176. [
  24177. [
  24178. 12,
  24179. 3
  24180. ],
  24181. 'UnderlinePosition',
  24182. 'num',
  24183. -100
  24184. ],
  24185. [
  24186. [
  24187. 12,
  24188. 4
  24189. ],
  24190. 'UnderlineThickness',
  24191. 'num',
  24192. 50
  24193. ],
  24194. [
  24195. [
  24196. 12,
  24197. 5
  24198. ],
  24199. 'PaintType',
  24200. 'num',
  24201. 0
  24202. ],
  24203. [
  24204. [
  24205. 12,
  24206. 6
  24207. ],
  24208. 'CharstringType',
  24209. 'num',
  24210. 2
  24211. ],
  24212. [
  24213. [
  24214. 12,
  24215. 7
  24216. ],
  24217. 'FontMatrix',
  24218. [
  24219. 'num',
  24220. 'num',
  24221. 'num',
  24222. 'num',
  24223. 'num',
  24224. 'num'
  24225. ],
  24226. [
  24227. 0.001,
  24228. 0,
  24229. 0,
  24230. 0.001,
  24231. 0,
  24232. 0
  24233. ]
  24234. ],
  24235. [
  24236. 13,
  24237. 'UniqueID',
  24238. 'num',
  24239. null
  24240. ],
  24241. [
  24242. 5,
  24243. 'FontBBox',
  24244. [
  24245. 'num',
  24246. 'num',
  24247. 'num',
  24248. 'num'
  24249. ],
  24250. [
  24251. 0,
  24252. 0,
  24253. 0,
  24254. 0
  24255. ]
  24256. ],
  24257. [
  24258. [
  24259. 12,
  24260. 8
  24261. ],
  24262. 'StrokeWidth',
  24263. 'num',
  24264. 0
  24265. ],
  24266. [
  24267. 14,
  24268. 'XUID',
  24269. 'array',
  24270. null
  24271. ],
  24272. [
  24273. 15,
  24274. 'charset',
  24275. 'offset',
  24276. 0
  24277. ],
  24278. [
  24279. 16,
  24280. 'Encoding',
  24281. 'offset',
  24282. 0
  24283. ],
  24284. [
  24285. 17,
  24286. 'CharStrings',
  24287. 'offset',
  24288. 0
  24289. ],
  24290. [
  24291. 18,
  24292. 'Private',
  24293. [
  24294. 'offset',
  24295. 'offset'
  24296. ],
  24297. null
  24298. ],
  24299. [
  24300. [
  24301. 12,
  24302. 21
  24303. ],
  24304. 'PostScript',
  24305. 'sid',
  24306. null
  24307. ],
  24308. [
  24309. [
  24310. 12,
  24311. 22
  24312. ],
  24313. 'BaseFontName',
  24314. 'sid',
  24315. null
  24316. ],
  24317. [
  24318. [
  24319. 12,
  24320. 23
  24321. ],
  24322. 'BaseFontBlend',
  24323. 'delta',
  24324. null
  24325. ],
  24326. [
  24327. [
  24328. 12,
  24329. 31
  24330. ],
  24331. 'CIDFontVersion',
  24332. 'num',
  24333. 0
  24334. ],
  24335. [
  24336. [
  24337. 12,
  24338. 32
  24339. ],
  24340. 'CIDFontRevision',
  24341. 'num',
  24342. 0
  24343. ],
  24344. [
  24345. [
  24346. 12,
  24347. 33
  24348. ],
  24349. 'CIDFontType',
  24350. 'num',
  24351. 0
  24352. ],
  24353. [
  24354. [
  24355. 12,
  24356. 34
  24357. ],
  24358. 'CIDCount',
  24359. 'num',
  24360. 8720
  24361. ],
  24362. [
  24363. [
  24364. 12,
  24365. 35
  24366. ],
  24367. 'UIDBase',
  24368. 'num',
  24369. null
  24370. ],
  24371. [
  24372. [
  24373. 12,
  24374. 37
  24375. ],
  24376. 'FDSelect',
  24377. 'offset',
  24378. null
  24379. ],
  24380. [
  24381. [
  24382. 12,
  24383. 36
  24384. ],
  24385. 'FDArray',
  24386. 'offset',
  24387. null
  24388. ],
  24389. [
  24390. [
  24391. 12,
  24392. 38
  24393. ],
  24394. 'FontName',
  24395. 'sid',
  24396. null
  24397. ]
  24398. ];
  24399. var tables = null;
  24400. function CFFTopDict(strings) {
  24401. if (tables === null) {
  24402. tables = CFFDict.createTables(layout);
  24403. }
  24404. CFFDict.call(this, tables, strings);
  24405. this.privateDict = null;
  24406. }
  24407. CFFTopDict.prototype = Object.create(CFFDict.prototype);
  24408. return CFFTopDict;
  24409. }();
  24410. var CFFPrivateDict = function CFFPrivateDictClosure() {
  24411. var layout = [
  24412. [
  24413. 6,
  24414. 'BlueValues',
  24415. 'delta',
  24416. null
  24417. ],
  24418. [
  24419. 7,
  24420. 'OtherBlues',
  24421. 'delta',
  24422. null
  24423. ],
  24424. [
  24425. 8,
  24426. 'FamilyBlues',
  24427. 'delta',
  24428. null
  24429. ],
  24430. [
  24431. 9,
  24432. 'FamilyOtherBlues',
  24433. 'delta',
  24434. null
  24435. ],
  24436. [
  24437. [
  24438. 12,
  24439. 9
  24440. ],
  24441. 'BlueScale',
  24442. 'num',
  24443. 0.039625
  24444. ],
  24445. [
  24446. [
  24447. 12,
  24448. 10
  24449. ],
  24450. 'BlueShift',
  24451. 'num',
  24452. 7
  24453. ],
  24454. [
  24455. [
  24456. 12,
  24457. 11
  24458. ],
  24459. 'BlueFuzz',
  24460. 'num',
  24461. 1
  24462. ],
  24463. [
  24464. 10,
  24465. 'StdHW',
  24466. 'num',
  24467. null
  24468. ],
  24469. [
  24470. 11,
  24471. 'StdVW',
  24472. 'num',
  24473. null
  24474. ],
  24475. [
  24476. [
  24477. 12,
  24478. 12
  24479. ],
  24480. 'StemSnapH',
  24481. 'delta',
  24482. null
  24483. ],
  24484. [
  24485. [
  24486. 12,
  24487. 13
  24488. ],
  24489. 'StemSnapV',
  24490. 'delta',
  24491. null
  24492. ],
  24493. [
  24494. [
  24495. 12,
  24496. 14
  24497. ],
  24498. 'ForceBold',
  24499. 'num',
  24500. 0
  24501. ],
  24502. [
  24503. [
  24504. 12,
  24505. 17
  24506. ],
  24507. 'LanguageGroup',
  24508. 'num',
  24509. 0
  24510. ],
  24511. [
  24512. [
  24513. 12,
  24514. 18
  24515. ],
  24516. 'ExpansionFactor',
  24517. 'num',
  24518. 0.06
  24519. ],
  24520. [
  24521. [
  24522. 12,
  24523. 19
  24524. ],
  24525. 'initialRandomSeed',
  24526. 'num',
  24527. 0
  24528. ],
  24529. [
  24530. 20,
  24531. 'defaultWidthX',
  24532. 'num',
  24533. 0
  24534. ],
  24535. [
  24536. 21,
  24537. 'nominalWidthX',
  24538. 'num',
  24539. 0
  24540. ],
  24541. [
  24542. 19,
  24543. 'Subrs',
  24544. 'offset',
  24545. null
  24546. ]
  24547. ];
  24548. var tables = null;
  24549. function CFFPrivateDict(strings) {
  24550. if (tables === null) {
  24551. tables = CFFDict.createTables(layout);
  24552. }
  24553. CFFDict.call(this, tables, strings);
  24554. this.subrsIndex = null;
  24555. }
  24556. CFFPrivateDict.prototype = Object.create(CFFDict.prototype);
  24557. return CFFPrivateDict;
  24558. }();
  24559. var CFFCharsetPredefinedTypes = {
  24560. ISO_ADOBE: 0,
  24561. EXPERT: 1,
  24562. EXPERT_SUBSET: 2
  24563. };
  24564. var CFFCharset = function CFFCharsetClosure() {
  24565. function CFFCharset(predefined, format, charset, raw) {
  24566. this.predefined = predefined;
  24567. this.format = format;
  24568. this.charset = charset;
  24569. this.raw = raw;
  24570. }
  24571. return CFFCharset;
  24572. }();
  24573. var CFFEncoding = function CFFEncodingClosure() {
  24574. function CFFEncoding(predefined, format, encoding, raw) {
  24575. this.predefined = predefined;
  24576. this.format = format;
  24577. this.encoding = encoding;
  24578. this.raw = raw;
  24579. }
  24580. return CFFEncoding;
  24581. }();
  24582. var CFFFDSelect = function CFFFDSelectClosure() {
  24583. function CFFFDSelect(fdSelect, raw) {
  24584. this.fdSelect = fdSelect;
  24585. this.raw = raw;
  24586. }
  24587. CFFFDSelect.prototype = {
  24588. getFDIndex: function CFFFDSelect_get(glyphIndex) {
  24589. if (glyphIndex < 0 || glyphIndex >= this.fdSelect.length) {
  24590. return -1;
  24591. }
  24592. return this.fdSelect[glyphIndex];
  24593. }
  24594. };
  24595. return CFFFDSelect;
  24596. }();
  24597. var CFFOffsetTracker = function CFFOffsetTrackerClosure() {
  24598. function CFFOffsetTracker() {
  24599. this.offsets = Object.create(null);
  24600. }
  24601. CFFOffsetTracker.prototype = {
  24602. isTracking: function CFFOffsetTracker_isTracking(key) {
  24603. return key in this.offsets;
  24604. },
  24605. track: function CFFOffsetTracker_track(key, location) {
  24606. if (key in this.offsets) {
  24607. error('Already tracking location of ' + key);
  24608. }
  24609. this.offsets[key] = location;
  24610. },
  24611. offset: function CFFOffsetTracker_offset(value) {
  24612. for (var key in this.offsets) {
  24613. this.offsets[key] += value;
  24614. }
  24615. },
  24616. setEntryLocation: function CFFOffsetTracker_setEntryLocation(key, values, output) {
  24617. if (!(key in this.offsets)) {
  24618. error('Not tracking location of ' + key);
  24619. }
  24620. var data = output.data;
  24621. var dataOffset = this.offsets[key];
  24622. var size = 5;
  24623. for (var i = 0, ii = values.length; i < ii; ++i) {
  24624. var offset0 = i * size + dataOffset;
  24625. var offset1 = offset0 + 1;
  24626. var offset2 = offset0 + 2;
  24627. var offset3 = offset0 + 3;
  24628. var offset4 = offset0 + 4;
  24629. if (data[offset0] !== 0x1d || data[offset1] !== 0 || data[offset2] !== 0 || data[offset3] !== 0 || data[offset4] !== 0) {
  24630. error('writing to an offset that is not empty');
  24631. }
  24632. var value = values[i];
  24633. data[offset0] = 0x1d;
  24634. data[offset1] = value >> 24 & 0xFF;
  24635. data[offset2] = value >> 16 & 0xFF;
  24636. data[offset3] = value >> 8 & 0xFF;
  24637. data[offset4] = value & 0xFF;
  24638. }
  24639. }
  24640. };
  24641. return CFFOffsetTracker;
  24642. }();
  24643. var CFFCompiler = function CFFCompilerClosure() {
  24644. function CFFCompiler(cff) {
  24645. this.cff = cff;
  24646. }
  24647. CFFCompiler.prototype = {
  24648. compile: function CFFCompiler_compile() {
  24649. var cff = this.cff;
  24650. var output = {
  24651. data: [],
  24652. length: 0,
  24653. add: function CFFCompiler_add(data) {
  24654. this.data = this.data.concat(data);
  24655. this.length = this.data.length;
  24656. }
  24657. };
  24658. var header = this.compileHeader(cff.header);
  24659. output.add(header);
  24660. var nameIndex = this.compileNameIndex(cff.names);
  24661. output.add(nameIndex);
  24662. if (cff.isCIDFont) {
  24663. if (cff.topDict.hasName('FontMatrix')) {
  24664. var base = cff.topDict.getByName('FontMatrix');
  24665. cff.topDict.removeByName('FontMatrix');
  24666. for (var i = 0, ii = cff.fdArray.length; i < ii; i++) {
  24667. var subDict = cff.fdArray[i];
  24668. var matrix = base.slice(0);
  24669. if (subDict.hasName('FontMatrix')) {
  24670. matrix = Util.transform(matrix, subDict.getByName('FontMatrix'));
  24671. }
  24672. subDict.setByName('FontMatrix', matrix);
  24673. }
  24674. }
  24675. }
  24676. var compiled = this.compileTopDicts([cff.topDict], output.length, cff.isCIDFont);
  24677. output.add(compiled.output);
  24678. var topDictTracker = compiled.trackers[0];
  24679. var stringIndex = this.compileStringIndex(cff.strings.strings);
  24680. output.add(stringIndex);
  24681. var globalSubrIndex = this.compileIndex(cff.globalSubrIndex);
  24682. output.add(globalSubrIndex);
  24683. if (cff.encoding && cff.topDict.hasName('Encoding')) {
  24684. if (cff.encoding.predefined) {
  24685. topDictTracker.setEntryLocation('Encoding', [cff.encoding.format], output);
  24686. } else {
  24687. var encoding = this.compileEncoding(cff.encoding);
  24688. topDictTracker.setEntryLocation('Encoding', [output.length], output);
  24689. output.add(encoding);
  24690. }
  24691. }
  24692. if (cff.charset && cff.topDict.hasName('charset')) {
  24693. if (cff.charset.predefined) {
  24694. topDictTracker.setEntryLocation('charset', [cff.charset.format], output);
  24695. } else {
  24696. var charset = this.compileCharset(cff.charset);
  24697. topDictTracker.setEntryLocation('charset', [output.length], output);
  24698. output.add(charset);
  24699. }
  24700. }
  24701. var charStrings = this.compileCharStrings(cff.charStrings);
  24702. topDictTracker.setEntryLocation('CharStrings', [output.length], output);
  24703. output.add(charStrings);
  24704. if (cff.isCIDFont) {
  24705. topDictTracker.setEntryLocation('FDSelect', [output.length], output);
  24706. var fdSelect = this.compileFDSelect(cff.fdSelect.raw);
  24707. output.add(fdSelect);
  24708. compiled = this.compileTopDicts(cff.fdArray, output.length, true);
  24709. topDictTracker.setEntryLocation('FDArray', [output.length], output);
  24710. output.add(compiled.output);
  24711. var fontDictTrackers = compiled.trackers;
  24712. this.compilePrivateDicts(cff.fdArray, fontDictTrackers, output);
  24713. }
  24714. this.compilePrivateDicts([cff.topDict], [topDictTracker], output);
  24715. output.add([0]);
  24716. return output.data;
  24717. },
  24718. encodeNumber: function CFFCompiler_encodeNumber(value) {
  24719. if (parseFloat(value) === parseInt(value, 10) && !isNaN(value)) {
  24720. return this.encodeInteger(value);
  24721. }
  24722. return this.encodeFloat(value);
  24723. },
  24724. encodeFloat: function CFFCompiler_encodeFloat(num) {
  24725. var value = num.toString();
  24726. var m = /\.(\d*?)(?:9{5,20}|0{5,20})\d{0,2}(?:e(.+)|$)/.exec(value);
  24727. if (m) {
  24728. var epsilon = parseFloat('1e' + ((m[2] ? +m[2] : 0) + m[1].length));
  24729. value = (Math.round(num * epsilon) / epsilon).toString();
  24730. }
  24731. var nibbles = '';
  24732. var i, ii;
  24733. for (i = 0, ii = value.length; i < ii; ++i) {
  24734. var a = value[i];
  24735. if (a === 'e') {
  24736. nibbles += value[++i] === '-' ? 'c' : 'b';
  24737. } else if (a === '.') {
  24738. nibbles += 'a';
  24739. } else if (a === '-') {
  24740. nibbles += 'e';
  24741. } else {
  24742. nibbles += a;
  24743. }
  24744. }
  24745. nibbles += nibbles.length & 1 ? 'f' : 'ff';
  24746. var out = [30];
  24747. for (i = 0, ii = nibbles.length; i < ii; i += 2) {
  24748. out.push(parseInt(nibbles.substr(i, 2), 16));
  24749. }
  24750. return out;
  24751. },
  24752. encodeInteger: function CFFCompiler_encodeInteger(value) {
  24753. var code;
  24754. if (value >= -107 && value <= 107) {
  24755. code = [value + 139];
  24756. } else if (value >= 108 && value <= 1131) {
  24757. value = value - 108;
  24758. code = [
  24759. (value >> 8) + 247,
  24760. value & 0xFF
  24761. ];
  24762. } else if (value >= -1131 && value <= -108) {
  24763. value = -value - 108;
  24764. code = [
  24765. (value >> 8) + 251,
  24766. value & 0xFF
  24767. ];
  24768. } else if (value >= -32768 && value <= 32767) {
  24769. code = [
  24770. 0x1c,
  24771. value >> 8 & 0xFF,
  24772. value & 0xFF
  24773. ];
  24774. } else {
  24775. code = [
  24776. 0x1d,
  24777. value >> 24 & 0xFF,
  24778. value >> 16 & 0xFF,
  24779. value >> 8 & 0xFF,
  24780. value & 0xFF
  24781. ];
  24782. }
  24783. return code;
  24784. },
  24785. compileHeader: function CFFCompiler_compileHeader(header) {
  24786. return [
  24787. header.major,
  24788. header.minor,
  24789. header.hdrSize,
  24790. header.offSize
  24791. ];
  24792. },
  24793. compileNameIndex: function CFFCompiler_compileNameIndex(names) {
  24794. var nameIndex = new CFFIndex();
  24795. for (var i = 0, ii = names.length; i < ii; ++i) {
  24796. nameIndex.add(stringToBytes(names[i]));
  24797. }
  24798. return this.compileIndex(nameIndex);
  24799. },
  24800. compileTopDicts: function CFFCompiler_compileTopDicts(dicts, length, removeCidKeys) {
  24801. var fontDictTrackers = [];
  24802. var fdArrayIndex = new CFFIndex();
  24803. for (var i = 0, ii = dicts.length; i < ii; ++i) {
  24804. var fontDict = dicts[i];
  24805. if (removeCidKeys) {
  24806. fontDict.removeByName('CIDFontVersion');
  24807. fontDict.removeByName('CIDFontRevision');
  24808. fontDict.removeByName('CIDFontType');
  24809. fontDict.removeByName('CIDCount');
  24810. fontDict.removeByName('UIDBase');
  24811. }
  24812. var fontDictTracker = new CFFOffsetTracker();
  24813. var fontDictData = this.compileDict(fontDict, fontDictTracker);
  24814. fontDictTrackers.push(fontDictTracker);
  24815. fdArrayIndex.add(fontDictData);
  24816. fontDictTracker.offset(length);
  24817. }
  24818. fdArrayIndex = this.compileIndex(fdArrayIndex, fontDictTrackers);
  24819. return {
  24820. trackers: fontDictTrackers,
  24821. output: fdArrayIndex
  24822. };
  24823. },
  24824. compilePrivateDicts: function CFFCompiler_compilePrivateDicts(dicts, trackers, output) {
  24825. for (var i = 0, ii = dicts.length; i < ii; ++i) {
  24826. var fontDict = dicts[i];
  24827. assert(fontDict.privateDict && fontDict.hasName('Private'), 'There must be an private dictionary.');
  24828. var privateDict = fontDict.privateDict;
  24829. var privateDictTracker = new CFFOffsetTracker();
  24830. var privateDictData = this.compileDict(privateDict, privateDictTracker);
  24831. var outputLength = output.length;
  24832. privateDictTracker.offset(outputLength);
  24833. if (!privateDictData.length) {
  24834. outputLength = 0;
  24835. }
  24836. trackers[i].setEntryLocation('Private', [
  24837. privateDictData.length,
  24838. outputLength
  24839. ], output);
  24840. output.add(privateDictData);
  24841. if (privateDict.subrsIndex && privateDict.hasName('Subrs')) {
  24842. var subrs = this.compileIndex(privateDict.subrsIndex);
  24843. privateDictTracker.setEntryLocation('Subrs', [privateDictData.length], output);
  24844. output.add(subrs);
  24845. }
  24846. }
  24847. },
  24848. compileDict: function CFFCompiler_compileDict(dict, offsetTracker) {
  24849. var out = [];
  24850. var order = dict.order;
  24851. for (var i = 0; i < order.length; ++i) {
  24852. var key = order[i];
  24853. if (!(key in dict.values)) {
  24854. continue;
  24855. }
  24856. var values = dict.values[key];
  24857. var types = dict.types[key];
  24858. if (!isArray(types)) {
  24859. types = [types];
  24860. }
  24861. if (!isArray(values)) {
  24862. values = [values];
  24863. }
  24864. if (values.length === 0) {
  24865. continue;
  24866. }
  24867. for (var j = 0, jj = types.length; j < jj; ++j) {
  24868. var type = types[j];
  24869. var value = values[j];
  24870. switch (type) {
  24871. case 'num':
  24872. case 'sid':
  24873. out = out.concat(this.encodeNumber(value));
  24874. break;
  24875. case 'offset':
  24876. var name = dict.keyToNameMap[key];
  24877. if (!offsetTracker.isTracking(name)) {
  24878. offsetTracker.track(name, out.length);
  24879. }
  24880. out = out.concat([
  24881. 0x1d,
  24882. 0,
  24883. 0,
  24884. 0,
  24885. 0
  24886. ]);
  24887. break;
  24888. case 'array':
  24889. case 'delta':
  24890. out = out.concat(this.encodeNumber(value));
  24891. for (var k = 1, kk = values.length; k < kk; ++k) {
  24892. out = out.concat(this.encodeNumber(values[k]));
  24893. }
  24894. break;
  24895. default:
  24896. error('Unknown data type of ' + type);
  24897. break;
  24898. }
  24899. }
  24900. out = out.concat(dict.opcodes[key]);
  24901. }
  24902. return out;
  24903. },
  24904. compileStringIndex: function CFFCompiler_compileStringIndex(strings) {
  24905. var stringIndex = new CFFIndex();
  24906. for (var i = 0, ii = strings.length; i < ii; ++i) {
  24907. stringIndex.add(stringToBytes(strings[i]));
  24908. }
  24909. return this.compileIndex(stringIndex);
  24910. },
  24911. compileGlobalSubrIndex: function CFFCompiler_compileGlobalSubrIndex() {
  24912. var globalSubrIndex = this.cff.globalSubrIndex;
  24913. this.out.writeByteArray(this.compileIndex(globalSubrIndex));
  24914. },
  24915. compileCharStrings: function CFFCompiler_compileCharStrings(charStrings) {
  24916. return this.compileIndex(charStrings);
  24917. },
  24918. compileCharset: function CFFCompiler_compileCharset(charset) {
  24919. return this.compileTypedArray(charset.raw);
  24920. },
  24921. compileEncoding: function CFFCompiler_compileEncoding(encoding) {
  24922. return this.compileTypedArray(encoding.raw);
  24923. },
  24924. compileFDSelect: function CFFCompiler_compileFDSelect(fdSelect) {
  24925. return this.compileTypedArray(fdSelect);
  24926. },
  24927. compileTypedArray: function CFFCompiler_compileTypedArray(data) {
  24928. var out = [];
  24929. for (var i = 0, ii = data.length; i < ii; ++i) {
  24930. out[i] = data[i];
  24931. }
  24932. return out;
  24933. },
  24934. compileIndex: function CFFCompiler_compileIndex(index, trackers) {
  24935. trackers = trackers || [];
  24936. var objects = index.objects;
  24937. var count = objects.length;
  24938. if (count === 0) {
  24939. return [
  24940. 0,
  24941. 0,
  24942. 0
  24943. ];
  24944. }
  24945. var data = [
  24946. count >> 8 & 0xFF,
  24947. count & 0xff
  24948. ];
  24949. var lastOffset = 1, i;
  24950. for (i = 0; i < count; ++i) {
  24951. lastOffset += objects[i].length;
  24952. }
  24953. var offsetSize;
  24954. if (lastOffset < 0x100) {
  24955. offsetSize = 1;
  24956. } else if (lastOffset < 0x10000) {
  24957. offsetSize = 2;
  24958. } else if (lastOffset < 0x1000000) {
  24959. offsetSize = 3;
  24960. } else {
  24961. offsetSize = 4;
  24962. }
  24963. data.push(offsetSize);
  24964. var relativeOffset = 1;
  24965. for (i = 0; i < count + 1; i++) {
  24966. if (offsetSize === 1) {
  24967. data.push(relativeOffset & 0xFF);
  24968. } else if (offsetSize === 2) {
  24969. data.push(relativeOffset >> 8 & 0xFF, relativeOffset & 0xFF);
  24970. } else if (offsetSize === 3) {
  24971. data.push(relativeOffset >> 16 & 0xFF, relativeOffset >> 8 & 0xFF, relativeOffset & 0xFF);
  24972. } else {
  24973. data.push(relativeOffset >>> 24 & 0xFF, relativeOffset >> 16 & 0xFF, relativeOffset >> 8 & 0xFF, relativeOffset & 0xFF);
  24974. }
  24975. if (objects[i]) {
  24976. relativeOffset += objects[i].length;
  24977. }
  24978. }
  24979. for (i = 0; i < count; i++) {
  24980. if (trackers[i]) {
  24981. trackers[i].offset(data.length);
  24982. }
  24983. for (var j = 0, jj = objects[i].length; j < jj; j++) {
  24984. data.push(objects[i][j]);
  24985. }
  24986. }
  24987. return data;
  24988. }
  24989. };
  24990. return CFFCompiler;
  24991. }();
  24992. exports.CFFStandardStrings = CFFStandardStrings;
  24993. exports.CFFParser = CFFParser;
  24994. exports.CFF = CFF;
  24995. exports.CFFHeader = CFFHeader;
  24996. exports.CFFStrings = CFFStrings;
  24997. exports.CFFIndex = CFFIndex;
  24998. exports.CFFCharset = CFFCharset;
  24999. exports.CFFTopDict = CFFTopDict;
  25000. exports.CFFPrivateDict = CFFPrivateDict;
  25001. exports.CFFCompiler = CFFCompiler;
  25002. /***/ }),
  25003. /* 15 */
  25004. /***/ (function(module, exports, __w_pdfjs_require__) {
  25005. "use strict";
  25006. var sharedUtil = __w_pdfjs_require__(0);
  25007. var MissingDataException = sharedUtil.MissingDataException;
  25008. var arrayByteLength = sharedUtil.arrayByteLength;
  25009. var arraysToBytes = sharedUtil.arraysToBytes;
  25010. var assert = sharedUtil.assert;
  25011. var createPromiseCapability = sharedUtil.createPromiseCapability;
  25012. var isInt = sharedUtil.isInt;
  25013. var isEmptyObj = sharedUtil.isEmptyObj;
  25014. var ChunkedStream = function ChunkedStreamClosure() {
  25015. function ChunkedStream(length, chunkSize, manager) {
  25016. this.bytes = new Uint8Array(length);
  25017. this.start = 0;
  25018. this.pos = 0;
  25019. this.end = length;
  25020. this.chunkSize = chunkSize;
  25021. this.loadedChunks = [];
  25022. this.numChunksLoaded = 0;
  25023. this.numChunks = Math.ceil(length / chunkSize);
  25024. this.manager = manager;
  25025. this.progressiveDataLength = 0;
  25026. this.lastSuccessfulEnsureByteChunk = -1;
  25027. }
  25028. ChunkedStream.prototype = {
  25029. getMissingChunks: function ChunkedStream_getMissingChunks() {
  25030. var chunks = [];
  25031. for (var chunk = 0, n = this.numChunks; chunk < n; ++chunk) {
  25032. if (!this.loadedChunks[chunk]) {
  25033. chunks.push(chunk);
  25034. }
  25035. }
  25036. return chunks;
  25037. },
  25038. getBaseStreams: function ChunkedStream_getBaseStreams() {
  25039. return [this];
  25040. },
  25041. allChunksLoaded: function ChunkedStream_allChunksLoaded() {
  25042. return this.numChunksLoaded === this.numChunks;
  25043. },
  25044. onReceiveData: function ChunkedStream_onReceiveData(begin, chunk) {
  25045. var end = begin + chunk.byteLength;
  25046. assert(begin % this.chunkSize === 0, 'Bad begin offset: ' + begin);
  25047. var length = this.bytes.length;
  25048. assert(end % this.chunkSize === 0 || end === length, 'Bad end offset: ' + end);
  25049. this.bytes.set(new Uint8Array(chunk), begin);
  25050. var chunkSize = this.chunkSize;
  25051. var beginChunk = Math.floor(begin / chunkSize);
  25052. var endChunk = Math.floor((end - 1) / chunkSize) + 1;
  25053. var curChunk;
  25054. for (curChunk = beginChunk; curChunk < endChunk; ++curChunk) {
  25055. if (!this.loadedChunks[curChunk]) {
  25056. this.loadedChunks[curChunk] = true;
  25057. ++this.numChunksLoaded;
  25058. }
  25059. }
  25060. },
  25061. onReceiveProgressiveData: function ChunkedStream_onReceiveProgressiveData(data) {
  25062. var position = this.progressiveDataLength;
  25063. var beginChunk = Math.floor(position / this.chunkSize);
  25064. this.bytes.set(new Uint8Array(data), position);
  25065. position += data.byteLength;
  25066. this.progressiveDataLength = position;
  25067. var endChunk = position >= this.end ? this.numChunks : Math.floor(position / this.chunkSize);
  25068. var curChunk;
  25069. for (curChunk = beginChunk; curChunk < endChunk; ++curChunk) {
  25070. if (!this.loadedChunks[curChunk]) {
  25071. this.loadedChunks[curChunk] = true;
  25072. ++this.numChunksLoaded;
  25073. }
  25074. }
  25075. },
  25076. ensureByte: function ChunkedStream_ensureByte(pos) {
  25077. var chunk = Math.floor(pos / this.chunkSize);
  25078. if (chunk === this.lastSuccessfulEnsureByteChunk) {
  25079. return;
  25080. }
  25081. if (!this.loadedChunks[chunk]) {
  25082. throw new MissingDataException(pos, pos + 1);
  25083. }
  25084. this.lastSuccessfulEnsureByteChunk = chunk;
  25085. },
  25086. ensureRange: function ChunkedStream_ensureRange(begin, end) {
  25087. if (begin >= end) {
  25088. return;
  25089. }
  25090. if (end <= this.progressiveDataLength) {
  25091. return;
  25092. }
  25093. var chunkSize = this.chunkSize;
  25094. var beginChunk = Math.floor(begin / chunkSize);
  25095. var endChunk = Math.floor((end - 1) / chunkSize) + 1;
  25096. for (var chunk = beginChunk; chunk < endChunk; ++chunk) {
  25097. if (!this.loadedChunks[chunk]) {
  25098. throw new MissingDataException(begin, end);
  25099. }
  25100. }
  25101. },
  25102. nextEmptyChunk: function ChunkedStream_nextEmptyChunk(beginChunk) {
  25103. var chunk, numChunks = this.numChunks;
  25104. for (var i = 0; i < numChunks; ++i) {
  25105. chunk = (beginChunk + i) % numChunks;
  25106. if (!this.loadedChunks[chunk]) {
  25107. return chunk;
  25108. }
  25109. }
  25110. return null;
  25111. },
  25112. hasChunk: function ChunkedStream_hasChunk(chunk) {
  25113. return !!this.loadedChunks[chunk];
  25114. },
  25115. get length() {
  25116. return this.end - this.start;
  25117. },
  25118. get isEmpty() {
  25119. return this.length === 0;
  25120. },
  25121. getByte: function ChunkedStream_getByte() {
  25122. var pos = this.pos;
  25123. if (pos >= this.end) {
  25124. return -1;
  25125. }
  25126. this.ensureByte(pos);
  25127. return this.bytes[this.pos++];
  25128. },
  25129. getUint16: function ChunkedStream_getUint16() {
  25130. var b0 = this.getByte();
  25131. var b1 = this.getByte();
  25132. if (b0 === -1 || b1 === -1) {
  25133. return -1;
  25134. }
  25135. return (b0 << 8) + b1;
  25136. },
  25137. getInt32: function ChunkedStream_getInt32() {
  25138. var b0 = this.getByte();
  25139. var b1 = this.getByte();
  25140. var b2 = this.getByte();
  25141. var b3 = this.getByte();
  25142. return (b0 << 24) + (b1 << 16) + (b2 << 8) + b3;
  25143. },
  25144. getBytes: function ChunkedStream_getBytes(length) {
  25145. var bytes = this.bytes;
  25146. var pos = this.pos;
  25147. var strEnd = this.end;
  25148. if (!length) {
  25149. this.ensureRange(pos, strEnd);
  25150. return bytes.subarray(pos, strEnd);
  25151. }
  25152. var end = pos + length;
  25153. if (end > strEnd) {
  25154. end = strEnd;
  25155. }
  25156. this.ensureRange(pos, end);
  25157. this.pos = end;
  25158. return bytes.subarray(pos, end);
  25159. },
  25160. peekByte: function ChunkedStream_peekByte() {
  25161. var peekedByte = this.getByte();
  25162. this.pos--;
  25163. return peekedByte;
  25164. },
  25165. peekBytes: function ChunkedStream_peekBytes(length) {
  25166. var bytes = this.getBytes(length);
  25167. this.pos -= bytes.length;
  25168. return bytes;
  25169. },
  25170. getByteRange: function ChunkedStream_getBytes(begin, end) {
  25171. this.ensureRange(begin, end);
  25172. return this.bytes.subarray(begin, end);
  25173. },
  25174. skip: function ChunkedStream_skip(n) {
  25175. if (!n) {
  25176. n = 1;
  25177. }
  25178. this.pos += n;
  25179. },
  25180. reset: function ChunkedStream_reset() {
  25181. this.pos = this.start;
  25182. },
  25183. moveStart: function ChunkedStream_moveStart() {
  25184. this.start = this.pos;
  25185. },
  25186. makeSubStream: function ChunkedStream_makeSubStream(start, length, dict) {
  25187. this.ensureRange(start, start + length);
  25188. function ChunkedStreamSubstream() {
  25189. }
  25190. ChunkedStreamSubstream.prototype = Object.create(this);
  25191. ChunkedStreamSubstream.prototype.getMissingChunks = function () {
  25192. var chunkSize = this.chunkSize;
  25193. var beginChunk = Math.floor(this.start / chunkSize);
  25194. var endChunk = Math.floor((this.end - 1) / chunkSize) + 1;
  25195. var missingChunks = [];
  25196. for (var chunk = beginChunk; chunk < endChunk; ++chunk) {
  25197. if (!this.loadedChunks[chunk]) {
  25198. missingChunks.push(chunk);
  25199. }
  25200. }
  25201. return missingChunks;
  25202. };
  25203. var subStream = new ChunkedStreamSubstream();
  25204. subStream.pos = subStream.start = start;
  25205. subStream.end = start + length || this.end;
  25206. subStream.dict = dict;
  25207. return subStream;
  25208. }
  25209. };
  25210. return ChunkedStream;
  25211. }();
  25212. var ChunkedStreamManager = function ChunkedStreamManagerClosure() {
  25213. function ChunkedStreamManager(pdfNetworkStream, args) {
  25214. var chunkSize = args.rangeChunkSize;
  25215. var length = args.length;
  25216. this.stream = new ChunkedStream(length, chunkSize, this);
  25217. this.length = length;
  25218. this.chunkSize = chunkSize;
  25219. this.pdfNetworkStream = pdfNetworkStream;
  25220. this.url = args.url;
  25221. this.disableAutoFetch = args.disableAutoFetch;
  25222. this.msgHandler = args.msgHandler;
  25223. this.currRequestId = 0;
  25224. this.chunksNeededByRequest = Object.create(null);
  25225. this.requestsByChunk = Object.create(null);
  25226. this.promisesByRequest = Object.create(null);
  25227. this.progressiveDataLength = 0;
  25228. this.aborted = false;
  25229. this._loadedStreamCapability = createPromiseCapability();
  25230. }
  25231. ChunkedStreamManager.prototype = {
  25232. onLoadedStream: function ChunkedStreamManager_getLoadedStream() {
  25233. return this._loadedStreamCapability.promise;
  25234. },
  25235. sendRequest: function ChunkedStreamManager_sendRequest(begin, end) {
  25236. var rangeReader = this.pdfNetworkStream.getRangeReader(begin, end);
  25237. if (!rangeReader.isStreamingSupported) {
  25238. rangeReader.onProgress = this.onProgress.bind(this);
  25239. }
  25240. var chunks = [], loaded = 0;
  25241. var manager = this;
  25242. var promise = new Promise(function (resolve, reject) {
  25243. var readChunk = function (chunk) {
  25244. try {
  25245. if (!chunk.done) {
  25246. var data = chunk.value;
  25247. chunks.push(data);
  25248. loaded += arrayByteLength(data);
  25249. if (rangeReader.isStreamingSupported) {
  25250. manager.onProgress({ loaded: loaded });
  25251. }
  25252. rangeReader.read().then(readChunk, reject);
  25253. return;
  25254. }
  25255. var chunkData = arraysToBytes(chunks);
  25256. chunks = null;
  25257. resolve(chunkData);
  25258. } catch (e) {
  25259. reject(e);
  25260. }
  25261. };
  25262. rangeReader.read().then(readChunk, reject);
  25263. });
  25264. promise.then(function (data) {
  25265. if (this.aborted) {
  25266. return;
  25267. }
  25268. this.onReceiveData({
  25269. chunk: data,
  25270. begin: begin
  25271. });
  25272. }.bind(this));
  25273. },
  25274. requestAllChunks: function ChunkedStreamManager_requestAllChunks() {
  25275. var missingChunks = this.stream.getMissingChunks();
  25276. this._requestChunks(missingChunks);
  25277. return this._loadedStreamCapability.promise;
  25278. },
  25279. _requestChunks: function ChunkedStreamManager_requestChunks(chunks) {
  25280. var requestId = this.currRequestId++;
  25281. var i, ii;
  25282. var chunksNeeded = Object.create(null);
  25283. this.chunksNeededByRequest[requestId] = chunksNeeded;
  25284. for (i = 0, ii = chunks.length; i < ii; i++) {
  25285. if (!this.stream.hasChunk(chunks[i])) {
  25286. chunksNeeded[chunks[i]] = true;
  25287. }
  25288. }
  25289. if (isEmptyObj(chunksNeeded)) {
  25290. return Promise.resolve();
  25291. }
  25292. var capability = createPromiseCapability();
  25293. this.promisesByRequest[requestId] = capability;
  25294. var chunksToRequest = [];
  25295. for (var chunk in chunksNeeded) {
  25296. chunk = chunk | 0;
  25297. if (!(chunk in this.requestsByChunk)) {
  25298. this.requestsByChunk[chunk] = [];
  25299. chunksToRequest.push(chunk);
  25300. }
  25301. this.requestsByChunk[chunk].push(requestId);
  25302. }
  25303. if (!chunksToRequest.length) {
  25304. return capability.promise;
  25305. }
  25306. var groupedChunksToRequest = this.groupChunks(chunksToRequest);
  25307. for (i = 0; i < groupedChunksToRequest.length; ++i) {
  25308. var groupedChunk = groupedChunksToRequest[i];
  25309. var begin = groupedChunk.beginChunk * this.chunkSize;
  25310. var end = Math.min(groupedChunk.endChunk * this.chunkSize, this.length);
  25311. this.sendRequest(begin, end);
  25312. }
  25313. return capability.promise;
  25314. },
  25315. getStream: function ChunkedStreamManager_getStream() {
  25316. return this.stream;
  25317. },
  25318. requestRange: function ChunkedStreamManager_requestRange(begin, end) {
  25319. end = Math.min(end, this.length);
  25320. var beginChunk = this.getBeginChunk(begin);
  25321. var endChunk = this.getEndChunk(end);
  25322. var chunks = [];
  25323. for (var chunk = beginChunk; chunk < endChunk; ++chunk) {
  25324. chunks.push(chunk);
  25325. }
  25326. return this._requestChunks(chunks);
  25327. },
  25328. requestRanges: function ChunkedStreamManager_requestRanges(ranges) {
  25329. ranges = ranges || [];
  25330. var chunksToRequest = [];
  25331. for (var i = 0; i < ranges.length; i++) {
  25332. var beginChunk = this.getBeginChunk(ranges[i].begin);
  25333. var endChunk = this.getEndChunk(ranges[i].end);
  25334. for (var chunk = beginChunk; chunk < endChunk; ++chunk) {
  25335. if (chunksToRequest.indexOf(chunk) < 0) {
  25336. chunksToRequest.push(chunk);
  25337. }
  25338. }
  25339. }
  25340. chunksToRequest.sort(function (a, b) {
  25341. return a - b;
  25342. });
  25343. return this._requestChunks(chunksToRequest);
  25344. },
  25345. groupChunks: function ChunkedStreamManager_groupChunks(chunks) {
  25346. var groupedChunks = [];
  25347. var beginChunk = -1;
  25348. var prevChunk = -1;
  25349. for (var i = 0; i < chunks.length; ++i) {
  25350. var chunk = chunks[i];
  25351. if (beginChunk < 0) {
  25352. beginChunk = chunk;
  25353. }
  25354. if (prevChunk >= 0 && prevChunk + 1 !== chunk) {
  25355. groupedChunks.push({
  25356. beginChunk: beginChunk,
  25357. endChunk: prevChunk + 1
  25358. });
  25359. beginChunk = chunk;
  25360. }
  25361. if (i + 1 === chunks.length) {
  25362. groupedChunks.push({
  25363. beginChunk: beginChunk,
  25364. endChunk: chunk + 1
  25365. });
  25366. }
  25367. prevChunk = chunk;
  25368. }
  25369. return groupedChunks;
  25370. },
  25371. onProgress: function ChunkedStreamManager_onProgress(args) {
  25372. var bytesLoaded = this.stream.numChunksLoaded * this.chunkSize + args.loaded;
  25373. this.msgHandler.send('DocProgress', {
  25374. loaded: bytesLoaded,
  25375. total: this.length
  25376. });
  25377. },
  25378. onReceiveData: function ChunkedStreamManager_onReceiveData(args) {
  25379. var chunk = args.chunk;
  25380. var isProgressive = args.begin === undefined;
  25381. var begin = isProgressive ? this.progressiveDataLength : args.begin;
  25382. var end = begin + chunk.byteLength;
  25383. var beginChunk = Math.floor(begin / this.chunkSize);
  25384. var endChunk = end < this.length ? Math.floor(end / this.chunkSize) : Math.ceil(end / this.chunkSize);
  25385. if (isProgressive) {
  25386. this.stream.onReceiveProgressiveData(chunk);
  25387. this.progressiveDataLength = end;
  25388. } else {
  25389. this.stream.onReceiveData(begin, chunk);
  25390. }
  25391. if (this.stream.allChunksLoaded()) {
  25392. this._loadedStreamCapability.resolve(this.stream);
  25393. }
  25394. var loadedRequests = [];
  25395. var i, requestId;
  25396. for (chunk = beginChunk; chunk < endChunk; ++chunk) {
  25397. var requestIds = this.requestsByChunk[chunk] || [];
  25398. delete this.requestsByChunk[chunk];
  25399. for (i = 0; i < requestIds.length; ++i) {
  25400. requestId = requestIds[i];
  25401. var chunksNeeded = this.chunksNeededByRequest[requestId];
  25402. if (chunk in chunksNeeded) {
  25403. delete chunksNeeded[chunk];
  25404. }
  25405. if (!isEmptyObj(chunksNeeded)) {
  25406. continue;
  25407. }
  25408. loadedRequests.push(requestId);
  25409. }
  25410. }
  25411. if (!this.disableAutoFetch && isEmptyObj(this.requestsByChunk)) {
  25412. var nextEmptyChunk;
  25413. if (this.stream.numChunksLoaded === 1) {
  25414. var lastChunk = this.stream.numChunks - 1;
  25415. if (!this.stream.hasChunk(lastChunk)) {
  25416. nextEmptyChunk = lastChunk;
  25417. }
  25418. } else {
  25419. nextEmptyChunk = this.stream.nextEmptyChunk(endChunk);
  25420. }
  25421. if (isInt(nextEmptyChunk)) {
  25422. this._requestChunks([nextEmptyChunk]);
  25423. }
  25424. }
  25425. for (i = 0; i < loadedRequests.length; ++i) {
  25426. requestId = loadedRequests[i];
  25427. var capability = this.promisesByRequest[requestId];
  25428. delete this.promisesByRequest[requestId];
  25429. capability.resolve();
  25430. }
  25431. this.msgHandler.send('DocProgress', {
  25432. loaded: this.stream.numChunksLoaded * this.chunkSize,
  25433. total: this.length
  25434. });
  25435. },
  25436. onError: function ChunkedStreamManager_onError(err) {
  25437. this._loadedStreamCapability.reject(err);
  25438. },
  25439. getBeginChunk: function ChunkedStreamManager_getBeginChunk(begin) {
  25440. var chunk = Math.floor(begin / this.chunkSize);
  25441. return chunk;
  25442. },
  25443. getEndChunk: function ChunkedStreamManager_getEndChunk(end) {
  25444. var chunk = Math.floor((end - 1) / this.chunkSize) + 1;
  25445. return chunk;
  25446. },
  25447. abort: function ChunkedStreamManager_abort() {
  25448. this.aborted = true;
  25449. if (this.pdfNetworkStream) {
  25450. this.pdfNetworkStream.cancelAllRequests('abort');
  25451. }
  25452. for (var requestId in this.promisesByRequest) {
  25453. var capability = this.promisesByRequest[requestId];
  25454. capability.reject(new Error('Request was aborted'));
  25455. }
  25456. }
  25457. };
  25458. return ChunkedStreamManager;
  25459. }();
  25460. exports.ChunkedStream = ChunkedStream;
  25461. exports.ChunkedStreamManager = ChunkedStreamManager;
  25462. /***/ }),
  25463. /* 16 */
  25464. /***/ (function(module, exports, __w_pdfjs_require__) {
  25465. "use strict";
  25466. var sharedUtil = __w_pdfjs_require__(0);
  25467. var corePrimitives = __w_pdfjs_require__(1);
  25468. var coreStream = __w_pdfjs_require__(2);
  25469. var PasswordException = sharedUtil.PasswordException;
  25470. var PasswordResponses = sharedUtil.PasswordResponses;
  25471. var bytesToString = sharedUtil.bytesToString;
  25472. var warn = sharedUtil.warn;
  25473. var error = sharedUtil.error;
  25474. var assert = sharedUtil.assert;
  25475. var isInt = sharedUtil.isInt;
  25476. var stringToBytes = sharedUtil.stringToBytes;
  25477. var utf8StringToString = sharedUtil.utf8StringToString;
  25478. var Name = corePrimitives.Name;
  25479. var isName = corePrimitives.isName;
  25480. var isDict = corePrimitives.isDict;
  25481. var DecryptStream = coreStream.DecryptStream;
  25482. var ARCFourCipher = function ARCFourCipherClosure() {
  25483. function ARCFourCipher(key) {
  25484. this.a = 0;
  25485. this.b = 0;
  25486. var s = new Uint8Array(256);
  25487. var i, j = 0, tmp, keyLength = key.length;
  25488. for (i = 0; i < 256; ++i) {
  25489. s[i] = i;
  25490. }
  25491. for (i = 0; i < 256; ++i) {
  25492. tmp = s[i];
  25493. j = j + tmp + key[i % keyLength] & 0xFF;
  25494. s[i] = s[j];
  25495. s[j] = tmp;
  25496. }
  25497. this.s = s;
  25498. }
  25499. ARCFourCipher.prototype = {
  25500. encryptBlock: function ARCFourCipher_encryptBlock(data) {
  25501. var i, n = data.length, tmp, tmp2;
  25502. var a = this.a, b = this.b, s = this.s;
  25503. var output = new Uint8Array(n);
  25504. for (i = 0; i < n; ++i) {
  25505. a = a + 1 & 0xFF;
  25506. tmp = s[a];
  25507. b = b + tmp & 0xFF;
  25508. tmp2 = s[b];
  25509. s[a] = tmp2;
  25510. s[b] = tmp;
  25511. output[i] = data[i] ^ s[tmp + tmp2 & 0xFF];
  25512. }
  25513. this.a = a;
  25514. this.b = b;
  25515. return output;
  25516. }
  25517. };
  25518. ARCFourCipher.prototype.decryptBlock = ARCFourCipher.prototype.encryptBlock;
  25519. return ARCFourCipher;
  25520. }();
  25521. var calculateMD5 = function calculateMD5Closure() {
  25522. var r = new Uint8Array([
  25523. 7,
  25524. 12,
  25525. 17,
  25526. 22,
  25527. 7,
  25528. 12,
  25529. 17,
  25530. 22,
  25531. 7,
  25532. 12,
  25533. 17,
  25534. 22,
  25535. 7,
  25536. 12,
  25537. 17,
  25538. 22,
  25539. 5,
  25540. 9,
  25541. 14,
  25542. 20,
  25543. 5,
  25544. 9,
  25545. 14,
  25546. 20,
  25547. 5,
  25548. 9,
  25549. 14,
  25550. 20,
  25551. 5,
  25552. 9,
  25553. 14,
  25554. 20,
  25555. 4,
  25556. 11,
  25557. 16,
  25558. 23,
  25559. 4,
  25560. 11,
  25561. 16,
  25562. 23,
  25563. 4,
  25564. 11,
  25565. 16,
  25566. 23,
  25567. 4,
  25568. 11,
  25569. 16,
  25570. 23,
  25571. 6,
  25572. 10,
  25573. 15,
  25574. 21,
  25575. 6,
  25576. 10,
  25577. 15,
  25578. 21,
  25579. 6,
  25580. 10,
  25581. 15,
  25582. 21,
  25583. 6,
  25584. 10,
  25585. 15,
  25586. 21
  25587. ]);
  25588. var k = new Int32Array([
  25589. -680876936,
  25590. -389564586,
  25591. 606105819,
  25592. -1044525330,
  25593. -176418897,
  25594. 1200080426,
  25595. -1473231341,
  25596. -45705983,
  25597. 1770035416,
  25598. -1958414417,
  25599. -42063,
  25600. -1990404162,
  25601. 1804603682,
  25602. -40341101,
  25603. -1502002290,
  25604. 1236535329,
  25605. -165796510,
  25606. -1069501632,
  25607. 643717713,
  25608. -373897302,
  25609. -701558691,
  25610. 38016083,
  25611. -660478335,
  25612. -405537848,
  25613. 568446438,
  25614. -1019803690,
  25615. -187363961,
  25616. 1163531501,
  25617. -1444681467,
  25618. -51403784,
  25619. 1735328473,
  25620. -1926607734,
  25621. -378558,
  25622. -2022574463,
  25623. 1839030562,
  25624. -35309556,
  25625. -1530992060,
  25626. 1272893353,
  25627. -155497632,
  25628. -1094730640,
  25629. 681279174,
  25630. -358537222,
  25631. -722521979,
  25632. 76029189,
  25633. -640364487,
  25634. -421815835,
  25635. 530742520,
  25636. -995338651,
  25637. -198630844,
  25638. 1126891415,
  25639. -1416354905,
  25640. -57434055,
  25641. 1700485571,
  25642. -1894986606,
  25643. -1051523,
  25644. -2054922799,
  25645. 1873313359,
  25646. -30611744,
  25647. -1560198380,
  25648. 1309151649,
  25649. -145523070,
  25650. -1120210379,
  25651. 718787259,
  25652. -343485551
  25653. ]);
  25654. function hash(data, offset, length) {
  25655. var h0 = 1732584193, h1 = -271733879, h2 = -1732584194, h3 = 271733878;
  25656. var paddedLength = length + 72 & ~63;
  25657. var padded = new Uint8Array(paddedLength);
  25658. var i, j, n;
  25659. for (i = 0; i < length; ++i) {
  25660. padded[i] = data[offset++];
  25661. }
  25662. padded[i++] = 0x80;
  25663. n = paddedLength - 8;
  25664. while (i < n) {
  25665. padded[i++] = 0;
  25666. }
  25667. padded[i++] = length << 3 & 0xFF;
  25668. padded[i++] = length >> 5 & 0xFF;
  25669. padded[i++] = length >> 13 & 0xFF;
  25670. padded[i++] = length >> 21 & 0xFF;
  25671. padded[i++] = length >>> 29 & 0xFF;
  25672. padded[i++] = 0;
  25673. padded[i++] = 0;
  25674. padded[i++] = 0;
  25675. var w = new Int32Array(16);
  25676. for (i = 0; i < paddedLength;) {
  25677. for (j = 0; j < 16; ++j, i += 4) {
  25678. w[j] = padded[i] | padded[i + 1] << 8 | padded[i + 2] << 16 | padded[i + 3] << 24;
  25679. }
  25680. var a = h0, b = h1, c = h2, d = h3, f, g;
  25681. for (j = 0; j < 64; ++j) {
  25682. if (j < 16) {
  25683. f = b & c | ~b & d;
  25684. g = j;
  25685. } else if (j < 32) {
  25686. f = d & b | ~d & c;
  25687. g = 5 * j + 1 & 15;
  25688. } else if (j < 48) {
  25689. f = b ^ c ^ d;
  25690. g = 3 * j + 5 & 15;
  25691. } else {
  25692. f = c ^ (b | ~d);
  25693. g = 7 * j & 15;
  25694. }
  25695. var tmp = d, rotateArg = a + f + k[j] + w[g] | 0, rotate = r[j];
  25696. d = c;
  25697. c = b;
  25698. b = b + (rotateArg << rotate | rotateArg >>> 32 - rotate) | 0;
  25699. a = tmp;
  25700. }
  25701. h0 = h0 + a | 0;
  25702. h1 = h1 + b | 0;
  25703. h2 = h2 + c | 0;
  25704. h3 = h3 + d | 0;
  25705. }
  25706. return new Uint8Array([
  25707. h0 & 0xFF,
  25708. h0 >> 8 & 0xFF,
  25709. h0 >> 16 & 0xFF,
  25710. h0 >>> 24 & 0xFF,
  25711. h1 & 0xFF,
  25712. h1 >> 8 & 0xFF,
  25713. h1 >> 16 & 0xFF,
  25714. h1 >>> 24 & 0xFF,
  25715. h2 & 0xFF,
  25716. h2 >> 8 & 0xFF,
  25717. h2 >> 16 & 0xFF,
  25718. h2 >>> 24 & 0xFF,
  25719. h3 & 0xFF,
  25720. h3 >> 8 & 0xFF,
  25721. h3 >> 16 & 0xFF,
  25722. h3 >>> 24 & 0xFF
  25723. ]);
  25724. }
  25725. return hash;
  25726. }();
  25727. var Word64 = function Word64Closure() {
  25728. function Word64(highInteger, lowInteger) {
  25729. this.high = highInteger | 0;
  25730. this.low = lowInteger | 0;
  25731. }
  25732. Word64.prototype = {
  25733. and: function Word64_and(word) {
  25734. this.high &= word.high;
  25735. this.low &= word.low;
  25736. },
  25737. xor: function Word64_xor(word) {
  25738. this.high ^= word.high;
  25739. this.low ^= word.low;
  25740. },
  25741. or: function Word64_or(word) {
  25742. this.high |= word.high;
  25743. this.low |= word.low;
  25744. },
  25745. shiftRight: function Word64_shiftRight(places) {
  25746. if (places >= 32) {
  25747. this.low = this.high >>> places - 32 | 0;
  25748. this.high = 0;
  25749. } else {
  25750. this.low = this.low >>> places | this.high << 32 - places;
  25751. this.high = this.high >>> places | 0;
  25752. }
  25753. },
  25754. shiftLeft: function Word64_shiftLeft(places) {
  25755. if (places >= 32) {
  25756. this.high = this.low << places - 32;
  25757. this.low = 0;
  25758. } else {
  25759. this.high = this.high << places | this.low >>> 32 - places;
  25760. this.low = this.low << places;
  25761. }
  25762. },
  25763. rotateRight: function Word64_rotateRight(places) {
  25764. var low, high;
  25765. if (places & 32) {
  25766. high = this.low;
  25767. low = this.high;
  25768. } else {
  25769. low = this.low;
  25770. high = this.high;
  25771. }
  25772. places &= 31;
  25773. this.low = low >>> places | high << 32 - places;
  25774. this.high = high >>> places | low << 32 - places;
  25775. },
  25776. not: function Word64_not() {
  25777. this.high = ~this.high;
  25778. this.low = ~this.low;
  25779. },
  25780. add: function Word64_add(word) {
  25781. var lowAdd = (this.low >>> 0) + (word.low >>> 0);
  25782. var highAdd = (this.high >>> 0) + (word.high >>> 0);
  25783. if (lowAdd > 0xFFFFFFFF) {
  25784. highAdd += 1;
  25785. }
  25786. this.low = lowAdd | 0;
  25787. this.high = highAdd | 0;
  25788. },
  25789. copyTo: function Word64_copyTo(bytes, offset) {
  25790. bytes[offset] = this.high >>> 24 & 0xFF;
  25791. bytes[offset + 1] = this.high >> 16 & 0xFF;
  25792. bytes[offset + 2] = this.high >> 8 & 0xFF;
  25793. bytes[offset + 3] = this.high & 0xFF;
  25794. bytes[offset + 4] = this.low >>> 24 & 0xFF;
  25795. bytes[offset + 5] = this.low >> 16 & 0xFF;
  25796. bytes[offset + 6] = this.low >> 8 & 0xFF;
  25797. bytes[offset + 7] = this.low & 0xFF;
  25798. },
  25799. assign: function Word64_assign(word) {
  25800. this.high = word.high;
  25801. this.low = word.low;
  25802. }
  25803. };
  25804. return Word64;
  25805. }();
  25806. var calculateSHA256 = function calculateSHA256Closure() {
  25807. function rotr(x, n) {
  25808. return x >>> n | x << 32 - n;
  25809. }
  25810. function ch(x, y, z) {
  25811. return x & y ^ ~x & z;
  25812. }
  25813. function maj(x, y, z) {
  25814. return x & y ^ x & z ^ y & z;
  25815. }
  25816. function sigma(x) {
  25817. return rotr(x, 2) ^ rotr(x, 13) ^ rotr(x, 22);
  25818. }
  25819. function sigmaPrime(x) {
  25820. return rotr(x, 6) ^ rotr(x, 11) ^ rotr(x, 25);
  25821. }
  25822. function littleSigma(x) {
  25823. return rotr(x, 7) ^ rotr(x, 18) ^ x >>> 3;
  25824. }
  25825. function littleSigmaPrime(x) {
  25826. return rotr(x, 17) ^ rotr(x, 19) ^ x >>> 10;
  25827. }
  25828. var k = [
  25829. 0x428a2f98,
  25830. 0x71374491,
  25831. 0xb5c0fbcf,
  25832. 0xe9b5dba5,
  25833. 0x3956c25b,
  25834. 0x59f111f1,
  25835. 0x923f82a4,
  25836. 0xab1c5ed5,
  25837. 0xd807aa98,
  25838. 0x12835b01,
  25839. 0x243185be,
  25840. 0x550c7dc3,
  25841. 0x72be5d74,
  25842. 0x80deb1fe,
  25843. 0x9bdc06a7,
  25844. 0xc19bf174,
  25845. 0xe49b69c1,
  25846. 0xefbe4786,
  25847. 0x0fc19dc6,
  25848. 0x240ca1cc,
  25849. 0x2de92c6f,
  25850. 0x4a7484aa,
  25851. 0x5cb0a9dc,
  25852. 0x76f988da,
  25853. 0x983e5152,
  25854. 0xa831c66d,
  25855. 0xb00327c8,
  25856. 0xbf597fc7,
  25857. 0xc6e00bf3,
  25858. 0xd5a79147,
  25859. 0x06ca6351,
  25860. 0x14292967,
  25861. 0x27b70a85,
  25862. 0x2e1b2138,
  25863. 0x4d2c6dfc,
  25864. 0x53380d13,
  25865. 0x650a7354,
  25866. 0x766a0abb,
  25867. 0x81c2c92e,
  25868. 0x92722c85,
  25869. 0xa2bfe8a1,
  25870. 0xa81a664b,
  25871. 0xc24b8b70,
  25872. 0xc76c51a3,
  25873. 0xd192e819,
  25874. 0xd6990624,
  25875. 0xf40e3585,
  25876. 0x106aa070,
  25877. 0x19a4c116,
  25878. 0x1e376c08,
  25879. 0x2748774c,
  25880. 0x34b0bcb5,
  25881. 0x391c0cb3,
  25882. 0x4ed8aa4a,
  25883. 0x5b9cca4f,
  25884. 0x682e6ff3,
  25885. 0x748f82ee,
  25886. 0x78a5636f,
  25887. 0x84c87814,
  25888. 0x8cc70208,
  25889. 0x90befffa,
  25890. 0xa4506ceb,
  25891. 0xbef9a3f7,
  25892. 0xc67178f2
  25893. ];
  25894. function hash(data, offset, length) {
  25895. var h0 = 0x6a09e667, h1 = 0xbb67ae85, h2 = 0x3c6ef372, h3 = 0xa54ff53a, h4 = 0x510e527f, h5 = 0x9b05688c, h6 = 0x1f83d9ab, h7 = 0x5be0cd19;
  25896. var paddedLength = Math.ceil((length + 9) / 64) * 64;
  25897. var padded = new Uint8Array(paddedLength);
  25898. var i, j, n;
  25899. for (i = 0; i < length; ++i) {
  25900. padded[i] = data[offset++];
  25901. }
  25902. padded[i++] = 0x80;
  25903. n = paddedLength - 8;
  25904. while (i < n) {
  25905. padded[i++] = 0;
  25906. }
  25907. padded[i++] = 0;
  25908. padded[i++] = 0;
  25909. padded[i++] = 0;
  25910. padded[i++] = length >>> 29 & 0xFF;
  25911. padded[i++] = length >> 21 & 0xFF;
  25912. padded[i++] = length >> 13 & 0xFF;
  25913. padded[i++] = length >> 5 & 0xFF;
  25914. padded[i++] = length << 3 & 0xFF;
  25915. var w = new Uint32Array(64);
  25916. for (i = 0; i < paddedLength;) {
  25917. for (j = 0; j < 16; ++j) {
  25918. w[j] = padded[i] << 24 | padded[i + 1] << 16 | padded[i + 2] << 8 | padded[i + 3];
  25919. i += 4;
  25920. }
  25921. for (j = 16; j < 64; ++j) {
  25922. w[j] = littleSigmaPrime(w[j - 2]) + w[j - 7] + littleSigma(w[j - 15]) + w[j - 16] | 0;
  25923. }
  25924. var a = h0, b = h1, c = h2, d = h3, e = h4, f = h5, g = h6, h = h7, t1, t2;
  25925. for (j = 0; j < 64; ++j) {
  25926. t1 = h + sigmaPrime(e) + ch(e, f, g) + k[j] + w[j];
  25927. t2 = sigma(a) + maj(a, b, c);
  25928. h = g;
  25929. g = f;
  25930. f = e;
  25931. e = d + t1 | 0;
  25932. d = c;
  25933. c = b;
  25934. b = a;
  25935. a = t1 + t2 | 0;
  25936. }
  25937. h0 = h0 + a | 0;
  25938. h1 = h1 + b | 0;
  25939. h2 = h2 + c | 0;
  25940. h3 = h3 + d | 0;
  25941. h4 = h4 + e | 0;
  25942. h5 = h5 + f | 0;
  25943. h6 = h6 + g | 0;
  25944. h7 = h7 + h | 0;
  25945. }
  25946. return new Uint8Array([
  25947. h0 >> 24 & 0xFF,
  25948. h0 >> 16 & 0xFF,
  25949. h0 >> 8 & 0xFF,
  25950. h0 & 0xFF,
  25951. h1 >> 24 & 0xFF,
  25952. h1 >> 16 & 0xFF,
  25953. h1 >> 8 & 0xFF,
  25954. h1 & 0xFF,
  25955. h2 >> 24 & 0xFF,
  25956. h2 >> 16 & 0xFF,
  25957. h2 >> 8 & 0xFF,
  25958. h2 & 0xFF,
  25959. h3 >> 24 & 0xFF,
  25960. h3 >> 16 & 0xFF,
  25961. h3 >> 8 & 0xFF,
  25962. h3 & 0xFF,
  25963. h4 >> 24 & 0xFF,
  25964. h4 >> 16 & 0xFF,
  25965. h4 >> 8 & 0xFF,
  25966. h4 & 0xFF,
  25967. h5 >> 24 & 0xFF,
  25968. h5 >> 16 & 0xFF,
  25969. h5 >> 8 & 0xFF,
  25970. h5 & 0xFF,
  25971. h6 >> 24 & 0xFF,
  25972. h6 >> 16 & 0xFF,
  25973. h6 >> 8 & 0xFF,
  25974. h6 & 0xFF,
  25975. h7 >> 24 & 0xFF,
  25976. h7 >> 16 & 0xFF,
  25977. h7 >> 8 & 0xFF,
  25978. h7 & 0xFF
  25979. ]);
  25980. }
  25981. return hash;
  25982. }();
  25983. var calculateSHA512 = function calculateSHA512Closure() {
  25984. function ch(result, x, y, z, tmp) {
  25985. result.assign(x);
  25986. result.and(y);
  25987. tmp.assign(x);
  25988. tmp.not();
  25989. tmp.and(z);
  25990. result.xor(tmp);
  25991. }
  25992. function maj(result, x, y, z, tmp) {
  25993. result.assign(x);
  25994. result.and(y);
  25995. tmp.assign(x);
  25996. tmp.and(z);
  25997. result.xor(tmp);
  25998. tmp.assign(y);
  25999. tmp.and(z);
  26000. result.xor(tmp);
  26001. }
  26002. function sigma(result, x, tmp) {
  26003. result.assign(x);
  26004. result.rotateRight(28);
  26005. tmp.assign(x);
  26006. tmp.rotateRight(34);
  26007. result.xor(tmp);
  26008. tmp.assign(x);
  26009. tmp.rotateRight(39);
  26010. result.xor(tmp);
  26011. }
  26012. function sigmaPrime(result, x, tmp) {
  26013. result.assign(x);
  26014. result.rotateRight(14);
  26015. tmp.assign(x);
  26016. tmp.rotateRight(18);
  26017. result.xor(tmp);
  26018. tmp.assign(x);
  26019. tmp.rotateRight(41);
  26020. result.xor(tmp);
  26021. }
  26022. function littleSigma(result, x, tmp) {
  26023. result.assign(x);
  26024. result.rotateRight(1);
  26025. tmp.assign(x);
  26026. tmp.rotateRight(8);
  26027. result.xor(tmp);
  26028. tmp.assign(x);
  26029. tmp.shiftRight(7);
  26030. result.xor(tmp);
  26031. }
  26032. function littleSigmaPrime(result, x, tmp) {
  26033. result.assign(x);
  26034. result.rotateRight(19);
  26035. tmp.assign(x);
  26036. tmp.rotateRight(61);
  26037. result.xor(tmp);
  26038. tmp.assign(x);
  26039. tmp.shiftRight(6);
  26040. result.xor(tmp);
  26041. }
  26042. var k = [
  26043. new Word64(0x428a2f98, 0xd728ae22),
  26044. new Word64(0x71374491, 0x23ef65cd),
  26045. new Word64(0xb5c0fbcf, 0xec4d3b2f),
  26046. new Word64(0xe9b5dba5, 0x8189dbbc),
  26047. new Word64(0x3956c25b, 0xf348b538),
  26048. new Word64(0x59f111f1, 0xb605d019),
  26049. new Word64(0x923f82a4, 0xaf194f9b),
  26050. new Word64(0xab1c5ed5, 0xda6d8118),
  26051. new Word64(0xd807aa98, 0xa3030242),
  26052. new Word64(0x12835b01, 0x45706fbe),
  26053. new Word64(0x243185be, 0x4ee4b28c),
  26054. new Word64(0x550c7dc3, 0xd5ffb4e2),
  26055. new Word64(0x72be5d74, 0xf27b896f),
  26056. new Word64(0x80deb1fe, 0x3b1696b1),
  26057. new Word64(0x9bdc06a7, 0x25c71235),
  26058. new Word64(0xc19bf174, 0xcf692694),
  26059. new Word64(0xe49b69c1, 0x9ef14ad2),
  26060. new Word64(0xefbe4786, 0x384f25e3),
  26061. new Word64(0x0fc19dc6, 0x8b8cd5b5),
  26062. new Word64(0x240ca1cc, 0x77ac9c65),
  26063. new Word64(0x2de92c6f, 0x592b0275),
  26064. new Word64(0x4a7484aa, 0x6ea6e483),
  26065. new Word64(0x5cb0a9dc, 0xbd41fbd4),
  26066. new Word64(0x76f988da, 0x831153b5),
  26067. new Word64(0x983e5152, 0xee66dfab),
  26068. new Word64(0xa831c66d, 0x2db43210),
  26069. new Word64(0xb00327c8, 0x98fb213f),
  26070. new Word64(0xbf597fc7, 0xbeef0ee4),
  26071. new Word64(0xc6e00bf3, 0x3da88fc2),
  26072. new Word64(0xd5a79147, 0x930aa725),
  26073. new Word64(0x06ca6351, 0xe003826f),
  26074. new Word64(0x14292967, 0x0a0e6e70),
  26075. new Word64(0x27b70a85, 0x46d22ffc),
  26076. new Word64(0x2e1b2138, 0x5c26c926),
  26077. new Word64(0x4d2c6dfc, 0x5ac42aed),
  26078. new Word64(0x53380d13, 0x9d95b3df),
  26079. new Word64(0x650a7354, 0x8baf63de),
  26080. new Word64(0x766a0abb, 0x3c77b2a8),
  26081. new Word64(0x81c2c92e, 0x47edaee6),
  26082. new Word64(0x92722c85, 0x1482353b),
  26083. new Word64(0xa2bfe8a1, 0x4cf10364),
  26084. new Word64(0xa81a664b, 0xbc423001),
  26085. new Word64(0xc24b8b70, 0xd0f89791),
  26086. new Word64(0xc76c51a3, 0x0654be30),
  26087. new Word64(0xd192e819, 0xd6ef5218),
  26088. new Word64(0xd6990624, 0x5565a910),
  26089. new Word64(0xf40e3585, 0x5771202a),
  26090. new Word64(0x106aa070, 0x32bbd1b8),
  26091. new Word64(0x19a4c116, 0xb8d2d0c8),
  26092. new Word64(0x1e376c08, 0x5141ab53),
  26093. new Word64(0x2748774c, 0xdf8eeb99),
  26094. new Word64(0x34b0bcb5, 0xe19b48a8),
  26095. new Word64(0x391c0cb3, 0xc5c95a63),
  26096. new Word64(0x4ed8aa4a, 0xe3418acb),
  26097. new Word64(0x5b9cca4f, 0x7763e373),
  26098. new Word64(0x682e6ff3, 0xd6b2b8a3),
  26099. new Word64(0x748f82ee, 0x5defb2fc),
  26100. new Word64(0x78a5636f, 0x43172f60),
  26101. new Word64(0x84c87814, 0xa1f0ab72),
  26102. new Word64(0x8cc70208, 0x1a6439ec),
  26103. new Word64(0x90befffa, 0x23631e28),
  26104. new Word64(0xa4506ceb, 0xde82bde9),
  26105. new Word64(0xbef9a3f7, 0xb2c67915),
  26106. new Word64(0xc67178f2, 0xe372532b),
  26107. new Word64(0xca273ece, 0xea26619c),
  26108. new Word64(0xd186b8c7, 0x21c0c207),
  26109. new Word64(0xeada7dd6, 0xcde0eb1e),
  26110. new Word64(0xf57d4f7f, 0xee6ed178),
  26111. new Word64(0x06f067aa, 0x72176fba),
  26112. new Word64(0x0a637dc5, 0xa2c898a6),
  26113. new Word64(0x113f9804, 0xbef90dae),
  26114. new Word64(0x1b710b35, 0x131c471b),
  26115. new Word64(0x28db77f5, 0x23047d84),
  26116. new Word64(0x32caab7b, 0x40c72493),
  26117. new Word64(0x3c9ebe0a, 0x15c9bebc),
  26118. new Word64(0x431d67c4, 0x9c100d4c),
  26119. new Word64(0x4cc5d4be, 0xcb3e42b6),
  26120. new Word64(0x597f299c, 0xfc657e2a),
  26121. new Word64(0x5fcb6fab, 0x3ad6faec),
  26122. new Word64(0x6c44198c, 0x4a475817)
  26123. ];
  26124. function hash(data, offset, length, mode384) {
  26125. mode384 = !!mode384;
  26126. var h0, h1, h2, h3, h4, h5, h6, h7;
  26127. if (!mode384) {
  26128. h0 = new Word64(0x6a09e667, 0xf3bcc908);
  26129. h1 = new Word64(0xbb67ae85, 0x84caa73b);
  26130. h2 = new Word64(0x3c6ef372, 0xfe94f82b);
  26131. h3 = new Word64(0xa54ff53a, 0x5f1d36f1);
  26132. h4 = new Word64(0x510e527f, 0xade682d1);
  26133. h5 = new Word64(0x9b05688c, 0x2b3e6c1f);
  26134. h6 = new Word64(0x1f83d9ab, 0xfb41bd6b);
  26135. h7 = new Word64(0x5be0cd19, 0x137e2179);
  26136. } else {
  26137. h0 = new Word64(0xcbbb9d5d, 0xc1059ed8);
  26138. h1 = new Word64(0x629a292a, 0x367cd507);
  26139. h2 = new Word64(0x9159015a, 0x3070dd17);
  26140. h3 = new Word64(0x152fecd8, 0xf70e5939);
  26141. h4 = new Word64(0x67332667, 0xffc00b31);
  26142. h5 = new Word64(0x8eb44a87, 0x68581511);
  26143. h6 = new Word64(0xdb0c2e0d, 0x64f98fa7);
  26144. h7 = new Word64(0x47b5481d, 0xbefa4fa4);
  26145. }
  26146. var paddedLength = Math.ceil((length + 17) / 128) * 128;
  26147. var padded = new Uint8Array(paddedLength);
  26148. var i, j, n;
  26149. for (i = 0; i < length; ++i) {
  26150. padded[i] = data[offset++];
  26151. }
  26152. padded[i++] = 0x80;
  26153. n = paddedLength - 16;
  26154. while (i < n) {
  26155. padded[i++] = 0;
  26156. }
  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++] = 0;
  26168. padded[i++] = length >>> 29 & 0xFF;
  26169. padded[i++] = length >> 21 & 0xFF;
  26170. padded[i++] = length >> 13 & 0xFF;
  26171. padded[i++] = length >> 5 & 0xFF;
  26172. padded[i++] = length << 3 & 0xFF;
  26173. var w = new Array(80);
  26174. for (i = 0; i < 80; i++) {
  26175. w[i] = new Word64(0, 0);
  26176. }
  26177. var a = new Word64(0, 0), b = new Word64(0, 0), c = new Word64(0, 0);
  26178. var d = new Word64(0, 0), e = new Word64(0, 0), f = new Word64(0, 0);
  26179. var g = new Word64(0, 0), h = new Word64(0, 0);
  26180. var t1 = new Word64(0, 0), t2 = new Word64(0, 0);
  26181. var tmp1 = new Word64(0, 0), tmp2 = new Word64(0, 0), tmp3;
  26182. for (i = 0; i < paddedLength;) {
  26183. for (j = 0; j < 16; ++j) {
  26184. w[j].high = padded[i] << 24 | padded[i + 1] << 16 | padded[i + 2] << 8 | padded[i + 3];
  26185. w[j].low = padded[i + 4] << 24 | padded[i + 5] << 16 | padded[i + 6] << 8 | padded[i + 7];
  26186. i += 8;
  26187. }
  26188. for (j = 16; j < 80; ++j) {
  26189. tmp3 = w[j];
  26190. littleSigmaPrime(tmp3, w[j - 2], tmp2);
  26191. tmp3.add(w[j - 7]);
  26192. littleSigma(tmp1, w[j - 15], tmp2);
  26193. tmp3.add(tmp1);
  26194. tmp3.add(w[j - 16]);
  26195. }
  26196. a.assign(h0);
  26197. b.assign(h1);
  26198. c.assign(h2);
  26199. d.assign(h3);
  26200. e.assign(h4);
  26201. f.assign(h5);
  26202. g.assign(h6);
  26203. h.assign(h7);
  26204. for (j = 0; j < 80; ++j) {
  26205. t1.assign(h);
  26206. sigmaPrime(tmp1, e, tmp2);
  26207. t1.add(tmp1);
  26208. ch(tmp1, e, f, g, tmp2);
  26209. t1.add(tmp1);
  26210. t1.add(k[j]);
  26211. t1.add(w[j]);
  26212. sigma(t2, a, tmp2);
  26213. maj(tmp1, a, b, c, tmp2);
  26214. t2.add(tmp1);
  26215. tmp3 = h;
  26216. h = g;
  26217. g = f;
  26218. f = e;
  26219. d.add(t1);
  26220. e = d;
  26221. d = c;
  26222. c = b;
  26223. b = a;
  26224. tmp3.assign(t1);
  26225. tmp3.add(t2);
  26226. a = tmp3;
  26227. }
  26228. h0.add(a);
  26229. h1.add(b);
  26230. h2.add(c);
  26231. h3.add(d);
  26232. h4.add(e);
  26233. h5.add(f);
  26234. h6.add(g);
  26235. h7.add(h);
  26236. }
  26237. var result;
  26238. if (!mode384) {
  26239. result = new Uint8Array(64);
  26240. h0.copyTo(result, 0);
  26241. h1.copyTo(result, 8);
  26242. h2.copyTo(result, 16);
  26243. h3.copyTo(result, 24);
  26244. h4.copyTo(result, 32);
  26245. h5.copyTo(result, 40);
  26246. h6.copyTo(result, 48);
  26247. h7.copyTo(result, 56);
  26248. } else {
  26249. result = new Uint8Array(48);
  26250. h0.copyTo(result, 0);
  26251. h1.copyTo(result, 8);
  26252. h2.copyTo(result, 16);
  26253. h3.copyTo(result, 24);
  26254. h4.copyTo(result, 32);
  26255. h5.copyTo(result, 40);
  26256. }
  26257. return result;
  26258. }
  26259. return hash;
  26260. }();
  26261. var calculateSHA384 = function calculateSHA384Closure() {
  26262. function hash(data, offset, length) {
  26263. return calculateSHA512(data, offset, length, true);
  26264. }
  26265. return hash;
  26266. }();
  26267. var NullCipher = function NullCipherClosure() {
  26268. function NullCipher() {
  26269. }
  26270. NullCipher.prototype = {
  26271. decryptBlock: function NullCipher_decryptBlock(data) {
  26272. return data;
  26273. }
  26274. };
  26275. return NullCipher;
  26276. }();
  26277. var AES128Cipher = function AES128CipherClosure() {
  26278. var rcon = new Uint8Array([
  26279. 0x8d,
  26280. 0x01,
  26281. 0x02,
  26282. 0x04,
  26283. 0x08,
  26284. 0x10,
  26285. 0x20,
  26286. 0x40,
  26287. 0x80,
  26288. 0x1b,
  26289. 0x36,
  26290. 0x6c,
  26291. 0xd8,
  26292. 0xab,
  26293. 0x4d,
  26294. 0x9a,
  26295. 0x2f,
  26296. 0x5e,
  26297. 0xbc,
  26298. 0x63,
  26299. 0xc6,
  26300. 0x97,
  26301. 0x35,
  26302. 0x6a,
  26303. 0xd4,
  26304. 0xb3,
  26305. 0x7d,
  26306. 0xfa,
  26307. 0xef,
  26308. 0xc5,
  26309. 0x91,
  26310. 0x39,
  26311. 0x72,
  26312. 0xe4,
  26313. 0xd3,
  26314. 0xbd,
  26315. 0x61,
  26316. 0xc2,
  26317. 0x9f,
  26318. 0x25,
  26319. 0x4a,
  26320. 0x94,
  26321. 0x33,
  26322. 0x66,
  26323. 0xcc,
  26324. 0x83,
  26325. 0x1d,
  26326. 0x3a,
  26327. 0x74,
  26328. 0xe8,
  26329. 0xcb,
  26330. 0x8d,
  26331. 0x01,
  26332. 0x02,
  26333. 0x04,
  26334. 0x08,
  26335. 0x10,
  26336. 0x20,
  26337. 0x40,
  26338. 0x80,
  26339. 0x1b,
  26340. 0x36,
  26341. 0x6c,
  26342. 0xd8,
  26343. 0xab,
  26344. 0x4d,
  26345. 0x9a,
  26346. 0x2f,
  26347. 0x5e,
  26348. 0xbc,
  26349. 0x63,
  26350. 0xc6,
  26351. 0x97,
  26352. 0x35,
  26353. 0x6a,
  26354. 0xd4,
  26355. 0xb3,
  26356. 0x7d,
  26357. 0xfa,
  26358. 0xef,
  26359. 0xc5,
  26360. 0x91,
  26361. 0x39,
  26362. 0x72,
  26363. 0xe4,
  26364. 0xd3,
  26365. 0xbd,
  26366. 0x61,
  26367. 0xc2,
  26368. 0x9f,
  26369. 0x25,
  26370. 0x4a,
  26371. 0x94,
  26372. 0x33,
  26373. 0x66,
  26374. 0xcc,
  26375. 0x83,
  26376. 0x1d,
  26377. 0x3a,
  26378. 0x74,
  26379. 0xe8,
  26380. 0xcb,
  26381. 0x8d,
  26382. 0x01,
  26383. 0x02,
  26384. 0x04,
  26385. 0x08,
  26386. 0x10,
  26387. 0x20,
  26388. 0x40,
  26389. 0x80,
  26390. 0x1b,
  26391. 0x36,
  26392. 0x6c,
  26393. 0xd8,
  26394. 0xab,
  26395. 0x4d,
  26396. 0x9a,
  26397. 0x2f,
  26398. 0x5e,
  26399. 0xbc,
  26400. 0x63,
  26401. 0xc6,
  26402. 0x97,
  26403. 0x35,
  26404. 0x6a,
  26405. 0xd4,
  26406. 0xb3,
  26407. 0x7d,
  26408. 0xfa,
  26409. 0xef,
  26410. 0xc5,
  26411. 0x91,
  26412. 0x39,
  26413. 0x72,
  26414. 0xe4,
  26415. 0xd3,
  26416. 0xbd,
  26417. 0x61,
  26418. 0xc2,
  26419. 0x9f,
  26420. 0x25,
  26421. 0x4a,
  26422. 0x94,
  26423. 0x33,
  26424. 0x66,
  26425. 0xcc,
  26426. 0x83,
  26427. 0x1d,
  26428. 0x3a,
  26429. 0x74,
  26430. 0xe8,
  26431. 0xcb,
  26432. 0x8d,
  26433. 0x01,
  26434. 0x02,
  26435. 0x04,
  26436. 0x08,
  26437. 0x10,
  26438. 0x20,
  26439. 0x40,
  26440. 0x80,
  26441. 0x1b,
  26442. 0x36,
  26443. 0x6c,
  26444. 0xd8,
  26445. 0xab,
  26446. 0x4d,
  26447. 0x9a,
  26448. 0x2f,
  26449. 0x5e,
  26450. 0xbc,
  26451. 0x63,
  26452. 0xc6,
  26453. 0x97,
  26454. 0x35,
  26455. 0x6a,
  26456. 0xd4,
  26457. 0xb3,
  26458. 0x7d,
  26459. 0xfa,
  26460. 0xef,
  26461. 0xc5,
  26462. 0x91,
  26463. 0x39,
  26464. 0x72,
  26465. 0xe4,
  26466. 0xd3,
  26467. 0xbd,
  26468. 0x61,
  26469. 0xc2,
  26470. 0x9f,
  26471. 0x25,
  26472. 0x4a,
  26473. 0x94,
  26474. 0x33,
  26475. 0x66,
  26476. 0xcc,
  26477. 0x83,
  26478. 0x1d,
  26479. 0x3a,
  26480. 0x74,
  26481. 0xe8,
  26482. 0xcb,
  26483. 0x8d,
  26484. 0x01,
  26485. 0x02,
  26486. 0x04,
  26487. 0x08,
  26488. 0x10,
  26489. 0x20,
  26490. 0x40,
  26491. 0x80,
  26492. 0x1b,
  26493. 0x36,
  26494. 0x6c,
  26495. 0xd8,
  26496. 0xab,
  26497. 0x4d,
  26498. 0x9a,
  26499. 0x2f,
  26500. 0x5e,
  26501. 0xbc,
  26502. 0x63,
  26503. 0xc6,
  26504. 0x97,
  26505. 0x35,
  26506. 0x6a,
  26507. 0xd4,
  26508. 0xb3,
  26509. 0x7d,
  26510. 0xfa,
  26511. 0xef,
  26512. 0xc5,
  26513. 0x91,
  26514. 0x39,
  26515. 0x72,
  26516. 0xe4,
  26517. 0xd3,
  26518. 0xbd,
  26519. 0x61,
  26520. 0xc2,
  26521. 0x9f,
  26522. 0x25,
  26523. 0x4a,
  26524. 0x94,
  26525. 0x33,
  26526. 0x66,
  26527. 0xcc,
  26528. 0x83,
  26529. 0x1d,
  26530. 0x3a,
  26531. 0x74,
  26532. 0xe8,
  26533. 0xcb,
  26534. 0x8d
  26535. ]);
  26536. var s = new Uint8Array([
  26537. 0x63,
  26538. 0x7c,
  26539. 0x77,
  26540. 0x7b,
  26541. 0xf2,
  26542. 0x6b,
  26543. 0x6f,
  26544. 0xc5,
  26545. 0x30,
  26546. 0x01,
  26547. 0x67,
  26548. 0x2b,
  26549. 0xfe,
  26550. 0xd7,
  26551. 0xab,
  26552. 0x76,
  26553. 0xca,
  26554. 0x82,
  26555. 0xc9,
  26556. 0x7d,
  26557. 0xfa,
  26558. 0x59,
  26559. 0x47,
  26560. 0xf0,
  26561. 0xad,
  26562. 0xd4,
  26563. 0xa2,
  26564. 0xaf,
  26565. 0x9c,
  26566. 0xa4,
  26567. 0x72,
  26568. 0xc0,
  26569. 0xb7,
  26570. 0xfd,
  26571. 0x93,
  26572. 0x26,
  26573. 0x36,
  26574. 0x3f,
  26575. 0xf7,
  26576. 0xcc,
  26577. 0x34,
  26578. 0xa5,
  26579. 0xe5,
  26580. 0xf1,
  26581. 0x71,
  26582. 0xd8,
  26583. 0x31,
  26584. 0x15,
  26585. 0x04,
  26586. 0xc7,
  26587. 0x23,
  26588. 0xc3,
  26589. 0x18,
  26590. 0x96,
  26591. 0x05,
  26592. 0x9a,
  26593. 0x07,
  26594. 0x12,
  26595. 0x80,
  26596. 0xe2,
  26597. 0xeb,
  26598. 0x27,
  26599. 0xb2,
  26600. 0x75,
  26601. 0x09,
  26602. 0x83,
  26603. 0x2c,
  26604. 0x1a,
  26605. 0x1b,
  26606. 0x6e,
  26607. 0x5a,
  26608. 0xa0,
  26609. 0x52,
  26610. 0x3b,
  26611. 0xd6,
  26612. 0xb3,
  26613. 0x29,
  26614. 0xe3,
  26615. 0x2f,
  26616. 0x84,
  26617. 0x53,
  26618. 0xd1,
  26619. 0x00,
  26620. 0xed,
  26621. 0x20,
  26622. 0xfc,
  26623. 0xb1,
  26624. 0x5b,
  26625. 0x6a,
  26626. 0xcb,
  26627. 0xbe,
  26628. 0x39,
  26629. 0x4a,
  26630. 0x4c,
  26631. 0x58,
  26632. 0xcf,
  26633. 0xd0,
  26634. 0xef,
  26635. 0xaa,
  26636. 0xfb,
  26637. 0x43,
  26638. 0x4d,
  26639. 0x33,
  26640. 0x85,
  26641. 0x45,
  26642. 0xf9,
  26643. 0x02,
  26644. 0x7f,
  26645. 0x50,
  26646. 0x3c,
  26647. 0x9f,
  26648. 0xa8,
  26649. 0x51,
  26650. 0xa3,
  26651. 0x40,
  26652. 0x8f,
  26653. 0x92,
  26654. 0x9d,
  26655. 0x38,
  26656. 0xf5,
  26657. 0xbc,
  26658. 0xb6,
  26659. 0xda,
  26660. 0x21,
  26661. 0x10,
  26662. 0xff,
  26663. 0xf3,
  26664. 0xd2,
  26665. 0xcd,
  26666. 0x0c,
  26667. 0x13,
  26668. 0xec,
  26669. 0x5f,
  26670. 0x97,
  26671. 0x44,
  26672. 0x17,
  26673. 0xc4,
  26674. 0xa7,
  26675. 0x7e,
  26676. 0x3d,
  26677. 0x64,
  26678. 0x5d,
  26679. 0x19,
  26680. 0x73,
  26681. 0x60,
  26682. 0x81,
  26683. 0x4f,
  26684. 0xdc,
  26685. 0x22,
  26686. 0x2a,
  26687. 0x90,
  26688. 0x88,
  26689. 0x46,
  26690. 0xee,
  26691. 0xb8,
  26692. 0x14,
  26693. 0xde,
  26694. 0x5e,
  26695. 0x0b,
  26696. 0xdb,
  26697. 0xe0,
  26698. 0x32,
  26699. 0x3a,
  26700. 0x0a,
  26701. 0x49,
  26702. 0x06,
  26703. 0x24,
  26704. 0x5c,
  26705. 0xc2,
  26706. 0xd3,
  26707. 0xac,
  26708. 0x62,
  26709. 0x91,
  26710. 0x95,
  26711. 0xe4,
  26712. 0x79,
  26713. 0xe7,
  26714. 0xc8,
  26715. 0x37,
  26716. 0x6d,
  26717. 0x8d,
  26718. 0xd5,
  26719. 0x4e,
  26720. 0xa9,
  26721. 0x6c,
  26722. 0x56,
  26723. 0xf4,
  26724. 0xea,
  26725. 0x65,
  26726. 0x7a,
  26727. 0xae,
  26728. 0x08,
  26729. 0xba,
  26730. 0x78,
  26731. 0x25,
  26732. 0x2e,
  26733. 0x1c,
  26734. 0xa6,
  26735. 0xb4,
  26736. 0xc6,
  26737. 0xe8,
  26738. 0xdd,
  26739. 0x74,
  26740. 0x1f,
  26741. 0x4b,
  26742. 0xbd,
  26743. 0x8b,
  26744. 0x8a,
  26745. 0x70,
  26746. 0x3e,
  26747. 0xb5,
  26748. 0x66,
  26749. 0x48,
  26750. 0x03,
  26751. 0xf6,
  26752. 0x0e,
  26753. 0x61,
  26754. 0x35,
  26755. 0x57,
  26756. 0xb9,
  26757. 0x86,
  26758. 0xc1,
  26759. 0x1d,
  26760. 0x9e,
  26761. 0xe1,
  26762. 0xf8,
  26763. 0x98,
  26764. 0x11,
  26765. 0x69,
  26766. 0xd9,
  26767. 0x8e,
  26768. 0x94,
  26769. 0x9b,
  26770. 0x1e,
  26771. 0x87,
  26772. 0xe9,
  26773. 0xce,
  26774. 0x55,
  26775. 0x28,
  26776. 0xdf,
  26777. 0x8c,
  26778. 0xa1,
  26779. 0x89,
  26780. 0x0d,
  26781. 0xbf,
  26782. 0xe6,
  26783. 0x42,
  26784. 0x68,
  26785. 0x41,
  26786. 0x99,
  26787. 0x2d,
  26788. 0x0f,
  26789. 0xb0,
  26790. 0x54,
  26791. 0xbb,
  26792. 0x16
  26793. ]);
  26794. var inv_s = new Uint8Array([
  26795. 0x52,
  26796. 0x09,
  26797. 0x6a,
  26798. 0xd5,
  26799. 0x30,
  26800. 0x36,
  26801. 0xa5,
  26802. 0x38,
  26803. 0xbf,
  26804. 0x40,
  26805. 0xa3,
  26806. 0x9e,
  26807. 0x81,
  26808. 0xf3,
  26809. 0xd7,
  26810. 0xfb,
  26811. 0x7c,
  26812. 0xe3,
  26813. 0x39,
  26814. 0x82,
  26815. 0x9b,
  26816. 0x2f,
  26817. 0xff,
  26818. 0x87,
  26819. 0x34,
  26820. 0x8e,
  26821. 0x43,
  26822. 0x44,
  26823. 0xc4,
  26824. 0xde,
  26825. 0xe9,
  26826. 0xcb,
  26827. 0x54,
  26828. 0x7b,
  26829. 0x94,
  26830. 0x32,
  26831. 0xa6,
  26832. 0xc2,
  26833. 0x23,
  26834. 0x3d,
  26835. 0xee,
  26836. 0x4c,
  26837. 0x95,
  26838. 0x0b,
  26839. 0x42,
  26840. 0xfa,
  26841. 0xc3,
  26842. 0x4e,
  26843. 0x08,
  26844. 0x2e,
  26845. 0xa1,
  26846. 0x66,
  26847. 0x28,
  26848. 0xd9,
  26849. 0x24,
  26850. 0xb2,
  26851. 0x76,
  26852. 0x5b,
  26853. 0xa2,
  26854. 0x49,
  26855. 0x6d,
  26856. 0x8b,
  26857. 0xd1,
  26858. 0x25,
  26859. 0x72,
  26860. 0xf8,
  26861. 0xf6,
  26862. 0x64,
  26863. 0x86,
  26864. 0x68,
  26865. 0x98,
  26866. 0x16,
  26867. 0xd4,
  26868. 0xa4,
  26869. 0x5c,
  26870. 0xcc,
  26871. 0x5d,
  26872. 0x65,
  26873. 0xb6,
  26874. 0x92,
  26875. 0x6c,
  26876. 0x70,
  26877. 0x48,
  26878. 0x50,
  26879. 0xfd,
  26880. 0xed,
  26881. 0xb9,
  26882. 0xda,
  26883. 0x5e,
  26884. 0x15,
  26885. 0x46,
  26886. 0x57,
  26887. 0xa7,
  26888. 0x8d,
  26889. 0x9d,
  26890. 0x84,
  26891. 0x90,
  26892. 0xd8,
  26893. 0xab,
  26894. 0x00,
  26895. 0x8c,
  26896. 0xbc,
  26897. 0xd3,
  26898. 0x0a,
  26899. 0xf7,
  26900. 0xe4,
  26901. 0x58,
  26902. 0x05,
  26903. 0xb8,
  26904. 0xb3,
  26905. 0x45,
  26906. 0x06,
  26907. 0xd0,
  26908. 0x2c,
  26909. 0x1e,
  26910. 0x8f,
  26911. 0xca,
  26912. 0x3f,
  26913. 0x0f,
  26914. 0x02,
  26915. 0xc1,
  26916. 0xaf,
  26917. 0xbd,
  26918. 0x03,
  26919. 0x01,
  26920. 0x13,
  26921. 0x8a,
  26922. 0x6b,
  26923. 0x3a,
  26924. 0x91,
  26925. 0x11,
  26926. 0x41,
  26927. 0x4f,
  26928. 0x67,
  26929. 0xdc,
  26930. 0xea,
  26931. 0x97,
  26932. 0xf2,
  26933. 0xcf,
  26934. 0xce,
  26935. 0xf0,
  26936. 0xb4,
  26937. 0xe6,
  26938. 0x73,
  26939. 0x96,
  26940. 0xac,
  26941. 0x74,
  26942. 0x22,
  26943. 0xe7,
  26944. 0xad,
  26945. 0x35,
  26946. 0x85,
  26947. 0xe2,
  26948. 0xf9,
  26949. 0x37,
  26950. 0xe8,
  26951. 0x1c,
  26952. 0x75,
  26953. 0xdf,
  26954. 0x6e,
  26955. 0x47,
  26956. 0xf1,
  26957. 0x1a,
  26958. 0x71,
  26959. 0x1d,
  26960. 0x29,
  26961. 0xc5,
  26962. 0x89,
  26963. 0x6f,
  26964. 0xb7,
  26965. 0x62,
  26966. 0x0e,
  26967. 0xaa,
  26968. 0x18,
  26969. 0xbe,
  26970. 0x1b,
  26971. 0xfc,
  26972. 0x56,
  26973. 0x3e,
  26974. 0x4b,
  26975. 0xc6,
  26976. 0xd2,
  26977. 0x79,
  26978. 0x20,
  26979. 0x9a,
  26980. 0xdb,
  26981. 0xc0,
  26982. 0xfe,
  26983. 0x78,
  26984. 0xcd,
  26985. 0x5a,
  26986. 0xf4,
  26987. 0x1f,
  26988. 0xdd,
  26989. 0xa8,
  26990. 0x33,
  26991. 0x88,
  26992. 0x07,
  26993. 0xc7,
  26994. 0x31,
  26995. 0xb1,
  26996. 0x12,
  26997. 0x10,
  26998. 0x59,
  26999. 0x27,
  27000. 0x80,
  27001. 0xec,
  27002. 0x5f,
  27003. 0x60,
  27004. 0x51,
  27005. 0x7f,
  27006. 0xa9,
  27007. 0x19,
  27008. 0xb5,
  27009. 0x4a,
  27010. 0x0d,
  27011. 0x2d,
  27012. 0xe5,
  27013. 0x7a,
  27014. 0x9f,
  27015. 0x93,
  27016. 0xc9,
  27017. 0x9c,
  27018. 0xef,
  27019. 0xa0,
  27020. 0xe0,
  27021. 0x3b,
  27022. 0x4d,
  27023. 0xae,
  27024. 0x2a,
  27025. 0xf5,
  27026. 0xb0,
  27027. 0xc8,
  27028. 0xeb,
  27029. 0xbb,
  27030. 0x3c,
  27031. 0x83,
  27032. 0x53,
  27033. 0x99,
  27034. 0x61,
  27035. 0x17,
  27036. 0x2b,
  27037. 0x04,
  27038. 0x7e,
  27039. 0xba,
  27040. 0x77,
  27041. 0xd6,
  27042. 0x26,
  27043. 0xe1,
  27044. 0x69,
  27045. 0x14,
  27046. 0x63,
  27047. 0x55,
  27048. 0x21,
  27049. 0x0c,
  27050. 0x7d
  27051. ]);
  27052. var mixCol = new Uint8Array(256);
  27053. for (var i = 0; i < 256; i++) {
  27054. if (i < 128) {
  27055. mixCol[i] = i << 1;
  27056. } else {
  27057. mixCol[i] = i << 1 ^ 0x1b;
  27058. }
  27059. }
  27060. var mix = new Uint32Array([
  27061. 0x00000000,
  27062. 0x0e090d0b,
  27063. 0x1c121a16,
  27064. 0x121b171d,
  27065. 0x3824342c,
  27066. 0x362d3927,
  27067. 0x24362e3a,
  27068. 0x2a3f2331,
  27069. 0x70486858,
  27070. 0x7e416553,
  27071. 0x6c5a724e,
  27072. 0x62537f45,
  27073. 0x486c5c74,
  27074. 0x4665517f,
  27075. 0x547e4662,
  27076. 0x5a774b69,
  27077. 0xe090d0b0,
  27078. 0xee99ddbb,
  27079. 0xfc82caa6,
  27080. 0xf28bc7ad,
  27081. 0xd8b4e49c,
  27082. 0xd6bde997,
  27083. 0xc4a6fe8a,
  27084. 0xcaaff381,
  27085. 0x90d8b8e8,
  27086. 0x9ed1b5e3,
  27087. 0x8ccaa2fe,
  27088. 0x82c3aff5,
  27089. 0xa8fc8cc4,
  27090. 0xa6f581cf,
  27091. 0xb4ee96d2,
  27092. 0xbae79bd9,
  27093. 0xdb3bbb7b,
  27094. 0xd532b670,
  27095. 0xc729a16d,
  27096. 0xc920ac66,
  27097. 0xe31f8f57,
  27098. 0xed16825c,
  27099. 0xff0d9541,
  27100. 0xf104984a,
  27101. 0xab73d323,
  27102. 0xa57ade28,
  27103. 0xb761c935,
  27104. 0xb968c43e,
  27105. 0x9357e70f,
  27106. 0x9d5eea04,
  27107. 0x8f45fd19,
  27108. 0x814cf012,
  27109. 0x3bab6bcb,
  27110. 0x35a266c0,
  27111. 0x27b971dd,
  27112. 0x29b07cd6,
  27113. 0x038f5fe7,
  27114. 0x0d8652ec,
  27115. 0x1f9d45f1,
  27116. 0x119448fa,
  27117. 0x4be30393,
  27118. 0x45ea0e98,
  27119. 0x57f11985,
  27120. 0x59f8148e,
  27121. 0x73c737bf,
  27122. 0x7dce3ab4,
  27123. 0x6fd52da9,
  27124. 0x61dc20a2,
  27125. 0xad766df6,
  27126. 0xa37f60fd,
  27127. 0xb16477e0,
  27128. 0xbf6d7aeb,
  27129. 0x955259da,
  27130. 0x9b5b54d1,
  27131. 0x894043cc,
  27132. 0x87494ec7,
  27133. 0xdd3e05ae,
  27134. 0xd33708a5,
  27135. 0xc12c1fb8,
  27136. 0xcf2512b3,
  27137. 0xe51a3182,
  27138. 0xeb133c89,
  27139. 0xf9082b94,
  27140. 0xf701269f,
  27141. 0x4de6bd46,
  27142. 0x43efb04d,
  27143. 0x51f4a750,
  27144. 0x5ffdaa5b,
  27145. 0x75c2896a,
  27146. 0x7bcb8461,
  27147. 0x69d0937c,
  27148. 0x67d99e77,
  27149. 0x3daed51e,
  27150. 0x33a7d815,
  27151. 0x21bccf08,
  27152. 0x2fb5c203,
  27153. 0x058ae132,
  27154. 0x0b83ec39,
  27155. 0x1998fb24,
  27156. 0x1791f62f,
  27157. 0x764dd68d,
  27158. 0x7844db86,
  27159. 0x6a5fcc9b,
  27160. 0x6456c190,
  27161. 0x4e69e2a1,
  27162. 0x4060efaa,
  27163. 0x527bf8b7,
  27164. 0x5c72f5bc,
  27165. 0x0605bed5,
  27166. 0x080cb3de,
  27167. 0x1a17a4c3,
  27168. 0x141ea9c8,
  27169. 0x3e218af9,
  27170. 0x302887f2,
  27171. 0x223390ef,
  27172. 0x2c3a9de4,
  27173. 0x96dd063d,
  27174. 0x98d40b36,
  27175. 0x8acf1c2b,
  27176. 0x84c61120,
  27177. 0xaef93211,
  27178. 0xa0f03f1a,
  27179. 0xb2eb2807,
  27180. 0xbce2250c,
  27181. 0xe6956e65,
  27182. 0xe89c636e,
  27183. 0xfa877473,
  27184. 0xf48e7978,
  27185. 0xdeb15a49,
  27186. 0xd0b85742,
  27187. 0xc2a3405f,
  27188. 0xccaa4d54,
  27189. 0x41ecdaf7,
  27190. 0x4fe5d7fc,
  27191. 0x5dfec0e1,
  27192. 0x53f7cdea,
  27193. 0x79c8eedb,
  27194. 0x77c1e3d0,
  27195. 0x65daf4cd,
  27196. 0x6bd3f9c6,
  27197. 0x31a4b2af,
  27198. 0x3fadbfa4,
  27199. 0x2db6a8b9,
  27200. 0x23bfa5b2,
  27201. 0x09808683,
  27202. 0x07898b88,
  27203. 0x15929c95,
  27204. 0x1b9b919e,
  27205. 0xa17c0a47,
  27206. 0xaf75074c,
  27207. 0xbd6e1051,
  27208. 0xb3671d5a,
  27209. 0x99583e6b,
  27210. 0x97513360,
  27211. 0x854a247d,
  27212. 0x8b432976,
  27213. 0xd134621f,
  27214. 0xdf3d6f14,
  27215. 0xcd267809,
  27216. 0xc32f7502,
  27217. 0xe9105633,
  27218. 0xe7195b38,
  27219. 0xf5024c25,
  27220. 0xfb0b412e,
  27221. 0x9ad7618c,
  27222. 0x94de6c87,
  27223. 0x86c57b9a,
  27224. 0x88cc7691,
  27225. 0xa2f355a0,
  27226. 0xacfa58ab,
  27227. 0xbee14fb6,
  27228. 0xb0e842bd,
  27229. 0xea9f09d4,
  27230. 0xe49604df,
  27231. 0xf68d13c2,
  27232. 0xf8841ec9,
  27233. 0xd2bb3df8,
  27234. 0xdcb230f3,
  27235. 0xcea927ee,
  27236. 0xc0a02ae5,
  27237. 0x7a47b13c,
  27238. 0x744ebc37,
  27239. 0x6655ab2a,
  27240. 0x685ca621,
  27241. 0x42638510,
  27242. 0x4c6a881b,
  27243. 0x5e719f06,
  27244. 0x5078920d,
  27245. 0x0a0fd964,
  27246. 0x0406d46f,
  27247. 0x161dc372,
  27248. 0x1814ce79,
  27249. 0x322bed48,
  27250. 0x3c22e043,
  27251. 0x2e39f75e,
  27252. 0x2030fa55,
  27253. 0xec9ab701,
  27254. 0xe293ba0a,
  27255. 0xf088ad17,
  27256. 0xfe81a01c,
  27257. 0xd4be832d,
  27258. 0xdab78e26,
  27259. 0xc8ac993b,
  27260. 0xc6a59430,
  27261. 0x9cd2df59,
  27262. 0x92dbd252,
  27263. 0x80c0c54f,
  27264. 0x8ec9c844,
  27265. 0xa4f6eb75,
  27266. 0xaaffe67e,
  27267. 0xb8e4f163,
  27268. 0xb6edfc68,
  27269. 0x0c0a67b1,
  27270. 0x02036aba,
  27271. 0x10187da7,
  27272. 0x1e1170ac,
  27273. 0x342e539d,
  27274. 0x3a275e96,
  27275. 0x283c498b,
  27276. 0x26354480,
  27277. 0x7c420fe9,
  27278. 0x724b02e2,
  27279. 0x605015ff,
  27280. 0x6e5918f4,
  27281. 0x44663bc5,
  27282. 0x4a6f36ce,
  27283. 0x587421d3,
  27284. 0x567d2cd8,
  27285. 0x37a10c7a,
  27286. 0x39a80171,
  27287. 0x2bb3166c,
  27288. 0x25ba1b67,
  27289. 0x0f853856,
  27290. 0x018c355d,
  27291. 0x13972240,
  27292. 0x1d9e2f4b,
  27293. 0x47e96422,
  27294. 0x49e06929,
  27295. 0x5bfb7e34,
  27296. 0x55f2733f,
  27297. 0x7fcd500e,
  27298. 0x71c45d05,
  27299. 0x63df4a18,
  27300. 0x6dd64713,
  27301. 0xd731dcca,
  27302. 0xd938d1c1,
  27303. 0xcb23c6dc,
  27304. 0xc52acbd7,
  27305. 0xef15e8e6,
  27306. 0xe11ce5ed,
  27307. 0xf307f2f0,
  27308. 0xfd0efffb,
  27309. 0xa779b492,
  27310. 0xa970b999,
  27311. 0xbb6bae84,
  27312. 0xb562a38f,
  27313. 0x9f5d80be,
  27314. 0x91548db5,
  27315. 0x834f9aa8,
  27316. 0x8d4697a3
  27317. ]);
  27318. function expandKey128(cipherKey) {
  27319. var b = 176, result = new Uint8Array(b);
  27320. result.set(cipherKey);
  27321. for (var j = 16, i = 1; j < b; ++i) {
  27322. var t1 = result[j - 3], t2 = result[j - 2], t3 = result[j - 1], t4 = result[j - 4];
  27323. t1 = s[t1];
  27324. t2 = s[t2];
  27325. t3 = s[t3];
  27326. t4 = s[t4];
  27327. t1 = t1 ^ rcon[i];
  27328. for (var n = 0; n < 4; ++n) {
  27329. result[j] = t1 ^= result[j - 16];
  27330. j++;
  27331. result[j] = t2 ^= result[j - 16];
  27332. j++;
  27333. result[j] = t3 ^= result[j - 16];
  27334. j++;
  27335. result[j] = t4 ^= result[j - 16];
  27336. j++;
  27337. }
  27338. }
  27339. return result;
  27340. }
  27341. function decrypt128(input, key) {
  27342. var state = new Uint8Array(16);
  27343. state.set(input);
  27344. var i, j, k;
  27345. var t, u, v;
  27346. for (j = 0, k = 160; j < 16; ++j, ++k) {
  27347. state[j] ^= key[k];
  27348. }
  27349. for (i = 9; i >= 1; --i) {
  27350. t = state[13];
  27351. state[13] = state[9];
  27352. state[9] = state[5];
  27353. state[5] = state[1];
  27354. state[1] = t;
  27355. t = state[14];
  27356. u = state[10];
  27357. state[14] = state[6];
  27358. state[10] = state[2];
  27359. state[6] = t;
  27360. state[2] = u;
  27361. t = state[15];
  27362. u = state[11];
  27363. v = state[7];
  27364. state[15] = state[3];
  27365. state[11] = t;
  27366. state[7] = u;
  27367. state[3] = v;
  27368. for (j = 0; j < 16; ++j) {
  27369. state[j] = inv_s[state[j]];
  27370. }
  27371. for (j = 0, k = i * 16; j < 16; ++j, ++k) {
  27372. state[j] ^= key[k];
  27373. }
  27374. for (j = 0; j < 16; j += 4) {
  27375. var s0 = mix[state[j]], s1 = mix[state[j + 1]], s2 = mix[state[j + 2]], s3 = mix[state[j + 3]];
  27376. t = s0 ^ s1 >>> 8 ^ s1 << 24 ^ s2 >>> 16 ^ s2 << 16 ^ s3 >>> 24 ^ s3 << 8;
  27377. state[j] = t >>> 24 & 0xFF;
  27378. state[j + 1] = t >> 16 & 0xFF;
  27379. state[j + 2] = t >> 8 & 0xFF;
  27380. state[j + 3] = t & 0xFF;
  27381. }
  27382. }
  27383. t = state[13];
  27384. state[13] = state[9];
  27385. state[9] = state[5];
  27386. state[5] = state[1];
  27387. state[1] = t;
  27388. t = state[14];
  27389. u = state[10];
  27390. state[14] = state[6];
  27391. state[10] = state[2];
  27392. state[6] = t;
  27393. state[2] = u;
  27394. t = state[15];
  27395. u = state[11];
  27396. v = state[7];
  27397. state[15] = state[3];
  27398. state[11] = t;
  27399. state[7] = u;
  27400. state[3] = v;
  27401. for (j = 0; j < 16; ++j) {
  27402. state[j] = inv_s[state[j]];
  27403. state[j] ^= key[j];
  27404. }
  27405. return state;
  27406. }
  27407. function encrypt128(input, key) {
  27408. var t, u, v, k;
  27409. var state = new Uint8Array(16);
  27410. state.set(input);
  27411. for (j = 0; j < 16; ++j) {
  27412. state[j] ^= key[j];
  27413. }
  27414. for (i = 1; i < 10; i++) {
  27415. for (j = 0; j < 16; ++j) {
  27416. state[j] = s[state[j]];
  27417. }
  27418. v = state[1];
  27419. state[1] = state[5];
  27420. state[5] = state[9];
  27421. state[9] = state[13];
  27422. state[13] = v;
  27423. v = state[2];
  27424. u = state[6];
  27425. state[2] = state[10];
  27426. state[6] = state[14];
  27427. state[10] = v;
  27428. state[14] = u;
  27429. v = state[3];
  27430. u = state[7];
  27431. t = state[11];
  27432. state[3] = state[15];
  27433. state[7] = v;
  27434. state[11] = u;
  27435. state[15] = t;
  27436. for (var j = 0; j < 16; j += 4) {
  27437. var s0 = state[j + 0], s1 = state[j + 1];
  27438. var s2 = state[j + 2], s3 = state[j + 3];
  27439. t = s0 ^ s1 ^ s2 ^ s3;
  27440. state[j + 0] ^= t ^ mixCol[s0 ^ s1];
  27441. state[j + 1] ^= t ^ mixCol[s1 ^ s2];
  27442. state[j + 2] ^= t ^ mixCol[s2 ^ s3];
  27443. state[j + 3] ^= t ^ mixCol[s3 ^ s0];
  27444. }
  27445. for (j = 0, k = i * 16; j < 16; ++j, ++k) {
  27446. state[j] ^= key[k];
  27447. }
  27448. }
  27449. for (j = 0; j < 16; ++j) {
  27450. state[j] = s[state[j]];
  27451. }
  27452. v = state[1];
  27453. state[1] = state[5];
  27454. state[5] = state[9];
  27455. state[9] = state[13];
  27456. state[13] = v;
  27457. v = state[2];
  27458. u = state[6];
  27459. state[2] = state[10];
  27460. state[6] = state[14];
  27461. state[10] = v;
  27462. state[14] = u;
  27463. v = state[3];
  27464. u = state[7];
  27465. t = state[11];
  27466. state[3] = state[15];
  27467. state[7] = v;
  27468. state[11] = u;
  27469. state[15] = t;
  27470. for (j = 0, k = 160; j < 16; ++j, ++k) {
  27471. state[j] ^= key[k];
  27472. }
  27473. return state;
  27474. }
  27475. function AES128Cipher(key) {
  27476. this.key = expandKey128(key);
  27477. this.buffer = new Uint8Array(16);
  27478. this.bufferPosition = 0;
  27479. }
  27480. function decryptBlock2(data, finalize) {
  27481. var i, j, ii, sourceLength = data.length, buffer = this.buffer, bufferLength = this.bufferPosition, result = [], iv = this.iv;
  27482. for (i = 0; i < sourceLength; ++i) {
  27483. buffer[bufferLength] = data[i];
  27484. ++bufferLength;
  27485. if (bufferLength < 16) {
  27486. continue;
  27487. }
  27488. var plain = decrypt128(buffer, this.key);
  27489. for (j = 0; j < 16; ++j) {
  27490. plain[j] ^= iv[j];
  27491. }
  27492. iv = buffer;
  27493. result.push(plain);
  27494. buffer = new Uint8Array(16);
  27495. bufferLength = 0;
  27496. }
  27497. this.buffer = buffer;
  27498. this.bufferLength = bufferLength;
  27499. this.iv = iv;
  27500. if (result.length === 0) {
  27501. return new Uint8Array([]);
  27502. }
  27503. var outputLength = 16 * result.length;
  27504. if (finalize) {
  27505. var lastBlock = result[result.length - 1];
  27506. var psLen = lastBlock[15];
  27507. if (psLen <= 16) {
  27508. for (i = 15, ii = 16 - psLen; i >= ii; --i) {
  27509. if (lastBlock[i] !== psLen) {
  27510. psLen = 0;
  27511. break;
  27512. }
  27513. }
  27514. outputLength -= psLen;
  27515. result[result.length - 1] = lastBlock.subarray(0, 16 - psLen);
  27516. }
  27517. }
  27518. var output = new Uint8Array(outputLength);
  27519. for (i = 0, j = 0, ii = result.length; i < ii; ++i, j += 16) {
  27520. output.set(result[i], j);
  27521. }
  27522. return output;
  27523. }
  27524. AES128Cipher.prototype = {
  27525. decryptBlock: function AES128Cipher_decryptBlock(data, finalize) {
  27526. var i, sourceLength = data.length;
  27527. var buffer = this.buffer, bufferLength = this.bufferPosition;
  27528. for (i = 0; bufferLength < 16 && i < sourceLength; ++i, ++bufferLength) {
  27529. buffer[bufferLength] = data[i];
  27530. }
  27531. if (bufferLength < 16) {
  27532. this.bufferLength = bufferLength;
  27533. return new Uint8Array([]);
  27534. }
  27535. this.iv = buffer;
  27536. this.buffer = new Uint8Array(16);
  27537. this.bufferLength = 0;
  27538. this.decryptBlock = decryptBlock2;
  27539. return this.decryptBlock(data.subarray(16), finalize);
  27540. },
  27541. encrypt: function AES128Cipher_encrypt(data, iv) {
  27542. var i, j, ii, sourceLength = data.length, buffer = this.buffer, bufferLength = this.bufferPosition, result = [];
  27543. if (!iv) {
  27544. iv = new Uint8Array(16);
  27545. }
  27546. for (i = 0; i < sourceLength; ++i) {
  27547. buffer[bufferLength] = data[i];
  27548. ++bufferLength;
  27549. if (bufferLength < 16) {
  27550. continue;
  27551. }
  27552. for (j = 0; j < 16; ++j) {
  27553. buffer[j] ^= iv[j];
  27554. }
  27555. var cipher = encrypt128(buffer, this.key);
  27556. iv = cipher;
  27557. result.push(cipher);
  27558. buffer = new Uint8Array(16);
  27559. bufferLength = 0;
  27560. }
  27561. this.buffer = buffer;
  27562. this.bufferLength = bufferLength;
  27563. this.iv = iv;
  27564. if (result.length === 0) {
  27565. return new Uint8Array([]);
  27566. }
  27567. var outputLength = 16 * result.length;
  27568. var output = new Uint8Array(outputLength);
  27569. for (i = 0, j = 0, ii = result.length; i < ii; ++i, j += 16) {
  27570. output.set(result[i], j);
  27571. }
  27572. return output;
  27573. }
  27574. };
  27575. return AES128Cipher;
  27576. }();
  27577. var AES256Cipher = function AES256CipherClosure() {
  27578. var s = new Uint8Array([
  27579. 0x63,
  27580. 0x7c,
  27581. 0x77,
  27582. 0x7b,
  27583. 0xf2,
  27584. 0x6b,
  27585. 0x6f,
  27586. 0xc5,
  27587. 0x30,
  27588. 0x01,
  27589. 0x67,
  27590. 0x2b,
  27591. 0xfe,
  27592. 0xd7,
  27593. 0xab,
  27594. 0x76,
  27595. 0xca,
  27596. 0x82,
  27597. 0xc9,
  27598. 0x7d,
  27599. 0xfa,
  27600. 0x59,
  27601. 0x47,
  27602. 0xf0,
  27603. 0xad,
  27604. 0xd4,
  27605. 0xa2,
  27606. 0xaf,
  27607. 0x9c,
  27608. 0xa4,
  27609. 0x72,
  27610. 0xc0,
  27611. 0xb7,
  27612. 0xfd,
  27613. 0x93,
  27614. 0x26,
  27615. 0x36,
  27616. 0x3f,
  27617. 0xf7,
  27618. 0xcc,
  27619. 0x34,
  27620. 0xa5,
  27621. 0xe5,
  27622. 0xf1,
  27623. 0x71,
  27624. 0xd8,
  27625. 0x31,
  27626. 0x15,
  27627. 0x04,
  27628. 0xc7,
  27629. 0x23,
  27630. 0xc3,
  27631. 0x18,
  27632. 0x96,
  27633. 0x05,
  27634. 0x9a,
  27635. 0x07,
  27636. 0x12,
  27637. 0x80,
  27638. 0xe2,
  27639. 0xeb,
  27640. 0x27,
  27641. 0xb2,
  27642. 0x75,
  27643. 0x09,
  27644. 0x83,
  27645. 0x2c,
  27646. 0x1a,
  27647. 0x1b,
  27648. 0x6e,
  27649. 0x5a,
  27650. 0xa0,
  27651. 0x52,
  27652. 0x3b,
  27653. 0xd6,
  27654. 0xb3,
  27655. 0x29,
  27656. 0xe3,
  27657. 0x2f,
  27658. 0x84,
  27659. 0x53,
  27660. 0xd1,
  27661. 0x00,
  27662. 0xed,
  27663. 0x20,
  27664. 0xfc,
  27665. 0xb1,
  27666. 0x5b,
  27667. 0x6a,
  27668. 0xcb,
  27669. 0xbe,
  27670. 0x39,
  27671. 0x4a,
  27672. 0x4c,
  27673. 0x58,
  27674. 0xcf,
  27675. 0xd0,
  27676. 0xef,
  27677. 0xaa,
  27678. 0xfb,
  27679. 0x43,
  27680. 0x4d,
  27681. 0x33,
  27682. 0x85,
  27683. 0x45,
  27684. 0xf9,
  27685. 0x02,
  27686. 0x7f,
  27687. 0x50,
  27688. 0x3c,
  27689. 0x9f,
  27690. 0xa8,
  27691. 0x51,
  27692. 0xa3,
  27693. 0x40,
  27694. 0x8f,
  27695. 0x92,
  27696. 0x9d,
  27697. 0x38,
  27698. 0xf5,
  27699. 0xbc,
  27700. 0xb6,
  27701. 0xda,
  27702. 0x21,
  27703. 0x10,
  27704. 0xff,
  27705. 0xf3,
  27706. 0xd2,
  27707. 0xcd,
  27708. 0x0c,
  27709. 0x13,
  27710. 0xec,
  27711. 0x5f,
  27712. 0x97,
  27713. 0x44,
  27714. 0x17,
  27715. 0xc4,
  27716. 0xa7,
  27717. 0x7e,
  27718. 0x3d,
  27719. 0x64,
  27720. 0x5d,
  27721. 0x19,
  27722. 0x73,
  27723. 0x60,
  27724. 0x81,
  27725. 0x4f,
  27726. 0xdc,
  27727. 0x22,
  27728. 0x2a,
  27729. 0x90,
  27730. 0x88,
  27731. 0x46,
  27732. 0xee,
  27733. 0xb8,
  27734. 0x14,
  27735. 0xde,
  27736. 0x5e,
  27737. 0x0b,
  27738. 0xdb,
  27739. 0xe0,
  27740. 0x32,
  27741. 0x3a,
  27742. 0x0a,
  27743. 0x49,
  27744. 0x06,
  27745. 0x24,
  27746. 0x5c,
  27747. 0xc2,
  27748. 0xd3,
  27749. 0xac,
  27750. 0x62,
  27751. 0x91,
  27752. 0x95,
  27753. 0xe4,
  27754. 0x79,
  27755. 0xe7,
  27756. 0xc8,
  27757. 0x37,
  27758. 0x6d,
  27759. 0x8d,
  27760. 0xd5,
  27761. 0x4e,
  27762. 0xa9,
  27763. 0x6c,
  27764. 0x56,
  27765. 0xf4,
  27766. 0xea,
  27767. 0x65,
  27768. 0x7a,
  27769. 0xae,
  27770. 0x08,
  27771. 0xba,
  27772. 0x78,
  27773. 0x25,
  27774. 0x2e,
  27775. 0x1c,
  27776. 0xa6,
  27777. 0xb4,
  27778. 0xc6,
  27779. 0xe8,
  27780. 0xdd,
  27781. 0x74,
  27782. 0x1f,
  27783. 0x4b,
  27784. 0xbd,
  27785. 0x8b,
  27786. 0x8a,
  27787. 0x70,
  27788. 0x3e,
  27789. 0xb5,
  27790. 0x66,
  27791. 0x48,
  27792. 0x03,
  27793. 0xf6,
  27794. 0x0e,
  27795. 0x61,
  27796. 0x35,
  27797. 0x57,
  27798. 0xb9,
  27799. 0x86,
  27800. 0xc1,
  27801. 0x1d,
  27802. 0x9e,
  27803. 0xe1,
  27804. 0xf8,
  27805. 0x98,
  27806. 0x11,
  27807. 0x69,
  27808. 0xd9,
  27809. 0x8e,
  27810. 0x94,
  27811. 0x9b,
  27812. 0x1e,
  27813. 0x87,
  27814. 0xe9,
  27815. 0xce,
  27816. 0x55,
  27817. 0x28,
  27818. 0xdf,
  27819. 0x8c,
  27820. 0xa1,
  27821. 0x89,
  27822. 0x0d,
  27823. 0xbf,
  27824. 0xe6,
  27825. 0x42,
  27826. 0x68,
  27827. 0x41,
  27828. 0x99,
  27829. 0x2d,
  27830. 0x0f,
  27831. 0xb0,
  27832. 0x54,
  27833. 0xbb,
  27834. 0x16
  27835. ]);
  27836. var inv_s = new Uint8Array([
  27837. 0x52,
  27838. 0x09,
  27839. 0x6a,
  27840. 0xd5,
  27841. 0x30,
  27842. 0x36,
  27843. 0xa5,
  27844. 0x38,
  27845. 0xbf,
  27846. 0x40,
  27847. 0xa3,
  27848. 0x9e,
  27849. 0x81,
  27850. 0xf3,
  27851. 0xd7,
  27852. 0xfb,
  27853. 0x7c,
  27854. 0xe3,
  27855. 0x39,
  27856. 0x82,
  27857. 0x9b,
  27858. 0x2f,
  27859. 0xff,
  27860. 0x87,
  27861. 0x34,
  27862. 0x8e,
  27863. 0x43,
  27864. 0x44,
  27865. 0xc4,
  27866. 0xde,
  27867. 0xe9,
  27868. 0xcb,
  27869. 0x54,
  27870. 0x7b,
  27871. 0x94,
  27872. 0x32,
  27873. 0xa6,
  27874. 0xc2,
  27875. 0x23,
  27876. 0x3d,
  27877. 0xee,
  27878. 0x4c,
  27879. 0x95,
  27880. 0x0b,
  27881. 0x42,
  27882. 0xfa,
  27883. 0xc3,
  27884. 0x4e,
  27885. 0x08,
  27886. 0x2e,
  27887. 0xa1,
  27888. 0x66,
  27889. 0x28,
  27890. 0xd9,
  27891. 0x24,
  27892. 0xb2,
  27893. 0x76,
  27894. 0x5b,
  27895. 0xa2,
  27896. 0x49,
  27897. 0x6d,
  27898. 0x8b,
  27899. 0xd1,
  27900. 0x25,
  27901. 0x72,
  27902. 0xf8,
  27903. 0xf6,
  27904. 0x64,
  27905. 0x86,
  27906. 0x68,
  27907. 0x98,
  27908. 0x16,
  27909. 0xd4,
  27910. 0xa4,
  27911. 0x5c,
  27912. 0xcc,
  27913. 0x5d,
  27914. 0x65,
  27915. 0xb6,
  27916. 0x92,
  27917. 0x6c,
  27918. 0x70,
  27919. 0x48,
  27920. 0x50,
  27921. 0xfd,
  27922. 0xed,
  27923. 0xb9,
  27924. 0xda,
  27925. 0x5e,
  27926. 0x15,
  27927. 0x46,
  27928. 0x57,
  27929. 0xa7,
  27930. 0x8d,
  27931. 0x9d,
  27932. 0x84,
  27933. 0x90,
  27934. 0xd8,
  27935. 0xab,
  27936. 0x00,
  27937. 0x8c,
  27938. 0xbc,
  27939. 0xd3,
  27940. 0x0a,
  27941. 0xf7,
  27942. 0xe4,
  27943. 0x58,
  27944. 0x05,
  27945. 0xb8,
  27946. 0xb3,
  27947. 0x45,
  27948. 0x06,
  27949. 0xd0,
  27950. 0x2c,
  27951. 0x1e,
  27952. 0x8f,
  27953. 0xca,
  27954. 0x3f,
  27955. 0x0f,
  27956. 0x02,
  27957. 0xc1,
  27958. 0xaf,
  27959. 0xbd,
  27960. 0x03,
  27961. 0x01,
  27962. 0x13,
  27963. 0x8a,
  27964. 0x6b,
  27965. 0x3a,
  27966. 0x91,
  27967. 0x11,
  27968. 0x41,
  27969. 0x4f,
  27970. 0x67,
  27971. 0xdc,
  27972. 0xea,
  27973. 0x97,
  27974. 0xf2,
  27975. 0xcf,
  27976. 0xce,
  27977. 0xf0,
  27978. 0xb4,
  27979. 0xe6,
  27980. 0x73,
  27981. 0x96,
  27982. 0xac,
  27983. 0x74,
  27984. 0x22,
  27985. 0xe7,
  27986. 0xad,
  27987. 0x35,
  27988. 0x85,
  27989. 0xe2,
  27990. 0xf9,
  27991. 0x37,
  27992. 0xe8,
  27993. 0x1c,
  27994. 0x75,
  27995. 0xdf,
  27996. 0x6e,
  27997. 0x47,
  27998. 0xf1,
  27999. 0x1a,
  28000. 0x71,
  28001. 0x1d,
  28002. 0x29,
  28003. 0xc5,
  28004. 0x89,
  28005. 0x6f,
  28006. 0xb7,
  28007. 0x62,
  28008. 0x0e,
  28009. 0xaa,
  28010. 0x18,
  28011. 0xbe,
  28012. 0x1b,
  28013. 0xfc,
  28014. 0x56,
  28015. 0x3e,
  28016. 0x4b,
  28017. 0xc6,
  28018. 0xd2,
  28019. 0x79,
  28020. 0x20,
  28021. 0x9a,
  28022. 0xdb,
  28023. 0xc0,
  28024. 0xfe,
  28025. 0x78,
  28026. 0xcd,
  28027. 0x5a,
  28028. 0xf4,
  28029. 0x1f,
  28030. 0xdd,
  28031. 0xa8,
  28032. 0x33,
  28033. 0x88,
  28034. 0x07,
  28035. 0xc7,
  28036. 0x31,
  28037. 0xb1,
  28038. 0x12,
  28039. 0x10,
  28040. 0x59,
  28041. 0x27,
  28042. 0x80,
  28043. 0xec,
  28044. 0x5f,
  28045. 0x60,
  28046. 0x51,
  28047. 0x7f,
  28048. 0xa9,
  28049. 0x19,
  28050. 0xb5,
  28051. 0x4a,
  28052. 0x0d,
  28053. 0x2d,
  28054. 0xe5,
  28055. 0x7a,
  28056. 0x9f,
  28057. 0x93,
  28058. 0xc9,
  28059. 0x9c,
  28060. 0xef,
  28061. 0xa0,
  28062. 0xe0,
  28063. 0x3b,
  28064. 0x4d,
  28065. 0xae,
  28066. 0x2a,
  28067. 0xf5,
  28068. 0xb0,
  28069. 0xc8,
  28070. 0xeb,
  28071. 0xbb,
  28072. 0x3c,
  28073. 0x83,
  28074. 0x53,
  28075. 0x99,
  28076. 0x61,
  28077. 0x17,
  28078. 0x2b,
  28079. 0x04,
  28080. 0x7e,
  28081. 0xba,
  28082. 0x77,
  28083. 0xd6,
  28084. 0x26,
  28085. 0xe1,
  28086. 0x69,
  28087. 0x14,
  28088. 0x63,
  28089. 0x55,
  28090. 0x21,
  28091. 0x0c,
  28092. 0x7d
  28093. ]);
  28094. var mixCol = new Uint8Array(256);
  28095. for (var i = 0; i < 256; i++) {
  28096. if (i < 128) {
  28097. mixCol[i] = i << 1;
  28098. } else {
  28099. mixCol[i] = i << 1 ^ 0x1b;
  28100. }
  28101. }
  28102. var mix = new Uint32Array([
  28103. 0x00000000,
  28104. 0x0e090d0b,
  28105. 0x1c121a16,
  28106. 0x121b171d,
  28107. 0x3824342c,
  28108. 0x362d3927,
  28109. 0x24362e3a,
  28110. 0x2a3f2331,
  28111. 0x70486858,
  28112. 0x7e416553,
  28113. 0x6c5a724e,
  28114. 0x62537f45,
  28115. 0x486c5c74,
  28116. 0x4665517f,
  28117. 0x547e4662,
  28118. 0x5a774b69,
  28119. 0xe090d0b0,
  28120. 0xee99ddbb,
  28121. 0xfc82caa6,
  28122. 0xf28bc7ad,
  28123. 0xd8b4e49c,
  28124. 0xd6bde997,
  28125. 0xc4a6fe8a,
  28126. 0xcaaff381,
  28127. 0x90d8b8e8,
  28128. 0x9ed1b5e3,
  28129. 0x8ccaa2fe,
  28130. 0x82c3aff5,
  28131. 0xa8fc8cc4,
  28132. 0xa6f581cf,
  28133. 0xb4ee96d2,
  28134. 0xbae79bd9,
  28135. 0xdb3bbb7b,
  28136. 0xd532b670,
  28137. 0xc729a16d,
  28138. 0xc920ac66,
  28139. 0xe31f8f57,
  28140. 0xed16825c,
  28141. 0xff0d9541,
  28142. 0xf104984a,
  28143. 0xab73d323,
  28144. 0xa57ade28,
  28145. 0xb761c935,
  28146. 0xb968c43e,
  28147. 0x9357e70f,
  28148. 0x9d5eea04,
  28149. 0x8f45fd19,
  28150. 0x814cf012,
  28151. 0x3bab6bcb,
  28152. 0x35a266c0,
  28153. 0x27b971dd,
  28154. 0x29b07cd6,
  28155. 0x038f5fe7,
  28156. 0x0d8652ec,
  28157. 0x1f9d45f1,
  28158. 0x119448fa,
  28159. 0x4be30393,
  28160. 0x45ea0e98,
  28161. 0x57f11985,
  28162. 0x59f8148e,
  28163. 0x73c737bf,
  28164. 0x7dce3ab4,
  28165. 0x6fd52da9,
  28166. 0x61dc20a2,
  28167. 0xad766df6,
  28168. 0xa37f60fd,
  28169. 0xb16477e0,
  28170. 0xbf6d7aeb,
  28171. 0x955259da,
  28172. 0x9b5b54d1,
  28173. 0x894043cc,
  28174. 0x87494ec7,
  28175. 0xdd3e05ae,
  28176. 0xd33708a5,
  28177. 0xc12c1fb8,
  28178. 0xcf2512b3,
  28179. 0xe51a3182,
  28180. 0xeb133c89,
  28181. 0xf9082b94,
  28182. 0xf701269f,
  28183. 0x4de6bd46,
  28184. 0x43efb04d,
  28185. 0x51f4a750,
  28186. 0x5ffdaa5b,
  28187. 0x75c2896a,
  28188. 0x7bcb8461,
  28189. 0x69d0937c,
  28190. 0x67d99e77,
  28191. 0x3daed51e,
  28192. 0x33a7d815,
  28193. 0x21bccf08,
  28194. 0x2fb5c203,
  28195. 0x058ae132,
  28196. 0x0b83ec39,
  28197. 0x1998fb24,
  28198. 0x1791f62f,
  28199. 0x764dd68d,
  28200. 0x7844db86,
  28201. 0x6a5fcc9b,
  28202. 0x6456c190,
  28203. 0x4e69e2a1,
  28204. 0x4060efaa,
  28205. 0x527bf8b7,
  28206. 0x5c72f5bc,
  28207. 0x0605bed5,
  28208. 0x080cb3de,
  28209. 0x1a17a4c3,
  28210. 0x141ea9c8,
  28211. 0x3e218af9,
  28212. 0x302887f2,
  28213. 0x223390ef,
  28214. 0x2c3a9de4,
  28215. 0x96dd063d,
  28216. 0x98d40b36,
  28217. 0x8acf1c2b,
  28218. 0x84c61120,
  28219. 0xaef93211,
  28220. 0xa0f03f1a,
  28221. 0xb2eb2807,
  28222. 0xbce2250c,
  28223. 0xe6956e65,
  28224. 0xe89c636e,
  28225. 0xfa877473,
  28226. 0xf48e7978,
  28227. 0xdeb15a49,
  28228. 0xd0b85742,
  28229. 0xc2a3405f,
  28230. 0xccaa4d54,
  28231. 0x41ecdaf7,
  28232. 0x4fe5d7fc,
  28233. 0x5dfec0e1,
  28234. 0x53f7cdea,
  28235. 0x79c8eedb,
  28236. 0x77c1e3d0,
  28237. 0x65daf4cd,
  28238. 0x6bd3f9c6,
  28239. 0x31a4b2af,
  28240. 0x3fadbfa4,
  28241. 0x2db6a8b9,
  28242. 0x23bfa5b2,
  28243. 0x09808683,
  28244. 0x07898b88,
  28245. 0x15929c95,
  28246. 0x1b9b919e,
  28247. 0xa17c0a47,
  28248. 0xaf75074c,
  28249. 0xbd6e1051,
  28250. 0xb3671d5a,
  28251. 0x99583e6b,
  28252. 0x97513360,
  28253. 0x854a247d,
  28254. 0x8b432976,
  28255. 0xd134621f,
  28256. 0xdf3d6f14,
  28257. 0xcd267809,
  28258. 0xc32f7502,
  28259. 0xe9105633,
  28260. 0xe7195b38,
  28261. 0xf5024c25,
  28262. 0xfb0b412e,
  28263. 0x9ad7618c,
  28264. 0x94de6c87,
  28265. 0x86c57b9a,
  28266. 0x88cc7691,
  28267. 0xa2f355a0,
  28268. 0xacfa58ab,
  28269. 0xbee14fb6,
  28270. 0xb0e842bd,
  28271. 0xea9f09d4,
  28272. 0xe49604df,
  28273. 0xf68d13c2,
  28274. 0xf8841ec9,
  28275. 0xd2bb3df8,
  28276. 0xdcb230f3,
  28277. 0xcea927ee,
  28278. 0xc0a02ae5,
  28279. 0x7a47b13c,
  28280. 0x744ebc37,
  28281. 0x6655ab2a,
  28282. 0x685ca621,
  28283. 0x42638510,
  28284. 0x4c6a881b,
  28285. 0x5e719f06,
  28286. 0x5078920d,
  28287. 0x0a0fd964,
  28288. 0x0406d46f,
  28289. 0x161dc372,
  28290. 0x1814ce79,
  28291. 0x322bed48,
  28292. 0x3c22e043,
  28293. 0x2e39f75e,
  28294. 0x2030fa55,
  28295. 0xec9ab701,
  28296. 0xe293ba0a,
  28297. 0xf088ad17,
  28298. 0xfe81a01c,
  28299. 0xd4be832d,
  28300. 0xdab78e26,
  28301. 0xc8ac993b,
  28302. 0xc6a59430,
  28303. 0x9cd2df59,
  28304. 0x92dbd252,
  28305. 0x80c0c54f,
  28306. 0x8ec9c844,
  28307. 0xa4f6eb75,
  28308. 0xaaffe67e,
  28309. 0xb8e4f163,
  28310. 0xb6edfc68,
  28311. 0x0c0a67b1,
  28312. 0x02036aba,
  28313. 0x10187da7,
  28314. 0x1e1170ac,
  28315. 0x342e539d,
  28316. 0x3a275e96,
  28317. 0x283c498b,
  28318. 0x26354480,
  28319. 0x7c420fe9,
  28320. 0x724b02e2,
  28321. 0x605015ff,
  28322. 0x6e5918f4,
  28323. 0x44663bc5,
  28324. 0x4a6f36ce,
  28325. 0x587421d3,
  28326. 0x567d2cd8,
  28327. 0x37a10c7a,
  28328. 0x39a80171,
  28329. 0x2bb3166c,
  28330. 0x25ba1b67,
  28331. 0x0f853856,
  28332. 0x018c355d,
  28333. 0x13972240,
  28334. 0x1d9e2f4b,
  28335. 0x47e96422,
  28336. 0x49e06929,
  28337. 0x5bfb7e34,
  28338. 0x55f2733f,
  28339. 0x7fcd500e,
  28340. 0x71c45d05,
  28341. 0x63df4a18,
  28342. 0x6dd64713,
  28343. 0xd731dcca,
  28344. 0xd938d1c1,
  28345. 0xcb23c6dc,
  28346. 0xc52acbd7,
  28347. 0xef15e8e6,
  28348. 0xe11ce5ed,
  28349. 0xf307f2f0,
  28350. 0xfd0efffb,
  28351. 0xa779b492,
  28352. 0xa970b999,
  28353. 0xbb6bae84,
  28354. 0xb562a38f,
  28355. 0x9f5d80be,
  28356. 0x91548db5,
  28357. 0x834f9aa8,
  28358. 0x8d4697a3
  28359. ]);
  28360. function expandKey256(cipherKey) {
  28361. var b = 240, result = new Uint8Array(b);
  28362. var r = 1;
  28363. result.set(cipherKey);
  28364. for (var j = 32, i = 1; j < b; ++i) {
  28365. if (j % 32 === 16) {
  28366. t1 = s[t1];
  28367. t2 = s[t2];
  28368. t3 = s[t3];
  28369. t4 = s[t4];
  28370. } else if (j % 32 === 0) {
  28371. var t1 = result[j - 3], t2 = result[j - 2], t3 = result[j - 1], t4 = result[j - 4];
  28372. t1 = s[t1];
  28373. t2 = s[t2];
  28374. t3 = s[t3];
  28375. t4 = s[t4];
  28376. t1 = t1 ^ r;
  28377. if ((r <<= 1) >= 256) {
  28378. r = (r ^ 0x1b) & 0xFF;
  28379. }
  28380. }
  28381. for (var n = 0; n < 4; ++n) {
  28382. result[j] = t1 ^= result[j - 32];
  28383. j++;
  28384. result[j] = t2 ^= result[j - 32];
  28385. j++;
  28386. result[j] = t3 ^= result[j - 32];
  28387. j++;
  28388. result[j] = t4 ^= result[j - 32];
  28389. j++;
  28390. }
  28391. }
  28392. return result;
  28393. }
  28394. function decrypt256(input, key) {
  28395. var state = new Uint8Array(16);
  28396. state.set(input);
  28397. var i, j, k;
  28398. var t, u, v;
  28399. for (j = 0, k = 224; j < 16; ++j, ++k) {
  28400. state[j] ^= key[k];
  28401. }
  28402. for (i = 13; i >= 1; --i) {
  28403. t = state[13];
  28404. state[13] = state[9];
  28405. state[9] = state[5];
  28406. state[5] = state[1];
  28407. state[1] = t;
  28408. t = state[14];
  28409. u = state[10];
  28410. state[14] = state[6];
  28411. state[10] = state[2];
  28412. state[6] = t;
  28413. state[2] = u;
  28414. t = state[15];
  28415. u = state[11];
  28416. v = state[7];
  28417. state[15] = state[3];
  28418. state[11] = t;
  28419. state[7] = u;
  28420. state[3] = v;
  28421. for (j = 0; j < 16; ++j) {
  28422. state[j] = inv_s[state[j]];
  28423. }
  28424. for (j = 0, k = i * 16; j < 16; ++j, ++k) {
  28425. state[j] ^= key[k];
  28426. }
  28427. for (j = 0; j < 16; j += 4) {
  28428. var s0 = mix[state[j]], s1 = mix[state[j + 1]], s2 = mix[state[j + 2]], s3 = mix[state[j + 3]];
  28429. t = s0 ^ s1 >>> 8 ^ s1 << 24 ^ s2 >>> 16 ^ s2 << 16 ^ s3 >>> 24 ^ s3 << 8;
  28430. state[j] = t >>> 24 & 0xFF;
  28431. state[j + 1] = t >> 16 & 0xFF;
  28432. state[j + 2] = t >> 8 & 0xFF;
  28433. state[j + 3] = t & 0xFF;
  28434. }
  28435. }
  28436. t = state[13];
  28437. state[13] = state[9];
  28438. state[9] = state[5];
  28439. state[5] = state[1];
  28440. state[1] = t;
  28441. t = state[14];
  28442. u = state[10];
  28443. state[14] = state[6];
  28444. state[10] = state[2];
  28445. state[6] = t;
  28446. state[2] = u;
  28447. t = state[15];
  28448. u = state[11];
  28449. v = state[7];
  28450. state[15] = state[3];
  28451. state[11] = t;
  28452. state[7] = u;
  28453. state[3] = v;
  28454. for (j = 0; j < 16; ++j) {
  28455. state[j] = inv_s[state[j]];
  28456. state[j] ^= key[j];
  28457. }
  28458. return state;
  28459. }
  28460. function encrypt256(input, key) {
  28461. var t, u, v, k;
  28462. var state = new Uint8Array(16);
  28463. state.set(input);
  28464. for (j = 0; j < 16; ++j) {
  28465. state[j] ^= key[j];
  28466. }
  28467. for (i = 1; i < 14; i++) {
  28468. for (j = 0; j < 16; ++j) {
  28469. state[j] = s[state[j]];
  28470. }
  28471. v = state[1];
  28472. state[1] = state[5];
  28473. state[5] = state[9];
  28474. state[9] = state[13];
  28475. state[13] = v;
  28476. v = state[2];
  28477. u = state[6];
  28478. state[2] = state[10];
  28479. state[6] = state[14];
  28480. state[10] = v;
  28481. state[14] = u;
  28482. v = state[3];
  28483. u = state[7];
  28484. t = state[11];
  28485. state[3] = state[15];
  28486. state[7] = v;
  28487. state[11] = u;
  28488. state[15] = t;
  28489. for (var j = 0; j < 16; j += 4) {
  28490. var s0 = state[j + 0], s1 = state[j + 1];
  28491. var s2 = state[j + 2], s3 = state[j + 3];
  28492. t = s0 ^ s1 ^ s2 ^ s3;
  28493. state[j + 0] ^= t ^ mixCol[s0 ^ s1];
  28494. state[j + 1] ^= t ^ mixCol[s1 ^ s2];
  28495. state[j + 2] ^= t ^ mixCol[s2 ^ s3];
  28496. state[j + 3] ^= t ^ mixCol[s3 ^ s0];
  28497. }
  28498. for (j = 0, k = i * 16; j < 16; ++j, ++k) {
  28499. state[j] ^= key[k];
  28500. }
  28501. }
  28502. for (j = 0; j < 16; ++j) {
  28503. state[j] = s[state[j]];
  28504. }
  28505. v = state[1];
  28506. state[1] = state[5];
  28507. state[5] = state[9];
  28508. state[9] = state[13];
  28509. state[13] = v;
  28510. v = state[2];
  28511. u = state[6];
  28512. state[2] = state[10];
  28513. state[6] = state[14];
  28514. state[10] = v;
  28515. state[14] = u;
  28516. v = state[3];
  28517. u = state[7];
  28518. t = state[11];
  28519. state[3] = state[15];
  28520. state[7] = v;
  28521. state[11] = u;
  28522. state[15] = t;
  28523. for (j = 0, k = 224; j < 16; ++j, ++k) {
  28524. state[j] ^= key[k];
  28525. }
  28526. return state;
  28527. }
  28528. function AES256Cipher(key) {
  28529. this.key = expandKey256(key);
  28530. this.buffer = new Uint8Array(16);
  28531. this.bufferPosition = 0;
  28532. }
  28533. function decryptBlock2(data, finalize) {
  28534. var i, j, ii, sourceLength = data.length, buffer = this.buffer, bufferLength = this.bufferPosition, result = [], iv = this.iv;
  28535. for (i = 0; i < sourceLength; ++i) {
  28536. buffer[bufferLength] = data[i];
  28537. ++bufferLength;
  28538. if (bufferLength < 16) {
  28539. continue;
  28540. }
  28541. var plain = decrypt256(buffer, this.key);
  28542. for (j = 0; j < 16; ++j) {
  28543. plain[j] ^= iv[j];
  28544. }
  28545. iv = buffer;
  28546. result.push(plain);
  28547. buffer = new Uint8Array(16);
  28548. bufferLength = 0;
  28549. }
  28550. this.buffer = buffer;
  28551. this.bufferLength = bufferLength;
  28552. this.iv = iv;
  28553. if (result.length === 0) {
  28554. return new Uint8Array([]);
  28555. }
  28556. var outputLength = 16 * result.length;
  28557. if (finalize) {
  28558. var lastBlock = result[result.length - 1];
  28559. var psLen = lastBlock[15];
  28560. if (psLen <= 16) {
  28561. for (i = 15, ii = 16 - psLen; i >= ii; --i) {
  28562. if (lastBlock[i] !== psLen) {
  28563. psLen = 0;
  28564. break;
  28565. }
  28566. }
  28567. outputLength -= psLen;
  28568. result[result.length - 1] = lastBlock.subarray(0, 16 - psLen);
  28569. }
  28570. }
  28571. var output = new Uint8Array(outputLength);
  28572. for (i = 0, j = 0, ii = result.length; i < ii; ++i, j += 16) {
  28573. output.set(result[i], j);
  28574. }
  28575. return output;
  28576. }
  28577. AES256Cipher.prototype = {
  28578. decryptBlock: function AES256Cipher_decryptBlock(data, finalize, iv) {
  28579. var i, sourceLength = data.length;
  28580. var buffer = this.buffer, bufferLength = this.bufferPosition;
  28581. if (iv) {
  28582. this.iv = iv;
  28583. } else {
  28584. for (i = 0; bufferLength < 16 && i < sourceLength; ++i, ++bufferLength) {
  28585. buffer[bufferLength] = data[i];
  28586. }
  28587. if (bufferLength < 16) {
  28588. this.bufferLength = bufferLength;
  28589. return new Uint8Array([]);
  28590. }
  28591. this.iv = buffer;
  28592. data = data.subarray(16);
  28593. }
  28594. this.buffer = new Uint8Array(16);
  28595. this.bufferLength = 0;
  28596. this.decryptBlock = decryptBlock2;
  28597. return this.decryptBlock(data, finalize);
  28598. },
  28599. encrypt: function AES256Cipher_encrypt(data, iv) {
  28600. var i, j, ii, sourceLength = data.length, buffer = this.buffer, bufferLength = this.bufferPosition, result = [];
  28601. if (!iv) {
  28602. iv = new Uint8Array(16);
  28603. }
  28604. for (i = 0; i < sourceLength; ++i) {
  28605. buffer[bufferLength] = data[i];
  28606. ++bufferLength;
  28607. if (bufferLength < 16) {
  28608. continue;
  28609. }
  28610. for (j = 0; j < 16; ++j) {
  28611. buffer[j] ^= iv[j];
  28612. }
  28613. var cipher = encrypt256(buffer, this.key);
  28614. this.iv = cipher;
  28615. result.push(cipher);
  28616. buffer = new Uint8Array(16);
  28617. bufferLength = 0;
  28618. }
  28619. this.buffer = buffer;
  28620. this.bufferLength = bufferLength;
  28621. this.iv = iv;
  28622. if (result.length === 0) {
  28623. return new Uint8Array([]);
  28624. }
  28625. var outputLength = 16 * result.length;
  28626. var output = new Uint8Array(outputLength);
  28627. for (i = 0, j = 0, ii = result.length; i < ii; ++i, j += 16) {
  28628. output.set(result[i], j);
  28629. }
  28630. return output;
  28631. }
  28632. };
  28633. return AES256Cipher;
  28634. }();
  28635. var PDF17 = function PDF17Closure() {
  28636. function compareByteArrays(array1, array2) {
  28637. if (array1.length !== array2.length) {
  28638. return false;
  28639. }
  28640. for (var i = 0; i < array1.length; i++) {
  28641. if (array1[i] !== array2[i]) {
  28642. return false;
  28643. }
  28644. }
  28645. return true;
  28646. }
  28647. function PDF17() {
  28648. }
  28649. PDF17.prototype = {
  28650. checkOwnerPassword: function PDF17_checkOwnerPassword(password, ownerValidationSalt, userBytes, ownerPassword) {
  28651. var hashData = new Uint8Array(password.length + 56);
  28652. hashData.set(password, 0);
  28653. hashData.set(ownerValidationSalt, password.length);
  28654. hashData.set(userBytes, password.length + ownerValidationSalt.length);
  28655. var result = calculateSHA256(hashData, 0, hashData.length);
  28656. return compareByteArrays(result, ownerPassword);
  28657. },
  28658. checkUserPassword: function PDF17_checkUserPassword(password, userValidationSalt, userPassword) {
  28659. var hashData = new Uint8Array(password.length + 8);
  28660. hashData.set(password, 0);
  28661. hashData.set(userValidationSalt, password.length);
  28662. var result = calculateSHA256(hashData, 0, hashData.length);
  28663. return compareByteArrays(result, userPassword);
  28664. },
  28665. getOwnerKey: function PDF17_getOwnerKey(password, ownerKeySalt, userBytes, ownerEncryption) {
  28666. var hashData = new Uint8Array(password.length + 56);
  28667. hashData.set(password, 0);
  28668. hashData.set(ownerKeySalt, password.length);
  28669. hashData.set(userBytes, password.length + ownerKeySalt.length);
  28670. var key = calculateSHA256(hashData, 0, hashData.length);
  28671. var cipher = new AES256Cipher(key);
  28672. return cipher.decryptBlock(ownerEncryption, false, new Uint8Array(16));
  28673. },
  28674. getUserKey: function PDF17_getUserKey(password, userKeySalt, userEncryption) {
  28675. var hashData = new Uint8Array(password.length + 8);
  28676. hashData.set(password, 0);
  28677. hashData.set(userKeySalt, password.length);
  28678. var key = calculateSHA256(hashData, 0, hashData.length);
  28679. var cipher = new AES256Cipher(key);
  28680. return cipher.decryptBlock(userEncryption, false, new Uint8Array(16));
  28681. }
  28682. };
  28683. return PDF17;
  28684. }();
  28685. var PDF20 = function PDF20Closure() {
  28686. function concatArrays(array1, array2) {
  28687. var t = new Uint8Array(array1.length + array2.length);
  28688. t.set(array1, 0);
  28689. t.set(array2, array1.length);
  28690. return t;
  28691. }
  28692. function calculatePDF20Hash(password, input, userBytes) {
  28693. var k = calculateSHA256(input, 0, input.length).subarray(0, 32);
  28694. var e = [0];
  28695. var i = 0;
  28696. while (i < 64 || e[e.length - 1] > i - 32) {
  28697. var arrayLength = password.length + k.length + userBytes.length;
  28698. var k1 = new Uint8Array(arrayLength * 64);
  28699. var array = concatArrays(password, k);
  28700. array = concatArrays(array, userBytes);
  28701. for (var j = 0, pos = 0; j < 64; j++, pos += arrayLength) {
  28702. k1.set(array, pos);
  28703. }
  28704. var cipher = new AES128Cipher(k.subarray(0, 16));
  28705. e = cipher.encrypt(k1, k.subarray(16, 32));
  28706. var remainder = 0;
  28707. for (var z = 0; z < 16; z++) {
  28708. remainder *= 256 % 3;
  28709. remainder %= 3;
  28710. remainder += (e[z] >>> 0) % 3;
  28711. remainder %= 3;
  28712. }
  28713. if (remainder === 0) {
  28714. k = calculateSHA256(e, 0, e.length);
  28715. } else if (remainder === 1) {
  28716. k = calculateSHA384(e, 0, e.length);
  28717. } else if (remainder === 2) {
  28718. k = calculateSHA512(e, 0, e.length);
  28719. }
  28720. i++;
  28721. }
  28722. return k.subarray(0, 32);
  28723. }
  28724. function PDF20() {
  28725. }
  28726. function compareByteArrays(array1, array2) {
  28727. if (array1.length !== array2.length) {
  28728. return false;
  28729. }
  28730. for (var i = 0; i < array1.length; i++) {
  28731. if (array1[i] !== array2[i]) {
  28732. return false;
  28733. }
  28734. }
  28735. return true;
  28736. }
  28737. PDF20.prototype = {
  28738. hash: function PDF20_hash(password, concatBytes, userBytes) {
  28739. return calculatePDF20Hash(password, concatBytes, userBytes);
  28740. },
  28741. checkOwnerPassword: function PDF20_checkOwnerPassword(password, ownerValidationSalt, userBytes, ownerPassword) {
  28742. var hashData = new Uint8Array(password.length + 56);
  28743. hashData.set(password, 0);
  28744. hashData.set(ownerValidationSalt, password.length);
  28745. hashData.set(userBytes, password.length + ownerValidationSalt.length);
  28746. var result = calculatePDF20Hash(password, hashData, userBytes);
  28747. return compareByteArrays(result, ownerPassword);
  28748. },
  28749. checkUserPassword: function PDF20_checkUserPassword(password, userValidationSalt, userPassword) {
  28750. var hashData = new Uint8Array(password.length + 8);
  28751. hashData.set(password, 0);
  28752. hashData.set(userValidationSalt, password.length);
  28753. var result = calculatePDF20Hash(password, hashData, []);
  28754. return compareByteArrays(result, userPassword);
  28755. },
  28756. getOwnerKey: function PDF20_getOwnerKey(password, ownerKeySalt, userBytes, ownerEncryption) {
  28757. var hashData = new Uint8Array(password.length + 56);
  28758. hashData.set(password, 0);
  28759. hashData.set(ownerKeySalt, password.length);
  28760. hashData.set(userBytes, password.length + ownerKeySalt.length);
  28761. var key = calculatePDF20Hash(password, hashData, userBytes);
  28762. var cipher = new AES256Cipher(key);
  28763. return cipher.decryptBlock(ownerEncryption, false, new Uint8Array(16));
  28764. },
  28765. getUserKey: function PDF20_getUserKey(password, userKeySalt, userEncryption) {
  28766. var hashData = new Uint8Array(password.length + 8);
  28767. hashData.set(password, 0);
  28768. hashData.set(userKeySalt, password.length);
  28769. var key = calculatePDF20Hash(password, hashData, []);
  28770. var cipher = new AES256Cipher(key);
  28771. return cipher.decryptBlock(userEncryption, false, new Uint8Array(16));
  28772. }
  28773. };
  28774. return PDF20;
  28775. }();
  28776. var CipherTransform = function CipherTransformClosure() {
  28777. function CipherTransform(stringCipherConstructor, streamCipherConstructor) {
  28778. this.StringCipherConstructor = stringCipherConstructor;
  28779. this.StreamCipherConstructor = streamCipherConstructor;
  28780. }
  28781. CipherTransform.prototype = {
  28782. createStream: function CipherTransform_createStream(stream, length) {
  28783. var cipher = new this.StreamCipherConstructor();
  28784. return new DecryptStream(stream, length, function cipherTransformDecryptStream(data, finalize) {
  28785. return cipher.decryptBlock(data, finalize);
  28786. });
  28787. },
  28788. decryptString: function CipherTransform_decryptString(s) {
  28789. var cipher = new this.StringCipherConstructor();
  28790. var data = stringToBytes(s);
  28791. data = cipher.decryptBlock(data, true);
  28792. return bytesToString(data);
  28793. }
  28794. };
  28795. return CipherTransform;
  28796. }();
  28797. var CipherTransformFactory = function CipherTransformFactoryClosure() {
  28798. var defaultPasswordBytes = new Uint8Array([
  28799. 0x28,
  28800. 0xBF,
  28801. 0x4E,
  28802. 0x5E,
  28803. 0x4E,
  28804. 0x75,
  28805. 0x8A,
  28806. 0x41,
  28807. 0x64,
  28808. 0x00,
  28809. 0x4E,
  28810. 0x56,
  28811. 0xFF,
  28812. 0xFA,
  28813. 0x01,
  28814. 0x08,
  28815. 0x2E,
  28816. 0x2E,
  28817. 0x00,
  28818. 0xB6,
  28819. 0xD0,
  28820. 0x68,
  28821. 0x3E,
  28822. 0x80,
  28823. 0x2F,
  28824. 0x0C,
  28825. 0xA9,
  28826. 0xFE,
  28827. 0x64,
  28828. 0x53,
  28829. 0x69,
  28830. 0x7A
  28831. ]);
  28832. function createEncryptionKey20(revision, password, ownerPassword, ownerValidationSalt, ownerKeySalt, uBytes, userPassword, userValidationSalt, userKeySalt, ownerEncryption, userEncryption, perms) {
  28833. if (password) {
  28834. var passwordLength = Math.min(127, password.length);
  28835. password = password.subarray(0, passwordLength);
  28836. } else {
  28837. password = [];
  28838. }
  28839. var pdfAlgorithm;
  28840. if (revision === 6) {
  28841. pdfAlgorithm = new PDF20();
  28842. } else {
  28843. pdfAlgorithm = new PDF17();
  28844. }
  28845. if (pdfAlgorithm.checkUserPassword(password, userValidationSalt, userPassword)) {
  28846. return pdfAlgorithm.getUserKey(password, userKeySalt, userEncryption);
  28847. } else if (password.length && pdfAlgorithm.checkOwnerPassword(password, ownerValidationSalt, uBytes, ownerPassword)) {
  28848. return pdfAlgorithm.getOwnerKey(password, ownerKeySalt, uBytes, ownerEncryption);
  28849. }
  28850. return null;
  28851. }
  28852. function prepareKeyData(fileId, password, ownerPassword, userPassword, flags, revision, keyLength, encryptMetadata) {
  28853. var hashDataSize = 40 + ownerPassword.length + fileId.length;
  28854. var hashData = new Uint8Array(hashDataSize), i = 0, j, n;
  28855. if (password) {
  28856. n = Math.min(32, password.length);
  28857. for (; i < n; ++i) {
  28858. hashData[i] = password[i];
  28859. }
  28860. }
  28861. j = 0;
  28862. while (i < 32) {
  28863. hashData[i++] = defaultPasswordBytes[j++];
  28864. }
  28865. for (j = 0, n = ownerPassword.length; j < n; ++j) {
  28866. hashData[i++] = ownerPassword[j];
  28867. }
  28868. hashData[i++] = flags & 0xFF;
  28869. hashData[i++] = flags >> 8 & 0xFF;
  28870. hashData[i++] = flags >> 16 & 0xFF;
  28871. hashData[i++] = flags >>> 24 & 0xFF;
  28872. for (j = 0, n = fileId.length; j < n; ++j) {
  28873. hashData[i++] = fileId[j];
  28874. }
  28875. if (revision >= 4 && !encryptMetadata) {
  28876. hashData[i++] = 0xFF;
  28877. hashData[i++] = 0xFF;
  28878. hashData[i++] = 0xFF;
  28879. hashData[i++] = 0xFF;
  28880. }
  28881. var hash = calculateMD5(hashData, 0, i);
  28882. var keyLengthInBytes = keyLength >> 3;
  28883. if (revision >= 3) {
  28884. for (j = 0; j < 50; ++j) {
  28885. hash = calculateMD5(hash, 0, keyLengthInBytes);
  28886. }
  28887. }
  28888. var encryptionKey = hash.subarray(0, keyLengthInBytes);
  28889. var cipher, checkData;
  28890. if (revision >= 3) {
  28891. for (i = 0; i < 32; ++i) {
  28892. hashData[i] = defaultPasswordBytes[i];
  28893. }
  28894. for (j = 0, n = fileId.length; j < n; ++j) {
  28895. hashData[i++] = fileId[j];
  28896. }
  28897. cipher = new ARCFourCipher(encryptionKey);
  28898. checkData = cipher.encryptBlock(calculateMD5(hashData, 0, i));
  28899. n = encryptionKey.length;
  28900. var derivedKey = new Uint8Array(n), k;
  28901. for (j = 1; j <= 19; ++j) {
  28902. for (k = 0; k < n; ++k) {
  28903. derivedKey[k] = encryptionKey[k] ^ j;
  28904. }
  28905. cipher = new ARCFourCipher(derivedKey);
  28906. checkData = cipher.encryptBlock(checkData);
  28907. }
  28908. for (j = 0, n = checkData.length; j < n; ++j) {
  28909. if (userPassword[j] !== checkData[j]) {
  28910. return null;
  28911. }
  28912. }
  28913. } else {
  28914. cipher = new ARCFourCipher(encryptionKey);
  28915. checkData = cipher.encryptBlock(defaultPasswordBytes);
  28916. for (j = 0, n = checkData.length; j < n; ++j) {
  28917. if (userPassword[j] !== checkData[j]) {
  28918. return null;
  28919. }
  28920. }
  28921. }
  28922. return encryptionKey;
  28923. }
  28924. function decodeUserPassword(password, ownerPassword, revision, keyLength) {
  28925. var hashData = new Uint8Array(32), i = 0, j, n;
  28926. n = Math.min(32, password.length);
  28927. for (; i < n; ++i) {
  28928. hashData[i] = password[i];
  28929. }
  28930. j = 0;
  28931. while (i < 32) {
  28932. hashData[i++] = defaultPasswordBytes[j++];
  28933. }
  28934. var hash = calculateMD5(hashData, 0, i);
  28935. var keyLengthInBytes = keyLength >> 3;
  28936. if (revision >= 3) {
  28937. for (j = 0; j < 50; ++j) {
  28938. hash = calculateMD5(hash, 0, hash.length);
  28939. }
  28940. }
  28941. var cipher, userPassword;
  28942. if (revision >= 3) {
  28943. userPassword = ownerPassword;
  28944. var derivedKey = new Uint8Array(keyLengthInBytes), k;
  28945. for (j = 19; j >= 0; j--) {
  28946. for (k = 0; k < keyLengthInBytes; ++k) {
  28947. derivedKey[k] = hash[k] ^ j;
  28948. }
  28949. cipher = new ARCFourCipher(derivedKey);
  28950. userPassword = cipher.encryptBlock(userPassword);
  28951. }
  28952. } else {
  28953. cipher = new ARCFourCipher(hash.subarray(0, keyLengthInBytes));
  28954. userPassword = cipher.encryptBlock(ownerPassword);
  28955. }
  28956. return userPassword;
  28957. }
  28958. var identityName = Name.get('Identity');
  28959. function CipherTransformFactory(dict, fileId, password) {
  28960. var filter = dict.get('Filter');
  28961. if (!isName(filter, 'Standard')) {
  28962. error('unknown encryption method');
  28963. }
  28964. this.dict = dict;
  28965. var algorithm = dict.get('V');
  28966. if (!isInt(algorithm) || algorithm !== 1 && algorithm !== 2 && algorithm !== 4 && algorithm !== 5) {
  28967. error('unsupported encryption algorithm');
  28968. }
  28969. this.algorithm = algorithm;
  28970. var keyLength = dict.get('Length');
  28971. if (!keyLength) {
  28972. if (algorithm <= 3) {
  28973. keyLength = 40;
  28974. } else {
  28975. var cfDict = dict.get('CF');
  28976. var streamCryptoName = dict.get('StmF');
  28977. if (isDict(cfDict) && isName(streamCryptoName)) {
  28978. cfDict.suppressEncryption = true;
  28979. var handlerDict = cfDict.get(streamCryptoName.name);
  28980. keyLength = handlerDict && handlerDict.get('Length') || 128;
  28981. if (keyLength < 40) {
  28982. keyLength <<= 3;
  28983. }
  28984. }
  28985. }
  28986. }
  28987. if (!isInt(keyLength) || keyLength < 40 || keyLength % 8 !== 0) {
  28988. error('invalid key length');
  28989. }
  28990. var ownerPassword = stringToBytes(dict.get('O')).subarray(0, 32);
  28991. var userPassword = stringToBytes(dict.get('U')).subarray(0, 32);
  28992. var flags = dict.get('P');
  28993. var revision = dict.get('R');
  28994. var encryptMetadata = (algorithm === 4 || algorithm === 5) && dict.get('EncryptMetadata') !== false;
  28995. this.encryptMetadata = encryptMetadata;
  28996. var fileIdBytes = stringToBytes(fileId);
  28997. var passwordBytes;
  28998. if (password) {
  28999. if (revision === 6) {
  29000. try {
  29001. password = utf8StringToString(password);
  29002. } catch (ex) {
  29003. warn('CipherTransformFactory: ' + 'Unable to convert UTF8 encoded password.');
  29004. }
  29005. }
  29006. passwordBytes = stringToBytes(password);
  29007. }
  29008. var encryptionKey;
  29009. if (algorithm !== 5) {
  29010. encryptionKey = prepareKeyData(fileIdBytes, passwordBytes, ownerPassword, userPassword, flags, revision, keyLength, encryptMetadata);
  29011. } else {
  29012. var ownerValidationSalt = stringToBytes(dict.get('O')).subarray(32, 40);
  29013. var ownerKeySalt = stringToBytes(dict.get('O')).subarray(40, 48);
  29014. var uBytes = stringToBytes(dict.get('U')).subarray(0, 48);
  29015. var userValidationSalt = stringToBytes(dict.get('U')).subarray(32, 40);
  29016. var userKeySalt = stringToBytes(dict.get('U')).subarray(40, 48);
  29017. var ownerEncryption = stringToBytes(dict.get('OE'));
  29018. var userEncryption = stringToBytes(dict.get('UE'));
  29019. var perms = stringToBytes(dict.get('Perms'));
  29020. encryptionKey = createEncryptionKey20(revision, passwordBytes, ownerPassword, ownerValidationSalt, ownerKeySalt, uBytes, userPassword, userValidationSalt, userKeySalt, ownerEncryption, userEncryption, perms);
  29021. }
  29022. if (!encryptionKey && !password) {
  29023. throw new PasswordException('No password given', PasswordResponses.NEED_PASSWORD);
  29024. } else if (!encryptionKey && password) {
  29025. var decodedPassword = decodeUserPassword(passwordBytes, ownerPassword, revision, keyLength);
  29026. encryptionKey = prepareKeyData(fileIdBytes, decodedPassword, ownerPassword, userPassword, flags, revision, keyLength, encryptMetadata);
  29027. }
  29028. if (!encryptionKey) {
  29029. throw new PasswordException('Incorrect Password', PasswordResponses.INCORRECT_PASSWORD);
  29030. }
  29031. this.encryptionKey = encryptionKey;
  29032. if (algorithm >= 4) {
  29033. var cf = dict.get('CF');
  29034. if (isDict(cf)) {
  29035. cf.suppressEncryption = true;
  29036. }
  29037. this.cf = cf;
  29038. this.stmf = dict.get('StmF') || identityName;
  29039. this.strf = dict.get('StrF') || identityName;
  29040. this.eff = dict.get('EFF') || this.stmf;
  29041. }
  29042. }
  29043. function buildObjectKey(num, gen, encryptionKey, isAes) {
  29044. var key = new Uint8Array(encryptionKey.length + 9), i, n;
  29045. for (i = 0, n = encryptionKey.length; i < n; ++i) {
  29046. key[i] = encryptionKey[i];
  29047. }
  29048. key[i++] = num & 0xFF;
  29049. key[i++] = num >> 8 & 0xFF;
  29050. key[i++] = num >> 16 & 0xFF;
  29051. key[i++] = gen & 0xFF;
  29052. key[i++] = gen >> 8 & 0xFF;
  29053. if (isAes) {
  29054. key[i++] = 0x73;
  29055. key[i++] = 0x41;
  29056. key[i++] = 0x6C;
  29057. key[i++] = 0x54;
  29058. }
  29059. var hash = calculateMD5(key, 0, i);
  29060. return hash.subarray(0, Math.min(encryptionKey.length + 5, 16));
  29061. }
  29062. function buildCipherConstructor(cf, name, num, gen, key) {
  29063. assert(isName(name), 'Invalid crypt filter name.');
  29064. var cryptFilter = cf.get(name.name);
  29065. var cfm;
  29066. if (cryptFilter !== null && cryptFilter !== undefined) {
  29067. cfm = cryptFilter.get('CFM');
  29068. }
  29069. if (!cfm || cfm.name === 'None') {
  29070. return function cipherTransformFactoryBuildCipherConstructorNone() {
  29071. return new NullCipher();
  29072. };
  29073. }
  29074. if (cfm.name === 'V2') {
  29075. return function cipherTransformFactoryBuildCipherConstructorV2() {
  29076. return new ARCFourCipher(buildObjectKey(num, gen, key, false));
  29077. };
  29078. }
  29079. if (cfm.name === 'AESV2') {
  29080. return function cipherTransformFactoryBuildCipherConstructorAESV2() {
  29081. return new AES128Cipher(buildObjectKey(num, gen, key, true));
  29082. };
  29083. }
  29084. if (cfm.name === 'AESV3') {
  29085. return function cipherTransformFactoryBuildCipherConstructorAESV3() {
  29086. return new AES256Cipher(key);
  29087. };
  29088. }
  29089. error('Unknown crypto method');
  29090. }
  29091. CipherTransformFactory.prototype = {
  29092. createCipherTransform: function CipherTransformFactory_createCipherTransform(num, gen) {
  29093. if (this.algorithm === 4 || this.algorithm === 5) {
  29094. return new CipherTransform(buildCipherConstructor(this.cf, this.stmf, num, gen, this.encryptionKey), buildCipherConstructor(this.cf, this.strf, num, gen, this.encryptionKey));
  29095. }
  29096. var key = buildObjectKey(num, gen, this.encryptionKey, false);
  29097. var cipherConstructor = function buildCipherCipherConstructor() {
  29098. return new ARCFourCipher(key);
  29099. };
  29100. return new CipherTransform(cipherConstructor, cipherConstructor);
  29101. }
  29102. };
  29103. return CipherTransformFactory;
  29104. }();
  29105. exports.AES128Cipher = AES128Cipher;
  29106. exports.AES256Cipher = AES256Cipher;
  29107. exports.ARCFourCipher = ARCFourCipher;
  29108. exports.CipherTransformFactory = CipherTransformFactory;
  29109. exports.PDF17 = PDF17;
  29110. exports.PDF20 = PDF20;
  29111. exports.calculateMD5 = calculateMD5;
  29112. exports.calculateSHA256 = calculateSHA256;
  29113. exports.calculateSHA384 = calculateSHA384;
  29114. exports.calculateSHA512 = calculateSHA512;
  29115. /***/ }),
  29116. /* 17 */
  29117. /***/ (function(module, exports, __w_pdfjs_require__) {
  29118. "use strict";
  29119. var sharedUtil = __w_pdfjs_require__(0);
  29120. var corePrimitives = __w_pdfjs_require__(1);
  29121. var coreStream = __w_pdfjs_require__(2);
  29122. var coreParser = __w_pdfjs_require__(6);
  29123. var coreImage = __w_pdfjs_require__(34);
  29124. var coreColorSpace = __w_pdfjs_require__(4);
  29125. var coreMurmurHash3 = __w_pdfjs_require__(38);
  29126. var coreFonts = __w_pdfjs_require__(33);
  29127. var coreFunction = __w_pdfjs_require__(7);
  29128. var corePattern = __w_pdfjs_require__(40);
  29129. var coreCMap = __w_pdfjs_require__(30);
  29130. var coreMetrics = __w_pdfjs_require__(37);
  29131. var coreBidi = __w_pdfjs_require__(28);
  29132. var coreEncodings = __w_pdfjs_require__(5);
  29133. var coreStandardFonts = __w_pdfjs_require__(20);
  29134. var coreUnicode = __w_pdfjs_require__(21);
  29135. var coreGlyphList = __w_pdfjs_require__(8);
  29136. var FONT_IDENTITY_MATRIX = sharedUtil.FONT_IDENTITY_MATRIX;
  29137. var IDENTITY_MATRIX = sharedUtil.IDENTITY_MATRIX;
  29138. var UNSUPPORTED_FEATURES = sharedUtil.UNSUPPORTED_FEATURES;
  29139. var ImageKind = sharedUtil.ImageKind;
  29140. var OPS = sharedUtil.OPS;
  29141. var TextRenderingMode = sharedUtil.TextRenderingMode;
  29142. var Util = sharedUtil.Util;
  29143. var assert = sharedUtil.assert;
  29144. var createPromiseCapability = sharedUtil.createPromiseCapability;
  29145. var error = sharedUtil.error;
  29146. var info = sharedUtil.info;
  29147. var isArray = sharedUtil.isArray;
  29148. var isNum = sharedUtil.isNum;
  29149. var isString = sharedUtil.isString;
  29150. var getLookupTableFactory = sharedUtil.getLookupTableFactory;
  29151. var warn = sharedUtil.warn;
  29152. var Dict = corePrimitives.Dict;
  29153. var Name = corePrimitives.Name;
  29154. var isEOF = corePrimitives.isEOF;
  29155. var isCmd = corePrimitives.isCmd;
  29156. var isDict = corePrimitives.isDict;
  29157. var isName = corePrimitives.isName;
  29158. var isRef = corePrimitives.isRef;
  29159. var isStream = corePrimitives.isStream;
  29160. var DecodeStream = coreStream.DecodeStream;
  29161. var JpegStream = coreStream.JpegStream;
  29162. var Stream = coreStream.Stream;
  29163. var Lexer = coreParser.Lexer;
  29164. var Parser = coreParser.Parser;
  29165. var PDFImage = coreImage.PDFImage;
  29166. var ColorSpace = coreColorSpace.ColorSpace;
  29167. var MurmurHash3_64 = coreMurmurHash3.MurmurHash3_64;
  29168. var ErrorFont = coreFonts.ErrorFont;
  29169. var FontFlags = coreFonts.FontFlags;
  29170. var Font = coreFonts.Font;
  29171. var IdentityToUnicodeMap = coreFonts.IdentityToUnicodeMap;
  29172. var ToUnicodeMap = coreFonts.ToUnicodeMap;
  29173. var getFontType = coreFonts.getFontType;
  29174. var isPDFFunction = coreFunction.isPDFFunction;
  29175. var PDFFunction = coreFunction.PDFFunction;
  29176. var Pattern = corePattern.Pattern;
  29177. var getTilingPatternIR = corePattern.getTilingPatternIR;
  29178. var CMapFactory = coreCMap.CMapFactory;
  29179. var IdentityCMap = coreCMap.IdentityCMap;
  29180. var getMetrics = coreMetrics.getMetrics;
  29181. var bidi = coreBidi.bidi;
  29182. var WinAnsiEncoding = coreEncodings.WinAnsiEncoding;
  29183. var StandardEncoding = coreEncodings.StandardEncoding;
  29184. var MacRomanEncoding = coreEncodings.MacRomanEncoding;
  29185. var SymbolSetEncoding = coreEncodings.SymbolSetEncoding;
  29186. var ZapfDingbatsEncoding = coreEncodings.ZapfDingbatsEncoding;
  29187. var getEncoding = coreEncodings.getEncoding;
  29188. var getStdFontMap = coreStandardFonts.getStdFontMap;
  29189. var getSerifFonts = coreStandardFonts.getSerifFonts;
  29190. var getSymbolsFonts = coreStandardFonts.getSymbolsFonts;
  29191. var getNormalizedUnicodes = coreUnicode.getNormalizedUnicodes;
  29192. var reverseIfRtl = coreUnicode.reverseIfRtl;
  29193. var getUnicodeForGlyph = coreUnicode.getUnicodeForGlyph;
  29194. var getGlyphsUnicode = coreGlyphList.getGlyphsUnicode;
  29195. var PartialEvaluator = function PartialEvaluatorClosure() {
  29196. var DefaultPartialEvaluatorOptions = {
  29197. forceDataSchema: false,
  29198. maxImageSize: -1,
  29199. disableFontFace: false,
  29200. cMapOptions: {
  29201. url: null,
  29202. packed: false
  29203. },
  29204. disableNativeImageDecoder: false
  29205. };
  29206. function NativeImageDecoder(xref, resources, handler, forceDataSchema) {
  29207. this.xref = xref;
  29208. this.resources = resources;
  29209. this.handler = handler;
  29210. this.forceDataSchema = forceDataSchema;
  29211. }
  29212. NativeImageDecoder.prototype = {
  29213. canDecode: function (image) {
  29214. return image instanceof JpegStream && NativeImageDecoder.isDecodable(image, this.xref, this.resources);
  29215. },
  29216. decode: function (image) {
  29217. var dict = image.dict;
  29218. var colorSpace = dict.get('ColorSpace', 'CS');
  29219. colorSpace = ColorSpace.parse(colorSpace, this.xref, this.resources);
  29220. var numComps = colorSpace.numComps;
  29221. var decodePromise = this.handler.sendWithPromise('JpegDecode', [
  29222. image.getIR(this.forceDataSchema),
  29223. numComps
  29224. ]);
  29225. return decodePromise.then(function (message) {
  29226. var data = message.data;
  29227. return new Stream(data, 0, data.length, image.dict);
  29228. });
  29229. }
  29230. };
  29231. NativeImageDecoder.isSupported = function NativeImageDecoder_isSupported(image, xref, res) {
  29232. var dict = image.dict;
  29233. if (dict.has('DecodeParms') || dict.has('DP')) {
  29234. return false;
  29235. }
  29236. var cs = ColorSpace.parse(dict.get('ColorSpace', 'CS'), xref, res);
  29237. return (cs.name === 'DeviceGray' || cs.name === 'DeviceRGB') && cs.isDefaultDecode(dict.getArray('Decode', 'D'));
  29238. };
  29239. NativeImageDecoder.isDecodable = function NativeImageDecoder_isDecodable(image, xref, res) {
  29240. var dict = image.dict;
  29241. if (dict.has('DecodeParms') || dict.has('DP')) {
  29242. return false;
  29243. }
  29244. var cs = ColorSpace.parse(dict.get('ColorSpace', 'CS'), xref, res);
  29245. return (cs.numComps === 1 || cs.numComps === 3) && cs.isDefaultDecode(dict.getArray('Decode', 'D'));
  29246. };
  29247. function PartialEvaluator(pdfManager, xref, handler, pageIndex, idFactory, fontCache, options) {
  29248. this.pdfManager = pdfManager;
  29249. this.xref = xref;
  29250. this.handler = handler;
  29251. this.pageIndex = pageIndex;
  29252. this.idFactory = idFactory;
  29253. this.fontCache = fontCache;
  29254. this.options = options || DefaultPartialEvaluatorOptions;
  29255. }
  29256. var TIME_SLOT_DURATION_MS = 20;
  29257. var CHECK_TIME_EVERY = 100;
  29258. function TimeSlotManager() {
  29259. this.reset();
  29260. }
  29261. TimeSlotManager.prototype = {
  29262. check: function TimeSlotManager_check() {
  29263. if (++this.checked < CHECK_TIME_EVERY) {
  29264. return false;
  29265. }
  29266. this.checked = 0;
  29267. return this.endTime <= Date.now();
  29268. },
  29269. reset: function TimeSlotManager_reset() {
  29270. this.endTime = Date.now() + TIME_SLOT_DURATION_MS;
  29271. this.checked = 0;
  29272. }
  29273. };
  29274. var deferred = Promise.resolve();
  29275. var TILING_PATTERN = 1, SHADING_PATTERN = 2;
  29276. PartialEvaluator.prototype = {
  29277. hasBlendModes: function PartialEvaluator_hasBlendModes(resources) {
  29278. if (!isDict(resources)) {
  29279. return false;
  29280. }
  29281. var processed = Object.create(null);
  29282. if (resources.objId) {
  29283. processed[resources.objId] = true;
  29284. }
  29285. var nodes = [resources], xref = this.xref;
  29286. while (nodes.length) {
  29287. var key, i, ii;
  29288. var node = nodes.shift();
  29289. var graphicStates = node.get('ExtGState');
  29290. if (isDict(graphicStates)) {
  29291. var graphicStatesKeys = graphicStates.getKeys();
  29292. for (i = 0, ii = graphicStatesKeys.length; i < ii; i++) {
  29293. key = graphicStatesKeys[i];
  29294. var graphicState = graphicStates.get(key);
  29295. var bm = graphicState.get('BM');
  29296. if (isName(bm) && bm.name !== 'Normal') {
  29297. return true;
  29298. }
  29299. }
  29300. }
  29301. var xObjects = node.get('XObject');
  29302. if (!isDict(xObjects)) {
  29303. continue;
  29304. }
  29305. var xObjectsKeys = xObjects.getKeys();
  29306. for (i = 0, ii = xObjectsKeys.length; i < ii; i++) {
  29307. key = xObjectsKeys[i];
  29308. var xObject = xObjects.getRaw(key);
  29309. if (isRef(xObject)) {
  29310. if (processed[xObject.toString()]) {
  29311. continue;
  29312. }
  29313. xObject = xref.fetch(xObject);
  29314. }
  29315. if (!isStream(xObject)) {
  29316. continue;
  29317. }
  29318. if (xObject.dict.objId) {
  29319. if (processed[xObject.dict.objId]) {
  29320. continue;
  29321. }
  29322. processed[xObject.dict.objId] = true;
  29323. }
  29324. var xResources = xObject.dict.get('Resources');
  29325. if (isDict(xResources) && (!xResources.objId || !processed[xResources.objId])) {
  29326. nodes.push(xResources);
  29327. if (xResources.objId) {
  29328. processed[xResources.objId] = true;
  29329. }
  29330. }
  29331. }
  29332. }
  29333. return false;
  29334. },
  29335. buildFormXObject: function PartialEvaluator_buildFormXObject(resources, xobj, smask, operatorList, task, initialState) {
  29336. var matrix = xobj.dict.getArray('Matrix');
  29337. var bbox = xobj.dict.getArray('BBox');
  29338. var group = xobj.dict.get('Group');
  29339. if (group) {
  29340. var groupOptions = {
  29341. matrix: matrix,
  29342. bbox: bbox,
  29343. smask: smask,
  29344. isolated: false,
  29345. knockout: false
  29346. };
  29347. var groupSubtype = group.get('S');
  29348. var colorSpace;
  29349. if (isName(groupSubtype, 'Transparency')) {
  29350. groupOptions.isolated = group.get('I') || false;
  29351. groupOptions.knockout = group.get('K') || false;
  29352. colorSpace = group.has('CS') ? ColorSpace.parse(group.get('CS'), this.xref, resources) : null;
  29353. }
  29354. if (smask && smask.backdrop) {
  29355. colorSpace = colorSpace || ColorSpace.singletons.rgb;
  29356. smask.backdrop = colorSpace.getRgb(smask.backdrop, 0);
  29357. }
  29358. operatorList.addOp(OPS.beginGroup, [groupOptions]);
  29359. }
  29360. operatorList.addOp(OPS.paintFormXObjectBegin, [
  29361. matrix,
  29362. bbox
  29363. ]);
  29364. return this.getOperatorList(xobj, task, xobj.dict.get('Resources') || resources, operatorList, initialState).then(function () {
  29365. operatorList.addOp(OPS.paintFormXObjectEnd, []);
  29366. if (group) {
  29367. operatorList.addOp(OPS.endGroup, [groupOptions]);
  29368. }
  29369. });
  29370. },
  29371. buildPaintImageXObject: function PartialEvaluator_buildPaintImageXObject(resources, image, inline, operatorList, cacheKey, imageCache) {
  29372. var self = this;
  29373. var dict = image.dict;
  29374. var w = dict.get('Width', 'W');
  29375. var h = dict.get('Height', 'H');
  29376. if (!(w && isNum(w)) || !(h && isNum(h))) {
  29377. warn('Image dimensions are missing, or not numbers.');
  29378. return;
  29379. }
  29380. var maxImageSize = this.options.maxImageSize;
  29381. if (maxImageSize !== -1 && w * h > maxImageSize) {
  29382. warn('Image exceeded maximum allowed size and was removed.');
  29383. return;
  29384. }
  29385. var imageMask = dict.get('ImageMask', 'IM') || false;
  29386. var imgData, args;
  29387. if (imageMask) {
  29388. var width = dict.get('Width', 'W');
  29389. var height = dict.get('Height', 'H');
  29390. var bitStrideLength = width + 7 >> 3;
  29391. var imgArray = image.getBytes(bitStrideLength * height);
  29392. var decode = dict.getArray('Decode', 'D');
  29393. var inverseDecode = !!decode && decode[0] > 0;
  29394. imgData = PDFImage.createMask(imgArray, width, height, image instanceof DecodeStream, inverseDecode);
  29395. imgData.cached = true;
  29396. args = [imgData];
  29397. operatorList.addOp(OPS.paintImageMaskXObject, args);
  29398. if (cacheKey) {
  29399. imageCache[cacheKey] = {
  29400. fn: OPS.paintImageMaskXObject,
  29401. args: args
  29402. };
  29403. }
  29404. return;
  29405. }
  29406. var softMask = dict.get('SMask', 'SM') || false;
  29407. var mask = dict.get('Mask') || false;
  29408. var SMALL_IMAGE_DIMENSIONS = 200;
  29409. if (inline && !softMask && !mask && !(image instanceof JpegStream) && w + h < SMALL_IMAGE_DIMENSIONS) {
  29410. var imageObj = new PDFImage(this.xref, resources, image, inline, null, null);
  29411. imgData = imageObj.createImageData(true);
  29412. operatorList.addOp(OPS.paintInlineImageXObject, [imgData]);
  29413. return;
  29414. }
  29415. var useNativeImageDecoder = !this.options.disableNativeImageDecoder;
  29416. var objId = 'img_' + this.idFactory.createObjId();
  29417. operatorList.addDependency(objId);
  29418. args = [
  29419. objId,
  29420. w,
  29421. h
  29422. ];
  29423. if (useNativeImageDecoder && !softMask && !mask && image instanceof JpegStream && NativeImageDecoder.isSupported(image, this.xref, resources)) {
  29424. operatorList.addOp(OPS.paintJpegXObject, args);
  29425. this.handler.send('obj', [
  29426. objId,
  29427. this.pageIndex,
  29428. 'JpegStream',
  29429. image.getIR(this.options.forceDataSchema)
  29430. ]);
  29431. return;
  29432. }
  29433. var nativeImageDecoder = null;
  29434. if (useNativeImageDecoder && (image instanceof JpegStream || mask instanceof JpegStream || softMask instanceof JpegStream)) {
  29435. nativeImageDecoder = new NativeImageDecoder(self.xref, resources, self.handler, self.options.forceDataSchema);
  29436. }
  29437. PDFImage.buildImage(self.handler, self.xref, resources, image, inline, nativeImageDecoder).then(function (imageObj) {
  29438. var imgData = imageObj.createImageData(false);
  29439. self.handler.send('obj', [
  29440. objId,
  29441. self.pageIndex,
  29442. 'Image',
  29443. imgData
  29444. ], [imgData.data.buffer]);
  29445. }).then(undefined, function (reason) {
  29446. warn('Unable to decode image: ' + reason);
  29447. self.handler.send('obj', [
  29448. objId,
  29449. self.pageIndex,
  29450. 'Image',
  29451. null
  29452. ]);
  29453. });
  29454. operatorList.addOp(OPS.paintImageXObject, args);
  29455. if (cacheKey) {
  29456. imageCache[cacheKey] = {
  29457. fn: OPS.paintImageXObject,
  29458. args: args
  29459. };
  29460. }
  29461. },
  29462. handleSMask: function PartialEvaluator_handleSmask(smask, resources, operatorList, task, stateManager) {
  29463. var smaskContent = smask.get('G');
  29464. var smaskOptions = {
  29465. subtype: smask.get('S').name,
  29466. backdrop: smask.get('BC')
  29467. };
  29468. var transferObj = smask.get('TR');
  29469. if (isPDFFunction(transferObj)) {
  29470. var transferFn = PDFFunction.parse(this.xref, transferObj);
  29471. var transferMap = new Uint8Array(256);
  29472. var tmp = new Float32Array(1);
  29473. for (var i = 0; i < 256; i++) {
  29474. tmp[0] = i / 255;
  29475. transferFn(tmp, 0, tmp, 0);
  29476. transferMap[i] = tmp[0] * 255 | 0;
  29477. }
  29478. smaskOptions.transferMap = transferMap;
  29479. }
  29480. return this.buildFormXObject(resources, smaskContent, smaskOptions, operatorList, task, stateManager.state.clone());
  29481. },
  29482. handleTilingType: function PartialEvaluator_handleTilingType(fn, args, resources, pattern, patternDict, operatorList, task) {
  29483. var tilingOpList = new OperatorList();
  29484. var resourcesArray = [
  29485. patternDict.get('Resources'),
  29486. resources
  29487. ];
  29488. var patternResources = Dict.merge(this.xref, resourcesArray);
  29489. return this.getOperatorList(pattern, task, patternResources, tilingOpList).then(function () {
  29490. operatorList.addDependencies(tilingOpList.dependencies);
  29491. operatorList.addOp(fn, getTilingPatternIR({
  29492. fnArray: tilingOpList.fnArray,
  29493. argsArray: tilingOpList.argsArray
  29494. }, patternDict, args));
  29495. });
  29496. },
  29497. handleSetFont: function PartialEvaluator_handleSetFont(resources, fontArgs, fontRef, operatorList, task, state) {
  29498. var fontName;
  29499. if (fontArgs) {
  29500. fontArgs = fontArgs.slice();
  29501. fontName = fontArgs[0].name;
  29502. }
  29503. var self = this;
  29504. return this.loadFont(fontName, fontRef, this.xref, resources).then(function (translated) {
  29505. if (!translated.font.isType3Font) {
  29506. return translated;
  29507. }
  29508. return translated.loadType3Data(self, resources, operatorList, task).then(function () {
  29509. return translated;
  29510. }, function (reason) {
  29511. self.handler.send('UnsupportedFeature', { featureId: UNSUPPORTED_FEATURES.font });
  29512. return new TranslatedFont('g_font_error', new ErrorFont('Type3 font load error: ' + reason), translated.font);
  29513. });
  29514. }).then(function (translated) {
  29515. state.font = translated.font;
  29516. translated.send(self.handler);
  29517. return translated.loadedName;
  29518. });
  29519. },
  29520. handleText: function PartialEvaluator_handleText(chars, state) {
  29521. var font = state.font;
  29522. var glyphs = font.charsToGlyphs(chars);
  29523. var isAddToPathSet = !!(state.textRenderingMode & TextRenderingMode.ADD_TO_PATH_FLAG);
  29524. if (font.data && (isAddToPathSet || this.options.disableFontFace)) {
  29525. var buildPath = function (fontChar) {
  29526. if (!font.renderer.hasBuiltPath(fontChar)) {
  29527. var path = font.renderer.getPathJs(fontChar);
  29528. this.handler.send('commonobj', [
  29529. font.loadedName + '_path_' + fontChar,
  29530. 'FontPath',
  29531. path
  29532. ]);
  29533. }
  29534. }.bind(this);
  29535. for (var i = 0, ii = glyphs.length; i < ii; i++) {
  29536. var glyph = glyphs[i];
  29537. buildPath(glyph.fontChar);
  29538. var accent = glyph.accent;
  29539. if (accent && accent.fontChar) {
  29540. buildPath(accent.fontChar);
  29541. }
  29542. }
  29543. }
  29544. return glyphs;
  29545. },
  29546. setGState: function PartialEvaluator_setGState(resources, gState, operatorList, task, xref, stateManager) {
  29547. var gStateObj = [];
  29548. var gStateKeys = gState.getKeys();
  29549. var self = this;
  29550. var promise = Promise.resolve();
  29551. for (var i = 0, ii = gStateKeys.length; i < ii; i++) {
  29552. var key = gStateKeys[i];
  29553. var value = gState.get(key);
  29554. switch (key) {
  29555. case 'Type':
  29556. break;
  29557. case 'LW':
  29558. case 'LC':
  29559. case 'LJ':
  29560. case 'ML':
  29561. case 'D':
  29562. case 'RI':
  29563. case 'FL':
  29564. case 'CA':
  29565. case 'ca':
  29566. gStateObj.push([
  29567. key,
  29568. value
  29569. ]);
  29570. break;
  29571. case 'Font':
  29572. promise = promise.then(function () {
  29573. return self.handleSetFont(resources, null, value[0], operatorList, task, stateManager.state).then(function (loadedName) {
  29574. operatorList.addDependency(loadedName);
  29575. gStateObj.push([
  29576. key,
  29577. [
  29578. loadedName,
  29579. value[1]
  29580. ]
  29581. ]);
  29582. });
  29583. });
  29584. break;
  29585. case 'BM':
  29586. gStateObj.push([
  29587. key,
  29588. value
  29589. ]);
  29590. break;
  29591. case 'SMask':
  29592. if (isName(value, 'None')) {
  29593. gStateObj.push([
  29594. key,
  29595. false
  29596. ]);
  29597. break;
  29598. }
  29599. if (isDict(value)) {
  29600. promise = promise.then(function (dict) {
  29601. return self.handleSMask(dict, resources, operatorList, task, stateManager);
  29602. }.bind(this, value));
  29603. gStateObj.push([
  29604. key,
  29605. true
  29606. ]);
  29607. } else {
  29608. warn('Unsupported SMask type');
  29609. }
  29610. break;
  29611. case 'OP':
  29612. case 'op':
  29613. case 'OPM':
  29614. case 'BG':
  29615. case 'BG2':
  29616. case 'UCR':
  29617. case 'UCR2':
  29618. case 'TR':
  29619. case 'TR2':
  29620. case 'HT':
  29621. case 'SM':
  29622. case 'SA':
  29623. case 'AIS':
  29624. case 'TK':
  29625. info('graphic state operator ' + key);
  29626. break;
  29627. default:
  29628. info('Unknown graphic state operator ' + key);
  29629. break;
  29630. }
  29631. }
  29632. return promise.then(function () {
  29633. if (gStateObj.length > 0) {
  29634. operatorList.addOp(OPS.setGState, [gStateObj]);
  29635. }
  29636. });
  29637. },
  29638. loadFont: function PartialEvaluator_loadFont(fontName, font, xref, resources) {
  29639. function errorFont() {
  29640. return Promise.resolve(new TranslatedFont('g_font_error', new ErrorFont('Font ' + fontName + ' is not available'), font));
  29641. }
  29642. var fontRef;
  29643. if (font) {
  29644. assert(isRef(font));
  29645. fontRef = font;
  29646. } else {
  29647. var fontRes = resources.get('Font');
  29648. if (fontRes) {
  29649. fontRef = fontRes.getRaw(fontName);
  29650. } else {
  29651. warn('fontRes not available');
  29652. return errorFont();
  29653. }
  29654. }
  29655. if (!fontRef) {
  29656. warn('fontRef not available');
  29657. return errorFont();
  29658. }
  29659. if (this.fontCache.has(fontRef)) {
  29660. return this.fontCache.get(fontRef);
  29661. }
  29662. font = xref.fetchIfRef(fontRef);
  29663. if (!isDict(font)) {
  29664. return errorFont();
  29665. }
  29666. if (font.translated) {
  29667. return font.translated;
  29668. }
  29669. var fontCapability = createPromiseCapability();
  29670. var preEvaluatedFont = this.preEvaluateFont(font, xref);
  29671. var descriptor = preEvaluatedFont.descriptor;
  29672. var fontRefIsRef = isRef(fontRef), fontID;
  29673. if (fontRefIsRef) {
  29674. fontID = fontRef.toString();
  29675. }
  29676. if (isDict(descriptor)) {
  29677. if (!descriptor.fontAliases) {
  29678. descriptor.fontAliases = Object.create(null);
  29679. }
  29680. var fontAliases = descriptor.fontAliases;
  29681. var hash = preEvaluatedFont.hash;
  29682. if (fontAliases[hash]) {
  29683. var aliasFontRef = fontAliases[hash].aliasRef;
  29684. if (fontRefIsRef && aliasFontRef && this.fontCache.has(aliasFontRef)) {
  29685. this.fontCache.putAlias(fontRef, aliasFontRef);
  29686. return this.fontCache.get(fontRef);
  29687. }
  29688. } else {
  29689. fontAliases[hash] = { fontID: Font.getFontID() };
  29690. }
  29691. if (fontRefIsRef) {
  29692. fontAliases[hash].aliasRef = fontRef;
  29693. }
  29694. fontID = fontAliases[hash].fontID;
  29695. }
  29696. if (fontRefIsRef) {
  29697. this.fontCache.put(fontRef, fontCapability.promise);
  29698. } else {
  29699. if (!fontID) {
  29700. fontID = this.idFactory.createObjId();
  29701. }
  29702. this.fontCache.put('id_' + fontID, fontCapability.promise);
  29703. }
  29704. assert(fontID, 'The "fontID" must be defined.');
  29705. font.loadedName = 'g_' + this.pdfManager.docId + '_f' + fontID;
  29706. font.translated = fontCapability.promise;
  29707. var translatedPromise;
  29708. try {
  29709. translatedPromise = this.translateFont(preEvaluatedFont, xref);
  29710. } catch (e) {
  29711. translatedPromise = Promise.reject(e);
  29712. }
  29713. var self = this;
  29714. translatedPromise.then(function (translatedFont) {
  29715. if (translatedFont.fontType !== undefined) {
  29716. var xrefFontStats = xref.stats.fontTypes;
  29717. xrefFontStats[translatedFont.fontType] = true;
  29718. }
  29719. fontCapability.resolve(new TranslatedFont(font.loadedName, translatedFont, font));
  29720. }, function (reason) {
  29721. self.handler.send('UnsupportedFeature', { featureId: UNSUPPORTED_FEATURES.font });
  29722. try {
  29723. var descriptor = preEvaluatedFont.descriptor;
  29724. var fontFile3 = descriptor && descriptor.get('FontFile3');
  29725. var subtype = fontFile3 && fontFile3.get('Subtype');
  29726. var fontType = getFontType(preEvaluatedFont.type, subtype && subtype.name);
  29727. var xrefFontStats = xref.stats.fontTypes;
  29728. xrefFontStats[fontType] = true;
  29729. } catch (ex) {
  29730. }
  29731. fontCapability.resolve(new TranslatedFont(font.loadedName, new ErrorFont(reason instanceof Error ? reason.message : reason), font));
  29732. });
  29733. return fontCapability.promise;
  29734. },
  29735. buildPath: function PartialEvaluator_buildPath(operatorList, fn, args) {
  29736. var lastIndex = operatorList.length - 1;
  29737. if (!args) {
  29738. args = [];
  29739. }
  29740. if (lastIndex < 0 || operatorList.fnArray[lastIndex] !== OPS.constructPath) {
  29741. operatorList.addOp(OPS.constructPath, [
  29742. [fn],
  29743. args
  29744. ]);
  29745. } else {
  29746. var opArgs = operatorList.argsArray[lastIndex];
  29747. opArgs[0].push(fn);
  29748. Array.prototype.push.apply(opArgs[1], args);
  29749. }
  29750. },
  29751. handleColorN: function PartialEvaluator_handleColorN(operatorList, fn, args, cs, patterns, resources, task, xref) {
  29752. var patternName = args[args.length - 1];
  29753. var pattern;
  29754. if (isName(patternName) && (pattern = patterns.get(patternName.name))) {
  29755. var dict = isStream(pattern) ? pattern.dict : pattern;
  29756. var typeNum = dict.get('PatternType');
  29757. if (typeNum === TILING_PATTERN) {
  29758. var color = cs.base ? cs.base.getRgb(args, 0) : null;
  29759. return this.handleTilingType(fn, color, resources, pattern, dict, operatorList, task);
  29760. } else if (typeNum === SHADING_PATTERN) {
  29761. var shading = dict.get('Shading');
  29762. var matrix = dict.getArray('Matrix');
  29763. pattern = Pattern.parseShading(shading, matrix, xref, resources, this.handler);
  29764. operatorList.addOp(fn, pattern.getIR());
  29765. return Promise.resolve();
  29766. }
  29767. return Promise.reject('Unknown PatternType: ' + typeNum);
  29768. }
  29769. operatorList.addOp(fn, args);
  29770. return Promise.resolve();
  29771. },
  29772. getOperatorList: function PartialEvaluator_getOperatorList(stream, task, resources, operatorList, initialState) {
  29773. var self = this;
  29774. var xref = this.xref;
  29775. var imageCache = Object.create(null);
  29776. assert(operatorList);
  29777. resources = resources || Dict.empty;
  29778. var xobjs = resources.get('XObject') || Dict.empty;
  29779. var patterns = resources.get('Pattern') || Dict.empty;
  29780. var stateManager = new StateManager(initialState || new EvalState());
  29781. var preprocessor = new EvaluatorPreprocessor(stream, xref, stateManager);
  29782. var timeSlotManager = new TimeSlotManager();
  29783. return new Promise(function promiseBody(resolve, reject) {
  29784. var next = function (promise) {
  29785. promise.then(function () {
  29786. try {
  29787. promiseBody(resolve, reject);
  29788. } catch (ex) {
  29789. reject(ex);
  29790. }
  29791. }, reject);
  29792. };
  29793. task.ensureNotTerminated();
  29794. timeSlotManager.reset();
  29795. var stop, operation = {}, i, ii, cs;
  29796. while (!(stop = timeSlotManager.check())) {
  29797. operation.args = null;
  29798. if (!preprocessor.read(operation)) {
  29799. break;
  29800. }
  29801. var args = operation.args;
  29802. var fn = operation.fn;
  29803. switch (fn | 0) {
  29804. case OPS.paintXObject:
  29805. if (args[0].code) {
  29806. break;
  29807. }
  29808. var name = args[0].name;
  29809. if (!name) {
  29810. warn('XObject must be referred to by name.');
  29811. continue;
  29812. }
  29813. if (imageCache[name] !== undefined) {
  29814. operatorList.addOp(imageCache[name].fn, imageCache[name].args);
  29815. args = null;
  29816. continue;
  29817. }
  29818. var xobj = xobjs.get(name);
  29819. if (xobj) {
  29820. assert(isStream(xobj), 'XObject should be a stream');
  29821. var type = xobj.dict.get('Subtype');
  29822. assert(isName(type), 'XObject should have a Name subtype');
  29823. if (type.name === 'Form') {
  29824. stateManager.save();
  29825. next(self.buildFormXObject(resources, xobj, null, operatorList, task, stateManager.state.clone()).then(function () {
  29826. stateManager.restore();
  29827. }));
  29828. return;
  29829. } else if (type.name === 'Image') {
  29830. self.buildPaintImageXObject(resources, xobj, false, operatorList, name, imageCache);
  29831. args = null;
  29832. continue;
  29833. } else if (type.name === 'PS') {
  29834. info('Ignored XObject subtype PS');
  29835. continue;
  29836. } else {
  29837. error('Unhandled XObject subtype ' + type.name);
  29838. }
  29839. }
  29840. break;
  29841. case OPS.setFont:
  29842. var fontSize = args[1];
  29843. next(self.handleSetFont(resources, args, null, operatorList, task, stateManager.state).then(function (loadedName) {
  29844. operatorList.addDependency(loadedName);
  29845. operatorList.addOp(OPS.setFont, [
  29846. loadedName,
  29847. fontSize
  29848. ]);
  29849. }));
  29850. return;
  29851. case OPS.endInlineImage:
  29852. var cacheKey = args[0].cacheKey;
  29853. if (cacheKey) {
  29854. var cacheEntry = imageCache[cacheKey];
  29855. if (cacheEntry !== undefined) {
  29856. operatorList.addOp(cacheEntry.fn, cacheEntry.args);
  29857. args = null;
  29858. continue;
  29859. }
  29860. }
  29861. self.buildPaintImageXObject(resources, args[0], true, operatorList, cacheKey, imageCache);
  29862. args = null;
  29863. continue;
  29864. case OPS.showText:
  29865. args[0] = self.handleText(args[0], stateManager.state);
  29866. break;
  29867. case OPS.showSpacedText:
  29868. var arr = args[0];
  29869. var combinedGlyphs = [];
  29870. var arrLength = arr.length;
  29871. var state = stateManager.state;
  29872. for (i = 0; i < arrLength; ++i) {
  29873. var arrItem = arr[i];
  29874. if (isString(arrItem)) {
  29875. Array.prototype.push.apply(combinedGlyphs, self.handleText(arrItem, state));
  29876. } else if (isNum(arrItem)) {
  29877. combinedGlyphs.push(arrItem);
  29878. }
  29879. }
  29880. args[0] = combinedGlyphs;
  29881. fn = OPS.showText;
  29882. break;
  29883. case OPS.nextLineShowText:
  29884. operatorList.addOp(OPS.nextLine);
  29885. args[0] = self.handleText(args[0], stateManager.state);
  29886. fn = OPS.showText;
  29887. break;
  29888. case OPS.nextLineSetSpacingShowText:
  29889. operatorList.addOp(OPS.nextLine);
  29890. operatorList.addOp(OPS.setWordSpacing, [args.shift()]);
  29891. operatorList.addOp(OPS.setCharSpacing, [args.shift()]);
  29892. args[0] = self.handleText(args[0], stateManager.state);
  29893. fn = OPS.showText;
  29894. break;
  29895. case OPS.setTextRenderingMode:
  29896. stateManager.state.textRenderingMode = args[0];
  29897. break;
  29898. case OPS.setFillColorSpace:
  29899. stateManager.state.fillColorSpace = ColorSpace.parse(args[0], xref, resources);
  29900. continue;
  29901. case OPS.setStrokeColorSpace:
  29902. stateManager.state.strokeColorSpace = ColorSpace.parse(args[0], xref, resources);
  29903. continue;
  29904. case OPS.setFillColor:
  29905. cs = stateManager.state.fillColorSpace;
  29906. args = cs.getRgb(args, 0);
  29907. fn = OPS.setFillRGBColor;
  29908. break;
  29909. case OPS.setStrokeColor:
  29910. cs = stateManager.state.strokeColorSpace;
  29911. args = cs.getRgb(args, 0);
  29912. fn = OPS.setStrokeRGBColor;
  29913. break;
  29914. case OPS.setFillGray:
  29915. stateManager.state.fillColorSpace = ColorSpace.singletons.gray;
  29916. args = ColorSpace.singletons.gray.getRgb(args, 0);
  29917. fn = OPS.setFillRGBColor;
  29918. break;
  29919. case OPS.setStrokeGray:
  29920. stateManager.state.strokeColorSpace = ColorSpace.singletons.gray;
  29921. args = ColorSpace.singletons.gray.getRgb(args, 0);
  29922. fn = OPS.setStrokeRGBColor;
  29923. break;
  29924. case OPS.setFillCMYKColor:
  29925. stateManager.state.fillColorSpace = ColorSpace.singletons.cmyk;
  29926. args = ColorSpace.singletons.cmyk.getRgb(args, 0);
  29927. fn = OPS.setFillRGBColor;
  29928. break;
  29929. case OPS.setStrokeCMYKColor:
  29930. stateManager.state.strokeColorSpace = ColorSpace.singletons.cmyk;
  29931. args = ColorSpace.singletons.cmyk.getRgb(args, 0);
  29932. fn = OPS.setStrokeRGBColor;
  29933. break;
  29934. case OPS.setFillRGBColor:
  29935. stateManager.state.fillColorSpace = ColorSpace.singletons.rgb;
  29936. args = ColorSpace.singletons.rgb.getRgb(args, 0);
  29937. break;
  29938. case OPS.setStrokeRGBColor:
  29939. stateManager.state.strokeColorSpace = ColorSpace.singletons.rgb;
  29940. args = ColorSpace.singletons.rgb.getRgb(args, 0);
  29941. break;
  29942. case OPS.setFillColorN:
  29943. cs = stateManager.state.fillColorSpace;
  29944. if (cs.name === 'Pattern') {
  29945. next(self.handleColorN(operatorList, OPS.setFillColorN, args, cs, patterns, resources, task, xref));
  29946. return;
  29947. }
  29948. args = cs.getRgb(args, 0);
  29949. fn = OPS.setFillRGBColor;
  29950. break;
  29951. case OPS.setStrokeColorN:
  29952. cs = stateManager.state.strokeColorSpace;
  29953. if (cs.name === 'Pattern') {
  29954. next(self.handleColorN(operatorList, OPS.setStrokeColorN, args, cs, patterns, resources, task, xref));
  29955. return;
  29956. }
  29957. args = cs.getRgb(args, 0);
  29958. fn = OPS.setStrokeRGBColor;
  29959. break;
  29960. case OPS.shadingFill:
  29961. var shadingRes = resources.get('Shading');
  29962. if (!shadingRes) {
  29963. error('No shading resource found');
  29964. }
  29965. var shading = shadingRes.get(args[0].name);
  29966. if (!shading) {
  29967. error('No shading object found');
  29968. }
  29969. var shadingFill = Pattern.parseShading(shading, null, xref, resources, self.handler);
  29970. var patternIR = shadingFill.getIR();
  29971. args = [patternIR];
  29972. fn = OPS.shadingFill;
  29973. break;
  29974. case OPS.setGState:
  29975. var dictName = args[0];
  29976. var extGState = resources.get('ExtGState');
  29977. if (!isDict(extGState) || !extGState.has(dictName.name)) {
  29978. break;
  29979. }
  29980. var gState = extGState.get(dictName.name);
  29981. next(self.setGState(resources, gState, operatorList, task, xref, stateManager));
  29982. return;
  29983. case OPS.moveTo:
  29984. case OPS.lineTo:
  29985. case OPS.curveTo:
  29986. case OPS.curveTo2:
  29987. case OPS.curveTo3:
  29988. case OPS.closePath:
  29989. self.buildPath(operatorList, fn, args);
  29990. continue;
  29991. case OPS.rectangle:
  29992. self.buildPath(operatorList, fn, args);
  29993. continue;
  29994. case OPS.markPoint:
  29995. case OPS.markPointProps:
  29996. case OPS.beginMarkedContent:
  29997. case OPS.beginMarkedContentProps:
  29998. case OPS.endMarkedContent:
  29999. case OPS.beginCompat:
  30000. case OPS.endCompat:
  30001. continue;
  30002. default:
  30003. if (args !== null) {
  30004. for (i = 0, ii = args.length; i < ii; i++) {
  30005. if (args[i] instanceof Dict) {
  30006. break;
  30007. }
  30008. }
  30009. if (i < ii) {
  30010. warn('getOperatorList - ignoring operator: ' + fn);
  30011. continue;
  30012. }
  30013. }
  30014. }
  30015. operatorList.addOp(fn, args);
  30016. }
  30017. if (stop) {
  30018. next(deferred);
  30019. return;
  30020. }
  30021. for (i = 0, ii = preprocessor.savedStatesDepth; i < ii; i++) {
  30022. operatorList.addOp(OPS.restore, []);
  30023. }
  30024. resolve();
  30025. });
  30026. },
  30027. getTextContent: function PartialEvaluator_getTextContent(stream, task, resources, stateManager, normalizeWhitespace, combineTextItems) {
  30028. stateManager = stateManager || new StateManager(new TextState());
  30029. var WhitespaceRegexp = /\s/g;
  30030. var textContent = {
  30031. items: [],
  30032. styles: Object.create(null)
  30033. };
  30034. var textContentItem = {
  30035. initialized: false,
  30036. str: [],
  30037. width: 0,
  30038. height: 0,
  30039. vertical: false,
  30040. lastAdvanceWidth: 0,
  30041. lastAdvanceHeight: 0,
  30042. textAdvanceScale: 0,
  30043. spaceWidth: 0,
  30044. fakeSpaceMin: Infinity,
  30045. fakeMultiSpaceMin: Infinity,
  30046. fakeMultiSpaceMax: -0,
  30047. textRunBreakAllowed: false,
  30048. transform: null,
  30049. fontName: null
  30050. };
  30051. var SPACE_FACTOR = 0.3;
  30052. var MULTI_SPACE_FACTOR = 1.5;
  30053. var MULTI_SPACE_FACTOR_MAX = 4;
  30054. var self = this;
  30055. var xref = this.xref;
  30056. resources = xref.fetchIfRef(resources) || Dict.empty;
  30057. var xobjs = null;
  30058. var xobjsCache = Object.create(null);
  30059. var preprocessor = new EvaluatorPreprocessor(stream, xref, stateManager);
  30060. var textState;
  30061. function ensureTextContentItem() {
  30062. if (textContentItem.initialized) {
  30063. return textContentItem;
  30064. }
  30065. var font = textState.font;
  30066. if (!(font.loadedName in textContent.styles)) {
  30067. textContent.styles[font.loadedName] = {
  30068. fontFamily: font.fallbackName,
  30069. ascent: font.ascent,
  30070. descent: font.descent,
  30071. vertical: font.vertical
  30072. };
  30073. }
  30074. textContentItem.fontName = font.loadedName;
  30075. var tsm = [
  30076. textState.fontSize * textState.textHScale,
  30077. 0,
  30078. 0,
  30079. textState.fontSize,
  30080. 0,
  30081. textState.textRise
  30082. ];
  30083. if (font.isType3Font && textState.fontMatrix !== FONT_IDENTITY_MATRIX && textState.fontSize === 1) {
  30084. var glyphHeight = font.bbox[3] - font.bbox[1];
  30085. if (glyphHeight > 0) {
  30086. glyphHeight = glyphHeight * textState.fontMatrix[3];
  30087. tsm[3] *= glyphHeight;
  30088. }
  30089. }
  30090. var trm = Util.transform(textState.ctm, Util.transform(textState.textMatrix, tsm));
  30091. textContentItem.transform = trm;
  30092. if (!font.vertical) {
  30093. textContentItem.width = 0;
  30094. textContentItem.height = Math.sqrt(trm[2] * trm[2] + trm[3] * trm[3]);
  30095. textContentItem.vertical = false;
  30096. } else {
  30097. textContentItem.width = Math.sqrt(trm[0] * trm[0] + trm[1] * trm[1]);
  30098. textContentItem.height = 0;
  30099. textContentItem.vertical = true;
  30100. }
  30101. var a = textState.textLineMatrix[0];
  30102. var b = textState.textLineMatrix[1];
  30103. var scaleLineX = Math.sqrt(a * a + b * b);
  30104. a = textState.ctm[0];
  30105. b = textState.ctm[1];
  30106. var scaleCtmX = Math.sqrt(a * a + b * b);
  30107. textContentItem.textAdvanceScale = scaleCtmX * scaleLineX;
  30108. textContentItem.lastAdvanceWidth = 0;
  30109. textContentItem.lastAdvanceHeight = 0;
  30110. var spaceWidth = font.spaceWidth / 1000 * textState.fontSize;
  30111. if (spaceWidth) {
  30112. textContentItem.spaceWidth = spaceWidth;
  30113. textContentItem.fakeSpaceMin = spaceWidth * SPACE_FACTOR;
  30114. textContentItem.fakeMultiSpaceMin = spaceWidth * MULTI_SPACE_FACTOR;
  30115. textContentItem.fakeMultiSpaceMax = spaceWidth * MULTI_SPACE_FACTOR_MAX;
  30116. textContentItem.textRunBreakAllowed = !font.isMonospace;
  30117. } else {
  30118. textContentItem.spaceWidth = 0;
  30119. textContentItem.fakeSpaceMin = Infinity;
  30120. textContentItem.fakeMultiSpaceMin = Infinity;
  30121. textContentItem.fakeMultiSpaceMax = 0;
  30122. textContentItem.textRunBreakAllowed = false;
  30123. }
  30124. textContentItem.initialized = true;
  30125. return textContentItem;
  30126. }
  30127. function replaceWhitespace(str) {
  30128. var i = 0, ii = str.length, code;
  30129. while (i < ii && (code = str.charCodeAt(i)) >= 0x20 && code <= 0x7F) {
  30130. i++;
  30131. }
  30132. return i < ii ? str.replace(WhitespaceRegexp, ' ') : str;
  30133. }
  30134. function runBidiTransform(textChunk) {
  30135. var str = textChunk.str.join('');
  30136. var bidiResult = bidi(str, -1, textChunk.vertical);
  30137. return {
  30138. str: normalizeWhitespace ? replaceWhitespace(bidiResult.str) : bidiResult.str,
  30139. dir: bidiResult.dir,
  30140. width: textChunk.width,
  30141. height: textChunk.height,
  30142. transform: textChunk.transform,
  30143. fontName: textChunk.fontName
  30144. };
  30145. }
  30146. function handleSetFont(fontName, fontRef) {
  30147. return self.loadFont(fontName, fontRef, xref, resources).then(function (translated) {
  30148. textState.font = translated.font;
  30149. textState.fontMatrix = translated.font.fontMatrix || FONT_IDENTITY_MATRIX;
  30150. });
  30151. }
  30152. function buildTextContentItem(chars) {
  30153. var font = textState.font;
  30154. var textChunk = ensureTextContentItem();
  30155. var width = 0;
  30156. var height = 0;
  30157. var glyphs = font.charsToGlyphs(chars);
  30158. for (var i = 0; i < glyphs.length; i++) {
  30159. var glyph = glyphs[i];
  30160. var glyphWidth = null;
  30161. if (font.vertical && glyph.vmetric) {
  30162. glyphWidth = glyph.vmetric[0];
  30163. } else {
  30164. glyphWidth = glyph.width;
  30165. }
  30166. var glyphUnicode = glyph.unicode;
  30167. var NormalizedUnicodes = getNormalizedUnicodes();
  30168. if (NormalizedUnicodes[glyphUnicode] !== undefined) {
  30169. glyphUnicode = NormalizedUnicodes[glyphUnicode];
  30170. }
  30171. glyphUnicode = reverseIfRtl(glyphUnicode);
  30172. var charSpacing = textState.charSpacing;
  30173. if (glyph.isSpace) {
  30174. var wordSpacing = textState.wordSpacing;
  30175. charSpacing += wordSpacing;
  30176. if (wordSpacing > 0) {
  30177. addFakeSpaces(wordSpacing, textChunk.str);
  30178. }
  30179. }
  30180. var tx = 0;
  30181. var ty = 0;
  30182. if (!font.vertical) {
  30183. var w0 = glyphWidth * textState.fontMatrix[0];
  30184. tx = (w0 * textState.fontSize + charSpacing) * textState.textHScale;
  30185. width += tx;
  30186. } else {
  30187. var w1 = glyphWidth * textState.fontMatrix[0];
  30188. ty = w1 * textState.fontSize + charSpacing;
  30189. height += ty;
  30190. }
  30191. textState.translateTextMatrix(tx, ty);
  30192. textChunk.str.push(glyphUnicode);
  30193. }
  30194. if (!font.vertical) {
  30195. textChunk.lastAdvanceWidth = width;
  30196. textChunk.width += width;
  30197. } else {
  30198. textChunk.lastAdvanceHeight = height;
  30199. textChunk.height += Math.abs(height);
  30200. }
  30201. return textChunk;
  30202. }
  30203. function addFakeSpaces(width, strBuf) {
  30204. if (width < textContentItem.fakeSpaceMin) {
  30205. return;
  30206. }
  30207. if (width < textContentItem.fakeMultiSpaceMin) {
  30208. strBuf.push(' ');
  30209. return;
  30210. }
  30211. var fakeSpaces = Math.round(width / textContentItem.spaceWidth);
  30212. while (fakeSpaces-- > 0) {
  30213. strBuf.push(' ');
  30214. }
  30215. }
  30216. function flushTextContentItem() {
  30217. if (!textContentItem.initialized) {
  30218. return;
  30219. }
  30220. textContentItem.width *= textContentItem.textAdvanceScale;
  30221. textContentItem.height *= textContentItem.textAdvanceScale;
  30222. textContent.items.push(runBidiTransform(textContentItem));
  30223. textContentItem.initialized = false;
  30224. textContentItem.str.length = 0;
  30225. }
  30226. var timeSlotManager = new TimeSlotManager();
  30227. return new Promise(function promiseBody(resolve, reject) {
  30228. var next = function (promise) {
  30229. promise.then(function () {
  30230. try {
  30231. promiseBody(resolve, reject);
  30232. } catch (ex) {
  30233. reject(ex);
  30234. }
  30235. }, reject);
  30236. };
  30237. task.ensureNotTerminated();
  30238. timeSlotManager.reset();
  30239. var stop, operation = {}, args = [];
  30240. while (!(stop = timeSlotManager.check())) {
  30241. args.length = 0;
  30242. operation.args = args;
  30243. if (!preprocessor.read(operation)) {
  30244. break;
  30245. }
  30246. textState = stateManager.state;
  30247. var fn = operation.fn;
  30248. args = operation.args;
  30249. var advance, diff;
  30250. switch (fn | 0) {
  30251. case OPS.setFont:
  30252. var fontNameArg = args[0].name, fontSizeArg = args[1];
  30253. if (textState.font && fontNameArg === textState.fontName && fontSizeArg === textState.fontSize) {
  30254. break;
  30255. }
  30256. flushTextContentItem();
  30257. textState.fontName = fontNameArg;
  30258. textState.fontSize = fontSizeArg;
  30259. next(handleSetFont(fontNameArg, null));
  30260. return;
  30261. case OPS.setTextRise:
  30262. flushTextContentItem();
  30263. textState.textRise = args[0];
  30264. break;
  30265. case OPS.setHScale:
  30266. flushTextContentItem();
  30267. textState.textHScale = args[0] / 100;
  30268. break;
  30269. case OPS.setLeading:
  30270. flushTextContentItem();
  30271. textState.leading = args[0];
  30272. break;
  30273. case OPS.moveText:
  30274. var isSameTextLine = !textState.font ? false : (textState.font.vertical ? args[0] : args[1]) === 0;
  30275. advance = args[0] - args[1];
  30276. if (combineTextItems && isSameTextLine && textContentItem.initialized && advance > 0 && advance <= textContentItem.fakeMultiSpaceMax) {
  30277. textState.translateTextLineMatrix(args[0], args[1]);
  30278. textContentItem.width += args[0] - textContentItem.lastAdvanceWidth;
  30279. textContentItem.height += args[1] - textContentItem.lastAdvanceHeight;
  30280. diff = args[0] - textContentItem.lastAdvanceWidth - (args[1] - textContentItem.lastAdvanceHeight);
  30281. addFakeSpaces(diff, textContentItem.str);
  30282. break;
  30283. }
  30284. flushTextContentItem();
  30285. textState.translateTextLineMatrix(args[0], args[1]);
  30286. textState.textMatrix = textState.textLineMatrix.slice();
  30287. break;
  30288. case OPS.setLeadingMoveText:
  30289. flushTextContentItem();
  30290. textState.leading = -args[1];
  30291. textState.translateTextLineMatrix(args[0], args[1]);
  30292. textState.textMatrix = textState.textLineMatrix.slice();
  30293. break;
  30294. case OPS.nextLine:
  30295. flushTextContentItem();
  30296. textState.carriageReturn();
  30297. break;
  30298. case OPS.setTextMatrix:
  30299. advance = textState.calcTextLineMatrixAdvance(args[0], args[1], args[2], args[3], args[4], args[5]);
  30300. if (combineTextItems && advance !== null && textContentItem.initialized && advance.value > 0 && advance.value <= textContentItem.fakeMultiSpaceMax) {
  30301. textState.translateTextLineMatrix(advance.width, advance.height);
  30302. textContentItem.width += advance.width - textContentItem.lastAdvanceWidth;
  30303. textContentItem.height += advance.height - textContentItem.lastAdvanceHeight;
  30304. diff = advance.width - textContentItem.lastAdvanceWidth - (advance.height - textContentItem.lastAdvanceHeight);
  30305. addFakeSpaces(diff, textContentItem.str);
  30306. break;
  30307. }
  30308. flushTextContentItem();
  30309. textState.setTextMatrix(args[0], args[1], args[2], args[3], args[4], args[5]);
  30310. textState.setTextLineMatrix(args[0], args[1], args[2], args[3], args[4], args[5]);
  30311. break;
  30312. case OPS.setCharSpacing:
  30313. textState.charSpacing = args[0];
  30314. break;
  30315. case OPS.setWordSpacing:
  30316. textState.wordSpacing = args[0];
  30317. break;
  30318. case OPS.beginText:
  30319. flushTextContentItem();
  30320. textState.textMatrix = IDENTITY_MATRIX.slice();
  30321. textState.textLineMatrix = IDENTITY_MATRIX.slice();
  30322. break;
  30323. case OPS.showSpacedText:
  30324. var items = args[0];
  30325. var offset;
  30326. for (var j = 0, jj = items.length; j < jj; j++) {
  30327. if (typeof items[j] === 'string') {
  30328. buildTextContentItem(items[j]);
  30329. } else if (isNum(items[j])) {
  30330. ensureTextContentItem();
  30331. advance = items[j] * textState.fontSize / 1000;
  30332. var breakTextRun = false;
  30333. if (textState.font.vertical) {
  30334. offset = advance;
  30335. textState.translateTextMatrix(0, offset);
  30336. breakTextRun = textContentItem.textRunBreakAllowed && advance > textContentItem.fakeMultiSpaceMax;
  30337. if (!breakTextRun) {
  30338. textContentItem.height += offset;
  30339. }
  30340. } else {
  30341. advance = -advance;
  30342. offset = advance * textState.textHScale;
  30343. textState.translateTextMatrix(offset, 0);
  30344. breakTextRun = textContentItem.textRunBreakAllowed && advance > textContentItem.fakeMultiSpaceMax;
  30345. if (!breakTextRun) {
  30346. textContentItem.width += offset;
  30347. }
  30348. }
  30349. if (breakTextRun) {
  30350. flushTextContentItem();
  30351. } else if (advance > 0) {
  30352. addFakeSpaces(advance, textContentItem.str);
  30353. }
  30354. }
  30355. }
  30356. break;
  30357. case OPS.showText:
  30358. buildTextContentItem(args[0]);
  30359. break;
  30360. case OPS.nextLineShowText:
  30361. flushTextContentItem();
  30362. textState.carriageReturn();
  30363. buildTextContentItem(args[0]);
  30364. break;
  30365. case OPS.nextLineSetSpacingShowText:
  30366. flushTextContentItem();
  30367. textState.wordSpacing = args[0];
  30368. textState.charSpacing = args[1];
  30369. textState.carriageReturn();
  30370. buildTextContentItem(args[2]);
  30371. break;
  30372. case OPS.paintXObject:
  30373. flushTextContentItem();
  30374. if (args[0].code) {
  30375. break;
  30376. }
  30377. if (!xobjs) {
  30378. xobjs = resources.get('XObject') || Dict.empty;
  30379. }
  30380. var name = args[0].name;
  30381. if (xobjsCache.key === name) {
  30382. if (xobjsCache.texts) {
  30383. Util.appendToArray(textContent.items, xobjsCache.texts.items);
  30384. Util.extendObj(textContent.styles, xobjsCache.texts.styles);
  30385. }
  30386. break;
  30387. }
  30388. var xobj = xobjs.get(name);
  30389. if (!xobj) {
  30390. break;
  30391. }
  30392. assert(isStream(xobj), 'XObject should be a stream');
  30393. var type = xobj.dict.get('Subtype');
  30394. assert(isName(type), 'XObject should have a Name subtype');
  30395. if ('Form' !== type.name) {
  30396. xobjsCache.key = name;
  30397. xobjsCache.texts = null;
  30398. break;
  30399. }
  30400. stateManager.save();
  30401. var matrix = xobj.dict.getArray('Matrix');
  30402. if (isArray(matrix) && matrix.length === 6) {
  30403. stateManager.transform(matrix);
  30404. }
  30405. next(self.getTextContent(xobj, task, xobj.dict.get('Resources') || resources, stateManager, normalizeWhitespace, combineTextItems).then(function (formTextContent) {
  30406. Util.appendToArray(textContent.items, formTextContent.items);
  30407. Util.extendObj(textContent.styles, formTextContent.styles);
  30408. stateManager.restore();
  30409. xobjsCache.key = name;
  30410. xobjsCache.texts = formTextContent;
  30411. }));
  30412. return;
  30413. case OPS.setGState:
  30414. flushTextContentItem();
  30415. var dictName = args[0];
  30416. var extGState = resources.get('ExtGState');
  30417. if (!isDict(extGState) || !isName(dictName)) {
  30418. break;
  30419. }
  30420. var gState = extGState.get(dictName.name);
  30421. if (!isDict(gState)) {
  30422. break;
  30423. }
  30424. var gStateFont = gState.get('Font');
  30425. if (gStateFont) {
  30426. textState.fontName = null;
  30427. textState.fontSize = gStateFont[1];
  30428. next(handleSetFont(null, gStateFont[0]));
  30429. return;
  30430. }
  30431. break;
  30432. }
  30433. }
  30434. if (stop) {
  30435. next(deferred);
  30436. return;
  30437. }
  30438. flushTextContentItem();
  30439. resolve(textContent);
  30440. });
  30441. },
  30442. extractDataStructures: function PartialEvaluator_extractDataStructures(dict, baseDict, xref, properties) {
  30443. var toUnicode = dict.get('ToUnicode') || baseDict.get('ToUnicode');
  30444. var toUnicodePromise = toUnicode ? this.readToUnicode(toUnicode) : Promise.resolve(undefined);
  30445. if (properties.composite) {
  30446. var cidSystemInfo = dict.get('CIDSystemInfo');
  30447. if (isDict(cidSystemInfo)) {
  30448. properties.cidSystemInfo = {
  30449. registry: cidSystemInfo.get('Registry'),
  30450. ordering: cidSystemInfo.get('Ordering'),
  30451. supplement: cidSystemInfo.get('Supplement')
  30452. };
  30453. }
  30454. var cidToGidMap = dict.get('CIDToGIDMap');
  30455. if (isStream(cidToGidMap)) {
  30456. properties.cidToGidMap = this.readCidToGidMap(cidToGidMap);
  30457. }
  30458. }
  30459. var differences = [];
  30460. var baseEncodingName = null;
  30461. var encoding;
  30462. if (dict.has('Encoding')) {
  30463. encoding = dict.get('Encoding');
  30464. if (isDict(encoding)) {
  30465. baseEncodingName = encoding.get('BaseEncoding');
  30466. baseEncodingName = isName(baseEncodingName) ? baseEncodingName.name : null;
  30467. if (encoding.has('Differences')) {
  30468. var diffEncoding = encoding.get('Differences');
  30469. var index = 0;
  30470. for (var j = 0, jj = diffEncoding.length; j < jj; j++) {
  30471. var data = xref.fetchIfRef(diffEncoding[j]);
  30472. if (isNum(data)) {
  30473. index = data;
  30474. } else if (isName(data)) {
  30475. differences[index++] = data.name;
  30476. } else {
  30477. error('Invalid entry in \'Differences\' array: ' + data);
  30478. }
  30479. }
  30480. }
  30481. } else if (isName(encoding)) {
  30482. baseEncodingName = encoding.name;
  30483. } else {
  30484. error('Encoding is not a Name nor a Dict');
  30485. }
  30486. if (baseEncodingName !== 'MacRomanEncoding' && baseEncodingName !== 'MacExpertEncoding' && baseEncodingName !== 'WinAnsiEncoding') {
  30487. baseEncodingName = null;
  30488. }
  30489. }
  30490. if (baseEncodingName) {
  30491. properties.defaultEncoding = getEncoding(baseEncodingName).slice();
  30492. } else {
  30493. var isSymbolicFont = !!(properties.flags & FontFlags.Symbolic);
  30494. var isNonsymbolicFont = !!(properties.flags & FontFlags.Nonsymbolic);
  30495. encoding = StandardEncoding;
  30496. if (properties.type === 'TrueType' && !isNonsymbolicFont) {
  30497. encoding = WinAnsiEncoding;
  30498. }
  30499. if (isSymbolicFont) {
  30500. encoding = MacRomanEncoding;
  30501. if (!properties.file) {
  30502. if (/Symbol/i.test(properties.name)) {
  30503. encoding = SymbolSetEncoding;
  30504. } else if (/Dingbats/i.test(properties.name)) {
  30505. encoding = ZapfDingbatsEncoding;
  30506. }
  30507. }
  30508. }
  30509. properties.defaultEncoding = encoding;
  30510. }
  30511. properties.differences = differences;
  30512. properties.baseEncodingName = baseEncodingName;
  30513. properties.hasEncoding = !!baseEncodingName || differences.length > 0;
  30514. properties.dict = dict;
  30515. return toUnicodePromise.then(function (toUnicode) {
  30516. properties.toUnicode = toUnicode;
  30517. return this.buildToUnicode(properties);
  30518. }.bind(this)).then(function (toUnicode) {
  30519. properties.toUnicode = toUnicode;
  30520. return properties;
  30521. });
  30522. },
  30523. buildToUnicode: function PartialEvaluator_buildToUnicode(properties) {
  30524. properties.hasIncludedToUnicodeMap = !!properties.toUnicode && properties.toUnicode.length > 0;
  30525. if (properties.hasIncludedToUnicodeMap) {
  30526. return Promise.resolve(properties.toUnicode);
  30527. }
  30528. var toUnicode, charcode, glyphName;
  30529. if (!properties.composite) {
  30530. toUnicode = [];
  30531. var encoding = properties.defaultEncoding.slice();
  30532. var baseEncodingName = properties.baseEncodingName;
  30533. var differences = properties.differences;
  30534. for (charcode in differences) {
  30535. glyphName = differences[charcode];
  30536. if (glyphName === '.notdef') {
  30537. continue;
  30538. }
  30539. encoding[charcode] = glyphName;
  30540. }
  30541. var glyphsUnicodeMap = getGlyphsUnicode();
  30542. for (charcode in encoding) {
  30543. glyphName = encoding[charcode];
  30544. if (glyphName === '') {
  30545. continue;
  30546. } else if (glyphsUnicodeMap[glyphName] === undefined) {
  30547. var code = 0;
  30548. switch (glyphName[0]) {
  30549. case 'G':
  30550. if (glyphName.length === 3) {
  30551. code = parseInt(glyphName.substr(1), 16);
  30552. }
  30553. break;
  30554. case 'g':
  30555. if (glyphName.length === 5) {
  30556. code = parseInt(glyphName.substr(1), 16);
  30557. }
  30558. break;
  30559. case 'C':
  30560. case 'c':
  30561. if (glyphName.length >= 3) {
  30562. code = +glyphName.substr(1);
  30563. }
  30564. break;
  30565. default:
  30566. var unicode = getUnicodeForGlyph(glyphName, glyphsUnicodeMap);
  30567. if (unicode !== -1) {
  30568. code = unicode;
  30569. }
  30570. }
  30571. if (code) {
  30572. if (baseEncodingName && code === +charcode) {
  30573. var baseEncoding = getEncoding(baseEncodingName);
  30574. if (baseEncoding && (glyphName = baseEncoding[charcode])) {
  30575. toUnicode[charcode] = String.fromCharCode(glyphsUnicodeMap[glyphName]);
  30576. continue;
  30577. }
  30578. }
  30579. toUnicode[charcode] = String.fromCharCode(code);
  30580. }
  30581. continue;
  30582. }
  30583. toUnicode[charcode] = String.fromCharCode(glyphsUnicodeMap[glyphName]);
  30584. }
  30585. return Promise.resolve(new ToUnicodeMap(toUnicode));
  30586. }
  30587. 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'))) {
  30588. var registry = properties.cidSystemInfo.registry;
  30589. var ordering = properties.cidSystemInfo.ordering;
  30590. var ucs2CMapName = Name.get(registry + '-' + ordering + '-UCS2');
  30591. return CMapFactory.create(ucs2CMapName, this.options.cMapOptions, null).then(function (ucs2CMap) {
  30592. var cMap = properties.cMap;
  30593. toUnicode = [];
  30594. cMap.forEach(function (charcode, cid) {
  30595. assert(cid <= 0xffff, 'Max size of CID is 65,535');
  30596. var ucs2 = ucs2CMap.lookup(cid);
  30597. if (ucs2) {
  30598. toUnicode[charcode] = String.fromCharCode((ucs2.charCodeAt(0) << 8) + ucs2.charCodeAt(1));
  30599. }
  30600. });
  30601. return new ToUnicodeMap(toUnicode);
  30602. });
  30603. }
  30604. return Promise.resolve(new IdentityToUnicodeMap(properties.firstChar, properties.lastChar));
  30605. },
  30606. readToUnicode: function PartialEvaluator_readToUnicode(toUnicode) {
  30607. var cmapObj = toUnicode;
  30608. if (isName(cmapObj)) {
  30609. return CMapFactory.create(cmapObj, this.options.cMapOptions, null).then(function (cmap) {
  30610. if (cmap instanceof IdentityCMap) {
  30611. return new IdentityToUnicodeMap(0, 0xFFFF);
  30612. }
  30613. return new ToUnicodeMap(cmap.getMap());
  30614. });
  30615. } else if (isStream(cmapObj)) {
  30616. return CMapFactory.create(cmapObj, this.options.cMapOptions, null).then(function (cmap) {
  30617. if (cmap instanceof IdentityCMap) {
  30618. return new IdentityToUnicodeMap(0, 0xFFFF);
  30619. }
  30620. var map = new Array(cmap.length);
  30621. cmap.forEach(function (charCode, token) {
  30622. var str = [];
  30623. for (var k = 0; k < token.length; k += 2) {
  30624. var w1 = token.charCodeAt(k) << 8 | token.charCodeAt(k + 1);
  30625. if ((w1 & 0xF800) !== 0xD800) {
  30626. str.push(w1);
  30627. continue;
  30628. }
  30629. k += 2;
  30630. var w2 = token.charCodeAt(k) << 8 | token.charCodeAt(k + 1);
  30631. str.push(((w1 & 0x3ff) << 10) + (w2 & 0x3ff) + 0x10000);
  30632. }
  30633. map[charCode] = String.fromCharCode.apply(String, str);
  30634. });
  30635. return new ToUnicodeMap(map);
  30636. });
  30637. }
  30638. return Promise.resolve(null);
  30639. },
  30640. readCidToGidMap: function PartialEvaluator_readCidToGidMap(cidToGidStream) {
  30641. var glyphsData = cidToGidStream.getBytes();
  30642. var result = [];
  30643. for (var j = 0, jj = glyphsData.length; j < jj; j++) {
  30644. var glyphID = glyphsData[j++] << 8 | glyphsData[j];
  30645. if (glyphID === 0) {
  30646. continue;
  30647. }
  30648. var code = j >> 1;
  30649. result[code] = glyphID;
  30650. }
  30651. return result;
  30652. },
  30653. extractWidths: function PartialEvaluator_extractWidths(dict, xref, descriptor, properties) {
  30654. var glyphsWidths = [];
  30655. var defaultWidth = 0;
  30656. var glyphsVMetrics = [];
  30657. var defaultVMetrics;
  30658. var i, ii, j, jj, start, code, widths;
  30659. if (properties.composite) {
  30660. defaultWidth = dict.get('DW') || 1000;
  30661. widths = dict.get('W');
  30662. if (widths) {
  30663. for (i = 0, ii = widths.length; i < ii; i++) {
  30664. start = xref.fetchIfRef(widths[i++]);
  30665. code = xref.fetchIfRef(widths[i]);
  30666. if (isArray(code)) {
  30667. for (j = 0, jj = code.length; j < jj; j++) {
  30668. glyphsWidths[start++] = xref.fetchIfRef(code[j]);
  30669. }
  30670. } else {
  30671. var width = xref.fetchIfRef(widths[++i]);
  30672. for (j = start; j <= code; j++) {
  30673. glyphsWidths[j] = width;
  30674. }
  30675. }
  30676. }
  30677. }
  30678. if (properties.vertical) {
  30679. var vmetrics = dict.getArray('DW2') || [
  30680. 880,
  30681. -1000
  30682. ];
  30683. defaultVMetrics = [
  30684. vmetrics[1],
  30685. defaultWidth * 0.5,
  30686. vmetrics[0]
  30687. ];
  30688. vmetrics = dict.get('W2');
  30689. if (vmetrics) {
  30690. for (i = 0, ii = vmetrics.length; i < ii; i++) {
  30691. start = xref.fetchIfRef(vmetrics[i++]);
  30692. code = xref.fetchIfRef(vmetrics[i]);
  30693. if (isArray(code)) {
  30694. for (j = 0, jj = code.length; j < jj; j++) {
  30695. glyphsVMetrics[start++] = [
  30696. xref.fetchIfRef(code[j++]),
  30697. xref.fetchIfRef(code[j++]),
  30698. xref.fetchIfRef(code[j])
  30699. ];
  30700. }
  30701. } else {
  30702. var vmetric = [
  30703. xref.fetchIfRef(vmetrics[++i]),
  30704. xref.fetchIfRef(vmetrics[++i]),
  30705. xref.fetchIfRef(vmetrics[++i])
  30706. ];
  30707. for (j = start; j <= code; j++) {
  30708. glyphsVMetrics[j] = vmetric;
  30709. }
  30710. }
  30711. }
  30712. }
  30713. }
  30714. } else {
  30715. var firstChar = properties.firstChar;
  30716. widths = dict.get('Widths');
  30717. if (widths) {
  30718. j = firstChar;
  30719. for (i = 0, ii = widths.length; i < ii; i++) {
  30720. glyphsWidths[j++] = xref.fetchIfRef(widths[i]);
  30721. }
  30722. defaultWidth = parseFloat(descriptor.get('MissingWidth')) || 0;
  30723. } else {
  30724. var baseFontName = dict.get('BaseFont');
  30725. if (isName(baseFontName)) {
  30726. var metrics = this.getBaseFontMetrics(baseFontName.name);
  30727. glyphsWidths = this.buildCharCodeToWidth(metrics.widths, properties);
  30728. defaultWidth = metrics.defaultWidth;
  30729. }
  30730. }
  30731. }
  30732. var isMonospace = true;
  30733. var firstWidth = defaultWidth;
  30734. for (var glyph in glyphsWidths) {
  30735. var glyphWidth = glyphsWidths[glyph];
  30736. if (!glyphWidth) {
  30737. continue;
  30738. }
  30739. if (!firstWidth) {
  30740. firstWidth = glyphWidth;
  30741. continue;
  30742. }
  30743. if (firstWidth !== glyphWidth) {
  30744. isMonospace = false;
  30745. break;
  30746. }
  30747. }
  30748. if (isMonospace) {
  30749. properties.flags |= FontFlags.FixedPitch;
  30750. }
  30751. properties.defaultWidth = defaultWidth;
  30752. properties.widths = glyphsWidths;
  30753. properties.defaultVMetrics = defaultVMetrics;
  30754. properties.vmetrics = glyphsVMetrics;
  30755. },
  30756. isSerifFont: function PartialEvaluator_isSerifFont(baseFontName) {
  30757. var fontNameWoStyle = baseFontName.split('-')[0];
  30758. return fontNameWoStyle in getSerifFonts() || fontNameWoStyle.search(/serif/gi) !== -1;
  30759. },
  30760. getBaseFontMetrics: function PartialEvaluator_getBaseFontMetrics(name) {
  30761. var defaultWidth = 0;
  30762. var widths = [];
  30763. var monospace = false;
  30764. var stdFontMap = getStdFontMap();
  30765. var lookupName = stdFontMap[name] || name;
  30766. var Metrics = getMetrics();
  30767. if (!(lookupName in Metrics)) {
  30768. if (this.isSerifFont(name)) {
  30769. lookupName = 'Times-Roman';
  30770. } else {
  30771. lookupName = 'Helvetica';
  30772. }
  30773. }
  30774. var glyphWidths = Metrics[lookupName];
  30775. if (isNum(glyphWidths)) {
  30776. defaultWidth = glyphWidths;
  30777. monospace = true;
  30778. } else {
  30779. widths = glyphWidths();
  30780. }
  30781. return {
  30782. defaultWidth: defaultWidth,
  30783. monospace: monospace,
  30784. widths: widths
  30785. };
  30786. },
  30787. buildCharCodeToWidth: function PartialEvaluator_bulildCharCodeToWidth(widthsByGlyphName, properties) {
  30788. var widths = Object.create(null);
  30789. var differences = properties.differences;
  30790. var encoding = properties.defaultEncoding;
  30791. for (var charCode = 0; charCode < 256; charCode++) {
  30792. if (charCode in differences && widthsByGlyphName[differences[charCode]]) {
  30793. widths[charCode] = widthsByGlyphName[differences[charCode]];
  30794. continue;
  30795. }
  30796. if (charCode in encoding && widthsByGlyphName[encoding[charCode]]) {
  30797. widths[charCode] = widthsByGlyphName[encoding[charCode]];
  30798. continue;
  30799. }
  30800. }
  30801. return widths;
  30802. },
  30803. preEvaluateFont: function PartialEvaluator_preEvaluateFont(dict, xref) {
  30804. var baseDict = dict;
  30805. var type = dict.get('Subtype');
  30806. assert(isName(type), 'invalid font Subtype');
  30807. var composite = false;
  30808. var uint8array;
  30809. if (type.name === 'Type0') {
  30810. var df = dict.get('DescendantFonts');
  30811. if (!df) {
  30812. error('Descendant fonts are not specified');
  30813. }
  30814. dict = isArray(df) ? xref.fetchIfRef(df[0]) : df;
  30815. type = dict.get('Subtype');
  30816. assert(isName(type), 'invalid font Subtype');
  30817. composite = true;
  30818. }
  30819. var descriptor = dict.get('FontDescriptor');
  30820. if (descriptor) {
  30821. var hash = new MurmurHash3_64();
  30822. var encoding = baseDict.getRaw('Encoding');
  30823. if (isName(encoding)) {
  30824. hash.update(encoding.name);
  30825. } else if (isRef(encoding)) {
  30826. hash.update(encoding.toString());
  30827. } else if (isDict(encoding)) {
  30828. var keys = encoding.getKeys();
  30829. for (var i = 0, ii = keys.length; i < ii; i++) {
  30830. var entry = encoding.getRaw(keys[i]);
  30831. if (isName(entry)) {
  30832. hash.update(entry.name);
  30833. } else if (isRef(entry)) {
  30834. hash.update(entry.toString());
  30835. } else if (isArray(entry)) {
  30836. var diffLength = entry.length, diffBuf = new Array(diffLength);
  30837. for (var j = 0; j < diffLength; j++) {
  30838. var diffEntry = entry[j];
  30839. if (isName(diffEntry)) {
  30840. diffBuf[j] = diffEntry.name;
  30841. } else if (isNum(diffEntry) || isRef(diffEntry)) {
  30842. diffBuf[j] = diffEntry.toString();
  30843. }
  30844. }
  30845. hash.update(diffBuf.join());
  30846. }
  30847. }
  30848. }
  30849. var toUnicode = dict.get('ToUnicode') || baseDict.get('ToUnicode');
  30850. if (isStream(toUnicode)) {
  30851. var stream = toUnicode.str || toUnicode;
  30852. uint8array = stream.buffer ? new Uint8Array(stream.buffer.buffer, 0, stream.bufferLength) : new Uint8Array(stream.bytes.buffer, stream.start, stream.end - stream.start);
  30853. hash.update(uint8array);
  30854. } else if (isName(toUnicode)) {
  30855. hash.update(toUnicode.name);
  30856. }
  30857. var widths = dict.get('Widths') || baseDict.get('Widths');
  30858. if (widths) {
  30859. uint8array = new Uint8Array(new Uint32Array(widths).buffer);
  30860. hash.update(uint8array);
  30861. }
  30862. }
  30863. return {
  30864. descriptor: descriptor,
  30865. dict: dict,
  30866. baseDict: baseDict,
  30867. composite: composite,
  30868. type: type.name,
  30869. hash: hash ? hash.hexdigest() : ''
  30870. };
  30871. },
  30872. translateFont: function PartialEvaluator_translateFont(preEvaluatedFont, xref) {
  30873. var baseDict = preEvaluatedFont.baseDict;
  30874. var dict = preEvaluatedFont.dict;
  30875. var composite = preEvaluatedFont.composite;
  30876. var descriptor = preEvaluatedFont.descriptor;
  30877. var type = preEvaluatedFont.type;
  30878. var maxCharIndex = composite ? 0xFFFF : 0xFF;
  30879. var cMapOptions = this.options.cMapOptions;
  30880. var properties;
  30881. if (!descriptor) {
  30882. if (type === 'Type3') {
  30883. descriptor = new Dict(null);
  30884. descriptor.set('FontName', Name.get(type));
  30885. descriptor.set('FontBBox', dict.getArray('FontBBox'));
  30886. } else {
  30887. var baseFontName = dict.get('BaseFont');
  30888. if (!isName(baseFontName)) {
  30889. error('Base font is not specified');
  30890. }
  30891. baseFontName = baseFontName.name.replace(/[,_]/g, '-');
  30892. var metrics = this.getBaseFontMetrics(baseFontName);
  30893. var fontNameWoStyle = baseFontName.split('-')[0];
  30894. var flags = (this.isSerifFont(fontNameWoStyle) ? FontFlags.Serif : 0) | (metrics.monospace ? FontFlags.FixedPitch : 0) | (getSymbolsFonts()[fontNameWoStyle] ? FontFlags.Symbolic : FontFlags.Nonsymbolic);
  30895. properties = {
  30896. type: type,
  30897. name: baseFontName,
  30898. widths: metrics.widths,
  30899. defaultWidth: metrics.defaultWidth,
  30900. flags: flags,
  30901. firstChar: 0,
  30902. lastChar: maxCharIndex
  30903. };
  30904. return this.extractDataStructures(dict, dict, xref, properties).then(function (properties) {
  30905. properties.widths = this.buildCharCodeToWidth(metrics.widths, properties);
  30906. return new Font(baseFontName, null, properties);
  30907. }.bind(this));
  30908. }
  30909. }
  30910. var firstChar = dict.get('FirstChar') || 0;
  30911. var lastChar = dict.get('LastChar') || maxCharIndex;
  30912. var fontName = descriptor.get('FontName');
  30913. var baseFont = dict.get('BaseFont');
  30914. if (isString(fontName)) {
  30915. fontName = Name.get(fontName);
  30916. }
  30917. if (isString(baseFont)) {
  30918. baseFont = Name.get(baseFont);
  30919. }
  30920. if (type !== 'Type3') {
  30921. var fontNameStr = fontName && fontName.name;
  30922. var baseFontStr = baseFont && baseFont.name;
  30923. if (fontNameStr !== baseFontStr) {
  30924. info('The FontDescriptor\'s FontName is "' + fontNameStr + '" but should be the same as the Font\'s BaseFont "' + baseFontStr + '"');
  30925. if (fontNameStr && baseFontStr && baseFontStr.indexOf(fontNameStr) === 0) {
  30926. fontName = baseFont;
  30927. }
  30928. }
  30929. }
  30930. fontName = fontName || baseFont;
  30931. assert(isName(fontName), 'invalid font name');
  30932. var fontFile = descriptor.get('FontFile', 'FontFile2', 'FontFile3');
  30933. if (fontFile) {
  30934. if (fontFile.dict) {
  30935. var subtype = fontFile.dict.get('Subtype');
  30936. if (subtype) {
  30937. subtype = subtype.name;
  30938. }
  30939. var length1 = fontFile.dict.get('Length1');
  30940. var length2 = fontFile.dict.get('Length2');
  30941. var length3 = fontFile.dict.get('Length3');
  30942. }
  30943. }
  30944. properties = {
  30945. type: type,
  30946. name: fontName.name,
  30947. subtype: subtype,
  30948. file: fontFile,
  30949. length1: length1,
  30950. length2: length2,
  30951. length3: length3,
  30952. loadedName: baseDict.loadedName,
  30953. composite: composite,
  30954. wideChars: composite,
  30955. fixedPitch: false,
  30956. fontMatrix: dict.getArray('FontMatrix') || FONT_IDENTITY_MATRIX,
  30957. firstChar: firstChar || 0,
  30958. lastChar: lastChar || maxCharIndex,
  30959. bbox: descriptor.getArray('FontBBox'),
  30960. ascent: descriptor.get('Ascent'),
  30961. descent: descriptor.get('Descent'),
  30962. xHeight: descriptor.get('XHeight'),
  30963. capHeight: descriptor.get('CapHeight'),
  30964. flags: descriptor.get('Flags'),
  30965. italicAngle: descriptor.get('ItalicAngle'),
  30966. coded: false
  30967. };
  30968. var cMapPromise;
  30969. if (composite) {
  30970. var cidEncoding = baseDict.get('Encoding');
  30971. if (isName(cidEncoding)) {
  30972. properties.cidEncoding = cidEncoding.name;
  30973. }
  30974. cMapPromise = CMapFactory.create(cidEncoding, cMapOptions, null).then(function (cMap) {
  30975. properties.cMap = cMap;
  30976. properties.vertical = properties.cMap.vertical;
  30977. });
  30978. } else {
  30979. cMapPromise = Promise.resolve(undefined);
  30980. }
  30981. return cMapPromise.then(function () {
  30982. return this.extractDataStructures(dict, baseDict, xref, properties);
  30983. }.bind(this)).then(function (properties) {
  30984. this.extractWidths(dict, xref, descriptor, properties);
  30985. if (type === 'Type3') {
  30986. properties.isType3Font = true;
  30987. }
  30988. return new Font(fontName.name, fontFile, properties);
  30989. }.bind(this));
  30990. }
  30991. };
  30992. return PartialEvaluator;
  30993. }();
  30994. var TranslatedFont = function TranslatedFontClosure() {
  30995. function TranslatedFont(loadedName, font, dict) {
  30996. this.loadedName = loadedName;
  30997. this.font = font;
  30998. this.dict = dict;
  30999. this.type3Loaded = null;
  31000. this.sent = false;
  31001. }
  31002. TranslatedFont.prototype = {
  31003. send: function (handler) {
  31004. if (this.sent) {
  31005. return;
  31006. }
  31007. var fontData = this.font.exportData();
  31008. handler.send('commonobj', [
  31009. this.loadedName,
  31010. 'Font',
  31011. fontData
  31012. ]);
  31013. this.sent = true;
  31014. },
  31015. loadType3Data: function (evaluator, resources, parentOperatorList, task) {
  31016. assert(this.font.isType3Font);
  31017. if (this.type3Loaded) {
  31018. return this.type3Loaded;
  31019. }
  31020. var translatedFont = this.font;
  31021. var loadCharProcsPromise = Promise.resolve();
  31022. var charProcs = this.dict.get('CharProcs');
  31023. var fontResources = this.dict.get('Resources') || resources;
  31024. var charProcKeys = charProcs.getKeys();
  31025. var charProcOperatorList = Object.create(null);
  31026. for (var i = 0, n = charProcKeys.length; i < n; ++i) {
  31027. loadCharProcsPromise = loadCharProcsPromise.then(function (key) {
  31028. var glyphStream = charProcs.get(key);
  31029. var operatorList = new OperatorList();
  31030. return evaluator.getOperatorList(glyphStream, task, fontResources, operatorList).then(function () {
  31031. charProcOperatorList[key] = operatorList.getIR();
  31032. parentOperatorList.addDependencies(operatorList.dependencies);
  31033. }, function (reason) {
  31034. warn('Type3 font resource \"' + key + '\" is not available');
  31035. var operatorList = new OperatorList();
  31036. charProcOperatorList[key] = operatorList.getIR();
  31037. });
  31038. }.bind(this, charProcKeys[i]));
  31039. }
  31040. this.type3Loaded = loadCharProcsPromise.then(function () {
  31041. translatedFont.charProcOperatorList = charProcOperatorList;
  31042. });
  31043. return this.type3Loaded;
  31044. }
  31045. };
  31046. return TranslatedFont;
  31047. }();
  31048. var OperatorList = function OperatorListClosure() {
  31049. var CHUNK_SIZE = 1000;
  31050. var CHUNK_SIZE_ABOUT = CHUNK_SIZE - 5;
  31051. function getTransfers(queue) {
  31052. var transfers = [];
  31053. var fnArray = queue.fnArray, argsArray = queue.argsArray;
  31054. for (var i = 0, ii = queue.length; i < ii; i++) {
  31055. switch (fnArray[i]) {
  31056. case OPS.paintInlineImageXObject:
  31057. case OPS.paintInlineImageXObjectGroup:
  31058. case OPS.paintImageMaskXObject:
  31059. var arg = argsArray[i][0];
  31060. if (!arg.cached) {
  31061. transfers.push(arg.data.buffer);
  31062. }
  31063. break;
  31064. }
  31065. }
  31066. return transfers;
  31067. }
  31068. function OperatorList(intent, messageHandler, pageIndex) {
  31069. this.messageHandler = messageHandler;
  31070. this.fnArray = [];
  31071. this.argsArray = [];
  31072. this.dependencies = Object.create(null);
  31073. this._totalLength = 0;
  31074. this.pageIndex = pageIndex;
  31075. this.intent = intent;
  31076. }
  31077. OperatorList.prototype = {
  31078. get length() {
  31079. return this.argsArray.length;
  31080. },
  31081. get totalLength() {
  31082. return this._totalLength + this.length;
  31083. },
  31084. addOp: function (fn, args) {
  31085. this.fnArray.push(fn);
  31086. this.argsArray.push(args);
  31087. if (this.messageHandler) {
  31088. if (this.fnArray.length >= CHUNK_SIZE) {
  31089. this.flush();
  31090. } else if (this.fnArray.length >= CHUNK_SIZE_ABOUT && (fn === OPS.restore || fn === OPS.endText)) {
  31091. this.flush();
  31092. }
  31093. }
  31094. },
  31095. addDependency: function (dependency) {
  31096. if (dependency in this.dependencies) {
  31097. return;
  31098. }
  31099. this.dependencies[dependency] = true;
  31100. this.addOp(OPS.dependency, [dependency]);
  31101. },
  31102. addDependencies: function (dependencies) {
  31103. for (var key in dependencies) {
  31104. this.addDependency(key);
  31105. }
  31106. },
  31107. addOpList: function (opList) {
  31108. Util.extendObj(this.dependencies, opList.dependencies);
  31109. for (var i = 0, ii = opList.length; i < ii; i++) {
  31110. this.addOp(opList.fnArray[i], opList.argsArray[i]);
  31111. }
  31112. },
  31113. getIR: function () {
  31114. return {
  31115. fnArray: this.fnArray,
  31116. argsArray: this.argsArray,
  31117. length: this.length
  31118. };
  31119. },
  31120. flush: function (lastChunk) {
  31121. if (this.intent !== 'oplist') {
  31122. new QueueOptimizer().optimize(this);
  31123. }
  31124. var transfers = getTransfers(this);
  31125. var length = this.length;
  31126. this._totalLength += length;
  31127. this.messageHandler.send('RenderPageChunk', {
  31128. operatorList: {
  31129. fnArray: this.fnArray,
  31130. argsArray: this.argsArray,
  31131. lastChunk: lastChunk,
  31132. length: length
  31133. },
  31134. pageIndex: this.pageIndex,
  31135. intent: this.intent
  31136. }, transfers);
  31137. this.dependencies = Object.create(null);
  31138. this.fnArray.length = 0;
  31139. this.argsArray.length = 0;
  31140. }
  31141. };
  31142. return OperatorList;
  31143. }();
  31144. var StateManager = function StateManagerClosure() {
  31145. function StateManager(initialState) {
  31146. this.state = initialState;
  31147. this.stateStack = [];
  31148. }
  31149. StateManager.prototype = {
  31150. save: function () {
  31151. var old = this.state;
  31152. this.stateStack.push(this.state);
  31153. this.state = old.clone();
  31154. },
  31155. restore: function () {
  31156. var prev = this.stateStack.pop();
  31157. if (prev) {
  31158. this.state = prev;
  31159. }
  31160. },
  31161. transform: function (args) {
  31162. this.state.ctm = Util.transform(this.state.ctm, args);
  31163. }
  31164. };
  31165. return StateManager;
  31166. }();
  31167. var TextState = function TextStateClosure() {
  31168. function TextState() {
  31169. this.ctm = new Float32Array(IDENTITY_MATRIX);
  31170. this.fontName = null;
  31171. this.fontSize = 0;
  31172. this.font = null;
  31173. this.fontMatrix = FONT_IDENTITY_MATRIX;
  31174. this.textMatrix = IDENTITY_MATRIX.slice();
  31175. this.textLineMatrix = IDENTITY_MATRIX.slice();
  31176. this.charSpacing = 0;
  31177. this.wordSpacing = 0;
  31178. this.leading = 0;
  31179. this.textHScale = 1;
  31180. this.textRise = 0;
  31181. }
  31182. TextState.prototype = {
  31183. setTextMatrix: function TextState_setTextMatrix(a, b, c, d, e, f) {
  31184. var m = this.textMatrix;
  31185. m[0] = a;
  31186. m[1] = b;
  31187. m[2] = c;
  31188. m[3] = d;
  31189. m[4] = e;
  31190. m[5] = f;
  31191. },
  31192. setTextLineMatrix: function TextState_setTextMatrix(a, b, c, d, e, f) {
  31193. var m = this.textLineMatrix;
  31194. m[0] = a;
  31195. m[1] = b;
  31196. m[2] = c;
  31197. m[3] = d;
  31198. m[4] = e;
  31199. m[5] = f;
  31200. },
  31201. translateTextMatrix: function TextState_translateTextMatrix(x, y) {
  31202. var m = this.textMatrix;
  31203. m[4] = m[0] * x + m[2] * y + m[4];
  31204. m[5] = m[1] * x + m[3] * y + m[5];
  31205. },
  31206. translateTextLineMatrix: function TextState_translateTextMatrix(x, y) {
  31207. var m = this.textLineMatrix;
  31208. m[4] = m[0] * x + m[2] * y + m[4];
  31209. m[5] = m[1] * x + m[3] * y + m[5];
  31210. },
  31211. calcTextLineMatrixAdvance: function TextState_calcTextLineMatrixAdvance(a, b, c, d, e, f) {
  31212. var font = this.font;
  31213. if (!font) {
  31214. return null;
  31215. }
  31216. var m = this.textLineMatrix;
  31217. if (!(a === m[0] && b === m[1] && c === m[2] && d === m[3])) {
  31218. return null;
  31219. }
  31220. var txDiff = e - m[4], tyDiff = f - m[5];
  31221. if (font.vertical && txDiff !== 0 || !font.vertical && tyDiff !== 0) {
  31222. return null;
  31223. }
  31224. var tx, ty, denominator = a * d - b * c;
  31225. if (font.vertical) {
  31226. tx = -tyDiff * c / denominator;
  31227. ty = tyDiff * a / denominator;
  31228. } else {
  31229. tx = txDiff * d / denominator;
  31230. ty = -txDiff * b / denominator;
  31231. }
  31232. return {
  31233. width: tx,
  31234. height: ty,
  31235. value: font.vertical ? ty : tx
  31236. };
  31237. },
  31238. calcRenderMatrix: function TextState_calcRendeMatrix(ctm) {
  31239. var tsm = [
  31240. this.fontSize * this.textHScale,
  31241. 0,
  31242. 0,
  31243. this.fontSize,
  31244. 0,
  31245. this.textRise
  31246. ];
  31247. return Util.transform(ctm, Util.transform(this.textMatrix, tsm));
  31248. },
  31249. carriageReturn: function TextState_carriageReturn() {
  31250. this.translateTextLineMatrix(0, -this.leading);
  31251. this.textMatrix = this.textLineMatrix.slice();
  31252. },
  31253. clone: function TextState_clone() {
  31254. var clone = Object.create(this);
  31255. clone.textMatrix = this.textMatrix.slice();
  31256. clone.textLineMatrix = this.textLineMatrix.slice();
  31257. clone.fontMatrix = this.fontMatrix.slice();
  31258. return clone;
  31259. }
  31260. };
  31261. return TextState;
  31262. }();
  31263. var EvalState = function EvalStateClosure() {
  31264. function EvalState() {
  31265. this.ctm = new Float32Array(IDENTITY_MATRIX);
  31266. this.font = null;
  31267. this.textRenderingMode = TextRenderingMode.FILL;
  31268. this.fillColorSpace = ColorSpace.singletons.gray;
  31269. this.strokeColorSpace = ColorSpace.singletons.gray;
  31270. }
  31271. EvalState.prototype = {
  31272. clone: function CanvasExtraState_clone() {
  31273. return Object.create(this);
  31274. }
  31275. };
  31276. return EvalState;
  31277. }();
  31278. var EvaluatorPreprocessor = function EvaluatorPreprocessorClosure() {
  31279. var getOPMap = getLookupTableFactory(function (t) {
  31280. t['w'] = {
  31281. id: OPS.setLineWidth,
  31282. numArgs: 1,
  31283. variableArgs: false
  31284. };
  31285. t['J'] = {
  31286. id: OPS.setLineCap,
  31287. numArgs: 1,
  31288. variableArgs: false
  31289. };
  31290. t['j'] = {
  31291. id: OPS.setLineJoin,
  31292. numArgs: 1,
  31293. variableArgs: false
  31294. };
  31295. t['M'] = {
  31296. id: OPS.setMiterLimit,
  31297. numArgs: 1,
  31298. variableArgs: false
  31299. };
  31300. t['d'] = {
  31301. id: OPS.setDash,
  31302. numArgs: 2,
  31303. variableArgs: false
  31304. };
  31305. t['ri'] = {
  31306. id: OPS.setRenderingIntent,
  31307. numArgs: 1,
  31308. variableArgs: false
  31309. };
  31310. t['i'] = {
  31311. id: OPS.setFlatness,
  31312. numArgs: 1,
  31313. variableArgs: false
  31314. };
  31315. t['gs'] = {
  31316. id: OPS.setGState,
  31317. numArgs: 1,
  31318. variableArgs: false
  31319. };
  31320. t['q'] = {
  31321. id: OPS.save,
  31322. numArgs: 0,
  31323. variableArgs: false
  31324. };
  31325. t['Q'] = {
  31326. id: OPS.restore,
  31327. numArgs: 0,
  31328. variableArgs: false
  31329. };
  31330. t['cm'] = {
  31331. id: OPS.transform,
  31332. numArgs: 6,
  31333. variableArgs: false
  31334. };
  31335. t['m'] = {
  31336. id: OPS.moveTo,
  31337. numArgs: 2,
  31338. variableArgs: false
  31339. };
  31340. t['l'] = {
  31341. id: OPS.lineTo,
  31342. numArgs: 2,
  31343. variableArgs: false
  31344. };
  31345. t['c'] = {
  31346. id: OPS.curveTo,
  31347. numArgs: 6,
  31348. variableArgs: false
  31349. };
  31350. t['v'] = {
  31351. id: OPS.curveTo2,
  31352. numArgs: 4,
  31353. variableArgs: false
  31354. };
  31355. t['y'] = {
  31356. id: OPS.curveTo3,
  31357. numArgs: 4,
  31358. variableArgs: false
  31359. };
  31360. t['h'] = {
  31361. id: OPS.closePath,
  31362. numArgs: 0,
  31363. variableArgs: false
  31364. };
  31365. t['re'] = {
  31366. id: OPS.rectangle,
  31367. numArgs: 4,
  31368. variableArgs: false
  31369. };
  31370. t['S'] = {
  31371. id: OPS.stroke,
  31372. numArgs: 0,
  31373. variableArgs: false
  31374. };
  31375. t['s'] = {
  31376. id: OPS.closeStroke,
  31377. numArgs: 0,
  31378. variableArgs: false
  31379. };
  31380. t['f'] = {
  31381. id: OPS.fill,
  31382. numArgs: 0,
  31383. variableArgs: false
  31384. };
  31385. t['F'] = {
  31386. id: OPS.fill,
  31387. numArgs: 0,
  31388. variableArgs: false
  31389. };
  31390. t['f*'] = {
  31391. id: OPS.eoFill,
  31392. numArgs: 0,
  31393. variableArgs: false
  31394. };
  31395. t['B'] = {
  31396. id: OPS.fillStroke,
  31397. numArgs: 0,
  31398. variableArgs: false
  31399. };
  31400. t['B*'] = {
  31401. id: OPS.eoFillStroke,
  31402. numArgs: 0,
  31403. variableArgs: false
  31404. };
  31405. t['b'] = {
  31406. id: OPS.closeFillStroke,
  31407. numArgs: 0,
  31408. variableArgs: false
  31409. };
  31410. t['b*'] = {
  31411. id: OPS.closeEOFillStroke,
  31412. numArgs: 0,
  31413. variableArgs: false
  31414. };
  31415. t['n'] = {
  31416. id: OPS.endPath,
  31417. numArgs: 0,
  31418. variableArgs: false
  31419. };
  31420. t['W'] = {
  31421. id: OPS.clip,
  31422. numArgs: 0,
  31423. variableArgs: false
  31424. };
  31425. t['W*'] = {
  31426. id: OPS.eoClip,
  31427. numArgs: 0,
  31428. variableArgs: false
  31429. };
  31430. t['BT'] = {
  31431. id: OPS.beginText,
  31432. numArgs: 0,
  31433. variableArgs: false
  31434. };
  31435. t['ET'] = {
  31436. id: OPS.endText,
  31437. numArgs: 0,
  31438. variableArgs: false
  31439. };
  31440. t['Tc'] = {
  31441. id: OPS.setCharSpacing,
  31442. numArgs: 1,
  31443. variableArgs: false
  31444. };
  31445. t['Tw'] = {
  31446. id: OPS.setWordSpacing,
  31447. numArgs: 1,
  31448. variableArgs: false
  31449. };
  31450. t['Tz'] = {
  31451. id: OPS.setHScale,
  31452. numArgs: 1,
  31453. variableArgs: false
  31454. };
  31455. t['TL'] = {
  31456. id: OPS.setLeading,
  31457. numArgs: 1,
  31458. variableArgs: false
  31459. };
  31460. t['Tf'] = {
  31461. id: OPS.setFont,
  31462. numArgs: 2,
  31463. variableArgs: false
  31464. };
  31465. t['Tr'] = {
  31466. id: OPS.setTextRenderingMode,
  31467. numArgs: 1,
  31468. variableArgs: false
  31469. };
  31470. t['Ts'] = {
  31471. id: OPS.setTextRise,
  31472. numArgs: 1,
  31473. variableArgs: false
  31474. };
  31475. t['Td'] = {
  31476. id: OPS.moveText,
  31477. numArgs: 2,
  31478. variableArgs: false
  31479. };
  31480. t['TD'] = {
  31481. id: OPS.setLeadingMoveText,
  31482. numArgs: 2,
  31483. variableArgs: false
  31484. };
  31485. t['Tm'] = {
  31486. id: OPS.setTextMatrix,
  31487. numArgs: 6,
  31488. variableArgs: false
  31489. };
  31490. t['T*'] = {
  31491. id: OPS.nextLine,
  31492. numArgs: 0,
  31493. variableArgs: false
  31494. };
  31495. t['Tj'] = {
  31496. id: OPS.showText,
  31497. numArgs: 1,
  31498. variableArgs: false
  31499. };
  31500. t['TJ'] = {
  31501. id: OPS.showSpacedText,
  31502. numArgs: 1,
  31503. variableArgs: false
  31504. };
  31505. t['\''] = {
  31506. id: OPS.nextLineShowText,
  31507. numArgs: 1,
  31508. variableArgs: false
  31509. };
  31510. t['"'] = {
  31511. id: OPS.nextLineSetSpacingShowText,
  31512. numArgs: 3,
  31513. variableArgs: false
  31514. };
  31515. t['d0'] = {
  31516. id: OPS.setCharWidth,
  31517. numArgs: 2,
  31518. variableArgs: false
  31519. };
  31520. t['d1'] = {
  31521. id: OPS.setCharWidthAndBounds,
  31522. numArgs: 6,
  31523. variableArgs: false
  31524. };
  31525. t['CS'] = {
  31526. id: OPS.setStrokeColorSpace,
  31527. numArgs: 1,
  31528. variableArgs: false
  31529. };
  31530. t['cs'] = {
  31531. id: OPS.setFillColorSpace,
  31532. numArgs: 1,
  31533. variableArgs: false
  31534. };
  31535. t['SC'] = {
  31536. id: OPS.setStrokeColor,
  31537. numArgs: 4,
  31538. variableArgs: true
  31539. };
  31540. t['SCN'] = {
  31541. id: OPS.setStrokeColorN,
  31542. numArgs: 33,
  31543. variableArgs: true
  31544. };
  31545. t['sc'] = {
  31546. id: OPS.setFillColor,
  31547. numArgs: 4,
  31548. variableArgs: true
  31549. };
  31550. t['scn'] = {
  31551. id: OPS.setFillColorN,
  31552. numArgs: 33,
  31553. variableArgs: true
  31554. };
  31555. t['G'] = {
  31556. id: OPS.setStrokeGray,
  31557. numArgs: 1,
  31558. variableArgs: false
  31559. };
  31560. t['g'] = {
  31561. id: OPS.setFillGray,
  31562. numArgs: 1,
  31563. variableArgs: false
  31564. };
  31565. t['RG'] = {
  31566. id: OPS.setStrokeRGBColor,
  31567. numArgs: 3,
  31568. variableArgs: false
  31569. };
  31570. t['rg'] = {
  31571. id: OPS.setFillRGBColor,
  31572. numArgs: 3,
  31573. variableArgs: false
  31574. };
  31575. t['K'] = {
  31576. id: OPS.setStrokeCMYKColor,
  31577. numArgs: 4,
  31578. variableArgs: false
  31579. };
  31580. t['k'] = {
  31581. id: OPS.setFillCMYKColor,
  31582. numArgs: 4,
  31583. variableArgs: false
  31584. };
  31585. t['sh'] = {
  31586. id: OPS.shadingFill,
  31587. numArgs: 1,
  31588. variableArgs: false
  31589. };
  31590. t['BI'] = {
  31591. id: OPS.beginInlineImage,
  31592. numArgs: 0,
  31593. variableArgs: false
  31594. };
  31595. t['ID'] = {
  31596. id: OPS.beginImageData,
  31597. numArgs: 0,
  31598. variableArgs: false
  31599. };
  31600. t['EI'] = {
  31601. id: OPS.endInlineImage,
  31602. numArgs: 1,
  31603. variableArgs: false
  31604. };
  31605. t['Do'] = {
  31606. id: OPS.paintXObject,
  31607. numArgs: 1,
  31608. variableArgs: false
  31609. };
  31610. t['MP'] = {
  31611. id: OPS.markPoint,
  31612. numArgs: 1,
  31613. variableArgs: false
  31614. };
  31615. t['DP'] = {
  31616. id: OPS.markPointProps,
  31617. numArgs: 2,
  31618. variableArgs: false
  31619. };
  31620. t['BMC'] = {
  31621. id: OPS.beginMarkedContent,
  31622. numArgs: 1,
  31623. variableArgs: false
  31624. };
  31625. t['BDC'] = {
  31626. id: OPS.beginMarkedContentProps,
  31627. numArgs: 2,
  31628. variableArgs: false
  31629. };
  31630. t['EMC'] = {
  31631. id: OPS.endMarkedContent,
  31632. numArgs: 0,
  31633. variableArgs: false
  31634. };
  31635. t['BX'] = {
  31636. id: OPS.beginCompat,
  31637. numArgs: 0,
  31638. variableArgs: false
  31639. };
  31640. t['EX'] = {
  31641. id: OPS.endCompat,
  31642. numArgs: 0,
  31643. variableArgs: false
  31644. };
  31645. t['BM'] = null;
  31646. t['BD'] = null;
  31647. t['true'] = null;
  31648. t['fa'] = null;
  31649. t['fal'] = null;
  31650. t['fals'] = null;
  31651. t['false'] = null;
  31652. t['nu'] = null;
  31653. t['nul'] = null;
  31654. t['null'] = null;
  31655. });
  31656. function EvaluatorPreprocessor(stream, xref, stateManager) {
  31657. this.opMap = getOPMap();
  31658. this.parser = new Parser(new Lexer(stream, this.opMap), false, xref);
  31659. this.stateManager = stateManager;
  31660. this.nonProcessedArgs = [];
  31661. }
  31662. EvaluatorPreprocessor.prototype = {
  31663. get savedStatesDepth() {
  31664. return this.stateManager.stateStack.length;
  31665. },
  31666. read: function EvaluatorPreprocessor_read(operation) {
  31667. var args = operation.args;
  31668. while (true) {
  31669. var obj = this.parser.getObj();
  31670. if (isCmd(obj)) {
  31671. var cmd = obj.cmd;
  31672. var opSpec = this.opMap[cmd];
  31673. if (!opSpec) {
  31674. warn('Unknown command "' + cmd + '"');
  31675. continue;
  31676. }
  31677. var fn = opSpec.id;
  31678. var numArgs = opSpec.numArgs;
  31679. var argsLength = args !== null ? args.length : 0;
  31680. if (!opSpec.variableArgs) {
  31681. if (argsLength !== numArgs) {
  31682. var nonProcessedArgs = this.nonProcessedArgs;
  31683. while (argsLength > numArgs) {
  31684. nonProcessedArgs.push(args.shift());
  31685. argsLength--;
  31686. }
  31687. while (argsLength < numArgs && nonProcessedArgs.length !== 0) {
  31688. if (args === null) {
  31689. args = [];
  31690. }
  31691. args.unshift(nonProcessedArgs.pop());
  31692. argsLength++;
  31693. }
  31694. }
  31695. if (argsLength < numArgs) {
  31696. warn('Skipping command ' + fn + ': expected ' + numArgs + ' args, but received ' + argsLength + ' args.');
  31697. if (args !== null) {
  31698. args.length = 0;
  31699. }
  31700. continue;
  31701. }
  31702. } else if (argsLength > numArgs) {
  31703. info('Command ' + fn + ': expected [0,' + numArgs + '] args, but received ' + argsLength + ' args.');
  31704. }
  31705. this.preprocessCommand(fn, args);
  31706. operation.fn = fn;
  31707. operation.args = args;
  31708. return true;
  31709. }
  31710. if (isEOF(obj)) {
  31711. return false;
  31712. }
  31713. if (obj !== null) {
  31714. if (args === null) {
  31715. args = [];
  31716. }
  31717. args.push(obj);
  31718. assert(args.length <= 33, 'Too many arguments');
  31719. }
  31720. }
  31721. },
  31722. preprocessCommand: function EvaluatorPreprocessor_preprocessCommand(fn, args) {
  31723. switch (fn | 0) {
  31724. case OPS.save:
  31725. this.stateManager.save();
  31726. break;
  31727. case OPS.restore:
  31728. this.stateManager.restore();
  31729. break;
  31730. case OPS.transform:
  31731. this.stateManager.transform(args);
  31732. break;
  31733. }
  31734. }
  31735. };
  31736. return EvaluatorPreprocessor;
  31737. }();
  31738. var QueueOptimizer = function QueueOptimizerClosure() {
  31739. function addState(parentState, pattern, fn) {
  31740. var state = parentState;
  31741. for (var i = 0, ii = pattern.length - 1; i < ii; i++) {
  31742. var item = pattern[i];
  31743. state = state[item] || (state[item] = []);
  31744. }
  31745. state[pattern[pattern.length - 1]] = fn;
  31746. }
  31747. function handlePaintSolidColorImageMask(iFirstSave, count, fnArray, argsArray) {
  31748. var iFirstPIMXO = iFirstSave + 2;
  31749. for (var i = 0; i < count; i++) {
  31750. var arg = argsArray[iFirstPIMXO + 4 * i];
  31751. var imageMask = arg.length === 1 && arg[0];
  31752. if (imageMask && imageMask.width === 1 && imageMask.height === 1 && (!imageMask.data.length || imageMask.data.length === 1 && imageMask.data[0] === 0)) {
  31753. fnArray[iFirstPIMXO + 4 * i] = OPS.paintSolidColorImageMask;
  31754. continue;
  31755. }
  31756. break;
  31757. }
  31758. return count - i;
  31759. }
  31760. var InitialState = [];
  31761. addState(InitialState, [
  31762. OPS.save,
  31763. OPS.transform,
  31764. OPS.paintInlineImageXObject,
  31765. OPS.restore
  31766. ], function foundInlineImageGroup(context) {
  31767. var MIN_IMAGES_IN_INLINE_IMAGES_BLOCK = 10;
  31768. var MAX_IMAGES_IN_INLINE_IMAGES_BLOCK = 200;
  31769. var MAX_WIDTH = 1000;
  31770. var IMAGE_PADDING = 1;
  31771. var fnArray = context.fnArray, argsArray = context.argsArray;
  31772. var curr = context.iCurr;
  31773. var iFirstSave = curr - 3;
  31774. var iFirstTransform = curr - 2;
  31775. var iFirstPIIXO = curr - 1;
  31776. var i = iFirstSave + 4;
  31777. var ii = fnArray.length;
  31778. while (i + 3 < ii) {
  31779. if (fnArray[i] !== OPS.save || fnArray[i + 1] !== OPS.transform || fnArray[i + 2] !== OPS.paintInlineImageXObject || fnArray[i + 3] !== OPS.restore) {
  31780. break;
  31781. }
  31782. i += 4;
  31783. }
  31784. var count = Math.min((i - iFirstSave) / 4, MAX_IMAGES_IN_INLINE_IMAGES_BLOCK);
  31785. if (count < MIN_IMAGES_IN_INLINE_IMAGES_BLOCK) {
  31786. return i;
  31787. }
  31788. var maxX = 0;
  31789. var map = [], maxLineHeight = 0;
  31790. var currentX = IMAGE_PADDING, currentY = IMAGE_PADDING;
  31791. var q;
  31792. for (q = 0; q < count; q++) {
  31793. var transform = argsArray[iFirstTransform + (q << 2)];
  31794. var img = argsArray[iFirstPIIXO + (q << 2)][0];
  31795. if (currentX + img.width > MAX_WIDTH) {
  31796. maxX = Math.max(maxX, currentX);
  31797. currentY += maxLineHeight + 2 * IMAGE_PADDING;
  31798. currentX = 0;
  31799. maxLineHeight = 0;
  31800. }
  31801. map.push({
  31802. transform: transform,
  31803. x: currentX,
  31804. y: currentY,
  31805. w: img.width,
  31806. h: img.height
  31807. });
  31808. currentX += img.width + 2 * IMAGE_PADDING;
  31809. maxLineHeight = Math.max(maxLineHeight, img.height);
  31810. }
  31811. var imgWidth = Math.max(maxX, currentX) + IMAGE_PADDING;
  31812. var imgHeight = currentY + maxLineHeight + IMAGE_PADDING;
  31813. var imgData = new Uint8Array(imgWidth * imgHeight * 4);
  31814. var imgRowSize = imgWidth << 2;
  31815. for (q = 0; q < count; q++) {
  31816. var data = argsArray[iFirstPIIXO + (q << 2)][0].data;
  31817. var rowSize = map[q].w << 2;
  31818. var dataOffset = 0;
  31819. var offset = map[q].x + map[q].y * imgWidth << 2;
  31820. imgData.set(data.subarray(0, rowSize), offset - imgRowSize);
  31821. for (var k = 0, kk = map[q].h; k < kk; k++) {
  31822. imgData.set(data.subarray(dataOffset, dataOffset + rowSize), offset);
  31823. dataOffset += rowSize;
  31824. offset += imgRowSize;
  31825. }
  31826. imgData.set(data.subarray(dataOffset - rowSize, dataOffset), offset);
  31827. while (offset >= 0) {
  31828. data[offset - 4] = data[offset];
  31829. data[offset - 3] = data[offset + 1];
  31830. data[offset - 2] = data[offset + 2];
  31831. data[offset - 1] = data[offset + 3];
  31832. data[offset + rowSize] = data[offset + rowSize - 4];
  31833. data[offset + rowSize + 1] = data[offset + rowSize - 3];
  31834. data[offset + rowSize + 2] = data[offset + rowSize - 2];
  31835. data[offset + rowSize + 3] = data[offset + rowSize - 1];
  31836. offset -= imgRowSize;
  31837. }
  31838. }
  31839. fnArray.splice(iFirstSave, count * 4, OPS.paintInlineImageXObjectGroup);
  31840. argsArray.splice(iFirstSave, count * 4, [
  31841. {
  31842. width: imgWidth,
  31843. height: imgHeight,
  31844. kind: ImageKind.RGBA_32BPP,
  31845. data: imgData
  31846. },
  31847. map
  31848. ]);
  31849. return iFirstSave + 1;
  31850. });
  31851. addState(InitialState, [
  31852. OPS.save,
  31853. OPS.transform,
  31854. OPS.paintImageMaskXObject,
  31855. OPS.restore
  31856. ], function foundImageMaskGroup(context) {
  31857. var MIN_IMAGES_IN_MASKS_BLOCK = 10;
  31858. var MAX_IMAGES_IN_MASKS_BLOCK = 100;
  31859. var MAX_SAME_IMAGES_IN_MASKS_BLOCK = 1000;
  31860. var fnArray = context.fnArray, argsArray = context.argsArray;
  31861. var curr = context.iCurr;
  31862. var iFirstSave = curr - 3;
  31863. var iFirstTransform = curr - 2;
  31864. var iFirstPIMXO = curr - 1;
  31865. var i = iFirstSave + 4;
  31866. var ii = fnArray.length;
  31867. while (i + 3 < ii) {
  31868. if (fnArray[i] !== OPS.save || fnArray[i + 1] !== OPS.transform || fnArray[i + 2] !== OPS.paintImageMaskXObject || fnArray[i + 3] !== OPS.restore) {
  31869. break;
  31870. }
  31871. i += 4;
  31872. }
  31873. var count = (i - iFirstSave) / 4;
  31874. count = handlePaintSolidColorImageMask(iFirstSave, count, fnArray, argsArray);
  31875. if (count < MIN_IMAGES_IN_MASKS_BLOCK) {
  31876. return i;
  31877. }
  31878. var q;
  31879. var isSameImage = false;
  31880. var iTransform, transformArgs;
  31881. var firstPIMXOArg0 = argsArray[iFirstPIMXO][0];
  31882. if (argsArray[iFirstTransform][1] === 0 && argsArray[iFirstTransform][2] === 0) {
  31883. isSameImage = true;
  31884. var firstTransformArg0 = argsArray[iFirstTransform][0];
  31885. var firstTransformArg3 = argsArray[iFirstTransform][3];
  31886. iTransform = iFirstTransform + 4;
  31887. var iPIMXO = iFirstPIMXO + 4;
  31888. for (q = 1; q < count; q++, iTransform += 4, iPIMXO += 4) {
  31889. transformArgs = argsArray[iTransform];
  31890. if (argsArray[iPIMXO][0] !== firstPIMXOArg0 || transformArgs[0] !== firstTransformArg0 || transformArgs[1] !== 0 || transformArgs[2] !== 0 || transformArgs[3] !== firstTransformArg3) {
  31891. if (q < MIN_IMAGES_IN_MASKS_BLOCK) {
  31892. isSameImage = false;
  31893. } else {
  31894. count = q;
  31895. }
  31896. break;
  31897. }
  31898. }
  31899. }
  31900. if (isSameImage) {
  31901. count = Math.min(count, MAX_SAME_IMAGES_IN_MASKS_BLOCK);
  31902. var positions = new Float32Array(count * 2);
  31903. iTransform = iFirstTransform;
  31904. for (q = 0; q < count; q++, iTransform += 4) {
  31905. transformArgs = argsArray[iTransform];
  31906. positions[q << 1] = transformArgs[4];
  31907. positions[(q << 1) + 1] = transformArgs[5];
  31908. }
  31909. fnArray.splice(iFirstSave, count * 4, OPS.paintImageMaskXObjectRepeat);
  31910. argsArray.splice(iFirstSave, count * 4, [
  31911. firstPIMXOArg0,
  31912. firstTransformArg0,
  31913. firstTransformArg3,
  31914. positions
  31915. ]);
  31916. } else {
  31917. count = Math.min(count, MAX_IMAGES_IN_MASKS_BLOCK);
  31918. var images = [];
  31919. for (q = 0; q < count; q++) {
  31920. transformArgs = argsArray[iFirstTransform + (q << 2)];
  31921. var maskParams = argsArray[iFirstPIMXO + (q << 2)][0];
  31922. images.push({
  31923. data: maskParams.data,
  31924. width: maskParams.width,
  31925. height: maskParams.height,
  31926. transform: transformArgs
  31927. });
  31928. }
  31929. fnArray.splice(iFirstSave, count * 4, OPS.paintImageMaskXObjectGroup);
  31930. argsArray.splice(iFirstSave, count * 4, [images]);
  31931. }
  31932. return iFirstSave + 1;
  31933. });
  31934. addState(InitialState, [
  31935. OPS.save,
  31936. OPS.transform,
  31937. OPS.paintImageXObject,
  31938. OPS.restore
  31939. ], function (context) {
  31940. var MIN_IMAGES_IN_BLOCK = 3;
  31941. var MAX_IMAGES_IN_BLOCK = 1000;
  31942. var fnArray = context.fnArray, argsArray = context.argsArray;
  31943. var curr = context.iCurr;
  31944. var iFirstSave = curr - 3;
  31945. var iFirstTransform = curr - 2;
  31946. var iFirstPIXO = curr - 1;
  31947. var iFirstRestore = curr;
  31948. if (argsArray[iFirstTransform][1] !== 0 || argsArray[iFirstTransform][2] !== 0) {
  31949. return iFirstRestore + 1;
  31950. }
  31951. var firstPIXOArg0 = argsArray[iFirstPIXO][0];
  31952. var firstTransformArg0 = argsArray[iFirstTransform][0];
  31953. var firstTransformArg3 = argsArray[iFirstTransform][3];
  31954. var i = iFirstSave + 4;
  31955. var ii = fnArray.length;
  31956. while (i + 3 < ii) {
  31957. if (fnArray[i] !== OPS.save || fnArray[i + 1] !== OPS.transform || fnArray[i + 2] !== OPS.paintImageXObject || fnArray[i + 3] !== OPS.restore) {
  31958. break;
  31959. }
  31960. if (argsArray[i + 1][0] !== firstTransformArg0 || argsArray[i + 1][1] !== 0 || argsArray[i + 1][2] !== 0 || argsArray[i + 1][3] !== firstTransformArg3) {
  31961. break;
  31962. }
  31963. if (argsArray[i + 2][0] !== firstPIXOArg0) {
  31964. break;
  31965. }
  31966. i += 4;
  31967. }
  31968. var count = Math.min((i - iFirstSave) / 4, MAX_IMAGES_IN_BLOCK);
  31969. if (count < MIN_IMAGES_IN_BLOCK) {
  31970. return i;
  31971. }
  31972. var positions = new Float32Array(count * 2);
  31973. var iTransform = iFirstTransform;
  31974. for (var q = 0; q < count; q++, iTransform += 4) {
  31975. var transformArgs = argsArray[iTransform];
  31976. positions[q << 1] = transformArgs[4];
  31977. positions[(q << 1) + 1] = transformArgs[5];
  31978. }
  31979. var args = [
  31980. firstPIXOArg0,
  31981. firstTransformArg0,
  31982. firstTransformArg3,
  31983. positions
  31984. ];
  31985. fnArray.splice(iFirstSave, count * 4, OPS.paintImageXObjectRepeat);
  31986. argsArray.splice(iFirstSave, count * 4, args);
  31987. return iFirstSave + 1;
  31988. });
  31989. addState(InitialState, [
  31990. OPS.beginText,
  31991. OPS.setFont,
  31992. OPS.setTextMatrix,
  31993. OPS.showText,
  31994. OPS.endText
  31995. ], function (context) {
  31996. var MIN_CHARS_IN_BLOCK = 3;
  31997. var MAX_CHARS_IN_BLOCK = 1000;
  31998. var fnArray = context.fnArray, argsArray = context.argsArray;
  31999. var curr = context.iCurr;
  32000. var iFirstBeginText = curr - 4;
  32001. var iFirstSetFont = curr - 3;
  32002. var iFirstSetTextMatrix = curr - 2;
  32003. var iFirstShowText = curr - 1;
  32004. var iFirstEndText = curr;
  32005. var firstSetFontArg0 = argsArray[iFirstSetFont][0];
  32006. var firstSetFontArg1 = argsArray[iFirstSetFont][1];
  32007. var i = iFirstBeginText + 5;
  32008. var ii = fnArray.length;
  32009. while (i + 4 < ii) {
  32010. 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) {
  32011. break;
  32012. }
  32013. if (argsArray[i + 1][0] !== firstSetFontArg0 || argsArray[i + 1][1] !== firstSetFontArg1) {
  32014. break;
  32015. }
  32016. i += 5;
  32017. }
  32018. var count = Math.min((i - iFirstBeginText) / 5, MAX_CHARS_IN_BLOCK);
  32019. if (count < MIN_CHARS_IN_BLOCK) {
  32020. return i;
  32021. }
  32022. var iFirst = iFirstBeginText;
  32023. 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) {
  32024. count++;
  32025. iFirst -= 5;
  32026. }
  32027. var iEndText = iFirst + 4;
  32028. for (var q = 1; q < count; q++) {
  32029. fnArray.splice(iEndText, 3);
  32030. argsArray.splice(iEndText, 3);
  32031. iEndText += 2;
  32032. }
  32033. return iEndText + 1;
  32034. });
  32035. function QueueOptimizer() {
  32036. }
  32037. QueueOptimizer.prototype = {
  32038. optimize: function QueueOptimizer_optimize(queue) {
  32039. var fnArray = queue.fnArray, argsArray = queue.argsArray;
  32040. var context = {
  32041. iCurr: 0,
  32042. fnArray: fnArray,
  32043. argsArray: argsArray
  32044. };
  32045. var state;
  32046. var i = 0, ii = fnArray.length;
  32047. while (i < ii) {
  32048. state = (state || InitialState)[fnArray[i]];
  32049. if (typeof state === 'function') {
  32050. context.iCurr = i;
  32051. i = state(context);
  32052. state = undefined;
  32053. ii = context.fnArray.length;
  32054. } else {
  32055. i++;
  32056. }
  32057. }
  32058. }
  32059. };
  32060. return QueueOptimizer;
  32061. }();
  32062. exports.OperatorList = OperatorList;
  32063. exports.PartialEvaluator = PartialEvaluator;
  32064. /***/ }),
  32065. /* 18 */
  32066. /***/ (function(module, exports, __w_pdfjs_require__) {
  32067. "use strict";
  32068. var sharedUtil = __w_pdfjs_require__(0);
  32069. var coreArithmeticDecoder = __w_pdfjs_require__(13);
  32070. var info = sharedUtil.info;
  32071. var warn = sharedUtil.warn;
  32072. var error = sharedUtil.error;
  32073. var log2 = sharedUtil.log2;
  32074. var readUint16 = sharedUtil.readUint16;
  32075. var readUint32 = sharedUtil.readUint32;
  32076. var ArithmeticDecoder = coreArithmeticDecoder.ArithmeticDecoder;
  32077. var JpxImage = function JpxImageClosure() {
  32078. var SubbandsGainLog2 = {
  32079. 'LL': 0,
  32080. 'LH': 1,
  32081. 'HL': 1,
  32082. 'HH': 2
  32083. };
  32084. function JpxImage() {
  32085. this.failOnCorruptedImage = false;
  32086. }
  32087. JpxImage.prototype = {
  32088. parse: function JpxImage_parse(data) {
  32089. var head = readUint16(data, 0);
  32090. if (head === 0xFF4F) {
  32091. this.parseCodestream(data, 0, data.length);
  32092. return;
  32093. }
  32094. var position = 0, length = data.length;
  32095. while (position < length) {
  32096. var headerSize = 8;
  32097. var lbox = readUint32(data, position);
  32098. var tbox = readUint32(data, position + 4);
  32099. position += headerSize;
  32100. if (lbox === 1) {
  32101. lbox = readUint32(data, position) * 4294967296 + readUint32(data, position + 4);
  32102. position += 8;
  32103. headerSize += 8;
  32104. }
  32105. if (lbox === 0) {
  32106. lbox = length - position + headerSize;
  32107. }
  32108. if (lbox < headerSize) {
  32109. error('JPX Error: Invalid box field size');
  32110. }
  32111. var dataLength = lbox - headerSize;
  32112. var jumpDataLength = true;
  32113. switch (tbox) {
  32114. case 0x6A703268:
  32115. jumpDataLength = false;
  32116. break;
  32117. case 0x636F6C72:
  32118. var method = data[position];
  32119. if (method === 1) {
  32120. var colorspace = readUint32(data, position + 3);
  32121. switch (colorspace) {
  32122. case 16:
  32123. case 17:
  32124. case 18:
  32125. break;
  32126. default:
  32127. warn('Unknown colorspace ' + colorspace);
  32128. break;
  32129. }
  32130. } else if (method === 2) {
  32131. info('ICC profile not supported');
  32132. }
  32133. break;
  32134. case 0x6A703263:
  32135. this.parseCodestream(data, position, position + dataLength);
  32136. break;
  32137. case 0x6A502020:
  32138. if (0x0d0a870a !== readUint32(data, position)) {
  32139. warn('Invalid JP2 signature');
  32140. }
  32141. break;
  32142. case 0x6A501A1A:
  32143. case 0x66747970:
  32144. case 0x72726571:
  32145. case 0x72657320:
  32146. case 0x69686472:
  32147. break;
  32148. default:
  32149. var headerType = String.fromCharCode(tbox >> 24 & 0xFF, tbox >> 16 & 0xFF, tbox >> 8 & 0xFF, tbox & 0xFF);
  32150. warn('Unsupported header type ' + tbox + ' (' + headerType + ')');
  32151. break;
  32152. }
  32153. if (jumpDataLength) {
  32154. position += dataLength;
  32155. }
  32156. }
  32157. },
  32158. parseImageProperties: function JpxImage_parseImageProperties(stream) {
  32159. var newByte = stream.getByte();
  32160. while (newByte >= 0) {
  32161. var oldByte = newByte;
  32162. newByte = stream.getByte();
  32163. var code = oldByte << 8 | newByte;
  32164. if (code === 0xFF51) {
  32165. stream.skip(4);
  32166. var Xsiz = stream.getInt32() >>> 0;
  32167. var Ysiz = stream.getInt32() >>> 0;
  32168. var XOsiz = stream.getInt32() >>> 0;
  32169. var YOsiz = stream.getInt32() >>> 0;
  32170. stream.skip(16);
  32171. var Csiz = stream.getUint16();
  32172. this.width = Xsiz - XOsiz;
  32173. this.height = Ysiz - YOsiz;
  32174. this.componentsCount = Csiz;
  32175. this.bitsPerComponent = 8;
  32176. return;
  32177. }
  32178. }
  32179. error('JPX Error: No size marker found in JPX stream');
  32180. },
  32181. parseCodestream: function JpxImage_parseCodestream(data, start, end) {
  32182. var context = {};
  32183. var doNotRecover = false;
  32184. try {
  32185. var position = start;
  32186. while (position + 1 < end) {
  32187. var code = readUint16(data, position);
  32188. position += 2;
  32189. var length = 0, j, sqcd, spqcds, spqcdSize, scalarExpounded, tile;
  32190. switch (code) {
  32191. case 0xFF4F:
  32192. context.mainHeader = true;
  32193. break;
  32194. case 0xFFD9:
  32195. break;
  32196. case 0xFF51:
  32197. length = readUint16(data, position);
  32198. var siz = {};
  32199. siz.Xsiz = readUint32(data, position + 4);
  32200. siz.Ysiz = readUint32(data, position + 8);
  32201. siz.XOsiz = readUint32(data, position + 12);
  32202. siz.YOsiz = readUint32(data, position + 16);
  32203. siz.XTsiz = readUint32(data, position + 20);
  32204. siz.YTsiz = readUint32(data, position + 24);
  32205. siz.XTOsiz = readUint32(data, position + 28);
  32206. siz.YTOsiz = readUint32(data, position + 32);
  32207. var componentsCount = readUint16(data, position + 36);
  32208. siz.Csiz = componentsCount;
  32209. var components = [];
  32210. j = position + 38;
  32211. for (var i = 0; i < componentsCount; i++) {
  32212. var component = {
  32213. precision: (data[j] & 0x7F) + 1,
  32214. isSigned: !!(data[j] & 0x80),
  32215. XRsiz: data[j + 1],
  32216. YRsiz: data[j + 1]
  32217. };
  32218. calculateComponentDimensions(component, siz);
  32219. components.push(component);
  32220. }
  32221. context.SIZ = siz;
  32222. context.components = components;
  32223. calculateTileGrids(context, components);
  32224. context.QCC = [];
  32225. context.COC = [];
  32226. break;
  32227. case 0xFF5C:
  32228. length = readUint16(data, position);
  32229. var qcd = {};
  32230. j = position + 2;
  32231. sqcd = data[j++];
  32232. switch (sqcd & 0x1F) {
  32233. case 0:
  32234. spqcdSize = 8;
  32235. scalarExpounded = true;
  32236. break;
  32237. case 1:
  32238. spqcdSize = 16;
  32239. scalarExpounded = false;
  32240. break;
  32241. case 2:
  32242. spqcdSize = 16;
  32243. scalarExpounded = true;
  32244. break;
  32245. default:
  32246. throw new Error('Invalid SQcd value ' + sqcd);
  32247. }
  32248. qcd.noQuantization = spqcdSize === 8;
  32249. qcd.scalarExpounded = scalarExpounded;
  32250. qcd.guardBits = sqcd >> 5;
  32251. spqcds = [];
  32252. while (j < length + position) {
  32253. var spqcd = {};
  32254. if (spqcdSize === 8) {
  32255. spqcd.epsilon = data[j++] >> 3;
  32256. spqcd.mu = 0;
  32257. } else {
  32258. spqcd.epsilon = data[j] >> 3;
  32259. spqcd.mu = (data[j] & 0x7) << 8 | data[j + 1];
  32260. j += 2;
  32261. }
  32262. spqcds.push(spqcd);
  32263. }
  32264. qcd.SPqcds = spqcds;
  32265. if (context.mainHeader) {
  32266. context.QCD = qcd;
  32267. } else {
  32268. context.currentTile.QCD = qcd;
  32269. context.currentTile.QCC = [];
  32270. }
  32271. break;
  32272. case 0xFF5D:
  32273. length = readUint16(data, position);
  32274. var qcc = {};
  32275. j = position + 2;
  32276. var cqcc;
  32277. if (context.SIZ.Csiz < 257) {
  32278. cqcc = data[j++];
  32279. } else {
  32280. cqcc = readUint16(data, j);
  32281. j += 2;
  32282. }
  32283. sqcd = data[j++];
  32284. switch (sqcd & 0x1F) {
  32285. case 0:
  32286. spqcdSize = 8;
  32287. scalarExpounded = true;
  32288. break;
  32289. case 1:
  32290. spqcdSize = 16;
  32291. scalarExpounded = false;
  32292. break;
  32293. case 2:
  32294. spqcdSize = 16;
  32295. scalarExpounded = true;
  32296. break;
  32297. default:
  32298. throw new Error('Invalid SQcd value ' + sqcd);
  32299. }
  32300. qcc.noQuantization = spqcdSize === 8;
  32301. qcc.scalarExpounded = scalarExpounded;
  32302. qcc.guardBits = sqcd >> 5;
  32303. spqcds = [];
  32304. while (j < length + position) {
  32305. spqcd = {};
  32306. if (spqcdSize === 8) {
  32307. spqcd.epsilon = data[j++] >> 3;
  32308. spqcd.mu = 0;
  32309. } else {
  32310. spqcd.epsilon = data[j] >> 3;
  32311. spqcd.mu = (data[j] & 0x7) << 8 | data[j + 1];
  32312. j += 2;
  32313. }
  32314. spqcds.push(spqcd);
  32315. }
  32316. qcc.SPqcds = spqcds;
  32317. if (context.mainHeader) {
  32318. context.QCC[cqcc] = qcc;
  32319. } else {
  32320. context.currentTile.QCC[cqcc] = qcc;
  32321. }
  32322. break;
  32323. case 0xFF52:
  32324. length = readUint16(data, position);
  32325. var cod = {};
  32326. j = position + 2;
  32327. var scod = data[j++];
  32328. cod.entropyCoderWithCustomPrecincts = !!(scod & 1);
  32329. cod.sopMarkerUsed = !!(scod & 2);
  32330. cod.ephMarkerUsed = !!(scod & 4);
  32331. cod.progressionOrder = data[j++];
  32332. cod.layersCount = readUint16(data, j);
  32333. j += 2;
  32334. cod.multipleComponentTransform = data[j++];
  32335. cod.decompositionLevelsCount = data[j++];
  32336. cod.xcb = (data[j++] & 0xF) + 2;
  32337. cod.ycb = (data[j++] & 0xF) + 2;
  32338. var blockStyle = data[j++];
  32339. cod.selectiveArithmeticCodingBypass = !!(blockStyle & 1);
  32340. cod.resetContextProbabilities = !!(blockStyle & 2);
  32341. cod.terminationOnEachCodingPass = !!(blockStyle & 4);
  32342. cod.verticalyStripe = !!(blockStyle & 8);
  32343. cod.predictableTermination = !!(blockStyle & 16);
  32344. cod.segmentationSymbolUsed = !!(blockStyle & 32);
  32345. cod.reversibleTransformation = data[j++];
  32346. if (cod.entropyCoderWithCustomPrecincts) {
  32347. var precinctsSizes = [];
  32348. while (j < length + position) {
  32349. var precinctsSize = data[j++];
  32350. precinctsSizes.push({
  32351. PPx: precinctsSize & 0xF,
  32352. PPy: precinctsSize >> 4
  32353. });
  32354. }
  32355. cod.precinctsSizes = precinctsSizes;
  32356. }
  32357. var unsupported = [];
  32358. if (cod.selectiveArithmeticCodingBypass) {
  32359. unsupported.push('selectiveArithmeticCodingBypass');
  32360. }
  32361. if (cod.resetContextProbabilities) {
  32362. unsupported.push('resetContextProbabilities');
  32363. }
  32364. if (cod.terminationOnEachCodingPass) {
  32365. unsupported.push('terminationOnEachCodingPass');
  32366. }
  32367. if (cod.verticalyStripe) {
  32368. unsupported.push('verticalyStripe');
  32369. }
  32370. if (cod.predictableTermination) {
  32371. unsupported.push('predictableTermination');
  32372. }
  32373. if (unsupported.length > 0) {
  32374. doNotRecover = true;
  32375. throw new Error('Unsupported COD options (' + unsupported.join(', ') + ')');
  32376. }
  32377. if (context.mainHeader) {
  32378. context.COD = cod;
  32379. } else {
  32380. context.currentTile.COD = cod;
  32381. context.currentTile.COC = [];
  32382. }
  32383. break;
  32384. case 0xFF90:
  32385. length = readUint16(data, position);
  32386. tile = {};
  32387. tile.index = readUint16(data, position + 2);
  32388. tile.length = readUint32(data, position + 4);
  32389. tile.dataEnd = tile.length + position - 2;
  32390. tile.partIndex = data[position + 8];
  32391. tile.partsCount = data[position + 9];
  32392. context.mainHeader = false;
  32393. if (tile.partIndex === 0) {
  32394. tile.COD = context.COD;
  32395. tile.COC = context.COC.slice(0);
  32396. tile.QCD = context.QCD;
  32397. tile.QCC = context.QCC.slice(0);
  32398. }
  32399. context.currentTile = tile;
  32400. break;
  32401. case 0xFF93:
  32402. tile = context.currentTile;
  32403. if (tile.partIndex === 0) {
  32404. initializeTile(context, tile.index);
  32405. buildPackets(context);
  32406. }
  32407. length = tile.dataEnd - position;
  32408. parseTilePackets(context, data, position, length);
  32409. break;
  32410. case 0xFF55:
  32411. case 0xFF57:
  32412. case 0xFF58:
  32413. case 0xFF64:
  32414. length = readUint16(data, position);
  32415. break;
  32416. case 0xFF53:
  32417. throw new Error('Codestream code 0xFF53 (COC) is ' + 'not implemented');
  32418. default:
  32419. throw new Error('Unknown codestream code: ' + code.toString(16));
  32420. }
  32421. position += length;
  32422. }
  32423. } catch (e) {
  32424. if (doNotRecover || this.failOnCorruptedImage) {
  32425. error('JPX Error: ' + e.message);
  32426. } else {
  32427. warn('JPX: Trying to recover from: ' + e.message);
  32428. }
  32429. }
  32430. this.tiles = transformComponents(context);
  32431. this.width = context.SIZ.Xsiz - context.SIZ.XOsiz;
  32432. this.height = context.SIZ.Ysiz - context.SIZ.YOsiz;
  32433. this.componentsCount = context.SIZ.Csiz;
  32434. }
  32435. };
  32436. function calculateComponentDimensions(component, siz) {
  32437. component.x0 = Math.ceil(siz.XOsiz / component.XRsiz);
  32438. component.x1 = Math.ceil(siz.Xsiz / component.XRsiz);
  32439. component.y0 = Math.ceil(siz.YOsiz / component.YRsiz);
  32440. component.y1 = Math.ceil(siz.Ysiz / component.YRsiz);
  32441. component.width = component.x1 - component.x0;
  32442. component.height = component.y1 - component.y0;
  32443. }
  32444. function calculateTileGrids(context, components) {
  32445. var siz = context.SIZ;
  32446. var tile, tiles = [];
  32447. var numXtiles = Math.ceil((siz.Xsiz - siz.XTOsiz) / siz.XTsiz);
  32448. var numYtiles = Math.ceil((siz.Ysiz - siz.YTOsiz) / siz.YTsiz);
  32449. for (var q = 0; q < numYtiles; q++) {
  32450. for (var p = 0; p < numXtiles; p++) {
  32451. tile = {};
  32452. tile.tx0 = Math.max(siz.XTOsiz + p * siz.XTsiz, siz.XOsiz);
  32453. tile.ty0 = Math.max(siz.YTOsiz + q * siz.YTsiz, siz.YOsiz);
  32454. tile.tx1 = Math.min(siz.XTOsiz + (p + 1) * siz.XTsiz, siz.Xsiz);
  32455. tile.ty1 = Math.min(siz.YTOsiz + (q + 1) * siz.YTsiz, siz.Ysiz);
  32456. tile.width = tile.tx1 - tile.tx0;
  32457. tile.height = tile.ty1 - tile.ty0;
  32458. tile.components = [];
  32459. tiles.push(tile);
  32460. }
  32461. }
  32462. context.tiles = tiles;
  32463. var componentsCount = siz.Csiz;
  32464. for (var i = 0, ii = componentsCount; i < ii; i++) {
  32465. var component = components[i];
  32466. for (var j = 0, jj = tiles.length; j < jj; j++) {
  32467. var tileComponent = {};
  32468. tile = tiles[j];
  32469. tileComponent.tcx0 = Math.ceil(tile.tx0 / component.XRsiz);
  32470. tileComponent.tcy0 = Math.ceil(tile.ty0 / component.YRsiz);
  32471. tileComponent.tcx1 = Math.ceil(tile.tx1 / component.XRsiz);
  32472. tileComponent.tcy1 = Math.ceil(tile.ty1 / component.YRsiz);
  32473. tileComponent.width = tileComponent.tcx1 - tileComponent.tcx0;
  32474. tileComponent.height = tileComponent.tcy1 - tileComponent.tcy0;
  32475. tile.components[i] = tileComponent;
  32476. }
  32477. }
  32478. }
  32479. function getBlocksDimensions(context, component, r) {
  32480. var codOrCoc = component.codingStyleParameters;
  32481. var result = {};
  32482. if (!codOrCoc.entropyCoderWithCustomPrecincts) {
  32483. result.PPx = 15;
  32484. result.PPy = 15;
  32485. } else {
  32486. result.PPx = codOrCoc.precinctsSizes[r].PPx;
  32487. result.PPy = codOrCoc.precinctsSizes[r].PPy;
  32488. }
  32489. result.xcb_ = r > 0 ? Math.min(codOrCoc.xcb, result.PPx - 1) : Math.min(codOrCoc.xcb, result.PPx);
  32490. result.ycb_ = r > 0 ? Math.min(codOrCoc.ycb, result.PPy - 1) : Math.min(codOrCoc.ycb, result.PPy);
  32491. return result;
  32492. }
  32493. function buildPrecincts(context, resolution, dimensions) {
  32494. var precinctWidth = 1 << dimensions.PPx;
  32495. var precinctHeight = 1 << dimensions.PPy;
  32496. var isZeroRes = resolution.resLevel === 0;
  32497. var precinctWidthInSubband = 1 << dimensions.PPx + (isZeroRes ? 0 : -1);
  32498. var precinctHeightInSubband = 1 << dimensions.PPy + (isZeroRes ? 0 : -1);
  32499. var numprecinctswide = resolution.trx1 > resolution.trx0 ? Math.ceil(resolution.trx1 / precinctWidth) - Math.floor(resolution.trx0 / precinctWidth) : 0;
  32500. var numprecinctshigh = resolution.try1 > resolution.try0 ? Math.ceil(resolution.try1 / precinctHeight) - Math.floor(resolution.try0 / precinctHeight) : 0;
  32501. var numprecincts = numprecinctswide * numprecinctshigh;
  32502. resolution.precinctParameters = {
  32503. precinctWidth: precinctWidth,
  32504. precinctHeight: precinctHeight,
  32505. numprecinctswide: numprecinctswide,
  32506. numprecinctshigh: numprecinctshigh,
  32507. numprecincts: numprecincts,
  32508. precinctWidthInSubband: precinctWidthInSubband,
  32509. precinctHeightInSubband: precinctHeightInSubband
  32510. };
  32511. }
  32512. function buildCodeblocks(context, subband, dimensions) {
  32513. var xcb_ = dimensions.xcb_;
  32514. var ycb_ = dimensions.ycb_;
  32515. var codeblockWidth = 1 << xcb_;
  32516. var codeblockHeight = 1 << ycb_;
  32517. var cbx0 = subband.tbx0 >> xcb_;
  32518. var cby0 = subband.tby0 >> ycb_;
  32519. var cbx1 = subband.tbx1 + codeblockWidth - 1 >> xcb_;
  32520. var cby1 = subband.tby1 + codeblockHeight - 1 >> ycb_;
  32521. var precinctParameters = subband.resolution.precinctParameters;
  32522. var codeblocks = [];
  32523. var precincts = [];
  32524. var i, j, codeblock, precinctNumber;
  32525. for (j = cby0; j < cby1; j++) {
  32526. for (i = cbx0; i < cbx1; i++) {
  32527. codeblock = {
  32528. cbx: i,
  32529. cby: j,
  32530. tbx0: codeblockWidth * i,
  32531. tby0: codeblockHeight * j,
  32532. tbx1: codeblockWidth * (i + 1),
  32533. tby1: codeblockHeight * (j + 1)
  32534. };
  32535. codeblock.tbx0_ = Math.max(subband.tbx0, codeblock.tbx0);
  32536. codeblock.tby0_ = Math.max(subband.tby0, codeblock.tby0);
  32537. codeblock.tbx1_ = Math.min(subband.tbx1, codeblock.tbx1);
  32538. codeblock.tby1_ = Math.min(subband.tby1, codeblock.tby1);
  32539. var pi = Math.floor((codeblock.tbx0_ - subband.tbx0) / precinctParameters.precinctWidthInSubband);
  32540. var pj = Math.floor((codeblock.tby0_ - subband.tby0) / precinctParameters.precinctHeightInSubband);
  32541. precinctNumber = pi + pj * precinctParameters.numprecinctswide;
  32542. codeblock.precinctNumber = precinctNumber;
  32543. codeblock.subbandType = subband.type;
  32544. codeblock.Lblock = 3;
  32545. if (codeblock.tbx1_ <= codeblock.tbx0_ || codeblock.tby1_ <= codeblock.tby0_) {
  32546. continue;
  32547. }
  32548. codeblocks.push(codeblock);
  32549. var precinct = precincts[precinctNumber];
  32550. if (precinct !== undefined) {
  32551. if (i < precinct.cbxMin) {
  32552. precinct.cbxMin = i;
  32553. } else if (i > precinct.cbxMax) {
  32554. precinct.cbxMax = i;
  32555. }
  32556. if (j < precinct.cbyMin) {
  32557. precinct.cbxMin = j;
  32558. } else if (j > precinct.cbyMax) {
  32559. precinct.cbyMax = j;
  32560. }
  32561. } else {
  32562. precincts[precinctNumber] = precinct = {
  32563. cbxMin: i,
  32564. cbyMin: j,
  32565. cbxMax: i,
  32566. cbyMax: j
  32567. };
  32568. }
  32569. codeblock.precinct = precinct;
  32570. }
  32571. }
  32572. subband.codeblockParameters = {
  32573. codeblockWidth: xcb_,
  32574. codeblockHeight: ycb_,
  32575. numcodeblockwide: cbx1 - cbx0 + 1,
  32576. numcodeblockhigh: cby1 - cby0 + 1
  32577. };
  32578. subband.codeblocks = codeblocks;
  32579. subband.precincts = precincts;
  32580. }
  32581. function createPacket(resolution, precinctNumber, layerNumber) {
  32582. var precinctCodeblocks = [];
  32583. var subbands = resolution.subbands;
  32584. for (var i = 0, ii = subbands.length; i < ii; i++) {
  32585. var subband = subbands[i];
  32586. var codeblocks = subband.codeblocks;
  32587. for (var j = 0, jj = codeblocks.length; j < jj; j++) {
  32588. var codeblock = codeblocks[j];
  32589. if (codeblock.precinctNumber !== precinctNumber) {
  32590. continue;
  32591. }
  32592. precinctCodeblocks.push(codeblock);
  32593. }
  32594. }
  32595. return {
  32596. layerNumber: layerNumber,
  32597. codeblocks: precinctCodeblocks
  32598. };
  32599. }
  32600. function LayerResolutionComponentPositionIterator(context) {
  32601. var siz = context.SIZ;
  32602. var tileIndex = context.currentTile.index;
  32603. var tile = context.tiles[tileIndex];
  32604. var layersCount = tile.codingStyleDefaultParameters.layersCount;
  32605. var componentsCount = siz.Csiz;
  32606. var maxDecompositionLevelsCount = 0;
  32607. for (var q = 0; q < componentsCount; q++) {
  32608. maxDecompositionLevelsCount = Math.max(maxDecompositionLevelsCount, tile.components[q].codingStyleParameters.decompositionLevelsCount);
  32609. }
  32610. var l = 0, r = 0, i = 0, k = 0;
  32611. this.nextPacket = function JpxImage_nextPacket() {
  32612. for (; l < layersCount; l++) {
  32613. for (; r <= maxDecompositionLevelsCount; r++) {
  32614. for (; i < componentsCount; i++) {
  32615. var component = tile.components[i];
  32616. if (r > component.codingStyleParameters.decompositionLevelsCount) {
  32617. continue;
  32618. }
  32619. var resolution = component.resolutions[r];
  32620. var numprecincts = resolution.precinctParameters.numprecincts;
  32621. for (; k < numprecincts;) {
  32622. var packet = createPacket(resolution, k, l);
  32623. k++;
  32624. return packet;
  32625. }
  32626. k = 0;
  32627. }
  32628. i = 0;
  32629. }
  32630. r = 0;
  32631. }
  32632. error('JPX Error: Out of packets');
  32633. };
  32634. }
  32635. function ResolutionLayerComponentPositionIterator(context) {
  32636. var siz = context.SIZ;
  32637. var tileIndex = context.currentTile.index;
  32638. var tile = context.tiles[tileIndex];
  32639. var layersCount = tile.codingStyleDefaultParameters.layersCount;
  32640. var componentsCount = siz.Csiz;
  32641. var maxDecompositionLevelsCount = 0;
  32642. for (var q = 0; q < componentsCount; q++) {
  32643. maxDecompositionLevelsCount = Math.max(maxDecompositionLevelsCount, tile.components[q].codingStyleParameters.decompositionLevelsCount);
  32644. }
  32645. var r = 0, l = 0, i = 0, k = 0;
  32646. this.nextPacket = function JpxImage_nextPacket() {
  32647. for (; r <= maxDecompositionLevelsCount; r++) {
  32648. for (; l < layersCount; l++) {
  32649. for (; i < componentsCount; i++) {
  32650. var component = tile.components[i];
  32651. if (r > component.codingStyleParameters.decompositionLevelsCount) {
  32652. continue;
  32653. }
  32654. var resolution = component.resolutions[r];
  32655. var numprecincts = resolution.precinctParameters.numprecincts;
  32656. for (; k < numprecincts;) {
  32657. var packet = createPacket(resolution, k, l);
  32658. k++;
  32659. return packet;
  32660. }
  32661. k = 0;
  32662. }
  32663. i = 0;
  32664. }
  32665. l = 0;
  32666. }
  32667. error('JPX Error: Out of packets');
  32668. };
  32669. }
  32670. function ResolutionPositionComponentLayerIterator(context) {
  32671. var siz = context.SIZ;
  32672. var tileIndex = context.currentTile.index;
  32673. var tile = context.tiles[tileIndex];
  32674. var layersCount = tile.codingStyleDefaultParameters.layersCount;
  32675. var componentsCount = siz.Csiz;
  32676. var l, r, c, p;
  32677. var maxDecompositionLevelsCount = 0;
  32678. for (c = 0; c < componentsCount; c++) {
  32679. var component = tile.components[c];
  32680. maxDecompositionLevelsCount = Math.max(maxDecompositionLevelsCount, component.codingStyleParameters.decompositionLevelsCount);
  32681. }
  32682. var maxNumPrecinctsInLevel = new Int32Array(maxDecompositionLevelsCount + 1);
  32683. for (r = 0; r <= maxDecompositionLevelsCount; ++r) {
  32684. var maxNumPrecincts = 0;
  32685. for (c = 0; c < componentsCount; ++c) {
  32686. var resolutions = tile.components[c].resolutions;
  32687. if (r < resolutions.length) {
  32688. maxNumPrecincts = Math.max(maxNumPrecincts, resolutions[r].precinctParameters.numprecincts);
  32689. }
  32690. }
  32691. maxNumPrecinctsInLevel[r] = maxNumPrecincts;
  32692. }
  32693. l = 0;
  32694. r = 0;
  32695. c = 0;
  32696. p = 0;
  32697. this.nextPacket = function JpxImage_nextPacket() {
  32698. for (; r <= maxDecompositionLevelsCount; r++) {
  32699. for (; p < maxNumPrecinctsInLevel[r]; p++) {
  32700. for (; c < componentsCount; c++) {
  32701. var component = tile.components[c];
  32702. if (r > component.codingStyleParameters.decompositionLevelsCount) {
  32703. continue;
  32704. }
  32705. var resolution = component.resolutions[r];
  32706. var numprecincts = resolution.precinctParameters.numprecincts;
  32707. if (p >= numprecincts) {
  32708. continue;
  32709. }
  32710. for (; l < layersCount;) {
  32711. var packet = createPacket(resolution, p, l);
  32712. l++;
  32713. return packet;
  32714. }
  32715. l = 0;
  32716. }
  32717. c = 0;
  32718. }
  32719. p = 0;
  32720. }
  32721. error('JPX Error: Out of packets');
  32722. };
  32723. }
  32724. function PositionComponentResolutionLayerIterator(context) {
  32725. var siz = context.SIZ;
  32726. var tileIndex = context.currentTile.index;
  32727. var tile = context.tiles[tileIndex];
  32728. var layersCount = tile.codingStyleDefaultParameters.layersCount;
  32729. var componentsCount = siz.Csiz;
  32730. var precinctsSizes = getPrecinctSizesInImageScale(tile);
  32731. var precinctsIterationSizes = precinctsSizes;
  32732. var l = 0, r = 0, c = 0, px = 0, py = 0;
  32733. this.nextPacket = function JpxImage_nextPacket() {
  32734. for (; py < precinctsIterationSizes.maxNumHigh; py++) {
  32735. for (; px < precinctsIterationSizes.maxNumWide; px++) {
  32736. for (; c < componentsCount; c++) {
  32737. var component = tile.components[c];
  32738. var decompositionLevelsCount = component.codingStyleParameters.decompositionLevelsCount;
  32739. for (; r <= decompositionLevelsCount; r++) {
  32740. var resolution = component.resolutions[r];
  32741. var sizeInImageScale = precinctsSizes.components[c].resolutions[r];
  32742. var k = getPrecinctIndexIfExist(px, py, sizeInImageScale, precinctsIterationSizes, resolution);
  32743. if (k === null) {
  32744. continue;
  32745. }
  32746. for (; l < layersCount;) {
  32747. var packet = createPacket(resolution, k, l);
  32748. l++;
  32749. return packet;
  32750. }
  32751. l = 0;
  32752. }
  32753. r = 0;
  32754. }
  32755. c = 0;
  32756. }
  32757. px = 0;
  32758. }
  32759. error('JPX Error: Out of packets');
  32760. };
  32761. }
  32762. function ComponentPositionResolutionLayerIterator(context) {
  32763. var siz = context.SIZ;
  32764. var tileIndex = context.currentTile.index;
  32765. var tile = context.tiles[tileIndex];
  32766. var layersCount = tile.codingStyleDefaultParameters.layersCount;
  32767. var componentsCount = siz.Csiz;
  32768. var precinctsSizes = getPrecinctSizesInImageScale(tile);
  32769. var l = 0, r = 0, c = 0, px = 0, py = 0;
  32770. this.nextPacket = function JpxImage_nextPacket() {
  32771. for (; c < componentsCount; ++c) {
  32772. var component = tile.components[c];
  32773. var precinctsIterationSizes = precinctsSizes.components[c];
  32774. var decompositionLevelsCount = component.codingStyleParameters.decompositionLevelsCount;
  32775. for (; py < precinctsIterationSizes.maxNumHigh; py++) {
  32776. for (; px < precinctsIterationSizes.maxNumWide; px++) {
  32777. for (; r <= decompositionLevelsCount; r++) {
  32778. var resolution = component.resolutions[r];
  32779. var sizeInImageScale = precinctsIterationSizes.resolutions[r];
  32780. var k = getPrecinctIndexIfExist(px, py, sizeInImageScale, precinctsIterationSizes, resolution);
  32781. if (k === null) {
  32782. continue;
  32783. }
  32784. for (; l < layersCount;) {
  32785. var packet = createPacket(resolution, k, l);
  32786. l++;
  32787. return packet;
  32788. }
  32789. l = 0;
  32790. }
  32791. r = 0;
  32792. }
  32793. px = 0;
  32794. }
  32795. py = 0;
  32796. }
  32797. error('JPX Error: Out of packets');
  32798. };
  32799. }
  32800. function getPrecinctIndexIfExist(pxIndex, pyIndex, sizeInImageScale, precinctIterationSizes, resolution) {
  32801. var posX = pxIndex * precinctIterationSizes.minWidth;
  32802. var posY = pyIndex * precinctIterationSizes.minHeight;
  32803. if (posX % sizeInImageScale.width !== 0 || posY % sizeInImageScale.height !== 0) {
  32804. return null;
  32805. }
  32806. var startPrecinctRowIndex = posY / sizeInImageScale.width * resolution.precinctParameters.numprecinctswide;
  32807. return posX / sizeInImageScale.height + startPrecinctRowIndex;
  32808. }
  32809. function getPrecinctSizesInImageScale(tile) {
  32810. var componentsCount = tile.components.length;
  32811. var minWidth = Number.MAX_VALUE;
  32812. var minHeight = Number.MAX_VALUE;
  32813. var maxNumWide = 0;
  32814. var maxNumHigh = 0;
  32815. var sizePerComponent = new Array(componentsCount);
  32816. for (var c = 0; c < componentsCount; c++) {
  32817. var component = tile.components[c];
  32818. var decompositionLevelsCount = component.codingStyleParameters.decompositionLevelsCount;
  32819. var sizePerResolution = new Array(decompositionLevelsCount + 1);
  32820. var minWidthCurrentComponent = Number.MAX_VALUE;
  32821. var minHeightCurrentComponent = Number.MAX_VALUE;
  32822. var maxNumWideCurrentComponent = 0;
  32823. var maxNumHighCurrentComponent = 0;
  32824. var scale = 1;
  32825. for (var r = decompositionLevelsCount; r >= 0; --r) {
  32826. var resolution = component.resolutions[r];
  32827. var widthCurrentResolution = scale * resolution.precinctParameters.precinctWidth;
  32828. var heightCurrentResolution = scale * resolution.precinctParameters.precinctHeight;
  32829. minWidthCurrentComponent = Math.min(minWidthCurrentComponent, widthCurrentResolution);
  32830. minHeightCurrentComponent = Math.min(minHeightCurrentComponent, heightCurrentResolution);
  32831. maxNumWideCurrentComponent = Math.max(maxNumWideCurrentComponent, resolution.precinctParameters.numprecinctswide);
  32832. maxNumHighCurrentComponent = Math.max(maxNumHighCurrentComponent, resolution.precinctParameters.numprecinctshigh);
  32833. sizePerResolution[r] = {
  32834. width: widthCurrentResolution,
  32835. height: heightCurrentResolution
  32836. };
  32837. scale <<= 1;
  32838. }
  32839. minWidth = Math.min(minWidth, minWidthCurrentComponent);
  32840. minHeight = Math.min(minHeight, minHeightCurrentComponent);
  32841. maxNumWide = Math.max(maxNumWide, maxNumWideCurrentComponent);
  32842. maxNumHigh = Math.max(maxNumHigh, maxNumHighCurrentComponent);
  32843. sizePerComponent[c] = {
  32844. resolutions: sizePerResolution,
  32845. minWidth: minWidthCurrentComponent,
  32846. minHeight: minHeightCurrentComponent,
  32847. maxNumWide: maxNumWideCurrentComponent,
  32848. maxNumHigh: maxNumHighCurrentComponent
  32849. };
  32850. }
  32851. return {
  32852. components: sizePerComponent,
  32853. minWidth: minWidth,
  32854. minHeight: minHeight,
  32855. maxNumWide: maxNumWide,
  32856. maxNumHigh: maxNumHigh
  32857. };
  32858. }
  32859. function buildPackets(context) {
  32860. var siz = context.SIZ;
  32861. var tileIndex = context.currentTile.index;
  32862. var tile = context.tiles[tileIndex];
  32863. var componentsCount = siz.Csiz;
  32864. for (var c = 0; c < componentsCount; c++) {
  32865. var component = tile.components[c];
  32866. var decompositionLevelsCount = component.codingStyleParameters.decompositionLevelsCount;
  32867. var resolutions = [];
  32868. var subbands = [];
  32869. for (var r = 0; r <= decompositionLevelsCount; r++) {
  32870. var blocksDimensions = getBlocksDimensions(context, component, r);
  32871. var resolution = {};
  32872. var scale = 1 << decompositionLevelsCount - r;
  32873. resolution.trx0 = Math.ceil(component.tcx0 / scale);
  32874. resolution.try0 = Math.ceil(component.tcy0 / scale);
  32875. resolution.trx1 = Math.ceil(component.tcx1 / scale);
  32876. resolution.try1 = Math.ceil(component.tcy1 / scale);
  32877. resolution.resLevel = r;
  32878. buildPrecincts(context, resolution, blocksDimensions);
  32879. resolutions.push(resolution);
  32880. var subband;
  32881. if (r === 0) {
  32882. subband = {};
  32883. subband.type = 'LL';
  32884. subband.tbx0 = Math.ceil(component.tcx0 / scale);
  32885. subband.tby0 = Math.ceil(component.tcy0 / scale);
  32886. subband.tbx1 = Math.ceil(component.tcx1 / scale);
  32887. subband.tby1 = Math.ceil(component.tcy1 / scale);
  32888. subband.resolution = resolution;
  32889. buildCodeblocks(context, subband, blocksDimensions);
  32890. subbands.push(subband);
  32891. resolution.subbands = [subband];
  32892. } else {
  32893. var bscale = 1 << decompositionLevelsCount - r + 1;
  32894. var resolutionSubbands = [];
  32895. subband = {};
  32896. subband.type = 'HL';
  32897. subband.tbx0 = Math.ceil(component.tcx0 / bscale - 0.5);
  32898. subband.tby0 = Math.ceil(component.tcy0 / bscale);
  32899. subband.tbx1 = Math.ceil(component.tcx1 / bscale - 0.5);
  32900. subband.tby1 = Math.ceil(component.tcy1 / bscale);
  32901. subband.resolution = resolution;
  32902. buildCodeblocks(context, subband, blocksDimensions);
  32903. subbands.push(subband);
  32904. resolutionSubbands.push(subband);
  32905. subband = {};
  32906. subband.type = 'LH';
  32907. subband.tbx0 = Math.ceil(component.tcx0 / bscale);
  32908. subband.tby0 = Math.ceil(component.tcy0 / bscale - 0.5);
  32909. subband.tbx1 = Math.ceil(component.tcx1 / bscale);
  32910. subband.tby1 = Math.ceil(component.tcy1 / bscale - 0.5);
  32911. subband.resolution = resolution;
  32912. buildCodeblocks(context, subband, blocksDimensions);
  32913. subbands.push(subband);
  32914. resolutionSubbands.push(subband);
  32915. subband = {};
  32916. subband.type = 'HH';
  32917. subband.tbx0 = Math.ceil(component.tcx0 / bscale - 0.5);
  32918. subband.tby0 = Math.ceil(component.tcy0 / bscale - 0.5);
  32919. subband.tbx1 = Math.ceil(component.tcx1 / bscale - 0.5);
  32920. subband.tby1 = Math.ceil(component.tcy1 / bscale - 0.5);
  32921. subband.resolution = resolution;
  32922. buildCodeblocks(context, subband, blocksDimensions);
  32923. subbands.push(subband);
  32924. resolutionSubbands.push(subband);
  32925. resolution.subbands = resolutionSubbands;
  32926. }
  32927. }
  32928. component.resolutions = resolutions;
  32929. component.subbands = subbands;
  32930. }
  32931. var progressionOrder = tile.codingStyleDefaultParameters.progressionOrder;
  32932. switch (progressionOrder) {
  32933. case 0:
  32934. tile.packetsIterator = new LayerResolutionComponentPositionIterator(context);
  32935. break;
  32936. case 1:
  32937. tile.packetsIterator = new ResolutionLayerComponentPositionIterator(context);
  32938. break;
  32939. case 2:
  32940. tile.packetsIterator = new ResolutionPositionComponentLayerIterator(context);
  32941. break;
  32942. case 3:
  32943. tile.packetsIterator = new PositionComponentResolutionLayerIterator(context);
  32944. break;
  32945. case 4:
  32946. tile.packetsIterator = new ComponentPositionResolutionLayerIterator(context);
  32947. break;
  32948. default:
  32949. error('JPX Error: Unsupported progression order ' + progressionOrder);
  32950. }
  32951. }
  32952. function parseTilePackets(context, data, offset, dataLength) {
  32953. var position = 0;
  32954. var buffer, bufferSize = 0, skipNextBit = false;
  32955. function readBits(count) {
  32956. while (bufferSize < count) {
  32957. var b = data[offset + position];
  32958. position++;
  32959. if (skipNextBit) {
  32960. buffer = buffer << 7 | b;
  32961. bufferSize += 7;
  32962. skipNextBit = false;
  32963. } else {
  32964. buffer = buffer << 8 | b;
  32965. bufferSize += 8;
  32966. }
  32967. if (b === 0xFF) {
  32968. skipNextBit = true;
  32969. }
  32970. }
  32971. bufferSize -= count;
  32972. return buffer >>> bufferSize & (1 << count) - 1;
  32973. }
  32974. function skipMarkerIfEqual(value) {
  32975. if (data[offset + position - 1] === 0xFF && data[offset + position] === value) {
  32976. skipBytes(1);
  32977. return true;
  32978. } else if (data[offset + position] === 0xFF && data[offset + position + 1] === value) {
  32979. skipBytes(2);
  32980. return true;
  32981. }
  32982. return false;
  32983. }
  32984. function skipBytes(count) {
  32985. position += count;
  32986. }
  32987. function alignToByte() {
  32988. bufferSize = 0;
  32989. if (skipNextBit) {
  32990. position++;
  32991. skipNextBit = false;
  32992. }
  32993. }
  32994. function readCodingpasses() {
  32995. if (readBits(1) === 0) {
  32996. return 1;
  32997. }
  32998. if (readBits(1) === 0) {
  32999. return 2;
  33000. }
  33001. var value = readBits(2);
  33002. if (value < 3) {
  33003. return value + 3;
  33004. }
  33005. value = readBits(5);
  33006. if (value < 31) {
  33007. return value + 6;
  33008. }
  33009. value = readBits(7);
  33010. return value + 37;
  33011. }
  33012. var tileIndex = context.currentTile.index;
  33013. var tile = context.tiles[tileIndex];
  33014. var sopMarkerUsed = context.COD.sopMarkerUsed;
  33015. var ephMarkerUsed = context.COD.ephMarkerUsed;
  33016. var packetsIterator = tile.packetsIterator;
  33017. while (position < dataLength) {
  33018. alignToByte();
  33019. if (sopMarkerUsed && skipMarkerIfEqual(0x91)) {
  33020. skipBytes(4);
  33021. }
  33022. var packet = packetsIterator.nextPacket();
  33023. if (!readBits(1)) {
  33024. continue;
  33025. }
  33026. var layerNumber = packet.layerNumber;
  33027. var queue = [], codeblock;
  33028. for (var i = 0, ii = packet.codeblocks.length; i < ii; i++) {
  33029. codeblock = packet.codeblocks[i];
  33030. var precinct = codeblock.precinct;
  33031. var codeblockColumn = codeblock.cbx - precinct.cbxMin;
  33032. var codeblockRow = codeblock.cby - precinct.cbyMin;
  33033. var codeblockIncluded = false;
  33034. var firstTimeInclusion = false;
  33035. var valueReady;
  33036. if (codeblock['included'] !== undefined) {
  33037. codeblockIncluded = !!readBits(1);
  33038. } else {
  33039. precinct = codeblock.precinct;
  33040. var inclusionTree, zeroBitPlanesTree;
  33041. if (precinct['inclusionTree'] !== undefined) {
  33042. inclusionTree = precinct.inclusionTree;
  33043. } else {
  33044. var width = precinct.cbxMax - precinct.cbxMin + 1;
  33045. var height = precinct.cbyMax - precinct.cbyMin + 1;
  33046. inclusionTree = new InclusionTree(width, height, layerNumber);
  33047. zeroBitPlanesTree = new TagTree(width, height);
  33048. precinct.inclusionTree = inclusionTree;
  33049. precinct.zeroBitPlanesTree = zeroBitPlanesTree;
  33050. }
  33051. if (inclusionTree.reset(codeblockColumn, codeblockRow, layerNumber)) {
  33052. while (true) {
  33053. if (readBits(1)) {
  33054. valueReady = !inclusionTree.nextLevel();
  33055. if (valueReady) {
  33056. codeblock.included = true;
  33057. codeblockIncluded = firstTimeInclusion = true;
  33058. break;
  33059. }
  33060. } else {
  33061. inclusionTree.incrementValue(layerNumber);
  33062. break;
  33063. }
  33064. }
  33065. }
  33066. }
  33067. if (!codeblockIncluded) {
  33068. continue;
  33069. }
  33070. if (firstTimeInclusion) {
  33071. zeroBitPlanesTree = precinct.zeroBitPlanesTree;
  33072. zeroBitPlanesTree.reset(codeblockColumn, codeblockRow);
  33073. while (true) {
  33074. if (readBits(1)) {
  33075. valueReady = !zeroBitPlanesTree.nextLevel();
  33076. if (valueReady) {
  33077. break;
  33078. }
  33079. } else {
  33080. zeroBitPlanesTree.incrementValue();
  33081. }
  33082. }
  33083. codeblock.zeroBitPlanes = zeroBitPlanesTree.value;
  33084. }
  33085. var codingpasses = readCodingpasses();
  33086. while (readBits(1)) {
  33087. codeblock.Lblock++;
  33088. }
  33089. var codingpassesLog2 = log2(codingpasses);
  33090. var bits = (codingpasses < 1 << codingpassesLog2 ? codingpassesLog2 - 1 : codingpassesLog2) + codeblock.Lblock;
  33091. var codedDataLength = readBits(bits);
  33092. queue.push({
  33093. codeblock: codeblock,
  33094. codingpasses: codingpasses,
  33095. dataLength: codedDataLength
  33096. });
  33097. }
  33098. alignToByte();
  33099. if (ephMarkerUsed) {
  33100. skipMarkerIfEqual(0x92);
  33101. }
  33102. while (queue.length > 0) {
  33103. var packetItem = queue.shift();
  33104. codeblock = packetItem.codeblock;
  33105. if (codeblock['data'] === undefined) {
  33106. codeblock.data = [];
  33107. }
  33108. codeblock.data.push({
  33109. data: data,
  33110. start: offset + position,
  33111. end: offset + position + packetItem.dataLength,
  33112. codingpasses: packetItem.codingpasses
  33113. });
  33114. position += packetItem.dataLength;
  33115. }
  33116. }
  33117. return position;
  33118. }
  33119. function copyCoefficients(coefficients, levelWidth, levelHeight, subband, delta, mb, reversible, segmentationSymbolUsed) {
  33120. var x0 = subband.tbx0;
  33121. var y0 = subband.tby0;
  33122. var width = subband.tbx1 - subband.tbx0;
  33123. var codeblocks = subband.codeblocks;
  33124. var right = subband.type.charAt(0) === 'H' ? 1 : 0;
  33125. var bottom = subband.type.charAt(1) === 'H' ? levelWidth : 0;
  33126. for (var i = 0, ii = codeblocks.length; i < ii; ++i) {
  33127. var codeblock = codeblocks[i];
  33128. var blockWidth = codeblock.tbx1_ - codeblock.tbx0_;
  33129. var blockHeight = codeblock.tby1_ - codeblock.tby0_;
  33130. if (blockWidth === 0 || blockHeight === 0) {
  33131. continue;
  33132. }
  33133. if (codeblock['data'] === undefined) {
  33134. continue;
  33135. }
  33136. var bitModel, currentCodingpassType;
  33137. bitModel = new BitModel(blockWidth, blockHeight, codeblock.subbandType, codeblock.zeroBitPlanes, mb);
  33138. currentCodingpassType = 2;
  33139. var data = codeblock.data, totalLength = 0, codingpasses = 0;
  33140. var j, jj, dataItem;
  33141. for (j = 0, jj = data.length; j < jj; j++) {
  33142. dataItem = data[j];
  33143. totalLength += dataItem.end - dataItem.start;
  33144. codingpasses += dataItem.codingpasses;
  33145. }
  33146. var encodedData = new Uint8Array(totalLength);
  33147. var position = 0;
  33148. for (j = 0, jj = data.length; j < jj; j++) {
  33149. dataItem = data[j];
  33150. var chunk = dataItem.data.subarray(dataItem.start, dataItem.end);
  33151. encodedData.set(chunk, position);
  33152. position += chunk.length;
  33153. }
  33154. var decoder = new ArithmeticDecoder(encodedData, 0, totalLength);
  33155. bitModel.setDecoder(decoder);
  33156. for (j = 0; j < codingpasses; j++) {
  33157. switch (currentCodingpassType) {
  33158. case 0:
  33159. bitModel.runSignificancePropagationPass();
  33160. break;
  33161. case 1:
  33162. bitModel.runMagnitudeRefinementPass();
  33163. break;
  33164. case 2:
  33165. bitModel.runCleanupPass();
  33166. if (segmentationSymbolUsed) {
  33167. bitModel.checkSegmentationSymbol();
  33168. }
  33169. break;
  33170. }
  33171. currentCodingpassType = (currentCodingpassType + 1) % 3;
  33172. }
  33173. var offset = codeblock.tbx0_ - x0 + (codeblock.tby0_ - y0) * width;
  33174. var sign = bitModel.coefficentsSign;
  33175. var magnitude = bitModel.coefficentsMagnitude;
  33176. var bitsDecoded = bitModel.bitsDecoded;
  33177. var magnitudeCorrection = reversible ? 0 : 0.5;
  33178. var k, n, nb;
  33179. position = 0;
  33180. var interleave = subband.type !== 'LL';
  33181. for (j = 0; j < blockHeight; j++) {
  33182. var row = offset / width | 0;
  33183. var levelOffset = 2 * row * (levelWidth - width) + right + bottom;
  33184. for (k = 0; k < blockWidth; k++) {
  33185. n = magnitude[position];
  33186. if (n !== 0) {
  33187. n = (n + magnitudeCorrection) * delta;
  33188. if (sign[position] !== 0) {
  33189. n = -n;
  33190. }
  33191. nb = bitsDecoded[position];
  33192. var pos = interleave ? levelOffset + (offset << 1) : offset;
  33193. if (reversible && nb >= mb) {
  33194. coefficients[pos] = n;
  33195. } else {
  33196. coefficients[pos] = n * (1 << mb - nb);
  33197. }
  33198. }
  33199. offset++;
  33200. position++;
  33201. }
  33202. offset += width - blockWidth;
  33203. }
  33204. }
  33205. }
  33206. function transformTile(context, tile, c) {
  33207. var component = tile.components[c];
  33208. var codingStyleParameters = component.codingStyleParameters;
  33209. var quantizationParameters = component.quantizationParameters;
  33210. var decompositionLevelsCount = codingStyleParameters.decompositionLevelsCount;
  33211. var spqcds = quantizationParameters.SPqcds;
  33212. var scalarExpounded = quantizationParameters.scalarExpounded;
  33213. var guardBits = quantizationParameters.guardBits;
  33214. var segmentationSymbolUsed = codingStyleParameters.segmentationSymbolUsed;
  33215. var precision = context.components[c].precision;
  33216. var reversible = codingStyleParameters.reversibleTransformation;
  33217. var transform = reversible ? new ReversibleTransform() : new IrreversibleTransform();
  33218. var subbandCoefficients = [];
  33219. var b = 0;
  33220. for (var i = 0; i <= decompositionLevelsCount; i++) {
  33221. var resolution = component.resolutions[i];
  33222. var width = resolution.trx1 - resolution.trx0;
  33223. var height = resolution.try1 - resolution.try0;
  33224. var coefficients = new Float32Array(width * height);
  33225. for (var j = 0, jj = resolution.subbands.length; j < jj; j++) {
  33226. var mu, epsilon;
  33227. if (!scalarExpounded) {
  33228. mu = spqcds[0].mu;
  33229. epsilon = spqcds[0].epsilon + (i > 0 ? 1 - i : 0);
  33230. } else {
  33231. mu = spqcds[b].mu;
  33232. epsilon = spqcds[b].epsilon;
  33233. b++;
  33234. }
  33235. var subband = resolution.subbands[j];
  33236. var gainLog2 = SubbandsGainLog2[subband.type];
  33237. var delta = reversible ? 1 : Math.pow(2, precision + gainLog2 - epsilon) * (1 + mu / 2048);
  33238. var mb = guardBits + epsilon - 1;
  33239. copyCoefficients(coefficients, width, height, subband, delta, mb, reversible, segmentationSymbolUsed);
  33240. }
  33241. subbandCoefficients.push({
  33242. width: width,
  33243. height: height,
  33244. items: coefficients
  33245. });
  33246. }
  33247. var result = transform.calculate(subbandCoefficients, component.tcx0, component.tcy0);
  33248. return {
  33249. left: component.tcx0,
  33250. top: component.tcy0,
  33251. width: result.width,
  33252. height: result.height,
  33253. items: result.items
  33254. };
  33255. }
  33256. function transformComponents(context) {
  33257. var siz = context.SIZ;
  33258. var components = context.components;
  33259. var componentsCount = siz.Csiz;
  33260. var resultImages = [];
  33261. for (var i = 0, ii = context.tiles.length; i < ii; i++) {
  33262. var tile = context.tiles[i];
  33263. var transformedTiles = [];
  33264. var c;
  33265. for (c = 0; c < componentsCount; c++) {
  33266. transformedTiles[c] = transformTile(context, tile, c);
  33267. }
  33268. var tile0 = transformedTiles[0];
  33269. var out = new Uint8Array(tile0.items.length * componentsCount);
  33270. var result = {
  33271. left: tile0.left,
  33272. top: tile0.top,
  33273. width: tile0.width,
  33274. height: tile0.height,
  33275. items: out
  33276. };
  33277. var shift, offset, max, min, maxK;
  33278. var pos = 0, j, jj, y0, y1, y2, r, g, b, k, val;
  33279. if (tile.codingStyleDefaultParameters.multipleComponentTransform) {
  33280. var fourComponents = componentsCount === 4;
  33281. var y0items = transformedTiles[0].items;
  33282. var y1items = transformedTiles[1].items;
  33283. var y2items = transformedTiles[2].items;
  33284. var y3items = fourComponents ? transformedTiles[3].items : null;
  33285. shift = components[0].precision - 8;
  33286. offset = (128 << shift) + 0.5;
  33287. max = 255 * (1 << shift);
  33288. maxK = max * 0.5;
  33289. min = -maxK;
  33290. var component0 = tile.components[0];
  33291. var alpha01 = componentsCount - 3;
  33292. jj = y0items.length;
  33293. if (!component0.codingStyleParameters.reversibleTransformation) {
  33294. for (j = 0; j < jj; j++, pos += alpha01) {
  33295. y0 = y0items[j] + offset;
  33296. y1 = y1items[j];
  33297. y2 = y2items[j];
  33298. r = y0 + 1.402 * y2;
  33299. g = y0 - 0.34413 * y1 - 0.71414 * y2;
  33300. b = y0 + 1.772 * y1;
  33301. out[pos++] = r <= 0 ? 0 : r >= max ? 255 : r >> shift;
  33302. out[pos++] = g <= 0 ? 0 : g >= max ? 255 : g >> shift;
  33303. out[pos++] = b <= 0 ? 0 : b >= max ? 255 : b >> shift;
  33304. }
  33305. } else {
  33306. for (j = 0; j < jj; j++, pos += alpha01) {
  33307. y0 = y0items[j] + offset;
  33308. y1 = y1items[j];
  33309. y2 = y2items[j];
  33310. g = y0 - (y2 + y1 >> 2);
  33311. r = g + y2;
  33312. b = g + y1;
  33313. out[pos++] = r <= 0 ? 0 : r >= max ? 255 : r >> shift;
  33314. out[pos++] = g <= 0 ? 0 : g >= max ? 255 : g >> shift;
  33315. out[pos++] = b <= 0 ? 0 : b >= max ? 255 : b >> shift;
  33316. }
  33317. }
  33318. if (fourComponents) {
  33319. for (j = 0, pos = 3; j < jj; j++, pos += 4) {
  33320. k = y3items[j];
  33321. out[pos] = k <= min ? 0 : k >= maxK ? 255 : k + offset >> shift;
  33322. }
  33323. }
  33324. } else {
  33325. for (c = 0; c < componentsCount; c++) {
  33326. var items = transformedTiles[c].items;
  33327. shift = components[c].precision - 8;
  33328. offset = (128 << shift) + 0.5;
  33329. max = 127.5 * (1 << shift);
  33330. min = -max;
  33331. for (pos = c, j = 0, jj = items.length; j < jj; j++) {
  33332. val = items[j];
  33333. out[pos] = val <= min ? 0 : val >= max ? 255 : val + offset >> shift;
  33334. pos += componentsCount;
  33335. }
  33336. }
  33337. }
  33338. resultImages.push(result);
  33339. }
  33340. return resultImages;
  33341. }
  33342. function initializeTile(context, tileIndex) {
  33343. var siz = context.SIZ;
  33344. var componentsCount = siz.Csiz;
  33345. var tile = context.tiles[tileIndex];
  33346. for (var c = 0; c < componentsCount; c++) {
  33347. var component = tile.components[c];
  33348. var qcdOrQcc = context.currentTile.QCC[c] !== undefined ? context.currentTile.QCC[c] : context.currentTile.QCD;
  33349. component.quantizationParameters = qcdOrQcc;
  33350. var codOrCoc = context.currentTile.COC[c] !== undefined ? context.currentTile.COC[c] : context.currentTile.COD;
  33351. component.codingStyleParameters = codOrCoc;
  33352. }
  33353. tile.codingStyleDefaultParameters = context.currentTile.COD;
  33354. }
  33355. var TagTree = function TagTreeClosure() {
  33356. function TagTree(width, height) {
  33357. var levelsLength = log2(Math.max(width, height)) + 1;
  33358. this.levels = [];
  33359. for (var i = 0; i < levelsLength; i++) {
  33360. var level = {
  33361. width: width,
  33362. height: height,
  33363. items: []
  33364. };
  33365. this.levels.push(level);
  33366. width = Math.ceil(width / 2);
  33367. height = Math.ceil(height / 2);
  33368. }
  33369. }
  33370. TagTree.prototype = {
  33371. reset: function TagTree_reset(i, j) {
  33372. var currentLevel = 0, value = 0, level;
  33373. while (currentLevel < this.levels.length) {
  33374. level = this.levels[currentLevel];
  33375. var index = i + j * level.width;
  33376. if (level.items[index] !== undefined) {
  33377. value = level.items[index];
  33378. break;
  33379. }
  33380. level.index = index;
  33381. i >>= 1;
  33382. j >>= 1;
  33383. currentLevel++;
  33384. }
  33385. currentLevel--;
  33386. level = this.levels[currentLevel];
  33387. level.items[level.index] = value;
  33388. this.currentLevel = currentLevel;
  33389. delete this.value;
  33390. },
  33391. incrementValue: function TagTree_incrementValue() {
  33392. var level = this.levels[this.currentLevel];
  33393. level.items[level.index]++;
  33394. },
  33395. nextLevel: function TagTree_nextLevel() {
  33396. var currentLevel = this.currentLevel;
  33397. var level = this.levels[currentLevel];
  33398. var value = level.items[level.index];
  33399. currentLevel--;
  33400. if (currentLevel < 0) {
  33401. this.value = value;
  33402. return false;
  33403. }
  33404. this.currentLevel = currentLevel;
  33405. level = this.levels[currentLevel];
  33406. level.items[level.index] = value;
  33407. return true;
  33408. }
  33409. };
  33410. return TagTree;
  33411. }();
  33412. var InclusionTree = function InclusionTreeClosure() {
  33413. function InclusionTree(width, height, defaultValue) {
  33414. var levelsLength = log2(Math.max(width, height)) + 1;
  33415. this.levels = [];
  33416. for (var i = 0; i < levelsLength; i++) {
  33417. var items = new Uint8Array(width * height);
  33418. for (var j = 0, jj = items.length; j < jj; j++) {
  33419. items[j] = defaultValue;
  33420. }
  33421. var level = {
  33422. width: width,
  33423. height: height,
  33424. items: items
  33425. };
  33426. this.levels.push(level);
  33427. width = Math.ceil(width / 2);
  33428. height = Math.ceil(height / 2);
  33429. }
  33430. }
  33431. InclusionTree.prototype = {
  33432. reset: function InclusionTree_reset(i, j, stopValue) {
  33433. var currentLevel = 0;
  33434. while (currentLevel < this.levels.length) {
  33435. var level = this.levels[currentLevel];
  33436. var index = i + j * level.width;
  33437. level.index = index;
  33438. var value = level.items[index];
  33439. if (value === 0xFF) {
  33440. break;
  33441. }
  33442. if (value > stopValue) {
  33443. this.currentLevel = currentLevel;
  33444. this.propagateValues();
  33445. return false;
  33446. }
  33447. i >>= 1;
  33448. j >>= 1;
  33449. currentLevel++;
  33450. }
  33451. this.currentLevel = currentLevel - 1;
  33452. return true;
  33453. },
  33454. incrementValue: function InclusionTree_incrementValue(stopValue) {
  33455. var level = this.levels[this.currentLevel];
  33456. level.items[level.index] = stopValue + 1;
  33457. this.propagateValues();
  33458. },
  33459. propagateValues: function InclusionTree_propagateValues() {
  33460. var levelIndex = this.currentLevel;
  33461. var level = this.levels[levelIndex];
  33462. var currentValue = level.items[level.index];
  33463. while (--levelIndex >= 0) {
  33464. level = this.levels[levelIndex];
  33465. level.items[level.index] = currentValue;
  33466. }
  33467. },
  33468. nextLevel: function InclusionTree_nextLevel() {
  33469. var currentLevel = this.currentLevel;
  33470. var level = this.levels[currentLevel];
  33471. var value = level.items[level.index];
  33472. level.items[level.index] = 0xFF;
  33473. currentLevel--;
  33474. if (currentLevel < 0) {
  33475. return false;
  33476. }
  33477. this.currentLevel = currentLevel;
  33478. level = this.levels[currentLevel];
  33479. level.items[level.index] = value;
  33480. return true;
  33481. }
  33482. };
  33483. return InclusionTree;
  33484. }();
  33485. var BitModel = function BitModelClosure() {
  33486. var UNIFORM_CONTEXT = 17;
  33487. var RUNLENGTH_CONTEXT = 18;
  33488. var LLAndLHContextsLabel = new Uint8Array([
  33489. 0,
  33490. 5,
  33491. 8,
  33492. 0,
  33493. 3,
  33494. 7,
  33495. 8,
  33496. 0,
  33497. 4,
  33498. 7,
  33499. 8,
  33500. 0,
  33501. 0,
  33502. 0,
  33503. 0,
  33504. 0,
  33505. 1,
  33506. 6,
  33507. 8,
  33508. 0,
  33509. 3,
  33510. 7,
  33511. 8,
  33512. 0,
  33513. 4,
  33514. 7,
  33515. 8,
  33516. 0,
  33517. 0,
  33518. 0,
  33519. 0,
  33520. 0,
  33521. 2,
  33522. 6,
  33523. 8,
  33524. 0,
  33525. 3,
  33526. 7,
  33527. 8,
  33528. 0,
  33529. 4,
  33530. 7,
  33531. 8,
  33532. 0,
  33533. 0,
  33534. 0,
  33535. 0,
  33536. 0,
  33537. 2,
  33538. 6,
  33539. 8,
  33540. 0,
  33541. 3,
  33542. 7,
  33543. 8,
  33544. 0,
  33545. 4,
  33546. 7,
  33547. 8,
  33548. 0,
  33549. 0,
  33550. 0,
  33551. 0,
  33552. 0,
  33553. 2,
  33554. 6,
  33555. 8,
  33556. 0,
  33557. 3,
  33558. 7,
  33559. 8,
  33560. 0,
  33561. 4,
  33562. 7,
  33563. 8
  33564. ]);
  33565. var HLContextLabel = new Uint8Array([
  33566. 0,
  33567. 3,
  33568. 4,
  33569. 0,
  33570. 5,
  33571. 7,
  33572. 7,
  33573. 0,
  33574. 8,
  33575. 8,
  33576. 8,
  33577. 0,
  33578. 0,
  33579. 0,
  33580. 0,
  33581. 0,
  33582. 1,
  33583. 3,
  33584. 4,
  33585. 0,
  33586. 6,
  33587. 7,
  33588. 7,
  33589. 0,
  33590. 8,
  33591. 8,
  33592. 8,
  33593. 0,
  33594. 0,
  33595. 0,
  33596. 0,
  33597. 0,
  33598. 2,
  33599. 3,
  33600. 4,
  33601. 0,
  33602. 6,
  33603. 7,
  33604. 7,
  33605. 0,
  33606. 8,
  33607. 8,
  33608. 8,
  33609. 0,
  33610. 0,
  33611. 0,
  33612. 0,
  33613. 0,
  33614. 2,
  33615. 3,
  33616. 4,
  33617. 0,
  33618. 6,
  33619. 7,
  33620. 7,
  33621. 0,
  33622. 8,
  33623. 8,
  33624. 8,
  33625. 0,
  33626. 0,
  33627. 0,
  33628. 0,
  33629. 0,
  33630. 2,
  33631. 3,
  33632. 4,
  33633. 0,
  33634. 6,
  33635. 7,
  33636. 7,
  33637. 0,
  33638. 8,
  33639. 8,
  33640. 8
  33641. ]);
  33642. var HHContextLabel = new Uint8Array([
  33643. 0,
  33644. 1,
  33645. 2,
  33646. 0,
  33647. 1,
  33648. 2,
  33649. 2,
  33650. 0,
  33651. 2,
  33652. 2,
  33653. 2,
  33654. 0,
  33655. 0,
  33656. 0,
  33657. 0,
  33658. 0,
  33659. 3,
  33660. 4,
  33661. 5,
  33662. 0,
  33663. 4,
  33664. 5,
  33665. 5,
  33666. 0,
  33667. 5,
  33668. 5,
  33669. 5,
  33670. 0,
  33671. 0,
  33672. 0,
  33673. 0,
  33674. 0,
  33675. 6,
  33676. 7,
  33677. 7,
  33678. 0,
  33679. 7,
  33680. 7,
  33681. 7,
  33682. 0,
  33683. 7,
  33684. 7,
  33685. 7,
  33686. 0,
  33687. 0,
  33688. 0,
  33689. 0,
  33690. 0,
  33691. 8,
  33692. 8,
  33693. 8,
  33694. 0,
  33695. 8,
  33696. 8,
  33697. 8,
  33698. 0,
  33699. 8,
  33700. 8,
  33701. 8,
  33702. 0,
  33703. 0,
  33704. 0,
  33705. 0,
  33706. 0,
  33707. 8,
  33708. 8,
  33709. 8,
  33710. 0,
  33711. 8,
  33712. 8,
  33713. 8,
  33714. 0,
  33715. 8,
  33716. 8,
  33717. 8
  33718. ]);
  33719. function BitModel(width, height, subband, zeroBitPlanes, mb) {
  33720. this.width = width;
  33721. this.height = height;
  33722. this.contextLabelTable = subband === 'HH' ? HHContextLabel : subband === 'HL' ? HLContextLabel : LLAndLHContextsLabel;
  33723. var coefficientCount = width * height;
  33724. this.neighborsSignificance = new Uint8Array(coefficientCount);
  33725. this.coefficentsSign = new Uint8Array(coefficientCount);
  33726. this.coefficentsMagnitude = mb > 14 ? new Uint32Array(coefficientCount) : mb > 6 ? new Uint16Array(coefficientCount) : new Uint8Array(coefficientCount);
  33727. this.processingFlags = new Uint8Array(coefficientCount);
  33728. var bitsDecoded = new Uint8Array(coefficientCount);
  33729. if (zeroBitPlanes !== 0) {
  33730. for (var i = 0; i < coefficientCount; i++) {
  33731. bitsDecoded[i] = zeroBitPlanes;
  33732. }
  33733. }
  33734. this.bitsDecoded = bitsDecoded;
  33735. this.reset();
  33736. }
  33737. BitModel.prototype = {
  33738. setDecoder: function BitModel_setDecoder(decoder) {
  33739. this.decoder = decoder;
  33740. },
  33741. reset: function BitModel_reset() {
  33742. this.contexts = new Int8Array(19);
  33743. this.contexts[0] = 4 << 1 | 0;
  33744. this.contexts[UNIFORM_CONTEXT] = 46 << 1 | 0;
  33745. this.contexts[RUNLENGTH_CONTEXT] = 3 << 1 | 0;
  33746. },
  33747. setNeighborsSignificance: function BitModel_setNeighborsSignificance(row, column, index) {
  33748. var neighborsSignificance = this.neighborsSignificance;
  33749. var width = this.width, height = this.height;
  33750. var left = column > 0;
  33751. var right = column + 1 < width;
  33752. var i;
  33753. if (row > 0) {
  33754. i = index - width;
  33755. if (left) {
  33756. neighborsSignificance[i - 1] += 0x10;
  33757. }
  33758. if (right) {
  33759. neighborsSignificance[i + 1] += 0x10;
  33760. }
  33761. neighborsSignificance[i] += 0x04;
  33762. }
  33763. if (row + 1 < height) {
  33764. i = index + width;
  33765. if (left) {
  33766. neighborsSignificance[i - 1] += 0x10;
  33767. }
  33768. if (right) {
  33769. neighborsSignificance[i + 1] += 0x10;
  33770. }
  33771. neighborsSignificance[i] += 0x04;
  33772. }
  33773. if (left) {
  33774. neighborsSignificance[index - 1] += 0x01;
  33775. }
  33776. if (right) {
  33777. neighborsSignificance[index + 1] += 0x01;
  33778. }
  33779. neighborsSignificance[index] |= 0x80;
  33780. },
  33781. runSignificancePropagationPass: function BitModel_runSignificancePropagationPass() {
  33782. var decoder = this.decoder;
  33783. var width = this.width, height = this.height;
  33784. var coefficentsMagnitude = this.coefficentsMagnitude;
  33785. var coefficentsSign = this.coefficentsSign;
  33786. var neighborsSignificance = this.neighborsSignificance;
  33787. var processingFlags = this.processingFlags;
  33788. var contexts = this.contexts;
  33789. var labels = this.contextLabelTable;
  33790. var bitsDecoded = this.bitsDecoded;
  33791. var processedInverseMask = ~1;
  33792. var processedMask = 1;
  33793. var firstMagnitudeBitMask = 2;
  33794. for (var i0 = 0; i0 < height; i0 += 4) {
  33795. for (var j = 0; j < width; j++) {
  33796. var index = i0 * width + j;
  33797. for (var i1 = 0; i1 < 4; i1++, index += width) {
  33798. var i = i0 + i1;
  33799. if (i >= height) {
  33800. break;
  33801. }
  33802. processingFlags[index] &= processedInverseMask;
  33803. if (coefficentsMagnitude[index] || !neighborsSignificance[index]) {
  33804. continue;
  33805. }
  33806. var contextLabel = labels[neighborsSignificance[index]];
  33807. var decision = decoder.readBit(contexts, contextLabel);
  33808. if (decision) {
  33809. var sign = this.decodeSignBit(i, j, index);
  33810. coefficentsSign[index] = sign;
  33811. coefficentsMagnitude[index] = 1;
  33812. this.setNeighborsSignificance(i, j, index);
  33813. processingFlags[index] |= firstMagnitudeBitMask;
  33814. }
  33815. bitsDecoded[index]++;
  33816. processingFlags[index] |= processedMask;
  33817. }
  33818. }
  33819. }
  33820. },
  33821. decodeSignBit: function BitModel_decodeSignBit(row, column, index) {
  33822. var width = this.width, height = this.height;
  33823. var coefficentsMagnitude = this.coefficentsMagnitude;
  33824. var coefficentsSign = this.coefficentsSign;
  33825. var contribution, sign0, sign1, significance1;
  33826. var contextLabel, decoded;
  33827. significance1 = column > 0 && coefficentsMagnitude[index - 1] !== 0;
  33828. if (column + 1 < width && coefficentsMagnitude[index + 1] !== 0) {
  33829. sign1 = coefficentsSign[index + 1];
  33830. if (significance1) {
  33831. sign0 = coefficentsSign[index - 1];
  33832. contribution = 1 - sign1 - sign0;
  33833. } else {
  33834. contribution = 1 - sign1 - sign1;
  33835. }
  33836. } else if (significance1) {
  33837. sign0 = coefficentsSign[index - 1];
  33838. contribution = 1 - sign0 - sign0;
  33839. } else {
  33840. contribution = 0;
  33841. }
  33842. var horizontalContribution = 3 * contribution;
  33843. significance1 = row > 0 && coefficentsMagnitude[index - width] !== 0;
  33844. if (row + 1 < height && coefficentsMagnitude[index + width] !== 0) {
  33845. sign1 = coefficentsSign[index + width];
  33846. if (significance1) {
  33847. sign0 = coefficentsSign[index - width];
  33848. contribution = 1 - sign1 - sign0 + horizontalContribution;
  33849. } else {
  33850. contribution = 1 - sign1 - sign1 + horizontalContribution;
  33851. }
  33852. } else if (significance1) {
  33853. sign0 = coefficentsSign[index - width];
  33854. contribution = 1 - sign0 - sign0 + horizontalContribution;
  33855. } else {
  33856. contribution = horizontalContribution;
  33857. }
  33858. if (contribution >= 0) {
  33859. contextLabel = 9 + contribution;
  33860. decoded = this.decoder.readBit(this.contexts, contextLabel);
  33861. } else {
  33862. contextLabel = 9 - contribution;
  33863. decoded = this.decoder.readBit(this.contexts, contextLabel) ^ 1;
  33864. }
  33865. return decoded;
  33866. },
  33867. runMagnitudeRefinementPass: function BitModel_runMagnitudeRefinementPass() {
  33868. var decoder = this.decoder;
  33869. var width = this.width, height = this.height;
  33870. var coefficentsMagnitude = this.coefficentsMagnitude;
  33871. var neighborsSignificance = this.neighborsSignificance;
  33872. var contexts = this.contexts;
  33873. var bitsDecoded = this.bitsDecoded;
  33874. var processingFlags = this.processingFlags;
  33875. var processedMask = 1;
  33876. var firstMagnitudeBitMask = 2;
  33877. var length = width * height;
  33878. var width4 = width * 4;
  33879. for (var index0 = 0, indexNext; index0 < length; index0 = indexNext) {
  33880. indexNext = Math.min(length, index0 + width4);
  33881. for (var j = 0; j < width; j++) {
  33882. for (var index = index0 + j; index < indexNext; index += width) {
  33883. if (!coefficentsMagnitude[index] || (processingFlags[index] & processedMask) !== 0) {
  33884. continue;
  33885. }
  33886. var contextLabel = 16;
  33887. if ((processingFlags[index] & firstMagnitudeBitMask) !== 0) {
  33888. processingFlags[index] ^= firstMagnitudeBitMask;
  33889. var significance = neighborsSignificance[index] & 127;
  33890. contextLabel = significance === 0 ? 15 : 14;
  33891. }
  33892. var bit = decoder.readBit(contexts, contextLabel);
  33893. coefficentsMagnitude[index] = coefficentsMagnitude[index] << 1 | bit;
  33894. bitsDecoded[index]++;
  33895. processingFlags[index] |= processedMask;
  33896. }
  33897. }
  33898. }
  33899. },
  33900. runCleanupPass: function BitModel_runCleanupPass() {
  33901. var decoder = this.decoder;
  33902. var width = this.width, height = this.height;
  33903. var neighborsSignificance = this.neighborsSignificance;
  33904. var coefficentsMagnitude = this.coefficentsMagnitude;
  33905. var coefficentsSign = this.coefficentsSign;
  33906. var contexts = this.contexts;
  33907. var labels = this.contextLabelTable;
  33908. var bitsDecoded = this.bitsDecoded;
  33909. var processingFlags = this.processingFlags;
  33910. var processedMask = 1;
  33911. var firstMagnitudeBitMask = 2;
  33912. var oneRowDown = width;
  33913. var twoRowsDown = width * 2;
  33914. var threeRowsDown = width * 3;
  33915. var iNext;
  33916. for (var i0 = 0; i0 < height; i0 = iNext) {
  33917. iNext = Math.min(i0 + 4, height);
  33918. var indexBase = i0 * width;
  33919. var checkAllEmpty = i0 + 3 < height;
  33920. for (var j = 0; j < width; j++) {
  33921. var index0 = indexBase + j;
  33922. 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;
  33923. var i1 = 0, index = index0;
  33924. var i = i0, sign;
  33925. if (allEmpty) {
  33926. var hasSignificantCoefficent = decoder.readBit(contexts, RUNLENGTH_CONTEXT);
  33927. if (!hasSignificantCoefficent) {
  33928. bitsDecoded[index0]++;
  33929. bitsDecoded[index0 + oneRowDown]++;
  33930. bitsDecoded[index0 + twoRowsDown]++;
  33931. bitsDecoded[index0 + threeRowsDown]++;
  33932. continue;
  33933. }
  33934. i1 = decoder.readBit(contexts, UNIFORM_CONTEXT) << 1 | decoder.readBit(contexts, UNIFORM_CONTEXT);
  33935. if (i1 !== 0) {
  33936. i = i0 + i1;
  33937. index += i1 * width;
  33938. }
  33939. sign = this.decodeSignBit(i, j, index);
  33940. coefficentsSign[index] = sign;
  33941. coefficentsMagnitude[index] = 1;
  33942. this.setNeighborsSignificance(i, j, index);
  33943. processingFlags[index] |= firstMagnitudeBitMask;
  33944. index = index0;
  33945. for (var i2 = i0; i2 <= i; i2++, index += width) {
  33946. bitsDecoded[index]++;
  33947. }
  33948. i1++;
  33949. }
  33950. for (i = i0 + i1; i < iNext; i++, index += width) {
  33951. if (coefficentsMagnitude[index] || (processingFlags[index] & processedMask) !== 0) {
  33952. continue;
  33953. }
  33954. var contextLabel = labels[neighborsSignificance[index]];
  33955. var decision = decoder.readBit(contexts, contextLabel);
  33956. if (decision === 1) {
  33957. sign = this.decodeSignBit(i, j, index);
  33958. coefficentsSign[index] = sign;
  33959. coefficentsMagnitude[index] = 1;
  33960. this.setNeighborsSignificance(i, j, index);
  33961. processingFlags[index] |= firstMagnitudeBitMask;
  33962. }
  33963. bitsDecoded[index]++;
  33964. }
  33965. }
  33966. }
  33967. },
  33968. checkSegmentationSymbol: function BitModel_checkSegmentationSymbol() {
  33969. var decoder = this.decoder;
  33970. var contexts = this.contexts;
  33971. 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);
  33972. if (symbol !== 0xA) {
  33973. error('JPX Error: Invalid segmentation symbol');
  33974. }
  33975. }
  33976. };
  33977. return BitModel;
  33978. }();
  33979. var Transform = function TransformClosure() {
  33980. function Transform() {
  33981. }
  33982. Transform.prototype.calculate = function transformCalculate(subbands, u0, v0) {
  33983. var ll = subbands[0];
  33984. for (var i = 1, ii = subbands.length; i < ii; i++) {
  33985. ll = this.iterate(ll, subbands[i], u0, v0);
  33986. }
  33987. return ll;
  33988. };
  33989. Transform.prototype.extend = function extend(buffer, offset, size) {
  33990. var i1 = offset - 1, j1 = offset + 1;
  33991. var i2 = offset + size - 2, j2 = offset + size;
  33992. buffer[i1--] = buffer[j1++];
  33993. buffer[j2++] = buffer[i2--];
  33994. buffer[i1--] = buffer[j1++];
  33995. buffer[j2++] = buffer[i2--];
  33996. buffer[i1--] = buffer[j1++];
  33997. buffer[j2++] = buffer[i2--];
  33998. buffer[i1] = buffer[j1];
  33999. buffer[j2] = buffer[i2];
  34000. };
  34001. Transform.prototype.iterate = function Transform_iterate(ll, hl_lh_hh, u0, v0) {
  34002. var llWidth = ll.width, llHeight = ll.height, llItems = ll.items;
  34003. var width = hl_lh_hh.width;
  34004. var height = hl_lh_hh.height;
  34005. var items = hl_lh_hh.items;
  34006. var i, j, k, l, u, v;
  34007. for (k = 0, i = 0; i < llHeight; i++) {
  34008. l = i * 2 * width;
  34009. for (j = 0; j < llWidth; j++, k++, l += 2) {
  34010. items[l] = llItems[k];
  34011. }
  34012. }
  34013. llItems = ll.items = null;
  34014. var bufferPadding = 4;
  34015. var rowBuffer = new Float32Array(width + 2 * bufferPadding);
  34016. if (width === 1) {
  34017. if ((u0 & 1) !== 0) {
  34018. for (v = 0, k = 0; v < height; v++, k += width) {
  34019. items[k] *= 0.5;
  34020. }
  34021. }
  34022. } else {
  34023. for (v = 0, k = 0; v < height; v++, k += width) {
  34024. rowBuffer.set(items.subarray(k, k + width), bufferPadding);
  34025. this.extend(rowBuffer, bufferPadding, width);
  34026. this.filter(rowBuffer, bufferPadding, width);
  34027. items.set(rowBuffer.subarray(bufferPadding, bufferPadding + width), k);
  34028. }
  34029. }
  34030. var numBuffers = 16;
  34031. var colBuffers = [];
  34032. for (i = 0; i < numBuffers; i++) {
  34033. colBuffers.push(new Float32Array(height + 2 * bufferPadding));
  34034. }
  34035. var b, currentBuffer = 0;
  34036. ll = bufferPadding + height;
  34037. if (height === 1) {
  34038. if ((v0 & 1) !== 0) {
  34039. for (u = 0; u < width; u++) {
  34040. items[u] *= 0.5;
  34041. }
  34042. }
  34043. } else {
  34044. for (u = 0; u < width; u++) {
  34045. if (currentBuffer === 0) {
  34046. numBuffers = Math.min(width - u, numBuffers);
  34047. for (k = u, l = bufferPadding; l < ll; k += width, l++) {
  34048. for (b = 0; b < numBuffers; b++) {
  34049. colBuffers[b][l] = items[k + b];
  34050. }
  34051. }
  34052. currentBuffer = numBuffers;
  34053. }
  34054. currentBuffer--;
  34055. var buffer = colBuffers[currentBuffer];
  34056. this.extend(buffer, bufferPadding, height);
  34057. this.filter(buffer, bufferPadding, height);
  34058. if (currentBuffer === 0) {
  34059. k = u - numBuffers + 1;
  34060. for (l = bufferPadding; l < ll; k += width, l++) {
  34061. for (b = 0; b < numBuffers; b++) {
  34062. items[k + b] = colBuffers[b][l];
  34063. }
  34064. }
  34065. }
  34066. }
  34067. }
  34068. return {
  34069. width: width,
  34070. height: height,
  34071. items: items
  34072. };
  34073. };
  34074. return Transform;
  34075. }();
  34076. var IrreversibleTransform = function IrreversibleTransformClosure() {
  34077. function IrreversibleTransform() {
  34078. Transform.call(this);
  34079. }
  34080. IrreversibleTransform.prototype = Object.create(Transform.prototype);
  34081. IrreversibleTransform.prototype.filter = function irreversibleTransformFilter(x, offset, length) {
  34082. var len = length >> 1;
  34083. offset = offset | 0;
  34084. var j, n, current, next;
  34085. var alpha = -1.586134342059924;
  34086. var beta = -0.052980118572961;
  34087. var gamma = 0.882911075530934;
  34088. var delta = 0.443506852043971;
  34089. var K = 1.230174104914001;
  34090. var K_ = 1 / K;
  34091. j = offset - 3;
  34092. for (n = len + 4; n--; j += 2) {
  34093. x[j] *= K_;
  34094. }
  34095. j = offset - 2;
  34096. current = delta * x[j - 1];
  34097. for (n = len + 3; n--; j += 2) {
  34098. next = delta * x[j + 1];
  34099. x[j] = K * x[j] - current - next;
  34100. if (n--) {
  34101. j += 2;
  34102. current = delta * x[j + 1];
  34103. x[j] = K * x[j] - current - next;
  34104. } else {
  34105. break;
  34106. }
  34107. }
  34108. j = offset - 1;
  34109. current = gamma * x[j - 1];
  34110. for (n = len + 2; n--; j += 2) {
  34111. next = gamma * x[j + 1];
  34112. x[j] -= current + next;
  34113. if (n--) {
  34114. j += 2;
  34115. current = gamma * x[j + 1];
  34116. x[j] -= current + next;
  34117. } else {
  34118. break;
  34119. }
  34120. }
  34121. j = offset;
  34122. current = beta * x[j - 1];
  34123. for (n = len + 1; n--; j += 2) {
  34124. next = beta * x[j + 1];
  34125. x[j] -= current + next;
  34126. if (n--) {
  34127. j += 2;
  34128. current = beta * x[j + 1];
  34129. x[j] -= current + next;
  34130. } else {
  34131. break;
  34132. }
  34133. }
  34134. if (len !== 0) {
  34135. j = offset + 1;
  34136. current = alpha * x[j - 1];
  34137. for (n = len; n--; j += 2) {
  34138. next = alpha * x[j + 1];
  34139. x[j] -= current + next;
  34140. if (n--) {
  34141. j += 2;
  34142. current = alpha * x[j + 1];
  34143. x[j] -= current + next;
  34144. } else {
  34145. break;
  34146. }
  34147. }
  34148. }
  34149. };
  34150. return IrreversibleTransform;
  34151. }();
  34152. var ReversibleTransform = function ReversibleTransformClosure() {
  34153. function ReversibleTransform() {
  34154. Transform.call(this);
  34155. }
  34156. ReversibleTransform.prototype = Object.create(Transform.prototype);
  34157. ReversibleTransform.prototype.filter = function reversibleTransformFilter(x, offset, length) {
  34158. var len = length >> 1;
  34159. offset = offset | 0;
  34160. var j, n;
  34161. for (j = offset, n = len + 1; n--; j += 2) {
  34162. x[j] -= x[j - 1] + x[j + 1] + 2 >> 2;
  34163. }
  34164. for (j = offset + 1, n = len; n--; j += 2) {
  34165. x[j] += x[j - 1] + x[j + 1] >> 1;
  34166. }
  34167. };
  34168. return ReversibleTransform;
  34169. }();
  34170. return JpxImage;
  34171. }();
  34172. exports.JpxImage = JpxImage;
  34173. /***/ }),
  34174. /* 19 */
  34175. /***/ (function(module, exports, __w_pdfjs_require__) {
  34176. "use strict";
  34177. var sharedUtil = __w_pdfjs_require__(0);
  34178. var corePrimitives = __w_pdfjs_require__(1);
  34179. var coreCrypto = __w_pdfjs_require__(16);
  34180. var coreParser = __w_pdfjs_require__(6);
  34181. var coreChunkedStream = __w_pdfjs_require__(15);
  34182. var coreColorSpace = __w_pdfjs_require__(4);
  34183. var InvalidPDFException = sharedUtil.InvalidPDFException;
  34184. var MissingDataException = sharedUtil.MissingDataException;
  34185. var XRefParseException = sharedUtil.XRefParseException;
  34186. var assert = sharedUtil.assert;
  34187. var bytesToString = sharedUtil.bytesToString;
  34188. var createPromiseCapability = sharedUtil.createPromiseCapability;
  34189. var error = sharedUtil.error;
  34190. var info = sharedUtil.info;
  34191. var isArray = sharedUtil.isArray;
  34192. var isBool = sharedUtil.isBool;
  34193. var isInt = sharedUtil.isInt;
  34194. var isString = sharedUtil.isString;
  34195. var shadow = sharedUtil.shadow;
  34196. var stringToPDFString = sharedUtil.stringToPDFString;
  34197. var stringToUTF8String = sharedUtil.stringToUTF8String;
  34198. var warn = sharedUtil.warn;
  34199. var createValidAbsoluteUrl = sharedUtil.createValidAbsoluteUrl;
  34200. var Util = sharedUtil.Util;
  34201. var Ref = corePrimitives.Ref;
  34202. var RefSet = corePrimitives.RefSet;
  34203. var RefSetCache = corePrimitives.RefSetCache;
  34204. var isName = corePrimitives.isName;
  34205. var isCmd = corePrimitives.isCmd;
  34206. var isDict = corePrimitives.isDict;
  34207. var isRef = corePrimitives.isRef;
  34208. var isRefsEqual = corePrimitives.isRefsEqual;
  34209. var isStream = corePrimitives.isStream;
  34210. var CipherTransformFactory = coreCrypto.CipherTransformFactory;
  34211. var Lexer = coreParser.Lexer;
  34212. var Parser = coreParser.Parser;
  34213. var ChunkedStream = coreChunkedStream.ChunkedStream;
  34214. var ColorSpace = coreColorSpace.ColorSpace;
  34215. var Catalog = function CatalogClosure() {
  34216. function Catalog(pdfManager, xref, pageFactory) {
  34217. this.pdfManager = pdfManager;
  34218. this.xref = xref;
  34219. this.catDict = xref.getCatalogObj();
  34220. this.fontCache = new RefSetCache();
  34221. assert(isDict(this.catDict), 'catalog object is not a dictionary');
  34222. this.pageFactory = pageFactory;
  34223. this.pagePromises = [];
  34224. }
  34225. Catalog.prototype = {
  34226. get metadata() {
  34227. var streamRef = this.catDict.getRaw('Metadata');
  34228. if (!isRef(streamRef)) {
  34229. return shadow(this, 'metadata', null);
  34230. }
  34231. var encryptMetadata = !this.xref.encrypt ? false : this.xref.encrypt.encryptMetadata;
  34232. var stream = this.xref.fetch(streamRef, !encryptMetadata);
  34233. var metadata;
  34234. if (stream && isDict(stream.dict)) {
  34235. var type = stream.dict.get('Type');
  34236. var subtype = stream.dict.get('Subtype');
  34237. if (isName(type, 'Metadata') && isName(subtype, 'XML')) {
  34238. try {
  34239. metadata = stringToUTF8String(bytesToString(stream.getBytes()));
  34240. } catch (e) {
  34241. info('Skipping invalid metadata.');
  34242. }
  34243. }
  34244. }
  34245. return shadow(this, 'metadata', metadata);
  34246. },
  34247. get toplevelPagesDict() {
  34248. var pagesObj = this.catDict.get('Pages');
  34249. assert(isDict(pagesObj), 'invalid top-level pages dictionary');
  34250. return shadow(this, 'toplevelPagesDict', pagesObj);
  34251. },
  34252. get documentOutline() {
  34253. var obj = null;
  34254. try {
  34255. obj = this.readDocumentOutline();
  34256. } catch (ex) {
  34257. if (ex instanceof MissingDataException) {
  34258. throw ex;
  34259. }
  34260. warn('Unable to read document outline');
  34261. }
  34262. return shadow(this, 'documentOutline', obj);
  34263. },
  34264. readDocumentOutline: function Catalog_readDocumentOutline() {
  34265. var obj = this.catDict.get('Outlines');
  34266. if (!isDict(obj)) {
  34267. return null;
  34268. }
  34269. obj = obj.getRaw('First');
  34270. if (!isRef(obj)) {
  34271. return null;
  34272. }
  34273. var root = { items: [] };
  34274. var queue = [{
  34275. obj: obj,
  34276. parent: root
  34277. }];
  34278. var processed = new RefSet();
  34279. processed.put(obj);
  34280. var xref = this.xref, blackColor = new Uint8Array(3);
  34281. while (queue.length > 0) {
  34282. var i = queue.shift();
  34283. var outlineDict = xref.fetchIfRef(i.obj);
  34284. if (outlineDict === null) {
  34285. continue;
  34286. }
  34287. assert(outlineDict.has('Title'), 'Invalid outline item');
  34288. var data = {
  34289. url: null,
  34290. dest: null
  34291. };
  34292. Catalog.parseDestDictionary({
  34293. destDict: outlineDict,
  34294. resultObj: data,
  34295. docBaseUrl: this.pdfManager.docBaseUrl
  34296. });
  34297. var title = outlineDict.get('Title');
  34298. var flags = outlineDict.get('F') || 0;
  34299. var color = outlineDict.getArray('C'), rgbColor = blackColor;
  34300. if (isArray(color) && color.length === 3 && (color[0] !== 0 || color[1] !== 0 || color[2] !== 0)) {
  34301. rgbColor = ColorSpace.singletons.rgb.getRgb(color, 0);
  34302. }
  34303. var outlineItem = {
  34304. dest: data.dest,
  34305. url: data.url,
  34306. unsafeUrl: data.unsafeUrl,
  34307. newWindow: data.newWindow,
  34308. title: stringToPDFString(title),
  34309. color: rgbColor,
  34310. count: outlineDict.get('Count'),
  34311. bold: !!(flags & 2),
  34312. italic: !!(flags & 1),
  34313. items: []
  34314. };
  34315. i.parent.items.push(outlineItem);
  34316. obj = outlineDict.getRaw('First');
  34317. if (isRef(obj) && !processed.has(obj)) {
  34318. queue.push({
  34319. obj: obj,
  34320. parent: outlineItem
  34321. });
  34322. processed.put(obj);
  34323. }
  34324. obj = outlineDict.getRaw('Next');
  34325. if (isRef(obj) && !processed.has(obj)) {
  34326. queue.push({
  34327. obj: obj,
  34328. parent: i.parent
  34329. });
  34330. processed.put(obj);
  34331. }
  34332. }
  34333. return root.items.length > 0 ? root.items : null;
  34334. },
  34335. get numPages() {
  34336. var obj = this.toplevelPagesDict.get('Count');
  34337. assert(isInt(obj), 'page count in top level pages object is not an integer');
  34338. return shadow(this, 'num', obj);
  34339. },
  34340. get destinations() {
  34341. function fetchDestination(dest) {
  34342. return isDict(dest) ? dest.get('D') : dest;
  34343. }
  34344. var xref = this.xref;
  34345. var dests = {}, nameTreeRef, nameDictionaryRef;
  34346. var obj = this.catDict.get('Names');
  34347. if (obj && obj.has('Dests')) {
  34348. nameTreeRef = obj.getRaw('Dests');
  34349. } else if (this.catDict.has('Dests')) {
  34350. nameDictionaryRef = this.catDict.get('Dests');
  34351. }
  34352. if (nameDictionaryRef) {
  34353. obj = nameDictionaryRef;
  34354. obj.forEach(function catalogForEach(key, value) {
  34355. if (!value) {
  34356. return;
  34357. }
  34358. dests[key] = fetchDestination(value);
  34359. });
  34360. }
  34361. if (nameTreeRef) {
  34362. var nameTree = new NameTree(nameTreeRef, xref);
  34363. var names = nameTree.getAll();
  34364. for (var name in names) {
  34365. dests[name] = fetchDestination(names[name]);
  34366. }
  34367. }
  34368. return shadow(this, 'destinations', dests);
  34369. },
  34370. getDestination: function Catalog_getDestination(destinationId) {
  34371. function fetchDestination(dest) {
  34372. return isDict(dest) ? dest.get('D') : dest;
  34373. }
  34374. var xref = this.xref;
  34375. var dest = null, nameTreeRef, nameDictionaryRef;
  34376. var obj = this.catDict.get('Names');
  34377. if (obj && obj.has('Dests')) {
  34378. nameTreeRef = obj.getRaw('Dests');
  34379. } else if (this.catDict.has('Dests')) {
  34380. nameDictionaryRef = this.catDict.get('Dests');
  34381. }
  34382. if (nameDictionaryRef) {
  34383. var value = nameDictionaryRef.get(destinationId);
  34384. if (value) {
  34385. dest = fetchDestination(value);
  34386. }
  34387. }
  34388. if (nameTreeRef) {
  34389. var nameTree = new NameTree(nameTreeRef, xref);
  34390. dest = fetchDestination(nameTree.get(destinationId));
  34391. }
  34392. return dest;
  34393. },
  34394. get pageLabels() {
  34395. var obj = null;
  34396. try {
  34397. obj = this.readPageLabels();
  34398. } catch (ex) {
  34399. if (ex instanceof MissingDataException) {
  34400. throw ex;
  34401. }
  34402. warn('Unable to read page labels.');
  34403. }
  34404. return shadow(this, 'pageLabels', obj);
  34405. },
  34406. readPageLabels: function Catalog_readPageLabels() {
  34407. var obj = this.catDict.getRaw('PageLabels');
  34408. if (!obj) {
  34409. return null;
  34410. }
  34411. var pageLabels = new Array(this.numPages);
  34412. var style = null;
  34413. var prefix = '';
  34414. var numberTree = new NumberTree(obj, this.xref);
  34415. var nums = numberTree.getAll();
  34416. var currentLabel = '', currentIndex = 1;
  34417. for (var i = 0, ii = this.numPages; i < ii; i++) {
  34418. if (i in nums) {
  34419. var labelDict = nums[i];
  34420. assert(isDict(labelDict), 'The PageLabel is not a dictionary.');
  34421. var type = labelDict.get('Type');
  34422. assert(!type || isName(type, 'PageLabel'), 'Invalid type in PageLabel dictionary.');
  34423. var s = labelDict.get('S');
  34424. assert(!s || isName(s), 'Invalid style in PageLabel dictionary.');
  34425. style = s ? s.name : null;
  34426. var p = labelDict.get('P');
  34427. assert(!p || isString(p), 'Invalid prefix in PageLabel dictionary.');
  34428. prefix = p ? stringToPDFString(p) : '';
  34429. var st = labelDict.get('St');
  34430. assert(!st || isInt(st) && st >= 1, 'Invalid start in PageLabel dictionary.');
  34431. currentIndex = st || 1;
  34432. }
  34433. switch (style) {
  34434. case 'D':
  34435. currentLabel = currentIndex;
  34436. break;
  34437. case 'R':
  34438. case 'r':
  34439. currentLabel = Util.toRoman(currentIndex, style === 'r');
  34440. break;
  34441. case 'A':
  34442. case 'a':
  34443. var LIMIT = 26;
  34444. var A_UPPER_CASE = 0x41, A_LOWER_CASE = 0x61;
  34445. var baseCharCode = style === 'a' ? A_LOWER_CASE : A_UPPER_CASE;
  34446. var letterIndex = currentIndex - 1;
  34447. var character = String.fromCharCode(baseCharCode + letterIndex % LIMIT);
  34448. var charBuf = [];
  34449. for (var j = 0, jj = letterIndex / LIMIT | 0; j <= jj; j++) {
  34450. charBuf.push(character);
  34451. }
  34452. currentLabel = charBuf.join('');
  34453. break;
  34454. default:
  34455. assert(!style, 'Invalid style "' + style + '" in PageLabel dictionary.');
  34456. }
  34457. pageLabels[i] = prefix + currentLabel;
  34458. currentLabel = '';
  34459. currentIndex++;
  34460. }
  34461. return pageLabels;
  34462. },
  34463. get attachments() {
  34464. var xref = this.xref;
  34465. var attachments = null, nameTreeRef;
  34466. var obj = this.catDict.get('Names');
  34467. if (obj) {
  34468. nameTreeRef = obj.getRaw('EmbeddedFiles');
  34469. }
  34470. if (nameTreeRef) {
  34471. var nameTree = new NameTree(nameTreeRef, xref);
  34472. var names = nameTree.getAll();
  34473. for (var name in names) {
  34474. var fs = new FileSpec(names[name], xref);
  34475. if (!attachments) {
  34476. attachments = Object.create(null);
  34477. }
  34478. attachments[stringToPDFString(name)] = fs.serializable;
  34479. }
  34480. }
  34481. return shadow(this, 'attachments', attachments);
  34482. },
  34483. get javaScript() {
  34484. var xref = this.xref;
  34485. var obj = this.catDict.get('Names');
  34486. var javaScript = [];
  34487. function appendIfJavaScriptDict(jsDict) {
  34488. var type = jsDict.get('S');
  34489. if (!isName(type, 'JavaScript')) {
  34490. return;
  34491. }
  34492. var js = jsDict.get('JS');
  34493. if (isStream(js)) {
  34494. js = bytesToString(js.getBytes());
  34495. } else if (!isString(js)) {
  34496. return;
  34497. }
  34498. javaScript.push(stringToPDFString(js));
  34499. }
  34500. if (obj && obj.has('JavaScript')) {
  34501. var nameTree = new NameTree(obj.getRaw('JavaScript'), xref);
  34502. var names = nameTree.getAll();
  34503. for (var name in names) {
  34504. var jsDict = names[name];
  34505. if (isDict(jsDict)) {
  34506. appendIfJavaScriptDict(jsDict);
  34507. }
  34508. }
  34509. }
  34510. var openactionDict = this.catDict.get('OpenAction');
  34511. if (isDict(openactionDict, 'Action')) {
  34512. var actionType = openactionDict.get('S');
  34513. if (isName(actionType, 'Named')) {
  34514. var action = openactionDict.get('N');
  34515. if (isName(action, 'Print')) {
  34516. javaScript.push('print({});');
  34517. }
  34518. } else {
  34519. appendIfJavaScriptDict(openactionDict);
  34520. }
  34521. }
  34522. return shadow(this, 'javaScript', javaScript);
  34523. },
  34524. cleanup: function Catalog_cleanup() {
  34525. var promises = [];
  34526. this.fontCache.forEach(function (promise) {
  34527. promises.push(promise);
  34528. });
  34529. return Promise.all(promises).then(function (translatedFonts) {
  34530. for (var i = 0, ii = translatedFonts.length; i < ii; i++) {
  34531. var font = translatedFonts[i].dict;
  34532. delete font.translated;
  34533. }
  34534. this.fontCache.clear();
  34535. }.bind(this));
  34536. },
  34537. getPage: function Catalog_getPage(pageIndex) {
  34538. if (!(pageIndex in this.pagePromises)) {
  34539. this.pagePromises[pageIndex] = this.getPageDict(pageIndex).then(function (a) {
  34540. var dict = a[0];
  34541. var ref = a[1];
  34542. return this.pageFactory.createPage(pageIndex, dict, ref, this.fontCache);
  34543. }.bind(this));
  34544. }
  34545. return this.pagePromises[pageIndex];
  34546. },
  34547. getPageDict: function Catalog_getPageDict(pageIndex) {
  34548. var capability = createPromiseCapability();
  34549. var nodesToVisit = [this.catDict.getRaw('Pages')];
  34550. var currentPageIndex = 0;
  34551. var xref = this.xref;
  34552. var checkAllKids = false;
  34553. function next() {
  34554. while (nodesToVisit.length) {
  34555. var currentNode = nodesToVisit.pop();
  34556. if (isRef(currentNode)) {
  34557. xref.fetchAsync(currentNode).then(function (obj) {
  34558. if (isDict(obj, 'Page') || isDict(obj) && !obj.has('Kids')) {
  34559. if (pageIndex === currentPageIndex) {
  34560. capability.resolve([
  34561. obj,
  34562. currentNode
  34563. ]);
  34564. } else {
  34565. currentPageIndex++;
  34566. next();
  34567. }
  34568. return;
  34569. }
  34570. nodesToVisit.push(obj);
  34571. next();
  34572. }, capability.reject);
  34573. return;
  34574. }
  34575. assert(isDict(currentNode), 'page dictionary kid reference points to wrong type of object');
  34576. var count = currentNode.get('Count');
  34577. if (count === 0) {
  34578. checkAllKids = true;
  34579. }
  34580. if (currentPageIndex + count <= pageIndex) {
  34581. currentPageIndex += count;
  34582. continue;
  34583. }
  34584. var kids = currentNode.get('Kids');
  34585. assert(isArray(kids), 'page dictionary kids object is not an array');
  34586. if (!checkAllKids && count === kids.length) {
  34587. nodesToVisit = [kids[pageIndex - currentPageIndex]];
  34588. currentPageIndex = pageIndex;
  34589. continue;
  34590. } else {
  34591. for (var last = kids.length - 1; last >= 0; last--) {
  34592. nodesToVisit.push(kids[last]);
  34593. }
  34594. }
  34595. }
  34596. capability.reject('Page index ' + pageIndex + ' not found.');
  34597. }
  34598. next();
  34599. return capability.promise;
  34600. },
  34601. getPageIndex: function Catalog_getPageIndex(pageRef) {
  34602. var xref = this.xref;
  34603. function pagesBeforeRef(kidRef) {
  34604. var total = 0;
  34605. var parentRef;
  34606. return xref.fetchAsync(kidRef).then(function (node) {
  34607. if (isRefsEqual(kidRef, pageRef) && !isDict(node, 'Page') && !(isDict(node) && !node.has('Type') && node.has('Contents'))) {
  34608. throw new Error('The reference does not point to a /Page Dict.');
  34609. }
  34610. if (!node) {
  34611. return null;
  34612. }
  34613. assert(isDict(node), 'node must be a Dict.');
  34614. parentRef = node.getRaw('Parent');
  34615. return node.getAsync('Parent');
  34616. }).then(function (parent) {
  34617. if (!parent) {
  34618. return null;
  34619. }
  34620. assert(isDict(parent), 'parent must be a Dict.');
  34621. return parent.getAsync('Kids');
  34622. }).then(function (kids) {
  34623. if (!kids) {
  34624. return null;
  34625. }
  34626. var kidPromises = [];
  34627. var found = false;
  34628. for (var i = 0; i < kids.length; i++) {
  34629. var kid = kids[i];
  34630. assert(isRef(kid), 'kid must be a Ref.');
  34631. if (kid.num === kidRef.num) {
  34632. found = true;
  34633. break;
  34634. }
  34635. kidPromises.push(xref.fetchAsync(kid).then(function (kid) {
  34636. if (kid.has('Count')) {
  34637. var count = kid.get('Count');
  34638. total += count;
  34639. } else {
  34640. total++;
  34641. }
  34642. }));
  34643. }
  34644. if (!found) {
  34645. error('kid ref not found in parents kids');
  34646. }
  34647. return Promise.all(kidPromises).then(function () {
  34648. return [
  34649. total,
  34650. parentRef
  34651. ];
  34652. });
  34653. });
  34654. }
  34655. var total = 0;
  34656. function next(ref) {
  34657. return pagesBeforeRef(ref).then(function (args) {
  34658. if (!args) {
  34659. return total;
  34660. }
  34661. var count = args[0];
  34662. var parentRef = args[1];
  34663. total += count;
  34664. return next(parentRef);
  34665. });
  34666. }
  34667. return next(pageRef);
  34668. }
  34669. };
  34670. Catalog.parseDestDictionary = function Catalog_parseDestDictionary(params) {
  34671. function addDefaultProtocolToUrl(url) {
  34672. if (url.indexOf('www.') === 0) {
  34673. return 'http://' + url;
  34674. }
  34675. return url;
  34676. }
  34677. function tryConvertUrlEncoding(url) {
  34678. try {
  34679. return stringToUTF8String(url);
  34680. } catch (e) {
  34681. return url;
  34682. }
  34683. }
  34684. var destDict = params.destDict;
  34685. if (!isDict(destDict)) {
  34686. warn('Catalog_parseDestDictionary: "destDict" must be a dictionary.');
  34687. return;
  34688. }
  34689. var resultObj = params.resultObj;
  34690. if (typeof resultObj !== 'object') {
  34691. warn('Catalog_parseDestDictionary: "resultObj" must be an object.');
  34692. return;
  34693. }
  34694. var docBaseUrl = params.docBaseUrl || null;
  34695. var action = destDict.get('A'), url, dest;
  34696. if (isDict(action)) {
  34697. var linkType = action.get('S').name;
  34698. switch (linkType) {
  34699. case 'URI':
  34700. url = action.get('URI');
  34701. if (isName(url)) {
  34702. url = '/' + url.name;
  34703. } else if (isString(url)) {
  34704. url = addDefaultProtocolToUrl(url);
  34705. }
  34706. break;
  34707. case 'GoTo':
  34708. dest = action.get('D');
  34709. break;
  34710. case 'Launch':
  34711. case 'GoToR':
  34712. var urlDict = action.get('F');
  34713. if (isDict(urlDict)) {
  34714. url = urlDict.get('F') || null;
  34715. } else if (isString(urlDict)) {
  34716. url = urlDict;
  34717. }
  34718. var remoteDest = action.get('D');
  34719. if (remoteDest) {
  34720. if (isName(remoteDest)) {
  34721. remoteDest = remoteDest.name;
  34722. }
  34723. if (isString(url)) {
  34724. var baseUrl = url.split('#')[0];
  34725. if (isString(remoteDest)) {
  34726. url = baseUrl + '#' + (/^\d+$/.test(remoteDest) ? 'nameddest=' : '') + remoteDest;
  34727. } else if (isArray(remoteDest)) {
  34728. url = baseUrl + '#' + JSON.stringify(remoteDest);
  34729. }
  34730. }
  34731. }
  34732. var newWindow = action.get('NewWindow');
  34733. if (isBool(newWindow)) {
  34734. resultObj.newWindow = newWindow;
  34735. }
  34736. break;
  34737. case 'Named':
  34738. var namedAction = action.get('N');
  34739. if (isName(namedAction)) {
  34740. resultObj.action = namedAction.name;
  34741. }
  34742. break;
  34743. case 'JavaScript':
  34744. var jsAction = action.get('JS'), js;
  34745. if (isStream(jsAction)) {
  34746. js = bytesToString(jsAction.getBytes());
  34747. } else if (isString(jsAction)) {
  34748. js = jsAction;
  34749. }
  34750. if (js) {
  34751. var URL_OPEN_METHODS = [
  34752. 'app.launchURL',
  34753. 'window.open'
  34754. ];
  34755. var regex = new RegExp('^(?:' + URL_OPEN_METHODS.join('|') + ')' + '\\((?:\'|\")(\\S+)(?:\'|\")(?:,|\\))');
  34756. var jsUrl = regex.exec(stringToPDFString(js), 'i');
  34757. if (jsUrl && jsUrl[1]) {
  34758. url = jsUrl[1];
  34759. break;
  34760. }
  34761. }
  34762. default:
  34763. warn('Catalog_parseDestDictionary: Unrecognized link type "' + linkType + '".');
  34764. break;
  34765. }
  34766. } else if (destDict.has('Dest')) {
  34767. dest = destDict.get('Dest');
  34768. }
  34769. if (isString(url)) {
  34770. url = tryConvertUrlEncoding(url);
  34771. var absoluteUrl = createValidAbsoluteUrl(url, docBaseUrl);
  34772. if (absoluteUrl) {
  34773. resultObj.url = absoluteUrl.href;
  34774. }
  34775. resultObj.unsafeUrl = url;
  34776. }
  34777. if (dest) {
  34778. if (isName(dest)) {
  34779. dest = dest.name;
  34780. }
  34781. if (isString(dest) || isArray(dest)) {
  34782. resultObj.dest = dest;
  34783. }
  34784. }
  34785. };
  34786. return Catalog;
  34787. }();
  34788. var XRef = function XRefClosure() {
  34789. function XRef(stream, pdfManager) {
  34790. this.stream = stream;
  34791. this.pdfManager = pdfManager;
  34792. this.entries = [];
  34793. this.xrefstms = Object.create(null);
  34794. this.cache = [];
  34795. this.stats = {
  34796. streamTypes: [],
  34797. fontTypes: []
  34798. };
  34799. }
  34800. XRef.prototype = {
  34801. setStartXRef: function XRef_setStartXRef(startXRef) {
  34802. this.startXRefQueue = [startXRef];
  34803. },
  34804. parse: function XRef_parse(recoveryMode) {
  34805. var trailerDict;
  34806. if (!recoveryMode) {
  34807. trailerDict = this.readXRef();
  34808. } else {
  34809. warn('Indexing all PDF objects');
  34810. trailerDict = this.indexObjects();
  34811. }
  34812. trailerDict.assignXref(this);
  34813. this.trailer = trailerDict;
  34814. var encrypt = trailerDict.get('Encrypt');
  34815. if (isDict(encrypt)) {
  34816. var ids = trailerDict.get('ID');
  34817. var fileId = ids && ids.length ? ids[0] : '';
  34818. encrypt.suppressEncryption = true;
  34819. this.encrypt = new CipherTransformFactory(encrypt, fileId, this.pdfManager.password);
  34820. }
  34821. if (!(this.root = trailerDict.get('Root'))) {
  34822. error('Invalid root reference');
  34823. }
  34824. },
  34825. processXRefTable: function XRef_processXRefTable(parser) {
  34826. if (!('tableState' in this)) {
  34827. this.tableState = {
  34828. entryNum: 0,
  34829. streamPos: parser.lexer.stream.pos,
  34830. parserBuf1: parser.buf1,
  34831. parserBuf2: parser.buf2
  34832. };
  34833. }
  34834. var obj = this.readXRefTable(parser);
  34835. if (!isCmd(obj, 'trailer')) {
  34836. error('Invalid XRef table: could not find trailer dictionary');
  34837. }
  34838. var dict = parser.getObj();
  34839. if (!isDict(dict) && dict.dict) {
  34840. dict = dict.dict;
  34841. }
  34842. if (!isDict(dict)) {
  34843. error('Invalid XRef table: could not parse trailer dictionary');
  34844. }
  34845. delete this.tableState;
  34846. return dict;
  34847. },
  34848. readXRefTable: function XRef_readXRefTable(parser) {
  34849. var stream = parser.lexer.stream;
  34850. var tableState = this.tableState;
  34851. stream.pos = tableState.streamPos;
  34852. parser.buf1 = tableState.parserBuf1;
  34853. parser.buf2 = tableState.parserBuf2;
  34854. var obj;
  34855. while (true) {
  34856. if (!('firstEntryNum' in tableState) || !('entryCount' in tableState)) {
  34857. if (isCmd(obj = parser.getObj(), 'trailer')) {
  34858. break;
  34859. }
  34860. tableState.firstEntryNum = obj;
  34861. tableState.entryCount = parser.getObj();
  34862. }
  34863. var first = tableState.firstEntryNum;
  34864. var count = tableState.entryCount;
  34865. if (!isInt(first) || !isInt(count)) {
  34866. error('Invalid XRef table: wrong types in subsection header');
  34867. }
  34868. for (var i = tableState.entryNum; i < count; i++) {
  34869. tableState.streamPos = stream.pos;
  34870. tableState.entryNum = i;
  34871. tableState.parserBuf1 = parser.buf1;
  34872. tableState.parserBuf2 = parser.buf2;
  34873. var entry = {};
  34874. entry.offset = parser.getObj();
  34875. entry.gen = parser.getObj();
  34876. var type = parser.getObj();
  34877. if (isCmd(type, 'f')) {
  34878. entry.free = true;
  34879. } else if (isCmd(type, 'n')) {
  34880. entry.uncompressed = true;
  34881. }
  34882. if (!isInt(entry.offset) || !isInt(entry.gen) || !(entry.free || entry.uncompressed)) {
  34883. error('Invalid entry in XRef subsection: ' + first + ', ' + count);
  34884. }
  34885. if (i === 0 && entry.free && first === 1) {
  34886. first = 0;
  34887. }
  34888. if (!this.entries[i + first]) {
  34889. this.entries[i + first] = entry;
  34890. }
  34891. }
  34892. tableState.entryNum = 0;
  34893. tableState.streamPos = stream.pos;
  34894. tableState.parserBuf1 = parser.buf1;
  34895. tableState.parserBuf2 = parser.buf2;
  34896. delete tableState.firstEntryNum;
  34897. delete tableState.entryCount;
  34898. }
  34899. if (this.entries[0] && !this.entries[0].free) {
  34900. error('Invalid XRef table: unexpected first object');
  34901. }
  34902. return obj;
  34903. },
  34904. processXRefStream: function XRef_processXRefStream(stream) {
  34905. if (!('streamState' in this)) {
  34906. var streamParameters = stream.dict;
  34907. var byteWidths = streamParameters.get('W');
  34908. var range = streamParameters.get('Index');
  34909. if (!range) {
  34910. range = [
  34911. 0,
  34912. streamParameters.get('Size')
  34913. ];
  34914. }
  34915. this.streamState = {
  34916. entryRanges: range,
  34917. byteWidths: byteWidths,
  34918. entryNum: 0,
  34919. streamPos: stream.pos
  34920. };
  34921. }
  34922. this.readXRefStream(stream);
  34923. delete this.streamState;
  34924. return stream.dict;
  34925. },
  34926. readXRefStream: function XRef_readXRefStream(stream) {
  34927. var i, j;
  34928. var streamState = this.streamState;
  34929. stream.pos = streamState.streamPos;
  34930. var byteWidths = streamState.byteWidths;
  34931. var typeFieldWidth = byteWidths[0];
  34932. var offsetFieldWidth = byteWidths[1];
  34933. var generationFieldWidth = byteWidths[2];
  34934. var entryRanges = streamState.entryRanges;
  34935. while (entryRanges.length > 0) {
  34936. var first = entryRanges[0];
  34937. var n = entryRanges[1];
  34938. if (!isInt(first) || !isInt(n)) {
  34939. error('Invalid XRef range fields: ' + first + ', ' + n);
  34940. }
  34941. if (!isInt(typeFieldWidth) || !isInt(offsetFieldWidth) || !isInt(generationFieldWidth)) {
  34942. error('Invalid XRef entry fields length: ' + first + ', ' + n);
  34943. }
  34944. for (i = streamState.entryNum; i < n; ++i) {
  34945. streamState.entryNum = i;
  34946. streamState.streamPos = stream.pos;
  34947. var type = 0, offset = 0, generation = 0;
  34948. for (j = 0; j < typeFieldWidth; ++j) {
  34949. type = type << 8 | stream.getByte();
  34950. }
  34951. if (typeFieldWidth === 0) {
  34952. type = 1;
  34953. }
  34954. for (j = 0; j < offsetFieldWidth; ++j) {
  34955. offset = offset << 8 | stream.getByte();
  34956. }
  34957. for (j = 0; j < generationFieldWidth; ++j) {
  34958. generation = generation << 8 | stream.getByte();
  34959. }
  34960. var entry = {};
  34961. entry.offset = offset;
  34962. entry.gen = generation;
  34963. switch (type) {
  34964. case 0:
  34965. entry.free = true;
  34966. break;
  34967. case 1:
  34968. entry.uncompressed = true;
  34969. break;
  34970. case 2:
  34971. break;
  34972. default:
  34973. error('Invalid XRef entry type: ' + type);
  34974. }
  34975. if (!this.entries[first + i]) {
  34976. this.entries[first + i] = entry;
  34977. }
  34978. }
  34979. streamState.entryNum = 0;
  34980. streamState.streamPos = stream.pos;
  34981. entryRanges.splice(0, 2);
  34982. }
  34983. },
  34984. indexObjects: function XRef_indexObjects() {
  34985. var TAB = 0x9, LF = 0xA, CR = 0xD, SPACE = 0x20;
  34986. var PERCENT = 0x25, LT = 0x3C;
  34987. function readToken(data, offset) {
  34988. var token = '', ch = data[offset];
  34989. while (ch !== LF && ch !== CR && ch !== LT) {
  34990. if (++offset >= data.length) {
  34991. break;
  34992. }
  34993. token += String.fromCharCode(ch);
  34994. ch = data[offset];
  34995. }
  34996. return token;
  34997. }
  34998. function skipUntil(data, offset, what) {
  34999. var length = what.length, dataLength = data.length;
  35000. var skipped = 0;
  35001. while (offset < dataLength) {
  35002. var i = 0;
  35003. while (i < length && data[offset + i] === what[i]) {
  35004. ++i;
  35005. }
  35006. if (i >= length) {
  35007. break;
  35008. }
  35009. offset++;
  35010. skipped++;
  35011. }
  35012. return skipped;
  35013. }
  35014. var objRegExp = /^(\d+)\s+(\d+)\s+obj\b/;
  35015. var trailerBytes = new Uint8Array([
  35016. 116,
  35017. 114,
  35018. 97,
  35019. 105,
  35020. 108,
  35021. 101,
  35022. 114
  35023. ]);
  35024. var startxrefBytes = new Uint8Array([
  35025. 115,
  35026. 116,
  35027. 97,
  35028. 114,
  35029. 116,
  35030. 120,
  35031. 114,
  35032. 101,
  35033. 102
  35034. ]);
  35035. var endobjBytes = new Uint8Array([
  35036. 101,
  35037. 110,
  35038. 100,
  35039. 111,
  35040. 98,
  35041. 106
  35042. ]);
  35043. var xrefBytes = new Uint8Array([
  35044. 47,
  35045. 88,
  35046. 82,
  35047. 101,
  35048. 102
  35049. ]);
  35050. this.entries.length = 0;
  35051. var stream = this.stream;
  35052. stream.pos = 0;
  35053. var buffer = stream.getBytes();
  35054. var position = stream.start, length = buffer.length;
  35055. var trailers = [], xrefStms = [];
  35056. while (position < length) {
  35057. var ch = buffer[position];
  35058. if (ch === TAB || ch === LF || ch === CR || ch === SPACE) {
  35059. ++position;
  35060. continue;
  35061. }
  35062. if (ch === PERCENT) {
  35063. do {
  35064. ++position;
  35065. if (position >= length) {
  35066. break;
  35067. }
  35068. ch = buffer[position];
  35069. } while (ch !== LF && ch !== CR);
  35070. continue;
  35071. }
  35072. var token = readToken(buffer, position);
  35073. var m;
  35074. if (token.indexOf('xref') === 0 && (token.length === 4 || /\s/.test(token[4]))) {
  35075. position += skipUntil(buffer, position, trailerBytes);
  35076. trailers.push(position);
  35077. position += skipUntil(buffer, position, startxrefBytes);
  35078. } else if (m = objRegExp.exec(token)) {
  35079. if (typeof this.entries[m[1]] === 'undefined') {
  35080. this.entries[m[1]] = {
  35081. offset: position - stream.start,
  35082. gen: m[2] | 0,
  35083. uncompressed: true
  35084. };
  35085. }
  35086. var contentLength = skipUntil(buffer, position, endobjBytes) + 7;
  35087. var content = buffer.subarray(position, position + contentLength);
  35088. var xrefTagOffset = skipUntil(content, 0, xrefBytes);
  35089. if (xrefTagOffset < contentLength && content[xrefTagOffset + 5] < 64) {
  35090. xrefStms.push(position - stream.start);
  35091. this.xrefstms[position - stream.start] = 1;
  35092. }
  35093. position += contentLength;
  35094. } else if (token.indexOf('trailer') === 0 && (token.length === 7 || /\s/.test(token[7]))) {
  35095. trailers.push(position);
  35096. position += skipUntil(buffer, position, startxrefBytes);
  35097. } else {
  35098. position += token.length + 1;
  35099. }
  35100. }
  35101. var i, ii;
  35102. for (i = 0, ii = xrefStms.length; i < ii; ++i) {
  35103. this.startXRefQueue.push(xrefStms[i]);
  35104. this.readXRef(true);
  35105. }
  35106. var dict;
  35107. for (i = 0, ii = trailers.length; i < ii; ++i) {
  35108. stream.pos = trailers[i];
  35109. var parser = new Parser(new Lexer(stream), true, this, true);
  35110. var obj = parser.getObj();
  35111. if (!isCmd(obj, 'trailer')) {
  35112. continue;
  35113. }
  35114. dict = parser.getObj();
  35115. if (!isDict(dict)) {
  35116. continue;
  35117. }
  35118. if (dict.has('ID')) {
  35119. return dict;
  35120. }
  35121. }
  35122. if (dict) {
  35123. return dict;
  35124. }
  35125. throw new InvalidPDFException('Invalid PDF structure');
  35126. },
  35127. readXRef: function XRef_readXRef(recoveryMode) {
  35128. var stream = this.stream;
  35129. try {
  35130. while (this.startXRefQueue.length) {
  35131. var startXRef = this.startXRefQueue[0];
  35132. stream.pos = startXRef + stream.start;
  35133. var parser = new Parser(new Lexer(stream), true, this);
  35134. var obj = parser.getObj();
  35135. var dict;
  35136. if (isCmd(obj, 'xref')) {
  35137. dict = this.processXRefTable(parser);
  35138. if (!this.topDict) {
  35139. this.topDict = dict;
  35140. }
  35141. obj = dict.get('XRefStm');
  35142. if (isInt(obj)) {
  35143. var pos = obj;
  35144. if (!(pos in this.xrefstms)) {
  35145. this.xrefstms[pos] = 1;
  35146. this.startXRefQueue.push(pos);
  35147. }
  35148. }
  35149. } else if (isInt(obj)) {
  35150. if (!isInt(parser.getObj()) || !isCmd(parser.getObj(), 'obj') || !isStream(obj = parser.getObj())) {
  35151. error('Invalid XRef stream');
  35152. }
  35153. dict = this.processXRefStream(obj);
  35154. if (!this.topDict) {
  35155. this.topDict = dict;
  35156. }
  35157. if (!dict) {
  35158. error('Failed to read XRef stream');
  35159. }
  35160. } else {
  35161. error('Invalid XRef stream header');
  35162. }
  35163. obj = dict.get('Prev');
  35164. if (isInt(obj)) {
  35165. this.startXRefQueue.push(obj);
  35166. } else if (isRef(obj)) {
  35167. this.startXRefQueue.push(obj.num);
  35168. }
  35169. this.startXRefQueue.shift();
  35170. }
  35171. return this.topDict;
  35172. } catch (e) {
  35173. if (e instanceof MissingDataException) {
  35174. throw e;
  35175. }
  35176. info('(while reading XRef): ' + e);
  35177. }
  35178. if (recoveryMode) {
  35179. return;
  35180. }
  35181. throw new XRefParseException();
  35182. },
  35183. getEntry: function XRef_getEntry(i) {
  35184. var xrefEntry = this.entries[i];
  35185. if (xrefEntry && !xrefEntry.free && xrefEntry.offset) {
  35186. return xrefEntry;
  35187. }
  35188. return null;
  35189. },
  35190. fetchIfRef: function XRef_fetchIfRef(obj, suppressEncryption) {
  35191. if (!isRef(obj)) {
  35192. return obj;
  35193. }
  35194. return this.fetch(obj, suppressEncryption);
  35195. },
  35196. fetch: function XRef_fetch(ref, suppressEncryption) {
  35197. assert(isRef(ref), 'ref object is not a reference');
  35198. var num = ref.num;
  35199. if (num in this.cache) {
  35200. var cacheEntry = this.cache[num];
  35201. return cacheEntry;
  35202. }
  35203. var xrefEntry = this.getEntry(num);
  35204. if (xrefEntry === null) {
  35205. return this.cache[num] = null;
  35206. }
  35207. if (xrefEntry.uncompressed) {
  35208. xrefEntry = this.fetchUncompressed(ref, xrefEntry, suppressEncryption);
  35209. } else {
  35210. xrefEntry = this.fetchCompressed(xrefEntry, suppressEncryption);
  35211. }
  35212. if (isDict(xrefEntry)) {
  35213. xrefEntry.objId = ref.toString();
  35214. } else if (isStream(xrefEntry)) {
  35215. xrefEntry.dict.objId = ref.toString();
  35216. }
  35217. return xrefEntry;
  35218. },
  35219. fetchUncompressed: function XRef_fetchUncompressed(ref, xrefEntry, suppressEncryption) {
  35220. var gen = ref.gen;
  35221. var num = ref.num;
  35222. if (xrefEntry.gen !== gen) {
  35223. error('inconsistent generation in XRef');
  35224. }
  35225. var stream = this.stream.makeSubStream(xrefEntry.offset + this.stream.start);
  35226. var parser = new Parser(new Lexer(stream), true, this);
  35227. var obj1 = parser.getObj();
  35228. var obj2 = parser.getObj();
  35229. var obj3 = parser.getObj();
  35230. if (!isInt(obj1) || parseInt(obj1, 10) !== num || !isInt(obj2) || parseInt(obj2, 10) !== gen || !isCmd(obj3)) {
  35231. error('bad XRef entry');
  35232. }
  35233. if (!isCmd(obj3, 'obj')) {
  35234. if (obj3.cmd.indexOf('obj') === 0) {
  35235. num = parseInt(obj3.cmd.substring(3), 10);
  35236. if (!isNaN(num)) {
  35237. return num;
  35238. }
  35239. }
  35240. error('bad XRef entry');
  35241. }
  35242. if (this.encrypt && !suppressEncryption) {
  35243. xrefEntry = parser.getObj(this.encrypt.createCipherTransform(num, gen));
  35244. } else {
  35245. xrefEntry = parser.getObj();
  35246. }
  35247. if (!isStream(xrefEntry)) {
  35248. this.cache[num] = xrefEntry;
  35249. }
  35250. return xrefEntry;
  35251. },
  35252. fetchCompressed: function XRef_fetchCompressed(xrefEntry, suppressEncryption) {
  35253. var tableOffset = xrefEntry.offset;
  35254. var stream = this.fetch(new Ref(tableOffset, 0));
  35255. if (!isStream(stream)) {
  35256. error('bad ObjStm stream');
  35257. }
  35258. var first = stream.dict.get('First');
  35259. var n = stream.dict.get('N');
  35260. if (!isInt(first) || !isInt(n)) {
  35261. error('invalid first and n parameters for ObjStm stream');
  35262. }
  35263. var parser = new Parser(new Lexer(stream), false, this);
  35264. parser.allowStreams = true;
  35265. var i, entries = [], num, nums = [];
  35266. for (i = 0; i < n; ++i) {
  35267. num = parser.getObj();
  35268. if (!isInt(num)) {
  35269. error('invalid object number in the ObjStm stream: ' + num);
  35270. }
  35271. nums.push(num);
  35272. var offset = parser.getObj();
  35273. if (!isInt(offset)) {
  35274. error('invalid object offset in the ObjStm stream: ' + offset);
  35275. }
  35276. }
  35277. for (i = 0; i < n; ++i) {
  35278. entries.push(parser.getObj());
  35279. if (isCmd(parser.buf1, 'endobj')) {
  35280. parser.shift();
  35281. }
  35282. num = nums[i];
  35283. var entry = this.entries[num];
  35284. if (entry && entry.offset === tableOffset && entry.gen === i) {
  35285. this.cache[num] = entries[i];
  35286. }
  35287. }
  35288. xrefEntry = entries[xrefEntry.gen];
  35289. if (xrefEntry === undefined) {
  35290. error('bad XRef entry for compressed object');
  35291. }
  35292. return xrefEntry;
  35293. },
  35294. fetchIfRefAsync: function XRef_fetchIfRefAsync(obj, suppressEncryption) {
  35295. if (!isRef(obj)) {
  35296. return Promise.resolve(obj);
  35297. }
  35298. return this.fetchAsync(obj, suppressEncryption);
  35299. },
  35300. fetchAsync: function XRef_fetchAsync(ref, suppressEncryption) {
  35301. var streamManager = this.stream.manager;
  35302. var xref = this;
  35303. return new Promise(function tryFetch(resolve, reject) {
  35304. try {
  35305. resolve(xref.fetch(ref, suppressEncryption));
  35306. } catch (e) {
  35307. if (e instanceof MissingDataException) {
  35308. streamManager.requestRange(e.begin, e.end).then(function () {
  35309. tryFetch(resolve, reject);
  35310. }, reject);
  35311. return;
  35312. }
  35313. reject(e);
  35314. }
  35315. });
  35316. },
  35317. getCatalogObj: function XRef_getCatalogObj() {
  35318. return this.root;
  35319. }
  35320. };
  35321. return XRef;
  35322. }();
  35323. var NameOrNumberTree = function NameOrNumberTreeClosure() {
  35324. function NameOrNumberTree(root, xref) {
  35325. throw new Error('Cannot initialize NameOrNumberTree.');
  35326. }
  35327. NameOrNumberTree.prototype = {
  35328. getAll: function NameOrNumberTree_getAll() {
  35329. var dict = Object.create(null);
  35330. if (!this.root) {
  35331. return dict;
  35332. }
  35333. var xref = this.xref;
  35334. var processed = new RefSet();
  35335. processed.put(this.root);
  35336. var queue = [this.root];
  35337. while (queue.length > 0) {
  35338. var i, n;
  35339. var obj = xref.fetchIfRef(queue.shift());
  35340. if (!isDict(obj)) {
  35341. continue;
  35342. }
  35343. if (obj.has('Kids')) {
  35344. var kids = obj.get('Kids');
  35345. for (i = 0, n = kids.length; i < n; i++) {
  35346. var kid = kids[i];
  35347. assert(!processed.has(kid), 'Duplicate entry in "' + this._type + '" tree.');
  35348. queue.push(kid);
  35349. processed.put(kid);
  35350. }
  35351. continue;
  35352. }
  35353. var entries = obj.get(this._type);
  35354. if (isArray(entries)) {
  35355. for (i = 0, n = entries.length; i < n; i += 2) {
  35356. dict[xref.fetchIfRef(entries[i])] = xref.fetchIfRef(entries[i + 1]);
  35357. }
  35358. }
  35359. }
  35360. return dict;
  35361. },
  35362. get: function NameOrNumberTree_get(key) {
  35363. if (!this.root) {
  35364. return null;
  35365. }
  35366. var xref = this.xref;
  35367. var kidsOrEntries = xref.fetchIfRef(this.root);
  35368. var loopCount = 0;
  35369. var MAX_LEVELS = 10;
  35370. var l, r, m;
  35371. while (kidsOrEntries.has('Kids')) {
  35372. if (++loopCount > MAX_LEVELS) {
  35373. warn('Search depth limit reached for "' + this._type + '" tree.');
  35374. return null;
  35375. }
  35376. var kids = kidsOrEntries.get('Kids');
  35377. if (!isArray(kids)) {
  35378. return null;
  35379. }
  35380. l = 0;
  35381. r = kids.length - 1;
  35382. while (l <= r) {
  35383. m = l + r >> 1;
  35384. var kid = xref.fetchIfRef(kids[m]);
  35385. var limits = kid.get('Limits');
  35386. if (key < xref.fetchIfRef(limits[0])) {
  35387. r = m - 1;
  35388. } else if (key > xref.fetchIfRef(limits[1])) {
  35389. l = m + 1;
  35390. } else {
  35391. kidsOrEntries = xref.fetchIfRef(kids[m]);
  35392. break;
  35393. }
  35394. }
  35395. if (l > r) {
  35396. return null;
  35397. }
  35398. }
  35399. var entries = kidsOrEntries.get(this._type);
  35400. if (isArray(entries)) {
  35401. l = 0;
  35402. r = entries.length - 2;
  35403. while (l <= r) {
  35404. m = l + r & ~1;
  35405. var currentKey = xref.fetchIfRef(entries[m]);
  35406. if (key < currentKey) {
  35407. r = m - 2;
  35408. } else if (key > currentKey) {
  35409. l = m + 2;
  35410. } else {
  35411. return xref.fetchIfRef(entries[m + 1]);
  35412. }
  35413. }
  35414. }
  35415. return null;
  35416. }
  35417. };
  35418. return NameOrNumberTree;
  35419. }();
  35420. var NameTree = function NameTreeClosure() {
  35421. function NameTree(root, xref) {
  35422. this.root = root;
  35423. this.xref = xref;
  35424. this._type = 'Names';
  35425. }
  35426. Util.inherit(NameTree, NameOrNumberTree, {});
  35427. return NameTree;
  35428. }();
  35429. var NumberTree = function NumberTreeClosure() {
  35430. function NumberTree(root, xref) {
  35431. this.root = root;
  35432. this.xref = xref;
  35433. this._type = 'Nums';
  35434. }
  35435. Util.inherit(NumberTree, NameOrNumberTree, {});
  35436. return NumberTree;
  35437. }();
  35438. var FileSpec = function FileSpecClosure() {
  35439. function FileSpec(root, xref) {
  35440. if (!root || !isDict(root)) {
  35441. return;
  35442. }
  35443. this.xref = xref;
  35444. this.root = root;
  35445. if (root.has('FS')) {
  35446. this.fs = root.get('FS');
  35447. }
  35448. this.description = root.has('Desc') ? stringToPDFString(root.get('Desc')) : '';
  35449. if (root.has('RF')) {
  35450. warn('Related file specifications are not supported');
  35451. }
  35452. this.contentAvailable = true;
  35453. if (!root.has('EF')) {
  35454. this.contentAvailable = false;
  35455. warn('Non-embedded file specifications are not supported');
  35456. }
  35457. }
  35458. function pickPlatformItem(dict) {
  35459. if (dict.has('UF')) {
  35460. return dict.get('UF');
  35461. } else if (dict.has('F')) {
  35462. return dict.get('F');
  35463. } else if (dict.has('Unix')) {
  35464. return dict.get('Unix');
  35465. } else if (dict.has('Mac')) {
  35466. return dict.get('Mac');
  35467. } else if (dict.has('DOS')) {
  35468. return dict.get('DOS');
  35469. }
  35470. return null;
  35471. }
  35472. FileSpec.prototype = {
  35473. get filename() {
  35474. if (!this._filename && this.root) {
  35475. var filename = pickPlatformItem(this.root) || 'unnamed';
  35476. this._filename = stringToPDFString(filename).replace(/\\\\/g, '\\').replace(/\\\//g, '/').replace(/\\/g, '/');
  35477. }
  35478. return this._filename;
  35479. },
  35480. get content() {
  35481. if (!this.contentAvailable) {
  35482. return null;
  35483. }
  35484. if (!this.contentRef && this.root) {
  35485. this.contentRef = pickPlatformItem(this.root.get('EF'));
  35486. }
  35487. var content = null;
  35488. if (this.contentRef) {
  35489. var xref = this.xref;
  35490. var fileObj = xref.fetchIfRef(this.contentRef);
  35491. if (fileObj && isStream(fileObj)) {
  35492. content = fileObj.getBytes();
  35493. } else {
  35494. warn('Embedded file specification points to non-existing/invalid ' + 'content');
  35495. }
  35496. } else {
  35497. warn('Embedded file specification does not have a content');
  35498. }
  35499. return content;
  35500. },
  35501. get serializable() {
  35502. return {
  35503. filename: this.filename,
  35504. content: this.content
  35505. };
  35506. }
  35507. };
  35508. return FileSpec;
  35509. }();
  35510. var ObjectLoader = function () {
  35511. function mayHaveChildren(value) {
  35512. return isRef(value) || isDict(value) || isArray(value) || isStream(value);
  35513. }
  35514. function addChildren(node, nodesToVisit) {
  35515. var value;
  35516. if (isDict(node) || isStream(node)) {
  35517. var map;
  35518. if (isDict(node)) {
  35519. map = node.map;
  35520. } else {
  35521. map = node.dict.map;
  35522. }
  35523. for (var key in map) {
  35524. value = map[key];
  35525. if (mayHaveChildren(value)) {
  35526. nodesToVisit.push(value);
  35527. }
  35528. }
  35529. } else if (isArray(node)) {
  35530. for (var i = 0, ii = node.length; i < ii; i++) {
  35531. value = node[i];
  35532. if (mayHaveChildren(value)) {
  35533. nodesToVisit.push(value);
  35534. }
  35535. }
  35536. }
  35537. }
  35538. function ObjectLoader(obj, keys, xref) {
  35539. this.obj = obj;
  35540. this.keys = keys;
  35541. this.xref = xref;
  35542. this.refSet = null;
  35543. this.capability = null;
  35544. }
  35545. ObjectLoader.prototype = {
  35546. load: function ObjectLoader_load() {
  35547. var keys = this.keys;
  35548. this.capability = createPromiseCapability();
  35549. if (!(this.xref.stream instanceof ChunkedStream) || this.xref.stream.getMissingChunks().length === 0) {
  35550. this.capability.resolve();
  35551. return this.capability.promise;
  35552. }
  35553. this.refSet = new RefSet();
  35554. var nodesToVisit = [];
  35555. for (var i = 0; i < keys.length; i++) {
  35556. nodesToVisit.push(this.obj[keys[i]]);
  35557. }
  35558. this._walk(nodesToVisit);
  35559. return this.capability.promise;
  35560. },
  35561. _walk: function ObjectLoader_walk(nodesToVisit) {
  35562. var nodesToRevisit = [];
  35563. var pendingRequests = [];
  35564. while (nodesToVisit.length) {
  35565. var currentNode = nodesToVisit.pop();
  35566. if (isRef(currentNode)) {
  35567. if (this.refSet.has(currentNode)) {
  35568. continue;
  35569. }
  35570. try {
  35571. var ref = currentNode;
  35572. this.refSet.put(ref);
  35573. currentNode = this.xref.fetch(currentNode);
  35574. } catch (e) {
  35575. if (!(e instanceof MissingDataException)) {
  35576. throw e;
  35577. }
  35578. nodesToRevisit.push(currentNode);
  35579. pendingRequests.push({
  35580. begin: e.begin,
  35581. end: e.end
  35582. });
  35583. }
  35584. }
  35585. if (currentNode && currentNode.getBaseStreams) {
  35586. var baseStreams = currentNode.getBaseStreams();
  35587. var foundMissingData = false;
  35588. for (var i = 0; i < baseStreams.length; i++) {
  35589. var stream = baseStreams[i];
  35590. if (stream.getMissingChunks && stream.getMissingChunks().length) {
  35591. foundMissingData = true;
  35592. pendingRequests.push({
  35593. begin: stream.start,
  35594. end: stream.end
  35595. });
  35596. }
  35597. }
  35598. if (foundMissingData) {
  35599. nodesToRevisit.push(currentNode);
  35600. }
  35601. }
  35602. addChildren(currentNode, nodesToVisit);
  35603. }
  35604. if (pendingRequests.length) {
  35605. this.xref.stream.manager.requestRanges(pendingRequests).then(function pendingRequestCallback() {
  35606. nodesToVisit = nodesToRevisit;
  35607. for (var i = 0; i < nodesToRevisit.length; i++) {
  35608. var node = nodesToRevisit[i];
  35609. if (isRef(node)) {
  35610. this.refSet.remove(node);
  35611. }
  35612. }
  35613. this._walk(nodesToVisit);
  35614. }.bind(this), this.capability.reject);
  35615. return;
  35616. }
  35617. this.refSet = null;
  35618. this.capability.resolve();
  35619. }
  35620. };
  35621. return ObjectLoader;
  35622. }();
  35623. exports.Catalog = Catalog;
  35624. exports.ObjectLoader = ObjectLoader;
  35625. exports.XRef = XRef;
  35626. exports.FileSpec = FileSpec;
  35627. /***/ }),
  35628. /* 20 */
  35629. /***/ (function(module, exports, __w_pdfjs_require__) {
  35630. "use strict";
  35631. var sharedUtil = __w_pdfjs_require__(0);
  35632. var getLookupTableFactory = sharedUtil.getLookupTableFactory;
  35633. var getStdFontMap = getLookupTableFactory(function (t) {
  35634. t['ArialNarrow'] = 'Helvetica';
  35635. t['ArialNarrow-Bold'] = 'Helvetica-Bold';
  35636. t['ArialNarrow-BoldItalic'] = 'Helvetica-BoldOblique';
  35637. t['ArialNarrow-Italic'] = 'Helvetica-Oblique';
  35638. t['ArialBlack'] = 'Helvetica';
  35639. t['ArialBlack-Bold'] = 'Helvetica-Bold';
  35640. t['ArialBlack-BoldItalic'] = 'Helvetica-BoldOblique';
  35641. t['ArialBlack-Italic'] = 'Helvetica-Oblique';
  35642. t['Arial-Black'] = 'Helvetica';
  35643. t['Arial-Black-Bold'] = 'Helvetica-Bold';
  35644. t['Arial-Black-BoldItalic'] = 'Helvetica-BoldOblique';
  35645. t['Arial-Black-Italic'] = 'Helvetica-Oblique';
  35646. t['Arial'] = 'Helvetica';
  35647. t['Arial-Bold'] = 'Helvetica-Bold';
  35648. t['Arial-BoldItalic'] = 'Helvetica-BoldOblique';
  35649. t['Arial-Italic'] = 'Helvetica-Oblique';
  35650. t['Arial-BoldItalicMT'] = 'Helvetica-BoldOblique';
  35651. t['Arial-BoldMT'] = 'Helvetica-Bold';
  35652. t['Arial-ItalicMT'] = 'Helvetica-Oblique';
  35653. t['ArialMT'] = 'Helvetica';
  35654. t['Courier-Bold'] = 'Courier-Bold';
  35655. t['Courier-BoldItalic'] = 'Courier-BoldOblique';
  35656. t['Courier-Italic'] = 'Courier-Oblique';
  35657. t['CourierNew'] = 'Courier';
  35658. t['CourierNew-Bold'] = 'Courier-Bold';
  35659. t['CourierNew-BoldItalic'] = 'Courier-BoldOblique';
  35660. t['CourierNew-Italic'] = 'Courier-Oblique';
  35661. t['CourierNewPS-BoldItalicMT'] = 'Courier-BoldOblique';
  35662. t['CourierNewPS-BoldMT'] = 'Courier-Bold';
  35663. t['CourierNewPS-ItalicMT'] = 'Courier-Oblique';
  35664. t['CourierNewPSMT'] = 'Courier';
  35665. t['Helvetica'] = 'Helvetica';
  35666. t['Helvetica-Bold'] = 'Helvetica-Bold';
  35667. t['Helvetica-BoldItalic'] = 'Helvetica-BoldOblique';
  35668. t['Helvetica-BoldOblique'] = 'Helvetica-BoldOblique';
  35669. t['Helvetica-Italic'] = 'Helvetica-Oblique';
  35670. t['Helvetica-Oblique'] = 'Helvetica-Oblique';
  35671. t['Symbol-Bold'] = 'Symbol';
  35672. t['Symbol-BoldItalic'] = 'Symbol';
  35673. t['Symbol-Italic'] = 'Symbol';
  35674. t['TimesNewRoman'] = 'Times-Roman';
  35675. t['TimesNewRoman-Bold'] = 'Times-Bold';
  35676. t['TimesNewRoman-BoldItalic'] = 'Times-BoldItalic';
  35677. t['TimesNewRoman-Italic'] = 'Times-Italic';
  35678. t['TimesNewRomanPS'] = 'Times-Roman';
  35679. t['TimesNewRomanPS-Bold'] = 'Times-Bold';
  35680. t['TimesNewRomanPS-BoldItalic'] = 'Times-BoldItalic';
  35681. t['TimesNewRomanPS-BoldItalicMT'] = 'Times-BoldItalic';
  35682. t['TimesNewRomanPS-BoldMT'] = 'Times-Bold';
  35683. t['TimesNewRomanPS-Italic'] = 'Times-Italic';
  35684. t['TimesNewRomanPS-ItalicMT'] = 'Times-Italic';
  35685. t['TimesNewRomanPSMT'] = 'Times-Roman';
  35686. t['TimesNewRomanPSMT-Bold'] = 'Times-Bold';
  35687. t['TimesNewRomanPSMT-BoldItalic'] = 'Times-BoldItalic';
  35688. t['TimesNewRomanPSMT-Italic'] = 'Times-Italic';
  35689. });
  35690. var getNonStdFontMap = getLookupTableFactory(function (t) {
  35691. t['CenturyGothic'] = 'Helvetica';
  35692. t['CenturyGothic-Bold'] = 'Helvetica-Bold';
  35693. t['CenturyGothic-BoldItalic'] = 'Helvetica-BoldOblique';
  35694. t['CenturyGothic-Italic'] = 'Helvetica-Oblique';
  35695. t['ComicSansMS'] = 'Comic Sans MS';
  35696. t['ComicSansMS-Bold'] = 'Comic Sans MS-Bold';
  35697. t['ComicSansMS-BoldItalic'] = 'Comic Sans MS-BoldItalic';
  35698. t['ComicSansMS-Italic'] = 'Comic Sans MS-Italic';
  35699. t['LucidaConsole'] = 'Courier';
  35700. t['LucidaConsole-Bold'] = 'Courier-Bold';
  35701. t['LucidaConsole-BoldItalic'] = 'Courier-BoldOblique';
  35702. t['LucidaConsole-Italic'] = 'Courier-Oblique';
  35703. t['MS-Gothic'] = 'MS Gothic';
  35704. t['MS-Gothic-Bold'] = 'MS Gothic-Bold';
  35705. t['MS-Gothic-BoldItalic'] = 'MS Gothic-BoldItalic';
  35706. t['MS-Gothic-Italic'] = 'MS Gothic-Italic';
  35707. t['MS-Mincho'] = 'MS Mincho';
  35708. t['MS-Mincho-Bold'] = 'MS Mincho-Bold';
  35709. t['MS-Mincho-BoldItalic'] = 'MS Mincho-BoldItalic';
  35710. t['MS-Mincho-Italic'] = 'MS Mincho-Italic';
  35711. t['MS-PGothic'] = 'MS PGothic';
  35712. t['MS-PGothic-Bold'] = 'MS PGothic-Bold';
  35713. t['MS-PGothic-BoldItalic'] = 'MS PGothic-BoldItalic';
  35714. t['MS-PGothic-Italic'] = 'MS PGothic-Italic';
  35715. t['MS-PMincho'] = 'MS PMincho';
  35716. t['MS-PMincho-Bold'] = 'MS PMincho-Bold';
  35717. t['MS-PMincho-BoldItalic'] = 'MS PMincho-BoldItalic';
  35718. t['MS-PMincho-Italic'] = 'MS PMincho-Italic';
  35719. t['NuptialScript'] = 'Times-Italic';
  35720. t['Wingdings'] = 'ZapfDingbats';
  35721. });
  35722. var getSerifFonts = getLookupTableFactory(function (t) {
  35723. t['Adobe Jenson'] = true;
  35724. t['Adobe Text'] = true;
  35725. t['Albertus'] = true;
  35726. t['Aldus'] = true;
  35727. t['Alexandria'] = true;
  35728. t['Algerian'] = true;
  35729. t['American Typewriter'] = true;
  35730. t['Antiqua'] = true;
  35731. t['Apex'] = true;
  35732. t['Arno'] = true;
  35733. t['Aster'] = true;
  35734. t['Aurora'] = true;
  35735. t['Baskerville'] = true;
  35736. t['Bell'] = true;
  35737. t['Bembo'] = true;
  35738. t['Bembo Schoolbook'] = true;
  35739. t['Benguiat'] = true;
  35740. t['Berkeley Old Style'] = true;
  35741. t['Bernhard Modern'] = true;
  35742. t['Berthold City'] = true;
  35743. t['Bodoni'] = true;
  35744. t['Bauer Bodoni'] = true;
  35745. t['Book Antiqua'] = true;
  35746. t['Bookman'] = true;
  35747. t['Bordeaux Roman'] = true;
  35748. t['Californian FB'] = true;
  35749. t['Calisto'] = true;
  35750. t['Calvert'] = true;
  35751. t['Capitals'] = true;
  35752. t['Cambria'] = true;
  35753. t['Cartier'] = true;
  35754. t['Caslon'] = true;
  35755. t['Catull'] = true;
  35756. t['Centaur'] = true;
  35757. t['Century Old Style'] = true;
  35758. t['Century Schoolbook'] = true;
  35759. t['Chaparral'] = true;
  35760. t['Charis SIL'] = true;
  35761. t['Cheltenham'] = true;
  35762. t['Cholla Slab'] = true;
  35763. t['Clarendon'] = true;
  35764. t['Clearface'] = true;
  35765. t['Cochin'] = true;
  35766. t['Colonna'] = true;
  35767. t['Computer Modern'] = true;
  35768. t['Concrete Roman'] = true;
  35769. t['Constantia'] = true;
  35770. t['Cooper Black'] = true;
  35771. t['Corona'] = true;
  35772. t['Ecotype'] = true;
  35773. t['Egyptienne'] = true;
  35774. t['Elephant'] = true;
  35775. t['Excelsior'] = true;
  35776. t['Fairfield'] = true;
  35777. t['FF Scala'] = true;
  35778. t['Folkard'] = true;
  35779. t['Footlight'] = true;
  35780. t['FreeSerif'] = true;
  35781. t['Friz Quadrata'] = true;
  35782. t['Garamond'] = true;
  35783. t['Gentium'] = true;
  35784. t['Georgia'] = true;
  35785. t['Gloucester'] = true;
  35786. t['Goudy Old Style'] = true;
  35787. t['Goudy Schoolbook'] = true;
  35788. t['Goudy Pro Font'] = true;
  35789. t['Granjon'] = true;
  35790. t['Guardian Egyptian'] = true;
  35791. t['Heather'] = true;
  35792. t['Hercules'] = true;
  35793. t['High Tower Text'] = true;
  35794. t['Hiroshige'] = true;
  35795. t['Hoefler Text'] = true;
  35796. t['Humana Serif'] = true;
  35797. t['Imprint'] = true;
  35798. t['Ionic No. 5'] = true;
  35799. t['Janson'] = true;
  35800. t['Joanna'] = true;
  35801. t['Korinna'] = true;
  35802. t['Lexicon'] = true;
  35803. t['Liberation Serif'] = true;
  35804. t['Linux Libertine'] = true;
  35805. t['Literaturnaya'] = true;
  35806. t['Lucida'] = true;
  35807. t['Lucida Bright'] = true;
  35808. t['Melior'] = true;
  35809. t['Memphis'] = true;
  35810. t['Miller'] = true;
  35811. t['Minion'] = true;
  35812. t['Modern'] = true;
  35813. t['Mona Lisa'] = true;
  35814. t['Mrs Eaves'] = true;
  35815. t['MS Serif'] = true;
  35816. t['Museo Slab'] = true;
  35817. t['New York'] = true;
  35818. t['Nimbus Roman'] = true;
  35819. t['NPS Rawlinson Roadway'] = true;
  35820. t['NuptialScript'] = true;
  35821. t['Palatino'] = true;
  35822. t['Perpetua'] = true;
  35823. t['Plantin'] = true;
  35824. t['Plantin Schoolbook'] = true;
  35825. t['Playbill'] = true;
  35826. t['Poor Richard'] = true;
  35827. t['Rawlinson Roadway'] = true;
  35828. t['Renault'] = true;
  35829. t['Requiem'] = true;
  35830. t['Rockwell'] = true;
  35831. t['Roman'] = true;
  35832. t['Rotis Serif'] = true;
  35833. t['Sabon'] = true;
  35834. t['Scala'] = true;
  35835. t['Seagull'] = true;
  35836. t['Sistina'] = true;
  35837. t['Souvenir'] = true;
  35838. t['STIX'] = true;
  35839. t['Stone Informal'] = true;
  35840. t['Stone Serif'] = true;
  35841. t['Sylfaen'] = true;
  35842. t['Times'] = true;
  35843. t['Trajan'] = true;
  35844. t['Trinité'] = true;
  35845. t['Trump Mediaeval'] = true;
  35846. t['Utopia'] = true;
  35847. t['Vale Type'] = true;
  35848. t['Bitstream Vera'] = true;
  35849. t['Vera Serif'] = true;
  35850. t['Versailles'] = true;
  35851. t['Wanted'] = true;
  35852. t['Weiss'] = true;
  35853. t['Wide Latin'] = true;
  35854. t['Windsor'] = true;
  35855. t['XITS'] = true;
  35856. });
  35857. var getSymbolsFonts = getLookupTableFactory(function (t) {
  35858. t['Dingbats'] = true;
  35859. t['Symbol'] = true;
  35860. t['ZapfDingbats'] = true;
  35861. });
  35862. var getGlyphMapForStandardFonts = getLookupTableFactory(function (t) {
  35863. t[2] = 10;
  35864. t[3] = 32;
  35865. t[4] = 33;
  35866. t[5] = 34;
  35867. t[6] = 35;
  35868. t[7] = 36;
  35869. t[8] = 37;
  35870. t[9] = 38;
  35871. t[10] = 39;
  35872. t[11] = 40;
  35873. t[12] = 41;
  35874. t[13] = 42;
  35875. t[14] = 43;
  35876. t[15] = 44;
  35877. t[16] = 45;
  35878. t[17] = 46;
  35879. t[18] = 47;
  35880. t[19] = 48;
  35881. t[20] = 49;
  35882. t[21] = 50;
  35883. t[22] = 51;
  35884. t[23] = 52;
  35885. t[24] = 53;
  35886. t[25] = 54;
  35887. t[26] = 55;
  35888. t[27] = 56;
  35889. t[28] = 57;
  35890. t[29] = 58;
  35891. t[30] = 894;
  35892. t[31] = 60;
  35893. t[32] = 61;
  35894. t[33] = 62;
  35895. t[34] = 63;
  35896. t[35] = 64;
  35897. t[36] = 65;
  35898. t[37] = 66;
  35899. t[38] = 67;
  35900. t[39] = 68;
  35901. t[40] = 69;
  35902. t[41] = 70;
  35903. t[42] = 71;
  35904. t[43] = 72;
  35905. t[44] = 73;
  35906. t[45] = 74;
  35907. t[46] = 75;
  35908. t[47] = 76;
  35909. t[48] = 77;
  35910. t[49] = 78;
  35911. t[50] = 79;
  35912. t[51] = 80;
  35913. t[52] = 81;
  35914. t[53] = 82;
  35915. t[54] = 83;
  35916. t[55] = 84;
  35917. t[56] = 85;
  35918. t[57] = 86;
  35919. t[58] = 87;
  35920. t[59] = 88;
  35921. t[60] = 89;
  35922. t[61] = 90;
  35923. t[62] = 91;
  35924. t[63] = 92;
  35925. t[64] = 93;
  35926. t[65] = 94;
  35927. t[66] = 95;
  35928. t[67] = 96;
  35929. t[68] = 97;
  35930. t[69] = 98;
  35931. t[70] = 99;
  35932. t[71] = 100;
  35933. t[72] = 101;
  35934. t[73] = 102;
  35935. t[74] = 103;
  35936. t[75] = 104;
  35937. t[76] = 105;
  35938. t[77] = 106;
  35939. t[78] = 107;
  35940. t[79] = 108;
  35941. t[80] = 109;
  35942. t[81] = 110;
  35943. t[82] = 111;
  35944. t[83] = 112;
  35945. t[84] = 113;
  35946. t[85] = 114;
  35947. t[86] = 115;
  35948. t[87] = 116;
  35949. t[88] = 117;
  35950. t[89] = 118;
  35951. t[90] = 119;
  35952. t[91] = 120;
  35953. t[92] = 121;
  35954. t[93] = 122;
  35955. t[94] = 123;
  35956. t[95] = 124;
  35957. t[96] = 125;
  35958. t[97] = 126;
  35959. t[98] = 196;
  35960. t[99] = 197;
  35961. t[100] = 199;
  35962. t[101] = 201;
  35963. t[102] = 209;
  35964. t[103] = 214;
  35965. t[104] = 220;
  35966. t[105] = 225;
  35967. t[106] = 224;
  35968. t[107] = 226;
  35969. t[108] = 228;
  35970. t[109] = 227;
  35971. t[110] = 229;
  35972. t[111] = 231;
  35973. t[112] = 233;
  35974. t[113] = 232;
  35975. t[114] = 234;
  35976. t[115] = 235;
  35977. t[116] = 237;
  35978. t[117] = 236;
  35979. t[118] = 238;
  35980. t[119] = 239;
  35981. t[120] = 241;
  35982. t[121] = 243;
  35983. t[122] = 242;
  35984. t[123] = 244;
  35985. t[124] = 246;
  35986. t[125] = 245;
  35987. t[126] = 250;
  35988. t[127] = 249;
  35989. t[128] = 251;
  35990. t[129] = 252;
  35991. t[130] = 8224;
  35992. t[131] = 176;
  35993. t[132] = 162;
  35994. t[133] = 163;
  35995. t[134] = 167;
  35996. t[135] = 8226;
  35997. t[136] = 182;
  35998. t[137] = 223;
  35999. t[138] = 174;
  36000. t[139] = 169;
  36001. t[140] = 8482;
  36002. t[141] = 180;
  36003. t[142] = 168;
  36004. t[143] = 8800;
  36005. t[144] = 198;
  36006. t[145] = 216;
  36007. t[146] = 8734;
  36008. t[147] = 177;
  36009. t[148] = 8804;
  36010. t[149] = 8805;
  36011. t[150] = 165;
  36012. t[151] = 181;
  36013. t[152] = 8706;
  36014. t[153] = 8721;
  36015. t[154] = 8719;
  36016. t[156] = 8747;
  36017. t[157] = 170;
  36018. t[158] = 186;
  36019. t[159] = 8486;
  36020. t[160] = 230;
  36021. t[161] = 248;
  36022. t[162] = 191;
  36023. t[163] = 161;
  36024. t[164] = 172;
  36025. t[165] = 8730;
  36026. t[166] = 402;
  36027. t[167] = 8776;
  36028. t[168] = 8710;
  36029. t[169] = 171;
  36030. t[170] = 187;
  36031. t[171] = 8230;
  36032. t[210] = 218;
  36033. t[223] = 711;
  36034. t[224] = 321;
  36035. t[225] = 322;
  36036. t[227] = 353;
  36037. t[229] = 382;
  36038. t[234] = 253;
  36039. t[252] = 263;
  36040. t[253] = 268;
  36041. t[254] = 269;
  36042. t[258] = 258;
  36043. t[260] = 260;
  36044. t[261] = 261;
  36045. t[265] = 280;
  36046. t[266] = 281;
  36047. t[268] = 283;
  36048. t[269] = 313;
  36049. t[275] = 323;
  36050. t[276] = 324;
  36051. t[278] = 328;
  36052. t[284] = 345;
  36053. t[285] = 346;
  36054. t[286] = 347;
  36055. t[292] = 367;
  36056. t[295] = 377;
  36057. t[296] = 378;
  36058. t[298] = 380;
  36059. t[305] = 963;
  36060. t[306] = 964;
  36061. t[307] = 966;
  36062. t[308] = 8215;
  36063. t[309] = 8252;
  36064. t[310] = 8319;
  36065. t[311] = 8359;
  36066. t[312] = 8592;
  36067. t[313] = 8593;
  36068. t[337] = 9552;
  36069. t[493] = 1039;
  36070. t[494] = 1040;
  36071. t[705] = 1524;
  36072. t[706] = 8362;
  36073. t[710] = 64288;
  36074. t[711] = 64298;
  36075. t[759] = 1617;
  36076. t[761] = 1776;
  36077. t[763] = 1778;
  36078. t[775] = 1652;
  36079. t[777] = 1764;
  36080. t[778] = 1780;
  36081. t[779] = 1781;
  36082. t[780] = 1782;
  36083. t[782] = 771;
  36084. t[783] = 64726;
  36085. t[786] = 8363;
  36086. t[788] = 8532;
  36087. t[790] = 768;
  36088. t[791] = 769;
  36089. t[792] = 768;
  36090. t[795] = 803;
  36091. t[797] = 64336;
  36092. t[798] = 64337;
  36093. t[799] = 64342;
  36094. t[800] = 64343;
  36095. t[801] = 64344;
  36096. t[802] = 64345;
  36097. t[803] = 64362;
  36098. t[804] = 64363;
  36099. t[805] = 64364;
  36100. t[2424] = 7821;
  36101. t[2425] = 7822;
  36102. t[2426] = 7823;
  36103. t[2427] = 7824;
  36104. t[2428] = 7825;
  36105. t[2429] = 7826;
  36106. t[2430] = 7827;
  36107. t[2433] = 7682;
  36108. t[2678] = 8045;
  36109. t[2679] = 8046;
  36110. t[2830] = 1552;
  36111. t[2838] = 686;
  36112. t[2840] = 751;
  36113. t[2842] = 753;
  36114. t[2843] = 754;
  36115. t[2844] = 755;
  36116. t[2846] = 757;
  36117. t[2856] = 767;
  36118. t[2857] = 848;
  36119. t[2858] = 849;
  36120. t[2862] = 853;
  36121. t[2863] = 854;
  36122. t[2864] = 855;
  36123. t[2865] = 861;
  36124. t[2866] = 862;
  36125. t[2906] = 7460;
  36126. t[2908] = 7462;
  36127. t[2909] = 7463;
  36128. t[2910] = 7464;
  36129. t[2912] = 7466;
  36130. t[2913] = 7467;
  36131. t[2914] = 7468;
  36132. t[2916] = 7470;
  36133. t[2917] = 7471;
  36134. t[2918] = 7472;
  36135. t[2920] = 7474;
  36136. t[2921] = 7475;
  36137. t[2922] = 7476;
  36138. t[2924] = 7478;
  36139. t[2925] = 7479;
  36140. t[2926] = 7480;
  36141. t[2928] = 7482;
  36142. t[2929] = 7483;
  36143. t[2930] = 7484;
  36144. t[2932] = 7486;
  36145. t[2933] = 7487;
  36146. t[2934] = 7488;
  36147. t[2936] = 7490;
  36148. t[2937] = 7491;
  36149. t[2938] = 7492;
  36150. t[2940] = 7494;
  36151. t[2941] = 7495;
  36152. t[2942] = 7496;
  36153. t[2944] = 7498;
  36154. t[2946] = 7500;
  36155. t[2948] = 7502;
  36156. t[2950] = 7504;
  36157. t[2951] = 7505;
  36158. t[2952] = 7506;
  36159. t[2954] = 7508;
  36160. t[2955] = 7509;
  36161. t[2956] = 7510;
  36162. t[2958] = 7512;
  36163. t[2959] = 7513;
  36164. t[2960] = 7514;
  36165. t[2962] = 7516;
  36166. t[2963] = 7517;
  36167. t[2964] = 7518;
  36168. t[2966] = 7520;
  36169. t[2967] = 7521;
  36170. t[2968] = 7522;
  36171. t[2970] = 7524;
  36172. t[2971] = 7525;
  36173. t[2972] = 7526;
  36174. t[2974] = 7528;
  36175. t[2975] = 7529;
  36176. t[2976] = 7530;
  36177. t[2978] = 1537;
  36178. t[2979] = 1538;
  36179. t[2980] = 1539;
  36180. t[2982] = 1549;
  36181. t[2983] = 1551;
  36182. t[2984] = 1552;
  36183. t[2986] = 1554;
  36184. t[2987] = 1555;
  36185. t[2988] = 1556;
  36186. t[2990] = 1623;
  36187. t[2991] = 1624;
  36188. t[2995] = 1775;
  36189. t[2999] = 1791;
  36190. t[3002] = 64290;
  36191. t[3003] = 64291;
  36192. t[3004] = 64292;
  36193. t[3006] = 64294;
  36194. t[3007] = 64295;
  36195. t[3008] = 64296;
  36196. t[3011] = 1900;
  36197. t[3014] = 8223;
  36198. t[3015] = 8244;
  36199. t[3017] = 7532;
  36200. t[3018] = 7533;
  36201. t[3019] = 7534;
  36202. t[3075] = 7590;
  36203. t[3076] = 7591;
  36204. t[3079] = 7594;
  36205. t[3080] = 7595;
  36206. t[3083] = 7598;
  36207. t[3084] = 7599;
  36208. t[3087] = 7602;
  36209. t[3088] = 7603;
  36210. t[3091] = 7606;
  36211. t[3092] = 7607;
  36212. t[3095] = 7610;
  36213. t[3096] = 7611;
  36214. t[3099] = 7614;
  36215. t[3100] = 7615;
  36216. t[3103] = 7618;
  36217. t[3104] = 7619;
  36218. t[3107] = 8337;
  36219. t[3108] = 8338;
  36220. t[3116] = 1884;
  36221. t[3119] = 1885;
  36222. t[3120] = 1885;
  36223. t[3123] = 1886;
  36224. t[3124] = 1886;
  36225. t[3127] = 1887;
  36226. t[3128] = 1887;
  36227. t[3131] = 1888;
  36228. t[3132] = 1888;
  36229. t[3135] = 1889;
  36230. t[3136] = 1889;
  36231. t[3139] = 1890;
  36232. t[3140] = 1890;
  36233. t[3143] = 1891;
  36234. t[3144] = 1891;
  36235. t[3147] = 1892;
  36236. t[3148] = 1892;
  36237. t[3153] = 580;
  36238. t[3154] = 581;
  36239. t[3157] = 584;
  36240. t[3158] = 585;
  36241. t[3161] = 588;
  36242. t[3162] = 589;
  36243. t[3165] = 891;
  36244. t[3166] = 892;
  36245. t[3169] = 1274;
  36246. t[3170] = 1275;
  36247. t[3173] = 1278;
  36248. t[3174] = 1279;
  36249. t[3181] = 7622;
  36250. t[3182] = 7623;
  36251. t[3282] = 11799;
  36252. t[3316] = 578;
  36253. t[3379] = 42785;
  36254. t[3393] = 1159;
  36255. t[3416] = 8377;
  36256. });
  36257. var getSupplementalGlyphMapForArialBlack = getLookupTableFactory(function (t) {
  36258. t[227] = 322;
  36259. t[264] = 261;
  36260. t[291] = 346;
  36261. });
  36262. exports.getStdFontMap = getStdFontMap;
  36263. exports.getNonStdFontMap = getNonStdFontMap;
  36264. exports.getSerifFonts = getSerifFonts;
  36265. exports.getSymbolsFonts = getSymbolsFonts;
  36266. exports.getGlyphMapForStandardFonts = getGlyphMapForStandardFonts;
  36267. exports.getSupplementalGlyphMapForArialBlack = getSupplementalGlyphMapForArialBlack;
  36268. /***/ }),
  36269. /* 21 */
  36270. /***/ (function(module, exports, __w_pdfjs_require__) {
  36271. "use strict";
  36272. var sharedUtil = __w_pdfjs_require__(0);
  36273. var getLookupTableFactory = sharedUtil.getLookupTableFactory;
  36274. var getSpecialPUASymbols = getLookupTableFactory(function (t) {
  36275. t[63721] = 0x00A9;
  36276. t[63193] = 0x00A9;
  36277. t[63720] = 0x00AE;
  36278. t[63194] = 0x00AE;
  36279. t[63722] = 0x2122;
  36280. t[63195] = 0x2122;
  36281. t[63729] = 0x23A7;
  36282. t[63730] = 0x23A8;
  36283. t[63731] = 0x23A9;
  36284. t[63740] = 0x23AB;
  36285. t[63741] = 0x23AC;
  36286. t[63742] = 0x23AD;
  36287. t[63726] = 0x23A1;
  36288. t[63727] = 0x23A2;
  36289. t[63728] = 0x23A3;
  36290. t[63737] = 0x23A4;
  36291. t[63738] = 0x23A5;
  36292. t[63739] = 0x23A6;
  36293. t[63723] = 0x239B;
  36294. t[63724] = 0x239C;
  36295. t[63725] = 0x239D;
  36296. t[63734] = 0x239E;
  36297. t[63735] = 0x239F;
  36298. t[63736] = 0x23A0;
  36299. });
  36300. function mapSpecialUnicodeValues(code) {
  36301. if (code >= 0xFFF0 && code <= 0xFFFF) {
  36302. return 0;
  36303. } else if (code >= 0xF600 && code <= 0xF8FF) {
  36304. return getSpecialPUASymbols()[code] || code;
  36305. }
  36306. return code;
  36307. }
  36308. function getUnicodeForGlyph(name, glyphsUnicodeMap) {
  36309. var unicode = glyphsUnicodeMap[name];
  36310. if (unicode !== undefined) {
  36311. return unicode;
  36312. }
  36313. if (!name) {
  36314. return -1;
  36315. }
  36316. if (name[0] === 'u') {
  36317. var nameLen = name.length, hexStr;
  36318. if (nameLen === 7 && name[1] === 'n' && name[2] === 'i') {
  36319. hexStr = name.substr(3);
  36320. } else if (nameLen >= 5 && nameLen <= 7) {
  36321. hexStr = name.substr(1);
  36322. } else {
  36323. return -1;
  36324. }
  36325. if (hexStr === hexStr.toUpperCase()) {
  36326. unicode = parseInt(hexStr, 16);
  36327. if (unicode >= 0) {
  36328. return unicode;
  36329. }
  36330. }
  36331. }
  36332. return -1;
  36333. }
  36334. var UnicodeRanges = [
  36335. {
  36336. 'begin': 0x0000,
  36337. 'end': 0x007F
  36338. },
  36339. {
  36340. 'begin': 0x0080,
  36341. 'end': 0x00FF
  36342. },
  36343. {
  36344. 'begin': 0x0100,
  36345. 'end': 0x017F
  36346. },
  36347. {
  36348. 'begin': 0x0180,
  36349. 'end': 0x024F
  36350. },
  36351. {
  36352. 'begin': 0x0250,
  36353. 'end': 0x02AF
  36354. },
  36355. {
  36356. 'begin': 0x02B0,
  36357. 'end': 0x02FF
  36358. },
  36359. {
  36360. 'begin': 0x0300,
  36361. 'end': 0x036F
  36362. },
  36363. {
  36364. 'begin': 0x0370,
  36365. 'end': 0x03FF
  36366. },
  36367. {
  36368. 'begin': 0x2C80,
  36369. 'end': 0x2CFF
  36370. },
  36371. {
  36372. 'begin': 0x0400,
  36373. 'end': 0x04FF
  36374. },
  36375. {
  36376. 'begin': 0x0530,
  36377. 'end': 0x058F
  36378. },
  36379. {
  36380. 'begin': 0x0590,
  36381. 'end': 0x05FF
  36382. },
  36383. {
  36384. 'begin': 0xA500,
  36385. 'end': 0xA63F
  36386. },
  36387. {
  36388. 'begin': 0x0600,
  36389. 'end': 0x06FF
  36390. },
  36391. {
  36392. 'begin': 0x07C0,
  36393. 'end': 0x07FF
  36394. },
  36395. {
  36396. 'begin': 0x0900,
  36397. 'end': 0x097F
  36398. },
  36399. {
  36400. 'begin': 0x0980,
  36401. 'end': 0x09FF
  36402. },
  36403. {
  36404. 'begin': 0x0A00,
  36405. 'end': 0x0A7F
  36406. },
  36407. {
  36408. 'begin': 0x0A80,
  36409. 'end': 0x0AFF
  36410. },
  36411. {
  36412. 'begin': 0x0B00,
  36413. 'end': 0x0B7F
  36414. },
  36415. {
  36416. 'begin': 0x0B80,
  36417. 'end': 0x0BFF
  36418. },
  36419. {
  36420. 'begin': 0x0C00,
  36421. 'end': 0x0C7F
  36422. },
  36423. {
  36424. 'begin': 0x0C80,
  36425. 'end': 0x0CFF
  36426. },
  36427. {
  36428. 'begin': 0x0D00,
  36429. 'end': 0x0D7F
  36430. },
  36431. {
  36432. 'begin': 0x0E00,
  36433. 'end': 0x0E7F
  36434. },
  36435. {
  36436. 'begin': 0x0E80,
  36437. 'end': 0x0EFF
  36438. },
  36439. {
  36440. 'begin': 0x10A0,
  36441. 'end': 0x10FF
  36442. },
  36443. {
  36444. 'begin': 0x1B00,
  36445. 'end': 0x1B7F
  36446. },
  36447. {
  36448. 'begin': 0x1100,
  36449. 'end': 0x11FF
  36450. },
  36451. {
  36452. 'begin': 0x1E00,
  36453. 'end': 0x1EFF
  36454. },
  36455. {
  36456. 'begin': 0x1F00,
  36457. 'end': 0x1FFF
  36458. },
  36459. {
  36460. 'begin': 0x2000,
  36461. 'end': 0x206F
  36462. },
  36463. {
  36464. 'begin': 0x2070,
  36465. 'end': 0x209F
  36466. },
  36467. {
  36468. 'begin': 0x20A0,
  36469. 'end': 0x20CF
  36470. },
  36471. {
  36472. 'begin': 0x20D0,
  36473. 'end': 0x20FF
  36474. },
  36475. {
  36476. 'begin': 0x2100,
  36477. 'end': 0x214F
  36478. },
  36479. {
  36480. 'begin': 0x2150,
  36481. 'end': 0x218F
  36482. },
  36483. {
  36484. 'begin': 0x2190,
  36485. 'end': 0x21FF
  36486. },
  36487. {
  36488. 'begin': 0x2200,
  36489. 'end': 0x22FF
  36490. },
  36491. {
  36492. 'begin': 0x2300,
  36493. 'end': 0x23FF
  36494. },
  36495. {
  36496. 'begin': 0x2400,
  36497. 'end': 0x243F
  36498. },
  36499. {
  36500. 'begin': 0x2440,
  36501. 'end': 0x245F
  36502. },
  36503. {
  36504. 'begin': 0x2460,
  36505. 'end': 0x24FF
  36506. },
  36507. {
  36508. 'begin': 0x2500,
  36509. 'end': 0x257F
  36510. },
  36511. {
  36512. 'begin': 0x2580,
  36513. 'end': 0x259F
  36514. },
  36515. {
  36516. 'begin': 0x25A0,
  36517. 'end': 0x25FF
  36518. },
  36519. {
  36520. 'begin': 0x2600,
  36521. 'end': 0x26FF
  36522. },
  36523. {
  36524. 'begin': 0x2700,
  36525. 'end': 0x27BF
  36526. },
  36527. {
  36528. 'begin': 0x3000,
  36529. 'end': 0x303F
  36530. },
  36531. {
  36532. 'begin': 0x3040,
  36533. 'end': 0x309F
  36534. },
  36535. {
  36536. 'begin': 0x30A0,
  36537. 'end': 0x30FF
  36538. },
  36539. {
  36540. 'begin': 0x3100,
  36541. 'end': 0x312F
  36542. },
  36543. {
  36544. 'begin': 0x3130,
  36545. 'end': 0x318F
  36546. },
  36547. {
  36548. 'begin': 0xA840,
  36549. 'end': 0xA87F
  36550. },
  36551. {
  36552. 'begin': 0x3200,
  36553. 'end': 0x32FF
  36554. },
  36555. {
  36556. 'begin': 0x3300,
  36557. 'end': 0x33FF
  36558. },
  36559. {
  36560. 'begin': 0xAC00,
  36561. 'end': 0xD7AF
  36562. },
  36563. {
  36564. 'begin': 0xD800,
  36565. 'end': 0xDFFF
  36566. },
  36567. {
  36568. 'begin': 0x10900,
  36569. 'end': 0x1091F
  36570. },
  36571. {
  36572. 'begin': 0x4E00,
  36573. 'end': 0x9FFF
  36574. },
  36575. {
  36576. 'begin': 0xE000,
  36577. 'end': 0xF8FF
  36578. },
  36579. {
  36580. 'begin': 0x31C0,
  36581. 'end': 0x31EF
  36582. },
  36583. {
  36584. 'begin': 0xFB00,
  36585. 'end': 0xFB4F
  36586. },
  36587. {
  36588. 'begin': 0xFB50,
  36589. 'end': 0xFDFF
  36590. },
  36591. {
  36592. 'begin': 0xFE20,
  36593. 'end': 0xFE2F
  36594. },
  36595. {
  36596. 'begin': 0xFE10,
  36597. 'end': 0xFE1F
  36598. },
  36599. {
  36600. 'begin': 0xFE50,
  36601. 'end': 0xFE6F
  36602. },
  36603. {
  36604. 'begin': 0xFE70,
  36605. 'end': 0xFEFF
  36606. },
  36607. {
  36608. 'begin': 0xFF00,
  36609. 'end': 0xFFEF
  36610. },
  36611. {
  36612. 'begin': 0xFFF0,
  36613. 'end': 0xFFFF
  36614. },
  36615. {
  36616. 'begin': 0x0F00,
  36617. 'end': 0x0FFF
  36618. },
  36619. {
  36620. 'begin': 0x0700,
  36621. 'end': 0x074F
  36622. },
  36623. {
  36624. 'begin': 0x0780,
  36625. 'end': 0x07BF
  36626. },
  36627. {
  36628. 'begin': 0x0D80,
  36629. 'end': 0x0DFF
  36630. },
  36631. {
  36632. 'begin': 0x1000,
  36633. 'end': 0x109F
  36634. },
  36635. {
  36636. 'begin': 0x1200,
  36637. 'end': 0x137F
  36638. },
  36639. {
  36640. 'begin': 0x13A0,
  36641. 'end': 0x13FF
  36642. },
  36643. {
  36644. 'begin': 0x1400,
  36645. 'end': 0x167F
  36646. },
  36647. {
  36648. 'begin': 0x1680,
  36649. 'end': 0x169F
  36650. },
  36651. {
  36652. 'begin': 0x16A0,
  36653. 'end': 0x16FF
  36654. },
  36655. {
  36656. 'begin': 0x1780,
  36657. 'end': 0x17FF
  36658. },
  36659. {
  36660. 'begin': 0x1800,
  36661. 'end': 0x18AF
  36662. },
  36663. {
  36664. 'begin': 0x2800,
  36665. 'end': 0x28FF
  36666. },
  36667. {
  36668. 'begin': 0xA000,
  36669. 'end': 0xA48F
  36670. },
  36671. {
  36672. 'begin': 0x1700,
  36673. 'end': 0x171F
  36674. },
  36675. {
  36676. 'begin': 0x10300,
  36677. 'end': 0x1032F
  36678. },
  36679. {
  36680. 'begin': 0x10330,
  36681. 'end': 0x1034F
  36682. },
  36683. {
  36684. 'begin': 0x10400,
  36685. 'end': 0x1044F
  36686. },
  36687. {
  36688. 'begin': 0x1D000,
  36689. 'end': 0x1D0FF
  36690. },
  36691. {
  36692. 'begin': 0x1D400,
  36693. 'end': 0x1D7FF
  36694. },
  36695. {
  36696. 'begin': 0xFF000,
  36697. 'end': 0xFFFFD
  36698. },
  36699. {
  36700. 'begin': 0xFE00,
  36701. 'end': 0xFE0F
  36702. },
  36703. {
  36704. 'begin': 0xE0000,
  36705. 'end': 0xE007F
  36706. },
  36707. {
  36708. 'begin': 0x1900,
  36709. 'end': 0x194F
  36710. },
  36711. {
  36712. 'begin': 0x1950,
  36713. 'end': 0x197F
  36714. },
  36715. {
  36716. 'begin': 0x1980,
  36717. 'end': 0x19DF
  36718. },
  36719. {
  36720. 'begin': 0x1A00,
  36721. 'end': 0x1A1F
  36722. },
  36723. {
  36724. 'begin': 0x2C00,
  36725. 'end': 0x2C5F
  36726. },
  36727. {
  36728. 'begin': 0x2D30,
  36729. 'end': 0x2D7F
  36730. },
  36731. {
  36732. 'begin': 0x4DC0,
  36733. 'end': 0x4DFF
  36734. },
  36735. {
  36736. 'begin': 0xA800,
  36737. 'end': 0xA82F
  36738. },
  36739. {
  36740. 'begin': 0x10000,
  36741. 'end': 0x1007F
  36742. },
  36743. {
  36744. 'begin': 0x10140,
  36745. 'end': 0x1018F
  36746. },
  36747. {
  36748. 'begin': 0x10380,
  36749. 'end': 0x1039F
  36750. },
  36751. {
  36752. 'begin': 0x103A0,
  36753. 'end': 0x103DF
  36754. },
  36755. {
  36756. 'begin': 0x10450,
  36757. 'end': 0x1047F
  36758. },
  36759. {
  36760. 'begin': 0x10480,
  36761. 'end': 0x104AF
  36762. },
  36763. {
  36764. 'begin': 0x10800,
  36765. 'end': 0x1083F
  36766. },
  36767. {
  36768. 'begin': 0x10A00,
  36769. 'end': 0x10A5F
  36770. },
  36771. {
  36772. 'begin': 0x1D300,
  36773. 'end': 0x1D35F
  36774. },
  36775. {
  36776. 'begin': 0x12000,
  36777. 'end': 0x123FF
  36778. },
  36779. {
  36780. 'begin': 0x1D360,
  36781. 'end': 0x1D37F
  36782. },
  36783. {
  36784. 'begin': 0x1B80,
  36785. 'end': 0x1BBF
  36786. },
  36787. {
  36788. 'begin': 0x1C00,
  36789. 'end': 0x1C4F
  36790. },
  36791. {
  36792. 'begin': 0x1C50,
  36793. 'end': 0x1C7F
  36794. },
  36795. {
  36796. 'begin': 0xA880,
  36797. 'end': 0xA8DF
  36798. },
  36799. {
  36800. 'begin': 0xA900,
  36801. 'end': 0xA92F
  36802. },
  36803. {
  36804. 'begin': 0xA930,
  36805. 'end': 0xA95F
  36806. },
  36807. {
  36808. 'begin': 0xAA00,
  36809. 'end': 0xAA5F
  36810. },
  36811. {
  36812. 'begin': 0x10190,
  36813. 'end': 0x101CF
  36814. },
  36815. {
  36816. 'begin': 0x101D0,
  36817. 'end': 0x101FF
  36818. },
  36819. {
  36820. 'begin': 0x102A0,
  36821. 'end': 0x102DF
  36822. },
  36823. {
  36824. 'begin': 0x1F030,
  36825. 'end': 0x1F09F
  36826. }
  36827. ];
  36828. function getUnicodeRangeFor(value) {
  36829. for (var i = 0, ii = UnicodeRanges.length; i < ii; i++) {
  36830. var range = UnicodeRanges[i];
  36831. if (value >= range.begin && value < range.end) {
  36832. return i;
  36833. }
  36834. }
  36835. return -1;
  36836. }
  36837. function isRTLRangeFor(value) {
  36838. var range = UnicodeRanges[13];
  36839. if (value >= range.begin && value < range.end) {
  36840. return true;
  36841. }
  36842. range = UnicodeRanges[11];
  36843. if (value >= range.begin && value < range.end) {
  36844. return true;
  36845. }
  36846. return false;
  36847. }
  36848. var getNormalizedUnicodes = getLookupTableFactory(function (t) {
  36849. t['\u00A8'] = '\u0020\u0308';
  36850. t['\u00AF'] = '\u0020\u0304';
  36851. t['\u00B4'] = '\u0020\u0301';
  36852. t['\u00B5'] = '\u03BC';
  36853. t['\u00B8'] = '\u0020\u0327';
  36854. t['\u0132'] = '\u0049\u004A';
  36855. t['\u0133'] = '\u0069\u006A';
  36856. t['\u013F'] = '\u004C\u00B7';
  36857. t['\u0140'] = '\u006C\u00B7';
  36858. t['\u0149'] = '\u02BC\u006E';
  36859. t['\u017F'] = '\u0073';
  36860. t['\u01C4'] = '\u0044\u017D';
  36861. t['\u01C5'] = '\u0044\u017E';
  36862. t['\u01C6'] = '\u0064\u017E';
  36863. t['\u01C7'] = '\u004C\u004A';
  36864. t['\u01C8'] = '\u004C\u006A';
  36865. t['\u01C9'] = '\u006C\u006A';
  36866. t['\u01CA'] = '\u004E\u004A';
  36867. t['\u01CB'] = '\u004E\u006A';
  36868. t['\u01CC'] = '\u006E\u006A';
  36869. t['\u01F1'] = '\u0044\u005A';
  36870. t['\u01F2'] = '\u0044\u007A';
  36871. t['\u01F3'] = '\u0064\u007A';
  36872. t['\u02D8'] = '\u0020\u0306';
  36873. t['\u02D9'] = '\u0020\u0307';
  36874. t['\u02DA'] = '\u0020\u030A';
  36875. t['\u02DB'] = '\u0020\u0328';
  36876. t['\u02DC'] = '\u0020\u0303';
  36877. t['\u02DD'] = '\u0020\u030B';
  36878. t['\u037A'] = '\u0020\u0345';
  36879. t['\u0384'] = '\u0020\u0301';
  36880. t['\u03D0'] = '\u03B2';
  36881. t['\u03D1'] = '\u03B8';
  36882. t['\u03D2'] = '\u03A5';
  36883. t['\u03D5'] = '\u03C6';
  36884. t['\u03D6'] = '\u03C0';
  36885. t['\u03F0'] = '\u03BA';
  36886. t['\u03F1'] = '\u03C1';
  36887. t['\u03F2'] = '\u03C2';
  36888. t['\u03F4'] = '\u0398';
  36889. t['\u03F5'] = '\u03B5';
  36890. t['\u03F9'] = '\u03A3';
  36891. t['\u0587'] = '\u0565\u0582';
  36892. t['\u0675'] = '\u0627\u0674';
  36893. t['\u0676'] = '\u0648\u0674';
  36894. t['\u0677'] = '\u06C7\u0674';
  36895. t['\u0678'] = '\u064A\u0674';
  36896. t['\u0E33'] = '\u0E4D\u0E32';
  36897. t['\u0EB3'] = '\u0ECD\u0EB2';
  36898. t['\u0EDC'] = '\u0EAB\u0E99';
  36899. t['\u0EDD'] = '\u0EAB\u0EA1';
  36900. t['\u0F77'] = '\u0FB2\u0F81';
  36901. t['\u0F79'] = '\u0FB3\u0F81';
  36902. t['\u1E9A'] = '\u0061\u02BE';
  36903. t['\u1FBD'] = '\u0020\u0313';
  36904. t['\u1FBF'] = '\u0020\u0313';
  36905. t['\u1FC0'] = '\u0020\u0342';
  36906. t['\u1FFE'] = '\u0020\u0314';
  36907. t['\u2002'] = '\u0020';
  36908. t['\u2003'] = '\u0020';
  36909. t['\u2004'] = '\u0020';
  36910. t['\u2005'] = '\u0020';
  36911. t['\u2006'] = '\u0020';
  36912. t['\u2008'] = '\u0020';
  36913. t['\u2009'] = '\u0020';
  36914. t['\u200A'] = '\u0020';
  36915. t['\u2017'] = '\u0020\u0333';
  36916. t['\u2024'] = '\u002E';
  36917. t['\u2025'] = '\u002E\u002E';
  36918. t['\u2026'] = '\u002E\u002E\u002E';
  36919. t['\u2033'] = '\u2032\u2032';
  36920. t['\u2034'] = '\u2032\u2032\u2032';
  36921. t['\u2036'] = '\u2035\u2035';
  36922. t['\u2037'] = '\u2035\u2035\u2035';
  36923. t['\u203C'] = '\u0021\u0021';
  36924. t['\u203E'] = '\u0020\u0305';
  36925. t['\u2047'] = '\u003F\u003F';
  36926. t['\u2048'] = '\u003F\u0021';
  36927. t['\u2049'] = '\u0021\u003F';
  36928. t['\u2057'] = '\u2032\u2032\u2032\u2032';
  36929. t['\u205F'] = '\u0020';
  36930. t['\u20A8'] = '\u0052\u0073';
  36931. t['\u2100'] = '\u0061\u002F\u0063';
  36932. t['\u2101'] = '\u0061\u002F\u0073';
  36933. t['\u2103'] = '\u00B0\u0043';
  36934. t['\u2105'] = '\u0063\u002F\u006F';
  36935. t['\u2106'] = '\u0063\u002F\u0075';
  36936. t['\u2107'] = '\u0190';
  36937. t['\u2109'] = '\u00B0\u0046';
  36938. t['\u2116'] = '\u004E\u006F';
  36939. t['\u2121'] = '\u0054\u0045\u004C';
  36940. t['\u2135'] = '\u05D0';
  36941. t['\u2136'] = '\u05D1';
  36942. t['\u2137'] = '\u05D2';
  36943. t['\u2138'] = '\u05D3';
  36944. t['\u213B'] = '\u0046\u0041\u0058';
  36945. t['\u2160'] = '\u0049';
  36946. t['\u2161'] = '\u0049\u0049';
  36947. t['\u2162'] = '\u0049\u0049\u0049';
  36948. t['\u2163'] = '\u0049\u0056';
  36949. t['\u2164'] = '\u0056';
  36950. t['\u2165'] = '\u0056\u0049';
  36951. t['\u2166'] = '\u0056\u0049\u0049';
  36952. t['\u2167'] = '\u0056\u0049\u0049\u0049';
  36953. t['\u2168'] = '\u0049\u0058';
  36954. t['\u2169'] = '\u0058';
  36955. t['\u216A'] = '\u0058\u0049';
  36956. t['\u216B'] = '\u0058\u0049\u0049';
  36957. t['\u216C'] = '\u004C';
  36958. t['\u216D'] = '\u0043';
  36959. t['\u216E'] = '\u0044';
  36960. t['\u216F'] = '\u004D';
  36961. t['\u2170'] = '\u0069';
  36962. t['\u2171'] = '\u0069\u0069';
  36963. t['\u2172'] = '\u0069\u0069\u0069';
  36964. t['\u2173'] = '\u0069\u0076';
  36965. t['\u2174'] = '\u0076';
  36966. t['\u2175'] = '\u0076\u0069';
  36967. t['\u2176'] = '\u0076\u0069\u0069';
  36968. t['\u2177'] = '\u0076\u0069\u0069\u0069';
  36969. t['\u2178'] = '\u0069\u0078';
  36970. t['\u2179'] = '\u0078';
  36971. t['\u217A'] = '\u0078\u0069';
  36972. t['\u217B'] = '\u0078\u0069\u0069';
  36973. t['\u217C'] = '\u006C';
  36974. t['\u217D'] = '\u0063';
  36975. t['\u217E'] = '\u0064';
  36976. t['\u217F'] = '\u006D';
  36977. t['\u222C'] = '\u222B\u222B';
  36978. t['\u222D'] = '\u222B\u222B\u222B';
  36979. t['\u222F'] = '\u222E\u222E';
  36980. t['\u2230'] = '\u222E\u222E\u222E';
  36981. t['\u2474'] = '\u0028\u0031\u0029';
  36982. t['\u2475'] = '\u0028\u0032\u0029';
  36983. t['\u2476'] = '\u0028\u0033\u0029';
  36984. t['\u2477'] = '\u0028\u0034\u0029';
  36985. t['\u2478'] = '\u0028\u0035\u0029';
  36986. t['\u2479'] = '\u0028\u0036\u0029';
  36987. t['\u247A'] = '\u0028\u0037\u0029';
  36988. t['\u247B'] = '\u0028\u0038\u0029';
  36989. t['\u247C'] = '\u0028\u0039\u0029';
  36990. t['\u247D'] = '\u0028\u0031\u0030\u0029';
  36991. t['\u247E'] = '\u0028\u0031\u0031\u0029';
  36992. t['\u247F'] = '\u0028\u0031\u0032\u0029';
  36993. t['\u2480'] = '\u0028\u0031\u0033\u0029';
  36994. t['\u2481'] = '\u0028\u0031\u0034\u0029';
  36995. t['\u2482'] = '\u0028\u0031\u0035\u0029';
  36996. t['\u2483'] = '\u0028\u0031\u0036\u0029';
  36997. t['\u2484'] = '\u0028\u0031\u0037\u0029';
  36998. t['\u2485'] = '\u0028\u0031\u0038\u0029';
  36999. t['\u2486'] = '\u0028\u0031\u0039\u0029';
  37000. t['\u2487'] = '\u0028\u0032\u0030\u0029';
  37001. t['\u2488'] = '\u0031\u002E';
  37002. t['\u2489'] = '\u0032\u002E';
  37003. t['\u248A'] = '\u0033\u002E';
  37004. t['\u248B'] = '\u0034\u002E';
  37005. t['\u248C'] = '\u0035\u002E';
  37006. t['\u248D'] = '\u0036\u002E';
  37007. t['\u248E'] = '\u0037\u002E';
  37008. t['\u248F'] = '\u0038\u002E';
  37009. t['\u2490'] = '\u0039\u002E';
  37010. t['\u2491'] = '\u0031\u0030\u002E';
  37011. t['\u2492'] = '\u0031\u0031\u002E';
  37012. t['\u2493'] = '\u0031\u0032\u002E';
  37013. t['\u2494'] = '\u0031\u0033\u002E';
  37014. t['\u2495'] = '\u0031\u0034\u002E';
  37015. t['\u2496'] = '\u0031\u0035\u002E';
  37016. t['\u2497'] = '\u0031\u0036\u002E';
  37017. t['\u2498'] = '\u0031\u0037\u002E';
  37018. t['\u2499'] = '\u0031\u0038\u002E';
  37019. t['\u249A'] = '\u0031\u0039\u002E';
  37020. t['\u249B'] = '\u0032\u0030\u002E';
  37021. t['\u249C'] = '\u0028\u0061\u0029';
  37022. t['\u249D'] = '\u0028\u0062\u0029';
  37023. t['\u249E'] = '\u0028\u0063\u0029';
  37024. t['\u249F'] = '\u0028\u0064\u0029';
  37025. t['\u24A0'] = '\u0028\u0065\u0029';
  37026. t['\u24A1'] = '\u0028\u0066\u0029';
  37027. t['\u24A2'] = '\u0028\u0067\u0029';
  37028. t['\u24A3'] = '\u0028\u0068\u0029';
  37029. t['\u24A4'] = '\u0028\u0069\u0029';
  37030. t['\u24A5'] = '\u0028\u006A\u0029';
  37031. t['\u24A6'] = '\u0028\u006B\u0029';
  37032. t['\u24A7'] = '\u0028\u006C\u0029';
  37033. t['\u24A8'] = '\u0028\u006D\u0029';
  37034. t['\u24A9'] = '\u0028\u006E\u0029';
  37035. t['\u24AA'] = '\u0028\u006F\u0029';
  37036. t['\u24AB'] = '\u0028\u0070\u0029';
  37037. t['\u24AC'] = '\u0028\u0071\u0029';
  37038. t['\u24AD'] = '\u0028\u0072\u0029';
  37039. t['\u24AE'] = '\u0028\u0073\u0029';
  37040. t['\u24AF'] = '\u0028\u0074\u0029';
  37041. t['\u24B0'] = '\u0028\u0075\u0029';
  37042. t['\u24B1'] = '\u0028\u0076\u0029';
  37043. t['\u24B2'] = '\u0028\u0077\u0029';
  37044. t['\u24B3'] = '\u0028\u0078\u0029';
  37045. t['\u24B4'] = '\u0028\u0079\u0029';
  37046. t['\u24B5'] = '\u0028\u007A\u0029';
  37047. t['\u2A0C'] = '\u222B\u222B\u222B\u222B';
  37048. t['\u2A74'] = '\u003A\u003A\u003D';
  37049. t['\u2A75'] = '\u003D\u003D';
  37050. t['\u2A76'] = '\u003D\u003D\u003D';
  37051. t['\u2E9F'] = '\u6BCD';
  37052. t['\u2EF3'] = '\u9F9F';
  37053. t['\u2F00'] = '\u4E00';
  37054. t['\u2F01'] = '\u4E28';
  37055. t['\u2F02'] = '\u4E36';
  37056. t['\u2F03'] = '\u4E3F';
  37057. t['\u2F04'] = '\u4E59';
  37058. t['\u2F05'] = '\u4E85';
  37059. t['\u2F06'] = '\u4E8C';
  37060. t['\u2F07'] = '\u4EA0';
  37061. t['\u2F08'] = '\u4EBA';
  37062. t['\u2F09'] = '\u513F';
  37063. t['\u2F0A'] = '\u5165';
  37064. t['\u2F0B'] = '\u516B';
  37065. t['\u2F0C'] = '\u5182';
  37066. t['\u2F0D'] = '\u5196';
  37067. t['\u2F0E'] = '\u51AB';
  37068. t['\u2F0F'] = '\u51E0';
  37069. t['\u2F10'] = '\u51F5';
  37070. t['\u2F11'] = '\u5200';
  37071. t['\u2F12'] = '\u529B';
  37072. t['\u2F13'] = '\u52F9';
  37073. t['\u2F14'] = '\u5315';
  37074. t['\u2F15'] = '\u531A';
  37075. t['\u2F16'] = '\u5338';
  37076. t['\u2F17'] = '\u5341';
  37077. t['\u2F18'] = '\u535C';
  37078. t['\u2F19'] = '\u5369';
  37079. t['\u2F1A'] = '\u5382';
  37080. t['\u2F1B'] = '\u53B6';
  37081. t['\u2F1C'] = '\u53C8';
  37082. t['\u2F1D'] = '\u53E3';
  37083. t['\u2F1E'] = '\u56D7';
  37084. t['\u2F1F'] = '\u571F';
  37085. t['\u2F20'] = '\u58EB';
  37086. t['\u2F21'] = '\u5902';
  37087. t['\u2F22'] = '\u590A';
  37088. t['\u2F23'] = '\u5915';
  37089. t['\u2F24'] = '\u5927';
  37090. t['\u2F25'] = '\u5973';
  37091. t['\u2F26'] = '\u5B50';
  37092. t['\u2F27'] = '\u5B80';
  37093. t['\u2F28'] = '\u5BF8';
  37094. t['\u2F29'] = '\u5C0F';
  37095. t['\u2F2A'] = '\u5C22';
  37096. t['\u2F2B'] = '\u5C38';
  37097. t['\u2F2C'] = '\u5C6E';
  37098. t['\u2F2D'] = '\u5C71';
  37099. t['\u2F2E'] = '\u5DDB';
  37100. t['\u2F2F'] = '\u5DE5';
  37101. t['\u2F30'] = '\u5DF1';
  37102. t['\u2F31'] = '\u5DFE';
  37103. t['\u2F32'] = '\u5E72';
  37104. t['\u2F33'] = '\u5E7A';
  37105. t['\u2F34'] = '\u5E7F';
  37106. t['\u2F35'] = '\u5EF4';
  37107. t['\u2F36'] = '\u5EFE';
  37108. t['\u2F37'] = '\u5F0B';
  37109. t['\u2F38'] = '\u5F13';
  37110. t['\u2F39'] = '\u5F50';
  37111. t['\u2F3A'] = '\u5F61';
  37112. t['\u2F3B'] = '\u5F73';
  37113. t['\u2F3C'] = '\u5FC3';
  37114. t['\u2F3D'] = '\u6208';
  37115. t['\u2F3E'] = '\u6236';
  37116. t['\u2F3F'] = '\u624B';
  37117. t['\u2F40'] = '\u652F';
  37118. t['\u2F41'] = '\u6534';
  37119. t['\u2F42'] = '\u6587';
  37120. t['\u2F43'] = '\u6597';
  37121. t['\u2F44'] = '\u65A4';
  37122. t['\u2F45'] = '\u65B9';
  37123. t['\u2F46'] = '\u65E0';
  37124. t['\u2F47'] = '\u65E5';
  37125. t['\u2F48'] = '\u66F0';
  37126. t['\u2F49'] = '\u6708';
  37127. t['\u2F4A'] = '\u6728';
  37128. t['\u2F4B'] = '\u6B20';
  37129. t['\u2F4C'] = '\u6B62';
  37130. t['\u2F4D'] = '\u6B79';
  37131. t['\u2F4E'] = '\u6BB3';
  37132. t['\u2F4F'] = '\u6BCB';
  37133. t['\u2F50'] = '\u6BD4';
  37134. t['\u2F51'] = '\u6BDB';
  37135. t['\u2F52'] = '\u6C0F';
  37136. t['\u2F53'] = '\u6C14';
  37137. t['\u2F54'] = '\u6C34';
  37138. t['\u2F55'] = '\u706B';
  37139. t['\u2F56'] = '\u722A';
  37140. t['\u2F57'] = '\u7236';
  37141. t['\u2F58'] = '\u723B';
  37142. t['\u2F59'] = '\u723F';
  37143. t['\u2F5A'] = '\u7247';
  37144. t['\u2F5B'] = '\u7259';
  37145. t['\u2F5C'] = '\u725B';
  37146. t['\u2F5D'] = '\u72AC';
  37147. t['\u2F5E'] = '\u7384';
  37148. t['\u2F5F'] = '\u7389';
  37149. t['\u2F60'] = '\u74DC';
  37150. t['\u2F61'] = '\u74E6';
  37151. t['\u2F62'] = '\u7518';
  37152. t['\u2F63'] = '\u751F';
  37153. t['\u2F64'] = '\u7528';
  37154. t['\u2F65'] = '\u7530';
  37155. t['\u2F66'] = '\u758B';
  37156. t['\u2F67'] = '\u7592';
  37157. t['\u2F68'] = '\u7676';
  37158. t['\u2F69'] = '\u767D';
  37159. t['\u2F6A'] = '\u76AE';
  37160. t['\u2F6B'] = '\u76BF';
  37161. t['\u2F6C'] = '\u76EE';
  37162. t['\u2F6D'] = '\u77DB';
  37163. t['\u2F6E'] = '\u77E2';
  37164. t['\u2F6F'] = '\u77F3';
  37165. t['\u2F70'] = '\u793A';
  37166. t['\u2F71'] = '\u79B8';
  37167. t['\u2F72'] = '\u79BE';
  37168. t['\u2F73'] = '\u7A74';
  37169. t['\u2F74'] = '\u7ACB';
  37170. t['\u2F75'] = '\u7AF9';
  37171. t['\u2F76'] = '\u7C73';
  37172. t['\u2F77'] = '\u7CF8';
  37173. t['\u2F78'] = '\u7F36';
  37174. t['\u2F79'] = '\u7F51';
  37175. t['\u2F7A'] = '\u7F8A';
  37176. t['\u2F7B'] = '\u7FBD';
  37177. t['\u2F7C'] = '\u8001';
  37178. t['\u2F7D'] = '\u800C';
  37179. t['\u2F7E'] = '\u8012';
  37180. t['\u2F7F'] = '\u8033';
  37181. t['\u2F80'] = '\u807F';
  37182. t['\u2F81'] = '\u8089';
  37183. t['\u2F82'] = '\u81E3';
  37184. t['\u2F83'] = '\u81EA';
  37185. t['\u2F84'] = '\u81F3';
  37186. t['\u2F85'] = '\u81FC';
  37187. t['\u2F86'] = '\u820C';
  37188. t['\u2F87'] = '\u821B';
  37189. t['\u2F88'] = '\u821F';
  37190. t['\u2F89'] = '\u826E';
  37191. t['\u2F8A'] = '\u8272';
  37192. t['\u2F8B'] = '\u8278';
  37193. t['\u2F8C'] = '\u864D';
  37194. t['\u2F8D'] = '\u866B';
  37195. t['\u2F8E'] = '\u8840';
  37196. t['\u2F8F'] = '\u884C';
  37197. t['\u2F90'] = '\u8863';
  37198. t['\u2F91'] = '\u897E';
  37199. t['\u2F92'] = '\u898B';
  37200. t['\u2F93'] = '\u89D2';
  37201. t['\u2F94'] = '\u8A00';
  37202. t['\u2F95'] = '\u8C37';
  37203. t['\u2F96'] = '\u8C46';
  37204. t['\u2F97'] = '\u8C55';
  37205. t['\u2F98'] = '\u8C78';
  37206. t['\u2F99'] = '\u8C9D';
  37207. t['\u2F9A'] = '\u8D64';
  37208. t['\u2F9B'] = '\u8D70';
  37209. t['\u2F9C'] = '\u8DB3';
  37210. t['\u2F9D'] = '\u8EAB';
  37211. t['\u2F9E'] = '\u8ECA';
  37212. t['\u2F9F'] = '\u8F9B';
  37213. t['\u2FA0'] = '\u8FB0';
  37214. t['\u2FA1'] = '\u8FB5';
  37215. t['\u2FA2'] = '\u9091';
  37216. t['\u2FA3'] = '\u9149';
  37217. t['\u2FA4'] = '\u91C6';
  37218. t['\u2FA5'] = '\u91CC';
  37219. t['\u2FA6'] = '\u91D1';
  37220. t['\u2FA7'] = '\u9577';
  37221. t['\u2FA8'] = '\u9580';
  37222. t['\u2FA9'] = '\u961C';
  37223. t['\u2FAA'] = '\u96B6';
  37224. t['\u2FAB'] = '\u96B9';
  37225. t['\u2FAC'] = '\u96E8';
  37226. t['\u2FAD'] = '\u9751';
  37227. t['\u2FAE'] = '\u975E';
  37228. t['\u2FAF'] = '\u9762';
  37229. t['\u2FB0'] = '\u9769';
  37230. t['\u2FB1'] = '\u97CB';
  37231. t['\u2FB2'] = '\u97ED';
  37232. t['\u2FB3'] = '\u97F3';
  37233. t['\u2FB4'] = '\u9801';
  37234. t['\u2FB5'] = '\u98A8';
  37235. t['\u2FB6'] = '\u98DB';
  37236. t['\u2FB7'] = '\u98DF';
  37237. t['\u2FB8'] = '\u9996';
  37238. t['\u2FB9'] = '\u9999';
  37239. t['\u2FBA'] = '\u99AC';
  37240. t['\u2FBB'] = '\u9AA8';
  37241. t['\u2FBC'] = '\u9AD8';
  37242. t['\u2FBD'] = '\u9ADF';
  37243. t['\u2FBE'] = '\u9B25';
  37244. t['\u2FBF'] = '\u9B2F';
  37245. t['\u2FC0'] = '\u9B32';
  37246. t['\u2FC1'] = '\u9B3C';
  37247. t['\u2FC2'] = '\u9B5A';
  37248. t['\u2FC3'] = '\u9CE5';
  37249. t['\u2FC4'] = '\u9E75';
  37250. t['\u2FC5'] = '\u9E7F';
  37251. t['\u2FC6'] = '\u9EA5';
  37252. t['\u2FC7'] = '\u9EBB';
  37253. t['\u2FC8'] = '\u9EC3';
  37254. t['\u2FC9'] = '\u9ECD';
  37255. t['\u2FCA'] = '\u9ED1';
  37256. t['\u2FCB'] = '\u9EF9';
  37257. t['\u2FCC'] = '\u9EFD';
  37258. t['\u2FCD'] = '\u9F0E';
  37259. t['\u2FCE'] = '\u9F13';
  37260. t['\u2FCF'] = '\u9F20';
  37261. t['\u2FD0'] = '\u9F3B';
  37262. t['\u2FD1'] = '\u9F4A';
  37263. t['\u2FD2'] = '\u9F52';
  37264. t['\u2FD3'] = '\u9F8D';
  37265. t['\u2FD4'] = '\u9F9C';
  37266. t['\u2FD5'] = '\u9FA0';
  37267. t['\u3036'] = '\u3012';
  37268. t['\u3038'] = '\u5341';
  37269. t['\u3039'] = '\u5344';
  37270. t['\u303A'] = '\u5345';
  37271. t['\u309B'] = '\u0020\u3099';
  37272. t['\u309C'] = '\u0020\u309A';
  37273. t['\u3131'] = '\u1100';
  37274. t['\u3132'] = '\u1101';
  37275. t['\u3133'] = '\u11AA';
  37276. t['\u3134'] = '\u1102';
  37277. t['\u3135'] = '\u11AC';
  37278. t['\u3136'] = '\u11AD';
  37279. t['\u3137'] = '\u1103';
  37280. t['\u3138'] = '\u1104';
  37281. t['\u3139'] = '\u1105';
  37282. t['\u313A'] = '\u11B0';
  37283. t['\u313B'] = '\u11B1';
  37284. t['\u313C'] = '\u11B2';
  37285. t['\u313D'] = '\u11B3';
  37286. t['\u313E'] = '\u11B4';
  37287. t['\u313F'] = '\u11B5';
  37288. t['\u3140'] = '\u111A';
  37289. t['\u3141'] = '\u1106';
  37290. t['\u3142'] = '\u1107';
  37291. t['\u3143'] = '\u1108';
  37292. t['\u3144'] = '\u1121';
  37293. t['\u3145'] = '\u1109';
  37294. t['\u3146'] = '\u110A';
  37295. t['\u3147'] = '\u110B';
  37296. t['\u3148'] = '\u110C';
  37297. t['\u3149'] = '\u110D';
  37298. t['\u314A'] = '\u110E';
  37299. t['\u314B'] = '\u110F';
  37300. t['\u314C'] = '\u1110';
  37301. t['\u314D'] = '\u1111';
  37302. t['\u314E'] = '\u1112';
  37303. t['\u314F'] = '\u1161';
  37304. t['\u3150'] = '\u1162';
  37305. t['\u3151'] = '\u1163';
  37306. t['\u3152'] = '\u1164';
  37307. t['\u3153'] = '\u1165';
  37308. t['\u3154'] = '\u1166';
  37309. t['\u3155'] = '\u1167';
  37310. t['\u3156'] = '\u1168';
  37311. t['\u3157'] = '\u1169';
  37312. t['\u3158'] = '\u116A';
  37313. t['\u3159'] = '\u116B';
  37314. t['\u315A'] = '\u116C';
  37315. t['\u315B'] = '\u116D';
  37316. t['\u315C'] = '\u116E';
  37317. t['\u315D'] = '\u116F';
  37318. t['\u315E'] = '\u1170';
  37319. t['\u315F'] = '\u1171';
  37320. t['\u3160'] = '\u1172';
  37321. t['\u3161'] = '\u1173';
  37322. t['\u3162'] = '\u1174';
  37323. t['\u3163'] = '\u1175';
  37324. t['\u3164'] = '\u1160';
  37325. t['\u3165'] = '\u1114';
  37326. t['\u3166'] = '\u1115';
  37327. t['\u3167'] = '\u11C7';
  37328. t['\u3168'] = '\u11C8';
  37329. t['\u3169'] = '\u11CC';
  37330. t['\u316A'] = '\u11CE';
  37331. t['\u316B'] = '\u11D3';
  37332. t['\u316C'] = '\u11D7';
  37333. t['\u316D'] = '\u11D9';
  37334. t['\u316E'] = '\u111C';
  37335. t['\u316F'] = '\u11DD';
  37336. t['\u3170'] = '\u11DF';
  37337. t['\u3171'] = '\u111D';
  37338. t['\u3172'] = '\u111E';
  37339. t['\u3173'] = '\u1120';
  37340. t['\u3174'] = '\u1122';
  37341. t['\u3175'] = '\u1123';
  37342. t['\u3176'] = '\u1127';
  37343. t['\u3177'] = '\u1129';
  37344. t['\u3178'] = '\u112B';
  37345. t['\u3179'] = '\u112C';
  37346. t['\u317A'] = '\u112D';
  37347. t['\u317B'] = '\u112E';
  37348. t['\u317C'] = '\u112F';
  37349. t['\u317D'] = '\u1132';
  37350. t['\u317E'] = '\u1136';
  37351. t['\u317F'] = '\u1140';
  37352. t['\u3180'] = '\u1147';
  37353. t['\u3181'] = '\u114C';
  37354. t['\u3182'] = '\u11F1';
  37355. t['\u3183'] = '\u11F2';
  37356. t['\u3184'] = '\u1157';
  37357. t['\u3185'] = '\u1158';
  37358. t['\u3186'] = '\u1159';
  37359. t['\u3187'] = '\u1184';
  37360. t['\u3188'] = '\u1185';
  37361. t['\u3189'] = '\u1188';
  37362. t['\u318A'] = '\u1191';
  37363. t['\u318B'] = '\u1192';
  37364. t['\u318C'] = '\u1194';
  37365. t['\u318D'] = '\u119E';
  37366. t['\u318E'] = '\u11A1';
  37367. t['\u3200'] = '\u0028\u1100\u0029';
  37368. t['\u3201'] = '\u0028\u1102\u0029';
  37369. t['\u3202'] = '\u0028\u1103\u0029';
  37370. t['\u3203'] = '\u0028\u1105\u0029';
  37371. t['\u3204'] = '\u0028\u1106\u0029';
  37372. t['\u3205'] = '\u0028\u1107\u0029';
  37373. t['\u3206'] = '\u0028\u1109\u0029';
  37374. t['\u3207'] = '\u0028\u110B\u0029';
  37375. t['\u3208'] = '\u0028\u110C\u0029';
  37376. t['\u3209'] = '\u0028\u110E\u0029';
  37377. t['\u320A'] = '\u0028\u110F\u0029';
  37378. t['\u320B'] = '\u0028\u1110\u0029';
  37379. t['\u320C'] = '\u0028\u1111\u0029';
  37380. t['\u320D'] = '\u0028\u1112\u0029';
  37381. t['\u320E'] = '\u0028\u1100\u1161\u0029';
  37382. t['\u320F'] = '\u0028\u1102\u1161\u0029';
  37383. t['\u3210'] = '\u0028\u1103\u1161\u0029';
  37384. t['\u3211'] = '\u0028\u1105\u1161\u0029';
  37385. t['\u3212'] = '\u0028\u1106\u1161\u0029';
  37386. t['\u3213'] = '\u0028\u1107\u1161\u0029';
  37387. t['\u3214'] = '\u0028\u1109\u1161\u0029';
  37388. t['\u3215'] = '\u0028\u110B\u1161\u0029';
  37389. t['\u3216'] = '\u0028\u110C\u1161\u0029';
  37390. t['\u3217'] = '\u0028\u110E\u1161\u0029';
  37391. t['\u3218'] = '\u0028\u110F\u1161\u0029';
  37392. t['\u3219'] = '\u0028\u1110\u1161\u0029';
  37393. t['\u321A'] = '\u0028\u1111\u1161\u0029';
  37394. t['\u321B'] = '\u0028\u1112\u1161\u0029';
  37395. t['\u321C'] = '\u0028\u110C\u116E\u0029';
  37396. t['\u321D'] = '\u0028\u110B\u1169\u110C\u1165\u11AB\u0029';
  37397. t['\u321E'] = '\u0028\u110B\u1169\u1112\u116E\u0029';
  37398. t['\u3220'] = '\u0028\u4E00\u0029';
  37399. t['\u3221'] = '\u0028\u4E8C\u0029';
  37400. t['\u3222'] = '\u0028\u4E09\u0029';
  37401. t['\u3223'] = '\u0028\u56DB\u0029';
  37402. t['\u3224'] = '\u0028\u4E94\u0029';
  37403. t['\u3225'] = '\u0028\u516D\u0029';
  37404. t['\u3226'] = '\u0028\u4E03\u0029';
  37405. t['\u3227'] = '\u0028\u516B\u0029';
  37406. t['\u3228'] = '\u0028\u4E5D\u0029';
  37407. t['\u3229'] = '\u0028\u5341\u0029';
  37408. t['\u322A'] = '\u0028\u6708\u0029';
  37409. t['\u322B'] = '\u0028\u706B\u0029';
  37410. t['\u322C'] = '\u0028\u6C34\u0029';
  37411. t['\u322D'] = '\u0028\u6728\u0029';
  37412. t['\u322E'] = '\u0028\u91D1\u0029';
  37413. t['\u322F'] = '\u0028\u571F\u0029';
  37414. t['\u3230'] = '\u0028\u65E5\u0029';
  37415. t['\u3231'] = '\u0028\u682A\u0029';
  37416. t['\u3232'] = '\u0028\u6709\u0029';
  37417. t['\u3233'] = '\u0028\u793E\u0029';
  37418. t['\u3234'] = '\u0028\u540D\u0029';
  37419. t['\u3235'] = '\u0028\u7279\u0029';
  37420. t['\u3236'] = '\u0028\u8CA1\u0029';
  37421. t['\u3237'] = '\u0028\u795D\u0029';
  37422. t['\u3238'] = '\u0028\u52B4\u0029';
  37423. t['\u3239'] = '\u0028\u4EE3\u0029';
  37424. t['\u323A'] = '\u0028\u547C\u0029';
  37425. t['\u323B'] = '\u0028\u5B66\u0029';
  37426. t['\u323C'] = '\u0028\u76E3\u0029';
  37427. t['\u323D'] = '\u0028\u4F01\u0029';
  37428. t['\u323E'] = '\u0028\u8CC7\u0029';
  37429. t['\u323F'] = '\u0028\u5354\u0029';
  37430. t['\u3240'] = '\u0028\u796D\u0029';
  37431. t['\u3241'] = '\u0028\u4F11\u0029';
  37432. t['\u3242'] = '\u0028\u81EA\u0029';
  37433. t['\u3243'] = '\u0028\u81F3\u0029';
  37434. t['\u32C0'] = '\u0031\u6708';
  37435. t['\u32C1'] = '\u0032\u6708';
  37436. t['\u32C2'] = '\u0033\u6708';
  37437. t['\u32C3'] = '\u0034\u6708';
  37438. t['\u32C4'] = '\u0035\u6708';
  37439. t['\u32C5'] = '\u0036\u6708';
  37440. t['\u32C6'] = '\u0037\u6708';
  37441. t['\u32C7'] = '\u0038\u6708';
  37442. t['\u32C8'] = '\u0039\u6708';
  37443. t['\u32C9'] = '\u0031\u0030\u6708';
  37444. t['\u32CA'] = '\u0031\u0031\u6708';
  37445. t['\u32CB'] = '\u0031\u0032\u6708';
  37446. t['\u3358'] = '\u0030\u70B9';
  37447. t['\u3359'] = '\u0031\u70B9';
  37448. t['\u335A'] = '\u0032\u70B9';
  37449. t['\u335B'] = '\u0033\u70B9';
  37450. t['\u335C'] = '\u0034\u70B9';
  37451. t['\u335D'] = '\u0035\u70B9';
  37452. t['\u335E'] = '\u0036\u70B9';
  37453. t['\u335F'] = '\u0037\u70B9';
  37454. t['\u3360'] = '\u0038\u70B9';
  37455. t['\u3361'] = '\u0039\u70B9';
  37456. t['\u3362'] = '\u0031\u0030\u70B9';
  37457. t['\u3363'] = '\u0031\u0031\u70B9';
  37458. t['\u3364'] = '\u0031\u0032\u70B9';
  37459. t['\u3365'] = '\u0031\u0033\u70B9';
  37460. t['\u3366'] = '\u0031\u0034\u70B9';
  37461. t['\u3367'] = '\u0031\u0035\u70B9';
  37462. t['\u3368'] = '\u0031\u0036\u70B9';
  37463. t['\u3369'] = '\u0031\u0037\u70B9';
  37464. t['\u336A'] = '\u0031\u0038\u70B9';
  37465. t['\u336B'] = '\u0031\u0039\u70B9';
  37466. t['\u336C'] = '\u0032\u0030\u70B9';
  37467. t['\u336D'] = '\u0032\u0031\u70B9';
  37468. t['\u336E'] = '\u0032\u0032\u70B9';
  37469. t['\u336F'] = '\u0032\u0033\u70B9';
  37470. t['\u3370'] = '\u0032\u0034\u70B9';
  37471. t['\u33E0'] = '\u0031\u65E5';
  37472. t['\u33E1'] = '\u0032\u65E5';
  37473. t['\u33E2'] = '\u0033\u65E5';
  37474. t['\u33E3'] = '\u0034\u65E5';
  37475. t['\u33E4'] = '\u0035\u65E5';
  37476. t['\u33E5'] = '\u0036\u65E5';
  37477. t['\u33E6'] = '\u0037\u65E5';
  37478. t['\u33E7'] = '\u0038\u65E5';
  37479. t['\u33E8'] = '\u0039\u65E5';
  37480. t['\u33E9'] = '\u0031\u0030\u65E5';
  37481. t['\u33EA'] = '\u0031\u0031\u65E5';
  37482. t['\u33EB'] = '\u0031\u0032\u65E5';
  37483. t['\u33EC'] = '\u0031\u0033\u65E5';
  37484. t['\u33ED'] = '\u0031\u0034\u65E5';
  37485. t['\u33EE'] = '\u0031\u0035\u65E5';
  37486. t['\u33EF'] = '\u0031\u0036\u65E5';
  37487. t['\u33F0'] = '\u0031\u0037\u65E5';
  37488. t['\u33F1'] = '\u0031\u0038\u65E5';
  37489. t['\u33F2'] = '\u0031\u0039\u65E5';
  37490. t['\u33F3'] = '\u0032\u0030\u65E5';
  37491. t['\u33F4'] = '\u0032\u0031\u65E5';
  37492. t['\u33F5'] = '\u0032\u0032\u65E5';
  37493. t['\u33F6'] = '\u0032\u0033\u65E5';
  37494. t['\u33F7'] = '\u0032\u0034\u65E5';
  37495. t['\u33F8'] = '\u0032\u0035\u65E5';
  37496. t['\u33F9'] = '\u0032\u0036\u65E5';
  37497. t['\u33FA'] = '\u0032\u0037\u65E5';
  37498. t['\u33FB'] = '\u0032\u0038\u65E5';
  37499. t['\u33FC'] = '\u0032\u0039\u65E5';
  37500. t['\u33FD'] = '\u0033\u0030\u65E5';
  37501. t['\u33FE'] = '\u0033\u0031\u65E5';
  37502. t['\uFB00'] = '\u0066\u0066';
  37503. t['\uFB01'] = '\u0066\u0069';
  37504. t['\uFB02'] = '\u0066\u006C';
  37505. t['\uFB03'] = '\u0066\u0066\u0069';
  37506. t['\uFB04'] = '\u0066\u0066\u006C';
  37507. t['\uFB05'] = '\u017F\u0074';
  37508. t['\uFB06'] = '\u0073\u0074';
  37509. t['\uFB13'] = '\u0574\u0576';
  37510. t['\uFB14'] = '\u0574\u0565';
  37511. t['\uFB15'] = '\u0574\u056B';
  37512. t['\uFB16'] = '\u057E\u0576';
  37513. t['\uFB17'] = '\u0574\u056D';
  37514. t['\uFB4F'] = '\u05D0\u05DC';
  37515. t['\uFB50'] = '\u0671';
  37516. t['\uFB51'] = '\u0671';
  37517. t['\uFB52'] = '\u067B';
  37518. t['\uFB53'] = '\u067B';
  37519. t['\uFB54'] = '\u067B';
  37520. t['\uFB55'] = '\u067B';
  37521. t['\uFB56'] = '\u067E';
  37522. t['\uFB57'] = '\u067E';
  37523. t['\uFB58'] = '\u067E';
  37524. t['\uFB59'] = '\u067E';
  37525. t['\uFB5A'] = '\u0680';
  37526. t['\uFB5B'] = '\u0680';
  37527. t['\uFB5C'] = '\u0680';
  37528. t['\uFB5D'] = '\u0680';
  37529. t['\uFB5E'] = '\u067A';
  37530. t['\uFB5F'] = '\u067A';
  37531. t['\uFB60'] = '\u067A';
  37532. t['\uFB61'] = '\u067A';
  37533. t['\uFB62'] = '\u067F';
  37534. t['\uFB63'] = '\u067F';
  37535. t['\uFB64'] = '\u067F';
  37536. t['\uFB65'] = '\u067F';
  37537. t['\uFB66'] = '\u0679';
  37538. t['\uFB67'] = '\u0679';
  37539. t['\uFB68'] = '\u0679';
  37540. t['\uFB69'] = '\u0679';
  37541. t['\uFB6A'] = '\u06A4';
  37542. t['\uFB6B'] = '\u06A4';
  37543. t['\uFB6C'] = '\u06A4';
  37544. t['\uFB6D'] = '\u06A4';
  37545. t['\uFB6E'] = '\u06A6';
  37546. t['\uFB6F'] = '\u06A6';
  37547. t['\uFB70'] = '\u06A6';
  37548. t['\uFB71'] = '\u06A6';
  37549. t['\uFB72'] = '\u0684';
  37550. t['\uFB73'] = '\u0684';
  37551. t['\uFB74'] = '\u0684';
  37552. t['\uFB75'] = '\u0684';
  37553. t['\uFB76'] = '\u0683';
  37554. t['\uFB77'] = '\u0683';
  37555. t['\uFB78'] = '\u0683';
  37556. t['\uFB79'] = '\u0683';
  37557. t['\uFB7A'] = '\u0686';
  37558. t['\uFB7B'] = '\u0686';
  37559. t['\uFB7C'] = '\u0686';
  37560. t['\uFB7D'] = '\u0686';
  37561. t['\uFB7E'] = '\u0687';
  37562. t['\uFB7F'] = '\u0687';
  37563. t['\uFB80'] = '\u0687';
  37564. t['\uFB81'] = '\u0687';
  37565. t['\uFB82'] = '\u068D';
  37566. t['\uFB83'] = '\u068D';
  37567. t['\uFB84'] = '\u068C';
  37568. t['\uFB85'] = '\u068C';
  37569. t['\uFB86'] = '\u068E';
  37570. t['\uFB87'] = '\u068E';
  37571. t['\uFB88'] = '\u0688';
  37572. t['\uFB89'] = '\u0688';
  37573. t['\uFB8A'] = '\u0698';
  37574. t['\uFB8B'] = '\u0698';
  37575. t['\uFB8C'] = '\u0691';
  37576. t['\uFB8D'] = '\u0691';
  37577. t['\uFB8E'] = '\u06A9';
  37578. t['\uFB8F'] = '\u06A9';
  37579. t['\uFB90'] = '\u06A9';
  37580. t['\uFB91'] = '\u06A9';
  37581. t['\uFB92'] = '\u06AF';
  37582. t['\uFB93'] = '\u06AF';
  37583. t['\uFB94'] = '\u06AF';
  37584. t['\uFB95'] = '\u06AF';
  37585. t['\uFB96'] = '\u06B3';
  37586. t['\uFB97'] = '\u06B3';
  37587. t['\uFB98'] = '\u06B3';
  37588. t['\uFB99'] = '\u06B3';
  37589. t['\uFB9A'] = '\u06B1';
  37590. t['\uFB9B'] = '\u06B1';
  37591. t['\uFB9C'] = '\u06B1';
  37592. t['\uFB9D'] = '\u06B1';
  37593. t['\uFB9E'] = '\u06BA';
  37594. t['\uFB9F'] = '\u06BA';
  37595. t['\uFBA0'] = '\u06BB';
  37596. t['\uFBA1'] = '\u06BB';
  37597. t['\uFBA2'] = '\u06BB';
  37598. t['\uFBA3'] = '\u06BB';
  37599. t['\uFBA4'] = '\u06C0';
  37600. t['\uFBA5'] = '\u06C0';
  37601. t['\uFBA6'] = '\u06C1';
  37602. t['\uFBA7'] = '\u06C1';
  37603. t['\uFBA8'] = '\u06C1';
  37604. t['\uFBA9'] = '\u06C1';
  37605. t['\uFBAA'] = '\u06BE';
  37606. t['\uFBAB'] = '\u06BE';
  37607. t['\uFBAC'] = '\u06BE';
  37608. t['\uFBAD'] = '\u06BE';
  37609. t['\uFBAE'] = '\u06D2';
  37610. t['\uFBAF'] = '\u06D2';
  37611. t['\uFBB0'] = '\u06D3';
  37612. t['\uFBB1'] = '\u06D3';
  37613. t['\uFBD3'] = '\u06AD';
  37614. t['\uFBD4'] = '\u06AD';
  37615. t['\uFBD5'] = '\u06AD';
  37616. t['\uFBD6'] = '\u06AD';
  37617. t['\uFBD7'] = '\u06C7';
  37618. t['\uFBD8'] = '\u06C7';
  37619. t['\uFBD9'] = '\u06C6';
  37620. t['\uFBDA'] = '\u06C6';
  37621. t['\uFBDB'] = '\u06C8';
  37622. t['\uFBDC'] = '\u06C8';
  37623. t['\uFBDD'] = '\u0677';
  37624. t['\uFBDE'] = '\u06CB';
  37625. t['\uFBDF'] = '\u06CB';
  37626. t['\uFBE0'] = '\u06C5';
  37627. t['\uFBE1'] = '\u06C5';
  37628. t['\uFBE2'] = '\u06C9';
  37629. t['\uFBE3'] = '\u06C9';
  37630. t['\uFBE4'] = '\u06D0';
  37631. t['\uFBE5'] = '\u06D0';
  37632. t['\uFBE6'] = '\u06D0';
  37633. t['\uFBE7'] = '\u06D0';
  37634. t['\uFBE8'] = '\u0649';
  37635. t['\uFBE9'] = '\u0649';
  37636. t['\uFBEA'] = '\u0626\u0627';
  37637. t['\uFBEB'] = '\u0626\u0627';
  37638. t['\uFBEC'] = '\u0626\u06D5';
  37639. t['\uFBED'] = '\u0626\u06D5';
  37640. t['\uFBEE'] = '\u0626\u0648';
  37641. t['\uFBEF'] = '\u0626\u0648';
  37642. t['\uFBF0'] = '\u0626\u06C7';
  37643. t['\uFBF1'] = '\u0626\u06C7';
  37644. t['\uFBF2'] = '\u0626\u06C6';
  37645. t['\uFBF3'] = '\u0626\u06C6';
  37646. t['\uFBF4'] = '\u0626\u06C8';
  37647. t['\uFBF5'] = '\u0626\u06C8';
  37648. t['\uFBF6'] = '\u0626\u06D0';
  37649. t['\uFBF7'] = '\u0626\u06D0';
  37650. t['\uFBF8'] = '\u0626\u06D0';
  37651. t['\uFBF9'] = '\u0626\u0649';
  37652. t['\uFBFA'] = '\u0626\u0649';
  37653. t['\uFBFB'] = '\u0626\u0649';
  37654. t['\uFBFC'] = '\u06CC';
  37655. t['\uFBFD'] = '\u06CC';
  37656. t['\uFBFE'] = '\u06CC';
  37657. t['\uFBFF'] = '\u06CC';
  37658. t['\uFC00'] = '\u0626\u062C';
  37659. t['\uFC01'] = '\u0626\u062D';
  37660. t['\uFC02'] = '\u0626\u0645';
  37661. t['\uFC03'] = '\u0626\u0649';
  37662. t['\uFC04'] = '\u0626\u064A';
  37663. t['\uFC05'] = '\u0628\u062C';
  37664. t['\uFC06'] = '\u0628\u062D';
  37665. t['\uFC07'] = '\u0628\u062E';
  37666. t['\uFC08'] = '\u0628\u0645';
  37667. t['\uFC09'] = '\u0628\u0649';
  37668. t['\uFC0A'] = '\u0628\u064A';
  37669. t['\uFC0B'] = '\u062A\u062C';
  37670. t['\uFC0C'] = '\u062A\u062D';
  37671. t['\uFC0D'] = '\u062A\u062E';
  37672. t['\uFC0E'] = '\u062A\u0645';
  37673. t['\uFC0F'] = '\u062A\u0649';
  37674. t['\uFC10'] = '\u062A\u064A';
  37675. t['\uFC11'] = '\u062B\u062C';
  37676. t['\uFC12'] = '\u062B\u0645';
  37677. t['\uFC13'] = '\u062B\u0649';
  37678. t['\uFC14'] = '\u062B\u064A';
  37679. t['\uFC15'] = '\u062C\u062D';
  37680. t['\uFC16'] = '\u062C\u0645';
  37681. t['\uFC17'] = '\u062D\u062C';
  37682. t['\uFC18'] = '\u062D\u0645';
  37683. t['\uFC19'] = '\u062E\u062C';
  37684. t['\uFC1A'] = '\u062E\u062D';
  37685. t['\uFC1B'] = '\u062E\u0645';
  37686. t['\uFC1C'] = '\u0633\u062C';
  37687. t['\uFC1D'] = '\u0633\u062D';
  37688. t['\uFC1E'] = '\u0633\u062E';
  37689. t['\uFC1F'] = '\u0633\u0645';
  37690. t['\uFC20'] = '\u0635\u062D';
  37691. t['\uFC21'] = '\u0635\u0645';
  37692. t['\uFC22'] = '\u0636\u062C';
  37693. t['\uFC23'] = '\u0636\u062D';
  37694. t['\uFC24'] = '\u0636\u062E';
  37695. t['\uFC25'] = '\u0636\u0645';
  37696. t['\uFC26'] = '\u0637\u062D';
  37697. t['\uFC27'] = '\u0637\u0645';
  37698. t['\uFC28'] = '\u0638\u0645';
  37699. t['\uFC29'] = '\u0639\u062C';
  37700. t['\uFC2A'] = '\u0639\u0645';
  37701. t['\uFC2B'] = '\u063A\u062C';
  37702. t['\uFC2C'] = '\u063A\u0645';
  37703. t['\uFC2D'] = '\u0641\u062C';
  37704. t['\uFC2E'] = '\u0641\u062D';
  37705. t['\uFC2F'] = '\u0641\u062E';
  37706. t['\uFC30'] = '\u0641\u0645';
  37707. t['\uFC31'] = '\u0641\u0649';
  37708. t['\uFC32'] = '\u0641\u064A';
  37709. t['\uFC33'] = '\u0642\u062D';
  37710. t['\uFC34'] = '\u0642\u0645';
  37711. t['\uFC35'] = '\u0642\u0649';
  37712. t['\uFC36'] = '\u0642\u064A';
  37713. t['\uFC37'] = '\u0643\u0627';
  37714. t['\uFC38'] = '\u0643\u062C';
  37715. t['\uFC39'] = '\u0643\u062D';
  37716. t['\uFC3A'] = '\u0643\u062E';
  37717. t['\uFC3B'] = '\u0643\u0644';
  37718. t['\uFC3C'] = '\u0643\u0645';
  37719. t['\uFC3D'] = '\u0643\u0649';
  37720. t['\uFC3E'] = '\u0643\u064A';
  37721. t['\uFC3F'] = '\u0644\u062C';
  37722. t['\uFC40'] = '\u0644\u062D';
  37723. t['\uFC41'] = '\u0644\u062E';
  37724. t['\uFC42'] = '\u0644\u0645';
  37725. t['\uFC43'] = '\u0644\u0649';
  37726. t['\uFC44'] = '\u0644\u064A';
  37727. t['\uFC45'] = '\u0645\u062C';
  37728. t['\uFC46'] = '\u0645\u062D';
  37729. t['\uFC47'] = '\u0645\u062E';
  37730. t['\uFC48'] = '\u0645\u0645';
  37731. t['\uFC49'] = '\u0645\u0649';
  37732. t['\uFC4A'] = '\u0645\u064A';
  37733. t['\uFC4B'] = '\u0646\u062C';
  37734. t['\uFC4C'] = '\u0646\u062D';
  37735. t['\uFC4D'] = '\u0646\u062E';
  37736. t['\uFC4E'] = '\u0646\u0645';
  37737. t['\uFC4F'] = '\u0646\u0649';
  37738. t['\uFC50'] = '\u0646\u064A';
  37739. t['\uFC51'] = '\u0647\u062C';
  37740. t['\uFC52'] = '\u0647\u0645';
  37741. t['\uFC53'] = '\u0647\u0649';
  37742. t['\uFC54'] = '\u0647\u064A';
  37743. t['\uFC55'] = '\u064A\u062C';
  37744. t['\uFC56'] = '\u064A\u062D';
  37745. t['\uFC57'] = '\u064A\u062E';
  37746. t['\uFC58'] = '\u064A\u0645';
  37747. t['\uFC59'] = '\u064A\u0649';
  37748. t['\uFC5A'] = '\u064A\u064A';
  37749. t['\uFC5B'] = '\u0630\u0670';
  37750. t['\uFC5C'] = '\u0631\u0670';
  37751. t['\uFC5D'] = '\u0649\u0670';
  37752. t['\uFC5E'] = '\u0020\u064C\u0651';
  37753. t['\uFC5F'] = '\u0020\u064D\u0651';
  37754. t['\uFC60'] = '\u0020\u064E\u0651';
  37755. t['\uFC61'] = '\u0020\u064F\u0651';
  37756. t['\uFC62'] = '\u0020\u0650\u0651';
  37757. t['\uFC63'] = '\u0020\u0651\u0670';
  37758. t['\uFC64'] = '\u0626\u0631';
  37759. t['\uFC65'] = '\u0626\u0632';
  37760. t['\uFC66'] = '\u0626\u0645';
  37761. t['\uFC67'] = '\u0626\u0646';
  37762. t['\uFC68'] = '\u0626\u0649';
  37763. t['\uFC69'] = '\u0626\u064A';
  37764. t['\uFC6A'] = '\u0628\u0631';
  37765. t['\uFC6B'] = '\u0628\u0632';
  37766. t['\uFC6C'] = '\u0628\u0645';
  37767. t['\uFC6D'] = '\u0628\u0646';
  37768. t['\uFC6E'] = '\u0628\u0649';
  37769. t['\uFC6F'] = '\u0628\u064A';
  37770. t['\uFC70'] = '\u062A\u0631';
  37771. t['\uFC71'] = '\u062A\u0632';
  37772. t['\uFC72'] = '\u062A\u0645';
  37773. t['\uFC73'] = '\u062A\u0646';
  37774. t['\uFC74'] = '\u062A\u0649';
  37775. t['\uFC75'] = '\u062A\u064A';
  37776. t['\uFC76'] = '\u062B\u0631';
  37777. t['\uFC77'] = '\u062B\u0632';
  37778. t['\uFC78'] = '\u062B\u0645';
  37779. t['\uFC79'] = '\u062B\u0646';
  37780. t['\uFC7A'] = '\u062B\u0649';
  37781. t['\uFC7B'] = '\u062B\u064A';
  37782. t['\uFC7C'] = '\u0641\u0649';
  37783. t['\uFC7D'] = '\u0641\u064A';
  37784. t['\uFC7E'] = '\u0642\u0649';
  37785. t['\uFC7F'] = '\u0642\u064A';
  37786. t['\uFC80'] = '\u0643\u0627';
  37787. t['\uFC81'] = '\u0643\u0644';
  37788. t['\uFC82'] = '\u0643\u0645';
  37789. t['\uFC83'] = '\u0643\u0649';
  37790. t['\uFC84'] = '\u0643\u064A';
  37791. t['\uFC85'] = '\u0644\u0645';
  37792. t['\uFC86'] = '\u0644\u0649';
  37793. t['\uFC87'] = '\u0644\u064A';
  37794. t['\uFC88'] = '\u0645\u0627';
  37795. t['\uFC89'] = '\u0645\u0645';
  37796. t['\uFC8A'] = '\u0646\u0631';
  37797. t['\uFC8B'] = '\u0646\u0632';
  37798. t['\uFC8C'] = '\u0646\u0645';
  37799. t['\uFC8D'] = '\u0646\u0646';
  37800. t['\uFC8E'] = '\u0646\u0649';
  37801. t['\uFC8F'] = '\u0646\u064A';
  37802. t['\uFC90'] = '\u0649\u0670';
  37803. t['\uFC91'] = '\u064A\u0631';
  37804. t['\uFC92'] = '\u064A\u0632';
  37805. t['\uFC93'] = '\u064A\u0645';
  37806. t['\uFC94'] = '\u064A\u0646';
  37807. t['\uFC95'] = '\u064A\u0649';
  37808. t['\uFC96'] = '\u064A\u064A';
  37809. t['\uFC97'] = '\u0626\u062C';
  37810. t['\uFC98'] = '\u0626\u062D';
  37811. t['\uFC99'] = '\u0626\u062E';
  37812. t['\uFC9A'] = '\u0626\u0645';
  37813. t['\uFC9B'] = '\u0626\u0647';
  37814. t['\uFC9C'] = '\u0628\u062C';
  37815. t['\uFC9D'] = '\u0628\u062D';
  37816. t['\uFC9E'] = '\u0628\u062E';
  37817. t['\uFC9F'] = '\u0628\u0645';
  37818. t['\uFCA0'] = '\u0628\u0647';
  37819. t['\uFCA1'] = '\u062A\u062C';
  37820. t['\uFCA2'] = '\u062A\u062D';
  37821. t['\uFCA3'] = '\u062A\u062E';
  37822. t['\uFCA4'] = '\u062A\u0645';
  37823. t['\uFCA5'] = '\u062A\u0647';
  37824. t['\uFCA6'] = '\u062B\u0645';
  37825. t['\uFCA7'] = '\u062C\u062D';
  37826. t['\uFCA8'] = '\u062C\u0645';
  37827. t['\uFCA9'] = '\u062D\u062C';
  37828. t['\uFCAA'] = '\u062D\u0645';
  37829. t['\uFCAB'] = '\u062E\u062C';
  37830. t['\uFCAC'] = '\u062E\u0645';
  37831. t['\uFCAD'] = '\u0633\u062C';
  37832. t['\uFCAE'] = '\u0633\u062D';
  37833. t['\uFCAF'] = '\u0633\u062E';
  37834. t['\uFCB0'] = '\u0633\u0645';
  37835. t['\uFCB1'] = '\u0635\u062D';
  37836. t['\uFCB2'] = '\u0635\u062E';
  37837. t['\uFCB3'] = '\u0635\u0645';
  37838. t['\uFCB4'] = '\u0636\u062C';
  37839. t['\uFCB5'] = '\u0636\u062D';
  37840. t['\uFCB6'] = '\u0636\u062E';
  37841. t['\uFCB7'] = '\u0636\u0645';
  37842. t['\uFCB8'] = '\u0637\u062D';
  37843. t['\uFCB9'] = '\u0638\u0645';
  37844. t['\uFCBA'] = '\u0639\u062C';
  37845. t['\uFCBB'] = '\u0639\u0645';
  37846. t['\uFCBC'] = '\u063A\u062C';
  37847. t['\uFCBD'] = '\u063A\u0645';
  37848. t['\uFCBE'] = '\u0641\u062C';
  37849. t['\uFCBF'] = '\u0641\u062D';
  37850. t['\uFCC0'] = '\u0641\u062E';
  37851. t['\uFCC1'] = '\u0641\u0645';
  37852. t['\uFCC2'] = '\u0642\u062D';
  37853. t['\uFCC3'] = '\u0642\u0645';
  37854. t['\uFCC4'] = '\u0643\u062C';
  37855. t['\uFCC5'] = '\u0643\u062D';
  37856. t['\uFCC6'] = '\u0643\u062E';
  37857. t['\uFCC7'] = '\u0643\u0644';
  37858. t['\uFCC8'] = '\u0643\u0645';
  37859. t['\uFCC9'] = '\u0644\u062C';
  37860. t['\uFCCA'] = '\u0644\u062D';
  37861. t['\uFCCB'] = '\u0644\u062E';
  37862. t['\uFCCC'] = '\u0644\u0645';
  37863. t['\uFCCD'] = '\u0644\u0647';
  37864. t['\uFCCE'] = '\u0645\u062C';
  37865. t['\uFCCF'] = '\u0645\u062D';
  37866. t['\uFCD0'] = '\u0645\u062E';
  37867. t['\uFCD1'] = '\u0645\u0645';
  37868. t['\uFCD2'] = '\u0646\u062C';
  37869. t['\uFCD3'] = '\u0646\u062D';
  37870. t['\uFCD4'] = '\u0646\u062E';
  37871. t['\uFCD5'] = '\u0646\u0645';
  37872. t['\uFCD6'] = '\u0646\u0647';
  37873. t['\uFCD7'] = '\u0647\u062C';
  37874. t['\uFCD8'] = '\u0647\u0645';
  37875. t['\uFCD9'] = '\u0647\u0670';
  37876. t['\uFCDA'] = '\u064A\u062C';
  37877. t['\uFCDB'] = '\u064A\u062D';
  37878. t['\uFCDC'] = '\u064A\u062E';
  37879. t['\uFCDD'] = '\u064A\u0645';
  37880. t['\uFCDE'] = '\u064A\u0647';
  37881. t['\uFCDF'] = '\u0626\u0645';
  37882. t['\uFCE0'] = '\u0626\u0647';
  37883. t['\uFCE1'] = '\u0628\u0645';
  37884. t['\uFCE2'] = '\u0628\u0647';
  37885. t['\uFCE3'] = '\u062A\u0645';
  37886. t['\uFCE4'] = '\u062A\u0647';
  37887. t['\uFCE5'] = '\u062B\u0645';
  37888. t['\uFCE6'] = '\u062B\u0647';
  37889. t['\uFCE7'] = '\u0633\u0645';
  37890. t['\uFCE8'] = '\u0633\u0647';
  37891. t['\uFCE9'] = '\u0634\u0645';
  37892. t['\uFCEA'] = '\u0634\u0647';
  37893. t['\uFCEB'] = '\u0643\u0644';
  37894. t['\uFCEC'] = '\u0643\u0645';
  37895. t['\uFCED'] = '\u0644\u0645';
  37896. t['\uFCEE'] = '\u0646\u0645';
  37897. t['\uFCEF'] = '\u0646\u0647';
  37898. t['\uFCF0'] = '\u064A\u0645';
  37899. t['\uFCF1'] = '\u064A\u0647';
  37900. t['\uFCF2'] = '\u0640\u064E\u0651';
  37901. t['\uFCF3'] = '\u0640\u064F\u0651';
  37902. t['\uFCF4'] = '\u0640\u0650\u0651';
  37903. t['\uFCF5'] = '\u0637\u0649';
  37904. t['\uFCF6'] = '\u0637\u064A';
  37905. t['\uFCF7'] = '\u0639\u0649';
  37906. t['\uFCF8'] = '\u0639\u064A';
  37907. t['\uFCF9'] = '\u063A\u0649';
  37908. t['\uFCFA'] = '\u063A\u064A';
  37909. t['\uFCFB'] = '\u0633\u0649';
  37910. t['\uFCFC'] = '\u0633\u064A';
  37911. t['\uFCFD'] = '\u0634\u0649';
  37912. t['\uFCFE'] = '\u0634\u064A';
  37913. t['\uFCFF'] = '\u062D\u0649';
  37914. t['\uFD00'] = '\u062D\u064A';
  37915. t['\uFD01'] = '\u062C\u0649';
  37916. t['\uFD02'] = '\u062C\u064A';
  37917. t['\uFD03'] = '\u062E\u0649';
  37918. t['\uFD04'] = '\u062E\u064A';
  37919. t['\uFD05'] = '\u0635\u0649';
  37920. t['\uFD06'] = '\u0635\u064A';
  37921. t['\uFD07'] = '\u0636\u0649';
  37922. t['\uFD08'] = '\u0636\u064A';
  37923. t['\uFD09'] = '\u0634\u062C';
  37924. t['\uFD0A'] = '\u0634\u062D';
  37925. t['\uFD0B'] = '\u0634\u062E';
  37926. t['\uFD0C'] = '\u0634\u0645';
  37927. t['\uFD0D'] = '\u0634\u0631';
  37928. t['\uFD0E'] = '\u0633\u0631';
  37929. t['\uFD0F'] = '\u0635\u0631';
  37930. t['\uFD10'] = '\u0636\u0631';
  37931. t['\uFD11'] = '\u0637\u0649';
  37932. t['\uFD12'] = '\u0637\u064A';
  37933. t['\uFD13'] = '\u0639\u0649';
  37934. t['\uFD14'] = '\u0639\u064A';
  37935. t['\uFD15'] = '\u063A\u0649';
  37936. t['\uFD16'] = '\u063A\u064A';
  37937. t['\uFD17'] = '\u0633\u0649';
  37938. t['\uFD18'] = '\u0633\u064A';
  37939. t['\uFD19'] = '\u0634\u0649';
  37940. t['\uFD1A'] = '\u0634\u064A';
  37941. t['\uFD1B'] = '\u062D\u0649';
  37942. t['\uFD1C'] = '\u062D\u064A';
  37943. t['\uFD1D'] = '\u062C\u0649';
  37944. t['\uFD1E'] = '\u062C\u064A';
  37945. t['\uFD1F'] = '\u062E\u0649';
  37946. t['\uFD20'] = '\u062E\u064A';
  37947. t['\uFD21'] = '\u0635\u0649';
  37948. t['\uFD22'] = '\u0635\u064A';
  37949. t['\uFD23'] = '\u0636\u0649';
  37950. t['\uFD24'] = '\u0636\u064A';
  37951. t['\uFD25'] = '\u0634\u062C';
  37952. t['\uFD26'] = '\u0634\u062D';
  37953. t['\uFD27'] = '\u0634\u062E';
  37954. t['\uFD28'] = '\u0634\u0645';
  37955. t['\uFD29'] = '\u0634\u0631';
  37956. t['\uFD2A'] = '\u0633\u0631';
  37957. t['\uFD2B'] = '\u0635\u0631';
  37958. t['\uFD2C'] = '\u0636\u0631';
  37959. t['\uFD2D'] = '\u0634\u062C';
  37960. t['\uFD2E'] = '\u0634\u062D';
  37961. t['\uFD2F'] = '\u0634\u062E';
  37962. t['\uFD30'] = '\u0634\u0645';
  37963. t['\uFD31'] = '\u0633\u0647';
  37964. t['\uFD32'] = '\u0634\u0647';
  37965. t['\uFD33'] = '\u0637\u0645';
  37966. t['\uFD34'] = '\u0633\u062C';
  37967. t['\uFD35'] = '\u0633\u062D';
  37968. t['\uFD36'] = '\u0633\u062E';
  37969. t['\uFD37'] = '\u0634\u062C';
  37970. t['\uFD38'] = '\u0634\u062D';
  37971. t['\uFD39'] = '\u0634\u062E';
  37972. t['\uFD3A'] = '\u0637\u0645';
  37973. t['\uFD3B'] = '\u0638\u0645';
  37974. t['\uFD3C'] = '\u0627\u064B';
  37975. t['\uFD3D'] = '\u0627\u064B';
  37976. t['\uFD50'] = '\u062A\u062C\u0645';
  37977. t['\uFD51'] = '\u062A\u062D\u062C';
  37978. t['\uFD52'] = '\u062A\u062D\u062C';
  37979. t['\uFD53'] = '\u062A\u062D\u0645';
  37980. t['\uFD54'] = '\u062A\u062E\u0645';
  37981. t['\uFD55'] = '\u062A\u0645\u062C';
  37982. t['\uFD56'] = '\u062A\u0645\u062D';
  37983. t['\uFD57'] = '\u062A\u0645\u062E';
  37984. t['\uFD58'] = '\u062C\u0645\u062D';
  37985. t['\uFD59'] = '\u062C\u0645\u062D';
  37986. t['\uFD5A'] = '\u062D\u0645\u064A';
  37987. t['\uFD5B'] = '\u062D\u0645\u0649';
  37988. t['\uFD5C'] = '\u0633\u062D\u062C';
  37989. t['\uFD5D'] = '\u0633\u062C\u062D';
  37990. t['\uFD5E'] = '\u0633\u062C\u0649';
  37991. t['\uFD5F'] = '\u0633\u0645\u062D';
  37992. t['\uFD60'] = '\u0633\u0645\u062D';
  37993. t['\uFD61'] = '\u0633\u0645\u062C';
  37994. t['\uFD62'] = '\u0633\u0645\u0645';
  37995. t['\uFD63'] = '\u0633\u0645\u0645';
  37996. t['\uFD64'] = '\u0635\u062D\u062D';
  37997. t['\uFD65'] = '\u0635\u062D\u062D';
  37998. t['\uFD66'] = '\u0635\u0645\u0645';
  37999. t['\uFD67'] = '\u0634\u062D\u0645';
  38000. t['\uFD68'] = '\u0634\u062D\u0645';
  38001. t['\uFD69'] = '\u0634\u062C\u064A';
  38002. t['\uFD6A'] = '\u0634\u0645\u062E';
  38003. t['\uFD6B'] = '\u0634\u0645\u062E';
  38004. t['\uFD6C'] = '\u0634\u0645\u0645';
  38005. t['\uFD6D'] = '\u0634\u0645\u0645';
  38006. t['\uFD6E'] = '\u0636\u062D\u0649';
  38007. t['\uFD6F'] = '\u0636\u062E\u0645';
  38008. t['\uFD70'] = '\u0636\u062E\u0645';
  38009. t['\uFD71'] = '\u0637\u0645\u062D';
  38010. t['\uFD72'] = '\u0637\u0645\u062D';
  38011. t['\uFD73'] = '\u0637\u0645\u0645';
  38012. t['\uFD74'] = '\u0637\u0645\u064A';
  38013. t['\uFD75'] = '\u0639\u062C\u0645';
  38014. t['\uFD76'] = '\u0639\u0645\u0645';
  38015. t['\uFD77'] = '\u0639\u0645\u0645';
  38016. t['\uFD78'] = '\u0639\u0645\u0649';
  38017. t['\uFD79'] = '\u063A\u0645\u0645';
  38018. t['\uFD7A'] = '\u063A\u0645\u064A';
  38019. t['\uFD7B'] = '\u063A\u0645\u0649';
  38020. t['\uFD7C'] = '\u0641\u062E\u0645';
  38021. t['\uFD7D'] = '\u0641\u062E\u0645';
  38022. t['\uFD7E'] = '\u0642\u0645\u062D';
  38023. t['\uFD7F'] = '\u0642\u0645\u0645';
  38024. t['\uFD80'] = '\u0644\u062D\u0645';
  38025. t['\uFD81'] = '\u0644\u062D\u064A';
  38026. t['\uFD82'] = '\u0644\u062D\u0649';
  38027. t['\uFD83'] = '\u0644\u062C\u062C';
  38028. t['\uFD84'] = '\u0644\u062C\u062C';
  38029. t['\uFD85'] = '\u0644\u062E\u0645';
  38030. t['\uFD86'] = '\u0644\u062E\u0645';
  38031. t['\uFD87'] = '\u0644\u0645\u062D';
  38032. t['\uFD88'] = '\u0644\u0645\u062D';
  38033. t['\uFD89'] = '\u0645\u062D\u062C';
  38034. t['\uFD8A'] = '\u0645\u062D\u0645';
  38035. t['\uFD8B'] = '\u0645\u062D\u064A';
  38036. t['\uFD8C'] = '\u0645\u062C\u062D';
  38037. t['\uFD8D'] = '\u0645\u062C\u0645';
  38038. t['\uFD8E'] = '\u0645\u062E\u062C';
  38039. t['\uFD8F'] = '\u0645\u062E\u0645';
  38040. t['\uFD92'] = '\u0645\u062C\u062E';
  38041. t['\uFD93'] = '\u0647\u0645\u062C';
  38042. t['\uFD94'] = '\u0647\u0645\u0645';
  38043. t['\uFD95'] = '\u0646\u062D\u0645';
  38044. t['\uFD96'] = '\u0646\u062D\u0649';
  38045. t['\uFD97'] = '\u0646\u062C\u0645';
  38046. t['\uFD98'] = '\u0646\u062C\u0645';
  38047. t['\uFD99'] = '\u0646\u062C\u0649';
  38048. t['\uFD9A'] = '\u0646\u0645\u064A';
  38049. t['\uFD9B'] = '\u0646\u0645\u0649';
  38050. t['\uFD9C'] = '\u064A\u0645\u0645';
  38051. t['\uFD9D'] = '\u064A\u0645\u0645';
  38052. t['\uFD9E'] = '\u0628\u062E\u064A';
  38053. t['\uFD9F'] = '\u062A\u062C\u064A';
  38054. t['\uFDA0'] = '\u062A\u062C\u0649';
  38055. t['\uFDA1'] = '\u062A\u062E\u064A';
  38056. t['\uFDA2'] = '\u062A\u062E\u0649';
  38057. t['\uFDA3'] = '\u062A\u0645\u064A';
  38058. t['\uFDA4'] = '\u062A\u0645\u0649';
  38059. t['\uFDA5'] = '\u062C\u0645\u064A';
  38060. t['\uFDA6'] = '\u062C\u062D\u0649';
  38061. t['\uFDA7'] = '\u062C\u0645\u0649';
  38062. t['\uFDA8'] = '\u0633\u062E\u0649';
  38063. t['\uFDA9'] = '\u0635\u062D\u064A';
  38064. t['\uFDAA'] = '\u0634\u062D\u064A';
  38065. t['\uFDAB'] = '\u0636\u062D\u064A';
  38066. t['\uFDAC'] = '\u0644\u062C\u064A';
  38067. t['\uFDAD'] = '\u0644\u0645\u064A';
  38068. t['\uFDAE'] = '\u064A\u062D\u064A';
  38069. t['\uFDAF'] = '\u064A\u062C\u064A';
  38070. t['\uFDB0'] = '\u064A\u0645\u064A';
  38071. t['\uFDB1'] = '\u0645\u0645\u064A';
  38072. t['\uFDB2'] = '\u0642\u0645\u064A';
  38073. t['\uFDB3'] = '\u0646\u062D\u064A';
  38074. t['\uFDB4'] = '\u0642\u0645\u062D';
  38075. t['\uFDB5'] = '\u0644\u062D\u0645';
  38076. t['\uFDB6'] = '\u0639\u0645\u064A';
  38077. t['\uFDB7'] = '\u0643\u0645\u064A';
  38078. t['\uFDB8'] = '\u0646\u062C\u062D';
  38079. t['\uFDB9'] = '\u0645\u062E\u064A';
  38080. t['\uFDBA'] = '\u0644\u062C\u0645';
  38081. t['\uFDBB'] = '\u0643\u0645\u0645';
  38082. t['\uFDBC'] = '\u0644\u062C\u0645';
  38083. t['\uFDBD'] = '\u0646\u062C\u062D';
  38084. t['\uFDBE'] = '\u062C\u062D\u064A';
  38085. t['\uFDBF'] = '\u062D\u062C\u064A';
  38086. t['\uFDC0'] = '\u0645\u062C\u064A';
  38087. t['\uFDC1'] = '\u0641\u0645\u064A';
  38088. t['\uFDC2'] = '\u0628\u062D\u064A';
  38089. t['\uFDC3'] = '\u0643\u0645\u0645';
  38090. t['\uFDC4'] = '\u0639\u062C\u0645';
  38091. t['\uFDC5'] = '\u0635\u0645\u0645';
  38092. t['\uFDC6'] = '\u0633\u062E\u064A';
  38093. t['\uFDC7'] = '\u0646\u062C\u064A';
  38094. t['\uFE49'] = '\u203E';
  38095. t['\uFE4A'] = '\u203E';
  38096. t['\uFE4B'] = '\u203E';
  38097. t['\uFE4C'] = '\u203E';
  38098. t['\uFE4D'] = '\u005F';
  38099. t['\uFE4E'] = '\u005F';
  38100. t['\uFE4F'] = '\u005F';
  38101. t['\uFE80'] = '\u0621';
  38102. t['\uFE81'] = '\u0622';
  38103. t['\uFE82'] = '\u0622';
  38104. t['\uFE83'] = '\u0623';
  38105. t['\uFE84'] = '\u0623';
  38106. t['\uFE85'] = '\u0624';
  38107. t['\uFE86'] = '\u0624';
  38108. t['\uFE87'] = '\u0625';
  38109. t['\uFE88'] = '\u0625';
  38110. t['\uFE89'] = '\u0626';
  38111. t['\uFE8A'] = '\u0626';
  38112. t['\uFE8B'] = '\u0626';
  38113. t['\uFE8C'] = '\u0626';
  38114. t['\uFE8D'] = '\u0627';
  38115. t['\uFE8E'] = '\u0627';
  38116. t['\uFE8F'] = '\u0628';
  38117. t['\uFE90'] = '\u0628';
  38118. t['\uFE91'] = '\u0628';
  38119. t['\uFE92'] = '\u0628';
  38120. t['\uFE93'] = '\u0629';
  38121. t['\uFE94'] = '\u0629';
  38122. t['\uFE95'] = '\u062A';
  38123. t['\uFE96'] = '\u062A';
  38124. t['\uFE97'] = '\u062A';
  38125. t['\uFE98'] = '\u062A';
  38126. t['\uFE99'] = '\u062B';
  38127. t['\uFE9A'] = '\u062B';
  38128. t['\uFE9B'] = '\u062B';
  38129. t['\uFE9C'] = '\u062B';
  38130. t['\uFE9D'] = '\u062C';
  38131. t['\uFE9E'] = '\u062C';
  38132. t['\uFE9F'] = '\u062C';
  38133. t['\uFEA0'] = '\u062C';
  38134. t['\uFEA1'] = '\u062D';
  38135. t['\uFEA2'] = '\u062D';
  38136. t['\uFEA3'] = '\u062D';
  38137. t['\uFEA4'] = '\u062D';
  38138. t['\uFEA5'] = '\u062E';
  38139. t['\uFEA6'] = '\u062E';
  38140. t['\uFEA7'] = '\u062E';
  38141. t['\uFEA8'] = '\u062E';
  38142. t['\uFEA9'] = '\u062F';
  38143. t['\uFEAA'] = '\u062F';
  38144. t['\uFEAB'] = '\u0630';
  38145. t['\uFEAC'] = '\u0630';
  38146. t['\uFEAD'] = '\u0631';
  38147. t['\uFEAE'] = '\u0631';
  38148. t['\uFEAF'] = '\u0632';
  38149. t['\uFEB0'] = '\u0632';
  38150. t['\uFEB1'] = '\u0633';
  38151. t['\uFEB2'] = '\u0633';
  38152. t['\uFEB3'] = '\u0633';
  38153. t['\uFEB4'] = '\u0633';
  38154. t['\uFEB5'] = '\u0634';
  38155. t['\uFEB6'] = '\u0634';
  38156. t['\uFEB7'] = '\u0634';
  38157. t['\uFEB8'] = '\u0634';
  38158. t['\uFEB9'] = '\u0635';
  38159. t['\uFEBA'] = '\u0635';
  38160. t['\uFEBB'] = '\u0635';
  38161. t['\uFEBC'] = '\u0635';
  38162. t['\uFEBD'] = '\u0636';
  38163. t['\uFEBE'] = '\u0636';
  38164. t['\uFEBF'] = '\u0636';
  38165. t['\uFEC0'] = '\u0636';
  38166. t['\uFEC1'] = '\u0637';
  38167. t['\uFEC2'] = '\u0637';
  38168. t['\uFEC3'] = '\u0637';
  38169. t['\uFEC4'] = '\u0637';
  38170. t['\uFEC5'] = '\u0638';
  38171. t['\uFEC6'] = '\u0638';
  38172. t['\uFEC7'] = '\u0638';
  38173. t['\uFEC8'] = '\u0638';
  38174. t['\uFEC9'] = '\u0639';
  38175. t['\uFECA'] = '\u0639';
  38176. t['\uFECB'] = '\u0639';
  38177. t['\uFECC'] = '\u0639';
  38178. t['\uFECD'] = '\u063A';
  38179. t['\uFECE'] = '\u063A';
  38180. t['\uFECF'] = '\u063A';
  38181. t['\uFED0'] = '\u063A';
  38182. t['\uFED1'] = '\u0641';
  38183. t['\uFED2'] = '\u0641';
  38184. t['\uFED3'] = '\u0641';
  38185. t['\uFED4'] = '\u0641';
  38186. t['\uFED5'] = '\u0642';
  38187. t['\uFED6'] = '\u0642';
  38188. t['\uFED7'] = '\u0642';
  38189. t['\uFED8'] = '\u0642';
  38190. t['\uFED9'] = '\u0643';
  38191. t['\uFEDA'] = '\u0643';
  38192. t['\uFEDB'] = '\u0643';
  38193. t['\uFEDC'] = '\u0643';
  38194. t['\uFEDD'] = '\u0644';
  38195. t['\uFEDE'] = '\u0644';
  38196. t['\uFEDF'] = '\u0644';
  38197. t['\uFEE0'] = '\u0644';
  38198. t['\uFEE1'] = '\u0645';
  38199. t['\uFEE2'] = '\u0645';
  38200. t['\uFEE3'] = '\u0645';
  38201. t['\uFEE4'] = '\u0645';
  38202. t['\uFEE5'] = '\u0646';
  38203. t['\uFEE6'] = '\u0646';
  38204. t['\uFEE7'] = '\u0646';
  38205. t['\uFEE8'] = '\u0646';
  38206. t['\uFEE9'] = '\u0647';
  38207. t['\uFEEA'] = '\u0647';
  38208. t['\uFEEB'] = '\u0647';
  38209. t['\uFEEC'] = '\u0647';
  38210. t['\uFEED'] = '\u0648';
  38211. t['\uFEEE'] = '\u0648';
  38212. t['\uFEEF'] = '\u0649';
  38213. t['\uFEF0'] = '\u0649';
  38214. t['\uFEF1'] = '\u064A';
  38215. t['\uFEF2'] = '\u064A';
  38216. t['\uFEF3'] = '\u064A';
  38217. t['\uFEF4'] = '\u064A';
  38218. t['\uFEF5'] = '\u0644\u0622';
  38219. t['\uFEF6'] = '\u0644\u0622';
  38220. t['\uFEF7'] = '\u0644\u0623';
  38221. t['\uFEF8'] = '\u0644\u0623';
  38222. t['\uFEF9'] = '\u0644\u0625';
  38223. t['\uFEFA'] = '\u0644\u0625';
  38224. t['\uFEFB'] = '\u0644\u0627';
  38225. t['\uFEFC'] = '\u0644\u0627';
  38226. });
  38227. function reverseIfRtl(chars) {
  38228. var charsLength = chars.length;
  38229. if (charsLength <= 1 || !isRTLRangeFor(chars.charCodeAt(0))) {
  38230. return chars;
  38231. }
  38232. var s = '';
  38233. for (var ii = charsLength - 1; ii >= 0; ii--) {
  38234. s += chars[ii];
  38235. }
  38236. return s;
  38237. }
  38238. exports.mapSpecialUnicodeValues = mapSpecialUnicodeValues;
  38239. exports.reverseIfRtl = reverseIfRtl;
  38240. exports.getUnicodeRangeFor = getUnicodeRangeFor;
  38241. exports.getNormalizedUnicodes = getNormalizedUnicodes;
  38242. exports.getUnicodeForGlyph = getUnicodeForGlyph;
  38243. /***/ }),
  38244. /* 22 */
  38245. /***/ (function(module, exports, __w_pdfjs_require__) {
  38246. "use strict";
  38247. var sharedUtil = __w_pdfjs_require__(0);
  38248. var corePrimitives = __w_pdfjs_require__(1);
  38249. var corePdfManager = __w_pdfjs_require__(41);
  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. function isNodeJS() {
  38962. if (typeof __pdfjsdev_webpack__ === 'undefined') {
  38963. return typeof process === 'object' && process + '' === '[object process]';
  38964. }
  38965. return false;
  38966. }
  38967. if (typeof window === 'undefined' && !isNodeJS()) {
  38968. initializeWorker();
  38969. }
  38970. exports.setPDFNetworkStreamClass = setPDFNetworkStreamClass;
  38971. exports.WorkerTask = WorkerTask;
  38972. exports.WorkerMessageHandler = WorkerMessageHandler;
  38973. /***/ }),
  38974. /* 23 */
  38975. /***/ (function(module, exports, __w_pdfjs_require__) {
  38976. "use strict";
  38977. var sharedUtil = __w_pdfjs_require__(0);
  38978. var error = sharedUtil.error;
  38979. function fixMetadata(meta) {
  38980. return meta.replace(/>\\376\\377([^<]+)/g, function (all, codes) {
  38981. var bytes = codes.replace(/\\([0-3])([0-7])([0-7])/g, function (code, d1, d2, d3) {
  38982. return String.fromCharCode(d1 * 64 + d2 * 8 + d3 * 1);
  38983. });
  38984. var chars = '';
  38985. for (var i = 0; i < bytes.length; i += 2) {
  38986. var code = bytes.charCodeAt(i) * 256 + bytes.charCodeAt(i + 1);
  38987. chars += code >= 32 && code < 127 && code !== 60 && code !== 62 && code !== 38 ? String.fromCharCode(code) : '&#x' + (0x10000 + code).toString(16).substring(1) + ';';
  38988. }
  38989. return '>' + chars;
  38990. });
  38991. }
  38992. function Metadata(meta) {
  38993. if (typeof meta === 'string') {
  38994. meta = fixMetadata(meta);
  38995. var parser = new DOMParser();
  38996. meta = parser.parseFromString(meta, 'application/xml');
  38997. } else if (!(meta instanceof Document)) {
  38998. error('Metadata: Invalid metadata object');
  38999. }
  39000. this.metaDocument = meta;
  39001. this.metadata = Object.create(null);
  39002. this.parse();
  39003. }
  39004. Metadata.prototype = {
  39005. parse: function Metadata_parse() {
  39006. var doc = this.metaDocument;
  39007. var rdf = doc.documentElement;
  39008. if (rdf.nodeName.toLowerCase() !== 'rdf:rdf') {
  39009. rdf = rdf.firstChild;
  39010. while (rdf && rdf.nodeName.toLowerCase() !== 'rdf:rdf') {
  39011. rdf = rdf.nextSibling;
  39012. }
  39013. }
  39014. var nodeName = rdf ? rdf.nodeName.toLowerCase() : null;
  39015. if (!rdf || nodeName !== 'rdf:rdf' || !rdf.hasChildNodes()) {
  39016. return;
  39017. }
  39018. var children = rdf.childNodes, desc, entry, name, i, ii, length, iLength;
  39019. for (i = 0, length = children.length; i < length; i++) {
  39020. desc = children[i];
  39021. if (desc.nodeName.toLowerCase() !== 'rdf:description') {
  39022. continue;
  39023. }
  39024. for (ii = 0, iLength = desc.childNodes.length; ii < iLength; ii++) {
  39025. if (desc.childNodes[ii].nodeName.toLowerCase() !== '#text') {
  39026. entry = desc.childNodes[ii];
  39027. name = entry.nodeName.toLowerCase();
  39028. this.metadata[name] = entry.textContent.trim();
  39029. }
  39030. }
  39031. }
  39032. },
  39033. get: function Metadata_get(name) {
  39034. return this.metadata[name] || null;
  39035. },
  39036. has: function Metadata_has(name) {
  39037. return typeof this.metadata[name] !== 'undefined';
  39038. }
  39039. };
  39040. exports.Metadata = Metadata;
  39041. /***/ }),
  39042. /* 24 */
  39043. /***/ (function(module, exports, __w_pdfjs_require__) {
  39044. "use strict";
  39045. var sharedUtil = __w_pdfjs_require__(0);
  39046. var displayDOMUtils = __w_pdfjs_require__(3);
  39047. var shadow = sharedUtil.shadow;
  39048. var getDefaultSetting = displayDOMUtils.getDefaultSetting;
  39049. var WebGLUtils = function WebGLUtilsClosure() {
  39050. function loadShader(gl, code, shaderType) {
  39051. var shader = gl.createShader(shaderType);
  39052. gl.shaderSource(shader, code);
  39053. gl.compileShader(shader);
  39054. var compiled = gl.getShaderParameter(shader, gl.COMPILE_STATUS);
  39055. if (!compiled) {
  39056. var errorMsg = gl.getShaderInfoLog(shader);
  39057. throw new Error('Error during shader compilation: ' + errorMsg);
  39058. }
  39059. return shader;
  39060. }
  39061. function createVertexShader(gl, code) {
  39062. return loadShader(gl, code, gl.VERTEX_SHADER);
  39063. }
  39064. function createFragmentShader(gl, code) {
  39065. return loadShader(gl, code, gl.FRAGMENT_SHADER);
  39066. }
  39067. function createProgram(gl, shaders) {
  39068. var program = gl.createProgram();
  39069. for (var i = 0, ii = shaders.length; i < ii; ++i) {
  39070. gl.attachShader(program, shaders[i]);
  39071. }
  39072. gl.linkProgram(program);
  39073. var linked = gl.getProgramParameter(program, gl.LINK_STATUS);
  39074. if (!linked) {
  39075. var errorMsg = gl.getProgramInfoLog(program);
  39076. throw new Error('Error during program linking: ' + errorMsg);
  39077. }
  39078. return program;
  39079. }
  39080. function createTexture(gl, image, textureId) {
  39081. gl.activeTexture(textureId);
  39082. var texture = gl.createTexture();
  39083. gl.bindTexture(gl.TEXTURE_2D, texture);
  39084. gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE);
  39085. gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE);
  39086. gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.NEAREST);
  39087. gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.NEAREST);
  39088. gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, gl.RGBA, gl.UNSIGNED_BYTE, image);
  39089. return texture;
  39090. }
  39091. var currentGL, currentCanvas;
  39092. function generateGL() {
  39093. if (currentGL) {
  39094. return;
  39095. }
  39096. currentCanvas = document.createElement('canvas');
  39097. currentGL = currentCanvas.getContext('webgl', { premultipliedalpha: false });
  39098. }
  39099. var smaskVertexShaderCode = '\
  39100. attribute vec2 a_position; \
  39101. attribute vec2 a_texCoord; \
  39102. \
  39103. uniform vec2 u_resolution; \
  39104. \
  39105. varying vec2 v_texCoord; \
  39106. \
  39107. void main() { \
  39108. vec2 clipSpace = (a_position / u_resolution) * 2.0 - 1.0; \
  39109. gl_Position = vec4(clipSpace * vec2(1, -1), 0, 1); \
  39110. \
  39111. v_texCoord = a_texCoord; \
  39112. } ';
  39113. var smaskFragmentShaderCode = '\
  39114. precision mediump float; \
  39115. \
  39116. uniform vec4 u_backdrop; \
  39117. uniform int u_subtype; \
  39118. uniform sampler2D u_image; \
  39119. uniform sampler2D u_mask; \
  39120. \
  39121. varying vec2 v_texCoord; \
  39122. \
  39123. void main() { \
  39124. vec4 imageColor = texture2D(u_image, v_texCoord); \
  39125. vec4 maskColor = texture2D(u_mask, v_texCoord); \
  39126. if (u_backdrop.a > 0.0) { \
  39127. maskColor.rgb = maskColor.rgb * maskColor.a + \
  39128. u_backdrop.rgb * (1.0 - maskColor.a); \
  39129. } \
  39130. float lum; \
  39131. if (u_subtype == 0) { \
  39132. lum = maskColor.a; \
  39133. } else { \
  39134. lum = maskColor.r * 0.3 + maskColor.g * 0.59 + \
  39135. maskColor.b * 0.11; \
  39136. } \
  39137. imageColor.a *= lum; \
  39138. imageColor.rgb *= imageColor.a; \
  39139. gl_FragColor = imageColor; \
  39140. } ';
  39141. var smaskCache = null;
  39142. function initSmaskGL() {
  39143. var canvas, gl;
  39144. generateGL();
  39145. canvas = currentCanvas;
  39146. currentCanvas = null;
  39147. gl = currentGL;
  39148. currentGL = null;
  39149. var vertexShader = createVertexShader(gl, smaskVertexShaderCode);
  39150. var fragmentShader = createFragmentShader(gl, smaskFragmentShaderCode);
  39151. var program = createProgram(gl, [
  39152. vertexShader,
  39153. fragmentShader
  39154. ]);
  39155. gl.useProgram(program);
  39156. var cache = {};
  39157. cache.gl = gl;
  39158. cache.canvas = canvas;
  39159. cache.resolutionLocation = gl.getUniformLocation(program, 'u_resolution');
  39160. cache.positionLocation = gl.getAttribLocation(program, 'a_position');
  39161. cache.backdropLocation = gl.getUniformLocation(program, 'u_backdrop');
  39162. cache.subtypeLocation = gl.getUniformLocation(program, 'u_subtype');
  39163. var texCoordLocation = gl.getAttribLocation(program, 'a_texCoord');
  39164. var texLayerLocation = gl.getUniformLocation(program, 'u_image');
  39165. var texMaskLocation = gl.getUniformLocation(program, 'u_mask');
  39166. var texCoordBuffer = gl.createBuffer();
  39167. gl.bindBuffer(gl.ARRAY_BUFFER, texCoordBuffer);
  39168. gl.bufferData(gl.ARRAY_BUFFER, new Float32Array([
  39169. 0.0,
  39170. 0.0,
  39171. 1.0,
  39172. 0.0,
  39173. 0.0,
  39174. 1.0,
  39175. 0.0,
  39176. 1.0,
  39177. 1.0,
  39178. 0.0,
  39179. 1.0,
  39180. 1.0
  39181. ]), gl.STATIC_DRAW);
  39182. gl.enableVertexAttribArray(texCoordLocation);
  39183. gl.vertexAttribPointer(texCoordLocation, 2, gl.FLOAT, false, 0, 0);
  39184. gl.uniform1i(texLayerLocation, 0);
  39185. gl.uniform1i(texMaskLocation, 1);
  39186. smaskCache = cache;
  39187. }
  39188. function composeSMask(layer, mask, properties) {
  39189. var width = layer.width, height = layer.height;
  39190. if (!smaskCache) {
  39191. initSmaskGL();
  39192. }
  39193. var cache = smaskCache, canvas = cache.canvas, gl = cache.gl;
  39194. canvas.width = width;
  39195. canvas.height = height;
  39196. gl.viewport(0, 0, gl.drawingBufferWidth, gl.drawingBufferHeight);
  39197. gl.uniform2f(cache.resolutionLocation, width, height);
  39198. if (properties.backdrop) {
  39199. gl.uniform4f(cache.resolutionLocation, properties.backdrop[0], properties.backdrop[1], properties.backdrop[2], 1);
  39200. } else {
  39201. gl.uniform4f(cache.resolutionLocation, 0, 0, 0, 0);
  39202. }
  39203. gl.uniform1i(cache.subtypeLocation, properties.subtype === 'Luminosity' ? 1 : 0);
  39204. var texture = createTexture(gl, layer, gl.TEXTURE0);
  39205. var maskTexture = createTexture(gl, mask, gl.TEXTURE1);
  39206. var buffer = gl.createBuffer();
  39207. gl.bindBuffer(gl.ARRAY_BUFFER, buffer);
  39208. gl.bufferData(gl.ARRAY_BUFFER, new Float32Array([
  39209. 0,
  39210. 0,
  39211. width,
  39212. 0,
  39213. 0,
  39214. height,
  39215. 0,
  39216. height,
  39217. width,
  39218. 0,
  39219. width,
  39220. height
  39221. ]), gl.STATIC_DRAW);
  39222. gl.enableVertexAttribArray(cache.positionLocation);
  39223. gl.vertexAttribPointer(cache.positionLocation, 2, gl.FLOAT, false, 0, 0);
  39224. gl.clearColor(0, 0, 0, 0);
  39225. gl.enable(gl.BLEND);
  39226. gl.blendFunc(gl.ONE, gl.ONE_MINUS_SRC_ALPHA);
  39227. gl.clear(gl.COLOR_BUFFER_BIT);
  39228. gl.drawArrays(gl.TRIANGLES, 0, 6);
  39229. gl.flush();
  39230. gl.deleteTexture(texture);
  39231. gl.deleteTexture(maskTexture);
  39232. gl.deleteBuffer(buffer);
  39233. return canvas;
  39234. }
  39235. var figuresVertexShaderCode = '\
  39236. attribute vec2 a_position; \
  39237. attribute vec3 a_color; \
  39238. \
  39239. uniform vec2 u_resolution; \
  39240. uniform vec2 u_scale; \
  39241. uniform vec2 u_offset; \
  39242. \
  39243. varying vec4 v_color; \
  39244. \
  39245. void main() { \
  39246. vec2 position = (a_position + u_offset) * u_scale; \
  39247. vec2 clipSpace = (position / u_resolution) * 2.0 - 1.0; \
  39248. gl_Position = vec4(clipSpace * vec2(1, -1), 0, 1); \
  39249. \
  39250. v_color = vec4(a_color / 255.0, 1.0); \
  39251. } ';
  39252. var figuresFragmentShaderCode = '\
  39253. precision mediump float; \
  39254. \
  39255. varying vec4 v_color; \
  39256. \
  39257. void main() { \
  39258. gl_FragColor = v_color; \
  39259. } ';
  39260. var figuresCache = null;
  39261. function initFiguresGL() {
  39262. var canvas, gl;
  39263. generateGL();
  39264. canvas = currentCanvas;
  39265. currentCanvas = null;
  39266. gl = currentGL;
  39267. currentGL = null;
  39268. var vertexShader = createVertexShader(gl, figuresVertexShaderCode);
  39269. var fragmentShader = createFragmentShader(gl, figuresFragmentShaderCode);
  39270. var program = createProgram(gl, [
  39271. vertexShader,
  39272. fragmentShader
  39273. ]);
  39274. gl.useProgram(program);
  39275. var cache = {};
  39276. cache.gl = gl;
  39277. cache.canvas = canvas;
  39278. cache.resolutionLocation = gl.getUniformLocation(program, 'u_resolution');
  39279. cache.scaleLocation = gl.getUniformLocation(program, 'u_scale');
  39280. cache.offsetLocation = gl.getUniformLocation(program, 'u_offset');
  39281. cache.positionLocation = gl.getAttribLocation(program, 'a_position');
  39282. cache.colorLocation = gl.getAttribLocation(program, 'a_color');
  39283. figuresCache = cache;
  39284. }
  39285. function drawFigures(width, height, backgroundColor, figures, context) {
  39286. if (!figuresCache) {
  39287. initFiguresGL();
  39288. }
  39289. var cache = figuresCache, canvas = cache.canvas, gl = cache.gl;
  39290. canvas.width = width;
  39291. canvas.height = height;
  39292. gl.viewport(0, 0, gl.drawingBufferWidth, gl.drawingBufferHeight);
  39293. gl.uniform2f(cache.resolutionLocation, width, height);
  39294. var count = 0;
  39295. var i, ii, rows;
  39296. for (i = 0, ii = figures.length; i < ii; i++) {
  39297. switch (figures[i].type) {
  39298. case 'lattice':
  39299. rows = figures[i].coords.length / figures[i].verticesPerRow | 0;
  39300. count += (rows - 1) * (figures[i].verticesPerRow - 1) * 6;
  39301. break;
  39302. case 'triangles':
  39303. count += figures[i].coords.length;
  39304. break;
  39305. }
  39306. }
  39307. var coords = new Float32Array(count * 2);
  39308. var colors = new Uint8Array(count * 3);
  39309. var coordsMap = context.coords, colorsMap = context.colors;
  39310. var pIndex = 0, cIndex = 0;
  39311. for (i = 0, ii = figures.length; i < ii; i++) {
  39312. var figure = figures[i], ps = figure.coords, cs = figure.colors;
  39313. switch (figure.type) {
  39314. case 'lattice':
  39315. var cols = figure.verticesPerRow;
  39316. rows = ps.length / cols | 0;
  39317. for (var row = 1; row < rows; row++) {
  39318. var offset = row * cols + 1;
  39319. for (var col = 1; col < cols; col++, offset++) {
  39320. coords[pIndex] = coordsMap[ps[offset - cols - 1]];
  39321. coords[pIndex + 1] = coordsMap[ps[offset - cols - 1] + 1];
  39322. coords[pIndex + 2] = coordsMap[ps[offset - cols]];
  39323. coords[pIndex + 3] = coordsMap[ps[offset - cols] + 1];
  39324. coords[pIndex + 4] = coordsMap[ps[offset - 1]];
  39325. coords[pIndex + 5] = coordsMap[ps[offset - 1] + 1];
  39326. colors[cIndex] = colorsMap[cs[offset - cols - 1]];
  39327. colors[cIndex + 1] = colorsMap[cs[offset - cols - 1] + 1];
  39328. colors[cIndex + 2] = colorsMap[cs[offset - cols - 1] + 2];
  39329. colors[cIndex + 3] = colorsMap[cs[offset - cols]];
  39330. colors[cIndex + 4] = colorsMap[cs[offset - cols] + 1];
  39331. colors[cIndex + 5] = colorsMap[cs[offset - cols] + 2];
  39332. colors[cIndex + 6] = colorsMap[cs[offset - 1]];
  39333. colors[cIndex + 7] = colorsMap[cs[offset - 1] + 1];
  39334. colors[cIndex + 8] = colorsMap[cs[offset - 1] + 2];
  39335. coords[pIndex + 6] = coords[pIndex + 2];
  39336. coords[pIndex + 7] = coords[pIndex + 3];
  39337. coords[pIndex + 8] = coords[pIndex + 4];
  39338. coords[pIndex + 9] = coords[pIndex + 5];
  39339. coords[pIndex + 10] = coordsMap[ps[offset]];
  39340. coords[pIndex + 11] = coordsMap[ps[offset] + 1];
  39341. colors[cIndex + 9] = colors[cIndex + 3];
  39342. colors[cIndex + 10] = colors[cIndex + 4];
  39343. colors[cIndex + 11] = colors[cIndex + 5];
  39344. colors[cIndex + 12] = colors[cIndex + 6];
  39345. colors[cIndex + 13] = colors[cIndex + 7];
  39346. colors[cIndex + 14] = colors[cIndex + 8];
  39347. colors[cIndex + 15] = colorsMap[cs[offset]];
  39348. colors[cIndex + 16] = colorsMap[cs[offset] + 1];
  39349. colors[cIndex + 17] = colorsMap[cs[offset] + 2];
  39350. pIndex += 12;
  39351. cIndex += 18;
  39352. }
  39353. }
  39354. break;
  39355. case 'triangles':
  39356. for (var j = 0, jj = ps.length; j < jj; j++) {
  39357. coords[pIndex] = coordsMap[ps[j]];
  39358. coords[pIndex + 1] = coordsMap[ps[j] + 1];
  39359. colors[cIndex] = colorsMap[cs[j]];
  39360. colors[cIndex + 1] = colorsMap[cs[j] + 1];
  39361. colors[cIndex + 2] = colorsMap[cs[j] + 2];
  39362. pIndex += 2;
  39363. cIndex += 3;
  39364. }
  39365. break;
  39366. }
  39367. }
  39368. if (backgroundColor) {
  39369. gl.clearColor(backgroundColor[0] / 255, backgroundColor[1] / 255, backgroundColor[2] / 255, 1.0);
  39370. } else {
  39371. gl.clearColor(0, 0, 0, 0);
  39372. }
  39373. gl.clear(gl.COLOR_BUFFER_BIT);
  39374. var coordsBuffer = gl.createBuffer();
  39375. gl.bindBuffer(gl.ARRAY_BUFFER, coordsBuffer);
  39376. gl.bufferData(gl.ARRAY_BUFFER, coords, gl.STATIC_DRAW);
  39377. gl.enableVertexAttribArray(cache.positionLocation);
  39378. gl.vertexAttribPointer(cache.positionLocation, 2, gl.FLOAT, false, 0, 0);
  39379. var colorsBuffer = gl.createBuffer();
  39380. gl.bindBuffer(gl.ARRAY_BUFFER, colorsBuffer);
  39381. gl.bufferData(gl.ARRAY_BUFFER, colors, gl.STATIC_DRAW);
  39382. gl.enableVertexAttribArray(cache.colorLocation);
  39383. gl.vertexAttribPointer(cache.colorLocation, 3, gl.UNSIGNED_BYTE, false, 0, 0);
  39384. gl.uniform2f(cache.scaleLocation, context.scaleX, context.scaleY);
  39385. gl.uniform2f(cache.offsetLocation, context.offsetX, context.offsetY);
  39386. gl.drawArrays(gl.TRIANGLES, 0, count);
  39387. gl.flush();
  39388. gl.deleteBuffer(coordsBuffer);
  39389. gl.deleteBuffer(colorsBuffer);
  39390. return canvas;
  39391. }
  39392. function cleanup() {
  39393. if (smaskCache && smaskCache.canvas) {
  39394. smaskCache.canvas.width = 0;
  39395. smaskCache.canvas.height = 0;
  39396. }
  39397. if (figuresCache && figuresCache.canvas) {
  39398. figuresCache.canvas.width = 0;
  39399. figuresCache.canvas.height = 0;
  39400. }
  39401. smaskCache = null;
  39402. figuresCache = null;
  39403. }
  39404. return {
  39405. get isEnabled() {
  39406. if (getDefaultSetting('disableWebGL')) {
  39407. return false;
  39408. }
  39409. var enabled = false;
  39410. try {
  39411. generateGL();
  39412. enabled = !!currentGL;
  39413. } catch (e) {
  39414. }
  39415. return shadow(this, 'isEnabled', enabled);
  39416. },
  39417. composeSMask: composeSMask,
  39418. drawFigures: drawFigures,
  39419. clear: cleanup
  39420. };
  39421. }();
  39422. exports.WebGLUtils = WebGLUtils;
  39423. /***/ }),
  39424. /* 25 */
  39425. /***/ (function(module, exports, __w_pdfjs_require__) {
  39426. "use strict";
  39427. var sharedUtil = __w_pdfjs_require__(0);
  39428. var displayDOMUtils = __w_pdfjs_require__(3);
  39429. var displayAPI = __w_pdfjs_require__(10);
  39430. var displayAnnotationLayer = __w_pdfjs_require__(9);
  39431. var displayTextLayer = __w_pdfjs_require__(12);
  39432. var displayMetadata = __w_pdfjs_require__(23);
  39433. var displaySVG = __w_pdfjs_require__(11);
  39434. var globalScope = sharedUtil.globalScope;
  39435. var deprecated = sharedUtil.deprecated;
  39436. var warn = sharedUtil.warn;
  39437. var LinkTarget = displayDOMUtils.LinkTarget;
  39438. var DEFAULT_LINK_REL = displayDOMUtils.DEFAULT_LINK_REL;
  39439. var isWorker = typeof window === 'undefined';
  39440. if (!globalScope.PDFJS) {
  39441. globalScope.PDFJS = {};
  39442. }
  39443. var PDFJS = globalScope.PDFJS;
  39444. PDFJS.version = '1.7.297';
  39445. PDFJS.build = '425ad309';
  39446. PDFJS.pdfBug = false;
  39447. if (PDFJS.verbosity !== undefined) {
  39448. sharedUtil.setVerbosityLevel(PDFJS.verbosity);
  39449. }
  39450. delete PDFJS.verbosity;
  39451. Object.defineProperty(PDFJS, 'verbosity', {
  39452. get: function () {
  39453. return sharedUtil.getVerbosityLevel();
  39454. },
  39455. set: function (level) {
  39456. sharedUtil.setVerbosityLevel(level);
  39457. },
  39458. enumerable: true,
  39459. configurable: true
  39460. });
  39461. PDFJS.VERBOSITY_LEVELS = sharedUtil.VERBOSITY_LEVELS;
  39462. PDFJS.OPS = sharedUtil.OPS;
  39463. PDFJS.UNSUPPORTED_FEATURES = sharedUtil.UNSUPPORTED_FEATURES;
  39464. PDFJS.isValidUrl = displayDOMUtils.isValidUrl;
  39465. PDFJS.shadow = sharedUtil.shadow;
  39466. PDFJS.createBlob = sharedUtil.createBlob;
  39467. PDFJS.createObjectURL = function PDFJS_createObjectURL(data, contentType) {
  39468. return sharedUtil.createObjectURL(data, contentType, PDFJS.disableCreateObjectURL);
  39469. };
  39470. Object.defineProperty(PDFJS, 'isLittleEndian', {
  39471. configurable: true,
  39472. get: function PDFJS_isLittleEndian() {
  39473. var value = sharedUtil.isLittleEndian();
  39474. return sharedUtil.shadow(PDFJS, 'isLittleEndian', value);
  39475. }
  39476. });
  39477. PDFJS.removeNullCharacters = sharedUtil.removeNullCharacters;
  39478. PDFJS.PasswordResponses = sharedUtil.PasswordResponses;
  39479. PDFJS.PasswordException = sharedUtil.PasswordException;
  39480. PDFJS.UnknownErrorException = sharedUtil.UnknownErrorException;
  39481. PDFJS.InvalidPDFException = sharedUtil.InvalidPDFException;
  39482. PDFJS.MissingPDFException = sharedUtil.MissingPDFException;
  39483. PDFJS.UnexpectedResponseException = sharedUtil.UnexpectedResponseException;
  39484. PDFJS.Util = sharedUtil.Util;
  39485. PDFJS.PageViewport = sharedUtil.PageViewport;
  39486. PDFJS.createPromiseCapability = sharedUtil.createPromiseCapability;
  39487. PDFJS.maxImageSize = PDFJS.maxImageSize === undefined ? -1 : PDFJS.maxImageSize;
  39488. PDFJS.cMapUrl = PDFJS.cMapUrl === undefined ? null : PDFJS.cMapUrl;
  39489. PDFJS.cMapPacked = PDFJS.cMapPacked === undefined ? false : PDFJS.cMapPacked;
  39490. PDFJS.disableFontFace = PDFJS.disableFontFace === undefined ? false : PDFJS.disableFontFace;
  39491. PDFJS.imageResourcesPath = PDFJS.imageResourcesPath === undefined ? '' : PDFJS.imageResourcesPath;
  39492. PDFJS.disableWorker = PDFJS.disableWorker === undefined ? false : PDFJS.disableWorker;
  39493. PDFJS.workerSrc = PDFJS.workerSrc === undefined ? null : PDFJS.workerSrc;
  39494. PDFJS.disableRange = PDFJS.disableRange === undefined ? false : PDFJS.disableRange;
  39495. PDFJS.disableStream = PDFJS.disableStream === undefined ? false : PDFJS.disableStream;
  39496. PDFJS.disableAutoFetch = PDFJS.disableAutoFetch === undefined ? false : PDFJS.disableAutoFetch;
  39497. PDFJS.pdfBug = PDFJS.pdfBug === undefined ? false : PDFJS.pdfBug;
  39498. PDFJS.postMessageTransfers = PDFJS.postMessageTransfers === undefined ? true : PDFJS.postMessageTransfers;
  39499. PDFJS.disableCreateObjectURL = PDFJS.disableCreateObjectURL === undefined ? false : PDFJS.disableCreateObjectURL;
  39500. PDFJS.disableWebGL = PDFJS.disableWebGL === undefined ? true : PDFJS.disableWebGL;
  39501. PDFJS.externalLinkTarget = PDFJS.externalLinkTarget === undefined ? LinkTarget.NONE : PDFJS.externalLinkTarget;
  39502. PDFJS.externalLinkRel = PDFJS.externalLinkRel === undefined ? DEFAULT_LINK_REL : PDFJS.externalLinkRel;
  39503. PDFJS.isEvalSupported = PDFJS.isEvalSupported === undefined ? true : PDFJS.isEvalSupported;
  39504. var savedOpenExternalLinksInNewWindow = PDFJS.openExternalLinksInNewWindow;
  39505. delete PDFJS.openExternalLinksInNewWindow;
  39506. Object.defineProperty(PDFJS, 'openExternalLinksInNewWindow', {
  39507. get: function () {
  39508. return PDFJS.externalLinkTarget === LinkTarget.BLANK;
  39509. },
  39510. set: function (value) {
  39511. if (value) {
  39512. deprecated('PDFJS.openExternalLinksInNewWindow, please use ' + '"PDFJS.externalLinkTarget = PDFJS.LinkTarget.BLANK" instead.');
  39513. }
  39514. if (PDFJS.externalLinkTarget !== LinkTarget.NONE) {
  39515. warn('PDFJS.externalLinkTarget is already initialized');
  39516. return;
  39517. }
  39518. PDFJS.externalLinkTarget = value ? LinkTarget.BLANK : LinkTarget.NONE;
  39519. },
  39520. enumerable: true,
  39521. configurable: true
  39522. });
  39523. if (savedOpenExternalLinksInNewWindow) {
  39524. PDFJS.openExternalLinksInNewWindow = savedOpenExternalLinksInNewWindow;
  39525. }
  39526. PDFJS.getDocument = displayAPI.getDocument;
  39527. PDFJS.PDFDataRangeTransport = displayAPI.PDFDataRangeTransport;
  39528. PDFJS.PDFWorker = displayAPI.PDFWorker;
  39529. Object.defineProperty(PDFJS, 'hasCanvasTypedArrays', {
  39530. configurable: true,
  39531. get: function PDFJS_hasCanvasTypedArrays() {
  39532. var value = displayDOMUtils.hasCanvasTypedArrays();
  39533. return sharedUtil.shadow(PDFJS, 'hasCanvasTypedArrays', value);
  39534. }
  39535. });
  39536. PDFJS.CustomStyle = displayDOMUtils.CustomStyle;
  39537. PDFJS.LinkTarget = LinkTarget;
  39538. PDFJS.addLinkAttributes = displayDOMUtils.addLinkAttributes;
  39539. PDFJS.getFilenameFromUrl = displayDOMUtils.getFilenameFromUrl;
  39540. PDFJS.isExternalLinkTargetSet = displayDOMUtils.isExternalLinkTargetSet;
  39541. PDFJS.AnnotationLayer = displayAnnotationLayer.AnnotationLayer;
  39542. PDFJS.renderTextLayer = displayTextLayer.renderTextLayer;
  39543. PDFJS.Metadata = displayMetadata.Metadata;
  39544. PDFJS.SVGGraphics = displaySVG.SVGGraphics;
  39545. PDFJS.UnsupportedManager = displayAPI._UnsupportedManager;
  39546. exports.globalScope = globalScope;
  39547. exports.isWorker = isWorker;
  39548. exports.PDFJS = globalScope.PDFJS;
  39549. /***/ }),
  39550. /* 26 */
  39551. /***/ (function(module, exports) {
  39552. var g;
  39553. g = function () {
  39554. return this;
  39555. }();
  39556. try {
  39557. g = g || Function("return this")() || (1, eval)("this");
  39558. } catch (e) {
  39559. if (typeof window === "object")
  39560. g = window;
  39561. }
  39562. module.exports = g;
  39563. /***/ }),
  39564. /* 27 */
  39565. /***/ (function(module, exports, __w_pdfjs_require__) {
  39566. "use strict";
  39567. var sharedUtil = __w_pdfjs_require__(0);
  39568. var corePrimitives = __w_pdfjs_require__(1);
  39569. var coreStream = __w_pdfjs_require__(2);
  39570. var coreColorSpace = __w_pdfjs_require__(4);
  39571. var coreObj = __w_pdfjs_require__(19);
  39572. var coreEvaluator = __w_pdfjs_require__(17);
  39573. var AnnotationBorderStyleType = sharedUtil.AnnotationBorderStyleType;
  39574. var AnnotationFieldFlag = sharedUtil.AnnotationFieldFlag;
  39575. var AnnotationFlag = sharedUtil.AnnotationFlag;
  39576. var AnnotationType = sharedUtil.AnnotationType;
  39577. var OPS = sharedUtil.OPS;
  39578. var Util = sharedUtil.Util;
  39579. var isArray = sharedUtil.isArray;
  39580. var isInt = sharedUtil.isInt;
  39581. var stringToBytes = sharedUtil.stringToBytes;
  39582. var stringToPDFString = sharedUtil.stringToPDFString;
  39583. var warn = sharedUtil.warn;
  39584. var Dict = corePrimitives.Dict;
  39585. var isDict = corePrimitives.isDict;
  39586. var isName = corePrimitives.isName;
  39587. var isRef = corePrimitives.isRef;
  39588. var isStream = corePrimitives.isStream;
  39589. var Stream = coreStream.Stream;
  39590. var ColorSpace = coreColorSpace.ColorSpace;
  39591. var Catalog = coreObj.Catalog;
  39592. var ObjectLoader = coreObj.ObjectLoader;
  39593. var FileSpec = coreObj.FileSpec;
  39594. var OperatorList = coreEvaluator.OperatorList;
  39595. function AnnotationFactory() {
  39596. }
  39597. AnnotationFactory.prototype = {
  39598. create: function AnnotationFactory_create(xref, ref, pdfManager, idFactory) {
  39599. var dict = xref.fetchIfRef(ref);
  39600. if (!isDict(dict)) {
  39601. return;
  39602. }
  39603. var id = isRef(ref) ? ref.toString() : 'annot_' + idFactory.createObjId();
  39604. var subtype = dict.get('Subtype');
  39605. subtype = isName(subtype) ? subtype.name : null;
  39606. var parameters = {
  39607. xref: xref,
  39608. dict: dict,
  39609. ref: isRef(ref) ? ref : null,
  39610. subtype: subtype,
  39611. id: id,
  39612. pdfManager: pdfManager
  39613. };
  39614. switch (subtype) {
  39615. case 'Link':
  39616. return new LinkAnnotation(parameters);
  39617. case 'Text':
  39618. return new TextAnnotation(parameters);
  39619. case 'Widget':
  39620. var fieldType = Util.getInheritableProperty(dict, 'FT');
  39621. fieldType = isName(fieldType) ? fieldType.name : null;
  39622. switch (fieldType) {
  39623. case 'Tx':
  39624. return new TextWidgetAnnotation(parameters);
  39625. case 'Btn':
  39626. return new ButtonWidgetAnnotation(parameters);
  39627. case 'Ch':
  39628. return new ChoiceWidgetAnnotation(parameters);
  39629. }
  39630. warn('Unimplemented widget field type "' + fieldType + '", ' + 'falling back to base field type.');
  39631. return new WidgetAnnotation(parameters);
  39632. case 'Popup':
  39633. return new PopupAnnotation(parameters);
  39634. case 'Highlight':
  39635. return new HighlightAnnotation(parameters);
  39636. case 'Underline':
  39637. return new UnderlineAnnotation(parameters);
  39638. case 'Squiggly':
  39639. return new SquigglyAnnotation(parameters);
  39640. case 'StrikeOut':
  39641. return new StrikeOutAnnotation(parameters);
  39642. case 'FileAttachment':
  39643. return new FileAttachmentAnnotation(parameters);
  39644. default:
  39645. if (!subtype) {
  39646. warn('Annotation is missing the required /Subtype.');
  39647. } else {
  39648. warn('Unimplemented annotation type "' + subtype + '", ' + 'falling back to base annotation.');
  39649. }
  39650. return new Annotation(parameters);
  39651. }
  39652. }
  39653. };
  39654. var Annotation = function AnnotationClosure() {
  39655. function getTransformMatrix(rect, bbox, matrix) {
  39656. var bounds = Util.getAxialAlignedBoundingBox(bbox, matrix);
  39657. var minX = bounds[0];
  39658. var minY = bounds[1];
  39659. var maxX = bounds[2];
  39660. var maxY = bounds[3];
  39661. if (minX === maxX || minY === maxY) {
  39662. return [
  39663. 1,
  39664. 0,
  39665. 0,
  39666. 1,
  39667. rect[0],
  39668. rect[1]
  39669. ];
  39670. }
  39671. var xRatio = (rect[2] - rect[0]) / (maxX - minX);
  39672. var yRatio = (rect[3] - rect[1]) / (maxY - minY);
  39673. return [
  39674. xRatio,
  39675. 0,
  39676. 0,
  39677. yRatio,
  39678. rect[0] - minX * xRatio,
  39679. rect[1] - minY * yRatio
  39680. ];
  39681. }
  39682. function Annotation(params) {
  39683. var dict = params.dict;
  39684. this.setFlags(dict.get('F'));
  39685. this.setRectangle(dict.getArray('Rect'));
  39686. this.setColor(dict.getArray('C'));
  39687. this.setBorderStyle(dict);
  39688. this.setAppearance(dict);
  39689. this.data = {};
  39690. this.data.id = params.id;
  39691. this.data.subtype = params.subtype;
  39692. this.data.annotationFlags = this.flags;
  39693. this.data.rect = this.rectangle;
  39694. this.data.color = this.color;
  39695. this.data.borderStyle = this.borderStyle;
  39696. this.data.hasAppearance = !!this.appearance;
  39697. }
  39698. Annotation.prototype = {
  39699. _hasFlag: function Annotation_hasFlag(flags, flag) {
  39700. return !!(flags & flag);
  39701. },
  39702. _isViewable: function Annotation_isViewable(flags) {
  39703. return !this._hasFlag(flags, AnnotationFlag.INVISIBLE) && !this._hasFlag(flags, AnnotationFlag.HIDDEN) && !this._hasFlag(flags, AnnotationFlag.NOVIEW);
  39704. },
  39705. _isPrintable: function AnnotationFlag_isPrintable(flags) {
  39706. return this._hasFlag(flags, AnnotationFlag.PRINT) && !this._hasFlag(flags, AnnotationFlag.INVISIBLE) && !this._hasFlag(flags, AnnotationFlag.HIDDEN);
  39707. },
  39708. get viewable() {
  39709. if (this.flags === 0) {
  39710. return true;
  39711. }
  39712. return this._isViewable(this.flags);
  39713. },
  39714. get printable() {
  39715. if (this.flags === 0) {
  39716. return false;
  39717. }
  39718. return this._isPrintable(this.flags);
  39719. },
  39720. setFlags: function Annotation_setFlags(flags) {
  39721. this.flags = isInt(flags) && flags > 0 ? flags : 0;
  39722. },
  39723. hasFlag: function Annotation_hasFlag(flag) {
  39724. return this._hasFlag(this.flags, flag);
  39725. },
  39726. setRectangle: function Annotation_setRectangle(rectangle) {
  39727. if (isArray(rectangle) && rectangle.length === 4) {
  39728. this.rectangle = Util.normalizeRect(rectangle);
  39729. } else {
  39730. this.rectangle = [
  39731. 0,
  39732. 0,
  39733. 0,
  39734. 0
  39735. ];
  39736. }
  39737. },
  39738. setColor: function Annotation_setColor(color) {
  39739. var rgbColor = new Uint8Array(3);
  39740. if (!isArray(color)) {
  39741. this.color = rgbColor;
  39742. return;
  39743. }
  39744. switch (color.length) {
  39745. case 0:
  39746. this.color = null;
  39747. break;
  39748. case 1:
  39749. ColorSpace.singletons.gray.getRgbItem(color, 0, rgbColor, 0);
  39750. this.color = rgbColor;
  39751. break;
  39752. case 3:
  39753. ColorSpace.singletons.rgb.getRgbItem(color, 0, rgbColor, 0);
  39754. this.color = rgbColor;
  39755. break;
  39756. case 4:
  39757. ColorSpace.singletons.cmyk.getRgbItem(color, 0, rgbColor, 0);
  39758. this.color = rgbColor;
  39759. break;
  39760. default:
  39761. this.color = rgbColor;
  39762. break;
  39763. }
  39764. },
  39765. setBorderStyle: function Annotation_setBorderStyle(borderStyle) {
  39766. this.borderStyle = new AnnotationBorderStyle();
  39767. if (!isDict(borderStyle)) {
  39768. return;
  39769. }
  39770. if (borderStyle.has('BS')) {
  39771. var dict = borderStyle.get('BS');
  39772. var dictType = dict.get('Type');
  39773. if (!dictType || isName(dictType, 'Border')) {
  39774. this.borderStyle.setWidth(dict.get('W'));
  39775. this.borderStyle.setStyle(dict.get('S'));
  39776. this.borderStyle.setDashArray(dict.getArray('D'));
  39777. }
  39778. } else if (borderStyle.has('Border')) {
  39779. var array = borderStyle.getArray('Border');
  39780. if (isArray(array) && array.length >= 3) {
  39781. this.borderStyle.setHorizontalCornerRadius(array[0]);
  39782. this.borderStyle.setVerticalCornerRadius(array[1]);
  39783. this.borderStyle.setWidth(array[2]);
  39784. if (array.length === 4) {
  39785. this.borderStyle.setDashArray(array[3]);
  39786. }
  39787. }
  39788. } else {
  39789. this.borderStyle.setWidth(0);
  39790. }
  39791. },
  39792. setAppearance: function Annotation_setAppearance(dict) {
  39793. this.appearance = null;
  39794. var appearanceStates = dict.get('AP');
  39795. if (!isDict(appearanceStates)) {
  39796. return;
  39797. }
  39798. var normalAppearanceState = appearanceStates.get('N');
  39799. if (isStream(normalAppearanceState)) {
  39800. this.appearance = normalAppearanceState;
  39801. return;
  39802. }
  39803. if (!isDict(normalAppearanceState)) {
  39804. return;
  39805. }
  39806. var as = dict.get('AS');
  39807. if (!isName(as) || !normalAppearanceState.has(as.name)) {
  39808. return;
  39809. }
  39810. this.appearance = normalAppearanceState.get(as.name);
  39811. },
  39812. _preparePopup: function Annotation_preparePopup(dict) {
  39813. if (!dict.has('C')) {
  39814. this.data.color = null;
  39815. }
  39816. this.data.hasPopup = dict.has('Popup');
  39817. this.data.title = stringToPDFString(dict.get('T') || '');
  39818. this.data.contents = stringToPDFString(dict.get('Contents') || '');
  39819. },
  39820. loadResources: function Annotation_loadResources(keys) {
  39821. return new Promise(function (resolve, reject) {
  39822. this.appearance.dict.getAsync('Resources').then(function (resources) {
  39823. if (!resources) {
  39824. resolve();
  39825. return;
  39826. }
  39827. var objectLoader = new ObjectLoader(resources.map, keys, resources.xref);
  39828. objectLoader.load().then(function () {
  39829. resolve(resources);
  39830. }, reject);
  39831. }, reject);
  39832. }.bind(this));
  39833. },
  39834. getOperatorList: function Annotation_getOperatorList(evaluator, task, renderForms) {
  39835. if (!this.appearance) {
  39836. return Promise.resolve(new OperatorList());
  39837. }
  39838. var data = this.data;
  39839. var appearanceDict = this.appearance.dict;
  39840. var resourcesPromise = this.loadResources([
  39841. 'ExtGState',
  39842. 'ColorSpace',
  39843. 'Pattern',
  39844. 'Shading',
  39845. 'XObject',
  39846. 'Font'
  39847. ]);
  39848. var bbox = appearanceDict.getArray('BBox') || [
  39849. 0,
  39850. 0,
  39851. 1,
  39852. 1
  39853. ];
  39854. var matrix = appearanceDict.getArray('Matrix') || [
  39855. 1,
  39856. 0,
  39857. 0,
  39858. 1,
  39859. 0,
  39860. 0
  39861. ];
  39862. var transform = getTransformMatrix(data.rect, bbox, matrix);
  39863. var self = this;
  39864. return resourcesPromise.then(function (resources) {
  39865. var opList = new OperatorList();
  39866. opList.addOp(OPS.beginAnnotation, [
  39867. data.rect,
  39868. transform,
  39869. matrix
  39870. ]);
  39871. return evaluator.getOperatorList(self.appearance, task, resources, opList).then(function () {
  39872. opList.addOp(OPS.endAnnotation, []);
  39873. self.appearance.reset();
  39874. return opList;
  39875. });
  39876. });
  39877. }
  39878. };
  39879. Annotation.appendToOperatorList = function Annotation_appendToOperatorList(annotations, opList, partialEvaluator, task, intent, renderForms) {
  39880. var annotationPromises = [];
  39881. for (var i = 0, n = annotations.length; i < n; ++i) {
  39882. if (intent === 'display' && annotations[i].viewable || intent === 'print' && annotations[i].printable) {
  39883. annotationPromises.push(annotations[i].getOperatorList(partialEvaluator, task, renderForms));
  39884. }
  39885. }
  39886. return Promise.all(annotationPromises).then(function (operatorLists) {
  39887. opList.addOp(OPS.beginAnnotations, []);
  39888. for (var i = 0, n = operatorLists.length; i < n; ++i) {
  39889. opList.addOpList(operatorLists[i]);
  39890. }
  39891. opList.addOp(OPS.endAnnotations, []);
  39892. });
  39893. };
  39894. return Annotation;
  39895. }();
  39896. var AnnotationBorderStyle = function AnnotationBorderStyleClosure() {
  39897. function AnnotationBorderStyle() {
  39898. this.width = 1;
  39899. this.style = AnnotationBorderStyleType.SOLID;
  39900. this.dashArray = [3];
  39901. this.horizontalCornerRadius = 0;
  39902. this.verticalCornerRadius = 0;
  39903. }
  39904. AnnotationBorderStyle.prototype = {
  39905. setWidth: function AnnotationBorderStyle_setWidth(width) {
  39906. if (width === (width | 0)) {
  39907. this.width = width;
  39908. }
  39909. },
  39910. setStyle: function AnnotationBorderStyle_setStyle(style) {
  39911. if (!style) {
  39912. return;
  39913. }
  39914. switch (style.name) {
  39915. case 'S':
  39916. this.style = AnnotationBorderStyleType.SOLID;
  39917. break;
  39918. case 'D':
  39919. this.style = AnnotationBorderStyleType.DASHED;
  39920. break;
  39921. case 'B':
  39922. this.style = AnnotationBorderStyleType.BEVELED;
  39923. break;
  39924. case 'I':
  39925. this.style = AnnotationBorderStyleType.INSET;
  39926. break;
  39927. case 'U':
  39928. this.style = AnnotationBorderStyleType.UNDERLINE;
  39929. break;
  39930. default:
  39931. break;
  39932. }
  39933. },
  39934. setDashArray: function AnnotationBorderStyle_setDashArray(dashArray) {
  39935. if (isArray(dashArray) && dashArray.length > 0) {
  39936. var isValid = true;
  39937. var allZeros = true;
  39938. for (var i = 0, len = dashArray.length; i < len; i++) {
  39939. var element = dashArray[i];
  39940. var validNumber = +element >= 0;
  39941. if (!validNumber) {
  39942. isValid = false;
  39943. break;
  39944. } else if (element > 0) {
  39945. allZeros = false;
  39946. }
  39947. }
  39948. if (isValid && !allZeros) {
  39949. this.dashArray = dashArray;
  39950. } else {
  39951. this.width = 0;
  39952. }
  39953. } else if (dashArray) {
  39954. this.width = 0;
  39955. }
  39956. },
  39957. setHorizontalCornerRadius: function AnnotationBorderStyle_setHorizontalCornerRadius(radius) {
  39958. if (radius === (radius | 0)) {
  39959. this.horizontalCornerRadius = radius;
  39960. }
  39961. },
  39962. setVerticalCornerRadius: function AnnotationBorderStyle_setVerticalCornerRadius(radius) {
  39963. if (radius === (radius | 0)) {
  39964. this.verticalCornerRadius = radius;
  39965. }
  39966. }
  39967. };
  39968. return AnnotationBorderStyle;
  39969. }();
  39970. var WidgetAnnotation = function WidgetAnnotationClosure() {
  39971. function WidgetAnnotation(params) {
  39972. Annotation.call(this, params);
  39973. var dict = params.dict;
  39974. var data = this.data;
  39975. data.annotationType = AnnotationType.WIDGET;
  39976. data.fieldName = this._constructFieldName(dict);
  39977. data.fieldValue = Util.getInheritableProperty(dict, 'V', true);
  39978. data.alternativeText = stringToPDFString(dict.get('TU') || '');
  39979. data.defaultAppearance = Util.getInheritableProperty(dict, 'DA') || '';
  39980. var fieldType = Util.getInheritableProperty(dict, 'FT');
  39981. data.fieldType = isName(fieldType) ? fieldType.name : null;
  39982. this.fieldResources = Util.getInheritableProperty(dict, 'DR') || Dict.empty;
  39983. data.fieldFlags = Util.getInheritableProperty(dict, 'Ff');
  39984. if (!isInt(data.fieldFlags) || data.fieldFlags < 0) {
  39985. data.fieldFlags = 0;
  39986. }
  39987. data.readOnly = this.hasFieldFlag(AnnotationFieldFlag.READONLY);
  39988. if (data.fieldType === 'Sig') {
  39989. this.setFlags(AnnotationFlag.HIDDEN);
  39990. }
  39991. }
  39992. Util.inherit(WidgetAnnotation, Annotation, {
  39993. _constructFieldName: function WidgetAnnotation_constructFieldName(dict) {
  39994. if (!dict.has('T') && !dict.has('Parent')) {
  39995. warn('Unknown field name, falling back to empty field name.');
  39996. return '';
  39997. }
  39998. if (!dict.has('Parent')) {
  39999. return stringToPDFString(dict.get('T'));
  40000. }
  40001. var fieldName = [];
  40002. if (dict.has('T')) {
  40003. fieldName.unshift(stringToPDFString(dict.get('T')));
  40004. }
  40005. var loopDict = dict;
  40006. while (loopDict.has('Parent')) {
  40007. loopDict = loopDict.get('Parent');
  40008. if (loopDict.has('T')) {
  40009. fieldName.unshift(stringToPDFString(loopDict.get('T')));
  40010. }
  40011. }
  40012. return fieldName.join('.');
  40013. },
  40014. hasFieldFlag: function WidgetAnnotation_hasFieldFlag(flag) {
  40015. return !!(this.data.fieldFlags & flag);
  40016. }
  40017. });
  40018. return WidgetAnnotation;
  40019. }();
  40020. var TextWidgetAnnotation = function TextWidgetAnnotationClosure() {
  40021. function TextWidgetAnnotation(params) {
  40022. WidgetAnnotation.call(this, params);
  40023. this.data.fieldValue = stringToPDFString(this.data.fieldValue || '');
  40024. var alignment = Util.getInheritableProperty(params.dict, 'Q');
  40025. if (!isInt(alignment) || alignment < 0 || alignment > 2) {
  40026. alignment = null;
  40027. }
  40028. this.data.textAlignment = alignment;
  40029. var maximumLength = Util.getInheritableProperty(params.dict, 'MaxLen');
  40030. if (!isInt(maximumLength) || maximumLength < 0) {
  40031. maximumLength = null;
  40032. }
  40033. this.data.maxLen = maximumLength;
  40034. this.data.multiLine = this.hasFieldFlag(AnnotationFieldFlag.MULTILINE);
  40035. this.data.comb = this.hasFieldFlag(AnnotationFieldFlag.COMB) && !this.hasFieldFlag(AnnotationFieldFlag.MULTILINE) && !this.hasFieldFlag(AnnotationFieldFlag.PASSWORD) && !this.hasFieldFlag(AnnotationFieldFlag.FILESELECT) && this.data.maxLen !== null;
  40036. }
  40037. Util.inherit(TextWidgetAnnotation, WidgetAnnotation, {
  40038. getOperatorList: function TextWidgetAnnotation_getOperatorList(evaluator, task, renderForms) {
  40039. var operatorList = new OperatorList();
  40040. if (renderForms) {
  40041. return Promise.resolve(operatorList);
  40042. }
  40043. if (this.appearance) {
  40044. return Annotation.prototype.getOperatorList.call(this, evaluator, task, renderForms);
  40045. }
  40046. if (!this.data.defaultAppearance) {
  40047. return Promise.resolve(operatorList);
  40048. }
  40049. var stream = new Stream(stringToBytes(this.data.defaultAppearance));
  40050. return evaluator.getOperatorList(stream, task, this.fieldResources, operatorList).then(function () {
  40051. return operatorList;
  40052. });
  40053. }
  40054. });
  40055. return TextWidgetAnnotation;
  40056. }();
  40057. var ButtonWidgetAnnotation = function ButtonWidgetAnnotationClosure() {
  40058. function ButtonWidgetAnnotation(params) {
  40059. WidgetAnnotation.call(this, params);
  40060. this.data.checkBox = !this.hasFieldFlag(AnnotationFieldFlag.RADIO) && !this.hasFieldFlag(AnnotationFieldFlag.PUSHBUTTON);
  40061. if (this.data.checkBox) {
  40062. if (!isName(this.data.fieldValue)) {
  40063. return;
  40064. }
  40065. this.data.fieldValue = this.data.fieldValue.name;
  40066. }
  40067. this.data.radioButton = this.hasFieldFlag(AnnotationFieldFlag.RADIO) && !this.hasFieldFlag(AnnotationFieldFlag.PUSHBUTTON);
  40068. if (this.data.radioButton) {
  40069. this.data.fieldValue = this.data.buttonValue = null;
  40070. var fieldParent = params.dict.get('Parent');
  40071. if (isDict(fieldParent) && fieldParent.has('V')) {
  40072. var fieldParentValue = fieldParent.get('V');
  40073. if (isName(fieldParentValue)) {
  40074. this.data.fieldValue = fieldParentValue.name;
  40075. }
  40076. }
  40077. var appearanceStates = params.dict.get('AP');
  40078. if (!isDict(appearanceStates)) {
  40079. return;
  40080. }
  40081. var normalAppearanceState = appearanceStates.get('N');
  40082. if (!isDict(normalAppearanceState)) {
  40083. return;
  40084. }
  40085. var keys = normalAppearanceState.getKeys();
  40086. for (var i = 0, ii = keys.length; i < ii; i++) {
  40087. if (keys[i] !== 'Off') {
  40088. this.data.buttonValue = keys[i];
  40089. break;
  40090. }
  40091. }
  40092. }
  40093. }
  40094. Util.inherit(ButtonWidgetAnnotation, WidgetAnnotation, {
  40095. getOperatorList: function ButtonWidgetAnnotation_getOperatorList(evaluator, task, renderForms) {
  40096. var operatorList = new OperatorList();
  40097. if (renderForms) {
  40098. return Promise.resolve(operatorList);
  40099. }
  40100. if (this.appearance) {
  40101. return Annotation.prototype.getOperatorList.call(this, evaluator, task, renderForms);
  40102. }
  40103. return Promise.resolve(operatorList);
  40104. }
  40105. });
  40106. return ButtonWidgetAnnotation;
  40107. }();
  40108. var ChoiceWidgetAnnotation = function ChoiceWidgetAnnotationClosure() {
  40109. function ChoiceWidgetAnnotation(params) {
  40110. WidgetAnnotation.call(this, params);
  40111. this.data.options = [];
  40112. var options = params.dict.get('Opt');
  40113. if (isArray(options)) {
  40114. var xref = params.xref;
  40115. for (var i = 0, ii = options.length; i < ii; i++) {
  40116. var option = xref.fetchIfRef(options[i]);
  40117. var isOptionArray = isArray(option);
  40118. this.data.options[i] = {
  40119. exportValue: isOptionArray ? xref.fetchIfRef(option[0]) : option,
  40120. displayValue: isOptionArray ? xref.fetchIfRef(option[1]) : option
  40121. };
  40122. }
  40123. }
  40124. if (!isArray(this.data.fieldValue)) {
  40125. this.data.fieldValue = [this.data.fieldValue];
  40126. }
  40127. this.data.combo = this.hasFieldFlag(AnnotationFieldFlag.COMBO);
  40128. this.data.multiSelect = this.hasFieldFlag(AnnotationFieldFlag.MULTISELECT);
  40129. }
  40130. Util.inherit(ChoiceWidgetAnnotation, WidgetAnnotation, {
  40131. getOperatorList: function ChoiceWidgetAnnotation_getOperatorList(evaluator, task, renderForms) {
  40132. var operatorList = new OperatorList();
  40133. if (renderForms) {
  40134. return Promise.resolve(operatorList);
  40135. }
  40136. return Annotation.prototype.getOperatorList.call(this, evaluator, task, renderForms);
  40137. }
  40138. });
  40139. return ChoiceWidgetAnnotation;
  40140. }();
  40141. var TextAnnotation = function TextAnnotationClosure() {
  40142. var DEFAULT_ICON_SIZE = 22;
  40143. function TextAnnotation(parameters) {
  40144. Annotation.call(this, parameters);
  40145. this.data.annotationType = AnnotationType.TEXT;
  40146. if (this.data.hasAppearance) {
  40147. this.data.name = 'NoIcon';
  40148. } else {
  40149. this.data.rect[1] = this.data.rect[3] - DEFAULT_ICON_SIZE;
  40150. this.data.rect[2] = this.data.rect[0] + DEFAULT_ICON_SIZE;
  40151. this.data.name = parameters.dict.has('Name') ? parameters.dict.get('Name').name : 'Note';
  40152. }
  40153. this._preparePopup(parameters.dict);
  40154. }
  40155. Util.inherit(TextAnnotation, Annotation, {});
  40156. return TextAnnotation;
  40157. }();
  40158. var LinkAnnotation = function LinkAnnotationClosure() {
  40159. function LinkAnnotation(params) {
  40160. Annotation.call(this, params);
  40161. var data = this.data;
  40162. data.annotationType = AnnotationType.LINK;
  40163. Catalog.parseDestDictionary({
  40164. destDict: params.dict,
  40165. resultObj: data,
  40166. docBaseUrl: params.pdfManager.docBaseUrl
  40167. });
  40168. }
  40169. Util.inherit(LinkAnnotation, Annotation, {});
  40170. return LinkAnnotation;
  40171. }();
  40172. var PopupAnnotation = function PopupAnnotationClosure() {
  40173. function PopupAnnotation(parameters) {
  40174. Annotation.call(this, parameters);
  40175. this.data.annotationType = AnnotationType.POPUP;
  40176. var dict = parameters.dict;
  40177. var parentItem = dict.get('Parent');
  40178. if (!parentItem) {
  40179. warn('Popup annotation has a missing or invalid parent annotation.');
  40180. return;
  40181. }
  40182. this.data.parentId = dict.getRaw('Parent').toString();
  40183. this.data.title = stringToPDFString(parentItem.get('T') || '');
  40184. this.data.contents = stringToPDFString(parentItem.get('Contents') || '');
  40185. if (!parentItem.has('C')) {
  40186. this.data.color = null;
  40187. } else {
  40188. this.setColor(parentItem.getArray('C'));
  40189. this.data.color = this.color;
  40190. }
  40191. if (!this.viewable) {
  40192. var parentFlags = parentItem.get('F');
  40193. if (this._isViewable(parentFlags)) {
  40194. this.setFlags(parentFlags);
  40195. }
  40196. }
  40197. }
  40198. Util.inherit(PopupAnnotation, Annotation, {});
  40199. return PopupAnnotation;
  40200. }();
  40201. var HighlightAnnotation = function HighlightAnnotationClosure() {
  40202. function HighlightAnnotation(parameters) {
  40203. Annotation.call(this, parameters);
  40204. this.data.annotationType = AnnotationType.HIGHLIGHT;
  40205. this._preparePopup(parameters.dict);
  40206. this.data.borderStyle.setWidth(0);
  40207. }
  40208. Util.inherit(HighlightAnnotation, Annotation, {});
  40209. return HighlightAnnotation;
  40210. }();
  40211. var UnderlineAnnotation = function UnderlineAnnotationClosure() {
  40212. function UnderlineAnnotation(parameters) {
  40213. Annotation.call(this, parameters);
  40214. this.data.annotationType = AnnotationType.UNDERLINE;
  40215. this._preparePopup(parameters.dict);
  40216. this.data.borderStyle.setWidth(0);
  40217. }
  40218. Util.inherit(UnderlineAnnotation, Annotation, {});
  40219. return UnderlineAnnotation;
  40220. }();
  40221. var SquigglyAnnotation = function SquigglyAnnotationClosure() {
  40222. function SquigglyAnnotation(parameters) {
  40223. Annotation.call(this, parameters);
  40224. this.data.annotationType = AnnotationType.SQUIGGLY;
  40225. this._preparePopup(parameters.dict);
  40226. this.data.borderStyle.setWidth(0);
  40227. }
  40228. Util.inherit(SquigglyAnnotation, Annotation, {});
  40229. return SquigglyAnnotation;
  40230. }();
  40231. var StrikeOutAnnotation = function StrikeOutAnnotationClosure() {
  40232. function StrikeOutAnnotation(parameters) {
  40233. Annotation.call(this, parameters);
  40234. this.data.annotationType = AnnotationType.STRIKEOUT;
  40235. this._preparePopup(parameters.dict);
  40236. this.data.borderStyle.setWidth(0);
  40237. }
  40238. Util.inherit(StrikeOutAnnotation, Annotation, {});
  40239. return StrikeOutAnnotation;
  40240. }();
  40241. var FileAttachmentAnnotation = function FileAttachmentAnnotationClosure() {
  40242. function FileAttachmentAnnotation(parameters) {
  40243. Annotation.call(this, parameters);
  40244. var file = new FileSpec(parameters.dict.get('FS'), parameters.xref);
  40245. this.data.annotationType = AnnotationType.FILEATTACHMENT;
  40246. this.data.file = file.serializable;
  40247. this._preparePopup(parameters.dict);
  40248. }
  40249. Util.inherit(FileAttachmentAnnotation, Annotation, {});
  40250. return FileAttachmentAnnotation;
  40251. }();
  40252. exports.Annotation = Annotation;
  40253. exports.AnnotationBorderStyle = AnnotationBorderStyle;
  40254. exports.AnnotationFactory = AnnotationFactory;
  40255. /***/ }),
  40256. /* 28 */
  40257. /***/ (function(module, exports, __w_pdfjs_require__) {
  40258. "use strict";
  40259. var sharedUtil = __w_pdfjs_require__(0);
  40260. var warn = sharedUtil.warn;
  40261. var baseTypes = [
  40262. 'BN',
  40263. 'BN',
  40264. 'BN',
  40265. 'BN',
  40266. 'BN',
  40267. 'BN',
  40268. 'BN',
  40269. 'BN',
  40270. 'BN',
  40271. 'S',
  40272. 'B',
  40273. 'S',
  40274. 'WS',
  40275. 'B',
  40276. 'BN',
  40277. 'BN',
  40278. 'BN',
  40279. 'BN',
  40280. 'BN',
  40281. 'BN',
  40282. 'BN',
  40283. 'BN',
  40284. 'BN',
  40285. 'BN',
  40286. 'BN',
  40287. 'BN',
  40288. 'BN',
  40289. 'BN',
  40290. 'B',
  40291. 'B',
  40292. 'B',
  40293. 'S',
  40294. 'WS',
  40295. 'ON',
  40296. 'ON',
  40297. 'ET',
  40298. 'ET',
  40299. 'ET',
  40300. 'ON',
  40301. 'ON',
  40302. 'ON',
  40303. 'ON',
  40304. 'ON',
  40305. 'ES',
  40306. 'CS',
  40307. 'ES',
  40308. 'CS',
  40309. 'CS',
  40310. 'EN',
  40311. 'EN',
  40312. 'EN',
  40313. 'EN',
  40314. 'EN',
  40315. 'EN',
  40316. 'EN',
  40317. 'EN',
  40318. 'EN',
  40319. 'EN',
  40320. 'CS',
  40321. 'ON',
  40322. 'ON',
  40323. 'ON',
  40324. 'ON',
  40325. 'ON',
  40326. 'ON',
  40327. 'L',
  40328. 'L',
  40329. 'L',
  40330. 'L',
  40331. 'L',
  40332. 'L',
  40333. 'L',
  40334. 'L',
  40335. 'L',
  40336. 'L',
  40337. 'L',
  40338. 'L',
  40339. 'L',
  40340. 'L',
  40341. 'L',
  40342. 'L',
  40343. 'L',
  40344. 'L',
  40345. 'L',
  40346. 'L',
  40347. 'L',
  40348. 'L',
  40349. 'L',
  40350. 'L',
  40351. 'L',
  40352. 'L',
  40353. 'ON',
  40354. 'ON',
  40355. 'ON',
  40356. 'ON',
  40357. 'ON',
  40358. 'ON',
  40359. 'L',
  40360. 'L',
  40361. 'L',
  40362. 'L',
  40363. 'L',
  40364. 'L',
  40365. 'L',
  40366. 'L',
  40367. 'L',
  40368. 'L',
  40369. 'L',
  40370. 'L',
  40371. 'L',
  40372. 'L',
  40373. 'L',
  40374. 'L',
  40375. 'L',
  40376. 'L',
  40377. 'L',
  40378. 'L',
  40379. 'L',
  40380. 'L',
  40381. 'L',
  40382. 'L',
  40383. 'L',
  40384. 'L',
  40385. 'ON',
  40386. 'ON',
  40387. 'ON',
  40388. 'ON',
  40389. 'BN',
  40390. 'BN',
  40391. 'BN',
  40392. 'BN',
  40393. 'BN',
  40394. 'BN',
  40395. 'B',
  40396. 'BN',
  40397. 'BN',
  40398. 'BN',
  40399. 'BN',
  40400. 'BN',
  40401. 'BN',
  40402. 'BN',
  40403. 'BN',
  40404. 'BN',
  40405. 'BN',
  40406. 'BN',
  40407. 'BN',
  40408. 'BN',
  40409. 'BN',
  40410. 'BN',
  40411. 'BN',
  40412. 'BN',
  40413. 'BN',
  40414. 'BN',
  40415. 'BN',
  40416. 'BN',
  40417. 'BN',
  40418. 'BN',
  40419. 'BN',
  40420. 'BN',
  40421. 'BN',
  40422. 'CS',
  40423. 'ON',
  40424. 'ET',
  40425. 'ET',
  40426. 'ET',
  40427. 'ET',
  40428. 'ON',
  40429. 'ON',
  40430. 'ON',
  40431. 'ON',
  40432. 'L',
  40433. 'ON',
  40434. 'ON',
  40435. 'BN',
  40436. 'ON',
  40437. 'ON',
  40438. 'ET',
  40439. 'ET',
  40440. 'EN',
  40441. 'EN',
  40442. 'ON',
  40443. 'L',
  40444. 'ON',
  40445. 'ON',
  40446. 'ON',
  40447. 'EN',
  40448. 'L',
  40449. 'ON',
  40450. 'ON',
  40451. 'ON',
  40452. 'ON',
  40453. 'ON',
  40454. 'L',
  40455. 'L',
  40456. 'L',
  40457. 'L',
  40458. 'L',
  40459. 'L',
  40460. 'L',
  40461. 'L',
  40462. 'L',
  40463. 'L',
  40464. 'L',
  40465. 'L',
  40466. 'L',
  40467. 'L',
  40468. 'L',
  40469. 'L',
  40470. 'L',
  40471. 'L',
  40472. 'L',
  40473. 'L',
  40474. 'L',
  40475. 'L',
  40476. 'L',
  40477. 'ON',
  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. 'L',
  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. 'ON',
  40510. 'L',
  40511. 'L',
  40512. 'L',
  40513. 'L',
  40514. 'L',
  40515. 'L',
  40516. 'L',
  40517. 'L'
  40518. ];
  40519. var arabicTypes = [
  40520. 'AN',
  40521. 'AN',
  40522. 'AN',
  40523. 'AN',
  40524. 'AN',
  40525. 'AN',
  40526. 'ON',
  40527. 'ON',
  40528. 'AL',
  40529. 'ET',
  40530. 'ET',
  40531. 'AL',
  40532. 'CS',
  40533. 'AL',
  40534. 'ON',
  40535. 'ON',
  40536. 'NSM',
  40537. 'NSM',
  40538. 'NSM',
  40539. 'NSM',
  40540. 'NSM',
  40541. 'NSM',
  40542. 'NSM',
  40543. 'NSM',
  40544. 'NSM',
  40545. 'NSM',
  40546. 'NSM',
  40547. 'AL',
  40548. 'AL',
  40549. '',
  40550. 'AL',
  40551. 'AL',
  40552. 'AL',
  40553. 'AL',
  40554. 'AL',
  40555. 'AL',
  40556. 'AL',
  40557. 'AL',
  40558. 'AL',
  40559. 'AL',
  40560. 'AL',
  40561. 'AL',
  40562. 'AL',
  40563. 'AL',
  40564. 'AL',
  40565. 'AL',
  40566. 'AL',
  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. 'NSM',
  40596. 'NSM',
  40597. 'NSM',
  40598. 'NSM',
  40599. 'NSM',
  40600. 'NSM',
  40601. 'NSM',
  40602. 'NSM',
  40603. 'NSM',
  40604. 'NSM',
  40605. 'NSM',
  40606. 'NSM',
  40607. 'NSM',
  40608. 'NSM',
  40609. 'NSM',
  40610. 'NSM',
  40611. 'NSM',
  40612. 'NSM',
  40613. 'NSM',
  40614. 'NSM',
  40615. 'NSM',
  40616. 'AN',
  40617. 'AN',
  40618. 'AN',
  40619. 'AN',
  40620. 'AN',
  40621. 'AN',
  40622. 'AN',
  40623. 'AN',
  40624. 'AN',
  40625. 'AN',
  40626. 'ET',
  40627. 'AN',
  40628. 'AN',
  40629. 'AL',
  40630. 'AL',
  40631. 'AL',
  40632. 'NSM',
  40633. 'AL',
  40634. 'AL',
  40635. 'AL',
  40636. 'AL',
  40637. 'AL',
  40638. 'AL',
  40639. 'AL',
  40640. 'AL',
  40641. 'AL',
  40642. 'AL',
  40643. 'AL',
  40644. 'AL',
  40645. 'AL',
  40646. 'AL',
  40647. 'AL',
  40648. 'AL',
  40649. 'AL',
  40650. 'AL',
  40651. 'AL',
  40652. 'AL',
  40653. 'AL',
  40654. 'AL',
  40655. 'AL',
  40656. 'AL',
  40657. 'AL',
  40658. 'AL',
  40659. 'AL',
  40660. 'AL',
  40661. 'AL',
  40662. 'AL',
  40663. 'AL',
  40664. 'AL',
  40665. 'AL',
  40666. 'AL',
  40667. 'AL',
  40668. 'AL',
  40669. 'AL',
  40670. 'AL',
  40671. 'AL',
  40672. 'AL',
  40673. 'AL',
  40674. 'AL',
  40675. 'AL',
  40676. 'AL',
  40677. 'AL',
  40678. 'AL',
  40679. 'AL',
  40680. '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. 'NSM',
  40735. 'NSM',
  40736. 'NSM',
  40737. 'NSM',
  40738. 'NSM',
  40739. 'NSM',
  40740. 'NSM',
  40741. 'AN',
  40742. 'ON',
  40743. 'NSM',
  40744. 'NSM',
  40745. 'NSM',
  40746. 'NSM',
  40747. 'NSM',
  40748. 'NSM',
  40749. 'AL',
  40750. 'AL',
  40751. 'NSM',
  40752. 'NSM',
  40753. 'ON',
  40754. 'NSM',
  40755. 'NSM',
  40756. 'NSM',
  40757. 'NSM',
  40758. 'AL',
  40759. 'AL',
  40760. 'EN',
  40761. 'EN',
  40762. 'EN',
  40763. 'EN',
  40764. 'EN',
  40765. 'EN',
  40766. 'EN',
  40767. 'EN',
  40768. 'EN',
  40769. 'EN',
  40770. 'AL',
  40771. 'AL',
  40772. 'AL',
  40773. 'AL',
  40774. 'AL',
  40775. 'AL'
  40776. ];
  40777. function isOdd(i) {
  40778. return (i & 1) !== 0;
  40779. }
  40780. function isEven(i) {
  40781. return (i & 1) === 0;
  40782. }
  40783. function findUnequal(arr, start, value) {
  40784. for (var j = start, jj = arr.length; j < jj; ++j) {
  40785. if (arr[j] !== value) {
  40786. return j;
  40787. }
  40788. }
  40789. return j;
  40790. }
  40791. function setValues(arr, start, end, value) {
  40792. for (var j = start; j < end; ++j) {
  40793. arr[j] = value;
  40794. }
  40795. }
  40796. function reverseValues(arr, start, end) {
  40797. for (var i = start, j = end - 1; i < j; ++i, --j) {
  40798. var temp = arr[i];
  40799. arr[i] = arr[j];
  40800. arr[j] = temp;
  40801. }
  40802. }
  40803. function createBidiText(str, isLTR, vertical) {
  40804. return {
  40805. str: str,
  40806. dir: vertical ? 'ttb' : isLTR ? 'ltr' : 'rtl'
  40807. };
  40808. }
  40809. var chars = [];
  40810. var types = [];
  40811. function bidi(str, startLevel, vertical) {
  40812. var isLTR = true;
  40813. var strLength = str.length;
  40814. if (strLength === 0 || vertical) {
  40815. return createBidiText(str, isLTR, vertical);
  40816. }
  40817. chars.length = strLength;
  40818. types.length = strLength;
  40819. var numBidi = 0;
  40820. var i, ii;
  40821. for (i = 0; i < strLength; ++i) {
  40822. chars[i] = str.charAt(i);
  40823. var charCode = str.charCodeAt(i);
  40824. var charType = 'L';
  40825. if (charCode <= 0x00ff) {
  40826. charType = baseTypes[charCode];
  40827. } else if (0x0590 <= charCode && charCode <= 0x05f4) {
  40828. charType = 'R';
  40829. } else if (0x0600 <= charCode && charCode <= 0x06ff) {
  40830. charType = arabicTypes[charCode & 0xff];
  40831. if (!charType) {
  40832. warn('Bidi: invalid Unicode character ' + charCode.toString(16));
  40833. }
  40834. } else if (0x0700 <= charCode && charCode <= 0x08AC) {
  40835. charType = 'AL';
  40836. }
  40837. if (charType === 'R' || charType === 'AL' || charType === 'AN') {
  40838. numBidi++;
  40839. }
  40840. types[i] = charType;
  40841. }
  40842. if (numBidi === 0) {
  40843. isLTR = true;
  40844. return createBidiText(str, isLTR);
  40845. }
  40846. if (startLevel === -1) {
  40847. if (numBidi / strLength < 0.3) {
  40848. isLTR = true;
  40849. startLevel = 0;
  40850. } else {
  40851. isLTR = false;
  40852. startLevel = 1;
  40853. }
  40854. }
  40855. var levels = [];
  40856. for (i = 0; i < strLength; ++i) {
  40857. levels[i] = startLevel;
  40858. }
  40859. var e = isOdd(startLevel) ? 'R' : 'L';
  40860. var sor = e;
  40861. var eor = sor;
  40862. var lastType = sor;
  40863. for (i = 0; i < strLength; ++i) {
  40864. if (types[i] === 'NSM') {
  40865. types[i] = lastType;
  40866. } else {
  40867. lastType = types[i];
  40868. }
  40869. }
  40870. lastType = sor;
  40871. var t;
  40872. for (i = 0; i < strLength; ++i) {
  40873. t = types[i];
  40874. if (t === 'EN') {
  40875. types[i] = lastType === 'AL' ? 'AN' : 'EN';
  40876. } else if (t === 'R' || t === 'L' || t === 'AL') {
  40877. lastType = t;
  40878. }
  40879. }
  40880. for (i = 0; i < strLength; ++i) {
  40881. t = types[i];
  40882. if (t === 'AL') {
  40883. types[i] = 'R';
  40884. }
  40885. }
  40886. for (i = 1; i < strLength - 1; ++i) {
  40887. if (types[i] === 'ES' && types[i - 1] === 'EN' && types[i + 1] === 'EN') {
  40888. types[i] = 'EN';
  40889. }
  40890. if (types[i] === 'CS' && (types[i - 1] === 'EN' || types[i - 1] === 'AN') && types[i + 1] === types[i - 1]) {
  40891. types[i] = types[i - 1];
  40892. }
  40893. }
  40894. for (i = 0; i < strLength; ++i) {
  40895. if (types[i] === 'EN') {
  40896. var j;
  40897. for (j = i - 1; j >= 0; --j) {
  40898. if (types[j] !== 'ET') {
  40899. break;
  40900. }
  40901. types[j] = 'EN';
  40902. }
  40903. for (j = i + 1; j < strLength; ++j) {
  40904. if (types[j] !== 'ET') {
  40905. break;
  40906. }
  40907. types[j] = 'EN';
  40908. }
  40909. }
  40910. }
  40911. for (i = 0; i < strLength; ++i) {
  40912. t = types[i];
  40913. if (t === 'WS' || t === 'ES' || t === 'ET' || t === 'CS') {
  40914. types[i] = 'ON';
  40915. }
  40916. }
  40917. lastType = sor;
  40918. for (i = 0; i < strLength; ++i) {
  40919. t = types[i];
  40920. if (t === 'EN') {
  40921. types[i] = lastType === 'L' ? 'L' : 'EN';
  40922. } else if (t === 'R' || t === 'L') {
  40923. lastType = t;
  40924. }
  40925. }
  40926. for (i = 0; i < strLength; ++i) {
  40927. if (types[i] === 'ON') {
  40928. var end = findUnequal(types, i + 1, 'ON');
  40929. var before = sor;
  40930. if (i > 0) {
  40931. before = types[i - 1];
  40932. }
  40933. var after = eor;
  40934. if (end + 1 < strLength) {
  40935. after = types[end + 1];
  40936. }
  40937. if (before !== 'L') {
  40938. before = 'R';
  40939. }
  40940. if (after !== 'L') {
  40941. after = 'R';
  40942. }
  40943. if (before === after) {
  40944. setValues(types, i, end, before);
  40945. }
  40946. i = end - 1;
  40947. }
  40948. }
  40949. for (i = 0; i < strLength; ++i) {
  40950. if (types[i] === 'ON') {
  40951. types[i] = e;
  40952. }
  40953. }
  40954. for (i = 0; i < strLength; ++i) {
  40955. t = types[i];
  40956. if (isEven(levels[i])) {
  40957. if (t === 'R') {
  40958. levels[i] += 1;
  40959. } else if (t === 'AN' || t === 'EN') {
  40960. levels[i] += 2;
  40961. }
  40962. } else {
  40963. if (t === 'L' || t === 'AN' || t === 'EN') {
  40964. levels[i] += 1;
  40965. }
  40966. }
  40967. }
  40968. var highestLevel = -1;
  40969. var lowestOddLevel = 99;
  40970. var level;
  40971. for (i = 0, ii = levels.length; i < ii; ++i) {
  40972. level = levels[i];
  40973. if (highestLevel < level) {
  40974. highestLevel = level;
  40975. }
  40976. if (lowestOddLevel > level && isOdd(level)) {
  40977. lowestOddLevel = level;
  40978. }
  40979. }
  40980. for (level = highestLevel; level >= lowestOddLevel; --level) {
  40981. var start = -1;
  40982. for (i = 0, ii = levels.length; i < ii; ++i) {
  40983. if (levels[i] < level) {
  40984. if (start >= 0) {
  40985. reverseValues(chars, start, i);
  40986. start = -1;
  40987. }
  40988. } else if (start < 0) {
  40989. start = i;
  40990. }
  40991. }
  40992. if (start >= 0) {
  40993. reverseValues(chars, start, levels.length);
  40994. }
  40995. }
  40996. for (i = 0, ii = chars.length; i < ii; ++i) {
  40997. var ch = chars[i];
  40998. if (ch === '<' || ch === '>') {
  40999. chars[i] = '';
  41000. }
  41001. }
  41002. return createBidiText(chars.join(''), isLTR);
  41003. }
  41004. exports.bidi = bidi;
  41005. /***/ }),
  41006. /* 29 */
  41007. /***/ (function(module, exports, __w_pdfjs_require__) {
  41008. "use strict";
  41009. var ISOAdobeCharset = [
  41010. '.notdef',
  41011. 'space',
  41012. 'exclam',
  41013. 'quotedbl',
  41014. 'numbersign',
  41015. 'dollar',
  41016. 'percent',
  41017. 'ampersand',
  41018. 'quoteright',
  41019. 'parenleft',
  41020. 'parenright',
  41021. 'asterisk',
  41022. 'plus',
  41023. 'comma',
  41024. 'hyphen',
  41025. 'period',
  41026. 'slash',
  41027. 'zero',
  41028. 'one',
  41029. 'two',
  41030. 'three',
  41031. 'four',
  41032. 'five',
  41033. 'six',
  41034. 'seven',
  41035. 'eight',
  41036. 'nine',
  41037. 'colon',
  41038. 'semicolon',
  41039. 'less',
  41040. 'equal',
  41041. 'greater',
  41042. 'question',
  41043. 'at',
  41044. 'A',
  41045. 'B',
  41046. 'C',
  41047. 'D',
  41048. 'E',
  41049. 'F',
  41050. 'G',
  41051. 'H',
  41052. 'I',
  41053. 'J',
  41054. 'K',
  41055. 'L',
  41056. 'M',
  41057. 'N',
  41058. 'O',
  41059. 'P',
  41060. 'Q',
  41061. 'R',
  41062. 'S',
  41063. 'T',
  41064. 'U',
  41065. 'V',
  41066. 'W',
  41067. 'X',
  41068. 'Y',
  41069. 'Z',
  41070. 'bracketleft',
  41071. 'backslash',
  41072. 'bracketright',
  41073. 'asciicircum',
  41074. 'underscore',
  41075. 'quoteleft',
  41076. 'a',
  41077. 'b',
  41078. 'c',
  41079. 'd',
  41080. 'e',
  41081. 'f',
  41082. 'g',
  41083. 'h',
  41084. 'i',
  41085. 'j',
  41086. 'k',
  41087. 'l',
  41088. 'm',
  41089. 'n',
  41090. 'o',
  41091. 'p',
  41092. 'q',
  41093. 'r',
  41094. 's',
  41095. 't',
  41096. 'u',
  41097. 'v',
  41098. 'w',
  41099. 'x',
  41100. 'y',
  41101. 'z',
  41102. 'braceleft',
  41103. 'bar',
  41104. 'braceright',
  41105. 'asciitilde',
  41106. 'exclamdown',
  41107. 'cent',
  41108. 'sterling',
  41109. 'fraction',
  41110. 'yen',
  41111. 'florin',
  41112. 'section',
  41113. 'currency',
  41114. 'quotesingle',
  41115. 'quotedblleft',
  41116. 'guillemotleft',
  41117. 'guilsinglleft',
  41118. 'guilsinglright',
  41119. 'fi',
  41120. 'fl',
  41121. 'endash',
  41122. 'dagger',
  41123. 'daggerdbl',
  41124. 'periodcentered',
  41125. 'paragraph',
  41126. 'bullet',
  41127. 'quotesinglbase',
  41128. 'quotedblbase',
  41129. 'quotedblright',
  41130. 'guillemotright',
  41131. 'ellipsis',
  41132. 'perthousand',
  41133. 'questiondown',
  41134. 'grave',
  41135. 'acute',
  41136. 'circumflex',
  41137. 'tilde',
  41138. 'macron',
  41139. 'breve',
  41140. 'dotaccent',
  41141. 'dieresis',
  41142. 'ring',
  41143. 'cedilla',
  41144. 'hungarumlaut',
  41145. 'ogonek',
  41146. 'caron',
  41147. 'emdash',
  41148. 'AE',
  41149. 'ordfeminine',
  41150. 'Lslash',
  41151. 'Oslash',
  41152. 'OE',
  41153. 'ordmasculine',
  41154. 'ae',
  41155. 'dotlessi',
  41156. 'lslash',
  41157. 'oslash',
  41158. 'oe',
  41159. 'germandbls',
  41160. 'onesuperior',
  41161. 'logicalnot',
  41162. 'mu',
  41163. 'trademark',
  41164. 'Eth',
  41165. 'onehalf',
  41166. 'plusminus',
  41167. 'Thorn',
  41168. 'onequarter',
  41169. 'divide',
  41170. 'brokenbar',
  41171. 'degree',
  41172. 'thorn',
  41173. 'threequarters',
  41174. 'twosuperior',
  41175. 'registered',
  41176. 'minus',
  41177. 'eth',
  41178. 'multiply',
  41179. 'threesuperior',
  41180. 'copyright',
  41181. 'Aacute',
  41182. 'Acircumflex',
  41183. 'Adieresis',
  41184. 'Agrave',
  41185. 'Aring',
  41186. 'Atilde',
  41187. 'Ccedilla',
  41188. 'Eacute',
  41189. 'Ecircumflex',
  41190. 'Edieresis',
  41191. 'Egrave',
  41192. 'Iacute',
  41193. 'Icircumflex',
  41194. 'Idieresis',
  41195. 'Igrave',
  41196. 'Ntilde',
  41197. 'Oacute',
  41198. 'Ocircumflex',
  41199. 'Odieresis',
  41200. 'Ograve',
  41201. 'Otilde',
  41202. 'Scaron',
  41203. 'Uacute',
  41204. 'Ucircumflex',
  41205. 'Udieresis',
  41206. 'Ugrave',
  41207. 'Yacute',
  41208. 'Ydieresis',
  41209. 'Zcaron',
  41210. 'aacute',
  41211. 'acircumflex',
  41212. 'adieresis',
  41213. 'agrave',
  41214. 'aring',
  41215. 'atilde',
  41216. 'ccedilla',
  41217. 'eacute',
  41218. 'ecircumflex',
  41219. 'edieresis',
  41220. 'egrave',
  41221. 'iacute',
  41222. 'icircumflex',
  41223. 'idieresis',
  41224. 'igrave',
  41225. 'ntilde',
  41226. 'oacute',
  41227. 'ocircumflex',
  41228. 'odieresis',
  41229. 'ograve',
  41230. 'otilde',
  41231. 'scaron',
  41232. 'uacute',
  41233. 'ucircumflex',
  41234. 'udieresis',
  41235. 'ugrave',
  41236. 'yacute',
  41237. 'ydieresis',
  41238. 'zcaron'
  41239. ];
  41240. var ExpertCharset = [
  41241. '.notdef',
  41242. 'space',
  41243. 'exclamsmall',
  41244. 'Hungarumlautsmall',
  41245. 'dollaroldstyle',
  41246. 'dollarsuperior',
  41247. 'ampersandsmall',
  41248. 'Acutesmall',
  41249. 'parenleftsuperior',
  41250. 'parenrightsuperior',
  41251. 'twodotenleader',
  41252. 'onedotenleader',
  41253. 'comma',
  41254. 'hyphen',
  41255. 'period',
  41256. 'fraction',
  41257. 'zerooldstyle',
  41258. 'oneoldstyle',
  41259. 'twooldstyle',
  41260. 'threeoldstyle',
  41261. 'fouroldstyle',
  41262. 'fiveoldstyle',
  41263. 'sixoldstyle',
  41264. 'sevenoldstyle',
  41265. 'eightoldstyle',
  41266. 'nineoldstyle',
  41267. 'colon',
  41268. 'semicolon',
  41269. 'commasuperior',
  41270. 'threequartersemdash',
  41271. 'periodsuperior',
  41272. 'questionsmall',
  41273. 'asuperior',
  41274. 'bsuperior',
  41275. 'centsuperior',
  41276. 'dsuperior',
  41277. 'esuperior',
  41278. 'isuperior',
  41279. 'lsuperior',
  41280. 'msuperior',
  41281. 'nsuperior',
  41282. 'osuperior',
  41283. 'rsuperior',
  41284. 'ssuperior',
  41285. 'tsuperior',
  41286. 'ff',
  41287. 'fi',
  41288. 'fl',
  41289. 'ffi',
  41290. 'ffl',
  41291. 'parenleftinferior',
  41292. 'parenrightinferior',
  41293. 'Circumflexsmall',
  41294. 'hyphensuperior',
  41295. 'Gravesmall',
  41296. 'Asmall',
  41297. 'Bsmall',
  41298. 'Csmall',
  41299. 'Dsmall',
  41300. 'Esmall',
  41301. 'Fsmall',
  41302. 'Gsmall',
  41303. 'Hsmall',
  41304. 'Ismall',
  41305. 'Jsmall',
  41306. 'Ksmall',
  41307. 'Lsmall',
  41308. 'Msmall',
  41309. 'Nsmall',
  41310. 'Osmall',
  41311. 'Psmall',
  41312. 'Qsmall',
  41313. 'Rsmall',
  41314. 'Ssmall',
  41315. 'Tsmall',
  41316. 'Usmall',
  41317. 'Vsmall',
  41318. 'Wsmall',
  41319. 'Xsmall',
  41320. 'Ysmall',
  41321. 'Zsmall',
  41322. 'colonmonetary',
  41323. 'onefitted',
  41324. 'rupiah',
  41325. 'Tildesmall',
  41326. 'exclamdownsmall',
  41327. 'centoldstyle',
  41328. 'Lslashsmall',
  41329. 'Scaronsmall',
  41330. 'Zcaronsmall',
  41331. 'Dieresissmall',
  41332. 'Brevesmall',
  41333. 'Caronsmall',
  41334. 'Dotaccentsmall',
  41335. 'Macronsmall',
  41336. 'figuredash',
  41337. 'hypheninferior',
  41338. 'Ogoneksmall',
  41339. 'Ringsmall',
  41340. 'Cedillasmall',
  41341. 'onequarter',
  41342. 'onehalf',
  41343. 'threequarters',
  41344. 'questiondownsmall',
  41345. 'oneeighth',
  41346. 'threeeighths',
  41347. 'fiveeighths',
  41348. 'seveneighths',
  41349. 'onethird',
  41350. 'twothirds',
  41351. 'zerosuperior',
  41352. 'onesuperior',
  41353. 'twosuperior',
  41354. 'threesuperior',
  41355. 'foursuperior',
  41356. 'fivesuperior',
  41357. 'sixsuperior',
  41358. 'sevensuperior',
  41359. 'eightsuperior',
  41360. 'ninesuperior',
  41361. 'zeroinferior',
  41362. 'oneinferior',
  41363. 'twoinferior',
  41364. 'threeinferior',
  41365. 'fourinferior',
  41366. 'fiveinferior',
  41367. 'sixinferior',
  41368. 'seveninferior',
  41369. 'eightinferior',
  41370. 'nineinferior',
  41371. 'centinferior',
  41372. 'dollarinferior',
  41373. 'periodinferior',
  41374. 'commainferior',
  41375. 'Agravesmall',
  41376. 'Aacutesmall',
  41377. 'Acircumflexsmall',
  41378. 'Atildesmall',
  41379. 'Adieresissmall',
  41380. 'Aringsmall',
  41381. 'AEsmall',
  41382. 'Ccedillasmall',
  41383. 'Egravesmall',
  41384. 'Eacutesmall',
  41385. 'Ecircumflexsmall',
  41386. 'Edieresissmall',
  41387. 'Igravesmall',
  41388. 'Iacutesmall',
  41389. 'Icircumflexsmall',
  41390. 'Idieresissmall',
  41391. 'Ethsmall',
  41392. 'Ntildesmall',
  41393. 'Ogravesmall',
  41394. 'Oacutesmall',
  41395. 'Ocircumflexsmall',
  41396. 'Otildesmall',
  41397. 'Odieresissmall',
  41398. 'OEsmall',
  41399. 'Oslashsmall',
  41400. 'Ugravesmall',
  41401. 'Uacutesmall',
  41402. 'Ucircumflexsmall',
  41403. 'Udieresissmall',
  41404. 'Yacutesmall',
  41405. 'Thornsmall',
  41406. 'Ydieresissmall'
  41407. ];
  41408. var ExpertSubsetCharset = [
  41409. '.notdef',
  41410. 'space',
  41411. 'dollaroldstyle',
  41412. 'dollarsuperior',
  41413. 'parenleftsuperior',
  41414. 'parenrightsuperior',
  41415. 'twodotenleader',
  41416. 'onedotenleader',
  41417. 'comma',
  41418. 'hyphen',
  41419. 'period',
  41420. 'fraction',
  41421. 'zerooldstyle',
  41422. 'oneoldstyle',
  41423. 'twooldstyle',
  41424. 'threeoldstyle',
  41425. 'fouroldstyle',
  41426. 'fiveoldstyle',
  41427. 'sixoldstyle',
  41428. 'sevenoldstyle',
  41429. 'eightoldstyle',
  41430. 'nineoldstyle',
  41431. 'colon',
  41432. 'semicolon',
  41433. 'commasuperior',
  41434. 'threequartersemdash',
  41435. 'periodsuperior',
  41436. 'asuperior',
  41437. 'bsuperior',
  41438. 'centsuperior',
  41439. 'dsuperior',
  41440. 'esuperior',
  41441. 'isuperior',
  41442. 'lsuperior',
  41443. 'msuperior',
  41444. 'nsuperior',
  41445. 'osuperior',
  41446. 'rsuperior',
  41447. 'ssuperior',
  41448. 'tsuperior',
  41449. 'ff',
  41450. 'fi',
  41451. 'fl',
  41452. 'ffi',
  41453. 'ffl',
  41454. 'parenleftinferior',
  41455. 'parenrightinferior',
  41456. 'hyphensuperior',
  41457. 'colonmonetary',
  41458. 'onefitted',
  41459. 'rupiah',
  41460. 'centoldstyle',
  41461. 'figuredash',
  41462. 'hypheninferior',
  41463. 'onequarter',
  41464. 'onehalf',
  41465. 'threequarters',
  41466. 'oneeighth',
  41467. 'threeeighths',
  41468. 'fiveeighths',
  41469. 'seveneighths',
  41470. 'onethird',
  41471. 'twothirds',
  41472. 'zerosuperior',
  41473. 'onesuperior',
  41474. 'twosuperior',
  41475. 'threesuperior',
  41476. 'foursuperior',
  41477. 'fivesuperior',
  41478. 'sixsuperior',
  41479. 'sevensuperior',
  41480. 'eightsuperior',
  41481. 'ninesuperior',
  41482. 'zeroinferior',
  41483. 'oneinferior',
  41484. 'twoinferior',
  41485. 'threeinferior',
  41486. 'fourinferior',
  41487. 'fiveinferior',
  41488. 'sixinferior',
  41489. 'seveninferior',
  41490. 'eightinferior',
  41491. 'nineinferior',
  41492. 'centinferior',
  41493. 'dollarinferior',
  41494. 'periodinferior',
  41495. 'commainferior'
  41496. ];
  41497. exports.ISOAdobeCharset = ISOAdobeCharset;
  41498. exports.ExpertCharset = ExpertCharset;
  41499. exports.ExpertSubsetCharset = ExpertSubsetCharset;
  41500. /***/ }),
  41501. /* 30 */
  41502. /***/ (function(module, exports, __w_pdfjs_require__) {
  41503. "use strict";
  41504. var sharedUtil = __w_pdfjs_require__(0);
  41505. var corePrimitives = __w_pdfjs_require__(1);
  41506. var coreStream = __w_pdfjs_require__(2);
  41507. var coreParser = __w_pdfjs_require__(6);
  41508. var Util = sharedUtil.Util;
  41509. var assert = sharedUtil.assert;
  41510. var warn = sharedUtil.warn;
  41511. var error = sharedUtil.error;
  41512. var isInt = sharedUtil.isInt;
  41513. var isString = sharedUtil.isString;
  41514. var MissingDataException = sharedUtil.MissingDataException;
  41515. var isEOF = corePrimitives.isEOF;
  41516. var isName = corePrimitives.isName;
  41517. var isCmd = corePrimitives.isCmd;
  41518. var isStream = corePrimitives.isStream;
  41519. var StringStream = coreStream.StringStream;
  41520. var Lexer = coreParser.Lexer;
  41521. var BUILT_IN_CMAPS = [
  41522. 'Adobe-GB1-UCS2',
  41523. 'Adobe-CNS1-UCS2',
  41524. 'Adobe-Japan1-UCS2',
  41525. 'Adobe-Korea1-UCS2',
  41526. '78-EUC-H',
  41527. '78-EUC-V',
  41528. '78-H',
  41529. '78-RKSJ-H',
  41530. '78-RKSJ-V',
  41531. '78-V',
  41532. '78ms-RKSJ-H',
  41533. '78ms-RKSJ-V',
  41534. '83pv-RKSJ-H',
  41535. '90ms-RKSJ-H',
  41536. '90ms-RKSJ-V',
  41537. '90msp-RKSJ-H',
  41538. '90msp-RKSJ-V',
  41539. '90pv-RKSJ-H',
  41540. '90pv-RKSJ-V',
  41541. 'Add-H',
  41542. 'Add-RKSJ-H',
  41543. 'Add-RKSJ-V',
  41544. 'Add-V',
  41545. 'Adobe-CNS1-0',
  41546. 'Adobe-CNS1-1',
  41547. 'Adobe-CNS1-2',
  41548. 'Adobe-CNS1-3',
  41549. 'Adobe-CNS1-4',
  41550. 'Adobe-CNS1-5',
  41551. 'Adobe-CNS1-6',
  41552. 'Adobe-GB1-0',
  41553. 'Adobe-GB1-1',
  41554. 'Adobe-GB1-2',
  41555. 'Adobe-GB1-3',
  41556. 'Adobe-GB1-4',
  41557. 'Adobe-GB1-5',
  41558. 'Adobe-Japan1-0',
  41559. 'Adobe-Japan1-1',
  41560. 'Adobe-Japan1-2',
  41561. 'Adobe-Japan1-3',
  41562. 'Adobe-Japan1-4',
  41563. 'Adobe-Japan1-5',
  41564. 'Adobe-Japan1-6',
  41565. 'Adobe-Korea1-0',
  41566. 'Adobe-Korea1-1',
  41567. 'Adobe-Korea1-2',
  41568. 'B5-H',
  41569. 'B5-V',
  41570. 'B5pc-H',
  41571. 'B5pc-V',
  41572. 'CNS-EUC-H',
  41573. 'CNS-EUC-V',
  41574. 'CNS1-H',
  41575. 'CNS1-V',
  41576. 'CNS2-H',
  41577. 'CNS2-V',
  41578. 'ETHK-B5-H',
  41579. 'ETHK-B5-V',
  41580. 'ETen-B5-H',
  41581. 'ETen-B5-V',
  41582. 'ETenms-B5-H',
  41583. 'ETenms-B5-V',
  41584. 'EUC-H',
  41585. 'EUC-V',
  41586. 'Ext-H',
  41587. 'Ext-RKSJ-H',
  41588. 'Ext-RKSJ-V',
  41589. 'Ext-V',
  41590. 'GB-EUC-H',
  41591. 'GB-EUC-V',
  41592. 'GB-H',
  41593. 'GB-V',
  41594. 'GBK-EUC-H',
  41595. 'GBK-EUC-V',
  41596. 'GBK2K-H',
  41597. 'GBK2K-V',
  41598. 'GBKp-EUC-H',
  41599. 'GBKp-EUC-V',
  41600. 'GBT-EUC-H',
  41601. 'GBT-EUC-V',
  41602. 'GBT-H',
  41603. 'GBT-V',
  41604. 'GBTpc-EUC-H',
  41605. 'GBTpc-EUC-V',
  41606. 'GBpc-EUC-H',
  41607. 'GBpc-EUC-V',
  41608. 'H',
  41609. 'HKdla-B5-H',
  41610. 'HKdla-B5-V',
  41611. 'HKdlb-B5-H',
  41612. 'HKdlb-B5-V',
  41613. 'HKgccs-B5-H',
  41614. 'HKgccs-B5-V',
  41615. 'HKm314-B5-H',
  41616. 'HKm314-B5-V',
  41617. 'HKm471-B5-H',
  41618. 'HKm471-B5-V',
  41619. 'HKscs-B5-H',
  41620. 'HKscs-B5-V',
  41621. 'Hankaku',
  41622. 'Hiragana',
  41623. 'KSC-EUC-H',
  41624. 'KSC-EUC-V',
  41625. 'KSC-H',
  41626. 'KSC-Johab-H',
  41627. 'KSC-Johab-V',
  41628. 'KSC-V',
  41629. 'KSCms-UHC-H',
  41630. 'KSCms-UHC-HW-H',
  41631. 'KSCms-UHC-HW-V',
  41632. 'KSCms-UHC-V',
  41633. 'KSCpc-EUC-H',
  41634. 'KSCpc-EUC-V',
  41635. 'Katakana',
  41636. 'NWP-H',
  41637. 'NWP-V',
  41638. 'RKSJ-H',
  41639. 'RKSJ-V',
  41640. 'Roman',
  41641. 'UniCNS-UCS2-H',
  41642. 'UniCNS-UCS2-V',
  41643. 'UniCNS-UTF16-H',
  41644. 'UniCNS-UTF16-V',
  41645. 'UniCNS-UTF32-H',
  41646. 'UniCNS-UTF32-V',
  41647. 'UniCNS-UTF8-H',
  41648. 'UniCNS-UTF8-V',
  41649. 'UniGB-UCS2-H',
  41650. 'UniGB-UCS2-V',
  41651. 'UniGB-UTF16-H',
  41652. 'UniGB-UTF16-V',
  41653. 'UniGB-UTF32-H',
  41654. 'UniGB-UTF32-V',
  41655. 'UniGB-UTF8-H',
  41656. 'UniGB-UTF8-V',
  41657. 'UniJIS-UCS2-H',
  41658. 'UniJIS-UCS2-HW-H',
  41659. 'UniJIS-UCS2-HW-V',
  41660. 'UniJIS-UCS2-V',
  41661. 'UniJIS-UTF16-H',
  41662. 'UniJIS-UTF16-V',
  41663. 'UniJIS-UTF32-H',
  41664. 'UniJIS-UTF32-V',
  41665. 'UniJIS-UTF8-H',
  41666. 'UniJIS-UTF8-V',
  41667. 'UniJIS2004-UTF16-H',
  41668. 'UniJIS2004-UTF16-V',
  41669. 'UniJIS2004-UTF32-H',
  41670. 'UniJIS2004-UTF32-V',
  41671. 'UniJIS2004-UTF8-H',
  41672. 'UniJIS2004-UTF8-V',
  41673. 'UniJISPro-UCS2-HW-V',
  41674. 'UniJISPro-UCS2-V',
  41675. 'UniJISPro-UTF8-V',
  41676. 'UniJISX0213-UTF32-H',
  41677. 'UniJISX0213-UTF32-V',
  41678. 'UniJISX02132004-UTF32-H',
  41679. 'UniJISX02132004-UTF32-V',
  41680. 'UniKS-UCS2-H',
  41681. 'UniKS-UCS2-V',
  41682. 'UniKS-UTF16-H',
  41683. 'UniKS-UTF16-V',
  41684. 'UniKS-UTF32-H',
  41685. 'UniKS-UTF32-V',
  41686. 'UniKS-UTF8-H',
  41687. 'UniKS-UTF8-V',
  41688. 'V',
  41689. 'WP-Symbol'
  41690. ];
  41691. var CMap = function CMapClosure() {
  41692. function CMap(builtInCMap) {
  41693. this.codespaceRanges = [
  41694. [],
  41695. [],
  41696. [],
  41697. []
  41698. ];
  41699. this.numCodespaceRanges = 0;
  41700. this._map = [];
  41701. this.name = '';
  41702. this.vertical = false;
  41703. this.useCMap = null;
  41704. this.builtInCMap = builtInCMap;
  41705. }
  41706. CMap.prototype = {
  41707. addCodespaceRange: function (n, low, high) {
  41708. this.codespaceRanges[n - 1].push(low, high);
  41709. this.numCodespaceRanges++;
  41710. },
  41711. mapCidRange: function (low, high, dstLow) {
  41712. while (low <= high) {
  41713. this._map[low++] = dstLow++;
  41714. }
  41715. },
  41716. mapBfRange: function (low, high, dstLow) {
  41717. var lastByte = dstLow.length - 1;
  41718. while (low <= high) {
  41719. this._map[low++] = dstLow;
  41720. dstLow = dstLow.substr(0, lastByte) + String.fromCharCode(dstLow.charCodeAt(lastByte) + 1);
  41721. }
  41722. },
  41723. mapBfRangeToArray: function (low, high, array) {
  41724. var i = 0, ii = array.length;
  41725. while (low <= high && i < ii) {
  41726. this._map[low] = array[i++];
  41727. ++low;
  41728. }
  41729. },
  41730. mapOne: function (src, dst) {
  41731. this._map[src] = dst;
  41732. },
  41733. lookup: function (code) {
  41734. return this._map[code];
  41735. },
  41736. contains: function (code) {
  41737. return this._map[code] !== undefined;
  41738. },
  41739. forEach: function (callback) {
  41740. var map = this._map;
  41741. var length = map.length;
  41742. var i;
  41743. if (length <= 0x10000) {
  41744. for (i = 0; i < length; i++) {
  41745. if (map[i] !== undefined) {
  41746. callback(i, map[i]);
  41747. }
  41748. }
  41749. } else {
  41750. for (i in this._map) {
  41751. callback(i, map[i]);
  41752. }
  41753. }
  41754. },
  41755. charCodeOf: function (value) {
  41756. return this._map.indexOf(value);
  41757. },
  41758. getMap: function () {
  41759. return this._map;
  41760. },
  41761. readCharCode: function (str, offset, out) {
  41762. var c = 0;
  41763. var codespaceRanges = this.codespaceRanges;
  41764. var codespaceRangesLen = this.codespaceRanges.length;
  41765. for (var n = 0; n < codespaceRangesLen; n++) {
  41766. c = (c << 8 | str.charCodeAt(offset + n)) >>> 0;
  41767. var codespaceRange = codespaceRanges[n];
  41768. for (var k = 0, kk = codespaceRange.length; k < kk;) {
  41769. var low = codespaceRange[k++];
  41770. var high = codespaceRange[k++];
  41771. if (c >= low && c <= high) {
  41772. out.charcode = c;
  41773. out.length = n + 1;
  41774. return;
  41775. }
  41776. }
  41777. }
  41778. out.charcode = 0;
  41779. out.length = 1;
  41780. },
  41781. get length() {
  41782. return this._map.length;
  41783. },
  41784. get isIdentityCMap() {
  41785. if (!(this.name === 'Identity-H' || this.name === 'Identity-V')) {
  41786. return false;
  41787. }
  41788. if (this._map.length !== 0x10000) {
  41789. return false;
  41790. }
  41791. for (var i = 0; i < 0x10000; i++) {
  41792. if (this._map[i] !== i) {
  41793. return false;
  41794. }
  41795. }
  41796. return true;
  41797. }
  41798. };
  41799. return CMap;
  41800. }();
  41801. var IdentityCMap = function IdentityCMapClosure() {
  41802. function IdentityCMap(vertical, n) {
  41803. CMap.call(this);
  41804. this.vertical = vertical;
  41805. this.addCodespaceRange(n, 0, 0xffff);
  41806. }
  41807. Util.inherit(IdentityCMap, CMap, {});
  41808. IdentityCMap.prototype = {
  41809. addCodespaceRange: CMap.prototype.addCodespaceRange,
  41810. mapCidRange: function (low, high, dstLow) {
  41811. error('should not call mapCidRange');
  41812. },
  41813. mapBfRange: function (low, high, dstLow) {
  41814. error('should not call mapBfRange');
  41815. },
  41816. mapBfRangeToArray: function (low, high, array) {
  41817. error('should not call mapBfRangeToArray');
  41818. },
  41819. mapOne: function (src, dst) {
  41820. error('should not call mapCidOne');
  41821. },
  41822. lookup: function (code) {
  41823. return isInt(code) && code <= 0xffff ? code : undefined;
  41824. },
  41825. contains: function (code) {
  41826. return isInt(code) && code <= 0xffff;
  41827. },
  41828. forEach: function (callback) {
  41829. for (var i = 0; i <= 0xffff; i++) {
  41830. callback(i, i);
  41831. }
  41832. },
  41833. charCodeOf: function (value) {
  41834. return isInt(value) && value <= 0xffff ? value : -1;
  41835. },
  41836. getMap: function () {
  41837. var map = new Array(0x10000);
  41838. for (var i = 0; i <= 0xffff; i++) {
  41839. map[i] = i;
  41840. }
  41841. return map;
  41842. },
  41843. readCharCode: CMap.prototype.readCharCode,
  41844. get length() {
  41845. return 0x10000;
  41846. },
  41847. get isIdentityCMap() {
  41848. error('should not access .isIdentityCMap');
  41849. }
  41850. };
  41851. return IdentityCMap;
  41852. }();
  41853. var BinaryCMapReader = function BinaryCMapReaderClosure() {
  41854. function fetchBinaryData(url) {
  41855. return new Promise(function (resolve, reject) {
  41856. var request = new XMLHttpRequest();
  41857. request.open('GET', url, true);
  41858. request.responseType = 'arraybuffer';
  41859. request.onreadystatechange = function () {
  41860. if (request.readyState === XMLHttpRequest.DONE) {
  41861. if (!request.response || request.status !== 200 && request.status !== 0) {
  41862. reject(new Error('Unable to get binary cMap at: ' + url));
  41863. } else {
  41864. resolve(new Uint8Array(request.response));
  41865. }
  41866. }
  41867. };
  41868. request.send(null);
  41869. });
  41870. }
  41871. function hexToInt(a, size) {
  41872. var n = 0;
  41873. for (var i = 0; i <= size; i++) {
  41874. n = n << 8 | a[i];
  41875. }
  41876. return n >>> 0;
  41877. }
  41878. function hexToStr(a, size) {
  41879. if (size === 1) {
  41880. return String.fromCharCode(a[0], a[1]);
  41881. }
  41882. if (size === 3) {
  41883. return String.fromCharCode(a[0], a[1], a[2], a[3]);
  41884. }
  41885. return String.fromCharCode.apply(null, a.subarray(0, size + 1));
  41886. }
  41887. function addHex(a, b, size) {
  41888. var c = 0;
  41889. for (var i = size; i >= 0; i--) {
  41890. c += a[i] + b[i];
  41891. a[i] = c & 255;
  41892. c >>= 8;
  41893. }
  41894. }
  41895. function incHex(a, size) {
  41896. var c = 1;
  41897. for (var i = size; i >= 0 && c > 0; i--) {
  41898. c += a[i];
  41899. a[i] = c & 255;
  41900. c >>= 8;
  41901. }
  41902. }
  41903. var MAX_NUM_SIZE = 16;
  41904. var MAX_ENCODED_NUM_SIZE = 19;
  41905. function BinaryCMapStream(data) {
  41906. this.buffer = data;
  41907. this.pos = 0;
  41908. this.end = data.length;
  41909. this.tmpBuf = new Uint8Array(MAX_ENCODED_NUM_SIZE);
  41910. }
  41911. BinaryCMapStream.prototype = {
  41912. readByte: function () {
  41913. if (this.pos >= this.end) {
  41914. return -1;
  41915. }
  41916. return this.buffer[this.pos++];
  41917. },
  41918. readNumber: function () {
  41919. var n = 0;
  41920. var last;
  41921. do {
  41922. var b = this.readByte();
  41923. if (b < 0) {
  41924. error('unexpected EOF in bcmap');
  41925. }
  41926. last = !(b & 0x80);
  41927. n = n << 7 | b & 0x7F;
  41928. } while (!last);
  41929. return n;
  41930. },
  41931. readSigned: function () {
  41932. var n = this.readNumber();
  41933. return n & 1 ? ~(n >>> 1) : n >>> 1;
  41934. },
  41935. readHex: function (num, size) {
  41936. num.set(this.buffer.subarray(this.pos, this.pos + size + 1));
  41937. this.pos += size + 1;
  41938. },
  41939. readHexNumber: function (num, size) {
  41940. var last;
  41941. var stack = this.tmpBuf, sp = 0;
  41942. do {
  41943. var b = this.readByte();
  41944. if (b < 0) {
  41945. error('unexpected EOF in bcmap');
  41946. }
  41947. last = !(b & 0x80);
  41948. stack[sp++] = b & 0x7F;
  41949. } while (!last);
  41950. var i = size, buffer = 0, bufferSize = 0;
  41951. while (i >= 0) {
  41952. while (bufferSize < 8 && stack.length > 0) {
  41953. buffer = stack[--sp] << bufferSize | buffer;
  41954. bufferSize += 7;
  41955. }
  41956. num[i] = buffer & 255;
  41957. i--;
  41958. buffer >>= 8;
  41959. bufferSize -= 8;
  41960. }
  41961. },
  41962. readHexSigned: function (num, size) {
  41963. this.readHexNumber(num, size);
  41964. var sign = num[size] & 1 ? 255 : 0;
  41965. var c = 0;
  41966. for (var i = 0; i <= size; i++) {
  41967. c = (c & 1) << 8 | num[i];
  41968. num[i] = c >> 1 ^ sign;
  41969. }
  41970. },
  41971. readString: function () {
  41972. var len = this.readNumber();
  41973. var s = '';
  41974. for (var i = 0; i < len; i++) {
  41975. s += String.fromCharCode(this.readNumber());
  41976. }
  41977. return s;
  41978. }
  41979. };
  41980. function processBinaryCMap(url, cMap, extend) {
  41981. return fetchBinaryData(url).then(function (data) {
  41982. var stream = new BinaryCMapStream(data);
  41983. var header = stream.readByte();
  41984. cMap.vertical = !!(header & 1);
  41985. var useCMap = null;
  41986. var start = new Uint8Array(MAX_NUM_SIZE);
  41987. var end = new Uint8Array(MAX_NUM_SIZE);
  41988. var char = new Uint8Array(MAX_NUM_SIZE);
  41989. var charCode = new Uint8Array(MAX_NUM_SIZE);
  41990. var tmp = new Uint8Array(MAX_NUM_SIZE);
  41991. var code;
  41992. var b;
  41993. while ((b = stream.readByte()) >= 0) {
  41994. var type = b >> 5;
  41995. if (type === 7) {
  41996. switch (b & 0x1F) {
  41997. case 0:
  41998. stream.readString();
  41999. break;
  42000. case 1:
  42001. useCMap = stream.readString();
  42002. break;
  42003. }
  42004. continue;
  42005. }
  42006. var sequence = !!(b & 0x10);
  42007. var dataSize = b & 15;
  42008. assert(dataSize + 1 <= MAX_NUM_SIZE);
  42009. var ucs2DataSize = 1;
  42010. var subitemsCount = stream.readNumber();
  42011. var i;
  42012. switch (type) {
  42013. case 0:
  42014. stream.readHex(start, dataSize);
  42015. stream.readHexNumber(end, dataSize);
  42016. addHex(end, start, dataSize);
  42017. cMap.addCodespaceRange(dataSize + 1, hexToInt(start, dataSize), hexToInt(end, dataSize));
  42018. for (i = 1; i < subitemsCount; i++) {
  42019. incHex(end, dataSize);
  42020. stream.readHexNumber(start, dataSize);
  42021. addHex(start, end, dataSize);
  42022. stream.readHexNumber(end, dataSize);
  42023. addHex(end, start, dataSize);
  42024. cMap.addCodespaceRange(dataSize + 1, hexToInt(start, dataSize), hexToInt(end, dataSize));
  42025. }
  42026. break;
  42027. case 1:
  42028. stream.readHex(start, dataSize);
  42029. stream.readHexNumber(end, dataSize);
  42030. addHex(end, start, dataSize);
  42031. code = stream.readNumber();
  42032. for (i = 1; i < subitemsCount; i++) {
  42033. incHex(end, dataSize);
  42034. stream.readHexNumber(start, dataSize);
  42035. addHex(start, end, dataSize);
  42036. stream.readHexNumber(end, dataSize);
  42037. addHex(end, start, dataSize);
  42038. code = stream.readNumber();
  42039. }
  42040. break;
  42041. case 2:
  42042. stream.readHex(char, dataSize);
  42043. code = stream.readNumber();
  42044. cMap.mapOne(hexToInt(char, dataSize), code);
  42045. for (i = 1; i < subitemsCount; i++) {
  42046. incHex(char, dataSize);
  42047. if (!sequence) {
  42048. stream.readHexNumber(tmp, dataSize);
  42049. addHex(char, tmp, dataSize);
  42050. }
  42051. code = stream.readSigned() + (code + 1);
  42052. cMap.mapOne(hexToInt(char, dataSize), code);
  42053. }
  42054. break;
  42055. case 3:
  42056. stream.readHex(start, dataSize);
  42057. stream.readHexNumber(end, dataSize);
  42058. addHex(end, start, dataSize);
  42059. code = stream.readNumber();
  42060. cMap.mapCidRange(hexToInt(start, dataSize), hexToInt(end, dataSize), code);
  42061. for (i = 1; i < subitemsCount; i++) {
  42062. incHex(end, dataSize);
  42063. if (!sequence) {
  42064. stream.readHexNumber(start, dataSize);
  42065. addHex(start, end, dataSize);
  42066. } else {
  42067. start.set(end);
  42068. }
  42069. stream.readHexNumber(end, dataSize);
  42070. addHex(end, start, dataSize);
  42071. code = stream.readNumber();
  42072. cMap.mapCidRange(hexToInt(start, dataSize), hexToInt(end, dataSize), code);
  42073. }
  42074. break;
  42075. case 4:
  42076. stream.readHex(char, ucs2DataSize);
  42077. stream.readHex(charCode, dataSize);
  42078. cMap.mapOne(hexToInt(char, ucs2DataSize), hexToStr(charCode, dataSize));
  42079. for (i = 1; i < subitemsCount; i++) {
  42080. incHex(char, ucs2DataSize);
  42081. if (!sequence) {
  42082. stream.readHexNumber(tmp, ucs2DataSize);
  42083. addHex(char, tmp, ucs2DataSize);
  42084. }
  42085. incHex(charCode, dataSize);
  42086. stream.readHexSigned(tmp, dataSize);
  42087. addHex(charCode, tmp, dataSize);
  42088. cMap.mapOne(hexToInt(char, ucs2DataSize), hexToStr(charCode, dataSize));
  42089. }
  42090. break;
  42091. case 5:
  42092. stream.readHex(start, ucs2DataSize);
  42093. stream.readHexNumber(end, ucs2DataSize);
  42094. addHex(end, start, ucs2DataSize);
  42095. stream.readHex(charCode, dataSize);
  42096. cMap.mapBfRange(hexToInt(start, ucs2DataSize), hexToInt(end, ucs2DataSize), hexToStr(charCode, dataSize));
  42097. for (i = 1; i < subitemsCount; i++) {
  42098. incHex(end, ucs2DataSize);
  42099. if (!sequence) {
  42100. stream.readHexNumber(start, ucs2DataSize);
  42101. addHex(start, end, ucs2DataSize);
  42102. } else {
  42103. start.set(end);
  42104. }
  42105. stream.readHexNumber(end, ucs2DataSize);
  42106. addHex(end, start, ucs2DataSize);
  42107. stream.readHex(charCode, dataSize);
  42108. cMap.mapBfRange(hexToInt(start, ucs2DataSize), hexToInt(end, ucs2DataSize), hexToStr(charCode, dataSize));
  42109. }
  42110. break;
  42111. default:
  42112. error('Unknown type: ' + type);
  42113. break;
  42114. }
  42115. }
  42116. if (useCMap) {
  42117. return extend(useCMap);
  42118. }
  42119. return cMap;
  42120. });
  42121. }
  42122. function BinaryCMapReader() {
  42123. }
  42124. BinaryCMapReader.prototype = { read: processBinaryCMap };
  42125. return BinaryCMapReader;
  42126. }();
  42127. var CMapFactory = function CMapFactoryClosure() {
  42128. function strToInt(str) {
  42129. var a = 0;
  42130. for (var i = 0; i < str.length; i++) {
  42131. a = a << 8 | str.charCodeAt(i);
  42132. }
  42133. return a >>> 0;
  42134. }
  42135. function expectString(obj) {
  42136. if (!isString(obj)) {
  42137. error('Malformed CMap: expected string.');
  42138. }
  42139. }
  42140. function expectInt(obj) {
  42141. if (!isInt(obj)) {
  42142. error('Malformed CMap: expected int.');
  42143. }
  42144. }
  42145. function parseBfChar(cMap, lexer) {
  42146. while (true) {
  42147. var obj = lexer.getObj();
  42148. if (isEOF(obj)) {
  42149. break;
  42150. }
  42151. if (isCmd(obj, 'endbfchar')) {
  42152. return;
  42153. }
  42154. expectString(obj);
  42155. var src = strToInt(obj);
  42156. obj = lexer.getObj();
  42157. expectString(obj);
  42158. var dst = obj;
  42159. cMap.mapOne(src, dst);
  42160. }
  42161. }
  42162. function parseBfRange(cMap, lexer) {
  42163. while (true) {
  42164. var obj = lexer.getObj();
  42165. if (isEOF(obj)) {
  42166. break;
  42167. }
  42168. if (isCmd(obj, 'endbfrange')) {
  42169. return;
  42170. }
  42171. expectString(obj);
  42172. var low = strToInt(obj);
  42173. obj = lexer.getObj();
  42174. expectString(obj);
  42175. var high = strToInt(obj);
  42176. obj = lexer.getObj();
  42177. if (isInt(obj) || isString(obj)) {
  42178. var dstLow = isInt(obj) ? String.fromCharCode(obj) : obj;
  42179. cMap.mapBfRange(low, high, dstLow);
  42180. } else if (isCmd(obj, '[')) {
  42181. obj = lexer.getObj();
  42182. var array = [];
  42183. while (!isCmd(obj, ']') && !isEOF(obj)) {
  42184. array.push(obj);
  42185. obj = lexer.getObj();
  42186. }
  42187. cMap.mapBfRangeToArray(low, high, array);
  42188. } else {
  42189. break;
  42190. }
  42191. }
  42192. error('Invalid bf range.');
  42193. }
  42194. function parseCidChar(cMap, lexer) {
  42195. while (true) {
  42196. var obj = lexer.getObj();
  42197. if (isEOF(obj)) {
  42198. break;
  42199. }
  42200. if (isCmd(obj, 'endcidchar')) {
  42201. return;
  42202. }
  42203. expectString(obj);
  42204. var src = strToInt(obj);
  42205. obj = lexer.getObj();
  42206. expectInt(obj);
  42207. var dst = obj;
  42208. cMap.mapOne(src, dst);
  42209. }
  42210. }
  42211. function parseCidRange(cMap, lexer) {
  42212. while (true) {
  42213. var obj = lexer.getObj();
  42214. if (isEOF(obj)) {
  42215. break;
  42216. }
  42217. if (isCmd(obj, 'endcidrange')) {
  42218. return;
  42219. }
  42220. expectString(obj);
  42221. var low = strToInt(obj);
  42222. obj = lexer.getObj();
  42223. expectString(obj);
  42224. var high = strToInt(obj);
  42225. obj = lexer.getObj();
  42226. expectInt(obj);
  42227. var dstLow = obj;
  42228. cMap.mapCidRange(low, high, dstLow);
  42229. }
  42230. }
  42231. function parseCodespaceRange(cMap, lexer) {
  42232. while (true) {
  42233. var obj = lexer.getObj();
  42234. if (isEOF(obj)) {
  42235. break;
  42236. }
  42237. if (isCmd(obj, 'endcodespacerange')) {
  42238. return;
  42239. }
  42240. if (!isString(obj)) {
  42241. break;
  42242. }
  42243. var low = strToInt(obj);
  42244. obj = lexer.getObj();
  42245. if (!isString(obj)) {
  42246. break;
  42247. }
  42248. var high = strToInt(obj);
  42249. cMap.addCodespaceRange(obj.length, low, high);
  42250. }
  42251. error('Invalid codespace range.');
  42252. }
  42253. function parseWMode(cMap, lexer) {
  42254. var obj = lexer.getObj();
  42255. if (isInt(obj)) {
  42256. cMap.vertical = !!obj;
  42257. }
  42258. }
  42259. function parseCMapName(cMap, lexer) {
  42260. var obj = lexer.getObj();
  42261. if (isName(obj) && isString(obj.name)) {
  42262. cMap.name = obj.name;
  42263. }
  42264. }
  42265. function parseCMap(cMap, lexer, builtInCMapParams, useCMap) {
  42266. var previous;
  42267. var embededUseCMap;
  42268. objLoop:
  42269. while (true) {
  42270. try {
  42271. var obj = lexer.getObj();
  42272. if (isEOF(obj)) {
  42273. break;
  42274. } else if (isName(obj)) {
  42275. if (obj.name === 'WMode') {
  42276. parseWMode(cMap, lexer);
  42277. } else if (obj.name === 'CMapName') {
  42278. parseCMapName(cMap, lexer);
  42279. }
  42280. previous = obj;
  42281. } else if (isCmd(obj)) {
  42282. switch (obj.cmd) {
  42283. case 'endcmap':
  42284. break objLoop;
  42285. case 'usecmap':
  42286. if (isName(previous)) {
  42287. embededUseCMap = previous.name;
  42288. }
  42289. break;
  42290. case 'begincodespacerange':
  42291. parseCodespaceRange(cMap, lexer);
  42292. break;
  42293. case 'beginbfchar':
  42294. parseBfChar(cMap, lexer);
  42295. break;
  42296. case 'begincidchar':
  42297. parseCidChar(cMap, lexer);
  42298. break;
  42299. case 'beginbfrange':
  42300. parseBfRange(cMap, lexer);
  42301. break;
  42302. case 'begincidrange':
  42303. parseCidRange(cMap, lexer);
  42304. break;
  42305. }
  42306. }
  42307. } catch (ex) {
  42308. if (ex instanceof MissingDataException) {
  42309. throw ex;
  42310. }
  42311. warn('Invalid cMap data: ' + ex);
  42312. continue;
  42313. }
  42314. }
  42315. if (!useCMap && embededUseCMap) {
  42316. useCMap = embededUseCMap;
  42317. }
  42318. if (useCMap) {
  42319. return extendCMap(cMap, builtInCMapParams, useCMap);
  42320. }
  42321. return Promise.resolve(cMap);
  42322. }
  42323. function extendCMap(cMap, builtInCMapParams, useCMap) {
  42324. return createBuiltInCMap(useCMap, builtInCMapParams).then(function (newCMap) {
  42325. cMap.useCMap = newCMap;
  42326. if (cMap.numCodespaceRanges === 0) {
  42327. var useCodespaceRanges = cMap.useCMap.codespaceRanges;
  42328. for (var i = 0; i < useCodespaceRanges.length; i++) {
  42329. cMap.codespaceRanges[i] = useCodespaceRanges[i].slice();
  42330. }
  42331. cMap.numCodespaceRanges = cMap.useCMap.numCodespaceRanges;
  42332. }
  42333. cMap.useCMap.forEach(function (key, value) {
  42334. if (!cMap.contains(key)) {
  42335. cMap.mapOne(key, cMap.useCMap.lookup(key));
  42336. }
  42337. });
  42338. return cMap;
  42339. });
  42340. }
  42341. function parseBinaryCMap(name, builtInCMapParams) {
  42342. var url = builtInCMapParams.url + name + '.bcmap';
  42343. var cMap = new CMap(true);
  42344. return new BinaryCMapReader().read(url, cMap, function (useCMap) {
  42345. return extendCMap(cMap, builtInCMapParams, useCMap);
  42346. });
  42347. }
  42348. function createBuiltInCMap(name, builtInCMapParams) {
  42349. if (name === 'Identity-H') {
  42350. return Promise.resolve(new IdentityCMap(false, 2));
  42351. } else if (name === 'Identity-V') {
  42352. return Promise.resolve(new IdentityCMap(true, 2));
  42353. }
  42354. if (BUILT_IN_CMAPS.indexOf(name) === -1) {
  42355. return Promise.reject(new Error('Unknown cMap name: ' + name));
  42356. }
  42357. assert(builtInCMapParams, 'built-in cMap parameters are not provided');
  42358. if (builtInCMapParams.packed) {
  42359. return parseBinaryCMap(name, builtInCMapParams);
  42360. }
  42361. return new Promise(function (resolve, reject) {
  42362. var url = builtInCMapParams.url + name;
  42363. var request = new XMLHttpRequest();
  42364. request.onreadystatechange = function () {
  42365. if (request.readyState === XMLHttpRequest.DONE) {
  42366. if (request.status === 200 || request.status === 0) {
  42367. var cMap = new CMap(true);
  42368. var lexer = new Lexer(new StringStream(request.responseText));
  42369. parseCMap(cMap, lexer, builtInCMapParams, null).then(function (parsedCMap) {
  42370. resolve(parsedCMap);
  42371. });
  42372. } else {
  42373. reject(new Error('Unable to get cMap at: ' + url));
  42374. }
  42375. }
  42376. };
  42377. request.open('GET', url, true);
  42378. request.send(null);
  42379. });
  42380. }
  42381. return {
  42382. create: function (encoding, builtInCMapParams, useCMap) {
  42383. if (isName(encoding)) {
  42384. return createBuiltInCMap(encoding.name, builtInCMapParams);
  42385. } else if (isStream(encoding)) {
  42386. var cMap = new CMap();
  42387. var lexer = new Lexer(encoding);
  42388. return parseCMap(cMap, lexer, builtInCMapParams, useCMap).then(function (parsedCMap) {
  42389. if (parsedCMap.isIdentityCMap) {
  42390. return createBuiltInCMap(parsedCMap.name, builtInCMapParams);
  42391. }
  42392. return parsedCMap;
  42393. });
  42394. }
  42395. return Promise.reject(new Error('Encoding required.'));
  42396. }
  42397. };
  42398. }();
  42399. exports.CMap = CMap;
  42400. exports.CMapFactory = CMapFactory;
  42401. exports.IdentityCMap = IdentityCMap;
  42402. /***/ }),
  42403. /* 31 */
  42404. /***/ (function(module, exports, __w_pdfjs_require__) {
  42405. "use strict";
  42406. var sharedUtil = __w_pdfjs_require__(0);
  42407. var corePrimitives = __w_pdfjs_require__(1);
  42408. var coreStream = __w_pdfjs_require__(2);
  42409. var coreObj = __w_pdfjs_require__(19);
  42410. var coreParser = __w_pdfjs_require__(6);
  42411. var coreCrypto = __w_pdfjs_require__(16);
  42412. var coreEvaluator = __w_pdfjs_require__(17);
  42413. var coreAnnotation = __w_pdfjs_require__(27);
  42414. var MissingDataException = sharedUtil.MissingDataException;
  42415. var Util = sharedUtil.Util;
  42416. var assert = sharedUtil.assert;
  42417. var error = sharedUtil.error;
  42418. var info = sharedUtil.info;
  42419. var isArray = sharedUtil.isArray;
  42420. var isArrayBuffer = sharedUtil.isArrayBuffer;
  42421. var isNum = sharedUtil.isNum;
  42422. var isString = sharedUtil.isString;
  42423. var shadow = sharedUtil.shadow;
  42424. var stringToBytes = sharedUtil.stringToBytes;
  42425. var stringToPDFString = sharedUtil.stringToPDFString;
  42426. var warn = sharedUtil.warn;
  42427. var isSpace = sharedUtil.isSpace;
  42428. var Dict = corePrimitives.Dict;
  42429. var isDict = corePrimitives.isDict;
  42430. var isName = corePrimitives.isName;
  42431. var isStream = corePrimitives.isStream;
  42432. var NullStream = coreStream.NullStream;
  42433. var Stream = coreStream.Stream;
  42434. var StreamsSequenceStream = coreStream.StreamsSequenceStream;
  42435. var Catalog = coreObj.Catalog;
  42436. var ObjectLoader = coreObj.ObjectLoader;
  42437. var XRef = coreObj.XRef;
  42438. var Linearization = coreParser.Linearization;
  42439. var calculateMD5 = coreCrypto.calculateMD5;
  42440. var OperatorList = coreEvaluator.OperatorList;
  42441. var PartialEvaluator = coreEvaluator.PartialEvaluator;
  42442. var Annotation = coreAnnotation.Annotation;
  42443. var AnnotationFactory = coreAnnotation.AnnotationFactory;
  42444. var Page = function PageClosure() {
  42445. var DEFAULT_USER_UNIT = 1.0;
  42446. var LETTER_SIZE_MEDIABOX = [
  42447. 0,
  42448. 0,
  42449. 612,
  42450. 792
  42451. ];
  42452. function Page(pdfManager, xref, pageIndex, pageDict, ref, fontCache) {
  42453. this.pdfManager = pdfManager;
  42454. this.pageIndex = pageIndex;
  42455. this.pageDict = pageDict;
  42456. this.xref = xref;
  42457. this.ref = ref;
  42458. this.fontCache = fontCache;
  42459. this.evaluatorOptions = pdfManager.evaluatorOptions;
  42460. this.resourcesPromise = null;
  42461. var uniquePrefix = 'p' + this.pageIndex + '_';
  42462. var idCounters = { obj: 0 };
  42463. this.idFactory = {
  42464. createObjId: function () {
  42465. return uniquePrefix + ++idCounters.obj;
  42466. }
  42467. };
  42468. }
  42469. Page.prototype = {
  42470. getPageProp: function Page_getPageProp(key) {
  42471. return this.pageDict.get(key);
  42472. },
  42473. getInheritedPageProp: function Page_getInheritedPageProp(key, getArray) {
  42474. var dict = this.pageDict, valueArray = null, loopCount = 0;
  42475. var MAX_LOOP_COUNT = 100;
  42476. getArray = getArray || false;
  42477. while (dict) {
  42478. var value = getArray ? dict.getArray(key) : dict.get(key);
  42479. if (value) {
  42480. if (!valueArray) {
  42481. valueArray = [];
  42482. }
  42483. valueArray.push(value);
  42484. }
  42485. if (++loopCount > MAX_LOOP_COUNT) {
  42486. warn('Page_getInheritedPageProp: maximum loop count exceeded.');
  42487. break;
  42488. }
  42489. dict = dict.get('Parent');
  42490. }
  42491. if (!valueArray) {
  42492. return Dict.empty;
  42493. }
  42494. if (valueArray.length === 1 || !isDict(valueArray[0]) || loopCount > MAX_LOOP_COUNT) {
  42495. return valueArray[0];
  42496. }
  42497. return Dict.merge(this.xref, valueArray);
  42498. },
  42499. get content() {
  42500. return this.getPageProp('Contents');
  42501. },
  42502. get resources() {
  42503. return shadow(this, 'resources', this.getInheritedPageProp('Resources'));
  42504. },
  42505. get mediaBox() {
  42506. var mediaBox = this.getInheritedPageProp('MediaBox', true);
  42507. if (!isArray(mediaBox) || mediaBox.length !== 4) {
  42508. return shadow(this, 'mediaBox', LETTER_SIZE_MEDIABOX);
  42509. }
  42510. return shadow(this, 'mediaBox', mediaBox);
  42511. },
  42512. get cropBox() {
  42513. var cropBox = this.getInheritedPageProp('CropBox', true);
  42514. if (!isArray(cropBox) || cropBox.length !== 4) {
  42515. return shadow(this, 'cropBox', this.mediaBox);
  42516. }
  42517. return shadow(this, 'cropBox', cropBox);
  42518. },
  42519. get userUnit() {
  42520. var obj = this.getPageProp('UserUnit');
  42521. if (!isNum(obj) || obj <= 0) {
  42522. obj = DEFAULT_USER_UNIT;
  42523. }
  42524. return shadow(this, 'userUnit', obj);
  42525. },
  42526. get view() {
  42527. var mediaBox = this.mediaBox, cropBox = this.cropBox;
  42528. if (mediaBox === cropBox) {
  42529. return shadow(this, 'view', mediaBox);
  42530. }
  42531. var intersection = Util.intersect(cropBox, mediaBox);
  42532. return shadow(this, 'view', intersection || mediaBox);
  42533. },
  42534. get rotate() {
  42535. var rotate = this.getInheritedPageProp('Rotate') || 0;
  42536. if (rotate % 90 !== 0) {
  42537. rotate = 0;
  42538. } else if (rotate >= 360) {
  42539. rotate = rotate % 360;
  42540. } else if (rotate < 0) {
  42541. rotate = (rotate % 360 + 360) % 360;
  42542. }
  42543. return shadow(this, 'rotate', rotate);
  42544. },
  42545. getContentStream: function Page_getContentStream() {
  42546. var content = this.content;
  42547. var stream;
  42548. if (isArray(content)) {
  42549. var xref = this.xref;
  42550. var i, n = content.length;
  42551. var streams = [];
  42552. for (i = 0; i < n; ++i) {
  42553. streams.push(xref.fetchIfRef(content[i]));
  42554. }
  42555. stream = new StreamsSequenceStream(streams);
  42556. } else if (isStream(content)) {
  42557. stream = content;
  42558. } else {
  42559. stream = new NullStream();
  42560. }
  42561. return stream;
  42562. },
  42563. loadResources: function Page_loadResources(keys) {
  42564. if (!this.resourcesPromise) {
  42565. this.resourcesPromise = this.pdfManager.ensure(this, 'resources');
  42566. }
  42567. return this.resourcesPromise.then(function resourceSuccess() {
  42568. var objectLoader = new ObjectLoader(this.resources.map, keys, this.xref);
  42569. return objectLoader.load();
  42570. }.bind(this));
  42571. },
  42572. getOperatorList: function Page_getOperatorList(handler, task, intent, renderInteractiveForms) {
  42573. var self = this;
  42574. var pdfManager = this.pdfManager;
  42575. var contentStreamPromise = pdfManager.ensure(this, 'getContentStream', []);
  42576. var resourcesPromise = this.loadResources([
  42577. 'ExtGState',
  42578. 'ColorSpace',
  42579. 'Pattern',
  42580. 'Shading',
  42581. 'XObject',
  42582. 'Font'
  42583. ]);
  42584. var partialEvaluator = new PartialEvaluator(pdfManager, this.xref, handler, this.pageIndex, this.idFactory, this.fontCache, this.evaluatorOptions);
  42585. var dataPromises = Promise.all([
  42586. contentStreamPromise,
  42587. resourcesPromise
  42588. ]);
  42589. var pageListPromise = dataPromises.then(function (data) {
  42590. var contentStream = data[0];
  42591. var opList = new OperatorList(intent, handler, self.pageIndex);
  42592. handler.send('StartRenderPage', {
  42593. transparency: partialEvaluator.hasBlendModes(self.resources),
  42594. pageIndex: self.pageIndex,
  42595. intent: intent
  42596. });
  42597. return partialEvaluator.getOperatorList(contentStream, task, self.resources, opList).then(function () {
  42598. return opList;
  42599. });
  42600. });
  42601. var annotationsPromise = pdfManager.ensure(this, 'annotations');
  42602. return Promise.all([
  42603. pageListPromise,
  42604. annotationsPromise
  42605. ]).then(function (datas) {
  42606. var pageOpList = datas[0];
  42607. var annotations = datas[1];
  42608. if (annotations.length === 0) {
  42609. pageOpList.flush(true);
  42610. return pageOpList;
  42611. }
  42612. var annotationsReadyPromise = Annotation.appendToOperatorList(annotations, pageOpList, partialEvaluator, task, intent, renderInteractiveForms);
  42613. return annotationsReadyPromise.then(function () {
  42614. pageOpList.flush(true);
  42615. return pageOpList;
  42616. });
  42617. });
  42618. },
  42619. extractTextContent: function Page_extractTextContent(task, normalizeWhitespace, combineTextItems) {
  42620. var handler = {
  42621. on: function nullHandlerOn() {
  42622. },
  42623. send: function nullHandlerSend() {
  42624. }
  42625. };
  42626. var self = this;
  42627. var pdfManager = this.pdfManager;
  42628. var contentStreamPromise = pdfManager.ensure(this, 'getContentStream', []);
  42629. var resourcesPromise = this.loadResources([
  42630. 'ExtGState',
  42631. 'XObject',
  42632. 'Font'
  42633. ]);
  42634. var dataPromises = Promise.all([
  42635. contentStreamPromise,
  42636. resourcesPromise
  42637. ]);
  42638. return dataPromises.then(function (data) {
  42639. var contentStream = data[0];
  42640. var partialEvaluator = new PartialEvaluator(pdfManager, self.xref, handler, self.pageIndex, self.idFactory, self.fontCache, self.evaluatorOptions);
  42641. return partialEvaluator.getTextContent(contentStream, task, self.resources, null, normalizeWhitespace, combineTextItems);
  42642. });
  42643. },
  42644. getAnnotationsData: function Page_getAnnotationsData(intent) {
  42645. var annotations = this.annotations;
  42646. var annotationsData = [];
  42647. for (var i = 0, n = annotations.length; i < n; ++i) {
  42648. if (intent) {
  42649. if (!(intent === 'display' && annotations[i].viewable) && !(intent === 'print' && annotations[i].printable)) {
  42650. continue;
  42651. }
  42652. }
  42653. annotationsData.push(annotations[i].data);
  42654. }
  42655. return annotationsData;
  42656. },
  42657. get annotations() {
  42658. var annotations = [];
  42659. var annotationRefs = this.getInheritedPageProp('Annots') || [];
  42660. var annotationFactory = new AnnotationFactory();
  42661. for (var i = 0, n = annotationRefs.length; i < n; ++i) {
  42662. var annotationRef = annotationRefs[i];
  42663. var annotation = annotationFactory.create(this.xref, annotationRef, this.pdfManager, this.idFactory);
  42664. if (annotation) {
  42665. annotations.push(annotation);
  42666. }
  42667. }
  42668. return shadow(this, 'annotations', annotations);
  42669. }
  42670. };
  42671. return Page;
  42672. }();
  42673. var PDFDocument = function PDFDocumentClosure() {
  42674. var FINGERPRINT_FIRST_BYTES = 1024;
  42675. var EMPTY_FINGERPRINT = '\x00\x00\x00\x00\x00\x00\x00' + '\x00\x00\x00\x00\x00\x00\x00\x00\x00';
  42676. function PDFDocument(pdfManager, arg) {
  42677. var stream;
  42678. if (isStream(arg)) {
  42679. stream = arg;
  42680. } else if (isArrayBuffer(arg)) {
  42681. stream = new Stream(arg);
  42682. } else {
  42683. error('PDFDocument: Unknown argument type');
  42684. }
  42685. assert(stream.length > 0, 'stream must have data');
  42686. this.pdfManager = pdfManager;
  42687. this.stream = stream;
  42688. this.xref = new XRef(stream, pdfManager);
  42689. }
  42690. function find(stream, needle, limit, backwards) {
  42691. var pos = stream.pos;
  42692. var end = stream.end;
  42693. var strBuf = [];
  42694. if (pos + limit > end) {
  42695. limit = end - pos;
  42696. }
  42697. for (var n = 0; n < limit; ++n) {
  42698. strBuf.push(String.fromCharCode(stream.getByte()));
  42699. }
  42700. var str = strBuf.join('');
  42701. stream.pos = pos;
  42702. var index = backwards ? str.lastIndexOf(needle) : str.indexOf(needle);
  42703. if (index === -1) {
  42704. return false;
  42705. }
  42706. stream.pos += index;
  42707. return true;
  42708. }
  42709. var DocumentInfoValidators = {
  42710. get entries() {
  42711. return shadow(this, 'entries', {
  42712. Title: isString,
  42713. Author: isString,
  42714. Subject: isString,
  42715. Keywords: isString,
  42716. Creator: isString,
  42717. Producer: isString,
  42718. CreationDate: isString,
  42719. ModDate: isString,
  42720. Trapped: isName
  42721. });
  42722. }
  42723. };
  42724. PDFDocument.prototype = {
  42725. parse: function PDFDocument_parse(recoveryMode) {
  42726. this.setup(recoveryMode);
  42727. var version = this.catalog.catDict.get('Version');
  42728. if (isName(version)) {
  42729. this.pdfFormatVersion = version.name;
  42730. }
  42731. try {
  42732. this.acroForm = this.catalog.catDict.get('AcroForm');
  42733. if (this.acroForm) {
  42734. this.xfa = this.acroForm.get('XFA');
  42735. var fields = this.acroForm.get('Fields');
  42736. if ((!fields || !isArray(fields) || fields.length === 0) && !this.xfa) {
  42737. this.acroForm = null;
  42738. }
  42739. }
  42740. } catch (ex) {
  42741. info('Something wrong with AcroForm entry');
  42742. this.acroForm = null;
  42743. }
  42744. },
  42745. get linearization() {
  42746. var linearization = null;
  42747. if (this.stream.length) {
  42748. try {
  42749. linearization = Linearization.create(this.stream);
  42750. } catch (err) {
  42751. if (err instanceof MissingDataException) {
  42752. throw err;
  42753. }
  42754. info(err);
  42755. }
  42756. }
  42757. return shadow(this, 'linearization', linearization);
  42758. },
  42759. get startXRef() {
  42760. var stream = this.stream;
  42761. var startXRef = 0;
  42762. var linearization = this.linearization;
  42763. if (linearization) {
  42764. stream.reset();
  42765. if (find(stream, 'endobj', 1024)) {
  42766. startXRef = stream.pos + 6;
  42767. }
  42768. } else {
  42769. var step = 1024;
  42770. var found = false, pos = stream.end;
  42771. while (!found && pos > 0) {
  42772. pos -= step - 'startxref'.length;
  42773. if (pos < 0) {
  42774. pos = 0;
  42775. }
  42776. stream.pos = pos;
  42777. found = find(stream, 'startxref', step, true);
  42778. }
  42779. if (found) {
  42780. stream.skip(9);
  42781. var ch;
  42782. do {
  42783. ch = stream.getByte();
  42784. } while (isSpace(ch));
  42785. var str = '';
  42786. while (ch >= 0x20 && ch <= 0x39) {
  42787. str += String.fromCharCode(ch);
  42788. ch = stream.getByte();
  42789. }
  42790. startXRef = parseInt(str, 10);
  42791. if (isNaN(startXRef)) {
  42792. startXRef = 0;
  42793. }
  42794. }
  42795. }
  42796. return shadow(this, 'startXRef', startXRef);
  42797. },
  42798. get mainXRefEntriesOffset() {
  42799. var mainXRefEntriesOffset = 0;
  42800. var linearization = this.linearization;
  42801. if (linearization) {
  42802. mainXRefEntriesOffset = linearization.mainXRefEntriesOffset;
  42803. }
  42804. return shadow(this, 'mainXRefEntriesOffset', mainXRefEntriesOffset);
  42805. },
  42806. checkHeader: function PDFDocument_checkHeader() {
  42807. var stream = this.stream;
  42808. stream.reset();
  42809. if (find(stream, '%PDF-', 1024)) {
  42810. stream.moveStart();
  42811. var MAX_VERSION_LENGTH = 12;
  42812. var version = '', ch;
  42813. while ((ch = stream.getByte()) > 0x20) {
  42814. if (version.length >= MAX_VERSION_LENGTH) {
  42815. break;
  42816. }
  42817. version += String.fromCharCode(ch);
  42818. }
  42819. if (!this.pdfFormatVersion) {
  42820. this.pdfFormatVersion = version.substring(5);
  42821. }
  42822. return;
  42823. }
  42824. },
  42825. parseStartXRef: function PDFDocument_parseStartXRef() {
  42826. var startXRef = this.startXRef;
  42827. this.xref.setStartXRef(startXRef);
  42828. },
  42829. setup: function PDFDocument_setup(recoveryMode) {
  42830. this.xref.parse(recoveryMode);
  42831. var self = this;
  42832. var pageFactory = {
  42833. createPage: function (pageIndex, dict, ref, fontCache) {
  42834. return new Page(self.pdfManager, self.xref, pageIndex, dict, ref, fontCache);
  42835. }
  42836. };
  42837. this.catalog = new Catalog(this.pdfManager, this.xref, pageFactory);
  42838. },
  42839. get numPages() {
  42840. var linearization = this.linearization;
  42841. var num = linearization ? linearization.numPages : this.catalog.numPages;
  42842. return shadow(this, 'numPages', num);
  42843. },
  42844. get documentInfo() {
  42845. var docInfo = {
  42846. PDFFormatVersion: this.pdfFormatVersion,
  42847. IsAcroFormPresent: !!this.acroForm,
  42848. IsXFAPresent: !!this.xfa
  42849. };
  42850. var infoDict;
  42851. try {
  42852. infoDict = this.xref.trailer.get('Info');
  42853. } catch (err) {
  42854. info('The document information dictionary is invalid.');
  42855. }
  42856. if (infoDict) {
  42857. var validEntries = DocumentInfoValidators.entries;
  42858. for (var key in validEntries) {
  42859. if (infoDict.has(key)) {
  42860. var value = infoDict.get(key);
  42861. if (validEntries[key](value)) {
  42862. docInfo[key] = typeof value !== 'string' ? value : stringToPDFString(value);
  42863. } else {
  42864. info('Bad value in document info for "' + key + '"');
  42865. }
  42866. }
  42867. }
  42868. }
  42869. return shadow(this, 'documentInfo', docInfo);
  42870. },
  42871. get fingerprint() {
  42872. var xref = this.xref, hash, fileID = '';
  42873. var idArray = xref.trailer.get('ID');
  42874. if (idArray && isArray(idArray) && idArray[0] && isString(idArray[0]) && idArray[0] !== EMPTY_FINGERPRINT) {
  42875. hash = stringToBytes(idArray[0]);
  42876. } else {
  42877. if (this.stream.ensureRange) {
  42878. this.stream.ensureRange(0, Math.min(FINGERPRINT_FIRST_BYTES, this.stream.end));
  42879. }
  42880. hash = calculateMD5(this.stream.bytes.subarray(0, FINGERPRINT_FIRST_BYTES), 0, FINGERPRINT_FIRST_BYTES);
  42881. }
  42882. for (var i = 0, n = hash.length; i < n; i++) {
  42883. var hex = hash[i].toString(16);
  42884. fileID += hex.length === 1 ? '0' + hex : hex;
  42885. }
  42886. return shadow(this, 'fingerprint', fileID);
  42887. },
  42888. getPage: function PDFDocument_getPage(pageIndex) {
  42889. return this.catalog.getPage(pageIndex);
  42890. },
  42891. cleanup: function PDFDocument_cleanup() {
  42892. return this.catalog.cleanup();
  42893. }
  42894. };
  42895. return PDFDocument;
  42896. }();
  42897. exports.Page = Page;
  42898. exports.PDFDocument = PDFDocument;
  42899. /***/ }),
  42900. /* 32 */
  42901. /***/ (function(module, exports, __w_pdfjs_require__) {
  42902. "use strict";
  42903. var sharedUtil = __w_pdfjs_require__(0);
  42904. var coreStream = __w_pdfjs_require__(2);
  42905. var coreGlyphList = __w_pdfjs_require__(8);
  42906. var coreEncodings = __w_pdfjs_require__(5);
  42907. var coreCFFParser = __w_pdfjs_require__(14);
  42908. var Util = sharedUtil.Util;
  42909. var bytesToString = sharedUtil.bytesToString;
  42910. var error = sharedUtil.error;
  42911. var Stream = coreStream.Stream;
  42912. var getGlyphsUnicode = coreGlyphList.getGlyphsUnicode;
  42913. var StandardEncoding = coreEncodings.StandardEncoding;
  42914. var CFFParser = coreCFFParser.CFFParser;
  42915. var FontRendererFactory = function FontRendererFactoryClosure() {
  42916. function getLong(data, offset) {
  42917. return data[offset] << 24 | data[offset + 1] << 16 | data[offset + 2] << 8 | data[offset + 3];
  42918. }
  42919. function getUshort(data, offset) {
  42920. return data[offset] << 8 | data[offset + 1];
  42921. }
  42922. function parseCmap(data, start, end) {
  42923. var offset = getUshort(data, start + 2) === 1 ? getLong(data, start + 8) : getLong(data, start + 16);
  42924. var format = getUshort(data, start + offset);
  42925. var ranges, p, i;
  42926. if (format === 4) {
  42927. getUshort(data, start + offset + 2);
  42928. var segCount = getUshort(data, start + offset + 6) >> 1;
  42929. p = start + offset + 14;
  42930. ranges = [];
  42931. for (i = 0; i < segCount; i++, p += 2) {
  42932. ranges[i] = { end: getUshort(data, p) };
  42933. }
  42934. p += 2;
  42935. for (i = 0; i < segCount; i++, p += 2) {
  42936. ranges[i].start = getUshort(data, p);
  42937. }
  42938. for (i = 0; i < segCount; i++, p += 2) {
  42939. ranges[i].idDelta = getUshort(data, p);
  42940. }
  42941. for (i = 0; i < segCount; i++, p += 2) {
  42942. var idOffset = getUshort(data, p);
  42943. if (idOffset === 0) {
  42944. continue;
  42945. }
  42946. ranges[i].ids = [];
  42947. for (var j = 0, jj = ranges[i].end - ranges[i].start + 1; j < jj; j++) {
  42948. ranges[i].ids[j] = getUshort(data, p + idOffset);
  42949. idOffset += 2;
  42950. }
  42951. }
  42952. return ranges;
  42953. } else if (format === 12) {
  42954. getLong(data, start + offset + 4);
  42955. var groups = getLong(data, start + offset + 12);
  42956. p = start + offset + 16;
  42957. ranges = [];
  42958. for (i = 0; i < groups; i++) {
  42959. ranges.push({
  42960. start: getLong(data, p),
  42961. end: getLong(data, p + 4),
  42962. idDelta: getLong(data, p + 8) - getLong(data, p)
  42963. });
  42964. p += 12;
  42965. }
  42966. return ranges;
  42967. }
  42968. error('not supported cmap: ' + format);
  42969. }
  42970. function parseCff(data, start, end, seacAnalysisEnabled) {
  42971. var properties = {};
  42972. var parser = new CFFParser(new Stream(data, start, end - start), properties, seacAnalysisEnabled);
  42973. var cff = parser.parse();
  42974. return {
  42975. glyphs: cff.charStrings.objects,
  42976. subrs: cff.topDict.privateDict && cff.topDict.privateDict.subrsIndex && cff.topDict.privateDict.subrsIndex.objects,
  42977. gsubrs: cff.globalSubrIndex && cff.globalSubrIndex.objects
  42978. };
  42979. }
  42980. function parseGlyfTable(glyf, loca, isGlyphLocationsLong) {
  42981. var itemSize, itemDecode;
  42982. if (isGlyphLocationsLong) {
  42983. itemSize = 4;
  42984. itemDecode = function fontItemDecodeLong(data, offset) {
  42985. return data[offset] << 24 | data[offset + 1] << 16 | data[offset + 2] << 8 | data[offset + 3];
  42986. };
  42987. } else {
  42988. itemSize = 2;
  42989. itemDecode = function fontItemDecode(data, offset) {
  42990. return data[offset] << 9 | data[offset + 1] << 1;
  42991. };
  42992. }
  42993. var glyphs = [];
  42994. var startOffset = itemDecode(loca, 0);
  42995. for (var j = itemSize; j < loca.length; j += itemSize) {
  42996. var endOffset = itemDecode(loca, j);
  42997. glyphs.push(glyf.subarray(startOffset, endOffset));
  42998. startOffset = endOffset;
  42999. }
  43000. return glyphs;
  43001. }
  43002. function lookupCmap(ranges, unicode) {
  43003. var code = unicode.charCodeAt(0), gid = 0;
  43004. var l = 0, r = ranges.length - 1;
  43005. while (l < r) {
  43006. var c = l + r + 1 >> 1;
  43007. if (code < ranges[c].start) {
  43008. r = c - 1;
  43009. } else {
  43010. l = c;
  43011. }
  43012. }
  43013. if (ranges[l].start <= code && code <= ranges[l].end) {
  43014. gid = ranges[l].idDelta + (ranges[l].ids ? ranges[l].ids[code - ranges[l].start] : code) & 0xFFFF;
  43015. }
  43016. return {
  43017. charCode: code,
  43018. glyphId: gid
  43019. };
  43020. }
  43021. function compileGlyf(code, cmds, font) {
  43022. function moveTo(x, y) {
  43023. cmds.push({
  43024. cmd: 'moveTo',
  43025. args: [
  43026. x,
  43027. y
  43028. ]
  43029. });
  43030. }
  43031. function lineTo(x, y) {
  43032. cmds.push({
  43033. cmd: 'lineTo',
  43034. args: [
  43035. x,
  43036. y
  43037. ]
  43038. });
  43039. }
  43040. function quadraticCurveTo(xa, ya, x, y) {
  43041. cmds.push({
  43042. cmd: 'quadraticCurveTo',
  43043. args: [
  43044. xa,
  43045. ya,
  43046. x,
  43047. y
  43048. ]
  43049. });
  43050. }
  43051. var i = 0;
  43052. var numberOfContours = (code[i] << 24 | code[i + 1] << 16) >> 16;
  43053. var flags;
  43054. var x = 0, y = 0;
  43055. i += 10;
  43056. if (numberOfContours < 0) {
  43057. do {
  43058. flags = code[i] << 8 | code[i + 1];
  43059. var glyphIndex = code[i + 2] << 8 | code[i + 3];
  43060. i += 4;
  43061. var arg1, arg2;
  43062. if (flags & 0x01) {
  43063. arg1 = (code[i] << 24 | code[i + 1] << 16) >> 16;
  43064. arg2 = (code[i + 2] << 24 | code[i + 3] << 16) >> 16;
  43065. i += 4;
  43066. } else {
  43067. arg1 = code[i++];
  43068. arg2 = code[i++];
  43069. }
  43070. if (flags & 0x02) {
  43071. x = arg1;
  43072. y = arg2;
  43073. } else {
  43074. x = 0;
  43075. y = 0;
  43076. }
  43077. var scaleX = 1, scaleY = 1, scale01 = 0, scale10 = 0;
  43078. if (flags & 0x08) {
  43079. scaleX = scaleY = (code[i] << 24 | code[i + 1] << 16) / 1073741824;
  43080. i += 2;
  43081. } else if (flags & 0x40) {
  43082. scaleX = (code[i] << 24 | code[i + 1] << 16) / 1073741824;
  43083. scaleY = (code[i + 2] << 24 | code[i + 3] << 16) / 1073741824;
  43084. i += 4;
  43085. } else if (flags & 0x80) {
  43086. scaleX = (code[i] << 24 | code[i + 1] << 16) / 1073741824;
  43087. scale01 = (code[i + 2] << 24 | code[i + 3] << 16) / 1073741824;
  43088. scale10 = (code[i + 4] << 24 | code[i + 5] << 16) / 1073741824;
  43089. scaleY = (code[i + 6] << 24 | code[i + 7] << 16) / 1073741824;
  43090. i += 8;
  43091. }
  43092. var subglyph = font.glyphs[glyphIndex];
  43093. if (subglyph) {
  43094. cmds.push({ cmd: 'save' });
  43095. cmds.push({
  43096. cmd: 'transform',
  43097. args: [
  43098. scaleX,
  43099. scale01,
  43100. scale10,
  43101. scaleY,
  43102. x,
  43103. y
  43104. ]
  43105. });
  43106. compileGlyf(subglyph, cmds, font);
  43107. cmds.push({ cmd: 'restore' });
  43108. }
  43109. } while (flags & 0x20);
  43110. } else {
  43111. var endPtsOfContours = [];
  43112. var j, jj;
  43113. for (j = 0; j < numberOfContours; j++) {
  43114. endPtsOfContours.push(code[i] << 8 | code[i + 1]);
  43115. i += 2;
  43116. }
  43117. var instructionLength = code[i] << 8 | code[i + 1];
  43118. i += 2 + instructionLength;
  43119. var numberOfPoints = endPtsOfContours[endPtsOfContours.length - 1] + 1;
  43120. var points = [];
  43121. while (points.length < numberOfPoints) {
  43122. flags = code[i++];
  43123. var repeat = 1;
  43124. if (flags & 0x08) {
  43125. repeat += code[i++];
  43126. }
  43127. while (repeat-- > 0) {
  43128. points.push({ flags: flags });
  43129. }
  43130. }
  43131. for (j = 0; j < numberOfPoints; j++) {
  43132. switch (points[j].flags & 0x12) {
  43133. case 0x00:
  43134. x += (code[i] << 24 | code[i + 1] << 16) >> 16;
  43135. i += 2;
  43136. break;
  43137. case 0x02:
  43138. x -= code[i++];
  43139. break;
  43140. case 0x12:
  43141. x += code[i++];
  43142. break;
  43143. }
  43144. points[j].x = x;
  43145. }
  43146. for (j = 0; j < numberOfPoints; j++) {
  43147. switch (points[j].flags & 0x24) {
  43148. case 0x00:
  43149. y += (code[i] << 24 | code[i + 1] << 16) >> 16;
  43150. i += 2;
  43151. break;
  43152. case 0x04:
  43153. y -= code[i++];
  43154. break;
  43155. case 0x24:
  43156. y += code[i++];
  43157. break;
  43158. }
  43159. points[j].y = y;
  43160. }
  43161. var startPoint = 0;
  43162. for (i = 0; i < numberOfContours; i++) {
  43163. var endPoint = endPtsOfContours[i];
  43164. var contour = points.slice(startPoint, endPoint + 1);
  43165. if (contour[0].flags & 1) {
  43166. contour.push(contour[0]);
  43167. } else if (contour[contour.length - 1].flags & 1) {
  43168. contour.unshift(contour[contour.length - 1]);
  43169. } else {
  43170. var p = {
  43171. flags: 1,
  43172. x: (contour[0].x + contour[contour.length - 1].x) / 2,
  43173. y: (contour[0].y + contour[contour.length - 1].y) / 2
  43174. };
  43175. contour.unshift(p);
  43176. contour.push(p);
  43177. }
  43178. moveTo(contour[0].x, contour[0].y);
  43179. for (j = 1, jj = contour.length; j < jj; j++) {
  43180. if (contour[j].flags & 1) {
  43181. lineTo(contour[j].x, contour[j].y);
  43182. } else if (contour[j + 1].flags & 1) {
  43183. quadraticCurveTo(contour[j].x, contour[j].y, contour[j + 1].x, contour[j + 1].y);
  43184. j++;
  43185. } else {
  43186. quadraticCurveTo(contour[j].x, contour[j].y, (contour[j].x + contour[j + 1].x) / 2, (contour[j].y + contour[j + 1].y) / 2);
  43187. }
  43188. }
  43189. startPoint = endPoint + 1;
  43190. }
  43191. }
  43192. }
  43193. function compileCharString(code, cmds, font) {
  43194. var stack = [];
  43195. var x = 0, y = 0;
  43196. var stems = 0;
  43197. function moveTo(x, y) {
  43198. cmds.push({
  43199. cmd: 'moveTo',
  43200. args: [
  43201. x,
  43202. y
  43203. ]
  43204. });
  43205. }
  43206. function lineTo(x, y) {
  43207. cmds.push({
  43208. cmd: 'lineTo',
  43209. args: [
  43210. x,
  43211. y
  43212. ]
  43213. });
  43214. }
  43215. function bezierCurveTo(x1, y1, x2, y2, x, y) {
  43216. cmds.push({
  43217. cmd: 'bezierCurveTo',
  43218. args: [
  43219. x1,
  43220. y1,
  43221. x2,
  43222. y2,
  43223. x,
  43224. y
  43225. ]
  43226. });
  43227. }
  43228. function parse(code) {
  43229. var i = 0;
  43230. while (i < code.length) {
  43231. var stackClean = false;
  43232. var v = code[i++];
  43233. var xa, xb, ya, yb, y1, y2, y3, n, subrCode;
  43234. switch (v) {
  43235. case 1:
  43236. stems += stack.length >> 1;
  43237. stackClean = true;
  43238. break;
  43239. case 3:
  43240. stems += stack.length >> 1;
  43241. stackClean = true;
  43242. break;
  43243. case 4:
  43244. y += stack.pop();
  43245. moveTo(x, y);
  43246. stackClean = true;
  43247. break;
  43248. case 5:
  43249. while (stack.length > 0) {
  43250. x += stack.shift();
  43251. y += stack.shift();
  43252. lineTo(x, y);
  43253. }
  43254. break;
  43255. case 6:
  43256. while (stack.length > 0) {
  43257. x += stack.shift();
  43258. lineTo(x, y);
  43259. if (stack.length === 0) {
  43260. break;
  43261. }
  43262. y += stack.shift();
  43263. lineTo(x, y);
  43264. }
  43265. break;
  43266. case 7:
  43267. while (stack.length > 0) {
  43268. y += stack.shift();
  43269. lineTo(x, y);
  43270. if (stack.length === 0) {
  43271. break;
  43272. }
  43273. x += stack.shift();
  43274. lineTo(x, y);
  43275. }
  43276. break;
  43277. case 8:
  43278. while (stack.length > 0) {
  43279. xa = x + stack.shift();
  43280. ya = y + stack.shift();
  43281. xb = xa + stack.shift();
  43282. yb = ya + stack.shift();
  43283. x = xb + stack.shift();
  43284. y = yb + stack.shift();
  43285. bezierCurveTo(xa, ya, xb, yb, x, y);
  43286. }
  43287. break;
  43288. case 10:
  43289. n = stack.pop() + font.subrsBias;
  43290. subrCode = font.subrs[n];
  43291. if (subrCode) {
  43292. parse(subrCode);
  43293. }
  43294. break;
  43295. case 11:
  43296. return;
  43297. case 12:
  43298. v = code[i++];
  43299. switch (v) {
  43300. case 34:
  43301. xa = x + stack.shift();
  43302. xb = xa + stack.shift();
  43303. y1 = y + stack.shift();
  43304. x = xb + stack.shift();
  43305. bezierCurveTo(xa, y, xb, y1, x, y1);
  43306. xa = x + stack.shift();
  43307. xb = xa + stack.shift();
  43308. x = xb + stack.shift();
  43309. bezierCurveTo(xa, y1, xb, y, x, y);
  43310. break;
  43311. case 35:
  43312. xa = x + stack.shift();
  43313. ya = y + stack.shift();
  43314. xb = xa + stack.shift();
  43315. yb = ya + stack.shift();
  43316. x = xb + stack.shift();
  43317. y = yb + stack.shift();
  43318. bezierCurveTo(xa, ya, xb, yb, x, y);
  43319. xa = x + stack.shift();
  43320. ya = y + stack.shift();
  43321. xb = xa + stack.shift();
  43322. yb = ya + stack.shift();
  43323. x = xb + stack.shift();
  43324. y = yb + stack.shift();
  43325. bezierCurveTo(xa, ya, xb, yb, x, y);
  43326. stack.pop();
  43327. break;
  43328. case 36:
  43329. xa = x + stack.shift();
  43330. y1 = y + stack.shift();
  43331. xb = xa + stack.shift();
  43332. y2 = y1 + stack.shift();
  43333. x = xb + stack.shift();
  43334. bezierCurveTo(xa, y1, xb, y2, x, y2);
  43335. xa = x + stack.shift();
  43336. xb = xa + stack.shift();
  43337. y3 = y2 + stack.shift();
  43338. x = xb + stack.shift();
  43339. bezierCurveTo(xa, y2, xb, y3, x, y);
  43340. break;
  43341. case 37:
  43342. var x0 = x, y0 = y;
  43343. xa = x + stack.shift();
  43344. ya = y + stack.shift();
  43345. xb = xa + stack.shift();
  43346. yb = ya + stack.shift();
  43347. x = xb + stack.shift();
  43348. y = yb + stack.shift();
  43349. bezierCurveTo(xa, ya, xb, yb, x, y);
  43350. xa = x + stack.shift();
  43351. ya = y + stack.shift();
  43352. xb = xa + stack.shift();
  43353. yb = ya + stack.shift();
  43354. x = xb;
  43355. y = yb;
  43356. if (Math.abs(x - x0) > Math.abs(y - y0)) {
  43357. x += stack.shift();
  43358. } else {
  43359. y += stack.shift();
  43360. }
  43361. bezierCurveTo(xa, ya, xb, yb, x, y);
  43362. break;
  43363. default:
  43364. error('unknown operator: 12 ' + v);
  43365. }
  43366. break;
  43367. case 14:
  43368. if (stack.length >= 4) {
  43369. var achar = stack.pop();
  43370. var bchar = stack.pop();
  43371. y = stack.pop();
  43372. x = stack.pop();
  43373. cmds.push({ cmd: 'save' });
  43374. cmds.push({
  43375. cmd: 'translate',
  43376. args: [
  43377. x,
  43378. y
  43379. ]
  43380. });
  43381. var cmap = lookupCmap(font.cmap, String.fromCharCode(font.glyphNameMap[StandardEncoding[achar]]));
  43382. compileCharString(font.glyphs[cmap.glyphId], cmds, font);
  43383. cmds.push({ cmd: 'restore' });
  43384. cmap = lookupCmap(font.cmap, String.fromCharCode(font.glyphNameMap[StandardEncoding[bchar]]));
  43385. compileCharString(font.glyphs[cmap.glyphId], cmds, font);
  43386. }
  43387. return;
  43388. case 18:
  43389. stems += stack.length >> 1;
  43390. stackClean = true;
  43391. break;
  43392. case 19:
  43393. stems += stack.length >> 1;
  43394. i += stems + 7 >> 3;
  43395. stackClean = true;
  43396. break;
  43397. case 20:
  43398. stems += stack.length >> 1;
  43399. i += stems + 7 >> 3;
  43400. stackClean = true;
  43401. break;
  43402. case 21:
  43403. y += stack.pop();
  43404. x += stack.pop();
  43405. moveTo(x, y);
  43406. stackClean = true;
  43407. break;
  43408. case 22:
  43409. x += stack.pop();
  43410. moveTo(x, y);
  43411. stackClean = true;
  43412. break;
  43413. case 23:
  43414. stems += stack.length >> 1;
  43415. stackClean = true;
  43416. break;
  43417. case 24:
  43418. while (stack.length > 2) {
  43419. xa = x + stack.shift();
  43420. ya = y + stack.shift();
  43421. xb = xa + stack.shift();
  43422. yb = ya + stack.shift();
  43423. x = xb + stack.shift();
  43424. y = yb + stack.shift();
  43425. bezierCurveTo(xa, ya, xb, yb, x, y);
  43426. }
  43427. x += stack.shift();
  43428. y += stack.shift();
  43429. lineTo(x, y);
  43430. break;
  43431. case 25:
  43432. while (stack.length > 6) {
  43433. x += stack.shift();
  43434. y += stack.shift();
  43435. lineTo(x, y);
  43436. }
  43437. xa = x + stack.shift();
  43438. ya = y + stack.shift();
  43439. xb = xa + stack.shift();
  43440. yb = ya + stack.shift();
  43441. x = xb + stack.shift();
  43442. y = yb + stack.shift();
  43443. bezierCurveTo(xa, ya, xb, yb, x, y);
  43444. break;
  43445. case 26:
  43446. if (stack.length % 2) {
  43447. x += stack.shift();
  43448. }
  43449. while (stack.length > 0) {
  43450. xa = x;
  43451. ya = y + stack.shift();
  43452. xb = xa + stack.shift();
  43453. yb = ya + stack.shift();
  43454. x = xb;
  43455. y = yb + stack.shift();
  43456. bezierCurveTo(xa, ya, xb, yb, x, y);
  43457. }
  43458. break;
  43459. case 27:
  43460. if (stack.length % 2) {
  43461. y += stack.shift();
  43462. }
  43463. while (stack.length > 0) {
  43464. xa = x + stack.shift();
  43465. ya = y;
  43466. xb = xa + stack.shift();
  43467. yb = ya + stack.shift();
  43468. x = xb + stack.shift();
  43469. y = yb;
  43470. bezierCurveTo(xa, ya, xb, yb, x, y);
  43471. }
  43472. break;
  43473. case 28:
  43474. stack.push((code[i] << 24 | code[i + 1] << 16) >> 16);
  43475. i += 2;
  43476. break;
  43477. case 29:
  43478. n = stack.pop() + font.gsubrsBias;
  43479. subrCode = font.gsubrs[n];
  43480. if (subrCode) {
  43481. parse(subrCode);
  43482. }
  43483. break;
  43484. case 30:
  43485. while (stack.length > 0) {
  43486. xa = x;
  43487. ya = y + stack.shift();
  43488. xb = xa + stack.shift();
  43489. yb = ya + stack.shift();
  43490. x = xb + stack.shift();
  43491. y = yb + (stack.length === 1 ? stack.shift() : 0);
  43492. bezierCurveTo(xa, ya, xb, yb, x, y);
  43493. if (stack.length === 0) {
  43494. break;
  43495. }
  43496. xa = x + stack.shift();
  43497. ya = y;
  43498. xb = xa + stack.shift();
  43499. yb = ya + stack.shift();
  43500. y = yb + stack.shift();
  43501. x = xb + (stack.length === 1 ? stack.shift() : 0);
  43502. bezierCurveTo(xa, ya, xb, yb, x, y);
  43503. }
  43504. break;
  43505. case 31:
  43506. while (stack.length > 0) {
  43507. xa = x + stack.shift();
  43508. ya = y;
  43509. xb = xa + stack.shift();
  43510. yb = ya + stack.shift();
  43511. y = yb + stack.shift();
  43512. x = xb + (stack.length === 1 ? stack.shift() : 0);
  43513. bezierCurveTo(xa, ya, xb, yb, x, y);
  43514. if (stack.length === 0) {
  43515. break;
  43516. }
  43517. xa = x;
  43518. ya = y + stack.shift();
  43519. xb = xa + stack.shift();
  43520. yb = ya + stack.shift();
  43521. x = xb + stack.shift();
  43522. y = yb + (stack.length === 1 ? stack.shift() : 0);
  43523. bezierCurveTo(xa, ya, xb, yb, x, y);
  43524. }
  43525. break;
  43526. default:
  43527. if (v < 32) {
  43528. error('unknown operator: ' + v);
  43529. }
  43530. if (v < 247) {
  43531. stack.push(v - 139);
  43532. } else if (v < 251) {
  43533. stack.push((v - 247) * 256 + code[i++] + 108);
  43534. } else if (v < 255) {
  43535. stack.push(-(v - 251) * 256 - code[i++] - 108);
  43536. } else {
  43537. stack.push((code[i] << 24 | code[i + 1] << 16 | code[i + 2] << 8 | code[i + 3]) / 65536);
  43538. i += 4;
  43539. }
  43540. break;
  43541. }
  43542. if (stackClean) {
  43543. stack.length = 0;
  43544. }
  43545. }
  43546. }
  43547. parse(code);
  43548. }
  43549. var noop = '';
  43550. function CompiledFont(fontMatrix) {
  43551. this.compiledGlyphs = Object.create(null);
  43552. this.compiledCharCodeToGlyphId = Object.create(null);
  43553. this.fontMatrix = fontMatrix;
  43554. }
  43555. CompiledFont.prototype = {
  43556. getPathJs: function (unicode) {
  43557. var cmap = lookupCmap(this.cmap, unicode);
  43558. var fn = this.compiledGlyphs[cmap.glyphId];
  43559. if (!fn) {
  43560. fn = this.compileGlyph(this.glyphs[cmap.glyphId]);
  43561. this.compiledGlyphs[cmap.glyphId] = fn;
  43562. }
  43563. if (this.compiledCharCodeToGlyphId[cmap.charCode] === undefined) {
  43564. this.compiledCharCodeToGlyphId[cmap.charCode] = cmap.glyphId;
  43565. }
  43566. return fn;
  43567. },
  43568. compileGlyph: function (code) {
  43569. if (!code || code.length === 0 || code[0] === 14) {
  43570. return noop;
  43571. }
  43572. var cmds = [];
  43573. cmds.push({ cmd: 'save' });
  43574. cmds.push({
  43575. cmd: 'transform',
  43576. args: this.fontMatrix.slice()
  43577. });
  43578. cmds.push({
  43579. cmd: 'scale',
  43580. args: [
  43581. 'size',
  43582. '-size'
  43583. ]
  43584. });
  43585. this.compileGlyphImpl(code, cmds);
  43586. cmds.push({ cmd: 'restore' });
  43587. return cmds;
  43588. },
  43589. compileGlyphImpl: function () {
  43590. error('Children classes should implement this.');
  43591. },
  43592. hasBuiltPath: function (unicode) {
  43593. var cmap = lookupCmap(this.cmap, unicode);
  43594. return this.compiledGlyphs[cmap.glyphId] !== undefined && this.compiledCharCodeToGlyphId[cmap.charCode] !== undefined;
  43595. }
  43596. };
  43597. function TrueTypeCompiled(glyphs, cmap, fontMatrix) {
  43598. fontMatrix = fontMatrix || [
  43599. 0.000488,
  43600. 0,
  43601. 0,
  43602. 0.000488,
  43603. 0,
  43604. 0
  43605. ];
  43606. CompiledFont.call(this, fontMatrix);
  43607. this.glyphs = glyphs;
  43608. this.cmap = cmap;
  43609. }
  43610. Util.inherit(TrueTypeCompiled, CompiledFont, {
  43611. compileGlyphImpl: function (code, cmds) {
  43612. compileGlyf(code, cmds, this);
  43613. }
  43614. });
  43615. function Type2Compiled(cffInfo, cmap, fontMatrix, glyphNameMap) {
  43616. fontMatrix = fontMatrix || [
  43617. 0.001,
  43618. 0,
  43619. 0,
  43620. 0.001,
  43621. 0,
  43622. 0
  43623. ];
  43624. CompiledFont.call(this, fontMatrix);
  43625. this.glyphs = cffInfo.glyphs;
  43626. this.gsubrs = cffInfo.gsubrs || [];
  43627. this.subrs = cffInfo.subrs || [];
  43628. this.cmap = cmap;
  43629. this.glyphNameMap = glyphNameMap || getGlyphsUnicode();
  43630. this.gsubrsBias = this.gsubrs.length < 1240 ? 107 : this.gsubrs.length < 33900 ? 1131 : 32768;
  43631. this.subrsBias = this.subrs.length < 1240 ? 107 : this.subrs.length < 33900 ? 1131 : 32768;
  43632. }
  43633. Util.inherit(Type2Compiled, CompiledFont, {
  43634. compileGlyphImpl: function (code, cmds) {
  43635. compileCharString(code, cmds, this);
  43636. }
  43637. });
  43638. return {
  43639. create: function FontRendererFactory_create(font, seacAnalysisEnabled) {
  43640. var data = new Uint8Array(font.data);
  43641. var cmap, glyf, loca, cff, indexToLocFormat, unitsPerEm;
  43642. var numTables = getUshort(data, 4);
  43643. for (var i = 0, p = 12; i < numTables; i++, p += 16) {
  43644. var tag = bytesToString(data.subarray(p, p + 4));
  43645. var offset = getLong(data, p + 8);
  43646. var length = getLong(data, p + 12);
  43647. switch (tag) {
  43648. case 'cmap':
  43649. cmap = parseCmap(data, offset, offset + length);
  43650. break;
  43651. case 'glyf':
  43652. glyf = data.subarray(offset, offset + length);
  43653. break;
  43654. case 'loca':
  43655. loca = data.subarray(offset, offset + length);
  43656. break;
  43657. case 'head':
  43658. unitsPerEm = getUshort(data, offset + 18);
  43659. indexToLocFormat = getUshort(data, offset + 50);
  43660. break;
  43661. case 'CFF ':
  43662. cff = parseCff(data, offset, offset + length, seacAnalysisEnabled);
  43663. break;
  43664. }
  43665. }
  43666. if (glyf) {
  43667. var fontMatrix = !unitsPerEm ? font.fontMatrix : [
  43668. 1 / unitsPerEm,
  43669. 0,
  43670. 0,
  43671. 1 / unitsPerEm,
  43672. 0,
  43673. 0
  43674. ];
  43675. return new TrueTypeCompiled(parseGlyfTable(glyf, loca, indexToLocFormat), cmap, fontMatrix);
  43676. }
  43677. return new Type2Compiled(cff, cmap, font.fontMatrix, font.glyphNameMap);
  43678. }
  43679. };
  43680. }();
  43681. exports.FontRendererFactory = FontRendererFactory;
  43682. /***/ }),
  43683. /* 33 */
  43684. /***/ (function(module, exports, __w_pdfjs_require__) {
  43685. "use strict";
  43686. var sharedUtil = __w_pdfjs_require__(0);
  43687. var corePrimitives = __w_pdfjs_require__(1);
  43688. var coreStream = __w_pdfjs_require__(2);
  43689. var coreGlyphList = __w_pdfjs_require__(8);
  43690. var coreFontRenderer = __w_pdfjs_require__(32);
  43691. var coreEncodings = __w_pdfjs_require__(5);
  43692. var coreStandardFonts = __w_pdfjs_require__(20);
  43693. var coreUnicode = __w_pdfjs_require__(21);
  43694. var coreType1Parser = __w_pdfjs_require__(43);
  43695. var coreCFFParser = __w_pdfjs_require__(14);
  43696. var FONT_IDENTITY_MATRIX = sharedUtil.FONT_IDENTITY_MATRIX;
  43697. var FontType = sharedUtil.FontType;
  43698. var assert = sharedUtil.assert;
  43699. var bytesToString = sharedUtil.bytesToString;
  43700. var error = sharedUtil.error;
  43701. var info = sharedUtil.info;
  43702. var isArray = sharedUtil.isArray;
  43703. var isInt = sharedUtil.isInt;
  43704. var isNum = sharedUtil.isNum;
  43705. var readUint32 = sharedUtil.readUint32;
  43706. var shadow = sharedUtil.shadow;
  43707. var string32 = sharedUtil.string32;
  43708. var warn = sharedUtil.warn;
  43709. var MissingDataException = sharedUtil.MissingDataException;
  43710. var isSpace = sharedUtil.isSpace;
  43711. var Stream = coreStream.Stream;
  43712. var getGlyphsUnicode = coreGlyphList.getGlyphsUnicode;
  43713. var getDingbatsGlyphsUnicode = coreGlyphList.getDingbatsGlyphsUnicode;
  43714. var FontRendererFactory = coreFontRenderer.FontRendererFactory;
  43715. var StandardEncoding = coreEncodings.StandardEncoding;
  43716. var MacRomanEncoding = coreEncodings.MacRomanEncoding;
  43717. var SymbolSetEncoding = coreEncodings.SymbolSetEncoding;
  43718. var ZapfDingbatsEncoding = coreEncodings.ZapfDingbatsEncoding;
  43719. var getEncoding = coreEncodings.getEncoding;
  43720. var getStdFontMap = coreStandardFonts.getStdFontMap;
  43721. var getNonStdFontMap = coreStandardFonts.getNonStdFontMap;
  43722. var getGlyphMapForStandardFonts = coreStandardFonts.getGlyphMapForStandardFonts;
  43723. var getSupplementalGlyphMapForArialBlack = coreStandardFonts.getSupplementalGlyphMapForArialBlack;
  43724. var getUnicodeRangeFor = coreUnicode.getUnicodeRangeFor;
  43725. var mapSpecialUnicodeValues = coreUnicode.mapSpecialUnicodeValues;
  43726. var getUnicodeForGlyph = coreUnicode.getUnicodeForGlyph;
  43727. var Type1Parser = coreType1Parser.Type1Parser;
  43728. var CFFStandardStrings = coreCFFParser.CFFStandardStrings;
  43729. var CFFParser = coreCFFParser.CFFParser;
  43730. var CFFCompiler = coreCFFParser.CFFCompiler;
  43731. var CFF = coreCFFParser.CFF;
  43732. var CFFHeader = coreCFFParser.CFFHeader;
  43733. var CFFTopDict = coreCFFParser.CFFTopDict;
  43734. var CFFPrivateDict = coreCFFParser.CFFPrivateDict;
  43735. var CFFStrings = coreCFFParser.CFFStrings;
  43736. var CFFIndex = coreCFFParser.CFFIndex;
  43737. var CFFCharset = coreCFFParser.CFFCharset;
  43738. var PRIVATE_USE_OFFSET_START = 0xE000;
  43739. var PRIVATE_USE_OFFSET_END = 0xF8FF;
  43740. var SKIP_PRIVATE_USE_RANGE_F000_TO_F01F = false;
  43741. var PDF_GLYPH_SPACE_UNITS = 1000;
  43742. var SEAC_ANALYSIS_ENABLED = false;
  43743. var FontFlags = {
  43744. FixedPitch: 1,
  43745. Serif: 2,
  43746. Symbolic: 4,
  43747. Script: 8,
  43748. Nonsymbolic: 32,
  43749. Italic: 64,
  43750. AllCap: 65536,
  43751. SmallCap: 131072,
  43752. ForceBold: 262144
  43753. };
  43754. var MacStandardGlyphOrdering = [
  43755. '.notdef',
  43756. '.null',
  43757. 'nonmarkingreturn',
  43758. 'space',
  43759. 'exclam',
  43760. 'quotedbl',
  43761. 'numbersign',
  43762. 'dollar',
  43763. 'percent',
  43764. 'ampersand',
  43765. 'quotesingle',
  43766. 'parenleft',
  43767. 'parenright',
  43768. 'asterisk',
  43769. 'plus',
  43770. 'comma',
  43771. 'hyphen',
  43772. 'period',
  43773. 'slash',
  43774. 'zero',
  43775. 'one',
  43776. 'two',
  43777. 'three',
  43778. 'four',
  43779. 'five',
  43780. 'six',
  43781. 'seven',
  43782. 'eight',
  43783. 'nine',
  43784. 'colon',
  43785. 'semicolon',
  43786. 'less',
  43787. 'equal',
  43788. 'greater',
  43789. 'question',
  43790. 'at',
  43791. 'A',
  43792. 'B',
  43793. 'C',
  43794. 'D',
  43795. 'E',
  43796. 'F',
  43797. 'G',
  43798. 'H',
  43799. 'I',
  43800. 'J',
  43801. 'K',
  43802. 'L',
  43803. 'M',
  43804. 'N',
  43805. 'O',
  43806. 'P',
  43807. 'Q',
  43808. 'R',
  43809. 'S',
  43810. 'T',
  43811. 'U',
  43812. 'V',
  43813. 'W',
  43814. 'X',
  43815. 'Y',
  43816. 'Z',
  43817. 'bracketleft',
  43818. 'backslash',
  43819. 'bracketright',
  43820. 'asciicircum',
  43821. 'underscore',
  43822. 'grave',
  43823. 'a',
  43824. 'b',
  43825. 'c',
  43826. 'd',
  43827. 'e',
  43828. 'f',
  43829. 'g',
  43830. 'h',
  43831. 'i',
  43832. 'j',
  43833. 'k',
  43834. 'l',
  43835. 'm',
  43836. 'n',
  43837. 'o',
  43838. 'p',
  43839. 'q',
  43840. 'r',
  43841. 's',
  43842. 't',
  43843. 'u',
  43844. 'v',
  43845. 'w',
  43846. 'x',
  43847. 'y',
  43848. 'z',
  43849. 'braceleft',
  43850. 'bar',
  43851. 'braceright',
  43852. 'asciitilde',
  43853. 'Adieresis',
  43854. 'Aring',
  43855. 'Ccedilla',
  43856. 'Eacute',
  43857. 'Ntilde',
  43858. 'Odieresis',
  43859. 'Udieresis',
  43860. 'aacute',
  43861. 'agrave',
  43862. 'acircumflex',
  43863. 'adieresis',
  43864. 'atilde',
  43865. 'aring',
  43866. 'ccedilla',
  43867. 'eacute',
  43868. 'egrave',
  43869. 'ecircumflex',
  43870. 'edieresis',
  43871. 'iacute',
  43872. 'igrave',
  43873. 'icircumflex',
  43874. 'idieresis',
  43875. 'ntilde',
  43876. 'oacute',
  43877. 'ograve',
  43878. 'ocircumflex',
  43879. 'odieresis',
  43880. 'otilde',
  43881. 'uacute',
  43882. 'ugrave',
  43883. 'ucircumflex',
  43884. 'udieresis',
  43885. 'dagger',
  43886. 'degree',
  43887. 'cent',
  43888. 'sterling',
  43889. 'section',
  43890. 'bullet',
  43891. 'paragraph',
  43892. 'germandbls',
  43893. 'registered',
  43894. 'copyright',
  43895. 'trademark',
  43896. 'acute',
  43897. 'dieresis',
  43898. 'notequal',
  43899. 'AE',
  43900. 'Oslash',
  43901. 'infinity',
  43902. 'plusminus',
  43903. 'lessequal',
  43904. 'greaterequal',
  43905. 'yen',
  43906. 'mu',
  43907. 'partialdiff',
  43908. 'summation',
  43909. 'product',
  43910. 'pi',
  43911. 'integral',
  43912. 'ordfeminine',
  43913. 'ordmasculine',
  43914. 'Omega',
  43915. 'ae',
  43916. 'oslash',
  43917. 'questiondown',
  43918. 'exclamdown',
  43919. 'logicalnot',
  43920. 'radical',
  43921. 'florin',
  43922. 'approxequal',
  43923. 'Delta',
  43924. 'guillemotleft',
  43925. 'guillemotright',
  43926. 'ellipsis',
  43927. 'nonbreakingspace',
  43928. 'Agrave',
  43929. 'Atilde',
  43930. 'Otilde',
  43931. 'OE',
  43932. 'oe',
  43933. 'endash',
  43934. 'emdash',
  43935. 'quotedblleft',
  43936. 'quotedblright',
  43937. 'quoteleft',
  43938. 'quoteright',
  43939. 'divide',
  43940. 'lozenge',
  43941. 'ydieresis',
  43942. 'Ydieresis',
  43943. 'fraction',
  43944. 'currency',
  43945. 'guilsinglleft',
  43946. 'guilsinglright',
  43947. 'fi',
  43948. 'fl',
  43949. 'daggerdbl',
  43950. 'periodcentered',
  43951. 'quotesinglbase',
  43952. 'quotedblbase',
  43953. 'perthousand',
  43954. 'Acircumflex',
  43955. 'Ecircumflex',
  43956. 'Aacute',
  43957. 'Edieresis',
  43958. 'Egrave',
  43959. 'Iacute',
  43960. 'Icircumflex',
  43961. 'Idieresis',
  43962. 'Igrave',
  43963. 'Oacute',
  43964. 'Ocircumflex',
  43965. 'apple',
  43966. 'Ograve',
  43967. 'Uacute',
  43968. 'Ucircumflex',
  43969. 'Ugrave',
  43970. 'dotlessi',
  43971. 'circumflex',
  43972. 'tilde',
  43973. 'macron',
  43974. 'breve',
  43975. 'dotaccent',
  43976. 'ring',
  43977. 'cedilla',
  43978. 'hungarumlaut',
  43979. 'ogonek',
  43980. 'caron',
  43981. 'Lslash',
  43982. 'lslash',
  43983. 'Scaron',
  43984. 'scaron',
  43985. 'Zcaron',
  43986. 'zcaron',
  43987. 'brokenbar',
  43988. 'Eth',
  43989. 'eth',
  43990. 'Yacute',
  43991. 'yacute',
  43992. 'Thorn',
  43993. 'thorn',
  43994. 'minus',
  43995. 'multiply',
  43996. 'onesuperior',
  43997. 'twosuperior',
  43998. 'threesuperior',
  43999. 'onehalf',
  44000. 'onequarter',
  44001. 'threequarters',
  44002. 'franc',
  44003. 'Gbreve',
  44004. 'gbreve',
  44005. 'Idotaccent',
  44006. 'Scedilla',
  44007. 'scedilla',
  44008. 'Cacute',
  44009. 'cacute',
  44010. 'Ccaron',
  44011. 'ccaron',
  44012. 'dcroat'
  44013. ];
  44014. function adjustWidths(properties) {
  44015. if (!properties.fontMatrix) {
  44016. return;
  44017. }
  44018. if (properties.fontMatrix[0] === FONT_IDENTITY_MATRIX[0]) {
  44019. return;
  44020. }
  44021. var scale = 0.001 / properties.fontMatrix[0];
  44022. var glyphsWidths = properties.widths;
  44023. for (var glyph in glyphsWidths) {
  44024. glyphsWidths[glyph] *= scale;
  44025. }
  44026. properties.defaultWidth *= scale;
  44027. }
  44028. function adjustToUnicode(properties, builtInEncoding) {
  44029. if (properties.hasIncludedToUnicodeMap) {
  44030. return;
  44031. }
  44032. if (properties.hasEncoding) {
  44033. return;
  44034. }
  44035. if (builtInEncoding === properties.defaultEncoding) {
  44036. return;
  44037. }
  44038. if (properties.toUnicode instanceof IdentityToUnicodeMap) {
  44039. return;
  44040. }
  44041. var toUnicode = [], glyphsUnicodeMap = getGlyphsUnicode();
  44042. for (var charCode in builtInEncoding) {
  44043. var glyphName = builtInEncoding[charCode];
  44044. var unicode = getUnicodeForGlyph(glyphName, glyphsUnicodeMap);
  44045. if (unicode !== -1) {
  44046. toUnicode[charCode] = String.fromCharCode(unicode);
  44047. }
  44048. }
  44049. properties.toUnicode.amend(toUnicode);
  44050. }
  44051. function getFontType(type, subtype) {
  44052. switch (type) {
  44053. case 'Type1':
  44054. return subtype === 'Type1C' ? FontType.TYPE1C : FontType.TYPE1;
  44055. case 'CIDFontType0':
  44056. return subtype === 'CIDFontType0C' ? FontType.CIDFONTTYPE0C : FontType.CIDFONTTYPE0;
  44057. case 'OpenType':
  44058. return FontType.OPENTYPE;
  44059. case 'TrueType':
  44060. return FontType.TRUETYPE;
  44061. case 'CIDFontType2':
  44062. return FontType.CIDFONTTYPE2;
  44063. case 'MMType1':
  44064. return FontType.MMTYPE1;
  44065. case 'Type0':
  44066. return FontType.TYPE0;
  44067. default:
  44068. return FontType.UNKNOWN;
  44069. }
  44070. }
  44071. function recoverGlyphName(name, glyphsUnicodeMap) {
  44072. if (glyphsUnicodeMap[name] !== undefined) {
  44073. return name;
  44074. }
  44075. var unicode = getUnicodeForGlyph(name, glyphsUnicodeMap);
  44076. if (unicode !== -1) {
  44077. for (var key in glyphsUnicodeMap) {
  44078. if (glyphsUnicodeMap[key] === unicode) {
  44079. return key;
  44080. }
  44081. }
  44082. }
  44083. info('Unable to recover a standard glyph name for: ' + name);
  44084. return name;
  44085. }
  44086. var Glyph = function GlyphClosure() {
  44087. function Glyph(fontChar, unicode, accent, width, vmetric, operatorListId, isSpace, isInFont) {
  44088. this.fontChar = fontChar;
  44089. this.unicode = unicode;
  44090. this.accent = accent;
  44091. this.width = width;
  44092. this.vmetric = vmetric;
  44093. this.operatorListId = operatorListId;
  44094. this.isSpace = isSpace;
  44095. this.isInFont = isInFont;
  44096. }
  44097. Glyph.prototype.matchesForCache = function (fontChar, unicode, accent, width, vmetric, operatorListId, isSpace, isInFont) {
  44098. 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;
  44099. };
  44100. return Glyph;
  44101. }();
  44102. var ToUnicodeMap = function ToUnicodeMapClosure() {
  44103. function ToUnicodeMap(cmap) {
  44104. this._map = cmap;
  44105. }
  44106. ToUnicodeMap.prototype = {
  44107. get length() {
  44108. return this._map.length;
  44109. },
  44110. forEach: function (callback) {
  44111. for (var charCode in this._map) {
  44112. callback(charCode, this._map[charCode].charCodeAt(0));
  44113. }
  44114. },
  44115. has: function (i) {
  44116. return this._map[i] !== undefined;
  44117. },
  44118. get: function (i) {
  44119. return this._map[i];
  44120. },
  44121. charCodeOf: function (v) {
  44122. return this._map.indexOf(v);
  44123. },
  44124. amend: function (map) {
  44125. for (var charCode in map) {
  44126. this._map[charCode] = map[charCode];
  44127. }
  44128. }
  44129. };
  44130. return ToUnicodeMap;
  44131. }();
  44132. var IdentityToUnicodeMap = function IdentityToUnicodeMapClosure() {
  44133. function IdentityToUnicodeMap(firstChar, lastChar) {
  44134. this.firstChar = firstChar;
  44135. this.lastChar = lastChar;
  44136. }
  44137. IdentityToUnicodeMap.prototype = {
  44138. get length() {
  44139. return this.lastChar + 1 - this.firstChar;
  44140. },
  44141. forEach: function (callback) {
  44142. for (var i = this.firstChar, ii = this.lastChar; i <= ii; i++) {
  44143. callback(i, i);
  44144. }
  44145. },
  44146. has: function (i) {
  44147. return this.firstChar <= i && i <= this.lastChar;
  44148. },
  44149. get: function (i) {
  44150. if (this.firstChar <= i && i <= this.lastChar) {
  44151. return String.fromCharCode(i);
  44152. }
  44153. return undefined;
  44154. },
  44155. charCodeOf: function (v) {
  44156. return isInt(v) && v >= this.firstChar && v <= this.lastChar ? v : -1;
  44157. },
  44158. amend: function (map) {
  44159. error('Should not call amend()');
  44160. }
  44161. };
  44162. return IdentityToUnicodeMap;
  44163. }();
  44164. var OpenTypeFileBuilder = function OpenTypeFileBuilderClosure() {
  44165. function writeInt16(dest, offset, num) {
  44166. dest[offset] = num >> 8 & 0xFF;
  44167. dest[offset + 1] = num & 0xFF;
  44168. }
  44169. function writeInt32(dest, offset, num) {
  44170. dest[offset] = num >> 24 & 0xFF;
  44171. dest[offset + 1] = num >> 16 & 0xFF;
  44172. dest[offset + 2] = num >> 8 & 0xFF;
  44173. dest[offset + 3] = num & 0xFF;
  44174. }
  44175. function writeData(dest, offset, data) {
  44176. var i, ii;
  44177. if (data instanceof Uint8Array) {
  44178. dest.set(data, offset);
  44179. } else if (typeof data === 'string') {
  44180. for (i = 0, ii = data.length; i < ii; i++) {
  44181. dest[offset++] = data.charCodeAt(i) & 0xFF;
  44182. }
  44183. } else {
  44184. for (i = 0, ii = data.length; i < ii; i++) {
  44185. dest[offset++] = data[i] & 0xFF;
  44186. }
  44187. }
  44188. }
  44189. function OpenTypeFileBuilder(sfnt) {
  44190. this.sfnt = sfnt;
  44191. this.tables = Object.create(null);
  44192. }
  44193. OpenTypeFileBuilder.getSearchParams = function OpenTypeFileBuilder_getSearchParams(entriesCount, entrySize) {
  44194. var maxPower2 = 1, log2 = 0;
  44195. while ((maxPower2 ^ entriesCount) > maxPower2) {
  44196. maxPower2 <<= 1;
  44197. log2++;
  44198. }
  44199. var searchRange = maxPower2 * entrySize;
  44200. return {
  44201. range: searchRange,
  44202. entry: log2,
  44203. rangeShift: entrySize * entriesCount - searchRange
  44204. };
  44205. };
  44206. var OTF_HEADER_SIZE = 12;
  44207. var OTF_TABLE_ENTRY_SIZE = 16;
  44208. OpenTypeFileBuilder.prototype = {
  44209. toArray: function OpenTypeFileBuilder_toArray() {
  44210. var sfnt = this.sfnt;
  44211. var tables = this.tables;
  44212. var tablesNames = Object.keys(tables);
  44213. tablesNames.sort();
  44214. var numTables = tablesNames.length;
  44215. var i, j, jj, table, tableName;
  44216. var offset = OTF_HEADER_SIZE + numTables * OTF_TABLE_ENTRY_SIZE;
  44217. var tableOffsets = [offset];
  44218. for (i = 0; i < numTables; i++) {
  44219. table = tables[tablesNames[i]];
  44220. var paddedLength = (table.length + 3 & ~3) >>> 0;
  44221. offset += paddedLength;
  44222. tableOffsets.push(offset);
  44223. }
  44224. var file = new Uint8Array(offset);
  44225. for (i = 0; i < numTables; i++) {
  44226. table = tables[tablesNames[i]];
  44227. writeData(file, tableOffsets[i], table);
  44228. }
  44229. if (sfnt === 'true') {
  44230. sfnt = string32(0x00010000);
  44231. }
  44232. file[0] = sfnt.charCodeAt(0) & 0xFF;
  44233. file[1] = sfnt.charCodeAt(1) & 0xFF;
  44234. file[2] = sfnt.charCodeAt(2) & 0xFF;
  44235. file[3] = sfnt.charCodeAt(3) & 0xFF;
  44236. writeInt16(file, 4, numTables);
  44237. var searchParams = OpenTypeFileBuilder.getSearchParams(numTables, 16);
  44238. writeInt16(file, 6, searchParams.range);
  44239. writeInt16(file, 8, searchParams.entry);
  44240. writeInt16(file, 10, searchParams.rangeShift);
  44241. offset = OTF_HEADER_SIZE;
  44242. for (i = 0; i < numTables; i++) {
  44243. tableName = tablesNames[i];
  44244. file[offset] = tableName.charCodeAt(0) & 0xFF;
  44245. file[offset + 1] = tableName.charCodeAt(1) & 0xFF;
  44246. file[offset + 2] = tableName.charCodeAt(2) & 0xFF;
  44247. file[offset + 3] = tableName.charCodeAt(3) & 0xFF;
  44248. var checksum = 0;
  44249. for (j = tableOffsets[i], jj = tableOffsets[i + 1]; j < jj; j += 4) {
  44250. var quad = readUint32(file, j);
  44251. checksum = checksum + quad >>> 0;
  44252. }
  44253. writeInt32(file, offset + 4, checksum);
  44254. writeInt32(file, offset + 8, tableOffsets[i]);
  44255. writeInt32(file, offset + 12, tables[tableName].length);
  44256. offset += OTF_TABLE_ENTRY_SIZE;
  44257. }
  44258. return file;
  44259. },
  44260. addTable: function OpenTypeFileBuilder_addTable(tag, data) {
  44261. if (tag in this.tables) {
  44262. throw new Error('Table ' + tag + ' already exists');
  44263. }
  44264. this.tables[tag] = data;
  44265. }
  44266. };
  44267. return OpenTypeFileBuilder;
  44268. }();
  44269. var ProblematicCharRanges = new Int32Array([
  44270. 0x0000,
  44271. 0x0020,
  44272. 0x007F,
  44273. 0x00A1,
  44274. 0x00AD,
  44275. 0x00AE,
  44276. 0x0600,
  44277. 0x0780,
  44278. 0x08A0,
  44279. 0x10A0,
  44280. 0x1780,
  44281. 0x1800,
  44282. 0x1C00,
  44283. 0x1C50,
  44284. 0x2000,
  44285. 0x2010,
  44286. 0x2011,
  44287. 0x2012,
  44288. 0x2028,
  44289. 0x2030,
  44290. 0x205F,
  44291. 0x2070,
  44292. 0x25CC,
  44293. 0x25CD,
  44294. 0x3000,
  44295. 0x3001,
  44296. 0xAA60,
  44297. 0xAA80,
  44298. 0xFFF0,
  44299. 0x10000
  44300. ]);
  44301. var Font = function FontClosure() {
  44302. function Font(name, file, properties) {
  44303. var charCode, glyphName, unicode;
  44304. this.name = name;
  44305. this.loadedName = properties.loadedName;
  44306. this.isType3Font = properties.isType3Font;
  44307. this.sizes = [];
  44308. this.missingFile = false;
  44309. this.glyphCache = Object.create(null);
  44310. this.isSerifFont = !!(properties.flags & FontFlags.Serif);
  44311. this.isSymbolicFont = !!(properties.flags & FontFlags.Symbolic);
  44312. this.isMonospace = !!(properties.flags & FontFlags.FixedPitch);
  44313. var type = properties.type;
  44314. var subtype = properties.subtype;
  44315. this.type = type;
  44316. this.fallbackName = this.isMonospace ? 'monospace' : this.isSerifFont ? 'serif' : 'sans-serif';
  44317. this.differences = properties.differences;
  44318. this.widths = properties.widths;
  44319. this.defaultWidth = properties.defaultWidth;
  44320. this.composite = properties.composite;
  44321. this.wideChars = properties.wideChars;
  44322. this.cMap = properties.cMap;
  44323. this.ascent = properties.ascent / PDF_GLYPH_SPACE_UNITS;
  44324. this.descent = properties.descent / PDF_GLYPH_SPACE_UNITS;
  44325. this.fontMatrix = properties.fontMatrix;
  44326. this.bbox = properties.bbox;
  44327. this.toUnicode = properties.toUnicode;
  44328. this.toFontChar = [];
  44329. if (properties.type === 'Type3') {
  44330. for (charCode = 0; charCode < 256; charCode++) {
  44331. this.toFontChar[charCode] = this.differences[charCode] || properties.defaultEncoding[charCode];
  44332. }
  44333. this.fontType = FontType.TYPE3;
  44334. return;
  44335. }
  44336. this.cidEncoding = properties.cidEncoding;
  44337. this.vertical = properties.vertical;
  44338. if (this.vertical) {
  44339. this.vmetrics = properties.vmetrics;
  44340. this.defaultVMetrics = properties.defaultVMetrics;
  44341. }
  44342. var glyphsUnicodeMap;
  44343. if (!file || file.isEmpty) {
  44344. if (file) {
  44345. warn('Font file is empty in "' + name + '" (' + this.loadedName + ')');
  44346. }
  44347. this.missingFile = true;
  44348. var fontName = name.replace(/[,_]/g, '-');
  44349. var stdFontMap = getStdFontMap(), nonStdFontMap = getNonStdFontMap();
  44350. var isStandardFont = !!stdFontMap[fontName] || !!(nonStdFontMap[fontName] && stdFontMap[nonStdFontMap[fontName]]);
  44351. fontName = stdFontMap[fontName] || nonStdFontMap[fontName] || fontName;
  44352. this.bold = fontName.search(/bold/gi) !== -1;
  44353. this.italic = fontName.search(/oblique/gi) !== -1 || fontName.search(/italic/gi) !== -1;
  44354. this.black = name.search(/Black/g) !== -1;
  44355. this.remeasure = Object.keys(this.widths).length > 0;
  44356. if (isStandardFont && type === 'CIDFontType2' && properties.cidEncoding.indexOf('Identity-') === 0) {
  44357. var GlyphMapForStandardFonts = getGlyphMapForStandardFonts();
  44358. var map = [];
  44359. for (charCode in GlyphMapForStandardFonts) {
  44360. map[+charCode] = GlyphMapForStandardFonts[charCode];
  44361. }
  44362. if (/Arial-?Black/i.test(name)) {
  44363. var SupplementalGlyphMapForArialBlack = getSupplementalGlyphMapForArialBlack();
  44364. for (charCode in SupplementalGlyphMapForArialBlack) {
  44365. map[+charCode] = SupplementalGlyphMapForArialBlack[charCode];
  44366. }
  44367. }
  44368. var isIdentityUnicode = this.toUnicode instanceof IdentityToUnicodeMap;
  44369. if (!isIdentityUnicode) {
  44370. this.toUnicode.forEach(function (charCode, unicodeCharCode) {
  44371. map[+charCode] = unicodeCharCode;
  44372. });
  44373. }
  44374. this.toFontChar = map;
  44375. this.toUnicode = new ToUnicodeMap(map);
  44376. } else if (/Symbol/i.test(fontName)) {
  44377. this.toFontChar = buildToFontChar(SymbolSetEncoding, getGlyphsUnicode(), properties.differences);
  44378. } else if (/Dingbats/i.test(fontName)) {
  44379. if (/Wingdings/i.test(name)) {
  44380. warn('Non-embedded Wingdings font, falling back to ZapfDingbats.');
  44381. }
  44382. this.toFontChar = buildToFontChar(ZapfDingbatsEncoding, getDingbatsGlyphsUnicode(), properties.differences);
  44383. } else if (isStandardFont) {
  44384. this.toFontChar = buildToFontChar(properties.defaultEncoding, getGlyphsUnicode(), properties.differences);
  44385. } else {
  44386. glyphsUnicodeMap = getGlyphsUnicode();
  44387. this.toUnicode.forEach(function (charCode, unicodeCharCode) {
  44388. if (!this.composite) {
  44389. glyphName = properties.differences[charCode] || properties.defaultEncoding[charCode];
  44390. unicode = getUnicodeForGlyph(glyphName, glyphsUnicodeMap);
  44391. if (unicode !== -1) {
  44392. unicodeCharCode = unicode;
  44393. }
  44394. }
  44395. this.toFontChar[charCode] = unicodeCharCode;
  44396. }.bind(this));
  44397. }
  44398. this.loadedName = fontName.split('-')[0];
  44399. this.loading = false;
  44400. this.fontType = getFontType(type, subtype);
  44401. return;
  44402. }
  44403. if (subtype === 'Type1C') {
  44404. if (type !== 'Type1' && type !== 'MMType1') {
  44405. if (isTrueTypeFile(file)) {
  44406. subtype = 'TrueType';
  44407. } else {
  44408. type = 'Type1';
  44409. }
  44410. } else if (isOpenTypeFile(file)) {
  44411. type = subtype = 'OpenType';
  44412. }
  44413. }
  44414. if (subtype === 'CIDFontType0C' && type !== 'CIDFontType0') {
  44415. type = 'CIDFontType0';
  44416. }
  44417. if (subtype === 'OpenType') {
  44418. type = 'OpenType';
  44419. }
  44420. if (type === 'CIDFontType0') {
  44421. if (isType1File(file)) {
  44422. subtype = 'CIDFontType0';
  44423. } else if (isOpenTypeFile(file)) {
  44424. type = subtype = 'OpenType';
  44425. } else {
  44426. subtype = 'CIDFontType0C';
  44427. }
  44428. }
  44429. var data;
  44430. switch (type) {
  44431. case 'MMType1':
  44432. info('MMType1 font (' + name + '), falling back to Type1.');
  44433. case 'Type1':
  44434. case 'CIDFontType0':
  44435. this.mimetype = 'font/opentype';
  44436. var cff = subtype === 'Type1C' || subtype === 'CIDFontType0C' ? new CFFFont(file, properties) : new Type1Font(name, file, properties);
  44437. adjustWidths(properties);
  44438. data = this.convert(name, cff, properties);
  44439. break;
  44440. case 'OpenType':
  44441. case 'TrueType':
  44442. case 'CIDFontType2':
  44443. this.mimetype = 'font/opentype';
  44444. data = this.checkAndRepair(name, file, properties);
  44445. if (this.isOpenType) {
  44446. adjustWidths(properties);
  44447. type = 'OpenType';
  44448. }
  44449. break;
  44450. default:
  44451. error('Font ' + type + ' is not supported');
  44452. break;
  44453. }
  44454. this.data = data;
  44455. this.fontType = getFontType(type, subtype);
  44456. this.fontMatrix = properties.fontMatrix;
  44457. this.widths = properties.widths;
  44458. this.defaultWidth = properties.defaultWidth;
  44459. this.toUnicode = properties.toUnicode;
  44460. this.encoding = properties.baseEncoding;
  44461. this.seacMap = properties.seacMap;
  44462. this.loading = true;
  44463. }
  44464. Font.getFontID = function () {
  44465. var ID = 1;
  44466. return function Font_getFontID() {
  44467. return String(ID++);
  44468. };
  44469. }();
  44470. function int16(b0, b1) {
  44471. return (b0 << 8) + b1;
  44472. }
  44473. function signedInt16(b0, b1) {
  44474. var value = (b0 << 8) + b1;
  44475. return value & 1 << 15 ? value - 0x10000 : value;
  44476. }
  44477. function int32(b0, b1, b2, b3) {
  44478. return (b0 << 24) + (b1 << 16) + (b2 << 8) + b3;
  44479. }
  44480. function string16(value) {
  44481. return String.fromCharCode(value >> 8 & 0xff, value & 0xff);
  44482. }
  44483. function safeString16(value) {
  44484. value = value > 0x7FFF ? 0x7FFF : value < -0x8000 ? -0x8000 : value;
  44485. return String.fromCharCode(value >> 8 & 0xff, value & 0xff);
  44486. }
  44487. function isTrueTypeFile(file) {
  44488. var header = file.peekBytes(4);
  44489. return readUint32(header, 0) === 0x00010000;
  44490. }
  44491. function isOpenTypeFile(file) {
  44492. var header = file.peekBytes(4);
  44493. return bytesToString(header) === 'OTTO';
  44494. }
  44495. function isType1File(file) {
  44496. var header = file.peekBytes(2);
  44497. if (header[0] === 0x25 && header[1] === 0x21) {
  44498. return true;
  44499. }
  44500. if (header[0] === 0x80 && header[1] === 0x01) {
  44501. return true;
  44502. }
  44503. return false;
  44504. }
  44505. function buildToFontChar(encoding, glyphsUnicodeMap, differences) {
  44506. var toFontChar = [], unicode;
  44507. for (var i = 0, ii = encoding.length; i < ii; i++) {
  44508. unicode = getUnicodeForGlyph(encoding[i], glyphsUnicodeMap);
  44509. if (unicode !== -1) {
  44510. toFontChar[i] = unicode;
  44511. }
  44512. }
  44513. for (var charCode in differences) {
  44514. unicode = getUnicodeForGlyph(differences[charCode], glyphsUnicodeMap);
  44515. if (unicode !== -1) {
  44516. toFontChar[+charCode] = unicode;
  44517. }
  44518. }
  44519. return toFontChar;
  44520. }
  44521. function isProblematicUnicodeLocation(code) {
  44522. var i = 0, j = ProblematicCharRanges.length - 1;
  44523. while (i < j) {
  44524. var c = i + j + 1 >> 1;
  44525. if (code < ProblematicCharRanges[c]) {
  44526. j = c - 1;
  44527. } else {
  44528. i = c;
  44529. }
  44530. }
  44531. return !(i & 1);
  44532. }
  44533. function adjustMapping(charCodeToGlyphId, properties) {
  44534. var toUnicode = properties.toUnicode;
  44535. var isSymbolic = !!(properties.flags & FontFlags.Symbolic);
  44536. var isIdentityUnicode = properties.toUnicode instanceof IdentityToUnicodeMap;
  44537. var newMap = Object.create(null);
  44538. var toFontChar = [];
  44539. var usedFontCharCodes = [];
  44540. var nextAvailableFontCharCode = PRIVATE_USE_OFFSET_START;
  44541. for (var originalCharCode in charCodeToGlyphId) {
  44542. originalCharCode |= 0;
  44543. var glyphId = charCodeToGlyphId[originalCharCode];
  44544. var fontCharCode = originalCharCode;
  44545. var hasUnicodeValue = false;
  44546. if (!isIdentityUnicode && toUnicode.has(originalCharCode)) {
  44547. hasUnicodeValue = true;
  44548. var unicode = toUnicode.get(fontCharCode);
  44549. if (unicode.length === 1) {
  44550. fontCharCode = unicode.charCodeAt(0);
  44551. }
  44552. }
  44553. if ((usedFontCharCodes[fontCharCode] !== undefined || isProblematicUnicodeLocation(fontCharCode) || isSymbolic && !hasUnicodeValue) && nextAvailableFontCharCode <= PRIVATE_USE_OFFSET_END) {
  44554. do {
  44555. fontCharCode = nextAvailableFontCharCode++;
  44556. if (SKIP_PRIVATE_USE_RANGE_F000_TO_F01F && fontCharCode === 0xF000) {
  44557. fontCharCode = 0xF020;
  44558. nextAvailableFontCharCode = fontCharCode + 1;
  44559. }
  44560. } while (usedFontCharCodes[fontCharCode] !== undefined && nextAvailableFontCharCode <= PRIVATE_USE_OFFSET_END);
  44561. }
  44562. newMap[fontCharCode] = glyphId;
  44563. toFontChar[originalCharCode] = fontCharCode;
  44564. usedFontCharCodes[fontCharCode] = true;
  44565. }
  44566. return {
  44567. toFontChar: toFontChar,
  44568. charCodeToGlyphId: newMap,
  44569. nextAvailableFontCharCode: nextAvailableFontCharCode
  44570. };
  44571. }
  44572. function getRanges(glyphs, numGlyphs) {
  44573. var codes = [];
  44574. for (var charCode in glyphs) {
  44575. if (glyphs[charCode] >= numGlyphs) {
  44576. continue;
  44577. }
  44578. codes.push({
  44579. fontCharCode: charCode | 0,
  44580. glyphId: glyphs[charCode]
  44581. });
  44582. }
  44583. codes.sort(function fontGetRangesSort(a, b) {
  44584. return a.fontCharCode - b.fontCharCode;
  44585. });
  44586. var ranges = [];
  44587. var length = codes.length;
  44588. for (var n = 0; n < length;) {
  44589. var start = codes[n].fontCharCode;
  44590. var codeIndices = [codes[n].glyphId];
  44591. ++n;
  44592. var end = start;
  44593. while (n < length && end + 1 === codes[n].fontCharCode) {
  44594. codeIndices.push(codes[n].glyphId);
  44595. ++end;
  44596. ++n;
  44597. if (end === 0xFFFF) {
  44598. break;
  44599. }
  44600. }
  44601. ranges.push([
  44602. start,
  44603. end,
  44604. codeIndices
  44605. ]);
  44606. }
  44607. return ranges;
  44608. }
  44609. function createCmapTable(glyphs, numGlyphs) {
  44610. var ranges = getRanges(glyphs, numGlyphs);
  44611. var numTables = ranges[ranges.length - 1][1] > 0xFFFF ? 2 : 1;
  44612. var cmap = '\x00\x00' + string16(numTables) + '\x00\x03' + '\x00\x01' + string32(4 + numTables * 8);
  44613. var i, ii, j, jj;
  44614. for (i = ranges.length - 1; i >= 0; --i) {
  44615. if (ranges[i][0] <= 0xFFFF) {
  44616. break;
  44617. }
  44618. }
  44619. var bmpLength = i + 1;
  44620. if (ranges[i][0] < 0xFFFF && ranges[i][1] === 0xFFFF) {
  44621. ranges[i][1] = 0xFFFE;
  44622. }
  44623. var trailingRangesCount = ranges[i][1] < 0xFFFF ? 1 : 0;
  44624. var segCount = bmpLength + trailingRangesCount;
  44625. var searchParams = OpenTypeFileBuilder.getSearchParams(segCount, 2);
  44626. var startCount = '';
  44627. var endCount = '';
  44628. var idDeltas = '';
  44629. var idRangeOffsets = '';
  44630. var glyphsIds = '';
  44631. var bias = 0;
  44632. var range, start, end, codes;
  44633. for (i = 0, ii = bmpLength; i < ii; i++) {
  44634. range = ranges[i];
  44635. start = range[0];
  44636. end = range[1];
  44637. startCount += string16(start);
  44638. endCount += string16(end);
  44639. codes = range[2];
  44640. var contiguous = true;
  44641. for (j = 1, jj = codes.length; j < jj; ++j) {
  44642. if (codes[j] !== codes[j - 1] + 1) {
  44643. contiguous = false;
  44644. break;
  44645. }
  44646. }
  44647. if (!contiguous) {
  44648. var offset = (segCount - i) * 2 + bias * 2;
  44649. bias += end - start + 1;
  44650. idDeltas += string16(0);
  44651. idRangeOffsets += string16(offset);
  44652. for (j = 0, jj = codes.length; j < jj; ++j) {
  44653. glyphsIds += string16(codes[j]);
  44654. }
  44655. } else {
  44656. var startCode = codes[0];
  44657. idDeltas += string16(startCode - start & 0xFFFF);
  44658. idRangeOffsets += string16(0);
  44659. }
  44660. }
  44661. if (trailingRangesCount > 0) {
  44662. endCount += '\xFF\xFF';
  44663. startCount += '\xFF\xFF';
  44664. idDeltas += '\x00\x01';
  44665. idRangeOffsets += '\x00\x00';
  44666. }
  44667. var format314 = '\x00\x00' + string16(2 * segCount) + string16(searchParams.range) + string16(searchParams.entry) + string16(searchParams.rangeShift) + endCount + '\x00\x00' + startCount + idDeltas + idRangeOffsets + glyphsIds;
  44668. var format31012 = '';
  44669. var header31012 = '';
  44670. if (numTables > 1) {
  44671. cmap += '\x00\x03' + '\x00\x0A' + string32(4 + numTables * 8 + 4 + format314.length);
  44672. format31012 = '';
  44673. for (i = 0, ii = ranges.length; i < ii; i++) {
  44674. range = ranges[i];
  44675. start = range[0];
  44676. codes = range[2];
  44677. var code = codes[0];
  44678. for (j = 1, jj = codes.length; j < jj; ++j) {
  44679. if (codes[j] !== codes[j - 1] + 1) {
  44680. end = range[0] + j - 1;
  44681. format31012 += string32(start) + string32(end) + string32(code);
  44682. start = end + 1;
  44683. code = codes[j];
  44684. }
  44685. }
  44686. format31012 += string32(start) + string32(range[1]) + string32(code);
  44687. }
  44688. header31012 = '\x00\x0C' + '\x00\x00' + string32(format31012.length + 16) + '\x00\x00\x00\x00' + string32(format31012.length / 12);
  44689. }
  44690. return cmap + '\x00\x04' + string16(format314.length + 4) + format314 + header31012 + format31012;
  44691. }
  44692. function validateOS2Table(os2) {
  44693. var stream = new Stream(os2.data);
  44694. var version = stream.getUint16();
  44695. stream.getBytes(60);
  44696. var selection = stream.getUint16();
  44697. if (version < 4 && selection & 0x0300) {
  44698. return false;
  44699. }
  44700. var firstChar = stream.getUint16();
  44701. var lastChar = stream.getUint16();
  44702. if (firstChar > lastChar) {
  44703. return false;
  44704. }
  44705. stream.getBytes(6);
  44706. var usWinAscent = stream.getUint16();
  44707. if (usWinAscent === 0) {
  44708. return false;
  44709. }
  44710. os2.data[8] = os2.data[9] = 0;
  44711. return true;
  44712. }
  44713. function createOS2Table(properties, charstrings, override) {
  44714. override = override || {
  44715. unitsPerEm: 0,
  44716. yMax: 0,
  44717. yMin: 0,
  44718. ascent: 0,
  44719. descent: 0
  44720. };
  44721. var ulUnicodeRange1 = 0;
  44722. var ulUnicodeRange2 = 0;
  44723. var ulUnicodeRange3 = 0;
  44724. var ulUnicodeRange4 = 0;
  44725. var firstCharIndex = null;
  44726. var lastCharIndex = 0;
  44727. if (charstrings) {
  44728. for (var code in charstrings) {
  44729. code |= 0;
  44730. if (firstCharIndex > code || !firstCharIndex) {
  44731. firstCharIndex = code;
  44732. }
  44733. if (lastCharIndex < code) {
  44734. lastCharIndex = code;
  44735. }
  44736. var position = getUnicodeRangeFor(code);
  44737. if (position < 32) {
  44738. ulUnicodeRange1 |= 1 << position;
  44739. } else if (position < 64) {
  44740. ulUnicodeRange2 |= 1 << position - 32;
  44741. } else if (position < 96) {
  44742. ulUnicodeRange3 |= 1 << position - 64;
  44743. } else if (position < 123) {
  44744. ulUnicodeRange4 |= 1 << position - 96;
  44745. } else {
  44746. error('Unicode ranges Bits > 123 are reserved for internal usage');
  44747. }
  44748. }
  44749. } else {
  44750. firstCharIndex = 0;
  44751. lastCharIndex = 255;
  44752. }
  44753. var bbox = properties.bbox || [
  44754. 0,
  44755. 0,
  44756. 0,
  44757. 0
  44758. ];
  44759. var unitsPerEm = override.unitsPerEm || 1 / (properties.fontMatrix || FONT_IDENTITY_MATRIX)[0];
  44760. var scale = properties.ascentScaled ? 1.0 : unitsPerEm / PDF_GLYPH_SPACE_UNITS;
  44761. var typoAscent = override.ascent || Math.round(scale * (properties.ascent || bbox[3]));
  44762. var typoDescent = override.descent || Math.round(scale * (properties.descent || bbox[1]));
  44763. if (typoDescent > 0 && properties.descent > 0 && bbox[1] < 0) {
  44764. typoDescent = -typoDescent;
  44765. }
  44766. var winAscent = override.yMax || typoAscent;
  44767. var winDescent = -override.yMin || -typoDescent;
  44768. 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';
  44769. }
  44770. function createPostTable(properties) {
  44771. var angle = Math.floor(properties.italicAngle * Math.pow(2, 16));
  44772. 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';
  44773. }
  44774. function createNameTable(name, proto) {
  44775. if (!proto) {
  44776. proto = [
  44777. [],
  44778. []
  44779. ];
  44780. }
  44781. var strings = [
  44782. proto[0][0] || 'Original licence',
  44783. proto[0][1] || name,
  44784. proto[0][2] || 'Unknown',
  44785. proto[0][3] || 'uniqueID',
  44786. proto[0][4] || name,
  44787. proto[0][5] || 'Version 0.11',
  44788. proto[0][6] || '',
  44789. proto[0][7] || 'Unknown',
  44790. proto[0][8] || 'Unknown',
  44791. proto[0][9] || 'Unknown'
  44792. ];
  44793. var stringsUnicode = [];
  44794. var i, ii, j, jj, str;
  44795. for (i = 0, ii = strings.length; i < ii; i++) {
  44796. str = proto[1][i] || strings[i];
  44797. var strBufUnicode = [];
  44798. for (j = 0, jj = str.length; j < jj; j++) {
  44799. strBufUnicode.push(string16(str.charCodeAt(j)));
  44800. }
  44801. stringsUnicode.push(strBufUnicode.join(''));
  44802. }
  44803. var names = [
  44804. strings,
  44805. stringsUnicode
  44806. ];
  44807. var platforms = [
  44808. '\x00\x01',
  44809. '\x00\x03'
  44810. ];
  44811. var encodings = [
  44812. '\x00\x00',
  44813. '\x00\x01'
  44814. ];
  44815. var languages = [
  44816. '\x00\x00',
  44817. '\x04\x09'
  44818. ];
  44819. var namesRecordCount = strings.length * platforms.length;
  44820. var nameTable = '\x00\x00' + string16(namesRecordCount) + string16(namesRecordCount * 12 + 6);
  44821. var strOffset = 0;
  44822. for (i = 0, ii = platforms.length; i < ii; i++) {
  44823. var strs = names[i];
  44824. for (j = 0, jj = strs.length; j < jj; j++) {
  44825. str = strs[j];
  44826. var nameRecord = platforms[i] + encodings[i] + languages[i] + string16(j) + string16(str.length) + string16(strOffset);
  44827. nameTable += nameRecord;
  44828. strOffset += str.length;
  44829. }
  44830. }
  44831. nameTable += strings.join('') + stringsUnicode.join('');
  44832. return nameTable;
  44833. }
  44834. Font.prototype = {
  44835. name: null,
  44836. font: null,
  44837. mimetype: null,
  44838. encoding: null,
  44839. get renderer() {
  44840. var renderer = FontRendererFactory.create(this, SEAC_ANALYSIS_ENABLED);
  44841. return shadow(this, 'renderer', renderer);
  44842. },
  44843. exportData: function Font_exportData() {
  44844. var data = {};
  44845. for (var i in this) {
  44846. if (this.hasOwnProperty(i)) {
  44847. data[i] = this[i];
  44848. }
  44849. }
  44850. return data;
  44851. },
  44852. checkAndRepair: function Font_checkAndRepair(name, font, properties) {
  44853. function readTableEntry(file) {
  44854. var tag = bytesToString(file.getBytes(4));
  44855. var checksum = file.getInt32() >>> 0;
  44856. var offset = file.getInt32() >>> 0;
  44857. var length = file.getInt32() >>> 0;
  44858. var previousPosition = file.pos;
  44859. file.pos = file.start ? file.start : 0;
  44860. file.skip(offset);
  44861. var data = file.getBytes(length);
  44862. file.pos = previousPosition;
  44863. if (tag === 'head') {
  44864. data[8] = data[9] = data[10] = data[11] = 0;
  44865. data[17] |= 0x20;
  44866. }
  44867. return {
  44868. tag: tag,
  44869. checksum: checksum,
  44870. length: length,
  44871. offset: offset,
  44872. data: data
  44873. };
  44874. }
  44875. function readOpenTypeHeader(ttf) {
  44876. return {
  44877. version: bytesToString(ttf.getBytes(4)),
  44878. numTables: ttf.getUint16(),
  44879. searchRange: ttf.getUint16(),
  44880. entrySelector: ttf.getUint16(),
  44881. rangeShift: ttf.getUint16()
  44882. };
  44883. }
  44884. function readCmapTable(cmap, font, isSymbolicFont, hasEncoding) {
  44885. if (!cmap) {
  44886. warn('No cmap table available.');
  44887. return {
  44888. platformId: -1,
  44889. encodingId: -1,
  44890. mappings: [],
  44891. hasShortCmap: false
  44892. };
  44893. }
  44894. var segment;
  44895. var start = (font.start ? font.start : 0) + cmap.offset;
  44896. font.pos = start;
  44897. font.getUint16();
  44898. var numTables = font.getUint16();
  44899. var potentialTable;
  44900. var canBreak = false;
  44901. for (var i = 0; i < numTables; i++) {
  44902. var platformId = font.getUint16();
  44903. var encodingId = font.getUint16();
  44904. var offset = font.getInt32() >>> 0;
  44905. var useTable = false;
  44906. if (platformId === 0 && encodingId === 0) {
  44907. useTable = true;
  44908. } else if (platformId === 1 && encodingId === 0) {
  44909. useTable = true;
  44910. } else if (platformId === 3 && encodingId === 1 && (hasEncoding || !potentialTable)) {
  44911. useTable = true;
  44912. if (!isSymbolicFont) {
  44913. canBreak = true;
  44914. }
  44915. } else if (isSymbolicFont && platformId === 3 && encodingId === 0) {
  44916. useTable = true;
  44917. canBreak = true;
  44918. }
  44919. if (useTable) {
  44920. potentialTable = {
  44921. platformId: platformId,
  44922. encodingId: encodingId,
  44923. offset: offset
  44924. };
  44925. }
  44926. if (canBreak) {
  44927. break;
  44928. }
  44929. }
  44930. if (potentialTable) {
  44931. font.pos = start + potentialTable.offset;
  44932. }
  44933. if (!potentialTable || font.peekByte() === -1) {
  44934. warn('Could not find a preferred cmap table.');
  44935. return {
  44936. platformId: -1,
  44937. encodingId: -1,
  44938. mappings: [],
  44939. hasShortCmap: false
  44940. };
  44941. }
  44942. var format = font.getUint16();
  44943. font.getUint16();
  44944. font.getUint16();
  44945. var hasShortCmap = false;
  44946. var mappings = [];
  44947. var j, glyphId;
  44948. if (format === 0) {
  44949. for (j = 0; j < 256; j++) {
  44950. var index = font.getByte();
  44951. if (!index) {
  44952. continue;
  44953. }
  44954. mappings.push({
  44955. charCode: j,
  44956. glyphId: index
  44957. });
  44958. }
  44959. hasShortCmap = true;
  44960. } else if (format === 4) {
  44961. var segCount = font.getUint16() >> 1;
  44962. font.getBytes(6);
  44963. var segIndex, segments = [];
  44964. for (segIndex = 0; segIndex < segCount; segIndex++) {
  44965. segments.push({ end: font.getUint16() });
  44966. }
  44967. font.getUint16();
  44968. for (segIndex = 0; segIndex < segCount; segIndex++) {
  44969. segments[segIndex].start = font.getUint16();
  44970. }
  44971. for (segIndex = 0; segIndex < segCount; segIndex++) {
  44972. segments[segIndex].delta = font.getUint16();
  44973. }
  44974. var offsetsCount = 0;
  44975. for (segIndex = 0; segIndex < segCount; segIndex++) {
  44976. segment = segments[segIndex];
  44977. var rangeOffset = font.getUint16();
  44978. if (!rangeOffset) {
  44979. segment.offsetIndex = -1;
  44980. continue;
  44981. }
  44982. var offsetIndex = (rangeOffset >> 1) - (segCount - segIndex);
  44983. segment.offsetIndex = offsetIndex;
  44984. offsetsCount = Math.max(offsetsCount, offsetIndex + segment.end - segment.start + 1);
  44985. }
  44986. var offsets = [];
  44987. for (j = 0; j < offsetsCount; j++) {
  44988. offsets.push(font.getUint16());
  44989. }
  44990. for (segIndex = 0; segIndex < segCount; segIndex++) {
  44991. segment = segments[segIndex];
  44992. start = segment.start;
  44993. var end = segment.end;
  44994. var delta = segment.delta;
  44995. offsetIndex = segment.offsetIndex;
  44996. for (j = start; j <= end; j++) {
  44997. if (j === 0xFFFF) {
  44998. continue;
  44999. }
  45000. glyphId = offsetIndex < 0 ? j : offsets[offsetIndex + j - start];
  45001. glyphId = glyphId + delta & 0xFFFF;
  45002. if (glyphId === 0) {
  45003. continue;
  45004. }
  45005. mappings.push({
  45006. charCode: j,
  45007. glyphId: glyphId
  45008. });
  45009. }
  45010. }
  45011. } else if (format === 6) {
  45012. var firstCode = font.getUint16();
  45013. var entryCount = font.getUint16();
  45014. for (j = 0; j < entryCount; j++) {
  45015. glyphId = font.getUint16();
  45016. var charCode = firstCode + j;
  45017. mappings.push({
  45018. charCode: charCode,
  45019. glyphId: glyphId
  45020. });
  45021. }
  45022. } else {
  45023. warn('cmap table has unsupported format: ' + format);
  45024. return {
  45025. platformId: -1,
  45026. encodingId: -1,
  45027. mappings: [],
  45028. hasShortCmap: false
  45029. };
  45030. }
  45031. mappings.sort(function (a, b) {
  45032. return a.charCode - b.charCode;
  45033. });
  45034. for (i = 1; i < mappings.length; i++) {
  45035. if (mappings[i - 1].charCode === mappings[i].charCode) {
  45036. mappings.splice(i, 1);
  45037. i--;
  45038. }
  45039. }
  45040. return {
  45041. platformId: potentialTable.platformId,
  45042. encodingId: potentialTable.encodingId,
  45043. mappings: mappings,
  45044. hasShortCmap: hasShortCmap
  45045. };
  45046. }
  45047. function sanitizeMetrics(font, header, metrics, numGlyphs) {
  45048. if (!header) {
  45049. if (metrics) {
  45050. metrics.data = null;
  45051. }
  45052. return;
  45053. }
  45054. font.pos = (font.start ? font.start : 0) + header.offset;
  45055. font.pos += header.length - 2;
  45056. var numOfMetrics = font.getUint16();
  45057. if (numOfMetrics > numGlyphs) {
  45058. info('The numOfMetrics (' + numOfMetrics + ') should not be ' + 'greater than the numGlyphs (' + numGlyphs + ')');
  45059. numOfMetrics = numGlyphs;
  45060. header.data[34] = (numOfMetrics & 0xff00) >> 8;
  45061. header.data[35] = numOfMetrics & 0x00ff;
  45062. }
  45063. var numOfSidebearings = numGlyphs - numOfMetrics;
  45064. var numMissing = numOfSidebearings - (metrics.length - numOfMetrics * 4 >> 1);
  45065. if (numMissing > 0) {
  45066. var entries = new Uint8Array(metrics.length + numMissing * 2);
  45067. entries.set(metrics.data);
  45068. metrics.data = entries;
  45069. }
  45070. }
  45071. function sanitizeGlyph(source, sourceStart, sourceEnd, dest, destStart, hintsValid) {
  45072. if (sourceEnd - sourceStart <= 12) {
  45073. return 0;
  45074. }
  45075. var glyf = source.subarray(sourceStart, sourceEnd);
  45076. var contoursCount = glyf[0] << 8 | glyf[1];
  45077. if (contoursCount & 0x8000) {
  45078. dest.set(glyf, destStart);
  45079. return glyf.length;
  45080. }
  45081. var i, j = 10, flagsCount = 0;
  45082. for (i = 0; i < contoursCount; i++) {
  45083. var endPoint = glyf[j] << 8 | glyf[j + 1];
  45084. flagsCount = endPoint + 1;
  45085. j += 2;
  45086. }
  45087. var instructionsStart = j;
  45088. var instructionsLength = glyf[j] << 8 | glyf[j + 1];
  45089. j += 2 + instructionsLength;
  45090. var instructionsEnd = j;
  45091. var coordinatesLength = 0;
  45092. for (i = 0; i < flagsCount; i++) {
  45093. var flag = glyf[j++];
  45094. if (flag & 0xC0) {
  45095. glyf[j - 1] = flag & 0x3F;
  45096. }
  45097. var xyLength = (flag & 2 ? 1 : flag & 16 ? 0 : 2) + (flag & 4 ? 1 : flag & 32 ? 0 : 2);
  45098. coordinatesLength += xyLength;
  45099. if (flag & 8) {
  45100. var repeat = glyf[j++];
  45101. i += repeat;
  45102. coordinatesLength += repeat * xyLength;
  45103. }
  45104. }
  45105. if (coordinatesLength === 0) {
  45106. return 0;
  45107. }
  45108. var glyphDataLength = j + coordinatesLength;
  45109. if (glyphDataLength > glyf.length) {
  45110. return 0;
  45111. }
  45112. if (!hintsValid && instructionsLength > 0) {
  45113. dest.set(glyf.subarray(0, instructionsStart), destStart);
  45114. dest.set([
  45115. 0,
  45116. 0
  45117. ], destStart + instructionsStart);
  45118. dest.set(glyf.subarray(instructionsEnd, glyphDataLength), destStart + instructionsStart + 2);
  45119. glyphDataLength -= instructionsLength;
  45120. if (glyf.length - glyphDataLength > 3) {
  45121. glyphDataLength = glyphDataLength + 3 & ~3;
  45122. }
  45123. return glyphDataLength;
  45124. }
  45125. if (glyf.length - glyphDataLength > 3) {
  45126. glyphDataLength = glyphDataLength + 3 & ~3;
  45127. dest.set(glyf.subarray(0, glyphDataLength), destStart);
  45128. return glyphDataLength;
  45129. }
  45130. dest.set(glyf, destStart);
  45131. return glyf.length;
  45132. }
  45133. function sanitizeHead(head, numGlyphs, locaLength) {
  45134. var data = head.data;
  45135. var version = int32(data[0], data[1], data[2], data[3]);
  45136. if (version >> 16 !== 1) {
  45137. info('Attempting to fix invalid version in head table: ' + version);
  45138. data[0] = 0;
  45139. data[1] = 1;
  45140. data[2] = 0;
  45141. data[3] = 0;
  45142. }
  45143. var indexToLocFormat = int16(data[50], data[51]);
  45144. if (indexToLocFormat < 0 || indexToLocFormat > 1) {
  45145. info('Attempting to fix invalid indexToLocFormat in head table: ' + indexToLocFormat);
  45146. var numGlyphsPlusOne = numGlyphs + 1;
  45147. if (locaLength === numGlyphsPlusOne << 1) {
  45148. data[50] = 0;
  45149. data[51] = 0;
  45150. } else if (locaLength === numGlyphsPlusOne << 2) {
  45151. data[50] = 0;
  45152. data[51] = 1;
  45153. } else {
  45154. warn('Could not fix indexToLocFormat: ' + indexToLocFormat);
  45155. }
  45156. }
  45157. }
  45158. function sanitizeGlyphLocations(loca, glyf, numGlyphs, isGlyphLocationsLong, hintsValid, dupFirstEntry) {
  45159. var itemSize, itemDecode, itemEncode;
  45160. if (isGlyphLocationsLong) {
  45161. itemSize = 4;
  45162. itemDecode = function fontItemDecodeLong(data, offset) {
  45163. return data[offset] << 24 | data[offset + 1] << 16 | data[offset + 2] << 8 | data[offset + 3];
  45164. };
  45165. itemEncode = function fontItemEncodeLong(data, offset, value) {
  45166. data[offset] = value >>> 24 & 0xFF;
  45167. data[offset + 1] = value >> 16 & 0xFF;
  45168. data[offset + 2] = value >> 8 & 0xFF;
  45169. data[offset + 3] = value & 0xFF;
  45170. };
  45171. } else {
  45172. itemSize = 2;
  45173. itemDecode = function fontItemDecode(data, offset) {
  45174. return data[offset] << 9 | data[offset + 1] << 1;
  45175. };
  45176. itemEncode = function fontItemEncode(data, offset, value) {
  45177. data[offset] = value >> 9 & 0xFF;
  45178. data[offset + 1] = value >> 1 & 0xFF;
  45179. };
  45180. }
  45181. var locaData = loca.data;
  45182. var locaDataSize = itemSize * (1 + numGlyphs);
  45183. if (locaData.length !== locaDataSize) {
  45184. locaData = new Uint8Array(locaDataSize);
  45185. locaData.set(loca.data.subarray(0, locaDataSize));
  45186. loca.data = locaData;
  45187. }
  45188. var oldGlyfData = glyf.data;
  45189. var oldGlyfDataLength = oldGlyfData.length;
  45190. var newGlyfData = new Uint8Array(oldGlyfDataLength);
  45191. var startOffset = itemDecode(locaData, 0);
  45192. var writeOffset = 0;
  45193. var missingGlyphData = Object.create(null);
  45194. itemEncode(locaData, 0, writeOffset);
  45195. var i, j;
  45196. for (i = 0, j = itemSize; i < numGlyphs; i++, j += itemSize) {
  45197. var endOffset = itemDecode(locaData, j);
  45198. if (endOffset > oldGlyfDataLength && (oldGlyfDataLength + 3 & ~3) === endOffset) {
  45199. endOffset = oldGlyfDataLength;
  45200. }
  45201. if (endOffset > oldGlyfDataLength) {
  45202. itemEncode(locaData, j, writeOffset);
  45203. startOffset = endOffset;
  45204. continue;
  45205. }
  45206. if (startOffset === endOffset) {
  45207. missingGlyphData[i] = true;
  45208. }
  45209. var newLength = sanitizeGlyph(oldGlyfData, startOffset, endOffset, newGlyfData, writeOffset, hintsValid);
  45210. writeOffset += newLength;
  45211. itemEncode(locaData, j, writeOffset);
  45212. startOffset = endOffset;
  45213. }
  45214. if (writeOffset === 0) {
  45215. var simpleGlyph = new Uint8Array([
  45216. 0,
  45217. 1,
  45218. 0,
  45219. 0,
  45220. 0,
  45221. 0,
  45222. 0,
  45223. 0,
  45224. 0,
  45225. 0,
  45226. 0,
  45227. 0,
  45228. 0,
  45229. 0,
  45230. 49,
  45231. 0
  45232. ]);
  45233. for (i = 0, j = itemSize; i < numGlyphs; i++, j += itemSize) {
  45234. itemEncode(locaData, j, simpleGlyph.length);
  45235. }
  45236. glyf.data = simpleGlyph;
  45237. return missingGlyphData;
  45238. }
  45239. if (dupFirstEntry) {
  45240. var firstEntryLength = itemDecode(locaData, itemSize);
  45241. if (newGlyfData.length > firstEntryLength + writeOffset) {
  45242. glyf.data = newGlyfData.subarray(0, firstEntryLength + writeOffset);
  45243. } else {
  45244. glyf.data = new Uint8Array(firstEntryLength + writeOffset);
  45245. glyf.data.set(newGlyfData.subarray(0, writeOffset));
  45246. }
  45247. glyf.data.set(newGlyfData.subarray(0, firstEntryLength), writeOffset);
  45248. itemEncode(loca.data, locaData.length - itemSize, writeOffset + firstEntryLength);
  45249. } else {
  45250. glyf.data = newGlyfData.subarray(0, writeOffset);
  45251. }
  45252. return missingGlyphData;
  45253. }
  45254. function readPostScriptTable(post, properties, maxpNumGlyphs) {
  45255. var start = (font.start ? font.start : 0) + post.offset;
  45256. font.pos = start;
  45257. var length = post.length, end = start + length;
  45258. var version = font.getInt32();
  45259. font.getBytes(28);
  45260. var glyphNames;
  45261. var valid = true;
  45262. var i;
  45263. switch (version) {
  45264. case 0x00010000:
  45265. glyphNames = MacStandardGlyphOrdering;
  45266. break;
  45267. case 0x00020000:
  45268. var numGlyphs = font.getUint16();
  45269. if (numGlyphs !== maxpNumGlyphs) {
  45270. valid = false;
  45271. break;
  45272. }
  45273. var glyphNameIndexes = [];
  45274. for (i = 0; i < numGlyphs; ++i) {
  45275. var index = font.getUint16();
  45276. if (index >= 32768) {
  45277. valid = false;
  45278. break;
  45279. }
  45280. glyphNameIndexes.push(index);
  45281. }
  45282. if (!valid) {
  45283. break;
  45284. }
  45285. var customNames = [];
  45286. var strBuf = [];
  45287. while (font.pos < end) {
  45288. var stringLength = font.getByte();
  45289. strBuf.length = stringLength;
  45290. for (i = 0; i < stringLength; ++i) {
  45291. strBuf[i] = String.fromCharCode(font.getByte());
  45292. }
  45293. customNames.push(strBuf.join(''));
  45294. }
  45295. glyphNames = [];
  45296. for (i = 0; i < numGlyphs; ++i) {
  45297. var j = glyphNameIndexes[i];
  45298. if (j < 258) {
  45299. glyphNames.push(MacStandardGlyphOrdering[j]);
  45300. continue;
  45301. }
  45302. glyphNames.push(customNames[j - 258]);
  45303. }
  45304. break;
  45305. case 0x00030000:
  45306. break;
  45307. default:
  45308. warn('Unknown/unsupported post table version ' + version);
  45309. valid = false;
  45310. if (properties.defaultEncoding) {
  45311. glyphNames = properties.defaultEncoding;
  45312. }
  45313. break;
  45314. }
  45315. properties.glyphNames = glyphNames;
  45316. return valid;
  45317. }
  45318. function readNameTable(nameTable) {
  45319. var start = (font.start ? font.start : 0) + nameTable.offset;
  45320. font.pos = start;
  45321. var names = [
  45322. [],
  45323. []
  45324. ];
  45325. var length = nameTable.length, end = start + length;
  45326. var format = font.getUint16();
  45327. var FORMAT_0_HEADER_LENGTH = 6;
  45328. if (format !== 0 || length < FORMAT_0_HEADER_LENGTH) {
  45329. return names;
  45330. }
  45331. var numRecords = font.getUint16();
  45332. var stringsStart = font.getUint16();
  45333. var records = [];
  45334. var NAME_RECORD_LENGTH = 12;
  45335. var i, ii;
  45336. for (i = 0; i < numRecords && font.pos + NAME_RECORD_LENGTH <= end; i++) {
  45337. var r = {
  45338. platform: font.getUint16(),
  45339. encoding: font.getUint16(),
  45340. language: font.getUint16(),
  45341. name: font.getUint16(),
  45342. length: font.getUint16(),
  45343. offset: font.getUint16()
  45344. };
  45345. if (r.platform === 1 && r.encoding === 0 && r.language === 0 || r.platform === 3 && r.encoding === 1 && r.language === 0x409) {
  45346. records.push(r);
  45347. }
  45348. }
  45349. for (i = 0, ii = records.length; i < ii; i++) {
  45350. var record = records[i];
  45351. if (record.length <= 0) {
  45352. continue;
  45353. }
  45354. var pos = start + stringsStart + record.offset;
  45355. if (pos + record.length > end) {
  45356. continue;
  45357. }
  45358. font.pos = pos;
  45359. var nameIndex = record.name;
  45360. if (record.encoding) {
  45361. var str = '';
  45362. for (var j = 0, jj = record.length; j < jj; j += 2) {
  45363. str += String.fromCharCode(font.getUint16());
  45364. }
  45365. names[1][nameIndex] = str;
  45366. } else {
  45367. names[0][nameIndex] = bytesToString(font.getBytes(record.length));
  45368. }
  45369. }
  45370. return names;
  45371. }
  45372. var TTOpsStackDeltas = [
  45373. 0,
  45374. 0,
  45375. 0,
  45376. 0,
  45377. 0,
  45378. 0,
  45379. 0,
  45380. 0,
  45381. -2,
  45382. -2,
  45383. -2,
  45384. -2,
  45385. 0,
  45386. 0,
  45387. -2,
  45388. -5,
  45389. -1,
  45390. -1,
  45391. -1,
  45392. -1,
  45393. -1,
  45394. -1,
  45395. -1,
  45396. -1,
  45397. 0,
  45398. 0,
  45399. -1,
  45400. 0,
  45401. -1,
  45402. -1,
  45403. -1,
  45404. -1,
  45405. 1,
  45406. -1,
  45407. -999,
  45408. 0,
  45409. 1,
  45410. 0,
  45411. -1,
  45412. -2,
  45413. 0,
  45414. -1,
  45415. -2,
  45416. -1,
  45417. -1,
  45418. 0,
  45419. -1,
  45420. -1,
  45421. 0,
  45422. 0,
  45423. -999,
  45424. -999,
  45425. -1,
  45426. -1,
  45427. -1,
  45428. -1,
  45429. -2,
  45430. -999,
  45431. -2,
  45432. -2,
  45433. -999,
  45434. 0,
  45435. -2,
  45436. -2,
  45437. 0,
  45438. 0,
  45439. -2,
  45440. 0,
  45441. -2,
  45442. 0,
  45443. 0,
  45444. 0,
  45445. -2,
  45446. -1,
  45447. -1,
  45448. 1,
  45449. 1,
  45450. 0,
  45451. 0,
  45452. -1,
  45453. -1,
  45454. -1,
  45455. -1,
  45456. -1,
  45457. -1,
  45458. -1,
  45459. 0,
  45460. 0,
  45461. -1,
  45462. 0,
  45463. -1,
  45464. -1,
  45465. 0,
  45466. -999,
  45467. -1,
  45468. -1,
  45469. -1,
  45470. -1,
  45471. -1,
  45472. -1,
  45473. 0,
  45474. 0,
  45475. 0,
  45476. 0,
  45477. 0,
  45478. 0,
  45479. 0,
  45480. 0,
  45481. 0,
  45482. 0,
  45483. 0,
  45484. 0,
  45485. -2,
  45486. -999,
  45487. -999,
  45488. -999,
  45489. -999,
  45490. -999,
  45491. -1,
  45492. -1,
  45493. -2,
  45494. -2,
  45495. 0,
  45496. 0,
  45497. 0,
  45498. 0,
  45499. -1,
  45500. -1,
  45501. -999,
  45502. -2,
  45503. -2,
  45504. 0,
  45505. 0,
  45506. -1,
  45507. -2,
  45508. -2,
  45509. 0,
  45510. 0,
  45511. 0,
  45512. -1,
  45513. -1,
  45514. -1,
  45515. -2
  45516. ];
  45517. function sanitizeTTProgram(table, ttContext) {
  45518. var data = table.data;
  45519. var i = 0, j, n, b, funcId, pc, lastEndf = 0, lastDeff = 0;
  45520. var stack = [];
  45521. var callstack = [];
  45522. var functionsCalled = [];
  45523. var tooComplexToFollowFunctions = ttContext.tooComplexToFollowFunctions;
  45524. var inFDEF = false, ifLevel = 0, inELSE = 0;
  45525. for (var ii = data.length; i < ii;) {
  45526. var op = data[i++];
  45527. if (op === 0x40) {
  45528. n = data[i++];
  45529. if (inFDEF || inELSE) {
  45530. i += n;
  45531. } else {
  45532. for (j = 0; j < n; j++) {
  45533. stack.push(data[i++]);
  45534. }
  45535. }
  45536. } else if (op === 0x41) {
  45537. n = data[i++];
  45538. if (inFDEF || inELSE) {
  45539. i += n * 2;
  45540. } else {
  45541. for (j = 0; j < n; j++) {
  45542. b = data[i++];
  45543. stack.push(b << 8 | data[i++]);
  45544. }
  45545. }
  45546. } else if ((op & 0xF8) === 0xB0) {
  45547. n = op - 0xB0 + 1;
  45548. if (inFDEF || inELSE) {
  45549. i += n;
  45550. } else {
  45551. for (j = 0; j < n; j++) {
  45552. stack.push(data[i++]);
  45553. }
  45554. }
  45555. } else if ((op & 0xF8) === 0xB8) {
  45556. n = op - 0xB8 + 1;
  45557. if (inFDEF || inELSE) {
  45558. i += n * 2;
  45559. } else {
  45560. for (j = 0; j < n; j++) {
  45561. b = data[i++];
  45562. stack.push(b << 8 | data[i++]);
  45563. }
  45564. }
  45565. } else if (op === 0x2B && !tooComplexToFollowFunctions) {
  45566. if (!inFDEF && !inELSE) {
  45567. funcId = stack[stack.length - 1];
  45568. ttContext.functionsUsed[funcId] = true;
  45569. if (funcId in ttContext.functionsStackDeltas) {
  45570. stack.length += ttContext.functionsStackDeltas[funcId];
  45571. } else if (funcId in ttContext.functionsDefined && functionsCalled.indexOf(funcId) < 0) {
  45572. callstack.push({
  45573. data: data,
  45574. i: i,
  45575. stackTop: stack.length - 1
  45576. });
  45577. functionsCalled.push(funcId);
  45578. pc = ttContext.functionsDefined[funcId];
  45579. if (!pc) {
  45580. warn('TT: CALL non-existent function');
  45581. ttContext.hintsValid = false;
  45582. return;
  45583. }
  45584. data = pc.data;
  45585. i = pc.i;
  45586. }
  45587. }
  45588. } else if (op === 0x2C && !tooComplexToFollowFunctions) {
  45589. if (inFDEF || inELSE) {
  45590. warn('TT: nested FDEFs not allowed');
  45591. tooComplexToFollowFunctions = true;
  45592. }
  45593. inFDEF = true;
  45594. lastDeff = i;
  45595. funcId = stack.pop();
  45596. ttContext.functionsDefined[funcId] = {
  45597. data: data,
  45598. i: i
  45599. };
  45600. } else if (op === 0x2D) {
  45601. if (inFDEF) {
  45602. inFDEF = false;
  45603. lastEndf = i;
  45604. } else {
  45605. pc = callstack.pop();
  45606. if (!pc) {
  45607. warn('TT: ENDF bad stack');
  45608. ttContext.hintsValid = false;
  45609. return;
  45610. }
  45611. funcId = functionsCalled.pop();
  45612. data = pc.data;
  45613. i = pc.i;
  45614. ttContext.functionsStackDeltas[funcId] = stack.length - pc.stackTop;
  45615. }
  45616. } else if (op === 0x89) {
  45617. if (inFDEF || inELSE) {
  45618. warn('TT: nested IDEFs not allowed');
  45619. tooComplexToFollowFunctions = true;
  45620. }
  45621. inFDEF = true;
  45622. lastDeff = i;
  45623. } else if (op === 0x58) {
  45624. ++ifLevel;
  45625. } else if (op === 0x1B) {
  45626. inELSE = ifLevel;
  45627. } else if (op === 0x59) {
  45628. if (inELSE === ifLevel) {
  45629. inELSE = 0;
  45630. }
  45631. --ifLevel;
  45632. } else if (op === 0x1C) {
  45633. if (!inFDEF && !inELSE) {
  45634. var offset = stack[stack.length - 1];
  45635. if (offset > 0) {
  45636. i += offset - 1;
  45637. }
  45638. }
  45639. }
  45640. if (!inFDEF && !inELSE) {
  45641. var stackDelta = op <= 0x8E ? TTOpsStackDeltas[op] : op >= 0xC0 && op <= 0xDF ? -1 : op >= 0xE0 ? -2 : 0;
  45642. if (op >= 0x71 && op <= 0x75) {
  45643. n = stack.pop();
  45644. if (!isNaN(n)) {
  45645. stackDelta = -n * 2;
  45646. }
  45647. }
  45648. while (stackDelta < 0 && stack.length > 0) {
  45649. stack.pop();
  45650. stackDelta++;
  45651. }
  45652. while (stackDelta > 0) {
  45653. stack.push(NaN);
  45654. stackDelta--;
  45655. }
  45656. }
  45657. }
  45658. ttContext.tooComplexToFollowFunctions = tooComplexToFollowFunctions;
  45659. var content = [data];
  45660. if (i > data.length) {
  45661. content.push(new Uint8Array(i - data.length));
  45662. }
  45663. if (lastDeff > lastEndf) {
  45664. warn('TT: complementing a missing function tail');
  45665. content.push(new Uint8Array([
  45666. 0x22,
  45667. 0x2D
  45668. ]));
  45669. }
  45670. foldTTTable(table, content);
  45671. }
  45672. function checkInvalidFunctions(ttContext, maxFunctionDefs) {
  45673. if (ttContext.tooComplexToFollowFunctions) {
  45674. return;
  45675. }
  45676. if (ttContext.functionsDefined.length > maxFunctionDefs) {
  45677. warn('TT: more functions defined than expected');
  45678. ttContext.hintsValid = false;
  45679. return;
  45680. }
  45681. for (var j = 0, jj = ttContext.functionsUsed.length; j < jj; j++) {
  45682. if (j > maxFunctionDefs) {
  45683. warn('TT: invalid function id: ' + j);
  45684. ttContext.hintsValid = false;
  45685. return;
  45686. }
  45687. if (ttContext.functionsUsed[j] && !ttContext.functionsDefined[j]) {
  45688. warn('TT: undefined function: ' + j);
  45689. ttContext.hintsValid = false;
  45690. return;
  45691. }
  45692. }
  45693. }
  45694. function foldTTTable(table, content) {
  45695. if (content.length > 1) {
  45696. var newLength = 0;
  45697. var j, jj;
  45698. for (j = 0, jj = content.length; j < jj; j++) {
  45699. newLength += content[j].length;
  45700. }
  45701. newLength = newLength + 3 & ~3;
  45702. var result = new Uint8Array(newLength);
  45703. var pos = 0;
  45704. for (j = 0, jj = content.length; j < jj; j++) {
  45705. result.set(content[j], pos);
  45706. pos += content[j].length;
  45707. }
  45708. table.data = result;
  45709. table.length = newLength;
  45710. }
  45711. }
  45712. function sanitizeTTPrograms(fpgm, prep, cvt, maxFunctionDefs) {
  45713. var ttContext = {
  45714. functionsDefined: [],
  45715. functionsUsed: [],
  45716. functionsStackDeltas: [],
  45717. tooComplexToFollowFunctions: false,
  45718. hintsValid: true
  45719. };
  45720. if (fpgm) {
  45721. sanitizeTTProgram(fpgm, ttContext);
  45722. }
  45723. if (prep) {
  45724. sanitizeTTProgram(prep, ttContext);
  45725. }
  45726. if (fpgm) {
  45727. checkInvalidFunctions(ttContext, maxFunctionDefs);
  45728. }
  45729. if (cvt && cvt.length & 1) {
  45730. var cvtData = new Uint8Array(cvt.length + 1);
  45731. cvtData.set(cvt.data);
  45732. cvt.data = cvtData;
  45733. }
  45734. return ttContext.hintsValid;
  45735. }
  45736. font = new Stream(new Uint8Array(font.getBytes()));
  45737. var VALID_TABLES = [
  45738. 'OS/2',
  45739. 'cmap',
  45740. 'head',
  45741. 'hhea',
  45742. 'hmtx',
  45743. 'maxp',
  45744. 'name',
  45745. 'post',
  45746. 'loca',
  45747. 'glyf',
  45748. 'fpgm',
  45749. 'prep',
  45750. 'cvt ',
  45751. 'CFF '
  45752. ];
  45753. var header = readOpenTypeHeader(font);
  45754. var numTables = header.numTables;
  45755. var cff, cffFile;
  45756. var tables = Object.create(null);
  45757. tables['OS/2'] = null;
  45758. tables['cmap'] = null;
  45759. tables['head'] = null;
  45760. tables['hhea'] = null;
  45761. tables['hmtx'] = null;
  45762. tables['maxp'] = null;
  45763. tables['name'] = null;
  45764. tables['post'] = null;
  45765. var table;
  45766. for (var i = 0; i < numTables; i++) {
  45767. table = readTableEntry(font);
  45768. if (VALID_TABLES.indexOf(table.tag) < 0) {
  45769. continue;
  45770. }
  45771. if (table.length === 0) {
  45772. continue;
  45773. }
  45774. tables[table.tag] = table;
  45775. }
  45776. var isTrueType = !tables['CFF '];
  45777. if (!isTrueType) {
  45778. if (header.version === 'OTTO' && !properties.composite || !tables['head'] || !tables['hhea'] || !tables['maxp'] || !tables['post']) {
  45779. cffFile = new Stream(tables['CFF '].data);
  45780. cff = new CFFFont(cffFile, properties);
  45781. adjustWidths(properties);
  45782. return this.convert(name, cff, properties);
  45783. }
  45784. delete tables['glyf'];
  45785. delete tables['loca'];
  45786. delete tables['fpgm'];
  45787. delete tables['prep'];
  45788. delete tables['cvt '];
  45789. this.isOpenType = true;
  45790. } else {
  45791. if (!tables['loca']) {
  45792. error('Required "loca" table is not found');
  45793. }
  45794. if (!tables['glyf']) {
  45795. warn('Required "glyf" table is not found -- trying to recover.');
  45796. tables['glyf'] = {
  45797. tag: 'glyf',
  45798. data: new Uint8Array(0)
  45799. };
  45800. }
  45801. this.isOpenType = false;
  45802. }
  45803. if (!tables['maxp']) {
  45804. error('Required "maxp" table is not found');
  45805. }
  45806. font.pos = (font.start || 0) + tables['maxp'].offset;
  45807. var version = font.getInt32();
  45808. var numGlyphs = font.getUint16();
  45809. var maxFunctionDefs = 0;
  45810. if (version >= 0x00010000 && tables['maxp'].length >= 22) {
  45811. font.pos += 8;
  45812. var maxZones = font.getUint16();
  45813. if (maxZones > 2) {
  45814. tables['maxp'].data[14] = 0;
  45815. tables['maxp'].data[15] = 2;
  45816. }
  45817. font.pos += 4;
  45818. maxFunctionDefs = font.getUint16();
  45819. }
  45820. var dupFirstEntry = false;
  45821. if (properties.type === 'CIDFontType2' && properties.toUnicode && properties.toUnicode.get(0) > '\u0000') {
  45822. dupFirstEntry = true;
  45823. numGlyphs++;
  45824. tables['maxp'].data[4] = numGlyphs >> 8;
  45825. tables['maxp'].data[5] = numGlyphs & 255;
  45826. }
  45827. var hintsValid = sanitizeTTPrograms(tables['fpgm'], tables['prep'], tables['cvt '], maxFunctionDefs);
  45828. if (!hintsValid) {
  45829. delete tables['fpgm'];
  45830. delete tables['prep'];
  45831. delete tables['cvt '];
  45832. }
  45833. sanitizeMetrics(font, tables['hhea'], tables['hmtx'], numGlyphs);
  45834. if (!tables['head']) {
  45835. error('Required "head" table is not found');
  45836. }
  45837. sanitizeHead(tables['head'], numGlyphs, isTrueType ? tables['loca'].length : 0);
  45838. var missingGlyphs = Object.create(null);
  45839. if (isTrueType) {
  45840. var isGlyphLocationsLong = int16(tables['head'].data[50], tables['head'].data[51]);
  45841. missingGlyphs = sanitizeGlyphLocations(tables['loca'], tables['glyf'], numGlyphs, isGlyphLocationsLong, hintsValid, dupFirstEntry);
  45842. }
  45843. if (!tables['hhea']) {
  45844. error('Required "hhea" table is not found');
  45845. }
  45846. if (tables['hhea'].data[10] === 0 && tables['hhea'].data[11] === 0) {
  45847. tables['hhea'].data[10] = 0xFF;
  45848. tables['hhea'].data[11] = 0xFF;
  45849. }
  45850. var metricsOverride = {
  45851. unitsPerEm: int16(tables['head'].data[18], tables['head'].data[19]),
  45852. yMax: int16(tables['head'].data[42], tables['head'].data[43]),
  45853. yMin: signedInt16(tables['head'].data[38], tables['head'].data[39]),
  45854. ascent: int16(tables['hhea'].data[4], tables['hhea'].data[5]),
  45855. descent: signedInt16(tables['hhea'].data[6], tables['hhea'].data[7])
  45856. };
  45857. this.ascent = metricsOverride.ascent / metricsOverride.unitsPerEm;
  45858. this.descent = metricsOverride.descent / metricsOverride.unitsPerEm;
  45859. if (tables['post']) {
  45860. var valid = readPostScriptTable(tables['post'], properties, numGlyphs);
  45861. if (!valid) {
  45862. tables['post'] = null;
  45863. }
  45864. }
  45865. var charCodeToGlyphId = [], charCode;
  45866. var toUnicode = properties.toUnicode, widths = properties.widths;
  45867. var skipToUnicode = toUnicode instanceof IdentityToUnicodeMap || toUnicode.length === 0x10000;
  45868. function hasGlyph(glyphId, charCode, widthCode) {
  45869. if (!missingGlyphs[glyphId]) {
  45870. return true;
  45871. }
  45872. if (!skipToUnicode && charCode >= 0 && toUnicode.has(charCode)) {
  45873. return true;
  45874. }
  45875. if (widths && widthCode >= 0 && isNum(widths[widthCode])) {
  45876. return true;
  45877. }
  45878. return false;
  45879. }
  45880. if (properties.composite) {
  45881. var cidToGidMap = properties.cidToGidMap || [];
  45882. var isCidToGidMapEmpty = cidToGidMap.length === 0;
  45883. properties.cMap.forEach(function (charCode, cid) {
  45884. assert(cid <= 0xffff, 'Max size of CID is 65,535');
  45885. var glyphId = -1;
  45886. if (isCidToGidMapEmpty) {
  45887. glyphId = cid;
  45888. } else if (cidToGidMap[cid] !== undefined) {
  45889. glyphId = cidToGidMap[cid];
  45890. }
  45891. if (glyphId >= 0 && glyphId < numGlyphs && hasGlyph(glyphId, charCode, cid)) {
  45892. charCodeToGlyphId[charCode] = glyphId;
  45893. }
  45894. });
  45895. if (dupFirstEntry && (isCidToGidMapEmpty || !charCodeToGlyphId[0])) {
  45896. charCodeToGlyphId[0] = numGlyphs - 1;
  45897. }
  45898. } else {
  45899. var cmapTable = readCmapTable(tables['cmap'], font, this.isSymbolicFont, properties.hasEncoding);
  45900. var cmapPlatformId = cmapTable.platformId;
  45901. var cmapEncodingId = cmapTable.encodingId;
  45902. var cmapMappings = cmapTable.mappings;
  45903. var cmapMappingsLength = cmapMappings.length;
  45904. if (properties.hasEncoding && (cmapPlatformId === 3 && cmapEncodingId === 1 || cmapPlatformId === 1 && cmapEncodingId === 0) || cmapPlatformId === -1 && cmapEncodingId === -1 && !!getEncoding(properties.baseEncodingName)) {
  45905. var baseEncoding = [];
  45906. if (properties.baseEncodingName === 'MacRomanEncoding' || properties.baseEncodingName === 'WinAnsiEncoding') {
  45907. baseEncoding = getEncoding(properties.baseEncodingName);
  45908. }
  45909. var glyphsUnicodeMap = getGlyphsUnicode();
  45910. for (charCode = 0; charCode < 256; charCode++) {
  45911. var glyphName, standardGlyphName;
  45912. if (this.differences && charCode in this.differences) {
  45913. glyphName = this.differences[charCode];
  45914. } else if (charCode in baseEncoding && baseEncoding[charCode] !== '') {
  45915. glyphName = baseEncoding[charCode];
  45916. } else {
  45917. glyphName = StandardEncoding[charCode];
  45918. }
  45919. if (!glyphName) {
  45920. continue;
  45921. }
  45922. standardGlyphName = recoverGlyphName(glyphName, glyphsUnicodeMap);
  45923. var unicodeOrCharCode, isUnicode = false;
  45924. if (cmapPlatformId === 3 && cmapEncodingId === 1) {
  45925. unicodeOrCharCode = glyphsUnicodeMap[standardGlyphName];
  45926. isUnicode = true;
  45927. } else if (cmapPlatformId === 1 && cmapEncodingId === 0) {
  45928. unicodeOrCharCode = MacRomanEncoding.indexOf(standardGlyphName);
  45929. }
  45930. var found = false;
  45931. for (i = 0; i < cmapMappingsLength; ++i) {
  45932. if (cmapMappings[i].charCode !== unicodeOrCharCode) {
  45933. continue;
  45934. }
  45935. var code = isUnicode ? charCode : unicodeOrCharCode;
  45936. if (hasGlyph(cmapMappings[i].glyphId, code, -1)) {
  45937. charCodeToGlyphId[charCode] = cmapMappings[i].glyphId;
  45938. found = true;
  45939. break;
  45940. }
  45941. }
  45942. if (!found && properties.glyphNames) {
  45943. var glyphId = properties.glyphNames.indexOf(glyphName);
  45944. if (glyphId === -1 && standardGlyphName !== glyphName) {
  45945. glyphId = properties.glyphNames.indexOf(standardGlyphName);
  45946. }
  45947. if (glyphId > 0 && hasGlyph(glyphId, -1, -1)) {
  45948. charCodeToGlyphId[charCode] = glyphId;
  45949. found = true;
  45950. }
  45951. }
  45952. if (!found) {
  45953. charCodeToGlyphId[charCode] = 0;
  45954. }
  45955. }
  45956. } else if (cmapPlatformId === 0 && cmapEncodingId === 0) {
  45957. for (i = 0; i < cmapMappingsLength; ++i) {
  45958. charCodeToGlyphId[cmapMappings[i].charCode] = cmapMappings[i].glyphId;
  45959. }
  45960. } else {
  45961. for (i = 0; i < cmapMappingsLength; ++i) {
  45962. charCode = cmapMappings[i].charCode & 0xFF;
  45963. charCodeToGlyphId[charCode] = cmapMappings[i].glyphId;
  45964. }
  45965. }
  45966. }
  45967. if (charCodeToGlyphId.length === 0) {
  45968. charCodeToGlyphId[0] = 0;
  45969. }
  45970. var newMapping = adjustMapping(charCodeToGlyphId, properties);
  45971. this.toFontChar = newMapping.toFontChar;
  45972. tables['cmap'] = {
  45973. tag: 'cmap',
  45974. data: createCmapTable(newMapping.charCodeToGlyphId, numGlyphs)
  45975. };
  45976. if (!tables['OS/2'] || !validateOS2Table(tables['OS/2'])) {
  45977. tables['OS/2'] = {
  45978. tag: 'OS/2',
  45979. data: createOS2Table(properties, newMapping.charCodeToGlyphId, metricsOverride)
  45980. };
  45981. }
  45982. if (!tables['post']) {
  45983. tables['post'] = {
  45984. tag: 'post',
  45985. data: createPostTable(properties)
  45986. };
  45987. }
  45988. if (!isTrueType) {
  45989. try {
  45990. cffFile = new Stream(tables['CFF '].data);
  45991. var parser = new CFFParser(cffFile, properties, SEAC_ANALYSIS_ENABLED);
  45992. cff = parser.parse();
  45993. var compiler = new CFFCompiler(cff);
  45994. tables['CFF '].data = compiler.compile();
  45995. } catch (e) {
  45996. warn('Failed to compile font ' + properties.loadedName);
  45997. }
  45998. }
  45999. if (!tables['name']) {
  46000. tables['name'] = {
  46001. tag: 'name',
  46002. data: createNameTable(this.name)
  46003. };
  46004. } else {
  46005. var namePrototype = readNameTable(tables['name']);
  46006. tables['name'].data = createNameTable(name, namePrototype);
  46007. }
  46008. var builder = new OpenTypeFileBuilder(header.version);
  46009. for (var tableTag in tables) {
  46010. builder.addTable(tableTag, tables[tableTag].data);
  46011. }
  46012. return builder.toArray();
  46013. },
  46014. convert: function Font_convert(fontName, font, properties) {
  46015. properties.fixedPitch = false;
  46016. if (properties.builtInEncoding) {
  46017. adjustToUnicode(properties, properties.builtInEncoding);
  46018. }
  46019. var mapping = font.getGlyphMapping(properties);
  46020. var newMapping = adjustMapping(mapping, properties);
  46021. this.toFontChar = newMapping.toFontChar;
  46022. var numGlyphs = font.numGlyphs;
  46023. function getCharCodes(charCodeToGlyphId, glyphId) {
  46024. var charCodes = null;
  46025. for (var charCode in charCodeToGlyphId) {
  46026. if (glyphId === charCodeToGlyphId[charCode]) {
  46027. if (!charCodes) {
  46028. charCodes = [];
  46029. }
  46030. charCodes.push(charCode | 0);
  46031. }
  46032. }
  46033. return charCodes;
  46034. }
  46035. function createCharCode(charCodeToGlyphId, glyphId) {
  46036. for (var charCode in charCodeToGlyphId) {
  46037. if (glyphId === charCodeToGlyphId[charCode]) {
  46038. return charCode | 0;
  46039. }
  46040. }
  46041. newMapping.charCodeToGlyphId[newMapping.nextAvailableFontCharCode] = glyphId;
  46042. return newMapping.nextAvailableFontCharCode++;
  46043. }
  46044. var seacs = font.seacs;
  46045. if (SEAC_ANALYSIS_ENABLED && seacs && seacs.length) {
  46046. var matrix = properties.fontMatrix || FONT_IDENTITY_MATRIX;
  46047. var charset = font.getCharset();
  46048. var seacMap = Object.create(null);
  46049. for (var glyphId in seacs) {
  46050. glyphId |= 0;
  46051. var seac = seacs[glyphId];
  46052. var baseGlyphName = StandardEncoding[seac[2]];
  46053. var accentGlyphName = StandardEncoding[seac[3]];
  46054. var baseGlyphId = charset.indexOf(baseGlyphName);
  46055. var accentGlyphId = charset.indexOf(accentGlyphName);
  46056. if (baseGlyphId < 0 || accentGlyphId < 0) {
  46057. continue;
  46058. }
  46059. var accentOffset = {
  46060. x: seac[0] * matrix[0] + seac[1] * matrix[2] + matrix[4],
  46061. y: seac[0] * matrix[1] + seac[1] * matrix[3] + matrix[5]
  46062. };
  46063. var charCodes = getCharCodes(mapping, glyphId);
  46064. if (!charCodes) {
  46065. continue;
  46066. }
  46067. for (var i = 0, ii = charCodes.length; i < ii; i++) {
  46068. var charCode = charCodes[i];
  46069. var charCodeToGlyphId = newMapping.charCodeToGlyphId;
  46070. var baseFontCharCode = createCharCode(charCodeToGlyphId, baseGlyphId);
  46071. var accentFontCharCode = createCharCode(charCodeToGlyphId, accentGlyphId);
  46072. seacMap[charCode] = {
  46073. baseFontCharCode: baseFontCharCode,
  46074. accentFontCharCode: accentFontCharCode,
  46075. accentOffset: accentOffset
  46076. };
  46077. }
  46078. }
  46079. properties.seacMap = seacMap;
  46080. }
  46081. var unitsPerEm = 1 / (properties.fontMatrix || FONT_IDENTITY_MATRIX)[0];
  46082. var builder = new OpenTypeFileBuilder('\x4F\x54\x54\x4F');
  46083. builder.addTable('CFF ', font.data);
  46084. builder.addTable('OS/2', createOS2Table(properties, newMapping.charCodeToGlyphId));
  46085. builder.addTable('cmap', createCmapTable(newMapping.charCodeToGlyphId, numGlyphs));
  46086. 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');
  46087. 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));
  46088. builder.addTable('hmtx', function fontFieldsHmtx() {
  46089. var charstrings = font.charstrings;
  46090. var cffWidths = font.cff ? font.cff.widths : null;
  46091. var hmtx = '\x00\x00\x00\x00';
  46092. for (var i = 1, ii = numGlyphs; i < ii; i++) {
  46093. var width = 0;
  46094. if (charstrings) {
  46095. var charstring = charstrings[i - 1];
  46096. width = 'width' in charstring ? charstring.width : 0;
  46097. } else if (cffWidths) {
  46098. width = Math.ceil(cffWidths[i] || 0);
  46099. }
  46100. hmtx += string16(width) + string16(0);
  46101. }
  46102. return hmtx;
  46103. }());
  46104. builder.addTable('maxp', '\x00\x00\x50\x00' + string16(numGlyphs));
  46105. builder.addTable('name', createNameTable(fontName));
  46106. builder.addTable('post', createPostTable(properties));
  46107. return builder.toArray();
  46108. },
  46109. get spaceWidth() {
  46110. if ('_shadowWidth' in this) {
  46111. return this._shadowWidth;
  46112. }
  46113. var possibleSpaceReplacements = [
  46114. 'space',
  46115. 'minus',
  46116. 'one',
  46117. 'i',
  46118. 'I'
  46119. ];
  46120. var width;
  46121. for (var i = 0, ii = possibleSpaceReplacements.length; i < ii; i++) {
  46122. var glyphName = possibleSpaceReplacements[i];
  46123. if (glyphName in this.widths) {
  46124. width = this.widths[glyphName];
  46125. break;
  46126. }
  46127. var glyphsUnicodeMap = getGlyphsUnicode();
  46128. var glyphUnicode = glyphsUnicodeMap[glyphName];
  46129. var charcode = 0;
  46130. if (this.composite) {
  46131. if (this.cMap.contains(glyphUnicode)) {
  46132. charcode = this.cMap.lookup(glyphUnicode);
  46133. }
  46134. }
  46135. if (!charcode && this.toUnicode) {
  46136. charcode = this.toUnicode.charCodeOf(glyphUnicode);
  46137. }
  46138. if (charcode <= 0) {
  46139. charcode = glyphUnicode;
  46140. }
  46141. width = this.widths[charcode];
  46142. if (width) {
  46143. break;
  46144. }
  46145. }
  46146. width = width || this.defaultWidth;
  46147. this._shadowWidth = width;
  46148. return width;
  46149. },
  46150. charToGlyph: function Font_charToGlyph(charcode, isSpace) {
  46151. var fontCharCode, width, operatorListId;
  46152. var widthCode = charcode;
  46153. if (this.cMap && this.cMap.contains(charcode)) {
  46154. widthCode = this.cMap.lookup(charcode);
  46155. }
  46156. width = this.widths[widthCode];
  46157. width = isNum(width) ? width : this.defaultWidth;
  46158. var vmetric = this.vmetrics && this.vmetrics[widthCode];
  46159. var unicode = this.toUnicode.get(charcode) || charcode;
  46160. if (typeof unicode === 'number') {
  46161. unicode = String.fromCharCode(unicode);
  46162. }
  46163. var isInFont = charcode in this.toFontChar;
  46164. fontCharCode = this.toFontChar[charcode] || charcode;
  46165. if (this.missingFile) {
  46166. fontCharCode = mapSpecialUnicodeValues(fontCharCode);
  46167. }
  46168. if (this.isType3Font) {
  46169. operatorListId = fontCharCode;
  46170. }
  46171. var accent = null;
  46172. if (this.seacMap && this.seacMap[charcode]) {
  46173. isInFont = true;
  46174. var seac = this.seacMap[charcode];
  46175. fontCharCode = seac.baseFontCharCode;
  46176. accent = {
  46177. fontChar: String.fromCharCode(seac.accentFontCharCode),
  46178. offset: seac.accentOffset
  46179. };
  46180. }
  46181. var fontChar = String.fromCharCode(fontCharCode);
  46182. var glyph = this.glyphCache[charcode];
  46183. if (!glyph || !glyph.matchesForCache(fontChar, unicode, accent, width, vmetric, operatorListId, isSpace, isInFont)) {
  46184. glyph = new Glyph(fontChar, unicode, accent, width, vmetric, operatorListId, isSpace, isInFont);
  46185. this.glyphCache[charcode] = glyph;
  46186. }
  46187. return glyph;
  46188. },
  46189. charsToGlyphs: function Font_charsToGlyphs(chars) {
  46190. var charsCache = this.charsCache;
  46191. var glyphs, glyph, charcode;
  46192. if (charsCache) {
  46193. glyphs = charsCache[chars];
  46194. if (glyphs) {
  46195. return glyphs;
  46196. }
  46197. }
  46198. if (!charsCache) {
  46199. charsCache = this.charsCache = Object.create(null);
  46200. }
  46201. glyphs = [];
  46202. var charsCacheKey = chars;
  46203. var i = 0, ii;
  46204. if (this.cMap) {
  46205. var c = Object.create(null);
  46206. while (i < chars.length) {
  46207. this.cMap.readCharCode(chars, i, c);
  46208. charcode = c.charcode;
  46209. var length = c.length;
  46210. i += length;
  46211. var isSpace = length === 1 && chars.charCodeAt(i - 1) === 0x20;
  46212. glyph = this.charToGlyph(charcode, isSpace);
  46213. glyphs.push(glyph);
  46214. }
  46215. } else {
  46216. for (i = 0, ii = chars.length; i < ii; ++i) {
  46217. charcode = chars.charCodeAt(i);
  46218. glyph = this.charToGlyph(charcode, charcode === 0x20);
  46219. glyphs.push(glyph);
  46220. }
  46221. }
  46222. return charsCache[charsCacheKey] = glyphs;
  46223. }
  46224. };
  46225. return Font;
  46226. }();
  46227. var ErrorFont = function ErrorFontClosure() {
  46228. function ErrorFont(error) {
  46229. this.error = error;
  46230. this.loadedName = 'g_font_error';
  46231. this.loading = false;
  46232. }
  46233. ErrorFont.prototype = {
  46234. charsToGlyphs: function ErrorFont_charsToGlyphs() {
  46235. return [];
  46236. },
  46237. exportData: function ErrorFont_exportData() {
  46238. return { error: this.error };
  46239. }
  46240. };
  46241. return ErrorFont;
  46242. }();
  46243. function type1FontGlyphMapping(properties, builtInEncoding, glyphNames) {
  46244. var charCodeToGlyphId = Object.create(null);
  46245. var glyphId, charCode, baseEncoding;
  46246. var isSymbolicFont = !!(properties.flags & FontFlags.Symbolic);
  46247. if (properties.baseEncodingName) {
  46248. baseEncoding = getEncoding(properties.baseEncodingName);
  46249. for (charCode = 0; charCode < baseEncoding.length; charCode++) {
  46250. glyphId = glyphNames.indexOf(baseEncoding[charCode]);
  46251. if (glyphId >= 0) {
  46252. charCodeToGlyphId[charCode] = glyphId;
  46253. } else {
  46254. charCodeToGlyphId[charCode] = 0;
  46255. }
  46256. }
  46257. } else if (isSymbolicFont) {
  46258. for (charCode in builtInEncoding) {
  46259. charCodeToGlyphId[charCode] = builtInEncoding[charCode];
  46260. }
  46261. } else {
  46262. baseEncoding = StandardEncoding;
  46263. for (charCode = 0; charCode < baseEncoding.length; charCode++) {
  46264. glyphId = glyphNames.indexOf(baseEncoding[charCode]);
  46265. if (glyphId >= 0) {
  46266. charCodeToGlyphId[charCode] = glyphId;
  46267. } else {
  46268. charCodeToGlyphId[charCode] = 0;
  46269. }
  46270. }
  46271. }
  46272. var differences = properties.differences, glyphsUnicodeMap;
  46273. if (differences) {
  46274. for (charCode in differences) {
  46275. var glyphName = differences[charCode];
  46276. glyphId = glyphNames.indexOf(glyphName);
  46277. if (glyphId === -1) {
  46278. if (!glyphsUnicodeMap) {
  46279. glyphsUnicodeMap = getGlyphsUnicode();
  46280. }
  46281. var standardGlyphName = recoverGlyphName(glyphName, glyphsUnicodeMap);
  46282. if (standardGlyphName !== glyphName) {
  46283. glyphId = glyphNames.indexOf(standardGlyphName);
  46284. }
  46285. }
  46286. if (glyphId >= 0) {
  46287. charCodeToGlyphId[charCode] = glyphId;
  46288. } else {
  46289. charCodeToGlyphId[charCode] = 0;
  46290. }
  46291. }
  46292. }
  46293. return charCodeToGlyphId;
  46294. }
  46295. var Type1Font = function Type1FontClosure() {
  46296. function findBlock(streamBytes, signature, startIndex) {
  46297. var streamBytesLength = streamBytes.length;
  46298. var signatureLength = signature.length;
  46299. var scanLength = streamBytesLength - signatureLength;
  46300. var i = startIndex, j, found = false;
  46301. while (i < scanLength) {
  46302. j = 0;
  46303. while (j < signatureLength && streamBytes[i + j] === signature[j]) {
  46304. j++;
  46305. }
  46306. if (j >= signatureLength) {
  46307. i += j;
  46308. while (i < streamBytesLength && isSpace(streamBytes[i])) {
  46309. i++;
  46310. }
  46311. found = true;
  46312. break;
  46313. }
  46314. i++;
  46315. }
  46316. return {
  46317. found: found,
  46318. length: i
  46319. };
  46320. }
  46321. function getHeaderBlock(stream, suggestedLength) {
  46322. var EEXEC_SIGNATURE = [
  46323. 0x65,
  46324. 0x65,
  46325. 0x78,
  46326. 0x65,
  46327. 0x63
  46328. ];
  46329. var streamStartPos = stream.pos;
  46330. var headerBytes, headerBytesLength, block;
  46331. try {
  46332. headerBytes = stream.getBytes(suggestedLength);
  46333. headerBytesLength = headerBytes.length;
  46334. } catch (ex) {
  46335. if (ex instanceof MissingDataException) {
  46336. throw ex;
  46337. }
  46338. }
  46339. if (headerBytesLength === suggestedLength) {
  46340. block = findBlock(headerBytes, EEXEC_SIGNATURE, suggestedLength - 2 * EEXEC_SIGNATURE.length);
  46341. if (block.found && block.length === suggestedLength) {
  46342. return {
  46343. stream: new Stream(headerBytes),
  46344. length: suggestedLength
  46345. };
  46346. }
  46347. }
  46348. warn('Invalid "Length1" property in Type1 font -- trying to recover.');
  46349. stream.pos = streamStartPos;
  46350. var SCAN_BLOCK_LENGTH = 2048;
  46351. var actualLength;
  46352. while (true) {
  46353. var scanBytes = stream.peekBytes(SCAN_BLOCK_LENGTH);
  46354. block = findBlock(scanBytes, EEXEC_SIGNATURE, 0);
  46355. if (block.length === 0) {
  46356. break;
  46357. }
  46358. stream.pos += block.length;
  46359. if (block.found) {
  46360. actualLength = stream.pos - streamStartPos;
  46361. break;
  46362. }
  46363. }
  46364. stream.pos = streamStartPos;
  46365. if (actualLength) {
  46366. return {
  46367. stream: new Stream(stream.getBytes(actualLength)),
  46368. length: actualLength
  46369. };
  46370. }
  46371. warn('Unable to recover "Length1" property in Type1 font -- using as is.');
  46372. return {
  46373. stream: new Stream(stream.getBytes(suggestedLength)),
  46374. length: suggestedLength
  46375. };
  46376. }
  46377. function getEexecBlock(stream, suggestedLength) {
  46378. var eexecBytes = stream.getBytes();
  46379. return {
  46380. stream: new Stream(eexecBytes),
  46381. length: eexecBytes.length
  46382. };
  46383. }
  46384. function Type1Font(name, file, properties) {
  46385. var PFB_HEADER_SIZE = 6;
  46386. var headerBlockLength = properties.length1;
  46387. var eexecBlockLength = properties.length2;
  46388. var pfbHeader = file.peekBytes(PFB_HEADER_SIZE);
  46389. var pfbHeaderPresent = pfbHeader[0] === 0x80 && pfbHeader[1] === 0x01;
  46390. if (pfbHeaderPresent) {
  46391. file.skip(PFB_HEADER_SIZE);
  46392. headerBlockLength = pfbHeader[5] << 24 | pfbHeader[4] << 16 | pfbHeader[3] << 8 | pfbHeader[2];
  46393. }
  46394. var headerBlock = getHeaderBlock(file, headerBlockLength);
  46395. headerBlockLength = headerBlock.length;
  46396. var headerBlockParser = new Type1Parser(headerBlock.stream, false, SEAC_ANALYSIS_ENABLED);
  46397. headerBlockParser.extractFontHeader(properties);
  46398. if (pfbHeaderPresent) {
  46399. pfbHeader = file.getBytes(PFB_HEADER_SIZE);
  46400. eexecBlockLength = pfbHeader[5] << 24 | pfbHeader[4] << 16 | pfbHeader[3] << 8 | pfbHeader[2];
  46401. }
  46402. var eexecBlock = getEexecBlock(file, eexecBlockLength);
  46403. eexecBlockLength = eexecBlock.length;
  46404. var eexecBlockParser = new Type1Parser(eexecBlock.stream, true, SEAC_ANALYSIS_ENABLED);
  46405. var data = eexecBlockParser.extractFontProgram();
  46406. for (var info in data.properties) {
  46407. properties[info] = data.properties[info];
  46408. }
  46409. var charstrings = data.charstrings;
  46410. var type2Charstrings = this.getType2Charstrings(charstrings);
  46411. var subrs = this.getType2Subrs(data.subrs);
  46412. this.charstrings = charstrings;
  46413. this.data = this.wrap(name, type2Charstrings, this.charstrings, subrs, properties);
  46414. this.seacs = this.getSeacs(data.charstrings);
  46415. }
  46416. Type1Font.prototype = {
  46417. get numGlyphs() {
  46418. return this.charstrings.length + 1;
  46419. },
  46420. getCharset: function Type1Font_getCharset() {
  46421. var charset = ['.notdef'];
  46422. var charstrings = this.charstrings;
  46423. for (var glyphId = 0; glyphId < charstrings.length; glyphId++) {
  46424. charset.push(charstrings[glyphId].glyphName);
  46425. }
  46426. return charset;
  46427. },
  46428. getGlyphMapping: function Type1Font_getGlyphMapping(properties) {
  46429. var charstrings = this.charstrings;
  46430. var glyphNames = ['.notdef'], glyphId;
  46431. for (glyphId = 0; glyphId < charstrings.length; glyphId++) {
  46432. glyphNames.push(charstrings[glyphId].glyphName);
  46433. }
  46434. var encoding = properties.builtInEncoding;
  46435. if (encoding) {
  46436. var builtInEncoding = Object.create(null);
  46437. for (var charCode in encoding) {
  46438. glyphId = glyphNames.indexOf(encoding[charCode]);
  46439. if (glyphId >= 0) {
  46440. builtInEncoding[charCode] = glyphId;
  46441. }
  46442. }
  46443. }
  46444. return type1FontGlyphMapping(properties, builtInEncoding, glyphNames);
  46445. },
  46446. getSeacs: function Type1Font_getSeacs(charstrings) {
  46447. var i, ii;
  46448. var seacMap = [];
  46449. for (i = 0, ii = charstrings.length; i < ii; i++) {
  46450. var charstring = charstrings[i];
  46451. if (charstring.seac) {
  46452. seacMap[i + 1] = charstring.seac;
  46453. }
  46454. }
  46455. return seacMap;
  46456. },
  46457. getType2Charstrings: function Type1Font_getType2Charstrings(type1Charstrings) {
  46458. var type2Charstrings = [];
  46459. for (var i = 0, ii = type1Charstrings.length; i < ii; i++) {
  46460. type2Charstrings.push(type1Charstrings[i].charstring);
  46461. }
  46462. return type2Charstrings;
  46463. },
  46464. getType2Subrs: function Type1Font_getType2Subrs(type1Subrs) {
  46465. var bias = 0;
  46466. var count = type1Subrs.length;
  46467. if (count < 1133) {
  46468. bias = 107;
  46469. } else if (count < 33769) {
  46470. bias = 1131;
  46471. } else {
  46472. bias = 32768;
  46473. }
  46474. var type2Subrs = [];
  46475. var i;
  46476. for (i = 0; i < bias; i++) {
  46477. type2Subrs.push([0x0B]);
  46478. }
  46479. for (i = 0; i < count; i++) {
  46480. type2Subrs.push(type1Subrs[i]);
  46481. }
  46482. return type2Subrs;
  46483. },
  46484. wrap: function Type1Font_wrap(name, glyphs, charstrings, subrs, properties) {
  46485. var cff = new CFF();
  46486. cff.header = new CFFHeader(1, 0, 4, 4);
  46487. cff.names = [name];
  46488. var topDict = new CFFTopDict();
  46489. topDict.setByName('version', 391);
  46490. topDict.setByName('Notice', 392);
  46491. topDict.setByName('FullName', 393);
  46492. topDict.setByName('FamilyName', 394);
  46493. topDict.setByName('Weight', 395);
  46494. topDict.setByName('Encoding', null);
  46495. topDict.setByName('FontMatrix', properties.fontMatrix);
  46496. topDict.setByName('FontBBox', properties.bbox);
  46497. topDict.setByName('charset', null);
  46498. topDict.setByName('CharStrings', null);
  46499. topDict.setByName('Private', null);
  46500. cff.topDict = topDict;
  46501. var strings = new CFFStrings();
  46502. strings.add('Version 0.11');
  46503. strings.add('See original notice');
  46504. strings.add(name);
  46505. strings.add(name);
  46506. strings.add('Medium');
  46507. cff.strings = strings;
  46508. cff.globalSubrIndex = new CFFIndex();
  46509. var count = glyphs.length;
  46510. var charsetArray = [0];
  46511. var i, ii;
  46512. for (i = 0; i < count; i++) {
  46513. var index = CFFStandardStrings.indexOf(charstrings[i].glyphName);
  46514. if (index === -1) {
  46515. index = 0;
  46516. }
  46517. charsetArray.push(index >> 8 & 0xff, index & 0xff);
  46518. }
  46519. cff.charset = new CFFCharset(false, 0, [], charsetArray);
  46520. var charStringsIndex = new CFFIndex();
  46521. charStringsIndex.add([
  46522. 0x8B,
  46523. 0x0E
  46524. ]);
  46525. for (i = 0; i < count; i++) {
  46526. var glyph = glyphs[i];
  46527. if (glyph.length === 0) {
  46528. charStringsIndex.add([
  46529. 0x8B,
  46530. 0x0E
  46531. ]);
  46532. continue;
  46533. }
  46534. charStringsIndex.add(glyph);
  46535. }
  46536. cff.charStrings = charStringsIndex;
  46537. var privateDict = new CFFPrivateDict();
  46538. privateDict.setByName('Subrs', null);
  46539. var fields = [
  46540. 'BlueValues',
  46541. 'OtherBlues',
  46542. 'FamilyBlues',
  46543. 'FamilyOtherBlues',
  46544. 'StemSnapH',
  46545. 'StemSnapV',
  46546. 'BlueShift',
  46547. 'BlueFuzz',
  46548. 'BlueScale',
  46549. 'LanguageGroup',
  46550. 'ExpansionFactor',
  46551. 'ForceBold',
  46552. 'StdHW',
  46553. 'StdVW'
  46554. ];
  46555. for (i = 0, ii = fields.length; i < ii; i++) {
  46556. var field = fields[i];
  46557. if (!(field in properties.privateData)) {
  46558. continue;
  46559. }
  46560. var value = properties.privateData[field];
  46561. if (isArray(value)) {
  46562. for (var j = value.length - 1; j > 0; j--) {
  46563. value[j] -= value[j - 1];
  46564. }
  46565. }
  46566. privateDict.setByName(field, value);
  46567. }
  46568. cff.topDict.privateDict = privateDict;
  46569. var subrIndex = new CFFIndex();
  46570. for (i = 0, ii = subrs.length; i < ii; i++) {
  46571. subrIndex.add(subrs[i]);
  46572. }
  46573. privateDict.subrsIndex = subrIndex;
  46574. var compiler = new CFFCompiler(cff);
  46575. return compiler.compile();
  46576. }
  46577. };
  46578. return Type1Font;
  46579. }();
  46580. var CFFFont = function CFFFontClosure() {
  46581. function CFFFont(file, properties) {
  46582. this.properties = properties;
  46583. var parser = new CFFParser(file, properties, SEAC_ANALYSIS_ENABLED);
  46584. this.cff = parser.parse();
  46585. var compiler = new CFFCompiler(this.cff);
  46586. this.seacs = this.cff.seacs;
  46587. try {
  46588. this.data = compiler.compile();
  46589. } catch (e) {
  46590. warn('Failed to compile font ' + properties.loadedName);
  46591. this.data = file;
  46592. }
  46593. }
  46594. CFFFont.prototype = {
  46595. get numGlyphs() {
  46596. return this.cff.charStrings.count;
  46597. },
  46598. getCharset: function CFFFont_getCharset() {
  46599. return this.cff.charset.charset;
  46600. },
  46601. getGlyphMapping: function CFFFont_getGlyphMapping() {
  46602. var cff = this.cff;
  46603. var properties = this.properties;
  46604. var charsets = cff.charset.charset;
  46605. var charCodeToGlyphId;
  46606. var glyphId;
  46607. if (properties.composite) {
  46608. charCodeToGlyphId = Object.create(null);
  46609. if (cff.isCIDFont) {
  46610. for (glyphId = 0; glyphId < charsets.length; glyphId++) {
  46611. var cid = charsets[glyphId];
  46612. var charCode = properties.cMap.charCodeOf(cid);
  46613. charCodeToGlyphId[charCode] = glyphId;
  46614. }
  46615. } else {
  46616. for (glyphId = 0; glyphId < cff.charStrings.count; glyphId++) {
  46617. charCodeToGlyphId[glyphId] = glyphId;
  46618. }
  46619. }
  46620. return charCodeToGlyphId;
  46621. }
  46622. var encoding = cff.encoding ? cff.encoding.encoding : null;
  46623. charCodeToGlyphId = type1FontGlyphMapping(properties, encoding, charsets);
  46624. return charCodeToGlyphId;
  46625. }
  46626. };
  46627. return CFFFont;
  46628. }();
  46629. (function checkSeacSupport() {
  46630. if (typeof navigator !== 'undefined' && /Windows/.test(navigator.userAgent)) {
  46631. SEAC_ANALYSIS_ENABLED = true;
  46632. }
  46633. }());
  46634. (function checkChromeWindows() {
  46635. if (typeof navigator !== 'undefined' && /Windows.*Chrome/.test(navigator.userAgent)) {
  46636. SKIP_PRIVATE_USE_RANGE_F000_TO_F01F = true;
  46637. }
  46638. }());
  46639. exports.ErrorFont = ErrorFont;
  46640. exports.Font = Font;
  46641. exports.FontFlags = FontFlags;
  46642. exports.IdentityToUnicodeMap = IdentityToUnicodeMap;
  46643. exports.ToUnicodeMap = ToUnicodeMap;
  46644. exports.getFontType = getFontType;
  46645. /***/ }),
  46646. /* 34 */
  46647. /***/ (function(module, exports, __w_pdfjs_require__) {
  46648. "use strict";
  46649. var sharedUtil = __w_pdfjs_require__(0);
  46650. var corePrimitives = __w_pdfjs_require__(1);
  46651. var coreColorSpace = __w_pdfjs_require__(4);
  46652. var coreStream = __w_pdfjs_require__(2);
  46653. var coreJpx = __w_pdfjs_require__(18);
  46654. var ImageKind = sharedUtil.ImageKind;
  46655. var assert = sharedUtil.assert;
  46656. var error = sharedUtil.error;
  46657. var info = sharedUtil.info;
  46658. var isArray = sharedUtil.isArray;
  46659. var warn = sharedUtil.warn;
  46660. var Name = corePrimitives.Name;
  46661. var isStream = corePrimitives.isStream;
  46662. var ColorSpace = coreColorSpace.ColorSpace;
  46663. var DecodeStream = coreStream.DecodeStream;
  46664. var JpegStream = coreStream.JpegStream;
  46665. var JpxImage = coreJpx.JpxImage;
  46666. var PDFImage = function PDFImageClosure() {
  46667. function handleImageData(image, nativeDecoder) {
  46668. if (nativeDecoder && nativeDecoder.canDecode(image)) {
  46669. return nativeDecoder.decode(image);
  46670. }
  46671. return Promise.resolve(image);
  46672. }
  46673. function decodeAndClamp(value, addend, coefficient, max) {
  46674. value = addend + value * coefficient;
  46675. return value < 0 ? 0 : value > max ? max : value;
  46676. }
  46677. function resizeImageMask(src, bpc, w1, h1, w2, h2) {
  46678. var length = w2 * h2;
  46679. var dest = bpc <= 8 ? new Uint8Array(length) : bpc <= 16 ? new Uint16Array(length) : new Uint32Array(length);
  46680. var xRatio = w1 / w2;
  46681. var yRatio = h1 / h2;
  46682. var i, j, py, newIndex = 0, oldIndex;
  46683. var xScaled = new Uint16Array(w2);
  46684. var w1Scanline = w1;
  46685. for (i = 0; i < w2; i++) {
  46686. xScaled[i] = Math.floor(i * xRatio);
  46687. }
  46688. for (i = 0; i < h2; i++) {
  46689. py = Math.floor(i * yRatio) * w1Scanline;
  46690. for (j = 0; j < w2; j++) {
  46691. oldIndex = py + xScaled[j];
  46692. dest[newIndex++] = src[oldIndex];
  46693. }
  46694. }
  46695. return dest;
  46696. }
  46697. function PDFImage(xref, res, image, inline, smask, mask, isMask) {
  46698. this.image = image;
  46699. var dict = image.dict;
  46700. if (dict.has('Filter')) {
  46701. var filter = dict.get('Filter').name;
  46702. if (filter === 'JPXDecode') {
  46703. var jpxImage = new JpxImage();
  46704. jpxImage.parseImageProperties(image.stream);
  46705. image.stream.reset();
  46706. image.bitsPerComponent = jpxImage.bitsPerComponent;
  46707. image.numComps = jpxImage.componentsCount;
  46708. } else if (filter === 'JBIG2Decode') {
  46709. image.bitsPerComponent = 1;
  46710. image.numComps = 1;
  46711. }
  46712. }
  46713. this.width = dict.get('Width', 'W');
  46714. this.height = dict.get('Height', 'H');
  46715. if (this.width < 1 || this.height < 1) {
  46716. error('Invalid image width: ' + this.width + ' or height: ' + this.height);
  46717. }
  46718. this.interpolate = dict.get('Interpolate', 'I') || false;
  46719. this.imageMask = dict.get('ImageMask', 'IM') || false;
  46720. this.matte = dict.get('Matte') || false;
  46721. var bitsPerComponent = image.bitsPerComponent;
  46722. if (!bitsPerComponent) {
  46723. bitsPerComponent = dict.get('BitsPerComponent', 'BPC');
  46724. if (!bitsPerComponent) {
  46725. if (this.imageMask) {
  46726. bitsPerComponent = 1;
  46727. } else {
  46728. error('Bits per component missing in image: ' + this.imageMask);
  46729. }
  46730. }
  46731. }
  46732. this.bpc = bitsPerComponent;
  46733. if (!this.imageMask) {
  46734. var colorSpace = dict.get('ColorSpace', 'CS');
  46735. if (!colorSpace) {
  46736. info('JPX images (which do not require color spaces)');
  46737. switch (image.numComps) {
  46738. case 1:
  46739. colorSpace = Name.get('DeviceGray');
  46740. break;
  46741. case 3:
  46742. colorSpace = Name.get('DeviceRGB');
  46743. break;
  46744. case 4:
  46745. colorSpace = Name.get('DeviceCMYK');
  46746. break;
  46747. default:
  46748. error('JPX images with ' + this.numComps + ' color components not supported.');
  46749. }
  46750. }
  46751. this.colorSpace = ColorSpace.parse(colorSpace, xref, res);
  46752. this.numComps = this.colorSpace.numComps;
  46753. }
  46754. this.decode = dict.getArray('Decode', 'D');
  46755. this.needsDecode = false;
  46756. if (this.decode && (this.colorSpace && !this.colorSpace.isDefaultDecode(this.decode) || isMask && !ColorSpace.isDefaultDecode(this.decode, 1))) {
  46757. this.needsDecode = true;
  46758. var max = (1 << bitsPerComponent) - 1;
  46759. this.decodeCoefficients = [];
  46760. this.decodeAddends = [];
  46761. for (var i = 0, j = 0; i < this.decode.length; i += 2, ++j) {
  46762. var dmin = this.decode[i];
  46763. var dmax = this.decode[i + 1];
  46764. this.decodeCoefficients[j] = dmax - dmin;
  46765. this.decodeAddends[j] = max * dmin;
  46766. }
  46767. }
  46768. if (smask) {
  46769. this.smask = new PDFImage(xref, res, smask, false);
  46770. } else if (mask) {
  46771. if (isStream(mask)) {
  46772. var maskDict = mask.dict, imageMask = maskDict.get('ImageMask', 'IM');
  46773. if (!imageMask) {
  46774. warn('Ignoring /Mask in image without /ImageMask.');
  46775. } else {
  46776. this.mask = new PDFImage(xref, res, mask, false, null, null, true);
  46777. }
  46778. } else {
  46779. this.mask = mask;
  46780. }
  46781. }
  46782. }
  46783. PDFImage.buildImage = function PDFImage_buildImage(handler, xref, res, image, inline, nativeDecoder) {
  46784. var imagePromise = handleImageData(image, nativeDecoder);
  46785. var smaskPromise;
  46786. var maskPromise;
  46787. var smask = image.dict.get('SMask');
  46788. var mask = image.dict.get('Mask');
  46789. if (smask) {
  46790. smaskPromise = handleImageData(smask, nativeDecoder);
  46791. maskPromise = Promise.resolve(null);
  46792. } else {
  46793. smaskPromise = Promise.resolve(null);
  46794. if (mask) {
  46795. if (isStream(mask)) {
  46796. maskPromise = handleImageData(mask, nativeDecoder);
  46797. } else if (isArray(mask)) {
  46798. maskPromise = Promise.resolve(mask);
  46799. } else {
  46800. warn('Unsupported mask format.');
  46801. maskPromise = Promise.resolve(null);
  46802. }
  46803. } else {
  46804. maskPromise = Promise.resolve(null);
  46805. }
  46806. }
  46807. return Promise.all([
  46808. imagePromise,
  46809. smaskPromise,
  46810. maskPromise
  46811. ]).then(function (results) {
  46812. var imageData = results[0];
  46813. var smaskData = results[1];
  46814. var maskData = results[2];
  46815. return new PDFImage(xref, res, imageData, inline, smaskData, maskData);
  46816. });
  46817. };
  46818. PDFImage.createMask = function PDFImage_createMask(imgArray, width, height, imageIsFromDecodeStream, inverseDecode) {
  46819. var computedLength = (width + 7 >> 3) * height;
  46820. var actualLength = imgArray.byteLength;
  46821. var haveFullData = computedLength === actualLength;
  46822. var data, i;
  46823. if (imageIsFromDecodeStream && (!inverseDecode || haveFullData)) {
  46824. data = imgArray;
  46825. } else if (!inverseDecode) {
  46826. data = new Uint8Array(actualLength);
  46827. data.set(imgArray);
  46828. } else {
  46829. data = new Uint8Array(computedLength);
  46830. data.set(imgArray);
  46831. for (i = actualLength; i < computedLength; i++) {
  46832. data[i] = 0xff;
  46833. }
  46834. }
  46835. if (inverseDecode) {
  46836. for (i = 0; i < actualLength; i++) {
  46837. data[i] = ~data[i];
  46838. }
  46839. }
  46840. return {
  46841. data: data,
  46842. width: width,
  46843. height: height
  46844. };
  46845. };
  46846. PDFImage.prototype = {
  46847. get drawWidth() {
  46848. return Math.max(this.width, this.smask && this.smask.width || 0, this.mask && this.mask.width || 0);
  46849. },
  46850. get drawHeight() {
  46851. return Math.max(this.height, this.smask && this.smask.height || 0, this.mask && this.mask.height || 0);
  46852. },
  46853. decodeBuffer: function PDFImage_decodeBuffer(buffer) {
  46854. var bpc = this.bpc;
  46855. var numComps = this.numComps;
  46856. var decodeAddends = this.decodeAddends;
  46857. var decodeCoefficients = this.decodeCoefficients;
  46858. var max = (1 << bpc) - 1;
  46859. var i, ii;
  46860. if (bpc === 1) {
  46861. for (i = 0, ii = buffer.length; i < ii; i++) {
  46862. buffer[i] = +!buffer[i];
  46863. }
  46864. return;
  46865. }
  46866. var index = 0;
  46867. for (i = 0, ii = this.width * this.height; i < ii; i++) {
  46868. for (var j = 0; j < numComps; j++) {
  46869. buffer[index] = decodeAndClamp(buffer[index], decodeAddends[j], decodeCoefficients[j], max);
  46870. index++;
  46871. }
  46872. }
  46873. },
  46874. getComponents: function PDFImage_getComponents(buffer) {
  46875. var bpc = this.bpc;
  46876. if (bpc === 8) {
  46877. return buffer;
  46878. }
  46879. var width = this.width;
  46880. var height = this.height;
  46881. var numComps = this.numComps;
  46882. var length = width * height * numComps;
  46883. var bufferPos = 0;
  46884. var output = bpc <= 8 ? new Uint8Array(length) : bpc <= 16 ? new Uint16Array(length) : new Uint32Array(length);
  46885. var rowComps = width * numComps;
  46886. var max = (1 << bpc) - 1;
  46887. var i = 0, ii, buf;
  46888. if (bpc === 1) {
  46889. var mask, loop1End, loop2End;
  46890. for (var j = 0; j < height; j++) {
  46891. loop1End = i + (rowComps & ~7);
  46892. loop2End = i + rowComps;
  46893. while (i < loop1End) {
  46894. buf = buffer[bufferPos++];
  46895. output[i] = buf >> 7 & 1;
  46896. output[i + 1] = buf >> 6 & 1;
  46897. output[i + 2] = buf >> 5 & 1;
  46898. output[i + 3] = buf >> 4 & 1;
  46899. output[i + 4] = buf >> 3 & 1;
  46900. output[i + 5] = buf >> 2 & 1;
  46901. output[i + 6] = buf >> 1 & 1;
  46902. output[i + 7] = buf & 1;
  46903. i += 8;
  46904. }
  46905. if (i < loop2End) {
  46906. buf = buffer[bufferPos++];
  46907. mask = 128;
  46908. while (i < loop2End) {
  46909. output[i++] = +!!(buf & mask);
  46910. mask >>= 1;
  46911. }
  46912. }
  46913. }
  46914. } else {
  46915. var bits = 0;
  46916. buf = 0;
  46917. for (i = 0, ii = length; i < ii; ++i) {
  46918. if (i % rowComps === 0) {
  46919. buf = 0;
  46920. bits = 0;
  46921. }
  46922. while (bits < bpc) {
  46923. buf = buf << 8 | buffer[bufferPos++];
  46924. bits += 8;
  46925. }
  46926. var remainingBits = bits - bpc;
  46927. var value = buf >> remainingBits;
  46928. output[i] = value < 0 ? 0 : value > max ? max : value;
  46929. buf = buf & (1 << remainingBits) - 1;
  46930. bits = remainingBits;
  46931. }
  46932. }
  46933. return output;
  46934. },
  46935. fillOpacity: function PDFImage_fillOpacity(rgbaBuf, width, height, actualHeight, image) {
  46936. var smask = this.smask;
  46937. var mask = this.mask;
  46938. var alphaBuf, sw, sh, i, ii, j;
  46939. if (smask) {
  46940. sw = smask.width;
  46941. sh = smask.height;
  46942. alphaBuf = new Uint8Array(sw * sh);
  46943. smask.fillGrayBuffer(alphaBuf);
  46944. if (sw !== width || sh !== height) {
  46945. alphaBuf = resizeImageMask(alphaBuf, smask.bpc, sw, sh, width, height);
  46946. }
  46947. } else if (mask) {
  46948. if (mask instanceof PDFImage) {
  46949. sw = mask.width;
  46950. sh = mask.height;
  46951. alphaBuf = new Uint8Array(sw * sh);
  46952. mask.numComps = 1;
  46953. mask.fillGrayBuffer(alphaBuf);
  46954. for (i = 0, ii = sw * sh; i < ii; ++i) {
  46955. alphaBuf[i] = 255 - alphaBuf[i];
  46956. }
  46957. if (sw !== width || sh !== height) {
  46958. alphaBuf = resizeImageMask(alphaBuf, mask.bpc, sw, sh, width, height);
  46959. }
  46960. } else if (isArray(mask)) {
  46961. alphaBuf = new Uint8Array(width * height);
  46962. var numComps = this.numComps;
  46963. for (i = 0, ii = width * height; i < ii; ++i) {
  46964. var opacity = 0;
  46965. var imageOffset = i * numComps;
  46966. for (j = 0; j < numComps; ++j) {
  46967. var color = image[imageOffset + j];
  46968. var maskOffset = j * 2;
  46969. if (color < mask[maskOffset] || color > mask[maskOffset + 1]) {
  46970. opacity = 255;
  46971. break;
  46972. }
  46973. }
  46974. alphaBuf[i] = opacity;
  46975. }
  46976. } else {
  46977. error('Unknown mask format.');
  46978. }
  46979. }
  46980. if (alphaBuf) {
  46981. for (i = 0, j = 3, ii = width * actualHeight; i < ii; ++i, j += 4) {
  46982. rgbaBuf[j] = alphaBuf[i];
  46983. }
  46984. } else {
  46985. for (i = 0, j = 3, ii = width * actualHeight; i < ii; ++i, j += 4) {
  46986. rgbaBuf[j] = 255;
  46987. }
  46988. }
  46989. },
  46990. undoPreblend: function PDFImage_undoPreblend(buffer, width, height) {
  46991. var matte = this.smask && this.smask.matte;
  46992. if (!matte) {
  46993. return;
  46994. }
  46995. var matteRgb = this.colorSpace.getRgb(matte, 0);
  46996. var matteR = matteRgb[0];
  46997. var matteG = matteRgb[1];
  46998. var matteB = matteRgb[2];
  46999. var length = width * height * 4;
  47000. var r, g, b;
  47001. for (var i = 0; i < length; i += 4) {
  47002. var alpha = buffer[i + 3];
  47003. if (alpha === 0) {
  47004. buffer[i] = 255;
  47005. buffer[i + 1] = 255;
  47006. buffer[i + 2] = 255;
  47007. continue;
  47008. }
  47009. var k = 255 / alpha;
  47010. r = (buffer[i] - matteR) * k + matteR;
  47011. g = (buffer[i + 1] - matteG) * k + matteG;
  47012. b = (buffer[i + 2] - matteB) * k + matteB;
  47013. buffer[i] = r <= 0 ? 0 : r >= 255 ? 255 : r | 0;
  47014. buffer[i + 1] = g <= 0 ? 0 : g >= 255 ? 255 : g | 0;
  47015. buffer[i + 2] = b <= 0 ? 0 : b >= 255 ? 255 : b | 0;
  47016. }
  47017. },
  47018. createImageData: function PDFImage_createImageData(forceRGBA) {
  47019. var drawWidth = this.drawWidth;
  47020. var drawHeight = this.drawHeight;
  47021. var imgData = {
  47022. width: drawWidth,
  47023. height: drawHeight
  47024. };
  47025. var numComps = this.numComps;
  47026. var originalWidth = this.width;
  47027. var originalHeight = this.height;
  47028. var bpc = this.bpc;
  47029. var rowBytes = originalWidth * numComps * bpc + 7 >> 3;
  47030. var imgArray;
  47031. if (!forceRGBA) {
  47032. var kind;
  47033. if (this.colorSpace.name === 'DeviceGray' && bpc === 1) {
  47034. kind = ImageKind.GRAYSCALE_1BPP;
  47035. } else if (this.colorSpace.name === 'DeviceRGB' && bpc === 8 && !this.needsDecode) {
  47036. kind = ImageKind.RGB_24BPP;
  47037. }
  47038. if (kind && !this.smask && !this.mask && drawWidth === originalWidth && drawHeight === originalHeight) {
  47039. imgData.kind = kind;
  47040. imgArray = this.getImageBytes(originalHeight * rowBytes);
  47041. if (this.image instanceof DecodeStream) {
  47042. imgData.data = imgArray;
  47043. } else {
  47044. var newArray = new Uint8Array(imgArray.length);
  47045. newArray.set(imgArray);
  47046. imgData.data = newArray;
  47047. }
  47048. if (this.needsDecode) {
  47049. assert(kind === ImageKind.GRAYSCALE_1BPP);
  47050. var buffer = imgData.data;
  47051. for (var i = 0, ii = buffer.length; i < ii; i++) {
  47052. buffer[i] ^= 0xff;
  47053. }
  47054. }
  47055. return imgData;
  47056. }
  47057. if (this.image instanceof JpegStream && !this.smask && !this.mask && (this.colorSpace.name === 'DeviceGray' || this.colorSpace.name === 'DeviceRGB' || this.colorSpace.name === 'DeviceCMYK')) {
  47058. imgData.kind = ImageKind.RGB_24BPP;
  47059. imgData.data = this.getImageBytes(originalHeight * rowBytes, drawWidth, drawHeight, true);
  47060. return imgData;
  47061. }
  47062. }
  47063. imgArray = this.getImageBytes(originalHeight * rowBytes);
  47064. var actualHeight = 0 | imgArray.length / rowBytes * drawHeight / originalHeight;
  47065. var comps = this.getComponents(imgArray);
  47066. var alpha01, maybeUndoPreblend;
  47067. if (!forceRGBA && !this.smask && !this.mask) {
  47068. imgData.kind = ImageKind.RGB_24BPP;
  47069. imgData.data = new Uint8Array(drawWidth * drawHeight * 3);
  47070. alpha01 = 0;
  47071. maybeUndoPreblend = false;
  47072. } else {
  47073. imgData.kind = ImageKind.RGBA_32BPP;
  47074. imgData.data = new Uint8Array(drawWidth * drawHeight * 4);
  47075. alpha01 = 1;
  47076. maybeUndoPreblend = true;
  47077. this.fillOpacity(imgData.data, drawWidth, drawHeight, actualHeight, comps);
  47078. }
  47079. if (this.needsDecode) {
  47080. this.decodeBuffer(comps);
  47081. }
  47082. this.colorSpace.fillRgb(imgData.data, originalWidth, originalHeight, drawWidth, drawHeight, actualHeight, bpc, comps, alpha01);
  47083. if (maybeUndoPreblend) {
  47084. this.undoPreblend(imgData.data, drawWidth, actualHeight);
  47085. }
  47086. return imgData;
  47087. },
  47088. fillGrayBuffer: function PDFImage_fillGrayBuffer(buffer) {
  47089. var numComps = this.numComps;
  47090. if (numComps !== 1) {
  47091. error('Reading gray scale from a color image: ' + numComps);
  47092. }
  47093. var width = this.width;
  47094. var height = this.height;
  47095. var bpc = this.bpc;
  47096. var rowBytes = width * numComps * bpc + 7 >> 3;
  47097. var imgArray = this.getImageBytes(height * rowBytes);
  47098. var comps = this.getComponents(imgArray);
  47099. var i, length;
  47100. if (bpc === 1) {
  47101. length = width * height;
  47102. if (this.needsDecode) {
  47103. for (i = 0; i < length; ++i) {
  47104. buffer[i] = comps[i] - 1 & 255;
  47105. }
  47106. } else {
  47107. for (i = 0; i < length; ++i) {
  47108. buffer[i] = -comps[i] & 255;
  47109. }
  47110. }
  47111. return;
  47112. }
  47113. if (this.needsDecode) {
  47114. this.decodeBuffer(comps);
  47115. }
  47116. length = width * height;
  47117. var scale = 255 / ((1 << bpc) - 1);
  47118. for (i = 0; i < length; ++i) {
  47119. buffer[i] = scale * comps[i] | 0;
  47120. }
  47121. },
  47122. getImageBytes: function PDFImage_getImageBytes(length, drawWidth, drawHeight, forceRGB) {
  47123. this.image.reset();
  47124. this.image.drawWidth = drawWidth || this.width;
  47125. this.image.drawHeight = drawHeight || this.height;
  47126. this.image.forceRGB = !!forceRGB;
  47127. return this.image.getBytes(length);
  47128. }
  47129. };
  47130. return PDFImage;
  47131. }();
  47132. exports.PDFImage = PDFImage;
  47133. /***/ }),
  47134. /* 35 */
  47135. /***/ (function(module, exports, __w_pdfjs_require__) {
  47136. "use strict";
  47137. var sharedUtil = __w_pdfjs_require__(0);
  47138. var coreArithmeticDecoder = __w_pdfjs_require__(13);
  47139. var error = sharedUtil.error;
  47140. var log2 = sharedUtil.log2;
  47141. var readInt8 = sharedUtil.readInt8;
  47142. var readUint16 = sharedUtil.readUint16;
  47143. var readUint32 = sharedUtil.readUint32;
  47144. var shadow = sharedUtil.shadow;
  47145. var ArithmeticDecoder = coreArithmeticDecoder.ArithmeticDecoder;
  47146. var Jbig2Image = function Jbig2ImageClosure() {
  47147. function ContextCache() {
  47148. }
  47149. ContextCache.prototype = {
  47150. getContexts: function (id) {
  47151. if (id in this) {
  47152. return this[id];
  47153. }
  47154. return this[id] = new Int8Array(1 << 16);
  47155. }
  47156. };
  47157. function DecodingContext(data, start, end) {
  47158. this.data = data;
  47159. this.start = start;
  47160. this.end = end;
  47161. }
  47162. DecodingContext.prototype = {
  47163. get decoder() {
  47164. var decoder = new ArithmeticDecoder(this.data, this.start, this.end);
  47165. return shadow(this, 'decoder', decoder);
  47166. },
  47167. get contextCache() {
  47168. var cache = new ContextCache();
  47169. return shadow(this, 'contextCache', cache);
  47170. }
  47171. };
  47172. function decodeInteger(contextCache, procedure, decoder) {
  47173. var contexts = contextCache.getContexts(procedure);
  47174. var prev = 1;
  47175. function readBits(length) {
  47176. var v = 0;
  47177. for (var i = 0; i < length; i++) {
  47178. var bit = decoder.readBit(contexts, prev);
  47179. prev = prev < 256 ? prev << 1 | bit : (prev << 1 | bit) & 511 | 256;
  47180. v = v << 1 | bit;
  47181. }
  47182. return v >>> 0;
  47183. }
  47184. var sign = readBits(1);
  47185. 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);
  47186. return sign === 0 ? value : value > 0 ? -value : null;
  47187. }
  47188. function decodeIAID(contextCache, decoder, codeLength) {
  47189. var contexts = contextCache.getContexts('IAID');
  47190. var prev = 1;
  47191. for (var i = 0; i < codeLength; i++) {
  47192. var bit = decoder.readBit(contexts, prev);
  47193. prev = prev << 1 | bit;
  47194. }
  47195. if (codeLength < 31) {
  47196. return prev & (1 << codeLength) - 1;
  47197. }
  47198. return prev & 0x7FFFFFFF;
  47199. }
  47200. var SegmentTypes = [
  47201. 'SymbolDictionary',
  47202. null,
  47203. null,
  47204. null,
  47205. 'IntermediateTextRegion',
  47206. null,
  47207. 'ImmediateTextRegion',
  47208. 'ImmediateLosslessTextRegion',
  47209. null,
  47210. null,
  47211. null,
  47212. null,
  47213. null,
  47214. null,
  47215. null,
  47216. null,
  47217. 'patternDictionary',
  47218. null,
  47219. null,
  47220. null,
  47221. 'IntermediateHalftoneRegion',
  47222. null,
  47223. 'ImmediateHalftoneRegion',
  47224. 'ImmediateLosslessHalftoneRegion',
  47225. null,
  47226. null,
  47227. null,
  47228. null,
  47229. null,
  47230. null,
  47231. null,
  47232. null,
  47233. null,
  47234. null,
  47235. null,
  47236. null,
  47237. 'IntermediateGenericRegion',
  47238. null,
  47239. 'ImmediateGenericRegion',
  47240. 'ImmediateLosslessGenericRegion',
  47241. 'IntermediateGenericRefinementRegion',
  47242. null,
  47243. 'ImmediateGenericRefinementRegion',
  47244. 'ImmediateLosslessGenericRefinementRegion',
  47245. null,
  47246. null,
  47247. null,
  47248. null,
  47249. 'PageInformation',
  47250. 'EndOfPage',
  47251. 'EndOfStripe',
  47252. 'EndOfFile',
  47253. 'Profiles',
  47254. 'Tables',
  47255. null,
  47256. null,
  47257. null,
  47258. null,
  47259. null,
  47260. null,
  47261. null,
  47262. null,
  47263. 'Extension'
  47264. ];
  47265. var CodingTemplates = [
  47266. [
  47267. {
  47268. x: -1,
  47269. y: -2
  47270. },
  47271. {
  47272. x: 0,
  47273. y: -2
  47274. },
  47275. {
  47276. x: 1,
  47277. y: -2
  47278. },
  47279. {
  47280. x: -2,
  47281. y: -1
  47282. },
  47283. {
  47284. x: -1,
  47285. y: -1
  47286. },
  47287. {
  47288. x: 0,
  47289. y: -1
  47290. },
  47291. {
  47292. x: 1,
  47293. y: -1
  47294. },
  47295. {
  47296. x: 2,
  47297. y: -1
  47298. },
  47299. {
  47300. x: -4,
  47301. y: 0
  47302. },
  47303. {
  47304. x: -3,
  47305. y: 0
  47306. },
  47307. {
  47308. x: -2,
  47309. y: 0
  47310. },
  47311. {
  47312. x: -1,
  47313. y: 0
  47314. }
  47315. ],
  47316. [
  47317. {
  47318. x: -1,
  47319. y: -2
  47320. },
  47321. {
  47322. x: 0,
  47323. y: -2
  47324. },
  47325. {
  47326. x: 1,
  47327. y: -2
  47328. },
  47329. {
  47330. x: 2,
  47331. y: -2
  47332. },
  47333. {
  47334. x: -2,
  47335. y: -1
  47336. },
  47337. {
  47338. x: -1,
  47339. y: -1
  47340. },
  47341. {
  47342. x: 0,
  47343. y: -1
  47344. },
  47345. {
  47346. x: 1,
  47347. y: -1
  47348. },
  47349. {
  47350. x: 2,
  47351. y: -1
  47352. },
  47353. {
  47354. x: -3,
  47355. y: 0
  47356. },
  47357. {
  47358. x: -2,
  47359. y: 0
  47360. },
  47361. {
  47362. x: -1,
  47363. y: 0
  47364. }
  47365. ],
  47366. [
  47367. {
  47368. x: -1,
  47369. y: -2
  47370. },
  47371. {
  47372. x: 0,
  47373. y: -2
  47374. },
  47375. {
  47376. x: 1,
  47377. y: -2
  47378. },
  47379. {
  47380. x: -2,
  47381. y: -1
  47382. },
  47383. {
  47384. x: -1,
  47385. y: -1
  47386. },
  47387. {
  47388. x: 0,
  47389. y: -1
  47390. },
  47391. {
  47392. x: 1,
  47393. y: -1
  47394. },
  47395. {
  47396. x: -2,
  47397. y: 0
  47398. },
  47399. {
  47400. x: -1,
  47401. y: 0
  47402. }
  47403. ],
  47404. [
  47405. {
  47406. x: -3,
  47407. y: -1
  47408. },
  47409. {
  47410. x: -2,
  47411. y: -1
  47412. },
  47413. {
  47414. x: -1,
  47415. y: -1
  47416. },
  47417. {
  47418. x: 0,
  47419. y: -1
  47420. },
  47421. {
  47422. x: 1,
  47423. y: -1
  47424. },
  47425. {
  47426. x: -4,
  47427. y: 0
  47428. },
  47429. {
  47430. x: -3,
  47431. y: 0
  47432. },
  47433. {
  47434. x: -2,
  47435. y: 0
  47436. },
  47437. {
  47438. x: -1,
  47439. y: 0
  47440. }
  47441. ]
  47442. ];
  47443. var RefinementTemplates = [
  47444. {
  47445. coding: [
  47446. {
  47447. x: 0,
  47448. y: -1
  47449. },
  47450. {
  47451. x: 1,
  47452. y: -1
  47453. },
  47454. {
  47455. x: -1,
  47456. y: 0
  47457. }
  47458. ],
  47459. reference: [
  47460. {
  47461. x: 0,
  47462. y: -1
  47463. },
  47464. {
  47465. x: 1,
  47466. y: -1
  47467. },
  47468. {
  47469. x: -1,
  47470. y: 0
  47471. },
  47472. {
  47473. x: 0,
  47474. y: 0
  47475. },
  47476. {
  47477. x: 1,
  47478. y: 0
  47479. },
  47480. {
  47481. x: -1,
  47482. y: 1
  47483. },
  47484. {
  47485. x: 0,
  47486. y: 1
  47487. },
  47488. {
  47489. x: 1,
  47490. y: 1
  47491. }
  47492. ]
  47493. },
  47494. {
  47495. coding: [
  47496. {
  47497. x: -1,
  47498. y: -1
  47499. },
  47500. {
  47501. x: 0,
  47502. y: -1
  47503. },
  47504. {
  47505. x: 1,
  47506. y: -1
  47507. },
  47508. {
  47509. x: -1,
  47510. y: 0
  47511. }
  47512. ],
  47513. reference: [
  47514. {
  47515. x: 0,
  47516. y: -1
  47517. },
  47518. {
  47519. x: -1,
  47520. y: 0
  47521. },
  47522. {
  47523. x: 0,
  47524. y: 0
  47525. },
  47526. {
  47527. x: 1,
  47528. y: 0
  47529. },
  47530. {
  47531. x: 0,
  47532. y: 1
  47533. },
  47534. {
  47535. x: 1,
  47536. y: 1
  47537. }
  47538. ]
  47539. }
  47540. ];
  47541. var ReusedContexts = [
  47542. 0x9B25,
  47543. 0x0795,
  47544. 0x00E5,
  47545. 0x0195
  47546. ];
  47547. var RefinementReusedContexts = [
  47548. 0x0020,
  47549. 0x0008
  47550. ];
  47551. function decodeBitmapTemplate0(width, height, decodingContext) {
  47552. var decoder = decodingContext.decoder;
  47553. var contexts = decodingContext.contextCache.getContexts('GB');
  47554. var contextLabel, i, j, pixel, row, row1, row2, bitmap = [];
  47555. var OLD_PIXEL_MASK = 0x7BF7;
  47556. for (i = 0; i < height; i++) {
  47557. row = bitmap[i] = new Uint8Array(width);
  47558. row1 = i < 1 ? row : bitmap[i - 1];
  47559. row2 = i < 2 ? row : bitmap[i - 2];
  47560. contextLabel = row2[0] << 13 | row2[1] << 12 | row2[2] << 11 | row1[0] << 7 | row1[1] << 6 | row1[2] << 5 | row1[3] << 4;
  47561. for (j = 0; j < width; j++) {
  47562. row[j] = pixel = decoder.readBit(contexts, contextLabel);
  47563. contextLabel = (contextLabel & OLD_PIXEL_MASK) << 1 | (j + 3 < width ? row2[j + 3] << 11 : 0) | (j + 4 < width ? row1[j + 4] << 4 : 0) | pixel;
  47564. }
  47565. }
  47566. return bitmap;
  47567. }
  47568. function decodeBitmap(mmr, width, height, templateIndex, prediction, skip, at, decodingContext) {
  47569. if (mmr) {
  47570. error('JBIG2 error: MMR encoding is not supported');
  47571. }
  47572. 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) {
  47573. return decodeBitmapTemplate0(width, height, decodingContext);
  47574. }
  47575. var useskip = !!skip;
  47576. var template = CodingTemplates[templateIndex].concat(at);
  47577. template.sort(function (a, b) {
  47578. return a.y - b.y || a.x - b.x;
  47579. });
  47580. var templateLength = template.length;
  47581. var templateX = new Int8Array(templateLength);
  47582. var templateY = new Int8Array(templateLength);
  47583. var changingTemplateEntries = [];
  47584. var reuseMask = 0, minX = 0, maxX = 0, minY = 0;
  47585. var c, k;
  47586. for (k = 0; k < templateLength; k++) {
  47587. templateX[k] = template[k].x;
  47588. templateY[k] = template[k].y;
  47589. minX = Math.min(minX, template[k].x);
  47590. maxX = Math.max(maxX, template[k].x);
  47591. minY = Math.min(minY, template[k].y);
  47592. if (k < templateLength - 1 && template[k].y === template[k + 1].y && template[k].x === template[k + 1].x - 1) {
  47593. reuseMask |= 1 << templateLength - 1 - k;
  47594. } else {
  47595. changingTemplateEntries.push(k);
  47596. }
  47597. }
  47598. var changingEntriesLength = changingTemplateEntries.length;
  47599. var changingTemplateX = new Int8Array(changingEntriesLength);
  47600. var changingTemplateY = new Int8Array(changingEntriesLength);
  47601. var changingTemplateBit = new Uint16Array(changingEntriesLength);
  47602. for (c = 0; c < changingEntriesLength; c++) {
  47603. k = changingTemplateEntries[c];
  47604. changingTemplateX[c] = template[k].x;
  47605. changingTemplateY[c] = template[k].y;
  47606. changingTemplateBit[c] = 1 << templateLength - 1 - k;
  47607. }
  47608. var sbb_left = -minX;
  47609. var sbb_top = -minY;
  47610. var sbb_right = width - maxX;
  47611. var pseudoPixelContext = ReusedContexts[templateIndex];
  47612. var row = new Uint8Array(width);
  47613. var bitmap = [];
  47614. var decoder = decodingContext.decoder;
  47615. var contexts = decodingContext.contextCache.getContexts('GB');
  47616. var ltp = 0, j, i0, j0, contextLabel = 0, bit, shift;
  47617. for (var i = 0; i < height; i++) {
  47618. if (prediction) {
  47619. var sltp = decoder.readBit(contexts, pseudoPixelContext);
  47620. ltp ^= sltp;
  47621. if (ltp) {
  47622. bitmap.push(row);
  47623. continue;
  47624. }
  47625. }
  47626. row = new Uint8Array(row);
  47627. bitmap.push(row);
  47628. for (j = 0; j < width; j++) {
  47629. if (useskip && skip[i][j]) {
  47630. row[j] = 0;
  47631. continue;
  47632. }
  47633. if (j >= sbb_left && j < sbb_right && i >= sbb_top) {
  47634. contextLabel = contextLabel << 1 & reuseMask;
  47635. for (k = 0; k < changingEntriesLength; k++) {
  47636. i0 = i + changingTemplateY[k];
  47637. j0 = j + changingTemplateX[k];
  47638. bit = bitmap[i0][j0];
  47639. if (bit) {
  47640. bit = changingTemplateBit[k];
  47641. contextLabel |= bit;
  47642. }
  47643. }
  47644. } else {
  47645. contextLabel = 0;
  47646. shift = templateLength - 1;
  47647. for (k = 0; k < templateLength; k++, shift--) {
  47648. j0 = j + templateX[k];
  47649. if (j0 >= 0 && j0 < width) {
  47650. i0 = i + templateY[k];
  47651. if (i0 >= 0) {
  47652. bit = bitmap[i0][j0];
  47653. if (bit) {
  47654. contextLabel |= bit << shift;
  47655. }
  47656. }
  47657. }
  47658. }
  47659. }
  47660. var pixel = decoder.readBit(contexts, contextLabel);
  47661. row[j] = pixel;
  47662. }
  47663. }
  47664. return bitmap;
  47665. }
  47666. function decodeRefinement(width, height, templateIndex, referenceBitmap, offsetX, offsetY, prediction, at, decodingContext) {
  47667. var codingTemplate = RefinementTemplates[templateIndex].coding;
  47668. if (templateIndex === 0) {
  47669. codingTemplate = codingTemplate.concat([at[0]]);
  47670. }
  47671. var codingTemplateLength = codingTemplate.length;
  47672. var codingTemplateX = new Int32Array(codingTemplateLength);
  47673. var codingTemplateY = new Int32Array(codingTemplateLength);
  47674. var k;
  47675. for (k = 0; k < codingTemplateLength; k++) {
  47676. codingTemplateX[k] = codingTemplate[k].x;
  47677. codingTemplateY[k] = codingTemplate[k].y;
  47678. }
  47679. var referenceTemplate = RefinementTemplates[templateIndex].reference;
  47680. if (templateIndex === 0) {
  47681. referenceTemplate = referenceTemplate.concat([at[1]]);
  47682. }
  47683. var referenceTemplateLength = referenceTemplate.length;
  47684. var referenceTemplateX = new Int32Array(referenceTemplateLength);
  47685. var referenceTemplateY = new Int32Array(referenceTemplateLength);
  47686. for (k = 0; k < referenceTemplateLength; k++) {
  47687. referenceTemplateX[k] = referenceTemplate[k].x;
  47688. referenceTemplateY[k] = referenceTemplate[k].y;
  47689. }
  47690. var referenceWidth = referenceBitmap[0].length;
  47691. var referenceHeight = referenceBitmap.length;
  47692. var pseudoPixelContext = RefinementReusedContexts[templateIndex];
  47693. var bitmap = [];
  47694. var decoder = decodingContext.decoder;
  47695. var contexts = decodingContext.contextCache.getContexts('GR');
  47696. var ltp = 0;
  47697. for (var i = 0; i < height; i++) {
  47698. if (prediction) {
  47699. var sltp = decoder.readBit(contexts, pseudoPixelContext);
  47700. ltp ^= sltp;
  47701. if (ltp) {
  47702. error('JBIG2 error: prediction is not supported');
  47703. }
  47704. }
  47705. var row = new Uint8Array(width);
  47706. bitmap.push(row);
  47707. for (var j = 0; j < width; j++) {
  47708. var i0, j0;
  47709. var contextLabel = 0;
  47710. for (k = 0; k < codingTemplateLength; k++) {
  47711. i0 = i + codingTemplateY[k];
  47712. j0 = j + codingTemplateX[k];
  47713. if (i0 < 0 || j0 < 0 || j0 >= width) {
  47714. contextLabel <<= 1;
  47715. } else {
  47716. contextLabel = contextLabel << 1 | bitmap[i0][j0];
  47717. }
  47718. }
  47719. for (k = 0; k < referenceTemplateLength; k++) {
  47720. i0 = i + referenceTemplateY[k] + offsetY;
  47721. j0 = j + referenceTemplateX[k] + offsetX;
  47722. if (i0 < 0 || i0 >= referenceHeight || j0 < 0 || j0 >= referenceWidth) {
  47723. contextLabel <<= 1;
  47724. } else {
  47725. contextLabel = contextLabel << 1 | referenceBitmap[i0][j0];
  47726. }
  47727. }
  47728. var pixel = decoder.readBit(contexts, contextLabel);
  47729. row[j] = pixel;
  47730. }
  47731. }
  47732. return bitmap;
  47733. }
  47734. function decodeSymbolDictionary(huffman, refinement, symbols, numberOfNewSymbols, numberOfExportedSymbols, huffmanTables, templateIndex, at, refinementTemplateIndex, refinementAt, decodingContext) {
  47735. if (huffman) {
  47736. error('JBIG2 error: huffman is not supported');
  47737. }
  47738. var newSymbols = [];
  47739. var currentHeight = 0;
  47740. var symbolCodeLength = log2(symbols.length + numberOfNewSymbols);
  47741. var decoder = decodingContext.decoder;
  47742. var contextCache = decodingContext.contextCache;
  47743. while (newSymbols.length < numberOfNewSymbols) {
  47744. var deltaHeight = decodeInteger(contextCache, 'IADH', decoder);
  47745. currentHeight += deltaHeight;
  47746. var currentWidth = 0;
  47747. while (true) {
  47748. var deltaWidth = decodeInteger(contextCache, 'IADW', decoder);
  47749. if (deltaWidth === null) {
  47750. break;
  47751. }
  47752. currentWidth += deltaWidth;
  47753. var bitmap;
  47754. if (refinement) {
  47755. var numberOfInstances = decodeInteger(contextCache, 'IAAI', decoder);
  47756. if (numberOfInstances > 1) {
  47757. bitmap = decodeTextRegion(huffman, refinement, currentWidth, currentHeight, 0, numberOfInstances, 1, symbols.concat(newSymbols), symbolCodeLength, 0, 0, 1, 0, huffmanTables, refinementTemplateIndex, refinementAt, decodingContext);
  47758. } else {
  47759. var symbolId = decodeIAID(contextCache, decoder, symbolCodeLength);
  47760. var rdx = decodeInteger(contextCache, 'IARDX', decoder);
  47761. var rdy = decodeInteger(contextCache, 'IARDY', decoder);
  47762. var symbol = symbolId < symbols.length ? symbols[symbolId] : newSymbols[symbolId - symbols.length];
  47763. bitmap = decodeRefinement(currentWidth, currentHeight, refinementTemplateIndex, symbol, rdx, rdy, false, refinementAt, decodingContext);
  47764. }
  47765. } else {
  47766. bitmap = decodeBitmap(false, currentWidth, currentHeight, templateIndex, false, null, at, decodingContext);
  47767. }
  47768. newSymbols.push(bitmap);
  47769. }
  47770. }
  47771. var exportedSymbols = [];
  47772. var flags = [], currentFlag = false;
  47773. var totalSymbolsLength = symbols.length + numberOfNewSymbols;
  47774. while (flags.length < totalSymbolsLength) {
  47775. var runLength = decodeInteger(contextCache, 'IAEX', decoder);
  47776. while (runLength--) {
  47777. flags.push(currentFlag);
  47778. }
  47779. currentFlag = !currentFlag;
  47780. }
  47781. for (var i = 0, ii = symbols.length; i < ii; i++) {
  47782. if (flags[i]) {
  47783. exportedSymbols.push(symbols[i]);
  47784. }
  47785. }
  47786. for (var j = 0; j < numberOfNewSymbols; i++, j++) {
  47787. if (flags[i]) {
  47788. exportedSymbols.push(newSymbols[j]);
  47789. }
  47790. }
  47791. return exportedSymbols;
  47792. }
  47793. function decodeTextRegion(huffman, refinement, width, height, defaultPixelValue, numberOfSymbolInstances, stripSize, inputSymbols, symbolCodeLength, transposed, dsOffset, referenceCorner, combinationOperator, huffmanTables, refinementTemplateIndex, refinementAt, decodingContext) {
  47794. if (huffman) {
  47795. error('JBIG2 error: huffman is not supported');
  47796. }
  47797. var bitmap = [];
  47798. var i, row;
  47799. for (i = 0; i < height; i++) {
  47800. row = new Uint8Array(width);
  47801. if (defaultPixelValue) {
  47802. for (var j = 0; j < width; j++) {
  47803. row[j] = defaultPixelValue;
  47804. }
  47805. }
  47806. bitmap.push(row);
  47807. }
  47808. var decoder = decodingContext.decoder;
  47809. var contextCache = decodingContext.contextCache;
  47810. var stripT = -decodeInteger(contextCache, 'IADT', decoder);
  47811. var firstS = 0;
  47812. i = 0;
  47813. while (i < numberOfSymbolInstances) {
  47814. var deltaT = decodeInteger(contextCache, 'IADT', decoder);
  47815. stripT += deltaT;
  47816. var deltaFirstS = decodeInteger(contextCache, 'IAFS', decoder);
  47817. firstS += deltaFirstS;
  47818. var currentS = firstS;
  47819. do {
  47820. var currentT = stripSize === 1 ? 0 : decodeInteger(contextCache, 'IAIT', decoder);
  47821. var t = stripSize * stripT + currentT;
  47822. var symbolId = decodeIAID(contextCache, decoder, symbolCodeLength);
  47823. var applyRefinement = refinement && decodeInteger(contextCache, 'IARI', decoder);
  47824. var symbolBitmap = inputSymbols[symbolId];
  47825. var symbolWidth = symbolBitmap[0].length;
  47826. var symbolHeight = symbolBitmap.length;
  47827. if (applyRefinement) {
  47828. var rdw = decodeInteger(contextCache, 'IARDW', decoder);
  47829. var rdh = decodeInteger(contextCache, 'IARDH', decoder);
  47830. var rdx = decodeInteger(contextCache, 'IARDX', decoder);
  47831. var rdy = decodeInteger(contextCache, 'IARDY', decoder);
  47832. symbolWidth += rdw;
  47833. symbolHeight += rdh;
  47834. symbolBitmap = decodeRefinement(symbolWidth, symbolHeight, refinementTemplateIndex, symbolBitmap, (rdw >> 1) + rdx, (rdh >> 1) + rdy, false, refinementAt, decodingContext);
  47835. }
  47836. var offsetT = t - (referenceCorner & 1 ? 0 : symbolHeight);
  47837. var offsetS = currentS - (referenceCorner & 2 ? symbolWidth : 0);
  47838. var s2, t2, symbolRow;
  47839. if (transposed) {
  47840. for (s2 = 0; s2 < symbolHeight; s2++) {
  47841. row = bitmap[offsetS + s2];
  47842. if (!row) {
  47843. continue;
  47844. }
  47845. symbolRow = symbolBitmap[s2];
  47846. var maxWidth = Math.min(width - offsetT, symbolWidth);
  47847. switch (combinationOperator) {
  47848. case 0:
  47849. for (t2 = 0; t2 < maxWidth; t2++) {
  47850. row[offsetT + t2] |= symbolRow[t2];
  47851. }
  47852. break;
  47853. case 2:
  47854. for (t2 = 0; t2 < maxWidth; t2++) {
  47855. row[offsetT + t2] ^= symbolRow[t2];
  47856. }
  47857. break;
  47858. default:
  47859. error('JBIG2 error: operator ' + combinationOperator + ' is not supported');
  47860. }
  47861. }
  47862. currentS += symbolHeight - 1;
  47863. } else {
  47864. for (t2 = 0; t2 < symbolHeight; t2++) {
  47865. row = bitmap[offsetT + t2];
  47866. if (!row) {
  47867. continue;
  47868. }
  47869. symbolRow = symbolBitmap[t2];
  47870. switch (combinationOperator) {
  47871. case 0:
  47872. for (s2 = 0; s2 < symbolWidth; s2++) {
  47873. row[offsetS + s2] |= symbolRow[s2];
  47874. }
  47875. break;
  47876. case 2:
  47877. for (s2 = 0; s2 < symbolWidth; s2++) {
  47878. row[offsetS + s2] ^= symbolRow[s2];
  47879. }
  47880. break;
  47881. default:
  47882. error('JBIG2 error: operator ' + combinationOperator + ' is not supported');
  47883. }
  47884. }
  47885. currentS += symbolWidth - 1;
  47886. }
  47887. i++;
  47888. var deltaS = decodeInteger(contextCache, 'IADS', decoder);
  47889. if (deltaS === null) {
  47890. break;
  47891. }
  47892. currentS += deltaS + dsOffset;
  47893. } while (true);
  47894. }
  47895. return bitmap;
  47896. }
  47897. function readSegmentHeader(data, start) {
  47898. var segmentHeader = {};
  47899. segmentHeader.number = readUint32(data, start);
  47900. var flags = data[start + 4];
  47901. var segmentType = flags & 0x3F;
  47902. if (!SegmentTypes[segmentType]) {
  47903. error('JBIG2 error: invalid segment type: ' + segmentType);
  47904. }
  47905. segmentHeader.type = segmentType;
  47906. segmentHeader.typeName = SegmentTypes[segmentType];
  47907. segmentHeader.deferredNonRetain = !!(flags & 0x80);
  47908. var pageAssociationFieldSize = !!(flags & 0x40);
  47909. var referredFlags = data[start + 5];
  47910. var referredToCount = referredFlags >> 5 & 7;
  47911. var retainBits = [referredFlags & 31];
  47912. var position = start + 6;
  47913. if (referredFlags === 7) {
  47914. referredToCount = readUint32(data, position - 1) & 0x1FFFFFFF;
  47915. position += 3;
  47916. var bytes = referredToCount + 7 >> 3;
  47917. retainBits[0] = data[position++];
  47918. while (--bytes > 0) {
  47919. retainBits.push(data[position++]);
  47920. }
  47921. } else if (referredFlags === 5 || referredFlags === 6) {
  47922. error('JBIG2 error: invalid referred-to flags');
  47923. }
  47924. segmentHeader.retainBits = retainBits;
  47925. var referredToSegmentNumberSize = segmentHeader.number <= 256 ? 1 : segmentHeader.number <= 65536 ? 2 : 4;
  47926. var referredTo = [];
  47927. var i, ii;
  47928. for (i = 0; i < referredToCount; i++) {
  47929. var number = referredToSegmentNumberSize === 1 ? data[position] : referredToSegmentNumberSize === 2 ? readUint16(data, position) : readUint32(data, position);
  47930. referredTo.push(number);
  47931. position += referredToSegmentNumberSize;
  47932. }
  47933. segmentHeader.referredTo = referredTo;
  47934. if (!pageAssociationFieldSize) {
  47935. segmentHeader.pageAssociation = data[position++];
  47936. } else {
  47937. segmentHeader.pageAssociation = readUint32(data, position);
  47938. position += 4;
  47939. }
  47940. segmentHeader.length = readUint32(data, position);
  47941. position += 4;
  47942. if (segmentHeader.length === 0xFFFFFFFF) {
  47943. if (segmentType === 38) {
  47944. var genericRegionInfo = readRegionSegmentInformation(data, position);
  47945. var genericRegionSegmentFlags = data[position + RegionSegmentInformationFieldLength];
  47946. var genericRegionMmr = !!(genericRegionSegmentFlags & 1);
  47947. var searchPatternLength = 6;
  47948. var searchPattern = new Uint8Array(searchPatternLength);
  47949. if (!genericRegionMmr) {
  47950. searchPattern[0] = 0xFF;
  47951. searchPattern[1] = 0xAC;
  47952. }
  47953. searchPattern[2] = genericRegionInfo.height >>> 24 & 0xFF;
  47954. searchPattern[3] = genericRegionInfo.height >> 16 & 0xFF;
  47955. searchPattern[4] = genericRegionInfo.height >> 8 & 0xFF;
  47956. searchPattern[5] = genericRegionInfo.height & 0xFF;
  47957. for (i = position, ii = data.length; i < ii; i++) {
  47958. var j = 0;
  47959. while (j < searchPatternLength && searchPattern[j] === data[i + j]) {
  47960. j++;
  47961. }
  47962. if (j === searchPatternLength) {
  47963. segmentHeader.length = i + searchPatternLength;
  47964. break;
  47965. }
  47966. }
  47967. if (segmentHeader.length === 0xFFFFFFFF) {
  47968. error('JBIG2 error: segment end was not found');
  47969. }
  47970. } else {
  47971. error('JBIG2 error: invalid unknown segment length');
  47972. }
  47973. }
  47974. segmentHeader.headerEnd = position;
  47975. return segmentHeader;
  47976. }
  47977. function readSegments(header, data, start, end) {
  47978. var segments = [];
  47979. var position = start;
  47980. while (position < end) {
  47981. var segmentHeader = readSegmentHeader(data, position);
  47982. position = segmentHeader.headerEnd;
  47983. var segment = {
  47984. header: segmentHeader,
  47985. data: data
  47986. };
  47987. if (!header.randomAccess) {
  47988. segment.start = position;
  47989. position += segmentHeader.length;
  47990. segment.end = position;
  47991. }
  47992. segments.push(segment);
  47993. if (segmentHeader.type === 51) {
  47994. break;
  47995. }
  47996. }
  47997. if (header.randomAccess) {
  47998. for (var i = 0, ii = segments.length; i < ii; i++) {
  47999. segments[i].start = position;
  48000. position += segments[i].header.length;
  48001. segments[i].end = position;
  48002. }
  48003. }
  48004. return segments;
  48005. }
  48006. function readRegionSegmentInformation(data, start) {
  48007. return {
  48008. width: readUint32(data, start),
  48009. height: readUint32(data, start + 4),
  48010. x: readUint32(data, start + 8),
  48011. y: readUint32(data, start + 12),
  48012. combinationOperator: data[start + 16] & 7
  48013. };
  48014. }
  48015. var RegionSegmentInformationFieldLength = 17;
  48016. function processSegment(segment, visitor) {
  48017. var header = segment.header;
  48018. var data = segment.data, position = segment.start, end = segment.end;
  48019. var args, at, i, atLength;
  48020. switch (header.type) {
  48021. case 0:
  48022. var dictionary = {};
  48023. var dictionaryFlags = readUint16(data, position);
  48024. dictionary.huffman = !!(dictionaryFlags & 1);
  48025. dictionary.refinement = !!(dictionaryFlags & 2);
  48026. dictionary.huffmanDHSelector = dictionaryFlags >> 2 & 3;
  48027. dictionary.huffmanDWSelector = dictionaryFlags >> 4 & 3;
  48028. dictionary.bitmapSizeSelector = dictionaryFlags >> 6 & 1;
  48029. dictionary.aggregationInstancesSelector = dictionaryFlags >> 7 & 1;
  48030. dictionary.bitmapCodingContextUsed = !!(dictionaryFlags & 256);
  48031. dictionary.bitmapCodingContextRetained = !!(dictionaryFlags & 512);
  48032. dictionary.template = dictionaryFlags >> 10 & 3;
  48033. dictionary.refinementTemplate = dictionaryFlags >> 12 & 1;
  48034. position += 2;
  48035. if (!dictionary.huffman) {
  48036. atLength = dictionary.template === 0 ? 4 : 1;
  48037. at = [];
  48038. for (i = 0; i < atLength; i++) {
  48039. at.push({
  48040. x: readInt8(data, position),
  48041. y: readInt8(data, position + 1)
  48042. });
  48043. position += 2;
  48044. }
  48045. dictionary.at = at;
  48046. }
  48047. if (dictionary.refinement && !dictionary.refinementTemplate) {
  48048. at = [];
  48049. for (i = 0; i < 2; i++) {
  48050. at.push({
  48051. x: readInt8(data, position),
  48052. y: readInt8(data, position + 1)
  48053. });
  48054. position += 2;
  48055. }
  48056. dictionary.refinementAt = at;
  48057. }
  48058. dictionary.numberOfExportedSymbols = readUint32(data, position);
  48059. position += 4;
  48060. dictionary.numberOfNewSymbols = readUint32(data, position);
  48061. position += 4;
  48062. args = [
  48063. dictionary,
  48064. header.number,
  48065. header.referredTo,
  48066. data,
  48067. position,
  48068. end
  48069. ];
  48070. break;
  48071. case 6:
  48072. case 7:
  48073. var textRegion = {};
  48074. textRegion.info = readRegionSegmentInformation(data, position);
  48075. position += RegionSegmentInformationFieldLength;
  48076. var textRegionSegmentFlags = readUint16(data, position);
  48077. position += 2;
  48078. textRegion.huffman = !!(textRegionSegmentFlags & 1);
  48079. textRegion.refinement = !!(textRegionSegmentFlags & 2);
  48080. textRegion.stripSize = 1 << (textRegionSegmentFlags >> 2 & 3);
  48081. textRegion.referenceCorner = textRegionSegmentFlags >> 4 & 3;
  48082. textRegion.transposed = !!(textRegionSegmentFlags & 64);
  48083. textRegion.combinationOperator = textRegionSegmentFlags >> 7 & 3;
  48084. textRegion.defaultPixelValue = textRegionSegmentFlags >> 9 & 1;
  48085. textRegion.dsOffset = textRegionSegmentFlags << 17 >> 27;
  48086. textRegion.refinementTemplate = textRegionSegmentFlags >> 15 & 1;
  48087. if (textRegion.huffman) {
  48088. var textRegionHuffmanFlags = readUint16(data, position);
  48089. position += 2;
  48090. textRegion.huffmanFS = textRegionHuffmanFlags & 3;
  48091. textRegion.huffmanDS = textRegionHuffmanFlags >> 2 & 3;
  48092. textRegion.huffmanDT = textRegionHuffmanFlags >> 4 & 3;
  48093. textRegion.huffmanRefinementDW = textRegionHuffmanFlags >> 6 & 3;
  48094. textRegion.huffmanRefinementDH = textRegionHuffmanFlags >> 8 & 3;
  48095. textRegion.huffmanRefinementDX = textRegionHuffmanFlags >> 10 & 3;
  48096. textRegion.huffmanRefinementDY = textRegionHuffmanFlags >> 12 & 3;
  48097. textRegion.huffmanRefinementSizeSelector = !!(textRegionHuffmanFlags & 14);
  48098. }
  48099. if (textRegion.refinement && !textRegion.refinementTemplate) {
  48100. at = [];
  48101. for (i = 0; i < 2; i++) {
  48102. at.push({
  48103. x: readInt8(data, position),
  48104. y: readInt8(data, position + 1)
  48105. });
  48106. position += 2;
  48107. }
  48108. textRegion.refinementAt = at;
  48109. }
  48110. textRegion.numberOfSymbolInstances = readUint32(data, position);
  48111. position += 4;
  48112. if (textRegion.huffman) {
  48113. error('JBIG2 error: huffman is not supported');
  48114. }
  48115. args = [
  48116. textRegion,
  48117. header.referredTo,
  48118. data,
  48119. position,
  48120. end
  48121. ];
  48122. break;
  48123. case 38:
  48124. case 39:
  48125. var genericRegion = {};
  48126. genericRegion.info = readRegionSegmentInformation(data, position);
  48127. position += RegionSegmentInformationFieldLength;
  48128. var genericRegionSegmentFlags = data[position++];
  48129. genericRegion.mmr = !!(genericRegionSegmentFlags & 1);
  48130. genericRegion.template = genericRegionSegmentFlags >> 1 & 3;
  48131. genericRegion.prediction = !!(genericRegionSegmentFlags & 8);
  48132. if (!genericRegion.mmr) {
  48133. atLength = genericRegion.template === 0 ? 4 : 1;
  48134. at = [];
  48135. for (i = 0; i < atLength; i++) {
  48136. at.push({
  48137. x: readInt8(data, position),
  48138. y: readInt8(data, position + 1)
  48139. });
  48140. position += 2;
  48141. }
  48142. genericRegion.at = at;
  48143. }
  48144. args = [
  48145. genericRegion,
  48146. data,
  48147. position,
  48148. end
  48149. ];
  48150. break;
  48151. case 48:
  48152. var pageInfo = {
  48153. width: readUint32(data, position),
  48154. height: readUint32(data, position + 4),
  48155. resolutionX: readUint32(data, position + 8),
  48156. resolutionY: readUint32(data, position + 12)
  48157. };
  48158. if (pageInfo.height === 0xFFFFFFFF) {
  48159. delete pageInfo.height;
  48160. }
  48161. var pageSegmentFlags = data[position + 16];
  48162. readUint16(data, position + 17);
  48163. pageInfo.lossless = !!(pageSegmentFlags & 1);
  48164. pageInfo.refinement = !!(pageSegmentFlags & 2);
  48165. pageInfo.defaultPixelValue = pageSegmentFlags >> 2 & 1;
  48166. pageInfo.combinationOperator = pageSegmentFlags >> 3 & 3;
  48167. pageInfo.requiresBuffer = !!(pageSegmentFlags & 32);
  48168. pageInfo.combinationOperatorOverride = !!(pageSegmentFlags & 64);
  48169. args = [pageInfo];
  48170. break;
  48171. case 49:
  48172. break;
  48173. case 50:
  48174. break;
  48175. case 51:
  48176. break;
  48177. case 62:
  48178. break;
  48179. default:
  48180. error('JBIG2 error: segment type ' + header.typeName + '(' + header.type + ') is not implemented');
  48181. }
  48182. var callbackName = 'on' + header.typeName;
  48183. if (callbackName in visitor) {
  48184. visitor[callbackName].apply(visitor, args);
  48185. }
  48186. }
  48187. function processSegments(segments, visitor) {
  48188. for (var i = 0, ii = segments.length; i < ii; i++) {
  48189. processSegment(segments[i], visitor);
  48190. }
  48191. }
  48192. function parseJbig2(data, start, end) {
  48193. var position = start;
  48194. 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) {
  48195. error('JBIG2 error: invalid header');
  48196. }
  48197. var header = {};
  48198. position += 8;
  48199. var flags = data[position++];
  48200. header.randomAccess = !(flags & 1);
  48201. if (!(flags & 2)) {
  48202. header.numberOfPages = readUint32(data, position);
  48203. position += 4;
  48204. }
  48205. readSegments(header, data, position, end);
  48206. error('Not implemented');
  48207. }
  48208. function parseJbig2Chunks(chunks) {
  48209. var visitor = new SimpleSegmentVisitor();
  48210. for (var i = 0, ii = chunks.length; i < ii; i++) {
  48211. var chunk = chunks[i];
  48212. var segments = readSegments({}, chunk.data, chunk.start, chunk.end);
  48213. processSegments(segments, visitor);
  48214. }
  48215. return visitor.buffer;
  48216. }
  48217. function SimpleSegmentVisitor() {
  48218. }
  48219. SimpleSegmentVisitor.prototype = {
  48220. onPageInformation: function SimpleSegmentVisitor_onPageInformation(info) {
  48221. this.currentPageInfo = info;
  48222. var rowSize = info.width + 7 >> 3;
  48223. var buffer = new Uint8Array(rowSize * info.height);
  48224. if (info.defaultPixelValue) {
  48225. for (var i = 0, ii = buffer.length; i < ii; i++) {
  48226. buffer[i] = 0xFF;
  48227. }
  48228. }
  48229. this.buffer = buffer;
  48230. },
  48231. drawBitmap: function SimpleSegmentVisitor_drawBitmap(regionInfo, bitmap) {
  48232. var pageInfo = this.currentPageInfo;
  48233. var width = regionInfo.width, height = regionInfo.height;
  48234. var rowSize = pageInfo.width + 7 >> 3;
  48235. var combinationOperator = pageInfo.combinationOperatorOverride ? regionInfo.combinationOperator : pageInfo.combinationOperator;
  48236. var buffer = this.buffer;
  48237. var mask0 = 128 >> (regionInfo.x & 7);
  48238. var offset0 = regionInfo.y * rowSize + (regionInfo.x >> 3);
  48239. var i, j, mask, offset;
  48240. switch (combinationOperator) {
  48241. case 0:
  48242. for (i = 0; i < height; i++) {
  48243. mask = mask0;
  48244. offset = offset0;
  48245. for (j = 0; j < width; j++) {
  48246. if (bitmap[i][j]) {
  48247. buffer[offset] |= mask;
  48248. }
  48249. mask >>= 1;
  48250. if (!mask) {
  48251. mask = 128;
  48252. offset++;
  48253. }
  48254. }
  48255. offset0 += rowSize;
  48256. }
  48257. break;
  48258. case 2:
  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. default:
  48276. error('JBIG2 error: operator ' + combinationOperator + ' is not supported');
  48277. }
  48278. },
  48279. onImmediateGenericRegion: function SimpleSegmentVisitor_onImmediateGenericRegion(region, data, start, end) {
  48280. var regionInfo = region.info;
  48281. var decodingContext = new DecodingContext(data, start, end);
  48282. var bitmap = decodeBitmap(region.mmr, regionInfo.width, regionInfo.height, region.template, region.prediction, null, region.at, decodingContext);
  48283. this.drawBitmap(regionInfo, bitmap);
  48284. },
  48285. onImmediateLosslessGenericRegion: function SimpleSegmentVisitor_onImmediateLosslessGenericRegion() {
  48286. this.onImmediateGenericRegion.apply(this, arguments);
  48287. },
  48288. onSymbolDictionary: function SimpleSegmentVisitor_onSymbolDictionary(dictionary, currentSegment, referredSegments, data, start, end) {
  48289. var huffmanTables;
  48290. if (dictionary.huffman) {
  48291. error('JBIG2 error: huffman is not supported');
  48292. }
  48293. var symbols = this.symbols;
  48294. if (!symbols) {
  48295. this.symbols = symbols = {};
  48296. }
  48297. var inputSymbols = [];
  48298. for (var i = 0, ii = referredSegments.length; i < ii; i++) {
  48299. inputSymbols = inputSymbols.concat(symbols[referredSegments[i]]);
  48300. }
  48301. var decodingContext = new DecodingContext(data, start, end);
  48302. symbols[currentSegment] = decodeSymbolDictionary(dictionary.huffman, dictionary.refinement, inputSymbols, dictionary.numberOfNewSymbols, dictionary.numberOfExportedSymbols, huffmanTables, dictionary.template, dictionary.at, dictionary.refinementTemplate, dictionary.refinementAt, decodingContext);
  48303. },
  48304. onImmediateTextRegion: function SimpleSegmentVisitor_onImmediateTextRegion(region, referredSegments, data, start, end) {
  48305. var regionInfo = region.info;
  48306. var huffmanTables;
  48307. var symbols = this.symbols;
  48308. var inputSymbols = [];
  48309. for (var i = 0, ii = referredSegments.length; i < ii; i++) {
  48310. inputSymbols = inputSymbols.concat(symbols[referredSegments[i]]);
  48311. }
  48312. var symbolCodeLength = log2(inputSymbols.length);
  48313. var decodingContext = new DecodingContext(data, start, end);
  48314. 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);
  48315. this.drawBitmap(regionInfo, bitmap);
  48316. },
  48317. onImmediateLosslessTextRegion: function SimpleSegmentVisitor_onImmediateLosslessTextRegion() {
  48318. this.onImmediateTextRegion.apply(this, arguments);
  48319. }
  48320. };
  48321. function Jbig2Image() {
  48322. }
  48323. Jbig2Image.prototype = {
  48324. parseChunks: function Jbig2Image_parseChunks(chunks) {
  48325. return parseJbig2Chunks(chunks);
  48326. }
  48327. };
  48328. return Jbig2Image;
  48329. }();
  48330. exports.Jbig2Image = Jbig2Image;
  48331. /***/ }),
  48332. /* 36 */
  48333. /***/ (function(module, exports, __w_pdfjs_require__) {
  48334. "use strict";
  48335. var sharedUtil = __w_pdfjs_require__(0);
  48336. var error = sharedUtil.error;
  48337. var JpegImage = function JpegImageClosure() {
  48338. var dctZigZag = new Uint8Array([
  48339. 0,
  48340. 1,
  48341. 8,
  48342. 16,
  48343. 9,
  48344. 2,
  48345. 3,
  48346. 10,
  48347. 17,
  48348. 24,
  48349. 32,
  48350. 25,
  48351. 18,
  48352. 11,
  48353. 4,
  48354. 5,
  48355. 12,
  48356. 19,
  48357. 26,
  48358. 33,
  48359. 40,
  48360. 48,
  48361. 41,
  48362. 34,
  48363. 27,
  48364. 20,
  48365. 13,
  48366. 6,
  48367. 7,
  48368. 14,
  48369. 21,
  48370. 28,
  48371. 35,
  48372. 42,
  48373. 49,
  48374. 56,
  48375. 57,
  48376. 50,
  48377. 43,
  48378. 36,
  48379. 29,
  48380. 22,
  48381. 15,
  48382. 23,
  48383. 30,
  48384. 37,
  48385. 44,
  48386. 51,
  48387. 58,
  48388. 59,
  48389. 52,
  48390. 45,
  48391. 38,
  48392. 31,
  48393. 39,
  48394. 46,
  48395. 53,
  48396. 60,
  48397. 61,
  48398. 54,
  48399. 47,
  48400. 55,
  48401. 62,
  48402. 63
  48403. ]);
  48404. var dctCos1 = 4017;
  48405. var dctSin1 = 799;
  48406. var dctCos3 = 3406;
  48407. var dctSin3 = 2276;
  48408. var dctCos6 = 1567;
  48409. var dctSin6 = 3784;
  48410. var dctSqrt2 = 5793;
  48411. var dctSqrt1d2 = 2896;
  48412. function JpegImage() {
  48413. this.decodeTransform = null;
  48414. this.colorTransform = -1;
  48415. }
  48416. function buildHuffmanTable(codeLengths, values) {
  48417. var k = 0, code = [], i, j, length = 16;
  48418. while (length > 0 && !codeLengths[length - 1]) {
  48419. length--;
  48420. }
  48421. code.push({
  48422. children: [],
  48423. index: 0
  48424. });
  48425. var p = code[0], q;
  48426. for (i = 0; i < length; i++) {
  48427. for (j = 0; j < codeLengths[i]; j++) {
  48428. p = code.pop();
  48429. p.children[p.index] = values[k];
  48430. while (p.index > 0) {
  48431. p = code.pop();
  48432. }
  48433. p.index++;
  48434. code.push(p);
  48435. while (code.length <= i) {
  48436. code.push(q = {
  48437. children: [],
  48438. index: 0
  48439. });
  48440. p.children[p.index] = q.children;
  48441. p = q;
  48442. }
  48443. k++;
  48444. }
  48445. if (i + 1 < length) {
  48446. code.push(q = {
  48447. children: [],
  48448. index: 0
  48449. });
  48450. p.children[p.index] = q.children;
  48451. p = q;
  48452. }
  48453. }
  48454. return code[0].children;
  48455. }
  48456. function getBlockBufferOffset(component, row, col) {
  48457. return 64 * ((component.blocksPerLine + 1) * row + col);
  48458. }
  48459. function decodeScan(data, offset, frame, components, resetInterval, spectralStart, spectralEnd, successivePrev, successive) {
  48460. var mcusPerLine = frame.mcusPerLine;
  48461. var progressive = frame.progressive;
  48462. var startOffset = offset, bitsData = 0, bitsCount = 0;
  48463. function readBit() {
  48464. if (bitsCount > 0) {
  48465. bitsCount--;
  48466. return bitsData >> bitsCount & 1;
  48467. }
  48468. bitsData = data[offset++];
  48469. if (bitsData === 0xFF) {
  48470. var nextByte = data[offset++];
  48471. if (nextByte) {
  48472. error('JPEG error: unexpected marker ' + (bitsData << 8 | nextByte).toString(16));
  48473. }
  48474. }
  48475. bitsCount = 7;
  48476. return bitsData >>> 7;
  48477. }
  48478. function decodeHuffman(tree) {
  48479. var node = tree;
  48480. while (true) {
  48481. node = node[readBit()];
  48482. if (typeof node === 'number') {
  48483. return node;
  48484. }
  48485. if (typeof node !== 'object') {
  48486. error('JPEG error: invalid huffman sequence');
  48487. }
  48488. }
  48489. }
  48490. function receive(length) {
  48491. var n = 0;
  48492. while (length > 0) {
  48493. n = n << 1 | readBit();
  48494. length--;
  48495. }
  48496. return n;
  48497. }
  48498. function receiveAndExtend(length) {
  48499. if (length === 1) {
  48500. return readBit() === 1 ? 1 : -1;
  48501. }
  48502. var n = receive(length);
  48503. if (n >= 1 << length - 1) {
  48504. return n;
  48505. }
  48506. return n + (-1 << length) + 1;
  48507. }
  48508. function decodeBaseline(component, offset) {
  48509. var t = decodeHuffman(component.huffmanTableDC);
  48510. var diff = t === 0 ? 0 : receiveAndExtend(t);
  48511. component.blockData[offset] = component.pred += diff;
  48512. var k = 1;
  48513. while (k < 64) {
  48514. var rs = decodeHuffman(component.huffmanTableAC);
  48515. var s = rs & 15, r = rs >> 4;
  48516. if (s === 0) {
  48517. if (r < 15) {
  48518. break;
  48519. }
  48520. k += 16;
  48521. continue;
  48522. }
  48523. k += r;
  48524. var z = dctZigZag[k];
  48525. component.blockData[offset + z] = receiveAndExtend(s);
  48526. k++;
  48527. }
  48528. }
  48529. function decodeDCFirst(component, offset) {
  48530. var t = decodeHuffman(component.huffmanTableDC);
  48531. var diff = t === 0 ? 0 : receiveAndExtend(t) << successive;
  48532. component.blockData[offset] = component.pred += diff;
  48533. }
  48534. function decodeDCSuccessive(component, offset) {
  48535. component.blockData[offset] |= readBit() << successive;
  48536. }
  48537. var eobrun = 0;
  48538. function decodeACFirst(component, offset) {
  48539. if (eobrun > 0) {
  48540. eobrun--;
  48541. return;
  48542. }
  48543. var k = spectralStart, e = spectralEnd;
  48544. while (k <= e) {
  48545. var rs = decodeHuffman(component.huffmanTableAC);
  48546. var s = rs & 15, r = rs >> 4;
  48547. if (s === 0) {
  48548. if (r < 15) {
  48549. eobrun = receive(r) + (1 << r) - 1;
  48550. break;
  48551. }
  48552. k += 16;
  48553. continue;
  48554. }
  48555. k += r;
  48556. var z = dctZigZag[k];
  48557. component.blockData[offset + z] = receiveAndExtend(s) * (1 << successive);
  48558. k++;
  48559. }
  48560. }
  48561. var successiveACState = 0, successiveACNextValue;
  48562. function decodeACSuccessive(component, offset) {
  48563. var k = spectralStart;
  48564. var e = spectralEnd;
  48565. var r = 0;
  48566. var s;
  48567. var rs;
  48568. while (k <= e) {
  48569. var z = dctZigZag[k];
  48570. switch (successiveACState) {
  48571. case 0:
  48572. rs = decodeHuffman(component.huffmanTableAC);
  48573. s = rs & 15;
  48574. r = rs >> 4;
  48575. if (s === 0) {
  48576. if (r < 15) {
  48577. eobrun = receive(r) + (1 << r);
  48578. successiveACState = 4;
  48579. } else {
  48580. r = 16;
  48581. successiveACState = 1;
  48582. }
  48583. } else {
  48584. if (s !== 1) {
  48585. error('JPEG error: invalid ACn encoding');
  48586. }
  48587. successiveACNextValue = receiveAndExtend(s);
  48588. successiveACState = r ? 2 : 3;
  48589. }
  48590. continue;
  48591. case 1:
  48592. case 2:
  48593. if (component.blockData[offset + z]) {
  48594. component.blockData[offset + z] += readBit() << successive;
  48595. } else {
  48596. r--;
  48597. if (r === 0) {
  48598. successiveACState = successiveACState === 2 ? 3 : 0;
  48599. }
  48600. }
  48601. break;
  48602. case 3:
  48603. if (component.blockData[offset + z]) {
  48604. component.blockData[offset + z] += readBit() << successive;
  48605. } else {
  48606. component.blockData[offset + z] = successiveACNextValue << successive;
  48607. successiveACState = 0;
  48608. }
  48609. break;
  48610. case 4:
  48611. if (component.blockData[offset + z]) {
  48612. component.blockData[offset + z] += readBit() << successive;
  48613. }
  48614. break;
  48615. }
  48616. k++;
  48617. }
  48618. if (successiveACState === 4) {
  48619. eobrun--;
  48620. if (eobrun === 0) {
  48621. successiveACState = 0;
  48622. }
  48623. }
  48624. }
  48625. function decodeMcu(component, decode, mcu, row, col) {
  48626. var mcuRow = mcu / mcusPerLine | 0;
  48627. var mcuCol = mcu % mcusPerLine;
  48628. var blockRow = mcuRow * component.v + row;
  48629. var blockCol = mcuCol * component.h + col;
  48630. var offset = getBlockBufferOffset(component, blockRow, blockCol);
  48631. decode(component, offset);
  48632. }
  48633. function decodeBlock(component, decode, mcu) {
  48634. var blockRow = mcu / component.blocksPerLine | 0;
  48635. var blockCol = mcu % component.blocksPerLine;
  48636. var offset = getBlockBufferOffset(component, blockRow, blockCol);
  48637. decode(component, offset);
  48638. }
  48639. var componentsLength = components.length;
  48640. var component, i, j, k, n;
  48641. var decodeFn;
  48642. if (progressive) {
  48643. if (spectralStart === 0) {
  48644. decodeFn = successivePrev === 0 ? decodeDCFirst : decodeDCSuccessive;
  48645. } else {
  48646. decodeFn = successivePrev === 0 ? decodeACFirst : decodeACSuccessive;
  48647. }
  48648. } else {
  48649. decodeFn = decodeBaseline;
  48650. }
  48651. var mcu = 0, marker;
  48652. var mcuExpected;
  48653. if (componentsLength === 1) {
  48654. mcuExpected = components[0].blocksPerLine * components[0].blocksPerColumn;
  48655. } else {
  48656. mcuExpected = mcusPerLine * frame.mcusPerColumn;
  48657. }
  48658. if (!resetInterval) {
  48659. resetInterval = mcuExpected;
  48660. }
  48661. var h, v;
  48662. while (mcu < mcuExpected) {
  48663. for (i = 0; i < componentsLength; i++) {
  48664. components[i].pred = 0;
  48665. }
  48666. eobrun = 0;
  48667. if (componentsLength === 1) {
  48668. component = components[0];
  48669. for (n = 0; n < resetInterval; n++) {
  48670. decodeBlock(component, decodeFn, mcu);
  48671. mcu++;
  48672. }
  48673. } else {
  48674. for (n = 0; n < resetInterval; n++) {
  48675. for (i = 0; i < componentsLength; i++) {
  48676. component = components[i];
  48677. h = component.h;
  48678. v = component.v;
  48679. for (j = 0; j < v; j++) {
  48680. for (k = 0; k < h; k++) {
  48681. decodeMcu(component, decodeFn, mcu, j, k);
  48682. }
  48683. }
  48684. }
  48685. mcu++;
  48686. }
  48687. }
  48688. bitsCount = 0;
  48689. marker = data[offset] << 8 | data[offset + 1];
  48690. while (data[offset] === 0x00 && offset < data.length - 1) {
  48691. offset++;
  48692. marker = data[offset] << 8 | data[offset + 1];
  48693. }
  48694. if (marker <= 0xFF00) {
  48695. error('JPEG error: marker was not found');
  48696. }
  48697. if (marker >= 0xFFD0 && marker <= 0xFFD7) {
  48698. offset += 2;
  48699. } else {
  48700. break;
  48701. }
  48702. }
  48703. return offset - startOffset;
  48704. }
  48705. function quantizeAndInverse(component, blockBufferOffset, p) {
  48706. var qt = component.quantizationTable, blockData = component.blockData;
  48707. var v0, v1, v2, v3, v4, v5, v6, v7;
  48708. var p0, p1, p2, p3, p4, p5, p6, p7;
  48709. var t;
  48710. if (!qt) {
  48711. error('JPEG error: missing required Quantization Table.');
  48712. }
  48713. for (var row = 0; row < 64; row += 8) {
  48714. p0 = blockData[blockBufferOffset + row];
  48715. p1 = blockData[blockBufferOffset + row + 1];
  48716. p2 = blockData[blockBufferOffset + row + 2];
  48717. p3 = blockData[blockBufferOffset + row + 3];
  48718. p4 = blockData[blockBufferOffset + row + 4];
  48719. p5 = blockData[blockBufferOffset + row + 5];
  48720. p6 = blockData[blockBufferOffset + row + 6];
  48721. p7 = blockData[blockBufferOffset + row + 7];
  48722. p0 *= qt[row];
  48723. if ((p1 | p2 | p3 | p4 | p5 | p6 | p7) === 0) {
  48724. t = dctSqrt2 * p0 + 512 >> 10;
  48725. p[row] = t;
  48726. p[row + 1] = t;
  48727. p[row + 2] = t;
  48728. p[row + 3] = t;
  48729. p[row + 4] = t;
  48730. p[row + 5] = t;
  48731. p[row + 6] = t;
  48732. p[row + 7] = t;
  48733. continue;
  48734. }
  48735. p1 *= qt[row + 1];
  48736. p2 *= qt[row + 2];
  48737. p3 *= qt[row + 3];
  48738. p4 *= qt[row + 4];
  48739. p5 *= qt[row + 5];
  48740. p6 *= qt[row + 6];
  48741. p7 *= qt[row + 7];
  48742. v0 = dctSqrt2 * p0 + 128 >> 8;
  48743. v1 = dctSqrt2 * p4 + 128 >> 8;
  48744. v2 = p2;
  48745. v3 = p6;
  48746. v4 = dctSqrt1d2 * (p1 - p7) + 128 >> 8;
  48747. v7 = dctSqrt1d2 * (p1 + p7) + 128 >> 8;
  48748. v5 = p3 << 4;
  48749. v6 = p5 << 4;
  48750. v0 = v0 + v1 + 1 >> 1;
  48751. v1 = v0 - v1;
  48752. t = v2 * dctSin6 + v3 * dctCos6 + 128 >> 8;
  48753. v2 = v2 * dctCos6 - v3 * dctSin6 + 128 >> 8;
  48754. v3 = t;
  48755. v4 = v4 + v6 + 1 >> 1;
  48756. v6 = v4 - v6;
  48757. v7 = v7 + v5 + 1 >> 1;
  48758. v5 = v7 - v5;
  48759. v0 = v0 + v3 + 1 >> 1;
  48760. v3 = v0 - v3;
  48761. v1 = v1 + v2 + 1 >> 1;
  48762. v2 = v1 - v2;
  48763. t = v4 * dctSin3 + v7 * dctCos3 + 2048 >> 12;
  48764. v4 = v4 * dctCos3 - v7 * dctSin3 + 2048 >> 12;
  48765. v7 = t;
  48766. t = v5 * dctSin1 + v6 * dctCos1 + 2048 >> 12;
  48767. v5 = v5 * dctCos1 - v6 * dctSin1 + 2048 >> 12;
  48768. v6 = t;
  48769. p[row] = v0 + v7;
  48770. p[row + 7] = v0 - v7;
  48771. p[row + 1] = v1 + v6;
  48772. p[row + 6] = v1 - v6;
  48773. p[row + 2] = v2 + v5;
  48774. p[row + 5] = v2 - v5;
  48775. p[row + 3] = v3 + v4;
  48776. p[row + 4] = v3 - v4;
  48777. }
  48778. for (var col = 0; col < 8; ++col) {
  48779. p0 = p[col];
  48780. p1 = p[col + 8];
  48781. p2 = p[col + 16];
  48782. p3 = p[col + 24];
  48783. p4 = p[col + 32];
  48784. p5 = p[col + 40];
  48785. p6 = p[col + 48];
  48786. p7 = p[col + 56];
  48787. if ((p1 | p2 | p3 | p4 | p5 | p6 | p7) === 0) {
  48788. t = dctSqrt2 * p0 + 8192 >> 14;
  48789. t = t < -2040 ? 0 : t >= 2024 ? 255 : t + 2056 >> 4;
  48790. blockData[blockBufferOffset + col] = t;
  48791. blockData[blockBufferOffset + col + 8] = t;
  48792. blockData[blockBufferOffset + col + 16] = t;
  48793. blockData[blockBufferOffset + col + 24] = t;
  48794. blockData[blockBufferOffset + col + 32] = t;
  48795. blockData[blockBufferOffset + col + 40] = t;
  48796. blockData[blockBufferOffset + col + 48] = t;
  48797. blockData[blockBufferOffset + col + 56] = t;
  48798. continue;
  48799. }
  48800. v0 = dctSqrt2 * p0 + 2048 >> 12;
  48801. v1 = dctSqrt2 * p4 + 2048 >> 12;
  48802. v2 = p2;
  48803. v3 = p6;
  48804. v4 = dctSqrt1d2 * (p1 - p7) + 2048 >> 12;
  48805. v7 = dctSqrt1d2 * (p1 + p7) + 2048 >> 12;
  48806. v5 = p3;
  48807. v6 = p5;
  48808. v0 = (v0 + v1 + 1 >> 1) + 4112;
  48809. v1 = v0 - v1;
  48810. t = v2 * dctSin6 + v3 * dctCos6 + 2048 >> 12;
  48811. v2 = v2 * dctCos6 - v3 * dctSin6 + 2048 >> 12;
  48812. v3 = t;
  48813. v4 = v4 + v6 + 1 >> 1;
  48814. v6 = v4 - v6;
  48815. v7 = v7 + v5 + 1 >> 1;
  48816. v5 = v7 - v5;
  48817. v0 = v0 + v3 + 1 >> 1;
  48818. v3 = v0 - v3;
  48819. v1 = v1 + v2 + 1 >> 1;
  48820. v2 = v1 - v2;
  48821. t = v4 * dctSin3 + v7 * dctCos3 + 2048 >> 12;
  48822. v4 = v4 * dctCos3 - v7 * dctSin3 + 2048 >> 12;
  48823. v7 = t;
  48824. t = v5 * dctSin1 + v6 * dctCos1 + 2048 >> 12;
  48825. v5 = v5 * dctCos1 - v6 * dctSin1 + 2048 >> 12;
  48826. v6 = t;
  48827. p0 = v0 + v7;
  48828. p7 = v0 - v7;
  48829. p1 = v1 + v6;
  48830. p6 = v1 - v6;
  48831. p2 = v2 + v5;
  48832. p5 = v2 - v5;
  48833. p3 = v3 + v4;
  48834. p4 = v3 - v4;
  48835. p0 = p0 < 16 ? 0 : p0 >= 4080 ? 255 : p0 >> 4;
  48836. p1 = p1 < 16 ? 0 : p1 >= 4080 ? 255 : p1 >> 4;
  48837. p2 = p2 < 16 ? 0 : p2 >= 4080 ? 255 : p2 >> 4;
  48838. p3 = p3 < 16 ? 0 : p3 >= 4080 ? 255 : p3 >> 4;
  48839. p4 = p4 < 16 ? 0 : p4 >= 4080 ? 255 : p4 >> 4;
  48840. p5 = p5 < 16 ? 0 : p5 >= 4080 ? 255 : p5 >> 4;
  48841. p6 = p6 < 16 ? 0 : p6 >= 4080 ? 255 : p6 >> 4;
  48842. p7 = p7 < 16 ? 0 : p7 >= 4080 ? 255 : p7 >> 4;
  48843. blockData[blockBufferOffset + col] = p0;
  48844. blockData[blockBufferOffset + col + 8] = p1;
  48845. blockData[blockBufferOffset + col + 16] = p2;
  48846. blockData[blockBufferOffset + col + 24] = p3;
  48847. blockData[blockBufferOffset + col + 32] = p4;
  48848. blockData[blockBufferOffset + col + 40] = p5;
  48849. blockData[blockBufferOffset + col + 48] = p6;
  48850. blockData[blockBufferOffset + col + 56] = p7;
  48851. }
  48852. }
  48853. function buildComponentData(frame, component) {
  48854. var blocksPerLine = component.blocksPerLine;
  48855. var blocksPerColumn = component.blocksPerColumn;
  48856. var computationBuffer = new Int16Array(64);
  48857. for (var blockRow = 0; blockRow < blocksPerColumn; blockRow++) {
  48858. for (var blockCol = 0; blockCol < blocksPerLine; blockCol++) {
  48859. var offset = getBlockBufferOffset(component, blockRow, blockCol);
  48860. quantizeAndInverse(component, offset, computationBuffer);
  48861. }
  48862. }
  48863. return component.blockData;
  48864. }
  48865. function clamp0to255(a) {
  48866. return a <= 0 ? 0 : a >= 255 ? 255 : a;
  48867. }
  48868. JpegImage.prototype = {
  48869. parse: function parse(data) {
  48870. function readUint16() {
  48871. var value = data[offset] << 8 | data[offset + 1];
  48872. offset += 2;
  48873. return value;
  48874. }
  48875. function readDataBlock() {
  48876. var length = readUint16();
  48877. var array = data.subarray(offset, offset + length - 2);
  48878. offset += array.length;
  48879. return array;
  48880. }
  48881. function prepareComponents(frame) {
  48882. var mcusPerLine = Math.ceil(frame.samplesPerLine / 8 / frame.maxH);
  48883. var mcusPerColumn = Math.ceil(frame.scanLines / 8 / frame.maxV);
  48884. for (var i = 0; i < frame.components.length; i++) {
  48885. component = frame.components[i];
  48886. var blocksPerLine = Math.ceil(Math.ceil(frame.samplesPerLine / 8) * component.h / frame.maxH);
  48887. var blocksPerColumn = Math.ceil(Math.ceil(frame.scanLines / 8) * component.v / frame.maxV);
  48888. var blocksPerLineForMcu = mcusPerLine * component.h;
  48889. var blocksPerColumnForMcu = mcusPerColumn * component.v;
  48890. var blocksBufferSize = 64 * blocksPerColumnForMcu * (blocksPerLineForMcu + 1);
  48891. component.blockData = new Int16Array(blocksBufferSize);
  48892. component.blocksPerLine = blocksPerLine;
  48893. component.blocksPerColumn = blocksPerColumn;
  48894. }
  48895. frame.mcusPerLine = mcusPerLine;
  48896. frame.mcusPerColumn = mcusPerColumn;
  48897. }
  48898. var offset = 0;
  48899. var jfif = null;
  48900. var adobe = null;
  48901. var frame, resetInterval;
  48902. var quantizationTables = [];
  48903. var huffmanTablesAC = [], huffmanTablesDC = [];
  48904. var fileMarker = readUint16();
  48905. if (fileMarker !== 0xFFD8) {
  48906. error('JPEG error: SOI not found');
  48907. }
  48908. fileMarker = readUint16();
  48909. while (fileMarker !== 0xFFD9) {
  48910. var i, j, l;
  48911. switch (fileMarker) {
  48912. case 0xFFE0:
  48913. case 0xFFE1:
  48914. case 0xFFE2:
  48915. case 0xFFE3:
  48916. case 0xFFE4:
  48917. case 0xFFE5:
  48918. case 0xFFE6:
  48919. case 0xFFE7:
  48920. case 0xFFE8:
  48921. case 0xFFE9:
  48922. case 0xFFEA:
  48923. case 0xFFEB:
  48924. case 0xFFEC:
  48925. case 0xFFED:
  48926. case 0xFFEE:
  48927. case 0xFFEF:
  48928. case 0xFFFE:
  48929. var appData = readDataBlock();
  48930. if (fileMarker === 0xFFE0) {
  48931. if (appData[0] === 0x4A && appData[1] === 0x46 && appData[2] === 0x49 && appData[3] === 0x46 && appData[4] === 0) {
  48932. jfif = {
  48933. version: {
  48934. major: appData[5],
  48935. minor: appData[6]
  48936. },
  48937. densityUnits: appData[7],
  48938. xDensity: appData[8] << 8 | appData[9],
  48939. yDensity: appData[10] << 8 | appData[11],
  48940. thumbWidth: appData[12],
  48941. thumbHeight: appData[13],
  48942. thumbData: appData.subarray(14, 14 + 3 * appData[12] * appData[13])
  48943. };
  48944. }
  48945. }
  48946. if (fileMarker === 0xFFEE) {
  48947. if (appData[0] === 0x41 && appData[1] === 0x64 && appData[2] === 0x6F && appData[3] === 0x62 && appData[4] === 0x65) {
  48948. adobe = {
  48949. version: appData[5] << 8 | appData[6],
  48950. flags0: appData[7] << 8 | appData[8],
  48951. flags1: appData[9] << 8 | appData[10],
  48952. transformCode: appData[11]
  48953. };
  48954. }
  48955. }
  48956. break;
  48957. case 0xFFDB:
  48958. var quantizationTablesLength = readUint16();
  48959. var quantizationTablesEnd = quantizationTablesLength + offset - 2;
  48960. var z;
  48961. while (offset < quantizationTablesEnd) {
  48962. var quantizationTableSpec = data[offset++];
  48963. var tableData = new Uint16Array(64);
  48964. if (quantizationTableSpec >> 4 === 0) {
  48965. for (j = 0; j < 64; j++) {
  48966. z = dctZigZag[j];
  48967. tableData[z] = data[offset++];
  48968. }
  48969. } else if (quantizationTableSpec >> 4 === 1) {
  48970. for (j = 0; j < 64; j++) {
  48971. z = dctZigZag[j];
  48972. tableData[z] = readUint16();
  48973. }
  48974. } else {
  48975. error('JPEG error: DQT - invalid table spec');
  48976. }
  48977. quantizationTables[quantizationTableSpec & 15] = tableData;
  48978. }
  48979. break;
  48980. case 0xFFC0:
  48981. case 0xFFC1:
  48982. case 0xFFC2:
  48983. if (frame) {
  48984. error('JPEG error: Only single frame JPEGs supported');
  48985. }
  48986. readUint16();
  48987. frame = {};
  48988. frame.extended = fileMarker === 0xFFC1;
  48989. frame.progressive = fileMarker === 0xFFC2;
  48990. frame.precision = data[offset++];
  48991. frame.scanLines = readUint16();
  48992. frame.samplesPerLine = readUint16();
  48993. frame.components = [];
  48994. frame.componentIds = {};
  48995. var componentsCount = data[offset++], componentId;
  48996. var maxH = 0, maxV = 0;
  48997. for (i = 0; i < componentsCount; i++) {
  48998. componentId = data[offset];
  48999. var h = data[offset + 1] >> 4;
  49000. var v = data[offset + 1] & 15;
  49001. if (maxH < h) {
  49002. maxH = h;
  49003. }
  49004. if (maxV < v) {
  49005. maxV = v;
  49006. }
  49007. var qId = data[offset + 2];
  49008. l = frame.components.push({
  49009. h: h,
  49010. v: v,
  49011. quantizationId: qId,
  49012. quantizationTable: null
  49013. });
  49014. frame.componentIds[componentId] = l - 1;
  49015. offset += 3;
  49016. }
  49017. frame.maxH = maxH;
  49018. frame.maxV = maxV;
  49019. prepareComponents(frame);
  49020. break;
  49021. case 0xFFC4:
  49022. var huffmanLength = readUint16();
  49023. for (i = 2; i < huffmanLength;) {
  49024. var huffmanTableSpec = data[offset++];
  49025. var codeLengths = new Uint8Array(16);
  49026. var codeLengthSum = 0;
  49027. for (j = 0; j < 16; j++, offset++) {
  49028. codeLengthSum += codeLengths[j] = data[offset];
  49029. }
  49030. var huffmanValues = new Uint8Array(codeLengthSum);
  49031. for (j = 0; j < codeLengthSum; j++, offset++) {
  49032. huffmanValues[j] = data[offset];
  49033. }
  49034. i += 17 + codeLengthSum;
  49035. (huffmanTableSpec >> 4 === 0 ? huffmanTablesDC : huffmanTablesAC)[huffmanTableSpec & 15] = buildHuffmanTable(codeLengths, huffmanValues);
  49036. }
  49037. break;
  49038. case 0xFFDD:
  49039. readUint16();
  49040. resetInterval = readUint16();
  49041. break;
  49042. case 0xFFDA:
  49043. readUint16();
  49044. var selectorsCount = data[offset++];
  49045. var components = [], component;
  49046. for (i = 0; i < selectorsCount; i++) {
  49047. var componentIndex = frame.componentIds[data[offset++]];
  49048. component = frame.components[componentIndex];
  49049. var tableSpec = data[offset++];
  49050. component.huffmanTableDC = huffmanTablesDC[tableSpec >> 4];
  49051. component.huffmanTableAC = huffmanTablesAC[tableSpec & 15];
  49052. components.push(component);
  49053. }
  49054. var spectralStart = data[offset++];
  49055. var spectralEnd = data[offset++];
  49056. var successiveApproximation = data[offset++];
  49057. var processed = decodeScan(data, offset, frame, components, resetInterval, spectralStart, spectralEnd, successiveApproximation >> 4, successiveApproximation & 15);
  49058. offset += processed;
  49059. break;
  49060. case 0xFFFF:
  49061. if (data[offset] !== 0xFF) {
  49062. offset--;
  49063. }
  49064. break;
  49065. default:
  49066. if (data[offset - 3] === 0xFF && data[offset - 2] >= 0xC0 && data[offset - 2] <= 0xFE) {
  49067. offset -= 3;
  49068. break;
  49069. }
  49070. error('JPEG error: unknown marker ' + fileMarker.toString(16));
  49071. }
  49072. fileMarker = readUint16();
  49073. }
  49074. this.width = frame.samplesPerLine;
  49075. this.height = frame.scanLines;
  49076. this.jfif = jfif;
  49077. this.adobe = adobe;
  49078. this.components = [];
  49079. for (i = 0; i < frame.components.length; i++) {
  49080. component = frame.components[i];
  49081. var quantizationTable = quantizationTables[component.quantizationId];
  49082. if (quantizationTable) {
  49083. component.quantizationTable = quantizationTable;
  49084. }
  49085. this.components.push({
  49086. output: buildComponentData(frame, component),
  49087. scaleX: component.h / frame.maxH,
  49088. scaleY: component.v / frame.maxV,
  49089. blocksPerLine: component.blocksPerLine,
  49090. blocksPerColumn: component.blocksPerColumn
  49091. });
  49092. }
  49093. this.numComponents = this.components.length;
  49094. },
  49095. _getLinearizedBlockData: function getLinearizedBlockData(width, height) {
  49096. var scaleX = this.width / width, scaleY = this.height / height;
  49097. var component, componentScaleX, componentScaleY, blocksPerScanline;
  49098. var x, y, i, j, k;
  49099. var index;
  49100. var offset = 0;
  49101. var output;
  49102. var numComponents = this.components.length;
  49103. var dataLength = width * height * numComponents;
  49104. var data = new Uint8Array(dataLength);
  49105. var xScaleBlockOffset = new Uint32Array(width);
  49106. var mask3LSB = 0xfffffff8;
  49107. for (i = 0; i < numComponents; i++) {
  49108. component = this.components[i];
  49109. componentScaleX = component.scaleX * scaleX;
  49110. componentScaleY = component.scaleY * scaleY;
  49111. offset = i;
  49112. output = component.output;
  49113. blocksPerScanline = component.blocksPerLine + 1 << 3;
  49114. for (x = 0; x < width; x++) {
  49115. j = 0 | x * componentScaleX;
  49116. xScaleBlockOffset[x] = (j & mask3LSB) << 3 | j & 7;
  49117. }
  49118. for (y = 0; y < height; y++) {
  49119. j = 0 | y * componentScaleY;
  49120. index = blocksPerScanline * (j & mask3LSB) | (j & 7) << 3;
  49121. for (x = 0; x < width; x++) {
  49122. data[offset] = output[index + xScaleBlockOffset[x]];
  49123. offset += numComponents;
  49124. }
  49125. }
  49126. }
  49127. var transform = this.decodeTransform;
  49128. if (transform) {
  49129. for (i = 0; i < dataLength;) {
  49130. for (j = 0, k = 0; j < numComponents; j++, i++, k += 2) {
  49131. data[i] = (data[i] * transform[k] >> 8) + transform[k + 1];
  49132. }
  49133. }
  49134. }
  49135. return data;
  49136. },
  49137. _isColorConversionNeeded: function isColorConversionNeeded() {
  49138. if (this.adobe && this.adobe.transformCode) {
  49139. return true;
  49140. } else if (this.numComponents === 3) {
  49141. if (!this.adobe && this.colorTransform === 0) {
  49142. return false;
  49143. }
  49144. return true;
  49145. }
  49146. if (!this.adobe && this.colorTransform === 1) {
  49147. return true;
  49148. }
  49149. return false;
  49150. },
  49151. _convertYccToRgb: function convertYccToRgb(data) {
  49152. var Y, Cb, Cr;
  49153. for (var i = 0, length = data.length; i < length; i += 3) {
  49154. Y = data[i];
  49155. Cb = data[i + 1];
  49156. Cr = data[i + 2];
  49157. data[i] = clamp0to255(Y - 179.456 + 1.402 * Cr);
  49158. data[i + 1] = clamp0to255(Y + 135.459 - 0.344 * Cb - 0.714 * Cr);
  49159. data[i + 2] = clamp0to255(Y - 226.816 + 1.772 * Cb);
  49160. }
  49161. return data;
  49162. },
  49163. _convertYcckToRgb: function convertYcckToRgb(data) {
  49164. var Y, Cb, Cr, k;
  49165. var offset = 0;
  49166. for (var i = 0, length = data.length; i < length; i += 4) {
  49167. Y = data[i];
  49168. Cb = data[i + 1];
  49169. Cr = data[i + 2];
  49170. k = data[i + 3];
  49171. 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);
  49172. 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);
  49173. 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);
  49174. data[offset++] = clamp0to255(r);
  49175. data[offset++] = clamp0to255(g);
  49176. data[offset++] = clamp0to255(b);
  49177. }
  49178. return data;
  49179. },
  49180. _convertYcckToCmyk: function convertYcckToCmyk(data) {
  49181. var Y, Cb, Cr;
  49182. for (var i = 0, length = data.length; i < length; i += 4) {
  49183. Y = data[i];
  49184. Cb = data[i + 1];
  49185. Cr = data[i + 2];
  49186. data[i] = clamp0to255(434.456 - Y - 1.402 * Cr);
  49187. data[i + 1] = clamp0to255(119.541 - Y + 0.344 * Cb + 0.714 * Cr);
  49188. data[i + 2] = clamp0to255(481.816 - Y - 1.772 * Cb);
  49189. }
  49190. return data;
  49191. },
  49192. _convertCmykToRgb: function convertCmykToRgb(data) {
  49193. var c, m, y, k;
  49194. var offset = 0;
  49195. var min = -255 * 255 * 255;
  49196. var scale = 1 / 255 / 255;
  49197. for (var i = 0, length = data.length; i < length; i += 4) {
  49198. c = data[i];
  49199. m = data[i + 1];
  49200. y = data[i + 2];
  49201. k = data[i + 3];
  49202. 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);
  49203. 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);
  49204. 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);
  49205. data[offset++] = r >= 0 ? 255 : r <= min ? 0 : 255 + r * scale | 0;
  49206. data[offset++] = g >= 0 ? 255 : g <= min ? 0 : 255 + g * scale | 0;
  49207. data[offset++] = b >= 0 ? 255 : b <= min ? 0 : 255 + b * scale | 0;
  49208. }
  49209. return data;
  49210. },
  49211. getData: function getData(width, height, forceRGBoutput) {
  49212. if (this.numComponents > 4) {
  49213. error('JPEG error: Unsupported color mode');
  49214. }
  49215. var data = this._getLinearizedBlockData(width, height);
  49216. if (this.numComponents === 1 && forceRGBoutput) {
  49217. var dataLength = data.length;
  49218. var rgbData = new Uint8Array(dataLength * 3);
  49219. var offset = 0;
  49220. for (var i = 0; i < dataLength; i++) {
  49221. var grayColor = data[i];
  49222. rgbData[offset++] = grayColor;
  49223. rgbData[offset++] = grayColor;
  49224. rgbData[offset++] = grayColor;
  49225. }
  49226. return rgbData;
  49227. } else if (this.numComponents === 3 && this._isColorConversionNeeded()) {
  49228. return this._convertYccToRgb(data);
  49229. } else if (this.numComponents === 4) {
  49230. if (this._isColorConversionNeeded()) {
  49231. if (forceRGBoutput) {
  49232. return this._convertYcckToRgb(data);
  49233. }
  49234. return this._convertYcckToCmyk(data);
  49235. } else if (forceRGBoutput) {
  49236. return this._convertCmykToRgb(data);
  49237. }
  49238. }
  49239. return data;
  49240. }
  49241. };
  49242. return JpegImage;
  49243. }();
  49244. exports.JpegImage = JpegImage;
  49245. /***/ }),
  49246. /* 37 */
  49247. /***/ (function(module, exports, __w_pdfjs_require__) {
  49248. "use strict";
  49249. var sharedUtil = __w_pdfjs_require__(0);
  49250. var getLookupTableFactory = sharedUtil.getLookupTableFactory;
  49251. var getMetrics = getLookupTableFactory(function (t) {
  49252. t['Courier'] = 600;
  49253. t['Courier-Bold'] = 600;
  49254. t['Courier-BoldOblique'] = 600;
  49255. t['Courier-Oblique'] = 600;
  49256. t['Helvetica'] = getLookupTableFactory(function (t) {
  49257. t['space'] = 278;
  49258. t['exclam'] = 278;
  49259. t['quotedbl'] = 355;
  49260. t['numbersign'] = 556;
  49261. t['dollar'] = 556;
  49262. t['percent'] = 889;
  49263. t['ampersand'] = 667;
  49264. t['quoteright'] = 222;
  49265. t['parenleft'] = 333;
  49266. t['parenright'] = 333;
  49267. t['asterisk'] = 389;
  49268. t['plus'] = 584;
  49269. t['comma'] = 278;
  49270. t['hyphen'] = 333;
  49271. t['period'] = 278;
  49272. t['slash'] = 278;
  49273. t['zero'] = 556;
  49274. t['one'] = 556;
  49275. t['two'] = 556;
  49276. t['three'] = 556;
  49277. t['four'] = 556;
  49278. t['five'] = 556;
  49279. t['six'] = 556;
  49280. t['seven'] = 556;
  49281. t['eight'] = 556;
  49282. t['nine'] = 556;
  49283. t['colon'] = 278;
  49284. t['semicolon'] = 278;
  49285. t['less'] = 584;
  49286. t['equal'] = 584;
  49287. t['greater'] = 584;
  49288. t['question'] = 556;
  49289. t['at'] = 1015;
  49290. t['A'] = 667;
  49291. t['B'] = 667;
  49292. t['C'] = 722;
  49293. t['D'] = 722;
  49294. t['E'] = 667;
  49295. t['F'] = 611;
  49296. t['G'] = 778;
  49297. t['H'] = 722;
  49298. t['I'] = 278;
  49299. t['J'] = 500;
  49300. t['K'] = 667;
  49301. t['L'] = 556;
  49302. t['M'] = 833;
  49303. t['N'] = 722;
  49304. t['O'] = 778;
  49305. t['P'] = 667;
  49306. t['Q'] = 778;
  49307. t['R'] = 722;
  49308. t['S'] = 667;
  49309. t['T'] = 611;
  49310. t['U'] = 722;
  49311. t['V'] = 667;
  49312. t['W'] = 944;
  49313. t['X'] = 667;
  49314. t['Y'] = 667;
  49315. t['Z'] = 611;
  49316. t['bracketleft'] = 278;
  49317. t['backslash'] = 278;
  49318. t['bracketright'] = 278;
  49319. t['asciicircum'] = 469;
  49320. t['underscore'] = 556;
  49321. t['quoteleft'] = 222;
  49322. t['a'] = 556;
  49323. t['b'] = 556;
  49324. t['c'] = 500;
  49325. t['d'] = 556;
  49326. t['e'] = 556;
  49327. t['f'] = 278;
  49328. t['g'] = 556;
  49329. t['h'] = 556;
  49330. t['i'] = 222;
  49331. t['j'] = 222;
  49332. t['k'] = 500;
  49333. t['l'] = 222;
  49334. t['m'] = 833;
  49335. t['n'] = 556;
  49336. t['o'] = 556;
  49337. t['p'] = 556;
  49338. t['q'] = 556;
  49339. t['r'] = 333;
  49340. t['s'] = 500;
  49341. t['t'] = 278;
  49342. t['u'] = 556;
  49343. t['v'] = 500;
  49344. t['w'] = 722;
  49345. t['x'] = 500;
  49346. t['y'] = 500;
  49347. t['z'] = 500;
  49348. t['braceleft'] = 334;
  49349. t['bar'] = 260;
  49350. t['braceright'] = 334;
  49351. t['asciitilde'] = 584;
  49352. t['exclamdown'] = 333;
  49353. t['cent'] = 556;
  49354. t['sterling'] = 556;
  49355. t['fraction'] = 167;
  49356. t['yen'] = 556;
  49357. t['florin'] = 556;
  49358. t['section'] = 556;
  49359. t['currency'] = 556;
  49360. t['quotesingle'] = 191;
  49361. t['quotedblleft'] = 333;
  49362. t['guillemotleft'] = 556;
  49363. t['guilsinglleft'] = 333;
  49364. t['guilsinglright'] = 333;
  49365. t['fi'] = 500;
  49366. t['fl'] = 500;
  49367. t['endash'] = 556;
  49368. t['dagger'] = 556;
  49369. t['daggerdbl'] = 556;
  49370. t['periodcentered'] = 278;
  49371. t['paragraph'] = 537;
  49372. t['bullet'] = 350;
  49373. t['quotesinglbase'] = 222;
  49374. t['quotedblbase'] = 333;
  49375. t['quotedblright'] = 333;
  49376. t['guillemotright'] = 556;
  49377. t['ellipsis'] = 1000;
  49378. t['perthousand'] = 1000;
  49379. t['questiondown'] = 611;
  49380. t['grave'] = 333;
  49381. t['acute'] = 333;
  49382. t['circumflex'] = 333;
  49383. t['tilde'] = 333;
  49384. t['macron'] = 333;
  49385. t['breve'] = 333;
  49386. t['dotaccent'] = 333;
  49387. t['dieresis'] = 333;
  49388. t['ring'] = 333;
  49389. t['cedilla'] = 333;
  49390. t['hungarumlaut'] = 333;
  49391. t['ogonek'] = 333;
  49392. t['caron'] = 333;
  49393. t['emdash'] = 1000;
  49394. t['AE'] = 1000;
  49395. t['ordfeminine'] = 370;
  49396. t['Lslash'] = 556;
  49397. t['Oslash'] = 778;
  49398. t['OE'] = 1000;
  49399. t['ordmasculine'] = 365;
  49400. t['ae'] = 889;
  49401. t['dotlessi'] = 278;
  49402. t['lslash'] = 222;
  49403. t['oslash'] = 611;
  49404. t['oe'] = 944;
  49405. t['germandbls'] = 611;
  49406. t['Idieresis'] = 278;
  49407. t['eacute'] = 556;
  49408. t['abreve'] = 556;
  49409. t['uhungarumlaut'] = 556;
  49410. t['ecaron'] = 556;
  49411. t['Ydieresis'] = 667;
  49412. t['divide'] = 584;
  49413. t['Yacute'] = 667;
  49414. t['Acircumflex'] = 667;
  49415. t['aacute'] = 556;
  49416. t['Ucircumflex'] = 722;
  49417. t['yacute'] = 500;
  49418. t['scommaaccent'] = 500;
  49419. t['ecircumflex'] = 556;
  49420. t['Uring'] = 722;
  49421. t['Udieresis'] = 722;
  49422. t['aogonek'] = 556;
  49423. t['Uacute'] = 722;
  49424. t['uogonek'] = 556;
  49425. t['Edieresis'] = 667;
  49426. t['Dcroat'] = 722;
  49427. t['commaaccent'] = 250;
  49428. t['copyright'] = 737;
  49429. t['Emacron'] = 667;
  49430. t['ccaron'] = 500;
  49431. t['aring'] = 556;
  49432. t['Ncommaaccent'] = 722;
  49433. t['lacute'] = 222;
  49434. t['agrave'] = 556;
  49435. t['Tcommaaccent'] = 611;
  49436. t['Cacute'] = 722;
  49437. t['atilde'] = 556;
  49438. t['Edotaccent'] = 667;
  49439. t['scaron'] = 500;
  49440. t['scedilla'] = 500;
  49441. t['iacute'] = 278;
  49442. t['lozenge'] = 471;
  49443. t['Rcaron'] = 722;
  49444. t['Gcommaaccent'] = 778;
  49445. t['ucircumflex'] = 556;
  49446. t['acircumflex'] = 556;
  49447. t['Amacron'] = 667;
  49448. t['rcaron'] = 333;
  49449. t['ccedilla'] = 500;
  49450. t['Zdotaccent'] = 611;
  49451. t['Thorn'] = 667;
  49452. t['Omacron'] = 778;
  49453. t['Racute'] = 722;
  49454. t['Sacute'] = 667;
  49455. t['dcaron'] = 643;
  49456. t['Umacron'] = 722;
  49457. t['uring'] = 556;
  49458. t['threesuperior'] = 333;
  49459. t['Ograve'] = 778;
  49460. t['Agrave'] = 667;
  49461. t['Abreve'] = 667;
  49462. t['multiply'] = 584;
  49463. t['uacute'] = 556;
  49464. t['Tcaron'] = 611;
  49465. t['partialdiff'] = 476;
  49466. t['ydieresis'] = 500;
  49467. t['Nacute'] = 722;
  49468. t['icircumflex'] = 278;
  49469. t['Ecircumflex'] = 667;
  49470. t['adieresis'] = 556;
  49471. t['edieresis'] = 556;
  49472. t['cacute'] = 500;
  49473. t['nacute'] = 556;
  49474. t['umacron'] = 556;
  49475. t['Ncaron'] = 722;
  49476. t['Iacute'] = 278;
  49477. t['plusminus'] = 584;
  49478. t['brokenbar'] = 260;
  49479. t['registered'] = 737;
  49480. t['Gbreve'] = 778;
  49481. t['Idotaccent'] = 278;
  49482. t['summation'] = 600;
  49483. t['Egrave'] = 667;
  49484. t['racute'] = 333;
  49485. t['omacron'] = 556;
  49486. t['Zacute'] = 611;
  49487. t['Zcaron'] = 611;
  49488. t['greaterequal'] = 549;
  49489. t['Eth'] = 722;
  49490. t['Ccedilla'] = 722;
  49491. t['lcommaaccent'] = 222;
  49492. t['tcaron'] = 317;
  49493. t['eogonek'] = 556;
  49494. t['Uogonek'] = 722;
  49495. t['Aacute'] = 667;
  49496. t['Adieresis'] = 667;
  49497. t['egrave'] = 556;
  49498. t['zacute'] = 500;
  49499. t['iogonek'] = 222;
  49500. t['Oacute'] = 778;
  49501. t['oacute'] = 556;
  49502. t['amacron'] = 556;
  49503. t['sacute'] = 500;
  49504. t['idieresis'] = 278;
  49505. t['Ocircumflex'] = 778;
  49506. t['Ugrave'] = 722;
  49507. t['Delta'] = 612;
  49508. t['thorn'] = 556;
  49509. t['twosuperior'] = 333;
  49510. t['Odieresis'] = 778;
  49511. t['mu'] = 556;
  49512. t['igrave'] = 278;
  49513. t['ohungarumlaut'] = 556;
  49514. t['Eogonek'] = 667;
  49515. t['dcroat'] = 556;
  49516. t['threequarters'] = 834;
  49517. t['Scedilla'] = 667;
  49518. t['lcaron'] = 299;
  49519. t['Kcommaaccent'] = 667;
  49520. t['Lacute'] = 556;
  49521. t['trademark'] = 1000;
  49522. t['edotaccent'] = 556;
  49523. t['Igrave'] = 278;
  49524. t['Imacron'] = 278;
  49525. t['Lcaron'] = 556;
  49526. t['onehalf'] = 834;
  49527. t['lessequal'] = 549;
  49528. t['ocircumflex'] = 556;
  49529. t['ntilde'] = 556;
  49530. t['Uhungarumlaut'] = 722;
  49531. t['Eacute'] = 667;
  49532. t['emacron'] = 556;
  49533. t['gbreve'] = 556;
  49534. t['onequarter'] = 834;
  49535. t['Scaron'] = 667;
  49536. t['Scommaaccent'] = 667;
  49537. t['Ohungarumlaut'] = 778;
  49538. t['degree'] = 400;
  49539. t['ograve'] = 556;
  49540. t['Ccaron'] = 722;
  49541. t['ugrave'] = 556;
  49542. t['radical'] = 453;
  49543. t['Dcaron'] = 722;
  49544. t['rcommaaccent'] = 333;
  49545. t['Ntilde'] = 722;
  49546. t['otilde'] = 556;
  49547. t['Rcommaaccent'] = 722;
  49548. t['Lcommaaccent'] = 556;
  49549. t['Atilde'] = 667;
  49550. t['Aogonek'] = 667;
  49551. t['Aring'] = 667;
  49552. t['Otilde'] = 778;
  49553. t['zdotaccent'] = 500;
  49554. t['Ecaron'] = 667;
  49555. t['Iogonek'] = 278;
  49556. t['kcommaaccent'] = 500;
  49557. t['minus'] = 584;
  49558. t['Icircumflex'] = 278;
  49559. t['ncaron'] = 556;
  49560. t['tcommaaccent'] = 278;
  49561. t['logicalnot'] = 584;
  49562. t['odieresis'] = 556;
  49563. t['udieresis'] = 556;
  49564. t['notequal'] = 549;
  49565. t['gcommaaccent'] = 556;
  49566. t['eth'] = 556;
  49567. t['zcaron'] = 500;
  49568. t['ncommaaccent'] = 556;
  49569. t['onesuperior'] = 333;
  49570. t['imacron'] = 278;
  49571. t['Euro'] = 556;
  49572. });
  49573. t['Helvetica-Bold'] = getLookupTableFactory(function (t) {
  49574. t['space'] = 278;
  49575. t['exclam'] = 333;
  49576. t['quotedbl'] = 474;
  49577. t['numbersign'] = 556;
  49578. t['dollar'] = 556;
  49579. t['percent'] = 889;
  49580. t['ampersand'] = 722;
  49581. t['quoteright'] = 278;
  49582. t['parenleft'] = 333;
  49583. t['parenright'] = 333;
  49584. t['asterisk'] = 389;
  49585. t['plus'] = 584;
  49586. t['comma'] = 278;
  49587. t['hyphen'] = 333;
  49588. t['period'] = 278;
  49589. t['slash'] = 278;
  49590. t['zero'] = 556;
  49591. t['one'] = 556;
  49592. t['two'] = 556;
  49593. t['three'] = 556;
  49594. t['four'] = 556;
  49595. t['five'] = 556;
  49596. t['six'] = 556;
  49597. t['seven'] = 556;
  49598. t['eight'] = 556;
  49599. t['nine'] = 556;
  49600. t['colon'] = 333;
  49601. t['semicolon'] = 333;
  49602. t['less'] = 584;
  49603. t['equal'] = 584;
  49604. t['greater'] = 584;
  49605. t['question'] = 611;
  49606. t['at'] = 975;
  49607. t['A'] = 722;
  49608. t['B'] = 722;
  49609. t['C'] = 722;
  49610. t['D'] = 722;
  49611. t['E'] = 667;
  49612. t['F'] = 611;
  49613. t['G'] = 778;
  49614. t['H'] = 722;
  49615. t['I'] = 278;
  49616. t['J'] = 556;
  49617. t['K'] = 722;
  49618. t['L'] = 611;
  49619. t['M'] = 833;
  49620. t['N'] = 722;
  49621. t['O'] = 778;
  49622. t['P'] = 667;
  49623. t['Q'] = 778;
  49624. t['R'] = 722;
  49625. t['S'] = 667;
  49626. t['T'] = 611;
  49627. t['U'] = 722;
  49628. t['V'] = 667;
  49629. t['W'] = 944;
  49630. t['X'] = 667;
  49631. t['Y'] = 667;
  49632. t['Z'] = 611;
  49633. t['bracketleft'] = 333;
  49634. t['backslash'] = 278;
  49635. t['bracketright'] = 333;
  49636. t['asciicircum'] = 584;
  49637. t['underscore'] = 556;
  49638. t['quoteleft'] = 278;
  49639. t['a'] = 556;
  49640. t['b'] = 611;
  49641. t['c'] = 556;
  49642. t['d'] = 611;
  49643. t['e'] = 556;
  49644. t['f'] = 333;
  49645. t['g'] = 611;
  49646. t['h'] = 611;
  49647. t['i'] = 278;
  49648. t['j'] = 278;
  49649. t['k'] = 556;
  49650. t['l'] = 278;
  49651. t['m'] = 889;
  49652. t['n'] = 611;
  49653. t['o'] = 611;
  49654. t['p'] = 611;
  49655. t['q'] = 611;
  49656. t['r'] = 389;
  49657. t['s'] = 556;
  49658. t['t'] = 333;
  49659. t['u'] = 611;
  49660. t['v'] = 556;
  49661. t['w'] = 778;
  49662. t['x'] = 556;
  49663. t['y'] = 556;
  49664. t['z'] = 500;
  49665. t['braceleft'] = 389;
  49666. t['bar'] = 280;
  49667. t['braceright'] = 389;
  49668. t['asciitilde'] = 584;
  49669. t['exclamdown'] = 333;
  49670. t['cent'] = 556;
  49671. t['sterling'] = 556;
  49672. t['fraction'] = 167;
  49673. t['yen'] = 556;
  49674. t['florin'] = 556;
  49675. t['section'] = 556;
  49676. t['currency'] = 556;
  49677. t['quotesingle'] = 238;
  49678. t['quotedblleft'] = 500;
  49679. t['guillemotleft'] = 556;
  49680. t['guilsinglleft'] = 333;
  49681. t['guilsinglright'] = 333;
  49682. t['fi'] = 611;
  49683. t['fl'] = 611;
  49684. t['endash'] = 556;
  49685. t['dagger'] = 556;
  49686. t['daggerdbl'] = 556;
  49687. t['periodcentered'] = 278;
  49688. t['paragraph'] = 556;
  49689. t['bullet'] = 350;
  49690. t['quotesinglbase'] = 278;
  49691. t['quotedblbase'] = 500;
  49692. t['quotedblright'] = 500;
  49693. t['guillemotright'] = 556;
  49694. t['ellipsis'] = 1000;
  49695. t['perthousand'] = 1000;
  49696. t['questiondown'] = 611;
  49697. t['grave'] = 333;
  49698. t['acute'] = 333;
  49699. t['circumflex'] = 333;
  49700. t['tilde'] = 333;
  49701. t['macron'] = 333;
  49702. t['breve'] = 333;
  49703. t['dotaccent'] = 333;
  49704. t['dieresis'] = 333;
  49705. t['ring'] = 333;
  49706. t['cedilla'] = 333;
  49707. t['hungarumlaut'] = 333;
  49708. t['ogonek'] = 333;
  49709. t['caron'] = 333;
  49710. t['emdash'] = 1000;
  49711. t['AE'] = 1000;
  49712. t['ordfeminine'] = 370;
  49713. t['Lslash'] = 611;
  49714. t['Oslash'] = 778;
  49715. t['OE'] = 1000;
  49716. t['ordmasculine'] = 365;
  49717. t['ae'] = 889;
  49718. t['dotlessi'] = 278;
  49719. t['lslash'] = 278;
  49720. t['oslash'] = 611;
  49721. t['oe'] = 944;
  49722. t['germandbls'] = 611;
  49723. t['Idieresis'] = 278;
  49724. t['eacute'] = 556;
  49725. t['abreve'] = 556;
  49726. t['uhungarumlaut'] = 611;
  49727. t['ecaron'] = 556;
  49728. t['Ydieresis'] = 667;
  49729. t['divide'] = 584;
  49730. t['Yacute'] = 667;
  49731. t['Acircumflex'] = 722;
  49732. t['aacute'] = 556;
  49733. t['Ucircumflex'] = 722;
  49734. t['yacute'] = 556;
  49735. t['scommaaccent'] = 556;
  49736. t['ecircumflex'] = 556;
  49737. t['Uring'] = 722;
  49738. t['Udieresis'] = 722;
  49739. t['aogonek'] = 556;
  49740. t['Uacute'] = 722;
  49741. t['uogonek'] = 611;
  49742. t['Edieresis'] = 667;
  49743. t['Dcroat'] = 722;
  49744. t['commaaccent'] = 250;
  49745. t['copyright'] = 737;
  49746. t['Emacron'] = 667;
  49747. t['ccaron'] = 556;
  49748. t['aring'] = 556;
  49749. t['Ncommaaccent'] = 722;
  49750. t['lacute'] = 278;
  49751. t['agrave'] = 556;
  49752. t['Tcommaaccent'] = 611;
  49753. t['Cacute'] = 722;
  49754. t['atilde'] = 556;
  49755. t['Edotaccent'] = 667;
  49756. t['scaron'] = 556;
  49757. t['scedilla'] = 556;
  49758. t['iacute'] = 278;
  49759. t['lozenge'] = 494;
  49760. t['Rcaron'] = 722;
  49761. t['Gcommaaccent'] = 778;
  49762. t['ucircumflex'] = 611;
  49763. t['acircumflex'] = 556;
  49764. t['Amacron'] = 722;
  49765. t['rcaron'] = 389;
  49766. t['ccedilla'] = 556;
  49767. t['Zdotaccent'] = 611;
  49768. t['Thorn'] = 667;
  49769. t['Omacron'] = 778;
  49770. t['Racute'] = 722;
  49771. t['Sacute'] = 667;
  49772. t['dcaron'] = 743;
  49773. t['Umacron'] = 722;
  49774. t['uring'] = 611;
  49775. t['threesuperior'] = 333;
  49776. t['Ograve'] = 778;
  49777. t['Agrave'] = 722;
  49778. t['Abreve'] = 722;
  49779. t['multiply'] = 584;
  49780. t['uacute'] = 611;
  49781. t['Tcaron'] = 611;
  49782. t['partialdiff'] = 494;
  49783. t['ydieresis'] = 556;
  49784. t['Nacute'] = 722;
  49785. t['icircumflex'] = 278;
  49786. t['Ecircumflex'] = 667;
  49787. t['adieresis'] = 556;
  49788. t['edieresis'] = 556;
  49789. t['cacute'] = 556;
  49790. t['nacute'] = 611;
  49791. t['umacron'] = 611;
  49792. t['Ncaron'] = 722;
  49793. t['Iacute'] = 278;
  49794. t['plusminus'] = 584;
  49795. t['brokenbar'] = 280;
  49796. t['registered'] = 737;
  49797. t['Gbreve'] = 778;
  49798. t['Idotaccent'] = 278;
  49799. t['summation'] = 600;
  49800. t['Egrave'] = 667;
  49801. t['racute'] = 389;
  49802. t['omacron'] = 611;
  49803. t['Zacute'] = 611;
  49804. t['Zcaron'] = 611;
  49805. t['greaterequal'] = 549;
  49806. t['Eth'] = 722;
  49807. t['Ccedilla'] = 722;
  49808. t['lcommaaccent'] = 278;
  49809. t['tcaron'] = 389;
  49810. t['eogonek'] = 556;
  49811. t['Uogonek'] = 722;
  49812. t['Aacute'] = 722;
  49813. t['Adieresis'] = 722;
  49814. t['egrave'] = 556;
  49815. t['zacute'] = 500;
  49816. t['iogonek'] = 278;
  49817. t['Oacute'] = 778;
  49818. t['oacute'] = 611;
  49819. t['amacron'] = 556;
  49820. t['sacute'] = 556;
  49821. t['idieresis'] = 278;
  49822. t['Ocircumflex'] = 778;
  49823. t['Ugrave'] = 722;
  49824. t['Delta'] = 612;
  49825. t['thorn'] = 611;
  49826. t['twosuperior'] = 333;
  49827. t['Odieresis'] = 778;
  49828. t['mu'] = 611;
  49829. t['igrave'] = 278;
  49830. t['ohungarumlaut'] = 611;
  49831. t['Eogonek'] = 667;
  49832. t['dcroat'] = 611;
  49833. t['threequarters'] = 834;
  49834. t['Scedilla'] = 667;
  49835. t['lcaron'] = 400;
  49836. t['Kcommaaccent'] = 722;
  49837. t['Lacute'] = 611;
  49838. t['trademark'] = 1000;
  49839. t['edotaccent'] = 556;
  49840. t['Igrave'] = 278;
  49841. t['Imacron'] = 278;
  49842. t['Lcaron'] = 611;
  49843. t['onehalf'] = 834;
  49844. t['lessequal'] = 549;
  49845. t['ocircumflex'] = 611;
  49846. t['ntilde'] = 611;
  49847. t['Uhungarumlaut'] = 722;
  49848. t['Eacute'] = 667;
  49849. t['emacron'] = 556;
  49850. t['gbreve'] = 611;
  49851. t['onequarter'] = 834;
  49852. t['Scaron'] = 667;
  49853. t['Scommaaccent'] = 667;
  49854. t['Ohungarumlaut'] = 778;
  49855. t['degree'] = 400;
  49856. t['ograve'] = 611;
  49857. t['Ccaron'] = 722;
  49858. t['ugrave'] = 611;
  49859. t['radical'] = 549;
  49860. t['Dcaron'] = 722;
  49861. t['rcommaaccent'] = 389;
  49862. t['Ntilde'] = 722;
  49863. t['otilde'] = 611;
  49864. t['Rcommaaccent'] = 722;
  49865. t['Lcommaaccent'] = 611;
  49866. t['Atilde'] = 722;
  49867. t['Aogonek'] = 722;
  49868. t['Aring'] = 722;
  49869. t['Otilde'] = 778;
  49870. t['zdotaccent'] = 500;
  49871. t['Ecaron'] = 667;
  49872. t['Iogonek'] = 278;
  49873. t['kcommaaccent'] = 556;
  49874. t['minus'] = 584;
  49875. t['Icircumflex'] = 278;
  49876. t['ncaron'] = 611;
  49877. t['tcommaaccent'] = 333;
  49878. t['logicalnot'] = 584;
  49879. t['odieresis'] = 611;
  49880. t['udieresis'] = 611;
  49881. t['notequal'] = 549;
  49882. t['gcommaaccent'] = 611;
  49883. t['eth'] = 611;
  49884. t['zcaron'] = 500;
  49885. t['ncommaaccent'] = 611;
  49886. t['onesuperior'] = 333;
  49887. t['imacron'] = 278;
  49888. t['Euro'] = 556;
  49889. });
  49890. t['Helvetica-BoldOblique'] = getLookupTableFactory(function (t) {
  49891. t['space'] = 278;
  49892. t['exclam'] = 333;
  49893. t['quotedbl'] = 474;
  49894. t['numbersign'] = 556;
  49895. t['dollar'] = 556;
  49896. t['percent'] = 889;
  49897. t['ampersand'] = 722;
  49898. t['quoteright'] = 278;
  49899. t['parenleft'] = 333;
  49900. t['parenright'] = 333;
  49901. t['asterisk'] = 389;
  49902. t['plus'] = 584;
  49903. t['comma'] = 278;
  49904. t['hyphen'] = 333;
  49905. t['period'] = 278;
  49906. t['slash'] = 278;
  49907. t['zero'] = 556;
  49908. t['one'] = 556;
  49909. t['two'] = 556;
  49910. t['three'] = 556;
  49911. t['four'] = 556;
  49912. t['five'] = 556;
  49913. t['six'] = 556;
  49914. t['seven'] = 556;
  49915. t['eight'] = 556;
  49916. t['nine'] = 556;
  49917. t['colon'] = 333;
  49918. t['semicolon'] = 333;
  49919. t['less'] = 584;
  49920. t['equal'] = 584;
  49921. t['greater'] = 584;
  49922. t['question'] = 611;
  49923. t['at'] = 975;
  49924. t['A'] = 722;
  49925. t['B'] = 722;
  49926. t['C'] = 722;
  49927. t['D'] = 722;
  49928. t['E'] = 667;
  49929. t['F'] = 611;
  49930. t['G'] = 778;
  49931. t['H'] = 722;
  49932. t['I'] = 278;
  49933. t['J'] = 556;
  49934. t['K'] = 722;
  49935. t['L'] = 611;
  49936. t['M'] = 833;
  49937. t['N'] = 722;
  49938. t['O'] = 778;
  49939. t['P'] = 667;
  49940. t['Q'] = 778;
  49941. t['R'] = 722;
  49942. t['S'] = 667;
  49943. t['T'] = 611;
  49944. t['U'] = 722;
  49945. t['V'] = 667;
  49946. t['W'] = 944;
  49947. t['X'] = 667;
  49948. t['Y'] = 667;
  49949. t['Z'] = 611;
  49950. t['bracketleft'] = 333;
  49951. t['backslash'] = 278;
  49952. t['bracketright'] = 333;
  49953. t['asciicircum'] = 584;
  49954. t['underscore'] = 556;
  49955. t['quoteleft'] = 278;
  49956. t['a'] = 556;
  49957. t['b'] = 611;
  49958. t['c'] = 556;
  49959. t['d'] = 611;
  49960. t['e'] = 556;
  49961. t['f'] = 333;
  49962. t['g'] = 611;
  49963. t['h'] = 611;
  49964. t['i'] = 278;
  49965. t['j'] = 278;
  49966. t['k'] = 556;
  49967. t['l'] = 278;
  49968. t['m'] = 889;
  49969. t['n'] = 611;
  49970. t['o'] = 611;
  49971. t['p'] = 611;
  49972. t['q'] = 611;
  49973. t['r'] = 389;
  49974. t['s'] = 556;
  49975. t['t'] = 333;
  49976. t['u'] = 611;
  49977. t['v'] = 556;
  49978. t['w'] = 778;
  49979. t['x'] = 556;
  49980. t['y'] = 556;
  49981. t['z'] = 500;
  49982. t['braceleft'] = 389;
  49983. t['bar'] = 280;
  49984. t['braceright'] = 389;
  49985. t['asciitilde'] = 584;
  49986. t['exclamdown'] = 333;
  49987. t['cent'] = 556;
  49988. t['sterling'] = 556;
  49989. t['fraction'] = 167;
  49990. t['yen'] = 556;
  49991. t['florin'] = 556;
  49992. t['section'] = 556;
  49993. t['currency'] = 556;
  49994. t['quotesingle'] = 238;
  49995. t['quotedblleft'] = 500;
  49996. t['guillemotleft'] = 556;
  49997. t['guilsinglleft'] = 333;
  49998. t['guilsinglright'] = 333;
  49999. t['fi'] = 611;
  50000. t['fl'] = 611;
  50001. t['endash'] = 556;
  50002. t['dagger'] = 556;
  50003. t['daggerdbl'] = 556;
  50004. t['periodcentered'] = 278;
  50005. t['paragraph'] = 556;
  50006. t['bullet'] = 350;
  50007. t['quotesinglbase'] = 278;
  50008. t['quotedblbase'] = 500;
  50009. t['quotedblright'] = 500;
  50010. t['guillemotright'] = 556;
  50011. t['ellipsis'] = 1000;
  50012. t['perthousand'] = 1000;
  50013. t['questiondown'] = 611;
  50014. t['grave'] = 333;
  50015. t['acute'] = 333;
  50016. t['circumflex'] = 333;
  50017. t['tilde'] = 333;
  50018. t['macron'] = 333;
  50019. t['breve'] = 333;
  50020. t['dotaccent'] = 333;
  50021. t['dieresis'] = 333;
  50022. t['ring'] = 333;
  50023. t['cedilla'] = 333;
  50024. t['hungarumlaut'] = 333;
  50025. t['ogonek'] = 333;
  50026. t['caron'] = 333;
  50027. t['emdash'] = 1000;
  50028. t['AE'] = 1000;
  50029. t['ordfeminine'] = 370;
  50030. t['Lslash'] = 611;
  50031. t['Oslash'] = 778;
  50032. t['OE'] = 1000;
  50033. t['ordmasculine'] = 365;
  50034. t['ae'] = 889;
  50035. t['dotlessi'] = 278;
  50036. t['lslash'] = 278;
  50037. t['oslash'] = 611;
  50038. t['oe'] = 944;
  50039. t['germandbls'] = 611;
  50040. t['Idieresis'] = 278;
  50041. t['eacute'] = 556;
  50042. t['abreve'] = 556;
  50043. t['uhungarumlaut'] = 611;
  50044. t['ecaron'] = 556;
  50045. t['Ydieresis'] = 667;
  50046. t['divide'] = 584;
  50047. t['Yacute'] = 667;
  50048. t['Acircumflex'] = 722;
  50049. t['aacute'] = 556;
  50050. t['Ucircumflex'] = 722;
  50051. t['yacute'] = 556;
  50052. t['scommaaccent'] = 556;
  50053. t['ecircumflex'] = 556;
  50054. t['Uring'] = 722;
  50055. t['Udieresis'] = 722;
  50056. t['aogonek'] = 556;
  50057. t['Uacute'] = 722;
  50058. t['uogonek'] = 611;
  50059. t['Edieresis'] = 667;
  50060. t['Dcroat'] = 722;
  50061. t['commaaccent'] = 250;
  50062. t['copyright'] = 737;
  50063. t['Emacron'] = 667;
  50064. t['ccaron'] = 556;
  50065. t['aring'] = 556;
  50066. t['Ncommaaccent'] = 722;
  50067. t['lacute'] = 278;
  50068. t['agrave'] = 556;
  50069. t['Tcommaaccent'] = 611;
  50070. t['Cacute'] = 722;
  50071. t['atilde'] = 556;
  50072. t['Edotaccent'] = 667;
  50073. t['scaron'] = 556;
  50074. t['scedilla'] = 556;
  50075. t['iacute'] = 278;
  50076. t['lozenge'] = 494;
  50077. t['Rcaron'] = 722;
  50078. t['Gcommaaccent'] = 778;
  50079. t['ucircumflex'] = 611;
  50080. t['acircumflex'] = 556;
  50081. t['Amacron'] = 722;
  50082. t['rcaron'] = 389;
  50083. t['ccedilla'] = 556;
  50084. t['Zdotaccent'] = 611;
  50085. t['Thorn'] = 667;
  50086. t['Omacron'] = 778;
  50087. t['Racute'] = 722;
  50088. t['Sacute'] = 667;
  50089. t['dcaron'] = 743;
  50090. t['Umacron'] = 722;
  50091. t['uring'] = 611;
  50092. t['threesuperior'] = 333;
  50093. t['Ograve'] = 778;
  50094. t['Agrave'] = 722;
  50095. t['Abreve'] = 722;
  50096. t['multiply'] = 584;
  50097. t['uacute'] = 611;
  50098. t['Tcaron'] = 611;
  50099. t['partialdiff'] = 494;
  50100. t['ydieresis'] = 556;
  50101. t['Nacute'] = 722;
  50102. t['icircumflex'] = 278;
  50103. t['Ecircumflex'] = 667;
  50104. t['adieresis'] = 556;
  50105. t['edieresis'] = 556;
  50106. t['cacute'] = 556;
  50107. t['nacute'] = 611;
  50108. t['umacron'] = 611;
  50109. t['Ncaron'] = 722;
  50110. t['Iacute'] = 278;
  50111. t['plusminus'] = 584;
  50112. t['brokenbar'] = 280;
  50113. t['registered'] = 737;
  50114. t['Gbreve'] = 778;
  50115. t['Idotaccent'] = 278;
  50116. t['summation'] = 600;
  50117. t['Egrave'] = 667;
  50118. t['racute'] = 389;
  50119. t['omacron'] = 611;
  50120. t['Zacute'] = 611;
  50121. t['Zcaron'] = 611;
  50122. t['greaterequal'] = 549;
  50123. t['Eth'] = 722;
  50124. t['Ccedilla'] = 722;
  50125. t['lcommaaccent'] = 278;
  50126. t['tcaron'] = 389;
  50127. t['eogonek'] = 556;
  50128. t['Uogonek'] = 722;
  50129. t['Aacute'] = 722;
  50130. t['Adieresis'] = 722;
  50131. t['egrave'] = 556;
  50132. t['zacute'] = 500;
  50133. t['iogonek'] = 278;
  50134. t['Oacute'] = 778;
  50135. t['oacute'] = 611;
  50136. t['amacron'] = 556;
  50137. t['sacute'] = 556;
  50138. t['idieresis'] = 278;
  50139. t['Ocircumflex'] = 778;
  50140. t['Ugrave'] = 722;
  50141. t['Delta'] = 612;
  50142. t['thorn'] = 611;
  50143. t['twosuperior'] = 333;
  50144. t['Odieresis'] = 778;
  50145. t['mu'] = 611;
  50146. t['igrave'] = 278;
  50147. t['ohungarumlaut'] = 611;
  50148. t['Eogonek'] = 667;
  50149. t['dcroat'] = 611;
  50150. t['threequarters'] = 834;
  50151. t['Scedilla'] = 667;
  50152. t['lcaron'] = 400;
  50153. t['Kcommaaccent'] = 722;
  50154. t['Lacute'] = 611;
  50155. t['trademark'] = 1000;
  50156. t['edotaccent'] = 556;
  50157. t['Igrave'] = 278;
  50158. t['Imacron'] = 278;
  50159. t['Lcaron'] = 611;
  50160. t['onehalf'] = 834;
  50161. t['lessequal'] = 549;
  50162. t['ocircumflex'] = 611;
  50163. t['ntilde'] = 611;
  50164. t['Uhungarumlaut'] = 722;
  50165. t['Eacute'] = 667;
  50166. t['emacron'] = 556;
  50167. t['gbreve'] = 611;
  50168. t['onequarter'] = 834;
  50169. t['Scaron'] = 667;
  50170. t['Scommaaccent'] = 667;
  50171. t['Ohungarumlaut'] = 778;
  50172. t['degree'] = 400;
  50173. t['ograve'] = 611;
  50174. t['Ccaron'] = 722;
  50175. t['ugrave'] = 611;
  50176. t['radical'] = 549;
  50177. t['Dcaron'] = 722;
  50178. t['rcommaaccent'] = 389;
  50179. t['Ntilde'] = 722;
  50180. t['otilde'] = 611;
  50181. t['Rcommaaccent'] = 722;
  50182. t['Lcommaaccent'] = 611;
  50183. t['Atilde'] = 722;
  50184. t['Aogonek'] = 722;
  50185. t['Aring'] = 722;
  50186. t['Otilde'] = 778;
  50187. t['zdotaccent'] = 500;
  50188. t['Ecaron'] = 667;
  50189. t['Iogonek'] = 278;
  50190. t['kcommaaccent'] = 556;
  50191. t['minus'] = 584;
  50192. t['Icircumflex'] = 278;
  50193. t['ncaron'] = 611;
  50194. t['tcommaaccent'] = 333;
  50195. t['logicalnot'] = 584;
  50196. t['odieresis'] = 611;
  50197. t['udieresis'] = 611;
  50198. t['notequal'] = 549;
  50199. t['gcommaaccent'] = 611;
  50200. t['eth'] = 611;
  50201. t['zcaron'] = 500;
  50202. t['ncommaaccent'] = 611;
  50203. t['onesuperior'] = 333;
  50204. t['imacron'] = 278;
  50205. t['Euro'] = 556;
  50206. });
  50207. t['Helvetica-Oblique'] = getLookupTableFactory(function (t) {
  50208. t['space'] = 278;
  50209. t['exclam'] = 278;
  50210. t['quotedbl'] = 355;
  50211. t['numbersign'] = 556;
  50212. t['dollar'] = 556;
  50213. t['percent'] = 889;
  50214. t['ampersand'] = 667;
  50215. t['quoteright'] = 222;
  50216. t['parenleft'] = 333;
  50217. t['parenright'] = 333;
  50218. t['asterisk'] = 389;
  50219. t['plus'] = 584;
  50220. t['comma'] = 278;
  50221. t['hyphen'] = 333;
  50222. t['period'] = 278;
  50223. t['slash'] = 278;
  50224. t['zero'] = 556;
  50225. t['one'] = 556;
  50226. t['two'] = 556;
  50227. t['three'] = 556;
  50228. t['four'] = 556;
  50229. t['five'] = 556;
  50230. t['six'] = 556;
  50231. t['seven'] = 556;
  50232. t['eight'] = 556;
  50233. t['nine'] = 556;
  50234. t['colon'] = 278;
  50235. t['semicolon'] = 278;
  50236. t['less'] = 584;
  50237. t['equal'] = 584;
  50238. t['greater'] = 584;
  50239. t['question'] = 556;
  50240. t['at'] = 1015;
  50241. t['A'] = 667;
  50242. t['B'] = 667;
  50243. t['C'] = 722;
  50244. t['D'] = 722;
  50245. t['E'] = 667;
  50246. t['F'] = 611;
  50247. t['G'] = 778;
  50248. t['H'] = 722;
  50249. t['I'] = 278;
  50250. t['J'] = 500;
  50251. t['K'] = 667;
  50252. t['L'] = 556;
  50253. t['M'] = 833;
  50254. t['N'] = 722;
  50255. t['O'] = 778;
  50256. t['P'] = 667;
  50257. t['Q'] = 778;
  50258. t['R'] = 722;
  50259. t['S'] = 667;
  50260. t['T'] = 611;
  50261. t['U'] = 722;
  50262. t['V'] = 667;
  50263. t['W'] = 944;
  50264. t['X'] = 667;
  50265. t['Y'] = 667;
  50266. t['Z'] = 611;
  50267. t['bracketleft'] = 278;
  50268. t['backslash'] = 278;
  50269. t['bracketright'] = 278;
  50270. t['asciicircum'] = 469;
  50271. t['underscore'] = 556;
  50272. t['quoteleft'] = 222;
  50273. t['a'] = 556;
  50274. t['b'] = 556;
  50275. t['c'] = 500;
  50276. t['d'] = 556;
  50277. t['e'] = 556;
  50278. t['f'] = 278;
  50279. t['g'] = 556;
  50280. t['h'] = 556;
  50281. t['i'] = 222;
  50282. t['j'] = 222;
  50283. t['k'] = 500;
  50284. t['l'] = 222;
  50285. t['m'] = 833;
  50286. t['n'] = 556;
  50287. t['o'] = 556;
  50288. t['p'] = 556;
  50289. t['q'] = 556;
  50290. t['r'] = 333;
  50291. t['s'] = 500;
  50292. t['t'] = 278;
  50293. t['u'] = 556;
  50294. t['v'] = 500;
  50295. t['w'] = 722;
  50296. t['x'] = 500;
  50297. t['y'] = 500;
  50298. t['z'] = 500;
  50299. t['braceleft'] = 334;
  50300. t['bar'] = 260;
  50301. t['braceright'] = 334;
  50302. t['asciitilde'] = 584;
  50303. t['exclamdown'] = 333;
  50304. t['cent'] = 556;
  50305. t['sterling'] = 556;
  50306. t['fraction'] = 167;
  50307. t['yen'] = 556;
  50308. t['florin'] = 556;
  50309. t['section'] = 556;
  50310. t['currency'] = 556;
  50311. t['quotesingle'] = 191;
  50312. t['quotedblleft'] = 333;
  50313. t['guillemotleft'] = 556;
  50314. t['guilsinglleft'] = 333;
  50315. t['guilsinglright'] = 333;
  50316. t['fi'] = 500;
  50317. t['fl'] = 500;
  50318. t['endash'] = 556;
  50319. t['dagger'] = 556;
  50320. t['daggerdbl'] = 556;
  50321. t['periodcentered'] = 278;
  50322. t['paragraph'] = 537;
  50323. t['bullet'] = 350;
  50324. t['quotesinglbase'] = 222;
  50325. t['quotedblbase'] = 333;
  50326. t['quotedblright'] = 333;
  50327. t['guillemotright'] = 556;
  50328. t['ellipsis'] = 1000;
  50329. t['perthousand'] = 1000;
  50330. t['questiondown'] = 611;
  50331. t['grave'] = 333;
  50332. t['acute'] = 333;
  50333. t['circumflex'] = 333;
  50334. t['tilde'] = 333;
  50335. t['macron'] = 333;
  50336. t['breve'] = 333;
  50337. t['dotaccent'] = 333;
  50338. t['dieresis'] = 333;
  50339. t['ring'] = 333;
  50340. t['cedilla'] = 333;
  50341. t['hungarumlaut'] = 333;
  50342. t['ogonek'] = 333;
  50343. t['caron'] = 333;
  50344. t['emdash'] = 1000;
  50345. t['AE'] = 1000;
  50346. t['ordfeminine'] = 370;
  50347. t['Lslash'] = 556;
  50348. t['Oslash'] = 778;
  50349. t['OE'] = 1000;
  50350. t['ordmasculine'] = 365;
  50351. t['ae'] = 889;
  50352. t['dotlessi'] = 278;
  50353. t['lslash'] = 222;
  50354. t['oslash'] = 611;
  50355. t['oe'] = 944;
  50356. t['germandbls'] = 611;
  50357. t['Idieresis'] = 278;
  50358. t['eacute'] = 556;
  50359. t['abreve'] = 556;
  50360. t['uhungarumlaut'] = 556;
  50361. t['ecaron'] = 556;
  50362. t['Ydieresis'] = 667;
  50363. t['divide'] = 584;
  50364. t['Yacute'] = 667;
  50365. t['Acircumflex'] = 667;
  50366. t['aacute'] = 556;
  50367. t['Ucircumflex'] = 722;
  50368. t['yacute'] = 500;
  50369. t['scommaaccent'] = 500;
  50370. t['ecircumflex'] = 556;
  50371. t['Uring'] = 722;
  50372. t['Udieresis'] = 722;
  50373. t['aogonek'] = 556;
  50374. t['Uacute'] = 722;
  50375. t['uogonek'] = 556;
  50376. t['Edieresis'] = 667;
  50377. t['Dcroat'] = 722;
  50378. t['commaaccent'] = 250;
  50379. t['copyright'] = 737;
  50380. t['Emacron'] = 667;
  50381. t['ccaron'] = 500;
  50382. t['aring'] = 556;
  50383. t['Ncommaaccent'] = 722;
  50384. t['lacute'] = 222;
  50385. t['agrave'] = 556;
  50386. t['Tcommaaccent'] = 611;
  50387. t['Cacute'] = 722;
  50388. t['atilde'] = 556;
  50389. t['Edotaccent'] = 667;
  50390. t['scaron'] = 500;
  50391. t['scedilla'] = 500;
  50392. t['iacute'] = 278;
  50393. t['lozenge'] = 471;
  50394. t['Rcaron'] = 722;
  50395. t['Gcommaaccent'] = 778;
  50396. t['ucircumflex'] = 556;
  50397. t['acircumflex'] = 556;
  50398. t['Amacron'] = 667;
  50399. t['rcaron'] = 333;
  50400. t['ccedilla'] = 500;
  50401. t['Zdotaccent'] = 611;
  50402. t['Thorn'] = 667;
  50403. t['Omacron'] = 778;
  50404. t['Racute'] = 722;
  50405. t['Sacute'] = 667;
  50406. t['dcaron'] = 643;
  50407. t['Umacron'] = 722;
  50408. t['uring'] = 556;
  50409. t['threesuperior'] = 333;
  50410. t['Ograve'] = 778;
  50411. t['Agrave'] = 667;
  50412. t['Abreve'] = 667;
  50413. t['multiply'] = 584;
  50414. t['uacute'] = 556;
  50415. t['Tcaron'] = 611;
  50416. t['partialdiff'] = 476;
  50417. t['ydieresis'] = 500;
  50418. t['Nacute'] = 722;
  50419. t['icircumflex'] = 278;
  50420. t['Ecircumflex'] = 667;
  50421. t['adieresis'] = 556;
  50422. t['edieresis'] = 556;
  50423. t['cacute'] = 500;
  50424. t['nacute'] = 556;
  50425. t['umacron'] = 556;
  50426. t['Ncaron'] = 722;
  50427. t['Iacute'] = 278;
  50428. t['plusminus'] = 584;
  50429. t['brokenbar'] = 260;
  50430. t['registered'] = 737;
  50431. t['Gbreve'] = 778;
  50432. t['Idotaccent'] = 278;
  50433. t['summation'] = 600;
  50434. t['Egrave'] = 667;
  50435. t['racute'] = 333;
  50436. t['omacron'] = 556;
  50437. t['Zacute'] = 611;
  50438. t['Zcaron'] = 611;
  50439. t['greaterequal'] = 549;
  50440. t['Eth'] = 722;
  50441. t['Ccedilla'] = 722;
  50442. t['lcommaaccent'] = 222;
  50443. t['tcaron'] = 317;
  50444. t['eogonek'] = 556;
  50445. t['Uogonek'] = 722;
  50446. t['Aacute'] = 667;
  50447. t['Adieresis'] = 667;
  50448. t['egrave'] = 556;
  50449. t['zacute'] = 500;
  50450. t['iogonek'] = 222;
  50451. t['Oacute'] = 778;
  50452. t['oacute'] = 556;
  50453. t['amacron'] = 556;
  50454. t['sacute'] = 500;
  50455. t['idieresis'] = 278;
  50456. t['Ocircumflex'] = 778;
  50457. t['Ugrave'] = 722;
  50458. t['Delta'] = 612;
  50459. t['thorn'] = 556;
  50460. t['twosuperior'] = 333;
  50461. t['Odieresis'] = 778;
  50462. t['mu'] = 556;
  50463. t['igrave'] = 278;
  50464. t['ohungarumlaut'] = 556;
  50465. t['Eogonek'] = 667;
  50466. t['dcroat'] = 556;
  50467. t['threequarters'] = 834;
  50468. t['Scedilla'] = 667;
  50469. t['lcaron'] = 299;
  50470. t['Kcommaaccent'] = 667;
  50471. t['Lacute'] = 556;
  50472. t['trademark'] = 1000;
  50473. t['edotaccent'] = 556;
  50474. t['Igrave'] = 278;
  50475. t['Imacron'] = 278;
  50476. t['Lcaron'] = 556;
  50477. t['onehalf'] = 834;
  50478. t['lessequal'] = 549;
  50479. t['ocircumflex'] = 556;
  50480. t['ntilde'] = 556;
  50481. t['Uhungarumlaut'] = 722;
  50482. t['Eacute'] = 667;
  50483. t['emacron'] = 556;
  50484. t['gbreve'] = 556;
  50485. t['onequarter'] = 834;
  50486. t['Scaron'] = 667;
  50487. t['Scommaaccent'] = 667;
  50488. t['Ohungarumlaut'] = 778;
  50489. t['degree'] = 400;
  50490. t['ograve'] = 556;
  50491. t['Ccaron'] = 722;
  50492. t['ugrave'] = 556;
  50493. t['radical'] = 453;
  50494. t['Dcaron'] = 722;
  50495. t['rcommaaccent'] = 333;
  50496. t['Ntilde'] = 722;
  50497. t['otilde'] = 556;
  50498. t['Rcommaaccent'] = 722;
  50499. t['Lcommaaccent'] = 556;
  50500. t['Atilde'] = 667;
  50501. t['Aogonek'] = 667;
  50502. t['Aring'] = 667;
  50503. t['Otilde'] = 778;
  50504. t['zdotaccent'] = 500;
  50505. t['Ecaron'] = 667;
  50506. t['Iogonek'] = 278;
  50507. t['kcommaaccent'] = 500;
  50508. t['minus'] = 584;
  50509. t['Icircumflex'] = 278;
  50510. t['ncaron'] = 556;
  50511. t['tcommaaccent'] = 278;
  50512. t['logicalnot'] = 584;
  50513. t['odieresis'] = 556;
  50514. t['udieresis'] = 556;
  50515. t['notequal'] = 549;
  50516. t['gcommaaccent'] = 556;
  50517. t['eth'] = 556;
  50518. t['zcaron'] = 500;
  50519. t['ncommaaccent'] = 556;
  50520. t['onesuperior'] = 333;
  50521. t['imacron'] = 278;
  50522. t['Euro'] = 556;
  50523. });
  50524. t['Symbol'] = getLookupTableFactory(function (t) {
  50525. t['space'] = 250;
  50526. t['exclam'] = 333;
  50527. t['universal'] = 713;
  50528. t['numbersign'] = 500;
  50529. t['existential'] = 549;
  50530. t['percent'] = 833;
  50531. t['ampersand'] = 778;
  50532. t['suchthat'] = 439;
  50533. t['parenleft'] = 333;
  50534. t['parenright'] = 333;
  50535. t['asteriskmath'] = 500;
  50536. t['plus'] = 549;
  50537. t['comma'] = 250;
  50538. t['minus'] = 549;
  50539. t['period'] = 250;
  50540. t['slash'] = 278;
  50541. t['zero'] = 500;
  50542. t['one'] = 500;
  50543. t['two'] = 500;
  50544. t['three'] = 500;
  50545. t['four'] = 500;
  50546. t['five'] = 500;
  50547. t['six'] = 500;
  50548. t['seven'] = 500;
  50549. t['eight'] = 500;
  50550. t['nine'] = 500;
  50551. t['colon'] = 278;
  50552. t['semicolon'] = 278;
  50553. t['less'] = 549;
  50554. t['equal'] = 549;
  50555. t['greater'] = 549;
  50556. t['question'] = 444;
  50557. t['congruent'] = 549;
  50558. t['Alpha'] = 722;
  50559. t['Beta'] = 667;
  50560. t['Chi'] = 722;
  50561. t['Delta'] = 612;
  50562. t['Epsilon'] = 611;
  50563. t['Phi'] = 763;
  50564. t['Gamma'] = 603;
  50565. t['Eta'] = 722;
  50566. t['Iota'] = 333;
  50567. t['theta1'] = 631;
  50568. t['Kappa'] = 722;
  50569. t['Lambda'] = 686;
  50570. t['Mu'] = 889;
  50571. t['Nu'] = 722;
  50572. t['Omicron'] = 722;
  50573. t['Pi'] = 768;
  50574. t['Theta'] = 741;
  50575. t['Rho'] = 556;
  50576. t['Sigma'] = 592;
  50577. t['Tau'] = 611;
  50578. t['Upsilon'] = 690;
  50579. t['sigma1'] = 439;
  50580. t['Omega'] = 768;
  50581. t['Xi'] = 645;
  50582. t['Psi'] = 795;
  50583. t['Zeta'] = 611;
  50584. t['bracketleft'] = 333;
  50585. t['therefore'] = 863;
  50586. t['bracketright'] = 333;
  50587. t['perpendicular'] = 658;
  50588. t['underscore'] = 500;
  50589. t['radicalex'] = 500;
  50590. t['alpha'] = 631;
  50591. t['beta'] = 549;
  50592. t['chi'] = 549;
  50593. t['delta'] = 494;
  50594. t['epsilon'] = 439;
  50595. t['phi'] = 521;
  50596. t['gamma'] = 411;
  50597. t['eta'] = 603;
  50598. t['iota'] = 329;
  50599. t['phi1'] = 603;
  50600. t['kappa'] = 549;
  50601. t['lambda'] = 549;
  50602. t['mu'] = 576;
  50603. t['nu'] = 521;
  50604. t['omicron'] = 549;
  50605. t['pi'] = 549;
  50606. t['theta'] = 521;
  50607. t['rho'] = 549;
  50608. t['sigma'] = 603;
  50609. t['tau'] = 439;
  50610. t['upsilon'] = 576;
  50611. t['omega1'] = 713;
  50612. t['omega'] = 686;
  50613. t['xi'] = 493;
  50614. t['psi'] = 686;
  50615. t['zeta'] = 494;
  50616. t['braceleft'] = 480;
  50617. t['bar'] = 200;
  50618. t['braceright'] = 480;
  50619. t['similar'] = 549;
  50620. t['Euro'] = 750;
  50621. t['Upsilon1'] = 620;
  50622. t['minute'] = 247;
  50623. t['lessequal'] = 549;
  50624. t['fraction'] = 167;
  50625. t['infinity'] = 713;
  50626. t['florin'] = 500;
  50627. t['club'] = 753;
  50628. t['diamond'] = 753;
  50629. t['heart'] = 753;
  50630. t['spade'] = 753;
  50631. t['arrowboth'] = 1042;
  50632. t['arrowleft'] = 987;
  50633. t['arrowup'] = 603;
  50634. t['arrowright'] = 987;
  50635. t['arrowdown'] = 603;
  50636. t['degree'] = 400;
  50637. t['plusminus'] = 549;
  50638. t['second'] = 411;
  50639. t['greaterequal'] = 549;
  50640. t['multiply'] = 549;
  50641. t['proportional'] = 713;
  50642. t['partialdiff'] = 494;
  50643. t['bullet'] = 460;
  50644. t['divide'] = 549;
  50645. t['notequal'] = 549;
  50646. t['equivalence'] = 549;
  50647. t['approxequal'] = 549;
  50648. t['ellipsis'] = 1000;
  50649. t['arrowvertex'] = 603;
  50650. t['arrowhorizex'] = 1000;
  50651. t['carriagereturn'] = 658;
  50652. t['aleph'] = 823;
  50653. t['Ifraktur'] = 686;
  50654. t['Rfraktur'] = 795;
  50655. t['weierstrass'] = 987;
  50656. t['circlemultiply'] = 768;
  50657. t['circleplus'] = 768;
  50658. t['emptyset'] = 823;
  50659. t['intersection'] = 768;
  50660. t['union'] = 768;
  50661. t['propersuperset'] = 713;
  50662. t['reflexsuperset'] = 713;
  50663. t['notsubset'] = 713;
  50664. t['propersubset'] = 713;
  50665. t['reflexsubset'] = 713;
  50666. t['element'] = 713;
  50667. t['notelement'] = 713;
  50668. t['angle'] = 768;
  50669. t['gradient'] = 713;
  50670. t['registerserif'] = 790;
  50671. t['copyrightserif'] = 790;
  50672. t['trademarkserif'] = 890;
  50673. t['product'] = 823;
  50674. t['radical'] = 549;
  50675. t['dotmath'] = 250;
  50676. t['logicalnot'] = 713;
  50677. t['logicaland'] = 603;
  50678. t['logicalor'] = 603;
  50679. t['arrowdblboth'] = 1042;
  50680. t['arrowdblleft'] = 987;
  50681. t['arrowdblup'] = 603;
  50682. t['arrowdblright'] = 987;
  50683. t['arrowdbldown'] = 603;
  50684. t['lozenge'] = 494;
  50685. t['angleleft'] = 329;
  50686. t['registersans'] = 790;
  50687. t['copyrightsans'] = 790;
  50688. t['trademarksans'] = 786;
  50689. t['summation'] = 713;
  50690. t['parenlefttp'] = 384;
  50691. t['parenleftex'] = 384;
  50692. t['parenleftbt'] = 384;
  50693. t['bracketlefttp'] = 384;
  50694. t['bracketleftex'] = 384;
  50695. t['bracketleftbt'] = 384;
  50696. t['bracelefttp'] = 494;
  50697. t['braceleftmid'] = 494;
  50698. t['braceleftbt'] = 494;
  50699. t['braceex'] = 494;
  50700. t['angleright'] = 329;
  50701. t['integral'] = 274;
  50702. t['integraltp'] = 686;
  50703. t['integralex'] = 686;
  50704. t['integralbt'] = 686;
  50705. t['parenrighttp'] = 384;
  50706. t['parenrightex'] = 384;
  50707. t['parenrightbt'] = 384;
  50708. t['bracketrighttp'] = 384;
  50709. t['bracketrightex'] = 384;
  50710. t['bracketrightbt'] = 384;
  50711. t['bracerighttp'] = 494;
  50712. t['bracerightmid'] = 494;
  50713. t['bracerightbt'] = 494;
  50714. t['apple'] = 790;
  50715. });
  50716. t['Times-Roman'] = getLookupTableFactory(function (t) {
  50717. t['space'] = 250;
  50718. t['exclam'] = 333;
  50719. t['quotedbl'] = 408;
  50720. t['numbersign'] = 500;
  50721. t['dollar'] = 500;
  50722. t['percent'] = 833;
  50723. t['ampersand'] = 778;
  50724. t['quoteright'] = 333;
  50725. t['parenleft'] = 333;
  50726. t['parenright'] = 333;
  50727. t['asterisk'] = 500;
  50728. t['plus'] = 564;
  50729. t['comma'] = 250;
  50730. t['hyphen'] = 333;
  50731. t['period'] = 250;
  50732. t['slash'] = 278;
  50733. t['zero'] = 500;
  50734. t['one'] = 500;
  50735. t['two'] = 500;
  50736. t['three'] = 500;
  50737. t['four'] = 500;
  50738. t['five'] = 500;
  50739. t['six'] = 500;
  50740. t['seven'] = 500;
  50741. t['eight'] = 500;
  50742. t['nine'] = 500;
  50743. t['colon'] = 278;
  50744. t['semicolon'] = 278;
  50745. t['less'] = 564;
  50746. t['equal'] = 564;
  50747. t['greater'] = 564;
  50748. t['question'] = 444;
  50749. t['at'] = 921;
  50750. t['A'] = 722;
  50751. t['B'] = 667;
  50752. t['C'] = 667;
  50753. t['D'] = 722;
  50754. t['E'] = 611;
  50755. t['F'] = 556;
  50756. t['G'] = 722;
  50757. t['H'] = 722;
  50758. t['I'] = 333;
  50759. t['J'] = 389;
  50760. t['K'] = 722;
  50761. t['L'] = 611;
  50762. t['M'] = 889;
  50763. t['N'] = 722;
  50764. t['O'] = 722;
  50765. t['P'] = 556;
  50766. t['Q'] = 722;
  50767. t['R'] = 667;
  50768. t['S'] = 556;
  50769. t['T'] = 611;
  50770. t['U'] = 722;
  50771. t['V'] = 722;
  50772. t['W'] = 944;
  50773. t['X'] = 722;
  50774. t['Y'] = 722;
  50775. t['Z'] = 611;
  50776. t['bracketleft'] = 333;
  50777. t['backslash'] = 278;
  50778. t['bracketright'] = 333;
  50779. t['asciicircum'] = 469;
  50780. t['underscore'] = 500;
  50781. t['quoteleft'] = 333;
  50782. t['a'] = 444;
  50783. t['b'] = 500;
  50784. t['c'] = 444;
  50785. t['d'] = 500;
  50786. t['e'] = 444;
  50787. t['f'] = 333;
  50788. t['g'] = 500;
  50789. t['h'] = 500;
  50790. t['i'] = 278;
  50791. t['j'] = 278;
  50792. t['k'] = 500;
  50793. t['l'] = 278;
  50794. t['m'] = 778;
  50795. t['n'] = 500;
  50796. t['o'] = 500;
  50797. t['p'] = 500;
  50798. t['q'] = 500;
  50799. t['r'] = 333;
  50800. t['s'] = 389;
  50801. t['t'] = 278;
  50802. t['u'] = 500;
  50803. t['v'] = 500;
  50804. t['w'] = 722;
  50805. t['x'] = 500;
  50806. t['y'] = 500;
  50807. t['z'] = 444;
  50808. t['braceleft'] = 480;
  50809. t['bar'] = 200;
  50810. t['braceright'] = 480;
  50811. t['asciitilde'] = 541;
  50812. t['exclamdown'] = 333;
  50813. t['cent'] = 500;
  50814. t['sterling'] = 500;
  50815. t['fraction'] = 167;
  50816. t['yen'] = 500;
  50817. t['florin'] = 500;
  50818. t['section'] = 500;
  50819. t['currency'] = 500;
  50820. t['quotesingle'] = 180;
  50821. t['quotedblleft'] = 444;
  50822. t['guillemotleft'] = 500;
  50823. t['guilsinglleft'] = 333;
  50824. t['guilsinglright'] = 333;
  50825. t['fi'] = 556;
  50826. t['fl'] = 556;
  50827. t['endash'] = 500;
  50828. t['dagger'] = 500;
  50829. t['daggerdbl'] = 500;
  50830. t['periodcentered'] = 250;
  50831. t['paragraph'] = 453;
  50832. t['bullet'] = 350;
  50833. t['quotesinglbase'] = 333;
  50834. t['quotedblbase'] = 444;
  50835. t['quotedblright'] = 444;
  50836. t['guillemotright'] = 500;
  50837. t['ellipsis'] = 1000;
  50838. t['perthousand'] = 1000;
  50839. t['questiondown'] = 444;
  50840. t['grave'] = 333;
  50841. t['acute'] = 333;
  50842. t['circumflex'] = 333;
  50843. t['tilde'] = 333;
  50844. t['macron'] = 333;
  50845. t['breve'] = 333;
  50846. t['dotaccent'] = 333;
  50847. t['dieresis'] = 333;
  50848. t['ring'] = 333;
  50849. t['cedilla'] = 333;
  50850. t['hungarumlaut'] = 333;
  50851. t['ogonek'] = 333;
  50852. t['caron'] = 333;
  50853. t['emdash'] = 1000;
  50854. t['AE'] = 889;
  50855. t['ordfeminine'] = 276;
  50856. t['Lslash'] = 611;
  50857. t['Oslash'] = 722;
  50858. t['OE'] = 889;
  50859. t['ordmasculine'] = 310;
  50860. t['ae'] = 667;
  50861. t['dotlessi'] = 278;
  50862. t['lslash'] = 278;
  50863. t['oslash'] = 500;
  50864. t['oe'] = 722;
  50865. t['germandbls'] = 500;
  50866. t['Idieresis'] = 333;
  50867. t['eacute'] = 444;
  50868. t['abreve'] = 444;
  50869. t['uhungarumlaut'] = 500;
  50870. t['ecaron'] = 444;
  50871. t['Ydieresis'] = 722;
  50872. t['divide'] = 564;
  50873. t['Yacute'] = 722;
  50874. t['Acircumflex'] = 722;
  50875. t['aacute'] = 444;
  50876. t['Ucircumflex'] = 722;
  50877. t['yacute'] = 500;
  50878. t['scommaaccent'] = 389;
  50879. t['ecircumflex'] = 444;
  50880. t['Uring'] = 722;
  50881. t['Udieresis'] = 722;
  50882. t['aogonek'] = 444;
  50883. t['Uacute'] = 722;
  50884. t['uogonek'] = 500;
  50885. t['Edieresis'] = 611;
  50886. t['Dcroat'] = 722;
  50887. t['commaaccent'] = 250;
  50888. t['copyright'] = 760;
  50889. t['Emacron'] = 611;
  50890. t['ccaron'] = 444;
  50891. t['aring'] = 444;
  50892. t['Ncommaaccent'] = 722;
  50893. t['lacute'] = 278;
  50894. t['agrave'] = 444;
  50895. t['Tcommaaccent'] = 611;
  50896. t['Cacute'] = 667;
  50897. t['atilde'] = 444;
  50898. t['Edotaccent'] = 611;
  50899. t['scaron'] = 389;
  50900. t['scedilla'] = 389;
  50901. t['iacute'] = 278;
  50902. t['lozenge'] = 471;
  50903. t['Rcaron'] = 667;
  50904. t['Gcommaaccent'] = 722;
  50905. t['ucircumflex'] = 500;
  50906. t['acircumflex'] = 444;
  50907. t['Amacron'] = 722;
  50908. t['rcaron'] = 333;
  50909. t['ccedilla'] = 444;
  50910. t['Zdotaccent'] = 611;
  50911. t['Thorn'] = 556;
  50912. t['Omacron'] = 722;
  50913. t['Racute'] = 667;
  50914. t['Sacute'] = 556;
  50915. t['dcaron'] = 588;
  50916. t['Umacron'] = 722;
  50917. t['uring'] = 500;
  50918. t['threesuperior'] = 300;
  50919. t['Ograve'] = 722;
  50920. t['Agrave'] = 722;
  50921. t['Abreve'] = 722;
  50922. t['multiply'] = 564;
  50923. t['uacute'] = 500;
  50924. t['Tcaron'] = 611;
  50925. t['partialdiff'] = 476;
  50926. t['ydieresis'] = 500;
  50927. t['Nacute'] = 722;
  50928. t['icircumflex'] = 278;
  50929. t['Ecircumflex'] = 611;
  50930. t['adieresis'] = 444;
  50931. t['edieresis'] = 444;
  50932. t['cacute'] = 444;
  50933. t['nacute'] = 500;
  50934. t['umacron'] = 500;
  50935. t['Ncaron'] = 722;
  50936. t['Iacute'] = 333;
  50937. t['plusminus'] = 564;
  50938. t['brokenbar'] = 200;
  50939. t['registered'] = 760;
  50940. t['Gbreve'] = 722;
  50941. t['Idotaccent'] = 333;
  50942. t['summation'] = 600;
  50943. t['Egrave'] = 611;
  50944. t['racute'] = 333;
  50945. t['omacron'] = 500;
  50946. t['Zacute'] = 611;
  50947. t['Zcaron'] = 611;
  50948. t['greaterequal'] = 549;
  50949. t['Eth'] = 722;
  50950. t['Ccedilla'] = 667;
  50951. t['lcommaaccent'] = 278;
  50952. t['tcaron'] = 326;
  50953. t['eogonek'] = 444;
  50954. t['Uogonek'] = 722;
  50955. t['Aacute'] = 722;
  50956. t['Adieresis'] = 722;
  50957. t['egrave'] = 444;
  50958. t['zacute'] = 444;
  50959. t['iogonek'] = 278;
  50960. t['Oacute'] = 722;
  50961. t['oacute'] = 500;
  50962. t['amacron'] = 444;
  50963. t['sacute'] = 389;
  50964. t['idieresis'] = 278;
  50965. t['Ocircumflex'] = 722;
  50966. t['Ugrave'] = 722;
  50967. t['Delta'] = 612;
  50968. t['thorn'] = 500;
  50969. t['twosuperior'] = 300;
  50970. t['Odieresis'] = 722;
  50971. t['mu'] = 500;
  50972. t['igrave'] = 278;
  50973. t['ohungarumlaut'] = 500;
  50974. t['Eogonek'] = 611;
  50975. t['dcroat'] = 500;
  50976. t['threequarters'] = 750;
  50977. t['Scedilla'] = 556;
  50978. t['lcaron'] = 344;
  50979. t['Kcommaaccent'] = 722;
  50980. t['Lacute'] = 611;
  50981. t['trademark'] = 980;
  50982. t['edotaccent'] = 444;
  50983. t['Igrave'] = 333;
  50984. t['Imacron'] = 333;
  50985. t['Lcaron'] = 611;
  50986. t['onehalf'] = 750;
  50987. t['lessequal'] = 549;
  50988. t['ocircumflex'] = 500;
  50989. t['ntilde'] = 500;
  50990. t['Uhungarumlaut'] = 722;
  50991. t['Eacute'] = 611;
  50992. t['emacron'] = 444;
  50993. t['gbreve'] = 500;
  50994. t['onequarter'] = 750;
  50995. t['Scaron'] = 556;
  50996. t['Scommaaccent'] = 556;
  50997. t['Ohungarumlaut'] = 722;
  50998. t['degree'] = 400;
  50999. t['ograve'] = 500;
  51000. t['Ccaron'] = 667;
  51001. t['ugrave'] = 500;
  51002. t['radical'] = 453;
  51003. t['Dcaron'] = 722;
  51004. t['rcommaaccent'] = 333;
  51005. t['Ntilde'] = 722;
  51006. t['otilde'] = 500;
  51007. t['Rcommaaccent'] = 667;
  51008. t['Lcommaaccent'] = 611;
  51009. t['Atilde'] = 722;
  51010. t['Aogonek'] = 722;
  51011. t['Aring'] = 722;
  51012. t['Otilde'] = 722;
  51013. t['zdotaccent'] = 444;
  51014. t['Ecaron'] = 611;
  51015. t['Iogonek'] = 333;
  51016. t['kcommaaccent'] = 500;
  51017. t['minus'] = 564;
  51018. t['Icircumflex'] = 333;
  51019. t['ncaron'] = 500;
  51020. t['tcommaaccent'] = 278;
  51021. t['logicalnot'] = 564;
  51022. t['odieresis'] = 500;
  51023. t['udieresis'] = 500;
  51024. t['notequal'] = 549;
  51025. t['gcommaaccent'] = 500;
  51026. t['eth'] = 500;
  51027. t['zcaron'] = 444;
  51028. t['ncommaaccent'] = 500;
  51029. t['onesuperior'] = 300;
  51030. t['imacron'] = 278;
  51031. t['Euro'] = 500;
  51032. });
  51033. t['Times-Bold'] = getLookupTableFactory(function (t) {
  51034. t['space'] = 250;
  51035. t['exclam'] = 333;
  51036. t['quotedbl'] = 555;
  51037. t['numbersign'] = 500;
  51038. t['dollar'] = 500;
  51039. t['percent'] = 1000;
  51040. t['ampersand'] = 833;
  51041. t['quoteright'] = 333;
  51042. t['parenleft'] = 333;
  51043. t['parenright'] = 333;
  51044. t['asterisk'] = 500;
  51045. t['plus'] = 570;
  51046. t['comma'] = 250;
  51047. t['hyphen'] = 333;
  51048. t['period'] = 250;
  51049. t['slash'] = 278;
  51050. t['zero'] = 500;
  51051. t['one'] = 500;
  51052. t['two'] = 500;
  51053. t['three'] = 500;
  51054. t['four'] = 500;
  51055. t['five'] = 500;
  51056. t['six'] = 500;
  51057. t['seven'] = 500;
  51058. t['eight'] = 500;
  51059. t['nine'] = 500;
  51060. t['colon'] = 333;
  51061. t['semicolon'] = 333;
  51062. t['less'] = 570;
  51063. t['equal'] = 570;
  51064. t['greater'] = 570;
  51065. t['question'] = 500;
  51066. t['at'] = 930;
  51067. t['A'] = 722;
  51068. t['B'] = 667;
  51069. t['C'] = 722;
  51070. t['D'] = 722;
  51071. t['E'] = 667;
  51072. t['F'] = 611;
  51073. t['G'] = 778;
  51074. t['H'] = 778;
  51075. t['I'] = 389;
  51076. t['J'] = 500;
  51077. t['K'] = 778;
  51078. t['L'] = 667;
  51079. t['M'] = 944;
  51080. t['N'] = 722;
  51081. t['O'] = 778;
  51082. t['P'] = 611;
  51083. t['Q'] = 778;
  51084. t['R'] = 722;
  51085. t['S'] = 556;
  51086. t['T'] = 667;
  51087. t['U'] = 722;
  51088. t['V'] = 722;
  51089. t['W'] = 1000;
  51090. t['X'] = 722;
  51091. t['Y'] = 722;
  51092. t['Z'] = 667;
  51093. t['bracketleft'] = 333;
  51094. t['backslash'] = 278;
  51095. t['bracketright'] = 333;
  51096. t['asciicircum'] = 581;
  51097. t['underscore'] = 500;
  51098. t['quoteleft'] = 333;
  51099. t['a'] = 500;
  51100. t['b'] = 556;
  51101. t['c'] = 444;
  51102. t['d'] = 556;
  51103. t['e'] = 444;
  51104. t['f'] = 333;
  51105. t['g'] = 500;
  51106. t['h'] = 556;
  51107. t['i'] = 278;
  51108. t['j'] = 333;
  51109. t['k'] = 556;
  51110. t['l'] = 278;
  51111. t['m'] = 833;
  51112. t['n'] = 556;
  51113. t['o'] = 500;
  51114. t['p'] = 556;
  51115. t['q'] = 556;
  51116. t['r'] = 444;
  51117. t['s'] = 389;
  51118. t['t'] = 333;
  51119. t['u'] = 556;
  51120. t['v'] = 500;
  51121. t['w'] = 722;
  51122. t['x'] = 500;
  51123. t['y'] = 500;
  51124. t['z'] = 444;
  51125. t['braceleft'] = 394;
  51126. t['bar'] = 220;
  51127. t['braceright'] = 394;
  51128. t['asciitilde'] = 520;
  51129. t['exclamdown'] = 333;
  51130. t['cent'] = 500;
  51131. t['sterling'] = 500;
  51132. t['fraction'] = 167;
  51133. t['yen'] = 500;
  51134. t['florin'] = 500;
  51135. t['section'] = 500;
  51136. t['currency'] = 500;
  51137. t['quotesingle'] = 278;
  51138. t['quotedblleft'] = 500;
  51139. t['guillemotleft'] = 500;
  51140. t['guilsinglleft'] = 333;
  51141. t['guilsinglright'] = 333;
  51142. t['fi'] = 556;
  51143. t['fl'] = 556;
  51144. t['endash'] = 500;
  51145. t['dagger'] = 500;
  51146. t['daggerdbl'] = 500;
  51147. t['periodcentered'] = 250;
  51148. t['paragraph'] = 540;
  51149. t['bullet'] = 350;
  51150. t['quotesinglbase'] = 333;
  51151. t['quotedblbase'] = 500;
  51152. t['quotedblright'] = 500;
  51153. t['guillemotright'] = 500;
  51154. t['ellipsis'] = 1000;
  51155. t['perthousand'] = 1000;
  51156. t['questiondown'] = 500;
  51157. t['grave'] = 333;
  51158. t['acute'] = 333;
  51159. t['circumflex'] = 333;
  51160. t['tilde'] = 333;
  51161. t['macron'] = 333;
  51162. t['breve'] = 333;
  51163. t['dotaccent'] = 333;
  51164. t['dieresis'] = 333;
  51165. t['ring'] = 333;
  51166. t['cedilla'] = 333;
  51167. t['hungarumlaut'] = 333;
  51168. t['ogonek'] = 333;
  51169. t['caron'] = 333;
  51170. t['emdash'] = 1000;
  51171. t['AE'] = 1000;
  51172. t['ordfeminine'] = 300;
  51173. t['Lslash'] = 667;
  51174. t['Oslash'] = 778;
  51175. t['OE'] = 1000;
  51176. t['ordmasculine'] = 330;
  51177. t['ae'] = 722;
  51178. t['dotlessi'] = 278;
  51179. t['lslash'] = 278;
  51180. t['oslash'] = 500;
  51181. t['oe'] = 722;
  51182. t['germandbls'] = 556;
  51183. t['Idieresis'] = 389;
  51184. t['eacute'] = 444;
  51185. t['abreve'] = 500;
  51186. t['uhungarumlaut'] = 556;
  51187. t['ecaron'] = 444;
  51188. t['Ydieresis'] = 722;
  51189. t['divide'] = 570;
  51190. t['Yacute'] = 722;
  51191. t['Acircumflex'] = 722;
  51192. t['aacute'] = 500;
  51193. t['Ucircumflex'] = 722;
  51194. t['yacute'] = 500;
  51195. t['scommaaccent'] = 389;
  51196. t['ecircumflex'] = 444;
  51197. t['Uring'] = 722;
  51198. t['Udieresis'] = 722;
  51199. t['aogonek'] = 500;
  51200. t['Uacute'] = 722;
  51201. t['uogonek'] = 556;
  51202. t['Edieresis'] = 667;
  51203. t['Dcroat'] = 722;
  51204. t['commaaccent'] = 250;
  51205. t['copyright'] = 747;
  51206. t['Emacron'] = 667;
  51207. t['ccaron'] = 444;
  51208. t['aring'] = 500;
  51209. t['Ncommaaccent'] = 722;
  51210. t['lacute'] = 278;
  51211. t['agrave'] = 500;
  51212. t['Tcommaaccent'] = 667;
  51213. t['Cacute'] = 722;
  51214. t['atilde'] = 500;
  51215. t['Edotaccent'] = 667;
  51216. t['scaron'] = 389;
  51217. t['scedilla'] = 389;
  51218. t['iacute'] = 278;
  51219. t['lozenge'] = 494;
  51220. t['Rcaron'] = 722;
  51221. t['Gcommaaccent'] = 778;
  51222. t['ucircumflex'] = 556;
  51223. t['acircumflex'] = 500;
  51224. t['Amacron'] = 722;
  51225. t['rcaron'] = 444;
  51226. t['ccedilla'] = 444;
  51227. t['Zdotaccent'] = 667;
  51228. t['Thorn'] = 611;
  51229. t['Omacron'] = 778;
  51230. t['Racute'] = 722;
  51231. t['Sacute'] = 556;
  51232. t['dcaron'] = 672;
  51233. t['Umacron'] = 722;
  51234. t['uring'] = 556;
  51235. t['threesuperior'] = 300;
  51236. t['Ograve'] = 778;
  51237. t['Agrave'] = 722;
  51238. t['Abreve'] = 722;
  51239. t['multiply'] = 570;
  51240. t['uacute'] = 556;
  51241. t['Tcaron'] = 667;
  51242. t['partialdiff'] = 494;
  51243. t['ydieresis'] = 500;
  51244. t['Nacute'] = 722;
  51245. t['icircumflex'] = 278;
  51246. t['Ecircumflex'] = 667;
  51247. t['adieresis'] = 500;
  51248. t['edieresis'] = 444;
  51249. t['cacute'] = 444;
  51250. t['nacute'] = 556;
  51251. t['umacron'] = 556;
  51252. t['Ncaron'] = 722;
  51253. t['Iacute'] = 389;
  51254. t['plusminus'] = 570;
  51255. t['brokenbar'] = 220;
  51256. t['registered'] = 747;
  51257. t['Gbreve'] = 778;
  51258. t['Idotaccent'] = 389;
  51259. t['summation'] = 600;
  51260. t['Egrave'] = 667;
  51261. t['racute'] = 444;
  51262. t['omacron'] = 500;
  51263. t['Zacute'] = 667;
  51264. t['Zcaron'] = 667;
  51265. t['greaterequal'] = 549;
  51266. t['Eth'] = 722;
  51267. t['Ccedilla'] = 722;
  51268. t['lcommaaccent'] = 278;
  51269. t['tcaron'] = 416;
  51270. t['eogonek'] = 444;
  51271. t['Uogonek'] = 722;
  51272. t['Aacute'] = 722;
  51273. t['Adieresis'] = 722;
  51274. t['egrave'] = 444;
  51275. t['zacute'] = 444;
  51276. t['iogonek'] = 278;
  51277. t['Oacute'] = 778;
  51278. t['oacute'] = 500;
  51279. t['amacron'] = 500;
  51280. t['sacute'] = 389;
  51281. t['idieresis'] = 278;
  51282. t['Ocircumflex'] = 778;
  51283. t['Ugrave'] = 722;
  51284. t['Delta'] = 612;
  51285. t['thorn'] = 556;
  51286. t['twosuperior'] = 300;
  51287. t['Odieresis'] = 778;
  51288. t['mu'] = 556;
  51289. t['igrave'] = 278;
  51290. t['ohungarumlaut'] = 500;
  51291. t['Eogonek'] = 667;
  51292. t['dcroat'] = 556;
  51293. t['threequarters'] = 750;
  51294. t['Scedilla'] = 556;
  51295. t['lcaron'] = 394;
  51296. t['Kcommaaccent'] = 778;
  51297. t['Lacute'] = 667;
  51298. t['trademark'] = 1000;
  51299. t['edotaccent'] = 444;
  51300. t['Igrave'] = 389;
  51301. t['Imacron'] = 389;
  51302. t['Lcaron'] = 667;
  51303. t['onehalf'] = 750;
  51304. t['lessequal'] = 549;
  51305. t['ocircumflex'] = 500;
  51306. t['ntilde'] = 556;
  51307. t['Uhungarumlaut'] = 722;
  51308. t['Eacute'] = 667;
  51309. t['emacron'] = 444;
  51310. t['gbreve'] = 500;
  51311. t['onequarter'] = 750;
  51312. t['Scaron'] = 556;
  51313. t['Scommaaccent'] = 556;
  51314. t['Ohungarumlaut'] = 778;
  51315. t['degree'] = 400;
  51316. t['ograve'] = 500;
  51317. t['Ccaron'] = 722;
  51318. t['ugrave'] = 556;
  51319. t['radical'] = 549;
  51320. t['Dcaron'] = 722;
  51321. t['rcommaaccent'] = 444;
  51322. t['Ntilde'] = 722;
  51323. t['otilde'] = 500;
  51324. t['Rcommaaccent'] = 722;
  51325. t['Lcommaaccent'] = 667;
  51326. t['Atilde'] = 722;
  51327. t['Aogonek'] = 722;
  51328. t['Aring'] = 722;
  51329. t['Otilde'] = 778;
  51330. t['zdotaccent'] = 444;
  51331. t['Ecaron'] = 667;
  51332. t['Iogonek'] = 389;
  51333. t['kcommaaccent'] = 556;
  51334. t['minus'] = 570;
  51335. t['Icircumflex'] = 389;
  51336. t['ncaron'] = 556;
  51337. t['tcommaaccent'] = 333;
  51338. t['logicalnot'] = 570;
  51339. t['odieresis'] = 500;
  51340. t['udieresis'] = 556;
  51341. t['notequal'] = 549;
  51342. t['gcommaaccent'] = 500;
  51343. t['eth'] = 500;
  51344. t['zcaron'] = 444;
  51345. t['ncommaaccent'] = 556;
  51346. t['onesuperior'] = 300;
  51347. t['imacron'] = 278;
  51348. t['Euro'] = 500;
  51349. });
  51350. t['Times-BoldItalic'] = getLookupTableFactory(function (t) {
  51351. t['space'] = 250;
  51352. t['exclam'] = 389;
  51353. t['quotedbl'] = 555;
  51354. t['numbersign'] = 500;
  51355. t['dollar'] = 500;
  51356. t['percent'] = 833;
  51357. t['ampersand'] = 778;
  51358. t['quoteright'] = 333;
  51359. t['parenleft'] = 333;
  51360. t['parenright'] = 333;
  51361. t['asterisk'] = 500;
  51362. t['plus'] = 570;
  51363. t['comma'] = 250;
  51364. t['hyphen'] = 333;
  51365. t['period'] = 250;
  51366. t['slash'] = 278;
  51367. t['zero'] = 500;
  51368. t['one'] = 500;
  51369. t['two'] = 500;
  51370. t['three'] = 500;
  51371. t['four'] = 500;
  51372. t['five'] = 500;
  51373. t['six'] = 500;
  51374. t['seven'] = 500;
  51375. t['eight'] = 500;
  51376. t['nine'] = 500;
  51377. t['colon'] = 333;
  51378. t['semicolon'] = 333;
  51379. t['less'] = 570;
  51380. t['equal'] = 570;
  51381. t['greater'] = 570;
  51382. t['question'] = 500;
  51383. t['at'] = 832;
  51384. t['A'] = 667;
  51385. t['B'] = 667;
  51386. t['C'] = 667;
  51387. t['D'] = 722;
  51388. t['E'] = 667;
  51389. t['F'] = 667;
  51390. t['G'] = 722;
  51391. t['H'] = 778;
  51392. t['I'] = 389;
  51393. t['J'] = 500;
  51394. t['K'] = 667;
  51395. t['L'] = 611;
  51396. t['M'] = 889;
  51397. t['N'] = 722;
  51398. t['O'] = 722;
  51399. t['P'] = 611;
  51400. t['Q'] = 722;
  51401. t['R'] = 667;
  51402. t['S'] = 556;
  51403. t['T'] = 611;
  51404. t['U'] = 722;
  51405. t['V'] = 667;
  51406. t['W'] = 889;
  51407. t['X'] = 667;
  51408. t['Y'] = 611;
  51409. t['Z'] = 611;
  51410. t['bracketleft'] = 333;
  51411. t['backslash'] = 278;
  51412. t['bracketright'] = 333;
  51413. t['asciicircum'] = 570;
  51414. t['underscore'] = 500;
  51415. t['quoteleft'] = 333;
  51416. t['a'] = 500;
  51417. t['b'] = 500;
  51418. t['c'] = 444;
  51419. t['d'] = 500;
  51420. t['e'] = 444;
  51421. t['f'] = 333;
  51422. t['g'] = 500;
  51423. t['h'] = 556;
  51424. t['i'] = 278;
  51425. t['j'] = 278;
  51426. t['k'] = 500;
  51427. t['l'] = 278;
  51428. t['m'] = 778;
  51429. t['n'] = 556;
  51430. t['o'] = 500;
  51431. t['p'] = 500;
  51432. t['q'] = 500;
  51433. t['r'] = 389;
  51434. t['s'] = 389;
  51435. t['t'] = 278;
  51436. t['u'] = 556;
  51437. t['v'] = 444;
  51438. t['w'] = 667;
  51439. t['x'] = 500;
  51440. t['y'] = 444;
  51441. t['z'] = 389;
  51442. t['braceleft'] = 348;
  51443. t['bar'] = 220;
  51444. t['braceright'] = 348;
  51445. t['asciitilde'] = 570;
  51446. t['exclamdown'] = 389;
  51447. t['cent'] = 500;
  51448. t['sterling'] = 500;
  51449. t['fraction'] = 167;
  51450. t['yen'] = 500;
  51451. t['florin'] = 500;
  51452. t['section'] = 500;
  51453. t['currency'] = 500;
  51454. t['quotesingle'] = 278;
  51455. t['quotedblleft'] = 500;
  51456. t['guillemotleft'] = 500;
  51457. t['guilsinglleft'] = 333;
  51458. t['guilsinglright'] = 333;
  51459. t['fi'] = 556;
  51460. t['fl'] = 556;
  51461. t['endash'] = 500;
  51462. t['dagger'] = 500;
  51463. t['daggerdbl'] = 500;
  51464. t['periodcentered'] = 250;
  51465. t['paragraph'] = 500;
  51466. t['bullet'] = 350;
  51467. t['quotesinglbase'] = 333;
  51468. t['quotedblbase'] = 500;
  51469. t['quotedblright'] = 500;
  51470. t['guillemotright'] = 500;
  51471. t['ellipsis'] = 1000;
  51472. t['perthousand'] = 1000;
  51473. t['questiondown'] = 500;
  51474. t['grave'] = 333;
  51475. t['acute'] = 333;
  51476. t['circumflex'] = 333;
  51477. t['tilde'] = 333;
  51478. t['macron'] = 333;
  51479. t['breve'] = 333;
  51480. t['dotaccent'] = 333;
  51481. t['dieresis'] = 333;
  51482. t['ring'] = 333;
  51483. t['cedilla'] = 333;
  51484. t['hungarumlaut'] = 333;
  51485. t['ogonek'] = 333;
  51486. t['caron'] = 333;
  51487. t['emdash'] = 1000;
  51488. t['AE'] = 944;
  51489. t['ordfeminine'] = 266;
  51490. t['Lslash'] = 611;
  51491. t['Oslash'] = 722;
  51492. t['OE'] = 944;
  51493. t['ordmasculine'] = 300;
  51494. t['ae'] = 722;
  51495. t['dotlessi'] = 278;
  51496. t['lslash'] = 278;
  51497. t['oslash'] = 500;
  51498. t['oe'] = 722;
  51499. t['germandbls'] = 500;
  51500. t['Idieresis'] = 389;
  51501. t['eacute'] = 444;
  51502. t['abreve'] = 500;
  51503. t['uhungarumlaut'] = 556;
  51504. t['ecaron'] = 444;
  51505. t['Ydieresis'] = 611;
  51506. t['divide'] = 570;
  51507. t['Yacute'] = 611;
  51508. t['Acircumflex'] = 667;
  51509. t['aacute'] = 500;
  51510. t['Ucircumflex'] = 722;
  51511. t['yacute'] = 444;
  51512. t['scommaaccent'] = 389;
  51513. t['ecircumflex'] = 444;
  51514. t['Uring'] = 722;
  51515. t['Udieresis'] = 722;
  51516. t['aogonek'] = 500;
  51517. t['Uacute'] = 722;
  51518. t['uogonek'] = 556;
  51519. t['Edieresis'] = 667;
  51520. t['Dcroat'] = 722;
  51521. t['commaaccent'] = 250;
  51522. t['copyright'] = 747;
  51523. t['Emacron'] = 667;
  51524. t['ccaron'] = 444;
  51525. t['aring'] = 500;
  51526. t['Ncommaaccent'] = 722;
  51527. t['lacute'] = 278;
  51528. t['agrave'] = 500;
  51529. t['Tcommaaccent'] = 611;
  51530. t['Cacute'] = 667;
  51531. t['atilde'] = 500;
  51532. t['Edotaccent'] = 667;
  51533. t['scaron'] = 389;
  51534. t['scedilla'] = 389;
  51535. t['iacute'] = 278;
  51536. t['lozenge'] = 494;
  51537. t['Rcaron'] = 667;
  51538. t['Gcommaaccent'] = 722;
  51539. t['ucircumflex'] = 556;
  51540. t['acircumflex'] = 500;
  51541. t['Amacron'] = 667;
  51542. t['rcaron'] = 389;
  51543. t['ccedilla'] = 444;
  51544. t['Zdotaccent'] = 611;
  51545. t['Thorn'] = 611;
  51546. t['Omacron'] = 722;
  51547. t['Racute'] = 667;
  51548. t['Sacute'] = 556;
  51549. t['dcaron'] = 608;
  51550. t['Umacron'] = 722;
  51551. t['uring'] = 556;
  51552. t['threesuperior'] = 300;
  51553. t['Ograve'] = 722;
  51554. t['Agrave'] = 667;
  51555. t['Abreve'] = 667;
  51556. t['multiply'] = 570;
  51557. t['uacute'] = 556;
  51558. t['Tcaron'] = 611;
  51559. t['partialdiff'] = 494;
  51560. t['ydieresis'] = 444;
  51561. t['Nacute'] = 722;
  51562. t['icircumflex'] = 278;
  51563. t['Ecircumflex'] = 667;
  51564. t['adieresis'] = 500;
  51565. t['edieresis'] = 444;
  51566. t['cacute'] = 444;
  51567. t['nacute'] = 556;
  51568. t['umacron'] = 556;
  51569. t['Ncaron'] = 722;
  51570. t['Iacute'] = 389;
  51571. t['plusminus'] = 570;
  51572. t['brokenbar'] = 220;
  51573. t['registered'] = 747;
  51574. t['Gbreve'] = 722;
  51575. t['Idotaccent'] = 389;
  51576. t['summation'] = 600;
  51577. t['Egrave'] = 667;
  51578. t['racute'] = 389;
  51579. t['omacron'] = 500;
  51580. t['Zacute'] = 611;
  51581. t['Zcaron'] = 611;
  51582. t['greaterequal'] = 549;
  51583. t['Eth'] = 722;
  51584. t['Ccedilla'] = 667;
  51585. t['lcommaaccent'] = 278;
  51586. t['tcaron'] = 366;
  51587. t['eogonek'] = 444;
  51588. t['Uogonek'] = 722;
  51589. t['Aacute'] = 667;
  51590. t['Adieresis'] = 667;
  51591. t['egrave'] = 444;
  51592. t['zacute'] = 389;
  51593. t['iogonek'] = 278;
  51594. t['Oacute'] = 722;
  51595. t['oacute'] = 500;
  51596. t['amacron'] = 500;
  51597. t['sacute'] = 389;
  51598. t['idieresis'] = 278;
  51599. t['Ocircumflex'] = 722;
  51600. t['Ugrave'] = 722;
  51601. t['Delta'] = 612;
  51602. t['thorn'] = 500;
  51603. t['twosuperior'] = 300;
  51604. t['Odieresis'] = 722;
  51605. t['mu'] = 576;
  51606. t['igrave'] = 278;
  51607. t['ohungarumlaut'] = 500;
  51608. t['Eogonek'] = 667;
  51609. t['dcroat'] = 500;
  51610. t['threequarters'] = 750;
  51611. t['Scedilla'] = 556;
  51612. t['lcaron'] = 382;
  51613. t['Kcommaaccent'] = 667;
  51614. t['Lacute'] = 611;
  51615. t['trademark'] = 1000;
  51616. t['edotaccent'] = 444;
  51617. t['Igrave'] = 389;
  51618. t['Imacron'] = 389;
  51619. t['Lcaron'] = 611;
  51620. t['onehalf'] = 750;
  51621. t['lessequal'] = 549;
  51622. t['ocircumflex'] = 500;
  51623. t['ntilde'] = 556;
  51624. t['Uhungarumlaut'] = 722;
  51625. t['Eacute'] = 667;
  51626. t['emacron'] = 444;
  51627. t['gbreve'] = 500;
  51628. t['onequarter'] = 750;
  51629. t['Scaron'] = 556;
  51630. t['Scommaaccent'] = 556;
  51631. t['Ohungarumlaut'] = 722;
  51632. t['degree'] = 400;
  51633. t['ograve'] = 500;
  51634. t['Ccaron'] = 667;
  51635. t['ugrave'] = 556;
  51636. t['radical'] = 549;
  51637. t['Dcaron'] = 722;
  51638. t['rcommaaccent'] = 389;
  51639. t['Ntilde'] = 722;
  51640. t['otilde'] = 500;
  51641. t['Rcommaaccent'] = 667;
  51642. t['Lcommaaccent'] = 611;
  51643. t['Atilde'] = 667;
  51644. t['Aogonek'] = 667;
  51645. t['Aring'] = 667;
  51646. t['Otilde'] = 722;
  51647. t['zdotaccent'] = 389;
  51648. t['Ecaron'] = 667;
  51649. t['Iogonek'] = 389;
  51650. t['kcommaaccent'] = 500;
  51651. t['minus'] = 606;
  51652. t['Icircumflex'] = 389;
  51653. t['ncaron'] = 556;
  51654. t['tcommaaccent'] = 278;
  51655. t['logicalnot'] = 606;
  51656. t['odieresis'] = 500;
  51657. t['udieresis'] = 556;
  51658. t['notequal'] = 549;
  51659. t['gcommaaccent'] = 500;
  51660. t['eth'] = 500;
  51661. t['zcaron'] = 389;
  51662. t['ncommaaccent'] = 556;
  51663. t['onesuperior'] = 300;
  51664. t['imacron'] = 278;
  51665. t['Euro'] = 500;
  51666. });
  51667. t['Times-Italic'] = getLookupTableFactory(function (t) {
  51668. t['space'] = 250;
  51669. t['exclam'] = 333;
  51670. t['quotedbl'] = 420;
  51671. t['numbersign'] = 500;
  51672. t['dollar'] = 500;
  51673. t['percent'] = 833;
  51674. t['ampersand'] = 778;
  51675. t['quoteright'] = 333;
  51676. t['parenleft'] = 333;
  51677. t['parenright'] = 333;
  51678. t['asterisk'] = 500;
  51679. t['plus'] = 675;
  51680. t['comma'] = 250;
  51681. t['hyphen'] = 333;
  51682. t['period'] = 250;
  51683. t['slash'] = 278;
  51684. t['zero'] = 500;
  51685. t['one'] = 500;
  51686. t['two'] = 500;
  51687. t['three'] = 500;
  51688. t['four'] = 500;
  51689. t['five'] = 500;
  51690. t['six'] = 500;
  51691. t['seven'] = 500;
  51692. t['eight'] = 500;
  51693. t['nine'] = 500;
  51694. t['colon'] = 333;
  51695. t['semicolon'] = 333;
  51696. t['less'] = 675;
  51697. t['equal'] = 675;
  51698. t['greater'] = 675;
  51699. t['question'] = 500;
  51700. t['at'] = 920;
  51701. t['A'] = 611;
  51702. t['B'] = 611;
  51703. t['C'] = 667;
  51704. t['D'] = 722;
  51705. t['E'] = 611;
  51706. t['F'] = 611;
  51707. t['G'] = 722;
  51708. t['H'] = 722;
  51709. t['I'] = 333;
  51710. t['J'] = 444;
  51711. t['K'] = 667;
  51712. t['L'] = 556;
  51713. t['M'] = 833;
  51714. t['N'] = 667;
  51715. t['O'] = 722;
  51716. t['P'] = 611;
  51717. t['Q'] = 722;
  51718. t['R'] = 611;
  51719. t['S'] = 500;
  51720. t['T'] = 556;
  51721. t['U'] = 722;
  51722. t['V'] = 611;
  51723. t['W'] = 833;
  51724. t['X'] = 611;
  51725. t['Y'] = 556;
  51726. t['Z'] = 556;
  51727. t['bracketleft'] = 389;
  51728. t['backslash'] = 278;
  51729. t['bracketright'] = 389;
  51730. t['asciicircum'] = 422;
  51731. t['underscore'] = 500;
  51732. t['quoteleft'] = 333;
  51733. t['a'] = 500;
  51734. t['b'] = 500;
  51735. t['c'] = 444;
  51736. t['d'] = 500;
  51737. t['e'] = 444;
  51738. t['f'] = 278;
  51739. t['g'] = 500;
  51740. t['h'] = 500;
  51741. t['i'] = 278;
  51742. t['j'] = 278;
  51743. t['k'] = 444;
  51744. t['l'] = 278;
  51745. t['m'] = 722;
  51746. t['n'] = 500;
  51747. t['o'] = 500;
  51748. t['p'] = 500;
  51749. t['q'] = 500;
  51750. t['r'] = 389;
  51751. t['s'] = 389;
  51752. t['t'] = 278;
  51753. t['u'] = 500;
  51754. t['v'] = 444;
  51755. t['w'] = 667;
  51756. t['x'] = 444;
  51757. t['y'] = 444;
  51758. t['z'] = 389;
  51759. t['braceleft'] = 400;
  51760. t['bar'] = 275;
  51761. t['braceright'] = 400;
  51762. t['asciitilde'] = 541;
  51763. t['exclamdown'] = 389;
  51764. t['cent'] = 500;
  51765. t['sterling'] = 500;
  51766. t['fraction'] = 167;
  51767. t['yen'] = 500;
  51768. t['florin'] = 500;
  51769. t['section'] = 500;
  51770. t['currency'] = 500;
  51771. t['quotesingle'] = 214;
  51772. t['quotedblleft'] = 556;
  51773. t['guillemotleft'] = 500;
  51774. t['guilsinglleft'] = 333;
  51775. t['guilsinglright'] = 333;
  51776. t['fi'] = 500;
  51777. t['fl'] = 500;
  51778. t['endash'] = 500;
  51779. t['dagger'] = 500;
  51780. t['daggerdbl'] = 500;
  51781. t['periodcentered'] = 250;
  51782. t['paragraph'] = 523;
  51783. t['bullet'] = 350;
  51784. t['quotesinglbase'] = 333;
  51785. t['quotedblbase'] = 556;
  51786. t['quotedblright'] = 556;
  51787. t['guillemotright'] = 500;
  51788. t['ellipsis'] = 889;
  51789. t['perthousand'] = 1000;
  51790. t['questiondown'] = 500;
  51791. t['grave'] = 333;
  51792. t['acute'] = 333;
  51793. t['circumflex'] = 333;
  51794. t['tilde'] = 333;
  51795. t['macron'] = 333;
  51796. t['breve'] = 333;
  51797. t['dotaccent'] = 333;
  51798. t['dieresis'] = 333;
  51799. t['ring'] = 333;
  51800. t['cedilla'] = 333;
  51801. t['hungarumlaut'] = 333;
  51802. t['ogonek'] = 333;
  51803. t['caron'] = 333;
  51804. t['emdash'] = 889;
  51805. t['AE'] = 889;
  51806. t['ordfeminine'] = 276;
  51807. t['Lslash'] = 556;
  51808. t['Oslash'] = 722;
  51809. t['OE'] = 944;
  51810. t['ordmasculine'] = 310;
  51811. t['ae'] = 667;
  51812. t['dotlessi'] = 278;
  51813. t['lslash'] = 278;
  51814. t['oslash'] = 500;
  51815. t['oe'] = 667;
  51816. t['germandbls'] = 500;
  51817. t['Idieresis'] = 333;
  51818. t['eacute'] = 444;
  51819. t['abreve'] = 500;
  51820. t['uhungarumlaut'] = 500;
  51821. t['ecaron'] = 444;
  51822. t['Ydieresis'] = 556;
  51823. t['divide'] = 675;
  51824. t['Yacute'] = 556;
  51825. t['Acircumflex'] = 611;
  51826. t['aacute'] = 500;
  51827. t['Ucircumflex'] = 722;
  51828. t['yacute'] = 444;
  51829. t['scommaaccent'] = 389;
  51830. t['ecircumflex'] = 444;
  51831. t['Uring'] = 722;
  51832. t['Udieresis'] = 722;
  51833. t['aogonek'] = 500;
  51834. t['Uacute'] = 722;
  51835. t['uogonek'] = 500;
  51836. t['Edieresis'] = 611;
  51837. t['Dcroat'] = 722;
  51838. t['commaaccent'] = 250;
  51839. t['copyright'] = 760;
  51840. t['Emacron'] = 611;
  51841. t['ccaron'] = 444;
  51842. t['aring'] = 500;
  51843. t['Ncommaaccent'] = 667;
  51844. t['lacute'] = 278;
  51845. t['agrave'] = 500;
  51846. t['Tcommaaccent'] = 556;
  51847. t['Cacute'] = 667;
  51848. t['atilde'] = 500;
  51849. t['Edotaccent'] = 611;
  51850. t['scaron'] = 389;
  51851. t['scedilla'] = 389;
  51852. t['iacute'] = 278;
  51853. t['lozenge'] = 471;
  51854. t['Rcaron'] = 611;
  51855. t['Gcommaaccent'] = 722;
  51856. t['ucircumflex'] = 500;
  51857. t['acircumflex'] = 500;
  51858. t['Amacron'] = 611;
  51859. t['rcaron'] = 389;
  51860. t['ccedilla'] = 444;
  51861. t['Zdotaccent'] = 556;
  51862. t['Thorn'] = 611;
  51863. t['Omacron'] = 722;
  51864. t['Racute'] = 611;
  51865. t['Sacute'] = 500;
  51866. t['dcaron'] = 544;
  51867. t['Umacron'] = 722;
  51868. t['uring'] = 500;
  51869. t['threesuperior'] = 300;
  51870. t['Ograve'] = 722;
  51871. t['Agrave'] = 611;
  51872. t['Abreve'] = 611;
  51873. t['multiply'] = 675;
  51874. t['uacute'] = 500;
  51875. t['Tcaron'] = 556;
  51876. t['partialdiff'] = 476;
  51877. t['ydieresis'] = 444;
  51878. t['Nacute'] = 667;
  51879. t['icircumflex'] = 278;
  51880. t['Ecircumflex'] = 611;
  51881. t['adieresis'] = 500;
  51882. t['edieresis'] = 444;
  51883. t['cacute'] = 444;
  51884. t['nacute'] = 500;
  51885. t['umacron'] = 500;
  51886. t['Ncaron'] = 667;
  51887. t['Iacute'] = 333;
  51888. t['plusminus'] = 675;
  51889. t['brokenbar'] = 275;
  51890. t['registered'] = 760;
  51891. t['Gbreve'] = 722;
  51892. t['Idotaccent'] = 333;
  51893. t['summation'] = 600;
  51894. t['Egrave'] = 611;
  51895. t['racute'] = 389;
  51896. t['omacron'] = 500;
  51897. t['Zacute'] = 556;
  51898. t['Zcaron'] = 556;
  51899. t['greaterequal'] = 549;
  51900. t['Eth'] = 722;
  51901. t['Ccedilla'] = 667;
  51902. t['lcommaaccent'] = 278;
  51903. t['tcaron'] = 300;
  51904. t['eogonek'] = 444;
  51905. t['Uogonek'] = 722;
  51906. t['Aacute'] = 611;
  51907. t['Adieresis'] = 611;
  51908. t['egrave'] = 444;
  51909. t['zacute'] = 389;
  51910. t['iogonek'] = 278;
  51911. t['Oacute'] = 722;
  51912. t['oacute'] = 500;
  51913. t['amacron'] = 500;
  51914. t['sacute'] = 389;
  51915. t['idieresis'] = 278;
  51916. t['Ocircumflex'] = 722;
  51917. t['Ugrave'] = 722;
  51918. t['Delta'] = 612;
  51919. t['thorn'] = 500;
  51920. t['twosuperior'] = 300;
  51921. t['Odieresis'] = 722;
  51922. t['mu'] = 500;
  51923. t['igrave'] = 278;
  51924. t['ohungarumlaut'] = 500;
  51925. t['Eogonek'] = 611;
  51926. t['dcroat'] = 500;
  51927. t['threequarters'] = 750;
  51928. t['Scedilla'] = 500;
  51929. t['lcaron'] = 300;
  51930. t['Kcommaaccent'] = 667;
  51931. t['Lacute'] = 556;
  51932. t['trademark'] = 980;
  51933. t['edotaccent'] = 444;
  51934. t['Igrave'] = 333;
  51935. t['Imacron'] = 333;
  51936. t['Lcaron'] = 611;
  51937. t['onehalf'] = 750;
  51938. t['lessequal'] = 549;
  51939. t['ocircumflex'] = 500;
  51940. t['ntilde'] = 500;
  51941. t['Uhungarumlaut'] = 722;
  51942. t['Eacute'] = 611;
  51943. t['emacron'] = 444;
  51944. t['gbreve'] = 500;
  51945. t['onequarter'] = 750;
  51946. t['Scaron'] = 500;
  51947. t['Scommaaccent'] = 500;
  51948. t['Ohungarumlaut'] = 722;
  51949. t['degree'] = 400;
  51950. t['ograve'] = 500;
  51951. t['Ccaron'] = 667;
  51952. t['ugrave'] = 500;
  51953. t['radical'] = 453;
  51954. t['Dcaron'] = 722;
  51955. t['rcommaaccent'] = 389;
  51956. t['Ntilde'] = 667;
  51957. t['otilde'] = 500;
  51958. t['Rcommaaccent'] = 611;
  51959. t['Lcommaaccent'] = 556;
  51960. t['Atilde'] = 611;
  51961. t['Aogonek'] = 611;
  51962. t['Aring'] = 611;
  51963. t['Otilde'] = 722;
  51964. t['zdotaccent'] = 389;
  51965. t['Ecaron'] = 611;
  51966. t['Iogonek'] = 333;
  51967. t['kcommaaccent'] = 444;
  51968. t['minus'] = 675;
  51969. t['Icircumflex'] = 333;
  51970. t['ncaron'] = 500;
  51971. t['tcommaaccent'] = 278;
  51972. t['logicalnot'] = 675;
  51973. t['odieresis'] = 500;
  51974. t['udieresis'] = 500;
  51975. t['notequal'] = 549;
  51976. t['gcommaaccent'] = 500;
  51977. t['eth'] = 500;
  51978. t['zcaron'] = 389;
  51979. t['ncommaaccent'] = 500;
  51980. t['onesuperior'] = 300;
  51981. t['imacron'] = 278;
  51982. t['Euro'] = 500;
  51983. });
  51984. t['ZapfDingbats'] = getLookupTableFactory(function (t) {
  51985. t['space'] = 278;
  51986. t['a1'] = 974;
  51987. t['a2'] = 961;
  51988. t['a202'] = 974;
  51989. t['a3'] = 980;
  51990. t['a4'] = 719;
  51991. t['a5'] = 789;
  51992. t['a119'] = 790;
  51993. t['a118'] = 791;
  51994. t['a117'] = 690;
  51995. t['a11'] = 960;
  51996. t['a12'] = 939;
  51997. t['a13'] = 549;
  51998. t['a14'] = 855;
  51999. t['a15'] = 911;
  52000. t['a16'] = 933;
  52001. t['a105'] = 911;
  52002. t['a17'] = 945;
  52003. t['a18'] = 974;
  52004. t['a19'] = 755;
  52005. t['a20'] = 846;
  52006. t['a21'] = 762;
  52007. t['a22'] = 761;
  52008. t['a23'] = 571;
  52009. t['a24'] = 677;
  52010. t['a25'] = 763;
  52011. t['a26'] = 760;
  52012. t['a27'] = 759;
  52013. t['a28'] = 754;
  52014. t['a6'] = 494;
  52015. t['a7'] = 552;
  52016. t['a8'] = 537;
  52017. t['a9'] = 577;
  52018. t['a10'] = 692;
  52019. t['a29'] = 786;
  52020. t['a30'] = 788;
  52021. t['a31'] = 788;
  52022. t['a32'] = 790;
  52023. t['a33'] = 793;
  52024. t['a34'] = 794;
  52025. t['a35'] = 816;
  52026. t['a36'] = 823;
  52027. t['a37'] = 789;
  52028. t['a38'] = 841;
  52029. t['a39'] = 823;
  52030. t['a40'] = 833;
  52031. t['a41'] = 816;
  52032. t['a42'] = 831;
  52033. t['a43'] = 923;
  52034. t['a44'] = 744;
  52035. t['a45'] = 723;
  52036. t['a46'] = 749;
  52037. t['a47'] = 790;
  52038. t['a48'] = 792;
  52039. t['a49'] = 695;
  52040. t['a50'] = 776;
  52041. t['a51'] = 768;
  52042. t['a52'] = 792;
  52043. t['a53'] = 759;
  52044. t['a54'] = 707;
  52045. t['a55'] = 708;
  52046. t['a56'] = 682;
  52047. t['a57'] = 701;
  52048. t['a58'] = 826;
  52049. t['a59'] = 815;
  52050. t['a60'] = 789;
  52051. t['a61'] = 789;
  52052. t['a62'] = 707;
  52053. t['a63'] = 687;
  52054. t['a64'] = 696;
  52055. t['a65'] = 689;
  52056. t['a66'] = 786;
  52057. t['a67'] = 787;
  52058. t['a68'] = 713;
  52059. t['a69'] = 791;
  52060. t['a70'] = 785;
  52061. t['a71'] = 791;
  52062. t['a72'] = 873;
  52063. t['a73'] = 761;
  52064. t['a74'] = 762;
  52065. t['a203'] = 762;
  52066. t['a75'] = 759;
  52067. t['a204'] = 759;
  52068. t['a76'] = 892;
  52069. t['a77'] = 892;
  52070. t['a78'] = 788;
  52071. t['a79'] = 784;
  52072. t['a81'] = 438;
  52073. t['a82'] = 138;
  52074. t['a83'] = 277;
  52075. t['a84'] = 415;
  52076. t['a97'] = 392;
  52077. t['a98'] = 392;
  52078. t['a99'] = 668;
  52079. t['a100'] = 668;
  52080. t['a89'] = 390;
  52081. t['a90'] = 390;
  52082. t['a93'] = 317;
  52083. t['a94'] = 317;
  52084. t['a91'] = 276;
  52085. t['a92'] = 276;
  52086. t['a205'] = 509;
  52087. t['a85'] = 509;
  52088. t['a206'] = 410;
  52089. t['a86'] = 410;
  52090. t['a87'] = 234;
  52091. t['a88'] = 234;
  52092. t['a95'] = 334;
  52093. t['a96'] = 334;
  52094. t['a101'] = 732;
  52095. t['a102'] = 544;
  52096. t['a103'] = 544;
  52097. t['a104'] = 910;
  52098. t['a106'] = 667;
  52099. t['a107'] = 760;
  52100. t['a108'] = 760;
  52101. t['a112'] = 776;
  52102. t['a111'] = 595;
  52103. t['a110'] = 694;
  52104. t['a109'] = 626;
  52105. t['a120'] = 788;
  52106. t['a121'] = 788;
  52107. t['a122'] = 788;
  52108. t['a123'] = 788;
  52109. t['a124'] = 788;
  52110. t['a125'] = 788;
  52111. t['a126'] = 788;
  52112. t['a127'] = 788;
  52113. t['a128'] = 788;
  52114. t['a129'] = 788;
  52115. t['a130'] = 788;
  52116. t['a131'] = 788;
  52117. t['a132'] = 788;
  52118. t['a133'] = 788;
  52119. t['a134'] = 788;
  52120. t['a135'] = 788;
  52121. t['a136'] = 788;
  52122. t['a137'] = 788;
  52123. t['a138'] = 788;
  52124. t['a139'] = 788;
  52125. t['a140'] = 788;
  52126. t['a141'] = 788;
  52127. t['a142'] = 788;
  52128. t['a143'] = 788;
  52129. t['a144'] = 788;
  52130. t['a145'] = 788;
  52131. t['a146'] = 788;
  52132. t['a147'] = 788;
  52133. t['a148'] = 788;
  52134. t['a149'] = 788;
  52135. t['a150'] = 788;
  52136. t['a151'] = 788;
  52137. t['a152'] = 788;
  52138. t['a153'] = 788;
  52139. t['a154'] = 788;
  52140. t['a155'] = 788;
  52141. t['a156'] = 788;
  52142. t['a157'] = 788;
  52143. t['a158'] = 788;
  52144. t['a159'] = 788;
  52145. t['a160'] = 894;
  52146. t['a161'] = 838;
  52147. t['a163'] = 1016;
  52148. t['a164'] = 458;
  52149. t['a196'] = 748;
  52150. t['a165'] = 924;
  52151. t['a192'] = 748;
  52152. t['a166'] = 918;
  52153. t['a167'] = 927;
  52154. t['a168'] = 928;
  52155. t['a169'] = 928;
  52156. t['a170'] = 834;
  52157. t['a171'] = 873;
  52158. t['a172'] = 828;
  52159. t['a173'] = 924;
  52160. t['a162'] = 924;
  52161. t['a174'] = 917;
  52162. t['a175'] = 930;
  52163. t['a176'] = 931;
  52164. t['a177'] = 463;
  52165. t['a178'] = 883;
  52166. t['a179'] = 836;
  52167. t['a193'] = 836;
  52168. t['a180'] = 867;
  52169. t['a199'] = 867;
  52170. t['a181'] = 696;
  52171. t['a200'] = 696;
  52172. t['a182'] = 874;
  52173. t['a201'] = 874;
  52174. t['a183'] = 760;
  52175. t['a184'] = 946;
  52176. t['a197'] = 771;
  52177. t['a185'] = 865;
  52178. t['a194'] = 771;
  52179. t['a198'] = 888;
  52180. t['a186'] = 967;
  52181. t['a195'] = 888;
  52182. t['a187'] = 831;
  52183. t['a188'] = 873;
  52184. t['a189'] = 927;
  52185. t['a190'] = 970;
  52186. t['a191'] = 918;
  52187. });
  52188. });
  52189. exports.getMetrics = getMetrics;
  52190. /***/ }),
  52191. /* 38 */
  52192. /***/ (function(module, exports, __w_pdfjs_require__) {
  52193. "use strict";
  52194. var sharedUtil = __w_pdfjs_require__(0);
  52195. var Uint32ArrayView = sharedUtil.Uint32ArrayView;
  52196. var MurmurHash3_64 = function MurmurHash3_64Closure(seed) {
  52197. var MASK_HIGH = 0xffff0000;
  52198. var MASK_LOW = 0xffff;
  52199. function MurmurHash3_64(seed) {
  52200. var SEED = 0xc3d2e1f0;
  52201. this.h1 = seed ? seed & 0xffffffff : SEED;
  52202. this.h2 = seed ? seed & 0xffffffff : SEED;
  52203. }
  52204. var alwaysUseUint32ArrayView = false;
  52205. try {
  52206. new Uint32Array(new Uint8Array(5).buffer, 0, 1);
  52207. } catch (e) {
  52208. alwaysUseUint32ArrayView = true;
  52209. }
  52210. MurmurHash3_64.prototype = {
  52211. update: function MurmurHash3_64_update(input) {
  52212. var useUint32ArrayView = alwaysUseUint32ArrayView;
  52213. var i;
  52214. if (typeof input === 'string') {
  52215. var data = new Uint8Array(input.length * 2);
  52216. var length = 0;
  52217. for (i = 0; i < input.length; i++) {
  52218. var code = input.charCodeAt(i);
  52219. if (code <= 0xff) {
  52220. data[length++] = code;
  52221. } else {
  52222. data[length++] = code >>> 8;
  52223. data[length++] = code & 0xff;
  52224. }
  52225. }
  52226. } else if (input instanceof Uint8Array) {
  52227. data = input;
  52228. length = data.length;
  52229. } else if (typeof input === 'object' && 'length' in input) {
  52230. data = input;
  52231. length = data.length;
  52232. useUint32ArrayView = true;
  52233. } else {
  52234. throw new Error('Wrong data format in MurmurHash3_64_update. ' + 'Input must be a string or array.');
  52235. }
  52236. var blockCounts = length >> 2;
  52237. var tailLength = length - blockCounts * 4;
  52238. var dataUint32 = useUint32ArrayView ? new Uint32ArrayView(data, blockCounts) : new Uint32Array(data.buffer, 0, blockCounts);
  52239. var k1 = 0;
  52240. var k2 = 0;
  52241. var h1 = this.h1;
  52242. var h2 = this.h2;
  52243. var C1 = 0xcc9e2d51;
  52244. var C2 = 0x1b873593;
  52245. var C1_LOW = C1 & MASK_LOW;
  52246. var C2_LOW = C2 & MASK_LOW;
  52247. for (i = 0; i < blockCounts; i++) {
  52248. if (i & 1) {
  52249. k1 = dataUint32[i];
  52250. k1 = k1 * C1 & MASK_HIGH | k1 * C1_LOW & MASK_LOW;
  52251. k1 = k1 << 15 | k1 >>> 17;
  52252. k1 = k1 * C2 & MASK_HIGH | k1 * C2_LOW & MASK_LOW;
  52253. h1 ^= k1;
  52254. h1 = h1 << 13 | h1 >>> 19;
  52255. h1 = h1 * 5 + 0xe6546b64;
  52256. } else {
  52257. k2 = dataUint32[i];
  52258. k2 = k2 * C1 & MASK_HIGH | k2 * C1_LOW & MASK_LOW;
  52259. k2 = k2 << 15 | k2 >>> 17;
  52260. k2 = k2 * C2 & MASK_HIGH | k2 * C2_LOW & MASK_LOW;
  52261. h2 ^= k2;
  52262. h2 = h2 << 13 | h2 >>> 19;
  52263. h2 = h2 * 5 + 0xe6546b64;
  52264. }
  52265. }
  52266. k1 = 0;
  52267. switch (tailLength) {
  52268. case 3:
  52269. k1 ^= data[blockCounts * 4 + 2] << 16;
  52270. case 2:
  52271. k1 ^= data[blockCounts * 4 + 1] << 8;
  52272. case 1:
  52273. k1 ^= data[blockCounts * 4];
  52274. k1 = k1 * C1 & MASK_HIGH | k1 * C1_LOW & MASK_LOW;
  52275. k1 = k1 << 15 | k1 >>> 17;
  52276. k1 = k1 * C2 & MASK_HIGH | k1 * C2_LOW & MASK_LOW;
  52277. if (blockCounts & 1) {
  52278. h1 ^= k1;
  52279. } else {
  52280. h2 ^= k1;
  52281. }
  52282. }
  52283. this.h1 = h1;
  52284. this.h2 = h2;
  52285. return this;
  52286. },
  52287. hexdigest: function MurmurHash3_64_hexdigest() {
  52288. var h1 = this.h1;
  52289. var h2 = this.h2;
  52290. h1 ^= h2 >>> 1;
  52291. h1 = h1 * 0xed558ccd & MASK_HIGH | h1 * 0x8ccd & MASK_LOW;
  52292. h2 = h2 * 0xff51afd7 & MASK_HIGH | ((h2 << 16 | h1 >>> 16) * 0xafd7ed55 & MASK_HIGH) >>> 16;
  52293. h1 ^= h2 >>> 1;
  52294. h1 = h1 * 0x1a85ec53 & MASK_HIGH | h1 * 0xec53 & MASK_LOW;
  52295. h2 = h2 * 0xc4ceb9fe & MASK_HIGH | ((h2 << 16 | h1 >>> 16) * 0xb9fe1a85 & MASK_HIGH) >>> 16;
  52296. h1 ^= h2 >>> 1;
  52297. for (var i = 0, arr = [
  52298. h1,
  52299. h2
  52300. ], str = ''; i < arr.length; i++) {
  52301. var hex = (arr[i] >>> 0).toString(16);
  52302. while (hex.length < 8) {
  52303. hex = '0' + hex;
  52304. }
  52305. str += hex;
  52306. }
  52307. return str;
  52308. }
  52309. };
  52310. return MurmurHash3_64;
  52311. }();
  52312. exports.MurmurHash3_64 = MurmurHash3_64;
  52313. /***/ }),
  52314. /* 39 */
  52315. /***/ (function(module, exports, __w_pdfjs_require__) {
  52316. "use strict";
  52317. var sharedUtil = __w_pdfjs_require__(0);
  52318. var coreWorker = __w_pdfjs_require__(22);
  52319. var OK_RESPONSE = 200;
  52320. var PARTIAL_CONTENT_RESPONSE = 206;
  52321. function NetworkManager(url, args) {
  52322. this.url = url;
  52323. args = args || {};
  52324. this.isHttp = /^https?:/i.test(url);
  52325. this.httpHeaders = this.isHttp && args.httpHeaders || {};
  52326. this.withCredentials = args.withCredentials || false;
  52327. this.getXhr = args.getXhr || function NetworkManager_getXhr() {
  52328. return new XMLHttpRequest();
  52329. };
  52330. this.currXhrId = 0;
  52331. this.pendingRequests = Object.create(null);
  52332. this.loadedRequests = Object.create(null);
  52333. }
  52334. function getArrayBuffer(xhr) {
  52335. var data = xhr.response;
  52336. if (typeof data !== 'string') {
  52337. return data;
  52338. }
  52339. var length = data.length;
  52340. var array = new Uint8Array(length);
  52341. for (var i = 0; i < length; i++) {
  52342. array[i] = data.charCodeAt(i) & 0xFF;
  52343. }
  52344. return array.buffer;
  52345. }
  52346. var supportsMozChunked = function supportsMozChunkedClosure() {
  52347. try {
  52348. var x = new XMLHttpRequest();
  52349. x.open('GET', 'https://example.com');
  52350. x.responseType = 'moz-chunked-arraybuffer';
  52351. return x.responseType === 'moz-chunked-arraybuffer';
  52352. } catch (e) {
  52353. return false;
  52354. }
  52355. }();
  52356. NetworkManager.prototype = {
  52357. requestRange: function NetworkManager_requestRange(begin, end, listeners) {
  52358. var args = {
  52359. begin: begin,
  52360. end: end
  52361. };
  52362. for (var prop in listeners) {
  52363. args[prop] = listeners[prop];
  52364. }
  52365. return this.request(args);
  52366. },
  52367. requestFull: function NetworkManager_requestFull(listeners) {
  52368. return this.request(listeners);
  52369. },
  52370. request: function NetworkManager_request(args) {
  52371. var xhr = this.getXhr();
  52372. var xhrId = this.currXhrId++;
  52373. var pendingRequest = this.pendingRequests[xhrId] = { xhr: xhr };
  52374. xhr.open('GET', this.url);
  52375. xhr.withCredentials = this.withCredentials;
  52376. for (var property in this.httpHeaders) {
  52377. var value = this.httpHeaders[property];
  52378. if (typeof value === 'undefined') {
  52379. continue;
  52380. }
  52381. xhr.setRequestHeader(property, value);
  52382. }
  52383. if (this.isHttp && 'begin' in args && 'end' in args) {
  52384. var rangeStr = args.begin + '-' + (args.end - 1);
  52385. xhr.setRequestHeader('Range', 'bytes=' + rangeStr);
  52386. pendingRequest.expectedStatus = 206;
  52387. } else {
  52388. pendingRequest.expectedStatus = 200;
  52389. }
  52390. var useMozChunkedLoading = supportsMozChunked && !!args.onProgressiveData;
  52391. if (useMozChunkedLoading) {
  52392. xhr.responseType = 'moz-chunked-arraybuffer';
  52393. pendingRequest.onProgressiveData = args.onProgressiveData;
  52394. pendingRequest.mozChunked = true;
  52395. } else {
  52396. xhr.responseType = 'arraybuffer';
  52397. }
  52398. if (args.onError) {
  52399. xhr.onerror = function (evt) {
  52400. args.onError(xhr.status);
  52401. };
  52402. }
  52403. xhr.onreadystatechange = this.onStateChange.bind(this, xhrId);
  52404. xhr.onprogress = this.onProgress.bind(this, xhrId);
  52405. pendingRequest.onHeadersReceived = args.onHeadersReceived;
  52406. pendingRequest.onDone = args.onDone;
  52407. pendingRequest.onError = args.onError;
  52408. pendingRequest.onProgress = args.onProgress;
  52409. xhr.send(null);
  52410. return xhrId;
  52411. },
  52412. onProgress: function NetworkManager_onProgress(xhrId, evt) {
  52413. var pendingRequest = this.pendingRequests[xhrId];
  52414. if (!pendingRequest) {
  52415. return;
  52416. }
  52417. if (pendingRequest.mozChunked) {
  52418. var chunk = getArrayBuffer(pendingRequest.xhr);
  52419. pendingRequest.onProgressiveData(chunk);
  52420. }
  52421. var onProgress = pendingRequest.onProgress;
  52422. if (onProgress) {
  52423. onProgress(evt);
  52424. }
  52425. },
  52426. onStateChange: function NetworkManager_onStateChange(xhrId, evt) {
  52427. var pendingRequest = this.pendingRequests[xhrId];
  52428. if (!pendingRequest) {
  52429. return;
  52430. }
  52431. var xhr = pendingRequest.xhr;
  52432. if (xhr.readyState >= 2 && pendingRequest.onHeadersReceived) {
  52433. pendingRequest.onHeadersReceived();
  52434. delete pendingRequest.onHeadersReceived;
  52435. }
  52436. if (xhr.readyState !== 4) {
  52437. return;
  52438. }
  52439. if (!(xhrId in this.pendingRequests)) {
  52440. return;
  52441. }
  52442. delete this.pendingRequests[xhrId];
  52443. if (xhr.status === 0 && this.isHttp) {
  52444. if (pendingRequest.onError) {
  52445. pendingRequest.onError(xhr.status);
  52446. }
  52447. return;
  52448. }
  52449. var xhrStatus = xhr.status || OK_RESPONSE;
  52450. var ok_response_on_range_request = xhrStatus === OK_RESPONSE && pendingRequest.expectedStatus === PARTIAL_CONTENT_RESPONSE;
  52451. if (!ok_response_on_range_request && xhrStatus !== pendingRequest.expectedStatus) {
  52452. if (pendingRequest.onError) {
  52453. pendingRequest.onError(xhr.status);
  52454. }
  52455. return;
  52456. }
  52457. this.loadedRequests[xhrId] = true;
  52458. var chunk = getArrayBuffer(xhr);
  52459. if (xhrStatus === PARTIAL_CONTENT_RESPONSE) {
  52460. var rangeHeader = xhr.getResponseHeader('Content-Range');
  52461. var matches = /bytes (\d+)-(\d+)\/(\d+)/.exec(rangeHeader);
  52462. var begin = parseInt(matches[1], 10);
  52463. pendingRequest.onDone({
  52464. begin: begin,
  52465. chunk: chunk
  52466. });
  52467. } else if (pendingRequest.onProgressiveData) {
  52468. pendingRequest.onDone(null);
  52469. } else if (chunk) {
  52470. pendingRequest.onDone({
  52471. begin: 0,
  52472. chunk: chunk
  52473. });
  52474. } else if (pendingRequest.onError) {
  52475. pendingRequest.onError(xhr.status);
  52476. }
  52477. },
  52478. hasPendingRequests: function NetworkManager_hasPendingRequests() {
  52479. for (var xhrId in this.pendingRequests) {
  52480. return true;
  52481. }
  52482. return false;
  52483. },
  52484. getRequestXhr: function NetworkManager_getXhr(xhrId) {
  52485. return this.pendingRequests[xhrId].xhr;
  52486. },
  52487. isStreamingRequest: function NetworkManager_isStreamingRequest(xhrId) {
  52488. return !!this.pendingRequests[xhrId].onProgressiveData;
  52489. },
  52490. isPendingRequest: function NetworkManager_isPendingRequest(xhrId) {
  52491. return xhrId in this.pendingRequests;
  52492. },
  52493. isLoadedRequest: function NetworkManager_isLoadedRequest(xhrId) {
  52494. return xhrId in this.loadedRequests;
  52495. },
  52496. abortAllRequests: function NetworkManager_abortAllRequests() {
  52497. for (var xhrId in this.pendingRequests) {
  52498. this.abortRequest(xhrId | 0);
  52499. }
  52500. },
  52501. abortRequest: function NetworkManager_abortRequest(xhrId) {
  52502. var xhr = this.pendingRequests[xhrId].xhr;
  52503. delete this.pendingRequests[xhrId];
  52504. xhr.abort();
  52505. }
  52506. };
  52507. var assert = sharedUtil.assert;
  52508. var createPromiseCapability = sharedUtil.createPromiseCapability;
  52509. var isInt = sharedUtil.isInt;
  52510. var MissingPDFException = sharedUtil.MissingPDFException;
  52511. var UnexpectedResponseException = sharedUtil.UnexpectedResponseException;
  52512. function PDFNetworkStream(options) {
  52513. this._options = options;
  52514. var source = options.source;
  52515. this._manager = new NetworkManager(source.url, {
  52516. httpHeaders: source.httpHeaders,
  52517. withCredentials: source.withCredentials
  52518. });
  52519. this._rangeChunkSize = source.rangeChunkSize;
  52520. this._fullRequestReader = null;
  52521. this._rangeRequestReaders = [];
  52522. }
  52523. PDFNetworkStream.prototype = {
  52524. _onRangeRequestReaderClosed: function PDFNetworkStream_onRangeRequestReaderClosed(reader) {
  52525. var i = this._rangeRequestReaders.indexOf(reader);
  52526. if (i >= 0) {
  52527. this._rangeRequestReaders.splice(i, 1);
  52528. }
  52529. },
  52530. getFullReader: function PDFNetworkStream_getFullReader() {
  52531. assert(!this._fullRequestReader);
  52532. this._fullRequestReader = new PDFNetworkStreamFullRequestReader(this._manager, this._options);
  52533. return this._fullRequestReader;
  52534. },
  52535. getRangeReader: function PDFNetworkStream_getRangeReader(begin, end) {
  52536. var reader = new PDFNetworkStreamRangeRequestReader(this._manager, begin, end);
  52537. reader.onClosed = this._onRangeRequestReaderClosed.bind(this);
  52538. this._rangeRequestReaders.push(reader);
  52539. return reader;
  52540. },
  52541. cancelAllRequests: function PDFNetworkStream_cancelAllRequests(reason) {
  52542. if (this._fullRequestReader) {
  52543. this._fullRequestReader.cancel(reason);
  52544. }
  52545. var readers = this._rangeRequestReaders.slice(0);
  52546. readers.forEach(function (reader) {
  52547. reader.cancel(reason);
  52548. });
  52549. }
  52550. };
  52551. function PDFNetworkStreamFullRequestReader(manager, options) {
  52552. this._manager = manager;
  52553. var source = options.source;
  52554. var args = {
  52555. onHeadersReceived: this._onHeadersReceived.bind(this),
  52556. onProgressiveData: source.disableStream ? null : this._onProgressiveData.bind(this),
  52557. onDone: this._onDone.bind(this),
  52558. onError: this._onError.bind(this),
  52559. onProgress: this._onProgress.bind(this)
  52560. };
  52561. this._url = source.url;
  52562. this._fullRequestId = manager.requestFull(args);
  52563. this._headersReceivedCapability = createPromiseCapability();
  52564. this._disableRange = options.disableRange || false;
  52565. this._contentLength = source.length;
  52566. this._rangeChunkSize = source.rangeChunkSize;
  52567. if (!this._rangeChunkSize && !this._disableRange) {
  52568. this._disableRange = true;
  52569. }
  52570. this._isStreamingSupported = false;
  52571. this._isRangeSupported = false;
  52572. this._cachedChunks = [];
  52573. this._requests = [];
  52574. this._done = false;
  52575. this._storedError = undefined;
  52576. this.onProgress = null;
  52577. }
  52578. PDFNetworkStreamFullRequestReader.prototype = {
  52579. _validateRangeRequestCapabilities: function PDFNetworkStreamFullRequestReader_validateRangeRequestCapabilities() {
  52580. if (this._disableRange) {
  52581. return false;
  52582. }
  52583. var networkManager = this._manager;
  52584. if (!networkManager.isHttp) {
  52585. return false;
  52586. }
  52587. var fullRequestXhrId = this._fullRequestId;
  52588. var fullRequestXhr = networkManager.getRequestXhr(fullRequestXhrId);
  52589. if (fullRequestXhr.getResponseHeader('Accept-Ranges') !== 'bytes') {
  52590. return false;
  52591. }
  52592. var contentEncoding = fullRequestXhr.getResponseHeader('Content-Encoding') || 'identity';
  52593. if (contentEncoding !== 'identity') {
  52594. return false;
  52595. }
  52596. var length = fullRequestXhr.getResponseHeader('Content-Length');
  52597. length = parseInt(length, 10);
  52598. if (!isInt(length)) {
  52599. return false;
  52600. }
  52601. this._contentLength = length;
  52602. if (length <= 2 * this._rangeChunkSize) {
  52603. return false;
  52604. }
  52605. return true;
  52606. },
  52607. _onHeadersReceived: function PDFNetworkStreamFullRequestReader_onHeadersReceived() {
  52608. if (this._validateRangeRequestCapabilities()) {
  52609. this._isRangeSupported = true;
  52610. }
  52611. var networkManager = this._manager;
  52612. var fullRequestXhrId = this._fullRequestId;
  52613. if (networkManager.isStreamingRequest(fullRequestXhrId)) {
  52614. this._isStreamingSupported = true;
  52615. } else if (this._isRangeSupported) {
  52616. networkManager.abortRequest(fullRequestXhrId);
  52617. }
  52618. this._headersReceivedCapability.resolve();
  52619. },
  52620. _onProgressiveData: function PDFNetworkStreamFullRequestReader_onProgressiveData(chunk) {
  52621. if (this._requests.length > 0) {
  52622. var requestCapability = this._requests.shift();
  52623. requestCapability.resolve({
  52624. value: chunk,
  52625. done: false
  52626. });
  52627. } else {
  52628. this._cachedChunks.push(chunk);
  52629. }
  52630. },
  52631. _onDone: function PDFNetworkStreamFullRequestReader_onDone(args) {
  52632. if (args) {
  52633. this._onProgressiveData(args.chunk);
  52634. }
  52635. this._done = true;
  52636. if (this._cachedChunks.length > 0) {
  52637. return;
  52638. }
  52639. this._requests.forEach(function (requestCapability) {
  52640. requestCapability.resolve({
  52641. value: undefined,
  52642. done: true
  52643. });
  52644. });
  52645. this._requests = [];
  52646. },
  52647. _onError: function PDFNetworkStreamFullRequestReader_onError(status) {
  52648. var url = this._url;
  52649. var exception;
  52650. if (status === 404 || status === 0 && /^file:/.test(url)) {
  52651. exception = new MissingPDFException('Missing PDF "' + url + '".');
  52652. } else {
  52653. exception = new UnexpectedResponseException('Unexpected server response (' + status + ') while retrieving PDF "' + url + '".', status);
  52654. }
  52655. this._storedError = exception;
  52656. this._headersReceivedCapability.reject(exception);
  52657. this._requests.forEach(function (requestCapability) {
  52658. requestCapability.reject(exception);
  52659. });
  52660. this._requests = [];
  52661. this._cachedChunks = [];
  52662. },
  52663. _onProgress: function PDFNetworkStreamFullRequestReader_onProgress(data) {
  52664. if (this.onProgress) {
  52665. this.onProgress({
  52666. loaded: data.loaded,
  52667. total: data.lengthComputable ? data.total : this._contentLength
  52668. });
  52669. }
  52670. },
  52671. get isRangeSupported() {
  52672. return this._isRangeSupported;
  52673. },
  52674. get isStreamingSupported() {
  52675. return this._isStreamingSupported;
  52676. },
  52677. get contentLength() {
  52678. return this._contentLength;
  52679. },
  52680. get headersReady() {
  52681. return this._headersReceivedCapability.promise;
  52682. },
  52683. read: function PDFNetworkStreamFullRequestReader_read() {
  52684. if (this._storedError) {
  52685. return Promise.reject(this._storedError);
  52686. }
  52687. if (this._cachedChunks.length > 0) {
  52688. var chunk = this._cachedChunks.shift();
  52689. return Promise.resolve(chunk);
  52690. }
  52691. if (this._done) {
  52692. return Promise.resolve({
  52693. value: undefined,
  52694. done: true
  52695. });
  52696. }
  52697. var requestCapability = createPromiseCapability();
  52698. this._requests.push(requestCapability);
  52699. return requestCapability.promise;
  52700. },
  52701. cancel: function PDFNetworkStreamFullRequestReader_cancel(reason) {
  52702. this._done = true;
  52703. this._headersReceivedCapability.reject(reason);
  52704. this._requests.forEach(function (requestCapability) {
  52705. requestCapability.resolve({
  52706. value: undefined,
  52707. done: true
  52708. });
  52709. });
  52710. this._requests = [];
  52711. if (this._manager.isPendingRequest(this._fullRequestId)) {
  52712. this._manager.abortRequest(this._fullRequestId);
  52713. }
  52714. this._fullRequestReader = null;
  52715. }
  52716. };
  52717. function PDFNetworkStreamRangeRequestReader(manager, begin, end) {
  52718. this._manager = manager;
  52719. var args = {
  52720. onDone: this._onDone.bind(this),
  52721. onProgress: this._onProgress.bind(this)
  52722. };
  52723. this._requestId = manager.requestRange(begin, end, args);
  52724. this._requests = [];
  52725. this._queuedChunk = null;
  52726. this._done = false;
  52727. this.onProgress = null;
  52728. this.onClosed = null;
  52729. }
  52730. PDFNetworkStreamRangeRequestReader.prototype = {
  52731. _close: function PDFNetworkStreamRangeRequestReader_close() {
  52732. if (this.onClosed) {
  52733. this.onClosed(this);
  52734. }
  52735. },
  52736. _onDone: function PDFNetworkStreamRangeRequestReader_onDone(data) {
  52737. var chunk = data.chunk;
  52738. if (this._requests.length > 0) {
  52739. var requestCapability = this._requests.shift();
  52740. requestCapability.resolve({
  52741. value: chunk,
  52742. done: false
  52743. });
  52744. } else {
  52745. this._queuedChunk = chunk;
  52746. }
  52747. this._done = true;
  52748. this._requests.forEach(function (requestCapability) {
  52749. requestCapability.resolve({
  52750. value: undefined,
  52751. done: true
  52752. });
  52753. });
  52754. this._requests = [];
  52755. this._close();
  52756. },
  52757. _onProgress: function PDFNetworkStreamRangeRequestReader_onProgress(evt) {
  52758. if (!this.isStreamingSupported && this.onProgress) {
  52759. this.onProgress({ loaded: evt.loaded });
  52760. }
  52761. },
  52762. get isStreamingSupported() {
  52763. return false;
  52764. },
  52765. read: function PDFNetworkStreamRangeRequestReader_read() {
  52766. if (this._queuedChunk !== null) {
  52767. var chunk = this._queuedChunk;
  52768. this._queuedChunk = null;
  52769. return Promise.resolve({
  52770. value: chunk,
  52771. done: false
  52772. });
  52773. }
  52774. if (this._done) {
  52775. return Promise.resolve({
  52776. value: undefined,
  52777. done: true
  52778. });
  52779. }
  52780. var requestCapability = createPromiseCapability();
  52781. this._requests.push(requestCapability);
  52782. return requestCapability.promise;
  52783. },
  52784. cancel: function PDFNetworkStreamRangeRequestReader_cancel(reason) {
  52785. this._done = true;
  52786. this._requests.forEach(function (requestCapability) {
  52787. requestCapability.resolve({
  52788. value: undefined,
  52789. done: true
  52790. });
  52791. });
  52792. this._requests = [];
  52793. if (this._manager.isPendingRequest(this._requestId)) {
  52794. this._manager.abortRequest(this._requestId);
  52795. }
  52796. this._close();
  52797. }
  52798. };
  52799. coreWorker.setPDFNetworkStreamClass(PDFNetworkStream);
  52800. exports.PDFNetworkStream = PDFNetworkStream;
  52801. exports.NetworkManager = NetworkManager;
  52802. /***/ }),
  52803. /* 40 */
  52804. /***/ (function(module, exports, __w_pdfjs_require__) {
  52805. "use strict";
  52806. var sharedUtil = __w_pdfjs_require__(0);
  52807. var corePrimitives = __w_pdfjs_require__(1);
  52808. var coreFunction = __w_pdfjs_require__(7);
  52809. var coreColorSpace = __w_pdfjs_require__(4);
  52810. var UNSUPPORTED_FEATURES = sharedUtil.UNSUPPORTED_FEATURES;
  52811. var MissingDataException = sharedUtil.MissingDataException;
  52812. var Util = sharedUtil.Util;
  52813. var assert = sharedUtil.assert;
  52814. var error = sharedUtil.error;
  52815. var info = sharedUtil.info;
  52816. var warn = sharedUtil.warn;
  52817. var isStream = corePrimitives.isStream;
  52818. var PDFFunction = coreFunction.PDFFunction;
  52819. var ColorSpace = coreColorSpace.ColorSpace;
  52820. var ShadingType = {
  52821. FUNCTION_BASED: 1,
  52822. AXIAL: 2,
  52823. RADIAL: 3,
  52824. FREE_FORM_MESH: 4,
  52825. LATTICE_FORM_MESH: 5,
  52826. COONS_PATCH_MESH: 6,
  52827. TENSOR_PATCH_MESH: 7
  52828. };
  52829. var Pattern = function PatternClosure() {
  52830. function Pattern() {
  52831. error('should not call Pattern constructor');
  52832. }
  52833. Pattern.prototype = {
  52834. getPattern: function Pattern_getPattern(ctx) {
  52835. error('Should not call Pattern.getStyle: ' + ctx);
  52836. }
  52837. };
  52838. Pattern.parseShading = function Pattern_parseShading(shading, matrix, xref, res, handler) {
  52839. var dict = isStream(shading) ? shading.dict : shading;
  52840. var type = dict.get('ShadingType');
  52841. try {
  52842. switch (type) {
  52843. case ShadingType.AXIAL:
  52844. case ShadingType.RADIAL:
  52845. return new Shadings.RadialAxial(dict, matrix, xref, res);
  52846. case ShadingType.FREE_FORM_MESH:
  52847. case ShadingType.LATTICE_FORM_MESH:
  52848. case ShadingType.COONS_PATCH_MESH:
  52849. case ShadingType.TENSOR_PATCH_MESH:
  52850. return new Shadings.Mesh(shading, matrix, xref, res);
  52851. default:
  52852. throw new Error('Unsupported ShadingType: ' + type);
  52853. }
  52854. } catch (ex) {
  52855. if (ex instanceof MissingDataException) {
  52856. throw ex;
  52857. }
  52858. handler.send('UnsupportedFeature', { featureId: UNSUPPORTED_FEATURES.shadingPattern });
  52859. warn(ex);
  52860. return new Shadings.Dummy();
  52861. }
  52862. };
  52863. return Pattern;
  52864. }();
  52865. var Shadings = {};
  52866. Shadings.SMALL_NUMBER = 1e-6;
  52867. Shadings.RadialAxial = function RadialAxialClosure() {
  52868. function RadialAxial(dict, matrix, xref, res) {
  52869. this.matrix = matrix;
  52870. this.coordsArr = dict.getArray('Coords');
  52871. this.shadingType = dict.get('ShadingType');
  52872. this.type = 'Pattern';
  52873. var cs = dict.get('ColorSpace', 'CS');
  52874. cs = ColorSpace.parse(cs, xref, res);
  52875. this.cs = cs;
  52876. var t0 = 0.0, t1 = 1.0;
  52877. if (dict.has('Domain')) {
  52878. var domainArr = dict.getArray('Domain');
  52879. t0 = domainArr[0];
  52880. t1 = domainArr[1];
  52881. }
  52882. var extendStart = false, extendEnd = false;
  52883. if (dict.has('Extend')) {
  52884. var extendArr = dict.getArray('Extend');
  52885. extendStart = extendArr[0];
  52886. extendEnd = extendArr[1];
  52887. }
  52888. if (this.shadingType === ShadingType.RADIAL && (!extendStart || !extendEnd)) {
  52889. var x1 = this.coordsArr[0];
  52890. var y1 = this.coordsArr[1];
  52891. var r1 = this.coordsArr[2];
  52892. var x2 = this.coordsArr[3];
  52893. var y2 = this.coordsArr[4];
  52894. var r2 = this.coordsArr[5];
  52895. var distance = Math.sqrt((x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2));
  52896. if (r1 <= r2 + distance && r2 <= r1 + distance) {
  52897. warn('Unsupported radial gradient.');
  52898. }
  52899. }
  52900. this.extendStart = extendStart;
  52901. this.extendEnd = extendEnd;
  52902. var fnObj = dict.get('Function');
  52903. var fn = PDFFunction.parseArray(xref, fnObj);
  52904. var diff = t1 - t0;
  52905. var step = diff / 10;
  52906. var colorStops = this.colorStops = [];
  52907. if (t0 >= t1 || step <= 0) {
  52908. info('Bad shading domain.');
  52909. return;
  52910. }
  52911. var color = new Float32Array(cs.numComps), ratio = new Float32Array(1);
  52912. var rgbColor;
  52913. for (var i = t0; i <= t1; i += step) {
  52914. ratio[0] = i;
  52915. fn(ratio, 0, color, 0);
  52916. rgbColor = cs.getRgb(color, 0);
  52917. var cssColor = Util.makeCssRgb(rgbColor[0], rgbColor[1], rgbColor[2]);
  52918. colorStops.push([
  52919. (i - t0) / diff,
  52920. cssColor
  52921. ]);
  52922. }
  52923. var background = 'transparent';
  52924. if (dict.has('Background')) {
  52925. rgbColor = cs.getRgb(dict.get('Background'), 0);
  52926. background = Util.makeCssRgb(rgbColor[0], rgbColor[1], rgbColor[2]);
  52927. }
  52928. if (!extendStart) {
  52929. colorStops.unshift([
  52930. 0,
  52931. background
  52932. ]);
  52933. colorStops[1][0] += Shadings.SMALL_NUMBER;
  52934. }
  52935. if (!extendEnd) {
  52936. colorStops[colorStops.length - 1][0] -= Shadings.SMALL_NUMBER;
  52937. colorStops.push([
  52938. 1,
  52939. background
  52940. ]);
  52941. }
  52942. this.colorStops = colorStops;
  52943. }
  52944. RadialAxial.prototype = {
  52945. getIR: function RadialAxial_getIR() {
  52946. var coordsArr = this.coordsArr;
  52947. var shadingType = this.shadingType;
  52948. var type, p0, p1, r0, r1;
  52949. if (shadingType === ShadingType.AXIAL) {
  52950. p0 = [
  52951. coordsArr[0],
  52952. coordsArr[1]
  52953. ];
  52954. p1 = [
  52955. coordsArr[2],
  52956. coordsArr[3]
  52957. ];
  52958. r0 = null;
  52959. r1 = null;
  52960. type = 'axial';
  52961. } else if (shadingType === ShadingType.RADIAL) {
  52962. p0 = [
  52963. coordsArr[0],
  52964. coordsArr[1]
  52965. ];
  52966. p1 = [
  52967. coordsArr[3],
  52968. coordsArr[4]
  52969. ];
  52970. r0 = coordsArr[2];
  52971. r1 = coordsArr[5];
  52972. type = 'radial';
  52973. } else {
  52974. error('getPattern type unknown: ' + shadingType);
  52975. }
  52976. var matrix = this.matrix;
  52977. if (matrix) {
  52978. p0 = Util.applyTransform(p0, matrix);
  52979. p1 = Util.applyTransform(p1, matrix);
  52980. if (shadingType === ShadingType.RADIAL) {
  52981. var scale = Util.singularValueDecompose2dScale(matrix);
  52982. r0 *= scale[0];
  52983. r1 *= scale[1];
  52984. }
  52985. }
  52986. return [
  52987. 'RadialAxial',
  52988. type,
  52989. this.colorStops,
  52990. p0,
  52991. p1,
  52992. r0,
  52993. r1
  52994. ];
  52995. }
  52996. };
  52997. return RadialAxial;
  52998. }();
  52999. Shadings.Mesh = function MeshClosure() {
  53000. function MeshStreamReader(stream, context) {
  53001. this.stream = stream;
  53002. this.context = context;
  53003. this.buffer = 0;
  53004. this.bufferLength = 0;
  53005. var numComps = context.numComps;
  53006. this.tmpCompsBuf = new Float32Array(numComps);
  53007. var csNumComps = context.colorSpace.numComps;
  53008. this.tmpCsCompsBuf = context.colorFn ? new Float32Array(csNumComps) : this.tmpCompsBuf;
  53009. }
  53010. MeshStreamReader.prototype = {
  53011. get hasData() {
  53012. if (this.stream.end) {
  53013. return this.stream.pos < this.stream.end;
  53014. }
  53015. if (this.bufferLength > 0) {
  53016. return true;
  53017. }
  53018. var nextByte = this.stream.getByte();
  53019. if (nextByte < 0) {
  53020. return false;
  53021. }
  53022. this.buffer = nextByte;
  53023. this.bufferLength = 8;
  53024. return true;
  53025. },
  53026. readBits: function MeshStreamReader_readBits(n) {
  53027. var buffer = this.buffer;
  53028. var bufferLength = this.bufferLength;
  53029. if (n === 32) {
  53030. if (bufferLength === 0) {
  53031. return (this.stream.getByte() << 24 | this.stream.getByte() << 16 | this.stream.getByte() << 8 | this.stream.getByte()) >>> 0;
  53032. }
  53033. buffer = buffer << 24 | this.stream.getByte() << 16 | this.stream.getByte() << 8 | this.stream.getByte();
  53034. var nextByte = this.stream.getByte();
  53035. this.buffer = nextByte & (1 << bufferLength) - 1;
  53036. return (buffer << 8 - bufferLength | (nextByte & 0xFF) >> bufferLength) >>> 0;
  53037. }
  53038. if (n === 8 && bufferLength === 0) {
  53039. return this.stream.getByte();
  53040. }
  53041. while (bufferLength < n) {
  53042. buffer = buffer << 8 | this.stream.getByte();
  53043. bufferLength += 8;
  53044. }
  53045. bufferLength -= n;
  53046. this.bufferLength = bufferLength;
  53047. this.buffer = buffer & (1 << bufferLength) - 1;
  53048. return buffer >> bufferLength;
  53049. },
  53050. align: function MeshStreamReader_align() {
  53051. this.buffer = 0;
  53052. this.bufferLength = 0;
  53053. },
  53054. readFlag: function MeshStreamReader_readFlag() {
  53055. return this.readBits(this.context.bitsPerFlag);
  53056. },
  53057. readCoordinate: function MeshStreamReader_readCoordinate() {
  53058. var bitsPerCoordinate = this.context.bitsPerCoordinate;
  53059. var xi = this.readBits(bitsPerCoordinate);
  53060. var yi = this.readBits(bitsPerCoordinate);
  53061. var decode = this.context.decode;
  53062. var scale = bitsPerCoordinate < 32 ? 1 / ((1 << bitsPerCoordinate) - 1) : 2.3283064365386963e-10;
  53063. return [
  53064. xi * scale * (decode[1] - decode[0]) + decode[0],
  53065. yi * scale * (decode[3] - decode[2]) + decode[2]
  53066. ];
  53067. },
  53068. readComponents: function MeshStreamReader_readComponents() {
  53069. var numComps = this.context.numComps;
  53070. var bitsPerComponent = this.context.bitsPerComponent;
  53071. var scale = bitsPerComponent < 32 ? 1 / ((1 << bitsPerComponent) - 1) : 2.3283064365386963e-10;
  53072. var decode = this.context.decode;
  53073. var components = this.tmpCompsBuf;
  53074. for (var i = 0, j = 4; i < numComps; i++, j += 2) {
  53075. var ci = this.readBits(bitsPerComponent);
  53076. components[i] = ci * scale * (decode[j + 1] - decode[j]) + decode[j];
  53077. }
  53078. var color = this.tmpCsCompsBuf;
  53079. if (this.context.colorFn) {
  53080. this.context.colorFn(components, 0, color, 0);
  53081. }
  53082. return this.context.colorSpace.getRgb(color, 0);
  53083. }
  53084. };
  53085. function decodeType4Shading(mesh, reader) {
  53086. var coords = mesh.coords;
  53087. var colors = mesh.colors;
  53088. var operators = [];
  53089. var ps = [];
  53090. var verticesLeft = 0;
  53091. while (reader.hasData) {
  53092. var f = reader.readFlag();
  53093. var coord = reader.readCoordinate();
  53094. var color = reader.readComponents();
  53095. if (verticesLeft === 0) {
  53096. assert(0 <= f && f <= 2, 'Unknown type4 flag');
  53097. switch (f) {
  53098. case 0:
  53099. verticesLeft = 3;
  53100. break;
  53101. case 1:
  53102. ps.push(ps[ps.length - 2], ps[ps.length - 1]);
  53103. verticesLeft = 1;
  53104. break;
  53105. case 2:
  53106. ps.push(ps[ps.length - 3], ps[ps.length - 1]);
  53107. verticesLeft = 1;
  53108. break;
  53109. }
  53110. operators.push(f);
  53111. }
  53112. ps.push(coords.length);
  53113. coords.push(coord);
  53114. colors.push(color);
  53115. verticesLeft--;
  53116. reader.align();
  53117. }
  53118. mesh.figures.push({
  53119. type: 'triangles',
  53120. coords: new Int32Array(ps),
  53121. colors: new Int32Array(ps)
  53122. });
  53123. }
  53124. function decodeType5Shading(mesh, reader, verticesPerRow) {
  53125. var coords = mesh.coords;
  53126. var colors = mesh.colors;
  53127. var ps = [];
  53128. while (reader.hasData) {
  53129. var coord = reader.readCoordinate();
  53130. var color = reader.readComponents();
  53131. ps.push(coords.length);
  53132. coords.push(coord);
  53133. colors.push(color);
  53134. }
  53135. mesh.figures.push({
  53136. type: 'lattice',
  53137. coords: new Int32Array(ps),
  53138. colors: new Int32Array(ps),
  53139. verticesPerRow: verticesPerRow
  53140. });
  53141. }
  53142. var MIN_SPLIT_PATCH_CHUNKS_AMOUNT = 3;
  53143. var MAX_SPLIT_PATCH_CHUNKS_AMOUNT = 20;
  53144. var TRIANGLE_DENSITY = 20;
  53145. var getB = function getBClosure() {
  53146. function buildB(count) {
  53147. var lut = [];
  53148. for (var i = 0; i <= count; i++) {
  53149. var t = i / count, t_ = 1 - t;
  53150. lut.push(new Float32Array([
  53151. t_ * t_ * t_,
  53152. 3 * t * t_ * t_,
  53153. 3 * t * t * t_,
  53154. t * t * t
  53155. ]));
  53156. }
  53157. return lut;
  53158. }
  53159. var cache = [];
  53160. return function getB(count) {
  53161. if (!cache[count]) {
  53162. cache[count] = buildB(count);
  53163. }
  53164. return cache[count];
  53165. };
  53166. }();
  53167. function buildFigureFromPatch(mesh, index) {
  53168. var figure = mesh.figures[index];
  53169. assert(figure.type === 'patch', 'Unexpected patch mesh figure');
  53170. var coords = mesh.coords, colors = mesh.colors;
  53171. var pi = figure.coords;
  53172. var ci = figure.colors;
  53173. var figureMinX = Math.min(coords[pi[0]][0], coords[pi[3]][0], coords[pi[12]][0], coords[pi[15]][0]);
  53174. var figureMinY = Math.min(coords[pi[0]][1], coords[pi[3]][1], coords[pi[12]][1], coords[pi[15]][1]);
  53175. var figureMaxX = Math.max(coords[pi[0]][0], coords[pi[3]][0], coords[pi[12]][0], coords[pi[15]][0]);
  53176. var figureMaxY = Math.max(coords[pi[0]][1], coords[pi[3]][1], coords[pi[12]][1], coords[pi[15]][1]);
  53177. var splitXBy = Math.ceil((figureMaxX - figureMinX) * TRIANGLE_DENSITY / (mesh.bounds[2] - mesh.bounds[0]));
  53178. splitXBy = Math.max(MIN_SPLIT_PATCH_CHUNKS_AMOUNT, Math.min(MAX_SPLIT_PATCH_CHUNKS_AMOUNT, splitXBy));
  53179. var splitYBy = Math.ceil((figureMaxY - figureMinY) * TRIANGLE_DENSITY / (mesh.bounds[3] - mesh.bounds[1]));
  53180. splitYBy = Math.max(MIN_SPLIT_PATCH_CHUNKS_AMOUNT, Math.min(MAX_SPLIT_PATCH_CHUNKS_AMOUNT, splitYBy));
  53181. var verticesPerRow = splitXBy + 1;
  53182. var figureCoords = new Int32Array((splitYBy + 1) * verticesPerRow);
  53183. var figureColors = new Int32Array((splitYBy + 1) * verticesPerRow);
  53184. var k = 0;
  53185. var cl = new Uint8Array(3), cr = new Uint8Array(3);
  53186. var c0 = colors[ci[0]], c1 = colors[ci[1]], c2 = colors[ci[2]], c3 = colors[ci[3]];
  53187. var bRow = getB(splitYBy), bCol = getB(splitXBy);
  53188. for (var row = 0; row <= splitYBy; row++) {
  53189. cl[0] = (c0[0] * (splitYBy - row) + c2[0] * row) / splitYBy | 0;
  53190. cl[1] = (c0[1] * (splitYBy - row) + c2[1] * row) / splitYBy | 0;
  53191. cl[2] = (c0[2] * (splitYBy - row) + c2[2] * row) / splitYBy | 0;
  53192. cr[0] = (c1[0] * (splitYBy - row) + c3[0] * row) / splitYBy | 0;
  53193. cr[1] = (c1[1] * (splitYBy - row) + c3[1] * row) / splitYBy | 0;
  53194. cr[2] = (c1[2] * (splitYBy - row) + c3[2] * row) / splitYBy | 0;
  53195. for (var col = 0; col <= splitXBy; col++, k++) {
  53196. if ((row === 0 || row === splitYBy) && (col === 0 || col === splitXBy)) {
  53197. continue;
  53198. }
  53199. var x = 0, y = 0;
  53200. var q = 0;
  53201. for (var i = 0; i <= 3; i++) {
  53202. for (var j = 0; j <= 3; j++, q++) {
  53203. var m = bRow[row][i] * bCol[col][j];
  53204. x += coords[pi[q]][0] * m;
  53205. y += coords[pi[q]][1] * m;
  53206. }
  53207. }
  53208. figureCoords[k] = coords.length;
  53209. coords.push([
  53210. x,
  53211. y
  53212. ]);
  53213. figureColors[k] = colors.length;
  53214. var newColor = new Uint8Array(3);
  53215. newColor[0] = (cl[0] * (splitXBy - col) + cr[0] * col) / splitXBy | 0;
  53216. newColor[1] = (cl[1] * (splitXBy - col) + cr[1] * col) / splitXBy | 0;
  53217. newColor[2] = (cl[2] * (splitXBy - col) + cr[2] * col) / splitXBy | 0;
  53218. colors.push(newColor);
  53219. }
  53220. }
  53221. figureCoords[0] = pi[0];
  53222. figureColors[0] = ci[0];
  53223. figureCoords[splitXBy] = pi[3];
  53224. figureColors[splitXBy] = ci[1];
  53225. figureCoords[verticesPerRow * splitYBy] = pi[12];
  53226. figureColors[verticesPerRow * splitYBy] = ci[2];
  53227. figureCoords[verticesPerRow * splitYBy + splitXBy] = pi[15];
  53228. figureColors[verticesPerRow * splitYBy + splitXBy] = ci[3];
  53229. mesh.figures[index] = {
  53230. type: 'lattice',
  53231. coords: figureCoords,
  53232. colors: figureColors,
  53233. verticesPerRow: verticesPerRow
  53234. };
  53235. }
  53236. function decodeType6Shading(mesh, reader) {
  53237. var coords = mesh.coords;
  53238. var colors = mesh.colors;
  53239. var ps = new Int32Array(16);
  53240. var cs = new Int32Array(4);
  53241. while (reader.hasData) {
  53242. var f = reader.readFlag();
  53243. assert(0 <= f && f <= 3, 'Unknown type6 flag');
  53244. var i, ii;
  53245. var pi = coords.length;
  53246. for (i = 0, ii = f !== 0 ? 8 : 12; i < ii; i++) {
  53247. coords.push(reader.readCoordinate());
  53248. }
  53249. var ci = colors.length;
  53250. for (i = 0, ii = f !== 0 ? 2 : 4; i < ii; i++) {
  53251. colors.push(reader.readComponents());
  53252. }
  53253. var tmp1, tmp2, tmp3, tmp4;
  53254. switch (f) {
  53255. case 0:
  53256. ps[12] = pi + 3;
  53257. ps[13] = pi + 4;
  53258. ps[14] = pi + 5;
  53259. ps[15] = pi + 6;
  53260. ps[8] = pi + 2;
  53261. ps[11] = pi + 7;
  53262. ps[4] = pi + 1;
  53263. ps[7] = pi + 8;
  53264. ps[0] = pi;
  53265. ps[1] = pi + 11;
  53266. ps[2] = pi + 10;
  53267. ps[3] = pi + 9;
  53268. cs[2] = ci + 1;
  53269. cs[3] = ci + 2;
  53270. cs[0] = ci;
  53271. cs[1] = ci + 3;
  53272. break;
  53273. case 1:
  53274. tmp1 = ps[12];
  53275. tmp2 = ps[13];
  53276. tmp3 = ps[14];
  53277. tmp4 = ps[15];
  53278. ps[12] = tmp4;
  53279. ps[13] = pi + 0;
  53280. ps[14] = pi + 1;
  53281. ps[15] = pi + 2;
  53282. ps[8] = tmp3;
  53283. ps[11] = pi + 3;
  53284. ps[4] = tmp2;
  53285. ps[7] = pi + 4;
  53286. ps[0] = tmp1;
  53287. ps[1] = pi + 7;
  53288. ps[2] = pi + 6;
  53289. ps[3] = pi + 5;
  53290. tmp1 = cs[2];
  53291. tmp2 = cs[3];
  53292. cs[2] = tmp2;
  53293. cs[3] = ci;
  53294. cs[0] = tmp1;
  53295. cs[1] = ci + 1;
  53296. break;
  53297. case 2:
  53298. tmp1 = ps[15];
  53299. tmp2 = ps[11];
  53300. ps[12] = ps[3];
  53301. ps[13] = pi + 0;
  53302. ps[14] = pi + 1;
  53303. ps[15] = pi + 2;
  53304. ps[8] = ps[7];
  53305. ps[11] = pi + 3;
  53306. ps[4] = tmp2;
  53307. ps[7] = pi + 4;
  53308. ps[0] = tmp1;
  53309. ps[1] = pi + 7;
  53310. ps[2] = pi + 6;
  53311. ps[3] = pi + 5;
  53312. tmp1 = cs[3];
  53313. cs[2] = cs[1];
  53314. cs[3] = ci;
  53315. cs[0] = tmp1;
  53316. cs[1] = ci + 1;
  53317. break;
  53318. case 3:
  53319. ps[12] = ps[0];
  53320. ps[13] = pi + 0;
  53321. ps[14] = pi + 1;
  53322. ps[15] = pi + 2;
  53323. ps[8] = ps[1];
  53324. ps[11] = pi + 3;
  53325. ps[4] = ps[2];
  53326. ps[7] = pi + 4;
  53327. ps[0] = ps[3];
  53328. ps[1] = pi + 7;
  53329. ps[2] = pi + 6;
  53330. ps[3] = pi + 5;
  53331. cs[2] = cs[0];
  53332. cs[3] = ci;
  53333. cs[0] = cs[1];
  53334. cs[1] = ci + 1;
  53335. break;
  53336. }
  53337. ps[5] = coords.length;
  53338. coords.push([
  53339. (-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,
  53340. (-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
  53341. ]);
  53342. ps[6] = coords.length;
  53343. coords.push([
  53344. (-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,
  53345. (-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
  53346. ]);
  53347. ps[9] = coords.length;
  53348. coords.push([
  53349. (-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,
  53350. (-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
  53351. ]);
  53352. ps[10] = coords.length;
  53353. coords.push([
  53354. (-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,
  53355. (-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
  53356. ]);
  53357. mesh.figures.push({
  53358. type: 'patch',
  53359. coords: new Int32Array(ps),
  53360. colors: new Int32Array(cs)
  53361. });
  53362. }
  53363. }
  53364. function decodeType7Shading(mesh, reader) {
  53365. var coords = mesh.coords;
  53366. var colors = mesh.colors;
  53367. var ps = new Int32Array(16);
  53368. var cs = new Int32Array(4);
  53369. while (reader.hasData) {
  53370. var f = reader.readFlag();
  53371. assert(0 <= f && f <= 3, 'Unknown type7 flag');
  53372. var i, ii;
  53373. var pi = coords.length;
  53374. for (i = 0, ii = f !== 0 ? 12 : 16; i < ii; i++) {
  53375. coords.push(reader.readCoordinate());
  53376. }
  53377. var ci = colors.length;
  53378. for (i = 0, ii = f !== 0 ? 2 : 4; i < ii; i++) {
  53379. colors.push(reader.readComponents());
  53380. }
  53381. var tmp1, tmp2, tmp3, tmp4;
  53382. switch (f) {
  53383. case 0:
  53384. ps[12] = pi + 3;
  53385. ps[13] = pi + 4;
  53386. ps[14] = pi + 5;
  53387. ps[15] = pi + 6;
  53388. ps[8] = pi + 2;
  53389. ps[9] = pi + 13;
  53390. ps[10] = pi + 14;
  53391. ps[11] = pi + 7;
  53392. ps[4] = pi + 1;
  53393. ps[5] = pi + 12;
  53394. ps[6] = pi + 15;
  53395. ps[7] = pi + 8;
  53396. ps[0] = pi;
  53397. ps[1] = pi + 11;
  53398. ps[2] = pi + 10;
  53399. ps[3] = pi + 9;
  53400. cs[2] = ci + 1;
  53401. cs[3] = ci + 2;
  53402. cs[0] = ci;
  53403. cs[1] = ci + 3;
  53404. break;
  53405. case 1:
  53406. tmp1 = ps[12];
  53407. tmp2 = ps[13];
  53408. tmp3 = ps[14];
  53409. tmp4 = ps[15];
  53410. ps[12] = tmp4;
  53411. ps[13] = pi + 0;
  53412. ps[14] = pi + 1;
  53413. ps[15] = pi + 2;
  53414. ps[8] = tmp3;
  53415. ps[9] = pi + 9;
  53416. ps[10] = pi + 10;
  53417. ps[11] = pi + 3;
  53418. ps[4] = tmp2;
  53419. ps[5] = pi + 8;
  53420. ps[6] = pi + 11;
  53421. ps[7] = pi + 4;
  53422. ps[0] = tmp1;
  53423. ps[1] = pi + 7;
  53424. ps[2] = pi + 6;
  53425. ps[3] = pi + 5;
  53426. tmp1 = cs[2];
  53427. tmp2 = cs[3];
  53428. cs[2] = tmp2;
  53429. cs[3] = ci;
  53430. cs[0] = tmp1;
  53431. cs[1] = ci + 1;
  53432. break;
  53433. case 2:
  53434. tmp1 = ps[15];
  53435. tmp2 = ps[11];
  53436. ps[12] = ps[3];
  53437. ps[13] = pi + 0;
  53438. ps[14] = pi + 1;
  53439. ps[15] = pi + 2;
  53440. ps[8] = ps[7];
  53441. ps[9] = pi + 9;
  53442. ps[10] = pi + 10;
  53443. ps[11] = pi + 3;
  53444. ps[4] = tmp2;
  53445. ps[5] = pi + 8;
  53446. ps[6] = pi + 11;
  53447. ps[7] = pi + 4;
  53448. ps[0] = tmp1;
  53449. ps[1] = pi + 7;
  53450. ps[2] = pi + 6;
  53451. ps[3] = pi + 5;
  53452. tmp1 = cs[3];
  53453. cs[2] = cs[1];
  53454. cs[3] = ci;
  53455. cs[0] = tmp1;
  53456. cs[1] = ci + 1;
  53457. break;
  53458. case 3:
  53459. ps[12] = ps[0];
  53460. ps[13] = pi + 0;
  53461. ps[14] = pi + 1;
  53462. ps[15] = pi + 2;
  53463. ps[8] = ps[1];
  53464. ps[9] = pi + 9;
  53465. ps[10] = pi + 10;
  53466. ps[11] = pi + 3;
  53467. ps[4] = ps[2];
  53468. ps[5] = pi + 8;
  53469. ps[6] = pi + 11;
  53470. ps[7] = pi + 4;
  53471. ps[0] = ps[3];
  53472. ps[1] = pi + 7;
  53473. ps[2] = pi + 6;
  53474. ps[3] = pi + 5;
  53475. cs[2] = cs[0];
  53476. cs[3] = ci;
  53477. cs[0] = cs[1];
  53478. cs[1] = ci + 1;
  53479. break;
  53480. }
  53481. mesh.figures.push({
  53482. type: 'patch',
  53483. coords: new Int32Array(ps),
  53484. colors: new Int32Array(cs)
  53485. });
  53486. }
  53487. }
  53488. function updateBounds(mesh) {
  53489. var minX = mesh.coords[0][0], minY = mesh.coords[0][1], maxX = minX, maxY = minY;
  53490. for (var i = 1, ii = mesh.coords.length; i < ii; i++) {
  53491. var x = mesh.coords[i][0], y = mesh.coords[i][1];
  53492. minX = minX > x ? x : minX;
  53493. minY = minY > y ? y : minY;
  53494. maxX = maxX < x ? x : maxX;
  53495. maxY = maxY < y ? y : maxY;
  53496. }
  53497. mesh.bounds = [
  53498. minX,
  53499. minY,
  53500. maxX,
  53501. maxY
  53502. ];
  53503. }
  53504. function packData(mesh) {
  53505. var i, ii, j, jj;
  53506. var coords = mesh.coords;
  53507. var coordsPacked = new Float32Array(coords.length * 2);
  53508. for (i = 0, j = 0, ii = coords.length; i < ii; i++) {
  53509. var xy = coords[i];
  53510. coordsPacked[j++] = xy[0];
  53511. coordsPacked[j++] = xy[1];
  53512. }
  53513. mesh.coords = coordsPacked;
  53514. var colors = mesh.colors;
  53515. var colorsPacked = new Uint8Array(colors.length * 3);
  53516. for (i = 0, j = 0, ii = colors.length; i < ii; i++) {
  53517. var c = colors[i];
  53518. colorsPacked[j++] = c[0];
  53519. colorsPacked[j++] = c[1];
  53520. colorsPacked[j++] = c[2];
  53521. }
  53522. mesh.colors = colorsPacked;
  53523. var figures = mesh.figures;
  53524. for (i = 0, ii = figures.length; i < ii; i++) {
  53525. var figure = figures[i], ps = figure.coords, cs = figure.colors;
  53526. for (j = 0, jj = ps.length; j < jj; j++) {
  53527. ps[j] *= 2;
  53528. cs[j] *= 3;
  53529. }
  53530. }
  53531. }
  53532. function Mesh(stream, matrix, xref, res) {
  53533. assert(isStream(stream), 'Mesh data is not a stream');
  53534. var dict = stream.dict;
  53535. this.matrix = matrix;
  53536. this.shadingType = dict.get('ShadingType');
  53537. this.type = 'Pattern';
  53538. this.bbox = dict.getArray('BBox');
  53539. var cs = dict.get('ColorSpace', 'CS');
  53540. cs = ColorSpace.parse(cs, xref, res);
  53541. this.cs = cs;
  53542. this.background = dict.has('Background') ? cs.getRgb(dict.get('Background'), 0) : null;
  53543. var fnObj = dict.get('Function');
  53544. var fn = fnObj ? PDFFunction.parseArray(xref, fnObj) : null;
  53545. this.coords = [];
  53546. this.colors = [];
  53547. this.figures = [];
  53548. var decodeContext = {
  53549. bitsPerCoordinate: dict.get('BitsPerCoordinate'),
  53550. bitsPerComponent: dict.get('BitsPerComponent'),
  53551. bitsPerFlag: dict.get('BitsPerFlag'),
  53552. decode: dict.getArray('Decode'),
  53553. colorFn: fn,
  53554. colorSpace: cs,
  53555. numComps: fn ? 1 : cs.numComps
  53556. };
  53557. var reader = new MeshStreamReader(stream, decodeContext);
  53558. var patchMesh = false;
  53559. switch (this.shadingType) {
  53560. case ShadingType.FREE_FORM_MESH:
  53561. decodeType4Shading(this, reader);
  53562. break;
  53563. case ShadingType.LATTICE_FORM_MESH:
  53564. var verticesPerRow = dict.get('VerticesPerRow') | 0;
  53565. assert(verticesPerRow >= 2, 'Invalid VerticesPerRow');
  53566. decodeType5Shading(this, reader, verticesPerRow);
  53567. break;
  53568. case ShadingType.COONS_PATCH_MESH:
  53569. decodeType6Shading(this, reader);
  53570. patchMesh = true;
  53571. break;
  53572. case ShadingType.TENSOR_PATCH_MESH:
  53573. decodeType7Shading(this, reader);
  53574. patchMesh = true;
  53575. break;
  53576. default:
  53577. error('Unsupported mesh type.');
  53578. break;
  53579. }
  53580. if (patchMesh) {
  53581. updateBounds(this);
  53582. for (var i = 0, ii = this.figures.length; i < ii; i++) {
  53583. buildFigureFromPatch(this, i);
  53584. }
  53585. }
  53586. updateBounds(this);
  53587. packData(this);
  53588. }
  53589. Mesh.prototype = {
  53590. getIR: function Mesh_getIR() {
  53591. return [
  53592. 'Mesh',
  53593. this.shadingType,
  53594. this.coords,
  53595. this.colors,
  53596. this.figures,
  53597. this.bounds,
  53598. this.matrix,
  53599. this.bbox,
  53600. this.background
  53601. ];
  53602. }
  53603. };
  53604. return Mesh;
  53605. }();
  53606. Shadings.Dummy = function DummyClosure() {
  53607. function Dummy() {
  53608. this.type = 'Pattern';
  53609. }
  53610. Dummy.prototype = {
  53611. getIR: function Dummy_getIR() {
  53612. return ['Dummy'];
  53613. }
  53614. };
  53615. return Dummy;
  53616. }();
  53617. function getTilingPatternIR(operatorList, dict, args) {
  53618. var matrix = dict.getArray('Matrix');
  53619. var bbox = dict.getArray('BBox');
  53620. var xstep = dict.get('XStep');
  53621. var ystep = dict.get('YStep');
  53622. var paintType = dict.get('PaintType');
  53623. var tilingType = dict.get('TilingType');
  53624. return [
  53625. 'TilingPattern',
  53626. args,
  53627. operatorList,
  53628. matrix,
  53629. bbox,
  53630. xstep,
  53631. ystep,
  53632. paintType,
  53633. tilingType
  53634. ];
  53635. }
  53636. exports.Pattern = Pattern;
  53637. exports.getTilingPatternIR = getTilingPatternIR;
  53638. /***/ }),
  53639. /* 41 */
  53640. /***/ (function(module, exports, __w_pdfjs_require__) {
  53641. "use strict";
  53642. var sharedUtil = __w_pdfjs_require__(0);
  53643. var coreStream = __w_pdfjs_require__(2);
  53644. var coreChunkedStream = __w_pdfjs_require__(15);
  53645. var coreDocument = __w_pdfjs_require__(31);
  53646. var warn = sharedUtil.warn;
  53647. var createValidAbsoluteUrl = sharedUtil.createValidAbsoluteUrl;
  53648. var shadow = sharedUtil.shadow;
  53649. var NotImplementedException = sharedUtil.NotImplementedException;
  53650. var MissingDataException = sharedUtil.MissingDataException;
  53651. var createPromiseCapability = sharedUtil.createPromiseCapability;
  53652. var Util = sharedUtil.Util;
  53653. var Stream = coreStream.Stream;
  53654. var ChunkedStreamManager = coreChunkedStream.ChunkedStreamManager;
  53655. var PDFDocument = coreDocument.PDFDocument;
  53656. var BasePdfManager = function BasePdfManagerClosure() {
  53657. function BasePdfManager() {
  53658. throw new Error('Cannot initialize BaseManagerManager');
  53659. }
  53660. BasePdfManager.prototype = {
  53661. get docId() {
  53662. return this._docId;
  53663. },
  53664. get password() {
  53665. return this._password;
  53666. },
  53667. get docBaseUrl() {
  53668. var docBaseUrl = null;
  53669. if (this._docBaseUrl) {
  53670. var absoluteUrl = createValidAbsoluteUrl(this._docBaseUrl);
  53671. if (absoluteUrl) {
  53672. docBaseUrl = absoluteUrl.href;
  53673. } else {
  53674. warn('Invalid absolute docBaseUrl: "' + this._docBaseUrl + '".');
  53675. }
  53676. }
  53677. return shadow(this, 'docBaseUrl', docBaseUrl);
  53678. },
  53679. onLoadedStream: function BasePdfManager_onLoadedStream() {
  53680. throw new NotImplementedException();
  53681. },
  53682. ensureDoc: function BasePdfManager_ensureDoc(prop, args) {
  53683. return this.ensure(this.pdfDocument, prop, args);
  53684. },
  53685. ensureXRef: function BasePdfManager_ensureXRef(prop, args) {
  53686. return this.ensure(this.pdfDocument.xref, prop, args);
  53687. },
  53688. ensureCatalog: function BasePdfManager_ensureCatalog(prop, args) {
  53689. return this.ensure(this.pdfDocument.catalog, prop, args);
  53690. },
  53691. getPage: function BasePdfManager_getPage(pageIndex) {
  53692. return this.pdfDocument.getPage(pageIndex);
  53693. },
  53694. cleanup: function BasePdfManager_cleanup() {
  53695. return this.pdfDocument.cleanup();
  53696. },
  53697. ensure: function BasePdfManager_ensure(obj, prop, args) {
  53698. return new NotImplementedException();
  53699. },
  53700. requestRange: function BasePdfManager_requestRange(begin, end) {
  53701. return new NotImplementedException();
  53702. },
  53703. requestLoadedStream: function BasePdfManager_requestLoadedStream() {
  53704. return new NotImplementedException();
  53705. },
  53706. sendProgressiveData: function BasePdfManager_sendProgressiveData(chunk) {
  53707. return new NotImplementedException();
  53708. },
  53709. updatePassword: function BasePdfManager_updatePassword(password) {
  53710. this._password = password;
  53711. },
  53712. terminate: function BasePdfManager_terminate() {
  53713. return new NotImplementedException();
  53714. }
  53715. };
  53716. return BasePdfManager;
  53717. }();
  53718. var LocalPdfManager = function LocalPdfManagerClosure() {
  53719. function LocalPdfManager(docId, data, password, evaluatorOptions, docBaseUrl) {
  53720. this._docId = docId;
  53721. this._password = password;
  53722. this._docBaseUrl = docBaseUrl;
  53723. this.evaluatorOptions = evaluatorOptions;
  53724. var stream = new Stream(data);
  53725. this.pdfDocument = new PDFDocument(this, stream);
  53726. this._loadedStreamCapability = createPromiseCapability();
  53727. this._loadedStreamCapability.resolve(stream);
  53728. }
  53729. Util.inherit(LocalPdfManager, BasePdfManager, {
  53730. ensure: function LocalPdfManager_ensure(obj, prop, args) {
  53731. return new Promise(function (resolve, reject) {
  53732. try {
  53733. var value = obj[prop];
  53734. var result;
  53735. if (typeof value === 'function') {
  53736. result = value.apply(obj, args);
  53737. } else {
  53738. result = value;
  53739. }
  53740. resolve(result);
  53741. } catch (e) {
  53742. reject(e);
  53743. }
  53744. });
  53745. },
  53746. requestRange: function LocalPdfManager_requestRange(begin, end) {
  53747. return Promise.resolve();
  53748. },
  53749. requestLoadedStream: function LocalPdfManager_requestLoadedStream() {
  53750. },
  53751. onLoadedStream: function LocalPdfManager_onLoadedStream() {
  53752. return this._loadedStreamCapability.promise;
  53753. },
  53754. terminate: function LocalPdfManager_terminate() {
  53755. }
  53756. });
  53757. return LocalPdfManager;
  53758. }();
  53759. var NetworkPdfManager = function NetworkPdfManagerClosure() {
  53760. function NetworkPdfManager(docId, pdfNetworkStream, args, evaluatorOptions, docBaseUrl) {
  53761. this._docId = docId;
  53762. this._password = args.password;
  53763. this._docBaseUrl = docBaseUrl;
  53764. this.msgHandler = args.msgHandler;
  53765. this.evaluatorOptions = evaluatorOptions;
  53766. var params = {
  53767. msgHandler: args.msgHandler,
  53768. url: args.url,
  53769. length: args.length,
  53770. disableAutoFetch: args.disableAutoFetch,
  53771. rangeChunkSize: args.rangeChunkSize
  53772. };
  53773. this.streamManager = new ChunkedStreamManager(pdfNetworkStream, params);
  53774. this.pdfDocument = new PDFDocument(this, this.streamManager.getStream());
  53775. }
  53776. Util.inherit(NetworkPdfManager, BasePdfManager, {
  53777. ensure: function NetworkPdfManager_ensure(obj, prop, args) {
  53778. var pdfManager = this;
  53779. return new Promise(function (resolve, reject) {
  53780. function ensureHelper() {
  53781. try {
  53782. var result;
  53783. var value = obj[prop];
  53784. if (typeof value === 'function') {
  53785. result = value.apply(obj, args);
  53786. } else {
  53787. result = value;
  53788. }
  53789. resolve(result);
  53790. } catch (e) {
  53791. if (!(e instanceof MissingDataException)) {
  53792. reject(e);
  53793. return;
  53794. }
  53795. pdfManager.streamManager.requestRange(e.begin, e.end).then(ensureHelper, reject);
  53796. }
  53797. }
  53798. ensureHelper();
  53799. });
  53800. },
  53801. requestRange: function NetworkPdfManager_requestRange(begin, end) {
  53802. return this.streamManager.requestRange(begin, end);
  53803. },
  53804. requestLoadedStream: function NetworkPdfManager_requestLoadedStream() {
  53805. this.streamManager.requestAllChunks();
  53806. },
  53807. sendProgressiveData: function NetworkPdfManager_sendProgressiveData(chunk) {
  53808. this.streamManager.onReceiveData({ chunk: chunk });
  53809. },
  53810. onLoadedStream: function NetworkPdfManager_onLoadedStream() {
  53811. return this.streamManager.onLoadedStream();
  53812. },
  53813. terminate: function NetworkPdfManager_terminate() {
  53814. this.streamManager.abort();
  53815. }
  53816. });
  53817. return NetworkPdfManager;
  53818. }();
  53819. exports.LocalPdfManager = LocalPdfManager;
  53820. exports.NetworkPdfManager = NetworkPdfManager;
  53821. /***/ }),
  53822. /* 42 */
  53823. /***/ (function(module, exports, __w_pdfjs_require__) {
  53824. "use strict";
  53825. var sharedUtil = __w_pdfjs_require__(0);
  53826. var corePrimitives = __w_pdfjs_require__(1);
  53827. var error = sharedUtil.error;
  53828. var isSpace = sharedUtil.isSpace;
  53829. var EOF = corePrimitives.EOF;
  53830. var PostScriptParser = function PostScriptParserClosure() {
  53831. function PostScriptParser(lexer) {
  53832. this.lexer = lexer;
  53833. this.operators = [];
  53834. this.token = null;
  53835. this.prev = null;
  53836. }
  53837. PostScriptParser.prototype = {
  53838. nextToken: function PostScriptParser_nextToken() {
  53839. this.prev = this.token;
  53840. this.token = this.lexer.getToken();
  53841. },
  53842. accept: function PostScriptParser_accept(type) {
  53843. if (this.token.type === type) {
  53844. this.nextToken();
  53845. return true;
  53846. }
  53847. return false;
  53848. },
  53849. expect: function PostScriptParser_expect(type) {
  53850. if (this.accept(type)) {
  53851. return true;
  53852. }
  53853. error('Unexpected symbol: found ' + this.token.type + ' expected ' + type + '.');
  53854. },
  53855. parse: function PostScriptParser_parse() {
  53856. this.nextToken();
  53857. this.expect(PostScriptTokenTypes.LBRACE);
  53858. this.parseBlock();
  53859. this.expect(PostScriptTokenTypes.RBRACE);
  53860. return this.operators;
  53861. },
  53862. parseBlock: function PostScriptParser_parseBlock() {
  53863. while (true) {
  53864. if (this.accept(PostScriptTokenTypes.NUMBER)) {
  53865. this.operators.push(this.prev.value);
  53866. } else if (this.accept(PostScriptTokenTypes.OPERATOR)) {
  53867. this.operators.push(this.prev.value);
  53868. } else if (this.accept(PostScriptTokenTypes.LBRACE)) {
  53869. this.parseCondition();
  53870. } else {
  53871. return;
  53872. }
  53873. }
  53874. },
  53875. parseCondition: function PostScriptParser_parseCondition() {
  53876. var conditionLocation = this.operators.length;
  53877. this.operators.push(null, null);
  53878. this.parseBlock();
  53879. this.expect(PostScriptTokenTypes.RBRACE);
  53880. if (this.accept(PostScriptTokenTypes.IF)) {
  53881. this.operators[conditionLocation] = this.operators.length;
  53882. this.operators[conditionLocation + 1] = 'jz';
  53883. } else if (this.accept(PostScriptTokenTypes.LBRACE)) {
  53884. var jumpLocation = this.operators.length;
  53885. this.operators.push(null, null);
  53886. var endOfTrue = this.operators.length;
  53887. this.parseBlock();
  53888. this.expect(PostScriptTokenTypes.RBRACE);
  53889. this.expect(PostScriptTokenTypes.IFELSE);
  53890. this.operators[jumpLocation] = this.operators.length;
  53891. this.operators[jumpLocation + 1] = 'j';
  53892. this.operators[conditionLocation] = endOfTrue;
  53893. this.operators[conditionLocation + 1] = 'jz';
  53894. } else {
  53895. error('PS Function: error parsing conditional.');
  53896. }
  53897. }
  53898. };
  53899. return PostScriptParser;
  53900. }();
  53901. var PostScriptTokenTypes = {
  53902. LBRACE: 0,
  53903. RBRACE: 1,
  53904. NUMBER: 2,
  53905. OPERATOR: 3,
  53906. IF: 4,
  53907. IFELSE: 5
  53908. };
  53909. var PostScriptToken = function PostScriptTokenClosure() {
  53910. function PostScriptToken(type, value) {
  53911. this.type = type;
  53912. this.value = value;
  53913. }
  53914. var opCache = Object.create(null);
  53915. PostScriptToken.getOperator = function PostScriptToken_getOperator(op) {
  53916. var opValue = opCache[op];
  53917. if (opValue) {
  53918. return opValue;
  53919. }
  53920. return opCache[op] = new PostScriptToken(PostScriptTokenTypes.OPERATOR, op);
  53921. };
  53922. PostScriptToken.LBRACE = new PostScriptToken(PostScriptTokenTypes.LBRACE, '{');
  53923. PostScriptToken.RBRACE = new PostScriptToken(PostScriptTokenTypes.RBRACE, '}');
  53924. PostScriptToken.IF = new PostScriptToken(PostScriptTokenTypes.IF, 'IF');
  53925. PostScriptToken.IFELSE = new PostScriptToken(PostScriptTokenTypes.IFELSE, 'IFELSE');
  53926. return PostScriptToken;
  53927. }();
  53928. var PostScriptLexer = function PostScriptLexerClosure() {
  53929. function PostScriptLexer(stream) {
  53930. this.stream = stream;
  53931. this.nextChar();
  53932. this.strBuf = [];
  53933. }
  53934. PostScriptLexer.prototype = {
  53935. nextChar: function PostScriptLexer_nextChar() {
  53936. return this.currentChar = this.stream.getByte();
  53937. },
  53938. getToken: function PostScriptLexer_getToken() {
  53939. var comment = false;
  53940. var ch = this.currentChar;
  53941. while (true) {
  53942. if (ch < 0) {
  53943. return EOF;
  53944. }
  53945. if (comment) {
  53946. if (ch === 0x0A || ch === 0x0D) {
  53947. comment = false;
  53948. }
  53949. } else if (ch === 0x25) {
  53950. comment = true;
  53951. } else if (!isSpace(ch)) {
  53952. break;
  53953. }
  53954. ch = this.nextChar();
  53955. }
  53956. switch (ch | 0) {
  53957. case 0x30:
  53958. case 0x31:
  53959. case 0x32:
  53960. case 0x33:
  53961. case 0x34:
  53962. case 0x35:
  53963. case 0x36:
  53964. case 0x37:
  53965. case 0x38:
  53966. case 0x39:
  53967. case 0x2B:
  53968. case 0x2D:
  53969. case 0x2E:
  53970. return new PostScriptToken(PostScriptTokenTypes.NUMBER, this.getNumber());
  53971. case 0x7B:
  53972. this.nextChar();
  53973. return PostScriptToken.LBRACE;
  53974. case 0x7D:
  53975. this.nextChar();
  53976. return PostScriptToken.RBRACE;
  53977. }
  53978. var strBuf = this.strBuf;
  53979. strBuf.length = 0;
  53980. strBuf[0] = String.fromCharCode(ch);
  53981. while ((ch = this.nextChar()) >= 0 && (ch >= 0x41 && ch <= 0x5A || ch >= 0x61 && ch <= 0x7A)) {
  53982. strBuf.push(String.fromCharCode(ch));
  53983. }
  53984. var str = strBuf.join('');
  53985. switch (str.toLowerCase()) {
  53986. case 'if':
  53987. return PostScriptToken.IF;
  53988. case 'ifelse':
  53989. return PostScriptToken.IFELSE;
  53990. default:
  53991. return PostScriptToken.getOperator(str);
  53992. }
  53993. },
  53994. getNumber: function PostScriptLexer_getNumber() {
  53995. var ch = this.currentChar;
  53996. var strBuf = this.strBuf;
  53997. strBuf.length = 0;
  53998. strBuf[0] = String.fromCharCode(ch);
  53999. while ((ch = this.nextChar()) >= 0) {
  54000. if (ch >= 0x30 && ch <= 0x39 || ch === 0x2D || ch === 0x2E) {
  54001. strBuf.push(String.fromCharCode(ch));
  54002. } else {
  54003. break;
  54004. }
  54005. }
  54006. var value = parseFloat(strBuf.join(''));
  54007. if (isNaN(value)) {
  54008. error('Invalid floating point number: ' + value);
  54009. }
  54010. return value;
  54011. }
  54012. };
  54013. return PostScriptLexer;
  54014. }();
  54015. exports.PostScriptLexer = PostScriptLexer;
  54016. exports.PostScriptParser = PostScriptParser;
  54017. /***/ }),
  54018. /* 43 */
  54019. /***/ (function(module, exports, __w_pdfjs_require__) {
  54020. "use strict";
  54021. var sharedUtil = __w_pdfjs_require__(0);
  54022. var coreStream = __w_pdfjs_require__(2);
  54023. var coreEncodings = __w_pdfjs_require__(5);
  54024. var warn = sharedUtil.warn;
  54025. var isSpace = sharedUtil.isSpace;
  54026. var Stream = coreStream.Stream;
  54027. var getEncoding = coreEncodings.getEncoding;
  54028. var HINTING_ENABLED = false;
  54029. var Type1CharString = function Type1CharStringClosure() {
  54030. var COMMAND_MAP = {
  54031. 'hstem': [1],
  54032. 'vstem': [3],
  54033. 'vmoveto': [4],
  54034. 'rlineto': [5],
  54035. 'hlineto': [6],
  54036. 'vlineto': [7],
  54037. 'rrcurveto': [8],
  54038. 'callsubr': [10],
  54039. 'flex': [
  54040. 12,
  54041. 35
  54042. ],
  54043. 'drop': [
  54044. 12,
  54045. 18
  54046. ],
  54047. 'endchar': [14],
  54048. 'rmoveto': [21],
  54049. 'hmoveto': [22],
  54050. 'vhcurveto': [30],
  54051. 'hvcurveto': [31]
  54052. };
  54053. function Type1CharString() {
  54054. this.width = 0;
  54055. this.lsb = 0;
  54056. this.flexing = false;
  54057. this.output = [];
  54058. this.stack = [];
  54059. }
  54060. Type1CharString.prototype = {
  54061. convert: function Type1CharString_convert(encoded, subrs, seacAnalysisEnabled) {
  54062. var count = encoded.length;
  54063. var error = false;
  54064. var wx, sbx, subrNumber;
  54065. for (var i = 0; i < count; i++) {
  54066. var value = encoded[i];
  54067. if (value < 32) {
  54068. if (value === 12) {
  54069. value = (value << 8) + encoded[++i];
  54070. }
  54071. switch (value) {
  54072. case 1:
  54073. if (!HINTING_ENABLED) {
  54074. this.stack = [];
  54075. break;
  54076. }
  54077. error = this.executeCommand(2, COMMAND_MAP.hstem);
  54078. break;
  54079. case 3:
  54080. if (!HINTING_ENABLED) {
  54081. this.stack = [];
  54082. break;
  54083. }
  54084. error = this.executeCommand(2, COMMAND_MAP.vstem);
  54085. break;
  54086. case 4:
  54087. if (this.flexing) {
  54088. if (this.stack.length < 1) {
  54089. error = true;
  54090. break;
  54091. }
  54092. var dy = this.stack.pop();
  54093. this.stack.push(0, dy);
  54094. break;
  54095. }
  54096. error = this.executeCommand(1, COMMAND_MAP.vmoveto);
  54097. break;
  54098. case 5:
  54099. error = this.executeCommand(2, COMMAND_MAP.rlineto);
  54100. break;
  54101. case 6:
  54102. error = this.executeCommand(1, COMMAND_MAP.hlineto);
  54103. break;
  54104. case 7:
  54105. error = this.executeCommand(1, COMMAND_MAP.vlineto);
  54106. break;
  54107. case 8:
  54108. error = this.executeCommand(6, COMMAND_MAP.rrcurveto);
  54109. break;
  54110. case 9:
  54111. this.stack = [];
  54112. break;
  54113. case 10:
  54114. if (this.stack.length < 1) {
  54115. error = true;
  54116. break;
  54117. }
  54118. subrNumber = this.stack.pop();
  54119. error = this.convert(subrs[subrNumber], subrs, seacAnalysisEnabled);
  54120. break;
  54121. case 11:
  54122. return error;
  54123. case 13:
  54124. if (this.stack.length < 2) {
  54125. error = true;
  54126. break;
  54127. }
  54128. wx = this.stack.pop();
  54129. sbx = this.stack.pop();
  54130. this.lsb = sbx;
  54131. this.width = wx;
  54132. this.stack.push(wx, sbx);
  54133. error = this.executeCommand(2, COMMAND_MAP.hmoveto);
  54134. break;
  54135. case 14:
  54136. this.output.push(COMMAND_MAP.endchar[0]);
  54137. break;
  54138. case 21:
  54139. if (this.flexing) {
  54140. break;
  54141. }
  54142. error = this.executeCommand(2, COMMAND_MAP.rmoveto);
  54143. break;
  54144. case 22:
  54145. if (this.flexing) {
  54146. this.stack.push(0);
  54147. break;
  54148. }
  54149. error = this.executeCommand(1, COMMAND_MAP.hmoveto);
  54150. break;
  54151. case 30:
  54152. error = this.executeCommand(4, COMMAND_MAP.vhcurveto);
  54153. break;
  54154. case 31:
  54155. error = this.executeCommand(4, COMMAND_MAP.hvcurveto);
  54156. break;
  54157. case (12 << 8) + 0:
  54158. this.stack = [];
  54159. break;
  54160. case (12 << 8) + 1:
  54161. if (!HINTING_ENABLED) {
  54162. this.stack = [];
  54163. break;
  54164. }
  54165. error = this.executeCommand(2, COMMAND_MAP.vstem);
  54166. break;
  54167. case (12 << 8) + 2:
  54168. if (!HINTING_ENABLED) {
  54169. this.stack = [];
  54170. break;
  54171. }
  54172. error = this.executeCommand(2, COMMAND_MAP.hstem);
  54173. break;
  54174. case (12 << 8) + 6:
  54175. if (seacAnalysisEnabled) {
  54176. this.seac = this.stack.splice(-4, 4);
  54177. error = this.executeCommand(0, COMMAND_MAP.endchar);
  54178. } else {
  54179. error = this.executeCommand(4, COMMAND_MAP.endchar);
  54180. }
  54181. break;
  54182. case (12 << 8) + 7:
  54183. if (this.stack.length < 4) {
  54184. error = true;
  54185. break;
  54186. }
  54187. this.stack.pop();
  54188. wx = this.stack.pop();
  54189. var sby = this.stack.pop();
  54190. sbx = this.stack.pop();
  54191. this.lsb = sbx;
  54192. this.width = wx;
  54193. this.stack.push(wx, sbx, sby);
  54194. error = this.executeCommand(3, COMMAND_MAP.rmoveto);
  54195. break;
  54196. case (12 << 8) + 12:
  54197. if (this.stack.length < 2) {
  54198. error = true;
  54199. break;
  54200. }
  54201. var num2 = this.stack.pop();
  54202. var num1 = this.stack.pop();
  54203. this.stack.push(num1 / num2);
  54204. break;
  54205. case (12 << 8) + 16:
  54206. if (this.stack.length < 2) {
  54207. error = true;
  54208. break;
  54209. }
  54210. subrNumber = this.stack.pop();
  54211. var numArgs = this.stack.pop();
  54212. if (subrNumber === 0 && numArgs === 3) {
  54213. var flexArgs = this.stack.splice(this.stack.length - 17, 17);
  54214. 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]);
  54215. error = this.executeCommand(13, COMMAND_MAP.flex, true);
  54216. this.flexing = false;
  54217. this.stack.push(flexArgs[15], flexArgs[16]);
  54218. } else if (subrNumber === 1 && numArgs === 0) {
  54219. this.flexing = true;
  54220. }
  54221. break;
  54222. case (12 << 8) + 17:
  54223. break;
  54224. case (12 << 8) + 33:
  54225. this.stack = [];
  54226. break;
  54227. default:
  54228. warn('Unknown type 1 charstring command of "' + value + '"');
  54229. break;
  54230. }
  54231. if (error) {
  54232. break;
  54233. }
  54234. continue;
  54235. } else if (value <= 246) {
  54236. value = value - 139;
  54237. } else if (value <= 250) {
  54238. value = (value - 247) * 256 + encoded[++i] + 108;
  54239. } else if (value <= 254) {
  54240. value = -((value - 251) * 256) - encoded[++i] - 108;
  54241. } else {
  54242. value = (encoded[++i] & 0xff) << 24 | (encoded[++i] & 0xff) << 16 | (encoded[++i] & 0xff) << 8 | (encoded[++i] & 0xff) << 0;
  54243. }
  54244. this.stack.push(value);
  54245. }
  54246. return error;
  54247. },
  54248. executeCommand: function (howManyArgs, command, keepStack) {
  54249. var stackLength = this.stack.length;
  54250. if (howManyArgs > stackLength) {
  54251. return true;
  54252. }
  54253. var start = stackLength - howManyArgs;
  54254. for (var i = start; i < stackLength; i++) {
  54255. var value = this.stack[i];
  54256. if (value === (value | 0)) {
  54257. this.output.push(28, value >> 8 & 0xff, value & 0xff);
  54258. } else {
  54259. value = 65536 * value | 0;
  54260. this.output.push(255, value >> 24 & 0xFF, value >> 16 & 0xFF, value >> 8 & 0xFF, value & 0xFF);
  54261. }
  54262. }
  54263. this.output.push.apply(this.output, command);
  54264. if (keepStack) {
  54265. this.stack.splice(start, howManyArgs);
  54266. } else {
  54267. this.stack.length = 0;
  54268. }
  54269. return false;
  54270. }
  54271. };
  54272. return Type1CharString;
  54273. }();
  54274. var Type1Parser = function Type1ParserClosure() {
  54275. var EEXEC_ENCRYPT_KEY = 55665;
  54276. var CHAR_STRS_ENCRYPT_KEY = 4330;
  54277. function isHexDigit(code) {
  54278. return code >= 48 && code <= 57 || code >= 65 && code <= 70 || code >= 97 && code <= 102;
  54279. }
  54280. function decrypt(data, key, discardNumber) {
  54281. if (discardNumber >= data.length) {
  54282. return new Uint8Array(0);
  54283. }
  54284. var r = key | 0, c1 = 52845, c2 = 22719, i, j;
  54285. for (i = 0; i < discardNumber; i++) {
  54286. r = (data[i] + r) * c1 + c2 & (1 << 16) - 1;
  54287. }
  54288. var count = data.length - discardNumber;
  54289. var decrypted = new Uint8Array(count);
  54290. for (i = discardNumber, j = 0; j < count; i++, j++) {
  54291. var value = data[i];
  54292. decrypted[j] = value ^ r >> 8;
  54293. r = (value + r) * c1 + c2 & (1 << 16) - 1;
  54294. }
  54295. return decrypted;
  54296. }
  54297. function decryptAscii(data, key, discardNumber) {
  54298. var r = key | 0, c1 = 52845, c2 = 22719;
  54299. var count = data.length, maybeLength = count >>> 1;
  54300. var decrypted = new Uint8Array(maybeLength);
  54301. var i, j;
  54302. for (i = 0, j = 0; i < count; i++) {
  54303. var digit1 = data[i];
  54304. if (!isHexDigit(digit1)) {
  54305. continue;
  54306. }
  54307. i++;
  54308. var digit2;
  54309. while (i < count && !isHexDigit(digit2 = data[i])) {
  54310. i++;
  54311. }
  54312. if (i < count) {
  54313. var value = parseInt(String.fromCharCode(digit1, digit2), 16);
  54314. decrypted[j++] = value ^ r >> 8;
  54315. r = (value + r) * c1 + c2 & (1 << 16) - 1;
  54316. }
  54317. }
  54318. return Array.prototype.slice.call(decrypted, discardNumber, j);
  54319. }
  54320. function isSpecial(c) {
  54321. return c === 0x2F || c === 0x5B || c === 0x5D || c === 0x7B || c === 0x7D || c === 0x28 || c === 0x29;
  54322. }
  54323. function Type1Parser(stream, encrypted, seacAnalysisEnabled) {
  54324. if (encrypted) {
  54325. var data = stream.getBytes();
  54326. var isBinary = !(isHexDigit(data[0]) && isHexDigit(data[1]) && isHexDigit(data[2]) && isHexDigit(data[3]));
  54327. stream = new Stream(isBinary ? decrypt(data, EEXEC_ENCRYPT_KEY, 4) : decryptAscii(data, EEXEC_ENCRYPT_KEY, 4));
  54328. }
  54329. this.seacAnalysisEnabled = !!seacAnalysisEnabled;
  54330. this.stream = stream;
  54331. this.nextChar();
  54332. }
  54333. Type1Parser.prototype = {
  54334. readNumberArray: function Type1Parser_readNumberArray() {
  54335. this.getToken();
  54336. var array = [];
  54337. while (true) {
  54338. var token = this.getToken();
  54339. if (token === null || token === ']' || token === '}') {
  54340. break;
  54341. }
  54342. array.push(parseFloat(token || 0));
  54343. }
  54344. return array;
  54345. },
  54346. readNumber: function Type1Parser_readNumber() {
  54347. var token = this.getToken();
  54348. return parseFloat(token || 0);
  54349. },
  54350. readInt: function Type1Parser_readInt() {
  54351. var token = this.getToken();
  54352. return parseInt(token || 0, 10) | 0;
  54353. },
  54354. readBoolean: function Type1Parser_readBoolean() {
  54355. var token = this.getToken();
  54356. return token === 'true' ? 1 : 0;
  54357. },
  54358. nextChar: function Type1_nextChar() {
  54359. return this.currentChar = this.stream.getByte();
  54360. },
  54361. getToken: function Type1Parser_getToken() {
  54362. var comment = false;
  54363. var ch = this.currentChar;
  54364. while (true) {
  54365. if (ch === -1) {
  54366. return null;
  54367. }
  54368. if (comment) {
  54369. if (ch === 0x0A || ch === 0x0D) {
  54370. comment = false;
  54371. }
  54372. } else if (ch === 0x25) {
  54373. comment = true;
  54374. } else if (!isSpace(ch)) {
  54375. break;
  54376. }
  54377. ch = this.nextChar();
  54378. }
  54379. if (isSpecial(ch)) {
  54380. this.nextChar();
  54381. return String.fromCharCode(ch);
  54382. }
  54383. var token = '';
  54384. do {
  54385. token += String.fromCharCode(ch);
  54386. ch = this.nextChar();
  54387. } while (ch >= 0 && !isSpace(ch) && !isSpecial(ch));
  54388. return token;
  54389. },
  54390. extractFontProgram: function Type1Parser_extractFontProgram() {
  54391. var stream = this.stream;
  54392. var subrs = [], charstrings = [];
  54393. var privateData = Object.create(null);
  54394. privateData['lenIV'] = 4;
  54395. var program = {
  54396. subrs: [],
  54397. charstrings: [],
  54398. properties: { 'privateData': privateData }
  54399. };
  54400. var token, length, data, lenIV, encoded;
  54401. while ((token = this.getToken()) !== null) {
  54402. if (token !== '/') {
  54403. continue;
  54404. }
  54405. token = this.getToken();
  54406. switch (token) {
  54407. case 'CharStrings':
  54408. this.getToken();
  54409. this.getToken();
  54410. this.getToken();
  54411. this.getToken();
  54412. while (true) {
  54413. token = this.getToken();
  54414. if (token === null || token === 'end') {
  54415. break;
  54416. }
  54417. if (token !== '/') {
  54418. continue;
  54419. }
  54420. var glyph = this.getToken();
  54421. length = this.readInt();
  54422. this.getToken();
  54423. data = stream.makeSubStream(stream.pos, length);
  54424. lenIV = program.properties.privateData['lenIV'];
  54425. encoded = decrypt(data.getBytes(), CHAR_STRS_ENCRYPT_KEY, lenIV);
  54426. stream.skip(length);
  54427. this.nextChar();
  54428. token = this.getToken();
  54429. if (token === 'noaccess') {
  54430. this.getToken();
  54431. }
  54432. charstrings.push({
  54433. glyph: glyph,
  54434. encoded: encoded
  54435. });
  54436. }
  54437. break;
  54438. case 'Subrs':
  54439. this.readInt();
  54440. this.getToken();
  54441. while ((token = this.getToken()) === 'dup') {
  54442. var index = this.readInt();
  54443. length = this.readInt();
  54444. this.getToken();
  54445. data = stream.makeSubStream(stream.pos, length);
  54446. lenIV = program.properties.privateData['lenIV'];
  54447. encoded = decrypt(data.getBytes(), CHAR_STRS_ENCRYPT_KEY, lenIV);
  54448. stream.skip(length);
  54449. this.nextChar();
  54450. token = this.getToken();
  54451. if (token === 'noaccess') {
  54452. this.getToken();
  54453. }
  54454. subrs[index] = encoded;
  54455. }
  54456. break;
  54457. case 'BlueValues':
  54458. case 'OtherBlues':
  54459. case 'FamilyBlues':
  54460. case 'FamilyOtherBlues':
  54461. var blueArray = this.readNumberArray();
  54462. if (blueArray.length > 0 && blueArray.length % 2 === 0 && HINTING_ENABLED) {
  54463. program.properties.privateData[token] = blueArray;
  54464. }
  54465. break;
  54466. case 'StemSnapH':
  54467. case 'StemSnapV':
  54468. program.properties.privateData[token] = this.readNumberArray();
  54469. break;
  54470. case 'StdHW':
  54471. case 'StdVW':
  54472. program.properties.privateData[token] = this.readNumberArray()[0];
  54473. break;
  54474. case 'BlueShift':
  54475. case 'lenIV':
  54476. case 'BlueFuzz':
  54477. case 'BlueScale':
  54478. case 'LanguageGroup':
  54479. case 'ExpansionFactor':
  54480. program.properties.privateData[token] = this.readNumber();
  54481. break;
  54482. case 'ForceBold':
  54483. program.properties.privateData[token] = this.readBoolean();
  54484. break;
  54485. }
  54486. }
  54487. for (var i = 0; i < charstrings.length; i++) {
  54488. glyph = charstrings[i].glyph;
  54489. encoded = charstrings[i].encoded;
  54490. var charString = new Type1CharString();
  54491. var error = charString.convert(encoded, subrs, this.seacAnalysisEnabled);
  54492. var output = charString.output;
  54493. if (error) {
  54494. output = [14];
  54495. }
  54496. program.charstrings.push({
  54497. glyphName: glyph,
  54498. charstring: output,
  54499. width: charString.width,
  54500. lsb: charString.lsb,
  54501. seac: charString.seac
  54502. });
  54503. }
  54504. return program;
  54505. },
  54506. extractFontHeader: function Type1Parser_extractFontHeader(properties) {
  54507. var token;
  54508. while ((token = this.getToken()) !== null) {
  54509. if (token !== '/') {
  54510. continue;
  54511. }
  54512. token = this.getToken();
  54513. switch (token) {
  54514. case 'FontMatrix':
  54515. var matrix = this.readNumberArray();
  54516. properties.fontMatrix = matrix;
  54517. break;
  54518. case 'Encoding':
  54519. var encodingArg = this.getToken();
  54520. var encoding;
  54521. if (!/^\d+$/.test(encodingArg)) {
  54522. encoding = getEncoding(encodingArg);
  54523. } else {
  54524. encoding = [];
  54525. var size = parseInt(encodingArg, 10) | 0;
  54526. this.getToken();
  54527. for (var j = 0; j < size; j++) {
  54528. token = this.getToken();
  54529. while (token !== 'dup' && token !== 'def') {
  54530. token = this.getToken();
  54531. if (token === null) {
  54532. return;
  54533. }
  54534. }
  54535. if (token === 'def') {
  54536. break;
  54537. }
  54538. var index = this.readInt();
  54539. this.getToken();
  54540. var glyph = this.getToken();
  54541. encoding[index] = glyph;
  54542. this.getToken();
  54543. }
  54544. }
  54545. properties.builtInEncoding = encoding;
  54546. break;
  54547. case 'FontBBox':
  54548. var fontBBox = this.readNumberArray();
  54549. properties.ascent = Math.max(fontBBox[3], fontBBox[1]);
  54550. properties.descent = Math.min(fontBBox[1], fontBBox[3]);
  54551. properties.ascentScaled = true;
  54552. break;
  54553. }
  54554. }
  54555. }
  54556. };
  54557. return Type1Parser;
  54558. }();
  54559. exports.Type1Parser = Type1Parser;
  54560. /***/ }),
  54561. /* 44 */
  54562. /***/ (function(module, exports, __w_pdfjs_require__) {
  54563. "use strict";
  54564. var sharedUtil = __w_pdfjs_require__(0);
  54565. var displayDOMUtils = __w_pdfjs_require__(3);
  54566. var displayPatternHelper = __w_pdfjs_require__(46);
  54567. var displayWebGL = __w_pdfjs_require__(24);
  54568. var FONT_IDENTITY_MATRIX = sharedUtil.FONT_IDENTITY_MATRIX;
  54569. var IDENTITY_MATRIX = sharedUtil.IDENTITY_MATRIX;
  54570. var ImageKind = sharedUtil.ImageKind;
  54571. var OPS = sharedUtil.OPS;
  54572. var TextRenderingMode = sharedUtil.TextRenderingMode;
  54573. var Uint32ArrayView = sharedUtil.Uint32ArrayView;
  54574. var Util = sharedUtil.Util;
  54575. var assert = sharedUtil.assert;
  54576. var info = sharedUtil.info;
  54577. var isNum = sharedUtil.isNum;
  54578. var isArray = sharedUtil.isArray;
  54579. var isLittleEndian = sharedUtil.isLittleEndian;
  54580. var error = sharedUtil.error;
  54581. var shadow = sharedUtil.shadow;
  54582. var warn = sharedUtil.warn;
  54583. var TilingPattern = displayPatternHelper.TilingPattern;
  54584. var getShadingPatternFromIR = displayPatternHelper.getShadingPatternFromIR;
  54585. var WebGLUtils = displayWebGL.WebGLUtils;
  54586. var hasCanvasTypedArrays = displayDOMUtils.hasCanvasTypedArrays;
  54587. var MIN_FONT_SIZE = 16;
  54588. var MAX_FONT_SIZE = 100;
  54589. var MAX_GROUP_SIZE = 4096;
  54590. var MIN_WIDTH_FACTOR = 0.65;
  54591. var COMPILE_TYPE3_GLYPHS = true;
  54592. var MAX_SIZE_TO_COMPILE = 1000;
  54593. var FULL_CHUNK_HEIGHT = 16;
  54594. var HasCanvasTypedArraysCached = {
  54595. get value() {
  54596. return shadow(HasCanvasTypedArraysCached, 'value', hasCanvasTypedArrays());
  54597. }
  54598. };
  54599. var IsLittleEndianCached = {
  54600. get value() {
  54601. return shadow(IsLittleEndianCached, 'value', isLittleEndian());
  54602. }
  54603. };
  54604. function addContextCurrentTransform(ctx) {
  54605. if (!ctx.mozCurrentTransform) {
  54606. ctx._originalSave = ctx.save;
  54607. ctx._originalRestore = ctx.restore;
  54608. ctx._originalRotate = ctx.rotate;
  54609. ctx._originalScale = ctx.scale;
  54610. ctx._originalTranslate = ctx.translate;
  54611. ctx._originalTransform = ctx.transform;
  54612. ctx._originalSetTransform = ctx.setTransform;
  54613. ctx._transformMatrix = ctx._transformMatrix || [
  54614. 1,
  54615. 0,
  54616. 0,
  54617. 1,
  54618. 0,
  54619. 0
  54620. ];
  54621. ctx._transformStack = [];
  54622. Object.defineProperty(ctx, 'mozCurrentTransform', {
  54623. get: function getCurrentTransform() {
  54624. return this._transformMatrix;
  54625. }
  54626. });
  54627. Object.defineProperty(ctx, 'mozCurrentTransformInverse', {
  54628. get: function getCurrentTransformInverse() {
  54629. var m = this._transformMatrix;
  54630. var a = m[0], b = m[1], c = m[2], d = m[3], e = m[4], f = m[5];
  54631. var ad_bc = a * d - b * c;
  54632. var bc_ad = b * c - a * d;
  54633. return [
  54634. d / ad_bc,
  54635. b / bc_ad,
  54636. c / bc_ad,
  54637. a / ad_bc,
  54638. (d * e - c * f) / bc_ad,
  54639. (b * e - a * f) / ad_bc
  54640. ];
  54641. }
  54642. });
  54643. ctx.save = function ctxSave() {
  54644. var old = this._transformMatrix;
  54645. this._transformStack.push(old);
  54646. this._transformMatrix = old.slice(0, 6);
  54647. this._originalSave();
  54648. };
  54649. ctx.restore = function ctxRestore() {
  54650. var prev = this._transformStack.pop();
  54651. if (prev) {
  54652. this._transformMatrix = prev;
  54653. this._originalRestore();
  54654. }
  54655. };
  54656. ctx.translate = function ctxTranslate(x, y) {
  54657. var m = this._transformMatrix;
  54658. m[4] = m[0] * x + m[2] * y + m[4];
  54659. m[5] = m[1] * x + m[3] * y + m[5];
  54660. this._originalTranslate(x, y);
  54661. };
  54662. ctx.scale = function ctxScale(x, y) {
  54663. var m = this._transformMatrix;
  54664. m[0] = m[0] * x;
  54665. m[1] = m[1] * x;
  54666. m[2] = m[2] * y;
  54667. m[3] = m[3] * y;
  54668. this._originalScale(x, y);
  54669. };
  54670. ctx.transform = function ctxTransform(a, b, c, d, e, f) {
  54671. var m = this._transformMatrix;
  54672. this._transformMatrix = [
  54673. m[0] * a + m[2] * b,
  54674. m[1] * a + m[3] * b,
  54675. m[0] * c + m[2] * d,
  54676. m[1] * c + m[3] * d,
  54677. m[0] * e + m[2] * f + m[4],
  54678. m[1] * e + m[3] * f + m[5]
  54679. ];
  54680. ctx._originalTransform(a, b, c, d, e, f);
  54681. };
  54682. ctx.setTransform = function ctxSetTransform(a, b, c, d, e, f) {
  54683. this._transformMatrix = [
  54684. a,
  54685. b,
  54686. c,
  54687. d,
  54688. e,
  54689. f
  54690. ];
  54691. ctx._originalSetTransform(a, b, c, d, e, f);
  54692. };
  54693. ctx.rotate = function ctxRotate(angle) {
  54694. var cosValue = Math.cos(angle);
  54695. var sinValue = Math.sin(angle);
  54696. var m = this._transformMatrix;
  54697. this._transformMatrix = [
  54698. m[0] * cosValue + m[2] * sinValue,
  54699. m[1] * cosValue + m[3] * sinValue,
  54700. m[0] * -sinValue + m[2] * cosValue,
  54701. m[1] * -sinValue + m[3] * cosValue,
  54702. m[4],
  54703. m[5]
  54704. ];
  54705. this._originalRotate(angle);
  54706. };
  54707. }
  54708. }
  54709. var CachedCanvases = function CachedCanvasesClosure() {
  54710. function CachedCanvases(canvasFactory) {
  54711. this.canvasFactory = canvasFactory;
  54712. this.cache = Object.create(null);
  54713. }
  54714. CachedCanvases.prototype = {
  54715. getCanvas: function CachedCanvases_getCanvas(id, width, height, trackTransform) {
  54716. var canvasEntry;
  54717. if (this.cache[id] !== undefined) {
  54718. canvasEntry = this.cache[id];
  54719. this.canvasFactory.reset(canvasEntry, width, height);
  54720. canvasEntry.context.setTransform(1, 0, 0, 1, 0, 0);
  54721. } else {
  54722. canvasEntry = this.canvasFactory.create(width, height);
  54723. this.cache[id] = canvasEntry;
  54724. }
  54725. if (trackTransform) {
  54726. addContextCurrentTransform(canvasEntry.context);
  54727. }
  54728. return canvasEntry;
  54729. },
  54730. clear: function () {
  54731. for (var id in this.cache) {
  54732. var canvasEntry = this.cache[id];
  54733. this.canvasFactory.destroy(canvasEntry);
  54734. delete this.cache[id];
  54735. }
  54736. }
  54737. };
  54738. return CachedCanvases;
  54739. }();
  54740. function compileType3Glyph(imgData) {
  54741. var POINT_TO_PROCESS_LIMIT = 1000;
  54742. var width = imgData.width, height = imgData.height;
  54743. var i, j, j0, width1 = width + 1;
  54744. var points = new Uint8Array(width1 * (height + 1));
  54745. var POINT_TYPES = new Uint8Array([
  54746. 0,
  54747. 2,
  54748. 4,
  54749. 0,
  54750. 1,
  54751. 0,
  54752. 5,
  54753. 4,
  54754. 8,
  54755. 10,
  54756. 0,
  54757. 8,
  54758. 0,
  54759. 2,
  54760. 1,
  54761. 0
  54762. ]);
  54763. var lineSize = width + 7 & ~7, data0 = imgData.data;
  54764. var data = new Uint8Array(lineSize * height), pos = 0, ii;
  54765. for (i = 0, ii = data0.length; i < ii; i++) {
  54766. var mask = 128, elem = data0[i];
  54767. while (mask > 0) {
  54768. data[pos++] = elem & mask ? 0 : 255;
  54769. mask >>= 1;
  54770. }
  54771. }
  54772. var count = 0;
  54773. pos = 0;
  54774. if (data[pos] !== 0) {
  54775. points[0] = 1;
  54776. ++count;
  54777. }
  54778. for (j = 1; j < width; j++) {
  54779. if (data[pos] !== data[pos + 1]) {
  54780. points[j] = data[pos] ? 2 : 1;
  54781. ++count;
  54782. }
  54783. pos++;
  54784. }
  54785. if (data[pos] !== 0) {
  54786. points[j] = 2;
  54787. ++count;
  54788. }
  54789. for (i = 1; i < height; i++) {
  54790. pos = i * lineSize;
  54791. j0 = i * width1;
  54792. if (data[pos - lineSize] !== data[pos]) {
  54793. points[j0] = data[pos] ? 1 : 8;
  54794. ++count;
  54795. }
  54796. var sum = (data[pos] ? 4 : 0) + (data[pos - lineSize] ? 8 : 0);
  54797. for (j = 1; j < width; j++) {
  54798. sum = (sum >> 2) + (data[pos + 1] ? 4 : 0) + (data[pos - lineSize + 1] ? 8 : 0);
  54799. if (POINT_TYPES[sum]) {
  54800. points[j0 + j] = POINT_TYPES[sum];
  54801. ++count;
  54802. }
  54803. pos++;
  54804. }
  54805. if (data[pos - lineSize] !== data[pos]) {
  54806. points[j0 + j] = data[pos] ? 2 : 4;
  54807. ++count;
  54808. }
  54809. if (count > POINT_TO_PROCESS_LIMIT) {
  54810. return null;
  54811. }
  54812. }
  54813. pos = lineSize * (height - 1);
  54814. j0 = i * width1;
  54815. if (data[pos] !== 0) {
  54816. points[j0] = 8;
  54817. ++count;
  54818. }
  54819. for (j = 1; j < width; j++) {
  54820. if (data[pos] !== data[pos + 1]) {
  54821. points[j0 + j] = data[pos] ? 4 : 8;
  54822. ++count;
  54823. }
  54824. pos++;
  54825. }
  54826. if (data[pos] !== 0) {
  54827. points[j0 + j] = 4;
  54828. ++count;
  54829. }
  54830. if (count > POINT_TO_PROCESS_LIMIT) {
  54831. return null;
  54832. }
  54833. var steps = new Int32Array([
  54834. 0,
  54835. width1,
  54836. -1,
  54837. 0,
  54838. -width1,
  54839. 0,
  54840. 0,
  54841. 0,
  54842. 1
  54843. ]);
  54844. var outlines = [];
  54845. for (i = 0; count && i <= height; i++) {
  54846. var p = i * width1;
  54847. var end = p + width;
  54848. while (p < end && !points[p]) {
  54849. p++;
  54850. }
  54851. if (p === end) {
  54852. continue;
  54853. }
  54854. var coords = [
  54855. p % width1,
  54856. i
  54857. ];
  54858. var type = points[p], p0 = p, pp;
  54859. do {
  54860. var step = steps[type];
  54861. do {
  54862. p += step;
  54863. } while (!points[p]);
  54864. pp = points[p];
  54865. if (pp !== 5 && pp !== 10) {
  54866. type = pp;
  54867. points[p] = 0;
  54868. } else {
  54869. type = pp & 0x33 * type >> 4;
  54870. points[p] &= type >> 2 | type << 2;
  54871. }
  54872. coords.push(p % width1);
  54873. coords.push(p / width1 | 0);
  54874. --count;
  54875. } while (p0 !== p);
  54876. outlines.push(coords);
  54877. --i;
  54878. }
  54879. var drawOutline = function (c) {
  54880. c.save();
  54881. c.scale(1 / width, -1 / height);
  54882. c.translate(0, -height);
  54883. c.beginPath();
  54884. for (var i = 0, ii = outlines.length; i < ii; i++) {
  54885. var o = outlines[i];
  54886. c.moveTo(o[0], o[1]);
  54887. for (var j = 2, jj = o.length; j < jj; j += 2) {
  54888. c.lineTo(o[j], o[j + 1]);
  54889. }
  54890. }
  54891. c.fill();
  54892. c.beginPath();
  54893. c.restore();
  54894. };
  54895. return drawOutline;
  54896. }
  54897. var CanvasExtraState = function CanvasExtraStateClosure() {
  54898. function CanvasExtraState(old) {
  54899. this.alphaIsShape = false;
  54900. this.fontSize = 0;
  54901. this.fontSizeScale = 1;
  54902. this.textMatrix = IDENTITY_MATRIX;
  54903. this.textMatrixScale = 1;
  54904. this.fontMatrix = FONT_IDENTITY_MATRIX;
  54905. this.leading = 0;
  54906. this.x = 0;
  54907. this.y = 0;
  54908. this.lineX = 0;
  54909. this.lineY = 0;
  54910. this.charSpacing = 0;
  54911. this.wordSpacing = 0;
  54912. this.textHScale = 1;
  54913. this.textRenderingMode = TextRenderingMode.FILL;
  54914. this.textRise = 0;
  54915. this.fillColor = '#000000';
  54916. this.strokeColor = '#000000';
  54917. this.patternFill = false;
  54918. this.fillAlpha = 1;
  54919. this.strokeAlpha = 1;
  54920. this.lineWidth = 1;
  54921. this.activeSMask = null;
  54922. this.resumeSMaskCtx = null;
  54923. this.old = old;
  54924. }
  54925. CanvasExtraState.prototype = {
  54926. clone: function CanvasExtraState_clone() {
  54927. return Object.create(this);
  54928. },
  54929. setCurrentPoint: function CanvasExtraState_setCurrentPoint(x, y) {
  54930. this.x = x;
  54931. this.y = y;
  54932. }
  54933. };
  54934. return CanvasExtraState;
  54935. }();
  54936. var CanvasGraphics = function CanvasGraphicsClosure() {
  54937. var EXECUTION_TIME = 15;
  54938. var EXECUTION_STEPS = 10;
  54939. function CanvasGraphics(canvasCtx, commonObjs, objs, canvasFactory, imageLayer) {
  54940. this.ctx = canvasCtx;
  54941. this.current = new CanvasExtraState();
  54942. this.stateStack = [];
  54943. this.pendingClip = null;
  54944. this.pendingEOFill = false;
  54945. this.res = null;
  54946. this.xobjs = null;
  54947. this.commonObjs = commonObjs;
  54948. this.objs = objs;
  54949. this.canvasFactory = canvasFactory;
  54950. this.imageLayer = imageLayer;
  54951. this.groupStack = [];
  54952. this.processingType3 = null;
  54953. this.baseTransform = null;
  54954. this.baseTransformStack = [];
  54955. this.groupLevel = 0;
  54956. this.smaskStack = [];
  54957. this.smaskCounter = 0;
  54958. this.tempSMask = null;
  54959. this.cachedCanvases = new CachedCanvases(this.canvasFactory);
  54960. if (canvasCtx) {
  54961. addContextCurrentTransform(canvasCtx);
  54962. }
  54963. this.cachedGetSinglePixelWidth = null;
  54964. }
  54965. function putBinaryImageData(ctx, imgData) {
  54966. if (typeof ImageData !== 'undefined' && imgData instanceof ImageData) {
  54967. ctx.putImageData(imgData, 0, 0);
  54968. return;
  54969. }
  54970. var height = imgData.height, width = imgData.width;
  54971. var partialChunkHeight = height % FULL_CHUNK_HEIGHT;
  54972. var fullChunks = (height - partialChunkHeight) / FULL_CHUNK_HEIGHT;
  54973. var totalChunks = partialChunkHeight === 0 ? fullChunks : fullChunks + 1;
  54974. var chunkImgData = ctx.createImageData(width, FULL_CHUNK_HEIGHT);
  54975. var srcPos = 0, destPos;
  54976. var src = imgData.data;
  54977. var dest = chunkImgData.data;
  54978. var i, j, thisChunkHeight, elemsInThisChunk;
  54979. if (imgData.kind === ImageKind.GRAYSCALE_1BPP) {
  54980. var srcLength = src.byteLength;
  54981. var dest32 = HasCanvasTypedArraysCached.value ? new Uint32Array(dest.buffer) : new Uint32ArrayView(dest);
  54982. var dest32DataLength = dest32.length;
  54983. var fullSrcDiff = width + 7 >> 3;
  54984. var white = 0xFFFFFFFF;
  54985. var black = IsLittleEndianCached.value || !HasCanvasTypedArraysCached.value ? 0xFF000000 : 0x000000FF;
  54986. for (i = 0; i < totalChunks; i++) {
  54987. thisChunkHeight = i < fullChunks ? FULL_CHUNK_HEIGHT : partialChunkHeight;
  54988. destPos = 0;
  54989. for (j = 0; j < thisChunkHeight; j++) {
  54990. var srcDiff = srcLength - srcPos;
  54991. var k = 0;
  54992. var kEnd = srcDiff > fullSrcDiff ? width : srcDiff * 8 - 7;
  54993. var kEndUnrolled = kEnd & ~7;
  54994. var mask = 0;
  54995. var srcByte = 0;
  54996. for (; k < kEndUnrolled; k += 8) {
  54997. srcByte = src[srcPos++];
  54998. dest32[destPos++] = srcByte & 128 ? white : black;
  54999. dest32[destPos++] = srcByte & 64 ? white : black;
  55000. dest32[destPos++] = srcByte & 32 ? white : black;
  55001. dest32[destPos++] = srcByte & 16 ? white : black;
  55002. dest32[destPos++] = srcByte & 8 ? white : black;
  55003. dest32[destPos++] = srcByte & 4 ? white : black;
  55004. dest32[destPos++] = srcByte & 2 ? white : black;
  55005. dest32[destPos++] = srcByte & 1 ? white : black;
  55006. }
  55007. for (; k < kEnd; k++) {
  55008. if (mask === 0) {
  55009. srcByte = src[srcPos++];
  55010. mask = 128;
  55011. }
  55012. dest32[destPos++] = srcByte & mask ? white : black;
  55013. mask >>= 1;
  55014. }
  55015. }
  55016. while (destPos < dest32DataLength) {
  55017. dest32[destPos++] = 0;
  55018. }
  55019. ctx.putImageData(chunkImgData, 0, i * FULL_CHUNK_HEIGHT);
  55020. }
  55021. } else if (imgData.kind === ImageKind.RGBA_32BPP) {
  55022. j = 0;
  55023. elemsInThisChunk = width * FULL_CHUNK_HEIGHT * 4;
  55024. for (i = 0; i < fullChunks; i++) {
  55025. dest.set(src.subarray(srcPos, srcPos + elemsInThisChunk));
  55026. srcPos += elemsInThisChunk;
  55027. ctx.putImageData(chunkImgData, 0, j);
  55028. j += FULL_CHUNK_HEIGHT;
  55029. }
  55030. if (i < totalChunks) {
  55031. elemsInThisChunk = width * partialChunkHeight * 4;
  55032. dest.set(src.subarray(srcPos, srcPos + elemsInThisChunk));
  55033. ctx.putImageData(chunkImgData, 0, j);
  55034. }
  55035. } else if (imgData.kind === ImageKind.RGB_24BPP) {
  55036. thisChunkHeight = FULL_CHUNK_HEIGHT;
  55037. elemsInThisChunk = width * thisChunkHeight;
  55038. for (i = 0; i < totalChunks; i++) {
  55039. if (i >= fullChunks) {
  55040. thisChunkHeight = partialChunkHeight;
  55041. elemsInThisChunk = width * thisChunkHeight;
  55042. }
  55043. destPos = 0;
  55044. for (j = elemsInThisChunk; j--;) {
  55045. dest[destPos++] = src[srcPos++];
  55046. dest[destPos++] = src[srcPos++];
  55047. dest[destPos++] = src[srcPos++];
  55048. dest[destPos++] = 255;
  55049. }
  55050. ctx.putImageData(chunkImgData, 0, i * FULL_CHUNK_HEIGHT);
  55051. }
  55052. } else {
  55053. error('bad image kind: ' + imgData.kind);
  55054. }
  55055. }
  55056. function putBinaryImageMask(ctx, imgData) {
  55057. var height = imgData.height, width = imgData.width;
  55058. var partialChunkHeight = height % FULL_CHUNK_HEIGHT;
  55059. var fullChunks = (height - partialChunkHeight) / FULL_CHUNK_HEIGHT;
  55060. var totalChunks = partialChunkHeight === 0 ? fullChunks : fullChunks + 1;
  55061. var chunkImgData = ctx.createImageData(width, FULL_CHUNK_HEIGHT);
  55062. var srcPos = 0;
  55063. var src = imgData.data;
  55064. var dest = chunkImgData.data;
  55065. for (var i = 0; i < totalChunks; i++) {
  55066. var thisChunkHeight = i < fullChunks ? FULL_CHUNK_HEIGHT : partialChunkHeight;
  55067. var destPos = 3;
  55068. for (var j = 0; j < thisChunkHeight; j++) {
  55069. var mask = 0;
  55070. for (var k = 0; k < width; k++) {
  55071. if (!mask) {
  55072. var elem = src[srcPos++];
  55073. mask = 128;
  55074. }
  55075. dest[destPos] = elem & mask ? 0 : 255;
  55076. destPos += 4;
  55077. mask >>= 1;
  55078. }
  55079. }
  55080. ctx.putImageData(chunkImgData, 0, i * FULL_CHUNK_HEIGHT);
  55081. }
  55082. }
  55083. function copyCtxState(sourceCtx, destCtx) {
  55084. var properties = [
  55085. 'strokeStyle',
  55086. 'fillStyle',
  55087. 'fillRule',
  55088. 'globalAlpha',
  55089. 'lineWidth',
  55090. 'lineCap',
  55091. 'lineJoin',
  55092. 'miterLimit',
  55093. 'globalCompositeOperation',
  55094. 'font'
  55095. ];
  55096. for (var i = 0, ii = properties.length; i < ii; i++) {
  55097. var property = properties[i];
  55098. if (sourceCtx[property] !== undefined) {
  55099. destCtx[property] = sourceCtx[property];
  55100. }
  55101. }
  55102. if (sourceCtx.setLineDash !== undefined) {
  55103. destCtx.setLineDash(sourceCtx.getLineDash());
  55104. destCtx.lineDashOffset = sourceCtx.lineDashOffset;
  55105. }
  55106. }
  55107. function composeSMaskBackdrop(bytes, r0, g0, b0) {
  55108. var length = bytes.length;
  55109. for (var i = 3; i < length; i += 4) {
  55110. var alpha = bytes[i];
  55111. if (alpha === 0) {
  55112. bytes[i - 3] = r0;
  55113. bytes[i - 2] = g0;
  55114. bytes[i - 1] = b0;
  55115. } else if (alpha < 255) {
  55116. var alpha_ = 255 - alpha;
  55117. bytes[i - 3] = bytes[i - 3] * alpha + r0 * alpha_ >> 8;
  55118. bytes[i - 2] = bytes[i - 2] * alpha + g0 * alpha_ >> 8;
  55119. bytes[i - 1] = bytes[i - 1] * alpha + b0 * alpha_ >> 8;
  55120. }
  55121. }
  55122. }
  55123. function composeSMaskAlpha(maskData, layerData, transferMap) {
  55124. var length = maskData.length;
  55125. var scale = 1 / 255;
  55126. for (var i = 3; i < length; i += 4) {
  55127. var alpha = transferMap ? transferMap[maskData[i]] : maskData[i];
  55128. layerData[i] = layerData[i] * alpha * scale | 0;
  55129. }
  55130. }
  55131. function composeSMaskLuminosity(maskData, layerData, transferMap) {
  55132. var length = maskData.length;
  55133. for (var i = 3; i < length; i += 4) {
  55134. var y = maskData[i - 3] * 77 + maskData[i - 2] * 152 + maskData[i - 1] * 28;
  55135. layerData[i] = transferMap ? layerData[i] * transferMap[y >> 8] >> 8 : layerData[i] * y >> 16;
  55136. }
  55137. }
  55138. function genericComposeSMask(maskCtx, layerCtx, width, height, subtype, backdrop, transferMap) {
  55139. var hasBackdrop = !!backdrop;
  55140. var r0 = hasBackdrop ? backdrop[0] : 0;
  55141. var g0 = hasBackdrop ? backdrop[1] : 0;
  55142. var b0 = hasBackdrop ? backdrop[2] : 0;
  55143. var composeFn;
  55144. if (subtype === 'Luminosity') {
  55145. composeFn = composeSMaskLuminosity;
  55146. } else {
  55147. composeFn = composeSMaskAlpha;
  55148. }
  55149. var PIXELS_TO_PROCESS = 1048576;
  55150. var chunkSize = Math.min(height, Math.ceil(PIXELS_TO_PROCESS / width));
  55151. for (var row = 0; row < height; row += chunkSize) {
  55152. var chunkHeight = Math.min(chunkSize, height - row);
  55153. var maskData = maskCtx.getImageData(0, row, width, chunkHeight);
  55154. var layerData = layerCtx.getImageData(0, row, width, chunkHeight);
  55155. if (hasBackdrop) {
  55156. composeSMaskBackdrop(maskData.data, r0, g0, b0);
  55157. }
  55158. composeFn(maskData.data, layerData.data, transferMap);
  55159. maskCtx.putImageData(layerData, 0, row);
  55160. }
  55161. }
  55162. function composeSMask(ctx, smask, layerCtx) {
  55163. var mask = smask.canvas;
  55164. var maskCtx = smask.context;
  55165. ctx.setTransform(smask.scaleX, 0, 0, smask.scaleY, smask.offsetX, smask.offsetY);
  55166. var backdrop = smask.backdrop || null;
  55167. if (!smask.transferMap && WebGLUtils.isEnabled) {
  55168. var composed = WebGLUtils.composeSMask(layerCtx.canvas, mask, {
  55169. subtype: smask.subtype,
  55170. backdrop: backdrop
  55171. });
  55172. ctx.setTransform(1, 0, 0, 1, 0, 0);
  55173. ctx.drawImage(composed, smask.offsetX, smask.offsetY);
  55174. return;
  55175. }
  55176. genericComposeSMask(maskCtx, layerCtx, mask.width, mask.height, smask.subtype, backdrop, smask.transferMap);
  55177. ctx.drawImage(mask, 0, 0);
  55178. }
  55179. var LINE_CAP_STYLES = [
  55180. 'butt',
  55181. 'round',
  55182. 'square'
  55183. ];
  55184. var LINE_JOIN_STYLES = [
  55185. 'miter',
  55186. 'round',
  55187. 'bevel'
  55188. ];
  55189. var NORMAL_CLIP = {};
  55190. var EO_CLIP = {};
  55191. CanvasGraphics.prototype = {
  55192. beginDrawing: function CanvasGraphics_beginDrawing(transform, viewport, transparency) {
  55193. var width = this.ctx.canvas.width;
  55194. var height = this.ctx.canvas.height;
  55195. this.ctx.save();
  55196. this.ctx.fillStyle = 'rgb(255, 255, 255)';
  55197. this.ctx.fillRect(0, 0, width, height);
  55198. this.ctx.restore();
  55199. if (transparency) {
  55200. var transparentCanvas = this.cachedCanvases.getCanvas('transparent', width, height, true);
  55201. this.compositeCtx = this.ctx;
  55202. this.transparentCanvas = transparentCanvas.canvas;
  55203. this.ctx = transparentCanvas.context;
  55204. this.ctx.save();
  55205. this.ctx.transform.apply(this.ctx, this.compositeCtx.mozCurrentTransform);
  55206. }
  55207. this.ctx.save();
  55208. if (transform) {
  55209. this.ctx.transform.apply(this.ctx, transform);
  55210. }
  55211. this.ctx.transform.apply(this.ctx, viewport.transform);
  55212. this.baseTransform = this.ctx.mozCurrentTransform.slice();
  55213. if (this.imageLayer) {
  55214. this.imageLayer.beginLayout();
  55215. }
  55216. },
  55217. executeOperatorList: function CanvasGraphics_executeOperatorList(operatorList, executionStartIdx, continueCallback, stepper) {
  55218. var argsArray = operatorList.argsArray;
  55219. var fnArray = operatorList.fnArray;
  55220. var i = executionStartIdx || 0;
  55221. var argsArrayLen = argsArray.length;
  55222. if (argsArrayLen === i) {
  55223. return i;
  55224. }
  55225. var chunkOperations = argsArrayLen - i > EXECUTION_STEPS && typeof continueCallback === 'function';
  55226. var endTime = chunkOperations ? Date.now() + EXECUTION_TIME : 0;
  55227. var steps = 0;
  55228. var commonObjs = this.commonObjs;
  55229. var objs = this.objs;
  55230. var fnId;
  55231. while (true) {
  55232. if (stepper !== undefined && i === stepper.nextBreakPoint) {
  55233. stepper.breakIt(i, continueCallback);
  55234. return i;
  55235. }
  55236. fnId = fnArray[i];
  55237. if (fnId !== OPS.dependency) {
  55238. this[fnId].apply(this, argsArray[i]);
  55239. } else {
  55240. var deps = argsArray[i];
  55241. for (var n = 0, nn = deps.length; n < nn; n++) {
  55242. var depObjId = deps[n];
  55243. var common = depObjId[0] === 'g' && depObjId[1] === '_';
  55244. var objsPool = common ? commonObjs : objs;
  55245. if (!objsPool.isResolved(depObjId)) {
  55246. objsPool.get(depObjId, continueCallback);
  55247. return i;
  55248. }
  55249. }
  55250. }
  55251. i++;
  55252. if (i === argsArrayLen) {
  55253. return i;
  55254. }
  55255. if (chunkOperations && ++steps > EXECUTION_STEPS) {
  55256. if (Date.now() > endTime) {
  55257. continueCallback();
  55258. return i;
  55259. }
  55260. steps = 0;
  55261. }
  55262. }
  55263. },
  55264. endDrawing: function CanvasGraphics_endDrawing() {
  55265. if (this.current.activeSMask !== null) {
  55266. this.endSMaskGroup();
  55267. }
  55268. this.ctx.restore();
  55269. if (this.transparentCanvas) {
  55270. this.ctx = this.compositeCtx;
  55271. this.ctx.save();
  55272. this.ctx.setTransform(1, 0, 0, 1, 0, 0);
  55273. this.ctx.drawImage(this.transparentCanvas, 0, 0);
  55274. this.ctx.restore();
  55275. this.transparentCanvas = null;
  55276. }
  55277. this.cachedCanvases.clear();
  55278. WebGLUtils.clear();
  55279. if (this.imageLayer) {
  55280. this.imageLayer.endLayout();
  55281. }
  55282. },
  55283. setLineWidth: function CanvasGraphics_setLineWidth(width) {
  55284. this.current.lineWidth = width;
  55285. this.ctx.lineWidth = width;
  55286. },
  55287. setLineCap: function CanvasGraphics_setLineCap(style) {
  55288. this.ctx.lineCap = LINE_CAP_STYLES[style];
  55289. },
  55290. setLineJoin: function CanvasGraphics_setLineJoin(style) {
  55291. this.ctx.lineJoin = LINE_JOIN_STYLES[style];
  55292. },
  55293. setMiterLimit: function CanvasGraphics_setMiterLimit(limit) {
  55294. this.ctx.miterLimit = limit;
  55295. },
  55296. setDash: function CanvasGraphics_setDash(dashArray, dashPhase) {
  55297. var ctx = this.ctx;
  55298. if (ctx.setLineDash !== undefined) {
  55299. ctx.setLineDash(dashArray);
  55300. ctx.lineDashOffset = dashPhase;
  55301. }
  55302. },
  55303. setRenderingIntent: function CanvasGraphics_setRenderingIntent(intent) {
  55304. },
  55305. setFlatness: function CanvasGraphics_setFlatness(flatness) {
  55306. },
  55307. setGState: function CanvasGraphics_setGState(states) {
  55308. for (var i = 0, ii = states.length; i < ii; i++) {
  55309. var state = states[i];
  55310. var key = state[0];
  55311. var value = state[1];
  55312. switch (key) {
  55313. case 'LW':
  55314. this.setLineWidth(value);
  55315. break;
  55316. case 'LC':
  55317. this.setLineCap(value);
  55318. break;
  55319. case 'LJ':
  55320. this.setLineJoin(value);
  55321. break;
  55322. case 'ML':
  55323. this.setMiterLimit(value);
  55324. break;
  55325. case 'D':
  55326. this.setDash(value[0], value[1]);
  55327. break;
  55328. case 'RI':
  55329. this.setRenderingIntent(value);
  55330. break;
  55331. case 'FL':
  55332. this.setFlatness(value);
  55333. break;
  55334. case 'Font':
  55335. this.setFont(value[0], value[1]);
  55336. break;
  55337. case 'CA':
  55338. this.current.strokeAlpha = state[1];
  55339. break;
  55340. case 'ca':
  55341. this.current.fillAlpha = state[1];
  55342. this.ctx.globalAlpha = state[1];
  55343. break;
  55344. case 'BM':
  55345. if (value && value.name && value.name !== 'Normal') {
  55346. var mode = value.name.replace(/([A-Z])/g, function (c) {
  55347. return '-' + c.toLowerCase();
  55348. }).substring(1);
  55349. this.ctx.globalCompositeOperation = mode;
  55350. if (this.ctx.globalCompositeOperation !== mode) {
  55351. warn('globalCompositeOperation "' + mode + '" is not supported');
  55352. }
  55353. } else {
  55354. this.ctx.globalCompositeOperation = 'source-over';
  55355. }
  55356. break;
  55357. case 'SMask':
  55358. if (this.current.activeSMask) {
  55359. if (this.stateStack.length > 0 && this.stateStack[this.stateStack.length - 1].activeSMask === this.current.activeSMask) {
  55360. this.suspendSMaskGroup();
  55361. } else {
  55362. this.endSMaskGroup();
  55363. }
  55364. }
  55365. this.current.activeSMask = value ? this.tempSMask : null;
  55366. if (this.current.activeSMask) {
  55367. this.beginSMaskGroup();
  55368. }
  55369. this.tempSMask = null;
  55370. break;
  55371. }
  55372. }
  55373. },
  55374. beginSMaskGroup: function CanvasGraphics_beginSMaskGroup() {
  55375. var activeSMask = this.current.activeSMask;
  55376. var drawnWidth = activeSMask.canvas.width;
  55377. var drawnHeight = activeSMask.canvas.height;
  55378. var cacheId = 'smaskGroupAt' + this.groupLevel;
  55379. var scratchCanvas = this.cachedCanvases.getCanvas(cacheId, drawnWidth, drawnHeight, true);
  55380. var currentCtx = this.ctx;
  55381. var currentTransform = currentCtx.mozCurrentTransform;
  55382. this.ctx.save();
  55383. var groupCtx = scratchCanvas.context;
  55384. groupCtx.scale(1 / activeSMask.scaleX, 1 / activeSMask.scaleY);
  55385. groupCtx.translate(-activeSMask.offsetX, -activeSMask.offsetY);
  55386. groupCtx.transform.apply(groupCtx, currentTransform);
  55387. activeSMask.startTransformInverse = groupCtx.mozCurrentTransformInverse;
  55388. copyCtxState(currentCtx, groupCtx);
  55389. this.ctx = groupCtx;
  55390. this.setGState([
  55391. [
  55392. 'BM',
  55393. 'Normal'
  55394. ],
  55395. [
  55396. 'ca',
  55397. 1
  55398. ],
  55399. [
  55400. 'CA',
  55401. 1
  55402. ]
  55403. ]);
  55404. this.groupStack.push(currentCtx);
  55405. this.groupLevel++;
  55406. },
  55407. suspendSMaskGroup: function CanvasGraphics_endSMaskGroup() {
  55408. var groupCtx = this.ctx;
  55409. this.groupLevel--;
  55410. this.ctx = this.groupStack.pop();
  55411. composeSMask(this.ctx, this.current.activeSMask, groupCtx);
  55412. this.ctx.restore();
  55413. this.ctx.save();
  55414. copyCtxState(groupCtx, this.ctx);
  55415. this.current.resumeSMaskCtx = groupCtx;
  55416. var deltaTransform = Util.transform(this.current.activeSMask.startTransformInverse, groupCtx.mozCurrentTransform);
  55417. this.ctx.transform.apply(this.ctx, deltaTransform);
  55418. groupCtx.save();
  55419. groupCtx.setTransform(1, 0, 0, 1, 0, 0);
  55420. groupCtx.clearRect(0, 0, groupCtx.canvas.width, groupCtx.canvas.height);
  55421. groupCtx.restore();
  55422. },
  55423. resumeSMaskGroup: function CanvasGraphics_endSMaskGroup() {
  55424. var groupCtx = this.current.resumeSMaskCtx;
  55425. var currentCtx = this.ctx;
  55426. this.ctx = groupCtx;
  55427. this.groupStack.push(currentCtx);
  55428. this.groupLevel++;
  55429. },
  55430. endSMaskGroup: function CanvasGraphics_endSMaskGroup() {
  55431. var groupCtx = this.ctx;
  55432. this.groupLevel--;
  55433. this.ctx = this.groupStack.pop();
  55434. composeSMask(this.ctx, this.current.activeSMask, groupCtx);
  55435. this.ctx.restore();
  55436. copyCtxState(groupCtx, this.ctx);
  55437. var deltaTransform = Util.transform(this.current.activeSMask.startTransformInverse, groupCtx.mozCurrentTransform);
  55438. this.ctx.transform.apply(this.ctx, deltaTransform);
  55439. },
  55440. save: function CanvasGraphics_save() {
  55441. this.ctx.save();
  55442. var old = this.current;
  55443. this.stateStack.push(old);
  55444. this.current = old.clone();
  55445. this.current.resumeSMaskCtx = null;
  55446. },
  55447. restore: function CanvasGraphics_restore() {
  55448. if (this.current.resumeSMaskCtx) {
  55449. this.resumeSMaskGroup();
  55450. }
  55451. if (this.current.activeSMask !== null && (this.stateStack.length === 0 || this.stateStack[this.stateStack.length - 1].activeSMask !== this.current.activeSMask)) {
  55452. this.endSMaskGroup();
  55453. }
  55454. if (this.stateStack.length !== 0) {
  55455. this.current = this.stateStack.pop();
  55456. this.ctx.restore();
  55457. this.pendingClip = null;
  55458. this.cachedGetSinglePixelWidth = null;
  55459. }
  55460. },
  55461. transform: function CanvasGraphics_transform(a, b, c, d, e, f) {
  55462. this.ctx.transform(a, b, c, d, e, f);
  55463. this.cachedGetSinglePixelWidth = null;
  55464. },
  55465. constructPath: function CanvasGraphics_constructPath(ops, args) {
  55466. var ctx = this.ctx;
  55467. var current = this.current;
  55468. var x = current.x, y = current.y;
  55469. for (var i = 0, j = 0, ii = ops.length; i < ii; i++) {
  55470. switch (ops[i] | 0) {
  55471. case OPS.rectangle:
  55472. x = args[j++];
  55473. y = args[j++];
  55474. var width = args[j++];
  55475. var height = args[j++];
  55476. if (width === 0) {
  55477. width = this.getSinglePixelWidth();
  55478. }
  55479. if (height === 0) {
  55480. height = this.getSinglePixelWidth();
  55481. }
  55482. var xw = x + width;
  55483. var yh = y + height;
  55484. this.ctx.moveTo(x, y);
  55485. this.ctx.lineTo(xw, y);
  55486. this.ctx.lineTo(xw, yh);
  55487. this.ctx.lineTo(x, yh);
  55488. this.ctx.lineTo(x, y);
  55489. this.ctx.closePath();
  55490. break;
  55491. case OPS.moveTo:
  55492. x = args[j++];
  55493. y = args[j++];
  55494. ctx.moveTo(x, y);
  55495. break;
  55496. case OPS.lineTo:
  55497. x = args[j++];
  55498. y = args[j++];
  55499. ctx.lineTo(x, y);
  55500. break;
  55501. case OPS.curveTo:
  55502. x = args[j + 4];
  55503. y = args[j + 5];
  55504. ctx.bezierCurveTo(args[j], args[j + 1], args[j + 2], args[j + 3], x, y);
  55505. j += 6;
  55506. break;
  55507. case OPS.curveTo2:
  55508. ctx.bezierCurveTo(x, y, args[j], args[j + 1], args[j + 2], args[j + 3]);
  55509. x = args[j + 2];
  55510. y = args[j + 3];
  55511. j += 4;
  55512. break;
  55513. case OPS.curveTo3:
  55514. x = args[j + 2];
  55515. y = args[j + 3];
  55516. ctx.bezierCurveTo(args[j], args[j + 1], x, y, x, y);
  55517. j += 4;
  55518. break;
  55519. case OPS.closePath:
  55520. ctx.closePath();
  55521. break;
  55522. }
  55523. }
  55524. current.setCurrentPoint(x, y);
  55525. },
  55526. closePath: function CanvasGraphics_closePath() {
  55527. this.ctx.closePath();
  55528. },
  55529. stroke: function CanvasGraphics_stroke(consumePath) {
  55530. consumePath = typeof consumePath !== 'undefined' ? consumePath : true;
  55531. var ctx = this.ctx;
  55532. var strokeColor = this.current.strokeColor;
  55533. ctx.lineWidth = Math.max(this.getSinglePixelWidth() * MIN_WIDTH_FACTOR, this.current.lineWidth);
  55534. ctx.globalAlpha = this.current.strokeAlpha;
  55535. if (strokeColor && strokeColor.hasOwnProperty('type') && strokeColor.type === 'Pattern') {
  55536. ctx.save();
  55537. ctx.strokeStyle = strokeColor.getPattern(ctx, this);
  55538. ctx.stroke();
  55539. ctx.restore();
  55540. } else {
  55541. ctx.stroke();
  55542. }
  55543. if (consumePath) {
  55544. this.consumePath();
  55545. }
  55546. ctx.globalAlpha = this.current.fillAlpha;
  55547. },
  55548. closeStroke: function CanvasGraphics_closeStroke() {
  55549. this.closePath();
  55550. this.stroke();
  55551. },
  55552. fill: function CanvasGraphics_fill(consumePath) {
  55553. consumePath = typeof consumePath !== 'undefined' ? consumePath : true;
  55554. var ctx = this.ctx;
  55555. var fillColor = this.current.fillColor;
  55556. var isPatternFill = this.current.patternFill;
  55557. var needRestore = false;
  55558. if (isPatternFill) {
  55559. ctx.save();
  55560. if (this.baseTransform) {
  55561. ctx.setTransform.apply(ctx, this.baseTransform);
  55562. }
  55563. ctx.fillStyle = fillColor.getPattern(ctx, this);
  55564. needRestore = true;
  55565. }
  55566. if (this.pendingEOFill) {
  55567. ctx.fill('evenodd');
  55568. this.pendingEOFill = false;
  55569. } else {
  55570. ctx.fill();
  55571. }
  55572. if (needRestore) {
  55573. ctx.restore();
  55574. }
  55575. if (consumePath) {
  55576. this.consumePath();
  55577. }
  55578. },
  55579. eoFill: function CanvasGraphics_eoFill() {
  55580. this.pendingEOFill = true;
  55581. this.fill();
  55582. },
  55583. fillStroke: function CanvasGraphics_fillStroke() {
  55584. this.fill(false);
  55585. this.stroke(false);
  55586. this.consumePath();
  55587. },
  55588. eoFillStroke: function CanvasGraphics_eoFillStroke() {
  55589. this.pendingEOFill = true;
  55590. this.fillStroke();
  55591. },
  55592. closeFillStroke: function CanvasGraphics_closeFillStroke() {
  55593. this.closePath();
  55594. this.fillStroke();
  55595. },
  55596. closeEOFillStroke: function CanvasGraphics_closeEOFillStroke() {
  55597. this.pendingEOFill = true;
  55598. this.closePath();
  55599. this.fillStroke();
  55600. },
  55601. endPath: function CanvasGraphics_endPath() {
  55602. this.consumePath();
  55603. },
  55604. clip: function CanvasGraphics_clip() {
  55605. this.pendingClip = NORMAL_CLIP;
  55606. },
  55607. eoClip: function CanvasGraphics_eoClip() {
  55608. this.pendingClip = EO_CLIP;
  55609. },
  55610. beginText: function CanvasGraphics_beginText() {
  55611. this.current.textMatrix = IDENTITY_MATRIX;
  55612. this.current.textMatrixScale = 1;
  55613. this.current.x = this.current.lineX = 0;
  55614. this.current.y = this.current.lineY = 0;
  55615. },
  55616. endText: function CanvasGraphics_endText() {
  55617. var paths = this.pendingTextPaths;
  55618. var ctx = this.ctx;
  55619. if (paths === undefined) {
  55620. ctx.beginPath();
  55621. return;
  55622. }
  55623. ctx.save();
  55624. ctx.beginPath();
  55625. for (var i = 0; i < paths.length; i++) {
  55626. var path = paths[i];
  55627. ctx.setTransform.apply(ctx, path.transform);
  55628. ctx.translate(path.x, path.y);
  55629. path.addToPath(ctx, path.fontSize);
  55630. }
  55631. ctx.restore();
  55632. ctx.clip();
  55633. ctx.beginPath();
  55634. delete this.pendingTextPaths;
  55635. },
  55636. setCharSpacing: function CanvasGraphics_setCharSpacing(spacing) {
  55637. this.current.charSpacing = spacing;
  55638. },
  55639. setWordSpacing: function CanvasGraphics_setWordSpacing(spacing) {
  55640. this.current.wordSpacing = spacing;
  55641. },
  55642. setHScale: function CanvasGraphics_setHScale(scale) {
  55643. this.current.textHScale = scale / 100;
  55644. },
  55645. setLeading: function CanvasGraphics_setLeading(leading) {
  55646. this.current.leading = -leading;
  55647. },
  55648. setFont: function CanvasGraphics_setFont(fontRefName, size) {
  55649. var fontObj = this.commonObjs.get(fontRefName);
  55650. var current = this.current;
  55651. if (!fontObj) {
  55652. error('Can\'t find font for ' + fontRefName);
  55653. }
  55654. current.fontMatrix = fontObj.fontMatrix ? fontObj.fontMatrix : FONT_IDENTITY_MATRIX;
  55655. if (current.fontMatrix[0] === 0 || current.fontMatrix[3] === 0) {
  55656. warn('Invalid font matrix for font ' + fontRefName);
  55657. }
  55658. if (size < 0) {
  55659. size = -size;
  55660. current.fontDirection = -1;
  55661. } else {
  55662. current.fontDirection = 1;
  55663. }
  55664. this.current.font = fontObj;
  55665. this.current.fontSize = size;
  55666. if (fontObj.isType3Font) {
  55667. return;
  55668. }
  55669. var name = fontObj.loadedName || 'sans-serif';
  55670. var bold = fontObj.black ? '900' : fontObj.bold ? 'bold' : 'normal';
  55671. var italic = fontObj.italic ? 'italic' : 'normal';
  55672. var typeface = '"' + name + '", ' + fontObj.fallbackName;
  55673. var browserFontSize = size < MIN_FONT_SIZE ? MIN_FONT_SIZE : size > MAX_FONT_SIZE ? MAX_FONT_SIZE : size;
  55674. this.current.fontSizeScale = size / browserFontSize;
  55675. var rule = italic + ' ' + bold + ' ' + browserFontSize + 'px ' + typeface;
  55676. this.ctx.font = rule;
  55677. },
  55678. setTextRenderingMode: function CanvasGraphics_setTextRenderingMode(mode) {
  55679. this.current.textRenderingMode = mode;
  55680. },
  55681. setTextRise: function CanvasGraphics_setTextRise(rise) {
  55682. this.current.textRise = rise;
  55683. },
  55684. moveText: function CanvasGraphics_moveText(x, y) {
  55685. this.current.x = this.current.lineX += x;
  55686. this.current.y = this.current.lineY += y;
  55687. },
  55688. setLeadingMoveText: function CanvasGraphics_setLeadingMoveText(x, y) {
  55689. this.setLeading(-y);
  55690. this.moveText(x, y);
  55691. },
  55692. setTextMatrix: function CanvasGraphics_setTextMatrix(a, b, c, d, e, f) {
  55693. this.current.textMatrix = [
  55694. a,
  55695. b,
  55696. c,
  55697. d,
  55698. e,
  55699. f
  55700. ];
  55701. this.current.textMatrixScale = Math.sqrt(a * a + b * b);
  55702. this.current.x = this.current.lineX = 0;
  55703. this.current.y = this.current.lineY = 0;
  55704. },
  55705. nextLine: function CanvasGraphics_nextLine() {
  55706. this.moveText(0, this.current.leading);
  55707. },
  55708. paintChar: function CanvasGraphics_paintChar(character, x, y) {
  55709. var ctx = this.ctx;
  55710. var current = this.current;
  55711. var font = current.font;
  55712. var textRenderingMode = current.textRenderingMode;
  55713. var fontSize = current.fontSize / current.fontSizeScale;
  55714. var fillStrokeMode = textRenderingMode & TextRenderingMode.FILL_STROKE_MASK;
  55715. var isAddToPathSet = !!(textRenderingMode & TextRenderingMode.ADD_TO_PATH_FLAG);
  55716. var addToPath;
  55717. if (font.disableFontFace || isAddToPathSet) {
  55718. addToPath = font.getPathGenerator(this.commonObjs, character);
  55719. }
  55720. if (font.disableFontFace) {
  55721. ctx.save();
  55722. ctx.translate(x, y);
  55723. ctx.beginPath();
  55724. addToPath(ctx, fontSize);
  55725. if (fillStrokeMode === TextRenderingMode.FILL || fillStrokeMode === TextRenderingMode.FILL_STROKE) {
  55726. ctx.fill();
  55727. }
  55728. if (fillStrokeMode === TextRenderingMode.STROKE || fillStrokeMode === TextRenderingMode.FILL_STROKE) {
  55729. ctx.stroke();
  55730. }
  55731. ctx.restore();
  55732. } else {
  55733. if (fillStrokeMode === TextRenderingMode.FILL || fillStrokeMode === TextRenderingMode.FILL_STROKE) {
  55734. ctx.fillText(character, x, y);
  55735. }
  55736. if (fillStrokeMode === TextRenderingMode.STROKE || fillStrokeMode === TextRenderingMode.FILL_STROKE) {
  55737. ctx.strokeText(character, x, y);
  55738. }
  55739. }
  55740. if (isAddToPathSet) {
  55741. var paths = this.pendingTextPaths || (this.pendingTextPaths = []);
  55742. paths.push({
  55743. transform: ctx.mozCurrentTransform,
  55744. x: x,
  55745. y: y,
  55746. fontSize: fontSize,
  55747. addToPath: addToPath
  55748. });
  55749. }
  55750. },
  55751. get isFontSubpixelAAEnabled() {
  55752. var ctx = this.canvasFactory.create(10, 10).context;
  55753. ctx.scale(1.5, 1);
  55754. ctx.fillText('I', 0, 10);
  55755. var data = ctx.getImageData(0, 0, 10, 10).data;
  55756. var enabled = false;
  55757. for (var i = 3; i < data.length; i += 4) {
  55758. if (data[i] > 0 && data[i] < 255) {
  55759. enabled = true;
  55760. break;
  55761. }
  55762. }
  55763. return shadow(this, 'isFontSubpixelAAEnabled', enabled);
  55764. },
  55765. showText: function CanvasGraphics_showText(glyphs) {
  55766. var current = this.current;
  55767. var font = current.font;
  55768. if (font.isType3Font) {
  55769. return this.showType3Text(glyphs);
  55770. }
  55771. var fontSize = current.fontSize;
  55772. if (fontSize === 0) {
  55773. return;
  55774. }
  55775. var ctx = this.ctx;
  55776. var fontSizeScale = current.fontSizeScale;
  55777. var charSpacing = current.charSpacing;
  55778. var wordSpacing = current.wordSpacing;
  55779. var fontDirection = current.fontDirection;
  55780. var textHScale = current.textHScale * fontDirection;
  55781. var glyphsLength = glyphs.length;
  55782. var vertical = font.vertical;
  55783. var spacingDir = vertical ? 1 : -1;
  55784. var defaultVMetrics = font.defaultVMetrics;
  55785. var widthAdvanceScale = fontSize * current.fontMatrix[0];
  55786. var simpleFillText = current.textRenderingMode === TextRenderingMode.FILL && !font.disableFontFace;
  55787. ctx.save();
  55788. ctx.transform.apply(ctx, current.textMatrix);
  55789. ctx.translate(current.x, current.y + current.textRise);
  55790. if (current.patternFill) {
  55791. ctx.fillStyle = current.fillColor.getPattern(ctx, this);
  55792. }
  55793. if (fontDirection > 0) {
  55794. ctx.scale(textHScale, -1);
  55795. } else {
  55796. ctx.scale(textHScale, 1);
  55797. }
  55798. var lineWidth = current.lineWidth;
  55799. var scale = current.textMatrixScale;
  55800. if (scale === 0 || lineWidth === 0) {
  55801. var fillStrokeMode = current.textRenderingMode & TextRenderingMode.FILL_STROKE_MASK;
  55802. if (fillStrokeMode === TextRenderingMode.STROKE || fillStrokeMode === TextRenderingMode.FILL_STROKE) {
  55803. this.cachedGetSinglePixelWidth = null;
  55804. lineWidth = this.getSinglePixelWidth() * MIN_WIDTH_FACTOR;
  55805. }
  55806. } else {
  55807. lineWidth /= scale;
  55808. }
  55809. if (fontSizeScale !== 1.0) {
  55810. ctx.scale(fontSizeScale, fontSizeScale);
  55811. lineWidth /= fontSizeScale;
  55812. }
  55813. ctx.lineWidth = lineWidth;
  55814. var x = 0, i;
  55815. for (i = 0; i < glyphsLength; ++i) {
  55816. var glyph = glyphs[i];
  55817. if (isNum(glyph)) {
  55818. x += spacingDir * glyph * fontSize / 1000;
  55819. continue;
  55820. }
  55821. var restoreNeeded = false;
  55822. var spacing = (glyph.isSpace ? wordSpacing : 0) + charSpacing;
  55823. var character = glyph.fontChar;
  55824. var accent = glyph.accent;
  55825. var scaledX, scaledY, scaledAccentX, scaledAccentY;
  55826. var width = glyph.width;
  55827. if (vertical) {
  55828. var vmetric, vx, vy;
  55829. vmetric = glyph.vmetric || defaultVMetrics;
  55830. vx = glyph.vmetric ? vmetric[1] : width * 0.5;
  55831. vx = -vx * widthAdvanceScale;
  55832. vy = vmetric[2] * widthAdvanceScale;
  55833. width = vmetric ? -vmetric[0] : width;
  55834. scaledX = vx / fontSizeScale;
  55835. scaledY = (x + vy) / fontSizeScale;
  55836. } else {
  55837. scaledX = x / fontSizeScale;
  55838. scaledY = 0;
  55839. }
  55840. if (font.remeasure && width > 0) {
  55841. var measuredWidth = ctx.measureText(character).width * 1000 / fontSize * fontSizeScale;
  55842. if (width < measuredWidth && this.isFontSubpixelAAEnabled) {
  55843. var characterScaleX = width / measuredWidth;
  55844. restoreNeeded = true;
  55845. ctx.save();
  55846. ctx.scale(characterScaleX, 1);
  55847. scaledX /= characterScaleX;
  55848. } else if (width !== measuredWidth) {
  55849. scaledX += (width - measuredWidth) / 2000 * fontSize / fontSizeScale;
  55850. }
  55851. }
  55852. if (glyph.isInFont || font.missingFile) {
  55853. if (simpleFillText && !accent) {
  55854. ctx.fillText(character, scaledX, scaledY);
  55855. } else {
  55856. this.paintChar(character, scaledX, scaledY);
  55857. if (accent) {
  55858. scaledAccentX = scaledX + accent.offset.x / fontSizeScale;
  55859. scaledAccentY = scaledY - accent.offset.y / fontSizeScale;
  55860. this.paintChar(accent.fontChar, scaledAccentX, scaledAccentY);
  55861. }
  55862. }
  55863. }
  55864. var charWidth = width * widthAdvanceScale + spacing * fontDirection;
  55865. x += charWidth;
  55866. if (restoreNeeded) {
  55867. ctx.restore();
  55868. }
  55869. }
  55870. if (vertical) {
  55871. current.y -= x * textHScale;
  55872. } else {
  55873. current.x += x * textHScale;
  55874. }
  55875. ctx.restore();
  55876. },
  55877. showType3Text: function CanvasGraphics_showType3Text(glyphs) {
  55878. var ctx = this.ctx;
  55879. var current = this.current;
  55880. var font = current.font;
  55881. var fontSize = current.fontSize;
  55882. var fontDirection = current.fontDirection;
  55883. var spacingDir = font.vertical ? 1 : -1;
  55884. var charSpacing = current.charSpacing;
  55885. var wordSpacing = current.wordSpacing;
  55886. var textHScale = current.textHScale * fontDirection;
  55887. var fontMatrix = current.fontMatrix || FONT_IDENTITY_MATRIX;
  55888. var glyphsLength = glyphs.length;
  55889. var isTextInvisible = current.textRenderingMode === TextRenderingMode.INVISIBLE;
  55890. var i, glyph, width, spacingLength;
  55891. if (isTextInvisible || fontSize === 0) {
  55892. return;
  55893. }
  55894. this.cachedGetSinglePixelWidth = null;
  55895. ctx.save();
  55896. ctx.transform.apply(ctx, current.textMatrix);
  55897. ctx.translate(current.x, current.y);
  55898. ctx.scale(textHScale, fontDirection);
  55899. for (i = 0; i < glyphsLength; ++i) {
  55900. glyph = glyphs[i];
  55901. if (isNum(glyph)) {
  55902. spacingLength = spacingDir * glyph * fontSize / 1000;
  55903. this.ctx.translate(spacingLength, 0);
  55904. current.x += spacingLength * textHScale;
  55905. continue;
  55906. }
  55907. var spacing = (glyph.isSpace ? wordSpacing : 0) + charSpacing;
  55908. var operatorList = font.charProcOperatorList[glyph.operatorListId];
  55909. if (!operatorList) {
  55910. warn('Type3 character \"' + glyph.operatorListId + '\" is not available');
  55911. continue;
  55912. }
  55913. this.processingType3 = glyph;
  55914. this.save();
  55915. ctx.scale(fontSize, fontSize);
  55916. ctx.transform.apply(ctx, fontMatrix);
  55917. this.executeOperatorList(operatorList);
  55918. this.restore();
  55919. var transformed = Util.applyTransform([
  55920. glyph.width,
  55921. 0
  55922. ], fontMatrix);
  55923. width = transformed[0] * fontSize + spacing;
  55924. ctx.translate(width, 0);
  55925. current.x += width * textHScale;
  55926. }
  55927. ctx.restore();
  55928. this.processingType3 = null;
  55929. },
  55930. setCharWidth: function CanvasGraphics_setCharWidth(xWidth, yWidth) {
  55931. },
  55932. setCharWidthAndBounds: function CanvasGraphics_setCharWidthAndBounds(xWidth, yWidth, llx, lly, urx, ury) {
  55933. this.ctx.rect(llx, lly, urx - llx, ury - lly);
  55934. this.clip();
  55935. this.endPath();
  55936. },
  55937. getColorN_Pattern: function CanvasGraphics_getColorN_Pattern(IR) {
  55938. var pattern;
  55939. if (IR[0] === 'TilingPattern') {
  55940. var color = IR[1];
  55941. var baseTransform = this.baseTransform || this.ctx.mozCurrentTransform.slice();
  55942. var self = this;
  55943. var canvasGraphicsFactory = {
  55944. createCanvasGraphics: function (ctx) {
  55945. return new CanvasGraphics(ctx, self.commonObjs, self.objs, self.canvasFactory);
  55946. }
  55947. };
  55948. pattern = new TilingPattern(IR, color, this.ctx, canvasGraphicsFactory, baseTransform);
  55949. } else {
  55950. pattern = getShadingPatternFromIR(IR);
  55951. }
  55952. return pattern;
  55953. },
  55954. setStrokeColorN: function CanvasGraphics_setStrokeColorN() {
  55955. this.current.strokeColor = this.getColorN_Pattern(arguments);
  55956. },
  55957. setFillColorN: function CanvasGraphics_setFillColorN() {
  55958. this.current.fillColor = this.getColorN_Pattern(arguments);
  55959. this.current.patternFill = true;
  55960. },
  55961. setStrokeRGBColor: function CanvasGraphics_setStrokeRGBColor(r, g, b) {
  55962. var color = Util.makeCssRgb(r, g, b);
  55963. this.ctx.strokeStyle = color;
  55964. this.current.strokeColor = color;
  55965. },
  55966. setFillRGBColor: function CanvasGraphics_setFillRGBColor(r, g, b) {
  55967. var color = Util.makeCssRgb(r, g, b);
  55968. this.ctx.fillStyle = color;
  55969. this.current.fillColor = color;
  55970. this.current.patternFill = false;
  55971. },
  55972. shadingFill: function CanvasGraphics_shadingFill(patternIR) {
  55973. var ctx = this.ctx;
  55974. this.save();
  55975. var pattern = getShadingPatternFromIR(patternIR);
  55976. ctx.fillStyle = pattern.getPattern(ctx, this, true);
  55977. var inv = ctx.mozCurrentTransformInverse;
  55978. if (inv) {
  55979. var canvas = ctx.canvas;
  55980. var width = canvas.width;
  55981. var height = canvas.height;
  55982. var bl = Util.applyTransform([
  55983. 0,
  55984. 0
  55985. ], inv);
  55986. var br = Util.applyTransform([
  55987. 0,
  55988. height
  55989. ], inv);
  55990. var ul = Util.applyTransform([
  55991. width,
  55992. 0
  55993. ], inv);
  55994. var ur = Util.applyTransform([
  55995. width,
  55996. height
  55997. ], inv);
  55998. var x0 = Math.min(bl[0], br[0], ul[0], ur[0]);
  55999. var y0 = Math.min(bl[1], br[1], ul[1], ur[1]);
  56000. var x1 = Math.max(bl[0], br[0], ul[0], ur[0]);
  56001. var y1 = Math.max(bl[1], br[1], ul[1], ur[1]);
  56002. this.ctx.fillRect(x0, y0, x1 - x0, y1 - y0);
  56003. } else {
  56004. this.ctx.fillRect(-1e10, -1e10, 2e10, 2e10);
  56005. }
  56006. this.restore();
  56007. },
  56008. beginInlineImage: function CanvasGraphics_beginInlineImage() {
  56009. error('Should not call beginInlineImage');
  56010. },
  56011. beginImageData: function CanvasGraphics_beginImageData() {
  56012. error('Should not call beginImageData');
  56013. },
  56014. paintFormXObjectBegin: function CanvasGraphics_paintFormXObjectBegin(matrix, bbox) {
  56015. this.save();
  56016. this.baseTransformStack.push(this.baseTransform);
  56017. if (isArray(matrix) && matrix.length === 6) {
  56018. this.transform.apply(this, matrix);
  56019. }
  56020. this.baseTransform = this.ctx.mozCurrentTransform;
  56021. if (isArray(bbox) && bbox.length === 4) {
  56022. var width = bbox[2] - bbox[0];
  56023. var height = bbox[3] - bbox[1];
  56024. this.ctx.rect(bbox[0], bbox[1], width, height);
  56025. this.clip();
  56026. this.endPath();
  56027. }
  56028. },
  56029. paintFormXObjectEnd: function CanvasGraphics_paintFormXObjectEnd() {
  56030. this.restore();
  56031. this.baseTransform = this.baseTransformStack.pop();
  56032. },
  56033. beginGroup: function CanvasGraphics_beginGroup(group) {
  56034. this.save();
  56035. var currentCtx = this.ctx;
  56036. if (!group.isolated) {
  56037. info('TODO: Support non-isolated groups.');
  56038. }
  56039. if (group.knockout) {
  56040. warn('Knockout groups not supported.');
  56041. }
  56042. var currentTransform = currentCtx.mozCurrentTransform;
  56043. if (group.matrix) {
  56044. currentCtx.transform.apply(currentCtx, group.matrix);
  56045. }
  56046. assert(group.bbox, 'Bounding box is required.');
  56047. var bounds = Util.getAxialAlignedBoundingBox(group.bbox, currentCtx.mozCurrentTransform);
  56048. var canvasBounds = [
  56049. 0,
  56050. 0,
  56051. currentCtx.canvas.width,
  56052. currentCtx.canvas.height
  56053. ];
  56054. bounds = Util.intersect(bounds, canvasBounds) || [
  56055. 0,
  56056. 0,
  56057. 0,
  56058. 0
  56059. ];
  56060. var offsetX = Math.floor(bounds[0]);
  56061. var offsetY = Math.floor(bounds[1]);
  56062. var drawnWidth = Math.max(Math.ceil(bounds[2]) - offsetX, 1);
  56063. var drawnHeight = Math.max(Math.ceil(bounds[3]) - offsetY, 1);
  56064. var scaleX = 1, scaleY = 1;
  56065. if (drawnWidth > MAX_GROUP_SIZE) {
  56066. scaleX = drawnWidth / MAX_GROUP_SIZE;
  56067. drawnWidth = MAX_GROUP_SIZE;
  56068. }
  56069. if (drawnHeight > MAX_GROUP_SIZE) {
  56070. scaleY = drawnHeight / MAX_GROUP_SIZE;
  56071. drawnHeight = MAX_GROUP_SIZE;
  56072. }
  56073. var cacheId = 'groupAt' + this.groupLevel;
  56074. if (group.smask) {
  56075. cacheId += '_smask_' + this.smaskCounter++ % 2;
  56076. }
  56077. var scratchCanvas = this.cachedCanvases.getCanvas(cacheId, drawnWidth, drawnHeight, true);
  56078. var groupCtx = scratchCanvas.context;
  56079. groupCtx.scale(1 / scaleX, 1 / scaleY);
  56080. groupCtx.translate(-offsetX, -offsetY);
  56081. groupCtx.transform.apply(groupCtx, currentTransform);
  56082. if (group.smask) {
  56083. this.smaskStack.push({
  56084. canvas: scratchCanvas.canvas,
  56085. context: groupCtx,
  56086. offsetX: offsetX,
  56087. offsetY: offsetY,
  56088. scaleX: scaleX,
  56089. scaleY: scaleY,
  56090. subtype: group.smask.subtype,
  56091. backdrop: group.smask.backdrop,
  56092. transferMap: group.smask.transferMap || null,
  56093. startTransformInverse: null
  56094. });
  56095. } else {
  56096. currentCtx.setTransform(1, 0, 0, 1, 0, 0);
  56097. currentCtx.translate(offsetX, offsetY);
  56098. currentCtx.scale(scaleX, scaleY);
  56099. }
  56100. copyCtxState(currentCtx, groupCtx);
  56101. this.ctx = groupCtx;
  56102. this.setGState([
  56103. [
  56104. 'BM',
  56105. 'Normal'
  56106. ],
  56107. [
  56108. 'ca',
  56109. 1
  56110. ],
  56111. [
  56112. 'CA',
  56113. 1
  56114. ]
  56115. ]);
  56116. this.groupStack.push(currentCtx);
  56117. this.groupLevel++;
  56118. this.current.activeSMask = null;
  56119. },
  56120. endGroup: function CanvasGraphics_endGroup(group) {
  56121. this.groupLevel--;
  56122. var groupCtx = this.ctx;
  56123. this.ctx = this.groupStack.pop();
  56124. if (this.ctx.imageSmoothingEnabled !== undefined) {
  56125. this.ctx.imageSmoothingEnabled = false;
  56126. } else {
  56127. this.ctx.mozImageSmoothingEnabled = false;
  56128. }
  56129. if (group.smask) {
  56130. this.tempSMask = this.smaskStack.pop();
  56131. } else {
  56132. this.ctx.drawImage(groupCtx.canvas, 0, 0);
  56133. }
  56134. this.restore();
  56135. },
  56136. beginAnnotations: function CanvasGraphics_beginAnnotations() {
  56137. this.save();
  56138. this.current = new CanvasExtraState();
  56139. if (this.baseTransform) {
  56140. this.ctx.setTransform.apply(this.ctx, this.baseTransform);
  56141. }
  56142. },
  56143. endAnnotations: function CanvasGraphics_endAnnotations() {
  56144. this.restore();
  56145. },
  56146. beginAnnotation: function CanvasGraphics_beginAnnotation(rect, transform, matrix) {
  56147. this.save();
  56148. if (isArray(rect) && rect.length === 4) {
  56149. var width = rect[2] - rect[0];
  56150. var height = rect[3] - rect[1];
  56151. this.ctx.rect(rect[0], rect[1], width, height);
  56152. this.clip();
  56153. this.endPath();
  56154. }
  56155. this.transform.apply(this, transform);
  56156. this.transform.apply(this, matrix);
  56157. },
  56158. endAnnotation: function CanvasGraphics_endAnnotation() {
  56159. this.restore();
  56160. },
  56161. paintJpegXObject: function CanvasGraphics_paintJpegXObject(objId, w, h) {
  56162. var domImage = this.objs.get(objId);
  56163. if (!domImage) {
  56164. warn('Dependent image isn\'t ready yet');
  56165. return;
  56166. }
  56167. this.save();
  56168. var ctx = this.ctx;
  56169. ctx.scale(1 / w, -1 / h);
  56170. ctx.drawImage(domImage, 0, 0, domImage.width, domImage.height, 0, -h, w, h);
  56171. if (this.imageLayer) {
  56172. var currentTransform = ctx.mozCurrentTransformInverse;
  56173. var position = this.getCanvasPosition(0, 0);
  56174. this.imageLayer.appendImage({
  56175. objId: objId,
  56176. left: position[0],
  56177. top: position[1],
  56178. width: w / currentTransform[0],
  56179. height: h / currentTransform[3]
  56180. });
  56181. }
  56182. this.restore();
  56183. },
  56184. paintImageMaskXObject: function CanvasGraphics_paintImageMaskXObject(img) {
  56185. var ctx = this.ctx;
  56186. var width = img.width, height = img.height;
  56187. var fillColor = this.current.fillColor;
  56188. var isPatternFill = this.current.patternFill;
  56189. var glyph = this.processingType3;
  56190. if (COMPILE_TYPE3_GLYPHS && glyph && glyph.compiled === undefined) {
  56191. if (width <= MAX_SIZE_TO_COMPILE && height <= MAX_SIZE_TO_COMPILE) {
  56192. glyph.compiled = compileType3Glyph({
  56193. data: img.data,
  56194. width: width,
  56195. height: height
  56196. });
  56197. } else {
  56198. glyph.compiled = null;
  56199. }
  56200. }
  56201. if (glyph && glyph.compiled) {
  56202. glyph.compiled(ctx);
  56203. return;
  56204. }
  56205. var maskCanvas = this.cachedCanvases.getCanvas('maskCanvas', width, height);
  56206. var maskCtx = maskCanvas.context;
  56207. maskCtx.save();
  56208. putBinaryImageMask(maskCtx, img);
  56209. maskCtx.globalCompositeOperation = 'source-in';
  56210. maskCtx.fillStyle = isPatternFill ? fillColor.getPattern(maskCtx, this) : fillColor;
  56211. maskCtx.fillRect(0, 0, width, height);
  56212. maskCtx.restore();
  56213. this.paintInlineImageXObject(maskCanvas.canvas);
  56214. },
  56215. paintImageMaskXObjectRepeat: function CanvasGraphics_paintImageMaskXObjectRepeat(imgData, scaleX, scaleY, positions) {
  56216. var width = imgData.width;
  56217. var height = imgData.height;
  56218. var fillColor = this.current.fillColor;
  56219. var isPatternFill = this.current.patternFill;
  56220. var maskCanvas = this.cachedCanvases.getCanvas('maskCanvas', width, height);
  56221. var maskCtx = maskCanvas.context;
  56222. maskCtx.save();
  56223. putBinaryImageMask(maskCtx, imgData);
  56224. maskCtx.globalCompositeOperation = 'source-in';
  56225. maskCtx.fillStyle = isPatternFill ? fillColor.getPattern(maskCtx, this) : fillColor;
  56226. maskCtx.fillRect(0, 0, width, height);
  56227. maskCtx.restore();
  56228. var ctx = this.ctx;
  56229. for (var i = 0, ii = positions.length; i < ii; i += 2) {
  56230. ctx.save();
  56231. ctx.transform(scaleX, 0, 0, scaleY, positions[i], positions[i + 1]);
  56232. ctx.scale(1, -1);
  56233. ctx.drawImage(maskCanvas.canvas, 0, 0, width, height, 0, -1, 1, 1);
  56234. ctx.restore();
  56235. }
  56236. },
  56237. paintImageMaskXObjectGroup: function CanvasGraphics_paintImageMaskXObjectGroup(images) {
  56238. var ctx = this.ctx;
  56239. var fillColor = this.current.fillColor;
  56240. var isPatternFill = this.current.patternFill;
  56241. for (var i = 0, ii = images.length; i < ii; i++) {
  56242. var image = images[i];
  56243. var width = image.width, height = image.height;
  56244. var maskCanvas = this.cachedCanvases.getCanvas('maskCanvas', width, height);
  56245. var maskCtx = maskCanvas.context;
  56246. maskCtx.save();
  56247. putBinaryImageMask(maskCtx, image);
  56248. maskCtx.globalCompositeOperation = 'source-in';
  56249. maskCtx.fillStyle = isPatternFill ? fillColor.getPattern(maskCtx, this) : fillColor;
  56250. maskCtx.fillRect(0, 0, width, height);
  56251. maskCtx.restore();
  56252. ctx.save();
  56253. ctx.transform.apply(ctx, image.transform);
  56254. ctx.scale(1, -1);
  56255. ctx.drawImage(maskCanvas.canvas, 0, 0, width, height, 0, -1, 1, 1);
  56256. ctx.restore();
  56257. }
  56258. },
  56259. paintImageXObject: function CanvasGraphics_paintImageXObject(objId) {
  56260. var imgData = this.objs.get(objId);
  56261. if (!imgData) {
  56262. warn('Dependent image isn\'t ready yet');
  56263. return;
  56264. }
  56265. this.paintInlineImageXObject(imgData);
  56266. },
  56267. paintImageXObjectRepeat: function CanvasGraphics_paintImageXObjectRepeat(objId, scaleX, scaleY, positions) {
  56268. var imgData = this.objs.get(objId);
  56269. if (!imgData) {
  56270. warn('Dependent image isn\'t ready yet');
  56271. return;
  56272. }
  56273. var width = imgData.width;
  56274. var height = imgData.height;
  56275. var map = [];
  56276. for (var i = 0, ii = positions.length; i < ii; i += 2) {
  56277. map.push({
  56278. transform: [
  56279. scaleX,
  56280. 0,
  56281. 0,
  56282. scaleY,
  56283. positions[i],
  56284. positions[i + 1]
  56285. ],
  56286. x: 0,
  56287. y: 0,
  56288. w: width,
  56289. h: height
  56290. });
  56291. }
  56292. this.paintInlineImageXObjectGroup(imgData, map);
  56293. },
  56294. paintInlineImageXObject: function CanvasGraphics_paintInlineImageXObject(imgData) {
  56295. var width = imgData.width;
  56296. var height = imgData.height;
  56297. var ctx = this.ctx;
  56298. this.save();
  56299. ctx.scale(1 / width, -1 / height);
  56300. var currentTransform = ctx.mozCurrentTransformInverse;
  56301. var a = currentTransform[0], b = currentTransform[1];
  56302. var widthScale = Math.max(Math.sqrt(a * a + b * b), 1);
  56303. var c = currentTransform[2], d = currentTransform[3];
  56304. var heightScale = Math.max(Math.sqrt(c * c + d * d), 1);
  56305. var imgToPaint, tmpCanvas;
  56306. if (imgData instanceof HTMLElement || !imgData.data) {
  56307. imgToPaint = imgData;
  56308. } else {
  56309. tmpCanvas = this.cachedCanvases.getCanvas('inlineImage', width, height);
  56310. var tmpCtx = tmpCanvas.context;
  56311. putBinaryImageData(tmpCtx, imgData);
  56312. imgToPaint = tmpCanvas.canvas;
  56313. }
  56314. var paintWidth = width, paintHeight = height;
  56315. var tmpCanvasId = 'prescale1';
  56316. while (widthScale > 2 && paintWidth > 1 || heightScale > 2 && paintHeight > 1) {
  56317. var newWidth = paintWidth, newHeight = paintHeight;
  56318. if (widthScale > 2 && paintWidth > 1) {
  56319. newWidth = Math.ceil(paintWidth / 2);
  56320. widthScale /= paintWidth / newWidth;
  56321. }
  56322. if (heightScale > 2 && paintHeight > 1) {
  56323. newHeight = Math.ceil(paintHeight / 2);
  56324. heightScale /= paintHeight / newHeight;
  56325. }
  56326. tmpCanvas = this.cachedCanvases.getCanvas(tmpCanvasId, newWidth, newHeight);
  56327. tmpCtx = tmpCanvas.context;
  56328. tmpCtx.clearRect(0, 0, newWidth, newHeight);
  56329. tmpCtx.drawImage(imgToPaint, 0, 0, paintWidth, paintHeight, 0, 0, newWidth, newHeight);
  56330. imgToPaint = tmpCanvas.canvas;
  56331. paintWidth = newWidth;
  56332. paintHeight = newHeight;
  56333. tmpCanvasId = tmpCanvasId === 'prescale1' ? 'prescale2' : 'prescale1';
  56334. }
  56335. ctx.drawImage(imgToPaint, 0, 0, paintWidth, paintHeight, 0, -height, width, height);
  56336. if (this.imageLayer) {
  56337. var position = this.getCanvasPosition(0, -height);
  56338. this.imageLayer.appendImage({
  56339. imgData: imgData,
  56340. left: position[0],
  56341. top: position[1],
  56342. width: width / currentTransform[0],
  56343. height: height / currentTransform[3]
  56344. });
  56345. }
  56346. this.restore();
  56347. },
  56348. paintInlineImageXObjectGroup: function CanvasGraphics_paintInlineImageXObjectGroup(imgData, map) {
  56349. var ctx = this.ctx;
  56350. var w = imgData.width;
  56351. var h = imgData.height;
  56352. var tmpCanvas = this.cachedCanvases.getCanvas('inlineImage', w, h);
  56353. var tmpCtx = tmpCanvas.context;
  56354. putBinaryImageData(tmpCtx, imgData);
  56355. for (var i = 0, ii = map.length; i < ii; i++) {
  56356. var entry = map[i];
  56357. ctx.save();
  56358. ctx.transform.apply(ctx, entry.transform);
  56359. ctx.scale(1, -1);
  56360. ctx.drawImage(tmpCanvas.canvas, entry.x, entry.y, entry.w, entry.h, 0, -1, 1, 1);
  56361. if (this.imageLayer) {
  56362. var position = this.getCanvasPosition(entry.x, entry.y);
  56363. this.imageLayer.appendImage({
  56364. imgData: imgData,
  56365. left: position[0],
  56366. top: position[1],
  56367. width: w,
  56368. height: h
  56369. });
  56370. }
  56371. ctx.restore();
  56372. }
  56373. },
  56374. paintSolidColorImageMask: function CanvasGraphics_paintSolidColorImageMask() {
  56375. this.ctx.fillRect(0, 0, 1, 1);
  56376. },
  56377. paintXObject: function CanvasGraphics_paintXObject() {
  56378. warn('Unsupported \'paintXObject\' command.');
  56379. },
  56380. markPoint: function CanvasGraphics_markPoint(tag) {
  56381. },
  56382. markPointProps: function CanvasGraphics_markPointProps(tag, properties) {
  56383. },
  56384. beginMarkedContent: function CanvasGraphics_beginMarkedContent(tag) {
  56385. },
  56386. beginMarkedContentProps: function CanvasGraphics_beginMarkedContentProps(tag, properties) {
  56387. },
  56388. endMarkedContent: function CanvasGraphics_endMarkedContent() {
  56389. },
  56390. beginCompat: function CanvasGraphics_beginCompat() {
  56391. },
  56392. endCompat: function CanvasGraphics_endCompat() {
  56393. },
  56394. consumePath: function CanvasGraphics_consumePath() {
  56395. var ctx = this.ctx;
  56396. if (this.pendingClip) {
  56397. if (this.pendingClip === EO_CLIP) {
  56398. ctx.clip('evenodd');
  56399. } else {
  56400. ctx.clip();
  56401. }
  56402. this.pendingClip = null;
  56403. }
  56404. ctx.beginPath();
  56405. },
  56406. getSinglePixelWidth: function CanvasGraphics_getSinglePixelWidth(scale) {
  56407. if (this.cachedGetSinglePixelWidth === null) {
  56408. this.ctx.save();
  56409. var inverse = this.ctx.mozCurrentTransformInverse;
  56410. this.ctx.restore();
  56411. this.cachedGetSinglePixelWidth = Math.sqrt(Math.max(inverse[0] * inverse[0] + inverse[1] * inverse[1], inverse[2] * inverse[2] + inverse[3] * inverse[3]));
  56412. }
  56413. return this.cachedGetSinglePixelWidth;
  56414. },
  56415. getCanvasPosition: function CanvasGraphics_getCanvasPosition(x, y) {
  56416. var transform = this.ctx.mozCurrentTransform;
  56417. return [
  56418. transform[0] * x + transform[2] * y + transform[4],
  56419. transform[1] * x + transform[3] * y + transform[5]
  56420. ];
  56421. }
  56422. };
  56423. for (var op in OPS) {
  56424. CanvasGraphics.prototype[OPS[op]] = CanvasGraphics.prototype[op];
  56425. }
  56426. return CanvasGraphics;
  56427. }();
  56428. exports.CanvasGraphics = CanvasGraphics;
  56429. /***/ }),
  56430. /* 45 */
  56431. /***/ (function(module, exports, __w_pdfjs_require__) {
  56432. "use strict";
  56433. var sharedUtil = __w_pdfjs_require__(0);
  56434. var assert = sharedUtil.assert;
  56435. var bytesToString = sharedUtil.bytesToString;
  56436. var string32 = sharedUtil.string32;
  56437. var shadow = sharedUtil.shadow;
  56438. var warn = sharedUtil.warn;
  56439. function FontLoader(docId) {
  56440. this.docId = docId;
  56441. this.styleElement = null;
  56442. this.nativeFontFaces = [];
  56443. this.loadTestFontId = 0;
  56444. this.loadingContext = {
  56445. requests: [],
  56446. nextRequestId: 0
  56447. };
  56448. }
  56449. FontLoader.prototype = {
  56450. insertRule: function fontLoaderInsertRule(rule) {
  56451. var styleElement = this.styleElement;
  56452. if (!styleElement) {
  56453. styleElement = this.styleElement = document.createElement('style');
  56454. styleElement.id = 'PDFJS_FONT_STYLE_TAG_' + this.docId;
  56455. document.documentElement.getElementsByTagName('head')[0].appendChild(styleElement);
  56456. }
  56457. var styleSheet = styleElement.sheet;
  56458. styleSheet.insertRule(rule, styleSheet.cssRules.length);
  56459. },
  56460. clear: function fontLoaderClear() {
  56461. if (this.styleElement) {
  56462. this.styleElement.remove();
  56463. this.styleElement = null;
  56464. }
  56465. this.nativeFontFaces.forEach(function (nativeFontFace) {
  56466. document.fonts.delete(nativeFontFace);
  56467. });
  56468. this.nativeFontFaces.length = 0;
  56469. }
  56470. };
  56471. var getLoadTestFont = function () {
  56472. 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==');
  56473. };
  56474. Object.defineProperty(FontLoader.prototype, 'loadTestFont', {
  56475. get: function () {
  56476. return shadow(this, 'loadTestFont', getLoadTestFont());
  56477. },
  56478. configurable: true
  56479. });
  56480. FontLoader.prototype.addNativeFontFace = function fontLoader_addNativeFontFace(nativeFontFace) {
  56481. this.nativeFontFaces.push(nativeFontFace);
  56482. document.fonts.add(nativeFontFace);
  56483. };
  56484. FontLoader.prototype.bind = function fontLoaderBind(fonts, callback) {
  56485. var rules = [];
  56486. var fontsToLoad = [];
  56487. var fontLoadPromises = [];
  56488. var getNativeFontPromise = function (nativeFontFace) {
  56489. return nativeFontFace.loaded.catch(function (e) {
  56490. warn('Failed to load font "' + nativeFontFace.family + '": ' + e);
  56491. });
  56492. };
  56493. var isFontLoadingAPISupported = FontLoader.isFontLoadingAPISupported && !FontLoader.isSyncFontLoadingSupported;
  56494. for (var i = 0, ii = fonts.length; i < ii; i++) {
  56495. var font = fonts[i];
  56496. if (font.attached || font.loading === false) {
  56497. continue;
  56498. }
  56499. font.attached = true;
  56500. if (isFontLoadingAPISupported) {
  56501. var nativeFontFace = font.createNativeFontFace();
  56502. if (nativeFontFace) {
  56503. this.addNativeFontFace(nativeFontFace);
  56504. fontLoadPromises.push(getNativeFontPromise(nativeFontFace));
  56505. }
  56506. } else {
  56507. var rule = font.createFontFaceRule();
  56508. if (rule) {
  56509. this.insertRule(rule);
  56510. rules.push(rule);
  56511. fontsToLoad.push(font);
  56512. }
  56513. }
  56514. }
  56515. var request = this.queueLoadingCallback(callback);
  56516. if (isFontLoadingAPISupported) {
  56517. Promise.all(fontLoadPromises).then(function () {
  56518. request.complete();
  56519. });
  56520. } else if (rules.length > 0 && !FontLoader.isSyncFontLoadingSupported) {
  56521. this.prepareFontLoadEvent(rules, fontsToLoad, request);
  56522. } else {
  56523. request.complete();
  56524. }
  56525. };
  56526. FontLoader.prototype.queueLoadingCallback = function FontLoader_queueLoadingCallback(callback) {
  56527. function LoadLoader_completeRequest() {
  56528. assert(!request.end, 'completeRequest() cannot be called twice');
  56529. request.end = Date.now();
  56530. while (context.requests.length > 0 && context.requests[0].end) {
  56531. var otherRequest = context.requests.shift();
  56532. setTimeout(otherRequest.callback, 0);
  56533. }
  56534. }
  56535. var context = this.loadingContext;
  56536. var requestId = 'pdfjs-font-loading-' + context.nextRequestId++;
  56537. var request = {
  56538. id: requestId,
  56539. complete: LoadLoader_completeRequest,
  56540. callback: callback,
  56541. started: Date.now()
  56542. };
  56543. context.requests.push(request);
  56544. return request;
  56545. };
  56546. FontLoader.prototype.prepareFontLoadEvent = function fontLoaderPrepareFontLoadEvent(rules, fonts, request) {
  56547. function int32(data, offset) {
  56548. return data.charCodeAt(offset) << 24 | data.charCodeAt(offset + 1) << 16 | data.charCodeAt(offset + 2) << 8 | data.charCodeAt(offset + 3) & 0xff;
  56549. }
  56550. function spliceString(s, offset, remove, insert) {
  56551. var chunk1 = s.substr(0, offset);
  56552. var chunk2 = s.substr(offset + remove);
  56553. return chunk1 + insert + chunk2;
  56554. }
  56555. var i, ii;
  56556. var canvas = document.createElement('canvas');
  56557. canvas.width = 1;
  56558. canvas.height = 1;
  56559. var ctx = canvas.getContext('2d');
  56560. var called = 0;
  56561. function isFontReady(name, callback) {
  56562. called++;
  56563. if (called > 30) {
  56564. warn('Load test font never loaded.');
  56565. callback();
  56566. return;
  56567. }
  56568. ctx.font = '30px ' + name;
  56569. ctx.fillText('.', 0, 20);
  56570. var imageData = ctx.getImageData(0, 0, 1, 1);
  56571. if (imageData.data[3] > 0) {
  56572. callback();
  56573. return;
  56574. }
  56575. setTimeout(isFontReady.bind(null, name, callback));
  56576. }
  56577. var loadTestFontId = 'lt' + Date.now() + this.loadTestFontId++;
  56578. var data = this.loadTestFont;
  56579. var COMMENT_OFFSET = 976;
  56580. data = spliceString(data, COMMENT_OFFSET, loadTestFontId.length, loadTestFontId);
  56581. var CFF_CHECKSUM_OFFSET = 16;
  56582. var XXXX_VALUE = 0x58585858;
  56583. var checksum = int32(data, CFF_CHECKSUM_OFFSET);
  56584. for (i = 0, ii = loadTestFontId.length - 3; i < ii; i += 4) {
  56585. checksum = checksum - XXXX_VALUE + int32(loadTestFontId, i) | 0;
  56586. }
  56587. if (i < loadTestFontId.length) {
  56588. checksum = checksum - XXXX_VALUE + int32(loadTestFontId + 'XXX', i) | 0;
  56589. }
  56590. data = spliceString(data, CFF_CHECKSUM_OFFSET, 4, string32(checksum));
  56591. var url = 'url(data:font/opentype;base64,' + btoa(data) + ');';
  56592. var rule = '@font-face { font-family:"' + loadTestFontId + '";src:' + url + '}';
  56593. this.insertRule(rule);
  56594. var names = [];
  56595. for (i = 0, ii = fonts.length; i < ii; i++) {
  56596. names.push(fonts[i].loadedName);
  56597. }
  56598. names.push(loadTestFontId);
  56599. var div = document.createElement('div');
  56600. div.setAttribute('style', 'visibility: hidden;' + 'width: 10px; height: 10px;' + 'position: absolute; top: 0px; left: 0px;');
  56601. for (i = 0, ii = names.length; i < ii; ++i) {
  56602. var span = document.createElement('span');
  56603. span.textContent = 'Hi';
  56604. span.style.fontFamily = names[i];
  56605. div.appendChild(span);
  56606. }
  56607. document.body.appendChild(div);
  56608. isFontReady(loadTestFontId, function () {
  56609. document.body.removeChild(div);
  56610. request.complete();
  56611. });
  56612. };
  56613. FontLoader.isFontLoadingAPISupported = typeof document !== 'undefined' && !!document.fonts;
  56614. var isSyncFontLoadingSupported = function isSyncFontLoadingSupported() {
  56615. if (typeof navigator === 'undefined') {
  56616. return true;
  56617. }
  56618. var supported = false;
  56619. var m = /Mozilla\/5.0.*?rv:(\d+).*? Gecko/.exec(navigator.userAgent);
  56620. if (m && m[1] >= 14) {
  56621. supported = true;
  56622. }
  56623. return supported;
  56624. };
  56625. Object.defineProperty(FontLoader, 'isSyncFontLoadingSupported', {
  56626. get: function () {
  56627. return shadow(FontLoader, 'isSyncFontLoadingSupported', isSyncFontLoadingSupported());
  56628. },
  56629. enumerable: true,
  56630. configurable: true
  56631. });
  56632. var IsEvalSupportedCached = {
  56633. get value() {
  56634. return shadow(this, 'value', sharedUtil.isEvalSupported());
  56635. }
  56636. };
  56637. var FontFaceObject = function FontFaceObjectClosure() {
  56638. function FontFaceObject(translatedData, options) {
  56639. this.compiledGlyphs = Object.create(null);
  56640. for (var i in translatedData) {
  56641. this[i] = translatedData[i];
  56642. }
  56643. this.options = options;
  56644. }
  56645. FontFaceObject.prototype = {
  56646. createNativeFontFace: function FontFaceObject_createNativeFontFace() {
  56647. if (!this.data) {
  56648. return null;
  56649. }
  56650. if (this.options.disableFontFace) {
  56651. this.disableFontFace = true;
  56652. return null;
  56653. }
  56654. var nativeFontFace = new FontFace(this.loadedName, this.data, {});
  56655. if (this.options.fontRegistry) {
  56656. this.options.fontRegistry.registerFont(this);
  56657. }
  56658. return nativeFontFace;
  56659. },
  56660. createFontFaceRule: function FontFaceObject_createFontFaceRule() {
  56661. if (!this.data) {
  56662. return null;
  56663. }
  56664. if (this.options.disableFontFace) {
  56665. this.disableFontFace = true;
  56666. return null;
  56667. }
  56668. var data = bytesToString(new Uint8Array(this.data));
  56669. var fontName = this.loadedName;
  56670. var url = 'url(data:' + this.mimetype + ';base64,' + btoa(data) + ');';
  56671. var rule = '@font-face { font-family:"' + fontName + '";src:' + url + '}';
  56672. if (this.options.fontRegistry) {
  56673. this.options.fontRegistry.registerFont(this, url);
  56674. }
  56675. return rule;
  56676. },
  56677. getPathGenerator: function FontFaceObject_getPathGenerator(objs, character) {
  56678. if (!(character in this.compiledGlyphs)) {
  56679. var cmds = objs.get(this.loadedName + '_path_' + character);
  56680. var current, i, len;
  56681. if (this.options.isEvalSupported && IsEvalSupportedCached.value) {
  56682. var args, js = '';
  56683. for (i = 0, len = cmds.length; i < len; i++) {
  56684. current = cmds[i];
  56685. if (current.args !== undefined) {
  56686. args = current.args.join(',');
  56687. } else {
  56688. args = '';
  56689. }
  56690. js += 'c.' + current.cmd + '(' + args + ');\n';
  56691. }
  56692. this.compiledGlyphs[character] = new Function('c', 'size', js);
  56693. } else {
  56694. this.compiledGlyphs[character] = function (c, size) {
  56695. for (i = 0, len = cmds.length; i < len; i++) {
  56696. current = cmds[i];
  56697. if (current.cmd === 'scale') {
  56698. current.args = [
  56699. size,
  56700. -size
  56701. ];
  56702. }
  56703. c[current.cmd].apply(c, current.args);
  56704. }
  56705. };
  56706. }
  56707. }
  56708. return this.compiledGlyphs[character];
  56709. }
  56710. };
  56711. return FontFaceObject;
  56712. }();
  56713. exports.FontFaceObject = FontFaceObject;
  56714. exports.FontLoader = FontLoader;
  56715. /***/ }),
  56716. /* 46 */
  56717. /***/ (function(module, exports, __w_pdfjs_require__) {
  56718. "use strict";
  56719. var sharedUtil = __w_pdfjs_require__(0);
  56720. var displayWebGL = __w_pdfjs_require__(24);
  56721. var Util = sharedUtil.Util;
  56722. var info = sharedUtil.info;
  56723. var isArray = sharedUtil.isArray;
  56724. var error = sharedUtil.error;
  56725. var WebGLUtils = displayWebGL.WebGLUtils;
  56726. var ShadingIRs = {};
  56727. ShadingIRs.RadialAxial = {
  56728. fromIR: function RadialAxial_fromIR(raw) {
  56729. var type = raw[1];
  56730. var colorStops = raw[2];
  56731. var p0 = raw[3];
  56732. var p1 = raw[4];
  56733. var r0 = raw[5];
  56734. var r1 = raw[6];
  56735. return {
  56736. type: 'Pattern',
  56737. getPattern: function RadialAxial_getPattern(ctx) {
  56738. var grad;
  56739. if (type === 'axial') {
  56740. grad = ctx.createLinearGradient(p0[0], p0[1], p1[0], p1[1]);
  56741. } else if (type === 'radial') {
  56742. grad = ctx.createRadialGradient(p0[0], p0[1], r0, p1[0], p1[1], r1);
  56743. }
  56744. for (var i = 0, ii = colorStops.length; i < ii; ++i) {
  56745. var c = colorStops[i];
  56746. grad.addColorStop(c[0], c[1]);
  56747. }
  56748. return grad;
  56749. }
  56750. };
  56751. }
  56752. };
  56753. var createMeshCanvas = function createMeshCanvasClosure() {
  56754. function drawTriangle(data, context, p1, p2, p3, c1, c2, c3) {
  56755. var coords = context.coords, colors = context.colors;
  56756. var bytes = data.data, rowSize = data.width * 4;
  56757. var tmp;
  56758. if (coords[p1 + 1] > coords[p2 + 1]) {
  56759. tmp = p1;
  56760. p1 = p2;
  56761. p2 = tmp;
  56762. tmp = c1;
  56763. c1 = c2;
  56764. c2 = tmp;
  56765. }
  56766. if (coords[p2 + 1] > coords[p3 + 1]) {
  56767. tmp = p2;
  56768. p2 = p3;
  56769. p3 = tmp;
  56770. tmp = c2;
  56771. c2 = c3;
  56772. c3 = tmp;
  56773. }
  56774. if (coords[p1 + 1] > coords[p2 + 1]) {
  56775. tmp = p1;
  56776. p1 = p2;
  56777. p2 = tmp;
  56778. tmp = c1;
  56779. c1 = c2;
  56780. c2 = tmp;
  56781. }
  56782. var x1 = (coords[p1] + context.offsetX) * context.scaleX;
  56783. var y1 = (coords[p1 + 1] + context.offsetY) * context.scaleY;
  56784. var x2 = (coords[p2] + context.offsetX) * context.scaleX;
  56785. var y2 = (coords[p2 + 1] + context.offsetY) * context.scaleY;
  56786. var x3 = (coords[p3] + context.offsetX) * context.scaleX;
  56787. var y3 = (coords[p3 + 1] + context.offsetY) * context.scaleY;
  56788. if (y1 >= y3) {
  56789. return;
  56790. }
  56791. var c1r = colors[c1], c1g = colors[c1 + 1], c1b = colors[c1 + 2];
  56792. var c2r = colors[c2], c2g = colors[c2 + 1], c2b = colors[c2 + 2];
  56793. var c3r = colors[c3], c3g = colors[c3 + 1], c3b = colors[c3 + 2];
  56794. var minY = Math.round(y1), maxY = Math.round(y3);
  56795. var xa, car, cag, cab;
  56796. var xb, cbr, cbg, cbb;
  56797. var k;
  56798. for (var y = minY; y <= maxY; y++) {
  56799. if (y < y2) {
  56800. k = y < y1 ? 0 : y1 === y2 ? 1 : (y1 - y) / (y1 - y2);
  56801. xa = x1 - (x1 - x2) * k;
  56802. car = c1r - (c1r - c2r) * k;
  56803. cag = c1g - (c1g - c2g) * k;
  56804. cab = c1b - (c1b - c2b) * k;
  56805. } else {
  56806. k = y > y3 ? 1 : y2 === y3 ? 0 : (y2 - y) / (y2 - y3);
  56807. xa = x2 - (x2 - x3) * k;
  56808. car = c2r - (c2r - c3r) * k;
  56809. cag = c2g - (c2g - c3g) * k;
  56810. cab = c2b - (c2b - c3b) * k;
  56811. }
  56812. k = y < y1 ? 0 : y > y3 ? 1 : (y1 - y) / (y1 - y3);
  56813. xb = x1 - (x1 - x3) * k;
  56814. cbr = c1r - (c1r - c3r) * k;
  56815. cbg = c1g - (c1g - c3g) * k;
  56816. cbb = c1b - (c1b - c3b) * k;
  56817. var x1_ = Math.round(Math.min(xa, xb));
  56818. var x2_ = Math.round(Math.max(xa, xb));
  56819. var j = rowSize * y + x1_ * 4;
  56820. for (var x = x1_; x <= x2_; x++) {
  56821. k = (xa - x) / (xa - xb);
  56822. k = k < 0 ? 0 : k > 1 ? 1 : k;
  56823. bytes[j++] = car - (car - cbr) * k | 0;
  56824. bytes[j++] = cag - (cag - cbg) * k | 0;
  56825. bytes[j++] = cab - (cab - cbb) * k | 0;
  56826. bytes[j++] = 255;
  56827. }
  56828. }
  56829. }
  56830. function drawFigure(data, figure, context) {
  56831. var ps = figure.coords;
  56832. var cs = figure.colors;
  56833. var i, ii;
  56834. switch (figure.type) {
  56835. case 'lattice':
  56836. var verticesPerRow = figure.verticesPerRow;
  56837. var rows = Math.floor(ps.length / verticesPerRow) - 1;
  56838. var cols = verticesPerRow - 1;
  56839. for (i = 0; i < rows; i++) {
  56840. var q = i * verticesPerRow;
  56841. for (var j = 0; j < cols; j++, q++) {
  56842. drawTriangle(data, context, ps[q], ps[q + 1], ps[q + verticesPerRow], cs[q], cs[q + 1], cs[q + verticesPerRow]);
  56843. drawTriangle(data, context, ps[q + verticesPerRow + 1], ps[q + 1], ps[q + verticesPerRow], cs[q + verticesPerRow + 1], cs[q + 1], cs[q + verticesPerRow]);
  56844. }
  56845. }
  56846. break;
  56847. case 'triangles':
  56848. for (i = 0, ii = ps.length; i < ii; i += 3) {
  56849. drawTriangle(data, context, ps[i], ps[i + 1], ps[i + 2], cs[i], cs[i + 1], cs[i + 2]);
  56850. }
  56851. break;
  56852. default:
  56853. error('illigal figure');
  56854. break;
  56855. }
  56856. }
  56857. function createMeshCanvas(bounds, combinesScale, coords, colors, figures, backgroundColor, cachedCanvases) {
  56858. var EXPECTED_SCALE = 1.1;
  56859. var MAX_PATTERN_SIZE = 3000;
  56860. var BORDER_SIZE = 2;
  56861. var offsetX = Math.floor(bounds[0]);
  56862. var offsetY = Math.floor(bounds[1]);
  56863. var boundsWidth = Math.ceil(bounds[2]) - offsetX;
  56864. var boundsHeight = Math.ceil(bounds[3]) - offsetY;
  56865. var width = Math.min(Math.ceil(Math.abs(boundsWidth * combinesScale[0] * EXPECTED_SCALE)), MAX_PATTERN_SIZE);
  56866. var height = Math.min(Math.ceil(Math.abs(boundsHeight * combinesScale[1] * EXPECTED_SCALE)), MAX_PATTERN_SIZE);
  56867. var scaleX = boundsWidth / width;
  56868. var scaleY = boundsHeight / height;
  56869. var context = {
  56870. coords: coords,
  56871. colors: colors,
  56872. offsetX: -offsetX,
  56873. offsetY: -offsetY,
  56874. scaleX: 1 / scaleX,
  56875. scaleY: 1 / scaleY
  56876. };
  56877. var paddedWidth = width + BORDER_SIZE * 2;
  56878. var paddedHeight = height + BORDER_SIZE * 2;
  56879. var canvas, tmpCanvas, i, ii;
  56880. if (WebGLUtils.isEnabled) {
  56881. canvas = WebGLUtils.drawFigures(width, height, backgroundColor, figures, context);
  56882. tmpCanvas = cachedCanvases.getCanvas('mesh', paddedWidth, paddedHeight, false);
  56883. tmpCanvas.context.drawImage(canvas, BORDER_SIZE, BORDER_SIZE);
  56884. canvas = tmpCanvas.canvas;
  56885. } else {
  56886. tmpCanvas = cachedCanvases.getCanvas('mesh', paddedWidth, paddedHeight, false);
  56887. var tmpCtx = tmpCanvas.context;
  56888. var data = tmpCtx.createImageData(width, height);
  56889. if (backgroundColor) {
  56890. var bytes = data.data;
  56891. for (i = 0, ii = bytes.length; i < ii; i += 4) {
  56892. bytes[i] = backgroundColor[0];
  56893. bytes[i + 1] = backgroundColor[1];
  56894. bytes[i + 2] = backgroundColor[2];
  56895. bytes[i + 3] = 255;
  56896. }
  56897. }
  56898. for (i = 0; i < figures.length; i++) {
  56899. drawFigure(data, figures[i], context);
  56900. }
  56901. tmpCtx.putImageData(data, BORDER_SIZE, BORDER_SIZE);
  56902. canvas = tmpCanvas.canvas;
  56903. }
  56904. return {
  56905. canvas: canvas,
  56906. offsetX: offsetX - BORDER_SIZE * scaleX,
  56907. offsetY: offsetY - BORDER_SIZE * scaleY,
  56908. scaleX: scaleX,
  56909. scaleY: scaleY
  56910. };
  56911. }
  56912. return createMeshCanvas;
  56913. }();
  56914. ShadingIRs.Mesh = {
  56915. fromIR: function Mesh_fromIR(raw) {
  56916. var coords = raw[2];
  56917. var colors = raw[3];
  56918. var figures = raw[4];
  56919. var bounds = raw[5];
  56920. var matrix = raw[6];
  56921. var background = raw[8];
  56922. return {
  56923. type: 'Pattern',
  56924. getPattern: function Mesh_getPattern(ctx, owner, shadingFill) {
  56925. var scale;
  56926. if (shadingFill) {
  56927. scale = Util.singularValueDecompose2dScale(ctx.mozCurrentTransform);
  56928. } else {
  56929. scale = Util.singularValueDecompose2dScale(owner.baseTransform);
  56930. if (matrix) {
  56931. var matrixScale = Util.singularValueDecompose2dScale(matrix);
  56932. scale = [
  56933. scale[0] * matrixScale[0],
  56934. scale[1] * matrixScale[1]
  56935. ];
  56936. }
  56937. }
  56938. var temporaryPatternCanvas = createMeshCanvas(bounds, scale, coords, colors, figures, shadingFill ? null : background, owner.cachedCanvases);
  56939. if (!shadingFill) {
  56940. ctx.setTransform.apply(ctx, owner.baseTransform);
  56941. if (matrix) {
  56942. ctx.transform.apply(ctx, matrix);
  56943. }
  56944. }
  56945. ctx.translate(temporaryPatternCanvas.offsetX, temporaryPatternCanvas.offsetY);
  56946. ctx.scale(temporaryPatternCanvas.scaleX, temporaryPatternCanvas.scaleY);
  56947. return ctx.createPattern(temporaryPatternCanvas.canvas, 'no-repeat');
  56948. }
  56949. };
  56950. }
  56951. };
  56952. ShadingIRs.Dummy = {
  56953. fromIR: function Dummy_fromIR() {
  56954. return {
  56955. type: 'Pattern',
  56956. getPattern: function Dummy_fromIR_getPattern() {
  56957. return 'hotpink';
  56958. }
  56959. };
  56960. }
  56961. };
  56962. function getShadingPatternFromIR(raw) {
  56963. var shadingIR = ShadingIRs[raw[0]];
  56964. if (!shadingIR) {
  56965. error('Unknown IR type: ' + raw[0]);
  56966. }
  56967. return shadingIR.fromIR(raw);
  56968. }
  56969. var TilingPattern = function TilingPatternClosure() {
  56970. var PaintType = {
  56971. COLORED: 1,
  56972. UNCOLORED: 2
  56973. };
  56974. var MAX_PATTERN_SIZE = 3000;
  56975. function TilingPattern(IR, color, ctx, canvasGraphicsFactory, baseTransform) {
  56976. this.operatorList = IR[2];
  56977. this.matrix = IR[3] || [
  56978. 1,
  56979. 0,
  56980. 0,
  56981. 1,
  56982. 0,
  56983. 0
  56984. ];
  56985. this.bbox = IR[4];
  56986. this.xstep = IR[5];
  56987. this.ystep = IR[6];
  56988. this.paintType = IR[7];
  56989. this.tilingType = IR[8];
  56990. this.color = color;
  56991. this.canvasGraphicsFactory = canvasGraphicsFactory;
  56992. this.baseTransform = baseTransform;
  56993. this.type = 'Pattern';
  56994. this.ctx = ctx;
  56995. }
  56996. TilingPattern.prototype = {
  56997. createPatternCanvas: function TilinPattern_createPatternCanvas(owner) {
  56998. var operatorList = this.operatorList;
  56999. var bbox = this.bbox;
  57000. var xstep = this.xstep;
  57001. var ystep = this.ystep;
  57002. var paintType = this.paintType;
  57003. var tilingType = this.tilingType;
  57004. var color = this.color;
  57005. var canvasGraphicsFactory = this.canvasGraphicsFactory;
  57006. info('TilingType: ' + tilingType);
  57007. var x0 = bbox[0], y0 = bbox[1], x1 = bbox[2], y1 = bbox[3];
  57008. var topLeft = [
  57009. x0,
  57010. y0
  57011. ];
  57012. var botRight = [
  57013. x0 + xstep,
  57014. y0 + ystep
  57015. ];
  57016. var width = botRight[0] - topLeft[0];
  57017. var height = botRight[1] - topLeft[1];
  57018. var matrixScale = Util.singularValueDecompose2dScale(this.matrix);
  57019. var curMatrixScale = Util.singularValueDecompose2dScale(this.baseTransform);
  57020. var combinedScale = [
  57021. matrixScale[0] * curMatrixScale[0],
  57022. matrixScale[1] * curMatrixScale[1]
  57023. ];
  57024. width = Math.min(Math.ceil(Math.abs(width * combinedScale[0])), MAX_PATTERN_SIZE);
  57025. height = Math.min(Math.ceil(Math.abs(height * combinedScale[1])), MAX_PATTERN_SIZE);
  57026. var tmpCanvas = owner.cachedCanvases.getCanvas('pattern', width, height, true);
  57027. var tmpCtx = tmpCanvas.context;
  57028. var graphics = canvasGraphicsFactory.createCanvasGraphics(tmpCtx);
  57029. graphics.groupLevel = owner.groupLevel;
  57030. this.setFillAndStrokeStyleToContext(tmpCtx, paintType, color);
  57031. this.setScale(width, height, xstep, ystep);
  57032. this.transformToScale(graphics);
  57033. var tmpTranslate = [
  57034. 1,
  57035. 0,
  57036. 0,
  57037. 1,
  57038. -topLeft[0],
  57039. -topLeft[1]
  57040. ];
  57041. graphics.transform.apply(graphics, tmpTranslate);
  57042. this.clipBbox(graphics, bbox, x0, y0, x1, y1);
  57043. graphics.executeOperatorList(operatorList);
  57044. return tmpCanvas.canvas;
  57045. },
  57046. setScale: function TilingPattern_setScale(width, height, xstep, ystep) {
  57047. this.scale = [
  57048. width / xstep,
  57049. height / ystep
  57050. ];
  57051. },
  57052. transformToScale: function TilingPattern_transformToScale(graphics) {
  57053. var scale = this.scale;
  57054. var tmpScale = [
  57055. scale[0],
  57056. 0,
  57057. 0,
  57058. scale[1],
  57059. 0,
  57060. 0
  57061. ];
  57062. graphics.transform.apply(graphics, tmpScale);
  57063. },
  57064. scaleToContext: function TilingPattern_scaleToContext() {
  57065. var scale = this.scale;
  57066. this.ctx.scale(1 / scale[0], 1 / scale[1]);
  57067. },
  57068. clipBbox: function clipBbox(graphics, bbox, x0, y0, x1, y1) {
  57069. if (bbox && isArray(bbox) && bbox.length === 4) {
  57070. var bboxWidth = x1 - x0;
  57071. var bboxHeight = y1 - y0;
  57072. graphics.ctx.rect(x0, y0, bboxWidth, bboxHeight);
  57073. graphics.clip();
  57074. graphics.endPath();
  57075. }
  57076. },
  57077. setFillAndStrokeStyleToContext: function setFillAndStrokeStyleToContext(context, paintType, color) {
  57078. switch (paintType) {
  57079. case PaintType.COLORED:
  57080. var ctx = this.ctx;
  57081. context.fillStyle = ctx.fillStyle;
  57082. context.strokeStyle = ctx.strokeStyle;
  57083. break;
  57084. case PaintType.UNCOLORED:
  57085. var cssColor = Util.makeCssRgb(color[0], color[1], color[2]);
  57086. context.fillStyle = cssColor;
  57087. context.strokeStyle = cssColor;
  57088. break;
  57089. default:
  57090. error('Unsupported paint type: ' + paintType);
  57091. }
  57092. },
  57093. getPattern: function TilingPattern_getPattern(ctx, owner) {
  57094. var temporaryPatternCanvas = this.createPatternCanvas(owner);
  57095. ctx = this.ctx;
  57096. ctx.setTransform.apply(ctx, this.baseTransform);
  57097. ctx.transform.apply(ctx, this.matrix);
  57098. this.scaleToContext();
  57099. return ctx.createPattern(temporaryPatternCanvas, 'repeat');
  57100. }
  57101. };
  57102. return TilingPattern;
  57103. }();
  57104. exports.getShadingPatternFromIR = getShadingPatternFromIR;
  57105. exports.TilingPattern = TilingPattern;
  57106. /***/ }),
  57107. /* 47 */
  57108. /***/ (function(module, exports, __w_pdfjs_require__) {
  57109. "use strict";
  57110. var pdfjsVersion = '1.7.297';
  57111. var pdfjsBuild = '425ad309';
  57112. var pdfjsSharedUtil = __w_pdfjs_require__(0);
  57113. var pdfjsDisplayGlobal = __w_pdfjs_require__(25);
  57114. var pdfjsDisplayAPI = __w_pdfjs_require__(10);
  57115. var pdfjsDisplayTextLayer = __w_pdfjs_require__(12);
  57116. var pdfjsDisplayAnnotationLayer = __w_pdfjs_require__(9);
  57117. var pdfjsDisplayDOMUtils = __w_pdfjs_require__(3);
  57118. var pdfjsDisplaySVG = __w_pdfjs_require__(11);
  57119. exports.PDFJS = pdfjsDisplayGlobal.PDFJS;
  57120. exports.build = pdfjsDisplayAPI.build;
  57121. exports.version = pdfjsDisplayAPI.version;
  57122. exports.getDocument = pdfjsDisplayAPI.getDocument;
  57123. exports.PDFDataRangeTransport = pdfjsDisplayAPI.PDFDataRangeTransport;
  57124. exports.PDFWorker = pdfjsDisplayAPI.PDFWorker;
  57125. exports.renderTextLayer = pdfjsDisplayTextLayer.renderTextLayer;
  57126. exports.AnnotationLayer = pdfjsDisplayAnnotationLayer.AnnotationLayer;
  57127. exports.CustomStyle = pdfjsDisplayDOMUtils.CustomStyle;
  57128. exports.createPromiseCapability = pdfjsSharedUtil.createPromiseCapability;
  57129. exports.PasswordResponses = pdfjsSharedUtil.PasswordResponses;
  57130. exports.InvalidPDFException = pdfjsSharedUtil.InvalidPDFException;
  57131. exports.MissingPDFException = pdfjsSharedUtil.MissingPDFException;
  57132. exports.SVGGraphics = pdfjsDisplaySVG.SVGGraphics;
  57133. exports.UnexpectedResponseException = pdfjsSharedUtil.UnexpectedResponseException;
  57134. exports.OPS = pdfjsSharedUtil.OPS;
  57135. exports.UNSUPPORTED_FEATURES = pdfjsSharedUtil.UNSUPPORTED_FEATURES;
  57136. exports.isValidUrl = pdfjsDisplayDOMUtils.isValidUrl;
  57137. exports.createValidAbsoluteUrl = pdfjsSharedUtil.createValidAbsoluteUrl;
  57138. exports.createObjectURL = pdfjsSharedUtil.createObjectURL;
  57139. exports.removeNullCharacters = pdfjsSharedUtil.removeNullCharacters;
  57140. exports.shadow = pdfjsSharedUtil.shadow;
  57141. exports.createBlob = pdfjsSharedUtil.createBlob;
  57142. exports.getFilenameFromUrl = pdfjsDisplayDOMUtils.getFilenameFromUrl;
  57143. exports.addLinkAttributes = pdfjsDisplayDOMUtils.addLinkAttributes;
  57144. /***/ })
  57145. /******/ ]);
  57146. });