pdf.combined.js 1.4 MB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180818181828183818481858186818781888189819081918192819381948195819681978198819982008201820282038204820582068207820882098210821182128213821482158216821782188219822082218222822382248225822682278228822982308231823282338234823582368237823882398240824182428243824482458246824782488249825082518252825382548255825682578258825982608261826282638264826582668267826882698270827182728273827482758276827782788279828082818282828382848285828682878288828982908291829282938294829582968297829882998300830183028303830483058306830783088309831083118312831383148315831683178318831983208321832283238324832583268327832883298330833183328333833483358336833783388339834083418342834383448345834683478348834983508351835283538354835583568357835883598360836183628363836483658366836783688369837083718372837383748375837683778378837983808381838283838384838583868387838883898390839183928393839483958396839783988399840084018402840384048405840684078408840984108411841284138414841584168417841884198420842184228423842484258426842784288429843084318432843384348435843684378438843984408441844284438444844584468447844884498450845184528453845484558456845784588459846084618462846384648465846684678468846984708471847284738474847584768477847884798480848184828483848484858486848784888489849084918492849384948495849684978498849985008501850285038504850585068507850885098510851185128513851485158516851785188519852085218522852385248525852685278528852985308531853285338534853585368537853885398540854185428543854485458546854785488549855085518552855385548555855685578558855985608561856285638564856585668567856885698570857185728573857485758576857785788579858085818582858385848585858685878588858985908591859285938594859585968597859885998600860186028603860486058606860786088609861086118612861386148615861686178618861986208621862286238624862586268627862886298630863186328633863486358636863786388639864086418642864386448645864686478648864986508651865286538654865586568657865886598660866186628663866486658666866786688669867086718672867386748675867686778678867986808681868286838684868586868687868886898690869186928693869486958696869786988699870087018702870387048705870687078708870987108711871287138714871587168717871887198720872187228723872487258726872787288729873087318732873387348735873687378738873987408741874287438744874587468747874887498750875187528753875487558756875787588759876087618762876387648765876687678768876987708771877287738774877587768777877887798780878187828783878487858786878787888789879087918792879387948795879687978798879988008801880288038804880588068807880888098810881188128813881488158816881788188819882088218822882388248825882688278828882988308831883288338834883588368837883888398840884188428843884488458846884788488849885088518852885388548855885688578858885988608861886288638864886588668867886888698870887188728873887488758876887788788879888088818882888388848885888688878888888988908891889288938894889588968897889888998900890189028903890489058906890789088909891089118912891389148915891689178918891989208921892289238924892589268927892889298930893189328933893489358936893789388939894089418942894389448945894689478948894989508951895289538954895589568957895889598960896189628963896489658966896789688969897089718972897389748975897689778978897989808981898289838984898589868987898889898990899189928993899489958996899789988999900090019002900390049005900690079008900990109011901290139014901590169017901890199020902190229023902490259026902790289029903090319032903390349035903690379038903990409041904290439044904590469047904890499050905190529053905490559056905790589059906090619062906390649065906690679068906990709071907290739074907590769077907890799080908190829083908490859086908790889089909090919092909390949095909690979098909991009101910291039104910591069107910891099110911191129113911491159116911791189119912091219122912391249125912691279128912991309131913291339134913591369137913891399140914191429143914491459146914791489149915091519152915391549155915691579158915991609161916291639164916591669167916891699170917191729173917491759176917791789179918091819182918391849185918691879188918991909191919291939194919591969197919891999200920192029203920492059206920792089209921092119212921392149215921692179218921992209221922292239224922592269227922892299230923192329233923492359236923792389239924092419242924392449245924692479248924992509251925292539254925592569257925892599260926192629263926492659266926792689269927092719272927392749275927692779278927992809281928292839284928592869287928892899290929192929293929492959296929792989299930093019302930393049305930693079308930993109311931293139314931593169317931893199320932193229323932493259326932793289329933093319332933393349335933693379338933993409341934293439344934593469347934893499350935193529353935493559356935793589359936093619362936393649365936693679368936993709371937293739374937593769377937893799380938193829383938493859386938793889389939093919392939393949395939693979398939994009401940294039404940594069407940894099410941194129413941494159416941794189419942094219422942394249425942694279428942994309431943294339434943594369437943894399440944194429443944494459446944794489449945094519452945394549455945694579458945994609461946294639464946594669467946894699470947194729473947494759476947794789479948094819482948394849485948694879488948994909491949294939494949594969497949894999500950195029503950495059506950795089509951095119512951395149515951695179518951995209521952295239524952595269527952895299530953195329533953495359536953795389539954095419542954395449545954695479548954995509551955295539554955595569557955895599560956195629563956495659566956795689569957095719572957395749575957695779578957995809581958295839584958595869587958895899590959195929593959495959596959795989599960096019602960396049605960696079608960996109611961296139614961596169617961896199620962196229623962496259626962796289629963096319632963396349635963696379638963996409641964296439644964596469647964896499650965196529653965496559656965796589659966096619662966396649665966696679668966996709671967296739674967596769677967896799680968196829683968496859686968796889689969096919692969396949695969696979698969997009701970297039704970597069707970897099710971197129713971497159716971797189719972097219722972397249725972697279728972997309731973297339734973597369737973897399740974197429743974497459746974797489749975097519752975397549755975697579758975997609761976297639764976597669767976897699770977197729773977497759776977797789779978097819782978397849785978697879788978997909791979297939794979597969797979897999800980198029803980498059806980798089809981098119812981398149815981698179818981998209821982298239824982598269827982898299830983198329833983498359836983798389839984098419842984398449845984698479848984998509851985298539854985598569857985898599860986198629863986498659866986798689869987098719872987398749875987698779878987998809881988298839884988598869887988898899890989198929893989498959896989798989899990099019902990399049905990699079908990999109911991299139914991599169917991899199920992199229923992499259926992799289929993099319932993399349935993699379938993999409941994299439944994599469947994899499950995199529953995499559956995799589959996099619962996399649965996699679968996999709971997299739974997599769977997899799980998199829983998499859986998799889989999099919992999399949995999699979998999910000100011000210003100041000510006100071000810009100101001110012100131001410015100161001710018100191002010021100221002310024100251002610027100281002910030100311003210033100341003510036100371003810039100401004110042100431004410045100461004710048100491005010051100521005310054100551005610057100581005910060100611006210063100641006510066100671006810069100701007110072100731007410075100761007710078100791008010081100821008310084100851008610087100881008910090100911009210093100941009510096100971009810099101001010110102101031010410105101061010710108101091011010111101121011310114101151011610117101181011910120101211012210123101241012510126101271012810129101301013110132101331013410135101361013710138101391014010141101421014310144101451014610147101481014910150101511015210153101541015510156101571015810159101601016110162101631016410165101661016710168101691017010171101721017310174101751017610177101781017910180101811018210183101841018510186101871018810189101901019110192101931019410195101961019710198101991020010201102021020310204102051020610207102081020910210102111021210213102141021510216102171021810219102201022110222102231022410225102261022710228102291023010231102321023310234102351023610237102381023910240102411024210243102441024510246102471024810249102501025110252102531025410255102561025710258102591026010261102621026310264102651026610267102681026910270102711027210273102741027510276102771027810279102801028110282102831028410285102861028710288102891029010291102921029310294102951029610297102981029910300103011030210303103041030510306103071030810309103101031110312103131031410315103161031710318103191032010321103221032310324103251032610327103281032910330103311033210333103341033510336103371033810339103401034110342103431034410345103461034710348103491035010351103521035310354103551035610357103581035910360103611036210363103641036510366103671036810369103701037110372103731037410375103761037710378103791038010381103821038310384103851038610387103881038910390103911039210393103941039510396103971039810399104001040110402104031040410405104061040710408104091041010411104121041310414104151041610417104181041910420104211042210423104241042510426104271042810429104301043110432104331043410435104361043710438104391044010441104421044310444104451044610447104481044910450104511045210453104541045510456104571045810459104601046110462104631046410465104661046710468104691047010471104721047310474104751047610477104781047910480104811048210483104841048510486104871048810489104901049110492104931049410495104961049710498104991050010501105021050310504105051050610507105081050910510105111051210513105141051510516105171051810519105201052110522105231052410525105261052710528105291053010531105321053310534105351053610537105381053910540105411054210543105441054510546105471054810549105501055110552105531055410555105561055710558105591056010561105621056310564105651056610567105681056910570105711057210573105741057510576105771057810579105801058110582105831058410585105861058710588105891059010591105921059310594105951059610597105981059910600106011060210603106041060510606106071060810609106101061110612106131061410615106161061710618106191062010621106221062310624106251062610627106281062910630106311063210633106341063510636106371063810639106401064110642106431064410645106461064710648106491065010651106521065310654106551065610657106581065910660106611066210663106641066510666106671066810669106701067110672106731067410675106761067710678106791068010681106821068310684106851068610687106881068910690106911069210693106941069510696106971069810699107001070110702107031070410705107061070710708107091071010711107121071310714107151071610717107181071910720107211072210723107241072510726107271072810729107301073110732107331073410735107361073710738107391074010741107421074310744107451074610747107481074910750107511075210753107541075510756107571075810759107601076110762107631076410765107661076710768107691077010771107721077310774107751077610777107781077910780107811078210783107841078510786107871078810789107901079110792107931079410795107961079710798107991080010801108021080310804108051080610807108081080910810108111081210813108141081510816108171081810819108201082110822108231082410825108261082710828108291083010831108321083310834108351083610837108381083910840108411084210843108441084510846108471084810849108501085110852108531085410855108561085710858108591086010861108621086310864108651086610867108681086910870108711087210873108741087510876108771087810879108801088110882108831088410885108861088710888108891089010891108921089310894108951089610897108981089910900109011090210903109041090510906109071090810909109101091110912109131091410915109161091710918109191092010921109221092310924109251092610927109281092910930109311093210933109341093510936109371093810939109401094110942109431094410945109461094710948109491095010951109521095310954109551095610957109581095910960109611096210963109641096510966109671096810969109701097110972109731097410975109761097710978109791098010981109821098310984109851098610987109881098910990109911099210993109941099510996109971099810999110001100111002110031100411005110061100711008110091101011011110121101311014110151101611017110181101911020110211102211023110241102511026110271102811029110301103111032110331103411035110361103711038110391104011041110421104311044110451104611047110481104911050110511105211053110541105511056110571105811059110601106111062110631106411065110661106711068110691107011071110721107311074110751107611077110781107911080110811108211083110841108511086110871108811089110901109111092110931109411095110961109711098110991110011101111021110311104111051110611107111081110911110111111111211113111141111511116111171111811119111201112111122111231112411125111261112711128111291113011131111321113311134111351113611137111381113911140111411114211143111441114511146111471114811149111501115111152111531115411155111561115711158111591116011161111621116311164111651116611167111681116911170111711117211173111741117511176111771117811179111801118111182111831118411185111861118711188111891119011191111921119311194111951119611197111981119911200112011120211203112041120511206112071120811209112101121111212112131121411215112161121711218112191122011221112221122311224112251122611227112281122911230112311123211233112341123511236112371123811239112401124111242112431124411245112461124711248112491125011251112521125311254112551125611257112581125911260112611126211263112641126511266112671126811269112701127111272112731127411275112761127711278112791128011281112821128311284112851128611287112881128911290112911129211293112941129511296112971129811299113001130111302113031130411305113061130711308113091131011311113121131311314113151131611317113181131911320113211132211323113241132511326113271132811329113301133111332113331133411335113361133711338113391134011341113421134311344113451134611347113481134911350113511135211353113541135511356113571135811359113601136111362113631136411365113661136711368113691137011371113721137311374113751137611377113781137911380113811138211383113841138511386113871138811389113901139111392113931139411395113961139711398113991140011401114021140311404114051140611407114081140911410114111141211413114141141511416114171141811419114201142111422114231142411425114261142711428114291143011431114321143311434114351143611437114381143911440114411144211443114441144511446114471144811449114501145111452114531145411455114561145711458114591146011461114621146311464114651146611467114681146911470114711147211473114741147511476114771147811479114801148111482114831148411485114861148711488114891149011491114921149311494114951149611497114981149911500115011150211503115041150511506115071150811509115101151111512115131151411515115161151711518115191152011521115221152311524115251152611527115281152911530115311153211533115341153511536115371153811539115401154111542115431154411545115461154711548115491155011551115521155311554115551155611557115581155911560115611156211563115641156511566115671156811569115701157111572115731157411575115761157711578115791158011581115821158311584115851158611587115881158911590115911159211593115941159511596115971159811599116001160111602116031160411605116061160711608116091161011611116121161311614116151161611617116181161911620116211162211623116241162511626116271162811629116301163111632116331163411635116361163711638116391164011641116421164311644116451164611647116481164911650116511165211653116541165511656116571165811659116601166111662116631166411665116661166711668116691167011671116721167311674116751167611677116781167911680116811168211683116841168511686116871168811689116901169111692116931169411695116961169711698116991170011701117021170311704117051170611707117081170911710117111171211713117141171511716117171171811719117201172111722117231172411725117261172711728117291173011731117321173311734117351173611737117381173911740117411174211743117441174511746117471174811749117501175111752117531175411755117561175711758117591176011761117621176311764117651176611767117681176911770117711177211773117741177511776117771177811779117801178111782117831178411785117861178711788117891179011791117921179311794117951179611797117981179911800118011180211803118041180511806118071180811809118101181111812118131181411815118161181711818118191182011821118221182311824118251182611827118281182911830118311183211833118341183511836118371183811839118401184111842118431184411845118461184711848118491185011851118521185311854118551185611857118581185911860118611186211863118641186511866118671186811869118701187111872118731187411875118761187711878118791188011881118821188311884118851188611887118881188911890118911189211893118941189511896118971189811899119001190111902119031190411905119061190711908119091191011911119121191311914119151191611917119181191911920119211192211923119241192511926119271192811929119301193111932119331193411935119361193711938119391194011941119421194311944119451194611947119481194911950119511195211953119541195511956119571195811959119601196111962119631196411965119661196711968119691197011971119721197311974119751197611977119781197911980119811198211983119841198511986119871198811989119901199111992119931199411995119961199711998119991200012001120021200312004120051200612007120081200912010120111201212013120141201512016120171201812019120201202112022120231202412025120261202712028120291203012031120321203312034120351203612037120381203912040120411204212043120441204512046120471204812049120501205112052120531205412055120561205712058120591206012061120621206312064120651206612067120681206912070120711207212073120741207512076120771207812079120801208112082120831208412085120861208712088120891209012091120921209312094120951209612097120981209912100121011210212103121041210512106121071210812109121101211112112121131211412115121161211712118121191212012121121221212312124121251212612127121281212912130121311213212133121341213512136121371213812139121401214112142121431214412145121461214712148121491215012151121521215312154121551215612157121581215912160121611216212163121641216512166121671216812169121701217112172121731217412175121761217712178121791218012181121821218312184121851218612187121881218912190121911219212193121941219512196121971219812199122001220112202122031220412205122061220712208122091221012211122121221312214122151221612217122181221912220122211222212223122241222512226122271222812229122301223112232122331223412235122361223712238122391224012241122421224312244122451224612247122481224912250122511225212253122541225512256122571225812259122601226112262122631226412265122661226712268122691227012271122721227312274122751227612277122781227912280122811228212283122841228512286122871228812289122901229112292122931229412295122961229712298122991230012301123021230312304123051230612307123081230912310123111231212313123141231512316123171231812319123201232112322123231232412325123261232712328123291233012331123321233312334123351233612337123381233912340123411234212343123441234512346123471234812349123501235112352123531235412355123561235712358123591236012361123621236312364123651236612367123681236912370123711237212373123741237512376123771237812379123801238112382123831238412385123861238712388123891239012391123921239312394123951239612397123981239912400124011240212403124041240512406124071240812409124101241112412124131241412415124161241712418124191242012421124221242312424124251242612427124281242912430124311243212433124341243512436124371243812439124401244112442124431244412445124461244712448124491245012451124521245312454124551245612457124581245912460124611246212463124641246512466124671246812469124701247112472124731247412475124761247712478124791248012481124821248312484124851248612487124881248912490124911249212493124941249512496124971249812499125001250112502125031250412505125061250712508125091251012511125121251312514125151251612517125181251912520125211252212523125241252512526125271252812529125301253112532125331253412535125361253712538125391254012541125421254312544125451254612547125481254912550125511255212553125541255512556125571255812559125601256112562125631256412565125661256712568125691257012571125721257312574125751257612577125781257912580125811258212583125841258512586125871258812589125901259112592125931259412595125961259712598125991260012601126021260312604126051260612607126081260912610126111261212613126141261512616126171261812619126201262112622126231262412625126261262712628126291263012631126321263312634126351263612637126381263912640126411264212643126441264512646126471264812649126501265112652126531265412655126561265712658126591266012661126621266312664126651266612667126681266912670126711267212673126741267512676126771267812679126801268112682126831268412685126861268712688126891269012691126921269312694126951269612697126981269912700127011270212703127041270512706127071270812709127101271112712127131271412715127161271712718127191272012721127221272312724127251272612727127281272912730127311273212733127341273512736127371273812739127401274112742127431274412745127461274712748127491275012751127521275312754127551275612757127581275912760127611276212763127641276512766127671276812769127701277112772127731277412775127761277712778127791278012781127821278312784127851278612787127881278912790127911279212793127941279512796127971279812799128001280112802128031280412805128061280712808128091281012811128121281312814128151281612817128181281912820128211282212823128241282512826128271282812829128301283112832128331283412835128361283712838128391284012841128421284312844128451284612847128481284912850128511285212853128541285512856128571285812859128601286112862128631286412865128661286712868128691287012871128721287312874128751287612877128781287912880128811288212883128841288512886128871288812889128901289112892128931289412895128961289712898128991290012901129021290312904129051290612907129081290912910129111291212913129141291512916129171291812919129201292112922129231292412925129261292712928129291293012931129321293312934129351293612937129381293912940129411294212943129441294512946129471294812949129501295112952129531295412955129561295712958129591296012961129621296312964129651296612967129681296912970129711297212973129741297512976129771297812979129801298112982129831298412985129861298712988129891299012991129921299312994129951299612997129981299913000130011300213003130041300513006130071300813009130101301113012130131301413015130161301713018130191302013021130221302313024130251302613027130281302913030130311303213033130341303513036130371303813039130401304113042130431304413045130461304713048130491305013051130521305313054130551305613057130581305913060130611306213063130641306513066130671306813069130701307113072130731307413075130761307713078130791308013081130821308313084130851308613087130881308913090130911309213093130941309513096130971309813099131001310113102131031310413105131061310713108131091311013111131121311313114131151311613117131181311913120131211312213123131241312513126131271312813129131301313113132131331313413135131361313713138131391314013141131421314313144131451314613147131481314913150131511315213153131541315513156131571315813159131601316113162131631316413165131661316713168131691317013171131721317313174131751317613177131781317913180131811318213183131841318513186131871318813189131901319113192131931319413195131961319713198131991320013201132021320313204132051320613207132081320913210132111321213213132141321513216132171321813219132201322113222132231322413225132261322713228132291323013231132321323313234132351323613237132381323913240132411324213243132441324513246132471324813249132501325113252132531325413255132561325713258132591326013261132621326313264132651326613267132681326913270132711327213273132741327513276132771327813279132801328113282132831328413285132861328713288132891329013291132921329313294132951329613297132981329913300133011330213303133041330513306133071330813309133101331113312133131331413315133161331713318133191332013321133221332313324133251332613327133281332913330133311333213333133341333513336133371333813339133401334113342133431334413345133461334713348133491335013351133521335313354133551335613357133581335913360133611336213363133641336513366133671336813369133701337113372133731337413375133761337713378133791338013381133821338313384133851338613387133881338913390133911339213393133941339513396133971339813399134001340113402134031340413405134061340713408134091341013411134121341313414134151341613417134181341913420134211342213423134241342513426134271342813429134301343113432134331343413435134361343713438134391344013441134421344313444134451344613447134481344913450134511345213453134541345513456134571345813459134601346113462134631346413465134661346713468134691347013471134721347313474134751347613477134781347913480134811348213483134841348513486134871348813489134901349113492134931349413495134961349713498134991350013501135021350313504135051350613507135081350913510135111351213513135141351513516135171351813519135201352113522135231352413525135261352713528135291353013531135321353313534135351353613537135381353913540135411354213543135441354513546135471354813549135501355113552135531355413555135561355713558135591356013561135621356313564135651356613567135681356913570135711357213573135741357513576135771357813579135801358113582135831358413585135861358713588135891359013591135921359313594135951359613597135981359913600136011360213603136041360513606136071360813609136101361113612136131361413615136161361713618136191362013621136221362313624136251362613627136281362913630136311363213633136341363513636136371363813639136401364113642136431364413645136461364713648136491365013651136521365313654136551365613657136581365913660136611366213663136641366513666136671366813669136701367113672136731367413675136761367713678136791368013681136821368313684136851368613687136881368913690136911369213693136941369513696136971369813699137001370113702137031370413705137061370713708137091371013711137121371313714137151371613717137181371913720137211372213723137241372513726137271372813729137301373113732137331373413735137361373713738137391374013741137421374313744137451374613747137481374913750137511375213753137541375513756137571375813759137601376113762137631376413765137661376713768137691377013771137721377313774137751377613777137781377913780137811378213783137841378513786137871378813789137901379113792137931379413795137961379713798137991380013801138021380313804138051380613807138081380913810138111381213813138141381513816138171381813819138201382113822138231382413825138261382713828138291383013831138321383313834138351383613837138381383913840138411384213843138441384513846138471384813849138501385113852138531385413855138561385713858138591386013861138621386313864138651386613867138681386913870138711387213873138741387513876138771387813879138801388113882138831388413885138861388713888138891389013891138921389313894138951389613897138981389913900139011390213903139041390513906139071390813909139101391113912139131391413915139161391713918139191392013921139221392313924139251392613927139281392913930139311393213933139341393513936139371393813939139401394113942139431394413945139461394713948139491395013951139521395313954139551395613957139581395913960139611396213963139641396513966139671396813969139701397113972139731397413975139761397713978139791398013981139821398313984139851398613987139881398913990139911399213993139941399513996139971399813999140001400114002140031400414005140061400714008140091401014011140121401314014140151401614017140181401914020140211402214023140241402514026140271402814029140301403114032140331403414035140361403714038140391404014041140421404314044140451404614047140481404914050140511405214053140541405514056140571405814059140601406114062140631406414065140661406714068140691407014071140721407314074140751407614077140781407914080140811408214083140841408514086140871408814089140901409114092140931409414095140961409714098140991410014101141021410314104141051410614107141081410914110141111411214113141141411514116141171411814119141201412114122141231412414125141261412714128141291413014131141321413314134141351413614137141381413914140141411414214143141441414514146141471414814149141501415114152141531415414155141561415714158141591416014161141621416314164141651416614167141681416914170141711417214173141741417514176141771417814179141801418114182141831418414185141861418714188141891419014191141921419314194141951419614197141981419914200142011420214203142041420514206142071420814209142101421114212142131421414215142161421714218142191422014221142221422314224142251422614227142281422914230142311423214233142341423514236142371423814239142401424114242142431424414245142461424714248142491425014251142521425314254142551425614257142581425914260142611426214263142641426514266142671426814269142701427114272142731427414275142761427714278142791428014281142821428314284142851428614287142881428914290142911429214293142941429514296142971429814299143001430114302143031430414305143061430714308143091431014311143121431314314143151431614317143181431914320143211432214323143241432514326143271432814329143301433114332143331433414335143361433714338143391434014341143421434314344143451434614347143481434914350143511435214353143541435514356143571435814359143601436114362143631436414365143661436714368143691437014371143721437314374143751437614377143781437914380143811438214383143841438514386143871438814389143901439114392143931439414395143961439714398143991440014401144021440314404144051440614407144081440914410144111441214413144141441514416144171441814419144201442114422144231442414425144261442714428144291443014431144321443314434144351443614437144381443914440144411444214443144441444514446144471444814449144501445114452144531445414455144561445714458144591446014461144621446314464144651446614467144681446914470144711447214473144741447514476144771447814479144801448114482144831448414485144861448714488144891449014491144921449314494144951449614497144981449914500145011450214503145041450514506145071450814509145101451114512145131451414515145161451714518145191452014521145221452314524145251452614527145281452914530145311453214533145341453514536145371453814539145401454114542145431454414545145461454714548145491455014551145521455314554145551455614557145581455914560145611456214563145641456514566145671456814569145701457114572145731457414575145761457714578145791458014581145821458314584145851458614587145881458914590145911459214593145941459514596145971459814599146001460114602146031460414605146061460714608146091461014611146121461314614146151461614617146181461914620146211462214623146241462514626146271462814629146301463114632146331463414635146361463714638146391464014641146421464314644146451464614647146481464914650146511465214653146541465514656146571465814659146601466114662146631466414665146661466714668146691467014671146721467314674146751467614677146781467914680146811468214683146841468514686146871468814689146901469114692146931469414695146961469714698146991470014701147021470314704147051470614707147081470914710147111471214713147141471514716147171471814719147201472114722147231472414725147261472714728147291473014731147321473314734147351473614737147381473914740147411474214743147441474514746147471474814749147501475114752147531475414755147561475714758147591476014761147621476314764147651476614767147681476914770147711477214773147741477514776147771477814779147801478114782147831478414785147861478714788147891479014791147921479314794147951479614797147981479914800148011480214803148041480514806148071480814809148101481114812148131481414815148161481714818148191482014821148221482314824148251482614827148281482914830148311483214833148341483514836148371483814839148401484114842148431484414845148461484714848148491485014851148521485314854148551485614857148581485914860148611486214863148641486514866148671486814869148701487114872148731487414875148761487714878148791488014881148821488314884148851488614887148881488914890148911489214893148941489514896148971489814899149001490114902149031490414905149061490714908149091491014911149121491314914149151491614917149181491914920149211492214923149241492514926149271492814929149301493114932149331493414935149361493714938149391494014941149421494314944149451494614947149481494914950149511495214953149541495514956149571495814959149601496114962149631496414965149661496714968149691497014971149721497314974149751497614977149781497914980149811498214983149841498514986149871498814989149901499114992149931499414995149961499714998149991500015001150021500315004150051500615007150081500915010150111501215013150141501515016150171501815019150201502115022150231502415025150261502715028150291503015031150321503315034150351503615037150381503915040150411504215043150441504515046150471504815049150501505115052150531505415055150561505715058150591506015061150621506315064150651506615067150681506915070150711507215073150741507515076150771507815079150801508115082150831508415085150861508715088150891509015091150921509315094150951509615097150981509915100151011510215103151041510515106151071510815109151101511115112151131511415115151161511715118151191512015121151221512315124151251512615127151281512915130151311513215133151341513515136151371513815139151401514115142151431514415145151461514715148151491515015151151521515315154151551515615157151581515915160151611516215163151641516515166151671516815169151701517115172151731517415175151761517715178151791518015181151821518315184151851518615187151881518915190151911519215193151941519515196151971519815199152001520115202152031520415205152061520715208152091521015211152121521315214152151521615217152181521915220152211522215223152241522515226152271522815229152301523115232152331523415235152361523715238152391524015241152421524315244152451524615247152481524915250152511525215253152541525515256152571525815259152601526115262152631526415265152661526715268152691527015271152721527315274152751527615277152781527915280152811528215283152841528515286152871528815289152901529115292152931529415295152961529715298152991530015301153021530315304153051530615307153081530915310153111531215313153141531515316153171531815319153201532115322153231532415325153261532715328153291533015331153321533315334153351533615337153381533915340153411534215343153441534515346153471534815349153501535115352153531535415355153561535715358153591536015361153621536315364153651536615367153681536915370153711537215373153741537515376153771537815379153801538115382153831538415385153861538715388153891539015391153921539315394153951539615397153981539915400154011540215403154041540515406154071540815409154101541115412154131541415415154161541715418154191542015421154221542315424154251542615427154281542915430154311543215433154341543515436154371543815439154401544115442154431544415445154461544715448154491545015451154521545315454154551545615457154581545915460154611546215463154641546515466154671546815469154701547115472154731547415475154761547715478154791548015481154821548315484154851548615487154881548915490154911549215493154941549515496154971549815499155001550115502155031550415505155061550715508155091551015511155121551315514155151551615517155181551915520155211552215523155241552515526155271552815529155301553115532155331553415535155361553715538155391554015541155421554315544155451554615547155481554915550155511555215553155541555515556155571555815559155601556115562155631556415565155661556715568155691557015571155721557315574155751557615577155781557915580155811558215583155841558515586155871558815589155901559115592155931559415595155961559715598155991560015601156021560315604156051560615607156081560915610156111561215613156141561515616156171561815619156201562115622156231562415625156261562715628156291563015631156321563315634156351563615637156381563915640156411564215643156441564515646156471564815649156501565115652156531565415655156561565715658156591566015661156621566315664156651566615667156681566915670156711567215673156741567515676156771567815679156801568115682156831568415685156861568715688156891569015691156921569315694156951569615697156981569915700157011570215703157041570515706157071570815709157101571115712157131571415715157161571715718157191572015721157221572315724157251572615727157281572915730157311573215733157341573515736157371573815739157401574115742157431574415745157461574715748157491575015751157521575315754157551575615757157581575915760157611576215763157641576515766157671576815769157701577115772157731577415775157761577715778157791578015781157821578315784157851578615787157881578915790157911579215793157941579515796157971579815799158001580115802158031580415805158061580715808158091581015811158121581315814158151581615817158181581915820158211582215823158241582515826158271582815829158301583115832158331583415835158361583715838158391584015841158421584315844158451584615847158481584915850158511585215853158541585515856158571585815859158601586115862158631586415865158661586715868158691587015871158721587315874158751587615877158781587915880158811588215883158841588515886158871588815889158901589115892158931589415895158961589715898158991590015901159021590315904159051590615907159081590915910159111591215913159141591515916159171591815919159201592115922159231592415925159261592715928159291593015931159321593315934159351593615937159381593915940159411594215943159441594515946159471594815949159501595115952159531595415955159561595715958159591596015961159621596315964159651596615967159681596915970159711597215973159741597515976159771597815979159801598115982159831598415985159861598715988159891599015991159921599315994159951599615997159981599916000160011600216003160041600516006160071600816009160101601116012160131601416015160161601716018160191602016021160221602316024160251602616027160281602916030160311603216033160341603516036160371603816039160401604116042160431604416045160461604716048160491605016051160521605316054160551605616057160581605916060160611606216063160641606516066160671606816069160701607116072160731607416075160761607716078160791608016081160821608316084160851608616087160881608916090160911609216093160941609516096160971609816099161001610116102161031610416105161061610716108161091611016111161121611316114161151611616117161181611916120161211612216123161241612516126161271612816129161301613116132161331613416135161361613716138161391614016141161421614316144161451614616147161481614916150161511615216153161541615516156161571615816159161601616116162161631616416165161661616716168161691617016171161721617316174161751617616177161781617916180161811618216183161841618516186161871618816189161901619116192161931619416195161961619716198161991620016201162021620316204162051620616207162081620916210162111621216213162141621516216162171621816219162201622116222162231622416225162261622716228162291623016231162321623316234162351623616237162381623916240162411624216243162441624516246162471624816249162501625116252162531625416255162561625716258162591626016261162621626316264162651626616267162681626916270162711627216273162741627516276162771627816279162801628116282162831628416285162861628716288162891629016291162921629316294162951629616297162981629916300163011630216303163041630516306163071630816309163101631116312163131631416315163161631716318163191632016321163221632316324163251632616327163281632916330163311633216333163341633516336163371633816339163401634116342163431634416345163461634716348163491635016351163521635316354163551635616357163581635916360163611636216363163641636516366163671636816369163701637116372163731637416375163761637716378163791638016381163821638316384163851638616387163881638916390163911639216393163941639516396163971639816399164001640116402164031640416405164061640716408164091641016411164121641316414164151641616417164181641916420164211642216423164241642516426164271642816429164301643116432164331643416435164361643716438164391644016441164421644316444164451644616447164481644916450164511645216453164541645516456164571645816459164601646116462164631646416465164661646716468164691647016471164721647316474164751647616477164781647916480164811648216483164841648516486164871648816489164901649116492164931649416495164961649716498164991650016501165021650316504165051650616507165081650916510165111651216513165141651516516165171651816519165201652116522165231652416525165261652716528165291653016531165321653316534165351653616537165381653916540165411654216543165441654516546165471654816549165501655116552165531655416555165561655716558165591656016561165621656316564165651656616567165681656916570165711657216573165741657516576165771657816579165801658116582165831658416585165861658716588165891659016591165921659316594165951659616597165981659916600166011660216603166041660516606166071660816609166101661116612166131661416615166161661716618166191662016621166221662316624166251662616627166281662916630166311663216633166341663516636166371663816639166401664116642166431664416645166461664716648166491665016651166521665316654166551665616657166581665916660166611666216663166641666516666166671666816669166701667116672166731667416675166761667716678166791668016681166821668316684166851668616687166881668916690166911669216693166941669516696166971669816699167001670116702167031670416705167061670716708167091671016711167121671316714167151671616717167181671916720167211672216723167241672516726167271672816729167301673116732167331673416735167361673716738167391674016741167421674316744167451674616747167481674916750167511675216753167541675516756167571675816759167601676116762167631676416765167661676716768167691677016771167721677316774167751677616777167781677916780167811678216783167841678516786167871678816789167901679116792167931679416795167961679716798167991680016801168021680316804168051680616807168081680916810168111681216813168141681516816168171681816819168201682116822168231682416825168261682716828168291683016831168321683316834168351683616837168381683916840168411684216843168441684516846168471684816849168501685116852168531685416855168561685716858168591686016861168621686316864168651686616867168681686916870168711687216873168741687516876168771687816879168801688116882168831688416885168861688716888168891689016891168921689316894168951689616897168981689916900169011690216903169041690516906169071690816909169101691116912169131691416915169161691716918169191692016921169221692316924169251692616927169281692916930169311693216933169341693516936169371693816939169401694116942169431694416945169461694716948169491695016951169521695316954169551695616957169581695916960169611696216963169641696516966169671696816969169701697116972169731697416975169761697716978169791698016981169821698316984169851698616987169881698916990169911699216993169941699516996169971699816999170001700117002170031700417005170061700717008170091701017011170121701317014170151701617017170181701917020170211702217023170241702517026170271702817029170301703117032170331703417035170361703717038170391704017041170421704317044170451704617047170481704917050170511705217053170541705517056170571705817059170601706117062170631706417065170661706717068170691707017071170721707317074170751707617077170781707917080170811708217083170841708517086170871708817089170901709117092170931709417095170961709717098170991710017101171021710317104171051710617107171081710917110171111711217113171141711517116171171711817119171201712117122171231712417125171261712717128171291713017131171321713317134171351713617137171381713917140171411714217143171441714517146171471714817149171501715117152171531715417155171561715717158171591716017161171621716317164171651716617167171681716917170171711717217173171741717517176171771717817179171801718117182171831718417185171861718717188171891719017191171921719317194171951719617197171981719917200172011720217203172041720517206172071720817209172101721117212172131721417215172161721717218172191722017221172221722317224172251722617227172281722917230172311723217233172341723517236172371723817239172401724117242172431724417245172461724717248172491725017251172521725317254172551725617257172581725917260172611726217263172641726517266172671726817269172701727117272172731727417275172761727717278172791728017281172821728317284172851728617287172881728917290172911729217293172941729517296172971729817299173001730117302173031730417305173061730717308173091731017311173121731317314173151731617317173181731917320173211732217323173241732517326173271732817329173301733117332173331733417335173361733717338173391734017341173421734317344173451734617347173481734917350173511735217353173541735517356173571735817359173601736117362173631736417365173661736717368173691737017371173721737317374173751737617377173781737917380173811738217383173841738517386173871738817389173901739117392173931739417395173961739717398173991740017401174021740317404174051740617407174081740917410174111741217413174141741517416174171741817419174201742117422174231742417425174261742717428174291743017431174321743317434174351743617437174381743917440174411744217443174441744517446174471744817449174501745117452174531745417455174561745717458174591746017461174621746317464174651746617467174681746917470174711747217473174741747517476174771747817479174801748117482174831748417485174861748717488174891749017491174921749317494174951749617497174981749917500175011750217503175041750517506175071750817509175101751117512175131751417515175161751717518175191752017521175221752317524175251752617527175281752917530175311753217533175341753517536175371753817539175401754117542175431754417545175461754717548175491755017551175521755317554175551755617557175581755917560175611756217563175641756517566175671756817569175701757117572175731757417575175761757717578175791758017581175821758317584175851758617587175881758917590175911759217593175941759517596175971759817599176001760117602176031760417605176061760717608176091761017611176121761317614176151761617617176181761917620176211762217623176241762517626176271762817629176301763117632176331763417635176361763717638176391764017641176421764317644176451764617647176481764917650176511765217653176541765517656176571765817659176601766117662176631766417665176661766717668176691767017671176721767317674176751767617677176781767917680176811768217683176841768517686176871768817689176901769117692176931769417695176961769717698176991770017701177021770317704177051770617707177081770917710177111771217713177141771517716177171771817719177201772117722177231772417725177261772717728177291773017731177321773317734177351773617737177381773917740177411774217743177441774517746177471774817749177501775117752177531775417755177561775717758177591776017761177621776317764177651776617767177681776917770177711777217773177741777517776177771777817779177801778117782177831778417785177861778717788177891779017791177921779317794177951779617797177981779917800178011780217803178041780517806178071780817809178101781117812178131781417815178161781717818178191782017821178221782317824178251782617827178281782917830178311783217833178341783517836178371783817839178401784117842178431784417845178461784717848178491785017851178521785317854178551785617857178581785917860178611786217863178641786517866178671786817869178701787117872178731787417875178761787717878178791788017881178821788317884178851788617887178881788917890178911789217893178941789517896178971789817899179001790117902179031790417905179061790717908179091791017911179121791317914179151791617917179181791917920179211792217923179241792517926179271792817929179301793117932179331793417935179361793717938179391794017941179421794317944179451794617947179481794917950179511795217953179541795517956179571795817959179601796117962179631796417965179661796717968179691797017971179721797317974179751797617977179781797917980179811798217983179841798517986179871798817989179901799117992179931799417995179961799717998179991800018001180021800318004180051800618007180081800918010180111801218013180141801518016180171801818019180201802118022180231802418025180261802718028180291803018031180321803318034180351803618037180381803918040180411804218043180441804518046180471804818049180501805118052180531805418055180561805718058180591806018061180621806318064180651806618067180681806918070180711807218073180741807518076180771807818079180801808118082180831808418085180861808718088180891809018091180921809318094180951809618097180981809918100181011810218103181041810518106181071810818109181101811118112181131811418115181161811718118181191812018121181221812318124181251812618127181281812918130181311813218133181341813518136181371813818139181401814118142181431814418145181461814718148181491815018151181521815318154181551815618157181581815918160181611816218163181641816518166181671816818169181701817118172181731817418175181761817718178181791818018181181821818318184181851818618187181881818918190181911819218193181941819518196181971819818199182001820118202182031820418205182061820718208182091821018211182121821318214182151821618217182181821918220182211822218223182241822518226182271822818229182301823118232182331823418235182361823718238182391824018241182421824318244182451824618247182481824918250182511825218253182541825518256182571825818259182601826118262182631826418265182661826718268182691827018271182721827318274182751827618277182781827918280182811828218283182841828518286182871828818289182901829118292182931829418295182961829718298182991830018301183021830318304183051830618307183081830918310183111831218313183141831518316183171831818319183201832118322183231832418325183261832718328183291833018331183321833318334183351833618337183381833918340183411834218343183441834518346183471834818349183501835118352183531835418355183561835718358183591836018361183621836318364183651836618367183681836918370183711837218373183741837518376183771837818379183801838118382183831838418385183861838718388183891839018391183921839318394183951839618397183981839918400184011840218403184041840518406184071840818409184101841118412184131841418415184161841718418184191842018421184221842318424184251842618427184281842918430184311843218433184341843518436184371843818439184401844118442184431844418445184461844718448184491845018451184521845318454184551845618457184581845918460184611846218463184641846518466184671846818469184701847118472184731847418475184761847718478184791848018481184821848318484184851848618487184881848918490184911849218493184941849518496184971849818499185001850118502185031850418505185061850718508185091851018511185121851318514185151851618517185181851918520185211852218523185241852518526185271852818529185301853118532185331853418535185361853718538185391854018541185421854318544185451854618547185481854918550185511855218553185541855518556185571855818559185601856118562185631856418565185661856718568185691857018571185721857318574185751857618577185781857918580185811858218583185841858518586185871858818589185901859118592185931859418595185961859718598185991860018601186021860318604186051860618607186081860918610186111861218613186141861518616186171861818619186201862118622186231862418625186261862718628186291863018631186321863318634186351863618637186381863918640186411864218643186441864518646186471864818649186501865118652186531865418655186561865718658186591866018661186621866318664186651866618667186681866918670186711867218673186741867518676186771867818679186801868118682186831868418685186861868718688186891869018691186921869318694186951869618697186981869918700187011870218703187041870518706187071870818709187101871118712187131871418715187161871718718187191872018721187221872318724187251872618727187281872918730187311873218733187341873518736187371873818739187401874118742187431874418745187461874718748187491875018751187521875318754187551875618757187581875918760187611876218763187641876518766187671876818769187701877118772187731877418775187761877718778187791878018781187821878318784187851878618787187881878918790187911879218793187941879518796187971879818799188001880118802188031880418805188061880718808188091881018811188121881318814188151881618817188181881918820188211882218823188241882518826188271882818829188301883118832188331883418835188361883718838188391884018841188421884318844188451884618847188481884918850188511885218853188541885518856188571885818859188601886118862188631886418865188661886718868188691887018871188721887318874188751887618877188781887918880188811888218883188841888518886188871888818889188901889118892188931889418895188961889718898188991890018901189021890318904189051890618907189081890918910189111891218913189141891518916189171891818919189201892118922189231892418925189261892718928189291893018931189321893318934189351893618937189381893918940189411894218943189441894518946189471894818949189501895118952189531895418955189561895718958189591896018961189621896318964189651896618967189681896918970189711897218973189741897518976189771897818979189801898118982189831898418985189861898718988189891899018991189921899318994189951899618997189981899919000190011900219003190041900519006190071900819009190101901119012190131901419015190161901719018190191902019021190221902319024190251902619027190281902919030190311903219033190341903519036190371903819039190401904119042190431904419045190461904719048190491905019051190521905319054190551905619057190581905919060190611906219063190641906519066190671906819069190701907119072190731907419075190761907719078190791908019081190821908319084190851908619087190881908919090190911909219093190941909519096190971909819099191001910119102191031910419105191061910719108191091911019111191121911319114191151911619117191181911919120191211912219123191241912519126191271912819129191301913119132191331913419135191361913719138191391914019141191421914319144191451914619147191481914919150191511915219153191541915519156191571915819159191601916119162191631916419165191661916719168191691917019171191721917319174191751917619177191781917919180191811918219183191841918519186191871918819189191901919119192191931919419195191961919719198191991920019201192021920319204192051920619207192081920919210192111921219213192141921519216192171921819219192201922119222192231922419225192261922719228192291923019231192321923319234192351923619237192381923919240192411924219243192441924519246192471924819249192501925119252192531925419255192561925719258192591926019261192621926319264192651926619267192681926919270192711927219273192741927519276192771927819279192801928119282192831928419285192861928719288192891929019291192921929319294192951929619297192981929919300193011930219303193041930519306193071930819309193101931119312193131931419315193161931719318193191932019321193221932319324193251932619327193281932919330193311933219333193341933519336193371933819339193401934119342193431934419345193461934719348193491935019351193521935319354193551935619357193581935919360193611936219363193641936519366193671936819369193701937119372193731937419375193761937719378193791938019381193821938319384193851938619387193881938919390193911939219393193941939519396193971939819399194001940119402194031940419405194061940719408194091941019411194121941319414194151941619417194181941919420194211942219423194241942519426194271942819429194301943119432194331943419435194361943719438194391944019441194421944319444194451944619447194481944919450194511945219453194541945519456194571945819459194601946119462194631946419465194661946719468194691947019471194721947319474194751947619477194781947919480194811948219483194841948519486194871948819489194901949119492194931949419495194961949719498194991950019501195021950319504195051950619507195081950919510195111951219513195141951519516195171951819519195201952119522195231952419525195261952719528195291953019531195321953319534195351953619537195381953919540195411954219543195441954519546195471954819549195501955119552195531955419555195561955719558195591956019561195621956319564195651956619567195681956919570195711957219573195741957519576195771957819579195801958119582195831958419585195861958719588195891959019591195921959319594195951959619597195981959919600196011960219603196041960519606196071960819609196101961119612196131961419615196161961719618196191962019621196221962319624196251962619627196281962919630196311963219633196341963519636196371963819639196401964119642196431964419645196461964719648196491965019651196521965319654196551965619657196581965919660196611966219663196641966519666196671966819669196701967119672196731967419675196761967719678196791968019681196821968319684196851968619687196881968919690196911969219693196941969519696196971969819699197001970119702197031970419705197061970719708197091971019711197121971319714197151971619717197181971919720197211972219723197241972519726197271972819729197301973119732197331973419735197361973719738197391974019741197421974319744197451974619747197481974919750197511975219753197541975519756197571975819759197601976119762197631976419765197661976719768197691977019771197721977319774197751977619777197781977919780197811978219783197841978519786197871978819789197901979119792197931979419795197961979719798197991980019801198021980319804198051980619807198081980919810198111981219813198141981519816198171981819819198201982119822198231982419825198261982719828198291983019831198321983319834198351983619837198381983919840198411984219843198441984519846198471984819849198501985119852198531985419855198561985719858198591986019861198621986319864198651986619867198681986919870198711987219873198741987519876198771987819879198801988119882198831988419885198861988719888198891989019891198921989319894198951989619897198981989919900199011990219903199041990519906199071990819909199101991119912199131991419915199161991719918199191992019921199221992319924199251992619927199281992919930199311993219933199341993519936199371993819939199401994119942199431994419945199461994719948199491995019951199521995319954199551995619957199581995919960199611996219963199641996519966199671996819969199701997119972199731997419975199761997719978199791998019981199821998319984199851998619987199881998919990199911999219993199941999519996199971999819999200002000120002200032000420005200062000720008200092001020011200122001320014200152001620017200182001920020200212002220023200242002520026200272002820029200302003120032200332003420035200362003720038200392004020041200422004320044200452004620047200482004920050200512005220053200542005520056200572005820059200602006120062200632006420065200662006720068200692007020071200722007320074200752007620077200782007920080200812008220083200842008520086200872008820089200902009120092200932009420095200962009720098200992010020101201022010320104201052010620107201082010920110201112011220113201142011520116201172011820119201202012120122201232012420125201262012720128201292013020131201322013320134201352013620137201382013920140201412014220143201442014520146201472014820149201502015120152201532015420155201562015720158201592016020161201622016320164201652016620167201682016920170201712017220173201742017520176201772017820179201802018120182201832018420185201862018720188201892019020191201922019320194201952019620197201982019920200202012020220203202042020520206202072020820209202102021120212202132021420215202162021720218202192022020221202222022320224202252022620227202282022920230202312023220233202342023520236202372023820239202402024120242202432024420245202462024720248202492025020251202522025320254202552025620257202582025920260202612026220263202642026520266202672026820269202702027120272202732027420275202762027720278202792028020281202822028320284202852028620287202882028920290202912029220293202942029520296202972029820299203002030120302203032030420305203062030720308203092031020311203122031320314203152031620317203182031920320203212032220323203242032520326203272032820329203302033120332203332033420335203362033720338203392034020341203422034320344203452034620347203482034920350203512035220353203542035520356203572035820359203602036120362203632036420365203662036720368203692037020371203722037320374203752037620377203782037920380203812038220383203842038520386203872038820389203902039120392203932039420395203962039720398203992040020401204022040320404204052040620407204082040920410204112041220413204142041520416204172041820419204202042120422204232042420425204262042720428204292043020431204322043320434204352043620437204382043920440204412044220443204442044520446204472044820449204502045120452204532045420455204562045720458204592046020461204622046320464204652046620467204682046920470204712047220473204742047520476204772047820479204802048120482204832048420485204862048720488204892049020491204922049320494204952049620497204982049920500205012050220503205042050520506205072050820509205102051120512205132051420515205162051720518205192052020521205222052320524205252052620527205282052920530205312053220533205342053520536205372053820539205402054120542205432054420545205462054720548205492055020551205522055320554205552055620557205582055920560205612056220563205642056520566205672056820569205702057120572205732057420575205762057720578205792058020581205822058320584205852058620587205882058920590205912059220593205942059520596205972059820599206002060120602206032060420605206062060720608206092061020611206122061320614206152061620617206182061920620206212062220623206242062520626206272062820629206302063120632206332063420635206362063720638206392064020641206422064320644206452064620647206482064920650206512065220653206542065520656206572065820659206602066120662206632066420665206662066720668206692067020671206722067320674206752067620677206782067920680206812068220683206842068520686206872068820689206902069120692206932069420695206962069720698206992070020701207022070320704207052070620707207082070920710207112071220713207142071520716207172071820719207202072120722207232072420725207262072720728207292073020731207322073320734207352073620737207382073920740207412074220743207442074520746207472074820749207502075120752207532075420755207562075720758207592076020761207622076320764207652076620767207682076920770207712077220773207742077520776207772077820779207802078120782207832078420785207862078720788207892079020791207922079320794207952079620797207982079920800208012080220803208042080520806208072080820809208102081120812208132081420815208162081720818208192082020821208222082320824208252082620827208282082920830208312083220833208342083520836208372083820839208402084120842208432084420845208462084720848208492085020851208522085320854208552085620857208582085920860208612086220863208642086520866208672086820869208702087120872208732087420875208762087720878208792088020881208822088320884208852088620887208882088920890208912089220893208942089520896208972089820899209002090120902209032090420905209062090720908209092091020911209122091320914209152091620917209182091920920209212092220923209242092520926209272092820929209302093120932209332093420935209362093720938209392094020941209422094320944209452094620947209482094920950209512095220953209542095520956209572095820959209602096120962209632096420965209662096720968209692097020971209722097320974209752097620977209782097920980209812098220983209842098520986209872098820989209902099120992209932099420995209962099720998209992100021001210022100321004210052100621007210082100921010210112101221013210142101521016210172101821019210202102121022210232102421025210262102721028210292103021031210322103321034210352103621037210382103921040210412104221043210442104521046210472104821049210502105121052210532105421055210562105721058210592106021061210622106321064210652106621067210682106921070210712107221073210742107521076210772107821079210802108121082210832108421085210862108721088210892109021091210922109321094210952109621097210982109921100211012110221103211042110521106211072110821109211102111121112211132111421115211162111721118211192112021121211222112321124211252112621127211282112921130211312113221133211342113521136211372113821139211402114121142211432114421145211462114721148211492115021151211522115321154211552115621157211582115921160211612116221163211642116521166211672116821169211702117121172211732117421175211762117721178211792118021181211822118321184211852118621187211882118921190211912119221193211942119521196211972119821199212002120121202212032120421205212062120721208212092121021211212122121321214212152121621217212182121921220212212122221223212242122521226212272122821229212302123121232212332123421235212362123721238212392124021241212422124321244212452124621247212482124921250212512125221253212542125521256212572125821259212602126121262212632126421265212662126721268212692127021271212722127321274212752127621277212782127921280212812128221283212842128521286212872128821289212902129121292212932129421295212962129721298212992130021301213022130321304213052130621307213082130921310213112131221313213142131521316213172131821319213202132121322213232132421325213262132721328213292133021331213322133321334213352133621337213382133921340213412134221343213442134521346213472134821349213502135121352213532135421355213562135721358213592136021361213622136321364213652136621367213682136921370213712137221373213742137521376213772137821379213802138121382213832138421385213862138721388213892139021391213922139321394213952139621397213982139921400214012140221403214042140521406214072140821409214102141121412214132141421415214162141721418214192142021421214222142321424214252142621427214282142921430214312143221433214342143521436214372143821439214402144121442214432144421445214462144721448214492145021451214522145321454214552145621457214582145921460214612146221463214642146521466214672146821469214702147121472214732147421475214762147721478214792148021481214822148321484214852148621487214882148921490214912149221493214942149521496214972149821499215002150121502215032150421505215062150721508215092151021511215122151321514215152151621517215182151921520215212152221523215242152521526215272152821529215302153121532215332153421535215362153721538215392154021541215422154321544215452154621547215482154921550215512155221553215542155521556215572155821559215602156121562215632156421565215662156721568215692157021571215722157321574215752157621577215782157921580215812158221583215842158521586215872158821589215902159121592215932159421595215962159721598215992160021601216022160321604216052160621607216082160921610216112161221613216142161521616216172161821619216202162121622216232162421625216262162721628216292163021631216322163321634216352163621637216382163921640216412164221643216442164521646216472164821649216502165121652216532165421655216562165721658216592166021661216622166321664216652166621667216682166921670216712167221673216742167521676216772167821679216802168121682216832168421685216862168721688216892169021691216922169321694216952169621697216982169921700217012170221703217042170521706217072170821709217102171121712217132171421715217162171721718217192172021721217222172321724217252172621727217282172921730217312173221733217342173521736217372173821739217402174121742217432174421745217462174721748217492175021751217522175321754217552175621757217582175921760217612176221763217642176521766217672176821769217702177121772217732177421775217762177721778217792178021781217822178321784217852178621787217882178921790217912179221793217942179521796217972179821799218002180121802218032180421805218062180721808218092181021811218122181321814218152181621817218182181921820218212182221823218242182521826218272182821829218302183121832218332183421835218362183721838218392184021841218422184321844218452184621847218482184921850218512185221853218542185521856218572185821859218602186121862218632186421865218662186721868218692187021871218722187321874218752187621877218782187921880218812188221883218842188521886218872188821889218902189121892218932189421895218962189721898218992190021901219022190321904219052190621907219082190921910219112191221913219142191521916219172191821919219202192121922219232192421925219262192721928219292193021931219322193321934219352193621937219382193921940219412194221943219442194521946219472194821949219502195121952219532195421955219562195721958219592196021961219622196321964219652196621967219682196921970219712197221973219742197521976219772197821979219802198121982219832198421985219862198721988219892199021991219922199321994219952199621997219982199922000220012200222003220042200522006220072200822009220102201122012220132201422015220162201722018220192202022021220222202322024220252202622027220282202922030220312203222033220342203522036220372203822039220402204122042220432204422045220462204722048220492205022051220522205322054220552205622057220582205922060220612206222063220642206522066220672206822069220702207122072220732207422075220762207722078220792208022081220822208322084220852208622087220882208922090220912209222093220942209522096220972209822099221002210122102221032210422105221062210722108221092211022111221122211322114221152211622117221182211922120221212212222123221242212522126221272212822129221302213122132221332213422135221362213722138221392214022141221422214322144221452214622147221482214922150221512215222153221542215522156221572215822159221602216122162221632216422165221662216722168221692217022171221722217322174221752217622177221782217922180221812218222183221842218522186221872218822189221902219122192221932219422195221962219722198221992220022201222022220322204222052220622207222082220922210222112221222213222142221522216222172221822219222202222122222222232222422225222262222722228222292223022231222322223322234222352223622237222382223922240222412224222243222442224522246222472224822249222502225122252222532225422255222562225722258222592226022261222622226322264222652226622267222682226922270222712227222273222742227522276222772227822279222802228122282222832228422285222862228722288222892229022291222922229322294222952229622297222982229922300223012230222303223042230522306223072230822309223102231122312223132231422315223162231722318223192232022321223222232322324223252232622327223282232922330223312233222333223342233522336223372233822339223402234122342223432234422345223462234722348223492235022351223522235322354223552235622357223582235922360223612236222363223642236522366223672236822369223702237122372223732237422375223762237722378223792238022381223822238322384223852238622387223882238922390223912239222393223942239522396223972239822399224002240122402224032240422405224062240722408224092241022411224122241322414224152241622417224182241922420224212242222423224242242522426224272242822429224302243122432224332243422435224362243722438224392244022441224422244322444224452244622447224482244922450224512245222453224542245522456224572245822459224602246122462224632246422465224662246722468224692247022471224722247322474224752247622477224782247922480224812248222483224842248522486224872248822489224902249122492224932249422495224962249722498224992250022501225022250322504225052250622507225082250922510225112251222513225142251522516225172251822519225202252122522225232252422525225262252722528225292253022531225322253322534225352253622537225382253922540225412254222543225442254522546225472254822549225502255122552225532255422555225562255722558225592256022561225622256322564225652256622567225682256922570225712257222573225742257522576225772257822579225802258122582225832258422585225862258722588225892259022591225922259322594225952259622597225982259922600226012260222603226042260522606226072260822609226102261122612226132261422615226162261722618226192262022621226222262322624226252262622627226282262922630226312263222633226342263522636226372263822639226402264122642226432264422645226462264722648226492265022651226522265322654226552265622657226582265922660226612266222663226642266522666226672266822669226702267122672226732267422675226762267722678226792268022681226822268322684226852268622687226882268922690226912269222693226942269522696226972269822699227002270122702227032270422705227062270722708227092271022711227122271322714227152271622717227182271922720227212272222723227242272522726227272272822729227302273122732227332273422735227362273722738227392274022741227422274322744227452274622747227482274922750227512275222753227542275522756227572275822759227602276122762227632276422765227662276722768227692277022771227722277322774227752277622777227782277922780227812278222783227842278522786227872278822789227902279122792227932279422795227962279722798227992280022801228022280322804228052280622807228082280922810228112281222813228142281522816228172281822819228202282122822228232282422825228262282722828228292283022831228322283322834228352283622837228382283922840228412284222843228442284522846228472284822849228502285122852228532285422855228562285722858228592286022861228622286322864228652286622867228682286922870228712287222873228742287522876228772287822879228802288122882228832288422885228862288722888228892289022891228922289322894228952289622897228982289922900229012290222903229042290522906229072290822909229102291122912229132291422915229162291722918229192292022921229222292322924229252292622927229282292922930229312293222933229342293522936229372293822939229402294122942229432294422945229462294722948229492295022951229522295322954229552295622957229582295922960229612296222963229642296522966229672296822969229702297122972229732297422975229762297722978229792298022981229822298322984229852298622987229882298922990229912299222993229942299522996229972299822999230002300123002230032300423005230062300723008230092301023011230122301323014230152301623017230182301923020230212302223023230242302523026230272302823029230302303123032230332303423035230362303723038230392304023041230422304323044230452304623047230482304923050230512305223053230542305523056230572305823059230602306123062230632306423065230662306723068230692307023071230722307323074230752307623077230782307923080230812308223083230842308523086230872308823089230902309123092230932309423095230962309723098230992310023101231022310323104231052310623107231082310923110231112311223113231142311523116231172311823119231202312123122231232312423125231262312723128231292313023131231322313323134231352313623137231382313923140231412314223143231442314523146231472314823149231502315123152231532315423155231562315723158231592316023161231622316323164231652316623167231682316923170231712317223173231742317523176231772317823179231802318123182231832318423185231862318723188231892319023191231922319323194231952319623197231982319923200232012320223203232042320523206232072320823209232102321123212232132321423215232162321723218232192322023221232222322323224232252322623227232282322923230232312323223233232342323523236232372323823239232402324123242232432324423245232462324723248232492325023251232522325323254232552325623257232582325923260232612326223263232642326523266232672326823269232702327123272232732327423275232762327723278232792328023281232822328323284232852328623287232882328923290232912329223293232942329523296232972329823299233002330123302233032330423305233062330723308233092331023311233122331323314233152331623317233182331923320233212332223323233242332523326233272332823329233302333123332233332333423335233362333723338233392334023341233422334323344233452334623347233482334923350233512335223353233542335523356233572335823359233602336123362233632336423365233662336723368233692337023371233722337323374233752337623377233782337923380233812338223383233842338523386233872338823389233902339123392233932339423395233962339723398233992340023401234022340323404234052340623407234082340923410234112341223413234142341523416234172341823419234202342123422234232342423425234262342723428234292343023431234322343323434234352343623437234382343923440234412344223443234442344523446234472344823449234502345123452234532345423455234562345723458234592346023461234622346323464234652346623467234682346923470234712347223473234742347523476234772347823479234802348123482234832348423485234862348723488234892349023491234922349323494234952349623497234982349923500235012350223503235042350523506235072350823509235102351123512235132351423515235162351723518235192352023521235222352323524235252352623527235282352923530235312353223533235342353523536235372353823539235402354123542235432354423545235462354723548235492355023551235522355323554235552355623557235582355923560235612356223563235642356523566235672356823569235702357123572235732357423575235762357723578235792358023581235822358323584235852358623587235882358923590235912359223593235942359523596235972359823599236002360123602236032360423605236062360723608236092361023611236122361323614236152361623617236182361923620236212362223623236242362523626236272362823629236302363123632236332363423635236362363723638236392364023641236422364323644236452364623647236482364923650236512365223653236542365523656236572365823659236602366123662236632366423665236662366723668236692367023671236722367323674236752367623677236782367923680236812368223683236842368523686236872368823689236902369123692236932369423695236962369723698236992370023701237022370323704237052370623707237082370923710237112371223713237142371523716237172371823719237202372123722237232372423725237262372723728237292373023731237322373323734237352373623737237382373923740237412374223743237442374523746237472374823749237502375123752237532375423755237562375723758237592376023761237622376323764237652376623767237682376923770237712377223773237742377523776237772377823779237802378123782237832378423785237862378723788237892379023791237922379323794237952379623797237982379923800238012380223803238042380523806238072380823809238102381123812238132381423815238162381723818238192382023821238222382323824238252382623827238282382923830238312383223833238342383523836238372383823839238402384123842238432384423845238462384723848238492385023851238522385323854238552385623857238582385923860238612386223863238642386523866238672386823869238702387123872238732387423875238762387723878238792388023881238822388323884238852388623887238882388923890238912389223893238942389523896238972389823899239002390123902239032390423905239062390723908239092391023911239122391323914239152391623917239182391923920239212392223923239242392523926239272392823929239302393123932239332393423935239362393723938239392394023941239422394323944239452394623947239482394923950239512395223953239542395523956239572395823959239602396123962239632396423965239662396723968239692397023971239722397323974239752397623977239782397923980239812398223983239842398523986239872398823989239902399123992239932399423995239962399723998239992400024001240022400324004240052400624007240082400924010240112401224013240142401524016240172401824019240202402124022240232402424025240262402724028240292403024031240322403324034240352403624037240382403924040240412404224043240442404524046240472404824049240502405124052240532405424055240562405724058240592406024061240622406324064240652406624067240682406924070240712407224073240742407524076240772407824079240802408124082240832408424085240862408724088240892409024091240922409324094240952409624097240982409924100241012410224103241042410524106241072410824109241102411124112241132411424115241162411724118241192412024121241222412324124241252412624127241282412924130241312413224133241342413524136241372413824139241402414124142241432414424145241462414724148241492415024151241522415324154241552415624157241582415924160241612416224163241642416524166241672416824169241702417124172241732417424175241762417724178241792418024181241822418324184241852418624187241882418924190241912419224193241942419524196241972419824199242002420124202242032420424205242062420724208242092421024211242122421324214242152421624217242182421924220242212422224223242242422524226242272422824229242302423124232242332423424235242362423724238242392424024241242422424324244242452424624247242482424924250242512425224253242542425524256242572425824259242602426124262242632426424265242662426724268242692427024271242722427324274242752427624277242782427924280242812428224283242842428524286242872428824289242902429124292242932429424295242962429724298242992430024301243022430324304243052430624307243082430924310243112431224313243142431524316243172431824319243202432124322243232432424325243262432724328243292433024331243322433324334243352433624337243382433924340243412434224343243442434524346243472434824349243502435124352243532435424355243562435724358243592436024361243622436324364243652436624367243682436924370243712437224373243742437524376243772437824379243802438124382243832438424385243862438724388243892439024391243922439324394243952439624397243982439924400244012440224403244042440524406244072440824409244102441124412244132441424415244162441724418244192442024421244222442324424244252442624427244282442924430244312443224433244342443524436244372443824439244402444124442244432444424445244462444724448244492445024451244522445324454244552445624457244582445924460244612446224463244642446524466244672446824469244702447124472244732447424475244762447724478244792448024481244822448324484244852448624487244882448924490244912449224493244942449524496244972449824499245002450124502245032450424505245062450724508245092451024511245122451324514245152451624517245182451924520245212452224523245242452524526245272452824529245302453124532245332453424535245362453724538245392454024541245422454324544245452454624547245482454924550245512455224553245542455524556245572455824559245602456124562245632456424565245662456724568245692457024571245722457324574245752457624577245782457924580245812458224583245842458524586245872458824589245902459124592245932459424595245962459724598245992460024601246022460324604246052460624607246082460924610246112461224613246142461524616246172461824619246202462124622246232462424625246262462724628246292463024631246322463324634246352463624637246382463924640246412464224643246442464524646246472464824649246502465124652246532465424655246562465724658246592466024661246622466324664246652466624667246682466924670246712467224673246742467524676246772467824679246802468124682246832468424685246862468724688246892469024691246922469324694246952469624697246982469924700247012470224703247042470524706247072470824709247102471124712247132471424715247162471724718247192472024721247222472324724247252472624727247282472924730247312473224733247342473524736247372473824739247402474124742247432474424745247462474724748247492475024751247522475324754247552475624757247582475924760247612476224763247642476524766247672476824769247702477124772247732477424775247762477724778247792478024781247822478324784247852478624787247882478924790247912479224793247942479524796247972479824799248002480124802248032480424805248062480724808248092481024811248122481324814248152481624817248182481924820248212482224823248242482524826248272482824829248302483124832248332483424835248362483724838248392484024841248422484324844248452484624847248482484924850248512485224853248542485524856248572485824859248602486124862248632486424865248662486724868248692487024871248722487324874248752487624877248782487924880248812488224883248842488524886248872488824889248902489124892248932489424895248962489724898248992490024901249022490324904249052490624907249082490924910249112491224913249142491524916249172491824919249202492124922249232492424925249262492724928249292493024931249322493324934249352493624937249382493924940249412494224943249442494524946249472494824949249502495124952249532495424955249562495724958249592496024961249622496324964249652496624967249682496924970249712497224973249742497524976249772497824979249802498124982249832498424985249862498724988249892499024991249922499324994249952499624997249982499925000250012500225003250042500525006250072500825009250102501125012250132501425015250162501725018250192502025021250222502325024250252502625027250282502925030250312503225033250342503525036250372503825039250402504125042250432504425045250462504725048250492505025051250522505325054250552505625057250582505925060250612506225063250642506525066250672506825069250702507125072250732507425075250762507725078250792508025081250822508325084250852508625087250882508925090250912509225093250942509525096250972509825099251002510125102251032510425105251062510725108251092511025111251122511325114251152511625117251182511925120251212512225123251242512525126251272512825129251302513125132251332513425135251362513725138251392514025141251422514325144251452514625147251482514925150251512515225153251542515525156251572515825159251602516125162251632516425165251662516725168251692517025171251722517325174251752517625177251782517925180251812518225183251842518525186251872518825189251902519125192251932519425195251962519725198251992520025201252022520325204252052520625207252082520925210252112521225213252142521525216252172521825219252202522125222252232522425225252262522725228252292523025231252322523325234252352523625237252382523925240252412524225243252442524525246252472524825249252502525125252252532525425255252562525725258252592526025261252622526325264252652526625267252682526925270252712527225273252742527525276252772527825279252802528125282252832528425285252862528725288252892529025291252922529325294252952529625297252982529925300253012530225303253042530525306253072530825309253102531125312253132531425315253162531725318253192532025321253222532325324253252532625327253282532925330253312533225333253342533525336253372533825339253402534125342253432534425345253462534725348253492535025351253522535325354253552535625357253582535925360253612536225363253642536525366253672536825369253702537125372253732537425375253762537725378253792538025381253822538325384253852538625387253882538925390253912539225393253942539525396253972539825399254002540125402254032540425405254062540725408254092541025411254122541325414254152541625417254182541925420254212542225423254242542525426254272542825429254302543125432254332543425435254362543725438254392544025441254422544325444254452544625447254482544925450254512545225453254542545525456254572545825459254602546125462254632546425465254662546725468254692547025471254722547325474254752547625477254782547925480254812548225483254842548525486254872548825489254902549125492254932549425495254962549725498254992550025501255022550325504255052550625507255082550925510255112551225513255142551525516255172551825519255202552125522255232552425525255262552725528255292553025531255322553325534255352553625537255382553925540255412554225543255442554525546255472554825549255502555125552255532555425555255562555725558255592556025561255622556325564255652556625567255682556925570255712557225573255742557525576255772557825579255802558125582255832558425585255862558725588255892559025591255922559325594255952559625597255982559925600256012560225603256042560525606256072560825609256102561125612256132561425615256162561725618256192562025621256222562325624256252562625627256282562925630256312563225633256342563525636256372563825639256402564125642256432564425645256462564725648256492565025651256522565325654256552565625657256582565925660256612566225663256642566525666256672566825669256702567125672256732567425675256762567725678256792568025681256822568325684256852568625687256882568925690256912569225693256942569525696256972569825699257002570125702257032570425705257062570725708257092571025711257122571325714257152571625717257182571925720257212572225723257242572525726257272572825729257302573125732257332573425735257362573725738257392574025741257422574325744257452574625747257482574925750257512575225753257542575525756257572575825759257602576125762257632576425765257662576725768257692577025771257722577325774257752577625777257782577925780257812578225783257842578525786257872578825789257902579125792257932579425795257962579725798257992580025801258022580325804258052580625807258082580925810258112581225813258142581525816258172581825819258202582125822258232582425825258262582725828258292583025831258322583325834258352583625837258382583925840258412584225843258442584525846258472584825849258502585125852258532585425855258562585725858258592586025861258622586325864258652586625867258682586925870258712587225873258742587525876258772587825879258802588125882258832588425885258862588725888258892589025891258922589325894258952589625897258982589925900259012590225903259042590525906259072590825909259102591125912259132591425915259162591725918259192592025921259222592325924259252592625927259282592925930259312593225933259342593525936259372593825939259402594125942259432594425945259462594725948259492595025951259522595325954259552595625957259582595925960259612596225963259642596525966259672596825969259702597125972259732597425975259762597725978259792598025981259822598325984259852598625987259882598925990259912599225993259942599525996259972599825999260002600126002260032600426005260062600726008260092601026011260122601326014260152601626017260182601926020260212602226023260242602526026260272602826029260302603126032260332603426035260362603726038260392604026041260422604326044260452604626047260482604926050260512605226053260542605526056260572605826059260602606126062260632606426065260662606726068260692607026071260722607326074260752607626077260782607926080260812608226083260842608526086260872608826089260902609126092260932609426095260962609726098260992610026101261022610326104261052610626107261082610926110261112611226113261142611526116261172611826119261202612126122261232612426125261262612726128261292613026131261322613326134261352613626137261382613926140261412614226143261442614526146261472614826149261502615126152261532615426155261562615726158261592616026161261622616326164261652616626167261682616926170261712617226173261742617526176261772617826179261802618126182261832618426185261862618726188261892619026191261922619326194261952619626197261982619926200262012620226203262042620526206262072620826209262102621126212262132621426215262162621726218262192622026221262222622326224262252622626227262282622926230262312623226233262342623526236262372623826239262402624126242262432624426245262462624726248262492625026251262522625326254262552625626257262582625926260262612626226263262642626526266262672626826269262702627126272262732627426275262762627726278262792628026281262822628326284262852628626287262882628926290262912629226293262942629526296262972629826299263002630126302263032630426305263062630726308263092631026311263122631326314263152631626317263182631926320263212632226323263242632526326263272632826329263302633126332263332633426335263362633726338263392634026341263422634326344263452634626347263482634926350263512635226353263542635526356263572635826359263602636126362263632636426365263662636726368263692637026371263722637326374263752637626377263782637926380263812638226383263842638526386263872638826389263902639126392263932639426395263962639726398263992640026401264022640326404264052640626407264082640926410264112641226413264142641526416264172641826419264202642126422264232642426425264262642726428264292643026431264322643326434264352643626437264382643926440264412644226443264442644526446264472644826449264502645126452264532645426455264562645726458264592646026461264622646326464264652646626467264682646926470264712647226473264742647526476264772647826479264802648126482264832648426485264862648726488264892649026491264922649326494264952649626497264982649926500265012650226503265042650526506265072650826509265102651126512265132651426515265162651726518265192652026521265222652326524265252652626527265282652926530265312653226533265342653526536265372653826539265402654126542265432654426545265462654726548265492655026551265522655326554265552655626557265582655926560265612656226563265642656526566265672656826569265702657126572265732657426575265762657726578265792658026581265822658326584265852658626587265882658926590265912659226593265942659526596265972659826599266002660126602266032660426605266062660726608266092661026611266122661326614266152661626617266182661926620266212662226623266242662526626266272662826629266302663126632266332663426635266362663726638266392664026641266422664326644266452664626647266482664926650266512665226653266542665526656266572665826659266602666126662266632666426665266662666726668266692667026671266722667326674266752667626677266782667926680266812668226683266842668526686266872668826689266902669126692266932669426695266962669726698266992670026701267022670326704267052670626707267082670926710267112671226713267142671526716267172671826719267202672126722267232672426725267262672726728267292673026731267322673326734267352673626737267382673926740267412674226743267442674526746267472674826749267502675126752267532675426755267562675726758267592676026761267622676326764267652676626767267682676926770267712677226773267742677526776267772677826779267802678126782267832678426785267862678726788267892679026791267922679326794267952679626797267982679926800268012680226803268042680526806268072680826809268102681126812268132681426815268162681726818268192682026821268222682326824268252682626827268282682926830268312683226833268342683526836268372683826839268402684126842268432684426845268462684726848268492685026851268522685326854268552685626857268582685926860268612686226863268642686526866268672686826869268702687126872268732687426875268762687726878268792688026881268822688326884268852688626887268882688926890268912689226893268942689526896268972689826899269002690126902269032690426905269062690726908269092691026911269122691326914269152691626917269182691926920269212692226923269242692526926269272692826929269302693126932269332693426935269362693726938269392694026941269422694326944269452694626947269482694926950269512695226953269542695526956269572695826959269602696126962269632696426965269662696726968269692697026971269722697326974269752697626977269782697926980269812698226983269842698526986269872698826989269902699126992269932699426995269962699726998269992700027001270022700327004270052700627007270082700927010270112701227013270142701527016270172701827019270202702127022270232702427025270262702727028270292703027031270322703327034270352703627037270382703927040270412704227043270442704527046270472704827049270502705127052270532705427055270562705727058270592706027061270622706327064270652706627067270682706927070270712707227073270742707527076270772707827079270802708127082270832708427085270862708727088270892709027091270922709327094270952709627097270982709927100271012710227103271042710527106271072710827109271102711127112271132711427115271162711727118271192712027121271222712327124271252712627127271282712927130271312713227133271342713527136271372713827139271402714127142271432714427145271462714727148271492715027151271522715327154271552715627157271582715927160271612716227163271642716527166271672716827169271702717127172271732717427175271762717727178271792718027181271822718327184271852718627187271882718927190271912719227193271942719527196271972719827199272002720127202272032720427205272062720727208272092721027211272122721327214272152721627217272182721927220272212722227223272242722527226272272722827229272302723127232272332723427235272362723727238272392724027241272422724327244272452724627247272482724927250272512725227253272542725527256272572725827259272602726127262272632726427265272662726727268272692727027271272722727327274272752727627277272782727927280272812728227283272842728527286272872728827289272902729127292272932729427295272962729727298272992730027301273022730327304273052730627307273082730927310273112731227313273142731527316273172731827319273202732127322273232732427325273262732727328273292733027331273322733327334273352733627337273382733927340273412734227343273442734527346273472734827349273502735127352273532735427355273562735727358273592736027361273622736327364273652736627367273682736927370273712737227373273742737527376273772737827379273802738127382273832738427385273862738727388273892739027391273922739327394273952739627397273982739927400274012740227403274042740527406274072740827409274102741127412274132741427415274162741727418274192742027421274222742327424274252742627427274282742927430274312743227433274342743527436274372743827439274402744127442274432744427445274462744727448274492745027451274522745327454274552745627457274582745927460274612746227463274642746527466274672746827469274702747127472274732747427475274762747727478274792748027481274822748327484274852748627487274882748927490274912749227493274942749527496274972749827499275002750127502275032750427505275062750727508275092751027511275122751327514275152751627517275182751927520275212752227523275242752527526275272752827529275302753127532275332753427535275362753727538275392754027541275422754327544275452754627547275482754927550275512755227553275542755527556275572755827559275602756127562275632756427565275662756727568275692757027571275722757327574275752757627577275782757927580275812758227583275842758527586275872758827589275902759127592275932759427595275962759727598275992760027601276022760327604276052760627607276082760927610276112761227613276142761527616276172761827619276202762127622276232762427625276262762727628276292763027631276322763327634276352763627637276382763927640276412764227643276442764527646276472764827649276502765127652276532765427655276562765727658276592766027661276622766327664276652766627667276682766927670276712767227673276742767527676276772767827679276802768127682276832768427685276862768727688276892769027691276922769327694276952769627697276982769927700277012770227703277042770527706277072770827709277102771127712277132771427715277162771727718277192772027721277222772327724277252772627727277282772927730277312773227733277342773527736277372773827739277402774127742277432774427745277462774727748277492775027751277522775327754277552775627757277582775927760277612776227763277642776527766277672776827769277702777127772277732777427775277762777727778277792778027781277822778327784277852778627787277882778927790277912779227793277942779527796277972779827799278002780127802278032780427805278062780727808278092781027811278122781327814278152781627817278182781927820278212782227823278242782527826278272782827829278302783127832278332783427835278362783727838278392784027841278422784327844278452784627847278482784927850278512785227853278542785527856278572785827859278602786127862278632786427865278662786727868278692787027871278722787327874278752787627877278782787927880278812788227883278842788527886278872788827889278902789127892278932789427895278962789727898278992790027901279022790327904279052790627907279082790927910279112791227913279142791527916279172791827919279202792127922279232792427925279262792727928279292793027931279322793327934279352793627937279382793927940279412794227943279442794527946279472794827949279502795127952279532795427955279562795727958279592796027961279622796327964279652796627967279682796927970279712797227973279742797527976279772797827979279802798127982279832798427985279862798727988279892799027991279922799327994279952799627997279982799928000280012800228003280042800528006280072800828009280102801128012280132801428015280162801728018280192802028021280222802328024280252802628027280282802928030280312803228033280342803528036280372803828039280402804128042280432804428045280462804728048280492805028051280522805328054280552805628057280582805928060280612806228063280642806528066280672806828069280702807128072280732807428075280762807728078280792808028081280822808328084280852808628087280882808928090280912809228093280942809528096280972809828099281002810128102281032810428105281062810728108281092811028111281122811328114281152811628117281182811928120281212812228123281242812528126281272812828129281302813128132281332813428135281362813728138281392814028141281422814328144281452814628147281482814928150281512815228153281542815528156281572815828159281602816128162281632816428165281662816728168281692817028171281722817328174281752817628177281782817928180281812818228183281842818528186281872818828189281902819128192281932819428195281962819728198281992820028201282022820328204282052820628207282082820928210282112821228213282142821528216282172821828219282202822128222282232822428225282262822728228282292823028231282322823328234282352823628237282382823928240282412824228243282442824528246282472824828249282502825128252282532825428255282562825728258282592826028261282622826328264282652826628267282682826928270282712827228273282742827528276282772827828279282802828128282282832828428285282862828728288282892829028291282922829328294282952829628297282982829928300283012830228303283042830528306283072830828309283102831128312283132831428315283162831728318283192832028321283222832328324283252832628327283282832928330283312833228333283342833528336283372833828339283402834128342283432834428345283462834728348283492835028351283522835328354283552835628357283582835928360283612836228363283642836528366283672836828369283702837128372283732837428375283762837728378283792838028381283822838328384283852838628387283882838928390283912839228393283942839528396283972839828399284002840128402284032840428405284062840728408284092841028411284122841328414284152841628417284182841928420284212842228423284242842528426284272842828429284302843128432284332843428435284362843728438284392844028441284422844328444284452844628447284482844928450284512845228453284542845528456284572845828459284602846128462284632846428465284662846728468284692847028471284722847328474284752847628477284782847928480284812848228483284842848528486284872848828489284902849128492284932849428495284962849728498284992850028501285022850328504285052850628507285082850928510285112851228513285142851528516285172851828519285202852128522285232852428525285262852728528285292853028531285322853328534285352853628537285382853928540285412854228543285442854528546285472854828549285502855128552285532855428555285562855728558285592856028561285622856328564285652856628567285682856928570285712857228573285742857528576285772857828579285802858128582285832858428585285862858728588285892859028591285922859328594285952859628597285982859928600286012860228603286042860528606286072860828609286102861128612286132861428615286162861728618286192862028621286222862328624286252862628627286282862928630286312863228633286342863528636286372863828639286402864128642286432864428645286462864728648286492865028651286522865328654286552865628657286582865928660286612866228663286642866528666286672866828669286702867128672286732867428675286762867728678286792868028681286822868328684286852868628687286882868928690286912869228693286942869528696286972869828699287002870128702287032870428705287062870728708287092871028711287122871328714287152871628717287182871928720287212872228723287242872528726287272872828729287302873128732287332873428735287362873728738287392874028741287422874328744287452874628747287482874928750287512875228753287542875528756287572875828759287602876128762287632876428765287662876728768287692877028771287722877328774287752877628777287782877928780287812878228783287842878528786287872878828789287902879128792287932879428795287962879728798287992880028801288022880328804288052880628807288082880928810288112881228813288142881528816288172881828819288202882128822288232882428825288262882728828288292883028831288322883328834288352883628837288382883928840288412884228843288442884528846288472884828849288502885128852288532885428855288562885728858288592886028861288622886328864288652886628867288682886928870288712887228873288742887528876288772887828879288802888128882288832888428885288862888728888288892889028891288922889328894288952889628897288982889928900289012890228903289042890528906289072890828909289102891128912289132891428915289162891728918289192892028921289222892328924289252892628927289282892928930289312893228933289342893528936289372893828939289402894128942289432894428945289462894728948289492895028951289522895328954289552895628957289582895928960289612896228963289642896528966289672896828969289702897128972289732897428975289762897728978289792898028981289822898328984289852898628987289882898928990289912899228993289942899528996289972899828999290002900129002290032900429005290062900729008290092901029011290122901329014290152901629017290182901929020290212902229023290242902529026290272902829029290302903129032290332903429035290362903729038290392904029041290422904329044290452904629047290482904929050290512905229053290542905529056290572905829059290602906129062290632906429065290662906729068290692907029071290722907329074290752907629077290782907929080290812908229083290842908529086290872908829089290902909129092290932909429095290962909729098290992910029101291022910329104291052910629107291082910929110291112911229113291142911529116291172911829119291202912129122291232912429125291262912729128291292913029131291322913329134291352913629137291382913929140291412914229143291442914529146291472914829149291502915129152291532915429155291562915729158291592916029161291622916329164291652916629167291682916929170291712917229173291742917529176291772917829179291802918129182291832918429185291862918729188291892919029191291922919329194291952919629197291982919929200292012920229203292042920529206292072920829209292102921129212292132921429215292162921729218292192922029221292222922329224292252922629227292282922929230292312923229233292342923529236292372923829239292402924129242292432924429245292462924729248292492925029251292522925329254292552925629257292582925929260292612926229263292642926529266292672926829269292702927129272292732927429275292762927729278292792928029281292822928329284292852928629287292882928929290292912929229293292942929529296292972929829299293002930129302293032930429305293062930729308293092931029311293122931329314293152931629317293182931929320293212932229323293242932529326293272932829329293302933129332293332933429335293362933729338293392934029341293422934329344293452934629347293482934929350293512935229353293542935529356293572935829359293602936129362293632936429365293662936729368293692937029371293722937329374293752937629377293782937929380293812938229383293842938529386293872938829389293902939129392293932939429395293962939729398293992940029401294022940329404294052940629407294082940929410294112941229413294142941529416294172941829419294202942129422294232942429425294262942729428294292943029431294322943329434294352943629437294382943929440294412944229443294442944529446294472944829449294502945129452294532945429455294562945729458294592946029461294622946329464294652946629467294682946929470294712947229473294742947529476294772947829479294802948129482294832948429485294862948729488294892949029491294922949329494294952949629497294982949929500295012950229503295042950529506295072950829509295102951129512295132951429515295162951729518295192952029521295222952329524295252952629527295282952929530295312953229533295342953529536295372953829539295402954129542295432954429545295462954729548295492955029551295522955329554295552955629557295582955929560295612956229563295642956529566295672956829569295702957129572295732957429575295762957729578295792958029581295822958329584295852958629587295882958929590295912959229593295942959529596295972959829599296002960129602296032960429605296062960729608296092961029611296122961329614296152961629617296182961929620296212962229623296242962529626296272962829629296302963129632296332963429635296362963729638296392964029641296422964329644296452964629647296482964929650296512965229653296542965529656296572965829659296602966129662296632966429665296662966729668296692967029671296722967329674296752967629677296782967929680296812968229683296842968529686296872968829689296902969129692296932969429695296962969729698296992970029701297022970329704297052970629707297082970929710297112971229713297142971529716297172971829719297202972129722297232972429725297262972729728297292973029731297322973329734297352973629737297382973929740297412974229743297442974529746297472974829749297502975129752297532975429755297562975729758297592976029761297622976329764297652976629767297682976929770297712977229773297742977529776297772977829779297802978129782297832978429785297862978729788297892979029791297922979329794297952979629797297982979929800298012980229803298042980529806298072980829809298102981129812298132981429815298162981729818298192982029821298222982329824298252982629827298282982929830298312983229833298342983529836298372983829839298402984129842298432984429845298462984729848298492985029851298522985329854298552985629857298582985929860298612986229863298642986529866298672986829869298702987129872298732987429875298762987729878298792988029881298822988329884298852988629887298882988929890298912989229893298942989529896298972989829899299002990129902299032990429905299062990729908299092991029911299122991329914299152991629917299182991929920299212992229923299242992529926299272992829929299302993129932299332993429935299362993729938299392994029941299422994329944299452994629947299482994929950299512995229953299542995529956299572995829959299602996129962299632996429965299662996729968299692997029971299722997329974299752997629977299782997929980299812998229983299842998529986299872998829989299902999129992299932999429995299962999729998299993000030001300023000330004300053000630007300083000930010300113001230013300143001530016300173001830019300203002130022300233002430025300263002730028300293003030031300323003330034300353003630037300383003930040300413004230043300443004530046300473004830049300503005130052300533005430055300563005730058300593006030061300623006330064300653006630067300683006930070300713007230073300743007530076300773007830079300803008130082300833008430085300863008730088300893009030091300923009330094300953009630097300983009930100301013010230103301043010530106301073010830109301103011130112301133011430115301163011730118301193012030121301223012330124301253012630127301283012930130301313013230133301343013530136301373013830139301403014130142301433014430145301463014730148301493015030151301523015330154301553015630157301583015930160301613016230163301643016530166301673016830169301703017130172301733017430175301763017730178301793018030181301823018330184301853018630187301883018930190301913019230193301943019530196301973019830199302003020130202302033020430205302063020730208302093021030211302123021330214302153021630217302183021930220302213022230223302243022530226302273022830229302303023130232302333023430235302363023730238302393024030241302423024330244302453024630247302483024930250302513025230253302543025530256302573025830259302603026130262302633026430265302663026730268302693027030271302723027330274302753027630277302783027930280302813028230283302843028530286302873028830289302903029130292302933029430295302963029730298302993030030301303023030330304303053030630307303083030930310303113031230313303143031530316303173031830319303203032130322303233032430325303263032730328303293033030331303323033330334303353033630337303383033930340303413034230343303443034530346303473034830349303503035130352303533035430355303563035730358303593036030361303623036330364303653036630367303683036930370303713037230373303743037530376303773037830379303803038130382303833038430385303863038730388303893039030391303923039330394303953039630397303983039930400304013040230403304043040530406304073040830409304103041130412304133041430415304163041730418304193042030421304223042330424304253042630427304283042930430304313043230433304343043530436304373043830439304403044130442304433044430445304463044730448304493045030451304523045330454304553045630457304583045930460304613046230463304643046530466304673046830469304703047130472304733047430475304763047730478304793048030481304823048330484304853048630487304883048930490304913049230493304943049530496304973049830499305003050130502305033050430505305063050730508305093051030511305123051330514305153051630517305183051930520305213052230523305243052530526305273052830529305303053130532305333053430535305363053730538305393054030541305423054330544305453054630547305483054930550305513055230553305543055530556305573055830559305603056130562305633056430565305663056730568305693057030571305723057330574305753057630577305783057930580305813058230583305843058530586305873058830589305903059130592305933059430595305963059730598305993060030601306023060330604306053060630607306083060930610306113061230613306143061530616306173061830619306203062130622306233062430625306263062730628306293063030631306323063330634306353063630637306383063930640306413064230643306443064530646306473064830649306503065130652306533065430655306563065730658306593066030661306623066330664306653066630667306683066930670306713067230673306743067530676306773067830679306803068130682306833068430685306863068730688306893069030691306923069330694306953069630697306983069930700307013070230703307043070530706307073070830709307103071130712307133071430715307163071730718307193072030721307223072330724307253072630727307283072930730307313073230733307343073530736307373073830739307403074130742307433074430745307463074730748307493075030751307523075330754307553075630757307583075930760307613076230763307643076530766307673076830769307703077130772307733077430775307763077730778307793078030781307823078330784307853078630787307883078930790307913079230793307943079530796307973079830799308003080130802308033080430805308063080730808308093081030811308123081330814308153081630817308183081930820308213082230823308243082530826308273082830829308303083130832308333083430835308363083730838308393084030841308423084330844308453084630847308483084930850308513085230853308543085530856308573085830859308603086130862308633086430865308663086730868308693087030871308723087330874308753087630877308783087930880308813088230883308843088530886308873088830889308903089130892308933089430895308963089730898308993090030901309023090330904309053090630907309083090930910309113091230913309143091530916309173091830919309203092130922309233092430925309263092730928309293093030931309323093330934309353093630937309383093930940309413094230943309443094530946309473094830949309503095130952309533095430955309563095730958309593096030961309623096330964309653096630967309683096930970309713097230973309743097530976309773097830979309803098130982309833098430985309863098730988309893099030991309923099330994309953099630997309983099931000310013100231003310043100531006310073100831009310103101131012310133101431015310163101731018310193102031021310223102331024310253102631027310283102931030310313103231033310343103531036310373103831039310403104131042310433104431045310463104731048310493105031051310523105331054310553105631057310583105931060310613106231063310643106531066310673106831069310703107131072310733107431075310763107731078310793108031081310823108331084310853108631087310883108931090310913109231093310943109531096310973109831099311003110131102311033110431105311063110731108311093111031111311123111331114311153111631117311183111931120311213112231123311243112531126311273112831129311303113131132311333113431135311363113731138311393114031141311423114331144311453114631147311483114931150311513115231153311543115531156311573115831159311603116131162311633116431165311663116731168311693117031171311723117331174311753117631177311783117931180311813118231183311843118531186311873118831189311903119131192311933119431195311963119731198311993120031201312023120331204312053120631207312083120931210312113121231213312143121531216312173121831219312203122131222312233122431225312263122731228312293123031231312323123331234312353123631237312383123931240312413124231243312443124531246312473124831249312503125131252312533125431255312563125731258312593126031261312623126331264312653126631267312683126931270312713127231273312743127531276312773127831279312803128131282312833128431285312863128731288312893129031291312923129331294312953129631297312983129931300313013130231303313043130531306313073130831309313103131131312313133131431315313163131731318313193132031321313223132331324313253132631327313283132931330313313133231333313343133531336313373133831339313403134131342313433134431345313463134731348313493135031351313523135331354313553135631357313583135931360313613136231363313643136531366313673136831369313703137131372313733137431375313763137731378313793138031381313823138331384313853138631387313883138931390313913139231393313943139531396313973139831399314003140131402314033140431405314063140731408314093141031411314123141331414314153141631417314183141931420314213142231423314243142531426314273142831429314303143131432314333143431435314363143731438314393144031441314423144331444314453144631447314483144931450314513145231453314543145531456314573145831459314603146131462314633146431465314663146731468314693147031471314723147331474314753147631477314783147931480314813148231483314843148531486314873148831489314903149131492314933149431495314963149731498314993150031501315023150331504315053150631507315083150931510315113151231513315143151531516315173151831519315203152131522315233152431525315263152731528315293153031531315323153331534315353153631537315383153931540315413154231543315443154531546315473154831549315503155131552315533155431555315563155731558315593156031561315623156331564315653156631567315683156931570315713157231573315743157531576315773157831579315803158131582315833158431585315863158731588315893159031591315923159331594315953159631597315983159931600316013160231603316043160531606316073160831609316103161131612316133161431615316163161731618316193162031621316223162331624316253162631627316283162931630316313163231633316343163531636316373163831639316403164131642316433164431645316463164731648316493165031651316523165331654316553165631657316583165931660316613166231663316643166531666316673166831669316703167131672316733167431675316763167731678316793168031681316823168331684316853168631687316883168931690316913169231693316943169531696316973169831699317003170131702317033170431705317063170731708317093171031711317123171331714317153171631717317183171931720317213172231723317243172531726317273172831729317303173131732317333173431735317363173731738317393174031741317423174331744317453174631747317483174931750317513175231753317543175531756317573175831759317603176131762317633176431765317663176731768317693177031771317723177331774317753177631777317783177931780317813178231783317843178531786317873178831789317903179131792317933179431795317963179731798317993180031801318023180331804318053180631807318083180931810318113181231813318143181531816318173181831819318203182131822318233182431825318263182731828318293183031831318323183331834318353183631837318383183931840318413184231843318443184531846318473184831849318503185131852318533185431855318563185731858318593186031861318623186331864318653186631867318683186931870318713187231873318743187531876318773187831879318803188131882318833188431885318863188731888318893189031891318923189331894318953189631897318983189931900319013190231903319043190531906319073190831909319103191131912319133191431915319163191731918319193192031921319223192331924319253192631927319283192931930319313193231933319343193531936319373193831939319403194131942319433194431945319463194731948319493195031951319523195331954319553195631957319583195931960319613196231963319643196531966319673196831969319703197131972319733197431975319763197731978319793198031981319823198331984319853198631987319883198931990319913199231993319943199531996319973199831999320003200132002320033200432005320063200732008320093201032011320123201332014320153201632017320183201932020320213202232023320243202532026320273202832029320303203132032320333203432035320363203732038320393204032041320423204332044320453204632047320483204932050320513205232053320543205532056320573205832059320603206132062320633206432065320663206732068320693207032071320723207332074320753207632077320783207932080320813208232083320843208532086320873208832089320903209132092320933209432095320963209732098320993210032101321023210332104321053210632107321083210932110321113211232113321143211532116321173211832119321203212132122321233212432125321263212732128321293213032131321323213332134321353213632137321383213932140321413214232143321443214532146321473214832149321503215132152321533215432155321563215732158321593216032161321623216332164321653216632167321683216932170321713217232173321743217532176321773217832179321803218132182321833218432185321863218732188321893219032191321923219332194321953219632197321983219932200322013220232203322043220532206322073220832209322103221132212322133221432215322163221732218322193222032221322223222332224322253222632227322283222932230322313223232233322343223532236322373223832239322403224132242322433224432245322463224732248322493225032251322523225332254322553225632257322583225932260322613226232263322643226532266322673226832269322703227132272322733227432275322763227732278322793228032281322823228332284322853228632287322883228932290322913229232293322943229532296322973229832299323003230132302323033230432305323063230732308323093231032311323123231332314323153231632317323183231932320323213232232323323243232532326323273232832329323303233132332323333233432335323363233732338323393234032341323423234332344323453234632347323483234932350323513235232353323543235532356323573235832359323603236132362323633236432365323663236732368323693237032371323723237332374323753237632377323783237932380323813238232383323843238532386323873238832389323903239132392323933239432395323963239732398323993240032401324023240332404324053240632407324083240932410324113241232413324143241532416324173241832419324203242132422324233242432425324263242732428324293243032431324323243332434324353243632437324383243932440324413244232443324443244532446324473244832449324503245132452324533245432455324563245732458324593246032461324623246332464324653246632467324683246932470324713247232473324743247532476324773247832479324803248132482324833248432485324863248732488324893249032491324923249332494324953249632497324983249932500325013250232503325043250532506325073250832509325103251132512325133251432515325163251732518325193252032521325223252332524325253252632527325283252932530325313253232533325343253532536325373253832539325403254132542325433254432545325463254732548325493255032551325523255332554325553255632557325583255932560325613256232563325643256532566325673256832569325703257132572325733257432575325763257732578325793258032581325823258332584325853258632587325883258932590325913259232593325943259532596325973259832599326003260132602326033260432605326063260732608326093261032611326123261332614326153261632617326183261932620326213262232623326243262532626326273262832629326303263132632326333263432635326363263732638326393264032641326423264332644326453264632647326483264932650326513265232653326543265532656326573265832659326603266132662326633266432665326663266732668326693267032671326723267332674326753267632677326783267932680326813268232683326843268532686326873268832689326903269132692326933269432695326963269732698326993270032701327023270332704327053270632707327083270932710327113271232713327143271532716327173271832719327203272132722327233272432725327263272732728327293273032731327323273332734327353273632737327383273932740327413274232743327443274532746327473274832749327503275132752327533275432755327563275732758327593276032761327623276332764327653276632767327683276932770327713277232773327743277532776327773277832779327803278132782327833278432785327863278732788327893279032791327923279332794327953279632797327983279932800328013280232803328043280532806328073280832809328103281132812328133281432815328163281732818328193282032821328223282332824328253282632827328283282932830328313283232833328343283532836328373283832839328403284132842328433284432845328463284732848328493285032851328523285332854328553285632857328583285932860328613286232863328643286532866328673286832869328703287132872328733287432875328763287732878328793288032881328823288332884328853288632887328883288932890328913289232893328943289532896328973289832899329003290132902329033290432905329063290732908329093291032911329123291332914329153291632917329183291932920329213292232923329243292532926329273292832929329303293132932329333293432935329363293732938329393294032941329423294332944329453294632947329483294932950329513295232953329543295532956329573295832959329603296132962329633296432965329663296732968329693297032971329723297332974329753297632977329783297932980329813298232983329843298532986329873298832989329903299132992329933299432995329963299732998329993300033001330023300333004330053300633007330083300933010330113301233013330143301533016330173301833019330203302133022330233302433025330263302733028330293303033031330323303333034330353303633037330383303933040330413304233043330443304533046330473304833049330503305133052330533305433055330563305733058330593306033061330623306333064330653306633067330683306933070330713307233073330743307533076330773307833079330803308133082330833308433085330863308733088330893309033091330923309333094330953309633097330983309933100331013310233103331043310533106331073310833109331103311133112331133311433115331163311733118331193312033121331223312333124331253312633127331283312933130331313313233133331343313533136331373313833139331403314133142331433314433145331463314733148331493315033151331523315333154331553315633157331583315933160331613316233163331643316533166331673316833169331703317133172331733317433175331763317733178331793318033181331823318333184331853318633187331883318933190331913319233193331943319533196331973319833199332003320133202332033320433205332063320733208332093321033211332123321333214332153321633217332183321933220332213322233223332243322533226332273322833229332303323133232332333323433235332363323733238332393324033241332423324333244332453324633247332483324933250332513325233253332543325533256332573325833259332603326133262332633326433265332663326733268332693327033271332723327333274332753327633277332783327933280332813328233283332843328533286332873328833289332903329133292332933329433295332963329733298332993330033301333023330333304333053330633307333083330933310333113331233313333143331533316333173331833319333203332133322333233332433325333263332733328333293333033331333323333333334333353333633337333383333933340333413334233343333443334533346333473334833349333503335133352333533335433355333563335733358333593336033361333623336333364333653336633367333683336933370333713337233373333743337533376333773337833379333803338133382333833338433385333863338733388333893339033391333923339333394333953339633397333983339933400334013340233403334043340533406334073340833409334103341133412334133341433415334163341733418334193342033421334223342333424334253342633427334283342933430334313343233433334343343533436334373343833439334403344133442334433344433445334463344733448334493345033451334523345333454334553345633457334583345933460334613346233463334643346533466334673346833469334703347133472334733347433475334763347733478334793348033481334823348333484334853348633487334883348933490334913349233493334943349533496334973349833499335003350133502335033350433505335063350733508335093351033511335123351333514335153351633517335183351933520335213352233523335243352533526335273352833529335303353133532335333353433535335363353733538335393354033541335423354333544335453354633547335483354933550335513355233553335543355533556335573355833559335603356133562335633356433565335663356733568335693357033571335723357333574335753357633577335783357933580335813358233583335843358533586335873358833589335903359133592335933359433595335963359733598335993360033601336023360333604336053360633607336083360933610336113361233613336143361533616336173361833619336203362133622336233362433625336263362733628336293363033631336323363333634336353363633637336383363933640336413364233643336443364533646336473364833649336503365133652336533365433655336563365733658336593366033661336623366333664336653366633667336683366933670336713367233673336743367533676336773367833679336803368133682336833368433685336863368733688336893369033691336923369333694336953369633697336983369933700337013370233703337043370533706337073370833709337103371133712337133371433715337163371733718337193372033721337223372333724337253372633727337283372933730337313373233733337343373533736337373373833739337403374133742337433374433745337463374733748337493375033751337523375333754337553375633757337583375933760337613376233763337643376533766337673376833769337703377133772337733377433775337763377733778337793378033781337823378333784337853378633787337883378933790337913379233793337943379533796337973379833799338003380133802338033380433805338063380733808338093381033811338123381333814338153381633817338183381933820338213382233823338243382533826338273382833829338303383133832338333383433835338363383733838338393384033841338423384333844338453384633847338483384933850338513385233853338543385533856338573385833859338603386133862338633386433865338663386733868338693387033871338723387333874338753387633877338783387933880338813388233883338843388533886338873388833889338903389133892338933389433895338963389733898338993390033901339023390333904339053390633907339083390933910339113391233913339143391533916339173391833919339203392133922339233392433925339263392733928339293393033931339323393333934339353393633937339383393933940339413394233943339443394533946339473394833949339503395133952339533395433955339563395733958339593396033961339623396333964339653396633967339683396933970339713397233973339743397533976339773397833979339803398133982339833398433985339863398733988339893399033991339923399333994339953399633997339983399934000340013400234003340043400534006340073400834009340103401134012340133401434015340163401734018340193402034021340223402334024340253402634027340283402934030340313403234033340343403534036340373403834039340403404134042340433404434045340463404734048340493405034051340523405334054340553405634057340583405934060340613406234063340643406534066340673406834069340703407134072340733407434075340763407734078340793408034081340823408334084340853408634087340883408934090340913409234093340943409534096340973409834099341003410134102341033410434105341063410734108341093411034111341123411334114341153411634117341183411934120341213412234123341243412534126341273412834129341303413134132341333413434135341363413734138341393414034141341423414334144341453414634147341483414934150341513415234153341543415534156341573415834159341603416134162341633416434165341663416734168341693417034171341723417334174341753417634177341783417934180341813418234183341843418534186341873418834189341903419134192341933419434195341963419734198341993420034201342023420334204342053420634207342083420934210342113421234213342143421534216342173421834219342203422134222342233422434225342263422734228342293423034231342323423334234342353423634237342383423934240342413424234243342443424534246342473424834249342503425134252342533425434255342563425734258342593426034261342623426334264342653426634267342683426934270342713427234273342743427534276342773427834279342803428134282342833428434285342863428734288342893429034291342923429334294342953429634297342983429934300343013430234303343043430534306343073430834309343103431134312343133431434315343163431734318343193432034321343223432334324343253432634327343283432934330343313433234333343343433534336343373433834339343403434134342343433434434345343463434734348343493435034351343523435334354343553435634357343583435934360343613436234363343643436534366343673436834369343703437134372343733437434375343763437734378343793438034381343823438334384343853438634387343883438934390343913439234393343943439534396343973439834399344003440134402344033440434405344063440734408344093441034411344123441334414344153441634417344183441934420344213442234423344243442534426344273442834429344303443134432344333443434435344363443734438344393444034441344423444334444344453444634447344483444934450344513445234453344543445534456344573445834459344603446134462344633446434465344663446734468344693447034471344723447334474344753447634477344783447934480344813448234483344843448534486344873448834489344903449134492344933449434495344963449734498344993450034501345023450334504345053450634507345083450934510345113451234513345143451534516345173451834519345203452134522345233452434525345263452734528345293453034531345323453334534345353453634537345383453934540345413454234543345443454534546345473454834549345503455134552345533455434555345563455734558345593456034561345623456334564345653456634567345683456934570345713457234573345743457534576345773457834579345803458134582345833458434585345863458734588345893459034591345923459334594345953459634597345983459934600346013460234603346043460534606346073460834609346103461134612346133461434615346163461734618346193462034621346223462334624346253462634627346283462934630346313463234633346343463534636346373463834639346403464134642346433464434645346463464734648346493465034651346523465334654346553465634657346583465934660346613466234663346643466534666346673466834669346703467134672346733467434675346763467734678346793468034681346823468334684346853468634687346883468934690346913469234693346943469534696346973469834699347003470134702347033470434705347063470734708347093471034711347123471334714347153471634717347183471934720347213472234723347243472534726347273472834729347303473134732347333473434735347363473734738347393474034741347423474334744347453474634747347483474934750347513475234753347543475534756347573475834759347603476134762347633476434765347663476734768347693477034771347723477334774347753477634777347783477934780347813478234783347843478534786347873478834789347903479134792347933479434795347963479734798347993480034801348023480334804348053480634807348083480934810348113481234813348143481534816348173481834819348203482134822348233482434825348263482734828348293483034831348323483334834348353483634837348383483934840348413484234843348443484534846348473484834849348503485134852348533485434855348563485734858348593486034861348623486334864348653486634867348683486934870348713487234873348743487534876348773487834879348803488134882348833488434885348863488734888348893489034891348923489334894348953489634897348983489934900349013490234903349043490534906349073490834909349103491134912349133491434915349163491734918349193492034921349223492334924349253492634927349283492934930349313493234933349343493534936349373493834939349403494134942349433494434945349463494734948349493495034951349523495334954349553495634957349583495934960349613496234963349643496534966349673496834969349703497134972349733497434975349763497734978349793498034981349823498334984349853498634987349883498934990349913499234993349943499534996349973499834999350003500135002350033500435005350063500735008350093501035011350123501335014350153501635017350183501935020350213502235023350243502535026350273502835029350303503135032350333503435035350363503735038350393504035041350423504335044350453504635047350483504935050350513505235053350543505535056350573505835059350603506135062350633506435065350663506735068350693507035071350723507335074350753507635077350783507935080350813508235083350843508535086350873508835089350903509135092350933509435095350963509735098350993510035101351023510335104351053510635107351083510935110351113511235113351143511535116351173511835119351203512135122351233512435125351263512735128351293513035131351323513335134351353513635137351383513935140351413514235143351443514535146351473514835149351503515135152351533515435155351563515735158351593516035161351623516335164351653516635167351683516935170351713517235173351743517535176351773517835179351803518135182351833518435185351863518735188351893519035191351923519335194351953519635197351983519935200352013520235203352043520535206352073520835209352103521135212352133521435215352163521735218352193522035221352223522335224352253522635227352283522935230352313523235233352343523535236352373523835239352403524135242352433524435245352463524735248352493525035251352523525335254352553525635257352583525935260352613526235263352643526535266352673526835269352703527135272352733527435275352763527735278352793528035281352823528335284352853528635287352883528935290352913529235293352943529535296352973529835299353003530135302353033530435305353063530735308353093531035311353123531335314353153531635317353183531935320353213532235323353243532535326353273532835329353303533135332353333533435335353363533735338353393534035341353423534335344353453534635347353483534935350353513535235353353543535535356353573535835359353603536135362353633536435365353663536735368353693537035371353723537335374353753537635377353783537935380353813538235383353843538535386353873538835389353903539135392353933539435395353963539735398353993540035401354023540335404354053540635407354083540935410354113541235413354143541535416354173541835419354203542135422354233542435425354263542735428354293543035431354323543335434354353543635437354383543935440354413544235443354443544535446354473544835449354503545135452354533545435455354563545735458354593546035461354623546335464354653546635467354683546935470354713547235473354743547535476354773547835479354803548135482354833548435485354863548735488354893549035491354923549335494354953549635497354983549935500355013550235503355043550535506355073550835509355103551135512355133551435515355163551735518355193552035521355223552335524355253552635527355283552935530355313553235533355343553535536355373553835539355403554135542355433554435545355463554735548355493555035551355523555335554355553555635557355583555935560355613556235563355643556535566355673556835569355703557135572355733557435575355763557735578355793558035581355823558335584355853558635587355883558935590355913559235593355943559535596355973559835599356003560135602356033560435605356063560735608356093561035611356123561335614356153561635617356183561935620356213562235623356243562535626356273562835629356303563135632356333563435635356363563735638356393564035641356423564335644356453564635647356483564935650356513565235653356543565535656356573565835659356603566135662356633566435665356663566735668356693567035671356723567335674356753567635677356783567935680356813568235683356843568535686356873568835689356903569135692356933569435695356963569735698356993570035701357023570335704357053570635707357083570935710357113571235713357143571535716357173571835719357203572135722357233572435725357263572735728357293573035731357323573335734357353573635737357383573935740357413574235743357443574535746357473574835749357503575135752357533575435755357563575735758357593576035761357623576335764357653576635767357683576935770357713577235773357743577535776357773577835779357803578135782357833578435785357863578735788357893579035791357923579335794357953579635797357983579935800358013580235803358043580535806358073580835809358103581135812358133581435815358163581735818358193582035821358223582335824358253582635827358283582935830358313583235833358343583535836358373583835839358403584135842358433584435845358463584735848358493585035851358523585335854358553585635857358583585935860358613586235863358643586535866358673586835869358703587135872358733587435875358763587735878358793588035881358823588335884358853588635887358883588935890358913589235893358943589535896358973589835899359003590135902359033590435905359063590735908359093591035911359123591335914359153591635917359183591935920359213592235923359243592535926359273592835929359303593135932359333593435935359363593735938359393594035941359423594335944359453594635947359483594935950359513595235953359543595535956359573595835959359603596135962359633596435965359663596735968359693597035971359723597335974359753597635977359783597935980359813598235983359843598535986359873598835989359903599135992359933599435995359963599735998359993600036001360023600336004360053600636007360083600936010360113601236013360143601536016360173601836019360203602136022360233602436025360263602736028360293603036031360323603336034360353603636037360383603936040360413604236043360443604536046360473604836049360503605136052360533605436055360563605736058360593606036061360623606336064360653606636067360683606936070360713607236073360743607536076360773607836079360803608136082360833608436085360863608736088360893609036091360923609336094360953609636097360983609936100361013610236103361043610536106361073610836109361103611136112361133611436115361163611736118361193612036121361223612336124361253612636127361283612936130361313613236133361343613536136361373613836139361403614136142361433614436145361463614736148361493615036151361523615336154361553615636157361583615936160361613616236163361643616536166361673616836169361703617136172361733617436175361763617736178361793618036181361823618336184361853618636187361883618936190361913619236193361943619536196361973619836199362003620136202362033620436205362063620736208362093621036211362123621336214362153621636217362183621936220362213622236223362243622536226362273622836229362303623136232362333623436235362363623736238362393624036241362423624336244362453624636247362483624936250362513625236253362543625536256362573625836259362603626136262362633626436265362663626736268362693627036271362723627336274362753627636277362783627936280362813628236283362843628536286362873628836289362903629136292362933629436295362963629736298362993630036301363023630336304363053630636307363083630936310363113631236313363143631536316363173631836319363203632136322363233632436325363263632736328363293633036331363323633336334363353633636337363383633936340363413634236343363443634536346363473634836349363503635136352363533635436355363563635736358363593636036361363623636336364363653636636367363683636936370363713637236373363743637536376363773637836379363803638136382363833638436385363863638736388363893639036391363923639336394363953639636397363983639936400364013640236403364043640536406364073640836409364103641136412364133641436415364163641736418364193642036421364223642336424364253642636427364283642936430364313643236433364343643536436364373643836439364403644136442364433644436445364463644736448364493645036451364523645336454364553645636457364583645936460364613646236463364643646536466364673646836469364703647136472364733647436475364763647736478364793648036481364823648336484364853648636487364883648936490364913649236493364943649536496364973649836499365003650136502365033650436505365063650736508365093651036511365123651336514365153651636517365183651936520365213652236523365243652536526365273652836529365303653136532365333653436535365363653736538365393654036541365423654336544365453654636547365483654936550365513655236553365543655536556365573655836559365603656136562365633656436565365663656736568365693657036571365723657336574365753657636577365783657936580365813658236583365843658536586365873658836589365903659136592365933659436595365963659736598365993660036601366023660336604366053660636607366083660936610366113661236613366143661536616366173661836619366203662136622366233662436625366263662736628366293663036631366323663336634366353663636637366383663936640366413664236643366443664536646366473664836649366503665136652366533665436655366563665736658366593666036661366623666336664366653666636667366683666936670366713667236673366743667536676366773667836679366803668136682366833668436685366863668736688366893669036691366923669336694366953669636697366983669936700367013670236703367043670536706367073670836709367103671136712367133671436715367163671736718367193672036721367223672336724367253672636727367283672936730367313673236733367343673536736367373673836739367403674136742367433674436745367463674736748367493675036751367523675336754367553675636757367583675936760367613676236763367643676536766367673676836769367703677136772367733677436775367763677736778367793678036781367823678336784367853678636787367883678936790367913679236793367943679536796367973679836799368003680136802368033680436805368063680736808368093681036811368123681336814368153681636817368183681936820368213682236823368243682536826368273682836829368303683136832368333683436835368363683736838368393684036841368423684336844368453684636847368483684936850368513685236853368543685536856368573685836859368603686136862368633686436865368663686736868368693687036871368723687336874368753687636877368783687936880368813688236883368843688536886368873688836889368903689136892368933689436895368963689736898368993690036901369023690336904369053690636907369083690936910369113691236913369143691536916369173691836919369203692136922369233692436925369263692736928369293693036931369323693336934369353693636937369383693936940369413694236943369443694536946369473694836949369503695136952369533695436955369563695736958369593696036961369623696336964369653696636967369683696936970369713697236973369743697536976369773697836979369803698136982369833698436985369863698736988369893699036991369923699336994369953699636997369983699937000370013700237003370043700537006370073700837009370103701137012370133701437015370163701737018370193702037021370223702337024370253702637027370283702937030370313703237033370343703537036370373703837039370403704137042370433704437045370463704737048370493705037051370523705337054370553705637057370583705937060370613706237063370643706537066370673706837069370703707137072370733707437075370763707737078370793708037081370823708337084370853708637087370883708937090370913709237093370943709537096370973709837099371003710137102371033710437105371063710737108371093711037111371123711337114371153711637117371183711937120371213712237123371243712537126371273712837129371303713137132371333713437135371363713737138371393714037141371423714337144371453714637147371483714937150371513715237153371543715537156371573715837159371603716137162371633716437165371663716737168371693717037171371723717337174371753717637177371783717937180371813718237183371843718537186371873718837189371903719137192371933719437195371963719737198371993720037201372023720337204372053720637207372083720937210372113721237213372143721537216372173721837219372203722137222372233722437225372263722737228372293723037231372323723337234372353723637237372383723937240372413724237243372443724537246372473724837249372503725137252372533725437255372563725737258372593726037261372623726337264372653726637267372683726937270372713727237273372743727537276372773727837279372803728137282372833728437285372863728737288372893729037291372923729337294372953729637297372983729937300373013730237303373043730537306373073730837309373103731137312373133731437315373163731737318373193732037321373223732337324373253732637327373283732937330373313733237333373343733537336373373733837339373403734137342373433734437345373463734737348373493735037351373523735337354373553735637357373583735937360373613736237363373643736537366373673736837369373703737137372373733737437375373763737737378373793738037381373823738337384373853738637387373883738937390373913739237393373943739537396373973739837399374003740137402374033740437405374063740737408374093741037411374123741337414374153741637417374183741937420374213742237423374243742537426374273742837429374303743137432374333743437435374363743737438374393744037441374423744337444374453744637447374483744937450374513745237453374543745537456374573745837459374603746137462374633746437465374663746737468374693747037471374723747337474374753747637477374783747937480374813748237483374843748537486374873748837489374903749137492374933749437495374963749737498374993750037501375023750337504375053750637507375083750937510375113751237513375143751537516375173751837519375203752137522375233752437525375263752737528375293753037531375323753337534375353753637537375383753937540375413754237543375443754537546375473754837549375503755137552375533755437555375563755737558375593756037561375623756337564375653756637567375683756937570375713757237573375743757537576375773757837579375803758137582375833758437585375863758737588375893759037591375923759337594375953759637597375983759937600376013760237603376043760537606376073760837609376103761137612376133761437615376163761737618376193762037621376223762337624376253762637627376283762937630376313763237633376343763537636376373763837639376403764137642376433764437645376463764737648376493765037651376523765337654376553765637657376583765937660376613766237663376643766537666376673766837669376703767137672376733767437675376763767737678376793768037681376823768337684376853768637687376883768937690376913769237693376943769537696376973769837699377003770137702377033770437705377063770737708377093771037711377123771337714377153771637717377183771937720377213772237723377243772537726377273772837729377303773137732377333773437735377363773737738377393774037741377423774337744377453774637747377483774937750377513775237753377543775537756377573775837759377603776137762377633776437765377663776737768377693777037771377723777337774377753777637777377783777937780377813778237783377843778537786377873778837789377903779137792377933779437795377963779737798377993780037801378023780337804378053780637807378083780937810378113781237813378143781537816378173781837819378203782137822378233782437825378263782737828378293783037831378323783337834378353783637837378383783937840378413784237843378443784537846378473784837849378503785137852378533785437855378563785737858378593786037861378623786337864378653786637867378683786937870378713787237873378743787537876378773787837879378803788137882378833788437885378863788737888378893789037891378923789337894378953789637897378983789937900379013790237903379043790537906379073790837909379103791137912379133791437915379163791737918379193792037921379223792337924379253792637927379283792937930379313793237933379343793537936379373793837939379403794137942379433794437945379463794737948379493795037951379523795337954379553795637957379583795937960379613796237963379643796537966379673796837969379703797137972379733797437975379763797737978379793798037981379823798337984379853798637987379883798937990379913799237993379943799537996379973799837999380003800138002380033800438005380063800738008380093801038011380123801338014380153801638017380183801938020380213802238023380243802538026380273802838029380303803138032380333803438035380363803738038380393804038041380423804338044380453804638047380483804938050380513805238053380543805538056380573805838059380603806138062380633806438065380663806738068380693807038071380723807338074380753807638077380783807938080380813808238083380843808538086380873808838089380903809138092380933809438095380963809738098380993810038101381023810338104381053810638107381083810938110381113811238113381143811538116381173811838119381203812138122381233812438125381263812738128381293813038131381323813338134381353813638137381383813938140381413814238143381443814538146381473814838149381503815138152381533815438155381563815738158381593816038161381623816338164381653816638167381683816938170381713817238173381743817538176381773817838179381803818138182381833818438185381863818738188381893819038191381923819338194381953819638197381983819938200382013820238203382043820538206382073820838209382103821138212382133821438215382163821738218382193822038221382223822338224382253822638227382283822938230382313823238233382343823538236382373823838239382403824138242382433824438245382463824738248382493825038251382523825338254382553825638257382583825938260382613826238263382643826538266382673826838269382703827138272382733827438275382763827738278382793828038281382823828338284382853828638287382883828938290382913829238293382943829538296382973829838299383003830138302383033830438305383063830738308383093831038311383123831338314383153831638317383183831938320383213832238323383243832538326383273832838329383303833138332383333833438335383363833738338383393834038341383423834338344383453834638347383483834938350383513835238353383543835538356383573835838359383603836138362383633836438365383663836738368383693837038371383723837338374383753837638377383783837938380383813838238383383843838538386383873838838389383903839138392383933839438395383963839738398383993840038401384023840338404384053840638407384083840938410384113841238413384143841538416384173841838419384203842138422384233842438425384263842738428384293843038431384323843338434384353843638437384383843938440384413844238443384443844538446384473844838449384503845138452384533845438455384563845738458384593846038461384623846338464384653846638467384683846938470384713847238473384743847538476384773847838479384803848138482384833848438485384863848738488384893849038491384923849338494384953849638497384983849938500385013850238503385043850538506385073850838509385103851138512385133851438515385163851738518385193852038521385223852338524385253852638527385283852938530385313853238533385343853538536385373853838539385403854138542385433854438545385463854738548385493855038551385523855338554385553855638557385583855938560385613856238563385643856538566385673856838569385703857138572385733857438575385763857738578385793858038581385823858338584385853858638587385883858938590385913859238593385943859538596385973859838599386003860138602386033860438605386063860738608386093861038611386123861338614386153861638617386183861938620386213862238623386243862538626386273862838629386303863138632386333863438635386363863738638386393864038641386423864338644386453864638647386483864938650386513865238653386543865538656386573865838659386603866138662386633866438665386663866738668386693867038671386723867338674386753867638677386783867938680386813868238683386843868538686386873868838689386903869138692386933869438695386963869738698386993870038701387023870338704387053870638707387083870938710387113871238713387143871538716387173871838719387203872138722387233872438725387263872738728387293873038731387323873338734387353873638737387383873938740387413874238743387443874538746387473874838749387503875138752387533875438755387563875738758387593876038761387623876338764387653876638767387683876938770387713877238773387743877538776387773877838779387803878138782387833878438785387863878738788387893879038791387923879338794387953879638797387983879938800388013880238803388043880538806388073880838809388103881138812388133881438815388163881738818388193882038821388223882338824388253882638827388283882938830388313883238833388343883538836388373883838839388403884138842388433884438845388463884738848388493885038851388523885338854388553885638857388583885938860388613886238863388643886538866388673886838869388703887138872388733887438875388763887738878388793888038881388823888338884388853888638887388883888938890388913889238893388943889538896388973889838899389003890138902389033890438905389063890738908389093891038911389123891338914389153891638917389183891938920389213892238923389243892538926389273892838929389303893138932389333893438935389363893738938389393894038941389423894338944389453894638947389483894938950389513895238953389543895538956389573895838959389603896138962389633896438965389663896738968389693897038971389723897338974389753897638977389783897938980389813898238983389843898538986389873898838989389903899138992389933899438995389963899738998389993900039001390023900339004390053900639007390083900939010390113901239013390143901539016390173901839019390203902139022390233902439025390263902739028390293903039031390323903339034390353903639037390383903939040390413904239043390443904539046390473904839049390503905139052390533905439055390563905739058390593906039061390623906339064390653906639067390683906939070390713907239073390743907539076390773907839079390803908139082390833908439085390863908739088390893909039091390923909339094390953909639097390983909939100391013910239103391043910539106391073910839109391103911139112391133911439115391163911739118391193912039121391223912339124391253912639127391283912939130391313913239133391343913539136391373913839139391403914139142391433914439145391463914739148391493915039151391523915339154391553915639157391583915939160391613916239163391643916539166391673916839169391703917139172391733917439175391763917739178391793918039181391823918339184391853918639187391883918939190391913919239193391943919539196391973919839199392003920139202392033920439205392063920739208392093921039211392123921339214392153921639217392183921939220392213922239223392243922539226392273922839229392303923139232392333923439235392363923739238392393924039241392423924339244392453924639247392483924939250392513925239253392543925539256392573925839259392603926139262392633926439265392663926739268392693927039271392723927339274392753927639277392783927939280392813928239283392843928539286392873928839289392903929139292392933929439295392963929739298392993930039301393023930339304393053930639307393083930939310393113931239313393143931539316393173931839319393203932139322393233932439325393263932739328393293933039331393323933339334393353933639337393383933939340393413934239343393443934539346393473934839349393503935139352393533935439355393563935739358393593936039361393623936339364393653936639367393683936939370393713937239373393743937539376393773937839379393803938139382393833938439385393863938739388393893939039391393923939339394393953939639397393983939939400394013940239403394043940539406394073940839409394103941139412394133941439415394163941739418394193942039421394223942339424394253942639427394283942939430394313943239433394343943539436394373943839439394403944139442394433944439445394463944739448394493945039451394523945339454394553945639457394583945939460394613946239463394643946539466394673946839469394703947139472394733947439475394763947739478394793948039481394823948339484394853948639487394883948939490394913949239493394943949539496394973949839499395003950139502395033950439505395063950739508395093951039511395123951339514395153951639517395183951939520395213952239523395243952539526395273952839529395303953139532395333953439535395363953739538395393954039541395423954339544395453954639547395483954939550395513955239553395543955539556395573955839559395603956139562395633956439565395663956739568395693957039571395723957339574395753957639577395783957939580395813958239583395843958539586395873958839589395903959139592395933959439595395963959739598395993960039601396023960339604396053960639607396083960939610396113961239613396143961539616396173961839619396203962139622396233962439625396263962739628396293963039631396323963339634396353963639637396383963939640396413964239643396443964539646396473964839649396503965139652396533965439655396563965739658396593966039661396623966339664396653966639667396683966939670396713967239673396743967539676396773967839679396803968139682396833968439685396863968739688396893969039691396923969339694396953969639697396983969939700397013970239703397043970539706397073970839709397103971139712397133971439715397163971739718397193972039721397223972339724397253972639727397283972939730397313973239733397343973539736397373973839739397403974139742397433974439745397463974739748397493975039751397523975339754397553975639757397583975939760397613976239763397643976539766397673976839769397703977139772397733977439775397763977739778397793978039781397823978339784397853978639787397883978939790397913979239793397943979539796397973979839799398003980139802398033980439805398063980739808398093981039811398123981339814398153981639817398183981939820398213982239823398243982539826398273982839829398303983139832398333983439835398363983739838398393984039841398423984339844398453984639847398483984939850398513985239853398543985539856398573985839859398603986139862398633986439865398663986739868398693987039871398723987339874398753987639877398783987939880398813988239883398843988539886398873988839889398903989139892398933989439895398963989739898398993990039901399023990339904399053990639907399083990939910399113991239913399143991539916399173991839919399203992139922399233992439925399263992739928399293993039931399323993339934399353993639937399383993939940399413994239943399443994539946399473994839949399503995139952399533995439955399563995739958399593996039961399623996339964399653996639967399683996939970399713997239973399743997539976399773997839979399803998139982399833998439985399863998739988399893999039991399923999339994399953999639997399983999940000400014000240003400044000540006400074000840009400104001140012400134001440015400164001740018400194002040021400224002340024400254002640027400284002940030400314003240033400344003540036400374003840039400404004140042400434004440045400464004740048400494005040051400524005340054400554005640057400584005940060400614006240063400644006540066400674006840069400704007140072400734007440075400764007740078400794008040081400824008340084400854008640087400884008940090400914009240093400944009540096400974009840099401004010140102401034010440105401064010740108401094011040111401124011340114401154011640117401184011940120401214012240123401244012540126401274012840129401304013140132401334013440135401364013740138401394014040141401424014340144401454014640147401484014940150401514015240153401544015540156401574015840159401604016140162401634016440165401664016740168401694017040171401724017340174401754017640177401784017940180401814018240183401844018540186401874018840189401904019140192401934019440195401964019740198401994020040201402024020340204402054020640207402084020940210402114021240213402144021540216402174021840219402204022140222402234022440225402264022740228402294023040231402324023340234402354023640237402384023940240402414024240243402444024540246402474024840249402504025140252402534025440255402564025740258402594026040261402624026340264402654026640267402684026940270402714027240273402744027540276402774027840279402804028140282402834028440285402864028740288402894029040291402924029340294402954029640297402984029940300403014030240303403044030540306403074030840309403104031140312403134031440315403164031740318403194032040321403224032340324403254032640327403284032940330403314033240333403344033540336403374033840339403404034140342403434034440345403464034740348403494035040351403524035340354403554035640357403584035940360403614036240363403644036540366403674036840369403704037140372403734037440375403764037740378403794038040381403824038340384403854038640387403884038940390403914039240393403944039540396403974039840399404004040140402404034040440405404064040740408404094041040411404124041340414404154041640417404184041940420404214042240423404244042540426404274042840429404304043140432404334043440435404364043740438404394044040441404424044340444404454044640447404484044940450404514045240453404544045540456404574045840459404604046140462404634046440465404664046740468404694047040471404724047340474404754047640477404784047940480404814048240483404844048540486404874048840489404904049140492404934049440495404964049740498404994050040501405024050340504405054050640507405084050940510405114051240513405144051540516405174051840519405204052140522405234052440525405264052740528405294053040531405324053340534405354053640537405384053940540405414054240543405444054540546405474054840549405504055140552405534055440555405564055740558405594056040561405624056340564405654056640567405684056940570405714057240573405744057540576405774057840579405804058140582405834058440585405864058740588405894059040591405924059340594405954059640597405984059940600406014060240603406044060540606406074060840609406104061140612406134061440615406164061740618406194062040621406224062340624406254062640627406284062940630406314063240633406344063540636406374063840639406404064140642406434064440645406464064740648406494065040651406524065340654406554065640657406584065940660406614066240663406644066540666406674066840669406704067140672406734067440675406764067740678406794068040681406824068340684406854068640687406884068940690406914069240693406944069540696406974069840699407004070140702407034070440705407064070740708407094071040711407124071340714407154071640717407184071940720407214072240723407244072540726407274072840729407304073140732407334073440735407364073740738407394074040741407424074340744407454074640747407484074940750407514075240753407544075540756407574075840759407604076140762407634076440765407664076740768407694077040771407724077340774407754077640777407784077940780407814078240783407844078540786407874078840789407904079140792407934079440795407964079740798407994080040801408024080340804408054080640807408084080940810408114081240813408144081540816408174081840819408204082140822408234082440825408264082740828408294083040831408324083340834408354083640837408384083940840408414084240843408444084540846408474084840849408504085140852408534085440855408564085740858408594086040861408624086340864408654086640867408684086940870408714087240873408744087540876408774087840879408804088140882408834088440885408864088740888408894089040891408924089340894408954089640897408984089940900409014090240903409044090540906409074090840909409104091140912409134091440915409164091740918409194092040921409224092340924409254092640927409284092940930409314093240933409344093540936409374093840939409404094140942409434094440945409464094740948409494095040951409524095340954409554095640957409584095940960409614096240963409644096540966409674096840969409704097140972409734097440975409764097740978409794098040981409824098340984409854098640987409884098940990409914099240993409944099540996409974099840999410004100141002410034100441005410064100741008410094101041011410124101341014410154101641017410184101941020410214102241023410244102541026410274102841029410304103141032410334103441035410364103741038410394104041041410424104341044410454104641047410484104941050410514105241053410544105541056410574105841059410604106141062410634106441065410664106741068410694107041071410724107341074410754107641077410784107941080410814108241083410844108541086410874108841089410904109141092410934109441095410964109741098410994110041101411024110341104411054110641107411084110941110411114111241113411144111541116411174111841119411204112141122411234112441125411264112741128411294113041131411324113341134411354113641137411384113941140411414114241143411444114541146411474114841149411504115141152411534115441155411564115741158411594116041161411624116341164411654116641167411684116941170411714117241173411744117541176411774117841179411804118141182411834118441185411864118741188411894119041191411924119341194411954119641197411984119941200412014120241203412044120541206412074120841209412104121141212412134121441215412164121741218412194122041221412224122341224412254122641227412284122941230412314123241233412344123541236412374123841239412404124141242412434124441245412464124741248412494125041251412524125341254412554125641257412584125941260412614126241263412644126541266412674126841269412704127141272412734127441275412764127741278412794128041281412824128341284412854128641287412884128941290412914129241293412944129541296412974129841299413004130141302413034130441305413064130741308413094131041311413124131341314413154131641317413184131941320413214132241323413244132541326413274132841329413304133141332413334133441335413364133741338413394134041341413424134341344413454134641347413484134941350413514135241353413544135541356413574135841359413604136141362413634136441365413664136741368413694137041371413724137341374413754137641377413784137941380413814138241383413844138541386413874138841389413904139141392413934139441395413964139741398413994140041401414024140341404414054140641407414084140941410414114141241413414144141541416414174141841419414204142141422414234142441425414264142741428414294143041431414324143341434414354143641437414384143941440414414144241443414444144541446414474144841449414504145141452414534145441455414564145741458414594146041461414624146341464414654146641467414684146941470414714147241473414744147541476414774147841479414804148141482414834148441485414864148741488414894149041491414924149341494414954149641497414984149941500415014150241503415044150541506415074150841509415104151141512415134151441515415164151741518415194152041521415224152341524415254152641527415284152941530415314153241533415344153541536415374153841539415404154141542415434154441545415464154741548415494155041551415524155341554415554155641557415584155941560415614156241563415644156541566415674156841569415704157141572415734157441575415764157741578415794158041581415824158341584415854158641587415884158941590415914159241593415944159541596415974159841599416004160141602416034160441605416064160741608416094161041611416124161341614416154161641617416184161941620416214162241623416244162541626416274162841629416304163141632416334163441635416364163741638416394164041641416424164341644416454164641647416484164941650416514165241653416544165541656416574165841659416604166141662416634166441665416664166741668416694167041671416724167341674416754167641677416784167941680416814168241683416844168541686416874168841689416904169141692416934169441695416964169741698416994170041701417024170341704417054170641707417084170941710417114171241713417144171541716417174171841719417204172141722417234172441725417264172741728417294173041731417324173341734417354173641737417384173941740417414174241743417444174541746417474174841749417504175141752417534175441755417564175741758417594176041761417624176341764417654176641767417684176941770417714177241773417744177541776417774177841779417804178141782417834178441785417864178741788417894179041791417924179341794417954179641797417984179941800418014180241803418044180541806418074180841809418104181141812418134181441815418164181741818418194182041821418224182341824418254182641827418284182941830418314183241833418344183541836418374183841839418404184141842418434184441845418464184741848418494185041851418524185341854418554185641857418584185941860418614186241863418644186541866418674186841869418704187141872418734187441875418764187741878418794188041881418824188341884418854188641887418884188941890418914189241893418944189541896418974189841899419004190141902419034190441905419064190741908419094191041911419124191341914419154191641917419184191941920419214192241923419244192541926419274192841929419304193141932419334193441935419364193741938419394194041941419424194341944419454194641947419484194941950419514195241953419544195541956419574195841959419604196141962419634196441965419664196741968419694197041971419724197341974419754197641977419784197941980419814198241983419844198541986419874198841989419904199141992419934199441995419964199741998419994200042001420024200342004420054200642007420084200942010420114201242013420144201542016420174201842019420204202142022420234202442025420264202742028420294203042031420324203342034420354203642037420384203942040420414204242043420444204542046420474204842049420504205142052420534205442055420564205742058420594206042061420624206342064420654206642067420684206942070420714207242073420744207542076420774207842079420804208142082420834208442085420864208742088420894209042091420924209342094420954209642097420984209942100421014210242103421044210542106421074210842109421104211142112421134211442115421164211742118421194212042121421224212342124421254212642127421284212942130421314213242133421344213542136421374213842139421404214142142421434214442145421464214742148421494215042151421524215342154421554215642157421584215942160421614216242163421644216542166421674216842169421704217142172421734217442175421764217742178421794218042181421824218342184421854218642187421884218942190421914219242193421944219542196421974219842199422004220142202422034220442205422064220742208422094221042211422124221342214422154221642217422184221942220422214222242223422244222542226422274222842229422304223142232422334223442235422364223742238422394224042241422424224342244422454224642247422484224942250422514225242253422544225542256422574225842259422604226142262422634226442265422664226742268422694227042271422724227342274422754227642277422784227942280422814228242283422844228542286422874228842289422904229142292422934229442295422964229742298422994230042301423024230342304423054230642307423084230942310423114231242313423144231542316423174231842319423204232142322423234232442325423264232742328423294233042331423324233342334423354233642337423384233942340423414234242343423444234542346423474234842349423504235142352423534235442355423564235742358423594236042361423624236342364423654236642367423684236942370423714237242373423744237542376423774237842379423804238142382423834238442385423864238742388423894239042391423924239342394423954239642397423984239942400424014240242403424044240542406424074240842409424104241142412424134241442415424164241742418424194242042421424224242342424424254242642427424284242942430424314243242433424344243542436424374243842439424404244142442424434244442445424464244742448424494245042451424524245342454424554245642457424584245942460424614246242463424644246542466424674246842469424704247142472424734247442475424764247742478424794248042481424824248342484424854248642487424884248942490424914249242493424944249542496424974249842499425004250142502425034250442505425064250742508425094251042511425124251342514425154251642517425184251942520425214252242523425244252542526425274252842529425304253142532425334253442535425364253742538425394254042541425424254342544425454254642547425484254942550425514255242553425544255542556425574255842559425604256142562425634256442565425664256742568425694257042571425724257342574425754257642577425784257942580425814258242583425844258542586425874258842589425904259142592425934259442595425964259742598425994260042601426024260342604426054260642607426084260942610426114261242613426144261542616426174261842619426204262142622426234262442625426264262742628426294263042631426324263342634426354263642637426384263942640426414264242643426444264542646426474264842649426504265142652426534265442655426564265742658426594266042661426624266342664426654266642667426684266942670426714267242673426744267542676426774267842679426804268142682426834268442685426864268742688426894269042691426924269342694426954269642697426984269942700427014270242703427044270542706427074270842709427104271142712427134271442715427164271742718427194272042721427224272342724427254272642727427284272942730427314273242733427344273542736427374273842739427404274142742427434274442745427464274742748427494275042751427524275342754427554275642757427584275942760427614276242763427644276542766427674276842769427704277142772427734277442775427764277742778427794278042781427824278342784427854278642787427884278942790427914279242793427944279542796427974279842799428004280142802428034280442805428064280742808428094281042811428124281342814428154281642817428184281942820428214282242823428244282542826428274282842829428304283142832428334283442835428364283742838428394284042841428424284342844428454284642847428484284942850428514285242853428544285542856428574285842859428604286142862428634286442865428664286742868428694287042871428724287342874428754287642877428784287942880428814288242883428844288542886428874288842889428904289142892428934289442895428964289742898428994290042901429024290342904429054290642907429084290942910429114291242913429144291542916429174291842919429204292142922429234292442925429264292742928429294293042931429324293342934429354293642937429384293942940429414294242943429444294542946429474294842949429504295142952429534295442955429564295742958429594296042961429624296342964429654296642967429684296942970429714297242973429744297542976429774297842979429804298142982429834298442985429864298742988429894299042991429924299342994429954299642997429984299943000430014300243003430044300543006430074300843009430104301143012430134301443015430164301743018430194302043021430224302343024430254302643027430284302943030430314303243033430344303543036430374303843039430404304143042430434304443045430464304743048430494305043051430524305343054430554305643057430584305943060430614306243063430644306543066430674306843069430704307143072430734307443075430764307743078430794308043081430824308343084430854308643087430884308943090430914309243093430944309543096430974309843099431004310143102431034310443105431064310743108431094311043111431124311343114431154311643117431184311943120431214312243123431244312543126431274312843129431304313143132431334313443135431364313743138431394314043141431424314343144431454314643147431484314943150431514315243153431544315543156431574315843159431604316143162431634316443165431664316743168431694317043171431724317343174431754317643177431784317943180431814318243183431844318543186431874318843189431904319143192431934319443195431964319743198431994320043201432024320343204432054320643207432084320943210432114321243213432144321543216432174321843219432204322143222432234322443225432264322743228432294323043231432324323343234432354323643237432384323943240432414324243243432444324543246432474324843249432504325143252432534325443255432564325743258432594326043261432624326343264432654326643267432684326943270432714327243273432744327543276432774327843279432804328143282432834328443285432864328743288432894329043291432924329343294432954329643297432984329943300433014330243303433044330543306433074330843309433104331143312433134331443315433164331743318433194332043321433224332343324433254332643327433284332943330433314333243333433344333543336433374333843339433404334143342433434334443345433464334743348433494335043351433524335343354433554335643357433584335943360433614336243363433644336543366433674336843369433704337143372433734337443375433764337743378433794338043381433824338343384433854338643387433884338943390433914339243393433944339543396433974339843399434004340143402434034340443405434064340743408434094341043411434124341343414434154341643417434184341943420434214342243423434244342543426434274342843429434304343143432434334343443435434364343743438434394344043441434424344343444434454344643447434484344943450434514345243453434544345543456434574345843459434604346143462434634346443465434664346743468434694347043471434724347343474434754347643477434784347943480434814348243483434844348543486434874348843489434904349143492434934349443495434964349743498434994350043501435024350343504435054350643507435084350943510435114351243513435144351543516435174351843519435204352143522435234352443525435264352743528435294353043531435324353343534435354353643537435384353943540435414354243543435444354543546435474354843549435504355143552435534355443555435564355743558435594356043561435624356343564435654356643567435684356943570435714357243573435744357543576435774357843579435804358143582435834358443585435864358743588435894359043591435924359343594435954359643597435984359943600436014360243603436044360543606436074360843609436104361143612436134361443615436164361743618436194362043621436224362343624436254362643627436284362943630436314363243633436344363543636436374363843639436404364143642436434364443645436464364743648436494365043651436524365343654436554365643657436584365943660436614366243663436644366543666436674366843669436704367143672436734367443675436764367743678436794368043681436824368343684436854368643687436884368943690436914369243693436944369543696436974369843699437004370143702437034370443705437064370743708437094371043711437124371343714437154371643717437184371943720437214372243723437244372543726437274372843729437304373143732437334373443735437364373743738437394374043741437424374343744437454374643747437484374943750437514375243753437544375543756437574375843759437604376143762437634376443765437664376743768437694377043771437724377343774437754377643777437784377943780437814378243783437844378543786437874378843789437904379143792437934379443795437964379743798437994380043801438024380343804438054380643807438084380943810438114381243813438144381543816438174381843819438204382143822438234382443825438264382743828438294383043831438324383343834438354383643837438384383943840438414384243843438444384543846438474384843849438504385143852438534385443855438564385743858438594386043861438624386343864438654386643867438684386943870438714387243873438744387543876438774387843879438804388143882438834388443885438864388743888438894389043891438924389343894438954389643897438984389943900439014390243903439044390543906439074390843909439104391143912439134391443915439164391743918439194392043921439224392343924439254392643927439284392943930439314393243933439344393543936439374393843939439404394143942439434394443945439464394743948439494395043951439524395343954439554395643957439584395943960439614396243963439644396543966439674396843969439704397143972439734397443975439764397743978439794398043981439824398343984439854398643987439884398943990439914399243993439944399543996439974399843999440004400144002440034400444005440064400744008440094401044011440124401344014440154401644017440184401944020440214402244023440244402544026440274402844029440304403144032440334403444035440364403744038440394404044041440424404344044440454404644047440484404944050440514405244053440544405544056440574405844059440604406144062440634406444065440664406744068440694407044071440724407344074440754407644077440784407944080440814408244083440844408544086440874408844089440904409144092440934409444095440964409744098440994410044101441024410344104441054410644107441084410944110441114411244113441144411544116441174411844119441204412144122441234412444125441264412744128441294413044131441324413344134441354413644137441384413944140441414414244143441444414544146441474414844149441504415144152441534415444155441564415744158441594416044161441624416344164441654416644167441684416944170441714417244173441744417544176441774417844179441804418144182441834418444185441864418744188441894419044191441924419344194441954419644197441984419944200442014420244203442044420544206442074420844209442104421144212442134421444215442164421744218442194422044221442224422344224442254422644227442284422944230442314423244233442344423544236442374423844239442404424144242442434424444245442464424744248442494425044251442524425344254442554425644257442584425944260442614426244263442644426544266442674426844269442704427144272442734427444275442764427744278442794428044281442824428344284442854428644287442884428944290442914429244293442944429544296442974429844299443004430144302443034430444305443064430744308443094431044311443124431344314443154431644317443184431944320443214432244323443244432544326443274432844329443304433144332443334433444335443364433744338443394434044341443424434344344443454434644347443484434944350443514435244353443544435544356443574435844359443604436144362443634436444365443664436744368443694437044371443724437344374443754437644377443784437944380443814438244383443844438544386443874438844389443904439144392443934439444395443964439744398443994440044401444024440344404444054440644407444084440944410444114441244413444144441544416444174441844419444204442144422444234442444425444264442744428444294443044431444324443344434444354443644437444384443944440444414444244443444444444544446444474444844449444504445144452444534445444455444564445744458444594446044461444624446344464444654446644467444684446944470444714447244473444744447544476444774447844479444804448144482444834448444485444864448744488444894449044491444924449344494444954449644497444984449944500445014450244503445044450544506445074450844509445104451144512445134451444515445164451744518445194452044521445224452344524445254452644527445284452944530445314453244533445344453544536445374453844539445404454144542445434454444545445464454744548445494455044551445524455344554445554455644557445584455944560445614456244563445644456544566445674456844569445704457144572445734457444575445764457744578445794458044581445824458344584445854458644587445884458944590445914459244593445944459544596445974459844599446004460144602446034460444605446064460744608446094461044611446124461344614446154461644617446184461944620446214462244623446244462544626446274462844629446304463144632446334463444635446364463744638446394464044641446424464344644446454464644647446484464944650446514465244653446544465544656446574465844659446604466144662446634466444665446664466744668446694467044671446724467344674446754467644677446784467944680446814468244683446844468544686446874468844689446904469144692446934469444695446964469744698446994470044701447024470344704447054470644707447084470944710447114471244713447144471544716447174471844719447204472144722447234472444725447264472744728447294473044731447324473344734447354473644737447384473944740447414474244743447444474544746447474474844749447504475144752447534475444755447564475744758447594476044761447624476344764447654476644767447684476944770447714477244773447744477544776447774477844779447804478144782447834478444785447864478744788447894479044791447924479344794447954479644797447984479944800448014480244803448044480544806448074480844809448104481144812448134481444815448164481744818448194482044821448224482344824448254482644827448284482944830448314483244833448344483544836448374483844839448404484144842448434484444845448464484744848448494485044851448524485344854448554485644857448584485944860448614486244863448644486544866448674486844869448704487144872448734487444875448764487744878448794488044881448824488344884448854488644887448884488944890448914489244893448944489544896448974489844899449004490144902449034490444905449064490744908449094491044911449124491344914449154491644917449184491944920449214492244923449244492544926449274492844929449304493144932449334493444935449364493744938449394494044941449424494344944449454494644947449484494944950449514495244953449544495544956449574495844959449604496144962449634496444965449664496744968449694497044971449724497344974449754497644977449784497944980449814498244983449844498544986449874498844989449904499144992449934499444995449964499744998449994500045001450024500345004450054500645007450084500945010450114501245013450144501545016450174501845019450204502145022450234502445025450264502745028450294503045031450324503345034450354503645037450384503945040450414504245043450444504545046450474504845049450504505145052450534505445055450564505745058450594506045061450624506345064450654506645067450684506945070450714507245073450744507545076450774507845079450804508145082450834508445085450864508745088450894509045091450924509345094450954509645097450984509945100451014510245103451044510545106451074510845109451104511145112451134511445115451164511745118451194512045121451224512345124451254512645127451284512945130451314513245133451344513545136451374513845139451404514145142451434514445145451464514745148451494515045151451524515345154451554515645157451584515945160451614516245163451644516545166451674516845169451704517145172451734517445175451764517745178451794518045181451824518345184451854518645187451884518945190451914519245193451944519545196451974519845199452004520145202452034520445205452064520745208452094521045211452124521345214452154521645217452184521945220452214522245223452244522545226452274522845229452304523145232452334523445235452364523745238452394524045241452424524345244452454524645247452484524945250452514525245253452544525545256452574525845259452604526145262452634526445265452664526745268452694527045271452724527345274452754527645277452784527945280452814528245283452844528545286452874528845289452904529145292452934529445295452964529745298452994530045301453024530345304453054530645307453084530945310453114531245313453144531545316453174531845319453204532145322453234532445325453264532745328453294533045331453324533345334453354533645337453384533945340453414534245343453444534545346453474534845349453504535145352453534535445355453564535745358453594536045361453624536345364453654536645367453684536945370453714537245373453744537545376453774537845379453804538145382453834538445385453864538745388453894539045391453924539345394453954539645397453984539945400454014540245403454044540545406454074540845409454104541145412454134541445415454164541745418454194542045421454224542345424454254542645427454284542945430454314543245433454344543545436454374543845439454404544145442454434544445445454464544745448454494545045451454524545345454454554545645457454584545945460454614546245463454644546545466454674546845469454704547145472454734547445475454764547745478454794548045481454824548345484454854548645487454884548945490454914549245493454944549545496454974549845499455004550145502455034550445505455064550745508455094551045511455124551345514455154551645517455184551945520455214552245523455244552545526455274552845529455304553145532455334553445535455364553745538455394554045541455424554345544455454554645547455484554945550455514555245553455544555545556455574555845559455604556145562455634556445565455664556745568455694557045571455724557345574455754557645577455784557945580455814558245583455844558545586455874558845589455904559145592455934559445595455964559745598455994560045601456024560345604456054560645607456084560945610456114561245613456144561545616456174561845619456204562145622456234562445625456264562745628456294563045631456324563345634456354563645637456384563945640456414564245643456444564545646456474564845649456504565145652456534565445655456564565745658456594566045661456624566345664456654566645667456684566945670456714567245673456744567545676456774567845679456804568145682456834568445685456864568745688456894569045691456924569345694456954569645697456984569945700457014570245703457044570545706457074570845709457104571145712457134571445715457164571745718457194572045721457224572345724457254572645727457284572945730457314573245733457344573545736457374573845739457404574145742457434574445745457464574745748457494575045751457524575345754457554575645757457584575945760457614576245763457644576545766457674576845769457704577145772457734577445775457764577745778457794578045781457824578345784457854578645787457884578945790457914579245793457944579545796457974579845799458004580145802458034580445805458064580745808458094581045811458124581345814458154581645817458184581945820458214582245823458244582545826458274582845829458304583145832458334583445835458364583745838458394584045841458424584345844458454584645847458484584945850458514585245853458544585545856458574585845859458604586145862458634586445865458664586745868458694587045871458724587345874458754587645877458784587945880458814588245883458844588545886458874588845889458904589145892458934589445895458964589745898458994590045901459024590345904459054590645907459084590945910459114591245913459144591545916459174591845919459204592145922459234592445925459264592745928459294593045931459324593345934459354593645937459384593945940459414594245943459444594545946459474594845949459504595145952459534595445955459564595745958459594596045961459624596345964459654596645967459684596945970459714597245973459744597545976459774597845979459804598145982459834598445985459864598745988459894599045991459924599345994459954599645997459984599946000460014600246003460044600546006460074600846009460104601146012460134601446015460164601746018460194602046021460224602346024460254602646027460284602946030460314603246033460344603546036460374603846039460404604146042460434604446045460464604746048460494605046051460524605346054460554605646057460584605946060460614606246063460644606546066460674606846069460704607146072460734607446075460764607746078460794608046081460824608346084460854608646087460884608946090460914609246093460944609546096460974609846099461004610146102461034610446105461064610746108461094611046111461124611346114461154611646117461184611946120461214612246123461244612546126461274612846129461304613146132461334613446135461364613746138461394614046141461424614346144461454614646147461484614946150461514615246153461544615546156461574615846159461604616146162461634616446165461664616746168461694617046171461724617346174461754617646177461784617946180461814618246183461844618546186461874618846189461904619146192461934619446195461964619746198461994620046201462024620346204462054620646207462084620946210462114621246213462144621546216462174621846219462204622146222462234622446225462264622746228462294623046231462324623346234462354623646237462384623946240462414624246243462444624546246462474624846249462504625146252462534625446255462564625746258462594626046261462624626346264462654626646267462684626946270462714627246273462744627546276462774627846279462804628146282462834628446285462864628746288462894629046291462924629346294462954629646297462984629946300463014630246303463044630546306463074630846309463104631146312463134631446315463164631746318463194632046321463224632346324463254632646327463284632946330463314633246333463344633546336463374633846339463404634146342463434634446345463464634746348463494635046351463524635346354463554635646357463584635946360463614636246363463644636546366463674636846369463704637146372463734637446375463764637746378463794638046381463824638346384463854638646387463884638946390463914639246393463944639546396463974639846399464004640146402464034640446405464064640746408464094641046411464124641346414464154641646417464184641946420464214642246423464244642546426464274642846429464304643146432464334643446435464364643746438464394644046441464424644346444464454644646447464484644946450464514645246453464544645546456464574645846459464604646146462464634646446465464664646746468464694647046471464724647346474464754647646477464784647946480464814648246483464844648546486464874648846489464904649146492464934649446495464964649746498464994650046501465024650346504465054650646507465084650946510465114651246513465144651546516465174651846519465204652146522465234652446525465264652746528465294653046531465324653346534465354653646537465384653946540465414654246543465444654546546465474654846549465504655146552465534655446555465564655746558465594656046561465624656346564465654656646567465684656946570465714657246573465744657546576465774657846579465804658146582465834658446585465864658746588465894659046591465924659346594465954659646597465984659946600466014660246603466044660546606466074660846609466104661146612466134661446615466164661746618466194662046621466224662346624466254662646627466284662946630466314663246633466344663546636466374663846639466404664146642466434664446645466464664746648466494665046651466524665346654466554665646657466584665946660466614666246663466644666546666466674666846669466704667146672466734667446675466764667746678466794668046681466824668346684466854668646687466884668946690466914669246693466944669546696466974669846699467004670146702467034670446705467064670746708467094671046711467124671346714467154671646717467184671946720467214672246723467244672546726467274672846729467304673146732467334673446735467364673746738467394674046741467424674346744467454674646747467484674946750467514675246753467544675546756467574675846759467604676146762467634676446765467664676746768467694677046771467724677346774467754677646777467784677946780467814678246783467844678546786467874678846789467904679146792467934679446795467964679746798467994680046801468024680346804468054680646807468084680946810468114681246813468144681546816468174681846819468204682146822468234682446825468264682746828468294683046831468324683346834468354683646837468384683946840468414684246843468444684546846468474684846849468504685146852468534685446855468564685746858468594686046861468624686346864468654686646867468684686946870468714687246873468744687546876468774687846879468804688146882468834688446885468864688746888468894689046891468924689346894468954689646897468984689946900469014690246903469044690546906469074690846909469104691146912469134691446915469164691746918469194692046921469224692346924469254692646927469284692946930469314693246933469344693546936469374693846939469404694146942469434694446945469464694746948469494695046951469524695346954469554695646957469584695946960469614696246963469644696546966469674696846969469704697146972469734697446975469764697746978469794698046981469824698346984469854698646987469884698946990469914699246993469944699546996469974699846999470004700147002470034700447005470064700747008470094701047011470124701347014470154701647017470184701947020470214702247023470244702547026470274702847029470304703147032470334703447035470364703747038470394704047041470424704347044470454704647047470484704947050470514705247053470544705547056470574705847059470604706147062470634706447065470664706747068470694707047071470724707347074470754707647077470784707947080470814708247083470844708547086470874708847089470904709147092470934709447095470964709747098470994710047101471024710347104471054710647107471084710947110471114711247113471144711547116471174711847119471204712147122471234712447125471264712747128471294713047131471324713347134471354713647137471384713947140471414714247143471444714547146471474714847149471504715147152471534715447155471564715747158471594716047161471624716347164471654716647167471684716947170471714717247173471744717547176471774717847179471804718147182471834718447185471864718747188471894719047191471924719347194471954719647197471984719947200472014720247203472044720547206472074720847209472104721147212472134721447215472164721747218472194722047221472224722347224472254722647227472284722947230472314723247233472344723547236472374723847239472404724147242472434724447245472464724747248472494725047251472524725347254472554725647257472584725947260472614726247263472644726547266472674726847269472704727147272472734727447275472764727747278472794728047281472824728347284472854728647287472884728947290472914729247293472944729547296472974729847299473004730147302473034730447305473064730747308473094731047311473124731347314473154731647317473184731947320473214732247323473244732547326473274732847329473304733147332473334733447335473364733747338473394734047341473424734347344473454734647347473484734947350473514735247353473544735547356473574735847359473604736147362473634736447365473664736747368473694737047371473724737347374473754737647377473784737947380473814738247383473844738547386473874738847389473904739147392473934739447395473964739747398473994740047401474024740347404474054740647407474084740947410474114741247413474144741547416474174741847419474204742147422474234742447425474264742747428474294743047431474324743347434474354743647437474384743947440474414744247443474444744547446474474744847449474504745147452474534745447455474564745747458474594746047461474624746347464474654746647467474684746947470474714747247473474744747547476474774747847479474804748147482474834748447485474864748747488474894749047491474924749347494474954749647497474984749947500475014750247503475044750547506475074750847509475104751147512475134751447515475164751747518475194752047521475224752347524475254752647527475284752947530475314753247533475344753547536475374753847539475404754147542475434754447545475464754747548475494755047551475524755347554475554755647557475584755947560475614756247563475644756547566475674756847569475704757147572475734757447575475764757747578475794758047581475824758347584475854758647587475884758947590475914759247593475944759547596475974759847599476004760147602476034760447605476064760747608476094761047611476124761347614476154761647617476184761947620476214762247623476244762547626476274762847629476304763147632476334763447635476364763747638476394764047641476424764347644476454764647647476484764947650476514765247653476544765547656476574765847659476604766147662476634766447665476664766747668476694767047671476724767347674476754767647677476784767947680476814768247683476844768547686476874768847689476904769147692476934769447695476964769747698476994770047701477024770347704477054770647707477084770947710477114771247713477144771547716477174771847719477204772147722477234772447725477264772747728477294773047731477324773347734477354773647737477384773947740477414774247743477444774547746477474774847749477504775147752477534775447755477564775747758477594776047761477624776347764477654776647767477684776947770477714777247773477744777547776477774777847779477804778147782477834778447785477864778747788477894779047791477924779347794477954779647797477984779947800478014780247803478044780547806478074780847809478104781147812478134781447815478164781747818478194782047821478224782347824478254782647827478284782947830478314783247833478344783547836478374783847839478404784147842478434784447845478464784747848478494785047851478524785347854478554785647857478584785947860478614786247863478644786547866478674786847869478704787147872478734787447875478764787747878478794788047881478824788347884478854788647887478884788947890478914789247893478944789547896478974789847899479004790147902479034790447905479064790747908479094791047911479124791347914479154791647917479184791947920479214792247923479244792547926479274792847929479304793147932479334793447935479364793747938479394794047941479424794347944479454794647947479484794947950479514795247953479544795547956479574795847959479604796147962479634796447965479664796747968479694797047971479724797347974479754797647977479784797947980479814798247983479844798547986479874798847989479904799147992479934799447995479964799747998479994800048001480024800348004480054800648007480084800948010480114801248013480144801548016480174801848019480204802148022480234802448025480264802748028480294803048031480324803348034480354803648037480384803948040480414804248043480444804548046480474804848049480504805148052480534805448055480564805748058480594806048061480624806348064480654806648067480684806948070480714807248073480744807548076480774807848079480804808148082480834808448085480864808748088480894809048091480924809348094480954809648097480984809948100481014810248103481044810548106481074810848109481104811148112481134811448115481164811748118481194812048121481224812348124481254812648127481284812948130481314813248133481344813548136481374813848139481404814148142481434814448145481464814748148481494815048151481524815348154481554815648157481584815948160481614816248163481644816548166481674816848169481704817148172481734817448175481764817748178481794818048181481824818348184481854818648187481884818948190481914819248193481944819548196481974819848199482004820148202482034820448205482064820748208482094821048211482124821348214482154821648217482184821948220482214822248223482244822548226482274822848229482304823148232482334823448235482364823748238482394824048241482424824348244482454824648247482484824948250482514825248253482544825548256482574825848259482604826148262482634826448265482664826748268482694827048271482724827348274482754827648277482784827948280482814828248283482844828548286482874828848289482904829148292482934829448295482964829748298482994830048301483024830348304483054830648307483084830948310483114831248313483144831548316483174831848319483204832148322483234832448325483264832748328483294833048331483324833348334483354833648337483384833948340483414834248343483444834548346483474834848349483504835148352483534835448355483564835748358483594836048361483624836348364483654836648367483684836948370483714837248373483744837548376483774837848379483804838148382483834838448385483864838748388483894839048391483924839348394483954839648397483984839948400484014840248403484044840548406484074840848409484104841148412484134841448415484164841748418484194842048421484224842348424484254842648427484284842948430484314843248433484344843548436484374843848439484404844148442484434844448445484464844748448484494845048451484524845348454484554845648457484584845948460484614846248463484644846548466484674846848469484704847148472484734847448475484764847748478484794848048481484824848348484484854848648487484884848948490484914849248493484944849548496484974849848499485004850148502485034850448505485064850748508485094851048511485124851348514485154851648517485184851948520485214852248523485244852548526485274852848529485304853148532485334853448535485364853748538485394854048541485424854348544485454854648547485484854948550485514855248553485544855548556485574855848559485604856148562485634856448565485664856748568485694857048571485724857348574485754857648577485784857948580485814858248583485844858548586485874858848589485904859148592485934859448595485964859748598485994860048601486024860348604486054860648607486084860948610486114861248613486144861548616486174861848619486204862148622486234862448625486264862748628486294863048631486324863348634486354863648637486384863948640486414864248643486444864548646486474864848649486504865148652486534865448655486564865748658486594866048661486624866348664486654866648667486684866948670486714867248673486744867548676486774867848679486804868148682486834868448685486864868748688486894869048691486924869348694486954869648697486984869948700487014870248703487044870548706487074870848709487104871148712487134871448715487164871748718487194872048721487224872348724487254872648727487284872948730487314873248733487344873548736487374873848739487404874148742487434874448745487464874748748487494875048751487524875348754487554875648757487584875948760487614876248763487644876548766487674876848769487704877148772487734877448775487764877748778487794878048781487824878348784487854878648787487884878948790487914879248793487944879548796487974879848799488004880148802488034880448805488064880748808488094881048811488124881348814488154881648817488184881948820488214882248823488244882548826488274882848829488304883148832488334883448835488364883748838488394884048841488424884348844488454884648847488484884948850488514885248853488544885548856488574885848859488604886148862488634886448865488664886748868488694887048871488724887348874488754887648877488784887948880488814888248883488844888548886488874888848889488904889148892488934889448895488964889748898488994890048901489024890348904489054890648907489084890948910489114891248913489144891548916489174891848919489204892148922489234892448925489264892748928489294893048931489324893348934489354893648937489384893948940489414894248943489444894548946489474894848949489504895148952489534895448955489564895748958489594896048961489624896348964489654896648967489684896948970489714897248973489744897548976489774897848979489804898148982489834898448985489864898748988489894899048991489924899348994489954899648997489984899949000490014900249003490044900549006490074900849009490104901149012490134901449015490164901749018490194902049021490224902349024490254902649027490284902949030490314903249033490344903549036490374903849039490404904149042490434904449045490464904749048490494905049051490524905349054490554905649057490584905949060490614906249063490644906549066490674906849069490704907149072490734907449075490764907749078490794908049081490824908349084490854908649087490884908949090490914909249093490944909549096490974909849099491004910149102491034910449105491064910749108491094911049111491124911349114491154911649117491184911949120491214912249123491244912549126491274912849129491304913149132491334913449135491364913749138491394914049141491424914349144491454914649147491484914949150491514915249153491544915549156491574915849159491604916149162491634916449165491664916749168491694917049171491724917349174491754917649177491784917949180491814918249183491844918549186491874918849189491904919149192491934919449195491964919749198491994920049201492024920349204492054920649207492084920949210492114921249213492144921549216492174921849219492204922149222492234922449225492264922749228492294923049231492324923349234492354923649237492384923949240492414924249243492444924549246492474924849249492504925149252492534925449255492564925749258492594926049261492624926349264492654926649267492684926949270492714927249273492744927549276492774927849279492804928149282492834928449285492864928749288492894929049291492924929349294492954929649297492984929949300493014930249303493044930549306493074930849309493104931149312493134931449315493164931749318493194932049321493224932349324493254932649327493284932949330493314933249333493344933549336493374933849339493404934149342493434934449345493464934749348493494935049351493524935349354493554935649357493584935949360493614936249363493644936549366493674936849369493704937149372493734937449375493764937749378493794938049381493824938349384493854938649387493884938949390493914939249393493944939549396493974939849399494004940149402494034940449405494064940749408494094941049411494124941349414494154941649417494184941949420494214942249423494244942549426494274942849429494304943149432494334943449435494364943749438494394944049441494424944349444494454944649447494484944949450494514945249453494544945549456494574945849459494604946149462494634946449465494664946749468494694947049471494724947349474494754947649477494784947949480494814948249483494844948549486494874948849489494904949149492494934949449495494964949749498494994950049501495024950349504495054950649507495084950949510495114951249513495144951549516495174951849519495204952149522495234952449525495264952749528495294953049531495324953349534495354953649537495384953949540495414954249543495444954549546495474954849549495504955149552495534955449555495564955749558495594956049561495624956349564495654956649567495684956949570495714957249573495744957549576495774957849579495804958149582495834958449585495864958749588495894959049591495924959349594495954959649597495984959949600496014960249603496044960549606496074960849609496104961149612496134961449615496164961749618496194962049621496224962349624496254962649627496284962949630496314963249633496344963549636496374963849639496404964149642496434964449645496464964749648496494965049651496524965349654496554965649657496584965949660496614966249663496644966549666496674966849669496704967149672496734967449675496764967749678496794968049681496824968349684496854968649687496884968949690496914969249693496944969549696496974969849699497004970149702497034970449705497064970749708497094971049711497124971349714497154971649717497184971949720497214972249723497244972549726497274972849729497304973149732497334973449735497364973749738497394974049741497424974349744497454974649747497484974949750497514975249753497544975549756497574975849759497604976149762497634976449765497664976749768497694977049771497724977349774497754977649777497784977949780497814978249783497844978549786497874978849789497904979149792497934979449795497964979749798497994980049801498024980349804498054980649807498084980949810498114981249813498144981549816498174981849819498204982149822498234982449825498264982749828498294983049831498324983349834498354983649837498384983949840498414984249843498444984549846498474984849849498504985149852498534985449855498564985749858498594986049861498624986349864498654986649867498684986949870498714987249873498744987549876498774987849879498804988149882498834988449885498864988749888498894989049891498924989349894498954989649897498984989949900499014990249903499044990549906499074990849909499104991149912499134991449915499164991749918499194992049921499224992349924499254992649927499284992949930499314993249933499344993549936499374993849939499404994149942499434994449945499464994749948499494995049951499524995349954499554995649957499584995949960499614996249963499644996549966499674996849969499704997149972499734997449975499764997749978499794998049981499824998349984499854998649987499884998949990499914999249993499944999549996499974999849999500005000150002500035000450005500065000750008500095001050011500125001350014500155001650017500185001950020500215002250023500245002550026500275002850029500305003150032500335003450035500365003750038500395004050041500425004350044500455004650047500485004950050500515005250053500545005550056500575005850059500605006150062500635006450065500665006750068500695007050071500725007350074500755007650077500785007950080500815008250083500845008550086500875008850089500905009150092500935009450095500965009750098500995010050101501025010350104501055010650107501085010950110501115011250113501145011550116501175011850119501205012150122501235012450125501265012750128501295013050131501325013350134501355013650137501385013950140501415014250143501445014550146501475014850149501505015150152501535015450155501565015750158501595016050161501625016350164501655016650167501685016950170501715017250173501745017550176501775017850179501805018150182501835018450185501865018750188501895019050191501925019350194501955019650197501985019950200502015020250203502045020550206502075020850209502105021150212502135021450215502165021750218502195022050221502225022350224502255022650227502285022950230502315023250233502345023550236502375023850239502405024150242502435024450245502465024750248502495025050251502525025350254502555025650257502585025950260502615026250263502645026550266502675026850269502705027150272502735027450275502765027750278502795028050281502825028350284502855028650287502885028950290502915029250293502945029550296502975029850299503005030150302503035030450305503065030750308503095031050311503125031350314503155031650317503185031950320503215032250323503245032550326503275032850329503305033150332503335033450335503365033750338503395034050341503425034350344503455034650347503485034950350503515035250353503545035550356503575035850359503605036150362503635036450365503665036750368503695037050371503725037350374503755037650377503785037950380503815038250383503845038550386503875038850389503905039150392503935039450395503965039750398503995040050401504025040350404504055040650407504085040950410504115041250413504145041550416504175041850419504205042150422504235042450425504265042750428504295043050431504325043350434504355043650437504385043950440504415044250443504445044550446504475044850449504505045150452504535045450455504565045750458504595046050461504625046350464504655046650467504685046950470504715047250473504745047550476504775047850479504805048150482504835048450485504865048750488504895049050491504925049350494504955049650497504985049950500505015050250503505045050550506505075050850509505105051150512505135051450515505165051750518505195052050521505225052350524505255052650527505285052950530505315053250533505345053550536505375053850539505405054150542505435054450545505465054750548505495055050551505525055350554505555055650557505585055950560505615056250563505645056550566505675056850569505705057150572505735057450575505765057750578505795058050581505825058350584505855058650587505885058950590505915059250593505945059550596505975059850599506005060150602506035060450605506065060750608506095061050611506125061350614506155061650617506185061950620506215062250623506245062550626506275062850629506305063150632506335063450635506365063750638506395064050641506425064350644506455064650647506485064950650506515065250653506545065550656506575065850659506605066150662506635066450665506665066750668506695067050671506725067350674506755067650677506785067950680506815068250683506845068550686506875068850689506905069150692506935069450695506965069750698506995070050701507025070350704507055070650707507085070950710507115071250713507145071550716507175071850719507205072150722507235072450725507265072750728507295073050731507325073350734507355073650737507385073950740507415074250743507445074550746507475074850749507505075150752507535075450755507565075750758507595076050761507625076350764507655076650767507685076950770507715077250773507745077550776507775077850779507805078150782507835078450785507865078750788507895079050791507925079350794507955079650797507985079950800508015080250803508045080550806508075080850809508105081150812508135081450815508165081750818508195082050821508225082350824508255082650827508285082950830508315083250833508345083550836508375083850839508405084150842508435084450845508465084750848508495085050851508525085350854508555085650857508585085950860508615086250863508645086550866508675086850869508705087150872508735087450875508765087750878508795088050881508825088350884508855088650887508885088950890508915089250893508945089550896508975089850899509005090150902509035090450905509065090750908509095091050911509125091350914509155091650917509185091950920509215092250923509245092550926509275092850929509305093150932509335093450935509365093750938509395094050941509425094350944509455094650947509485094950950509515095250953509545095550956509575095850959509605096150962509635096450965509665096750968509695097050971509725097350974509755097650977509785097950980509815098250983509845098550986509875098850989509905099150992509935099450995509965099750998509995100051001510025100351004510055100651007510085100951010510115101251013510145101551016510175101851019510205102151022510235102451025510265102751028510295103051031510325103351034510355103651037510385103951040510415104251043510445104551046510475104851049510505105151052510535105451055510565105751058510595106051061510625106351064510655106651067510685106951070510715107251073510745107551076510775107851079510805108151082510835108451085510865108751088510895109051091510925109351094510955109651097510985109951100511015110251103511045110551106511075110851109511105111151112511135111451115511165111751118511195112051121511225112351124511255112651127511285112951130511315113251133511345113551136511375113851139511405114151142511435114451145511465114751148511495115051151511525115351154511555115651157511585115951160511615116251163511645116551166511675116851169511705117151172511735117451175511765117751178511795118051181511825118351184511855118651187511885118951190511915119251193511945119551196511975119851199512005120151202512035120451205512065120751208512095121051211512125121351214512155121651217512185121951220512215122251223512245122551226512275122851229512305123151232512335123451235512365123751238512395124051241512425124351244512455124651247512485124951250512515125251253512545125551256512575125851259512605126151262512635126451265512665126751268512695127051271512725127351274512755127651277512785127951280512815128251283512845128551286512875128851289512905129151292512935129451295512965129751298512995130051301513025130351304513055130651307513085130951310513115131251313513145131551316513175131851319513205132151322513235132451325513265132751328513295133051331513325133351334513355133651337513385133951340513415134251343513445134551346513475134851349513505135151352513535135451355513565135751358513595136051361513625136351364513655136651367513685136951370513715137251373513745137551376513775137851379513805138151382513835138451385513865138751388513895139051391513925139351394513955139651397513985139951400514015140251403514045140551406514075140851409514105141151412514135141451415514165141751418514195142051421514225142351424514255142651427514285142951430514315143251433514345143551436514375143851439514405144151442514435144451445514465144751448514495145051451514525145351454514555145651457514585145951460514615146251463514645146551466514675146851469514705147151472514735147451475514765147751478514795148051481514825148351484514855148651487514885148951490514915149251493514945149551496514975149851499515005150151502515035150451505515065150751508515095151051511515125151351514515155151651517515185151951520515215152251523515245152551526515275152851529515305153151532515335153451535515365153751538515395154051541515425154351544515455154651547515485154951550515515155251553515545155551556515575155851559515605156151562515635156451565515665156751568515695157051571515725157351574515755157651577515785157951580515815158251583515845158551586515875158851589515905159151592515935159451595515965159751598515995160051601516025160351604516055160651607516085160951610516115161251613516145161551616516175161851619516205162151622516235162451625516265162751628516295163051631516325163351634516355163651637516385163951640516415164251643516445164551646516475164851649516505165151652516535165451655516565165751658516595166051661516625166351664516655166651667516685166951670516715167251673516745167551676516775167851679516805168151682516835168451685516865168751688516895169051691516925169351694516955169651697516985169951700517015170251703517045170551706517075170851709517105171151712517135171451715517165171751718517195172051721517225172351724517255172651727517285172951730517315173251733517345173551736517375173851739517405174151742517435174451745517465174751748517495175051751517525175351754517555175651757517585175951760517615176251763517645176551766517675176851769517705177151772517735177451775517765177751778517795178051781517825178351784517855178651787517885178951790517915179251793517945179551796517975179851799518005180151802518035180451805518065180751808518095181051811518125181351814518155181651817518185181951820518215182251823518245182551826518275182851829518305183151832518335183451835518365183751838518395184051841518425184351844518455184651847518485184951850518515185251853518545185551856518575185851859518605186151862518635186451865518665186751868518695187051871518725187351874518755187651877518785187951880518815188251883518845188551886518875188851889518905189151892518935189451895518965189751898518995190051901519025190351904519055190651907519085190951910519115191251913519145191551916519175191851919519205192151922519235192451925519265192751928519295193051931519325193351934519355193651937519385193951940519415194251943519445194551946519475194851949519505195151952519535195451955519565195751958519595196051961519625196351964519655196651967519685196951970519715197251973519745197551976519775197851979519805198151982519835198451985519865198751988519895199051991519925199351994519955199651997519985199952000520015200252003520045200552006520075200852009520105201152012520135201452015520165201752018520195202052021520225202352024520255202652027520285202952030520315203252033520345203552036520375203852039520405204152042520435204452045520465204752048520495205052051520525205352054520555205652057520585205952060520615206252063520645206552066520675206852069520705207152072520735207452075520765207752078520795208052081520825208352084520855208652087520885208952090520915209252093520945209552096520975209852099521005210152102521035210452105521065210752108521095211052111521125211352114521155211652117521185211952120521215212252123521245212552126521275212852129521305213152132521335213452135521365213752138521395214052141521425214352144521455214652147521485214952150521515215252153521545215552156521575215852159521605216152162521635216452165521665216752168521695217052171521725217352174521755217652177521785217952180521815218252183521845218552186521875218852189521905219152192521935219452195521965219752198521995220052201522025220352204522055220652207522085220952210522115221252213522145221552216522175221852219522205222152222522235222452225522265222752228522295223052231522325223352234522355223652237522385223952240522415224252243522445224552246522475224852249522505225152252522535225452255522565225752258522595226052261522625226352264522655226652267522685226952270522715227252273522745227552276522775227852279522805228152282522835228452285522865228752288522895229052291522925229352294522955229652297522985229952300523015230252303523045230552306523075230852309523105231152312523135231452315523165231752318523195232052321523225232352324523255232652327523285232952330523315233252333523345233552336523375233852339523405234152342523435234452345523465234752348523495235052351523525235352354523555235652357523585235952360523615236252363523645236552366523675236852369523705237152372523735237452375523765237752378523795238052381523825238352384523855238652387523885238952390523915239252393523945239552396523975239852399524005240152402524035240452405524065240752408524095241052411524125241352414524155241652417524185241952420524215242252423524245242552426524275242852429524305243152432524335243452435524365243752438524395244052441524425244352444524455244652447524485244952450524515245252453524545245552456524575245852459524605246152462524635246452465524665246752468524695247052471524725247352474524755247652477524785247952480524815248252483524845248552486524875248852489524905249152492524935249452495524965249752498524995250052501525025250352504525055250652507525085250952510525115251252513525145251552516525175251852519525205252152522525235252452525525265252752528525295253052531525325253352534525355253652537525385253952540525415254252543525445254552546525475254852549525505255152552525535255452555525565255752558525595256052561525625256352564525655256652567525685256952570525715257252573525745257552576525775257852579525805258152582525835258452585525865258752588525895259052591525925259352594525955259652597525985259952600526015260252603526045260552606526075260852609526105261152612526135261452615526165261752618526195262052621526225262352624526255262652627526285262952630526315263252633526345263552636526375263852639526405264152642526435264452645526465264752648526495265052651526525265352654526555265652657526585265952660526615266252663526645266552666526675266852669526705267152672526735267452675526765267752678526795268052681526825268352684526855268652687526885268952690526915269252693526945269552696526975269852699527005270152702527035270452705527065270752708527095271052711527125271352714527155271652717527185271952720527215272252723527245272552726527275272852729527305273152732527335273452735527365273752738527395274052741527425274352744527455274652747527485274952750527515275252753527545275552756527575275852759527605276152762527635276452765527665276752768527695277052771527725277352774527755277652777527785277952780527815278252783527845278552786527875278852789527905279152792527935279452795527965279752798527995280052801528025280352804528055280652807528085280952810528115281252813528145281552816528175281852819528205282152822528235282452825528265282752828528295283052831528325283352834528355283652837528385283952840528415284252843528445284552846528475284852849528505285152852528535285452855528565285752858528595286052861528625286352864528655286652867528685286952870528715287252873528745287552876528775287852879528805288152882528835288452885528865288752888528895289052891528925289352894528955289652897528985289952900529015290252903529045290552906529075290852909529105291152912529135291452915529165291752918529195292052921529225292352924529255292652927529285292952930529315293252933529345293552936529375293852939529405294152942529435294452945529465294752948529495295052951529525295352954529555295652957529585295952960529615296252963529645296552966529675296852969529705297152972529735297452975529765297752978529795298052981529825298352984529855298652987529885298952990529915299252993529945299552996529975299852999530005300153002530035300453005530065300753008530095301053011530125301353014530155301653017530185301953020530215302253023530245302553026530275302853029530305303153032530335303453035530365303753038530395304053041530425304353044530455304653047530485304953050530515305253053530545305553056530575305853059530605306153062530635306453065530665306753068530695307053071530725307353074530755307653077530785307953080530815308253083530845308553086530875308853089530905309153092530935309453095530965309753098530995310053101531025310353104531055310653107531085310953110531115311253113531145311553116531175311853119531205312153122531235312453125531265312753128531295313053131531325313353134531355313653137531385313953140531415314253143531445314553146531475314853149531505315153152531535315453155531565315753158531595316053161531625316353164531655316653167531685316953170531715317253173531745317553176531775317853179531805318153182531835318453185531865318753188531895319053191531925319353194531955319653197531985319953200532015320253203532045320553206532075320853209532105321153212532135321453215532165321753218532195322053221532225322353224532255322653227532285322953230532315323253233532345323553236532375323853239532405324153242532435324453245532465324753248532495325053251532525325353254532555325653257532585325953260532615326253263532645326553266532675326853269532705327153272532735327453275532765327753278532795328053281532825328353284532855328653287532885328953290532915329253293532945329553296532975329853299533005330153302533035330453305533065330753308533095331053311533125331353314533155331653317533185331953320533215332253323533245332553326533275332853329533305333153332533335333453335533365333753338533395334053341533425334353344533455334653347533485334953350533515335253353533545335553356533575335853359533605336153362533635336453365533665336753368533695337053371533725337353374533755337653377533785337953380533815338253383533845338553386533875338853389533905339153392533935339453395533965339753398533995340053401534025340353404534055340653407534085340953410534115341253413534145341553416534175341853419534205342153422534235342453425534265342753428534295343053431534325343353434534355343653437534385343953440534415344253443534445344553446534475344853449534505345153452534535345453455534565345753458534595346053461534625346353464534655346653467534685346953470534715347253473534745347553476534775347853479534805348153482534835348453485534865348753488534895349053491534925349353494534955349653497534985349953500535015350253503535045350553506535075350853509535105351153512535135351453515535165351753518535195352053521535225352353524535255352653527535285352953530535315353253533535345353553536535375353853539535405354153542535435354453545535465354753548535495355053551535525355353554535555355653557535585355953560535615356253563535645356553566535675356853569535705357153572535735357453575535765357753578535795358053581535825358353584535855358653587535885358953590535915359253593535945359553596535975359853599536005360153602536035360453605536065360753608536095361053611536125361353614536155361653617536185361953620536215362253623536245362553626536275362853629536305363153632536335363453635536365363753638536395364053641536425364353644536455364653647536485364953650536515365253653536545365553656536575365853659536605366153662536635366453665536665366753668536695367053671536725367353674536755367653677536785367953680536815368253683536845368553686536875368853689536905369153692536935369453695536965369753698536995370053701537025370353704537055370653707537085370953710537115371253713537145371553716537175371853719537205372153722537235372453725537265372753728537295373053731537325373353734537355373653737537385373953740537415374253743537445374553746537475374853749537505375153752537535375453755537565375753758537595376053761537625376353764537655376653767537685376953770537715377253773537745377553776537775377853779537805378153782537835378453785537865378753788537895379053791537925379353794537955379653797537985379953800538015380253803538045380553806538075380853809538105381153812538135381453815538165381753818538195382053821538225382353824538255382653827538285382953830538315383253833538345383553836538375383853839538405384153842538435384453845538465384753848538495385053851538525385353854538555385653857538585385953860538615386253863538645386553866538675386853869538705387153872538735387453875538765387753878538795388053881538825388353884538855388653887538885388953890538915389253893538945389553896538975389853899539005390153902539035390453905539065390753908539095391053911539125391353914539155391653917539185391953920539215392253923539245392553926539275392853929539305393153932539335393453935539365393753938539395394053941539425394353944539455394653947539485394953950539515395253953539545395553956539575395853959539605396153962539635396453965539665396753968539695397053971539725397353974539755397653977539785397953980539815398253983539845398553986539875398853989539905399153992539935399453995539965399753998539995400054001540025400354004540055400654007540085400954010540115401254013540145401554016540175401854019540205402154022540235402454025540265402754028540295403054031540325403354034540355403654037540385403954040540415404254043540445404554046540475404854049540505405154052540535405454055540565405754058540595406054061540625406354064540655406654067540685406954070540715407254073540745407554076540775407854079540805408154082540835408454085540865408754088540895409054091540925409354094540955409654097540985409954100541015410254103541045410554106541075410854109541105411154112541135411454115541165411754118541195412054121541225412354124541255412654127541285412954130541315413254133541345413554136541375413854139541405414154142541435414454145541465414754148541495415054151541525415354154541555415654157541585415954160541615416254163541645416554166541675416854169541705417154172541735417454175541765417754178541795418054181541825418354184541855418654187541885418954190541915419254193541945419554196541975419854199542005420154202542035420454205542065420754208542095421054211542125421354214542155421654217542185421954220542215422254223542245422554226542275422854229542305423154232542335423454235542365423754238542395424054241542425424354244542455424654247542485424954250542515425254253542545425554256542575425854259542605426154262542635426454265542665426754268542695427054271542725427354274542755427654277542785427954280542815428254283542845428554286542875428854289542905429154292542935429454295542965429754298542995430054301543025430354304543055430654307543085430954310543115431254313543145431554316543175431854319543205432154322543235432454325543265432754328543295433054331543325433354334543355433654337543385433954340543415434254343543445434554346543475434854349543505435154352543535435454355543565435754358543595436054361543625436354364543655436654367543685436954370543715437254373543745437554376543775437854379543805438154382543835438454385543865438754388543895439054391543925439354394543955439654397543985439954400544015440254403544045440554406544075440854409544105441154412544135441454415544165441754418544195442054421544225442354424544255442654427544285442954430544315443254433544345443554436544375443854439544405444154442544435444454445544465444754448544495445054451544525445354454544555445654457544585445954460544615446254463544645446554466544675446854469544705447154472544735447454475544765447754478544795448054481544825448354484544855448654487544885448954490544915449254493544945449554496544975449854499545005450154502545035450454505545065450754508545095451054511545125451354514545155451654517545185451954520545215452254523545245452554526545275452854529545305453154532545335453454535545365453754538545395454054541545425454354544545455454654547545485454954550545515455254553545545455554556545575455854559545605456154562545635456454565545665456754568545695457054571545725457354574545755457654577545785457954580545815458254583545845458554586545875458854589545905459154592545935459454595545965459754598545995460054601546025460354604546055460654607546085460954610546115461254613546145461554616546175461854619546205462154622546235462454625546265462754628546295463054631546325463354634546355463654637546385463954640546415464254643546445464554646546475464854649546505465154652546535465454655546565465754658546595466054661546625466354664546655466654667546685466954670546715467254673546745467554676546775467854679546805468154682546835468454685546865468754688546895469054691546925469354694546955469654697546985469954700547015470254703547045470554706547075470854709547105471154712547135471454715547165471754718547195472054721547225472354724547255472654727547285472954730547315473254733547345473554736547375473854739547405474154742547435474454745547465474754748547495475054751547525475354754547555475654757547585475954760547615476254763547645476554766547675476854769547705477154772547735477454775547765477754778547795478054781547825478354784547855478654787547885478954790547915479254793547945479554796547975479854799548005480154802548035480454805548065480754808548095481054811548125481354814548155481654817548185481954820548215482254823548245482554826548275482854829548305483154832548335483454835548365483754838548395484054841548425484354844548455484654847548485484954850548515485254853548545485554856548575485854859548605486154862548635486454865548665486754868548695487054871548725487354874548755487654877548785487954880548815488254883548845488554886548875488854889548905489154892548935489454895548965489754898548995490054901549025490354904549055490654907549085490954910549115491254913549145491554916549175491854919549205492154922549235492454925549265492754928549295493054931549325493354934549355493654937549385493954940549415494254943549445494554946549475494854949549505495154952549535495454955549565495754958549595496054961549625496354964549655496654967549685496954970549715497254973549745497554976549775497854979549805498154982549835498454985549865498754988549895499054991549925499354994549955499654997549985499955000550015500255003550045500555006550075500855009550105501155012550135501455015550165501755018550195502055021550225502355024550255502655027550285502955030550315503255033550345503555036550375503855039550405504155042550435504455045550465504755048550495505055051550525505355054550555505655057550585505955060550615506255063550645506555066550675506855069550705507155072550735507455075550765507755078550795508055081550825508355084550855508655087550885508955090550915509255093550945509555096550975509855099551005510155102551035510455105551065510755108551095511055111551125511355114551155511655117551185511955120551215512255123551245512555126551275512855129551305513155132551335513455135551365513755138551395514055141551425514355144551455514655147551485514955150551515515255153551545515555156551575515855159551605516155162551635516455165551665516755168551695517055171551725517355174551755517655177551785517955180551815518255183551845518555186551875518855189551905519155192551935519455195551965519755198551995520055201552025520355204552055520655207552085520955210552115521255213552145521555216552175521855219552205522155222552235522455225552265522755228552295523055231552325523355234552355523655237552385523955240552415524255243552445524555246552475524855249552505525155252552535525455255552565525755258552595526055261552625526355264552655526655267552685526955270552715527255273552745527555276552775527855279552805528155282552835528455285552865528755288552895529055291552925529355294552955529655297552985529955300553015530255303553045530555306553075530855309553105531155312553135531455315553165531755318553195532055321553225532355324553255532655327553285532955330553315533255333553345533555336553375533855339553405534155342553435534455345553465534755348553495535055351553525535355354553555535655357553585535955360553615536255363553645536555366553675536855369553705537155372553735537455375553765537755378553795538055381553825538355384553855538655387553885538955390553915539255393553945539555396553975539855399554005540155402554035540455405554065540755408554095541055411554125541355414554155541655417554185541955420554215542255423554245542555426554275542855429554305543155432554335543455435554365543755438554395544055441554425544355444554455544655447554485544955450554515545255453554545545555456554575545855459554605546155462554635546455465554665546755468554695547055471554725547355474554755547655477554785547955480554815548255483554845548555486554875548855489554905549155492554935549455495554965549755498554995550055501555025550355504555055550655507555085550955510555115551255513555145551555516555175551855519555205552155522555235552455525555265552755528555295553055531555325553355534555355553655537555385553955540555415554255543555445554555546555475554855549555505555155552555535555455555555565555755558555595556055561555625556355564555655556655567555685556955570555715557255573555745557555576555775557855579555805558155582555835558455585555865558755588555895559055591555925559355594555955559655597555985559955600556015560255603556045560555606556075560855609556105561155612556135561455615556165561755618556195562055621556225562355624556255562655627556285562955630556315563255633556345563555636556375563855639556405564155642556435564455645556465564755648556495565055651556525565355654556555565655657556585565955660556615566255663556645566555666556675566855669556705567155672556735567455675556765567755678556795568055681556825568355684556855568655687556885568955690556915569255693556945569555696556975569855699557005570155702557035570455705557065570755708557095571055711557125571355714557155571655717557185571955720557215572255723557245572555726557275572855729557305573155732557335573455735557365573755738557395574055741557425574355744557455574655747557485574955750557515575255753557545575555756557575575855759557605576155762557635576455765557665576755768557695577055771557725577355774557755577655777557785577955780557815578255783557845578555786557875578855789557905579155792557935579455795557965579755798557995580055801558025580355804558055580655807558085580955810558115581255813558145581555816558175581855819558205582155822558235582455825558265582755828558295583055831558325583355834558355583655837558385583955840558415584255843558445584555846558475584855849558505585155852558535585455855558565585755858558595586055861558625586355864558655586655867558685586955870558715587255873558745587555876558775587855879558805588155882558835588455885558865588755888558895589055891558925589355894558955589655897558985589955900559015590255903559045590555906559075590855909559105591155912559135591455915559165591755918559195592055921559225592355924559255592655927559285592955930559315593255933559345593555936559375593855939559405594155942559435594455945559465594755948559495595055951559525595355954559555595655957559585595955960559615596255963559645596555966559675596855969559705597155972559735597455975559765597755978559795598055981559825598355984559855598655987559885598955990559915599255993559945599555996559975599855999560005600156002560035600456005560065600756008560095601056011560125601356014560155601656017560185601956020560215602256023560245602556026560275602856029560305603156032560335603456035560365603756038560395604056041560425604356044560455604656047560485604956050560515605256053560545605556056560575605856059560605606156062560635606456065560665606756068560695607056071560725607356074560755607656077560785607956080560815608256083560845608556086560875608856089560905609156092560935609456095560965609756098560995610056101561025610356104561055610656107561085610956110561115611256113561145611556116561175611856119561205612156122561235612456125561265612756128561295613056131561325613356134561355613656137561385613956140561415614256143561445614556146561475614856149561505615156152561535615456155561565615756158561595616056161561625616356164561655616656167561685616956170561715617256173561745617556176561775617856179561805618156182561835618456185561865618756188561895619056191561925619356194561955619656197561985619956200562015620256203562045620556206562075620856209562105621156212562135621456215562165621756218562195622056221562225622356224562255622656227562285622956230562315623256233562345623556236562375623856239562405624156242562435624456245562465624756248562495625056251562525625356254562555625656257562585625956260562615626256263562645626556266562675626856269562705627156272562735627456275562765627756278562795628056281562825628356284562855628656287562885628956290562915629256293562945629556296562975629856299563005630156302563035630456305563065630756308563095631056311563125631356314563155631656317563185631956320563215632256323563245632556326563275632856329563305633156332563335633456335563365633756338563395634056341563425634356344563455634656347563485634956350563515635256353563545635556356563575635856359563605636156362563635636456365563665636756368563695637056371563725637356374563755637656377563785637956380563815638256383563845638556386563875638856389563905639156392563935639456395563965639756398563995640056401564025640356404564055640656407564085640956410564115641256413564145641556416564175641856419564205642156422564235642456425564265642756428564295643056431564325643356434564355643656437564385643956440564415644256443564445644556446564475644856449564505645156452564535645456455564565645756458564595646056461564625646356464564655646656467564685646956470564715647256473564745647556476564775647856479564805648156482564835648456485564865648756488564895649056491564925649356494564955649656497564985649956500565015650256503565045650556506565075650856509565105651156512565135651456515565165651756518565195652056521565225652356524565255652656527565285652956530565315653256533565345653556536565375653856539565405654156542565435654456545565465654756548565495655056551565525655356554565555655656557565585655956560565615656256563565645656556566565675656856569565705657156572565735657456575565765657756578565795658056581565825658356584565855658656587565885658956590565915659256593565945659556596565975659856599566005660156602566035660456605566065660756608566095661056611566125661356614566155661656617566185661956620566215662256623566245662556626566275662856629566305663156632566335663456635566365663756638566395664056641566425664356644566455664656647566485664956650566515665256653566545665556656566575665856659566605666156662566635666456665566665666756668566695667056671566725667356674566755667656677566785667956680566815668256683566845668556686566875668856689566905669156692566935669456695566965669756698566995670056701567025670356704567055670656707567085670956710567115671256713567145671556716567175671856719567205672156722567235672456725567265672756728567295673056731567325673356734567355673656737567385673956740567415674256743567445674556746567475674856749567505675156752567535675456755567565675756758567595676056761567625676356764567655676656767567685676956770567715677256773567745677556776567775677856779567805678156782567835678456785567865678756788567895679056791567925679356794567955679656797567985679956800568015680256803568045680556806568075680856809568105681156812568135681456815568165681756818568195682056821568225682356824568255682656827568285682956830568315683256833568345683556836568375683856839568405684156842568435684456845568465684756848568495685056851568525685356854568555685656857568585685956860568615686256863568645686556866568675686856869568705687156872568735687456875568765687756878568795688056881568825688356884568855688656887568885688956890568915689256893568945689556896568975689856899569005690156902569035690456905569065690756908569095691056911569125691356914569155691656917569185691956920569215692256923569245692556926569275692856929569305693156932569335693456935569365693756938569395694056941569425694356944569455694656947569485694956950569515695256953569545695556956569575695856959569605696156962569635696456965569665696756968569695697056971569725697356974569755697656977569785697956980569815698256983569845698556986569875698856989569905699156992569935699456995569965699756998569995700057001570025700357004570055700657007570085700957010570115701257013570145701557016570175701857019570205702157022570235702457025570265702757028570295703057031570325703357034570355703657037570385703957040570415704257043570445704557046570475704857049570505705157052570535705457055570565705757058570595706057061570625706357064570655706657067570685706957070570715707257073570745707557076570775707857079570805708157082570835708457085570865708757088570895709057091570925709357094570955709657097570985709957100571015710257103571045710557106571075710857109571105711157112571135711457115571165711757118571195712057121571225712357124571255712657127571285712957130571315713257133571345713557136571375713857139571405714157142571435714457145571465714757148571495715057151571525715357154571555715657157571585715957160571615716257163571645716557166571675716857169571705717157172571735717457175571765717757178571795718057181571825718357184571855718657187571885718957190571915719257193571945719557196571975719857199572005720157202572035720457205572065720757208572095721057211572125721357214572155721657217572185721957220572215722257223572245722557226572275722857229572305723157232572335723457235572365723757238572395724057241572425724357244572455724657247572485724957250572515725257253572545725557256572575725857259572605726157262572635726457265572665726757268572695727057271572725727357274572755727657277572785727957280572815728257283572845728557286572875728857289572905729157292572935729457295572965729757298572995730057301573025730357304573055730657307573085730957310573115731257313573145731557316573175731857319573205732157322573235732457325573265732757328573295733057331573325733357334573355733657337573385733957340573415734257343573445734557346573475734857349573505735157352573535735457355573565735757358573595736057361573625736357364573655736657367573685736957370573715737257373573745737557376573775737857379573805738157382573835738457385573865738757388573895739057391573925739357394573955739657397573985739957400574015740257403574045740557406574075740857409574105741157412574135741457415574165741757418574195742057421574225742357424574255742657427574285742957430574315743257433574345743557436574375743857439574405744157442574435744457445574465744757448574495745057451574525745357454574555745657457574585745957460574615746257463574645746557466574675746857469574705747157472574735747457475574765747757478574795748057481574825748357484574855748657487574885748957490574915749257493574945749557496574975749857499575005750157502575035750457505575065750757508575095751057511575125751357514575155751657517575185751957520575215752257523575245752557526575275752857529575305753157532575335753457535575365753757538575395754057541575425754357544575455754657547575485754957550575515755257553575545755557556575575755857559575605756157562575635756457565575665756757568575695757057571575725757357574575755757657577575785757957580575815758257583575845758557586575875758857589575905759157592575935759457595575965759757598575995760057601576025760357604576055760657607576085760957610576115761257613576145761557616576175761857619576205762157622576235762457625576265762757628576295763057631576325763357634576355763657637576385763957640576415764257643576445764557646576475764857649576505765157652576535765457655576565765757658576595766057661576625766357664576655766657667576685766957670576715767257673576745767557676576775767857679576805768157682576835768457685576865768757688576895769057691576925769357694576955769657697576985769957700577015770257703577045770557706577075770857709577105771157712577135771457715577165771757718577195772057721577225772357724577255772657727577285772957730577315773257733577345773557736577375773857739577405774157742577435774457745577465774757748577495775057751577525775357754577555775657757577585775957760577615776257763577645776557766577675776857769577705777157772577735777457775577765777757778577795778057781577825778357784577855778657787577885778957790577915779257793577945779557796577975779857799578005780157802578035780457805578065780757808578095781057811578125781357814578155781657817578185781957820578215782257823578245782557826578275782857829578305783157832578335783457835578365783757838578395784057841578425784357844578455784657847578485784957850578515785257853578545785557856578575785857859578605786157862578635786457865578665786757868578695787057871578725787357874578755787657877578785787957880578815788257883578845788557886578875788857889578905789157892578935789457895578965789757898578995790057901579025790357904579055790657907579085790957910579115791257913579145791557916579175791857919579205792157922579235792457925579265792757928579295793057931579325793357934579355793657937579385793957940579415794257943
  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. /******/
  29. /******/ // The require function
  30. /******/ function __w_pdfjs_require__(moduleId) {
  31. /******/
  32. /******/ // Check if module is in cache
  33. /******/ if(installedModules[moduleId])
  34. /******/ return installedModules[moduleId].exports;
  35. /******/
  36. /******/ // Create a new module (and put it into the cache)
  37. /******/ var module = installedModules[moduleId] = {
  38. /******/ i: moduleId,
  39. /******/ l: false,
  40. /******/ exports: {}
  41. /******/ };
  42. /******/
  43. /******/ // Execute the module function
  44. /******/ modules[moduleId].call(module.exports, module, module.exports, __w_pdfjs_require__);
  45. /******/
  46. /******/ // Flag the module as loaded
  47. /******/ module.l = true;
  48. /******/
  49. /******/ // Return the exports of the module
  50. /******/ return module.exports;
  51. /******/ }
  52. /******/
  53. /******/
  54. /******/ // expose the modules object (__webpack_modules__)
  55. /******/ __w_pdfjs_require__.m = modules;
  56. /******/
  57. /******/ // expose the module cache
  58. /******/ __w_pdfjs_require__.c = installedModules;
  59. /******/
  60. /******/ // identity function for calling harmony imports with the correct context
  61. /******/ __w_pdfjs_require__.i = function(value) { return value; };
  62. /******/
  63. /******/ // define getter function for harmony exports
  64. /******/ __w_pdfjs_require__.d = function(exports, name, getter) {
  65. /******/ if(!__w_pdfjs_require__.o(exports, name)) {
  66. /******/ Object.defineProperty(exports, name, {
  67. /******/ configurable: false,
  68. /******/ enumerable: true,
  69. /******/ get: getter
  70. /******/ });
  71. /******/ }
  72. /******/ };
  73. /******/
  74. /******/ // getDefaultExport function for compatibility with non-harmony modules
  75. /******/ __w_pdfjs_require__.n = function(module) {
  76. /******/ var getter = module && module.__esModule ?
  77. /******/ function getDefault() { return module['default']; } :
  78. /******/ function getModuleExports() { return module; };
  79. /******/ __w_pdfjs_require__.d(getter, 'a', getter);
  80. /******/ return getter;
  81. /******/ };
  82. /******/
  83. /******/ // Object.prototype.hasOwnProperty.call
  84. /******/ __w_pdfjs_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
  85. /******/
  86. /******/ // __webpack_public_path__
  87. /******/ __w_pdfjs_require__.p = "";
  88. /******/
  89. /******/ // Load entry module and return exports
  90. /******/ return __w_pdfjs_require__(__w_pdfjs_require__.s = 48);
  91. /******/ })
  92. /************************************************************************/
  93. /******/ ([
  94. /* 0 */
  95. /***/ (function(module, exports, __w_pdfjs_require__) {
  96. "use strict";
  97. /* WEBPACK VAR INJECTION */(function(global) {
  98. var compatibility = __w_pdfjs_require__(47);
  99. var globalScope = typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : this;
  100. var FONT_IDENTITY_MATRIX = [
  101. 0.001,
  102. 0,
  103. 0,
  104. 0.001,
  105. 0,
  106. 0
  107. ];
  108. var TextRenderingMode = {
  109. FILL: 0,
  110. STROKE: 1,
  111. FILL_STROKE: 2,
  112. INVISIBLE: 3,
  113. FILL_ADD_TO_PATH: 4,
  114. STROKE_ADD_TO_PATH: 5,
  115. FILL_STROKE_ADD_TO_PATH: 6,
  116. ADD_TO_PATH: 7,
  117. FILL_STROKE_MASK: 3,
  118. ADD_TO_PATH_FLAG: 4
  119. };
  120. var ImageKind = {
  121. GRAYSCALE_1BPP: 1,
  122. RGB_24BPP: 2,
  123. RGBA_32BPP: 3
  124. };
  125. var AnnotationType = {
  126. TEXT: 1,
  127. LINK: 2,
  128. FREETEXT: 3,
  129. LINE: 4,
  130. SQUARE: 5,
  131. CIRCLE: 6,
  132. POLYGON: 7,
  133. POLYLINE: 8,
  134. HIGHLIGHT: 9,
  135. UNDERLINE: 10,
  136. SQUIGGLY: 11,
  137. STRIKEOUT: 12,
  138. STAMP: 13,
  139. CARET: 14,
  140. INK: 15,
  141. POPUP: 16,
  142. FILEATTACHMENT: 17,
  143. SOUND: 18,
  144. MOVIE: 19,
  145. WIDGET: 20,
  146. SCREEN: 21,
  147. PRINTERMARK: 22,
  148. TRAPNET: 23,
  149. WATERMARK: 24,
  150. THREED: 25,
  151. REDACT: 26
  152. };
  153. var AnnotationFlag = {
  154. INVISIBLE: 0x01,
  155. HIDDEN: 0x02,
  156. PRINT: 0x04,
  157. NOZOOM: 0x08,
  158. NOROTATE: 0x10,
  159. NOVIEW: 0x20,
  160. READONLY: 0x40,
  161. LOCKED: 0x80,
  162. TOGGLENOVIEW: 0x100,
  163. LOCKEDCONTENTS: 0x200
  164. };
  165. var AnnotationFieldFlag = {
  166. READONLY: 0x0000001,
  167. REQUIRED: 0x0000002,
  168. NOEXPORT: 0x0000004,
  169. MULTILINE: 0x0001000,
  170. PASSWORD: 0x0002000,
  171. NOTOGGLETOOFF: 0x0004000,
  172. RADIO: 0x0008000,
  173. PUSHBUTTON: 0x0010000,
  174. COMBO: 0x0020000,
  175. EDIT: 0x0040000,
  176. SORT: 0x0080000,
  177. FILESELECT: 0x0100000,
  178. MULTISELECT: 0x0200000,
  179. DONOTSPELLCHECK: 0x0400000,
  180. DONOTSCROLL: 0x0800000,
  181. COMB: 0x1000000,
  182. RICHTEXT: 0x2000000,
  183. RADIOSINUNISON: 0x2000000,
  184. COMMITONSELCHANGE: 0x4000000
  185. };
  186. var AnnotationBorderStyleType = {
  187. SOLID: 1,
  188. DASHED: 2,
  189. BEVELED: 3,
  190. INSET: 4,
  191. UNDERLINE: 5
  192. };
  193. var StreamType = {
  194. UNKNOWN: 0,
  195. FLATE: 1,
  196. LZW: 2,
  197. DCT: 3,
  198. JPX: 4,
  199. JBIG: 5,
  200. A85: 6,
  201. AHX: 7,
  202. CCF: 8,
  203. RL: 9
  204. };
  205. var FontType = {
  206. UNKNOWN: 0,
  207. TYPE1: 1,
  208. TYPE1C: 2,
  209. CIDFONTTYPE0: 3,
  210. CIDFONTTYPE0C: 4,
  211. TRUETYPE: 5,
  212. CIDFONTTYPE2: 6,
  213. TYPE3: 7,
  214. OPENTYPE: 8,
  215. TYPE0: 9,
  216. MMTYPE1: 10
  217. };
  218. var VERBOSITY_LEVELS = {
  219. errors: 0,
  220. warnings: 1,
  221. infos: 5
  222. };
  223. var CMapCompressionType = {
  224. NONE: 0,
  225. BINARY: 1,
  226. STREAM: 2
  227. };
  228. var OPS = {
  229. dependency: 1,
  230. setLineWidth: 2,
  231. setLineCap: 3,
  232. setLineJoin: 4,
  233. setMiterLimit: 5,
  234. setDash: 6,
  235. setRenderingIntent: 7,
  236. setFlatness: 8,
  237. setGState: 9,
  238. save: 10,
  239. restore: 11,
  240. transform: 12,
  241. moveTo: 13,
  242. lineTo: 14,
  243. curveTo: 15,
  244. curveTo2: 16,
  245. curveTo3: 17,
  246. closePath: 18,
  247. rectangle: 19,
  248. stroke: 20,
  249. closeStroke: 21,
  250. fill: 22,
  251. eoFill: 23,
  252. fillStroke: 24,
  253. eoFillStroke: 25,
  254. closeFillStroke: 26,
  255. closeEOFillStroke: 27,
  256. endPath: 28,
  257. clip: 29,
  258. eoClip: 30,
  259. beginText: 31,
  260. endText: 32,
  261. setCharSpacing: 33,
  262. setWordSpacing: 34,
  263. setHScale: 35,
  264. setLeading: 36,
  265. setFont: 37,
  266. setTextRenderingMode: 38,
  267. setTextRise: 39,
  268. moveText: 40,
  269. setLeadingMoveText: 41,
  270. setTextMatrix: 42,
  271. nextLine: 43,
  272. showText: 44,
  273. showSpacedText: 45,
  274. nextLineShowText: 46,
  275. nextLineSetSpacingShowText: 47,
  276. setCharWidth: 48,
  277. setCharWidthAndBounds: 49,
  278. setStrokeColorSpace: 50,
  279. setFillColorSpace: 51,
  280. setStrokeColor: 52,
  281. setStrokeColorN: 53,
  282. setFillColor: 54,
  283. setFillColorN: 55,
  284. setStrokeGray: 56,
  285. setFillGray: 57,
  286. setStrokeRGBColor: 58,
  287. setFillRGBColor: 59,
  288. setStrokeCMYKColor: 60,
  289. setFillCMYKColor: 61,
  290. shadingFill: 62,
  291. beginInlineImage: 63,
  292. beginImageData: 64,
  293. endInlineImage: 65,
  294. paintXObject: 66,
  295. markPoint: 67,
  296. markPointProps: 68,
  297. beginMarkedContent: 69,
  298. beginMarkedContentProps: 70,
  299. endMarkedContent: 71,
  300. beginCompat: 72,
  301. endCompat: 73,
  302. paintFormXObjectBegin: 74,
  303. paintFormXObjectEnd: 75,
  304. beginGroup: 76,
  305. endGroup: 77,
  306. beginAnnotations: 78,
  307. endAnnotations: 79,
  308. beginAnnotation: 80,
  309. endAnnotation: 81,
  310. paintJpegXObject: 82,
  311. paintImageMaskXObject: 83,
  312. paintImageMaskXObjectGroup: 84,
  313. paintImageXObject: 85,
  314. paintInlineImageXObject: 86,
  315. paintInlineImageXObjectGroup: 87,
  316. paintImageXObjectRepeat: 88,
  317. paintImageMaskXObjectRepeat: 89,
  318. paintSolidColorImageMask: 90,
  319. constructPath: 91
  320. };
  321. var verbosity = VERBOSITY_LEVELS.warnings;
  322. function setVerbosityLevel(level) {
  323. verbosity = level;
  324. }
  325. function getVerbosityLevel() {
  326. return verbosity;
  327. }
  328. function info(msg) {
  329. if (verbosity >= VERBOSITY_LEVELS.infos) {
  330. console.log('Info: ' + msg);
  331. }
  332. }
  333. function warn(msg) {
  334. if (verbosity >= VERBOSITY_LEVELS.warnings) {
  335. console.log('Warning: ' + msg);
  336. }
  337. }
  338. function deprecated(details) {
  339. console.log('Deprecated API usage: ' + details);
  340. }
  341. function error(msg) {
  342. if (verbosity >= VERBOSITY_LEVELS.errors) {
  343. console.log('Error: ' + msg);
  344. console.log(backtrace());
  345. }
  346. throw new Error(msg);
  347. }
  348. function backtrace() {
  349. try {
  350. throw new Error();
  351. } catch (e) {
  352. return e.stack ? e.stack.split('\n').slice(2).join('\n') : '';
  353. }
  354. }
  355. function assert(cond, msg) {
  356. if (!cond) {
  357. error(msg);
  358. }
  359. }
  360. var UNSUPPORTED_FEATURES = {
  361. unknown: 'unknown',
  362. forms: 'forms',
  363. javaScript: 'javaScript',
  364. smask: 'smask',
  365. shadingPattern: 'shadingPattern',
  366. font: 'font'
  367. };
  368. function isSameOrigin(baseUrl, otherUrl) {
  369. try {
  370. var base = new URL(baseUrl);
  371. if (!base.origin || base.origin === 'null') {
  372. return false;
  373. }
  374. } catch (e) {
  375. return false;
  376. }
  377. var other = new URL(otherUrl, base);
  378. return base.origin === other.origin;
  379. }
  380. function isValidProtocol(url) {
  381. if (!url) {
  382. return false;
  383. }
  384. switch (url.protocol) {
  385. case 'http:':
  386. case 'https:':
  387. case 'ftp:':
  388. case 'mailto:':
  389. case 'tel:':
  390. return true;
  391. default:
  392. return false;
  393. }
  394. }
  395. function createValidAbsoluteUrl(url, baseUrl) {
  396. if (!url) {
  397. return null;
  398. }
  399. try {
  400. var absoluteUrl = baseUrl ? new URL(url, baseUrl) : new URL(url);
  401. if (isValidProtocol(absoluteUrl)) {
  402. return absoluteUrl;
  403. }
  404. } catch (ex) {
  405. }
  406. return null;
  407. }
  408. function shadow(obj, prop, value) {
  409. Object.defineProperty(obj, prop, {
  410. value: value,
  411. enumerable: true,
  412. configurable: true,
  413. writable: false
  414. });
  415. return value;
  416. }
  417. function getLookupTableFactory(initializer) {
  418. var lookup;
  419. return function () {
  420. if (initializer) {
  421. lookup = Object.create(null);
  422. initializer(lookup);
  423. initializer = null;
  424. }
  425. return lookup;
  426. };
  427. }
  428. var PasswordResponses = {
  429. NEED_PASSWORD: 1,
  430. INCORRECT_PASSWORD: 2
  431. };
  432. var PasswordException = function PasswordExceptionClosure() {
  433. function PasswordException(msg, code) {
  434. this.name = 'PasswordException';
  435. this.message = msg;
  436. this.code = code;
  437. }
  438. PasswordException.prototype = new Error();
  439. PasswordException.constructor = PasswordException;
  440. return PasswordException;
  441. }();
  442. var UnknownErrorException = function UnknownErrorExceptionClosure() {
  443. function UnknownErrorException(msg, details) {
  444. this.name = 'UnknownErrorException';
  445. this.message = msg;
  446. this.details = details;
  447. }
  448. UnknownErrorException.prototype = new Error();
  449. UnknownErrorException.constructor = UnknownErrorException;
  450. return UnknownErrorException;
  451. }();
  452. var InvalidPDFException = function InvalidPDFExceptionClosure() {
  453. function InvalidPDFException(msg) {
  454. this.name = 'InvalidPDFException';
  455. this.message = msg;
  456. }
  457. InvalidPDFException.prototype = new Error();
  458. InvalidPDFException.constructor = InvalidPDFException;
  459. return InvalidPDFException;
  460. }();
  461. var MissingPDFException = function MissingPDFExceptionClosure() {
  462. function MissingPDFException(msg) {
  463. this.name = 'MissingPDFException';
  464. this.message = msg;
  465. }
  466. MissingPDFException.prototype = new Error();
  467. MissingPDFException.constructor = MissingPDFException;
  468. return MissingPDFException;
  469. }();
  470. var UnexpectedResponseException = function UnexpectedResponseExceptionClosure() {
  471. function UnexpectedResponseException(msg, status) {
  472. this.name = 'UnexpectedResponseException';
  473. this.message = msg;
  474. this.status = status;
  475. }
  476. UnexpectedResponseException.prototype = new Error();
  477. UnexpectedResponseException.constructor = UnexpectedResponseException;
  478. return UnexpectedResponseException;
  479. }();
  480. var NotImplementedException = function NotImplementedExceptionClosure() {
  481. function NotImplementedException(msg) {
  482. this.message = msg;
  483. }
  484. NotImplementedException.prototype = new Error();
  485. NotImplementedException.prototype.name = 'NotImplementedException';
  486. NotImplementedException.constructor = NotImplementedException;
  487. return NotImplementedException;
  488. }();
  489. var MissingDataException = function MissingDataExceptionClosure() {
  490. function MissingDataException(begin, end) {
  491. this.begin = begin;
  492. this.end = end;
  493. this.message = 'Missing data [' + begin + ', ' + end + ')';
  494. }
  495. MissingDataException.prototype = new Error();
  496. MissingDataException.prototype.name = 'MissingDataException';
  497. MissingDataException.constructor = MissingDataException;
  498. return MissingDataException;
  499. }();
  500. var XRefParseException = function XRefParseExceptionClosure() {
  501. function XRefParseException(msg) {
  502. this.message = msg;
  503. }
  504. XRefParseException.prototype = new Error();
  505. XRefParseException.prototype.name = 'XRefParseException';
  506. XRefParseException.constructor = XRefParseException;
  507. return XRefParseException;
  508. }();
  509. var NullCharactersRegExp = /\x00/g;
  510. function removeNullCharacters(str) {
  511. if (typeof str !== 'string') {
  512. warn('The argument for removeNullCharacters must be a string.');
  513. return str;
  514. }
  515. return str.replace(NullCharactersRegExp, '');
  516. }
  517. function bytesToString(bytes) {
  518. assert(bytes !== null && typeof bytes === 'object' && bytes.length !== undefined, 'Invalid argument for bytesToString');
  519. var length = bytes.length;
  520. var MAX_ARGUMENT_COUNT = 8192;
  521. if (length < MAX_ARGUMENT_COUNT) {
  522. return String.fromCharCode.apply(null, bytes);
  523. }
  524. var strBuf = [];
  525. for (var i = 0; i < length; i += MAX_ARGUMENT_COUNT) {
  526. var chunkEnd = Math.min(i + MAX_ARGUMENT_COUNT, length);
  527. var chunk = bytes.subarray(i, chunkEnd);
  528. strBuf.push(String.fromCharCode.apply(null, chunk));
  529. }
  530. return strBuf.join('');
  531. }
  532. function stringToBytes(str) {
  533. assert(typeof str === 'string', 'Invalid argument for stringToBytes');
  534. var length = str.length;
  535. var bytes = new Uint8Array(length);
  536. for (var i = 0; i < length; ++i) {
  537. bytes[i] = str.charCodeAt(i) & 0xFF;
  538. }
  539. return bytes;
  540. }
  541. function arrayByteLength(arr) {
  542. if (arr.length !== undefined) {
  543. return arr.length;
  544. }
  545. assert(arr.byteLength !== undefined);
  546. return arr.byteLength;
  547. }
  548. function arraysToBytes(arr) {
  549. if (arr.length === 1 && arr[0] instanceof Uint8Array) {
  550. return arr[0];
  551. }
  552. var resultLength = 0;
  553. var i, ii = arr.length;
  554. var item, itemLength;
  555. for (i = 0; i < ii; i++) {
  556. item = arr[i];
  557. itemLength = arrayByteLength(item);
  558. resultLength += itemLength;
  559. }
  560. var pos = 0;
  561. var data = new Uint8Array(resultLength);
  562. for (i = 0; i < ii; i++) {
  563. item = arr[i];
  564. if (!(item instanceof Uint8Array)) {
  565. if (typeof item === 'string') {
  566. item = stringToBytes(item);
  567. } else {
  568. item = new Uint8Array(item);
  569. }
  570. }
  571. itemLength = item.byteLength;
  572. data.set(item, pos);
  573. pos += itemLength;
  574. }
  575. return data;
  576. }
  577. function string32(value) {
  578. return String.fromCharCode(value >> 24 & 0xff, value >> 16 & 0xff, value >> 8 & 0xff, value & 0xff);
  579. }
  580. function log2(x) {
  581. var n = 1, i = 0;
  582. while (x > n) {
  583. n <<= 1;
  584. i++;
  585. }
  586. return i;
  587. }
  588. function readInt8(data, start) {
  589. return data[start] << 24 >> 24;
  590. }
  591. function readUint16(data, offset) {
  592. return data[offset] << 8 | data[offset + 1];
  593. }
  594. function readUint32(data, offset) {
  595. return (data[offset] << 24 | data[offset + 1] << 16 | data[offset + 2] << 8 | data[offset + 3]) >>> 0;
  596. }
  597. function isLittleEndian() {
  598. var buffer8 = new Uint8Array(2);
  599. buffer8[0] = 1;
  600. var buffer16 = new Uint16Array(buffer8.buffer);
  601. return buffer16[0] === 1;
  602. }
  603. function isEvalSupported() {
  604. try {
  605. new Function('');
  606. return true;
  607. } catch (e) {
  608. return false;
  609. }
  610. }
  611. var Uint32ArrayView = function Uint32ArrayViewClosure() {
  612. function Uint32ArrayView(buffer, length) {
  613. this.buffer = buffer;
  614. this.byteLength = buffer.length;
  615. this.length = length === undefined ? this.byteLength >> 2 : length;
  616. ensureUint32ArrayViewProps(this.length);
  617. }
  618. Uint32ArrayView.prototype = Object.create(null);
  619. var uint32ArrayViewSetters = 0;
  620. function createUint32ArrayProp(index) {
  621. return {
  622. get: function () {
  623. var buffer = this.buffer, offset = index << 2;
  624. return (buffer[offset] | buffer[offset + 1] << 8 | buffer[offset + 2] << 16 | buffer[offset + 3] << 24) >>> 0;
  625. },
  626. set: function (value) {
  627. var buffer = this.buffer, offset = index << 2;
  628. buffer[offset] = value & 255;
  629. buffer[offset + 1] = value >> 8 & 255;
  630. buffer[offset + 2] = value >> 16 & 255;
  631. buffer[offset + 3] = value >>> 24 & 255;
  632. }
  633. };
  634. }
  635. function ensureUint32ArrayViewProps(length) {
  636. while (uint32ArrayViewSetters < length) {
  637. Object.defineProperty(Uint32ArrayView.prototype, uint32ArrayViewSetters, createUint32ArrayProp(uint32ArrayViewSetters));
  638. uint32ArrayViewSetters++;
  639. }
  640. }
  641. return Uint32ArrayView;
  642. }();
  643. exports.Uint32ArrayView = Uint32ArrayView;
  644. var IDENTITY_MATRIX = [
  645. 1,
  646. 0,
  647. 0,
  648. 1,
  649. 0,
  650. 0
  651. ];
  652. var Util = function UtilClosure() {
  653. function Util() {
  654. }
  655. var rgbBuf = [
  656. 'rgb(',
  657. 0,
  658. ',',
  659. 0,
  660. ',',
  661. 0,
  662. ')'
  663. ];
  664. Util.makeCssRgb = function Util_makeCssRgb(r, g, b) {
  665. rgbBuf[1] = r;
  666. rgbBuf[3] = g;
  667. rgbBuf[5] = b;
  668. return rgbBuf.join('');
  669. };
  670. Util.transform = function Util_transform(m1, m2) {
  671. return [
  672. m1[0] * m2[0] + m1[2] * m2[1],
  673. m1[1] * m2[0] + m1[3] * m2[1],
  674. m1[0] * m2[2] + m1[2] * m2[3],
  675. m1[1] * m2[2] + m1[3] * m2[3],
  676. m1[0] * m2[4] + m1[2] * m2[5] + m1[4],
  677. m1[1] * m2[4] + m1[3] * m2[5] + m1[5]
  678. ];
  679. };
  680. Util.applyTransform = function Util_applyTransform(p, m) {
  681. var xt = p[0] * m[0] + p[1] * m[2] + m[4];
  682. var yt = p[0] * m[1] + p[1] * m[3] + m[5];
  683. return [
  684. xt,
  685. yt
  686. ];
  687. };
  688. Util.applyInverseTransform = function Util_applyInverseTransform(p, m) {
  689. var d = m[0] * m[3] - m[1] * m[2];
  690. var xt = (p[0] * m[3] - p[1] * m[2] + m[2] * m[5] - m[4] * m[3]) / d;
  691. var yt = (-p[0] * m[1] + p[1] * m[0] + m[4] * m[1] - m[5] * m[0]) / d;
  692. return [
  693. xt,
  694. yt
  695. ];
  696. };
  697. Util.getAxialAlignedBoundingBox = function Util_getAxialAlignedBoundingBox(r, m) {
  698. var p1 = Util.applyTransform(r, m);
  699. var p2 = Util.applyTransform(r.slice(2, 4), m);
  700. var p3 = Util.applyTransform([
  701. r[0],
  702. r[3]
  703. ], m);
  704. var p4 = Util.applyTransform([
  705. r[2],
  706. r[1]
  707. ], m);
  708. return [
  709. Math.min(p1[0], p2[0], p3[0], p4[0]),
  710. Math.min(p1[1], p2[1], p3[1], p4[1]),
  711. Math.max(p1[0], p2[0], p3[0], p4[0]),
  712. Math.max(p1[1], p2[1], p3[1], p4[1])
  713. ];
  714. };
  715. Util.inverseTransform = function Util_inverseTransform(m) {
  716. var d = m[0] * m[3] - m[1] * m[2];
  717. return [
  718. m[3] / d,
  719. -m[1] / d,
  720. -m[2] / d,
  721. m[0] / d,
  722. (m[2] * m[5] - m[4] * m[3]) / d,
  723. (m[4] * m[1] - m[5] * m[0]) / d
  724. ];
  725. };
  726. Util.apply3dTransform = function Util_apply3dTransform(m, v) {
  727. return [
  728. m[0] * v[0] + m[1] * v[1] + m[2] * v[2],
  729. m[3] * v[0] + m[4] * v[1] + m[5] * v[2],
  730. m[6] * v[0] + m[7] * v[1] + m[8] * v[2]
  731. ];
  732. };
  733. Util.singularValueDecompose2dScale = function Util_singularValueDecompose2dScale(m) {
  734. var transpose = [
  735. m[0],
  736. m[2],
  737. m[1],
  738. m[3]
  739. ];
  740. var a = m[0] * transpose[0] + m[1] * transpose[2];
  741. var b = m[0] * transpose[1] + m[1] * transpose[3];
  742. var c = m[2] * transpose[0] + m[3] * transpose[2];
  743. var d = m[2] * transpose[1] + m[3] * transpose[3];
  744. var first = (a + d) / 2;
  745. var second = Math.sqrt((a + d) * (a + d) - 4 * (a * d - c * b)) / 2;
  746. var sx = first + second || 1;
  747. var sy = first - second || 1;
  748. return [
  749. Math.sqrt(sx),
  750. Math.sqrt(sy)
  751. ];
  752. };
  753. Util.normalizeRect = function Util_normalizeRect(rect) {
  754. var r = rect.slice(0);
  755. if (rect[0] > rect[2]) {
  756. r[0] = rect[2];
  757. r[2] = rect[0];
  758. }
  759. if (rect[1] > rect[3]) {
  760. r[1] = rect[3];
  761. r[3] = rect[1];
  762. }
  763. return r;
  764. };
  765. Util.intersect = function Util_intersect(rect1, rect2) {
  766. function compare(a, b) {
  767. return a - b;
  768. }
  769. var orderedX = [
  770. rect1[0],
  771. rect1[2],
  772. rect2[0],
  773. rect2[2]
  774. ].sort(compare), orderedY = [
  775. rect1[1],
  776. rect1[3],
  777. rect2[1],
  778. rect2[3]
  779. ].sort(compare), result = [];
  780. rect1 = Util.normalizeRect(rect1);
  781. rect2 = Util.normalizeRect(rect2);
  782. if (orderedX[0] === rect1[0] && orderedX[1] === rect2[0] || orderedX[0] === rect2[0] && orderedX[1] === rect1[0]) {
  783. result[0] = orderedX[1];
  784. result[2] = orderedX[2];
  785. } else {
  786. return false;
  787. }
  788. if (orderedY[0] === rect1[1] && orderedY[1] === rect2[1] || orderedY[0] === rect2[1] && orderedY[1] === rect1[1]) {
  789. result[1] = orderedY[1];
  790. result[3] = orderedY[2];
  791. } else {
  792. return false;
  793. }
  794. return result;
  795. };
  796. Util.sign = function Util_sign(num) {
  797. return num < 0 ? -1 : 1;
  798. };
  799. var ROMAN_NUMBER_MAP = [
  800. '',
  801. 'C',
  802. 'CC',
  803. 'CCC',
  804. 'CD',
  805. 'D',
  806. 'DC',
  807. 'DCC',
  808. 'DCCC',
  809. 'CM',
  810. '',
  811. 'X',
  812. 'XX',
  813. 'XXX',
  814. 'XL',
  815. 'L',
  816. 'LX',
  817. 'LXX',
  818. 'LXXX',
  819. 'XC',
  820. '',
  821. 'I',
  822. 'II',
  823. 'III',
  824. 'IV',
  825. 'V',
  826. 'VI',
  827. 'VII',
  828. 'VIII',
  829. 'IX'
  830. ];
  831. Util.toRoman = function Util_toRoman(number, lowerCase) {
  832. assert(isInt(number) && number > 0, 'The number should be a positive integer.');
  833. var pos, romanBuf = [];
  834. while (number >= 1000) {
  835. number -= 1000;
  836. romanBuf.push('M');
  837. }
  838. pos = number / 100 | 0;
  839. number %= 100;
  840. romanBuf.push(ROMAN_NUMBER_MAP[pos]);
  841. pos = number / 10 | 0;
  842. number %= 10;
  843. romanBuf.push(ROMAN_NUMBER_MAP[10 + pos]);
  844. romanBuf.push(ROMAN_NUMBER_MAP[20 + number]);
  845. var romanStr = romanBuf.join('');
  846. return lowerCase ? romanStr.toLowerCase() : romanStr;
  847. };
  848. Util.appendToArray = function Util_appendToArray(arr1, arr2) {
  849. Array.prototype.push.apply(arr1, arr2);
  850. };
  851. Util.prependToArray = function Util_prependToArray(arr1, arr2) {
  852. Array.prototype.unshift.apply(arr1, arr2);
  853. };
  854. Util.extendObj = function extendObj(obj1, obj2) {
  855. for (var key in obj2) {
  856. obj1[key] = obj2[key];
  857. }
  858. };
  859. Util.getInheritableProperty = function Util_getInheritableProperty(dict, name, getArray) {
  860. while (dict && !dict.has(name)) {
  861. dict = dict.get('Parent');
  862. }
  863. if (!dict) {
  864. return null;
  865. }
  866. return getArray ? dict.getArray(name) : dict.get(name);
  867. };
  868. Util.inherit = function Util_inherit(sub, base, prototype) {
  869. sub.prototype = Object.create(base.prototype);
  870. sub.prototype.constructor = sub;
  871. for (var prop in prototype) {
  872. sub.prototype[prop] = prototype[prop];
  873. }
  874. };
  875. Util.loadScript = function Util_loadScript(src, callback) {
  876. var script = document.createElement('script');
  877. var loaded = false;
  878. script.setAttribute('src', src);
  879. if (callback) {
  880. script.onload = function () {
  881. if (!loaded) {
  882. callback();
  883. }
  884. loaded = true;
  885. };
  886. }
  887. document.getElementsByTagName('head')[0].appendChild(script);
  888. };
  889. return Util;
  890. }();
  891. var PageViewport = function PageViewportClosure() {
  892. function PageViewport(viewBox, scale, rotation, offsetX, offsetY, dontFlip) {
  893. this.viewBox = viewBox;
  894. this.scale = scale;
  895. this.rotation = rotation;
  896. this.offsetX = offsetX;
  897. this.offsetY = offsetY;
  898. var centerX = (viewBox[2] + viewBox[0]) / 2;
  899. var centerY = (viewBox[3] + viewBox[1]) / 2;
  900. var rotateA, rotateB, rotateC, rotateD;
  901. rotation = rotation % 360;
  902. rotation = rotation < 0 ? rotation + 360 : rotation;
  903. switch (rotation) {
  904. case 180:
  905. rotateA = -1;
  906. rotateB = 0;
  907. rotateC = 0;
  908. rotateD = 1;
  909. break;
  910. case 90:
  911. rotateA = 0;
  912. rotateB = 1;
  913. rotateC = 1;
  914. rotateD = 0;
  915. break;
  916. case 270:
  917. rotateA = 0;
  918. rotateB = -1;
  919. rotateC = -1;
  920. rotateD = 0;
  921. break;
  922. default:
  923. rotateA = 1;
  924. rotateB = 0;
  925. rotateC = 0;
  926. rotateD = -1;
  927. break;
  928. }
  929. if (dontFlip) {
  930. rotateC = -rotateC;
  931. rotateD = -rotateD;
  932. }
  933. var offsetCanvasX, offsetCanvasY;
  934. var width, height;
  935. if (rotateA === 0) {
  936. offsetCanvasX = Math.abs(centerY - viewBox[1]) * scale + offsetX;
  937. offsetCanvasY = Math.abs(centerX - viewBox[0]) * scale + offsetY;
  938. width = Math.abs(viewBox[3] - viewBox[1]) * scale;
  939. height = Math.abs(viewBox[2] - viewBox[0]) * scale;
  940. } else {
  941. offsetCanvasX = Math.abs(centerX - viewBox[0]) * scale + offsetX;
  942. offsetCanvasY = Math.abs(centerY - viewBox[1]) * scale + offsetY;
  943. width = Math.abs(viewBox[2] - viewBox[0]) * scale;
  944. height = Math.abs(viewBox[3] - viewBox[1]) * scale;
  945. }
  946. this.transform = [
  947. rotateA * scale,
  948. rotateB * scale,
  949. rotateC * scale,
  950. rotateD * scale,
  951. offsetCanvasX - rotateA * scale * centerX - rotateC * scale * centerY,
  952. offsetCanvasY - rotateB * scale * centerX - rotateD * scale * centerY
  953. ];
  954. this.width = width;
  955. this.height = height;
  956. this.fontScale = scale;
  957. }
  958. PageViewport.prototype = {
  959. clone: function PageViewPort_clone(args) {
  960. args = args || {};
  961. var scale = 'scale' in args ? args.scale : this.scale;
  962. var rotation = 'rotation' in args ? args.rotation : this.rotation;
  963. return new PageViewport(this.viewBox.slice(), scale, rotation, this.offsetX, this.offsetY, args.dontFlip);
  964. },
  965. convertToViewportPoint: function PageViewport_convertToViewportPoint(x, y) {
  966. return Util.applyTransform([
  967. x,
  968. y
  969. ], this.transform);
  970. },
  971. convertToViewportRectangle: function PageViewport_convertToViewportRectangle(rect) {
  972. var tl = Util.applyTransform([
  973. rect[0],
  974. rect[1]
  975. ], this.transform);
  976. var br = Util.applyTransform([
  977. rect[2],
  978. rect[3]
  979. ], this.transform);
  980. return [
  981. tl[0],
  982. tl[1],
  983. br[0],
  984. br[1]
  985. ];
  986. },
  987. convertToPdfPoint: function PageViewport_convertToPdfPoint(x, y) {
  988. return Util.applyInverseTransform([
  989. x,
  990. y
  991. ], this.transform);
  992. }
  993. };
  994. return PageViewport;
  995. }();
  996. var PDFStringTranslateTable = [
  997. 0,
  998. 0,
  999. 0,
  1000. 0,
  1001. 0,
  1002. 0,
  1003. 0,
  1004. 0,
  1005. 0,
  1006. 0,
  1007. 0,
  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. 0x2D8,
  1022. 0x2C7,
  1023. 0x2C6,
  1024. 0x2D9,
  1025. 0x2DD,
  1026. 0x2DB,
  1027. 0x2DA,
  1028. 0x2DC,
  1029. 0,
  1030. 0,
  1031. 0,
  1032. 0,
  1033. 0,
  1034. 0,
  1035. 0,
  1036. 0,
  1037. 0,
  1038. 0,
  1039. 0,
  1040. 0,
  1041. 0,
  1042. 0,
  1043. 0,
  1044. 0,
  1045. 0,
  1046. 0,
  1047. 0,
  1048. 0,
  1049. 0,
  1050. 0,
  1051. 0,
  1052. 0,
  1053. 0,
  1054. 0,
  1055. 0,
  1056. 0,
  1057. 0,
  1058. 0,
  1059. 0,
  1060. 0,
  1061. 0,
  1062. 0,
  1063. 0,
  1064. 0,
  1065. 0,
  1066. 0,
  1067. 0,
  1068. 0,
  1069. 0,
  1070. 0,
  1071. 0,
  1072. 0,
  1073. 0,
  1074. 0,
  1075. 0,
  1076. 0,
  1077. 0,
  1078. 0,
  1079. 0,
  1080. 0,
  1081. 0,
  1082. 0,
  1083. 0,
  1084. 0,
  1085. 0,
  1086. 0,
  1087. 0,
  1088. 0,
  1089. 0,
  1090. 0,
  1091. 0,
  1092. 0,
  1093. 0,
  1094. 0,
  1095. 0,
  1096. 0,
  1097. 0,
  1098. 0,
  1099. 0,
  1100. 0,
  1101. 0,
  1102. 0,
  1103. 0,
  1104. 0,
  1105. 0,
  1106. 0,
  1107. 0,
  1108. 0,
  1109. 0,
  1110. 0,
  1111. 0,
  1112. 0,
  1113. 0,
  1114. 0,
  1115. 0,
  1116. 0,
  1117. 0,
  1118. 0,
  1119. 0,
  1120. 0,
  1121. 0,
  1122. 0,
  1123. 0,
  1124. 0,
  1125. 0x2022,
  1126. 0x2020,
  1127. 0x2021,
  1128. 0x2026,
  1129. 0x2014,
  1130. 0x2013,
  1131. 0x192,
  1132. 0x2044,
  1133. 0x2039,
  1134. 0x203A,
  1135. 0x2212,
  1136. 0x2030,
  1137. 0x201E,
  1138. 0x201C,
  1139. 0x201D,
  1140. 0x2018,
  1141. 0x2019,
  1142. 0x201A,
  1143. 0x2122,
  1144. 0xFB01,
  1145. 0xFB02,
  1146. 0x141,
  1147. 0x152,
  1148. 0x160,
  1149. 0x178,
  1150. 0x17D,
  1151. 0x131,
  1152. 0x142,
  1153. 0x153,
  1154. 0x161,
  1155. 0x17E,
  1156. 0,
  1157. 0x20AC
  1158. ];
  1159. function stringToPDFString(str) {
  1160. var i, n = str.length, strBuf = [];
  1161. if (str[0] === '\xFE' && str[1] === '\xFF') {
  1162. for (i = 2; i < n; i += 2) {
  1163. strBuf.push(String.fromCharCode(str.charCodeAt(i) << 8 | str.charCodeAt(i + 1)));
  1164. }
  1165. } else {
  1166. for (i = 0; i < n; ++i) {
  1167. var code = PDFStringTranslateTable[str.charCodeAt(i)];
  1168. strBuf.push(code ? String.fromCharCode(code) : str.charAt(i));
  1169. }
  1170. }
  1171. return strBuf.join('');
  1172. }
  1173. function stringToUTF8String(str) {
  1174. return decodeURIComponent(escape(str));
  1175. }
  1176. function utf8StringToString(str) {
  1177. return unescape(encodeURIComponent(str));
  1178. }
  1179. function isEmptyObj(obj) {
  1180. for (var key in obj) {
  1181. return false;
  1182. }
  1183. return true;
  1184. }
  1185. function isBool(v) {
  1186. return typeof v === 'boolean';
  1187. }
  1188. function isInt(v) {
  1189. return typeof v === 'number' && (v | 0) === v;
  1190. }
  1191. function isNum(v) {
  1192. return typeof v === 'number';
  1193. }
  1194. function isString(v) {
  1195. return typeof v === 'string';
  1196. }
  1197. function isArray(v) {
  1198. return v instanceof Array;
  1199. }
  1200. function isArrayBuffer(v) {
  1201. return typeof v === 'object' && v !== null && v.byteLength !== undefined;
  1202. }
  1203. function isSpace(ch) {
  1204. return ch === 0x20 || ch === 0x09 || ch === 0x0D || ch === 0x0A;
  1205. }
  1206. function isNodeJS() {
  1207. if (typeof __pdfjsdev_webpack__ === 'undefined') {
  1208. return typeof process === 'object' && process + '' === '[object process]';
  1209. }
  1210. return false;
  1211. }
  1212. function createPromiseCapability() {
  1213. var capability = {};
  1214. capability.promise = new Promise(function (resolve, reject) {
  1215. capability.resolve = resolve;
  1216. capability.reject = reject;
  1217. });
  1218. return capability;
  1219. }
  1220. var StatTimer = function StatTimerClosure() {
  1221. function rpad(str, pad, length) {
  1222. while (str.length < length) {
  1223. str += pad;
  1224. }
  1225. return str;
  1226. }
  1227. function StatTimer() {
  1228. this.started = Object.create(null);
  1229. this.times = [];
  1230. this.enabled = true;
  1231. }
  1232. StatTimer.prototype = {
  1233. time: function StatTimer_time(name) {
  1234. if (!this.enabled) {
  1235. return;
  1236. }
  1237. if (name in this.started) {
  1238. warn('Timer is already running for ' + name);
  1239. }
  1240. this.started[name] = Date.now();
  1241. },
  1242. timeEnd: function StatTimer_timeEnd(name) {
  1243. if (!this.enabled) {
  1244. return;
  1245. }
  1246. if (!(name in this.started)) {
  1247. warn('Timer has not been started for ' + name);
  1248. }
  1249. this.times.push({
  1250. 'name': name,
  1251. 'start': this.started[name],
  1252. 'end': Date.now()
  1253. });
  1254. delete this.started[name];
  1255. },
  1256. toString: function StatTimer_toString() {
  1257. var i, ii;
  1258. var times = this.times;
  1259. var out = '';
  1260. var longest = 0;
  1261. for (i = 0, ii = times.length; i < ii; ++i) {
  1262. var name = times[i]['name'];
  1263. if (name.length > longest) {
  1264. longest = name.length;
  1265. }
  1266. }
  1267. for (i = 0, ii = times.length; i < ii; ++i) {
  1268. var span = times[i];
  1269. var duration = span.end - span.start;
  1270. out += rpad(span['name'], ' ', longest) + ' ' + duration + 'ms\n';
  1271. }
  1272. return out;
  1273. }
  1274. };
  1275. return StatTimer;
  1276. }();
  1277. var createBlob = function createBlob(data, contentType) {
  1278. if (typeof Blob !== 'undefined') {
  1279. return new Blob([data], { type: contentType });
  1280. }
  1281. warn('The "Blob" constructor is not supported.');
  1282. };
  1283. var createObjectURL = function createObjectURLClosure() {
  1284. var digits = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=';
  1285. return function createObjectURL(data, contentType, forceDataSchema) {
  1286. if (!forceDataSchema && typeof URL !== 'undefined' && URL.createObjectURL) {
  1287. var blob = createBlob(data, contentType);
  1288. return URL.createObjectURL(blob);
  1289. }
  1290. var buffer = 'data:' + contentType + ';base64,';
  1291. for (var i = 0, ii = data.length; i < ii; i += 3) {
  1292. var b1 = data[i] & 0xFF;
  1293. var b2 = data[i + 1] & 0xFF;
  1294. var b3 = data[i + 2] & 0xFF;
  1295. var d1 = b1 >> 2, d2 = (b1 & 3) << 4 | b2 >> 4;
  1296. var d3 = i + 1 < ii ? (b2 & 0xF) << 2 | b3 >> 6 : 64;
  1297. var d4 = i + 2 < ii ? b3 & 0x3F : 64;
  1298. buffer += digits[d1] + digits[d2] + digits[d3] + digits[d4];
  1299. }
  1300. return buffer;
  1301. };
  1302. }();
  1303. function MessageHandler(sourceName, targetName, comObj) {
  1304. this.sourceName = sourceName;
  1305. this.targetName = targetName;
  1306. this.comObj = comObj;
  1307. this.callbackIndex = 1;
  1308. this.postMessageTransfers = true;
  1309. var callbacksCapabilities = this.callbacksCapabilities = Object.create(null);
  1310. var ah = this.actionHandler = Object.create(null);
  1311. this._onComObjOnMessage = function messageHandlerComObjOnMessage(event) {
  1312. var data = event.data;
  1313. if (data.targetName !== this.sourceName) {
  1314. return;
  1315. }
  1316. if (data.isReply) {
  1317. var callbackId = data.callbackId;
  1318. if (data.callbackId in callbacksCapabilities) {
  1319. var callback = callbacksCapabilities[callbackId];
  1320. delete callbacksCapabilities[callbackId];
  1321. if ('error' in data) {
  1322. callback.reject(data.error);
  1323. } else {
  1324. callback.resolve(data.data);
  1325. }
  1326. } else {
  1327. error('Cannot resolve callback ' + callbackId);
  1328. }
  1329. } else if (data.action in ah) {
  1330. var action = ah[data.action];
  1331. if (data.callbackId) {
  1332. var sourceName = this.sourceName;
  1333. var targetName = data.sourceName;
  1334. Promise.resolve().then(function () {
  1335. return action[0].call(action[1], data.data);
  1336. }).then(function (result) {
  1337. comObj.postMessage({
  1338. sourceName: sourceName,
  1339. targetName: targetName,
  1340. isReply: true,
  1341. callbackId: data.callbackId,
  1342. data: result
  1343. });
  1344. }, function (reason) {
  1345. if (reason instanceof Error) {
  1346. reason = reason + '';
  1347. }
  1348. comObj.postMessage({
  1349. sourceName: sourceName,
  1350. targetName: targetName,
  1351. isReply: true,
  1352. callbackId: data.callbackId,
  1353. error: reason
  1354. });
  1355. });
  1356. } else {
  1357. action[0].call(action[1], data.data);
  1358. }
  1359. } else {
  1360. error('Unknown action from worker: ' + data.action);
  1361. }
  1362. }.bind(this);
  1363. comObj.addEventListener('message', this._onComObjOnMessage);
  1364. }
  1365. MessageHandler.prototype = {
  1366. on: function messageHandlerOn(actionName, handler, scope) {
  1367. var ah = this.actionHandler;
  1368. if (ah[actionName]) {
  1369. error('There is already an actionName called "' + actionName + '"');
  1370. }
  1371. ah[actionName] = [
  1372. handler,
  1373. scope
  1374. ];
  1375. },
  1376. send: function messageHandlerSend(actionName, data, transfers) {
  1377. var message = {
  1378. sourceName: this.sourceName,
  1379. targetName: this.targetName,
  1380. action: actionName,
  1381. data: data
  1382. };
  1383. this.postMessage(message, transfers);
  1384. },
  1385. sendWithPromise: function messageHandlerSendWithPromise(actionName, data, transfers) {
  1386. var callbackId = this.callbackIndex++;
  1387. var message = {
  1388. sourceName: this.sourceName,
  1389. targetName: this.targetName,
  1390. action: actionName,
  1391. data: data,
  1392. callbackId: callbackId
  1393. };
  1394. var capability = createPromiseCapability();
  1395. this.callbacksCapabilities[callbackId] = capability;
  1396. try {
  1397. this.postMessage(message, transfers);
  1398. } catch (e) {
  1399. capability.reject(e);
  1400. }
  1401. return capability.promise;
  1402. },
  1403. postMessage: function (message, transfers) {
  1404. if (transfers && this.postMessageTransfers) {
  1405. this.comObj.postMessage(message, transfers);
  1406. } else {
  1407. this.comObj.postMessage(message);
  1408. }
  1409. },
  1410. destroy: function () {
  1411. this.comObj.removeEventListener('message', this._onComObjOnMessage);
  1412. }
  1413. };
  1414. function loadJpegStream(id, imageUrl, objs) {
  1415. var img = new Image();
  1416. img.onload = function loadJpegStream_onloadClosure() {
  1417. objs.resolve(id, img);
  1418. };
  1419. img.onerror = function loadJpegStream_onerrorClosure() {
  1420. objs.resolve(id, null);
  1421. warn('Error during JPEG image loading');
  1422. };
  1423. img.src = imageUrl;
  1424. }
  1425. exports.FONT_IDENTITY_MATRIX = FONT_IDENTITY_MATRIX;
  1426. exports.IDENTITY_MATRIX = IDENTITY_MATRIX;
  1427. exports.OPS = OPS;
  1428. exports.VERBOSITY_LEVELS = VERBOSITY_LEVELS;
  1429. exports.UNSUPPORTED_FEATURES = UNSUPPORTED_FEATURES;
  1430. exports.AnnotationBorderStyleType = AnnotationBorderStyleType;
  1431. exports.AnnotationFieldFlag = AnnotationFieldFlag;
  1432. exports.AnnotationFlag = AnnotationFlag;
  1433. exports.AnnotationType = AnnotationType;
  1434. exports.FontType = FontType;
  1435. exports.ImageKind = ImageKind;
  1436. exports.CMapCompressionType = CMapCompressionType;
  1437. exports.InvalidPDFException = InvalidPDFException;
  1438. exports.MessageHandler = MessageHandler;
  1439. exports.MissingDataException = MissingDataException;
  1440. exports.MissingPDFException = MissingPDFException;
  1441. exports.NotImplementedException = NotImplementedException;
  1442. exports.PageViewport = PageViewport;
  1443. exports.PasswordException = PasswordException;
  1444. exports.PasswordResponses = PasswordResponses;
  1445. exports.StatTimer = StatTimer;
  1446. exports.StreamType = StreamType;
  1447. exports.TextRenderingMode = TextRenderingMode;
  1448. exports.UnexpectedResponseException = UnexpectedResponseException;
  1449. exports.UnknownErrorException = UnknownErrorException;
  1450. exports.Util = Util;
  1451. exports.XRefParseException = XRefParseException;
  1452. exports.arrayByteLength = arrayByteLength;
  1453. exports.arraysToBytes = arraysToBytes;
  1454. exports.assert = assert;
  1455. exports.bytesToString = bytesToString;
  1456. exports.createBlob = createBlob;
  1457. exports.createPromiseCapability = createPromiseCapability;
  1458. exports.createObjectURL = createObjectURL;
  1459. exports.deprecated = deprecated;
  1460. exports.error = error;
  1461. exports.getLookupTableFactory = getLookupTableFactory;
  1462. exports.getVerbosityLevel = getVerbosityLevel;
  1463. exports.globalScope = globalScope;
  1464. exports.info = info;
  1465. exports.isArray = isArray;
  1466. exports.isArrayBuffer = isArrayBuffer;
  1467. exports.isBool = isBool;
  1468. exports.isEmptyObj = isEmptyObj;
  1469. exports.isInt = isInt;
  1470. exports.isNum = isNum;
  1471. exports.isString = isString;
  1472. exports.isSpace = isSpace;
  1473. exports.isNodeJS = isNodeJS;
  1474. exports.isSameOrigin = isSameOrigin;
  1475. exports.createValidAbsoluteUrl = createValidAbsoluteUrl;
  1476. exports.isLittleEndian = isLittleEndian;
  1477. exports.isEvalSupported = isEvalSupported;
  1478. exports.loadJpegStream = loadJpegStream;
  1479. exports.log2 = log2;
  1480. exports.readInt8 = readInt8;
  1481. exports.readUint16 = readUint16;
  1482. exports.readUint32 = readUint32;
  1483. exports.removeNullCharacters = removeNullCharacters;
  1484. exports.setVerbosityLevel = setVerbosityLevel;
  1485. exports.shadow = shadow;
  1486. exports.string32 = string32;
  1487. exports.stringToBytes = stringToBytes;
  1488. exports.stringToPDFString = stringToPDFString;
  1489. exports.stringToUTF8String = stringToUTF8String;
  1490. exports.utf8StringToString = utf8StringToString;
  1491. exports.warn = warn;
  1492. /* WEBPACK VAR INJECTION */}.call(exports, __w_pdfjs_require__(13)))
  1493. /***/ }),
  1494. /* 1 */
  1495. /***/ (function(module, exports, __w_pdfjs_require__) {
  1496. "use strict";
  1497. var sharedUtil = __w_pdfjs_require__(0);
  1498. var isArray = sharedUtil.isArray;
  1499. var EOF = {};
  1500. var Name = function NameClosure() {
  1501. function Name(name) {
  1502. this.name = name;
  1503. }
  1504. Name.prototype = {};
  1505. var nameCache = Object.create(null);
  1506. Name.get = function Name_get(name) {
  1507. var nameValue = nameCache[name];
  1508. return nameValue ? nameValue : nameCache[name] = new Name(name);
  1509. };
  1510. return Name;
  1511. }();
  1512. var Cmd = function CmdClosure() {
  1513. function Cmd(cmd) {
  1514. this.cmd = cmd;
  1515. }
  1516. Cmd.prototype = {};
  1517. var cmdCache = Object.create(null);
  1518. Cmd.get = function Cmd_get(cmd) {
  1519. var cmdValue = cmdCache[cmd];
  1520. return cmdValue ? cmdValue : cmdCache[cmd] = new Cmd(cmd);
  1521. };
  1522. return Cmd;
  1523. }();
  1524. var Dict = function DictClosure() {
  1525. var nonSerializable = function nonSerializableClosure() {
  1526. return nonSerializable;
  1527. };
  1528. function Dict(xref) {
  1529. this.map = Object.create(null);
  1530. this.xref = xref;
  1531. this.objId = null;
  1532. this.suppressEncryption = false;
  1533. this.__nonSerializable__ = nonSerializable;
  1534. }
  1535. Dict.prototype = {
  1536. assignXref: function Dict_assignXref(newXref) {
  1537. this.xref = newXref;
  1538. },
  1539. get: function Dict_get(key1, key2, key3) {
  1540. var value;
  1541. var xref = this.xref, suppressEncryption = this.suppressEncryption;
  1542. if (typeof (value = this.map[key1]) !== 'undefined' || key1 in this.map || typeof key2 === 'undefined') {
  1543. return xref ? xref.fetchIfRef(value, suppressEncryption) : value;
  1544. }
  1545. if (typeof (value = this.map[key2]) !== 'undefined' || key2 in this.map || typeof key3 === 'undefined') {
  1546. return xref ? xref.fetchIfRef(value, suppressEncryption) : value;
  1547. }
  1548. value = this.map[key3] || null;
  1549. return xref ? xref.fetchIfRef(value, suppressEncryption) : value;
  1550. },
  1551. getAsync: function Dict_getAsync(key1, key2, key3) {
  1552. var value;
  1553. var xref = this.xref, suppressEncryption = this.suppressEncryption;
  1554. if (typeof (value = this.map[key1]) !== 'undefined' || key1 in this.map || typeof key2 === 'undefined') {
  1555. if (xref) {
  1556. return xref.fetchIfRefAsync(value, suppressEncryption);
  1557. }
  1558. return Promise.resolve(value);
  1559. }
  1560. if (typeof (value = this.map[key2]) !== 'undefined' || key2 in this.map || typeof key3 === 'undefined') {
  1561. if (xref) {
  1562. return xref.fetchIfRefAsync(value, suppressEncryption);
  1563. }
  1564. return Promise.resolve(value);
  1565. }
  1566. value = this.map[key3] || null;
  1567. if (xref) {
  1568. return xref.fetchIfRefAsync(value, suppressEncryption);
  1569. }
  1570. return Promise.resolve(value);
  1571. },
  1572. getArray: function Dict_getArray(key1, key2, key3) {
  1573. var value = this.get(key1, key2, key3);
  1574. var xref = this.xref, suppressEncryption = this.suppressEncryption;
  1575. if (!isArray(value) || !xref) {
  1576. return value;
  1577. }
  1578. value = value.slice();
  1579. for (var i = 0, ii = value.length; i < ii; i++) {
  1580. if (!isRef(value[i])) {
  1581. continue;
  1582. }
  1583. value[i] = xref.fetch(value[i], suppressEncryption);
  1584. }
  1585. return value;
  1586. },
  1587. getRaw: function Dict_getRaw(key) {
  1588. return this.map[key];
  1589. },
  1590. getKeys: function Dict_getKeys() {
  1591. return Object.keys(this.map);
  1592. },
  1593. set: function Dict_set(key, value) {
  1594. this.map[key] = value;
  1595. },
  1596. has: function Dict_has(key) {
  1597. return key in this.map;
  1598. },
  1599. forEach: function Dict_forEach(callback) {
  1600. for (var key in this.map) {
  1601. callback(key, this.get(key));
  1602. }
  1603. }
  1604. };
  1605. Dict.empty = new Dict(null);
  1606. Dict.merge = function Dict_merge(xref, dictArray) {
  1607. var mergedDict = new Dict(xref);
  1608. for (var i = 0, ii = dictArray.length; i < ii; i++) {
  1609. var dict = dictArray[i];
  1610. if (!isDict(dict)) {
  1611. continue;
  1612. }
  1613. for (var keyName in dict.map) {
  1614. if (mergedDict.map[keyName]) {
  1615. continue;
  1616. }
  1617. mergedDict.map[keyName] = dict.map[keyName];
  1618. }
  1619. }
  1620. return mergedDict;
  1621. };
  1622. return Dict;
  1623. }();
  1624. var Ref = function RefClosure() {
  1625. function Ref(num, gen) {
  1626. this.num = num;
  1627. this.gen = gen;
  1628. }
  1629. Ref.prototype = {
  1630. toString: function Ref_toString() {
  1631. var str = this.num + 'R';
  1632. if (this.gen !== 0) {
  1633. str += this.gen;
  1634. }
  1635. return str;
  1636. }
  1637. };
  1638. return Ref;
  1639. }();
  1640. var RefSet = function RefSetClosure() {
  1641. function RefSet() {
  1642. this.dict = Object.create(null);
  1643. }
  1644. RefSet.prototype = {
  1645. has: function RefSet_has(ref) {
  1646. return ref.toString() in this.dict;
  1647. },
  1648. put: function RefSet_put(ref) {
  1649. this.dict[ref.toString()] = true;
  1650. },
  1651. remove: function RefSet_remove(ref) {
  1652. delete this.dict[ref.toString()];
  1653. }
  1654. };
  1655. return RefSet;
  1656. }();
  1657. var RefSetCache = function RefSetCacheClosure() {
  1658. function RefSetCache() {
  1659. this.dict = Object.create(null);
  1660. }
  1661. RefSetCache.prototype = {
  1662. get: function RefSetCache_get(ref) {
  1663. return this.dict[ref.toString()];
  1664. },
  1665. has: function RefSetCache_has(ref) {
  1666. return ref.toString() in this.dict;
  1667. },
  1668. put: function RefSetCache_put(ref, obj) {
  1669. this.dict[ref.toString()] = obj;
  1670. },
  1671. putAlias: function RefSetCache_putAlias(ref, aliasRef) {
  1672. this.dict[ref.toString()] = this.get(aliasRef);
  1673. },
  1674. forEach: function RefSetCache_forEach(fn, thisArg) {
  1675. for (var i in this.dict) {
  1676. fn.call(thisArg, this.dict[i]);
  1677. }
  1678. },
  1679. clear: function RefSetCache_clear() {
  1680. this.dict = Object.create(null);
  1681. }
  1682. };
  1683. return RefSetCache;
  1684. }();
  1685. function isEOF(v) {
  1686. return v === EOF;
  1687. }
  1688. function isName(v, name) {
  1689. return v instanceof Name && (name === undefined || v.name === name);
  1690. }
  1691. function isCmd(v, cmd) {
  1692. return v instanceof Cmd && (cmd === undefined || v.cmd === cmd);
  1693. }
  1694. function isDict(v, type) {
  1695. return v instanceof Dict && (type === undefined || isName(v.get('Type'), type));
  1696. }
  1697. function isRef(v) {
  1698. return v instanceof Ref;
  1699. }
  1700. function isRefsEqual(v1, v2) {
  1701. return v1.num === v2.num && v1.gen === v2.gen;
  1702. }
  1703. function isStream(v) {
  1704. return typeof v === 'object' && v !== null && v.getBytes !== undefined;
  1705. }
  1706. exports.EOF = EOF;
  1707. exports.Cmd = Cmd;
  1708. exports.Dict = Dict;
  1709. exports.Name = Name;
  1710. exports.Ref = Ref;
  1711. exports.RefSet = RefSet;
  1712. exports.RefSetCache = RefSetCache;
  1713. exports.isEOF = isEOF;
  1714. exports.isCmd = isCmd;
  1715. exports.isDict = isDict;
  1716. exports.isName = isName;
  1717. exports.isRef = isRef;
  1718. exports.isRefsEqual = isRefsEqual;
  1719. exports.isStream = isStream;
  1720. /***/ }),
  1721. /* 2 */
  1722. /***/ (function(module, exports, __w_pdfjs_require__) {
  1723. "use strict";
  1724. var sharedUtil = __w_pdfjs_require__(0);
  1725. var corePrimitives = __w_pdfjs_require__(1);
  1726. var coreJbig2 = __w_pdfjs_require__(35);
  1727. var coreJpg = __w_pdfjs_require__(36);
  1728. var coreJpx = __w_pdfjs_require__(19);
  1729. var Util = sharedUtil.Util;
  1730. var error = sharedUtil.error;
  1731. var info = sharedUtil.info;
  1732. var isInt = sharedUtil.isInt;
  1733. var isArray = sharedUtil.isArray;
  1734. var createObjectURL = sharedUtil.createObjectURL;
  1735. var shadow = sharedUtil.shadow;
  1736. var isSpace = sharedUtil.isSpace;
  1737. var Dict = corePrimitives.Dict;
  1738. var isDict = corePrimitives.isDict;
  1739. var isStream = corePrimitives.isStream;
  1740. var Jbig2Image = coreJbig2.Jbig2Image;
  1741. var JpegImage = coreJpg.JpegImage;
  1742. var JpxImage = coreJpx.JpxImage;
  1743. var Stream = function StreamClosure() {
  1744. function Stream(arrayBuffer, start, length, dict) {
  1745. this.bytes = arrayBuffer instanceof Uint8Array ? arrayBuffer : new Uint8Array(arrayBuffer);
  1746. this.start = start || 0;
  1747. this.pos = this.start;
  1748. this.end = start + length || this.bytes.length;
  1749. this.dict = dict;
  1750. }
  1751. Stream.prototype = {
  1752. get length() {
  1753. return this.end - this.start;
  1754. },
  1755. get isEmpty() {
  1756. return this.length === 0;
  1757. },
  1758. getByte: function Stream_getByte() {
  1759. if (this.pos >= this.end) {
  1760. return -1;
  1761. }
  1762. return this.bytes[this.pos++];
  1763. },
  1764. getUint16: function Stream_getUint16() {
  1765. var b0 = this.getByte();
  1766. var b1 = this.getByte();
  1767. if (b0 === -1 || b1 === -1) {
  1768. return -1;
  1769. }
  1770. return (b0 << 8) + b1;
  1771. },
  1772. getInt32: function Stream_getInt32() {
  1773. var b0 = this.getByte();
  1774. var b1 = this.getByte();
  1775. var b2 = this.getByte();
  1776. var b3 = this.getByte();
  1777. return (b0 << 24) + (b1 << 16) + (b2 << 8) + b3;
  1778. },
  1779. getBytes: function Stream_getBytes(length) {
  1780. var bytes = this.bytes;
  1781. var pos = this.pos;
  1782. var strEnd = this.end;
  1783. if (!length) {
  1784. return bytes.subarray(pos, strEnd);
  1785. }
  1786. var end = pos + length;
  1787. if (end > strEnd) {
  1788. end = strEnd;
  1789. }
  1790. this.pos = end;
  1791. return bytes.subarray(pos, end);
  1792. },
  1793. peekByte: function Stream_peekByte() {
  1794. var peekedByte = this.getByte();
  1795. this.pos--;
  1796. return peekedByte;
  1797. },
  1798. peekBytes: function Stream_peekBytes(length) {
  1799. var bytes = this.getBytes(length);
  1800. this.pos -= bytes.length;
  1801. return bytes;
  1802. },
  1803. skip: function Stream_skip(n) {
  1804. if (!n) {
  1805. n = 1;
  1806. }
  1807. this.pos += n;
  1808. },
  1809. reset: function Stream_reset() {
  1810. this.pos = this.start;
  1811. },
  1812. moveStart: function Stream_moveStart() {
  1813. this.start = this.pos;
  1814. },
  1815. makeSubStream: function Stream_makeSubStream(start, length, dict) {
  1816. return new Stream(this.bytes.buffer, start, length, dict);
  1817. }
  1818. };
  1819. return Stream;
  1820. }();
  1821. var StringStream = function StringStreamClosure() {
  1822. function StringStream(str) {
  1823. var length = str.length;
  1824. var bytes = new Uint8Array(length);
  1825. for (var n = 0; n < length; ++n) {
  1826. bytes[n] = str.charCodeAt(n);
  1827. }
  1828. Stream.call(this, bytes);
  1829. }
  1830. StringStream.prototype = Stream.prototype;
  1831. return StringStream;
  1832. }();
  1833. var DecodeStream = function DecodeStreamClosure() {
  1834. var emptyBuffer = new Uint8Array(0);
  1835. function DecodeStream(maybeMinBufferLength) {
  1836. this.pos = 0;
  1837. this.bufferLength = 0;
  1838. this.eof = false;
  1839. this.buffer = emptyBuffer;
  1840. this.minBufferLength = 512;
  1841. if (maybeMinBufferLength) {
  1842. while (this.minBufferLength < maybeMinBufferLength) {
  1843. this.minBufferLength *= 2;
  1844. }
  1845. }
  1846. }
  1847. DecodeStream.prototype = {
  1848. get isEmpty() {
  1849. while (!this.eof && this.bufferLength === 0) {
  1850. this.readBlock();
  1851. }
  1852. return this.bufferLength === 0;
  1853. },
  1854. ensureBuffer: function DecodeStream_ensureBuffer(requested) {
  1855. var buffer = this.buffer;
  1856. if (requested <= buffer.byteLength) {
  1857. return buffer;
  1858. }
  1859. var size = this.minBufferLength;
  1860. while (size < requested) {
  1861. size *= 2;
  1862. }
  1863. var buffer2 = new Uint8Array(size);
  1864. buffer2.set(buffer);
  1865. return this.buffer = buffer2;
  1866. },
  1867. getByte: function DecodeStream_getByte() {
  1868. var pos = this.pos;
  1869. while (this.bufferLength <= pos) {
  1870. if (this.eof) {
  1871. return -1;
  1872. }
  1873. this.readBlock();
  1874. }
  1875. return this.buffer[this.pos++];
  1876. },
  1877. getUint16: function DecodeStream_getUint16() {
  1878. var b0 = this.getByte();
  1879. var b1 = this.getByte();
  1880. if (b0 === -1 || b1 === -1) {
  1881. return -1;
  1882. }
  1883. return (b0 << 8) + b1;
  1884. },
  1885. getInt32: function DecodeStream_getInt32() {
  1886. var b0 = this.getByte();
  1887. var b1 = this.getByte();
  1888. var b2 = this.getByte();
  1889. var b3 = this.getByte();
  1890. return (b0 << 24) + (b1 << 16) + (b2 << 8) + b3;
  1891. },
  1892. getBytes: function DecodeStream_getBytes(length) {
  1893. var end, pos = this.pos;
  1894. if (length) {
  1895. this.ensureBuffer(pos + length);
  1896. end = pos + length;
  1897. while (!this.eof && this.bufferLength < end) {
  1898. this.readBlock();
  1899. }
  1900. var bufEnd = this.bufferLength;
  1901. if (end > bufEnd) {
  1902. end = bufEnd;
  1903. }
  1904. } else {
  1905. while (!this.eof) {
  1906. this.readBlock();
  1907. }
  1908. end = this.bufferLength;
  1909. }
  1910. this.pos = end;
  1911. return this.buffer.subarray(pos, end);
  1912. },
  1913. peekByte: function DecodeStream_peekByte() {
  1914. var peekedByte = this.getByte();
  1915. this.pos--;
  1916. return peekedByte;
  1917. },
  1918. peekBytes: function DecodeStream_peekBytes(length) {
  1919. var bytes = this.getBytes(length);
  1920. this.pos -= bytes.length;
  1921. return bytes;
  1922. },
  1923. makeSubStream: function DecodeStream_makeSubStream(start, length, dict) {
  1924. var end = start + length;
  1925. while (this.bufferLength <= end && !this.eof) {
  1926. this.readBlock();
  1927. }
  1928. return new Stream(this.buffer, start, length, dict);
  1929. },
  1930. skip: function DecodeStream_skip(n) {
  1931. if (!n) {
  1932. n = 1;
  1933. }
  1934. this.pos += n;
  1935. },
  1936. reset: function DecodeStream_reset() {
  1937. this.pos = 0;
  1938. },
  1939. getBaseStreams: function DecodeStream_getBaseStreams() {
  1940. if (this.str && this.str.getBaseStreams) {
  1941. return this.str.getBaseStreams();
  1942. }
  1943. return [];
  1944. }
  1945. };
  1946. return DecodeStream;
  1947. }();
  1948. var StreamsSequenceStream = function StreamsSequenceStreamClosure() {
  1949. function StreamsSequenceStream(streams) {
  1950. this.streams = streams;
  1951. DecodeStream.call(this, null);
  1952. }
  1953. StreamsSequenceStream.prototype = Object.create(DecodeStream.prototype);
  1954. StreamsSequenceStream.prototype.readBlock = function streamSequenceStreamReadBlock() {
  1955. var streams = this.streams;
  1956. if (streams.length === 0) {
  1957. this.eof = true;
  1958. return;
  1959. }
  1960. var stream = streams.shift();
  1961. var chunk = stream.getBytes();
  1962. var bufferLength = this.bufferLength;
  1963. var newLength = bufferLength + chunk.length;
  1964. var buffer = this.ensureBuffer(newLength);
  1965. buffer.set(chunk, bufferLength);
  1966. this.bufferLength = newLength;
  1967. };
  1968. StreamsSequenceStream.prototype.getBaseStreams = function StreamsSequenceStream_getBaseStreams() {
  1969. var baseStreams = [];
  1970. for (var i = 0, ii = this.streams.length; i < ii; i++) {
  1971. var stream = this.streams[i];
  1972. if (stream.getBaseStreams) {
  1973. Util.appendToArray(baseStreams, stream.getBaseStreams());
  1974. }
  1975. }
  1976. return baseStreams;
  1977. };
  1978. return StreamsSequenceStream;
  1979. }();
  1980. var FlateStream = function FlateStreamClosure() {
  1981. var codeLenCodeMap = new Int32Array([
  1982. 16,
  1983. 17,
  1984. 18,
  1985. 0,
  1986. 8,
  1987. 7,
  1988. 9,
  1989. 6,
  1990. 10,
  1991. 5,
  1992. 11,
  1993. 4,
  1994. 12,
  1995. 3,
  1996. 13,
  1997. 2,
  1998. 14,
  1999. 1,
  2000. 15
  2001. ]);
  2002. var lengthDecode = new Int32Array([
  2003. 0x00003,
  2004. 0x00004,
  2005. 0x00005,
  2006. 0x00006,
  2007. 0x00007,
  2008. 0x00008,
  2009. 0x00009,
  2010. 0x0000a,
  2011. 0x1000b,
  2012. 0x1000d,
  2013. 0x1000f,
  2014. 0x10011,
  2015. 0x20013,
  2016. 0x20017,
  2017. 0x2001b,
  2018. 0x2001f,
  2019. 0x30023,
  2020. 0x3002b,
  2021. 0x30033,
  2022. 0x3003b,
  2023. 0x40043,
  2024. 0x40053,
  2025. 0x40063,
  2026. 0x40073,
  2027. 0x50083,
  2028. 0x500a3,
  2029. 0x500c3,
  2030. 0x500e3,
  2031. 0x00102,
  2032. 0x00102,
  2033. 0x00102
  2034. ]);
  2035. var distDecode = new Int32Array([
  2036. 0x00001,
  2037. 0x00002,
  2038. 0x00003,
  2039. 0x00004,
  2040. 0x10005,
  2041. 0x10007,
  2042. 0x20009,
  2043. 0x2000d,
  2044. 0x30011,
  2045. 0x30019,
  2046. 0x40021,
  2047. 0x40031,
  2048. 0x50041,
  2049. 0x50061,
  2050. 0x60081,
  2051. 0x600c1,
  2052. 0x70101,
  2053. 0x70181,
  2054. 0x80201,
  2055. 0x80301,
  2056. 0x90401,
  2057. 0x90601,
  2058. 0xa0801,
  2059. 0xa0c01,
  2060. 0xb1001,
  2061. 0xb1801,
  2062. 0xc2001,
  2063. 0xc3001,
  2064. 0xd4001,
  2065. 0xd6001
  2066. ]);
  2067. var fixedLitCodeTab = [
  2068. new Int32Array([
  2069. 0x70100,
  2070. 0x80050,
  2071. 0x80010,
  2072. 0x80118,
  2073. 0x70110,
  2074. 0x80070,
  2075. 0x80030,
  2076. 0x900c0,
  2077. 0x70108,
  2078. 0x80060,
  2079. 0x80020,
  2080. 0x900a0,
  2081. 0x80000,
  2082. 0x80080,
  2083. 0x80040,
  2084. 0x900e0,
  2085. 0x70104,
  2086. 0x80058,
  2087. 0x80018,
  2088. 0x90090,
  2089. 0x70114,
  2090. 0x80078,
  2091. 0x80038,
  2092. 0x900d0,
  2093. 0x7010c,
  2094. 0x80068,
  2095. 0x80028,
  2096. 0x900b0,
  2097. 0x80008,
  2098. 0x80088,
  2099. 0x80048,
  2100. 0x900f0,
  2101. 0x70102,
  2102. 0x80054,
  2103. 0x80014,
  2104. 0x8011c,
  2105. 0x70112,
  2106. 0x80074,
  2107. 0x80034,
  2108. 0x900c8,
  2109. 0x7010a,
  2110. 0x80064,
  2111. 0x80024,
  2112. 0x900a8,
  2113. 0x80004,
  2114. 0x80084,
  2115. 0x80044,
  2116. 0x900e8,
  2117. 0x70106,
  2118. 0x8005c,
  2119. 0x8001c,
  2120. 0x90098,
  2121. 0x70116,
  2122. 0x8007c,
  2123. 0x8003c,
  2124. 0x900d8,
  2125. 0x7010e,
  2126. 0x8006c,
  2127. 0x8002c,
  2128. 0x900b8,
  2129. 0x8000c,
  2130. 0x8008c,
  2131. 0x8004c,
  2132. 0x900f8,
  2133. 0x70101,
  2134. 0x80052,
  2135. 0x80012,
  2136. 0x8011a,
  2137. 0x70111,
  2138. 0x80072,
  2139. 0x80032,
  2140. 0x900c4,
  2141. 0x70109,
  2142. 0x80062,
  2143. 0x80022,
  2144. 0x900a4,
  2145. 0x80002,
  2146. 0x80082,
  2147. 0x80042,
  2148. 0x900e4,
  2149. 0x70105,
  2150. 0x8005a,
  2151. 0x8001a,
  2152. 0x90094,
  2153. 0x70115,
  2154. 0x8007a,
  2155. 0x8003a,
  2156. 0x900d4,
  2157. 0x7010d,
  2158. 0x8006a,
  2159. 0x8002a,
  2160. 0x900b4,
  2161. 0x8000a,
  2162. 0x8008a,
  2163. 0x8004a,
  2164. 0x900f4,
  2165. 0x70103,
  2166. 0x80056,
  2167. 0x80016,
  2168. 0x8011e,
  2169. 0x70113,
  2170. 0x80076,
  2171. 0x80036,
  2172. 0x900cc,
  2173. 0x7010b,
  2174. 0x80066,
  2175. 0x80026,
  2176. 0x900ac,
  2177. 0x80006,
  2178. 0x80086,
  2179. 0x80046,
  2180. 0x900ec,
  2181. 0x70107,
  2182. 0x8005e,
  2183. 0x8001e,
  2184. 0x9009c,
  2185. 0x70117,
  2186. 0x8007e,
  2187. 0x8003e,
  2188. 0x900dc,
  2189. 0x7010f,
  2190. 0x8006e,
  2191. 0x8002e,
  2192. 0x900bc,
  2193. 0x8000e,
  2194. 0x8008e,
  2195. 0x8004e,
  2196. 0x900fc,
  2197. 0x70100,
  2198. 0x80051,
  2199. 0x80011,
  2200. 0x80119,
  2201. 0x70110,
  2202. 0x80071,
  2203. 0x80031,
  2204. 0x900c2,
  2205. 0x70108,
  2206. 0x80061,
  2207. 0x80021,
  2208. 0x900a2,
  2209. 0x80001,
  2210. 0x80081,
  2211. 0x80041,
  2212. 0x900e2,
  2213. 0x70104,
  2214. 0x80059,
  2215. 0x80019,
  2216. 0x90092,
  2217. 0x70114,
  2218. 0x80079,
  2219. 0x80039,
  2220. 0x900d2,
  2221. 0x7010c,
  2222. 0x80069,
  2223. 0x80029,
  2224. 0x900b2,
  2225. 0x80009,
  2226. 0x80089,
  2227. 0x80049,
  2228. 0x900f2,
  2229. 0x70102,
  2230. 0x80055,
  2231. 0x80015,
  2232. 0x8011d,
  2233. 0x70112,
  2234. 0x80075,
  2235. 0x80035,
  2236. 0x900ca,
  2237. 0x7010a,
  2238. 0x80065,
  2239. 0x80025,
  2240. 0x900aa,
  2241. 0x80005,
  2242. 0x80085,
  2243. 0x80045,
  2244. 0x900ea,
  2245. 0x70106,
  2246. 0x8005d,
  2247. 0x8001d,
  2248. 0x9009a,
  2249. 0x70116,
  2250. 0x8007d,
  2251. 0x8003d,
  2252. 0x900da,
  2253. 0x7010e,
  2254. 0x8006d,
  2255. 0x8002d,
  2256. 0x900ba,
  2257. 0x8000d,
  2258. 0x8008d,
  2259. 0x8004d,
  2260. 0x900fa,
  2261. 0x70101,
  2262. 0x80053,
  2263. 0x80013,
  2264. 0x8011b,
  2265. 0x70111,
  2266. 0x80073,
  2267. 0x80033,
  2268. 0x900c6,
  2269. 0x70109,
  2270. 0x80063,
  2271. 0x80023,
  2272. 0x900a6,
  2273. 0x80003,
  2274. 0x80083,
  2275. 0x80043,
  2276. 0x900e6,
  2277. 0x70105,
  2278. 0x8005b,
  2279. 0x8001b,
  2280. 0x90096,
  2281. 0x70115,
  2282. 0x8007b,
  2283. 0x8003b,
  2284. 0x900d6,
  2285. 0x7010d,
  2286. 0x8006b,
  2287. 0x8002b,
  2288. 0x900b6,
  2289. 0x8000b,
  2290. 0x8008b,
  2291. 0x8004b,
  2292. 0x900f6,
  2293. 0x70103,
  2294. 0x80057,
  2295. 0x80017,
  2296. 0x8011f,
  2297. 0x70113,
  2298. 0x80077,
  2299. 0x80037,
  2300. 0x900ce,
  2301. 0x7010b,
  2302. 0x80067,
  2303. 0x80027,
  2304. 0x900ae,
  2305. 0x80007,
  2306. 0x80087,
  2307. 0x80047,
  2308. 0x900ee,
  2309. 0x70107,
  2310. 0x8005f,
  2311. 0x8001f,
  2312. 0x9009e,
  2313. 0x70117,
  2314. 0x8007f,
  2315. 0x8003f,
  2316. 0x900de,
  2317. 0x7010f,
  2318. 0x8006f,
  2319. 0x8002f,
  2320. 0x900be,
  2321. 0x8000f,
  2322. 0x8008f,
  2323. 0x8004f,
  2324. 0x900fe,
  2325. 0x70100,
  2326. 0x80050,
  2327. 0x80010,
  2328. 0x80118,
  2329. 0x70110,
  2330. 0x80070,
  2331. 0x80030,
  2332. 0x900c1,
  2333. 0x70108,
  2334. 0x80060,
  2335. 0x80020,
  2336. 0x900a1,
  2337. 0x80000,
  2338. 0x80080,
  2339. 0x80040,
  2340. 0x900e1,
  2341. 0x70104,
  2342. 0x80058,
  2343. 0x80018,
  2344. 0x90091,
  2345. 0x70114,
  2346. 0x80078,
  2347. 0x80038,
  2348. 0x900d1,
  2349. 0x7010c,
  2350. 0x80068,
  2351. 0x80028,
  2352. 0x900b1,
  2353. 0x80008,
  2354. 0x80088,
  2355. 0x80048,
  2356. 0x900f1,
  2357. 0x70102,
  2358. 0x80054,
  2359. 0x80014,
  2360. 0x8011c,
  2361. 0x70112,
  2362. 0x80074,
  2363. 0x80034,
  2364. 0x900c9,
  2365. 0x7010a,
  2366. 0x80064,
  2367. 0x80024,
  2368. 0x900a9,
  2369. 0x80004,
  2370. 0x80084,
  2371. 0x80044,
  2372. 0x900e9,
  2373. 0x70106,
  2374. 0x8005c,
  2375. 0x8001c,
  2376. 0x90099,
  2377. 0x70116,
  2378. 0x8007c,
  2379. 0x8003c,
  2380. 0x900d9,
  2381. 0x7010e,
  2382. 0x8006c,
  2383. 0x8002c,
  2384. 0x900b9,
  2385. 0x8000c,
  2386. 0x8008c,
  2387. 0x8004c,
  2388. 0x900f9,
  2389. 0x70101,
  2390. 0x80052,
  2391. 0x80012,
  2392. 0x8011a,
  2393. 0x70111,
  2394. 0x80072,
  2395. 0x80032,
  2396. 0x900c5,
  2397. 0x70109,
  2398. 0x80062,
  2399. 0x80022,
  2400. 0x900a5,
  2401. 0x80002,
  2402. 0x80082,
  2403. 0x80042,
  2404. 0x900e5,
  2405. 0x70105,
  2406. 0x8005a,
  2407. 0x8001a,
  2408. 0x90095,
  2409. 0x70115,
  2410. 0x8007a,
  2411. 0x8003a,
  2412. 0x900d5,
  2413. 0x7010d,
  2414. 0x8006a,
  2415. 0x8002a,
  2416. 0x900b5,
  2417. 0x8000a,
  2418. 0x8008a,
  2419. 0x8004a,
  2420. 0x900f5,
  2421. 0x70103,
  2422. 0x80056,
  2423. 0x80016,
  2424. 0x8011e,
  2425. 0x70113,
  2426. 0x80076,
  2427. 0x80036,
  2428. 0x900cd,
  2429. 0x7010b,
  2430. 0x80066,
  2431. 0x80026,
  2432. 0x900ad,
  2433. 0x80006,
  2434. 0x80086,
  2435. 0x80046,
  2436. 0x900ed,
  2437. 0x70107,
  2438. 0x8005e,
  2439. 0x8001e,
  2440. 0x9009d,
  2441. 0x70117,
  2442. 0x8007e,
  2443. 0x8003e,
  2444. 0x900dd,
  2445. 0x7010f,
  2446. 0x8006e,
  2447. 0x8002e,
  2448. 0x900bd,
  2449. 0x8000e,
  2450. 0x8008e,
  2451. 0x8004e,
  2452. 0x900fd,
  2453. 0x70100,
  2454. 0x80051,
  2455. 0x80011,
  2456. 0x80119,
  2457. 0x70110,
  2458. 0x80071,
  2459. 0x80031,
  2460. 0x900c3,
  2461. 0x70108,
  2462. 0x80061,
  2463. 0x80021,
  2464. 0x900a3,
  2465. 0x80001,
  2466. 0x80081,
  2467. 0x80041,
  2468. 0x900e3,
  2469. 0x70104,
  2470. 0x80059,
  2471. 0x80019,
  2472. 0x90093,
  2473. 0x70114,
  2474. 0x80079,
  2475. 0x80039,
  2476. 0x900d3,
  2477. 0x7010c,
  2478. 0x80069,
  2479. 0x80029,
  2480. 0x900b3,
  2481. 0x80009,
  2482. 0x80089,
  2483. 0x80049,
  2484. 0x900f3,
  2485. 0x70102,
  2486. 0x80055,
  2487. 0x80015,
  2488. 0x8011d,
  2489. 0x70112,
  2490. 0x80075,
  2491. 0x80035,
  2492. 0x900cb,
  2493. 0x7010a,
  2494. 0x80065,
  2495. 0x80025,
  2496. 0x900ab,
  2497. 0x80005,
  2498. 0x80085,
  2499. 0x80045,
  2500. 0x900eb,
  2501. 0x70106,
  2502. 0x8005d,
  2503. 0x8001d,
  2504. 0x9009b,
  2505. 0x70116,
  2506. 0x8007d,
  2507. 0x8003d,
  2508. 0x900db,
  2509. 0x7010e,
  2510. 0x8006d,
  2511. 0x8002d,
  2512. 0x900bb,
  2513. 0x8000d,
  2514. 0x8008d,
  2515. 0x8004d,
  2516. 0x900fb,
  2517. 0x70101,
  2518. 0x80053,
  2519. 0x80013,
  2520. 0x8011b,
  2521. 0x70111,
  2522. 0x80073,
  2523. 0x80033,
  2524. 0x900c7,
  2525. 0x70109,
  2526. 0x80063,
  2527. 0x80023,
  2528. 0x900a7,
  2529. 0x80003,
  2530. 0x80083,
  2531. 0x80043,
  2532. 0x900e7,
  2533. 0x70105,
  2534. 0x8005b,
  2535. 0x8001b,
  2536. 0x90097,
  2537. 0x70115,
  2538. 0x8007b,
  2539. 0x8003b,
  2540. 0x900d7,
  2541. 0x7010d,
  2542. 0x8006b,
  2543. 0x8002b,
  2544. 0x900b7,
  2545. 0x8000b,
  2546. 0x8008b,
  2547. 0x8004b,
  2548. 0x900f7,
  2549. 0x70103,
  2550. 0x80057,
  2551. 0x80017,
  2552. 0x8011f,
  2553. 0x70113,
  2554. 0x80077,
  2555. 0x80037,
  2556. 0x900cf,
  2557. 0x7010b,
  2558. 0x80067,
  2559. 0x80027,
  2560. 0x900af,
  2561. 0x80007,
  2562. 0x80087,
  2563. 0x80047,
  2564. 0x900ef,
  2565. 0x70107,
  2566. 0x8005f,
  2567. 0x8001f,
  2568. 0x9009f,
  2569. 0x70117,
  2570. 0x8007f,
  2571. 0x8003f,
  2572. 0x900df,
  2573. 0x7010f,
  2574. 0x8006f,
  2575. 0x8002f,
  2576. 0x900bf,
  2577. 0x8000f,
  2578. 0x8008f,
  2579. 0x8004f,
  2580. 0x900ff
  2581. ]),
  2582. 9
  2583. ];
  2584. var fixedDistCodeTab = [
  2585. new Int32Array([
  2586. 0x50000,
  2587. 0x50010,
  2588. 0x50008,
  2589. 0x50018,
  2590. 0x50004,
  2591. 0x50014,
  2592. 0x5000c,
  2593. 0x5001c,
  2594. 0x50002,
  2595. 0x50012,
  2596. 0x5000a,
  2597. 0x5001a,
  2598. 0x50006,
  2599. 0x50016,
  2600. 0x5000e,
  2601. 0x00000,
  2602. 0x50001,
  2603. 0x50011,
  2604. 0x50009,
  2605. 0x50019,
  2606. 0x50005,
  2607. 0x50015,
  2608. 0x5000d,
  2609. 0x5001d,
  2610. 0x50003,
  2611. 0x50013,
  2612. 0x5000b,
  2613. 0x5001b,
  2614. 0x50007,
  2615. 0x50017,
  2616. 0x5000f,
  2617. 0x00000
  2618. ]),
  2619. 5
  2620. ];
  2621. function FlateStream(str, maybeLength) {
  2622. this.str = str;
  2623. this.dict = str.dict;
  2624. var cmf = str.getByte();
  2625. var flg = str.getByte();
  2626. if (cmf === -1 || flg === -1) {
  2627. error('Invalid header in flate stream: ' + cmf + ', ' + flg);
  2628. }
  2629. if ((cmf & 0x0f) !== 0x08) {
  2630. error('Unknown compression method in flate stream: ' + cmf + ', ' + flg);
  2631. }
  2632. if (((cmf << 8) + flg) % 31 !== 0) {
  2633. error('Bad FCHECK in flate stream: ' + cmf + ', ' + flg);
  2634. }
  2635. if (flg & 0x20) {
  2636. error('FDICT bit set in flate stream: ' + cmf + ', ' + flg);
  2637. }
  2638. this.codeSize = 0;
  2639. this.codeBuf = 0;
  2640. DecodeStream.call(this, maybeLength);
  2641. }
  2642. FlateStream.prototype = Object.create(DecodeStream.prototype);
  2643. FlateStream.prototype.getBits = function FlateStream_getBits(bits) {
  2644. var str = this.str;
  2645. var codeSize = this.codeSize;
  2646. var codeBuf = this.codeBuf;
  2647. var b;
  2648. while (codeSize < bits) {
  2649. if ((b = str.getByte()) === -1) {
  2650. error('Bad encoding in flate stream');
  2651. }
  2652. codeBuf |= b << codeSize;
  2653. codeSize += 8;
  2654. }
  2655. b = codeBuf & (1 << bits) - 1;
  2656. this.codeBuf = codeBuf >> bits;
  2657. this.codeSize = codeSize -= bits;
  2658. return b;
  2659. };
  2660. FlateStream.prototype.getCode = function FlateStream_getCode(table) {
  2661. var str = this.str;
  2662. var codes = table[0];
  2663. var maxLen = table[1];
  2664. var codeSize = this.codeSize;
  2665. var codeBuf = this.codeBuf;
  2666. var b;
  2667. while (codeSize < maxLen) {
  2668. if ((b = str.getByte()) === -1) {
  2669. break;
  2670. }
  2671. codeBuf |= b << codeSize;
  2672. codeSize += 8;
  2673. }
  2674. var code = codes[codeBuf & (1 << maxLen) - 1];
  2675. var codeLen = code >> 16;
  2676. var codeVal = code & 0xffff;
  2677. if (codeLen < 1 || codeSize < codeLen) {
  2678. error('Bad encoding in flate stream');
  2679. }
  2680. this.codeBuf = codeBuf >> codeLen;
  2681. this.codeSize = codeSize - codeLen;
  2682. return codeVal;
  2683. };
  2684. FlateStream.prototype.generateHuffmanTable = function flateStreamGenerateHuffmanTable(lengths) {
  2685. var n = lengths.length;
  2686. var maxLen = 0;
  2687. var i;
  2688. for (i = 0; i < n; ++i) {
  2689. if (lengths[i] > maxLen) {
  2690. maxLen = lengths[i];
  2691. }
  2692. }
  2693. var size = 1 << maxLen;
  2694. var codes = new Int32Array(size);
  2695. for (var len = 1, code = 0, skip = 2; len <= maxLen; ++len, code <<= 1, skip <<= 1) {
  2696. for (var val = 0; val < n; ++val) {
  2697. if (lengths[val] === len) {
  2698. var code2 = 0;
  2699. var t = code;
  2700. for (i = 0; i < len; ++i) {
  2701. code2 = code2 << 1 | t & 1;
  2702. t >>= 1;
  2703. }
  2704. for (i = code2; i < size; i += skip) {
  2705. codes[i] = len << 16 | val;
  2706. }
  2707. ++code;
  2708. }
  2709. }
  2710. }
  2711. return [
  2712. codes,
  2713. maxLen
  2714. ];
  2715. };
  2716. FlateStream.prototype.readBlock = function FlateStream_readBlock() {
  2717. var buffer, len;
  2718. var str = this.str;
  2719. var hdr = this.getBits(3);
  2720. if (hdr & 1) {
  2721. this.eof = true;
  2722. }
  2723. hdr >>= 1;
  2724. if (hdr === 0) {
  2725. var b;
  2726. if ((b = str.getByte()) === -1) {
  2727. error('Bad block header in flate stream');
  2728. }
  2729. var blockLen = b;
  2730. if ((b = str.getByte()) === -1) {
  2731. error('Bad block header in flate stream');
  2732. }
  2733. blockLen |= b << 8;
  2734. if ((b = str.getByte()) === -1) {
  2735. error('Bad block header in flate stream');
  2736. }
  2737. var check = b;
  2738. if ((b = str.getByte()) === -1) {
  2739. error('Bad block header in flate stream');
  2740. }
  2741. check |= b << 8;
  2742. if (check !== (~blockLen & 0xffff) && (blockLen !== 0 || check !== 0)) {
  2743. error('Bad uncompressed block length in flate stream');
  2744. }
  2745. this.codeBuf = 0;
  2746. this.codeSize = 0;
  2747. var bufferLength = this.bufferLength;
  2748. buffer = this.ensureBuffer(bufferLength + blockLen);
  2749. var end = bufferLength + blockLen;
  2750. this.bufferLength = end;
  2751. if (blockLen === 0) {
  2752. if (str.peekByte() === -1) {
  2753. this.eof = true;
  2754. }
  2755. } else {
  2756. for (var n = bufferLength; n < end; ++n) {
  2757. if ((b = str.getByte()) === -1) {
  2758. this.eof = true;
  2759. break;
  2760. }
  2761. buffer[n] = b;
  2762. }
  2763. }
  2764. return;
  2765. }
  2766. var litCodeTable;
  2767. var distCodeTable;
  2768. if (hdr === 1) {
  2769. litCodeTable = fixedLitCodeTab;
  2770. distCodeTable = fixedDistCodeTab;
  2771. } else if (hdr === 2) {
  2772. var numLitCodes = this.getBits(5) + 257;
  2773. var numDistCodes = this.getBits(5) + 1;
  2774. var numCodeLenCodes = this.getBits(4) + 4;
  2775. var codeLenCodeLengths = new Uint8Array(codeLenCodeMap.length);
  2776. var i;
  2777. for (i = 0; i < numCodeLenCodes; ++i) {
  2778. codeLenCodeLengths[codeLenCodeMap[i]] = this.getBits(3);
  2779. }
  2780. var codeLenCodeTab = this.generateHuffmanTable(codeLenCodeLengths);
  2781. len = 0;
  2782. i = 0;
  2783. var codes = numLitCodes + numDistCodes;
  2784. var codeLengths = new Uint8Array(codes);
  2785. var bitsLength, bitsOffset, what;
  2786. while (i < codes) {
  2787. var code = this.getCode(codeLenCodeTab);
  2788. if (code === 16) {
  2789. bitsLength = 2;
  2790. bitsOffset = 3;
  2791. what = len;
  2792. } else if (code === 17) {
  2793. bitsLength = 3;
  2794. bitsOffset = 3;
  2795. what = len = 0;
  2796. } else if (code === 18) {
  2797. bitsLength = 7;
  2798. bitsOffset = 11;
  2799. what = len = 0;
  2800. } else {
  2801. codeLengths[i++] = len = code;
  2802. continue;
  2803. }
  2804. var repeatLength = this.getBits(bitsLength) + bitsOffset;
  2805. while (repeatLength-- > 0) {
  2806. codeLengths[i++] = what;
  2807. }
  2808. }
  2809. litCodeTable = this.generateHuffmanTable(codeLengths.subarray(0, numLitCodes));
  2810. distCodeTable = this.generateHuffmanTable(codeLengths.subarray(numLitCodes, codes));
  2811. } else {
  2812. error('Unknown block type in flate stream');
  2813. }
  2814. buffer = this.buffer;
  2815. var limit = buffer ? buffer.length : 0;
  2816. var pos = this.bufferLength;
  2817. while (true) {
  2818. var code1 = this.getCode(litCodeTable);
  2819. if (code1 < 256) {
  2820. if (pos + 1 >= limit) {
  2821. buffer = this.ensureBuffer(pos + 1);
  2822. limit = buffer.length;
  2823. }
  2824. buffer[pos++] = code1;
  2825. continue;
  2826. }
  2827. if (code1 === 256) {
  2828. this.bufferLength = pos;
  2829. return;
  2830. }
  2831. code1 -= 257;
  2832. code1 = lengthDecode[code1];
  2833. var code2 = code1 >> 16;
  2834. if (code2 > 0) {
  2835. code2 = this.getBits(code2);
  2836. }
  2837. len = (code1 & 0xffff) + code2;
  2838. code1 = this.getCode(distCodeTable);
  2839. code1 = distDecode[code1];
  2840. code2 = code1 >> 16;
  2841. if (code2 > 0) {
  2842. code2 = this.getBits(code2);
  2843. }
  2844. var dist = (code1 & 0xffff) + code2;
  2845. if (pos + len >= limit) {
  2846. buffer = this.ensureBuffer(pos + len);
  2847. limit = buffer.length;
  2848. }
  2849. for (var k = 0; k < len; ++k, ++pos) {
  2850. buffer[pos] = buffer[pos - dist];
  2851. }
  2852. }
  2853. };
  2854. return FlateStream;
  2855. }();
  2856. var PredictorStream = function PredictorStreamClosure() {
  2857. function PredictorStream(str, maybeLength, params) {
  2858. if (!isDict(params)) {
  2859. return str;
  2860. }
  2861. var predictor = this.predictor = params.get('Predictor') || 1;
  2862. if (predictor <= 1) {
  2863. return str;
  2864. }
  2865. if (predictor !== 2 && (predictor < 10 || predictor > 15)) {
  2866. error('Unsupported predictor: ' + predictor);
  2867. }
  2868. if (predictor === 2) {
  2869. this.readBlock = this.readBlockTiff;
  2870. } else {
  2871. this.readBlock = this.readBlockPng;
  2872. }
  2873. this.str = str;
  2874. this.dict = str.dict;
  2875. var colors = this.colors = params.get('Colors') || 1;
  2876. var bits = this.bits = params.get('BitsPerComponent') || 8;
  2877. var columns = this.columns = params.get('Columns') || 1;
  2878. this.pixBytes = colors * bits + 7 >> 3;
  2879. this.rowBytes = columns * colors * bits + 7 >> 3;
  2880. DecodeStream.call(this, maybeLength);
  2881. return this;
  2882. }
  2883. PredictorStream.prototype = Object.create(DecodeStream.prototype);
  2884. PredictorStream.prototype.readBlockTiff = function predictorStreamReadBlockTiff() {
  2885. var rowBytes = this.rowBytes;
  2886. var bufferLength = this.bufferLength;
  2887. var buffer = this.ensureBuffer(bufferLength + rowBytes);
  2888. var bits = this.bits;
  2889. var colors = this.colors;
  2890. var rawBytes = this.str.getBytes(rowBytes);
  2891. this.eof = !rawBytes.length;
  2892. if (this.eof) {
  2893. return;
  2894. }
  2895. var inbuf = 0, outbuf = 0;
  2896. var inbits = 0, outbits = 0;
  2897. var pos = bufferLength;
  2898. var i;
  2899. if (bits === 1 && colors === 1) {
  2900. for (i = 0; i < rowBytes; ++i) {
  2901. var c = rawBytes[i] ^ inbuf;
  2902. c ^= c >> 1;
  2903. c ^= c >> 2;
  2904. c ^= c >> 4;
  2905. inbuf = (c & 1) << 7;
  2906. buffer[pos++] = c;
  2907. }
  2908. } else if (bits === 8) {
  2909. for (i = 0; i < colors; ++i) {
  2910. buffer[pos++] = rawBytes[i];
  2911. }
  2912. for (; i < rowBytes; ++i) {
  2913. buffer[pos] = buffer[pos - colors] + rawBytes[i];
  2914. pos++;
  2915. }
  2916. } else {
  2917. var compArray = new Uint8Array(colors + 1);
  2918. var bitMask = (1 << bits) - 1;
  2919. var j = 0, k = bufferLength;
  2920. var columns = this.columns;
  2921. for (i = 0; i < columns; ++i) {
  2922. for (var kk = 0; kk < colors; ++kk) {
  2923. if (inbits < bits) {
  2924. inbuf = inbuf << 8 | rawBytes[j++] & 0xFF;
  2925. inbits += 8;
  2926. }
  2927. compArray[kk] = compArray[kk] + (inbuf >> inbits - bits) & bitMask;
  2928. inbits -= bits;
  2929. outbuf = outbuf << bits | compArray[kk];
  2930. outbits += bits;
  2931. if (outbits >= 8) {
  2932. buffer[k++] = outbuf >> outbits - 8 & 0xFF;
  2933. outbits -= 8;
  2934. }
  2935. }
  2936. }
  2937. if (outbits > 0) {
  2938. buffer[k++] = (outbuf << 8 - outbits) + (inbuf & (1 << 8 - outbits) - 1);
  2939. }
  2940. }
  2941. this.bufferLength += rowBytes;
  2942. };
  2943. PredictorStream.prototype.readBlockPng = function predictorStreamReadBlockPng() {
  2944. var rowBytes = this.rowBytes;
  2945. var pixBytes = this.pixBytes;
  2946. var predictor = this.str.getByte();
  2947. var rawBytes = this.str.getBytes(rowBytes);
  2948. this.eof = !rawBytes.length;
  2949. if (this.eof) {
  2950. return;
  2951. }
  2952. var bufferLength = this.bufferLength;
  2953. var buffer = this.ensureBuffer(bufferLength + rowBytes);
  2954. var prevRow = buffer.subarray(bufferLength - rowBytes, bufferLength);
  2955. if (prevRow.length === 0) {
  2956. prevRow = new Uint8Array(rowBytes);
  2957. }
  2958. var i, j = bufferLength, up, c;
  2959. switch (predictor) {
  2960. case 0:
  2961. for (i = 0; i < rowBytes; ++i) {
  2962. buffer[j++] = rawBytes[i];
  2963. }
  2964. break;
  2965. case 1:
  2966. for (i = 0; i < pixBytes; ++i) {
  2967. buffer[j++] = rawBytes[i];
  2968. }
  2969. for (; i < rowBytes; ++i) {
  2970. buffer[j] = buffer[j - pixBytes] + rawBytes[i] & 0xFF;
  2971. j++;
  2972. }
  2973. break;
  2974. case 2:
  2975. for (i = 0; i < rowBytes; ++i) {
  2976. buffer[j++] = prevRow[i] + rawBytes[i] & 0xFF;
  2977. }
  2978. break;
  2979. case 3:
  2980. for (i = 0; i < pixBytes; ++i) {
  2981. buffer[j++] = (prevRow[i] >> 1) + rawBytes[i];
  2982. }
  2983. for (; i < rowBytes; ++i) {
  2984. buffer[j] = (prevRow[i] + buffer[j - pixBytes] >> 1) + rawBytes[i] & 0xFF;
  2985. j++;
  2986. }
  2987. break;
  2988. case 4:
  2989. for (i = 0; i < pixBytes; ++i) {
  2990. up = prevRow[i];
  2991. c = rawBytes[i];
  2992. buffer[j++] = up + c;
  2993. }
  2994. for (; i < rowBytes; ++i) {
  2995. up = prevRow[i];
  2996. var upLeft = prevRow[i - pixBytes];
  2997. var left = buffer[j - pixBytes];
  2998. var p = left + up - upLeft;
  2999. var pa = p - left;
  3000. if (pa < 0) {
  3001. pa = -pa;
  3002. }
  3003. var pb = p - up;
  3004. if (pb < 0) {
  3005. pb = -pb;
  3006. }
  3007. var pc = p - upLeft;
  3008. if (pc < 0) {
  3009. pc = -pc;
  3010. }
  3011. c = rawBytes[i];
  3012. if (pa <= pb && pa <= pc) {
  3013. buffer[j++] = left + c;
  3014. } else if (pb <= pc) {
  3015. buffer[j++] = up + c;
  3016. } else {
  3017. buffer[j++] = upLeft + c;
  3018. }
  3019. }
  3020. break;
  3021. default:
  3022. error('Unsupported predictor: ' + predictor);
  3023. }
  3024. this.bufferLength += rowBytes;
  3025. };
  3026. return PredictorStream;
  3027. }();
  3028. var JpegStream = function JpegStreamClosure() {
  3029. function JpegStream(stream, maybeLength, dict, params) {
  3030. var ch;
  3031. while ((ch = stream.getByte()) !== -1) {
  3032. if (ch === 0xFF) {
  3033. stream.skip(-1);
  3034. break;
  3035. }
  3036. }
  3037. this.stream = stream;
  3038. this.maybeLength = maybeLength;
  3039. this.dict = dict;
  3040. this.params = params;
  3041. DecodeStream.call(this, maybeLength);
  3042. }
  3043. JpegStream.prototype = Object.create(DecodeStream.prototype);
  3044. Object.defineProperty(JpegStream.prototype, 'bytes', {
  3045. get: function JpegStream_bytes() {
  3046. return shadow(this, 'bytes', this.stream.getBytes(this.maybeLength));
  3047. },
  3048. configurable: true
  3049. });
  3050. JpegStream.prototype.ensureBuffer = function JpegStream_ensureBuffer(req) {
  3051. if (this.bufferLength) {
  3052. return;
  3053. }
  3054. var jpegImage = new JpegImage();
  3055. var decodeArr = this.dict.getArray('Decode', 'D');
  3056. if (this.forceRGB && isArray(decodeArr)) {
  3057. var bitsPerComponent = this.dict.get('BitsPerComponent') || 8;
  3058. var decodeArrLength = decodeArr.length;
  3059. var transform = new Int32Array(decodeArrLength);
  3060. var transformNeeded = false;
  3061. var maxValue = (1 << bitsPerComponent) - 1;
  3062. for (var i = 0; i < decodeArrLength; i += 2) {
  3063. transform[i] = (decodeArr[i + 1] - decodeArr[i]) * 256 | 0;
  3064. transform[i + 1] = decodeArr[i] * maxValue | 0;
  3065. if (transform[i] !== 256 || transform[i + 1] !== 0) {
  3066. transformNeeded = true;
  3067. }
  3068. }
  3069. if (transformNeeded) {
  3070. jpegImage.decodeTransform = transform;
  3071. }
  3072. }
  3073. if (isDict(this.params)) {
  3074. var colorTransform = this.params.get('ColorTransform');
  3075. if (isInt(colorTransform)) {
  3076. jpegImage.colorTransform = colorTransform;
  3077. }
  3078. }
  3079. jpegImage.parse(this.bytes);
  3080. var data = jpegImage.getData(this.drawWidth, this.drawHeight, this.forceRGB);
  3081. this.buffer = data;
  3082. this.bufferLength = data.length;
  3083. this.eof = true;
  3084. };
  3085. JpegStream.prototype.getBytes = function JpegStream_getBytes(length) {
  3086. this.ensureBuffer();
  3087. return this.buffer;
  3088. };
  3089. JpegStream.prototype.getIR = function JpegStream_getIR(forceDataSchema) {
  3090. return createObjectURL(this.bytes, 'image/jpeg', forceDataSchema);
  3091. };
  3092. return JpegStream;
  3093. }();
  3094. var JpxStream = function JpxStreamClosure() {
  3095. function JpxStream(stream, maybeLength, dict, params) {
  3096. this.stream = stream;
  3097. this.maybeLength = maybeLength;
  3098. this.dict = dict;
  3099. this.params = params;
  3100. DecodeStream.call(this, maybeLength);
  3101. }
  3102. JpxStream.prototype = Object.create(DecodeStream.prototype);
  3103. Object.defineProperty(JpxStream.prototype, 'bytes', {
  3104. get: function JpxStream_bytes() {
  3105. return shadow(this, 'bytes', this.stream.getBytes(this.maybeLength));
  3106. },
  3107. configurable: true
  3108. });
  3109. JpxStream.prototype.ensureBuffer = function JpxStream_ensureBuffer(req) {
  3110. if (this.bufferLength) {
  3111. return;
  3112. }
  3113. var jpxImage = new JpxImage();
  3114. jpxImage.parse(this.bytes);
  3115. var width = jpxImage.width;
  3116. var height = jpxImage.height;
  3117. var componentsCount = jpxImage.componentsCount;
  3118. var tileCount = jpxImage.tiles.length;
  3119. if (tileCount === 1) {
  3120. this.buffer = jpxImage.tiles[0].items;
  3121. } else {
  3122. var data = new Uint8Array(width * height * componentsCount);
  3123. for (var k = 0; k < tileCount; k++) {
  3124. var tileComponents = jpxImage.tiles[k];
  3125. var tileWidth = tileComponents.width;
  3126. var tileHeight = tileComponents.height;
  3127. var tileLeft = tileComponents.left;
  3128. var tileTop = tileComponents.top;
  3129. var src = tileComponents.items;
  3130. var srcPosition = 0;
  3131. var dataPosition = (width * tileTop + tileLeft) * componentsCount;
  3132. var imgRowSize = width * componentsCount;
  3133. var tileRowSize = tileWidth * componentsCount;
  3134. for (var j = 0; j < tileHeight; j++) {
  3135. var rowBytes = src.subarray(srcPosition, srcPosition + tileRowSize);
  3136. data.set(rowBytes, dataPosition);
  3137. srcPosition += tileRowSize;
  3138. dataPosition += imgRowSize;
  3139. }
  3140. }
  3141. this.buffer = data;
  3142. }
  3143. this.bufferLength = this.buffer.length;
  3144. this.eof = true;
  3145. };
  3146. return JpxStream;
  3147. }();
  3148. var Jbig2Stream = function Jbig2StreamClosure() {
  3149. function Jbig2Stream(stream, maybeLength, dict, params) {
  3150. this.stream = stream;
  3151. this.maybeLength = maybeLength;
  3152. this.dict = dict;
  3153. this.params = params;
  3154. DecodeStream.call(this, maybeLength);
  3155. }
  3156. Jbig2Stream.prototype = Object.create(DecodeStream.prototype);
  3157. Object.defineProperty(Jbig2Stream.prototype, 'bytes', {
  3158. get: function Jbig2Stream_bytes() {
  3159. return shadow(this, 'bytes', this.stream.getBytes(this.maybeLength));
  3160. },
  3161. configurable: true
  3162. });
  3163. Jbig2Stream.prototype.ensureBuffer = function Jbig2Stream_ensureBuffer(req) {
  3164. if (this.bufferLength) {
  3165. return;
  3166. }
  3167. var jbig2Image = new Jbig2Image();
  3168. var chunks = [];
  3169. if (isDict(this.params)) {
  3170. var globalsStream = this.params.get('JBIG2Globals');
  3171. if (isStream(globalsStream)) {
  3172. var globals = globalsStream.getBytes();
  3173. chunks.push({
  3174. data: globals,
  3175. start: 0,
  3176. end: globals.length
  3177. });
  3178. }
  3179. }
  3180. chunks.push({
  3181. data: this.bytes,
  3182. start: 0,
  3183. end: this.bytes.length
  3184. });
  3185. var data = jbig2Image.parseChunks(chunks);
  3186. var dataLength = data.length;
  3187. for (var i = 0; i < dataLength; i++) {
  3188. data[i] ^= 0xFF;
  3189. }
  3190. this.buffer = data;
  3191. this.bufferLength = dataLength;
  3192. this.eof = true;
  3193. };
  3194. return Jbig2Stream;
  3195. }();
  3196. var DecryptStream = function DecryptStreamClosure() {
  3197. function DecryptStream(str, maybeLength, decrypt) {
  3198. this.str = str;
  3199. this.dict = str.dict;
  3200. this.decrypt = decrypt;
  3201. this.nextChunk = null;
  3202. this.initialized = false;
  3203. DecodeStream.call(this, maybeLength);
  3204. }
  3205. var chunkSize = 512;
  3206. DecryptStream.prototype = Object.create(DecodeStream.prototype);
  3207. DecryptStream.prototype.readBlock = function DecryptStream_readBlock() {
  3208. var chunk;
  3209. if (this.initialized) {
  3210. chunk = this.nextChunk;
  3211. } else {
  3212. chunk = this.str.getBytes(chunkSize);
  3213. this.initialized = true;
  3214. }
  3215. if (!chunk || chunk.length === 0) {
  3216. this.eof = true;
  3217. return;
  3218. }
  3219. this.nextChunk = this.str.getBytes(chunkSize);
  3220. var hasMoreData = this.nextChunk && this.nextChunk.length > 0;
  3221. var decrypt = this.decrypt;
  3222. chunk = decrypt(chunk, !hasMoreData);
  3223. var bufferLength = this.bufferLength;
  3224. var i, n = chunk.length;
  3225. var buffer = this.ensureBuffer(bufferLength + n);
  3226. for (i = 0; i < n; i++) {
  3227. buffer[bufferLength++] = chunk[i];
  3228. }
  3229. this.bufferLength = bufferLength;
  3230. };
  3231. return DecryptStream;
  3232. }();
  3233. var Ascii85Stream = function Ascii85StreamClosure() {
  3234. function Ascii85Stream(str, maybeLength) {
  3235. this.str = str;
  3236. this.dict = str.dict;
  3237. this.input = new Uint8Array(5);
  3238. if (maybeLength) {
  3239. maybeLength = 0.8 * maybeLength;
  3240. }
  3241. DecodeStream.call(this, maybeLength);
  3242. }
  3243. Ascii85Stream.prototype = Object.create(DecodeStream.prototype);
  3244. Ascii85Stream.prototype.readBlock = function Ascii85Stream_readBlock() {
  3245. var TILDA_CHAR = 0x7E;
  3246. var Z_LOWER_CHAR = 0x7A;
  3247. var EOF = -1;
  3248. var str = this.str;
  3249. var c = str.getByte();
  3250. while (isSpace(c)) {
  3251. c = str.getByte();
  3252. }
  3253. if (c === EOF || c === TILDA_CHAR) {
  3254. this.eof = true;
  3255. return;
  3256. }
  3257. var bufferLength = this.bufferLength, buffer;
  3258. var i;
  3259. if (c === Z_LOWER_CHAR) {
  3260. buffer = this.ensureBuffer(bufferLength + 4);
  3261. for (i = 0; i < 4; ++i) {
  3262. buffer[bufferLength + i] = 0;
  3263. }
  3264. this.bufferLength += 4;
  3265. } else {
  3266. var input = this.input;
  3267. input[0] = c;
  3268. for (i = 1; i < 5; ++i) {
  3269. c = str.getByte();
  3270. while (isSpace(c)) {
  3271. c = str.getByte();
  3272. }
  3273. input[i] = c;
  3274. if (c === EOF || c === TILDA_CHAR) {
  3275. break;
  3276. }
  3277. }
  3278. buffer = this.ensureBuffer(bufferLength + i - 1);
  3279. this.bufferLength += i - 1;
  3280. if (i < 5) {
  3281. for (; i < 5; ++i) {
  3282. input[i] = 0x21 + 84;
  3283. }
  3284. this.eof = true;
  3285. }
  3286. var t = 0;
  3287. for (i = 0; i < 5; ++i) {
  3288. t = t * 85 + (input[i] - 0x21);
  3289. }
  3290. for (i = 3; i >= 0; --i) {
  3291. buffer[bufferLength + i] = t & 0xFF;
  3292. t >>= 8;
  3293. }
  3294. }
  3295. };
  3296. return Ascii85Stream;
  3297. }();
  3298. var AsciiHexStream = function AsciiHexStreamClosure() {
  3299. function AsciiHexStream(str, maybeLength) {
  3300. this.str = str;
  3301. this.dict = str.dict;
  3302. this.firstDigit = -1;
  3303. if (maybeLength) {
  3304. maybeLength = 0.5 * maybeLength;
  3305. }
  3306. DecodeStream.call(this, maybeLength);
  3307. }
  3308. AsciiHexStream.prototype = Object.create(DecodeStream.prototype);
  3309. AsciiHexStream.prototype.readBlock = function AsciiHexStream_readBlock() {
  3310. var UPSTREAM_BLOCK_SIZE = 8000;
  3311. var bytes = this.str.getBytes(UPSTREAM_BLOCK_SIZE);
  3312. if (!bytes.length) {
  3313. this.eof = true;
  3314. return;
  3315. }
  3316. var maxDecodeLength = bytes.length + 1 >> 1;
  3317. var buffer = this.ensureBuffer(this.bufferLength + maxDecodeLength);
  3318. var bufferLength = this.bufferLength;
  3319. var firstDigit = this.firstDigit;
  3320. for (var i = 0, ii = bytes.length; i < ii; i++) {
  3321. var ch = bytes[i], digit;
  3322. if (ch >= 0x30 && ch <= 0x39) {
  3323. digit = ch & 0x0F;
  3324. } else if (ch >= 0x41 && ch <= 0x46 || ch >= 0x61 && ch <= 0x66) {
  3325. digit = (ch & 0x0F) + 9;
  3326. } else if (ch === 0x3E) {
  3327. this.eof = true;
  3328. break;
  3329. } else {
  3330. continue;
  3331. }
  3332. if (firstDigit < 0) {
  3333. firstDigit = digit;
  3334. } else {
  3335. buffer[bufferLength++] = firstDigit << 4 | digit;
  3336. firstDigit = -1;
  3337. }
  3338. }
  3339. if (firstDigit >= 0 && this.eof) {
  3340. buffer[bufferLength++] = firstDigit << 4;
  3341. firstDigit = -1;
  3342. }
  3343. this.firstDigit = firstDigit;
  3344. this.bufferLength = bufferLength;
  3345. };
  3346. return AsciiHexStream;
  3347. }();
  3348. var RunLengthStream = function RunLengthStreamClosure() {
  3349. function RunLengthStream(str, maybeLength) {
  3350. this.str = str;
  3351. this.dict = str.dict;
  3352. DecodeStream.call(this, maybeLength);
  3353. }
  3354. RunLengthStream.prototype = Object.create(DecodeStream.prototype);
  3355. RunLengthStream.prototype.readBlock = function RunLengthStream_readBlock() {
  3356. var repeatHeader = this.str.getBytes(2);
  3357. if (!repeatHeader || repeatHeader.length < 2 || repeatHeader[0] === 128) {
  3358. this.eof = true;
  3359. return;
  3360. }
  3361. var buffer;
  3362. var bufferLength = this.bufferLength;
  3363. var n = repeatHeader[0];
  3364. if (n < 128) {
  3365. buffer = this.ensureBuffer(bufferLength + n + 1);
  3366. buffer[bufferLength++] = repeatHeader[1];
  3367. if (n > 0) {
  3368. var source = this.str.getBytes(n);
  3369. buffer.set(source, bufferLength);
  3370. bufferLength += n;
  3371. }
  3372. } else {
  3373. n = 257 - n;
  3374. var b = repeatHeader[1];
  3375. buffer = this.ensureBuffer(bufferLength + n + 1);
  3376. for (var i = 0; i < n; i++) {
  3377. buffer[bufferLength++] = b;
  3378. }
  3379. }
  3380. this.bufferLength = bufferLength;
  3381. };
  3382. return RunLengthStream;
  3383. }();
  3384. var CCITTFaxStream = function CCITTFaxStreamClosure() {
  3385. var ccittEOL = -2;
  3386. var ccittEOF = -1;
  3387. var twoDimPass = 0;
  3388. var twoDimHoriz = 1;
  3389. var twoDimVert0 = 2;
  3390. var twoDimVertR1 = 3;
  3391. var twoDimVertL1 = 4;
  3392. var twoDimVertR2 = 5;
  3393. var twoDimVertL2 = 6;
  3394. var twoDimVertR3 = 7;
  3395. var twoDimVertL3 = 8;
  3396. var twoDimTable = [
  3397. [
  3398. -1,
  3399. -1
  3400. ],
  3401. [
  3402. -1,
  3403. -1
  3404. ],
  3405. [
  3406. 7,
  3407. twoDimVertL3
  3408. ],
  3409. [
  3410. 7,
  3411. twoDimVertR3
  3412. ],
  3413. [
  3414. 6,
  3415. twoDimVertL2
  3416. ],
  3417. [
  3418. 6,
  3419. twoDimVertL2
  3420. ],
  3421. [
  3422. 6,
  3423. twoDimVertR2
  3424. ],
  3425. [
  3426. 6,
  3427. twoDimVertR2
  3428. ],
  3429. [
  3430. 4,
  3431. twoDimPass
  3432. ],
  3433. [
  3434. 4,
  3435. twoDimPass
  3436. ],
  3437. [
  3438. 4,
  3439. twoDimPass
  3440. ],
  3441. [
  3442. 4,
  3443. twoDimPass
  3444. ],
  3445. [
  3446. 4,
  3447. twoDimPass
  3448. ],
  3449. [
  3450. 4,
  3451. twoDimPass
  3452. ],
  3453. [
  3454. 4,
  3455. twoDimPass
  3456. ],
  3457. [
  3458. 4,
  3459. twoDimPass
  3460. ],
  3461. [
  3462. 3,
  3463. twoDimHoriz
  3464. ],
  3465. [
  3466. 3,
  3467. twoDimHoriz
  3468. ],
  3469. [
  3470. 3,
  3471. twoDimHoriz
  3472. ],
  3473. [
  3474. 3,
  3475. twoDimHoriz
  3476. ],
  3477. [
  3478. 3,
  3479. twoDimHoriz
  3480. ],
  3481. [
  3482. 3,
  3483. twoDimHoriz
  3484. ],
  3485. [
  3486. 3,
  3487. twoDimHoriz
  3488. ],
  3489. [
  3490. 3,
  3491. twoDimHoriz
  3492. ],
  3493. [
  3494. 3,
  3495. twoDimHoriz
  3496. ],
  3497. [
  3498. 3,
  3499. twoDimHoriz
  3500. ],
  3501. [
  3502. 3,
  3503. twoDimHoriz
  3504. ],
  3505. [
  3506. 3,
  3507. twoDimHoriz
  3508. ],
  3509. [
  3510. 3,
  3511. twoDimHoriz
  3512. ],
  3513. [
  3514. 3,
  3515. twoDimHoriz
  3516. ],
  3517. [
  3518. 3,
  3519. twoDimHoriz
  3520. ],
  3521. [
  3522. 3,
  3523. twoDimHoriz
  3524. ],
  3525. [
  3526. 3,
  3527. twoDimVertL1
  3528. ],
  3529. [
  3530. 3,
  3531. twoDimVertL1
  3532. ],
  3533. [
  3534. 3,
  3535. twoDimVertL1
  3536. ],
  3537. [
  3538. 3,
  3539. twoDimVertL1
  3540. ],
  3541. [
  3542. 3,
  3543. twoDimVertL1
  3544. ],
  3545. [
  3546. 3,
  3547. twoDimVertL1
  3548. ],
  3549. [
  3550. 3,
  3551. twoDimVertL1
  3552. ],
  3553. [
  3554. 3,
  3555. twoDimVertL1
  3556. ],
  3557. [
  3558. 3,
  3559. twoDimVertL1
  3560. ],
  3561. [
  3562. 3,
  3563. twoDimVertL1
  3564. ],
  3565. [
  3566. 3,
  3567. twoDimVertL1
  3568. ],
  3569. [
  3570. 3,
  3571. twoDimVertL1
  3572. ],
  3573. [
  3574. 3,
  3575. twoDimVertL1
  3576. ],
  3577. [
  3578. 3,
  3579. twoDimVertL1
  3580. ],
  3581. [
  3582. 3,
  3583. twoDimVertL1
  3584. ],
  3585. [
  3586. 3,
  3587. twoDimVertL1
  3588. ],
  3589. [
  3590. 3,
  3591. twoDimVertR1
  3592. ],
  3593. [
  3594. 3,
  3595. twoDimVertR1
  3596. ],
  3597. [
  3598. 3,
  3599. twoDimVertR1
  3600. ],
  3601. [
  3602. 3,
  3603. twoDimVertR1
  3604. ],
  3605. [
  3606. 3,
  3607. twoDimVertR1
  3608. ],
  3609. [
  3610. 3,
  3611. twoDimVertR1
  3612. ],
  3613. [
  3614. 3,
  3615. twoDimVertR1
  3616. ],
  3617. [
  3618. 3,
  3619. twoDimVertR1
  3620. ],
  3621. [
  3622. 3,
  3623. twoDimVertR1
  3624. ],
  3625. [
  3626. 3,
  3627. twoDimVertR1
  3628. ],
  3629. [
  3630. 3,
  3631. twoDimVertR1
  3632. ],
  3633. [
  3634. 3,
  3635. twoDimVertR1
  3636. ],
  3637. [
  3638. 3,
  3639. twoDimVertR1
  3640. ],
  3641. [
  3642. 3,
  3643. twoDimVertR1
  3644. ],
  3645. [
  3646. 3,
  3647. twoDimVertR1
  3648. ],
  3649. [
  3650. 3,
  3651. twoDimVertR1
  3652. ],
  3653. [
  3654. 1,
  3655. twoDimVert0
  3656. ],
  3657. [
  3658. 1,
  3659. twoDimVert0
  3660. ],
  3661. [
  3662. 1,
  3663. twoDimVert0
  3664. ],
  3665. [
  3666. 1,
  3667. twoDimVert0
  3668. ],
  3669. [
  3670. 1,
  3671. twoDimVert0
  3672. ],
  3673. [
  3674. 1,
  3675. twoDimVert0
  3676. ],
  3677. [
  3678. 1,
  3679. twoDimVert0
  3680. ],
  3681. [
  3682. 1,
  3683. twoDimVert0
  3684. ],
  3685. [
  3686. 1,
  3687. twoDimVert0
  3688. ],
  3689. [
  3690. 1,
  3691. twoDimVert0
  3692. ],
  3693. [
  3694. 1,
  3695. twoDimVert0
  3696. ],
  3697. [
  3698. 1,
  3699. twoDimVert0
  3700. ],
  3701. [
  3702. 1,
  3703. twoDimVert0
  3704. ],
  3705. [
  3706. 1,
  3707. twoDimVert0
  3708. ],
  3709. [
  3710. 1,
  3711. twoDimVert0
  3712. ],
  3713. [
  3714. 1,
  3715. twoDimVert0
  3716. ],
  3717. [
  3718. 1,
  3719. twoDimVert0
  3720. ],
  3721. [
  3722. 1,
  3723. twoDimVert0
  3724. ],
  3725. [
  3726. 1,
  3727. twoDimVert0
  3728. ],
  3729. [
  3730. 1,
  3731. twoDimVert0
  3732. ],
  3733. [
  3734. 1,
  3735. twoDimVert0
  3736. ],
  3737. [
  3738. 1,
  3739. twoDimVert0
  3740. ],
  3741. [
  3742. 1,
  3743. twoDimVert0
  3744. ],
  3745. [
  3746. 1,
  3747. twoDimVert0
  3748. ],
  3749. [
  3750. 1,
  3751. twoDimVert0
  3752. ],
  3753. [
  3754. 1,
  3755. twoDimVert0
  3756. ],
  3757. [
  3758. 1,
  3759. twoDimVert0
  3760. ],
  3761. [
  3762. 1,
  3763. twoDimVert0
  3764. ],
  3765. [
  3766. 1,
  3767. twoDimVert0
  3768. ],
  3769. [
  3770. 1,
  3771. twoDimVert0
  3772. ],
  3773. [
  3774. 1,
  3775. twoDimVert0
  3776. ],
  3777. [
  3778. 1,
  3779. twoDimVert0
  3780. ],
  3781. [
  3782. 1,
  3783. twoDimVert0
  3784. ],
  3785. [
  3786. 1,
  3787. twoDimVert0
  3788. ],
  3789. [
  3790. 1,
  3791. twoDimVert0
  3792. ],
  3793. [
  3794. 1,
  3795. twoDimVert0
  3796. ],
  3797. [
  3798. 1,
  3799. twoDimVert0
  3800. ],
  3801. [
  3802. 1,
  3803. twoDimVert0
  3804. ],
  3805. [
  3806. 1,
  3807. twoDimVert0
  3808. ],
  3809. [
  3810. 1,
  3811. twoDimVert0
  3812. ],
  3813. [
  3814. 1,
  3815. twoDimVert0
  3816. ],
  3817. [
  3818. 1,
  3819. twoDimVert0
  3820. ],
  3821. [
  3822. 1,
  3823. twoDimVert0
  3824. ],
  3825. [
  3826. 1,
  3827. twoDimVert0
  3828. ],
  3829. [
  3830. 1,
  3831. twoDimVert0
  3832. ],
  3833. [
  3834. 1,
  3835. twoDimVert0
  3836. ],
  3837. [
  3838. 1,
  3839. twoDimVert0
  3840. ],
  3841. [
  3842. 1,
  3843. twoDimVert0
  3844. ],
  3845. [
  3846. 1,
  3847. twoDimVert0
  3848. ],
  3849. [
  3850. 1,
  3851. twoDimVert0
  3852. ],
  3853. [
  3854. 1,
  3855. twoDimVert0
  3856. ],
  3857. [
  3858. 1,
  3859. twoDimVert0
  3860. ],
  3861. [
  3862. 1,
  3863. twoDimVert0
  3864. ],
  3865. [
  3866. 1,
  3867. twoDimVert0
  3868. ],
  3869. [
  3870. 1,
  3871. twoDimVert0
  3872. ],
  3873. [
  3874. 1,
  3875. twoDimVert0
  3876. ],
  3877. [
  3878. 1,
  3879. twoDimVert0
  3880. ],
  3881. [
  3882. 1,
  3883. twoDimVert0
  3884. ],
  3885. [
  3886. 1,
  3887. twoDimVert0
  3888. ],
  3889. [
  3890. 1,
  3891. twoDimVert0
  3892. ],
  3893. [
  3894. 1,
  3895. twoDimVert0
  3896. ],
  3897. [
  3898. 1,
  3899. twoDimVert0
  3900. ],
  3901. [
  3902. 1,
  3903. twoDimVert0
  3904. ],
  3905. [
  3906. 1,
  3907. twoDimVert0
  3908. ]
  3909. ];
  3910. var whiteTable1 = [
  3911. [
  3912. -1,
  3913. -1
  3914. ],
  3915. [
  3916. 12,
  3917. ccittEOL
  3918. ],
  3919. [
  3920. -1,
  3921. -1
  3922. ],
  3923. [
  3924. -1,
  3925. -1
  3926. ],
  3927. [
  3928. -1,
  3929. -1
  3930. ],
  3931. [
  3932. -1,
  3933. -1
  3934. ],
  3935. [
  3936. -1,
  3937. -1
  3938. ],
  3939. [
  3940. -1,
  3941. -1
  3942. ],
  3943. [
  3944. -1,
  3945. -1
  3946. ],
  3947. [
  3948. -1,
  3949. -1
  3950. ],
  3951. [
  3952. -1,
  3953. -1
  3954. ],
  3955. [
  3956. -1,
  3957. -1
  3958. ],
  3959. [
  3960. -1,
  3961. -1
  3962. ],
  3963. [
  3964. -1,
  3965. -1
  3966. ],
  3967. [
  3968. -1,
  3969. -1
  3970. ],
  3971. [
  3972. -1,
  3973. -1
  3974. ],
  3975. [
  3976. 11,
  3977. 1792
  3978. ],
  3979. [
  3980. 11,
  3981. 1792
  3982. ],
  3983. [
  3984. 12,
  3985. 1984
  3986. ],
  3987. [
  3988. 12,
  3989. 2048
  3990. ],
  3991. [
  3992. 12,
  3993. 2112
  3994. ],
  3995. [
  3996. 12,
  3997. 2176
  3998. ],
  3999. [
  4000. 12,
  4001. 2240
  4002. ],
  4003. [
  4004. 12,
  4005. 2304
  4006. ],
  4007. [
  4008. 11,
  4009. 1856
  4010. ],
  4011. [
  4012. 11,
  4013. 1856
  4014. ],
  4015. [
  4016. 11,
  4017. 1920
  4018. ],
  4019. [
  4020. 11,
  4021. 1920
  4022. ],
  4023. [
  4024. 12,
  4025. 2368
  4026. ],
  4027. [
  4028. 12,
  4029. 2432
  4030. ],
  4031. [
  4032. 12,
  4033. 2496
  4034. ],
  4035. [
  4036. 12,
  4037. 2560
  4038. ]
  4039. ];
  4040. var whiteTable2 = [
  4041. [
  4042. -1,
  4043. -1
  4044. ],
  4045. [
  4046. -1,
  4047. -1
  4048. ],
  4049. [
  4050. -1,
  4051. -1
  4052. ],
  4053. [
  4054. -1,
  4055. -1
  4056. ],
  4057. [
  4058. 8,
  4059. 29
  4060. ],
  4061. [
  4062. 8,
  4063. 29
  4064. ],
  4065. [
  4066. 8,
  4067. 30
  4068. ],
  4069. [
  4070. 8,
  4071. 30
  4072. ],
  4073. [
  4074. 8,
  4075. 45
  4076. ],
  4077. [
  4078. 8,
  4079. 45
  4080. ],
  4081. [
  4082. 8,
  4083. 46
  4084. ],
  4085. [
  4086. 8,
  4087. 46
  4088. ],
  4089. [
  4090. 7,
  4091. 22
  4092. ],
  4093. [
  4094. 7,
  4095. 22
  4096. ],
  4097. [
  4098. 7,
  4099. 22
  4100. ],
  4101. [
  4102. 7,
  4103. 22
  4104. ],
  4105. [
  4106. 7,
  4107. 23
  4108. ],
  4109. [
  4110. 7,
  4111. 23
  4112. ],
  4113. [
  4114. 7,
  4115. 23
  4116. ],
  4117. [
  4118. 7,
  4119. 23
  4120. ],
  4121. [
  4122. 8,
  4123. 47
  4124. ],
  4125. [
  4126. 8,
  4127. 47
  4128. ],
  4129. [
  4130. 8,
  4131. 48
  4132. ],
  4133. [
  4134. 8,
  4135. 48
  4136. ],
  4137. [
  4138. 6,
  4139. 13
  4140. ],
  4141. [
  4142. 6,
  4143. 13
  4144. ],
  4145. [
  4146. 6,
  4147. 13
  4148. ],
  4149. [
  4150. 6,
  4151. 13
  4152. ],
  4153. [
  4154. 6,
  4155. 13
  4156. ],
  4157. [
  4158. 6,
  4159. 13
  4160. ],
  4161. [
  4162. 6,
  4163. 13
  4164. ],
  4165. [
  4166. 6,
  4167. 13
  4168. ],
  4169. [
  4170. 7,
  4171. 20
  4172. ],
  4173. [
  4174. 7,
  4175. 20
  4176. ],
  4177. [
  4178. 7,
  4179. 20
  4180. ],
  4181. [
  4182. 7,
  4183. 20
  4184. ],
  4185. [
  4186. 8,
  4187. 33
  4188. ],
  4189. [
  4190. 8,
  4191. 33
  4192. ],
  4193. [
  4194. 8,
  4195. 34
  4196. ],
  4197. [
  4198. 8,
  4199. 34
  4200. ],
  4201. [
  4202. 8,
  4203. 35
  4204. ],
  4205. [
  4206. 8,
  4207. 35
  4208. ],
  4209. [
  4210. 8,
  4211. 36
  4212. ],
  4213. [
  4214. 8,
  4215. 36
  4216. ],
  4217. [
  4218. 8,
  4219. 37
  4220. ],
  4221. [
  4222. 8,
  4223. 37
  4224. ],
  4225. [
  4226. 8,
  4227. 38
  4228. ],
  4229. [
  4230. 8,
  4231. 38
  4232. ],
  4233. [
  4234. 7,
  4235. 19
  4236. ],
  4237. [
  4238. 7,
  4239. 19
  4240. ],
  4241. [
  4242. 7,
  4243. 19
  4244. ],
  4245. [
  4246. 7,
  4247. 19
  4248. ],
  4249. [
  4250. 8,
  4251. 31
  4252. ],
  4253. [
  4254. 8,
  4255. 31
  4256. ],
  4257. [
  4258. 8,
  4259. 32
  4260. ],
  4261. [
  4262. 8,
  4263. 32
  4264. ],
  4265. [
  4266. 6,
  4267. 1
  4268. ],
  4269. [
  4270. 6,
  4271. 1
  4272. ],
  4273. [
  4274. 6,
  4275. 1
  4276. ],
  4277. [
  4278. 6,
  4279. 1
  4280. ],
  4281. [
  4282. 6,
  4283. 1
  4284. ],
  4285. [
  4286. 6,
  4287. 1
  4288. ],
  4289. [
  4290. 6,
  4291. 1
  4292. ],
  4293. [
  4294. 6,
  4295. 1
  4296. ],
  4297. [
  4298. 6,
  4299. 12
  4300. ],
  4301. [
  4302. 6,
  4303. 12
  4304. ],
  4305. [
  4306. 6,
  4307. 12
  4308. ],
  4309. [
  4310. 6,
  4311. 12
  4312. ],
  4313. [
  4314. 6,
  4315. 12
  4316. ],
  4317. [
  4318. 6,
  4319. 12
  4320. ],
  4321. [
  4322. 6,
  4323. 12
  4324. ],
  4325. [
  4326. 6,
  4327. 12
  4328. ],
  4329. [
  4330. 8,
  4331. 53
  4332. ],
  4333. [
  4334. 8,
  4335. 53
  4336. ],
  4337. [
  4338. 8,
  4339. 54
  4340. ],
  4341. [
  4342. 8,
  4343. 54
  4344. ],
  4345. [
  4346. 7,
  4347. 26
  4348. ],
  4349. [
  4350. 7,
  4351. 26
  4352. ],
  4353. [
  4354. 7,
  4355. 26
  4356. ],
  4357. [
  4358. 7,
  4359. 26
  4360. ],
  4361. [
  4362. 8,
  4363. 39
  4364. ],
  4365. [
  4366. 8,
  4367. 39
  4368. ],
  4369. [
  4370. 8,
  4371. 40
  4372. ],
  4373. [
  4374. 8,
  4375. 40
  4376. ],
  4377. [
  4378. 8,
  4379. 41
  4380. ],
  4381. [
  4382. 8,
  4383. 41
  4384. ],
  4385. [
  4386. 8,
  4387. 42
  4388. ],
  4389. [
  4390. 8,
  4391. 42
  4392. ],
  4393. [
  4394. 8,
  4395. 43
  4396. ],
  4397. [
  4398. 8,
  4399. 43
  4400. ],
  4401. [
  4402. 8,
  4403. 44
  4404. ],
  4405. [
  4406. 8,
  4407. 44
  4408. ],
  4409. [
  4410. 7,
  4411. 21
  4412. ],
  4413. [
  4414. 7,
  4415. 21
  4416. ],
  4417. [
  4418. 7,
  4419. 21
  4420. ],
  4421. [
  4422. 7,
  4423. 21
  4424. ],
  4425. [
  4426. 7,
  4427. 28
  4428. ],
  4429. [
  4430. 7,
  4431. 28
  4432. ],
  4433. [
  4434. 7,
  4435. 28
  4436. ],
  4437. [
  4438. 7,
  4439. 28
  4440. ],
  4441. [
  4442. 8,
  4443. 61
  4444. ],
  4445. [
  4446. 8,
  4447. 61
  4448. ],
  4449. [
  4450. 8,
  4451. 62
  4452. ],
  4453. [
  4454. 8,
  4455. 62
  4456. ],
  4457. [
  4458. 8,
  4459. 63
  4460. ],
  4461. [
  4462. 8,
  4463. 63
  4464. ],
  4465. [
  4466. 8,
  4467. 0
  4468. ],
  4469. [
  4470. 8,
  4471. 0
  4472. ],
  4473. [
  4474. 8,
  4475. 320
  4476. ],
  4477. [
  4478. 8,
  4479. 320
  4480. ],
  4481. [
  4482. 8,
  4483. 384
  4484. ],
  4485. [
  4486. 8,
  4487. 384
  4488. ],
  4489. [
  4490. 5,
  4491. 10
  4492. ],
  4493. [
  4494. 5,
  4495. 10
  4496. ],
  4497. [
  4498. 5,
  4499. 10
  4500. ],
  4501. [
  4502. 5,
  4503. 10
  4504. ],
  4505. [
  4506. 5,
  4507. 10
  4508. ],
  4509. [
  4510. 5,
  4511. 10
  4512. ],
  4513. [
  4514. 5,
  4515. 10
  4516. ],
  4517. [
  4518. 5,
  4519. 10
  4520. ],
  4521. [
  4522. 5,
  4523. 10
  4524. ],
  4525. [
  4526. 5,
  4527. 10
  4528. ],
  4529. [
  4530. 5,
  4531. 10
  4532. ],
  4533. [
  4534. 5,
  4535. 10
  4536. ],
  4537. [
  4538. 5,
  4539. 10
  4540. ],
  4541. [
  4542. 5,
  4543. 10
  4544. ],
  4545. [
  4546. 5,
  4547. 10
  4548. ],
  4549. [
  4550. 5,
  4551. 10
  4552. ],
  4553. [
  4554. 5,
  4555. 11
  4556. ],
  4557. [
  4558. 5,
  4559. 11
  4560. ],
  4561. [
  4562. 5,
  4563. 11
  4564. ],
  4565. [
  4566. 5,
  4567. 11
  4568. ],
  4569. [
  4570. 5,
  4571. 11
  4572. ],
  4573. [
  4574. 5,
  4575. 11
  4576. ],
  4577. [
  4578. 5,
  4579. 11
  4580. ],
  4581. [
  4582. 5,
  4583. 11
  4584. ],
  4585. [
  4586. 5,
  4587. 11
  4588. ],
  4589. [
  4590. 5,
  4591. 11
  4592. ],
  4593. [
  4594. 5,
  4595. 11
  4596. ],
  4597. [
  4598. 5,
  4599. 11
  4600. ],
  4601. [
  4602. 5,
  4603. 11
  4604. ],
  4605. [
  4606. 5,
  4607. 11
  4608. ],
  4609. [
  4610. 5,
  4611. 11
  4612. ],
  4613. [
  4614. 5,
  4615. 11
  4616. ],
  4617. [
  4618. 7,
  4619. 27
  4620. ],
  4621. [
  4622. 7,
  4623. 27
  4624. ],
  4625. [
  4626. 7,
  4627. 27
  4628. ],
  4629. [
  4630. 7,
  4631. 27
  4632. ],
  4633. [
  4634. 8,
  4635. 59
  4636. ],
  4637. [
  4638. 8,
  4639. 59
  4640. ],
  4641. [
  4642. 8,
  4643. 60
  4644. ],
  4645. [
  4646. 8,
  4647. 60
  4648. ],
  4649. [
  4650. 9,
  4651. 1472
  4652. ],
  4653. [
  4654. 9,
  4655. 1536
  4656. ],
  4657. [
  4658. 9,
  4659. 1600
  4660. ],
  4661. [
  4662. 9,
  4663. 1728
  4664. ],
  4665. [
  4666. 7,
  4667. 18
  4668. ],
  4669. [
  4670. 7,
  4671. 18
  4672. ],
  4673. [
  4674. 7,
  4675. 18
  4676. ],
  4677. [
  4678. 7,
  4679. 18
  4680. ],
  4681. [
  4682. 7,
  4683. 24
  4684. ],
  4685. [
  4686. 7,
  4687. 24
  4688. ],
  4689. [
  4690. 7,
  4691. 24
  4692. ],
  4693. [
  4694. 7,
  4695. 24
  4696. ],
  4697. [
  4698. 8,
  4699. 49
  4700. ],
  4701. [
  4702. 8,
  4703. 49
  4704. ],
  4705. [
  4706. 8,
  4707. 50
  4708. ],
  4709. [
  4710. 8,
  4711. 50
  4712. ],
  4713. [
  4714. 8,
  4715. 51
  4716. ],
  4717. [
  4718. 8,
  4719. 51
  4720. ],
  4721. [
  4722. 8,
  4723. 52
  4724. ],
  4725. [
  4726. 8,
  4727. 52
  4728. ],
  4729. [
  4730. 7,
  4731. 25
  4732. ],
  4733. [
  4734. 7,
  4735. 25
  4736. ],
  4737. [
  4738. 7,
  4739. 25
  4740. ],
  4741. [
  4742. 7,
  4743. 25
  4744. ],
  4745. [
  4746. 8,
  4747. 55
  4748. ],
  4749. [
  4750. 8,
  4751. 55
  4752. ],
  4753. [
  4754. 8,
  4755. 56
  4756. ],
  4757. [
  4758. 8,
  4759. 56
  4760. ],
  4761. [
  4762. 8,
  4763. 57
  4764. ],
  4765. [
  4766. 8,
  4767. 57
  4768. ],
  4769. [
  4770. 8,
  4771. 58
  4772. ],
  4773. [
  4774. 8,
  4775. 58
  4776. ],
  4777. [
  4778. 6,
  4779. 192
  4780. ],
  4781. [
  4782. 6,
  4783. 192
  4784. ],
  4785. [
  4786. 6,
  4787. 192
  4788. ],
  4789. [
  4790. 6,
  4791. 192
  4792. ],
  4793. [
  4794. 6,
  4795. 192
  4796. ],
  4797. [
  4798. 6,
  4799. 192
  4800. ],
  4801. [
  4802. 6,
  4803. 192
  4804. ],
  4805. [
  4806. 6,
  4807. 192
  4808. ],
  4809. [
  4810. 6,
  4811. 1664
  4812. ],
  4813. [
  4814. 6,
  4815. 1664
  4816. ],
  4817. [
  4818. 6,
  4819. 1664
  4820. ],
  4821. [
  4822. 6,
  4823. 1664
  4824. ],
  4825. [
  4826. 6,
  4827. 1664
  4828. ],
  4829. [
  4830. 6,
  4831. 1664
  4832. ],
  4833. [
  4834. 6,
  4835. 1664
  4836. ],
  4837. [
  4838. 6,
  4839. 1664
  4840. ],
  4841. [
  4842. 8,
  4843. 448
  4844. ],
  4845. [
  4846. 8,
  4847. 448
  4848. ],
  4849. [
  4850. 8,
  4851. 512
  4852. ],
  4853. [
  4854. 8,
  4855. 512
  4856. ],
  4857. [
  4858. 9,
  4859. 704
  4860. ],
  4861. [
  4862. 9,
  4863. 768
  4864. ],
  4865. [
  4866. 8,
  4867. 640
  4868. ],
  4869. [
  4870. 8,
  4871. 640
  4872. ],
  4873. [
  4874. 8,
  4875. 576
  4876. ],
  4877. [
  4878. 8,
  4879. 576
  4880. ],
  4881. [
  4882. 9,
  4883. 832
  4884. ],
  4885. [
  4886. 9,
  4887. 896
  4888. ],
  4889. [
  4890. 9,
  4891. 960
  4892. ],
  4893. [
  4894. 9,
  4895. 1024
  4896. ],
  4897. [
  4898. 9,
  4899. 1088
  4900. ],
  4901. [
  4902. 9,
  4903. 1152
  4904. ],
  4905. [
  4906. 9,
  4907. 1216
  4908. ],
  4909. [
  4910. 9,
  4911. 1280
  4912. ],
  4913. [
  4914. 9,
  4915. 1344
  4916. ],
  4917. [
  4918. 9,
  4919. 1408
  4920. ],
  4921. [
  4922. 7,
  4923. 256
  4924. ],
  4925. [
  4926. 7,
  4927. 256
  4928. ],
  4929. [
  4930. 7,
  4931. 256
  4932. ],
  4933. [
  4934. 7,
  4935. 256
  4936. ],
  4937. [
  4938. 4,
  4939. 2
  4940. ],
  4941. [
  4942. 4,
  4943. 2
  4944. ],
  4945. [
  4946. 4,
  4947. 2
  4948. ],
  4949. [
  4950. 4,
  4951. 2
  4952. ],
  4953. [
  4954. 4,
  4955. 2
  4956. ],
  4957. [
  4958. 4,
  4959. 2
  4960. ],
  4961. [
  4962. 4,
  4963. 2
  4964. ],
  4965. [
  4966. 4,
  4967. 2
  4968. ],
  4969. [
  4970. 4,
  4971. 2
  4972. ],
  4973. [
  4974. 4,
  4975. 2
  4976. ],
  4977. [
  4978. 4,
  4979. 2
  4980. ],
  4981. [
  4982. 4,
  4983. 2
  4984. ],
  4985. [
  4986. 4,
  4987. 2
  4988. ],
  4989. [
  4990. 4,
  4991. 2
  4992. ],
  4993. [
  4994. 4,
  4995. 2
  4996. ],
  4997. [
  4998. 4,
  4999. 2
  5000. ],
  5001. [
  5002. 4,
  5003. 2
  5004. ],
  5005. [
  5006. 4,
  5007. 2
  5008. ],
  5009. [
  5010. 4,
  5011. 2
  5012. ],
  5013. [
  5014. 4,
  5015. 2
  5016. ],
  5017. [
  5018. 4,
  5019. 2
  5020. ],
  5021. [
  5022. 4,
  5023. 2
  5024. ],
  5025. [
  5026. 4,
  5027. 2
  5028. ],
  5029. [
  5030. 4,
  5031. 2
  5032. ],
  5033. [
  5034. 4,
  5035. 2
  5036. ],
  5037. [
  5038. 4,
  5039. 2
  5040. ],
  5041. [
  5042. 4,
  5043. 2
  5044. ],
  5045. [
  5046. 4,
  5047. 2
  5048. ],
  5049. [
  5050. 4,
  5051. 2
  5052. ],
  5053. [
  5054. 4,
  5055. 2
  5056. ],
  5057. [
  5058. 4,
  5059. 2
  5060. ],
  5061. [
  5062. 4,
  5063. 2
  5064. ],
  5065. [
  5066. 4,
  5067. 3
  5068. ],
  5069. [
  5070. 4,
  5071. 3
  5072. ],
  5073. [
  5074. 4,
  5075. 3
  5076. ],
  5077. [
  5078. 4,
  5079. 3
  5080. ],
  5081. [
  5082. 4,
  5083. 3
  5084. ],
  5085. [
  5086. 4,
  5087. 3
  5088. ],
  5089. [
  5090. 4,
  5091. 3
  5092. ],
  5093. [
  5094. 4,
  5095. 3
  5096. ],
  5097. [
  5098. 4,
  5099. 3
  5100. ],
  5101. [
  5102. 4,
  5103. 3
  5104. ],
  5105. [
  5106. 4,
  5107. 3
  5108. ],
  5109. [
  5110. 4,
  5111. 3
  5112. ],
  5113. [
  5114. 4,
  5115. 3
  5116. ],
  5117. [
  5118. 4,
  5119. 3
  5120. ],
  5121. [
  5122. 4,
  5123. 3
  5124. ],
  5125. [
  5126. 4,
  5127. 3
  5128. ],
  5129. [
  5130. 4,
  5131. 3
  5132. ],
  5133. [
  5134. 4,
  5135. 3
  5136. ],
  5137. [
  5138. 4,
  5139. 3
  5140. ],
  5141. [
  5142. 4,
  5143. 3
  5144. ],
  5145. [
  5146. 4,
  5147. 3
  5148. ],
  5149. [
  5150. 4,
  5151. 3
  5152. ],
  5153. [
  5154. 4,
  5155. 3
  5156. ],
  5157. [
  5158. 4,
  5159. 3
  5160. ],
  5161. [
  5162. 4,
  5163. 3
  5164. ],
  5165. [
  5166. 4,
  5167. 3
  5168. ],
  5169. [
  5170. 4,
  5171. 3
  5172. ],
  5173. [
  5174. 4,
  5175. 3
  5176. ],
  5177. [
  5178. 4,
  5179. 3
  5180. ],
  5181. [
  5182. 4,
  5183. 3
  5184. ],
  5185. [
  5186. 4,
  5187. 3
  5188. ],
  5189. [
  5190. 4,
  5191. 3
  5192. ],
  5193. [
  5194. 5,
  5195. 128
  5196. ],
  5197. [
  5198. 5,
  5199. 128
  5200. ],
  5201. [
  5202. 5,
  5203. 128
  5204. ],
  5205. [
  5206. 5,
  5207. 128
  5208. ],
  5209. [
  5210. 5,
  5211. 128
  5212. ],
  5213. [
  5214. 5,
  5215. 128
  5216. ],
  5217. [
  5218. 5,
  5219. 128
  5220. ],
  5221. [
  5222. 5,
  5223. 128
  5224. ],
  5225. [
  5226. 5,
  5227. 128
  5228. ],
  5229. [
  5230. 5,
  5231. 128
  5232. ],
  5233. [
  5234. 5,
  5235. 128
  5236. ],
  5237. [
  5238. 5,
  5239. 128
  5240. ],
  5241. [
  5242. 5,
  5243. 128
  5244. ],
  5245. [
  5246. 5,
  5247. 128
  5248. ],
  5249. [
  5250. 5,
  5251. 128
  5252. ],
  5253. [
  5254. 5,
  5255. 128
  5256. ],
  5257. [
  5258. 5,
  5259. 8
  5260. ],
  5261. [
  5262. 5,
  5263. 8
  5264. ],
  5265. [
  5266. 5,
  5267. 8
  5268. ],
  5269. [
  5270. 5,
  5271. 8
  5272. ],
  5273. [
  5274. 5,
  5275. 8
  5276. ],
  5277. [
  5278. 5,
  5279. 8
  5280. ],
  5281. [
  5282. 5,
  5283. 8
  5284. ],
  5285. [
  5286. 5,
  5287. 8
  5288. ],
  5289. [
  5290. 5,
  5291. 8
  5292. ],
  5293. [
  5294. 5,
  5295. 8
  5296. ],
  5297. [
  5298. 5,
  5299. 8
  5300. ],
  5301. [
  5302. 5,
  5303. 8
  5304. ],
  5305. [
  5306. 5,
  5307. 8
  5308. ],
  5309. [
  5310. 5,
  5311. 8
  5312. ],
  5313. [
  5314. 5,
  5315. 8
  5316. ],
  5317. [
  5318. 5,
  5319. 8
  5320. ],
  5321. [
  5322. 5,
  5323. 9
  5324. ],
  5325. [
  5326. 5,
  5327. 9
  5328. ],
  5329. [
  5330. 5,
  5331. 9
  5332. ],
  5333. [
  5334. 5,
  5335. 9
  5336. ],
  5337. [
  5338. 5,
  5339. 9
  5340. ],
  5341. [
  5342. 5,
  5343. 9
  5344. ],
  5345. [
  5346. 5,
  5347. 9
  5348. ],
  5349. [
  5350. 5,
  5351. 9
  5352. ],
  5353. [
  5354. 5,
  5355. 9
  5356. ],
  5357. [
  5358. 5,
  5359. 9
  5360. ],
  5361. [
  5362. 5,
  5363. 9
  5364. ],
  5365. [
  5366. 5,
  5367. 9
  5368. ],
  5369. [
  5370. 5,
  5371. 9
  5372. ],
  5373. [
  5374. 5,
  5375. 9
  5376. ],
  5377. [
  5378. 5,
  5379. 9
  5380. ],
  5381. [
  5382. 5,
  5383. 9
  5384. ],
  5385. [
  5386. 6,
  5387. 16
  5388. ],
  5389. [
  5390. 6,
  5391. 16
  5392. ],
  5393. [
  5394. 6,
  5395. 16
  5396. ],
  5397. [
  5398. 6,
  5399. 16
  5400. ],
  5401. [
  5402. 6,
  5403. 16
  5404. ],
  5405. [
  5406. 6,
  5407. 16
  5408. ],
  5409. [
  5410. 6,
  5411. 16
  5412. ],
  5413. [
  5414. 6,
  5415. 16
  5416. ],
  5417. [
  5418. 6,
  5419. 17
  5420. ],
  5421. [
  5422. 6,
  5423. 17
  5424. ],
  5425. [
  5426. 6,
  5427. 17
  5428. ],
  5429. [
  5430. 6,
  5431. 17
  5432. ],
  5433. [
  5434. 6,
  5435. 17
  5436. ],
  5437. [
  5438. 6,
  5439. 17
  5440. ],
  5441. [
  5442. 6,
  5443. 17
  5444. ],
  5445. [
  5446. 6,
  5447. 17
  5448. ],
  5449. [
  5450. 4,
  5451. 4
  5452. ],
  5453. [
  5454. 4,
  5455. 4
  5456. ],
  5457. [
  5458. 4,
  5459. 4
  5460. ],
  5461. [
  5462. 4,
  5463. 4
  5464. ],
  5465. [
  5466. 4,
  5467. 4
  5468. ],
  5469. [
  5470. 4,
  5471. 4
  5472. ],
  5473. [
  5474. 4,
  5475. 4
  5476. ],
  5477. [
  5478. 4,
  5479. 4
  5480. ],
  5481. [
  5482. 4,
  5483. 4
  5484. ],
  5485. [
  5486. 4,
  5487. 4
  5488. ],
  5489. [
  5490. 4,
  5491. 4
  5492. ],
  5493. [
  5494. 4,
  5495. 4
  5496. ],
  5497. [
  5498. 4,
  5499. 4
  5500. ],
  5501. [
  5502. 4,
  5503. 4
  5504. ],
  5505. [
  5506. 4,
  5507. 4
  5508. ],
  5509. [
  5510. 4,
  5511. 4
  5512. ],
  5513. [
  5514. 4,
  5515. 4
  5516. ],
  5517. [
  5518. 4,
  5519. 4
  5520. ],
  5521. [
  5522. 4,
  5523. 4
  5524. ],
  5525. [
  5526. 4,
  5527. 4
  5528. ],
  5529. [
  5530. 4,
  5531. 4
  5532. ],
  5533. [
  5534. 4,
  5535. 4
  5536. ],
  5537. [
  5538. 4,
  5539. 4
  5540. ],
  5541. [
  5542. 4,
  5543. 4
  5544. ],
  5545. [
  5546. 4,
  5547. 4
  5548. ],
  5549. [
  5550. 4,
  5551. 4
  5552. ],
  5553. [
  5554. 4,
  5555. 4
  5556. ],
  5557. [
  5558. 4,
  5559. 4
  5560. ],
  5561. [
  5562. 4,
  5563. 4
  5564. ],
  5565. [
  5566. 4,
  5567. 4
  5568. ],
  5569. [
  5570. 4,
  5571. 4
  5572. ],
  5573. [
  5574. 4,
  5575. 4
  5576. ],
  5577. [
  5578. 4,
  5579. 5
  5580. ],
  5581. [
  5582. 4,
  5583. 5
  5584. ],
  5585. [
  5586. 4,
  5587. 5
  5588. ],
  5589. [
  5590. 4,
  5591. 5
  5592. ],
  5593. [
  5594. 4,
  5595. 5
  5596. ],
  5597. [
  5598. 4,
  5599. 5
  5600. ],
  5601. [
  5602. 4,
  5603. 5
  5604. ],
  5605. [
  5606. 4,
  5607. 5
  5608. ],
  5609. [
  5610. 4,
  5611. 5
  5612. ],
  5613. [
  5614. 4,
  5615. 5
  5616. ],
  5617. [
  5618. 4,
  5619. 5
  5620. ],
  5621. [
  5622. 4,
  5623. 5
  5624. ],
  5625. [
  5626. 4,
  5627. 5
  5628. ],
  5629. [
  5630. 4,
  5631. 5
  5632. ],
  5633. [
  5634. 4,
  5635. 5
  5636. ],
  5637. [
  5638. 4,
  5639. 5
  5640. ],
  5641. [
  5642. 4,
  5643. 5
  5644. ],
  5645. [
  5646. 4,
  5647. 5
  5648. ],
  5649. [
  5650. 4,
  5651. 5
  5652. ],
  5653. [
  5654. 4,
  5655. 5
  5656. ],
  5657. [
  5658. 4,
  5659. 5
  5660. ],
  5661. [
  5662. 4,
  5663. 5
  5664. ],
  5665. [
  5666. 4,
  5667. 5
  5668. ],
  5669. [
  5670. 4,
  5671. 5
  5672. ],
  5673. [
  5674. 4,
  5675. 5
  5676. ],
  5677. [
  5678. 4,
  5679. 5
  5680. ],
  5681. [
  5682. 4,
  5683. 5
  5684. ],
  5685. [
  5686. 4,
  5687. 5
  5688. ],
  5689. [
  5690. 4,
  5691. 5
  5692. ],
  5693. [
  5694. 4,
  5695. 5
  5696. ],
  5697. [
  5698. 4,
  5699. 5
  5700. ],
  5701. [
  5702. 4,
  5703. 5
  5704. ],
  5705. [
  5706. 6,
  5707. 14
  5708. ],
  5709. [
  5710. 6,
  5711. 14
  5712. ],
  5713. [
  5714. 6,
  5715. 14
  5716. ],
  5717. [
  5718. 6,
  5719. 14
  5720. ],
  5721. [
  5722. 6,
  5723. 14
  5724. ],
  5725. [
  5726. 6,
  5727. 14
  5728. ],
  5729. [
  5730. 6,
  5731. 14
  5732. ],
  5733. [
  5734. 6,
  5735. 14
  5736. ],
  5737. [
  5738. 6,
  5739. 15
  5740. ],
  5741. [
  5742. 6,
  5743. 15
  5744. ],
  5745. [
  5746. 6,
  5747. 15
  5748. ],
  5749. [
  5750. 6,
  5751. 15
  5752. ],
  5753. [
  5754. 6,
  5755. 15
  5756. ],
  5757. [
  5758. 6,
  5759. 15
  5760. ],
  5761. [
  5762. 6,
  5763. 15
  5764. ],
  5765. [
  5766. 6,
  5767. 15
  5768. ],
  5769. [
  5770. 5,
  5771. 64
  5772. ],
  5773. [
  5774. 5,
  5775. 64
  5776. ],
  5777. [
  5778. 5,
  5779. 64
  5780. ],
  5781. [
  5782. 5,
  5783. 64
  5784. ],
  5785. [
  5786. 5,
  5787. 64
  5788. ],
  5789. [
  5790. 5,
  5791. 64
  5792. ],
  5793. [
  5794. 5,
  5795. 64
  5796. ],
  5797. [
  5798. 5,
  5799. 64
  5800. ],
  5801. [
  5802. 5,
  5803. 64
  5804. ],
  5805. [
  5806. 5,
  5807. 64
  5808. ],
  5809. [
  5810. 5,
  5811. 64
  5812. ],
  5813. [
  5814. 5,
  5815. 64
  5816. ],
  5817. [
  5818. 5,
  5819. 64
  5820. ],
  5821. [
  5822. 5,
  5823. 64
  5824. ],
  5825. [
  5826. 5,
  5827. 64
  5828. ],
  5829. [
  5830. 5,
  5831. 64
  5832. ],
  5833. [
  5834. 4,
  5835. 6
  5836. ],
  5837. [
  5838. 4,
  5839. 6
  5840. ],
  5841. [
  5842. 4,
  5843. 6
  5844. ],
  5845. [
  5846. 4,
  5847. 6
  5848. ],
  5849. [
  5850. 4,
  5851. 6
  5852. ],
  5853. [
  5854. 4,
  5855. 6
  5856. ],
  5857. [
  5858. 4,
  5859. 6
  5860. ],
  5861. [
  5862. 4,
  5863. 6
  5864. ],
  5865. [
  5866. 4,
  5867. 6
  5868. ],
  5869. [
  5870. 4,
  5871. 6
  5872. ],
  5873. [
  5874. 4,
  5875. 6
  5876. ],
  5877. [
  5878. 4,
  5879. 6
  5880. ],
  5881. [
  5882. 4,
  5883. 6
  5884. ],
  5885. [
  5886. 4,
  5887. 6
  5888. ],
  5889. [
  5890. 4,
  5891. 6
  5892. ],
  5893. [
  5894. 4,
  5895. 6
  5896. ],
  5897. [
  5898. 4,
  5899. 6
  5900. ],
  5901. [
  5902. 4,
  5903. 6
  5904. ],
  5905. [
  5906. 4,
  5907. 6
  5908. ],
  5909. [
  5910. 4,
  5911. 6
  5912. ],
  5913. [
  5914. 4,
  5915. 6
  5916. ],
  5917. [
  5918. 4,
  5919. 6
  5920. ],
  5921. [
  5922. 4,
  5923. 6
  5924. ],
  5925. [
  5926. 4,
  5927. 6
  5928. ],
  5929. [
  5930. 4,
  5931. 6
  5932. ],
  5933. [
  5934. 4,
  5935. 6
  5936. ],
  5937. [
  5938. 4,
  5939. 6
  5940. ],
  5941. [
  5942. 4,
  5943. 6
  5944. ],
  5945. [
  5946. 4,
  5947. 6
  5948. ],
  5949. [
  5950. 4,
  5951. 6
  5952. ],
  5953. [
  5954. 4,
  5955. 6
  5956. ],
  5957. [
  5958. 4,
  5959. 6
  5960. ],
  5961. [
  5962. 4,
  5963. 7
  5964. ],
  5965. [
  5966. 4,
  5967. 7
  5968. ],
  5969. [
  5970. 4,
  5971. 7
  5972. ],
  5973. [
  5974. 4,
  5975. 7
  5976. ],
  5977. [
  5978. 4,
  5979. 7
  5980. ],
  5981. [
  5982. 4,
  5983. 7
  5984. ],
  5985. [
  5986. 4,
  5987. 7
  5988. ],
  5989. [
  5990. 4,
  5991. 7
  5992. ],
  5993. [
  5994. 4,
  5995. 7
  5996. ],
  5997. [
  5998. 4,
  5999. 7
  6000. ],
  6001. [
  6002. 4,
  6003. 7
  6004. ],
  6005. [
  6006. 4,
  6007. 7
  6008. ],
  6009. [
  6010. 4,
  6011. 7
  6012. ],
  6013. [
  6014. 4,
  6015. 7
  6016. ],
  6017. [
  6018. 4,
  6019. 7
  6020. ],
  6021. [
  6022. 4,
  6023. 7
  6024. ],
  6025. [
  6026. 4,
  6027. 7
  6028. ],
  6029. [
  6030. 4,
  6031. 7
  6032. ],
  6033. [
  6034. 4,
  6035. 7
  6036. ],
  6037. [
  6038. 4,
  6039. 7
  6040. ],
  6041. [
  6042. 4,
  6043. 7
  6044. ],
  6045. [
  6046. 4,
  6047. 7
  6048. ],
  6049. [
  6050. 4,
  6051. 7
  6052. ],
  6053. [
  6054. 4,
  6055. 7
  6056. ],
  6057. [
  6058. 4,
  6059. 7
  6060. ],
  6061. [
  6062. 4,
  6063. 7
  6064. ],
  6065. [
  6066. 4,
  6067. 7
  6068. ],
  6069. [
  6070. 4,
  6071. 7
  6072. ],
  6073. [
  6074. 4,
  6075. 7
  6076. ],
  6077. [
  6078. 4,
  6079. 7
  6080. ],
  6081. [
  6082. 4,
  6083. 7
  6084. ],
  6085. [
  6086. 4,
  6087. 7
  6088. ]
  6089. ];
  6090. var blackTable1 = [
  6091. [
  6092. -1,
  6093. -1
  6094. ],
  6095. [
  6096. -1,
  6097. -1
  6098. ],
  6099. [
  6100. 12,
  6101. ccittEOL
  6102. ],
  6103. [
  6104. 12,
  6105. ccittEOL
  6106. ],
  6107. [
  6108. -1,
  6109. -1
  6110. ],
  6111. [
  6112. -1,
  6113. -1
  6114. ],
  6115. [
  6116. -1,
  6117. -1
  6118. ],
  6119. [
  6120. -1,
  6121. -1
  6122. ],
  6123. [
  6124. -1,
  6125. -1
  6126. ],
  6127. [
  6128. -1,
  6129. -1
  6130. ],
  6131. [
  6132. -1,
  6133. -1
  6134. ],
  6135. [
  6136. -1,
  6137. -1
  6138. ],
  6139. [
  6140. -1,
  6141. -1
  6142. ],
  6143. [
  6144. -1,
  6145. -1
  6146. ],
  6147. [
  6148. -1,
  6149. -1
  6150. ],
  6151. [
  6152. -1,
  6153. -1
  6154. ],
  6155. [
  6156. -1,
  6157. -1
  6158. ],
  6159. [
  6160. -1,
  6161. -1
  6162. ],
  6163. [
  6164. -1,
  6165. -1
  6166. ],
  6167. [
  6168. -1,
  6169. -1
  6170. ],
  6171. [
  6172. -1,
  6173. -1
  6174. ],
  6175. [
  6176. -1,
  6177. -1
  6178. ],
  6179. [
  6180. -1,
  6181. -1
  6182. ],
  6183. [
  6184. -1,
  6185. -1
  6186. ],
  6187. [
  6188. -1,
  6189. -1
  6190. ],
  6191. [
  6192. -1,
  6193. -1
  6194. ],
  6195. [
  6196. -1,
  6197. -1
  6198. ],
  6199. [
  6200. -1,
  6201. -1
  6202. ],
  6203. [
  6204. -1,
  6205. -1
  6206. ],
  6207. [
  6208. -1,
  6209. -1
  6210. ],
  6211. [
  6212. -1,
  6213. -1
  6214. ],
  6215. [
  6216. -1,
  6217. -1
  6218. ],
  6219. [
  6220. 11,
  6221. 1792
  6222. ],
  6223. [
  6224. 11,
  6225. 1792
  6226. ],
  6227. [
  6228. 11,
  6229. 1792
  6230. ],
  6231. [
  6232. 11,
  6233. 1792
  6234. ],
  6235. [
  6236. 12,
  6237. 1984
  6238. ],
  6239. [
  6240. 12,
  6241. 1984
  6242. ],
  6243. [
  6244. 12,
  6245. 2048
  6246. ],
  6247. [
  6248. 12,
  6249. 2048
  6250. ],
  6251. [
  6252. 12,
  6253. 2112
  6254. ],
  6255. [
  6256. 12,
  6257. 2112
  6258. ],
  6259. [
  6260. 12,
  6261. 2176
  6262. ],
  6263. [
  6264. 12,
  6265. 2176
  6266. ],
  6267. [
  6268. 12,
  6269. 2240
  6270. ],
  6271. [
  6272. 12,
  6273. 2240
  6274. ],
  6275. [
  6276. 12,
  6277. 2304
  6278. ],
  6279. [
  6280. 12,
  6281. 2304
  6282. ],
  6283. [
  6284. 11,
  6285. 1856
  6286. ],
  6287. [
  6288. 11,
  6289. 1856
  6290. ],
  6291. [
  6292. 11,
  6293. 1856
  6294. ],
  6295. [
  6296. 11,
  6297. 1856
  6298. ],
  6299. [
  6300. 11,
  6301. 1920
  6302. ],
  6303. [
  6304. 11,
  6305. 1920
  6306. ],
  6307. [
  6308. 11,
  6309. 1920
  6310. ],
  6311. [
  6312. 11,
  6313. 1920
  6314. ],
  6315. [
  6316. 12,
  6317. 2368
  6318. ],
  6319. [
  6320. 12,
  6321. 2368
  6322. ],
  6323. [
  6324. 12,
  6325. 2432
  6326. ],
  6327. [
  6328. 12,
  6329. 2432
  6330. ],
  6331. [
  6332. 12,
  6333. 2496
  6334. ],
  6335. [
  6336. 12,
  6337. 2496
  6338. ],
  6339. [
  6340. 12,
  6341. 2560
  6342. ],
  6343. [
  6344. 12,
  6345. 2560
  6346. ],
  6347. [
  6348. 10,
  6349. 18
  6350. ],
  6351. [
  6352. 10,
  6353. 18
  6354. ],
  6355. [
  6356. 10,
  6357. 18
  6358. ],
  6359. [
  6360. 10,
  6361. 18
  6362. ],
  6363. [
  6364. 10,
  6365. 18
  6366. ],
  6367. [
  6368. 10,
  6369. 18
  6370. ],
  6371. [
  6372. 10,
  6373. 18
  6374. ],
  6375. [
  6376. 10,
  6377. 18
  6378. ],
  6379. [
  6380. 12,
  6381. 52
  6382. ],
  6383. [
  6384. 12,
  6385. 52
  6386. ],
  6387. [
  6388. 13,
  6389. 640
  6390. ],
  6391. [
  6392. 13,
  6393. 704
  6394. ],
  6395. [
  6396. 13,
  6397. 768
  6398. ],
  6399. [
  6400. 13,
  6401. 832
  6402. ],
  6403. [
  6404. 12,
  6405. 55
  6406. ],
  6407. [
  6408. 12,
  6409. 55
  6410. ],
  6411. [
  6412. 12,
  6413. 56
  6414. ],
  6415. [
  6416. 12,
  6417. 56
  6418. ],
  6419. [
  6420. 13,
  6421. 1280
  6422. ],
  6423. [
  6424. 13,
  6425. 1344
  6426. ],
  6427. [
  6428. 13,
  6429. 1408
  6430. ],
  6431. [
  6432. 13,
  6433. 1472
  6434. ],
  6435. [
  6436. 12,
  6437. 59
  6438. ],
  6439. [
  6440. 12,
  6441. 59
  6442. ],
  6443. [
  6444. 12,
  6445. 60
  6446. ],
  6447. [
  6448. 12,
  6449. 60
  6450. ],
  6451. [
  6452. 13,
  6453. 1536
  6454. ],
  6455. [
  6456. 13,
  6457. 1600
  6458. ],
  6459. [
  6460. 11,
  6461. 24
  6462. ],
  6463. [
  6464. 11,
  6465. 24
  6466. ],
  6467. [
  6468. 11,
  6469. 24
  6470. ],
  6471. [
  6472. 11,
  6473. 24
  6474. ],
  6475. [
  6476. 11,
  6477. 25
  6478. ],
  6479. [
  6480. 11,
  6481. 25
  6482. ],
  6483. [
  6484. 11,
  6485. 25
  6486. ],
  6487. [
  6488. 11,
  6489. 25
  6490. ],
  6491. [
  6492. 13,
  6493. 1664
  6494. ],
  6495. [
  6496. 13,
  6497. 1728
  6498. ],
  6499. [
  6500. 12,
  6501. 320
  6502. ],
  6503. [
  6504. 12,
  6505. 320
  6506. ],
  6507. [
  6508. 12,
  6509. 384
  6510. ],
  6511. [
  6512. 12,
  6513. 384
  6514. ],
  6515. [
  6516. 12,
  6517. 448
  6518. ],
  6519. [
  6520. 12,
  6521. 448
  6522. ],
  6523. [
  6524. 13,
  6525. 512
  6526. ],
  6527. [
  6528. 13,
  6529. 576
  6530. ],
  6531. [
  6532. 12,
  6533. 53
  6534. ],
  6535. [
  6536. 12,
  6537. 53
  6538. ],
  6539. [
  6540. 12,
  6541. 54
  6542. ],
  6543. [
  6544. 12,
  6545. 54
  6546. ],
  6547. [
  6548. 13,
  6549. 896
  6550. ],
  6551. [
  6552. 13,
  6553. 960
  6554. ],
  6555. [
  6556. 13,
  6557. 1024
  6558. ],
  6559. [
  6560. 13,
  6561. 1088
  6562. ],
  6563. [
  6564. 13,
  6565. 1152
  6566. ],
  6567. [
  6568. 13,
  6569. 1216
  6570. ],
  6571. [
  6572. 10,
  6573. 64
  6574. ],
  6575. [
  6576. 10,
  6577. 64
  6578. ],
  6579. [
  6580. 10,
  6581. 64
  6582. ],
  6583. [
  6584. 10,
  6585. 64
  6586. ],
  6587. [
  6588. 10,
  6589. 64
  6590. ],
  6591. [
  6592. 10,
  6593. 64
  6594. ],
  6595. [
  6596. 10,
  6597. 64
  6598. ],
  6599. [
  6600. 10,
  6601. 64
  6602. ]
  6603. ];
  6604. var blackTable2 = [
  6605. [
  6606. 8,
  6607. 13
  6608. ],
  6609. [
  6610. 8,
  6611. 13
  6612. ],
  6613. [
  6614. 8,
  6615. 13
  6616. ],
  6617. [
  6618. 8,
  6619. 13
  6620. ],
  6621. [
  6622. 8,
  6623. 13
  6624. ],
  6625. [
  6626. 8,
  6627. 13
  6628. ],
  6629. [
  6630. 8,
  6631. 13
  6632. ],
  6633. [
  6634. 8,
  6635. 13
  6636. ],
  6637. [
  6638. 8,
  6639. 13
  6640. ],
  6641. [
  6642. 8,
  6643. 13
  6644. ],
  6645. [
  6646. 8,
  6647. 13
  6648. ],
  6649. [
  6650. 8,
  6651. 13
  6652. ],
  6653. [
  6654. 8,
  6655. 13
  6656. ],
  6657. [
  6658. 8,
  6659. 13
  6660. ],
  6661. [
  6662. 8,
  6663. 13
  6664. ],
  6665. [
  6666. 8,
  6667. 13
  6668. ],
  6669. [
  6670. 11,
  6671. 23
  6672. ],
  6673. [
  6674. 11,
  6675. 23
  6676. ],
  6677. [
  6678. 12,
  6679. 50
  6680. ],
  6681. [
  6682. 12,
  6683. 51
  6684. ],
  6685. [
  6686. 12,
  6687. 44
  6688. ],
  6689. [
  6690. 12,
  6691. 45
  6692. ],
  6693. [
  6694. 12,
  6695. 46
  6696. ],
  6697. [
  6698. 12,
  6699. 47
  6700. ],
  6701. [
  6702. 12,
  6703. 57
  6704. ],
  6705. [
  6706. 12,
  6707. 58
  6708. ],
  6709. [
  6710. 12,
  6711. 61
  6712. ],
  6713. [
  6714. 12,
  6715. 256
  6716. ],
  6717. [
  6718. 10,
  6719. 16
  6720. ],
  6721. [
  6722. 10,
  6723. 16
  6724. ],
  6725. [
  6726. 10,
  6727. 16
  6728. ],
  6729. [
  6730. 10,
  6731. 16
  6732. ],
  6733. [
  6734. 10,
  6735. 17
  6736. ],
  6737. [
  6738. 10,
  6739. 17
  6740. ],
  6741. [
  6742. 10,
  6743. 17
  6744. ],
  6745. [
  6746. 10,
  6747. 17
  6748. ],
  6749. [
  6750. 12,
  6751. 48
  6752. ],
  6753. [
  6754. 12,
  6755. 49
  6756. ],
  6757. [
  6758. 12,
  6759. 62
  6760. ],
  6761. [
  6762. 12,
  6763. 63
  6764. ],
  6765. [
  6766. 12,
  6767. 30
  6768. ],
  6769. [
  6770. 12,
  6771. 31
  6772. ],
  6773. [
  6774. 12,
  6775. 32
  6776. ],
  6777. [
  6778. 12,
  6779. 33
  6780. ],
  6781. [
  6782. 12,
  6783. 40
  6784. ],
  6785. [
  6786. 12,
  6787. 41
  6788. ],
  6789. [
  6790. 11,
  6791. 22
  6792. ],
  6793. [
  6794. 11,
  6795. 22
  6796. ],
  6797. [
  6798. 8,
  6799. 14
  6800. ],
  6801. [
  6802. 8,
  6803. 14
  6804. ],
  6805. [
  6806. 8,
  6807. 14
  6808. ],
  6809. [
  6810. 8,
  6811. 14
  6812. ],
  6813. [
  6814. 8,
  6815. 14
  6816. ],
  6817. [
  6818. 8,
  6819. 14
  6820. ],
  6821. [
  6822. 8,
  6823. 14
  6824. ],
  6825. [
  6826. 8,
  6827. 14
  6828. ],
  6829. [
  6830. 8,
  6831. 14
  6832. ],
  6833. [
  6834. 8,
  6835. 14
  6836. ],
  6837. [
  6838. 8,
  6839. 14
  6840. ],
  6841. [
  6842. 8,
  6843. 14
  6844. ],
  6845. [
  6846. 8,
  6847. 14
  6848. ],
  6849. [
  6850. 8,
  6851. 14
  6852. ],
  6853. [
  6854. 8,
  6855. 14
  6856. ],
  6857. [
  6858. 8,
  6859. 14
  6860. ],
  6861. [
  6862. 7,
  6863. 10
  6864. ],
  6865. [
  6866. 7,
  6867. 10
  6868. ],
  6869. [
  6870. 7,
  6871. 10
  6872. ],
  6873. [
  6874. 7,
  6875. 10
  6876. ],
  6877. [
  6878. 7,
  6879. 10
  6880. ],
  6881. [
  6882. 7,
  6883. 10
  6884. ],
  6885. [
  6886. 7,
  6887. 10
  6888. ],
  6889. [
  6890. 7,
  6891. 10
  6892. ],
  6893. [
  6894. 7,
  6895. 10
  6896. ],
  6897. [
  6898. 7,
  6899. 10
  6900. ],
  6901. [
  6902. 7,
  6903. 10
  6904. ],
  6905. [
  6906. 7,
  6907. 10
  6908. ],
  6909. [
  6910. 7,
  6911. 10
  6912. ],
  6913. [
  6914. 7,
  6915. 10
  6916. ],
  6917. [
  6918. 7,
  6919. 10
  6920. ],
  6921. [
  6922. 7,
  6923. 10
  6924. ],
  6925. [
  6926. 7,
  6927. 10
  6928. ],
  6929. [
  6930. 7,
  6931. 10
  6932. ],
  6933. [
  6934. 7,
  6935. 10
  6936. ],
  6937. [
  6938. 7,
  6939. 10
  6940. ],
  6941. [
  6942. 7,
  6943. 10
  6944. ],
  6945. [
  6946. 7,
  6947. 10
  6948. ],
  6949. [
  6950. 7,
  6951. 10
  6952. ],
  6953. [
  6954. 7,
  6955. 10
  6956. ],
  6957. [
  6958. 7,
  6959. 10
  6960. ],
  6961. [
  6962. 7,
  6963. 10
  6964. ],
  6965. [
  6966. 7,
  6967. 10
  6968. ],
  6969. [
  6970. 7,
  6971. 10
  6972. ],
  6973. [
  6974. 7,
  6975. 10
  6976. ],
  6977. [
  6978. 7,
  6979. 10
  6980. ],
  6981. [
  6982. 7,
  6983. 10
  6984. ],
  6985. [
  6986. 7,
  6987. 10
  6988. ],
  6989. [
  6990. 7,
  6991. 11
  6992. ],
  6993. [
  6994. 7,
  6995. 11
  6996. ],
  6997. [
  6998. 7,
  6999. 11
  7000. ],
  7001. [
  7002. 7,
  7003. 11
  7004. ],
  7005. [
  7006. 7,
  7007. 11
  7008. ],
  7009. [
  7010. 7,
  7011. 11
  7012. ],
  7013. [
  7014. 7,
  7015. 11
  7016. ],
  7017. [
  7018. 7,
  7019. 11
  7020. ],
  7021. [
  7022. 7,
  7023. 11
  7024. ],
  7025. [
  7026. 7,
  7027. 11
  7028. ],
  7029. [
  7030. 7,
  7031. 11
  7032. ],
  7033. [
  7034. 7,
  7035. 11
  7036. ],
  7037. [
  7038. 7,
  7039. 11
  7040. ],
  7041. [
  7042. 7,
  7043. 11
  7044. ],
  7045. [
  7046. 7,
  7047. 11
  7048. ],
  7049. [
  7050. 7,
  7051. 11
  7052. ],
  7053. [
  7054. 7,
  7055. 11
  7056. ],
  7057. [
  7058. 7,
  7059. 11
  7060. ],
  7061. [
  7062. 7,
  7063. 11
  7064. ],
  7065. [
  7066. 7,
  7067. 11
  7068. ],
  7069. [
  7070. 7,
  7071. 11
  7072. ],
  7073. [
  7074. 7,
  7075. 11
  7076. ],
  7077. [
  7078. 7,
  7079. 11
  7080. ],
  7081. [
  7082. 7,
  7083. 11
  7084. ],
  7085. [
  7086. 7,
  7087. 11
  7088. ],
  7089. [
  7090. 7,
  7091. 11
  7092. ],
  7093. [
  7094. 7,
  7095. 11
  7096. ],
  7097. [
  7098. 7,
  7099. 11
  7100. ],
  7101. [
  7102. 7,
  7103. 11
  7104. ],
  7105. [
  7106. 7,
  7107. 11
  7108. ],
  7109. [
  7110. 7,
  7111. 11
  7112. ],
  7113. [
  7114. 7,
  7115. 11
  7116. ],
  7117. [
  7118. 9,
  7119. 15
  7120. ],
  7121. [
  7122. 9,
  7123. 15
  7124. ],
  7125. [
  7126. 9,
  7127. 15
  7128. ],
  7129. [
  7130. 9,
  7131. 15
  7132. ],
  7133. [
  7134. 9,
  7135. 15
  7136. ],
  7137. [
  7138. 9,
  7139. 15
  7140. ],
  7141. [
  7142. 9,
  7143. 15
  7144. ],
  7145. [
  7146. 9,
  7147. 15
  7148. ],
  7149. [
  7150. 12,
  7151. 128
  7152. ],
  7153. [
  7154. 12,
  7155. 192
  7156. ],
  7157. [
  7158. 12,
  7159. 26
  7160. ],
  7161. [
  7162. 12,
  7163. 27
  7164. ],
  7165. [
  7166. 12,
  7167. 28
  7168. ],
  7169. [
  7170. 12,
  7171. 29
  7172. ],
  7173. [
  7174. 11,
  7175. 19
  7176. ],
  7177. [
  7178. 11,
  7179. 19
  7180. ],
  7181. [
  7182. 11,
  7183. 20
  7184. ],
  7185. [
  7186. 11,
  7187. 20
  7188. ],
  7189. [
  7190. 12,
  7191. 34
  7192. ],
  7193. [
  7194. 12,
  7195. 35
  7196. ],
  7197. [
  7198. 12,
  7199. 36
  7200. ],
  7201. [
  7202. 12,
  7203. 37
  7204. ],
  7205. [
  7206. 12,
  7207. 38
  7208. ],
  7209. [
  7210. 12,
  7211. 39
  7212. ],
  7213. [
  7214. 11,
  7215. 21
  7216. ],
  7217. [
  7218. 11,
  7219. 21
  7220. ],
  7221. [
  7222. 12,
  7223. 42
  7224. ],
  7225. [
  7226. 12,
  7227. 43
  7228. ],
  7229. [
  7230. 10,
  7231. 0
  7232. ],
  7233. [
  7234. 10,
  7235. 0
  7236. ],
  7237. [
  7238. 10,
  7239. 0
  7240. ],
  7241. [
  7242. 10,
  7243. 0
  7244. ],
  7245. [
  7246. 7,
  7247. 12
  7248. ],
  7249. [
  7250. 7,
  7251. 12
  7252. ],
  7253. [
  7254. 7,
  7255. 12
  7256. ],
  7257. [
  7258. 7,
  7259. 12
  7260. ],
  7261. [
  7262. 7,
  7263. 12
  7264. ],
  7265. [
  7266. 7,
  7267. 12
  7268. ],
  7269. [
  7270. 7,
  7271. 12
  7272. ],
  7273. [
  7274. 7,
  7275. 12
  7276. ],
  7277. [
  7278. 7,
  7279. 12
  7280. ],
  7281. [
  7282. 7,
  7283. 12
  7284. ],
  7285. [
  7286. 7,
  7287. 12
  7288. ],
  7289. [
  7290. 7,
  7291. 12
  7292. ],
  7293. [
  7294. 7,
  7295. 12
  7296. ],
  7297. [
  7298. 7,
  7299. 12
  7300. ],
  7301. [
  7302. 7,
  7303. 12
  7304. ],
  7305. [
  7306. 7,
  7307. 12
  7308. ],
  7309. [
  7310. 7,
  7311. 12
  7312. ],
  7313. [
  7314. 7,
  7315. 12
  7316. ],
  7317. [
  7318. 7,
  7319. 12
  7320. ],
  7321. [
  7322. 7,
  7323. 12
  7324. ],
  7325. [
  7326. 7,
  7327. 12
  7328. ],
  7329. [
  7330. 7,
  7331. 12
  7332. ],
  7333. [
  7334. 7,
  7335. 12
  7336. ],
  7337. [
  7338. 7,
  7339. 12
  7340. ],
  7341. [
  7342. 7,
  7343. 12
  7344. ],
  7345. [
  7346. 7,
  7347. 12
  7348. ],
  7349. [
  7350. 7,
  7351. 12
  7352. ],
  7353. [
  7354. 7,
  7355. 12
  7356. ],
  7357. [
  7358. 7,
  7359. 12
  7360. ],
  7361. [
  7362. 7,
  7363. 12
  7364. ],
  7365. [
  7366. 7,
  7367. 12
  7368. ],
  7369. [
  7370. 7,
  7371. 12
  7372. ]
  7373. ];
  7374. var blackTable3 = [
  7375. [
  7376. -1,
  7377. -1
  7378. ],
  7379. [
  7380. -1,
  7381. -1
  7382. ],
  7383. [
  7384. -1,
  7385. -1
  7386. ],
  7387. [
  7388. -1,
  7389. -1
  7390. ],
  7391. [
  7392. 6,
  7393. 9
  7394. ],
  7395. [
  7396. 6,
  7397. 8
  7398. ],
  7399. [
  7400. 5,
  7401. 7
  7402. ],
  7403. [
  7404. 5,
  7405. 7
  7406. ],
  7407. [
  7408. 4,
  7409. 6
  7410. ],
  7411. [
  7412. 4,
  7413. 6
  7414. ],
  7415. [
  7416. 4,
  7417. 6
  7418. ],
  7419. [
  7420. 4,
  7421. 6
  7422. ],
  7423. [
  7424. 4,
  7425. 5
  7426. ],
  7427. [
  7428. 4,
  7429. 5
  7430. ],
  7431. [
  7432. 4,
  7433. 5
  7434. ],
  7435. [
  7436. 4,
  7437. 5
  7438. ],
  7439. [
  7440. 3,
  7441. 1
  7442. ],
  7443. [
  7444. 3,
  7445. 1
  7446. ],
  7447. [
  7448. 3,
  7449. 1
  7450. ],
  7451. [
  7452. 3,
  7453. 1
  7454. ],
  7455. [
  7456. 3,
  7457. 1
  7458. ],
  7459. [
  7460. 3,
  7461. 1
  7462. ],
  7463. [
  7464. 3,
  7465. 1
  7466. ],
  7467. [
  7468. 3,
  7469. 1
  7470. ],
  7471. [
  7472. 3,
  7473. 4
  7474. ],
  7475. [
  7476. 3,
  7477. 4
  7478. ],
  7479. [
  7480. 3,
  7481. 4
  7482. ],
  7483. [
  7484. 3,
  7485. 4
  7486. ],
  7487. [
  7488. 3,
  7489. 4
  7490. ],
  7491. [
  7492. 3,
  7493. 4
  7494. ],
  7495. [
  7496. 3,
  7497. 4
  7498. ],
  7499. [
  7500. 3,
  7501. 4
  7502. ],
  7503. [
  7504. 2,
  7505. 3
  7506. ],
  7507. [
  7508. 2,
  7509. 3
  7510. ],
  7511. [
  7512. 2,
  7513. 3
  7514. ],
  7515. [
  7516. 2,
  7517. 3
  7518. ],
  7519. [
  7520. 2,
  7521. 3
  7522. ],
  7523. [
  7524. 2,
  7525. 3
  7526. ],
  7527. [
  7528. 2,
  7529. 3
  7530. ],
  7531. [
  7532. 2,
  7533. 3
  7534. ],
  7535. [
  7536. 2,
  7537. 3
  7538. ],
  7539. [
  7540. 2,
  7541. 3
  7542. ],
  7543. [
  7544. 2,
  7545. 3
  7546. ],
  7547. [
  7548. 2,
  7549. 3
  7550. ],
  7551. [
  7552. 2,
  7553. 3
  7554. ],
  7555. [
  7556. 2,
  7557. 3
  7558. ],
  7559. [
  7560. 2,
  7561. 3
  7562. ],
  7563. [
  7564. 2,
  7565. 3
  7566. ],
  7567. [
  7568. 2,
  7569. 2
  7570. ],
  7571. [
  7572. 2,
  7573. 2
  7574. ],
  7575. [
  7576. 2,
  7577. 2
  7578. ],
  7579. [
  7580. 2,
  7581. 2
  7582. ],
  7583. [
  7584. 2,
  7585. 2
  7586. ],
  7587. [
  7588. 2,
  7589. 2
  7590. ],
  7591. [
  7592. 2,
  7593. 2
  7594. ],
  7595. [
  7596. 2,
  7597. 2
  7598. ],
  7599. [
  7600. 2,
  7601. 2
  7602. ],
  7603. [
  7604. 2,
  7605. 2
  7606. ],
  7607. [
  7608. 2,
  7609. 2
  7610. ],
  7611. [
  7612. 2,
  7613. 2
  7614. ],
  7615. [
  7616. 2,
  7617. 2
  7618. ],
  7619. [
  7620. 2,
  7621. 2
  7622. ],
  7623. [
  7624. 2,
  7625. 2
  7626. ],
  7627. [
  7628. 2,
  7629. 2
  7630. ]
  7631. ];
  7632. function CCITTFaxStream(str, maybeLength, params) {
  7633. this.str = str;
  7634. this.dict = str.dict;
  7635. params = params || Dict.empty;
  7636. this.encoding = params.get('K') || 0;
  7637. this.eoline = params.get('EndOfLine') || false;
  7638. this.byteAlign = params.get('EncodedByteAlign') || false;
  7639. this.columns = params.get('Columns') || 1728;
  7640. this.rows = params.get('Rows') || 0;
  7641. var eoblock = params.get('EndOfBlock');
  7642. if (eoblock === null || eoblock === undefined) {
  7643. eoblock = true;
  7644. }
  7645. this.eoblock = eoblock;
  7646. this.black = params.get('BlackIs1') || false;
  7647. this.codingLine = new Uint32Array(this.columns + 1);
  7648. this.refLine = new Uint32Array(this.columns + 2);
  7649. this.codingLine[0] = this.columns;
  7650. this.codingPos = 0;
  7651. this.row = 0;
  7652. this.nextLine2D = this.encoding < 0;
  7653. this.inputBits = 0;
  7654. this.inputBuf = 0;
  7655. this.outputBits = 0;
  7656. var code1;
  7657. while ((code1 = this.lookBits(12)) === 0) {
  7658. this.eatBits(1);
  7659. }
  7660. if (code1 === 1) {
  7661. this.eatBits(12);
  7662. }
  7663. if (this.encoding > 0) {
  7664. this.nextLine2D = !this.lookBits(1);
  7665. this.eatBits(1);
  7666. }
  7667. DecodeStream.call(this, maybeLength);
  7668. }
  7669. CCITTFaxStream.prototype = Object.create(DecodeStream.prototype);
  7670. CCITTFaxStream.prototype.readBlock = function CCITTFaxStream_readBlock() {
  7671. while (!this.eof) {
  7672. var c = this.lookChar();
  7673. this.ensureBuffer(this.bufferLength + 1);
  7674. this.buffer[this.bufferLength++] = c;
  7675. }
  7676. };
  7677. CCITTFaxStream.prototype.addPixels = function ccittFaxStreamAddPixels(a1, blackPixels) {
  7678. var codingLine = this.codingLine;
  7679. var codingPos = this.codingPos;
  7680. if (a1 > codingLine[codingPos]) {
  7681. if (a1 > this.columns) {
  7682. info('row is wrong length');
  7683. this.err = true;
  7684. a1 = this.columns;
  7685. }
  7686. if (codingPos & 1 ^ blackPixels) {
  7687. ++codingPos;
  7688. }
  7689. codingLine[codingPos] = a1;
  7690. }
  7691. this.codingPos = codingPos;
  7692. };
  7693. CCITTFaxStream.prototype.addPixelsNeg = function ccittFaxStreamAddPixelsNeg(a1, blackPixels) {
  7694. var codingLine = this.codingLine;
  7695. var codingPos = this.codingPos;
  7696. if (a1 > codingLine[codingPos]) {
  7697. if (a1 > this.columns) {
  7698. info('row is wrong length');
  7699. this.err = true;
  7700. a1 = this.columns;
  7701. }
  7702. if (codingPos & 1 ^ blackPixels) {
  7703. ++codingPos;
  7704. }
  7705. codingLine[codingPos] = a1;
  7706. } else if (a1 < codingLine[codingPos]) {
  7707. if (a1 < 0) {
  7708. info('invalid code');
  7709. this.err = true;
  7710. a1 = 0;
  7711. }
  7712. while (codingPos > 0 && a1 < codingLine[codingPos - 1]) {
  7713. --codingPos;
  7714. }
  7715. codingLine[codingPos] = a1;
  7716. }
  7717. this.codingPos = codingPos;
  7718. };
  7719. CCITTFaxStream.prototype.lookChar = function CCITTFaxStream_lookChar() {
  7720. var refLine = this.refLine;
  7721. var codingLine = this.codingLine;
  7722. var columns = this.columns;
  7723. var refPos, blackPixels, bits, i;
  7724. if (this.outputBits === 0) {
  7725. if (this.eof) {
  7726. return null;
  7727. }
  7728. this.err = false;
  7729. var code1, code2, code3;
  7730. if (this.nextLine2D) {
  7731. for (i = 0; codingLine[i] < columns; ++i) {
  7732. refLine[i] = codingLine[i];
  7733. }
  7734. refLine[i++] = columns;
  7735. refLine[i] = columns;
  7736. codingLine[0] = 0;
  7737. this.codingPos = 0;
  7738. refPos = 0;
  7739. blackPixels = 0;
  7740. while (codingLine[this.codingPos] < columns) {
  7741. code1 = this.getTwoDimCode();
  7742. switch (code1) {
  7743. case twoDimPass:
  7744. this.addPixels(refLine[refPos + 1], blackPixels);
  7745. if (refLine[refPos + 1] < columns) {
  7746. refPos += 2;
  7747. }
  7748. break;
  7749. case twoDimHoriz:
  7750. code1 = code2 = 0;
  7751. if (blackPixels) {
  7752. do {
  7753. code1 += code3 = this.getBlackCode();
  7754. } while (code3 >= 64);
  7755. do {
  7756. code2 += code3 = this.getWhiteCode();
  7757. } while (code3 >= 64);
  7758. } else {
  7759. do {
  7760. code1 += code3 = this.getWhiteCode();
  7761. } while (code3 >= 64);
  7762. do {
  7763. code2 += code3 = this.getBlackCode();
  7764. } while (code3 >= 64);
  7765. }
  7766. this.addPixels(codingLine[this.codingPos] + code1, blackPixels);
  7767. if (codingLine[this.codingPos] < columns) {
  7768. this.addPixels(codingLine[this.codingPos] + code2, blackPixels ^ 1);
  7769. }
  7770. while (refLine[refPos] <= codingLine[this.codingPos] && refLine[refPos] < columns) {
  7771. refPos += 2;
  7772. }
  7773. break;
  7774. case twoDimVertR3:
  7775. this.addPixels(refLine[refPos] + 3, blackPixels);
  7776. blackPixels ^= 1;
  7777. if (codingLine[this.codingPos] < columns) {
  7778. ++refPos;
  7779. while (refLine[refPos] <= codingLine[this.codingPos] && refLine[refPos] < columns) {
  7780. refPos += 2;
  7781. }
  7782. }
  7783. break;
  7784. case twoDimVertR2:
  7785. this.addPixels(refLine[refPos] + 2, blackPixels);
  7786. blackPixels ^= 1;
  7787. if (codingLine[this.codingPos] < columns) {
  7788. ++refPos;
  7789. while (refLine[refPos] <= codingLine[this.codingPos] && refLine[refPos] < columns) {
  7790. refPos += 2;
  7791. }
  7792. }
  7793. break;
  7794. case twoDimVertR1:
  7795. this.addPixels(refLine[refPos] + 1, blackPixels);
  7796. blackPixels ^= 1;
  7797. if (codingLine[this.codingPos] < columns) {
  7798. ++refPos;
  7799. while (refLine[refPos] <= codingLine[this.codingPos] && refLine[refPos] < columns) {
  7800. refPos += 2;
  7801. }
  7802. }
  7803. break;
  7804. case twoDimVert0:
  7805. this.addPixels(refLine[refPos], blackPixels);
  7806. blackPixels ^= 1;
  7807. if (codingLine[this.codingPos] < columns) {
  7808. ++refPos;
  7809. while (refLine[refPos] <= codingLine[this.codingPos] && refLine[refPos] < columns) {
  7810. refPos += 2;
  7811. }
  7812. }
  7813. break;
  7814. case twoDimVertL3:
  7815. this.addPixelsNeg(refLine[refPos] - 3, blackPixels);
  7816. blackPixels ^= 1;
  7817. if (codingLine[this.codingPos] < columns) {
  7818. if (refPos > 0) {
  7819. --refPos;
  7820. } else {
  7821. ++refPos;
  7822. }
  7823. while (refLine[refPos] <= codingLine[this.codingPos] && refLine[refPos] < columns) {
  7824. refPos += 2;
  7825. }
  7826. }
  7827. break;
  7828. case twoDimVertL2:
  7829. this.addPixelsNeg(refLine[refPos] - 2, blackPixels);
  7830. blackPixels ^= 1;
  7831. if (codingLine[this.codingPos] < columns) {
  7832. if (refPos > 0) {
  7833. --refPos;
  7834. } else {
  7835. ++refPos;
  7836. }
  7837. while (refLine[refPos] <= codingLine[this.codingPos] && refLine[refPos] < columns) {
  7838. refPos += 2;
  7839. }
  7840. }
  7841. break;
  7842. case twoDimVertL1:
  7843. this.addPixelsNeg(refLine[refPos] - 1, blackPixels);
  7844. blackPixels ^= 1;
  7845. if (codingLine[this.codingPos] < columns) {
  7846. if (refPos > 0) {
  7847. --refPos;
  7848. } else {
  7849. ++refPos;
  7850. }
  7851. while (refLine[refPos] <= codingLine[this.codingPos] && refLine[refPos] < columns) {
  7852. refPos += 2;
  7853. }
  7854. }
  7855. break;
  7856. case ccittEOF:
  7857. this.addPixels(columns, 0);
  7858. this.eof = true;
  7859. break;
  7860. default:
  7861. info('bad 2d code');
  7862. this.addPixels(columns, 0);
  7863. this.err = true;
  7864. }
  7865. }
  7866. } else {
  7867. codingLine[0] = 0;
  7868. this.codingPos = 0;
  7869. blackPixels = 0;
  7870. while (codingLine[this.codingPos] < columns) {
  7871. code1 = 0;
  7872. if (blackPixels) {
  7873. do {
  7874. code1 += code3 = this.getBlackCode();
  7875. } while (code3 >= 64);
  7876. } else {
  7877. do {
  7878. code1 += code3 = this.getWhiteCode();
  7879. } while (code3 >= 64);
  7880. }
  7881. this.addPixels(codingLine[this.codingPos] + code1, blackPixels);
  7882. blackPixels ^= 1;
  7883. }
  7884. }
  7885. var gotEOL = false;
  7886. if (this.byteAlign) {
  7887. this.inputBits &= ~7;
  7888. }
  7889. if (!this.eoblock && this.row === this.rows - 1) {
  7890. this.eof = true;
  7891. } else {
  7892. code1 = this.lookBits(12);
  7893. if (this.eoline) {
  7894. while (code1 !== ccittEOF && code1 !== 1) {
  7895. this.eatBits(1);
  7896. code1 = this.lookBits(12);
  7897. }
  7898. } else {
  7899. while (code1 === 0) {
  7900. this.eatBits(1);
  7901. code1 = this.lookBits(12);
  7902. }
  7903. }
  7904. if (code1 === 1) {
  7905. this.eatBits(12);
  7906. gotEOL = true;
  7907. } else if (code1 === ccittEOF) {
  7908. this.eof = true;
  7909. }
  7910. }
  7911. if (!this.eof && this.encoding > 0) {
  7912. this.nextLine2D = !this.lookBits(1);
  7913. this.eatBits(1);
  7914. }
  7915. if (this.eoblock && gotEOL && this.byteAlign) {
  7916. code1 = this.lookBits(12);
  7917. if (code1 === 1) {
  7918. this.eatBits(12);
  7919. if (this.encoding > 0) {
  7920. this.lookBits(1);
  7921. this.eatBits(1);
  7922. }
  7923. if (this.encoding >= 0) {
  7924. for (i = 0; i < 4; ++i) {
  7925. code1 = this.lookBits(12);
  7926. if (code1 !== 1) {
  7927. info('bad rtc code: ' + code1);
  7928. }
  7929. this.eatBits(12);
  7930. if (this.encoding > 0) {
  7931. this.lookBits(1);
  7932. this.eatBits(1);
  7933. }
  7934. }
  7935. }
  7936. this.eof = true;
  7937. }
  7938. } else if (this.err && this.eoline) {
  7939. while (true) {
  7940. code1 = this.lookBits(13);
  7941. if (code1 === ccittEOF) {
  7942. this.eof = true;
  7943. return null;
  7944. }
  7945. if (code1 >> 1 === 1) {
  7946. break;
  7947. }
  7948. this.eatBits(1);
  7949. }
  7950. this.eatBits(12);
  7951. if (this.encoding > 0) {
  7952. this.eatBits(1);
  7953. this.nextLine2D = !(code1 & 1);
  7954. }
  7955. }
  7956. if (codingLine[0] > 0) {
  7957. this.outputBits = codingLine[this.codingPos = 0];
  7958. } else {
  7959. this.outputBits = codingLine[this.codingPos = 1];
  7960. }
  7961. this.row++;
  7962. }
  7963. var c;
  7964. if (this.outputBits >= 8) {
  7965. c = this.codingPos & 1 ? 0 : 0xFF;
  7966. this.outputBits -= 8;
  7967. if (this.outputBits === 0 && codingLine[this.codingPos] < columns) {
  7968. this.codingPos++;
  7969. this.outputBits = codingLine[this.codingPos] - codingLine[this.codingPos - 1];
  7970. }
  7971. } else {
  7972. bits = 8;
  7973. c = 0;
  7974. do {
  7975. if (this.outputBits > bits) {
  7976. c <<= bits;
  7977. if (!(this.codingPos & 1)) {
  7978. c |= 0xFF >> 8 - bits;
  7979. }
  7980. this.outputBits -= bits;
  7981. bits = 0;
  7982. } else {
  7983. c <<= this.outputBits;
  7984. if (!(this.codingPos & 1)) {
  7985. c |= 0xFF >> 8 - this.outputBits;
  7986. }
  7987. bits -= this.outputBits;
  7988. this.outputBits = 0;
  7989. if (codingLine[this.codingPos] < columns) {
  7990. this.codingPos++;
  7991. this.outputBits = codingLine[this.codingPos] - codingLine[this.codingPos - 1];
  7992. } else if (bits > 0) {
  7993. c <<= bits;
  7994. bits = 0;
  7995. }
  7996. }
  7997. } while (bits);
  7998. }
  7999. if (this.black) {
  8000. c ^= 0xFF;
  8001. }
  8002. return c;
  8003. };
  8004. CCITTFaxStream.prototype.findTableCode = function ccittFaxStreamFindTableCode(start, end, table, limit) {
  8005. var limitValue = limit || 0;
  8006. for (var i = start; i <= end; ++i) {
  8007. var code = this.lookBits(i);
  8008. if (code === ccittEOF) {
  8009. return [
  8010. true,
  8011. 1,
  8012. false
  8013. ];
  8014. }
  8015. if (i < end) {
  8016. code <<= end - i;
  8017. }
  8018. if (!limitValue || code >= limitValue) {
  8019. var p = table[code - limitValue];
  8020. if (p[0] === i) {
  8021. this.eatBits(i);
  8022. return [
  8023. true,
  8024. p[1],
  8025. true
  8026. ];
  8027. }
  8028. }
  8029. }
  8030. return [
  8031. false,
  8032. 0,
  8033. false
  8034. ];
  8035. };
  8036. CCITTFaxStream.prototype.getTwoDimCode = function ccittFaxStreamGetTwoDimCode() {
  8037. var code = 0;
  8038. var p;
  8039. if (this.eoblock) {
  8040. code = this.lookBits(7);
  8041. p = twoDimTable[code];
  8042. if (p && p[0] > 0) {
  8043. this.eatBits(p[0]);
  8044. return p[1];
  8045. }
  8046. } else {
  8047. var result = this.findTableCode(1, 7, twoDimTable);
  8048. if (result[0] && result[2]) {
  8049. return result[1];
  8050. }
  8051. }
  8052. info('Bad two dim code');
  8053. return ccittEOF;
  8054. };
  8055. CCITTFaxStream.prototype.getWhiteCode = function ccittFaxStreamGetWhiteCode() {
  8056. var code = 0;
  8057. var p;
  8058. if (this.eoblock) {
  8059. code = this.lookBits(12);
  8060. if (code === ccittEOF) {
  8061. return 1;
  8062. }
  8063. if (code >> 5 === 0) {
  8064. p = whiteTable1[code];
  8065. } else {
  8066. p = whiteTable2[code >> 3];
  8067. }
  8068. if (p[0] > 0) {
  8069. this.eatBits(p[0]);
  8070. return p[1];
  8071. }
  8072. } else {
  8073. var result = this.findTableCode(1, 9, whiteTable2);
  8074. if (result[0]) {
  8075. return result[1];
  8076. }
  8077. result = this.findTableCode(11, 12, whiteTable1);
  8078. if (result[0]) {
  8079. return result[1];
  8080. }
  8081. }
  8082. info('bad white code');
  8083. this.eatBits(1);
  8084. return 1;
  8085. };
  8086. CCITTFaxStream.prototype.getBlackCode = function ccittFaxStreamGetBlackCode() {
  8087. var code, p;
  8088. if (this.eoblock) {
  8089. code = this.lookBits(13);
  8090. if (code === ccittEOF) {
  8091. return 1;
  8092. }
  8093. if (code >> 7 === 0) {
  8094. p = blackTable1[code];
  8095. } else if (code >> 9 === 0 && code >> 7 !== 0) {
  8096. p = blackTable2[(code >> 1) - 64];
  8097. } else {
  8098. p = blackTable3[code >> 7];
  8099. }
  8100. if (p[0] > 0) {
  8101. this.eatBits(p[0]);
  8102. return p[1];
  8103. }
  8104. } else {
  8105. var result = this.findTableCode(2, 6, blackTable3);
  8106. if (result[0]) {
  8107. return result[1];
  8108. }
  8109. result = this.findTableCode(7, 12, blackTable2, 64);
  8110. if (result[0]) {
  8111. return result[1];
  8112. }
  8113. result = this.findTableCode(10, 13, blackTable1);
  8114. if (result[0]) {
  8115. return result[1];
  8116. }
  8117. }
  8118. info('bad black code');
  8119. this.eatBits(1);
  8120. return 1;
  8121. };
  8122. CCITTFaxStream.prototype.lookBits = function CCITTFaxStream_lookBits(n) {
  8123. var c;
  8124. while (this.inputBits < n) {
  8125. if ((c = this.str.getByte()) === -1) {
  8126. if (this.inputBits === 0) {
  8127. return ccittEOF;
  8128. }
  8129. return this.inputBuf << n - this.inputBits & 0xFFFF >> 16 - n;
  8130. }
  8131. this.inputBuf = this.inputBuf << 8 | c;
  8132. this.inputBits += 8;
  8133. }
  8134. return this.inputBuf >> this.inputBits - n & 0xFFFF >> 16 - n;
  8135. };
  8136. CCITTFaxStream.prototype.eatBits = function CCITTFaxStream_eatBits(n) {
  8137. if ((this.inputBits -= n) < 0) {
  8138. this.inputBits = 0;
  8139. }
  8140. };
  8141. return CCITTFaxStream;
  8142. }();
  8143. var LZWStream = function LZWStreamClosure() {
  8144. function LZWStream(str, maybeLength, earlyChange) {
  8145. this.str = str;
  8146. this.dict = str.dict;
  8147. this.cachedData = 0;
  8148. this.bitsCached = 0;
  8149. var maxLzwDictionarySize = 4096;
  8150. var lzwState = {
  8151. earlyChange: earlyChange,
  8152. codeLength: 9,
  8153. nextCode: 258,
  8154. dictionaryValues: new Uint8Array(maxLzwDictionarySize),
  8155. dictionaryLengths: new Uint16Array(maxLzwDictionarySize),
  8156. dictionaryPrevCodes: new Uint16Array(maxLzwDictionarySize),
  8157. currentSequence: new Uint8Array(maxLzwDictionarySize),
  8158. currentSequenceLength: 0
  8159. };
  8160. for (var i = 0; i < 256; ++i) {
  8161. lzwState.dictionaryValues[i] = i;
  8162. lzwState.dictionaryLengths[i] = 1;
  8163. }
  8164. this.lzwState = lzwState;
  8165. DecodeStream.call(this, maybeLength);
  8166. }
  8167. LZWStream.prototype = Object.create(DecodeStream.prototype);
  8168. LZWStream.prototype.readBits = function LZWStream_readBits(n) {
  8169. var bitsCached = this.bitsCached;
  8170. var cachedData = this.cachedData;
  8171. while (bitsCached < n) {
  8172. var c = this.str.getByte();
  8173. if (c === -1) {
  8174. this.eof = true;
  8175. return null;
  8176. }
  8177. cachedData = cachedData << 8 | c;
  8178. bitsCached += 8;
  8179. }
  8180. this.bitsCached = bitsCached -= n;
  8181. this.cachedData = cachedData;
  8182. this.lastCode = null;
  8183. return cachedData >>> bitsCached & (1 << n) - 1;
  8184. };
  8185. LZWStream.prototype.readBlock = function LZWStream_readBlock() {
  8186. var blockSize = 512;
  8187. var estimatedDecodedSize = blockSize * 2, decodedSizeDelta = blockSize;
  8188. var i, j, q;
  8189. var lzwState = this.lzwState;
  8190. if (!lzwState) {
  8191. return;
  8192. }
  8193. var earlyChange = lzwState.earlyChange;
  8194. var nextCode = lzwState.nextCode;
  8195. var dictionaryValues = lzwState.dictionaryValues;
  8196. var dictionaryLengths = lzwState.dictionaryLengths;
  8197. var dictionaryPrevCodes = lzwState.dictionaryPrevCodes;
  8198. var codeLength = lzwState.codeLength;
  8199. var prevCode = lzwState.prevCode;
  8200. var currentSequence = lzwState.currentSequence;
  8201. var currentSequenceLength = lzwState.currentSequenceLength;
  8202. var decodedLength = 0;
  8203. var currentBufferLength = this.bufferLength;
  8204. var buffer = this.ensureBuffer(this.bufferLength + estimatedDecodedSize);
  8205. for (i = 0; i < blockSize; i++) {
  8206. var code = this.readBits(codeLength);
  8207. var hasPrev = currentSequenceLength > 0;
  8208. if (code < 256) {
  8209. currentSequence[0] = code;
  8210. currentSequenceLength = 1;
  8211. } else if (code >= 258) {
  8212. if (code < nextCode) {
  8213. currentSequenceLength = dictionaryLengths[code];
  8214. for (j = currentSequenceLength - 1, q = code; j >= 0; j--) {
  8215. currentSequence[j] = dictionaryValues[q];
  8216. q = dictionaryPrevCodes[q];
  8217. }
  8218. } else {
  8219. currentSequence[currentSequenceLength++] = currentSequence[0];
  8220. }
  8221. } else if (code === 256) {
  8222. codeLength = 9;
  8223. nextCode = 258;
  8224. currentSequenceLength = 0;
  8225. continue;
  8226. } else {
  8227. this.eof = true;
  8228. delete this.lzwState;
  8229. break;
  8230. }
  8231. if (hasPrev) {
  8232. dictionaryPrevCodes[nextCode] = prevCode;
  8233. dictionaryLengths[nextCode] = dictionaryLengths[prevCode] + 1;
  8234. dictionaryValues[nextCode] = currentSequence[0];
  8235. nextCode++;
  8236. codeLength = nextCode + earlyChange & nextCode + earlyChange - 1 ? codeLength : Math.min(Math.log(nextCode + earlyChange) / 0.6931471805599453 + 1, 12) | 0;
  8237. }
  8238. prevCode = code;
  8239. decodedLength += currentSequenceLength;
  8240. if (estimatedDecodedSize < decodedLength) {
  8241. do {
  8242. estimatedDecodedSize += decodedSizeDelta;
  8243. } while (estimatedDecodedSize < decodedLength);
  8244. buffer = this.ensureBuffer(this.bufferLength + estimatedDecodedSize);
  8245. }
  8246. for (j = 0; j < currentSequenceLength; j++) {
  8247. buffer[currentBufferLength++] = currentSequence[j];
  8248. }
  8249. }
  8250. lzwState.nextCode = nextCode;
  8251. lzwState.codeLength = codeLength;
  8252. lzwState.prevCode = prevCode;
  8253. lzwState.currentSequenceLength = currentSequenceLength;
  8254. this.bufferLength = currentBufferLength;
  8255. };
  8256. return LZWStream;
  8257. }();
  8258. var NullStream = function NullStreamClosure() {
  8259. function NullStream() {
  8260. Stream.call(this, new Uint8Array(0));
  8261. }
  8262. NullStream.prototype = Stream.prototype;
  8263. return NullStream;
  8264. }();
  8265. exports.Ascii85Stream = Ascii85Stream;
  8266. exports.AsciiHexStream = AsciiHexStream;
  8267. exports.CCITTFaxStream = CCITTFaxStream;
  8268. exports.DecryptStream = DecryptStream;
  8269. exports.DecodeStream = DecodeStream;
  8270. exports.FlateStream = FlateStream;
  8271. exports.Jbig2Stream = Jbig2Stream;
  8272. exports.JpegStream = JpegStream;
  8273. exports.JpxStream = JpxStream;
  8274. exports.NullStream = NullStream;
  8275. exports.PredictorStream = PredictorStream;
  8276. exports.RunLengthStream = RunLengthStream;
  8277. exports.Stream = Stream;
  8278. exports.StreamsSequenceStream = StreamsSequenceStream;
  8279. exports.StringStream = StringStream;
  8280. exports.LZWStream = LZWStream;
  8281. /***/ }),
  8282. /* 3 */
  8283. /***/ (function(module, exports, __w_pdfjs_require__) {
  8284. "use strict";
  8285. var sharedUtil = __w_pdfjs_require__(0);
  8286. var assert = sharedUtil.assert;
  8287. var removeNullCharacters = sharedUtil.removeNullCharacters;
  8288. var warn = sharedUtil.warn;
  8289. var deprecated = sharedUtil.deprecated;
  8290. var createValidAbsoluteUrl = sharedUtil.createValidAbsoluteUrl;
  8291. var stringToBytes = sharedUtil.stringToBytes;
  8292. var CMapCompressionType = sharedUtil.CMapCompressionType;
  8293. var DEFAULT_LINK_REL = 'noopener noreferrer nofollow';
  8294. function DOMCanvasFactory() {
  8295. }
  8296. DOMCanvasFactory.prototype = {
  8297. create: function DOMCanvasFactory_create(width, height) {
  8298. assert(width > 0 && height > 0, 'invalid canvas size');
  8299. var canvas = document.createElement('canvas');
  8300. var context = canvas.getContext('2d');
  8301. canvas.width = width;
  8302. canvas.height = height;
  8303. return {
  8304. canvas: canvas,
  8305. context: context
  8306. };
  8307. },
  8308. reset: function DOMCanvasFactory_reset(canvasAndContextPair, width, height) {
  8309. assert(canvasAndContextPair.canvas, 'canvas is not specified');
  8310. assert(width > 0 && height > 0, 'invalid canvas size');
  8311. canvasAndContextPair.canvas.width = width;
  8312. canvasAndContextPair.canvas.height = height;
  8313. },
  8314. destroy: function DOMCanvasFactory_destroy(canvasAndContextPair) {
  8315. assert(canvasAndContextPair.canvas, 'canvas is not specified');
  8316. canvasAndContextPair.canvas.width = 0;
  8317. canvasAndContextPair.canvas.height = 0;
  8318. canvasAndContextPair.canvas = null;
  8319. canvasAndContextPair.context = null;
  8320. }
  8321. };
  8322. var DOMCMapReaderFactory = function DOMCMapReaderFactoryClosure() {
  8323. function DOMCMapReaderFactory(params) {
  8324. this.baseUrl = params.baseUrl || null;
  8325. this.isCompressed = params.isCompressed || false;
  8326. }
  8327. DOMCMapReaderFactory.prototype = {
  8328. fetch: function (params) {
  8329. if (!params.name) {
  8330. return Promise.reject(new Error('CMap name must be specified.'));
  8331. }
  8332. return new Promise(function (resolve, reject) {
  8333. var url = this.baseUrl + params.name;
  8334. var request = new XMLHttpRequest();
  8335. if (this.isCompressed) {
  8336. url += '.bcmap';
  8337. request.responseType = 'arraybuffer';
  8338. }
  8339. request.onreadystatechange = function () {
  8340. if (request.readyState === XMLHttpRequest.DONE && (request.status === 200 || request.status === 0)) {
  8341. var data;
  8342. if (this.isCompressed && request.response) {
  8343. data = new Uint8Array(request.response);
  8344. } else if (!this.isCompressed && request.responseText) {
  8345. data = stringToBytes(request.responseText);
  8346. }
  8347. if (data) {
  8348. resolve({
  8349. cMapData: data,
  8350. compressionType: this.isCompressed ? CMapCompressionType.BINARY : CMapCompressionType.NONE
  8351. });
  8352. return;
  8353. }
  8354. reject(new Error('Unable to load ' + (this.isCompressed ? 'binary' : '') + ' CMap at: ' + url));
  8355. }
  8356. }.bind(this);
  8357. request.open('GET', url, true);
  8358. request.send(null);
  8359. }.bind(this));
  8360. }
  8361. };
  8362. return DOMCMapReaderFactory;
  8363. }();
  8364. var CustomStyle = function CustomStyleClosure() {
  8365. var prefixes = [
  8366. 'ms',
  8367. 'Moz',
  8368. 'Webkit',
  8369. 'O'
  8370. ];
  8371. var _cache = Object.create(null);
  8372. function CustomStyle() {
  8373. }
  8374. CustomStyle.getProp = function get(propName, element) {
  8375. if (arguments.length === 1 && typeof _cache[propName] === 'string') {
  8376. return _cache[propName];
  8377. }
  8378. element = element || document.documentElement;
  8379. var style = element.style, prefixed, uPropName;
  8380. if (typeof style[propName] === 'string') {
  8381. return _cache[propName] = propName;
  8382. }
  8383. uPropName = propName.charAt(0).toUpperCase() + propName.slice(1);
  8384. for (var i = 0, l = prefixes.length; i < l; i++) {
  8385. prefixed = prefixes[i] + uPropName;
  8386. if (typeof style[prefixed] === 'string') {
  8387. return _cache[propName] = prefixed;
  8388. }
  8389. }
  8390. return _cache[propName] = 'undefined';
  8391. };
  8392. CustomStyle.setProp = function set(propName, element, str) {
  8393. var prop = this.getProp(propName);
  8394. if (prop !== 'undefined') {
  8395. element.style[prop] = str;
  8396. }
  8397. };
  8398. return CustomStyle;
  8399. }();
  8400. var hasCanvasTypedArrays;
  8401. hasCanvasTypedArrays = function hasCanvasTypedArrays() {
  8402. var canvas = document.createElement('canvas');
  8403. canvas.width = canvas.height = 1;
  8404. var ctx = canvas.getContext('2d');
  8405. var imageData = ctx.createImageData(1, 1);
  8406. return typeof imageData.data.buffer !== 'undefined';
  8407. };
  8408. var LinkTarget = {
  8409. NONE: 0,
  8410. SELF: 1,
  8411. BLANK: 2,
  8412. PARENT: 3,
  8413. TOP: 4
  8414. };
  8415. var LinkTargetStringMap = [
  8416. '',
  8417. '_self',
  8418. '_blank',
  8419. '_parent',
  8420. '_top'
  8421. ];
  8422. function addLinkAttributes(link, params) {
  8423. var url = params && params.url;
  8424. link.href = link.title = url ? removeNullCharacters(url) : '';
  8425. if (url) {
  8426. var target = params.target;
  8427. if (typeof target === 'undefined') {
  8428. target = getDefaultSetting('externalLinkTarget');
  8429. }
  8430. link.target = LinkTargetStringMap[target];
  8431. var rel = params.rel;
  8432. if (typeof rel === 'undefined') {
  8433. rel = getDefaultSetting('externalLinkRel');
  8434. }
  8435. link.rel = rel;
  8436. }
  8437. }
  8438. function getFilenameFromUrl(url) {
  8439. var anchor = url.indexOf('#');
  8440. var query = url.indexOf('?');
  8441. var end = Math.min(anchor > 0 ? anchor : url.length, query > 0 ? query : url.length);
  8442. return url.substring(url.lastIndexOf('/', end) + 1, end);
  8443. }
  8444. function getDefaultSetting(id) {
  8445. var globalSettings = sharedUtil.globalScope.PDFJS;
  8446. switch (id) {
  8447. case 'pdfBug':
  8448. return globalSettings ? globalSettings.pdfBug : false;
  8449. case 'disableAutoFetch':
  8450. return globalSettings ? globalSettings.disableAutoFetch : false;
  8451. case 'disableStream':
  8452. return globalSettings ? globalSettings.disableStream : false;
  8453. case 'disableRange':
  8454. return globalSettings ? globalSettings.disableRange : false;
  8455. case 'disableFontFace':
  8456. return globalSettings ? globalSettings.disableFontFace : false;
  8457. case 'disableCreateObjectURL':
  8458. return globalSettings ? globalSettings.disableCreateObjectURL : false;
  8459. case 'disableWebGL':
  8460. return globalSettings ? globalSettings.disableWebGL : true;
  8461. case 'cMapUrl':
  8462. return globalSettings ? globalSettings.cMapUrl : null;
  8463. case 'cMapPacked':
  8464. return globalSettings ? globalSettings.cMapPacked : false;
  8465. case 'postMessageTransfers':
  8466. return globalSettings ? globalSettings.postMessageTransfers : true;
  8467. case 'workerPort':
  8468. return globalSettings ? globalSettings.workerPort : null;
  8469. case 'workerSrc':
  8470. return globalSettings ? globalSettings.workerSrc : null;
  8471. case 'disableWorker':
  8472. return globalSettings ? globalSettings.disableWorker : false;
  8473. case 'maxImageSize':
  8474. return globalSettings ? globalSettings.maxImageSize : -1;
  8475. case 'imageResourcesPath':
  8476. return globalSettings ? globalSettings.imageResourcesPath : '';
  8477. case 'isEvalSupported':
  8478. return globalSettings ? globalSettings.isEvalSupported : true;
  8479. case 'externalLinkTarget':
  8480. if (!globalSettings) {
  8481. return LinkTarget.NONE;
  8482. }
  8483. switch (globalSettings.externalLinkTarget) {
  8484. case LinkTarget.NONE:
  8485. case LinkTarget.SELF:
  8486. case LinkTarget.BLANK:
  8487. case LinkTarget.PARENT:
  8488. case LinkTarget.TOP:
  8489. return globalSettings.externalLinkTarget;
  8490. }
  8491. warn('PDFJS.externalLinkTarget is invalid: ' + globalSettings.externalLinkTarget);
  8492. globalSettings.externalLinkTarget = LinkTarget.NONE;
  8493. return LinkTarget.NONE;
  8494. case 'externalLinkRel':
  8495. return globalSettings ? globalSettings.externalLinkRel : DEFAULT_LINK_REL;
  8496. case 'enableStats':
  8497. return !!(globalSettings && globalSettings.enableStats);
  8498. default:
  8499. throw new Error('Unknown default setting: ' + id);
  8500. }
  8501. }
  8502. function isExternalLinkTargetSet() {
  8503. var externalLinkTarget = getDefaultSetting('externalLinkTarget');
  8504. switch (externalLinkTarget) {
  8505. case LinkTarget.NONE:
  8506. return false;
  8507. case LinkTarget.SELF:
  8508. case LinkTarget.BLANK:
  8509. case LinkTarget.PARENT:
  8510. case LinkTarget.TOP:
  8511. return true;
  8512. }
  8513. }
  8514. function isValidUrl(url, allowRelative) {
  8515. deprecated('isValidUrl(), please use createValidAbsoluteUrl() instead.');
  8516. var baseUrl = allowRelative ? 'http://example.com' : null;
  8517. return createValidAbsoluteUrl(url, baseUrl) !== null;
  8518. }
  8519. exports.CustomStyle = CustomStyle;
  8520. exports.addLinkAttributes = addLinkAttributes;
  8521. exports.isExternalLinkTargetSet = isExternalLinkTargetSet;
  8522. exports.isValidUrl = isValidUrl;
  8523. exports.getFilenameFromUrl = getFilenameFromUrl;
  8524. exports.LinkTarget = LinkTarget;
  8525. exports.hasCanvasTypedArrays = hasCanvasTypedArrays;
  8526. exports.getDefaultSetting = getDefaultSetting;
  8527. exports.DEFAULT_LINK_REL = DEFAULT_LINK_REL;
  8528. exports.DOMCanvasFactory = DOMCanvasFactory;
  8529. exports.DOMCMapReaderFactory = DOMCMapReaderFactory;
  8530. /***/ }),
  8531. /* 4 */
  8532. /***/ (function(module, exports, __w_pdfjs_require__) {
  8533. "use strict";
  8534. var sharedUtil = __w_pdfjs_require__(0);
  8535. var corePrimitives = __w_pdfjs_require__(1);
  8536. var coreFunction = __w_pdfjs_require__(7);
  8537. var error = sharedUtil.error;
  8538. var info = sharedUtil.info;
  8539. var isArray = sharedUtil.isArray;
  8540. var isString = sharedUtil.isString;
  8541. var shadow = sharedUtil.shadow;
  8542. var warn = sharedUtil.warn;
  8543. var isDict = corePrimitives.isDict;
  8544. var isName = corePrimitives.isName;
  8545. var isStream = corePrimitives.isStream;
  8546. var PDFFunction = coreFunction.PDFFunction;
  8547. var ColorSpace = function ColorSpaceClosure() {
  8548. function resizeRgbImage(src, bpc, w1, h1, w2, h2, alpha01, dest) {
  8549. var COMPONENTS = 3;
  8550. alpha01 = alpha01 !== 1 ? 0 : alpha01;
  8551. var xRatio = w1 / w2;
  8552. var yRatio = h1 / h2;
  8553. var i, j, py, newIndex = 0, oldIndex;
  8554. var xScaled = new Uint16Array(w2);
  8555. var w1Scanline = w1 * COMPONENTS;
  8556. for (i = 0; i < w2; i++) {
  8557. xScaled[i] = Math.floor(i * xRatio) * COMPONENTS;
  8558. }
  8559. for (i = 0; i < h2; i++) {
  8560. py = Math.floor(i * yRatio) * w1Scanline;
  8561. for (j = 0; j < w2; j++) {
  8562. oldIndex = py + xScaled[j];
  8563. dest[newIndex++] = src[oldIndex++];
  8564. dest[newIndex++] = src[oldIndex++];
  8565. dest[newIndex++] = src[oldIndex++];
  8566. newIndex += alpha01;
  8567. }
  8568. }
  8569. }
  8570. function ColorSpace() {
  8571. error('should not call ColorSpace constructor');
  8572. }
  8573. ColorSpace.prototype = {
  8574. getRgb: function ColorSpace_getRgb(src, srcOffset) {
  8575. var rgb = new Uint8Array(3);
  8576. this.getRgbItem(src, srcOffset, rgb, 0);
  8577. return rgb;
  8578. },
  8579. getRgbItem: function ColorSpace_getRgbItem(src, srcOffset, dest, destOffset) {
  8580. error('Should not call ColorSpace.getRgbItem');
  8581. },
  8582. getRgbBuffer: function ColorSpace_getRgbBuffer(src, srcOffset, count, dest, destOffset, bits, alpha01) {
  8583. error('Should not call ColorSpace.getRgbBuffer');
  8584. },
  8585. getOutputLength: function ColorSpace_getOutputLength(inputLength, alpha01) {
  8586. error('Should not call ColorSpace.getOutputLength');
  8587. },
  8588. isPassthrough: function ColorSpace_isPassthrough(bits) {
  8589. return false;
  8590. },
  8591. fillRgb: function ColorSpace_fillRgb(dest, originalWidth, originalHeight, width, height, actualHeight, bpc, comps, alpha01) {
  8592. var count = originalWidth * originalHeight;
  8593. var rgbBuf = null;
  8594. var numComponentColors = 1 << bpc;
  8595. var needsResizing = originalHeight !== height || originalWidth !== width;
  8596. var i, ii;
  8597. if (this.isPassthrough(bpc)) {
  8598. rgbBuf = comps;
  8599. } else if (this.numComps === 1 && count > numComponentColors && this.name !== 'DeviceGray' && this.name !== 'DeviceRGB') {
  8600. var allColors = bpc <= 8 ? new Uint8Array(numComponentColors) : new Uint16Array(numComponentColors);
  8601. var key;
  8602. for (i = 0; i < numComponentColors; i++) {
  8603. allColors[i] = i;
  8604. }
  8605. var colorMap = new Uint8Array(numComponentColors * 3);
  8606. this.getRgbBuffer(allColors, 0, numComponentColors, colorMap, 0, bpc, 0);
  8607. var destPos, rgbPos;
  8608. if (!needsResizing) {
  8609. destPos = 0;
  8610. for (i = 0; i < count; ++i) {
  8611. key = comps[i] * 3;
  8612. dest[destPos++] = colorMap[key];
  8613. dest[destPos++] = colorMap[key + 1];
  8614. dest[destPos++] = colorMap[key + 2];
  8615. destPos += alpha01;
  8616. }
  8617. } else {
  8618. rgbBuf = new Uint8Array(count * 3);
  8619. rgbPos = 0;
  8620. for (i = 0; i < count; ++i) {
  8621. key = comps[i] * 3;
  8622. rgbBuf[rgbPos++] = colorMap[key];
  8623. rgbBuf[rgbPos++] = colorMap[key + 1];
  8624. rgbBuf[rgbPos++] = colorMap[key + 2];
  8625. }
  8626. }
  8627. } else {
  8628. if (!needsResizing) {
  8629. this.getRgbBuffer(comps, 0, width * actualHeight, dest, 0, bpc, alpha01);
  8630. } else {
  8631. rgbBuf = new Uint8Array(count * 3);
  8632. this.getRgbBuffer(comps, 0, count, rgbBuf, 0, bpc, 0);
  8633. }
  8634. }
  8635. if (rgbBuf) {
  8636. if (needsResizing) {
  8637. resizeRgbImage(rgbBuf, bpc, originalWidth, originalHeight, width, height, alpha01, dest);
  8638. } else {
  8639. rgbPos = 0;
  8640. destPos = 0;
  8641. for (i = 0, ii = width * actualHeight; i < ii; i++) {
  8642. dest[destPos++] = rgbBuf[rgbPos++];
  8643. dest[destPos++] = rgbBuf[rgbPos++];
  8644. dest[destPos++] = rgbBuf[rgbPos++];
  8645. destPos += alpha01;
  8646. }
  8647. }
  8648. }
  8649. },
  8650. usesZeroToOneRange: true
  8651. };
  8652. ColorSpace.parse = function ColorSpace_parse(cs, xref, res) {
  8653. var IR = ColorSpace.parseToIR(cs, xref, res);
  8654. if (IR instanceof AlternateCS) {
  8655. return IR;
  8656. }
  8657. return ColorSpace.fromIR(IR);
  8658. };
  8659. ColorSpace.fromIR = function ColorSpace_fromIR(IR) {
  8660. var name = isArray(IR) ? IR[0] : IR;
  8661. var whitePoint, blackPoint, gamma;
  8662. switch (name) {
  8663. case 'DeviceGrayCS':
  8664. return this.singletons.gray;
  8665. case 'DeviceRgbCS':
  8666. return this.singletons.rgb;
  8667. case 'DeviceCmykCS':
  8668. return this.singletons.cmyk;
  8669. case 'CalGrayCS':
  8670. whitePoint = IR[1];
  8671. blackPoint = IR[2];
  8672. gamma = IR[3];
  8673. return new CalGrayCS(whitePoint, blackPoint, gamma);
  8674. case 'CalRGBCS':
  8675. whitePoint = IR[1];
  8676. blackPoint = IR[2];
  8677. gamma = IR[3];
  8678. var matrix = IR[4];
  8679. return new CalRGBCS(whitePoint, blackPoint, gamma, matrix);
  8680. case 'PatternCS':
  8681. var basePatternCS = IR[1];
  8682. if (basePatternCS) {
  8683. basePatternCS = ColorSpace.fromIR(basePatternCS);
  8684. }
  8685. return new PatternCS(basePatternCS);
  8686. case 'IndexedCS':
  8687. var baseIndexedCS = IR[1];
  8688. var hiVal = IR[2];
  8689. var lookup = IR[3];
  8690. return new IndexedCS(ColorSpace.fromIR(baseIndexedCS), hiVal, lookup);
  8691. case 'AlternateCS':
  8692. var numComps = IR[1];
  8693. var alt = IR[2];
  8694. var tintFnIR = IR[3];
  8695. return new AlternateCS(numComps, ColorSpace.fromIR(alt), PDFFunction.fromIR(tintFnIR));
  8696. case 'LabCS':
  8697. whitePoint = IR[1];
  8698. blackPoint = IR[2];
  8699. var range = IR[3];
  8700. return new LabCS(whitePoint, blackPoint, range);
  8701. default:
  8702. error('Unknown name ' + name);
  8703. }
  8704. return null;
  8705. };
  8706. ColorSpace.parseToIR = function ColorSpace_parseToIR(cs, xref, res) {
  8707. if (isName(cs)) {
  8708. var colorSpaces = res.get('ColorSpace');
  8709. if (isDict(colorSpaces)) {
  8710. var refcs = colorSpaces.get(cs.name);
  8711. if (refcs) {
  8712. cs = refcs;
  8713. }
  8714. }
  8715. }
  8716. cs = xref.fetchIfRef(cs);
  8717. if (isName(cs)) {
  8718. switch (cs.name) {
  8719. case 'DeviceGray':
  8720. case 'G':
  8721. return 'DeviceGrayCS';
  8722. case 'DeviceRGB':
  8723. case 'RGB':
  8724. return 'DeviceRgbCS';
  8725. case 'DeviceCMYK':
  8726. case 'CMYK':
  8727. return 'DeviceCmykCS';
  8728. case 'Pattern':
  8729. return [
  8730. 'PatternCS',
  8731. null
  8732. ];
  8733. default:
  8734. error('unrecognized colorspace ' + cs.name);
  8735. }
  8736. } else if (isArray(cs)) {
  8737. var mode = xref.fetchIfRef(cs[0]).name;
  8738. var numComps, params, alt, whitePoint, blackPoint, gamma;
  8739. switch (mode) {
  8740. case 'DeviceGray':
  8741. case 'G':
  8742. return 'DeviceGrayCS';
  8743. case 'DeviceRGB':
  8744. case 'RGB':
  8745. return 'DeviceRgbCS';
  8746. case 'DeviceCMYK':
  8747. case 'CMYK':
  8748. return 'DeviceCmykCS';
  8749. case 'CalGray':
  8750. params = xref.fetchIfRef(cs[1]);
  8751. whitePoint = params.getArray('WhitePoint');
  8752. blackPoint = params.getArray('BlackPoint');
  8753. gamma = params.get('Gamma');
  8754. return [
  8755. 'CalGrayCS',
  8756. whitePoint,
  8757. blackPoint,
  8758. gamma
  8759. ];
  8760. case 'CalRGB':
  8761. params = xref.fetchIfRef(cs[1]);
  8762. whitePoint = params.getArray('WhitePoint');
  8763. blackPoint = params.getArray('BlackPoint');
  8764. gamma = params.getArray('Gamma');
  8765. var matrix = params.getArray('Matrix');
  8766. return [
  8767. 'CalRGBCS',
  8768. whitePoint,
  8769. blackPoint,
  8770. gamma,
  8771. matrix
  8772. ];
  8773. case 'ICCBased':
  8774. var stream = xref.fetchIfRef(cs[1]);
  8775. var dict = stream.dict;
  8776. numComps = dict.get('N');
  8777. alt = dict.get('Alternate');
  8778. if (alt) {
  8779. var altIR = ColorSpace.parseToIR(alt, xref, res);
  8780. var altCS = ColorSpace.fromIR(altIR);
  8781. if (altCS.numComps === numComps) {
  8782. return altIR;
  8783. }
  8784. warn('ICCBased color space: Ignoring incorrect /Alternate entry.');
  8785. }
  8786. if (numComps === 1) {
  8787. return 'DeviceGrayCS';
  8788. } else if (numComps === 3) {
  8789. return 'DeviceRgbCS';
  8790. } else if (numComps === 4) {
  8791. return 'DeviceCmykCS';
  8792. }
  8793. break;
  8794. case 'Pattern':
  8795. var basePatternCS = cs[1] || null;
  8796. if (basePatternCS) {
  8797. basePatternCS = ColorSpace.parseToIR(basePatternCS, xref, res);
  8798. }
  8799. return [
  8800. 'PatternCS',
  8801. basePatternCS
  8802. ];
  8803. case 'Indexed':
  8804. case 'I':
  8805. var baseIndexedCS = ColorSpace.parseToIR(cs[1], xref, res);
  8806. var hiVal = xref.fetchIfRef(cs[2]) + 1;
  8807. var lookup = xref.fetchIfRef(cs[3]);
  8808. if (isStream(lookup)) {
  8809. lookup = lookup.getBytes();
  8810. }
  8811. return [
  8812. 'IndexedCS',
  8813. baseIndexedCS,
  8814. hiVal,
  8815. lookup
  8816. ];
  8817. case 'Separation':
  8818. case 'DeviceN':
  8819. var name = xref.fetchIfRef(cs[1]);
  8820. numComps = isArray(name) ? name.length : 1;
  8821. alt = ColorSpace.parseToIR(cs[2], xref, res);
  8822. var tintFnIR = PDFFunction.getIR(xref, xref.fetchIfRef(cs[3]));
  8823. return [
  8824. 'AlternateCS',
  8825. numComps,
  8826. alt,
  8827. tintFnIR
  8828. ];
  8829. case 'Lab':
  8830. params = xref.fetchIfRef(cs[1]);
  8831. whitePoint = params.getArray('WhitePoint');
  8832. blackPoint = params.getArray('BlackPoint');
  8833. var range = params.getArray('Range');
  8834. return [
  8835. 'LabCS',
  8836. whitePoint,
  8837. blackPoint,
  8838. range
  8839. ];
  8840. default:
  8841. error('unimplemented color space object "' + mode + '"');
  8842. }
  8843. } else {
  8844. error('unrecognized color space object: "' + cs + '"');
  8845. }
  8846. return null;
  8847. };
  8848. ColorSpace.isDefaultDecode = function ColorSpace_isDefaultDecode(decode, n) {
  8849. if (!isArray(decode)) {
  8850. return true;
  8851. }
  8852. if (n * 2 !== decode.length) {
  8853. warn('The decode map is not the correct length');
  8854. return true;
  8855. }
  8856. for (var i = 0, ii = decode.length; i < ii; i += 2) {
  8857. if (decode[i] !== 0 || decode[i + 1] !== 1) {
  8858. return false;
  8859. }
  8860. }
  8861. return true;
  8862. };
  8863. ColorSpace.singletons = {
  8864. get gray() {
  8865. return shadow(this, 'gray', new DeviceGrayCS());
  8866. },
  8867. get rgb() {
  8868. return shadow(this, 'rgb', new DeviceRgbCS());
  8869. },
  8870. get cmyk() {
  8871. return shadow(this, 'cmyk', new DeviceCmykCS());
  8872. }
  8873. };
  8874. return ColorSpace;
  8875. }();
  8876. var AlternateCS = function AlternateCSClosure() {
  8877. function AlternateCS(numComps, base, tintFn) {
  8878. this.name = 'Alternate';
  8879. this.numComps = numComps;
  8880. this.defaultColor = new Float32Array(numComps);
  8881. for (var i = 0; i < numComps; ++i) {
  8882. this.defaultColor[i] = 1;
  8883. }
  8884. this.base = base;
  8885. this.tintFn = tintFn;
  8886. this.tmpBuf = new Float32Array(base.numComps);
  8887. }
  8888. AlternateCS.prototype = {
  8889. getRgb: ColorSpace.prototype.getRgb,
  8890. getRgbItem: function AlternateCS_getRgbItem(src, srcOffset, dest, destOffset) {
  8891. var tmpBuf = this.tmpBuf;
  8892. this.tintFn(src, srcOffset, tmpBuf, 0);
  8893. this.base.getRgbItem(tmpBuf, 0, dest, destOffset);
  8894. },
  8895. getRgbBuffer: function AlternateCS_getRgbBuffer(src, srcOffset, count, dest, destOffset, bits, alpha01) {
  8896. var tintFn = this.tintFn;
  8897. var base = this.base;
  8898. var scale = 1 / ((1 << bits) - 1);
  8899. var baseNumComps = base.numComps;
  8900. var usesZeroToOneRange = base.usesZeroToOneRange;
  8901. var isPassthrough = (base.isPassthrough(8) || !usesZeroToOneRange) && alpha01 === 0;
  8902. var pos = isPassthrough ? destOffset : 0;
  8903. var baseBuf = isPassthrough ? dest : new Uint8Array(baseNumComps * count);
  8904. var numComps = this.numComps;
  8905. var scaled = new Float32Array(numComps);
  8906. var tinted = new Float32Array(baseNumComps);
  8907. var i, j;
  8908. for (i = 0; i < count; i++) {
  8909. for (j = 0; j < numComps; j++) {
  8910. scaled[j] = src[srcOffset++] * scale;
  8911. }
  8912. tintFn(scaled, 0, tinted, 0);
  8913. if (usesZeroToOneRange) {
  8914. for (j = 0; j < baseNumComps; j++) {
  8915. baseBuf[pos++] = tinted[j] * 255;
  8916. }
  8917. } else {
  8918. base.getRgbItem(tinted, 0, baseBuf, pos);
  8919. pos += baseNumComps;
  8920. }
  8921. }
  8922. if (!isPassthrough) {
  8923. base.getRgbBuffer(baseBuf, 0, count, dest, destOffset, 8, alpha01);
  8924. }
  8925. },
  8926. getOutputLength: function AlternateCS_getOutputLength(inputLength, alpha01) {
  8927. return this.base.getOutputLength(inputLength * this.base.numComps / this.numComps, alpha01);
  8928. },
  8929. isPassthrough: ColorSpace.prototype.isPassthrough,
  8930. fillRgb: ColorSpace.prototype.fillRgb,
  8931. isDefaultDecode: function AlternateCS_isDefaultDecode(decodeMap) {
  8932. return ColorSpace.isDefaultDecode(decodeMap, this.numComps);
  8933. },
  8934. usesZeroToOneRange: true
  8935. };
  8936. return AlternateCS;
  8937. }();
  8938. var PatternCS = function PatternCSClosure() {
  8939. function PatternCS(baseCS) {
  8940. this.name = 'Pattern';
  8941. this.base = baseCS;
  8942. }
  8943. PatternCS.prototype = {};
  8944. return PatternCS;
  8945. }();
  8946. var IndexedCS = function IndexedCSClosure() {
  8947. function IndexedCS(base, highVal, lookup) {
  8948. this.name = 'Indexed';
  8949. this.numComps = 1;
  8950. this.defaultColor = new Uint8Array(this.numComps);
  8951. this.base = base;
  8952. this.highVal = highVal;
  8953. var baseNumComps = base.numComps;
  8954. var length = baseNumComps * highVal;
  8955. if (isStream(lookup)) {
  8956. this.lookup = new Uint8Array(length);
  8957. var bytes = lookup.getBytes(length);
  8958. this.lookup.set(bytes);
  8959. } else if (isString(lookup)) {
  8960. this.lookup = new Uint8Array(length);
  8961. for (var i = 0; i < length; ++i) {
  8962. this.lookup[i] = lookup.charCodeAt(i);
  8963. }
  8964. } else if (lookup instanceof Uint8Array || lookup instanceof Array) {
  8965. this.lookup = lookup;
  8966. } else {
  8967. error('Unrecognized lookup table: ' + lookup);
  8968. }
  8969. }
  8970. IndexedCS.prototype = {
  8971. getRgb: ColorSpace.prototype.getRgb,
  8972. getRgbItem: function IndexedCS_getRgbItem(src, srcOffset, dest, destOffset) {
  8973. var numComps = this.base.numComps;
  8974. var start = src[srcOffset] * numComps;
  8975. this.base.getRgbItem(this.lookup, start, dest, destOffset);
  8976. },
  8977. getRgbBuffer: function IndexedCS_getRgbBuffer(src, srcOffset, count, dest, destOffset, bits, alpha01) {
  8978. var base = this.base;
  8979. var numComps = base.numComps;
  8980. var outputDelta = base.getOutputLength(numComps, alpha01);
  8981. var lookup = this.lookup;
  8982. for (var i = 0; i < count; ++i) {
  8983. var lookupPos = src[srcOffset++] * numComps;
  8984. base.getRgbBuffer(lookup, lookupPos, 1, dest, destOffset, 8, alpha01);
  8985. destOffset += outputDelta;
  8986. }
  8987. },
  8988. getOutputLength: function IndexedCS_getOutputLength(inputLength, alpha01) {
  8989. return this.base.getOutputLength(inputLength * this.base.numComps, alpha01);
  8990. },
  8991. isPassthrough: ColorSpace.prototype.isPassthrough,
  8992. fillRgb: ColorSpace.prototype.fillRgb,
  8993. isDefaultDecode: function IndexedCS_isDefaultDecode(decodeMap) {
  8994. return true;
  8995. },
  8996. usesZeroToOneRange: true
  8997. };
  8998. return IndexedCS;
  8999. }();
  9000. var DeviceGrayCS = function DeviceGrayCSClosure() {
  9001. function DeviceGrayCS() {
  9002. this.name = 'DeviceGray';
  9003. this.numComps = 1;
  9004. this.defaultColor = new Float32Array(this.numComps);
  9005. }
  9006. DeviceGrayCS.prototype = {
  9007. getRgb: ColorSpace.prototype.getRgb,
  9008. getRgbItem: function DeviceGrayCS_getRgbItem(src, srcOffset, dest, destOffset) {
  9009. var c = src[srcOffset] * 255 | 0;
  9010. c = c < 0 ? 0 : c > 255 ? 255 : c;
  9011. dest[destOffset] = dest[destOffset + 1] = dest[destOffset + 2] = c;
  9012. },
  9013. getRgbBuffer: function DeviceGrayCS_getRgbBuffer(src, srcOffset, count, dest, destOffset, bits, alpha01) {
  9014. var scale = 255 / ((1 << bits) - 1);
  9015. var j = srcOffset, q = destOffset;
  9016. for (var i = 0; i < count; ++i) {
  9017. var c = scale * src[j++] | 0;
  9018. dest[q++] = c;
  9019. dest[q++] = c;
  9020. dest[q++] = c;
  9021. q += alpha01;
  9022. }
  9023. },
  9024. getOutputLength: function DeviceGrayCS_getOutputLength(inputLength, alpha01) {
  9025. return inputLength * (3 + alpha01);
  9026. },
  9027. isPassthrough: ColorSpace.prototype.isPassthrough,
  9028. fillRgb: ColorSpace.prototype.fillRgb,
  9029. isDefaultDecode: function DeviceGrayCS_isDefaultDecode(decodeMap) {
  9030. return ColorSpace.isDefaultDecode(decodeMap, this.numComps);
  9031. },
  9032. usesZeroToOneRange: true
  9033. };
  9034. return DeviceGrayCS;
  9035. }();
  9036. var DeviceRgbCS = function DeviceRgbCSClosure() {
  9037. function DeviceRgbCS() {
  9038. this.name = 'DeviceRGB';
  9039. this.numComps = 3;
  9040. this.defaultColor = new Float32Array(this.numComps);
  9041. }
  9042. DeviceRgbCS.prototype = {
  9043. getRgb: ColorSpace.prototype.getRgb,
  9044. getRgbItem: function DeviceRgbCS_getRgbItem(src, srcOffset, dest, destOffset) {
  9045. var r = src[srcOffset] * 255 | 0;
  9046. var g = src[srcOffset + 1] * 255 | 0;
  9047. var b = src[srcOffset + 2] * 255 | 0;
  9048. dest[destOffset] = r < 0 ? 0 : r > 255 ? 255 : r;
  9049. dest[destOffset + 1] = g < 0 ? 0 : g > 255 ? 255 : g;
  9050. dest[destOffset + 2] = b < 0 ? 0 : b > 255 ? 255 : b;
  9051. },
  9052. getRgbBuffer: function DeviceRgbCS_getRgbBuffer(src, srcOffset, count, dest, destOffset, bits, alpha01) {
  9053. if (bits === 8 && alpha01 === 0) {
  9054. dest.set(src.subarray(srcOffset, srcOffset + count * 3), destOffset);
  9055. return;
  9056. }
  9057. var scale = 255 / ((1 << bits) - 1);
  9058. var j = srcOffset, q = destOffset;
  9059. for (var i = 0; i < count; ++i) {
  9060. dest[q++] = scale * src[j++] | 0;
  9061. dest[q++] = scale * src[j++] | 0;
  9062. dest[q++] = scale * src[j++] | 0;
  9063. q += alpha01;
  9064. }
  9065. },
  9066. getOutputLength: function DeviceRgbCS_getOutputLength(inputLength, alpha01) {
  9067. return inputLength * (3 + alpha01) / 3 | 0;
  9068. },
  9069. isPassthrough: function DeviceRgbCS_isPassthrough(bits) {
  9070. return bits === 8;
  9071. },
  9072. fillRgb: ColorSpace.prototype.fillRgb,
  9073. isDefaultDecode: function DeviceRgbCS_isDefaultDecode(decodeMap) {
  9074. return ColorSpace.isDefaultDecode(decodeMap, this.numComps);
  9075. },
  9076. usesZeroToOneRange: true
  9077. };
  9078. return DeviceRgbCS;
  9079. }();
  9080. var DeviceCmykCS = function DeviceCmykCSClosure() {
  9081. function convertToRgb(src, srcOffset, srcScale, dest, destOffset) {
  9082. var c = src[srcOffset + 0] * srcScale;
  9083. var m = src[srcOffset + 1] * srcScale;
  9084. var y = src[srcOffset + 2] * srcScale;
  9085. var k = src[srcOffset + 3] * srcScale;
  9086. 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;
  9087. 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;
  9088. 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;
  9089. dest[destOffset] = r > 255 ? 255 : r < 0 ? 0 : r;
  9090. dest[destOffset + 1] = g > 255 ? 255 : g < 0 ? 0 : g;
  9091. dest[destOffset + 2] = b > 255 ? 255 : b < 0 ? 0 : b;
  9092. }
  9093. function DeviceCmykCS() {
  9094. this.name = 'DeviceCMYK';
  9095. this.numComps = 4;
  9096. this.defaultColor = new Float32Array(this.numComps);
  9097. this.defaultColor[3] = 1;
  9098. }
  9099. DeviceCmykCS.prototype = {
  9100. getRgb: ColorSpace.prototype.getRgb,
  9101. getRgbItem: function DeviceCmykCS_getRgbItem(src, srcOffset, dest, destOffset) {
  9102. convertToRgb(src, srcOffset, 1, dest, destOffset);
  9103. },
  9104. getRgbBuffer: function DeviceCmykCS_getRgbBuffer(src, srcOffset, count, dest, destOffset, bits, alpha01) {
  9105. var scale = 1 / ((1 << bits) - 1);
  9106. for (var i = 0; i < count; i++) {
  9107. convertToRgb(src, srcOffset, scale, dest, destOffset);
  9108. srcOffset += 4;
  9109. destOffset += 3 + alpha01;
  9110. }
  9111. },
  9112. getOutputLength: function DeviceCmykCS_getOutputLength(inputLength, alpha01) {
  9113. return inputLength / 4 * (3 + alpha01) | 0;
  9114. },
  9115. isPassthrough: ColorSpace.prototype.isPassthrough,
  9116. fillRgb: ColorSpace.prototype.fillRgb,
  9117. isDefaultDecode: function DeviceCmykCS_isDefaultDecode(decodeMap) {
  9118. return ColorSpace.isDefaultDecode(decodeMap, this.numComps);
  9119. },
  9120. usesZeroToOneRange: true
  9121. };
  9122. return DeviceCmykCS;
  9123. }();
  9124. var CalGrayCS = function CalGrayCSClosure() {
  9125. function CalGrayCS(whitePoint, blackPoint, gamma) {
  9126. this.name = 'CalGray';
  9127. this.numComps = 1;
  9128. this.defaultColor = new Float32Array(this.numComps);
  9129. if (!whitePoint) {
  9130. error('WhitePoint missing - required for color space CalGray');
  9131. }
  9132. blackPoint = blackPoint || [
  9133. 0,
  9134. 0,
  9135. 0
  9136. ];
  9137. gamma = gamma || 1;
  9138. this.XW = whitePoint[0];
  9139. this.YW = whitePoint[1];
  9140. this.ZW = whitePoint[2];
  9141. this.XB = blackPoint[0];
  9142. this.YB = blackPoint[1];
  9143. this.ZB = blackPoint[2];
  9144. this.G = gamma;
  9145. if (this.XW < 0 || this.ZW < 0 || this.YW !== 1) {
  9146. error('Invalid WhitePoint components for ' + this.name + ', no fallback available');
  9147. }
  9148. if (this.XB < 0 || this.YB < 0 || this.ZB < 0) {
  9149. info('Invalid BlackPoint for ' + this.name + ', falling back to default');
  9150. this.XB = this.YB = this.ZB = 0;
  9151. }
  9152. if (this.XB !== 0 || this.YB !== 0 || this.ZB !== 0) {
  9153. warn(this.name + ', BlackPoint: XB: ' + this.XB + ', YB: ' + this.YB + ', ZB: ' + this.ZB + ', only default values are supported.');
  9154. }
  9155. if (this.G < 1) {
  9156. info('Invalid Gamma: ' + this.G + ' for ' + this.name + ', falling back to default');
  9157. this.G = 1;
  9158. }
  9159. }
  9160. function convertToRgb(cs, src, srcOffset, dest, destOffset, scale) {
  9161. var A = src[srcOffset] * scale;
  9162. var AG = Math.pow(A, cs.G);
  9163. var L = cs.YW * AG;
  9164. var val = Math.max(295.8 * Math.pow(L, 0.333333333333333333) - 40.8, 0) | 0;
  9165. dest[destOffset] = val;
  9166. dest[destOffset + 1] = val;
  9167. dest[destOffset + 2] = val;
  9168. }
  9169. CalGrayCS.prototype = {
  9170. getRgb: ColorSpace.prototype.getRgb,
  9171. getRgbItem: function CalGrayCS_getRgbItem(src, srcOffset, dest, destOffset) {
  9172. convertToRgb(this, src, srcOffset, dest, destOffset, 1);
  9173. },
  9174. getRgbBuffer: function CalGrayCS_getRgbBuffer(src, srcOffset, count, dest, destOffset, bits, alpha01) {
  9175. var scale = 1 / ((1 << bits) - 1);
  9176. for (var i = 0; i < count; ++i) {
  9177. convertToRgb(this, src, srcOffset, dest, destOffset, scale);
  9178. srcOffset += 1;
  9179. destOffset += 3 + alpha01;
  9180. }
  9181. },
  9182. getOutputLength: function CalGrayCS_getOutputLength(inputLength, alpha01) {
  9183. return inputLength * (3 + alpha01);
  9184. },
  9185. isPassthrough: ColorSpace.prototype.isPassthrough,
  9186. fillRgb: ColorSpace.prototype.fillRgb,
  9187. isDefaultDecode: function CalGrayCS_isDefaultDecode(decodeMap) {
  9188. return ColorSpace.isDefaultDecode(decodeMap, this.numComps);
  9189. },
  9190. usesZeroToOneRange: true
  9191. };
  9192. return CalGrayCS;
  9193. }();
  9194. var CalRGBCS = function CalRGBCSClosure() {
  9195. var BRADFORD_SCALE_MATRIX = new Float32Array([
  9196. 0.8951,
  9197. 0.2664,
  9198. -0.1614,
  9199. -0.7502,
  9200. 1.7135,
  9201. 0.0367,
  9202. 0.0389,
  9203. -0.0685,
  9204. 1.0296
  9205. ]);
  9206. var BRADFORD_SCALE_INVERSE_MATRIX = new Float32Array([
  9207. 0.9869929,
  9208. -0.1470543,
  9209. 0.1599627,
  9210. 0.4323053,
  9211. 0.5183603,
  9212. 0.0492912,
  9213. -0.0085287,
  9214. 0.0400428,
  9215. 0.9684867
  9216. ]);
  9217. var SRGB_D65_XYZ_TO_RGB_MATRIX = new Float32Array([
  9218. 3.2404542,
  9219. -1.5371385,
  9220. -0.4985314,
  9221. -0.9692660,
  9222. 1.8760108,
  9223. 0.0415560,
  9224. 0.0556434,
  9225. -0.2040259,
  9226. 1.0572252
  9227. ]);
  9228. var FLAT_WHITEPOINT_MATRIX = new Float32Array([
  9229. 1,
  9230. 1,
  9231. 1
  9232. ]);
  9233. var tempNormalizeMatrix = new Float32Array(3);
  9234. var tempConvertMatrix1 = new Float32Array(3);
  9235. var tempConvertMatrix2 = new Float32Array(3);
  9236. var DECODE_L_CONSTANT = Math.pow((8 + 16) / 116, 3) / 8.0;
  9237. function CalRGBCS(whitePoint, blackPoint, gamma, matrix) {
  9238. this.name = 'CalRGB';
  9239. this.numComps = 3;
  9240. this.defaultColor = new Float32Array(this.numComps);
  9241. if (!whitePoint) {
  9242. error('WhitePoint missing - required for color space CalRGB');
  9243. }
  9244. blackPoint = blackPoint || new Float32Array(3);
  9245. gamma = gamma || new Float32Array([
  9246. 1,
  9247. 1,
  9248. 1
  9249. ]);
  9250. matrix = matrix || new Float32Array([
  9251. 1,
  9252. 0,
  9253. 0,
  9254. 0,
  9255. 1,
  9256. 0,
  9257. 0,
  9258. 0,
  9259. 1
  9260. ]);
  9261. var XW = whitePoint[0];
  9262. var YW = whitePoint[1];
  9263. var ZW = whitePoint[2];
  9264. this.whitePoint = whitePoint;
  9265. var XB = blackPoint[0];
  9266. var YB = blackPoint[1];
  9267. var ZB = blackPoint[2];
  9268. this.blackPoint = blackPoint;
  9269. this.GR = gamma[0];
  9270. this.GG = gamma[1];
  9271. this.GB = gamma[2];
  9272. this.MXA = matrix[0];
  9273. this.MYA = matrix[1];
  9274. this.MZA = matrix[2];
  9275. this.MXB = matrix[3];
  9276. this.MYB = matrix[4];
  9277. this.MZB = matrix[5];
  9278. this.MXC = matrix[6];
  9279. this.MYC = matrix[7];
  9280. this.MZC = matrix[8];
  9281. if (XW < 0 || ZW < 0 || YW !== 1) {
  9282. error('Invalid WhitePoint components for ' + this.name + ', no fallback available');
  9283. }
  9284. if (XB < 0 || YB < 0 || ZB < 0) {
  9285. info('Invalid BlackPoint for ' + this.name + ' [' + XB + ', ' + YB + ', ' + ZB + '], falling back to default');
  9286. this.blackPoint = new Float32Array(3);
  9287. }
  9288. if (this.GR < 0 || this.GG < 0 || this.GB < 0) {
  9289. info('Invalid Gamma [' + this.GR + ', ' + this.GG + ', ' + this.GB + '] for ' + this.name + ', falling back to default');
  9290. this.GR = this.GG = this.GB = 1;
  9291. }
  9292. 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) {
  9293. 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');
  9294. this.MXA = this.MYB = this.MZC = 1;
  9295. this.MXB = this.MYA = this.MZA = this.MXC = this.MYC = this.MZB = 0;
  9296. }
  9297. }
  9298. function matrixProduct(a, b, result) {
  9299. result[0] = a[0] * b[0] + a[1] * b[1] + a[2] * b[2];
  9300. result[1] = a[3] * b[0] + a[4] * b[1] + a[5] * b[2];
  9301. result[2] = a[6] * b[0] + a[7] * b[1] + a[8] * b[2];
  9302. }
  9303. function convertToFlat(sourceWhitePoint, LMS, result) {
  9304. result[0] = LMS[0] * 1 / sourceWhitePoint[0];
  9305. result[1] = LMS[1] * 1 / sourceWhitePoint[1];
  9306. result[2] = LMS[2] * 1 / sourceWhitePoint[2];
  9307. }
  9308. function convertToD65(sourceWhitePoint, LMS, result) {
  9309. var D65X = 0.95047;
  9310. var D65Y = 1;
  9311. var D65Z = 1.08883;
  9312. result[0] = LMS[0] * D65X / sourceWhitePoint[0];
  9313. result[1] = LMS[1] * D65Y / sourceWhitePoint[1];
  9314. result[2] = LMS[2] * D65Z / sourceWhitePoint[2];
  9315. }
  9316. function sRGBTransferFunction(color) {
  9317. if (color <= 0.0031308) {
  9318. return adjustToRange(0, 1, 12.92 * color);
  9319. }
  9320. return adjustToRange(0, 1, (1 + 0.055) * Math.pow(color, 1 / 2.4) - 0.055);
  9321. }
  9322. function adjustToRange(min, max, value) {
  9323. return Math.max(min, Math.min(max, value));
  9324. }
  9325. function decodeL(L) {
  9326. if (L < 0) {
  9327. return -decodeL(-L);
  9328. }
  9329. if (L > 8.0) {
  9330. return Math.pow((L + 16) / 116, 3);
  9331. }
  9332. return L * DECODE_L_CONSTANT;
  9333. }
  9334. function compensateBlackPoint(sourceBlackPoint, XYZ_Flat, result) {
  9335. if (sourceBlackPoint[0] === 0 && sourceBlackPoint[1] === 0 && sourceBlackPoint[2] === 0) {
  9336. result[0] = XYZ_Flat[0];
  9337. result[1] = XYZ_Flat[1];
  9338. result[2] = XYZ_Flat[2];
  9339. return;
  9340. }
  9341. var zeroDecodeL = decodeL(0);
  9342. var X_DST = zeroDecodeL;
  9343. var X_SRC = decodeL(sourceBlackPoint[0]);
  9344. var Y_DST = zeroDecodeL;
  9345. var Y_SRC = decodeL(sourceBlackPoint[1]);
  9346. var Z_DST = zeroDecodeL;
  9347. var Z_SRC = decodeL(sourceBlackPoint[2]);
  9348. var X_Scale = (1 - X_DST) / (1 - X_SRC);
  9349. var X_Offset = 1 - X_Scale;
  9350. var Y_Scale = (1 - Y_DST) / (1 - Y_SRC);
  9351. var Y_Offset = 1 - Y_Scale;
  9352. var Z_Scale = (1 - Z_DST) / (1 - Z_SRC);
  9353. var Z_Offset = 1 - Z_Scale;
  9354. result[0] = XYZ_Flat[0] * X_Scale + X_Offset;
  9355. result[1] = XYZ_Flat[1] * Y_Scale + Y_Offset;
  9356. result[2] = XYZ_Flat[2] * Z_Scale + Z_Offset;
  9357. }
  9358. function normalizeWhitePointToFlat(sourceWhitePoint, XYZ_In, result) {
  9359. if (sourceWhitePoint[0] === 1 && sourceWhitePoint[2] === 1) {
  9360. result[0] = XYZ_In[0];
  9361. result[1] = XYZ_In[1];
  9362. result[2] = XYZ_In[2];
  9363. return;
  9364. }
  9365. var LMS = result;
  9366. matrixProduct(BRADFORD_SCALE_MATRIX, XYZ_In, LMS);
  9367. var LMS_Flat = tempNormalizeMatrix;
  9368. convertToFlat(sourceWhitePoint, LMS, LMS_Flat);
  9369. matrixProduct(BRADFORD_SCALE_INVERSE_MATRIX, LMS_Flat, result);
  9370. }
  9371. function normalizeWhitePointToD65(sourceWhitePoint, XYZ_In, result) {
  9372. var LMS = result;
  9373. matrixProduct(BRADFORD_SCALE_MATRIX, XYZ_In, LMS);
  9374. var LMS_D65 = tempNormalizeMatrix;
  9375. convertToD65(sourceWhitePoint, LMS, LMS_D65);
  9376. matrixProduct(BRADFORD_SCALE_INVERSE_MATRIX, LMS_D65, result);
  9377. }
  9378. function convertToRgb(cs, src, srcOffset, dest, destOffset, scale) {
  9379. var A = adjustToRange(0, 1, src[srcOffset] * scale);
  9380. var B = adjustToRange(0, 1, src[srcOffset + 1] * scale);
  9381. var C = adjustToRange(0, 1, src[srcOffset + 2] * scale);
  9382. var AGR = Math.pow(A, cs.GR);
  9383. var BGG = Math.pow(B, cs.GG);
  9384. var CGB = Math.pow(C, cs.GB);
  9385. var X = cs.MXA * AGR + cs.MXB * BGG + cs.MXC * CGB;
  9386. var Y = cs.MYA * AGR + cs.MYB * BGG + cs.MYC * CGB;
  9387. var Z = cs.MZA * AGR + cs.MZB * BGG + cs.MZC * CGB;
  9388. var XYZ = tempConvertMatrix1;
  9389. XYZ[0] = X;
  9390. XYZ[1] = Y;
  9391. XYZ[2] = Z;
  9392. var XYZ_Flat = tempConvertMatrix2;
  9393. normalizeWhitePointToFlat(cs.whitePoint, XYZ, XYZ_Flat);
  9394. var XYZ_Black = tempConvertMatrix1;
  9395. compensateBlackPoint(cs.blackPoint, XYZ_Flat, XYZ_Black);
  9396. var XYZ_D65 = tempConvertMatrix2;
  9397. normalizeWhitePointToD65(FLAT_WHITEPOINT_MATRIX, XYZ_Black, XYZ_D65);
  9398. var SRGB = tempConvertMatrix1;
  9399. matrixProduct(SRGB_D65_XYZ_TO_RGB_MATRIX, XYZ_D65, SRGB);
  9400. var sR = sRGBTransferFunction(SRGB[0]);
  9401. var sG = sRGBTransferFunction(SRGB[1]);
  9402. var sB = sRGBTransferFunction(SRGB[2]);
  9403. dest[destOffset] = Math.round(sR * 255);
  9404. dest[destOffset + 1] = Math.round(sG * 255);
  9405. dest[destOffset + 2] = Math.round(sB * 255);
  9406. }
  9407. CalRGBCS.prototype = {
  9408. getRgb: function CalRGBCS_getRgb(src, srcOffset) {
  9409. var rgb = new Uint8Array(3);
  9410. this.getRgbItem(src, srcOffset, rgb, 0);
  9411. return rgb;
  9412. },
  9413. getRgbItem: function CalRGBCS_getRgbItem(src, srcOffset, dest, destOffset) {
  9414. convertToRgb(this, src, srcOffset, dest, destOffset, 1);
  9415. },
  9416. getRgbBuffer: function CalRGBCS_getRgbBuffer(src, srcOffset, count, dest, destOffset, bits, alpha01) {
  9417. var scale = 1 / ((1 << bits) - 1);
  9418. for (var i = 0; i < count; ++i) {
  9419. convertToRgb(this, src, srcOffset, dest, destOffset, scale);
  9420. srcOffset += 3;
  9421. destOffset += 3 + alpha01;
  9422. }
  9423. },
  9424. getOutputLength: function CalRGBCS_getOutputLength(inputLength, alpha01) {
  9425. return inputLength * (3 + alpha01) / 3 | 0;
  9426. },
  9427. isPassthrough: ColorSpace.prototype.isPassthrough,
  9428. fillRgb: ColorSpace.prototype.fillRgb,
  9429. isDefaultDecode: function CalRGBCS_isDefaultDecode(decodeMap) {
  9430. return ColorSpace.isDefaultDecode(decodeMap, this.numComps);
  9431. },
  9432. usesZeroToOneRange: true
  9433. };
  9434. return CalRGBCS;
  9435. }();
  9436. var LabCS = function LabCSClosure() {
  9437. function LabCS(whitePoint, blackPoint, range) {
  9438. this.name = 'Lab';
  9439. this.numComps = 3;
  9440. this.defaultColor = new Float32Array(this.numComps);
  9441. if (!whitePoint) {
  9442. error('WhitePoint missing - required for color space Lab');
  9443. }
  9444. blackPoint = blackPoint || [
  9445. 0,
  9446. 0,
  9447. 0
  9448. ];
  9449. range = range || [
  9450. -100,
  9451. 100,
  9452. -100,
  9453. 100
  9454. ];
  9455. this.XW = whitePoint[0];
  9456. this.YW = whitePoint[1];
  9457. this.ZW = whitePoint[2];
  9458. this.amin = range[0];
  9459. this.amax = range[1];
  9460. this.bmin = range[2];
  9461. this.bmax = range[3];
  9462. this.XB = blackPoint[0];
  9463. this.YB = blackPoint[1];
  9464. this.ZB = blackPoint[2];
  9465. if (this.XW < 0 || this.ZW < 0 || this.YW !== 1) {
  9466. error('Invalid WhitePoint components, no fallback available');
  9467. }
  9468. if (this.XB < 0 || this.YB < 0 || this.ZB < 0) {
  9469. info('Invalid BlackPoint, falling back to default');
  9470. this.XB = this.YB = this.ZB = 0;
  9471. }
  9472. if (this.amin > this.amax || this.bmin > this.bmax) {
  9473. info('Invalid Range, falling back to defaults');
  9474. this.amin = -100;
  9475. this.amax = 100;
  9476. this.bmin = -100;
  9477. this.bmax = 100;
  9478. }
  9479. }
  9480. function fn_g(x) {
  9481. var result;
  9482. if (x >= 6 / 29) {
  9483. result = x * x * x;
  9484. } else {
  9485. result = 108 / 841 * (x - 4 / 29);
  9486. }
  9487. return result;
  9488. }
  9489. function decode(value, high1, low2, high2) {
  9490. return low2 + value * (high2 - low2) / high1;
  9491. }
  9492. function convertToRgb(cs, src, srcOffset, maxVal, dest, destOffset) {
  9493. var Ls = src[srcOffset];
  9494. var as = src[srcOffset + 1];
  9495. var bs = src[srcOffset + 2];
  9496. if (maxVal !== false) {
  9497. Ls = decode(Ls, maxVal, 0, 100);
  9498. as = decode(as, maxVal, cs.amin, cs.amax);
  9499. bs = decode(bs, maxVal, cs.bmin, cs.bmax);
  9500. }
  9501. as = as > cs.amax ? cs.amax : as < cs.amin ? cs.amin : as;
  9502. bs = bs > cs.bmax ? cs.bmax : bs < cs.bmin ? cs.bmin : bs;
  9503. var M = (Ls + 16) / 116;
  9504. var L = M + as / 500;
  9505. var N = M - bs / 200;
  9506. var X = cs.XW * fn_g(L);
  9507. var Y = cs.YW * fn_g(M);
  9508. var Z = cs.ZW * fn_g(N);
  9509. var r, g, b;
  9510. if (cs.ZW < 1) {
  9511. r = X * 3.1339 + Y * -1.6170 + Z * -0.4906;
  9512. g = X * -0.9785 + Y * 1.9160 + Z * 0.0333;
  9513. b = X * 0.0720 + Y * -0.2290 + Z * 1.4057;
  9514. } else {
  9515. r = X * 3.2406 + Y * -1.5372 + Z * -0.4986;
  9516. g = X * -0.9689 + Y * 1.8758 + Z * 0.0415;
  9517. b = X * 0.0557 + Y * -0.2040 + Z * 1.0570;
  9518. }
  9519. dest[destOffset] = r <= 0 ? 0 : r >= 1 ? 255 : Math.sqrt(r) * 255 | 0;
  9520. dest[destOffset + 1] = g <= 0 ? 0 : g >= 1 ? 255 : Math.sqrt(g) * 255 | 0;
  9521. dest[destOffset + 2] = b <= 0 ? 0 : b >= 1 ? 255 : Math.sqrt(b) * 255 | 0;
  9522. }
  9523. LabCS.prototype = {
  9524. getRgb: ColorSpace.prototype.getRgb,
  9525. getRgbItem: function LabCS_getRgbItem(src, srcOffset, dest, destOffset) {
  9526. convertToRgb(this, src, srcOffset, false, dest, destOffset);
  9527. },
  9528. getRgbBuffer: function LabCS_getRgbBuffer(src, srcOffset, count, dest, destOffset, bits, alpha01) {
  9529. var maxVal = (1 << bits) - 1;
  9530. for (var i = 0; i < count; i++) {
  9531. convertToRgb(this, src, srcOffset, maxVal, dest, destOffset);
  9532. srcOffset += 3;
  9533. destOffset += 3 + alpha01;
  9534. }
  9535. },
  9536. getOutputLength: function LabCS_getOutputLength(inputLength, alpha01) {
  9537. return inputLength * (3 + alpha01) / 3 | 0;
  9538. },
  9539. isPassthrough: ColorSpace.prototype.isPassthrough,
  9540. fillRgb: ColorSpace.prototype.fillRgb,
  9541. isDefaultDecode: function LabCS_isDefaultDecode(decodeMap) {
  9542. return true;
  9543. },
  9544. usesZeroToOneRange: false
  9545. };
  9546. return LabCS;
  9547. }();
  9548. exports.ColorSpace = ColorSpace;
  9549. /***/ }),
  9550. /* 5 */
  9551. /***/ (function(module, exports, __w_pdfjs_require__) {
  9552. "use strict";
  9553. var ExpertEncoding = [
  9554. '',
  9555. '',
  9556. '',
  9557. '',
  9558. '',
  9559. '',
  9560. '',
  9561. '',
  9562. '',
  9563. '',
  9564. '',
  9565. '',
  9566. '',
  9567. '',
  9568. '',
  9569. '',
  9570. '',
  9571. '',
  9572. '',
  9573. '',
  9574. '',
  9575. '',
  9576. '',
  9577. '',
  9578. '',
  9579. '',
  9580. '',
  9581. '',
  9582. '',
  9583. '',
  9584. '',
  9585. '',
  9586. 'space',
  9587. 'exclamsmall',
  9588. 'Hungarumlautsmall',
  9589. '',
  9590. 'dollaroldstyle',
  9591. 'dollarsuperior',
  9592. 'ampersandsmall',
  9593. 'Acutesmall',
  9594. 'parenleftsuperior',
  9595. 'parenrightsuperior',
  9596. 'twodotenleader',
  9597. 'onedotenleader',
  9598. 'comma',
  9599. 'hyphen',
  9600. 'period',
  9601. 'fraction',
  9602. 'zerooldstyle',
  9603. 'oneoldstyle',
  9604. 'twooldstyle',
  9605. 'threeoldstyle',
  9606. 'fouroldstyle',
  9607. 'fiveoldstyle',
  9608. 'sixoldstyle',
  9609. 'sevenoldstyle',
  9610. 'eightoldstyle',
  9611. 'nineoldstyle',
  9612. 'colon',
  9613. 'semicolon',
  9614. 'commasuperior',
  9615. 'threequartersemdash',
  9616. 'periodsuperior',
  9617. 'questionsmall',
  9618. '',
  9619. 'asuperior',
  9620. 'bsuperior',
  9621. 'centsuperior',
  9622. 'dsuperior',
  9623. 'esuperior',
  9624. '',
  9625. '',
  9626. 'isuperior',
  9627. '',
  9628. '',
  9629. 'lsuperior',
  9630. 'msuperior',
  9631. 'nsuperior',
  9632. 'osuperior',
  9633. '',
  9634. '',
  9635. 'rsuperior',
  9636. 'ssuperior',
  9637. 'tsuperior',
  9638. '',
  9639. 'ff',
  9640. 'fi',
  9641. 'fl',
  9642. 'ffi',
  9643. 'ffl',
  9644. 'parenleftinferior',
  9645. '',
  9646. 'parenrightinferior',
  9647. 'Circumflexsmall',
  9648. 'hyphensuperior',
  9649. 'Gravesmall',
  9650. 'Asmall',
  9651. 'Bsmall',
  9652. 'Csmall',
  9653. 'Dsmall',
  9654. 'Esmall',
  9655. 'Fsmall',
  9656. 'Gsmall',
  9657. 'Hsmall',
  9658. 'Ismall',
  9659. 'Jsmall',
  9660. 'Ksmall',
  9661. 'Lsmall',
  9662. 'Msmall',
  9663. 'Nsmall',
  9664. 'Osmall',
  9665. 'Psmall',
  9666. 'Qsmall',
  9667. 'Rsmall',
  9668. 'Ssmall',
  9669. 'Tsmall',
  9670. 'Usmall',
  9671. 'Vsmall',
  9672. 'Wsmall',
  9673. 'Xsmall',
  9674. 'Ysmall',
  9675. 'Zsmall',
  9676. 'colonmonetary',
  9677. 'onefitted',
  9678. 'rupiah',
  9679. 'Tildesmall',
  9680. '',
  9681. '',
  9682. '',
  9683. '',
  9684. '',
  9685. '',
  9686. '',
  9687. '',
  9688. '',
  9689. '',
  9690. '',
  9691. '',
  9692. '',
  9693. '',
  9694. '',
  9695. '',
  9696. '',
  9697. '',
  9698. '',
  9699. '',
  9700. '',
  9701. '',
  9702. '',
  9703. '',
  9704. '',
  9705. '',
  9706. '',
  9707. '',
  9708. '',
  9709. '',
  9710. '',
  9711. '',
  9712. '',
  9713. '',
  9714. 'exclamdownsmall',
  9715. 'centoldstyle',
  9716. 'Lslashsmall',
  9717. '',
  9718. '',
  9719. 'Scaronsmall',
  9720. 'Zcaronsmall',
  9721. 'Dieresissmall',
  9722. 'Brevesmall',
  9723. 'Caronsmall',
  9724. '',
  9725. 'Dotaccentsmall',
  9726. '',
  9727. '',
  9728. 'Macronsmall',
  9729. '',
  9730. '',
  9731. 'figuredash',
  9732. 'hypheninferior',
  9733. '',
  9734. '',
  9735. 'Ogoneksmall',
  9736. 'Ringsmall',
  9737. 'Cedillasmall',
  9738. '',
  9739. '',
  9740. '',
  9741. 'onequarter',
  9742. 'onehalf',
  9743. 'threequarters',
  9744. 'questiondownsmall',
  9745. 'oneeighth',
  9746. 'threeeighths',
  9747. 'fiveeighths',
  9748. 'seveneighths',
  9749. 'onethird',
  9750. 'twothirds',
  9751. '',
  9752. '',
  9753. 'zerosuperior',
  9754. 'onesuperior',
  9755. 'twosuperior',
  9756. 'threesuperior',
  9757. 'foursuperior',
  9758. 'fivesuperior',
  9759. 'sixsuperior',
  9760. 'sevensuperior',
  9761. 'eightsuperior',
  9762. 'ninesuperior',
  9763. 'zeroinferior',
  9764. 'oneinferior',
  9765. 'twoinferior',
  9766. 'threeinferior',
  9767. 'fourinferior',
  9768. 'fiveinferior',
  9769. 'sixinferior',
  9770. 'seveninferior',
  9771. 'eightinferior',
  9772. 'nineinferior',
  9773. 'centinferior',
  9774. 'dollarinferior',
  9775. 'periodinferior',
  9776. 'commainferior',
  9777. 'Agravesmall',
  9778. 'Aacutesmall',
  9779. 'Acircumflexsmall',
  9780. 'Atildesmall',
  9781. 'Adieresissmall',
  9782. 'Aringsmall',
  9783. 'AEsmall',
  9784. 'Ccedillasmall',
  9785. 'Egravesmall',
  9786. 'Eacutesmall',
  9787. 'Ecircumflexsmall',
  9788. 'Edieresissmall',
  9789. 'Igravesmall',
  9790. 'Iacutesmall',
  9791. 'Icircumflexsmall',
  9792. 'Idieresissmall',
  9793. 'Ethsmall',
  9794. 'Ntildesmall',
  9795. 'Ogravesmall',
  9796. 'Oacutesmall',
  9797. 'Ocircumflexsmall',
  9798. 'Otildesmall',
  9799. 'Odieresissmall',
  9800. 'OEsmall',
  9801. 'Oslashsmall',
  9802. 'Ugravesmall',
  9803. 'Uacutesmall',
  9804. 'Ucircumflexsmall',
  9805. 'Udieresissmall',
  9806. 'Yacutesmall',
  9807. 'Thornsmall',
  9808. 'Ydieresissmall'
  9809. ];
  9810. var MacExpertEncoding = [
  9811. '',
  9812. '',
  9813. '',
  9814. '',
  9815. '',
  9816. '',
  9817. '',
  9818. '',
  9819. '',
  9820. '',
  9821. '',
  9822. '',
  9823. '',
  9824. '',
  9825. '',
  9826. '',
  9827. '',
  9828. '',
  9829. '',
  9830. '',
  9831. '',
  9832. '',
  9833. '',
  9834. '',
  9835. '',
  9836. '',
  9837. '',
  9838. '',
  9839. '',
  9840. '',
  9841. '',
  9842. '',
  9843. 'space',
  9844. 'exclamsmall',
  9845. 'Hungarumlautsmall',
  9846. 'centoldstyle',
  9847. 'dollaroldstyle',
  9848. 'dollarsuperior',
  9849. 'ampersandsmall',
  9850. 'Acutesmall',
  9851. 'parenleftsuperior',
  9852. 'parenrightsuperior',
  9853. 'twodotenleader',
  9854. 'onedotenleader',
  9855. 'comma',
  9856. 'hyphen',
  9857. 'period',
  9858. 'fraction',
  9859. 'zerooldstyle',
  9860. 'oneoldstyle',
  9861. 'twooldstyle',
  9862. 'threeoldstyle',
  9863. 'fouroldstyle',
  9864. 'fiveoldstyle',
  9865. 'sixoldstyle',
  9866. 'sevenoldstyle',
  9867. 'eightoldstyle',
  9868. 'nineoldstyle',
  9869. 'colon',
  9870. 'semicolon',
  9871. '',
  9872. 'threequartersemdash',
  9873. '',
  9874. 'questionsmall',
  9875. '',
  9876. '',
  9877. '',
  9878. '',
  9879. 'Ethsmall',
  9880. '',
  9881. '',
  9882. 'onequarter',
  9883. 'onehalf',
  9884. 'threequarters',
  9885. 'oneeighth',
  9886. 'threeeighths',
  9887. 'fiveeighths',
  9888. 'seveneighths',
  9889. 'onethird',
  9890. 'twothirds',
  9891. '',
  9892. '',
  9893. '',
  9894. '',
  9895. '',
  9896. '',
  9897. 'ff',
  9898. 'fi',
  9899. 'fl',
  9900. 'ffi',
  9901. 'ffl',
  9902. 'parenleftinferior',
  9903. '',
  9904. 'parenrightinferior',
  9905. 'Circumflexsmall',
  9906. 'hypheninferior',
  9907. 'Gravesmall',
  9908. 'Asmall',
  9909. 'Bsmall',
  9910. 'Csmall',
  9911. 'Dsmall',
  9912. 'Esmall',
  9913. 'Fsmall',
  9914. 'Gsmall',
  9915. 'Hsmall',
  9916. 'Ismall',
  9917. 'Jsmall',
  9918. 'Ksmall',
  9919. 'Lsmall',
  9920. 'Msmall',
  9921. 'Nsmall',
  9922. 'Osmall',
  9923. 'Psmall',
  9924. 'Qsmall',
  9925. 'Rsmall',
  9926. 'Ssmall',
  9927. 'Tsmall',
  9928. 'Usmall',
  9929. 'Vsmall',
  9930. 'Wsmall',
  9931. 'Xsmall',
  9932. 'Ysmall',
  9933. 'Zsmall',
  9934. 'colonmonetary',
  9935. 'onefitted',
  9936. 'rupiah',
  9937. 'Tildesmall',
  9938. '',
  9939. '',
  9940. 'asuperior',
  9941. 'centsuperior',
  9942. '',
  9943. '',
  9944. '',
  9945. '',
  9946. 'Aacutesmall',
  9947. 'Agravesmall',
  9948. 'Acircumflexsmall',
  9949. 'Adieresissmall',
  9950. 'Atildesmall',
  9951. 'Aringsmall',
  9952. 'Ccedillasmall',
  9953. 'Eacutesmall',
  9954. 'Egravesmall',
  9955. 'Ecircumflexsmall',
  9956. 'Edieresissmall',
  9957. 'Iacutesmall',
  9958. 'Igravesmall',
  9959. 'Icircumflexsmall',
  9960. 'Idieresissmall',
  9961. 'Ntildesmall',
  9962. 'Oacutesmall',
  9963. 'Ogravesmall',
  9964. 'Ocircumflexsmall',
  9965. 'Odieresissmall',
  9966. 'Otildesmall',
  9967. 'Uacutesmall',
  9968. 'Ugravesmall',
  9969. 'Ucircumflexsmall',
  9970. 'Udieresissmall',
  9971. '',
  9972. 'eightsuperior',
  9973. 'fourinferior',
  9974. 'threeinferior',
  9975. 'sixinferior',
  9976. 'eightinferior',
  9977. 'seveninferior',
  9978. 'Scaronsmall',
  9979. '',
  9980. 'centinferior',
  9981. 'twoinferior',
  9982. '',
  9983. 'Dieresissmall',
  9984. '',
  9985. 'Caronsmall',
  9986. 'osuperior',
  9987. 'fiveinferior',
  9988. '',
  9989. 'commainferior',
  9990. 'periodinferior',
  9991. 'Yacutesmall',
  9992. '',
  9993. 'dollarinferior',
  9994. '',
  9995. 'Thornsmall',
  9996. '',
  9997. 'nineinferior',
  9998. 'zeroinferior',
  9999. 'Zcaronsmall',
  10000. 'AEsmall',
  10001. 'Oslashsmall',
  10002. 'questiondownsmall',
  10003. 'oneinferior',
  10004. 'Lslashsmall',
  10005. '',
  10006. '',
  10007. '',
  10008. '',
  10009. '',
  10010. '',
  10011. 'Cedillasmall',
  10012. '',
  10013. '',
  10014. '',
  10015. '',
  10016. '',
  10017. 'OEsmall',
  10018. 'figuredash',
  10019. 'hyphensuperior',
  10020. '',
  10021. '',
  10022. '',
  10023. '',
  10024. 'exclamdownsmall',
  10025. '',
  10026. 'Ydieresissmall',
  10027. '',
  10028. 'onesuperior',
  10029. 'twosuperior',
  10030. 'threesuperior',
  10031. 'foursuperior',
  10032. 'fivesuperior',
  10033. 'sixsuperior',
  10034. 'sevensuperior',
  10035. 'ninesuperior',
  10036. 'zerosuperior',
  10037. '',
  10038. 'esuperior',
  10039. 'rsuperior',
  10040. 'tsuperior',
  10041. '',
  10042. '',
  10043. 'isuperior',
  10044. 'ssuperior',
  10045. 'dsuperior',
  10046. '',
  10047. '',
  10048. '',
  10049. '',
  10050. '',
  10051. 'lsuperior',
  10052. 'Ogoneksmall',
  10053. 'Brevesmall',
  10054. 'Macronsmall',
  10055. 'bsuperior',
  10056. 'nsuperior',
  10057. 'msuperior',
  10058. 'commasuperior',
  10059. 'periodsuperior',
  10060. 'Dotaccentsmall',
  10061. 'Ringsmall'
  10062. ];
  10063. var MacRomanEncoding = [
  10064. '',
  10065. '',
  10066. '',
  10067. '',
  10068. '',
  10069. '',
  10070. '',
  10071. '',
  10072. '',
  10073. '',
  10074. '',
  10075. '',
  10076. '',
  10077. '',
  10078. '',
  10079. '',
  10080. '',
  10081. '',
  10082. '',
  10083. '',
  10084. '',
  10085. '',
  10086. '',
  10087. '',
  10088. '',
  10089. '',
  10090. '',
  10091. '',
  10092. '',
  10093. '',
  10094. '',
  10095. '',
  10096. 'space',
  10097. 'exclam',
  10098. 'quotedbl',
  10099. 'numbersign',
  10100. 'dollar',
  10101. 'percent',
  10102. 'ampersand',
  10103. 'quotesingle',
  10104. 'parenleft',
  10105. 'parenright',
  10106. 'asterisk',
  10107. 'plus',
  10108. 'comma',
  10109. 'hyphen',
  10110. 'period',
  10111. 'slash',
  10112. 'zero',
  10113. 'one',
  10114. 'two',
  10115. 'three',
  10116. 'four',
  10117. 'five',
  10118. 'six',
  10119. 'seven',
  10120. 'eight',
  10121. 'nine',
  10122. 'colon',
  10123. 'semicolon',
  10124. 'less',
  10125. 'equal',
  10126. 'greater',
  10127. 'question',
  10128. 'at',
  10129. 'A',
  10130. 'B',
  10131. 'C',
  10132. 'D',
  10133. 'E',
  10134. 'F',
  10135. 'G',
  10136. 'H',
  10137. 'I',
  10138. 'J',
  10139. 'K',
  10140. 'L',
  10141. 'M',
  10142. 'N',
  10143. 'O',
  10144. 'P',
  10145. 'Q',
  10146. 'R',
  10147. 'S',
  10148. 'T',
  10149. 'U',
  10150. 'V',
  10151. 'W',
  10152. 'X',
  10153. 'Y',
  10154. 'Z',
  10155. 'bracketleft',
  10156. 'backslash',
  10157. 'bracketright',
  10158. 'asciicircum',
  10159. 'underscore',
  10160. 'grave',
  10161. 'a',
  10162. 'b',
  10163. 'c',
  10164. 'd',
  10165. 'e',
  10166. 'f',
  10167. 'g',
  10168. 'h',
  10169. 'i',
  10170. 'j',
  10171. 'k',
  10172. 'l',
  10173. 'm',
  10174. 'n',
  10175. 'o',
  10176. 'p',
  10177. 'q',
  10178. 'r',
  10179. 's',
  10180. 't',
  10181. 'u',
  10182. 'v',
  10183. 'w',
  10184. 'x',
  10185. 'y',
  10186. 'z',
  10187. 'braceleft',
  10188. 'bar',
  10189. 'braceright',
  10190. 'asciitilde',
  10191. '',
  10192. 'Adieresis',
  10193. 'Aring',
  10194. 'Ccedilla',
  10195. 'Eacute',
  10196. 'Ntilde',
  10197. 'Odieresis',
  10198. 'Udieresis',
  10199. 'aacute',
  10200. 'agrave',
  10201. 'acircumflex',
  10202. 'adieresis',
  10203. 'atilde',
  10204. 'aring',
  10205. 'ccedilla',
  10206. 'eacute',
  10207. 'egrave',
  10208. 'ecircumflex',
  10209. 'edieresis',
  10210. 'iacute',
  10211. 'igrave',
  10212. 'icircumflex',
  10213. 'idieresis',
  10214. 'ntilde',
  10215. 'oacute',
  10216. 'ograve',
  10217. 'ocircumflex',
  10218. 'odieresis',
  10219. 'otilde',
  10220. 'uacute',
  10221. 'ugrave',
  10222. 'ucircumflex',
  10223. 'udieresis',
  10224. 'dagger',
  10225. 'degree',
  10226. 'cent',
  10227. 'sterling',
  10228. 'section',
  10229. 'bullet',
  10230. 'paragraph',
  10231. 'germandbls',
  10232. 'registered',
  10233. 'copyright',
  10234. 'trademark',
  10235. 'acute',
  10236. 'dieresis',
  10237. 'notequal',
  10238. 'AE',
  10239. 'Oslash',
  10240. 'infinity',
  10241. 'plusminus',
  10242. 'lessequal',
  10243. 'greaterequal',
  10244. 'yen',
  10245. 'mu',
  10246. 'partialdiff',
  10247. 'summation',
  10248. 'product',
  10249. 'pi',
  10250. 'integral',
  10251. 'ordfeminine',
  10252. 'ordmasculine',
  10253. 'Omega',
  10254. 'ae',
  10255. 'oslash',
  10256. 'questiondown',
  10257. 'exclamdown',
  10258. 'logicalnot',
  10259. 'radical',
  10260. 'florin',
  10261. 'approxequal',
  10262. 'Delta',
  10263. 'guillemotleft',
  10264. 'guillemotright',
  10265. 'ellipsis',
  10266. 'space',
  10267. 'Agrave',
  10268. 'Atilde',
  10269. 'Otilde',
  10270. 'OE',
  10271. 'oe',
  10272. 'endash',
  10273. 'emdash',
  10274. 'quotedblleft',
  10275. 'quotedblright',
  10276. 'quoteleft',
  10277. 'quoteright',
  10278. 'divide',
  10279. 'lozenge',
  10280. 'ydieresis',
  10281. 'Ydieresis',
  10282. 'fraction',
  10283. 'currency',
  10284. 'guilsinglleft',
  10285. 'guilsinglright',
  10286. 'fi',
  10287. 'fl',
  10288. 'daggerdbl',
  10289. 'periodcentered',
  10290. 'quotesinglbase',
  10291. 'quotedblbase',
  10292. 'perthousand',
  10293. 'Acircumflex',
  10294. 'Ecircumflex',
  10295. 'Aacute',
  10296. 'Edieresis',
  10297. 'Egrave',
  10298. 'Iacute',
  10299. 'Icircumflex',
  10300. 'Idieresis',
  10301. 'Igrave',
  10302. 'Oacute',
  10303. 'Ocircumflex',
  10304. 'apple',
  10305. 'Ograve',
  10306. 'Uacute',
  10307. 'Ucircumflex',
  10308. 'Ugrave',
  10309. 'dotlessi',
  10310. 'circumflex',
  10311. 'tilde',
  10312. 'macron',
  10313. 'breve',
  10314. 'dotaccent',
  10315. 'ring',
  10316. 'cedilla',
  10317. 'hungarumlaut',
  10318. 'ogonek',
  10319. 'caron'
  10320. ];
  10321. var StandardEncoding = [
  10322. '',
  10323. '',
  10324. '',
  10325. '',
  10326. '',
  10327. '',
  10328. '',
  10329. '',
  10330. '',
  10331. '',
  10332. '',
  10333. '',
  10334. '',
  10335. '',
  10336. '',
  10337. '',
  10338. '',
  10339. '',
  10340. '',
  10341. '',
  10342. '',
  10343. '',
  10344. '',
  10345. '',
  10346. '',
  10347. '',
  10348. '',
  10349. '',
  10350. '',
  10351. '',
  10352. '',
  10353. '',
  10354. 'space',
  10355. 'exclam',
  10356. 'quotedbl',
  10357. 'numbersign',
  10358. 'dollar',
  10359. 'percent',
  10360. 'ampersand',
  10361. 'quoteright',
  10362. 'parenleft',
  10363. 'parenright',
  10364. 'asterisk',
  10365. 'plus',
  10366. 'comma',
  10367. 'hyphen',
  10368. 'period',
  10369. 'slash',
  10370. 'zero',
  10371. 'one',
  10372. 'two',
  10373. 'three',
  10374. 'four',
  10375. 'five',
  10376. 'six',
  10377. 'seven',
  10378. 'eight',
  10379. 'nine',
  10380. 'colon',
  10381. 'semicolon',
  10382. 'less',
  10383. 'equal',
  10384. 'greater',
  10385. 'question',
  10386. 'at',
  10387. 'A',
  10388. 'B',
  10389. 'C',
  10390. 'D',
  10391. 'E',
  10392. 'F',
  10393. 'G',
  10394. 'H',
  10395. 'I',
  10396. 'J',
  10397. 'K',
  10398. 'L',
  10399. 'M',
  10400. 'N',
  10401. 'O',
  10402. 'P',
  10403. 'Q',
  10404. 'R',
  10405. 'S',
  10406. 'T',
  10407. 'U',
  10408. 'V',
  10409. 'W',
  10410. 'X',
  10411. 'Y',
  10412. 'Z',
  10413. 'bracketleft',
  10414. 'backslash',
  10415. 'bracketright',
  10416. 'asciicircum',
  10417. 'underscore',
  10418. 'quoteleft',
  10419. 'a',
  10420. 'b',
  10421. 'c',
  10422. 'd',
  10423. 'e',
  10424. 'f',
  10425. 'g',
  10426. 'h',
  10427. 'i',
  10428. 'j',
  10429. 'k',
  10430. 'l',
  10431. 'm',
  10432. 'n',
  10433. 'o',
  10434. 'p',
  10435. 'q',
  10436. 'r',
  10437. 's',
  10438. 't',
  10439. 'u',
  10440. 'v',
  10441. 'w',
  10442. 'x',
  10443. 'y',
  10444. 'z',
  10445. 'braceleft',
  10446. 'bar',
  10447. 'braceright',
  10448. 'asciitilde',
  10449. '',
  10450. '',
  10451. '',
  10452. '',
  10453. '',
  10454. '',
  10455. '',
  10456. '',
  10457. '',
  10458. '',
  10459. '',
  10460. '',
  10461. '',
  10462. '',
  10463. '',
  10464. '',
  10465. '',
  10466. '',
  10467. '',
  10468. '',
  10469. '',
  10470. '',
  10471. '',
  10472. '',
  10473. '',
  10474. '',
  10475. '',
  10476. '',
  10477. '',
  10478. '',
  10479. '',
  10480. '',
  10481. '',
  10482. '',
  10483. 'exclamdown',
  10484. 'cent',
  10485. 'sterling',
  10486. 'fraction',
  10487. 'yen',
  10488. 'florin',
  10489. 'section',
  10490. 'currency',
  10491. 'quotesingle',
  10492. 'quotedblleft',
  10493. 'guillemotleft',
  10494. 'guilsinglleft',
  10495. 'guilsinglright',
  10496. 'fi',
  10497. 'fl',
  10498. '',
  10499. 'endash',
  10500. 'dagger',
  10501. 'daggerdbl',
  10502. 'periodcentered',
  10503. '',
  10504. 'paragraph',
  10505. 'bullet',
  10506. 'quotesinglbase',
  10507. 'quotedblbase',
  10508. 'quotedblright',
  10509. 'guillemotright',
  10510. 'ellipsis',
  10511. 'perthousand',
  10512. '',
  10513. 'questiondown',
  10514. '',
  10515. 'grave',
  10516. 'acute',
  10517. 'circumflex',
  10518. 'tilde',
  10519. 'macron',
  10520. 'breve',
  10521. 'dotaccent',
  10522. 'dieresis',
  10523. '',
  10524. 'ring',
  10525. 'cedilla',
  10526. '',
  10527. 'hungarumlaut',
  10528. 'ogonek',
  10529. 'caron',
  10530. 'emdash',
  10531. '',
  10532. '',
  10533. '',
  10534. '',
  10535. '',
  10536. '',
  10537. '',
  10538. '',
  10539. '',
  10540. '',
  10541. '',
  10542. '',
  10543. '',
  10544. '',
  10545. '',
  10546. '',
  10547. 'AE',
  10548. '',
  10549. 'ordfeminine',
  10550. '',
  10551. '',
  10552. '',
  10553. '',
  10554. 'Lslash',
  10555. 'Oslash',
  10556. 'OE',
  10557. 'ordmasculine',
  10558. '',
  10559. '',
  10560. '',
  10561. '',
  10562. '',
  10563. 'ae',
  10564. '',
  10565. '',
  10566. '',
  10567. 'dotlessi',
  10568. '',
  10569. '',
  10570. 'lslash',
  10571. 'oslash',
  10572. 'oe',
  10573. 'germandbls'
  10574. ];
  10575. var WinAnsiEncoding = [
  10576. '',
  10577. '',
  10578. '',
  10579. '',
  10580. '',
  10581. '',
  10582. '',
  10583. '',
  10584. '',
  10585. '',
  10586. '',
  10587. '',
  10588. '',
  10589. '',
  10590. '',
  10591. '',
  10592. '',
  10593. '',
  10594. '',
  10595. '',
  10596. '',
  10597. '',
  10598. '',
  10599. '',
  10600. '',
  10601. '',
  10602. '',
  10603. '',
  10604. '',
  10605. '',
  10606. '',
  10607. '',
  10608. 'space',
  10609. 'exclam',
  10610. 'quotedbl',
  10611. 'numbersign',
  10612. 'dollar',
  10613. 'percent',
  10614. 'ampersand',
  10615. 'quotesingle',
  10616. 'parenleft',
  10617. 'parenright',
  10618. 'asterisk',
  10619. 'plus',
  10620. 'comma',
  10621. 'hyphen',
  10622. 'period',
  10623. 'slash',
  10624. 'zero',
  10625. 'one',
  10626. 'two',
  10627. 'three',
  10628. 'four',
  10629. 'five',
  10630. 'six',
  10631. 'seven',
  10632. 'eight',
  10633. 'nine',
  10634. 'colon',
  10635. 'semicolon',
  10636. 'less',
  10637. 'equal',
  10638. 'greater',
  10639. 'question',
  10640. 'at',
  10641. 'A',
  10642. 'B',
  10643. 'C',
  10644. 'D',
  10645. 'E',
  10646. 'F',
  10647. 'G',
  10648. 'H',
  10649. 'I',
  10650. 'J',
  10651. 'K',
  10652. 'L',
  10653. 'M',
  10654. 'N',
  10655. 'O',
  10656. 'P',
  10657. 'Q',
  10658. 'R',
  10659. 'S',
  10660. 'T',
  10661. 'U',
  10662. 'V',
  10663. 'W',
  10664. 'X',
  10665. 'Y',
  10666. 'Z',
  10667. 'bracketleft',
  10668. 'backslash',
  10669. 'bracketright',
  10670. 'asciicircum',
  10671. 'underscore',
  10672. 'grave',
  10673. 'a',
  10674. 'b',
  10675. 'c',
  10676. 'd',
  10677. 'e',
  10678. 'f',
  10679. 'g',
  10680. 'h',
  10681. 'i',
  10682. 'j',
  10683. 'k',
  10684. 'l',
  10685. 'm',
  10686. 'n',
  10687. 'o',
  10688. 'p',
  10689. 'q',
  10690. 'r',
  10691. 's',
  10692. 't',
  10693. 'u',
  10694. 'v',
  10695. 'w',
  10696. 'x',
  10697. 'y',
  10698. 'z',
  10699. 'braceleft',
  10700. 'bar',
  10701. 'braceright',
  10702. 'asciitilde',
  10703. 'bullet',
  10704. 'Euro',
  10705. 'bullet',
  10706. 'quotesinglbase',
  10707. 'florin',
  10708. 'quotedblbase',
  10709. 'ellipsis',
  10710. 'dagger',
  10711. 'daggerdbl',
  10712. 'circumflex',
  10713. 'perthousand',
  10714. 'Scaron',
  10715. 'guilsinglleft',
  10716. 'OE',
  10717. 'bullet',
  10718. 'Zcaron',
  10719. 'bullet',
  10720. 'bullet',
  10721. 'quoteleft',
  10722. 'quoteright',
  10723. 'quotedblleft',
  10724. 'quotedblright',
  10725. 'bullet',
  10726. 'endash',
  10727. 'emdash',
  10728. 'tilde',
  10729. 'trademark',
  10730. 'scaron',
  10731. 'guilsinglright',
  10732. 'oe',
  10733. 'bullet',
  10734. 'zcaron',
  10735. 'Ydieresis',
  10736. 'space',
  10737. 'exclamdown',
  10738. 'cent',
  10739. 'sterling',
  10740. 'currency',
  10741. 'yen',
  10742. 'brokenbar',
  10743. 'section',
  10744. 'dieresis',
  10745. 'copyright',
  10746. 'ordfeminine',
  10747. 'guillemotleft',
  10748. 'logicalnot',
  10749. 'hyphen',
  10750. 'registered',
  10751. 'macron',
  10752. 'degree',
  10753. 'plusminus',
  10754. 'twosuperior',
  10755. 'threesuperior',
  10756. 'acute',
  10757. 'mu',
  10758. 'paragraph',
  10759. 'periodcentered',
  10760. 'cedilla',
  10761. 'onesuperior',
  10762. 'ordmasculine',
  10763. 'guillemotright',
  10764. 'onequarter',
  10765. 'onehalf',
  10766. 'threequarters',
  10767. 'questiondown',
  10768. 'Agrave',
  10769. 'Aacute',
  10770. 'Acircumflex',
  10771. 'Atilde',
  10772. 'Adieresis',
  10773. 'Aring',
  10774. 'AE',
  10775. 'Ccedilla',
  10776. 'Egrave',
  10777. 'Eacute',
  10778. 'Ecircumflex',
  10779. 'Edieresis',
  10780. 'Igrave',
  10781. 'Iacute',
  10782. 'Icircumflex',
  10783. 'Idieresis',
  10784. 'Eth',
  10785. 'Ntilde',
  10786. 'Ograve',
  10787. 'Oacute',
  10788. 'Ocircumflex',
  10789. 'Otilde',
  10790. 'Odieresis',
  10791. 'multiply',
  10792. 'Oslash',
  10793. 'Ugrave',
  10794. 'Uacute',
  10795. 'Ucircumflex',
  10796. 'Udieresis',
  10797. 'Yacute',
  10798. 'Thorn',
  10799. 'germandbls',
  10800. 'agrave',
  10801. 'aacute',
  10802. 'acircumflex',
  10803. 'atilde',
  10804. 'adieresis',
  10805. 'aring',
  10806. 'ae',
  10807. 'ccedilla',
  10808. 'egrave',
  10809. 'eacute',
  10810. 'ecircumflex',
  10811. 'edieresis',
  10812. 'igrave',
  10813. 'iacute',
  10814. 'icircumflex',
  10815. 'idieresis',
  10816. 'eth',
  10817. 'ntilde',
  10818. 'ograve',
  10819. 'oacute',
  10820. 'ocircumflex',
  10821. 'otilde',
  10822. 'odieresis',
  10823. 'divide',
  10824. 'oslash',
  10825. 'ugrave',
  10826. 'uacute',
  10827. 'ucircumflex',
  10828. 'udieresis',
  10829. 'yacute',
  10830. 'thorn',
  10831. 'ydieresis'
  10832. ];
  10833. var SymbolSetEncoding = [
  10834. '',
  10835. '',
  10836. '',
  10837. '',
  10838. '',
  10839. '',
  10840. '',
  10841. '',
  10842. '',
  10843. '',
  10844. '',
  10845. '',
  10846. '',
  10847. '',
  10848. '',
  10849. '',
  10850. '',
  10851. '',
  10852. '',
  10853. '',
  10854. '',
  10855. '',
  10856. '',
  10857. '',
  10858. '',
  10859. '',
  10860. '',
  10861. '',
  10862. '',
  10863. '',
  10864. '',
  10865. '',
  10866. 'space',
  10867. 'exclam',
  10868. 'universal',
  10869. 'numbersign',
  10870. 'existential',
  10871. 'percent',
  10872. 'ampersand',
  10873. 'suchthat',
  10874. 'parenleft',
  10875. 'parenright',
  10876. 'asteriskmath',
  10877. 'plus',
  10878. 'comma',
  10879. 'minus',
  10880. 'period',
  10881. 'slash',
  10882. 'zero',
  10883. 'one',
  10884. 'two',
  10885. 'three',
  10886. 'four',
  10887. 'five',
  10888. 'six',
  10889. 'seven',
  10890. 'eight',
  10891. 'nine',
  10892. 'colon',
  10893. 'semicolon',
  10894. 'less',
  10895. 'equal',
  10896. 'greater',
  10897. 'question',
  10898. 'congruent',
  10899. 'Alpha',
  10900. 'Beta',
  10901. 'Chi',
  10902. 'Delta',
  10903. 'Epsilon',
  10904. 'Phi',
  10905. 'Gamma',
  10906. 'Eta',
  10907. 'Iota',
  10908. 'theta1',
  10909. 'Kappa',
  10910. 'Lambda',
  10911. 'Mu',
  10912. 'Nu',
  10913. 'Omicron',
  10914. 'Pi',
  10915. 'Theta',
  10916. 'Rho',
  10917. 'Sigma',
  10918. 'Tau',
  10919. 'Upsilon',
  10920. 'sigma1',
  10921. 'Omega',
  10922. 'Xi',
  10923. 'Psi',
  10924. 'Zeta',
  10925. 'bracketleft',
  10926. 'therefore',
  10927. 'bracketright',
  10928. 'perpendicular',
  10929. 'underscore',
  10930. 'radicalex',
  10931. 'alpha',
  10932. 'beta',
  10933. 'chi',
  10934. 'delta',
  10935. 'epsilon',
  10936. 'phi',
  10937. 'gamma',
  10938. 'eta',
  10939. 'iota',
  10940. 'phi1',
  10941. 'kappa',
  10942. 'lambda',
  10943. 'mu',
  10944. 'nu',
  10945. 'omicron',
  10946. 'pi',
  10947. 'theta',
  10948. 'rho',
  10949. 'sigma',
  10950. 'tau',
  10951. 'upsilon',
  10952. 'omega1',
  10953. 'omega',
  10954. 'xi',
  10955. 'psi',
  10956. 'zeta',
  10957. 'braceleft',
  10958. 'bar',
  10959. 'braceright',
  10960. 'similar',
  10961. '',
  10962. '',
  10963. '',
  10964. '',
  10965. '',
  10966. '',
  10967. '',
  10968. '',
  10969. '',
  10970. '',
  10971. '',
  10972. '',
  10973. '',
  10974. '',
  10975. '',
  10976. '',
  10977. '',
  10978. '',
  10979. '',
  10980. '',
  10981. '',
  10982. '',
  10983. '',
  10984. '',
  10985. '',
  10986. '',
  10987. '',
  10988. '',
  10989. '',
  10990. '',
  10991. '',
  10992. '',
  10993. '',
  10994. 'Euro',
  10995. 'Upsilon1',
  10996. 'minute',
  10997. 'lessequal',
  10998. 'fraction',
  10999. 'infinity',
  11000. 'florin',
  11001. 'club',
  11002. 'diamond',
  11003. 'heart',
  11004. 'spade',
  11005. 'arrowboth',
  11006. 'arrowleft',
  11007. 'arrowup',
  11008. 'arrowright',
  11009. 'arrowdown',
  11010. 'degree',
  11011. 'plusminus',
  11012. 'second',
  11013. 'greaterequal',
  11014. 'multiply',
  11015. 'proportional',
  11016. 'partialdiff',
  11017. 'bullet',
  11018. 'divide',
  11019. 'notequal',
  11020. 'equivalence',
  11021. 'approxequal',
  11022. 'ellipsis',
  11023. 'arrowvertex',
  11024. 'arrowhorizex',
  11025. 'carriagereturn',
  11026. 'aleph',
  11027. 'Ifraktur',
  11028. 'Rfraktur',
  11029. 'weierstrass',
  11030. 'circlemultiply',
  11031. 'circleplus',
  11032. 'emptyset',
  11033. 'intersection',
  11034. 'union',
  11035. 'propersuperset',
  11036. 'reflexsuperset',
  11037. 'notsubset',
  11038. 'propersubset',
  11039. 'reflexsubset',
  11040. 'element',
  11041. 'notelement',
  11042. 'angle',
  11043. 'gradient',
  11044. 'registerserif',
  11045. 'copyrightserif',
  11046. 'trademarkserif',
  11047. 'product',
  11048. 'radical',
  11049. 'dotmath',
  11050. 'logicalnot',
  11051. 'logicaland',
  11052. 'logicalor',
  11053. 'arrowdblboth',
  11054. 'arrowdblleft',
  11055. 'arrowdblup',
  11056. 'arrowdblright',
  11057. 'arrowdbldown',
  11058. 'lozenge',
  11059. 'angleleft',
  11060. 'registersans',
  11061. 'copyrightsans',
  11062. 'trademarksans',
  11063. 'summation',
  11064. 'parenlefttp',
  11065. 'parenleftex',
  11066. 'parenleftbt',
  11067. 'bracketlefttp',
  11068. 'bracketleftex',
  11069. 'bracketleftbt',
  11070. 'bracelefttp',
  11071. 'braceleftmid',
  11072. 'braceleftbt',
  11073. 'braceex',
  11074. '',
  11075. 'angleright',
  11076. 'integral',
  11077. 'integraltp',
  11078. 'integralex',
  11079. 'integralbt',
  11080. 'parenrighttp',
  11081. 'parenrightex',
  11082. 'parenrightbt',
  11083. 'bracketrighttp',
  11084. 'bracketrightex',
  11085. 'bracketrightbt',
  11086. 'bracerighttp',
  11087. 'bracerightmid',
  11088. 'bracerightbt'
  11089. ];
  11090. var ZapfDingbatsEncoding = [
  11091. '',
  11092. '',
  11093. '',
  11094. '',
  11095. '',
  11096. '',
  11097. '',
  11098. '',
  11099. '',
  11100. '',
  11101. '',
  11102. '',
  11103. '',
  11104. '',
  11105. '',
  11106. '',
  11107. '',
  11108. '',
  11109. '',
  11110. '',
  11111. '',
  11112. '',
  11113. '',
  11114. '',
  11115. '',
  11116. '',
  11117. '',
  11118. '',
  11119. '',
  11120. '',
  11121. '',
  11122. '',
  11123. 'space',
  11124. 'a1',
  11125. 'a2',
  11126. 'a202',
  11127. 'a3',
  11128. 'a4',
  11129. 'a5',
  11130. 'a119',
  11131. 'a118',
  11132. 'a117',
  11133. 'a11',
  11134. 'a12',
  11135. 'a13',
  11136. 'a14',
  11137. 'a15',
  11138. 'a16',
  11139. 'a105',
  11140. 'a17',
  11141. 'a18',
  11142. 'a19',
  11143. 'a20',
  11144. 'a21',
  11145. 'a22',
  11146. 'a23',
  11147. 'a24',
  11148. 'a25',
  11149. 'a26',
  11150. 'a27',
  11151. 'a28',
  11152. 'a6',
  11153. 'a7',
  11154. 'a8',
  11155. 'a9',
  11156. 'a10',
  11157. 'a29',
  11158. 'a30',
  11159. 'a31',
  11160. 'a32',
  11161. 'a33',
  11162. 'a34',
  11163. 'a35',
  11164. 'a36',
  11165. 'a37',
  11166. 'a38',
  11167. 'a39',
  11168. 'a40',
  11169. 'a41',
  11170. 'a42',
  11171. 'a43',
  11172. 'a44',
  11173. 'a45',
  11174. 'a46',
  11175. 'a47',
  11176. 'a48',
  11177. 'a49',
  11178. 'a50',
  11179. 'a51',
  11180. 'a52',
  11181. 'a53',
  11182. 'a54',
  11183. 'a55',
  11184. 'a56',
  11185. 'a57',
  11186. 'a58',
  11187. 'a59',
  11188. 'a60',
  11189. 'a61',
  11190. 'a62',
  11191. 'a63',
  11192. 'a64',
  11193. 'a65',
  11194. 'a66',
  11195. 'a67',
  11196. 'a68',
  11197. 'a69',
  11198. 'a70',
  11199. 'a71',
  11200. 'a72',
  11201. 'a73',
  11202. 'a74',
  11203. 'a203',
  11204. 'a75',
  11205. 'a204',
  11206. 'a76',
  11207. 'a77',
  11208. 'a78',
  11209. 'a79',
  11210. 'a81',
  11211. 'a82',
  11212. 'a83',
  11213. 'a84',
  11214. 'a97',
  11215. 'a98',
  11216. 'a99',
  11217. 'a100',
  11218. '',
  11219. 'a89',
  11220. 'a90',
  11221. 'a93',
  11222. 'a94',
  11223. 'a91',
  11224. 'a92',
  11225. 'a205',
  11226. 'a85',
  11227. 'a206',
  11228. 'a86',
  11229. 'a87',
  11230. 'a88',
  11231. 'a95',
  11232. 'a96',
  11233. '',
  11234. '',
  11235. '',
  11236. '',
  11237. '',
  11238. '',
  11239. '',
  11240. '',
  11241. '',
  11242. '',
  11243. '',
  11244. '',
  11245. '',
  11246. '',
  11247. '',
  11248. '',
  11249. '',
  11250. '',
  11251. '',
  11252. 'a101',
  11253. 'a102',
  11254. 'a103',
  11255. 'a104',
  11256. 'a106',
  11257. 'a107',
  11258. 'a108',
  11259. 'a112',
  11260. 'a111',
  11261. 'a110',
  11262. 'a109',
  11263. 'a120',
  11264. 'a121',
  11265. 'a122',
  11266. 'a123',
  11267. 'a124',
  11268. 'a125',
  11269. 'a126',
  11270. 'a127',
  11271. 'a128',
  11272. 'a129',
  11273. 'a130',
  11274. 'a131',
  11275. 'a132',
  11276. 'a133',
  11277. 'a134',
  11278. 'a135',
  11279. 'a136',
  11280. 'a137',
  11281. 'a138',
  11282. 'a139',
  11283. 'a140',
  11284. 'a141',
  11285. 'a142',
  11286. 'a143',
  11287. 'a144',
  11288. 'a145',
  11289. 'a146',
  11290. 'a147',
  11291. 'a148',
  11292. 'a149',
  11293. 'a150',
  11294. 'a151',
  11295. 'a152',
  11296. 'a153',
  11297. 'a154',
  11298. 'a155',
  11299. 'a156',
  11300. 'a157',
  11301. 'a158',
  11302. 'a159',
  11303. 'a160',
  11304. 'a161',
  11305. 'a163',
  11306. 'a164',
  11307. 'a196',
  11308. 'a165',
  11309. 'a192',
  11310. 'a166',
  11311. 'a167',
  11312. 'a168',
  11313. 'a169',
  11314. 'a170',
  11315. 'a171',
  11316. 'a172',
  11317. 'a173',
  11318. 'a162',
  11319. 'a174',
  11320. 'a175',
  11321. 'a176',
  11322. 'a177',
  11323. 'a178',
  11324. 'a179',
  11325. 'a193',
  11326. 'a180',
  11327. 'a199',
  11328. 'a181',
  11329. 'a200',
  11330. 'a182',
  11331. '',
  11332. 'a201',
  11333. 'a183',
  11334. 'a184',
  11335. 'a197',
  11336. 'a185',
  11337. 'a194',
  11338. 'a198',
  11339. 'a186',
  11340. 'a195',
  11341. 'a187',
  11342. 'a188',
  11343. 'a189',
  11344. 'a190',
  11345. 'a191'
  11346. ];
  11347. function getEncoding(encodingName) {
  11348. switch (encodingName) {
  11349. case 'WinAnsiEncoding':
  11350. return WinAnsiEncoding;
  11351. case 'StandardEncoding':
  11352. return StandardEncoding;
  11353. case 'MacRomanEncoding':
  11354. return MacRomanEncoding;
  11355. case 'SymbolSetEncoding':
  11356. return SymbolSetEncoding;
  11357. case 'ZapfDingbatsEncoding':
  11358. return ZapfDingbatsEncoding;
  11359. case 'ExpertEncoding':
  11360. return ExpertEncoding;
  11361. case 'MacExpertEncoding':
  11362. return MacExpertEncoding;
  11363. default:
  11364. return null;
  11365. }
  11366. }
  11367. exports.WinAnsiEncoding = WinAnsiEncoding;
  11368. exports.StandardEncoding = StandardEncoding;
  11369. exports.MacRomanEncoding = MacRomanEncoding;
  11370. exports.SymbolSetEncoding = SymbolSetEncoding;
  11371. exports.ZapfDingbatsEncoding = ZapfDingbatsEncoding;
  11372. exports.ExpertEncoding = ExpertEncoding;
  11373. exports.getEncoding = getEncoding;
  11374. /***/ }),
  11375. /* 6 */
  11376. /***/ (function(module, exports, __w_pdfjs_require__) {
  11377. "use strict";
  11378. var sharedUtil = __w_pdfjs_require__(0);
  11379. var corePrimitives = __w_pdfjs_require__(1);
  11380. var coreStream = __w_pdfjs_require__(2);
  11381. var MissingDataException = sharedUtil.MissingDataException;
  11382. var StreamType = sharedUtil.StreamType;
  11383. var assert = sharedUtil.assert;
  11384. var error = sharedUtil.error;
  11385. var info = sharedUtil.info;
  11386. var isArray = sharedUtil.isArray;
  11387. var isInt = sharedUtil.isInt;
  11388. var isNum = sharedUtil.isNum;
  11389. var isString = sharedUtil.isString;
  11390. var warn = sharedUtil.warn;
  11391. var EOF = corePrimitives.EOF;
  11392. var Cmd = corePrimitives.Cmd;
  11393. var Dict = corePrimitives.Dict;
  11394. var Name = corePrimitives.Name;
  11395. var Ref = corePrimitives.Ref;
  11396. var isEOF = corePrimitives.isEOF;
  11397. var isCmd = corePrimitives.isCmd;
  11398. var isDict = corePrimitives.isDict;
  11399. var isName = corePrimitives.isName;
  11400. var Ascii85Stream = coreStream.Ascii85Stream;
  11401. var AsciiHexStream = coreStream.AsciiHexStream;
  11402. var CCITTFaxStream = coreStream.CCITTFaxStream;
  11403. var FlateStream = coreStream.FlateStream;
  11404. var Jbig2Stream = coreStream.Jbig2Stream;
  11405. var JpegStream = coreStream.JpegStream;
  11406. var JpxStream = coreStream.JpxStream;
  11407. var LZWStream = coreStream.LZWStream;
  11408. var NullStream = coreStream.NullStream;
  11409. var PredictorStream = coreStream.PredictorStream;
  11410. var RunLengthStream = coreStream.RunLengthStream;
  11411. var MAX_LENGTH_TO_CACHE = 1000;
  11412. var Parser = function ParserClosure() {
  11413. function Parser(lexer, allowStreams, xref, recoveryMode) {
  11414. this.lexer = lexer;
  11415. this.allowStreams = allowStreams;
  11416. this.xref = xref;
  11417. this.recoveryMode = recoveryMode || false;
  11418. this.imageCache = Object.create(null);
  11419. this.refill();
  11420. }
  11421. Parser.prototype = {
  11422. refill: function Parser_refill() {
  11423. this.buf1 = this.lexer.getObj();
  11424. this.buf2 = this.lexer.getObj();
  11425. },
  11426. shift: function Parser_shift() {
  11427. if (isCmd(this.buf2, 'ID')) {
  11428. this.buf1 = this.buf2;
  11429. this.buf2 = null;
  11430. } else {
  11431. this.buf1 = this.buf2;
  11432. this.buf2 = this.lexer.getObj();
  11433. }
  11434. },
  11435. tryShift: function Parser_tryShift() {
  11436. try {
  11437. this.shift();
  11438. return true;
  11439. } catch (e) {
  11440. if (e instanceof MissingDataException) {
  11441. throw e;
  11442. }
  11443. return false;
  11444. }
  11445. },
  11446. getObj: function Parser_getObj(cipherTransform) {
  11447. var buf1 = this.buf1;
  11448. this.shift();
  11449. if (buf1 instanceof Cmd) {
  11450. switch (buf1.cmd) {
  11451. case 'BI':
  11452. return this.makeInlineImage(cipherTransform);
  11453. case '[':
  11454. var array = [];
  11455. while (!isCmd(this.buf1, ']') && !isEOF(this.buf1)) {
  11456. array.push(this.getObj(cipherTransform));
  11457. }
  11458. if (isEOF(this.buf1)) {
  11459. if (!this.recoveryMode) {
  11460. error('End of file inside array');
  11461. }
  11462. return array;
  11463. }
  11464. this.shift();
  11465. return array;
  11466. case '<<':
  11467. var dict = new Dict(this.xref);
  11468. while (!isCmd(this.buf1, '>>') && !isEOF(this.buf1)) {
  11469. if (!isName(this.buf1)) {
  11470. info('Malformed dictionary: key must be a name object');
  11471. this.shift();
  11472. continue;
  11473. }
  11474. var key = this.buf1.name;
  11475. this.shift();
  11476. if (isEOF(this.buf1)) {
  11477. break;
  11478. }
  11479. dict.set(key, this.getObj(cipherTransform));
  11480. }
  11481. if (isEOF(this.buf1)) {
  11482. if (!this.recoveryMode) {
  11483. error('End of file inside dictionary');
  11484. }
  11485. return dict;
  11486. }
  11487. if (isCmd(this.buf2, 'stream')) {
  11488. return this.allowStreams ? this.makeStream(dict, cipherTransform) : dict;
  11489. }
  11490. this.shift();
  11491. return dict;
  11492. default:
  11493. return buf1;
  11494. }
  11495. }
  11496. if (isInt(buf1)) {
  11497. var num = buf1;
  11498. if (isInt(this.buf1) && isCmd(this.buf2, 'R')) {
  11499. var ref = new Ref(num, this.buf1);
  11500. this.shift();
  11501. this.shift();
  11502. return ref;
  11503. }
  11504. return num;
  11505. }
  11506. if (isString(buf1)) {
  11507. var str = buf1;
  11508. if (cipherTransform) {
  11509. str = cipherTransform.decryptString(str);
  11510. }
  11511. return str;
  11512. }
  11513. return buf1;
  11514. },
  11515. findDefaultInlineStreamEnd: function Parser_findDefaultInlineStreamEnd(stream) {
  11516. var E = 0x45, I = 0x49, SPACE = 0x20, LF = 0xA, CR = 0xD;
  11517. var startPos = stream.pos, state = 0, ch, i, n, followingBytes;
  11518. while ((ch = stream.getByte()) !== -1) {
  11519. if (state === 0) {
  11520. state = ch === E ? 1 : 0;
  11521. } else if (state === 1) {
  11522. state = ch === I ? 2 : 0;
  11523. } else {
  11524. assert(state === 2);
  11525. if (ch === SPACE || ch === LF || ch === CR) {
  11526. n = 5;
  11527. followingBytes = stream.peekBytes(n);
  11528. for (i = 0; i < n; i++) {
  11529. ch = followingBytes[i];
  11530. if (ch !== LF && ch !== CR && (ch < SPACE || ch > 0x7F)) {
  11531. state = 0;
  11532. break;
  11533. }
  11534. }
  11535. if (state === 2) {
  11536. break;
  11537. }
  11538. } else {
  11539. state = 0;
  11540. }
  11541. }
  11542. }
  11543. return stream.pos - 4 - startPos;
  11544. },
  11545. findDCTDecodeInlineStreamEnd: function Parser_findDCTDecodeInlineStreamEnd(stream) {
  11546. var startPos = stream.pos, foundEOI = false, b, markerLength, length;
  11547. while ((b = stream.getByte()) !== -1) {
  11548. if (b !== 0xFF) {
  11549. continue;
  11550. }
  11551. switch (stream.getByte()) {
  11552. case 0x00:
  11553. break;
  11554. case 0xFF:
  11555. stream.skip(-1);
  11556. break;
  11557. case 0xD9:
  11558. foundEOI = true;
  11559. break;
  11560. case 0xC0:
  11561. case 0xC1:
  11562. case 0xC2:
  11563. case 0xC3:
  11564. case 0xC5:
  11565. case 0xC6:
  11566. case 0xC7:
  11567. case 0xC9:
  11568. case 0xCA:
  11569. case 0xCB:
  11570. case 0xCD:
  11571. case 0xCE:
  11572. case 0xCF:
  11573. case 0xC4:
  11574. case 0xCC:
  11575. case 0xDA:
  11576. case 0xDB:
  11577. case 0xDC:
  11578. case 0xDD:
  11579. case 0xDE:
  11580. case 0xDF:
  11581. case 0xE0:
  11582. case 0xE1:
  11583. case 0xE2:
  11584. case 0xE3:
  11585. case 0xE4:
  11586. case 0xE5:
  11587. case 0xE6:
  11588. case 0xE7:
  11589. case 0xE8:
  11590. case 0xE9:
  11591. case 0xEA:
  11592. case 0xEB:
  11593. case 0xEC:
  11594. case 0xED:
  11595. case 0xEE:
  11596. case 0xEF:
  11597. case 0xFE:
  11598. markerLength = stream.getUint16();
  11599. if (markerLength > 2) {
  11600. stream.skip(markerLength - 2);
  11601. } else {
  11602. stream.skip(-2);
  11603. }
  11604. break;
  11605. }
  11606. if (foundEOI) {
  11607. break;
  11608. }
  11609. }
  11610. length = stream.pos - startPos;
  11611. if (b === -1) {
  11612. warn('Inline DCTDecode image stream: ' + 'EOI marker not found, searching for /EI/ instead.');
  11613. stream.skip(-length);
  11614. return this.findDefaultInlineStreamEnd(stream);
  11615. }
  11616. this.inlineStreamSkipEI(stream);
  11617. return length;
  11618. },
  11619. findASCII85DecodeInlineStreamEnd: function Parser_findASCII85DecodeInlineStreamEnd(stream) {
  11620. var TILDE = 0x7E, GT = 0x3E;
  11621. var startPos = stream.pos, ch, length;
  11622. while ((ch = stream.getByte()) !== -1) {
  11623. if (ch === TILDE && stream.peekByte() === GT) {
  11624. stream.skip();
  11625. break;
  11626. }
  11627. }
  11628. length = stream.pos - startPos;
  11629. if (ch === -1) {
  11630. warn('Inline ASCII85Decode image stream: ' + 'EOD marker not found, searching for /EI/ instead.');
  11631. stream.skip(-length);
  11632. return this.findDefaultInlineStreamEnd(stream);
  11633. }
  11634. this.inlineStreamSkipEI(stream);
  11635. return length;
  11636. },
  11637. findASCIIHexDecodeInlineStreamEnd: function Parser_findASCIIHexDecodeInlineStreamEnd(stream) {
  11638. var GT = 0x3E;
  11639. var startPos = stream.pos, ch, length;
  11640. while ((ch = stream.getByte()) !== -1) {
  11641. if (ch === GT) {
  11642. break;
  11643. }
  11644. }
  11645. length = stream.pos - startPos;
  11646. if (ch === -1) {
  11647. warn('Inline ASCIIHexDecode image stream: ' + 'EOD marker not found, searching for /EI/ instead.');
  11648. stream.skip(-length);
  11649. return this.findDefaultInlineStreamEnd(stream);
  11650. }
  11651. this.inlineStreamSkipEI(stream);
  11652. return length;
  11653. },
  11654. inlineStreamSkipEI: function Parser_inlineStreamSkipEI(stream) {
  11655. var E = 0x45, I = 0x49;
  11656. var state = 0, ch;
  11657. while ((ch = stream.getByte()) !== -1) {
  11658. if (state === 0) {
  11659. state = ch === E ? 1 : 0;
  11660. } else if (state === 1) {
  11661. state = ch === I ? 2 : 0;
  11662. } else if (state === 2) {
  11663. break;
  11664. }
  11665. }
  11666. },
  11667. makeInlineImage: function Parser_makeInlineImage(cipherTransform) {
  11668. var lexer = this.lexer;
  11669. var stream = lexer.stream;
  11670. var dict = new Dict(this.xref);
  11671. while (!isCmd(this.buf1, 'ID') && !isEOF(this.buf1)) {
  11672. if (!isName(this.buf1)) {
  11673. error('Dictionary key must be a name object');
  11674. }
  11675. var key = this.buf1.name;
  11676. this.shift();
  11677. if (isEOF(this.buf1)) {
  11678. break;
  11679. }
  11680. dict.set(key, this.getObj(cipherTransform));
  11681. }
  11682. var filter = dict.get('Filter', 'F'), filterName;
  11683. if (isName(filter)) {
  11684. filterName = filter.name;
  11685. } else if (isArray(filter)) {
  11686. var filterZero = this.xref.fetchIfRef(filter[0]);
  11687. if (isName(filterZero)) {
  11688. filterName = filterZero.name;
  11689. }
  11690. }
  11691. var startPos = stream.pos, length, i, ii;
  11692. if (filterName === 'DCTDecode' || filterName === 'DCT') {
  11693. length = this.findDCTDecodeInlineStreamEnd(stream);
  11694. } else if (filterName === 'ASCII85Decide' || filterName === 'A85') {
  11695. length = this.findASCII85DecodeInlineStreamEnd(stream);
  11696. } else if (filterName === 'ASCIIHexDecode' || filterName === 'AHx') {
  11697. length = this.findASCIIHexDecodeInlineStreamEnd(stream);
  11698. } else {
  11699. length = this.findDefaultInlineStreamEnd(stream);
  11700. }
  11701. var imageStream = stream.makeSubStream(startPos, length, dict);
  11702. var adler32;
  11703. if (length < MAX_LENGTH_TO_CACHE) {
  11704. var imageBytes = imageStream.getBytes();
  11705. imageStream.reset();
  11706. var a = 1;
  11707. var b = 0;
  11708. for (i = 0, ii = imageBytes.length; i < ii; ++i) {
  11709. a += imageBytes[i] & 0xff;
  11710. b += a;
  11711. }
  11712. adler32 = b % 65521 << 16 | a % 65521;
  11713. if (this.imageCache.adler32 === adler32) {
  11714. this.buf2 = Cmd.get('EI');
  11715. this.shift();
  11716. this.imageCache[adler32].reset();
  11717. return this.imageCache[adler32];
  11718. }
  11719. }
  11720. if (cipherTransform) {
  11721. imageStream = cipherTransform.createStream(imageStream, length);
  11722. }
  11723. imageStream = this.filter(imageStream, dict, length);
  11724. imageStream.dict = dict;
  11725. if (adler32 !== undefined) {
  11726. imageStream.cacheKey = 'inline_' + length + '_' + adler32;
  11727. this.imageCache[adler32] = imageStream;
  11728. }
  11729. this.buf2 = Cmd.get('EI');
  11730. this.shift();
  11731. return imageStream;
  11732. },
  11733. makeStream: function Parser_makeStream(dict, cipherTransform) {
  11734. var lexer = this.lexer;
  11735. var stream = lexer.stream;
  11736. lexer.skipToNextLine();
  11737. var pos = stream.pos - 1;
  11738. var length = dict.get('Length');
  11739. if (!isInt(length)) {
  11740. info('Bad ' + length + ' attribute in stream');
  11741. length = 0;
  11742. }
  11743. stream.pos = pos + length;
  11744. lexer.nextChar();
  11745. if (this.tryShift() && isCmd(this.buf2, 'endstream')) {
  11746. this.shift();
  11747. } else {
  11748. stream.pos = pos;
  11749. var SCAN_BLOCK_SIZE = 2048;
  11750. var ENDSTREAM_SIGNATURE_LENGTH = 9;
  11751. var ENDSTREAM_SIGNATURE = [
  11752. 0x65,
  11753. 0x6E,
  11754. 0x64,
  11755. 0x73,
  11756. 0x74,
  11757. 0x72,
  11758. 0x65,
  11759. 0x61,
  11760. 0x6D
  11761. ];
  11762. var skipped = 0, found = false, i, j;
  11763. while (stream.pos < stream.end) {
  11764. var scanBytes = stream.peekBytes(SCAN_BLOCK_SIZE);
  11765. var scanLength = scanBytes.length - ENDSTREAM_SIGNATURE_LENGTH;
  11766. if (scanLength <= 0) {
  11767. break;
  11768. }
  11769. found = false;
  11770. i = 0;
  11771. while (i < scanLength) {
  11772. j = 0;
  11773. while (j < ENDSTREAM_SIGNATURE_LENGTH && scanBytes[i + j] === ENDSTREAM_SIGNATURE[j]) {
  11774. j++;
  11775. }
  11776. if (j >= ENDSTREAM_SIGNATURE_LENGTH) {
  11777. found = true;
  11778. break;
  11779. }
  11780. i++;
  11781. }
  11782. if (found) {
  11783. skipped += i;
  11784. stream.pos += i;
  11785. break;
  11786. }
  11787. skipped += scanLength;
  11788. stream.pos += scanLength;
  11789. }
  11790. if (!found) {
  11791. error('Missing endstream');
  11792. }
  11793. length = skipped;
  11794. lexer.nextChar();
  11795. this.shift();
  11796. this.shift();
  11797. }
  11798. this.shift();
  11799. stream = stream.makeSubStream(pos, length, dict);
  11800. if (cipherTransform) {
  11801. stream = cipherTransform.createStream(stream, length);
  11802. }
  11803. stream = this.filter(stream, dict, length);
  11804. stream.dict = dict;
  11805. return stream;
  11806. },
  11807. filter: function Parser_filter(stream, dict, length) {
  11808. var filter = dict.get('Filter', 'F');
  11809. var params = dict.get('DecodeParms', 'DP');
  11810. if (isName(filter)) {
  11811. if (isArray(params)) {
  11812. params = this.xref.fetchIfRef(params[0]);
  11813. }
  11814. return this.makeFilter(stream, filter.name, length, params);
  11815. }
  11816. var maybeLength = length;
  11817. if (isArray(filter)) {
  11818. var filterArray = filter;
  11819. var paramsArray = params;
  11820. for (var i = 0, ii = filterArray.length; i < ii; ++i) {
  11821. filter = this.xref.fetchIfRef(filterArray[i]);
  11822. if (!isName(filter)) {
  11823. error('Bad filter name: ' + filter);
  11824. }
  11825. params = null;
  11826. if (isArray(paramsArray) && i in paramsArray) {
  11827. params = this.xref.fetchIfRef(paramsArray[i]);
  11828. }
  11829. stream = this.makeFilter(stream, filter.name, maybeLength, params);
  11830. maybeLength = null;
  11831. }
  11832. }
  11833. return stream;
  11834. },
  11835. makeFilter: function Parser_makeFilter(stream, name, maybeLength, params) {
  11836. if (maybeLength === 0) {
  11837. warn('Empty "' + name + '" stream.');
  11838. return new NullStream(stream);
  11839. }
  11840. try {
  11841. var xrefStreamStats = this.xref.stats.streamTypes;
  11842. if (name === 'FlateDecode' || name === 'Fl') {
  11843. xrefStreamStats[StreamType.FLATE] = true;
  11844. if (params) {
  11845. return new PredictorStream(new FlateStream(stream, maybeLength), maybeLength, params);
  11846. }
  11847. return new FlateStream(stream, maybeLength);
  11848. }
  11849. if (name === 'LZWDecode' || name === 'LZW') {
  11850. xrefStreamStats[StreamType.LZW] = true;
  11851. var earlyChange = 1;
  11852. if (params) {
  11853. if (params.has('EarlyChange')) {
  11854. earlyChange = params.get('EarlyChange');
  11855. }
  11856. return new PredictorStream(new LZWStream(stream, maybeLength, earlyChange), maybeLength, params);
  11857. }
  11858. return new LZWStream(stream, maybeLength, earlyChange);
  11859. }
  11860. if (name === 'DCTDecode' || name === 'DCT') {
  11861. xrefStreamStats[StreamType.DCT] = true;
  11862. return new JpegStream(stream, maybeLength, stream.dict, params);
  11863. }
  11864. if (name === 'JPXDecode' || name === 'JPX') {
  11865. xrefStreamStats[StreamType.JPX] = true;
  11866. return new JpxStream(stream, maybeLength, stream.dict, params);
  11867. }
  11868. if (name === 'ASCII85Decode' || name === 'A85') {
  11869. xrefStreamStats[StreamType.A85] = true;
  11870. return new Ascii85Stream(stream, maybeLength);
  11871. }
  11872. if (name === 'ASCIIHexDecode' || name === 'AHx') {
  11873. xrefStreamStats[StreamType.AHX] = true;
  11874. return new AsciiHexStream(stream, maybeLength);
  11875. }
  11876. if (name === 'CCITTFaxDecode' || name === 'CCF') {
  11877. xrefStreamStats[StreamType.CCF] = true;
  11878. return new CCITTFaxStream(stream, maybeLength, params);
  11879. }
  11880. if (name === 'RunLengthDecode' || name === 'RL') {
  11881. xrefStreamStats[StreamType.RL] = true;
  11882. return new RunLengthStream(stream, maybeLength);
  11883. }
  11884. if (name === 'JBIG2Decode') {
  11885. xrefStreamStats[StreamType.JBIG] = true;
  11886. return new Jbig2Stream(stream, maybeLength, stream.dict, params);
  11887. }
  11888. warn('filter "' + name + '" not supported yet');
  11889. return stream;
  11890. } catch (ex) {
  11891. if (ex instanceof MissingDataException) {
  11892. throw ex;
  11893. }
  11894. warn('Invalid stream: \"' + ex + '\"');
  11895. return new NullStream(stream);
  11896. }
  11897. }
  11898. };
  11899. return Parser;
  11900. }();
  11901. var Lexer = function LexerClosure() {
  11902. function Lexer(stream, knownCommands) {
  11903. this.stream = stream;
  11904. this.nextChar();
  11905. this.strBuf = [];
  11906. this.knownCommands = knownCommands;
  11907. }
  11908. var specialChars = [
  11909. 1,
  11910. 0,
  11911. 0,
  11912. 0,
  11913. 0,
  11914. 0,
  11915. 0,
  11916. 0,
  11917. 0,
  11918. 1,
  11919. 1,
  11920. 0,
  11921. 1,
  11922. 1,
  11923. 0,
  11924. 0,
  11925. 0,
  11926. 0,
  11927. 0,
  11928. 0,
  11929. 0,
  11930. 0,
  11931. 0,
  11932. 0,
  11933. 0,
  11934. 0,
  11935. 0,
  11936. 0,
  11937. 0,
  11938. 0,
  11939. 0,
  11940. 0,
  11941. 1,
  11942. 0,
  11943. 0,
  11944. 0,
  11945. 0,
  11946. 2,
  11947. 0,
  11948. 0,
  11949. 2,
  11950. 2,
  11951. 0,
  11952. 0,
  11953. 0,
  11954. 0,
  11955. 0,
  11956. 2,
  11957. 0,
  11958. 0,
  11959. 0,
  11960. 0,
  11961. 0,
  11962. 0,
  11963. 0,
  11964. 0,
  11965. 0,
  11966. 0,
  11967. 0,
  11968. 0,
  11969. 2,
  11970. 0,
  11971. 2,
  11972. 0,
  11973. 0,
  11974. 0,
  11975. 0,
  11976. 0,
  11977. 0,
  11978. 0,
  11979. 0,
  11980. 0,
  11981. 0,
  11982. 0,
  11983. 0,
  11984. 0,
  11985. 0,
  11986. 0,
  11987. 0,
  11988. 0,
  11989. 0,
  11990. 0,
  11991. 0,
  11992. 0,
  11993. 0,
  11994. 0,
  11995. 0,
  11996. 0,
  11997. 0,
  11998. 0,
  11999. 0,
  12000. 2,
  12001. 0,
  12002. 2,
  12003. 0,
  12004. 0,
  12005. 0,
  12006. 0,
  12007. 0,
  12008. 0,
  12009. 0,
  12010. 0,
  12011. 0,
  12012. 0,
  12013. 0,
  12014. 0,
  12015. 0,
  12016. 0,
  12017. 0,
  12018. 0,
  12019. 0,
  12020. 0,
  12021. 0,
  12022. 0,
  12023. 0,
  12024. 0,
  12025. 0,
  12026. 0,
  12027. 0,
  12028. 0,
  12029. 0,
  12030. 0,
  12031. 0,
  12032. 2,
  12033. 0,
  12034. 2,
  12035. 0,
  12036. 0,
  12037. 0,
  12038. 0,
  12039. 0,
  12040. 0,
  12041. 0,
  12042. 0,
  12043. 0,
  12044. 0,
  12045. 0,
  12046. 0,
  12047. 0,
  12048. 0,
  12049. 0,
  12050. 0,
  12051. 0,
  12052. 0,
  12053. 0,
  12054. 0,
  12055. 0,
  12056. 0,
  12057. 0,
  12058. 0,
  12059. 0,
  12060. 0,
  12061. 0,
  12062. 0,
  12063. 0,
  12064. 0,
  12065. 0,
  12066. 0,
  12067. 0,
  12068. 0,
  12069. 0,
  12070. 0,
  12071. 0,
  12072. 0,
  12073. 0,
  12074. 0,
  12075. 0,
  12076. 0,
  12077. 0,
  12078. 0,
  12079. 0,
  12080. 0,
  12081. 0,
  12082. 0,
  12083. 0,
  12084. 0,
  12085. 0,
  12086. 0,
  12087. 0,
  12088. 0,
  12089. 0,
  12090. 0,
  12091. 0,
  12092. 0,
  12093. 0,
  12094. 0,
  12095. 0,
  12096. 0,
  12097. 0,
  12098. 0,
  12099. 0,
  12100. 0,
  12101. 0,
  12102. 0,
  12103. 0,
  12104. 0,
  12105. 0,
  12106. 0,
  12107. 0,
  12108. 0,
  12109. 0,
  12110. 0,
  12111. 0,
  12112. 0,
  12113. 0,
  12114. 0,
  12115. 0,
  12116. 0,
  12117. 0,
  12118. 0,
  12119. 0,
  12120. 0,
  12121. 0,
  12122. 0,
  12123. 0,
  12124. 0,
  12125. 0,
  12126. 0,
  12127. 0,
  12128. 0,
  12129. 0,
  12130. 0,
  12131. 0,
  12132. 0,
  12133. 0,
  12134. 0,
  12135. 0,
  12136. 0,
  12137. 0,
  12138. 0,
  12139. 0,
  12140. 0,
  12141. 0,
  12142. 0,
  12143. 0,
  12144. 0,
  12145. 0,
  12146. 0,
  12147. 0,
  12148. 0,
  12149. 0,
  12150. 0,
  12151. 0,
  12152. 0,
  12153. 0,
  12154. 0,
  12155. 0,
  12156. 0,
  12157. 0,
  12158. 0,
  12159. 0,
  12160. 0,
  12161. 0,
  12162. 0,
  12163. 0,
  12164. 0
  12165. ];
  12166. function toHexDigit(ch) {
  12167. if (ch >= 0x30 && ch <= 0x39) {
  12168. return ch & 0x0F;
  12169. }
  12170. if (ch >= 0x41 && ch <= 0x46 || ch >= 0x61 && ch <= 0x66) {
  12171. return (ch & 0x0F) + 9;
  12172. }
  12173. return -1;
  12174. }
  12175. Lexer.prototype = {
  12176. nextChar: function Lexer_nextChar() {
  12177. return this.currentChar = this.stream.getByte();
  12178. },
  12179. peekChar: function Lexer_peekChar() {
  12180. return this.stream.peekByte();
  12181. },
  12182. getNumber: function Lexer_getNumber() {
  12183. var ch = this.currentChar;
  12184. var eNotation = false;
  12185. var divideBy = 0;
  12186. var sign = 1;
  12187. if (ch === 0x2D) {
  12188. sign = -1;
  12189. ch = this.nextChar();
  12190. if (ch === 0x2D) {
  12191. ch = this.nextChar();
  12192. }
  12193. } else if (ch === 0x2B) {
  12194. ch = this.nextChar();
  12195. }
  12196. if (ch === 0x2E) {
  12197. divideBy = 10;
  12198. ch = this.nextChar();
  12199. }
  12200. if (ch < 0x30 || ch > 0x39) {
  12201. error('Invalid number: ' + String.fromCharCode(ch));
  12202. return 0;
  12203. }
  12204. var baseValue = ch - 0x30;
  12205. var powerValue = 0;
  12206. var powerValueSign = 1;
  12207. while ((ch = this.nextChar()) >= 0) {
  12208. if (0x30 <= ch && ch <= 0x39) {
  12209. var currentDigit = ch - 0x30;
  12210. if (eNotation) {
  12211. powerValue = powerValue * 10 + currentDigit;
  12212. } else {
  12213. if (divideBy !== 0) {
  12214. divideBy *= 10;
  12215. }
  12216. baseValue = baseValue * 10 + currentDigit;
  12217. }
  12218. } else if (ch === 0x2E) {
  12219. if (divideBy === 0) {
  12220. divideBy = 1;
  12221. } else {
  12222. break;
  12223. }
  12224. } else if (ch === 0x2D) {
  12225. warn('Badly formatted number');
  12226. } else if (ch === 0x45 || ch === 0x65) {
  12227. ch = this.peekChar();
  12228. if (ch === 0x2B || ch === 0x2D) {
  12229. powerValueSign = ch === 0x2D ? -1 : 1;
  12230. this.nextChar();
  12231. } else if (ch < 0x30 || ch > 0x39) {
  12232. break;
  12233. }
  12234. eNotation = true;
  12235. } else {
  12236. break;
  12237. }
  12238. }
  12239. if (divideBy !== 0) {
  12240. baseValue /= divideBy;
  12241. }
  12242. if (eNotation) {
  12243. baseValue *= Math.pow(10, powerValueSign * powerValue);
  12244. }
  12245. return sign * baseValue;
  12246. },
  12247. getString: function Lexer_getString() {
  12248. var numParen = 1;
  12249. var done = false;
  12250. var strBuf = this.strBuf;
  12251. strBuf.length = 0;
  12252. var ch = this.nextChar();
  12253. while (true) {
  12254. var charBuffered = false;
  12255. switch (ch | 0) {
  12256. case -1:
  12257. warn('Unterminated string');
  12258. done = true;
  12259. break;
  12260. case 0x28:
  12261. ++numParen;
  12262. strBuf.push('(');
  12263. break;
  12264. case 0x29:
  12265. if (--numParen === 0) {
  12266. this.nextChar();
  12267. done = true;
  12268. } else {
  12269. strBuf.push(')');
  12270. }
  12271. break;
  12272. case 0x5C:
  12273. ch = this.nextChar();
  12274. switch (ch) {
  12275. case -1:
  12276. warn('Unterminated string');
  12277. done = true;
  12278. break;
  12279. case 0x6E:
  12280. strBuf.push('\n');
  12281. break;
  12282. case 0x72:
  12283. strBuf.push('\r');
  12284. break;
  12285. case 0x74:
  12286. strBuf.push('\t');
  12287. break;
  12288. case 0x62:
  12289. strBuf.push('\b');
  12290. break;
  12291. case 0x66:
  12292. strBuf.push('\f');
  12293. break;
  12294. case 0x5C:
  12295. case 0x28:
  12296. case 0x29:
  12297. strBuf.push(String.fromCharCode(ch));
  12298. break;
  12299. case 0x30:
  12300. case 0x31:
  12301. case 0x32:
  12302. case 0x33:
  12303. case 0x34:
  12304. case 0x35:
  12305. case 0x36:
  12306. case 0x37:
  12307. var x = ch & 0x0F;
  12308. ch = this.nextChar();
  12309. charBuffered = true;
  12310. if (ch >= 0x30 && ch <= 0x37) {
  12311. x = (x << 3) + (ch & 0x0F);
  12312. ch = this.nextChar();
  12313. if (ch >= 0x30 && ch <= 0x37) {
  12314. charBuffered = false;
  12315. x = (x << 3) + (ch & 0x0F);
  12316. }
  12317. }
  12318. strBuf.push(String.fromCharCode(x));
  12319. break;
  12320. case 0x0D:
  12321. if (this.peekChar() === 0x0A) {
  12322. this.nextChar();
  12323. }
  12324. break;
  12325. case 0x0A:
  12326. break;
  12327. default:
  12328. strBuf.push(String.fromCharCode(ch));
  12329. break;
  12330. }
  12331. break;
  12332. default:
  12333. strBuf.push(String.fromCharCode(ch));
  12334. break;
  12335. }
  12336. if (done) {
  12337. break;
  12338. }
  12339. if (!charBuffered) {
  12340. ch = this.nextChar();
  12341. }
  12342. }
  12343. return strBuf.join('');
  12344. },
  12345. getName: function Lexer_getName() {
  12346. var ch, previousCh;
  12347. var strBuf = this.strBuf;
  12348. strBuf.length = 0;
  12349. while ((ch = this.nextChar()) >= 0 && !specialChars[ch]) {
  12350. if (ch === 0x23) {
  12351. ch = this.nextChar();
  12352. if (specialChars[ch]) {
  12353. warn('Lexer_getName: ' + 'NUMBER SIGN (#) should be followed by a hexadecimal number.');
  12354. strBuf.push('#');
  12355. break;
  12356. }
  12357. var x = toHexDigit(ch);
  12358. if (x !== -1) {
  12359. previousCh = ch;
  12360. ch = this.nextChar();
  12361. var x2 = toHexDigit(ch);
  12362. if (x2 === -1) {
  12363. warn('Lexer_getName: Illegal digit (' + String.fromCharCode(ch) + ') in hexadecimal number.');
  12364. strBuf.push('#', String.fromCharCode(previousCh));
  12365. if (specialChars[ch]) {
  12366. break;
  12367. }
  12368. strBuf.push(String.fromCharCode(ch));
  12369. continue;
  12370. }
  12371. strBuf.push(String.fromCharCode(x << 4 | x2));
  12372. } else {
  12373. strBuf.push('#', String.fromCharCode(ch));
  12374. }
  12375. } else {
  12376. strBuf.push(String.fromCharCode(ch));
  12377. }
  12378. }
  12379. if (strBuf.length > 127) {
  12380. warn('name token is longer than allowed by the spec: ' + strBuf.length);
  12381. }
  12382. return Name.get(strBuf.join(''));
  12383. },
  12384. getHexString: function Lexer_getHexString() {
  12385. var strBuf = this.strBuf;
  12386. strBuf.length = 0;
  12387. var ch = this.currentChar;
  12388. var isFirstHex = true;
  12389. var firstDigit;
  12390. var secondDigit;
  12391. while (true) {
  12392. if (ch < 0) {
  12393. warn('Unterminated hex string');
  12394. break;
  12395. } else if (ch === 0x3E) {
  12396. this.nextChar();
  12397. break;
  12398. } else if (specialChars[ch] === 1) {
  12399. ch = this.nextChar();
  12400. continue;
  12401. } else {
  12402. if (isFirstHex) {
  12403. firstDigit = toHexDigit(ch);
  12404. if (firstDigit === -1) {
  12405. warn('Ignoring invalid character "' + ch + '" in hex string');
  12406. ch = this.nextChar();
  12407. continue;
  12408. }
  12409. } else {
  12410. secondDigit = toHexDigit(ch);
  12411. if (secondDigit === -1) {
  12412. warn('Ignoring invalid character "' + ch + '" in hex string');
  12413. ch = this.nextChar();
  12414. continue;
  12415. }
  12416. strBuf.push(String.fromCharCode(firstDigit << 4 | secondDigit));
  12417. }
  12418. isFirstHex = !isFirstHex;
  12419. ch = this.nextChar();
  12420. }
  12421. }
  12422. return strBuf.join('');
  12423. },
  12424. getObj: function Lexer_getObj() {
  12425. var comment = false;
  12426. var ch = this.currentChar;
  12427. while (true) {
  12428. if (ch < 0) {
  12429. return EOF;
  12430. }
  12431. if (comment) {
  12432. if (ch === 0x0A || ch === 0x0D) {
  12433. comment = false;
  12434. }
  12435. } else if (ch === 0x25) {
  12436. comment = true;
  12437. } else if (specialChars[ch] !== 1) {
  12438. break;
  12439. }
  12440. ch = this.nextChar();
  12441. }
  12442. switch (ch | 0) {
  12443. case 0x30:
  12444. case 0x31:
  12445. case 0x32:
  12446. case 0x33:
  12447. case 0x34:
  12448. case 0x35:
  12449. case 0x36:
  12450. case 0x37:
  12451. case 0x38:
  12452. case 0x39:
  12453. case 0x2B:
  12454. case 0x2D:
  12455. case 0x2E:
  12456. return this.getNumber();
  12457. case 0x28:
  12458. return this.getString();
  12459. case 0x2F:
  12460. return this.getName();
  12461. case 0x5B:
  12462. this.nextChar();
  12463. return Cmd.get('[');
  12464. case 0x5D:
  12465. this.nextChar();
  12466. return Cmd.get(']');
  12467. case 0x3C:
  12468. ch = this.nextChar();
  12469. if (ch === 0x3C) {
  12470. this.nextChar();
  12471. return Cmd.get('<<');
  12472. }
  12473. return this.getHexString();
  12474. case 0x3E:
  12475. ch = this.nextChar();
  12476. if (ch === 0x3E) {
  12477. this.nextChar();
  12478. return Cmd.get('>>');
  12479. }
  12480. return Cmd.get('>');
  12481. case 0x7B:
  12482. this.nextChar();
  12483. return Cmd.get('{');
  12484. case 0x7D:
  12485. this.nextChar();
  12486. return Cmd.get('}');
  12487. case 0x29:
  12488. this.nextChar();
  12489. error('Illegal character: ' + ch);
  12490. break;
  12491. }
  12492. var str = String.fromCharCode(ch);
  12493. var knownCommands = this.knownCommands;
  12494. var knownCommandFound = knownCommands && knownCommands[str] !== undefined;
  12495. while ((ch = this.nextChar()) >= 0 && !specialChars[ch]) {
  12496. var possibleCommand = str + String.fromCharCode(ch);
  12497. if (knownCommandFound && knownCommands[possibleCommand] === undefined) {
  12498. break;
  12499. }
  12500. if (str.length === 128) {
  12501. error('Command token too long: ' + str.length);
  12502. }
  12503. str = possibleCommand;
  12504. knownCommandFound = knownCommands && knownCommands[str] !== undefined;
  12505. }
  12506. if (str === 'true') {
  12507. return true;
  12508. }
  12509. if (str === 'false') {
  12510. return false;
  12511. }
  12512. if (str === 'null') {
  12513. return null;
  12514. }
  12515. return Cmd.get(str);
  12516. },
  12517. skipToNextLine: function Lexer_skipToNextLine() {
  12518. var ch = this.currentChar;
  12519. while (ch >= 0) {
  12520. if (ch === 0x0D) {
  12521. ch = this.nextChar();
  12522. if (ch === 0x0A) {
  12523. this.nextChar();
  12524. }
  12525. break;
  12526. } else if (ch === 0x0A) {
  12527. this.nextChar();
  12528. break;
  12529. }
  12530. ch = this.nextChar();
  12531. }
  12532. }
  12533. };
  12534. return Lexer;
  12535. }();
  12536. var Linearization = {
  12537. create: function LinearizationCreate(stream) {
  12538. function getInt(name, allowZeroValue) {
  12539. var obj = linDict.get(name);
  12540. if (isInt(obj) && (allowZeroValue ? obj >= 0 : obj > 0)) {
  12541. return obj;
  12542. }
  12543. throw new Error('The "' + name + '" parameter in the linearization ' + 'dictionary is invalid.');
  12544. }
  12545. function getHints() {
  12546. var hints = linDict.get('H'), hintsLength, item;
  12547. if (isArray(hints) && ((hintsLength = hints.length) === 2 || hintsLength === 4)) {
  12548. for (var index = 0; index < hintsLength; index++) {
  12549. if (!(isInt(item = hints[index]) && item > 0)) {
  12550. throw new Error('Hint (' + index + ') in the linearization dictionary is invalid.');
  12551. }
  12552. }
  12553. return hints;
  12554. }
  12555. throw new Error('Hint array in the linearization dictionary is invalid.');
  12556. }
  12557. var parser = new Parser(new Lexer(stream), false, null);
  12558. var obj1 = parser.getObj();
  12559. var obj2 = parser.getObj();
  12560. var obj3 = parser.getObj();
  12561. var linDict = parser.getObj();
  12562. var obj, length;
  12563. if (!(isInt(obj1) && isInt(obj2) && isCmd(obj3, 'obj') && isDict(linDict) && isNum(obj = linDict.get('Linearized')) && obj > 0)) {
  12564. return null;
  12565. } else if ((length = getInt('L')) !== stream.length) {
  12566. throw new Error('The "L" parameter in the linearization dictionary ' + 'does not equal the stream length.');
  12567. }
  12568. return {
  12569. length: length,
  12570. hints: getHints(),
  12571. objectNumberFirst: getInt('O'),
  12572. endFirst: getInt('E'),
  12573. numPages: getInt('N'),
  12574. mainXRefEntriesOffset: getInt('T'),
  12575. pageFirst: linDict.has('P') ? getInt('P', true) : 0
  12576. };
  12577. }
  12578. };
  12579. exports.Lexer = Lexer;
  12580. exports.Linearization = Linearization;
  12581. exports.Parser = Parser;
  12582. /***/ }),
  12583. /* 7 */
  12584. /***/ (function(module, exports, __w_pdfjs_require__) {
  12585. "use strict";
  12586. var sharedUtil = __w_pdfjs_require__(0);
  12587. var corePrimitives = __w_pdfjs_require__(1);
  12588. var corePsParser = __w_pdfjs_require__(42);
  12589. var error = sharedUtil.error;
  12590. var info = sharedUtil.info;
  12591. var isArray = sharedUtil.isArray;
  12592. var isBool = sharedUtil.isBool;
  12593. var isDict = corePrimitives.isDict;
  12594. var isStream = corePrimitives.isStream;
  12595. var PostScriptLexer = corePsParser.PostScriptLexer;
  12596. var PostScriptParser = corePsParser.PostScriptParser;
  12597. var PDFFunction = function PDFFunctionClosure() {
  12598. var CONSTRUCT_SAMPLED = 0;
  12599. var CONSTRUCT_INTERPOLATED = 2;
  12600. var CONSTRUCT_STICHED = 3;
  12601. var CONSTRUCT_POSTSCRIPT = 4;
  12602. return {
  12603. getSampleArray: function PDFFunction_getSampleArray(size, outputSize, bps, str) {
  12604. var i, ii;
  12605. var length = 1;
  12606. for (i = 0, ii = size.length; i < ii; i++) {
  12607. length *= size[i];
  12608. }
  12609. length *= outputSize;
  12610. var array = new Array(length);
  12611. var codeSize = 0;
  12612. var codeBuf = 0;
  12613. var sampleMul = 1.0 / (Math.pow(2.0, bps) - 1);
  12614. var strBytes = str.getBytes((length * bps + 7) / 8);
  12615. var strIdx = 0;
  12616. for (i = 0; i < length; i++) {
  12617. while (codeSize < bps) {
  12618. codeBuf <<= 8;
  12619. codeBuf |= strBytes[strIdx++];
  12620. codeSize += 8;
  12621. }
  12622. codeSize -= bps;
  12623. array[i] = (codeBuf >> codeSize) * sampleMul;
  12624. codeBuf &= (1 << codeSize) - 1;
  12625. }
  12626. return array;
  12627. },
  12628. getIR: function PDFFunction_getIR(xref, fn) {
  12629. var dict = fn.dict;
  12630. if (!dict) {
  12631. dict = fn;
  12632. }
  12633. var types = [
  12634. this.constructSampled,
  12635. null,
  12636. this.constructInterpolated,
  12637. this.constructStiched,
  12638. this.constructPostScript
  12639. ];
  12640. var typeNum = dict.get('FunctionType');
  12641. var typeFn = types[typeNum];
  12642. if (!typeFn) {
  12643. error('Unknown type of function');
  12644. }
  12645. return typeFn.call(this, fn, dict, xref);
  12646. },
  12647. fromIR: function PDFFunction_fromIR(IR) {
  12648. var type = IR[0];
  12649. switch (type) {
  12650. case CONSTRUCT_SAMPLED:
  12651. return this.constructSampledFromIR(IR);
  12652. case CONSTRUCT_INTERPOLATED:
  12653. return this.constructInterpolatedFromIR(IR);
  12654. case CONSTRUCT_STICHED:
  12655. return this.constructStichedFromIR(IR);
  12656. default:
  12657. return this.constructPostScriptFromIR(IR);
  12658. }
  12659. },
  12660. parse: function PDFFunction_parse(xref, fn) {
  12661. var IR = this.getIR(xref, fn);
  12662. return this.fromIR(IR);
  12663. },
  12664. parseArray: function PDFFunction_parseArray(xref, fnObj) {
  12665. if (!isArray(fnObj)) {
  12666. return this.parse(xref, fnObj);
  12667. }
  12668. var fnArray = [];
  12669. for (var j = 0, jj = fnObj.length; j < jj; j++) {
  12670. var obj = xref.fetchIfRef(fnObj[j]);
  12671. fnArray.push(PDFFunction.parse(xref, obj));
  12672. }
  12673. return function (src, srcOffset, dest, destOffset) {
  12674. for (var i = 0, ii = fnArray.length; i < ii; i++) {
  12675. fnArray[i](src, srcOffset, dest, destOffset + i);
  12676. }
  12677. };
  12678. },
  12679. constructSampled: function PDFFunction_constructSampled(str, dict) {
  12680. function toMultiArray(arr) {
  12681. var inputLength = arr.length;
  12682. var out = [];
  12683. var index = 0;
  12684. for (var i = 0; i < inputLength; i += 2) {
  12685. out[index] = [
  12686. arr[i],
  12687. arr[i + 1]
  12688. ];
  12689. ++index;
  12690. }
  12691. return out;
  12692. }
  12693. var domain = dict.getArray('Domain');
  12694. var range = dict.getArray('Range');
  12695. if (!domain || !range) {
  12696. error('No domain or range');
  12697. }
  12698. var inputSize = domain.length / 2;
  12699. var outputSize = range.length / 2;
  12700. domain = toMultiArray(domain);
  12701. range = toMultiArray(range);
  12702. var size = dict.get('Size');
  12703. var bps = dict.get('BitsPerSample');
  12704. var order = dict.get('Order') || 1;
  12705. if (order !== 1) {
  12706. info('No support for cubic spline interpolation: ' + order);
  12707. }
  12708. var encode = dict.getArray('Encode');
  12709. if (!encode) {
  12710. encode = [];
  12711. for (var i = 0; i < inputSize; ++i) {
  12712. encode.push(0);
  12713. encode.push(size[i] - 1);
  12714. }
  12715. }
  12716. encode = toMultiArray(encode);
  12717. var decode = dict.getArray('Decode');
  12718. if (!decode) {
  12719. decode = range;
  12720. } else {
  12721. decode = toMultiArray(decode);
  12722. }
  12723. var samples = this.getSampleArray(size, outputSize, bps, str);
  12724. return [
  12725. CONSTRUCT_SAMPLED,
  12726. inputSize,
  12727. domain,
  12728. encode,
  12729. decode,
  12730. samples,
  12731. size,
  12732. outputSize,
  12733. Math.pow(2, bps) - 1,
  12734. range
  12735. ];
  12736. },
  12737. constructSampledFromIR: function PDFFunction_constructSampledFromIR(IR) {
  12738. function interpolate(x, xmin, xmax, ymin, ymax) {
  12739. return ymin + (x - xmin) * ((ymax - ymin) / (xmax - xmin));
  12740. }
  12741. return function constructSampledFromIRResult(src, srcOffset, dest, destOffset) {
  12742. var m = IR[1];
  12743. var domain = IR[2];
  12744. var encode = IR[3];
  12745. var decode = IR[4];
  12746. var samples = IR[5];
  12747. var size = IR[6];
  12748. var n = IR[7];
  12749. var range = IR[9];
  12750. var cubeVertices = 1 << m;
  12751. var cubeN = new Float64Array(cubeVertices);
  12752. var cubeVertex = new Uint32Array(cubeVertices);
  12753. var i, j;
  12754. for (j = 0; j < cubeVertices; j++) {
  12755. cubeN[j] = 1;
  12756. }
  12757. var k = n, pos = 1;
  12758. for (i = 0; i < m; ++i) {
  12759. var domain_2i = domain[i][0];
  12760. var domain_2i_1 = domain[i][1];
  12761. var xi = Math.min(Math.max(src[srcOffset + i], domain_2i), domain_2i_1);
  12762. var e = interpolate(xi, domain_2i, domain_2i_1, encode[i][0], encode[i][1]);
  12763. var size_i = size[i];
  12764. e = Math.min(Math.max(e, 0), size_i - 1);
  12765. var e0 = e < size_i - 1 ? Math.floor(e) : e - 1;
  12766. var n0 = e0 + 1 - e;
  12767. var n1 = e - e0;
  12768. var offset0 = e0 * k;
  12769. var offset1 = offset0 + k;
  12770. for (j = 0; j < cubeVertices; j++) {
  12771. if (j & pos) {
  12772. cubeN[j] *= n1;
  12773. cubeVertex[j] += offset1;
  12774. } else {
  12775. cubeN[j] *= n0;
  12776. cubeVertex[j] += offset0;
  12777. }
  12778. }
  12779. k *= size_i;
  12780. pos <<= 1;
  12781. }
  12782. for (j = 0; j < n; ++j) {
  12783. var rj = 0;
  12784. for (i = 0; i < cubeVertices; i++) {
  12785. rj += samples[cubeVertex[i] + j] * cubeN[i];
  12786. }
  12787. rj = interpolate(rj, 0, 1, decode[j][0], decode[j][1]);
  12788. dest[destOffset + j] = Math.min(Math.max(rj, range[j][0]), range[j][1]);
  12789. }
  12790. };
  12791. },
  12792. constructInterpolated: function PDFFunction_constructInterpolated(str, dict) {
  12793. var c0 = dict.getArray('C0') || [0];
  12794. var c1 = dict.getArray('C1') || [1];
  12795. var n = dict.get('N');
  12796. if (!isArray(c0) || !isArray(c1)) {
  12797. error('Illegal dictionary for interpolated function');
  12798. }
  12799. var length = c0.length;
  12800. var diff = [];
  12801. for (var i = 0; i < length; ++i) {
  12802. diff.push(c1[i] - c0[i]);
  12803. }
  12804. return [
  12805. CONSTRUCT_INTERPOLATED,
  12806. c0,
  12807. diff,
  12808. n
  12809. ];
  12810. },
  12811. constructInterpolatedFromIR: function PDFFunction_constructInterpolatedFromIR(IR) {
  12812. var c0 = IR[1];
  12813. var diff = IR[2];
  12814. var n = IR[3];
  12815. var length = diff.length;
  12816. return function constructInterpolatedFromIRResult(src, srcOffset, dest, destOffset) {
  12817. var x = n === 1 ? src[srcOffset] : Math.pow(src[srcOffset], n);
  12818. for (var j = 0; j < length; ++j) {
  12819. dest[destOffset + j] = c0[j] + x * diff[j];
  12820. }
  12821. };
  12822. },
  12823. constructStiched: function PDFFunction_constructStiched(fn, dict, xref) {
  12824. var domain = dict.getArray('Domain');
  12825. if (!domain) {
  12826. error('No domain');
  12827. }
  12828. var inputSize = domain.length / 2;
  12829. if (inputSize !== 1) {
  12830. error('Bad domain for stiched function');
  12831. }
  12832. var fnRefs = dict.get('Functions');
  12833. var fns = [];
  12834. for (var i = 0, ii = fnRefs.length; i < ii; ++i) {
  12835. fns.push(PDFFunction.getIR(xref, xref.fetchIfRef(fnRefs[i])));
  12836. }
  12837. var bounds = dict.getArray('Bounds');
  12838. var encode = dict.getArray('Encode');
  12839. return [
  12840. CONSTRUCT_STICHED,
  12841. domain,
  12842. bounds,
  12843. encode,
  12844. fns
  12845. ];
  12846. },
  12847. constructStichedFromIR: function PDFFunction_constructStichedFromIR(IR) {
  12848. var domain = IR[1];
  12849. var bounds = IR[2];
  12850. var encode = IR[3];
  12851. var fnsIR = IR[4];
  12852. var fns = [];
  12853. var tmpBuf = new Float32Array(1);
  12854. for (var i = 0, ii = fnsIR.length; i < ii; i++) {
  12855. fns.push(PDFFunction.fromIR(fnsIR[i]));
  12856. }
  12857. return function constructStichedFromIRResult(src, srcOffset, dest, destOffset) {
  12858. var clip = function constructStichedFromIRClip(v, min, max) {
  12859. if (v > max) {
  12860. v = max;
  12861. } else if (v < min) {
  12862. v = min;
  12863. }
  12864. return v;
  12865. };
  12866. var v = clip(src[srcOffset], domain[0], domain[1]);
  12867. for (var i = 0, ii = bounds.length; i < ii; ++i) {
  12868. if (v < bounds[i]) {
  12869. break;
  12870. }
  12871. }
  12872. var dmin = domain[0];
  12873. if (i > 0) {
  12874. dmin = bounds[i - 1];
  12875. }
  12876. var dmax = domain[1];
  12877. if (i < bounds.length) {
  12878. dmax = bounds[i];
  12879. }
  12880. var rmin = encode[2 * i];
  12881. var rmax = encode[2 * i + 1];
  12882. tmpBuf[0] = dmin === dmax ? rmin : rmin + (v - dmin) * (rmax - rmin) / (dmax - dmin);
  12883. fns[i](tmpBuf, 0, dest, destOffset);
  12884. };
  12885. },
  12886. constructPostScript: function PDFFunction_constructPostScript(fn, dict, xref) {
  12887. var domain = dict.getArray('Domain');
  12888. var range = dict.getArray('Range');
  12889. if (!domain) {
  12890. error('No domain.');
  12891. }
  12892. if (!range) {
  12893. error('No range.');
  12894. }
  12895. var lexer = new PostScriptLexer(fn);
  12896. var parser = new PostScriptParser(lexer);
  12897. var code = parser.parse();
  12898. return [
  12899. CONSTRUCT_POSTSCRIPT,
  12900. domain,
  12901. range,
  12902. code
  12903. ];
  12904. },
  12905. constructPostScriptFromIR: function PDFFunction_constructPostScriptFromIR(IR) {
  12906. var domain = IR[1];
  12907. var range = IR[2];
  12908. var code = IR[3];
  12909. var compiled = new PostScriptCompiler().compile(code, domain, range);
  12910. if (compiled) {
  12911. return new Function('src', 'srcOffset', 'dest', 'destOffset', compiled);
  12912. }
  12913. info('Unable to compile PS function');
  12914. var numOutputs = range.length >> 1;
  12915. var numInputs = domain.length >> 1;
  12916. var evaluator = new PostScriptEvaluator(code);
  12917. var cache = Object.create(null);
  12918. var MAX_CACHE_SIZE = 2048 * 4;
  12919. var cache_available = MAX_CACHE_SIZE;
  12920. var tmpBuf = new Float32Array(numInputs);
  12921. return function constructPostScriptFromIRResult(src, srcOffset, dest, destOffset) {
  12922. var i, value;
  12923. var key = '';
  12924. var input = tmpBuf;
  12925. for (i = 0; i < numInputs; i++) {
  12926. value = src[srcOffset + i];
  12927. input[i] = value;
  12928. key += value + '_';
  12929. }
  12930. var cachedValue = cache[key];
  12931. if (cachedValue !== undefined) {
  12932. dest.set(cachedValue, destOffset);
  12933. return;
  12934. }
  12935. var output = new Float32Array(numOutputs);
  12936. var stack = evaluator.execute(input);
  12937. var stackIndex = stack.length - numOutputs;
  12938. for (i = 0; i < numOutputs; i++) {
  12939. value = stack[stackIndex + i];
  12940. var bound = range[i * 2];
  12941. if (value < bound) {
  12942. value = bound;
  12943. } else {
  12944. bound = range[i * 2 + 1];
  12945. if (value > bound) {
  12946. value = bound;
  12947. }
  12948. }
  12949. output[i] = value;
  12950. }
  12951. if (cache_available > 0) {
  12952. cache_available--;
  12953. cache[key] = output;
  12954. }
  12955. dest.set(output, destOffset);
  12956. };
  12957. }
  12958. };
  12959. }();
  12960. function isPDFFunction(v) {
  12961. var fnDict;
  12962. if (typeof v !== 'object') {
  12963. return false;
  12964. } else if (isDict(v)) {
  12965. fnDict = v;
  12966. } else if (isStream(v)) {
  12967. fnDict = v.dict;
  12968. } else {
  12969. return false;
  12970. }
  12971. return fnDict.has('FunctionType');
  12972. }
  12973. var PostScriptStack = function PostScriptStackClosure() {
  12974. var MAX_STACK_SIZE = 100;
  12975. function PostScriptStack(initialStack) {
  12976. this.stack = !initialStack ? [] : Array.prototype.slice.call(initialStack, 0);
  12977. }
  12978. PostScriptStack.prototype = {
  12979. push: function PostScriptStack_push(value) {
  12980. if (this.stack.length >= MAX_STACK_SIZE) {
  12981. error('PostScript function stack overflow.');
  12982. }
  12983. this.stack.push(value);
  12984. },
  12985. pop: function PostScriptStack_pop() {
  12986. if (this.stack.length <= 0) {
  12987. error('PostScript function stack underflow.');
  12988. }
  12989. return this.stack.pop();
  12990. },
  12991. copy: function PostScriptStack_copy(n) {
  12992. if (this.stack.length + n >= MAX_STACK_SIZE) {
  12993. error('PostScript function stack overflow.');
  12994. }
  12995. var stack = this.stack;
  12996. for (var i = stack.length - n, j = n - 1; j >= 0; j--, i++) {
  12997. stack.push(stack[i]);
  12998. }
  12999. },
  13000. index: function PostScriptStack_index(n) {
  13001. this.push(this.stack[this.stack.length - n - 1]);
  13002. },
  13003. roll: function PostScriptStack_roll(n, p) {
  13004. var stack = this.stack;
  13005. var l = stack.length - n;
  13006. var r = stack.length - 1, c = l + (p - Math.floor(p / n) * n), i, j, t;
  13007. for (i = l, j = r; i < j; i++, j--) {
  13008. t = stack[i];
  13009. stack[i] = stack[j];
  13010. stack[j] = t;
  13011. }
  13012. for (i = l, j = c - 1; i < j; i++, j--) {
  13013. t = stack[i];
  13014. stack[i] = stack[j];
  13015. stack[j] = t;
  13016. }
  13017. for (i = c, j = r; i < j; i++, j--) {
  13018. t = stack[i];
  13019. stack[i] = stack[j];
  13020. stack[j] = t;
  13021. }
  13022. }
  13023. };
  13024. return PostScriptStack;
  13025. }();
  13026. var PostScriptEvaluator = function PostScriptEvaluatorClosure() {
  13027. function PostScriptEvaluator(operators) {
  13028. this.operators = operators;
  13029. }
  13030. PostScriptEvaluator.prototype = {
  13031. execute: function PostScriptEvaluator_execute(initialStack) {
  13032. var stack = new PostScriptStack(initialStack);
  13033. var counter = 0;
  13034. var operators = this.operators;
  13035. var length = operators.length;
  13036. var operator, a, b;
  13037. while (counter < length) {
  13038. operator = operators[counter++];
  13039. if (typeof operator === 'number') {
  13040. stack.push(operator);
  13041. continue;
  13042. }
  13043. switch (operator) {
  13044. case 'jz':
  13045. b = stack.pop();
  13046. a = stack.pop();
  13047. if (!a) {
  13048. counter = b;
  13049. }
  13050. break;
  13051. case 'j':
  13052. a = stack.pop();
  13053. counter = a;
  13054. break;
  13055. case 'abs':
  13056. a = stack.pop();
  13057. stack.push(Math.abs(a));
  13058. break;
  13059. case 'add':
  13060. b = stack.pop();
  13061. a = stack.pop();
  13062. stack.push(a + b);
  13063. break;
  13064. case 'and':
  13065. b = stack.pop();
  13066. a = stack.pop();
  13067. if (isBool(a) && isBool(b)) {
  13068. stack.push(a && b);
  13069. } else {
  13070. stack.push(a & b);
  13071. }
  13072. break;
  13073. case 'atan':
  13074. a = stack.pop();
  13075. stack.push(Math.atan(a));
  13076. break;
  13077. case 'bitshift':
  13078. b = stack.pop();
  13079. a = stack.pop();
  13080. if (a > 0) {
  13081. stack.push(a << b);
  13082. } else {
  13083. stack.push(a >> b);
  13084. }
  13085. break;
  13086. case 'ceiling':
  13087. a = stack.pop();
  13088. stack.push(Math.ceil(a));
  13089. break;
  13090. case 'copy':
  13091. a = stack.pop();
  13092. stack.copy(a);
  13093. break;
  13094. case 'cos':
  13095. a = stack.pop();
  13096. stack.push(Math.cos(a));
  13097. break;
  13098. case 'cvi':
  13099. a = stack.pop() | 0;
  13100. stack.push(a);
  13101. break;
  13102. case 'cvr':
  13103. break;
  13104. case 'div':
  13105. b = stack.pop();
  13106. a = stack.pop();
  13107. stack.push(a / b);
  13108. break;
  13109. case 'dup':
  13110. stack.copy(1);
  13111. break;
  13112. case 'eq':
  13113. b = stack.pop();
  13114. a = stack.pop();
  13115. stack.push(a === b);
  13116. break;
  13117. case 'exch':
  13118. stack.roll(2, 1);
  13119. break;
  13120. case 'exp':
  13121. b = stack.pop();
  13122. a = stack.pop();
  13123. stack.push(Math.pow(a, b));
  13124. break;
  13125. case 'false':
  13126. stack.push(false);
  13127. break;
  13128. case 'floor':
  13129. a = stack.pop();
  13130. stack.push(Math.floor(a));
  13131. break;
  13132. case 'ge':
  13133. b = stack.pop();
  13134. a = stack.pop();
  13135. stack.push(a >= b);
  13136. break;
  13137. case 'gt':
  13138. b = stack.pop();
  13139. a = stack.pop();
  13140. stack.push(a > b);
  13141. break;
  13142. case 'idiv':
  13143. b = stack.pop();
  13144. a = stack.pop();
  13145. stack.push(a / b | 0);
  13146. break;
  13147. case 'index':
  13148. a = stack.pop();
  13149. stack.index(a);
  13150. break;
  13151. case 'le':
  13152. b = stack.pop();
  13153. a = stack.pop();
  13154. stack.push(a <= b);
  13155. break;
  13156. case 'ln':
  13157. a = stack.pop();
  13158. stack.push(Math.log(a));
  13159. break;
  13160. case 'log':
  13161. a = stack.pop();
  13162. stack.push(Math.log(a) / Math.LN10);
  13163. break;
  13164. case 'lt':
  13165. b = stack.pop();
  13166. a = stack.pop();
  13167. stack.push(a < b);
  13168. break;
  13169. case 'mod':
  13170. b = stack.pop();
  13171. a = stack.pop();
  13172. stack.push(a % b);
  13173. break;
  13174. case 'mul':
  13175. b = stack.pop();
  13176. a = stack.pop();
  13177. stack.push(a * b);
  13178. break;
  13179. case 'ne':
  13180. b = stack.pop();
  13181. a = stack.pop();
  13182. stack.push(a !== b);
  13183. break;
  13184. case 'neg':
  13185. a = stack.pop();
  13186. stack.push(-a);
  13187. break;
  13188. case 'not':
  13189. a = stack.pop();
  13190. if (isBool(a)) {
  13191. stack.push(!a);
  13192. } else {
  13193. stack.push(~a);
  13194. }
  13195. break;
  13196. case 'or':
  13197. b = stack.pop();
  13198. a = stack.pop();
  13199. if (isBool(a) && isBool(b)) {
  13200. stack.push(a || b);
  13201. } else {
  13202. stack.push(a | b);
  13203. }
  13204. break;
  13205. case 'pop':
  13206. stack.pop();
  13207. break;
  13208. case 'roll':
  13209. b = stack.pop();
  13210. a = stack.pop();
  13211. stack.roll(a, b);
  13212. break;
  13213. case 'round':
  13214. a = stack.pop();
  13215. stack.push(Math.round(a));
  13216. break;
  13217. case 'sin':
  13218. a = stack.pop();
  13219. stack.push(Math.sin(a));
  13220. break;
  13221. case 'sqrt':
  13222. a = stack.pop();
  13223. stack.push(Math.sqrt(a));
  13224. break;
  13225. case 'sub':
  13226. b = stack.pop();
  13227. a = stack.pop();
  13228. stack.push(a - b);
  13229. break;
  13230. case 'true':
  13231. stack.push(true);
  13232. break;
  13233. case 'truncate':
  13234. a = stack.pop();
  13235. a = a < 0 ? Math.ceil(a) : Math.floor(a);
  13236. stack.push(a);
  13237. break;
  13238. case 'xor':
  13239. b = stack.pop();
  13240. a = stack.pop();
  13241. if (isBool(a) && isBool(b)) {
  13242. stack.push(a !== b);
  13243. } else {
  13244. stack.push(a ^ b);
  13245. }
  13246. break;
  13247. default:
  13248. error('Unknown operator ' + operator);
  13249. break;
  13250. }
  13251. }
  13252. return stack.stack;
  13253. }
  13254. };
  13255. return PostScriptEvaluator;
  13256. }();
  13257. var PostScriptCompiler = function PostScriptCompilerClosure() {
  13258. function AstNode(type) {
  13259. this.type = type;
  13260. }
  13261. AstNode.prototype.visit = function (visitor) {
  13262. throw new Error('abstract method');
  13263. };
  13264. function AstArgument(index, min, max) {
  13265. AstNode.call(this, 'args');
  13266. this.index = index;
  13267. this.min = min;
  13268. this.max = max;
  13269. }
  13270. AstArgument.prototype = Object.create(AstNode.prototype);
  13271. AstArgument.prototype.visit = function (visitor) {
  13272. visitor.visitArgument(this);
  13273. };
  13274. function AstLiteral(number) {
  13275. AstNode.call(this, 'literal');
  13276. this.number = number;
  13277. this.min = number;
  13278. this.max = number;
  13279. }
  13280. AstLiteral.prototype = Object.create(AstNode.prototype);
  13281. AstLiteral.prototype.visit = function (visitor) {
  13282. visitor.visitLiteral(this);
  13283. };
  13284. function AstBinaryOperation(op, arg1, arg2, min, max) {
  13285. AstNode.call(this, 'binary');
  13286. this.op = op;
  13287. this.arg1 = arg1;
  13288. this.arg2 = arg2;
  13289. this.min = min;
  13290. this.max = max;
  13291. }
  13292. AstBinaryOperation.prototype = Object.create(AstNode.prototype);
  13293. AstBinaryOperation.prototype.visit = function (visitor) {
  13294. visitor.visitBinaryOperation(this);
  13295. };
  13296. function AstMin(arg, max) {
  13297. AstNode.call(this, 'max');
  13298. this.arg = arg;
  13299. this.min = arg.min;
  13300. this.max = max;
  13301. }
  13302. AstMin.prototype = Object.create(AstNode.prototype);
  13303. AstMin.prototype.visit = function (visitor) {
  13304. visitor.visitMin(this);
  13305. };
  13306. function AstVariable(index, min, max) {
  13307. AstNode.call(this, 'var');
  13308. this.index = index;
  13309. this.min = min;
  13310. this.max = max;
  13311. }
  13312. AstVariable.prototype = Object.create(AstNode.prototype);
  13313. AstVariable.prototype.visit = function (visitor) {
  13314. visitor.visitVariable(this);
  13315. };
  13316. function AstVariableDefinition(variable, arg) {
  13317. AstNode.call(this, 'definition');
  13318. this.variable = variable;
  13319. this.arg = arg;
  13320. }
  13321. AstVariableDefinition.prototype = Object.create(AstNode.prototype);
  13322. AstVariableDefinition.prototype.visit = function (visitor) {
  13323. visitor.visitVariableDefinition(this);
  13324. };
  13325. function ExpressionBuilderVisitor() {
  13326. this.parts = [];
  13327. }
  13328. ExpressionBuilderVisitor.prototype = {
  13329. visitArgument: function (arg) {
  13330. this.parts.push('Math.max(', arg.min, ', Math.min(', arg.max, ', src[srcOffset + ', arg.index, ']))');
  13331. },
  13332. visitVariable: function (variable) {
  13333. this.parts.push('v', variable.index);
  13334. },
  13335. visitLiteral: function (literal) {
  13336. this.parts.push(literal.number);
  13337. },
  13338. visitBinaryOperation: function (operation) {
  13339. this.parts.push('(');
  13340. operation.arg1.visit(this);
  13341. this.parts.push(' ', operation.op, ' ');
  13342. operation.arg2.visit(this);
  13343. this.parts.push(')');
  13344. },
  13345. visitVariableDefinition: function (definition) {
  13346. this.parts.push('var ');
  13347. definition.variable.visit(this);
  13348. this.parts.push(' = ');
  13349. definition.arg.visit(this);
  13350. this.parts.push(';');
  13351. },
  13352. visitMin: function (max) {
  13353. this.parts.push('Math.min(');
  13354. max.arg.visit(this);
  13355. this.parts.push(', ', max.max, ')');
  13356. },
  13357. toString: function () {
  13358. return this.parts.join('');
  13359. }
  13360. };
  13361. function buildAddOperation(num1, num2) {
  13362. if (num2.type === 'literal' && num2.number === 0) {
  13363. return num1;
  13364. }
  13365. if (num1.type === 'literal' && num1.number === 0) {
  13366. return num2;
  13367. }
  13368. if (num2.type === 'literal' && num1.type === 'literal') {
  13369. return new AstLiteral(num1.number + num2.number);
  13370. }
  13371. return new AstBinaryOperation('+', num1, num2, num1.min + num2.min, num1.max + num2.max);
  13372. }
  13373. function buildMulOperation(num1, num2) {
  13374. if (num2.type === 'literal') {
  13375. if (num2.number === 0) {
  13376. return new AstLiteral(0);
  13377. } else if (num2.number === 1) {
  13378. return num1;
  13379. } else if (num1.type === 'literal') {
  13380. return new AstLiteral(num1.number * num2.number);
  13381. }
  13382. }
  13383. if (num1.type === 'literal') {
  13384. if (num1.number === 0) {
  13385. return new AstLiteral(0);
  13386. } else if (num1.number === 1) {
  13387. return num2;
  13388. }
  13389. }
  13390. var min = Math.min(num1.min * num2.min, num1.min * num2.max, num1.max * num2.min, num1.max * num2.max);
  13391. var max = Math.max(num1.min * num2.min, num1.min * num2.max, num1.max * num2.min, num1.max * num2.max);
  13392. return new AstBinaryOperation('*', num1, num2, min, max);
  13393. }
  13394. function buildSubOperation(num1, num2) {
  13395. if (num2.type === 'literal') {
  13396. if (num2.number === 0) {
  13397. return num1;
  13398. } else if (num1.type === 'literal') {
  13399. return new AstLiteral(num1.number - num2.number);
  13400. }
  13401. }
  13402. if (num2.type === 'binary' && num2.op === '-' && num1.type === 'literal' && num1.number === 1 && num2.arg1.type === 'literal' && num2.arg1.number === 1) {
  13403. return num2.arg2;
  13404. }
  13405. return new AstBinaryOperation('-', num1, num2, num1.min - num2.max, num1.max - num2.min);
  13406. }
  13407. function buildMinOperation(num1, max) {
  13408. if (num1.min >= max) {
  13409. return new AstLiteral(max);
  13410. } else if (num1.max <= max) {
  13411. return num1;
  13412. }
  13413. return new AstMin(num1, max);
  13414. }
  13415. function PostScriptCompiler() {
  13416. }
  13417. PostScriptCompiler.prototype = {
  13418. compile: function PostScriptCompiler_compile(code, domain, range) {
  13419. var stack = [];
  13420. var i, ii;
  13421. var instructions = [];
  13422. var inputSize = domain.length >> 1, outputSize = range.length >> 1;
  13423. var lastRegister = 0;
  13424. var n, j;
  13425. var num1, num2, ast1, ast2, tmpVar, item;
  13426. for (i = 0; i < inputSize; i++) {
  13427. stack.push(new AstArgument(i, domain[i * 2], domain[i * 2 + 1]));
  13428. }
  13429. for (i = 0, ii = code.length; i < ii; i++) {
  13430. item = code[i];
  13431. if (typeof item === 'number') {
  13432. stack.push(new AstLiteral(item));
  13433. continue;
  13434. }
  13435. switch (item) {
  13436. case 'add':
  13437. if (stack.length < 2) {
  13438. return null;
  13439. }
  13440. num2 = stack.pop();
  13441. num1 = stack.pop();
  13442. stack.push(buildAddOperation(num1, num2));
  13443. break;
  13444. case 'cvr':
  13445. if (stack.length < 1) {
  13446. return null;
  13447. }
  13448. break;
  13449. case 'mul':
  13450. if (stack.length < 2) {
  13451. return null;
  13452. }
  13453. num2 = stack.pop();
  13454. num1 = stack.pop();
  13455. stack.push(buildMulOperation(num1, num2));
  13456. break;
  13457. case 'sub':
  13458. if (stack.length < 2) {
  13459. return null;
  13460. }
  13461. num2 = stack.pop();
  13462. num1 = stack.pop();
  13463. stack.push(buildSubOperation(num1, num2));
  13464. break;
  13465. case 'exch':
  13466. if (stack.length < 2) {
  13467. return null;
  13468. }
  13469. ast1 = stack.pop();
  13470. ast2 = stack.pop();
  13471. stack.push(ast1, ast2);
  13472. break;
  13473. case 'pop':
  13474. if (stack.length < 1) {
  13475. return null;
  13476. }
  13477. stack.pop();
  13478. break;
  13479. case 'index':
  13480. if (stack.length < 1) {
  13481. return null;
  13482. }
  13483. num1 = stack.pop();
  13484. if (num1.type !== 'literal') {
  13485. return null;
  13486. }
  13487. n = num1.number;
  13488. if (n < 0 || (n | 0) !== n || stack.length < n) {
  13489. return null;
  13490. }
  13491. ast1 = stack[stack.length - n - 1];
  13492. if (ast1.type === 'literal' || ast1.type === 'var') {
  13493. stack.push(ast1);
  13494. break;
  13495. }
  13496. tmpVar = new AstVariable(lastRegister++, ast1.min, ast1.max);
  13497. stack[stack.length - n - 1] = tmpVar;
  13498. stack.push(tmpVar);
  13499. instructions.push(new AstVariableDefinition(tmpVar, ast1));
  13500. break;
  13501. case 'dup':
  13502. if (stack.length < 1) {
  13503. return null;
  13504. }
  13505. 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]) {
  13506. num1 = stack.pop();
  13507. stack.push(buildMinOperation(num1, code[i + 1]));
  13508. i += 6;
  13509. break;
  13510. }
  13511. ast1 = stack[stack.length - 1];
  13512. if (ast1.type === 'literal' || ast1.type === 'var') {
  13513. stack.push(ast1);
  13514. break;
  13515. }
  13516. tmpVar = new AstVariable(lastRegister++, ast1.min, ast1.max);
  13517. stack[stack.length - 1] = tmpVar;
  13518. stack.push(tmpVar);
  13519. instructions.push(new AstVariableDefinition(tmpVar, ast1));
  13520. break;
  13521. case 'roll':
  13522. if (stack.length < 2) {
  13523. return null;
  13524. }
  13525. num2 = stack.pop();
  13526. num1 = stack.pop();
  13527. if (num2.type !== 'literal' || num1.type !== 'literal') {
  13528. return null;
  13529. }
  13530. j = num2.number;
  13531. n = num1.number;
  13532. if (n <= 0 || (n | 0) !== n || (j | 0) !== j || stack.length < n) {
  13533. return null;
  13534. }
  13535. j = (j % n + n) % n;
  13536. if (j === 0) {
  13537. break;
  13538. }
  13539. Array.prototype.push.apply(stack, stack.splice(stack.length - n, n - j));
  13540. break;
  13541. default:
  13542. return null;
  13543. }
  13544. }
  13545. if (stack.length !== outputSize) {
  13546. return null;
  13547. }
  13548. var result = [];
  13549. instructions.forEach(function (instruction) {
  13550. var statementBuilder = new ExpressionBuilderVisitor();
  13551. instruction.visit(statementBuilder);
  13552. result.push(statementBuilder.toString());
  13553. });
  13554. stack.forEach(function (expr, i) {
  13555. var statementBuilder = new ExpressionBuilderVisitor();
  13556. expr.visit(statementBuilder);
  13557. var min = range[i * 2], max = range[i * 2 + 1];
  13558. var out = [statementBuilder.toString()];
  13559. if (min > expr.min) {
  13560. out.unshift('Math.max(', min, ', ');
  13561. out.push(')');
  13562. }
  13563. if (max < expr.max) {
  13564. out.unshift('Math.min(', max, ', ');
  13565. out.push(')');
  13566. }
  13567. out.unshift('dest[destOffset + ', i, '] = ');
  13568. out.push(';');
  13569. result.push(out.join(''));
  13570. });
  13571. return result.join('\n');
  13572. }
  13573. };
  13574. return PostScriptCompiler;
  13575. }();
  13576. exports.isPDFFunction = isPDFFunction;
  13577. exports.PDFFunction = PDFFunction;
  13578. exports.PostScriptEvaluator = PostScriptEvaluator;
  13579. exports.PostScriptCompiler = PostScriptCompiler;
  13580. /***/ }),
  13581. /* 8 */
  13582. /***/ (function(module, exports, __w_pdfjs_require__) {
  13583. "use strict";
  13584. var sharedUtil = __w_pdfjs_require__(0);
  13585. var getLookupTableFactory = sharedUtil.getLookupTableFactory;
  13586. var getGlyphsUnicode = getLookupTableFactory(function (t) {
  13587. t['A'] = 0x0041;
  13588. t['AE'] = 0x00C6;
  13589. t['AEacute'] = 0x01FC;
  13590. t['AEmacron'] = 0x01E2;
  13591. t['AEsmall'] = 0xF7E6;
  13592. t['Aacute'] = 0x00C1;
  13593. t['Aacutesmall'] = 0xF7E1;
  13594. t['Abreve'] = 0x0102;
  13595. t['Abreveacute'] = 0x1EAE;
  13596. t['Abrevecyrillic'] = 0x04D0;
  13597. t['Abrevedotbelow'] = 0x1EB6;
  13598. t['Abrevegrave'] = 0x1EB0;
  13599. t['Abrevehookabove'] = 0x1EB2;
  13600. t['Abrevetilde'] = 0x1EB4;
  13601. t['Acaron'] = 0x01CD;
  13602. t['Acircle'] = 0x24B6;
  13603. t['Acircumflex'] = 0x00C2;
  13604. t['Acircumflexacute'] = 0x1EA4;
  13605. t['Acircumflexdotbelow'] = 0x1EAC;
  13606. t['Acircumflexgrave'] = 0x1EA6;
  13607. t['Acircumflexhookabove'] = 0x1EA8;
  13608. t['Acircumflexsmall'] = 0xF7E2;
  13609. t['Acircumflextilde'] = 0x1EAA;
  13610. t['Acute'] = 0xF6C9;
  13611. t['Acutesmall'] = 0xF7B4;
  13612. t['Acyrillic'] = 0x0410;
  13613. t['Adblgrave'] = 0x0200;
  13614. t['Adieresis'] = 0x00C4;
  13615. t['Adieresiscyrillic'] = 0x04D2;
  13616. t['Adieresismacron'] = 0x01DE;
  13617. t['Adieresissmall'] = 0xF7E4;
  13618. t['Adotbelow'] = 0x1EA0;
  13619. t['Adotmacron'] = 0x01E0;
  13620. t['Agrave'] = 0x00C0;
  13621. t['Agravesmall'] = 0xF7E0;
  13622. t['Ahookabove'] = 0x1EA2;
  13623. t['Aiecyrillic'] = 0x04D4;
  13624. t['Ainvertedbreve'] = 0x0202;
  13625. t['Alpha'] = 0x0391;
  13626. t['Alphatonos'] = 0x0386;
  13627. t['Amacron'] = 0x0100;
  13628. t['Amonospace'] = 0xFF21;
  13629. t['Aogonek'] = 0x0104;
  13630. t['Aring'] = 0x00C5;
  13631. t['Aringacute'] = 0x01FA;
  13632. t['Aringbelow'] = 0x1E00;
  13633. t['Aringsmall'] = 0xF7E5;
  13634. t['Asmall'] = 0xF761;
  13635. t['Atilde'] = 0x00C3;
  13636. t['Atildesmall'] = 0xF7E3;
  13637. t['Aybarmenian'] = 0x0531;
  13638. t['B'] = 0x0042;
  13639. t['Bcircle'] = 0x24B7;
  13640. t['Bdotaccent'] = 0x1E02;
  13641. t['Bdotbelow'] = 0x1E04;
  13642. t['Becyrillic'] = 0x0411;
  13643. t['Benarmenian'] = 0x0532;
  13644. t['Beta'] = 0x0392;
  13645. t['Bhook'] = 0x0181;
  13646. t['Blinebelow'] = 0x1E06;
  13647. t['Bmonospace'] = 0xFF22;
  13648. t['Brevesmall'] = 0xF6F4;
  13649. t['Bsmall'] = 0xF762;
  13650. t['Btopbar'] = 0x0182;
  13651. t['C'] = 0x0043;
  13652. t['Caarmenian'] = 0x053E;
  13653. t['Cacute'] = 0x0106;
  13654. t['Caron'] = 0xF6CA;
  13655. t['Caronsmall'] = 0xF6F5;
  13656. t['Ccaron'] = 0x010C;
  13657. t['Ccedilla'] = 0x00C7;
  13658. t['Ccedillaacute'] = 0x1E08;
  13659. t['Ccedillasmall'] = 0xF7E7;
  13660. t['Ccircle'] = 0x24B8;
  13661. t['Ccircumflex'] = 0x0108;
  13662. t['Cdot'] = 0x010A;
  13663. t['Cdotaccent'] = 0x010A;
  13664. t['Cedillasmall'] = 0xF7B8;
  13665. t['Chaarmenian'] = 0x0549;
  13666. t['Cheabkhasiancyrillic'] = 0x04BC;
  13667. t['Checyrillic'] = 0x0427;
  13668. t['Chedescenderabkhasiancyrillic'] = 0x04BE;
  13669. t['Chedescendercyrillic'] = 0x04B6;
  13670. t['Chedieresiscyrillic'] = 0x04F4;
  13671. t['Cheharmenian'] = 0x0543;
  13672. t['Chekhakassiancyrillic'] = 0x04CB;
  13673. t['Cheverticalstrokecyrillic'] = 0x04B8;
  13674. t['Chi'] = 0x03A7;
  13675. t['Chook'] = 0x0187;
  13676. t['Circumflexsmall'] = 0xF6F6;
  13677. t['Cmonospace'] = 0xFF23;
  13678. t['Coarmenian'] = 0x0551;
  13679. t['Csmall'] = 0xF763;
  13680. t['D'] = 0x0044;
  13681. t['DZ'] = 0x01F1;
  13682. t['DZcaron'] = 0x01C4;
  13683. t['Daarmenian'] = 0x0534;
  13684. t['Dafrican'] = 0x0189;
  13685. t['Dcaron'] = 0x010E;
  13686. t['Dcedilla'] = 0x1E10;
  13687. t['Dcircle'] = 0x24B9;
  13688. t['Dcircumflexbelow'] = 0x1E12;
  13689. t['Dcroat'] = 0x0110;
  13690. t['Ddotaccent'] = 0x1E0A;
  13691. t['Ddotbelow'] = 0x1E0C;
  13692. t['Decyrillic'] = 0x0414;
  13693. t['Deicoptic'] = 0x03EE;
  13694. t['Delta'] = 0x2206;
  13695. t['Deltagreek'] = 0x0394;
  13696. t['Dhook'] = 0x018A;
  13697. t['Dieresis'] = 0xF6CB;
  13698. t['DieresisAcute'] = 0xF6CC;
  13699. t['DieresisGrave'] = 0xF6CD;
  13700. t['Dieresissmall'] = 0xF7A8;
  13701. t['Digammagreek'] = 0x03DC;
  13702. t['Djecyrillic'] = 0x0402;
  13703. t['Dlinebelow'] = 0x1E0E;
  13704. t['Dmonospace'] = 0xFF24;
  13705. t['Dotaccentsmall'] = 0xF6F7;
  13706. t['Dslash'] = 0x0110;
  13707. t['Dsmall'] = 0xF764;
  13708. t['Dtopbar'] = 0x018B;
  13709. t['Dz'] = 0x01F2;
  13710. t['Dzcaron'] = 0x01C5;
  13711. t['Dzeabkhasiancyrillic'] = 0x04E0;
  13712. t['Dzecyrillic'] = 0x0405;
  13713. t['Dzhecyrillic'] = 0x040F;
  13714. t['E'] = 0x0045;
  13715. t['Eacute'] = 0x00C9;
  13716. t['Eacutesmall'] = 0xF7E9;
  13717. t['Ebreve'] = 0x0114;
  13718. t['Ecaron'] = 0x011A;
  13719. t['Ecedillabreve'] = 0x1E1C;
  13720. t['Echarmenian'] = 0x0535;
  13721. t['Ecircle'] = 0x24BA;
  13722. t['Ecircumflex'] = 0x00CA;
  13723. t['Ecircumflexacute'] = 0x1EBE;
  13724. t['Ecircumflexbelow'] = 0x1E18;
  13725. t['Ecircumflexdotbelow'] = 0x1EC6;
  13726. t['Ecircumflexgrave'] = 0x1EC0;
  13727. t['Ecircumflexhookabove'] = 0x1EC2;
  13728. t['Ecircumflexsmall'] = 0xF7EA;
  13729. t['Ecircumflextilde'] = 0x1EC4;
  13730. t['Ecyrillic'] = 0x0404;
  13731. t['Edblgrave'] = 0x0204;
  13732. t['Edieresis'] = 0x00CB;
  13733. t['Edieresissmall'] = 0xF7EB;
  13734. t['Edot'] = 0x0116;
  13735. t['Edotaccent'] = 0x0116;
  13736. t['Edotbelow'] = 0x1EB8;
  13737. t['Efcyrillic'] = 0x0424;
  13738. t['Egrave'] = 0x00C8;
  13739. t['Egravesmall'] = 0xF7E8;
  13740. t['Eharmenian'] = 0x0537;
  13741. t['Ehookabove'] = 0x1EBA;
  13742. t['Eightroman'] = 0x2167;
  13743. t['Einvertedbreve'] = 0x0206;
  13744. t['Eiotifiedcyrillic'] = 0x0464;
  13745. t['Elcyrillic'] = 0x041B;
  13746. t['Elevenroman'] = 0x216A;
  13747. t['Emacron'] = 0x0112;
  13748. t['Emacronacute'] = 0x1E16;
  13749. t['Emacrongrave'] = 0x1E14;
  13750. t['Emcyrillic'] = 0x041C;
  13751. t['Emonospace'] = 0xFF25;
  13752. t['Encyrillic'] = 0x041D;
  13753. t['Endescendercyrillic'] = 0x04A2;
  13754. t['Eng'] = 0x014A;
  13755. t['Enghecyrillic'] = 0x04A4;
  13756. t['Enhookcyrillic'] = 0x04C7;
  13757. t['Eogonek'] = 0x0118;
  13758. t['Eopen'] = 0x0190;
  13759. t['Epsilon'] = 0x0395;
  13760. t['Epsilontonos'] = 0x0388;
  13761. t['Ercyrillic'] = 0x0420;
  13762. t['Ereversed'] = 0x018E;
  13763. t['Ereversedcyrillic'] = 0x042D;
  13764. t['Escyrillic'] = 0x0421;
  13765. t['Esdescendercyrillic'] = 0x04AA;
  13766. t['Esh'] = 0x01A9;
  13767. t['Esmall'] = 0xF765;
  13768. t['Eta'] = 0x0397;
  13769. t['Etarmenian'] = 0x0538;
  13770. t['Etatonos'] = 0x0389;
  13771. t['Eth'] = 0x00D0;
  13772. t['Ethsmall'] = 0xF7F0;
  13773. t['Etilde'] = 0x1EBC;
  13774. t['Etildebelow'] = 0x1E1A;
  13775. t['Euro'] = 0x20AC;
  13776. t['Ezh'] = 0x01B7;
  13777. t['Ezhcaron'] = 0x01EE;
  13778. t['Ezhreversed'] = 0x01B8;
  13779. t['F'] = 0x0046;
  13780. t['Fcircle'] = 0x24BB;
  13781. t['Fdotaccent'] = 0x1E1E;
  13782. t['Feharmenian'] = 0x0556;
  13783. t['Feicoptic'] = 0x03E4;
  13784. t['Fhook'] = 0x0191;
  13785. t['Fitacyrillic'] = 0x0472;
  13786. t['Fiveroman'] = 0x2164;
  13787. t['Fmonospace'] = 0xFF26;
  13788. t['Fourroman'] = 0x2163;
  13789. t['Fsmall'] = 0xF766;
  13790. t['G'] = 0x0047;
  13791. t['GBsquare'] = 0x3387;
  13792. t['Gacute'] = 0x01F4;
  13793. t['Gamma'] = 0x0393;
  13794. t['Gammaafrican'] = 0x0194;
  13795. t['Gangiacoptic'] = 0x03EA;
  13796. t['Gbreve'] = 0x011E;
  13797. t['Gcaron'] = 0x01E6;
  13798. t['Gcedilla'] = 0x0122;
  13799. t['Gcircle'] = 0x24BC;
  13800. t['Gcircumflex'] = 0x011C;
  13801. t['Gcommaaccent'] = 0x0122;
  13802. t['Gdot'] = 0x0120;
  13803. t['Gdotaccent'] = 0x0120;
  13804. t['Gecyrillic'] = 0x0413;
  13805. t['Ghadarmenian'] = 0x0542;
  13806. t['Ghemiddlehookcyrillic'] = 0x0494;
  13807. t['Ghestrokecyrillic'] = 0x0492;
  13808. t['Gheupturncyrillic'] = 0x0490;
  13809. t['Ghook'] = 0x0193;
  13810. t['Gimarmenian'] = 0x0533;
  13811. t['Gjecyrillic'] = 0x0403;
  13812. t['Gmacron'] = 0x1E20;
  13813. t['Gmonospace'] = 0xFF27;
  13814. t['Grave'] = 0xF6CE;
  13815. t['Gravesmall'] = 0xF760;
  13816. t['Gsmall'] = 0xF767;
  13817. t['Gsmallhook'] = 0x029B;
  13818. t['Gstroke'] = 0x01E4;
  13819. t['H'] = 0x0048;
  13820. t['H18533'] = 0x25CF;
  13821. t['H18543'] = 0x25AA;
  13822. t['H18551'] = 0x25AB;
  13823. t['H22073'] = 0x25A1;
  13824. t['HPsquare'] = 0x33CB;
  13825. t['Haabkhasiancyrillic'] = 0x04A8;
  13826. t['Hadescendercyrillic'] = 0x04B2;
  13827. t['Hardsigncyrillic'] = 0x042A;
  13828. t['Hbar'] = 0x0126;
  13829. t['Hbrevebelow'] = 0x1E2A;
  13830. t['Hcedilla'] = 0x1E28;
  13831. t['Hcircle'] = 0x24BD;
  13832. t['Hcircumflex'] = 0x0124;
  13833. t['Hdieresis'] = 0x1E26;
  13834. t['Hdotaccent'] = 0x1E22;
  13835. t['Hdotbelow'] = 0x1E24;
  13836. t['Hmonospace'] = 0xFF28;
  13837. t['Hoarmenian'] = 0x0540;
  13838. t['Horicoptic'] = 0x03E8;
  13839. t['Hsmall'] = 0xF768;
  13840. t['Hungarumlaut'] = 0xF6CF;
  13841. t['Hungarumlautsmall'] = 0xF6F8;
  13842. t['Hzsquare'] = 0x3390;
  13843. t['I'] = 0x0049;
  13844. t['IAcyrillic'] = 0x042F;
  13845. t['IJ'] = 0x0132;
  13846. t['IUcyrillic'] = 0x042E;
  13847. t['Iacute'] = 0x00CD;
  13848. t['Iacutesmall'] = 0xF7ED;
  13849. t['Ibreve'] = 0x012C;
  13850. t['Icaron'] = 0x01CF;
  13851. t['Icircle'] = 0x24BE;
  13852. t['Icircumflex'] = 0x00CE;
  13853. t['Icircumflexsmall'] = 0xF7EE;
  13854. t['Icyrillic'] = 0x0406;
  13855. t['Idblgrave'] = 0x0208;
  13856. t['Idieresis'] = 0x00CF;
  13857. t['Idieresisacute'] = 0x1E2E;
  13858. t['Idieresiscyrillic'] = 0x04E4;
  13859. t['Idieresissmall'] = 0xF7EF;
  13860. t['Idot'] = 0x0130;
  13861. t['Idotaccent'] = 0x0130;
  13862. t['Idotbelow'] = 0x1ECA;
  13863. t['Iebrevecyrillic'] = 0x04D6;
  13864. t['Iecyrillic'] = 0x0415;
  13865. t['Ifraktur'] = 0x2111;
  13866. t['Igrave'] = 0x00CC;
  13867. t['Igravesmall'] = 0xF7EC;
  13868. t['Ihookabove'] = 0x1EC8;
  13869. t['Iicyrillic'] = 0x0418;
  13870. t['Iinvertedbreve'] = 0x020A;
  13871. t['Iishortcyrillic'] = 0x0419;
  13872. t['Imacron'] = 0x012A;
  13873. t['Imacroncyrillic'] = 0x04E2;
  13874. t['Imonospace'] = 0xFF29;
  13875. t['Iniarmenian'] = 0x053B;
  13876. t['Iocyrillic'] = 0x0401;
  13877. t['Iogonek'] = 0x012E;
  13878. t['Iota'] = 0x0399;
  13879. t['Iotaafrican'] = 0x0196;
  13880. t['Iotadieresis'] = 0x03AA;
  13881. t['Iotatonos'] = 0x038A;
  13882. t['Ismall'] = 0xF769;
  13883. t['Istroke'] = 0x0197;
  13884. t['Itilde'] = 0x0128;
  13885. t['Itildebelow'] = 0x1E2C;
  13886. t['Izhitsacyrillic'] = 0x0474;
  13887. t['Izhitsadblgravecyrillic'] = 0x0476;
  13888. t['J'] = 0x004A;
  13889. t['Jaarmenian'] = 0x0541;
  13890. t['Jcircle'] = 0x24BF;
  13891. t['Jcircumflex'] = 0x0134;
  13892. t['Jecyrillic'] = 0x0408;
  13893. t['Jheharmenian'] = 0x054B;
  13894. t['Jmonospace'] = 0xFF2A;
  13895. t['Jsmall'] = 0xF76A;
  13896. t['K'] = 0x004B;
  13897. t['KBsquare'] = 0x3385;
  13898. t['KKsquare'] = 0x33CD;
  13899. t['Kabashkircyrillic'] = 0x04A0;
  13900. t['Kacute'] = 0x1E30;
  13901. t['Kacyrillic'] = 0x041A;
  13902. t['Kadescendercyrillic'] = 0x049A;
  13903. t['Kahookcyrillic'] = 0x04C3;
  13904. t['Kappa'] = 0x039A;
  13905. t['Kastrokecyrillic'] = 0x049E;
  13906. t['Kaverticalstrokecyrillic'] = 0x049C;
  13907. t['Kcaron'] = 0x01E8;
  13908. t['Kcedilla'] = 0x0136;
  13909. t['Kcircle'] = 0x24C0;
  13910. t['Kcommaaccent'] = 0x0136;
  13911. t['Kdotbelow'] = 0x1E32;
  13912. t['Keharmenian'] = 0x0554;
  13913. t['Kenarmenian'] = 0x053F;
  13914. t['Khacyrillic'] = 0x0425;
  13915. t['Kheicoptic'] = 0x03E6;
  13916. t['Khook'] = 0x0198;
  13917. t['Kjecyrillic'] = 0x040C;
  13918. t['Klinebelow'] = 0x1E34;
  13919. t['Kmonospace'] = 0xFF2B;
  13920. t['Koppacyrillic'] = 0x0480;
  13921. t['Koppagreek'] = 0x03DE;
  13922. t['Ksicyrillic'] = 0x046E;
  13923. t['Ksmall'] = 0xF76B;
  13924. t['L'] = 0x004C;
  13925. t['LJ'] = 0x01C7;
  13926. t['LL'] = 0xF6BF;
  13927. t['Lacute'] = 0x0139;
  13928. t['Lambda'] = 0x039B;
  13929. t['Lcaron'] = 0x013D;
  13930. t['Lcedilla'] = 0x013B;
  13931. t['Lcircle'] = 0x24C1;
  13932. t['Lcircumflexbelow'] = 0x1E3C;
  13933. t['Lcommaaccent'] = 0x013B;
  13934. t['Ldot'] = 0x013F;
  13935. t['Ldotaccent'] = 0x013F;
  13936. t['Ldotbelow'] = 0x1E36;
  13937. t['Ldotbelowmacron'] = 0x1E38;
  13938. t['Liwnarmenian'] = 0x053C;
  13939. t['Lj'] = 0x01C8;
  13940. t['Ljecyrillic'] = 0x0409;
  13941. t['Llinebelow'] = 0x1E3A;
  13942. t['Lmonospace'] = 0xFF2C;
  13943. t['Lslash'] = 0x0141;
  13944. t['Lslashsmall'] = 0xF6F9;
  13945. t['Lsmall'] = 0xF76C;
  13946. t['M'] = 0x004D;
  13947. t['MBsquare'] = 0x3386;
  13948. t['Macron'] = 0xF6D0;
  13949. t['Macronsmall'] = 0xF7AF;
  13950. t['Macute'] = 0x1E3E;
  13951. t['Mcircle'] = 0x24C2;
  13952. t['Mdotaccent'] = 0x1E40;
  13953. t['Mdotbelow'] = 0x1E42;
  13954. t['Menarmenian'] = 0x0544;
  13955. t['Mmonospace'] = 0xFF2D;
  13956. t['Msmall'] = 0xF76D;
  13957. t['Mturned'] = 0x019C;
  13958. t['Mu'] = 0x039C;
  13959. t['N'] = 0x004E;
  13960. t['NJ'] = 0x01CA;
  13961. t['Nacute'] = 0x0143;
  13962. t['Ncaron'] = 0x0147;
  13963. t['Ncedilla'] = 0x0145;
  13964. t['Ncircle'] = 0x24C3;
  13965. t['Ncircumflexbelow'] = 0x1E4A;
  13966. t['Ncommaaccent'] = 0x0145;
  13967. t['Ndotaccent'] = 0x1E44;
  13968. t['Ndotbelow'] = 0x1E46;
  13969. t['Nhookleft'] = 0x019D;
  13970. t['Nineroman'] = 0x2168;
  13971. t['Nj'] = 0x01CB;
  13972. t['Njecyrillic'] = 0x040A;
  13973. t['Nlinebelow'] = 0x1E48;
  13974. t['Nmonospace'] = 0xFF2E;
  13975. t['Nowarmenian'] = 0x0546;
  13976. t['Nsmall'] = 0xF76E;
  13977. t['Ntilde'] = 0x00D1;
  13978. t['Ntildesmall'] = 0xF7F1;
  13979. t['Nu'] = 0x039D;
  13980. t['O'] = 0x004F;
  13981. t['OE'] = 0x0152;
  13982. t['OEsmall'] = 0xF6FA;
  13983. t['Oacute'] = 0x00D3;
  13984. t['Oacutesmall'] = 0xF7F3;
  13985. t['Obarredcyrillic'] = 0x04E8;
  13986. t['Obarreddieresiscyrillic'] = 0x04EA;
  13987. t['Obreve'] = 0x014E;
  13988. t['Ocaron'] = 0x01D1;
  13989. t['Ocenteredtilde'] = 0x019F;
  13990. t['Ocircle'] = 0x24C4;
  13991. t['Ocircumflex'] = 0x00D4;
  13992. t['Ocircumflexacute'] = 0x1ED0;
  13993. t['Ocircumflexdotbelow'] = 0x1ED8;
  13994. t['Ocircumflexgrave'] = 0x1ED2;
  13995. t['Ocircumflexhookabove'] = 0x1ED4;
  13996. t['Ocircumflexsmall'] = 0xF7F4;
  13997. t['Ocircumflextilde'] = 0x1ED6;
  13998. t['Ocyrillic'] = 0x041E;
  13999. t['Odblacute'] = 0x0150;
  14000. t['Odblgrave'] = 0x020C;
  14001. t['Odieresis'] = 0x00D6;
  14002. t['Odieresiscyrillic'] = 0x04E6;
  14003. t['Odieresissmall'] = 0xF7F6;
  14004. t['Odotbelow'] = 0x1ECC;
  14005. t['Ogoneksmall'] = 0xF6FB;
  14006. t['Ograve'] = 0x00D2;
  14007. t['Ogravesmall'] = 0xF7F2;
  14008. t['Oharmenian'] = 0x0555;
  14009. t['Ohm'] = 0x2126;
  14010. t['Ohookabove'] = 0x1ECE;
  14011. t['Ohorn'] = 0x01A0;
  14012. t['Ohornacute'] = 0x1EDA;
  14013. t['Ohorndotbelow'] = 0x1EE2;
  14014. t['Ohorngrave'] = 0x1EDC;
  14015. t['Ohornhookabove'] = 0x1EDE;
  14016. t['Ohorntilde'] = 0x1EE0;
  14017. t['Ohungarumlaut'] = 0x0150;
  14018. t['Oi'] = 0x01A2;
  14019. t['Oinvertedbreve'] = 0x020E;
  14020. t['Omacron'] = 0x014C;
  14021. t['Omacronacute'] = 0x1E52;
  14022. t['Omacrongrave'] = 0x1E50;
  14023. t['Omega'] = 0x2126;
  14024. t['Omegacyrillic'] = 0x0460;
  14025. t['Omegagreek'] = 0x03A9;
  14026. t['Omegaroundcyrillic'] = 0x047A;
  14027. t['Omegatitlocyrillic'] = 0x047C;
  14028. t['Omegatonos'] = 0x038F;
  14029. t['Omicron'] = 0x039F;
  14030. t['Omicrontonos'] = 0x038C;
  14031. t['Omonospace'] = 0xFF2F;
  14032. t['Oneroman'] = 0x2160;
  14033. t['Oogonek'] = 0x01EA;
  14034. t['Oogonekmacron'] = 0x01EC;
  14035. t['Oopen'] = 0x0186;
  14036. t['Oslash'] = 0x00D8;
  14037. t['Oslashacute'] = 0x01FE;
  14038. t['Oslashsmall'] = 0xF7F8;
  14039. t['Osmall'] = 0xF76F;
  14040. t['Ostrokeacute'] = 0x01FE;
  14041. t['Otcyrillic'] = 0x047E;
  14042. t['Otilde'] = 0x00D5;
  14043. t['Otildeacute'] = 0x1E4C;
  14044. t['Otildedieresis'] = 0x1E4E;
  14045. t['Otildesmall'] = 0xF7F5;
  14046. t['P'] = 0x0050;
  14047. t['Pacute'] = 0x1E54;
  14048. t['Pcircle'] = 0x24C5;
  14049. t['Pdotaccent'] = 0x1E56;
  14050. t['Pecyrillic'] = 0x041F;
  14051. t['Peharmenian'] = 0x054A;
  14052. t['Pemiddlehookcyrillic'] = 0x04A6;
  14053. t['Phi'] = 0x03A6;
  14054. t['Phook'] = 0x01A4;
  14055. t['Pi'] = 0x03A0;
  14056. t['Piwrarmenian'] = 0x0553;
  14057. t['Pmonospace'] = 0xFF30;
  14058. t['Psi'] = 0x03A8;
  14059. t['Psicyrillic'] = 0x0470;
  14060. t['Psmall'] = 0xF770;
  14061. t['Q'] = 0x0051;
  14062. t['Qcircle'] = 0x24C6;
  14063. t['Qmonospace'] = 0xFF31;
  14064. t['Qsmall'] = 0xF771;
  14065. t['R'] = 0x0052;
  14066. t['Raarmenian'] = 0x054C;
  14067. t['Racute'] = 0x0154;
  14068. t['Rcaron'] = 0x0158;
  14069. t['Rcedilla'] = 0x0156;
  14070. t['Rcircle'] = 0x24C7;
  14071. t['Rcommaaccent'] = 0x0156;
  14072. t['Rdblgrave'] = 0x0210;
  14073. t['Rdotaccent'] = 0x1E58;
  14074. t['Rdotbelow'] = 0x1E5A;
  14075. t['Rdotbelowmacron'] = 0x1E5C;
  14076. t['Reharmenian'] = 0x0550;
  14077. t['Rfraktur'] = 0x211C;
  14078. t['Rho'] = 0x03A1;
  14079. t['Ringsmall'] = 0xF6FC;
  14080. t['Rinvertedbreve'] = 0x0212;
  14081. t['Rlinebelow'] = 0x1E5E;
  14082. t['Rmonospace'] = 0xFF32;
  14083. t['Rsmall'] = 0xF772;
  14084. t['Rsmallinverted'] = 0x0281;
  14085. t['Rsmallinvertedsuperior'] = 0x02B6;
  14086. t['S'] = 0x0053;
  14087. t['SF010000'] = 0x250C;
  14088. t['SF020000'] = 0x2514;
  14089. t['SF030000'] = 0x2510;
  14090. t['SF040000'] = 0x2518;
  14091. t['SF050000'] = 0x253C;
  14092. t['SF060000'] = 0x252C;
  14093. t['SF070000'] = 0x2534;
  14094. t['SF080000'] = 0x251C;
  14095. t['SF090000'] = 0x2524;
  14096. t['SF100000'] = 0x2500;
  14097. t['SF110000'] = 0x2502;
  14098. t['SF190000'] = 0x2561;
  14099. t['SF200000'] = 0x2562;
  14100. t['SF210000'] = 0x2556;
  14101. t['SF220000'] = 0x2555;
  14102. t['SF230000'] = 0x2563;
  14103. t['SF240000'] = 0x2551;
  14104. t['SF250000'] = 0x2557;
  14105. t['SF260000'] = 0x255D;
  14106. t['SF270000'] = 0x255C;
  14107. t['SF280000'] = 0x255B;
  14108. t['SF360000'] = 0x255E;
  14109. t['SF370000'] = 0x255F;
  14110. t['SF380000'] = 0x255A;
  14111. t['SF390000'] = 0x2554;
  14112. t['SF400000'] = 0x2569;
  14113. t['SF410000'] = 0x2566;
  14114. t['SF420000'] = 0x2560;
  14115. t['SF430000'] = 0x2550;
  14116. t['SF440000'] = 0x256C;
  14117. t['SF450000'] = 0x2567;
  14118. t['SF460000'] = 0x2568;
  14119. t['SF470000'] = 0x2564;
  14120. t['SF480000'] = 0x2565;
  14121. t['SF490000'] = 0x2559;
  14122. t['SF500000'] = 0x2558;
  14123. t['SF510000'] = 0x2552;
  14124. t['SF520000'] = 0x2553;
  14125. t['SF530000'] = 0x256B;
  14126. t['SF540000'] = 0x256A;
  14127. t['Sacute'] = 0x015A;
  14128. t['Sacutedotaccent'] = 0x1E64;
  14129. t['Sampigreek'] = 0x03E0;
  14130. t['Scaron'] = 0x0160;
  14131. t['Scarondotaccent'] = 0x1E66;
  14132. t['Scaronsmall'] = 0xF6FD;
  14133. t['Scedilla'] = 0x015E;
  14134. t['Schwa'] = 0x018F;
  14135. t['Schwacyrillic'] = 0x04D8;
  14136. t['Schwadieresiscyrillic'] = 0x04DA;
  14137. t['Scircle'] = 0x24C8;
  14138. t['Scircumflex'] = 0x015C;
  14139. t['Scommaaccent'] = 0x0218;
  14140. t['Sdotaccent'] = 0x1E60;
  14141. t['Sdotbelow'] = 0x1E62;
  14142. t['Sdotbelowdotaccent'] = 0x1E68;
  14143. t['Seharmenian'] = 0x054D;
  14144. t['Sevenroman'] = 0x2166;
  14145. t['Shaarmenian'] = 0x0547;
  14146. t['Shacyrillic'] = 0x0428;
  14147. t['Shchacyrillic'] = 0x0429;
  14148. t['Sheicoptic'] = 0x03E2;
  14149. t['Shhacyrillic'] = 0x04BA;
  14150. t['Shimacoptic'] = 0x03EC;
  14151. t['Sigma'] = 0x03A3;
  14152. t['Sixroman'] = 0x2165;
  14153. t['Smonospace'] = 0xFF33;
  14154. t['Softsigncyrillic'] = 0x042C;
  14155. t['Ssmall'] = 0xF773;
  14156. t['Stigmagreek'] = 0x03DA;
  14157. t['T'] = 0x0054;
  14158. t['Tau'] = 0x03A4;
  14159. t['Tbar'] = 0x0166;
  14160. t['Tcaron'] = 0x0164;
  14161. t['Tcedilla'] = 0x0162;
  14162. t['Tcircle'] = 0x24C9;
  14163. t['Tcircumflexbelow'] = 0x1E70;
  14164. t['Tcommaaccent'] = 0x0162;
  14165. t['Tdotaccent'] = 0x1E6A;
  14166. t['Tdotbelow'] = 0x1E6C;
  14167. t['Tecyrillic'] = 0x0422;
  14168. t['Tedescendercyrillic'] = 0x04AC;
  14169. t['Tenroman'] = 0x2169;
  14170. t['Tetsecyrillic'] = 0x04B4;
  14171. t['Theta'] = 0x0398;
  14172. t['Thook'] = 0x01AC;
  14173. t['Thorn'] = 0x00DE;
  14174. t['Thornsmall'] = 0xF7FE;
  14175. t['Threeroman'] = 0x2162;
  14176. t['Tildesmall'] = 0xF6FE;
  14177. t['Tiwnarmenian'] = 0x054F;
  14178. t['Tlinebelow'] = 0x1E6E;
  14179. t['Tmonospace'] = 0xFF34;
  14180. t['Toarmenian'] = 0x0539;
  14181. t['Tonefive'] = 0x01BC;
  14182. t['Tonesix'] = 0x0184;
  14183. t['Tonetwo'] = 0x01A7;
  14184. t['Tretroflexhook'] = 0x01AE;
  14185. t['Tsecyrillic'] = 0x0426;
  14186. t['Tshecyrillic'] = 0x040B;
  14187. t['Tsmall'] = 0xF774;
  14188. t['Twelveroman'] = 0x216B;
  14189. t['Tworoman'] = 0x2161;
  14190. t['U'] = 0x0055;
  14191. t['Uacute'] = 0x00DA;
  14192. t['Uacutesmall'] = 0xF7FA;
  14193. t['Ubreve'] = 0x016C;
  14194. t['Ucaron'] = 0x01D3;
  14195. t['Ucircle'] = 0x24CA;
  14196. t['Ucircumflex'] = 0x00DB;
  14197. t['Ucircumflexbelow'] = 0x1E76;
  14198. t['Ucircumflexsmall'] = 0xF7FB;
  14199. t['Ucyrillic'] = 0x0423;
  14200. t['Udblacute'] = 0x0170;
  14201. t['Udblgrave'] = 0x0214;
  14202. t['Udieresis'] = 0x00DC;
  14203. t['Udieresisacute'] = 0x01D7;
  14204. t['Udieresisbelow'] = 0x1E72;
  14205. t['Udieresiscaron'] = 0x01D9;
  14206. t['Udieresiscyrillic'] = 0x04F0;
  14207. t['Udieresisgrave'] = 0x01DB;
  14208. t['Udieresismacron'] = 0x01D5;
  14209. t['Udieresissmall'] = 0xF7FC;
  14210. t['Udotbelow'] = 0x1EE4;
  14211. t['Ugrave'] = 0x00D9;
  14212. t['Ugravesmall'] = 0xF7F9;
  14213. t['Uhookabove'] = 0x1EE6;
  14214. t['Uhorn'] = 0x01AF;
  14215. t['Uhornacute'] = 0x1EE8;
  14216. t['Uhorndotbelow'] = 0x1EF0;
  14217. t['Uhorngrave'] = 0x1EEA;
  14218. t['Uhornhookabove'] = 0x1EEC;
  14219. t['Uhorntilde'] = 0x1EEE;
  14220. t['Uhungarumlaut'] = 0x0170;
  14221. t['Uhungarumlautcyrillic'] = 0x04F2;
  14222. t['Uinvertedbreve'] = 0x0216;
  14223. t['Ukcyrillic'] = 0x0478;
  14224. t['Umacron'] = 0x016A;
  14225. t['Umacroncyrillic'] = 0x04EE;
  14226. t['Umacrondieresis'] = 0x1E7A;
  14227. t['Umonospace'] = 0xFF35;
  14228. t['Uogonek'] = 0x0172;
  14229. t['Upsilon'] = 0x03A5;
  14230. t['Upsilon1'] = 0x03D2;
  14231. t['Upsilonacutehooksymbolgreek'] = 0x03D3;
  14232. t['Upsilonafrican'] = 0x01B1;
  14233. t['Upsilondieresis'] = 0x03AB;
  14234. t['Upsilondieresishooksymbolgreek'] = 0x03D4;
  14235. t['Upsilonhooksymbol'] = 0x03D2;
  14236. t['Upsilontonos'] = 0x038E;
  14237. t['Uring'] = 0x016E;
  14238. t['Ushortcyrillic'] = 0x040E;
  14239. t['Usmall'] = 0xF775;
  14240. t['Ustraightcyrillic'] = 0x04AE;
  14241. t['Ustraightstrokecyrillic'] = 0x04B0;
  14242. t['Utilde'] = 0x0168;
  14243. t['Utildeacute'] = 0x1E78;
  14244. t['Utildebelow'] = 0x1E74;
  14245. t['V'] = 0x0056;
  14246. t['Vcircle'] = 0x24CB;
  14247. t['Vdotbelow'] = 0x1E7E;
  14248. t['Vecyrillic'] = 0x0412;
  14249. t['Vewarmenian'] = 0x054E;
  14250. t['Vhook'] = 0x01B2;
  14251. t['Vmonospace'] = 0xFF36;
  14252. t['Voarmenian'] = 0x0548;
  14253. t['Vsmall'] = 0xF776;
  14254. t['Vtilde'] = 0x1E7C;
  14255. t['W'] = 0x0057;
  14256. t['Wacute'] = 0x1E82;
  14257. t['Wcircle'] = 0x24CC;
  14258. t['Wcircumflex'] = 0x0174;
  14259. t['Wdieresis'] = 0x1E84;
  14260. t['Wdotaccent'] = 0x1E86;
  14261. t['Wdotbelow'] = 0x1E88;
  14262. t['Wgrave'] = 0x1E80;
  14263. t['Wmonospace'] = 0xFF37;
  14264. t['Wsmall'] = 0xF777;
  14265. t['X'] = 0x0058;
  14266. t['Xcircle'] = 0x24CD;
  14267. t['Xdieresis'] = 0x1E8C;
  14268. t['Xdotaccent'] = 0x1E8A;
  14269. t['Xeharmenian'] = 0x053D;
  14270. t['Xi'] = 0x039E;
  14271. t['Xmonospace'] = 0xFF38;
  14272. t['Xsmall'] = 0xF778;
  14273. t['Y'] = 0x0059;
  14274. t['Yacute'] = 0x00DD;
  14275. t['Yacutesmall'] = 0xF7FD;
  14276. t['Yatcyrillic'] = 0x0462;
  14277. t['Ycircle'] = 0x24CE;
  14278. t['Ycircumflex'] = 0x0176;
  14279. t['Ydieresis'] = 0x0178;
  14280. t['Ydieresissmall'] = 0xF7FF;
  14281. t['Ydotaccent'] = 0x1E8E;
  14282. t['Ydotbelow'] = 0x1EF4;
  14283. t['Yericyrillic'] = 0x042B;
  14284. t['Yerudieresiscyrillic'] = 0x04F8;
  14285. t['Ygrave'] = 0x1EF2;
  14286. t['Yhook'] = 0x01B3;
  14287. t['Yhookabove'] = 0x1EF6;
  14288. t['Yiarmenian'] = 0x0545;
  14289. t['Yicyrillic'] = 0x0407;
  14290. t['Yiwnarmenian'] = 0x0552;
  14291. t['Ymonospace'] = 0xFF39;
  14292. t['Ysmall'] = 0xF779;
  14293. t['Ytilde'] = 0x1EF8;
  14294. t['Yusbigcyrillic'] = 0x046A;
  14295. t['Yusbigiotifiedcyrillic'] = 0x046C;
  14296. t['Yuslittlecyrillic'] = 0x0466;
  14297. t['Yuslittleiotifiedcyrillic'] = 0x0468;
  14298. t['Z'] = 0x005A;
  14299. t['Zaarmenian'] = 0x0536;
  14300. t['Zacute'] = 0x0179;
  14301. t['Zcaron'] = 0x017D;
  14302. t['Zcaronsmall'] = 0xF6FF;
  14303. t['Zcircle'] = 0x24CF;
  14304. t['Zcircumflex'] = 0x1E90;
  14305. t['Zdot'] = 0x017B;
  14306. t['Zdotaccent'] = 0x017B;
  14307. t['Zdotbelow'] = 0x1E92;
  14308. t['Zecyrillic'] = 0x0417;
  14309. t['Zedescendercyrillic'] = 0x0498;
  14310. t['Zedieresiscyrillic'] = 0x04DE;
  14311. t['Zeta'] = 0x0396;
  14312. t['Zhearmenian'] = 0x053A;
  14313. t['Zhebrevecyrillic'] = 0x04C1;
  14314. t['Zhecyrillic'] = 0x0416;
  14315. t['Zhedescendercyrillic'] = 0x0496;
  14316. t['Zhedieresiscyrillic'] = 0x04DC;
  14317. t['Zlinebelow'] = 0x1E94;
  14318. t['Zmonospace'] = 0xFF3A;
  14319. t['Zsmall'] = 0xF77A;
  14320. t['Zstroke'] = 0x01B5;
  14321. t['a'] = 0x0061;
  14322. t['aabengali'] = 0x0986;
  14323. t['aacute'] = 0x00E1;
  14324. t['aadeva'] = 0x0906;
  14325. t['aagujarati'] = 0x0A86;
  14326. t['aagurmukhi'] = 0x0A06;
  14327. t['aamatragurmukhi'] = 0x0A3E;
  14328. t['aarusquare'] = 0x3303;
  14329. t['aavowelsignbengali'] = 0x09BE;
  14330. t['aavowelsigndeva'] = 0x093E;
  14331. t['aavowelsigngujarati'] = 0x0ABE;
  14332. t['abbreviationmarkarmenian'] = 0x055F;
  14333. t['abbreviationsigndeva'] = 0x0970;
  14334. t['abengali'] = 0x0985;
  14335. t['abopomofo'] = 0x311A;
  14336. t['abreve'] = 0x0103;
  14337. t['abreveacute'] = 0x1EAF;
  14338. t['abrevecyrillic'] = 0x04D1;
  14339. t['abrevedotbelow'] = 0x1EB7;
  14340. t['abrevegrave'] = 0x1EB1;
  14341. t['abrevehookabove'] = 0x1EB3;
  14342. t['abrevetilde'] = 0x1EB5;
  14343. t['acaron'] = 0x01CE;
  14344. t['acircle'] = 0x24D0;
  14345. t['acircumflex'] = 0x00E2;
  14346. t['acircumflexacute'] = 0x1EA5;
  14347. t['acircumflexdotbelow'] = 0x1EAD;
  14348. t['acircumflexgrave'] = 0x1EA7;
  14349. t['acircumflexhookabove'] = 0x1EA9;
  14350. t['acircumflextilde'] = 0x1EAB;
  14351. t['acute'] = 0x00B4;
  14352. t['acutebelowcmb'] = 0x0317;
  14353. t['acutecmb'] = 0x0301;
  14354. t['acutecomb'] = 0x0301;
  14355. t['acutedeva'] = 0x0954;
  14356. t['acutelowmod'] = 0x02CF;
  14357. t['acutetonecmb'] = 0x0341;
  14358. t['acyrillic'] = 0x0430;
  14359. t['adblgrave'] = 0x0201;
  14360. t['addakgurmukhi'] = 0x0A71;
  14361. t['adeva'] = 0x0905;
  14362. t['adieresis'] = 0x00E4;
  14363. t['adieresiscyrillic'] = 0x04D3;
  14364. t['adieresismacron'] = 0x01DF;
  14365. t['adotbelow'] = 0x1EA1;
  14366. t['adotmacron'] = 0x01E1;
  14367. t['ae'] = 0x00E6;
  14368. t['aeacute'] = 0x01FD;
  14369. t['aekorean'] = 0x3150;
  14370. t['aemacron'] = 0x01E3;
  14371. t['afii00208'] = 0x2015;
  14372. t['afii08941'] = 0x20A4;
  14373. t['afii10017'] = 0x0410;
  14374. t['afii10018'] = 0x0411;
  14375. t['afii10019'] = 0x0412;
  14376. t['afii10020'] = 0x0413;
  14377. t['afii10021'] = 0x0414;
  14378. t['afii10022'] = 0x0415;
  14379. t['afii10023'] = 0x0401;
  14380. t['afii10024'] = 0x0416;
  14381. t['afii10025'] = 0x0417;
  14382. t['afii10026'] = 0x0418;
  14383. t['afii10027'] = 0x0419;
  14384. t['afii10028'] = 0x041A;
  14385. t['afii10029'] = 0x041B;
  14386. t['afii10030'] = 0x041C;
  14387. t['afii10031'] = 0x041D;
  14388. t['afii10032'] = 0x041E;
  14389. t['afii10033'] = 0x041F;
  14390. t['afii10034'] = 0x0420;
  14391. t['afii10035'] = 0x0421;
  14392. t['afii10036'] = 0x0422;
  14393. t['afii10037'] = 0x0423;
  14394. t['afii10038'] = 0x0424;
  14395. t['afii10039'] = 0x0425;
  14396. t['afii10040'] = 0x0426;
  14397. t['afii10041'] = 0x0427;
  14398. t['afii10042'] = 0x0428;
  14399. t['afii10043'] = 0x0429;
  14400. t['afii10044'] = 0x042A;
  14401. t['afii10045'] = 0x042B;
  14402. t['afii10046'] = 0x042C;
  14403. t['afii10047'] = 0x042D;
  14404. t['afii10048'] = 0x042E;
  14405. t['afii10049'] = 0x042F;
  14406. t['afii10050'] = 0x0490;
  14407. t['afii10051'] = 0x0402;
  14408. t['afii10052'] = 0x0403;
  14409. t['afii10053'] = 0x0404;
  14410. t['afii10054'] = 0x0405;
  14411. t['afii10055'] = 0x0406;
  14412. t['afii10056'] = 0x0407;
  14413. t['afii10057'] = 0x0408;
  14414. t['afii10058'] = 0x0409;
  14415. t['afii10059'] = 0x040A;
  14416. t['afii10060'] = 0x040B;
  14417. t['afii10061'] = 0x040C;
  14418. t['afii10062'] = 0x040E;
  14419. t['afii10063'] = 0xF6C4;
  14420. t['afii10064'] = 0xF6C5;
  14421. t['afii10065'] = 0x0430;
  14422. t['afii10066'] = 0x0431;
  14423. t['afii10067'] = 0x0432;
  14424. t['afii10068'] = 0x0433;
  14425. t['afii10069'] = 0x0434;
  14426. t['afii10070'] = 0x0435;
  14427. t['afii10071'] = 0x0451;
  14428. t['afii10072'] = 0x0436;
  14429. t['afii10073'] = 0x0437;
  14430. t['afii10074'] = 0x0438;
  14431. t['afii10075'] = 0x0439;
  14432. t['afii10076'] = 0x043A;
  14433. t['afii10077'] = 0x043B;
  14434. t['afii10078'] = 0x043C;
  14435. t['afii10079'] = 0x043D;
  14436. t['afii10080'] = 0x043E;
  14437. t['afii10081'] = 0x043F;
  14438. t['afii10082'] = 0x0440;
  14439. t['afii10083'] = 0x0441;
  14440. t['afii10084'] = 0x0442;
  14441. t['afii10085'] = 0x0443;
  14442. t['afii10086'] = 0x0444;
  14443. t['afii10087'] = 0x0445;
  14444. t['afii10088'] = 0x0446;
  14445. t['afii10089'] = 0x0447;
  14446. t['afii10090'] = 0x0448;
  14447. t['afii10091'] = 0x0449;
  14448. t['afii10092'] = 0x044A;
  14449. t['afii10093'] = 0x044B;
  14450. t['afii10094'] = 0x044C;
  14451. t['afii10095'] = 0x044D;
  14452. t['afii10096'] = 0x044E;
  14453. t['afii10097'] = 0x044F;
  14454. t['afii10098'] = 0x0491;
  14455. t['afii10099'] = 0x0452;
  14456. t['afii10100'] = 0x0453;
  14457. t['afii10101'] = 0x0454;
  14458. t['afii10102'] = 0x0455;
  14459. t['afii10103'] = 0x0456;
  14460. t['afii10104'] = 0x0457;
  14461. t['afii10105'] = 0x0458;
  14462. t['afii10106'] = 0x0459;
  14463. t['afii10107'] = 0x045A;
  14464. t['afii10108'] = 0x045B;
  14465. t['afii10109'] = 0x045C;
  14466. t['afii10110'] = 0x045E;
  14467. t['afii10145'] = 0x040F;
  14468. t['afii10146'] = 0x0462;
  14469. t['afii10147'] = 0x0472;
  14470. t['afii10148'] = 0x0474;
  14471. t['afii10192'] = 0xF6C6;
  14472. t['afii10193'] = 0x045F;
  14473. t['afii10194'] = 0x0463;
  14474. t['afii10195'] = 0x0473;
  14475. t['afii10196'] = 0x0475;
  14476. t['afii10831'] = 0xF6C7;
  14477. t['afii10832'] = 0xF6C8;
  14478. t['afii10846'] = 0x04D9;
  14479. t['afii299'] = 0x200E;
  14480. t['afii300'] = 0x200F;
  14481. t['afii301'] = 0x200D;
  14482. t['afii57381'] = 0x066A;
  14483. t['afii57388'] = 0x060C;
  14484. t['afii57392'] = 0x0660;
  14485. t['afii57393'] = 0x0661;
  14486. t['afii57394'] = 0x0662;
  14487. t['afii57395'] = 0x0663;
  14488. t['afii57396'] = 0x0664;
  14489. t['afii57397'] = 0x0665;
  14490. t['afii57398'] = 0x0666;
  14491. t['afii57399'] = 0x0667;
  14492. t['afii57400'] = 0x0668;
  14493. t['afii57401'] = 0x0669;
  14494. t['afii57403'] = 0x061B;
  14495. t['afii57407'] = 0x061F;
  14496. t['afii57409'] = 0x0621;
  14497. t['afii57410'] = 0x0622;
  14498. t['afii57411'] = 0x0623;
  14499. t['afii57412'] = 0x0624;
  14500. t['afii57413'] = 0x0625;
  14501. t['afii57414'] = 0x0626;
  14502. t['afii57415'] = 0x0627;
  14503. t['afii57416'] = 0x0628;
  14504. t['afii57417'] = 0x0629;
  14505. t['afii57418'] = 0x062A;
  14506. t['afii57419'] = 0x062B;
  14507. t['afii57420'] = 0x062C;
  14508. t['afii57421'] = 0x062D;
  14509. t['afii57422'] = 0x062E;
  14510. t['afii57423'] = 0x062F;
  14511. t['afii57424'] = 0x0630;
  14512. t['afii57425'] = 0x0631;
  14513. t['afii57426'] = 0x0632;
  14514. t['afii57427'] = 0x0633;
  14515. t['afii57428'] = 0x0634;
  14516. t['afii57429'] = 0x0635;
  14517. t['afii57430'] = 0x0636;
  14518. t['afii57431'] = 0x0637;
  14519. t['afii57432'] = 0x0638;
  14520. t['afii57433'] = 0x0639;
  14521. t['afii57434'] = 0x063A;
  14522. t['afii57440'] = 0x0640;
  14523. t['afii57441'] = 0x0641;
  14524. t['afii57442'] = 0x0642;
  14525. t['afii57443'] = 0x0643;
  14526. t['afii57444'] = 0x0644;
  14527. t['afii57445'] = 0x0645;
  14528. t['afii57446'] = 0x0646;
  14529. t['afii57448'] = 0x0648;
  14530. t['afii57449'] = 0x0649;
  14531. t['afii57450'] = 0x064A;
  14532. t['afii57451'] = 0x064B;
  14533. t['afii57452'] = 0x064C;
  14534. t['afii57453'] = 0x064D;
  14535. t['afii57454'] = 0x064E;
  14536. t['afii57455'] = 0x064F;
  14537. t['afii57456'] = 0x0650;
  14538. t['afii57457'] = 0x0651;
  14539. t['afii57458'] = 0x0652;
  14540. t['afii57470'] = 0x0647;
  14541. t['afii57505'] = 0x06A4;
  14542. t['afii57506'] = 0x067E;
  14543. t['afii57507'] = 0x0686;
  14544. t['afii57508'] = 0x0698;
  14545. t['afii57509'] = 0x06AF;
  14546. t['afii57511'] = 0x0679;
  14547. t['afii57512'] = 0x0688;
  14548. t['afii57513'] = 0x0691;
  14549. t['afii57514'] = 0x06BA;
  14550. t['afii57519'] = 0x06D2;
  14551. t['afii57534'] = 0x06D5;
  14552. t['afii57636'] = 0x20AA;
  14553. t['afii57645'] = 0x05BE;
  14554. t['afii57658'] = 0x05C3;
  14555. t['afii57664'] = 0x05D0;
  14556. t['afii57665'] = 0x05D1;
  14557. t['afii57666'] = 0x05D2;
  14558. t['afii57667'] = 0x05D3;
  14559. t['afii57668'] = 0x05D4;
  14560. t['afii57669'] = 0x05D5;
  14561. t['afii57670'] = 0x05D6;
  14562. t['afii57671'] = 0x05D7;
  14563. t['afii57672'] = 0x05D8;
  14564. t['afii57673'] = 0x05D9;
  14565. t['afii57674'] = 0x05DA;
  14566. t['afii57675'] = 0x05DB;
  14567. t['afii57676'] = 0x05DC;
  14568. t['afii57677'] = 0x05DD;
  14569. t['afii57678'] = 0x05DE;
  14570. t['afii57679'] = 0x05DF;
  14571. t['afii57680'] = 0x05E0;
  14572. t['afii57681'] = 0x05E1;
  14573. t['afii57682'] = 0x05E2;
  14574. t['afii57683'] = 0x05E3;
  14575. t['afii57684'] = 0x05E4;
  14576. t['afii57685'] = 0x05E5;
  14577. t['afii57686'] = 0x05E6;
  14578. t['afii57687'] = 0x05E7;
  14579. t['afii57688'] = 0x05E8;
  14580. t['afii57689'] = 0x05E9;
  14581. t['afii57690'] = 0x05EA;
  14582. t['afii57694'] = 0xFB2A;
  14583. t['afii57695'] = 0xFB2B;
  14584. t['afii57700'] = 0xFB4B;
  14585. t['afii57705'] = 0xFB1F;
  14586. t['afii57716'] = 0x05F0;
  14587. t['afii57717'] = 0x05F1;
  14588. t['afii57718'] = 0x05F2;
  14589. t['afii57723'] = 0xFB35;
  14590. t['afii57793'] = 0x05B4;
  14591. t['afii57794'] = 0x05B5;
  14592. t['afii57795'] = 0x05B6;
  14593. t['afii57796'] = 0x05BB;
  14594. t['afii57797'] = 0x05B8;
  14595. t['afii57798'] = 0x05B7;
  14596. t['afii57799'] = 0x05B0;
  14597. t['afii57800'] = 0x05B2;
  14598. t['afii57801'] = 0x05B1;
  14599. t['afii57802'] = 0x05B3;
  14600. t['afii57803'] = 0x05C2;
  14601. t['afii57804'] = 0x05C1;
  14602. t['afii57806'] = 0x05B9;
  14603. t['afii57807'] = 0x05BC;
  14604. t['afii57839'] = 0x05BD;
  14605. t['afii57841'] = 0x05BF;
  14606. t['afii57842'] = 0x05C0;
  14607. t['afii57929'] = 0x02BC;
  14608. t['afii61248'] = 0x2105;
  14609. t['afii61289'] = 0x2113;
  14610. t['afii61352'] = 0x2116;
  14611. t['afii61573'] = 0x202C;
  14612. t['afii61574'] = 0x202D;
  14613. t['afii61575'] = 0x202E;
  14614. t['afii61664'] = 0x200C;
  14615. t['afii63167'] = 0x066D;
  14616. t['afii64937'] = 0x02BD;
  14617. t['agrave'] = 0x00E0;
  14618. t['agujarati'] = 0x0A85;
  14619. t['agurmukhi'] = 0x0A05;
  14620. t['ahiragana'] = 0x3042;
  14621. t['ahookabove'] = 0x1EA3;
  14622. t['aibengali'] = 0x0990;
  14623. t['aibopomofo'] = 0x311E;
  14624. t['aideva'] = 0x0910;
  14625. t['aiecyrillic'] = 0x04D5;
  14626. t['aigujarati'] = 0x0A90;
  14627. t['aigurmukhi'] = 0x0A10;
  14628. t['aimatragurmukhi'] = 0x0A48;
  14629. t['ainarabic'] = 0x0639;
  14630. t['ainfinalarabic'] = 0xFECA;
  14631. t['aininitialarabic'] = 0xFECB;
  14632. t['ainmedialarabic'] = 0xFECC;
  14633. t['ainvertedbreve'] = 0x0203;
  14634. t['aivowelsignbengali'] = 0x09C8;
  14635. t['aivowelsigndeva'] = 0x0948;
  14636. t['aivowelsigngujarati'] = 0x0AC8;
  14637. t['akatakana'] = 0x30A2;
  14638. t['akatakanahalfwidth'] = 0xFF71;
  14639. t['akorean'] = 0x314F;
  14640. t['alef'] = 0x05D0;
  14641. t['alefarabic'] = 0x0627;
  14642. t['alefdageshhebrew'] = 0xFB30;
  14643. t['aleffinalarabic'] = 0xFE8E;
  14644. t['alefhamzaabovearabic'] = 0x0623;
  14645. t['alefhamzaabovefinalarabic'] = 0xFE84;
  14646. t['alefhamzabelowarabic'] = 0x0625;
  14647. t['alefhamzabelowfinalarabic'] = 0xFE88;
  14648. t['alefhebrew'] = 0x05D0;
  14649. t['aleflamedhebrew'] = 0xFB4F;
  14650. t['alefmaddaabovearabic'] = 0x0622;
  14651. t['alefmaddaabovefinalarabic'] = 0xFE82;
  14652. t['alefmaksuraarabic'] = 0x0649;
  14653. t['alefmaksurafinalarabic'] = 0xFEF0;
  14654. t['alefmaksurainitialarabic'] = 0xFEF3;
  14655. t['alefmaksuramedialarabic'] = 0xFEF4;
  14656. t['alefpatahhebrew'] = 0xFB2E;
  14657. t['alefqamatshebrew'] = 0xFB2F;
  14658. t['aleph'] = 0x2135;
  14659. t['allequal'] = 0x224C;
  14660. t['alpha'] = 0x03B1;
  14661. t['alphatonos'] = 0x03AC;
  14662. t['amacron'] = 0x0101;
  14663. t['amonospace'] = 0xFF41;
  14664. t['ampersand'] = 0x0026;
  14665. t['ampersandmonospace'] = 0xFF06;
  14666. t['ampersandsmall'] = 0xF726;
  14667. t['amsquare'] = 0x33C2;
  14668. t['anbopomofo'] = 0x3122;
  14669. t['angbopomofo'] = 0x3124;
  14670. t['angbracketleft'] = 0x3008;
  14671. t['angbracketright'] = 0x3009;
  14672. t['angkhankhuthai'] = 0x0E5A;
  14673. t['angle'] = 0x2220;
  14674. t['anglebracketleft'] = 0x3008;
  14675. t['anglebracketleftvertical'] = 0xFE3F;
  14676. t['anglebracketright'] = 0x3009;
  14677. t['anglebracketrightvertical'] = 0xFE40;
  14678. t['angleleft'] = 0x2329;
  14679. t['angleright'] = 0x232A;
  14680. t['angstrom'] = 0x212B;
  14681. t['anoteleia'] = 0x0387;
  14682. t['anudattadeva'] = 0x0952;
  14683. t['anusvarabengali'] = 0x0982;
  14684. t['anusvaradeva'] = 0x0902;
  14685. t['anusvaragujarati'] = 0x0A82;
  14686. t['aogonek'] = 0x0105;
  14687. t['apaatosquare'] = 0x3300;
  14688. t['aparen'] = 0x249C;
  14689. t['apostrophearmenian'] = 0x055A;
  14690. t['apostrophemod'] = 0x02BC;
  14691. t['apple'] = 0xF8FF;
  14692. t['approaches'] = 0x2250;
  14693. t['approxequal'] = 0x2248;
  14694. t['approxequalorimage'] = 0x2252;
  14695. t['approximatelyequal'] = 0x2245;
  14696. t['araeaekorean'] = 0x318E;
  14697. t['araeakorean'] = 0x318D;
  14698. t['arc'] = 0x2312;
  14699. t['arighthalfring'] = 0x1E9A;
  14700. t['aring'] = 0x00E5;
  14701. t['aringacute'] = 0x01FB;
  14702. t['aringbelow'] = 0x1E01;
  14703. t['arrowboth'] = 0x2194;
  14704. t['arrowdashdown'] = 0x21E3;
  14705. t['arrowdashleft'] = 0x21E0;
  14706. t['arrowdashright'] = 0x21E2;
  14707. t['arrowdashup'] = 0x21E1;
  14708. t['arrowdblboth'] = 0x21D4;
  14709. t['arrowdbldown'] = 0x21D3;
  14710. t['arrowdblleft'] = 0x21D0;
  14711. t['arrowdblright'] = 0x21D2;
  14712. t['arrowdblup'] = 0x21D1;
  14713. t['arrowdown'] = 0x2193;
  14714. t['arrowdownleft'] = 0x2199;
  14715. t['arrowdownright'] = 0x2198;
  14716. t['arrowdownwhite'] = 0x21E9;
  14717. t['arrowheaddownmod'] = 0x02C5;
  14718. t['arrowheadleftmod'] = 0x02C2;
  14719. t['arrowheadrightmod'] = 0x02C3;
  14720. t['arrowheadupmod'] = 0x02C4;
  14721. t['arrowhorizex'] = 0xF8E7;
  14722. t['arrowleft'] = 0x2190;
  14723. t['arrowleftdbl'] = 0x21D0;
  14724. t['arrowleftdblstroke'] = 0x21CD;
  14725. t['arrowleftoverright'] = 0x21C6;
  14726. t['arrowleftwhite'] = 0x21E6;
  14727. t['arrowright'] = 0x2192;
  14728. t['arrowrightdblstroke'] = 0x21CF;
  14729. t['arrowrightheavy'] = 0x279E;
  14730. t['arrowrightoverleft'] = 0x21C4;
  14731. t['arrowrightwhite'] = 0x21E8;
  14732. t['arrowtableft'] = 0x21E4;
  14733. t['arrowtabright'] = 0x21E5;
  14734. t['arrowup'] = 0x2191;
  14735. t['arrowupdn'] = 0x2195;
  14736. t['arrowupdnbse'] = 0x21A8;
  14737. t['arrowupdownbase'] = 0x21A8;
  14738. t['arrowupleft'] = 0x2196;
  14739. t['arrowupleftofdown'] = 0x21C5;
  14740. t['arrowupright'] = 0x2197;
  14741. t['arrowupwhite'] = 0x21E7;
  14742. t['arrowvertex'] = 0xF8E6;
  14743. t['asciicircum'] = 0x005E;
  14744. t['asciicircummonospace'] = 0xFF3E;
  14745. t['asciitilde'] = 0x007E;
  14746. t['asciitildemonospace'] = 0xFF5E;
  14747. t['ascript'] = 0x0251;
  14748. t['ascriptturned'] = 0x0252;
  14749. t['asmallhiragana'] = 0x3041;
  14750. t['asmallkatakana'] = 0x30A1;
  14751. t['asmallkatakanahalfwidth'] = 0xFF67;
  14752. t['asterisk'] = 0x002A;
  14753. t['asteriskaltonearabic'] = 0x066D;
  14754. t['asteriskarabic'] = 0x066D;
  14755. t['asteriskmath'] = 0x2217;
  14756. t['asteriskmonospace'] = 0xFF0A;
  14757. t['asterisksmall'] = 0xFE61;
  14758. t['asterism'] = 0x2042;
  14759. t['asuperior'] = 0xF6E9;
  14760. t['asymptoticallyequal'] = 0x2243;
  14761. t['at'] = 0x0040;
  14762. t['atilde'] = 0x00E3;
  14763. t['atmonospace'] = 0xFF20;
  14764. t['atsmall'] = 0xFE6B;
  14765. t['aturned'] = 0x0250;
  14766. t['aubengali'] = 0x0994;
  14767. t['aubopomofo'] = 0x3120;
  14768. t['audeva'] = 0x0914;
  14769. t['augujarati'] = 0x0A94;
  14770. t['augurmukhi'] = 0x0A14;
  14771. t['aulengthmarkbengali'] = 0x09D7;
  14772. t['aumatragurmukhi'] = 0x0A4C;
  14773. t['auvowelsignbengali'] = 0x09CC;
  14774. t['auvowelsigndeva'] = 0x094C;
  14775. t['auvowelsigngujarati'] = 0x0ACC;
  14776. t['avagrahadeva'] = 0x093D;
  14777. t['aybarmenian'] = 0x0561;
  14778. t['ayin'] = 0x05E2;
  14779. t['ayinaltonehebrew'] = 0xFB20;
  14780. t['ayinhebrew'] = 0x05E2;
  14781. t['b'] = 0x0062;
  14782. t['babengali'] = 0x09AC;
  14783. t['backslash'] = 0x005C;
  14784. t['backslashmonospace'] = 0xFF3C;
  14785. t['badeva'] = 0x092C;
  14786. t['bagujarati'] = 0x0AAC;
  14787. t['bagurmukhi'] = 0x0A2C;
  14788. t['bahiragana'] = 0x3070;
  14789. t['bahtthai'] = 0x0E3F;
  14790. t['bakatakana'] = 0x30D0;
  14791. t['bar'] = 0x007C;
  14792. t['barmonospace'] = 0xFF5C;
  14793. t['bbopomofo'] = 0x3105;
  14794. t['bcircle'] = 0x24D1;
  14795. t['bdotaccent'] = 0x1E03;
  14796. t['bdotbelow'] = 0x1E05;
  14797. t['beamedsixteenthnotes'] = 0x266C;
  14798. t['because'] = 0x2235;
  14799. t['becyrillic'] = 0x0431;
  14800. t['beharabic'] = 0x0628;
  14801. t['behfinalarabic'] = 0xFE90;
  14802. t['behinitialarabic'] = 0xFE91;
  14803. t['behiragana'] = 0x3079;
  14804. t['behmedialarabic'] = 0xFE92;
  14805. t['behmeeminitialarabic'] = 0xFC9F;
  14806. t['behmeemisolatedarabic'] = 0xFC08;
  14807. t['behnoonfinalarabic'] = 0xFC6D;
  14808. t['bekatakana'] = 0x30D9;
  14809. t['benarmenian'] = 0x0562;
  14810. t['bet'] = 0x05D1;
  14811. t['beta'] = 0x03B2;
  14812. t['betasymbolgreek'] = 0x03D0;
  14813. t['betdagesh'] = 0xFB31;
  14814. t['betdageshhebrew'] = 0xFB31;
  14815. t['bethebrew'] = 0x05D1;
  14816. t['betrafehebrew'] = 0xFB4C;
  14817. t['bhabengali'] = 0x09AD;
  14818. t['bhadeva'] = 0x092D;
  14819. t['bhagujarati'] = 0x0AAD;
  14820. t['bhagurmukhi'] = 0x0A2D;
  14821. t['bhook'] = 0x0253;
  14822. t['bihiragana'] = 0x3073;
  14823. t['bikatakana'] = 0x30D3;
  14824. t['bilabialclick'] = 0x0298;
  14825. t['bindigurmukhi'] = 0x0A02;
  14826. t['birusquare'] = 0x3331;
  14827. t['blackcircle'] = 0x25CF;
  14828. t['blackdiamond'] = 0x25C6;
  14829. t['blackdownpointingtriangle'] = 0x25BC;
  14830. t['blackleftpointingpointer'] = 0x25C4;
  14831. t['blackleftpointingtriangle'] = 0x25C0;
  14832. t['blacklenticularbracketleft'] = 0x3010;
  14833. t['blacklenticularbracketleftvertical'] = 0xFE3B;
  14834. t['blacklenticularbracketright'] = 0x3011;
  14835. t['blacklenticularbracketrightvertical'] = 0xFE3C;
  14836. t['blacklowerlefttriangle'] = 0x25E3;
  14837. t['blacklowerrighttriangle'] = 0x25E2;
  14838. t['blackrectangle'] = 0x25AC;
  14839. t['blackrightpointingpointer'] = 0x25BA;
  14840. t['blackrightpointingtriangle'] = 0x25B6;
  14841. t['blacksmallsquare'] = 0x25AA;
  14842. t['blacksmilingface'] = 0x263B;
  14843. t['blacksquare'] = 0x25A0;
  14844. t['blackstar'] = 0x2605;
  14845. t['blackupperlefttriangle'] = 0x25E4;
  14846. t['blackupperrighttriangle'] = 0x25E5;
  14847. t['blackuppointingsmalltriangle'] = 0x25B4;
  14848. t['blackuppointingtriangle'] = 0x25B2;
  14849. t['blank'] = 0x2423;
  14850. t['blinebelow'] = 0x1E07;
  14851. t['block'] = 0x2588;
  14852. t['bmonospace'] = 0xFF42;
  14853. t['bobaimaithai'] = 0x0E1A;
  14854. t['bohiragana'] = 0x307C;
  14855. t['bokatakana'] = 0x30DC;
  14856. t['bparen'] = 0x249D;
  14857. t['bqsquare'] = 0x33C3;
  14858. t['braceex'] = 0xF8F4;
  14859. t['braceleft'] = 0x007B;
  14860. t['braceleftbt'] = 0xF8F3;
  14861. t['braceleftmid'] = 0xF8F2;
  14862. t['braceleftmonospace'] = 0xFF5B;
  14863. t['braceleftsmall'] = 0xFE5B;
  14864. t['bracelefttp'] = 0xF8F1;
  14865. t['braceleftvertical'] = 0xFE37;
  14866. t['braceright'] = 0x007D;
  14867. t['bracerightbt'] = 0xF8FE;
  14868. t['bracerightmid'] = 0xF8FD;
  14869. t['bracerightmonospace'] = 0xFF5D;
  14870. t['bracerightsmall'] = 0xFE5C;
  14871. t['bracerighttp'] = 0xF8FC;
  14872. t['bracerightvertical'] = 0xFE38;
  14873. t['bracketleft'] = 0x005B;
  14874. t['bracketleftbt'] = 0xF8F0;
  14875. t['bracketleftex'] = 0xF8EF;
  14876. t['bracketleftmonospace'] = 0xFF3B;
  14877. t['bracketlefttp'] = 0xF8EE;
  14878. t['bracketright'] = 0x005D;
  14879. t['bracketrightbt'] = 0xF8FB;
  14880. t['bracketrightex'] = 0xF8FA;
  14881. t['bracketrightmonospace'] = 0xFF3D;
  14882. t['bracketrighttp'] = 0xF8F9;
  14883. t['breve'] = 0x02D8;
  14884. t['brevebelowcmb'] = 0x032E;
  14885. t['brevecmb'] = 0x0306;
  14886. t['breveinvertedbelowcmb'] = 0x032F;
  14887. t['breveinvertedcmb'] = 0x0311;
  14888. t['breveinverteddoublecmb'] = 0x0361;
  14889. t['bridgebelowcmb'] = 0x032A;
  14890. t['bridgeinvertedbelowcmb'] = 0x033A;
  14891. t['brokenbar'] = 0x00A6;
  14892. t['bstroke'] = 0x0180;
  14893. t['bsuperior'] = 0xF6EA;
  14894. t['btopbar'] = 0x0183;
  14895. t['buhiragana'] = 0x3076;
  14896. t['bukatakana'] = 0x30D6;
  14897. t['bullet'] = 0x2022;
  14898. t['bulletinverse'] = 0x25D8;
  14899. t['bulletoperator'] = 0x2219;
  14900. t['bullseye'] = 0x25CE;
  14901. t['c'] = 0x0063;
  14902. t['caarmenian'] = 0x056E;
  14903. t['cabengali'] = 0x099A;
  14904. t['cacute'] = 0x0107;
  14905. t['cadeva'] = 0x091A;
  14906. t['cagujarati'] = 0x0A9A;
  14907. t['cagurmukhi'] = 0x0A1A;
  14908. t['calsquare'] = 0x3388;
  14909. t['candrabindubengali'] = 0x0981;
  14910. t['candrabinducmb'] = 0x0310;
  14911. t['candrabindudeva'] = 0x0901;
  14912. t['candrabindugujarati'] = 0x0A81;
  14913. t['capslock'] = 0x21EA;
  14914. t['careof'] = 0x2105;
  14915. t['caron'] = 0x02C7;
  14916. t['caronbelowcmb'] = 0x032C;
  14917. t['caroncmb'] = 0x030C;
  14918. t['carriagereturn'] = 0x21B5;
  14919. t['cbopomofo'] = 0x3118;
  14920. t['ccaron'] = 0x010D;
  14921. t['ccedilla'] = 0x00E7;
  14922. t['ccedillaacute'] = 0x1E09;
  14923. t['ccircle'] = 0x24D2;
  14924. t['ccircumflex'] = 0x0109;
  14925. t['ccurl'] = 0x0255;
  14926. t['cdot'] = 0x010B;
  14927. t['cdotaccent'] = 0x010B;
  14928. t['cdsquare'] = 0x33C5;
  14929. t['cedilla'] = 0x00B8;
  14930. t['cedillacmb'] = 0x0327;
  14931. t['cent'] = 0x00A2;
  14932. t['centigrade'] = 0x2103;
  14933. t['centinferior'] = 0xF6DF;
  14934. t['centmonospace'] = 0xFFE0;
  14935. t['centoldstyle'] = 0xF7A2;
  14936. t['centsuperior'] = 0xF6E0;
  14937. t['chaarmenian'] = 0x0579;
  14938. t['chabengali'] = 0x099B;
  14939. t['chadeva'] = 0x091B;
  14940. t['chagujarati'] = 0x0A9B;
  14941. t['chagurmukhi'] = 0x0A1B;
  14942. t['chbopomofo'] = 0x3114;
  14943. t['cheabkhasiancyrillic'] = 0x04BD;
  14944. t['checkmark'] = 0x2713;
  14945. t['checyrillic'] = 0x0447;
  14946. t['chedescenderabkhasiancyrillic'] = 0x04BF;
  14947. t['chedescendercyrillic'] = 0x04B7;
  14948. t['chedieresiscyrillic'] = 0x04F5;
  14949. t['cheharmenian'] = 0x0573;
  14950. t['chekhakassiancyrillic'] = 0x04CC;
  14951. t['cheverticalstrokecyrillic'] = 0x04B9;
  14952. t['chi'] = 0x03C7;
  14953. t['chieuchacirclekorean'] = 0x3277;
  14954. t['chieuchaparenkorean'] = 0x3217;
  14955. t['chieuchcirclekorean'] = 0x3269;
  14956. t['chieuchkorean'] = 0x314A;
  14957. t['chieuchparenkorean'] = 0x3209;
  14958. t['chochangthai'] = 0x0E0A;
  14959. t['chochanthai'] = 0x0E08;
  14960. t['chochingthai'] = 0x0E09;
  14961. t['chochoethai'] = 0x0E0C;
  14962. t['chook'] = 0x0188;
  14963. t['cieucacirclekorean'] = 0x3276;
  14964. t['cieucaparenkorean'] = 0x3216;
  14965. t['cieuccirclekorean'] = 0x3268;
  14966. t['cieuckorean'] = 0x3148;
  14967. t['cieucparenkorean'] = 0x3208;
  14968. t['cieucuparenkorean'] = 0x321C;
  14969. t['circle'] = 0x25CB;
  14970. t['circlecopyrt'] = 0x00A9;
  14971. t['circlemultiply'] = 0x2297;
  14972. t['circleot'] = 0x2299;
  14973. t['circleplus'] = 0x2295;
  14974. t['circlepostalmark'] = 0x3036;
  14975. t['circlewithlefthalfblack'] = 0x25D0;
  14976. t['circlewithrighthalfblack'] = 0x25D1;
  14977. t['circumflex'] = 0x02C6;
  14978. t['circumflexbelowcmb'] = 0x032D;
  14979. t['circumflexcmb'] = 0x0302;
  14980. t['clear'] = 0x2327;
  14981. t['clickalveolar'] = 0x01C2;
  14982. t['clickdental'] = 0x01C0;
  14983. t['clicklateral'] = 0x01C1;
  14984. t['clickretroflex'] = 0x01C3;
  14985. t['club'] = 0x2663;
  14986. t['clubsuitblack'] = 0x2663;
  14987. t['clubsuitwhite'] = 0x2667;
  14988. t['cmcubedsquare'] = 0x33A4;
  14989. t['cmonospace'] = 0xFF43;
  14990. t['cmsquaredsquare'] = 0x33A0;
  14991. t['coarmenian'] = 0x0581;
  14992. t['colon'] = 0x003A;
  14993. t['colonmonetary'] = 0x20A1;
  14994. t['colonmonospace'] = 0xFF1A;
  14995. t['colonsign'] = 0x20A1;
  14996. t['colonsmall'] = 0xFE55;
  14997. t['colontriangularhalfmod'] = 0x02D1;
  14998. t['colontriangularmod'] = 0x02D0;
  14999. t['comma'] = 0x002C;
  15000. t['commaabovecmb'] = 0x0313;
  15001. t['commaaboverightcmb'] = 0x0315;
  15002. t['commaaccent'] = 0xF6C3;
  15003. t['commaarabic'] = 0x060C;
  15004. t['commaarmenian'] = 0x055D;
  15005. t['commainferior'] = 0xF6E1;
  15006. t['commamonospace'] = 0xFF0C;
  15007. t['commareversedabovecmb'] = 0x0314;
  15008. t['commareversedmod'] = 0x02BD;
  15009. t['commasmall'] = 0xFE50;
  15010. t['commasuperior'] = 0xF6E2;
  15011. t['commaturnedabovecmb'] = 0x0312;
  15012. t['commaturnedmod'] = 0x02BB;
  15013. t['compass'] = 0x263C;
  15014. t['congruent'] = 0x2245;
  15015. t['contourintegral'] = 0x222E;
  15016. t['control'] = 0x2303;
  15017. t['controlACK'] = 0x0006;
  15018. t['controlBEL'] = 0x0007;
  15019. t['controlBS'] = 0x0008;
  15020. t['controlCAN'] = 0x0018;
  15021. t['controlCR'] = 0x000D;
  15022. t['controlDC1'] = 0x0011;
  15023. t['controlDC2'] = 0x0012;
  15024. t['controlDC3'] = 0x0013;
  15025. t['controlDC4'] = 0x0014;
  15026. t['controlDEL'] = 0x007F;
  15027. t['controlDLE'] = 0x0010;
  15028. t['controlEM'] = 0x0019;
  15029. t['controlENQ'] = 0x0005;
  15030. t['controlEOT'] = 0x0004;
  15031. t['controlESC'] = 0x001B;
  15032. t['controlETB'] = 0x0017;
  15033. t['controlETX'] = 0x0003;
  15034. t['controlFF'] = 0x000C;
  15035. t['controlFS'] = 0x001C;
  15036. t['controlGS'] = 0x001D;
  15037. t['controlHT'] = 0x0009;
  15038. t['controlLF'] = 0x000A;
  15039. t['controlNAK'] = 0x0015;
  15040. t['controlNULL'] = 0x0000;
  15041. t['controlRS'] = 0x001E;
  15042. t['controlSI'] = 0x000F;
  15043. t['controlSO'] = 0x000E;
  15044. t['controlSOT'] = 0x0002;
  15045. t['controlSTX'] = 0x0001;
  15046. t['controlSUB'] = 0x001A;
  15047. t['controlSYN'] = 0x0016;
  15048. t['controlUS'] = 0x001F;
  15049. t['controlVT'] = 0x000B;
  15050. t['copyright'] = 0x00A9;
  15051. t['copyrightsans'] = 0xF8E9;
  15052. t['copyrightserif'] = 0xF6D9;
  15053. t['cornerbracketleft'] = 0x300C;
  15054. t['cornerbracketlefthalfwidth'] = 0xFF62;
  15055. t['cornerbracketleftvertical'] = 0xFE41;
  15056. t['cornerbracketright'] = 0x300D;
  15057. t['cornerbracketrighthalfwidth'] = 0xFF63;
  15058. t['cornerbracketrightvertical'] = 0xFE42;
  15059. t['corporationsquare'] = 0x337F;
  15060. t['cosquare'] = 0x33C7;
  15061. t['coverkgsquare'] = 0x33C6;
  15062. t['cparen'] = 0x249E;
  15063. t['cruzeiro'] = 0x20A2;
  15064. t['cstretched'] = 0x0297;
  15065. t['curlyand'] = 0x22CF;
  15066. t['curlyor'] = 0x22CE;
  15067. t['currency'] = 0x00A4;
  15068. t['cyrBreve'] = 0xF6D1;
  15069. t['cyrFlex'] = 0xF6D2;
  15070. t['cyrbreve'] = 0xF6D4;
  15071. t['cyrflex'] = 0xF6D5;
  15072. t['d'] = 0x0064;
  15073. t['daarmenian'] = 0x0564;
  15074. t['dabengali'] = 0x09A6;
  15075. t['dadarabic'] = 0x0636;
  15076. t['dadeva'] = 0x0926;
  15077. t['dadfinalarabic'] = 0xFEBE;
  15078. t['dadinitialarabic'] = 0xFEBF;
  15079. t['dadmedialarabic'] = 0xFEC0;
  15080. t['dagesh'] = 0x05BC;
  15081. t['dageshhebrew'] = 0x05BC;
  15082. t['dagger'] = 0x2020;
  15083. t['daggerdbl'] = 0x2021;
  15084. t['dagujarati'] = 0x0AA6;
  15085. t['dagurmukhi'] = 0x0A26;
  15086. t['dahiragana'] = 0x3060;
  15087. t['dakatakana'] = 0x30C0;
  15088. t['dalarabic'] = 0x062F;
  15089. t['dalet'] = 0x05D3;
  15090. t['daletdagesh'] = 0xFB33;
  15091. t['daletdageshhebrew'] = 0xFB33;
  15092. t['dalethebrew'] = 0x05D3;
  15093. t['dalfinalarabic'] = 0xFEAA;
  15094. t['dammaarabic'] = 0x064F;
  15095. t['dammalowarabic'] = 0x064F;
  15096. t['dammatanaltonearabic'] = 0x064C;
  15097. t['dammatanarabic'] = 0x064C;
  15098. t['danda'] = 0x0964;
  15099. t['dargahebrew'] = 0x05A7;
  15100. t['dargalefthebrew'] = 0x05A7;
  15101. t['dasiapneumatacyrilliccmb'] = 0x0485;
  15102. t['dblGrave'] = 0xF6D3;
  15103. t['dblanglebracketleft'] = 0x300A;
  15104. t['dblanglebracketleftvertical'] = 0xFE3D;
  15105. t['dblanglebracketright'] = 0x300B;
  15106. t['dblanglebracketrightvertical'] = 0xFE3E;
  15107. t['dblarchinvertedbelowcmb'] = 0x032B;
  15108. t['dblarrowleft'] = 0x21D4;
  15109. t['dblarrowright'] = 0x21D2;
  15110. t['dbldanda'] = 0x0965;
  15111. t['dblgrave'] = 0xF6D6;
  15112. t['dblgravecmb'] = 0x030F;
  15113. t['dblintegral'] = 0x222C;
  15114. t['dbllowline'] = 0x2017;
  15115. t['dbllowlinecmb'] = 0x0333;
  15116. t['dbloverlinecmb'] = 0x033F;
  15117. t['dblprimemod'] = 0x02BA;
  15118. t['dblverticalbar'] = 0x2016;
  15119. t['dblverticallineabovecmb'] = 0x030E;
  15120. t['dbopomofo'] = 0x3109;
  15121. t['dbsquare'] = 0x33C8;
  15122. t['dcaron'] = 0x010F;
  15123. t['dcedilla'] = 0x1E11;
  15124. t['dcircle'] = 0x24D3;
  15125. t['dcircumflexbelow'] = 0x1E13;
  15126. t['dcroat'] = 0x0111;
  15127. t['ddabengali'] = 0x09A1;
  15128. t['ddadeva'] = 0x0921;
  15129. t['ddagujarati'] = 0x0AA1;
  15130. t['ddagurmukhi'] = 0x0A21;
  15131. t['ddalarabic'] = 0x0688;
  15132. t['ddalfinalarabic'] = 0xFB89;
  15133. t['dddhadeva'] = 0x095C;
  15134. t['ddhabengali'] = 0x09A2;
  15135. t['ddhadeva'] = 0x0922;
  15136. t['ddhagujarati'] = 0x0AA2;
  15137. t['ddhagurmukhi'] = 0x0A22;
  15138. t['ddotaccent'] = 0x1E0B;
  15139. t['ddotbelow'] = 0x1E0D;
  15140. t['decimalseparatorarabic'] = 0x066B;
  15141. t['decimalseparatorpersian'] = 0x066B;
  15142. t['decyrillic'] = 0x0434;
  15143. t['degree'] = 0x00B0;
  15144. t['dehihebrew'] = 0x05AD;
  15145. t['dehiragana'] = 0x3067;
  15146. t['deicoptic'] = 0x03EF;
  15147. t['dekatakana'] = 0x30C7;
  15148. t['deleteleft'] = 0x232B;
  15149. t['deleteright'] = 0x2326;
  15150. t['delta'] = 0x03B4;
  15151. t['deltaturned'] = 0x018D;
  15152. t['denominatorminusonenumeratorbengali'] = 0x09F8;
  15153. t['dezh'] = 0x02A4;
  15154. t['dhabengali'] = 0x09A7;
  15155. t['dhadeva'] = 0x0927;
  15156. t['dhagujarati'] = 0x0AA7;
  15157. t['dhagurmukhi'] = 0x0A27;
  15158. t['dhook'] = 0x0257;
  15159. t['dialytikatonos'] = 0x0385;
  15160. t['dialytikatonoscmb'] = 0x0344;
  15161. t['diamond'] = 0x2666;
  15162. t['diamondsuitwhite'] = 0x2662;
  15163. t['dieresis'] = 0x00A8;
  15164. t['dieresisacute'] = 0xF6D7;
  15165. t['dieresisbelowcmb'] = 0x0324;
  15166. t['dieresiscmb'] = 0x0308;
  15167. t['dieresisgrave'] = 0xF6D8;
  15168. t['dieresistonos'] = 0x0385;
  15169. t['dihiragana'] = 0x3062;
  15170. t['dikatakana'] = 0x30C2;
  15171. t['dittomark'] = 0x3003;
  15172. t['divide'] = 0x00F7;
  15173. t['divides'] = 0x2223;
  15174. t['divisionslash'] = 0x2215;
  15175. t['djecyrillic'] = 0x0452;
  15176. t['dkshade'] = 0x2593;
  15177. t['dlinebelow'] = 0x1E0F;
  15178. t['dlsquare'] = 0x3397;
  15179. t['dmacron'] = 0x0111;
  15180. t['dmonospace'] = 0xFF44;
  15181. t['dnblock'] = 0x2584;
  15182. t['dochadathai'] = 0x0E0E;
  15183. t['dodekthai'] = 0x0E14;
  15184. t['dohiragana'] = 0x3069;
  15185. t['dokatakana'] = 0x30C9;
  15186. t['dollar'] = 0x0024;
  15187. t['dollarinferior'] = 0xF6E3;
  15188. t['dollarmonospace'] = 0xFF04;
  15189. t['dollaroldstyle'] = 0xF724;
  15190. t['dollarsmall'] = 0xFE69;
  15191. t['dollarsuperior'] = 0xF6E4;
  15192. t['dong'] = 0x20AB;
  15193. t['dorusquare'] = 0x3326;
  15194. t['dotaccent'] = 0x02D9;
  15195. t['dotaccentcmb'] = 0x0307;
  15196. t['dotbelowcmb'] = 0x0323;
  15197. t['dotbelowcomb'] = 0x0323;
  15198. t['dotkatakana'] = 0x30FB;
  15199. t['dotlessi'] = 0x0131;
  15200. t['dotlessj'] = 0xF6BE;
  15201. t['dotlessjstrokehook'] = 0x0284;
  15202. t['dotmath'] = 0x22C5;
  15203. t['dottedcircle'] = 0x25CC;
  15204. t['doubleyodpatah'] = 0xFB1F;
  15205. t['doubleyodpatahhebrew'] = 0xFB1F;
  15206. t['downtackbelowcmb'] = 0x031E;
  15207. t['downtackmod'] = 0x02D5;
  15208. t['dparen'] = 0x249F;
  15209. t['dsuperior'] = 0xF6EB;
  15210. t['dtail'] = 0x0256;
  15211. t['dtopbar'] = 0x018C;
  15212. t['duhiragana'] = 0x3065;
  15213. t['dukatakana'] = 0x30C5;
  15214. t['dz'] = 0x01F3;
  15215. t['dzaltone'] = 0x02A3;
  15216. t['dzcaron'] = 0x01C6;
  15217. t['dzcurl'] = 0x02A5;
  15218. t['dzeabkhasiancyrillic'] = 0x04E1;
  15219. t['dzecyrillic'] = 0x0455;
  15220. t['dzhecyrillic'] = 0x045F;
  15221. t['e'] = 0x0065;
  15222. t['eacute'] = 0x00E9;
  15223. t['earth'] = 0x2641;
  15224. t['ebengali'] = 0x098F;
  15225. t['ebopomofo'] = 0x311C;
  15226. t['ebreve'] = 0x0115;
  15227. t['ecandradeva'] = 0x090D;
  15228. t['ecandragujarati'] = 0x0A8D;
  15229. t['ecandravowelsigndeva'] = 0x0945;
  15230. t['ecandravowelsigngujarati'] = 0x0AC5;
  15231. t['ecaron'] = 0x011B;
  15232. t['ecedillabreve'] = 0x1E1D;
  15233. t['echarmenian'] = 0x0565;
  15234. t['echyiwnarmenian'] = 0x0587;
  15235. t['ecircle'] = 0x24D4;
  15236. t['ecircumflex'] = 0x00EA;
  15237. t['ecircumflexacute'] = 0x1EBF;
  15238. t['ecircumflexbelow'] = 0x1E19;
  15239. t['ecircumflexdotbelow'] = 0x1EC7;
  15240. t['ecircumflexgrave'] = 0x1EC1;
  15241. t['ecircumflexhookabove'] = 0x1EC3;
  15242. t['ecircumflextilde'] = 0x1EC5;
  15243. t['ecyrillic'] = 0x0454;
  15244. t['edblgrave'] = 0x0205;
  15245. t['edeva'] = 0x090F;
  15246. t['edieresis'] = 0x00EB;
  15247. t['edot'] = 0x0117;
  15248. t['edotaccent'] = 0x0117;
  15249. t['edotbelow'] = 0x1EB9;
  15250. t['eegurmukhi'] = 0x0A0F;
  15251. t['eematragurmukhi'] = 0x0A47;
  15252. t['efcyrillic'] = 0x0444;
  15253. t['egrave'] = 0x00E8;
  15254. t['egujarati'] = 0x0A8F;
  15255. t['eharmenian'] = 0x0567;
  15256. t['ehbopomofo'] = 0x311D;
  15257. t['ehiragana'] = 0x3048;
  15258. t['ehookabove'] = 0x1EBB;
  15259. t['eibopomofo'] = 0x311F;
  15260. t['eight'] = 0x0038;
  15261. t['eightarabic'] = 0x0668;
  15262. t['eightbengali'] = 0x09EE;
  15263. t['eightcircle'] = 0x2467;
  15264. t['eightcircleinversesansserif'] = 0x2791;
  15265. t['eightdeva'] = 0x096E;
  15266. t['eighteencircle'] = 0x2471;
  15267. t['eighteenparen'] = 0x2485;
  15268. t['eighteenperiod'] = 0x2499;
  15269. t['eightgujarati'] = 0x0AEE;
  15270. t['eightgurmukhi'] = 0x0A6E;
  15271. t['eighthackarabic'] = 0x0668;
  15272. t['eighthangzhou'] = 0x3028;
  15273. t['eighthnotebeamed'] = 0x266B;
  15274. t['eightideographicparen'] = 0x3227;
  15275. t['eightinferior'] = 0x2088;
  15276. t['eightmonospace'] = 0xFF18;
  15277. t['eightoldstyle'] = 0xF738;
  15278. t['eightparen'] = 0x247B;
  15279. t['eightperiod'] = 0x248F;
  15280. t['eightpersian'] = 0x06F8;
  15281. t['eightroman'] = 0x2177;
  15282. t['eightsuperior'] = 0x2078;
  15283. t['eightthai'] = 0x0E58;
  15284. t['einvertedbreve'] = 0x0207;
  15285. t['eiotifiedcyrillic'] = 0x0465;
  15286. t['ekatakana'] = 0x30A8;
  15287. t['ekatakanahalfwidth'] = 0xFF74;
  15288. t['ekonkargurmukhi'] = 0x0A74;
  15289. t['ekorean'] = 0x3154;
  15290. t['elcyrillic'] = 0x043B;
  15291. t['element'] = 0x2208;
  15292. t['elevencircle'] = 0x246A;
  15293. t['elevenparen'] = 0x247E;
  15294. t['elevenperiod'] = 0x2492;
  15295. t['elevenroman'] = 0x217A;
  15296. t['ellipsis'] = 0x2026;
  15297. t['ellipsisvertical'] = 0x22EE;
  15298. t['emacron'] = 0x0113;
  15299. t['emacronacute'] = 0x1E17;
  15300. t['emacrongrave'] = 0x1E15;
  15301. t['emcyrillic'] = 0x043C;
  15302. t['emdash'] = 0x2014;
  15303. t['emdashvertical'] = 0xFE31;
  15304. t['emonospace'] = 0xFF45;
  15305. t['emphasismarkarmenian'] = 0x055B;
  15306. t['emptyset'] = 0x2205;
  15307. t['enbopomofo'] = 0x3123;
  15308. t['encyrillic'] = 0x043D;
  15309. t['endash'] = 0x2013;
  15310. t['endashvertical'] = 0xFE32;
  15311. t['endescendercyrillic'] = 0x04A3;
  15312. t['eng'] = 0x014B;
  15313. t['engbopomofo'] = 0x3125;
  15314. t['enghecyrillic'] = 0x04A5;
  15315. t['enhookcyrillic'] = 0x04C8;
  15316. t['enspace'] = 0x2002;
  15317. t['eogonek'] = 0x0119;
  15318. t['eokorean'] = 0x3153;
  15319. t['eopen'] = 0x025B;
  15320. t['eopenclosed'] = 0x029A;
  15321. t['eopenreversed'] = 0x025C;
  15322. t['eopenreversedclosed'] = 0x025E;
  15323. t['eopenreversedhook'] = 0x025D;
  15324. t['eparen'] = 0x24A0;
  15325. t['epsilon'] = 0x03B5;
  15326. t['epsilontonos'] = 0x03AD;
  15327. t['equal'] = 0x003D;
  15328. t['equalmonospace'] = 0xFF1D;
  15329. t['equalsmall'] = 0xFE66;
  15330. t['equalsuperior'] = 0x207C;
  15331. t['equivalence'] = 0x2261;
  15332. t['erbopomofo'] = 0x3126;
  15333. t['ercyrillic'] = 0x0440;
  15334. t['ereversed'] = 0x0258;
  15335. t['ereversedcyrillic'] = 0x044D;
  15336. t['escyrillic'] = 0x0441;
  15337. t['esdescendercyrillic'] = 0x04AB;
  15338. t['esh'] = 0x0283;
  15339. t['eshcurl'] = 0x0286;
  15340. t['eshortdeva'] = 0x090E;
  15341. t['eshortvowelsigndeva'] = 0x0946;
  15342. t['eshreversedloop'] = 0x01AA;
  15343. t['eshsquatreversed'] = 0x0285;
  15344. t['esmallhiragana'] = 0x3047;
  15345. t['esmallkatakana'] = 0x30A7;
  15346. t['esmallkatakanahalfwidth'] = 0xFF6A;
  15347. t['estimated'] = 0x212E;
  15348. t['esuperior'] = 0xF6EC;
  15349. t['eta'] = 0x03B7;
  15350. t['etarmenian'] = 0x0568;
  15351. t['etatonos'] = 0x03AE;
  15352. t['eth'] = 0x00F0;
  15353. t['etilde'] = 0x1EBD;
  15354. t['etildebelow'] = 0x1E1B;
  15355. t['etnahtafoukhhebrew'] = 0x0591;
  15356. t['etnahtafoukhlefthebrew'] = 0x0591;
  15357. t['etnahtahebrew'] = 0x0591;
  15358. t['etnahtalefthebrew'] = 0x0591;
  15359. t['eturned'] = 0x01DD;
  15360. t['eukorean'] = 0x3161;
  15361. t['euro'] = 0x20AC;
  15362. t['evowelsignbengali'] = 0x09C7;
  15363. t['evowelsigndeva'] = 0x0947;
  15364. t['evowelsigngujarati'] = 0x0AC7;
  15365. t['exclam'] = 0x0021;
  15366. t['exclamarmenian'] = 0x055C;
  15367. t['exclamdbl'] = 0x203C;
  15368. t['exclamdown'] = 0x00A1;
  15369. t['exclamdownsmall'] = 0xF7A1;
  15370. t['exclammonospace'] = 0xFF01;
  15371. t['exclamsmall'] = 0xF721;
  15372. t['existential'] = 0x2203;
  15373. t['ezh'] = 0x0292;
  15374. t['ezhcaron'] = 0x01EF;
  15375. t['ezhcurl'] = 0x0293;
  15376. t['ezhreversed'] = 0x01B9;
  15377. t['ezhtail'] = 0x01BA;
  15378. t['f'] = 0x0066;
  15379. t['fadeva'] = 0x095E;
  15380. t['fagurmukhi'] = 0x0A5E;
  15381. t['fahrenheit'] = 0x2109;
  15382. t['fathaarabic'] = 0x064E;
  15383. t['fathalowarabic'] = 0x064E;
  15384. t['fathatanarabic'] = 0x064B;
  15385. t['fbopomofo'] = 0x3108;
  15386. t['fcircle'] = 0x24D5;
  15387. t['fdotaccent'] = 0x1E1F;
  15388. t['feharabic'] = 0x0641;
  15389. t['feharmenian'] = 0x0586;
  15390. t['fehfinalarabic'] = 0xFED2;
  15391. t['fehinitialarabic'] = 0xFED3;
  15392. t['fehmedialarabic'] = 0xFED4;
  15393. t['feicoptic'] = 0x03E5;
  15394. t['female'] = 0x2640;
  15395. t['ff'] = 0xFB00;
  15396. t['ffi'] = 0xFB03;
  15397. t['ffl'] = 0xFB04;
  15398. t['fi'] = 0xFB01;
  15399. t['fifteencircle'] = 0x246E;
  15400. t['fifteenparen'] = 0x2482;
  15401. t['fifteenperiod'] = 0x2496;
  15402. t['figuredash'] = 0x2012;
  15403. t['filledbox'] = 0x25A0;
  15404. t['filledrect'] = 0x25AC;
  15405. t['finalkaf'] = 0x05DA;
  15406. t['finalkafdagesh'] = 0xFB3A;
  15407. t['finalkafdageshhebrew'] = 0xFB3A;
  15408. t['finalkafhebrew'] = 0x05DA;
  15409. t['finalmem'] = 0x05DD;
  15410. t['finalmemhebrew'] = 0x05DD;
  15411. t['finalnun'] = 0x05DF;
  15412. t['finalnunhebrew'] = 0x05DF;
  15413. t['finalpe'] = 0x05E3;
  15414. t['finalpehebrew'] = 0x05E3;
  15415. t['finaltsadi'] = 0x05E5;
  15416. t['finaltsadihebrew'] = 0x05E5;
  15417. t['firsttonechinese'] = 0x02C9;
  15418. t['fisheye'] = 0x25C9;
  15419. t['fitacyrillic'] = 0x0473;
  15420. t['five'] = 0x0035;
  15421. t['fivearabic'] = 0x0665;
  15422. t['fivebengali'] = 0x09EB;
  15423. t['fivecircle'] = 0x2464;
  15424. t['fivecircleinversesansserif'] = 0x278E;
  15425. t['fivedeva'] = 0x096B;
  15426. t['fiveeighths'] = 0x215D;
  15427. t['fivegujarati'] = 0x0AEB;
  15428. t['fivegurmukhi'] = 0x0A6B;
  15429. t['fivehackarabic'] = 0x0665;
  15430. t['fivehangzhou'] = 0x3025;
  15431. t['fiveideographicparen'] = 0x3224;
  15432. t['fiveinferior'] = 0x2085;
  15433. t['fivemonospace'] = 0xFF15;
  15434. t['fiveoldstyle'] = 0xF735;
  15435. t['fiveparen'] = 0x2478;
  15436. t['fiveperiod'] = 0x248C;
  15437. t['fivepersian'] = 0x06F5;
  15438. t['fiveroman'] = 0x2174;
  15439. t['fivesuperior'] = 0x2075;
  15440. t['fivethai'] = 0x0E55;
  15441. t['fl'] = 0xFB02;
  15442. t['florin'] = 0x0192;
  15443. t['fmonospace'] = 0xFF46;
  15444. t['fmsquare'] = 0x3399;
  15445. t['fofanthai'] = 0x0E1F;
  15446. t['fofathai'] = 0x0E1D;
  15447. t['fongmanthai'] = 0x0E4F;
  15448. t['forall'] = 0x2200;
  15449. t['four'] = 0x0034;
  15450. t['fourarabic'] = 0x0664;
  15451. t['fourbengali'] = 0x09EA;
  15452. t['fourcircle'] = 0x2463;
  15453. t['fourcircleinversesansserif'] = 0x278D;
  15454. t['fourdeva'] = 0x096A;
  15455. t['fourgujarati'] = 0x0AEA;
  15456. t['fourgurmukhi'] = 0x0A6A;
  15457. t['fourhackarabic'] = 0x0664;
  15458. t['fourhangzhou'] = 0x3024;
  15459. t['fourideographicparen'] = 0x3223;
  15460. t['fourinferior'] = 0x2084;
  15461. t['fourmonospace'] = 0xFF14;
  15462. t['fournumeratorbengali'] = 0x09F7;
  15463. t['fouroldstyle'] = 0xF734;
  15464. t['fourparen'] = 0x2477;
  15465. t['fourperiod'] = 0x248B;
  15466. t['fourpersian'] = 0x06F4;
  15467. t['fourroman'] = 0x2173;
  15468. t['foursuperior'] = 0x2074;
  15469. t['fourteencircle'] = 0x246D;
  15470. t['fourteenparen'] = 0x2481;
  15471. t['fourteenperiod'] = 0x2495;
  15472. t['fourthai'] = 0x0E54;
  15473. t['fourthtonechinese'] = 0x02CB;
  15474. t['fparen'] = 0x24A1;
  15475. t['fraction'] = 0x2044;
  15476. t['franc'] = 0x20A3;
  15477. t['g'] = 0x0067;
  15478. t['gabengali'] = 0x0997;
  15479. t['gacute'] = 0x01F5;
  15480. t['gadeva'] = 0x0917;
  15481. t['gafarabic'] = 0x06AF;
  15482. t['gaffinalarabic'] = 0xFB93;
  15483. t['gafinitialarabic'] = 0xFB94;
  15484. t['gafmedialarabic'] = 0xFB95;
  15485. t['gagujarati'] = 0x0A97;
  15486. t['gagurmukhi'] = 0x0A17;
  15487. t['gahiragana'] = 0x304C;
  15488. t['gakatakana'] = 0x30AC;
  15489. t['gamma'] = 0x03B3;
  15490. t['gammalatinsmall'] = 0x0263;
  15491. t['gammasuperior'] = 0x02E0;
  15492. t['gangiacoptic'] = 0x03EB;
  15493. t['gbopomofo'] = 0x310D;
  15494. t['gbreve'] = 0x011F;
  15495. t['gcaron'] = 0x01E7;
  15496. t['gcedilla'] = 0x0123;
  15497. t['gcircle'] = 0x24D6;
  15498. t['gcircumflex'] = 0x011D;
  15499. t['gcommaaccent'] = 0x0123;
  15500. t['gdot'] = 0x0121;
  15501. t['gdotaccent'] = 0x0121;
  15502. t['gecyrillic'] = 0x0433;
  15503. t['gehiragana'] = 0x3052;
  15504. t['gekatakana'] = 0x30B2;
  15505. t['geometricallyequal'] = 0x2251;
  15506. t['gereshaccenthebrew'] = 0x059C;
  15507. t['gereshhebrew'] = 0x05F3;
  15508. t['gereshmuqdamhebrew'] = 0x059D;
  15509. t['germandbls'] = 0x00DF;
  15510. t['gershayimaccenthebrew'] = 0x059E;
  15511. t['gershayimhebrew'] = 0x05F4;
  15512. t['getamark'] = 0x3013;
  15513. t['ghabengali'] = 0x0998;
  15514. t['ghadarmenian'] = 0x0572;
  15515. t['ghadeva'] = 0x0918;
  15516. t['ghagujarati'] = 0x0A98;
  15517. t['ghagurmukhi'] = 0x0A18;
  15518. t['ghainarabic'] = 0x063A;
  15519. t['ghainfinalarabic'] = 0xFECE;
  15520. t['ghaininitialarabic'] = 0xFECF;
  15521. t['ghainmedialarabic'] = 0xFED0;
  15522. t['ghemiddlehookcyrillic'] = 0x0495;
  15523. t['ghestrokecyrillic'] = 0x0493;
  15524. t['gheupturncyrillic'] = 0x0491;
  15525. t['ghhadeva'] = 0x095A;
  15526. t['ghhagurmukhi'] = 0x0A5A;
  15527. t['ghook'] = 0x0260;
  15528. t['ghzsquare'] = 0x3393;
  15529. t['gihiragana'] = 0x304E;
  15530. t['gikatakana'] = 0x30AE;
  15531. t['gimarmenian'] = 0x0563;
  15532. t['gimel'] = 0x05D2;
  15533. t['gimeldagesh'] = 0xFB32;
  15534. t['gimeldageshhebrew'] = 0xFB32;
  15535. t['gimelhebrew'] = 0x05D2;
  15536. t['gjecyrillic'] = 0x0453;
  15537. t['glottalinvertedstroke'] = 0x01BE;
  15538. t['glottalstop'] = 0x0294;
  15539. t['glottalstopinverted'] = 0x0296;
  15540. t['glottalstopmod'] = 0x02C0;
  15541. t['glottalstopreversed'] = 0x0295;
  15542. t['glottalstopreversedmod'] = 0x02C1;
  15543. t['glottalstopreversedsuperior'] = 0x02E4;
  15544. t['glottalstopstroke'] = 0x02A1;
  15545. t['glottalstopstrokereversed'] = 0x02A2;
  15546. t['gmacron'] = 0x1E21;
  15547. t['gmonospace'] = 0xFF47;
  15548. t['gohiragana'] = 0x3054;
  15549. t['gokatakana'] = 0x30B4;
  15550. t['gparen'] = 0x24A2;
  15551. t['gpasquare'] = 0x33AC;
  15552. t['gradient'] = 0x2207;
  15553. t['grave'] = 0x0060;
  15554. t['gravebelowcmb'] = 0x0316;
  15555. t['gravecmb'] = 0x0300;
  15556. t['gravecomb'] = 0x0300;
  15557. t['gravedeva'] = 0x0953;
  15558. t['gravelowmod'] = 0x02CE;
  15559. t['gravemonospace'] = 0xFF40;
  15560. t['gravetonecmb'] = 0x0340;
  15561. t['greater'] = 0x003E;
  15562. t['greaterequal'] = 0x2265;
  15563. t['greaterequalorless'] = 0x22DB;
  15564. t['greatermonospace'] = 0xFF1E;
  15565. t['greaterorequivalent'] = 0x2273;
  15566. t['greaterorless'] = 0x2277;
  15567. t['greateroverequal'] = 0x2267;
  15568. t['greatersmall'] = 0xFE65;
  15569. t['gscript'] = 0x0261;
  15570. t['gstroke'] = 0x01E5;
  15571. t['guhiragana'] = 0x3050;
  15572. t['guillemotleft'] = 0x00AB;
  15573. t['guillemotright'] = 0x00BB;
  15574. t['guilsinglleft'] = 0x2039;
  15575. t['guilsinglright'] = 0x203A;
  15576. t['gukatakana'] = 0x30B0;
  15577. t['guramusquare'] = 0x3318;
  15578. t['gysquare'] = 0x33C9;
  15579. t['h'] = 0x0068;
  15580. t['haabkhasiancyrillic'] = 0x04A9;
  15581. t['haaltonearabic'] = 0x06C1;
  15582. t['habengali'] = 0x09B9;
  15583. t['hadescendercyrillic'] = 0x04B3;
  15584. t['hadeva'] = 0x0939;
  15585. t['hagujarati'] = 0x0AB9;
  15586. t['hagurmukhi'] = 0x0A39;
  15587. t['haharabic'] = 0x062D;
  15588. t['hahfinalarabic'] = 0xFEA2;
  15589. t['hahinitialarabic'] = 0xFEA3;
  15590. t['hahiragana'] = 0x306F;
  15591. t['hahmedialarabic'] = 0xFEA4;
  15592. t['haitusquare'] = 0x332A;
  15593. t['hakatakana'] = 0x30CF;
  15594. t['hakatakanahalfwidth'] = 0xFF8A;
  15595. t['halantgurmukhi'] = 0x0A4D;
  15596. t['hamzaarabic'] = 0x0621;
  15597. t['hamzalowarabic'] = 0x0621;
  15598. t['hangulfiller'] = 0x3164;
  15599. t['hardsigncyrillic'] = 0x044A;
  15600. t['harpoonleftbarbup'] = 0x21BC;
  15601. t['harpoonrightbarbup'] = 0x21C0;
  15602. t['hasquare'] = 0x33CA;
  15603. t['hatafpatah'] = 0x05B2;
  15604. t['hatafpatah16'] = 0x05B2;
  15605. t['hatafpatah23'] = 0x05B2;
  15606. t['hatafpatah2f'] = 0x05B2;
  15607. t['hatafpatahhebrew'] = 0x05B2;
  15608. t['hatafpatahnarrowhebrew'] = 0x05B2;
  15609. t['hatafpatahquarterhebrew'] = 0x05B2;
  15610. t['hatafpatahwidehebrew'] = 0x05B2;
  15611. t['hatafqamats'] = 0x05B3;
  15612. t['hatafqamats1b'] = 0x05B3;
  15613. t['hatafqamats28'] = 0x05B3;
  15614. t['hatafqamats34'] = 0x05B3;
  15615. t['hatafqamatshebrew'] = 0x05B3;
  15616. t['hatafqamatsnarrowhebrew'] = 0x05B3;
  15617. t['hatafqamatsquarterhebrew'] = 0x05B3;
  15618. t['hatafqamatswidehebrew'] = 0x05B3;
  15619. t['hatafsegol'] = 0x05B1;
  15620. t['hatafsegol17'] = 0x05B1;
  15621. t['hatafsegol24'] = 0x05B1;
  15622. t['hatafsegol30'] = 0x05B1;
  15623. t['hatafsegolhebrew'] = 0x05B1;
  15624. t['hatafsegolnarrowhebrew'] = 0x05B1;
  15625. t['hatafsegolquarterhebrew'] = 0x05B1;
  15626. t['hatafsegolwidehebrew'] = 0x05B1;
  15627. t['hbar'] = 0x0127;
  15628. t['hbopomofo'] = 0x310F;
  15629. t['hbrevebelow'] = 0x1E2B;
  15630. t['hcedilla'] = 0x1E29;
  15631. t['hcircle'] = 0x24D7;
  15632. t['hcircumflex'] = 0x0125;
  15633. t['hdieresis'] = 0x1E27;
  15634. t['hdotaccent'] = 0x1E23;
  15635. t['hdotbelow'] = 0x1E25;
  15636. t['he'] = 0x05D4;
  15637. t['heart'] = 0x2665;
  15638. t['heartsuitblack'] = 0x2665;
  15639. t['heartsuitwhite'] = 0x2661;
  15640. t['hedagesh'] = 0xFB34;
  15641. t['hedageshhebrew'] = 0xFB34;
  15642. t['hehaltonearabic'] = 0x06C1;
  15643. t['heharabic'] = 0x0647;
  15644. t['hehebrew'] = 0x05D4;
  15645. t['hehfinalaltonearabic'] = 0xFBA7;
  15646. t['hehfinalalttwoarabic'] = 0xFEEA;
  15647. t['hehfinalarabic'] = 0xFEEA;
  15648. t['hehhamzaabovefinalarabic'] = 0xFBA5;
  15649. t['hehhamzaaboveisolatedarabic'] = 0xFBA4;
  15650. t['hehinitialaltonearabic'] = 0xFBA8;
  15651. t['hehinitialarabic'] = 0xFEEB;
  15652. t['hehiragana'] = 0x3078;
  15653. t['hehmedialaltonearabic'] = 0xFBA9;
  15654. t['hehmedialarabic'] = 0xFEEC;
  15655. t['heiseierasquare'] = 0x337B;
  15656. t['hekatakana'] = 0x30D8;
  15657. t['hekatakanahalfwidth'] = 0xFF8D;
  15658. t['hekutaarusquare'] = 0x3336;
  15659. t['henghook'] = 0x0267;
  15660. t['herutusquare'] = 0x3339;
  15661. t['het'] = 0x05D7;
  15662. t['hethebrew'] = 0x05D7;
  15663. t['hhook'] = 0x0266;
  15664. t['hhooksuperior'] = 0x02B1;
  15665. t['hieuhacirclekorean'] = 0x327B;
  15666. t['hieuhaparenkorean'] = 0x321B;
  15667. t['hieuhcirclekorean'] = 0x326D;
  15668. t['hieuhkorean'] = 0x314E;
  15669. t['hieuhparenkorean'] = 0x320D;
  15670. t['hihiragana'] = 0x3072;
  15671. t['hikatakana'] = 0x30D2;
  15672. t['hikatakanahalfwidth'] = 0xFF8B;
  15673. t['hiriq'] = 0x05B4;
  15674. t['hiriq14'] = 0x05B4;
  15675. t['hiriq21'] = 0x05B4;
  15676. t['hiriq2d'] = 0x05B4;
  15677. t['hiriqhebrew'] = 0x05B4;
  15678. t['hiriqnarrowhebrew'] = 0x05B4;
  15679. t['hiriqquarterhebrew'] = 0x05B4;
  15680. t['hiriqwidehebrew'] = 0x05B4;
  15681. t['hlinebelow'] = 0x1E96;
  15682. t['hmonospace'] = 0xFF48;
  15683. t['hoarmenian'] = 0x0570;
  15684. t['hohipthai'] = 0x0E2B;
  15685. t['hohiragana'] = 0x307B;
  15686. t['hokatakana'] = 0x30DB;
  15687. t['hokatakanahalfwidth'] = 0xFF8E;
  15688. t['holam'] = 0x05B9;
  15689. t['holam19'] = 0x05B9;
  15690. t['holam26'] = 0x05B9;
  15691. t['holam32'] = 0x05B9;
  15692. t['holamhebrew'] = 0x05B9;
  15693. t['holamnarrowhebrew'] = 0x05B9;
  15694. t['holamquarterhebrew'] = 0x05B9;
  15695. t['holamwidehebrew'] = 0x05B9;
  15696. t['honokhukthai'] = 0x0E2E;
  15697. t['hookabovecomb'] = 0x0309;
  15698. t['hookcmb'] = 0x0309;
  15699. t['hookpalatalizedbelowcmb'] = 0x0321;
  15700. t['hookretroflexbelowcmb'] = 0x0322;
  15701. t['hoonsquare'] = 0x3342;
  15702. t['horicoptic'] = 0x03E9;
  15703. t['horizontalbar'] = 0x2015;
  15704. t['horncmb'] = 0x031B;
  15705. t['hotsprings'] = 0x2668;
  15706. t['house'] = 0x2302;
  15707. t['hparen'] = 0x24A3;
  15708. t['hsuperior'] = 0x02B0;
  15709. t['hturned'] = 0x0265;
  15710. t['huhiragana'] = 0x3075;
  15711. t['huiitosquare'] = 0x3333;
  15712. t['hukatakana'] = 0x30D5;
  15713. t['hukatakanahalfwidth'] = 0xFF8C;
  15714. t['hungarumlaut'] = 0x02DD;
  15715. t['hungarumlautcmb'] = 0x030B;
  15716. t['hv'] = 0x0195;
  15717. t['hyphen'] = 0x002D;
  15718. t['hypheninferior'] = 0xF6E5;
  15719. t['hyphenmonospace'] = 0xFF0D;
  15720. t['hyphensmall'] = 0xFE63;
  15721. t['hyphensuperior'] = 0xF6E6;
  15722. t['hyphentwo'] = 0x2010;
  15723. t['i'] = 0x0069;
  15724. t['iacute'] = 0x00ED;
  15725. t['iacyrillic'] = 0x044F;
  15726. t['ibengali'] = 0x0987;
  15727. t['ibopomofo'] = 0x3127;
  15728. t['ibreve'] = 0x012D;
  15729. t['icaron'] = 0x01D0;
  15730. t['icircle'] = 0x24D8;
  15731. t['icircumflex'] = 0x00EE;
  15732. t['icyrillic'] = 0x0456;
  15733. t['idblgrave'] = 0x0209;
  15734. t['ideographearthcircle'] = 0x328F;
  15735. t['ideographfirecircle'] = 0x328B;
  15736. t['ideographicallianceparen'] = 0x323F;
  15737. t['ideographiccallparen'] = 0x323A;
  15738. t['ideographiccentrecircle'] = 0x32A5;
  15739. t['ideographicclose'] = 0x3006;
  15740. t['ideographiccomma'] = 0x3001;
  15741. t['ideographiccommaleft'] = 0xFF64;
  15742. t['ideographiccongratulationparen'] = 0x3237;
  15743. t['ideographiccorrectcircle'] = 0x32A3;
  15744. t['ideographicearthparen'] = 0x322F;
  15745. t['ideographicenterpriseparen'] = 0x323D;
  15746. t['ideographicexcellentcircle'] = 0x329D;
  15747. t['ideographicfestivalparen'] = 0x3240;
  15748. t['ideographicfinancialcircle'] = 0x3296;
  15749. t['ideographicfinancialparen'] = 0x3236;
  15750. t['ideographicfireparen'] = 0x322B;
  15751. t['ideographichaveparen'] = 0x3232;
  15752. t['ideographichighcircle'] = 0x32A4;
  15753. t['ideographiciterationmark'] = 0x3005;
  15754. t['ideographiclaborcircle'] = 0x3298;
  15755. t['ideographiclaborparen'] = 0x3238;
  15756. t['ideographicleftcircle'] = 0x32A7;
  15757. t['ideographiclowcircle'] = 0x32A6;
  15758. t['ideographicmedicinecircle'] = 0x32A9;
  15759. t['ideographicmetalparen'] = 0x322E;
  15760. t['ideographicmoonparen'] = 0x322A;
  15761. t['ideographicnameparen'] = 0x3234;
  15762. t['ideographicperiod'] = 0x3002;
  15763. t['ideographicprintcircle'] = 0x329E;
  15764. t['ideographicreachparen'] = 0x3243;
  15765. t['ideographicrepresentparen'] = 0x3239;
  15766. t['ideographicresourceparen'] = 0x323E;
  15767. t['ideographicrightcircle'] = 0x32A8;
  15768. t['ideographicsecretcircle'] = 0x3299;
  15769. t['ideographicselfparen'] = 0x3242;
  15770. t['ideographicsocietyparen'] = 0x3233;
  15771. t['ideographicspace'] = 0x3000;
  15772. t['ideographicspecialparen'] = 0x3235;
  15773. t['ideographicstockparen'] = 0x3231;
  15774. t['ideographicstudyparen'] = 0x323B;
  15775. t['ideographicsunparen'] = 0x3230;
  15776. t['ideographicsuperviseparen'] = 0x323C;
  15777. t['ideographicwaterparen'] = 0x322C;
  15778. t['ideographicwoodparen'] = 0x322D;
  15779. t['ideographiczero'] = 0x3007;
  15780. t['ideographmetalcircle'] = 0x328E;
  15781. t['ideographmooncircle'] = 0x328A;
  15782. t['ideographnamecircle'] = 0x3294;
  15783. t['ideographsuncircle'] = 0x3290;
  15784. t['ideographwatercircle'] = 0x328C;
  15785. t['ideographwoodcircle'] = 0x328D;
  15786. t['ideva'] = 0x0907;
  15787. t['idieresis'] = 0x00EF;
  15788. t['idieresisacute'] = 0x1E2F;
  15789. t['idieresiscyrillic'] = 0x04E5;
  15790. t['idotbelow'] = 0x1ECB;
  15791. t['iebrevecyrillic'] = 0x04D7;
  15792. t['iecyrillic'] = 0x0435;
  15793. t['ieungacirclekorean'] = 0x3275;
  15794. t['ieungaparenkorean'] = 0x3215;
  15795. t['ieungcirclekorean'] = 0x3267;
  15796. t['ieungkorean'] = 0x3147;
  15797. t['ieungparenkorean'] = 0x3207;
  15798. t['igrave'] = 0x00EC;
  15799. t['igujarati'] = 0x0A87;
  15800. t['igurmukhi'] = 0x0A07;
  15801. t['ihiragana'] = 0x3044;
  15802. t['ihookabove'] = 0x1EC9;
  15803. t['iibengali'] = 0x0988;
  15804. t['iicyrillic'] = 0x0438;
  15805. t['iideva'] = 0x0908;
  15806. t['iigujarati'] = 0x0A88;
  15807. t['iigurmukhi'] = 0x0A08;
  15808. t['iimatragurmukhi'] = 0x0A40;
  15809. t['iinvertedbreve'] = 0x020B;
  15810. t['iishortcyrillic'] = 0x0439;
  15811. t['iivowelsignbengali'] = 0x09C0;
  15812. t['iivowelsigndeva'] = 0x0940;
  15813. t['iivowelsigngujarati'] = 0x0AC0;
  15814. t['ij'] = 0x0133;
  15815. t['ikatakana'] = 0x30A4;
  15816. t['ikatakanahalfwidth'] = 0xFF72;
  15817. t['ikorean'] = 0x3163;
  15818. t['ilde'] = 0x02DC;
  15819. t['iluyhebrew'] = 0x05AC;
  15820. t['imacron'] = 0x012B;
  15821. t['imacroncyrillic'] = 0x04E3;
  15822. t['imageorapproximatelyequal'] = 0x2253;
  15823. t['imatragurmukhi'] = 0x0A3F;
  15824. t['imonospace'] = 0xFF49;
  15825. t['increment'] = 0x2206;
  15826. t['infinity'] = 0x221E;
  15827. t['iniarmenian'] = 0x056B;
  15828. t['integral'] = 0x222B;
  15829. t['integralbottom'] = 0x2321;
  15830. t['integralbt'] = 0x2321;
  15831. t['integralex'] = 0xF8F5;
  15832. t['integraltop'] = 0x2320;
  15833. t['integraltp'] = 0x2320;
  15834. t['intersection'] = 0x2229;
  15835. t['intisquare'] = 0x3305;
  15836. t['invbullet'] = 0x25D8;
  15837. t['invcircle'] = 0x25D9;
  15838. t['invsmileface'] = 0x263B;
  15839. t['iocyrillic'] = 0x0451;
  15840. t['iogonek'] = 0x012F;
  15841. t['iota'] = 0x03B9;
  15842. t['iotadieresis'] = 0x03CA;
  15843. t['iotadieresistonos'] = 0x0390;
  15844. t['iotalatin'] = 0x0269;
  15845. t['iotatonos'] = 0x03AF;
  15846. t['iparen'] = 0x24A4;
  15847. t['irigurmukhi'] = 0x0A72;
  15848. t['ismallhiragana'] = 0x3043;
  15849. t['ismallkatakana'] = 0x30A3;
  15850. t['ismallkatakanahalfwidth'] = 0xFF68;
  15851. t['issharbengali'] = 0x09FA;
  15852. t['istroke'] = 0x0268;
  15853. t['isuperior'] = 0xF6ED;
  15854. t['iterationhiragana'] = 0x309D;
  15855. t['iterationkatakana'] = 0x30FD;
  15856. t['itilde'] = 0x0129;
  15857. t['itildebelow'] = 0x1E2D;
  15858. t['iubopomofo'] = 0x3129;
  15859. t['iucyrillic'] = 0x044E;
  15860. t['ivowelsignbengali'] = 0x09BF;
  15861. t['ivowelsigndeva'] = 0x093F;
  15862. t['ivowelsigngujarati'] = 0x0ABF;
  15863. t['izhitsacyrillic'] = 0x0475;
  15864. t['izhitsadblgravecyrillic'] = 0x0477;
  15865. t['j'] = 0x006A;
  15866. t['jaarmenian'] = 0x0571;
  15867. t['jabengali'] = 0x099C;
  15868. t['jadeva'] = 0x091C;
  15869. t['jagujarati'] = 0x0A9C;
  15870. t['jagurmukhi'] = 0x0A1C;
  15871. t['jbopomofo'] = 0x3110;
  15872. t['jcaron'] = 0x01F0;
  15873. t['jcircle'] = 0x24D9;
  15874. t['jcircumflex'] = 0x0135;
  15875. t['jcrossedtail'] = 0x029D;
  15876. t['jdotlessstroke'] = 0x025F;
  15877. t['jecyrillic'] = 0x0458;
  15878. t['jeemarabic'] = 0x062C;
  15879. t['jeemfinalarabic'] = 0xFE9E;
  15880. t['jeeminitialarabic'] = 0xFE9F;
  15881. t['jeemmedialarabic'] = 0xFEA0;
  15882. t['jeharabic'] = 0x0698;
  15883. t['jehfinalarabic'] = 0xFB8B;
  15884. t['jhabengali'] = 0x099D;
  15885. t['jhadeva'] = 0x091D;
  15886. t['jhagujarati'] = 0x0A9D;
  15887. t['jhagurmukhi'] = 0x0A1D;
  15888. t['jheharmenian'] = 0x057B;
  15889. t['jis'] = 0x3004;
  15890. t['jmonospace'] = 0xFF4A;
  15891. t['jparen'] = 0x24A5;
  15892. t['jsuperior'] = 0x02B2;
  15893. t['k'] = 0x006B;
  15894. t['kabashkircyrillic'] = 0x04A1;
  15895. t['kabengali'] = 0x0995;
  15896. t['kacute'] = 0x1E31;
  15897. t['kacyrillic'] = 0x043A;
  15898. t['kadescendercyrillic'] = 0x049B;
  15899. t['kadeva'] = 0x0915;
  15900. t['kaf'] = 0x05DB;
  15901. t['kafarabic'] = 0x0643;
  15902. t['kafdagesh'] = 0xFB3B;
  15903. t['kafdageshhebrew'] = 0xFB3B;
  15904. t['kaffinalarabic'] = 0xFEDA;
  15905. t['kafhebrew'] = 0x05DB;
  15906. t['kafinitialarabic'] = 0xFEDB;
  15907. t['kafmedialarabic'] = 0xFEDC;
  15908. t['kafrafehebrew'] = 0xFB4D;
  15909. t['kagujarati'] = 0x0A95;
  15910. t['kagurmukhi'] = 0x0A15;
  15911. t['kahiragana'] = 0x304B;
  15912. t['kahookcyrillic'] = 0x04C4;
  15913. t['kakatakana'] = 0x30AB;
  15914. t['kakatakanahalfwidth'] = 0xFF76;
  15915. t['kappa'] = 0x03BA;
  15916. t['kappasymbolgreek'] = 0x03F0;
  15917. t['kapyeounmieumkorean'] = 0x3171;
  15918. t['kapyeounphieuphkorean'] = 0x3184;
  15919. t['kapyeounpieupkorean'] = 0x3178;
  15920. t['kapyeounssangpieupkorean'] = 0x3179;
  15921. t['karoriisquare'] = 0x330D;
  15922. t['kashidaautoarabic'] = 0x0640;
  15923. t['kashidaautonosidebearingarabic'] = 0x0640;
  15924. t['kasmallkatakana'] = 0x30F5;
  15925. t['kasquare'] = 0x3384;
  15926. t['kasraarabic'] = 0x0650;
  15927. t['kasratanarabic'] = 0x064D;
  15928. t['kastrokecyrillic'] = 0x049F;
  15929. t['katahiraprolongmarkhalfwidth'] = 0xFF70;
  15930. t['kaverticalstrokecyrillic'] = 0x049D;
  15931. t['kbopomofo'] = 0x310E;
  15932. t['kcalsquare'] = 0x3389;
  15933. t['kcaron'] = 0x01E9;
  15934. t['kcedilla'] = 0x0137;
  15935. t['kcircle'] = 0x24DA;
  15936. t['kcommaaccent'] = 0x0137;
  15937. t['kdotbelow'] = 0x1E33;
  15938. t['keharmenian'] = 0x0584;
  15939. t['kehiragana'] = 0x3051;
  15940. t['kekatakana'] = 0x30B1;
  15941. t['kekatakanahalfwidth'] = 0xFF79;
  15942. t['kenarmenian'] = 0x056F;
  15943. t['kesmallkatakana'] = 0x30F6;
  15944. t['kgreenlandic'] = 0x0138;
  15945. t['khabengali'] = 0x0996;
  15946. t['khacyrillic'] = 0x0445;
  15947. t['khadeva'] = 0x0916;
  15948. t['khagujarati'] = 0x0A96;
  15949. t['khagurmukhi'] = 0x0A16;
  15950. t['khaharabic'] = 0x062E;
  15951. t['khahfinalarabic'] = 0xFEA6;
  15952. t['khahinitialarabic'] = 0xFEA7;
  15953. t['khahmedialarabic'] = 0xFEA8;
  15954. t['kheicoptic'] = 0x03E7;
  15955. t['khhadeva'] = 0x0959;
  15956. t['khhagurmukhi'] = 0x0A59;
  15957. t['khieukhacirclekorean'] = 0x3278;
  15958. t['khieukhaparenkorean'] = 0x3218;
  15959. t['khieukhcirclekorean'] = 0x326A;
  15960. t['khieukhkorean'] = 0x314B;
  15961. t['khieukhparenkorean'] = 0x320A;
  15962. t['khokhaithai'] = 0x0E02;
  15963. t['khokhonthai'] = 0x0E05;
  15964. t['khokhuatthai'] = 0x0E03;
  15965. t['khokhwaithai'] = 0x0E04;
  15966. t['khomutthai'] = 0x0E5B;
  15967. t['khook'] = 0x0199;
  15968. t['khorakhangthai'] = 0x0E06;
  15969. t['khzsquare'] = 0x3391;
  15970. t['kihiragana'] = 0x304D;
  15971. t['kikatakana'] = 0x30AD;
  15972. t['kikatakanahalfwidth'] = 0xFF77;
  15973. t['kiroguramusquare'] = 0x3315;
  15974. t['kiromeetorusquare'] = 0x3316;
  15975. t['kirosquare'] = 0x3314;
  15976. t['kiyeokacirclekorean'] = 0x326E;
  15977. t['kiyeokaparenkorean'] = 0x320E;
  15978. t['kiyeokcirclekorean'] = 0x3260;
  15979. t['kiyeokkorean'] = 0x3131;
  15980. t['kiyeokparenkorean'] = 0x3200;
  15981. t['kiyeoksioskorean'] = 0x3133;
  15982. t['kjecyrillic'] = 0x045C;
  15983. t['klinebelow'] = 0x1E35;
  15984. t['klsquare'] = 0x3398;
  15985. t['kmcubedsquare'] = 0x33A6;
  15986. t['kmonospace'] = 0xFF4B;
  15987. t['kmsquaredsquare'] = 0x33A2;
  15988. t['kohiragana'] = 0x3053;
  15989. t['kohmsquare'] = 0x33C0;
  15990. t['kokaithai'] = 0x0E01;
  15991. t['kokatakana'] = 0x30B3;
  15992. t['kokatakanahalfwidth'] = 0xFF7A;
  15993. t['kooposquare'] = 0x331E;
  15994. t['koppacyrillic'] = 0x0481;
  15995. t['koreanstandardsymbol'] = 0x327F;
  15996. t['koroniscmb'] = 0x0343;
  15997. t['kparen'] = 0x24A6;
  15998. t['kpasquare'] = 0x33AA;
  15999. t['ksicyrillic'] = 0x046F;
  16000. t['ktsquare'] = 0x33CF;
  16001. t['kturned'] = 0x029E;
  16002. t['kuhiragana'] = 0x304F;
  16003. t['kukatakana'] = 0x30AF;
  16004. t['kukatakanahalfwidth'] = 0xFF78;
  16005. t['kvsquare'] = 0x33B8;
  16006. t['kwsquare'] = 0x33BE;
  16007. t['l'] = 0x006C;
  16008. t['labengali'] = 0x09B2;
  16009. t['lacute'] = 0x013A;
  16010. t['ladeva'] = 0x0932;
  16011. t['lagujarati'] = 0x0AB2;
  16012. t['lagurmukhi'] = 0x0A32;
  16013. t['lakkhangyaothai'] = 0x0E45;
  16014. t['lamaleffinalarabic'] = 0xFEFC;
  16015. t['lamalefhamzaabovefinalarabic'] = 0xFEF8;
  16016. t['lamalefhamzaaboveisolatedarabic'] = 0xFEF7;
  16017. t['lamalefhamzabelowfinalarabic'] = 0xFEFA;
  16018. t['lamalefhamzabelowisolatedarabic'] = 0xFEF9;
  16019. t['lamalefisolatedarabic'] = 0xFEFB;
  16020. t['lamalefmaddaabovefinalarabic'] = 0xFEF6;
  16021. t['lamalefmaddaaboveisolatedarabic'] = 0xFEF5;
  16022. t['lamarabic'] = 0x0644;
  16023. t['lambda'] = 0x03BB;
  16024. t['lambdastroke'] = 0x019B;
  16025. t['lamed'] = 0x05DC;
  16026. t['lameddagesh'] = 0xFB3C;
  16027. t['lameddageshhebrew'] = 0xFB3C;
  16028. t['lamedhebrew'] = 0x05DC;
  16029. t['lamfinalarabic'] = 0xFEDE;
  16030. t['lamhahinitialarabic'] = 0xFCCA;
  16031. t['laminitialarabic'] = 0xFEDF;
  16032. t['lamjeeminitialarabic'] = 0xFCC9;
  16033. t['lamkhahinitialarabic'] = 0xFCCB;
  16034. t['lamlamhehisolatedarabic'] = 0xFDF2;
  16035. t['lammedialarabic'] = 0xFEE0;
  16036. t['lammeemhahinitialarabic'] = 0xFD88;
  16037. t['lammeeminitialarabic'] = 0xFCCC;
  16038. t['largecircle'] = 0x25EF;
  16039. t['lbar'] = 0x019A;
  16040. t['lbelt'] = 0x026C;
  16041. t['lbopomofo'] = 0x310C;
  16042. t['lcaron'] = 0x013E;
  16043. t['lcedilla'] = 0x013C;
  16044. t['lcircle'] = 0x24DB;
  16045. t['lcircumflexbelow'] = 0x1E3D;
  16046. t['lcommaaccent'] = 0x013C;
  16047. t['ldot'] = 0x0140;
  16048. t['ldotaccent'] = 0x0140;
  16049. t['ldotbelow'] = 0x1E37;
  16050. t['ldotbelowmacron'] = 0x1E39;
  16051. t['leftangleabovecmb'] = 0x031A;
  16052. t['lefttackbelowcmb'] = 0x0318;
  16053. t['less'] = 0x003C;
  16054. t['lessequal'] = 0x2264;
  16055. t['lessequalorgreater'] = 0x22DA;
  16056. t['lessmonospace'] = 0xFF1C;
  16057. t['lessorequivalent'] = 0x2272;
  16058. t['lessorgreater'] = 0x2276;
  16059. t['lessoverequal'] = 0x2266;
  16060. t['lesssmall'] = 0xFE64;
  16061. t['lezh'] = 0x026E;
  16062. t['lfblock'] = 0x258C;
  16063. t['lhookretroflex'] = 0x026D;
  16064. t['lira'] = 0x20A4;
  16065. t['liwnarmenian'] = 0x056C;
  16066. t['lj'] = 0x01C9;
  16067. t['ljecyrillic'] = 0x0459;
  16068. t['ll'] = 0xF6C0;
  16069. t['lladeva'] = 0x0933;
  16070. t['llagujarati'] = 0x0AB3;
  16071. t['llinebelow'] = 0x1E3B;
  16072. t['llladeva'] = 0x0934;
  16073. t['llvocalicbengali'] = 0x09E1;
  16074. t['llvocalicdeva'] = 0x0961;
  16075. t['llvocalicvowelsignbengali'] = 0x09E3;
  16076. t['llvocalicvowelsigndeva'] = 0x0963;
  16077. t['lmiddletilde'] = 0x026B;
  16078. t['lmonospace'] = 0xFF4C;
  16079. t['lmsquare'] = 0x33D0;
  16080. t['lochulathai'] = 0x0E2C;
  16081. t['logicaland'] = 0x2227;
  16082. t['logicalnot'] = 0x00AC;
  16083. t['logicalnotreversed'] = 0x2310;
  16084. t['logicalor'] = 0x2228;
  16085. t['lolingthai'] = 0x0E25;
  16086. t['longs'] = 0x017F;
  16087. t['lowlinecenterline'] = 0xFE4E;
  16088. t['lowlinecmb'] = 0x0332;
  16089. t['lowlinedashed'] = 0xFE4D;
  16090. t['lozenge'] = 0x25CA;
  16091. t['lparen'] = 0x24A7;
  16092. t['lslash'] = 0x0142;
  16093. t['lsquare'] = 0x2113;
  16094. t['lsuperior'] = 0xF6EE;
  16095. t['ltshade'] = 0x2591;
  16096. t['luthai'] = 0x0E26;
  16097. t['lvocalicbengali'] = 0x098C;
  16098. t['lvocalicdeva'] = 0x090C;
  16099. t['lvocalicvowelsignbengali'] = 0x09E2;
  16100. t['lvocalicvowelsigndeva'] = 0x0962;
  16101. t['lxsquare'] = 0x33D3;
  16102. t['m'] = 0x006D;
  16103. t['mabengali'] = 0x09AE;
  16104. t['macron'] = 0x00AF;
  16105. t['macronbelowcmb'] = 0x0331;
  16106. t['macroncmb'] = 0x0304;
  16107. t['macronlowmod'] = 0x02CD;
  16108. t['macronmonospace'] = 0xFFE3;
  16109. t['macute'] = 0x1E3F;
  16110. t['madeva'] = 0x092E;
  16111. t['magujarati'] = 0x0AAE;
  16112. t['magurmukhi'] = 0x0A2E;
  16113. t['mahapakhhebrew'] = 0x05A4;
  16114. t['mahapakhlefthebrew'] = 0x05A4;
  16115. t['mahiragana'] = 0x307E;
  16116. t['maichattawalowleftthai'] = 0xF895;
  16117. t['maichattawalowrightthai'] = 0xF894;
  16118. t['maichattawathai'] = 0x0E4B;
  16119. t['maichattawaupperleftthai'] = 0xF893;
  16120. t['maieklowleftthai'] = 0xF88C;
  16121. t['maieklowrightthai'] = 0xF88B;
  16122. t['maiekthai'] = 0x0E48;
  16123. t['maiekupperleftthai'] = 0xF88A;
  16124. t['maihanakatleftthai'] = 0xF884;
  16125. t['maihanakatthai'] = 0x0E31;
  16126. t['maitaikhuleftthai'] = 0xF889;
  16127. t['maitaikhuthai'] = 0x0E47;
  16128. t['maitholowleftthai'] = 0xF88F;
  16129. t['maitholowrightthai'] = 0xF88E;
  16130. t['maithothai'] = 0x0E49;
  16131. t['maithoupperleftthai'] = 0xF88D;
  16132. t['maitrilowleftthai'] = 0xF892;
  16133. t['maitrilowrightthai'] = 0xF891;
  16134. t['maitrithai'] = 0x0E4A;
  16135. t['maitriupperleftthai'] = 0xF890;
  16136. t['maiyamokthai'] = 0x0E46;
  16137. t['makatakana'] = 0x30DE;
  16138. t['makatakanahalfwidth'] = 0xFF8F;
  16139. t['male'] = 0x2642;
  16140. t['mansyonsquare'] = 0x3347;
  16141. t['maqafhebrew'] = 0x05BE;
  16142. t['mars'] = 0x2642;
  16143. t['masoracirclehebrew'] = 0x05AF;
  16144. t['masquare'] = 0x3383;
  16145. t['mbopomofo'] = 0x3107;
  16146. t['mbsquare'] = 0x33D4;
  16147. t['mcircle'] = 0x24DC;
  16148. t['mcubedsquare'] = 0x33A5;
  16149. t['mdotaccent'] = 0x1E41;
  16150. t['mdotbelow'] = 0x1E43;
  16151. t['meemarabic'] = 0x0645;
  16152. t['meemfinalarabic'] = 0xFEE2;
  16153. t['meeminitialarabic'] = 0xFEE3;
  16154. t['meemmedialarabic'] = 0xFEE4;
  16155. t['meemmeeminitialarabic'] = 0xFCD1;
  16156. t['meemmeemisolatedarabic'] = 0xFC48;
  16157. t['meetorusquare'] = 0x334D;
  16158. t['mehiragana'] = 0x3081;
  16159. t['meizierasquare'] = 0x337E;
  16160. t['mekatakana'] = 0x30E1;
  16161. t['mekatakanahalfwidth'] = 0xFF92;
  16162. t['mem'] = 0x05DE;
  16163. t['memdagesh'] = 0xFB3E;
  16164. t['memdageshhebrew'] = 0xFB3E;
  16165. t['memhebrew'] = 0x05DE;
  16166. t['menarmenian'] = 0x0574;
  16167. t['merkhahebrew'] = 0x05A5;
  16168. t['merkhakefulahebrew'] = 0x05A6;
  16169. t['merkhakefulalefthebrew'] = 0x05A6;
  16170. t['merkhalefthebrew'] = 0x05A5;
  16171. t['mhook'] = 0x0271;
  16172. t['mhzsquare'] = 0x3392;
  16173. t['middledotkatakanahalfwidth'] = 0xFF65;
  16174. t['middot'] = 0x00B7;
  16175. t['mieumacirclekorean'] = 0x3272;
  16176. t['mieumaparenkorean'] = 0x3212;
  16177. t['mieumcirclekorean'] = 0x3264;
  16178. t['mieumkorean'] = 0x3141;
  16179. t['mieumpansioskorean'] = 0x3170;
  16180. t['mieumparenkorean'] = 0x3204;
  16181. t['mieumpieupkorean'] = 0x316E;
  16182. t['mieumsioskorean'] = 0x316F;
  16183. t['mihiragana'] = 0x307F;
  16184. t['mikatakana'] = 0x30DF;
  16185. t['mikatakanahalfwidth'] = 0xFF90;
  16186. t['minus'] = 0x2212;
  16187. t['minusbelowcmb'] = 0x0320;
  16188. t['minuscircle'] = 0x2296;
  16189. t['minusmod'] = 0x02D7;
  16190. t['minusplus'] = 0x2213;
  16191. t['minute'] = 0x2032;
  16192. t['miribaarusquare'] = 0x334A;
  16193. t['mirisquare'] = 0x3349;
  16194. t['mlonglegturned'] = 0x0270;
  16195. t['mlsquare'] = 0x3396;
  16196. t['mmcubedsquare'] = 0x33A3;
  16197. t['mmonospace'] = 0xFF4D;
  16198. t['mmsquaredsquare'] = 0x339F;
  16199. t['mohiragana'] = 0x3082;
  16200. t['mohmsquare'] = 0x33C1;
  16201. t['mokatakana'] = 0x30E2;
  16202. t['mokatakanahalfwidth'] = 0xFF93;
  16203. t['molsquare'] = 0x33D6;
  16204. t['momathai'] = 0x0E21;
  16205. t['moverssquare'] = 0x33A7;
  16206. t['moverssquaredsquare'] = 0x33A8;
  16207. t['mparen'] = 0x24A8;
  16208. t['mpasquare'] = 0x33AB;
  16209. t['mssquare'] = 0x33B3;
  16210. t['msuperior'] = 0xF6EF;
  16211. t['mturned'] = 0x026F;
  16212. t['mu'] = 0x00B5;
  16213. t['mu1'] = 0x00B5;
  16214. t['muasquare'] = 0x3382;
  16215. t['muchgreater'] = 0x226B;
  16216. t['muchless'] = 0x226A;
  16217. t['mufsquare'] = 0x338C;
  16218. t['mugreek'] = 0x03BC;
  16219. t['mugsquare'] = 0x338D;
  16220. t['muhiragana'] = 0x3080;
  16221. t['mukatakana'] = 0x30E0;
  16222. t['mukatakanahalfwidth'] = 0xFF91;
  16223. t['mulsquare'] = 0x3395;
  16224. t['multiply'] = 0x00D7;
  16225. t['mumsquare'] = 0x339B;
  16226. t['munahhebrew'] = 0x05A3;
  16227. t['munahlefthebrew'] = 0x05A3;
  16228. t['musicalnote'] = 0x266A;
  16229. t['musicalnotedbl'] = 0x266B;
  16230. t['musicflatsign'] = 0x266D;
  16231. t['musicsharpsign'] = 0x266F;
  16232. t['mussquare'] = 0x33B2;
  16233. t['muvsquare'] = 0x33B6;
  16234. t['muwsquare'] = 0x33BC;
  16235. t['mvmegasquare'] = 0x33B9;
  16236. t['mvsquare'] = 0x33B7;
  16237. t['mwmegasquare'] = 0x33BF;
  16238. t['mwsquare'] = 0x33BD;
  16239. t['n'] = 0x006E;
  16240. t['nabengali'] = 0x09A8;
  16241. t['nabla'] = 0x2207;
  16242. t['nacute'] = 0x0144;
  16243. t['nadeva'] = 0x0928;
  16244. t['nagujarati'] = 0x0AA8;
  16245. t['nagurmukhi'] = 0x0A28;
  16246. t['nahiragana'] = 0x306A;
  16247. t['nakatakana'] = 0x30CA;
  16248. t['nakatakanahalfwidth'] = 0xFF85;
  16249. t['napostrophe'] = 0x0149;
  16250. t['nasquare'] = 0x3381;
  16251. t['nbopomofo'] = 0x310B;
  16252. t['nbspace'] = 0x00A0;
  16253. t['ncaron'] = 0x0148;
  16254. t['ncedilla'] = 0x0146;
  16255. t['ncircle'] = 0x24DD;
  16256. t['ncircumflexbelow'] = 0x1E4B;
  16257. t['ncommaaccent'] = 0x0146;
  16258. t['ndotaccent'] = 0x1E45;
  16259. t['ndotbelow'] = 0x1E47;
  16260. t['nehiragana'] = 0x306D;
  16261. t['nekatakana'] = 0x30CD;
  16262. t['nekatakanahalfwidth'] = 0xFF88;
  16263. t['newsheqelsign'] = 0x20AA;
  16264. t['nfsquare'] = 0x338B;
  16265. t['ngabengali'] = 0x0999;
  16266. t['ngadeva'] = 0x0919;
  16267. t['ngagujarati'] = 0x0A99;
  16268. t['ngagurmukhi'] = 0x0A19;
  16269. t['ngonguthai'] = 0x0E07;
  16270. t['nhiragana'] = 0x3093;
  16271. t['nhookleft'] = 0x0272;
  16272. t['nhookretroflex'] = 0x0273;
  16273. t['nieunacirclekorean'] = 0x326F;
  16274. t['nieunaparenkorean'] = 0x320F;
  16275. t['nieuncieuckorean'] = 0x3135;
  16276. t['nieuncirclekorean'] = 0x3261;
  16277. t['nieunhieuhkorean'] = 0x3136;
  16278. t['nieunkorean'] = 0x3134;
  16279. t['nieunpansioskorean'] = 0x3168;
  16280. t['nieunparenkorean'] = 0x3201;
  16281. t['nieunsioskorean'] = 0x3167;
  16282. t['nieuntikeutkorean'] = 0x3166;
  16283. t['nihiragana'] = 0x306B;
  16284. t['nikatakana'] = 0x30CB;
  16285. t['nikatakanahalfwidth'] = 0xFF86;
  16286. t['nikhahitleftthai'] = 0xF899;
  16287. t['nikhahitthai'] = 0x0E4D;
  16288. t['nine'] = 0x0039;
  16289. t['ninearabic'] = 0x0669;
  16290. t['ninebengali'] = 0x09EF;
  16291. t['ninecircle'] = 0x2468;
  16292. t['ninecircleinversesansserif'] = 0x2792;
  16293. t['ninedeva'] = 0x096F;
  16294. t['ninegujarati'] = 0x0AEF;
  16295. t['ninegurmukhi'] = 0x0A6F;
  16296. t['ninehackarabic'] = 0x0669;
  16297. t['ninehangzhou'] = 0x3029;
  16298. t['nineideographicparen'] = 0x3228;
  16299. t['nineinferior'] = 0x2089;
  16300. t['ninemonospace'] = 0xFF19;
  16301. t['nineoldstyle'] = 0xF739;
  16302. t['nineparen'] = 0x247C;
  16303. t['nineperiod'] = 0x2490;
  16304. t['ninepersian'] = 0x06F9;
  16305. t['nineroman'] = 0x2178;
  16306. t['ninesuperior'] = 0x2079;
  16307. t['nineteencircle'] = 0x2472;
  16308. t['nineteenparen'] = 0x2486;
  16309. t['nineteenperiod'] = 0x249A;
  16310. t['ninethai'] = 0x0E59;
  16311. t['nj'] = 0x01CC;
  16312. t['njecyrillic'] = 0x045A;
  16313. t['nkatakana'] = 0x30F3;
  16314. t['nkatakanahalfwidth'] = 0xFF9D;
  16315. t['nlegrightlong'] = 0x019E;
  16316. t['nlinebelow'] = 0x1E49;
  16317. t['nmonospace'] = 0xFF4E;
  16318. t['nmsquare'] = 0x339A;
  16319. t['nnabengali'] = 0x09A3;
  16320. t['nnadeva'] = 0x0923;
  16321. t['nnagujarati'] = 0x0AA3;
  16322. t['nnagurmukhi'] = 0x0A23;
  16323. t['nnnadeva'] = 0x0929;
  16324. t['nohiragana'] = 0x306E;
  16325. t['nokatakana'] = 0x30CE;
  16326. t['nokatakanahalfwidth'] = 0xFF89;
  16327. t['nonbreakingspace'] = 0x00A0;
  16328. t['nonenthai'] = 0x0E13;
  16329. t['nonuthai'] = 0x0E19;
  16330. t['noonarabic'] = 0x0646;
  16331. t['noonfinalarabic'] = 0xFEE6;
  16332. t['noonghunnaarabic'] = 0x06BA;
  16333. t['noonghunnafinalarabic'] = 0xFB9F;
  16334. t['nooninitialarabic'] = 0xFEE7;
  16335. t['noonjeeminitialarabic'] = 0xFCD2;
  16336. t['noonjeemisolatedarabic'] = 0xFC4B;
  16337. t['noonmedialarabic'] = 0xFEE8;
  16338. t['noonmeeminitialarabic'] = 0xFCD5;
  16339. t['noonmeemisolatedarabic'] = 0xFC4E;
  16340. t['noonnoonfinalarabic'] = 0xFC8D;
  16341. t['notcontains'] = 0x220C;
  16342. t['notelement'] = 0x2209;
  16343. t['notelementof'] = 0x2209;
  16344. t['notequal'] = 0x2260;
  16345. t['notgreater'] = 0x226F;
  16346. t['notgreaternorequal'] = 0x2271;
  16347. t['notgreaternorless'] = 0x2279;
  16348. t['notidentical'] = 0x2262;
  16349. t['notless'] = 0x226E;
  16350. t['notlessnorequal'] = 0x2270;
  16351. t['notparallel'] = 0x2226;
  16352. t['notprecedes'] = 0x2280;
  16353. t['notsubset'] = 0x2284;
  16354. t['notsucceeds'] = 0x2281;
  16355. t['notsuperset'] = 0x2285;
  16356. t['nowarmenian'] = 0x0576;
  16357. t['nparen'] = 0x24A9;
  16358. t['nssquare'] = 0x33B1;
  16359. t['nsuperior'] = 0x207F;
  16360. t['ntilde'] = 0x00F1;
  16361. t['nu'] = 0x03BD;
  16362. t['nuhiragana'] = 0x306C;
  16363. t['nukatakana'] = 0x30CC;
  16364. t['nukatakanahalfwidth'] = 0xFF87;
  16365. t['nuktabengali'] = 0x09BC;
  16366. t['nuktadeva'] = 0x093C;
  16367. t['nuktagujarati'] = 0x0ABC;
  16368. t['nuktagurmukhi'] = 0x0A3C;
  16369. t['numbersign'] = 0x0023;
  16370. t['numbersignmonospace'] = 0xFF03;
  16371. t['numbersignsmall'] = 0xFE5F;
  16372. t['numeralsigngreek'] = 0x0374;
  16373. t['numeralsignlowergreek'] = 0x0375;
  16374. t['numero'] = 0x2116;
  16375. t['nun'] = 0x05E0;
  16376. t['nundagesh'] = 0xFB40;
  16377. t['nundageshhebrew'] = 0xFB40;
  16378. t['nunhebrew'] = 0x05E0;
  16379. t['nvsquare'] = 0x33B5;
  16380. t['nwsquare'] = 0x33BB;
  16381. t['nyabengali'] = 0x099E;
  16382. t['nyadeva'] = 0x091E;
  16383. t['nyagujarati'] = 0x0A9E;
  16384. t['nyagurmukhi'] = 0x0A1E;
  16385. t['o'] = 0x006F;
  16386. t['oacute'] = 0x00F3;
  16387. t['oangthai'] = 0x0E2D;
  16388. t['obarred'] = 0x0275;
  16389. t['obarredcyrillic'] = 0x04E9;
  16390. t['obarreddieresiscyrillic'] = 0x04EB;
  16391. t['obengali'] = 0x0993;
  16392. t['obopomofo'] = 0x311B;
  16393. t['obreve'] = 0x014F;
  16394. t['ocandradeva'] = 0x0911;
  16395. t['ocandragujarati'] = 0x0A91;
  16396. t['ocandravowelsigndeva'] = 0x0949;
  16397. t['ocandravowelsigngujarati'] = 0x0AC9;
  16398. t['ocaron'] = 0x01D2;
  16399. t['ocircle'] = 0x24DE;
  16400. t['ocircumflex'] = 0x00F4;
  16401. t['ocircumflexacute'] = 0x1ED1;
  16402. t['ocircumflexdotbelow'] = 0x1ED9;
  16403. t['ocircumflexgrave'] = 0x1ED3;
  16404. t['ocircumflexhookabove'] = 0x1ED5;
  16405. t['ocircumflextilde'] = 0x1ED7;
  16406. t['ocyrillic'] = 0x043E;
  16407. t['odblacute'] = 0x0151;
  16408. t['odblgrave'] = 0x020D;
  16409. t['odeva'] = 0x0913;
  16410. t['odieresis'] = 0x00F6;
  16411. t['odieresiscyrillic'] = 0x04E7;
  16412. t['odotbelow'] = 0x1ECD;
  16413. t['oe'] = 0x0153;
  16414. t['oekorean'] = 0x315A;
  16415. t['ogonek'] = 0x02DB;
  16416. t['ogonekcmb'] = 0x0328;
  16417. t['ograve'] = 0x00F2;
  16418. t['ogujarati'] = 0x0A93;
  16419. t['oharmenian'] = 0x0585;
  16420. t['ohiragana'] = 0x304A;
  16421. t['ohookabove'] = 0x1ECF;
  16422. t['ohorn'] = 0x01A1;
  16423. t['ohornacute'] = 0x1EDB;
  16424. t['ohorndotbelow'] = 0x1EE3;
  16425. t['ohorngrave'] = 0x1EDD;
  16426. t['ohornhookabove'] = 0x1EDF;
  16427. t['ohorntilde'] = 0x1EE1;
  16428. t['ohungarumlaut'] = 0x0151;
  16429. t['oi'] = 0x01A3;
  16430. t['oinvertedbreve'] = 0x020F;
  16431. t['okatakana'] = 0x30AA;
  16432. t['okatakanahalfwidth'] = 0xFF75;
  16433. t['okorean'] = 0x3157;
  16434. t['olehebrew'] = 0x05AB;
  16435. t['omacron'] = 0x014D;
  16436. t['omacronacute'] = 0x1E53;
  16437. t['omacrongrave'] = 0x1E51;
  16438. t['omdeva'] = 0x0950;
  16439. t['omega'] = 0x03C9;
  16440. t['omega1'] = 0x03D6;
  16441. t['omegacyrillic'] = 0x0461;
  16442. t['omegalatinclosed'] = 0x0277;
  16443. t['omegaroundcyrillic'] = 0x047B;
  16444. t['omegatitlocyrillic'] = 0x047D;
  16445. t['omegatonos'] = 0x03CE;
  16446. t['omgujarati'] = 0x0AD0;
  16447. t['omicron'] = 0x03BF;
  16448. t['omicrontonos'] = 0x03CC;
  16449. t['omonospace'] = 0xFF4F;
  16450. t['one'] = 0x0031;
  16451. t['onearabic'] = 0x0661;
  16452. t['onebengali'] = 0x09E7;
  16453. t['onecircle'] = 0x2460;
  16454. t['onecircleinversesansserif'] = 0x278A;
  16455. t['onedeva'] = 0x0967;
  16456. t['onedotenleader'] = 0x2024;
  16457. t['oneeighth'] = 0x215B;
  16458. t['onefitted'] = 0xF6DC;
  16459. t['onegujarati'] = 0x0AE7;
  16460. t['onegurmukhi'] = 0x0A67;
  16461. t['onehackarabic'] = 0x0661;
  16462. t['onehalf'] = 0x00BD;
  16463. t['onehangzhou'] = 0x3021;
  16464. t['oneideographicparen'] = 0x3220;
  16465. t['oneinferior'] = 0x2081;
  16466. t['onemonospace'] = 0xFF11;
  16467. t['onenumeratorbengali'] = 0x09F4;
  16468. t['oneoldstyle'] = 0xF731;
  16469. t['oneparen'] = 0x2474;
  16470. t['oneperiod'] = 0x2488;
  16471. t['onepersian'] = 0x06F1;
  16472. t['onequarter'] = 0x00BC;
  16473. t['oneroman'] = 0x2170;
  16474. t['onesuperior'] = 0x00B9;
  16475. t['onethai'] = 0x0E51;
  16476. t['onethird'] = 0x2153;
  16477. t['oogonek'] = 0x01EB;
  16478. t['oogonekmacron'] = 0x01ED;
  16479. t['oogurmukhi'] = 0x0A13;
  16480. t['oomatragurmukhi'] = 0x0A4B;
  16481. t['oopen'] = 0x0254;
  16482. t['oparen'] = 0x24AA;
  16483. t['openbullet'] = 0x25E6;
  16484. t['option'] = 0x2325;
  16485. t['ordfeminine'] = 0x00AA;
  16486. t['ordmasculine'] = 0x00BA;
  16487. t['orthogonal'] = 0x221F;
  16488. t['oshortdeva'] = 0x0912;
  16489. t['oshortvowelsigndeva'] = 0x094A;
  16490. t['oslash'] = 0x00F8;
  16491. t['oslashacute'] = 0x01FF;
  16492. t['osmallhiragana'] = 0x3049;
  16493. t['osmallkatakana'] = 0x30A9;
  16494. t['osmallkatakanahalfwidth'] = 0xFF6B;
  16495. t['ostrokeacute'] = 0x01FF;
  16496. t['osuperior'] = 0xF6F0;
  16497. t['otcyrillic'] = 0x047F;
  16498. t['otilde'] = 0x00F5;
  16499. t['otildeacute'] = 0x1E4D;
  16500. t['otildedieresis'] = 0x1E4F;
  16501. t['oubopomofo'] = 0x3121;
  16502. t['overline'] = 0x203E;
  16503. t['overlinecenterline'] = 0xFE4A;
  16504. t['overlinecmb'] = 0x0305;
  16505. t['overlinedashed'] = 0xFE49;
  16506. t['overlinedblwavy'] = 0xFE4C;
  16507. t['overlinewavy'] = 0xFE4B;
  16508. t['overscore'] = 0x00AF;
  16509. t['ovowelsignbengali'] = 0x09CB;
  16510. t['ovowelsigndeva'] = 0x094B;
  16511. t['ovowelsigngujarati'] = 0x0ACB;
  16512. t['p'] = 0x0070;
  16513. t['paampssquare'] = 0x3380;
  16514. t['paasentosquare'] = 0x332B;
  16515. t['pabengali'] = 0x09AA;
  16516. t['pacute'] = 0x1E55;
  16517. t['padeva'] = 0x092A;
  16518. t['pagedown'] = 0x21DF;
  16519. t['pageup'] = 0x21DE;
  16520. t['pagujarati'] = 0x0AAA;
  16521. t['pagurmukhi'] = 0x0A2A;
  16522. t['pahiragana'] = 0x3071;
  16523. t['paiyannoithai'] = 0x0E2F;
  16524. t['pakatakana'] = 0x30D1;
  16525. t['palatalizationcyrilliccmb'] = 0x0484;
  16526. t['palochkacyrillic'] = 0x04C0;
  16527. t['pansioskorean'] = 0x317F;
  16528. t['paragraph'] = 0x00B6;
  16529. t['parallel'] = 0x2225;
  16530. t['parenleft'] = 0x0028;
  16531. t['parenleftaltonearabic'] = 0xFD3E;
  16532. t['parenleftbt'] = 0xF8ED;
  16533. t['parenleftex'] = 0xF8EC;
  16534. t['parenleftinferior'] = 0x208D;
  16535. t['parenleftmonospace'] = 0xFF08;
  16536. t['parenleftsmall'] = 0xFE59;
  16537. t['parenleftsuperior'] = 0x207D;
  16538. t['parenlefttp'] = 0xF8EB;
  16539. t['parenleftvertical'] = 0xFE35;
  16540. t['parenright'] = 0x0029;
  16541. t['parenrightaltonearabic'] = 0xFD3F;
  16542. t['parenrightbt'] = 0xF8F8;
  16543. t['parenrightex'] = 0xF8F7;
  16544. t['parenrightinferior'] = 0x208E;
  16545. t['parenrightmonospace'] = 0xFF09;
  16546. t['parenrightsmall'] = 0xFE5A;
  16547. t['parenrightsuperior'] = 0x207E;
  16548. t['parenrighttp'] = 0xF8F6;
  16549. t['parenrightvertical'] = 0xFE36;
  16550. t['partialdiff'] = 0x2202;
  16551. t['paseqhebrew'] = 0x05C0;
  16552. t['pashtahebrew'] = 0x0599;
  16553. t['pasquare'] = 0x33A9;
  16554. t['patah'] = 0x05B7;
  16555. t['patah11'] = 0x05B7;
  16556. t['patah1d'] = 0x05B7;
  16557. t['patah2a'] = 0x05B7;
  16558. t['patahhebrew'] = 0x05B7;
  16559. t['patahnarrowhebrew'] = 0x05B7;
  16560. t['patahquarterhebrew'] = 0x05B7;
  16561. t['patahwidehebrew'] = 0x05B7;
  16562. t['pazerhebrew'] = 0x05A1;
  16563. t['pbopomofo'] = 0x3106;
  16564. t['pcircle'] = 0x24DF;
  16565. t['pdotaccent'] = 0x1E57;
  16566. t['pe'] = 0x05E4;
  16567. t['pecyrillic'] = 0x043F;
  16568. t['pedagesh'] = 0xFB44;
  16569. t['pedageshhebrew'] = 0xFB44;
  16570. t['peezisquare'] = 0x333B;
  16571. t['pefinaldageshhebrew'] = 0xFB43;
  16572. t['peharabic'] = 0x067E;
  16573. t['peharmenian'] = 0x057A;
  16574. t['pehebrew'] = 0x05E4;
  16575. t['pehfinalarabic'] = 0xFB57;
  16576. t['pehinitialarabic'] = 0xFB58;
  16577. t['pehiragana'] = 0x307A;
  16578. t['pehmedialarabic'] = 0xFB59;
  16579. t['pekatakana'] = 0x30DA;
  16580. t['pemiddlehookcyrillic'] = 0x04A7;
  16581. t['perafehebrew'] = 0xFB4E;
  16582. t['percent'] = 0x0025;
  16583. t['percentarabic'] = 0x066A;
  16584. t['percentmonospace'] = 0xFF05;
  16585. t['percentsmall'] = 0xFE6A;
  16586. t['period'] = 0x002E;
  16587. t['periodarmenian'] = 0x0589;
  16588. t['periodcentered'] = 0x00B7;
  16589. t['periodhalfwidth'] = 0xFF61;
  16590. t['periodinferior'] = 0xF6E7;
  16591. t['periodmonospace'] = 0xFF0E;
  16592. t['periodsmall'] = 0xFE52;
  16593. t['periodsuperior'] = 0xF6E8;
  16594. t['perispomenigreekcmb'] = 0x0342;
  16595. t['perpendicular'] = 0x22A5;
  16596. t['perthousand'] = 0x2030;
  16597. t['peseta'] = 0x20A7;
  16598. t['pfsquare'] = 0x338A;
  16599. t['phabengali'] = 0x09AB;
  16600. t['phadeva'] = 0x092B;
  16601. t['phagujarati'] = 0x0AAB;
  16602. t['phagurmukhi'] = 0x0A2B;
  16603. t['phi'] = 0x03C6;
  16604. t['phi1'] = 0x03D5;
  16605. t['phieuphacirclekorean'] = 0x327A;
  16606. t['phieuphaparenkorean'] = 0x321A;
  16607. t['phieuphcirclekorean'] = 0x326C;
  16608. t['phieuphkorean'] = 0x314D;
  16609. t['phieuphparenkorean'] = 0x320C;
  16610. t['philatin'] = 0x0278;
  16611. t['phinthuthai'] = 0x0E3A;
  16612. t['phisymbolgreek'] = 0x03D5;
  16613. t['phook'] = 0x01A5;
  16614. t['phophanthai'] = 0x0E1E;
  16615. t['phophungthai'] = 0x0E1C;
  16616. t['phosamphaothai'] = 0x0E20;
  16617. t['pi'] = 0x03C0;
  16618. t['pieupacirclekorean'] = 0x3273;
  16619. t['pieupaparenkorean'] = 0x3213;
  16620. t['pieupcieuckorean'] = 0x3176;
  16621. t['pieupcirclekorean'] = 0x3265;
  16622. t['pieupkiyeokkorean'] = 0x3172;
  16623. t['pieupkorean'] = 0x3142;
  16624. t['pieupparenkorean'] = 0x3205;
  16625. t['pieupsioskiyeokkorean'] = 0x3174;
  16626. t['pieupsioskorean'] = 0x3144;
  16627. t['pieupsiostikeutkorean'] = 0x3175;
  16628. t['pieupthieuthkorean'] = 0x3177;
  16629. t['pieuptikeutkorean'] = 0x3173;
  16630. t['pihiragana'] = 0x3074;
  16631. t['pikatakana'] = 0x30D4;
  16632. t['pisymbolgreek'] = 0x03D6;
  16633. t['piwrarmenian'] = 0x0583;
  16634. t['plus'] = 0x002B;
  16635. t['plusbelowcmb'] = 0x031F;
  16636. t['pluscircle'] = 0x2295;
  16637. t['plusminus'] = 0x00B1;
  16638. t['plusmod'] = 0x02D6;
  16639. t['plusmonospace'] = 0xFF0B;
  16640. t['plussmall'] = 0xFE62;
  16641. t['plussuperior'] = 0x207A;
  16642. t['pmonospace'] = 0xFF50;
  16643. t['pmsquare'] = 0x33D8;
  16644. t['pohiragana'] = 0x307D;
  16645. t['pointingindexdownwhite'] = 0x261F;
  16646. t['pointingindexleftwhite'] = 0x261C;
  16647. t['pointingindexrightwhite'] = 0x261E;
  16648. t['pointingindexupwhite'] = 0x261D;
  16649. t['pokatakana'] = 0x30DD;
  16650. t['poplathai'] = 0x0E1B;
  16651. t['postalmark'] = 0x3012;
  16652. t['postalmarkface'] = 0x3020;
  16653. t['pparen'] = 0x24AB;
  16654. t['precedes'] = 0x227A;
  16655. t['prescription'] = 0x211E;
  16656. t['primemod'] = 0x02B9;
  16657. t['primereversed'] = 0x2035;
  16658. t['product'] = 0x220F;
  16659. t['projective'] = 0x2305;
  16660. t['prolongedkana'] = 0x30FC;
  16661. t['propellor'] = 0x2318;
  16662. t['propersubset'] = 0x2282;
  16663. t['propersuperset'] = 0x2283;
  16664. t['proportion'] = 0x2237;
  16665. t['proportional'] = 0x221D;
  16666. t['psi'] = 0x03C8;
  16667. t['psicyrillic'] = 0x0471;
  16668. t['psilipneumatacyrilliccmb'] = 0x0486;
  16669. t['pssquare'] = 0x33B0;
  16670. t['puhiragana'] = 0x3077;
  16671. t['pukatakana'] = 0x30D7;
  16672. t['pvsquare'] = 0x33B4;
  16673. t['pwsquare'] = 0x33BA;
  16674. t['q'] = 0x0071;
  16675. t['qadeva'] = 0x0958;
  16676. t['qadmahebrew'] = 0x05A8;
  16677. t['qafarabic'] = 0x0642;
  16678. t['qaffinalarabic'] = 0xFED6;
  16679. t['qafinitialarabic'] = 0xFED7;
  16680. t['qafmedialarabic'] = 0xFED8;
  16681. t['qamats'] = 0x05B8;
  16682. t['qamats10'] = 0x05B8;
  16683. t['qamats1a'] = 0x05B8;
  16684. t['qamats1c'] = 0x05B8;
  16685. t['qamats27'] = 0x05B8;
  16686. t['qamats29'] = 0x05B8;
  16687. t['qamats33'] = 0x05B8;
  16688. t['qamatsde'] = 0x05B8;
  16689. t['qamatshebrew'] = 0x05B8;
  16690. t['qamatsnarrowhebrew'] = 0x05B8;
  16691. t['qamatsqatanhebrew'] = 0x05B8;
  16692. t['qamatsqatannarrowhebrew'] = 0x05B8;
  16693. t['qamatsqatanquarterhebrew'] = 0x05B8;
  16694. t['qamatsqatanwidehebrew'] = 0x05B8;
  16695. t['qamatsquarterhebrew'] = 0x05B8;
  16696. t['qamatswidehebrew'] = 0x05B8;
  16697. t['qarneyparahebrew'] = 0x059F;
  16698. t['qbopomofo'] = 0x3111;
  16699. t['qcircle'] = 0x24E0;
  16700. t['qhook'] = 0x02A0;
  16701. t['qmonospace'] = 0xFF51;
  16702. t['qof'] = 0x05E7;
  16703. t['qofdagesh'] = 0xFB47;
  16704. t['qofdageshhebrew'] = 0xFB47;
  16705. t['qofhebrew'] = 0x05E7;
  16706. t['qparen'] = 0x24AC;
  16707. t['quarternote'] = 0x2669;
  16708. t['qubuts'] = 0x05BB;
  16709. t['qubuts18'] = 0x05BB;
  16710. t['qubuts25'] = 0x05BB;
  16711. t['qubuts31'] = 0x05BB;
  16712. t['qubutshebrew'] = 0x05BB;
  16713. t['qubutsnarrowhebrew'] = 0x05BB;
  16714. t['qubutsquarterhebrew'] = 0x05BB;
  16715. t['qubutswidehebrew'] = 0x05BB;
  16716. t['question'] = 0x003F;
  16717. t['questionarabic'] = 0x061F;
  16718. t['questionarmenian'] = 0x055E;
  16719. t['questiondown'] = 0x00BF;
  16720. t['questiondownsmall'] = 0xF7BF;
  16721. t['questiongreek'] = 0x037E;
  16722. t['questionmonospace'] = 0xFF1F;
  16723. t['questionsmall'] = 0xF73F;
  16724. t['quotedbl'] = 0x0022;
  16725. t['quotedblbase'] = 0x201E;
  16726. t['quotedblleft'] = 0x201C;
  16727. t['quotedblmonospace'] = 0xFF02;
  16728. t['quotedblprime'] = 0x301E;
  16729. t['quotedblprimereversed'] = 0x301D;
  16730. t['quotedblright'] = 0x201D;
  16731. t['quoteleft'] = 0x2018;
  16732. t['quoteleftreversed'] = 0x201B;
  16733. t['quotereversed'] = 0x201B;
  16734. t['quoteright'] = 0x2019;
  16735. t['quoterightn'] = 0x0149;
  16736. t['quotesinglbase'] = 0x201A;
  16737. t['quotesingle'] = 0x0027;
  16738. t['quotesinglemonospace'] = 0xFF07;
  16739. t['r'] = 0x0072;
  16740. t['raarmenian'] = 0x057C;
  16741. t['rabengali'] = 0x09B0;
  16742. t['racute'] = 0x0155;
  16743. t['radeva'] = 0x0930;
  16744. t['radical'] = 0x221A;
  16745. t['radicalex'] = 0xF8E5;
  16746. t['radoverssquare'] = 0x33AE;
  16747. t['radoverssquaredsquare'] = 0x33AF;
  16748. t['radsquare'] = 0x33AD;
  16749. t['rafe'] = 0x05BF;
  16750. t['rafehebrew'] = 0x05BF;
  16751. t['ragujarati'] = 0x0AB0;
  16752. t['ragurmukhi'] = 0x0A30;
  16753. t['rahiragana'] = 0x3089;
  16754. t['rakatakana'] = 0x30E9;
  16755. t['rakatakanahalfwidth'] = 0xFF97;
  16756. t['ralowerdiagonalbengali'] = 0x09F1;
  16757. t['ramiddlediagonalbengali'] = 0x09F0;
  16758. t['ramshorn'] = 0x0264;
  16759. t['ratio'] = 0x2236;
  16760. t['rbopomofo'] = 0x3116;
  16761. t['rcaron'] = 0x0159;
  16762. t['rcedilla'] = 0x0157;
  16763. t['rcircle'] = 0x24E1;
  16764. t['rcommaaccent'] = 0x0157;
  16765. t['rdblgrave'] = 0x0211;
  16766. t['rdotaccent'] = 0x1E59;
  16767. t['rdotbelow'] = 0x1E5B;
  16768. t['rdotbelowmacron'] = 0x1E5D;
  16769. t['referencemark'] = 0x203B;
  16770. t['reflexsubset'] = 0x2286;
  16771. t['reflexsuperset'] = 0x2287;
  16772. t['registered'] = 0x00AE;
  16773. t['registersans'] = 0xF8E8;
  16774. t['registerserif'] = 0xF6DA;
  16775. t['reharabic'] = 0x0631;
  16776. t['reharmenian'] = 0x0580;
  16777. t['rehfinalarabic'] = 0xFEAE;
  16778. t['rehiragana'] = 0x308C;
  16779. t['rekatakana'] = 0x30EC;
  16780. t['rekatakanahalfwidth'] = 0xFF9A;
  16781. t['resh'] = 0x05E8;
  16782. t['reshdageshhebrew'] = 0xFB48;
  16783. t['reshhebrew'] = 0x05E8;
  16784. t['reversedtilde'] = 0x223D;
  16785. t['reviahebrew'] = 0x0597;
  16786. t['reviamugrashhebrew'] = 0x0597;
  16787. t['revlogicalnot'] = 0x2310;
  16788. t['rfishhook'] = 0x027E;
  16789. t['rfishhookreversed'] = 0x027F;
  16790. t['rhabengali'] = 0x09DD;
  16791. t['rhadeva'] = 0x095D;
  16792. t['rho'] = 0x03C1;
  16793. t['rhook'] = 0x027D;
  16794. t['rhookturned'] = 0x027B;
  16795. t['rhookturnedsuperior'] = 0x02B5;
  16796. t['rhosymbolgreek'] = 0x03F1;
  16797. t['rhotichookmod'] = 0x02DE;
  16798. t['rieulacirclekorean'] = 0x3271;
  16799. t['rieulaparenkorean'] = 0x3211;
  16800. t['rieulcirclekorean'] = 0x3263;
  16801. t['rieulhieuhkorean'] = 0x3140;
  16802. t['rieulkiyeokkorean'] = 0x313A;
  16803. t['rieulkiyeoksioskorean'] = 0x3169;
  16804. t['rieulkorean'] = 0x3139;
  16805. t['rieulmieumkorean'] = 0x313B;
  16806. t['rieulpansioskorean'] = 0x316C;
  16807. t['rieulparenkorean'] = 0x3203;
  16808. t['rieulphieuphkorean'] = 0x313F;
  16809. t['rieulpieupkorean'] = 0x313C;
  16810. t['rieulpieupsioskorean'] = 0x316B;
  16811. t['rieulsioskorean'] = 0x313D;
  16812. t['rieulthieuthkorean'] = 0x313E;
  16813. t['rieultikeutkorean'] = 0x316A;
  16814. t['rieulyeorinhieuhkorean'] = 0x316D;
  16815. t['rightangle'] = 0x221F;
  16816. t['righttackbelowcmb'] = 0x0319;
  16817. t['righttriangle'] = 0x22BF;
  16818. t['rihiragana'] = 0x308A;
  16819. t['rikatakana'] = 0x30EA;
  16820. t['rikatakanahalfwidth'] = 0xFF98;
  16821. t['ring'] = 0x02DA;
  16822. t['ringbelowcmb'] = 0x0325;
  16823. t['ringcmb'] = 0x030A;
  16824. t['ringhalfleft'] = 0x02BF;
  16825. t['ringhalfleftarmenian'] = 0x0559;
  16826. t['ringhalfleftbelowcmb'] = 0x031C;
  16827. t['ringhalfleftcentered'] = 0x02D3;
  16828. t['ringhalfright'] = 0x02BE;
  16829. t['ringhalfrightbelowcmb'] = 0x0339;
  16830. t['ringhalfrightcentered'] = 0x02D2;
  16831. t['rinvertedbreve'] = 0x0213;
  16832. t['rittorusquare'] = 0x3351;
  16833. t['rlinebelow'] = 0x1E5F;
  16834. t['rlongleg'] = 0x027C;
  16835. t['rlonglegturned'] = 0x027A;
  16836. t['rmonospace'] = 0xFF52;
  16837. t['rohiragana'] = 0x308D;
  16838. t['rokatakana'] = 0x30ED;
  16839. t['rokatakanahalfwidth'] = 0xFF9B;
  16840. t['roruathai'] = 0x0E23;
  16841. t['rparen'] = 0x24AD;
  16842. t['rrabengali'] = 0x09DC;
  16843. t['rradeva'] = 0x0931;
  16844. t['rragurmukhi'] = 0x0A5C;
  16845. t['rreharabic'] = 0x0691;
  16846. t['rrehfinalarabic'] = 0xFB8D;
  16847. t['rrvocalicbengali'] = 0x09E0;
  16848. t['rrvocalicdeva'] = 0x0960;
  16849. t['rrvocalicgujarati'] = 0x0AE0;
  16850. t['rrvocalicvowelsignbengali'] = 0x09C4;
  16851. t['rrvocalicvowelsigndeva'] = 0x0944;
  16852. t['rrvocalicvowelsigngujarati'] = 0x0AC4;
  16853. t['rsuperior'] = 0xF6F1;
  16854. t['rtblock'] = 0x2590;
  16855. t['rturned'] = 0x0279;
  16856. t['rturnedsuperior'] = 0x02B4;
  16857. t['ruhiragana'] = 0x308B;
  16858. t['rukatakana'] = 0x30EB;
  16859. t['rukatakanahalfwidth'] = 0xFF99;
  16860. t['rupeemarkbengali'] = 0x09F2;
  16861. t['rupeesignbengali'] = 0x09F3;
  16862. t['rupiah'] = 0xF6DD;
  16863. t['ruthai'] = 0x0E24;
  16864. t['rvocalicbengali'] = 0x098B;
  16865. t['rvocalicdeva'] = 0x090B;
  16866. t['rvocalicgujarati'] = 0x0A8B;
  16867. t['rvocalicvowelsignbengali'] = 0x09C3;
  16868. t['rvocalicvowelsigndeva'] = 0x0943;
  16869. t['rvocalicvowelsigngujarati'] = 0x0AC3;
  16870. t['s'] = 0x0073;
  16871. t['sabengali'] = 0x09B8;
  16872. t['sacute'] = 0x015B;
  16873. t['sacutedotaccent'] = 0x1E65;
  16874. t['sadarabic'] = 0x0635;
  16875. t['sadeva'] = 0x0938;
  16876. t['sadfinalarabic'] = 0xFEBA;
  16877. t['sadinitialarabic'] = 0xFEBB;
  16878. t['sadmedialarabic'] = 0xFEBC;
  16879. t['sagujarati'] = 0x0AB8;
  16880. t['sagurmukhi'] = 0x0A38;
  16881. t['sahiragana'] = 0x3055;
  16882. t['sakatakana'] = 0x30B5;
  16883. t['sakatakanahalfwidth'] = 0xFF7B;
  16884. t['sallallahoualayhewasallamarabic'] = 0xFDFA;
  16885. t['samekh'] = 0x05E1;
  16886. t['samekhdagesh'] = 0xFB41;
  16887. t['samekhdageshhebrew'] = 0xFB41;
  16888. t['samekhhebrew'] = 0x05E1;
  16889. t['saraaathai'] = 0x0E32;
  16890. t['saraaethai'] = 0x0E41;
  16891. t['saraaimaimalaithai'] = 0x0E44;
  16892. t['saraaimaimuanthai'] = 0x0E43;
  16893. t['saraamthai'] = 0x0E33;
  16894. t['saraathai'] = 0x0E30;
  16895. t['saraethai'] = 0x0E40;
  16896. t['saraiileftthai'] = 0xF886;
  16897. t['saraiithai'] = 0x0E35;
  16898. t['saraileftthai'] = 0xF885;
  16899. t['saraithai'] = 0x0E34;
  16900. t['saraothai'] = 0x0E42;
  16901. t['saraueeleftthai'] = 0xF888;
  16902. t['saraueethai'] = 0x0E37;
  16903. t['saraueleftthai'] = 0xF887;
  16904. t['sarauethai'] = 0x0E36;
  16905. t['sarauthai'] = 0x0E38;
  16906. t['sarauuthai'] = 0x0E39;
  16907. t['sbopomofo'] = 0x3119;
  16908. t['scaron'] = 0x0161;
  16909. t['scarondotaccent'] = 0x1E67;
  16910. t['scedilla'] = 0x015F;
  16911. t['schwa'] = 0x0259;
  16912. t['schwacyrillic'] = 0x04D9;
  16913. t['schwadieresiscyrillic'] = 0x04DB;
  16914. t['schwahook'] = 0x025A;
  16915. t['scircle'] = 0x24E2;
  16916. t['scircumflex'] = 0x015D;
  16917. t['scommaaccent'] = 0x0219;
  16918. t['sdotaccent'] = 0x1E61;
  16919. t['sdotbelow'] = 0x1E63;
  16920. t['sdotbelowdotaccent'] = 0x1E69;
  16921. t['seagullbelowcmb'] = 0x033C;
  16922. t['second'] = 0x2033;
  16923. t['secondtonechinese'] = 0x02CA;
  16924. t['section'] = 0x00A7;
  16925. t['seenarabic'] = 0x0633;
  16926. t['seenfinalarabic'] = 0xFEB2;
  16927. t['seeninitialarabic'] = 0xFEB3;
  16928. t['seenmedialarabic'] = 0xFEB4;
  16929. t['segol'] = 0x05B6;
  16930. t['segol13'] = 0x05B6;
  16931. t['segol1f'] = 0x05B6;
  16932. t['segol2c'] = 0x05B6;
  16933. t['segolhebrew'] = 0x05B6;
  16934. t['segolnarrowhebrew'] = 0x05B6;
  16935. t['segolquarterhebrew'] = 0x05B6;
  16936. t['segoltahebrew'] = 0x0592;
  16937. t['segolwidehebrew'] = 0x05B6;
  16938. t['seharmenian'] = 0x057D;
  16939. t['sehiragana'] = 0x305B;
  16940. t['sekatakana'] = 0x30BB;
  16941. t['sekatakanahalfwidth'] = 0xFF7E;
  16942. t['semicolon'] = 0x003B;
  16943. t['semicolonarabic'] = 0x061B;
  16944. t['semicolonmonospace'] = 0xFF1B;
  16945. t['semicolonsmall'] = 0xFE54;
  16946. t['semivoicedmarkkana'] = 0x309C;
  16947. t['semivoicedmarkkanahalfwidth'] = 0xFF9F;
  16948. t['sentisquare'] = 0x3322;
  16949. t['sentosquare'] = 0x3323;
  16950. t['seven'] = 0x0037;
  16951. t['sevenarabic'] = 0x0667;
  16952. t['sevenbengali'] = 0x09ED;
  16953. t['sevencircle'] = 0x2466;
  16954. t['sevencircleinversesansserif'] = 0x2790;
  16955. t['sevendeva'] = 0x096D;
  16956. t['seveneighths'] = 0x215E;
  16957. t['sevengujarati'] = 0x0AED;
  16958. t['sevengurmukhi'] = 0x0A6D;
  16959. t['sevenhackarabic'] = 0x0667;
  16960. t['sevenhangzhou'] = 0x3027;
  16961. t['sevenideographicparen'] = 0x3226;
  16962. t['seveninferior'] = 0x2087;
  16963. t['sevenmonospace'] = 0xFF17;
  16964. t['sevenoldstyle'] = 0xF737;
  16965. t['sevenparen'] = 0x247A;
  16966. t['sevenperiod'] = 0x248E;
  16967. t['sevenpersian'] = 0x06F7;
  16968. t['sevenroman'] = 0x2176;
  16969. t['sevensuperior'] = 0x2077;
  16970. t['seventeencircle'] = 0x2470;
  16971. t['seventeenparen'] = 0x2484;
  16972. t['seventeenperiod'] = 0x2498;
  16973. t['seventhai'] = 0x0E57;
  16974. t['sfthyphen'] = 0x00AD;
  16975. t['shaarmenian'] = 0x0577;
  16976. t['shabengali'] = 0x09B6;
  16977. t['shacyrillic'] = 0x0448;
  16978. t['shaddaarabic'] = 0x0651;
  16979. t['shaddadammaarabic'] = 0xFC61;
  16980. t['shaddadammatanarabic'] = 0xFC5E;
  16981. t['shaddafathaarabic'] = 0xFC60;
  16982. t['shaddakasraarabic'] = 0xFC62;
  16983. t['shaddakasratanarabic'] = 0xFC5F;
  16984. t['shade'] = 0x2592;
  16985. t['shadedark'] = 0x2593;
  16986. t['shadelight'] = 0x2591;
  16987. t['shademedium'] = 0x2592;
  16988. t['shadeva'] = 0x0936;
  16989. t['shagujarati'] = 0x0AB6;
  16990. t['shagurmukhi'] = 0x0A36;
  16991. t['shalshelethebrew'] = 0x0593;
  16992. t['shbopomofo'] = 0x3115;
  16993. t['shchacyrillic'] = 0x0449;
  16994. t['sheenarabic'] = 0x0634;
  16995. t['sheenfinalarabic'] = 0xFEB6;
  16996. t['sheeninitialarabic'] = 0xFEB7;
  16997. t['sheenmedialarabic'] = 0xFEB8;
  16998. t['sheicoptic'] = 0x03E3;
  16999. t['sheqel'] = 0x20AA;
  17000. t['sheqelhebrew'] = 0x20AA;
  17001. t['sheva'] = 0x05B0;
  17002. t['sheva115'] = 0x05B0;
  17003. t['sheva15'] = 0x05B0;
  17004. t['sheva22'] = 0x05B0;
  17005. t['sheva2e'] = 0x05B0;
  17006. t['shevahebrew'] = 0x05B0;
  17007. t['shevanarrowhebrew'] = 0x05B0;
  17008. t['shevaquarterhebrew'] = 0x05B0;
  17009. t['shevawidehebrew'] = 0x05B0;
  17010. t['shhacyrillic'] = 0x04BB;
  17011. t['shimacoptic'] = 0x03ED;
  17012. t['shin'] = 0x05E9;
  17013. t['shindagesh'] = 0xFB49;
  17014. t['shindageshhebrew'] = 0xFB49;
  17015. t['shindageshshindot'] = 0xFB2C;
  17016. t['shindageshshindothebrew'] = 0xFB2C;
  17017. t['shindageshsindot'] = 0xFB2D;
  17018. t['shindageshsindothebrew'] = 0xFB2D;
  17019. t['shindothebrew'] = 0x05C1;
  17020. t['shinhebrew'] = 0x05E9;
  17021. t['shinshindot'] = 0xFB2A;
  17022. t['shinshindothebrew'] = 0xFB2A;
  17023. t['shinsindot'] = 0xFB2B;
  17024. t['shinsindothebrew'] = 0xFB2B;
  17025. t['shook'] = 0x0282;
  17026. t['sigma'] = 0x03C3;
  17027. t['sigma1'] = 0x03C2;
  17028. t['sigmafinal'] = 0x03C2;
  17029. t['sigmalunatesymbolgreek'] = 0x03F2;
  17030. t['sihiragana'] = 0x3057;
  17031. t['sikatakana'] = 0x30B7;
  17032. t['sikatakanahalfwidth'] = 0xFF7C;
  17033. t['siluqhebrew'] = 0x05BD;
  17034. t['siluqlefthebrew'] = 0x05BD;
  17035. t['similar'] = 0x223C;
  17036. t['sindothebrew'] = 0x05C2;
  17037. t['siosacirclekorean'] = 0x3274;
  17038. t['siosaparenkorean'] = 0x3214;
  17039. t['sioscieuckorean'] = 0x317E;
  17040. t['sioscirclekorean'] = 0x3266;
  17041. t['sioskiyeokkorean'] = 0x317A;
  17042. t['sioskorean'] = 0x3145;
  17043. t['siosnieunkorean'] = 0x317B;
  17044. t['siosparenkorean'] = 0x3206;
  17045. t['siospieupkorean'] = 0x317D;
  17046. t['siostikeutkorean'] = 0x317C;
  17047. t['six'] = 0x0036;
  17048. t['sixarabic'] = 0x0666;
  17049. t['sixbengali'] = 0x09EC;
  17050. t['sixcircle'] = 0x2465;
  17051. t['sixcircleinversesansserif'] = 0x278F;
  17052. t['sixdeva'] = 0x096C;
  17053. t['sixgujarati'] = 0x0AEC;
  17054. t['sixgurmukhi'] = 0x0A6C;
  17055. t['sixhackarabic'] = 0x0666;
  17056. t['sixhangzhou'] = 0x3026;
  17057. t['sixideographicparen'] = 0x3225;
  17058. t['sixinferior'] = 0x2086;
  17059. t['sixmonospace'] = 0xFF16;
  17060. t['sixoldstyle'] = 0xF736;
  17061. t['sixparen'] = 0x2479;
  17062. t['sixperiod'] = 0x248D;
  17063. t['sixpersian'] = 0x06F6;
  17064. t['sixroman'] = 0x2175;
  17065. t['sixsuperior'] = 0x2076;
  17066. t['sixteencircle'] = 0x246F;
  17067. t['sixteencurrencydenominatorbengali'] = 0x09F9;
  17068. t['sixteenparen'] = 0x2483;
  17069. t['sixteenperiod'] = 0x2497;
  17070. t['sixthai'] = 0x0E56;
  17071. t['slash'] = 0x002F;
  17072. t['slashmonospace'] = 0xFF0F;
  17073. t['slong'] = 0x017F;
  17074. t['slongdotaccent'] = 0x1E9B;
  17075. t['smileface'] = 0x263A;
  17076. t['smonospace'] = 0xFF53;
  17077. t['sofpasuqhebrew'] = 0x05C3;
  17078. t['softhyphen'] = 0x00AD;
  17079. t['softsigncyrillic'] = 0x044C;
  17080. t['sohiragana'] = 0x305D;
  17081. t['sokatakana'] = 0x30BD;
  17082. t['sokatakanahalfwidth'] = 0xFF7F;
  17083. t['soliduslongoverlaycmb'] = 0x0338;
  17084. t['solidusshortoverlaycmb'] = 0x0337;
  17085. t['sorusithai'] = 0x0E29;
  17086. t['sosalathai'] = 0x0E28;
  17087. t['sosothai'] = 0x0E0B;
  17088. t['sosuathai'] = 0x0E2A;
  17089. t['space'] = 0x0020;
  17090. t['spacehackarabic'] = 0x0020;
  17091. t['spade'] = 0x2660;
  17092. t['spadesuitblack'] = 0x2660;
  17093. t['spadesuitwhite'] = 0x2664;
  17094. t['sparen'] = 0x24AE;
  17095. t['squarebelowcmb'] = 0x033B;
  17096. t['squarecc'] = 0x33C4;
  17097. t['squarecm'] = 0x339D;
  17098. t['squarediagonalcrosshatchfill'] = 0x25A9;
  17099. t['squarehorizontalfill'] = 0x25A4;
  17100. t['squarekg'] = 0x338F;
  17101. t['squarekm'] = 0x339E;
  17102. t['squarekmcapital'] = 0x33CE;
  17103. t['squareln'] = 0x33D1;
  17104. t['squarelog'] = 0x33D2;
  17105. t['squaremg'] = 0x338E;
  17106. t['squaremil'] = 0x33D5;
  17107. t['squaremm'] = 0x339C;
  17108. t['squaremsquared'] = 0x33A1;
  17109. t['squareorthogonalcrosshatchfill'] = 0x25A6;
  17110. t['squareupperlefttolowerrightfill'] = 0x25A7;
  17111. t['squareupperrighttolowerleftfill'] = 0x25A8;
  17112. t['squareverticalfill'] = 0x25A5;
  17113. t['squarewhitewithsmallblack'] = 0x25A3;
  17114. t['srsquare'] = 0x33DB;
  17115. t['ssabengali'] = 0x09B7;
  17116. t['ssadeva'] = 0x0937;
  17117. t['ssagujarati'] = 0x0AB7;
  17118. t['ssangcieuckorean'] = 0x3149;
  17119. t['ssanghieuhkorean'] = 0x3185;
  17120. t['ssangieungkorean'] = 0x3180;
  17121. t['ssangkiyeokkorean'] = 0x3132;
  17122. t['ssangnieunkorean'] = 0x3165;
  17123. t['ssangpieupkorean'] = 0x3143;
  17124. t['ssangsioskorean'] = 0x3146;
  17125. t['ssangtikeutkorean'] = 0x3138;
  17126. t['ssuperior'] = 0xF6F2;
  17127. t['sterling'] = 0x00A3;
  17128. t['sterlingmonospace'] = 0xFFE1;
  17129. t['strokelongoverlaycmb'] = 0x0336;
  17130. t['strokeshortoverlaycmb'] = 0x0335;
  17131. t['subset'] = 0x2282;
  17132. t['subsetnotequal'] = 0x228A;
  17133. t['subsetorequal'] = 0x2286;
  17134. t['succeeds'] = 0x227B;
  17135. t['suchthat'] = 0x220B;
  17136. t['suhiragana'] = 0x3059;
  17137. t['sukatakana'] = 0x30B9;
  17138. t['sukatakanahalfwidth'] = 0xFF7D;
  17139. t['sukunarabic'] = 0x0652;
  17140. t['summation'] = 0x2211;
  17141. t['sun'] = 0x263C;
  17142. t['superset'] = 0x2283;
  17143. t['supersetnotequal'] = 0x228B;
  17144. t['supersetorequal'] = 0x2287;
  17145. t['svsquare'] = 0x33DC;
  17146. t['syouwaerasquare'] = 0x337C;
  17147. t['t'] = 0x0074;
  17148. t['tabengali'] = 0x09A4;
  17149. t['tackdown'] = 0x22A4;
  17150. t['tackleft'] = 0x22A3;
  17151. t['tadeva'] = 0x0924;
  17152. t['tagujarati'] = 0x0AA4;
  17153. t['tagurmukhi'] = 0x0A24;
  17154. t['taharabic'] = 0x0637;
  17155. t['tahfinalarabic'] = 0xFEC2;
  17156. t['tahinitialarabic'] = 0xFEC3;
  17157. t['tahiragana'] = 0x305F;
  17158. t['tahmedialarabic'] = 0xFEC4;
  17159. t['taisyouerasquare'] = 0x337D;
  17160. t['takatakana'] = 0x30BF;
  17161. t['takatakanahalfwidth'] = 0xFF80;
  17162. t['tatweelarabic'] = 0x0640;
  17163. t['tau'] = 0x03C4;
  17164. t['tav'] = 0x05EA;
  17165. t['tavdages'] = 0xFB4A;
  17166. t['tavdagesh'] = 0xFB4A;
  17167. t['tavdageshhebrew'] = 0xFB4A;
  17168. t['tavhebrew'] = 0x05EA;
  17169. t['tbar'] = 0x0167;
  17170. t['tbopomofo'] = 0x310A;
  17171. t['tcaron'] = 0x0165;
  17172. t['tccurl'] = 0x02A8;
  17173. t['tcedilla'] = 0x0163;
  17174. t['tcheharabic'] = 0x0686;
  17175. t['tchehfinalarabic'] = 0xFB7B;
  17176. t['tchehinitialarabic'] = 0xFB7C;
  17177. t['tchehmedialarabic'] = 0xFB7D;
  17178. t['tcircle'] = 0x24E3;
  17179. t['tcircumflexbelow'] = 0x1E71;
  17180. t['tcommaaccent'] = 0x0163;
  17181. t['tdieresis'] = 0x1E97;
  17182. t['tdotaccent'] = 0x1E6B;
  17183. t['tdotbelow'] = 0x1E6D;
  17184. t['tecyrillic'] = 0x0442;
  17185. t['tedescendercyrillic'] = 0x04AD;
  17186. t['teharabic'] = 0x062A;
  17187. t['tehfinalarabic'] = 0xFE96;
  17188. t['tehhahinitialarabic'] = 0xFCA2;
  17189. t['tehhahisolatedarabic'] = 0xFC0C;
  17190. t['tehinitialarabic'] = 0xFE97;
  17191. t['tehiragana'] = 0x3066;
  17192. t['tehjeeminitialarabic'] = 0xFCA1;
  17193. t['tehjeemisolatedarabic'] = 0xFC0B;
  17194. t['tehmarbutaarabic'] = 0x0629;
  17195. t['tehmarbutafinalarabic'] = 0xFE94;
  17196. t['tehmedialarabic'] = 0xFE98;
  17197. t['tehmeeminitialarabic'] = 0xFCA4;
  17198. t['tehmeemisolatedarabic'] = 0xFC0E;
  17199. t['tehnoonfinalarabic'] = 0xFC73;
  17200. t['tekatakana'] = 0x30C6;
  17201. t['tekatakanahalfwidth'] = 0xFF83;
  17202. t['telephone'] = 0x2121;
  17203. t['telephoneblack'] = 0x260E;
  17204. t['telishagedolahebrew'] = 0x05A0;
  17205. t['telishaqetanahebrew'] = 0x05A9;
  17206. t['tencircle'] = 0x2469;
  17207. t['tenideographicparen'] = 0x3229;
  17208. t['tenparen'] = 0x247D;
  17209. t['tenperiod'] = 0x2491;
  17210. t['tenroman'] = 0x2179;
  17211. t['tesh'] = 0x02A7;
  17212. t['tet'] = 0x05D8;
  17213. t['tetdagesh'] = 0xFB38;
  17214. t['tetdageshhebrew'] = 0xFB38;
  17215. t['tethebrew'] = 0x05D8;
  17216. t['tetsecyrillic'] = 0x04B5;
  17217. t['tevirhebrew'] = 0x059B;
  17218. t['tevirlefthebrew'] = 0x059B;
  17219. t['thabengali'] = 0x09A5;
  17220. t['thadeva'] = 0x0925;
  17221. t['thagujarati'] = 0x0AA5;
  17222. t['thagurmukhi'] = 0x0A25;
  17223. t['thalarabic'] = 0x0630;
  17224. t['thalfinalarabic'] = 0xFEAC;
  17225. t['thanthakhatlowleftthai'] = 0xF898;
  17226. t['thanthakhatlowrightthai'] = 0xF897;
  17227. t['thanthakhatthai'] = 0x0E4C;
  17228. t['thanthakhatupperleftthai'] = 0xF896;
  17229. t['theharabic'] = 0x062B;
  17230. t['thehfinalarabic'] = 0xFE9A;
  17231. t['thehinitialarabic'] = 0xFE9B;
  17232. t['thehmedialarabic'] = 0xFE9C;
  17233. t['thereexists'] = 0x2203;
  17234. t['therefore'] = 0x2234;
  17235. t['theta'] = 0x03B8;
  17236. t['theta1'] = 0x03D1;
  17237. t['thetasymbolgreek'] = 0x03D1;
  17238. t['thieuthacirclekorean'] = 0x3279;
  17239. t['thieuthaparenkorean'] = 0x3219;
  17240. t['thieuthcirclekorean'] = 0x326B;
  17241. t['thieuthkorean'] = 0x314C;
  17242. t['thieuthparenkorean'] = 0x320B;
  17243. t['thirteencircle'] = 0x246C;
  17244. t['thirteenparen'] = 0x2480;
  17245. t['thirteenperiod'] = 0x2494;
  17246. t['thonangmonthothai'] = 0x0E11;
  17247. t['thook'] = 0x01AD;
  17248. t['thophuthaothai'] = 0x0E12;
  17249. t['thorn'] = 0x00FE;
  17250. t['thothahanthai'] = 0x0E17;
  17251. t['thothanthai'] = 0x0E10;
  17252. t['thothongthai'] = 0x0E18;
  17253. t['thothungthai'] = 0x0E16;
  17254. t['thousandcyrillic'] = 0x0482;
  17255. t['thousandsseparatorarabic'] = 0x066C;
  17256. t['thousandsseparatorpersian'] = 0x066C;
  17257. t['three'] = 0x0033;
  17258. t['threearabic'] = 0x0663;
  17259. t['threebengali'] = 0x09E9;
  17260. t['threecircle'] = 0x2462;
  17261. t['threecircleinversesansserif'] = 0x278C;
  17262. t['threedeva'] = 0x0969;
  17263. t['threeeighths'] = 0x215C;
  17264. t['threegujarati'] = 0x0AE9;
  17265. t['threegurmukhi'] = 0x0A69;
  17266. t['threehackarabic'] = 0x0663;
  17267. t['threehangzhou'] = 0x3023;
  17268. t['threeideographicparen'] = 0x3222;
  17269. t['threeinferior'] = 0x2083;
  17270. t['threemonospace'] = 0xFF13;
  17271. t['threenumeratorbengali'] = 0x09F6;
  17272. t['threeoldstyle'] = 0xF733;
  17273. t['threeparen'] = 0x2476;
  17274. t['threeperiod'] = 0x248A;
  17275. t['threepersian'] = 0x06F3;
  17276. t['threequarters'] = 0x00BE;
  17277. t['threequartersemdash'] = 0xF6DE;
  17278. t['threeroman'] = 0x2172;
  17279. t['threesuperior'] = 0x00B3;
  17280. t['threethai'] = 0x0E53;
  17281. t['thzsquare'] = 0x3394;
  17282. t['tihiragana'] = 0x3061;
  17283. t['tikatakana'] = 0x30C1;
  17284. t['tikatakanahalfwidth'] = 0xFF81;
  17285. t['tikeutacirclekorean'] = 0x3270;
  17286. t['tikeutaparenkorean'] = 0x3210;
  17287. t['tikeutcirclekorean'] = 0x3262;
  17288. t['tikeutkorean'] = 0x3137;
  17289. t['tikeutparenkorean'] = 0x3202;
  17290. t['tilde'] = 0x02DC;
  17291. t['tildebelowcmb'] = 0x0330;
  17292. t['tildecmb'] = 0x0303;
  17293. t['tildecomb'] = 0x0303;
  17294. t['tildedoublecmb'] = 0x0360;
  17295. t['tildeoperator'] = 0x223C;
  17296. t['tildeoverlaycmb'] = 0x0334;
  17297. t['tildeverticalcmb'] = 0x033E;
  17298. t['timescircle'] = 0x2297;
  17299. t['tipehahebrew'] = 0x0596;
  17300. t['tipehalefthebrew'] = 0x0596;
  17301. t['tippigurmukhi'] = 0x0A70;
  17302. t['titlocyrilliccmb'] = 0x0483;
  17303. t['tiwnarmenian'] = 0x057F;
  17304. t['tlinebelow'] = 0x1E6F;
  17305. t['tmonospace'] = 0xFF54;
  17306. t['toarmenian'] = 0x0569;
  17307. t['tohiragana'] = 0x3068;
  17308. t['tokatakana'] = 0x30C8;
  17309. t['tokatakanahalfwidth'] = 0xFF84;
  17310. t['tonebarextrahighmod'] = 0x02E5;
  17311. t['tonebarextralowmod'] = 0x02E9;
  17312. t['tonebarhighmod'] = 0x02E6;
  17313. t['tonebarlowmod'] = 0x02E8;
  17314. t['tonebarmidmod'] = 0x02E7;
  17315. t['tonefive'] = 0x01BD;
  17316. t['tonesix'] = 0x0185;
  17317. t['tonetwo'] = 0x01A8;
  17318. t['tonos'] = 0x0384;
  17319. t['tonsquare'] = 0x3327;
  17320. t['topatakthai'] = 0x0E0F;
  17321. t['tortoiseshellbracketleft'] = 0x3014;
  17322. t['tortoiseshellbracketleftsmall'] = 0xFE5D;
  17323. t['tortoiseshellbracketleftvertical'] = 0xFE39;
  17324. t['tortoiseshellbracketright'] = 0x3015;
  17325. t['tortoiseshellbracketrightsmall'] = 0xFE5E;
  17326. t['tortoiseshellbracketrightvertical'] = 0xFE3A;
  17327. t['totaothai'] = 0x0E15;
  17328. t['tpalatalhook'] = 0x01AB;
  17329. t['tparen'] = 0x24AF;
  17330. t['trademark'] = 0x2122;
  17331. t['trademarksans'] = 0xF8EA;
  17332. t['trademarkserif'] = 0xF6DB;
  17333. t['tretroflexhook'] = 0x0288;
  17334. t['triagdn'] = 0x25BC;
  17335. t['triaglf'] = 0x25C4;
  17336. t['triagrt'] = 0x25BA;
  17337. t['triagup'] = 0x25B2;
  17338. t['ts'] = 0x02A6;
  17339. t['tsadi'] = 0x05E6;
  17340. t['tsadidagesh'] = 0xFB46;
  17341. t['tsadidageshhebrew'] = 0xFB46;
  17342. t['tsadihebrew'] = 0x05E6;
  17343. t['tsecyrillic'] = 0x0446;
  17344. t['tsere'] = 0x05B5;
  17345. t['tsere12'] = 0x05B5;
  17346. t['tsere1e'] = 0x05B5;
  17347. t['tsere2b'] = 0x05B5;
  17348. t['tserehebrew'] = 0x05B5;
  17349. t['tserenarrowhebrew'] = 0x05B5;
  17350. t['tserequarterhebrew'] = 0x05B5;
  17351. t['tserewidehebrew'] = 0x05B5;
  17352. t['tshecyrillic'] = 0x045B;
  17353. t['tsuperior'] = 0xF6F3;
  17354. t['ttabengali'] = 0x099F;
  17355. t['ttadeva'] = 0x091F;
  17356. t['ttagujarati'] = 0x0A9F;
  17357. t['ttagurmukhi'] = 0x0A1F;
  17358. t['tteharabic'] = 0x0679;
  17359. t['ttehfinalarabic'] = 0xFB67;
  17360. t['ttehinitialarabic'] = 0xFB68;
  17361. t['ttehmedialarabic'] = 0xFB69;
  17362. t['tthabengali'] = 0x09A0;
  17363. t['tthadeva'] = 0x0920;
  17364. t['tthagujarati'] = 0x0AA0;
  17365. t['tthagurmukhi'] = 0x0A20;
  17366. t['tturned'] = 0x0287;
  17367. t['tuhiragana'] = 0x3064;
  17368. t['tukatakana'] = 0x30C4;
  17369. t['tukatakanahalfwidth'] = 0xFF82;
  17370. t['tusmallhiragana'] = 0x3063;
  17371. t['tusmallkatakana'] = 0x30C3;
  17372. t['tusmallkatakanahalfwidth'] = 0xFF6F;
  17373. t['twelvecircle'] = 0x246B;
  17374. t['twelveparen'] = 0x247F;
  17375. t['twelveperiod'] = 0x2493;
  17376. t['twelveroman'] = 0x217B;
  17377. t['twentycircle'] = 0x2473;
  17378. t['twentyhangzhou'] = 0x5344;
  17379. t['twentyparen'] = 0x2487;
  17380. t['twentyperiod'] = 0x249B;
  17381. t['two'] = 0x0032;
  17382. t['twoarabic'] = 0x0662;
  17383. t['twobengali'] = 0x09E8;
  17384. t['twocircle'] = 0x2461;
  17385. t['twocircleinversesansserif'] = 0x278B;
  17386. t['twodeva'] = 0x0968;
  17387. t['twodotenleader'] = 0x2025;
  17388. t['twodotleader'] = 0x2025;
  17389. t['twodotleadervertical'] = 0xFE30;
  17390. t['twogujarati'] = 0x0AE8;
  17391. t['twogurmukhi'] = 0x0A68;
  17392. t['twohackarabic'] = 0x0662;
  17393. t['twohangzhou'] = 0x3022;
  17394. t['twoideographicparen'] = 0x3221;
  17395. t['twoinferior'] = 0x2082;
  17396. t['twomonospace'] = 0xFF12;
  17397. t['twonumeratorbengali'] = 0x09F5;
  17398. t['twooldstyle'] = 0xF732;
  17399. t['twoparen'] = 0x2475;
  17400. t['twoperiod'] = 0x2489;
  17401. t['twopersian'] = 0x06F2;
  17402. t['tworoman'] = 0x2171;
  17403. t['twostroke'] = 0x01BB;
  17404. t['twosuperior'] = 0x00B2;
  17405. t['twothai'] = 0x0E52;
  17406. t['twothirds'] = 0x2154;
  17407. t['u'] = 0x0075;
  17408. t['uacute'] = 0x00FA;
  17409. t['ubar'] = 0x0289;
  17410. t['ubengali'] = 0x0989;
  17411. t['ubopomofo'] = 0x3128;
  17412. t['ubreve'] = 0x016D;
  17413. t['ucaron'] = 0x01D4;
  17414. t['ucircle'] = 0x24E4;
  17415. t['ucircumflex'] = 0x00FB;
  17416. t['ucircumflexbelow'] = 0x1E77;
  17417. t['ucyrillic'] = 0x0443;
  17418. t['udattadeva'] = 0x0951;
  17419. t['udblacute'] = 0x0171;
  17420. t['udblgrave'] = 0x0215;
  17421. t['udeva'] = 0x0909;
  17422. t['udieresis'] = 0x00FC;
  17423. t['udieresisacute'] = 0x01D8;
  17424. t['udieresisbelow'] = 0x1E73;
  17425. t['udieresiscaron'] = 0x01DA;
  17426. t['udieresiscyrillic'] = 0x04F1;
  17427. t['udieresisgrave'] = 0x01DC;
  17428. t['udieresismacron'] = 0x01D6;
  17429. t['udotbelow'] = 0x1EE5;
  17430. t['ugrave'] = 0x00F9;
  17431. t['ugujarati'] = 0x0A89;
  17432. t['ugurmukhi'] = 0x0A09;
  17433. t['uhiragana'] = 0x3046;
  17434. t['uhookabove'] = 0x1EE7;
  17435. t['uhorn'] = 0x01B0;
  17436. t['uhornacute'] = 0x1EE9;
  17437. t['uhorndotbelow'] = 0x1EF1;
  17438. t['uhorngrave'] = 0x1EEB;
  17439. t['uhornhookabove'] = 0x1EED;
  17440. t['uhorntilde'] = 0x1EEF;
  17441. t['uhungarumlaut'] = 0x0171;
  17442. t['uhungarumlautcyrillic'] = 0x04F3;
  17443. t['uinvertedbreve'] = 0x0217;
  17444. t['ukatakana'] = 0x30A6;
  17445. t['ukatakanahalfwidth'] = 0xFF73;
  17446. t['ukcyrillic'] = 0x0479;
  17447. t['ukorean'] = 0x315C;
  17448. t['umacron'] = 0x016B;
  17449. t['umacroncyrillic'] = 0x04EF;
  17450. t['umacrondieresis'] = 0x1E7B;
  17451. t['umatragurmukhi'] = 0x0A41;
  17452. t['umonospace'] = 0xFF55;
  17453. t['underscore'] = 0x005F;
  17454. t['underscoredbl'] = 0x2017;
  17455. t['underscoremonospace'] = 0xFF3F;
  17456. t['underscorevertical'] = 0xFE33;
  17457. t['underscorewavy'] = 0xFE4F;
  17458. t['union'] = 0x222A;
  17459. t['universal'] = 0x2200;
  17460. t['uogonek'] = 0x0173;
  17461. t['uparen'] = 0x24B0;
  17462. t['upblock'] = 0x2580;
  17463. t['upperdothebrew'] = 0x05C4;
  17464. t['upsilon'] = 0x03C5;
  17465. t['upsilondieresis'] = 0x03CB;
  17466. t['upsilondieresistonos'] = 0x03B0;
  17467. t['upsilonlatin'] = 0x028A;
  17468. t['upsilontonos'] = 0x03CD;
  17469. t['uptackbelowcmb'] = 0x031D;
  17470. t['uptackmod'] = 0x02D4;
  17471. t['uragurmukhi'] = 0x0A73;
  17472. t['uring'] = 0x016F;
  17473. t['ushortcyrillic'] = 0x045E;
  17474. t['usmallhiragana'] = 0x3045;
  17475. t['usmallkatakana'] = 0x30A5;
  17476. t['usmallkatakanahalfwidth'] = 0xFF69;
  17477. t['ustraightcyrillic'] = 0x04AF;
  17478. t['ustraightstrokecyrillic'] = 0x04B1;
  17479. t['utilde'] = 0x0169;
  17480. t['utildeacute'] = 0x1E79;
  17481. t['utildebelow'] = 0x1E75;
  17482. t['uubengali'] = 0x098A;
  17483. t['uudeva'] = 0x090A;
  17484. t['uugujarati'] = 0x0A8A;
  17485. t['uugurmukhi'] = 0x0A0A;
  17486. t['uumatragurmukhi'] = 0x0A42;
  17487. t['uuvowelsignbengali'] = 0x09C2;
  17488. t['uuvowelsigndeva'] = 0x0942;
  17489. t['uuvowelsigngujarati'] = 0x0AC2;
  17490. t['uvowelsignbengali'] = 0x09C1;
  17491. t['uvowelsigndeva'] = 0x0941;
  17492. t['uvowelsigngujarati'] = 0x0AC1;
  17493. t['v'] = 0x0076;
  17494. t['vadeva'] = 0x0935;
  17495. t['vagujarati'] = 0x0AB5;
  17496. t['vagurmukhi'] = 0x0A35;
  17497. t['vakatakana'] = 0x30F7;
  17498. t['vav'] = 0x05D5;
  17499. t['vavdagesh'] = 0xFB35;
  17500. t['vavdagesh65'] = 0xFB35;
  17501. t['vavdageshhebrew'] = 0xFB35;
  17502. t['vavhebrew'] = 0x05D5;
  17503. t['vavholam'] = 0xFB4B;
  17504. t['vavholamhebrew'] = 0xFB4B;
  17505. t['vavvavhebrew'] = 0x05F0;
  17506. t['vavyodhebrew'] = 0x05F1;
  17507. t['vcircle'] = 0x24E5;
  17508. t['vdotbelow'] = 0x1E7F;
  17509. t['vecyrillic'] = 0x0432;
  17510. t['veharabic'] = 0x06A4;
  17511. t['vehfinalarabic'] = 0xFB6B;
  17512. t['vehinitialarabic'] = 0xFB6C;
  17513. t['vehmedialarabic'] = 0xFB6D;
  17514. t['vekatakana'] = 0x30F9;
  17515. t['venus'] = 0x2640;
  17516. t['verticalbar'] = 0x007C;
  17517. t['verticallineabovecmb'] = 0x030D;
  17518. t['verticallinebelowcmb'] = 0x0329;
  17519. t['verticallinelowmod'] = 0x02CC;
  17520. t['verticallinemod'] = 0x02C8;
  17521. t['vewarmenian'] = 0x057E;
  17522. t['vhook'] = 0x028B;
  17523. t['vikatakana'] = 0x30F8;
  17524. t['viramabengali'] = 0x09CD;
  17525. t['viramadeva'] = 0x094D;
  17526. t['viramagujarati'] = 0x0ACD;
  17527. t['visargabengali'] = 0x0983;
  17528. t['visargadeva'] = 0x0903;
  17529. t['visargagujarati'] = 0x0A83;
  17530. t['vmonospace'] = 0xFF56;
  17531. t['voarmenian'] = 0x0578;
  17532. t['voicediterationhiragana'] = 0x309E;
  17533. t['voicediterationkatakana'] = 0x30FE;
  17534. t['voicedmarkkana'] = 0x309B;
  17535. t['voicedmarkkanahalfwidth'] = 0xFF9E;
  17536. t['vokatakana'] = 0x30FA;
  17537. t['vparen'] = 0x24B1;
  17538. t['vtilde'] = 0x1E7D;
  17539. t['vturned'] = 0x028C;
  17540. t['vuhiragana'] = 0x3094;
  17541. t['vukatakana'] = 0x30F4;
  17542. t['w'] = 0x0077;
  17543. t['wacute'] = 0x1E83;
  17544. t['waekorean'] = 0x3159;
  17545. t['wahiragana'] = 0x308F;
  17546. t['wakatakana'] = 0x30EF;
  17547. t['wakatakanahalfwidth'] = 0xFF9C;
  17548. t['wakorean'] = 0x3158;
  17549. t['wasmallhiragana'] = 0x308E;
  17550. t['wasmallkatakana'] = 0x30EE;
  17551. t['wattosquare'] = 0x3357;
  17552. t['wavedash'] = 0x301C;
  17553. t['wavyunderscorevertical'] = 0xFE34;
  17554. t['wawarabic'] = 0x0648;
  17555. t['wawfinalarabic'] = 0xFEEE;
  17556. t['wawhamzaabovearabic'] = 0x0624;
  17557. t['wawhamzaabovefinalarabic'] = 0xFE86;
  17558. t['wbsquare'] = 0x33DD;
  17559. t['wcircle'] = 0x24E6;
  17560. t['wcircumflex'] = 0x0175;
  17561. t['wdieresis'] = 0x1E85;
  17562. t['wdotaccent'] = 0x1E87;
  17563. t['wdotbelow'] = 0x1E89;
  17564. t['wehiragana'] = 0x3091;
  17565. t['weierstrass'] = 0x2118;
  17566. t['wekatakana'] = 0x30F1;
  17567. t['wekorean'] = 0x315E;
  17568. t['weokorean'] = 0x315D;
  17569. t['wgrave'] = 0x1E81;
  17570. t['whitebullet'] = 0x25E6;
  17571. t['whitecircle'] = 0x25CB;
  17572. t['whitecircleinverse'] = 0x25D9;
  17573. t['whitecornerbracketleft'] = 0x300E;
  17574. t['whitecornerbracketleftvertical'] = 0xFE43;
  17575. t['whitecornerbracketright'] = 0x300F;
  17576. t['whitecornerbracketrightvertical'] = 0xFE44;
  17577. t['whitediamond'] = 0x25C7;
  17578. t['whitediamondcontainingblacksmalldiamond'] = 0x25C8;
  17579. t['whitedownpointingsmalltriangle'] = 0x25BF;
  17580. t['whitedownpointingtriangle'] = 0x25BD;
  17581. t['whiteleftpointingsmalltriangle'] = 0x25C3;
  17582. t['whiteleftpointingtriangle'] = 0x25C1;
  17583. t['whitelenticularbracketleft'] = 0x3016;
  17584. t['whitelenticularbracketright'] = 0x3017;
  17585. t['whiterightpointingsmalltriangle'] = 0x25B9;
  17586. t['whiterightpointingtriangle'] = 0x25B7;
  17587. t['whitesmallsquare'] = 0x25AB;
  17588. t['whitesmilingface'] = 0x263A;
  17589. t['whitesquare'] = 0x25A1;
  17590. t['whitestar'] = 0x2606;
  17591. t['whitetelephone'] = 0x260F;
  17592. t['whitetortoiseshellbracketleft'] = 0x3018;
  17593. t['whitetortoiseshellbracketright'] = 0x3019;
  17594. t['whiteuppointingsmalltriangle'] = 0x25B5;
  17595. t['whiteuppointingtriangle'] = 0x25B3;
  17596. t['wihiragana'] = 0x3090;
  17597. t['wikatakana'] = 0x30F0;
  17598. t['wikorean'] = 0x315F;
  17599. t['wmonospace'] = 0xFF57;
  17600. t['wohiragana'] = 0x3092;
  17601. t['wokatakana'] = 0x30F2;
  17602. t['wokatakanahalfwidth'] = 0xFF66;
  17603. t['won'] = 0x20A9;
  17604. t['wonmonospace'] = 0xFFE6;
  17605. t['wowaenthai'] = 0x0E27;
  17606. t['wparen'] = 0x24B2;
  17607. t['wring'] = 0x1E98;
  17608. t['wsuperior'] = 0x02B7;
  17609. t['wturned'] = 0x028D;
  17610. t['wynn'] = 0x01BF;
  17611. t['x'] = 0x0078;
  17612. t['xabovecmb'] = 0x033D;
  17613. t['xbopomofo'] = 0x3112;
  17614. t['xcircle'] = 0x24E7;
  17615. t['xdieresis'] = 0x1E8D;
  17616. t['xdotaccent'] = 0x1E8B;
  17617. t['xeharmenian'] = 0x056D;
  17618. t['xi'] = 0x03BE;
  17619. t['xmonospace'] = 0xFF58;
  17620. t['xparen'] = 0x24B3;
  17621. t['xsuperior'] = 0x02E3;
  17622. t['y'] = 0x0079;
  17623. t['yaadosquare'] = 0x334E;
  17624. t['yabengali'] = 0x09AF;
  17625. t['yacute'] = 0x00FD;
  17626. t['yadeva'] = 0x092F;
  17627. t['yaekorean'] = 0x3152;
  17628. t['yagujarati'] = 0x0AAF;
  17629. t['yagurmukhi'] = 0x0A2F;
  17630. t['yahiragana'] = 0x3084;
  17631. t['yakatakana'] = 0x30E4;
  17632. t['yakatakanahalfwidth'] = 0xFF94;
  17633. t['yakorean'] = 0x3151;
  17634. t['yamakkanthai'] = 0x0E4E;
  17635. t['yasmallhiragana'] = 0x3083;
  17636. t['yasmallkatakana'] = 0x30E3;
  17637. t['yasmallkatakanahalfwidth'] = 0xFF6C;
  17638. t['yatcyrillic'] = 0x0463;
  17639. t['ycircle'] = 0x24E8;
  17640. t['ycircumflex'] = 0x0177;
  17641. t['ydieresis'] = 0x00FF;
  17642. t['ydotaccent'] = 0x1E8F;
  17643. t['ydotbelow'] = 0x1EF5;
  17644. t['yeharabic'] = 0x064A;
  17645. t['yehbarreearabic'] = 0x06D2;
  17646. t['yehbarreefinalarabic'] = 0xFBAF;
  17647. t['yehfinalarabic'] = 0xFEF2;
  17648. t['yehhamzaabovearabic'] = 0x0626;
  17649. t['yehhamzaabovefinalarabic'] = 0xFE8A;
  17650. t['yehhamzaaboveinitialarabic'] = 0xFE8B;
  17651. t['yehhamzaabovemedialarabic'] = 0xFE8C;
  17652. t['yehinitialarabic'] = 0xFEF3;
  17653. t['yehmedialarabic'] = 0xFEF4;
  17654. t['yehmeeminitialarabic'] = 0xFCDD;
  17655. t['yehmeemisolatedarabic'] = 0xFC58;
  17656. t['yehnoonfinalarabic'] = 0xFC94;
  17657. t['yehthreedotsbelowarabic'] = 0x06D1;
  17658. t['yekorean'] = 0x3156;
  17659. t['yen'] = 0x00A5;
  17660. t['yenmonospace'] = 0xFFE5;
  17661. t['yeokorean'] = 0x3155;
  17662. t['yeorinhieuhkorean'] = 0x3186;
  17663. t['yerahbenyomohebrew'] = 0x05AA;
  17664. t['yerahbenyomolefthebrew'] = 0x05AA;
  17665. t['yericyrillic'] = 0x044B;
  17666. t['yerudieresiscyrillic'] = 0x04F9;
  17667. t['yesieungkorean'] = 0x3181;
  17668. t['yesieungpansioskorean'] = 0x3183;
  17669. t['yesieungsioskorean'] = 0x3182;
  17670. t['yetivhebrew'] = 0x059A;
  17671. t['ygrave'] = 0x1EF3;
  17672. t['yhook'] = 0x01B4;
  17673. t['yhookabove'] = 0x1EF7;
  17674. t['yiarmenian'] = 0x0575;
  17675. t['yicyrillic'] = 0x0457;
  17676. t['yikorean'] = 0x3162;
  17677. t['yinyang'] = 0x262F;
  17678. t['yiwnarmenian'] = 0x0582;
  17679. t['ymonospace'] = 0xFF59;
  17680. t['yod'] = 0x05D9;
  17681. t['yoddagesh'] = 0xFB39;
  17682. t['yoddageshhebrew'] = 0xFB39;
  17683. t['yodhebrew'] = 0x05D9;
  17684. t['yodyodhebrew'] = 0x05F2;
  17685. t['yodyodpatahhebrew'] = 0xFB1F;
  17686. t['yohiragana'] = 0x3088;
  17687. t['yoikorean'] = 0x3189;
  17688. t['yokatakana'] = 0x30E8;
  17689. t['yokatakanahalfwidth'] = 0xFF96;
  17690. t['yokorean'] = 0x315B;
  17691. t['yosmallhiragana'] = 0x3087;
  17692. t['yosmallkatakana'] = 0x30E7;
  17693. t['yosmallkatakanahalfwidth'] = 0xFF6E;
  17694. t['yotgreek'] = 0x03F3;
  17695. t['yoyaekorean'] = 0x3188;
  17696. t['yoyakorean'] = 0x3187;
  17697. t['yoyakthai'] = 0x0E22;
  17698. t['yoyingthai'] = 0x0E0D;
  17699. t['yparen'] = 0x24B4;
  17700. t['ypogegrammeni'] = 0x037A;
  17701. t['ypogegrammenigreekcmb'] = 0x0345;
  17702. t['yr'] = 0x01A6;
  17703. t['yring'] = 0x1E99;
  17704. t['ysuperior'] = 0x02B8;
  17705. t['ytilde'] = 0x1EF9;
  17706. t['yturned'] = 0x028E;
  17707. t['yuhiragana'] = 0x3086;
  17708. t['yuikorean'] = 0x318C;
  17709. t['yukatakana'] = 0x30E6;
  17710. t['yukatakanahalfwidth'] = 0xFF95;
  17711. t['yukorean'] = 0x3160;
  17712. t['yusbigcyrillic'] = 0x046B;
  17713. t['yusbigiotifiedcyrillic'] = 0x046D;
  17714. t['yuslittlecyrillic'] = 0x0467;
  17715. t['yuslittleiotifiedcyrillic'] = 0x0469;
  17716. t['yusmallhiragana'] = 0x3085;
  17717. t['yusmallkatakana'] = 0x30E5;
  17718. t['yusmallkatakanahalfwidth'] = 0xFF6D;
  17719. t['yuyekorean'] = 0x318B;
  17720. t['yuyeokorean'] = 0x318A;
  17721. t['yyabengali'] = 0x09DF;
  17722. t['yyadeva'] = 0x095F;
  17723. t['z'] = 0x007A;
  17724. t['zaarmenian'] = 0x0566;
  17725. t['zacute'] = 0x017A;
  17726. t['zadeva'] = 0x095B;
  17727. t['zagurmukhi'] = 0x0A5B;
  17728. t['zaharabic'] = 0x0638;
  17729. t['zahfinalarabic'] = 0xFEC6;
  17730. t['zahinitialarabic'] = 0xFEC7;
  17731. t['zahiragana'] = 0x3056;
  17732. t['zahmedialarabic'] = 0xFEC8;
  17733. t['zainarabic'] = 0x0632;
  17734. t['zainfinalarabic'] = 0xFEB0;
  17735. t['zakatakana'] = 0x30B6;
  17736. t['zaqefgadolhebrew'] = 0x0595;
  17737. t['zaqefqatanhebrew'] = 0x0594;
  17738. t['zarqahebrew'] = 0x0598;
  17739. t['zayin'] = 0x05D6;
  17740. t['zayindagesh'] = 0xFB36;
  17741. t['zayindageshhebrew'] = 0xFB36;
  17742. t['zayinhebrew'] = 0x05D6;
  17743. t['zbopomofo'] = 0x3117;
  17744. t['zcaron'] = 0x017E;
  17745. t['zcircle'] = 0x24E9;
  17746. t['zcircumflex'] = 0x1E91;
  17747. t['zcurl'] = 0x0291;
  17748. t['zdot'] = 0x017C;
  17749. t['zdotaccent'] = 0x017C;
  17750. t['zdotbelow'] = 0x1E93;
  17751. t['zecyrillic'] = 0x0437;
  17752. t['zedescendercyrillic'] = 0x0499;
  17753. t['zedieresiscyrillic'] = 0x04DF;
  17754. t['zehiragana'] = 0x305C;
  17755. t['zekatakana'] = 0x30BC;
  17756. t['zero'] = 0x0030;
  17757. t['zeroarabic'] = 0x0660;
  17758. t['zerobengali'] = 0x09E6;
  17759. t['zerodeva'] = 0x0966;
  17760. t['zerogujarati'] = 0x0AE6;
  17761. t['zerogurmukhi'] = 0x0A66;
  17762. t['zerohackarabic'] = 0x0660;
  17763. t['zeroinferior'] = 0x2080;
  17764. t['zeromonospace'] = 0xFF10;
  17765. t['zerooldstyle'] = 0xF730;
  17766. t['zeropersian'] = 0x06F0;
  17767. t['zerosuperior'] = 0x2070;
  17768. t['zerothai'] = 0x0E50;
  17769. t['zerowidthjoiner'] = 0xFEFF;
  17770. t['zerowidthnonjoiner'] = 0x200C;
  17771. t['zerowidthspace'] = 0x200B;
  17772. t['zeta'] = 0x03B6;
  17773. t['zhbopomofo'] = 0x3113;
  17774. t['zhearmenian'] = 0x056A;
  17775. t['zhebrevecyrillic'] = 0x04C2;
  17776. t['zhecyrillic'] = 0x0436;
  17777. t['zhedescendercyrillic'] = 0x0497;
  17778. t['zhedieresiscyrillic'] = 0x04DD;
  17779. t['zihiragana'] = 0x3058;
  17780. t['zikatakana'] = 0x30B8;
  17781. t['zinorhebrew'] = 0x05AE;
  17782. t['zlinebelow'] = 0x1E95;
  17783. t['zmonospace'] = 0xFF5A;
  17784. t['zohiragana'] = 0x305E;
  17785. t['zokatakana'] = 0x30BE;
  17786. t['zparen'] = 0x24B5;
  17787. t['zretroflexhook'] = 0x0290;
  17788. t['zstroke'] = 0x01B6;
  17789. t['zuhiragana'] = 0x305A;
  17790. t['zukatakana'] = 0x30BA;
  17791. t['.notdef'] = 0x0000;
  17792. t['angbracketleftbig'] = 0x2329;
  17793. t['angbracketleftBig'] = 0x2329;
  17794. t['angbracketleftbigg'] = 0x2329;
  17795. t['angbracketleftBigg'] = 0x2329;
  17796. t['angbracketrightBig'] = 0x232A;
  17797. t['angbracketrightbig'] = 0x232A;
  17798. t['angbracketrightBigg'] = 0x232A;
  17799. t['angbracketrightbigg'] = 0x232A;
  17800. t['arrowhookleft'] = 0x21AA;
  17801. t['arrowhookright'] = 0x21A9;
  17802. t['arrowlefttophalf'] = 0x21BC;
  17803. t['arrowleftbothalf'] = 0x21BD;
  17804. t['arrownortheast'] = 0x2197;
  17805. t['arrownorthwest'] = 0x2196;
  17806. t['arrowrighttophalf'] = 0x21C0;
  17807. t['arrowrightbothalf'] = 0x21C1;
  17808. t['arrowsoutheast'] = 0x2198;
  17809. t['arrowsouthwest'] = 0x2199;
  17810. t['backslashbig'] = 0x2216;
  17811. t['backslashBig'] = 0x2216;
  17812. t['backslashBigg'] = 0x2216;
  17813. t['backslashbigg'] = 0x2216;
  17814. t['bardbl'] = 0x2016;
  17815. t['bracehtipdownleft'] = 0xFE37;
  17816. t['bracehtipdownright'] = 0xFE37;
  17817. t['bracehtipupleft'] = 0xFE38;
  17818. t['bracehtipupright'] = 0xFE38;
  17819. t['braceleftBig'] = 0x007B;
  17820. t['braceleftbig'] = 0x007B;
  17821. t['braceleftbigg'] = 0x007B;
  17822. t['braceleftBigg'] = 0x007B;
  17823. t['bracerightBig'] = 0x007D;
  17824. t['bracerightbig'] = 0x007D;
  17825. t['bracerightbigg'] = 0x007D;
  17826. t['bracerightBigg'] = 0x007D;
  17827. t['bracketleftbig'] = 0x005B;
  17828. t['bracketleftBig'] = 0x005B;
  17829. t['bracketleftbigg'] = 0x005B;
  17830. t['bracketleftBigg'] = 0x005B;
  17831. t['bracketrightBig'] = 0x005D;
  17832. t['bracketrightbig'] = 0x005D;
  17833. t['bracketrightbigg'] = 0x005D;
  17834. t['bracketrightBigg'] = 0x005D;
  17835. t['ceilingleftbig'] = 0x2308;
  17836. t['ceilingleftBig'] = 0x2308;
  17837. t['ceilingleftBigg'] = 0x2308;
  17838. t['ceilingleftbigg'] = 0x2308;
  17839. t['ceilingrightbig'] = 0x2309;
  17840. t['ceilingrightBig'] = 0x2309;
  17841. t['ceilingrightbigg'] = 0x2309;
  17842. t['ceilingrightBigg'] = 0x2309;
  17843. t['circledotdisplay'] = 0x2299;
  17844. t['circledottext'] = 0x2299;
  17845. t['circlemultiplydisplay'] = 0x2297;
  17846. t['circlemultiplytext'] = 0x2297;
  17847. t['circleplusdisplay'] = 0x2295;
  17848. t['circleplustext'] = 0x2295;
  17849. t['contintegraldisplay'] = 0x222E;
  17850. t['contintegraltext'] = 0x222E;
  17851. t['coproductdisplay'] = 0x2210;
  17852. t['coproducttext'] = 0x2210;
  17853. t['floorleftBig'] = 0x230A;
  17854. t['floorleftbig'] = 0x230A;
  17855. t['floorleftbigg'] = 0x230A;
  17856. t['floorleftBigg'] = 0x230A;
  17857. t['floorrightbig'] = 0x230B;
  17858. t['floorrightBig'] = 0x230B;
  17859. t['floorrightBigg'] = 0x230B;
  17860. t['floorrightbigg'] = 0x230B;
  17861. t['hatwide'] = 0x0302;
  17862. t['hatwider'] = 0x0302;
  17863. t['hatwidest'] = 0x0302;
  17864. t['intercal'] = 0x1D40;
  17865. t['integraldisplay'] = 0x222B;
  17866. t['integraltext'] = 0x222B;
  17867. t['intersectiondisplay'] = 0x22C2;
  17868. t['intersectiontext'] = 0x22C2;
  17869. t['logicalanddisplay'] = 0x2227;
  17870. t['logicalandtext'] = 0x2227;
  17871. t['logicalordisplay'] = 0x2228;
  17872. t['logicalortext'] = 0x2228;
  17873. t['parenleftBig'] = 0x0028;
  17874. t['parenleftbig'] = 0x0028;
  17875. t['parenleftBigg'] = 0x0028;
  17876. t['parenleftbigg'] = 0x0028;
  17877. t['parenrightBig'] = 0x0029;
  17878. t['parenrightbig'] = 0x0029;
  17879. t['parenrightBigg'] = 0x0029;
  17880. t['parenrightbigg'] = 0x0029;
  17881. t['prime'] = 0x2032;
  17882. t['productdisplay'] = 0x220F;
  17883. t['producttext'] = 0x220F;
  17884. t['radicalbig'] = 0x221A;
  17885. t['radicalBig'] = 0x221A;
  17886. t['radicalBigg'] = 0x221A;
  17887. t['radicalbigg'] = 0x221A;
  17888. t['radicalbt'] = 0x221A;
  17889. t['radicaltp'] = 0x221A;
  17890. t['radicalvertex'] = 0x221A;
  17891. t['slashbig'] = 0x002F;
  17892. t['slashBig'] = 0x002F;
  17893. t['slashBigg'] = 0x002F;
  17894. t['slashbigg'] = 0x002F;
  17895. t['summationdisplay'] = 0x2211;
  17896. t['summationtext'] = 0x2211;
  17897. t['tildewide'] = 0x02DC;
  17898. t['tildewider'] = 0x02DC;
  17899. t['tildewidest'] = 0x02DC;
  17900. t['uniondisplay'] = 0x22C3;
  17901. t['unionmultidisplay'] = 0x228E;
  17902. t['unionmultitext'] = 0x228E;
  17903. t['unionsqdisplay'] = 0x2294;
  17904. t['unionsqtext'] = 0x2294;
  17905. t['uniontext'] = 0x22C3;
  17906. t['vextenddouble'] = 0x2225;
  17907. t['vextendsingle'] = 0x2223;
  17908. });
  17909. var getDingbatsGlyphsUnicode = getLookupTableFactory(function (t) {
  17910. t['space'] = 0x0020;
  17911. t['a1'] = 0x2701;
  17912. t['a2'] = 0x2702;
  17913. t['a202'] = 0x2703;
  17914. t['a3'] = 0x2704;
  17915. t['a4'] = 0x260E;
  17916. t['a5'] = 0x2706;
  17917. t['a119'] = 0x2707;
  17918. t['a118'] = 0x2708;
  17919. t['a117'] = 0x2709;
  17920. t['a11'] = 0x261B;
  17921. t['a12'] = 0x261E;
  17922. t['a13'] = 0x270C;
  17923. t['a14'] = 0x270D;
  17924. t['a15'] = 0x270E;
  17925. t['a16'] = 0x270F;
  17926. t['a105'] = 0x2710;
  17927. t['a17'] = 0x2711;
  17928. t['a18'] = 0x2712;
  17929. t['a19'] = 0x2713;
  17930. t['a20'] = 0x2714;
  17931. t['a21'] = 0x2715;
  17932. t['a22'] = 0x2716;
  17933. t['a23'] = 0x2717;
  17934. t['a24'] = 0x2718;
  17935. t['a25'] = 0x2719;
  17936. t['a26'] = 0x271A;
  17937. t['a27'] = 0x271B;
  17938. t['a28'] = 0x271C;
  17939. t['a6'] = 0x271D;
  17940. t['a7'] = 0x271E;
  17941. t['a8'] = 0x271F;
  17942. t['a9'] = 0x2720;
  17943. t['a10'] = 0x2721;
  17944. t['a29'] = 0x2722;
  17945. t['a30'] = 0x2723;
  17946. t['a31'] = 0x2724;
  17947. t['a32'] = 0x2725;
  17948. t['a33'] = 0x2726;
  17949. t['a34'] = 0x2727;
  17950. t['a35'] = 0x2605;
  17951. t['a36'] = 0x2729;
  17952. t['a37'] = 0x272A;
  17953. t['a38'] = 0x272B;
  17954. t['a39'] = 0x272C;
  17955. t['a40'] = 0x272D;
  17956. t['a41'] = 0x272E;
  17957. t['a42'] = 0x272F;
  17958. t['a43'] = 0x2730;
  17959. t['a44'] = 0x2731;
  17960. t['a45'] = 0x2732;
  17961. t['a46'] = 0x2733;
  17962. t['a47'] = 0x2734;
  17963. t['a48'] = 0x2735;
  17964. t['a49'] = 0x2736;
  17965. t['a50'] = 0x2737;
  17966. t['a51'] = 0x2738;
  17967. t['a52'] = 0x2739;
  17968. t['a53'] = 0x273A;
  17969. t['a54'] = 0x273B;
  17970. t['a55'] = 0x273C;
  17971. t['a56'] = 0x273D;
  17972. t['a57'] = 0x273E;
  17973. t['a58'] = 0x273F;
  17974. t['a59'] = 0x2740;
  17975. t['a60'] = 0x2741;
  17976. t['a61'] = 0x2742;
  17977. t['a62'] = 0x2743;
  17978. t['a63'] = 0x2744;
  17979. t['a64'] = 0x2745;
  17980. t['a65'] = 0x2746;
  17981. t['a66'] = 0x2747;
  17982. t['a67'] = 0x2748;
  17983. t['a68'] = 0x2749;
  17984. t['a69'] = 0x274A;
  17985. t['a70'] = 0x274B;
  17986. t['a71'] = 0x25CF;
  17987. t['a72'] = 0x274D;
  17988. t['a73'] = 0x25A0;
  17989. t['a74'] = 0x274F;
  17990. t['a203'] = 0x2750;
  17991. t['a75'] = 0x2751;
  17992. t['a204'] = 0x2752;
  17993. t['a76'] = 0x25B2;
  17994. t['a77'] = 0x25BC;
  17995. t['a78'] = 0x25C6;
  17996. t['a79'] = 0x2756;
  17997. t['a81'] = 0x25D7;
  17998. t['a82'] = 0x2758;
  17999. t['a83'] = 0x2759;
  18000. t['a84'] = 0x275A;
  18001. t['a97'] = 0x275B;
  18002. t['a98'] = 0x275C;
  18003. t['a99'] = 0x275D;
  18004. t['a100'] = 0x275E;
  18005. t['a101'] = 0x2761;
  18006. t['a102'] = 0x2762;
  18007. t['a103'] = 0x2763;
  18008. t['a104'] = 0x2764;
  18009. t['a106'] = 0x2765;
  18010. t['a107'] = 0x2766;
  18011. t['a108'] = 0x2767;
  18012. t['a112'] = 0x2663;
  18013. t['a111'] = 0x2666;
  18014. t['a110'] = 0x2665;
  18015. t['a109'] = 0x2660;
  18016. t['a120'] = 0x2460;
  18017. t['a121'] = 0x2461;
  18018. t['a122'] = 0x2462;
  18019. t['a123'] = 0x2463;
  18020. t['a124'] = 0x2464;
  18021. t['a125'] = 0x2465;
  18022. t['a126'] = 0x2466;
  18023. t['a127'] = 0x2467;
  18024. t['a128'] = 0x2468;
  18025. t['a129'] = 0x2469;
  18026. t['a130'] = 0x2776;
  18027. t['a131'] = 0x2777;
  18028. t['a132'] = 0x2778;
  18029. t['a133'] = 0x2779;
  18030. t['a134'] = 0x277A;
  18031. t['a135'] = 0x277B;
  18032. t['a136'] = 0x277C;
  18033. t['a137'] = 0x277D;
  18034. t['a138'] = 0x277E;
  18035. t['a139'] = 0x277F;
  18036. t['a140'] = 0x2780;
  18037. t['a141'] = 0x2781;
  18038. t['a142'] = 0x2782;
  18039. t['a143'] = 0x2783;
  18040. t['a144'] = 0x2784;
  18041. t['a145'] = 0x2785;
  18042. t['a146'] = 0x2786;
  18043. t['a147'] = 0x2787;
  18044. t['a148'] = 0x2788;
  18045. t['a149'] = 0x2789;
  18046. t['a150'] = 0x278A;
  18047. t['a151'] = 0x278B;
  18048. t['a152'] = 0x278C;
  18049. t['a153'] = 0x278D;
  18050. t['a154'] = 0x278E;
  18051. t['a155'] = 0x278F;
  18052. t['a156'] = 0x2790;
  18053. t['a157'] = 0x2791;
  18054. t['a158'] = 0x2792;
  18055. t['a159'] = 0x2793;
  18056. t['a160'] = 0x2794;
  18057. t['a161'] = 0x2192;
  18058. t['a163'] = 0x2194;
  18059. t['a164'] = 0x2195;
  18060. t['a196'] = 0x2798;
  18061. t['a165'] = 0x2799;
  18062. t['a192'] = 0x279A;
  18063. t['a166'] = 0x279B;
  18064. t['a167'] = 0x279C;
  18065. t['a168'] = 0x279D;
  18066. t['a169'] = 0x279E;
  18067. t['a170'] = 0x279F;
  18068. t['a171'] = 0x27A0;
  18069. t['a172'] = 0x27A1;
  18070. t['a173'] = 0x27A2;
  18071. t['a162'] = 0x27A3;
  18072. t['a174'] = 0x27A4;
  18073. t['a175'] = 0x27A5;
  18074. t['a176'] = 0x27A6;
  18075. t['a177'] = 0x27A7;
  18076. t['a178'] = 0x27A8;
  18077. t['a179'] = 0x27A9;
  18078. t['a193'] = 0x27AA;
  18079. t['a180'] = 0x27AB;
  18080. t['a199'] = 0x27AC;
  18081. t['a181'] = 0x27AD;
  18082. t['a200'] = 0x27AE;
  18083. t['a182'] = 0x27AF;
  18084. t['a201'] = 0x27B1;
  18085. t['a183'] = 0x27B2;
  18086. t['a184'] = 0x27B3;
  18087. t['a197'] = 0x27B4;
  18088. t['a185'] = 0x27B5;
  18089. t['a194'] = 0x27B6;
  18090. t['a198'] = 0x27B7;
  18091. t['a186'] = 0x27B8;
  18092. t['a195'] = 0x27B9;
  18093. t['a187'] = 0x27BA;
  18094. t['a188'] = 0x27BB;
  18095. t['a189'] = 0x27BC;
  18096. t['a190'] = 0x27BD;
  18097. t['a191'] = 0x27BE;
  18098. t['a89'] = 0x2768;
  18099. t['a90'] = 0x2769;
  18100. t['a93'] = 0x276A;
  18101. t['a94'] = 0x276B;
  18102. t['a91'] = 0x276C;
  18103. t['a92'] = 0x276D;
  18104. t['a205'] = 0x276E;
  18105. t['a85'] = 0x276F;
  18106. t['a206'] = 0x2770;
  18107. t['a86'] = 0x2771;
  18108. t['a87'] = 0x2772;
  18109. t['a88'] = 0x2773;
  18110. t['a95'] = 0x2774;
  18111. t['a96'] = 0x2775;
  18112. t['.notdef'] = 0x0000;
  18113. });
  18114. exports.getGlyphsUnicode = getGlyphsUnicode;
  18115. exports.getDingbatsGlyphsUnicode = getDingbatsGlyphsUnicode;
  18116. /***/ }),
  18117. /* 9 */
  18118. /***/ (function(module, exports, __w_pdfjs_require__) {
  18119. "use strict";
  18120. var sharedUtil = __w_pdfjs_require__(0);
  18121. var displayDOMUtils = __w_pdfjs_require__(3);
  18122. var AnnotationBorderStyleType = sharedUtil.AnnotationBorderStyleType;
  18123. var AnnotationType = sharedUtil.AnnotationType;
  18124. var stringToPDFString = sharedUtil.stringToPDFString;
  18125. var Util = sharedUtil.Util;
  18126. var addLinkAttributes = displayDOMUtils.addLinkAttributes;
  18127. var LinkTarget = displayDOMUtils.LinkTarget;
  18128. var getFilenameFromUrl = displayDOMUtils.getFilenameFromUrl;
  18129. var warn = sharedUtil.warn;
  18130. var CustomStyle = displayDOMUtils.CustomStyle;
  18131. var getDefaultSetting = displayDOMUtils.getDefaultSetting;
  18132. function AnnotationElementFactory() {
  18133. }
  18134. AnnotationElementFactory.prototype = {
  18135. create: function AnnotationElementFactory_create(parameters) {
  18136. var subtype = parameters.data.annotationType;
  18137. switch (subtype) {
  18138. case AnnotationType.LINK:
  18139. return new LinkAnnotationElement(parameters);
  18140. case AnnotationType.TEXT:
  18141. return new TextAnnotationElement(parameters);
  18142. case AnnotationType.WIDGET:
  18143. var fieldType = parameters.data.fieldType;
  18144. switch (fieldType) {
  18145. case 'Tx':
  18146. return new TextWidgetAnnotationElement(parameters);
  18147. case 'Btn':
  18148. if (parameters.data.radioButton) {
  18149. return new RadioButtonWidgetAnnotationElement(parameters);
  18150. } else if (parameters.data.checkBox) {
  18151. return new CheckboxWidgetAnnotationElement(parameters);
  18152. }
  18153. warn('Unimplemented button widget annotation: pushbutton');
  18154. break;
  18155. case 'Ch':
  18156. return new ChoiceWidgetAnnotationElement(parameters);
  18157. }
  18158. return new WidgetAnnotationElement(parameters);
  18159. case AnnotationType.POPUP:
  18160. return new PopupAnnotationElement(parameters);
  18161. case AnnotationType.HIGHLIGHT:
  18162. return new HighlightAnnotationElement(parameters);
  18163. case AnnotationType.UNDERLINE:
  18164. return new UnderlineAnnotationElement(parameters);
  18165. case AnnotationType.SQUIGGLY:
  18166. return new SquigglyAnnotationElement(parameters);
  18167. case AnnotationType.STRIKEOUT:
  18168. return new StrikeOutAnnotationElement(parameters);
  18169. case AnnotationType.FILEATTACHMENT:
  18170. return new FileAttachmentAnnotationElement(parameters);
  18171. default:
  18172. return new AnnotationElement(parameters);
  18173. }
  18174. }
  18175. };
  18176. var AnnotationElement = function AnnotationElementClosure() {
  18177. function AnnotationElement(parameters, isRenderable) {
  18178. this.isRenderable = isRenderable || false;
  18179. this.data = parameters.data;
  18180. this.layer = parameters.layer;
  18181. this.page = parameters.page;
  18182. this.viewport = parameters.viewport;
  18183. this.linkService = parameters.linkService;
  18184. this.downloadManager = parameters.downloadManager;
  18185. this.imageResourcesPath = parameters.imageResourcesPath;
  18186. this.renderInteractiveForms = parameters.renderInteractiveForms;
  18187. if (isRenderable) {
  18188. this.container = this._createContainer();
  18189. }
  18190. }
  18191. AnnotationElement.prototype = {
  18192. _createContainer: function AnnotationElement_createContainer() {
  18193. var data = this.data, page = this.page, viewport = this.viewport;
  18194. var container = document.createElement('section');
  18195. var width = data.rect[2] - data.rect[0];
  18196. var height = data.rect[3] - data.rect[1];
  18197. container.setAttribute('data-annotation-id', data.id);
  18198. var rect = Util.normalizeRect([
  18199. data.rect[0],
  18200. page.view[3] - data.rect[1] + page.view[1],
  18201. data.rect[2],
  18202. page.view[3] - data.rect[3] + page.view[1]
  18203. ]);
  18204. CustomStyle.setProp('transform', container, 'matrix(' + viewport.transform.join(',') + ')');
  18205. CustomStyle.setProp('transformOrigin', container, -rect[0] + 'px ' + -rect[1] + 'px');
  18206. if (data.borderStyle.width > 0) {
  18207. container.style.borderWidth = data.borderStyle.width + 'px';
  18208. if (data.borderStyle.style !== AnnotationBorderStyleType.UNDERLINE) {
  18209. width = width - 2 * data.borderStyle.width;
  18210. height = height - 2 * data.borderStyle.width;
  18211. }
  18212. var horizontalRadius = data.borderStyle.horizontalCornerRadius;
  18213. var verticalRadius = data.borderStyle.verticalCornerRadius;
  18214. if (horizontalRadius > 0 || verticalRadius > 0) {
  18215. var radius = horizontalRadius + 'px / ' + verticalRadius + 'px';
  18216. CustomStyle.setProp('borderRadius', container, radius);
  18217. }
  18218. switch (data.borderStyle.style) {
  18219. case AnnotationBorderStyleType.SOLID:
  18220. container.style.borderStyle = 'solid';
  18221. break;
  18222. case AnnotationBorderStyleType.DASHED:
  18223. container.style.borderStyle = 'dashed';
  18224. break;
  18225. case AnnotationBorderStyleType.BEVELED:
  18226. warn('Unimplemented border style: beveled');
  18227. break;
  18228. case AnnotationBorderStyleType.INSET:
  18229. warn('Unimplemented border style: inset');
  18230. break;
  18231. case AnnotationBorderStyleType.UNDERLINE:
  18232. container.style.borderBottomStyle = 'solid';
  18233. break;
  18234. default:
  18235. break;
  18236. }
  18237. if (data.color) {
  18238. container.style.borderColor = Util.makeCssRgb(data.color[0] | 0, data.color[1] | 0, data.color[2] | 0);
  18239. } else {
  18240. container.style.borderWidth = 0;
  18241. }
  18242. }
  18243. container.style.left = rect[0] + 'px';
  18244. container.style.top = rect[1] + 'px';
  18245. container.style.width = width + 'px';
  18246. container.style.height = height + 'px';
  18247. return container;
  18248. },
  18249. _createPopup: function AnnotationElement_createPopup(container, trigger, data) {
  18250. if (!trigger) {
  18251. trigger = document.createElement('div');
  18252. trigger.style.height = container.style.height;
  18253. trigger.style.width = container.style.width;
  18254. container.appendChild(trigger);
  18255. }
  18256. var popupElement = new PopupElement({
  18257. container: container,
  18258. trigger: trigger,
  18259. color: data.color,
  18260. title: data.title,
  18261. contents: data.contents,
  18262. hideWrapper: true
  18263. });
  18264. var popup = popupElement.render();
  18265. popup.style.left = container.style.width;
  18266. container.appendChild(popup);
  18267. },
  18268. render: function AnnotationElement_render() {
  18269. throw new Error('Abstract method AnnotationElement.render called');
  18270. }
  18271. };
  18272. return AnnotationElement;
  18273. }();
  18274. var LinkAnnotationElement = function LinkAnnotationElementClosure() {
  18275. function LinkAnnotationElement(parameters) {
  18276. AnnotationElement.call(this, parameters, true);
  18277. }
  18278. Util.inherit(LinkAnnotationElement, AnnotationElement, {
  18279. render: function LinkAnnotationElement_render() {
  18280. this.container.className = 'linkAnnotation';
  18281. var link = document.createElement('a');
  18282. addLinkAttributes(link, {
  18283. url: this.data.url,
  18284. target: this.data.newWindow ? LinkTarget.BLANK : undefined
  18285. });
  18286. if (!this.data.url) {
  18287. if (this.data.action) {
  18288. this._bindNamedAction(link, this.data.action);
  18289. } else {
  18290. this._bindLink(link, this.data.dest);
  18291. }
  18292. }
  18293. this.container.appendChild(link);
  18294. return this.container;
  18295. },
  18296. _bindLink: function LinkAnnotationElement_bindLink(link, destination) {
  18297. var self = this;
  18298. link.href = this.linkService.getDestinationHash(destination);
  18299. link.onclick = function () {
  18300. if (destination) {
  18301. self.linkService.navigateTo(destination);
  18302. }
  18303. return false;
  18304. };
  18305. if (destination) {
  18306. link.className = 'internalLink';
  18307. }
  18308. },
  18309. _bindNamedAction: function LinkAnnotationElement_bindNamedAction(link, action) {
  18310. var self = this;
  18311. link.href = this.linkService.getAnchorUrl('');
  18312. link.onclick = function () {
  18313. self.linkService.executeNamedAction(action);
  18314. return false;
  18315. };
  18316. link.className = 'internalLink';
  18317. }
  18318. });
  18319. return LinkAnnotationElement;
  18320. }();
  18321. var TextAnnotationElement = function TextAnnotationElementClosure() {
  18322. function TextAnnotationElement(parameters) {
  18323. var isRenderable = !!(parameters.data.hasPopup || parameters.data.title || parameters.data.contents);
  18324. AnnotationElement.call(this, parameters, isRenderable);
  18325. }
  18326. Util.inherit(TextAnnotationElement, AnnotationElement, {
  18327. render: function TextAnnotationElement_render() {
  18328. this.container.className = 'textAnnotation';
  18329. var image = document.createElement('img');
  18330. image.style.height = this.container.style.height;
  18331. image.style.width = this.container.style.width;
  18332. image.src = this.imageResourcesPath + 'annotation-' + this.data.name.toLowerCase() + '.svg';
  18333. image.alt = '[{{type}} Annotation]';
  18334. image.dataset.l10nId = 'text_annotation_type';
  18335. image.dataset.l10nArgs = JSON.stringify({ type: this.data.name });
  18336. if (!this.data.hasPopup) {
  18337. this._createPopup(this.container, image, this.data);
  18338. }
  18339. this.container.appendChild(image);
  18340. return this.container;
  18341. }
  18342. });
  18343. return TextAnnotationElement;
  18344. }();
  18345. var WidgetAnnotationElement = function WidgetAnnotationElementClosure() {
  18346. function WidgetAnnotationElement(parameters, isRenderable) {
  18347. AnnotationElement.call(this, parameters, isRenderable);
  18348. }
  18349. Util.inherit(WidgetAnnotationElement, AnnotationElement, {
  18350. render: function WidgetAnnotationElement_render() {
  18351. return this.container;
  18352. }
  18353. });
  18354. return WidgetAnnotationElement;
  18355. }();
  18356. var TextWidgetAnnotationElement = function TextWidgetAnnotationElementClosure() {
  18357. var TEXT_ALIGNMENT = [
  18358. 'left',
  18359. 'center',
  18360. 'right'
  18361. ];
  18362. function TextWidgetAnnotationElement(parameters) {
  18363. var isRenderable = parameters.renderInteractiveForms || !parameters.data.hasAppearance && !!parameters.data.fieldValue;
  18364. WidgetAnnotationElement.call(this, parameters, isRenderable);
  18365. }
  18366. Util.inherit(TextWidgetAnnotationElement, WidgetAnnotationElement, {
  18367. render: function TextWidgetAnnotationElement_render() {
  18368. this.container.className = 'textWidgetAnnotation';
  18369. var element = null;
  18370. if (this.renderInteractiveForms) {
  18371. if (this.data.multiLine) {
  18372. element = document.createElement('textarea');
  18373. element.textContent = this.data.fieldValue;
  18374. } else {
  18375. element = document.createElement('input');
  18376. element.type = 'text';
  18377. element.setAttribute('value', this.data.fieldValue);
  18378. }
  18379. element.disabled = this.data.readOnly;
  18380. if (this.data.maxLen !== null) {
  18381. element.maxLength = this.data.maxLen;
  18382. }
  18383. if (this.data.comb) {
  18384. var fieldWidth = this.data.rect[2] - this.data.rect[0];
  18385. var combWidth = fieldWidth / this.data.maxLen;
  18386. element.classList.add('comb');
  18387. element.style.letterSpacing = 'calc(' + combWidth + 'px - 1ch)';
  18388. }
  18389. } else {
  18390. element = document.createElement('div');
  18391. element.textContent = this.data.fieldValue;
  18392. element.style.verticalAlign = 'middle';
  18393. element.style.display = 'table-cell';
  18394. var font = null;
  18395. if (this.data.fontRefName) {
  18396. font = this.page.commonObjs.getData(this.data.fontRefName);
  18397. }
  18398. this._setTextStyle(element, font);
  18399. }
  18400. if (this.data.textAlignment !== null) {
  18401. element.style.textAlign = TEXT_ALIGNMENT[this.data.textAlignment];
  18402. }
  18403. this.container.appendChild(element);
  18404. return this.container;
  18405. },
  18406. _setTextStyle: function TextWidgetAnnotationElement_setTextStyle(element, font) {
  18407. var style = element.style;
  18408. style.fontSize = this.data.fontSize + 'px';
  18409. style.direction = this.data.fontDirection < 0 ? 'rtl' : 'ltr';
  18410. if (!font) {
  18411. return;
  18412. }
  18413. style.fontWeight = font.black ? font.bold ? '900' : 'bold' : font.bold ? 'bold' : 'normal';
  18414. style.fontStyle = font.italic ? 'italic' : 'normal';
  18415. var fontFamily = font.loadedName ? '"' + font.loadedName + '", ' : '';
  18416. var fallbackName = font.fallbackName || 'Helvetica, sans-serif';
  18417. style.fontFamily = fontFamily + fallbackName;
  18418. }
  18419. });
  18420. return TextWidgetAnnotationElement;
  18421. }();
  18422. var CheckboxWidgetAnnotationElement = function CheckboxWidgetAnnotationElementClosure() {
  18423. function CheckboxWidgetAnnotationElement(parameters) {
  18424. WidgetAnnotationElement.call(this, parameters, parameters.renderInteractiveForms);
  18425. }
  18426. Util.inherit(CheckboxWidgetAnnotationElement, WidgetAnnotationElement, {
  18427. render: function CheckboxWidgetAnnotationElement_render() {
  18428. this.container.className = 'buttonWidgetAnnotation checkBox';
  18429. var element = document.createElement('input');
  18430. element.disabled = this.data.readOnly;
  18431. element.type = 'checkbox';
  18432. if (this.data.fieldValue && this.data.fieldValue !== 'Off') {
  18433. element.setAttribute('checked', true);
  18434. }
  18435. this.container.appendChild(element);
  18436. return this.container;
  18437. }
  18438. });
  18439. return CheckboxWidgetAnnotationElement;
  18440. }();
  18441. var RadioButtonWidgetAnnotationElement = function RadioButtonWidgetAnnotationElementClosure() {
  18442. function RadioButtonWidgetAnnotationElement(parameters) {
  18443. WidgetAnnotationElement.call(this, parameters, parameters.renderInteractiveForms);
  18444. }
  18445. Util.inherit(RadioButtonWidgetAnnotationElement, WidgetAnnotationElement, {
  18446. render: function RadioButtonWidgetAnnotationElement_render() {
  18447. this.container.className = 'buttonWidgetAnnotation radioButton';
  18448. var element = document.createElement('input');
  18449. element.disabled = this.data.readOnly;
  18450. element.type = 'radio';
  18451. element.name = this.data.fieldName;
  18452. if (this.data.fieldValue === this.data.buttonValue) {
  18453. element.setAttribute('checked', true);
  18454. }
  18455. this.container.appendChild(element);
  18456. return this.container;
  18457. }
  18458. });
  18459. return RadioButtonWidgetAnnotationElement;
  18460. }();
  18461. var ChoiceWidgetAnnotationElement = function ChoiceWidgetAnnotationElementClosure() {
  18462. function ChoiceWidgetAnnotationElement(parameters) {
  18463. WidgetAnnotationElement.call(this, parameters, parameters.renderInteractiveForms);
  18464. }
  18465. Util.inherit(ChoiceWidgetAnnotationElement, WidgetAnnotationElement, {
  18466. render: function ChoiceWidgetAnnotationElement_render() {
  18467. this.container.className = 'choiceWidgetAnnotation';
  18468. var selectElement = document.createElement('select');
  18469. selectElement.disabled = this.data.readOnly;
  18470. if (!this.data.combo) {
  18471. selectElement.size = this.data.options.length;
  18472. if (this.data.multiSelect) {
  18473. selectElement.multiple = true;
  18474. }
  18475. }
  18476. for (var i = 0, ii = this.data.options.length; i < ii; i++) {
  18477. var option = this.data.options[i];
  18478. var optionElement = document.createElement('option');
  18479. optionElement.textContent = option.displayValue;
  18480. optionElement.value = option.exportValue;
  18481. if (this.data.fieldValue.indexOf(option.displayValue) >= 0) {
  18482. optionElement.setAttribute('selected', true);
  18483. }
  18484. selectElement.appendChild(optionElement);
  18485. }
  18486. this.container.appendChild(selectElement);
  18487. return this.container;
  18488. }
  18489. });
  18490. return ChoiceWidgetAnnotationElement;
  18491. }();
  18492. var PopupAnnotationElement = function PopupAnnotationElementClosure() {
  18493. function PopupAnnotationElement(parameters) {
  18494. var isRenderable = !!(parameters.data.title || parameters.data.contents);
  18495. AnnotationElement.call(this, parameters, isRenderable);
  18496. }
  18497. Util.inherit(PopupAnnotationElement, AnnotationElement, {
  18498. render: function PopupAnnotationElement_render() {
  18499. this.container.className = 'popupAnnotation';
  18500. var selector = '[data-annotation-id="' + this.data.parentId + '"]';
  18501. var parentElement = this.layer.querySelector(selector);
  18502. if (!parentElement) {
  18503. return this.container;
  18504. }
  18505. var popup = new PopupElement({
  18506. container: this.container,
  18507. trigger: parentElement,
  18508. color: this.data.color,
  18509. title: this.data.title,
  18510. contents: this.data.contents
  18511. });
  18512. var parentLeft = parseFloat(parentElement.style.left);
  18513. var parentWidth = parseFloat(parentElement.style.width);
  18514. CustomStyle.setProp('transformOrigin', this.container, -(parentLeft + parentWidth) + 'px -' + parentElement.style.top);
  18515. this.container.style.left = parentLeft + parentWidth + 'px';
  18516. this.container.appendChild(popup.render());
  18517. return this.container;
  18518. }
  18519. });
  18520. return PopupAnnotationElement;
  18521. }();
  18522. var PopupElement = function PopupElementClosure() {
  18523. var BACKGROUND_ENLIGHT = 0.7;
  18524. function PopupElement(parameters) {
  18525. this.container = parameters.container;
  18526. this.trigger = parameters.trigger;
  18527. this.color = parameters.color;
  18528. this.title = parameters.title;
  18529. this.contents = parameters.contents;
  18530. this.hideWrapper = parameters.hideWrapper || false;
  18531. this.pinned = false;
  18532. }
  18533. PopupElement.prototype = {
  18534. render: function PopupElement_render() {
  18535. var wrapper = document.createElement('div');
  18536. wrapper.className = 'popupWrapper';
  18537. this.hideElement = this.hideWrapper ? wrapper : this.container;
  18538. this.hideElement.setAttribute('hidden', true);
  18539. var popup = document.createElement('div');
  18540. popup.className = 'popup';
  18541. var color = this.color;
  18542. if (color) {
  18543. var r = BACKGROUND_ENLIGHT * (255 - color[0]) + color[0];
  18544. var g = BACKGROUND_ENLIGHT * (255 - color[1]) + color[1];
  18545. var b = BACKGROUND_ENLIGHT * (255 - color[2]) + color[2];
  18546. popup.style.backgroundColor = Util.makeCssRgb(r | 0, g | 0, b | 0);
  18547. }
  18548. var contents = this._formatContents(this.contents);
  18549. var title = document.createElement('h1');
  18550. title.textContent = this.title;
  18551. this.trigger.addEventListener('click', this._toggle.bind(this));
  18552. this.trigger.addEventListener('mouseover', this._show.bind(this, false));
  18553. this.trigger.addEventListener('mouseout', this._hide.bind(this, false));
  18554. popup.addEventListener('click', this._hide.bind(this, true));
  18555. popup.appendChild(title);
  18556. popup.appendChild(contents);
  18557. wrapper.appendChild(popup);
  18558. return wrapper;
  18559. },
  18560. _formatContents: function PopupElement_formatContents(contents) {
  18561. var p = document.createElement('p');
  18562. var lines = contents.split(/(?:\r\n?|\n)/);
  18563. for (var i = 0, ii = lines.length; i < ii; ++i) {
  18564. var line = lines[i];
  18565. p.appendChild(document.createTextNode(line));
  18566. if (i < ii - 1) {
  18567. p.appendChild(document.createElement('br'));
  18568. }
  18569. }
  18570. return p;
  18571. },
  18572. _toggle: function PopupElement_toggle() {
  18573. if (this.pinned) {
  18574. this._hide(true);
  18575. } else {
  18576. this._show(true);
  18577. }
  18578. },
  18579. _show: function PopupElement_show(pin) {
  18580. if (pin) {
  18581. this.pinned = true;
  18582. }
  18583. if (this.hideElement.hasAttribute('hidden')) {
  18584. this.hideElement.removeAttribute('hidden');
  18585. this.container.style.zIndex += 1;
  18586. }
  18587. },
  18588. _hide: function PopupElement_hide(unpin) {
  18589. if (unpin) {
  18590. this.pinned = false;
  18591. }
  18592. if (!this.hideElement.hasAttribute('hidden') && !this.pinned) {
  18593. this.hideElement.setAttribute('hidden', true);
  18594. this.container.style.zIndex -= 1;
  18595. }
  18596. }
  18597. };
  18598. return PopupElement;
  18599. }();
  18600. var HighlightAnnotationElement = function HighlightAnnotationElementClosure() {
  18601. function HighlightAnnotationElement(parameters) {
  18602. var isRenderable = !!(parameters.data.hasPopup || parameters.data.title || parameters.data.contents);
  18603. AnnotationElement.call(this, parameters, isRenderable);
  18604. }
  18605. Util.inherit(HighlightAnnotationElement, AnnotationElement, {
  18606. render: function HighlightAnnotationElement_render() {
  18607. this.container.className = 'highlightAnnotation';
  18608. if (!this.data.hasPopup) {
  18609. this._createPopup(this.container, null, this.data);
  18610. }
  18611. return this.container;
  18612. }
  18613. });
  18614. return HighlightAnnotationElement;
  18615. }();
  18616. var UnderlineAnnotationElement = function UnderlineAnnotationElementClosure() {
  18617. function UnderlineAnnotationElement(parameters) {
  18618. var isRenderable = !!(parameters.data.hasPopup || parameters.data.title || parameters.data.contents);
  18619. AnnotationElement.call(this, parameters, isRenderable);
  18620. }
  18621. Util.inherit(UnderlineAnnotationElement, AnnotationElement, {
  18622. render: function UnderlineAnnotationElement_render() {
  18623. this.container.className = 'underlineAnnotation';
  18624. if (!this.data.hasPopup) {
  18625. this._createPopup(this.container, null, this.data);
  18626. }
  18627. return this.container;
  18628. }
  18629. });
  18630. return UnderlineAnnotationElement;
  18631. }();
  18632. var SquigglyAnnotationElement = function SquigglyAnnotationElementClosure() {
  18633. function SquigglyAnnotationElement(parameters) {
  18634. var isRenderable = !!(parameters.data.hasPopup || parameters.data.title || parameters.data.contents);
  18635. AnnotationElement.call(this, parameters, isRenderable);
  18636. }
  18637. Util.inherit(SquigglyAnnotationElement, AnnotationElement, {
  18638. render: function SquigglyAnnotationElement_render() {
  18639. this.container.className = 'squigglyAnnotation';
  18640. if (!this.data.hasPopup) {
  18641. this._createPopup(this.container, null, this.data);
  18642. }
  18643. return this.container;
  18644. }
  18645. });
  18646. return SquigglyAnnotationElement;
  18647. }();
  18648. var StrikeOutAnnotationElement = function StrikeOutAnnotationElementClosure() {
  18649. function StrikeOutAnnotationElement(parameters) {
  18650. var isRenderable = !!(parameters.data.hasPopup || parameters.data.title || parameters.data.contents);
  18651. AnnotationElement.call(this, parameters, isRenderable);
  18652. }
  18653. Util.inherit(StrikeOutAnnotationElement, AnnotationElement, {
  18654. render: function StrikeOutAnnotationElement_render() {
  18655. this.container.className = 'strikeoutAnnotation';
  18656. if (!this.data.hasPopup) {
  18657. this._createPopup(this.container, null, this.data);
  18658. }
  18659. return this.container;
  18660. }
  18661. });
  18662. return StrikeOutAnnotationElement;
  18663. }();
  18664. var FileAttachmentAnnotationElement = function FileAttachmentAnnotationElementClosure() {
  18665. function FileAttachmentAnnotationElement(parameters) {
  18666. AnnotationElement.call(this, parameters, true);
  18667. var file = this.data.file;
  18668. this.filename = getFilenameFromUrl(file.filename);
  18669. this.content = file.content;
  18670. this.linkService.onFileAttachmentAnnotation({
  18671. id: stringToPDFString(file.filename),
  18672. filename: file.filename,
  18673. content: file.content
  18674. });
  18675. }
  18676. Util.inherit(FileAttachmentAnnotationElement, AnnotationElement, {
  18677. render: function FileAttachmentAnnotationElement_render() {
  18678. this.container.className = 'fileAttachmentAnnotation';
  18679. var trigger = document.createElement('div');
  18680. trigger.style.height = this.container.style.height;
  18681. trigger.style.width = this.container.style.width;
  18682. trigger.addEventListener('dblclick', this._download.bind(this));
  18683. if (!this.data.hasPopup && (this.data.title || this.data.contents)) {
  18684. this._createPopup(this.container, trigger, this.data);
  18685. }
  18686. this.container.appendChild(trigger);
  18687. return this.container;
  18688. },
  18689. _download: function FileAttachmentAnnotationElement_download() {
  18690. if (!this.downloadManager) {
  18691. warn('Download cannot be started due to unavailable download manager');
  18692. return;
  18693. }
  18694. this.downloadManager.downloadData(this.content, this.filename, '');
  18695. }
  18696. });
  18697. return FileAttachmentAnnotationElement;
  18698. }();
  18699. var AnnotationLayer = function AnnotationLayerClosure() {
  18700. return {
  18701. render: function AnnotationLayer_render(parameters) {
  18702. var annotationElementFactory = new AnnotationElementFactory();
  18703. for (var i = 0, ii = parameters.annotations.length; i < ii; i++) {
  18704. var data = parameters.annotations[i];
  18705. if (!data) {
  18706. continue;
  18707. }
  18708. var element = annotationElementFactory.create({
  18709. data: data,
  18710. layer: parameters.div,
  18711. page: parameters.page,
  18712. viewport: parameters.viewport,
  18713. linkService: parameters.linkService,
  18714. downloadManager: parameters.downloadManager,
  18715. imageResourcesPath: parameters.imageResourcesPath || getDefaultSetting('imageResourcesPath'),
  18716. renderInteractiveForms: parameters.renderInteractiveForms || false
  18717. });
  18718. if (element.isRenderable) {
  18719. parameters.div.appendChild(element.render());
  18720. }
  18721. }
  18722. },
  18723. update: function AnnotationLayer_update(parameters) {
  18724. for (var i = 0, ii = parameters.annotations.length; i < ii; i++) {
  18725. var data = parameters.annotations[i];
  18726. var element = parameters.div.querySelector('[data-annotation-id="' + data.id + '"]');
  18727. if (element) {
  18728. CustomStyle.setProp('transform', element, 'matrix(' + parameters.viewport.transform.join(',') + ')');
  18729. }
  18730. }
  18731. parameters.div.removeAttribute('hidden');
  18732. }
  18733. };
  18734. }();
  18735. exports.AnnotationLayer = AnnotationLayer;
  18736. /***/ }),
  18737. /* 10 */
  18738. /***/ (function(module, exports, __w_pdfjs_require__) {
  18739. "use strict";
  18740. var sharedUtil = __w_pdfjs_require__(0);
  18741. var displayFontLoader = __w_pdfjs_require__(45);
  18742. var displayCanvas = __w_pdfjs_require__(44);
  18743. var displayMetadata = __w_pdfjs_require__(24);
  18744. var displayDOMUtils = __w_pdfjs_require__(3);
  18745. var amdRequire;
  18746. var InvalidPDFException = sharedUtil.InvalidPDFException;
  18747. var MessageHandler = sharedUtil.MessageHandler;
  18748. var MissingPDFException = sharedUtil.MissingPDFException;
  18749. var PageViewport = sharedUtil.PageViewport;
  18750. var PasswordException = sharedUtil.PasswordException;
  18751. var StatTimer = sharedUtil.StatTimer;
  18752. var UnexpectedResponseException = sharedUtil.UnexpectedResponseException;
  18753. var UnknownErrorException = sharedUtil.UnknownErrorException;
  18754. var Util = sharedUtil.Util;
  18755. var createPromiseCapability = sharedUtil.createPromiseCapability;
  18756. var error = sharedUtil.error;
  18757. var deprecated = sharedUtil.deprecated;
  18758. var getVerbosityLevel = sharedUtil.getVerbosityLevel;
  18759. var info = sharedUtil.info;
  18760. var isInt = sharedUtil.isInt;
  18761. var isArray = sharedUtil.isArray;
  18762. var isArrayBuffer = sharedUtil.isArrayBuffer;
  18763. var isSameOrigin = sharedUtil.isSameOrigin;
  18764. var loadJpegStream = sharedUtil.loadJpegStream;
  18765. var stringToBytes = sharedUtil.stringToBytes;
  18766. var globalScope = sharedUtil.globalScope;
  18767. var warn = sharedUtil.warn;
  18768. var FontFaceObject = displayFontLoader.FontFaceObject;
  18769. var FontLoader = displayFontLoader.FontLoader;
  18770. var CanvasGraphics = displayCanvas.CanvasGraphics;
  18771. var Metadata = displayMetadata.Metadata;
  18772. var getDefaultSetting = displayDOMUtils.getDefaultSetting;
  18773. var DOMCanvasFactory = displayDOMUtils.DOMCanvasFactory;
  18774. var DOMCMapReaderFactory = displayDOMUtils.DOMCMapReaderFactory;
  18775. var DEFAULT_RANGE_CHUNK_SIZE = 65536;
  18776. var isWorkerDisabled = false;
  18777. var workerSrc;
  18778. var isPostMessageTransfersDisabled = false;
  18779. var pdfjsFilePath = typeof document !== 'undefined' && document.currentScript ? document.currentScript.src : null;
  18780. var fakeWorkerFilesLoader = null;
  18781. var useRequireEnsure = false;
  18782. function getDocument(src, pdfDataRangeTransport, passwordCallback, progressCallback) {
  18783. var task = new PDFDocumentLoadingTask();
  18784. if (arguments.length > 1) {
  18785. deprecated('getDocument is called with pdfDataRangeTransport, ' + 'passwordCallback or progressCallback argument');
  18786. }
  18787. if (pdfDataRangeTransport) {
  18788. if (!(pdfDataRangeTransport instanceof PDFDataRangeTransport)) {
  18789. pdfDataRangeTransport = Object.create(pdfDataRangeTransport);
  18790. pdfDataRangeTransport.length = src.length;
  18791. pdfDataRangeTransport.initialData = src.initialData;
  18792. if (!pdfDataRangeTransport.abort) {
  18793. pdfDataRangeTransport.abort = function () {
  18794. };
  18795. }
  18796. }
  18797. src = Object.create(src);
  18798. src.range = pdfDataRangeTransport;
  18799. }
  18800. task.onPassword = passwordCallback || null;
  18801. task.onProgress = progressCallback || null;
  18802. var source;
  18803. if (typeof src === 'string') {
  18804. source = { url: src };
  18805. } else if (isArrayBuffer(src)) {
  18806. source = { data: src };
  18807. } else if (src instanceof PDFDataRangeTransport) {
  18808. source = { range: src };
  18809. } else {
  18810. if (typeof src !== 'object') {
  18811. error('Invalid parameter in getDocument, need either Uint8Array, ' + 'string or a parameter object');
  18812. }
  18813. if (!src.url && !src.data && !src.range) {
  18814. error('Invalid parameter object: need either .data, .range or .url');
  18815. }
  18816. source = src;
  18817. }
  18818. var params = {};
  18819. var rangeTransport = null;
  18820. var worker = null;
  18821. for (var key in source) {
  18822. if (key === 'url' && typeof window !== 'undefined') {
  18823. params[key] = new URL(source[key], window.location).href;
  18824. continue;
  18825. } else if (key === 'range') {
  18826. rangeTransport = source[key];
  18827. continue;
  18828. } else if (key === 'worker') {
  18829. worker = source[key];
  18830. continue;
  18831. } else if (key === 'data' && !(source[key] instanceof Uint8Array)) {
  18832. var pdfBytes = source[key];
  18833. if (typeof pdfBytes === 'string') {
  18834. params[key] = stringToBytes(pdfBytes);
  18835. } else if (typeof pdfBytes === 'object' && pdfBytes !== null && !isNaN(pdfBytes.length)) {
  18836. params[key] = new Uint8Array(pdfBytes);
  18837. } else if (isArrayBuffer(pdfBytes)) {
  18838. params[key] = new Uint8Array(pdfBytes);
  18839. } else {
  18840. error('Invalid PDF binary data: either typed array, string or ' + 'array-like object is expected in the data property.');
  18841. }
  18842. continue;
  18843. }
  18844. params[key] = source[key];
  18845. }
  18846. params.rangeChunkSize = params.rangeChunkSize || DEFAULT_RANGE_CHUNK_SIZE;
  18847. params.disableNativeImageDecoder = params.disableNativeImageDecoder === true;
  18848. var CMapReaderFactory = params.CMapReaderFactory || DOMCMapReaderFactory;
  18849. if (!worker) {
  18850. var workerPort = getDefaultSetting('workerPort');
  18851. worker = workerPort ? new PDFWorker(null, workerPort) : new PDFWorker();
  18852. task._worker = worker;
  18853. }
  18854. var docId = task.docId;
  18855. worker.promise.then(function () {
  18856. if (task.destroyed) {
  18857. throw new Error('Loading aborted');
  18858. }
  18859. return _fetchDocument(worker, params, rangeTransport, docId).then(function (workerId) {
  18860. if (task.destroyed) {
  18861. throw new Error('Loading aborted');
  18862. }
  18863. var messageHandler = new MessageHandler(docId, workerId, worker.port);
  18864. var transport = new WorkerTransport(messageHandler, task, rangeTransport, CMapReaderFactory);
  18865. task._transport = transport;
  18866. messageHandler.send('Ready', null);
  18867. });
  18868. }).catch(task._capability.reject);
  18869. return task;
  18870. }
  18871. function _fetchDocument(worker, source, pdfDataRangeTransport, docId) {
  18872. if (worker.destroyed) {
  18873. return Promise.reject(new Error('Worker was destroyed'));
  18874. }
  18875. source.disableAutoFetch = getDefaultSetting('disableAutoFetch');
  18876. source.disableStream = getDefaultSetting('disableStream');
  18877. source.chunkedViewerLoading = !!pdfDataRangeTransport;
  18878. if (pdfDataRangeTransport) {
  18879. source.length = pdfDataRangeTransport.length;
  18880. source.initialData = pdfDataRangeTransport.initialData;
  18881. }
  18882. return worker.messageHandler.sendWithPromise('GetDocRequest', {
  18883. docId: docId,
  18884. source: source,
  18885. disableRange: getDefaultSetting('disableRange'),
  18886. maxImageSize: getDefaultSetting('maxImageSize'),
  18887. disableFontFace: getDefaultSetting('disableFontFace'),
  18888. disableCreateObjectURL: getDefaultSetting('disableCreateObjectURL'),
  18889. postMessageTransfers: getDefaultSetting('postMessageTransfers') && !isPostMessageTransfersDisabled,
  18890. docBaseUrl: source.docBaseUrl,
  18891. disableNativeImageDecoder: source.disableNativeImageDecoder
  18892. }).then(function (workerId) {
  18893. if (worker.destroyed) {
  18894. throw new Error('Worker was destroyed');
  18895. }
  18896. return workerId;
  18897. });
  18898. }
  18899. var PDFDocumentLoadingTask = function PDFDocumentLoadingTaskClosure() {
  18900. var nextDocumentId = 0;
  18901. function PDFDocumentLoadingTask() {
  18902. this._capability = createPromiseCapability();
  18903. this._transport = null;
  18904. this._worker = null;
  18905. this.docId = 'd' + nextDocumentId++;
  18906. this.destroyed = false;
  18907. this.onPassword = null;
  18908. this.onProgress = null;
  18909. this.onUnsupportedFeature = null;
  18910. }
  18911. PDFDocumentLoadingTask.prototype = {
  18912. get promise() {
  18913. return this._capability.promise;
  18914. },
  18915. destroy: function () {
  18916. this.destroyed = true;
  18917. var transportDestroyed = !this._transport ? Promise.resolve() : this._transport.destroy();
  18918. return transportDestroyed.then(function () {
  18919. this._transport = null;
  18920. if (this._worker) {
  18921. this._worker.destroy();
  18922. this._worker = null;
  18923. }
  18924. }.bind(this));
  18925. },
  18926. then: function PDFDocumentLoadingTask_then(onFulfilled, onRejected) {
  18927. return this.promise.then.apply(this.promise, arguments);
  18928. }
  18929. };
  18930. return PDFDocumentLoadingTask;
  18931. }();
  18932. var PDFDataRangeTransport = function pdfDataRangeTransportClosure() {
  18933. function PDFDataRangeTransport(length, initialData) {
  18934. this.length = length;
  18935. this.initialData = initialData;
  18936. this._rangeListeners = [];
  18937. this._progressListeners = [];
  18938. this._progressiveReadListeners = [];
  18939. this._readyCapability = createPromiseCapability();
  18940. }
  18941. PDFDataRangeTransport.prototype = {
  18942. addRangeListener: function PDFDataRangeTransport_addRangeListener(listener) {
  18943. this._rangeListeners.push(listener);
  18944. },
  18945. addProgressListener: function PDFDataRangeTransport_addProgressListener(listener) {
  18946. this._progressListeners.push(listener);
  18947. },
  18948. addProgressiveReadListener: function PDFDataRangeTransport_addProgressiveReadListener(listener) {
  18949. this._progressiveReadListeners.push(listener);
  18950. },
  18951. onDataRange: function PDFDataRangeTransport_onDataRange(begin, chunk) {
  18952. var listeners = this._rangeListeners;
  18953. for (var i = 0, n = listeners.length; i < n; ++i) {
  18954. listeners[i](begin, chunk);
  18955. }
  18956. },
  18957. onDataProgress: function PDFDataRangeTransport_onDataProgress(loaded) {
  18958. this._readyCapability.promise.then(function () {
  18959. var listeners = this._progressListeners;
  18960. for (var i = 0, n = listeners.length; i < n; ++i) {
  18961. listeners[i](loaded);
  18962. }
  18963. }.bind(this));
  18964. },
  18965. onDataProgressiveRead: function PDFDataRangeTransport_onDataProgress(chunk) {
  18966. this._readyCapability.promise.then(function () {
  18967. var listeners = this._progressiveReadListeners;
  18968. for (var i = 0, n = listeners.length; i < n; ++i) {
  18969. listeners[i](chunk);
  18970. }
  18971. }.bind(this));
  18972. },
  18973. transportReady: function PDFDataRangeTransport_transportReady() {
  18974. this._readyCapability.resolve();
  18975. },
  18976. requestDataRange: function PDFDataRangeTransport_requestDataRange(begin, end) {
  18977. throw new Error('Abstract method PDFDataRangeTransport.requestDataRange');
  18978. },
  18979. abort: function PDFDataRangeTransport_abort() {
  18980. }
  18981. };
  18982. return PDFDataRangeTransport;
  18983. }();
  18984. var PDFDocumentProxy = function PDFDocumentProxyClosure() {
  18985. function PDFDocumentProxy(pdfInfo, transport, loadingTask) {
  18986. this.pdfInfo = pdfInfo;
  18987. this.transport = transport;
  18988. this.loadingTask = loadingTask;
  18989. }
  18990. PDFDocumentProxy.prototype = {
  18991. get numPages() {
  18992. return this.pdfInfo.numPages;
  18993. },
  18994. get fingerprint() {
  18995. return this.pdfInfo.fingerprint;
  18996. },
  18997. getPage: function PDFDocumentProxy_getPage(pageNumber) {
  18998. return this.transport.getPage(pageNumber);
  18999. },
  19000. getPageIndex: function PDFDocumentProxy_getPageIndex(ref) {
  19001. return this.transport.getPageIndex(ref);
  19002. },
  19003. getDestinations: function PDFDocumentProxy_getDestinations() {
  19004. return this.transport.getDestinations();
  19005. },
  19006. getDestination: function PDFDocumentProxy_getDestination(id) {
  19007. return this.transport.getDestination(id);
  19008. },
  19009. getPageLabels: function PDFDocumentProxy_getPageLabels() {
  19010. return this.transport.getPageLabels();
  19011. },
  19012. getAttachments: function PDFDocumentProxy_getAttachments() {
  19013. return this.transport.getAttachments();
  19014. },
  19015. getJavaScript: function PDFDocumentProxy_getJavaScript() {
  19016. return this.transport.getJavaScript();
  19017. },
  19018. getOutline: function PDFDocumentProxy_getOutline() {
  19019. return this.transport.getOutline();
  19020. },
  19021. getMetadata: function PDFDocumentProxy_getMetadata() {
  19022. return this.transport.getMetadata();
  19023. },
  19024. getData: function PDFDocumentProxy_getData() {
  19025. return this.transport.getData();
  19026. },
  19027. getDownloadInfo: function PDFDocumentProxy_getDownloadInfo() {
  19028. return this.transport.downloadInfoCapability.promise;
  19029. },
  19030. getStats: function PDFDocumentProxy_getStats() {
  19031. return this.transport.getStats();
  19032. },
  19033. cleanup: function PDFDocumentProxy_cleanup() {
  19034. this.transport.startCleanup();
  19035. },
  19036. destroy: function PDFDocumentProxy_destroy() {
  19037. return this.loadingTask.destroy();
  19038. }
  19039. };
  19040. return PDFDocumentProxy;
  19041. }();
  19042. var PDFPageProxy = function PDFPageProxyClosure() {
  19043. function PDFPageProxy(pageIndex, pageInfo, transport) {
  19044. this.pageIndex = pageIndex;
  19045. this.pageInfo = pageInfo;
  19046. this.transport = transport;
  19047. this.stats = new StatTimer();
  19048. this.stats.enabled = getDefaultSetting('enableStats');
  19049. this.commonObjs = transport.commonObjs;
  19050. this.objs = new PDFObjects();
  19051. this.cleanupAfterRender = false;
  19052. this.pendingCleanup = false;
  19053. this.intentStates = Object.create(null);
  19054. this.destroyed = false;
  19055. }
  19056. PDFPageProxy.prototype = {
  19057. get pageNumber() {
  19058. return this.pageIndex + 1;
  19059. },
  19060. get rotate() {
  19061. return this.pageInfo.rotate;
  19062. },
  19063. get ref() {
  19064. return this.pageInfo.ref;
  19065. },
  19066. get userUnit() {
  19067. return this.pageInfo.userUnit;
  19068. },
  19069. get view() {
  19070. return this.pageInfo.view;
  19071. },
  19072. getViewport: function PDFPageProxy_getViewport(scale, rotate) {
  19073. if (arguments.length < 2) {
  19074. rotate = this.rotate;
  19075. }
  19076. return new PageViewport(this.view, scale, rotate, 0, 0);
  19077. },
  19078. getAnnotations: function PDFPageProxy_getAnnotations(params) {
  19079. var intent = params && params.intent || null;
  19080. if (!this.annotationsPromise || this.annotationsIntent !== intent) {
  19081. this.annotationsPromise = this.transport.getAnnotations(this.pageIndex, intent);
  19082. this.annotationsIntent = intent;
  19083. }
  19084. return this.annotationsPromise;
  19085. },
  19086. render: function PDFPageProxy_render(params) {
  19087. var stats = this.stats;
  19088. stats.time('Overall');
  19089. this.pendingCleanup = false;
  19090. var renderingIntent = params.intent === 'print' ? 'print' : 'display';
  19091. var renderInteractiveForms = params.renderInteractiveForms === true ? true : false;
  19092. var canvasFactory = params.canvasFactory || new DOMCanvasFactory();
  19093. if (!this.intentStates[renderingIntent]) {
  19094. this.intentStates[renderingIntent] = Object.create(null);
  19095. }
  19096. var intentState = this.intentStates[renderingIntent];
  19097. if (!intentState.displayReadyCapability) {
  19098. intentState.receivingOperatorList = true;
  19099. intentState.displayReadyCapability = createPromiseCapability();
  19100. intentState.operatorList = {
  19101. fnArray: [],
  19102. argsArray: [],
  19103. lastChunk: false
  19104. };
  19105. this.stats.time('Page Request');
  19106. this.transport.messageHandler.send('RenderPageRequest', {
  19107. pageIndex: this.pageNumber - 1,
  19108. intent: renderingIntent,
  19109. renderInteractiveForms: renderInteractiveForms
  19110. });
  19111. }
  19112. var internalRenderTask = new InternalRenderTask(complete, params, this.objs, this.commonObjs, intentState.operatorList, this.pageNumber, canvasFactory);
  19113. internalRenderTask.useRequestAnimationFrame = renderingIntent !== 'print';
  19114. if (!intentState.renderTasks) {
  19115. intentState.renderTasks = [];
  19116. }
  19117. intentState.renderTasks.push(internalRenderTask);
  19118. var renderTask = internalRenderTask.task;
  19119. if (params.continueCallback) {
  19120. deprecated('render is used with continueCallback parameter');
  19121. renderTask.onContinue = params.continueCallback;
  19122. }
  19123. var self = this;
  19124. intentState.displayReadyCapability.promise.then(function pageDisplayReadyPromise(transparency) {
  19125. if (self.pendingCleanup) {
  19126. complete();
  19127. return;
  19128. }
  19129. stats.time('Rendering');
  19130. internalRenderTask.initializeGraphics(transparency);
  19131. internalRenderTask.operatorListChanged();
  19132. }, function pageDisplayReadPromiseError(reason) {
  19133. complete(reason);
  19134. });
  19135. function complete(error) {
  19136. var i = intentState.renderTasks.indexOf(internalRenderTask);
  19137. if (i >= 0) {
  19138. intentState.renderTasks.splice(i, 1);
  19139. }
  19140. if (self.cleanupAfterRender) {
  19141. self.pendingCleanup = true;
  19142. }
  19143. self._tryCleanup();
  19144. if (error) {
  19145. internalRenderTask.capability.reject(error);
  19146. } else {
  19147. internalRenderTask.capability.resolve();
  19148. }
  19149. stats.timeEnd('Rendering');
  19150. stats.timeEnd('Overall');
  19151. }
  19152. return renderTask;
  19153. },
  19154. getOperatorList: function PDFPageProxy_getOperatorList() {
  19155. function operatorListChanged() {
  19156. if (intentState.operatorList.lastChunk) {
  19157. intentState.opListReadCapability.resolve(intentState.operatorList);
  19158. var i = intentState.renderTasks.indexOf(opListTask);
  19159. if (i >= 0) {
  19160. intentState.renderTasks.splice(i, 1);
  19161. }
  19162. }
  19163. }
  19164. var renderingIntent = 'oplist';
  19165. if (!this.intentStates[renderingIntent]) {
  19166. this.intentStates[renderingIntent] = Object.create(null);
  19167. }
  19168. var intentState = this.intentStates[renderingIntent];
  19169. var opListTask;
  19170. if (!intentState.opListReadCapability) {
  19171. opListTask = {};
  19172. opListTask.operatorListChanged = operatorListChanged;
  19173. intentState.receivingOperatorList = true;
  19174. intentState.opListReadCapability = createPromiseCapability();
  19175. intentState.renderTasks = [];
  19176. intentState.renderTasks.push(opListTask);
  19177. intentState.operatorList = {
  19178. fnArray: [],
  19179. argsArray: [],
  19180. lastChunk: false
  19181. };
  19182. this.transport.messageHandler.send('RenderPageRequest', {
  19183. pageIndex: this.pageIndex,
  19184. intent: renderingIntent
  19185. });
  19186. }
  19187. return intentState.opListReadCapability.promise;
  19188. },
  19189. getTextContent: function PDFPageProxy_getTextContent(params) {
  19190. return this.transport.messageHandler.sendWithPromise('GetTextContent', {
  19191. pageIndex: this.pageNumber - 1,
  19192. normalizeWhitespace: params && params.normalizeWhitespace === true ? true : false,
  19193. combineTextItems: params && params.disableCombineTextItems === true ? false : true
  19194. });
  19195. },
  19196. _destroy: function PDFPageProxy_destroy() {
  19197. this.destroyed = true;
  19198. this.transport.pageCache[this.pageIndex] = null;
  19199. var waitOn = [];
  19200. Object.keys(this.intentStates).forEach(function (intent) {
  19201. if (intent === 'oplist') {
  19202. return;
  19203. }
  19204. var intentState = this.intentStates[intent];
  19205. intentState.renderTasks.forEach(function (renderTask) {
  19206. var renderCompleted = renderTask.capability.promise.catch(function () {
  19207. });
  19208. waitOn.push(renderCompleted);
  19209. renderTask.cancel();
  19210. });
  19211. }, this);
  19212. this.objs.clear();
  19213. this.annotationsPromise = null;
  19214. this.pendingCleanup = false;
  19215. return Promise.all(waitOn);
  19216. },
  19217. destroy: function () {
  19218. deprecated('page destroy method, use cleanup() instead');
  19219. this.cleanup();
  19220. },
  19221. cleanup: function PDFPageProxy_cleanup() {
  19222. this.pendingCleanup = true;
  19223. this._tryCleanup();
  19224. },
  19225. _tryCleanup: function PDFPageProxy_tryCleanup() {
  19226. if (!this.pendingCleanup || Object.keys(this.intentStates).some(function (intent) {
  19227. var intentState = this.intentStates[intent];
  19228. return intentState.renderTasks.length !== 0 || intentState.receivingOperatorList;
  19229. }, this)) {
  19230. return;
  19231. }
  19232. Object.keys(this.intentStates).forEach(function (intent) {
  19233. delete this.intentStates[intent];
  19234. }, this);
  19235. this.objs.clear();
  19236. this.annotationsPromise = null;
  19237. this.pendingCleanup = false;
  19238. },
  19239. _startRenderPage: function PDFPageProxy_startRenderPage(transparency, intent) {
  19240. var intentState = this.intentStates[intent];
  19241. if (intentState.displayReadyCapability) {
  19242. intentState.displayReadyCapability.resolve(transparency);
  19243. }
  19244. },
  19245. _renderPageChunk: function PDFPageProxy_renderPageChunk(operatorListChunk, intent) {
  19246. var intentState = this.intentStates[intent];
  19247. var i, ii;
  19248. for (i = 0, ii = operatorListChunk.length; i < ii; i++) {
  19249. intentState.operatorList.fnArray.push(operatorListChunk.fnArray[i]);
  19250. intentState.operatorList.argsArray.push(operatorListChunk.argsArray[i]);
  19251. }
  19252. intentState.operatorList.lastChunk = operatorListChunk.lastChunk;
  19253. for (i = 0; i < intentState.renderTasks.length; i++) {
  19254. intentState.renderTasks[i].operatorListChanged();
  19255. }
  19256. if (operatorListChunk.lastChunk) {
  19257. intentState.receivingOperatorList = false;
  19258. this._tryCleanup();
  19259. }
  19260. }
  19261. };
  19262. return PDFPageProxy;
  19263. }();
  19264. var PDFWorker = function PDFWorkerClosure() {
  19265. var nextFakeWorkerId = 0;
  19266. function getWorkerSrc() {
  19267. if (typeof workerSrc !== 'undefined') {
  19268. return workerSrc;
  19269. }
  19270. if (getDefaultSetting('workerSrc')) {
  19271. return getDefaultSetting('workerSrc');
  19272. }
  19273. if (pdfjsFilePath) {
  19274. return pdfjsFilePath.replace(/\.js$/i, '.worker.js');
  19275. }
  19276. error('No PDFJS.workerSrc specified');
  19277. }
  19278. var fakeWorkerFilesLoadedCapability;
  19279. function setupFakeWorkerGlobal() {
  19280. var WorkerMessageHandler;
  19281. if (fakeWorkerFilesLoadedCapability) {
  19282. return fakeWorkerFilesLoadedCapability.promise;
  19283. }
  19284. fakeWorkerFilesLoadedCapability = createPromiseCapability();
  19285. var pdfjsCoreWorker = __w_pdfjs_require__(23);
  19286. __w_pdfjs_require__(39);
  19287. WorkerMessageHandler = pdfjsCoreWorker.WorkerMessageHandler;
  19288. fakeWorkerFilesLoadedCapability.resolve(WorkerMessageHandler);
  19289. return fakeWorkerFilesLoadedCapability.promise;
  19290. }
  19291. function FakeWorkerPort(defer) {
  19292. this._listeners = [];
  19293. this._defer = defer;
  19294. this._deferred = Promise.resolve(undefined);
  19295. }
  19296. FakeWorkerPort.prototype = {
  19297. postMessage: function (obj, transfers) {
  19298. function cloneValue(value) {
  19299. if (typeof value !== 'object' || value === null) {
  19300. return value;
  19301. }
  19302. if (cloned.has(value)) {
  19303. return cloned.get(value);
  19304. }
  19305. var result;
  19306. var buffer;
  19307. if ((buffer = value.buffer) && isArrayBuffer(buffer)) {
  19308. var transferable = transfers && transfers.indexOf(buffer) >= 0;
  19309. if (value === buffer) {
  19310. result = value;
  19311. } else if (transferable) {
  19312. result = new value.constructor(buffer, value.byteOffset, value.byteLength);
  19313. } else {
  19314. result = new value.constructor(value);
  19315. }
  19316. cloned.set(value, result);
  19317. return result;
  19318. }
  19319. result = isArray(value) ? [] : {};
  19320. cloned.set(value, result);
  19321. for (var i in value) {
  19322. var desc, p = value;
  19323. while (!(desc = Object.getOwnPropertyDescriptor(p, i))) {
  19324. p = Object.getPrototypeOf(p);
  19325. }
  19326. if (typeof desc.value === 'undefined' || typeof desc.value === 'function') {
  19327. continue;
  19328. }
  19329. result[i] = cloneValue(desc.value);
  19330. }
  19331. return result;
  19332. }
  19333. if (!this._defer) {
  19334. this._listeners.forEach(function (listener) {
  19335. listener.call(this, { data: obj });
  19336. }, this);
  19337. return;
  19338. }
  19339. var cloned = new WeakMap();
  19340. var e = { data: cloneValue(obj) };
  19341. this._deferred.then(function () {
  19342. this._listeners.forEach(function (listener) {
  19343. listener.call(this, e);
  19344. }, this);
  19345. }.bind(this));
  19346. },
  19347. addEventListener: function (name, listener) {
  19348. this._listeners.push(listener);
  19349. },
  19350. removeEventListener: function (name, listener) {
  19351. var i = this._listeners.indexOf(listener);
  19352. this._listeners.splice(i, 1);
  19353. },
  19354. terminate: function () {
  19355. this._listeners = [];
  19356. }
  19357. };
  19358. function createCDNWrapper(url) {
  19359. var wrapper = 'importScripts(\'' + url + '\');';
  19360. return URL.createObjectURL(new Blob([wrapper]));
  19361. }
  19362. function PDFWorker(name, port) {
  19363. this.name = name;
  19364. this.destroyed = false;
  19365. this._readyCapability = createPromiseCapability();
  19366. this._port = null;
  19367. this._webWorker = null;
  19368. this._messageHandler = null;
  19369. if (port) {
  19370. this._initializeFromPort(port);
  19371. return;
  19372. }
  19373. this._initialize();
  19374. }
  19375. PDFWorker.prototype = {
  19376. get promise() {
  19377. return this._readyCapability.promise;
  19378. },
  19379. get port() {
  19380. return this._port;
  19381. },
  19382. get messageHandler() {
  19383. return this._messageHandler;
  19384. },
  19385. _initializeFromPort: function PDFWorker_initializeFromPort(port) {
  19386. this._port = port;
  19387. this._messageHandler = new MessageHandler('main', 'worker', port);
  19388. this._messageHandler.on('ready', function () {
  19389. });
  19390. this._readyCapability.resolve();
  19391. },
  19392. _initialize: function PDFWorker_initialize() {
  19393. this._setupFakeWorker();
  19394. },
  19395. _setupFakeWorker: function PDFWorker_setupFakeWorker() {
  19396. if (!isWorkerDisabled && !getDefaultSetting('disableWorker')) {
  19397. warn('Setting up fake worker.');
  19398. isWorkerDisabled = true;
  19399. }
  19400. setupFakeWorkerGlobal().then(function (WorkerMessageHandler) {
  19401. if (this.destroyed) {
  19402. this._readyCapability.reject(new Error('Worker was destroyed'));
  19403. return;
  19404. }
  19405. var isTypedArraysPresent = Uint8Array !== Float32Array;
  19406. var port = new FakeWorkerPort(isTypedArraysPresent);
  19407. this._port = port;
  19408. var id = 'fake' + nextFakeWorkerId++;
  19409. var workerHandler = new MessageHandler(id + '_worker', id, port);
  19410. WorkerMessageHandler.setup(workerHandler, port);
  19411. var messageHandler = new MessageHandler(id, id + '_worker', port);
  19412. this._messageHandler = messageHandler;
  19413. this._readyCapability.resolve();
  19414. }.bind(this));
  19415. },
  19416. destroy: function PDFWorker_destroy() {
  19417. this.destroyed = true;
  19418. if (this._webWorker) {
  19419. this._webWorker.terminate();
  19420. this._webWorker = null;
  19421. }
  19422. this._port = null;
  19423. if (this._messageHandler) {
  19424. this._messageHandler.destroy();
  19425. this._messageHandler = null;
  19426. }
  19427. }
  19428. };
  19429. return PDFWorker;
  19430. }();
  19431. var WorkerTransport = function WorkerTransportClosure() {
  19432. function WorkerTransport(messageHandler, loadingTask, pdfDataRangeTransport, CMapReaderFactory) {
  19433. this.messageHandler = messageHandler;
  19434. this.loadingTask = loadingTask;
  19435. this.pdfDataRangeTransport = pdfDataRangeTransport;
  19436. this.commonObjs = new PDFObjects();
  19437. this.fontLoader = new FontLoader(loadingTask.docId);
  19438. this.CMapReaderFactory = new CMapReaderFactory({
  19439. baseUrl: getDefaultSetting('cMapUrl'),
  19440. isCompressed: getDefaultSetting('cMapPacked')
  19441. });
  19442. this.destroyed = false;
  19443. this.destroyCapability = null;
  19444. this._passwordCapability = null;
  19445. this.pageCache = [];
  19446. this.pagePromises = [];
  19447. this.downloadInfoCapability = createPromiseCapability();
  19448. this.setupMessageHandler();
  19449. }
  19450. WorkerTransport.prototype = {
  19451. destroy: function WorkerTransport_destroy() {
  19452. if (this.destroyCapability) {
  19453. return this.destroyCapability.promise;
  19454. }
  19455. this.destroyed = true;
  19456. this.destroyCapability = createPromiseCapability();
  19457. if (this._passwordCapability) {
  19458. this._passwordCapability.reject(new Error('Worker was destroyed during onPassword callback'));
  19459. }
  19460. var waitOn = [];
  19461. this.pageCache.forEach(function (page) {
  19462. if (page) {
  19463. waitOn.push(page._destroy());
  19464. }
  19465. });
  19466. this.pageCache = [];
  19467. this.pagePromises = [];
  19468. var self = this;
  19469. var terminated = this.messageHandler.sendWithPromise('Terminate', null);
  19470. waitOn.push(terminated);
  19471. Promise.all(waitOn).then(function () {
  19472. self.fontLoader.clear();
  19473. if (self.pdfDataRangeTransport) {
  19474. self.pdfDataRangeTransport.abort();
  19475. self.pdfDataRangeTransport = null;
  19476. }
  19477. if (self.messageHandler) {
  19478. self.messageHandler.destroy();
  19479. self.messageHandler = null;
  19480. }
  19481. self.destroyCapability.resolve();
  19482. }, this.destroyCapability.reject);
  19483. return this.destroyCapability.promise;
  19484. },
  19485. setupMessageHandler: function WorkerTransport_setupMessageHandler() {
  19486. var messageHandler = this.messageHandler;
  19487. var loadingTask = this.loadingTask;
  19488. var pdfDataRangeTransport = this.pdfDataRangeTransport;
  19489. if (pdfDataRangeTransport) {
  19490. pdfDataRangeTransport.addRangeListener(function (begin, chunk) {
  19491. messageHandler.send('OnDataRange', {
  19492. begin: begin,
  19493. chunk: chunk
  19494. });
  19495. });
  19496. pdfDataRangeTransport.addProgressListener(function (loaded) {
  19497. messageHandler.send('OnDataProgress', { loaded: loaded });
  19498. });
  19499. pdfDataRangeTransport.addProgressiveReadListener(function (chunk) {
  19500. messageHandler.send('OnDataRange', { chunk: chunk });
  19501. });
  19502. messageHandler.on('RequestDataRange', function transportDataRange(data) {
  19503. pdfDataRangeTransport.requestDataRange(data.begin, data.end);
  19504. }, this);
  19505. }
  19506. messageHandler.on('GetDoc', function transportDoc(data) {
  19507. var pdfInfo = data.pdfInfo;
  19508. this.numPages = data.pdfInfo.numPages;
  19509. var loadingTask = this.loadingTask;
  19510. var pdfDocument = new PDFDocumentProxy(pdfInfo, this, loadingTask);
  19511. this.pdfDocument = pdfDocument;
  19512. loadingTask._capability.resolve(pdfDocument);
  19513. }, this);
  19514. messageHandler.on('PasswordRequest', function transportPasswordRequest(exception) {
  19515. this._passwordCapability = createPromiseCapability();
  19516. if (loadingTask.onPassword) {
  19517. var updatePassword = function (password) {
  19518. this._passwordCapability.resolve({ password: password });
  19519. }.bind(this);
  19520. loadingTask.onPassword(updatePassword, exception.code);
  19521. } else {
  19522. this._passwordCapability.reject(new PasswordException(exception.message, exception.code));
  19523. }
  19524. return this._passwordCapability.promise;
  19525. }, this);
  19526. messageHandler.on('PasswordException', function transportPasswordException(exception) {
  19527. loadingTask._capability.reject(new PasswordException(exception.message, exception.code));
  19528. }, this);
  19529. messageHandler.on('InvalidPDF', function transportInvalidPDF(exception) {
  19530. this.loadingTask._capability.reject(new InvalidPDFException(exception.message));
  19531. }, this);
  19532. messageHandler.on('MissingPDF', function transportMissingPDF(exception) {
  19533. this.loadingTask._capability.reject(new MissingPDFException(exception.message));
  19534. }, this);
  19535. messageHandler.on('UnexpectedResponse', function transportUnexpectedResponse(exception) {
  19536. this.loadingTask._capability.reject(new UnexpectedResponseException(exception.message, exception.status));
  19537. }, this);
  19538. messageHandler.on('UnknownError', function transportUnknownError(exception) {
  19539. this.loadingTask._capability.reject(new UnknownErrorException(exception.message, exception.details));
  19540. }, this);
  19541. messageHandler.on('DataLoaded', function transportPage(data) {
  19542. this.downloadInfoCapability.resolve(data);
  19543. }, this);
  19544. messageHandler.on('PDFManagerReady', function transportPage(data) {
  19545. if (this.pdfDataRangeTransport) {
  19546. this.pdfDataRangeTransport.transportReady();
  19547. }
  19548. }, this);
  19549. messageHandler.on('StartRenderPage', function transportRender(data) {
  19550. if (this.destroyed) {
  19551. return;
  19552. }
  19553. var page = this.pageCache[data.pageIndex];
  19554. page.stats.timeEnd('Page Request');
  19555. page._startRenderPage(data.transparency, data.intent);
  19556. }, this);
  19557. messageHandler.on('RenderPageChunk', function transportRender(data) {
  19558. if (this.destroyed) {
  19559. return;
  19560. }
  19561. var page = this.pageCache[data.pageIndex];
  19562. page._renderPageChunk(data.operatorList, data.intent);
  19563. }, this);
  19564. messageHandler.on('commonobj', function transportObj(data) {
  19565. if (this.destroyed) {
  19566. return;
  19567. }
  19568. var id = data[0];
  19569. var type = data[1];
  19570. if (this.commonObjs.hasData(id)) {
  19571. return;
  19572. }
  19573. switch (type) {
  19574. case 'Font':
  19575. var exportedData = data[2];
  19576. if ('error' in exportedData) {
  19577. var exportedError = exportedData.error;
  19578. warn('Error during font loading: ' + exportedError);
  19579. this.commonObjs.resolve(id, exportedError);
  19580. break;
  19581. }
  19582. var fontRegistry = null;
  19583. if (getDefaultSetting('pdfBug') && globalScope.FontInspector && globalScope['FontInspector'].enabled) {
  19584. fontRegistry = {
  19585. registerFont: function (font, url) {
  19586. globalScope['FontInspector'].fontAdded(font, url);
  19587. }
  19588. };
  19589. }
  19590. var font = new FontFaceObject(exportedData, {
  19591. isEvalSuported: getDefaultSetting('isEvalSupported'),
  19592. disableFontFace: getDefaultSetting('disableFontFace'),
  19593. fontRegistry: fontRegistry
  19594. });
  19595. this.fontLoader.bind([font], function fontReady(fontObjs) {
  19596. this.commonObjs.resolve(id, font);
  19597. }.bind(this));
  19598. break;
  19599. case 'FontPath':
  19600. this.commonObjs.resolve(id, data[2]);
  19601. break;
  19602. default:
  19603. error('Got unknown common object type ' + type);
  19604. }
  19605. }, this);
  19606. messageHandler.on('obj', function transportObj(data) {
  19607. if (this.destroyed) {
  19608. return;
  19609. }
  19610. var id = data[0];
  19611. var pageIndex = data[1];
  19612. var type = data[2];
  19613. var pageProxy = this.pageCache[pageIndex];
  19614. var imageData;
  19615. if (pageProxy.objs.hasData(id)) {
  19616. return;
  19617. }
  19618. switch (type) {
  19619. case 'JpegStream':
  19620. imageData = data[3];
  19621. loadJpegStream(id, imageData, pageProxy.objs);
  19622. break;
  19623. case 'Image':
  19624. imageData = data[3];
  19625. pageProxy.objs.resolve(id, imageData);
  19626. var MAX_IMAGE_SIZE_TO_STORE = 8000000;
  19627. if (imageData && 'data' in imageData && imageData.data.length > MAX_IMAGE_SIZE_TO_STORE) {
  19628. pageProxy.cleanupAfterRender = true;
  19629. }
  19630. break;
  19631. default:
  19632. error('Got unknown object type ' + type);
  19633. }
  19634. }, this);
  19635. messageHandler.on('DocProgress', function transportDocProgress(data) {
  19636. if (this.destroyed) {
  19637. return;
  19638. }
  19639. var loadingTask = this.loadingTask;
  19640. if (loadingTask.onProgress) {
  19641. loadingTask.onProgress({
  19642. loaded: data.loaded,
  19643. total: data.total
  19644. });
  19645. }
  19646. }, this);
  19647. messageHandler.on('PageError', function transportError(data) {
  19648. if (this.destroyed) {
  19649. return;
  19650. }
  19651. var page = this.pageCache[data.pageNum - 1];
  19652. var intentState = page.intentStates[data.intent];
  19653. if (intentState.displayReadyCapability) {
  19654. intentState.displayReadyCapability.reject(data.error);
  19655. } else {
  19656. error(data.error);
  19657. }
  19658. if (intentState.operatorList) {
  19659. intentState.operatorList.lastChunk = true;
  19660. for (var i = 0; i < intentState.renderTasks.length; i++) {
  19661. intentState.renderTasks[i].operatorListChanged();
  19662. }
  19663. }
  19664. }, this);
  19665. messageHandler.on('UnsupportedFeature', function transportUnsupportedFeature(data) {
  19666. if (this.destroyed) {
  19667. return;
  19668. }
  19669. var featureId = data.featureId;
  19670. var loadingTask = this.loadingTask;
  19671. if (loadingTask.onUnsupportedFeature) {
  19672. loadingTask.onUnsupportedFeature(featureId);
  19673. }
  19674. _UnsupportedManager.notify(featureId);
  19675. }, this);
  19676. messageHandler.on('JpegDecode', function (data) {
  19677. if (this.destroyed) {
  19678. return Promise.reject(new Error('Worker was destroyed'));
  19679. }
  19680. if (typeof document === 'undefined') {
  19681. return Promise.reject(new Error('"document" is not defined.'));
  19682. }
  19683. var imageUrl = data[0];
  19684. var components = data[1];
  19685. if (components !== 3 && components !== 1) {
  19686. return Promise.reject(new Error('Only 3 components or 1 component can be returned'));
  19687. }
  19688. return new Promise(function (resolve, reject) {
  19689. var img = new Image();
  19690. img.onload = function () {
  19691. var width = img.width;
  19692. var height = img.height;
  19693. var size = width * height;
  19694. var rgbaLength = size * 4;
  19695. var buf = new Uint8Array(size * components);
  19696. var tmpCanvas = document.createElement('canvas');
  19697. tmpCanvas.width = width;
  19698. tmpCanvas.height = height;
  19699. var tmpCtx = tmpCanvas.getContext('2d');
  19700. tmpCtx.drawImage(img, 0, 0);
  19701. var data = tmpCtx.getImageData(0, 0, width, height).data;
  19702. var i, j;
  19703. if (components === 3) {
  19704. for (i = 0, j = 0; i < rgbaLength; i += 4, j += 3) {
  19705. buf[j] = data[i];
  19706. buf[j + 1] = data[i + 1];
  19707. buf[j + 2] = data[i + 2];
  19708. }
  19709. } else if (components === 1) {
  19710. for (i = 0, j = 0; i < rgbaLength; i += 4, j++) {
  19711. buf[j] = data[i];
  19712. }
  19713. }
  19714. resolve({
  19715. data: buf,
  19716. width: width,
  19717. height: height
  19718. });
  19719. };
  19720. img.onerror = function () {
  19721. reject(new Error('JpegDecode failed to load image'));
  19722. };
  19723. img.src = imageUrl;
  19724. });
  19725. }, this);
  19726. messageHandler.on('FetchBuiltInCMap', function (data) {
  19727. if (this.destroyed) {
  19728. return Promise.reject(new Error('Worker was destroyed'));
  19729. }
  19730. return this.CMapReaderFactory.fetch({ name: data.name });
  19731. }, this);
  19732. },
  19733. getData: function WorkerTransport_getData() {
  19734. return this.messageHandler.sendWithPromise('GetData', null);
  19735. },
  19736. getPage: function WorkerTransport_getPage(pageNumber, capability) {
  19737. if (!isInt(pageNumber) || pageNumber <= 0 || pageNumber > this.numPages) {
  19738. return Promise.reject(new Error('Invalid page request'));
  19739. }
  19740. var pageIndex = pageNumber - 1;
  19741. if (pageIndex in this.pagePromises) {
  19742. return this.pagePromises[pageIndex];
  19743. }
  19744. var promise = this.messageHandler.sendWithPromise('GetPage', { pageIndex: pageIndex }).then(function (pageInfo) {
  19745. if (this.destroyed) {
  19746. throw new Error('Transport destroyed');
  19747. }
  19748. var page = new PDFPageProxy(pageIndex, pageInfo, this);
  19749. this.pageCache[pageIndex] = page;
  19750. return page;
  19751. }.bind(this));
  19752. this.pagePromises[pageIndex] = promise;
  19753. return promise;
  19754. },
  19755. getPageIndex: function WorkerTransport_getPageIndexByRef(ref) {
  19756. return this.messageHandler.sendWithPromise('GetPageIndex', { ref: ref }).catch(function (reason) {
  19757. return Promise.reject(new Error(reason));
  19758. });
  19759. },
  19760. getAnnotations: function WorkerTransport_getAnnotations(pageIndex, intent) {
  19761. return this.messageHandler.sendWithPromise('GetAnnotations', {
  19762. pageIndex: pageIndex,
  19763. intent: intent
  19764. });
  19765. },
  19766. getDestinations: function WorkerTransport_getDestinations() {
  19767. return this.messageHandler.sendWithPromise('GetDestinations', null);
  19768. },
  19769. getDestination: function WorkerTransport_getDestination(id) {
  19770. return this.messageHandler.sendWithPromise('GetDestination', { id: id });
  19771. },
  19772. getPageLabels: function WorkerTransport_getPageLabels() {
  19773. return this.messageHandler.sendWithPromise('GetPageLabels', null);
  19774. },
  19775. getAttachments: function WorkerTransport_getAttachments() {
  19776. return this.messageHandler.sendWithPromise('GetAttachments', null);
  19777. },
  19778. getJavaScript: function WorkerTransport_getJavaScript() {
  19779. return this.messageHandler.sendWithPromise('GetJavaScript', null);
  19780. },
  19781. getOutline: function WorkerTransport_getOutline() {
  19782. return this.messageHandler.sendWithPromise('GetOutline', null);
  19783. },
  19784. getMetadata: function WorkerTransport_getMetadata() {
  19785. return this.messageHandler.sendWithPromise('GetMetadata', null).then(function transportMetadata(results) {
  19786. return {
  19787. info: results[0],
  19788. metadata: results[1] ? new Metadata(results[1]) : null
  19789. };
  19790. });
  19791. },
  19792. getStats: function WorkerTransport_getStats() {
  19793. return this.messageHandler.sendWithPromise('GetStats', null);
  19794. },
  19795. startCleanup: function WorkerTransport_startCleanup() {
  19796. this.messageHandler.sendWithPromise('Cleanup', null).then(function endCleanup() {
  19797. for (var i = 0, ii = this.pageCache.length; i < ii; i++) {
  19798. var page = this.pageCache[i];
  19799. if (page) {
  19800. page.cleanup();
  19801. }
  19802. }
  19803. this.commonObjs.clear();
  19804. this.fontLoader.clear();
  19805. }.bind(this));
  19806. }
  19807. };
  19808. return WorkerTransport;
  19809. }();
  19810. var PDFObjects = function PDFObjectsClosure() {
  19811. function PDFObjects() {
  19812. this.objs = Object.create(null);
  19813. }
  19814. PDFObjects.prototype = {
  19815. ensureObj: function PDFObjects_ensureObj(objId) {
  19816. if (this.objs[objId]) {
  19817. return this.objs[objId];
  19818. }
  19819. var obj = {
  19820. capability: createPromiseCapability(),
  19821. data: null,
  19822. resolved: false
  19823. };
  19824. this.objs[objId] = obj;
  19825. return obj;
  19826. },
  19827. get: function PDFObjects_get(objId, callback) {
  19828. if (callback) {
  19829. this.ensureObj(objId).capability.promise.then(callback);
  19830. return null;
  19831. }
  19832. var obj = this.objs[objId];
  19833. if (!obj || !obj.resolved) {
  19834. error('Requesting object that isn\'t resolved yet ' + objId);
  19835. }
  19836. return obj.data;
  19837. },
  19838. resolve: function PDFObjects_resolve(objId, data) {
  19839. var obj = this.ensureObj(objId);
  19840. obj.resolved = true;
  19841. obj.data = data;
  19842. obj.capability.resolve(data);
  19843. },
  19844. isResolved: function PDFObjects_isResolved(objId) {
  19845. var objs = this.objs;
  19846. if (!objs[objId]) {
  19847. return false;
  19848. }
  19849. return objs[objId].resolved;
  19850. },
  19851. hasData: function PDFObjects_hasData(objId) {
  19852. return this.isResolved(objId);
  19853. },
  19854. getData: function PDFObjects_getData(objId) {
  19855. var objs = this.objs;
  19856. if (!objs[objId] || !objs[objId].resolved) {
  19857. return null;
  19858. }
  19859. return objs[objId].data;
  19860. },
  19861. clear: function PDFObjects_clear() {
  19862. this.objs = Object.create(null);
  19863. }
  19864. };
  19865. return PDFObjects;
  19866. }();
  19867. var RenderTask = function RenderTaskClosure() {
  19868. function RenderTask(internalRenderTask) {
  19869. this._internalRenderTask = internalRenderTask;
  19870. this.onContinue = null;
  19871. }
  19872. RenderTask.prototype = {
  19873. get promise() {
  19874. return this._internalRenderTask.capability.promise;
  19875. },
  19876. cancel: function RenderTask_cancel() {
  19877. this._internalRenderTask.cancel();
  19878. },
  19879. then: function RenderTask_then(onFulfilled, onRejected) {
  19880. return this.promise.then.apply(this.promise, arguments);
  19881. }
  19882. };
  19883. return RenderTask;
  19884. }();
  19885. var InternalRenderTask = function InternalRenderTaskClosure() {
  19886. function InternalRenderTask(callback, params, objs, commonObjs, operatorList, pageNumber, canvasFactory) {
  19887. this.callback = callback;
  19888. this.params = params;
  19889. this.objs = objs;
  19890. this.commonObjs = commonObjs;
  19891. this.operatorListIdx = null;
  19892. this.operatorList = operatorList;
  19893. this.pageNumber = pageNumber;
  19894. this.canvasFactory = canvasFactory;
  19895. this.running = false;
  19896. this.graphicsReadyCallback = null;
  19897. this.graphicsReady = false;
  19898. this.useRequestAnimationFrame = false;
  19899. this.cancelled = false;
  19900. this.capability = createPromiseCapability();
  19901. this.task = new RenderTask(this);
  19902. this._continueBound = this._continue.bind(this);
  19903. this._scheduleNextBound = this._scheduleNext.bind(this);
  19904. this._nextBound = this._next.bind(this);
  19905. }
  19906. InternalRenderTask.prototype = {
  19907. initializeGraphics: function InternalRenderTask_initializeGraphics(transparency) {
  19908. if (this.cancelled) {
  19909. return;
  19910. }
  19911. if (getDefaultSetting('pdfBug') && globalScope.StepperManager && globalScope.StepperManager.enabled) {
  19912. this.stepper = globalScope.StepperManager.create(this.pageNumber - 1);
  19913. this.stepper.init(this.operatorList);
  19914. this.stepper.nextBreakPoint = this.stepper.getNextBreakPoint();
  19915. }
  19916. var params = this.params;
  19917. this.gfx = new CanvasGraphics(params.canvasContext, this.commonObjs, this.objs, this.canvasFactory, params.imageLayer);
  19918. this.gfx.beginDrawing(params.transform, params.viewport, transparency);
  19919. this.operatorListIdx = 0;
  19920. this.graphicsReady = true;
  19921. if (this.graphicsReadyCallback) {
  19922. this.graphicsReadyCallback();
  19923. }
  19924. },
  19925. cancel: function InternalRenderTask_cancel() {
  19926. this.running = false;
  19927. this.cancelled = true;
  19928. this.callback('cancelled');
  19929. },
  19930. operatorListChanged: function InternalRenderTask_operatorListChanged() {
  19931. if (!this.graphicsReady) {
  19932. if (!this.graphicsReadyCallback) {
  19933. this.graphicsReadyCallback = this._continueBound;
  19934. }
  19935. return;
  19936. }
  19937. if (this.stepper) {
  19938. this.stepper.updateOperatorList(this.operatorList);
  19939. }
  19940. if (this.running) {
  19941. return;
  19942. }
  19943. this._continue();
  19944. },
  19945. _continue: function InternalRenderTask__continue() {
  19946. this.running = true;
  19947. if (this.cancelled) {
  19948. return;
  19949. }
  19950. if (this.task.onContinue) {
  19951. this.task.onContinue(this._scheduleNextBound);
  19952. } else {
  19953. this._scheduleNext();
  19954. }
  19955. },
  19956. _scheduleNext: function InternalRenderTask__scheduleNext() {
  19957. if (this.useRequestAnimationFrame && typeof window !== 'undefined') {
  19958. window.requestAnimationFrame(this._nextBound);
  19959. } else {
  19960. Promise.resolve(undefined).then(this._nextBound);
  19961. }
  19962. },
  19963. _next: function InternalRenderTask__next() {
  19964. if (this.cancelled) {
  19965. return;
  19966. }
  19967. this.operatorListIdx = this.gfx.executeOperatorList(this.operatorList, this.operatorListIdx, this._continueBound, this.stepper);
  19968. if (this.operatorListIdx === this.operatorList.argsArray.length) {
  19969. this.running = false;
  19970. if (this.operatorList.lastChunk) {
  19971. this.gfx.endDrawing();
  19972. this.callback();
  19973. }
  19974. }
  19975. }
  19976. };
  19977. return InternalRenderTask;
  19978. }();
  19979. var _UnsupportedManager = function UnsupportedManagerClosure() {
  19980. var listeners = [];
  19981. return {
  19982. listen: function (cb) {
  19983. deprecated('Global UnsupportedManager.listen is used: ' + ' use PDFDocumentLoadingTask.onUnsupportedFeature instead');
  19984. listeners.push(cb);
  19985. },
  19986. notify: function (featureId) {
  19987. for (var i = 0, ii = listeners.length; i < ii; i++) {
  19988. listeners[i](featureId);
  19989. }
  19990. }
  19991. };
  19992. }();
  19993. exports.version = '1.7.374';
  19994. exports.build = 'cfc45e55';
  19995. exports.getDocument = getDocument;
  19996. exports.PDFDataRangeTransport = PDFDataRangeTransport;
  19997. exports.PDFWorker = PDFWorker;
  19998. exports.PDFDocumentProxy = PDFDocumentProxy;
  19999. exports.PDFPageProxy = PDFPageProxy;
  20000. exports._UnsupportedManager = _UnsupportedManager;
  20001. /***/ }),
  20002. /* 11 */
  20003. /***/ (function(module, exports, __w_pdfjs_require__) {
  20004. "use strict";
  20005. var sharedUtil = __w_pdfjs_require__(0);
  20006. var FONT_IDENTITY_MATRIX = sharedUtil.FONT_IDENTITY_MATRIX;
  20007. var IDENTITY_MATRIX = sharedUtil.IDENTITY_MATRIX;
  20008. var ImageKind = sharedUtil.ImageKind;
  20009. var OPS = sharedUtil.OPS;
  20010. var Util = sharedUtil.Util;
  20011. var isNum = sharedUtil.isNum;
  20012. var isArray = sharedUtil.isArray;
  20013. var warn = sharedUtil.warn;
  20014. var createObjectURL = sharedUtil.createObjectURL;
  20015. var SVG_DEFAULTS = {
  20016. fontStyle: 'normal',
  20017. fontWeight: 'normal',
  20018. fillColor: '#000000'
  20019. };
  20020. var convertImgDataToPng = function convertImgDataToPngClosure() {
  20021. var PNG_HEADER = new Uint8Array([
  20022. 0x89,
  20023. 0x50,
  20024. 0x4e,
  20025. 0x47,
  20026. 0x0d,
  20027. 0x0a,
  20028. 0x1a,
  20029. 0x0a
  20030. ]);
  20031. var CHUNK_WRAPPER_SIZE = 12;
  20032. var crcTable = new Int32Array(256);
  20033. for (var i = 0; i < 256; i++) {
  20034. var c = i;
  20035. for (var h = 0; h < 8; h++) {
  20036. if (c & 1) {
  20037. c = 0xedB88320 ^ c >> 1 & 0x7fffffff;
  20038. } else {
  20039. c = c >> 1 & 0x7fffffff;
  20040. }
  20041. }
  20042. crcTable[i] = c;
  20043. }
  20044. function crc32(data, start, end) {
  20045. var crc = -1;
  20046. for (var i = start; i < end; i++) {
  20047. var a = (crc ^ data[i]) & 0xff;
  20048. var b = crcTable[a];
  20049. crc = crc >>> 8 ^ b;
  20050. }
  20051. return crc ^ -1;
  20052. }
  20053. function writePngChunk(type, body, data, offset) {
  20054. var p = offset;
  20055. var len = body.length;
  20056. data[p] = len >> 24 & 0xff;
  20057. data[p + 1] = len >> 16 & 0xff;
  20058. data[p + 2] = len >> 8 & 0xff;
  20059. data[p + 3] = len & 0xff;
  20060. p += 4;
  20061. data[p] = type.charCodeAt(0) & 0xff;
  20062. data[p + 1] = type.charCodeAt(1) & 0xff;
  20063. data[p + 2] = type.charCodeAt(2) & 0xff;
  20064. data[p + 3] = type.charCodeAt(3) & 0xff;
  20065. p += 4;
  20066. data.set(body, p);
  20067. p += body.length;
  20068. var crc = crc32(data, offset + 4, p);
  20069. data[p] = crc >> 24 & 0xff;
  20070. data[p + 1] = crc >> 16 & 0xff;
  20071. data[p + 2] = crc >> 8 & 0xff;
  20072. data[p + 3] = crc & 0xff;
  20073. }
  20074. function adler32(data, start, end) {
  20075. var a = 1;
  20076. var b = 0;
  20077. for (var i = start; i < end; ++i) {
  20078. a = (a + (data[i] & 0xff)) % 65521;
  20079. b = (b + a) % 65521;
  20080. }
  20081. return b << 16 | a;
  20082. }
  20083. function encode(imgData, kind, forceDataSchema) {
  20084. var width = imgData.width;
  20085. var height = imgData.height;
  20086. var bitDepth, colorType, lineSize;
  20087. var bytes = imgData.data;
  20088. switch (kind) {
  20089. case ImageKind.GRAYSCALE_1BPP:
  20090. colorType = 0;
  20091. bitDepth = 1;
  20092. lineSize = width + 7 >> 3;
  20093. break;
  20094. case ImageKind.RGB_24BPP:
  20095. colorType = 2;
  20096. bitDepth = 8;
  20097. lineSize = width * 3;
  20098. break;
  20099. case ImageKind.RGBA_32BPP:
  20100. colorType = 6;
  20101. bitDepth = 8;
  20102. lineSize = width * 4;
  20103. break;
  20104. default:
  20105. throw new Error('invalid format');
  20106. }
  20107. var literals = new Uint8Array((1 + lineSize) * height);
  20108. var offsetLiterals = 0, offsetBytes = 0;
  20109. var y, i;
  20110. for (y = 0; y < height; ++y) {
  20111. literals[offsetLiterals++] = 0;
  20112. literals.set(bytes.subarray(offsetBytes, offsetBytes + lineSize), offsetLiterals);
  20113. offsetBytes += lineSize;
  20114. offsetLiterals += lineSize;
  20115. }
  20116. if (kind === ImageKind.GRAYSCALE_1BPP) {
  20117. offsetLiterals = 0;
  20118. for (y = 0; y < height; y++) {
  20119. offsetLiterals++;
  20120. for (i = 0; i < lineSize; i++) {
  20121. literals[offsetLiterals++] ^= 0xFF;
  20122. }
  20123. }
  20124. }
  20125. var ihdr = new Uint8Array([
  20126. width >> 24 & 0xff,
  20127. width >> 16 & 0xff,
  20128. width >> 8 & 0xff,
  20129. width & 0xff,
  20130. height >> 24 & 0xff,
  20131. height >> 16 & 0xff,
  20132. height >> 8 & 0xff,
  20133. height & 0xff,
  20134. bitDepth,
  20135. colorType,
  20136. 0x00,
  20137. 0x00,
  20138. 0x00
  20139. ]);
  20140. var len = literals.length;
  20141. var maxBlockLength = 0xFFFF;
  20142. var deflateBlocks = Math.ceil(len / maxBlockLength);
  20143. var idat = new Uint8Array(2 + len + deflateBlocks * 5 + 4);
  20144. var pi = 0;
  20145. idat[pi++] = 0x78;
  20146. idat[pi++] = 0x9c;
  20147. var pos = 0;
  20148. while (len > maxBlockLength) {
  20149. idat[pi++] = 0x00;
  20150. idat[pi++] = 0xff;
  20151. idat[pi++] = 0xff;
  20152. idat[pi++] = 0x00;
  20153. idat[pi++] = 0x00;
  20154. idat.set(literals.subarray(pos, pos + maxBlockLength), pi);
  20155. pi += maxBlockLength;
  20156. pos += maxBlockLength;
  20157. len -= maxBlockLength;
  20158. }
  20159. idat[pi++] = 0x01;
  20160. idat[pi++] = len & 0xff;
  20161. idat[pi++] = len >> 8 & 0xff;
  20162. idat[pi++] = ~len & 0xffff & 0xff;
  20163. idat[pi++] = (~len & 0xffff) >> 8 & 0xff;
  20164. idat.set(literals.subarray(pos), pi);
  20165. pi += literals.length - pos;
  20166. var adler = adler32(literals, 0, literals.length);
  20167. idat[pi++] = adler >> 24 & 0xff;
  20168. idat[pi++] = adler >> 16 & 0xff;
  20169. idat[pi++] = adler >> 8 & 0xff;
  20170. idat[pi++] = adler & 0xff;
  20171. var pngLength = PNG_HEADER.length + CHUNK_WRAPPER_SIZE * 3 + ihdr.length + idat.length;
  20172. var data = new Uint8Array(pngLength);
  20173. var offset = 0;
  20174. data.set(PNG_HEADER, offset);
  20175. offset += PNG_HEADER.length;
  20176. writePngChunk('IHDR', ihdr, data, offset);
  20177. offset += CHUNK_WRAPPER_SIZE + ihdr.length;
  20178. writePngChunk('IDATA', idat, data, offset);
  20179. offset += CHUNK_WRAPPER_SIZE + idat.length;
  20180. writePngChunk('IEND', new Uint8Array(0), data, offset);
  20181. return createObjectURL(data, 'image/png', forceDataSchema);
  20182. }
  20183. return function convertImgDataToPng(imgData, forceDataSchema) {
  20184. var kind = imgData.kind === undefined ? ImageKind.GRAYSCALE_1BPP : imgData.kind;
  20185. return encode(imgData, kind, forceDataSchema);
  20186. };
  20187. }();
  20188. var SVGExtraState = function SVGExtraStateClosure() {
  20189. function SVGExtraState() {
  20190. this.fontSizeScale = 1;
  20191. this.fontWeight = SVG_DEFAULTS.fontWeight;
  20192. this.fontSize = 0;
  20193. this.textMatrix = IDENTITY_MATRIX;
  20194. this.fontMatrix = FONT_IDENTITY_MATRIX;
  20195. this.leading = 0;
  20196. this.x = 0;
  20197. this.y = 0;
  20198. this.lineX = 0;
  20199. this.lineY = 0;
  20200. this.charSpacing = 0;
  20201. this.wordSpacing = 0;
  20202. this.textHScale = 1;
  20203. this.textRise = 0;
  20204. this.fillColor = SVG_DEFAULTS.fillColor;
  20205. this.strokeColor = '#000000';
  20206. this.fillAlpha = 1;
  20207. this.strokeAlpha = 1;
  20208. this.lineWidth = 1;
  20209. this.lineJoin = '';
  20210. this.lineCap = '';
  20211. this.miterLimit = 0;
  20212. this.dashArray = [];
  20213. this.dashPhase = 0;
  20214. this.dependencies = [];
  20215. this.activeClipUrl = null;
  20216. this.clipGroup = null;
  20217. this.maskId = '';
  20218. }
  20219. SVGExtraState.prototype = {
  20220. clone: function SVGExtraState_clone() {
  20221. return Object.create(this);
  20222. },
  20223. setCurrentPoint: function SVGExtraState_setCurrentPoint(x, y) {
  20224. this.x = x;
  20225. this.y = y;
  20226. }
  20227. };
  20228. return SVGExtraState;
  20229. }();
  20230. var SVGGraphics = function SVGGraphicsClosure() {
  20231. function opListToTree(opList) {
  20232. var opTree = [];
  20233. var tmp = [];
  20234. var opListLen = opList.length;
  20235. for (var x = 0; x < opListLen; x++) {
  20236. if (opList[x].fn === 'save') {
  20237. opTree.push({
  20238. 'fnId': 92,
  20239. 'fn': 'group',
  20240. 'items': []
  20241. });
  20242. tmp.push(opTree);
  20243. opTree = opTree[opTree.length - 1].items;
  20244. continue;
  20245. }
  20246. if (opList[x].fn === 'restore') {
  20247. opTree = tmp.pop();
  20248. } else {
  20249. opTree.push(opList[x]);
  20250. }
  20251. }
  20252. return opTree;
  20253. }
  20254. function pf(value) {
  20255. if (value === (value | 0)) {
  20256. return value.toString();
  20257. }
  20258. var s = value.toFixed(10);
  20259. var i = s.length - 1;
  20260. if (s[i] !== '0') {
  20261. return s;
  20262. }
  20263. do {
  20264. i--;
  20265. } while (s[i] === '0');
  20266. return s.substr(0, s[i] === '.' ? i : i + 1);
  20267. }
  20268. function pm(m) {
  20269. if (m[4] === 0 && m[5] === 0) {
  20270. if (m[1] === 0 && m[2] === 0) {
  20271. if (m[0] === 1 && m[3] === 1) {
  20272. return '';
  20273. }
  20274. return 'scale(' + pf(m[0]) + ' ' + pf(m[3]) + ')';
  20275. }
  20276. if (m[0] === m[3] && m[1] === -m[2]) {
  20277. var a = Math.acos(m[0]) * 180 / Math.PI;
  20278. return 'rotate(' + pf(a) + ')';
  20279. }
  20280. } else {
  20281. if (m[0] === 1 && m[1] === 0 && m[2] === 0 && m[3] === 1) {
  20282. return 'translate(' + pf(m[4]) + ' ' + pf(m[5]) + ')';
  20283. }
  20284. }
  20285. return 'matrix(' + pf(m[0]) + ' ' + pf(m[1]) + ' ' + pf(m[2]) + ' ' + pf(m[3]) + ' ' + pf(m[4]) + ' ' + pf(m[5]) + ')';
  20286. }
  20287. function SVGGraphics(commonObjs, objs, forceDataSchema) {
  20288. this.current = new SVGExtraState();
  20289. this.transformMatrix = IDENTITY_MATRIX;
  20290. this.transformStack = [];
  20291. this.extraStack = [];
  20292. this.commonObjs = commonObjs;
  20293. this.objs = objs;
  20294. this.pendingEOFill = false;
  20295. this.embedFonts = false;
  20296. this.embeddedFonts = Object.create(null);
  20297. this.cssStyle = null;
  20298. this.forceDataSchema = !!forceDataSchema;
  20299. }
  20300. var NS = 'http://www.w3.org/2000/svg';
  20301. var XML_NS = 'http://www.w3.org/XML/1998/namespace';
  20302. var XLINK_NS = 'http://www.w3.org/1999/xlink';
  20303. var LINE_CAP_STYLES = [
  20304. 'butt',
  20305. 'round',
  20306. 'square'
  20307. ];
  20308. var LINE_JOIN_STYLES = [
  20309. 'miter',
  20310. 'round',
  20311. 'bevel'
  20312. ];
  20313. var clipCount = 0;
  20314. var maskCount = 0;
  20315. SVGGraphics.prototype = {
  20316. save: function SVGGraphics_save() {
  20317. this.transformStack.push(this.transformMatrix);
  20318. var old = this.current;
  20319. this.extraStack.push(old);
  20320. this.current = old.clone();
  20321. },
  20322. restore: function SVGGraphics_restore() {
  20323. this.transformMatrix = this.transformStack.pop();
  20324. this.current = this.extraStack.pop();
  20325. this.tgrp = null;
  20326. },
  20327. group: function SVGGraphics_group(items) {
  20328. this.save();
  20329. this.executeOpTree(items);
  20330. this.restore();
  20331. },
  20332. loadDependencies: function SVGGraphics_loadDependencies(operatorList) {
  20333. var fnArray = operatorList.fnArray;
  20334. var fnArrayLen = fnArray.length;
  20335. var argsArray = operatorList.argsArray;
  20336. var self = this;
  20337. for (var i = 0; i < fnArrayLen; i++) {
  20338. if (OPS.dependency === fnArray[i]) {
  20339. var deps = argsArray[i];
  20340. for (var n = 0, nn = deps.length; n < nn; n++) {
  20341. var obj = deps[n];
  20342. var common = obj.substring(0, 2) === 'g_';
  20343. var promise;
  20344. if (common) {
  20345. promise = new Promise(function (resolve) {
  20346. self.commonObjs.get(obj, resolve);
  20347. });
  20348. } else {
  20349. promise = new Promise(function (resolve) {
  20350. self.objs.get(obj, resolve);
  20351. });
  20352. }
  20353. this.current.dependencies.push(promise);
  20354. }
  20355. }
  20356. }
  20357. return Promise.all(this.current.dependencies);
  20358. },
  20359. transform: function SVGGraphics_transform(a, b, c, d, e, f) {
  20360. var transformMatrix = [
  20361. a,
  20362. b,
  20363. c,
  20364. d,
  20365. e,
  20366. f
  20367. ];
  20368. this.transformMatrix = Util.transform(this.transformMatrix, transformMatrix);
  20369. this.tgrp = null;
  20370. },
  20371. getSVG: function SVGGraphics_getSVG(operatorList, viewport) {
  20372. this.viewport = viewport;
  20373. var svgElement = this._initialize(viewport);
  20374. return this.loadDependencies(operatorList).then(function () {
  20375. this.transformMatrix = IDENTITY_MATRIX;
  20376. var opTree = this.convertOpList(operatorList);
  20377. this.executeOpTree(opTree);
  20378. return svgElement;
  20379. }.bind(this));
  20380. },
  20381. convertOpList: function SVGGraphics_convertOpList(operatorList) {
  20382. var argsArray = operatorList.argsArray;
  20383. var fnArray = operatorList.fnArray;
  20384. var fnArrayLen = fnArray.length;
  20385. var REVOPS = [];
  20386. var opList = [];
  20387. for (var op in OPS) {
  20388. REVOPS[OPS[op]] = op;
  20389. }
  20390. for (var x = 0; x < fnArrayLen; x++) {
  20391. var fnId = fnArray[x];
  20392. opList.push({
  20393. 'fnId': fnId,
  20394. 'fn': REVOPS[fnId],
  20395. 'args': argsArray[x]
  20396. });
  20397. }
  20398. return opListToTree(opList);
  20399. },
  20400. executeOpTree: function SVGGraphics_executeOpTree(opTree) {
  20401. var opTreeLen = opTree.length;
  20402. for (var x = 0; x < opTreeLen; x++) {
  20403. var fn = opTree[x].fn;
  20404. var fnId = opTree[x].fnId;
  20405. var args = opTree[x].args;
  20406. switch (fnId | 0) {
  20407. case OPS.beginText:
  20408. this.beginText();
  20409. break;
  20410. case OPS.setLeading:
  20411. this.setLeading(args);
  20412. break;
  20413. case OPS.setLeadingMoveText:
  20414. this.setLeadingMoveText(args[0], args[1]);
  20415. break;
  20416. case OPS.setFont:
  20417. this.setFont(args);
  20418. break;
  20419. case OPS.showText:
  20420. this.showText(args[0]);
  20421. break;
  20422. case OPS.showSpacedText:
  20423. this.showText(args[0]);
  20424. break;
  20425. case OPS.endText:
  20426. this.endText();
  20427. break;
  20428. case OPS.moveText:
  20429. this.moveText(args[0], args[1]);
  20430. break;
  20431. case OPS.setCharSpacing:
  20432. this.setCharSpacing(args[0]);
  20433. break;
  20434. case OPS.setWordSpacing:
  20435. this.setWordSpacing(args[0]);
  20436. break;
  20437. case OPS.setHScale:
  20438. this.setHScale(args[0]);
  20439. break;
  20440. case OPS.setTextMatrix:
  20441. this.setTextMatrix(args[0], args[1], args[2], args[3], args[4], args[5]);
  20442. break;
  20443. case OPS.setLineWidth:
  20444. this.setLineWidth(args[0]);
  20445. break;
  20446. case OPS.setLineJoin:
  20447. this.setLineJoin(args[0]);
  20448. break;
  20449. case OPS.setLineCap:
  20450. this.setLineCap(args[0]);
  20451. break;
  20452. case OPS.setMiterLimit:
  20453. this.setMiterLimit(args[0]);
  20454. break;
  20455. case OPS.setFillRGBColor:
  20456. this.setFillRGBColor(args[0], args[1], args[2]);
  20457. break;
  20458. case OPS.setStrokeRGBColor:
  20459. this.setStrokeRGBColor(args[0], args[1], args[2]);
  20460. break;
  20461. case OPS.setDash:
  20462. this.setDash(args[0], args[1]);
  20463. break;
  20464. case OPS.setGState:
  20465. this.setGState(args[0]);
  20466. break;
  20467. case OPS.fill:
  20468. this.fill();
  20469. break;
  20470. case OPS.eoFill:
  20471. this.eoFill();
  20472. break;
  20473. case OPS.stroke:
  20474. this.stroke();
  20475. break;
  20476. case OPS.fillStroke:
  20477. this.fillStroke();
  20478. break;
  20479. case OPS.eoFillStroke:
  20480. this.eoFillStroke();
  20481. break;
  20482. case OPS.clip:
  20483. this.clip('nonzero');
  20484. break;
  20485. case OPS.eoClip:
  20486. this.clip('evenodd');
  20487. break;
  20488. case OPS.paintSolidColorImageMask:
  20489. this.paintSolidColorImageMask();
  20490. break;
  20491. case OPS.paintJpegXObject:
  20492. this.paintJpegXObject(args[0], args[1], args[2]);
  20493. break;
  20494. case OPS.paintImageXObject:
  20495. this.paintImageXObject(args[0]);
  20496. break;
  20497. case OPS.paintInlineImageXObject:
  20498. this.paintInlineImageXObject(args[0]);
  20499. break;
  20500. case OPS.paintImageMaskXObject:
  20501. this.paintImageMaskXObject(args[0]);
  20502. break;
  20503. case OPS.paintFormXObjectBegin:
  20504. this.paintFormXObjectBegin(args[0], args[1]);
  20505. break;
  20506. case OPS.paintFormXObjectEnd:
  20507. this.paintFormXObjectEnd();
  20508. break;
  20509. case OPS.closePath:
  20510. this.closePath();
  20511. break;
  20512. case OPS.closeStroke:
  20513. this.closeStroke();
  20514. break;
  20515. case OPS.closeFillStroke:
  20516. this.closeFillStroke();
  20517. break;
  20518. case OPS.nextLine:
  20519. this.nextLine();
  20520. break;
  20521. case OPS.transform:
  20522. this.transform(args[0], args[1], args[2], args[3], args[4], args[5]);
  20523. break;
  20524. case OPS.constructPath:
  20525. this.constructPath(args[0], args[1]);
  20526. break;
  20527. case OPS.endPath:
  20528. this.endPath();
  20529. break;
  20530. case 92:
  20531. this.group(opTree[x].items);
  20532. break;
  20533. default:
  20534. warn('Unimplemented operator ' + fn);
  20535. break;
  20536. }
  20537. }
  20538. },
  20539. setWordSpacing: function SVGGraphics_setWordSpacing(wordSpacing) {
  20540. this.current.wordSpacing = wordSpacing;
  20541. },
  20542. setCharSpacing: function SVGGraphics_setCharSpacing(charSpacing) {
  20543. this.current.charSpacing = charSpacing;
  20544. },
  20545. nextLine: function SVGGraphics_nextLine() {
  20546. this.moveText(0, this.current.leading);
  20547. },
  20548. setTextMatrix: function SVGGraphics_setTextMatrix(a, b, c, d, e, f) {
  20549. var current = this.current;
  20550. this.current.textMatrix = this.current.lineMatrix = [
  20551. a,
  20552. b,
  20553. c,
  20554. d,
  20555. e,
  20556. f
  20557. ];
  20558. this.current.x = this.current.lineX = 0;
  20559. this.current.y = this.current.lineY = 0;
  20560. current.xcoords = [];
  20561. current.tspan = document.createElementNS(NS, 'svg:tspan');
  20562. current.tspan.setAttributeNS(null, 'font-family', current.fontFamily);
  20563. current.tspan.setAttributeNS(null, 'font-size', pf(current.fontSize) + 'px');
  20564. current.tspan.setAttributeNS(null, 'y', pf(-current.y));
  20565. current.txtElement = document.createElementNS(NS, 'svg:text');
  20566. current.txtElement.appendChild(current.tspan);
  20567. },
  20568. beginText: function SVGGraphics_beginText() {
  20569. this.current.x = this.current.lineX = 0;
  20570. this.current.y = this.current.lineY = 0;
  20571. this.current.textMatrix = IDENTITY_MATRIX;
  20572. this.current.lineMatrix = IDENTITY_MATRIX;
  20573. this.current.tspan = document.createElementNS(NS, 'svg:tspan');
  20574. this.current.txtElement = document.createElementNS(NS, 'svg:text');
  20575. this.current.txtgrp = document.createElementNS(NS, 'svg:g');
  20576. this.current.xcoords = [];
  20577. },
  20578. moveText: function SVGGraphics_moveText(x, y) {
  20579. var current = this.current;
  20580. this.current.x = this.current.lineX += x;
  20581. this.current.y = this.current.lineY += y;
  20582. current.xcoords = [];
  20583. current.tspan = document.createElementNS(NS, 'svg:tspan');
  20584. current.tspan.setAttributeNS(null, 'font-family', current.fontFamily);
  20585. current.tspan.setAttributeNS(null, 'font-size', pf(current.fontSize) + 'px');
  20586. current.tspan.setAttributeNS(null, 'y', pf(-current.y));
  20587. },
  20588. showText: function SVGGraphics_showText(glyphs) {
  20589. var current = this.current;
  20590. var font = current.font;
  20591. var fontSize = current.fontSize;
  20592. if (fontSize === 0) {
  20593. return;
  20594. }
  20595. var charSpacing = current.charSpacing;
  20596. var wordSpacing = current.wordSpacing;
  20597. var fontDirection = current.fontDirection;
  20598. var textHScale = current.textHScale * fontDirection;
  20599. var glyphsLength = glyphs.length;
  20600. var vertical = font.vertical;
  20601. var widthAdvanceScale = fontSize * current.fontMatrix[0];
  20602. var x = 0, i;
  20603. for (i = 0; i < glyphsLength; ++i) {
  20604. var glyph = glyphs[i];
  20605. if (glyph === null) {
  20606. x += fontDirection * wordSpacing;
  20607. continue;
  20608. } else if (isNum(glyph)) {
  20609. x += -glyph * fontSize * 0.001;
  20610. continue;
  20611. }
  20612. current.xcoords.push(current.x + x * textHScale);
  20613. var width = glyph.width;
  20614. var character = glyph.fontChar;
  20615. var charWidth = width * widthAdvanceScale + charSpacing * fontDirection;
  20616. x += charWidth;
  20617. current.tspan.textContent += character;
  20618. }
  20619. if (vertical) {
  20620. current.y -= x * textHScale;
  20621. } else {
  20622. current.x += x * textHScale;
  20623. }
  20624. current.tspan.setAttributeNS(null, 'x', current.xcoords.map(pf).join(' '));
  20625. current.tspan.setAttributeNS(null, 'y', pf(-current.y));
  20626. current.tspan.setAttributeNS(null, 'font-family', current.fontFamily);
  20627. current.tspan.setAttributeNS(null, 'font-size', pf(current.fontSize) + 'px');
  20628. if (current.fontStyle !== SVG_DEFAULTS.fontStyle) {
  20629. current.tspan.setAttributeNS(null, 'font-style', current.fontStyle);
  20630. }
  20631. if (current.fontWeight !== SVG_DEFAULTS.fontWeight) {
  20632. current.tspan.setAttributeNS(null, 'font-weight', current.fontWeight);
  20633. }
  20634. if (current.fillColor !== SVG_DEFAULTS.fillColor) {
  20635. current.tspan.setAttributeNS(null, 'fill', current.fillColor);
  20636. }
  20637. current.txtElement.setAttributeNS(null, 'transform', pm(current.textMatrix) + ' scale(1, -1)');
  20638. current.txtElement.setAttributeNS(XML_NS, 'xml:space', 'preserve');
  20639. current.txtElement.appendChild(current.tspan);
  20640. current.txtgrp.appendChild(current.txtElement);
  20641. this._ensureTransformGroup().appendChild(current.txtElement);
  20642. },
  20643. setLeadingMoveText: function SVGGraphics_setLeadingMoveText(x, y) {
  20644. this.setLeading(-y);
  20645. this.moveText(x, y);
  20646. },
  20647. addFontStyle: function SVGGraphics_addFontStyle(fontObj) {
  20648. if (!this.cssStyle) {
  20649. this.cssStyle = document.createElementNS(NS, 'svg:style');
  20650. this.cssStyle.setAttributeNS(null, 'type', 'text/css');
  20651. this.defs.appendChild(this.cssStyle);
  20652. }
  20653. var url = createObjectURL(fontObj.data, fontObj.mimetype, this.forceDataSchema);
  20654. this.cssStyle.textContent += '@font-face { font-family: "' + fontObj.loadedName + '";' + ' src: url(' + url + '); }\n';
  20655. },
  20656. setFont: function SVGGraphics_setFont(details) {
  20657. var current = this.current;
  20658. var fontObj = this.commonObjs.get(details[0]);
  20659. var size = details[1];
  20660. this.current.font = fontObj;
  20661. if (this.embedFonts && fontObj.data && !this.embeddedFonts[fontObj.loadedName]) {
  20662. this.addFontStyle(fontObj);
  20663. this.embeddedFonts[fontObj.loadedName] = fontObj;
  20664. }
  20665. current.fontMatrix = fontObj.fontMatrix ? fontObj.fontMatrix : FONT_IDENTITY_MATRIX;
  20666. var bold = fontObj.black ? fontObj.bold ? 'bolder' : 'bold' : fontObj.bold ? 'bold' : 'normal';
  20667. var italic = fontObj.italic ? 'italic' : 'normal';
  20668. if (size < 0) {
  20669. size = -size;
  20670. current.fontDirection = -1;
  20671. } else {
  20672. current.fontDirection = 1;
  20673. }
  20674. current.fontSize = size;
  20675. current.fontFamily = fontObj.loadedName;
  20676. current.fontWeight = bold;
  20677. current.fontStyle = italic;
  20678. current.tspan = document.createElementNS(NS, 'svg:tspan');
  20679. current.tspan.setAttributeNS(null, 'y', pf(-current.y));
  20680. current.xcoords = [];
  20681. },
  20682. endText: function SVGGraphics_endText() {
  20683. },
  20684. setLineWidth: function SVGGraphics_setLineWidth(width) {
  20685. this.current.lineWidth = width;
  20686. },
  20687. setLineCap: function SVGGraphics_setLineCap(style) {
  20688. this.current.lineCap = LINE_CAP_STYLES[style];
  20689. },
  20690. setLineJoin: function SVGGraphics_setLineJoin(style) {
  20691. this.current.lineJoin = LINE_JOIN_STYLES[style];
  20692. },
  20693. setMiterLimit: function SVGGraphics_setMiterLimit(limit) {
  20694. this.current.miterLimit = limit;
  20695. },
  20696. setStrokeRGBColor: function SVGGraphics_setStrokeRGBColor(r, g, b) {
  20697. var color = Util.makeCssRgb(r, g, b);
  20698. this.current.strokeColor = color;
  20699. },
  20700. setFillRGBColor: function SVGGraphics_setFillRGBColor(r, g, b) {
  20701. var color = Util.makeCssRgb(r, g, b);
  20702. this.current.fillColor = color;
  20703. this.current.tspan = document.createElementNS(NS, 'svg:tspan');
  20704. this.current.xcoords = [];
  20705. },
  20706. setDash: function SVGGraphics_setDash(dashArray, dashPhase) {
  20707. this.current.dashArray = dashArray;
  20708. this.current.dashPhase = dashPhase;
  20709. },
  20710. constructPath: function SVGGraphics_constructPath(ops, args) {
  20711. var current = this.current;
  20712. var x = current.x, y = current.y;
  20713. current.path = document.createElementNS(NS, 'svg:path');
  20714. var d = [];
  20715. var opLength = ops.length;
  20716. for (var i = 0, j = 0; i < opLength; i++) {
  20717. switch (ops[i] | 0) {
  20718. case OPS.rectangle:
  20719. x = args[j++];
  20720. y = args[j++];
  20721. var width = args[j++];
  20722. var height = args[j++];
  20723. var xw = x + width;
  20724. var yh = y + height;
  20725. d.push('M', pf(x), pf(y), 'L', pf(xw), pf(y), 'L', pf(xw), pf(yh), 'L', pf(x), pf(yh), 'Z');
  20726. break;
  20727. case OPS.moveTo:
  20728. x = args[j++];
  20729. y = args[j++];
  20730. d.push('M', pf(x), pf(y));
  20731. break;
  20732. case OPS.lineTo:
  20733. x = args[j++];
  20734. y = args[j++];
  20735. d.push('L', pf(x), pf(y));
  20736. break;
  20737. case OPS.curveTo:
  20738. x = args[j + 4];
  20739. y = args[j + 5];
  20740. d.push('C', pf(args[j]), pf(args[j + 1]), pf(args[j + 2]), pf(args[j + 3]), pf(x), pf(y));
  20741. j += 6;
  20742. break;
  20743. case OPS.curveTo2:
  20744. x = args[j + 2];
  20745. y = args[j + 3];
  20746. d.push('C', pf(x), pf(y), pf(args[j]), pf(args[j + 1]), pf(args[j + 2]), pf(args[j + 3]));
  20747. j += 4;
  20748. break;
  20749. case OPS.curveTo3:
  20750. x = args[j + 2];
  20751. y = args[j + 3];
  20752. d.push('C', pf(args[j]), pf(args[j + 1]), pf(x), pf(y), pf(x), pf(y));
  20753. j += 4;
  20754. break;
  20755. case OPS.closePath:
  20756. d.push('Z');
  20757. break;
  20758. }
  20759. }
  20760. current.path.setAttributeNS(null, 'd', d.join(' '));
  20761. current.path.setAttributeNS(null, 'stroke-miterlimit', pf(current.miterLimit));
  20762. current.path.setAttributeNS(null, 'stroke-linecap', current.lineCap);
  20763. current.path.setAttributeNS(null, 'stroke-linejoin', current.lineJoin);
  20764. current.path.setAttributeNS(null, 'stroke-width', pf(current.lineWidth) + 'px');
  20765. current.path.setAttributeNS(null, 'stroke-dasharray', current.dashArray.map(pf).join(' '));
  20766. current.path.setAttributeNS(null, 'stroke-dashoffset', pf(current.dashPhase) + 'px');
  20767. current.path.setAttributeNS(null, 'fill', 'none');
  20768. this._ensureTransformGroup().appendChild(current.path);
  20769. current.element = current.path;
  20770. current.setCurrentPoint(x, y);
  20771. },
  20772. endPath: function SVGGraphics_endPath() {
  20773. },
  20774. clip: function SVGGraphics_clip(type) {
  20775. var current = this.current;
  20776. var clipId = 'clippath' + clipCount;
  20777. clipCount++;
  20778. var clipPath = document.createElementNS(NS, 'svg:clipPath');
  20779. clipPath.setAttributeNS(null, 'id', clipId);
  20780. clipPath.setAttributeNS(null, 'transform', pm(this.transformMatrix));
  20781. var clipElement = current.element.cloneNode();
  20782. if (type === 'evenodd') {
  20783. clipElement.setAttributeNS(null, 'clip-rule', 'evenodd');
  20784. } else {
  20785. clipElement.setAttributeNS(null, 'clip-rule', 'nonzero');
  20786. }
  20787. clipPath.appendChild(clipElement);
  20788. this.defs.appendChild(clipPath);
  20789. if (current.activeClipUrl) {
  20790. current.clipGroup = null;
  20791. this.extraStack.forEach(function (prev) {
  20792. prev.clipGroup = null;
  20793. });
  20794. }
  20795. current.activeClipUrl = 'url(#' + clipId + ')';
  20796. this.tgrp = null;
  20797. },
  20798. closePath: function SVGGraphics_closePath() {
  20799. var current = this.current;
  20800. var d = current.path.getAttributeNS(null, 'd');
  20801. d += 'Z';
  20802. current.path.setAttributeNS(null, 'd', d);
  20803. },
  20804. setLeading: function SVGGraphics_setLeading(leading) {
  20805. this.current.leading = -leading;
  20806. },
  20807. setTextRise: function SVGGraphics_setTextRise(textRise) {
  20808. this.current.textRise = textRise;
  20809. },
  20810. setHScale: function SVGGraphics_setHScale(scale) {
  20811. this.current.textHScale = scale / 100;
  20812. },
  20813. setGState: function SVGGraphics_setGState(states) {
  20814. for (var i = 0, ii = states.length; i < ii; i++) {
  20815. var state = states[i];
  20816. var key = state[0];
  20817. var value = state[1];
  20818. switch (key) {
  20819. case 'LW':
  20820. this.setLineWidth(value);
  20821. break;
  20822. case 'LC':
  20823. this.setLineCap(value);
  20824. break;
  20825. case 'LJ':
  20826. this.setLineJoin(value);
  20827. break;
  20828. case 'ML':
  20829. this.setMiterLimit(value);
  20830. break;
  20831. case 'D':
  20832. this.setDash(value[0], value[1]);
  20833. break;
  20834. case 'Font':
  20835. this.setFont(value);
  20836. break;
  20837. default:
  20838. warn('Unimplemented graphic state ' + key);
  20839. break;
  20840. }
  20841. }
  20842. },
  20843. fill: function SVGGraphics_fill() {
  20844. var current = this.current;
  20845. current.element.setAttributeNS(null, 'fill', current.fillColor);
  20846. },
  20847. stroke: function SVGGraphics_stroke() {
  20848. var current = this.current;
  20849. current.element.setAttributeNS(null, 'stroke', current.strokeColor);
  20850. current.element.setAttributeNS(null, 'fill', 'none');
  20851. },
  20852. eoFill: function SVGGraphics_eoFill() {
  20853. var current = this.current;
  20854. current.element.setAttributeNS(null, 'fill', current.fillColor);
  20855. current.element.setAttributeNS(null, 'fill-rule', 'evenodd');
  20856. },
  20857. fillStroke: function SVGGraphics_fillStroke() {
  20858. this.stroke();
  20859. this.fill();
  20860. },
  20861. eoFillStroke: function SVGGraphics_eoFillStroke() {
  20862. this.current.element.setAttributeNS(null, 'fill-rule', 'evenodd');
  20863. this.fillStroke();
  20864. },
  20865. closeStroke: function SVGGraphics_closeStroke() {
  20866. this.closePath();
  20867. this.stroke();
  20868. },
  20869. closeFillStroke: function SVGGraphics_closeFillStroke() {
  20870. this.closePath();
  20871. this.fillStroke();
  20872. },
  20873. paintSolidColorImageMask: function SVGGraphics_paintSolidColorImageMask() {
  20874. var current = this.current;
  20875. var rect = document.createElementNS(NS, 'svg:rect');
  20876. rect.setAttributeNS(null, 'x', '0');
  20877. rect.setAttributeNS(null, 'y', '0');
  20878. rect.setAttributeNS(null, 'width', '1px');
  20879. rect.setAttributeNS(null, 'height', '1px');
  20880. rect.setAttributeNS(null, 'fill', current.fillColor);
  20881. this._ensureTransformGroup().appendChild(rect);
  20882. },
  20883. paintJpegXObject: function SVGGraphics_paintJpegXObject(objId, w, h) {
  20884. var imgObj = this.objs.get(objId);
  20885. var imgEl = document.createElementNS(NS, 'svg:image');
  20886. imgEl.setAttributeNS(XLINK_NS, 'xlink:href', imgObj.src);
  20887. imgEl.setAttributeNS(null, 'width', imgObj.width + 'px');
  20888. imgEl.setAttributeNS(null, 'height', imgObj.height + 'px');
  20889. imgEl.setAttributeNS(null, 'x', '0');
  20890. imgEl.setAttributeNS(null, 'y', pf(-h));
  20891. imgEl.setAttributeNS(null, 'transform', 'scale(' + pf(1 / w) + ' ' + pf(-1 / h) + ')');
  20892. this._ensureTransformGroup().appendChild(imgEl);
  20893. },
  20894. paintImageXObject: function SVGGraphics_paintImageXObject(objId) {
  20895. var imgData = this.objs.get(objId);
  20896. if (!imgData) {
  20897. warn('Dependent image isn\'t ready yet');
  20898. return;
  20899. }
  20900. this.paintInlineImageXObject(imgData);
  20901. },
  20902. paintInlineImageXObject: function SVGGraphics_paintInlineImageXObject(imgData, mask) {
  20903. var width = imgData.width;
  20904. var height = imgData.height;
  20905. var imgSrc = convertImgDataToPng(imgData, this.forceDataSchema);
  20906. var cliprect = document.createElementNS(NS, 'svg:rect');
  20907. cliprect.setAttributeNS(null, 'x', '0');
  20908. cliprect.setAttributeNS(null, 'y', '0');
  20909. cliprect.setAttributeNS(null, 'width', pf(width));
  20910. cliprect.setAttributeNS(null, 'height', pf(height));
  20911. this.current.element = cliprect;
  20912. this.clip('nonzero');
  20913. var imgEl = document.createElementNS(NS, 'svg:image');
  20914. imgEl.setAttributeNS(XLINK_NS, 'xlink:href', imgSrc);
  20915. imgEl.setAttributeNS(null, 'x', '0');
  20916. imgEl.setAttributeNS(null, 'y', pf(-height));
  20917. imgEl.setAttributeNS(null, 'width', pf(width) + 'px');
  20918. imgEl.setAttributeNS(null, 'height', pf(height) + 'px');
  20919. imgEl.setAttributeNS(null, 'transform', 'scale(' + pf(1 / width) + ' ' + pf(-1 / height) + ')');
  20920. if (mask) {
  20921. mask.appendChild(imgEl);
  20922. } else {
  20923. this._ensureTransformGroup().appendChild(imgEl);
  20924. }
  20925. },
  20926. paintImageMaskXObject: function SVGGraphics_paintImageMaskXObject(imgData) {
  20927. var current = this.current;
  20928. var width = imgData.width;
  20929. var height = imgData.height;
  20930. var fillColor = current.fillColor;
  20931. current.maskId = 'mask' + maskCount++;
  20932. var mask = document.createElementNS(NS, 'svg:mask');
  20933. mask.setAttributeNS(null, 'id', current.maskId);
  20934. var rect = document.createElementNS(NS, 'svg:rect');
  20935. rect.setAttributeNS(null, 'x', '0');
  20936. rect.setAttributeNS(null, 'y', '0');
  20937. rect.setAttributeNS(null, 'width', pf(width));
  20938. rect.setAttributeNS(null, 'height', pf(height));
  20939. rect.setAttributeNS(null, 'fill', fillColor);
  20940. rect.setAttributeNS(null, 'mask', 'url(#' + current.maskId + ')');
  20941. this.defs.appendChild(mask);
  20942. this._ensureTransformGroup().appendChild(rect);
  20943. this.paintInlineImageXObject(imgData, mask);
  20944. },
  20945. paintFormXObjectBegin: function SVGGraphics_paintFormXObjectBegin(matrix, bbox) {
  20946. if (isArray(matrix) && matrix.length === 6) {
  20947. this.transform(matrix[0], matrix[1], matrix[2], matrix[3], matrix[4], matrix[5]);
  20948. }
  20949. if (isArray(bbox) && bbox.length === 4) {
  20950. var width = bbox[2] - bbox[0];
  20951. var height = bbox[3] - bbox[1];
  20952. var cliprect = document.createElementNS(NS, 'svg:rect');
  20953. cliprect.setAttributeNS(null, 'x', bbox[0]);
  20954. cliprect.setAttributeNS(null, 'y', bbox[1]);
  20955. cliprect.setAttributeNS(null, 'width', pf(width));
  20956. cliprect.setAttributeNS(null, 'height', pf(height));
  20957. this.current.element = cliprect;
  20958. this.clip('nonzero');
  20959. this.endPath();
  20960. }
  20961. },
  20962. paintFormXObjectEnd: function SVGGraphics_paintFormXObjectEnd() {
  20963. },
  20964. _initialize: function SVGGraphics_initialize(viewport) {
  20965. var svg = document.createElementNS(NS, 'svg:svg');
  20966. svg.setAttributeNS(null, 'version', '1.1');
  20967. svg.setAttributeNS(null, 'width', viewport.width + 'px');
  20968. svg.setAttributeNS(null, 'height', viewport.height + 'px');
  20969. svg.setAttributeNS(null, 'preserveAspectRatio', 'none');
  20970. svg.setAttributeNS(null, 'viewBox', '0 0 ' + viewport.width + ' ' + viewport.height);
  20971. var definitions = document.createElementNS(NS, 'svg:defs');
  20972. svg.appendChild(definitions);
  20973. this.defs = definitions;
  20974. var rootGroup = document.createElementNS(NS, 'svg:g');
  20975. rootGroup.setAttributeNS(null, 'transform', pm(viewport.transform));
  20976. svg.appendChild(rootGroup);
  20977. this.svg = rootGroup;
  20978. return svg;
  20979. },
  20980. _ensureClipGroup: function SVGGraphics_ensureClipGroup() {
  20981. if (!this.current.clipGroup) {
  20982. var clipGroup = document.createElementNS(NS, 'svg:g');
  20983. clipGroup.setAttributeNS(null, 'clip-path', this.current.activeClipUrl);
  20984. this.svg.appendChild(clipGroup);
  20985. this.current.clipGroup = clipGroup;
  20986. }
  20987. return this.current.clipGroup;
  20988. },
  20989. _ensureTransformGroup: function SVGGraphics_ensureTransformGroup() {
  20990. if (!this.tgrp) {
  20991. this.tgrp = document.createElementNS(NS, 'svg:g');
  20992. this.tgrp.setAttributeNS(null, 'transform', pm(this.transformMatrix));
  20993. if (this.current.activeClipUrl) {
  20994. this._ensureClipGroup().appendChild(this.tgrp);
  20995. } else {
  20996. this.svg.appendChild(this.tgrp);
  20997. }
  20998. }
  20999. return this.tgrp;
  21000. }
  21001. };
  21002. return SVGGraphics;
  21003. }();
  21004. exports.SVGGraphics = SVGGraphics;
  21005. /***/ }),
  21006. /* 12 */
  21007. /***/ (function(module, exports, __w_pdfjs_require__) {
  21008. "use strict";
  21009. var sharedUtil = __w_pdfjs_require__(0);
  21010. var displayDOMUtils = __w_pdfjs_require__(3);
  21011. var Util = sharedUtil.Util;
  21012. var createPromiseCapability = sharedUtil.createPromiseCapability;
  21013. var CustomStyle = displayDOMUtils.CustomStyle;
  21014. var getDefaultSetting = displayDOMUtils.getDefaultSetting;
  21015. var renderTextLayer = function renderTextLayerClosure() {
  21016. var MAX_TEXT_DIVS_TO_RENDER = 100000;
  21017. var NonWhitespaceRegexp = /\S/;
  21018. function isAllWhitespace(str) {
  21019. return !NonWhitespaceRegexp.test(str);
  21020. }
  21021. var styleBuf = [
  21022. 'left: ',
  21023. 0,
  21024. 'px; top: ',
  21025. 0,
  21026. 'px; font-size: ',
  21027. 0,
  21028. 'px; font-family: ',
  21029. '',
  21030. ';'
  21031. ];
  21032. function appendText(task, geom, styles) {
  21033. var textDiv = document.createElement('div');
  21034. var textDivProperties = {
  21035. style: null,
  21036. angle: 0,
  21037. canvasWidth: 0,
  21038. isWhitespace: false,
  21039. originalTransform: null,
  21040. paddingBottom: 0,
  21041. paddingLeft: 0,
  21042. paddingRight: 0,
  21043. paddingTop: 0,
  21044. scale: 1
  21045. };
  21046. task._textDivs.push(textDiv);
  21047. if (isAllWhitespace(geom.str)) {
  21048. textDivProperties.isWhitespace = true;
  21049. task._textDivProperties.set(textDiv, textDivProperties);
  21050. return;
  21051. }
  21052. var tx = Util.transform(task._viewport.transform, geom.transform);
  21053. var angle = Math.atan2(tx[1], tx[0]);
  21054. var style = styles[geom.fontName];
  21055. if (style.vertical) {
  21056. angle += Math.PI / 2;
  21057. }
  21058. var fontHeight = Math.sqrt(tx[2] * tx[2] + tx[3] * tx[3]);
  21059. var fontAscent = fontHeight;
  21060. if (style.ascent) {
  21061. fontAscent = style.ascent * fontAscent;
  21062. } else if (style.descent) {
  21063. fontAscent = (1 + style.descent) * fontAscent;
  21064. }
  21065. var left;
  21066. var top;
  21067. if (angle === 0) {
  21068. left = tx[4];
  21069. top = tx[5] - fontAscent;
  21070. } else {
  21071. left = tx[4] + fontAscent * Math.sin(angle);
  21072. top = tx[5] - fontAscent * Math.cos(angle);
  21073. }
  21074. styleBuf[1] = left;
  21075. styleBuf[3] = top;
  21076. styleBuf[5] = fontHeight;
  21077. styleBuf[7] = style.fontFamily;
  21078. textDivProperties.style = styleBuf.join('');
  21079. textDiv.setAttribute('style', textDivProperties.style);
  21080. textDiv.textContent = geom.str;
  21081. if (getDefaultSetting('pdfBug')) {
  21082. textDiv.dataset.fontName = geom.fontName;
  21083. }
  21084. if (angle !== 0) {
  21085. textDivProperties.angle = angle * (180 / Math.PI);
  21086. }
  21087. if (geom.str.length > 1) {
  21088. if (style.vertical) {
  21089. textDivProperties.canvasWidth = geom.height * task._viewport.scale;
  21090. } else {
  21091. textDivProperties.canvasWidth = geom.width * task._viewport.scale;
  21092. }
  21093. }
  21094. task._textDivProperties.set(textDiv, textDivProperties);
  21095. if (task._enhanceTextSelection) {
  21096. var angleCos = 1, angleSin = 0;
  21097. if (angle !== 0) {
  21098. angleCos = Math.cos(angle);
  21099. angleSin = Math.sin(angle);
  21100. }
  21101. var divWidth = (style.vertical ? geom.height : geom.width) * task._viewport.scale;
  21102. var divHeight = fontHeight;
  21103. var m, b;
  21104. if (angle !== 0) {
  21105. m = [
  21106. angleCos,
  21107. angleSin,
  21108. -angleSin,
  21109. angleCos,
  21110. left,
  21111. top
  21112. ];
  21113. b = Util.getAxialAlignedBoundingBox([
  21114. 0,
  21115. 0,
  21116. divWidth,
  21117. divHeight
  21118. ], m);
  21119. } else {
  21120. b = [
  21121. left,
  21122. top,
  21123. left + divWidth,
  21124. top + divHeight
  21125. ];
  21126. }
  21127. task._bounds.push({
  21128. left: b[0],
  21129. top: b[1],
  21130. right: b[2],
  21131. bottom: b[3],
  21132. div: textDiv,
  21133. size: [
  21134. divWidth,
  21135. divHeight
  21136. ],
  21137. m: m
  21138. });
  21139. }
  21140. }
  21141. function render(task) {
  21142. if (task._canceled) {
  21143. return;
  21144. }
  21145. var textLayerFrag = task._container;
  21146. var textDivs = task._textDivs;
  21147. var capability = task._capability;
  21148. var textDivsLength = textDivs.length;
  21149. if (textDivsLength > MAX_TEXT_DIVS_TO_RENDER) {
  21150. task._renderingDone = true;
  21151. capability.resolve();
  21152. return;
  21153. }
  21154. var canvas = document.createElement('canvas');
  21155. var ctx = canvas.getContext('2d', { alpha: false });
  21156. var lastFontSize;
  21157. var lastFontFamily;
  21158. for (var i = 0; i < textDivsLength; i++) {
  21159. var textDiv = textDivs[i];
  21160. var textDivProperties = task._textDivProperties.get(textDiv);
  21161. if (textDivProperties.isWhitespace) {
  21162. continue;
  21163. }
  21164. var fontSize = textDiv.style.fontSize;
  21165. var fontFamily = textDiv.style.fontFamily;
  21166. if (fontSize !== lastFontSize || fontFamily !== lastFontFamily) {
  21167. ctx.font = fontSize + ' ' + fontFamily;
  21168. lastFontSize = fontSize;
  21169. lastFontFamily = fontFamily;
  21170. }
  21171. var width = ctx.measureText(textDiv.textContent).width;
  21172. textLayerFrag.appendChild(textDiv);
  21173. var transform = '';
  21174. if (textDivProperties.canvasWidth !== 0 && width > 0) {
  21175. textDivProperties.scale = textDivProperties.canvasWidth / width;
  21176. transform = 'scaleX(' + textDivProperties.scale + ')';
  21177. }
  21178. if (textDivProperties.angle !== 0) {
  21179. transform = 'rotate(' + textDivProperties.angle + 'deg) ' + transform;
  21180. }
  21181. if (transform !== '') {
  21182. textDivProperties.originalTransform = transform;
  21183. CustomStyle.setProp('transform', textDiv, transform);
  21184. }
  21185. task._textDivProperties.set(textDiv, textDivProperties);
  21186. }
  21187. task._renderingDone = true;
  21188. capability.resolve();
  21189. }
  21190. function expand(task) {
  21191. var bounds = task._bounds;
  21192. var viewport = task._viewport;
  21193. var expanded = expandBounds(viewport.width, viewport.height, bounds);
  21194. for (var i = 0; i < expanded.length; i++) {
  21195. var div = bounds[i].div;
  21196. var divProperties = task._textDivProperties.get(div);
  21197. if (divProperties.angle === 0) {
  21198. divProperties.paddingLeft = bounds[i].left - expanded[i].left;
  21199. divProperties.paddingTop = bounds[i].top - expanded[i].top;
  21200. divProperties.paddingRight = expanded[i].right - bounds[i].right;
  21201. divProperties.paddingBottom = expanded[i].bottom - bounds[i].bottom;
  21202. task._textDivProperties.set(div, divProperties);
  21203. continue;
  21204. }
  21205. var e = expanded[i], b = bounds[i];
  21206. var m = b.m, c = m[0], s = m[1];
  21207. var points = [
  21208. [
  21209. 0,
  21210. 0
  21211. ],
  21212. [
  21213. 0,
  21214. b.size[1]
  21215. ],
  21216. [
  21217. b.size[0],
  21218. 0
  21219. ],
  21220. b.size
  21221. ];
  21222. var ts = new Float64Array(64);
  21223. points.forEach(function (p, i) {
  21224. var t = Util.applyTransform(p, m);
  21225. ts[i + 0] = c && (e.left - t[0]) / c;
  21226. ts[i + 4] = s && (e.top - t[1]) / s;
  21227. ts[i + 8] = c && (e.right - t[0]) / c;
  21228. ts[i + 12] = s && (e.bottom - t[1]) / s;
  21229. ts[i + 16] = s && (e.left - t[0]) / -s;
  21230. ts[i + 20] = c && (e.top - t[1]) / c;
  21231. ts[i + 24] = s && (e.right - t[0]) / -s;
  21232. ts[i + 28] = c && (e.bottom - t[1]) / c;
  21233. ts[i + 32] = c && (e.left - t[0]) / -c;
  21234. ts[i + 36] = s && (e.top - t[1]) / -s;
  21235. ts[i + 40] = c && (e.right - t[0]) / -c;
  21236. ts[i + 44] = s && (e.bottom - t[1]) / -s;
  21237. ts[i + 48] = s && (e.left - t[0]) / s;
  21238. ts[i + 52] = c && (e.top - t[1]) / -c;
  21239. ts[i + 56] = s && (e.right - t[0]) / s;
  21240. ts[i + 60] = c && (e.bottom - t[1]) / -c;
  21241. });
  21242. var findPositiveMin = function (ts, offset, count) {
  21243. var result = 0;
  21244. for (var i = 0; i < count; i++) {
  21245. var t = ts[offset++];
  21246. if (t > 0) {
  21247. result = result ? Math.min(t, result) : t;
  21248. }
  21249. }
  21250. return result;
  21251. };
  21252. var boxScale = 1 + Math.min(Math.abs(c), Math.abs(s));
  21253. divProperties.paddingLeft = findPositiveMin(ts, 32, 16) / boxScale;
  21254. divProperties.paddingTop = findPositiveMin(ts, 48, 16) / boxScale;
  21255. divProperties.paddingRight = findPositiveMin(ts, 0, 16) / boxScale;
  21256. divProperties.paddingBottom = findPositiveMin(ts, 16, 16) / boxScale;
  21257. task._textDivProperties.set(div, divProperties);
  21258. }
  21259. }
  21260. function expandBounds(width, height, boxes) {
  21261. var bounds = boxes.map(function (box, i) {
  21262. return {
  21263. x1: box.left,
  21264. y1: box.top,
  21265. x2: box.right,
  21266. y2: box.bottom,
  21267. index: i,
  21268. x1New: undefined,
  21269. x2New: undefined
  21270. };
  21271. });
  21272. expandBoundsLTR(width, bounds);
  21273. var expanded = new Array(boxes.length);
  21274. bounds.forEach(function (b) {
  21275. var i = b.index;
  21276. expanded[i] = {
  21277. left: b.x1New,
  21278. top: 0,
  21279. right: b.x2New,
  21280. bottom: 0
  21281. };
  21282. });
  21283. boxes.map(function (box, i) {
  21284. var e = expanded[i], b = bounds[i];
  21285. b.x1 = box.top;
  21286. b.y1 = width - e.right;
  21287. b.x2 = box.bottom;
  21288. b.y2 = width - e.left;
  21289. b.index = i;
  21290. b.x1New = undefined;
  21291. b.x2New = undefined;
  21292. });
  21293. expandBoundsLTR(height, bounds);
  21294. bounds.forEach(function (b) {
  21295. var i = b.index;
  21296. expanded[i].top = b.x1New;
  21297. expanded[i].bottom = b.x2New;
  21298. });
  21299. return expanded;
  21300. }
  21301. function expandBoundsLTR(width, bounds) {
  21302. bounds.sort(function (a, b) {
  21303. return a.x1 - b.x1 || a.index - b.index;
  21304. });
  21305. var fakeBoundary = {
  21306. x1: -Infinity,
  21307. y1: -Infinity,
  21308. x2: 0,
  21309. y2: Infinity,
  21310. index: -1,
  21311. x1New: 0,
  21312. x2New: 0
  21313. };
  21314. var horizon = [{
  21315. start: -Infinity,
  21316. end: Infinity,
  21317. boundary: fakeBoundary
  21318. }];
  21319. bounds.forEach(function (boundary) {
  21320. var i = 0;
  21321. while (i < horizon.length && horizon[i].end <= boundary.y1) {
  21322. i++;
  21323. }
  21324. var j = horizon.length - 1;
  21325. while (j >= 0 && horizon[j].start >= boundary.y2) {
  21326. j--;
  21327. }
  21328. var horizonPart, affectedBoundary;
  21329. var q, k, maxXNew = -Infinity;
  21330. for (q = i; q <= j; q++) {
  21331. horizonPart = horizon[q];
  21332. affectedBoundary = horizonPart.boundary;
  21333. var xNew;
  21334. if (affectedBoundary.x2 > boundary.x1) {
  21335. xNew = affectedBoundary.index > boundary.index ? affectedBoundary.x1New : boundary.x1;
  21336. } else if (affectedBoundary.x2New === undefined) {
  21337. xNew = (affectedBoundary.x2 + boundary.x1) / 2;
  21338. } else {
  21339. xNew = affectedBoundary.x2New;
  21340. }
  21341. if (xNew > maxXNew) {
  21342. maxXNew = xNew;
  21343. }
  21344. }
  21345. boundary.x1New = maxXNew;
  21346. for (q = i; q <= j; q++) {
  21347. horizonPart = horizon[q];
  21348. affectedBoundary = horizonPart.boundary;
  21349. if (affectedBoundary.x2New === undefined) {
  21350. if (affectedBoundary.x2 > boundary.x1) {
  21351. if (affectedBoundary.index > boundary.index) {
  21352. affectedBoundary.x2New = affectedBoundary.x2;
  21353. }
  21354. } else {
  21355. affectedBoundary.x2New = maxXNew;
  21356. }
  21357. } else if (affectedBoundary.x2New > maxXNew) {
  21358. affectedBoundary.x2New = Math.max(maxXNew, affectedBoundary.x2);
  21359. }
  21360. }
  21361. var changedHorizon = [], lastBoundary = null;
  21362. for (q = i; q <= j; q++) {
  21363. horizonPart = horizon[q];
  21364. affectedBoundary = horizonPart.boundary;
  21365. var useBoundary = affectedBoundary.x2 > boundary.x2 ? affectedBoundary : boundary;
  21366. if (lastBoundary === useBoundary) {
  21367. changedHorizon[changedHorizon.length - 1].end = horizonPart.end;
  21368. } else {
  21369. changedHorizon.push({
  21370. start: horizonPart.start,
  21371. end: horizonPart.end,
  21372. boundary: useBoundary
  21373. });
  21374. lastBoundary = useBoundary;
  21375. }
  21376. }
  21377. if (horizon[i].start < boundary.y1) {
  21378. changedHorizon[0].start = boundary.y1;
  21379. changedHorizon.unshift({
  21380. start: horizon[i].start,
  21381. end: boundary.y1,
  21382. boundary: horizon[i].boundary
  21383. });
  21384. }
  21385. if (boundary.y2 < horizon[j].end) {
  21386. changedHorizon[changedHorizon.length - 1].end = boundary.y2;
  21387. changedHorizon.push({
  21388. start: boundary.y2,
  21389. end: horizon[j].end,
  21390. boundary: horizon[j].boundary
  21391. });
  21392. }
  21393. for (q = i; q <= j; q++) {
  21394. horizonPart = horizon[q];
  21395. affectedBoundary = horizonPart.boundary;
  21396. if (affectedBoundary.x2New !== undefined) {
  21397. continue;
  21398. }
  21399. var used = false;
  21400. for (k = i - 1; !used && k >= 0 && horizon[k].start >= affectedBoundary.y1; k--) {
  21401. used = horizon[k].boundary === affectedBoundary;
  21402. }
  21403. for (k = j + 1; !used && k < horizon.length && horizon[k].end <= affectedBoundary.y2; k++) {
  21404. used = horizon[k].boundary === affectedBoundary;
  21405. }
  21406. for (k = 0; !used && k < changedHorizon.length; k++) {
  21407. used = changedHorizon[k].boundary === affectedBoundary;
  21408. }
  21409. if (!used) {
  21410. affectedBoundary.x2New = maxXNew;
  21411. }
  21412. }
  21413. Array.prototype.splice.apply(horizon, [
  21414. i,
  21415. j - i + 1
  21416. ].concat(changedHorizon));
  21417. });
  21418. horizon.forEach(function (horizonPart) {
  21419. var affectedBoundary = horizonPart.boundary;
  21420. if (affectedBoundary.x2New === undefined) {
  21421. affectedBoundary.x2New = Math.max(width, affectedBoundary.x2);
  21422. }
  21423. });
  21424. }
  21425. function TextLayerRenderTask(textContent, container, viewport, textDivs, enhanceTextSelection) {
  21426. this._textContent = textContent;
  21427. this._container = container;
  21428. this._viewport = viewport;
  21429. this._textDivs = textDivs || [];
  21430. this._textDivProperties = new WeakMap();
  21431. this._renderingDone = false;
  21432. this._canceled = false;
  21433. this._capability = createPromiseCapability();
  21434. this._renderTimer = null;
  21435. this._bounds = [];
  21436. this._enhanceTextSelection = !!enhanceTextSelection;
  21437. }
  21438. TextLayerRenderTask.prototype = {
  21439. get promise() {
  21440. return this._capability.promise;
  21441. },
  21442. cancel: function TextLayer_cancel() {
  21443. this._canceled = true;
  21444. if (this._renderTimer !== null) {
  21445. clearTimeout(this._renderTimer);
  21446. this._renderTimer = null;
  21447. }
  21448. this._capability.reject('canceled');
  21449. },
  21450. _render: function TextLayer_render(timeout) {
  21451. var textItems = this._textContent.items;
  21452. var textStyles = this._textContent.styles;
  21453. for (var i = 0, len = textItems.length; i < len; i++) {
  21454. appendText(this, textItems[i], textStyles);
  21455. }
  21456. if (!timeout) {
  21457. render(this);
  21458. } else {
  21459. var self = this;
  21460. this._renderTimer = setTimeout(function () {
  21461. render(self);
  21462. self._renderTimer = null;
  21463. }, timeout);
  21464. }
  21465. },
  21466. expandTextDivs: function TextLayer_expandTextDivs(expandDivs) {
  21467. if (!this._enhanceTextSelection || !this._renderingDone) {
  21468. return;
  21469. }
  21470. if (this._bounds !== null) {
  21471. expand(this);
  21472. this._bounds = null;
  21473. }
  21474. for (var i = 0, ii = this._textDivs.length; i < ii; i++) {
  21475. var div = this._textDivs[i];
  21476. var divProperties = this._textDivProperties.get(div);
  21477. if (divProperties.isWhitespace) {
  21478. continue;
  21479. }
  21480. if (expandDivs) {
  21481. var transform = '', padding = '';
  21482. if (divProperties.scale !== 1) {
  21483. transform = 'scaleX(' + divProperties.scale + ')';
  21484. }
  21485. if (divProperties.angle !== 0) {
  21486. transform = 'rotate(' + divProperties.angle + 'deg) ' + transform;
  21487. }
  21488. if (divProperties.paddingLeft !== 0) {
  21489. padding += ' padding-left: ' + divProperties.paddingLeft / divProperties.scale + 'px;';
  21490. transform += ' translateX(' + -divProperties.paddingLeft / divProperties.scale + 'px)';
  21491. }
  21492. if (divProperties.paddingTop !== 0) {
  21493. padding += ' padding-top: ' + divProperties.paddingTop + 'px;';
  21494. transform += ' translateY(' + -divProperties.paddingTop + 'px)';
  21495. }
  21496. if (divProperties.paddingRight !== 0) {
  21497. padding += ' padding-right: ' + divProperties.paddingRight / divProperties.scale + 'px;';
  21498. }
  21499. if (divProperties.paddingBottom !== 0) {
  21500. padding += ' padding-bottom: ' + divProperties.paddingBottom + 'px;';
  21501. }
  21502. if (padding !== '') {
  21503. div.setAttribute('style', divProperties.style + padding);
  21504. }
  21505. if (transform !== '') {
  21506. CustomStyle.setProp('transform', div, transform);
  21507. }
  21508. } else {
  21509. div.style.padding = 0;
  21510. CustomStyle.setProp('transform', div, divProperties.originalTransform || '');
  21511. }
  21512. }
  21513. }
  21514. };
  21515. function renderTextLayer(renderParameters) {
  21516. var task = new TextLayerRenderTask(renderParameters.textContent, renderParameters.container, renderParameters.viewport, renderParameters.textDivs, renderParameters.enhanceTextSelection);
  21517. task._render(renderParameters.timeout);
  21518. return task;
  21519. }
  21520. return renderTextLayer;
  21521. }();
  21522. exports.renderTextLayer = renderTextLayer;
  21523. /***/ }),
  21524. /* 13 */
  21525. /***/ (function(module, exports) {
  21526. var g;
  21527. g = function () {
  21528. return this;
  21529. }();
  21530. try {
  21531. g = g || Function("return this")() || (1, eval)("this");
  21532. } catch (e) {
  21533. if (typeof window === "object")
  21534. g = window;
  21535. }
  21536. module.exports = g;
  21537. /***/ }),
  21538. /* 14 */
  21539. /***/ (function(module, exports, __w_pdfjs_require__) {
  21540. "use strict";
  21541. var ArithmeticDecoder = function ArithmeticDecoderClosure() {
  21542. var QeTable = [
  21543. {
  21544. qe: 0x5601,
  21545. nmps: 1,
  21546. nlps: 1,
  21547. switchFlag: 1
  21548. },
  21549. {
  21550. qe: 0x3401,
  21551. nmps: 2,
  21552. nlps: 6,
  21553. switchFlag: 0
  21554. },
  21555. {
  21556. qe: 0x1801,
  21557. nmps: 3,
  21558. nlps: 9,
  21559. switchFlag: 0
  21560. },
  21561. {
  21562. qe: 0x0AC1,
  21563. nmps: 4,
  21564. nlps: 12,
  21565. switchFlag: 0
  21566. },
  21567. {
  21568. qe: 0x0521,
  21569. nmps: 5,
  21570. nlps: 29,
  21571. switchFlag: 0
  21572. },
  21573. {
  21574. qe: 0x0221,
  21575. nmps: 38,
  21576. nlps: 33,
  21577. switchFlag: 0
  21578. },
  21579. {
  21580. qe: 0x5601,
  21581. nmps: 7,
  21582. nlps: 6,
  21583. switchFlag: 1
  21584. },
  21585. {
  21586. qe: 0x5401,
  21587. nmps: 8,
  21588. nlps: 14,
  21589. switchFlag: 0
  21590. },
  21591. {
  21592. qe: 0x4801,
  21593. nmps: 9,
  21594. nlps: 14,
  21595. switchFlag: 0
  21596. },
  21597. {
  21598. qe: 0x3801,
  21599. nmps: 10,
  21600. nlps: 14,
  21601. switchFlag: 0
  21602. },
  21603. {
  21604. qe: 0x3001,
  21605. nmps: 11,
  21606. nlps: 17,
  21607. switchFlag: 0
  21608. },
  21609. {
  21610. qe: 0x2401,
  21611. nmps: 12,
  21612. nlps: 18,
  21613. switchFlag: 0
  21614. },
  21615. {
  21616. qe: 0x1C01,
  21617. nmps: 13,
  21618. nlps: 20,
  21619. switchFlag: 0
  21620. },
  21621. {
  21622. qe: 0x1601,
  21623. nmps: 29,
  21624. nlps: 21,
  21625. switchFlag: 0
  21626. },
  21627. {
  21628. qe: 0x5601,
  21629. nmps: 15,
  21630. nlps: 14,
  21631. switchFlag: 1
  21632. },
  21633. {
  21634. qe: 0x5401,
  21635. nmps: 16,
  21636. nlps: 14,
  21637. switchFlag: 0
  21638. },
  21639. {
  21640. qe: 0x5101,
  21641. nmps: 17,
  21642. nlps: 15,
  21643. switchFlag: 0
  21644. },
  21645. {
  21646. qe: 0x4801,
  21647. nmps: 18,
  21648. nlps: 16,
  21649. switchFlag: 0
  21650. },
  21651. {
  21652. qe: 0x3801,
  21653. nmps: 19,
  21654. nlps: 17,
  21655. switchFlag: 0
  21656. },
  21657. {
  21658. qe: 0x3401,
  21659. nmps: 20,
  21660. nlps: 18,
  21661. switchFlag: 0
  21662. },
  21663. {
  21664. qe: 0x3001,
  21665. nmps: 21,
  21666. nlps: 19,
  21667. switchFlag: 0
  21668. },
  21669. {
  21670. qe: 0x2801,
  21671. nmps: 22,
  21672. nlps: 19,
  21673. switchFlag: 0
  21674. },
  21675. {
  21676. qe: 0x2401,
  21677. nmps: 23,
  21678. nlps: 20,
  21679. switchFlag: 0
  21680. },
  21681. {
  21682. qe: 0x2201,
  21683. nmps: 24,
  21684. nlps: 21,
  21685. switchFlag: 0
  21686. },
  21687. {
  21688. qe: 0x1C01,
  21689. nmps: 25,
  21690. nlps: 22,
  21691. switchFlag: 0
  21692. },
  21693. {
  21694. qe: 0x1801,
  21695. nmps: 26,
  21696. nlps: 23,
  21697. switchFlag: 0
  21698. },
  21699. {
  21700. qe: 0x1601,
  21701. nmps: 27,
  21702. nlps: 24,
  21703. switchFlag: 0
  21704. },
  21705. {
  21706. qe: 0x1401,
  21707. nmps: 28,
  21708. nlps: 25,
  21709. switchFlag: 0
  21710. },
  21711. {
  21712. qe: 0x1201,
  21713. nmps: 29,
  21714. nlps: 26,
  21715. switchFlag: 0
  21716. },
  21717. {
  21718. qe: 0x1101,
  21719. nmps: 30,
  21720. nlps: 27,
  21721. switchFlag: 0
  21722. },
  21723. {
  21724. qe: 0x0AC1,
  21725. nmps: 31,
  21726. nlps: 28,
  21727. switchFlag: 0
  21728. },
  21729. {
  21730. qe: 0x09C1,
  21731. nmps: 32,
  21732. nlps: 29,
  21733. switchFlag: 0
  21734. },
  21735. {
  21736. qe: 0x08A1,
  21737. nmps: 33,
  21738. nlps: 30,
  21739. switchFlag: 0
  21740. },
  21741. {
  21742. qe: 0x0521,
  21743. nmps: 34,
  21744. nlps: 31,
  21745. switchFlag: 0
  21746. },
  21747. {
  21748. qe: 0x0441,
  21749. nmps: 35,
  21750. nlps: 32,
  21751. switchFlag: 0
  21752. },
  21753. {
  21754. qe: 0x02A1,
  21755. nmps: 36,
  21756. nlps: 33,
  21757. switchFlag: 0
  21758. },
  21759. {
  21760. qe: 0x0221,
  21761. nmps: 37,
  21762. nlps: 34,
  21763. switchFlag: 0
  21764. },
  21765. {
  21766. qe: 0x0141,
  21767. nmps: 38,
  21768. nlps: 35,
  21769. switchFlag: 0
  21770. },
  21771. {
  21772. qe: 0x0111,
  21773. nmps: 39,
  21774. nlps: 36,
  21775. switchFlag: 0
  21776. },
  21777. {
  21778. qe: 0x0085,
  21779. nmps: 40,
  21780. nlps: 37,
  21781. switchFlag: 0
  21782. },
  21783. {
  21784. qe: 0x0049,
  21785. nmps: 41,
  21786. nlps: 38,
  21787. switchFlag: 0
  21788. },
  21789. {
  21790. qe: 0x0025,
  21791. nmps: 42,
  21792. nlps: 39,
  21793. switchFlag: 0
  21794. },
  21795. {
  21796. qe: 0x0015,
  21797. nmps: 43,
  21798. nlps: 40,
  21799. switchFlag: 0
  21800. },
  21801. {
  21802. qe: 0x0009,
  21803. nmps: 44,
  21804. nlps: 41,
  21805. switchFlag: 0
  21806. },
  21807. {
  21808. qe: 0x0005,
  21809. nmps: 45,
  21810. nlps: 42,
  21811. switchFlag: 0
  21812. },
  21813. {
  21814. qe: 0x0001,
  21815. nmps: 45,
  21816. nlps: 43,
  21817. switchFlag: 0
  21818. },
  21819. {
  21820. qe: 0x5601,
  21821. nmps: 46,
  21822. nlps: 46,
  21823. switchFlag: 0
  21824. }
  21825. ];
  21826. function ArithmeticDecoder(data, start, end) {
  21827. this.data = data;
  21828. this.bp = start;
  21829. this.dataEnd = end;
  21830. this.chigh = data[start];
  21831. this.clow = 0;
  21832. this.byteIn();
  21833. this.chigh = this.chigh << 7 & 0xFFFF | this.clow >> 9 & 0x7F;
  21834. this.clow = this.clow << 7 & 0xFFFF;
  21835. this.ct -= 7;
  21836. this.a = 0x8000;
  21837. }
  21838. ArithmeticDecoder.prototype = {
  21839. byteIn: function ArithmeticDecoder_byteIn() {
  21840. var data = this.data;
  21841. var bp = this.bp;
  21842. if (data[bp] === 0xFF) {
  21843. var b1 = data[bp + 1];
  21844. if (b1 > 0x8F) {
  21845. this.clow += 0xFF00;
  21846. this.ct = 8;
  21847. } else {
  21848. bp++;
  21849. this.clow += data[bp] << 9;
  21850. this.ct = 7;
  21851. this.bp = bp;
  21852. }
  21853. } else {
  21854. bp++;
  21855. this.clow += bp < this.dataEnd ? data[bp] << 8 : 0xFF00;
  21856. this.ct = 8;
  21857. this.bp = bp;
  21858. }
  21859. if (this.clow > 0xFFFF) {
  21860. this.chigh += this.clow >> 16;
  21861. this.clow &= 0xFFFF;
  21862. }
  21863. },
  21864. readBit: function ArithmeticDecoder_readBit(contexts, pos) {
  21865. var cx_index = contexts[pos] >> 1, cx_mps = contexts[pos] & 1;
  21866. var qeTableIcx = QeTable[cx_index];
  21867. var qeIcx = qeTableIcx.qe;
  21868. var d;
  21869. var a = this.a - qeIcx;
  21870. if (this.chigh < qeIcx) {
  21871. if (a < qeIcx) {
  21872. a = qeIcx;
  21873. d = cx_mps;
  21874. cx_index = qeTableIcx.nmps;
  21875. } else {
  21876. a = qeIcx;
  21877. d = 1 ^ cx_mps;
  21878. if (qeTableIcx.switchFlag === 1) {
  21879. cx_mps = d;
  21880. }
  21881. cx_index = qeTableIcx.nlps;
  21882. }
  21883. } else {
  21884. this.chigh -= qeIcx;
  21885. if ((a & 0x8000) !== 0) {
  21886. this.a = a;
  21887. return cx_mps;
  21888. }
  21889. if (a < qeIcx) {
  21890. d = 1 ^ cx_mps;
  21891. if (qeTableIcx.switchFlag === 1) {
  21892. cx_mps = d;
  21893. }
  21894. cx_index = qeTableIcx.nlps;
  21895. } else {
  21896. d = cx_mps;
  21897. cx_index = qeTableIcx.nmps;
  21898. }
  21899. }
  21900. do {
  21901. if (this.ct === 0) {
  21902. this.byteIn();
  21903. }
  21904. a <<= 1;
  21905. this.chigh = this.chigh << 1 & 0xFFFF | this.clow >> 15 & 1;
  21906. this.clow = this.clow << 1 & 0xFFFF;
  21907. this.ct--;
  21908. } while ((a & 0x8000) === 0);
  21909. this.a = a;
  21910. contexts[pos] = cx_index << 1 | cx_mps;
  21911. return d;
  21912. }
  21913. };
  21914. return ArithmeticDecoder;
  21915. }();
  21916. exports.ArithmeticDecoder = ArithmeticDecoder;
  21917. /***/ }),
  21918. /* 15 */
  21919. /***/ (function(module, exports, __w_pdfjs_require__) {
  21920. "use strict";
  21921. var sharedUtil = __w_pdfjs_require__(0);
  21922. var coreCharsets = __w_pdfjs_require__(29);
  21923. var coreEncodings = __w_pdfjs_require__(5);
  21924. var error = sharedUtil.error;
  21925. var info = sharedUtil.info;
  21926. var bytesToString = sharedUtil.bytesToString;
  21927. var warn = sharedUtil.warn;
  21928. var isArray = sharedUtil.isArray;
  21929. var Util = sharedUtil.Util;
  21930. var stringToBytes = sharedUtil.stringToBytes;
  21931. var assert = sharedUtil.assert;
  21932. var ISOAdobeCharset = coreCharsets.ISOAdobeCharset;
  21933. var ExpertCharset = coreCharsets.ExpertCharset;
  21934. var ExpertSubsetCharset = coreCharsets.ExpertSubsetCharset;
  21935. var StandardEncoding = coreEncodings.StandardEncoding;
  21936. var ExpertEncoding = coreEncodings.ExpertEncoding;
  21937. var MAX_SUBR_NESTING = 10;
  21938. var CFFStandardStrings = [
  21939. '.notdef',
  21940. 'space',
  21941. 'exclam',
  21942. 'quotedbl',
  21943. 'numbersign',
  21944. 'dollar',
  21945. 'percent',
  21946. 'ampersand',
  21947. 'quoteright',
  21948. 'parenleft',
  21949. 'parenright',
  21950. 'asterisk',
  21951. 'plus',
  21952. 'comma',
  21953. 'hyphen',
  21954. 'period',
  21955. 'slash',
  21956. 'zero',
  21957. 'one',
  21958. 'two',
  21959. 'three',
  21960. 'four',
  21961. 'five',
  21962. 'six',
  21963. 'seven',
  21964. 'eight',
  21965. 'nine',
  21966. 'colon',
  21967. 'semicolon',
  21968. 'less',
  21969. 'equal',
  21970. 'greater',
  21971. 'question',
  21972. 'at',
  21973. 'A',
  21974. 'B',
  21975. 'C',
  21976. 'D',
  21977. 'E',
  21978. 'F',
  21979. 'G',
  21980. 'H',
  21981. 'I',
  21982. 'J',
  21983. 'K',
  21984. 'L',
  21985. 'M',
  21986. 'N',
  21987. 'O',
  21988. 'P',
  21989. 'Q',
  21990. 'R',
  21991. 'S',
  21992. 'T',
  21993. 'U',
  21994. 'V',
  21995. 'W',
  21996. 'X',
  21997. 'Y',
  21998. 'Z',
  21999. 'bracketleft',
  22000. 'backslash',
  22001. 'bracketright',
  22002. 'asciicircum',
  22003. 'underscore',
  22004. 'quoteleft',
  22005. 'a',
  22006. 'b',
  22007. 'c',
  22008. 'd',
  22009. 'e',
  22010. 'f',
  22011. 'g',
  22012. 'h',
  22013. 'i',
  22014. 'j',
  22015. 'k',
  22016. 'l',
  22017. 'm',
  22018. 'n',
  22019. 'o',
  22020. 'p',
  22021. 'q',
  22022. 'r',
  22023. 's',
  22024. 't',
  22025. 'u',
  22026. 'v',
  22027. 'w',
  22028. 'x',
  22029. 'y',
  22030. 'z',
  22031. 'braceleft',
  22032. 'bar',
  22033. 'braceright',
  22034. 'asciitilde',
  22035. 'exclamdown',
  22036. 'cent',
  22037. 'sterling',
  22038. 'fraction',
  22039. 'yen',
  22040. 'florin',
  22041. 'section',
  22042. 'currency',
  22043. 'quotesingle',
  22044. 'quotedblleft',
  22045. 'guillemotleft',
  22046. 'guilsinglleft',
  22047. 'guilsinglright',
  22048. 'fi',
  22049. 'fl',
  22050. 'endash',
  22051. 'dagger',
  22052. 'daggerdbl',
  22053. 'periodcentered',
  22054. 'paragraph',
  22055. 'bullet',
  22056. 'quotesinglbase',
  22057. 'quotedblbase',
  22058. 'quotedblright',
  22059. 'guillemotright',
  22060. 'ellipsis',
  22061. 'perthousand',
  22062. 'questiondown',
  22063. 'grave',
  22064. 'acute',
  22065. 'circumflex',
  22066. 'tilde',
  22067. 'macron',
  22068. 'breve',
  22069. 'dotaccent',
  22070. 'dieresis',
  22071. 'ring',
  22072. 'cedilla',
  22073. 'hungarumlaut',
  22074. 'ogonek',
  22075. 'caron',
  22076. 'emdash',
  22077. 'AE',
  22078. 'ordfeminine',
  22079. 'Lslash',
  22080. 'Oslash',
  22081. 'OE',
  22082. 'ordmasculine',
  22083. 'ae',
  22084. 'dotlessi',
  22085. 'lslash',
  22086. 'oslash',
  22087. 'oe',
  22088. 'germandbls',
  22089. 'onesuperior',
  22090. 'logicalnot',
  22091. 'mu',
  22092. 'trademark',
  22093. 'Eth',
  22094. 'onehalf',
  22095. 'plusminus',
  22096. 'Thorn',
  22097. 'onequarter',
  22098. 'divide',
  22099. 'brokenbar',
  22100. 'degree',
  22101. 'thorn',
  22102. 'threequarters',
  22103. 'twosuperior',
  22104. 'registered',
  22105. 'minus',
  22106. 'eth',
  22107. 'multiply',
  22108. 'threesuperior',
  22109. 'copyright',
  22110. 'Aacute',
  22111. 'Acircumflex',
  22112. 'Adieresis',
  22113. 'Agrave',
  22114. 'Aring',
  22115. 'Atilde',
  22116. 'Ccedilla',
  22117. 'Eacute',
  22118. 'Ecircumflex',
  22119. 'Edieresis',
  22120. 'Egrave',
  22121. 'Iacute',
  22122. 'Icircumflex',
  22123. 'Idieresis',
  22124. 'Igrave',
  22125. 'Ntilde',
  22126. 'Oacute',
  22127. 'Ocircumflex',
  22128. 'Odieresis',
  22129. 'Ograve',
  22130. 'Otilde',
  22131. 'Scaron',
  22132. 'Uacute',
  22133. 'Ucircumflex',
  22134. 'Udieresis',
  22135. 'Ugrave',
  22136. 'Yacute',
  22137. 'Ydieresis',
  22138. 'Zcaron',
  22139. 'aacute',
  22140. 'acircumflex',
  22141. 'adieresis',
  22142. 'agrave',
  22143. 'aring',
  22144. 'atilde',
  22145. 'ccedilla',
  22146. 'eacute',
  22147. 'ecircumflex',
  22148. 'edieresis',
  22149. 'egrave',
  22150. 'iacute',
  22151. 'icircumflex',
  22152. 'idieresis',
  22153. 'igrave',
  22154. 'ntilde',
  22155. 'oacute',
  22156. 'ocircumflex',
  22157. 'odieresis',
  22158. 'ograve',
  22159. 'otilde',
  22160. 'scaron',
  22161. 'uacute',
  22162. 'ucircumflex',
  22163. 'udieresis',
  22164. 'ugrave',
  22165. 'yacute',
  22166. 'ydieresis',
  22167. 'zcaron',
  22168. 'exclamsmall',
  22169. 'Hungarumlautsmall',
  22170. 'dollaroldstyle',
  22171. 'dollarsuperior',
  22172. 'ampersandsmall',
  22173. 'Acutesmall',
  22174. 'parenleftsuperior',
  22175. 'parenrightsuperior',
  22176. 'twodotenleader',
  22177. 'onedotenleader',
  22178. 'zerooldstyle',
  22179. 'oneoldstyle',
  22180. 'twooldstyle',
  22181. 'threeoldstyle',
  22182. 'fouroldstyle',
  22183. 'fiveoldstyle',
  22184. 'sixoldstyle',
  22185. 'sevenoldstyle',
  22186. 'eightoldstyle',
  22187. 'nineoldstyle',
  22188. 'commasuperior',
  22189. 'threequartersemdash',
  22190. 'periodsuperior',
  22191. 'questionsmall',
  22192. 'asuperior',
  22193. 'bsuperior',
  22194. 'centsuperior',
  22195. 'dsuperior',
  22196. 'esuperior',
  22197. 'isuperior',
  22198. 'lsuperior',
  22199. 'msuperior',
  22200. 'nsuperior',
  22201. 'osuperior',
  22202. 'rsuperior',
  22203. 'ssuperior',
  22204. 'tsuperior',
  22205. 'ff',
  22206. 'ffi',
  22207. 'ffl',
  22208. 'parenleftinferior',
  22209. 'parenrightinferior',
  22210. 'Circumflexsmall',
  22211. 'hyphensuperior',
  22212. 'Gravesmall',
  22213. 'Asmall',
  22214. 'Bsmall',
  22215. 'Csmall',
  22216. 'Dsmall',
  22217. 'Esmall',
  22218. 'Fsmall',
  22219. 'Gsmall',
  22220. 'Hsmall',
  22221. 'Ismall',
  22222. 'Jsmall',
  22223. 'Ksmall',
  22224. 'Lsmall',
  22225. 'Msmall',
  22226. 'Nsmall',
  22227. 'Osmall',
  22228. 'Psmall',
  22229. 'Qsmall',
  22230. 'Rsmall',
  22231. 'Ssmall',
  22232. 'Tsmall',
  22233. 'Usmall',
  22234. 'Vsmall',
  22235. 'Wsmall',
  22236. 'Xsmall',
  22237. 'Ysmall',
  22238. 'Zsmall',
  22239. 'colonmonetary',
  22240. 'onefitted',
  22241. 'rupiah',
  22242. 'Tildesmall',
  22243. 'exclamdownsmall',
  22244. 'centoldstyle',
  22245. 'Lslashsmall',
  22246. 'Scaronsmall',
  22247. 'Zcaronsmall',
  22248. 'Dieresissmall',
  22249. 'Brevesmall',
  22250. 'Caronsmall',
  22251. 'Dotaccentsmall',
  22252. 'Macronsmall',
  22253. 'figuredash',
  22254. 'hypheninferior',
  22255. 'Ogoneksmall',
  22256. 'Ringsmall',
  22257. 'Cedillasmall',
  22258. 'questiondownsmall',
  22259. 'oneeighth',
  22260. 'threeeighths',
  22261. 'fiveeighths',
  22262. 'seveneighths',
  22263. 'onethird',
  22264. 'twothirds',
  22265. 'zerosuperior',
  22266. 'foursuperior',
  22267. 'fivesuperior',
  22268. 'sixsuperior',
  22269. 'sevensuperior',
  22270. 'eightsuperior',
  22271. 'ninesuperior',
  22272. 'zeroinferior',
  22273. 'oneinferior',
  22274. 'twoinferior',
  22275. 'threeinferior',
  22276. 'fourinferior',
  22277. 'fiveinferior',
  22278. 'sixinferior',
  22279. 'seveninferior',
  22280. 'eightinferior',
  22281. 'nineinferior',
  22282. 'centinferior',
  22283. 'dollarinferior',
  22284. 'periodinferior',
  22285. 'commainferior',
  22286. 'Agravesmall',
  22287. 'Aacutesmall',
  22288. 'Acircumflexsmall',
  22289. 'Atildesmall',
  22290. 'Adieresissmall',
  22291. 'Aringsmall',
  22292. 'AEsmall',
  22293. 'Ccedillasmall',
  22294. 'Egravesmall',
  22295. 'Eacutesmall',
  22296. 'Ecircumflexsmall',
  22297. 'Edieresissmall',
  22298. 'Igravesmall',
  22299. 'Iacutesmall',
  22300. 'Icircumflexsmall',
  22301. 'Idieresissmall',
  22302. 'Ethsmall',
  22303. 'Ntildesmall',
  22304. 'Ogravesmall',
  22305. 'Oacutesmall',
  22306. 'Ocircumflexsmall',
  22307. 'Otildesmall',
  22308. 'Odieresissmall',
  22309. 'OEsmall',
  22310. 'Oslashsmall',
  22311. 'Ugravesmall',
  22312. 'Uacutesmall',
  22313. 'Ucircumflexsmall',
  22314. 'Udieresissmall',
  22315. 'Yacutesmall',
  22316. 'Thornsmall',
  22317. 'Ydieresissmall',
  22318. '001.000',
  22319. '001.001',
  22320. '001.002',
  22321. '001.003',
  22322. 'Black',
  22323. 'Bold',
  22324. 'Book',
  22325. 'Light',
  22326. 'Medium',
  22327. 'Regular',
  22328. 'Roman',
  22329. 'Semibold'
  22330. ];
  22331. var CFFParser = function CFFParserClosure() {
  22332. var CharstringValidationData = [
  22333. null,
  22334. {
  22335. id: 'hstem',
  22336. min: 2,
  22337. stackClearing: true,
  22338. stem: true
  22339. },
  22340. null,
  22341. {
  22342. id: 'vstem',
  22343. min: 2,
  22344. stackClearing: true,
  22345. stem: true
  22346. },
  22347. {
  22348. id: 'vmoveto',
  22349. min: 1,
  22350. stackClearing: true
  22351. },
  22352. {
  22353. id: 'rlineto',
  22354. min: 2,
  22355. resetStack: true
  22356. },
  22357. {
  22358. id: 'hlineto',
  22359. min: 1,
  22360. resetStack: true
  22361. },
  22362. {
  22363. id: 'vlineto',
  22364. min: 1,
  22365. resetStack: true
  22366. },
  22367. {
  22368. id: 'rrcurveto',
  22369. min: 6,
  22370. resetStack: true
  22371. },
  22372. null,
  22373. {
  22374. id: 'callsubr',
  22375. min: 1,
  22376. undefStack: true
  22377. },
  22378. {
  22379. id: 'return',
  22380. min: 0,
  22381. undefStack: true
  22382. },
  22383. null,
  22384. null,
  22385. {
  22386. id: 'endchar',
  22387. min: 0,
  22388. stackClearing: true
  22389. },
  22390. null,
  22391. null,
  22392. null,
  22393. {
  22394. id: 'hstemhm',
  22395. min: 2,
  22396. stackClearing: true,
  22397. stem: true
  22398. },
  22399. {
  22400. id: 'hintmask',
  22401. min: 0,
  22402. stackClearing: true
  22403. },
  22404. {
  22405. id: 'cntrmask',
  22406. min: 0,
  22407. stackClearing: true
  22408. },
  22409. {
  22410. id: 'rmoveto',
  22411. min: 2,
  22412. stackClearing: true
  22413. },
  22414. {
  22415. id: 'hmoveto',
  22416. min: 1,
  22417. stackClearing: true
  22418. },
  22419. {
  22420. id: 'vstemhm',
  22421. min: 2,
  22422. stackClearing: true,
  22423. stem: true
  22424. },
  22425. {
  22426. id: 'rcurveline',
  22427. min: 8,
  22428. resetStack: true
  22429. },
  22430. {
  22431. id: 'rlinecurve',
  22432. min: 8,
  22433. resetStack: true
  22434. },
  22435. {
  22436. id: 'vvcurveto',
  22437. min: 4,
  22438. resetStack: true
  22439. },
  22440. {
  22441. id: 'hhcurveto',
  22442. min: 4,
  22443. resetStack: true
  22444. },
  22445. null,
  22446. {
  22447. id: 'callgsubr',
  22448. min: 1,
  22449. undefStack: true
  22450. },
  22451. {
  22452. id: 'vhcurveto',
  22453. min: 4,
  22454. resetStack: true
  22455. },
  22456. {
  22457. id: 'hvcurveto',
  22458. min: 4,
  22459. resetStack: true
  22460. }
  22461. ];
  22462. var CharstringValidationData12 = [
  22463. null,
  22464. null,
  22465. null,
  22466. {
  22467. id: 'and',
  22468. min: 2,
  22469. stackDelta: -1
  22470. },
  22471. {
  22472. id: 'or',
  22473. min: 2,
  22474. stackDelta: -1
  22475. },
  22476. {
  22477. id: 'not',
  22478. min: 1,
  22479. stackDelta: 0
  22480. },
  22481. null,
  22482. null,
  22483. null,
  22484. {
  22485. id: 'abs',
  22486. min: 1,
  22487. stackDelta: 0
  22488. },
  22489. {
  22490. id: 'add',
  22491. min: 2,
  22492. stackDelta: -1,
  22493. stackFn: function stack_div(stack, index) {
  22494. stack[index - 2] = stack[index - 2] + stack[index - 1];
  22495. }
  22496. },
  22497. {
  22498. id: 'sub',
  22499. min: 2,
  22500. stackDelta: -1,
  22501. stackFn: function stack_div(stack, index) {
  22502. stack[index - 2] = stack[index - 2] - stack[index - 1];
  22503. }
  22504. },
  22505. {
  22506. id: 'div',
  22507. min: 2,
  22508. stackDelta: -1,
  22509. stackFn: function stack_div(stack, index) {
  22510. stack[index - 2] = stack[index - 2] / stack[index - 1];
  22511. }
  22512. },
  22513. null,
  22514. {
  22515. id: 'neg',
  22516. min: 1,
  22517. stackDelta: 0,
  22518. stackFn: function stack_div(stack, index) {
  22519. stack[index - 1] = -stack[index - 1];
  22520. }
  22521. },
  22522. {
  22523. id: 'eq',
  22524. min: 2,
  22525. stackDelta: -1
  22526. },
  22527. null,
  22528. null,
  22529. {
  22530. id: 'drop',
  22531. min: 1,
  22532. stackDelta: -1
  22533. },
  22534. null,
  22535. {
  22536. id: 'put',
  22537. min: 2,
  22538. stackDelta: -2
  22539. },
  22540. {
  22541. id: 'get',
  22542. min: 1,
  22543. stackDelta: 0
  22544. },
  22545. {
  22546. id: 'ifelse',
  22547. min: 4,
  22548. stackDelta: -3
  22549. },
  22550. {
  22551. id: 'random',
  22552. min: 0,
  22553. stackDelta: 1
  22554. },
  22555. {
  22556. id: 'mul',
  22557. min: 2,
  22558. stackDelta: -1,
  22559. stackFn: function stack_div(stack, index) {
  22560. stack[index - 2] = stack[index - 2] * stack[index - 1];
  22561. }
  22562. },
  22563. null,
  22564. {
  22565. id: 'sqrt',
  22566. min: 1,
  22567. stackDelta: 0
  22568. },
  22569. {
  22570. id: 'dup',
  22571. min: 1,
  22572. stackDelta: 1
  22573. },
  22574. {
  22575. id: 'exch',
  22576. min: 2,
  22577. stackDelta: 0
  22578. },
  22579. {
  22580. id: 'index',
  22581. min: 2,
  22582. stackDelta: 0
  22583. },
  22584. {
  22585. id: 'roll',
  22586. min: 3,
  22587. stackDelta: -2
  22588. },
  22589. null,
  22590. null,
  22591. null,
  22592. {
  22593. id: 'hflex',
  22594. min: 7,
  22595. resetStack: true
  22596. },
  22597. {
  22598. id: 'flex',
  22599. min: 13,
  22600. resetStack: true
  22601. },
  22602. {
  22603. id: 'hflex1',
  22604. min: 9,
  22605. resetStack: true
  22606. },
  22607. {
  22608. id: 'flex1',
  22609. min: 11,
  22610. resetStack: true
  22611. }
  22612. ];
  22613. function CFFParser(file, properties, seacAnalysisEnabled) {
  22614. this.bytes = file.getBytes();
  22615. this.properties = properties;
  22616. this.seacAnalysisEnabled = !!seacAnalysisEnabled;
  22617. }
  22618. CFFParser.prototype = {
  22619. parse: function CFFParser_parse() {
  22620. var properties = this.properties;
  22621. var cff = new CFF();
  22622. this.cff = cff;
  22623. var header = this.parseHeader();
  22624. var nameIndex = this.parseIndex(header.endPos);
  22625. var topDictIndex = this.parseIndex(nameIndex.endPos);
  22626. var stringIndex = this.parseIndex(topDictIndex.endPos);
  22627. var globalSubrIndex = this.parseIndex(stringIndex.endPos);
  22628. var topDictParsed = this.parseDict(topDictIndex.obj.get(0));
  22629. var topDict = this.createDict(CFFTopDict, topDictParsed, cff.strings);
  22630. cff.header = header.obj;
  22631. cff.names = this.parseNameIndex(nameIndex.obj);
  22632. cff.strings = this.parseStringIndex(stringIndex.obj);
  22633. cff.topDict = topDict;
  22634. cff.globalSubrIndex = globalSubrIndex.obj;
  22635. this.parsePrivateDict(cff.topDict);
  22636. cff.isCIDFont = topDict.hasName('ROS');
  22637. var charStringOffset = topDict.getByName('CharStrings');
  22638. var charStringIndex = this.parseIndex(charStringOffset).obj;
  22639. var fontMatrix = topDict.getByName('FontMatrix');
  22640. if (fontMatrix) {
  22641. properties.fontMatrix = fontMatrix;
  22642. }
  22643. var fontBBox = topDict.getByName('FontBBox');
  22644. if (fontBBox) {
  22645. properties.ascent = Math.max(fontBBox[3], fontBBox[1]);
  22646. properties.descent = Math.min(fontBBox[1], fontBBox[3]);
  22647. properties.ascentScaled = true;
  22648. }
  22649. var charset, encoding;
  22650. if (cff.isCIDFont) {
  22651. var fdArrayIndex = this.parseIndex(topDict.getByName('FDArray')).obj;
  22652. for (var i = 0, ii = fdArrayIndex.count; i < ii; ++i) {
  22653. var dictRaw = fdArrayIndex.get(i);
  22654. var fontDict = this.createDict(CFFTopDict, this.parseDict(dictRaw), cff.strings);
  22655. this.parsePrivateDict(fontDict);
  22656. cff.fdArray.push(fontDict);
  22657. }
  22658. encoding = null;
  22659. charset = this.parseCharsets(topDict.getByName('charset'), charStringIndex.count, cff.strings, true);
  22660. cff.fdSelect = this.parseFDSelect(topDict.getByName('FDSelect'), charStringIndex.count);
  22661. } else {
  22662. charset = this.parseCharsets(topDict.getByName('charset'), charStringIndex.count, cff.strings, false);
  22663. encoding = this.parseEncoding(topDict.getByName('Encoding'), properties, cff.strings, charset.charset);
  22664. }
  22665. cff.charset = charset;
  22666. cff.encoding = encoding;
  22667. var charStringsAndSeacs = this.parseCharStrings(charStringIndex, topDict.privateDict.subrsIndex, globalSubrIndex.obj, cff.fdSelect, cff.fdArray);
  22668. cff.charStrings = charStringsAndSeacs.charStrings;
  22669. cff.seacs = charStringsAndSeacs.seacs;
  22670. cff.widths = charStringsAndSeacs.widths;
  22671. return cff;
  22672. },
  22673. parseHeader: function CFFParser_parseHeader() {
  22674. var bytes = this.bytes;
  22675. var bytesLength = bytes.length;
  22676. var offset = 0;
  22677. while (offset < bytesLength && bytes[offset] !== 1) {
  22678. ++offset;
  22679. }
  22680. if (offset >= bytesLength) {
  22681. error('Invalid CFF header');
  22682. } else if (offset !== 0) {
  22683. info('cff data is shifted');
  22684. bytes = bytes.subarray(offset);
  22685. this.bytes = bytes;
  22686. }
  22687. var major = bytes[0];
  22688. var minor = bytes[1];
  22689. var hdrSize = bytes[2];
  22690. var offSize = bytes[3];
  22691. var header = new CFFHeader(major, minor, hdrSize, offSize);
  22692. return {
  22693. obj: header,
  22694. endPos: hdrSize
  22695. };
  22696. },
  22697. parseDict: function CFFParser_parseDict(dict) {
  22698. var pos = 0;
  22699. function parseOperand() {
  22700. var value = dict[pos++];
  22701. if (value === 30) {
  22702. return parseFloatOperand();
  22703. } else if (value === 28) {
  22704. value = dict[pos++];
  22705. value = (value << 24 | dict[pos++] << 16) >> 16;
  22706. return value;
  22707. } else if (value === 29) {
  22708. value = dict[pos++];
  22709. value = value << 8 | dict[pos++];
  22710. value = value << 8 | dict[pos++];
  22711. value = value << 8 | dict[pos++];
  22712. return value;
  22713. } else if (value >= 32 && value <= 246) {
  22714. return value - 139;
  22715. } else if (value >= 247 && value <= 250) {
  22716. return (value - 247) * 256 + dict[pos++] + 108;
  22717. } else if (value >= 251 && value <= 254) {
  22718. return -((value - 251) * 256) - dict[pos++] - 108;
  22719. }
  22720. warn('CFFParser_parseDict: "' + value + '" is a reserved command.');
  22721. return NaN;
  22722. }
  22723. function parseFloatOperand() {
  22724. var str = '';
  22725. var eof = 15;
  22726. var lookup = [
  22727. '0',
  22728. '1',
  22729. '2',
  22730. '3',
  22731. '4',
  22732. '5',
  22733. '6',
  22734. '7',
  22735. '8',
  22736. '9',
  22737. '.',
  22738. 'E',
  22739. 'E-',
  22740. null,
  22741. '-'
  22742. ];
  22743. var length = dict.length;
  22744. while (pos < length) {
  22745. var b = dict[pos++];
  22746. var b1 = b >> 4;
  22747. var b2 = b & 15;
  22748. if (b1 === eof) {
  22749. break;
  22750. }
  22751. str += lookup[b1];
  22752. if (b2 === eof) {
  22753. break;
  22754. }
  22755. str += lookup[b2];
  22756. }
  22757. return parseFloat(str);
  22758. }
  22759. var operands = [];
  22760. var entries = [];
  22761. pos = 0;
  22762. var end = dict.length;
  22763. while (pos < end) {
  22764. var b = dict[pos];
  22765. if (b <= 21) {
  22766. if (b === 12) {
  22767. b = b << 8 | dict[++pos];
  22768. }
  22769. entries.push([
  22770. b,
  22771. operands
  22772. ]);
  22773. operands = [];
  22774. ++pos;
  22775. } else {
  22776. operands.push(parseOperand());
  22777. }
  22778. }
  22779. return entries;
  22780. },
  22781. parseIndex: function CFFParser_parseIndex(pos) {
  22782. var cffIndex = new CFFIndex();
  22783. var bytes = this.bytes;
  22784. var count = bytes[pos++] << 8 | bytes[pos++];
  22785. var offsets = [];
  22786. var end = pos;
  22787. var i, ii;
  22788. if (count !== 0) {
  22789. var offsetSize = bytes[pos++];
  22790. var startPos = pos + (count + 1) * offsetSize - 1;
  22791. for (i = 0, ii = count + 1; i < ii; ++i) {
  22792. var offset = 0;
  22793. for (var j = 0; j < offsetSize; ++j) {
  22794. offset <<= 8;
  22795. offset += bytes[pos++];
  22796. }
  22797. offsets.push(startPos + offset);
  22798. }
  22799. end = offsets[count];
  22800. }
  22801. for (i = 0, ii = offsets.length - 1; i < ii; ++i) {
  22802. var offsetStart = offsets[i];
  22803. var offsetEnd = offsets[i + 1];
  22804. cffIndex.add(bytes.subarray(offsetStart, offsetEnd));
  22805. }
  22806. return {
  22807. obj: cffIndex,
  22808. endPos: end
  22809. };
  22810. },
  22811. parseNameIndex: function CFFParser_parseNameIndex(index) {
  22812. var names = [];
  22813. for (var i = 0, ii = index.count; i < ii; ++i) {
  22814. var name = index.get(i);
  22815. var length = Math.min(name.length, 127);
  22816. var data = [];
  22817. for (var j = 0; j < length; ++j) {
  22818. var c = name[j];
  22819. if (j === 0 && c === 0) {
  22820. data[j] = c;
  22821. continue;
  22822. }
  22823. 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) {
  22824. data[j] = 95;
  22825. continue;
  22826. }
  22827. data[j] = c;
  22828. }
  22829. names.push(bytesToString(data));
  22830. }
  22831. return names;
  22832. },
  22833. parseStringIndex: function CFFParser_parseStringIndex(index) {
  22834. var strings = new CFFStrings();
  22835. for (var i = 0, ii = index.count; i < ii; ++i) {
  22836. var data = index.get(i);
  22837. strings.add(bytesToString(data));
  22838. }
  22839. return strings;
  22840. },
  22841. createDict: function CFFParser_createDict(Type, dict, strings) {
  22842. var cffDict = new Type(strings);
  22843. for (var i = 0, ii = dict.length; i < ii; ++i) {
  22844. var pair = dict[i];
  22845. var key = pair[0];
  22846. var value = pair[1];
  22847. cffDict.setByKey(key, value);
  22848. }
  22849. return cffDict;
  22850. },
  22851. parseCharString: function CFFParser_parseCharString(state, data, localSubrIndex, globalSubrIndex) {
  22852. if (!data || state.callDepth > MAX_SUBR_NESTING) {
  22853. return false;
  22854. }
  22855. var stackSize = state.stackSize;
  22856. var stack = state.stack;
  22857. var length = data.length;
  22858. for (var j = 0; j < length;) {
  22859. var value = data[j++];
  22860. var validationCommand = null;
  22861. if (value === 12) {
  22862. var q = data[j++];
  22863. if (q === 0) {
  22864. data[j - 2] = 139;
  22865. data[j - 1] = 22;
  22866. stackSize = 0;
  22867. } else {
  22868. validationCommand = CharstringValidationData12[q];
  22869. }
  22870. } else if (value === 28) {
  22871. stack[stackSize] = (data[j] << 24 | data[j + 1] << 16) >> 16;
  22872. j += 2;
  22873. stackSize++;
  22874. } else if (value === 14) {
  22875. if (stackSize >= 4) {
  22876. stackSize -= 4;
  22877. if (this.seacAnalysisEnabled) {
  22878. state.seac = stack.slice(stackSize, stackSize + 4);
  22879. return false;
  22880. }
  22881. }
  22882. validationCommand = CharstringValidationData[value];
  22883. } else if (value >= 32 && value <= 246) {
  22884. stack[stackSize] = value - 139;
  22885. stackSize++;
  22886. } else if (value >= 247 && value <= 254) {
  22887. stack[stackSize] = value < 251 ? (value - 247 << 8) + data[j] + 108 : -(value - 251 << 8) - data[j] - 108;
  22888. j++;
  22889. stackSize++;
  22890. } else if (value === 255) {
  22891. stack[stackSize] = (data[j] << 24 | data[j + 1] << 16 | data[j + 2] << 8 | data[j + 3]) / 65536;
  22892. j += 4;
  22893. stackSize++;
  22894. } else if (value === 19 || value === 20) {
  22895. state.hints += stackSize >> 1;
  22896. j += state.hints + 7 >> 3;
  22897. stackSize %= 2;
  22898. validationCommand = CharstringValidationData[value];
  22899. } else if (value === 10 || value === 29) {
  22900. var subrsIndex;
  22901. if (value === 10) {
  22902. subrsIndex = localSubrIndex;
  22903. } else {
  22904. subrsIndex = globalSubrIndex;
  22905. }
  22906. if (!subrsIndex) {
  22907. validationCommand = CharstringValidationData[value];
  22908. warn('Missing subrsIndex for ' + validationCommand.id);
  22909. return false;
  22910. }
  22911. var bias = 32768;
  22912. if (subrsIndex.count < 1240) {
  22913. bias = 107;
  22914. } else if (subrsIndex.count < 33900) {
  22915. bias = 1131;
  22916. }
  22917. var subrNumber = stack[--stackSize] + bias;
  22918. if (subrNumber < 0 || subrNumber >= subrsIndex.count || isNaN(subrNumber)) {
  22919. validationCommand = CharstringValidationData[value];
  22920. warn('Out of bounds subrIndex for ' + validationCommand.id);
  22921. return false;
  22922. }
  22923. state.stackSize = stackSize;
  22924. state.callDepth++;
  22925. var valid = this.parseCharString(state, subrsIndex.get(subrNumber), localSubrIndex, globalSubrIndex);
  22926. if (!valid) {
  22927. return false;
  22928. }
  22929. state.callDepth--;
  22930. stackSize = state.stackSize;
  22931. continue;
  22932. } else if (value === 11) {
  22933. state.stackSize = stackSize;
  22934. return true;
  22935. } else {
  22936. validationCommand = CharstringValidationData[value];
  22937. }
  22938. if (validationCommand) {
  22939. if (validationCommand.stem) {
  22940. state.hints += stackSize >> 1;
  22941. }
  22942. if ('min' in validationCommand) {
  22943. if (!state.undefStack && stackSize < validationCommand.min) {
  22944. warn('Not enough parameters for ' + validationCommand.id + '; actual: ' + stackSize + ', expected: ' + validationCommand.min);
  22945. return false;
  22946. }
  22947. }
  22948. if (state.firstStackClearing && validationCommand.stackClearing) {
  22949. state.firstStackClearing = false;
  22950. stackSize -= validationCommand.min;
  22951. if (stackSize >= 2 && validationCommand.stem) {
  22952. stackSize %= 2;
  22953. } else if (stackSize > 1) {
  22954. warn('Found too many parameters for stack-clearing command');
  22955. }
  22956. if (stackSize > 0 && stack[stackSize - 1] >= 0) {
  22957. state.width = stack[stackSize - 1];
  22958. }
  22959. }
  22960. if ('stackDelta' in validationCommand) {
  22961. if ('stackFn' in validationCommand) {
  22962. validationCommand.stackFn(stack, stackSize);
  22963. }
  22964. stackSize += validationCommand.stackDelta;
  22965. } else if (validationCommand.stackClearing) {
  22966. stackSize = 0;
  22967. } else if (validationCommand.resetStack) {
  22968. stackSize = 0;
  22969. state.undefStack = false;
  22970. } else if (validationCommand.undefStack) {
  22971. stackSize = 0;
  22972. state.undefStack = true;
  22973. state.firstStackClearing = false;
  22974. }
  22975. }
  22976. }
  22977. state.stackSize = stackSize;
  22978. return true;
  22979. },
  22980. parseCharStrings: function CFFParser_parseCharStrings(charStrings, localSubrIndex, globalSubrIndex, fdSelect, fdArray) {
  22981. var seacs = [];
  22982. var widths = [];
  22983. var count = charStrings.count;
  22984. for (var i = 0; i < count; i++) {
  22985. var charstring = charStrings.get(i);
  22986. var state = {
  22987. callDepth: 0,
  22988. stackSize: 0,
  22989. stack: [],
  22990. undefStack: true,
  22991. hints: 0,
  22992. firstStackClearing: true,
  22993. seac: null,
  22994. width: null
  22995. };
  22996. var valid = true;
  22997. var localSubrToUse = null;
  22998. if (fdSelect && fdArray.length) {
  22999. var fdIndex = fdSelect.getFDIndex(i);
  23000. if (fdIndex === -1) {
  23001. warn('Glyph index is not in fd select.');
  23002. valid = false;
  23003. }
  23004. if (fdIndex >= fdArray.length) {
  23005. warn('Invalid fd index for glyph index.');
  23006. valid = false;
  23007. }
  23008. if (valid) {
  23009. localSubrToUse = fdArray[fdIndex].privateDict.subrsIndex;
  23010. }
  23011. } else if (localSubrIndex) {
  23012. localSubrToUse = localSubrIndex;
  23013. }
  23014. if (valid) {
  23015. valid = this.parseCharString(state, charstring, localSubrToUse, globalSubrIndex);
  23016. }
  23017. if (state.width !== null) {
  23018. widths[i] = state.width;
  23019. }
  23020. if (state.seac !== null) {
  23021. seacs[i] = state.seac;
  23022. }
  23023. if (!valid) {
  23024. charStrings.set(i, new Uint8Array([14]));
  23025. }
  23026. }
  23027. return {
  23028. charStrings: charStrings,
  23029. seacs: seacs,
  23030. widths: widths
  23031. };
  23032. },
  23033. emptyPrivateDictionary: function CFFParser_emptyPrivateDictionary(parentDict) {
  23034. var privateDict = this.createDict(CFFPrivateDict, [], parentDict.strings);
  23035. parentDict.setByKey(18, [
  23036. 0,
  23037. 0
  23038. ]);
  23039. parentDict.privateDict = privateDict;
  23040. },
  23041. parsePrivateDict: function CFFParser_parsePrivateDict(parentDict) {
  23042. if (!parentDict.hasName('Private')) {
  23043. this.emptyPrivateDictionary(parentDict);
  23044. return;
  23045. }
  23046. var privateOffset = parentDict.getByName('Private');
  23047. if (!isArray(privateOffset) || privateOffset.length !== 2) {
  23048. parentDict.removeByName('Private');
  23049. return;
  23050. }
  23051. var size = privateOffset[0];
  23052. var offset = privateOffset[1];
  23053. if (size === 0 || offset >= this.bytes.length) {
  23054. this.emptyPrivateDictionary(parentDict);
  23055. return;
  23056. }
  23057. var privateDictEnd = offset + size;
  23058. var dictData = this.bytes.subarray(offset, privateDictEnd);
  23059. var dict = this.parseDict(dictData);
  23060. var privateDict = this.createDict(CFFPrivateDict, dict, parentDict.strings);
  23061. parentDict.privateDict = privateDict;
  23062. if (!privateDict.getByName('Subrs')) {
  23063. return;
  23064. }
  23065. var subrsOffset = privateDict.getByName('Subrs');
  23066. var relativeOffset = offset + subrsOffset;
  23067. if (subrsOffset === 0 || relativeOffset >= this.bytes.length) {
  23068. this.emptyPrivateDictionary(parentDict);
  23069. return;
  23070. }
  23071. var subrsIndex = this.parseIndex(relativeOffset);
  23072. privateDict.subrsIndex = subrsIndex.obj;
  23073. },
  23074. parseCharsets: function CFFParser_parseCharsets(pos, length, strings, cid) {
  23075. if (pos === 0) {
  23076. return new CFFCharset(true, CFFCharsetPredefinedTypes.ISO_ADOBE, ISOAdobeCharset);
  23077. } else if (pos === 1) {
  23078. return new CFFCharset(true, CFFCharsetPredefinedTypes.EXPERT, ExpertCharset);
  23079. } else if (pos === 2) {
  23080. return new CFFCharset(true, CFFCharsetPredefinedTypes.EXPERT_SUBSET, ExpertSubsetCharset);
  23081. }
  23082. var bytes = this.bytes;
  23083. var start = pos;
  23084. var format = bytes[pos++];
  23085. var charset = ['.notdef'];
  23086. var id, count, i;
  23087. length -= 1;
  23088. switch (format) {
  23089. case 0:
  23090. for (i = 0; i < length; i++) {
  23091. id = bytes[pos++] << 8 | bytes[pos++];
  23092. charset.push(cid ? id : strings.get(id));
  23093. }
  23094. break;
  23095. case 1:
  23096. while (charset.length <= length) {
  23097. id = bytes[pos++] << 8 | bytes[pos++];
  23098. count = bytes[pos++];
  23099. for (i = 0; i <= count; i++) {
  23100. charset.push(cid ? id++ : strings.get(id++));
  23101. }
  23102. }
  23103. break;
  23104. case 2:
  23105. while (charset.length <= length) {
  23106. id = bytes[pos++] << 8 | bytes[pos++];
  23107. count = bytes[pos++] << 8 | bytes[pos++];
  23108. for (i = 0; i <= count; i++) {
  23109. charset.push(cid ? id++ : strings.get(id++));
  23110. }
  23111. }
  23112. break;
  23113. default:
  23114. error('Unknown charset format');
  23115. }
  23116. var end = pos;
  23117. var raw = bytes.subarray(start, end);
  23118. return new CFFCharset(false, format, charset, raw);
  23119. },
  23120. parseEncoding: function CFFParser_parseEncoding(pos, properties, strings, charset) {
  23121. var encoding = Object.create(null);
  23122. var bytes = this.bytes;
  23123. var predefined = false;
  23124. var format, i, ii;
  23125. var raw = null;
  23126. function readSupplement() {
  23127. var supplementsCount = bytes[pos++];
  23128. for (i = 0; i < supplementsCount; i++) {
  23129. var code = bytes[pos++];
  23130. var sid = (bytes[pos++] << 8) + (bytes[pos++] & 0xff);
  23131. encoding[code] = charset.indexOf(strings.get(sid));
  23132. }
  23133. }
  23134. if (pos === 0 || pos === 1) {
  23135. predefined = true;
  23136. format = pos;
  23137. var baseEncoding = pos ? ExpertEncoding : StandardEncoding;
  23138. for (i = 0, ii = charset.length; i < ii; i++) {
  23139. var index = baseEncoding.indexOf(charset[i]);
  23140. if (index !== -1) {
  23141. encoding[index] = i;
  23142. }
  23143. }
  23144. } else {
  23145. var dataStart = pos;
  23146. format = bytes[pos++];
  23147. switch (format & 0x7f) {
  23148. case 0:
  23149. var glyphsCount = bytes[pos++];
  23150. for (i = 1; i <= glyphsCount; i++) {
  23151. encoding[bytes[pos++]] = i;
  23152. }
  23153. break;
  23154. case 1:
  23155. var rangesCount = bytes[pos++];
  23156. var gid = 1;
  23157. for (i = 0; i < rangesCount; i++) {
  23158. var start = bytes[pos++];
  23159. var left = bytes[pos++];
  23160. for (var j = start; j <= start + left; j++) {
  23161. encoding[j] = gid++;
  23162. }
  23163. }
  23164. break;
  23165. default:
  23166. error('Unknown encoding format: ' + format + ' in CFF');
  23167. break;
  23168. }
  23169. var dataEnd = pos;
  23170. if (format & 0x80) {
  23171. bytes[dataStart] &= 0x7f;
  23172. readSupplement();
  23173. }
  23174. raw = bytes.subarray(dataStart, dataEnd);
  23175. }
  23176. format = format & 0x7f;
  23177. return new CFFEncoding(predefined, format, encoding, raw);
  23178. },
  23179. parseFDSelect: function CFFParser_parseFDSelect(pos, length) {
  23180. var start = pos;
  23181. var bytes = this.bytes;
  23182. var format = bytes[pos++];
  23183. var fdSelect = [], rawBytes;
  23184. var i, invalidFirstGID = false;
  23185. switch (format) {
  23186. case 0:
  23187. for (i = 0; i < length; ++i) {
  23188. var id = bytes[pos++];
  23189. fdSelect.push(id);
  23190. }
  23191. rawBytes = bytes.subarray(start, pos);
  23192. break;
  23193. case 3:
  23194. var rangesCount = bytes[pos++] << 8 | bytes[pos++];
  23195. for (i = 0; i < rangesCount; ++i) {
  23196. var first = bytes[pos++] << 8 | bytes[pos++];
  23197. if (i === 0 && first !== 0) {
  23198. warn('parseFDSelect: The first range must have a first GID of 0' + ' -- trying to recover.');
  23199. invalidFirstGID = true;
  23200. first = 0;
  23201. }
  23202. var fdIndex = bytes[pos++];
  23203. var next = bytes[pos] << 8 | bytes[pos + 1];
  23204. for (var j = first; j < next; ++j) {
  23205. fdSelect.push(fdIndex);
  23206. }
  23207. }
  23208. pos += 2;
  23209. rawBytes = bytes.subarray(start, pos);
  23210. if (invalidFirstGID) {
  23211. rawBytes[3] = rawBytes[4] = 0;
  23212. }
  23213. break;
  23214. default:
  23215. error('parseFDSelect: Unknown format "' + format + '".');
  23216. break;
  23217. }
  23218. assert(fdSelect.length === length, 'parseFDSelect: Invalid font data.');
  23219. return new CFFFDSelect(fdSelect, rawBytes);
  23220. }
  23221. };
  23222. return CFFParser;
  23223. }();
  23224. var CFF = function CFFClosure() {
  23225. function CFF() {
  23226. this.header = null;
  23227. this.names = [];
  23228. this.topDict = null;
  23229. this.strings = new CFFStrings();
  23230. this.globalSubrIndex = null;
  23231. this.encoding = null;
  23232. this.charset = null;
  23233. this.charStrings = null;
  23234. this.fdArray = [];
  23235. this.fdSelect = null;
  23236. this.isCIDFont = false;
  23237. }
  23238. return CFF;
  23239. }();
  23240. var CFFHeader = function CFFHeaderClosure() {
  23241. function CFFHeader(major, minor, hdrSize, offSize) {
  23242. this.major = major;
  23243. this.minor = minor;
  23244. this.hdrSize = hdrSize;
  23245. this.offSize = offSize;
  23246. }
  23247. return CFFHeader;
  23248. }();
  23249. var CFFStrings = function CFFStringsClosure() {
  23250. function CFFStrings() {
  23251. this.strings = [];
  23252. }
  23253. CFFStrings.prototype = {
  23254. get: function CFFStrings_get(index) {
  23255. if (index >= 0 && index <= 390) {
  23256. return CFFStandardStrings[index];
  23257. }
  23258. if (index - 391 <= this.strings.length) {
  23259. return this.strings[index - 391];
  23260. }
  23261. return CFFStandardStrings[0];
  23262. },
  23263. add: function CFFStrings_add(value) {
  23264. this.strings.push(value);
  23265. },
  23266. get count() {
  23267. return this.strings.length;
  23268. }
  23269. };
  23270. return CFFStrings;
  23271. }();
  23272. var CFFIndex = function CFFIndexClosure() {
  23273. function CFFIndex() {
  23274. this.objects = [];
  23275. this.length = 0;
  23276. }
  23277. CFFIndex.prototype = {
  23278. add: function CFFIndex_add(data) {
  23279. this.length += data.length;
  23280. this.objects.push(data);
  23281. },
  23282. set: function CFFIndex_set(index, data) {
  23283. this.length += data.length - this.objects[index].length;
  23284. this.objects[index] = data;
  23285. },
  23286. get: function CFFIndex_get(index) {
  23287. return this.objects[index];
  23288. },
  23289. get count() {
  23290. return this.objects.length;
  23291. }
  23292. };
  23293. return CFFIndex;
  23294. }();
  23295. var CFFDict = function CFFDictClosure() {
  23296. function CFFDict(tables, strings) {
  23297. this.keyToNameMap = tables.keyToNameMap;
  23298. this.nameToKeyMap = tables.nameToKeyMap;
  23299. this.defaults = tables.defaults;
  23300. this.types = tables.types;
  23301. this.opcodes = tables.opcodes;
  23302. this.order = tables.order;
  23303. this.strings = strings;
  23304. this.values = Object.create(null);
  23305. }
  23306. CFFDict.prototype = {
  23307. setByKey: function CFFDict_setByKey(key, value) {
  23308. if (!(key in this.keyToNameMap)) {
  23309. return false;
  23310. }
  23311. var valueLength = value.length;
  23312. if (valueLength === 0) {
  23313. return true;
  23314. }
  23315. for (var i = 0; i < valueLength; i++) {
  23316. if (isNaN(value[i])) {
  23317. warn('Invalid CFFDict value: "' + value + '" for key "' + key + '".');
  23318. return true;
  23319. }
  23320. }
  23321. var type = this.types[key];
  23322. if (type === 'num' || type === 'sid' || type === 'offset') {
  23323. value = value[0];
  23324. }
  23325. this.values[key] = value;
  23326. return true;
  23327. },
  23328. setByName: function CFFDict_setByName(name, value) {
  23329. if (!(name in this.nameToKeyMap)) {
  23330. error('Invalid dictionary name "' + name + '"');
  23331. }
  23332. this.values[this.nameToKeyMap[name]] = value;
  23333. },
  23334. hasName: function CFFDict_hasName(name) {
  23335. return this.nameToKeyMap[name] in this.values;
  23336. },
  23337. getByName: function CFFDict_getByName(name) {
  23338. if (!(name in this.nameToKeyMap)) {
  23339. error('Invalid dictionary name "' + name + '"');
  23340. }
  23341. var key = this.nameToKeyMap[name];
  23342. if (!(key in this.values)) {
  23343. return this.defaults[key];
  23344. }
  23345. return this.values[key];
  23346. },
  23347. removeByName: function CFFDict_removeByName(name) {
  23348. delete this.values[this.nameToKeyMap[name]];
  23349. }
  23350. };
  23351. CFFDict.createTables = function CFFDict_createTables(layout) {
  23352. var tables = {
  23353. keyToNameMap: {},
  23354. nameToKeyMap: {},
  23355. defaults: {},
  23356. types: {},
  23357. opcodes: {},
  23358. order: []
  23359. };
  23360. for (var i = 0, ii = layout.length; i < ii; ++i) {
  23361. var entry = layout[i];
  23362. var key = isArray(entry[0]) ? (entry[0][0] << 8) + entry[0][1] : entry[0];
  23363. tables.keyToNameMap[key] = entry[1];
  23364. tables.nameToKeyMap[entry[1]] = key;
  23365. tables.types[key] = entry[2];
  23366. tables.defaults[key] = entry[3];
  23367. tables.opcodes[key] = isArray(entry[0]) ? entry[0] : [entry[0]];
  23368. tables.order.push(key);
  23369. }
  23370. return tables;
  23371. };
  23372. return CFFDict;
  23373. }();
  23374. var CFFTopDict = function CFFTopDictClosure() {
  23375. var layout = [
  23376. [
  23377. [
  23378. 12,
  23379. 30
  23380. ],
  23381. 'ROS',
  23382. [
  23383. 'sid',
  23384. 'sid',
  23385. 'num'
  23386. ],
  23387. null
  23388. ],
  23389. [
  23390. [
  23391. 12,
  23392. 20
  23393. ],
  23394. 'SyntheticBase',
  23395. 'num',
  23396. null
  23397. ],
  23398. [
  23399. 0,
  23400. 'version',
  23401. 'sid',
  23402. null
  23403. ],
  23404. [
  23405. 1,
  23406. 'Notice',
  23407. 'sid',
  23408. null
  23409. ],
  23410. [
  23411. [
  23412. 12,
  23413. 0
  23414. ],
  23415. 'Copyright',
  23416. 'sid',
  23417. null
  23418. ],
  23419. [
  23420. 2,
  23421. 'FullName',
  23422. 'sid',
  23423. null
  23424. ],
  23425. [
  23426. 3,
  23427. 'FamilyName',
  23428. 'sid',
  23429. null
  23430. ],
  23431. [
  23432. 4,
  23433. 'Weight',
  23434. 'sid',
  23435. null
  23436. ],
  23437. [
  23438. [
  23439. 12,
  23440. 1
  23441. ],
  23442. 'isFixedPitch',
  23443. 'num',
  23444. 0
  23445. ],
  23446. [
  23447. [
  23448. 12,
  23449. 2
  23450. ],
  23451. 'ItalicAngle',
  23452. 'num',
  23453. 0
  23454. ],
  23455. [
  23456. [
  23457. 12,
  23458. 3
  23459. ],
  23460. 'UnderlinePosition',
  23461. 'num',
  23462. -100
  23463. ],
  23464. [
  23465. [
  23466. 12,
  23467. 4
  23468. ],
  23469. 'UnderlineThickness',
  23470. 'num',
  23471. 50
  23472. ],
  23473. [
  23474. [
  23475. 12,
  23476. 5
  23477. ],
  23478. 'PaintType',
  23479. 'num',
  23480. 0
  23481. ],
  23482. [
  23483. [
  23484. 12,
  23485. 6
  23486. ],
  23487. 'CharstringType',
  23488. 'num',
  23489. 2
  23490. ],
  23491. [
  23492. [
  23493. 12,
  23494. 7
  23495. ],
  23496. 'FontMatrix',
  23497. [
  23498. 'num',
  23499. 'num',
  23500. 'num',
  23501. 'num',
  23502. 'num',
  23503. 'num'
  23504. ],
  23505. [
  23506. 0.001,
  23507. 0,
  23508. 0,
  23509. 0.001,
  23510. 0,
  23511. 0
  23512. ]
  23513. ],
  23514. [
  23515. 13,
  23516. 'UniqueID',
  23517. 'num',
  23518. null
  23519. ],
  23520. [
  23521. 5,
  23522. 'FontBBox',
  23523. [
  23524. 'num',
  23525. 'num',
  23526. 'num',
  23527. 'num'
  23528. ],
  23529. [
  23530. 0,
  23531. 0,
  23532. 0,
  23533. 0
  23534. ]
  23535. ],
  23536. [
  23537. [
  23538. 12,
  23539. 8
  23540. ],
  23541. 'StrokeWidth',
  23542. 'num',
  23543. 0
  23544. ],
  23545. [
  23546. 14,
  23547. 'XUID',
  23548. 'array',
  23549. null
  23550. ],
  23551. [
  23552. 15,
  23553. 'charset',
  23554. 'offset',
  23555. 0
  23556. ],
  23557. [
  23558. 16,
  23559. 'Encoding',
  23560. 'offset',
  23561. 0
  23562. ],
  23563. [
  23564. 17,
  23565. 'CharStrings',
  23566. 'offset',
  23567. 0
  23568. ],
  23569. [
  23570. 18,
  23571. 'Private',
  23572. [
  23573. 'offset',
  23574. 'offset'
  23575. ],
  23576. null
  23577. ],
  23578. [
  23579. [
  23580. 12,
  23581. 21
  23582. ],
  23583. 'PostScript',
  23584. 'sid',
  23585. null
  23586. ],
  23587. [
  23588. [
  23589. 12,
  23590. 22
  23591. ],
  23592. 'BaseFontName',
  23593. 'sid',
  23594. null
  23595. ],
  23596. [
  23597. [
  23598. 12,
  23599. 23
  23600. ],
  23601. 'BaseFontBlend',
  23602. 'delta',
  23603. null
  23604. ],
  23605. [
  23606. [
  23607. 12,
  23608. 31
  23609. ],
  23610. 'CIDFontVersion',
  23611. 'num',
  23612. 0
  23613. ],
  23614. [
  23615. [
  23616. 12,
  23617. 32
  23618. ],
  23619. 'CIDFontRevision',
  23620. 'num',
  23621. 0
  23622. ],
  23623. [
  23624. [
  23625. 12,
  23626. 33
  23627. ],
  23628. 'CIDFontType',
  23629. 'num',
  23630. 0
  23631. ],
  23632. [
  23633. [
  23634. 12,
  23635. 34
  23636. ],
  23637. 'CIDCount',
  23638. 'num',
  23639. 8720
  23640. ],
  23641. [
  23642. [
  23643. 12,
  23644. 35
  23645. ],
  23646. 'UIDBase',
  23647. 'num',
  23648. null
  23649. ],
  23650. [
  23651. [
  23652. 12,
  23653. 37
  23654. ],
  23655. 'FDSelect',
  23656. 'offset',
  23657. null
  23658. ],
  23659. [
  23660. [
  23661. 12,
  23662. 36
  23663. ],
  23664. 'FDArray',
  23665. 'offset',
  23666. null
  23667. ],
  23668. [
  23669. [
  23670. 12,
  23671. 38
  23672. ],
  23673. 'FontName',
  23674. 'sid',
  23675. null
  23676. ]
  23677. ];
  23678. var tables = null;
  23679. function CFFTopDict(strings) {
  23680. if (tables === null) {
  23681. tables = CFFDict.createTables(layout);
  23682. }
  23683. CFFDict.call(this, tables, strings);
  23684. this.privateDict = null;
  23685. }
  23686. CFFTopDict.prototype = Object.create(CFFDict.prototype);
  23687. return CFFTopDict;
  23688. }();
  23689. var CFFPrivateDict = function CFFPrivateDictClosure() {
  23690. var layout = [
  23691. [
  23692. 6,
  23693. 'BlueValues',
  23694. 'delta',
  23695. null
  23696. ],
  23697. [
  23698. 7,
  23699. 'OtherBlues',
  23700. 'delta',
  23701. null
  23702. ],
  23703. [
  23704. 8,
  23705. 'FamilyBlues',
  23706. 'delta',
  23707. null
  23708. ],
  23709. [
  23710. 9,
  23711. 'FamilyOtherBlues',
  23712. 'delta',
  23713. null
  23714. ],
  23715. [
  23716. [
  23717. 12,
  23718. 9
  23719. ],
  23720. 'BlueScale',
  23721. 'num',
  23722. 0.039625
  23723. ],
  23724. [
  23725. [
  23726. 12,
  23727. 10
  23728. ],
  23729. 'BlueShift',
  23730. 'num',
  23731. 7
  23732. ],
  23733. [
  23734. [
  23735. 12,
  23736. 11
  23737. ],
  23738. 'BlueFuzz',
  23739. 'num',
  23740. 1
  23741. ],
  23742. [
  23743. 10,
  23744. 'StdHW',
  23745. 'num',
  23746. null
  23747. ],
  23748. [
  23749. 11,
  23750. 'StdVW',
  23751. 'num',
  23752. null
  23753. ],
  23754. [
  23755. [
  23756. 12,
  23757. 12
  23758. ],
  23759. 'StemSnapH',
  23760. 'delta',
  23761. null
  23762. ],
  23763. [
  23764. [
  23765. 12,
  23766. 13
  23767. ],
  23768. 'StemSnapV',
  23769. 'delta',
  23770. null
  23771. ],
  23772. [
  23773. [
  23774. 12,
  23775. 14
  23776. ],
  23777. 'ForceBold',
  23778. 'num',
  23779. 0
  23780. ],
  23781. [
  23782. [
  23783. 12,
  23784. 17
  23785. ],
  23786. 'LanguageGroup',
  23787. 'num',
  23788. 0
  23789. ],
  23790. [
  23791. [
  23792. 12,
  23793. 18
  23794. ],
  23795. 'ExpansionFactor',
  23796. 'num',
  23797. 0.06
  23798. ],
  23799. [
  23800. [
  23801. 12,
  23802. 19
  23803. ],
  23804. 'initialRandomSeed',
  23805. 'num',
  23806. 0
  23807. ],
  23808. [
  23809. 20,
  23810. 'defaultWidthX',
  23811. 'num',
  23812. 0
  23813. ],
  23814. [
  23815. 21,
  23816. 'nominalWidthX',
  23817. 'num',
  23818. 0
  23819. ],
  23820. [
  23821. 19,
  23822. 'Subrs',
  23823. 'offset',
  23824. null
  23825. ]
  23826. ];
  23827. var tables = null;
  23828. function CFFPrivateDict(strings) {
  23829. if (tables === null) {
  23830. tables = CFFDict.createTables(layout);
  23831. }
  23832. CFFDict.call(this, tables, strings);
  23833. this.subrsIndex = null;
  23834. }
  23835. CFFPrivateDict.prototype = Object.create(CFFDict.prototype);
  23836. return CFFPrivateDict;
  23837. }();
  23838. var CFFCharsetPredefinedTypes = {
  23839. ISO_ADOBE: 0,
  23840. EXPERT: 1,
  23841. EXPERT_SUBSET: 2
  23842. };
  23843. var CFFCharset = function CFFCharsetClosure() {
  23844. function CFFCharset(predefined, format, charset, raw) {
  23845. this.predefined = predefined;
  23846. this.format = format;
  23847. this.charset = charset;
  23848. this.raw = raw;
  23849. }
  23850. return CFFCharset;
  23851. }();
  23852. var CFFEncoding = function CFFEncodingClosure() {
  23853. function CFFEncoding(predefined, format, encoding, raw) {
  23854. this.predefined = predefined;
  23855. this.format = format;
  23856. this.encoding = encoding;
  23857. this.raw = raw;
  23858. }
  23859. return CFFEncoding;
  23860. }();
  23861. var CFFFDSelect = function CFFFDSelectClosure() {
  23862. function CFFFDSelect(fdSelect, raw) {
  23863. this.fdSelect = fdSelect;
  23864. this.raw = raw;
  23865. }
  23866. CFFFDSelect.prototype = {
  23867. getFDIndex: function CFFFDSelect_get(glyphIndex) {
  23868. if (glyphIndex < 0 || glyphIndex >= this.fdSelect.length) {
  23869. return -1;
  23870. }
  23871. return this.fdSelect[glyphIndex];
  23872. }
  23873. };
  23874. return CFFFDSelect;
  23875. }();
  23876. var CFFOffsetTracker = function CFFOffsetTrackerClosure() {
  23877. function CFFOffsetTracker() {
  23878. this.offsets = Object.create(null);
  23879. }
  23880. CFFOffsetTracker.prototype = {
  23881. isTracking: function CFFOffsetTracker_isTracking(key) {
  23882. return key in this.offsets;
  23883. },
  23884. track: function CFFOffsetTracker_track(key, location) {
  23885. if (key in this.offsets) {
  23886. error('Already tracking location of ' + key);
  23887. }
  23888. this.offsets[key] = location;
  23889. },
  23890. offset: function CFFOffsetTracker_offset(value) {
  23891. for (var key in this.offsets) {
  23892. this.offsets[key] += value;
  23893. }
  23894. },
  23895. setEntryLocation: function CFFOffsetTracker_setEntryLocation(key, values, output) {
  23896. if (!(key in this.offsets)) {
  23897. error('Not tracking location of ' + key);
  23898. }
  23899. var data = output.data;
  23900. var dataOffset = this.offsets[key];
  23901. var size = 5;
  23902. for (var i = 0, ii = values.length; i < ii; ++i) {
  23903. var offset0 = i * size + dataOffset;
  23904. var offset1 = offset0 + 1;
  23905. var offset2 = offset0 + 2;
  23906. var offset3 = offset0 + 3;
  23907. var offset4 = offset0 + 4;
  23908. if (data[offset0] !== 0x1d || data[offset1] !== 0 || data[offset2] !== 0 || data[offset3] !== 0 || data[offset4] !== 0) {
  23909. error('writing to an offset that is not empty');
  23910. }
  23911. var value = values[i];
  23912. data[offset0] = 0x1d;
  23913. data[offset1] = value >> 24 & 0xFF;
  23914. data[offset2] = value >> 16 & 0xFF;
  23915. data[offset3] = value >> 8 & 0xFF;
  23916. data[offset4] = value & 0xFF;
  23917. }
  23918. }
  23919. };
  23920. return CFFOffsetTracker;
  23921. }();
  23922. var CFFCompiler = function CFFCompilerClosure() {
  23923. function CFFCompiler(cff) {
  23924. this.cff = cff;
  23925. }
  23926. CFFCompiler.prototype = {
  23927. compile: function CFFCompiler_compile() {
  23928. var cff = this.cff;
  23929. var output = {
  23930. data: [],
  23931. length: 0,
  23932. add: function CFFCompiler_add(data) {
  23933. this.data = this.data.concat(data);
  23934. this.length = this.data.length;
  23935. }
  23936. };
  23937. var header = this.compileHeader(cff.header);
  23938. output.add(header);
  23939. var nameIndex = this.compileNameIndex(cff.names);
  23940. output.add(nameIndex);
  23941. if (cff.isCIDFont) {
  23942. if (cff.topDict.hasName('FontMatrix')) {
  23943. var base = cff.topDict.getByName('FontMatrix');
  23944. cff.topDict.removeByName('FontMatrix');
  23945. for (var i = 0, ii = cff.fdArray.length; i < ii; i++) {
  23946. var subDict = cff.fdArray[i];
  23947. var matrix = base.slice(0);
  23948. if (subDict.hasName('FontMatrix')) {
  23949. matrix = Util.transform(matrix, subDict.getByName('FontMatrix'));
  23950. }
  23951. subDict.setByName('FontMatrix', matrix);
  23952. }
  23953. }
  23954. }
  23955. var compiled = this.compileTopDicts([cff.topDict], output.length, cff.isCIDFont);
  23956. output.add(compiled.output);
  23957. var topDictTracker = compiled.trackers[0];
  23958. var stringIndex = this.compileStringIndex(cff.strings.strings);
  23959. output.add(stringIndex);
  23960. var globalSubrIndex = this.compileIndex(cff.globalSubrIndex);
  23961. output.add(globalSubrIndex);
  23962. if (cff.encoding && cff.topDict.hasName('Encoding')) {
  23963. if (cff.encoding.predefined) {
  23964. topDictTracker.setEntryLocation('Encoding', [cff.encoding.format], output);
  23965. } else {
  23966. var encoding = this.compileEncoding(cff.encoding);
  23967. topDictTracker.setEntryLocation('Encoding', [output.length], output);
  23968. output.add(encoding);
  23969. }
  23970. }
  23971. if (cff.charset && cff.topDict.hasName('charset')) {
  23972. if (cff.charset.predefined) {
  23973. topDictTracker.setEntryLocation('charset', [cff.charset.format], output);
  23974. } else {
  23975. var charset = this.compileCharset(cff.charset);
  23976. topDictTracker.setEntryLocation('charset', [output.length], output);
  23977. output.add(charset);
  23978. }
  23979. }
  23980. var charStrings = this.compileCharStrings(cff.charStrings);
  23981. topDictTracker.setEntryLocation('CharStrings', [output.length], output);
  23982. output.add(charStrings);
  23983. if (cff.isCIDFont) {
  23984. topDictTracker.setEntryLocation('FDSelect', [output.length], output);
  23985. var fdSelect = this.compileFDSelect(cff.fdSelect.raw);
  23986. output.add(fdSelect);
  23987. compiled = this.compileTopDicts(cff.fdArray, output.length, true);
  23988. topDictTracker.setEntryLocation('FDArray', [output.length], output);
  23989. output.add(compiled.output);
  23990. var fontDictTrackers = compiled.trackers;
  23991. this.compilePrivateDicts(cff.fdArray, fontDictTrackers, output);
  23992. }
  23993. this.compilePrivateDicts([cff.topDict], [topDictTracker], output);
  23994. output.add([0]);
  23995. return output.data;
  23996. },
  23997. encodeNumber: function CFFCompiler_encodeNumber(value) {
  23998. if (parseFloat(value) === parseInt(value, 10) && !isNaN(value)) {
  23999. return this.encodeInteger(value);
  24000. }
  24001. return this.encodeFloat(value);
  24002. },
  24003. encodeFloat: function CFFCompiler_encodeFloat(num) {
  24004. var value = num.toString();
  24005. var m = /\.(\d*?)(?:9{5,20}|0{5,20})\d{0,2}(?:e(.+)|$)/.exec(value);
  24006. if (m) {
  24007. var epsilon = parseFloat('1e' + ((m[2] ? +m[2] : 0) + m[1].length));
  24008. value = (Math.round(num * epsilon) / epsilon).toString();
  24009. }
  24010. var nibbles = '';
  24011. var i, ii;
  24012. for (i = 0, ii = value.length; i < ii; ++i) {
  24013. var a = value[i];
  24014. if (a === 'e') {
  24015. nibbles += value[++i] === '-' ? 'c' : 'b';
  24016. } else if (a === '.') {
  24017. nibbles += 'a';
  24018. } else if (a === '-') {
  24019. nibbles += 'e';
  24020. } else {
  24021. nibbles += a;
  24022. }
  24023. }
  24024. nibbles += nibbles.length & 1 ? 'f' : 'ff';
  24025. var out = [30];
  24026. for (i = 0, ii = nibbles.length; i < ii; i += 2) {
  24027. out.push(parseInt(nibbles.substr(i, 2), 16));
  24028. }
  24029. return out;
  24030. },
  24031. encodeInteger: function CFFCompiler_encodeInteger(value) {
  24032. var code;
  24033. if (value >= -107 && value <= 107) {
  24034. code = [value + 139];
  24035. } else if (value >= 108 && value <= 1131) {
  24036. value = value - 108;
  24037. code = [
  24038. (value >> 8) + 247,
  24039. value & 0xFF
  24040. ];
  24041. } else if (value >= -1131 && value <= -108) {
  24042. value = -value - 108;
  24043. code = [
  24044. (value >> 8) + 251,
  24045. value & 0xFF
  24046. ];
  24047. } else if (value >= -32768 && value <= 32767) {
  24048. code = [
  24049. 0x1c,
  24050. value >> 8 & 0xFF,
  24051. value & 0xFF
  24052. ];
  24053. } else {
  24054. code = [
  24055. 0x1d,
  24056. value >> 24 & 0xFF,
  24057. value >> 16 & 0xFF,
  24058. value >> 8 & 0xFF,
  24059. value & 0xFF
  24060. ];
  24061. }
  24062. return code;
  24063. },
  24064. compileHeader: function CFFCompiler_compileHeader(header) {
  24065. return [
  24066. header.major,
  24067. header.minor,
  24068. header.hdrSize,
  24069. header.offSize
  24070. ];
  24071. },
  24072. compileNameIndex: function CFFCompiler_compileNameIndex(names) {
  24073. var nameIndex = new CFFIndex();
  24074. for (var i = 0, ii = names.length; i < ii; ++i) {
  24075. nameIndex.add(stringToBytes(names[i]));
  24076. }
  24077. return this.compileIndex(nameIndex);
  24078. },
  24079. compileTopDicts: function CFFCompiler_compileTopDicts(dicts, length, removeCidKeys) {
  24080. var fontDictTrackers = [];
  24081. var fdArrayIndex = new CFFIndex();
  24082. for (var i = 0, ii = dicts.length; i < ii; ++i) {
  24083. var fontDict = dicts[i];
  24084. if (removeCidKeys) {
  24085. fontDict.removeByName('CIDFontVersion');
  24086. fontDict.removeByName('CIDFontRevision');
  24087. fontDict.removeByName('CIDFontType');
  24088. fontDict.removeByName('CIDCount');
  24089. fontDict.removeByName('UIDBase');
  24090. }
  24091. var fontDictTracker = new CFFOffsetTracker();
  24092. var fontDictData = this.compileDict(fontDict, fontDictTracker);
  24093. fontDictTrackers.push(fontDictTracker);
  24094. fdArrayIndex.add(fontDictData);
  24095. fontDictTracker.offset(length);
  24096. }
  24097. fdArrayIndex = this.compileIndex(fdArrayIndex, fontDictTrackers);
  24098. return {
  24099. trackers: fontDictTrackers,
  24100. output: fdArrayIndex
  24101. };
  24102. },
  24103. compilePrivateDicts: function CFFCompiler_compilePrivateDicts(dicts, trackers, output) {
  24104. for (var i = 0, ii = dicts.length; i < ii; ++i) {
  24105. var fontDict = dicts[i];
  24106. assert(fontDict.privateDict && fontDict.hasName('Private'), 'There must be an private dictionary.');
  24107. var privateDict = fontDict.privateDict;
  24108. var privateDictTracker = new CFFOffsetTracker();
  24109. var privateDictData = this.compileDict(privateDict, privateDictTracker);
  24110. var outputLength = output.length;
  24111. privateDictTracker.offset(outputLength);
  24112. if (!privateDictData.length) {
  24113. outputLength = 0;
  24114. }
  24115. trackers[i].setEntryLocation('Private', [
  24116. privateDictData.length,
  24117. outputLength
  24118. ], output);
  24119. output.add(privateDictData);
  24120. if (privateDict.subrsIndex && privateDict.hasName('Subrs')) {
  24121. var subrs = this.compileIndex(privateDict.subrsIndex);
  24122. privateDictTracker.setEntryLocation('Subrs', [privateDictData.length], output);
  24123. output.add(subrs);
  24124. }
  24125. }
  24126. },
  24127. compileDict: function CFFCompiler_compileDict(dict, offsetTracker) {
  24128. var out = [];
  24129. var order = dict.order;
  24130. for (var i = 0; i < order.length; ++i) {
  24131. var key = order[i];
  24132. if (!(key in dict.values)) {
  24133. continue;
  24134. }
  24135. var values = dict.values[key];
  24136. var types = dict.types[key];
  24137. if (!isArray(types)) {
  24138. types = [types];
  24139. }
  24140. if (!isArray(values)) {
  24141. values = [values];
  24142. }
  24143. if (values.length === 0) {
  24144. continue;
  24145. }
  24146. for (var j = 0, jj = types.length; j < jj; ++j) {
  24147. var type = types[j];
  24148. var value = values[j];
  24149. switch (type) {
  24150. case 'num':
  24151. case 'sid':
  24152. out = out.concat(this.encodeNumber(value));
  24153. break;
  24154. case 'offset':
  24155. var name = dict.keyToNameMap[key];
  24156. if (!offsetTracker.isTracking(name)) {
  24157. offsetTracker.track(name, out.length);
  24158. }
  24159. out = out.concat([
  24160. 0x1d,
  24161. 0,
  24162. 0,
  24163. 0,
  24164. 0
  24165. ]);
  24166. break;
  24167. case 'array':
  24168. case 'delta':
  24169. out = out.concat(this.encodeNumber(value));
  24170. for (var k = 1, kk = values.length; k < kk; ++k) {
  24171. out = out.concat(this.encodeNumber(values[k]));
  24172. }
  24173. break;
  24174. default:
  24175. error('Unknown data type of ' + type);
  24176. break;
  24177. }
  24178. }
  24179. out = out.concat(dict.opcodes[key]);
  24180. }
  24181. return out;
  24182. },
  24183. compileStringIndex: function CFFCompiler_compileStringIndex(strings) {
  24184. var stringIndex = new CFFIndex();
  24185. for (var i = 0, ii = strings.length; i < ii; ++i) {
  24186. stringIndex.add(stringToBytes(strings[i]));
  24187. }
  24188. return this.compileIndex(stringIndex);
  24189. },
  24190. compileGlobalSubrIndex: function CFFCompiler_compileGlobalSubrIndex() {
  24191. var globalSubrIndex = this.cff.globalSubrIndex;
  24192. this.out.writeByteArray(this.compileIndex(globalSubrIndex));
  24193. },
  24194. compileCharStrings: function CFFCompiler_compileCharStrings(charStrings) {
  24195. return this.compileIndex(charStrings);
  24196. },
  24197. compileCharset: function CFFCompiler_compileCharset(charset) {
  24198. return this.compileTypedArray(charset.raw);
  24199. },
  24200. compileEncoding: function CFFCompiler_compileEncoding(encoding) {
  24201. return this.compileTypedArray(encoding.raw);
  24202. },
  24203. compileFDSelect: function CFFCompiler_compileFDSelect(fdSelect) {
  24204. return this.compileTypedArray(fdSelect);
  24205. },
  24206. compileTypedArray: function CFFCompiler_compileTypedArray(data) {
  24207. var out = [];
  24208. for (var i = 0, ii = data.length; i < ii; ++i) {
  24209. out[i] = data[i];
  24210. }
  24211. return out;
  24212. },
  24213. compileIndex: function CFFCompiler_compileIndex(index, trackers) {
  24214. trackers = trackers || [];
  24215. var objects = index.objects;
  24216. var count = objects.length;
  24217. if (count === 0) {
  24218. return [
  24219. 0,
  24220. 0,
  24221. 0
  24222. ];
  24223. }
  24224. var data = [
  24225. count >> 8 & 0xFF,
  24226. count & 0xff
  24227. ];
  24228. var lastOffset = 1, i;
  24229. for (i = 0; i < count; ++i) {
  24230. lastOffset += objects[i].length;
  24231. }
  24232. var offsetSize;
  24233. if (lastOffset < 0x100) {
  24234. offsetSize = 1;
  24235. } else if (lastOffset < 0x10000) {
  24236. offsetSize = 2;
  24237. } else if (lastOffset < 0x1000000) {
  24238. offsetSize = 3;
  24239. } else {
  24240. offsetSize = 4;
  24241. }
  24242. data.push(offsetSize);
  24243. var relativeOffset = 1;
  24244. for (i = 0; i < count + 1; i++) {
  24245. if (offsetSize === 1) {
  24246. data.push(relativeOffset & 0xFF);
  24247. } else if (offsetSize === 2) {
  24248. data.push(relativeOffset >> 8 & 0xFF, relativeOffset & 0xFF);
  24249. } else if (offsetSize === 3) {
  24250. data.push(relativeOffset >> 16 & 0xFF, relativeOffset >> 8 & 0xFF, relativeOffset & 0xFF);
  24251. } else {
  24252. data.push(relativeOffset >>> 24 & 0xFF, relativeOffset >> 16 & 0xFF, relativeOffset >> 8 & 0xFF, relativeOffset & 0xFF);
  24253. }
  24254. if (objects[i]) {
  24255. relativeOffset += objects[i].length;
  24256. }
  24257. }
  24258. for (i = 0; i < count; i++) {
  24259. if (trackers[i]) {
  24260. trackers[i].offset(data.length);
  24261. }
  24262. for (var j = 0, jj = objects[i].length; j < jj; j++) {
  24263. data.push(objects[i][j]);
  24264. }
  24265. }
  24266. return data;
  24267. }
  24268. };
  24269. return CFFCompiler;
  24270. }();
  24271. exports.CFFStandardStrings = CFFStandardStrings;
  24272. exports.CFFParser = CFFParser;
  24273. exports.CFF = CFF;
  24274. exports.CFFHeader = CFFHeader;
  24275. exports.CFFStrings = CFFStrings;
  24276. exports.CFFIndex = CFFIndex;
  24277. exports.CFFCharset = CFFCharset;
  24278. exports.CFFTopDict = CFFTopDict;
  24279. exports.CFFPrivateDict = CFFPrivateDict;
  24280. exports.CFFCompiler = CFFCompiler;
  24281. /***/ }),
  24282. /* 16 */
  24283. /***/ (function(module, exports, __w_pdfjs_require__) {
  24284. "use strict";
  24285. var sharedUtil = __w_pdfjs_require__(0);
  24286. var MissingDataException = sharedUtil.MissingDataException;
  24287. var arrayByteLength = sharedUtil.arrayByteLength;
  24288. var arraysToBytes = sharedUtil.arraysToBytes;
  24289. var assert = sharedUtil.assert;
  24290. var createPromiseCapability = sharedUtil.createPromiseCapability;
  24291. var isInt = sharedUtil.isInt;
  24292. var isEmptyObj = sharedUtil.isEmptyObj;
  24293. var ChunkedStream = function ChunkedStreamClosure() {
  24294. function ChunkedStream(length, chunkSize, manager) {
  24295. this.bytes = new Uint8Array(length);
  24296. this.start = 0;
  24297. this.pos = 0;
  24298. this.end = length;
  24299. this.chunkSize = chunkSize;
  24300. this.loadedChunks = [];
  24301. this.numChunksLoaded = 0;
  24302. this.numChunks = Math.ceil(length / chunkSize);
  24303. this.manager = manager;
  24304. this.progressiveDataLength = 0;
  24305. this.lastSuccessfulEnsureByteChunk = -1;
  24306. }
  24307. ChunkedStream.prototype = {
  24308. getMissingChunks: function ChunkedStream_getMissingChunks() {
  24309. var chunks = [];
  24310. for (var chunk = 0, n = this.numChunks; chunk < n; ++chunk) {
  24311. if (!this.loadedChunks[chunk]) {
  24312. chunks.push(chunk);
  24313. }
  24314. }
  24315. return chunks;
  24316. },
  24317. getBaseStreams: function ChunkedStream_getBaseStreams() {
  24318. return [this];
  24319. },
  24320. allChunksLoaded: function ChunkedStream_allChunksLoaded() {
  24321. return this.numChunksLoaded === this.numChunks;
  24322. },
  24323. onReceiveData: function ChunkedStream_onReceiveData(begin, chunk) {
  24324. var end = begin + chunk.byteLength;
  24325. assert(begin % this.chunkSize === 0, 'Bad begin offset: ' + begin);
  24326. var length = this.bytes.length;
  24327. assert(end % this.chunkSize === 0 || end === length, 'Bad end offset: ' + end);
  24328. this.bytes.set(new Uint8Array(chunk), begin);
  24329. var chunkSize = this.chunkSize;
  24330. var beginChunk = Math.floor(begin / chunkSize);
  24331. var endChunk = Math.floor((end - 1) / chunkSize) + 1;
  24332. var curChunk;
  24333. for (curChunk = beginChunk; curChunk < endChunk; ++curChunk) {
  24334. if (!this.loadedChunks[curChunk]) {
  24335. this.loadedChunks[curChunk] = true;
  24336. ++this.numChunksLoaded;
  24337. }
  24338. }
  24339. },
  24340. onReceiveProgressiveData: function ChunkedStream_onReceiveProgressiveData(data) {
  24341. var position = this.progressiveDataLength;
  24342. var beginChunk = Math.floor(position / this.chunkSize);
  24343. this.bytes.set(new Uint8Array(data), position);
  24344. position += data.byteLength;
  24345. this.progressiveDataLength = position;
  24346. var endChunk = position >= this.end ? this.numChunks : Math.floor(position / this.chunkSize);
  24347. var curChunk;
  24348. for (curChunk = beginChunk; curChunk < endChunk; ++curChunk) {
  24349. if (!this.loadedChunks[curChunk]) {
  24350. this.loadedChunks[curChunk] = true;
  24351. ++this.numChunksLoaded;
  24352. }
  24353. }
  24354. },
  24355. ensureByte: function ChunkedStream_ensureByte(pos) {
  24356. var chunk = Math.floor(pos / this.chunkSize);
  24357. if (chunk === this.lastSuccessfulEnsureByteChunk) {
  24358. return;
  24359. }
  24360. if (!this.loadedChunks[chunk]) {
  24361. throw new MissingDataException(pos, pos + 1);
  24362. }
  24363. this.lastSuccessfulEnsureByteChunk = chunk;
  24364. },
  24365. ensureRange: function ChunkedStream_ensureRange(begin, end) {
  24366. if (begin >= end) {
  24367. return;
  24368. }
  24369. if (end <= this.progressiveDataLength) {
  24370. return;
  24371. }
  24372. var chunkSize = this.chunkSize;
  24373. var beginChunk = Math.floor(begin / chunkSize);
  24374. var endChunk = Math.floor((end - 1) / chunkSize) + 1;
  24375. for (var chunk = beginChunk; chunk < endChunk; ++chunk) {
  24376. if (!this.loadedChunks[chunk]) {
  24377. throw new MissingDataException(begin, end);
  24378. }
  24379. }
  24380. },
  24381. nextEmptyChunk: function ChunkedStream_nextEmptyChunk(beginChunk) {
  24382. var chunk, numChunks = this.numChunks;
  24383. for (var i = 0; i < numChunks; ++i) {
  24384. chunk = (beginChunk + i) % numChunks;
  24385. if (!this.loadedChunks[chunk]) {
  24386. return chunk;
  24387. }
  24388. }
  24389. return null;
  24390. },
  24391. hasChunk: function ChunkedStream_hasChunk(chunk) {
  24392. return !!this.loadedChunks[chunk];
  24393. },
  24394. get length() {
  24395. return this.end - this.start;
  24396. },
  24397. get isEmpty() {
  24398. return this.length === 0;
  24399. },
  24400. getByte: function ChunkedStream_getByte() {
  24401. var pos = this.pos;
  24402. if (pos >= this.end) {
  24403. return -1;
  24404. }
  24405. this.ensureByte(pos);
  24406. return this.bytes[this.pos++];
  24407. },
  24408. getUint16: function ChunkedStream_getUint16() {
  24409. var b0 = this.getByte();
  24410. var b1 = this.getByte();
  24411. if (b0 === -1 || b1 === -1) {
  24412. return -1;
  24413. }
  24414. return (b0 << 8) + b1;
  24415. },
  24416. getInt32: function ChunkedStream_getInt32() {
  24417. var b0 = this.getByte();
  24418. var b1 = this.getByte();
  24419. var b2 = this.getByte();
  24420. var b3 = this.getByte();
  24421. return (b0 << 24) + (b1 << 16) + (b2 << 8) + b3;
  24422. },
  24423. getBytes: function ChunkedStream_getBytes(length) {
  24424. var bytes = this.bytes;
  24425. var pos = this.pos;
  24426. var strEnd = this.end;
  24427. if (!length) {
  24428. this.ensureRange(pos, strEnd);
  24429. return bytes.subarray(pos, strEnd);
  24430. }
  24431. var end = pos + length;
  24432. if (end > strEnd) {
  24433. end = strEnd;
  24434. }
  24435. this.ensureRange(pos, end);
  24436. this.pos = end;
  24437. return bytes.subarray(pos, end);
  24438. },
  24439. peekByte: function ChunkedStream_peekByte() {
  24440. var peekedByte = this.getByte();
  24441. this.pos--;
  24442. return peekedByte;
  24443. },
  24444. peekBytes: function ChunkedStream_peekBytes(length) {
  24445. var bytes = this.getBytes(length);
  24446. this.pos -= bytes.length;
  24447. return bytes;
  24448. },
  24449. getByteRange: function ChunkedStream_getBytes(begin, end) {
  24450. this.ensureRange(begin, end);
  24451. return this.bytes.subarray(begin, end);
  24452. },
  24453. skip: function ChunkedStream_skip(n) {
  24454. if (!n) {
  24455. n = 1;
  24456. }
  24457. this.pos += n;
  24458. },
  24459. reset: function ChunkedStream_reset() {
  24460. this.pos = this.start;
  24461. },
  24462. moveStart: function ChunkedStream_moveStart() {
  24463. this.start = this.pos;
  24464. },
  24465. makeSubStream: function ChunkedStream_makeSubStream(start, length, dict) {
  24466. this.ensureRange(start, start + length);
  24467. function ChunkedStreamSubstream() {
  24468. }
  24469. ChunkedStreamSubstream.prototype = Object.create(this);
  24470. ChunkedStreamSubstream.prototype.getMissingChunks = function () {
  24471. var chunkSize = this.chunkSize;
  24472. var beginChunk = Math.floor(this.start / chunkSize);
  24473. var endChunk = Math.floor((this.end - 1) / chunkSize) + 1;
  24474. var missingChunks = [];
  24475. for (var chunk = beginChunk; chunk < endChunk; ++chunk) {
  24476. if (!this.loadedChunks[chunk]) {
  24477. missingChunks.push(chunk);
  24478. }
  24479. }
  24480. return missingChunks;
  24481. };
  24482. var subStream = new ChunkedStreamSubstream();
  24483. subStream.pos = subStream.start = start;
  24484. subStream.end = start + length || this.end;
  24485. subStream.dict = dict;
  24486. return subStream;
  24487. }
  24488. };
  24489. return ChunkedStream;
  24490. }();
  24491. var ChunkedStreamManager = function ChunkedStreamManagerClosure() {
  24492. function ChunkedStreamManager(pdfNetworkStream, args) {
  24493. var chunkSize = args.rangeChunkSize;
  24494. var length = args.length;
  24495. this.stream = new ChunkedStream(length, chunkSize, this);
  24496. this.length = length;
  24497. this.chunkSize = chunkSize;
  24498. this.pdfNetworkStream = pdfNetworkStream;
  24499. this.url = args.url;
  24500. this.disableAutoFetch = args.disableAutoFetch;
  24501. this.msgHandler = args.msgHandler;
  24502. this.currRequestId = 0;
  24503. this.chunksNeededByRequest = Object.create(null);
  24504. this.requestsByChunk = Object.create(null);
  24505. this.promisesByRequest = Object.create(null);
  24506. this.progressiveDataLength = 0;
  24507. this.aborted = false;
  24508. this._loadedStreamCapability = createPromiseCapability();
  24509. }
  24510. ChunkedStreamManager.prototype = {
  24511. onLoadedStream: function ChunkedStreamManager_getLoadedStream() {
  24512. return this._loadedStreamCapability.promise;
  24513. },
  24514. sendRequest: function ChunkedStreamManager_sendRequest(begin, end) {
  24515. var rangeReader = this.pdfNetworkStream.getRangeReader(begin, end);
  24516. if (!rangeReader.isStreamingSupported) {
  24517. rangeReader.onProgress = this.onProgress.bind(this);
  24518. }
  24519. var chunks = [], loaded = 0;
  24520. var manager = this;
  24521. var promise = new Promise(function (resolve, reject) {
  24522. var readChunk = function (chunk) {
  24523. try {
  24524. if (!chunk.done) {
  24525. var data = chunk.value;
  24526. chunks.push(data);
  24527. loaded += arrayByteLength(data);
  24528. if (rangeReader.isStreamingSupported) {
  24529. manager.onProgress({ loaded: loaded });
  24530. }
  24531. rangeReader.read().then(readChunk, reject);
  24532. return;
  24533. }
  24534. var chunkData = arraysToBytes(chunks);
  24535. chunks = null;
  24536. resolve(chunkData);
  24537. } catch (e) {
  24538. reject(e);
  24539. }
  24540. };
  24541. rangeReader.read().then(readChunk, reject);
  24542. });
  24543. promise.then(function (data) {
  24544. if (this.aborted) {
  24545. return;
  24546. }
  24547. this.onReceiveData({
  24548. chunk: data,
  24549. begin: begin
  24550. });
  24551. }.bind(this));
  24552. },
  24553. requestAllChunks: function ChunkedStreamManager_requestAllChunks() {
  24554. var missingChunks = this.stream.getMissingChunks();
  24555. this._requestChunks(missingChunks);
  24556. return this._loadedStreamCapability.promise;
  24557. },
  24558. _requestChunks: function ChunkedStreamManager_requestChunks(chunks) {
  24559. var requestId = this.currRequestId++;
  24560. var i, ii;
  24561. var chunksNeeded = Object.create(null);
  24562. this.chunksNeededByRequest[requestId] = chunksNeeded;
  24563. for (i = 0, ii = chunks.length; i < ii; i++) {
  24564. if (!this.stream.hasChunk(chunks[i])) {
  24565. chunksNeeded[chunks[i]] = true;
  24566. }
  24567. }
  24568. if (isEmptyObj(chunksNeeded)) {
  24569. return Promise.resolve();
  24570. }
  24571. var capability = createPromiseCapability();
  24572. this.promisesByRequest[requestId] = capability;
  24573. var chunksToRequest = [];
  24574. for (var chunk in chunksNeeded) {
  24575. chunk = chunk | 0;
  24576. if (!(chunk in this.requestsByChunk)) {
  24577. this.requestsByChunk[chunk] = [];
  24578. chunksToRequest.push(chunk);
  24579. }
  24580. this.requestsByChunk[chunk].push(requestId);
  24581. }
  24582. if (!chunksToRequest.length) {
  24583. return capability.promise;
  24584. }
  24585. var groupedChunksToRequest = this.groupChunks(chunksToRequest);
  24586. for (i = 0; i < groupedChunksToRequest.length; ++i) {
  24587. var groupedChunk = groupedChunksToRequest[i];
  24588. var begin = groupedChunk.beginChunk * this.chunkSize;
  24589. var end = Math.min(groupedChunk.endChunk * this.chunkSize, this.length);
  24590. this.sendRequest(begin, end);
  24591. }
  24592. return capability.promise;
  24593. },
  24594. getStream: function ChunkedStreamManager_getStream() {
  24595. return this.stream;
  24596. },
  24597. requestRange: function ChunkedStreamManager_requestRange(begin, end) {
  24598. end = Math.min(end, this.length);
  24599. var beginChunk = this.getBeginChunk(begin);
  24600. var endChunk = this.getEndChunk(end);
  24601. var chunks = [];
  24602. for (var chunk = beginChunk; chunk < endChunk; ++chunk) {
  24603. chunks.push(chunk);
  24604. }
  24605. return this._requestChunks(chunks);
  24606. },
  24607. requestRanges: function ChunkedStreamManager_requestRanges(ranges) {
  24608. ranges = ranges || [];
  24609. var chunksToRequest = [];
  24610. for (var i = 0; i < ranges.length; i++) {
  24611. var beginChunk = this.getBeginChunk(ranges[i].begin);
  24612. var endChunk = this.getEndChunk(ranges[i].end);
  24613. for (var chunk = beginChunk; chunk < endChunk; ++chunk) {
  24614. if (chunksToRequest.indexOf(chunk) < 0) {
  24615. chunksToRequest.push(chunk);
  24616. }
  24617. }
  24618. }
  24619. chunksToRequest.sort(function (a, b) {
  24620. return a - b;
  24621. });
  24622. return this._requestChunks(chunksToRequest);
  24623. },
  24624. groupChunks: function ChunkedStreamManager_groupChunks(chunks) {
  24625. var groupedChunks = [];
  24626. var beginChunk = -1;
  24627. var prevChunk = -1;
  24628. for (var i = 0; i < chunks.length; ++i) {
  24629. var chunk = chunks[i];
  24630. if (beginChunk < 0) {
  24631. beginChunk = chunk;
  24632. }
  24633. if (prevChunk >= 0 && prevChunk + 1 !== chunk) {
  24634. groupedChunks.push({
  24635. beginChunk: beginChunk,
  24636. endChunk: prevChunk + 1
  24637. });
  24638. beginChunk = chunk;
  24639. }
  24640. if (i + 1 === chunks.length) {
  24641. groupedChunks.push({
  24642. beginChunk: beginChunk,
  24643. endChunk: chunk + 1
  24644. });
  24645. }
  24646. prevChunk = chunk;
  24647. }
  24648. return groupedChunks;
  24649. },
  24650. onProgress: function ChunkedStreamManager_onProgress(args) {
  24651. var bytesLoaded = this.stream.numChunksLoaded * this.chunkSize + args.loaded;
  24652. this.msgHandler.send('DocProgress', {
  24653. loaded: bytesLoaded,
  24654. total: this.length
  24655. });
  24656. },
  24657. onReceiveData: function ChunkedStreamManager_onReceiveData(args) {
  24658. var chunk = args.chunk;
  24659. var isProgressive = args.begin === undefined;
  24660. var begin = isProgressive ? this.progressiveDataLength : args.begin;
  24661. var end = begin + chunk.byteLength;
  24662. var beginChunk = Math.floor(begin / this.chunkSize);
  24663. var endChunk = end < this.length ? Math.floor(end / this.chunkSize) : Math.ceil(end / this.chunkSize);
  24664. if (isProgressive) {
  24665. this.stream.onReceiveProgressiveData(chunk);
  24666. this.progressiveDataLength = end;
  24667. } else {
  24668. this.stream.onReceiveData(begin, chunk);
  24669. }
  24670. if (this.stream.allChunksLoaded()) {
  24671. this._loadedStreamCapability.resolve(this.stream);
  24672. }
  24673. var loadedRequests = [];
  24674. var i, requestId;
  24675. for (chunk = beginChunk; chunk < endChunk; ++chunk) {
  24676. var requestIds = this.requestsByChunk[chunk] || [];
  24677. delete this.requestsByChunk[chunk];
  24678. for (i = 0; i < requestIds.length; ++i) {
  24679. requestId = requestIds[i];
  24680. var chunksNeeded = this.chunksNeededByRequest[requestId];
  24681. if (chunk in chunksNeeded) {
  24682. delete chunksNeeded[chunk];
  24683. }
  24684. if (!isEmptyObj(chunksNeeded)) {
  24685. continue;
  24686. }
  24687. loadedRequests.push(requestId);
  24688. }
  24689. }
  24690. if (!this.disableAutoFetch && isEmptyObj(this.requestsByChunk)) {
  24691. var nextEmptyChunk;
  24692. if (this.stream.numChunksLoaded === 1) {
  24693. var lastChunk = this.stream.numChunks - 1;
  24694. if (!this.stream.hasChunk(lastChunk)) {
  24695. nextEmptyChunk = lastChunk;
  24696. }
  24697. } else {
  24698. nextEmptyChunk = this.stream.nextEmptyChunk(endChunk);
  24699. }
  24700. if (isInt(nextEmptyChunk)) {
  24701. this._requestChunks([nextEmptyChunk]);
  24702. }
  24703. }
  24704. for (i = 0; i < loadedRequests.length; ++i) {
  24705. requestId = loadedRequests[i];
  24706. var capability = this.promisesByRequest[requestId];
  24707. delete this.promisesByRequest[requestId];
  24708. capability.resolve();
  24709. }
  24710. this.msgHandler.send('DocProgress', {
  24711. loaded: this.stream.numChunksLoaded * this.chunkSize,
  24712. total: this.length
  24713. });
  24714. },
  24715. onError: function ChunkedStreamManager_onError(err) {
  24716. this._loadedStreamCapability.reject(err);
  24717. },
  24718. getBeginChunk: function ChunkedStreamManager_getBeginChunk(begin) {
  24719. var chunk = Math.floor(begin / this.chunkSize);
  24720. return chunk;
  24721. },
  24722. getEndChunk: function ChunkedStreamManager_getEndChunk(end) {
  24723. var chunk = Math.floor((end - 1) / this.chunkSize) + 1;
  24724. return chunk;
  24725. },
  24726. abort: function ChunkedStreamManager_abort() {
  24727. this.aborted = true;
  24728. if (this.pdfNetworkStream) {
  24729. this.pdfNetworkStream.cancelAllRequests('abort');
  24730. }
  24731. for (var requestId in this.promisesByRequest) {
  24732. var capability = this.promisesByRequest[requestId];
  24733. capability.reject(new Error('Request was aborted'));
  24734. }
  24735. }
  24736. };
  24737. return ChunkedStreamManager;
  24738. }();
  24739. exports.ChunkedStream = ChunkedStream;
  24740. exports.ChunkedStreamManager = ChunkedStreamManager;
  24741. /***/ }),
  24742. /* 17 */
  24743. /***/ (function(module, exports, __w_pdfjs_require__) {
  24744. "use strict";
  24745. var sharedUtil = __w_pdfjs_require__(0);
  24746. var corePrimitives = __w_pdfjs_require__(1);
  24747. var coreStream = __w_pdfjs_require__(2);
  24748. var PasswordException = sharedUtil.PasswordException;
  24749. var PasswordResponses = sharedUtil.PasswordResponses;
  24750. var bytesToString = sharedUtil.bytesToString;
  24751. var warn = sharedUtil.warn;
  24752. var error = sharedUtil.error;
  24753. var assert = sharedUtil.assert;
  24754. var isInt = sharedUtil.isInt;
  24755. var stringToBytes = sharedUtil.stringToBytes;
  24756. var utf8StringToString = sharedUtil.utf8StringToString;
  24757. var Name = corePrimitives.Name;
  24758. var isName = corePrimitives.isName;
  24759. var isDict = corePrimitives.isDict;
  24760. var DecryptStream = coreStream.DecryptStream;
  24761. var ARCFourCipher = function ARCFourCipherClosure() {
  24762. function ARCFourCipher(key) {
  24763. this.a = 0;
  24764. this.b = 0;
  24765. var s = new Uint8Array(256);
  24766. var i, j = 0, tmp, keyLength = key.length;
  24767. for (i = 0; i < 256; ++i) {
  24768. s[i] = i;
  24769. }
  24770. for (i = 0; i < 256; ++i) {
  24771. tmp = s[i];
  24772. j = j + tmp + key[i % keyLength] & 0xFF;
  24773. s[i] = s[j];
  24774. s[j] = tmp;
  24775. }
  24776. this.s = s;
  24777. }
  24778. ARCFourCipher.prototype = {
  24779. encryptBlock: function ARCFourCipher_encryptBlock(data) {
  24780. var i, n = data.length, tmp, tmp2;
  24781. var a = this.a, b = this.b, s = this.s;
  24782. var output = new Uint8Array(n);
  24783. for (i = 0; i < n; ++i) {
  24784. a = a + 1 & 0xFF;
  24785. tmp = s[a];
  24786. b = b + tmp & 0xFF;
  24787. tmp2 = s[b];
  24788. s[a] = tmp2;
  24789. s[b] = tmp;
  24790. output[i] = data[i] ^ s[tmp + tmp2 & 0xFF];
  24791. }
  24792. this.a = a;
  24793. this.b = b;
  24794. return output;
  24795. }
  24796. };
  24797. ARCFourCipher.prototype.decryptBlock = ARCFourCipher.prototype.encryptBlock;
  24798. return ARCFourCipher;
  24799. }();
  24800. var calculateMD5 = function calculateMD5Closure() {
  24801. var r = new Uint8Array([
  24802. 7,
  24803. 12,
  24804. 17,
  24805. 22,
  24806. 7,
  24807. 12,
  24808. 17,
  24809. 22,
  24810. 7,
  24811. 12,
  24812. 17,
  24813. 22,
  24814. 7,
  24815. 12,
  24816. 17,
  24817. 22,
  24818. 5,
  24819. 9,
  24820. 14,
  24821. 20,
  24822. 5,
  24823. 9,
  24824. 14,
  24825. 20,
  24826. 5,
  24827. 9,
  24828. 14,
  24829. 20,
  24830. 5,
  24831. 9,
  24832. 14,
  24833. 20,
  24834. 4,
  24835. 11,
  24836. 16,
  24837. 23,
  24838. 4,
  24839. 11,
  24840. 16,
  24841. 23,
  24842. 4,
  24843. 11,
  24844. 16,
  24845. 23,
  24846. 4,
  24847. 11,
  24848. 16,
  24849. 23,
  24850. 6,
  24851. 10,
  24852. 15,
  24853. 21,
  24854. 6,
  24855. 10,
  24856. 15,
  24857. 21,
  24858. 6,
  24859. 10,
  24860. 15,
  24861. 21,
  24862. 6,
  24863. 10,
  24864. 15,
  24865. 21
  24866. ]);
  24867. var k = new Int32Array([
  24868. -680876936,
  24869. -389564586,
  24870. 606105819,
  24871. -1044525330,
  24872. -176418897,
  24873. 1200080426,
  24874. -1473231341,
  24875. -45705983,
  24876. 1770035416,
  24877. -1958414417,
  24878. -42063,
  24879. -1990404162,
  24880. 1804603682,
  24881. -40341101,
  24882. -1502002290,
  24883. 1236535329,
  24884. -165796510,
  24885. -1069501632,
  24886. 643717713,
  24887. -373897302,
  24888. -701558691,
  24889. 38016083,
  24890. -660478335,
  24891. -405537848,
  24892. 568446438,
  24893. -1019803690,
  24894. -187363961,
  24895. 1163531501,
  24896. -1444681467,
  24897. -51403784,
  24898. 1735328473,
  24899. -1926607734,
  24900. -378558,
  24901. -2022574463,
  24902. 1839030562,
  24903. -35309556,
  24904. -1530992060,
  24905. 1272893353,
  24906. -155497632,
  24907. -1094730640,
  24908. 681279174,
  24909. -358537222,
  24910. -722521979,
  24911. 76029189,
  24912. -640364487,
  24913. -421815835,
  24914. 530742520,
  24915. -995338651,
  24916. -198630844,
  24917. 1126891415,
  24918. -1416354905,
  24919. -57434055,
  24920. 1700485571,
  24921. -1894986606,
  24922. -1051523,
  24923. -2054922799,
  24924. 1873313359,
  24925. -30611744,
  24926. -1560198380,
  24927. 1309151649,
  24928. -145523070,
  24929. -1120210379,
  24930. 718787259,
  24931. -343485551
  24932. ]);
  24933. function hash(data, offset, length) {
  24934. var h0 = 1732584193, h1 = -271733879, h2 = -1732584194, h3 = 271733878;
  24935. var paddedLength = length + 72 & ~63;
  24936. var padded = new Uint8Array(paddedLength);
  24937. var i, j, n;
  24938. for (i = 0; i < length; ++i) {
  24939. padded[i] = data[offset++];
  24940. }
  24941. padded[i++] = 0x80;
  24942. n = paddedLength - 8;
  24943. while (i < n) {
  24944. padded[i++] = 0;
  24945. }
  24946. padded[i++] = length << 3 & 0xFF;
  24947. padded[i++] = length >> 5 & 0xFF;
  24948. padded[i++] = length >> 13 & 0xFF;
  24949. padded[i++] = length >> 21 & 0xFF;
  24950. padded[i++] = length >>> 29 & 0xFF;
  24951. padded[i++] = 0;
  24952. padded[i++] = 0;
  24953. padded[i++] = 0;
  24954. var w = new Int32Array(16);
  24955. for (i = 0; i < paddedLength;) {
  24956. for (j = 0; j < 16; ++j, i += 4) {
  24957. w[j] = padded[i] | padded[i + 1] << 8 | padded[i + 2] << 16 | padded[i + 3] << 24;
  24958. }
  24959. var a = h0, b = h1, c = h2, d = h3, f, g;
  24960. for (j = 0; j < 64; ++j) {
  24961. if (j < 16) {
  24962. f = b & c | ~b & d;
  24963. g = j;
  24964. } else if (j < 32) {
  24965. f = d & b | ~d & c;
  24966. g = 5 * j + 1 & 15;
  24967. } else if (j < 48) {
  24968. f = b ^ c ^ d;
  24969. g = 3 * j + 5 & 15;
  24970. } else {
  24971. f = c ^ (b | ~d);
  24972. g = 7 * j & 15;
  24973. }
  24974. var tmp = d, rotateArg = a + f + k[j] + w[g] | 0, rotate = r[j];
  24975. d = c;
  24976. c = b;
  24977. b = b + (rotateArg << rotate | rotateArg >>> 32 - rotate) | 0;
  24978. a = tmp;
  24979. }
  24980. h0 = h0 + a | 0;
  24981. h1 = h1 + b | 0;
  24982. h2 = h2 + c | 0;
  24983. h3 = h3 + d | 0;
  24984. }
  24985. return new Uint8Array([
  24986. h0 & 0xFF,
  24987. h0 >> 8 & 0xFF,
  24988. h0 >> 16 & 0xFF,
  24989. h0 >>> 24 & 0xFF,
  24990. h1 & 0xFF,
  24991. h1 >> 8 & 0xFF,
  24992. h1 >> 16 & 0xFF,
  24993. h1 >>> 24 & 0xFF,
  24994. h2 & 0xFF,
  24995. h2 >> 8 & 0xFF,
  24996. h2 >> 16 & 0xFF,
  24997. h2 >>> 24 & 0xFF,
  24998. h3 & 0xFF,
  24999. h3 >> 8 & 0xFF,
  25000. h3 >> 16 & 0xFF,
  25001. h3 >>> 24 & 0xFF
  25002. ]);
  25003. }
  25004. return hash;
  25005. }();
  25006. var Word64 = function Word64Closure() {
  25007. function Word64(highInteger, lowInteger) {
  25008. this.high = highInteger | 0;
  25009. this.low = lowInteger | 0;
  25010. }
  25011. Word64.prototype = {
  25012. and: function Word64_and(word) {
  25013. this.high &= word.high;
  25014. this.low &= word.low;
  25015. },
  25016. xor: function Word64_xor(word) {
  25017. this.high ^= word.high;
  25018. this.low ^= word.low;
  25019. },
  25020. or: function Word64_or(word) {
  25021. this.high |= word.high;
  25022. this.low |= word.low;
  25023. },
  25024. shiftRight: function Word64_shiftRight(places) {
  25025. if (places >= 32) {
  25026. this.low = this.high >>> places - 32 | 0;
  25027. this.high = 0;
  25028. } else {
  25029. this.low = this.low >>> places | this.high << 32 - places;
  25030. this.high = this.high >>> places | 0;
  25031. }
  25032. },
  25033. shiftLeft: function Word64_shiftLeft(places) {
  25034. if (places >= 32) {
  25035. this.high = this.low << places - 32;
  25036. this.low = 0;
  25037. } else {
  25038. this.high = this.high << places | this.low >>> 32 - places;
  25039. this.low = this.low << places;
  25040. }
  25041. },
  25042. rotateRight: function Word64_rotateRight(places) {
  25043. var low, high;
  25044. if (places & 32) {
  25045. high = this.low;
  25046. low = this.high;
  25047. } else {
  25048. low = this.low;
  25049. high = this.high;
  25050. }
  25051. places &= 31;
  25052. this.low = low >>> places | high << 32 - places;
  25053. this.high = high >>> places | low << 32 - places;
  25054. },
  25055. not: function Word64_not() {
  25056. this.high = ~this.high;
  25057. this.low = ~this.low;
  25058. },
  25059. add: function Word64_add(word) {
  25060. var lowAdd = (this.low >>> 0) + (word.low >>> 0);
  25061. var highAdd = (this.high >>> 0) + (word.high >>> 0);
  25062. if (lowAdd > 0xFFFFFFFF) {
  25063. highAdd += 1;
  25064. }
  25065. this.low = lowAdd | 0;
  25066. this.high = highAdd | 0;
  25067. },
  25068. copyTo: function Word64_copyTo(bytes, offset) {
  25069. bytes[offset] = this.high >>> 24 & 0xFF;
  25070. bytes[offset + 1] = this.high >> 16 & 0xFF;
  25071. bytes[offset + 2] = this.high >> 8 & 0xFF;
  25072. bytes[offset + 3] = this.high & 0xFF;
  25073. bytes[offset + 4] = this.low >>> 24 & 0xFF;
  25074. bytes[offset + 5] = this.low >> 16 & 0xFF;
  25075. bytes[offset + 6] = this.low >> 8 & 0xFF;
  25076. bytes[offset + 7] = this.low & 0xFF;
  25077. },
  25078. assign: function Word64_assign(word) {
  25079. this.high = word.high;
  25080. this.low = word.low;
  25081. }
  25082. };
  25083. return Word64;
  25084. }();
  25085. var calculateSHA256 = function calculateSHA256Closure() {
  25086. function rotr(x, n) {
  25087. return x >>> n | x << 32 - n;
  25088. }
  25089. function ch(x, y, z) {
  25090. return x & y ^ ~x & z;
  25091. }
  25092. function maj(x, y, z) {
  25093. return x & y ^ x & z ^ y & z;
  25094. }
  25095. function sigma(x) {
  25096. return rotr(x, 2) ^ rotr(x, 13) ^ rotr(x, 22);
  25097. }
  25098. function sigmaPrime(x) {
  25099. return rotr(x, 6) ^ rotr(x, 11) ^ rotr(x, 25);
  25100. }
  25101. function littleSigma(x) {
  25102. return rotr(x, 7) ^ rotr(x, 18) ^ x >>> 3;
  25103. }
  25104. function littleSigmaPrime(x) {
  25105. return rotr(x, 17) ^ rotr(x, 19) ^ x >>> 10;
  25106. }
  25107. var k = [
  25108. 0x428a2f98,
  25109. 0x71374491,
  25110. 0xb5c0fbcf,
  25111. 0xe9b5dba5,
  25112. 0x3956c25b,
  25113. 0x59f111f1,
  25114. 0x923f82a4,
  25115. 0xab1c5ed5,
  25116. 0xd807aa98,
  25117. 0x12835b01,
  25118. 0x243185be,
  25119. 0x550c7dc3,
  25120. 0x72be5d74,
  25121. 0x80deb1fe,
  25122. 0x9bdc06a7,
  25123. 0xc19bf174,
  25124. 0xe49b69c1,
  25125. 0xefbe4786,
  25126. 0x0fc19dc6,
  25127. 0x240ca1cc,
  25128. 0x2de92c6f,
  25129. 0x4a7484aa,
  25130. 0x5cb0a9dc,
  25131. 0x76f988da,
  25132. 0x983e5152,
  25133. 0xa831c66d,
  25134. 0xb00327c8,
  25135. 0xbf597fc7,
  25136. 0xc6e00bf3,
  25137. 0xd5a79147,
  25138. 0x06ca6351,
  25139. 0x14292967,
  25140. 0x27b70a85,
  25141. 0x2e1b2138,
  25142. 0x4d2c6dfc,
  25143. 0x53380d13,
  25144. 0x650a7354,
  25145. 0x766a0abb,
  25146. 0x81c2c92e,
  25147. 0x92722c85,
  25148. 0xa2bfe8a1,
  25149. 0xa81a664b,
  25150. 0xc24b8b70,
  25151. 0xc76c51a3,
  25152. 0xd192e819,
  25153. 0xd6990624,
  25154. 0xf40e3585,
  25155. 0x106aa070,
  25156. 0x19a4c116,
  25157. 0x1e376c08,
  25158. 0x2748774c,
  25159. 0x34b0bcb5,
  25160. 0x391c0cb3,
  25161. 0x4ed8aa4a,
  25162. 0x5b9cca4f,
  25163. 0x682e6ff3,
  25164. 0x748f82ee,
  25165. 0x78a5636f,
  25166. 0x84c87814,
  25167. 0x8cc70208,
  25168. 0x90befffa,
  25169. 0xa4506ceb,
  25170. 0xbef9a3f7,
  25171. 0xc67178f2
  25172. ];
  25173. function hash(data, offset, length) {
  25174. var h0 = 0x6a09e667, h1 = 0xbb67ae85, h2 = 0x3c6ef372, h3 = 0xa54ff53a, h4 = 0x510e527f, h5 = 0x9b05688c, h6 = 0x1f83d9ab, h7 = 0x5be0cd19;
  25175. var paddedLength = Math.ceil((length + 9) / 64) * 64;
  25176. var padded = new Uint8Array(paddedLength);
  25177. var i, j, n;
  25178. for (i = 0; i < length; ++i) {
  25179. padded[i] = data[offset++];
  25180. }
  25181. padded[i++] = 0x80;
  25182. n = paddedLength - 8;
  25183. while (i < n) {
  25184. padded[i++] = 0;
  25185. }
  25186. padded[i++] = 0;
  25187. padded[i++] = 0;
  25188. padded[i++] = 0;
  25189. padded[i++] = length >>> 29 & 0xFF;
  25190. padded[i++] = length >> 21 & 0xFF;
  25191. padded[i++] = length >> 13 & 0xFF;
  25192. padded[i++] = length >> 5 & 0xFF;
  25193. padded[i++] = length << 3 & 0xFF;
  25194. var w = new Uint32Array(64);
  25195. for (i = 0; i < paddedLength;) {
  25196. for (j = 0; j < 16; ++j) {
  25197. w[j] = padded[i] << 24 | padded[i + 1] << 16 | padded[i + 2] << 8 | padded[i + 3];
  25198. i += 4;
  25199. }
  25200. for (j = 16; j < 64; ++j) {
  25201. w[j] = littleSigmaPrime(w[j - 2]) + w[j - 7] + littleSigma(w[j - 15]) + w[j - 16] | 0;
  25202. }
  25203. var a = h0, b = h1, c = h2, d = h3, e = h4, f = h5, g = h6, h = h7, t1, t2;
  25204. for (j = 0; j < 64; ++j) {
  25205. t1 = h + sigmaPrime(e) + ch(e, f, g) + k[j] + w[j];
  25206. t2 = sigma(a) + maj(a, b, c);
  25207. h = g;
  25208. g = f;
  25209. f = e;
  25210. e = d + t1 | 0;
  25211. d = c;
  25212. c = b;
  25213. b = a;
  25214. a = t1 + t2 | 0;
  25215. }
  25216. h0 = h0 + a | 0;
  25217. h1 = h1 + b | 0;
  25218. h2 = h2 + c | 0;
  25219. h3 = h3 + d | 0;
  25220. h4 = h4 + e | 0;
  25221. h5 = h5 + f | 0;
  25222. h6 = h6 + g | 0;
  25223. h7 = h7 + h | 0;
  25224. }
  25225. return new Uint8Array([
  25226. h0 >> 24 & 0xFF,
  25227. h0 >> 16 & 0xFF,
  25228. h0 >> 8 & 0xFF,
  25229. h0 & 0xFF,
  25230. h1 >> 24 & 0xFF,
  25231. h1 >> 16 & 0xFF,
  25232. h1 >> 8 & 0xFF,
  25233. h1 & 0xFF,
  25234. h2 >> 24 & 0xFF,
  25235. h2 >> 16 & 0xFF,
  25236. h2 >> 8 & 0xFF,
  25237. h2 & 0xFF,
  25238. h3 >> 24 & 0xFF,
  25239. h3 >> 16 & 0xFF,
  25240. h3 >> 8 & 0xFF,
  25241. h3 & 0xFF,
  25242. h4 >> 24 & 0xFF,
  25243. h4 >> 16 & 0xFF,
  25244. h4 >> 8 & 0xFF,
  25245. h4 & 0xFF,
  25246. h5 >> 24 & 0xFF,
  25247. h5 >> 16 & 0xFF,
  25248. h5 >> 8 & 0xFF,
  25249. h5 & 0xFF,
  25250. h6 >> 24 & 0xFF,
  25251. h6 >> 16 & 0xFF,
  25252. h6 >> 8 & 0xFF,
  25253. h6 & 0xFF,
  25254. h7 >> 24 & 0xFF,
  25255. h7 >> 16 & 0xFF,
  25256. h7 >> 8 & 0xFF,
  25257. h7 & 0xFF
  25258. ]);
  25259. }
  25260. return hash;
  25261. }();
  25262. var calculateSHA512 = function calculateSHA512Closure() {
  25263. function ch(result, x, y, z, tmp) {
  25264. result.assign(x);
  25265. result.and(y);
  25266. tmp.assign(x);
  25267. tmp.not();
  25268. tmp.and(z);
  25269. result.xor(tmp);
  25270. }
  25271. function maj(result, x, y, z, tmp) {
  25272. result.assign(x);
  25273. result.and(y);
  25274. tmp.assign(x);
  25275. tmp.and(z);
  25276. result.xor(tmp);
  25277. tmp.assign(y);
  25278. tmp.and(z);
  25279. result.xor(tmp);
  25280. }
  25281. function sigma(result, x, tmp) {
  25282. result.assign(x);
  25283. result.rotateRight(28);
  25284. tmp.assign(x);
  25285. tmp.rotateRight(34);
  25286. result.xor(tmp);
  25287. tmp.assign(x);
  25288. tmp.rotateRight(39);
  25289. result.xor(tmp);
  25290. }
  25291. function sigmaPrime(result, x, tmp) {
  25292. result.assign(x);
  25293. result.rotateRight(14);
  25294. tmp.assign(x);
  25295. tmp.rotateRight(18);
  25296. result.xor(tmp);
  25297. tmp.assign(x);
  25298. tmp.rotateRight(41);
  25299. result.xor(tmp);
  25300. }
  25301. function littleSigma(result, x, tmp) {
  25302. result.assign(x);
  25303. result.rotateRight(1);
  25304. tmp.assign(x);
  25305. tmp.rotateRight(8);
  25306. result.xor(tmp);
  25307. tmp.assign(x);
  25308. tmp.shiftRight(7);
  25309. result.xor(tmp);
  25310. }
  25311. function littleSigmaPrime(result, x, tmp) {
  25312. result.assign(x);
  25313. result.rotateRight(19);
  25314. tmp.assign(x);
  25315. tmp.rotateRight(61);
  25316. result.xor(tmp);
  25317. tmp.assign(x);
  25318. tmp.shiftRight(6);
  25319. result.xor(tmp);
  25320. }
  25321. var k = [
  25322. new Word64(0x428a2f98, 0xd728ae22),
  25323. new Word64(0x71374491, 0x23ef65cd),
  25324. new Word64(0xb5c0fbcf, 0xec4d3b2f),
  25325. new Word64(0xe9b5dba5, 0x8189dbbc),
  25326. new Word64(0x3956c25b, 0xf348b538),
  25327. new Word64(0x59f111f1, 0xb605d019),
  25328. new Word64(0x923f82a4, 0xaf194f9b),
  25329. new Word64(0xab1c5ed5, 0xda6d8118),
  25330. new Word64(0xd807aa98, 0xa3030242),
  25331. new Word64(0x12835b01, 0x45706fbe),
  25332. new Word64(0x243185be, 0x4ee4b28c),
  25333. new Word64(0x550c7dc3, 0xd5ffb4e2),
  25334. new Word64(0x72be5d74, 0xf27b896f),
  25335. new Word64(0x80deb1fe, 0x3b1696b1),
  25336. new Word64(0x9bdc06a7, 0x25c71235),
  25337. new Word64(0xc19bf174, 0xcf692694),
  25338. new Word64(0xe49b69c1, 0x9ef14ad2),
  25339. new Word64(0xefbe4786, 0x384f25e3),
  25340. new Word64(0x0fc19dc6, 0x8b8cd5b5),
  25341. new Word64(0x240ca1cc, 0x77ac9c65),
  25342. new Word64(0x2de92c6f, 0x592b0275),
  25343. new Word64(0x4a7484aa, 0x6ea6e483),
  25344. new Word64(0x5cb0a9dc, 0xbd41fbd4),
  25345. new Word64(0x76f988da, 0x831153b5),
  25346. new Word64(0x983e5152, 0xee66dfab),
  25347. new Word64(0xa831c66d, 0x2db43210),
  25348. new Word64(0xb00327c8, 0x98fb213f),
  25349. new Word64(0xbf597fc7, 0xbeef0ee4),
  25350. new Word64(0xc6e00bf3, 0x3da88fc2),
  25351. new Word64(0xd5a79147, 0x930aa725),
  25352. new Word64(0x06ca6351, 0xe003826f),
  25353. new Word64(0x14292967, 0x0a0e6e70),
  25354. new Word64(0x27b70a85, 0x46d22ffc),
  25355. new Word64(0x2e1b2138, 0x5c26c926),
  25356. new Word64(0x4d2c6dfc, 0x5ac42aed),
  25357. new Word64(0x53380d13, 0x9d95b3df),
  25358. new Word64(0x650a7354, 0x8baf63de),
  25359. new Word64(0x766a0abb, 0x3c77b2a8),
  25360. new Word64(0x81c2c92e, 0x47edaee6),
  25361. new Word64(0x92722c85, 0x1482353b),
  25362. new Word64(0xa2bfe8a1, 0x4cf10364),
  25363. new Word64(0xa81a664b, 0xbc423001),
  25364. new Word64(0xc24b8b70, 0xd0f89791),
  25365. new Word64(0xc76c51a3, 0x0654be30),
  25366. new Word64(0xd192e819, 0xd6ef5218),
  25367. new Word64(0xd6990624, 0x5565a910),
  25368. new Word64(0xf40e3585, 0x5771202a),
  25369. new Word64(0x106aa070, 0x32bbd1b8),
  25370. new Word64(0x19a4c116, 0xb8d2d0c8),
  25371. new Word64(0x1e376c08, 0x5141ab53),
  25372. new Word64(0x2748774c, 0xdf8eeb99),
  25373. new Word64(0x34b0bcb5, 0xe19b48a8),
  25374. new Word64(0x391c0cb3, 0xc5c95a63),
  25375. new Word64(0x4ed8aa4a, 0xe3418acb),
  25376. new Word64(0x5b9cca4f, 0x7763e373),
  25377. new Word64(0x682e6ff3, 0xd6b2b8a3),
  25378. new Word64(0x748f82ee, 0x5defb2fc),
  25379. new Word64(0x78a5636f, 0x43172f60),
  25380. new Word64(0x84c87814, 0xa1f0ab72),
  25381. new Word64(0x8cc70208, 0x1a6439ec),
  25382. new Word64(0x90befffa, 0x23631e28),
  25383. new Word64(0xa4506ceb, 0xde82bde9),
  25384. new Word64(0xbef9a3f7, 0xb2c67915),
  25385. new Word64(0xc67178f2, 0xe372532b),
  25386. new Word64(0xca273ece, 0xea26619c),
  25387. new Word64(0xd186b8c7, 0x21c0c207),
  25388. new Word64(0xeada7dd6, 0xcde0eb1e),
  25389. new Word64(0xf57d4f7f, 0xee6ed178),
  25390. new Word64(0x06f067aa, 0x72176fba),
  25391. new Word64(0x0a637dc5, 0xa2c898a6),
  25392. new Word64(0x113f9804, 0xbef90dae),
  25393. new Word64(0x1b710b35, 0x131c471b),
  25394. new Word64(0x28db77f5, 0x23047d84),
  25395. new Word64(0x32caab7b, 0x40c72493),
  25396. new Word64(0x3c9ebe0a, 0x15c9bebc),
  25397. new Word64(0x431d67c4, 0x9c100d4c),
  25398. new Word64(0x4cc5d4be, 0xcb3e42b6),
  25399. new Word64(0x597f299c, 0xfc657e2a),
  25400. new Word64(0x5fcb6fab, 0x3ad6faec),
  25401. new Word64(0x6c44198c, 0x4a475817)
  25402. ];
  25403. function hash(data, offset, length, mode384) {
  25404. mode384 = !!mode384;
  25405. var h0, h1, h2, h3, h4, h5, h6, h7;
  25406. if (!mode384) {
  25407. h0 = new Word64(0x6a09e667, 0xf3bcc908);
  25408. h1 = new Word64(0xbb67ae85, 0x84caa73b);
  25409. h2 = new Word64(0x3c6ef372, 0xfe94f82b);
  25410. h3 = new Word64(0xa54ff53a, 0x5f1d36f1);
  25411. h4 = new Word64(0x510e527f, 0xade682d1);
  25412. h5 = new Word64(0x9b05688c, 0x2b3e6c1f);
  25413. h6 = new Word64(0x1f83d9ab, 0xfb41bd6b);
  25414. h7 = new Word64(0x5be0cd19, 0x137e2179);
  25415. } else {
  25416. h0 = new Word64(0xcbbb9d5d, 0xc1059ed8);
  25417. h1 = new Word64(0x629a292a, 0x367cd507);
  25418. h2 = new Word64(0x9159015a, 0x3070dd17);
  25419. h3 = new Word64(0x152fecd8, 0xf70e5939);
  25420. h4 = new Word64(0x67332667, 0xffc00b31);
  25421. h5 = new Word64(0x8eb44a87, 0x68581511);
  25422. h6 = new Word64(0xdb0c2e0d, 0x64f98fa7);
  25423. h7 = new Word64(0x47b5481d, 0xbefa4fa4);
  25424. }
  25425. var paddedLength = Math.ceil((length + 17) / 128) * 128;
  25426. var padded = new Uint8Array(paddedLength);
  25427. var i, j, n;
  25428. for (i = 0; i < length; ++i) {
  25429. padded[i] = data[offset++];
  25430. }
  25431. padded[i++] = 0x80;
  25432. n = paddedLength - 16;
  25433. while (i < n) {
  25434. padded[i++] = 0;
  25435. }
  25436. padded[i++] = 0;
  25437. padded[i++] = 0;
  25438. padded[i++] = 0;
  25439. padded[i++] = 0;
  25440. padded[i++] = 0;
  25441. padded[i++] = 0;
  25442. padded[i++] = 0;
  25443. padded[i++] = 0;
  25444. padded[i++] = 0;
  25445. padded[i++] = 0;
  25446. padded[i++] = 0;
  25447. padded[i++] = length >>> 29 & 0xFF;
  25448. padded[i++] = length >> 21 & 0xFF;
  25449. padded[i++] = length >> 13 & 0xFF;
  25450. padded[i++] = length >> 5 & 0xFF;
  25451. padded[i++] = length << 3 & 0xFF;
  25452. var w = new Array(80);
  25453. for (i = 0; i < 80; i++) {
  25454. w[i] = new Word64(0, 0);
  25455. }
  25456. var a = new Word64(0, 0), b = new Word64(0, 0), c = new Word64(0, 0);
  25457. var d = new Word64(0, 0), e = new Word64(0, 0), f = new Word64(0, 0);
  25458. var g = new Word64(0, 0), h = new Word64(0, 0);
  25459. var t1 = new Word64(0, 0), t2 = new Word64(0, 0);
  25460. var tmp1 = new Word64(0, 0), tmp2 = new Word64(0, 0), tmp3;
  25461. for (i = 0; i < paddedLength;) {
  25462. for (j = 0; j < 16; ++j) {
  25463. w[j].high = padded[i] << 24 | padded[i + 1] << 16 | padded[i + 2] << 8 | padded[i + 3];
  25464. w[j].low = padded[i + 4] << 24 | padded[i + 5] << 16 | padded[i + 6] << 8 | padded[i + 7];
  25465. i += 8;
  25466. }
  25467. for (j = 16; j < 80; ++j) {
  25468. tmp3 = w[j];
  25469. littleSigmaPrime(tmp3, w[j - 2], tmp2);
  25470. tmp3.add(w[j - 7]);
  25471. littleSigma(tmp1, w[j - 15], tmp2);
  25472. tmp3.add(tmp1);
  25473. tmp3.add(w[j - 16]);
  25474. }
  25475. a.assign(h0);
  25476. b.assign(h1);
  25477. c.assign(h2);
  25478. d.assign(h3);
  25479. e.assign(h4);
  25480. f.assign(h5);
  25481. g.assign(h6);
  25482. h.assign(h7);
  25483. for (j = 0; j < 80; ++j) {
  25484. t1.assign(h);
  25485. sigmaPrime(tmp1, e, tmp2);
  25486. t1.add(tmp1);
  25487. ch(tmp1, e, f, g, tmp2);
  25488. t1.add(tmp1);
  25489. t1.add(k[j]);
  25490. t1.add(w[j]);
  25491. sigma(t2, a, tmp2);
  25492. maj(tmp1, a, b, c, tmp2);
  25493. t2.add(tmp1);
  25494. tmp3 = h;
  25495. h = g;
  25496. g = f;
  25497. f = e;
  25498. d.add(t1);
  25499. e = d;
  25500. d = c;
  25501. c = b;
  25502. b = a;
  25503. tmp3.assign(t1);
  25504. tmp3.add(t2);
  25505. a = tmp3;
  25506. }
  25507. h0.add(a);
  25508. h1.add(b);
  25509. h2.add(c);
  25510. h3.add(d);
  25511. h4.add(e);
  25512. h5.add(f);
  25513. h6.add(g);
  25514. h7.add(h);
  25515. }
  25516. var result;
  25517. if (!mode384) {
  25518. result = new Uint8Array(64);
  25519. h0.copyTo(result, 0);
  25520. h1.copyTo(result, 8);
  25521. h2.copyTo(result, 16);
  25522. h3.copyTo(result, 24);
  25523. h4.copyTo(result, 32);
  25524. h5.copyTo(result, 40);
  25525. h6.copyTo(result, 48);
  25526. h7.copyTo(result, 56);
  25527. } else {
  25528. result = new Uint8Array(48);
  25529. h0.copyTo(result, 0);
  25530. h1.copyTo(result, 8);
  25531. h2.copyTo(result, 16);
  25532. h3.copyTo(result, 24);
  25533. h4.copyTo(result, 32);
  25534. h5.copyTo(result, 40);
  25535. }
  25536. return result;
  25537. }
  25538. return hash;
  25539. }();
  25540. var calculateSHA384 = function calculateSHA384Closure() {
  25541. function hash(data, offset, length) {
  25542. return calculateSHA512(data, offset, length, true);
  25543. }
  25544. return hash;
  25545. }();
  25546. var NullCipher = function NullCipherClosure() {
  25547. function NullCipher() {
  25548. }
  25549. NullCipher.prototype = {
  25550. decryptBlock: function NullCipher_decryptBlock(data) {
  25551. return data;
  25552. }
  25553. };
  25554. return NullCipher;
  25555. }();
  25556. var AES128Cipher = function AES128CipherClosure() {
  25557. var rcon = new Uint8Array([
  25558. 0x8d,
  25559. 0x01,
  25560. 0x02,
  25561. 0x04,
  25562. 0x08,
  25563. 0x10,
  25564. 0x20,
  25565. 0x40,
  25566. 0x80,
  25567. 0x1b,
  25568. 0x36,
  25569. 0x6c,
  25570. 0xd8,
  25571. 0xab,
  25572. 0x4d,
  25573. 0x9a,
  25574. 0x2f,
  25575. 0x5e,
  25576. 0xbc,
  25577. 0x63,
  25578. 0xc6,
  25579. 0x97,
  25580. 0x35,
  25581. 0x6a,
  25582. 0xd4,
  25583. 0xb3,
  25584. 0x7d,
  25585. 0xfa,
  25586. 0xef,
  25587. 0xc5,
  25588. 0x91,
  25589. 0x39,
  25590. 0x72,
  25591. 0xe4,
  25592. 0xd3,
  25593. 0xbd,
  25594. 0x61,
  25595. 0xc2,
  25596. 0x9f,
  25597. 0x25,
  25598. 0x4a,
  25599. 0x94,
  25600. 0x33,
  25601. 0x66,
  25602. 0xcc,
  25603. 0x83,
  25604. 0x1d,
  25605. 0x3a,
  25606. 0x74,
  25607. 0xe8,
  25608. 0xcb,
  25609. 0x8d,
  25610. 0x01,
  25611. 0x02,
  25612. 0x04,
  25613. 0x08,
  25614. 0x10,
  25615. 0x20,
  25616. 0x40,
  25617. 0x80,
  25618. 0x1b,
  25619. 0x36,
  25620. 0x6c,
  25621. 0xd8,
  25622. 0xab,
  25623. 0x4d,
  25624. 0x9a,
  25625. 0x2f,
  25626. 0x5e,
  25627. 0xbc,
  25628. 0x63,
  25629. 0xc6,
  25630. 0x97,
  25631. 0x35,
  25632. 0x6a,
  25633. 0xd4,
  25634. 0xb3,
  25635. 0x7d,
  25636. 0xfa,
  25637. 0xef,
  25638. 0xc5,
  25639. 0x91,
  25640. 0x39,
  25641. 0x72,
  25642. 0xe4,
  25643. 0xd3,
  25644. 0xbd,
  25645. 0x61,
  25646. 0xc2,
  25647. 0x9f,
  25648. 0x25,
  25649. 0x4a,
  25650. 0x94,
  25651. 0x33,
  25652. 0x66,
  25653. 0xcc,
  25654. 0x83,
  25655. 0x1d,
  25656. 0x3a,
  25657. 0x74,
  25658. 0xe8,
  25659. 0xcb,
  25660. 0x8d,
  25661. 0x01,
  25662. 0x02,
  25663. 0x04,
  25664. 0x08,
  25665. 0x10,
  25666. 0x20,
  25667. 0x40,
  25668. 0x80,
  25669. 0x1b,
  25670. 0x36,
  25671. 0x6c,
  25672. 0xd8,
  25673. 0xab,
  25674. 0x4d,
  25675. 0x9a,
  25676. 0x2f,
  25677. 0x5e,
  25678. 0xbc,
  25679. 0x63,
  25680. 0xc6,
  25681. 0x97,
  25682. 0x35,
  25683. 0x6a,
  25684. 0xd4,
  25685. 0xb3,
  25686. 0x7d,
  25687. 0xfa,
  25688. 0xef,
  25689. 0xc5,
  25690. 0x91,
  25691. 0x39,
  25692. 0x72,
  25693. 0xe4,
  25694. 0xd3,
  25695. 0xbd,
  25696. 0x61,
  25697. 0xc2,
  25698. 0x9f,
  25699. 0x25,
  25700. 0x4a,
  25701. 0x94,
  25702. 0x33,
  25703. 0x66,
  25704. 0xcc,
  25705. 0x83,
  25706. 0x1d,
  25707. 0x3a,
  25708. 0x74,
  25709. 0xe8,
  25710. 0xcb,
  25711. 0x8d,
  25712. 0x01,
  25713. 0x02,
  25714. 0x04,
  25715. 0x08,
  25716. 0x10,
  25717. 0x20,
  25718. 0x40,
  25719. 0x80,
  25720. 0x1b,
  25721. 0x36,
  25722. 0x6c,
  25723. 0xd8,
  25724. 0xab,
  25725. 0x4d,
  25726. 0x9a,
  25727. 0x2f,
  25728. 0x5e,
  25729. 0xbc,
  25730. 0x63,
  25731. 0xc6,
  25732. 0x97,
  25733. 0x35,
  25734. 0x6a,
  25735. 0xd4,
  25736. 0xb3,
  25737. 0x7d,
  25738. 0xfa,
  25739. 0xef,
  25740. 0xc5,
  25741. 0x91,
  25742. 0x39,
  25743. 0x72,
  25744. 0xe4,
  25745. 0xd3,
  25746. 0xbd,
  25747. 0x61,
  25748. 0xc2,
  25749. 0x9f,
  25750. 0x25,
  25751. 0x4a,
  25752. 0x94,
  25753. 0x33,
  25754. 0x66,
  25755. 0xcc,
  25756. 0x83,
  25757. 0x1d,
  25758. 0x3a,
  25759. 0x74,
  25760. 0xe8,
  25761. 0xcb,
  25762. 0x8d,
  25763. 0x01,
  25764. 0x02,
  25765. 0x04,
  25766. 0x08,
  25767. 0x10,
  25768. 0x20,
  25769. 0x40,
  25770. 0x80,
  25771. 0x1b,
  25772. 0x36,
  25773. 0x6c,
  25774. 0xd8,
  25775. 0xab,
  25776. 0x4d,
  25777. 0x9a,
  25778. 0x2f,
  25779. 0x5e,
  25780. 0xbc,
  25781. 0x63,
  25782. 0xc6,
  25783. 0x97,
  25784. 0x35,
  25785. 0x6a,
  25786. 0xd4,
  25787. 0xb3,
  25788. 0x7d,
  25789. 0xfa,
  25790. 0xef,
  25791. 0xc5,
  25792. 0x91,
  25793. 0x39,
  25794. 0x72,
  25795. 0xe4,
  25796. 0xd3,
  25797. 0xbd,
  25798. 0x61,
  25799. 0xc2,
  25800. 0x9f,
  25801. 0x25,
  25802. 0x4a,
  25803. 0x94,
  25804. 0x33,
  25805. 0x66,
  25806. 0xcc,
  25807. 0x83,
  25808. 0x1d,
  25809. 0x3a,
  25810. 0x74,
  25811. 0xe8,
  25812. 0xcb,
  25813. 0x8d
  25814. ]);
  25815. var s = new Uint8Array([
  25816. 0x63,
  25817. 0x7c,
  25818. 0x77,
  25819. 0x7b,
  25820. 0xf2,
  25821. 0x6b,
  25822. 0x6f,
  25823. 0xc5,
  25824. 0x30,
  25825. 0x01,
  25826. 0x67,
  25827. 0x2b,
  25828. 0xfe,
  25829. 0xd7,
  25830. 0xab,
  25831. 0x76,
  25832. 0xca,
  25833. 0x82,
  25834. 0xc9,
  25835. 0x7d,
  25836. 0xfa,
  25837. 0x59,
  25838. 0x47,
  25839. 0xf0,
  25840. 0xad,
  25841. 0xd4,
  25842. 0xa2,
  25843. 0xaf,
  25844. 0x9c,
  25845. 0xa4,
  25846. 0x72,
  25847. 0xc0,
  25848. 0xb7,
  25849. 0xfd,
  25850. 0x93,
  25851. 0x26,
  25852. 0x36,
  25853. 0x3f,
  25854. 0xf7,
  25855. 0xcc,
  25856. 0x34,
  25857. 0xa5,
  25858. 0xe5,
  25859. 0xf1,
  25860. 0x71,
  25861. 0xd8,
  25862. 0x31,
  25863. 0x15,
  25864. 0x04,
  25865. 0xc7,
  25866. 0x23,
  25867. 0xc3,
  25868. 0x18,
  25869. 0x96,
  25870. 0x05,
  25871. 0x9a,
  25872. 0x07,
  25873. 0x12,
  25874. 0x80,
  25875. 0xe2,
  25876. 0xeb,
  25877. 0x27,
  25878. 0xb2,
  25879. 0x75,
  25880. 0x09,
  25881. 0x83,
  25882. 0x2c,
  25883. 0x1a,
  25884. 0x1b,
  25885. 0x6e,
  25886. 0x5a,
  25887. 0xa0,
  25888. 0x52,
  25889. 0x3b,
  25890. 0xd6,
  25891. 0xb3,
  25892. 0x29,
  25893. 0xe3,
  25894. 0x2f,
  25895. 0x84,
  25896. 0x53,
  25897. 0xd1,
  25898. 0x00,
  25899. 0xed,
  25900. 0x20,
  25901. 0xfc,
  25902. 0xb1,
  25903. 0x5b,
  25904. 0x6a,
  25905. 0xcb,
  25906. 0xbe,
  25907. 0x39,
  25908. 0x4a,
  25909. 0x4c,
  25910. 0x58,
  25911. 0xcf,
  25912. 0xd0,
  25913. 0xef,
  25914. 0xaa,
  25915. 0xfb,
  25916. 0x43,
  25917. 0x4d,
  25918. 0x33,
  25919. 0x85,
  25920. 0x45,
  25921. 0xf9,
  25922. 0x02,
  25923. 0x7f,
  25924. 0x50,
  25925. 0x3c,
  25926. 0x9f,
  25927. 0xa8,
  25928. 0x51,
  25929. 0xa3,
  25930. 0x40,
  25931. 0x8f,
  25932. 0x92,
  25933. 0x9d,
  25934. 0x38,
  25935. 0xf5,
  25936. 0xbc,
  25937. 0xb6,
  25938. 0xda,
  25939. 0x21,
  25940. 0x10,
  25941. 0xff,
  25942. 0xf3,
  25943. 0xd2,
  25944. 0xcd,
  25945. 0x0c,
  25946. 0x13,
  25947. 0xec,
  25948. 0x5f,
  25949. 0x97,
  25950. 0x44,
  25951. 0x17,
  25952. 0xc4,
  25953. 0xa7,
  25954. 0x7e,
  25955. 0x3d,
  25956. 0x64,
  25957. 0x5d,
  25958. 0x19,
  25959. 0x73,
  25960. 0x60,
  25961. 0x81,
  25962. 0x4f,
  25963. 0xdc,
  25964. 0x22,
  25965. 0x2a,
  25966. 0x90,
  25967. 0x88,
  25968. 0x46,
  25969. 0xee,
  25970. 0xb8,
  25971. 0x14,
  25972. 0xde,
  25973. 0x5e,
  25974. 0x0b,
  25975. 0xdb,
  25976. 0xe0,
  25977. 0x32,
  25978. 0x3a,
  25979. 0x0a,
  25980. 0x49,
  25981. 0x06,
  25982. 0x24,
  25983. 0x5c,
  25984. 0xc2,
  25985. 0xd3,
  25986. 0xac,
  25987. 0x62,
  25988. 0x91,
  25989. 0x95,
  25990. 0xe4,
  25991. 0x79,
  25992. 0xe7,
  25993. 0xc8,
  25994. 0x37,
  25995. 0x6d,
  25996. 0x8d,
  25997. 0xd5,
  25998. 0x4e,
  25999. 0xa9,
  26000. 0x6c,
  26001. 0x56,
  26002. 0xf4,
  26003. 0xea,
  26004. 0x65,
  26005. 0x7a,
  26006. 0xae,
  26007. 0x08,
  26008. 0xba,
  26009. 0x78,
  26010. 0x25,
  26011. 0x2e,
  26012. 0x1c,
  26013. 0xa6,
  26014. 0xb4,
  26015. 0xc6,
  26016. 0xe8,
  26017. 0xdd,
  26018. 0x74,
  26019. 0x1f,
  26020. 0x4b,
  26021. 0xbd,
  26022. 0x8b,
  26023. 0x8a,
  26024. 0x70,
  26025. 0x3e,
  26026. 0xb5,
  26027. 0x66,
  26028. 0x48,
  26029. 0x03,
  26030. 0xf6,
  26031. 0x0e,
  26032. 0x61,
  26033. 0x35,
  26034. 0x57,
  26035. 0xb9,
  26036. 0x86,
  26037. 0xc1,
  26038. 0x1d,
  26039. 0x9e,
  26040. 0xe1,
  26041. 0xf8,
  26042. 0x98,
  26043. 0x11,
  26044. 0x69,
  26045. 0xd9,
  26046. 0x8e,
  26047. 0x94,
  26048. 0x9b,
  26049. 0x1e,
  26050. 0x87,
  26051. 0xe9,
  26052. 0xce,
  26053. 0x55,
  26054. 0x28,
  26055. 0xdf,
  26056. 0x8c,
  26057. 0xa1,
  26058. 0x89,
  26059. 0x0d,
  26060. 0xbf,
  26061. 0xe6,
  26062. 0x42,
  26063. 0x68,
  26064. 0x41,
  26065. 0x99,
  26066. 0x2d,
  26067. 0x0f,
  26068. 0xb0,
  26069. 0x54,
  26070. 0xbb,
  26071. 0x16
  26072. ]);
  26073. var inv_s = new Uint8Array([
  26074. 0x52,
  26075. 0x09,
  26076. 0x6a,
  26077. 0xd5,
  26078. 0x30,
  26079. 0x36,
  26080. 0xa5,
  26081. 0x38,
  26082. 0xbf,
  26083. 0x40,
  26084. 0xa3,
  26085. 0x9e,
  26086. 0x81,
  26087. 0xf3,
  26088. 0xd7,
  26089. 0xfb,
  26090. 0x7c,
  26091. 0xe3,
  26092. 0x39,
  26093. 0x82,
  26094. 0x9b,
  26095. 0x2f,
  26096. 0xff,
  26097. 0x87,
  26098. 0x34,
  26099. 0x8e,
  26100. 0x43,
  26101. 0x44,
  26102. 0xc4,
  26103. 0xde,
  26104. 0xe9,
  26105. 0xcb,
  26106. 0x54,
  26107. 0x7b,
  26108. 0x94,
  26109. 0x32,
  26110. 0xa6,
  26111. 0xc2,
  26112. 0x23,
  26113. 0x3d,
  26114. 0xee,
  26115. 0x4c,
  26116. 0x95,
  26117. 0x0b,
  26118. 0x42,
  26119. 0xfa,
  26120. 0xc3,
  26121. 0x4e,
  26122. 0x08,
  26123. 0x2e,
  26124. 0xa1,
  26125. 0x66,
  26126. 0x28,
  26127. 0xd9,
  26128. 0x24,
  26129. 0xb2,
  26130. 0x76,
  26131. 0x5b,
  26132. 0xa2,
  26133. 0x49,
  26134. 0x6d,
  26135. 0x8b,
  26136. 0xd1,
  26137. 0x25,
  26138. 0x72,
  26139. 0xf8,
  26140. 0xf6,
  26141. 0x64,
  26142. 0x86,
  26143. 0x68,
  26144. 0x98,
  26145. 0x16,
  26146. 0xd4,
  26147. 0xa4,
  26148. 0x5c,
  26149. 0xcc,
  26150. 0x5d,
  26151. 0x65,
  26152. 0xb6,
  26153. 0x92,
  26154. 0x6c,
  26155. 0x70,
  26156. 0x48,
  26157. 0x50,
  26158. 0xfd,
  26159. 0xed,
  26160. 0xb9,
  26161. 0xda,
  26162. 0x5e,
  26163. 0x15,
  26164. 0x46,
  26165. 0x57,
  26166. 0xa7,
  26167. 0x8d,
  26168. 0x9d,
  26169. 0x84,
  26170. 0x90,
  26171. 0xd8,
  26172. 0xab,
  26173. 0x00,
  26174. 0x8c,
  26175. 0xbc,
  26176. 0xd3,
  26177. 0x0a,
  26178. 0xf7,
  26179. 0xe4,
  26180. 0x58,
  26181. 0x05,
  26182. 0xb8,
  26183. 0xb3,
  26184. 0x45,
  26185. 0x06,
  26186. 0xd0,
  26187. 0x2c,
  26188. 0x1e,
  26189. 0x8f,
  26190. 0xca,
  26191. 0x3f,
  26192. 0x0f,
  26193. 0x02,
  26194. 0xc1,
  26195. 0xaf,
  26196. 0xbd,
  26197. 0x03,
  26198. 0x01,
  26199. 0x13,
  26200. 0x8a,
  26201. 0x6b,
  26202. 0x3a,
  26203. 0x91,
  26204. 0x11,
  26205. 0x41,
  26206. 0x4f,
  26207. 0x67,
  26208. 0xdc,
  26209. 0xea,
  26210. 0x97,
  26211. 0xf2,
  26212. 0xcf,
  26213. 0xce,
  26214. 0xf0,
  26215. 0xb4,
  26216. 0xe6,
  26217. 0x73,
  26218. 0x96,
  26219. 0xac,
  26220. 0x74,
  26221. 0x22,
  26222. 0xe7,
  26223. 0xad,
  26224. 0x35,
  26225. 0x85,
  26226. 0xe2,
  26227. 0xf9,
  26228. 0x37,
  26229. 0xe8,
  26230. 0x1c,
  26231. 0x75,
  26232. 0xdf,
  26233. 0x6e,
  26234. 0x47,
  26235. 0xf1,
  26236. 0x1a,
  26237. 0x71,
  26238. 0x1d,
  26239. 0x29,
  26240. 0xc5,
  26241. 0x89,
  26242. 0x6f,
  26243. 0xb7,
  26244. 0x62,
  26245. 0x0e,
  26246. 0xaa,
  26247. 0x18,
  26248. 0xbe,
  26249. 0x1b,
  26250. 0xfc,
  26251. 0x56,
  26252. 0x3e,
  26253. 0x4b,
  26254. 0xc6,
  26255. 0xd2,
  26256. 0x79,
  26257. 0x20,
  26258. 0x9a,
  26259. 0xdb,
  26260. 0xc0,
  26261. 0xfe,
  26262. 0x78,
  26263. 0xcd,
  26264. 0x5a,
  26265. 0xf4,
  26266. 0x1f,
  26267. 0xdd,
  26268. 0xa8,
  26269. 0x33,
  26270. 0x88,
  26271. 0x07,
  26272. 0xc7,
  26273. 0x31,
  26274. 0xb1,
  26275. 0x12,
  26276. 0x10,
  26277. 0x59,
  26278. 0x27,
  26279. 0x80,
  26280. 0xec,
  26281. 0x5f,
  26282. 0x60,
  26283. 0x51,
  26284. 0x7f,
  26285. 0xa9,
  26286. 0x19,
  26287. 0xb5,
  26288. 0x4a,
  26289. 0x0d,
  26290. 0x2d,
  26291. 0xe5,
  26292. 0x7a,
  26293. 0x9f,
  26294. 0x93,
  26295. 0xc9,
  26296. 0x9c,
  26297. 0xef,
  26298. 0xa0,
  26299. 0xe0,
  26300. 0x3b,
  26301. 0x4d,
  26302. 0xae,
  26303. 0x2a,
  26304. 0xf5,
  26305. 0xb0,
  26306. 0xc8,
  26307. 0xeb,
  26308. 0xbb,
  26309. 0x3c,
  26310. 0x83,
  26311. 0x53,
  26312. 0x99,
  26313. 0x61,
  26314. 0x17,
  26315. 0x2b,
  26316. 0x04,
  26317. 0x7e,
  26318. 0xba,
  26319. 0x77,
  26320. 0xd6,
  26321. 0x26,
  26322. 0xe1,
  26323. 0x69,
  26324. 0x14,
  26325. 0x63,
  26326. 0x55,
  26327. 0x21,
  26328. 0x0c,
  26329. 0x7d
  26330. ]);
  26331. var mixCol = new Uint8Array(256);
  26332. for (var i = 0; i < 256; i++) {
  26333. if (i < 128) {
  26334. mixCol[i] = i << 1;
  26335. } else {
  26336. mixCol[i] = i << 1 ^ 0x1b;
  26337. }
  26338. }
  26339. var mix = new Uint32Array([
  26340. 0x00000000,
  26341. 0x0e090d0b,
  26342. 0x1c121a16,
  26343. 0x121b171d,
  26344. 0x3824342c,
  26345. 0x362d3927,
  26346. 0x24362e3a,
  26347. 0x2a3f2331,
  26348. 0x70486858,
  26349. 0x7e416553,
  26350. 0x6c5a724e,
  26351. 0x62537f45,
  26352. 0x486c5c74,
  26353. 0x4665517f,
  26354. 0x547e4662,
  26355. 0x5a774b69,
  26356. 0xe090d0b0,
  26357. 0xee99ddbb,
  26358. 0xfc82caa6,
  26359. 0xf28bc7ad,
  26360. 0xd8b4e49c,
  26361. 0xd6bde997,
  26362. 0xc4a6fe8a,
  26363. 0xcaaff381,
  26364. 0x90d8b8e8,
  26365. 0x9ed1b5e3,
  26366. 0x8ccaa2fe,
  26367. 0x82c3aff5,
  26368. 0xa8fc8cc4,
  26369. 0xa6f581cf,
  26370. 0xb4ee96d2,
  26371. 0xbae79bd9,
  26372. 0xdb3bbb7b,
  26373. 0xd532b670,
  26374. 0xc729a16d,
  26375. 0xc920ac66,
  26376. 0xe31f8f57,
  26377. 0xed16825c,
  26378. 0xff0d9541,
  26379. 0xf104984a,
  26380. 0xab73d323,
  26381. 0xa57ade28,
  26382. 0xb761c935,
  26383. 0xb968c43e,
  26384. 0x9357e70f,
  26385. 0x9d5eea04,
  26386. 0x8f45fd19,
  26387. 0x814cf012,
  26388. 0x3bab6bcb,
  26389. 0x35a266c0,
  26390. 0x27b971dd,
  26391. 0x29b07cd6,
  26392. 0x038f5fe7,
  26393. 0x0d8652ec,
  26394. 0x1f9d45f1,
  26395. 0x119448fa,
  26396. 0x4be30393,
  26397. 0x45ea0e98,
  26398. 0x57f11985,
  26399. 0x59f8148e,
  26400. 0x73c737bf,
  26401. 0x7dce3ab4,
  26402. 0x6fd52da9,
  26403. 0x61dc20a2,
  26404. 0xad766df6,
  26405. 0xa37f60fd,
  26406. 0xb16477e0,
  26407. 0xbf6d7aeb,
  26408. 0x955259da,
  26409. 0x9b5b54d1,
  26410. 0x894043cc,
  26411. 0x87494ec7,
  26412. 0xdd3e05ae,
  26413. 0xd33708a5,
  26414. 0xc12c1fb8,
  26415. 0xcf2512b3,
  26416. 0xe51a3182,
  26417. 0xeb133c89,
  26418. 0xf9082b94,
  26419. 0xf701269f,
  26420. 0x4de6bd46,
  26421. 0x43efb04d,
  26422. 0x51f4a750,
  26423. 0x5ffdaa5b,
  26424. 0x75c2896a,
  26425. 0x7bcb8461,
  26426. 0x69d0937c,
  26427. 0x67d99e77,
  26428. 0x3daed51e,
  26429. 0x33a7d815,
  26430. 0x21bccf08,
  26431. 0x2fb5c203,
  26432. 0x058ae132,
  26433. 0x0b83ec39,
  26434. 0x1998fb24,
  26435. 0x1791f62f,
  26436. 0x764dd68d,
  26437. 0x7844db86,
  26438. 0x6a5fcc9b,
  26439. 0x6456c190,
  26440. 0x4e69e2a1,
  26441. 0x4060efaa,
  26442. 0x527bf8b7,
  26443. 0x5c72f5bc,
  26444. 0x0605bed5,
  26445. 0x080cb3de,
  26446. 0x1a17a4c3,
  26447. 0x141ea9c8,
  26448. 0x3e218af9,
  26449. 0x302887f2,
  26450. 0x223390ef,
  26451. 0x2c3a9de4,
  26452. 0x96dd063d,
  26453. 0x98d40b36,
  26454. 0x8acf1c2b,
  26455. 0x84c61120,
  26456. 0xaef93211,
  26457. 0xa0f03f1a,
  26458. 0xb2eb2807,
  26459. 0xbce2250c,
  26460. 0xe6956e65,
  26461. 0xe89c636e,
  26462. 0xfa877473,
  26463. 0xf48e7978,
  26464. 0xdeb15a49,
  26465. 0xd0b85742,
  26466. 0xc2a3405f,
  26467. 0xccaa4d54,
  26468. 0x41ecdaf7,
  26469. 0x4fe5d7fc,
  26470. 0x5dfec0e1,
  26471. 0x53f7cdea,
  26472. 0x79c8eedb,
  26473. 0x77c1e3d0,
  26474. 0x65daf4cd,
  26475. 0x6bd3f9c6,
  26476. 0x31a4b2af,
  26477. 0x3fadbfa4,
  26478. 0x2db6a8b9,
  26479. 0x23bfa5b2,
  26480. 0x09808683,
  26481. 0x07898b88,
  26482. 0x15929c95,
  26483. 0x1b9b919e,
  26484. 0xa17c0a47,
  26485. 0xaf75074c,
  26486. 0xbd6e1051,
  26487. 0xb3671d5a,
  26488. 0x99583e6b,
  26489. 0x97513360,
  26490. 0x854a247d,
  26491. 0x8b432976,
  26492. 0xd134621f,
  26493. 0xdf3d6f14,
  26494. 0xcd267809,
  26495. 0xc32f7502,
  26496. 0xe9105633,
  26497. 0xe7195b38,
  26498. 0xf5024c25,
  26499. 0xfb0b412e,
  26500. 0x9ad7618c,
  26501. 0x94de6c87,
  26502. 0x86c57b9a,
  26503. 0x88cc7691,
  26504. 0xa2f355a0,
  26505. 0xacfa58ab,
  26506. 0xbee14fb6,
  26507. 0xb0e842bd,
  26508. 0xea9f09d4,
  26509. 0xe49604df,
  26510. 0xf68d13c2,
  26511. 0xf8841ec9,
  26512. 0xd2bb3df8,
  26513. 0xdcb230f3,
  26514. 0xcea927ee,
  26515. 0xc0a02ae5,
  26516. 0x7a47b13c,
  26517. 0x744ebc37,
  26518. 0x6655ab2a,
  26519. 0x685ca621,
  26520. 0x42638510,
  26521. 0x4c6a881b,
  26522. 0x5e719f06,
  26523. 0x5078920d,
  26524. 0x0a0fd964,
  26525. 0x0406d46f,
  26526. 0x161dc372,
  26527. 0x1814ce79,
  26528. 0x322bed48,
  26529. 0x3c22e043,
  26530. 0x2e39f75e,
  26531. 0x2030fa55,
  26532. 0xec9ab701,
  26533. 0xe293ba0a,
  26534. 0xf088ad17,
  26535. 0xfe81a01c,
  26536. 0xd4be832d,
  26537. 0xdab78e26,
  26538. 0xc8ac993b,
  26539. 0xc6a59430,
  26540. 0x9cd2df59,
  26541. 0x92dbd252,
  26542. 0x80c0c54f,
  26543. 0x8ec9c844,
  26544. 0xa4f6eb75,
  26545. 0xaaffe67e,
  26546. 0xb8e4f163,
  26547. 0xb6edfc68,
  26548. 0x0c0a67b1,
  26549. 0x02036aba,
  26550. 0x10187da7,
  26551. 0x1e1170ac,
  26552. 0x342e539d,
  26553. 0x3a275e96,
  26554. 0x283c498b,
  26555. 0x26354480,
  26556. 0x7c420fe9,
  26557. 0x724b02e2,
  26558. 0x605015ff,
  26559. 0x6e5918f4,
  26560. 0x44663bc5,
  26561. 0x4a6f36ce,
  26562. 0x587421d3,
  26563. 0x567d2cd8,
  26564. 0x37a10c7a,
  26565. 0x39a80171,
  26566. 0x2bb3166c,
  26567. 0x25ba1b67,
  26568. 0x0f853856,
  26569. 0x018c355d,
  26570. 0x13972240,
  26571. 0x1d9e2f4b,
  26572. 0x47e96422,
  26573. 0x49e06929,
  26574. 0x5bfb7e34,
  26575. 0x55f2733f,
  26576. 0x7fcd500e,
  26577. 0x71c45d05,
  26578. 0x63df4a18,
  26579. 0x6dd64713,
  26580. 0xd731dcca,
  26581. 0xd938d1c1,
  26582. 0xcb23c6dc,
  26583. 0xc52acbd7,
  26584. 0xef15e8e6,
  26585. 0xe11ce5ed,
  26586. 0xf307f2f0,
  26587. 0xfd0efffb,
  26588. 0xa779b492,
  26589. 0xa970b999,
  26590. 0xbb6bae84,
  26591. 0xb562a38f,
  26592. 0x9f5d80be,
  26593. 0x91548db5,
  26594. 0x834f9aa8,
  26595. 0x8d4697a3
  26596. ]);
  26597. function expandKey128(cipherKey) {
  26598. var b = 176, result = new Uint8Array(b);
  26599. result.set(cipherKey);
  26600. for (var j = 16, i = 1; j < b; ++i) {
  26601. var t1 = result[j - 3], t2 = result[j - 2], t3 = result[j - 1], t4 = result[j - 4];
  26602. t1 = s[t1];
  26603. t2 = s[t2];
  26604. t3 = s[t3];
  26605. t4 = s[t4];
  26606. t1 = t1 ^ rcon[i];
  26607. for (var n = 0; n < 4; ++n) {
  26608. result[j] = t1 ^= result[j - 16];
  26609. j++;
  26610. result[j] = t2 ^= result[j - 16];
  26611. j++;
  26612. result[j] = t3 ^= result[j - 16];
  26613. j++;
  26614. result[j] = t4 ^= result[j - 16];
  26615. j++;
  26616. }
  26617. }
  26618. return result;
  26619. }
  26620. function decrypt128(input, key) {
  26621. var state = new Uint8Array(16);
  26622. state.set(input);
  26623. var i, j, k;
  26624. var t, u, v;
  26625. for (j = 0, k = 160; j < 16; ++j, ++k) {
  26626. state[j] ^= key[k];
  26627. }
  26628. for (i = 9; i >= 1; --i) {
  26629. t = state[13];
  26630. state[13] = state[9];
  26631. state[9] = state[5];
  26632. state[5] = state[1];
  26633. state[1] = t;
  26634. t = state[14];
  26635. u = state[10];
  26636. state[14] = state[6];
  26637. state[10] = state[2];
  26638. state[6] = t;
  26639. state[2] = u;
  26640. t = state[15];
  26641. u = state[11];
  26642. v = state[7];
  26643. state[15] = state[3];
  26644. state[11] = t;
  26645. state[7] = u;
  26646. state[3] = v;
  26647. for (j = 0; j < 16; ++j) {
  26648. state[j] = inv_s[state[j]];
  26649. }
  26650. for (j = 0, k = i * 16; j < 16; ++j, ++k) {
  26651. state[j] ^= key[k];
  26652. }
  26653. for (j = 0; j < 16; j += 4) {
  26654. var s0 = mix[state[j]], s1 = mix[state[j + 1]], s2 = mix[state[j + 2]], s3 = mix[state[j + 3]];
  26655. t = s0 ^ s1 >>> 8 ^ s1 << 24 ^ s2 >>> 16 ^ s2 << 16 ^ s3 >>> 24 ^ s3 << 8;
  26656. state[j] = t >>> 24 & 0xFF;
  26657. state[j + 1] = t >> 16 & 0xFF;
  26658. state[j + 2] = t >> 8 & 0xFF;
  26659. state[j + 3] = t & 0xFF;
  26660. }
  26661. }
  26662. t = state[13];
  26663. state[13] = state[9];
  26664. state[9] = state[5];
  26665. state[5] = state[1];
  26666. state[1] = t;
  26667. t = state[14];
  26668. u = state[10];
  26669. state[14] = state[6];
  26670. state[10] = state[2];
  26671. state[6] = t;
  26672. state[2] = u;
  26673. t = state[15];
  26674. u = state[11];
  26675. v = state[7];
  26676. state[15] = state[3];
  26677. state[11] = t;
  26678. state[7] = u;
  26679. state[3] = v;
  26680. for (j = 0; j < 16; ++j) {
  26681. state[j] = inv_s[state[j]];
  26682. state[j] ^= key[j];
  26683. }
  26684. return state;
  26685. }
  26686. function encrypt128(input, key) {
  26687. var t, u, v, k;
  26688. var state = new Uint8Array(16);
  26689. state.set(input);
  26690. for (j = 0; j < 16; ++j) {
  26691. state[j] ^= key[j];
  26692. }
  26693. for (i = 1; i < 10; i++) {
  26694. for (j = 0; j < 16; ++j) {
  26695. state[j] = s[state[j]];
  26696. }
  26697. v = state[1];
  26698. state[1] = state[5];
  26699. state[5] = state[9];
  26700. state[9] = state[13];
  26701. state[13] = v;
  26702. v = state[2];
  26703. u = state[6];
  26704. state[2] = state[10];
  26705. state[6] = state[14];
  26706. state[10] = v;
  26707. state[14] = u;
  26708. v = state[3];
  26709. u = state[7];
  26710. t = state[11];
  26711. state[3] = state[15];
  26712. state[7] = v;
  26713. state[11] = u;
  26714. state[15] = t;
  26715. for (var j = 0; j < 16; j += 4) {
  26716. var s0 = state[j + 0], s1 = state[j + 1];
  26717. var s2 = state[j + 2], s3 = state[j + 3];
  26718. t = s0 ^ s1 ^ s2 ^ s3;
  26719. state[j + 0] ^= t ^ mixCol[s0 ^ s1];
  26720. state[j + 1] ^= t ^ mixCol[s1 ^ s2];
  26721. state[j + 2] ^= t ^ mixCol[s2 ^ s3];
  26722. state[j + 3] ^= t ^ mixCol[s3 ^ s0];
  26723. }
  26724. for (j = 0, k = i * 16; j < 16; ++j, ++k) {
  26725. state[j] ^= key[k];
  26726. }
  26727. }
  26728. for (j = 0; j < 16; ++j) {
  26729. state[j] = s[state[j]];
  26730. }
  26731. v = state[1];
  26732. state[1] = state[5];
  26733. state[5] = state[9];
  26734. state[9] = state[13];
  26735. state[13] = v;
  26736. v = state[2];
  26737. u = state[6];
  26738. state[2] = state[10];
  26739. state[6] = state[14];
  26740. state[10] = v;
  26741. state[14] = u;
  26742. v = state[3];
  26743. u = state[7];
  26744. t = state[11];
  26745. state[3] = state[15];
  26746. state[7] = v;
  26747. state[11] = u;
  26748. state[15] = t;
  26749. for (j = 0, k = 160; j < 16; ++j, ++k) {
  26750. state[j] ^= key[k];
  26751. }
  26752. return state;
  26753. }
  26754. function AES128Cipher(key) {
  26755. this.key = expandKey128(key);
  26756. this.buffer = new Uint8Array(16);
  26757. this.bufferPosition = 0;
  26758. }
  26759. function decryptBlock2(data, finalize) {
  26760. var i, j, ii, sourceLength = data.length, buffer = this.buffer, bufferLength = this.bufferPosition, result = [], iv = this.iv;
  26761. for (i = 0; i < sourceLength; ++i) {
  26762. buffer[bufferLength] = data[i];
  26763. ++bufferLength;
  26764. if (bufferLength < 16) {
  26765. continue;
  26766. }
  26767. var plain = decrypt128(buffer, this.key);
  26768. for (j = 0; j < 16; ++j) {
  26769. plain[j] ^= iv[j];
  26770. }
  26771. iv = buffer;
  26772. result.push(plain);
  26773. buffer = new Uint8Array(16);
  26774. bufferLength = 0;
  26775. }
  26776. this.buffer = buffer;
  26777. this.bufferLength = bufferLength;
  26778. this.iv = iv;
  26779. if (result.length === 0) {
  26780. return new Uint8Array([]);
  26781. }
  26782. var outputLength = 16 * result.length;
  26783. if (finalize) {
  26784. var lastBlock = result[result.length - 1];
  26785. var psLen = lastBlock[15];
  26786. if (psLen <= 16) {
  26787. for (i = 15, ii = 16 - psLen; i >= ii; --i) {
  26788. if (lastBlock[i] !== psLen) {
  26789. psLen = 0;
  26790. break;
  26791. }
  26792. }
  26793. outputLength -= psLen;
  26794. result[result.length - 1] = lastBlock.subarray(0, 16 - psLen);
  26795. }
  26796. }
  26797. var output = new Uint8Array(outputLength);
  26798. for (i = 0, j = 0, ii = result.length; i < ii; ++i, j += 16) {
  26799. output.set(result[i], j);
  26800. }
  26801. return output;
  26802. }
  26803. AES128Cipher.prototype = {
  26804. decryptBlock: function AES128Cipher_decryptBlock(data, finalize) {
  26805. var i, sourceLength = data.length;
  26806. var buffer = this.buffer, bufferLength = this.bufferPosition;
  26807. for (i = 0; bufferLength < 16 && i < sourceLength; ++i, ++bufferLength) {
  26808. buffer[bufferLength] = data[i];
  26809. }
  26810. if (bufferLength < 16) {
  26811. this.bufferLength = bufferLength;
  26812. return new Uint8Array([]);
  26813. }
  26814. this.iv = buffer;
  26815. this.buffer = new Uint8Array(16);
  26816. this.bufferLength = 0;
  26817. this.decryptBlock = decryptBlock2;
  26818. return this.decryptBlock(data.subarray(16), finalize);
  26819. },
  26820. encrypt: function AES128Cipher_encrypt(data, iv) {
  26821. var i, j, ii, sourceLength = data.length, buffer = this.buffer, bufferLength = this.bufferPosition, result = [];
  26822. if (!iv) {
  26823. iv = new Uint8Array(16);
  26824. }
  26825. for (i = 0; i < sourceLength; ++i) {
  26826. buffer[bufferLength] = data[i];
  26827. ++bufferLength;
  26828. if (bufferLength < 16) {
  26829. continue;
  26830. }
  26831. for (j = 0; j < 16; ++j) {
  26832. buffer[j] ^= iv[j];
  26833. }
  26834. var cipher = encrypt128(buffer, this.key);
  26835. iv = cipher;
  26836. result.push(cipher);
  26837. buffer = new Uint8Array(16);
  26838. bufferLength = 0;
  26839. }
  26840. this.buffer = buffer;
  26841. this.bufferLength = bufferLength;
  26842. this.iv = iv;
  26843. if (result.length === 0) {
  26844. return new Uint8Array([]);
  26845. }
  26846. var outputLength = 16 * result.length;
  26847. var output = new Uint8Array(outputLength);
  26848. for (i = 0, j = 0, ii = result.length; i < ii; ++i, j += 16) {
  26849. output.set(result[i], j);
  26850. }
  26851. return output;
  26852. }
  26853. };
  26854. return AES128Cipher;
  26855. }();
  26856. var AES256Cipher = function AES256CipherClosure() {
  26857. var s = new Uint8Array([
  26858. 0x63,
  26859. 0x7c,
  26860. 0x77,
  26861. 0x7b,
  26862. 0xf2,
  26863. 0x6b,
  26864. 0x6f,
  26865. 0xc5,
  26866. 0x30,
  26867. 0x01,
  26868. 0x67,
  26869. 0x2b,
  26870. 0xfe,
  26871. 0xd7,
  26872. 0xab,
  26873. 0x76,
  26874. 0xca,
  26875. 0x82,
  26876. 0xc9,
  26877. 0x7d,
  26878. 0xfa,
  26879. 0x59,
  26880. 0x47,
  26881. 0xf0,
  26882. 0xad,
  26883. 0xd4,
  26884. 0xa2,
  26885. 0xaf,
  26886. 0x9c,
  26887. 0xa4,
  26888. 0x72,
  26889. 0xc0,
  26890. 0xb7,
  26891. 0xfd,
  26892. 0x93,
  26893. 0x26,
  26894. 0x36,
  26895. 0x3f,
  26896. 0xf7,
  26897. 0xcc,
  26898. 0x34,
  26899. 0xa5,
  26900. 0xe5,
  26901. 0xf1,
  26902. 0x71,
  26903. 0xd8,
  26904. 0x31,
  26905. 0x15,
  26906. 0x04,
  26907. 0xc7,
  26908. 0x23,
  26909. 0xc3,
  26910. 0x18,
  26911. 0x96,
  26912. 0x05,
  26913. 0x9a,
  26914. 0x07,
  26915. 0x12,
  26916. 0x80,
  26917. 0xe2,
  26918. 0xeb,
  26919. 0x27,
  26920. 0xb2,
  26921. 0x75,
  26922. 0x09,
  26923. 0x83,
  26924. 0x2c,
  26925. 0x1a,
  26926. 0x1b,
  26927. 0x6e,
  26928. 0x5a,
  26929. 0xa0,
  26930. 0x52,
  26931. 0x3b,
  26932. 0xd6,
  26933. 0xb3,
  26934. 0x29,
  26935. 0xe3,
  26936. 0x2f,
  26937. 0x84,
  26938. 0x53,
  26939. 0xd1,
  26940. 0x00,
  26941. 0xed,
  26942. 0x20,
  26943. 0xfc,
  26944. 0xb1,
  26945. 0x5b,
  26946. 0x6a,
  26947. 0xcb,
  26948. 0xbe,
  26949. 0x39,
  26950. 0x4a,
  26951. 0x4c,
  26952. 0x58,
  26953. 0xcf,
  26954. 0xd0,
  26955. 0xef,
  26956. 0xaa,
  26957. 0xfb,
  26958. 0x43,
  26959. 0x4d,
  26960. 0x33,
  26961. 0x85,
  26962. 0x45,
  26963. 0xf9,
  26964. 0x02,
  26965. 0x7f,
  26966. 0x50,
  26967. 0x3c,
  26968. 0x9f,
  26969. 0xa8,
  26970. 0x51,
  26971. 0xa3,
  26972. 0x40,
  26973. 0x8f,
  26974. 0x92,
  26975. 0x9d,
  26976. 0x38,
  26977. 0xf5,
  26978. 0xbc,
  26979. 0xb6,
  26980. 0xda,
  26981. 0x21,
  26982. 0x10,
  26983. 0xff,
  26984. 0xf3,
  26985. 0xd2,
  26986. 0xcd,
  26987. 0x0c,
  26988. 0x13,
  26989. 0xec,
  26990. 0x5f,
  26991. 0x97,
  26992. 0x44,
  26993. 0x17,
  26994. 0xc4,
  26995. 0xa7,
  26996. 0x7e,
  26997. 0x3d,
  26998. 0x64,
  26999. 0x5d,
  27000. 0x19,
  27001. 0x73,
  27002. 0x60,
  27003. 0x81,
  27004. 0x4f,
  27005. 0xdc,
  27006. 0x22,
  27007. 0x2a,
  27008. 0x90,
  27009. 0x88,
  27010. 0x46,
  27011. 0xee,
  27012. 0xb8,
  27013. 0x14,
  27014. 0xde,
  27015. 0x5e,
  27016. 0x0b,
  27017. 0xdb,
  27018. 0xe0,
  27019. 0x32,
  27020. 0x3a,
  27021. 0x0a,
  27022. 0x49,
  27023. 0x06,
  27024. 0x24,
  27025. 0x5c,
  27026. 0xc2,
  27027. 0xd3,
  27028. 0xac,
  27029. 0x62,
  27030. 0x91,
  27031. 0x95,
  27032. 0xe4,
  27033. 0x79,
  27034. 0xe7,
  27035. 0xc8,
  27036. 0x37,
  27037. 0x6d,
  27038. 0x8d,
  27039. 0xd5,
  27040. 0x4e,
  27041. 0xa9,
  27042. 0x6c,
  27043. 0x56,
  27044. 0xf4,
  27045. 0xea,
  27046. 0x65,
  27047. 0x7a,
  27048. 0xae,
  27049. 0x08,
  27050. 0xba,
  27051. 0x78,
  27052. 0x25,
  27053. 0x2e,
  27054. 0x1c,
  27055. 0xa6,
  27056. 0xb4,
  27057. 0xc6,
  27058. 0xe8,
  27059. 0xdd,
  27060. 0x74,
  27061. 0x1f,
  27062. 0x4b,
  27063. 0xbd,
  27064. 0x8b,
  27065. 0x8a,
  27066. 0x70,
  27067. 0x3e,
  27068. 0xb5,
  27069. 0x66,
  27070. 0x48,
  27071. 0x03,
  27072. 0xf6,
  27073. 0x0e,
  27074. 0x61,
  27075. 0x35,
  27076. 0x57,
  27077. 0xb9,
  27078. 0x86,
  27079. 0xc1,
  27080. 0x1d,
  27081. 0x9e,
  27082. 0xe1,
  27083. 0xf8,
  27084. 0x98,
  27085. 0x11,
  27086. 0x69,
  27087. 0xd9,
  27088. 0x8e,
  27089. 0x94,
  27090. 0x9b,
  27091. 0x1e,
  27092. 0x87,
  27093. 0xe9,
  27094. 0xce,
  27095. 0x55,
  27096. 0x28,
  27097. 0xdf,
  27098. 0x8c,
  27099. 0xa1,
  27100. 0x89,
  27101. 0x0d,
  27102. 0xbf,
  27103. 0xe6,
  27104. 0x42,
  27105. 0x68,
  27106. 0x41,
  27107. 0x99,
  27108. 0x2d,
  27109. 0x0f,
  27110. 0xb0,
  27111. 0x54,
  27112. 0xbb,
  27113. 0x16
  27114. ]);
  27115. var inv_s = new Uint8Array([
  27116. 0x52,
  27117. 0x09,
  27118. 0x6a,
  27119. 0xd5,
  27120. 0x30,
  27121. 0x36,
  27122. 0xa5,
  27123. 0x38,
  27124. 0xbf,
  27125. 0x40,
  27126. 0xa3,
  27127. 0x9e,
  27128. 0x81,
  27129. 0xf3,
  27130. 0xd7,
  27131. 0xfb,
  27132. 0x7c,
  27133. 0xe3,
  27134. 0x39,
  27135. 0x82,
  27136. 0x9b,
  27137. 0x2f,
  27138. 0xff,
  27139. 0x87,
  27140. 0x34,
  27141. 0x8e,
  27142. 0x43,
  27143. 0x44,
  27144. 0xc4,
  27145. 0xde,
  27146. 0xe9,
  27147. 0xcb,
  27148. 0x54,
  27149. 0x7b,
  27150. 0x94,
  27151. 0x32,
  27152. 0xa6,
  27153. 0xc2,
  27154. 0x23,
  27155. 0x3d,
  27156. 0xee,
  27157. 0x4c,
  27158. 0x95,
  27159. 0x0b,
  27160. 0x42,
  27161. 0xfa,
  27162. 0xc3,
  27163. 0x4e,
  27164. 0x08,
  27165. 0x2e,
  27166. 0xa1,
  27167. 0x66,
  27168. 0x28,
  27169. 0xd9,
  27170. 0x24,
  27171. 0xb2,
  27172. 0x76,
  27173. 0x5b,
  27174. 0xa2,
  27175. 0x49,
  27176. 0x6d,
  27177. 0x8b,
  27178. 0xd1,
  27179. 0x25,
  27180. 0x72,
  27181. 0xf8,
  27182. 0xf6,
  27183. 0x64,
  27184. 0x86,
  27185. 0x68,
  27186. 0x98,
  27187. 0x16,
  27188. 0xd4,
  27189. 0xa4,
  27190. 0x5c,
  27191. 0xcc,
  27192. 0x5d,
  27193. 0x65,
  27194. 0xb6,
  27195. 0x92,
  27196. 0x6c,
  27197. 0x70,
  27198. 0x48,
  27199. 0x50,
  27200. 0xfd,
  27201. 0xed,
  27202. 0xb9,
  27203. 0xda,
  27204. 0x5e,
  27205. 0x15,
  27206. 0x46,
  27207. 0x57,
  27208. 0xa7,
  27209. 0x8d,
  27210. 0x9d,
  27211. 0x84,
  27212. 0x90,
  27213. 0xd8,
  27214. 0xab,
  27215. 0x00,
  27216. 0x8c,
  27217. 0xbc,
  27218. 0xd3,
  27219. 0x0a,
  27220. 0xf7,
  27221. 0xe4,
  27222. 0x58,
  27223. 0x05,
  27224. 0xb8,
  27225. 0xb3,
  27226. 0x45,
  27227. 0x06,
  27228. 0xd0,
  27229. 0x2c,
  27230. 0x1e,
  27231. 0x8f,
  27232. 0xca,
  27233. 0x3f,
  27234. 0x0f,
  27235. 0x02,
  27236. 0xc1,
  27237. 0xaf,
  27238. 0xbd,
  27239. 0x03,
  27240. 0x01,
  27241. 0x13,
  27242. 0x8a,
  27243. 0x6b,
  27244. 0x3a,
  27245. 0x91,
  27246. 0x11,
  27247. 0x41,
  27248. 0x4f,
  27249. 0x67,
  27250. 0xdc,
  27251. 0xea,
  27252. 0x97,
  27253. 0xf2,
  27254. 0xcf,
  27255. 0xce,
  27256. 0xf0,
  27257. 0xb4,
  27258. 0xe6,
  27259. 0x73,
  27260. 0x96,
  27261. 0xac,
  27262. 0x74,
  27263. 0x22,
  27264. 0xe7,
  27265. 0xad,
  27266. 0x35,
  27267. 0x85,
  27268. 0xe2,
  27269. 0xf9,
  27270. 0x37,
  27271. 0xe8,
  27272. 0x1c,
  27273. 0x75,
  27274. 0xdf,
  27275. 0x6e,
  27276. 0x47,
  27277. 0xf1,
  27278. 0x1a,
  27279. 0x71,
  27280. 0x1d,
  27281. 0x29,
  27282. 0xc5,
  27283. 0x89,
  27284. 0x6f,
  27285. 0xb7,
  27286. 0x62,
  27287. 0x0e,
  27288. 0xaa,
  27289. 0x18,
  27290. 0xbe,
  27291. 0x1b,
  27292. 0xfc,
  27293. 0x56,
  27294. 0x3e,
  27295. 0x4b,
  27296. 0xc6,
  27297. 0xd2,
  27298. 0x79,
  27299. 0x20,
  27300. 0x9a,
  27301. 0xdb,
  27302. 0xc0,
  27303. 0xfe,
  27304. 0x78,
  27305. 0xcd,
  27306. 0x5a,
  27307. 0xf4,
  27308. 0x1f,
  27309. 0xdd,
  27310. 0xa8,
  27311. 0x33,
  27312. 0x88,
  27313. 0x07,
  27314. 0xc7,
  27315. 0x31,
  27316. 0xb1,
  27317. 0x12,
  27318. 0x10,
  27319. 0x59,
  27320. 0x27,
  27321. 0x80,
  27322. 0xec,
  27323. 0x5f,
  27324. 0x60,
  27325. 0x51,
  27326. 0x7f,
  27327. 0xa9,
  27328. 0x19,
  27329. 0xb5,
  27330. 0x4a,
  27331. 0x0d,
  27332. 0x2d,
  27333. 0xe5,
  27334. 0x7a,
  27335. 0x9f,
  27336. 0x93,
  27337. 0xc9,
  27338. 0x9c,
  27339. 0xef,
  27340. 0xa0,
  27341. 0xe0,
  27342. 0x3b,
  27343. 0x4d,
  27344. 0xae,
  27345. 0x2a,
  27346. 0xf5,
  27347. 0xb0,
  27348. 0xc8,
  27349. 0xeb,
  27350. 0xbb,
  27351. 0x3c,
  27352. 0x83,
  27353. 0x53,
  27354. 0x99,
  27355. 0x61,
  27356. 0x17,
  27357. 0x2b,
  27358. 0x04,
  27359. 0x7e,
  27360. 0xba,
  27361. 0x77,
  27362. 0xd6,
  27363. 0x26,
  27364. 0xe1,
  27365. 0x69,
  27366. 0x14,
  27367. 0x63,
  27368. 0x55,
  27369. 0x21,
  27370. 0x0c,
  27371. 0x7d
  27372. ]);
  27373. var mixCol = new Uint8Array(256);
  27374. for (var i = 0; i < 256; i++) {
  27375. if (i < 128) {
  27376. mixCol[i] = i << 1;
  27377. } else {
  27378. mixCol[i] = i << 1 ^ 0x1b;
  27379. }
  27380. }
  27381. var mix = new Uint32Array([
  27382. 0x00000000,
  27383. 0x0e090d0b,
  27384. 0x1c121a16,
  27385. 0x121b171d,
  27386. 0x3824342c,
  27387. 0x362d3927,
  27388. 0x24362e3a,
  27389. 0x2a3f2331,
  27390. 0x70486858,
  27391. 0x7e416553,
  27392. 0x6c5a724e,
  27393. 0x62537f45,
  27394. 0x486c5c74,
  27395. 0x4665517f,
  27396. 0x547e4662,
  27397. 0x5a774b69,
  27398. 0xe090d0b0,
  27399. 0xee99ddbb,
  27400. 0xfc82caa6,
  27401. 0xf28bc7ad,
  27402. 0xd8b4e49c,
  27403. 0xd6bde997,
  27404. 0xc4a6fe8a,
  27405. 0xcaaff381,
  27406. 0x90d8b8e8,
  27407. 0x9ed1b5e3,
  27408. 0x8ccaa2fe,
  27409. 0x82c3aff5,
  27410. 0xa8fc8cc4,
  27411. 0xa6f581cf,
  27412. 0xb4ee96d2,
  27413. 0xbae79bd9,
  27414. 0xdb3bbb7b,
  27415. 0xd532b670,
  27416. 0xc729a16d,
  27417. 0xc920ac66,
  27418. 0xe31f8f57,
  27419. 0xed16825c,
  27420. 0xff0d9541,
  27421. 0xf104984a,
  27422. 0xab73d323,
  27423. 0xa57ade28,
  27424. 0xb761c935,
  27425. 0xb968c43e,
  27426. 0x9357e70f,
  27427. 0x9d5eea04,
  27428. 0x8f45fd19,
  27429. 0x814cf012,
  27430. 0x3bab6bcb,
  27431. 0x35a266c0,
  27432. 0x27b971dd,
  27433. 0x29b07cd6,
  27434. 0x038f5fe7,
  27435. 0x0d8652ec,
  27436. 0x1f9d45f1,
  27437. 0x119448fa,
  27438. 0x4be30393,
  27439. 0x45ea0e98,
  27440. 0x57f11985,
  27441. 0x59f8148e,
  27442. 0x73c737bf,
  27443. 0x7dce3ab4,
  27444. 0x6fd52da9,
  27445. 0x61dc20a2,
  27446. 0xad766df6,
  27447. 0xa37f60fd,
  27448. 0xb16477e0,
  27449. 0xbf6d7aeb,
  27450. 0x955259da,
  27451. 0x9b5b54d1,
  27452. 0x894043cc,
  27453. 0x87494ec7,
  27454. 0xdd3e05ae,
  27455. 0xd33708a5,
  27456. 0xc12c1fb8,
  27457. 0xcf2512b3,
  27458. 0xe51a3182,
  27459. 0xeb133c89,
  27460. 0xf9082b94,
  27461. 0xf701269f,
  27462. 0x4de6bd46,
  27463. 0x43efb04d,
  27464. 0x51f4a750,
  27465. 0x5ffdaa5b,
  27466. 0x75c2896a,
  27467. 0x7bcb8461,
  27468. 0x69d0937c,
  27469. 0x67d99e77,
  27470. 0x3daed51e,
  27471. 0x33a7d815,
  27472. 0x21bccf08,
  27473. 0x2fb5c203,
  27474. 0x058ae132,
  27475. 0x0b83ec39,
  27476. 0x1998fb24,
  27477. 0x1791f62f,
  27478. 0x764dd68d,
  27479. 0x7844db86,
  27480. 0x6a5fcc9b,
  27481. 0x6456c190,
  27482. 0x4e69e2a1,
  27483. 0x4060efaa,
  27484. 0x527bf8b7,
  27485. 0x5c72f5bc,
  27486. 0x0605bed5,
  27487. 0x080cb3de,
  27488. 0x1a17a4c3,
  27489. 0x141ea9c8,
  27490. 0x3e218af9,
  27491. 0x302887f2,
  27492. 0x223390ef,
  27493. 0x2c3a9de4,
  27494. 0x96dd063d,
  27495. 0x98d40b36,
  27496. 0x8acf1c2b,
  27497. 0x84c61120,
  27498. 0xaef93211,
  27499. 0xa0f03f1a,
  27500. 0xb2eb2807,
  27501. 0xbce2250c,
  27502. 0xe6956e65,
  27503. 0xe89c636e,
  27504. 0xfa877473,
  27505. 0xf48e7978,
  27506. 0xdeb15a49,
  27507. 0xd0b85742,
  27508. 0xc2a3405f,
  27509. 0xccaa4d54,
  27510. 0x41ecdaf7,
  27511. 0x4fe5d7fc,
  27512. 0x5dfec0e1,
  27513. 0x53f7cdea,
  27514. 0x79c8eedb,
  27515. 0x77c1e3d0,
  27516. 0x65daf4cd,
  27517. 0x6bd3f9c6,
  27518. 0x31a4b2af,
  27519. 0x3fadbfa4,
  27520. 0x2db6a8b9,
  27521. 0x23bfa5b2,
  27522. 0x09808683,
  27523. 0x07898b88,
  27524. 0x15929c95,
  27525. 0x1b9b919e,
  27526. 0xa17c0a47,
  27527. 0xaf75074c,
  27528. 0xbd6e1051,
  27529. 0xb3671d5a,
  27530. 0x99583e6b,
  27531. 0x97513360,
  27532. 0x854a247d,
  27533. 0x8b432976,
  27534. 0xd134621f,
  27535. 0xdf3d6f14,
  27536. 0xcd267809,
  27537. 0xc32f7502,
  27538. 0xe9105633,
  27539. 0xe7195b38,
  27540. 0xf5024c25,
  27541. 0xfb0b412e,
  27542. 0x9ad7618c,
  27543. 0x94de6c87,
  27544. 0x86c57b9a,
  27545. 0x88cc7691,
  27546. 0xa2f355a0,
  27547. 0xacfa58ab,
  27548. 0xbee14fb6,
  27549. 0xb0e842bd,
  27550. 0xea9f09d4,
  27551. 0xe49604df,
  27552. 0xf68d13c2,
  27553. 0xf8841ec9,
  27554. 0xd2bb3df8,
  27555. 0xdcb230f3,
  27556. 0xcea927ee,
  27557. 0xc0a02ae5,
  27558. 0x7a47b13c,
  27559. 0x744ebc37,
  27560. 0x6655ab2a,
  27561. 0x685ca621,
  27562. 0x42638510,
  27563. 0x4c6a881b,
  27564. 0x5e719f06,
  27565. 0x5078920d,
  27566. 0x0a0fd964,
  27567. 0x0406d46f,
  27568. 0x161dc372,
  27569. 0x1814ce79,
  27570. 0x322bed48,
  27571. 0x3c22e043,
  27572. 0x2e39f75e,
  27573. 0x2030fa55,
  27574. 0xec9ab701,
  27575. 0xe293ba0a,
  27576. 0xf088ad17,
  27577. 0xfe81a01c,
  27578. 0xd4be832d,
  27579. 0xdab78e26,
  27580. 0xc8ac993b,
  27581. 0xc6a59430,
  27582. 0x9cd2df59,
  27583. 0x92dbd252,
  27584. 0x80c0c54f,
  27585. 0x8ec9c844,
  27586. 0xa4f6eb75,
  27587. 0xaaffe67e,
  27588. 0xb8e4f163,
  27589. 0xb6edfc68,
  27590. 0x0c0a67b1,
  27591. 0x02036aba,
  27592. 0x10187da7,
  27593. 0x1e1170ac,
  27594. 0x342e539d,
  27595. 0x3a275e96,
  27596. 0x283c498b,
  27597. 0x26354480,
  27598. 0x7c420fe9,
  27599. 0x724b02e2,
  27600. 0x605015ff,
  27601. 0x6e5918f4,
  27602. 0x44663bc5,
  27603. 0x4a6f36ce,
  27604. 0x587421d3,
  27605. 0x567d2cd8,
  27606. 0x37a10c7a,
  27607. 0x39a80171,
  27608. 0x2bb3166c,
  27609. 0x25ba1b67,
  27610. 0x0f853856,
  27611. 0x018c355d,
  27612. 0x13972240,
  27613. 0x1d9e2f4b,
  27614. 0x47e96422,
  27615. 0x49e06929,
  27616. 0x5bfb7e34,
  27617. 0x55f2733f,
  27618. 0x7fcd500e,
  27619. 0x71c45d05,
  27620. 0x63df4a18,
  27621. 0x6dd64713,
  27622. 0xd731dcca,
  27623. 0xd938d1c1,
  27624. 0xcb23c6dc,
  27625. 0xc52acbd7,
  27626. 0xef15e8e6,
  27627. 0xe11ce5ed,
  27628. 0xf307f2f0,
  27629. 0xfd0efffb,
  27630. 0xa779b492,
  27631. 0xa970b999,
  27632. 0xbb6bae84,
  27633. 0xb562a38f,
  27634. 0x9f5d80be,
  27635. 0x91548db5,
  27636. 0x834f9aa8,
  27637. 0x8d4697a3
  27638. ]);
  27639. function expandKey256(cipherKey) {
  27640. var b = 240, result = new Uint8Array(b);
  27641. var r = 1;
  27642. result.set(cipherKey);
  27643. for (var j = 32, i = 1; j < b; ++i) {
  27644. if (j % 32 === 16) {
  27645. t1 = s[t1];
  27646. t2 = s[t2];
  27647. t3 = s[t3];
  27648. t4 = s[t4];
  27649. } else if (j % 32 === 0) {
  27650. var t1 = result[j - 3], t2 = result[j - 2], t3 = result[j - 1], t4 = result[j - 4];
  27651. t1 = s[t1];
  27652. t2 = s[t2];
  27653. t3 = s[t3];
  27654. t4 = s[t4];
  27655. t1 = t1 ^ r;
  27656. if ((r <<= 1) >= 256) {
  27657. r = (r ^ 0x1b) & 0xFF;
  27658. }
  27659. }
  27660. for (var n = 0; n < 4; ++n) {
  27661. result[j] = t1 ^= result[j - 32];
  27662. j++;
  27663. result[j] = t2 ^= result[j - 32];
  27664. j++;
  27665. result[j] = t3 ^= result[j - 32];
  27666. j++;
  27667. result[j] = t4 ^= result[j - 32];
  27668. j++;
  27669. }
  27670. }
  27671. return result;
  27672. }
  27673. function decrypt256(input, key) {
  27674. var state = new Uint8Array(16);
  27675. state.set(input);
  27676. var i, j, k;
  27677. var t, u, v;
  27678. for (j = 0, k = 224; j < 16; ++j, ++k) {
  27679. state[j] ^= key[k];
  27680. }
  27681. for (i = 13; i >= 1; --i) {
  27682. t = state[13];
  27683. state[13] = state[9];
  27684. state[9] = state[5];
  27685. state[5] = state[1];
  27686. state[1] = t;
  27687. t = state[14];
  27688. u = state[10];
  27689. state[14] = state[6];
  27690. state[10] = state[2];
  27691. state[6] = t;
  27692. state[2] = u;
  27693. t = state[15];
  27694. u = state[11];
  27695. v = state[7];
  27696. state[15] = state[3];
  27697. state[11] = t;
  27698. state[7] = u;
  27699. state[3] = v;
  27700. for (j = 0; j < 16; ++j) {
  27701. state[j] = inv_s[state[j]];
  27702. }
  27703. for (j = 0, k = i * 16; j < 16; ++j, ++k) {
  27704. state[j] ^= key[k];
  27705. }
  27706. for (j = 0; j < 16; j += 4) {
  27707. var s0 = mix[state[j]], s1 = mix[state[j + 1]], s2 = mix[state[j + 2]], s3 = mix[state[j + 3]];
  27708. t = s0 ^ s1 >>> 8 ^ s1 << 24 ^ s2 >>> 16 ^ s2 << 16 ^ s3 >>> 24 ^ s3 << 8;
  27709. state[j] = t >>> 24 & 0xFF;
  27710. state[j + 1] = t >> 16 & 0xFF;
  27711. state[j + 2] = t >> 8 & 0xFF;
  27712. state[j + 3] = t & 0xFF;
  27713. }
  27714. }
  27715. t = state[13];
  27716. state[13] = state[9];
  27717. state[9] = state[5];
  27718. state[5] = state[1];
  27719. state[1] = t;
  27720. t = state[14];
  27721. u = state[10];
  27722. state[14] = state[6];
  27723. state[10] = state[2];
  27724. state[6] = t;
  27725. state[2] = u;
  27726. t = state[15];
  27727. u = state[11];
  27728. v = state[7];
  27729. state[15] = state[3];
  27730. state[11] = t;
  27731. state[7] = u;
  27732. state[3] = v;
  27733. for (j = 0; j < 16; ++j) {
  27734. state[j] = inv_s[state[j]];
  27735. state[j] ^= key[j];
  27736. }
  27737. return state;
  27738. }
  27739. function encrypt256(input, key) {
  27740. var t, u, v, k;
  27741. var state = new Uint8Array(16);
  27742. state.set(input);
  27743. for (j = 0; j < 16; ++j) {
  27744. state[j] ^= key[j];
  27745. }
  27746. for (i = 1; i < 14; i++) {
  27747. for (j = 0; j < 16; ++j) {
  27748. state[j] = s[state[j]];
  27749. }
  27750. v = state[1];
  27751. state[1] = state[5];
  27752. state[5] = state[9];
  27753. state[9] = state[13];
  27754. state[13] = v;
  27755. v = state[2];
  27756. u = state[6];
  27757. state[2] = state[10];
  27758. state[6] = state[14];
  27759. state[10] = v;
  27760. state[14] = u;
  27761. v = state[3];
  27762. u = state[7];
  27763. t = state[11];
  27764. state[3] = state[15];
  27765. state[7] = v;
  27766. state[11] = u;
  27767. state[15] = t;
  27768. for (var j = 0; j < 16; j += 4) {
  27769. var s0 = state[j + 0], s1 = state[j + 1];
  27770. var s2 = state[j + 2], s3 = state[j + 3];
  27771. t = s0 ^ s1 ^ s2 ^ s3;
  27772. state[j + 0] ^= t ^ mixCol[s0 ^ s1];
  27773. state[j + 1] ^= t ^ mixCol[s1 ^ s2];
  27774. state[j + 2] ^= t ^ mixCol[s2 ^ s3];
  27775. state[j + 3] ^= t ^ mixCol[s3 ^ s0];
  27776. }
  27777. for (j = 0, k = i * 16; j < 16; ++j, ++k) {
  27778. state[j] ^= key[k];
  27779. }
  27780. }
  27781. for (j = 0; j < 16; ++j) {
  27782. state[j] = s[state[j]];
  27783. }
  27784. v = state[1];
  27785. state[1] = state[5];
  27786. state[5] = state[9];
  27787. state[9] = state[13];
  27788. state[13] = v;
  27789. v = state[2];
  27790. u = state[6];
  27791. state[2] = state[10];
  27792. state[6] = state[14];
  27793. state[10] = v;
  27794. state[14] = u;
  27795. v = state[3];
  27796. u = state[7];
  27797. t = state[11];
  27798. state[3] = state[15];
  27799. state[7] = v;
  27800. state[11] = u;
  27801. state[15] = t;
  27802. for (j = 0, k = 224; j < 16; ++j, ++k) {
  27803. state[j] ^= key[k];
  27804. }
  27805. return state;
  27806. }
  27807. function AES256Cipher(key) {
  27808. this.key = expandKey256(key);
  27809. this.buffer = new Uint8Array(16);
  27810. this.bufferPosition = 0;
  27811. }
  27812. function decryptBlock2(data, finalize) {
  27813. var i, j, ii, sourceLength = data.length, buffer = this.buffer, bufferLength = this.bufferPosition, result = [], iv = this.iv;
  27814. for (i = 0; i < sourceLength; ++i) {
  27815. buffer[bufferLength] = data[i];
  27816. ++bufferLength;
  27817. if (bufferLength < 16) {
  27818. continue;
  27819. }
  27820. var plain = decrypt256(buffer, this.key);
  27821. for (j = 0; j < 16; ++j) {
  27822. plain[j] ^= iv[j];
  27823. }
  27824. iv = buffer;
  27825. result.push(plain);
  27826. buffer = new Uint8Array(16);
  27827. bufferLength = 0;
  27828. }
  27829. this.buffer = buffer;
  27830. this.bufferLength = bufferLength;
  27831. this.iv = iv;
  27832. if (result.length === 0) {
  27833. return new Uint8Array([]);
  27834. }
  27835. var outputLength = 16 * result.length;
  27836. if (finalize) {
  27837. var lastBlock = result[result.length - 1];
  27838. var psLen = lastBlock[15];
  27839. if (psLen <= 16) {
  27840. for (i = 15, ii = 16 - psLen; i >= ii; --i) {
  27841. if (lastBlock[i] !== psLen) {
  27842. psLen = 0;
  27843. break;
  27844. }
  27845. }
  27846. outputLength -= psLen;
  27847. result[result.length - 1] = lastBlock.subarray(0, 16 - psLen);
  27848. }
  27849. }
  27850. var output = new Uint8Array(outputLength);
  27851. for (i = 0, j = 0, ii = result.length; i < ii; ++i, j += 16) {
  27852. output.set(result[i], j);
  27853. }
  27854. return output;
  27855. }
  27856. AES256Cipher.prototype = {
  27857. decryptBlock: function AES256Cipher_decryptBlock(data, finalize, iv) {
  27858. var i, sourceLength = data.length;
  27859. var buffer = this.buffer, bufferLength = this.bufferPosition;
  27860. if (iv) {
  27861. this.iv = iv;
  27862. } else {
  27863. for (i = 0; bufferLength < 16 && i < sourceLength; ++i, ++bufferLength) {
  27864. buffer[bufferLength] = data[i];
  27865. }
  27866. if (bufferLength < 16) {
  27867. this.bufferLength = bufferLength;
  27868. return new Uint8Array([]);
  27869. }
  27870. this.iv = buffer;
  27871. data = data.subarray(16);
  27872. }
  27873. this.buffer = new Uint8Array(16);
  27874. this.bufferLength = 0;
  27875. this.decryptBlock = decryptBlock2;
  27876. return this.decryptBlock(data, finalize);
  27877. },
  27878. encrypt: function AES256Cipher_encrypt(data, iv) {
  27879. var i, j, ii, sourceLength = data.length, buffer = this.buffer, bufferLength = this.bufferPosition, result = [];
  27880. if (!iv) {
  27881. iv = new Uint8Array(16);
  27882. }
  27883. for (i = 0; i < sourceLength; ++i) {
  27884. buffer[bufferLength] = data[i];
  27885. ++bufferLength;
  27886. if (bufferLength < 16) {
  27887. continue;
  27888. }
  27889. for (j = 0; j < 16; ++j) {
  27890. buffer[j] ^= iv[j];
  27891. }
  27892. var cipher = encrypt256(buffer, this.key);
  27893. this.iv = cipher;
  27894. result.push(cipher);
  27895. buffer = new Uint8Array(16);
  27896. bufferLength = 0;
  27897. }
  27898. this.buffer = buffer;
  27899. this.bufferLength = bufferLength;
  27900. this.iv = iv;
  27901. if (result.length === 0) {
  27902. return new Uint8Array([]);
  27903. }
  27904. var outputLength = 16 * result.length;
  27905. var output = new Uint8Array(outputLength);
  27906. for (i = 0, j = 0, ii = result.length; i < ii; ++i, j += 16) {
  27907. output.set(result[i], j);
  27908. }
  27909. return output;
  27910. }
  27911. };
  27912. return AES256Cipher;
  27913. }();
  27914. var PDF17 = function PDF17Closure() {
  27915. function compareByteArrays(array1, array2) {
  27916. if (array1.length !== array2.length) {
  27917. return false;
  27918. }
  27919. for (var i = 0; i < array1.length; i++) {
  27920. if (array1[i] !== array2[i]) {
  27921. return false;
  27922. }
  27923. }
  27924. return true;
  27925. }
  27926. function PDF17() {
  27927. }
  27928. PDF17.prototype = {
  27929. checkOwnerPassword: function PDF17_checkOwnerPassword(password, ownerValidationSalt, userBytes, ownerPassword) {
  27930. var hashData = new Uint8Array(password.length + 56);
  27931. hashData.set(password, 0);
  27932. hashData.set(ownerValidationSalt, password.length);
  27933. hashData.set(userBytes, password.length + ownerValidationSalt.length);
  27934. var result = calculateSHA256(hashData, 0, hashData.length);
  27935. return compareByteArrays(result, ownerPassword);
  27936. },
  27937. checkUserPassword: function PDF17_checkUserPassword(password, userValidationSalt, userPassword) {
  27938. var hashData = new Uint8Array(password.length + 8);
  27939. hashData.set(password, 0);
  27940. hashData.set(userValidationSalt, password.length);
  27941. var result = calculateSHA256(hashData, 0, hashData.length);
  27942. return compareByteArrays(result, userPassword);
  27943. },
  27944. getOwnerKey: function PDF17_getOwnerKey(password, ownerKeySalt, userBytes, ownerEncryption) {
  27945. var hashData = new Uint8Array(password.length + 56);
  27946. hashData.set(password, 0);
  27947. hashData.set(ownerKeySalt, password.length);
  27948. hashData.set(userBytes, password.length + ownerKeySalt.length);
  27949. var key = calculateSHA256(hashData, 0, hashData.length);
  27950. var cipher = new AES256Cipher(key);
  27951. return cipher.decryptBlock(ownerEncryption, false, new Uint8Array(16));
  27952. },
  27953. getUserKey: function PDF17_getUserKey(password, userKeySalt, userEncryption) {
  27954. var hashData = new Uint8Array(password.length + 8);
  27955. hashData.set(password, 0);
  27956. hashData.set(userKeySalt, password.length);
  27957. var key = calculateSHA256(hashData, 0, hashData.length);
  27958. var cipher = new AES256Cipher(key);
  27959. return cipher.decryptBlock(userEncryption, false, new Uint8Array(16));
  27960. }
  27961. };
  27962. return PDF17;
  27963. }();
  27964. var PDF20 = function PDF20Closure() {
  27965. function concatArrays(array1, array2) {
  27966. var t = new Uint8Array(array1.length + array2.length);
  27967. t.set(array1, 0);
  27968. t.set(array2, array1.length);
  27969. return t;
  27970. }
  27971. function calculatePDF20Hash(password, input, userBytes) {
  27972. var k = calculateSHA256(input, 0, input.length).subarray(0, 32);
  27973. var e = [0];
  27974. var i = 0;
  27975. while (i < 64 || e[e.length - 1] > i - 32) {
  27976. var arrayLength = password.length + k.length + userBytes.length;
  27977. var k1 = new Uint8Array(arrayLength * 64);
  27978. var array = concatArrays(password, k);
  27979. array = concatArrays(array, userBytes);
  27980. for (var j = 0, pos = 0; j < 64; j++, pos += arrayLength) {
  27981. k1.set(array, pos);
  27982. }
  27983. var cipher = new AES128Cipher(k.subarray(0, 16));
  27984. e = cipher.encrypt(k1, k.subarray(16, 32));
  27985. var remainder = 0;
  27986. for (var z = 0; z < 16; z++) {
  27987. remainder *= 256 % 3;
  27988. remainder %= 3;
  27989. remainder += (e[z] >>> 0) % 3;
  27990. remainder %= 3;
  27991. }
  27992. if (remainder === 0) {
  27993. k = calculateSHA256(e, 0, e.length);
  27994. } else if (remainder === 1) {
  27995. k = calculateSHA384(e, 0, e.length);
  27996. } else if (remainder === 2) {
  27997. k = calculateSHA512(e, 0, e.length);
  27998. }
  27999. i++;
  28000. }
  28001. return k.subarray(0, 32);
  28002. }
  28003. function PDF20() {
  28004. }
  28005. function compareByteArrays(array1, array2) {
  28006. if (array1.length !== array2.length) {
  28007. return false;
  28008. }
  28009. for (var i = 0; i < array1.length; i++) {
  28010. if (array1[i] !== array2[i]) {
  28011. return false;
  28012. }
  28013. }
  28014. return true;
  28015. }
  28016. PDF20.prototype = {
  28017. hash: function PDF20_hash(password, concatBytes, userBytes) {
  28018. return calculatePDF20Hash(password, concatBytes, userBytes);
  28019. },
  28020. checkOwnerPassword: function PDF20_checkOwnerPassword(password, ownerValidationSalt, userBytes, ownerPassword) {
  28021. var hashData = new Uint8Array(password.length + 56);
  28022. hashData.set(password, 0);
  28023. hashData.set(ownerValidationSalt, password.length);
  28024. hashData.set(userBytes, password.length + ownerValidationSalt.length);
  28025. var result = calculatePDF20Hash(password, hashData, userBytes);
  28026. return compareByteArrays(result, ownerPassword);
  28027. },
  28028. checkUserPassword: function PDF20_checkUserPassword(password, userValidationSalt, userPassword) {
  28029. var hashData = new Uint8Array(password.length + 8);
  28030. hashData.set(password, 0);
  28031. hashData.set(userValidationSalt, password.length);
  28032. var result = calculatePDF20Hash(password, hashData, []);
  28033. return compareByteArrays(result, userPassword);
  28034. },
  28035. getOwnerKey: function PDF20_getOwnerKey(password, ownerKeySalt, userBytes, ownerEncryption) {
  28036. var hashData = new Uint8Array(password.length + 56);
  28037. hashData.set(password, 0);
  28038. hashData.set(ownerKeySalt, password.length);
  28039. hashData.set(userBytes, password.length + ownerKeySalt.length);
  28040. var key = calculatePDF20Hash(password, hashData, userBytes);
  28041. var cipher = new AES256Cipher(key);
  28042. return cipher.decryptBlock(ownerEncryption, false, new Uint8Array(16));
  28043. },
  28044. getUserKey: function PDF20_getUserKey(password, userKeySalt, userEncryption) {
  28045. var hashData = new Uint8Array(password.length + 8);
  28046. hashData.set(password, 0);
  28047. hashData.set(userKeySalt, password.length);
  28048. var key = calculatePDF20Hash(password, hashData, []);
  28049. var cipher = new AES256Cipher(key);
  28050. return cipher.decryptBlock(userEncryption, false, new Uint8Array(16));
  28051. }
  28052. };
  28053. return PDF20;
  28054. }();
  28055. var CipherTransform = function CipherTransformClosure() {
  28056. function CipherTransform(stringCipherConstructor, streamCipherConstructor) {
  28057. this.StringCipherConstructor = stringCipherConstructor;
  28058. this.StreamCipherConstructor = streamCipherConstructor;
  28059. }
  28060. CipherTransform.prototype = {
  28061. createStream: function CipherTransform_createStream(stream, length) {
  28062. var cipher = new this.StreamCipherConstructor();
  28063. return new DecryptStream(stream, length, function cipherTransformDecryptStream(data, finalize) {
  28064. return cipher.decryptBlock(data, finalize);
  28065. });
  28066. },
  28067. decryptString: function CipherTransform_decryptString(s) {
  28068. var cipher = new this.StringCipherConstructor();
  28069. var data = stringToBytes(s);
  28070. data = cipher.decryptBlock(data, true);
  28071. return bytesToString(data);
  28072. }
  28073. };
  28074. return CipherTransform;
  28075. }();
  28076. var CipherTransformFactory = function CipherTransformFactoryClosure() {
  28077. var defaultPasswordBytes = new Uint8Array([
  28078. 0x28,
  28079. 0xBF,
  28080. 0x4E,
  28081. 0x5E,
  28082. 0x4E,
  28083. 0x75,
  28084. 0x8A,
  28085. 0x41,
  28086. 0x64,
  28087. 0x00,
  28088. 0x4E,
  28089. 0x56,
  28090. 0xFF,
  28091. 0xFA,
  28092. 0x01,
  28093. 0x08,
  28094. 0x2E,
  28095. 0x2E,
  28096. 0x00,
  28097. 0xB6,
  28098. 0xD0,
  28099. 0x68,
  28100. 0x3E,
  28101. 0x80,
  28102. 0x2F,
  28103. 0x0C,
  28104. 0xA9,
  28105. 0xFE,
  28106. 0x64,
  28107. 0x53,
  28108. 0x69,
  28109. 0x7A
  28110. ]);
  28111. function createEncryptionKey20(revision, password, ownerPassword, ownerValidationSalt, ownerKeySalt, uBytes, userPassword, userValidationSalt, userKeySalt, ownerEncryption, userEncryption, perms) {
  28112. if (password) {
  28113. var passwordLength = Math.min(127, password.length);
  28114. password = password.subarray(0, passwordLength);
  28115. } else {
  28116. password = [];
  28117. }
  28118. var pdfAlgorithm;
  28119. if (revision === 6) {
  28120. pdfAlgorithm = new PDF20();
  28121. } else {
  28122. pdfAlgorithm = new PDF17();
  28123. }
  28124. if (pdfAlgorithm.checkUserPassword(password, userValidationSalt, userPassword)) {
  28125. return pdfAlgorithm.getUserKey(password, userKeySalt, userEncryption);
  28126. } else if (password.length && pdfAlgorithm.checkOwnerPassword(password, ownerValidationSalt, uBytes, ownerPassword)) {
  28127. return pdfAlgorithm.getOwnerKey(password, ownerKeySalt, uBytes, ownerEncryption);
  28128. }
  28129. return null;
  28130. }
  28131. function prepareKeyData(fileId, password, ownerPassword, userPassword, flags, revision, keyLength, encryptMetadata) {
  28132. var hashDataSize = 40 + ownerPassword.length + fileId.length;
  28133. var hashData = new Uint8Array(hashDataSize), i = 0, j, n;
  28134. if (password) {
  28135. n = Math.min(32, password.length);
  28136. for (; i < n; ++i) {
  28137. hashData[i] = password[i];
  28138. }
  28139. }
  28140. j = 0;
  28141. while (i < 32) {
  28142. hashData[i++] = defaultPasswordBytes[j++];
  28143. }
  28144. for (j = 0, n = ownerPassword.length; j < n; ++j) {
  28145. hashData[i++] = ownerPassword[j];
  28146. }
  28147. hashData[i++] = flags & 0xFF;
  28148. hashData[i++] = flags >> 8 & 0xFF;
  28149. hashData[i++] = flags >> 16 & 0xFF;
  28150. hashData[i++] = flags >>> 24 & 0xFF;
  28151. for (j = 0, n = fileId.length; j < n; ++j) {
  28152. hashData[i++] = fileId[j];
  28153. }
  28154. if (revision >= 4 && !encryptMetadata) {
  28155. hashData[i++] = 0xFF;
  28156. hashData[i++] = 0xFF;
  28157. hashData[i++] = 0xFF;
  28158. hashData[i++] = 0xFF;
  28159. }
  28160. var hash = calculateMD5(hashData, 0, i);
  28161. var keyLengthInBytes = keyLength >> 3;
  28162. if (revision >= 3) {
  28163. for (j = 0; j < 50; ++j) {
  28164. hash = calculateMD5(hash, 0, keyLengthInBytes);
  28165. }
  28166. }
  28167. var encryptionKey = hash.subarray(0, keyLengthInBytes);
  28168. var cipher, checkData;
  28169. if (revision >= 3) {
  28170. for (i = 0; i < 32; ++i) {
  28171. hashData[i] = defaultPasswordBytes[i];
  28172. }
  28173. for (j = 0, n = fileId.length; j < n; ++j) {
  28174. hashData[i++] = fileId[j];
  28175. }
  28176. cipher = new ARCFourCipher(encryptionKey);
  28177. checkData = cipher.encryptBlock(calculateMD5(hashData, 0, i));
  28178. n = encryptionKey.length;
  28179. var derivedKey = new Uint8Array(n), k;
  28180. for (j = 1; j <= 19; ++j) {
  28181. for (k = 0; k < n; ++k) {
  28182. derivedKey[k] = encryptionKey[k] ^ j;
  28183. }
  28184. cipher = new ARCFourCipher(derivedKey);
  28185. checkData = cipher.encryptBlock(checkData);
  28186. }
  28187. for (j = 0, n = checkData.length; j < n; ++j) {
  28188. if (userPassword[j] !== checkData[j]) {
  28189. return null;
  28190. }
  28191. }
  28192. } else {
  28193. cipher = new ARCFourCipher(encryptionKey);
  28194. checkData = cipher.encryptBlock(defaultPasswordBytes);
  28195. for (j = 0, n = checkData.length; j < n; ++j) {
  28196. if (userPassword[j] !== checkData[j]) {
  28197. return null;
  28198. }
  28199. }
  28200. }
  28201. return encryptionKey;
  28202. }
  28203. function decodeUserPassword(password, ownerPassword, revision, keyLength) {
  28204. var hashData = new Uint8Array(32), i = 0, j, n;
  28205. n = Math.min(32, password.length);
  28206. for (; i < n; ++i) {
  28207. hashData[i] = password[i];
  28208. }
  28209. j = 0;
  28210. while (i < 32) {
  28211. hashData[i++] = defaultPasswordBytes[j++];
  28212. }
  28213. var hash = calculateMD5(hashData, 0, i);
  28214. var keyLengthInBytes = keyLength >> 3;
  28215. if (revision >= 3) {
  28216. for (j = 0; j < 50; ++j) {
  28217. hash = calculateMD5(hash, 0, hash.length);
  28218. }
  28219. }
  28220. var cipher, userPassword;
  28221. if (revision >= 3) {
  28222. userPassword = ownerPassword;
  28223. var derivedKey = new Uint8Array(keyLengthInBytes), k;
  28224. for (j = 19; j >= 0; j--) {
  28225. for (k = 0; k < keyLengthInBytes; ++k) {
  28226. derivedKey[k] = hash[k] ^ j;
  28227. }
  28228. cipher = new ARCFourCipher(derivedKey);
  28229. userPassword = cipher.encryptBlock(userPassword);
  28230. }
  28231. } else {
  28232. cipher = new ARCFourCipher(hash.subarray(0, keyLengthInBytes));
  28233. userPassword = cipher.encryptBlock(ownerPassword);
  28234. }
  28235. return userPassword;
  28236. }
  28237. var identityName = Name.get('Identity');
  28238. function CipherTransformFactory(dict, fileId, password) {
  28239. var filter = dict.get('Filter');
  28240. if (!isName(filter, 'Standard')) {
  28241. error('unknown encryption method');
  28242. }
  28243. this.dict = dict;
  28244. var algorithm = dict.get('V');
  28245. if (!isInt(algorithm) || algorithm !== 1 && algorithm !== 2 && algorithm !== 4 && algorithm !== 5) {
  28246. error('unsupported encryption algorithm');
  28247. }
  28248. this.algorithm = algorithm;
  28249. var keyLength = dict.get('Length');
  28250. if (!keyLength) {
  28251. if (algorithm <= 3) {
  28252. keyLength = 40;
  28253. } else {
  28254. var cfDict = dict.get('CF');
  28255. var streamCryptoName = dict.get('StmF');
  28256. if (isDict(cfDict) && isName(streamCryptoName)) {
  28257. cfDict.suppressEncryption = true;
  28258. var handlerDict = cfDict.get(streamCryptoName.name);
  28259. keyLength = handlerDict && handlerDict.get('Length') || 128;
  28260. if (keyLength < 40) {
  28261. keyLength <<= 3;
  28262. }
  28263. }
  28264. }
  28265. }
  28266. if (!isInt(keyLength) || keyLength < 40 || keyLength % 8 !== 0) {
  28267. error('invalid key length');
  28268. }
  28269. var ownerPassword = stringToBytes(dict.get('O')).subarray(0, 32);
  28270. var userPassword = stringToBytes(dict.get('U')).subarray(0, 32);
  28271. var flags = dict.get('P');
  28272. var revision = dict.get('R');
  28273. var encryptMetadata = (algorithm === 4 || algorithm === 5) && dict.get('EncryptMetadata') !== false;
  28274. this.encryptMetadata = encryptMetadata;
  28275. var fileIdBytes = stringToBytes(fileId);
  28276. var passwordBytes;
  28277. if (password) {
  28278. if (revision === 6) {
  28279. try {
  28280. password = utf8StringToString(password);
  28281. } catch (ex) {
  28282. warn('CipherTransformFactory: ' + 'Unable to convert UTF8 encoded password.');
  28283. }
  28284. }
  28285. passwordBytes = stringToBytes(password);
  28286. }
  28287. var encryptionKey;
  28288. if (algorithm !== 5) {
  28289. encryptionKey = prepareKeyData(fileIdBytes, passwordBytes, ownerPassword, userPassword, flags, revision, keyLength, encryptMetadata);
  28290. } else {
  28291. var ownerValidationSalt = stringToBytes(dict.get('O')).subarray(32, 40);
  28292. var ownerKeySalt = stringToBytes(dict.get('O')).subarray(40, 48);
  28293. var uBytes = stringToBytes(dict.get('U')).subarray(0, 48);
  28294. var userValidationSalt = stringToBytes(dict.get('U')).subarray(32, 40);
  28295. var userKeySalt = stringToBytes(dict.get('U')).subarray(40, 48);
  28296. var ownerEncryption = stringToBytes(dict.get('OE'));
  28297. var userEncryption = stringToBytes(dict.get('UE'));
  28298. var perms = stringToBytes(dict.get('Perms'));
  28299. encryptionKey = createEncryptionKey20(revision, passwordBytes, ownerPassword, ownerValidationSalt, ownerKeySalt, uBytes, userPassword, userValidationSalt, userKeySalt, ownerEncryption, userEncryption, perms);
  28300. }
  28301. if (!encryptionKey && !password) {
  28302. throw new PasswordException('No password given', PasswordResponses.NEED_PASSWORD);
  28303. } else if (!encryptionKey && password) {
  28304. var decodedPassword = decodeUserPassword(passwordBytes, ownerPassword, revision, keyLength);
  28305. encryptionKey = prepareKeyData(fileIdBytes, decodedPassword, ownerPassword, userPassword, flags, revision, keyLength, encryptMetadata);
  28306. }
  28307. if (!encryptionKey) {
  28308. throw new PasswordException('Incorrect Password', PasswordResponses.INCORRECT_PASSWORD);
  28309. }
  28310. this.encryptionKey = encryptionKey;
  28311. if (algorithm >= 4) {
  28312. var cf = dict.get('CF');
  28313. if (isDict(cf)) {
  28314. cf.suppressEncryption = true;
  28315. }
  28316. this.cf = cf;
  28317. this.stmf = dict.get('StmF') || identityName;
  28318. this.strf = dict.get('StrF') || identityName;
  28319. this.eff = dict.get('EFF') || this.stmf;
  28320. }
  28321. }
  28322. function buildObjectKey(num, gen, encryptionKey, isAes) {
  28323. var key = new Uint8Array(encryptionKey.length + 9), i, n;
  28324. for (i = 0, n = encryptionKey.length; i < n; ++i) {
  28325. key[i] = encryptionKey[i];
  28326. }
  28327. key[i++] = num & 0xFF;
  28328. key[i++] = num >> 8 & 0xFF;
  28329. key[i++] = num >> 16 & 0xFF;
  28330. key[i++] = gen & 0xFF;
  28331. key[i++] = gen >> 8 & 0xFF;
  28332. if (isAes) {
  28333. key[i++] = 0x73;
  28334. key[i++] = 0x41;
  28335. key[i++] = 0x6C;
  28336. key[i++] = 0x54;
  28337. }
  28338. var hash = calculateMD5(key, 0, i);
  28339. return hash.subarray(0, Math.min(encryptionKey.length + 5, 16));
  28340. }
  28341. function buildCipherConstructor(cf, name, num, gen, key) {
  28342. assert(isName(name), 'Invalid crypt filter name.');
  28343. var cryptFilter = cf.get(name.name);
  28344. var cfm;
  28345. if (cryptFilter !== null && cryptFilter !== undefined) {
  28346. cfm = cryptFilter.get('CFM');
  28347. }
  28348. if (!cfm || cfm.name === 'None') {
  28349. return function cipherTransformFactoryBuildCipherConstructorNone() {
  28350. return new NullCipher();
  28351. };
  28352. }
  28353. if (cfm.name === 'V2') {
  28354. return function cipherTransformFactoryBuildCipherConstructorV2() {
  28355. return new ARCFourCipher(buildObjectKey(num, gen, key, false));
  28356. };
  28357. }
  28358. if (cfm.name === 'AESV2') {
  28359. return function cipherTransformFactoryBuildCipherConstructorAESV2() {
  28360. return new AES128Cipher(buildObjectKey(num, gen, key, true));
  28361. };
  28362. }
  28363. if (cfm.name === 'AESV3') {
  28364. return function cipherTransformFactoryBuildCipherConstructorAESV3() {
  28365. return new AES256Cipher(key);
  28366. };
  28367. }
  28368. error('Unknown crypto method');
  28369. }
  28370. CipherTransformFactory.prototype = {
  28371. createCipherTransform: function CipherTransformFactory_createCipherTransform(num, gen) {
  28372. if (this.algorithm === 4 || this.algorithm === 5) {
  28373. return new CipherTransform(buildCipherConstructor(this.cf, this.stmf, num, gen, this.encryptionKey), buildCipherConstructor(this.cf, this.strf, num, gen, this.encryptionKey));
  28374. }
  28375. var key = buildObjectKey(num, gen, this.encryptionKey, false);
  28376. var cipherConstructor = function buildCipherCipherConstructor() {
  28377. return new ARCFourCipher(key);
  28378. };
  28379. return new CipherTransform(cipherConstructor, cipherConstructor);
  28380. }
  28381. };
  28382. return CipherTransformFactory;
  28383. }();
  28384. exports.AES128Cipher = AES128Cipher;
  28385. exports.AES256Cipher = AES256Cipher;
  28386. exports.ARCFourCipher = ARCFourCipher;
  28387. exports.CipherTransformFactory = CipherTransformFactory;
  28388. exports.PDF17 = PDF17;
  28389. exports.PDF20 = PDF20;
  28390. exports.calculateMD5 = calculateMD5;
  28391. exports.calculateSHA256 = calculateSHA256;
  28392. exports.calculateSHA384 = calculateSHA384;
  28393. exports.calculateSHA512 = calculateSHA512;
  28394. /***/ }),
  28395. /* 18 */
  28396. /***/ (function(module, exports, __w_pdfjs_require__) {
  28397. "use strict";
  28398. var sharedUtil = __w_pdfjs_require__(0);
  28399. var corePrimitives = __w_pdfjs_require__(1);
  28400. var coreStream = __w_pdfjs_require__(2);
  28401. var coreParser = __w_pdfjs_require__(6);
  28402. var coreImage = __w_pdfjs_require__(34);
  28403. var coreColorSpace = __w_pdfjs_require__(4);
  28404. var coreMurmurHash3 = __w_pdfjs_require__(38);
  28405. var coreFonts = __w_pdfjs_require__(33);
  28406. var coreFunction = __w_pdfjs_require__(7);
  28407. var corePattern = __w_pdfjs_require__(40);
  28408. var coreCMap = __w_pdfjs_require__(30);
  28409. var coreMetrics = __w_pdfjs_require__(37);
  28410. var coreBidi = __w_pdfjs_require__(28);
  28411. var coreEncodings = __w_pdfjs_require__(5);
  28412. var coreStandardFonts = __w_pdfjs_require__(21);
  28413. var coreUnicode = __w_pdfjs_require__(22);
  28414. var coreGlyphList = __w_pdfjs_require__(8);
  28415. var FONT_IDENTITY_MATRIX = sharedUtil.FONT_IDENTITY_MATRIX;
  28416. var IDENTITY_MATRIX = sharedUtil.IDENTITY_MATRIX;
  28417. var UNSUPPORTED_FEATURES = sharedUtil.UNSUPPORTED_FEATURES;
  28418. var ImageKind = sharedUtil.ImageKind;
  28419. var OPS = sharedUtil.OPS;
  28420. var TextRenderingMode = sharedUtil.TextRenderingMode;
  28421. var CMapCompressionType = sharedUtil.CMapCompressionType;
  28422. var Util = sharedUtil.Util;
  28423. var assert = sharedUtil.assert;
  28424. var createPromiseCapability = sharedUtil.createPromiseCapability;
  28425. var error = sharedUtil.error;
  28426. var info = sharedUtil.info;
  28427. var isArray = sharedUtil.isArray;
  28428. var isNum = sharedUtil.isNum;
  28429. var isString = sharedUtil.isString;
  28430. var getLookupTableFactory = sharedUtil.getLookupTableFactory;
  28431. var warn = sharedUtil.warn;
  28432. var Dict = corePrimitives.Dict;
  28433. var Name = corePrimitives.Name;
  28434. var isEOF = corePrimitives.isEOF;
  28435. var isCmd = corePrimitives.isCmd;
  28436. var isDict = corePrimitives.isDict;
  28437. var isName = corePrimitives.isName;
  28438. var isRef = corePrimitives.isRef;
  28439. var isStream = corePrimitives.isStream;
  28440. var DecodeStream = coreStream.DecodeStream;
  28441. var JpegStream = coreStream.JpegStream;
  28442. var Stream = coreStream.Stream;
  28443. var Lexer = coreParser.Lexer;
  28444. var Parser = coreParser.Parser;
  28445. var PDFImage = coreImage.PDFImage;
  28446. var ColorSpace = coreColorSpace.ColorSpace;
  28447. var MurmurHash3_64 = coreMurmurHash3.MurmurHash3_64;
  28448. var ErrorFont = coreFonts.ErrorFont;
  28449. var FontFlags = coreFonts.FontFlags;
  28450. var Font = coreFonts.Font;
  28451. var IdentityToUnicodeMap = coreFonts.IdentityToUnicodeMap;
  28452. var ToUnicodeMap = coreFonts.ToUnicodeMap;
  28453. var getFontType = coreFonts.getFontType;
  28454. var isPDFFunction = coreFunction.isPDFFunction;
  28455. var PDFFunction = coreFunction.PDFFunction;
  28456. var Pattern = corePattern.Pattern;
  28457. var getTilingPatternIR = corePattern.getTilingPatternIR;
  28458. var CMapFactory = coreCMap.CMapFactory;
  28459. var IdentityCMap = coreCMap.IdentityCMap;
  28460. var getMetrics = coreMetrics.getMetrics;
  28461. var bidi = coreBidi.bidi;
  28462. var WinAnsiEncoding = coreEncodings.WinAnsiEncoding;
  28463. var StandardEncoding = coreEncodings.StandardEncoding;
  28464. var MacRomanEncoding = coreEncodings.MacRomanEncoding;
  28465. var SymbolSetEncoding = coreEncodings.SymbolSetEncoding;
  28466. var ZapfDingbatsEncoding = coreEncodings.ZapfDingbatsEncoding;
  28467. var getEncoding = coreEncodings.getEncoding;
  28468. var getStdFontMap = coreStandardFonts.getStdFontMap;
  28469. var getSerifFonts = coreStandardFonts.getSerifFonts;
  28470. var getSymbolsFonts = coreStandardFonts.getSymbolsFonts;
  28471. var getNormalizedUnicodes = coreUnicode.getNormalizedUnicodes;
  28472. var reverseIfRtl = coreUnicode.reverseIfRtl;
  28473. var getUnicodeForGlyph = coreUnicode.getUnicodeForGlyph;
  28474. var getGlyphsUnicode = coreGlyphList.getGlyphsUnicode;
  28475. var PartialEvaluator = function PartialEvaluatorClosure() {
  28476. var DefaultPartialEvaluatorOptions = {
  28477. forceDataSchema: false,
  28478. maxImageSize: -1,
  28479. disableFontFace: false,
  28480. disableNativeImageDecoder: false
  28481. };
  28482. function NativeImageDecoder(xref, resources, handler, forceDataSchema) {
  28483. this.xref = xref;
  28484. this.resources = resources;
  28485. this.handler = handler;
  28486. this.forceDataSchema = forceDataSchema;
  28487. }
  28488. NativeImageDecoder.prototype = {
  28489. canDecode: function (image) {
  28490. return image instanceof JpegStream && NativeImageDecoder.isDecodable(image, this.xref, this.resources);
  28491. },
  28492. decode: function (image) {
  28493. var dict = image.dict;
  28494. var colorSpace = dict.get('ColorSpace', 'CS');
  28495. colorSpace = ColorSpace.parse(colorSpace, this.xref, this.resources);
  28496. var numComps = colorSpace.numComps;
  28497. var decodePromise = this.handler.sendWithPromise('JpegDecode', [
  28498. image.getIR(this.forceDataSchema),
  28499. numComps
  28500. ]);
  28501. return decodePromise.then(function (message) {
  28502. var data = message.data;
  28503. return new Stream(data, 0, data.length, image.dict);
  28504. });
  28505. }
  28506. };
  28507. NativeImageDecoder.isSupported = function NativeImageDecoder_isSupported(image, xref, res) {
  28508. var dict = image.dict;
  28509. if (dict.has('DecodeParms') || dict.has('DP')) {
  28510. return false;
  28511. }
  28512. var cs = ColorSpace.parse(dict.get('ColorSpace', 'CS'), xref, res);
  28513. return (cs.name === 'DeviceGray' || cs.name === 'DeviceRGB') && cs.isDefaultDecode(dict.getArray('Decode', 'D'));
  28514. };
  28515. NativeImageDecoder.isDecodable = function NativeImageDecoder_isDecodable(image, xref, res) {
  28516. var dict = image.dict;
  28517. if (dict.has('DecodeParms') || dict.has('DP')) {
  28518. return false;
  28519. }
  28520. var cs = ColorSpace.parse(dict.get('ColorSpace', 'CS'), xref, res);
  28521. return (cs.numComps === 1 || cs.numComps === 3) && cs.isDefaultDecode(dict.getArray('Decode', 'D'));
  28522. };
  28523. function PartialEvaluator(pdfManager, xref, handler, pageIndex, idFactory, fontCache, builtInCMapCache, options) {
  28524. this.pdfManager = pdfManager;
  28525. this.xref = xref;
  28526. this.handler = handler;
  28527. this.pageIndex = pageIndex;
  28528. this.idFactory = idFactory;
  28529. this.fontCache = fontCache;
  28530. this.builtInCMapCache = builtInCMapCache;
  28531. this.options = options || DefaultPartialEvaluatorOptions;
  28532. this.fetchBuiltInCMap = function (name) {
  28533. var cachedCMap = builtInCMapCache[name];
  28534. if (cachedCMap) {
  28535. return Promise.resolve(cachedCMap);
  28536. }
  28537. return handler.sendWithPromise('FetchBuiltInCMap', { name: name }).then(function (data) {
  28538. if (data.compressionType !== CMapCompressionType.NONE) {
  28539. builtInCMapCache[name] = data;
  28540. }
  28541. return data;
  28542. });
  28543. };
  28544. }
  28545. var TIME_SLOT_DURATION_MS = 20;
  28546. var CHECK_TIME_EVERY = 100;
  28547. function TimeSlotManager() {
  28548. this.reset();
  28549. }
  28550. TimeSlotManager.prototype = {
  28551. check: function TimeSlotManager_check() {
  28552. if (++this.checked < CHECK_TIME_EVERY) {
  28553. return false;
  28554. }
  28555. this.checked = 0;
  28556. return this.endTime <= Date.now();
  28557. },
  28558. reset: function TimeSlotManager_reset() {
  28559. this.endTime = Date.now() + TIME_SLOT_DURATION_MS;
  28560. this.checked = 0;
  28561. }
  28562. };
  28563. var deferred = Promise.resolve();
  28564. var TILING_PATTERN = 1, SHADING_PATTERN = 2;
  28565. PartialEvaluator.prototype = {
  28566. hasBlendModes: function PartialEvaluator_hasBlendModes(resources) {
  28567. if (!isDict(resources)) {
  28568. return false;
  28569. }
  28570. var processed = Object.create(null);
  28571. if (resources.objId) {
  28572. processed[resources.objId] = true;
  28573. }
  28574. var nodes = [resources], xref = this.xref;
  28575. while (nodes.length) {
  28576. var key, i, ii;
  28577. var node = nodes.shift();
  28578. var graphicStates = node.get('ExtGState');
  28579. if (isDict(graphicStates)) {
  28580. var graphicStatesKeys = graphicStates.getKeys();
  28581. for (i = 0, ii = graphicStatesKeys.length; i < ii; i++) {
  28582. key = graphicStatesKeys[i];
  28583. var graphicState = graphicStates.get(key);
  28584. var bm = graphicState.get('BM');
  28585. if (isName(bm) && bm.name !== 'Normal') {
  28586. return true;
  28587. }
  28588. }
  28589. }
  28590. var xObjects = node.get('XObject');
  28591. if (!isDict(xObjects)) {
  28592. continue;
  28593. }
  28594. var xObjectsKeys = xObjects.getKeys();
  28595. for (i = 0, ii = xObjectsKeys.length; i < ii; i++) {
  28596. key = xObjectsKeys[i];
  28597. var xObject = xObjects.getRaw(key);
  28598. if (isRef(xObject)) {
  28599. if (processed[xObject.toString()]) {
  28600. continue;
  28601. }
  28602. xObject = xref.fetch(xObject);
  28603. }
  28604. if (!isStream(xObject)) {
  28605. continue;
  28606. }
  28607. if (xObject.dict.objId) {
  28608. if (processed[xObject.dict.objId]) {
  28609. continue;
  28610. }
  28611. processed[xObject.dict.objId] = true;
  28612. }
  28613. var xResources = xObject.dict.get('Resources');
  28614. if (isDict(xResources) && (!xResources.objId || !processed[xResources.objId])) {
  28615. nodes.push(xResources);
  28616. if (xResources.objId) {
  28617. processed[xResources.objId] = true;
  28618. }
  28619. }
  28620. }
  28621. }
  28622. return false;
  28623. },
  28624. buildFormXObject: function PartialEvaluator_buildFormXObject(resources, xobj, smask, operatorList, task, initialState) {
  28625. var matrix = xobj.dict.getArray('Matrix');
  28626. var bbox = xobj.dict.getArray('BBox');
  28627. var group = xobj.dict.get('Group');
  28628. if (group) {
  28629. var groupOptions = {
  28630. matrix: matrix,
  28631. bbox: bbox,
  28632. smask: smask,
  28633. isolated: false,
  28634. knockout: false
  28635. };
  28636. var groupSubtype = group.get('S');
  28637. var colorSpace;
  28638. if (isName(groupSubtype, 'Transparency')) {
  28639. groupOptions.isolated = group.get('I') || false;
  28640. groupOptions.knockout = group.get('K') || false;
  28641. colorSpace = group.has('CS') ? ColorSpace.parse(group.get('CS'), this.xref, resources) : null;
  28642. }
  28643. if (smask && smask.backdrop) {
  28644. colorSpace = colorSpace || ColorSpace.singletons.rgb;
  28645. smask.backdrop = colorSpace.getRgb(smask.backdrop, 0);
  28646. }
  28647. operatorList.addOp(OPS.beginGroup, [groupOptions]);
  28648. }
  28649. operatorList.addOp(OPS.paintFormXObjectBegin, [
  28650. matrix,
  28651. bbox
  28652. ]);
  28653. return this.getOperatorList(xobj, task, xobj.dict.get('Resources') || resources, operatorList, initialState).then(function () {
  28654. operatorList.addOp(OPS.paintFormXObjectEnd, []);
  28655. if (group) {
  28656. operatorList.addOp(OPS.endGroup, [groupOptions]);
  28657. }
  28658. });
  28659. },
  28660. buildPaintImageXObject: function PartialEvaluator_buildPaintImageXObject(resources, image, inline, operatorList, cacheKey, imageCache) {
  28661. var self = this;
  28662. var dict = image.dict;
  28663. var w = dict.get('Width', 'W');
  28664. var h = dict.get('Height', 'H');
  28665. if (!(w && isNum(w)) || !(h && isNum(h))) {
  28666. warn('Image dimensions are missing, or not numbers.');
  28667. return;
  28668. }
  28669. var maxImageSize = this.options.maxImageSize;
  28670. if (maxImageSize !== -1 && w * h > maxImageSize) {
  28671. warn('Image exceeded maximum allowed size and was removed.');
  28672. return;
  28673. }
  28674. var imageMask = dict.get('ImageMask', 'IM') || false;
  28675. var imgData, args;
  28676. if (imageMask) {
  28677. var width = dict.get('Width', 'W');
  28678. var height = dict.get('Height', 'H');
  28679. var bitStrideLength = width + 7 >> 3;
  28680. var imgArray = image.getBytes(bitStrideLength * height);
  28681. var decode = dict.getArray('Decode', 'D');
  28682. var inverseDecode = !!decode && decode[0] > 0;
  28683. imgData = PDFImage.createMask(imgArray, width, height, image instanceof DecodeStream, inverseDecode);
  28684. imgData.cached = true;
  28685. args = [imgData];
  28686. operatorList.addOp(OPS.paintImageMaskXObject, args);
  28687. if (cacheKey) {
  28688. imageCache[cacheKey] = {
  28689. fn: OPS.paintImageMaskXObject,
  28690. args: args
  28691. };
  28692. }
  28693. return;
  28694. }
  28695. var softMask = dict.get('SMask', 'SM') || false;
  28696. var mask = dict.get('Mask') || false;
  28697. var SMALL_IMAGE_DIMENSIONS = 200;
  28698. if (inline && !softMask && !mask && !(image instanceof JpegStream) && w + h < SMALL_IMAGE_DIMENSIONS) {
  28699. var imageObj = new PDFImage(this.xref, resources, image, inline, null, null);
  28700. imgData = imageObj.createImageData(true);
  28701. operatorList.addOp(OPS.paintInlineImageXObject, [imgData]);
  28702. return;
  28703. }
  28704. var useNativeImageDecoder = !this.options.disableNativeImageDecoder;
  28705. var objId = 'img_' + this.idFactory.createObjId();
  28706. operatorList.addDependency(objId);
  28707. args = [
  28708. objId,
  28709. w,
  28710. h
  28711. ];
  28712. if (useNativeImageDecoder && !softMask && !mask && image instanceof JpegStream && NativeImageDecoder.isSupported(image, this.xref, resources)) {
  28713. operatorList.addOp(OPS.paintJpegXObject, args);
  28714. this.handler.send('obj', [
  28715. objId,
  28716. this.pageIndex,
  28717. 'JpegStream',
  28718. image.getIR(this.options.forceDataSchema)
  28719. ]);
  28720. return;
  28721. }
  28722. var nativeImageDecoder = null;
  28723. if (useNativeImageDecoder && (image instanceof JpegStream || mask instanceof JpegStream || softMask instanceof JpegStream)) {
  28724. nativeImageDecoder = new NativeImageDecoder(self.xref, resources, self.handler, self.options.forceDataSchema);
  28725. }
  28726. PDFImage.buildImage(self.handler, self.xref, resources, image, inline, nativeImageDecoder).then(function (imageObj) {
  28727. var imgData = imageObj.createImageData(false);
  28728. self.handler.send('obj', [
  28729. objId,
  28730. self.pageIndex,
  28731. 'Image',
  28732. imgData
  28733. ], [imgData.data.buffer]);
  28734. }).then(undefined, function (reason) {
  28735. warn('Unable to decode image: ' + reason);
  28736. self.handler.send('obj', [
  28737. objId,
  28738. self.pageIndex,
  28739. 'Image',
  28740. null
  28741. ]);
  28742. });
  28743. operatorList.addOp(OPS.paintImageXObject, args);
  28744. if (cacheKey) {
  28745. imageCache[cacheKey] = {
  28746. fn: OPS.paintImageXObject,
  28747. args: args
  28748. };
  28749. }
  28750. },
  28751. handleSMask: function PartialEvaluator_handleSmask(smask, resources, operatorList, task, stateManager) {
  28752. var smaskContent = smask.get('G');
  28753. var smaskOptions = {
  28754. subtype: smask.get('S').name,
  28755. backdrop: smask.get('BC')
  28756. };
  28757. var transferObj = smask.get('TR');
  28758. if (isPDFFunction(transferObj)) {
  28759. var transferFn = PDFFunction.parse(this.xref, transferObj);
  28760. var transferMap = new Uint8Array(256);
  28761. var tmp = new Float32Array(1);
  28762. for (var i = 0; i < 256; i++) {
  28763. tmp[0] = i / 255;
  28764. transferFn(tmp, 0, tmp, 0);
  28765. transferMap[i] = tmp[0] * 255 | 0;
  28766. }
  28767. smaskOptions.transferMap = transferMap;
  28768. }
  28769. return this.buildFormXObject(resources, smaskContent, smaskOptions, operatorList, task, stateManager.state.clone());
  28770. },
  28771. handleTilingType: function PartialEvaluator_handleTilingType(fn, args, resources, pattern, patternDict, operatorList, task) {
  28772. var tilingOpList = new OperatorList();
  28773. var resourcesArray = [
  28774. patternDict.get('Resources'),
  28775. resources
  28776. ];
  28777. var patternResources = Dict.merge(this.xref, resourcesArray);
  28778. return this.getOperatorList(pattern, task, patternResources, tilingOpList).then(function () {
  28779. operatorList.addDependencies(tilingOpList.dependencies);
  28780. operatorList.addOp(fn, getTilingPatternIR({
  28781. fnArray: tilingOpList.fnArray,
  28782. argsArray: tilingOpList.argsArray
  28783. }, patternDict, args));
  28784. });
  28785. },
  28786. handleSetFont: function PartialEvaluator_handleSetFont(resources, fontArgs, fontRef, operatorList, task, state) {
  28787. var fontName;
  28788. if (fontArgs) {
  28789. fontArgs = fontArgs.slice();
  28790. fontName = fontArgs[0].name;
  28791. }
  28792. var self = this;
  28793. return this.loadFont(fontName, fontRef, this.xref, resources).then(function (translated) {
  28794. if (!translated.font.isType3Font) {
  28795. return translated;
  28796. }
  28797. return translated.loadType3Data(self, resources, operatorList, task).then(function () {
  28798. return translated;
  28799. }, function (reason) {
  28800. self.handler.send('UnsupportedFeature', { featureId: UNSUPPORTED_FEATURES.font });
  28801. return new TranslatedFont('g_font_error', new ErrorFont('Type3 font load error: ' + reason), translated.font);
  28802. });
  28803. }).then(function (translated) {
  28804. state.font = translated.font;
  28805. translated.send(self.handler);
  28806. return translated.loadedName;
  28807. });
  28808. },
  28809. handleText: function PartialEvaluator_handleText(chars, state) {
  28810. var font = state.font;
  28811. var glyphs = font.charsToGlyphs(chars);
  28812. var isAddToPathSet = !!(state.textRenderingMode & TextRenderingMode.ADD_TO_PATH_FLAG);
  28813. if (font.data && (isAddToPathSet || this.options.disableFontFace)) {
  28814. var buildPath = function (fontChar) {
  28815. if (!font.renderer.hasBuiltPath(fontChar)) {
  28816. var path = font.renderer.getPathJs(fontChar);
  28817. this.handler.send('commonobj', [
  28818. font.loadedName + '_path_' + fontChar,
  28819. 'FontPath',
  28820. path
  28821. ]);
  28822. }
  28823. }.bind(this);
  28824. for (var i = 0, ii = glyphs.length; i < ii; i++) {
  28825. var glyph = glyphs[i];
  28826. buildPath(glyph.fontChar);
  28827. var accent = glyph.accent;
  28828. if (accent && accent.fontChar) {
  28829. buildPath(accent.fontChar);
  28830. }
  28831. }
  28832. }
  28833. return glyphs;
  28834. },
  28835. setGState: function PartialEvaluator_setGState(resources, gState, operatorList, task, xref, stateManager) {
  28836. var gStateObj = [];
  28837. var gStateKeys = gState.getKeys();
  28838. var self = this;
  28839. var promise = Promise.resolve();
  28840. for (var i = 0, ii = gStateKeys.length; i < ii; i++) {
  28841. var key = gStateKeys[i];
  28842. var value = gState.get(key);
  28843. switch (key) {
  28844. case 'Type':
  28845. break;
  28846. case 'LW':
  28847. case 'LC':
  28848. case 'LJ':
  28849. case 'ML':
  28850. case 'D':
  28851. case 'RI':
  28852. case 'FL':
  28853. case 'CA':
  28854. case 'ca':
  28855. gStateObj.push([
  28856. key,
  28857. value
  28858. ]);
  28859. break;
  28860. case 'Font':
  28861. promise = promise.then(function () {
  28862. return self.handleSetFont(resources, null, value[0], operatorList, task, stateManager.state).then(function (loadedName) {
  28863. operatorList.addDependency(loadedName);
  28864. gStateObj.push([
  28865. key,
  28866. [
  28867. loadedName,
  28868. value[1]
  28869. ]
  28870. ]);
  28871. });
  28872. });
  28873. break;
  28874. case 'BM':
  28875. gStateObj.push([
  28876. key,
  28877. value
  28878. ]);
  28879. break;
  28880. case 'SMask':
  28881. if (isName(value, 'None')) {
  28882. gStateObj.push([
  28883. key,
  28884. false
  28885. ]);
  28886. break;
  28887. }
  28888. if (isDict(value)) {
  28889. promise = promise.then(function (dict) {
  28890. return self.handleSMask(dict, resources, operatorList, task, stateManager);
  28891. }.bind(this, value));
  28892. gStateObj.push([
  28893. key,
  28894. true
  28895. ]);
  28896. } else {
  28897. warn('Unsupported SMask type');
  28898. }
  28899. break;
  28900. case 'OP':
  28901. case 'op':
  28902. case 'OPM':
  28903. case 'BG':
  28904. case 'BG2':
  28905. case 'UCR':
  28906. case 'UCR2':
  28907. case 'TR':
  28908. case 'TR2':
  28909. case 'HT':
  28910. case 'SM':
  28911. case 'SA':
  28912. case 'AIS':
  28913. case 'TK':
  28914. info('graphic state operator ' + key);
  28915. break;
  28916. default:
  28917. info('Unknown graphic state operator ' + key);
  28918. break;
  28919. }
  28920. }
  28921. return promise.then(function () {
  28922. if (gStateObj.length > 0) {
  28923. operatorList.addOp(OPS.setGState, [gStateObj]);
  28924. }
  28925. });
  28926. },
  28927. loadFont: function PartialEvaluator_loadFont(fontName, font, xref, resources) {
  28928. function errorFont() {
  28929. return Promise.resolve(new TranslatedFont('g_font_error', new ErrorFont('Font ' + fontName + ' is not available'), font));
  28930. }
  28931. var fontRef;
  28932. if (font) {
  28933. assert(isRef(font));
  28934. fontRef = font;
  28935. } else {
  28936. var fontRes = resources.get('Font');
  28937. if (fontRes) {
  28938. fontRef = fontRes.getRaw(fontName);
  28939. } else {
  28940. warn('fontRes not available');
  28941. return errorFont();
  28942. }
  28943. }
  28944. if (!fontRef) {
  28945. warn('fontRef not available');
  28946. return errorFont();
  28947. }
  28948. if (this.fontCache.has(fontRef)) {
  28949. return this.fontCache.get(fontRef);
  28950. }
  28951. font = xref.fetchIfRef(fontRef);
  28952. if (!isDict(font)) {
  28953. return errorFont();
  28954. }
  28955. if (font.translated) {
  28956. return font.translated;
  28957. }
  28958. var fontCapability = createPromiseCapability();
  28959. var preEvaluatedFont = this.preEvaluateFont(font, xref);
  28960. var descriptor = preEvaluatedFont.descriptor;
  28961. var fontRefIsRef = isRef(fontRef), fontID;
  28962. if (fontRefIsRef) {
  28963. fontID = fontRef.toString();
  28964. }
  28965. if (isDict(descriptor)) {
  28966. if (!descriptor.fontAliases) {
  28967. descriptor.fontAliases = Object.create(null);
  28968. }
  28969. var fontAliases = descriptor.fontAliases;
  28970. var hash = preEvaluatedFont.hash;
  28971. if (fontAliases[hash]) {
  28972. var aliasFontRef = fontAliases[hash].aliasRef;
  28973. if (fontRefIsRef && aliasFontRef && this.fontCache.has(aliasFontRef)) {
  28974. this.fontCache.putAlias(fontRef, aliasFontRef);
  28975. return this.fontCache.get(fontRef);
  28976. }
  28977. } else {
  28978. fontAliases[hash] = { fontID: Font.getFontID() };
  28979. }
  28980. if (fontRefIsRef) {
  28981. fontAliases[hash].aliasRef = fontRef;
  28982. }
  28983. fontID = fontAliases[hash].fontID;
  28984. }
  28985. if (fontRefIsRef) {
  28986. this.fontCache.put(fontRef, fontCapability.promise);
  28987. } else {
  28988. if (!fontID) {
  28989. fontID = this.idFactory.createObjId();
  28990. }
  28991. this.fontCache.put('id_' + fontID, fontCapability.promise);
  28992. }
  28993. assert(fontID, 'The "fontID" must be defined.');
  28994. font.loadedName = 'g_' + this.pdfManager.docId + '_f' + fontID;
  28995. font.translated = fontCapability.promise;
  28996. var translatedPromise;
  28997. try {
  28998. translatedPromise = this.translateFont(preEvaluatedFont, xref);
  28999. } catch (e) {
  29000. translatedPromise = Promise.reject(e);
  29001. }
  29002. var self = this;
  29003. translatedPromise.then(function (translatedFont) {
  29004. if (translatedFont.fontType !== undefined) {
  29005. var xrefFontStats = xref.stats.fontTypes;
  29006. xrefFontStats[translatedFont.fontType] = true;
  29007. }
  29008. fontCapability.resolve(new TranslatedFont(font.loadedName, translatedFont, font));
  29009. }, function (reason) {
  29010. self.handler.send('UnsupportedFeature', { featureId: UNSUPPORTED_FEATURES.font });
  29011. try {
  29012. var descriptor = preEvaluatedFont.descriptor;
  29013. var fontFile3 = descriptor && descriptor.get('FontFile3');
  29014. var subtype = fontFile3 && fontFile3.get('Subtype');
  29015. var fontType = getFontType(preEvaluatedFont.type, subtype && subtype.name);
  29016. var xrefFontStats = xref.stats.fontTypes;
  29017. xrefFontStats[fontType] = true;
  29018. } catch (ex) {
  29019. }
  29020. fontCapability.resolve(new TranslatedFont(font.loadedName, new ErrorFont(reason instanceof Error ? reason.message : reason), font));
  29021. });
  29022. return fontCapability.promise;
  29023. },
  29024. buildPath: function PartialEvaluator_buildPath(operatorList, fn, args) {
  29025. var lastIndex = operatorList.length - 1;
  29026. if (!args) {
  29027. args = [];
  29028. }
  29029. if (lastIndex < 0 || operatorList.fnArray[lastIndex] !== OPS.constructPath) {
  29030. operatorList.addOp(OPS.constructPath, [
  29031. [fn],
  29032. args
  29033. ]);
  29034. } else {
  29035. var opArgs = operatorList.argsArray[lastIndex];
  29036. opArgs[0].push(fn);
  29037. Array.prototype.push.apply(opArgs[1], args);
  29038. }
  29039. },
  29040. handleColorN: function PartialEvaluator_handleColorN(operatorList, fn, args, cs, patterns, resources, task, xref) {
  29041. var patternName = args[args.length - 1];
  29042. var pattern;
  29043. if (isName(patternName) && (pattern = patterns.get(patternName.name))) {
  29044. var dict = isStream(pattern) ? pattern.dict : pattern;
  29045. var typeNum = dict.get('PatternType');
  29046. if (typeNum === TILING_PATTERN) {
  29047. var color = cs.base ? cs.base.getRgb(args, 0) : null;
  29048. return this.handleTilingType(fn, color, resources, pattern, dict, operatorList, task);
  29049. } else if (typeNum === SHADING_PATTERN) {
  29050. var shading = dict.get('Shading');
  29051. var matrix = dict.getArray('Matrix');
  29052. pattern = Pattern.parseShading(shading, matrix, xref, resources, this.handler);
  29053. operatorList.addOp(fn, pattern.getIR());
  29054. return Promise.resolve();
  29055. }
  29056. return Promise.reject('Unknown PatternType: ' + typeNum);
  29057. }
  29058. operatorList.addOp(fn, args);
  29059. return Promise.resolve();
  29060. },
  29061. getOperatorList: function PartialEvaluator_getOperatorList(stream, task, resources, operatorList, initialState) {
  29062. var self = this;
  29063. var xref = this.xref;
  29064. var imageCache = Object.create(null);
  29065. assert(operatorList);
  29066. resources = resources || Dict.empty;
  29067. var xobjs = resources.get('XObject') || Dict.empty;
  29068. var patterns = resources.get('Pattern') || Dict.empty;
  29069. var stateManager = new StateManager(initialState || new EvalState());
  29070. var preprocessor = new EvaluatorPreprocessor(stream, xref, stateManager);
  29071. var timeSlotManager = new TimeSlotManager();
  29072. return new Promise(function promiseBody(resolve, reject) {
  29073. var next = function (promise) {
  29074. promise.then(function () {
  29075. try {
  29076. promiseBody(resolve, reject);
  29077. } catch (ex) {
  29078. reject(ex);
  29079. }
  29080. }, reject);
  29081. };
  29082. task.ensureNotTerminated();
  29083. timeSlotManager.reset();
  29084. var stop, operation = {}, i, ii, cs;
  29085. while (!(stop = timeSlotManager.check())) {
  29086. operation.args = null;
  29087. if (!preprocessor.read(operation)) {
  29088. break;
  29089. }
  29090. var args = operation.args;
  29091. var fn = operation.fn;
  29092. switch (fn | 0) {
  29093. case OPS.paintXObject:
  29094. if (args[0].code) {
  29095. break;
  29096. }
  29097. var name = args[0].name;
  29098. if (!name) {
  29099. warn('XObject must be referred to by name.');
  29100. continue;
  29101. }
  29102. if (imageCache[name] !== undefined) {
  29103. operatorList.addOp(imageCache[name].fn, imageCache[name].args);
  29104. args = null;
  29105. continue;
  29106. }
  29107. var xobj = xobjs.get(name);
  29108. if (xobj) {
  29109. assert(isStream(xobj), 'XObject should be a stream');
  29110. var type = xobj.dict.get('Subtype');
  29111. assert(isName(type), 'XObject should have a Name subtype');
  29112. if (type.name === 'Form') {
  29113. stateManager.save();
  29114. next(self.buildFormXObject(resources, xobj, null, operatorList, task, stateManager.state.clone()).then(function () {
  29115. stateManager.restore();
  29116. }));
  29117. return;
  29118. } else if (type.name === 'Image') {
  29119. self.buildPaintImageXObject(resources, xobj, false, operatorList, name, imageCache);
  29120. args = null;
  29121. continue;
  29122. } else if (type.name === 'PS') {
  29123. info('Ignored XObject subtype PS');
  29124. continue;
  29125. } else {
  29126. error('Unhandled XObject subtype ' + type.name);
  29127. }
  29128. }
  29129. break;
  29130. case OPS.setFont:
  29131. var fontSize = args[1];
  29132. next(self.handleSetFont(resources, args, null, operatorList, task, stateManager.state).then(function (loadedName) {
  29133. operatorList.addDependency(loadedName);
  29134. operatorList.addOp(OPS.setFont, [
  29135. loadedName,
  29136. fontSize
  29137. ]);
  29138. }));
  29139. return;
  29140. case OPS.endInlineImage:
  29141. var cacheKey = args[0].cacheKey;
  29142. if (cacheKey) {
  29143. var cacheEntry = imageCache[cacheKey];
  29144. if (cacheEntry !== undefined) {
  29145. operatorList.addOp(cacheEntry.fn, cacheEntry.args);
  29146. args = null;
  29147. continue;
  29148. }
  29149. }
  29150. self.buildPaintImageXObject(resources, args[0], true, operatorList, cacheKey, imageCache);
  29151. args = null;
  29152. continue;
  29153. case OPS.showText:
  29154. args[0] = self.handleText(args[0], stateManager.state);
  29155. break;
  29156. case OPS.showSpacedText:
  29157. var arr = args[0];
  29158. var combinedGlyphs = [];
  29159. var arrLength = arr.length;
  29160. var state = stateManager.state;
  29161. for (i = 0; i < arrLength; ++i) {
  29162. var arrItem = arr[i];
  29163. if (isString(arrItem)) {
  29164. Array.prototype.push.apply(combinedGlyphs, self.handleText(arrItem, state));
  29165. } else if (isNum(arrItem)) {
  29166. combinedGlyphs.push(arrItem);
  29167. }
  29168. }
  29169. args[0] = combinedGlyphs;
  29170. fn = OPS.showText;
  29171. break;
  29172. case OPS.nextLineShowText:
  29173. operatorList.addOp(OPS.nextLine);
  29174. args[0] = self.handleText(args[0], stateManager.state);
  29175. fn = OPS.showText;
  29176. break;
  29177. case OPS.nextLineSetSpacingShowText:
  29178. operatorList.addOp(OPS.nextLine);
  29179. operatorList.addOp(OPS.setWordSpacing, [args.shift()]);
  29180. operatorList.addOp(OPS.setCharSpacing, [args.shift()]);
  29181. args[0] = self.handleText(args[0], stateManager.state);
  29182. fn = OPS.showText;
  29183. break;
  29184. case OPS.setTextRenderingMode:
  29185. stateManager.state.textRenderingMode = args[0];
  29186. break;
  29187. case OPS.setFillColorSpace:
  29188. stateManager.state.fillColorSpace = ColorSpace.parse(args[0], xref, resources);
  29189. continue;
  29190. case OPS.setStrokeColorSpace:
  29191. stateManager.state.strokeColorSpace = ColorSpace.parse(args[0], xref, resources);
  29192. continue;
  29193. case OPS.setFillColor:
  29194. cs = stateManager.state.fillColorSpace;
  29195. args = cs.getRgb(args, 0);
  29196. fn = OPS.setFillRGBColor;
  29197. break;
  29198. case OPS.setStrokeColor:
  29199. cs = stateManager.state.strokeColorSpace;
  29200. args = cs.getRgb(args, 0);
  29201. fn = OPS.setStrokeRGBColor;
  29202. break;
  29203. case OPS.setFillGray:
  29204. stateManager.state.fillColorSpace = ColorSpace.singletons.gray;
  29205. args = ColorSpace.singletons.gray.getRgb(args, 0);
  29206. fn = OPS.setFillRGBColor;
  29207. break;
  29208. case OPS.setStrokeGray:
  29209. stateManager.state.strokeColorSpace = ColorSpace.singletons.gray;
  29210. args = ColorSpace.singletons.gray.getRgb(args, 0);
  29211. fn = OPS.setStrokeRGBColor;
  29212. break;
  29213. case OPS.setFillCMYKColor:
  29214. stateManager.state.fillColorSpace = ColorSpace.singletons.cmyk;
  29215. args = ColorSpace.singletons.cmyk.getRgb(args, 0);
  29216. fn = OPS.setFillRGBColor;
  29217. break;
  29218. case OPS.setStrokeCMYKColor:
  29219. stateManager.state.strokeColorSpace = ColorSpace.singletons.cmyk;
  29220. args = ColorSpace.singletons.cmyk.getRgb(args, 0);
  29221. fn = OPS.setStrokeRGBColor;
  29222. break;
  29223. case OPS.setFillRGBColor:
  29224. stateManager.state.fillColorSpace = ColorSpace.singletons.rgb;
  29225. args = ColorSpace.singletons.rgb.getRgb(args, 0);
  29226. break;
  29227. case OPS.setStrokeRGBColor:
  29228. stateManager.state.strokeColorSpace = ColorSpace.singletons.rgb;
  29229. args = ColorSpace.singletons.rgb.getRgb(args, 0);
  29230. break;
  29231. case OPS.setFillColorN:
  29232. cs = stateManager.state.fillColorSpace;
  29233. if (cs.name === 'Pattern') {
  29234. next(self.handleColorN(operatorList, OPS.setFillColorN, args, cs, patterns, resources, task, xref));
  29235. return;
  29236. }
  29237. args = cs.getRgb(args, 0);
  29238. fn = OPS.setFillRGBColor;
  29239. break;
  29240. case OPS.setStrokeColorN:
  29241. cs = stateManager.state.strokeColorSpace;
  29242. if (cs.name === 'Pattern') {
  29243. next(self.handleColorN(operatorList, OPS.setStrokeColorN, args, cs, patterns, resources, task, xref));
  29244. return;
  29245. }
  29246. args = cs.getRgb(args, 0);
  29247. fn = OPS.setStrokeRGBColor;
  29248. break;
  29249. case OPS.shadingFill:
  29250. var shadingRes = resources.get('Shading');
  29251. if (!shadingRes) {
  29252. error('No shading resource found');
  29253. }
  29254. var shading = shadingRes.get(args[0].name);
  29255. if (!shading) {
  29256. error('No shading object found');
  29257. }
  29258. var shadingFill = Pattern.parseShading(shading, null, xref, resources, self.handler);
  29259. var patternIR = shadingFill.getIR();
  29260. args = [patternIR];
  29261. fn = OPS.shadingFill;
  29262. break;
  29263. case OPS.setGState:
  29264. var dictName = args[0];
  29265. var extGState = resources.get('ExtGState');
  29266. if (!isDict(extGState) || !extGState.has(dictName.name)) {
  29267. break;
  29268. }
  29269. var gState = extGState.get(dictName.name);
  29270. next(self.setGState(resources, gState, operatorList, task, xref, stateManager));
  29271. return;
  29272. case OPS.moveTo:
  29273. case OPS.lineTo:
  29274. case OPS.curveTo:
  29275. case OPS.curveTo2:
  29276. case OPS.curveTo3:
  29277. case OPS.closePath:
  29278. self.buildPath(operatorList, fn, args);
  29279. continue;
  29280. case OPS.rectangle:
  29281. self.buildPath(operatorList, fn, args);
  29282. continue;
  29283. case OPS.markPoint:
  29284. case OPS.markPointProps:
  29285. case OPS.beginMarkedContent:
  29286. case OPS.beginMarkedContentProps:
  29287. case OPS.endMarkedContent:
  29288. case OPS.beginCompat:
  29289. case OPS.endCompat:
  29290. continue;
  29291. default:
  29292. if (args !== null) {
  29293. for (i = 0, ii = args.length; i < ii; i++) {
  29294. if (args[i] instanceof Dict) {
  29295. break;
  29296. }
  29297. }
  29298. if (i < ii) {
  29299. warn('getOperatorList - ignoring operator: ' + fn);
  29300. continue;
  29301. }
  29302. }
  29303. }
  29304. operatorList.addOp(fn, args);
  29305. }
  29306. if (stop) {
  29307. next(deferred);
  29308. return;
  29309. }
  29310. for (i = 0, ii = preprocessor.savedStatesDepth; i < ii; i++) {
  29311. operatorList.addOp(OPS.restore, []);
  29312. }
  29313. resolve();
  29314. });
  29315. },
  29316. getTextContent: function PartialEvaluator_getTextContent(stream, task, resources, stateManager, normalizeWhitespace, combineTextItems) {
  29317. stateManager = stateManager || new StateManager(new TextState());
  29318. var WhitespaceRegexp = /\s/g;
  29319. var textContent = {
  29320. items: [],
  29321. styles: Object.create(null)
  29322. };
  29323. var textContentItem = {
  29324. initialized: false,
  29325. str: [],
  29326. width: 0,
  29327. height: 0,
  29328. vertical: false,
  29329. lastAdvanceWidth: 0,
  29330. lastAdvanceHeight: 0,
  29331. textAdvanceScale: 0,
  29332. spaceWidth: 0,
  29333. fakeSpaceMin: Infinity,
  29334. fakeMultiSpaceMin: Infinity,
  29335. fakeMultiSpaceMax: -0,
  29336. textRunBreakAllowed: false,
  29337. transform: null,
  29338. fontName: null
  29339. };
  29340. var SPACE_FACTOR = 0.3;
  29341. var MULTI_SPACE_FACTOR = 1.5;
  29342. var MULTI_SPACE_FACTOR_MAX = 4;
  29343. var self = this;
  29344. var xref = this.xref;
  29345. resources = xref.fetchIfRef(resources) || Dict.empty;
  29346. var xobjs = null;
  29347. var xobjsCache = Object.create(null);
  29348. var preprocessor = new EvaluatorPreprocessor(stream, xref, stateManager);
  29349. var textState;
  29350. function ensureTextContentItem() {
  29351. if (textContentItem.initialized) {
  29352. return textContentItem;
  29353. }
  29354. var font = textState.font;
  29355. if (!(font.loadedName in textContent.styles)) {
  29356. textContent.styles[font.loadedName] = {
  29357. fontFamily: font.fallbackName,
  29358. ascent: font.ascent,
  29359. descent: font.descent,
  29360. vertical: font.vertical
  29361. };
  29362. }
  29363. textContentItem.fontName = font.loadedName;
  29364. var tsm = [
  29365. textState.fontSize * textState.textHScale,
  29366. 0,
  29367. 0,
  29368. textState.fontSize,
  29369. 0,
  29370. textState.textRise
  29371. ];
  29372. if (font.isType3Font && textState.fontMatrix !== FONT_IDENTITY_MATRIX && textState.fontSize === 1) {
  29373. var glyphHeight = font.bbox[3] - font.bbox[1];
  29374. if (glyphHeight > 0) {
  29375. glyphHeight = glyphHeight * textState.fontMatrix[3];
  29376. tsm[3] *= glyphHeight;
  29377. }
  29378. }
  29379. var trm = Util.transform(textState.ctm, Util.transform(textState.textMatrix, tsm));
  29380. textContentItem.transform = trm;
  29381. if (!font.vertical) {
  29382. textContentItem.width = 0;
  29383. textContentItem.height = Math.sqrt(trm[2] * trm[2] + trm[3] * trm[3]);
  29384. textContentItem.vertical = false;
  29385. } else {
  29386. textContentItem.width = Math.sqrt(trm[0] * trm[0] + trm[1] * trm[1]);
  29387. textContentItem.height = 0;
  29388. textContentItem.vertical = true;
  29389. }
  29390. var a = textState.textLineMatrix[0];
  29391. var b = textState.textLineMatrix[1];
  29392. var scaleLineX = Math.sqrt(a * a + b * b);
  29393. a = textState.ctm[0];
  29394. b = textState.ctm[1];
  29395. var scaleCtmX = Math.sqrt(a * a + b * b);
  29396. textContentItem.textAdvanceScale = scaleCtmX * scaleLineX;
  29397. textContentItem.lastAdvanceWidth = 0;
  29398. textContentItem.lastAdvanceHeight = 0;
  29399. var spaceWidth = font.spaceWidth / 1000 * textState.fontSize;
  29400. if (spaceWidth) {
  29401. textContentItem.spaceWidth = spaceWidth;
  29402. textContentItem.fakeSpaceMin = spaceWidth * SPACE_FACTOR;
  29403. textContentItem.fakeMultiSpaceMin = spaceWidth * MULTI_SPACE_FACTOR;
  29404. textContentItem.fakeMultiSpaceMax = spaceWidth * MULTI_SPACE_FACTOR_MAX;
  29405. textContentItem.textRunBreakAllowed = !font.isMonospace;
  29406. } else {
  29407. textContentItem.spaceWidth = 0;
  29408. textContentItem.fakeSpaceMin = Infinity;
  29409. textContentItem.fakeMultiSpaceMin = Infinity;
  29410. textContentItem.fakeMultiSpaceMax = 0;
  29411. textContentItem.textRunBreakAllowed = false;
  29412. }
  29413. textContentItem.initialized = true;
  29414. return textContentItem;
  29415. }
  29416. function replaceWhitespace(str) {
  29417. var i = 0, ii = str.length, code;
  29418. while (i < ii && (code = str.charCodeAt(i)) >= 0x20 && code <= 0x7F) {
  29419. i++;
  29420. }
  29421. return i < ii ? str.replace(WhitespaceRegexp, ' ') : str;
  29422. }
  29423. function runBidiTransform(textChunk) {
  29424. var str = textChunk.str.join('');
  29425. var bidiResult = bidi(str, -1, textChunk.vertical);
  29426. return {
  29427. str: normalizeWhitespace ? replaceWhitespace(bidiResult.str) : bidiResult.str,
  29428. dir: bidiResult.dir,
  29429. width: textChunk.width,
  29430. height: textChunk.height,
  29431. transform: textChunk.transform,
  29432. fontName: textChunk.fontName
  29433. };
  29434. }
  29435. function handleSetFont(fontName, fontRef) {
  29436. return self.loadFont(fontName, fontRef, xref, resources).then(function (translated) {
  29437. textState.font = translated.font;
  29438. textState.fontMatrix = translated.font.fontMatrix || FONT_IDENTITY_MATRIX;
  29439. });
  29440. }
  29441. function buildTextContentItem(chars) {
  29442. var font = textState.font;
  29443. var textChunk = ensureTextContentItem();
  29444. var width = 0;
  29445. var height = 0;
  29446. var glyphs = font.charsToGlyphs(chars);
  29447. for (var i = 0; i < glyphs.length; i++) {
  29448. var glyph = glyphs[i];
  29449. var glyphWidth = null;
  29450. if (font.vertical && glyph.vmetric) {
  29451. glyphWidth = glyph.vmetric[0];
  29452. } else {
  29453. glyphWidth = glyph.width;
  29454. }
  29455. var glyphUnicode = glyph.unicode;
  29456. var NormalizedUnicodes = getNormalizedUnicodes();
  29457. if (NormalizedUnicodes[glyphUnicode] !== undefined) {
  29458. glyphUnicode = NormalizedUnicodes[glyphUnicode];
  29459. }
  29460. glyphUnicode = reverseIfRtl(glyphUnicode);
  29461. var charSpacing = textState.charSpacing;
  29462. if (glyph.isSpace) {
  29463. var wordSpacing = textState.wordSpacing;
  29464. charSpacing += wordSpacing;
  29465. if (wordSpacing > 0) {
  29466. addFakeSpaces(wordSpacing, textChunk.str);
  29467. }
  29468. }
  29469. var tx = 0;
  29470. var ty = 0;
  29471. if (!font.vertical) {
  29472. var w0 = glyphWidth * textState.fontMatrix[0];
  29473. tx = (w0 * textState.fontSize + charSpacing) * textState.textHScale;
  29474. width += tx;
  29475. } else {
  29476. var w1 = glyphWidth * textState.fontMatrix[0];
  29477. ty = w1 * textState.fontSize + charSpacing;
  29478. height += ty;
  29479. }
  29480. textState.translateTextMatrix(tx, ty);
  29481. textChunk.str.push(glyphUnicode);
  29482. }
  29483. if (!font.vertical) {
  29484. textChunk.lastAdvanceWidth = width;
  29485. textChunk.width += width;
  29486. } else {
  29487. textChunk.lastAdvanceHeight = height;
  29488. textChunk.height += Math.abs(height);
  29489. }
  29490. return textChunk;
  29491. }
  29492. function addFakeSpaces(width, strBuf) {
  29493. if (width < textContentItem.fakeSpaceMin) {
  29494. return;
  29495. }
  29496. if (width < textContentItem.fakeMultiSpaceMin) {
  29497. strBuf.push(' ');
  29498. return;
  29499. }
  29500. var fakeSpaces = Math.round(width / textContentItem.spaceWidth);
  29501. while (fakeSpaces-- > 0) {
  29502. strBuf.push(' ');
  29503. }
  29504. }
  29505. function flushTextContentItem() {
  29506. if (!textContentItem.initialized) {
  29507. return;
  29508. }
  29509. textContentItem.width *= textContentItem.textAdvanceScale;
  29510. textContentItem.height *= textContentItem.textAdvanceScale;
  29511. textContent.items.push(runBidiTransform(textContentItem));
  29512. textContentItem.initialized = false;
  29513. textContentItem.str.length = 0;
  29514. }
  29515. var timeSlotManager = new TimeSlotManager();
  29516. return new Promise(function promiseBody(resolve, reject) {
  29517. var next = function (promise) {
  29518. promise.then(function () {
  29519. try {
  29520. promiseBody(resolve, reject);
  29521. } catch (ex) {
  29522. reject(ex);
  29523. }
  29524. }, reject);
  29525. };
  29526. task.ensureNotTerminated();
  29527. timeSlotManager.reset();
  29528. var stop, operation = {}, args = [];
  29529. while (!(stop = timeSlotManager.check())) {
  29530. args.length = 0;
  29531. operation.args = args;
  29532. if (!preprocessor.read(operation)) {
  29533. break;
  29534. }
  29535. textState = stateManager.state;
  29536. var fn = operation.fn;
  29537. args = operation.args;
  29538. var advance, diff;
  29539. switch (fn | 0) {
  29540. case OPS.setFont:
  29541. var fontNameArg = args[0].name, fontSizeArg = args[1];
  29542. if (textState.font && fontNameArg === textState.fontName && fontSizeArg === textState.fontSize) {
  29543. break;
  29544. }
  29545. flushTextContentItem();
  29546. textState.fontName = fontNameArg;
  29547. textState.fontSize = fontSizeArg;
  29548. next(handleSetFont(fontNameArg, null));
  29549. return;
  29550. case OPS.setTextRise:
  29551. flushTextContentItem();
  29552. textState.textRise = args[0];
  29553. break;
  29554. case OPS.setHScale:
  29555. flushTextContentItem();
  29556. textState.textHScale = args[0] / 100;
  29557. break;
  29558. case OPS.setLeading:
  29559. flushTextContentItem();
  29560. textState.leading = args[0];
  29561. break;
  29562. case OPS.moveText:
  29563. var isSameTextLine = !textState.font ? false : (textState.font.vertical ? args[0] : args[1]) === 0;
  29564. advance = args[0] - args[1];
  29565. if (combineTextItems && isSameTextLine && textContentItem.initialized && advance > 0 && advance <= textContentItem.fakeMultiSpaceMax) {
  29566. textState.translateTextLineMatrix(args[0], args[1]);
  29567. textContentItem.width += args[0] - textContentItem.lastAdvanceWidth;
  29568. textContentItem.height += args[1] - textContentItem.lastAdvanceHeight;
  29569. diff = args[0] - textContentItem.lastAdvanceWidth - (args[1] - textContentItem.lastAdvanceHeight);
  29570. addFakeSpaces(diff, textContentItem.str);
  29571. break;
  29572. }
  29573. flushTextContentItem();
  29574. textState.translateTextLineMatrix(args[0], args[1]);
  29575. textState.textMatrix = textState.textLineMatrix.slice();
  29576. break;
  29577. case OPS.setLeadingMoveText:
  29578. flushTextContentItem();
  29579. textState.leading = -args[1];
  29580. textState.translateTextLineMatrix(args[0], args[1]);
  29581. textState.textMatrix = textState.textLineMatrix.slice();
  29582. break;
  29583. case OPS.nextLine:
  29584. flushTextContentItem();
  29585. textState.carriageReturn();
  29586. break;
  29587. case OPS.setTextMatrix:
  29588. advance = textState.calcTextLineMatrixAdvance(args[0], args[1], args[2], args[3], args[4], args[5]);
  29589. if (combineTextItems && advance !== null && textContentItem.initialized && advance.value > 0 && advance.value <= textContentItem.fakeMultiSpaceMax) {
  29590. textState.translateTextLineMatrix(advance.width, advance.height);
  29591. textContentItem.width += advance.width - textContentItem.lastAdvanceWidth;
  29592. textContentItem.height += advance.height - textContentItem.lastAdvanceHeight;
  29593. diff = advance.width - textContentItem.lastAdvanceWidth - (advance.height - textContentItem.lastAdvanceHeight);
  29594. addFakeSpaces(diff, textContentItem.str);
  29595. break;
  29596. }
  29597. flushTextContentItem();
  29598. textState.setTextMatrix(args[0], args[1], args[2], args[3], args[4], args[5]);
  29599. textState.setTextLineMatrix(args[0], args[1], args[2], args[3], args[4], args[5]);
  29600. break;
  29601. case OPS.setCharSpacing:
  29602. textState.charSpacing = args[0];
  29603. break;
  29604. case OPS.setWordSpacing:
  29605. textState.wordSpacing = args[0];
  29606. break;
  29607. case OPS.beginText:
  29608. flushTextContentItem();
  29609. textState.textMatrix = IDENTITY_MATRIX.slice();
  29610. textState.textLineMatrix = IDENTITY_MATRIX.slice();
  29611. break;
  29612. case OPS.showSpacedText:
  29613. var items = args[0];
  29614. var offset;
  29615. for (var j = 0, jj = items.length; j < jj; j++) {
  29616. if (typeof items[j] === 'string') {
  29617. buildTextContentItem(items[j]);
  29618. } else if (isNum(items[j])) {
  29619. ensureTextContentItem();
  29620. advance = items[j] * textState.fontSize / 1000;
  29621. var breakTextRun = false;
  29622. if (textState.font.vertical) {
  29623. offset = advance;
  29624. textState.translateTextMatrix(0, offset);
  29625. breakTextRun = textContentItem.textRunBreakAllowed && advance > textContentItem.fakeMultiSpaceMax;
  29626. if (!breakTextRun) {
  29627. textContentItem.height += offset;
  29628. }
  29629. } else {
  29630. advance = -advance;
  29631. offset = advance * textState.textHScale;
  29632. textState.translateTextMatrix(offset, 0);
  29633. breakTextRun = textContentItem.textRunBreakAllowed && advance > textContentItem.fakeMultiSpaceMax;
  29634. if (!breakTextRun) {
  29635. textContentItem.width += offset;
  29636. }
  29637. }
  29638. if (breakTextRun) {
  29639. flushTextContentItem();
  29640. } else if (advance > 0) {
  29641. addFakeSpaces(advance, textContentItem.str);
  29642. }
  29643. }
  29644. }
  29645. break;
  29646. case OPS.showText:
  29647. buildTextContentItem(args[0]);
  29648. break;
  29649. case OPS.nextLineShowText:
  29650. flushTextContentItem();
  29651. textState.carriageReturn();
  29652. buildTextContentItem(args[0]);
  29653. break;
  29654. case OPS.nextLineSetSpacingShowText:
  29655. flushTextContentItem();
  29656. textState.wordSpacing = args[0];
  29657. textState.charSpacing = args[1];
  29658. textState.carriageReturn();
  29659. buildTextContentItem(args[2]);
  29660. break;
  29661. case OPS.paintXObject:
  29662. flushTextContentItem();
  29663. if (args[0].code) {
  29664. break;
  29665. }
  29666. if (!xobjs) {
  29667. xobjs = resources.get('XObject') || Dict.empty;
  29668. }
  29669. var name = args[0].name;
  29670. if (xobjsCache.key === name) {
  29671. if (xobjsCache.texts) {
  29672. Util.appendToArray(textContent.items, xobjsCache.texts.items);
  29673. Util.extendObj(textContent.styles, xobjsCache.texts.styles);
  29674. }
  29675. break;
  29676. }
  29677. var xobj = xobjs.get(name);
  29678. if (!xobj) {
  29679. break;
  29680. }
  29681. assert(isStream(xobj), 'XObject should be a stream');
  29682. var type = xobj.dict.get('Subtype');
  29683. assert(isName(type), 'XObject should have a Name subtype');
  29684. if (type.name !== 'Form') {
  29685. xobjsCache.key = name;
  29686. xobjsCache.texts = null;
  29687. break;
  29688. }
  29689. stateManager.save();
  29690. var matrix = xobj.dict.getArray('Matrix');
  29691. if (isArray(matrix) && matrix.length === 6) {
  29692. stateManager.transform(matrix);
  29693. }
  29694. next(self.getTextContent(xobj, task, xobj.dict.get('Resources') || resources, stateManager, normalizeWhitespace, combineTextItems).then(function (formTextContent) {
  29695. Util.appendToArray(textContent.items, formTextContent.items);
  29696. Util.extendObj(textContent.styles, formTextContent.styles);
  29697. stateManager.restore();
  29698. xobjsCache.key = name;
  29699. xobjsCache.texts = formTextContent;
  29700. }));
  29701. return;
  29702. case OPS.setGState:
  29703. flushTextContentItem();
  29704. var dictName = args[0];
  29705. var extGState = resources.get('ExtGState');
  29706. if (!isDict(extGState) || !isName(dictName)) {
  29707. break;
  29708. }
  29709. var gState = extGState.get(dictName.name);
  29710. if (!isDict(gState)) {
  29711. break;
  29712. }
  29713. var gStateFont = gState.get('Font');
  29714. if (gStateFont) {
  29715. textState.fontName = null;
  29716. textState.fontSize = gStateFont[1];
  29717. next(handleSetFont(null, gStateFont[0]));
  29718. return;
  29719. }
  29720. break;
  29721. }
  29722. }
  29723. if (stop) {
  29724. next(deferred);
  29725. return;
  29726. }
  29727. flushTextContentItem();
  29728. resolve(textContent);
  29729. });
  29730. },
  29731. extractDataStructures: function PartialEvaluator_extractDataStructures(dict, baseDict, xref, properties) {
  29732. var toUnicode = dict.get('ToUnicode') || baseDict.get('ToUnicode');
  29733. var toUnicodePromise = toUnicode ? this.readToUnicode(toUnicode) : Promise.resolve(undefined);
  29734. if (properties.composite) {
  29735. var cidSystemInfo = dict.get('CIDSystemInfo');
  29736. if (isDict(cidSystemInfo)) {
  29737. properties.cidSystemInfo = {
  29738. registry: cidSystemInfo.get('Registry'),
  29739. ordering: cidSystemInfo.get('Ordering'),
  29740. supplement: cidSystemInfo.get('Supplement')
  29741. };
  29742. }
  29743. var cidToGidMap = dict.get('CIDToGIDMap');
  29744. if (isStream(cidToGidMap)) {
  29745. properties.cidToGidMap = this.readCidToGidMap(cidToGidMap);
  29746. }
  29747. }
  29748. var differences = [];
  29749. var baseEncodingName = null;
  29750. var encoding;
  29751. if (dict.has('Encoding')) {
  29752. encoding = dict.get('Encoding');
  29753. if (isDict(encoding)) {
  29754. baseEncodingName = encoding.get('BaseEncoding');
  29755. baseEncodingName = isName(baseEncodingName) ? baseEncodingName.name : null;
  29756. if (encoding.has('Differences')) {
  29757. var diffEncoding = encoding.get('Differences');
  29758. var index = 0;
  29759. for (var j = 0, jj = diffEncoding.length; j < jj; j++) {
  29760. var data = xref.fetchIfRef(diffEncoding[j]);
  29761. if (isNum(data)) {
  29762. index = data;
  29763. } else if (isName(data)) {
  29764. differences[index++] = data.name;
  29765. } else {
  29766. error('Invalid entry in \'Differences\' array: ' + data);
  29767. }
  29768. }
  29769. }
  29770. } else if (isName(encoding)) {
  29771. baseEncodingName = encoding.name;
  29772. } else {
  29773. error('Encoding is not a Name nor a Dict');
  29774. }
  29775. if (baseEncodingName !== 'MacRomanEncoding' && baseEncodingName !== 'MacExpertEncoding' && baseEncodingName !== 'WinAnsiEncoding') {
  29776. baseEncodingName = null;
  29777. }
  29778. }
  29779. if (baseEncodingName) {
  29780. properties.defaultEncoding = getEncoding(baseEncodingName).slice();
  29781. } else {
  29782. var isSymbolicFont = !!(properties.flags & FontFlags.Symbolic);
  29783. var isNonsymbolicFont = !!(properties.flags & FontFlags.Nonsymbolic);
  29784. encoding = StandardEncoding;
  29785. if (properties.type === 'TrueType' && !isNonsymbolicFont) {
  29786. encoding = WinAnsiEncoding;
  29787. }
  29788. if (isSymbolicFont) {
  29789. encoding = MacRomanEncoding;
  29790. if (!properties.file) {
  29791. if (/Symbol/i.test(properties.name)) {
  29792. encoding = SymbolSetEncoding;
  29793. } else if (/Dingbats/i.test(properties.name)) {
  29794. encoding = ZapfDingbatsEncoding;
  29795. }
  29796. }
  29797. }
  29798. properties.defaultEncoding = encoding;
  29799. }
  29800. properties.differences = differences;
  29801. properties.baseEncodingName = baseEncodingName;
  29802. properties.hasEncoding = !!baseEncodingName || differences.length > 0;
  29803. properties.dict = dict;
  29804. return toUnicodePromise.then(function (toUnicode) {
  29805. properties.toUnicode = toUnicode;
  29806. return this.buildToUnicode(properties);
  29807. }.bind(this)).then(function (toUnicode) {
  29808. properties.toUnicode = toUnicode;
  29809. return properties;
  29810. });
  29811. },
  29812. buildToUnicode: function PartialEvaluator_buildToUnicode(properties) {
  29813. properties.hasIncludedToUnicodeMap = !!properties.toUnicode && properties.toUnicode.length > 0;
  29814. if (properties.hasIncludedToUnicodeMap) {
  29815. return Promise.resolve(properties.toUnicode);
  29816. }
  29817. var toUnicode, charcode, glyphName;
  29818. if (!properties.composite) {
  29819. toUnicode = [];
  29820. var encoding = properties.defaultEncoding.slice();
  29821. var baseEncodingName = properties.baseEncodingName;
  29822. var differences = properties.differences;
  29823. for (charcode in differences) {
  29824. glyphName = differences[charcode];
  29825. if (glyphName === '.notdef') {
  29826. continue;
  29827. }
  29828. encoding[charcode] = glyphName;
  29829. }
  29830. var glyphsUnicodeMap = getGlyphsUnicode();
  29831. for (charcode in encoding) {
  29832. glyphName = encoding[charcode];
  29833. if (glyphName === '') {
  29834. continue;
  29835. } else if (glyphsUnicodeMap[glyphName] === undefined) {
  29836. var code = 0;
  29837. switch (glyphName[0]) {
  29838. case 'G':
  29839. if (glyphName.length === 3) {
  29840. code = parseInt(glyphName.substr(1), 16);
  29841. }
  29842. break;
  29843. case 'g':
  29844. if (glyphName.length === 5) {
  29845. code = parseInt(glyphName.substr(1), 16);
  29846. }
  29847. break;
  29848. case 'C':
  29849. case 'c':
  29850. if (glyphName.length >= 3) {
  29851. code = +glyphName.substr(1);
  29852. }
  29853. break;
  29854. default:
  29855. var unicode = getUnicodeForGlyph(glyphName, glyphsUnicodeMap);
  29856. if (unicode !== -1) {
  29857. code = unicode;
  29858. }
  29859. }
  29860. if (code) {
  29861. if (baseEncodingName && code === +charcode) {
  29862. var baseEncoding = getEncoding(baseEncodingName);
  29863. if (baseEncoding && (glyphName = baseEncoding[charcode])) {
  29864. toUnicode[charcode] = String.fromCharCode(glyphsUnicodeMap[glyphName]);
  29865. continue;
  29866. }
  29867. }
  29868. toUnicode[charcode] = String.fromCharCode(code);
  29869. }
  29870. continue;
  29871. }
  29872. toUnicode[charcode] = String.fromCharCode(glyphsUnicodeMap[glyphName]);
  29873. }
  29874. return Promise.resolve(new ToUnicodeMap(toUnicode));
  29875. }
  29876. 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'))) {
  29877. var registry = properties.cidSystemInfo.registry;
  29878. var ordering = properties.cidSystemInfo.ordering;
  29879. var ucs2CMapName = Name.get(registry + '-' + ordering + '-UCS2');
  29880. return CMapFactory.create({
  29881. encoding: ucs2CMapName,
  29882. fetchBuiltInCMap: this.fetchBuiltInCMap,
  29883. useCMap: null
  29884. }).then(function (ucs2CMap) {
  29885. var cMap = properties.cMap;
  29886. toUnicode = [];
  29887. cMap.forEach(function (charcode, cid) {
  29888. assert(cid <= 0xffff, 'Max size of CID is 65,535');
  29889. var ucs2 = ucs2CMap.lookup(cid);
  29890. if (ucs2) {
  29891. toUnicode[charcode] = String.fromCharCode((ucs2.charCodeAt(0) << 8) + ucs2.charCodeAt(1));
  29892. }
  29893. });
  29894. return new ToUnicodeMap(toUnicode);
  29895. });
  29896. }
  29897. return Promise.resolve(new IdentityToUnicodeMap(properties.firstChar, properties.lastChar));
  29898. },
  29899. readToUnicode: function PartialEvaluator_readToUnicode(toUnicode) {
  29900. var cmapObj = toUnicode;
  29901. if (isName(cmapObj)) {
  29902. return CMapFactory.create({
  29903. encoding: cmapObj,
  29904. fetchBuiltInCMap: this.fetchBuiltInCMap,
  29905. useCMap: null
  29906. }).then(function (cmap) {
  29907. if (cmap instanceof IdentityCMap) {
  29908. return new IdentityToUnicodeMap(0, 0xFFFF);
  29909. }
  29910. return new ToUnicodeMap(cmap.getMap());
  29911. });
  29912. } else if (isStream(cmapObj)) {
  29913. return CMapFactory.create({
  29914. encoding: cmapObj,
  29915. fetchBuiltInCMap: this.fetchBuiltInCMap,
  29916. useCMap: null
  29917. }).then(function (cmap) {
  29918. if (cmap instanceof IdentityCMap) {
  29919. return new IdentityToUnicodeMap(0, 0xFFFF);
  29920. }
  29921. var map = new Array(cmap.length);
  29922. cmap.forEach(function (charCode, token) {
  29923. var str = [];
  29924. for (var k = 0; k < token.length; k += 2) {
  29925. var w1 = token.charCodeAt(k) << 8 | token.charCodeAt(k + 1);
  29926. if ((w1 & 0xF800) !== 0xD800) {
  29927. str.push(w1);
  29928. continue;
  29929. }
  29930. k += 2;
  29931. var w2 = token.charCodeAt(k) << 8 | token.charCodeAt(k + 1);
  29932. str.push(((w1 & 0x3ff) << 10) + (w2 & 0x3ff) + 0x10000);
  29933. }
  29934. map[charCode] = String.fromCharCode.apply(String, str);
  29935. });
  29936. return new ToUnicodeMap(map);
  29937. });
  29938. }
  29939. return Promise.resolve(null);
  29940. },
  29941. readCidToGidMap: function PartialEvaluator_readCidToGidMap(cidToGidStream) {
  29942. var glyphsData = cidToGidStream.getBytes();
  29943. var result = [];
  29944. for (var j = 0, jj = glyphsData.length; j < jj; j++) {
  29945. var glyphID = glyphsData[j++] << 8 | glyphsData[j];
  29946. if (glyphID === 0) {
  29947. continue;
  29948. }
  29949. var code = j >> 1;
  29950. result[code] = glyphID;
  29951. }
  29952. return result;
  29953. },
  29954. extractWidths: function PartialEvaluator_extractWidths(dict, xref, descriptor, properties) {
  29955. var glyphsWidths = [];
  29956. var defaultWidth = 0;
  29957. var glyphsVMetrics = [];
  29958. var defaultVMetrics;
  29959. var i, ii, j, jj, start, code, widths;
  29960. if (properties.composite) {
  29961. defaultWidth = dict.get('DW') || 1000;
  29962. widths = dict.get('W');
  29963. if (widths) {
  29964. for (i = 0, ii = widths.length; i < ii; i++) {
  29965. start = xref.fetchIfRef(widths[i++]);
  29966. code = xref.fetchIfRef(widths[i]);
  29967. if (isArray(code)) {
  29968. for (j = 0, jj = code.length; j < jj; j++) {
  29969. glyphsWidths[start++] = xref.fetchIfRef(code[j]);
  29970. }
  29971. } else {
  29972. var width = xref.fetchIfRef(widths[++i]);
  29973. for (j = start; j <= code; j++) {
  29974. glyphsWidths[j] = width;
  29975. }
  29976. }
  29977. }
  29978. }
  29979. if (properties.vertical) {
  29980. var vmetrics = dict.getArray('DW2') || [
  29981. 880,
  29982. -1000
  29983. ];
  29984. defaultVMetrics = [
  29985. vmetrics[1],
  29986. defaultWidth * 0.5,
  29987. vmetrics[0]
  29988. ];
  29989. vmetrics = dict.get('W2');
  29990. if (vmetrics) {
  29991. for (i = 0, ii = vmetrics.length; i < ii; i++) {
  29992. start = xref.fetchIfRef(vmetrics[i++]);
  29993. code = xref.fetchIfRef(vmetrics[i]);
  29994. if (isArray(code)) {
  29995. for (j = 0, jj = code.length; j < jj; j++) {
  29996. glyphsVMetrics[start++] = [
  29997. xref.fetchIfRef(code[j++]),
  29998. xref.fetchIfRef(code[j++]),
  29999. xref.fetchIfRef(code[j])
  30000. ];
  30001. }
  30002. } else {
  30003. var vmetric = [
  30004. xref.fetchIfRef(vmetrics[++i]),
  30005. xref.fetchIfRef(vmetrics[++i]),
  30006. xref.fetchIfRef(vmetrics[++i])
  30007. ];
  30008. for (j = start; j <= code; j++) {
  30009. glyphsVMetrics[j] = vmetric;
  30010. }
  30011. }
  30012. }
  30013. }
  30014. }
  30015. } else {
  30016. var firstChar = properties.firstChar;
  30017. widths = dict.get('Widths');
  30018. if (widths) {
  30019. j = firstChar;
  30020. for (i = 0, ii = widths.length; i < ii; i++) {
  30021. glyphsWidths[j++] = xref.fetchIfRef(widths[i]);
  30022. }
  30023. defaultWidth = parseFloat(descriptor.get('MissingWidth')) || 0;
  30024. } else {
  30025. var baseFontName = dict.get('BaseFont');
  30026. if (isName(baseFontName)) {
  30027. var metrics = this.getBaseFontMetrics(baseFontName.name);
  30028. glyphsWidths = this.buildCharCodeToWidth(metrics.widths, properties);
  30029. defaultWidth = metrics.defaultWidth;
  30030. }
  30031. }
  30032. }
  30033. var isMonospace = true;
  30034. var firstWidth = defaultWidth;
  30035. for (var glyph in glyphsWidths) {
  30036. var glyphWidth = glyphsWidths[glyph];
  30037. if (!glyphWidth) {
  30038. continue;
  30039. }
  30040. if (!firstWidth) {
  30041. firstWidth = glyphWidth;
  30042. continue;
  30043. }
  30044. if (firstWidth !== glyphWidth) {
  30045. isMonospace = false;
  30046. break;
  30047. }
  30048. }
  30049. if (isMonospace) {
  30050. properties.flags |= FontFlags.FixedPitch;
  30051. }
  30052. properties.defaultWidth = defaultWidth;
  30053. properties.widths = glyphsWidths;
  30054. properties.defaultVMetrics = defaultVMetrics;
  30055. properties.vmetrics = glyphsVMetrics;
  30056. },
  30057. isSerifFont: function PartialEvaluator_isSerifFont(baseFontName) {
  30058. var fontNameWoStyle = baseFontName.split('-')[0];
  30059. return fontNameWoStyle in getSerifFonts() || fontNameWoStyle.search(/serif/gi) !== -1;
  30060. },
  30061. getBaseFontMetrics: function PartialEvaluator_getBaseFontMetrics(name) {
  30062. var defaultWidth = 0;
  30063. var widths = [];
  30064. var monospace = false;
  30065. var stdFontMap = getStdFontMap();
  30066. var lookupName = stdFontMap[name] || name;
  30067. var Metrics = getMetrics();
  30068. if (!(lookupName in Metrics)) {
  30069. if (this.isSerifFont(name)) {
  30070. lookupName = 'Times-Roman';
  30071. } else {
  30072. lookupName = 'Helvetica';
  30073. }
  30074. }
  30075. var glyphWidths = Metrics[lookupName];
  30076. if (isNum(glyphWidths)) {
  30077. defaultWidth = glyphWidths;
  30078. monospace = true;
  30079. } else {
  30080. widths = glyphWidths();
  30081. }
  30082. return {
  30083. defaultWidth: defaultWidth,
  30084. monospace: monospace,
  30085. widths: widths
  30086. };
  30087. },
  30088. buildCharCodeToWidth: function PartialEvaluator_bulildCharCodeToWidth(widthsByGlyphName, properties) {
  30089. var widths = Object.create(null);
  30090. var differences = properties.differences;
  30091. var encoding = properties.defaultEncoding;
  30092. for (var charCode = 0; charCode < 256; charCode++) {
  30093. if (charCode in differences && widthsByGlyphName[differences[charCode]]) {
  30094. widths[charCode] = widthsByGlyphName[differences[charCode]];
  30095. continue;
  30096. }
  30097. if (charCode in encoding && widthsByGlyphName[encoding[charCode]]) {
  30098. widths[charCode] = widthsByGlyphName[encoding[charCode]];
  30099. continue;
  30100. }
  30101. }
  30102. return widths;
  30103. },
  30104. preEvaluateFont: function PartialEvaluator_preEvaluateFont(dict, xref) {
  30105. var baseDict = dict;
  30106. var type = dict.get('Subtype');
  30107. assert(isName(type), 'invalid font Subtype');
  30108. var composite = false;
  30109. var uint8array;
  30110. if (type.name === 'Type0') {
  30111. var df = dict.get('DescendantFonts');
  30112. if (!df) {
  30113. error('Descendant fonts are not specified');
  30114. }
  30115. dict = isArray(df) ? xref.fetchIfRef(df[0]) : df;
  30116. type = dict.get('Subtype');
  30117. assert(isName(type), 'invalid font Subtype');
  30118. composite = true;
  30119. }
  30120. var descriptor = dict.get('FontDescriptor');
  30121. if (descriptor) {
  30122. var hash = new MurmurHash3_64();
  30123. var encoding = baseDict.getRaw('Encoding');
  30124. if (isName(encoding)) {
  30125. hash.update(encoding.name);
  30126. } else if (isRef(encoding)) {
  30127. hash.update(encoding.toString());
  30128. } else if (isDict(encoding)) {
  30129. var keys = encoding.getKeys();
  30130. for (var i = 0, ii = keys.length; i < ii; i++) {
  30131. var entry = encoding.getRaw(keys[i]);
  30132. if (isName(entry)) {
  30133. hash.update(entry.name);
  30134. } else if (isRef(entry)) {
  30135. hash.update(entry.toString());
  30136. } else if (isArray(entry)) {
  30137. var diffLength = entry.length, diffBuf = new Array(diffLength);
  30138. for (var j = 0; j < diffLength; j++) {
  30139. var diffEntry = entry[j];
  30140. if (isName(diffEntry)) {
  30141. diffBuf[j] = diffEntry.name;
  30142. } else if (isNum(diffEntry) || isRef(diffEntry)) {
  30143. diffBuf[j] = diffEntry.toString();
  30144. }
  30145. }
  30146. hash.update(diffBuf.join());
  30147. }
  30148. }
  30149. }
  30150. var toUnicode = dict.get('ToUnicode') || baseDict.get('ToUnicode');
  30151. if (isStream(toUnicode)) {
  30152. var stream = toUnicode.str || toUnicode;
  30153. uint8array = stream.buffer ? new Uint8Array(stream.buffer.buffer, 0, stream.bufferLength) : new Uint8Array(stream.bytes.buffer, stream.start, stream.end - stream.start);
  30154. hash.update(uint8array);
  30155. } else if (isName(toUnicode)) {
  30156. hash.update(toUnicode.name);
  30157. }
  30158. var widths = dict.get('Widths') || baseDict.get('Widths');
  30159. if (widths) {
  30160. uint8array = new Uint8Array(new Uint32Array(widths).buffer);
  30161. hash.update(uint8array);
  30162. }
  30163. }
  30164. return {
  30165. descriptor: descriptor,
  30166. dict: dict,
  30167. baseDict: baseDict,
  30168. composite: composite,
  30169. type: type.name,
  30170. hash: hash ? hash.hexdigest() : ''
  30171. };
  30172. },
  30173. translateFont: function PartialEvaluator_translateFont(preEvaluatedFont, xref) {
  30174. var baseDict = preEvaluatedFont.baseDict;
  30175. var dict = preEvaluatedFont.dict;
  30176. var composite = preEvaluatedFont.composite;
  30177. var descriptor = preEvaluatedFont.descriptor;
  30178. var type = preEvaluatedFont.type;
  30179. var maxCharIndex = composite ? 0xFFFF : 0xFF;
  30180. var properties;
  30181. if (!descriptor) {
  30182. if (type === 'Type3') {
  30183. descriptor = new Dict(null);
  30184. descriptor.set('FontName', Name.get(type));
  30185. descriptor.set('FontBBox', dict.getArray('FontBBox'));
  30186. } else {
  30187. var baseFontName = dict.get('BaseFont');
  30188. if (!isName(baseFontName)) {
  30189. error('Base font is not specified');
  30190. }
  30191. baseFontName = baseFontName.name.replace(/[,_]/g, '-');
  30192. var metrics = this.getBaseFontMetrics(baseFontName);
  30193. var fontNameWoStyle = baseFontName.split('-')[0];
  30194. var flags = (this.isSerifFont(fontNameWoStyle) ? FontFlags.Serif : 0) | (metrics.monospace ? FontFlags.FixedPitch : 0) | (getSymbolsFonts()[fontNameWoStyle] ? FontFlags.Symbolic : FontFlags.Nonsymbolic);
  30195. properties = {
  30196. type: type,
  30197. name: baseFontName,
  30198. widths: metrics.widths,
  30199. defaultWidth: metrics.defaultWidth,
  30200. flags: flags,
  30201. firstChar: 0,
  30202. lastChar: maxCharIndex
  30203. };
  30204. return this.extractDataStructures(dict, dict, xref, properties).then(function (properties) {
  30205. properties.widths = this.buildCharCodeToWidth(metrics.widths, properties);
  30206. return new Font(baseFontName, null, properties);
  30207. }.bind(this));
  30208. }
  30209. }
  30210. var firstChar = dict.get('FirstChar') || 0;
  30211. var lastChar = dict.get('LastChar') || maxCharIndex;
  30212. var fontName = descriptor.get('FontName');
  30213. var baseFont = dict.get('BaseFont');
  30214. if (isString(fontName)) {
  30215. fontName = Name.get(fontName);
  30216. }
  30217. if (isString(baseFont)) {
  30218. baseFont = Name.get(baseFont);
  30219. }
  30220. if (type !== 'Type3') {
  30221. var fontNameStr = fontName && fontName.name;
  30222. var baseFontStr = baseFont && baseFont.name;
  30223. if (fontNameStr !== baseFontStr) {
  30224. info('The FontDescriptor\'s FontName is "' + fontNameStr + '" but should be the same as the Font\'s BaseFont "' + baseFontStr + '"');
  30225. if (fontNameStr && baseFontStr && baseFontStr.indexOf(fontNameStr) === 0) {
  30226. fontName = baseFont;
  30227. }
  30228. }
  30229. }
  30230. fontName = fontName || baseFont;
  30231. assert(isName(fontName), 'invalid font name');
  30232. var fontFile = descriptor.get('FontFile', 'FontFile2', 'FontFile3');
  30233. if (fontFile) {
  30234. if (fontFile.dict) {
  30235. var subtype = fontFile.dict.get('Subtype');
  30236. if (subtype) {
  30237. subtype = subtype.name;
  30238. }
  30239. var length1 = fontFile.dict.get('Length1');
  30240. var length2 = fontFile.dict.get('Length2');
  30241. var length3 = fontFile.dict.get('Length3');
  30242. }
  30243. }
  30244. properties = {
  30245. type: type,
  30246. name: fontName.name,
  30247. subtype: subtype,
  30248. file: fontFile,
  30249. length1: length1,
  30250. length2: length2,
  30251. length3: length3,
  30252. loadedName: baseDict.loadedName,
  30253. composite: composite,
  30254. wideChars: composite,
  30255. fixedPitch: false,
  30256. fontMatrix: dict.getArray('FontMatrix') || FONT_IDENTITY_MATRIX,
  30257. firstChar: firstChar || 0,
  30258. lastChar: lastChar || maxCharIndex,
  30259. bbox: descriptor.getArray('FontBBox'),
  30260. ascent: descriptor.get('Ascent'),
  30261. descent: descriptor.get('Descent'),
  30262. xHeight: descriptor.get('XHeight'),
  30263. capHeight: descriptor.get('CapHeight'),
  30264. flags: descriptor.get('Flags'),
  30265. italicAngle: descriptor.get('ItalicAngle'),
  30266. coded: false
  30267. };
  30268. var cMapPromise;
  30269. if (composite) {
  30270. var cidEncoding = baseDict.get('Encoding');
  30271. if (isName(cidEncoding)) {
  30272. properties.cidEncoding = cidEncoding.name;
  30273. }
  30274. cMapPromise = CMapFactory.create({
  30275. encoding: cidEncoding,
  30276. fetchBuiltInCMap: this.fetchBuiltInCMap,
  30277. useCMap: null
  30278. }).then(function (cMap) {
  30279. properties.cMap = cMap;
  30280. properties.vertical = properties.cMap.vertical;
  30281. });
  30282. } else {
  30283. cMapPromise = Promise.resolve(undefined);
  30284. }
  30285. return cMapPromise.then(function () {
  30286. return this.extractDataStructures(dict, baseDict, xref, properties);
  30287. }.bind(this)).then(function (properties) {
  30288. this.extractWidths(dict, xref, descriptor, properties);
  30289. if (type === 'Type3') {
  30290. properties.isType3Font = true;
  30291. }
  30292. return new Font(fontName.name, fontFile, properties);
  30293. }.bind(this));
  30294. }
  30295. };
  30296. return PartialEvaluator;
  30297. }();
  30298. var TranslatedFont = function TranslatedFontClosure() {
  30299. function TranslatedFont(loadedName, font, dict) {
  30300. this.loadedName = loadedName;
  30301. this.font = font;
  30302. this.dict = dict;
  30303. this.type3Loaded = null;
  30304. this.sent = false;
  30305. }
  30306. TranslatedFont.prototype = {
  30307. send: function (handler) {
  30308. if (this.sent) {
  30309. return;
  30310. }
  30311. var fontData = this.font.exportData();
  30312. handler.send('commonobj', [
  30313. this.loadedName,
  30314. 'Font',
  30315. fontData
  30316. ]);
  30317. this.sent = true;
  30318. },
  30319. loadType3Data: function (evaluator, resources, parentOperatorList, task) {
  30320. assert(this.font.isType3Font);
  30321. if (this.type3Loaded) {
  30322. return this.type3Loaded;
  30323. }
  30324. var translatedFont = this.font;
  30325. var loadCharProcsPromise = Promise.resolve();
  30326. var charProcs = this.dict.get('CharProcs');
  30327. var fontResources = this.dict.get('Resources') || resources;
  30328. var charProcKeys = charProcs.getKeys();
  30329. var charProcOperatorList = Object.create(null);
  30330. for (var i = 0, n = charProcKeys.length; i < n; ++i) {
  30331. loadCharProcsPromise = loadCharProcsPromise.then(function (key) {
  30332. var glyphStream = charProcs.get(key);
  30333. var operatorList = new OperatorList();
  30334. return evaluator.getOperatorList(glyphStream, task, fontResources, operatorList).then(function () {
  30335. charProcOperatorList[key] = operatorList.getIR();
  30336. parentOperatorList.addDependencies(operatorList.dependencies);
  30337. }, function (reason) {
  30338. warn('Type3 font resource \"' + key + '\" is not available');
  30339. var operatorList = new OperatorList();
  30340. charProcOperatorList[key] = operatorList.getIR();
  30341. });
  30342. }.bind(this, charProcKeys[i]));
  30343. }
  30344. this.type3Loaded = loadCharProcsPromise.then(function () {
  30345. translatedFont.charProcOperatorList = charProcOperatorList;
  30346. });
  30347. return this.type3Loaded;
  30348. }
  30349. };
  30350. return TranslatedFont;
  30351. }();
  30352. var OperatorList = function OperatorListClosure() {
  30353. var CHUNK_SIZE = 1000;
  30354. var CHUNK_SIZE_ABOUT = CHUNK_SIZE - 5;
  30355. function getTransfers(queue) {
  30356. var transfers = [];
  30357. var fnArray = queue.fnArray, argsArray = queue.argsArray;
  30358. for (var i = 0, ii = queue.length; i < ii; i++) {
  30359. switch (fnArray[i]) {
  30360. case OPS.paintInlineImageXObject:
  30361. case OPS.paintInlineImageXObjectGroup:
  30362. case OPS.paintImageMaskXObject:
  30363. var arg = argsArray[i][0];
  30364. if (!arg.cached) {
  30365. transfers.push(arg.data.buffer);
  30366. }
  30367. break;
  30368. }
  30369. }
  30370. return transfers;
  30371. }
  30372. function OperatorList(intent, messageHandler, pageIndex) {
  30373. this.messageHandler = messageHandler;
  30374. this.fnArray = [];
  30375. this.argsArray = [];
  30376. this.dependencies = Object.create(null);
  30377. this._totalLength = 0;
  30378. this.pageIndex = pageIndex;
  30379. this.intent = intent;
  30380. }
  30381. OperatorList.prototype = {
  30382. get length() {
  30383. return this.argsArray.length;
  30384. },
  30385. get totalLength() {
  30386. return this._totalLength + this.length;
  30387. },
  30388. addOp: function (fn, args) {
  30389. this.fnArray.push(fn);
  30390. this.argsArray.push(args);
  30391. if (this.messageHandler) {
  30392. if (this.fnArray.length >= CHUNK_SIZE) {
  30393. this.flush();
  30394. } else if (this.fnArray.length >= CHUNK_SIZE_ABOUT && (fn === OPS.restore || fn === OPS.endText)) {
  30395. this.flush();
  30396. }
  30397. }
  30398. },
  30399. addDependency: function (dependency) {
  30400. if (dependency in this.dependencies) {
  30401. return;
  30402. }
  30403. this.dependencies[dependency] = true;
  30404. this.addOp(OPS.dependency, [dependency]);
  30405. },
  30406. addDependencies: function (dependencies) {
  30407. for (var key in dependencies) {
  30408. this.addDependency(key);
  30409. }
  30410. },
  30411. addOpList: function (opList) {
  30412. Util.extendObj(this.dependencies, opList.dependencies);
  30413. for (var i = 0, ii = opList.length; i < ii; i++) {
  30414. this.addOp(opList.fnArray[i], opList.argsArray[i]);
  30415. }
  30416. },
  30417. getIR: function () {
  30418. return {
  30419. fnArray: this.fnArray,
  30420. argsArray: this.argsArray,
  30421. length: this.length
  30422. };
  30423. },
  30424. flush: function (lastChunk) {
  30425. if (this.intent !== 'oplist') {
  30426. new QueueOptimizer().optimize(this);
  30427. }
  30428. var transfers = getTransfers(this);
  30429. var length = this.length;
  30430. this._totalLength += length;
  30431. this.messageHandler.send('RenderPageChunk', {
  30432. operatorList: {
  30433. fnArray: this.fnArray,
  30434. argsArray: this.argsArray,
  30435. lastChunk: lastChunk,
  30436. length: length
  30437. },
  30438. pageIndex: this.pageIndex,
  30439. intent: this.intent
  30440. }, transfers);
  30441. this.dependencies = Object.create(null);
  30442. this.fnArray.length = 0;
  30443. this.argsArray.length = 0;
  30444. }
  30445. };
  30446. return OperatorList;
  30447. }();
  30448. var StateManager = function StateManagerClosure() {
  30449. function StateManager(initialState) {
  30450. this.state = initialState;
  30451. this.stateStack = [];
  30452. }
  30453. StateManager.prototype = {
  30454. save: function () {
  30455. var old = this.state;
  30456. this.stateStack.push(this.state);
  30457. this.state = old.clone();
  30458. },
  30459. restore: function () {
  30460. var prev = this.stateStack.pop();
  30461. if (prev) {
  30462. this.state = prev;
  30463. }
  30464. },
  30465. transform: function (args) {
  30466. this.state.ctm = Util.transform(this.state.ctm, args);
  30467. }
  30468. };
  30469. return StateManager;
  30470. }();
  30471. var TextState = function TextStateClosure() {
  30472. function TextState() {
  30473. this.ctm = new Float32Array(IDENTITY_MATRIX);
  30474. this.fontName = null;
  30475. this.fontSize = 0;
  30476. this.font = null;
  30477. this.fontMatrix = FONT_IDENTITY_MATRIX;
  30478. this.textMatrix = IDENTITY_MATRIX.slice();
  30479. this.textLineMatrix = IDENTITY_MATRIX.slice();
  30480. this.charSpacing = 0;
  30481. this.wordSpacing = 0;
  30482. this.leading = 0;
  30483. this.textHScale = 1;
  30484. this.textRise = 0;
  30485. }
  30486. TextState.prototype = {
  30487. setTextMatrix: function TextState_setTextMatrix(a, b, c, d, e, f) {
  30488. var m = this.textMatrix;
  30489. m[0] = a;
  30490. m[1] = b;
  30491. m[2] = c;
  30492. m[3] = d;
  30493. m[4] = e;
  30494. m[5] = f;
  30495. },
  30496. setTextLineMatrix: function TextState_setTextMatrix(a, b, c, d, e, f) {
  30497. var m = this.textLineMatrix;
  30498. m[0] = a;
  30499. m[1] = b;
  30500. m[2] = c;
  30501. m[3] = d;
  30502. m[4] = e;
  30503. m[5] = f;
  30504. },
  30505. translateTextMatrix: function TextState_translateTextMatrix(x, y) {
  30506. var m = this.textMatrix;
  30507. m[4] = m[0] * x + m[2] * y + m[4];
  30508. m[5] = m[1] * x + m[3] * y + m[5];
  30509. },
  30510. translateTextLineMatrix: function TextState_translateTextMatrix(x, y) {
  30511. var m = this.textLineMatrix;
  30512. m[4] = m[0] * x + m[2] * y + m[4];
  30513. m[5] = m[1] * x + m[3] * y + m[5];
  30514. },
  30515. calcTextLineMatrixAdvance: function TextState_calcTextLineMatrixAdvance(a, b, c, d, e, f) {
  30516. var font = this.font;
  30517. if (!font) {
  30518. return null;
  30519. }
  30520. var m = this.textLineMatrix;
  30521. if (!(a === m[0] && b === m[1] && c === m[2] && d === m[3])) {
  30522. return null;
  30523. }
  30524. var txDiff = e - m[4], tyDiff = f - m[5];
  30525. if (font.vertical && txDiff !== 0 || !font.vertical && tyDiff !== 0) {
  30526. return null;
  30527. }
  30528. var tx, ty, denominator = a * d - b * c;
  30529. if (font.vertical) {
  30530. tx = -tyDiff * c / denominator;
  30531. ty = tyDiff * a / denominator;
  30532. } else {
  30533. tx = txDiff * d / denominator;
  30534. ty = -txDiff * b / denominator;
  30535. }
  30536. return {
  30537. width: tx,
  30538. height: ty,
  30539. value: font.vertical ? ty : tx
  30540. };
  30541. },
  30542. calcRenderMatrix: function TextState_calcRendeMatrix(ctm) {
  30543. var tsm = [
  30544. this.fontSize * this.textHScale,
  30545. 0,
  30546. 0,
  30547. this.fontSize,
  30548. 0,
  30549. this.textRise
  30550. ];
  30551. return Util.transform(ctm, Util.transform(this.textMatrix, tsm));
  30552. },
  30553. carriageReturn: function TextState_carriageReturn() {
  30554. this.translateTextLineMatrix(0, -this.leading);
  30555. this.textMatrix = this.textLineMatrix.slice();
  30556. },
  30557. clone: function TextState_clone() {
  30558. var clone = Object.create(this);
  30559. clone.textMatrix = this.textMatrix.slice();
  30560. clone.textLineMatrix = this.textLineMatrix.slice();
  30561. clone.fontMatrix = this.fontMatrix.slice();
  30562. return clone;
  30563. }
  30564. };
  30565. return TextState;
  30566. }();
  30567. var EvalState = function EvalStateClosure() {
  30568. function EvalState() {
  30569. this.ctm = new Float32Array(IDENTITY_MATRIX);
  30570. this.font = null;
  30571. this.textRenderingMode = TextRenderingMode.FILL;
  30572. this.fillColorSpace = ColorSpace.singletons.gray;
  30573. this.strokeColorSpace = ColorSpace.singletons.gray;
  30574. }
  30575. EvalState.prototype = {
  30576. clone: function CanvasExtraState_clone() {
  30577. return Object.create(this);
  30578. }
  30579. };
  30580. return EvalState;
  30581. }();
  30582. var EvaluatorPreprocessor = function EvaluatorPreprocessorClosure() {
  30583. var getOPMap = getLookupTableFactory(function (t) {
  30584. t['w'] = {
  30585. id: OPS.setLineWidth,
  30586. numArgs: 1,
  30587. variableArgs: false
  30588. };
  30589. t['J'] = {
  30590. id: OPS.setLineCap,
  30591. numArgs: 1,
  30592. variableArgs: false
  30593. };
  30594. t['j'] = {
  30595. id: OPS.setLineJoin,
  30596. numArgs: 1,
  30597. variableArgs: false
  30598. };
  30599. t['M'] = {
  30600. id: OPS.setMiterLimit,
  30601. numArgs: 1,
  30602. variableArgs: false
  30603. };
  30604. t['d'] = {
  30605. id: OPS.setDash,
  30606. numArgs: 2,
  30607. variableArgs: false
  30608. };
  30609. t['ri'] = {
  30610. id: OPS.setRenderingIntent,
  30611. numArgs: 1,
  30612. variableArgs: false
  30613. };
  30614. t['i'] = {
  30615. id: OPS.setFlatness,
  30616. numArgs: 1,
  30617. variableArgs: false
  30618. };
  30619. t['gs'] = {
  30620. id: OPS.setGState,
  30621. numArgs: 1,
  30622. variableArgs: false
  30623. };
  30624. t['q'] = {
  30625. id: OPS.save,
  30626. numArgs: 0,
  30627. variableArgs: false
  30628. };
  30629. t['Q'] = {
  30630. id: OPS.restore,
  30631. numArgs: 0,
  30632. variableArgs: false
  30633. };
  30634. t['cm'] = {
  30635. id: OPS.transform,
  30636. numArgs: 6,
  30637. variableArgs: false
  30638. };
  30639. t['m'] = {
  30640. id: OPS.moveTo,
  30641. numArgs: 2,
  30642. variableArgs: false
  30643. };
  30644. t['l'] = {
  30645. id: OPS.lineTo,
  30646. numArgs: 2,
  30647. variableArgs: false
  30648. };
  30649. t['c'] = {
  30650. id: OPS.curveTo,
  30651. numArgs: 6,
  30652. variableArgs: false
  30653. };
  30654. t['v'] = {
  30655. id: OPS.curveTo2,
  30656. numArgs: 4,
  30657. variableArgs: false
  30658. };
  30659. t['y'] = {
  30660. id: OPS.curveTo3,
  30661. numArgs: 4,
  30662. variableArgs: false
  30663. };
  30664. t['h'] = {
  30665. id: OPS.closePath,
  30666. numArgs: 0,
  30667. variableArgs: false
  30668. };
  30669. t['re'] = {
  30670. id: OPS.rectangle,
  30671. numArgs: 4,
  30672. variableArgs: false
  30673. };
  30674. t['S'] = {
  30675. id: OPS.stroke,
  30676. numArgs: 0,
  30677. variableArgs: false
  30678. };
  30679. t['s'] = {
  30680. id: OPS.closeStroke,
  30681. numArgs: 0,
  30682. variableArgs: false
  30683. };
  30684. t['f'] = {
  30685. id: OPS.fill,
  30686. numArgs: 0,
  30687. variableArgs: false
  30688. };
  30689. t['F'] = {
  30690. id: OPS.fill,
  30691. numArgs: 0,
  30692. variableArgs: false
  30693. };
  30694. t['f*'] = {
  30695. id: OPS.eoFill,
  30696. numArgs: 0,
  30697. variableArgs: false
  30698. };
  30699. t['B'] = {
  30700. id: OPS.fillStroke,
  30701. numArgs: 0,
  30702. variableArgs: false
  30703. };
  30704. t['B*'] = {
  30705. id: OPS.eoFillStroke,
  30706. numArgs: 0,
  30707. variableArgs: false
  30708. };
  30709. t['b'] = {
  30710. id: OPS.closeFillStroke,
  30711. numArgs: 0,
  30712. variableArgs: false
  30713. };
  30714. t['b*'] = {
  30715. id: OPS.closeEOFillStroke,
  30716. numArgs: 0,
  30717. variableArgs: false
  30718. };
  30719. t['n'] = {
  30720. id: OPS.endPath,
  30721. numArgs: 0,
  30722. variableArgs: false
  30723. };
  30724. t['W'] = {
  30725. id: OPS.clip,
  30726. numArgs: 0,
  30727. variableArgs: false
  30728. };
  30729. t['W*'] = {
  30730. id: OPS.eoClip,
  30731. numArgs: 0,
  30732. variableArgs: false
  30733. };
  30734. t['BT'] = {
  30735. id: OPS.beginText,
  30736. numArgs: 0,
  30737. variableArgs: false
  30738. };
  30739. t['ET'] = {
  30740. id: OPS.endText,
  30741. numArgs: 0,
  30742. variableArgs: false
  30743. };
  30744. t['Tc'] = {
  30745. id: OPS.setCharSpacing,
  30746. numArgs: 1,
  30747. variableArgs: false
  30748. };
  30749. t['Tw'] = {
  30750. id: OPS.setWordSpacing,
  30751. numArgs: 1,
  30752. variableArgs: false
  30753. };
  30754. t['Tz'] = {
  30755. id: OPS.setHScale,
  30756. numArgs: 1,
  30757. variableArgs: false
  30758. };
  30759. t['TL'] = {
  30760. id: OPS.setLeading,
  30761. numArgs: 1,
  30762. variableArgs: false
  30763. };
  30764. t['Tf'] = {
  30765. id: OPS.setFont,
  30766. numArgs: 2,
  30767. variableArgs: false
  30768. };
  30769. t['Tr'] = {
  30770. id: OPS.setTextRenderingMode,
  30771. numArgs: 1,
  30772. variableArgs: false
  30773. };
  30774. t['Ts'] = {
  30775. id: OPS.setTextRise,
  30776. numArgs: 1,
  30777. variableArgs: false
  30778. };
  30779. t['Td'] = {
  30780. id: OPS.moveText,
  30781. numArgs: 2,
  30782. variableArgs: false
  30783. };
  30784. t['TD'] = {
  30785. id: OPS.setLeadingMoveText,
  30786. numArgs: 2,
  30787. variableArgs: false
  30788. };
  30789. t['Tm'] = {
  30790. id: OPS.setTextMatrix,
  30791. numArgs: 6,
  30792. variableArgs: false
  30793. };
  30794. t['T*'] = {
  30795. id: OPS.nextLine,
  30796. numArgs: 0,
  30797. variableArgs: false
  30798. };
  30799. t['Tj'] = {
  30800. id: OPS.showText,
  30801. numArgs: 1,
  30802. variableArgs: false
  30803. };
  30804. t['TJ'] = {
  30805. id: OPS.showSpacedText,
  30806. numArgs: 1,
  30807. variableArgs: false
  30808. };
  30809. t['\''] = {
  30810. id: OPS.nextLineShowText,
  30811. numArgs: 1,
  30812. variableArgs: false
  30813. };
  30814. t['"'] = {
  30815. id: OPS.nextLineSetSpacingShowText,
  30816. numArgs: 3,
  30817. variableArgs: false
  30818. };
  30819. t['d0'] = {
  30820. id: OPS.setCharWidth,
  30821. numArgs: 2,
  30822. variableArgs: false
  30823. };
  30824. t['d1'] = {
  30825. id: OPS.setCharWidthAndBounds,
  30826. numArgs: 6,
  30827. variableArgs: false
  30828. };
  30829. t['CS'] = {
  30830. id: OPS.setStrokeColorSpace,
  30831. numArgs: 1,
  30832. variableArgs: false
  30833. };
  30834. t['cs'] = {
  30835. id: OPS.setFillColorSpace,
  30836. numArgs: 1,
  30837. variableArgs: false
  30838. };
  30839. t['SC'] = {
  30840. id: OPS.setStrokeColor,
  30841. numArgs: 4,
  30842. variableArgs: true
  30843. };
  30844. t['SCN'] = {
  30845. id: OPS.setStrokeColorN,
  30846. numArgs: 33,
  30847. variableArgs: true
  30848. };
  30849. t['sc'] = {
  30850. id: OPS.setFillColor,
  30851. numArgs: 4,
  30852. variableArgs: true
  30853. };
  30854. t['scn'] = {
  30855. id: OPS.setFillColorN,
  30856. numArgs: 33,
  30857. variableArgs: true
  30858. };
  30859. t['G'] = {
  30860. id: OPS.setStrokeGray,
  30861. numArgs: 1,
  30862. variableArgs: false
  30863. };
  30864. t['g'] = {
  30865. id: OPS.setFillGray,
  30866. numArgs: 1,
  30867. variableArgs: false
  30868. };
  30869. t['RG'] = {
  30870. id: OPS.setStrokeRGBColor,
  30871. numArgs: 3,
  30872. variableArgs: false
  30873. };
  30874. t['rg'] = {
  30875. id: OPS.setFillRGBColor,
  30876. numArgs: 3,
  30877. variableArgs: false
  30878. };
  30879. t['K'] = {
  30880. id: OPS.setStrokeCMYKColor,
  30881. numArgs: 4,
  30882. variableArgs: false
  30883. };
  30884. t['k'] = {
  30885. id: OPS.setFillCMYKColor,
  30886. numArgs: 4,
  30887. variableArgs: false
  30888. };
  30889. t['sh'] = {
  30890. id: OPS.shadingFill,
  30891. numArgs: 1,
  30892. variableArgs: false
  30893. };
  30894. t['BI'] = {
  30895. id: OPS.beginInlineImage,
  30896. numArgs: 0,
  30897. variableArgs: false
  30898. };
  30899. t['ID'] = {
  30900. id: OPS.beginImageData,
  30901. numArgs: 0,
  30902. variableArgs: false
  30903. };
  30904. t['EI'] = {
  30905. id: OPS.endInlineImage,
  30906. numArgs: 1,
  30907. variableArgs: false
  30908. };
  30909. t['Do'] = {
  30910. id: OPS.paintXObject,
  30911. numArgs: 1,
  30912. variableArgs: false
  30913. };
  30914. t['MP'] = {
  30915. id: OPS.markPoint,
  30916. numArgs: 1,
  30917. variableArgs: false
  30918. };
  30919. t['DP'] = {
  30920. id: OPS.markPointProps,
  30921. numArgs: 2,
  30922. variableArgs: false
  30923. };
  30924. t['BMC'] = {
  30925. id: OPS.beginMarkedContent,
  30926. numArgs: 1,
  30927. variableArgs: false
  30928. };
  30929. t['BDC'] = {
  30930. id: OPS.beginMarkedContentProps,
  30931. numArgs: 2,
  30932. variableArgs: false
  30933. };
  30934. t['EMC'] = {
  30935. id: OPS.endMarkedContent,
  30936. numArgs: 0,
  30937. variableArgs: false
  30938. };
  30939. t['BX'] = {
  30940. id: OPS.beginCompat,
  30941. numArgs: 0,
  30942. variableArgs: false
  30943. };
  30944. t['EX'] = {
  30945. id: OPS.endCompat,
  30946. numArgs: 0,
  30947. variableArgs: false
  30948. };
  30949. t['BM'] = null;
  30950. t['BD'] = null;
  30951. t['true'] = null;
  30952. t['fa'] = null;
  30953. t['fal'] = null;
  30954. t['fals'] = null;
  30955. t['false'] = null;
  30956. t['nu'] = null;
  30957. t['nul'] = null;
  30958. t['null'] = null;
  30959. });
  30960. function EvaluatorPreprocessor(stream, xref, stateManager) {
  30961. this.opMap = getOPMap();
  30962. this.parser = new Parser(new Lexer(stream, this.opMap), false, xref);
  30963. this.stateManager = stateManager;
  30964. this.nonProcessedArgs = [];
  30965. }
  30966. EvaluatorPreprocessor.prototype = {
  30967. get savedStatesDepth() {
  30968. return this.stateManager.stateStack.length;
  30969. },
  30970. read: function EvaluatorPreprocessor_read(operation) {
  30971. var args = operation.args;
  30972. while (true) {
  30973. var obj = this.parser.getObj();
  30974. if (isCmd(obj)) {
  30975. var cmd = obj.cmd;
  30976. var opSpec = this.opMap[cmd];
  30977. if (!opSpec) {
  30978. warn('Unknown command "' + cmd + '"');
  30979. continue;
  30980. }
  30981. var fn = opSpec.id;
  30982. var numArgs = opSpec.numArgs;
  30983. var argsLength = args !== null ? args.length : 0;
  30984. if (!opSpec.variableArgs) {
  30985. if (argsLength !== numArgs) {
  30986. var nonProcessedArgs = this.nonProcessedArgs;
  30987. while (argsLength > numArgs) {
  30988. nonProcessedArgs.push(args.shift());
  30989. argsLength--;
  30990. }
  30991. while (argsLength < numArgs && nonProcessedArgs.length !== 0) {
  30992. if (args === null) {
  30993. args = [];
  30994. }
  30995. args.unshift(nonProcessedArgs.pop());
  30996. argsLength++;
  30997. }
  30998. }
  30999. if (argsLength < numArgs) {
  31000. warn('Skipping command ' + fn + ': expected ' + numArgs + ' args, but received ' + argsLength + ' args.');
  31001. if (args !== null) {
  31002. args.length = 0;
  31003. }
  31004. continue;
  31005. }
  31006. } else if (argsLength > numArgs) {
  31007. info('Command ' + fn + ': expected [0,' + numArgs + '] args, but received ' + argsLength + ' args.');
  31008. }
  31009. this.preprocessCommand(fn, args);
  31010. operation.fn = fn;
  31011. operation.args = args;
  31012. return true;
  31013. }
  31014. if (isEOF(obj)) {
  31015. return false;
  31016. }
  31017. if (obj !== null) {
  31018. if (args === null) {
  31019. args = [];
  31020. }
  31021. args.push(obj);
  31022. assert(args.length <= 33, 'Too many arguments');
  31023. }
  31024. }
  31025. },
  31026. preprocessCommand: function EvaluatorPreprocessor_preprocessCommand(fn, args) {
  31027. switch (fn | 0) {
  31028. case OPS.save:
  31029. this.stateManager.save();
  31030. break;
  31031. case OPS.restore:
  31032. this.stateManager.restore();
  31033. break;
  31034. case OPS.transform:
  31035. this.stateManager.transform(args);
  31036. break;
  31037. }
  31038. }
  31039. };
  31040. return EvaluatorPreprocessor;
  31041. }();
  31042. var QueueOptimizer = function QueueOptimizerClosure() {
  31043. function addState(parentState, pattern, fn) {
  31044. var state = parentState;
  31045. for (var i = 0, ii = pattern.length - 1; i < ii; i++) {
  31046. var item = pattern[i];
  31047. state = state[item] || (state[item] = []);
  31048. }
  31049. state[pattern[pattern.length - 1]] = fn;
  31050. }
  31051. function handlePaintSolidColorImageMask(iFirstSave, count, fnArray, argsArray) {
  31052. var iFirstPIMXO = iFirstSave + 2;
  31053. for (var i = 0; i < count; i++) {
  31054. var arg = argsArray[iFirstPIMXO + 4 * i];
  31055. var imageMask = arg.length === 1 && arg[0];
  31056. if (imageMask && imageMask.width === 1 && imageMask.height === 1 && (!imageMask.data.length || imageMask.data.length === 1 && imageMask.data[0] === 0)) {
  31057. fnArray[iFirstPIMXO + 4 * i] = OPS.paintSolidColorImageMask;
  31058. continue;
  31059. }
  31060. break;
  31061. }
  31062. return count - i;
  31063. }
  31064. var InitialState = [];
  31065. addState(InitialState, [
  31066. OPS.save,
  31067. OPS.transform,
  31068. OPS.paintInlineImageXObject,
  31069. OPS.restore
  31070. ], function foundInlineImageGroup(context) {
  31071. var MIN_IMAGES_IN_INLINE_IMAGES_BLOCK = 10;
  31072. var MAX_IMAGES_IN_INLINE_IMAGES_BLOCK = 200;
  31073. var MAX_WIDTH = 1000;
  31074. var IMAGE_PADDING = 1;
  31075. var fnArray = context.fnArray, argsArray = context.argsArray;
  31076. var curr = context.iCurr;
  31077. var iFirstSave = curr - 3;
  31078. var iFirstTransform = curr - 2;
  31079. var iFirstPIIXO = curr - 1;
  31080. var i = iFirstSave + 4;
  31081. var ii = fnArray.length;
  31082. while (i + 3 < ii) {
  31083. if (fnArray[i] !== OPS.save || fnArray[i + 1] !== OPS.transform || fnArray[i + 2] !== OPS.paintInlineImageXObject || fnArray[i + 3] !== OPS.restore) {
  31084. break;
  31085. }
  31086. i += 4;
  31087. }
  31088. var count = Math.min((i - iFirstSave) / 4, MAX_IMAGES_IN_INLINE_IMAGES_BLOCK);
  31089. if (count < MIN_IMAGES_IN_INLINE_IMAGES_BLOCK) {
  31090. return i;
  31091. }
  31092. var maxX = 0;
  31093. var map = [], maxLineHeight = 0;
  31094. var currentX = IMAGE_PADDING, currentY = IMAGE_PADDING;
  31095. var q;
  31096. for (q = 0; q < count; q++) {
  31097. var transform = argsArray[iFirstTransform + (q << 2)];
  31098. var img = argsArray[iFirstPIIXO + (q << 2)][0];
  31099. if (currentX + img.width > MAX_WIDTH) {
  31100. maxX = Math.max(maxX, currentX);
  31101. currentY += maxLineHeight + 2 * IMAGE_PADDING;
  31102. currentX = 0;
  31103. maxLineHeight = 0;
  31104. }
  31105. map.push({
  31106. transform: transform,
  31107. x: currentX,
  31108. y: currentY,
  31109. w: img.width,
  31110. h: img.height
  31111. });
  31112. currentX += img.width + 2 * IMAGE_PADDING;
  31113. maxLineHeight = Math.max(maxLineHeight, img.height);
  31114. }
  31115. var imgWidth = Math.max(maxX, currentX) + IMAGE_PADDING;
  31116. var imgHeight = currentY + maxLineHeight + IMAGE_PADDING;
  31117. var imgData = new Uint8Array(imgWidth * imgHeight * 4);
  31118. var imgRowSize = imgWidth << 2;
  31119. for (q = 0; q < count; q++) {
  31120. var data = argsArray[iFirstPIIXO + (q << 2)][0].data;
  31121. var rowSize = map[q].w << 2;
  31122. var dataOffset = 0;
  31123. var offset = map[q].x + map[q].y * imgWidth << 2;
  31124. imgData.set(data.subarray(0, rowSize), offset - imgRowSize);
  31125. for (var k = 0, kk = map[q].h; k < kk; k++) {
  31126. imgData.set(data.subarray(dataOffset, dataOffset + rowSize), offset);
  31127. dataOffset += rowSize;
  31128. offset += imgRowSize;
  31129. }
  31130. imgData.set(data.subarray(dataOffset - rowSize, dataOffset), offset);
  31131. while (offset >= 0) {
  31132. data[offset - 4] = data[offset];
  31133. data[offset - 3] = data[offset + 1];
  31134. data[offset - 2] = data[offset + 2];
  31135. data[offset - 1] = data[offset + 3];
  31136. data[offset + rowSize] = data[offset + rowSize - 4];
  31137. data[offset + rowSize + 1] = data[offset + rowSize - 3];
  31138. data[offset + rowSize + 2] = data[offset + rowSize - 2];
  31139. data[offset + rowSize + 3] = data[offset + rowSize - 1];
  31140. offset -= imgRowSize;
  31141. }
  31142. }
  31143. fnArray.splice(iFirstSave, count * 4, OPS.paintInlineImageXObjectGroup);
  31144. argsArray.splice(iFirstSave, count * 4, [
  31145. {
  31146. width: imgWidth,
  31147. height: imgHeight,
  31148. kind: ImageKind.RGBA_32BPP,
  31149. data: imgData
  31150. },
  31151. map
  31152. ]);
  31153. return iFirstSave + 1;
  31154. });
  31155. addState(InitialState, [
  31156. OPS.save,
  31157. OPS.transform,
  31158. OPS.paintImageMaskXObject,
  31159. OPS.restore
  31160. ], function foundImageMaskGroup(context) {
  31161. var MIN_IMAGES_IN_MASKS_BLOCK = 10;
  31162. var MAX_IMAGES_IN_MASKS_BLOCK = 100;
  31163. var MAX_SAME_IMAGES_IN_MASKS_BLOCK = 1000;
  31164. var fnArray = context.fnArray, argsArray = context.argsArray;
  31165. var curr = context.iCurr;
  31166. var iFirstSave = curr - 3;
  31167. var iFirstTransform = curr - 2;
  31168. var iFirstPIMXO = curr - 1;
  31169. var i = iFirstSave + 4;
  31170. var ii = fnArray.length;
  31171. while (i + 3 < ii) {
  31172. if (fnArray[i] !== OPS.save || fnArray[i + 1] !== OPS.transform || fnArray[i + 2] !== OPS.paintImageMaskXObject || fnArray[i + 3] !== OPS.restore) {
  31173. break;
  31174. }
  31175. i += 4;
  31176. }
  31177. var count = (i - iFirstSave) / 4;
  31178. count = handlePaintSolidColorImageMask(iFirstSave, count, fnArray, argsArray);
  31179. if (count < MIN_IMAGES_IN_MASKS_BLOCK) {
  31180. return i;
  31181. }
  31182. var q;
  31183. var isSameImage = false;
  31184. var iTransform, transformArgs;
  31185. var firstPIMXOArg0 = argsArray[iFirstPIMXO][0];
  31186. if (argsArray[iFirstTransform][1] === 0 && argsArray[iFirstTransform][2] === 0) {
  31187. isSameImage = true;
  31188. var firstTransformArg0 = argsArray[iFirstTransform][0];
  31189. var firstTransformArg3 = argsArray[iFirstTransform][3];
  31190. iTransform = iFirstTransform + 4;
  31191. var iPIMXO = iFirstPIMXO + 4;
  31192. for (q = 1; q < count; q++, iTransform += 4, iPIMXO += 4) {
  31193. transformArgs = argsArray[iTransform];
  31194. if (argsArray[iPIMXO][0] !== firstPIMXOArg0 || transformArgs[0] !== firstTransformArg0 || transformArgs[1] !== 0 || transformArgs[2] !== 0 || transformArgs[3] !== firstTransformArg3) {
  31195. if (q < MIN_IMAGES_IN_MASKS_BLOCK) {
  31196. isSameImage = false;
  31197. } else {
  31198. count = q;
  31199. }
  31200. break;
  31201. }
  31202. }
  31203. }
  31204. if (isSameImage) {
  31205. count = Math.min(count, MAX_SAME_IMAGES_IN_MASKS_BLOCK);
  31206. var positions = new Float32Array(count * 2);
  31207. iTransform = iFirstTransform;
  31208. for (q = 0; q < count; q++, iTransform += 4) {
  31209. transformArgs = argsArray[iTransform];
  31210. positions[q << 1] = transformArgs[4];
  31211. positions[(q << 1) + 1] = transformArgs[5];
  31212. }
  31213. fnArray.splice(iFirstSave, count * 4, OPS.paintImageMaskXObjectRepeat);
  31214. argsArray.splice(iFirstSave, count * 4, [
  31215. firstPIMXOArg0,
  31216. firstTransformArg0,
  31217. firstTransformArg3,
  31218. positions
  31219. ]);
  31220. } else {
  31221. count = Math.min(count, MAX_IMAGES_IN_MASKS_BLOCK);
  31222. var images = [];
  31223. for (q = 0; q < count; q++) {
  31224. transformArgs = argsArray[iFirstTransform + (q << 2)];
  31225. var maskParams = argsArray[iFirstPIMXO + (q << 2)][0];
  31226. images.push({
  31227. data: maskParams.data,
  31228. width: maskParams.width,
  31229. height: maskParams.height,
  31230. transform: transformArgs
  31231. });
  31232. }
  31233. fnArray.splice(iFirstSave, count * 4, OPS.paintImageMaskXObjectGroup);
  31234. argsArray.splice(iFirstSave, count * 4, [images]);
  31235. }
  31236. return iFirstSave + 1;
  31237. });
  31238. addState(InitialState, [
  31239. OPS.save,
  31240. OPS.transform,
  31241. OPS.paintImageXObject,
  31242. OPS.restore
  31243. ], function (context) {
  31244. var MIN_IMAGES_IN_BLOCK = 3;
  31245. var MAX_IMAGES_IN_BLOCK = 1000;
  31246. var fnArray = context.fnArray, argsArray = context.argsArray;
  31247. var curr = context.iCurr;
  31248. var iFirstSave = curr - 3;
  31249. var iFirstTransform = curr - 2;
  31250. var iFirstPIXO = curr - 1;
  31251. var iFirstRestore = curr;
  31252. if (argsArray[iFirstTransform][1] !== 0 || argsArray[iFirstTransform][2] !== 0) {
  31253. return iFirstRestore + 1;
  31254. }
  31255. var firstPIXOArg0 = argsArray[iFirstPIXO][0];
  31256. var firstTransformArg0 = argsArray[iFirstTransform][0];
  31257. var firstTransformArg3 = argsArray[iFirstTransform][3];
  31258. var i = iFirstSave + 4;
  31259. var ii = fnArray.length;
  31260. while (i + 3 < ii) {
  31261. if (fnArray[i] !== OPS.save || fnArray[i + 1] !== OPS.transform || fnArray[i + 2] !== OPS.paintImageXObject || fnArray[i + 3] !== OPS.restore) {
  31262. break;
  31263. }
  31264. if (argsArray[i + 1][0] !== firstTransformArg0 || argsArray[i + 1][1] !== 0 || argsArray[i + 1][2] !== 0 || argsArray[i + 1][3] !== firstTransformArg3) {
  31265. break;
  31266. }
  31267. if (argsArray[i + 2][0] !== firstPIXOArg0) {
  31268. break;
  31269. }
  31270. i += 4;
  31271. }
  31272. var count = Math.min((i - iFirstSave) / 4, MAX_IMAGES_IN_BLOCK);
  31273. if (count < MIN_IMAGES_IN_BLOCK) {
  31274. return i;
  31275. }
  31276. var positions = new Float32Array(count * 2);
  31277. var iTransform = iFirstTransform;
  31278. for (var q = 0; q < count; q++, iTransform += 4) {
  31279. var transformArgs = argsArray[iTransform];
  31280. positions[q << 1] = transformArgs[4];
  31281. positions[(q << 1) + 1] = transformArgs[5];
  31282. }
  31283. var args = [
  31284. firstPIXOArg0,
  31285. firstTransformArg0,
  31286. firstTransformArg3,
  31287. positions
  31288. ];
  31289. fnArray.splice(iFirstSave, count * 4, OPS.paintImageXObjectRepeat);
  31290. argsArray.splice(iFirstSave, count * 4, args);
  31291. return iFirstSave + 1;
  31292. });
  31293. addState(InitialState, [
  31294. OPS.beginText,
  31295. OPS.setFont,
  31296. OPS.setTextMatrix,
  31297. OPS.showText,
  31298. OPS.endText
  31299. ], function (context) {
  31300. var MIN_CHARS_IN_BLOCK = 3;
  31301. var MAX_CHARS_IN_BLOCK = 1000;
  31302. var fnArray = context.fnArray, argsArray = context.argsArray;
  31303. var curr = context.iCurr;
  31304. var iFirstBeginText = curr - 4;
  31305. var iFirstSetFont = curr - 3;
  31306. var iFirstSetTextMatrix = curr - 2;
  31307. var iFirstShowText = curr - 1;
  31308. var iFirstEndText = curr;
  31309. var firstSetFontArg0 = argsArray[iFirstSetFont][0];
  31310. var firstSetFontArg1 = argsArray[iFirstSetFont][1];
  31311. var i = iFirstBeginText + 5;
  31312. var ii = fnArray.length;
  31313. while (i + 4 < ii) {
  31314. 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) {
  31315. break;
  31316. }
  31317. if (argsArray[i + 1][0] !== firstSetFontArg0 || argsArray[i + 1][1] !== firstSetFontArg1) {
  31318. break;
  31319. }
  31320. i += 5;
  31321. }
  31322. var count = Math.min((i - iFirstBeginText) / 5, MAX_CHARS_IN_BLOCK);
  31323. if (count < MIN_CHARS_IN_BLOCK) {
  31324. return i;
  31325. }
  31326. var iFirst = iFirstBeginText;
  31327. 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) {
  31328. count++;
  31329. iFirst -= 5;
  31330. }
  31331. var iEndText = iFirst + 4;
  31332. for (var q = 1; q < count; q++) {
  31333. fnArray.splice(iEndText, 3);
  31334. argsArray.splice(iEndText, 3);
  31335. iEndText += 2;
  31336. }
  31337. return iEndText + 1;
  31338. });
  31339. function QueueOptimizer() {
  31340. }
  31341. QueueOptimizer.prototype = {
  31342. optimize: function QueueOptimizer_optimize(queue) {
  31343. var fnArray = queue.fnArray, argsArray = queue.argsArray;
  31344. var context = {
  31345. iCurr: 0,
  31346. fnArray: fnArray,
  31347. argsArray: argsArray
  31348. };
  31349. var state;
  31350. var i = 0, ii = fnArray.length;
  31351. while (i < ii) {
  31352. state = (state || InitialState)[fnArray[i]];
  31353. if (typeof state === 'function') {
  31354. context.iCurr = i;
  31355. i = state(context);
  31356. state = undefined;
  31357. ii = context.fnArray.length;
  31358. } else {
  31359. i++;
  31360. }
  31361. }
  31362. }
  31363. };
  31364. return QueueOptimizer;
  31365. }();
  31366. exports.OperatorList = OperatorList;
  31367. exports.PartialEvaluator = PartialEvaluator;
  31368. /***/ }),
  31369. /* 19 */
  31370. /***/ (function(module, exports, __w_pdfjs_require__) {
  31371. "use strict";
  31372. var sharedUtil = __w_pdfjs_require__(0);
  31373. var coreArithmeticDecoder = __w_pdfjs_require__(14);
  31374. var info = sharedUtil.info;
  31375. var warn = sharedUtil.warn;
  31376. var error = sharedUtil.error;
  31377. var log2 = sharedUtil.log2;
  31378. var readUint16 = sharedUtil.readUint16;
  31379. var readUint32 = sharedUtil.readUint32;
  31380. var ArithmeticDecoder = coreArithmeticDecoder.ArithmeticDecoder;
  31381. var JpxImage = function JpxImageClosure() {
  31382. var SubbandsGainLog2 = {
  31383. 'LL': 0,
  31384. 'LH': 1,
  31385. 'HL': 1,
  31386. 'HH': 2
  31387. };
  31388. function JpxImage() {
  31389. this.failOnCorruptedImage = false;
  31390. }
  31391. JpxImage.prototype = {
  31392. parse: function JpxImage_parse(data) {
  31393. var head = readUint16(data, 0);
  31394. if (head === 0xFF4F) {
  31395. this.parseCodestream(data, 0, data.length);
  31396. return;
  31397. }
  31398. var position = 0, length = data.length;
  31399. while (position < length) {
  31400. var headerSize = 8;
  31401. var lbox = readUint32(data, position);
  31402. var tbox = readUint32(data, position + 4);
  31403. position += headerSize;
  31404. if (lbox === 1) {
  31405. lbox = readUint32(data, position) * 4294967296 + readUint32(data, position + 4);
  31406. position += 8;
  31407. headerSize += 8;
  31408. }
  31409. if (lbox === 0) {
  31410. lbox = length - position + headerSize;
  31411. }
  31412. if (lbox < headerSize) {
  31413. error('JPX Error: Invalid box field size');
  31414. }
  31415. var dataLength = lbox - headerSize;
  31416. var jumpDataLength = true;
  31417. switch (tbox) {
  31418. case 0x6A703268:
  31419. jumpDataLength = false;
  31420. break;
  31421. case 0x636F6C72:
  31422. var method = data[position];
  31423. if (method === 1) {
  31424. var colorspace = readUint32(data, position + 3);
  31425. switch (colorspace) {
  31426. case 16:
  31427. case 17:
  31428. case 18:
  31429. break;
  31430. default:
  31431. warn('Unknown colorspace ' + colorspace);
  31432. break;
  31433. }
  31434. } else if (method === 2) {
  31435. info('ICC profile not supported');
  31436. }
  31437. break;
  31438. case 0x6A703263:
  31439. this.parseCodestream(data, position, position + dataLength);
  31440. break;
  31441. case 0x6A502020:
  31442. if (readUint32(data, position) !== 0x0d0a870a) {
  31443. warn('Invalid JP2 signature');
  31444. }
  31445. break;
  31446. case 0x6A501A1A:
  31447. case 0x66747970:
  31448. case 0x72726571:
  31449. case 0x72657320:
  31450. case 0x69686472:
  31451. break;
  31452. default:
  31453. var headerType = String.fromCharCode(tbox >> 24 & 0xFF, tbox >> 16 & 0xFF, tbox >> 8 & 0xFF, tbox & 0xFF);
  31454. warn('Unsupported header type ' + tbox + ' (' + headerType + ')');
  31455. break;
  31456. }
  31457. if (jumpDataLength) {
  31458. position += dataLength;
  31459. }
  31460. }
  31461. },
  31462. parseImageProperties: function JpxImage_parseImageProperties(stream) {
  31463. var newByte = stream.getByte();
  31464. while (newByte >= 0) {
  31465. var oldByte = newByte;
  31466. newByte = stream.getByte();
  31467. var code = oldByte << 8 | newByte;
  31468. if (code === 0xFF51) {
  31469. stream.skip(4);
  31470. var Xsiz = stream.getInt32() >>> 0;
  31471. var Ysiz = stream.getInt32() >>> 0;
  31472. var XOsiz = stream.getInt32() >>> 0;
  31473. var YOsiz = stream.getInt32() >>> 0;
  31474. stream.skip(16);
  31475. var Csiz = stream.getUint16();
  31476. this.width = Xsiz - XOsiz;
  31477. this.height = Ysiz - YOsiz;
  31478. this.componentsCount = Csiz;
  31479. this.bitsPerComponent = 8;
  31480. return;
  31481. }
  31482. }
  31483. error('JPX Error: No size marker found in JPX stream');
  31484. },
  31485. parseCodestream: function JpxImage_parseCodestream(data, start, end) {
  31486. var context = {};
  31487. var doNotRecover = false;
  31488. try {
  31489. var position = start;
  31490. while (position + 1 < end) {
  31491. var code = readUint16(data, position);
  31492. position += 2;
  31493. var length = 0, j, sqcd, spqcds, spqcdSize, scalarExpounded, tile;
  31494. switch (code) {
  31495. case 0xFF4F:
  31496. context.mainHeader = true;
  31497. break;
  31498. case 0xFFD9:
  31499. break;
  31500. case 0xFF51:
  31501. length = readUint16(data, position);
  31502. var siz = {};
  31503. siz.Xsiz = readUint32(data, position + 4);
  31504. siz.Ysiz = readUint32(data, position + 8);
  31505. siz.XOsiz = readUint32(data, position + 12);
  31506. siz.YOsiz = readUint32(data, position + 16);
  31507. siz.XTsiz = readUint32(data, position + 20);
  31508. siz.YTsiz = readUint32(data, position + 24);
  31509. siz.XTOsiz = readUint32(data, position + 28);
  31510. siz.YTOsiz = readUint32(data, position + 32);
  31511. var componentsCount = readUint16(data, position + 36);
  31512. siz.Csiz = componentsCount;
  31513. var components = [];
  31514. j = position + 38;
  31515. for (var i = 0; i < componentsCount; i++) {
  31516. var component = {
  31517. precision: (data[j] & 0x7F) + 1,
  31518. isSigned: !!(data[j] & 0x80),
  31519. XRsiz: data[j + 1],
  31520. YRsiz: data[j + 1]
  31521. };
  31522. calculateComponentDimensions(component, siz);
  31523. components.push(component);
  31524. }
  31525. context.SIZ = siz;
  31526. context.components = components;
  31527. calculateTileGrids(context, components);
  31528. context.QCC = [];
  31529. context.COC = [];
  31530. break;
  31531. case 0xFF5C:
  31532. length = readUint16(data, position);
  31533. var qcd = {};
  31534. j = position + 2;
  31535. sqcd = data[j++];
  31536. switch (sqcd & 0x1F) {
  31537. case 0:
  31538. spqcdSize = 8;
  31539. scalarExpounded = true;
  31540. break;
  31541. case 1:
  31542. spqcdSize = 16;
  31543. scalarExpounded = false;
  31544. break;
  31545. case 2:
  31546. spqcdSize = 16;
  31547. scalarExpounded = true;
  31548. break;
  31549. default:
  31550. throw new Error('Invalid SQcd value ' + sqcd);
  31551. }
  31552. qcd.noQuantization = spqcdSize === 8;
  31553. qcd.scalarExpounded = scalarExpounded;
  31554. qcd.guardBits = sqcd >> 5;
  31555. spqcds = [];
  31556. while (j < length + position) {
  31557. var spqcd = {};
  31558. if (spqcdSize === 8) {
  31559. spqcd.epsilon = data[j++] >> 3;
  31560. spqcd.mu = 0;
  31561. } else {
  31562. spqcd.epsilon = data[j] >> 3;
  31563. spqcd.mu = (data[j] & 0x7) << 8 | data[j + 1];
  31564. j += 2;
  31565. }
  31566. spqcds.push(spqcd);
  31567. }
  31568. qcd.SPqcds = spqcds;
  31569. if (context.mainHeader) {
  31570. context.QCD = qcd;
  31571. } else {
  31572. context.currentTile.QCD = qcd;
  31573. context.currentTile.QCC = [];
  31574. }
  31575. break;
  31576. case 0xFF5D:
  31577. length = readUint16(data, position);
  31578. var qcc = {};
  31579. j = position + 2;
  31580. var cqcc;
  31581. if (context.SIZ.Csiz < 257) {
  31582. cqcc = data[j++];
  31583. } else {
  31584. cqcc = readUint16(data, j);
  31585. j += 2;
  31586. }
  31587. sqcd = data[j++];
  31588. switch (sqcd & 0x1F) {
  31589. case 0:
  31590. spqcdSize = 8;
  31591. scalarExpounded = true;
  31592. break;
  31593. case 1:
  31594. spqcdSize = 16;
  31595. scalarExpounded = false;
  31596. break;
  31597. case 2:
  31598. spqcdSize = 16;
  31599. scalarExpounded = true;
  31600. break;
  31601. default:
  31602. throw new Error('Invalid SQcd value ' + sqcd);
  31603. }
  31604. qcc.noQuantization = spqcdSize === 8;
  31605. qcc.scalarExpounded = scalarExpounded;
  31606. qcc.guardBits = sqcd >> 5;
  31607. spqcds = [];
  31608. while (j < length + position) {
  31609. spqcd = {};
  31610. if (spqcdSize === 8) {
  31611. spqcd.epsilon = data[j++] >> 3;
  31612. spqcd.mu = 0;
  31613. } else {
  31614. spqcd.epsilon = data[j] >> 3;
  31615. spqcd.mu = (data[j] & 0x7) << 8 | data[j + 1];
  31616. j += 2;
  31617. }
  31618. spqcds.push(spqcd);
  31619. }
  31620. qcc.SPqcds = spqcds;
  31621. if (context.mainHeader) {
  31622. context.QCC[cqcc] = qcc;
  31623. } else {
  31624. context.currentTile.QCC[cqcc] = qcc;
  31625. }
  31626. break;
  31627. case 0xFF52:
  31628. length = readUint16(data, position);
  31629. var cod = {};
  31630. j = position + 2;
  31631. var scod = data[j++];
  31632. cod.entropyCoderWithCustomPrecincts = !!(scod & 1);
  31633. cod.sopMarkerUsed = !!(scod & 2);
  31634. cod.ephMarkerUsed = !!(scod & 4);
  31635. cod.progressionOrder = data[j++];
  31636. cod.layersCount = readUint16(data, j);
  31637. j += 2;
  31638. cod.multipleComponentTransform = data[j++];
  31639. cod.decompositionLevelsCount = data[j++];
  31640. cod.xcb = (data[j++] & 0xF) + 2;
  31641. cod.ycb = (data[j++] & 0xF) + 2;
  31642. var blockStyle = data[j++];
  31643. cod.selectiveArithmeticCodingBypass = !!(blockStyle & 1);
  31644. cod.resetContextProbabilities = !!(blockStyle & 2);
  31645. cod.terminationOnEachCodingPass = !!(blockStyle & 4);
  31646. cod.verticalyStripe = !!(blockStyle & 8);
  31647. cod.predictableTermination = !!(blockStyle & 16);
  31648. cod.segmentationSymbolUsed = !!(blockStyle & 32);
  31649. cod.reversibleTransformation = data[j++];
  31650. if (cod.entropyCoderWithCustomPrecincts) {
  31651. var precinctsSizes = [];
  31652. while (j < length + position) {
  31653. var precinctsSize = data[j++];
  31654. precinctsSizes.push({
  31655. PPx: precinctsSize & 0xF,
  31656. PPy: precinctsSize >> 4
  31657. });
  31658. }
  31659. cod.precinctsSizes = precinctsSizes;
  31660. }
  31661. var unsupported = [];
  31662. if (cod.selectiveArithmeticCodingBypass) {
  31663. unsupported.push('selectiveArithmeticCodingBypass');
  31664. }
  31665. if (cod.resetContextProbabilities) {
  31666. unsupported.push('resetContextProbabilities');
  31667. }
  31668. if (cod.terminationOnEachCodingPass) {
  31669. unsupported.push('terminationOnEachCodingPass');
  31670. }
  31671. if (cod.verticalyStripe) {
  31672. unsupported.push('verticalyStripe');
  31673. }
  31674. if (cod.predictableTermination) {
  31675. unsupported.push('predictableTermination');
  31676. }
  31677. if (unsupported.length > 0) {
  31678. doNotRecover = true;
  31679. throw new Error('Unsupported COD options (' + unsupported.join(', ') + ')');
  31680. }
  31681. if (context.mainHeader) {
  31682. context.COD = cod;
  31683. } else {
  31684. context.currentTile.COD = cod;
  31685. context.currentTile.COC = [];
  31686. }
  31687. break;
  31688. case 0xFF90:
  31689. length = readUint16(data, position);
  31690. tile = {};
  31691. tile.index = readUint16(data, position + 2);
  31692. tile.length = readUint32(data, position + 4);
  31693. tile.dataEnd = tile.length + position - 2;
  31694. tile.partIndex = data[position + 8];
  31695. tile.partsCount = data[position + 9];
  31696. context.mainHeader = false;
  31697. if (tile.partIndex === 0) {
  31698. tile.COD = context.COD;
  31699. tile.COC = context.COC.slice(0);
  31700. tile.QCD = context.QCD;
  31701. tile.QCC = context.QCC.slice(0);
  31702. }
  31703. context.currentTile = tile;
  31704. break;
  31705. case 0xFF93:
  31706. tile = context.currentTile;
  31707. if (tile.partIndex === 0) {
  31708. initializeTile(context, tile.index);
  31709. buildPackets(context);
  31710. }
  31711. length = tile.dataEnd - position;
  31712. parseTilePackets(context, data, position, length);
  31713. break;
  31714. case 0xFF55:
  31715. case 0xFF57:
  31716. case 0xFF58:
  31717. case 0xFF64:
  31718. length = readUint16(data, position);
  31719. break;
  31720. case 0xFF53:
  31721. throw new Error('Codestream code 0xFF53 (COC) is ' + 'not implemented');
  31722. default:
  31723. throw new Error('Unknown codestream code: ' + code.toString(16));
  31724. }
  31725. position += length;
  31726. }
  31727. } catch (e) {
  31728. if (doNotRecover || this.failOnCorruptedImage) {
  31729. error('JPX Error: ' + e.message);
  31730. } else {
  31731. warn('JPX: Trying to recover from: ' + e.message);
  31732. }
  31733. }
  31734. this.tiles = transformComponents(context);
  31735. this.width = context.SIZ.Xsiz - context.SIZ.XOsiz;
  31736. this.height = context.SIZ.Ysiz - context.SIZ.YOsiz;
  31737. this.componentsCount = context.SIZ.Csiz;
  31738. }
  31739. };
  31740. function calculateComponentDimensions(component, siz) {
  31741. component.x0 = Math.ceil(siz.XOsiz / component.XRsiz);
  31742. component.x1 = Math.ceil(siz.Xsiz / component.XRsiz);
  31743. component.y0 = Math.ceil(siz.YOsiz / component.YRsiz);
  31744. component.y1 = Math.ceil(siz.Ysiz / component.YRsiz);
  31745. component.width = component.x1 - component.x0;
  31746. component.height = component.y1 - component.y0;
  31747. }
  31748. function calculateTileGrids(context, components) {
  31749. var siz = context.SIZ;
  31750. var tile, tiles = [];
  31751. var numXtiles = Math.ceil((siz.Xsiz - siz.XTOsiz) / siz.XTsiz);
  31752. var numYtiles = Math.ceil((siz.Ysiz - siz.YTOsiz) / siz.YTsiz);
  31753. for (var q = 0; q < numYtiles; q++) {
  31754. for (var p = 0; p < numXtiles; p++) {
  31755. tile = {};
  31756. tile.tx0 = Math.max(siz.XTOsiz + p * siz.XTsiz, siz.XOsiz);
  31757. tile.ty0 = Math.max(siz.YTOsiz + q * siz.YTsiz, siz.YOsiz);
  31758. tile.tx1 = Math.min(siz.XTOsiz + (p + 1) * siz.XTsiz, siz.Xsiz);
  31759. tile.ty1 = Math.min(siz.YTOsiz + (q + 1) * siz.YTsiz, siz.Ysiz);
  31760. tile.width = tile.tx1 - tile.tx0;
  31761. tile.height = tile.ty1 - tile.ty0;
  31762. tile.components = [];
  31763. tiles.push(tile);
  31764. }
  31765. }
  31766. context.tiles = tiles;
  31767. var componentsCount = siz.Csiz;
  31768. for (var i = 0, ii = componentsCount; i < ii; i++) {
  31769. var component = components[i];
  31770. for (var j = 0, jj = tiles.length; j < jj; j++) {
  31771. var tileComponent = {};
  31772. tile = tiles[j];
  31773. tileComponent.tcx0 = Math.ceil(tile.tx0 / component.XRsiz);
  31774. tileComponent.tcy0 = Math.ceil(tile.ty0 / component.YRsiz);
  31775. tileComponent.tcx1 = Math.ceil(tile.tx1 / component.XRsiz);
  31776. tileComponent.tcy1 = Math.ceil(tile.ty1 / component.YRsiz);
  31777. tileComponent.width = tileComponent.tcx1 - tileComponent.tcx0;
  31778. tileComponent.height = tileComponent.tcy1 - tileComponent.tcy0;
  31779. tile.components[i] = tileComponent;
  31780. }
  31781. }
  31782. }
  31783. function getBlocksDimensions(context, component, r) {
  31784. var codOrCoc = component.codingStyleParameters;
  31785. var result = {};
  31786. if (!codOrCoc.entropyCoderWithCustomPrecincts) {
  31787. result.PPx = 15;
  31788. result.PPy = 15;
  31789. } else {
  31790. result.PPx = codOrCoc.precinctsSizes[r].PPx;
  31791. result.PPy = codOrCoc.precinctsSizes[r].PPy;
  31792. }
  31793. result.xcb_ = r > 0 ? Math.min(codOrCoc.xcb, result.PPx - 1) : Math.min(codOrCoc.xcb, result.PPx);
  31794. result.ycb_ = r > 0 ? Math.min(codOrCoc.ycb, result.PPy - 1) : Math.min(codOrCoc.ycb, result.PPy);
  31795. return result;
  31796. }
  31797. function buildPrecincts(context, resolution, dimensions) {
  31798. var precinctWidth = 1 << dimensions.PPx;
  31799. var precinctHeight = 1 << dimensions.PPy;
  31800. var isZeroRes = resolution.resLevel === 0;
  31801. var precinctWidthInSubband = 1 << dimensions.PPx + (isZeroRes ? 0 : -1);
  31802. var precinctHeightInSubband = 1 << dimensions.PPy + (isZeroRes ? 0 : -1);
  31803. var numprecinctswide = resolution.trx1 > resolution.trx0 ? Math.ceil(resolution.trx1 / precinctWidth) - Math.floor(resolution.trx0 / precinctWidth) : 0;
  31804. var numprecinctshigh = resolution.try1 > resolution.try0 ? Math.ceil(resolution.try1 / precinctHeight) - Math.floor(resolution.try0 / precinctHeight) : 0;
  31805. var numprecincts = numprecinctswide * numprecinctshigh;
  31806. resolution.precinctParameters = {
  31807. precinctWidth: precinctWidth,
  31808. precinctHeight: precinctHeight,
  31809. numprecinctswide: numprecinctswide,
  31810. numprecinctshigh: numprecinctshigh,
  31811. numprecincts: numprecincts,
  31812. precinctWidthInSubband: precinctWidthInSubband,
  31813. precinctHeightInSubband: precinctHeightInSubband
  31814. };
  31815. }
  31816. function buildCodeblocks(context, subband, dimensions) {
  31817. var xcb_ = dimensions.xcb_;
  31818. var ycb_ = dimensions.ycb_;
  31819. var codeblockWidth = 1 << xcb_;
  31820. var codeblockHeight = 1 << ycb_;
  31821. var cbx0 = subband.tbx0 >> xcb_;
  31822. var cby0 = subband.tby0 >> ycb_;
  31823. var cbx1 = subband.tbx1 + codeblockWidth - 1 >> xcb_;
  31824. var cby1 = subband.tby1 + codeblockHeight - 1 >> ycb_;
  31825. var precinctParameters = subband.resolution.precinctParameters;
  31826. var codeblocks = [];
  31827. var precincts = [];
  31828. var i, j, codeblock, precinctNumber;
  31829. for (j = cby0; j < cby1; j++) {
  31830. for (i = cbx0; i < cbx1; i++) {
  31831. codeblock = {
  31832. cbx: i,
  31833. cby: j,
  31834. tbx0: codeblockWidth * i,
  31835. tby0: codeblockHeight * j,
  31836. tbx1: codeblockWidth * (i + 1),
  31837. tby1: codeblockHeight * (j + 1)
  31838. };
  31839. codeblock.tbx0_ = Math.max(subband.tbx0, codeblock.tbx0);
  31840. codeblock.tby0_ = Math.max(subband.tby0, codeblock.tby0);
  31841. codeblock.tbx1_ = Math.min(subband.tbx1, codeblock.tbx1);
  31842. codeblock.tby1_ = Math.min(subband.tby1, codeblock.tby1);
  31843. var pi = Math.floor((codeblock.tbx0_ - subband.tbx0) / precinctParameters.precinctWidthInSubband);
  31844. var pj = Math.floor((codeblock.tby0_ - subband.tby0) / precinctParameters.precinctHeightInSubband);
  31845. precinctNumber = pi + pj * precinctParameters.numprecinctswide;
  31846. codeblock.precinctNumber = precinctNumber;
  31847. codeblock.subbandType = subband.type;
  31848. codeblock.Lblock = 3;
  31849. if (codeblock.tbx1_ <= codeblock.tbx0_ || codeblock.tby1_ <= codeblock.tby0_) {
  31850. continue;
  31851. }
  31852. codeblocks.push(codeblock);
  31853. var precinct = precincts[precinctNumber];
  31854. if (precinct !== undefined) {
  31855. if (i < precinct.cbxMin) {
  31856. precinct.cbxMin = i;
  31857. } else if (i > precinct.cbxMax) {
  31858. precinct.cbxMax = i;
  31859. }
  31860. if (j < precinct.cbyMin) {
  31861. precinct.cbxMin = j;
  31862. } else if (j > precinct.cbyMax) {
  31863. precinct.cbyMax = j;
  31864. }
  31865. } else {
  31866. precincts[precinctNumber] = precinct = {
  31867. cbxMin: i,
  31868. cbyMin: j,
  31869. cbxMax: i,
  31870. cbyMax: j
  31871. };
  31872. }
  31873. codeblock.precinct = precinct;
  31874. }
  31875. }
  31876. subband.codeblockParameters = {
  31877. codeblockWidth: xcb_,
  31878. codeblockHeight: ycb_,
  31879. numcodeblockwide: cbx1 - cbx0 + 1,
  31880. numcodeblockhigh: cby1 - cby0 + 1
  31881. };
  31882. subband.codeblocks = codeblocks;
  31883. subband.precincts = precincts;
  31884. }
  31885. function createPacket(resolution, precinctNumber, layerNumber) {
  31886. var precinctCodeblocks = [];
  31887. var subbands = resolution.subbands;
  31888. for (var i = 0, ii = subbands.length; i < ii; i++) {
  31889. var subband = subbands[i];
  31890. var codeblocks = subband.codeblocks;
  31891. for (var j = 0, jj = codeblocks.length; j < jj; j++) {
  31892. var codeblock = codeblocks[j];
  31893. if (codeblock.precinctNumber !== precinctNumber) {
  31894. continue;
  31895. }
  31896. precinctCodeblocks.push(codeblock);
  31897. }
  31898. }
  31899. return {
  31900. layerNumber: layerNumber,
  31901. codeblocks: precinctCodeblocks
  31902. };
  31903. }
  31904. function LayerResolutionComponentPositionIterator(context) {
  31905. var siz = context.SIZ;
  31906. var tileIndex = context.currentTile.index;
  31907. var tile = context.tiles[tileIndex];
  31908. var layersCount = tile.codingStyleDefaultParameters.layersCount;
  31909. var componentsCount = siz.Csiz;
  31910. var maxDecompositionLevelsCount = 0;
  31911. for (var q = 0; q < componentsCount; q++) {
  31912. maxDecompositionLevelsCount = Math.max(maxDecompositionLevelsCount, tile.components[q].codingStyleParameters.decompositionLevelsCount);
  31913. }
  31914. var l = 0, r = 0, i = 0, k = 0;
  31915. this.nextPacket = function JpxImage_nextPacket() {
  31916. for (; l < layersCount; l++) {
  31917. for (; r <= maxDecompositionLevelsCount; r++) {
  31918. for (; i < componentsCount; i++) {
  31919. var component = tile.components[i];
  31920. if (r > component.codingStyleParameters.decompositionLevelsCount) {
  31921. continue;
  31922. }
  31923. var resolution = component.resolutions[r];
  31924. var numprecincts = resolution.precinctParameters.numprecincts;
  31925. for (; k < numprecincts;) {
  31926. var packet = createPacket(resolution, k, l);
  31927. k++;
  31928. return packet;
  31929. }
  31930. k = 0;
  31931. }
  31932. i = 0;
  31933. }
  31934. r = 0;
  31935. }
  31936. error('JPX Error: Out of packets');
  31937. };
  31938. }
  31939. function ResolutionLayerComponentPositionIterator(context) {
  31940. var siz = context.SIZ;
  31941. var tileIndex = context.currentTile.index;
  31942. var tile = context.tiles[tileIndex];
  31943. var layersCount = tile.codingStyleDefaultParameters.layersCount;
  31944. var componentsCount = siz.Csiz;
  31945. var maxDecompositionLevelsCount = 0;
  31946. for (var q = 0; q < componentsCount; q++) {
  31947. maxDecompositionLevelsCount = Math.max(maxDecompositionLevelsCount, tile.components[q].codingStyleParameters.decompositionLevelsCount);
  31948. }
  31949. var r = 0, l = 0, i = 0, k = 0;
  31950. this.nextPacket = function JpxImage_nextPacket() {
  31951. for (; r <= maxDecompositionLevelsCount; r++) {
  31952. for (; l < layersCount; l++) {
  31953. for (; i < componentsCount; i++) {
  31954. var component = tile.components[i];
  31955. if (r > component.codingStyleParameters.decompositionLevelsCount) {
  31956. continue;
  31957. }
  31958. var resolution = component.resolutions[r];
  31959. var numprecincts = resolution.precinctParameters.numprecincts;
  31960. for (; k < numprecincts;) {
  31961. var packet = createPacket(resolution, k, l);
  31962. k++;
  31963. return packet;
  31964. }
  31965. k = 0;
  31966. }
  31967. i = 0;
  31968. }
  31969. l = 0;
  31970. }
  31971. error('JPX Error: Out of packets');
  31972. };
  31973. }
  31974. function ResolutionPositionComponentLayerIterator(context) {
  31975. var siz = context.SIZ;
  31976. var tileIndex = context.currentTile.index;
  31977. var tile = context.tiles[tileIndex];
  31978. var layersCount = tile.codingStyleDefaultParameters.layersCount;
  31979. var componentsCount = siz.Csiz;
  31980. var l, r, c, p;
  31981. var maxDecompositionLevelsCount = 0;
  31982. for (c = 0; c < componentsCount; c++) {
  31983. var component = tile.components[c];
  31984. maxDecompositionLevelsCount = Math.max(maxDecompositionLevelsCount, component.codingStyleParameters.decompositionLevelsCount);
  31985. }
  31986. var maxNumPrecinctsInLevel = new Int32Array(maxDecompositionLevelsCount + 1);
  31987. for (r = 0; r <= maxDecompositionLevelsCount; ++r) {
  31988. var maxNumPrecincts = 0;
  31989. for (c = 0; c < componentsCount; ++c) {
  31990. var resolutions = tile.components[c].resolutions;
  31991. if (r < resolutions.length) {
  31992. maxNumPrecincts = Math.max(maxNumPrecincts, resolutions[r].precinctParameters.numprecincts);
  31993. }
  31994. }
  31995. maxNumPrecinctsInLevel[r] = maxNumPrecincts;
  31996. }
  31997. l = 0;
  31998. r = 0;
  31999. c = 0;
  32000. p = 0;
  32001. this.nextPacket = function JpxImage_nextPacket() {
  32002. for (; r <= maxDecompositionLevelsCount; r++) {
  32003. for (; p < maxNumPrecinctsInLevel[r]; p++) {
  32004. for (; c < componentsCount; c++) {
  32005. var component = tile.components[c];
  32006. if (r > component.codingStyleParameters.decompositionLevelsCount) {
  32007. continue;
  32008. }
  32009. var resolution = component.resolutions[r];
  32010. var numprecincts = resolution.precinctParameters.numprecincts;
  32011. if (p >= numprecincts) {
  32012. continue;
  32013. }
  32014. for (; l < layersCount;) {
  32015. var packet = createPacket(resolution, p, l);
  32016. l++;
  32017. return packet;
  32018. }
  32019. l = 0;
  32020. }
  32021. c = 0;
  32022. }
  32023. p = 0;
  32024. }
  32025. error('JPX Error: Out of packets');
  32026. };
  32027. }
  32028. function PositionComponentResolutionLayerIterator(context) {
  32029. var siz = context.SIZ;
  32030. var tileIndex = context.currentTile.index;
  32031. var tile = context.tiles[tileIndex];
  32032. var layersCount = tile.codingStyleDefaultParameters.layersCount;
  32033. var componentsCount = siz.Csiz;
  32034. var precinctsSizes = getPrecinctSizesInImageScale(tile);
  32035. var precinctsIterationSizes = precinctsSizes;
  32036. var l = 0, r = 0, c = 0, px = 0, py = 0;
  32037. this.nextPacket = function JpxImage_nextPacket() {
  32038. for (; py < precinctsIterationSizes.maxNumHigh; py++) {
  32039. for (; px < precinctsIterationSizes.maxNumWide; px++) {
  32040. for (; c < componentsCount; c++) {
  32041. var component = tile.components[c];
  32042. var decompositionLevelsCount = component.codingStyleParameters.decompositionLevelsCount;
  32043. for (; r <= decompositionLevelsCount; r++) {
  32044. var resolution = component.resolutions[r];
  32045. var sizeInImageScale = precinctsSizes.components[c].resolutions[r];
  32046. var k = getPrecinctIndexIfExist(px, py, sizeInImageScale, precinctsIterationSizes, resolution);
  32047. if (k === null) {
  32048. continue;
  32049. }
  32050. for (; l < layersCount;) {
  32051. var packet = createPacket(resolution, k, l);
  32052. l++;
  32053. return packet;
  32054. }
  32055. l = 0;
  32056. }
  32057. r = 0;
  32058. }
  32059. c = 0;
  32060. }
  32061. px = 0;
  32062. }
  32063. error('JPX Error: Out of packets');
  32064. };
  32065. }
  32066. function ComponentPositionResolutionLayerIterator(context) {
  32067. var siz = context.SIZ;
  32068. var tileIndex = context.currentTile.index;
  32069. var tile = context.tiles[tileIndex];
  32070. var layersCount = tile.codingStyleDefaultParameters.layersCount;
  32071. var componentsCount = siz.Csiz;
  32072. var precinctsSizes = getPrecinctSizesInImageScale(tile);
  32073. var l = 0, r = 0, c = 0, px = 0, py = 0;
  32074. this.nextPacket = function JpxImage_nextPacket() {
  32075. for (; c < componentsCount; ++c) {
  32076. var component = tile.components[c];
  32077. var precinctsIterationSizes = precinctsSizes.components[c];
  32078. var decompositionLevelsCount = component.codingStyleParameters.decompositionLevelsCount;
  32079. for (; py < precinctsIterationSizes.maxNumHigh; py++) {
  32080. for (; px < precinctsIterationSizes.maxNumWide; px++) {
  32081. for (; r <= decompositionLevelsCount; r++) {
  32082. var resolution = component.resolutions[r];
  32083. var sizeInImageScale = precinctsIterationSizes.resolutions[r];
  32084. var k = getPrecinctIndexIfExist(px, py, sizeInImageScale, precinctsIterationSizes, resolution);
  32085. if (k === null) {
  32086. continue;
  32087. }
  32088. for (; l < layersCount;) {
  32089. var packet = createPacket(resolution, k, l);
  32090. l++;
  32091. return packet;
  32092. }
  32093. l = 0;
  32094. }
  32095. r = 0;
  32096. }
  32097. px = 0;
  32098. }
  32099. py = 0;
  32100. }
  32101. error('JPX Error: Out of packets');
  32102. };
  32103. }
  32104. function getPrecinctIndexIfExist(pxIndex, pyIndex, sizeInImageScale, precinctIterationSizes, resolution) {
  32105. var posX = pxIndex * precinctIterationSizes.minWidth;
  32106. var posY = pyIndex * precinctIterationSizes.minHeight;
  32107. if (posX % sizeInImageScale.width !== 0 || posY % sizeInImageScale.height !== 0) {
  32108. return null;
  32109. }
  32110. var startPrecinctRowIndex = posY / sizeInImageScale.width * resolution.precinctParameters.numprecinctswide;
  32111. return posX / sizeInImageScale.height + startPrecinctRowIndex;
  32112. }
  32113. function getPrecinctSizesInImageScale(tile) {
  32114. var componentsCount = tile.components.length;
  32115. var minWidth = Number.MAX_VALUE;
  32116. var minHeight = Number.MAX_VALUE;
  32117. var maxNumWide = 0;
  32118. var maxNumHigh = 0;
  32119. var sizePerComponent = new Array(componentsCount);
  32120. for (var c = 0; c < componentsCount; c++) {
  32121. var component = tile.components[c];
  32122. var decompositionLevelsCount = component.codingStyleParameters.decompositionLevelsCount;
  32123. var sizePerResolution = new Array(decompositionLevelsCount + 1);
  32124. var minWidthCurrentComponent = Number.MAX_VALUE;
  32125. var minHeightCurrentComponent = Number.MAX_VALUE;
  32126. var maxNumWideCurrentComponent = 0;
  32127. var maxNumHighCurrentComponent = 0;
  32128. var scale = 1;
  32129. for (var r = decompositionLevelsCount; r >= 0; --r) {
  32130. var resolution = component.resolutions[r];
  32131. var widthCurrentResolution = scale * resolution.precinctParameters.precinctWidth;
  32132. var heightCurrentResolution = scale * resolution.precinctParameters.precinctHeight;
  32133. minWidthCurrentComponent = Math.min(minWidthCurrentComponent, widthCurrentResolution);
  32134. minHeightCurrentComponent = Math.min(minHeightCurrentComponent, heightCurrentResolution);
  32135. maxNumWideCurrentComponent = Math.max(maxNumWideCurrentComponent, resolution.precinctParameters.numprecinctswide);
  32136. maxNumHighCurrentComponent = Math.max(maxNumHighCurrentComponent, resolution.precinctParameters.numprecinctshigh);
  32137. sizePerResolution[r] = {
  32138. width: widthCurrentResolution,
  32139. height: heightCurrentResolution
  32140. };
  32141. scale <<= 1;
  32142. }
  32143. minWidth = Math.min(minWidth, minWidthCurrentComponent);
  32144. minHeight = Math.min(minHeight, minHeightCurrentComponent);
  32145. maxNumWide = Math.max(maxNumWide, maxNumWideCurrentComponent);
  32146. maxNumHigh = Math.max(maxNumHigh, maxNumHighCurrentComponent);
  32147. sizePerComponent[c] = {
  32148. resolutions: sizePerResolution,
  32149. minWidth: minWidthCurrentComponent,
  32150. minHeight: minHeightCurrentComponent,
  32151. maxNumWide: maxNumWideCurrentComponent,
  32152. maxNumHigh: maxNumHighCurrentComponent
  32153. };
  32154. }
  32155. return {
  32156. components: sizePerComponent,
  32157. minWidth: minWidth,
  32158. minHeight: minHeight,
  32159. maxNumWide: maxNumWide,
  32160. maxNumHigh: maxNumHigh
  32161. };
  32162. }
  32163. function buildPackets(context) {
  32164. var siz = context.SIZ;
  32165. var tileIndex = context.currentTile.index;
  32166. var tile = context.tiles[tileIndex];
  32167. var componentsCount = siz.Csiz;
  32168. for (var c = 0; c < componentsCount; c++) {
  32169. var component = tile.components[c];
  32170. var decompositionLevelsCount = component.codingStyleParameters.decompositionLevelsCount;
  32171. var resolutions = [];
  32172. var subbands = [];
  32173. for (var r = 0; r <= decompositionLevelsCount; r++) {
  32174. var blocksDimensions = getBlocksDimensions(context, component, r);
  32175. var resolution = {};
  32176. var scale = 1 << decompositionLevelsCount - r;
  32177. resolution.trx0 = Math.ceil(component.tcx0 / scale);
  32178. resolution.try0 = Math.ceil(component.tcy0 / scale);
  32179. resolution.trx1 = Math.ceil(component.tcx1 / scale);
  32180. resolution.try1 = Math.ceil(component.tcy1 / scale);
  32181. resolution.resLevel = r;
  32182. buildPrecincts(context, resolution, blocksDimensions);
  32183. resolutions.push(resolution);
  32184. var subband;
  32185. if (r === 0) {
  32186. subband = {};
  32187. subband.type = 'LL';
  32188. subband.tbx0 = Math.ceil(component.tcx0 / scale);
  32189. subband.tby0 = Math.ceil(component.tcy0 / scale);
  32190. subband.tbx1 = Math.ceil(component.tcx1 / scale);
  32191. subband.tby1 = Math.ceil(component.tcy1 / scale);
  32192. subband.resolution = resolution;
  32193. buildCodeblocks(context, subband, blocksDimensions);
  32194. subbands.push(subband);
  32195. resolution.subbands = [subband];
  32196. } else {
  32197. var bscale = 1 << decompositionLevelsCount - r + 1;
  32198. var resolutionSubbands = [];
  32199. subband = {};
  32200. subband.type = 'HL';
  32201. subband.tbx0 = Math.ceil(component.tcx0 / bscale - 0.5);
  32202. subband.tby0 = Math.ceil(component.tcy0 / bscale);
  32203. subband.tbx1 = Math.ceil(component.tcx1 / bscale - 0.5);
  32204. subband.tby1 = Math.ceil(component.tcy1 / bscale);
  32205. subband.resolution = resolution;
  32206. buildCodeblocks(context, subband, blocksDimensions);
  32207. subbands.push(subband);
  32208. resolutionSubbands.push(subband);
  32209. subband = {};
  32210. subband.type = 'LH';
  32211. subband.tbx0 = Math.ceil(component.tcx0 / bscale);
  32212. subband.tby0 = Math.ceil(component.tcy0 / bscale - 0.5);
  32213. subband.tbx1 = Math.ceil(component.tcx1 / bscale);
  32214. subband.tby1 = Math.ceil(component.tcy1 / bscale - 0.5);
  32215. subband.resolution = resolution;
  32216. buildCodeblocks(context, subband, blocksDimensions);
  32217. subbands.push(subband);
  32218. resolutionSubbands.push(subband);
  32219. subband = {};
  32220. subband.type = 'HH';
  32221. subband.tbx0 = Math.ceil(component.tcx0 / bscale - 0.5);
  32222. subband.tby0 = Math.ceil(component.tcy0 / bscale - 0.5);
  32223. subband.tbx1 = Math.ceil(component.tcx1 / bscale - 0.5);
  32224. subband.tby1 = Math.ceil(component.tcy1 / bscale - 0.5);
  32225. subband.resolution = resolution;
  32226. buildCodeblocks(context, subband, blocksDimensions);
  32227. subbands.push(subband);
  32228. resolutionSubbands.push(subband);
  32229. resolution.subbands = resolutionSubbands;
  32230. }
  32231. }
  32232. component.resolutions = resolutions;
  32233. component.subbands = subbands;
  32234. }
  32235. var progressionOrder = tile.codingStyleDefaultParameters.progressionOrder;
  32236. switch (progressionOrder) {
  32237. case 0:
  32238. tile.packetsIterator = new LayerResolutionComponentPositionIterator(context);
  32239. break;
  32240. case 1:
  32241. tile.packetsIterator = new ResolutionLayerComponentPositionIterator(context);
  32242. break;
  32243. case 2:
  32244. tile.packetsIterator = new ResolutionPositionComponentLayerIterator(context);
  32245. break;
  32246. case 3:
  32247. tile.packetsIterator = new PositionComponentResolutionLayerIterator(context);
  32248. break;
  32249. case 4:
  32250. tile.packetsIterator = new ComponentPositionResolutionLayerIterator(context);
  32251. break;
  32252. default:
  32253. error('JPX Error: Unsupported progression order ' + progressionOrder);
  32254. }
  32255. }
  32256. function parseTilePackets(context, data, offset, dataLength) {
  32257. var position = 0;
  32258. var buffer, bufferSize = 0, skipNextBit = false;
  32259. function readBits(count) {
  32260. while (bufferSize < count) {
  32261. var b = data[offset + position];
  32262. position++;
  32263. if (skipNextBit) {
  32264. buffer = buffer << 7 | b;
  32265. bufferSize += 7;
  32266. skipNextBit = false;
  32267. } else {
  32268. buffer = buffer << 8 | b;
  32269. bufferSize += 8;
  32270. }
  32271. if (b === 0xFF) {
  32272. skipNextBit = true;
  32273. }
  32274. }
  32275. bufferSize -= count;
  32276. return buffer >>> bufferSize & (1 << count) - 1;
  32277. }
  32278. function skipMarkerIfEqual(value) {
  32279. if (data[offset + position - 1] === 0xFF && data[offset + position] === value) {
  32280. skipBytes(1);
  32281. return true;
  32282. } else if (data[offset + position] === 0xFF && data[offset + position + 1] === value) {
  32283. skipBytes(2);
  32284. return true;
  32285. }
  32286. return false;
  32287. }
  32288. function skipBytes(count) {
  32289. position += count;
  32290. }
  32291. function alignToByte() {
  32292. bufferSize = 0;
  32293. if (skipNextBit) {
  32294. position++;
  32295. skipNextBit = false;
  32296. }
  32297. }
  32298. function readCodingpasses() {
  32299. if (readBits(1) === 0) {
  32300. return 1;
  32301. }
  32302. if (readBits(1) === 0) {
  32303. return 2;
  32304. }
  32305. var value = readBits(2);
  32306. if (value < 3) {
  32307. return value + 3;
  32308. }
  32309. value = readBits(5);
  32310. if (value < 31) {
  32311. return value + 6;
  32312. }
  32313. value = readBits(7);
  32314. return value + 37;
  32315. }
  32316. var tileIndex = context.currentTile.index;
  32317. var tile = context.tiles[tileIndex];
  32318. var sopMarkerUsed = context.COD.sopMarkerUsed;
  32319. var ephMarkerUsed = context.COD.ephMarkerUsed;
  32320. var packetsIterator = tile.packetsIterator;
  32321. while (position < dataLength) {
  32322. alignToByte();
  32323. if (sopMarkerUsed && skipMarkerIfEqual(0x91)) {
  32324. skipBytes(4);
  32325. }
  32326. var packet = packetsIterator.nextPacket();
  32327. if (!readBits(1)) {
  32328. continue;
  32329. }
  32330. var layerNumber = packet.layerNumber;
  32331. var queue = [], codeblock;
  32332. for (var i = 0, ii = packet.codeblocks.length; i < ii; i++) {
  32333. codeblock = packet.codeblocks[i];
  32334. var precinct = codeblock.precinct;
  32335. var codeblockColumn = codeblock.cbx - precinct.cbxMin;
  32336. var codeblockRow = codeblock.cby - precinct.cbyMin;
  32337. var codeblockIncluded = false;
  32338. var firstTimeInclusion = false;
  32339. var valueReady;
  32340. if (codeblock['included'] !== undefined) {
  32341. codeblockIncluded = !!readBits(1);
  32342. } else {
  32343. precinct = codeblock.precinct;
  32344. var inclusionTree, zeroBitPlanesTree;
  32345. if (precinct['inclusionTree'] !== undefined) {
  32346. inclusionTree = precinct.inclusionTree;
  32347. } else {
  32348. var width = precinct.cbxMax - precinct.cbxMin + 1;
  32349. var height = precinct.cbyMax - precinct.cbyMin + 1;
  32350. inclusionTree = new InclusionTree(width, height, layerNumber);
  32351. zeroBitPlanesTree = new TagTree(width, height);
  32352. precinct.inclusionTree = inclusionTree;
  32353. precinct.zeroBitPlanesTree = zeroBitPlanesTree;
  32354. }
  32355. if (inclusionTree.reset(codeblockColumn, codeblockRow, layerNumber)) {
  32356. while (true) {
  32357. if (readBits(1)) {
  32358. valueReady = !inclusionTree.nextLevel();
  32359. if (valueReady) {
  32360. codeblock.included = true;
  32361. codeblockIncluded = firstTimeInclusion = true;
  32362. break;
  32363. }
  32364. } else {
  32365. inclusionTree.incrementValue(layerNumber);
  32366. break;
  32367. }
  32368. }
  32369. }
  32370. }
  32371. if (!codeblockIncluded) {
  32372. continue;
  32373. }
  32374. if (firstTimeInclusion) {
  32375. zeroBitPlanesTree = precinct.zeroBitPlanesTree;
  32376. zeroBitPlanesTree.reset(codeblockColumn, codeblockRow);
  32377. while (true) {
  32378. if (readBits(1)) {
  32379. valueReady = !zeroBitPlanesTree.nextLevel();
  32380. if (valueReady) {
  32381. break;
  32382. }
  32383. } else {
  32384. zeroBitPlanesTree.incrementValue();
  32385. }
  32386. }
  32387. codeblock.zeroBitPlanes = zeroBitPlanesTree.value;
  32388. }
  32389. var codingpasses = readCodingpasses();
  32390. while (readBits(1)) {
  32391. codeblock.Lblock++;
  32392. }
  32393. var codingpassesLog2 = log2(codingpasses);
  32394. var bits = (codingpasses < 1 << codingpassesLog2 ? codingpassesLog2 - 1 : codingpassesLog2) + codeblock.Lblock;
  32395. var codedDataLength = readBits(bits);
  32396. queue.push({
  32397. codeblock: codeblock,
  32398. codingpasses: codingpasses,
  32399. dataLength: codedDataLength
  32400. });
  32401. }
  32402. alignToByte();
  32403. if (ephMarkerUsed) {
  32404. skipMarkerIfEqual(0x92);
  32405. }
  32406. while (queue.length > 0) {
  32407. var packetItem = queue.shift();
  32408. codeblock = packetItem.codeblock;
  32409. if (codeblock['data'] === undefined) {
  32410. codeblock.data = [];
  32411. }
  32412. codeblock.data.push({
  32413. data: data,
  32414. start: offset + position,
  32415. end: offset + position + packetItem.dataLength,
  32416. codingpasses: packetItem.codingpasses
  32417. });
  32418. position += packetItem.dataLength;
  32419. }
  32420. }
  32421. return position;
  32422. }
  32423. function copyCoefficients(coefficients, levelWidth, levelHeight, subband, delta, mb, reversible, segmentationSymbolUsed) {
  32424. var x0 = subband.tbx0;
  32425. var y0 = subband.tby0;
  32426. var width = subband.tbx1 - subband.tbx0;
  32427. var codeblocks = subband.codeblocks;
  32428. var right = subband.type.charAt(0) === 'H' ? 1 : 0;
  32429. var bottom = subband.type.charAt(1) === 'H' ? levelWidth : 0;
  32430. for (var i = 0, ii = codeblocks.length; i < ii; ++i) {
  32431. var codeblock = codeblocks[i];
  32432. var blockWidth = codeblock.tbx1_ - codeblock.tbx0_;
  32433. var blockHeight = codeblock.tby1_ - codeblock.tby0_;
  32434. if (blockWidth === 0 || blockHeight === 0) {
  32435. continue;
  32436. }
  32437. if (codeblock['data'] === undefined) {
  32438. continue;
  32439. }
  32440. var bitModel, currentCodingpassType;
  32441. bitModel = new BitModel(blockWidth, blockHeight, codeblock.subbandType, codeblock.zeroBitPlanes, mb);
  32442. currentCodingpassType = 2;
  32443. var data = codeblock.data, totalLength = 0, codingpasses = 0;
  32444. var j, jj, dataItem;
  32445. for (j = 0, jj = data.length; j < jj; j++) {
  32446. dataItem = data[j];
  32447. totalLength += dataItem.end - dataItem.start;
  32448. codingpasses += dataItem.codingpasses;
  32449. }
  32450. var encodedData = new Uint8Array(totalLength);
  32451. var position = 0;
  32452. for (j = 0, jj = data.length; j < jj; j++) {
  32453. dataItem = data[j];
  32454. var chunk = dataItem.data.subarray(dataItem.start, dataItem.end);
  32455. encodedData.set(chunk, position);
  32456. position += chunk.length;
  32457. }
  32458. var decoder = new ArithmeticDecoder(encodedData, 0, totalLength);
  32459. bitModel.setDecoder(decoder);
  32460. for (j = 0; j < codingpasses; j++) {
  32461. switch (currentCodingpassType) {
  32462. case 0:
  32463. bitModel.runSignificancePropagationPass();
  32464. break;
  32465. case 1:
  32466. bitModel.runMagnitudeRefinementPass();
  32467. break;
  32468. case 2:
  32469. bitModel.runCleanupPass();
  32470. if (segmentationSymbolUsed) {
  32471. bitModel.checkSegmentationSymbol();
  32472. }
  32473. break;
  32474. }
  32475. currentCodingpassType = (currentCodingpassType + 1) % 3;
  32476. }
  32477. var offset = codeblock.tbx0_ - x0 + (codeblock.tby0_ - y0) * width;
  32478. var sign = bitModel.coefficentsSign;
  32479. var magnitude = bitModel.coefficentsMagnitude;
  32480. var bitsDecoded = bitModel.bitsDecoded;
  32481. var magnitudeCorrection = reversible ? 0 : 0.5;
  32482. var k, n, nb;
  32483. position = 0;
  32484. var interleave = subband.type !== 'LL';
  32485. for (j = 0; j < blockHeight; j++) {
  32486. var row = offset / width | 0;
  32487. var levelOffset = 2 * row * (levelWidth - width) + right + bottom;
  32488. for (k = 0; k < blockWidth; k++) {
  32489. n = magnitude[position];
  32490. if (n !== 0) {
  32491. n = (n + magnitudeCorrection) * delta;
  32492. if (sign[position] !== 0) {
  32493. n = -n;
  32494. }
  32495. nb = bitsDecoded[position];
  32496. var pos = interleave ? levelOffset + (offset << 1) : offset;
  32497. if (reversible && nb >= mb) {
  32498. coefficients[pos] = n;
  32499. } else {
  32500. coefficients[pos] = n * (1 << mb - nb);
  32501. }
  32502. }
  32503. offset++;
  32504. position++;
  32505. }
  32506. offset += width - blockWidth;
  32507. }
  32508. }
  32509. }
  32510. function transformTile(context, tile, c) {
  32511. var component = tile.components[c];
  32512. var codingStyleParameters = component.codingStyleParameters;
  32513. var quantizationParameters = component.quantizationParameters;
  32514. var decompositionLevelsCount = codingStyleParameters.decompositionLevelsCount;
  32515. var spqcds = quantizationParameters.SPqcds;
  32516. var scalarExpounded = quantizationParameters.scalarExpounded;
  32517. var guardBits = quantizationParameters.guardBits;
  32518. var segmentationSymbolUsed = codingStyleParameters.segmentationSymbolUsed;
  32519. var precision = context.components[c].precision;
  32520. var reversible = codingStyleParameters.reversibleTransformation;
  32521. var transform = reversible ? new ReversibleTransform() : new IrreversibleTransform();
  32522. var subbandCoefficients = [];
  32523. var b = 0;
  32524. for (var i = 0; i <= decompositionLevelsCount; i++) {
  32525. var resolution = component.resolutions[i];
  32526. var width = resolution.trx1 - resolution.trx0;
  32527. var height = resolution.try1 - resolution.try0;
  32528. var coefficients = new Float32Array(width * height);
  32529. for (var j = 0, jj = resolution.subbands.length; j < jj; j++) {
  32530. var mu, epsilon;
  32531. if (!scalarExpounded) {
  32532. mu = spqcds[0].mu;
  32533. epsilon = spqcds[0].epsilon + (i > 0 ? 1 - i : 0);
  32534. } else {
  32535. mu = spqcds[b].mu;
  32536. epsilon = spqcds[b].epsilon;
  32537. b++;
  32538. }
  32539. var subband = resolution.subbands[j];
  32540. var gainLog2 = SubbandsGainLog2[subband.type];
  32541. var delta = reversible ? 1 : Math.pow(2, precision + gainLog2 - epsilon) * (1 + mu / 2048);
  32542. var mb = guardBits + epsilon - 1;
  32543. copyCoefficients(coefficients, width, height, subband, delta, mb, reversible, segmentationSymbolUsed);
  32544. }
  32545. subbandCoefficients.push({
  32546. width: width,
  32547. height: height,
  32548. items: coefficients
  32549. });
  32550. }
  32551. var result = transform.calculate(subbandCoefficients, component.tcx0, component.tcy0);
  32552. return {
  32553. left: component.tcx0,
  32554. top: component.tcy0,
  32555. width: result.width,
  32556. height: result.height,
  32557. items: result.items
  32558. };
  32559. }
  32560. function transformComponents(context) {
  32561. var siz = context.SIZ;
  32562. var components = context.components;
  32563. var componentsCount = siz.Csiz;
  32564. var resultImages = [];
  32565. for (var i = 0, ii = context.tiles.length; i < ii; i++) {
  32566. var tile = context.tiles[i];
  32567. var transformedTiles = [];
  32568. var c;
  32569. for (c = 0; c < componentsCount; c++) {
  32570. transformedTiles[c] = transformTile(context, tile, c);
  32571. }
  32572. var tile0 = transformedTiles[0];
  32573. var out = new Uint8Array(tile0.items.length * componentsCount);
  32574. var result = {
  32575. left: tile0.left,
  32576. top: tile0.top,
  32577. width: tile0.width,
  32578. height: tile0.height,
  32579. items: out
  32580. };
  32581. var shift, offset, max, min, maxK;
  32582. var pos = 0, j, jj, y0, y1, y2, r, g, b, k, val;
  32583. if (tile.codingStyleDefaultParameters.multipleComponentTransform) {
  32584. var fourComponents = componentsCount === 4;
  32585. var y0items = transformedTiles[0].items;
  32586. var y1items = transformedTiles[1].items;
  32587. var y2items = transformedTiles[2].items;
  32588. var y3items = fourComponents ? transformedTiles[3].items : null;
  32589. shift = components[0].precision - 8;
  32590. offset = (128 << shift) + 0.5;
  32591. max = 255 * (1 << shift);
  32592. maxK = max * 0.5;
  32593. min = -maxK;
  32594. var component0 = tile.components[0];
  32595. var alpha01 = componentsCount - 3;
  32596. jj = y0items.length;
  32597. if (!component0.codingStyleParameters.reversibleTransformation) {
  32598. for (j = 0; j < jj; j++, pos += alpha01) {
  32599. y0 = y0items[j] + offset;
  32600. y1 = y1items[j];
  32601. y2 = y2items[j];
  32602. r = y0 + 1.402 * y2;
  32603. g = y0 - 0.34413 * y1 - 0.71414 * y2;
  32604. b = y0 + 1.772 * y1;
  32605. out[pos++] = r <= 0 ? 0 : r >= max ? 255 : r >> shift;
  32606. out[pos++] = g <= 0 ? 0 : g >= max ? 255 : g >> shift;
  32607. out[pos++] = b <= 0 ? 0 : b >= max ? 255 : b >> shift;
  32608. }
  32609. } else {
  32610. for (j = 0; j < jj; j++, pos += alpha01) {
  32611. y0 = y0items[j] + offset;
  32612. y1 = y1items[j];
  32613. y2 = y2items[j];
  32614. g = y0 - (y2 + y1 >> 2);
  32615. r = g + y2;
  32616. b = g + y1;
  32617. out[pos++] = r <= 0 ? 0 : r >= max ? 255 : r >> shift;
  32618. out[pos++] = g <= 0 ? 0 : g >= max ? 255 : g >> shift;
  32619. out[pos++] = b <= 0 ? 0 : b >= max ? 255 : b >> shift;
  32620. }
  32621. }
  32622. if (fourComponents) {
  32623. for (j = 0, pos = 3; j < jj; j++, pos += 4) {
  32624. k = y3items[j];
  32625. out[pos] = k <= min ? 0 : k >= maxK ? 255 : k + offset >> shift;
  32626. }
  32627. }
  32628. } else {
  32629. for (c = 0; c < componentsCount; c++) {
  32630. var items = transformedTiles[c].items;
  32631. shift = components[c].precision - 8;
  32632. offset = (128 << shift) + 0.5;
  32633. max = 127.5 * (1 << shift);
  32634. min = -max;
  32635. for (pos = c, j = 0, jj = items.length; j < jj; j++) {
  32636. val = items[j];
  32637. out[pos] = val <= min ? 0 : val >= max ? 255 : val + offset >> shift;
  32638. pos += componentsCount;
  32639. }
  32640. }
  32641. }
  32642. resultImages.push(result);
  32643. }
  32644. return resultImages;
  32645. }
  32646. function initializeTile(context, tileIndex) {
  32647. var siz = context.SIZ;
  32648. var componentsCount = siz.Csiz;
  32649. var tile = context.tiles[tileIndex];
  32650. for (var c = 0; c < componentsCount; c++) {
  32651. var component = tile.components[c];
  32652. var qcdOrQcc = context.currentTile.QCC[c] !== undefined ? context.currentTile.QCC[c] : context.currentTile.QCD;
  32653. component.quantizationParameters = qcdOrQcc;
  32654. var codOrCoc = context.currentTile.COC[c] !== undefined ? context.currentTile.COC[c] : context.currentTile.COD;
  32655. component.codingStyleParameters = codOrCoc;
  32656. }
  32657. tile.codingStyleDefaultParameters = context.currentTile.COD;
  32658. }
  32659. var TagTree = function TagTreeClosure() {
  32660. function TagTree(width, height) {
  32661. var levelsLength = log2(Math.max(width, height)) + 1;
  32662. this.levels = [];
  32663. for (var i = 0; i < levelsLength; i++) {
  32664. var level = {
  32665. width: width,
  32666. height: height,
  32667. items: []
  32668. };
  32669. this.levels.push(level);
  32670. width = Math.ceil(width / 2);
  32671. height = Math.ceil(height / 2);
  32672. }
  32673. }
  32674. TagTree.prototype = {
  32675. reset: function TagTree_reset(i, j) {
  32676. var currentLevel = 0, value = 0, level;
  32677. while (currentLevel < this.levels.length) {
  32678. level = this.levels[currentLevel];
  32679. var index = i + j * level.width;
  32680. if (level.items[index] !== undefined) {
  32681. value = level.items[index];
  32682. break;
  32683. }
  32684. level.index = index;
  32685. i >>= 1;
  32686. j >>= 1;
  32687. currentLevel++;
  32688. }
  32689. currentLevel--;
  32690. level = this.levels[currentLevel];
  32691. level.items[level.index] = value;
  32692. this.currentLevel = currentLevel;
  32693. delete this.value;
  32694. },
  32695. incrementValue: function TagTree_incrementValue() {
  32696. var level = this.levels[this.currentLevel];
  32697. level.items[level.index]++;
  32698. },
  32699. nextLevel: function TagTree_nextLevel() {
  32700. var currentLevel = this.currentLevel;
  32701. var level = this.levels[currentLevel];
  32702. var value = level.items[level.index];
  32703. currentLevel--;
  32704. if (currentLevel < 0) {
  32705. this.value = value;
  32706. return false;
  32707. }
  32708. this.currentLevel = currentLevel;
  32709. level = this.levels[currentLevel];
  32710. level.items[level.index] = value;
  32711. return true;
  32712. }
  32713. };
  32714. return TagTree;
  32715. }();
  32716. var InclusionTree = function InclusionTreeClosure() {
  32717. function InclusionTree(width, height, defaultValue) {
  32718. var levelsLength = log2(Math.max(width, height)) + 1;
  32719. this.levels = [];
  32720. for (var i = 0; i < levelsLength; i++) {
  32721. var items = new Uint8Array(width * height);
  32722. for (var j = 0, jj = items.length; j < jj; j++) {
  32723. items[j] = defaultValue;
  32724. }
  32725. var level = {
  32726. width: width,
  32727. height: height,
  32728. items: items
  32729. };
  32730. this.levels.push(level);
  32731. width = Math.ceil(width / 2);
  32732. height = Math.ceil(height / 2);
  32733. }
  32734. }
  32735. InclusionTree.prototype = {
  32736. reset: function InclusionTree_reset(i, j, stopValue) {
  32737. var currentLevel = 0;
  32738. while (currentLevel < this.levels.length) {
  32739. var level = this.levels[currentLevel];
  32740. var index = i + j * level.width;
  32741. level.index = index;
  32742. var value = level.items[index];
  32743. if (value === 0xFF) {
  32744. break;
  32745. }
  32746. if (value > stopValue) {
  32747. this.currentLevel = currentLevel;
  32748. this.propagateValues();
  32749. return false;
  32750. }
  32751. i >>= 1;
  32752. j >>= 1;
  32753. currentLevel++;
  32754. }
  32755. this.currentLevel = currentLevel - 1;
  32756. return true;
  32757. },
  32758. incrementValue: function InclusionTree_incrementValue(stopValue) {
  32759. var level = this.levels[this.currentLevel];
  32760. level.items[level.index] = stopValue + 1;
  32761. this.propagateValues();
  32762. },
  32763. propagateValues: function InclusionTree_propagateValues() {
  32764. var levelIndex = this.currentLevel;
  32765. var level = this.levels[levelIndex];
  32766. var currentValue = level.items[level.index];
  32767. while (--levelIndex >= 0) {
  32768. level = this.levels[levelIndex];
  32769. level.items[level.index] = currentValue;
  32770. }
  32771. },
  32772. nextLevel: function InclusionTree_nextLevel() {
  32773. var currentLevel = this.currentLevel;
  32774. var level = this.levels[currentLevel];
  32775. var value = level.items[level.index];
  32776. level.items[level.index] = 0xFF;
  32777. currentLevel--;
  32778. if (currentLevel < 0) {
  32779. return false;
  32780. }
  32781. this.currentLevel = currentLevel;
  32782. level = this.levels[currentLevel];
  32783. level.items[level.index] = value;
  32784. return true;
  32785. }
  32786. };
  32787. return InclusionTree;
  32788. }();
  32789. var BitModel = function BitModelClosure() {
  32790. var UNIFORM_CONTEXT = 17;
  32791. var RUNLENGTH_CONTEXT = 18;
  32792. var LLAndLHContextsLabel = new Uint8Array([
  32793. 0,
  32794. 5,
  32795. 8,
  32796. 0,
  32797. 3,
  32798. 7,
  32799. 8,
  32800. 0,
  32801. 4,
  32802. 7,
  32803. 8,
  32804. 0,
  32805. 0,
  32806. 0,
  32807. 0,
  32808. 0,
  32809. 1,
  32810. 6,
  32811. 8,
  32812. 0,
  32813. 3,
  32814. 7,
  32815. 8,
  32816. 0,
  32817. 4,
  32818. 7,
  32819. 8,
  32820. 0,
  32821. 0,
  32822. 0,
  32823. 0,
  32824. 0,
  32825. 2,
  32826. 6,
  32827. 8,
  32828. 0,
  32829. 3,
  32830. 7,
  32831. 8,
  32832. 0,
  32833. 4,
  32834. 7,
  32835. 8,
  32836. 0,
  32837. 0,
  32838. 0,
  32839. 0,
  32840. 0,
  32841. 2,
  32842. 6,
  32843. 8,
  32844. 0,
  32845. 3,
  32846. 7,
  32847. 8,
  32848. 0,
  32849. 4,
  32850. 7,
  32851. 8,
  32852. 0,
  32853. 0,
  32854. 0,
  32855. 0,
  32856. 0,
  32857. 2,
  32858. 6,
  32859. 8,
  32860. 0,
  32861. 3,
  32862. 7,
  32863. 8,
  32864. 0,
  32865. 4,
  32866. 7,
  32867. 8
  32868. ]);
  32869. var HLContextLabel = new Uint8Array([
  32870. 0,
  32871. 3,
  32872. 4,
  32873. 0,
  32874. 5,
  32875. 7,
  32876. 7,
  32877. 0,
  32878. 8,
  32879. 8,
  32880. 8,
  32881. 0,
  32882. 0,
  32883. 0,
  32884. 0,
  32885. 0,
  32886. 1,
  32887. 3,
  32888. 4,
  32889. 0,
  32890. 6,
  32891. 7,
  32892. 7,
  32893. 0,
  32894. 8,
  32895. 8,
  32896. 8,
  32897. 0,
  32898. 0,
  32899. 0,
  32900. 0,
  32901. 0,
  32902. 2,
  32903. 3,
  32904. 4,
  32905. 0,
  32906. 6,
  32907. 7,
  32908. 7,
  32909. 0,
  32910. 8,
  32911. 8,
  32912. 8,
  32913. 0,
  32914. 0,
  32915. 0,
  32916. 0,
  32917. 0,
  32918. 2,
  32919. 3,
  32920. 4,
  32921. 0,
  32922. 6,
  32923. 7,
  32924. 7,
  32925. 0,
  32926. 8,
  32927. 8,
  32928. 8,
  32929. 0,
  32930. 0,
  32931. 0,
  32932. 0,
  32933. 0,
  32934. 2,
  32935. 3,
  32936. 4,
  32937. 0,
  32938. 6,
  32939. 7,
  32940. 7,
  32941. 0,
  32942. 8,
  32943. 8,
  32944. 8
  32945. ]);
  32946. var HHContextLabel = new Uint8Array([
  32947. 0,
  32948. 1,
  32949. 2,
  32950. 0,
  32951. 1,
  32952. 2,
  32953. 2,
  32954. 0,
  32955. 2,
  32956. 2,
  32957. 2,
  32958. 0,
  32959. 0,
  32960. 0,
  32961. 0,
  32962. 0,
  32963. 3,
  32964. 4,
  32965. 5,
  32966. 0,
  32967. 4,
  32968. 5,
  32969. 5,
  32970. 0,
  32971. 5,
  32972. 5,
  32973. 5,
  32974. 0,
  32975. 0,
  32976. 0,
  32977. 0,
  32978. 0,
  32979. 6,
  32980. 7,
  32981. 7,
  32982. 0,
  32983. 7,
  32984. 7,
  32985. 7,
  32986. 0,
  32987. 7,
  32988. 7,
  32989. 7,
  32990. 0,
  32991. 0,
  32992. 0,
  32993. 0,
  32994. 0,
  32995. 8,
  32996. 8,
  32997. 8,
  32998. 0,
  32999. 8,
  33000. 8,
  33001. 8,
  33002. 0,
  33003. 8,
  33004. 8,
  33005. 8,
  33006. 0,
  33007. 0,
  33008. 0,
  33009. 0,
  33010. 0,
  33011. 8,
  33012. 8,
  33013. 8,
  33014. 0,
  33015. 8,
  33016. 8,
  33017. 8,
  33018. 0,
  33019. 8,
  33020. 8,
  33021. 8
  33022. ]);
  33023. function BitModel(width, height, subband, zeroBitPlanes, mb) {
  33024. this.width = width;
  33025. this.height = height;
  33026. this.contextLabelTable = subband === 'HH' ? HHContextLabel : subband === 'HL' ? HLContextLabel : LLAndLHContextsLabel;
  33027. var coefficientCount = width * height;
  33028. this.neighborsSignificance = new Uint8Array(coefficientCount);
  33029. this.coefficentsSign = new Uint8Array(coefficientCount);
  33030. this.coefficentsMagnitude = mb > 14 ? new Uint32Array(coefficientCount) : mb > 6 ? new Uint16Array(coefficientCount) : new Uint8Array(coefficientCount);
  33031. this.processingFlags = new Uint8Array(coefficientCount);
  33032. var bitsDecoded = new Uint8Array(coefficientCount);
  33033. if (zeroBitPlanes !== 0) {
  33034. for (var i = 0; i < coefficientCount; i++) {
  33035. bitsDecoded[i] = zeroBitPlanes;
  33036. }
  33037. }
  33038. this.bitsDecoded = bitsDecoded;
  33039. this.reset();
  33040. }
  33041. BitModel.prototype = {
  33042. setDecoder: function BitModel_setDecoder(decoder) {
  33043. this.decoder = decoder;
  33044. },
  33045. reset: function BitModel_reset() {
  33046. this.contexts = new Int8Array(19);
  33047. this.contexts[0] = 4 << 1 | 0;
  33048. this.contexts[UNIFORM_CONTEXT] = 46 << 1 | 0;
  33049. this.contexts[RUNLENGTH_CONTEXT] = 3 << 1 | 0;
  33050. },
  33051. setNeighborsSignificance: function BitModel_setNeighborsSignificance(row, column, index) {
  33052. var neighborsSignificance = this.neighborsSignificance;
  33053. var width = this.width, height = this.height;
  33054. var left = column > 0;
  33055. var right = column + 1 < width;
  33056. var i;
  33057. if (row > 0) {
  33058. i = index - width;
  33059. if (left) {
  33060. neighborsSignificance[i - 1] += 0x10;
  33061. }
  33062. if (right) {
  33063. neighborsSignificance[i + 1] += 0x10;
  33064. }
  33065. neighborsSignificance[i] += 0x04;
  33066. }
  33067. if (row + 1 < height) {
  33068. i = index + width;
  33069. if (left) {
  33070. neighborsSignificance[i - 1] += 0x10;
  33071. }
  33072. if (right) {
  33073. neighborsSignificance[i + 1] += 0x10;
  33074. }
  33075. neighborsSignificance[i] += 0x04;
  33076. }
  33077. if (left) {
  33078. neighborsSignificance[index - 1] += 0x01;
  33079. }
  33080. if (right) {
  33081. neighborsSignificance[index + 1] += 0x01;
  33082. }
  33083. neighborsSignificance[index] |= 0x80;
  33084. },
  33085. runSignificancePropagationPass: function BitModel_runSignificancePropagationPass() {
  33086. var decoder = this.decoder;
  33087. var width = this.width, height = this.height;
  33088. var coefficentsMagnitude = this.coefficentsMagnitude;
  33089. var coefficentsSign = this.coefficentsSign;
  33090. var neighborsSignificance = this.neighborsSignificance;
  33091. var processingFlags = this.processingFlags;
  33092. var contexts = this.contexts;
  33093. var labels = this.contextLabelTable;
  33094. var bitsDecoded = this.bitsDecoded;
  33095. var processedInverseMask = ~1;
  33096. var processedMask = 1;
  33097. var firstMagnitudeBitMask = 2;
  33098. for (var i0 = 0; i0 < height; i0 += 4) {
  33099. for (var j = 0; j < width; j++) {
  33100. var index = i0 * width + j;
  33101. for (var i1 = 0; i1 < 4; i1++, index += width) {
  33102. var i = i0 + i1;
  33103. if (i >= height) {
  33104. break;
  33105. }
  33106. processingFlags[index] &= processedInverseMask;
  33107. if (coefficentsMagnitude[index] || !neighborsSignificance[index]) {
  33108. continue;
  33109. }
  33110. var contextLabel = labels[neighborsSignificance[index]];
  33111. var decision = decoder.readBit(contexts, contextLabel);
  33112. if (decision) {
  33113. var sign = this.decodeSignBit(i, j, index);
  33114. coefficentsSign[index] = sign;
  33115. coefficentsMagnitude[index] = 1;
  33116. this.setNeighborsSignificance(i, j, index);
  33117. processingFlags[index] |= firstMagnitudeBitMask;
  33118. }
  33119. bitsDecoded[index]++;
  33120. processingFlags[index] |= processedMask;
  33121. }
  33122. }
  33123. }
  33124. },
  33125. decodeSignBit: function BitModel_decodeSignBit(row, column, index) {
  33126. var width = this.width, height = this.height;
  33127. var coefficentsMagnitude = this.coefficentsMagnitude;
  33128. var coefficentsSign = this.coefficentsSign;
  33129. var contribution, sign0, sign1, significance1;
  33130. var contextLabel, decoded;
  33131. significance1 = column > 0 && coefficentsMagnitude[index - 1] !== 0;
  33132. if (column + 1 < width && coefficentsMagnitude[index + 1] !== 0) {
  33133. sign1 = coefficentsSign[index + 1];
  33134. if (significance1) {
  33135. sign0 = coefficentsSign[index - 1];
  33136. contribution = 1 - sign1 - sign0;
  33137. } else {
  33138. contribution = 1 - sign1 - sign1;
  33139. }
  33140. } else if (significance1) {
  33141. sign0 = coefficentsSign[index - 1];
  33142. contribution = 1 - sign0 - sign0;
  33143. } else {
  33144. contribution = 0;
  33145. }
  33146. var horizontalContribution = 3 * contribution;
  33147. significance1 = row > 0 && coefficentsMagnitude[index - width] !== 0;
  33148. if (row + 1 < height && coefficentsMagnitude[index + width] !== 0) {
  33149. sign1 = coefficentsSign[index + width];
  33150. if (significance1) {
  33151. sign0 = coefficentsSign[index - width];
  33152. contribution = 1 - sign1 - sign0 + horizontalContribution;
  33153. } else {
  33154. contribution = 1 - sign1 - sign1 + horizontalContribution;
  33155. }
  33156. } else if (significance1) {
  33157. sign0 = coefficentsSign[index - width];
  33158. contribution = 1 - sign0 - sign0 + horizontalContribution;
  33159. } else {
  33160. contribution = horizontalContribution;
  33161. }
  33162. if (contribution >= 0) {
  33163. contextLabel = 9 + contribution;
  33164. decoded = this.decoder.readBit(this.contexts, contextLabel);
  33165. } else {
  33166. contextLabel = 9 - contribution;
  33167. decoded = this.decoder.readBit(this.contexts, contextLabel) ^ 1;
  33168. }
  33169. return decoded;
  33170. },
  33171. runMagnitudeRefinementPass: function BitModel_runMagnitudeRefinementPass() {
  33172. var decoder = this.decoder;
  33173. var width = this.width, height = this.height;
  33174. var coefficentsMagnitude = this.coefficentsMagnitude;
  33175. var neighborsSignificance = this.neighborsSignificance;
  33176. var contexts = this.contexts;
  33177. var bitsDecoded = this.bitsDecoded;
  33178. var processingFlags = this.processingFlags;
  33179. var processedMask = 1;
  33180. var firstMagnitudeBitMask = 2;
  33181. var length = width * height;
  33182. var width4 = width * 4;
  33183. for (var index0 = 0, indexNext; index0 < length; index0 = indexNext) {
  33184. indexNext = Math.min(length, index0 + width4);
  33185. for (var j = 0; j < width; j++) {
  33186. for (var index = index0 + j; index < indexNext; index += width) {
  33187. if (!coefficentsMagnitude[index] || (processingFlags[index] & processedMask) !== 0) {
  33188. continue;
  33189. }
  33190. var contextLabel = 16;
  33191. if ((processingFlags[index] & firstMagnitudeBitMask) !== 0) {
  33192. processingFlags[index] ^= firstMagnitudeBitMask;
  33193. var significance = neighborsSignificance[index] & 127;
  33194. contextLabel = significance === 0 ? 15 : 14;
  33195. }
  33196. var bit = decoder.readBit(contexts, contextLabel);
  33197. coefficentsMagnitude[index] = coefficentsMagnitude[index] << 1 | bit;
  33198. bitsDecoded[index]++;
  33199. processingFlags[index] |= processedMask;
  33200. }
  33201. }
  33202. }
  33203. },
  33204. runCleanupPass: function BitModel_runCleanupPass() {
  33205. var decoder = this.decoder;
  33206. var width = this.width, height = this.height;
  33207. var neighborsSignificance = this.neighborsSignificance;
  33208. var coefficentsMagnitude = this.coefficentsMagnitude;
  33209. var coefficentsSign = this.coefficentsSign;
  33210. var contexts = this.contexts;
  33211. var labels = this.contextLabelTable;
  33212. var bitsDecoded = this.bitsDecoded;
  33213. var processingFlags = this.processingFlags;
  33214. var processedMask = 1;
  33215. var firstMagnitudeBitMask = 2;
  33216. var oneRowDown = width;
  33217. var twoRowsDown = width * 2;
  33218. var threeRowsDown = width * 3;
  33219. var iNext;
  33220. for (var i0 = 0; i0 < height; i0 = iNext) {
  33221. iNext = Math.min(i0 + 4, height);
  33222. var indexBase = i0 * width;
  33223. var checkAllEmpty = i0 + 3 < height;
  33224. for (var j = 0; j < width; j++) {
  33225. var index0 = indexBase + j;
  33226. 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;
  33227. var i1 = 0, index = index0;
  33228. var i = i0, sign;
  33229. if (allEmpty) {
  33230. var hasSignificantCoefficent = decoder.readBit(contexts, RUNLENGTH_CONTEXT);
  33231. if (!hasSignificantCoefficent) {
  33232. bitsDecoded[index0]++;
  33233. bitsDecoded[index0 + oneRowDown]++;
  33234. bitsDecoded[index0 + twoRowsDown]++;
  33235. bitsDecoded[index0 + threeRowsDown]++;
  33236. continue;
  33237. }
  33238. i1 = decoder.readBit(contexts, UNIFORM_CONTEXT) << 1 | decoder.readBit(contexts, UNIFORM_CONTEXT);
  33239. if (i1 !== 0) {
  33240. i = i0 + i1;
  33241. index += i1 * width;
  33242. }
  33243. sign = this.decodeSignBit(i, j, index);
  33244. coefficentsSign[index] = sign;
  33245. coefficentsMagnitude[index] = 1;
  33246. this.setNeighborsSignificance(i, j, index);
  33247. processingFlags[index] |= firstMagnitudeBitMask;
  33248. index = index0;
  33249. for (var i2 = i0; i2 <= i; i2++, index += width) {
  33250. bitsDecoded[index]++;
  33251. }
  33252. i1++;
  33253. }
  33254. for (i = i0 + i1; i < iNext; i++, index += width) {
  33255. if (coefficentsMagnitude[index] || (processingFlags[index] & processedMask) !== 0) {
  33256. continue;
  33257. }
  33258. var contextLabel = labels[neighborsSignificance[index]];
  33259. var decision = decoder.readBit(contexts, contextLabel);
  33260. if (decision === 1) {
  33261. sign = this.decodeSignBit(i, j, index);
  33262. coefficentsSign[index] = sign;
  33263. coefficentsMagnitude[index] = 1;
  33264. this.setNeighborsSignificance(i, j, index);
  33265. processingFlags[index] |= firstMagnitudeBitMask;
  33266. }
  33267. bitsDecoded[index]++;
  33268. }
  33269. }
  33270. }
  33271. },
  33272. checkSegmentationSymbol: function BitModel_checkSegmentationSymbol() {
  33273. var decoder = this.decoder;
  33274. var contexts = this.contexts;
  33275. 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);
  33276. if (symbol !== 0xA) {
  33277. error('JPX Error: Invalid segmentation symbol');
  33278. }
  33279. }
  33280. };
  33281. return BitModel;
  33282. }();
  33283. var Transform = function TransformClosure() {
  33284. function Transform() {
  33285. }
  33286. Transform.prototype.calculate = function transformCalculate(subbands, u0, v0) {
  33287. var ll = subbands[0];
  33288. for (var i = 1, ii = subbands.length; i < ii; i++) {
  33289. ll = this.iterate(ll, subbands[i], u0, v0);
  33290. }
  33291. return ll;
  33292. };
  33293. Transform.prototype.extend = function extend(buffer, offset, size) {
  33294. var i1 = offset - 1, j1 = offset + 1;
  33295. var i2 = offset + size - 2, j2 = offset + size;
  33296. buffer[i1--] = buffer[j1++];
  33297. buffer[j2++] = buffer[i2--];
  33298. buffer[i1--] = buffer[j1++];
  33299. buffer[j2++] = buffer[i2--];
  33300. buffer[i1--] = buffer[j1++];
  33301. buffer[j2++] = buffer[i2--];
  33302. buffer[i1] = buffer[j1];
  33303. buffer[j2] = buffer[i2];
  33304. };
  33305. Transform.prototype.iterate = function Transform_iterate(ll, hl_lh_hh, u0, v0) {
  33306. var llWidth = ll.width, llHeight = ll.height, llItems = ll.items;
  33307. var width = hl_lh_hh.width;
  33308. var height = hl_lh_hh.height;
  33309. var items = hl_lh_hh.items;
  33310. var i, j, k, l, u, v;
  33311. for (k = 0, i = 0; i < llHeight; i++) {
  33312. l = i * 2 * width;
  33313. for (j = 0; j < llWidth; j++, k++, l += 2) {
  33314. items[l] = llItems[k];
  33315. }
  33316. }
  33317. llItems = ll.items = null;
  33318. var bufferPadding = 4;
  33319. var rowBuffer = new Float32Array(width + 2 * bufferPadding);
  33320. if (width === 1) {
  33321. if ((u0 & 1) !== 0) {
  33322. for (v = 0, k = 0; v < height; v++, k += width) {
  33323. items[k] *= 0.5;
  33324. }
  33325. }
  33326. } else {
  33327. for (v = 0, k = 0; v < height; v++, k += width) {
  33328. rowBuffer.set(items.subarray(k, k + width), bufferPadding);
  33329. this.extend(rowBuffer, bufferPadding, width);
  33330. this.filter(rowBuffer, bufferPadding, width);
  33331. items.set(rowBuffer.subarray(bufferPadding, bufferPadding + width), k);
  33332. }
  33333. }
  33334. var numBuffers = 16;
  33335. var colBuffers = [];
  33336. for (i = 0; i < numBuffers; i++) {
  33337. colBuffers.push(new Float32Array(height + 2 * bufferPadding));
  33338. }
  33339. var b, currentBuffer = 0;
  33340. ll = bufferPadding + height;
  33341. if (height === 1) {
  33342. if ((v0 & 1) !== 0) {
  33343. for (u = 0; u < width; u++) {
  33344. items[u] *= 0.5;
  33345. }
  33346. }
  33347. } else {
  33348. for (u = 0; u < width; u++) {
  33349. if (currentBuffer === 0) {
  33350. numBuffers = Math.min(width - u, numBuffers);
  33351. for (k = u, l = bufferPadding; l < ll; k += width, l++) {
  33352. for (b = 0; b < numBuffers; b++) {
  33353. colBuffers[b][l] = items[k + b];
  33354. }
  33355. }
  33356. currentBuffer = numBuffers;
  33357. }
  33358. currentBuffer--;
  33359. var buffer = colBuffers[currentBuffer];
  33360. this.extend(buffer, bufferPadding, height);
  33361. this.filter(buffer, bufferPadding, height);
  33362. if (currentBuffer === 0) {
  33363. k = u - numBuffers + 1;
  33364. for (l = bufferPadding; l < ll; k += width, l++) {
  33365. for (b = 0; b < numBuffers; b++) {
  33366. items[k + b] = colBuffers[b][l];
  33367. }
  33368. }
  33369. }
  33370. }
  33371. }
  33372. return {
  33373. width: width,
  33374. height: height,
  33375. items: items
  33376. };
  33377. };
  33378. return Transform;
  33379. }();
  33380. var IrreversibleTransform = function IrreversibleTransformClosure() {
  33381. function IrreversibleTransform() {
  33382. Transform.call(this);
  33383. }
  33384. IrreversibleTransform.prototype = Object.create(Transform.prototype);
  33385. IrreversibleTransform.prototype.filter = function irreversibleTransformFilter(x, offset, length) {
  33386. var len = length >> 1;
  33387. offset = offset | 0;
  33388. var j, n, current, next;
  33389. var alpha = -1.586134342059924;
  33390. var beta = -0.052980118572961;
  33391. var gamma = 0.882911075530934;
  33392. var delta = 0.443506852043971;
  33393. var K = 1.230174104914001;
  33394. var K_ = 1 / K;
  33395. j = offset - 3;
  33396. for (n = len + 4; n--; j += 2) {
  33397. x[j] *= K_;
  33398. }
  33399. j = offset - 2;
  33400. current = delta * x[j - 1];
  33401. for (n = len + 3; n--; j += 2) {
  33402. next = delta * x[j + 1];
  33403. x[j] = K * x[j] - current - next;
  33404. if (n--) {
  33405. j += 2;
  33406. current = delta * x[j + 1];
  33407. x[j] = K * x[j] - current - next;
  33408. } else {
  33409. break;
  33410. }
  33411. }
  33412. j = offset - 1;
  33413. current = gamma * x[j - 1];
  33414. for (n = len + 2; n--; j += 2) {
  33415. next = gamma * x[j + 1];
  33416. x[j] -= current + next;
  33417. if (n--) {
  33418. j += 2;
  33419. current = gamma * x[j + 1];
  33420. x[j] -= current + next;
  33421. } else {
  33422. break;
  33423. }
  33424. }
  33425. j = offset;
  33426. current = beta * x[j - 1];
  33427. for (n = len + 1; n--; j += 2) {
  33428. next = beta * x[j + 1];
  33429. x[j] -= current + next;
  33430. if (n--) {
  33431. j += 2;
  33432. current = beta * x[j + 1];
  33433. x[j] -= current + next;
  33434. } else {
  33435. break;
  33436. }
  33437. }
  33438. if (len !== 0) {
  33439. j = offset + 1;
  33440. current = alpha * x[j - 1];
  33441. for (n = len; n--; j += 2) {
  33442. next = alpha * x[j + 1];
  33443. x[j] -= current + next;
  33444. if (n--) {
  33445. j += 2;
  33446. current = alpha * x[j + 1];
  33447. x[j] -= current + next;
  33448. } else {
  33449. break;
  33450. }
  33451. }
  33452. }
  33453. };
  33454. return IrreversibleTransform;
  33455. }();
  33456. var ReversibleTransform = function ReversibleTransformClosure() {
  33457. function ReversibleTransform() {
  33458. Transform.call(this);
  33459. }
  33460. ReversibleTransform.prototype = Object.create(Transform.prototype);
  33461. ReversibleTransform.prototype.filter = function reversibleTransformFilter(x, offset, length) {
  33462. var len = length >> 1;
  33463. offset = offset | 0;
  33464. var j, n;
  33465. for (j = offset, n = len + 1; n--; j += 2) {
  33466. x[j] -= x[j - 1] + x[j + 1] + 2 >> 2;
  33467. }
  33468. for (j = offset + 1, n = len; n--; j += 2) {
  33469. x[j] += x[j - 1] + x[j + 1] >> 1;
  33470. }
  33471. };
  33472. return ReversibleTransform;
  33473. }();
  33474. return JpxImage;
  33475. }();
  33476. exports.JpxImage = JpxImage;
  33477. /***/ }),
  33478. /* 20 */
  33479. /***/ (function(module, exports, __w_pdfjs_require__) {
  33480. "use strict";
  33481. var sharedUtil = __w_pdfjs_require__(0);
  33482. var corePrimitives = __w_pdfjs_require__(1);
  33483. var coreCrypto = __w_pdfjs_require__(17);
  33484. var coreParser = __w_pdfjs_require__(6);
  33485. var coreChunkedStream = __w_pdfjs_require__(16);
  33486. var coreColorSpace = __w_pdfjs_require__(4);
  33487. var InvalidPDFException = sharedUtil.InvalidPDFException;
  33488. var MissingDataException = sharedUtil.MissingDataException;
  33489. var XRefParseException = sharedUtil.XRefParseException;
  33490. var assert = sharedUtil.assert;
  33491. var bytesToString = sharedUtil.bytesToString;
  33492. var createPromiseCapability = sharedUtil.createPromiseCapability;
  33493. var error = sharedUtil.error;
  33494. var info = sharedUtil.info;
  33495. var isArray = sharedUtil.isArray;
  33496. var isBool = sharedUtil.isBool;
  33497. var isInt = sharedUtil.isInt;
  33498. var isString = sharedUtil.isString;
  33499. var shadow = sharedUtil.shadow;
  33500. var stringToPDFString = sharedUtil.stringToPDFString;
  33501. var stringToUTF8String = sharedUtil.stringToUTF8String;
  33502. var warn = sharedUtil.warn;
  33503. var createValidAbsoluteUrl = sharedUtil.createValidAbsoluteUrl;
  33504. var Util = sharedUtil.Util;
  33505. var Ref = corePrimitives.Ref;
  33506. var RefSet = corePrimitives.RefSet;
  33507. var RefSetCache = corePrimitives.RefSetCache;
  33508. var isName = corePrimitives.isName;
  33509. var isCmd = corePrimitives.isCmd;
  33510. var isDict = corePrimitives.isDict;
  33511. var isRef = corePrimitives.isRef;
  33512. var isRefsEqual = corePrimitives.isRefsEqual;
  33513. var isStream = corePrimitives.isStream;
  33514. var CipherTransformFactory = coreCrypto.CipherTransformFactory;
  33515. var Lexer = coreParser.Lexer;
  33516. var Parser = coreParser.Parser;
  33517. var ChunkedStream = coreChunkedStream.ChunkedStream;
  33518. var ColorSpace = coreColorSpace.ColorSpace;
  33519. var Catalog = function CatalogClosure() {
  33520. function Catalog(pdfManager, xref, pageFactory) {
  33521. this.pdfManager = pdfManager;
  33522. this.xref = xref;
  33523. this.catDict = xref.getCatalogObj();
  33524. this.fontCache = new RefSetCache();
  33525. this.builtInCMapCache = Object.create(null);
  33526. assert(isDict(this.catDict), 'catalog object is not a dictionary');
  33527. this.pageFactory = pageFactory;
  33528. this.pagePromises = [];
  33529. }
  33530. Catalog.prototype = {
  33531. get metadata() {
  33532. var streamRef = this.catDict.getRaw('Metadata');
  33533. if (!isRef(streamRef)) {
  33534. return shadow(this, 'metadata', null);
  33535. }
  33536. var encryptMetadata = !this.xref.encrypt ? false : this.xref.encrypt.encryptMetadata;
  33537. var stream = this.xref.fetch(streamRef, !encryptMetadata);
  33538. var metadata;
  33539. if (stream && isDict(stream.dict)) {
  33540. var type = stream.dict.get('Type');
  33541. var subtype = stream.dict.get('Subtype');
  33542. if (isName(type, 'Metadata') && isName(subtype, 'XML')) {
  33543. try {
  33544. metadata = stringToUTF8String(bytesToString(stream.getBytes()));
  33545. } catch (e) {
  33546. info('Skipping invalid metadata.');
  33547. }
  33548. }
  33549. }
  33550. return shadow(this, 'metadata', metadata);
  33551. },
  33552. get toplevelPagesDict() {
  33553. var pagesObj = this.catDict.get('Pages');
  33554. assert(isDict(pagesObj), 'invalid top-level pages dictionary');
  33555. return shadow(this, 'toplevelPagesDict', pagesObj);
  33556. },
  33557. get documentOutline() {
  33558. var obj = null;
  33559. try {
  33560. obj = this.readDocumentOutline();
  33561. } catch (ex) {
  33562. if (ex instanceof MissingDataException) {
  33563. throw ex;
  33564. }
  33565. warn('Unable to read document outline');
  33566. }
  33567. return shadow(this, 'documentOutline', obj);
  33568. },
  33569. readDocumentOutline: function Catalog_readDocumentOutline() {
  33570. var obj = this.catDict.get('Outlines');
  33571. if (!isDict(obj)) {
  33572. return null;
  33573. }
  33574. obj = obj.getRaw('First');
  33575. if (!isRef(obj)) {
  33576. return null;
  33577. }
  33578. var root = { items: [] };
  33579. var queue = [{
  33580. obj: obj,
  33581. parent: root
  33582. }];
  33583. var processed = new RefSet();
  33584. processed.put(obj);
  33585. var xref = this.xref, blackColor = new Uint8Array(3);
  33586. while (queue.length > 0) {
  33587. var i = queue.shift();
  33588. var outlineDict = xref.fetchIfRef(i.obj);
  33589. if (outlineDict === null) {
  33590. continue;
  33591. }
  33592. assert(outlineDict.has('Title'), 'Invalid outline item');
  33593. var data = {
  33594. url: null,
  33595. dest: null
  33596. };
  33597. Catalog.parseDestDictionary({
  33598. destDict: outlineDict,
  33599. resultObj: data,
  33600. docBaseUrl: this.pdfManager.docBaseUrl
  33601. });
  33602. var title = outlineDict.get('Title');
  33603. var flags = outlineDict.get('F') || 0;
  33604. var color = outlineDict.getArray('C'), rgbColor = blackColor;
  33605. if (isArray(color) && color.length === 3 && (color[0] !== 0 || color[1] !== 0 || color[2] !== 0)) {
  33606. rgbColor = ColorSpace.singletons.rgb.getRgb(color, 0);
  33607. }
  33608. var outlineItem = {
  33609. dest: data.dest,
  33610. url: data.url,
  33611. unsafeUrl: data.unsafeUrl,
  33612. newWindow: data.newWindow,
  33613. title: stringToPDFString(title),
  33614. color: rgbColor,
  33615. count: outlineDict.get('Count'),
  33616. bold: !!(flags & 2),
  33617. italic: !!(flags & 1),
  33618. items: []
  33619. };
  33620. i.parent.items.push(outlineItem);
  33621. obj = outlineDict.getRaw('First');
  33622. if (isRef(obj) && !processed.has(obj)) {
  33623. queue.push({
  33624. obj: obj,
  33625. parent: outlineItem
  33626. });
  33627. processed.put(obj);
  33628. }
  33629. obj = outlineDict.getRaw('Next');
  33630. if (isRef(obj) && !processed.has(obj)) {
  33631. queue.push({
  33632. obj: obj,
  33633. parent: i.parent
  33634. });
  33635. processed.put(obj);
  33636. }
  33637. }
  33638. return root.items.length > 0 ? root.items : null;
  33639. },
  33640. get numPages() {
  33641. var obj = this.toplevelPagesDict.get('Count');
  33642. assert(isInt(obj), 'page count in top level pages object is not an integer');
  33643. return shadow(this, 'num', obj);
  33644. },
  33645. get destinations() {
  33646. function fetchDestination(dest) {
  33647. return isDict(dest) ? dest.get('D') : dest;
  33648. }
  33649. var xref = this.xref;
  33650. var dests = {}, nameTreeRef, nameDictionaryRef;
  33651. var obj = this.catDict.get('Names');
  33652. if (obj && obj.has('Dests')) {
  33653. nameTreeRef = obj.getRaw('Dests');
  33654. } else if (this.catDict.has('Dests')) {
  33655. nameDictionaryRef = this.catDict.get('Dests');
  33656. }
  33657. if (nameDictionaryRef) {
  33658. obj = nameDictionaryRef;
  33659. obj.forEach(function catalogForEach(key, value) {
  33660. if (!value) {
  33661. return;
  33662. }
  33663. dests[key] = fetchDestination(value);
  33664. });
  33665. }
  33666. if (nameTreeRef) {
  33667. var nameTree = new NameTree(nameTreeRef, xref);
  33668. var names = nameTree.getAll();
  33669. for (var name in names) {
  33670. dests[name] = fetchDestination(names[name]);
  33671. }
  33672. }
  33673. return shadow(this, 'destinations', dests);
  33674. },
  33675. getDestination: function Catalog_getDestination(destinationId) {
  33676. function fetchDestination(dest) {
  33677. return isDict(dest) ? dest.get('D') : dest;
  33678. }
  33679. var xref = this.xref;
  33680. var dest = null, nameTreeRef, nameDictionaryRef;
  33681. var obj = this.catDict.get('Names');
  33682. if (obj && obj.has('Dests')) {
  33683. nameTreeRef = obj.getRaw('Dests');
  33684. } else if (this.catDict.has('Dests')) {
  33685. nameDictionaryRef = this.catDict.get('Dests');
  33686. }
  33687. if (nameDictionaryRef) {
  33688. var value = nameDictionaryRef.get(destinationId);
  33689. if (value) {
  33690. dest = fetchDestination(value);
  33691. }
  33692. }
  33693. if (nameTreeRef) {
  33694. var nameTree = new NameTree(nameTreeRef, xref);
  33695. dest = fetchDestination(nameTree.get(destinationId));
  33696. }
  33697. return dest;
  33698. },
  33699. get pageLabels() {
  33700. var obj = null;
  33701. try {
  33702. obj = this.readPageLabels();
  33703. } catch (ex) {
  33704. if (ex instanceof MissingDataException) {
  33705. throw ex;
  33706. }
  33707. warn('Unable to read page labels.');
  33708. }
  33709. return shadow(this, 'pageLabels', obj);
  33710. },
  33711. readPageLabels: function Catalog_readPageLabels() {
  33712. var obj = this.catDict.getRaw('PageLabels');
  33713. if (!obj) {
  33714. return null;
  33715. }
  33716. var pageLabels = new Array(this.numPages);
  33717. var style = null;
  33718. var prefix = '';
  33719. var numberTree = new NumberTree(obj, this.xref);
  33720. var nums = numberTree.getAll();
  33721. var currentLabel = '', currentIndex = 1;
  33722. for (var i = 0, ii = this.numPages; i < ii; i++) {
  33723. if (i in nums) {
  33724. var labelDict = nums[i];
  33725. assert(isDict(labelDict), 'The PageLabel is not a dictionary.');
  33726. var type = labelDict.get('Type');
  33727. assert(!type || isName(type, 'PageLabel'), 'Invalid type in PageLabel dictionary.');
  33728. var s = labelDict.get('S');
  33729. assert(!s || isName(s), 'Invalid style in PageLabel dictionary.');
  33730. style = s ? s.name : null;
  33731. var p = labelDict.get('P');
  33732. assert(!p || isString(p), 'Invalid prefix in PageLabel dictionary.');
  33733. prefix = p ? stringToPDFString(p) : '';
  33734. var st = labelDict.get('St');
  33735. assert(!st || isInt(st) && st >= 1, 'Invalid start in PageLabel dictionary.');
  33736. currentIndex = st || 1;
  33737. }
  33738. switch (style) {
  33739. case 'D':
  33740. currentLabel = currentIndex;
  33741. break;
  33742. case 'R':
  33743. case 'r':
  33744. currentLabel = Util.toRoman(currentIndex, style === 'r');
  33745. break;
  33746. case 'A':
  33747. case 'a':
  33748. var LIMIT = 26;
  33749. var A_UPPER_CASE = 0x41, A_LOWER_CASE = 0x61;
  33750. var baseCharCode = style === 'a' ? A_LOWER_CASE : A_UPPER_CASE;
  33751. var letterIndex = currentIndex - 1;
  33752. var character = String.fromCharCode(baseCharCode + letterIndex % LIMIT);
  33753. var charBuf = [];
  33754. for (var j = 0, jj = letterIndex / LIMIT | 0; j <= jj; j++) {
  33755. charBuf.push(character);
  33756. }
  33757. currentLabel = charBuf.join('');
  33758. break;
  33759. default:
  33760. assert(!style, 'Invalid style "' + style + '" in PageLabel dictionary.');
  33761. }
  33762. pageLabels[i] = prefix + currentLabel;
  33763. currentLabel = '';
  33764. currentIndex++;
  33765. }
  33766. return pageLabels;
  33767. },
  33768. get attachments() {
  33769. var xref = this.xref;
  33770. var attachments = null, nameTreeRef;
  33771. var obj = this.catDict.get('Names');
  33772. if (obj) {
  33773. nameTreeRef = obj.getRaw('EmbeddedFiles');
  33774. }
  33775. if (nameTreeRef) {
  33776. var nameTree = new NameTree(nameTreeRef, xref);
  33777. var names = nameTree.getAll();
  33778. for (var name in names) {
  33779. var fs = new FileSpec(names[name], xref);
  33780. if (!attachments) {
  33781. attachments = Object.create(null);
  33782. }
  33783. attachments[stringToPDFString(name)] = fs.serializable;
  33784. }
  33785. }
  33786. return shadow(this, 'attachments', attachments);
  33787. },
  33788. get javaScript() {
  33789. var xref = this.xref;
  33790. var obj = this.catDict.get('Names');
  33791. var javaScript = [];
  33792. function appendIfJavaScriptDict(jsDict) {
  33793. var type = jsDict.get('S');
  33794. if (!isName(type, 'JavaScript')) {
  33795. return;
  33796. }
  33797. var js = jsDict.get('JS');
  33798. if (isStream(js)) {
  33799. js = bytesToString(js.getBytes());
  33800. } else if (!isString(js)) {
  33801. return;
  33802. }
  33803. javaScript.push(stringToPDFString(js));
  33804. }
  33805. if (obj && obj.has('JavaScript')) {
  33806. var nameTree = new NameTree(obj.getRaw('JavaScript'), xref);
  33807. var names = nameTree.getAll();
  33808. for (var name in names) {
  33809. var jsDict = names[name];
  33810. if (isDict(jsDict)) {
  33811. appendIfJavaScriptDict(jsDict);
  33812. }
  33813. }
  33814. }
  33815. var openactionDict = this.catDict.get('OpenAction');
  33816. if (isDict(openactionDict, 'Action')) {
  33817. var actionType = openactionDict.get('S');
  33818. if (isName(actionType, 'Named')) {
  33819. var action = openactionDict.get('N');
  33820. if (isName(action, 'Print')) {
  33821. javaScript.push('print({});');
  33822. }
  33823. } else {
  33824. appendIfJavaScriptDict(openactionDict);
  33825. }
  33826. }
  33827. return shadow(this, 'javaScript', javaScript);
  33828. },
  33829. cleanup: function Catalog_cleanup() {
  33830. var promises = [];
  33831. this.fontCache.forEach(function (promise) {
  33832. promises.push(promise);
  33833. });
  33834. return Promise.all(promises).then(function (translatedFonts) {
  33835. for (var i = 0, ii = translatedFonts.length; i < ii; i++) {
  33836. var font = translatedFonts[i].dict;
  33837. delete font.translated;
  33838. }
  33839. this.fontCache.clear();
  33840. this.builtInCMapCache = Object.create(null);
  33841. }.bind(this));
  33842. },
  33843. getPage: function Catalog_getPage(pageIndex) {
  33844. if (!(pageIndex in this.pagePromises)) {
  33845. this.pagePromises[pageIndex] = this.getPageDict(pageIndex).then(function (a) {
  33846. var dict = a[0];
  33847. var ref = a[1];
  33848. return this.pageFactory.createPage(pageIndex, dict, ref, this.fontCache, this.builtInCMapCache);
  33849. }.bind(this));
  33850. }
  33851. return this.pagePromises[pageIndex];
  33852. },
  33853. getPageDict: function Catalog_getPageDict(pageIndex) {
  33854. var capability = createPromiseCapability();
  33855. var nodesToVisit = [this.catDict.getRaw('Pages')];
  33856. var currentPageIndex = 0;
  33857. var xref = this.xref;
  33858. function next() {
  33859. while (nodesToVisit.length) {
  33860. var currentNode = nodesToVisit.pop();
  33861. if (isRef(currentNode)) {
  33862. xref.fetchAsync(currentNode).then(function (obj) {
  33863. if (isDict(obj, 'Page') || isDict(obj) && !obj.has('Kids')) {
  33864. if (pageIndex === currentPageIndex) {
  33865. capability.resolve([
  33866. obj,
  33867. currentNode
  33868. ]);
  33869. } else {
  33870. currentPageIndex++;
  33871. next();
  33872. }
  33873. return;
  33874. }
  33875. nodesToVisit.push(obj);
  33876. next();
  33877. }, capability.reject);
  33878. return;
  33879. }
  33880. assert(isDict(currentNode), 'page dictionary kid reference points to wrong type of object');
  33881. var count = currentNode.get('Count');
  33882. if (currentPageIndex + count <= pageIndex) {
  33883. currentPageIndex += count;
  33884. continue;
  33885. }
  33886. var kids = currentNode.get('Kids');
  33887. assert(isArray(kids), 'page dictionary kids object is not an array');
  33888. for (var last = kids.length - 1; last >= 0; last--) {
  33889. nodesToVisit.push(kids[last]);
  33890. }
  33891. }
  33892. capability.reject('Page index ' + pageIndex + ' not found.');
  33893. }
  33894. next();
  33895. return capability.promise;
  33896. },
  33897. getPageIndex: function Catalog_getPageIndex(pageRef) {
  33898. var xref = this.xref;
  33899. function pagesBeforeRef(kidRef) {
  33900. var total = 0;
  33901. var parentRef;
  33902. return xref.fetchAsync(kidRef).then(function (node) {
  33903. if (isRefsEqual(kidRef, pageRef) && !isDict(node, 'Page') && !(isDict(node) && !node.has('Type') && node.has('Contents'))) {
  33904. throw new Error('The reference does not point to a /Page Dict.');
  33905. }
  33906. if (!node) {
  33907. return null;
  33908. }
  33909. assert(isDict(node), 'node must be a Dict.');
  33910. parentRef = node.getRaw('Parent');
  33911. return node.getAsync('Parent');
  33912. }).then(function (parent) {
  33913. if (!parent) {
  33914. return null;
  33915. }
  33916. assert(isDict(parent), 'parent must be a Dict.');
  33917. return parent.getAsync('Kids');
  33918. }).then(function (kids) {
  33919. if (!kids) {
  33920. return null;
  33921. }
  33922. var kidPromises = [];
  33923. var found = false;
  33924. for (var i = 0; i < kids.length; i++) {
  33925. var kid = kids[i];
  33926. assert(isRef(kid), 'kid must be a Ref.');
  33927. if (kid.num === kidRef.num) {
  33928. found = true;
  33929. break;
  33930. }
  33931. kidPromises.push(xref.fetchAsync(kid).then(function (kid) {
  33932. if (kid.has('Count')) {
  33933. var count = kid.get('Count');
  33934. total += count;
  33935. } else {
  33936. total++;
  33937. }
  33938. }));
  33939. }
  33940. if (!found) {
  33941. error('kid ref not found in parents kids');
  33942. }
  33943. return Promise.all(kidPromises).then(function () {
  33944. return [
  33945. total,
  33946. parentRef
  33947. ];
  33948. });
  33949. });
  33950. }
  33951. var total = 0;
  33952. function next(ref) {
  33953. return pagesBeforeRef(ref).then(function (args) {
  33954. if (!args) {
  33955. return total;
  33956. }
  33957. var count = args[0];
  33958. var parentRef = args[1];
  33959. total += count;
  33960. return next(parentRef);
  33961. });
  33962. }
  33963. return next(pageRef);
  33964. }
  33965. };
  33966. Catalog.parseDestDictionary = function Catalog_parseDestDictionary(params) {
  33967. function addDefaultProtocolToUrl(url) {
  33968. if (url.indexOf('www.') === 0) {
  33969. return 'http://' + url;
  33970. }
  33971. return url;
  33972. }
  33973. function tryConvertUrlEncoding(url) {
  33974. try {
  33975. return stringToUTF8String(url);
  33976. } catch (e) {
  33977. return url;
  33978. }
  33979. }
  33980. var destDict = params.destDict;
  33981. if (!isDict(destDict)) {
  33982. warn('Catalog_parseDestDictionary: "destDict" must be a dictionary.');
  33983. return;
  33984. }
  33985. var resultObj = params.resultObj;
  33986. if (typeof resultObj !== 'object') {
  33987. warn('Catalog_parseDestDictionary: "resultObj" must be an object.');
  33988. return;
  33989. }
  33990. var docBaseUrl = params.docBaseUrl || null;
  33991. var action = destDict.get('A'), url, dest;
  33992. if (isDict(action)) {
  33993. var linkType = action.get('S').name;
  33994. switch (linkType) {
  33995. case 'URI':
  33996. url = action.get('URI');
  33997. if (isName(url)) {
  33998. url = '/' + url.name;
  33999. } else if (isString(url)) {
  34000. url = addDefaultProtocolToUrl(url);
  34001. }
  34002. break;
  34003. case 'GoTo':
  34004. dest = action.get('D');
  34005. break;
  34006. case 'Launch':
  34007. case 'GoToR':
  34008. var urlDict = action.get('F');
  34009. if (isDict(urlDict)) {
  34010. url = urlDict.get('F') || null;
  34011. } else if (isString(urlDict)) {
  34012. url = urlDict;
  34013. }
  34014. var remoteDest = action.get('D');
  34015. if (remoteDest) {
  34016. if (isName(remoteDest)) {
  34017. remoteDest = remoteDest.name;
  34018. }
  34019. if (isString(url)) {
  34020. var baseUrl = url.split('#')[0];
  34021. if (isString(remoteDest)) {
  34022. url = baseUrl + '#' + (/^\d+$/.test(remoteDest) ? 'nameddest=' : '') + remoteDest;
  34023. } else if (isArray(remoteDest)) {
  34024. url = baseUrl + '#' + JSON.stringify(remoteDest);
  34025. }
  34026. }
  34027. }
  34028. var newWindow = action.get('NewWindow');
  34029. if (isBool(newWindow)) {
  34030. resultObj.newWindow = newWindow;
  34031. }
  34032. break;
  34033. case 'Named':
  34034. var namedAction = action.get('N');
  34035. if (isName(namedAction)) {
  34036. resultObj.action = namedAction.name;
  34037. }
  34038. break;
  34039. case 'JavaScript':
  34040. var jsAction = action.get('JS'), js;
  34041. if (isStream(jsAction)) {
  34042. js = bytesToString(jsAction.getBytes());
  34043. } else if (isString(jsAction)) {
  34044. js = jsAction;
  34045. }
  34046. if (js) {
  34047. var URL_OPEN_METHODS = [
  34048. 'app.launchURL',
  34049. 'window.open'
  34050. ];
  34051. var regex = new RegExp('^\\s*(' + URL_OPEN_METHODS.join('|').split('.').join('\\.') + ')\\((?:\'|\")([^\'\"]*)(?:\'|\")(?:,\\s*(\\w+)\\)|\\))', 'i');
  34052. var jsUrl = regex.exec(stringToPDFString(js));
  34053. if (jsUrl && jsUrl[2]) {
  34054. url = jsUrl[2];
  34055. if (jsUrl[3] === 'true' && jsUrl[1] === 'app.launchURL') {
  34056. resultObj.newWindow = true;
  34057. }
  34058. break;
  34059. }
  34060. }
  34061. default:
  34062. warn('Catalog_parseDestDictionary: Unrecognized link type "' + linkType + '".');
  34063. break;
  34064. }
  34065. } else if (destDict.has('Dest')) {
  34066. dest = destDict.get('Dest');
  34067. }
  34068. if (isString(url)) {
  34069. url = tryConvertUrlEncoding(url);
  34070. var absoluteUrl = createValidAbsoluteUrl(url, docBaseUrl);
  34071. if (absoluteUrl) {
  34072. resultObj.url = absoluteUrl.href;
  34073. }
  34074. resultObj.unsafeUrl = url;
  34075. }
  34076. if (dest) {
  34077. if (isName(dest)) {
  34078. dest = dest.name;
  34079. }
  34080. if (isString(dest) || isArray(dest)) {
  34081. resultObj.dest = dest;
  34082. }
  34083. }
  34084. };
  34085. return Catalog;
  34086. }();
  34087. var XRef = function XRefClosure() {
  34088. function XRef(stream, pdfManager) {
  34089. this.stream = stream;
  34090. this.pdfManager = pdfManager;
  34091. this.entries = [];
  34092. this.xrefstms = Object.create(null);
  34093. this.cache = [];
  34094. this.stats = {
  34095. streamTypes: [],
  34096. fontTypes: []
  34097. };
  34098. }
  34099. XRef.prototype = {
  34100. setStartXRef: function XRef_setStartXRef(startXRef) {
  34101. this.startXRefQueue = [startXRef];
  34102. },
  34103. parse: function XRef_parse(recoveryMode) {
  34104. var trailerDict;
  34105. if (!recoveryMode) {
  34106. trailerDict = this.readXRef();
  34107. } else {
  34108. warn('Indexing all PDF objects');
  34109. trailerDict = this.indexObjects();
  34110. }
  34111. trailerDict.assignXref(this);
  34112. this.trailer = trailerDict;
  34113. var encrypt = trailerDict.get('Encrypt');
  34114. if (isDict(encrypt)) {
  34115. var ids = trailerDict.get('ID');
  34116. var fileId = ids && ids.length ? ids[0] : '';
  34117. encrypt.suppressEncryption = true;
  34118. this.encrypt = new CipherTransformFactory(encrypt, fileId, this.pdfManager.password);
  34119. }
  34120. if (!(this.root = trailerDict.get('Root'))) {
  34121. error('Invalid root reference');
  34122. }
  34123. },
  34124. processXRefTable: function XRef_processXRefTable(parser) {
  34125. if (!('tableState' in this)) {
  34126. this.tableState = {
  34127. entryNum: 0,
  34128. streamPos: parser.lexer.stream.pos,
  34129. parserBuf1: parser.buf1,
  34130. parserBuf2: parser.buf2
  34131. };
  34132. }
  34133. var obj = this.readXRefTable(parser);
  34134. if (!isCmd(obj, 'trailer')) {
  34135. error('Invalid XRef table: could not find trailer dictionary');
  34136. }
  34137. var dict = parser.getObj();
  34138. if (!isDict(dict) && dict.dict) {
  34139. dict = dict.dict;
  34140. }
  34141. if (!isDict(dict)) {
  34142. error('Invalid XRef table: could not parse trailer dictionary');
  34143. }
  34144. delete this.tableState;
  34145. return dict;
  34146. },
  34147. readXRefTable: function XRef_readXRefTable(parser) {
  34148. var stream = parser.lexer.stream;
  34149. var tableState = this.tableState;
  34150. stream.pos = tableState.streamPos;
  34151. parser.buf1 = tableState.parserBuf1;
  34152. parser.buf2 = tableState.parserBuf2;
  34153. var obj;
  34154. while (true) {
  34155. if (!('firstEntryNum' in tableState) || !('entryCount' in tableState)) {
  34156. if (isCmd(obj = parser.getObj(), 'trailer')) {
  34157. break;
  34158. }
  34159. tableState.firstEntryNum = obj;
  34160. tableState.entryCount = parser.getObj();
  34161. }
  34162. var first = tableState.firstEntryNum;
  34163. var count = tableState.entryCount;
  34164. if (!isInt(first) || !isInt(count)) {
  34165. error('Invalid XRef table: wrong types in subsection header');
  34166. }
  34167. for (var i = tableState.entryNum; i < count; i++) {
  34168. tableState.streamPos = stream.pos;
  34169. tableState.entryNum = i;
  34170. tableState.parserBuf1 = parser.buf1;
  34171. tableState.parserBuf2 = parser.buf2;
  34172. var entry = {};
  34173. entry.offset = parser.getObj();
  34174. entry.gen = parser.getObj();
  34175. var type = parser.getObj();
  34176. if (isCmd(type, 'f')) {
  34177. entry.free = true;
  34178. } else if (isCmd(type, 'n')) {
  34179. entry.uncompressed = true;
  34180. }
  34181. if (!isInt(entry.offset) || !isInt(entry.gen) || !(entry.free || entry.uncompressed)) {
  34182. error('Invalid entry in XRef subsection: ' + first + ', ' + count);
  34183. }
  34184. if (i === 0 && entry.free && first === 1) {
  34185. first = 0;
  34186. }
  34187. if (!this.entries[i + first]) {
  34188. this.entries[i + first] = entry;
  34189. }
  34190. }
  34191. tableState.entryNum = 0;
  34192. tableState.streamPos = stream.pos;
  34193. tableState.parserBuf1 = parser.buf1;
  34194. tableState.parserBuf2 = parser.buf2;
  34195. delete tableState.firstEntryNum;
  34196. delete tableState.entryCount;
  34197. }
  34198. if (this.entries[0] && !this.entries[0].free) {
  34199. error('Invalid XRef table: unexpected first object');
  34200. }
  34201. return obj;
  34202. },
  34203. processXRefStream: function XRef_processXRefStream(stream) {
  34204. if (!('streamState' in this)) {
  34205. var streamParameters = stream.dict;
  34206. var byteWidths = streamParameters.get('W');
  34207. var range = streamParameters.get('Index');
  34208. if (!range) {
  34209. range = [
  34210. 0,
  34211. streamParameters.get('Size')
  34212. ];
  34213. }
  34214. this.streamState = {
  34215. entryRanges: range,
  34216. byteWidths: byteWidths,
  34217. entryNum: 0,
  34218. streamPos: stream.pos
  34219. };
  34220. }
  34221. this.readXRefStream(stream);
  34222. delete this.streamState;
  34223. return stream.dict;
  34224. },
  34225. readXRefStream: function XRef_readXRefStream(stream) {
  34226. var i, j;
  34227. var streamState = this.streamState;
  34228. stream.pos = streamState.streamPos;
  34229. var byteWidths = streamState.byteWidths;
  34230. var typeFieldWidth = byteWidths[0];
  34231. var offsetFieldWidth = byteWidths[1];
  34232. var generationFieldWidth = byteWidths[2];
  34233. var entryRanges = streamState.entryRanges;
  34234. while (entryRanges.length > 0) {
  34235. var first = entryRanges[0];
  34236. var n = entryRanges[1];
  34237. if (!isInt(first) || !isInt(n)) {
  34238. error('Invalid XRef range fields: ' + first + ', ' + n);
  34239. }
  34240. if (!isInt(typeFieldWidth) || !isInt(offsetFieldWidth) || !isInt(generationFieldWidth)) {
  34241. error('Invalid XRef entry fields length: ' + first + ', ' + n);
  34242. }
  34243. for (i = streamState.entryNum; i < n; ++i) {
  34244. streamState.entryNum = i;
  34245. streamState.streamPos = stream.pos;
  34246. var type = 0, offset = 0, generation = 0;
  34247. for (j = 0; j < typeFieldWidth; ++j) {
  34248. type = type << 8 | stream.getByte();
  34249. }
  34250. if (typeFieldWidth === 0) {
  34251. type = 1;
  34252. }
  34253. for (j = 0; j < offsetFieldWidth; ++j) {
  34254. offset = offset << 8 | stream.getByte();
  34255. }
  34256. for (j = 0; j < generationFieldWidth; ++j) {
  34257. generation = generation << 8 | stream.getByte();
  34258. }
  34259. var entry = {};
  34260. entry.offset = offset;
  34261. entry.gen = generation;
  34262. switch (type) {
  34263. case 0:
  34264. entry.free = true;
  34265. break;
  34266. case 1:
  34267. entry.uncompressed = true;
  34268. break;
  34269. case 2:
  34270. break;
  34271. default:
  34272. error('Invalid XRef entry type: ' + type);
  34273. }
  34274. if (!this.entries[first + i]) {
  34275. this.entries[first + i] = entry;
  34276. }
  34277. }
  34278. streamState.entryNum = 0;
  34279. streamState.streamPos = stream.pos;
  34280. entryRanges.splice(0, 2);
  34281. }
  34282. },
  34283. indexObjects: function XRef_indexObjects() {
  34284. var TAB = 0x9, LF = 0xA, CR = 0xD, SPACE = 0x20;
  34285. var PERCENT = 0x25, LT = 0x3C;
  34286. function readToken(data, offset) {
  34287. var token = '', ch = data[offset];
  34288. while (ch !== LF && ch !== CR && ch !== LT) {
  34289. if (++offset >= data.length) {
  34290. break;
  34291. }
  34292. token += String.fromCharCode(ch);
  34293. ch = data[offset];
  34294. }
  34295. return token;
  34296. }
  34297. function skipUntil(data, offset, what) {
  34298. var length = what.length, dataLength = data.length;
  34299. var skipped = 0;
  34300. while (offset < dataLength) {
  34301. var i = 0;
  34302. while (i < length && data[offset + i] === what[i]) {
  34303. ++i;
  34304. }
  34305. if (i >= length) {
  34306. break;
  34307. }
  34308. offset++;
  34309. skipped++;
  34310. }
  34311. return skipped;
  34312. }
  34313. var objRegExp = /^(\d+)\s+(\d+)\s+obj\b/;
  34314. var trailerBytes = new Uint8Array([
  34315. 116,
  34316. 114,
  34317. 97,
  34318. 105,
  34319. 108,
  34320. 101,
  34321. 114
  34322. ]);
  34323. var startxrefBytes = new Uint8Array([
  34324. 115,
  34325. 116,
  34326. 97,
  34327. 114,
  34328. 116,
  34329. 120,
  34330. 114,
  34331. 101,
  34332. 102
  34333. ]);
  34334. var endobjBytes = new Uint8Array([
  34335. 101,
  34336. 110,
  34337. 100,
  34338. 111,
  34339. 98,
  34340. 106
  34341. ]);
  34342. var xrefBytes = new Uint8Array([
  34343. 47,
  34344. 88,
  34345. 82,
  34346. 101,
  34347. 102
  34348. ]);
  34349. this.entries.length = 0;
  34350. var stream = this.stream;
  34351. stream.pos = 0;
  34352. var buffer = stream.getBytes();
  34353. var position = stream.start, length = buffer.length;
  34354. var trailers = [], xrefStms = [];
  34355. while (position < length) {
  34356. var ch = buffer[position];
  34357. if (ch === TAB || ch === LF || ch === CR || ch === SPACE) {
  34358. ++position;
  34359. continue;
  34360. }
  34361. if (ch === PERCENT) {
  34362. do {
  34363. ++position;
  34364. if (position >= length) {
  34365. break;
  34366. }
  34367. ch = buffer[position];
  34368. } while (ch !== LF && ch !== CR);
  34369. continue;
  34370. }
  34371. var token = readToken(buffer, position);
  34372. var m;
  34373. if (token.indexOf('xref') === 0 && (token.length === 4 || /\s/.test(token[4]))) {
  34374. position += skipUntil(buffer, position, trailerBytes);
  34375. trailers.push(position);
  34376. position += skipUntil(buffer, position, startxrefBytes);
  34377. } else if (m = objRegExp.exec(token)) {
  34378. if (typeof this.entries[m[1]] === 'undefined') {
  34379. this.entries[m[1]] = {
  34380. offset: position - stream.start,
  34381. gen: m[2] | 0,
  34382. uncompressed: true
  34383. };
  34384. }
  34385. var contentLength = skipUntil(buffer, position, endobjBytes) + 7;
  34386. var content = buffer.subarray(position, position + contentLength);
  34387. var xrefTagOffset = skipUntil(content, 0, xrefBytes);
  34388. if (xrefTagOffset < contentLength && content[xrefTagOffset + 5] < 64) {
  34389. xrefStms.push(position - stream.start);
  34390. this.xrefstms[position - stream.start] = 1;
  34391. }
  34392. position += contentLength;
  34393. } else if (token.indexOf('trailer') === 0 && (token.length === 7 || /\s/.test(token[7]))) {
  34394. trailers.push(position);
  34395. position += skipUntil(buffer, position, startxrefBytes);
  34396. } else {
  34397. position += token.length + 1;
  34398. }
  34399. }
  34400. var i, ii;
  34401. for (i = 0, ii = xrefStms.length; i < ii; ++i) {
  34402. this.startXRefQueue.push(xrefStms[i]);
  34403. this.readXRef(true);
  34404. }
  34405. var dict;
  34406. for (i = 0, ii = trailers.length; i < ii; ++i) {
  34407. stream.pos = trailers[i];
  34408. var parser = new Parser(new Lexer(stream), true, this, true);
  34409. var obj = parser.getObj();
  34410. if (!isCmd(obj, 'trailer')) {
  34411. continue;
  34412. }
  34413. dict = parser.getObj();
  34414. if (!isDict(dict)) {
  34415. continue;
  34416. }
  34417. if (dict.has('ID')) {
  34418. return dict;
  34419. }
  34420. }
  34421. if (dict) {
  34422. return dict;
  34423. }
  34424. throw new InvalidPDFException('Invalid PDF structure');
  34425. },
  34426. readXRef: function XRef_readXRef(recoveryMode) {
  34427. var stream = this.stream;
  34428. try {
  34429. while (this.startXRefQueue.length) {
  34430. var startXRef = this.startXRefQueue[0];
  34431. stream.pos = startXRef + stream.start;
  34432. var parser = new Parser(new Lexer(stream), true, this);
  34433. var obj = parser.getObj();
  34434. var dict;
  34435. if (isCmd(obj, 'xref')) {
  34436. dict = this.processXRefTable(parser);
  34437. if (!this.topDict) {
  34438. this.topDict = dict;
  34439. }
  34440. obj = dict.get('XRefStm');
  34441. if (isInt(obj)) {
  34442. var pos = obj;
  34443. if (!(pos in this.xrefstms)) {
  34444. this.xrefstms[pos] = 1;
  34445. this.startXRefQueue.push(pos);
  34446. }
  34447. }
  34448. } else if (isInt(obj)) {
  34449. if (!isInt(parser.getObj()) || !isCmd(parser.getObj(), 'obj') || !isStream(obj = parser.getObj())) {
  34450. error('Invalid XRef stream');
  34451. }
  34452. dict = this.processXRefStream(obj);
  34453. if (!this.topDict) {
  34454. this.topDict = dict;
  34455. }
  34456. if (!dict) {
  34457. error('Failed to read XRef stream');
  34458. }
  34459. } else {
  34460. error('Invalid XRef stream header');
  34461. }
  34462. obj = dict.get('Prev');
  34463. if (isInt(obj)) {
  34464. this.startXRefQueue.push(obj);
  34465. } else if (isRef(obj)) {
  34466. this.startXRefQueue.push(obj.num);
  34467. }
  34468. this.startXRefQueue.shift();
  34469. }
  34470. return this.topDict;
  34471. } catch (e) {
  34472. if (e instanceof MissingDataException) {
  34473. throw e;
  34474. }
  34475. info('(while reading XRef): ' + e);
  34476. }
  34477. if (recoveryMode) {
  34478. return;
  34479. }
  34480. throw new XRefParseException();
  34481. },
  34482. getEntry: function XRef_getEntry(i) {
  34483. var xrefEntry = this.entries[i];
  34484. if (xrefEntry && !xrefEntry.free && xrefEntry.offset) {
  34485. return xrefEntry;
  34486. }
  34487. return null;
  34488. },
  34489. fetchIfRef: function XRef_fetchIfRef(obj, suppressEncryption) {
  34490. if (!isRef(obj)) {
  34491. return obj;
  34492. }
  34493. return this.fetch(obj, suppressEncryption);
  34494. },
  34495. fetch: function XRef_fetch(ref, suppressEncryption) {
  34496. assert(isRef(ref), 'ref object is not a reference');
  34497. var num = ref.num;
  34498. if (num in this.cache) {
  34499. var cacheEntry = this.cache[num];
  34500. if (isDict(cacheEntry) && !cacheEntry.objId) {
  34501. cacheEntry.objId = ref.toString();
  34502. }
  34503. return cacheEntry;
  34504. }
  34505. var xrefEntry = this.getEntry(num);
  34506. if (xrefEntry === null) {
  34507. return this.cache[num] = null;
  34508. }
  34509. if (xrefEntry.uncompressed) {
  34510. xrefEntry = this.fetchUncompressed(ref, xrefEntry, suppressEncryption);
  34511. } else {
  34512. xrefEntry = this.fetchCompressed(xrefEntry, suppressEncryption);
  34513. }
  34514. if (isDict(xrefEntry)) {
  34515. xrefEntry.objId = ref.toString();
  34516. } else if (isStream(xrefEntry)) {
  34517. xrefEntry.dict.objId = ref.toString();
  34518. }
  34519. return xrefEntry;
  34520. },
  34521. fetchUncompressed: function XRef_fetchUncompressed(ref, xrefEntry, suppressEncryption) {
  34522. var gen = ref.gen;
  34523. var num = ref.num;
  34524. if (xrefEntry.gen !== gen) {
  34525. error('inconsistent generation in XRef');
  34526. }
  34527. var stream = this.stream.makeSubStream(xrefEntry.offset + this.stream.start);
  34528. var parser = new Parser(new Lexer(stream), true, this);
  34529. var obj1 = parser.getObj();
  34530. var obj2 = parser.getObj();
  34531. var obj3 = parser.getObj();
  34532. if (!isInt(obj1) || parseInt(obj1, 10) !== num || !isInt(obj2) || parseInt(obj2, 10) !== gen || !isCmd(obj3)) {
  34533. error('bad XRef entry');
  34534. }
  34535. if (!isCmd(obj3, 'obj')) {
  34536. if (obj3.cmd.indexOf('obj') === 0) {
  34537. num = parseInt(obj3.cmd.substring(3), 10);
  34538. if (!isNaN(num)) {
  34539. return num;
  34540. }
  34541. }
  34542. error('bad XRef entry');
  34543. }
  34544. if (this.encrypt && !suppressEncryption) {
  34545. xrefEntry = parser.getObj(this.encrypt.createCipherTransform(num, gen));
  34546. } else {
  34547. xrefEntry = parser.getObj();
  34548. }
  34549. if (!isStream(xrefEntry)) {
  34550. this.cache[num] = xrefEntry;
  34551. }
  34552. return xrefEntry;
  34553. },
  34554. fetchCompressed: function XRef_fetchCompressed(xrefEntry, suppressEncryption) {
  34555. var tableOffset = xrefEntry.offset;
  34556. var stream = this.fetch(new Ref(tableOffset, 0));
  34557. if (!isStream(stream)) {
  34558. error('bad ObjStm stream');
  34559. }
  34560. var first = stream.dict.get('First');
  34561. var n = stream.dict.get('N');
  34562. if (!isInt(first) || !isInt(n)) {
  34563. error('invalid first and n parameters for ObjStm stream');
  34564. }
  34565. var parser = new Parser(new Lexer(stream), false, this);
  34566. parser.allowStreams = true;
  34567. var i, entries = [], num, nums = [];
  34568. for (i = 0; i < n; ++i) {
  34569. num = parser.getObj();
  34570. if (!isInt(num)) {
  34571. error('invalid object number in the ObjStm stream: ' + num);
  34572. }
  34573. nums.push(num);
  34574. var offset = parser.getObj();
  34575. if (!isInt(offset)) {
  34576. error('invalid object offset in the ObjStm stream: ' + offset);
  34577. }
  34578. }
  34579. for (i = 0; i < n; ++i) {
  34580. entries.push(parser.getObj());
  34581. if (isCmd(parser.buf1, 'endobj')) {
  34582. parser.shift();
  34583. }
  34584. num = nums[i];
  34585. var entry = this.entries[num];
  34586. if (entry && entry.offset === tableOffset && entry.gen === i) {
  34587. this.cache[num] = entries[i];
  34588. }
  34589. }
  34590. xrefEntry = entries[xrefEntry.gen];
  34591. if (xrefEntry === undefined) {
  34592. error('bad XRef entry for compressed object');
  34593. }
  34594. return xrefEntry;
  34595. },
  34596. fetchIfRefAsync: function XRef_fetchIfRefAsync(obj, suppressEncryption) {
  34597. if (!isRef(obj)) {
  34598. return Promise.resolve(obj);
  34599. }
  34600. return this.fetchAsync(obj, suppressEncryption);
  34601. },
  34602. fetchAsync: function XRef_fetchAsync(ref, suppressEncryption) {
  34603. var streamManager = this.stream.manager;
  34604. var xref = this;
  34605. return new Promise(function tryFetch(resolve, reject) {
  34606. try {
  34607. resolve(xref.fetch(ref, suppressEncryption));
  34608. } catch (e) {
  34609. if (e instanceof MissingDataException) {
  34610. streamManager.requestRange(e.begin, e.end).then(function () {
  34611. tryFetch(resolve, reject);
  34612. }, reject);
  34613. return;
  34614. }
  34615. reject(e);
  34616. }
  34617. });
  34618. },
  34619. getCatalogObj: function XRef_getCatalogObj() {
  34620. return this.root;
  34621. }
  34622. };
  34623. return XRef;
  34624. }();
  34625. var NameOrNumberTree = function NameOrNumberTreeClosure() {
  34626. function NameOrNumberTree(root, xref) {
  34627. throw new Error('Cannot initialize NameOrNumberTree.');
  34628. }
  34629. NameOrNumberTree.prototype = {
  34630. getAll: function NameOrNumberTree_getAll() {
  34631. var dict = Object.create(null);
  34632. if (!this.root) {
  34633. return dict;
  34634. }
  34635. var xref = this.xref;
  34636. var processed = new RefSet();
  34637. processed.put(this.root);
  34638. var queue = [this.root];
  34639. while (queue.length > 0) {
  34640. var i, n;
  34641. var obj = xref.fetchIfRef(queue.shift());
  34642. if (!isDict(obj)) {
  34643. continue;
  34644. }
  34645. if (obj.has('Kids')) {
  34646. var kids = obj.get('Kids');
  34647. for (i = 0, n = kids.length; i < n; i++) {
  34648. var kid = kids[i];
  34649. assert(!processed.has(kid), 'Duplicate entry in "' + this._type + '" tree.');
  34650. queue.push(kid);
  34651. processed.put(kid);
  34652. }
  34653. continue;
  34654. }
  34655. var entries = obj.get(this._type);
  34656. if (isArray(entries)) {
  34657. for (i = 0, n = entries.length; i < n; i += 2) {
  34658. dict[xref.fetchIfRef(entries[i])] = xref.fetchIfRef(entries[i + 1]);
  34659. }
  34660. }
  34661. }
  34662. return dict;
  34663. },
  34664. get: function NameOrNumberTree_get(key) {
  34665. if (!this.root) {
  34666. return null;
  34667. }
  34668. var xref = this.xref;
  34669. var kidsOrEntries = xref.fetchIfRef(this.root);
  34670. var loopCount = 0;
  34671. var MAX_LEVELS = 10;
  34672. var l, r, m;
  34673. while (kidsOrEntries.has('Kids')) {
  34674. if (++loopCount > MAX_LEVELS) {
  34675. warn('Search depth limit reached for "' + this._type + '" tree.');
  34676. return null;
  34677. }
  34678. var kids = kidsOrEntries.get('Kids');
  34679. if (!isArray(kids)) {
  34680. return null;
  34681. }
  34682. l = 0;
  34683. r = kids.length - 1;
  34684. while (l <= r) {
  34685. m = l + r >> 1;
  34686. var kid = xref.fetchIfRef(kids[m]);
  34687. var limits = kid.get('Limits');
  34688. if (key < xref.fetchIfRef(limits[0])) {
  34689. r = m - 1;
  34690. } else if (key > xref.fetchIfRef(limits[1])) {
  34691. l = m + 1;
  34692. } else {
  34693. kidsOrEntries = xref.fetchIfRef(kids[m]);
  34694. break;
  34695. }
  34696. }
  34697. if (l > r) {
  34698. return null;
  34699. }
  34700. }
  34701. var entries = kidsOrEntries.get(this._type);
  34702. if (isArray(entries)) {
  34703. l = 0;
  34704. r = entries.length - 2;
  34705. while (l <= r) {
  34706. m = l + r & ~1;
  34707. var currentKey = xref.fetchIfRef(entries[m]);
  34708. if (key < currentKey) {
  34709. r = m - 2;
  34710. } else if (key > currentKey) {
  34711. l = m + 2;
  34712. } else {
  34713. return xref.fetchIfRef(entries[m + 1]);
  34714. }
  34715. }
  34716. }
  34717. return null;
  34718. }
  34719. };
  34720. return NameOrNumberTree;
  34721. }();
  34722. var NameTree = function NameTreeClosure() {
  34723. function NameTree(root, xref) {
  34724. this.root = root;
  34725. this.xref = xref;
  34726. this._type = 'Names';
  34727. }
  34728. Util.inherit(NameTree, NameOrNumberTree, {});
  34729. return NameTree;
  34730. }();
  34731. var NumberTree = function NumberTreeClosure() {
  34732. function NumberTree(root, xref) {
  34733. this.root = root;
  34734. this.xref = xref;
  34735. this._type = 'Nums';
  34736. }
  34737. Util.inherit(NumberTree, NameOrNumberTree, {});
  34738. return NumberTree;
  34739. }();
  34740. var FileSpec = function FileSpecClosure() {
  34741. function FileSpec(root, xref) {
  34742. if (!root || !isDict(root)) {
  34743. return;
  34744. }
  34745. this.xref = xref;
  34746. this.root = root;
  34747. if (root.has('FS')) {
  34748. this.fs = root.get('FS');
  34749. }
  34750. this.description = root.has('Desc') ? stringToPDFString(root.get('Desc')) : '';
  34751. if (root.has('RF')) {
  34752. warn('Related file specifications are not supported');
  34753. }
  34754. this.contentAvailable = true;
  34755. if (!root.has('EF')) {
  34756. this.contentAvailable = false;
  34757. warn('Non-embedded file specifications are not supported');
  34758. }
  34759. }
  34760. function pickPlatformItem(dict) {
  34761. if (dict.has('UF')) {
  34762. return dict.get('UF');
  34763. } else if (dict.has('F')) {
  34764. return dict.get('F');
  34765. } else if (dict.has('Unix')) {
  34766. return dict.get('Unix');
  34767. } else if (dict.has('Mac')) {
  34768. return dict.get('Mac');
  34769. } else if (dict.has('DOS')) {
  34770. return dict.get('DOS');
  34771. }
  34772. return null;
  34773. }
  34774. FileSpec.prototype = {
  34775. get filename() {
  34776. if (!this._filename && this.root) {
  34777. var filename = pickPlatformItem(this.root) || 'unnamed';
  34778. this._filename = stringToPDFString(filename).replace(/\\\\/g, '\\').replace(/\\\//g, '/').replace(/\\/g, '/');
  34779. }
  34780. return this._filename;
  34781. },
  34782. get content() {
  34783. if (!this.contentAvailable) {
  34784. return null;
  34785. }
  34786. if (!this.contentRef && this.root) {
  34787. this.contentRef = pickPlatformItem(this.root.get('EF'));
  34788. }
  34789. var content = null;
  34790. if (this.contentRef) {
  34791. var xref = this.xref;
  34792. var fileObj = xref.fetchIfRef(this.contentRef);
  34793. if (fileObj && isStream(fileObj)) {
  34794. content = fileObj.getBytes();
  34795. } else {
  34796. warn('Embedded file specification points to non-existing/invalid ' + 'content');
  34797. }
  34798. } else {
  34799. warn('Embedded file specification does not have a content');
  34800. }
  34801. return content;
  34802. },
  34803. get serializable() {
  34804. return {
  34805. filename: this.filename,
  34806. content: this.content
  34807. };
  34808. }
  34809. };
  34810. return FileSpec;
  34811. }();
  34812. var ObjectLoader = function () {
  34813. function mayHaveChildren(value) {
  34814. return isRef(value) || isDict(value) || isArray(value) || isStream(value);
  34815. }
  34816. function addChildren(node, nodesToVisit) {
  34817. var value;
  34818. if (isDict(node) || isStream(node)) {
  34819. var map;
  34820. if (isDict(node)) {
  34821. map = node.map;
  34822. } else {
  34823. map = node.dict.map;
  34824. }
  34825. for (var key in map) {
  34826. value = map[key];
  34827. if (mayHaveChildren(value)) {
  34828. nodesToVisit.push(value);
  34829. }
  34830. }
  34831. } else if (isArray(node)) {
  34832. for (var i = 0, ii = node.length; i < ii; i++) {
  34833. value = node[i];
  34834. if (mayHaveChildren(value)) {
  34835. nodesToVisit.push(value);
  34836. }
  34837. }
  34838. }
  34839. }
  34840. function ObjectLoader(obj, keys, xref) {
  34841. this.obj = obj;
  34842. this.keys = keys;
  34843. this.xref = xref;
  34844. this.refSet = null;
  34845. this.capability = null;
  34846. }
  34847. ObjectLoader.prototype = {
  34848. load: function ObjectLoader_load() {
  34849. var keys = this.keys;
  34850. this.capability = createPromiseCapability();
  34851. if (!(this.xref.stream instanceof ChunkedStream) || this.xref.stream.getMissingChunks().length === 0) {
  34852. this.capability.resolve();
  34853. return this.capability.promise;
  34854. }
  34855. this.refSet = new RefSet();
  34856. var nodesToVisit = [];
  34857. for (var i = 0; i < keys.length; i++) {
  34858. nodesToVisit.push(this.obj[keys[i]]);
  34859. }
  34860. this._walk(nodesToVisit);
  34861. return this.capability.promise;
  34862. },
  34863. _walk: function ObjectLoader_walk(nodesToVisit) {
  34864. var nodesToRevisit = [];
  34865. var pendingRequests = [];
  34866. while (nodesToVisit.length) {
  34867. var currentNode = nodesToVisit.pop();
  34868. if (isRef(currentNode)) {
  34869. if (this.refSet.has(currentNode)) {
  34870. continue;
  34871. }
  34872. try {
  34873. var ref = currentNode;
  34874. this.refSet.put(ref);
  34875. currentNode = this.xref.fetch(currentNode);
  34876. } catch (e) {
  34877. if (!(e instanceof MissingDataException)) {
  34878. throw e;
  34879. }
  34880. nodesToRevisit.push(currentNode);
  34881. pendingRequests.push({
  34882. begin: e.begin,
  34883. end: e.end
  34884. });
  34885. }
  34886. }
  34887. if (currentNode && currentNode.getBaseStreams) {
  34888. var baseStreams = currentNode.getBaseStreams();
  34889. var foundMissingData = false;
  34890. for (var i = 0; i < baseStreams.length; i++) {
  34891. var stream = baseStreams[i];
  34892. if (stream.getMissingChunks && stream.getMissingChunks().length) {
  34893. foundMissingData = true;
  34894. pendingRequests.push({
  34895. begin: stream.start,
  34896. end: stream.end
  34897. });
  34898. }
  34899. }
  34900. if (foundMissingData) {
  34901. nodesToRevisit.push(currentNode);
  34902. }
  34903. }
  34904. addChildren(currentNode, nodesToVisit);
  34905. }
  34906. if (pendingRequests.length) {
  34907. this.xref.stream.manager.requestRanges(pendingRequests).then(function pendingRequestCallback() {
  34908. nodesToVisit = nodesToRevisit;
  34909. for (var i = 0; i < nodesToRevisit.length; i++) {
  34910. var node = nodesToRevisit[i];
  34911. if (isRef(node)) {
  34912. this.refSet.remove(node);
  34913. }
  34914. }
  34915. this._walk(nodesToVisit);
  34916. }.bind(this), this.capability.reject);
  34917. return;
  34918. }
  34919. this.refSet = null;
  34920. this.capability.resolve();
  34921. }
  34922. };
  34923. return ObjectLoader;
  34924. }();
  34925. exports.Catalog = Catalog;
  34926. exports.ObjectLoader = ObjectLoader;
  34927. exports.XRef = XRef;
  34928. exports.FileSpec = FileSpec;
  34929. /***/ }),
  34930. /* 21 */
  34931. /***/ (function(module, exports, __w_pdfjs_require__) {
  34932. "use strict";
  34933. var sharedUtil = __w_pdfjs_require__(0);
  34934. var getLookupTableFactory = sharedUtil.getLookupTableFactory;
  34935. var getStdFontMap = getLookupTableFactory(function (t) {
  34936. t['ArialNarrow'] = 'Helvetica';
  34937. t['ArialNarrow-Bold'] = 'Helvetica-Bold';
  34938. t['ArialNarrow-BoldItalic'] = 'Helvetica-BoldOblique';
  34939. t['ArialNarrow-Italic'] = 'Helvetica-Oblique';
  34940. t['ArialBlack'] = 'Helvetica';
  34941. t['ArialBlack-Bold'] = 'Helvetica-Bold';
  34942. t['ArialBlack-BoldItalic'] = 'Helvetica-BoldOblique';
  34943. t['ArialBlack-Italic'] = 'Helvetica-Oblique';
  34944. t['Arial-Black'] = 'Helvetica';
  34945. t['Arial-Black-Bold'] = 'Helvetica-Bold';
  34946. t['Arial-Black-BoldItalic'] = 'Helvetica-BoldOblique';
  34947. t['Arial-Black-Italic'] = 'Helvetica-Oblique';
  34948. t['Arial'] = 'Helvetica';
  34949. t['Arial-Bold'] = 'Helvetica-Bold';
  34950. t['Arial-BoldItalic'] = 'Helvetica-BoldOblique';
  34951. t['Arial-Italic'] = 'Helvetica-Oblique';
  34952. t['Arial-BoldItalicMT'] = 'Helvetica-BoldOblique';
  34953. t['Arial-BoldMT'] = 'Helvetica-Bold';
  34954. t['Arial-ItalicMT'] = 'Helvetica-Oblique';
  34955. t['ArialMT'] = 'Helvetica';
  34956. t['Courier-Bold'] = 'Courier-Bold';
  34957. t['Courier-BoldItalic'] = 'Courier-BoldOblique';
  34958. t['Courier-Italic'] = 'Courier-Oblique';
  34959. t['CourierNew'] = 'Courier';
  34960. t['CourierNew-Bold'] = 'Courier-Bold';
  34961. t['CourierNew-BoldItalic'] = 'Courier-BoldOblique';
  34962. t['CourierNew-Italic'] = 'Courier-Oblique';
  34963. t['CourierNewPS-BoldItalicMT'] = 'Courier-BoldOblique';
  34964. t['CourierNewPS-BoldMT'] = 'Courier-Bold';
  34965. t['CourierNewPS-ItalicMT'] = 'Courier-Oblique';
  34966. t['CourierNewPSMT'] = 'Courier';
  34967. t['Helvetica'] = 'Helvetica';
  34968. t['Helvetica-Bold'] = 'Helvetica-Bold';
  34969. t['Helvetica-BoldItalic'] = 'Helvetica-BoldOblique';
  34970. t['Helvetica-BoldOblique'] = 'Helvetica-BoldOblique';
  34971. t['Helvetica-Italic'] = 'Helvetica-Oblique';
  34972. t['Helvetica-Oblique'] = 'Helvetica-Oblique';
  34973. t['Symbol-Bold'] = 'Symbol';
  34974. t['Symbol-BoldItalic'] = 'Symbol';
  34975. t['Symbol-Italic'] = 'Symbol';
  34976. t['TimesNewRoman'] = 'Times-Roman';
  34977. t['TimesNewRoman-Bold'] = 'Times-Bold';
  34978. t['TimesNewRoman-BoldItalic'] = 'Times-BoldItalic';
  34979. t['TimesNewRoman-Italic'] = 'Times-Italic';
  34980. t['TimesNewRomanPS'] = 'Times-Roman';
  34981. t['TimesNewRomanPS-Bold'] = 'Times-Bold';
  34982. t['TimesNewRomanPS-BoldItalic'] = 'Times-BoldItalic';
  34983. t['TimesNewRomanPS-BoldItalicMT'] = 'Times-BoldItalic';
  34984. t['TimesNewRomanPS-BoldMT'] = 'Times-Bold';
  34985. t['TimesNewRomanPS-Italic'] = 'Times-Italic';
  34986. t['TimesNewRomanPS-ItalicMT'] = 'Times-Italic';
  34987. t['TimesNewRomanPSMT'] = 'Times-Roman';
  34988. t['TimesNewRomanPSMT-Bold'] = 'Times-Bold';
  34989. t['TimesNewRomanPSMT-BoldItalic'] = 'Times-BoldItalic';
  34990. t['TimesNewRomanPSMT-Italic'] = 'Times-Italic';
  34991. });
  34992. var getNonStdFontMap = getLookupTableFactory(function (t) {
  34993. t['CenturyGothic'] = 'Helvetica';
  34994. t['CenturyGothic-Bold'] = 'Helvetica-Bold';
  34995. t['CenturyGothic-BoldItalic'] = 'Helvetica-BoldOblique';
  34996. t['CenturyGothic-Italic'] = 'Helvetica-Oblique';
  34997. t['ComicSansMS'] = 'Comic Sans MS';
  34998. t['ComicSansMS-Bold'] = 'Comic Sans MS-Bold';
  34999. t['ComicSansMS-BoldItalic'] = 'Comic Sans MS-BoldItalic';
  35000. t['ComicSansMS-Italic'] = 'Comic Sans MS-Italic';
  35001. t['LucidaConsole'] = 'Courier';
  35002. t['LucidaConsole-Bold'] = 'Courier-Bold';
  35003. t['LucidaConsole-BoldItalic'] = 'Courier-BoldOblique';
  35004. t['LucidaConsole-Italic'] = 'Courier-Oblique';
  35005. t['MS-Gothic'] = 'MS Gothic';
  35006. t['MS-Gothic-Bold'] = 'MS Gothic-Bold';
  35007. t['MS-Gothic-BoldItalic'] = 'MS Gothic-BoldItalic';
  35008. t['MS-Gothic-Italic'] = 'MS Gothic-Italic';
  35009. t['MS-Mincho'] = 'MS Mincho';
  35010. t['MS-Mincho-Bold'] = 'MS Mincho-Bold';
  35011. t['MS-Mincho-BoldItalic'] = 'MS Mincho-BoldItalic';
  35012. t['MS-Mincho-Italic'] = 'MS Mincho-Italic';
  35013. t['MS-PGothic'] = 'MS PGothic';
  35014. t['MS-PGothic-Bold'] = 'MS PGothic-Bold';
  35015. t['MS-PGothic-BoldItalic'] = 'MS PGothic-BoldItalic';
  35016. t['MS-PGothic-Italic'] = 'MS PGothic-Italic';
  35017. t['MS-PMincho'] = 'MS PMincho';
  35018. t['MS-PMincho-Bold'] = 'MS PMincho-Bold';
  35019. t['MS-PMincho-BoldItalic'] = 'MS PMincho-BoldItalic';
  35020. t['MS-PMincho-Italic'] = 'MS PMincho-Italic';
  35021. t['NuptialScript'] = 'Times-Italic';
  35022. t['Wingdings'] = 'ZapfDingbats';
  35023. });
  35024. var getSerifFonts = getLookupTableFactory(function (t) {
  35025. t['Adobe Jenson'] = true;
  35026. t['Adobe Text'] = true;
  35027. t['Albertus'] = true;
  35028. t['Aldus'] = true;
  35029. t['Alexandria'] = true;
  35030. t['Algerian'] = true;
  35031. t['American Typewriter'] = true;
  35032. t['Antiqua'] = true;
  35033. t['Apex'] = true;
  35034. t['Arno'] = true;
  35035. t['Aster'] = true;
  35036. t['Aurora'] = true;
  35037. t['Baskerville'] = true;
  35038. t['Bell'] = true;
  35039. t['Bembo'] = true;
  35040. t['Bembo Schoolbook'] = true;
  35041. t['Benguiat'] = true;
  35042. t['Berkeley Old Style'] = true;
  35043. t['Bernhard Modern'] = true;
  35044. t['Berthold City'] = true;
  35045. t['Bodoni'] = true;
  35046. t['Bauer Bodoni'] = true;
  35047. t['Book Antiqua'] = true;
  35048. t['Bookman'] = true;
  35049. t['Bordeaux Roman'] = true;
  35050. t['Californian FB'] = true;
  35051. t['Calisto'] = true;
  35052. t['Calvert'] = true;
  35053. t['Capitals'] = true;
  35054. t['Cambria'] = true;
  35055. t['Cartier'] = true;
  35056. t['Caslon'] = true;
  35057. t['Catull'] = true;
  35058. t['Centaur'] = true;
  35059. t['Century Old Style'] = true;
  35060. t['Century Schoolbook'] = true;
  35061. t['Chaparral'] = true;
  35062. t['Charis SIL'] = true;
  35063. t['Cheltenham'] = true;
  35064. t['Cholla Slab'] = true;
  35065. t['Clarendon'] = true;
  35066. t['Clearface'] = true;
  35067. t['Cochin'] = true;
  35068. t['Colonna'] = true;
  35069. t['Computer Modern'] = true;
  35070. t['Concrete Roman'] = true;
  35071. t['Constantia'] = true;
  35072. t['Cooper Black'] = true;
  35073. t['Corona'] = true;
  35074. t['Ecotype'] = true;
  35075. t['Egyptienne'] = true;
  35076. t['Elephant'] = true;
  35077. t['Excelsior'] = true;
  35078. t['Fairfield'] = true;
  35079. t['FF Scala'] = true;
  35080. t['Folkard'] = true;
  35081. t['Footlight'] = true;
  35082. t['FreeSerif'] = true;
  35083. t['Friz Quadrata'] = true;
  35084. t['Garamond'] = true;
  35085. t['Gentium'] = true;
  35086. t['Georgia'] = true;
  35087. t['Gloucester'] = true;
  35088. t['Goudy Old Style'] = true;
  35089. t['Goudy Schoolbook'] = true;
  35090. t['Goudy Pro Font'] = true;
  35091. t['Granjon'] = true;
  35092. t['Guardian Egyptian'] = true;
  35093. t['Heather'] = true;
  35094. t['Hercules'] = true;
  35095. t['High Tower Text'] = true;
  35096. t['Hiroshige'] = true;
  35097. t['Hoefler Text'] = true;
  35098. t['Humana Serif'] = true;
  35099. t['Imprint'] = true;
  35100. t['Ionic No. 5'] = true;
  35101. t['Janson'] = true;
  35102. t['Joanna'] = true;
  35103. t['Korinna'] = true;
  35104. t['Lexicon'] = true;
  35105. t['Liberation Serif'] = true;
  35106. t['Linux Libertine'] = true;
  35107. t['Literaturnaya'] = true;
  35108. t['Lucida'] = true;
  35109. t['Lucida Bright'] = true;
  35110. t['Melior'] = true;
  35111. t['Memphis'] = true;
  35112. t['Miller'] = true;
  35113. t['Minion'] = true;
  35114. t['Modern'] = true;
  35115. t['Mona Lisa'] = true;
  35116. t['Mrs Eaves'] = true;
  35117. t['MS Serif'] = true;
  35118. t['Museo Slab'] = true;
  35119. t['New York'] = true;
  35120. t['Nimbus Roman'] = true;
  35121. t['NPS Rawlinson Roadway'] = true;
  35122. t['NuptialScript'] = true;
  35123. t['Palatino'] = true;
  35124. t['Perpetua'] = true;
  35125. t['Plantin'] = true;
  35126. t['Plantin Schoolbook'] = true;
  35127. t['Playbill'] = true;
  35128. t['Poor Richard'] = true;
  35129. t['Rawlinson Roadway'] = true;
  35130. t['Renault'] = true;
  35131. t['Requiem'] = true;
  35132. t['Rockwell'] = true;
  35133. t['Roman'] = true;
  35134. t['Rotis Serif'] = true;
  35135. t['Sabon'] = true;
  35136. t['Scala'] = true;
  35137. t['Seagull'] = true;
  35138. t['Sistina'] = true;
  35139. t['Souvenir'] = true;
  35140. t['STIX'] = true;
  35141. t['Stone Informal'] = true;
  35142. t['Stone Serif'] = true;
  35143. t['Sylfaen'] = true;
  35144. t['Times'] = true;
  35145. t['Trajan'] = true;
  35146. t['Trinité'] = true;
  35147. t['Trump Mediaeval'] = true;
  35148. t['Utopia'] = true;
  35149. t['Vale Type'] = true;
  35150. t['Bitstream Vera'] = true;
  35151. t['Vera Serif'] = true;
  35152. t['Versailles'] = true;
  35153. t['Wanted'] = true;
  35154. t['Weiss'] = true;
  35155. t['Wide Latin'] = true;
  35156. t['Windsor'] = true;
  35157. t['XITS'] = true;
  35158. });
  35159. var getSymbolsFonts = getLookupTableFactory(function (t) {
  35160. t['Dingbats'] = true;
  35161. t['Symbol'] = true;
  35162. t['ZapfDingbats'] = true;
  35163. });
  35164. var getGlyphMapForStandardFonts = getLookupTableFactory(function (t) {
  35165. t[2] = 10;
  35166. t[3] = 32;
  35167. t[4] = 33;
  35168. t[5] = 34;
  35169. t[6] = 35;
  35170. t[7] = 36;
  35171. t[8] = 37;
  35172. t[9] = 38;
  35173. t[10] = 39;
  35174. t[11] = 40;
  35175. t[12] = 41;
  35176. t[13] = 42;
  35177. t[14] = 43;
  35178. t[15] = 44;
  35179. t[16] = 45;
  35180. t[17] = 46;
  35181. t[18] = 47;
  35182. t[19] = 48;
  35183. t[20] = 49;
  35184. t[21] = 50;
  35185. t[22] = 51;
  35186. t[23] = 52;
  35187. t[24] = 53;
  35188. t[25] = 54;
  35189. t[26] = 55;
  35190. t[27] = 56;
  35191. t[28] = 57;
  35192. t[29] = 58;
  35193. t[30] = 894;
  35194. t[31] = 60;
  35195. t[32] = 61;
  35196. t[33] = 62;
  35197. t[34] = 63;
  35198. t[35] = 64;
  35199. t[36] = 65;
  35200. t[37] = 66;
  35201. t[38] = 67;
  35202. t[39] = 68;
  35203. t[40] = 69;
  35204. t[41] = 70;
  35205. t[42] = 71;
  35206. t[43] = 72;
  35207. t[44] = 73;
  35208. t[45] = 74;
  35209. t[46] = 75;
  35210. t[47] = 76;
  35211. t[48] = 77;
  35212. t[49] = 78;
  35213. t[50] = 79;
  35214. t[51] = 80;
  35215. t[52] = 81;
  35216. t[53] = 82;
  35217. t[54] = 83;
  35218. t[55] = 84;
  35219. t[56] = 85;
  35220. t[57] = 86;
  35221. t[58] = 87;
  35222. t[59] = 88;
  35223. t[60] = 89;
  35224. t[61] = 90;
  35225. t[62] = 91;
  35226. t[63] = 92;
  35227. t[64] = 93;
  35228. t[65] = 94;
  35229. t[66] = 95;
  35230. t[67] = 96;
  35231. t[68] = 97;
  35232. t[69] = 98;
  35233. t[70] = 99;
  35234. t[71] = 100;
  35235. t[72] = 101;
  35236. t[73] = 102;
  35237. t[74] = 103;
  35238. t[75] = 104;
  35239. t[76] = 105;
  35240. t[77] = 106;
  35241. t[78] = 107;
  35242. t[79] = 108;
  35243. t[80] = 109;
  35244. t[81] = 110;
  35245. t[82] = 111;
  35246. t[83] = 112;
  35247. t[84] = 113;
  35248. t[85] = 114;
  35249. t[86] = 115;
  35250. t[87] = 116;
  35251. t[88] = 117;
  35252. t[89] = 118;
  35253. t[90] = 119;
  35254. t[91] = 120;
  35255. t[92] = 121;
  35256. t[93] = 122;
  35257. t[94] = 123;
  35258. t[95] = 124;
  35259. t[96] = 125;
  35260. t[97] = 126;
  35261. t[98] = 196;
  35262. t[99] = 197;
  35263. t[100] = 199;
  35264. t[101] = 201;
  35265. t[102] = 209;
  35266. t[103] = 214;
  35267. t[104] = 220;
  35268. t[105] = 225;
  35269. t[106] = 224;
  35270. t[107] = 226;
  35271. t[108] = 228;
  35272. t[109] = 227;
  35273. t[110] = 229;
  35274. t[111] = 231;
  35275. t[112] = 233;
  35276. t[113] = 232;
  35277. t[114] = 234;
  35278. t[115] = 235;
  35279. t[116] = 237;
  35280. t[117] = 236;
  35281. t[118] = 238;
  35282. t[119] = 239;
  35283. t[120] = 241;
  35284. t[121] = 243;
  35285. t[122] = 242;
  35286. t[123] = 244;
  35287. t[124] = 246;
  35288. t[125] = 245;
  35289. t[126] = 250;
  35290. t[127] = 249;
  35291. t[128] = 251;
  35292. t[129] = 252;
  35293. t[130] = 8224;
  35294. t[131] = 176;
  35295. t[132] = 162;
  35296. t[133] = 163;
  35297. t[134] = 167;
  35298. t[135] = 8226;
  35299. t[136] = 182;
  35300. t[137] = 223;
  35301. t[138] = 174;
  35302. t[139] = 169;
  35303. t[140] = 8482;
  35304. t[141] = 180;
  35305. t[142] = 168;
  35306. t[143] = 8800;
  35307. t[144] = 198;
  35308. t[145] = 216;
  35309. t[146] = 8734;
  35310. t[147] = 177;
  35311. t[148] = 8804;
  35312. t[149] = 8805;
  35313. t[150] = 165;
  35314. t[151] = 181;
  35315. t[152] = 8706;
  35316. t[153] = 8721;
  35317. t[154] = 8719;
  35318. t[156] = 8747;
  35319. t[157] = 170;
  35320. t[158] = 186;
  35321. t[159] = 8486;
  35322. t[160] = 230;
  35323. t[161] = 248;
  35324. t[162] = 191;
  35325. t[163] = 161;
  35326. t[164] = 172;
  35327. t[165] = 8730;
  35328. t[166] = 402;
  35329. t[167] = 8776;
  35330. t[168] = 8710;
  35331. t[169] = 171;
  35332. t[170] = 187;
  35333. t[171] = 8230;
  35334. t[210] = 218;
  35335. t[223] = 711;
  35336. t[224] = 321;
  35337. t[225] = 322;
  35338. t[227] = 353;
  35339. t[229] = 382;
  35340. t[234] = 253;
  35341. t[252] = 263;
  35342. t[253] = 268;
  35343. t[254] = 269;
  35344. t[258] = 258;
  35345. t[260] = 260;
  35346. t[261] = 261;
  35347. t[265] = 280;
  35348. t[266] = 281;
  35349. t[268] = 283;
  35350. t[269] = 313;
  35351. t[275] = 323;
  35352. t[276] = 324;
  35353. t[278] = 328;
  35354. t[284] = 345;
  35355. t[285] = 346;
  35356. t[286] = 347;
  35357. t[292] = 367;
  35358. t[295] = 377;
  35359. t[296] = 378;
  35360. t[298] = 380;
  35361. t[305] = 963;
  35362. t[306] = 964;
  35363. t[307] = 966;
  35364. t[308] = 8215;
  35365. t[309] = 8252;
  35366. t[310] = 8319;
  35367. t[311] = 8359;
  35368. t[312] = 8592;
  35369. t[313] = 8593;
  35370. t[337] = 9552;
  35371. t[493] = 1039;
  35372. t[494] = 1040;
  35373. t[705] = 1524;
  35374. t[706] = 8362;
  35375. t[710] = 64288;
  35376. t[711] = 64298;
  35377. t[759] = 1617;
  35378. t[761] = 1776;
  35379. t[763] = 1778;
  35380. t[775] = 1652;
  35381. t[777] = 1764;
  35382. t[778] = 1780;
  35383. t[779] = 1781;
  35384. t[780] = 1782;
  35385. t[782] = 771;
  35386. t[783] = 64726;
  35387. t[786] = 8363;
  35388. t[788] = 8532;
  35389. t[790] = 768;
  35390. t[791] = 769;
  35391. t[792] = 768;
  35392. t[795] = 803;
  35393. t[797] = 64336;
  35394. t[798] = 64337;
  35395. t[799] = 64342;
  35396. t[800] = 64343;
  35397. t[801] = 64344;
  35398. t[802] = 64345;
  35399. t[803] = 64362;
  35400. t[804] = 64363;
  35401. t[805] = 64364;
  35402. t[2424] = 7821;
  35403. t[2425] = 7822;
  35404. t[2426] = 7823;
  35405. t[2427] = 7824;
  35406. t[2428] = 7825;
  35407. t[2429] = 7826;
  35408. t[2430] = 7827;
  35409. t[2433] = 7682;
  35410. t[2678] = 8045;
  35411. t[2679] = 8046;
  35412. t[2830] = 1552;
  35413. t[2838] = 686;
  35414. t[2840] = 751;
  35415. t[2842] = 753;
  35416. t[2843] = 754;
  35417. t[2844] = 755;
  35418. t[2846] = 757;
  35419. t[2856] = 767;
  35420. t[2857] = 848;
  35421. t[2858] = 849;
  35422. t[2862] = 853;
  35423. t[2863] = 854;
  35424. t[2864] = 855;
  35425. t[2865] = 861;
  35426. t[2866] = 862;
  35427. t[2906] = 7460;
  35428. t[2908] = 7462;
  35429. t[2909] = 7463;
  35430. t[2910] = 7464;
  35431. t[2912] = 7466;
  35432. t[2913] = 7467;
  35433. t[2914] = 7468;
  35434. t[2916] = 7470;
  35435. t[2917] = 7471;
  35436. t[2918] = 7472;
  35437. t[2920] = 7474;
  35438. t[2921] = 7475;
  35439. t[2922] = 7476;
  35440. t[2924] = 7478;
  35441. t[2925] = 7479;
  35442. t[2926] = 7480;
  35443. t[2928] = 7482;
  35444. t[2929] = 7483;
  35445. t[2930] = 7484;
  35446. t[2932] = 7486;
  35447. t[2933] = 7487;
  35448. t[2934] = 7488;
  35449. t[2936] = 7490;
  35450. t[2937] = 7491;
  35451. t[2938] = 7492;
  35452. t[2940] = 7494;
  35453. t[2941] = 7495;
  35454. t[2942] = 7496;
  35455. t[2944] = 7498;
  35456. t[2946] = 7500;
  35457. t[2948] = 7502;
  35458. t[2950] = 7504;
  35459. t[2951] = 7505;
  35460. t[2952] = 7506;
  35461. t[2954] = 7508;
  35462. t[2955] = 7509;
  35463. t[2956] = 7510;
  35464. t[2958] = 7512;
  35465. t[2959] = 7513;
  35466. t[2960] = 7514;
  35467. t[2962] = 7516;
  35468. t[2963] = 7517;
  35469. t[2964] = 7518;
  35470. t[2966] = 7520;
  35471. t[2967] = 7521;
  35472. t[2968] = 7522;
  35473. t[2970] = 7524;
  35474. t[2971] = 7525;
  35475. t[2972] = 7526;
  35476. t[2974] = 7528;
  35477. t[2975] = 7529;
  35478. t[2976] = 7530;
  35479. t[2978] = 1537;
  35480. t[2979] = 1538;
  35481. t[2980] = 1539;
  35482. t[2982] = 1549;
  35483. t[2983] = 1551;
  35484. t[2984] = 1552;
  35485. t[2986] = 1554;
  35486. t[2987] = 1555;
  35487. t[2988] = 1556;
  35488. t[2990] = 1623;
  35489. t[2991] = 1624;
  35490. t[2995] = 1775;
  35491. t[2999] = 1791;
  35492. t[3002] = 64290;
  35493. t[3003] = 64291;
  35494. t[3004] = 64292;
  35495. t[3006] = 64294;
  35496. t[3007] = 64295;
  35497. t[3008] = 64296;
  35498. t[3011] = 1900;
  35499. t[3014] = 8223;
  35500. t[3015] = 8244;
  35501. t[3017] = 7532;
  35502. t[3018] = 7533;
  35503. t[3019] = 7534;
  35504. t[3075] = 7590;
  35505. t[3076] = 7591;
  35506. t[3079] = 7594;
  35507. t[3080] = 7595;
  35508. t[3083] = 7598;
  35509. t[3084] = 7599;
  35510. t[3087] = 7602;
  35511. t[3088] = 7603;
  35512. t[3091] = 7606;
  35513. t[3092] = 7607;
  35514. t[3095] = 7610;
  35515. t[3096] = 7611;
  35516. t[3099] = 7614;
  35517. t[3100] = 7615;
  35518. t[3103] = 7618;
  35519. t[3104] = 7619;
  35520. t[3107] = 8337;
  35521. t[3108] = 8338;
  35522. t[3116] = 1884;
  35523. t[3119] = 1885;
  35524. t[3120] = 1885;
  35525. t[3123] = 1886;
  35526. t[3124] = 1886;
  35527. t[3127] = 1887;
  35528. t[3128] = 1887;
  35529. t[3131] = 1888;
  35530. t[3132] = 1888;
  35531. t[3135] = 1889;
  35532. t[3136] = 1889;
  35533. t[3139] = 1890;
  35534. t[3140] = 1890;
  35535. t[3143] = 1891;
  35536. t[3144] = 1891;
  35537. t[3147] = 1892;
  35538. t[3148] = 1892;
  35539. t[3153] = 580;
  35540. t[3154] = 581;
  35541. t[3157] = 584;
  35542. t[3158] = 585;
  35543. t[3161] = 588;
  35544. t[3162] = 589;
  35545. t[3165] = 891;
  35546. t[3166] = 892;
  35547. t[3169] = 1274;
  35548. t[3170] = 1275;
  35549. t[3173] = 1278;
  35550. t[3174] = 1279;
  35551. t[3181] = 7622;
  35552. t[3182] = 7623;
  35553. t[3282] = 11799;
  35554. t[3316] = 578;
  35555. t[3379] = 42785;
  35556. t[3393] = 1159;
  35557. t[3416] = 8377;
  35558. });
  35559. var getSupplementalGlyphMapForArialBlack = getLookupTableFactory(function (t) {
  35560. t[227] = 322;
  35561. t[264] = 261;
  35562. t[291] = 346;
  35563. });
  35564. exports.getStdFontMap = getStdFontMap;
  35565. exports.getNonStdFontMap = getNonStdFontMap;
  35566. exports.getSerifFonts = getSerifFonts;
  35567. exports.getSymbolsFonts = getSymbolsFonts;
  35568. exports.getGlyphMapForStandardFonts = getGlyphMapForStandardFonts;
  35569. exports.getSupplementalGlyphMapForArialBlack = getSupplementalGlyphMapForArialBlack;
  35570. /***/ }),
  35571. /* 22 */
  35572. /***/ (function(module, exports, __w_pdfjs_require__) {
  35573. "use strict";
  35574. var sharedUtil = __w_pdfjs_require__(0);
  35575. var getLookupTableFactory = sharedUtil.getLookupTableFactory;
  35576. var getSpecialPUASymbols = getLookupTableFactory(function (t) {
  35577. t[63721] = 0x00A9;
  35578. t[63193] = 0x00A9;
  35579. t[63720] = 0x00AE;
  35580. t[63194] = 0x00AE;
  35581. t[63722] = 0x2122;
  35582. t[63195] = 0x2122;
  35583. t[63729] = 0x23A7;
  35584. t[63730] = 0x23A8;
  35585. t[63731] = 0x23A9;
  35586. t[63740] = 0x23AB;
  35587. t[63741] = 0x23AC;
  35588. t[63742] = 0x23AD;
  35589. t[63726] = 0x23A1;
  35590. t[63727] = 0x23A2;
  35591. t[63728] = 0x23A3;
  35592. t[63737] = 0x23A4;
  35593. t[63738] = 0x23A5;
  35594. t[63739] = 0x23A6;
  35595. t[63723] = 0x239B;
  35596. t[63724] = 0x239C;
  35597. t[63725] = 0x239D;
  35598. t[63734] = 0x239E;
  35599. t[63735] = 0x239F;
  35600. t[63736] = 0x23A0;
  35601. });
  35602. function mapSpecialUnicodeValues(code) {
  35603. if (code >= 0xFFF0 && code <= 0xFFFF) {
  35604. return 0;
  35605. } else if (code >= 0xF600 && code <= 0xF8FF) {
  35606. return getSpecialPUASymbols()[code] || code;
  35607. }
  35608. return code;
  35609. }
  35610. function getUnicodeForGlyph(name, glyphsUnicodeMap) {
  35611. var unicode = glyphsUnicodeMap[name];
  35612. if (unicode !== undefined) {
  35613. return unicode;
  35614. }
  35615. if (!name) {
  35616. return -1;
  35617. }
  35618. if (name[0] === 'u') {
  35619. var nameLen = name.length, hexStr;
  35620. if (nameLen === 7 && name[1] === 'n' && name[2] === 'i') {
  35621. hexStr = name.substr(3);
  35622. } else if (nameLen >= 5 && nameLen <= 7) {
  35623. hexStr = name.substr(1);
  35624. } else {
  35625. return -1;
  35626. }
  35627. if (hexStr === hexStr.toUpperCase()) {
  35628. unicode = parseInt(hexStr, 16);
  35629. if (unicode >= 0) {
  35630. return unicode;
  35631. }
  35632. }
  35633. }
  35634. return -1;
  35635. }
  35636. var UnicodeRanges = [
  35637. {
  35638. 'begin': 0x0000,
  35639. 'end': 0x007F
  35640. },
  35641. {
  35642. 'begin': 0x0080,
  35643. 'end': 0x00FF
  35644. },
  35645. {
  35646. 'begin': 0x0100,
  35647. 'end': 0x017F
  35648. },
  35649. {
  35650. 'begin': 0x0180,
  35651. 'end': 0x024F
  35652. },
  35653. {
  35654. 'begin': 0x0250,
  35655. 'end': 0x02AF
  35656. },
  35657. {
  35658. 'begin': 0x02B0,
  35659. 'end': 0x02FF
  35660. },
  35661. {
  35662. 'begin': 0x0300,
  35663. 'end': 0x036F
  35664. },
  35665. {
  35666. 'begin': 0x0370,
  35667. 'end': 0x03FF
  35668. },
  35669. {
  35670. 'begin': 0x2C80,
  35671. 'end': 0x2CFF
  35672. },
  35673. {
  35674. 'begin': 0x0400,
  35675. 'end': 0x04FF
  35676. },
  35677. {
  35678. 'begin': 0x0530,
  35679. 'end': 0x058F
  35680. },
  35681. {
  35682. 'begin': 0x0590,
  35683. 'end': 0x05FF
  35684. },
  35685. {
  35686. 'begin': 0xA500,
  35687. 'end': 0xA63F
  35688. },
  35689. {
  35690. 'begin': 0x0600,
  35691. 'end': 0x06FF
  35692. },
  35693. {
  35694. 'begin': 0x07C0,
  35695. 'end': 0x07FF
  35696. },
  35697. {
  35698. 'begin': 0x0900,
  35699. 'end': 0x097F
  35700. },
  35701. {
  35702. 'begin': 0x0980,
  35703. 'end': 0x09FF
  35704. },
  35705. {
  35706. 'begin': 0x0A00,
  35707. 'end': 0x0A7F
  35708. },
  35709. {
  35710. 'begin': 0x0A80,
  35711. 'end': 0x0AFF
  35712. },
  35713. {
  35714. 'begin': 0x0B00,
  35715. 'end': 0x0B7F
  35716. },
  35717. {
  35718. 'begin': 0x0B80,
  35719. 'end': 0x0BFF
  35720. },
  35721. {
  35722. 'begin': 0x0C00,
  35723. 'end': 0x0C7F
  35724. },
  35725. {
  35726. 'begin': 0x0C80,
  35727. 'end': 0x0CFF
  35728. },
  35729. {
  35730. 'begin': 0x0D00,
  35731. 'end': 0x0D7F
  35732. },
  35733. {
  35734. 'begin': 0x0E00,
  35735. 'end': 0x0E7F
  35736. },
  35737. {
  35738. 'begin': 0x0E80,
  35739. 'end': 0x0EFF
  35740. },
  35741. {
  35742. 'begin': 0x10A0,
  35743. 'end': 0x10FF
  35744. },
  35745. {
  35746. 'begin': 0x1B00,
  35747. 'end': 0x1B7F
  35748. },
  35749. {
  35750. 'begin': 0x1100,
  35751. 'end': 0x11FF
  35752. },
  35753. {
  35754. 'begin': 0x1E00,
  35755. 'end': 0x1EFF
  35756. },
  35757. {
  35758. 'begin': 0x1F00,
  35759. 'end': 0x1FFF
  35760. },
  35761. {
  35762. 'begin': 0x2000,
  35763. 'end': 0x206F
  35764. },
  35765. {
  35766. 'begin': 0x2070,
  35767. 'end': 0x209F
  35768. },
  35769. {
  35770. 'begin': 0x20A0,
  35771. 'end': 0x20CF
  35772. },
  35773. {
  35774. 'begin': 0x20D0,
  35775. 'end': 0x20FF
  35776. },
  35777. {
  35778. 'begin': 0x2100,
  35779. 'end': 0x214F
  35780. },
  35781. {
  35782. 'begin': 0x2150,
  35783. 'end': 0x218F
  35784. },
  35785. {
  35786. 'begin': 0x2190,
  35787. 'end': 0x21FF
  35788. },
  35789. {
  35790. 'begin': 0x2200,
  35791. 'end': 0x22FF
  35792. },
  35793. {
  35794. 'begin': 0x2300,
  35795. 'end': 0x23FF
  35796. },
  35797. {
  35798. 'begin': 0x2400,
  35799. 'end': 0x243F
  35800. },
  35801. {
  35802. 'begin': 0x2440,
  35803. 'end': 0x245F
  35804. },
  35805. {
  35806. 'begin': 0x2460,
  35807. 'end': 0x24FF
  35808. },
  35809. {
  35810. 'begin': 0x2500,
  35811. 'end': 0x257F
  35812. },
  35813. {
  35814. 'begin': 0x2580,
  35815. 'end': 0x259F
  35816. },
  35817. {
  35818. 'begin': 0x25A0,
  35819. 'end': 0x25FF
  35820. },
  35821. {
  35822. 'begin': 0x2600,
  35823. 'end': 0x26FF
  35824. },
  35825. {
  35826. 'begin': 0x2700,
  35827. 'end': 0x27BF
  35828. },
  35829. {
  35830. 'begin': 0x3000,
  35831. 'end': 0x303F
  35832. },
  35833. {
  35834. 'begin': 0x3040,
  35835. 'end': 0x309F
  35836. },
  35837. {
  35838. 'begin': 0x30A0,
  35839. 'end': 0x30FF
  35840. },
  35841. {
  35842. 'begin': 0x3100,
  35843. 'end': 0x312F
  35844. },
  35845. {
  35846. 'begin': 0x3130,
  35847. 'end': 0x318F
  35848. },
  35849. {
  35850. 'begin': 0xA840,
  35851. 'end': 0xA87F
  35852. },
  35853. {
  35854. 'begin': 0x3200,
  35855. 'end': 0x32FF
  35856. },
  35857. {
  35858. 'begin': 0x3300,
  35859. 'end': 0x33FF
  35860. },
  35861. {
  35862. 'begin': 0xAC00,
  35863. 'end': 0xD7AF
  35864. },
  35865. {
  35866. 'begin': 0xD800,
  35867. 'end': 0xDFFF
  35868. },
  35869. {
  35870. 'begin': 0x10900,
  35871. 'end': 0x1091F
  35872. },
  35873. {
  35874. 'begin': 0x4E00,
  35875. 'end': 0x9FFF
  35876. },
  35877. {
  35878. 'begin': 0xE000,
  35879. 'end': 0xF8FF
  35880. },
  35881. {
  35882. 'begin': 0x31C0,
  35883. 'end': 0x31EF
  35884. },
  35885. {
  35886. 'begin': 0xFB00,
  35887. 'end': 0xFB4F
  35888. },
  35889. {
  35890. 'begin': 0xFB50,
  35891. 'end': 0xFDFF
  35892. },
  35893. {
  35894. 'begin': 0xFE20,
  35895. 'end': 0xFE2F
  35896. },
  35897. {
  35898. 'begin': 0xFE10,
  35899. 'end': 0xFE1F
  35900. },
  35901. {
  35902. 'begin': 0xFE50,
  35903. 'end': 0xFE6F
  35904. },
  35905. {
  35906. 'begin': 0xFE70,
  35907. 'end': 0xFEFF
  35908. },
  35909. {
  35910. 'begin': 0xFF00,
  35911. 'end': 0xFFEF
  35912. },
  35913. {
  35914. 'begin': 0xFFF0,
  35915. 'end': 0xFFFF
  35916. },
  35917. {
  35918. 'begin': 0x0F00,
  35919. 'end': 0x0FFF
  35920. },
  35921. {
  35922. 'begin': 0x0700,
  35923. 'end': 0x074F
  35924. },
  35925. {
  35926. 'begin': 0x0780,
  35927. 'end': 0x07BF
  35928. },
  35929. {
  35930. 'begin': 0x0D80,
  35931. 'end': 0x0DFF
  35932. },
  35933. {
  35934. 'begin': 0x1000,
  35935. 'end': 0x109F
  35936. },
  35937. {
  35938. 'begin': 0x1200,
  35939. 'end': 0x137F
  35940. },
  35941. {
  35942. 'begin': 0x13A0,
  35943. 'end': 0x13FF
  35944. },
  35945. {
  35946. 'begin': 0x1400,
  35947. 'end': 0x167F
  35948. },
  35949. {
  35950. 'begin': 0x1680,
  35951. 'end': 0x169F
  35952. },
  35953. {
  35954. 'begin': 0x16A0,
  35955. 'end': 0x16FF
  35956. },
  35957. {
  35958. 'begin': 0x1780,
  35959. 'end': 0x17FF
  35960. },
  35961. {
  35962. 'begin': 0x1800,
  35963. 'end': 0x18AF
  35964. },
  35965. {
  35966. 'begin': 0x2800,
  35967. 'end': 0x28FF
  35968. },
  35969. {
  35970. 'begin': 0xA000,
  35971. 'end': 0xA48F
  35972. },
  35973. {
  35974. 'begin': 0x1700,
  35975. 'end': 0x171F
  35976. },
  35977. {
  35978. 'begin': 0x10300,
  35979. 'end': 0x1032F
  35980. },
  35981. {
  35982. 'begin': 0x10330,
  35983. 'end': 0x1034F
  35984. },
  35985. {
  35986. 'begin': 0x10400,
  35987. 'end': 0x1044F
  35988. },
  35989. {
  35990. 'begin': 0x1D000,
  35991. 'end': 0x1D0FF
  35992. },
  35993. {
  35994. 'begin': 0x1D400,
  35995. 'end': 0x1D7FF
  35996. },
  35997. {
  35998. 'begin': 0xFF000,
  35999. 'end': 0xFFFFD
  36000. },
  36001. {
  36002. 'begin': 0xFE00,
  36003. 'end': 0xFE0F
  36004. },
  36005. {
  36006. 'begin': 0xE0000,
  36007. 'end': 0xE007F
  36008. },
  36009. {
  36010. 'begin': 0x1900,
  36011. 'end': 0x194F
  36012. },
  36013. {
  36014. 'begin': 0x1950,
  36015. 'end': 0x197F
  36016. },
  36017. {
  36018. 'begin': 0x1980,
  36019. 'end': 0x19DF
  36020. },
  36021. {
  36022. 'begin': 0x1A00,
  36023. 'end': 0x1A1F
  36024. },
  36025. {
  36026. 'begin': 0x2C00,
  36027. 'end': 0x2C5F
  36028. },
  36029. {
  36030. 'begin': 0x2D30,
  36031. 'end': 0x2D7F
  36032. },
  36033. {
  36034. 'begin': 0x4DC0,
  36035. 'end': 0x4DFF
  36036. },
  36037. {
  36038. 'begin': 0xA800,
  36039. 'end': 0xA82F
  36040. },
  36041. {
  36042. 'begin': 0x10000,
  36043. 'end': 0x1007F
  36044. },
  36045. {
  36046. 'begin': 0x10140,
  36047. 'end': 0x1018F
  36048. },
  36049. {
  36050. 'begin': 0x10380,
  36051. 'end': 0x1039F
  36052. },
  36053. {
  36054. 'begin': 0x103A0,
  36055. 'end': 0x103DF
  36056. },
  36057. {
  36058. 'begin': 0x10450,
  36059. 'end': 0x1047F
  36060. },
  36061. {
  36062. 'begin': 0x10480,
  36063. 'end': 0x104AF
  36064. },
  36065. {
  36066. 'begin': 0x10800,
  36067. 'end': 0x1083F
  36068. },
  36069. {
  36070. 'begin': 0x10A00,
  36071. 'end': 0x10A5F
  36072. },
  36073. {
  36074. 'begin': 0x1D300,
  36075. 'end': 0x1D35F
  36076. },
  36077. {
  36078. 'begin': 0x12000,
  36079. 'end': 0x123FF
  36080. },
  36081. {
  36082. 'begin': 0x1D360,
  36083. 'end': 0x1D37F
  36084. },
  36085. {
  36086. 'begin': 0x1B80,
  36087. 'end': 0x1BBF
  36088. },
  36089. {
  36090. 'begin': 0x1C00,
  36091. 'end': 0x1C4F
  36092. },
  36093. {
  36094. 'begin': 0x1C50,
  36095. 'end': 0x1C7F
  36096. },
  36097. {
  36098. 'begin': 0xA880,
  36099. 'end': 0xA8DF
  36100. },
  36101. {
  36102. 'begin': 0xA900,
  36103. 'end': 0xA92F
  36104. },
  36105. {
  36106. 'begin': 0xA930,
  36107. 'end': 0xA95F
  36108. },
  36109. {
  36110. 'begin': 0xAA00,
  36111. 'end': 0xAA5F
  36112. },
  36113. {
  36114. 'begin': 0x10190,
  36115. 'end': 0x101CF
  36116. },
  36117. {
  36118. 'begin': 0x101D0,
  36119. 'end': 0x101FF
  36120. },
  36121. {
  36122. 'begin': 0x102A0,
  36123. 'end': 0x102DF
  36124. },
  36125. {
  36126. 'begin': 0x1F030,
  36127. 'end': 0x1F09F
  36128. }
  36129. ];
  36130. function getUnicodeRangeFor(value) {
  36131. for (var i = 0, ii = UnicodeRanges.length; i < ii; i++) {
  36132. var range = UnicodeRanges[i];
  36133. if (value >= range.begin && value < range.end) {
  36134. return i;
  36135. }
  36136. }
  36137. return -1;
  36138. }
  36139. function isRTLRangeFor(value) {
  36140. var range = UnicodeRanges[13];
  36141. if (value >= range.begin && value < range.end) {
  36142. return true;
  36143. }
  36144. range = UnicodeRanges[11];
  36145. if (value >= range.begin && value < range.end) {
  36146. return true;
  36147. }
  36148. return false;
  36149. }
  36150. var getNormalizedUnicodes = getLookupTableFactory(function (t) {
  36151. t['\u00A8'] = '\u0020\u0308';
  36152. t['\u00AF'] = '\u0020\u0304';
  36153. t['\u00B4'] = '\u0020\u0301';
  36154. t['\u00B5'] = '\u03BC';
  36155. t['\u00B8'] = '\u0020\u0327';
  36156. t['\u0132'] = '\u0049\u004A';
  36157. t['\u0133'] = '\u0069\u006A';
  36158. t['\u013F'] = '\u004C\u00B7';
  36159. t['\u0140'] = '\u006C\u00B7';
  36160. t['\u0149'] = '\u02BC\u006E';
  36161. t['\u017F'] = '\u0073';
  36162. t['\u01C4'] = '\u0044\u017D';
  36163. t['\u01C5'] = '\u0044\u017E';
  36164. t['\u01C6'] = '\u0064\u017E';
  36165. t['\u01C7'] = '\u004C\u004A';
  36166. t['\u01C8'] = '\u004C\u006A';
  36167. t['\u01C9'] = '\u006C\u006A';
  36168. t['\u01CA'] = '\u004E\u004A';
  36169. t['\u01CB'] = '\u004E\u006A';
  36170. t['\u01CC'] = '\u006E\u006A';
  36171. t['\u01F1'] = '\u0044\u005A';
  36172. t['\u01F2'] = '\u0044\u007A';
  36173. t['\u01F3'] = '\u0064\u007A';
  36174. t['\u02D8'] = '\u0020\u0306';
  36175. t['\u02D9'] = '\u0020\u0307';
  36176. t['\u02DA'] = '\u0020\u030A';
  36177. t['\u02DB'] = '\u0020\u0328';
  36178. t['\u02DC'] = '\u0020\u0303';
  36179. t['\u02DD'] = '\u0020\u030B';
  36180. t['\u037A'] = '\u0020\u0345';
  36181. t['\u0384'] = '\u0020\u0301';
  36182. t['\u03D0'] = '\u03B2';
  36183. t['\u03D1'] = '\u03B8';
  36184. t['\u03D2'] = '\u03A5';
  36185. t['\u03D5'] = '\u03C6';
  36186. t['\u03D6'] = '\u03C0';
  36187. t['\u03F0'] = '\u03BA';
  36188. t['\u03F1'] = '\u03C1';
  36189. t['\u03F2'] = '\u03C2';
  36190. t['\u03F4'] = '\u0398';
  36191. t['\u03F5'] = '\u03B5';
  36192. t['\u03F9'] = '\u03A3';
  36193. t['\u0587'] = '\u0565\u0582';
  36194. t['\u0675'] = '\u0627\u0674';
  36195. t['\u0676'] = '\u0648\u0674';
  36196. t['\u0677'] = '\u06C7\u0674';
  36197. t['\u0678'] = '\u064A\u0674';
  36198. t['\u0E33'] = '\u0E4D\u0E32';
  36199. t['\u0EB3'] = '\u0ECD\u0EB2';
  36200. t['\u0EDC'] = '\u0EAB\u0E99';
  36201. t['\u0EDD'] = '\u0EAB\u0EA1';
  36202. t['\u0F77'] = '\u0FB2\u0F81';
  36203. t['\u0F79'] = '\u0FB3\u0F81';
  36204. t['\u1E9A'] = '\u0061\u02BE';
  36205. t['\u1FBD'] = '\u0020\u0313';
  36206. t['\u1FBF'] = '\u0020\u0313';
  36207. t['\u1FC0'] = '\u0020\u0342';
  36208. t['\u1FFE'] = '\u0020\u0314';
  36209. t['\u2002'] = '\u0020';
  36210. t['\u2003'] = '\u0020';
  36211. t['\u2004'] = '\u0020';
  36212. t['\u2005'] = '\u0020';
  36213. t['\u2006'] = '\u0020';
  36214. t['\u2008'] = '\u0020';
  36215. t['\u2009'] = '\u0020';
  36216. t['\u200A'] = '\u0020';
  36217. t['\u2017'] = '\u0020\u0333';
  36218. t['\u2024'] = '\u002E';
  36219. t['\u2025'] = '\u002E\u002E';
  36220. t['\u2026'] = '\u002E\u002E\u002E';
  36221. t['\u2033'] = '\u2032\u2032';
  36222. t['\u2034'] = '\u2032\u2032\u2032';
  36223. t['\u2036'] = '\u2035\u2035';
  36224. t['\u2037'] = '\u2035\u2035\u2035';
  36225. t['\u203C'] = '\u0021\u0021';
  36226. t['\u203E'] = '\u0020\u0305';
  36227. t['\u2047'] = '\u003F\u003F';
  36228. t['\u2048'] = '\u003F\u0021';
  36229. t['\u2049'] = '\u0021\u003F';
  36230. t['\u2057'] = '\u2032\u2032\u2032\u2032';
  36231. t['\u205F'] = '\u0020';
  36232. t['\u20A8'] = '\u0052\u0073';
  36233. t['\u2100'] = '\u0061\u002F\u0063';
  36234. t['\u2101'] = '\u0061\u002F\u0073';
  36235. t['\u2103'] = '\u00B0\u0043';
  36236. t['\u2105'] = '\u0063\u002F\u006F';
  36237. t['\u2106'] = '\u0063\u002F\u0075';
  36238. t['\u2107'] = '\u0190';
  36239. t['\u2109'] = '\u00B0\u0046';
  36240. t['\u2116'] = '\u004E\u006F';
  36241. t['\u2121'] = '\u0054\u0045\u004C';
  36242. t['\u2135'] = '\u05D0';
  36243. t['\u2136'] = '\u05D1';
  36244. t['\u2137'] = '\u05D2';
  36245. t['\u2138'] = '\u05D3';
  36246. t['\u213B'] = '\u0046\u0041\u0058';
  36247. t['\u2160'] = '\u0049';
  36248. t['\u2161'] = '\u0049\u0049';
  36249. t['\u2162'] = '\u0049\u0049\u0049';
  36250. t['\u2163'] = '\u0049\u0056';
  36251. t['\u2164'] = '\u0056';
  36252. t['\u2165'] = '\u0056\u0049';
  36253. t['\u2166'] = '\u0056\u0049\u0049';
  36254. t['\u2167'] = '\u0056\u0049\u0049\u0049';
  36255. t['\u2168'] = '\u0049\u0058';
  36256. t['\u2169'] = '\u0058';
  36257. t['\u216A'] = '\u0058\u0049';
  36258. t['\u216B'] = '\u0058\u0049\u0049';
  36259. t['\u216C'] = '\u004C';
  36260. t['\u216D'] = '\u0043';
  36261. t['\u216E'] = '\u0044';
  36262. t['\u216F'] = '\u004D';
  36263. t['\u2170'] = '\u0069';
  36264. t['\u2171'] = '\u0069\u0069';
  36265. t['\u2172'] = '\u0069\u0069\u0069';
  36266. t['\u2173'] = '\u0069\u0076';
  36267. t['\u2174'] = '\u0076';
  36268. t['\u2175'] = '\u0076\u0069';
  36269. t['\u2176'] = '\u0076\u0069\u0069';
  36270. t['\u2177'] = '\u0076\u0069\u0069\u0069';
  36271. t['\u2178'] = '\u0069\u0078';
  36272. t['\u2179'] = '\u0078';
  36273. t['\u217A'] = '\u0078\u0069';
  36274. t['\u217B'] = '\u0078\u0069\u0069';
  36275. t['\u217C'] = '\u006C';
  36276. t['\u217D'] = '\u0063';
  36277. t['\u217E'] = '\u0064';
  36278. t['\u217F'] = '\u006D';
  36279. t['\u222C'] = '\u222B\u222B';
  36280. t['\u222D'] = '\u222B\u222B\u222B';
  36281. t['\u222F'] = '\u222E\u222E';
  36282. t['\u2230'] = '\u222E\u222E\u222E';
  36283. t['\u2474'] = '\u0028\u0031\u0029';
  36284. t['\u2475'] = '\u0028\u0032\u0029';
  36285. t['\u2476'] = '\u0028\u0033\u0029';
  36286. t['\u2477'] = '\u0028\u0034\u0029';
  36287. t['\u2478'] = '\u0028\u0035\u0029';
  36288. t['\u2479'] = '\u0028\u0036\u0029';
  36289. t['\u247A'] = '\u0028\u0037\u0029';
  36290. t['\u247B'] = '\u0028\u0038\u0029';
  36291. t['\u247C'] = '\u0028\u0039\u0029';
  36292. t['\u247D'] = '\u0028\u0031\u0030\u0029';
  36293. t['\u247E'] = '\u0028\u0031\u0031\u0029';
  36294. t['\u247F'] = '\u0028\u0031\u0032\u0029';
  36295. t['\u2480'] = '\u0028\u0031\u0033\u0029';
  36296. t['\u2481'] = '\u0028\u0031\u0034\u0029';
  36297. t['\u2482'] = '\u0028\u0031\u0035\u0029';
  36298. t['\u2483'] = '\u0028\u0031\u0036\u0029';
  36299. t['\u2484'] = '\u0028\u0031\u0037\u0029';
  36300. t['\u2485'] = '\u0028\u0031\u0038\u0029';
  36301. t['\u2486'] = '\u0028\u0031\u0039\u0029';
  36302. t['\u2487'] = '\u0028\u0032\u0030\u0029';
  36303. t['\u2488'] = '\u0031\u002E';
  36304. t['\u2489'] = '\u0032\u002E';
  36305. t['\u248A'] = '\u0033\u002E';
  36306. t['\u248B'] = '\u0034\u002E';
  36307. t['\u248C'] = '\u0035\u002E';
  36308. t['\u248D'] = '\u0036\u002E';
  36309. t['\u248E'] = '\u0037\u002E';
  36310. t['\u248F'] = '\u0038\u002E';
  36311. t['\u2490'] = '\u0039\u002E';
  36312. t['\u2491'] = '\u0031\u0030\u002E';
  36313. t['\u2492'] = '\u0031\u0031\u002E';
  36314. t['\u2493'] = '\u0031\u0032\u002E';
  36315. t['\u2494'] = '\u0031\u0033\u002E';
  36316. t['\u2495'] = '\u0031\u0034\u002E';
  36317. t['\u2496'] = '\u0031\u0035\u002E';
  36318. t['\u2497'] = '\u0031\u0036\u002E';
  36319. t['\u2498'] = '\u0031\u0037\u002E';
  36320. t['\u2499'] = '\u0031\u0038\u002E';
  36321. t['\u249A'] = '\u0031\u0039\u002E';
  36322. t['\u249B'] = '\u0032\u0030\u002E';
  36323. t['\u249C'] = '\u0028\u0061\u0029';
  36324. t['\u249D'] = '\u0028\u0062\u0029';
  36325. t['\u249E'] = '\u0028\u0063\u0029';
  36326. t['\u249F'] = '\u0028\u0064\u0029';
  36327. t['\u24A0'] = '\u0028\u0065\u0029';
  36328. t['\u24A1'] = '\u0028\u0066\u0029';
  36329. t['\u24A2'] = '\u0028\u0067\u0029';
  36330. t['\u24A3'] = '\u0028\u0068\u0029';
  36331. t['\u24A4'] = '\u0028\u0069\u0029';
  36332. t['\u24A5'] = '\u0028\u006A\u0029';
  36333. t['\u24A6'] = '\u0028\u006B\u0029';
  36334. t['\u24A7'] = '\u0028\u006C\u0029';
  36335. t['\u24A8'] = '\u0028\u006D\u0029';
  36336. t['\u24A9'] = '\u0028\u006E\u0029';
  36337. t['\u24AA'] = '\u0028\u006F\u0029';
  36338. t['\u24AB'] = '\u0028\u0070\u0029';
  36339. t['\u24AC'] = '\u0028\u0071\u0029';
  36340. t['\u24AD'] = '\u0028\u0072\u0029';
  36341. t['\u24AE'] = '\u0028\u0073\u0029';
  36342. t['\u24AF'] = '\u0028\u0074\u0029';
  36343. t['\u24B0'] = '\u0028\u0075\u0029';
  36344. t['\u24B1'] = '\u0028\u0076\u0029';
  36345. t['\u24B2'] = '\u0028\u0077\u0029';
  36346. t['\u24B3'] = '\u0028\u0078\u0029';
  36347. t['\u24B4'] = '\u0028\u0079\u0029';
  36348. t['\u24B5'] = '\u0028\u007A\u0029';
  36349. t['\u2A0C'] = '\u222B\u222B\u222B\u222B';
  36350. t['\u2A74'] = '\u003A\u003A\u003D';
  36351. t['\u2A75'] = '\u003D\u003D';
  36352. t['\u2A76'] = '\u003D\u003D\u003D';
  36353. t['\u2E9F'] = '\u6BCD';
  36354. t['\u2EF3'] = '\u9F9F';
  36355. t['\u2F00'] = '\u4E00';
  36356. t['\u2F01'] = '\u4E28';
  36357. t['\u2F02'] = '\u4E36';
  36358. t['\u2F03'] = '\u4E3F';
  36359. t['\u2F04'] = '\u4E59';
  36360. t['\u2F05'] = '\u4E85';
  36361. t['\u2F06'] = '\u4E8C';
  36362. t['\u2F07'] = '\u4EA0';
  36363. t['\u2F08'] = '\u4EBA';
  36364. t['\u2F09'] = '\u513F';
  36365. t['\u2F0A'] = '\u5165';
  36366. t['\u2F0B'] = '\u516B';
  36367. t['\u2F0C'] = '\u5182';
  36368. t['\u2F0D'] = '\u5196';
  36369. t['\u2F0E'] = '\u51AB';
  36370. t['\u2F0F'] = '\u51E0';
  36371. t['\u2F10'] = '\u51F5';
  36372. t['\u2F11'] = '\u5200';
  36373. t['\u2F12'] = '\u529B';
  36374. t['\u2F13'] = '\u52F9';
  36375. t['\u2F14'] = '\u5315';
  36376. t['\u2F15'] = '\u531A';
  36377. t['\u2F16'] = '\u5338';
  36378. t['\u2F17'] = '\u5341';
  36379. t['\u2F18'] = '\u535C';
  36380. t['\u2F19'] = '\u5369';
  36381. t['\u2F1A'] = '\u5382';
  36382. t['\u2F1B'] = '\u53B6';
  36383. t['\u2F1C'] = '\u53C8';
  36384. t['\u2F1D'] = '\u53E3';
  36385. t['\u2F1E'] = '\u56D7';
  36386. t['\u2F1F'] = '\u571F';
  36387. t['\u2F20'] = '\u58EB';
  36388. t['\u2F21'] = '\u5902';
  36389. t['\u2F22'] = '\u590A';
  36390. t['\u2F23'] = '\u5915';
  36391. t['\u2F24'] = '\u5927';
  36392. t['\u2F25'] = '\u5973';
  36393. t['\u2F26'] = '\u5B50';
  36394. t['\u2F27'] = '\u5B80';
  36395. t['\u2F28'] = '\u5BF8';
  36396. t['\u2F29'] = '\u5C0F';
  36397. t['\u2F2A'] = '\u5C22';
  36398. t['\u2F2B'] = '\u5C38';
  36399. t['\u2F2C'] = '\u5C6E';
  36400. t['\u2F2D'] = '\u5C71';
  36401. t['\u2F2E'] = '\u5DDB';
  36402. t['\u2F2F'] = '\u5DE5';
  36403. t['\u2F30'] = '\u5DF1';
  36404. t['\u2F31'] = '\u5DFE';
  36405. t['\u2F32'] = '\u5E72';
  36406. t['\u2F33'] = '\u5E7A';
  36407. t['\u2F34'] = '\u5E7F';
  36408. t['\u2F35'] = '\u5EF4';
  36409. t['\u2F36'] = '\u5EFE';
  36410. t['\u2F37'] = '\u5F0B';
  36411. t['\u2F38'] = '\u5F13';
  36412. t['\u2F39'] = '\u5F50';
  36413. t['\u2F3A'] = '\u5F61';
  36414. t['\u2F3B'] = '\u5F73';
  36415. t['\u2F3C'] = '\u5FC3';
  36416. t['\u2F3D'] = '\u6208';
  36417. t['\u2F3E'] = '\u6236';
  36418. t['\u2F3F'] = '\u624B';
  36419. t['\u2F40'] = '\u652F';
  36420. t['\u2F41'] = '\u6534';
  36421. t['\u2F42'] = '\u6587';
  36422. t['\u2F43'] = '\u6597';
  36423. t['\u2F44'] = '\u65A4';
  36424. t['\u2F45'] = '\u65B9';
  36425. t['\u2F46'] = '\u65E0';
  36426. t['\u2F47'] = '\u65E5';
  36427. t['\u2F48'] = '\u66F0';
  36428. t['\u2F49'] = '\u6708';
  36429. t['\u2F4A'] = '\u6728';
  36430. t['\u2F4B'] = '\u6B20';
  36431. t['\u2F4C'] = '\u6B62';
  36432. t['\u2F4D'] = '\u6B79';
  36433. t['\u2F4E'] = '\u6BB3';
  36434. t['\u2F4F'] = '\u6BCB';
  36435. t['\u2F50'] = '\u6BD4';
  36436. t['\u2F51'] = '\u6BDB';
  36437. t['\u2F52'] = '\u6C0F';
  36438. t['\u2F53'] = '\u6C14';
  36439. t['\u2F54'] = '\u6C34';
  36440. t['\u2F55'] = '\u706B';
  36441. t['\u2F56'] = '\u722A';
  36442. t['\u2F57'] = '\u7236';
  36443. t['\u2F58'] = '\u723B';
  36444. t['\u2F59'] = '\u723F';
  36445. t['\u2F5A'] = '\u7247';
  36446. t['\u2F5B'] = '\u7259';
  36447. t['\u2F5C'] = '\u725B';
  36448. t['\u2F5D'] = '\u72AC';
  36449. t['\u2F5E'] = '\u7384';
  36450. t['\u2F5F'] = '\u7389';
  36451. t['\u2F60'] = '\u74DC';
  36452. t['\u2F61'] = '\u74E6';
  36453. t['\u2F62'] = '\u7518';
  36454. t['\u2F63'] = '\u751F';
  36455. t['\u2F64'] = '\u7528';
  36456. t['\u2F65'] = '\u7530';
  36457. t['\u2F66'] = '\u758B';
  36458. t['\u2F67'] = '\u7592';
  36459. t['\u2F68'] = '\u7676';
  36460. t['\u2F69'] = '\u767D';
  36461. t['\u2F6A'] = '\u76AE';
  36462. t['\u2F6B'] = '\u76BF';
  36463. t['\u2F6C'] = '\u76EE';
  36464. t['\u2F6D'] = '\u77DB';
  36465. t['\u2F6E'] = '\u77E2';
  36466. t['\u2F6F'] = '\u77F3';
  36467. t['\u2F70'] = '\u793A';
  36468. t['\u2F71'] = '\u79B8';
  36469. t['\u2F72'] = '\u79BE';
  36470. t['\u2F73'] = '\u7A74';
  36471. t['\u2F74'] = '\u7ACB';
  36472. t['\u2F75'] = '\u7AF9';
  36473. t['\u2F76'] = '\u7C73';
  36474. t['\u2F77'] = '\u7CF8';
  36475. t['\u2F78'] = '\u7F36';
  36476. t['\u2F79'] = '\u7F51';
  36477. t['\u2F7A'] = '\u7F8A';
  36478. t['\u2F7B'] = '\u7FBD';
  36479. t['\u2F7C'] = '\u8001';
  36480. t['\u2F7D'] = '\u800C';
  36481. t['\u2F7E'] = '\u8012';
  36482. t['\u2F7F'] = '\u8033';
  36483. t['\u2F80'] = '\u807F';
  36484. t['\u2F81'] = '\u8089';
  36485. t['\u2F82'] = '\u81E3';
  36486. t['\u2F83'] = '\u81EA';
  36487. t['\u2F84'] = '\u81F3';
  36488. t['\u2F85'] = '\u81FC';
  36489. t['\u2F86'] = '\u820C';
  36490. t['\u2F87'] = '\u821B';
  36491. t['\u2F88'] = '\u821F';
  36492. t['\u2F89'] = '\u826E';
  36493. t['\u2F8A'] = '\u8272';
  36494. t['\u2F8B'] = '\u8278';
  36495. t['\u2F8C'] = '\u864D';
  36496. t['\u2F8D'] = '\u866B';
  36497. t['\u2F8E'] = '\u8840';
  36498. t['\u2F8F'] = '\u884C';
  36499. t['\u2F90'] = '\u8863';
  36500. t['\u2F91'] = '\u897E';
  36501. t['\u2F92'] = '\u898B';
  36502. t['\u2F93'] = '\u89D2';
  36503. t['\u2F94'] = '\u8A00';
  36504. t['\u2F95'] = '\u8C37';
  36505. t['\u2F96'] = '\u8C46';
  36506. t['\u2F97'] = '\u8C55';
  36507. t['\u2F98'] = '\u8C78';
  36508. t['\u2F99'] = '\u8C9D';
  36509. t['\u2F9A'] = '\u8D64';
  36510. t['\u2F9B'] = '\u8D70';
  36511. t['\u2F9C'] = '\u8DB3';
  36512. t['\u2F9D'] = '\u8EAB';
  36513. t['\u2F9E'] = '\u8ECA';
  36514. t['\u2F9F'] = '\u8F9B';
  36515. t['\u2FA0'] = '\u8FB0';
  36516. t['\u2FA1'] = '\u8FB5';
  36517. t['\u2FA2'] = '\u9091';
  36518. t['\u2FA3'] = '\u9149';
  36519. t['\u2FA4'] = '\u91C6';
  36520. t['\u2FA5'] = '\u91CC';
  36521. t['\u2FA6'] = '\u91D1';
  36522. t['\u2FA7'] = '\u9577';
  36523. t['\u2FA8'] = '\u9580';
  36524. t['\u2FA9'] = '\u961C';
  36525. t['\u2FAA'] = '\u96B6';
  36526. t['\u2FAB'] = '\u96B9';
  36527. t['\u2FAC'] = '\u96E8';
  36528. t['\u2FAD'] = '\u9751';
  36529. t['\u2FAE'] = '\u975E';
  36530. t['\u2FAF'] = '\u9762';
  36531. t['\u2FB0'] = '\u9769';
  36532. t['\u2FB1'] = '\u97CB';
  36533. t['\u2FB2'] = '\u97ED';
  36534. t['\u2FB3'] = '\u97F3';
  36535. t['\u2FB4'] = '\u9801';
  36536. t['\u2FB5'] = '\u98A8';
  36537. t['\u2FB6'] = '\u98DB';
  36538. t['\u2FB7'] = '\u98DF';
  36539. t['\u2FB8'] = '\u9996';
  36540. t['\u2FB9'] = '\u9999';
  36541. t['\u2FBA'] = '\u99AC';
  36542. t['\u2FBB'] = '\u9AA8';
  36543. t['\u2FBC'] = '\u9AD8';
  36544. t['\u2FBD'] = '\u9ADF';
  36545. t['\u2FBE'] = '\u9B25';
  36546. t['\u2FBF'] = '\u9B2F';
  36547. t['\u2FC0'] = '\u9B32';
  36548. t['\u2FC1'] = '\u9B3C';
  36549. t['\u2FC2'] = '\u9B5A';
  36550. t['\u2FC3'] = '\u9CE5';
  36551. t['\u2FC4'] = '\u9E75';
  36552. t['\u2FC5'] = '\u9E7F';
  36553. t['\u2FC6'] = '\u9EA5';
  36554. t['\u2FC7'] = '\u9EBB';
  36555. t['\u2FC8'] = '\u9EC3';
  36556. t['\u2FC9'] = '\u9ECD';
  36557. t['\u2FCA'] = '\u9ED1';
  36558. t['\u2FCB'] = '\u9EF9';
  36559. t['\u2FCC'] = '\u9EFD';
  36560. t['\u2FCD'] = '\u9F0E';
  36561. t['\u2FCE'] = '\u9F13';
  36562. t['\u2FCF'] = '\u9F20';
  36563. t['\u2FD0'] = '\u9F3B';
  36564. t['\u2FD1'] = '\u9F4A';
  36565. t['\u2FD2'] = '\u9F52';
  36566. t['\u2FD3'] = '\u9F8D';
  36567. t['\u2FD4'] = '\u9F9C';
  36568. t['\u2FD5'] = '\u9FA0';
  36569. t['\u3036'] = '\u3012';
  36570. t['\u3038'] = '\u5341';
  36571. t['\u3039'] = '\u5344';
  36572. t['\u303A'] = '\u5345';
  36573. t['\u309B'] = '\u0020\u3099';
  36574. t['\u309C'] = '\u0020\u309A';
  36575. t['\u3131'] = '\u1100';
  36576. t['\u3132'] = '\u1101';
  36577. t['\u3133'] = '\u11AA';
  36578. t['\u3134'] = '\u1102';
  36579. t['\u3135'] = '\u11AC';
  36580. t['\u3136'] = '\u11AD';
  36581. t['\u3137'] = '\u1103';
  36582. t['\u3138'] = '\u1104';
  36583. t['\u3139'] = '\u1105';
  36584. t['\u313A'] = '\u11B0';
  36585. t['\u313B'] = '\u11B1';
  36586. t['\u313C'] = '\u11B2';
  36587. t['\u313D'] = '\u11B3';
  36588. t['\u313E'] = '\u11B4';
  36589. t['\u313F'] = '\u11B5';
  36590. t['\u3140'] = '\u111A';
  36591. t['\u3141'] = '\u1106';
  36592. t['\u3142'] = '\u1107';
  36593. t['\u3143'] = '\u1108';
  36594. t['\u3144'] = '\u1121';
  36595. t['\u3145'] = '\u1109';
  36596. t['\u3146'] = '\u110A';
  36597. t['\u3147'] = '\u110B';
  36598. t['\u3148'] = '\u110C';
  36599. t['\u3149'] = '\u110D';
  36600. t['\u314A'] = '\u110E';
  36601. t['\u314B'] = '\u110F';
  36602. t['\u314C'] = '\u1110';
  36603. t['\u314D'] = '\u1111';
  36604. t['\u314E'] = '\u1112';
  36605. t['\u314F'] = '\u1161';
  36606. t['\u3150'] = '\u1162';
  36607. t['\u3151'] = '\u1163';
  36608. t['\u3152'] = '\u1164';
  36609. t['\u3153'] = '\u1165';
  36610. t['\u3154'] = '\u1166';
  36611. t['\u3155'] = '\u1167';
  36612. t['\u3156'] = '\u1168';
  36613. t['\u3157'] = '\u1169';
  36614. t['\u3158'] = '\u116A';
  36615. t['\u3159'] = '\u116B';
  36616. t['\u315A'] = '\u116C';
  36617. t['\u315B'] = '\u116D';
  36618. t['\u315C'] = '\u116E';
  36619. t['\u315D'] = '\u116F';
  36620. t['\u315E'] = '\u1170';
  36621. t['\u315F'] = '\u1171';
  36622. t['\u3160'] = '\u1172';
  36623. t['\u3161'] = '\u1173';
  36624. t['\u3162'] = '\u1174';
  36625. t['\u3163'] = '\u1175';
  36626. t['\u3164'] = '\u1160';
  36627. t['\u3165'] = '\u1114';
  36628. t['\u3166'] = '\u1115';
  36629. t['\u3167'] = '\u11C7';
  36630. t['\u3168'] = '\u11C8';
  36631. t['\u3169'] = '\u11CC';
  36632. t['\u316A'] = '\u11CE';
  36633. t['\u316B'] = '\u11D3';
  36634. t['\u316C'] = '\u11D7';
  36635. t['\u316D'] = '\u11D9';
  36636. t['\u316E'] = '\u111C';
  36637. t['\u316F'] = '\u11DD';
  36638. t['\u3170'] = '\u11DF';
  36639. t['\u3171'] = '\u111D';
  36640. t['\u3172'] = '\u111E';
  36641. t['\u3173'] = '\u1120';
  36642. t['\u3174'] = '\u1122';
  36643. t['\u3175'] = '\u1123';
  36644. t['\u3176'] = '\u1127';
  36645. t['\u3177'] = '\u1129';
  36646. t['\u3178'] = '\u112B';
  36647. t['\u3179'] = '\u112C';
  36648. t['\u317A'] = '\u112D';
  36649. t['\u317B'] = '\u112E';
  36650. t['\u317C'] = '\u112F';
  36651. t['\u317D'] = '\u1132';
  36652. t['\u317E'] = '\u1136';
  36653. t['\u317F'] = '\u1140';
  36654. t['\u3180'] = '\u1147';
  36655. t['\u3181'] = '\u114C';
  36656. t['\u3182'] = '\u11F1';
  36657. t['\u3183'] = '\u11F2';
  36658. t['\u3184'] = '\u1157';
  36659. t['\u3185'] = '\u1158';
  36660. t['\u3186'] = '\u1159';
  36661. t['\u3187'] = '\u1184';
  36662. t['\u3188'] = '\u1185';
  36663. t['\u3189'] = '\u1188';
  36664. t['\u318A'] = '\u1191';
  36665. t['\u318B'] = '\u1192';
  36666. t['\u318C'] = '\u1194';
  36667. t['\u318D'] = '\u119E';
  36668. t['\u318E'] = '\u11A1';
  36669. t['\u3200'] = '\u0028\u1100\u0029';
  36670. t['\u3201'] = '\u0028\u1102\u0029';
  36671. t['\u3202'] = '\u0028\u1103\u0029';
  36672. t['\u3203'] = '\u0028\u1105\u0029';
  36673. t['\u3204'] = '\u0028\u1106\u0029';
  36674. t['\u3205'] = '\u0028\u1107\u0029';
  36675. t['\u3206'] = '\u0028\u1109\u0029';
  36676. t['\u3207'] = '\u0028\u110B\u0029';
  36677. t['\u3208'] = '\u0028\u110C\u0029';
  36678. t['\u3209'] = '\u0028\u110E\u0029';
  36679. t['\u320A'] = '\u0028\u110F\u0029';
  36680. t['\u320B'] = '\u0028\u1110\u0029';
  36681. t['\u320C'] = '\u0028\u1111\u0029';
  36682. t['\u320D'] = '\u0028\u1112\u0029';
  36683. t['\u320E'] = '\u0028\u1100\u1161\u0029';
  36684. t['\u320F'] = '\u0028\u1102\u1161\u0029';
  36685. t['\u3210'] = '\u0028\u1103\u1161\u0029';
  36686. t['\u3211'] = '\u0028\u1105\u1161\u0029';
  36687. t['\u3212'] = '\u0028\u1106\u1161\u0029';
  36688. t['\u3213'] = '\u0028\u1107\u1161\u0029';
  36689. t['\u3214'] = '\u0028\u1109\u1161\u0029';
  36690. t['\u3215'] = '\u0028\u110B\u1161\u0029';
  36691. t['\u3216'] = '\u0028\u110C\u1161\u0029';
  36692. t['\u3217'] = '\u0028\u110E\u1161\u0029';
  36693. t['\u3218'] = '\u0028\u110F\u1161\u0029';
  36694. t['\u3219'] = '\u0028\u1110\u1161\u0029';
  36695. t['\u321A'] = '\u0028\u1111\u1161\u0029';
  36696. t['\u321B'] = '\u0028\u1112\u1161\u0029';
  36697. t['\u321C'] = '\u0028\u110C\u116E\u0029';
  36698. t['\u321D'] = '\u0028\u110B\u1169\u110C\u1165\u11AB\u0029';
  36699. t['\u321E'] = '\u0028\u110B\u1169\u1112\u116E\u0029';
  36700. t['\u3220'] = '\u0028\u4E00\u0029';
  36701. t['\u3221'] = '\u0028\u4E8C\u0029';
  36702. t['\u3222'] = '\u0028\u4E09\u0029';
  36703. t['\u3223'] = '\u0028\u56DB\u0029';
  36704. t['\u3224'] = '\u0028\u4E94\u0029';
  36705. t['\u3225'] = '\u0028\u516D\u0029';
  36706. t['\u3226'] = '\u0028\u4E03\u0029';
  36707. t['\u3227'] = '\u0028\u516B\u0029';
  36708. t['\u3228'] = '\u0028\u4E5D\u0029';
  36709. t['\u3229'] = '\u0028\u5341\u0029';
  36710. t['\u322A'] = '\u0028\u6708\u0029';
  36711. t['\u322B'] = '\u0028\u706B\u0029';
  36712. t['\u322C'] = '\u0028\u6C34\u0029';
  36713. t['\u322D'] = '\u0028\u6728\u0029';
  36714. t['\u322E'] = '\u0028\u91D1\u0029';
  36715. t['\u322F'] = '\u0028\u571F\u0029';
  36716. t['\u3230'] = '\u0028\u65E5\u0029';
  36717. t['\u3231'] = '\u0028\u682A\u0029';
  36718. t['\u3232'] = '\u0028\u6709\u0029';
  36719. t['\u3233'] = '\u0028\u793E\u0029';
  36720. t['\u3234'] = '\u0028\u540D\u0029';
  36721. t['\u3235'] = '\u0028\u7279\u0029';
  36722. t['\u3236'] = '\u0028\u8CA1\u0029';
  36723. t['\u3237'] = '\u0028\u795D\u0029';
  36724. t['\u3238'] = '\u0028\u52B4\u0029';
  36725. t['\u3239'] = '\u0028\u4EE3\u0029';
  36726. t['\u323A'] = '\u0028\u547C\u0029';
  36727. t['\u323B'] = '\u0028\u5B66\u0029';
  36728. t['\u323C'] = '\u0028\u76E3\u0029';
  36729. t['\u323D'] = '\u0028\u4F01\u0029';
  36730. t['\u323E'] = '\u0028\u8CC7\u0029';
  36731. t['\u323F'] = '\u0028\u5354\u0029';
  36732. t['\u3240'] = '\u0028\u796D\u0029';
  36733. t['\u3241'] = '\u0028\u4F11\u0029';
  36734. t['\u3242'] = '\u0028\u81EA\u0029';
  36735. t['\u3243'] = '\u0028\u81F3\u0029';
  36736. t['\u32C0'] = '\u0031\u6708';
  36737. t['\u32C1'] = '\u0032\u6708';
  36738. t['\u32C2'] = '\u0033\u6708';
  36739. t['\u32C3'] = '\u0034\u6708';
  36740. t['\u32C4'] = '\u0035\u6708';
  36741. t['\u32C5'] = '\u0036\u6708';
  36742. t['\u32C6'] = '\u0037\u6708';
  36743. t['\u32C7'] = '\u0038\u6708';
  36744. t['\u32C8'] = '\u0039\u6708';
  36745. t['\u32C9'] = '\u0031\u0030\u6708';
  36746. t['\u32CA'] = '\u0031\u0031\u6708';
  36747. t['\u32CB'] = '\u0031\u0032\u6708';
  36748. t['\u3358'] = '\u0030\u70B9';
  36749. t['\u3359'] = '\u0031\u70B9';
  36750. t['\u335A'] = '\u0032\u70B9';
  36751. t['\u335B'] = '\u0033\u70B9';
  36752. t['\u335C'] = '\u0034\u70B9';
  36753. t['\u335D'] = '\u0035\u70B9';
  36754. t['\u335E'] = '\u0036\u70B9';
  36755. t['\u335F'] = '\u0037\u70B9';
  36756. t['\u3360'] = '\u0038\u70B9';
  36757. t['\u3361'] = '\u0039\u70B9';
  36758. t['\u3362'] = '\u0031\u0030\u70B9';
  36759. t['\u3363'] = '\u0031\u0031\u70B9';
  36760. t['\u3364'] = '\u0031\u0032\u70B9';
  36761. t['\u3365'] = '\u0031\u0033\u70B9';
  36762. t['\u3366'] = '\u0031\u0034\u70B9';
  36763. t['\u3367'] = '\u0031\u0035\u70B9';
  36764. t['\u3368'] = '\u0031\u0036\u70B9';
  36765. t['\u3369'] = '\u0031\u0037\u70B9';
  36766. t['\u336A'] = '\u0031\u0038\u70B9';
  36767. t['\u336B'] = '\u0031\u0039\u70B9';
  36768. t['\u336C'] = '\u0032\u0030\u70B9';
  36769. t['\u336D'] = '\u0032\u0031\u70B9';
  36770. t['\u336E'] = '\u0032\u0032\u70B9';
  36771. t['\u336F'] = '\u0032\u0033\u70B9';
  36772. t['\u3370'] = '\u0032\u0034\u70B9';
  36773. t['\u33E0'] = '\u0031\u65E5';
  36774. t['\u33E1'] = '\u0032\u65E5';
  36775. t['\u33E2'] = '\u0033\u65E5';
  36776. t['\u33E3'] = '\u0034\u65E5';
  36777. t['\u33E4'] = '\u0035\u65E5';
  36778. t['\u33E5'] = '\u0036\u65E5';
  36779. t['\u33E6'] = '\u0037\u65E5';
  36780. t['\u33E7'] = '\u0038\u65E5';
  36781. t['\u33E8'] = '\u0039\u65E5';
  36782. t['\u33E9'] = '\u0031\u0030\u65E5';
  36783. t['\u33EA'] = '\u0031\u0031\u65E5';
  36784. t['\u33EB'] = '\u0031\u0032\u65E5';
  36785. t['\u33EC'] = '\u0031\u0033\u65E5';
  36786. t['\u33ED'] = '\u0031\u0034\u65E5';
  36787. t['\u33EE'] = '\u0031\u0035\u65E5';
  36788. t['\u33EF'] = '\u0031\u0036\u65E5';
  36789. t['\u33F0'] = '\u0031\u0037\u65E5';
  36790. t['\u33F1'] = '\u0031\u0038\u65E5';
  36791. t['\u33F2'] = '\u0031\u0039\u65E5';
  36792. t['\u33F3'] = '\u0032\u0030\u65E5';
  36793. t['\u33F4'] = '\u0032\u0031\u65E5';
  36794. t['\u33F5'] = '\u0032\u0032\u65E5';
  36795. t['\u33F6'] = '\u0032\u0033\u65E5';
  36796. t['\u33F7'] = '\u0032\u0034\u65E5';
  36797. t['\u33F8'] = '\u0032\u0035\u65E5';
  36798. t['\u33F9'] = '\u0032\u0036\u65E5';
  36799. t['\u33FA'] = '\u0032\u0037\u65E5';
  36800. t['\u33FB'] = '\u0032\u0038\u65E5';
  36801. t['\u33FC'] = '\u0032\u0039\u65E5';
  36802. t['\u33FD'] = '\u0033\u0030\u65E5';
  36803. t['\u33FE'] = '\u0033\u0031\u65E5';
  36804. t['\uFB00'] = '\u0066\u0066';
  36805. t['\uFB01'] = '\u0066\u0069';
  36806. t['\uFB02'] = '\u0066\u006C';
  36807. t['\uFB03'] = '\u0066\u0066\u0069';
  36808. t['\uFB04'] = '\u0066\u0066\u006C';
  36809. t['\uFB05'] = '\u017F\u0074';
  36810. t['\uFB06'] = '\u0073\u0074';
  36811. t['\uFB13'] = '\u0574\u0576';
  36812. t['\uFB14'] = '\u0574\u0565';
  36813. t['\uFB15'] = '\u0574\u056B';
  36814. t['\uFB16'] = '\u057E\u0576';
  36815. t['\uFB17'] = '\u0574\u056D';
  36816. t['\uFB4F'] = '\u05D0\u05DC';
  36817. t['\uFB50'] = '\u0671';
  36818. t['\uFB51'] = '\u0671';
  36819. t['\uFB52'] = '\u067B';
  36820. t['\uFB53'] = '\u067B';
  36821. t['\uFB54'] = '\u067B';
  36822. t['\uFB55'] = '\u067B';
  36823. t['\uFB56'] = '\u067E';
  36824. t['\uFB57'] = '\u067E';
  36825. t['\uFB58'] = '\u067E';
  36826. t['\uFB59'] = '\u067E';
  36827. t['\uFB5A'] = '\u0680';
  36828. t['\uFB5B'] = '\u0680';
  36829. t['\uFB5C'] = '\u0680';
  36830. t['\uFB5D'] = '\u0680';
  36831. t['\uFB5E'] = '\u067A';
  36832. t['\uFB5F'] = '\u067A';
  36833. t['\uFB60'] = '\u067A';
  36834. t['\uFB61'] = '\u067A';
  36835. t['\uFB62'] = '\u067F';
  36836. t['\uFB63'] = '\u067F';
  36837. t['\uFB64'] = '\u067F';
  36838. t['\uFB65'] = '\u067F';
  36839. t['\uFB66'] = '\u0679';
  36840. t['\uFB67'] = '\u0679';
  36841. t['\uFB68'] = '\u0679';
  36842. t['\uFB69'] = '\u0679';
  36843. t['\uFB6A'] = '\u06A4';
  36844. t['\uFB6B'] = '\u06A4';
  36845. t['\uFB6C'] = '\u06A4';
  36846. t['\uFB6D'] = '\u06A4';
  36847. t['\uFB6E'] = '\u06A6';
  36848. t['\uFB6F'] = '\u06A6';
  36849. t['\uFB70'] = '\u06A6';
  36850. t['\uFB71'] = '\u06A6';
  36851. t['\uFB72'] = '\u0684';
  36852. t['\uFB73'] = '\u0684';
  36853. t['\uFB74'] = '\u0684';
  36854. t['\uFB75'] = '\u0684';
  36855. t['\uFB76'] = '\u0683';
  36856. t['\uFB77'] = '\u0683';
  36857. t['\uFB78'] = '\u0683';
  36858. t['\uFB79'] = '\u0683';
  36859. t['\uFB7A'] = '\u0686';
  36860. t['\uFB7B'] = '\u0686';
  36861. t['\uFB7C'] = '\u0686';
  36862. t['\uFB7D'] = '\u0686';
  36863. t['\uFB7E'] = '\u0687';
  36864. t['\uFB7F'] = '\u0687';
  36865. t['\uFB80'] = '\u0687';
  36866. t['\uFB81'] = '\u0687';
  36867. t['\uFB82'] = '\u068D';
  36868. t['\uFB83'] = '\u068D';
  36869. t['\uFB84'] = '\u068C';
  36870. t['\uFB85'] = '\u068C';
  36871. t['\uFB86'] = '\u068E';
  36872. t['\uFB87'] = '\u068E';
  36873. t['\uFB88'] = '\u0688';
  36874. t['\uFB89'] = '\u0688';
  36875. t['\uFB8A'] = '\u0698';
  36876. t['\uFB8B'] = '\u0698';
  36877. t['\uFB8C'] = '\u0691';
  36878. t['\uFB8D'] = '\u0691';
  36879. t['\uFB8E'] = '\u06A9';
  36880. t['\uFB8F'] = '\u06A9';
  36881. t['\uFB90'] = '\u06A9';
  36882. t['\uFB91'] = '\u06A9';
  36883. t['\uFB92'] = '\u06AF';
  36884. t['\uFB93'] = '\u06AF';
  36885. t['\uFB94'] = '\u06AF';
  36886. t['\uFB95'] = '\u06AF';
  36887. t['\uFB96'] = '\u06B3';
  36888. t['\uFB97'] = '\u06B3';
  36889. t['\uFB98'] = '\u06B3';
  36890. t['\uFB99'] = '\u06B3';
  36891. t['\uFB9A'] = '\u06B1';
  36892. t['\uFB9B'] = '\u06B1';
  36893. t['\uFB9C'] = '\u06B1';
  36894. t['\uFB9D'] = '\u06B1';
  36895. t['\uFB9E'] = '\u06BA';
  36896. t['\uFB9F'] = '\u06BA';
  36897. t['\uFBA0'] = '\u06BB';
  36898. t['\uFBA1'] = '\u06BB';
  36899. t['\uFBA2'] = '\u06BB';
  36900. t['\uFBA3'] = '\u06BB';
  36901. t['\uFBA4'] = '\u06C0';
  36902. t['\uFBA5'] = '\u06C0';
  36903. t['\uFBA6'] = '\u06C1';
  36904. t['\uFBA7'] = '\u06C1';
  36905. t['\uFBA8'] = '\u06C1';
  36906. t['\uFBA9'] = '\u06C1';
  36907. t['\uFBAA'] = '\u06BE';
  36908. t['\uFBAB'] = '\u06BE';
  36909. t['\uFBAC'] = '\u06BE';
  36910. t['\uFBAD'] = '\u06BE';
  36911. t['\uFBAE'] = '\u06D2';
  36912. t['\uFBAF'] = '\u06D2';
  36913. t['\uFBB0'] = '\u06D3';
  36914. t['\uFBB1'] = '\u06D3';
  36915. t['\uFBD3'] = '\u06AD';
  36916. t['\uFBD4'] = '\u06AD';
  36917. t['\uFBD5'] = '\u06AD';
  36918. t['\uFBD6'] = '\u06AD';
  36919. t['\uFBD7'] = '\u06C7';
  36920. t['\uFBD8'] = '\u06C7';
  36921. t['\uFBD9'] = '\u06C6';
  36922. t['\uFBDA'] = '\u06C6';
  36923. t['\uFBDB'] = '\u06C8';
  36924. t['\uFBDC'] = '\u06C8';
  36925. t['\uFBDD'] = '\u0677';
  36926. t['\uFBDE'] = '\u06CB';
  36927. t['\uFBDF'] = '\u06CB';
  36928. t['\uFBE0'] = '\u06C5';
  36929. t['\uFBE1'] = '\u06C5';
  36930. t['\uFBE2'] = '\u06C9';
  36931. t['\uFBE3'] = '\u06C9';
  36932. t['\uFBE4'] = '\u06D0';
  36933. t['\uFBE5'] = '\u06D0';
  36934. t['\uFBE6'] = '\u06D0';
  36935. t['\uFBE7'] = '\u06D0';
  36936. t['\uFBE8'] = '\u0649';
  36937. t['\uFBE9'] = '\u0649';
  36938. t['\uFBEA'] = '\u0626\u0627';
  36939. t['\uFBEB'] = '\u0626\u0627';
  36940. t['\uFBEC'] = '\u0626\u06D5';
  36941. t['\uFBED'] = '\u0626\u06D5';
  36942. t['\uFBEE'] = '\u0626\u0648';
  36943. t['\uFBEF'] = '\u0626\u0648';
  36944. t['\uFBF0'] = '\u0626\u06C7';
  36945. t['\uFBF1'] = '\u0626\u06C7';
  36946. t['\uFBF2'] = '\u0626\u06C6';
  36947. t['\uFBF3'] = '\u0626\u06C6';
  36948. t['\uFBF4'] = '\u0626\u06C8';
  36949. t['\uFBF5'] = '\u0626\u06C8';
  36950. t['\uFBF6'] = '\u0626\u06D0';
  36951. t['\uFBF7'] = '\u0626\u06D0';
  36952. t['\uFBF8'] = '\u0626\u06D0';
  36953. t['\uFBF9'] = '\u0626\u0649';
  36954. t['\uFBFA'] = '\u0626\u0649';
  36955. t['\uFBFB'] = '\u0626\u0649';
  36956. t['\uFBFC'] = '\u06CC';
  36957. t['\uFBFD'] = '\u06CC';
  36958. t['\uFBFE'] = '\u06CC';
  36959. t['\uFBFF'] = '\u06CC';
  36960. t['\uFC00'] = '\u0626\u062C';
  36961. t['\uFC01'] = '\u0626\u062D';
  36962. t['\uFC02'] = '\u0626\u0645';
  36963. t['\uFC03'] = '\u0626\u0649';
  36964. t['\uFC04'] = '\u0626\u064A';
  36965. t['\uFC05'] = '\u0628\u062C';
  36966. t['\uFC06'] = '\u0628\u062D';
  36967. t['\uFC07'] = '\u0628\u062E';
  36968. t['\uFC08'] = '\u0628\u0645';
  36969. t['\uFC09'] = '\u0628\u0649';
  36970. t['\uFC0A'] = '\u0628\u064A';
  36971. t['\uFC0B'] = '\u062A\u062C';
  36972. t['\uFC0C'] = '\u062A\u062D';
  36973. t['\uFC0D'] = '\u062A\u062E';
  36974. t['\uFC0E'] = '\u062A\u0645';
  36975. t['\uFC0F'] = '\u062A\u0649';
  36976. t['\uFC10'] = '\u062A\u064A';
  36977. t['\uFC11'] = '\u062B\u062C';
  36978. t['\uFC12'] = '\u062B\u0645';
  36979. t['\uFC13'] = '\u062B\u0649';
  36980. t['\uFC14'] = '\u062B\u064A';
  36981. t['\uFC15'] = '\u062C\u062D';
  36982. t['\uFC16'] = '\u062C\u0645';
  36983. t['\uFC17'] = '\u062D\u062C';
  36984. t['\uFC18'] = '\u062D\u0645';
  36985. t['\uFC19'] = '\u062E\u062C';
  36986. t['\uFC1A'] = '\u062E\u062D';
  36987. t['\uFC1B'] = '\u062E\u0645';
  36988. t['\uFC1C'] = '\u0633\u062C';
  36989. t['\uFC1D'] = '\u0633\u062D';
  36990. t['\uFC1E'] = '\u0633\u062E';
  36991. t['\uFC1F'] = '\u0633\u0645';
  36992. t['\uFC20'] = '\u0635\u062D';
  36993. t['\uFC21'] = '\u0635\u0645';
  36994. t['\uFC22'] = '\u0636\u062C';
  36995. t['\uFC23'] = '\u0636\u062D';
  36996. t['\uFC24'] = '\u0636\u062E';
  36997. t['\uFC25'] = '\u0636\u0645';
  36998. t['\uFC26'] = '\u0637\u062D';
  36999. t['\uFC27'] = '\u0637\u0645';
  37000. t['\uFC28'] = '\u0638\u0645';
  37001. t['\uFC29'] = '\u0639\u062C';
  37002. t['\uFC2A'] = '\u0639\u0645';
  37003. t['\uFC2B'] = '\u063A\u062C';
  37004. t['\uFC2C'] = '\u063A\u0645';
  37005. t['\uFC2D'] = '\u0641\u062C';
  37006. t['\uFC2E'] = '\u0641\u062D';
  37007. t['\uFC2F'] = '\u0641\u062E';
  37008. t['\uFC30'] = '\u0641\u0645';
  37009. t['\uFC31'] = '\u0641\u0649';
  37010. t['\uFC32'] = '\u0641\u064A';
  37011. t['\uFC33'] = '\u0642\u062D';
  37012. t['\uFC34'] = '\u0642\u0645';
  37013. t['\uFC35'] = '\u0642\u0649';
  37014. t['\uFC36'] = '\u0642\u064A';
  37015. t['\uFC37'] = '\u0643\u0627';
  37016. t['\uFC38'] = '\u0643\u062C';
  37017. t['\uFC39'] = '\u0643\u062D';
  37018. t['\uFC3A'] = '\u0643\u062E';
  37019. t['\uFC3B'] = '\u0643\u0644';
  37020. t['\uFC3C'] = '\u0643\u0645';
  37021. t['\uFC3D'] = '\u0643\u0649';
  37022. t['\uFC3E'] = '\u0643\u064A';
  37023. t['\uFC3F'] = '\u0644\u062C';
  37024. t['\uFC40'] = '\u0644\u062D';
  37025. t['\uFC41'] = '\u0644\u062E';
  37026. t['\uFC42'] = '\u0644\u0645';
  37027. t['\uFC43'] = '\u0644\u0649';
  37028. t['\uFC44'] = '\u0644\u064A';
  37029. t['\uFC45'] = '\u0645\u062C';
  37030. t['\uFC46'] = '\u0645\u062D';
  37031. t['\uFC47'] = '\u0645\u062E';
  37032. t['\uFC48'] = '\u0645\u0645';
  37033. t['\uFC49'] = '\u0645\u0649';
  37034. t['\uFC4A'] = '\u0645\u064A';
  37035. t['\uFC4B'] = '\u0646\u062C';
  37036. t['\uFC4C'] = '\u0646\u062D';
  37037. t['\uFC4D'] = '\u0646\u062E';
  37038. t['\uFC4E'] = '\u0646\u0645';
  37039. t['\uFC4F'] = '\u0646\u0649';
  37040. t['\uFC50'] = '\u0646\u064A';
  37041. t['\uFC51'] = '\u0647\u062C';
  37042. t['\uFC52'] = '\u0647\u0645';
  37043. t['\uFC53'] = '\u0647\u0649';
  37044. t['\uFC54'] = '\u0647\u064A';
  37045. t['\uFC55'] = '\u064A\u062C';
  37046. t['\uFC56'] = '\u064A\u062D';
  37047. t['\uFC57'] = '\u064A\u062E';
  37048. t['\uFC58'] = '\u064A\u0645';
  37049. t['\uFC59'] = '\u064A\u0649';
  37050. t['\uFC5A'] = '\u064A\u064A';
  37051. t['\uFC5B'] = '\u0630\u0670';
  37052. t['\uFC5C'] = '\u0631\u0670';
  37053. t['\uFC5D'] = '\u0649\u0670';
  37054. t['\uFC5E'] = '\u0020\u064C\u0651';
  37055. t['\uFC5F'] = '\u0020\u064D\u0651';
  37056. t['\uFC60'] = '\u0020\u064E\u0651';
  37057. t['\uFC61'] = '\u0020\u064F\u0651';
  37058. t['\uFC62'] = '\u0020\u0650\u0651';
  37059. t['\uFC63'] = '\u0020\u0651\u0670';
  37060. t['\uFC64'] = '\u0626\u0631';
  37061. t['\uFC65'] = '\u0626\u0632';
  37062. t['\uFC66'] = '\u0626\u0645';
  37063. t['\uFC67'] = '\u0626\u0646';
  37064. t['\uFC68'] = '\u0626\u0649';
  37065. t['\uFC69'] = '\u0626\u064A';
  37066. t['\uFC6A'] = '\u0628\u0631';
  37067. t['\uFC6B'] = '\u0628\u0632';
  37068. t['\uFC6C'] = '\u0628\u0645';
  37069. t['\uFC6D'] = '\u0628\u0646';
  37070. t['\uFC6E'] = '\u0628\u0649';
  37071. t['\uFC6F'] = '\u0628\u064A';
  37072. t['\uFC70'] = '\u062A\u0631';
  37073. t['\uFC71'] = '\u062A\u0632';
  37074. t['\uFC72'] = '\u062A\u0645';
  37075. t['\uFC73'] = '\u062A\u0646';
  37076. t['\uFC74'] = '\u062A\u0649';
  37077. t['\uFC75'] = '\u062A\u064A';
  37078. t['\uFC76'] = '\u062B\u0631';
  37079. t['\uFC77'] = '\u062B\u0632';
  37080. t['\uFC78'] = '\u062B\u0645';
  37081. t['\uFC79'] = '\u062B\u0646';
  37082. t['\uFC7A'] = '\u062B\u0649';
  37083. t['\uFC7B'] = '\u062B\u064A';
  37084. t['\uFC7C'] = '\u0641\u0649';
  37085. t['\uFC7D'] = '\u0641\u064A';
  37086. t['\uFC7E'] = '\u0642\u0649';
  37087. t['\uFC7F'] = '\u0642\u064A';
  37088. t['\uFC80'] = '\u0643\u0627';
  37089. t['\uFC81'] = '\u0643\u0644';
  37090. t['\uFC82'] = '\u0643\u0645';
  37091. t['\uFC83'] = '\u0643\u0649';
  37092. t['\uFC84'] = '\u0643\u064A';
  37093. t['\uFC85'] = '\u0644\u0645';
  37094. t['\uFC86'] = '\u0644\u0649';
  37095. t['\uFC87'] = '\u0644\u064A';
  37096. t['\uFC88'] = '\u0645\u0627';
  37097. t['\uFC89'] = '\u0645\u0645';
  37098. t['\uFC8A'] = '\u0646\u0631';
  37099. t['\uFC8B'] = '\u0646\u0632';
  37100. t['\uFC8C'] = '\u0646\u0645';
  37101. t['\uFC8D'] = '\u0646\u0646';
  37102. t['\uFC8E'] = '\u0646\u0649';
  37103. t['\uFC8F'] = '\u0646\u064A';
  37104. t['\uFC90'] = '\u0649\u0670';
  37105. t['\uFC91'] = '\u064A\u0631';
  37106. t['\uFC92'] = '\u064A\u0632';
  37107. t['\uFC93'] = '\u064A\u0645';
  37108. t['\uFC94'] = '\u064A\u0646';
  37109. t['\uFC95'] = '\u064A\u0649';
  37110. t['\uFC96'] = '\u064A\u064A';
  37111. t['\uFC97'] = '\u0626\u062C';
  37112. t['\uFC98'] = '\u0626\u062D';
  37113. t['\uFC99'] = '\u0626\u062E';
  37114. t['\uFC9A'] = '\u0626\u0645';
  37115. t['\uFC9B'] = '\u0626\u0647';
  37116. t['\uFC9C'] = '\u0628\u062C';
  37117. t['\uFC9D'] = '\u0628\u062D';
  37118. t['\uFC9E'] = '\u0628\u062E';
  37119. t['\uFC9F'] = '\u0628\u0645';
  37120. t['\uFCA0'] = '\u0628\u0647';
  37121. t['\uFCA1'] = '\u062A\u062C';
  37122. t['\uFCA2'] = '\u062A\u062D';
  37123. t['\uFCA3'] = '\u062A\u062E';
  37124. t['\uFCA4'] = '\u062A\u0645';
  37125. t['\uFCA5'] = '\u062A\u0647';
  37126. t['\uFCA6'] = '\u062B\u0645';
  37127. t['\uFCA7'] = '\u062C\u062D';
  37128. t['\uFCA8'] = '\u062C\u0645';
  37129. t['\uFCA9'] = '\u062D\u062C';
  37130. t['\uFCAA'] = '\u062D\u0645';
  37131. t['\uFCAB'] = '\u062E\u062C';
  37132. t['\uFCAC'] = '\u062E\u0645';
  37133. t['\uFCAD'] = '\u0633\u062C';
  37134. t['\uFCAE'] = '\u0633\u062D';
  37135. t['\uFCAF'] = '\u0633\u062E';
  37136. t['\uFCB0'] = '\u0633\u0645';
  37137. t['\uFCB1'] = '\u0635\u062D';
  37138. t['\uFCB2'] = '\u0635\u062E';
  37139. t['\uFCB3'] = '\u0635\u0645';
  37140. t['\uFCB4'] = '\u0636\u062C';
  37141. t['\uFCB5'] = '\u0636\u062D';
  37142. t['\uFCB6'] = '\u0636\u062E';
  37143. t['\uFCB7'] = '\u0636\u0645';
  37144. t['\uFCB8'] = '\u0637\u062D';
  37145. t['\uFCB9'] = '\u0638\u0645';
  37146. t['\uFCBA'] = '\u0639\u062C';
  37147. t['\uFCBB'] = '\u0639\u0645';
  37148. t['\uFCBC'] = '\u063A\u062C';
  37149. t['\uFCBD'] = '\u063A\u0645';
  37150. t['\uFCBE'] = '\u0641\u062C';
  37151. t['\uFCBF'] = '\u0641\u062D';
  37152. t['\uFCC0'] = '\u0641\u062E';
  37153. t['\uFCC1'] = '\u0641\u0645';
  37154. t['\uFCC2'] = '\u0642\u062D';
  37155. t['\uFCC3'] = '\u0642\u0645';
  37156. t['\uFCC4'] = '\u0643\u062C';
  37157. t['\uFCC5'] = '\u0643\u062D';
  37158. t['\uFCC6'] = '\u0643\u062E';
  37159. t['\uFCC7'] = '\u0643\u0644';
  37160. t['\uFCC8'] = '\u0643\u0645';
  37161. t['\uFCC9'] = '\u0644\u062C';
  37162. t['\uFCCA'] = '\u0644\u062D';
  37163. t['\uFCCB'] = '\u0644\u062E';
  37164. t['\uFCCC'] = '\u0644\u0645';
  37165. t['\uFCCD'] = '\u0644\u0647';
  37166. t['\uFCCE'] = '\u0645\u062C';
  37167. t['\uFCCF'] = '\u0645\u062D';
  37168. t['\uFCD0'] = '\u0645\u062E';
  37169. t['\uFCD1'] = '\u0645\u0645';
  37170. t['\uFCD2'] = '\u0646\u062C';
  37171. t['\uFCD3'] = '\u0646\u062D';
  37172. t['\uFCD4'] = '\u0646\u062E';
  37173. t['\uFCD5'] = '\u0646\u0645';
  37174. t['\uFCD6'] = '\u0646\u0647';
  37175. t['\uFCD7'] = '\u0647\u062C';
  37176. t['\uFCD8'] = '\u0647\u0645';
  37177. t['\uFCD9'] = '\u0647\u0670';
  37178. t['\uFCDA'] = '\u064A\u062C';
  37179. t['\uFCDB'] = '\u064A\u062D';
  37180. t['\uFCDC'] = '\u064A\u062E';
  37181. t['\uFCDD'] = '\u064A\u0645';
  37182. t['\uFCDE'] = '\u064A\u0647';
  37183. t['\uFCDF'] = '\u0626\u0645';
  37184. t['\uFCE0'] = '\u0626\u0647';
  37185. t['\uFCE1'] = '\u0628\u0645';
  37186. t['\uFCE2'] = '\u0628\u0647';
  37187. t['\uFCE3'] = '\u062A\u0645';
  37188. t['\uFCE4'] = '\u062A\u0647';
  37189. t['\uFCE5'] = '\u062B\u0645';
  37190. t['\uFCE6'] = '\u062B\u0647';
  37191. t['\uFCE7'] = '\u0633\u0645';
  37192. t['\uFCE8'] = '\u0633\u0647';
  37193. t['\uFCE9'] = '\u0634\u0645';
  37194. t['\uFCEA'] = '\u0634\u0647';
  37195. t['\uFCEB'] = '\u0643\u0644';
  37196. t['\uFCEC'] = '\u0643\u0645';
  37197. t['\uFCED'] = '\u0644\u0645';
  37198. t['\uFCEE'] = '\u0646\u0645';
  37199. t['\uFCEF'] = '\u0646\u0647';
  37200. t['\uFCF0'] = '\u064A\u0645';
  37201. t['\uFCF1'] = '\u064A\u0647';
  37202. t['\uFCF2'] = '\u0640\u064E\u0651';
  37203. t['\uFCF3'] = '\u0640\u064F\u0651';
  37204. t['\uFCF4'] = '\u0640\u0650\u0651';
  37205. t['\uFCF5'] = '\u0637\u0649';
  37206. t['\uFCF6'] = '\u0637\u064A';
  37207. t['\uFCF7'] = '\u0639\u0649';
  37208. t['\uFCF8'] = '\u0639\u064A';
  37209. t['\uFCF9'] = '\u063A\u0649';
  37210. t['\uFCFA'] = '\u063A\u064A';
  37211. t['\uFCFB'] = '\u0633\u0649';
  37212. t['\uFCFC'] = '\u0633\u064A';
  37213. t['\uFCFD'] = '\u0634\u0649';
  37214. t['\uFCFE'] = '\u0634\u064A';
  37215. t['\uFCFF'] = '\u062D\u0649';
  37216. t['\uFD00'] = '\u062D\u064A';
  37217. t['\uFD01'] = '\u062C\u0649';
  37218. t['\uFD02'] = '\u062C\u064A';
  37219. t['\uFD03'] = '\u062E\u0649';
  37220. t['\uFD04'] = '\u062E\u064A';
  37221. t['\uFD05'] = '\u0635\u0649';
  37222. t['\uFD06'] = '\u0635\u064A';
  37223. t['\uFD07'] = '\u0636\u0649';
  37224. t['\uFD08'] = '\u0636\u064A';
  37225. t['\uFD09'] = '\u0634\u062C';
  37226. t['\uFD0A'] = '\u0634\u062D';
  37227. t['\uFD0B'] = '\u0634\u062E';
  37228. t['\uFD0C'] = '\u0634\u0645';
  37229. t['\uFD0D'] = '\u0634\u0631';
  37230. t['\uFD0E'] = '\u0633\u0631';
  37231. t['\uFD0F'] = '\u0635\u0631';
  37232. t['\uFD10'] = '\u0636\u0631';
  37233. t['\uFD11'] = '\u0637\u0649';
  37234. t['\uFD12'] = '\u0637\u064A';
  37235. t['\uFD13'] = '\u0639\u0649';
  37236. t['\uFD14'] = '\u0639\u064A';
  37237. t['\uFD15'] = '\u063A\u0649';
  37238. t['\uFD16'] = '\u063A\u064A';
  37239. t['\uFD17'] = '\u0633\u0649';
  37240. t['\uFD18'] = '\u0633\u064A';
  37241. t['\uFD19'] = '\u0634\u0649';
  37242. t['\uFD1A'] = '\u0634\u064A';
  37243. t['\uFD1B'] = '\u062D\u0649';
  37244. t['\uFD1C'] = '\u062D\u064A';
  37245. t['\uFD1D'] = '\u062C\u0649';
  37246. t['\uFD1E'] = '\u062C\u064A';
  37247. t['\uFD1F'] = '\u062E\u0649';
  37248. t['\uFD20'] = '\u062E\u064A';
  37249. t['\uFD21'] = '\u0635\u0649';
  37250. t['\uFD22'] = '\u0635\u064A';
  37251. t['\uFD23'] = '\u0636\u0649';
  37252. t['\uFD24'] = '\u0636\u064A';
  37253. t['\uFD25'] = '\u0634\u062C';
  37254. t['\uFD26'] = '\u0634\u062D';
  37255. t['\uFD27'] = '\u0634\u062E';
  37256. t['\uFD28'] = '\u0634\u0645';
  37257. t['\uFD29'] = '\u0634\u0631';
  37258. t['\uFD2A'] = '\u0633\u0631';
  37259. t['\uFD2B'] = '\u0635\u0631';
  37260. t['\uFD2C'] = '\u0636\u0631';
  37261. t['\uFD2D'] = '\u0634\u062C';
  37262. t['\uFD2E'] = '\u0634\u062D';
  37263. t['\uFD2F'] = '\u0634\u062E';
  37264. t['\uFD30'] = '\u0634\u0645';
  37265. t['\uFD31'] = '\u0633\u0647';
  37266. t['\uFD32'] = '\u0634\u0647';
  37267. t['\uFD33'] = '\u0637\u0645';
  37268. t['\uFD34'] = '\u0633\u062C';
  37269. t['\uFD35'] = '\u0633\u062D';
  37270. t['\uFD36'] = '\u0633\u062E';
  37271. t['\uFD37'] = '\u0634\u062C';
  37272. t['\uFD38'] = '\u0634\u062D';
  37273. t['\uFD39'] = '\u0634\u062E';
  37274. t['\uFD3A'] = '\u0637\u0645';
  37275. t['\uFD3B'] = '\u0638\u0645';
  37276. t['\uFD3C'] = '\u0627\u064B';
  37277. t['\uFD3D'] = '\u0627\u064B';
  37278. t['\uFD50'] = '\u062A\u062C\u0645';
  37279. t['\uFD51'] = '\u062A\u062D\u062C';
  37280. t['\uFD52'] = '\u062A\u062D\u062C';
  37281. t['\uFD53'] = '\u062A\u062D\u0645';
  37282. t['\uFD54'] = '\u062A\u062E\u0645';
  37283. t['\uFD55'] = '\u062A\u0645\u062C';
  37284. t['\uFD56'] = '\u062A\u0645\u062D';
  37285. t['\uFD57'] = '\u062A\u0645\u062E';
  37286. t['\uFD58'] = '\u062C\u0645\u062D';
  37287. t['\uFD59'] = '\u062C\u0645\u062D';
  37288. t['\uFD5A'] = '\u062D\u0645\u064A';
  37289. t['\uFD5B'] = '\u062D\u0645\u0649';
  37290. t['\uFD5C'] = '\u0633\u062D\u062C';
  37291. t['\uFD5D'] = '\u0633\u062C\u062D';
  37292. t['\uFD5E'] = '\u0633\u062C\u0649';
  37293. t['\uFD5F'] = '\u0633\u0645\u062D';
  37294. t['\uFD60'] = '\u0633\u0645\u062D';
  37295. t['\uFD61'] = '\u0633\u0645\u062C';
  37296. t['\uFD62'] = '\u0633\u0645\u0645';
  37297. t['\uFD63'] = '\u0633\u0645\u0645';
  37298. t['\uFD64'] = '\u0635\u062D\u062D';
  37299. t['\uFD65'] = '\u0635\u062D\u062D';
  37300. t['\uFD66'] = '\u0635\u0645\u0645';
  37301. t['\uFD67'] = '\u0634\u062D\u0645';
  37302. t['\uFD68'] = '\u0634\u062D\u0645';
  37303. t['\uFD69'] = '\u0634\u062C\u064A';
  37304. t['\uFD6A'] = '\u0634\u0645\u062E';
  37305. t['\uFD6B'] = '\u0634\u0645\u062E';
  37306. t['\uFD6C'] = '\u0634\u0645\u0645';
  37307. t['\uFD6D'] = '\u0634\u0645\u0645';
  37308. t['\uFD6E'] = '\u0636\u062D\u0649';
  37309. t['\uFD6F'] = '\u0636\u062E\u0645';
  37310. t['\uFD70'] = '\u0636\u062E\u0645';
  37311. t['\uFD71'] = '\u0637\u0645\u062D';
  37312. t['\uFD72'] = '\u0637\u0645\u062D';
  37313. t['\uFD73'] = '\u0637\u0645\u0645';
  37314. t['\uFD74'] = '\u0637\u0645\u064A';
  37315. t['\uFD75'] = '\u0639\u062C\u0645';
  37316. t['\uFD76'] = '\u0639\u0645\u0645';
  37317. t['\uFD77'] = '\u0639\u0645\u0645';
  37318. t['\uFD78'] = '\u0639\u0645\u0649';
  37319. t['\uFD79'] = '\u063A\u0645\u0645';
  37320. t['\uFD7A'] = '\u063A\u0645\u064A';
  37321. t['\uFD7B'] = '\u063A\u0645\u0649';
  37322. t['\uFD7C'] = '\u0641\u062E\u0645';
  37323. t['\uFD7D'] = '\u0641\u062E\u0645';
  37324. t['\uFD7E'] = '\u0642\u0645\u062D';
  37325. t['\uFD7F'] = '\u0642\u0645\u0645';
  37326. t['\uFD80'] = '\u0644\u062D\u0645';
  37327. t['\uFD81'] = '\u0644\u062D\u064A';
  37328. t['\uFD82'] = '\u0644\u062D\u0649';
  37329. t['\uFD83'] = '\u0644\u062C\u062C';
  37330. t['\uFD84'] = '\u0644\u062C\u062C';
  37331. t['\uFD85'] = '\u0644\u062E\u0645';
  37332. t['\uFD86'] = '\u0644\u062E\u0645';
  37333. t['\uFD87'] = '\u0644\u0645\u062D';
  37334. t['\uFD88'] = '\u0644\u0645\u062D';
  37335. t['\uFD89'] = '\u0645\u062D\u062C';
  37336. t['\uFD8A'] = '\u0645\u062D\u0645';
  37337. t['\uFD8B'] = '\u0645\u062D\u064A';
  37338. t['\uFD8C'] = '\u0645\u062C\u062D';
  37339. t['\uFD8D'] = '\u0645\u062C\u0645';
  37340. t['\uFD8E'] = '\u0645\u062E\u062C';
  37341. t['\uFD8F'] = '\u0645\u062E\u0645';
  37342. t['\uFD92'] = '\u0645\u062C\u062E';
  37343. t['\uFD93'] = '\u0647\u0645\u062C';
  37344. t['\uFD94'] = '\u0647\u0645\u0645';
  37345. t['\uFD95'] = '\u0646\u062D\u0645';
  37346. t['\uFD96'] = '\u0646\u062D\u0649';
  37347. t['\uFD97'] = '\u0646\u062C\u0645';
  37348. t['\uFD98'] = '\u0646\u062C\u0645';
  37349. t['\uFD99'] = '\u0646\u062C\u0649';
  37350. t['\uFD9A'] = '\u0646\u0645\u064A';
  37351. t['\uFD9B'] = '\u0646\u0645\u0649';
  37352. t['\uFD9C'] = '\u064A\u0645\u0645';
  37353. t['\uFD9D'] = '\u064A\u0645\u0645';
  37354. t['\uFD9E'] = '\u0628\u062E\u064A';
  37355. t['\uFD9F'] = '\u062A\u062C\u064A';
  37356. t['\uFDA0'] = '\u062A\u062C\u0649';
  37357. t['\uFDA1'] = '\u062A\u062E\u064A';
  37358. t['\uFDA2'] = '\u062A\u062E\u0649';
  37359. t['\uFDA3'] = '\u062A\u0645\u064A';
  37360. t['\uFDA4'] = '\u062A\u0645\u0649';
  37361. t['\uFDA5'] = '\u062C\u0645\u064A';
  37362. t['\uFDA6'] = '\u062C\u062D\u0649';
  37363. t['\uFDA7'] = '\u062C\u0645\u0649';
  37364. t['\uFDA8'] = '\u0633\u062E\u0649';
  37365. t['\uFDA9'] = '\u0635\u062D\u064A';
  37366. t['\uFDAA'] = '\u0634\u062D\u064A';
  37367. t['\uFDAB'] = '\u0636\u062D\u064A';
  37368. t['\uFDAC'] = '\u0644\u062C\u064A';
  37369. t['\uFDAD'] = '\u0644\u0645\u064A';
  37370. t['\uFDAE'] = '\u064A\u062D\u064A';
  37371. t['\uFDAF'] = '\u064A\u062C\u064A';
  37372. t['\uFDB0'] = '\u064A\u0645\u064A';
  37373. t['\uFDB1'] = '\u0645\u0645\u064A';
  37374. t['\uFDB2'] = '\u0642\u0645\u064A';
  37375. t['\uFDB3'] = '\u0646\u062D\u064A';
  37376. t['\uFDB4'] = '\u0642\u0645\u062D';
  37377. t['\uFDB5'] = '\u0644\u062D\u0645';
  37378. t['\uFDB6'] = '\u0639\u0645\u064A';
  37379. t['\uFDB7'] = '\u0643\u0645\u064A';
  37380. t['\uFDB8'] = '\u0646\u062C\u062D';
  37381. t['\uFDB9'] = '\u0645\u062E\u064A';
  37382. t['\uFDBA'] = '\u0644\u062C\u0645';
  37383. t['\uFDBB'] = '\u0643\u0645\u0645';
  37384. t['\uFDBC'] = '\u0644\u062C\u0645';
  37385. t['\uFDBD'] = '\u0646\u062C\u062D';
  37386. t['\uFDBE'] = '\u062C\u062D\u064A';
  37387. t['\uFDBF'] = '\u062D\u062C\u064A';
  37388. t['\uFDC0'] = '\u0645\u062C\u064A';
  37389. t['\uFDC1'] = '\u0641\u0645\u064A';
  37390. t['\uFDC2'] = '\u0628\u062D\u064A';
  37391. t['\uFDC3'] = '\u0643\u0645\u0645';
  37392. t['\uFDC4'] = '\u0639\u062C\u0645';
  37393. t['\uFDC5'] = '\u0635\u0645\u0645';
  37394. t['\uFDC6'] = '\u0633\u062E\u064A';
  37395. t['\uFDC7'] = '\u0646\u062C\u064A';
  37396. t['\uFE49'] = '\u203E';
  37397. t['\uFE4A'] = '\u203E';
  37398. t['\uFE4B'] = '\u203E';
  37399. t['\uFE4C'] = '\u203E';
  37400. t['\uFE4D'] = '\u005F';
  37401. t['\uFE4E'] = '\u005F';
  37402. t['\uFE4F'] = '\u005F';
  37403. t['\uFE80'] = '\u0621';
  37404. t['\uFE81'] = '\u0622';
  37405. t['\uFE82'] = '\u0622';
  37406. t['\uFE83'] = '\u0623';
  37407. t['\uFE84'] = '\u0623';
  37408. t['\uFE85'] = '\u0624';
  37409. t['\uFE86'] = '\u0624';
  37410. t['\uFE87'] = '\u0625';
  37411. t['\uFE88'] = '\u0625';
  37412. t['\uFE89'] = '\u0626';
  37413. t['\uFE8A'] = '\u0626';
  37414. t['\uFE8B'] = '\u0626';
  37415. t['\uFE8C'] = '\u0626';
  37416. t['\uFE8D'] = '\u0627';
  37417. t['\uFE8E'] = '\u0627';
  37418. t['\uFE8F'] = '\u0628';
  37419. t['\uFE90'] = '\u0628';
  37420. t['\uFE91'] = '\u0628';
  37421. t['\uFE92'] = '\u0628';
  37422. t['\uFE93'] = '\u0629';
  37423. t['\uFE94'] = '\u0629';
  37424. t['\uFE95'] = '\u062A';
  37425. t['\uFE96'] = '\u062A';
  37426. t['\uFE97'] = '\u062A';
  37427. t['\uFE98'] = '\u062A';
  37428. t['\uFE99'] = '\u062B';
  37429. t['\uFE9A'] = '\u062B';
  37430. t['\uFE9B'] = '\u062B';
  37431. t['\uFE9C'] = '\u062B';
  37432. t['\uFE9D'] = '\u062C';
  37433. t['\uFE9E'] = '\u062C';
  37434. t['\uFE9F'] = '\u062C';
  37435. t['\uFEA0'] = '\u062C';
  37436. t['\uFEA1'] = '\u062D';
  37437. t['\uFEA2'] = '\u062D';
  37438. t['\uFEA3'] = '\u062D';
  37439. t['\uFEA4'] = '\u062D';
  37440. t['\uFEA5'] = '\u062E';
  37441. t['\uFEA6'] = '\u062E';
  37442. t['\uFEA7'] = '\u062E';
  37443. t['\uFEA8'] = '\u062E';
  37444. t['\uFEA9'] = '\u062F';
  37445. t['\uFEAA'] = '\u062F';
  37446. t['\uFEAB'] = '\u0630';
  37447. t['\uFEAC'] = '\u0630';
  37448. t['\uFEAD'] = '\u0631';
  37449. t['\uFEAE'] = '\u0631';
  37450. t['\uFEAF'] = '\u0632';
  37451. t['\uFEB0'] = '\u0632';
  37452. t['\uFEB1'] = '\u0633';
  37453. t['\uFEB2'] = '\u0633';
  37454. t['\uFEB3'] = '\u0633';
  37455. t['\uFEB4'] = '\u0633';
  37456. t['\uFEB5'] = '\u0634';
  37457. t['\uFEB6'] = '\u0634';
  37458. t['\uFEB7'] = '\u0634';
  37459. t['\uFEB8'] = '\u0634';
  37460. t['\uFEB9'] = '\u0635';
  37461. t['\uFEBA'] = '\u0635';
  37462. t['\uFEBB'] = '\u0635';
  37463. t['\uFEBC'] = '\u0635';
  37464. t['\uFEBD'] = '\u0636';
  37465. t['\uFEBE'] = '\u0636';
  37466. t['\uFEBF'] = '\u0636';
  37467. t['\uFEC0'] = '\u0636';
  37468. t['\uFEC1'] = '\u0637';
  37469. t['\uFEC2'] = '\u0637';
  37470. t['\uFEC3'] = '\u0637';
  37471. t['\uFEC4'] = '\u0637';
  37472. t['\uFEC5'] = '\u0638';
  37473. t['\uFEC6'] = '\u0638';
  37474. t['\uFEC7'] = '\u0638';
  37475. t['\uFEC8'] = '\u0638';
  37476. t['\uFEC9'] = '\u0639';
  37477. t['\uFECA'] = '\u0639';
  37478. t['\uFECB'] = '\u0639';
  37479. t['\uFECC'] = '\u0639';
  37480. t['\uFECD'] = '\u063A';
  37481. t['\uFECE'] = '\u063A';
  37482. t['\uFECF'] = '\u063A';
  37483. t['\uFED0'] = '\u063A';
  37484. t['\uFED1'] = '\u0641';
  37485. t['\uFED2'] = '\u0641';
  37486. t['\uFED3'] = '\u0641';
  37487. t['\uFED4'] = '\u0641';
  37488. t['\uFED5'] = '\u0642';
  37489. t['\uFED6'] = '\u0642';
  37490. t['\uFED7'] = '\u0642';
  37491. t['\uFED8'] = '\u0642';
  37492. t['\uFED9'] = '\u0643';
  37493. t['\uFEDA'] = '\u0643';
  37494. t['\uFEDB'] = '\u0643';
  37495. t['\uFEDC'] = '\u0643';
  37496. t['\uFEDD'] = '\u0644';
  37497. t['\uFEDE'] = '\u0644';
  37498. t['\uFEDF'] = '\u0644';
  37499. t['\uFEE0'] = '\u0644';
  37500. t['\uFEE1'] = '\u0645';
  37501. t['\uFEE2'] = '\u0645';
  37502. t['\uFEE3'] = '\u0645';
  37503. t['\uFEE4'] = '\u0645';
  37504. t['\uFEE5'] = '\u0646';
  37505. t['\uFEE6'] = '\u0646';
  37506. t['\uFEE7'] = '\u0646';
  37507. t['\uFEE8'] = '\u0646';
  37508. t['\uFEE9'] = '\u0647';
  37509. t['\uFEEA'] = '\u0647';
  37510. t['\uFEEB'] = '\u0647';
  37511. t['\uFEEC'] = '\u0647';
  37512. t['\uFEED'] = '\u0648';
  37513. t['\uFEEE'] = '\u0648';
  37514. t['\uFEEF'] = '\u0649';
  37515. t['\uFEF0'] = '\u0649';
  37516. t['\uFEF1'] = '\u064A';
  37517. t['\uFEF2'] = '\u064A';
  37518. t['\uFEF3'] = '\u064A';
  37519. t['\uFEF4'] = '\u064A';
  37520. t['\uFEF5'] = '\u0644\u0622';
  37521. t['\uFEF6'] = '\u0644\u0622';
  37522. t['\uFEF7'] = '\u0644\u0623';
  37523. t['\uFEF8'] = '\u0644\u0623';
  37524. t['\uFEF9'] = '\u0644\u0625';
  37525. t['\uFEFA'] = '\u0644\u0625';
  37526. t['\uFEFB'] = '\u0644\u0627';
  37527. t['\uFEFC'] = '\u0644\u0627';
  37528. });
  37529. function reverseIfRtl(chars) {
  37530. var charsLength = chars.length;
  37531. if (charsLength <= 1 || !isRTLRangeFor(chars.charCodeAt(0))) {
  37532. return chars;
  37533. }
  37534. var s = '';
  37535. for (var ii = charsLength - 1; ii >= 0; ii--) {
  37536. s += chars[ii];
  37537. }
  37538. return s;
  37539. }
  37540. exports.mapSpecialUnicodeValues = mapSpecialUnicodeValues;
  37541. exports.reverseIfRtl = reverseIfRtl;
  37542. exports.getUnicodeRangeFor = getUnicodeRangeFor;
  37543. exports.getNormalizedUnicodes = getNormalizedUnicodes;
  37544. exports.getUnicodeForGlyph = getUnicodeForGlyph;
  37545. /***/ }),
  37546. /* 23 */
  37547. /***/ (function(module, exports, __w_pdfjs_require__) {
  37548. "use strict";
  37549. var sharedUtil = __w_pdfjs_require__(0);
  37550. var corePrimitives = __w_pdfjs_require__(1);
  37551. var corePdfManager = __w_pdfjs_require__(41);
  37552. var UNSUPPORTED_FEATURES = sharedUtil.UNSUPPORTED_FEATURES;
  37553. var InvalidPDFException = sharedUtil.InvalidPDFException;
  37554. var MessageHandler = sharedUtil.MessageHandler;
  37555. var MissingPDFException = sharedUtil.MissingPDFException;
  37556. var UnexpectedResponseException = sharedUtil.UnexpectedResponseException;
  37557. var PasswordException = sharedUtil.PasswordException;
  37558. var UnknownErrorException = sharedUtil.UnknownErrorException;
  37559. var XRefParseException = sharedUtil.XRefParseException;
  37560. var arrayByteLength = sharedUtil.arrayByteLength;
  37561. var arraysToBytes = sharedUtil.arraysToBytes;
  37562. var assert = sharedUtil.assert;
  37563. var createPromiseCapability = sharedUtil.createPromiseCapability;
  37564. var info = sharedUtil.info;
  37565. var warn = sharedUtil.warn;
  37566. var setVerbosityLevel = sharedUtil.setVerbosityLevel;
  37567. var isNodeJS = sharedUtil.isNodeJS;
  37568. var Ref = corePrimitives.Ref;
  37569. var LocalPdfManager = corePdfManager.LocalPdfManager;
  37570. var NetworkPdfManager = corePdfManager.NetworkPdfManager;
  37571. var WorkerTask = function WorkerTaskClosure() {
  37572. function WorkerTask(name) {
  37573. this.name = name;
  37574. this.terminated = false;
  37575. this._capability = createPromiseCapability();
  37576. }
  37577. WorkerTask.prototype = {
  37578. get finished() {
  37579. return this._capability.promise;
  37580. },
  37581. finish: function () {
  37582. this._capability.resolve();
  37583. },
  37584. terminate: function () {
  37585. this.terminated = true;
  37586. },
  37587. ensureNotTerminated: function () {
  37588. if (this.terminated) {
  37589. throw new Error('Worker task was terminated');
  37590. }
  37591. }
  37592. };
  37593. return WorkerTask;
  37594. }();
  37595. var PDFWorkerStream = function PDFWorkerStreamClosure() {
  37596. function PDFWorkerStream(params, msgHandler) {
  37597. this._queuedChunks = [];
  37598. var initialData = params.initialData;
  37599. if (initialData && initialData.length > 0) {
  37600. this._queuedChunks.push(initialData);
  37601. }
  37602. this._msgHandler = msgHandler;
  37603. this._isRangeSupported = !params.disableRange;
  37604. this._isStreamingSupported = !params.disableStream;
  37605. this._contentLength = params.length;
  37606. this._fullRequestReader = null;
  37607. this._rangeReaders = [];
  37608. msgHandler.on('OnDataRange', this._onReceiveData.bind(this));
  37609. msgHandler.on('OnDataProgress', this._onProgress.bind(this));
  37610. }
  37611. PDFWorkerStream.prototype = {
  37612. _onReceiveData: function PDFWorkerStream_onReceiveData(args) {
  37613. if (args.begin === undefined) {
  37614. if (this._fullRequestReader) {
  37615. this._fullRequestReader._enqueue(args.chunk);
  37616. } else {
  37617. this._queuedChunks.push(args.chunk);
  37618. }
  37619. } else {
  37620. var found = this._rangeReaders.some(function (rangeReader) {
  37621. if (rangeReader._begin !== args.begin) {
  37622. return false;
  37623. }
  37624. rangeReader._enqueue(args.chunk);
  37625. return true;
  37626. });
  37627. assert(found);
  37628. }
  37629. },
  37630. _onProgress: function PDFWorkerStream_onProgress(evt) {
  37631. if (this._rangeReaders.length > 0) {
  37632. var firstReader = this._rangeReaders[0];
  37633. if (firstReader.onProgress) {
  37634. firstReader.onProgress({ loaded: evt.loaded });
  37635. }
  37636. }
  37637. },
  37638. _removeRangeReader: function PDFWorkerStream_removeRangeReader(reader) {
  37639. var i = this._rangeReaders.indexOf(reader);
  37640. if (i >= 0) {
  37641. this._rangeReaders.splice(i, 1);
  37642. }
  37643. },
  37644. getFullReader: function PDFWorkerStream_getFullReader() {
  37645. assert(!this._fullRequestReader);
  37646. var queuedChunks = this._queuedChunks;
  37647. this._queuedChunks = null;
  37648. return new PDFWorkerStreamReader(this, queuedChunks);
  37649. },
  37650. getRangeReader: function PDFWorkerStream_getRangeReader(begin, end) {
  37651. var reader = new PDFWorkerStreamRangeReader(this, begin, end);
  37652. this._msgHandler.send('RequestDataRange', {
  37653. begin: begin,
  37654. end: end
  37655. });
  37656. this._rangeReaders.push(reader);
  37657. return reader;
  37658. },
  37659. cancelAllRequests: function PDFWorkerStream_cancelAllRequests(reason) {
  37660. if (this._fullRequestReader) {
  37661. this._fullRequestReader.cancel(reason);
  37662. }
  37663. var readers = this._rangeReaders.slice(0);
  37664. readers.forEach(function (rangeReader) {
  37665. rangeReader.cancel(reason);
  37666. });
  37667. }
  37668. };
  37669. function PDFWorkerStreamReader(stream, queuedChunks) {
  37670. this._stream = stream;
  37671. this._done = false;
  37672. this._queuedChunks = queuedChunks || [];
  37673. this._requests = [];
  37674. this._headersReady = Promise.resolve();
  37675. stream._fullRequestReader = this;
  37676. this.onProgress = null;
  37677. }
  37678. PDFWorkerStreamReader.prototype = {
  37679. _enqueue: function PDFWorkerStreamReader_enqueue(chunk) {
  37680. if (this._done) {
  37681. return;
  37682. }
  37683. if (this._requests.length > 0) {
  37684. var requestCapability = this._requests.shift();
  37685. requestCapability.resolve({
  37686. value: chunk,
  37687. done: false
  37688. });
  37689. return;
  37690. }
  37691. this._queuedChunks.push(chunk);
  37692. },
  37693. get headersReady() {
  37694. return this._headersReady;
  37695. },
  37696. get isRangeSupported() {
  37697. return this._stream._isRangeSupported;
  37698. },
  37699. get isStreamingSupported() {
  37700. return this._stream._isStreamingSupported;
  37701. },
  37702. get contentLength() {
  37703. return this._stream._contentLength;
  37704. },
  37705. read: function PDFWorkerStreamReader_read() {
  37706. if (this._queuedChunks.length > 0) {
  37707. var chunk = this._queuedChunks.shift();
  37708. return Promise.resolve({
  37709. value: chunk,
  37710. done: false
  37711. });
  37712. }
  37713. if (this._done) {
  37714. return Promise.resolve({
  37715. value: undefined,
  37716. done: true
  37717. });
  37718. }
  37719. var requestCapability = createPromiseCapability();
  37720. this._requests.push(requestCapability);
  37721. return requestCapability.promise;
  37722. },
  37723. cancel: function PDFWorkerStreamReader_cancel(reason) {
  37724. this._done = true;
  37725. this._requests.forEach(function (requestCapability) {
  37726. requestCapability.resolve({
  37727. value: undefined,
  37728. done: true
  37729. });
  37730. });
  37731. this._requests = [];
  37732. }
  37733. };
  37734. function PDFWorkerStreamRangeReader(stream, begin, end) {
  37735. this._stream = stream;
  37736. this._begin = begin;
  37737. this._end = end;
  37738. this._queuedChunk = null;
  37739. this._requests = [];
  37740. this._done = false;
  37741. this.onProgress = null;
  37742. }
  37743. PDFWorkerStreamRangeReader.prototype = {
  37744. _enqueue: function PDFWorkerStreamRangeReader_enqueue(chunk) {
  37745. if (this._done) {
  37746. return;
  37747. }
  37748. if (this._requests.length === 0) {
  37749. this._queuedChunk = chunk;
  37750. } else {
  37751. var requestsCapability = this._requests.shift();
  37752. requestsCapability.resolve({
  37753. value: chunk,
  37754. done: false
  37755. });
  37756. this._requests.forEach(function (requestCapability) {
  37757. requestCapability.resolve({
  37758. value: undefined,
  37759. done: true
  37760. });
  37761. });
  37762. this._requests = [];
  37763. }
  37764. this._done = true;
  37765. this._stream._removeRangeReader(this);
  37766. },
  37767. get isStreamingSupported() {
  37768. return false;
  37769. },
  37770. read: function PDFWorkerStreamRangeReader_read() {
  37771. if (this._queuedChunk) {
  37772. return Promise.resolve({
  37773. value: this._queuedChunk,
  37774. done: false
  37775. });
  37776. }
  37777. if (this._done) {
  37778. return Promise.resolve({
  37779. value: undefined,
  37780. done: true
  37781. });
  37782. }
  37783. var requestCapability = createPromiseCapability();
  37784. this._requests.push(requestCapability);
  37785. return requestCapability.promise;
  37786. },
  37787. cancel: function PDFWorkerStreamRangeReader_cancel(reason) {
  37788. this._done = true;
  37789. this._requests.forEach(function (requestCapability) {
  37790. requestCapability.resolve({
  37791. value: undefined,
  37792. done: true
  37793. });
  37794. });
  37795. this._requests = [];
  37796. this._stream._removeRangeReader(this);
  37797. }
  37798. };
  37799. return PDFWorkerStream;
  37800. }();
  37801. var PDFNetworkStream;
  37802. function setPDFNetworkStreamClass(cls) {
  37803. PDFNetworkStream = cls;
  37804. }
  37805. var WorkerMessageHandler = {
  37806. setup: function wphSetup(handler, port) {
  37807. var testMessageProcessed = false;
  37808. handler.on('test', function wphSetupTest(data) {
  37809. if (testMessageProcessed) {
  37810. return;
  37811. }
  37812. testMessageProcessed = true;
  37813. if (!(data instanceof Uint8Array)) {
  37814. handler.send('test', 'main', false);
  37815. return;
  37816. }
  37817. var supportTransfers = data[0] === 255;
  37818. handler.postMessageTransfers = supportTransfers;
  37819. var xhr = new XMLHttpRequest();
  37820. var responseExists = 'response' in xhr;
  37821. try {
  37822. xhr.responseType;
  37823. } catch (e) {
  37824. responseExists = false;
  37825. }
  37826. if (!responseExists) {
  37827. handler.send('test', false);
  37828. return;
  37829. }
  37830. handler.send('test', {
  37831. supportTypedArray: true,
  37832. supportTransfers: supportTransfers
  37833. });
  37834. });
  37835. handler.on('configure', function wphConfigure(data) {
  37836. setVerbosityLevel(data.verbosity);
  37837. });
  37838. handler.on('GetDocRequest', function wphSetupDoc(data) {
  37839. return WorkerMessageHandler.createDocumentHandler(data, port);
  37840. });
  37841. },
  37842. createDocumentHandler: function wphCreateDocumentHandler(docParams, port) {
  37843. var pdfManager;
  37844. var terminated = false;
  37845. var cancelXHRs = null;
  37846. var WorkerTasks = [];
  37847. var docId = docParams.docId;
  37848. var docBaseUrl = docParams.docBaseUrl;
  37849. var workerHandlerName = docParams.docId + '_worker';
  37850. var handler = new MessageHandler(workerHandlerName, docId, port);
  37851. handler.postMessageTransfers = docParams.postMessageTransfers;
  37852. function ensureNotTerminated() {
  37853. if (terminated) {
  37854. throw new Error('Worker was terminated');
  37855. }
  37856. }
  37857. function startWorkerTask(task) {
  37858. WorkerTasks.push(task);
  37859. }
  37860. function finishWorkerTask(task) {
  37861. task.finish();
  37862. var i = WorkerTasks.indexOf(task);
  37863. WorkerTasks.splice(i, 1);
  37864. }
  37865. function loadDocument(recoveryMode) {
  37866. var loadDocumentCapability = createPromiseCapability();
  37867. var parseSuccess = function parseSuccess() {
  37868. var numPagesPromise = pdfManager.ensureDoc('numPages');
  37869. var fingerprintPromise = pdfManager.ensureDoc('fingerprint');
  37870. var encryptedPromise = pdfManager.ensureXRef('encrypt');
  37871. Promise.all([
  37872. numPagesPromise,
  37873. fingerprintPromise,
  37874. encryptedPromise
  37875. ]).then(function onDocReady(results) {
  37876. var doc = {
  37877. numPages: results[0],
  37878. fingerprint: results[1],
  37879. encrypted: !!results[2]
  37880. };
  37881. loadDocumentCapability.resolve(doc);
  37882. }, parseFailure);
  37883. };
  37884. var parseFailure = function parseFailure(e) {
  37885. loadDocumentCapability.reject(e);
  37886. };
  37887. pdfManager.ensureDoc('checkHeader', []).then(function () {
  37888. pdfManager.ensureDoc('parseStartXRef', []).then(function () {
  37889. pdfManager.ensureDoc('parse', [recoveryMode]).then(parseSuccess, parseFailure);
  37890. }, parseFailure);
  37891. }, parseFailure);
  37892. return loadDocumentCapability.promise;
  37893. }
  37894. function getPdfManager(data, evaluatorOptions) {
  37895. var pdfManagerCapability = createPromiseCapability();
  37896. var pdfManager;
  37897. var source = data.source;
  37898. if (source.data) {
  37899. try {
  37900. pdfManager = new LocalPdfManager(docId, source.data, source.password, evaluatorOptions, docBaseUrl);
  37901. pdfManagerCapability.resolve(pdfManager);
  37902. } catch (ex) {
  37903. pdfManagerCapability.reject(ex);
  37904. }
  37905. return pdfManagerCapability.promise;
  37906. }
  37907. var pdfStream;
  37908. try {
  37909. if (source.chunkedViewerLoading) {
  37910. pdfStream = new PDFWorkerStream(source, handler);
  37911. } else {
  37912. assert(PDFNetworkStream, 'pdfjs/core/network module is not loaded');
  37913. pdfStream = new PDFNetworkStream(data);
  37914. }
  37915. } catch (ex) {
  37916. pdfManagerCapability.reject(ex);
  37917. return pdfManagerCapability.promise;
  37918. }
  37919. var fullRequest = pdfStream.getFullReader();
  37920. fullRequest.headersReady.then(function () {
  37921. if (!fullRequest.isStreamingSupported || !fullRequest.isRangeSupported) {
  37922. fullRequest.onProgress = function (evt) {
  37923. handler.send('DocProgress', {
  37924. loaded: evt.loaded,
  37925. total: evt.total
  37926. });
  37927. };
  37928. }
  37929. if (!fullRequest.isRangeSupported) {
  37930. return;
  37931. }
  37932. var disableAutoFetch = source.disableAutoFetch || fullRequest.isStreamingSupported;
  37933. pdfManager = new NetworkPdfManager(docId, pdfStream, {
  37934. msgHandler: handler,
  37935. url: source.url,
  37936. password: source.password,
  37937. length: fullRequest.contentLength,
  37938. disableAutoFetch: disableAutoFetch,
  37939. rangeChunkSize: source.rangeChunkSize
  37940. }, evaluatorOptions, docBaseUrl);
  37941. pdfManagerCapability.resolve(pdfManager);
  37942. cancelXHRs = null;
  37943. }).catch(function (reason) {
  37944. pdfManagerCapability.reject(reason);
  37945. cancelXHRs = null;
  37946. });
  37947. var cachedChunks = [], loaded = 0;
  37948. var flushChunks = function () {
  37949. var pdfFile = arraysToBytes(cachedChunks);
  37950. if (source.length && pdfFile.length !== source.length) {
  37951. warn('reported HTTP length is different from actual');
  37952. }
  37953. try {
  37954. pdfManager = new LocalPdfManager(docId, pdfFile, source.password, evaluatorOptions, docBaseUrl);
  37955. pdfManagerCapability.resolve(pdfManager);
  37956. } catch (ex) {
  37957. pdfManagerCapability.reject(ex);
  37958. }
  37959. cachedChunks = [];
  37960. };
  37961. var readPromise = new Promise(function (resolve, reject) {
  37962. var readChunk = function (chunk) {
  37963. try {
  37964. ensureNotTerminated();
  37965. if (chunk.done) {
  37966. if (!pdfManager) {
  37967. flushChunks();
  37968. }
  37969. cancelXHRs = null;
  37970. return;
  37971. }
  37972. var data = chunk.value;
  37973. loaded += arrayByteLength(data);
  37974. if (!fullRequest.isStreamingSupported) {
  37975. handler.send('DocProgress', {
  37976. loaded: loaded,
  37977. total: Math.max(loaded, fullRequest.contentLength || 0)
  37978. });
  37979. }
  37980. if (pdfManager) {
  37981. pdfManager.sendProgressiveData(data);
  37982. } else {
  37983. cachedChunks.push(data);
  37984. }
  37985. fullRequest.read().then(readChunk, reject);
  37986. } catch (e) {
  37987. reject(e);
  37988. }
  37989. };
  37990. fullRequest.read().then(readChunk, reject);
  37991. });
  37992. readPromise.catch(function (e) {
  37993. pdfManagerCapability.reject(e);
  37994. cancelXHRs = null;
  37995. });
  37996. cancelXHRs = function () {
  37997. pdfStream.cancelAllRequests('abort');
  37998. };
  37999. return pdfManagerCapability.promise;
  38000. }
  38001. function setupDoc(data) {
  38002. function onSuccess(doc) {
  38003. ensureNotTerminated();
  38004. handler.send('GetDoc', { pdfInfo: doc });
  38005. }
  38006. function onFailure(e) {
  38007. if (e instanceof PasswordException) {
  38008. var task = new WorkerTask('PasswordException: response ' + e.code);
  38009. startWorkerTask(task);
  38010. handler.sendWithPromise('PasswordRequest', e).then(function (data) {
  38011. finishWorkerTask(task);
  38012. pdfManager.updatePassword(data.password);
  38013. pdfManagerReady();
  38014. }).catch(function (ex) {
  38015. finishWorkerTask(task);
  38016. handler.send('PasswordException', ex);
  38017. }.bind(null, e));
  38018. } else if (e instanceof InvalidPDFException) {
  38019. handler.send('InvalidPDF', e);
  38020. } else if (e instanceof MissingPDFException) {
  38021. handler.send('MissingPDF', e);
  38022. } else if (e instanceof UnexpectedResponseException) {
  38023. handler.send('UnexpectedResponse', e);
  38024. } else {
  38025. handler.send('UnknownError', new UnknownErrorException(e.message, e.toString()));
  38026. }
  38027. }
  38028. function pdfManagerReady() {
  38029. ensureNotTerminated();
  38030. loadDocument(false).then(onSuccess, function loadFailure(ex) {
  38031. ensureNotTerminated();
  38032. if (!(ex instanceof XRefParseException)) {
  38033. onFailure(ex);
  38034. return;
  38035. }
  38036. pdfManager.requestLoadedStream();
  38037. pdfManager.onLoadedStream().then(function () {
  38038. ensureNotTerminated();
  38039. loadDocument(true).then(onSuccess, onFailure);
  38040. });
  38041. }, onFailure);
  38042. }
  38043. ensureNotTerminated();
  38044. var evaluatorOptions = {
  38045. forceDataSchema: data.disableCreateObjectURL,
  38046. maxImageSize: data.maxImageSize === undefined ? -1 : data.maxImageSize,
  38047. disableFontFace: data.disableFontFace,
  38048. disableNativeImageDecoder: data.disableNativeImageDecoder
  38049. };
  38050. getPdfManager(data, evaluatorOptions).then(function (newPdfManager) {
  38051. if (terminated) {
  38052. newPdfManager.terminate();
  38053. throw new Error('Worker was terminated');
  38054. }
  38055. pdfManager = newPdfManager;
  38056. handler.send('PDFManagerReady', null);
  38057. pdfManager.onLoadedStream().then(function (stream) {
  38058. handler.send('DataLoaded', { length: stream.bytes.byteLength });
  38059. });
  38060. }).then(pdfManagerReady, onFailure);
  38061. }
  38062. handler.on('GetPage', function wphSetupGetPage(data) {
  38063. return pdfManager.getPage(data.pageIndex).then(function (page) {
  38064. var rotatePromise = pdfManager.ensure(page, 'rotate');
  38065. var refPromise = pdfManager.ensure(page, 'ref');
  38066. var userUnitPromise = pdfManager.ensure(page, 'userUnit');
  38067. var viewPromise = pdfManager.ensure(page, 'view');
  38068. return Promise.all([
  38069. rotatePromise,
  38070. refPromise,
  38071. userUnitPromise,
  38072. viewPromise
  38073. ]).then(function (results) {
  38074. return {
  38075. rotate: results[0],
  38076. ref: results[1],
  38077. userUnit: results[2],
  38078. view: results[3]
  38079. };
  38080. });
  38081. });
  38082. });
  38083. handler.on('GetPageIndex', function wphSetupGetPageIndex(data) {
  38084. var ref = new Ref(data.ref.num, data.ref.gen);
  38085. var catalog = pdfManager.pdfDocument.catalog;
  38086. return catalog.getPageIndex(ref);
  38087. });
  38088. handler.on('GetDestinations', function wphSetupGetDestinations(data) {
  38089. return pdfManager.ensureCatalog('destinations');
  38090. });
  38091. handler.on('GetDestination', function wphSetupGetDestination(data) {
  38092. return pdfManager.ensureCatalog('getDestination', [data.id]);
  38093. });
  38094. handler.on('GetPageLabels', function wphSetupGetPageLabels(data) {
  38095. return pdfManager.ensureCatalog('pageLabels');
  38096. });
  38097. handler.on('GetAttachments', function wphSetupGetAttachments(data) {
  38098. return pdfManager.ensureCatalog('attachments');
  38099. });
  38100. handler.on('GetJavaScript', function wphSetupGetJavaScript(data) {
  38101. return pdfManager.ensureCatalog('javaScript');
  38102. });
  38103. handler.on('GetOutline', function wphSetupGetOutline(data) {
  38104. return pdfManager.ensureCatalog('documentOutline');
  38105. });
  38106. handler.on('GetMetadata', function wphSetupGetMetadata(data) {
  38107. return Promise.all([
  38108. pdfManager.ensureDoc('documentInfo'),
  38109. pdfManager.ensureCatalog('metadata')
  38110. ]);
  38111. });
  38112. handler.on('GetData', function wphSetupGetData(data) {
  38113. pdfManager.requestLoadedStream();
  38114. return pdfManager.onLoadedStream().then(function (stream) {
  38115. return stream.bytes;
  38116. });
  38117. });
  38118. handler.on('GetStats', function wphSetupGetStats(data) {
  38119. return pdfManager.pdfDocument.xref.stats;
  38120. });
  38121. handler.on('GetAnnotations', function wphSetupGetAnnotations(data) {
  38122. return pdfManager.getPage(data.pageIndex).then(function (page) {
  38123. return pdfManager.ensure(page, 'getAnnotationsData', [data.intent]);
  38124. });
  38125. });
  38126. handler.on('RenderPageRequest', function wphSetupRenderPage(data) {
  38127. var pageIndex = data.pageIndex;
  38128. pdfManager.getPage(pageIndex).then(function (page) {
  38129. var task = new WorkerTask('RenderPageRequest: page ' + pageIndex);
  38130. startWorkerTask(task);
  38131. var pageNum = pageIndex + 1;
  38132. var start = Date.now();
  38133. page.getOperatorList(handler, task, data.intent, data.renderInteractiveForms).then(function (operatorList) {
  38134. finishWorkerTask(task);
  38135. info('page=' + pageNum + ' - getOperatorList: time=' + (Date.now() - start) + 'ms, len=' + operatorList.totalLength);
  38136. }, function (e) {
  38137. finishWorkerTask(task);
  38138. if (task.terminated) {
  38139. return;
  38140. }
  38141. handler.send('UnsupportedFeature', { featureId: UNSUPPORTED_FEATURES.unknown });
  38142. var minimumStackMessage = 'worker.js: while trying to getPage() and getOperatorList()';
  38143. var wrappedException;
  38144. if (typeof e === 'string') {
  38145. wrappedException = {
  38146. message: e,
  38147. stack: minimumStackMessage
  38148. };
  38149. } else if (typeof e === 'object') {
  38150. wrappedException = {
  38151. message: e.message || e.toString(),
  38152. stack: e.stack || minimumStackMessage
  38153. };
  38154. } else {
  38155. wrappedException = {
  38156. message: 'Unknown exception type: ' + typeof e,
  38157. stack: minimumStackMessage
  38158. };
  38159. }
  38160. handler.send('PageError', {
  38161. pageNum: pageNum,
  38162. error: wrappedException,
  38163. intent: data.intent
  38164. });
  38165. });
  38166. });
  38167. }, this);
  38168. handler.on('GetTextContent', function wphExtractText(data) {
  38169. var pageIndex = data.pageIndex;
  38170. var normalizeWhitespace = data.normalizeWhitespace;
  38171. var combineTextItems = data.combineTextItems;
  38172. return pdfManager.getPage(pageIndex).then(function (page) {
  38173. var task = new WorkerTask('GetTextContent: page ' + pageIndex);
  38174. startWorkerTask(task);
  38175. var pageNum = pageIndex + 1;
  38176. var start = Date.now();
  38177. return page.extractTextContent(task, normalizeWhitespace, combineTextItems).then(function (textContent) {
  38178. finishWorkerTask(task);
  38179. info('text indexing: page=' + pageNum + ' - time=' + (Date.now() - start) + 'ms');
  38180. return textContent;
  38181. }, function (reason) {
  38182. finishWorkerTask(task);
  38183. if (task.terminated) {
  38184. return;
  38185. }
  38186. throw reason;
  38187. });
  38188. });
  38189. });
  38190. handler.on('Cleanup', function wphCleanup(data) {
  38191. return pdfManager.cleanup();
  38192. });
  38193. handler.on('Terminate', function wphTerminate(data) {
  38194. terminated = true;
  38195. if (pdfManager) {
  38196. pdfManager.terminate();
  38197. pdfManager = null;
  38198. }
  38199. if (cancelXHRs) {
  38200. cancelXHRs();
  38201. }
  38202. var waitOn = [];
  38203. WorkerTasks.forEach(function (task) {
  38204. waitOn.push(task.finished);
  38205. task.terminate();
  38206. });
  38207. return Promise.all(waitOn).then(function () {
  38208. handler.destroy();
  38209. handler = null;
  38210. });
  38211. });
  38212. handler.on('Ready', function wphReady(data) {
  38213. setupDoc(docParams);
  38214. docParams = null;
  38215. });
  38216. return workerHandlerName;
  38217. }
  38218. };
  38219. function initializeWorker() {
  38220. var handler = new MessageHandler('worker', 'main', self);
  38221. WorkerMessageHandler.setup(handler, self);
  38222. handler.send('ready', null);
  38223. }
  38224. if (typeof window === 'undefined' && !isNodeJS()) {
  38225. initializeWorker();
  38226. }
  38227. exports.setPDFNetworkStreamClass = setPDFNetworkStreamClass;
  38228. exports.WorkerTask = WorkerTask;
  38229. exports.WorkerMessageHandler = WorkerMessageHandler;
  38230. /***/ }),
  38231. /* 24 */
  38232. /***/ (function(module, exports, __w_pdfjs_require__) {
  38233. "use strict";
  38234. var sharedUtil = __w_pdfjs_require__(0);
  38235. var error = sharedUtil.error;
  38236. function fixMetadata(meta) {
  38237. return meta.replace(/>\\376\\377([^<]+)/g, function (all, codes) {
  38238. var bytes = codes.replace(/\\([0-3])([0-7])([0-7])/g, function (code, d1, d2, d3) {
  38239. return String.fromCharCode(d1 * 64 + d2 * 8 + d3 * 1);
  38240. });
  38241. var chars = '';
  38242. for (var i = 0; i < bytes.length; i += 2) {
  38243. var code = bytes.charCodeAt(i) * 256 + bytes.charCodeAt(i + 1);
  38244. chars += code >= 32 && code < 127 && code !== 60 && code !== 62 && code !== 38 ? String.fromCharCode(code) : '&#x' + (0x10000 + code).toString(16).substring(1) + ';';
  38245. }
  38246. return '>' + chars;
  38247. });
  38248. }
  38249. function Metadata(meta) {
  38250. if (typeof meta === 'string') {
  38251. meta = fixMetadata(meta);
  38252. var parser = new DOMParser();
  38253. meta = parser.parseFromString(meta, 'application/xml');
  38254. } else if (!(meta instanceof Document)) {
  38255. error('Metadata: Invalid metadata object');
  38256. }
  38257. this.metaDocument = meta;
  38258. this.metadata = Object.create(null);
  38259. this.parse();
  38260. }
  38261. Metadata.prototype = {
  38262. parse: function Metadata_parse() {
  38263. var doc = this.metaDocument;
  38264. var rdf = doc.documentElement;
  38265. if (rdf.nodeName.toLowerCase() !== 'rdf:rdf') {
  38266. rdf = rdf.firstChild;
  38267. while (rdf && rdf.nodeName.toLowerCase() !== 'rdf:rdf') {
  38268. rdf = rdf.nextSibling;
  38269. }
  38270. }
  38271. var nodeName = rdf ? rdf.nodeName.toLowerCase() : null;
  38272. if (!rdf || nodeName !== 'rdf:rdf' || !rdf.hasChildNodes()) {
  38273. return;
  38274. }
  38275. var children = rdf.childNodes, desc, entry, name, i, ii, length, iLength;
  38276. for (i = 0, length = children.length; i < length; i++) {
  38277. desc = children[i];
  38278. if (desc.nodeName.toLowerCase() !== 'rdf:description') {
  38279. continue;
  38280. }
  38281. for (ii = 0, iLength = desc.childNodes.length; ii < iLength; ii++) {
  38282. if (desc.childNodes[ii].nodeName.toLowerCase() !== '#text') {
  38283. entry = desc.childNodes[ii];
  38284. name = entry.nodeName.toLowerCase();
  38285. this.metadata[name] = entry.textContent.trim();
  38286. }
  38287. }
  38288. }
  38289. },
  38290. get: function Metadata_get(name) {
  38291. return this.metadata[name] || null;
  38292. },
  38293. has: function Metadata_has(name) {
  38294. return typeof this.metadata[name] !== 'undefined';
  38295. }
  38296. };
  38297. exports.Metadata = Metadata;
  38298. /***/ }),
  38299. /* 25 */
  38300. /***/ (function(module, exports, __w_pdfjs_require__) {
  38301. "use strict";
  38302. var sharedUtil = __w_pdfjs_require__(0);
  38303. var displayDOMUtils = __w_pdfjs_require__(3);
  38304. var shadow = sharedUtil.shadow;
  38305. var getDefaultSetting = displayDOMUtils.getDefaultSetting;
  38306. var WebGLUtils = function WebGLUtilsClosure() {
  38307. function loadShader(gl, code, shaderType) {
  38308. var shader = gl.createShader(shaderType);
  38309. gl.shaderSource(shader, code);
  38310. gl.compileShader(shader);
  38311. var compiled = gl.getShaderParameter(shader, gl.COMPILE_STATUS);
  38312. if (!compiled) {
  38313. var errorMsg = gl.getShaderInfoLog(shader);
  38314. throw new Error('Error during shader compilation: ' + errorMsg);
  38315. }
  38316. return shader;
  38317. }
  38318. function createVertexShader(gl, code) {
  38319. return loadShader(gl, code, gl.VERTEX_SHADER);
  38320. }
  38321. function createFragmentShader(gl, code) {
  38322. return loadShader(gl, code, gl.FRAGMENT_SHADER);
  38323. }
  38324. function createProgram(gl, shaders) {
  38325. var program = gl.createProgram();
  38326. for (var i = 0, ii = shaders.length; i < ii; ++i) {
  38327. gl.attachShader(program, shaders[i]);
  38328. }
  38329. gl.linkProgram(program);
  38330. var linked = gl.getProgramParameter(program, gl.LINK_STATUS);
  38331. if (!linked) {
  38332. var errorMsg = gl.getProgramInfoLog(program);
  38333. throw new Error('Error during program linking: ' + errorMsg);
  38334. }
  38335. return program;
  38336. }
  38337. function createTexture(gl, image, textureId) {
  38338. gl.activeTexture(textureId);
  38339. var texture = gl.createTexture();
  38340. gl.bindTexture(gl.TEXTURE_2D, texture);
  38341. gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE);
  38342. gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE);
  38343. gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.NEAREST);
  38344. gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.NEAREST);
  38345. gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, gl.RGBA, gl.UNSIGNED_BYTE, image);
  38346. return texture;
  38347. }
  38348. var currentGL, currentCanvas;
  38349. function generateGL() {
  38350. if (currentGL) {
  38351. return;
  38352. }
  38353. currentCanvas = document.createElement('canvas');
  38354. currentGL = currentCanvas.getContext('webgl', { premultipliedalpha: false });
  38355. }
  38356. var smaskVertexShaderCode = '\
  38357. attribute vec2 a_position; \
  38358. attribute vec2 a_texCoord; \
  38359. \
  38360. uniform vec2 u_resolution; \
  38361. \
  38362. varying vec2 v_texCoord; \
  38363. \
  38364. void main() { \
  38365. vec2 clipSpace = (a_position / u_resolution) * 2.0 - 1.0; \
  38366. gl_Position = vec4(clipSpace * vec2(1, -1), 0, 1); \
  38367. \
  38368. v_texCoord = a_texCoord; \
  38369. } ';
  38370. var smaskFragmentShaderCode = '\
  38371. precision mediump float; \
  38372. \
  38373. uniform vec4 u_backdrop; \
  38374. uniform int u_subtype; \
  38375. uniform sampler2D u_image; \
  38376. uniform sampler2D u_mask; \
  38377. \
  38378. varying vec2 v_texCoord; \
  38379. \
  38380. void main() { \
  38381. vec4 imageColor = texture2D(u_image, v_texCoord); \
  38382. vec4 maskColor = texture2D(u_mask, v_texCoord); \
  38383. if (u_backdrop.a > 0.0) { \
  38384. maskColor.rgb = maskColor.rgb * maskColor.a + \
  38385. u_backdrop.rgb * (1.0 - maskColor.a); \
  38386. } \
  38387. float lum; \
  38388. if (u_subtype == 0) { \
  38389. lum = maskColor.a; \
  38390. } else { \
  38391. lum = maskColor.r * 0.3 + maskColor.g * 0.59 + \
  38392. maskColor.b * 0.11; \
  38393. } \
  38394. imageColor.a *= lum; \
  38395. imageColor.rgb *= imageColor.a; \
  38396. gl_FragColor = imageColor; \
  38397. } ';
  38398. var smaskCache = null;
  38399. function initSmaskGL() {
  38400. var canvas, gl;
  38401. generateGL();
  38402. canvas = currentCanvas;
  38403. currentCanvas = null;
  38404. gl = currentGL;
  38405. currentGL = null;
  38406. var vertexShader = createVertexShader(gl, smaskVertexShaderCode);
  38407. var fragmentShader = createFragmentShader(gl, smaskFragmentShaderCode);
  38408. var program = createProgram(gl, [
  38409. vertexShader,
  38410. fragmentShader
  38411. ]);
  38412. gl.useProgram(program);
  38413. var cache = {};
  38414. cache.gl = gl;
  38415. cache.canvas = canvas;
  38416. cache.resolutionLocation = gl.getUniformLocation(program, 'u_resolution');
  38417. cache.positionLocation = gl.getAttribLocation(program, 'a_position');
  38418. cache.backdropLocation = gl.getUniformLocation(program, 'u_backdrop');
  38419. cache.subtypeLocation = gl.getUniformLocation(program, 'u_subtype');
  38420. var texCoordLocation = gl.getAttribLocation(program, 'a_texCoord');
  38421. var texLayerLocation = gl.getUniformLocation(program, 'u_image');
  38422. var texMaskLocation = gl.getUniformLocation(program, 'u_mask');
  38423. var texCoordBuffer = gl.createBuffer();
  38424. gl.bindBuffer(gl.ARRAY_BUFFER, texCoordBuffer);
  38425. gl.bufferData(gl.ARRAY_BUFFER, new Float32Array([
  38426. 0.0,
  38427. 0.0,
  38428. 1.0,
  38429. 0.0,
  38430. 0.0,
  38431. 1.0,
  38432. 0.0,
  38433. 1.0,
  38434. 1.0,
  38435. 0.0,
  38436. 1.0,
  38437. 1.0
  38438. ]), gl.STATIC_DRAW);
  38439. gl.enableVertexAttribArray(texCoordLocation);
  38440. gl.vertexAttribPointer(texCoordLocation, 2, gl.FLOAT, false, 0, 0);
  38441. gl.uniform1i(texLayerLocation, 0);
  38442. gl.uniform1i(texMaskLocation, 1);
  38443. smaskCache = cache;
  38444. }
  38445. function composeSMask(layer, mask, properties) {
  38446. var width = layer.width, height = layer.height;
  38447. if (!smaskCache) {
  38448. initSmaskGL();
  38449. }
  38450. var cache = smaskCache, canvas = cache.canvas, gl = cache.gl;
  38451. canvas.width = width;
  38452. canvas.height = height;
  38453. gl.viewport(0, 0, gl.drawingBufferWidth, gl.drawingBufferHeight);
  38454. gl.uniform2f(cache.resolutionLocation, width, height);
  38455. if (properties.backdrop) {
  38456. gl.uniform4f(cache.resolutionLocation, properties.backdrop[0], properties.backdrop[1], properties.backdrop[2], 1);
  38457. } else {
  38458. gl.uniform4f(cache.resolutionLocation, 0, 0, 0, 0);
  38459. }
  38460. gl.uniform1i(cache.subtypeLocation, properties.subtype === 'Luminosity' ? 1 : 0);
  38461. var texture = createTexture(gl, layer, gl.TEXTURE0);
  38462. var maskTexture = createTexture(gl, mask, gl.TEXTURE1);
  38463. var buffer = gl.createBuffer();
  38464. gl.bindBuffer(gl.ARRAY_BUFFER, buffer);
  38465. gl.bufferData(gl.ARRAY_BUFFER, new Float32Array([
  38466. 0,
  38467. 0,
  38468. width,
  38469. 0,
  38470. 0,
  38471. height,
  38472. 0,
  38473. height,
  38474. width,
  38475. 0,
  38476. width,
  38477. height
  38478. ]), gl.STATIC_DRAW);
  38479. gl.enableVertexAttribArray(cache.positionLocation);
  38480. gl.vertexAttribPointer(cache.positionLocation, 2, gl.FLOAT, false, 0, 0);
  38481. gl.clearColor(0, 0, 0, 0);
  38482. gl.enable(gl.BLEND);
  38483. gl.blendFunc(gl.ONE, gl.ONE_MINUS_SRC_ALPHA);
  38484. gl.clear(gl.COLOR_BUFFER_BIT);
  38485. gl.drawArrays(gl.TRIANGLES, 0, 6);
  38486. gl.flush();
  38487. gl.deleteTexture(texture);
  38488. gl.deleteTexture(maskTexture);
  38489. gl.deleteBuffer(buffer);
  38490. return canvas;
  38491. }
  38492. var figuresVertexShaderCode = '\
  38493. attribute vec2 a_position; \
  38494. attribute vec3 a_color; \
  38495. \
  38496. uniform vec2 u_resolution; \
  38497. uniform vec2 u_scale; \
  38498. uniform vec2 u_offset; \
  38499. \
  38500. varying vec4 v_color; \
  38501. \
  38502. void main() { \
  38503. vec2 position = (a_position + u_offset) * u_scale; \
  38504. vec2 clipSpace = (position / u_resolution) * 2.0 - 1.0; \
  38505. gl_Position = vec4(clipSpace * vec2(1, -1), 0, 1); \
  38506. \
  38507. v_color = vec4(a_color / 255.0, 1.0); \
  38508. } ';
  38509. var figuresFragmentShaderCode = '\
  38510. precision mediump float; \
  38511. \
  38512. varying vec4 v_color; \
  38513. \
  38514. void main() { \
  38515. gl_FragColor = v_color; \
  38516. } ';
  38517. var figuresCache = null;
  38518. function initFiguresGL() {
  38519. var canvas, gl;
  38520. generateGL();
  38521. canvas = currentCanvas;
  38522. currentCanvas = null;
  38523. gl = currentGL;
  38524. currentGL = null;
  38525. var vertexShader = createVertexShader(gl, figuresVertexShaderCode);
  38526. var fragmentShader = createFragmentShader(gl, figuresFragmentShaderCode);
  38527. var program = createProgram(gl, [
  38528. vertexShader,
  38529. fragmentShader
  38530. ]);
  38531. gl.useProgram(program);
  38532. var cache = {};
  38533. cache.gl = gl;
  38534. cache.canvas = canvas;
  38535. cache.resolutionLocation = gl.getUniformLocation(program, 'u_resolution');
  38536. cache.scaleLocation = gl.getUniformLocation(program, 'u_scale');
  38537. cache.offsetLocation = gl.getUniformLocation(program, 'u_offset');
  38538. cache.positionLocation = gl.getAttribLocation(program, 'a_position');
  38539. cache.colorLocation = gl.getAttribLocation(program, 'a_color');
  38540. figuresCache = cache;
  38541. }
  38542. function drawFigures(width, height, backgroundColor, figures, context) {
  38543. if (!figuresCache) {
  38544. initFiguresGL();
  38545. }
  38546. var cache = figuresCache, canvas = cache.canvas, gl = cache.gl;
  38547. canvas.width = width;
  38548. canvas.height = height;
  38549. gl.viewport(0, 0, gl.drawingBufferWidth, gl.drawingBufferHeight);
  38550. gl.uniform2f(cache.resolutionLocation, width, height);
  38551. var count = 0;
  38552. var i, ii, rows;
  38553. for (i = 0, ii = figures.length; i < ii; i++) {
  38554. switch (figures[i].type) {
  38555. case 'lattice':
  38556. rows = figures[i].coords.length / figures[i].verticesPerRow | 0;
  38557. count += (rows - 1) * (figures[i].verticesPerRow - 1) * 6;
  38558. break;
  38559. case 'triangles':
  38560. count += figures[i].coords.length;
  38561. break;
  38562. }
  38563. }
  38564. var coords = new Float32Array(count * 2);
  38565. var colors = new Uint8Array(count * 3);
  38566. var coordsMap = context.coords, colorsMap = context.colors;
  38567. var pIndex = 0, cIndex = 0;
  38568. for (i = 0, ii = figures.length; i < ii; i++) {
  38569. var figure = figures[i], ps = figure.coords, cs = figure.colors;
  38570. switch (figure.type) {
  38571. case 'lattice':
  38572. var cols = figure.verticesPerRow;
  38573. rows = ps.length / cols | 0;
  38574. for (var row = 1; row < rows; row++) {
  38575. var offset = row * cols + 1;
  38576. for (var col = 1; col < cols; col++, offset++) {
  38577. coords[pIndex] = coordsMap[ps[offset - cols - 1]];
  38578. coords[pIndex + 1] = coordsMap[ps[offset - cols - 1] + 1];
  38579. coords[pIndex + 2] = coordsMap[ps[offset - cols]];
  38580. coords[pIndex + 3] = coordsMap[ps[offset - cols] + 1];
  38581. coords[pIndex + 4] = coordsMap[ps[offset - 1]];
  38582. coords[pIndex + 5] = coordsMap[ps[offset - 1] + 1];
  38583. colors[cIndex] = colorsMap[cs[offset - cols - 1]];
  38584. colors[cIndex + 1] = colorsMap[cs[offset - cols - 1] + 1];
  38585. colors[cIndex + 2] = colorsMap[cs[offset - cols - 1] + 2];
  38586. colors[cIndex + 3] = colorsMap[cs[offset - cols]];
  38587. colors[cIndex + 4] = colorsMap[cs[offset - cols] + 1];
  38588. colors[cIndex + 5] = colorsMap[cs[offset - cols] + 2];
  38589. colors[cIndex + 6] = colorsMap[cs[offset - 1]];
  38590. colors[cIndex + 7] = colorsMap[cs[offset - 1] + 1];
  38591. colors[cIndex + 8] = colorsMap[cs[offset - 1] + 2];
  38592. coords[pIndex + 6] = coords[pIndex + 2];
  38593. coords[pIndex + 7] = coords[pIndex + 3];
  38594. coords[pIndex + 8] = coords[pIndex + 4];
  38595. coords[pIndex + 9] = coords[pIndex + 5];
  38596. coords[pIndex + 10] = coordsMap[ps[offset]];
  38597. coords[pIndex + 11] = coordsMap[ps[offset] + 1];
  38598. colors[cIndex + 9] = colors[cIndex + 3];
  38599. colors[cIndex + 10] = colors[cIndex + 4];
  38600. colors[cIndex + 11] = colors[cIndex + 5];
  38601. colors[cIndex + 12] = colors[cIndex + 6];
  38602. colors[cIndex + 13] = colors[cIndex + 7];
  38603. colors[cIndex + 14] = colors[cIndex + 8];
  38604. colors[cIndex + 15] = colorsMap[cs[offset]];
  38605. colors[cIndex + 16] = colorsMap[cs[offset] + 1];
  38606. colors[cIndex + 17] = colorsMap[cs[offset] + 2];
  38607. pIndex += 12;
  38608. cIndex += 18;
  38609. }
  38610. }
  38611. break;
  38612. case 'triangles':
  38613. for (var j = 0, jj = ps.length; j < jj; j++) {
  38614. coords[pIndex] = coordsMap[ps[j]];
  38615. coords[pIndex + 1] = coordsMap[ps[j] + 1];
  38616. colors[cIndex] = colorsMap[cs[j]];
  38617. colors[cIndex + 1] = colorsMap[cs[j] + 1];
  38618. colors[cIndex + 2] = colorsMap[cs[j] + 2];
  38619. pIndex += 2;
  38620. cIndex += 3;
  38621. }
  38622. break;
  38623. }
  38624. }
  38625. if (backgroundColor) {
  38626. gl.clearColor(backgroundColor[0] / 255, backgroundColor[1] / 255, backgroundColor[2] / 255, 1.0);
  38627. } else {
  38628. gl.clearColor(0, 0, 0, 0);
  38629. }
  38630. gl.clear(gl.COLOR_BUFFER_BIT);
  38631. var coordsBuffer = gl.createBuffer();
  38632. gl.bindBuffer(gl.ARRAY_BUFFER, coordsBuffer);
  38633. gl.bufferData(gl.ARRAY_BUFFER, coords, gl.STATIC_DRAW);
  38634. gl.enableVertexAttribArray(cache.positionLocation);
  38635. gl.vertexAttribPointer(cache.positionLocation, 2, gl.FLOAT, false, 0, 0);
  38636. var colorsBuffer = gl.createBuffer();
  38637. gl.bindBuffer(gl.ARRAY_BUFFER, colorsBuffer);
  38638. gl.bufferData(gl.ARRAY_BUFFER, colors, gl.STATIC_DRAW);
  38639. gl.enableVertexAttribArray(cache.colorLocation);
  38640. gl.vertexAttribPointer(cache.colorLocation, 3, gl.UNSIGNED_BYTE, false, 0, 0);
  38641. gl.uniform2f(cache.scaleLocation, context.scaleX, context.scaleY);
  38642. gl.uniform2f(cache.offsetLocation, context.offsetX, context.offsetY);
  38643. gl.drawArrays(gl.TRIANGLES, 0, count);
  38644. gl.flush();
  38645. gl.deleteBuffer(coordsBuffer);
  38646. gl.deleteBuffer(colorsBuffer);
  38647. return canvas;
  38648. }
  38649. function cleanup() {
  38650. if (smaskCache && smaskCache.canvas) {
  38651. smaskCache.canvas.width = 0;
  38652. smaskCache.canvas.height = 0;
  38653. }
  38654. if (figuresCache && figuresCache.canvas) {
  38655. figuresCache.canvas.width = 0;
  38656. figuresCache.canvas.height = 0;
  38657. }
  38658. smaskCache = null;
  38659. figuresCache = null;
  38660. }
  38661. return {
  38662. get isEnabled() {
  38663. if (getDefaultSetting('disableWebGL')) {
  38664. return false;
  38665. }
  38666. var enabled = false;
  38667. try {
  38668. generateGL();
  38669. enabled = !!currentGL;
  38670. } catch (e) {
  38671. }
  38672. return shadow(this, 'isEnabled', enabled);
  38673. },
  38674. composeSMask: composeSMask,
  38675. drawFigures: drawFigures,
  38676. clear: cleanup
  38677. };
  38678. }();
  38679. exports.WebGLUtils = WebGLUtils;
  38680. /***/ }),
  38681. /* 26 */
  38682. /***/ (function(module, exports, __w_pdfjs_require__) {
  38683. "use strict";
  38684. var sharedUtil = __w_pdfjs_require__(0);
  38685. var displayDOMUtils = __w_pdfjs_require__(3);
  38686. var displayAPI = __w_pdfjs_require__(10);
  38687. var displayAnnotationLayer = __w_pdfjs_require__(9);
  38688. var displayTextLayer = __w_pdfjs_require__(12);
  38689. var displayMetadata = __w_pdfjs_require__(24);
  38690. var displaySVG = __w_pdfjs_require__(11);
  38691. var globalScope = sharedUtil.globalScope;
  38692. var deprecated = sharedUtil.deprecated;
  38693. var warn = sharedUtil.warn;
  38694. var LinkTarget = displayDOMUtils.LinkTarget;
  38695. var DEFAULT_LINK_REL = displayDOMUtils.DEFAULT_LINK_REL;
  38696. var isWorker = typeof window === 'undefined';
  38697. if (!globalScope.PDFJS) {
  38698. globalScope.PDFJS = {};
  38699. }
  38700. var PDFJS = globalScope.PDFJS;
  38701. PDFJS.version = '1.7.374';
  38702. PDFJS.build = 'cfc45e55';
  38703. PDFJS.pdfBug = false;
  38704. if (PDFJS.verbosity !== undefined) {
  38705. sharedUtil.setVerbosityLevel(PDFJS.verbosity);
  38706. }
  38707. delete PDFJS.verbosity;
  38708. Object.defineProperty(PDFJS, 'verbosity', {
  38709. get: function () {
  38710. return sharedUtil.getVerbosityLevel();
  38711. },
  38712. set: function (level) {
  38713. sharedUtil.setVerbosityLevel(level);
  38714. },
  38715. enumerable: true,
  38716. configurable: true
  38717. });
  38718. PDFJS.VERBOSITY_LEVELS = sharedUtil.VERBOSITY_LEVELS;
  38719. PDFJS.OPS = sharedUtil.OPS;
  38720. PDFJS.UNSUPPORTED_FEATURES = sharedUtil.UNSUPPORTED_FEATURES;
  38721. PDFJS.isValidUrl = displayDOMUtils.isValidUrl;
  38722. PDFJS.shadow = sharedUtil.shadow;
  38723. PDFJS.createBlob = sharedUtil.createBlob;
  38724. PDFJS.createObjectURL = function PDFJS_createObjectURL(data, contentType) {
  38725. return sharedUtil.createObjectURL(data, contentType, PDFJS.disableCreateObjectURL);
  38726. };
  38727. Object.defineProperty(PDFJS, 'isLittleEndian', {
  38728. configurable: true,
  38729. get: function PDFJS_isLittleEndian() {
  38730. var value = sharedUtil.isLittleEndian();
  38731. return sharedUtil.shadow(PDFJS, 'isLittleEndian', value);
  38732. }
  38733. });
  38734. PDFJS.removeNullCharacters = sharedUtil.removeNullCharacters;
  38735. PDFJS.PasswordResponses = sharedUtil.PasswordResponses;
  38736. PDFJS.PasswordException = sharedUtil.PasswordException;
  38737. PDFJS.UnknownErrorException = sharedUtil.UnknownErrorException;
  38738. PDFJS.InvalidPDFException = sharedUtil.InvalidPDFException;
  38739. PDFJS.MissingPDFException = sharedUtil.MissingPDFException;
  38740. PDFJS.UnexpectedResponseException = sharedUtil.UnexpectedResponseException;
  38741. PDFJS.Util = sharedUtil.Util;
  38742. PDFJS.PageViewport = sharedUtil.PageViewport;
  38743. PDFJS.createPromiseCapability = sharedUtil.createPromiseCapability;
  38744. PDFJS.maxImageSize = PDFJS.maxImageSize === undefined ? -1 : PDFJS.maxImageSize;
  38745. PDFJS.cMapUrl = PDFJS.cMapUrl === undefined ? null : PDFJS.cMapUrl;
  38746. PDFJS.cMapPacked = PDFJS.cMapPacked === undefined ? false : PDFJS.cMapPacked;
  38747. PDFJS.disableFontFace = PDFJS.disableFontFace === undefined ? false : PDFJS.disableFontFace;
  38748. PDFJS.imageResourcesPath = PDFJS.imageResourcesPath === undefined ? '' : PDFJS.imageResourcesPath;
  38749. PDFJS.disableWorker = PDFJS.disableWorker === undefined ? false : PDFJS.disableWorker;
  38750. PDFJS.workerSrc = PDFJS.workerSrc === undefined ? null : PDFJS.workerSrc;
  38751. PDFJS.workerPort = PDFJS.workerPort === undefined ? null : PDFJS.workerPort;
  38752. PDFJS.disableRange = PDFJS.disableRange === undefined ? false : PDFJS.disableRange;
  38753. PDFJS.disableStream = PDFJS.disableStream === undefined ? false : PDFJS.disableStream;
  38754. PDFJS.disableAutoFetch = PDFJS.disableAutoFetch === undefined ? false : PDFJS.disableAutoFetch;
  38755. PDFJS.pdfBug = PDFJS.pdfBug === undefined ? false : PDFJS.pdfBug;
  38756. PDFJS.postMessageTransfers = PDFJS.postMessageTransfers === undefined ? true : PDFJS.postMessageTransfers;
  38757. PDFJS.disableCreateObjectURL = PDFJS.disableCreateObjectURL === undefined ? false : PDFJS.disableCreateObjectURL;
  38758. PDFJS.disableWebGL = PDFJS.disableWebGL === undefined ? true : PDFJS.disableWebGL;
  38759. PDFJS.externalLinkTarget = PDFJS.externalLinkTarget === undefined ? LinkTarget.NONE : PDFJS.externalLinkTarget;
  38760. PDFJS.externalLinkRel = PDFJS.externalLinkRel === undefined ? DEFAULT_LINK_REL : PDFJS.externalLinkRel;
  38761. PDFJS.isEvalSupported = PDFJS.isEvalSupported === undefined ? true : PDFJS.isEvalSupported;
  38762. var savedOpenExternalLinksInNewWindow = PDFJS.openExternalLinksInNewWindow;
  38763. delete PDFJS.openExternalLinksInNewWindow;
  38764. Object.defineProperty(PDFJS, 'openExternalLinksInNewWindow', {
  38765. get: function () {
  38766. return PDFJS.externalLinkTarget === LinkTarget.BLANK;
  38767. },
  38768. set: function (value) {
  38769. if (value) {
  38770. deprecated('PDFJS.openExternalLinksInNewWindow, please use ' + '"PDFJS.externalLinkTarget = PDFJS.LinkTarget.BLANK" instead.');
  38771. }
  38772. if (PDFJS.externalLinkTarget !== LinkTarget.NONE) {
  38773. warn('PDFJS.externalLinkTarget is already initialized');
  38774. return;
  38775. }
  38776. PDFJS.externalLinkTarget = value ? LinkTarget.BLANK : LinkTarget.NONE;
  38777. },
  38778. enumerable: true,
  38779. configurable: true
  38780. });
  38781. if (savedOpenExternalLinksInNewWindow) {
  38782. PDFJS.openExternalLinksInNewWindow = savedOpenExternalLinksInNewWindow;
  38783. }
  38784. PDFJS.getDocument = displayAPI.getDocument;
  38785. PDFJS.PDFDataRangeTransport = displayAPI.PDFDataRangeTransport;
  38786. PDFJS.PDFWorker = displayAPI.PDFWorker;
  38787. Object.defineProperty(PDFJS, 'hasCanvasTypedArrays', {
  38788. configurable: true,
  38789. get: function PDFJS_hasCanvasTypedArrays() {
  38790. var value = displayDOMUtils.hasCanvasTypedArrays();
  38791. return sharedUtil.shadow(PDFJS, 'hasCanvasTypedArrays', value);
  38792. }
  38793. });
  38794. PDFJS.CustomStyle = displayDOMUtils.CustomStyle;
  38795. PDFJS.LinkTarget = LinkTarget;
  38796. PDFJS.addLinkAttributes = displayDOMUtils.addLinkAttributes;
  38797. PDFJS.getFilenameFromUrl = displayDOMUtils.getFilenameFromUrl;
  38798. PDFJS.isExternalLinkTargetSet = displayDOMUtils.isExternalLinkTargetSet;
  38799. PDFJS.AnnotationLayer = displayAnnotationLayer.AnnotationLayer;
  38800. PDFJS.renderTextLayer = displayTextLayer.renderTextLayer;
  38801. PDFJS.Metadata = displayMetadata.Metadata;
  38802. PDFJS.SVGGraphics = displaySVG.SVGGraphics;
  38803. PDFJS.UnsupportedManager = displayAPI._UnsupportedManager;
  38804. exports.globalScope = globalScope;
  38805. exports.isWorker = isWorker;
  38806. exports.PDFJS = globalScope.PDFJS;
  38807. /***/ }),
  38808. /* 27 */
  38809. /***/ (function(module, exports, __w_pdfjs_require__) {
  38810. "use strict";
  38811. var sharedUtil = __w_pdfjs_require__(0);
  38812. var corePrimitives = __w_pdfjs_require__(1);
  38813. var coreStream = __w_pdfjs_require__(2);
  38814. var coreColorSpace = __w_pdfjs_require__(4);
  38815. var coreObj = __w_pdfjs_require__(20);
  38816. var coreEvaluator = __w_pdfjs_require__(18);
  38817. var AnnotationBorderStyleType = sharedUtil.AnnotationBorderStyleType;
  38818. var AnnotationFieldFlag = sharedUtil.AnnotationFieldFlag;
  38819. var AnnotationFlag = sharedUtil.AnnotationFlag;
  38820. var AnnotationType = sharedUtil.AnnotationType;
  38821. var OPS = sharedUtil.OPS;
  38822. var Util = sharedUtil.Util;
  38823. var isArray = sharedUtil.isArray;
  38824. var isInt = sharedUtil.isInt;
  38825. var stringToBytes = sharedUtil.stringToBytes;
  38826. var stringToPDFString = sharedUtil.stringToPDFString;
  38827. var warn = sharedUtil.warn;
  38828. var Dict = corePrimitives.Dict;
  38829. var isDict = corePrimitives.isDict;
  38830. var isName = corePrimitives.isName;
  38831. var isRef = corePrimitives.isRef;
  38832. var isStream = corePrimitives.isStream;
  38833. var Stream = coreStream.Stream;
  38834. var ColorSpace = coreColorSpace.ColorSpace;
  38835. var Catalog = coreObj.Catalog;
  38836. var ObjectLoader = coreObj.ObjectLoader;
  38837. var FileSpec = coreObj.FileSpec;
  38838. var OperatorList = coreEvaluator.OperatorList;
  38839. function AnnotationFactory() {
  38840. }
  38841. AnnotationFactory.prototype = {
  38842. create: function AnnotationFactory_create(xref, ref, pdfManager, idFactory) {
  38843. var dict = xref.fetchIfRef(ref);
  38844. if (!isDict(dict)) {
  38845. return;
  38846. }
  38847. var id = isRef(ref) ? ref.toString() : 'annot_' + idFactory.createObjId();
  38848. var subtype = dict.get('Subtype');
  38849. subtype = isName(subtype) ? subtype.name : null;
  38850. var parameters = {
  38851. xref: xref,
  38852. dict: dict,
  38853. ref: isRef(ref) ? ref : null,
  38854. subtype: subtype,
  38855. id: id,
  38856. pdfManager: pdfManager
  38857. };
  38858. switch (subtype) {
  38859. case 'Link':
  38860. return new LinkAnnotation(parameters);
  38861. case 'Text':
  38862. return new TextAnnotation(parameters);
  38863. case 'Widget':
  38864. var fieldType = Util.getInheritableProperty(dict, 'FT');
  38865. fieldType = isName(fieldType) ? fieldType.name : null;
  38866. switch (fieldType) {
  38867. case 'Tx':
  38868. return new TextWidgetAnnotation(parameters);
  38869. case 'Btn':
  38870. return new ButtonWidgetAnnotation(parameters);
  38871. case 'Ch':
  38872. return new ChoiceWidgetAnnotation(parameters);
  38873. }
  38874. warn('Unimplemented widget field type "' + fieldType + '", ' + 'falling back to base field type.');
  38875. return new WidgetAnnotation(parameters);
  38876. case 'Popup':
  38877. return new PopupAnnotation(parameters);
  38878. case 'Highlight':
  38879. return new HighlightAnnotation(parameters);
  38880. case 'Underline':
  38881. return new UnderlineAnnotation(parameters);
  38882. case 'Squiggly':
  38883. return new SquigglyAnnotation(parameters);
  38884. case 'StrikeOut':
  38885. return new StrikeOutAnnotation(parameters);
  38886. case 'FileAttachment':
  38887. return new FileAttachmentAnnotation(parameters);
  38888. default:
  38889. if (!subtype) {
  38890. warn('Annotation is missing the required /Subtype.');
  38891. } else {
  38892. warn('Unimplemented annotation type "' + subtype + '", ' + 'falling back to base annotation.');
  38893. }
  38894. return new Annotation(parameters);
  38895. }
  38896. }
  38897. };
  38898. var Annotation = function AnnotationClosure() {
  38899. function getTransformMatrix(rect, bbox, matrix) {
  38900. var bounds = Util.getAxialAlignedBoundingBox(bbox, matrix);
  38901. var minX = bounds[0];
  38902. var minY = bounds[1];
  38903. var maxX = bounds[2];
  38904. var maxY = bounds[3];
  38905. if (minX === maxX || minY === maxY) {
  38906. return [
  38907. 1,
  38908. 0,
  38909. 0,
  38910. 1,
  38911. rect[0],
  38912. rect[1]
  38913. ];
  38914. }
  38915. var xRatio = (rect[2] - rect[0]) / (maxX - minX);
  38916. var yRatio = (rect[3] - rect[1]) / (maxY - minY);
  38917. return [
  38918. xRatio,
  38919. 0,
  38920. 0,
  38921. yRatio,
  38922. rect[0] - minX * xRatio,
  38923. rect[1] - minY * yRatio
  38924. ];
  38925. }
  38926. function Annotation(params) {
  38927. var dict = params.dict;
  38928. this.setFlags(dict.get('F'));
  38929. this.setRectangle(dict.getArray('Rect'));
  38930. this.setColor(dict.getArray('C'));
  38931. this.setBorderStyle(dict);
  38932. this.setAppearance(dict);
  38933. this.data = {};
  38934. this.data.id = params.id;
  38935. this.data.subtype = params.subtype;
  38936. this.data.annotationFlags = this.flags;
  38937. this.data.rect = this.rectangle;
  38938. this.data.color = this.color;
  38939. this.data.borderStyle = this.borderStyle;
  38940. this.data.hasAppearance = !!this.appearance;
  38941. }
  38942. Annotation.prototype = {
  38943. _hasFlag: function Annotation_hasFlag(flags, flag) {
  38944. return !!(flags & flag);
  38945. },
  38946. _isViewable: function Annotation_isViewable(flags) {
  38947. return !this._hasFlag(flags, AnnotationFlag.INVISIBLE) && !this._hasFlag(flags, AnnotationFlag.HIDDEN) && !this._hasFlag(flags, AnnotationFlag.NOVIEW);
  38948. },
  38949. _isPrintable: function AnnotationFlag_isPrintable(flags) {
  38950. return this._hasFlag(flags, AnnotationFlag.PRINT) && !this._hasFlag(flags, AnnotationFlag.INVISIBLE) && !this._hasFlag(flags, AnnotationFlag.HIDDEN);
  38951. },
  38952. get viewable() {
  38953. if (this.flags === 0) {
  38954. return true;
  38955. }
  38956. return this._isViewable(this.flags);
  38957. },
  38958. get printable() {
  38959. if (this.flags === 0) {
  38960. return false;
  38961. }
  38962. return this._isPrintable(this.flags);
  38963. },
  38964. setFlags: function Annotation_setFlags(flags) {
  38965. this.flags = isInt(flags) && flags > 0 ? flags : 0;
  38966. },
  38967. hasFlag: function Annotation_hasFlag(flag) {
  38968. return this._hasFlag(this.flags, flag);
  38969. },
  38970. setRectangle: function Annotation_setRectangle(rectangle) {
  38971. if (isArray(rectangle) && rectangle.length === 4) {
  38972. this.rectangle = Util.normalizeRect(rectangle);
  38973. } else {
  38974. this.rectangle = [
  38975. 0,
  38976. 0,
  38977. 0,
  38978. 0
  38979. ];
  38980. }
  38981. },
  38982. setColor: function Annotation_setColor(color) {
  38983. var rgbColor = new Uint8Array(3);
  38984. if (!isArray(color)) {
  38985. this.color = rgbColor;
  38986. return;
  38987. }
  38988. switch (color.length) {
  38989. case 0:
  38990. this.color = null;
  38991. break;
  38992. case 1:
  38993. ColorSpace.singletons.gray.getRgbItem(color, 0, rgbColor, 0);
  38994. this.color = rgbColor;
  38995. break;
  38996. case 3:
  38997. ColorSpace.singletons.rgb.getRgbItem(color, 0, rgbColor, 0);
  38998. this.color = rgbColor;
  38999. break;
  39000. case 4:
  39001. ColorSpace.singletons.cmyk.getRgbItem(color, 0, rgbColor, 0);
  39002. this.color = rgbColor;
  39003. break;
  39004. default:
  39005. this.color = rgbColor;
  39006. break;
  39007. }
  39008. },
  39009. setBorderStyle: function Annotation_setBorderStyle(borderStyle) {
  39010. this.borderStyle = new AnnotationBorderStyle();
  39011. if (!isDict(borderStyle)) {
  39012. return;
  39013. }
  39014. if (borderStyle.has('BS')) {
  39015. var dict = borderStyle.get('BS');
  39016. var dictType = dict.get('Type');
  39017. if (!dictType || isName(dictType, 'Border')) {
  39018. this.borderStyle.setWidth(dict.get('W'));
  39019. this.borderStyle.setStyle(dict.get('S'));
  39020. this.borderStyle.setDashArray(dict.getArray('D'));
  39021. }
  39022. } else if (borderStyle.has('Border')) {
  39023. var array = borderStyle.getArray('Border');
  39024. if (isArray(array) && array.length >= 3) {
  39025. this.borderStyle.setHorizontalCornerRadius(array[0]);
  39026. this.borderStyle.setVerticalCornerRadius(array[1]);
  39027. this.borderStyle.setWidth(array[2]);
  39028. if (array.length === 4) {
  39029. this.borderStyle.setDashArray(array[3]);
  39030. }
  39031. }
  39032. } else {
  39033. this.borderStyle.setWidth(0);
  39034. }
  39035. },
  39036. setAppearance: function Annotation_setAppearance(dict) {
  39037. this.appearance = null;
  39038. var appearanceStates = dict.get('AP');
  39039. if (!isDict(appearanceStates)) {
  39040. return;
  39041. }
  39042. var normalAppearanceState = appearanceStates.get('N');
  39043. if (isStream(normalAppearanceState)) {
  39044. this.appearance = normalAppearanceState;
  39045. return;
  39046. }
  39047. if (!isDict(normalAppearanceState)) {
  39048. return;
  39049. }
  39050. var as = dict.get('AS');
  39051. if (!isName(as) || !normalAppearanceState.has(as.name)) {
  39052. return;
  39053. }
  39054. this.appearance = normalAppearanceState.get(as.name);
  39055. },
  39056. _preparePopup: function Annotation_preparePopup(dict) {
  39057. if (!dict.has('C')) {
  39058. this.data.color = null;
  39059. }
  39060. this.data.hasPopup = dict.has('Popup');
  39061. this.data.title = stringToPDFString(dict.get('T') || '');
  39062. this.data.contents = stringToPDFString(dict.get('Contents') || '');
  39063. },
  39064. loadResources: function Annotation_loadResources(keys) {
  39065. return new Promise(function (resolve, reject) {
  39066. this.appearance.dict.getAsync('Resources').then(function (resources) {
  39067. if (!resources) {
  39068. resolve();
  39069. return;
  39070. }
  39071. var objectLoader = new ObjectLoader(resources.map, keys, resources.xref);
  39072. objectLoader.load().then(function () {
  39073. resolve(resources);
  39074. }, reject);
  39075. }, reject);
  39076. }.bind(this));
  39077. },
  39078. getOperatorList: function Annotation_getOperatorList(evaluator, task, renderForms) {
  39079. if (!this.appearance) {
  39080. return Promise.resolve(new OperatorList());
  39081. }
  39082. var data = this.data;
  39083. var appearanceDict = this.appearance.dict;
  39084. var resourcesPromise = this.loadResources([
  39085. 'ExtGState',
  39086. 'ColorSpace',
  39087. 'Pattern',
  39088. 'Shading',
  39089. 'XObject',
  39090. 'Font'
  39091. ]);
  39092. var bbox = appearanceDict.getArray('BBox') || [
  39093. 0,
  39094. 0,
  39095. 1,
  39096. 1
  39097. ];
  39098. var matrix = appearanceDict.getArray('Matrix') || [
  39099. 1,
  39100. 0,
  39101. 0,
  39102. 1,
  39103. 0,
  39104. 0
  39105. ];
  39106. var transform = getTransformMatrix(data.rect, bbox, matrix);
  39107. var self = this;
  39108. return resourcesPromise.then(function (resources) {
  39109. var opList = new OperatorList();
  39110. opList.addOp(OPS.beginAnnotation, [
  39111. data.rect,
  39112. transform,
  39113. matrix
  39114. ]);
  39115. return evaluator.getOperatorList(self.appearance, task, resources, opList).then(function () {
  39116. opList.addOp(OPS.endAnnotation, []);
  39117. self.appearance.reset();
  39118. return opList;
  39119. });
  39120. });
  39121. }
  39122. };
  39123. return Annotation;
  39124. }();
  39125. var AnnotationBorderStyle = function AnnotationBorderStyleClosure() {
  39126. function AnnotationBorderStyle() {
  39127. this.width = 1;
  39128. this.style = AnnotationBorderStyleType.SOLID;
  39129. this.dashArray = [3];
  39130. this.horizontalCornerRadius = 0;
  39131. this.verticalCornerRadius = 0;
  39132. }
  39133. AnnotationBorderStyle.prototype = {
  39134. setWidth: function AnnotationBorderStyle_setWidth(width) {
  39135. if (width === (width | 0)) {
  39136. this.width = width;
  39137. }
  39138. },
  39139. setStyle: function AnnotationBorderStyle_setStyle(style) {
  39140. if (!style) {
  39141. return;
  39142. }
  39143. switch (style.name) {
  39144. case 'S':
  39145. this.style = AnnotationBorderStyleType.SOLID;
  39146. break;
  39147. case 'D':
  39148. this.style = AnnotationBorderStyleType.DASHED;
  39149. break;
  39150. case 'B':
  39151. this.style = AnnotationBorderStyleType.BEVELED;
  39152. break;
  39153. case 'I':
  39154. this.style = AnnotationBorderStyleType.INSET;
  39155. break;
  39156. case 'U':
  39157. this.style = AnnotationBorderStyleType.UNDERLINE;
  39158. break;
  39159. default:
  39160. break;
  39161. }
  39162. },
  39163. setDashArray: function AnnotationBorderStyle_setDashArray(dashArray) {
  39164. if (isArray(dashArray) && dashArray.length > 0) {
  39165. var isValid = true;
  39166. var allZeros = true;
  39167. for (var i = 0, len = dashArray.length; i < len; i++) {
  39168. var element = dashArray[i];
  39169. var validNumber = +element >= 0;
  39170. if (!validNumber) {
  39171. isValid = false;
  39172. break;
  39173. } else if (element > 0) {
  39174. allZeros = false;
  39175. }
  39176. }
  39177. if (isValid && !allZeros) {
  39178. this.dashArray = dashArray;
  39179. } else {
  39180. this.width = 0;
  39181. }
  39182. } else if (dashArray) {
  39183. this.width = 0;
  39184. }
  39185. },
  39186. setHorizontalCornerRadius: function AnnotationBorderStyle_setHorizontalCornerRadius(radius) {
  39187. if (radius === (radius | 0)) {
  39188. this.horizontalCornerRadius = radius;
  39189. }
  39190. },
  39191. setVerticalCornerRadius: function AnnotationBorderStyle_setVerticalCornerRadius(radius) {
  39192. if (radius === (radius | 0)) {
  39193. this.verticalCornerRadius = radius;
  39194. }
  39195. }
  39196. };
  39197. return AnnotationBorderStyle;
  39198. }();
  39199. var WidgetAnnotation = function WidgetAnnotationClosure() {
  39200. function WidgetAnnotation(params) {
  39201. Annotation.call(this, params);
  39202. var dict = params.dict;
  39203. var data = this.data;
  39204. data.annotationType = AnnotationType.WIDGET;
  39205. data.fieldName = this._constructFieldName(dict);
  39206. data.fieldValue = Util.getInheritableProperty(dict, 'V', true);
  39207. data.alternativeText = stringToPDFString(dict.get('TU') || '');
  39208. data.defaultAppearance = Util.getInheritableProperty(dict, 'DA') || '';
  39209. var fieldType = Util.getInheritableProperty(dict, 'FT');
  39210. data.fieldType = isName(fieldType) ? fieldType.name : null;
  39211. this.fieldResources = Util.getInheritableProperty(dict, 'DR') || Dict.empty;
  39212. data.fieldFlags = Util.getInheritableProperty(dict, 'Ff');
  39213. if (!isInt(data.fieldFlags) || data.fieldFlags < 0) {
  39214. data.fieldFlags = 0;
  39215. }
  39216. data.readOnly = this.hasFieldFlag(AnnotationFieldFlag.READONLY);
  39217. if (data.fieldType === 'Sig') {
  39218. this.setFlags(AnnotationFlag.HIDDEN);
  39219. }
  39220. }
  39221. Util.inherit(WidgetAnnotation, Annotation, {
  39222. _constructFieldName: function WidgetAnnotation_constructFieldName(dict) {
  39223. if (!dict.has('T') && !dict.has('Parent')) {
  39224. warn('Unknown field name, falling back to empty field name.');
  39225. return '';
  39226. }
  39227. if (!dict.has('Parent')) {
  39228. return stringToPDFString(dict.get('T'));
  39229. }
  39230. var fieldName = [];
  39231. if (dict.has('T')) {
  39232. fieldName.unshift(stringToPDFString(dict.get('T')));
  39233. }
  39234. var loopDict = dict;
  39235. while (loopDict.has('Parent')) {
  39236. loopDict = loopDict.get('Parent');
  39237. if (!isDict(loopDict)) {
  39238. break;
  39239. }
  39240. if (loopDict.has('T')) {
  39241. fieldName.unshift(stringToPDFString(loopDict.get('T')));
  39242. }
  39243. }
  39244. return fieldName.join('.');
  39245. },
  39246. hasFieldFlag: function WidgetAnnotation_hasFieldFlag(flag) {
  39247. return !!(this.data.fieldFlags & flag);
  39248. }
  39249. });
  39250. return WidgetAnnotation;
  39251. }();
  39252. var TextWidgetAnnotation = function TextWidgetAnnotationClosure() {
  39253. function TextWidgetAnnotation(params) {
  39254. WidgetAnnotation.call(this, params);
  39255. this.data.fieldValue = stringToPDFString(this.data.fieldValue || '');
  39256. var alignment = Util.getInheritableProperty(params.dict, 'Q');
  39257. if (!isInt(alignment) || alignment < 0 || alignment > 2) {
  39258. alignment = null;
  39259. }
  39260. this.data.textAlignment = alignment;
  39261. var maximumLength = Util.getInheritableProperty(params.dict, 'MaxLen');
  39262. if (!isInt(maximumLength) || maximumLength < 0) {
  39263. maximumLength = null;
  39264. }
  39265. this.data.maxLen = maximumLength;
  39266. this.data.multiLine = this.hasFieldFlag(AnnotationFieldFlag.MULTILINE);
  39267. this.data.comb = this.hasFieldFlag(AnnotationFieldFlag.COMB) && !this.hasFieldFlag(AnnotationFieldFlag.MULTILINE) && !this.hasFieldFlag(AnnotationFieldFlag.PASSWORD) && !this.hasFieldFlag(AnnotationFieldFlag.FILESELECT) && this.data.maxLen !== null;
  39268. }
  39269. Util.inherit(TextWidgetAnnotation, WidgetAnnotation, {
  39270. getOperatorList: function TextWidgetAnnotation_getOperatorList(evaluator, task, renderForms) {
  39271. var operatorList = new OperatorList();
  39272. if (renderForms) {
  39273. return Promise.resolve(operatorList);
  39274. }
  39275. if (this.appearance) {
  39276. return Annotation.prototype.getOperatorList.call(this, evaluator, task, renderForms);
  39277. }
  39278. if (!this.data.defaultAppearance) {
  39279. return Promise.resolve(operatorList);
  39280. }
  39281. var stream = new Stream(stringToBytes(this.data.defaultAppearance));
  39282. return evaluator.getOperatorList(stream, task, this.fieldResources, operatorList).then(function () {
  39283. return operatorList;
  39284. });
  39285. }
  39286. });
  39287. return TextWidgetAnnotation;
  39288. }();
  39289. var ButtonWidgetAnnotation = function ButtonWidgetAnnotationClosure() {
  39290. function ButtonWidgetAnnotation(params) {
  39291. WidgetAnnotation.call(this, params);
  39292. this.data.checkBox = !this.hasFieldFlag(AnnotationFieldFlag.RADIO) && !this.hasFieldFlag(AnnotationFieldFlag.PUSHBUTTON);
  39293. if (this.data.checkBox) {
  39294. if (!isName(this.data.fieldValue)) {
  39295. return;
  39296. }
  39297. this.data.fieldValue = this.data.fieldValue.name;
  39298. }
  39299. this.data.radioButton = this.hasFieldFlag(AnnotationFieldFlag.RADIO) && !this.hasFieldFlag(AnnotationFieldFlag.PUSHBUTTON);
  39300. if (this.data.radioButton) {
  39301. this.data.fieldValue = this.data.buttonValue = null;
  39302. var fieldParent = params.dict.get('Parent');
  39303. if (isDict(fieldParent) && fieldParent.has('V')) {
  39304. var fieldParentValue = fieldParent.get('V');
  39305. if (isName(fieldParentValue)) {
  39306. this.data.fieldValue = fieldParentValue.name;
  39307. }
  39308. }
  39309. var appearanceStates = params.dict.get('AP');
  39310. if (!isDict(appearanceStates)) {
  39311. return;
  39312. }
  39313. var normalAppearanceState = appearanceStates.get('N');
  39314. if (!isDict(normalAppearanceState)) {
  39315. return;
  39316. }
  39317. var keys = normalAppearanceState.getKeys();
  39318. for (var i = 0, ii = keys.length; i < ii; i++) {
  39319. if (keys[i] !== 'Off') {
  39320. this.data.buttonValue = keys[i];
  39321. break;
  39322. }
  39323. }
  39324. }
  39325. }
  39326. Util.inherit(ButtonWidgetAnnotation, WidgetAnnotation, {
  39327. getOperatorList: function ButtonWidgetAnnotation_getOperatorList(evaluator, task, renderForms) {
  39328. var operatorList = new OperatorList();
  39329. if (renderForms) {
  39330. return Promise.resolve(operatorList);
  39331. }
  39332. if (this.appearance) {
  39333. return Annotation.prototype.getOperatorList.call(this, evaluator, task, renderForms);
  39334. }
  39335. return Promise.resolve(operatorList);
  39336. }
  39337. });
  39338. return ButtonWidgetAnnotation;
  39339. }();
  39340. var ChoiceWidgetAnnotation = function ChoiceWidgetAnnotationClosure() {
  39341. function ChoiceWidgetAnnotation(params) {
  39342. WidgetAnnotation.call(this, params);
  39343. this.data.options = [];
  39344. var options = Util.getInheritableProperty(params.dict, 'Opt');
  39345. if (isArray(options)) {
  39346. var xref = params.xref;
  39347. for (var i = 0, ii = options.length; i < ii; i++) {
  39348. var option = xref.fetchIfRef(options[i]);
  39349. var isOptionArray = isArray(option);
  39350. this.data.options[i] = {
  39351. exportValue: isOptionArray ? xref.fetchIfRef(option[0]) : option,
  39352. displayValue: isOptionArray ? xref.fetchIfRef(option[1]) : option
  39353. };
  39354. }
  39355. }
  39356. if (!isArray(this.data.fieldValue)) {
  39357. this.data.fieldValue = [this.data.fieldValue];
  39358. }
  39359. this.data.combo = this.hasFieldFlag(AnnotationFieldFlag.COMBO);
  39360. this.data.multiSelect = this.hasFieldFlag(AnnotationFieldFlag.MULTISELECT);
  39361. }
  39362. Util.inherit(ChoiceWidgetAnnotation, WidgetAnnotation, {
  39363. getOperatorList: function ChoiceWidgetAnnotation_getOperatorList(evaluator, task, renderForms) {
  39364. var operatorList = new OperatorList();
  39365. if (renderForms) {
  39366. return Promise.resolve(operatorList);
  39367. }
  39368. return Annotation.prototype.getOperatorList.call(this, evaluator, task, renderForms);
  39369. }
  39370. });
  39371. return ChoiceWidgetAnnotation;
  39372. }();
  39373. var TextAnnotation = function TextAnnotationClosure() {
  39374. var DEFAULT_ICON_SIZE = 22;
  39375. function TextAnnotation(parameters) {
  39376. Annotation.call(this, parameters);
  39377. this.data.annotationType = AnnotationType.TEXT;
  39378. if (this.data.hasAppearance) {
  39379. this.data.name = 'NoIcon';
  39380. } else {
  39381. this.data.rect[1] = this.data.rect[3] - DEFAULT_ICON_SIZE;
  39382. this.data.rect[2] = this.data.rect[0] + DEFAULT_ICON_SIZE;
  39383. this.data.name = parameters.dict.has('Name') ? parameters.dict.get('Name').name : 'Note';
  39384. }
  39385. this._preparePopup(parameters.dict);
  39386. }
  39387. Util.inherit(TextAnnotation, Annotation, {});
  39388. return TextAnnotation;
  39389. }();
  39390. var LinkAnnotation = function LinkAnnotationClosure() {
  39391. function LinkAnnotation(params) {
  39392. Annotation.call(this, params);
  39393. var data = this.data;
  39394. data.annotationType = AnnotationType.LINK;
  39395. Catalog.parseDestDictionary({
  39396. destDict: params.dict,
  39397. resultObj: data,
  39398. docBaseUrl: params.pdfManager.docBaseUrl
  39399. });
  39400. }
  39401. Util.inherit(LinkAnnotation, Annotation, {});
  39402. return LinkAnnotation;
  39403. }();
  39404. var PopupAnnotation = function PopupAnnotationClosure() {
  39405. function PopupAnnotation(parameters) {
  39406. Annotation.call(this, parameters);
  39407. this.data.annotationType = AnnotationType.POPUP;
  39408. var dict = parameters.dict;
  39409. var parentItem = dict.get('Parent');
  39410. if (!parentItem) {
  39411. warn('Popup annotation has a missing or invalid parent annotation.');
  39412. return;
  39413. }
  39414. this.data.parentId = dict.getRaw('Parent').toString();
  39415. this.data.title = stringToPDFString(parentItem.get('T') || '');
  39416. this.data.contents = stringToPDFString(parentItem.get('Contents') || '');
  39417. if (!parentItem.has('C')) {
  39418. this.data.color = null;
  39419. } else {
  39420. this.setColor(parentItem.getArray('C'));
  39421. this.data.color = this.color;
  39422. }
  39423. if (!this.viewable) {
  39424. var parentFlags = parentItem.get('F');
  39425. if (this._isViewable(parentFlags)) {
  39426. this.setFlags(parentFlags);
  39427. }
  39428. }
  39429. }
  39430. Util.inherit(PopupAnnotation, Annotation, {});
  39431. return PopupAnnotation;
  39432. }();
  39433. var HighlightAnnotation = function HighlightAnnotationClosure() {
  39434. function HighlightAnnotation(parameters) {
  39435. Annotation.call(this, parameters);
  39436. this.data.annotationType = AnnotationType.HIGHLIGHT;
  39437. this._preparePopup(parameters.dict);
  39438. this.data.borderStyle.setWidth(0);
  39439. }
  39440. Util.inherit(HighlightAnnotation, Annotation, {});
  39441. return HighlightAnnotation;
  39442. }();
  39443. var UnderlineAnnotation = function UnderlineAnnotationClosure() {
  39444. function UnderlineAnnotation(parameters) {
  39445. Annotation.call(this, parameters);
  39446. this.data.annotationType = AnnotationType.UNDERLINE;
  39447. this._preparePopup(parameters.dict);
  39448. this.data.borderStyle.setWidth(0);
  39449. }
  39450. Util.inherit(UnderlineAnnotation, Annotation, {});
  39451. return UnderlineAnnotation;
  39452. }();
  39453. var SquigglyAnnotation = function SquigglyAnnotationClosure() {
  39454. function SquigglyAnnotation(parameters) {
  39455. Annotation.call(this, parameters);
  39456. this.data.annotationType = AnnotationType.SQUIGGLY;
  39457. this._preparePopup(parameters.dict);
  39458. this.data.borderStyle.setWidth(0);
  39459. }
  39460. Util.inherit(SquigglyAnnotation, Annotation, {});
  39461. return SquigglyAnnotation;
  39462. }();
  39463. var StrikeOutAnnotation = function StrikeOutAnnotationClosure() {
  39464. function StrikeOutAnnotation(parameters) {
  39465. Annotation.call(this, parameters);
  39466. this.data.annotationType = AnnotationType.STRIKEOUT;
  39467. this._preparePopup(parameters.dict);
  39468. this.data.borderStyle.setWidth(0);
  39469. }
  39470. Util.inherit(StrikeOutAnnotation, Annotation, {});
  39471. return StrikeOutAnnotation;
  39472. }();
  39473. var FileAttachmentAnnotation = function FileAttachmentAnnotationClosure() {
  39474. function FileAttachmentAnnotation(parameters) {
  39475. Annotation.call(this, parameters);
  39476. var file = new FileSpec(parameters.dict.get('FS'), parameters.xref);
  39477. this.data.annotationType = AnnotationType.FILEATTACHMENT;
  39478. this.data.file = file.serializable;
  39479. this._preparePopup(parameters.dict);
  39480. }
  39481. Util.inherit(FileAttachmentAnnotation, Annotation, {});
  39482. return FileAttachmentAnnotation;
  39483. }();
  39484. exports.Annotation = Annotation;
  39485. exports.AnnotationBorderStyle = AnnotationBorderStyle;
  39486. exports.AnnotationFactory = AnnotationFactory;
  39487. /***/ }),
  39488. /* 28 */
  39489. /***/ (function(module, exports, __w_pdfjs_require__) {
  39490. "use strict";
  39491. var sharedUtil = __w_pdfjs_require__(0);
  39492. var warn = sharedUtil.warn;
  39493. var baseTypes = [
  39494. 'BN',
  39495. 'BN',
  39496. 'BN',
  39497. 'BN',
  39498. 'BN',
  39499. 'BN',
  39500. 'BN',
  39501. 'BN',
  39502. 'BN',
  39503. 'S',
  39504. 'B',
  39505. 'S',
  39506. 'WS',
  39507. 'B',
  39508. 'BN',
  39509. 'BN',
  39510. 'BN',
  39511. 'BN',
  39512. 'BN',
  39513. 'BN',
  39514. 'BN',
  39515. 'BN',
  39516. 'BN',
  39517. 'BN',
  39518. 'BN',
  39519. 'BN',
  39520. 'BN',
  39521. 'BN',
  39522. 'B',
  39523. 'B',
  39524. 'B',
  39525. 'S',
  39526. 'WS',
  39527. 'ON',
  39528. 'ON',
  39529. 'ET',
  39530. 'ET',
  39531. 'ET',
  39532. 'ON',
  39533. 'ON',
  39534. 'ON',
  39535. 'ON',
  39536. 'ON',
  39537. 'ES',
  39538. 'CS',
  39539. 'ES',
  39540. 'CS',
  39541. 'CS',
  39542. 'EN',
  39543. 'EN',
  39544. 'EN',
  39545. 'EN',
  39546. 'EN',
  39547. 'EN',
  39548. 'EN',
  39549. 'EN',
  39550. 'EN',
  39551. 'EN',
  39552. 'CS',
  39553. 'ON',
  39554. 'ON',
  39555. 'ON',
  39556. 'ON',
  39557. 'ON',
  39558. 'ON',
  39559. 'L',
  39560. 'L',
  39561. 'L',
  39562. 'L',
  39563. 'L',
  39564. 'L',
  39565. 'L',
  39566. 'L',
  39567. 'L',
  39568. 'L',
  39569. 'L',
  39570. 'L',
  39571. 'L',
  39572. 'L',
  39573. 'L',
  39574. 'L',
  39575. 'L',
  39576. 'L',
  39577. 'L',
  39578. 'L',
  39579. 'L',
  39580. 'L',
  39581. 'L',
  39582. 'L',
  39583. 'L',
  39584. 'L',
  39585. 'ON',
  39586. 'ON',
  39587. 'ON',
  39588. 'ON',
  39589. 'ON',
  39590. 'ON',
  39591. 'L',
  39592. 'L',
  39593. 'L',
  39594. 'L',
  39595. 'L',
  39596. 'L',
  39597. 'L',
  39598. 'L',
  39599. 'L',
  39600. 'L',
  39601. 'L',
  39602. 'L',
  39603. 'L',
  39604. 'L',
  39605. 'L',
  39606. 'L',
  39607. 'L',
  39608. 'L',
  39609. 'L',
  39610. 'L',
  39611. 'L',
  39612. 'L',
  39613. 'L',
  39614. 'L',
  39615. 'L',
  39616. 'L',
  39617. 'ON',
  39618. 'ON',
  39619. 'ON',
  39620. 'ON',
  39621. 'BN',
  39622. 'BN',
  39623. 'BN',
  39624. 'BN',
  39625. 'BN',
  39626. 'BN',
  39627. 'B',
  39628. 'BN',
  39629. 'BN',
  39630. 'BN',
  39631. 'BN',
  39632. 'BN',
  39633. 'BN',
  39634. 'BN',
  39635. 'BN',
  39636. 'BN',
  39637. 'BN',
  39638. 'BN',
  39639. 'BN',
  39640. 'BN',
  39641. 'BN',
  39642. 'BN',
  39643. 'BN',
  39644. 'BN',
  39645. 'BN',
  39646. 'BN',
  39647. 'BN',
  39648. 'BN',
  39649. 'BN',
  39650. 'BN',
  39651. 'BN',
  39652. 'BN',
  39653. 'BN',
  39654. 'CS',
  39655. 'ON',
  39656. 'ET',
  39657. 'ET',
  39658. 'ET',
  39659. 'ET',
  39660. 'ON',
  39661. 'ON',
  39662. 'ON',
  39663. 'ON',
  39664. 'L',
  39665. 'ON',
  39666. 'ON',
  39667. 'BN',
  39668. 'ON',
  39669. 'ON',
  39670. 'ET',
  39671. 'ET',
  39672. 'EN',
  39673. 'EN',
  39674. 'ON',
  39675. 'L',
  39676. 'ON',
  39677. 'ON',
  39678. 'ON',
  39679. 'EN',
  39680. 'L',
  39681. 'ON',
  39682. 'ON',
  39683. 'ON',
  39684. 'ON',
  39685. 'ON',
  39686. 'L',
  39687. 'L',
  39688. 'L',
  39689. 'L',
  39690. 'L',
  39691. 'L',
  39692. 'L',
  39693. 'L',
  39694. 'L',
  39695. 'L',
  39696. 'L',
  39697. 'L',
  39698. 'L',
  39699. 'L',
  39700. 'L',
  39701. 'L',
  39702. 'L',
  39703. 'L',
  39704. 'L',
  39705. 'L',
  39706. 'L',
  39707. 'L',
  39708. 'L',
  39709. 'ON',
  39710. 'L',
  39711. 'L',
  39712. 'L',
  39713. 'L',
  39714. 'L',
  39715. 'L',
  39716. 'L',
  39717. 'L',
  39718. 'L',
  39719. 'L',
  39720. 'L',
  39721. 'L',
  39722. 'L',
  39723. 'L',
  39724. 'L',
  39725. 'L',
  39726. 'L',
  39727. 'L',
  39728. 'L',
  39729. 'L',
  39730. 'L',
  39731. 'L',
  39732. 'L',
  39733. 'L',
  39734. 'L',
  39735. 'L',
  39736. 'L',
  39737. 'L',
  39738. 'L',
  39739. 'L',
  39740. 'L',
  39741. 'ON',
  39742. 'L',
  39743. 'L',
  39744. 'L',
  39745. 'L',
  39746. 'L',
  39747. 'L',
  39748. 'L',
  39749. 'L'
  39750. ];
  39751. var arabicTypes = [
  39752. 'AN',
  39753. 'AN',
  39754. 'AN',
  39755. 'AN',
  39756. 'AN',
  39757. 'AN',
  39758. 'ON',
  39759. 'ON',
  39760. 'AL',
  39761. 'ET',
  39762. 'ET',
  39763. 'AL',
  39764. 'CS',
  39765. 'AL',
  39766. 'ON',
  39767. 'ON',
  39768. 'NSM',
  39769. 'NSM',
  39770. 'NSM',
  39771. 'NSM',
  39772. 'NSM',
  39773. 'NSM',
  39774. 'NSM',
  39775. 'NSM',
  39776. 'NSM',
  39777. 'NSM',
  39778. 'NSM',
  39779. 'AL',
  39780. 'AL',
  39781. '',
  39782. 'AL',
  39783. 'AL',
  39784. 'AL',
  39785. 'AL',
  39786. 'AL',
  39787. 'AL',
  39788. 'AL',
  39789. 'AL',
  39790. 'AL',
  39791. 'AL',
  39792. 'AL',
  39793. 'AL',
  39794. 'AL',
  39795. 'AL',
  39796. 'AL',
  39797. 'AL',
  39798. 'AL',
  39799. 'AL',
  39800. 'AL',
  39801. 'AL',
  39802. 'AL',
  39803. 'AL',
  39804. 'AL',
  39805. 'AL',
  39806. 'AL',
  39807. 'AL',
  39808. 'AL',
  39809. 'AL',
  39810. 'AL',
  39811. 'AL',
  39812. 'AL',
  39813. 'AL',
  39814. 'AL',
  39815. 'AL',
  39816. 'AL',
  39817. 'AL',
  39818. 'AL',
  39819. 'AL',
  39820. 'AL',
  39821. 'AL',
  39822. 'AL',
  39823. 'AL',
  39824. 'AL',
  39825. 'AL',
  39826. 'AL',
  39827. 'NSM',
  39828. 'NSM',
  39829. 'NSM',
  39830. 'NSM',
  39831. 'NSM',
  39832. 'NSM',
  39833. 'NSM',
  39834. 'NSM',
  39835. 'NSM',
  39836. 'NSM',
  39837. 'NSM',
  39838. 'NSM',
  39839. 'NSM',
  39840. 'NSM',
  39841. 'NSM',
  39842. 'NSM',
  39843. 'NSM',
  39844. 'NSM',
  39845. 'NSM',
  39846. 'NSM',
  39847. 'NSM',
  39848. 'AN',
  39849. 'AN',
  39850. 'AN',
  39851. 'AN',
  39852. 'AN',
  39853. 'AN',
  39854. 'AN',
  39855. 'AN',
  39856. 'AN',
  39857. 'AN',
  39858. 'ET',
  39859. 'AN',
  39860. 'AN',
  39861. 'AL',
  39862. 'AL',
  39863. 'AL',
  39864. 'NSM',
  39865. 'AL',
  39866. 'AL',
  39867. 'AL',
  39868. 'AL',
  39869. 'AL',
  39870. 'AL',
  39871. 'AL',
  39872. 'AL',
  39873. 'AL',
  39874. 'AL',
  39875. 'AL',
  39876. 'AL',
  39877. 'AL',
  39878. 'AL',
  39879. 'AL',
  39880. 'AL',
  39881. 'AL',
  39882. 'AL',
  39883. 'AL',
  39884. 'AL',
  39885. 'AL',
  39886. 'AL',
  39887. 'AL',
  39888. 'AL',
  39889. 'AL',
  39890. 'AL',
  39891. 'AL',
  39892. 'AL',
  39893. 'AL',
  39894. 'AL',
  39895. 'AL',
  39896. 'AL',
  39897. 'AL',
  39898. 'AL',
  39899. 'AL',
  39900. 'AL',
  39901. 'AL',
  39902. 'AL',
  39903. 'AL',
  39904. 'AL',
  39905. 'AL',
  39906. 'AL',
  39907. 'AL',
  39908. 'AL',
  39909. 'AL',
  39910. 'AL',
  39911. 'AL',
  39912. 'AL',
  39913. 'AL',
  39914. 'AL',
  39915. 'AL',
  39916. 'AL',
  39917. 'AL',
  39918. 'AL',
  39919. 'AL',
  39920. 'AL',
  39921. 'AL',
  39922. 'AL',
  39923. 'AL',
  39924. 'AL',
  39925. 'AL',
  39926. 'AL',
  39927. 'AL',
  39928. 'AL',
  39929. 'AL',
  39930. 'AL',
  39931. 'AL',
  39932. 'AL',
  39933. 'AL',
  39934. 'AL',
  39935. 'AL',
  39936. 'AL',
  39937. 'AL',
  39938. 'AL',
  39939. 'AL',
  39940. 'AL',
  39941. 'AL',
  39942. 'AL',
  39943. 'AL',
  39944. 'AL',
  39945. 'AL',
  39946. 'AL',
  39947. 'AL',
  39948. 'AL',
  39949. 'AL',
  39950. 'AL',
  39951. 'AL',
  39952. 'AL',
  39953. 'AL',
  39954. 'AL',
  39955. 'AL',
  39956. 'AL',
  39957. 'AL',
  39958. 'AL',
  39959. 'AL',
  39960. 'AL',
  39961. 'AL',
  39962. 'AL',
  39963. 'AL',
  39964. 'AL',
  39965. 'AL',
  39966. 'NSM',
  39967. 'NSM',
  39968. 'NSM',
  39969. 'NSM',
  39970. 'NSM',
  39971. 'NSM',
  39972. 'NSM',
  39973. 'AN',
  39974. 'ON',
  39975. 'NSM',
  39976. 'NSM',
  39977. 'NSM',
  39978. 'NSM',
  39979. 'NSM',
  39980. 'NSM',
  39981. 'AL',
  39982. 'AL',
  39983. 'NSM',
  39984. 'NSM',
  39985. 'ON',
  39986. 'NSM',
  39987. 'NSM',
  39988. 'NSM',
  39989. 'NSM',
  39990. 'AL',
  39991. 'AL',
  39992. 'EN',
  39993. 'EN',
  39994. 'EN',
  39995. 'EN',
  39996. 'EN',
  39997. 'EN',
  39998. 'EN',
  39999. 'EN',
  40000. 'EN',
  40001. 'EN',
  40002. 'AL',
  40003. 'AL',
  40004. 'AL',
  40005. 'AL',
  40006. 'AL',
  40007. 'AL'
  40008. ];
  40009. function isOdd(i) {
  40010. return (i & 1) !== 0;
  40011. }
  40012. function isEven(i) {
  40013. return (i & 1) === 0;
  40014. }
  40015. function findUnequal(arr, start, value) {
  40016. for (var j = start, jj = arr.length; j < jj; ++j) {
  40017. if (arr[j] !== value) {
  40018. return j;
  40019. }
  40020. }
  40021. return j;
  40022. }
  40023. function setValues(arr, start, end, value) {
  40024. for (var j = start; j < end; ++j) {
  40025. arr[j] = value;
  40026. }
  40027. }
  40028. function reverseValues(arr, start, end) {
  40029. for (var i = start, j = end - 1; i < j; ++i, --j) {
  40030. var temp = arr[i];
  40031. arr[i] = arr[j];
  40032. arr[j] = temp;
  40033. }
  40034. }
  40035. function createBidiText(str, isLTR, vertical) {
  40036. return {
  40037. str: str,
  40038. dir: vertical ? 'ttb' : isLTR ? 'ltr' : 'rtl'
  40039. };
  40040. }
  40041. var chars = [];
  40042. var types = [];
  40043. function bidi(str, startLevel, vertical) {
  40044. var isLTR = true;
  40045. var strLength = str.length;
  40046. if (strLength === 0 || vertical) {
  40047. return createBidiText(str, isLTR, vertical);
  40048. }
  40049. chars.length = strLength;
  40050. types.length = strLength;
  40051. var numBidi = 0;
  40052. var i, ii;
  40053. for (i = 0; i < strLength; ++i) {
  40054. chars[i] = str.charAt(i);
  40055. var charCode = str.charCodeAt(i);
  40056. var charType = 'L';
  40057. if (charCode <= 0x00ff) {
  40058. charType = baseTypes[charCode];
  40059. } else if (0x0590 <= charCode && charCode <= 0x05f4) {
  40060. charType = 'R';
  40061. } else if (0x0600 <= charCode && charCode <= 0x06ff) {
  40062. charType = arabicTypes[charCode & 0xff];
  40063. if (!charType) {
  40064. warn('Bidi: invalid Unicode character ' + charCode.toString(16));
  40065. }
  40066. } else if (0x0700 <= charCode && charCode <= 0x08AC) {
  40067. charType = 'AL';
  40068. }
  40069. if (charType === 'R' || charType === 'AL' || charType === 'AN') {
  40070. numBidi++;
  40071. }
  40072. types[i] = charType;
  40073. }
  40074. if (numBidi === 0) {
  40075. isLTR = true;
  40076. return createBidiText(str, isLTR);
  40077. }
  40078. if (startLevel === -1) {
  40079. if (numBidi / strLength < 0.3) {
  40080. isLTR = true;
  40081. startLevel = 0;
  40082. } else {
  40083. isLTR = false;
  40084. startLevel = 1;
  40085. }
  40086. }
  40087. var levels = [];
  40088. for (i = 0; i < strLength; ++i) {
  40089. levels[i] = startLevel;
  40090. }
  40091. var e = isOdd(startLevel) ? 'R' : 'L';
  40092. var sor = e;
  40093. var eor = sor;
  40094. var lastType = sor;
  40095. for (i = 0; i < strLength; ++i) {
  40096. if (types[i] === 'NSM') {
  40097. types[i] = lastType;
  40098. } else {
  40099. lastType = types[i];
  40100. }
  40101. }
  40102. lastType = sor;
  40103. var t;
  40104. for (i = 0; i < strLength; ++i) {
  40105. t = types[i];
  40106. if (t === 'EN') {
  40107. types[i] = lastType === 'AL' ? 'AN' : 'EN';
  40108. } else if (t === 'R' || t === 'L' || t === 'AL') {
  40109. lastType = t;
  40110. }
  40111. }
  40112. for (i = 0; i < strLength; ++i) {
  40113. t = types[i];
  40114. if (t === 'AL') {
  40115. types[i] = 'R';
  40116. }
  40117. }
  40118. for (i = 1; i < strLength - 1; ++i) {
  40119. if (types[i] === 'ES' && types[i - 1] === 'EN' && types[i + 1] === 'EN') {
  40120. types[i] = 'EN';
  40121. }
  40122. if (types[i] === 'CS' && (types[i - 1] === 'EN' || types[i - 1] === 'AN') && types[i + 1] === types[i - 1]) {
  40123. types[i] = types[i - 1];
  40124. }
  40125. }
  40126. for (i = 0; i < strLength; ++i) {
  40127. if (types[i] === 'EN') {
  40128. var j;
  40129. for (j = i - 1; j >= 0; --j) {
  40130. if (types[j] !== 'ET') {
  40131. break;
  40132. }
  40133. types[j] = 'EN';
  40134. }
  40135. for (j = i + 1; j < strLength; ++j) {
  40136. if (types[j] !== 'ET') {
  40137. break;
  40138. }
  40139. types[j] = 'EN';
  40140. }
  40141. }
  40142. }
  40143. for (i = 0; i < strLength; ++i) {
  40144. t = types[i];
  40145. if (t === 'WS' || t === 'ES' || t === 'ET' || t === 'CS') {
  40146. types[i] = 'ON';
  40147. }
  40148. }
  40149. lastType = sor;
  40150. for (i = 0; i < strLength; ++i) {
  40151. t = types[i];
  40152. if (t === 'EN') {
  40153. types[i] = lastType === 'L' ? 'L' : 'EN';
  40154. } else if (t === 'R' || t === 'L') {
  40155. lastType = t;
  40156. }
  40157. }
  40158. for (i = 0; i < strLength; ++i) {
  40159. if (types[i] === 'ON') {
  40160. var end = findUnequal(types, i + 1, 'ON');
  40161. var before = sor;
  40162. if (i > 0) {
  40163. before = types[i - 1];
  40164. }
  40165. var after = eor;
  40166. if (end + 1 < strLength) {
  40167. after = types[end + 1];
  40168. }
  40169. if (before !== 'L') {
  40170. before = 'R';
  40171. }
  40172. if (after !== 'L') {
  40173. after = 'R';
  40174. }
  40175. if (before === after) {
  40176. setValues(types, i, end, before);
  40177. }
  40178. i = end - 1;
  40179. }
  40180. }
  40181. for (i = 0; i < strLength; ++i) {
  40182. if (types[i] === 'ON') {
  40183. types[i] = e;
  40184. }
  40185. }
  40186. for (i = 0; i < strLength; ++i) {
  40187. t = types[i];
  40188. if (isEven(levels[i])) {
  40189. if (t === 'R') {
  40190. levels[i] += 1;
  40191. } else if (t === 'AN' || t === 'EN') {
  40192. levels[i] += 2;
  40193. }
  40194. } else {
  40195. if (t === 'L' || t === 'AN' || t === 'EN') {
  40196. levels[i] += 1;
  40197. }
  40198. }
  40199. }
  40200. var highestLevel = -1;
  40201. var lowestOddLevel = 99;
  40202. var level;
  40203. for (i = 0, ii = levels.length; i < ii; ++i) {
  40204. level = levels[i];
  40205. if (highestLevel < level) {
  40206. highestLevel = level;
  40207. }
  40208. if (lowestOddLevel > level && isOdd(level)) {
  40209. lowestOddLevel = level;
  40210. }
  40211. }
  40212. for (level = highestLevel; level >= lowestOddLevel; --level) {
  40213. var start = -1;
  40214. for (i = 0, ii = levels.length; i < ii; ++i) {
  40215. if (levels[i] < level) {
  40216. if (start >= 0) {
  40217. reverseValues(chars, start, i);
  40218. start = -1;
  40219. }
  40220. } else if (start < 0) {
  40221. start = i;
  40222. }
  40223. }
  40224. if (start >= 0) {
  40225. reverseValues(chars, start, levels.length);
  40226. }
  40227. }
  40228. for (i = 0, ii = chars.length; i < ii; ++i) {
  40229. var ch = chars[i];
  40230. if (ch === '<' || ch === '>') {
  40231. chars[i] = '';
  40232. }
  40233. }
  40234. return createBidiText(chars.join(''), isLTR);
  40235. }
  40236. exports.bidi = bidi;
  40237. /***/ }),
  40238. /* 29 */
  40239. /***/ (function(module, exports, __w_pdfjs_require__) {
  40240. "use strict";
  40241. var ISOAdobeCharset = [
  40242. '.notdef',
  40243. 'space',
  40244. 'exclam',
  40245. 'quotedbl',
  40246. 'numbersign',
  40247. 'dollar',
  40248. 'percent',
  40249. 'ampersand',
  40250. 'quoteright',
  40251. 'parenleft',
  40252. 'parenright',
  40253. 'asterisk',
  40254. 'plus',
  40255. 'comma',
  40256. 'hyphen',
  40257. 'period',
  40258. 'slash',
  40259. 'zero',
  40260. 'one',
  40261. 'two',
  40262. 'three',
  40263. 'four',
  40264. 'five',
  40265. 'six',
  40266. 'seven',
  40267. 'eight',
  40268. 'nine',
  40269. 'colon',
  40270. 'semicolon',
  40271. 'less',
  40272. 'equal',
  40273. 'greater',
  40274. 'question',
  40275. 'at',
  40276. 'A',
  40277. 'B',
  40278. 'C',
  40279. 'D',
  40280. 'E',
  40281. 'F',
  40282. 'G',
  40283. 'H',
  40284. 'I',
  40285. 'J',
  40286. 'K',
  40287. 'L',
  40288. 'M',
  40289. 'N',
  40290. 'O',
  40291. 'P',
  40292. 'Q',
  40293. 'R',
  40294. 'S',
  40295. 'T',
  40296. 'U',
  40297. 'V',
  40298. 'W',
  40299. 'X',
  40300. 'Y',
  40301. 'Z',
  40302. 'bracketleft',
  40303. 'backslash',
  40304. 'bracketright',
  40305. 'asciicircum',
  40306. 'underscore',
  40307. 'quoteleft',
  40308. 'a',
  40309. 'b',
  40310. 'c',
  40311. 'd',
  40312. 'e',
  40313. 'f',
  40314. 'g',
  40315. 'h',
  40316. 'i',
  40317. 'j',
  40318. 'k',
  40319. 'l',
  40320. 'm',
  40321. 'n',
  40322. 'o',
  40323. 'p',
  40324. 'q',
  40325. 'r',
  40326. 's',
  40327. 't',
  40328. 'u',
  40329. 'v',
  40330. 'w',
  40331. 'x',
  40332. 'y',
  40333. 'z',
  40334. 'braceleft',
  40335. 'bar',
  40336. 'braceright',
  40337. 'asciitilde',
  40338. 'exclamdown',
  40339. 'cent',
  40340. 'sterling',
  40341. 'fraction',
  40342. 'yen',
  40343. 'florin',
  40344. 'section',
  40345. 'currency',
  40346. 'quotesingle',
  40347. 'quotedblleft',
  40348. 'guillemotleft',
  40349. 'guilsinglleft',
  40350. 'guilsinglright',
  40351. 'fi',
  40352. 'fl',
  40353. 'endash',
  40354. 'dagger',
  40355. 'daggerdbl',
  40356. 'periodcentered',
  40357. 'paragraph',
  40358. 'bullet',
  40359. 'quotesinglbase',
  40360. 'quotedblbase',
  40361. 'quotedblright',
  40362. 'guillemotright',
  40363. 'ellipsis',
  40364. 'perthousand',
  40365. 'questiondown',
  40366. 'grave',
  40367. 'acute',
  40368. 'circumflex',
  40369. 'tilde',
  40370. 'macron',
  40371. 'breve',
  40372. 'dotaccent',
  40373. 'dieresis',
  40374. 'ring',
  40375. 'cedilla',
  40376. 'hungarumlaut',
  40377. 'ogonek',
  40378. 'caron',
  40379. 'emdash',
  40380. 'AE',
  40381. 'ordfeminine',
  40382. 'Lslash',
  40383. 'Oslash',
  40384. 'OE',
  40385. 'ordmasculine',
  40386. 'ae',
  40387. 'dotlessi',
  40388. 'lslash',
  40389. 'oslash',
  40390. 'oe',
  40391. 'germandbls',
  40392. 'onesuperior',
  40393. 'logicalnot',
  40394. 'mu',
  40395. 'trademark',
  40396. 'Eth',
  40397. 'onehalf',
  40398. 'plusminus',
  40399. 'Thorn',
  40400. 'onequarter',
  40401. 'divide',
  40402. 'brokenbar',
  40403. 'degree',
  40404. 'thorn',
  40405. 'threequarters',
  40406. 'twosuperior',
  40407. 'registered',
  40408. 'minus',
  40409. 'eth',
  40410. 'multiply',
  40411. 'threesuperior',
  40412. 'copyright',
  40413. 'Aacute',
  40414. 'Acircumflex',
  40415. 'Adieresis',
  40416. 'Agrave',
  40417. 'Aring',
  40418. 'Atilde',
  40419. 'Ccedilla',
  40420. 'Eacute',
  40421. 'Ecircumflex',
  40422. 'Edieresis',
  40423. 'Egrave',
  40424. 'Iacute',
  40425. 'Icircumflex',
  40426. 'Idieresis',
  40427. 'Igrave',
  40428. 'Ntilde',
  40429. 'Oacute',
  40430. 'Ocircumflex',
  40431. 'Odieresis',
  40432. 'Ograve',
  40433. 'Otilde',
  40434. 'Scaron',
  40435. 'Uacute',
  40436. 'Ucircumflex',
  40437. 'Udieresis',
  40438. 'Ugrave',
  40439. 'Yacute',
  40440. 'Ydieresis',
  40441. 'Zcaron',
  40442. 'aacute',
  40443. 'acircumflex',
  40444. 'adieresis',
  40445. 'agrave',
  40446. 'aring',
  40447. 'atilde',
  40448. 'ccedilla',
  40449. 'eacute',
  40450. 'ecircumflex',
  40451. 'edieresis',
  40452. 'egrave',
  40453. 'iacute',
  40454. 'icircumflex',
  40455. 'idieresis',
  40456. 'igrave',
  40457. 'ntilde',
  40458. 'oacute',
  40459. 'ocircumflex',
  40460. 'odieresis',
  40461. 'ograve',
  40462. 'otilde',
  40463. 'scaron',
  40464. 'uacute',
  40465. 'ucircumflex',
  40466. 'udieresis',
  40467. 'ugrave',
  40468. 'yacute',
  40469. 'ydieresis',
  40470. 'zcaron'
  40471. ];
  40472. var ExpertCharset = [
  40473. '.notdef',
  40474. 'space',
  40475. 'exclamsmall',
  40476. 'Hungarumlautsmall',
  40477. 'dollaroldstyle',
  40478. 'dollarsuperior',
  40479. 'ampersandsmall',
  40480. 'Acutesmall',
  40481. 'parenleftsuperior',
  40482. 'parenrightsuperior',
  40483. 'twodotenleader',
  40484. 'onedotenleader',
  40485. 'comma',
  40486. 'hyphen',
  40487. 'period',
  40488. 'fraction',
  40489. 'zerooldstyle',
  40490. 'oneoldstyle',
  40491. 'twooldstyle',
  40492. 'threeoldstyle',
  40493. 'fouroldstyle',
  40494. 'fiveoldstyle',
  40495. 'sixoldstyle',
  40496. 'sevenoldstyle',
  40497. 'eightoldstyle',
  40498. 'nineoldstyle',
  40499. 'colon',
  40500. 'semicolon',
  40501. 'commasuperior',
  40502. 'threequartersemdash',
  40503. 'periodsuperior',
  40504. 'questionsmall',
  40505. 'asuperior',
  40506. 'bsuperior',
  40507. 'centsuperior',
  40508. 'dsuperior',
  40509. 'esuperior',
  40510. 'isuperior',
  40511. 'lsuperior',
  40512. 'msuperior',
  40513. 'nsuperior',
  40514. 'osuperior',
  40515. 'rsuperior',
  40516. 'ssuperior',
  40517. 'tsuperior',
  40518. 'ff',
  40519. 'fi',
  40520. 'fl',
  40521. 'ffi',
  40522. 'ffl',
  40523. 'parenleftinferior',
  40524. 'parenrightinferior',
  40525. 'Circumflexsmall',
  40526. 'hyphensuperior',
  40527. 'Gravesmall',
  40528. 'Asmall',
  40529. 'Bsmall',
  40530. 'Csmall',
  40531. 'Dsmall',
  40532. 'Esmall',
  40533. 'Fsmall',
  40534. 'Gsmall',
  40535. 'Hsmall',
  40536. 'Ismall',
  40537. 'Jsmall',
  40538. 'Ksmall',
  40539. 'Lsmall',
  40540. 'Msmall',
  40541. 'Nsmall',
  40542. 'Osmall',
  40543. 'Psmall',
  40544. 'Qsmall',
  40545. 'Rsmall',
  40546. 'Ssmall',
  40547. 'Tsmall',
  40548. 'Usmall',
  40549. 'Vsmall',
  40550. 'Wsmall',
  40551. 'Xsmall',
  40552. 'Ysmall',
  40553. 'Zsmall',
  40554. 'colonmonetary',
  40555. 'onefitted',
  40556. 'rupiah',
  40557. 'Tildesmall',
  40558. 'exclamdownsmall',
  40559. 'centoldstyle',
  40560. 'Lslashsmall',
  40561. 'Scaronsmall',
  40562. 'Zcaronsmall',
  40563. 'Dieresissmall',
  40564. 'Brevesmall',
  40565. 'Caronsmall',
  40566. 'Dotaccentsmall',
  40567. 'Macronsmall',
  40568. 'figuredash',
  40569. 'hypheninferior',
  40570. 'Ogoneksmall',
  40571. 'Ringsmall',
  40572. 'Cedillasmall',
  40573. 'onequarter',
  40574. 'onehalf',
  40575. 'threequarters',
  40576. 'questiondownsmall',
  40577. 'oneeighth',
  40578. 'threeeighths',
  40579. 'fiveeighths',
  40580. 'seveneighths',
  40581. 'onethird',
  40582. 'twothirds',
  40583. 'zerosuperior',
  40584. 'onesuperior',
  40585. 'twosuperior',
  40586. 'threesuperior',
  40587. 'foursuperior',
  40588. 'fivesuperior',
  40589. 'sixsuperior',
  40590. 'sevensuperior',
  40591. 'eightsuperior',
  40592. 'ninesuperior',
  40593. 'zeroinferior',
  40594. 'oneinferior',
  40595. 'twoinferior',
  40596. 'threeinferior',
  40597. 'fourinferior',
  40598. 'fiveinferior',
  40599. 'sixinferior',
  40600. 'seveninferior',
  40601. 'eightinferior',
  40602. 'nineinferior',
  40603. 'centinferior',
  40604. 'dollarinferior',
  40605. 'periodinferior',
  40606. 'commainferior',
  40607. 'Agravesmall',
  40608. 'Aacutesmall',
  40609. 'Acircumflexsmall',
  40610. 'Atildesmall',
  40611. 'Adieresissmall',
  40612. 'Aringsmall',
  40613. 'AEsmall',
  40614. 'Ccedillasmall',
  40615. 'Egravesmall',
  40616. 'Eacutesmall',
  40617. 'Ecircumflexsmall',
  40618. 'Edieresissmall',
  40619. 'Igravesmall',
  40620. 'Iacutesmall',
  40621. 'Icircumflexsmall',
  40622. 'Idieresissmall',
  40623. 'Ethsmall',
  40624. 'Ntildesmall',
  40625. 'Ogravesmall',
  40626. 'Oacutesmall',
  40627. 'Ocircumflexsmall',
  40628. 'Otildesmall',
  40629. 'Odieresissmall',
  40630. 'OEsmall',
  40631. 'Oslashsmall',
  40632. 'Ugravesmall',
  40633. 'Uacutesmall',
  40634. 'Ucircumflexsmall',
  40635. 'Udieresissmall',
  40636. 'Yacutesmall',
  40637. 'Thornsmall',
  40638. 'Ydieresissmall'
  40639. ];
  40640. var ExpertSubsetCharset = [
  40641. '.notdef',
  40642. 'space',
  40643. 'dollaroldstyle',
  40644. 'dollarsuperior',
  40645. 'parenleftsuperior',
  40646. 'parenrightsuperior',
  40647. 'twodotenleader',
  40648. 'onedotenleader',
  40649. 'comma',
  40650. 'hyphen',
  40651. 'period',
  40652. 'fraction',
  40653. 'zerooldstyle',
  40654. 'oneoldstyle',
  40655. 'twooldstyle',
  40656. 'threeoldstyle',
  40657. 'fouroldstyle',
  40658. 'fiveoldstyle',
  40659. 'sixoldstyle',
  40660. 'sevenoldstyle',
  40661. 'eightoldstyle',
  40662. 'nineoldstyle',
  40663. 'colon',
  40664. 'semicolon',
  40665. 'commasuperior',
  40666. 'threequartersemdash',
  40667. 'periodsuperior',
  40668. 'asuperior',
  40669. 'bsuperior',
  40670. 'centsuperior',
  40671. 'dsuperior',
  40672. 'esuperior',
  40673. 'isuperior',
  40674. 'lsuperior',
  40675. 'msuperior',
  40676. 'nsuperior',
  40677. 'osuperior',
  40678. 'rsuperior',
  40679. 'ssuperior',
  40680. 'tsuperior',
  40681. 'ff',
  40682. 'fi',
  40683. 'fl',
  40684. 'ffi',
  40685. 'ffl',
  40686. 'parenleftinferior',
  40687. 'parenrightinferior',
  40688. 'hyphensuperior',
  40689. 'colonmonetary',
  40690. 'onefitted',
  40691. 'rupiah',
  40692. 'centoldstyle',
  40693. 'figuredash',
  40694. 'hypheninferior',
  40695. 'onequarter',
  40696. 'onehalf',
  40697. 'threequarters',
  40698. 'oneeighth',
  40699. 'threeeighths',
  40700. 'fiveeighths',
  40701. 'seveneighths',
  40702. 'onethird',
  40703. 'twothirds',
  40704. 'zerosuperior',
  40705. 'onesuperior',
  40706. 'twosuperior',
  40707. 'threesuperior',
  40708. 'foursuperior',
  40709. 'fivesuperior',
  40710. 'sixsuperior',
  40711. 'sevensuperior',
  40712. 'eightsuperior',
  40713. 'ninesuperior',
  40714. 'zeroinferior',
  40715. 'oneinferior',
  40716. 'twoinferior',
  40717. 'threeinferior',
  40718. 'fourinferior',
  40719. 'fiveinferior',
  40720. 'sixinferior',
  40721. 'seveninferior',
  40722. 'eightinferior',
  40723. 'nineinferior',
  40724. 'centinferior',
  40725. 'dollarinferior',
  40726. 'periodinferior',
  40727. 'commainferior'
  40728. ];
  40729. exports.ISOAdobeCharset = ISOAdobeCharset;
  40730. exports.ExpertCharset = ExpertCharset;
  40731. exports.ExpertSubsetCharset = ExpertSubsetCharset;
  40732. /***/ }),
  40733. /* 30 */
  40734. /***/ (function(module, exports, __w_pdfjs_require__) {
  40735. "use strict";
  40736. var sharedUtil = __w_pdfjs_require__(0);
  40737. var corePrimitives = __w_pdfjs_require__(1);
  40738. var coreStream = __w_pdfjs_require__(2);
  40739. var coreParser = __w_pdfjs_require__(6);
  40740. var Util = sharedUtil.Util;
  40741. var assert = sharedUtil.assert;
  40742. var warn = sharedUtil.warn;
  40743. var error = sharedUtil.error;
  40744. var isInt = sharedUtil.isInt;
  40745. var isString = sharedUtil.isString;
  40746. var MissingDataException = sharedUtil.MissingDataException;
  40747. var CMapCompressionType = sharedUtil.CMapCompressionType;
  40748. var isEOF = corePrimitives.isEOF;
  40749. var isName = corePrimitives.isName;
  40750. var isCmd = corePrimitives.isCmd;
  40751. var isStream = corePrimitives.isStream;
  40752. var Stream = coreStream.Stream;
  40753. var Lexer = coreParser.Lexer;
  40754. var BUILT_IN_CMAPS = [
  40755. 'Adobe-GB1-UCS2',
  40756. 'Adobe-CNS1-UCS2',
  40757. 'Adobe-Japan1-UCS2',
  40758. 'Adobe-Korea1-UCS2',
  40759. '78-EUC-H',
  40760. '78-EUC-V',
  40761. '78-H',
  40762. '78-RKSJ-H',
  40763. '78-RKSJ-V',
  40764. '78-V',
  40765. '78ms-RKSJ-H',
  40766. '78ms-RKSJ-V',
  40767. '83pv-RKSJ-H',
  40768. '90ms-RKSJ-H',
  40769. '90ms-RKSJ-V',
  40770. '90msp-RKSJ-H',
  40771. '90msp-RKSJ-V',
  40772. '90pv-RKSJ-H',
  40773. '90pv-RKSJ-V',
  40774. 'Add-H',
  40775. 'Add-RKSJ-H',
  40776. 'Add-RKSJ-V',
  40777. 'Add-V',
  40778. 'Adobe-CNS1-0',
  40779. 'Adobe-CNS1-1',
  40780. 'Adobe-CNS1-2',
  40781. 'Adobe-CNS1-3',
  40782. 'Adobe-CNS1-4',
  40783. 'Adobe-CNS1-5',
  40784. 'Adobe-CNS1-6',
  40785. 'Adobe-GB1-0',
  40786. 'Adobe-GB1-1',
  40787. 'Adobe-GB1-2',
  40788. 'Adobe-GB1-3',
  40789. 'Adobe-GB1-4',
  40790. 'Adobe-GB1-5',
  40791. 'Adobe-Japan1-0',
  40792. 'Adobe-Japan1-1',
  40793. 'Adobe-Japan1-2',
  40794. 'Adobe-Japan1-3',
  40795. 'Adobe-Japan1-4',
  40796. 'Adobe-Japan1-5',
  40797. 'Adobe-Japan1-6',
  40798. 'Adobe-Korea1-0',
  40799. 'Adobe-Korea1-1',
  40800. 'Adobe-Korea1-2',
  40801. 'B5-H',
  40802. 'B5-V',
  40803. 'B5pc-H',
  40804. 'B5pc-V',
  40805. 'CNS-EUC-H',
  40806. 'CNS-EUC-V',
  40807. 'CNS1-H',
  40808. 'CNS1-V',
  40809. 'CNS2-H',
  40810. 'CNS2-V',
  40811. 'ETHK-B5-H',
  40812. 'ETHK-B5-V',
  40813. 'ETen-B5-H',
  40814. 'ETen-B5-V',
  40815. 'ETenms-B5-H',
  40816. 'ETenms-B5-V',
  40817. 'EUC-H',
  40818. 'EUC-V',
  40819. 'Ext-H',
  40820. 'Ext-RKSJ-H',
  40821. 'Ext-RKSJ-V',
  40822. 'Ext-V',
  40823. 'GB-EUC-H',
  40824. 'GB-EUC-V',
  40825. 'GB-H',
  40826. 'GB-V',
  40827. 'GBK-EUC-H',
  40828. 'GBK-EUC-V',
  40829. 'GBK2K-H',
  40830. 'GBK2K-V',
  40831. 'GBKp-EUC-H',
  40832. 'GBKp-EUC-V',
  40833. 'GBT-EUC-H',
  40834. 'GBT-EUC-V',
  40835. 'GBT-H',
  40836. 'GBT-V',
  40837. 'GBTpc-EUC-H',
  40838. 'GBTpc-EUC-V',
  40839. 'GBpc-EUC-H',
  40840. 'GBpc-EUC-V',
  40841. 'H',
  40842. 'HKdla-B5-H',
  40843. 'HKdla-B5-V',
  40844. 'HKdlb-B5-H',
  40845. 'HKdlb-B5-V',
  40846. 'HKgccs-B5-H',
  40847. 'HKgccs-B5-V',
  40848. 'HKm314-B5-H',
  40849. 'HKm314-B5-V',
  40850. 'HKm471-B5-H',
  40851. 'HKm471-B5-V',
  40852. 'HKscs-B5-H',
  40853. 'HKscs-B5-V',
  40854. 'Hankaku',
  40855. 'Hiragana',
  40856. 'KSC-EUC-H',
  40857. 'KSC-EUC-V',
  40858. 'KSC-H',
  40859. 'KSC-Johab-H',
  40860. 'KSC-Johab-V',
  40861. 'KSC-V',
  40862. 'KSCms-UHC-H',
  40863. 'KSCms-UHC-HW-H',
  40864. 'KSCms-UHC-HW-V',
  40865. 'KSCms-UHC-V',
  40866. 'KSCpc-EUC-H',
  40867. 'KSCpc-EUC-V',
  40868. 'Katakana',
  40869. 'NWP-H',
  40870. 'NWP-V',
  40871. 'RKSJ-H',
  40872. 'RKSJ-V',
  40873. 'Roman',
  40874. 'UniCNS-UCS2-H',
  40875. 'UniCNS-UCS2-V',
  40876. 'UniCNS-UTF16-H',
  40877. 'UniCNS-UTF16-V',
  40878. 'UniCNS-UTF32-H',
  40879. 'UniCNS-UTF32-V',
  40880. 'UniCNS-UTF8-H',
  40881. 'UniCNS-UTF8-V',
  40882. 'UniGB-UCS2-H',
  40883. 'UniGB-UCS2-V',
  40884. 'UniGB-UTF16-H',
  40885. 'UniGB-UTF16-V',
  40886. 'UniGB-UTF32-H',
  40887. 'UniGB-UTF32-V',
  40888. 'UniGB-UTF8-H',
  40889. 'UniGB-UTF8-V',
  40890. 'UniJIS-UCS2-H',
  40891. 'UniJIS-UCS2-HW-H',
  40892. 'UniJIS-UCS2-HW-V',
  40893. 'UniJIS-UCS2-V',
  40894. 'UniJIS-UTF16-H',
  40895. 'UniJIS-UTF16-V',
  40896. 'UniJIS-UTF32-H',
  40897. 'UniJIS-UTF32-V',
  40898. 'UniJIS-UTF8-H',
  40899. 'UniJIS-UTF8-V',
  40900. 'UniJIS2004-UTF16-H',
  40901. 'UniJIS2004-UTF16-V',
  40902. 'UniJIS2004-UTF32-H',
  40903. 'UniJIS2004-UTF32-V',
  40904. 'UniJIS2004-UTF8-H',
  40905. 'UniJIS2004-UTF8-V',
  40906. 'UniJISPro-UCS2-HW-V',
  40907. 'UniJISPro-UCS2-V',
  40908. 'UniJISPro-UTF8-V',
  40909. 'UniJISX0213-UTF32-H',
  40910. 'UniJISX0213-UTF32-V',
  40911. 'UniJISX02132004-UTF32-H',
  40912. 'UniJISX02132004-UTF32-V',
  40913. 'UniKS-UCS2-H',
  40914. 'UniKS-UCS2-V',
  40915. 'UniKS-UTF16-H',
  40916. 'UniKS-UTF16-V',
  40917. 'UniKS-UTF32-H',
  40918. 'UniKS-UTF32-V',
  40919. 'UniKS-UTF8-H',
  40920. 'UniKS-UTF8-V',
  40921. 'V',
  40922. 'WP-Symbol'
  40923. ];
  40924. var CMap = function CMapClosure() {
  40925. function CMap(builtInCMap) {
  40926. this.codespaceRanges = [
  40927. [],
  40928. [],
  40929. [],
  40930. []
  40931. ];
  40932. this.numCodespaceRanges = 0;
  40933. this._map = [];
  40934. this.name = '';
  40935. this.vertical = false;
  40936. this.useCMap = null;
  40937. this.builtInCMap = builtInCMap;
  40938. }
  40939. CMap.prototype = {
  40940. addCodespaceRange: function (n, low, high) {
  40941. this.codespaceRanges[n - 1].push(low, high);
  40942. this.numCodespaceRanges++;
  40943. },
  40944. mapCidRange: function (low, high, dstLow) {
  40945. while (low <= high) {
  40946. this._map[low++] = dstLow++;
  40947. }
  40948. },
  40949. mapBfRange: function (low, high, dstLow) {
  40950. var lastByte = dstLow.length - 1;
  40951. while (low <= high) {
  40952. this._map[low++] = dstLow;
  40953. dstLow = dstLow.substr(0, lastByte) + String.fromCharCode(dstLow.charCodeAt(lastByte) + 1);
  40954. }
  40955. },
  40956. mapBfRangeToArray: function (low, high, array) {
  40957. var i = 0, ii = array.length;
  40958. while (low <= high && i < ii) {
  40959. this._map[low] = array[i++];
  40960. ++low;
  40961. }
  40962. },
  40963. mapOne: function (src, dst) {
  40964. this._map[src] = dst;
  40965. },
  40966. lookup: function (code) {
  40967. return this._map[code];
  40968. },
  40969. contains: function (code) {
  40970. return this._map[code] !== undefined;
  40971. },
  40972. forEach: function (callback) {
  40973. var map = this._map;
  40974. var length = map.length;
  40975. var i;
  40976. if (length <= 0x10000) {
  40977. for (i = 0; i < length; i++) {
  40978. if (map[i] !== undefined) {
  40979. callback(i, map[i]);
  40980. }
  40981. }
  40982. } else {
  40983. for (i in this._map) {
  40984. callback(i, map[i]);
  40985. }
  40986. }
  40987. },
  40988. charCodeOf: function (value) {
  40989. return this._map.indexOf(value);
  40990. },
  40991. getMap: function () {
  40992. return this._map;
  40993. },
  40994. readCharCode: function (str, offset, out) {
  40995. var c = 0;
  40996. var codespaceRanges = this.codespaceRanges;
  40997. var codespaceRangesLen = this.codespaceRanges.length;
  40998. for (var n = 0; n < codespaceRangesLen; n++) {
  40999. c = (c << 8 | str.charCodeAt(offset + n)) >>> 0;
  41000. var codespaceRange = codespaceRanges[n];
  41001. for (var k = 0, kk = codespaceRange.length; k < kk;) {
  41002. var low = codespaceRange[k++];
  41003. var high = codespaceRange[k++];
  41004. if (c >= low && c <= high) {
  41005. out.charcode = c;
  41006. out.length = n + 1;
  41007. return;
  41008. }
  41009. }
  41010. }
  41011. out.charcode = 0;
  41012. out.length = 1;
  41013. },
  41014. get length() {
  41015. return this._map.length;
  41016. },
  41017. get isIdentityCMap() {
  41018. if (!(this.name === 'Identity-H' || this.name === 'Identity-V')) {
  41019. return false;
  41020. }
  41021. if (this._map.length !== 0x10000) {
  41022. return false;
  41023. }
  41024. for (var i = 0; i < 0x10000; i++) {
  41025. if (this._map[i] !== i) {
  41026. return false;
  41027. }
  41028. }
  41029. return true;
  41030. }
  41031. };
  41032. return CMap;
  41033. }();
  41034. var IdentityCMap = function IdentityCMapClosure() {
  41035. function IdentityCMap(vertical, n) {
  41036. CMap.call(this);
  41037. this.vertical = vertical;
  41038. this.addCodespaceRange(n, 0, 0xffff);
  41039. }
  41040. Util.inherit(IdentityCMap, CMap, {});
  41041. IdentityCMap.prototype = {
  41042. addCodespaceRange: CMap.prototype.addCodespaceRange,
  41043. mapCidRange: function (low, high, dstLow) {
  41044. error('should not call mapCidRange');
  41045. },
  41046. mapBfRange: function (low, high, dstLow) {
  41047. error('should not call mapBfRange');
  41048. },
  41049. mapBfRangeToArray: function (low, high, array) {
  41050. error('should not call mapBfRangeToArray');
  41051. },
  41052. mapOne: function (src, dst) {
  41053. error('should not call mapCidOne');
  41054. },
  41055. lookup: function (code) {
  41056. return isInt(code) && code <= 0xffff ? code : undefined;
  41057. },
  41058. contains: function (code) {
  41059. return isInt(code) && code <= 0xffff;
  41060. },
  41061. forEach: function (callback) {
  41062. for (var i = 0; i <= 0xffff; i++) {
  41063. callback(i, i);
  41064. }
  41065. },
  41066. charCodeOf: function (value) {
  41067. return isInt(value) && value <= 0xffff ? value : -1;
  41068. },
  41069. getMap: function () {
  41070. var map = new Array(0x10000);
  41071. for (var i = 0; i <= 0xffff; i++) {
  41072. map[i] = i;
  41073. }
  41074. return map;
  41075. },
  41076. readCharCode: CMap.prototype.readCharCode,
  41077. get length() {
  41078. return 0x10000;
  41079. },
  41080. get isIdentityCMap() {
  41081. error('should not access .isIdentityCMap');
  41082. }
  41083. };
  41084. return IdentityCMap;
  41085. }();
  41086. var BinaryCMapReader = function BinaryCMapReaderClosure() {
  41087. function hexToInt(a, size) {
  41088. var n = 0;
  41089. for (var i = 0; i <= size; i++) {
  41090. n = n << 8 | a[i];
  41091. }
  41092. return n >>> 0;
  41093. }
  41094. function hexToStr(a, size) {
  41095. if (size === 1) {
  41096. return String.fromCharCode(a[0], a[1]);
  41097. }
  41098. if (size === 3) {
  41099. return String.fromCharCode(a[0], a[1], a[2], a[3]);
  41100. }
  41101. return String.fromCharCode.apply(null, a.subarray(0, size + 1));
  41102. }
  41103. function addHex(a, b, size) {
  41104. var c = 0;
  41105. for (var i = size; i >= 0; i--) {
  41106. c += a[i] + b[i];
  41107. a[i] = c & 255;
  41108. c >>= 8;
  41109. }
  41110. }
  41111. function incHex(a, size) {
  41112. var c = 1;
  41113. for (var i = size; i >= 0 && c > 0; i--) {
  41114. c += a[i];
  41115. a[i] = c & 255;
  41116. c >>= 8;
  41117. }
  41118. }
  41119. var MAX_NUM_SIZE = 16;
  41120. var MAX_ENCODED_NUM_SIZE = 19;
  41121. function BinaryCMapStream(data) {
  41122. this.buffer = data;
  41123. this.pos = 0;
  41124. this.end = data.length;
  41125. this.tmpBuf = new Uint8Array(MAX_ENCODED_NUM_SIZE);
  41126. }
  41127. BinaryCMapStream.prototype = {
  41128. readByte: function () {
  41129. if (this.pos >= this.end) {
  41130. return -1;
  41131. }
  41132. return this.buffer[this.pos++];
  41133. },
  41134. readNumber: function () {
  41135. var n = 0;
  41136. var last;
  41137. do {
  41138. var b = this.readByte();
  41139. if (b < 0) {
  41140. error('unexpected EOF in bcmap');
  41141. }
  41142. last = !(b & 0x80);
  41143. n = n << 7 | b & 0x7F;
  41144. } while (!last);
  41145. return n;
  41146. },
  41147. readSigned: function () {
  41148. var n = this.readNumber();
  41149. return n & 1 ? ~(n >>> 1) : n >>> 1;
  41150. },
  41151. readHex: function (num, size) {
  41152. num.set(this.buffer.subarray(this.pos, this.pos + size + 1));
  41153. this.pos += size + 1;
  41154. },
  41155. readHexNumber: function (num, size) {
  41156. var last;
  41157. var stack = this.tmpBuf, sp = 0;
  41158. do {
  41159. var b = this.readByte();
  41160. if (b < 0) {
  41161. error('unexpected EOF in bcmap');
  41162. }
  41163. last = !(b & 0x80);
  41164. stack[sp++] = b & 0x7F;
  41165. } while (!last);
  41166. var i = size, buffer = 0, bufferSize = 0;
  41167. while (i >= 0) {
  41168. while (bufferSize < 8 && stack.length > 0) {
  41169. buffer = stack[--sp] << bufferSize | buffer;
  41170. bufferSize += 7;
  41171. }
  41172. num[i] = buffer & 255;
  41173. i--;
  41174. buffer >>= 8;
  41175. bufferSize -= 8;
  41176. }
  41177. },
  41178. readHexSigned: function (num, size) {
  41179. this.readHexNumber(num, size);
  41180. var sign = num[size] & 1 ? 255 : 0;
  41181. var c = 0;
  41182. for (var i = 0; i <= size; i++) {
  41183. c = (c & 1) << 8 | num[i];
  41184. num[i] = c >> 1 ^ sign;
  41185. }
  41186. },
  41187. readString: function () {
  41188. var len = this.readNumber();
  41189. var s = '';
  41190. for (var i = 0; i < len; i++) {
  41191. s += String.fromCharCode(this.readNumber());
  41192. }
  41193. return s;
  41194. }
  41195. };
  41196. function processBinaryCMap(data, cMap, extend) {
  41197. return new Promise(function (resolve, reject) {
  41198. var stream = new BinaryCMapStream(data);
  41199. var header = stream.readByte();
  41200. cMap.vertical = !!(header & 1);
  41201. var useCMap = null;
  41202. var start = new Uint8Array(MAX_NUM_SIZE);
  41203. var end = new Uint8Array(MAX_NUM_SIZE);
  41204. var char = new Uint8Array(MAX_NUM_SIZE);
  41205. var charCode = new Uint8Array(MAX_NUM_SIZE);
  41206. var tmp = new Uint8Array(MAX_NUM_SIZE);
  41207. var code;
  41208. var b;
  41209. while ((b = stream.readByte()) >= 0) {
  41210. var type = b >> 5;
  41211. if (type === 7) {
  41212. switch (b & 0x1F) {
  41213. case 0:
  41214. stream.readString();
  41215. break;
  41216. case 1:
  41217. useCMap = stream.readString();
  41218. break;
  41219. }
  41220. continue;
  41221. }
  41222. var sequence = !!(b & 0x10);
  41223. var dataSize = b & 15;
  41224. assert(dataSize + 1 <= MAX_NUM_SIZE);
  41225. var ucs2DataSize = 1;
  41226. var subitemsCount = stream.readNumber();
  41227. var i;
  41228. switch (type) {
  41229. case 0:
  41230. stream.readHex(start, dataSize);
  41231. stream.readHexNumber(end, dataSize);
  41232. addHex(end, start, dataSize);
  41233. cMap.addCodespaceRange(dataSize + 1, hexToInt(start, dataSize), hexToInt(end, dataSize));
  41234. for (i = 1; i < subitemsCount; i++) {
  41235. incHex(end, dataSize);
  41236. stream.readHexNumber(start, dataSize);
  41237. addHex(start, end, dataSize);
  41238. stream.readHexNumber(end, dataSize);
  41239. addHex(end, start, dataSize);
  41240. cMap.addCodespaceRange(dataSize + 1, hexToInt(start, dataSize), hexToInt(end, dataSize));
  41241. }
  41242. break;
  41243. case 1:
  41244. stream.readHex(start, dataSize);
  41245. stream.readHexNumber(end, dataSize);
  41246. addHex(end, start, dataSize);
  41247. code = stream.readNumber();
  41248. for (i = 1; i < subitemsCount; i++) {
  41249. incHex(end, dataSize);
  41250. stream.readHexNumber(start, dataSize);
  41251. addHex(start, end, dataSize);
  41252. stream.readHexNumber(end, dataSize);
  41253. addHex(end, start, dataSize);
  41254. code = stream.readNumber();
  41255. }
  41256. break;
  41257. case 2:
  41258. stream.readHex(char, dataSize);
  41259. code = stream.readNumber();
  41260. cMap.mapOne(hexToInt(char, dataSize), code);
  41261. for (i = 1; i < subitemsCount; i++) {
  41262. incHex(char, dataSize);
  41263. if (!sequence) {
  41264. stream.readHexNumber(tmp, dataSize);
  41265. addHex(char, tmp, dataSize);
  41266. }
  41267. code = stream.readSigned() + (code + 1);
  41268. cMap.mapOne(hexToInt(char, dataSize), code);
  41269. }
  41270. break;
  41271. case 3:
  41272. stream.readHex(start, dataSize);
  41273. stream.readHexNumber(end, dataSize);
  41274. addHex(end, start, dataSize);
  41275. code = stream.readNumber();
  41276. cMap.mapCidRange(hexToInt(start, dataSize), hexToInt(end, dataSize), code);
  41277. for (i = 1; i < subitemsCount; i++) {
  41278. incHex(end, dataSize);
  41279. if (!sequence) {
  41280. stream.readHexNumber(start, dataSize);
  41281. addHex(start, end, dataSize);
  41282. } else {
  41283. start.set(end);
  41284. }
  41285. stream.readHexNumber(end, dataSize);
  41286. addHex(end, start, dataSize);
  41287. code = stream.readNumber();
  41288. cMap.mapCidRange(hexToInt(start, dataSize), hexToInt(end, dataSize), code);
  41289. }
  41290. break;
  41291. case 4:
  41292. stream.readHex(char, ucs2DataSize);
  41293. stream.readHex(charCode, dataSize);
  41294. cMap.mapOne(hexToInt(char, ucs2DataSize), hexToStr(charCode, dataSize));
  41295. for (i = 1; i < subitemsCount; i++) {
  41296. incHex(char, ucs2DataSize);
  41297. if (!sequence) {
  41298. stream.readHexNumber(tmp, ucs2DataSize);
  41299. addHex(char, tmp, ucs2DataSize);
  41300. }
  41301. incHex(charCode, dataSize);
  41302. stream.readHexSigned(tmp, dataSize);
  41303. addHex(charCode, tmp, dataSize);
  41304. cMap.mapOne(hexToInt(char, ucs2DataSize), hexToStr(charCode, dataSize));
  41305. }
  41306. break;
  41307. case 5:
  41308. stream.readHex(start, ucs2DataSize);
  41309. stream.readHexNumber(end, ucs2DataSize);
  41310. addHex(end, start, ucs2DataSize);
  41311. stream.readHex(charCode, dataSize);
  41312. cMap.mapBfRange(hexToInt(start, ucs2DataSize), hexToInt(end, ucs2DataSize), hexToStr(charCode, dataSize));
  41313. for (i = 1; i < subitemsCount; i++) {
  41314. incHex(end, ucs2DataSize);
  41315. if (!sequence) {
  41316. stream.readHexNumber(start, ucs2DataSize);
  41317. addHex(start, end, ucs2DataSize);
  41318. } else {
  41319. start.set(end);
  41320. }
  41321. stream.readHexNumber(end, ucs2DataSize);
  41322. addHex(end, start, ucs2DataSize);
  41323. stream.readHex(charCode, dataSize);
  41324. cMap.mapBfRange(hexToInt(start, ucs2DataSize), hexToInt(end, ucs2DataSize), hexToStr(charCode, dataSize));
  41325. }
  41326. break;
  41327. default:
  41328. reject(new Error('processBinaryCMap: Unknown type: ' + type));
  41329. return;
  41330. }
  41331. }
  41332. if (useCMap) {
  41333. resolve(extend(useCMap));
  41334. return;
  41335. }
  41336. resolve(cMap);
  41337. });
  41338. }
  41339. function BinaryCMapReader() {
  41340. }
  41341. BinaryCMapReader.prototype = { process: processBinaryCMap };
  41342. return BinaryCMapReader;
  41343. }();
  41344. var CMapFactory = function CMapFactoryClosure() {
  41345. function strToInt(str) {
  41346. var a = 0;
  41347. for (var i = 0; i < str.length; i++) {
  41348. a = a << 8 | str.charCodeAt(i);
  41349. }
  41350. return a >>> 0;
  41351. }
  41352. function expectString(obj) {
  41353. if (!isString(obj)) {
  41354. error('Malformed CMap: expected string.');
  41355. }
  41356. }
  41357. function expectInt(obj) {
  41358. if (!isInt(obj)) {
  41359. error('Malformed CMap: expected int.');
  41360. }
  41361. }
  41362. function parseBfChar(cMap, lexer) {
  41363. while (true) {
  41364. var obj = lexer.getObj();
  41365. if (isEOF(obj)) {
  41366. break;
  41367. }
  41368. if (isCmd(obj, 'endbfchar')) {
  41369. return;
  41370. }
  41371. expectString(obj);
  41372. var src = strToInt(obj);
  41373. obj = lexer.getObj();
  41374. expectString(obj);
  41375. var dst = obj;
  41376. cMap.mapOne(src, dst);
  41377. }
  41378. }
  41379. function parseBfRange(cMap, lexer) {
  41380. while (true) {
  41381. var obj = lexer.getObj();
  41382. if (isEOF(obj)) {
  41383. break;
  41384. }
  41385. if (isCmd(obj, 'endbfrange')) {
  41386. return;
  41387. }
  41388. expectString(obj);
  41389. var low = strToInt(obj);
  41390. obj = lexer.getObj();
  41391. expectString(obj);
  41392. var high = strToInt(obj);
  41393. obj = lexer.getObj();
  41394. if (isInt(obj) || isString(obj)) {
  41395. var dstLow = isInt(obj) ? String.fromCharCode(obj) : obj;
  41396. cMap.mapBfRange(low, high, dstLow);
  41397. } else if (isCmd(obj, '[')) {
  41398. obj = lexer.getObj();
  41399. var array = [];
  41400. while (!isCmd(obj, ']') && !isEOF(obj)) {
  41401. array.push(obj);
  41402. obj = lexer.getObj();
  41403. }
  41404. cMap.mapBfRangeToArray(low, high, array);
  41405. } else {
  41406. break;
  41407. }
  41408. }
  41409. error('Invalid bf range.');
  41410. }
  41411. function parseCidChar(cMap, lexer) {
  41412. while (true) {
  41413. var obj = lexer.getObj();
  41414. if (isEOF(obj)) {
  41415. break;
  41416. }
  41417. if (isCmd(obj, 'endcidchar')) {
  41418. return;
  41419. }
  41420. expectString(obj);
  41421. var src = strToInt(obj);
  41422. obj = lexer.getObj();
  41423. expectInt(obj);
  41424. var dst = obj;
  41425. cMap.mapOne(src, dst);
  41426. }
  41427. }
  41428. function parseCidRange(cMap, lexer) {
  41429. while (true) {
  41430. var obj = lexer.getObj();
  41431. if (isEOF(obj)) {
  41432. break;
  41433. }
  41434. if (isCmd(obj, 'endcidrange')) {
  41435. return;
  41436. }
  41437. expectString(obj);
  41438. var low = strToInt(obj);
  41439. obj = lexer.getObj();
  41440. expectString(obj);
  41441. var high = strToInt(obj);
  41442. obj = lexer.getObj();
  41443. expectInt(obj);
  41444. var dstLow = obj;
  41445. cMap.mapCidRange(low, high, dstLow);
  41446. }
  41447. }
  41448. function parseCodespaceRange(cMap, lexer) {
  41449. while (true) {
  41450. var obj = lexer.getObj();
  41451. if (isEOF(obj)) {
  41452. break;
  41453. }
  41454. if (isCmd(obj, 'endcodespacerange')) {
  41455. return;
  41456. }
  41457. if (!isString(obj)) {
  41458. break;
  41459. }
  41460. var low = strToInt(obj);
  41461. obj = lexer.getObj();
  41462. if (!isString(obj)) {
  41463. break;
  41464. }
  41465. var high = strToInt(obj);
  41466. cMap.addCodespaceRange(obj.length, low, high);
  41467. }
  41468. error('Invalid codespace range.');
  41469. }
  41470. function parseWMode(cMap, lexer) {
  41471. var obj = lexer.getObj();
  41472. if (isInt(obj)) {
  41473. cMap.vertical = !!obj;
  41474. }
  41475. }
  41476. function parseCMapName(cMap, lexer) {
  41477. var obj = lexer.getObj();
  41478. if (isName(obj) && isString(obj.name)) {
  41479. cMap.name = obj.name;
  41480. }
  41481. }
  41482. function parseCMap(cMap, lexer, fetchBuiltInCMap, useCMap) {
  41483. var previous;
  41484. var embededUseCMap;
  41485. objLoop:
  41486. while (true) {
  41487. try {
  41488. var obj = lexer.getObj();
  41489. if (isEOF(obj)) {
  41490. break;
  41491. } else if (isName(obj)) {
  41492. if (obj.name === 'WMode') {
  41493. parseWMode(cMap, lexer);
  41494. } else if (obj.name === 'CMapName') {
  41495. parseCMapName(cMap, lexer);
  41496. }
  41497. previous = obj;
  41498. } else if (isCmd(obj)) {
  41499. switch (obj.cmd) {
  41500. case 'endcmap':
  41501. break objLoop;
  41502. case 'usecmap':
  41503. if (isName(previous)) {
  41504. embededUseCMap = previous.name;
  41505. }
  41506. break;
  41507. case 'begincodespacerange':
  41508. parseCodespaceRange(cMap, lexer);
  41509. break;
  41510. case 'beginbfchar':
  41511. parseBfChar(cMap, lexer);
  41512. break;
  41513. case 'begincidchar':
  41514. parseCidChar(cMap, lexer);
  41515. break;
  41516. case 'beginbfrange':
  41517. parseBfRange(cMap, lexer);
  41518. break;
  41519. case 'begincidrange':
  41520. parseCidRange(cMap, lexer);
  41521. break;
  41522. }
  41523. }
  41524. } catch (ex) {
  41525. if (ex instanceof MissingDataException) {
  41526. throw ex;
  41527. }
  41528. warn('Invalid cMap data: ' + ex);
  41529. continue;
  41530. }
  41531. }
  41532. if (!useCMap && embededUseCMap) {
  41533. useCMap = embededUseCMap;
  41534. }
  41535. if (useCMap) {
  41536. return extendCMap(cMap, fetchBuiltInCMap, useCMap);
  41537. }
  41538. return Promise.resolve(cMap);
  41539. }
  41540. function extendCMap(cMap, fetchBuiltInCMap, useCMap) {
  41541. return createBuiltInCMap(useCMap, fetchBuiltInCMap).then(function (newCMap) {
  41542. cMap.useCMap = newCMap;
  41543. if (cMap.numCodespaceRanges === 0) {
  41544. var useCodespaceRanges = cMap.useCMap.codespaceRanges;
  41545. for (var i = 0; i < useCodespaceRanges.length; i++) {
  41546. cMap.codespaceRanges[i] = useCodespaceRanges[i].slice();
  41547. }
  41548. cMap.numCodespaceRanges = cMap.useCMap.numCodespaceRanges;
  41549. }
  41550. cMap.useCMap.forEach(function (key, value) {
  41551. if (!cMap.contains(key)) {
  41552. cMap.mapOne(key, cMap.useCMap.lookup(key));
  41553. }
  41554. });
  41555. return cMap;
  41556. });
  41557. }
  41558. function createBuiltInCMap(name, fetchBuiltInCMap) {
  41559. if (name === 'Identity-H') {
  41560. return Promise.resolve(new IdentityCMap(false, 2));
  41561. } else if (name === 'Identity-V') {
  41562. return Promise.resolve(new IdentityCMap(true, 2));
  41563. }
  41564. if (BUILT_IN_CMAPS.indexOf(name) === -1) {
  41565. return Promise.reject(new Error('Unknown cMap name: ' + name));
  41566. }
  41567. assert(fetchBuiltInCMap, 'Built-in CMap parameters are not provided.');
  41568. return fetchBuiltInCMap(name).then(function (data) {
  41569. var cMapData = data.cMapData, compressionType = data.compressionType;
  41570. var cMap = new CMap(true);
  41571. if (compressionType === CMapCompressionType.BINARY) {
  41572. return new BinaryCMapReader().process(cMapData, cMap, function (useCMap) {
  41573. return extendCMap(cMap, fetchBuiltInCMap, useCMap);
  41574. });
  41575. }
  41576. assert(compressionType === CMapCompressionType.NONE, 'TODO: Only BINARY/NONE CMap compression is currently supported.');
  41577. var lexer = new Lexer(new Stream(cMapData));
  41578. return parseCMap(cMap, lexer, fetchBuiltInCMap, null);
  41579. });
  41580. }
  41581. return {
  41582. create: function (params) {
  41583. var encoding = params.encoding;
  41584. var fetchBuiltInCMap = params.fetchBuiltInCMap;
  41585. var useCMap = params.useCMap;
  41586. if (isName(encoding)) {
  41587. return createBuiltInCMap(encoding.name, fetchBuiltInCMap);
  41588. } else if (isStream(encoding)) {
  41589. var cMap = new CMap();
  41590. var lexer = new Lexer(encoding);
  41591. return parseCMap(cMap, lexer, fetchBuiltInCMap, useCMap).then(function (parsedCMap) {
  41592. if (parsedCMap.isIdentityCMap) {
  41593. return createBuiltInCMap(parsedCMap.name, fetchBuiltInCMap);
  41594. }
  41595. return parsedCMap;
  41596. });
  41597. }
  41598. return Promise.reject(new Error('Encoding required.'));
  41599. }
  41600. };
  41601. }();
  41602. exports.CMap = CMap;
  41603. exports.CMapFactory = CMapFactory;
  41604. exports.IdentityCMap = IdentityCMap;
  41605. /***/ }),
  41606. /* 31 */
  41607. /***/ (function(module, exports, __w_pdfjs_require__) {
  41608. "use strict";
  41609. var sharedUtil = __w_pdfjs_require__(0);
  41610. var corePrimitives = __w_pdfjs_require__(1);
  41611. var coreStream = __w_pdfjs_require__(2);
  41612. var coreObj = __w_pdfjs_require__(20);
  41613. var coreParser = __w_pdfjs_require__(6);
  41614. var coreCrypto = __w_pdfjs_require__(17);
  41615. var coreEvaluator = __w_pdfjs_require__(18);
  41616. var coreAnnotation = __w_pdfjs_require__(27);
  41617. var OPS = sharedUtil.OPS;
  41618. var MissingDataException = sharedUtil.MissingDataException;
  41619. var Util = sharedUtil.Util;
  41620. var assert = sharedUtil.assert;
  41621. var error = sharedUtil.error;
  41622. var info = sharedUtil.info;
  41623. var isArray = sharedUtil.isArray;
  41624. var isArrayBuffer = sharedUtil.isArrayBuffer;
  41625. var isNum = sharedUtil.isNum;
  41626. var isString = sharedUtil.isString;
  41627. var shadow = sharedUtil.shadow;
  41628. var stringToBytes = sharedUtil.stringToBytes;
  41629. var stringToPDFString = sharedUtil.stringToPDFString;
  41630. var warn = sharedUtil.warn;
  41631. var isSpace = sharedUtil.isSpace;
  41632. var Dict = corePrimitives.Dict;
  41633. var isDict = corePrimitives.isDict;
  41634. var isName = corePrimitives.isName;
  41635. var isStream = corePrimitives.isStream;
  41636. var NullStream = coreStream.NullStream;
  41637. var Stream = coreStream.Stream;
  41638. var StreamsSequenceStream = coreStream.StreamsSequenceStream;
  41639. var Catalog = coreObj.Catalog;
  41640. var ObjectLoader = coreObj.ObjectLoader;
  41641. var XRef = coreObj.XRef;
  41642. var Linearization = coreParser.Linearization;
  41643. var calculateMD5 = coreCrypto.calculateMD5;
  41644. var OperatorList = coreEvaluator.OperatorList;
  41645. var PartialEvaluator = coreEvaluator.PartialEvaluator;
  41646. var AnnotationFactory = coreAnnotation.AnnotationFactory;
  41647. var Page = function PageClosure() {
  41648. var DEFAULT_USER_UNIT = 1.0;
  41649. var LETTER_SIZE_MEDIABOX = [
  41650. 0,
  41651. 0,
  41652. 612,
  41653. 792
  41654. ];
  41655. function isAnnotationRenderable(annotation, intent) {
  41656. return intent === 'display' && annotation.viewable || intent === 'print' && annotation.printable;
  41657. }
  41658. function Page(pdfManager, xref, pageIndex, pageDict, ref, fontCache, builtInCMapCache) {
  41659. this.pdfManager = pdfManager;
  41660. this.pageIndex = pageIndex;
  41661. this.pageDict = pageDict;
  41662. this.xref = xref;
  41663. this.ref = ref;
  41664. this.fontCache = fontCache;
  41665. this.builtInCMapCache = builtInCMapCache;
  41666. this.evaluatorOptions = pdfManager.evaluatorOptions;
  41667. this.resourcesPromise = null;
  41668. var uniquePrefix = 'p' + this.pageIndex + '_';
  41669. var idCounters = { obj: 0 };
  41670. this.idFactory = {
  41671. createObjId: function () {
  41672. return uniquePrefix + ++idCounters.obj;
  41673. }
  41674. };
  41675. }
  41676. Page.prototype = {
  41677. getPageProp: function Page_getPageProp(key) {
  41678. return this.pageDict.get(key);
  41679. },
  41680. getInheritedPageProp: function Page_getInheritedPageProp(key, getArray) {
  41681. var dict = this.pageDict, valueArray = null, loopCount = 0;
  41682. var MAX_LOOP_COUNT = 100;
  41683. getArray = getArray || false;
  41684. while (dict) {
  41685. var value = getArray ? dict.getArray(key) : dict.get(key);
  41686. if (value !== undefined) {
  41687. if (!valueArray) {
  41688. valueArray = [];
  41689. }
  41690. valueArray.push(value);
  41691. }
  41692. if (++loopCount > MAX_LOOP_COUNT) {
  41693. warn('getInheritedPageProp: maximum loop count exceeded for ' + key);
  41694. return valueArray ? valueArray[0] : undefined;
  41695. }
  41696. dict = dict.get('Parent');
  41697. }
  41698. if (!valueArray) {
  41699. return undefined;
  41700. }
  41701. if (valueArray.length === 1 || !isDict(valueArray[0])) {
  41702. return valueArray[0];
  41703. }
  41704. return Dict.merge(this.xref, valueArray);
  41705. },
  41706. get content() {
  41707. return this.getPageProp('Contents');
  41708. },
  41709. get resources() {
  41710. return shadow(this, 'resources', this.getInheritedPageProp('Resources') || Dict.empty);
  41711. },
  41712. get mediaBox() {
  41713. var mediaBox = this.getInheritedPageProp('MediaBox', true);
  41714. if (!isArray(mediaBox) || mediaBox.length !== 4) {
  41715. return shadow(this, 'mediaBox', LETTER_SIZE_MEDIABOX);
  41716. }
  41717. return shadow(this, 'mediaBox', mediaBox);
  41718. },
  41719. get cropBox() {
  41720. var cropBox = this.getInheritedPageProp('CropBox', true);
  41721. if (!isArray(cropBox) || cropBox.length !== 4) {
  41722. return shadow(this, 'cropBox', this.mediaBox);
  41723. }
  41724. return shadow(this, 'cropBox', cropBox);
  41725. },
  41726. get userUnit() {
  41727. var obj = this.getPageProp('UserUnit');
  41728. if (!isNum(obj) || obj <= 0) {
  41729. obj = DEFAULT_USER_UNIT;
  41730. }
  41731. return shadow(this, 'userUnit', obj);
  41732. },
  41733. get view() {
  41734. var mediaBox = this.mediaBox, cropBox = this.cropBox;
  41735. if (mediaBox === cropBox) {
  41736. return shadow(this, 'view', mediaBox);
  41737. }
  41738. var intersection = Util.intersect(cropBox, mediaBox);
  41739. return shadow(this, 'view', intersection || mediaBox);
  41740. },
  41741. get rotate() {
  41742. var rotate = this.getInheritedPageProp('Rotate') || 0;
  41743. if (rotate % 90 !== 0) {
  41744. rotate = 0;
  41745. } else if (rotate >= 360) {
  41746. rotate = rotate % 360;
  41747. } else if (rotate < 0) {
  41748. rotate = (rotate % 360 + 360) % 360;
  41749. }
  41750. return shadow(this, 'rotate', rotate);
  41751. },
  41752. getContentStream: function Page_getContentStream() {
  41753. var content = this.content;
  41754. var stream;
  41755. if (isArray(content)) {
  41756. var xref = this.xref;
  41757. var i, n = content.length;
  41758. var streams = [];
  41759. for (i = 0; i < n; ++i) {
  41760. streams.push(xref.fetchIfRef(content[i]));
  41761. }
  41762. stream = new StreamsSequenceStream(streams);
  41763. } else if (isStream(content)) {
  41764. stream = content;
  41765. } else {
  41766. stream = new NullStream();
  41767. }
  41768. return stream;
  41769. },
  41770. loadResources: function Page_loadResources(keys) {
  41771. if (!this.resourcesPromise) {
  41772. this.resourcesPromise = this.pdfManager.ensure(this, 'resources');
  41773. }
  41774. return this.resourcesPromise.then(function resourceSuccess() {
  41775. var objectLoader = new ObjectLoader(this.resources.map, keys, this.xref);
  41776. return objectLoader.load();
  41777. }.bind(this));
  41778. },
  41779. getOperatorList: function Page_getOperatorList(handler, task, intent, renderInteractiveForms) {
  41780. var self = this;
  41781. var pdfManager = this.pdfManager;
  41782. var contentStreamPromise = pdfManager.ensure(this, 'getContentStream', []);
  41783. var resourcesPromise = this.loadResources([
  41784. 'ExtGState',
  41785. 'ColorSpace',
  41786. 'Pattern',
  41787. 'Shading',
  41788. 'XObject',
  41789. 'Font'
  41790. ]);
  41791. var partialEvaluator = new PartialEvaluator(pdfManager, this.xref, handler, this.pageIndex, this.idFactory, this.fontCache, this.builtInCMapCache, this.evaluatorOptions);
  41792. var dataPromises = Promise.all([
  41793. contentStreamPromise,
  41794. resourcesPromise
  41795. ]);
  41796. var pageListPromise = dataPromises.then(function (data) {
  41797. var contentStream = data[0];
  41798. var opList = new OperatorList(intent, handler, self.pageIndex);
  41799. handler.send('StartRenderPage', {
  41800. transparency: partialEvaluator.hasBlendModes(self.resources),
  41801. pageIndex: self.pageIndex,
  41802. intent: intent
  41803. });
  41804. return partialEvaluator.getOperatorList(contentStream, task, self.resources, opList).then(function () {
  41805. return opList;
  41806. });
  41807. });
  41808. var annotationsPromise = pdfManager.ensure(this, 'annotations');
  41809. return Promise.all([
  41810. pageListPromise,
  41811. annotationsPromise
  41812. ]).then(function (datas) {
  41813. var pageOpList = datas[0];
  41814. var annotations = datas[1];
  41815. if (annotations.length === 0) {
  41816. pageOpList.flush(true);
  41817. return pageOpList;
  41818. }
  41819. var i, ii, opListPromises = [];
  41820. for (i = 0, ii = annotations.length; i < ii; i++) {
  41821. if (isAnnotationRenderable(annotations[i], intent)) {
  41822. opListPromises.push(annotations[i].getOperatorList(partialEvaluator, task, renderInteractiveForms));
  41823. }
  41824. }
  41825. return Promise.all(opListPromises).then(function (opLists) {
  41826. pageOpList.addOp(OPS.beginAnnotations, []);
  41827. for (i = 0, ii = opLists.length; i < ii; i++) {
  41828. pageOpList.addOpList(opLists[i]);
  41829. }
  41830. pageOpList.addOp(OPS.endAnnotations, []);
  41831. pageOpList.flush(true);
  41832. return pageOpList;
  41833. });
  41834. });
  41835. },
  41836. extractTextContent: function Page_extractTextContent(task, normalizeWhitespace, combineTextItems) {
  41837. var handler = {
  41838. on: function nullHandlerOn() {
  41839. },
  41840. send: function nullHandlerSend() {
  41841. }
  41842. };
  41843. var self = this;
  41844. var pdfManager = this.pdfManager;
  41845. var contentStreamPromise = pdfManager.ensure(this, 'getContentStream', []);
  41846. var resourcesPromise = this.loadResources([
  41847. 'ExtGState',
  41848. 'XObject',
  41849. 'Font'
  41850. ]);
  41851. var dataPromises = Promise.all([
  41852. contentStreamPromise,
  41853. resourcesPromise
  41854. ]);
  41855. return dataPromises.then(function (data) {
  41856. var contentStream = data[0];
  41857. var partialEvaluator = new PartialEvaluator(pdfManager, self.xref, handler, self.pageIndex, self.idFactory, self.fontCache, self.builtInCMapCache, self.evaluatorOptions);
  41858. return partialEvaluator.getTextContent(contentStream, task, self.resources, null, normalizeWhitespace, combineTextItems);
  41859. });
  41860. },
  41861. getAnnotationsData: function Page_getAnnotationsData(intent) {
  41862. var annotations = this.annotations;
  41863. var annotationsData = [];
  41864. for (var i = 0, n = annotations.length; i < n; ++i) {
  41865. if (!intent || isAnnotationRenderable(annotations[i], intent)) {
  41866. annotationsData.push(annotations[i].data);
  41867. }
  41868. }
  41869. return annotationsData;
  41870. },
  41871. get annotations() {
  41872. var annotations = [];
  41873. var annotationRefs = this.getInheritedPageProp('Annots') || [];
  41874. var annotationFactory = new AnnotationFactory();
  41875. for (var i = 0, n = annotationRefs.length; i < n; ++i) {
  41876. var annotationRef = annotationRefs[i];
  41877. var annotation = annotationFactory.create(this.xref, annotationRef, this.pdfManager, this.idFactory);
  41878. if (annotation) {
  41879. annotations.push(annotation);
  41880. }
  41881. }
  41882. return shadow(this, 'annotations', annotations);
  41883. }
  41884. };
  41885. return Page;
  41886. }();
  41887. var PDFDocument = function PDFDocumentClosure() {
  41888. var FINGERPRINT_FIRST_BYTES = 1024;
  41889. var EMPTY_FINGERPRINT = '\x00\x00\x00\x00\x00\x00\x00' + '\x00\x00\x00\x00\x00\x00\x00\x00\x00';
  41890. function PDFDocument(pdfManager, arg) {
  41891. var stream;
  41892. if (isStream(arg)) {
  41893. stream = arg;
  41894. } else if (isArrayBuffer(arg)) {
  41895. stream = new Stream(arg);
  41896. } else {
  41897. error('PDFDocument: Unknown argument type');
  41898. }
  41899. assert(stream.length > 0, 'stream must have data');
  41900. this.pdfManager = pdfManager;
  41901. this.stream = stream;
  41902. this.xref = new XRef(stream, pdfManager);
  41903. }
  41904. function find(stream, needle, limit, backwards) {
  41905. var pos = stream.pos;
  41906. var end = stream.end;
  41907. var strBuf = [];
  41908. if (pos + limit > end) {
  41909. limit = end - pos;
  41910. }
  41911. for (var n = 0; n < limit; ++n) {
  41912. strBuf.push(String.fromCharCode(stream.getByte()));
  41913. }
  41914. var str = strBuf.join('');
  41915. stream.pos = pos;
  41916. var index = backwards ? str.lastIndexOf(needle) : str.indexOf(needle);
  41917. if (index === -1) {
  41918. return false;
  41919. }
  41920. stream.pos += index;
  41921. return true;
  41922. }
  41923. var DocumentInfoValidators = {
  41924. get entries() {
  41925. return shadow(this, 'entries', {
  41926. Title: isString,
  41927. Author: isString,
  41928. Subject: isString,
  41929. Keywords: isString,
  41930. Creator: isString,
  41931. Producer: isString,
  41932. CreationDate: isString,
  41933. ModDate: isString,
  41934. Trapped: isName
  41935. });
  41936. }
  41937. };
  41938. PDFDocument.prototype = {
  41939. parse: function PDFDocument_parse(recoveryMode) {
  41940. this.setup(recoveryMode);
  41941. var version = this.catalog.catDict.get('Version');
  41942. if (isName(version)) {
  41943. this.pdfFormatVersion = version.name;
  41944. }
  41945. try {
  41946. this.acroForm = this.catalog.catDict.get('AcroForm');
  41947. if (this.acroForm) {
  41948. this.xfa = this.acroForm.get('XFA');
  41949. var fields = this.acroForm.get('Fields');
  41950. if ((!fields || !isArray(fields) || fields.length === 0) && !this.xfa) {
  41951. this.acroForm = null;
  41952. }
  41953. }
  41954. } catch (ex) {
  41955. info('Something wrong with AcroForm entry');
  41956. this.acroForm = null;
  41957. }
  41958. },
  41959. get linearization() {
  41960. var linearization = null;
  41961. if (this.stream.length) {
  41962. try {
  41963. linearization = Linearization.create(this.stream);
  41964. } catch (err) {
  41965. if (err instanceof MissingDataException) {
  41966. throw err;
  41967. }
  41968. info(err);
  41969. }
  41970. }
  41971. return shadow(this, 'linearization', linearization);
  41972. },
  41973. get startXRef() {
  41974. var stream = this.stream;
  41975. var startXRef = 0;
  41976. var linearization = this.linearization;
  41977. if (linearization) {
  41978. stream.reset();
  41979. if (find(stream, 'endobj', 1024)) {
  41980. startXRef = stream.pos + 6;
  41981. }
  41982. } else {
  41983. var step = 1024;
  41984. var found = false, pos = stream.end;
  41985. while (!found && pos > 0) {
  41986. pos -= step - 'startxref'.length;
  41987. if (pos < 0) {
  41988. pos = 0;
  41989. }
  41990. stream.pos = pos;
  41991. found = find(stream, 'startxref', step, true);
  41992. }
  41993. if (found) {
  41994. stream.skip(9);
  41995. var ch;
  41996. do {
  41997. ch = stream.getByte();
  41998. } while (isSpace(ch));
  41999. var str = '';
  42000. while (ch >= 0x20 && ch <= 0x39) {
  42001. str += String.fromCharCode(ch);
  42002. ch = stream.getByte();
  42003. }
  42004. startXRef = parseInt(str, 10);
  42005. if (isNaN(startXRef)) {
  42006. startXRef = 0;
  42007. }
  42008. }
  42009. }
  42010. return shadow(this, 'startXRef', startXRef);
  42011. },
  42012. get mainXRefEntriesOffset() {
  42013. var mainXRefEntriesOffset = 0;
  42014. var linearization = this.linearization;
  42015. if (linearization) {
  42016. mainXRefEntriesOffset = linearization.mainXRefEntriesOffset;
  42017. }
  42018. return shadow(this, 'mainXRefEntriesOffset', mainXRefEntriesOffset);
  42019. },
  42020. checkHeader: function PDFDocument_checkHeader() {
  42021. var stream = this.stream;
  42022. stream.reset();
  42023. if (find(stream, '%PDF-', 1024)) {
  42024. stream.moveStart();
  42025. var MAX_VERSION_LENGTH = 12;
  42026. var version = '', ch;
  42027. while ((ch = stream.getByte()) > 0x20) {
  42028. if (version.length >= MAX_VERSION_LENGTH) {
  42029. break;
  42030. }
  42031. version += String.fromCharCode(ch);
  42032. }
  42033. if (!this.pdfFormatVersion) {
  42034. this.pdfFormatVersion = version.substring(5);
  42035. }
  42036. return;
  42037. }
  42038. },
  42039. parseStartXRef: function PDFDocument_parseStartXRef() {
  42040. var startXRef = this.startXRef;
  42041. this.xref.setStartXRef(startXRef);
  42042. },
  42043. setup: function PDFDocument_setup(recoveryMode) {
  42044. this.xref.parse(recoveryMode);
  42045. var self = this;
  42046. var pageFactory = {
  42047. createPage: function (pageIndex, dict, ref, fontCache, builtInCMapCache) {
  42048. return new Page(self.pdfManager, self.xref, pageIndex, dict, ref, fontCache, builtInCMapCache);
  42049. }
  42050. };
  42051. this.catalog = new Catalog(this.pdfManager, this.xref, pageFactory);
  42052. },
  42053. get numPages() {
  42054. var linearization = this.linearization;
  42055. var num = linearization ? linearization.numPages : this.catalog.numPages;
  42056. return shadow(this, 'numPages', num);
  42057. },
  42058. get documentInfo() {
  42059. var docInfo = {
  42060. PDFFormatVersion: this.pdfFormatVersion,
  42061. IsAcroFormPresent: !!this.acroForm,
  42062. IsXFAPresent: !!this.xfa
  42063. };
  42064. var infoDict;
  42065. try {
  42066. infoDict = this.xref.trailer.get('Info');
  42067. } catch (err) {
  42068. info('The document information dictionary is invalid.');
  42069. }
  42070. if (infoDict) {
  42071. var validEntries = DocumentInfoValidators.entries;
  42072. for (var key in validEntries) {
  42073. if (infoDict.has(key)) {
  42074. var value = infoDict.get(key);
  42075. if (validEntries[key](value)) {
  42076. docInfo[key] = typeof value !== 'string' ? value : stringToPDFString(value);
  42077. } else {
  42078. info('Bad value in document info for "' + key + '"');
  42079. }
  42080. }
  42081. }
  42082. }
  42083. return shadow(this, 'documentInfo', docInfo);
  42084. },
  42085. get fingerprint() {
  42086. var xref = this.xref, hash, fileID = '';
  42087. var idArray = xref.trailer.get('ID');
  42088. if (idArray && isArray(idArray) && idArray[0] && isString(idArray[0]) && idArray[0] !== EMPTY_FINGERPRINT) {
  42089. hash = stringToBytes(idArray[0]);
  42090. } else {
  42091. if (this.stream.ensureRange) {
  42092. this.stream.ensureRange(0, Math.min(FINGERPRINT_FIRST_BYTES, this.stream.end));
  42093. }
  42094. hash = calculateMD5(this.stream.bytes.subarray(0, FINGERPRINT_FIRST_BYTES), 0, FINGERPRINT_FIRST_BYTES);
  42095. }
  42096. for (var i = 0, n = hash.length; i < n; i++) {
  42097. var hex = hash[i].toString(16);
  42098. fileID += hex.length === 1 ? '0' + hex : hex;
  42099. }
  42100. return shadow(this, 'fingerprint', fileID);
  42101. },
  42102. getPage: function PDFDocument_getPage(pageIndex) {
  42103. return this.catalog.getPage(pageIndex);
  42104. },
  42105. cleanup: function PDFDocument_cleanup() {
  42106. return this.catalog.cleanup();
  42107. }
  42108. };
  42109. return PDFDocument;
  42110. }();
  42111. exports.Page = Page;
  42112. exports.PDFDocument = PDFDocument;
  42113. /***/ }),
  42114. /* 32 */
  42115. /***/ (function(module, exports, __w_pdfjs_require__) {
  42116. "use strict";
  42117. var sharedUtil = __w_pdfjs_require__(0);
  42118. var coreStream = __w_pdfjs_require__(2);
  42119. var coreGlyphList = __w_pdfjs_require__(8);
  42120. var coreEncodings = __w_pdfjs_require__(5);
  42121. var coreCFFParser = __w_pdfjs_require__(15);
  42122. var Util = sharedUtil.Util;
  42123. var bytesToString = sharedUtil.bytesToString;
  42124. var error = sharedUtil.error;
  42125. var Stream = coreStream.Stream;
  42126. var getGlyphsUnicode = coreGlyphList.getGlyphsUnicode;
  42127. var StandardEncoding = coreEncodings.StandardEncoding;
  42128. var CFFParser = coreCFFParser.CFFParser;
  42129. var FontRendererFactory = function FontRendererFactoryClosure() {
  42130. function getLong(data, offset) {
  42131. return data[offset] << 24 | data[offset + 1] << 16 | data[offset + 2] << 8 | data[offset + 3];
  42132. }
  42133. function getUshort(data, offset) {
  42134. return data[offset] << 8 | data[offset + 1];
  42135. }
  42136. function parseCmap(data, start, end) {
  42137. var offset = getUshort(data, start + 2) === 1 ? getLong(data, start + 8) : getLong(data, start + 16);
  42138. var format = getUshort(data, start + offset);
  42139. var ranges, p, i;
  42140. if (format === 4) {
  42141. getUshort(data, start + offset + 2);
  42142. var segCount = getUshort(data, start + offset + 6) >> 1;
  42143. p = start + offset + 14;
  42144. ranges = [];
  42145. for (i = 0; i < segCount; i++, p += 2) {
  42146. ranges[i] = { end: getUshort(data, p) };
  42147. }
  42148. p += 2;
  42149. for (i = 0; i < segCount; i++, p += 2) {
  42150. ranges[i].start = getUshort(data, p);
  42151. }
  42152. for (i = 0; i < segCount; i++, p += 2) {
  42153. ranges[i].idDelta = getUshort(data, p);
  42154. }
  42155. for (i = 0; i < segCount; i++, p += 2) {
  42156. var idOffset = getUshort(data, p);
  42157. if (idOffset === 0) {
  42158. continue;
  42159. }
  42160. ranges[i].ids = [];
  42161. for (var j = 0, jj = ranges[i].end - ranges[i].start + 1; j < jj; j++) {
  42162. ranges[i].ids[j] = getUshort(data, p + idOffset);
  42163. idOffset += 2;
  42164. }
  42165. }
  42166. return ranges;
  42167. } else if (format === 12) {
  42168. getLong(data, start + offset + 4);
  42169. var groups = getLong(data, start + offset + 12);
  42170. p = start + offset + 16;
  42171. ranges = [];
  42172. for (i = 0; i < groups; i++) {
  42173. ranges.push({
  42174. start: getLong(data, p),
  42175. end: getLong(data, p + 4),
  42176. idDelta: getLong(data, p + 8) - getLong(data, p)
  42177. });
  42178. p += 12;
  42179. }
  42180. return ranges;
  42181. }
  42182. error('not supported cmap: ' + format);
  42183. }
  42184. function parseCff(data, start, end, seacAnalysisEnabled) {
  42185. var properties = {};
  42186. var parser = new CFFParser(new Stream(data, start, end - start), properties, seacAnalysisEnabled);
  42187. var cff = parser.parse();
  42188. return {
  42189. glyphs: cff.charStrings.objects,
  42190. subrs: cff.topDict.privateDict && cff.topDict.privateDict.subrsIndex && cff.topDict.privateDict.subrsIndex.objects,
  42191. gsubrs: cff.globalSubrIndex && cff.globalSubrIndex.objects
  42192. };
  42193. }
  42194. function parseGlyfTable(glyf, loca, isGlyphLocationsLong) {
  42195. var itemSize, itemDecode;
  42196. if (isGlyphLocationsLong) {
  42197. itemSize = 4;
  42198. itemDecode = function fontItemDecodeLong(data, offset) {
  42199. return data[offset] << 24 | data[offset + 1] << 16 | data[offset + 2] << 8 | data[offset + 3];
  42200. };
  42201. } else {
  42202. itemSize = 2;
  42203. itemDecode = function fontItemDecode(data, offset) {
  42204. return data[offset] << 9 | data[offset + 1] << 1;
  42205. };
  42206. }
  42207. var glyphs = [];
  42208. var startOffset = itemDecode(loca, 0);
  42209. for (var j = itemSize; j < loca.length; j += itemSize) {
  42210. var endOffset = itemDecode(loca, j);
  42211. glyphs.push(glyf.subarray(startOffset, endOffset));
  42212. startOffset = endOffset;
  42213. }
  42214. return glyphs;
  42215. }
  42216. function lookupCmap(ranges, unicode) {
  42217. var code = unicode.charCodeAt(0), gid = 0;
  42218. var l = 0, r = ranges.length - 1;
  42219. while (l < r) {
  42220. var c = l + r + 1 >> 1;
  42221. if (code < ranges[c].start) {
  42222. r = c - 1;
  42223. } else {
  42224. l = c;
  42225. }
  42226. }
  42227. if (ranges[l].start <= code && code <= ranges[l].end) {
  42228. gid = ranges[l].idDelta + (ranges[l].ids ? ranges[l].ids[code - ranges[l].start] : code) & 0xFFFF;
  42229. }
  42230. return {
  42231. charCode: code,
  42232. glyphId: gid
  42233. };
  42234. }
  42235. function compileGlyf(code, cmds, font) {
  42236. function moveTo(x, y) {
  42237. cmds.push({
  42238. cmd: 'moveTo',
  42239. args: [
  42240. x,
  42241. y
  42242. ]
  42243. });
  42244. }
  42245. function lineTo(x, y) {
  42246. cmds.push({
  42247. cmd: 'lineTo',
  42248. args: [
  42249. x,
  42250. y
  42251. ]
  42252. });
  42253. }
  42254. function quadraticCurveTo(xa, ya, x, y) {
  42255. cmds.push({
  42256. cmd: 'quadraticCurveTo',
  42257. args: [
  42258. xa,
  42259. ya,
  42260. x,
  42261. y
  42262. ]
  42263. });
  42264. }
  42265. var i = 0;
  42266. var numberOfContours = (code[i] << 24 | code[i + 1] << 16) >> 16;
  42267. var flags;
  42268. var x = 0, y = 0;
  42269. i += 10;
  42270. if (numberOfContours < 0) {
  42271. do {
  42272. flags = code[i] << 8 | code[i + 1];
  42273. var glyphIndex = code[i + 2] << 8 | code[i + 3];
  42274. i += 4;
  42275. var arg1, arg2;
  42276. if (flags & 0x01) {
  42277. arg1 = (code[i] << 24 | code[i + 1] << 16) >> 16;
  42278. arg2 = (code[i + 2] << 24 | code[i + 3] << 16) >> 16;
  42279. i += 4;
  42280. } else {
  42281. arg1 = code[i++];
  42282. arg2 = code[i++];
  42283. }
  42284. if (flags & 0x02) {
  42285. x = arg1;
  42286. y = arg2;
  42287. } else {
  42288. x = 0;
  42289. y = 0;
  42290. }
  42291. var scaleX = 1, scaleY = 1, scale01 = 0, scale10 = 0;
  42292. if (flags & 0x08) {
  42293. scaleX = scaleY = (code[i] << 24 | code[i + 1] << 16) / 1073741824;
  42294. i += 2;
  42295. } else if (flags & 0x40) {
  42296. scaleX = (code[i] << 24 | code[i + 1] << 16) / 1073741824;
  42297. scaleY = (code[i + 2] << 24 | code[i + 3] << 16) / 1073741824;
  42298. i += 4;
  42299. } else if (flags & 0x80) {
  42300. scaleX = (code[i] << 24 | code[i + 1] << 16) / 1073741824;
  42301. scale01 = (code[i + 2] << 24 | code[i + 3] << 16) / 1073741824;
  42302. scale10 = (code[i + 4] << 24 | code[i + 5] << 16) / 1073741824;
  42303. scaleY = (code[i + 6] << 24 | code[i + 7] << 16) / 1073741824;
  42304. i += 8;
  42305. }
  42306. var subglyph = font.glyphs[glyphIndex];
  42307. if (subglyph) {
  42308. cmds.push({ cmd: 'save' });
  42309. cmds.push({
  42310. cmd: 'transform',
  42311. args: [
  42312. scaleX,
  42313. scale01,
  42314. scale10,
  42315. scaleY,
  42316. x,
  42317. y
  42318. ]
  42319. });
  42320. compileGlyf(subglyph, cmds, font);
  42321. cmds.push({ cmd: 'restore' });
  42322. }
  42323. } while (flags & 0x20);
  42324. } else {
  42325. var endPtsOfContours = [];
  42326. var j, jj;
  42327. for (j = 0; j < numberOfContours; j++) {
  42328. endPtsOfContours.push(code[i] << 8 | code[i + 1]);
  42329. i += 2;
  42330. }
  42331. var instructionLength = code[i] << 8 | code[i + 1];
  42332. i += 2 + instructionLength;
  42333. var numberOfPoints = endPtsOfContours[endPtsOfContours.length - 1] + 1;
  42334. var points = [];
  42335. while (points.length < numberOfPoints) {
  42336. flags = code[i++];
  42337. var repeat = 1;
  42338. if (flags & 0x08) {
  42339. repeat += code[i++];
  42340. }
  42341. while (repeat-- > 0) {
  42342. points.push({ flags: flags });
  42343. }
  42344. }
  42345. for (j = 0; j < numberOfPoints; j++) {
  42346. switch (points[j].flags & 0x12) {
  42347. case 0x00:
  42348. x += (code[i] << 24 | code[i + 1] << 16) >> 16;
  42349. i += 2;
  42350. break;
  42351. case 0x02:
  42352. x -= code[i++];
  42353. break;
  42354. case 0x12:
  42355. x += code[i++];
  42356. break;
  42357. }
  42358. points[j].x = x;
  42359. }
  42360. for (j = 0; j < numberOfPoints; j++) {
  42361. switch (points[j].flags & 0x24) {
  42362. case 0x00:
  42363. y += (code[i] << 24 | code[i + 1] << 16) >> 16;
  42364. i += 2;
  42365. break;
  42366. case 0x04:
  42367. y -= code[i++];
  42368. break;
  42369. case 0x24:
  42370. y += code[i++];
  42371. break;
  42372. }
  42373. points[j].y = y;
  42374. }
  42375. var startPoint = 0;
  42376. for (i = 0; i < numberOfContours; i++) {
  42377. var endPoint = endPtsOfContours[i];
  42378. var contour = points.slice(startPoint, endPoint + 1);
  42379. if (contour[0].flags & 1) {
  42380. contour.push(contour[0]);
  42381. } else if (contour[contour.length - 1].flags & 1) {
  42382. contour.unshift(contour[contour.length - 1]);
  42383. } else {
  42384. var p = {
  42385. flags: 1,
  42386. x: (contour[0].x + contour[contour.length - 1].x) / 2,
  42387. y: (contour[0].y + contour[contour.length - 1].y) / 2
  42388. };
  42389. contour.unshift(p);
  42390. contour.push(p);
  42391. }
  42392. moveTo(contour[0].x, contour[0].y);
  42393. for (j = 1, jj = contour.length; j < jj; j++) {
  42394. if (contour[j].flags & 1) {
  42395. lineTo(contour[j].x, contour[j].y);
  42396. } else if (contour[j + 1].flags & 1) {
  42397. quadraticCurveTo(contour[j].x, contour[j].y, contour[j + 1].x, contour[j + 1].y);
  42398. j++;
  42399. } else {
  42400. quadraticCurveTo(contour[j].x, contour[j].y, (contour[j].x + contour[j + 1].x) / 2, (contour[j].y + contour[j + 1].y) / 2);
  42401. }
  42402. }
  42403. startPoint = endPoint + 1;
  42404. }
  42405. }
  42406. }
  42407. function compileCharString(code, cmds, font) {
  42408. var stack = [];
  42409. var x = 0, y = 0;
  42410. var stems = 0;
  42411. function moveTo(x, y) {
  42412. cmds.push({
  42413. cmd: 'moveTo',
  42414. args: [
  42415. x,
  42416. y
  42417. ]
  42418. });
  42419. }
  42420. function lineTo(x, y) {
  42421. cmds.push({
  42422. cmd: 'lineTo',
  42423. args: [
  42424. x,
  42425. y
  42426. ]
  42427. });
  42428. }
  42429. function bezierCurveTo(x1, y1, x2, y2, x, y) {
  42430. cmds.push({
  42431. cmd: 'bezierCurveTo',
  42432. args: [
  42433. x1,
  42434. y1,
  42435. x2,
  42436. y2,
  42437. x,
  42438. y
  42439. ]
  42440. });
  42441. }
  42442. function parse(code) {
  42443. var i = 0;
  42444. while (i < code.length) {
  42445. var stackClean = false;
  42446. var v = code[i++];
  42447. var xa, xb, ya, yb, y1, y2, y3, n, subrCode;
  42448. switch (v) {
  42449. case 1:
  42450. stems += stack.length >> 1;
  42451. stackClean = true;
  42452. break;
  42453. case 3:
  42454. stems += stack.length >> 1;
  42455. stackClean = true;
  42456. break;
  42457. case 4:
  42458. y += stack.pop();
  42459. moveTo(x, y);
  42460. stackClean = true;
  42461. break;
  42462. case 5:
  42463. while (stack.length > 0) {
  42464. x += stack.shift();
  42465. y += stack.shift();
  42466. lineTo(x, y);
  42467. }
  42468. break;
  42469. case 6:
  42470. while (stack.length > 0) {
  42471. x += stack.shift();
  42472. lineTo(x, y);
  42473. if (stack.length === 0) {
  42474. break;
  42475. }
  42476. y += stack.shift();
  42477. lineTo(x, y);
  42478. }
  42479. break;
  42480. case 7:
  42481. while (stack.length > 0) {
  42482. y += stack.shift();
  42483. lineTo(x, y);
  42484. if (stack.length === 0) {
  42485. break;
  42486. }
  42487. x += stack.shift();
  42488. lineTo(x, y);
  42489. }
  42490. break;
  42491. case 8:
  42492. while (stack.length > 0) {
  42493. xa = x + stack.shift();
  42494. ya = y + stack.shift();
  42495. xb = xa + stack.shift();
  42496. yb = ya + stack.shift();
  42497. x = xb + stack.shift();
  42498. y = yb + stack.shift();
  42499. bezierCurveTo(xa, ya, xb, yb, x, y);
  42500. }
  42501. break;
  42502. case 10:
  42503. n = stack.pop() + font.subrsBias;
  42504. subrCode = font.subrs[n];
  42505. if (subrCode) {
  42506. parse(subrCode);
  42507. }
  42508. break;
  42509. case 11:
  42510. return;
  42511. case 12:
  42512. v = code[i++];
  42513. switch (v) {
  42514. case 34:
  42515. xa = x + stack.shift();
  42516. xb = xa + stack.shift();
  42517. y1 = y + stack.shift();
  42518. x = xb + stack.shift();
  42519. bezierCurveTo(xa, y, xb, y1, x, y1);
  42520. xa = x + stack.shift();
  42521. xb = xa + stack.shift();
  42522. x = xb + stack.shift();
  42523. bezierCurveTo(xa, y1, xb, y, x, y);
  42524. break;
  42525. case 35:
  42526. xa = x + stack.shift();
  42527. ya = y + stack.shift();
  42528. xb = xa + stack.shift();
  42529. yb = ya + stack.shift();
  42530. x = xb + stack.shift();
  42531. y = yb + stack.shift();
  42532. bezierCurveTo(xa, ya, xb, yb, x, y);
  42533. xa = x + stack.shift();
  42534. ya = y + stack.shift();
  42535. xb = xa + stack.shift();
  42536. yb = ya + stack.shift();
  42537. x = xb + stack.shift();
  42538. y = yb + stack.shift();
  42539. bezierCurveTo(xa, ya, xb, yb, x, y);
  42540. stack.pop();
  42541. break;
  42542. case 36:
  42543. xa = x + stack.shift();
  42544. y1 = y + stack.shift();
  42545. xb = xa + stack.shift();
  42546. y2 = y1 + stack.shift();
  42547. x = xb + stack.shift();
  42548. bezierCurveTo(xa, y1, xb, y2, x, y2);
  42549. xa = x + stack.shift();
  42550. xb = xa + stack.shift();
  42551. y3 = y2 + stack.shift();
  42552. x = xb + stack.shift();
  42553. bezierCurveTo(xa, y2, xb, y3, x, y);
  42554. break;
  42555. case 37:
  42556. var x0 = x, y0 = y;
  42557. xa = x + stack.shift();
  42558. ya = y + stack.shift();
  42559. xb = xa + stack.shift();
  42560. yb = ya + stack.shift();
  42561. x = xb + stack.shift();
  42562. y = yb + stack.shift();
  42563. bezierCurveTo(xa, ya, xb, yb, x, y);
  42564. xa = x + stack.shift();
  42565. ya = y + stack.shift();
  42566. xb = xa + stack.shift();
  42567. yb = ya + stack.shift();
  42568. x = xb;
  42569. y = yb;
  42570. if (Math.abs(x - x0) > Math.abs(y - y0)) {
  42571. x += stack.shift();
  42572. } else {
  42573. y += stack.shift();
  42574. }
  42575. bezierCurveTo(xa, ya, xb, yb, x, y);
  42576. break;
  42577. default:
  42578. error('unknown operator: 12 ' + v);
  42579. }
  42580. break;
  42581. case 14:
  42582. if (stack.length >= 4) {
  42583. var achar = stack.pop();
  42584. var bchar = stack.pop();
  42585. y = stack.pop();
  42586. x = stack.pop();
  42587. cmds.push({ cmd: 'save' });
  42588. cmds.push({
  42589. cmd: 'translate',
  42590. args: [
  42591. x,
  42592. y
  42593. ]
  42594. });
  42595. var cmap = lookupCmap(font.cmap, String.fromCharCode(font.glyphNameMap[StandardEncoding[achar]]));
  42596. compileCharString(font.glyphs[cmap.glyphId], cmds, font);
  42597. cmds.push({ cmd: 'restore' });
  42598. cmap = lookupCmap(font.cmap, String.fromCharCode(font.glyphNameMap[StandardEncoding[bchar]]));
  42599. compileCharString(font.glyphs[cmap.glyphId], cmds, font);
  42600. }
  42601. return;
  42602. case 18:
  42603. stems += stack.length >> 1;
  42604. stackClean = true;
  42605. break;
  42606. case 19:
  42607. stems += stack.length >> 1;
  42608. i += stems + 7 >> 3;
  42609. stackClean = true;
  42610. break;
  42611. case 20:
  42612. stems += stack.length >> 1;
  42613. i += stems + 7 >> 3;
  42614. stackClean = true;
  42615. break;
  42616. case 21:
  42617. y += stack.pop();
  42618. x += stack.pop();
  42619. moveTo(x, y);
  42620. stackClean = true;
  42621. break;
  42622. case 22:
  42623. x += stack.pop();
  42624. moveTo(x, y);
  42625. stackClean = true;
  42626. break;
  42627. case 23:
  42628. stems += stack.length >> 1;
  42629. stackClean = true;
  42630. break;
  42631. case 24:
  42632. while (stack.length > 2) {
  42633. xa = x + stack.shift();
  42634. ya = y + stack.shift();
  42635. xb = xa + stack.shift();
  42636. yb = ya + stack.shift();
  42637. x = xb + stack.shift();
  42638. y = yb + stack.shift();
  42639. bezierCurveTo(xa, ya, xb, yb, x, y);
  42640. }
  42641. x += stack.shift();
  42642. y += stack.shift();
  42643. lineTo(x, y);
  42644. break;
  42645. case 25:
  42646. while (stack.length > 6) {
  42647. x += stack.shift();
  42648. y += stack.shift();
  42649. lineTo(x, y);
  42650. }
  42651. xa = x + stack.shift();
  42652. ya = y + stack.shift();
  42653. xb = xa + stack.shift();
  42654. yb = ya + stack.shift();
  42655. x = xb + stack.shift();
  42656. y = yb + stack.shift();
  42657. bezierCurveTo(xa, ya, xb, yb, x, y);
  42658. break;
  42659. case 26:
  42660. if (stack.length % 2) {
  42661. x += stack.shift();
  42662. }
  42663. while (stack.length > 0) {
  42664. xa = x;
  42665. ya = y + stack.shift();
  42666. xb = xa + stack.shift();
  42667. yb = ya + stack.shift();
  42668. x = xb;
  42669. y = yb + stack.shift();
  42670. bezierCurveTo(xa, ya, xb, yb, x, y);
  42671. }
  42672. break;
  42673. case 27:
  42674. if (stack.length % 2) {
  42675. y += stack.shift();
  42676. }
  42677. while (stack.length > 0) {
  42678. xa = x + stack.shift();
  42679. ya = y;
  42680. xb = xa + stack.shift();
  42681. yb = ya + stack.shift();
  42682. x = xb + stack.shift();
  42683. y = yb;
  42684. bezierCurveTo(xa, ya, xb, yb, x, y);
  42685. }
  42686. break;
  42687. case 28:
  42688. stack.push((code[i] << 24 | code[i + 1] << 16) >> 16);
  42689. i += 2;
  42690. break;
  42691. case 29:
  42692. n = stack.pop() + font.gsubrsBias;
  42693. subrCode = font.gsubrs[n];
  42694. if (subrCode) {
  42695. parse(subrCode);
  42696. }
  42697. break;
  42698. case 30:
  42699. while (stack.length > 0) {
  42700. xa = x;
  42701. ya = y + stack.shift();
  42702. xb = xa + stack.shift();
  42703. yb = ya + stack.shift();
  42704. x = xb + stack.shift();
  42705. y = yb + (stack.length === 1 ? stack.shift() : 0);
  42706. bezierCurveTo(xa, ya, xb, yb, x, y);
  42707. if (stack.length === 0) {
  42708. break;
  42709. }
  42710. xa = x + stack.shift();
  42711. ya = y;
  42712. xb = xa + stack.shift();
  42713. yb = ya + stack.shift();
  42714. y = yb + stack.shift();
  42715. x = xb + (stack.length === 1 ? stack.shift() : 0);
  42716. bezierCurveTo(xa, ya, xb, yb, x, y);
  42717. }
  42718. break;
  42719. case 31:
  42720. while (stack.length > 0) {
  42721. xa = x + stack.shift();
  42722. ya = y;
  42723. xb = xa + stack.shift();
  42724. yb = ya + stack.shift();
  42725. y = yb + stack.shift();
  42726. x = xb + (stack.length === 1 ? stack.shift() : 0);
  42727. bezierCurveTo(xa, ya, xb, yb, x, y);
  42728. if (stack.length === 0) {
  42729. break;
  42730. }
  42731. xa = x;
  42732. ya = y + stack.shift();
  42733. xb = xa + stack.shift();
  42734. yb = ya + stack.shift();
  42735. x = xb + stack.shift();
  42736. y = yb + (stack.length === 1 ? stack.shift() : 0);
  42737. bezierCurveTo(xa, ya, xb, yb, x, y);
  42738. }
  42739. break;
  42740. default:
  42741. if (v < 32) {
  42742. error('unknown operator: ' + v);
  42743. }
  42744. if (v < 247) {
  42745. stack.push(v - 139);
  42746. } else if (v < 251) {
  42747. stack.push((v - 247) * 256 + code[i++] + 108);
  42748. } else if (v < 255) {
  42749. stack.push(-(v - 251) * 256 - code[i++] - 108);
  42750. } else {
  42751. stack.push((code[i] << 24 | code[i + 1] << 16 | code[i + 2] << 8 | code[i + 3]) / 65536);
  42752. i += 4;
  42753. }
  42754. break;
  42755. }
  42756. if (stackClean) {
  42757. stack.length = 0;
  42758. }
  42759. }
  42760. }
  42761. parse(code);
  42762. }
  42763. var noop = '';
  42764. function CompiledFont(fontMatrix) {
  42765. this.compiledGlyphs = Object.create(null);
  42766. this.compiledCharCodeToGlyphId = Object.create(null);
  42767. this.fontMatrix = fontMatrix;
  42768. }
  42769. CompiledFont.prototype = {
  42770. getPathJs: function (unicode) {
  42771. var cmap = lookupCmap(this.cmap, unicode);
  42772. var fn = this.compiledGlyphs[cmap.glyphId];
  42773. if (!fn) {
  42774. fn = this.compileGlyph(this.glyphs[cmap.glyphId]);
  42775. this.compiledGlyphs[cmap.glyphId] = fn;
  42776. }
  42777. if (this.compiledCharCodeToGlyphId[cmap.charCode] === undefined) {
  42778. this.compiledCharCodeToGlyphId[cmap.charCode] = cmap.glyphId;
  42779. }
  42780. return fn;
  42781. },
  42782. compileGlyph: function (code) {
  42783. if (!code || code.length === 0 || code[0] === 14) {
  42784. return noop;
  42785. }
  42786. var cmds = [];
  42787. cmds.push({ cmd: 'save' });
  42788. cmds.push({
  42789. cmd: 'transform',
  42790. args: this.fontMatrix.slice()
  42791. });
  42792. cmds.push({
  42793. cmd: 'scale',
  42794. args: [
  42795. 'size',
  42796. '-size'
  42797. ]
  42798. });
  42799. this.compileGlyphImpl(code, cmds);
  42800. cmds.push({ cmd: 'restore' });
  42801. return cmds;
  42802. },
  42803. compileGlyphImpl: function () {
  42804. error('Children classes should implement this.');
  42805. },
  42806. hasBuiltPath: function (unicode) {
  42807. var cmap = lookupCmap(this.cmap, unicode);
  42808. return this.compiledGlyphs[cmap.glyphId] !== undefined && this.compiledCharCodeToGlyphId[cmap.charCode] !== undefined;
  42809. }
  42810. };
  42811. function TrueTypeCompiled(glyphs, cmap, fontMatrix) {
  42812. fontMatrix = fontMatrix || [
  42813. 0.000488,
  42814. 0,
  42815. 0,
  42816. 0.000488,
  42817. 0,
  42818. 0
  42819. ];
  42820. CompiledFont.call(this, fontMatrix);
  42821. this.glyphs = glyphs;
  42822. this.cmap = cmap;
  42823. }
  42824. Util.inherit(TrueTypeCompiled, CompiledFont, {
  42825. compileGlyphImpl: function (code, cmds) {
  42826. compileGlyf(code, cmds, this);
  42827. }
  42828. });
  42829. function Type2Compiled(cffInfo, cmap, fontMatrix, glyphNameMap) {
  42830. fontMatrix = fontMatrix || [
  42831. 0.001,
  42832. 0,
  42833. 0,
  42834. 0.001,
  42835. 0,
  42836. 0
  42837. ];
  42838. CompiledFont.call(this, fontMatrix);
  42839. this.glyphs = cffInfo.glyphs;
  42840. this.gsubrs = cffInfo.gsubrs || [];
  42841. this.subrs = cffInfo.subrs || [];
  42842. this.cmap = cmap;
  42843. this.glyphNameMap = glyphNameMap || getGlyphsUnicode();
  42844. this.gsubrsBias = this.gsubrs.length < 1240 ? 107 : this.gsubrs.length < 33900 ? 1131 : 32768;
  42845. this.subrsBias = this.subrs.length < 1240 ? 107 : this.subrs.length < 33900 ? 1131 : 32768;
  42846. }
  42847. Util.inherit(Type2Compiled, CompiledFont, {
  42848. compileGlyphImpl: function (code, cmds) {
  42849. compileCharString(code, cmds, this);
  42850. }
  42851. });
  42852. return {
  42853. create: function FontRendererFactory_create(font, seacAnalysisEnabled) {
  42854. var data = new Uint8Array(font.data);
  42855. var cmap, glyf, loca, cff, indexToLocFormat, unitsPerEm;
  42856. var numTables = getUshort(data, 4);
  42857. for (var i = 0, p = 12; i < numTables; i++, p += 16) {
  42858. var tag = bytesToString(data.subarray(p, p + 4));
  42859. var offset = getLong(data, p + 8);
  42860. var length = getLong(data, p + 12);
  42861. switch (tag) {
  42862. case 'cmap':
  42863. cmap = parseCmap(data, offset, offset + length);
  42864. break;
  42865. case 'glyf':
  42866. glyf = data.subarray(offset, offset + length);
  42867. break;
  42868. case 'loca':
  42869. loca = data.subarray(offset, offset + length);
  42870. break;
  42871. case 'head':
  42872. unitsPerEm = getUshort(data, offset + 18);
  42873. indexToLocFormat = getUshort(data, offset + 50);
  42874. break;
  42875. case 'CFF ':
  42876. cff = parseCff(data, offset, offset + length, seacAnalysisEnabled);
  42877. break;
  42878. }
  42879. }
  42880. if (glyf) {
  42881. var fontMatrix = !unitsPerEm ? font.fontMatrix : [
  42882. 1 / unitsPerEm,
  42883. 0,
  42884. 0,
  42885. 1 / unitsPerEm,
  42886. 0,
  42887. 0
  42888. ];
  42889. return new TrueTypeCompiled(parseGlyfTable(glyf, loca, indexToLocFormat), cmap, fontMatrix);
  42890. }
  42891. return new Type2Compiled(cff, cmap, font.fontMatrix, font.glyphNameMap);
  42892. }
  42893. };
  42894. }();
  42895. exports.FontRendererFactory = FontRendererFactory;
  42896. /***/ }),
  42897. /* 33 */
  42898. /***/ (function(module, exports, __w_pdfjs_require__) {
  42899. "use strict";
  42900. var sharedUtil = __w_pdfjs_require__(0);
  42901. var corePrimitives = __w_pdfjs_require__(1);
  42902. var coreStream = __w_pdfjs_require__(2);
  42903. var coreGlyphList = __w_pdfjs_require__(8);
  42904. var coreFontRenderer = __w_pdfjs_require__(32);
  42905. var coreEncodings = __w_pdfjs_require__(5);
  42906. var coreStandardFonts = __w_pdfjs_require__(21);
  42907. var coreUnicode = __w_pdfjs_require__(22);
  42908. var coreType1Parser = __w_pdfjs_require__(43);
  42909. var coreCFFParser = __w_pdfjs_require__(15);
  42910. var FONT_IDENTITY_MATRIX = sharedUtil.FONT_IDENTITY_MATRIX;
  42911. var FontType = sharedUtil.FontType;
  42912. var assert = sharedUtil.assert;
  42913. var bytesToString = sharedUtil.bytesToString;
  42914. var error = sharedUtil.error;
  42915. var info = sharedUtil.info;
  42916. var isArray = sharedUtil.isArray;
  42917. var isInt = sharedUtil.isInt;
  42918. var isNum = sharedUtil.isNum;
  42919. var readUint32 = sharedUtil.readUint32;
  42920. var shadow = sharedUtil.shadow;
  42921. var string32 = sharedUtil.string32;
  42922. var warn = sharedUtil.warn;
  42923. var MissingDataException = sharedUtil.MissingDataException;
  42924. var isSpace = sharedUtil.isSpace;
  42925. var Stream = coreStream.Stream;
  42926. var getGlyphsUnicode = coreGlyphList.getGlyphsUnicode;
  42927. var getDingbatsGlyphsUnicode = coreGlyphList.getDingbatsGlyphsUnicode;
  42928. var FontRendererFactory = coreFontRenderer.FontRendererFactory;
  42929. var StandardEncoding = coreEncodings.StandardEncoding;
  42930. var MacRomanEncoding = coreEncodings.MacRomanEncoding;
  42931. var SymbolSetEncoding = coreEncodings.SymbolSetEncoding;
  42932. var ZapfDingbatsEncoding = coreEncodings.ZapfDingbatsEncoding;
  42933. var getEncoding = coreEncodings.getEncoding;
  42934. var getStdFontMap = coreStandardFonts.getStdFontMap;
  42935. var getNonStdFontMap = coreStandardFonts.getNonStdFontMap;
  42936. var getGlyphMapForStandardFonts = coreStandardFonts.getGlyphMapForStandardFonts;
  42937. var getSupplementalGlyphMapForArialBlack = coreStandardFonts.getSupplementalGlyphMapForArialBlack;
  42938. var getUnicodeRangeFor = coreUnicode.getUnicodeRangeFor;
  42939. var mapSpecialUnicodeValues = coreUnicode.mapSpecialUnicodeValues;
  42940. var getUnicodeForGlyph = coreUnicode.getUnicodeForGlyph;
  42941. var Type1Parser = coreType1Parser.Type1Parser;
  42942. var CFFStandardStrings = coreCFFParser.CFFStandardStrings;
  42943. var CFFParser = coreCFFParser.CFFParser;
  42944. var CFFCompiler = coreCFFParser.CFFCompiler;
  42945. var CFF = coreCFFParser.CFF;
  42946. var CFFHeader = coreCFFParser.CFFHeader;
  42947. var CFFTopDict = coreCFFParser.CFFTopDict;
  42948. var CFFPrivateDict = coreCFFParser.CFFPrivateDict;
  42949. var CFFStrings = coreCFFParser.CFFStrings;
  42950. var CFFIndex = coreCFFParser.CFFIndex;
  42951. var CFFCharset = coreCFFParser.CFFCharset;
  42952. var PRIVATE_USE_OFFSET_START = 0xE000;
  42953. var PRIVATE_USE_OFFSET_END = 0xF8FF;
  42954. var SKIP_PRIVATE_USE_RANGE_F000_TO_F01F = false;
  42955. var PDF_GLYPH_SPACE_UNITS = 1000;
  42956. var SEAC_ANALYSIS_ENABLED = false;
  42957. var FontFlags = {
  42958. FixedPitch: 1,
  42959. Serif: 2,
  42960. Symbolic: 4,
  42961. Script: 8,
  42962. Nonsymbolic: 32,
  42963. Italic: 64,
  42964. AllCap: 65536,
  42965. SmallCap: 131072,
  42966. ForceBold: 262144
  42967. };
  42968. var MacStandardGlyphOrdering = [
  42969. '.notdef',
  42970. '.null',
  42971. 'nonmarkingreturn',
  42972. 'space',
  42973. 'exclam',
  42974. 'quotedbl',
  42975. 'numbersign',
  42976. 'dollar',
  42977. 'percent',
  42978. 'ampersand',
  42979. 'quotesingle',
  42980. 'parenleft',
  42981. 'parenright',
  42982. 'asterisk',
  42983. 'plus',
  42984. 'comma',
  42985. 'hyphen',
  42986. 'period',
  42987. 'slash',
  42988. 'zero',
  42989. 'one',
  42990. 'two',
  42991. 'three',
  42992. 'four',
  42993. 'five',
  42994. 'six',
  42995. 'seven',
  42996. 'eight',
  42997. 'nine',
  42998. 'colon',
  42999. 'semicolon',
  43000. 'less',
  43001. 'equal',
  43002. 'greater',
  43003. 'question',
  43004. 'at',
  43005. 'A',
  43006. 'B',
  43007. 'C',
  43008. 'D',
  43009. 'E',
  43010. 'F',
  43011. 'G',
  43012. 'H',
  43013. 'I',
  43014. 'J',
  43015. 'K',
  43016. 'L',
  43017. 'M',
  43018. 'N',
  43019. 'O',
  43020. 'P',
  43021. 'Q',
  43022. 'R',
  43023. 'S',
  43024. 'T',
  43025. 'U',
  43026. 'V',
  43027. 'W',
  43028. 'X',
  43029. 'Y',
  43030. 'Z',
  43031. 'bracketleft',
  43032. 'backslash',
  43033. 'bracketright',
  43034. 'asciicircum',
  43035. 'underscore',
  43036. 'grave',
  43037. 'a',
  43038. 'b',
  43039. 'c',
  43040. 'd',
  43041. 'e',
  43042. 'f',
  43043. 'g',
  43044. 'h',
  43045. 'i',
  43046. 'j',
  43047. 'k',
  43048. 'l',
  43049. 'm',
  43050. 'n',
  43051. 'o',
  43052. 'p',
  43053. 'q',
  43054. 'r',
  43055. 's',
  43056. 't',
  43057. 'u',
  43058. 'v',
  43059. 'w',
  43060. 'x',
  43061. 'y',
  43062. 'z',
  43063. 'braceleft',
  43064. 'bar',
  43065. 'braceright',
  43066. 'asciitilde',
  43067. 'Adieresis',
  43068. 'Aring',
  43069. 'Ccedilla',
  43070. 'Eacute',
  43071. 'Ntilde',
  43072. 'Odieresis',
  43073. 'Udieresis',
  43074. 'aacute',
  43075. 'agrave',
  43076. 'acircumflex',
  43077. 'adieresis',
  43078. 'atilde',
  43079. 'aring',
  43080. 'ccedilla',
  43081. 'eacute',
  43082. 'egrave',
  43083. 'ecircumflex',
  43084. 'edieresis',
  43085. 'iacute',
  43086. 'igrave',
  43087. 'icircumflex',
  43088. 'idieresis',
  43089. 'ntilde',
  43090. 'oacute',
  43091. 'ograve',
  43092. 'ocircumflex',
  43093. 'odieresis',
  43094. 'otilde',
  43095. 'uacute',
  43096. 'ugrave',
  43097. 'ucircumflex',
  43098. 'udieresis',
  43099. 'dagger',
  43100. 'degree',
  43101. 'cent',
  43102. 'sterling',
  43103. 'section',
  43104. 'bullet',
  43105. 'paragraph',
  43106. 'germandbls',
  43107. 'registered',
  43108. 'copyright',
  43109. 'trademark',
  43110. 'acute',
  43111. 'dieresis',
  43112. 'notequal',
  43113. 'AE',
  43114. 'Oslash',
  43115. 'infinity',
  43116. 'plusminus',
  43117. 'lessequal',
  43118. 'greaterequal',
  43119. 'yen',
  43120. 'mu',
  43121. 'partialdiff',
  43122. 'summation',
  43123. 'product',
  43124. 'pi',
  43125. 'integral',
  43126. 'ordfeminine',
  43127. 'ordmasculine',
  43128. 'Omega',
  43129. 'ae',
  43130. 'oslash',
  43131. 'questiondown',
  43132. 'exclamdown',
  43133. 'logicalnot',
  43134. 'radical',
  43135. 'florin',
  43136. 'approxequal',
  43137. 'Delta',
  43138. 'guillemotleft',
  43139. 'guillemotright',
  43140. 'ellipsis',
  43141. 'nonbreakingspace',
  43142. 'Agrave',
  43143. 'Atilde',
  43144. 'Otilde',
  43145. 'OE',
  43146. 'oe',
  43147. 'endash',
  43148. 'emdash',
  43149. 'quotedblleft',
  43150. 'quotedblright',
  43151. 'quoteleft',
  43152. 'quoteright',
  43153. 'divide',
  43154. 'lozenge',
  43155. 'ydieresis',
  43156. 'Ydieresis',
  43157. 'fraction',
  43158. 'currency',
  43159. 'guilsinglleft',
  43160. 'guilsinglright',
  43161. 'fi',
  43162. 'fl',
  43163. 'daggerdbl',
  43164. 'periodcentered',
  43165. 'quotesinglbase',
  43166. 'quotedblbase',
  43167. 'perthousand',
  43168. 'Acircumflex',
  43169. 'Ecircumflex',
  43170. 'Aacute',
  43171. 'Edieresis',
  43172. 'Egrave',
  43173. 'Iacute',
  43174. 'Icircumflex',
  43175. 'Idieresis',
  43176. 'Igrave',
  43177. 'Oacute',
  43178. 'Ocircumflex',
  43179. 'apple',
  43180. 'Ograve',
  43181. 'Uacute',
  43182. 'Ucircumflex',
  43183. 'Ugrave',
  43184. 'dotlessi',
  43185. 'circumflex',
  43186. 'tilde',
  43187. 'macron',
  43188. 'breve',
  43189. 'dotaccent',
  43190. 'ring',
  43191. 'cedilla',
  43192. 'hungarumlaut',
  43193. 'ogonek',
  43194. 'caron',
  43195. 'Lslash',
  43196. 'lslash',
  43197. 'Scaron',
  43198. 'scaron',
  43199. 'Zcaron',
  43200. 'zcaron',
  43201. 'brokenbar',
  43202. 'Eth',
  43203. 'eth',
  43204. 'Yacute',
  43205. 'yacute',
  43206. 'Thorn',
  43207. 'thorn',
  43208. 'minus',
  43209. 'multiply',
  43210. 'onesuperior',
  43211. 'twosuperior',
  43212. 'threesuperior',
  43213. 'onehalf',
  43214. 'onequarter',
  43215. 'threequarters',
  43216. 'franc',
  43217. 'Gbreve',
  43218. 'gbreve',
  43219. 'Idotaccent',
  43220. 'Scedilla',
  43221. 'scedilla',
  43222. 'Cacute',
  43223. 'cacute',
  43224. 'Ccaron',
  43225. 'ccaron',
  43226. 'dcroat'
  43227. ];
  43228. function adjustWidths(properties) {
  43229. if (!properties.fontMatrix) {
  43230. return;
  43231. }
  43232. if (properties.fontMatrix[0] === FONT_IDENTITY_MATRIX[0]) {
  43233. return;
  43234. }
  43235. var scale = 0.001 / properties.fontMatrix[0];
  43236. var glyphsWidths = properties.widths;
  43237. for (var glyph in glyphsWidths) {
  43238. glyphsWidths[glyph] *= scale;
  43239. }
  43240. properties.defaultWidth *= scale;
  43241. }
  43242. function adjustToUnicode(properties, builtInEncoding) {
  43243. if (properties.hasIncludedToUnicodeMap) {
  43244. return;
  43245. }
  43246. if (properties.hasEncoding) {
  43247. return;
  43248. }
  43249. if (builtInEncoding === properties.defaultEncoding) {
  43250. return;
  43251. }
  43252. if (properties.toUnicode instanceof IdentityToUnicodeMap) {
  43253. return;
  43254. }
  43255. var toUnicode = [], glyphsUnicodeMap = getGlyphsUnicode();
  43256. for (var charCode in builtInEncoding) {
  43257. var glyphName = builtInEncoding[charCode];
  43258. var unicode = getUnicodeForGlyph(glyphName, glyphsUnicodeMap);
  43259. if (unicode !== -1) {
  43260. toUnicode[charCode] = String.fromCharCode(unicode);
  43261. }
  43262. }
  43263. properties.toUnicode.amend(toUnicode);
  43264. }
  43265. function getFontType(type, subtype) {
  43266. switch (type) {
  43267. case 'Type1':
  43268. return subtype === 'Type1C' ? FontType.TYPE1C : FontType.TYPE1;
  43269. case 'CIDFontType0':
  43270. return subtype === 'CIDFontType0C' ? FontType.CIDFONTTYPE0C : FontType.CIDFONTTYPE0;
  43271. case 'OpenType':
  43272. return FontType.OPENTYPE;
  43273. case 'TrueType':
  43274. return FontType.TRUETYPE;
  43275. case 'CIDFontType2':
  43276. return FontType.CIDFONTTYPE2;
  43277. case 'MMType1':
  43278. return FontType.MMTYPE1;
  43279. case 'Type0':
  43280. return FontType.TYPE0;
  43281. default:
  43282. return FontType.UNKNOWN;
  43283. }
  43284. }
  43285. function recoverGlyphName(name, glyphsUnicodeMap) {
  43286. if (glyphsUnicodeMap[name] !== undefined) {
  43287. return name;
  43288. }
  43289. var unicode = getUnicodeForGlyph(name, glyphsUnicodeMap);
  43290. if (unicode !== -1) {
  43291. for (var key in glyphsUnicodeMap) {
  43292. if (glyphsUnicodeMap[key] === unicode) {
  43293. return key;
  43294. }
  43295. }
  43296. }
  43297. info('Unable to recover a standard glyph name for: ' + name);
  43298. return name;
  43299. }
  43300. var Glyph = function GlyphClosure() {
  43301. function Glyph(fontChar, unicode, accent, width, vmetric, operatorListId, isSpace, isInFont) {
  43302. this.fontChar = fontChar;
  43303. this.unicode = unicode;
  43304. this.accent = accent;
  43305. this.width = width;
  43306. this.vmetric = vmetric;
  43307. this.operatorListId = operatorListId;
  43308. this.isSpace = isSpace;
  43309. this.isInFont = isInFont;
  43310. }
  43311. Glyph.prototype.matchesForCache = function (fontChar, unicode, accent, width, vmetric, operatorListId, isSpace, isInFont) {
  43312. 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;
  43313. };
  43314. return Glyph;
  43315. }();
  43316. var ToUnicodeMap = function ToUnicodeMapClosure() {
  43317. function ToUnicodeMap(cmap) {
  43318. this._map = cmap;
  43319. }
  43320. ToUnicodeMap.prototype = {
  43321. get length() {
  43322. return this._map.length;
  43323. },
  43324. forEach: function (callback) {
  43325. for (var charCode in this._map) {
  43326. callback(charCode, this._map[charCode].charCodeAt(0));
  43327. }
  43328. },
  43329. has: function (i) {
  43330. return this._map[i] !== undefined;
  43331. },
  43332. get: function (i) {
  43333. return this._map[i];
  43334. },
  43335. charCodeOf: function (v) {
  43336. return this._map.indexOf(v);
  43337. },
  43338. amend: function (map) {
  43339. for (var charCode in map) {
  43340. this._map[charCode] = map[charCode];
  43341. }
  43342. }
  43343. };
  43344. return ToUnicodeMap;
  43345. }();
  43346. var IdentityToUnicodeMap = function IdentityToUnicodeMapClosure() {
  43347. function IdentityToUnicodeMap(firstChar, lastChar) {
  43348. this.firstChar = firstChar;
  43349. this.lastChar = lastChar;
  43350. }
  43351. IdentityToUnicodeMap.prototype = {
  43352. get length() {
  43353. return this.lastChar + 1 - this.firstChar;
  43354. },
  43355. forEach: function (callback) {
  43356. for (var i = this.firstChar, ii = this.lastChar; i <= ii; i++) {
  43357. callback(i, i);
  43358. }
  43359. },
  43360. has: function (i) {
  43361. return this.firstChar <= i && i <= this.lastChar;
  43362. },
  43363. get: function (i) {
  43364. if (this.firstChar <= i && i <= this.lastChar) {
  43365. return String.fromCharCode(i);
  43366. }
  43367. return undefined;
  43368. },
  43369. charCodeOf: function (v) {
  43370. return isInt(v) && v >= this.firstChar && v <= this.lastChar ? v : -1;
  43371. },
  43372. amend: function (map) {
  43373. error('Should not call amend()');
  43374. }
  43375. };
  43376. return IdentityToUnicodeMap;
  43377. }();
  43378. var OpenTypeFileBuilder = function OpenTypeFileBuilderClosure() {
  43379. function writeInt16(dest, offset, num) {
  43380. dest[offset] = num >> 8 & 0xFF;
  43381. dest[offset + 1] = num & 0xFF;
  43382. }
  43383. function writeInt32(dest, offset, num) {
  43384. dest[offset] = num >> 24 & 0xFF;
  43385. dest[offset + 1] = num >> 16 & 0xFF;
  43386. dest[offset + 2] = num >> 8 & 0xFF;
  43387. dest[offset + 3] = num & 0xFF;
  43388. }
  43389. function writeData(dest, offset, data) {
  43390. var i, ii;
  43391. if (data instanceof Uint8Array) {
  43392. dest.set(data, offset);
  43393. } else if (typeof data === 'string') {
  43394. for (i = 0, ii = data.length; i < ii; i++) {
  43395. dest[offset++] = data.charCodeAt(i) & 0xFF;
  43396. }
  43397. } else {
  43398. for (i = 0, ii = data.length; i < ii; i++) {
  43399. dest[offset++] = data[i] & 0xFF;
  43400. }
  43401. }
  43402. }
  43403. function OpenTypeFileBuilder(sfnt) {
  43404. this.sfnt = sfnt;
  43405. this.tables = Object.create(null);
  43406. }
  43407. OpenTypeFileBuilder.getSearchParams = function OpenTypeFileBuilder_getSearchParams(entriesCount, entrySize) {
  43408. var maxPower2 = 1, log2 = 0;
  43409. while ((maxPower2 ^ entriesCount) > maxPower2) {
  43410. maxPower2 <<= 1;
  43411. log2++;
  43412. }
  43413. var searchRange = maxPower2 * entrySize;
  43414. return {
  43415. range: searchRange,
  43416. entry: log2,
  43417. rangeShift: entrySize * entriesCount - searchRange
  43418. };
  43419. };
  43420. var OTF_HEADER_SIZE = 12;
  43421. var OTF_TABLE_ENTRY_SIZE = 16;
  43422. OpenTypeFileBuilder.prototype = {
  43423. toArray: function OpenTypeFileBuilder_toArray() {
  43424. var sfnt = this.sfnt;
  43425. var tables = this.tables;
  43426. var tablesNames = Object.keys(tables);
  43427. tablesNames.sort();
  43428. var numTables = tablesNames.length;
  43429. var i, j, jj, table, tableName;
  43430. var offset = OTF_HEADER_SIZE + numTables * OTF_TABLE_ENTRY_SIZE;
  43431. var tableOffsets = [offset];
  43432. for (i = 0; i < numTables; i++) {
  43433. table = tables[tablesNames[i]];
  43434. var paddedLength = (table.length + 3 & ~3) >>> 0;
  43435. offset += paddedLength;
  43436. tableOffsets.push(offset);
  43437. }
  43438. var file = new Uint8Array(offset);
  43439. for (i = 0; i < numTables; i++) {
  43440. table = tables[tablesNames[i]];
  43441. writeData(file, tableOffsets[i], table);
  43442. }
  43443. if (sfnt === 'true') {
  43444. sfnt = string32(0x00010000);
  43445. }
  43446. file[0] = sfnt.charCodeAt(0) & 0xFF;
  43447. file[1] = sfnt.charCodeAt(1) & 0xFF;
  43448. file[2] = sfnt.charCodeAt(2) & 0xFF;
  43449. file[3] = sfnt.charCodeAt(3) & 0xFF;
  43450. writeInt16(file, 4, numTables);
  43451. var searchParams = OpenTypeFileBuilder.getSearchParams(numTables, 16);
  43452. writeInt16(file, 6, searchParams.range);
  43453. writeInt16(file, 8, searchParams.entry);
  43454. writeInt16(file, 10, searchParams.rangeShift);
  43455. offset = OTF_HEADER_SIZE;
  43456. for (i = 0; i < numTables; i++) {
  43457. tableName = tablesNames[i];
  43458. file[offset] = tableName.charCodeAt(0) & 0xFF;
  43459. file[offset + 1] = tableName.charCodeAt(1) & 0xFF;
  43460. file[offset + 2] = tableName.charCodeAt(2) & 0xFF;
  43461. file[offset + 3] = tableName.charCodeAt(3) & 0xFF;
  43462. var checksum = 0;
  43463. for (j = tableOffsets[i], jj = tableOffsets[i + 1]; j < jj; j += 4) {
  43464. var quad = readUint32(file, j);
  43465. checksum = checksum + quad >>> 0;
  43466. }
  43467. writeInt32(file, offset + 4, checksum);
  43468. writeInt32(file, offset + 8, tableOffsets[i]);
  43469. writeInt32(file, offset + 12, tables[tableName].length);
  43470. offset += OTF_TABLE_ENTRY_SIZE;
  43471. }
  43472. return file;
  43473. },
  43474. addTable: function OpenTypeFileBuilder_addTable(tag, data) {
  43475. if (tag in this.tables) {
  43476. throw new Error('Table ' + tag + ' already exists');
  43477. }
  43478. this.tables[tag] = data;
  43479. }
  43480. };
  43481. return OpenTypeFileBuilder;
  43482. }();
  43483. var ProblematicCharRanges = new Int32Array([
  43484. 0x0000,
  43485. 0x0020,
  43486. 0x007F,
  43487. 0x00A1,
  43488. 0x00AD,
  43489. 0x00AE,
  43490. 0x0600,
  43491. 0x0780,
  43492. 0x08A0,
  43493. 0x10A0,
  43494. 0x1780,
  43495. 0x1800,
  43496. 0x1C00,
  43497. 0x1C50,
  43498. 0x2000,
  43499. 0x2010,
  43500. 0x2011,
  43501. 0x2012,
  43502. 0x2028,
  43503. 0x2030,
  43504. 0x205F,
  43505. 0x2070,
  43506. 0x25CC,
  43507. 0x25CD,
  43508. 0x3000,
  43509. 0x3001,
  43510. 0xAA60,
  43511. 0xAA80,
  43512. 0xFFF0,
  43513. 0x10000
  43514. ]);
  43515. var Font = function FontClosure() {
  43516. function Font(name, file, properties) {
  43517. var charCode, glyphName, unicode;
  43518. this.name = name;
  43519. this.loadedName = properties.loadedName;
  43520. this.isType3Font = properties.isType3Font;
  43521. this.sizes = [];
  43522. this.missingFile = false;
  43523. this.glyphCache = Object.create(null);
  43524. this.isSerifFont = !!(properties.flags & FontFlags.Serif);
  43525. this.isSymbolicFont = !!(properties.flags & FontFlags.Symbolic);
  43526. this.isMonospace = !!(properties.flags & FontFlags.FixedPitch);
  43527. var type = properties.type;
  43528. var subtype = properties.subtype;
  43529. this.type = type;
  43530. this.fallbackName = this.isMonospace ? 'monospace' : this.isSerifFont ? 'serif' : 'sans-serif';
  43531. this.differences = properties.differences;
  43532. this.widths = properties.widths;
  43533. this.defaultWidth = properties.defaultWidth;
  43534. this.composite = properties.composite;
  43535. this.wideChars = properties.wideChars;
  43536. this.cMap = properties.cMap;
  43537. this.ascent = properties.ascent / PDF_GLYPH_SPACE_UNITS;
  43538. this.descent = properties.descent / PDF_GLYPH_SPACE_UNITS;
  43539. this.fontMatrix = properties.fontMatrix;
  43540. this.bbox = properties.bbox;
  43541. this.toUnicode = properties.toUnicode;
  43542. this.toFontChar = [];
  43543. if (properties.type === 'Type3') {
  43544. for (charCode = 0; charCode < 256; charCode++) {
  43545. this.toFontChar[charCode] = this.differences[charCode] || properties.defaultEncoding[charCode];
  43546. }
  43547. this.fontType = FontType.TYPE3;
  43548. return;
  43549. }
  43550. this.cidEncoding = properties.cidEncoding;
  43551. this.vertical = properties.vertical;
  43552. if (this.vertical) {
  43553. this.vmetrics = properties.vmetrics;
  43554. this.defaultVMetrics = properties.defaultVMetrics;
  43555. }
  43556. var glyphsUnicodeMap;
  43557. if (!file || file.isEmpty) {
  43558. if (file) {
  43559. warn('Font file is empty in "' + name + '" (' + this.loadedName + ')');
  43560. }
  43561. this.missingFile = true;
  43562. var fontName = name.replace(/[,_]/g, '-');
  43563. var stdFontMap = getStdFontMap(), nonStdFontMap = getNonStdFontMap();
  43564. var isStandardFont = !!stdFontMap[fontName] || !!(nonStdFontMap[fontName] && stdFontMap[nonStdFontMap[fontName]]);
  43565. fontName = stdFontMap[fontName] || nonStdFontMap[fontName] || fontName;
  43566. this.bold = fontName.search(/bold/gi) !== -1;
  43567. this.italic = fontName.search(/oblique/gi) !== -1 || fontName.search(/italic/gi) !== -1;
  43568. this.black = name.search(/Black/g) !== -1;
  43569. this.remeasure = Object.keys(this.widths).length > 0;
  43570. if (isStandardFont && type === 'CIDFontType2' && properties.cidEncoding.indexOf('Identity-') === 0) {
  43571. var GlyphMapForStandardFonts = getGlyphMapForStandardFonts();
  43572. var map = [];
  43573. for (charCode in GlyphMapForStandardFonts) {
  43574. map[+charCode] = GlyphMapForStandardFonts[charCode];
  43575. }
  43576. if (/Arial-?Black/i.test(name)) {
  43577. var SupplementalGlyphMapForArialBlack = getSupplementalGlyphMapForArialBlack();
  43578. for (charCode in SupplementalGlyphMapForArialBlack) {
  43579. map[+charCode] = SupplementalGlyphMapForArialBlack[charCode];
  43580. }
  43581. }
  43582. var isIdentityUnicode = this.toUnicode instanceof IdentityToUnicodeMap;
  43583. if (!isIdentityUnicode) {
  43584. this.toUnicode.forEach(function (charCode, unicodeCharCode) {
  43585. map[+charCode] = unicodeCharCode;
  43586. });
  43587. }
  43588. this.toFontChar = map;
  43589. this.toUnicode = new ToUnicodeMap(map);
  43590. } else if (/Symbol/i.test(fontName)) {
  43591. this.toFontChar = buildToFontChar(SymbolSetEncoding, getGlyphsUnicode(), properties.differences);
  43592. } else if (/Dingbats/i.test(fontName)) {
  43593. if (/Wingdings/i.test(name)) {
  43594. warn('Non-embedded Wingdings font, falling back to ZapfDingbats.');
  43595. }
  43596. this.toFontChar = buildToFontChar(ZapfDingbatsEncoding, getDingbatsGlyphsUnicode(), properties.differences);
  43597. } else if (isStandardFont) {
  43598. this.toFontChar = buildToFontChar(properties.defaultEncoding, getGlyphsUnicode(), properties.differences);
  43599. } else {
  43600. glyphsUnicodeMap = getGlyphsUnicode();
  43601. this.toUnicode.forEach(function (charCode, unicodeCharCode) {
  43602. if (!this.composite) {
  43603. glyphName = properties.differences[charCode] || properties.defaultEncoding[charCode];
  43604. unicode = getUnicodeForGlyph(glyphName, glyphsUnicodeMap);
  43605. if (unicode !== -1) {
  43606. unicodeCharCode = unicode;
  43607. }
  43608. }
  43609. this.toFontChar[charCode] = unicodeCharCode;
  43610. }.bind(this));
  43611. }
  43612. this.loadedName = fontName.split('-')[0];
  43613. this.loading = false;
  43614. this.fontType = getFontType(type, subtype);
  43615. return;
  43616. }
  43617. if (subtype === 'Type1C') {
  43618. if (type !== 'Type1' && type !== 'MMType1') {
  43619. if (isTrueTypeFile(file)) {
  43620. subtype = 'TrueType';
  43621. } else {
  43622. type = 'Type1';
  43623. }
  43624. } else if (isOpenTypeFile(file)) {
  43625. type = subtype = 'OpenType';
  43626. }
  43627. }
  43628. if (subtype === 'CIDFontType0C' && type !== 'CIDFontType0') {
  43629. type = 'CIDFontType0';
  43630. }
  43631. if (subtype === 'OpenType') {
  43632. type = 'OpenType';
  43633. }
  43634. if (type === 'CIDFontType0') {
  43635. if (isType1File(file)) {
  43636. subtype = 'CIDFontType0';
  43637. } else if (isOpenTypeFile(file)) {
  43638. type = subtype = 'OpenType';
  43639. } else {
  43640. subtype = 'CIDFontType0C';
  43641. }
  43642. }
  43643. var data;
  43644. switch (type) {
  43645. case 'MMType1':
  43646. info('MMType1 font (' + name + '), falling back to Type1.');
  43647. case 'Type1':
  43648. case 'CIDFontType0':
  43649. this.mimetype = 'font/opentype';
  43650. var cff = subtype === 'Type1C' || subtype === 'CIDFontType0C' ? new CFFFont(file, properties) : new Type1Font(name, file, properties);
  43651. adjustWidths(properties);
  43652. data = this.convert(name, cff, properties);
  43653. break;
  43654. case 'OpenType':
  43655. case 'TrueType':
  43656. case 'CIDFontType2':
  43657. this.mimetype = 'font/opentype';
  43658. data = this.checkAndRepair(name, file, properties);
  43659. if (this.isOpenType) {
  43660. adjustWidths(properties);
  43661. type = 'OpenType';
  43662. }
  43663. break;
  43664. default:
  43665. error('Font ' + type + ' is not supported');
  43666. break;
  43667. }
  43668. this.data = data;
  43669. this.fontType = getFontType(type, subtype);
  43670. this.fontMatrix = properties.fontMatrix;
  43671. this.widths = properties.widths;
  43672. this.defaultWidth = properties.defaultWidth;
  43673. this.toUnicode = properties.toUnicode;
  43674. this.encoding = properties.baseEncoding;
  43675. this.seacMap = properties.seacMap;
  43676. this.loading = true;
  43677. }
  43678. Font.getFontID = function () {
  43679. var ID = 1;
  43680. return function Font_getFontID() {
  43681. return String(ID++);
  43682. };
  43683. }();
  43684. function int16(b0, b1) {
  43685. return (b0 << 8) + b1;
  43686. }
  43687. function signedInt16(b0, b1) {
  43688. var value = (b0 << 8) + b1;
  43689. return value & 1 << 15 ? value - 0x10000 : value;
  43690. }
  43691. function int32(b0, b1, b2, b3) {
  43692. return (b0 << 24) + (b1 << 16) + (b2 << 8) + b3;
  43693. }
  43694. function string16(value) {
  43695. return String.fromCharCode(value >> 8 & 0xff, value & 0xff);
  43696. }
  43697. function safeString16(value) {
  43698. value = value > 0x7FFF ? 0x7FFF : value < -0x8000 ? -0x8000 : value;
  43699. return String.fromCharCode(value >> 8 & 0xff, value & 0xff);
  43700. }
  43701. function isTrueTypeFile(file) {
  43702. var header = file.peekBytes(4);
  43703. return readUint32(header, 0) === 0x00010000;
  43704. }
  43705. function isOpenTypeFile(file) {
  43706. var header = file.peekBytes(4);
  43707. return bytesToString(header) === 'OTTO';
  43708. }
  43709. function isType1File(file) {
  43710. var header = file.peekBytes(2);
  43711. if (header[0] === 0x25 && header[1] === 0x21) {
  43712. return true;
  43713. }
  43714. if (header[0] === 0x80 && header[1] === 0x01) {
  43715. return true;
  43716. }
  43717. return false;
  43718. }
  43719. function buildToFontChar(encoding, glyphsUnicodeMap, differences) {
  43720. var toFontChar = [], unicode;
  43721. for (var i = 0, ii = encoding.length; i < ii; i++) {
  43722. unicode = getUnicodeForGlyph(encoding[i], glyphsUnicodeMap);
  43723. if (unicode !== -1) {
  43724. toFontChar[i] = unicode;
  43725. }
  43726. }
  43727. for (var charCode in differences) {
  43728. unicode = getUnicodeForGlyph(differences[charCode], glyphsUnicodeMap);
  43729. if (unicode !== -1) {
  43730. toFontChar[+charCode] = unicode;
  43731. }
  43732. }
  43733. return toFontChar;
  43734. }
  43735. function isProblematicUnicodeLocation(code) {
  43736. var i = 0, j = ProblematicCharRanges.length - 1;
  43737. while (i < j) {
  43738. var c = i + j + 1 >> 1;
  43739. if (code < ProblematicCharRanges[c]) {
  43740. j = c - 1;
  43741. } else {
  43742. i = c;
  43743. }
  43744. }
  43745. return !(i & 1);
  43746. }
  43747. function adjustMapping(charCodeToGlyphId, properties) {
  43748. var toUnicode = properties.toUnicode;
  43749. var isSymbolic = !!(properties.flags & FontFlags.Symbolic);
  43750. var isIdentityUnicode = properties.toUnicode instanceof IdentityToUnicodeMap;
  43751. var newMap = Object.create(null);
  43752. var toFontChar = [];
  43753. var usedFontCharCodes = [];
  43754. var nextAvailableFontCharCode = PRIVATE_USE_OFFSET_START;
  43755. for (var originalCharCode in charCodeToGlyphId) {
  43756. originalCharCode |= 0;
  43757. var glyphId = charCodeToGlyphId[originalCharCode];
  43758. var fontCharCode = originalCharCode;
  43759. var hasUnicodeValue = false;
  43760. if (!isIdentityUnicode && toUnicode.has(originalCharCode)) {
  43761. hasUnicodeValue = true;
  43762. var unicode = toUnicode.get(fontCharCode);
  43763. if (unicode.length === 1) {
  43764. fontCharCode = unicode.charCodeAt(0);
  43765. }
  43766. }
  43767. if ((usedFontCharCodes[fontCharCode] !== undefined || isProblematicUnicodeLocation(fontCharCode) || isSymbolic && !hasUnicodeValue) && nextAvailableFontCharCode <= PRIVATE_USE_OFFSET_END) {
  43768. do {
  43769. fontCharCode = nextAvailableFontCharCode++;
  43770. if (SKIP_PRIVATE_USE_RANGE_F000_TO_F01F && fontCharCode === 0xF000) {
  43771. fontCharCode = 0xF020;
  43772. nextAvailableFontCharCode = fontCharCode + 1;
  43773. }
  43774. } while (usedFontCharCodes[fontCharCode] !== undefined && nextAvailableFontCharCode <= PRIVATE_USE_OFFSET_END);
  43775. }
  43776. newMap[fontCharCode] = glyphId;
  43777. toFontChar[originalCharCode] = fontCharCode;
  43778. usedFontCharCodes[fontCharCode] = true;
  43779. }
  43780. return {
  43781. toFontChar: toFontChar,
  43782. charCodeToGlyphId: newMap,
  43783. nextAvailableFontCharCode: nextAvailableFontCharCode
  43784. };
  43785. }
  43786. function getRanges(glyphs, numGlyphs) {
  43787. var codes = [];
  43788. for (var charCode in glyphs) {
  43789. if (glyphs[charCode] >= numGlyphs) {
  43790. continue;
  43791. }
  43792. codes.push({
  43793. fontCharCode: charCode | 0,
  43794. glyphId: glyphs[charCode]
  43795. });
  43796. }
  43797. codes.sort(function fontGetRangesSort(a, b) {
  43798. return a.fontCharCode - b.fontCharCode;
  43799. });
  43800. var ranges = [];
  43801. var length = codes.length;
  43802. for (var n = 0; n < length;) {
  43803. var start = codes[n].fontCharCode;
  43804. var codeIndices = [codes[n].glyphId];
  43805. ++n;
  43806. var end = start;
  43807. while (n < length && end + 1 === codes[n].fontCharCode) {
  43808. codeIndices.push(codes[n].glyphId);
  43809. ++end;
  43810. ++n;
  43811. if (end === 0xFFFF) {
  43812. break;
  43813. }
  43814. }
  43815. ranges.push([
  43816. start,
  43817. end,
  43818. codeIndices
  43819. ]);
  43820. }
  43821. return ranges;
  43822. }
  43823. function createCmapTable(glyphs, numGlyphs) {
  43824. var ranges = getRanges(glyphs, numGlyphs);
  43825. var numTables = ranges[ranges.length - 1][1] > 0xFFFF ? 2 : 1;
  43826. var cmap = '\x00\x00' + string16(numTables) + '\x00\x03' + '\x00\x01' + string32(4 + numTables * 8);
  43827. var i, ii, j, jj;
  43828. for (i = ranges.length - 1; i >= 0; --i) {
  43829. if (ranges[i][0] <= 0xFFFF) {
  43830. break;
  43831. }
  43832. }
  43833. var bmpLength = i + 1;
  43834. if (ranges[i][0] < 0xFFFF && ranges[i][1] === 0xFFFF) {
  43835. ranges[i][1] = 0xFFFE;
  43836. }
  43837. var trailingRangesCount = ranges[i][1] < 0xFFFF ? 1 : 0;
  43838. var segCount = bmpLength + trailingRangesCount;
  43839. var searchParams = OpenTypeFileBuilder.getSearchParams(segCount, 2);
  43840. var startCount = '';
  43841. var endCount = '';
  43842. var idDeltas = '';
  43843. var idRangeOffsets = '';
  43844. var glyphsIds = '';
  43845. var bias = 0;
  43846. var range, start, end, codes;
  43847. for (i = 0, ii = bmpLength; i < ii; i++) {
  43848. range = ranges[i];
  43849. start = range[0];
  43850. end = range[1];
  43851. startCount += string16(start);
  43852. endCount += string16(end);
  43853. codes = range[2];
  43854. var contiguous = true;
  43855. for (j = 1, jj = codes.length; j < jj; ++j) {
  43856. if (codes[j] !== codes[j - 1] + 1) {
  43857. contiguous = false;
  43858. break;
  43859. }
  43860. }
  43861. if (!contiguous) {
  43862. var offset = (segCount - i) * 2 + bias * 2;
  43863. bias += end - start + 1;
  43864. idDeltas += string16(0);
  43865. idRangeOffsets += string16(offset);
  43866. for (j = 0, jj = codes.length; j < jj; ++j) {
  43867. glyphsIds += string16(codes[j]);
  43868. }
  43869. } else {
  43870. var startCode = codes[0];
  43871. idDeltas += string16(startCode - start & 0xFFFF);
  43872. idRangeOffsets += string16(0);
  43873. }
  43874. }
  43875. if (trailingRangesCount > 0) {
  43876. endCount += '\xFF\xFF';
  43877. startCount += '\xFF\xFF';
  43878. idDeltas += '\x00\x01';
  43879. idRangeOffsets += '\x00\x00';
  43880. }
  43881. var format314 = '\x00\x00' + string16(2 * segCount) + string16(searchParams.range) + string16(searchParams.entry) + string16(searchParams.rangeShift) + endCount + '\x00\x00' + startCount + idDeltas + idRangeOffsets + glyphsIds;
  43882. var format31012 = '';
  43883. var header31012 = '';
  43884. if (numTables > 1) {
  43885. cmap += '\x00\x03' + '\x00\x0A' + string32(4 + numTables * 8 + 4 + format314.length);
  43886. format31012 = '';
  43887. for (i = 0, ii = ranges.length; i < ii; i++) {
  43888. range = ranges[i];
  43889. start = range[0];
  43890. codes = range[2];
  43891. var code = codes[0];
  43892. for (j = 1, jj = codes.length; j < jj; ++j) {
  43893. if (codes[j] !== codes[j - 1] + 1) {
  43894. end = range[0] + j - 1;
  43895. format31012 += string32(start) + string32(end) + string32(code);
  43896. start = end + 1;
  43897. code = codes[j];
  43898. }
  43899. }
  43900. format31012 += string32(start) + string32(range[1]) + string32(code);
  43901. }
  43902. header31012 = '\x00\x0C' + '\x00\x00' + string32(format31012.length + 16) + '\x00\x00\x00\x00' + string32(format31012.length / 12);
  43903. }
  43904. return cmap + '\x00\x04' + string16(format314.length + 4) + format314 + header31012 + format31012;
  43905. }
  43906. function validateOS2Table(os2) {
  43907. var stream = new Stream(os2.data);
  43908. var version = stream.getUint16();
  43909. stream.getBytes(60);
  43910. var selection = stream.getUint16();
  43911. if (version < 4 && selection & 0x0300) {
  43912. return false;
  43913. }
  43914. var firstChar = stream.getUint16();
  43915. var lastChar = stream.getUint16();
  43916. if (firstChar > lastChar) {
  43917. return false;
  43918. }
  43919. stream.getBytes(6);
  43920. var usWinAscent = stream.getUint16();
  43921. if (usWinAscent === 0) {
  43922. return false;
  43923. }
  43924. os2.data[8] = os2.data[9] = 0;
  43925. return true;
  43926. }
  43927. function createOS2Table(properties, charstrings, override) {
  43928. override = override || {
  43929. unitsPerEm: 0,
  43930. yMax: 0,
  43931. yMin: 0,
  43932. ascent: 0,
  43933. descent: 0
  43934. };
  43935. var ulUnicodeRange1 = 0;
  43936. var ulUnicodeRange2 = 0;
  43937. var ulUnicodeRange3 = 0;
  43938. var ulUnicodeRange4 = 0;
  43939. var firstCharIndex = null;
  43940. var lastCharIndex = 0;
  43941. if (charstrings) {
  43942. for (var code in charstrings) {
  43943. code |= 0;
  43944. if (firstCharIndex > code || !firstCharIndex) {
  43945. firstCharIndex = code;
  43946. }
  43947. if (lastCharIndex < code) {
  43948. lastCharIndex = code;
  43949. }
  43950. var position = getUnicodeRangeFor(code);
  43951. if (position < 32) {
  43952. ulUnicodeRange1 |= 1 << position;
  43953. } else if (position < 64) {
  43954. ulUnicodeRange2 |= 1 << position - 32;
  43955. } else if (position < 96) {
  43956. ulUnicodeRange3 |= 1 << position - 64;
  43957. } else if (position < 123) {
  43958. ulUnicodeRange4 |= 1 << position - 96;
  43959. } else {
  43960. error('Unicode ranges Bits > 123 are reserved for internal usage');
  43961. }
  43962. }
  43963. } else {
  43964. firstCharIndex = 0;
  43965. lastCharIndex = 255;
  43966. }
  43967. var bbox = properties.bbox || [
  43968. 0,
  43969. 0,
  43970. 0,
  43971. 0
  43972. ];
  43973. var unitsPerEm = override.unitsPerEm || 1 / (properties.fontMatrix || FONT_IDENTITY_MATRIX)[0];
  43974. var scale = properties.ascentScaled ? 1.0 : unitsPerEm / PDF_GLYPH_SPACE_UNITS;
  43975. var typoAscent = override.ascent || Math.round(scale * (properties.ascent || bbox[3]));
  43976. var typoDescent = override.descent || Math.round(scale * (properties.descent || bbox[1]));
  43977. if (typoDescent > 0 && properties.descent > 0 && bbox[1] < 0) {
  43978. typoDescent = -typoDescent;
  43979. }
  43980. var winAscent = override.yMax || typoAscent;
  43981. var winDescent = -override.yMin || -typoDescent;
  43982. 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';
  43983. }
  43984. function createPostTable(properties) {
  43985. var angle = Math.floor(properties.italicAngle * Math.pow(2, 16));
  43986. 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';
  43987. }
  43988. function createNameTable(name, proto) {
  43989. if (!proto) {
  43990. proto = [
  43991. [],
  43992. []
  43993. ];
  43994. }
  43995. var strings = [
  43996. proto[0][0] || 'Original licence',
  43997. proto[0][1] || name,
  43998. proto[0][2] || 'Unknown',
  43999. proto[0][3] || 'uniqueID',
  44000. proto[0][4] || name,
  44001. proto[0][5] || 'Version 0.11',
  44002. proto[0][6] || '',
  44003. proto[0][7] || 'Unknown',
  44004. proto[0][8] || 'Unknown',
  44005. proto[0][9] || 'Unknown'
  44006. ];
  44007. var stringsUnicode = [];
  44008. var i, ii, j, jj, str;
  44009. for (i = 0, ii = strings.length; i < ii; i++) {
  44010. str = proto[1][i] || strings[i];
  44011. var strBufUnicode = [];
  44012. for (j = 0, jj = str.length; j < jj; j++) {
  44013. strBufUnicode.push(string16(str.charCodeAt(j)));
  44014. }
  44015. stringsUnicode.push(strBufUnicode.join(''));
  44016. }
  44017. var names = [
  44018. strings,
  44019. stringsUnicode
  44020. ];
  44021. var platforms = [
  44022. '\x00\x01',
  44023. '\x00\x03'
  44024. ];
  44025. var encodings = [
  44026. '\x00\x00',
  44027. '\x00\x01'
  44028. ];
  44029. var languages = [
  44030. '\x00\x00',
  44031. '\x04\x09'
  44032. ];
  44033. var namesRecordCount = strings.length * platforms.length;
  44034. var nameTable = '\x00\x00' + string16(namesRecordCount) + string16(namesRecordCount * 12 + 6);
  44035. var strOffset = 0;
  44036. for (i = 0, ii = platforms.length; i < ii; i++) {
  44037. var strs = names[i];
  44038. for (j = 0, jj = strs.length; j < jj; j++) {
  44039. str = strs[j];
  44040. var nameRecord = platforms[i] + encodings[i] + languages[i] + string16(j) + string16(str.length) + string16(strOffset);
  44041. nameTable += nameRecord;
  44042. strOffset += str.length;
  44043. }
  44044. }
  44045. nameTable += strings.join('') + stringsUnicode.join('');
  44046. return nameTable;
  44047. }
  44048. Font.prototype = {
  44049. name: null,
  44050. font: null,
  44051. mimetype: null,
  44052. encoding: null,
  44053. get renderer() {
  44054. var renderer = FontRendererFactory.create(this, SEAC_ANALYSIS_ENABLED);
  44055. return shadow(this, 'renderer', renderer);
  44056. },
  44057. exportData: function Font_exportData() {
  44058. var data = {};
  44059. for (var i in this) {
  44060. if (this.hasOwnProperty(i)) {
  44061. data[i] = this[i];
  44062. }
  44063. }
  44064. return data;
  44065. },
  44066. checkAndRepair: function Font_checkAndRepair(name, font, properties) {
  44067. function readTableEntry(file) {
  44068. var tag = bytesToString(file.getBytes(4));
  44069. var checksum = file.getInt32() >>> 0;
  44070. var offset = file.getInt32() >>> 0;
  44071. var length = file.getInt32() >>> 0;
  44072. var previousPosition = file.pos;
  44073. file.pos = file.start ? file.start : 0;
  44074. file.skip(offset);
  44075. var data = file.getBytes(length);
  44076. file.pos = previousPosition;
  44077. if (tag === 'head') {
  44078. data[8] = data[9] = data[10] = data[11] = 0;
  44079. data[17] |= 0x20;
  44080. }
  44081. return {
  44082. tag: tag,
  44083. checksum: checksum,
  44084. length: length,
  44085. offset: offset,
  44086. data: data
  44087. };
  44088. }
  44089. function readOpenTypeHeader(ttf) {
  44090. return {
  44091. version: bytesToString(ttf.getBytes(4)),
  44092. numTables: ttf.getUint16(),
  44093. searchRange: ttf.getUint16(),
  44094. entrySelector: ttf.getUint16(),
  44095. rangeShift: ttf.getUint16()
  44096. };
  44097. }
  44098. function readCmapTable(cmap, font, isSymbolicFont, hasEncoding) {
  44099. if (!cmap) {
  44100. warn('No cmap table available.');
  44101. return {
  44102. platformId: -1,
  44103. encodingId: -1,
  44104. mappings: [],
  44105. hasShortCmap: false
  44106. };
  44107. }
  44108. var segment;
  44109. var start = (font.start ? font.start : 0) + cmap.offset;
  44110. font.pos = start;
  44111. font.getUint16();
  44112. var numTables = font.getUint16();
  44113. var potentialTable;
  44114. var canBreak = false;
  44115. for (var i = 0; i < numTables; i++) {
  44116. var platformId = font.getUint16();
  44117. var encodingId = font.getUint16();
  44118. var offset = font.getInt32() >>> 0;
  44119. var useTable = false;
  44120. if (platformId === 0 && encodingId === 0) {
  44121. useTable = true;
  44122. } else if (platformId === 1 && encodingId === 0) {
  44123. useTable = true;
  44124. } else if (platformId === 3 && encodingId === 1 && (hasEncoding || !potentialTable)) {
  44125. useTable = true;
  44126. if (!isSymbolicFont) {
  44127. canBreak = true;
  44128. }
  44129. } else if (isSymbolicFont && platformId === 3 && encodingId === 0) {
  44130. useTable = true;
  44131. canBreak = true;
  44132. }
  44133. if (useTable) {
  44134. potentialTable = {
  44135. platformId: platformId,
  44136. encodingId: encodingId,
  44137. offset: offset
  44138. };
  44139. }
  44140. if (canBreak) {
  44141. break;
  44142. }
  44143. }
  44144. if (potentialTable) {
  44145. font.pos = start + potentialTable.offset;
  44146. }
  44147. if (!potentialTable || font.peekByte() === -1) {
  44148. warn('Could not find a preferred cmap table.');
  44149. return {
  44150. platformId: -1,
  44151. encodingId: -1,
  44152. mappings: [],
  44153. hasShortCmap: false
  44154. };
  44155. }
  44156. var format = font.getUint16();
  44157. font.getUint16();
  44158. font.getUint16();
  44159. var hasShortCmap = false;
  44160. var mappings = [];
  44161. var j, glyphId;
  44162. if (format === 0) {
  44163. for (j = 0; j < 256; j++) {
  44164. var index = font.getByte();
  44165. if (!index) {
  44166. continue;
  44167. }
  44168. mappings.push({
  44169. charCode: j,
  44170. glyphId: index
  44171. });
  44172. }
  44173. hasShortCmap = true;
  44174. } else if (format === 4) {
  44175. var segCount = font.getUint16() >> 1;
  44176. font.getBytes(6);
  44177. var segIndex, segments = [];
  44178. for (segIndex = 0; segIndex < segCount; segIndex++) {
  44179. segments.push({ end: font.getUint16() });
  44180. }
  44181. font.getUint16();
  44182. for (segIndex = 0; segIndex < segCount; segIndex++) {
  44183. segments[segIndex].start = font.getUint16();
  44184. }
  44185. for (segIndex = 0; segIndex < segCount; segIndex++) {
  44186. segments[segIndex].delta = font.getUint16();
  44187. }
  44188. var offsetsCount = 0;
  44189. for (segIndex = 0; segIndex < segCount; segIndex++) {
  44190. segment = segments[segIndex];
  44191. var rangeOffset = font.getUint16();
  44192. if (!rangeOffset) {
  44193. segment.offsetIndex = -1;
  44194. continue;
  44195. }
  44196. var offsetIndex = (rangeOffset >> 1) - (segCount - segIndex);
  44197. segment.offsetIndex = offsetIndex;
  44198. offsetsCount = Math.max(offsetsCount, offsetIndex + segment.end - segment.start + 1);
  44199. }
  44200. var offsets = [];
  44201. for (j = 0; j < offsetsCount; j++) {
  44202. offsets.push(font.getUint16());
  44203. }
  44204. for (segIndex = 0; segIndex < segCount; segIndex++) {
  44205. segment = segments[segIndex];
  44206. start = segment.start;
  44207. var end = segment.end;
  44208. var delta = segment.delta;
  44209. offsetIndex = segment.offsetIndex;
  44210. for (j = start; j <= end; j++) {
  44211. if (j === 0xFFFF) {
  44212. continue;
  44213. }
  44214. glyphId = offsetIndex < 0 ? j : offsets[offsetIndex + j - start];
  44215. glyphId = glyphId + delta & 0xFFFF;
  44216. if (glyphId === 0) {
  44217. continue;
  44218. }
  44219. mappings.push({
  44220. charCode: j,
  44221. glyphId: glyphId
  44222. });
  44223. }
  44224. }
  44225. } else if (format === 6) {
  44226. var firstCode = font.getUint16();
  44227. var entryCount = font.getUint16();
  44228. for (j = 0; j < entryCount; j++) {
  44229. glyphId = font.getUint16();
  44230. var charCode = firstCode + j;
  44231. mappings.push({
  44232. charCode: charCode,
  44233. glyphId: glyphId
  44234. });
  44235. }
  44236. } else {
  44237. warn('cmap table has unsupported format: ' + format);
  44238. return {
  44239. platformId: -1,
  44240. encodingId: -1,
  44241. mappings: [],
  44242. hasShortCmap: false
  44243. };
  44244. }
  44245. mappings.sort(function (a, b) {
  44246. return a.charCode - b.charCode;
  44247. });
  44248. for (i = 1; i < mappings.length; i++) {
  44249. if (mappings[i - 1].charCode === mappings[i].charCode) {
  44250. mappings.splice(i, 1);
  44251. i--;
  44252. }
  44253. }
  44254. return {
  44255. platformId: potentialTable.platformId,
  44256. encodingId: potentialTable.encodingId,
  44257. mappings: mappings,
  44258. hasShortCmap: hasShortCmap
  44259. };
  44260. }
  44261. function sanitizeMetrics(font, header, metrics, numGlyphs) {
  44262. if (!header) {
  44263. if (metrics) {
  44264. metrics.data = null;
  44265. }
  44266. return;
  44267. }
  44268. font.pos = (font.start ? font.start : 0) + header.offset;
  44269. font.pos += header.length - 2;
  44270. var numOfMetrics = font.getUint16();
  44271. if (numOfMetrics > numGlyphs) {
  44272. info('The numOfMetrics (' + numOfMetrics + ') should not be ' + 'greater than the numGlyphs (' + numGlyphs + ')');
  44273. numOfMetrics = numGlyphs;
  44274. header.data[34] = (numOfMetrics & 0xff00) >> 8;
  44275. header.data[35] = numOfMetrics & 0x00ff;
  44276. }
  44277. var numOfSidebearings = numGlyphs - numOfMetrics;
  44278. var numMissing = numOfSidebearings - (metrics.length - numOfMetrics * 4 >> 1);
  44279. if (numMissing > 0) {
  44280. var entries = new Uint8Array(metrics.length + numMissing * 2);
  44281. entries.set(metrics.data);
  44282. metrics.data = entries;
  44283. }
  44284. }
  44285. function sanitizeGlyph(source, sourceStart, sourceEnd, dest, destStart, hintsValid) {
  44286. if (sourceEnd - sourceStart <= 12) {
  44287. return 0;
  44288. }
  44289. var glyf = source.subarray(sourceStart, sourceEnd);
  44290. var contoursCount = glyf[0] << 8 | glyf[1];
  44291. if (contoursCount & 0x8000) {
  44292. dest.set(glyf, destStart);
  44293. return glyf.length;
  44294. }
  44295. var i, j = 10, flagsCount = 0;
  44296. for (i = 0; i < contoursCount; i++) {
  44297. var endPoint = glyf[j] << 8 | glyf[j + 1];
  44298. flagsCount = endPoint + 1;
  44299. j += 2;
  44300. }
  44301. var instructionsStart = j;
  44302. var instructionsLength = glyf[j] << 8 | glyf[j + 1];
  44303. j += 2 + instructionsLength;
  44304. var instructionsEnd = j;
  44305. var coordinatesLength = 0;
  44306. for (i = 0; i < flagsCount; i++) {
  44307. var flag = glyf[j++];
  44308. if (flag & 0xC0) {
  44309. glyf[j - 1] = flag & 0x3F;
  44310. }
  44311. var xyLength = (flag & 2 ? 1 : flag & 16 ? 0 : 2) + (flag & 4 ? 1 : flag & 32 ? 0 : 2);
  44312. coordinatesLength += xyLength;
  44313. if (flag & 8) {
  44314. var repeat = glyf[j++];
  44315. i += repeat;
  44316. coordinatesLength += repeat * xyLength;
  44317. }
  44318. }
  44319. if (coordinatesLength === 0) {
  44320. return 0;
  44321. }
  44322. var glyphDataLength = j + coordinatesLength;
  44323. if (glyphDataLength > glyf.length) {
  44324. return 0;
  44325. }
  44326. if (!hintsValid && instructionsLength > 0) {
  44327. dest.set(glyf.subarray(0, instructionsStart), destStart);
  44328. dest.set([
  44329. 0,
  44330. 0
  44331. ], destStart + instructionsStart);
  44332. dest.set(glyf.subarray(instructionsEnd, glyphDataLength), destStart + instructionsStart + 2);
  44333. glyphDataLength -= instructionsLength;
  44334. if (glyf.length - glyphDataLength > 3) {
  44335. glyphDataLength = glyphDataLength + 3 & ~3;
  44336. }
  44337. return glyphDataLength;
  44338. }
  44339. if (glyf.length - glyphDataLength > 3) {
  44340. glyphDataLength = glyphDataLength + 3 & ~3;
  44341. dest.set(glyf.subarray(0, glyphDataLength), destStart);
  44342. return glyphDataLength;
  44343. }
  44344. dest.set(glyf, destStart);
  44345. return glyf.length;
  44346. }
  44347. function sanitizeHead(head, numGlyphs, locaLength) {
  44348. var data = head.data;
  44349. var version = int32(data[0], data[1], data[2], data[3]);
  44350. if (version >> 16 !== 1) {
  44351. info('Attempting to fix invalid version in head table: ' + version);
  44352. data[0] = 0;
  44353. data[1] = 1;
  44354. data[2] = 0;
  44355. data[3] = 0;
  44356. }
  44357. var indexToLocFormat = int16(data[50], data[51]);
  44358. if (indexToLocFormat < 0 || indexToLocFormat > 1) {
  44359. info('Attempting to fix invalid indexToLocFormat in head table: ' + indexToLocFormat);
  44360. var numGlyphsPlusOne = numGlyphs + 1;
  44361. if (locaLength === numGlyphsPlusOne << 1) {
  44362. data[50] = 0;
  44363. data[51] = 0;
  44364. } else if (locaLength === numGlyphsPlusOne << 2) {
  44365. data[50] = 0;
  44366. data[51] = 1;
  44367. } else {
  44368. warn('Could not fix indexToLocFormat: ' + indexToLocFormat);
  44369. }
  44370. }
  44371. }
  44372. function sanitizeGlyphLocations(loca, glyf, numGlyphs, isGlyphLocationsLong, hintsValid, dupFirstEntry) {
  44373. var itemSize, itemDecode, itemEncode;
  44374. if (isGlyphLocationsLong) {
  44375. itemSize = 4;
  44376. itemDecode = function fontItemDecodeLong(data, offset) {
  44377. return data[offset] << 24 | data[offset + 1] << 16 | data[offset + 2] << 8 | data[offset + 3];
  44378. };
  44379. itemEncode = function fontItemEncodeLong(data, offset, value) {
  44380. data[offset] = value >>> 24 & 0xFF;
  44381. data[offset + 1] = value >> 16 & 0xFF;
  44382. data[offset + 2] = value >> 8 & 0xFF;
  44383. data[offset + 3] = value & 0xFF;
  44384. };
  44385. } else {
  44386. itemSize = 2;
  44387. itemDecode = function fontItemDecode(data, offset) {
  44388. return data[offset] << 9 | data[offset + 1] << 1;
  44389. };
  44390. itemEncode = function fontItemEncode(data, offset, value) {
  44391. data[offset] = value >> 9 & 0xFF;
  44392. data[offset + 1] = value >> 1 & 0xFF;
  44393. };
  44394. }
  44395. var locaData = loca.data;
  44396. var locaDataSize = itemSize * (1 + numGlyphs);
  44397. if (locaData.length !== locaDataSize) {
  44398. locaData = new Uint8Array(locaDataSize);
  44399. locaData.set(loca.data.subarray(0, locaDataSize));
  44400. loca.data = locaData;
  44401. }
  44402. var oldGlyfData = glyf.data;
  44403. var oldGlyfDataLength = oldGlyfData.length;
  44404. var newGlyfData = new Uint8Array(oldGlyfDataLength);
  44405. var startOffset = itemDecode(locaData, 0);
  44406. var writeOffset = 0;
  44407. var missingGlyphData = Object.create(null);
  44408. itemEncode(locaData, 0, writeOffset);
  44409. var i, j;
  44410. for (i = 0, j = itemSize; i < numGlyphs; i++, j += itemSize) {
  44411. var endOffset = itemDecode(locaData, j);
  44412. if (endOffset > oldGlyfDataLength && (oldGlyfDataLength + 3 & ~3) === endOffset) {
  44413. endOffset = oldGlyfDataLength;
  44414. }
  44415. if (endOffset > oldGlyfDataLength) {
  44416. itemEncode(locaData, j, writeOffset);
  44417. startOffset = endOffset;
  44418. continue;
  44419. }
  44420. if (startOffset === endOffset) {
  44421. missingGlyphData[i] = true;
  44422. }
  44423. var newLength = sanitizeGlyph(oldGlyfData, startOffset, endOffset, newGlyfData, writeOffset, hintsValid);
  44424. writeOffset += newLength;
  44425. itemEncode(locaData, j, writeOffset);
  44426. startOffset = endOffset;
  44427. }
  44428. if (writeOffset === 0) {
  44429. var simpleGlyph = new Uint8Array([
  44430. 0,
  44431. 1,
  44432. 0,
  44433. 0,
  44434. 0,
  44435. 0,
  44436. 0,
  44437. 0,
  44438. 0,
  44439. 0,
  44440. 0,
  44441. 0,
  44442. 0,
  44443. 0,
  44444. 49,
  44445. 0
  44446. ]);
  44447. for (i = 0, j = itemSize; i < numGlyphs; i++, j += itemSize) {
  44448. itemEncode(locaData, j, simpleGlyph.length);
  44449. }
  44450. glyf.data = simpleGlyph;
  44451. return missingGlyphData;
  44452. }
  44453. if (dupFirstEntry) {
  44454. var firstEntryLength = itemDecode(locaData, itemSize);
  44455. if (newGlyfData.length > firstEntryLength + writeOffset) {
  44456. glyf.data = newGlyfData.subarray(0, firstEntryLength + writeOffset);
  44457. } else {
  44458. glyf.data = new Uint8Array(firstEntryLength + writeOffset);
  44459. glyf.data.set(newGlyfData.subarray(0, writeOffset));
  44460. }
  44461. glyf.data.set(newGlyfData.subarray(0, firstEntryLength), writeOffset);
  44462. itemEncode(loca.data, locaData.length - itemSize, writeOffset + firstEntryLength);
  44463. } else {
  44464. glyf.data = newGlyfData.subarray(0, writeOffset);
  44465. }
  44466. return missingGlyphData;
  44467. }
  44468. function readPostScriptTable(post, properties, maxpNumGlyphs) {
  44469. var start = (font.start ? font.start : 0) + post.offset;
  44470. font.pos = start;
  44471. var length = post.length, end = start + length;
  44472. var version = font.getInt32();
  44473. font.getBytes(28);
  44474. var glyphNames;
  44475. var valid = true;
  44476. var i;
  44477. switch (version) {
  44478. case 0x00010000:
  44479. glyphNames = MacStandardGlyphOrdering;
  44480. break;
  44481. case 0x00020000:
  44482. var numGlyphs = font.getUint16();
  44483. if (numGlyphs !== maxpNumGlyphs) {
  44484. valid = false;
  44485. break;
  44486. }
  44487. var glyphNameIndexes = [];
  44488. for (i = 0; i < numGlyphs; ++i) {
  44489. var index = font.getUint16();
  44490. if (index >= 32768) {
  44491. valid = false;
  44492. break;
  44493. }
  44494. glyphNameIndexes.push(index);
  44495. }
  44496. if (!valid) {
  44497. break;
  44498. }
  44499. var customNames = [];
  44500. var strBuf = [];
  44501. while (font.pos < end) {
  44502. var stringLength = font.getByte();
  44503. strBuf.length = stringLength;
  44504. for (i = 0; i < stringLength; ++i) {
  44505. strBuf[i] = String.fromCharCode(font.getByte());
  44506. }
  44507. customNames.push(strBuf.join(''));
  44508. }
  44509. glyphNames = [];
  44510. for (i = 0; i < numGlyphs; ++i) {
  44511. var j = glyphNameIndexes[i];
  44512. if (j < 258) {
  44513. glyphNames.push(MacStandardGlyphOrdering[j]);
  44514. continue;
  44515. }
  44516. glyphNames.push(customNames[j - 258]);
  44517. }
  44518. break;
  44519. case 0x00030000:
  44520. break;
  44521. default:
  44522. warn('Unknown/unsupported post table version ' + version);
  44523. valid = false;
  44524. if (properties.defaultEncoding) {
  44525. glyphNames = properties.defaultEncoding;
  44526. }
  44527. break;
  44528. }
  44529. properties.glyphNames = glyphNames;
  44530. return valid;
  44531. }
  44532. function readNameTable(nameTable) {
  44533. var start = (font.start ? font.start : 0) + nameTable.offset;
  44534. font.pos = start;
  44535. var names = [
  44536. [],
  44537. []
  44538. ];
  44539. var length = nameTable.length, end = start + length;
  44540. var format = font.getUint16();
  44541. var FORMAT_0_HEADER_LENGTH = 6;
  44542. if (format !== 0 || length < FORMAT_0_HEADER_LENGTH) {
  44543. return names;
  44544. }
  44545. var numRecords = font.getUint16();
  44546. var stringsStart = font.getUint16();
  44547. var records = [];
  44548. var NAME_RECORD_LENGTH = 12;
  44549. var i, ii;
  44550. for (i = 0; i < numRecords && font.pos + NAME_RECORD_LENGTH <= end; i++) {
  44551. var r = {
  44552. platform: font.getUint16(),
  44553. encoding: font.getUint16(),
  44554. language: font.getUint16(),
  44555. name: font.getUint16(),
  44556. length: font.getUint16(),
  44557. offset: font.getUint16()
  44558. };
  44559. if (r.platform === 1 && r.encoding === 0 && r.language === 0 || r.platform === 3 && r.encoding === 1 && r.language === 0x409) {
  44560. records.push(r);
  44561. }
  44562. }
  44563. for (i = 0, ii = records.length; i < ii; i++) {
  44564. var record = records[i];
  44565. if (record.length <= 0) {
  44566. continue;
  44567. }
  44568. var pos = start + stringsStart + record.offset;
  44569. if (pos + record.length > end) {
  44570. continue;
  44571. }
  44572. font.pos = pos;
  44573. var nameIndex = record.name;
  44574. if (record.encoding) {
  44575. var str = '';
  44576. for (var j = 0, jj = record.length; j < jj; j += 2) {
  44577. str += String.fromCharCode(font.getUint16());
  44578. }
  44579. names[1][nameIndex] = str;
  44580. } else {
  44581. names[0][nameIndex] = bytesToString(font.getBytes(record.length));
  44582. }
  44583. }
  44584. return names;
  44585. }
  44586. var TTOpsStackDeltas = [
  44587. 0,
  44588. 0,
  44589. 0,
  44590. 0,
  44591. 0,
  44592. 0,
  44593. 0,
  44594. 0,
  44595. -2,
  44596. -2,
  44597. -2,
  44598. -2,
  44599. 0,
  44600. 0,
  44601. -2,
  44602. -5,
  44603. -1,
  44604. -1,
  44605. -1,
  44606. -1,
  44607. -1,
  44608. -1,
  44609. -1,
  44610. -1,
  44611. 0,
  44612. 0,
  44613. -1,
  44614. 0,
  44615. -1,
  44616. -1,
  44617. -1,
  44618. -1,
  44619. 1,
  44620. -1,
  44621. -999,
  44622. 0,
  44623. 1,
  44624. 0,
  44625. -1,
  44626. -2,
  44627. 0,
  44628. -1,
  44629. -2,
  44630. -1,
  44631. -1,
  44632. 0,
  44633. -1,
  44634. -1,
  44635. 0,
  44636. 0,
  44637. -999,
  44638. -999,
  44639. -1,
  44640. -1,
  44641. -1,
  44642. -1,
  44643. -2,
  44644. -999,
  44645. -2,
  44646. -2,
  44647. -999,
  44648. 0,
  44649. -2,
  44650. -2,
  44651. 0,
  44652. 0,
  44653. -2,
  44654. 0,
  44655. -2,
  44656. 0,
  44657. 0,
  44658. 0,
  44659. -2,
  44660. -1,
  44661. -1,
  44662. 1,
  44663. 1,
  44664. 0,
  44665. 0,
  44666. -1,
  44667. -1,
  44668. -1,
  44669. -1,
  44670. -1,
  44671. -1,
  44672. -1,
  44673. 0,
  44674. 0,
  44675. -1,
  44676. 0,
  44677. -1,
  44678. -1,
  44679. 0,
  44680. -999,
  44681. -1,
  44682. -1,
  44683. -1,
  44684. -1,
  44685. -1,
  44686. -1,
  44687. 0,
  44688. 0,
  44689. 0,
  44690. 0,
  44691. 0,
  44692. 0,
  44693. 0,
  44694. 0,
  44695. 0,
  44696. 0,
  44697. 0,
  44698. 0,
  44699. -2,
  44700. -999,
  44701. -999,
  44702. -999,
  44703. -999,
  44704. -999,
  44705. -1,
  44706. -1,
  44707. -2,
  44708. -2,
  44709. 0,
  44710. 0,
  44711. 0,
  44712. 0,
  44713. -1,
  44714. -1,
  44715. -999,
  44716. -2,
  44717. -2,
  44718. 0,
  44719. 0,
  44720. -1,
  44721. -2,
  44722. -2,
  44723. 0,
  44724. 0,
  44725. 0,
  44726. -1,
  44727. -1,
  44728. -1,
  44729. -2
  44730. ];
  44731. function sanitizeTTProgram(table, ttContext) {
  44732. var data = table.data;
  44733. var i = 0, j, n, b, funcId, pc, lastEndf = 0, lastDeff = 0;
  44734. var stack = [];
  44735. var callstack = [];
  44736. var functionsCalled = [];
  44737. var tooComplexToFollowFunctions = ttContext.tooComplexToFollowFunctions;
  44738. var inFDEF = false, ifLevel = 0, inELSE = 0;
  44739. for (var ii = data.length; i < ii;) {
  44740. var op = data[i++];
  44741. if (op === 0x40) {
  44742. n = data[i++];
  44743. if (inFDEF || inELSE) {
  44744. i += n;
  44745. } else {
  44746. for (j = 0; j < n; j++) {
  44747. stack.push(data[i++]);
  44748. }
  44749. }
  44750. } else if (op === 0x41) {
  44751. n = data[i++];
  44752. if (inFDEF || inELSE) {
  44753. i += n * 2;
  44754. } else {
  44755. for (j = 0; j < n; j++) {
  44756. b = data[i++];
  44757. stack.push(b << 8 | data[i++]);
  44758. }
  44759. }
  44760. } else if ((op & 0xF8) === 0xB0) {
  44761. n = op - 0xB0 + 1;
  44762. if (inFDEF || inELSE) {
  44763. i += n;
  44764. } else {
  44765. for (j = 0; j < n; j++) {
  44766. stack.push(data[i++]);
  44767. }
  44768. }
  44769. } else if ((op & 0xF8) === 0xB8) {
  44770. n = op - 0xB8 + 1;
  44771. if (inFDEF || inELSE) {
  44772. i += n * 2;
  44773. } else {
  44774. for (j = 0; j < n; j++) {
  44775. b = data[i++];
  44776. stack.push(b << 8 | data[i++]);
  44777. }
  44778. }
  44779. } else if (op === 0x2B && !tooComplexToFollowFunctions) {
  44780. if (!inFDEF && !inELSE) {
  44781. funcId = stack[stack.length - 1];
  44782. ttContext.functionsUsed[funcId] = true;
  44783. if (funcId in ttContext.functionsStackDeltas) {
  44784. stack.length += ttContext.functionsStackDeltas[funcId];
  44785. } else if (funcId in ttContext.functionsDefined && functionsCalled.indexOf(funcId) < 0) {
  44786. callstack.push({
  44787. data: data,
  44788. i: i,
  44789. stackTop: stack.length - 1
  44790. });
  44791. functionsCalled.push(funcId);
  44792. pc = ttContext.functionsDefined[funcId];
  44793. if (!pc) {
  44794. warn('TT: CALL non-existent function');
  44795. ttContext.hintsValid = false;
  44796. return;
  44797. }
  44798. data = pc.data;
  44799. i = pc.i;
  44800. }
  44801. }
  44802. } else if (op === 0x2C && !tooComplexToFollowFunctions) {
  44803. if (inFDEF || inELSE) {
  44804. warn('TT: nested FDEFs not allowed');
  44805. tooComplexToFollowFunctions = true;
  44806. }
  44807. inFDEF = true;
  44808. lastDeff = i;
  44809. funcId = stack.pop();
  44810. ttContext.functionsDefined[funcId] = {
  44811. data: data,
  44812. i: i
  44813. };
  44814. } else if (op === 0x2D) {
  44815. if (inFDEF) {
  44816. inFDEF = false;
  44817. lastEndf = i;
  44818. } else {
  44819. pc = callstack.pop();
  44820. if (!pc) {
  44821. warn('TT: ENDF bad stack');
  44822. ttContext.hintsValid = false;
  44823. return;
  44824. }
  44825. funcId = functionsCalled.pop();
  44826. data = pc.data;
  44827. i = pc.i;
  44828. ttContext.functionsStackDeltas[funcId] = stack.length - pc.stackTop;
  44829. }
  44830. } else if (op === 0x89) {
  44831. if (inFDEF || inELSE) {
  44832. warn('TT: nested IDEFs not allowed');
  44833. tooComplexToFollowFunctions = true;
  44834. }
  44835. inFDEF = true;
  44836. lastDeff = i;
  44837. } else if (op === 0x58) {
  44838. ++ifLevel;
  44839. } else if (op === 0x1B) {
  44840. inELSE = ifLevel;
  44841. } else if (op === 0x59) {
  44842. if (inELSE === ifLevel) {
  44843. inELSE = 0;
  44844. }
  44845. --ifLevel;
  44846. } else if (op === 0x1C) {
  44847. if (!inFDEF && !inELSE) {
  44848. var offset = stack[stack.length - 1];
  44849. if (offset > 0) {
  44850. i += offset - 1;
  44851. }
  44852. }
  44853. }
  44854. if (!inFDEF && !inELSE) {
  44855. var stackDelta = op <= 0x8E ? TTOpsStackDeltas[op] : op >= 0xC0 && op <= 0xDF ? -1 : op >= 0xE0 ? -2 : 0;
  44856. if (op >= 0x71 && op <= 0x75) {
  44857. n = stack.pop();
  44858. if (!isNaN(n)) {
  44859. stackDelta = -n * 2;
  44860. }
  44861. }
  44862. while (stackDelta < 0 && stack.length > 0) {
  44863. stack.pop();
  44864. stackDelta++;
  44865. }
  44866. while (stackDelta > 0) {
  44867. stack.push(NaN);
  44868. stackDelta--;
  44869. }
  44870. }
  44871. }
  44872. ttContext.tooComplexToFollowFunctions = tooComplexToFollowFunctions;
  44873. var content = [data];
  44874. if (i > data.length) {
  44875. content.push(new Uint8Array(i - data.length));
  44876. }
  44877. if (lastDeff > lastEndf) {
  44878. warn('TT: complementing a missing function tail');
  44879. content.push(new Uint8Array([
  44880. 0x22,
  44881. 0x2D
  44882. ]));
  44883. }
  44884. foldTTTable(table, content);
  44885. }
  44886. function checkInvalidFunctions(ttContext, maxFunctionDefs) {
  44887. if (ttContext.tooComplexToFollowFunctions) {
  44888. return;
  44889. }
  44890. if (ttContext.functionsDefined.length > maxFunctionDefs) {
  44891. warn('TT: more functions defined than expected');
  44892. ttContext.hintsValid = false;
  44893. return;
  44894. }
  44895. for (var j = 0, jj = ttContext.functionsUsed.length; j < jj; j++) {
  44896. if (j > maxFunctionDefs) {
  44897. warn('TT: invalid function id: ' + j);
  44898. ttContext.hintsValid = false;
  44899. return;
  44900. }
  44901. if (ttContext.functionsUsed[j] && !ttContext.functionsDefined[j]) {
  44902. warn('TT: undefined function: ' + j);
  44903. ttContext.hintsValid = false;
  44904. return;
  44905. }
  44906. }
  44907. }
  44908. function foldTTTable(table, content) {
  44909. if (content.length > 1) {
  44910. var newLength = 0;
  44911. var j, jj;
  44912. for (j = 0, jj = content.length; j < jj; j++) {
  44913. newLength += content[j].length;
  44914. }
  44915. newLength = newLength + 3 & ~3;
  44916. var result = new Uint8Array(newLength);
  44917. var pos = 0;
  44918. for (j = 0, jj = content.length; j < jj; j++) {
  44919. result.set(content[j], pos);
  44920. pos += content[j].length;
  44921. }
  44922. table.data = result;
  44923. table.length = newLength;
  44924. }
  44925. }
  44926. function sanitizeTTPrograms(fpgm, prep, cvt, maxFunctionDefs) {
  44927. var ttContext = {
  44928. functionsDefined: [],
  44929. functionsUsed: [],
  44930. functionsStackDeltas: [],
  44931. tooComplexToFollowFunctions: false,
  44932. hintsValid: true
  44933. };
  44934. if (fpgm) {
  44935. sanitizeTTProgram(fpgm, ttContext);
  44936. }
  44937. if (prep) {
  44938. sanitizeTTProgram(prep, ttContext);
  44939. }
  44940. if (fpgm) {
  44941. checkInvalidFunctions(ttContext, maxFunctionDefs);
  44942. }
  44943. if (cvt && cvt.length & 1) {
  44944. var cvtData = new Uint8Array(cvt.length + 1);
  44945. cvtData.set(cvt.data);
  44946. cvt.data = cvtData;
  44947. }
  44948. return ttContext.hintsValid;
  44949. }
  44950. font = new Stream(new Uint8Array(font.getBytes()));
  44951. var VALID_TABLES = [
  44952. 'OS/2',
  44953. 'cmap',
  44954. 'head',
  44955. 'hhea',
  44956. 'hmtx',
  44957. 'maxp',
  44958. 'name',
  44959. 'post',
  44960. 'loca',
  44961. 'glyf',
  44962. 'fpgm',
  44963. 'prep',
  44964. 'cvt ',
  44965. 'CFF '
  44966. ];
  44967. var header = readOpenTypeHeader(font);
  44968. var numTables = header.numTables;
  44969. var cff, cffFile;
  44970. var tables = Object.create(null);
  44971. tables['OS/2'] = null;
  44972. tables['cmap'] = null;
  44973. tables['head'] = null;
  44974. tables['hhea'] = null;
  44975. tables['hmtx'] = null;
  44976. tables['maxp'] = null;
  44977. tables['name'] = null;
  44978. tables['post'] = null;
  44979. var table;
  44980. for (var i = 0; i < numTables; i++) {
  44981. table = readTableEntry(font);
  44982. if (VALID_TABLES.indexOf(table.tag) < 0) {
  44983. continue;
  44984. }
  44985. if (table.length === 0) {
  44986. continue;
  44987. }
  44988. tables[table.tag] = table;
  44989. }
  44990. var isTrueType = !tables['CFF '];
  44991. if (!isTrueType) {
  44992. if (header.version === 'OTTO' && !properties.composite || !tables['head'] || !tables['hhea'] || !tables['maxp'] || !tables['post']) {
  44993. cffFile = new Stream(tables['CFF '].data);
  44994. cff = new CFFFont(cffFile, properties);
  44995. adjustWidths(properties);
  44996. return this.convert(name, cff, properties);
  44997. }
  44998. delete tables['glyf'];
  44999. delete tables['loca'];
  45000. delete tables['fpgm'];
  45001. delete tables['prep'];
  45002. delete tables['cvt '];
  45003. this.isOpenType = true;
  45004. } else {
  45005. if (!tables['loca']) {
  45006. error('Required "loca" table is not found');
  45007. }
  45008. if (!tables['glyf']) {
  45009. warn('Required "glyf" table is not found -- trying to recover.');
  45010. tables['glyf'] = {
  45011. tag: 'glyf',
  45012. data: new Uint8Array(0)
  45013. };
  45014. }
  45015. this.isOpenType = false;
  45016. }
  45017. if (!tables['maxp']) {
  45018. error('Required "maxp" table is not found');
  45019. }
  45020. font.pos = (font.start || 0) + tables['maxp'].offset;
  45021. var version = font.getInt32();
  45022. var numGlyphs = font.getUint16();
  45023. var maxFunctionDefs = 0;
  45024. if (version >= 0x00010000 && tables['maxp'].length >= 22) {
  45025. font.pos += 8;
  45026. var maxZones = font.getUint16();
  45027. if (maxZones > 2) {
  45028. tables['maxp'].data[14] = 0;
  45029. tables['maxp'].data[15] = 2;
  45030. }
  45031. font.pos += 4;
  45032. maxFunctionDefs = font.getUint16();
  45033. }
  45034. var dupFirstEntry = false;
  45035. if (properties.type === 'CIDFontType2' && properties.toUnicode && properties.toUnicode.get(0) > '\u0000') {
  45036. dupFirstEntry = true;
  45037. numGlyphs++;
  45038. tables['maxp'].data[4] = numGlyphs >> 8;
  45039. tables['maxp'].data[5] = numGlyphs & 255;
  45040. }
  45041. var hintsValid = sanitizeTTPrograms(tables['fpgm'], tables['prep'], tables['cvt '], maxFunctionDefs);
  45042. if (!hintsValid) {
  45043. delete tables['fpgm'];
  45044. delete tables['prep'];
  45045. delete tables['cvt '];
  45046. }
  45047. sanitizeMetrics(font, tables['hhea'], tables['hmtx'], numGlyphs);
  45048. if (!tables['head']) {
  45049. error('Required "head" table is not found');
  45050. }
  45051. sanitizeHead(tables['head'], numGlyphs, isTrueType ? tables['loca'].length : 0);
  45052. var missingGlyphs = Object.create(null);
  45053. if (isTrueType) {
  45054. var isGlyphLocationsLong = int16(tables['head'].data[50], tables['head'].data[51]);
  45055. missingGlyphs = sanitizeGlyphLocations(tables['loca'], tables['glyf'], numGlyphs, isGlyphLocationsLong, hintsValid, dupFirstEntry);
  45056. }
  45057. if (!tables['hhea']) {
  45058. error('Required "hhea" table is not found');
  45059. }
  45060. if (tables['hhea'].data[10] === 0 && tables['hhea'].data[11] === 0) {
  45061. tables['hhea'].data[10] = 0xFF;
  45062. tables['hhea'].data[11] = 0xFF;
  45063. }
  45064. var metricsOverride = {
  45065. unitsPerEm: int16(tables['head'].data[18], tables['head'].data[19]),
  45066. yMax: int16(tables['head'].data[42], tables['head'].data[43]),
  45067. yMin: signedInt16(tables['head'].data[38], tables['head'].data[39]),
  45068. ascent: int16(tables['hhea'].data[4], tables['hhea'].data[5]),
  45069. descent: signedInt16(tables['hhea'].data[6], tables['hhea'].data[7])
  45070. };
  45071. this.ascent = metricsOverride.ascent / metricsOverride.unitsPerEm;
  45072. this.descent = metricsOverride.descent / metricsOverride.unitsPerEm;
  45073. if (tables['post']) {
  45074. var valid = readPostScriptTable(tables['post'], properties, numGlyphs);
  45075. if (!valid) {
  45076. tables['post'] = null;
  45077. }
  45078. }
  45079. var charCodeToGlyphId = [], charCode;
  45080. var toUnicode = properties.toUnicode, widths = properties.widths;
  45081. var skipToUnicode = toUnicode instanceof IdentityToUnicodeMap || toUnicode.length === 0x10000;
  45082. function hasGlyph(glyphId, charCode, widthCode) {
  45083. if (!missingGlyphs[glyphId]) {
  45084. return true;
  45085. }
  45086. if (!skipToUnicode && charCode >= 0 && toUnicode.has(charCode)) {
  45087. return true;
  45088. }
  45089. if (widths && widthCode >= 0 && isNum(widths[widthCode])) {
  45090. return true;
  45091. }
  45092. return false;
  45093. }
  45094. if (properties.composite) {
  45095. var cidToGidMap = properties.cidToGidMap || [];
  45096. var isCidToGidMapEmpty = cidToGidMap.length === 0;
  45097. properties.cMap.forEach(function (charCode, cid) {
  45098. assert(cid <= 0xffff, 'Max size of CID is 65,535');
  45099. var glyphId = -1;
  45100. if (isCidToGidMapEmpty) {
  45101. glyphId = cid;
  45102. } else if (cidToGidMap[cid] !== undefined) {
  45103. glyphId = cidToGidMap[cid];
  45104. }
  45105. if (glyphId >= 0 && glyphId < numGlyphs && hasGlyph(glyphId, charCode, cid)) {
  45106. charCodeToGlyphId[charCode] = glyphId;
  45107. }
  45108. });
  45109. if (dupFirstEntry && (isCidToGidMapEmpty || !charCodeToGlyphId[0])) {
  45110. charCodeToGlyphId[0] = numGlyphs - 1;
  45111. }
  45112. } else {
  45113. var cmapTable = readCmapTable(tables['cmap'], font, this.isSymbolicFont, properties.hasEncoding);
  45114. var cmapPlatformId = cmapTable.platformId;
  45115. var cmapEncodingId = cmapTable.encodingId;
  45116. var cmapMappings = cmapTable.mappings;
  45117. var cmapMappingsLength = cmapMappings.length;
  45118. if (properties.hasEncoding && (cmapPlatformId === 3 && cmapEncodingId === 1 || cmapPlatformId === 1 && cmapEncodingId === 0) || cmapPlatformId === -1 && cmapEncodingId === -1 && !!getEncoding(properties.baseEncodingName)) {
  45119. var baseEncoding = [];
  45120. if (properties.baseEncodingName === 'MacRomanEncoding' || properties.baseEncodingName === 'WinAnsiEncoding') {
  45121. baseEncoding = getEncoding(properties.baseEncodingName);
  45122. }
  45123. var glyphsUnicodeMap = getGlyphsUnicode();
  45124. for (charCode = 0; charCode < 256; charCode++) {
  45125. var glyphName, standardGlyphName;
  45126. if (this.differences && charCode in this.differences) {
  45127. glyphName = this.differences[charCode];
  45128. } else if (charCode in baseEncoding && baseEncoding[charCode] !== '') {
  45129. glyphName = baseEncoding[charCode];
  45130. } else {
  45131. glyphName = StandardEncoding[charCode];
  45132. }
  45133. if (!glyphName) {
  45134. continue;
  45135. }
  45136. standardGlyphName = recoverGlyphName(glyphName, glyphsUnicodeMap);
  45137. var unicodeOrCharCode, isUnicode = false;
  45138. if (cmapPlatformId === 3 && cmapEncodingId === 1) {
  45139. unicodeOrCharCode = glyphsUnicodeMap[standardGlyphName];
  45140. isUnicode = true;
  45141. } else if (cmapPlatformId === 1 && cmapEncodingId === 0) {
  45142. unicodeOrCharCode = MacRomanEncoding.indexOf(standardGlyphName);
  45143. }
  45144. var found = false;
  45145. for (i = 0; i < cmapMappingsLength; ++i) {
  45146. if (cmapMappings[i].charCode !== unicodeOrCharCode) {
  45147. continue;
  45148. }
  45149. var code = isUnicode ? charCode : unicodeOrCharCode;
  45150. if (hasGlyph(cmapMappings[i].glyphId, code, -1)) {
  45151. charCodeToGlyphId[charCode] = cmapMappings[i].glyphId;
  45152. found = true;
  45153. break;
  45154. }
  45155. }
  45156. if (!found && properties.glyphNames) {
  45157. var glyphId = properties.glyphNames.indexOf(glyphName);
  45158. if (glyphId === -1 && standardGlyphName !== glyphName) {
  45159. glyphId = properties.glyphNames.indexOf(standardGlyphName);
  45160. }
  45161. if (glyphId > 0 && hasGlyph(glyphId, -1, -1)) {
  45162. charCodeToGlyphId[charCode] = glyphId;
  45163. found = true;
  45164. }
  45165. }
  45166. if (!found) {
  45167. charCodeToGlyphId[charCode] = 0;
  45168. }
  45169. }
  45170. } else if (cmapPlatformId === 0 && cmapEncodingId === 0) {
  45171. for (i = 0; i < cmapMappingsLength; ++i) {
  45172. charCodeToGlyphId[cmapMappings[i].charCode] = cmapMappings[i].glyphId;
  45173. }
  45174. } else {
  45175. for (i = 0; i < cmapMappingsLength; ++i) {
  45176. charCode = cmapMappings[i].charCode & 0xFF;
  45177. charCodeToGlyphId[charCode] = cmapMappings[i].glyphId;
  45178. }
  45179. }
  45180. }
  45181. if (charCodeToGlyphId.length === 0) {
  45182. charCodeToGlyphId[0] = 0;
  45183. }
  45184. var newMapping = adjustMapping(charCodeToGlyphId, properties);
  45185. this.toFontChar = newMapping.toFontChar;
  45186. tables['cmap'] = {
  45187. tag: 'cmap',
  45188. data: createCmapTable(newMapping.charCodeToGlyphId, numGlyphs)
  45189. };
  45190. if (!tables['OS/2'] || !validateOS2Table(tables['OS/2'])) {
  45191. tables['OS/2'] = {
  45192. tag: 'OS/2',
  45193. data: createOS2Table(properties, newMapping.charCodeToGlyphId, metricsOverride)
  45194. };
  45195. }
  45196. if (!tables['post']) {
  45197. tables['post'] = {
  45198. tag: 'post',
  45199. data: createPostTable(properties)
  45200. };
  45201. }
  45202. if (!isTrueType) {
  45203. try {
  45204. cffFile = new Stream(tables['CFF '].data);
  45205. var parser = new CFFParser(cffFile, properties, SEAC_ANALYSIS_ENABLED);
  45206. cff = parser.parse();
  45207. var compiler = new CFFCompiler(cff);
  45208. tables['CFF '].data = compiler.compile();
  45209. } catch (e) {
  45210. warn('Failed to compile font ' + properties.loadedName);
  45211. }
  45212. }
  45213. if (!tables['name']) {
  45214. tables['name'] = {
  45215. tag: 'name',
  45216. data: createNameTable(this.name)
  45217. };
  45218. } else {
  45219. var namePrototype = readNameTable(tables['name']);
  45220. tables['name'].data = createNameTable(name, namePrototype);
  45221. }
  45222. var builder = new OpenTypeFileBuilder(header.version);
  45223. for (var tableTag in tables) {
  45224. builder.addTable(tableTag, tables[tableTag].data);
  45225. }
  45226. return builder.toArray();
  45227. },
  45228. convert: function Font_convert(fontName, font, properties) {
  45229. properties.fixedPitch = false;
  45230. if (properties.builtInEncoding) {
  45231. adjustToUnicode(properties, properties.builtInEncoding);
  45232. }
  45233. var mapping = font.getGlyphMapping(properties);
  45234. var newMapping = adjustMapping(mapping, properties);
  45235. this.toFontChar = newMapping.toFontChar;
  45236. var numGlyphs = font.numGlyphs;
  45237. function getCharCodes(charCodeToGlyphId, glyphId) {
  45238. var charCodes = null;
  45239. for (var charCode in charCodeToGlyphId) {
  45240. if (glyphId === charCodeToGlyphId[charCode]) {
  45241. if (!charCodes) {
  45242. charCodes = [];
  45243. }
  45244. charCodes.push(charCode | 0);
  45245. }
  45246. }
  45247. return charCodes;
  45248. }
  45249. function createCharCode(charCodeToGlyphId, glyphId) {
  45250. for (var charCode in charCodeToGlyphId) {
  45251. if (glyphId === charCodeToGlyphId[charCode]) {
  45252. return charCode | 0;
  45253. }
  45254. }
  45255. newMapping.charCodeToGlyphId[newMapping.nextAvailableFontCharCode] = glyphId;
  45256. return newMapping.nextAvailableFontCharCode++;
  45257. }
  45258. var seacs = font.seacs;
  45259. if (SEAC_ANALYSIS_ENABLED && seacs && seacs.length) {
  45260. var matrix = properties.fontMatrix || FONT_IDENTITY_MATRIX;
  45261. var charset = font.getCharset();
  45262. var seacMap = Object.create(null);
  45263. for (var glyphId in seacs) {
  45264. glyphId |= 0;
  45265. var seac = seacs[glyphId];
  45266. var baseGlyphName = StandardEncoding[seac[2]];
  45267. var accentGlyphName = StandardEncoding[seac[3]];
  45268. var baseGlyphId = charset.indexOf(baseGlyphName);
  45269. var accentGlyphId = charset.indexOf(accentGlyphName);
  45270. if (baseGlyphId < 0 || accentGlyphId < 0) {
  45271. continue;
  45272. }
  45273. var accentOffset = {
  45274. x: seac[0] * matrix[0] + seac[1] * matrix[2] + matrix[4],
  45275. y: seac[0] * matrix[1] + seac[1] * matrix[3] + matrix[5]
  45276. };
  45277. var charCodes = getCharCodes(mapping, glyphId);
  45278. if (!charCodes) {
  45279. continue;
  45280. }
  45281. for (var i = 0, ii = charCodes.length; i < ii; i++) {
  45282. var charCode = charCodes[i];
  45283. var charCodeToGlyphId = newMapping.charCodeToGlyphId;
  45284. var baseFontCharCode = createCharCode(charCodeToGlyphId, baseGlyphId);
  45285. var accentFontCharCode = createCharCode(charCodeToGlyphId, accentGlyphId);
  45286. seacMap[charCode] = {
  45287. baseFontCharCode: baseFontCharCode,
  45288. accentFontCharCode: accentFontCharCode,
  45289. accentOffset: accentOffset
  45290. };
  45291. }
  45292. }
  45293. properties.seacMap = seacMap;
  45294. }
  45295. var unitsPerEm = 1 / (properties.fontMatrix || FONT_IDENTITY_MATRIX)[0];
  45296. var builder = new OpenTypeFileBuilder('\x4F\x54\x54\x4F');
  45297. builder.addTable('CFF ', font.data);
  45298. builder.addTable('OS/2', createOS2Table(properties, newMapping.charCodeToGlyphId));
  45299. builder.addTable('cmap', createCmapTable(newMapping.charCodeToGlyphId, numGlyphs));
  45300. 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');
  45301. 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));
  45302. builder.addTable('hmtx', function fontFieldsHmtx() {
  45303. var charstrings = font.charstrings;
  45304. var cffWidths = font.cff ? font.cff.widths : null;
  45305. var hmtx = '\x00\x00\x00\x00';
  45306. for (var i = 1, ii = numGlyphs; i < ii; i++) {
  45307. var width = 0;
  45308. if (charstrings) {
  45309. var charstring = charstrings[i - 1];
  45310. width = 'width' in charstring ? charstring.width : 0;
  45311. } else if (cffWidths) {
  45312. width = Math.ceil(cffWidths[i] || 0);
  45313. }
  45314. hmtx += string16(width) + string16(0);
  45315. }
  45316. return hmtx;
  45317. }());
  45318. builder.addTable('maxp', '\x00\x00\x50\x00' + string16(numGlyphs));
  45319. builder.addTable('name', createNameTable(fontName));
  45320. builder.addTable('post', createPostTable(properties));
  45321. return builder.toArray();
  45322. },
  45323. get spaceWidth() {
  45324. if ('_shadowWidth' in this) {
  45325. return this._shadowWidth;
  45326. }
  45327. var possibleSpaceReplacements = [
  45328. 'space',
  45329. 'minus',
  45330. 'one',
  45331. 'i',
  45332. 'I'
  45333. ];
  45334. var width;
  45335. for (var i = 0, ii = possibleSpaceReplacements.length; i < ii; i++) {
  45336. var glyphName = possibleSpaceReplacements[i];
  45337. if (glyphName in this.widths) {
  45338. width = this.widths[glyphName];
  45339. break;
  45340. }
  45341. var glyphsUnicodeMap = getGlyphsUnicode();
  45342. var glyphUnicode = glyphsUnicodeMap[glyphName];
  45343. var charcode = 0;
  45344. if (this.composite) {
  45345. if (this.cMap.contains(glyphUnicode)) {
  45346. charcode = this.cMap.lookup(glyphUnicode);
  45347. }
  45348. }
  45349. if (!charcode && this.toUnicode) {
  45350. charcode = this.toUnicode.charCodeOf(glyphUnicode);
  45351. }
  45352. if (charcode <= 0) {
  45353. charcode = glyphUnicode;
  45354. }
  45355. width = this.widths[charcode];
  45356. if (width) {
  45357. break;
  45358. }
  45359. }
  45360. width = width || this.defaultWidth;
  45361. this._shadowWidth = width;
  45362. return width;
  45363. },
  45364. charToGlyph: function Font_charToGlyph(charcode, isSpace) {
  45365. var fontCharCode, width, operatorListId;
  45366. var widthCode = charcode;
  45367. if (this.cMap && this.cMap.contains(charcode)) {
  45368. widthCode = this.cMap.lookup(charcode);
  45369. }
  45370. width = this.widths[widthCode];
  45371. width = isNum(width) ? width : this.defaultWidth;
  45372. var vmetric = this.vmetrics && this.vmetrics[widthCode];
  45373. var unicode = this.toUnicode.get(charcode) || charcode;
  45374. if (typeof unicode === 'number') {
  45375. unicode = String.fromCharCode(unicode);
  45376. }
  45377. var isInFont = charcode in this.toFontChar;
  45378. fontCharCode = this.toFontChar[charcode] || charcode;
  45379. if (this.missingFile) {
  45380. fontCharCode = mapSpecialUnicodeValues(fontCharCode);
  45381. }
  45382. if (this.isType3Font) {
  45383. operatorListId = fontCharCode;
  45384. }
  45385. var accent = null;
  45386. if (this.seacMap && this.seacMap[charcode]) {
  45387. isInFont = true;
  45388. var seac = this.seacMap[charcode];
  45389. fontCharCode = seac.baseFontCharCode;
  45390. accent = {
  45391. fontChar: String.fromCharCode(seac.accentFontCharCode),
  45392. offset: seac.accentOffset
  45393. };
  45394. }
  45395. var fontChar = String.fromCharCode(fontCharCode);
  45396. var glyph = this.glyphCache[charcode];
  45397. if (!glyph || !glyph.matchesForCache(fontChar, unicode, accent, width, vmetric, operatorListId, isSpace, isInFont)) {
  45398. glyph = new Glyph(fontChar, unicode, accent, width, vmetric, operatorListId, isSpace, isInFont);
  45399. this.glyphCache[charcode] = glyph;
  45400. }
  45401. return glyph;
  45402. },
  45403. charsToGlyphs: function Font_charsToGlyphs(chars) {
  45404. var charsCache = this.charsCache;
  45405. var glyphs, glyph, charcode;
  45406. if (charsCache) {
  45407. glyphs = charsCache[chars];
  45408. if (glyphs) {
  45409. return glyphs;
  45410. }
  45411. }
  45412. if (!charsCache) {
  45413. charsCache = this.charsCache = Object.create(null);
  45414. }
  45415. glyphs = [];
  45416. var charsCacheKey = chars;
  45417. var i = 0, ii;
  45418. if (this.cMap) {
  45419. var c = Object.create(null);
  45420. while (i < chars.length) {
  45421. this.cMap.readCharCode(chars, i, c);
  45422. charcode = c.charcode;
  45423. var length = c.length;
  45424. i += length;
  45425. var isSpace = length === 1 && chars.charCodeAt(i - 1) === 0x20;
  45426. glyph = this.charToGlyph(charcode, isSpace);
  45427. glyphs.push(glyph);
  45428. }
  45429. } else {
  45430. for (i = 0, ii = chars.length; i < ii; ++i) {
  45431. charcode = chars.charCodeAt(i);
  45432. glyph = this.charToGlyph(charcode, charcode === 0x20);
  45433. glyphs.push(glyph);
  45434. }
  45435. }
  45436. return charsCache[charsCacheKey] = glyphs;
  45437. }
  45438. };
  45439. return Font;
  45440. }();
  45441. var ErrorFont = function ErrorFontClosure() {
  45442. function ErrorFont(error) {
  45443. this.error = error;
  45444. this.loadedName = 'g_font_error';
  45445. this.loading = false;
  45446. }
  45447. ErrorFont.prototype = {
  45448. charsToGlyphs: function ErrorFont_charsToGlyphs() {
  45449. return [];
  45450. },
  45451. exportData: function ErrorFont_exportData() {
  45452. return { error: this.error };
  45453. }
  45454. };
  45455. return ErrorFont;
  45456. }();
  45457. function type1FontGlyphMapping(properties, builtInEncoding, glyphNames) {
  45458. var charCodeToGlyphId = Object.create(null);
  45459. var glyphId, charCode, baseEncoding;
  45460. var isSymbolicFont = !!(properties.flags & FontFlags.Symbolic);
  45461. if (properties.baseEncodingName) {
  45462. baseEncoding = getEncoding(properties.baseEncodingName);
  45463. for (charCode = 0; charCode < baseEncoding.length; charCode++) {
  45464. glyphId = glyphNames.indexOf(baseEncoding[charCode]);
  45465. if (glyphId >= 0) {
  45466. charCodeToGlyphId[charCode] = glyphId;
  45467. } else {
  45468. charCodeToGlyphId[charCode] = 0;
  45469. }
  45470. }
  45471. } else if (isSymbolicFont) {
  45472. for (charCode in builtInEncoding) {
  45473. charCodeToGlyphId[charCode] = builtInEncoding[charCode];
  45474. }
  45475. } else {
  45476. baseEncoding = StandardEncoding;
  45477. for (charCode = 0; charCode < baseEncoding.length; charCode++) {
  45478. glyphId = glyphNames.indexOf(baseEncoding[charCode]);
  45479. if (glyphId >= 0) {
  45480. charCodeToGlyphId[charCode] = glyphId;
  45481. } else {
  45482. charCodeToGlyphId[charCode] = 0;
  45483. }
  45484. }
  45485. }
  45486. var differences = properties.differences, glyphsUnicodeMap;
  45487. if (differences) {
  45488. for (charCode in differences) {
  45489. var glyphName = differences[charCode];
  45490. glyphId = glyphNames.indexOf(glyphName);
  45491. if (glyphId === -1) {
  45492. if (!glyphsUnicodeMap) {
  45493. glyphsUnicodeMap = getGlyphsUnicode();
  45494. }
  45495. var standardGlyphName = recoverGlyphName(glyphName, glyphsUnicodeMap);
  45496. if (standardGlyphName !== glyphName) {
  45497. glyphId = glyphNames.indexOf(standardGlyphName);
  45498. }
  45499. }
  45500. if (glyphId >= 0) {
  45501. charCodeToGlyphId[charCode] = glyphId;
  45502. } else {
  45503. charCodeToGlyphId[charCode] = 0;
  45504. }
  45505. }
  45506. }
  45507. return charCodeToGlyphId;
  45508. }
  45509. var Type1Font = function Type1FontClosure() {
  45510. function findBlock(streamBytes, signature, startIndex) {
  45511. var streamBytesLength = streamBytes.length;
  45512. var signatureLength = signature.length;
  45513. var scanLength = streamBytesLength - signatureLength;
  45514. var i = startIndex, j, found = false;
  45515. while (i < scanLength) {
  45516. j = 0;
  45517. while (j < signatureLength && streamBytes[i + j] === signature[j]) {
  45518. j++;
  45519. }
  45520. if (j >= signatureLength) {
  45521. i += j;
  45522. while (i < streamBytesLength && isSpace(streamBytes[i])) {
  45523. i++;
  45524. }
  45525. found = true;
  45526. break;
  45527. }
  45528. i++;
  45529. }
  45530. return {
  45531. found: found,
  45532. length: i
  45533. };
  45534. }
  45535. function getHeaderBlock(stream, suggestedLength) {
  45536. var EEXEC_SIGNATURE = [
  45537. 0x65,
  45538. 0x65,
  45539. 0x78,
  45540. 0x65,
  45541. 0x63
  45542. ];
  45543. var streamStartPos = stream.pos;
  45544. var headerBytes, headerBytesLength, block;
  45545. try {
  45546. headerBytes = stream.getBytes(suggestedLength);
  45547. headerBytesLength = headerBytes.length;
  45548. } catch (ex) {
  45549. if (ex instanceof MissingDataException) {
  45550. throw ex;
  45551. }
  45552. }
  45553. if (headerBytesLength === suggestedLength) {
  45554. block = findBlock(headerBytes, EEXEC_SIGNATURE, suggestedLength - 2 * EEXEC_SIGNATURE.length);
  45555. if (block.found && block.length === suggestedLength) {
  45556. return {
  45557. stream: new Stream(headerBytes),
  45558. length: suggestedLength
  45559. };
  45560. }
  45561. }
  45562. warn('Invalid "Length1" property in Type1 font -- trying to recover.');
  45563. stream.pos = streamStartPos;
  45564. var SCAN_BLOCK_LENGTH = 2048;
  45565. var actualLength;
  45566. while (true) {
  45567. var scanBytes = stream.peekBytes(SCAN_BLOCK_LENGTH);
  45568. block = findBlock(scanBytes, EEXEC_SIGNATURE, 0);
  45569. if (block.length === 0) {
  45570. break;
  45571. }
  45572. stream.pos += block.length;
  45573. if (block.found) {
  45574. actualLength = stream.pos - streamStartPos;
  45575. break;
  45576. }
  45577. }
  45578. stream.pos = streamStartPos;
  45579. if (actualLength) {
  45580. return {
  45581. stream: new Stream(stream.getBytes(actualLength)),
  45582. length: actualLength
  45583. };
  45584. }
  45585. warn('Unable to recover "Length1" property in Type1 font -- using as is.');
  45586. return {
  45587. stream: new Stream(stream.getBytes(suggestedLength)),
  45588. length: suggestedLength
  45589. };
  45590. }
  45591. function getEexecBlock(stream, suggestedLength) {
  45592. var eexecBytes = stream.getBytes();
  45593. return {
  45594. stream: new Stream(eexecBytes),
  45595. length: eexecBytes.length
  45596. };
  45597. }
  45598. function Type1Font(name, file, properties) {
  45599. var PFB_HEADER_SIZE = 6;
  45600. var headerBlockLength = properties.length1;
  45601. var eexecBlockLength = properties.length2;
  45602. var pfbHeader = file.peekBytes(PFB_HEADER_SIZE);
  45603. var pfbHeaderPresent = pfbHeader[0] === 0x80 && pfbHeader[1] === 0x01;
  45604. if (pfbHeaderPresent) {
  45605. file.skip(PFB_HEADER_SIZE);
  45606. headerBlockLength = pfbHeader[5] << 24 | pfbHeader[4] << 16 | pfbHeader[3] << 8 | pfbHeader[2];
  45607. }
  45608. var headerBlock = getHeaderBlock(file, headerBlockLength);
  45609. headerBlockLength = headerBlock.length;
  45610. var headerBlockParser = new Type1Parser(headerBlock.stream, false, SEAC_ANALYSIS_ENABLED);
  45611. headerBlockParser.extractFontHeader(properties);
  45612. if (pfbHeaderPresent) {
  45613. pfbHeader = file.getBytes(PFB_HEADER_SIZE);
  45614. eexecBlockLength = pfbHeader[5] << 24 | pfbHeader[4] << 16 | pfbHeader[3] << 8 | pfbHeader[2];
  45615. }
  45616. var eexecBlock = getEexecBlock(file, eexecBlockLength);
  45617. eexecBlockLength = eexecBlock.length;
  45618. var eexecBlockParser = new Type1Parser(eexecBlock.stream, true, SEAC_ANALYSIS_ENABLED);
  45619. var data = eexecBlockParser.extractFontProgram();
  45620. for (var info in data.properties) {
  45621. properties[info] = data.properties[info];
  45622. }
  45623. var charstrings = data.charstrings;
  45624. var type2Charstrings = this.getType2Charstrings(charstrings);
  45625. var subrs = this.getType2Subrs(data.subrs);
  45626. this.charstrings = charstrings;
  45627. this.data = this.wrap(name, type2Charstrings, this.charstrings, subrs, properties);
  45628. this.seacs = this.getSeacs(data.charstrings);
  45629. }
  45630. Type1Font.prototype = {
  45631. get numGlyphs() {
  45632. return this.charstrings.length + 1;
  45633. },
  45634. getCharset: function Type1Font_getCharset() {
  45635. var charset = ['.notdef'];
  45636. var charstrings = this.charstrings;
  45637. for (var glyphId = 0; glyphId < charstrings.length; glyphId++) {
  45638. charset.push(charstrings[glyphId].glyphName);
  45639. }
  45640. return charset;
  45641. },
  45642. getGlyphMapping: function Type1Font_getGlyphMapping(properties) {
  45643. var charstrings = this.charstrings;
  45644. var glyphNames = ['.notdef'], glyphId;
  45645. for (glyphId = 0; glyphId < charstrings.length; glyphId++) {
  45646. glyphNames.push(charstrings[glyphId].glyphName);
  45647. }
  45648. var encoding = properties.builtInEncoding;
  45649. if (encoding) {
  45650. var builtInEncoding = Object.create(null);
  45651. for (var charCode in encoding) {
  45652. glyphId = glyphNames.indexOf(encoding[charCode]);
  45653. if (glyphId >= 0) {
  45654. builtInEncoding[charCode] = glyphId;
  45655. }
  45656. }
  45657. }
  45658. return type1FontGlyphMapping(properties, builtInEncoding, glyphNames);
  45659. },
  45660. getSeacs: function Type1Font_getSeacs(charstrings) {
  45661. var i, ii;
  45662. var seacMap = [];
  45663. for (i = 0, ii = charstrings.length; i < ii; i++) {
  45664. var charstring = charstrings[i];
  45665. if (charstring.seac) {
  45666. seacMap[i + 1] = charstring.seac;
  45667. }
  45668. }
  45669. return seacMap;
  45670. },
  45671. getType2Charstrings: function Type1Font_getType2Charstrings(type1Charstrings) {
  45672. var type2Charstrings = [];
  45673. for (var i = 0, ii = type1Charstrings.length; i < ii; i++) {
  45674. type2Charstrings.push(type1Charstrings[i].charstring);
  45675. }
  45676. return type2Charstrings;
  45677. },
  45678. getType2Subrs: function Type1Font_getType2Subrs(type1Subrs) {
  45679. var bias = 0;
  45680. var count = type1Subrs.length;
  45681. if (count < 1133) {
  45682. bias = 107;
  45683. } else if (count < 33769) {
  45684. bias = 1131;
  45685. } else {
  45686. bias = 32768;
  45687. }
  45688. var type2Subrs = [];
  45689. var i;
  45690. for (i = 0; i < bias; i++) {
  45691. type2Subrs.push([0x0B]);
  45692. }
  45693. for (i = 0; i < count; i++) {
  45694. type2Subrs.push(type1Subrs[i]);
  45695. }
  45696. return type2Subrs;
  45697. },
  45698. wrap: function Type1Font_wrap(name, glyphs, charstrings, subrs, properties) {
  45699. var cff = new CFF();
  45700. cff.header = new CFFHeader(1, 0, 4, 4);
  45701. cff.names = [name];
  45702. var topDict = new CFFTopDict();
  45703. topDict.setByName('version', 391);
  45704. topDict.setByName('Notice', 392);
  45705. topDict.setByName('FullName', 393);
  45706. topDict.setByName('FamilyName', 394);
  45707. topDict.setByName('Weight', 395);
  45708. topDict.setByName('Encoding', null);
  45709. topDict.setByName('FontMatrix', properties.fontMatrix);
  45710. topDict.setByName('FontBBox', properties.bbox);
  45711. topDict.setByName('charset', null);
  45712. topDict.setByName('CharStrings', null);
  45713. topDict.setByName('Private', null);
  45714. cff.topDict = topDict;
  45715. var strings = new CFFStrings();
  45716. strings.add('Version 0.11');
  45717. strings.add('See original notice');
  45718. strings.add(name);
  45719. strings.add(name);
  45720. strings.add('Medium');
  45721. cff.strings = strings;
  45722. cff.globalSubrIndex = new CFFIndex();
  45723. var count = glyphs.length;
  45724. var charsetArray = [0];
  45725. var i, ii;
  45726. for (i = 0; i < count; i++) {
  45727. var index = CFFStandardStrings.indexOf(charstrings[i].glyphName);
  45728. if (index === -1) {
  45729. index = 0;
  45730. }
  45731. charsetArray.push(index >> 8 & 0xff, index & 0xff);
  45732. }
  45733. cff.charset = new CFFCharset(false, 0, [], charsetArray);
  45734. var charStringsIndex = new CFFIndex();
  45735. charStringsIndex.add([
  45736. 0x8B,
  45737. 0x0E
  45738. ]);
  45739. for (i = 0; i < count; i++) {
  45740. var glyph = glyphs[i];
  45741. if (glyph.length === 0) {
  45742. charStringsIndex.add([
  45743. 0x8B,
  45744. 0x0E
  45745. ]);
  45746. continue;
  45747. }
  45748. charStringsIndex.add(glyph);
  45749. }
  45750. cff.charStrings = charStringsIndex;
  45751. var privateDict = new CFFPrivateDict();
  45752. privateDict.setByName('Subrs', null);
  45753. var fields = [
  45754. 'BlueValues',
  45755. 'OtherBlues',
  45756. 'FamilyBlues',
  45757. 'FamilyOtherBlues',
  45758. 'StemSnapH',
  45759. 'StemSnapV',
  45760. 'BlueShift',
  45761. 'BlueFuzz',
  45762. 'BlueScale',
  45763. 'LanguageGroup',
  45764. 'ExpansionFactor',
  45765. 'ForceBold',
  45766. 'StdHW',
  45767. 'StdVW'
  45768. ];
  45769. for (i = 0, ii = fields.length; i < ii; i++) {
  45770. var field = fields[i];
  45771. if (!(field in properties.privateData)) {
  45772. continue;
  45773. }
  45774. var value = properties.privateData[field];
  45775. if (isArray(value)) {
  45776. for (var j = value.length - 1; j > 0; j--) {
  45777. value[j] -= value[j - 1];
  45778. }
  45779. }
  45780. privateDict.setByName(field, value);
  45781. }
  45782. cff.topDict.privateDict = privateDict;
  45783. var subrIndex = new CFFIndex();
  45784. for (i = 0, ii = subrs.length; i < ii; i++) {
  45785. subrIndex.add(subrs[i]);
  45786. }
  45787. privateDict.subrsIndex = subrIndex;
  45788. var compiler = new CFFCompiler(cff);
  45789. return compiler.compile();
  45790. }
  45791. };
  45792. return Type1Font;
  45793. }();
  45794. var CFFFont = function CFFFontClosure() {
  45795. function CFFFont(file, properties) {
  45796. this.properties = properties;
  45797. var parser = new CFFParser(file, properties, SEAC_ANALYSIS_ENABLED);
  45798. this.cff = parser.parse();
  45799. var compiler = new CFFCompiler(this.cff);
  45800. this.seacs = this.cff.seacs;
  45801. try {
  45802. this.data = compiler.compile();
  45803. } catch (e) {
  45804. warn('Failed to compile font ' + properties.loadedName);
  45805. this.data = file;
  45806. }
  45807. }
  45808. CFFFont.prototype = {
  45809. get numGlyphs() {
  45810. return this.cff.charStrings.count;
  45811. },
  45812. getCharset: function CFFFont_getCharset() {
  45813. return this.cff.charset.charset;
  45814. },
  45815. getGlyphMapping: function CFFFont_getGlyphMapping() {
  45816. var cff = this.cff;
  45817. var properties = this.properties;
  45818. var charsets = cff.charset.charset;
  45819. var charCodeToGlyphId;
  45820. var glyphId;
  45821. if (properties.composite) {
  45822. charCodeToGlyphId = Object.create(null);
  45823. if (cff.isCIDFont) {
  45824. for (glyphId = 0; glyphId < charsets.length; glyphId++) {
  45825. var cid = charsets[glyphId];
  45826. var charCode = properties.cMap.charCodeOf(cid);
  45827. charCodeToGlyphId[charCode] = glyphId;
  45828. }
  45829. } else {
  45830. for (glyphId = 0; glyphId < cff.charStrings.count; glyphId++) {
  45831. charCodeToGlyphId[glyphId] = glyphId;
  45832. }
  45833. }
  45834. return charCodeToGlyphId;
  45835. }
  45836. var encoding = cff.encoding ? cff.encoding.encoding : null;
  45837. charCodeToGlyphId = type1FontGlyphMapping(properties, encoding, charsets);
  45838. return charCodeToGlyphId;
  45839. }
  45840. };
  45841. return CFFFont;
  45842. }();
  45843. (function checkSeacSupport() {
  45844. if (typeof navigator !== 'undefined' && /Windows/.test(navigator.userAgent)) {
  45845. SEAC_ANALYSIS_ENABLED = true;
  45846. }
  45847. }());
  45848. (function checkChromeWindows() {
  45849. if (typeof navigator !== 'undefined' && /Windows.*Chrome/.test(navigator.userAgent)) {
  45850. SKIP_PRIVATE_USE_RANGE_F000_TO_F01F = true;
  45851. }
  45852. }());
  45853. exports.SEAC_ANALYSIS_ENABLED = SEAC_ANALYSIS_ENABLED;
  45854. exports.PRIVATE_USE_OFFSET_START = PRIVATE_USE_OFFSET_START;
  45855. exports.PRIVATE_USE_OFFSET_END = PRIVATE_USE_OFFSET_END;
  45856. exports.ErrorFont = ErrorFont;
  45857. exports.Font = Font;
  45858. exports.FontFlags = FontFlags;
  45859. exports.IdentityToUnicodeMap = IdentityToUnicodeMap;
  45860. exports.ProblematicCharRanges = ProblematicCharRanges;
  45861. exports.ToUnicodeMap = ToUnicodeMap;
  45862. exports.getFontType = getFontType;
  45863. /***/ }),
  45864. /* 34 */
  45865. /***/ (function(module, exports, __w_pdfjs_require__) {
  45866. "use strict";
  45867. var sharedUtil = __w_pdfjs_require__(0);
  45868. var corePrimitives = __w_pdfjs_require__(1);
  45869. var coreColorSpace = __w_pdfjs_require__(4);
  45870. var coreStream = __w_pdfjs_require__(2);
  45871. var coreJpx = __w_pdfjs_require__(19);
  45872. var ImageKind = sharedUtil.ImageKind;
  45873. var assert = sharedUtil.assert;
  45874. var error = sharedUtil.error;
  45875. var info = sharedUtil.info;
  45876. var isArray = sharedUtil.isArray;
  45877. var warn = sharedUtil.warn;
  45878. var Name = corePrimitives.Name;
  45879. var isStream = corePrimitives.isStream;
  45880. var ColorSpace = coreColorSpace.ColorSpace;
  45881. var DecodeStream = coreStream.DecodeStream;
  45882. var JpegStream = coreStream.JpegStream;
  45883. var JpxImage = coreJpx.JpxImage;
  45884. var PDFImage = function PDFImageClosure() {
  45885. function handleImageData(image, nativeDecoder) {
  45886. if (nativeDecoder && nativeDecoder.canDecode(image)) {
  45887. return nativeDecoder.decode(image);
  45888. }
  45889. return Promise.resolve(image);
  45890. }
  45891. function decodeAndClamp(value, addend, coefficient, max) {
  45892. value = addend + value * coefficient;
  45893. return value < 0 ? 0 : value > max ? max : value;
  45894. }
  45895. function resizeImageMask(src, bpc, w1, h1, w2, h2) {
  45896. var length = w2 * h2;
  45897. var dest = bpc <= 8 ? new Uint8Array(length) : bpc <= 16 ? new Uint16Array(length) : new Uint32Array(length);
  45898. var xRatio = w1 / w2;
  45899. var yRatio = h1 / h2;
  45900. var i, j, py, newIndex = 0, oldIndex;
  45901. var xScaled = new Uint16Array(w2);
  45902. var w1Scanline = w1;
  45903. for (i = 0; i < w2; i++) {
  45904. xScaled[i] = Math.floor(i * xRatio);
  45905. }
  45906. for (i = 0; i < h2; i++) {
  45907. py = Math.floor(i * yRatio) * w1Scanline;
  45908. for (j = 0; j < w2; j++) {
  45909. oldIndex = py + xScaled[j];
  45910. dest[newIndex++] = src[oldIndex];
  45911. }
  45912. }
  45913. return dest;
  45914. }
  45915. function PDFImage(xref, res, image, inline, smask, mask, isMask) {
  45916. this.image = image;
  45917. var dict = image.dict;
  45918. if (dict.has('Filter')) {
  45919. var filter = dict.get('Filter').name;
  45920. if (filter === 'JPXDecode') {
  45921. var jpxImage = new JpxImage();
  45922. jpxImage.parseImageProperties(image.stream);
  45923. image.stream.reset();
  45924. image.bitsPerComponent = jpxImage.bitsPerComponent;
  45925. image.numComps = jpxImage.componentsCount;
  45926. } else if (filter === 'JBIG2Decode') {
  45927. image.bitsPerComponent = 1;
  45928. image.numComps = 1;
  45929. }
  45930. }
  45931. this.width = dict.get('Width', 'W');
  45932. this.height = dict.get('Height', 'H');
  45933. if (this.width < 1 || this.height < 1) {
  45934. error('Invalid image width: ' + this.width + ' or height: ' + this.height);
  45935. }
  45936. this.interpolate = dict.get('Interpolate', 'I') || false;
  45937. this.imageMask = dict.get('ImageMask', 'IM') || false;
  45938. this.matte = dict.get('Matte') || false;
  45939. var bitsPerComponent = image.bitsPerComponent;
  45940. if (!bitsPerComponent) {
  45941. bitsPerComponent = dict.get('BitsPerComponent', 'BPC');
  45942. if (!bitsPerComponent) {
  45943. if (this.imageMask) {
  45944. bitsPerComponent = 1;
  45945. } else {
  45946. error('Bits per component missing in image: ' + this.imageMask);
  45947. }
  45948. }
  45949. }
  45950. this.bpc = bitsPerComponent;
  45951. if (!this.imageMask) {
  45952. var colorSpace = dict.get('ColorSpace', 'CS');
  45953. if (!colorSpace) {
  45954. info('JPX images (which do not require color spaces)');
  45955. switch (image.numComps) {
  45956. case 1:
  45957. colorSpace = Name.get('DeviceGray');
  45958. break;
  45959. case 3:
  45960. colorSpace = Name.get('DeviceRGB');
  45961. break;
  45962. case 4:
  45963. colorSpace = Name.get('DeviceCMYK');
  45964. break;
  45965. default:
  45966. error('JPX images with ' + this.numComps + ' color components not supported.');
  45967. }
  45968. }
  45969. this.colorSpace = ColorSpace.parse(colorSpace, xref, res);
  45970. this.numComps = this.colorSpace.numComps;
  45971. }
  45972. this.decode = dict.getArray('Decode', 'D');
  45973. this.needsDecode = false;
  45974. if (this.decode && (this.colorSpace && !this.colorSpace.isDefaultDecode(this.decode) || isMask && !ColorSpace.isDefaultDecode(this.decode, 1))) {
  45975. this.needsDecode = true;
  45976. var max = (1 << bitsPerComponent) - 1;
  45977. this.decodeCoefficients = [];
  45978. this.decodeAddends = [];
  45979. for (var i = 0, j = 0; i < this.decode.length; i += 2, ++j) {
  45980. var dmin = this.decode[i];
  45981. var dmax = this.decode[i + 1];
  45982. this.decodeCoefficients[j] = dmax - dmin;
  45983. this.decodeAddends[j] = max * dmin;
  45984. }
  45985. }
  45986. if (smask) {
  45987. this.smask = new PDFImage(xref, res, smask, false);
  45988. } else if (mask) {
  45989. if (isStream(mask)) {
  45990. var maskDict = mask.dict, imageMask = maskDict.get('ImageMask', 'IM');
  45991. if (!imageMask) {
  45992. warn('Ignoring /Mask in image without /ImageMask.');
  45993. } else {
  45994. this.mask = new PDFImage(xref, res, mask, false, null, null, true);
  45995. }
  45996. } else {
  45997. this.mask = mask;
  45998. }
  45999. }
  46000. }
  46001. PDFImage.buildImage = function PDFImage_buildImage(handler, xref, res, image, inline, nativeDecoder) {
  46002. var imagePromise = handleImageData(image, nativeDecoder);
  46003. var smaskPromise;
  46004. var maskPromise;
  46005. var smask = image.dict.get('SMask');
  46006. var mask = image.dict.get('Mask');
  46007. if (smask) {
  46008. smaskPromise = handleImageData(smask, nativeDecoder);
  46009. maskPromise = Promise.resolve(null);
  46010. } else {
  46011. smaskPromise = Promise.resolve(null);
  46012. if (mask) {
  46013. if (isStream(mask)) {
  46014. maskPromise = handleImageData(mask, nativeDecoder);
  46015. } else if (isArray(mask)) {
  46016. maskPromise = Promise.resolve(mask);
  46017. } else {
  46018. warn('Unsupported mask format.');
  46019. maskPromise = Promise.resolve(null);
  46020. }
  46021. } else {
  46022. maskPromise = Promise.resolve(null);
  46023. }
  46024. }
  46025. return Promise.all([
  46026. imagePromise,
  46027. smaskPromise,
  46028. maskPromise
  46029. ]).then(function (results) {
  46030. var imageData = results[0];
  46031. var smaskData = results[1];
  46032. var maskData = results[2];
  46033. return new PDFImage(xref, res, imageData, inline, smaskData, maskData);
  46034. });
  46035. };
  46036. PDFImage.createMask = function PDFImage_createMask(imgArray, width, height, imageIsFromDecodeStream, inverseDecode) {
  46037. var computedLength = (width + 7 >> 3) * height;
  46038. var actualLength = imgArray.byteLength;
  46039. var haveFullData = computedLength === actualLength;
  46040. var data, i;
  46041. if (imageIsFromDecodeStream && (!inverseDecode || haveFullData)) {
  46042. data = imgArray;
  46043. } else if (!inverseDecode) {
  46044. data = new Uint8Array(actualLength);
  46045. data.set(imgArray);
  46046. } else {
  46047. data = new Uint8Array(computedLength);
  46048. data.set(imgArray);
  46049. for (i = actualLength; i < computedLength; i++) {
  46050. data[i] = 0xff;
  46051. }
  46052. }
  46053. if (inverseDecode) {
  46054. for (i = 0; i < actualLength; i++) {
  46055. data[i] = ~data[i];
  46056. }
  46057. }
  46058. return {
  46059. data: data,
  46060. width: width,
  46061. height: height
  46062. };
  46063. };
  46064. PDFImage.prototype = {
  46065. get drawWidth() {
  46066. return Math.max(this.width, this.smask && this.smask.width || 0, this.mask && this.mask.width || 0);
  46067. },
  46068. get drawHeight() {
  46069. return Math.max(this.height, this.smask && this.smask.height || 0, this.mask && this.mask.height || 0);
  46070. },
  46071. decodeBuffer: function PDFImage_decodeBuffer(buffer) {
  46072. var bpc = this.bpc;
  46073. var numComps = this.numComps;
  46074. var decodeAddends = this.decodeAddends;
  46075. var decodeCoefficients = this.decodeCoefficients;
  46076. var max = (1 << bpc) - 1;
  46077. var i, ii;
  46078. if (bpc === 1) {
  46079. for (i = 0, ii = buffer.length; i < ii; i++) {
  46080. buffer[i] = +!buffer[i];
  46081. }
  46082. return;
  46083. }
  46084. var index = 0;
  46085. for (i = 0, ii = this.width * this.height; i < ii; i++) {
  46086. for (var j = 0; j < numComps; j++) {
  46087. buffer[index] = decodeAndClamp(buffer[index], decodeAddends[j], decodeCoefficients[j], max);
  46088. index++;
  46089. }
  46090. }
  46091. },
  46092. getComponents: function PDFImage_getComponents(buffer) {
  46093. var bpc = this.bpc;
  46094. if (bpc === 8) {
  46095. return buffer;
  46096. }
  46097. var width = this.width;
  46098. var height = this.height;
  46099. var numComps = this.numComps;
  46100. var length = width * height * numComps;
  46101. var bufferPos = 0;
  46102. var output = bpc <= 8 ? new Uint8Array(length) : bpc <= 16 ? new Uint16Array(length) : new Uint32Array(length);
  46103. var rowComps = width * numComps;
  46104. var max = (1 << bpc) - 1;
  46105. var i = 0, ii, buf;
  46106. if (bpc === 1) {
  46107. var mask, loop1End, loop2End;
  46108. for (var j = 0; j < height; j++) {
  46109. loop1End = i + (rowComps & ~7);
  46110. loop2End = i + rowComps;
  46111. while (i < loop1End) {
  46112. buf = buffer[bufferPos++];
  46113. output[i] = buf >> 7 & 1;
  46114. output[i + 1] = buf >> 6 & 1;
  46115. output[i + 2] = buf >> 5 & 1;
  46116. output[i + 3] = buf >> 4 & 1;
  46117. output[i + 4] = buf >> 3 & 1;
  46118. output[i + 5] = buf >> 2 & 1;
  46119. output[i + 6] = buf >> 1 & 1;
  46120. output[i + 7] = buf & 1;
  46121. i += 8;
  46122. }
  46123. if (i < loop2End) {
  46124. buf = buffer[bufferPos++];
  46125. mask = 128;
  46126. while (i < loop2End) {
  46127. output[i++] = +!!(buf & mask);
  46128. mask >>= 1;
  46129. }
  46130. }
  46131. }
  46132. } else {
  46133. var bits = 0;
  46134. buf = 0;
  46135. for (i = 0, ii = length; i < ii; ++i) {
  46136. if (i % rowComps === 0) {
  46137. buf = 0;
  46138. bits = 0;
  46139. }
  46140. while (bits < bpc) {
  46141. buf = buf << 8 | buffer[bufferPos++];
  46142. bits += 8;
  46143. }
  46144. var remainingBits = bits - bpc;
  46145. var value = buf >> remainingBits;
  46146. output[i] = value < 0 ? 0 : value > max ? max : value;
  46147. buf = buf & (1 << remainingBits) - 1;
  46148. bits = remainingBits;
  46149. }
  46150. }
  46151. return output;
  46152. },
  46153. fillOpacity: function PDFImage_fillOpacity(rgbaBuf, width, height, actualHeight, image) {
  46154. var smask = this.smask;
  46155. var mask = this.mask;
  46156. var alphaBuf, sw, sh, i, ii, j;
  46157. if (smask) {
  46158. sw = smask.width;
  46159. sh = smask.height;
  46160. alphaBuf = new Uint8Array(sw * sh);
  46161. smask.fillGrayBuffer(alphaBuf);
  46162. if (sw !== width || sh !== height) {
  46163. alphaBuf = resizeImageMask(alphaBuf, smask.bpc, sw, sh, width, height);
  46164. }
  46165. } else if (mask) {
  46166. if (mask instanceof PDFImage) {
  46167. sw = mask.width;
  46168. sh = mask.height;
  46169. alphaBuf = new Uint8Array(sw * sh);
  46170. mask.numComps = 1;
  46171. mask.fillGrayBuffer(alphaBuf);
  46172. for (i = 0, ii = sw * sh; i < ii; ++i) {
  46173. alphaBuf[i] = 255 - alphaBuf[i];
  46174. }
  46175. if (sw !== width || sh !== height) {
  46176. alphaBuf = resizeImageMask(alphaBuf, mask.bpc, sw, sh, width, height);
  46177. }
  46178. } else if (isArray(mask)) {
  46179. alphaBuf = new Uint8Array(width * height);
  46180. var numComps = this.numComps;
  46181. for (i = 0, ii = width * height; i < ii; ++i) {
  46182. var opacity = 0;
  46183. var imageOffset = i * numComps;
  46184. for (j = 0; j < numComps; ++j) {
  46185. var color = image[imageOffset + j];
  46186. var maskOffset = j * 2;
  46187. if (color < mask[maskOffset] || color > mask[maskOffset + 1]) {
  46188. opacity = 255;
  46189. break;
  46190. }
  46191. }
  46192. alphaBuf[i] = opacity;
  46193. }
  46194. } else {
  46195. error('Unknown mask format.');
  46196. }
  46197. }
  46198. if (alphaBuf) {
  46199. for (i = 0, j = 3, ii = width * actualHeight; i < ii; ++i, j += 4) {
  46200. rgbaBuf[j] = alphaBuf[i];
  46201. }
  46202. } else {
  46203. for (i = 0, j = 3, ii = width * actualHeight; i < ii; ++i, j += 4) {
  46204. rgbaBuf[j] = 255;
  46205. }
  46206. }
  46207. },
  46208. undoPreblend: function PDFImage_undoPreblend(buffer, width, height) {
  46209. var matte = this.smask && this.smask.matte;
  46210. if (!matte) {
  46211. return;
  46212. }
  46213. var matteRgb = this.colorSpace.getRgb(matte, 0);
  46214. var matteR = matteRgb[0];
  46215. var matteG = matteRgb[1];
  46216. var matteB = matteRgb[2];
  46217. var length = width * height * 4;
  46218. var r, g, b;
  46219. for (var i = 0; i < length; i += 4) {
  46220. var alpha = buffer[i + 3];
  46221. if (alpha === 0) {
  46222. buffer[i] = 255;
  46223. buffer[i + 1] = 255;
  46224. buffer[i + 2] = 255;
  46225. continue;
  46226. }
  46227. var k = 255 / alpha;
  46228. r = (buffer[i] - matteR) * k + matteR;
  46229. g = (buffer[i + 1] - matteG) * k + matteG;
  46230. b = (buffer[i + 2] - matteB) * k + matteB;
  46231. buffer[i] = r <= 0 ? 0 : r >= 255 ? 255 : r | 0;
  46232. buffer[i + 1] = g <= 0 ? 0 : g >= 255 ? 255 : g | 0;
  46233. buffer[i + 2] = b <= 0 ? 0 : b >= 255 ? 255 : b | 0;
  46234. }
  46235. },
  46236. createImageData: function PDFImage_createImageData(forceRGBA) {
  46237. var drawWidth = this.drawWidth;
  46238. var drawHeight = this.drawHeight;
  46239. var imgData = {
  46240. width: drawWidth,
  46241. height: drawHeight
  46242. };
  46243. var numComps = this.numComps;
  46244. var originalWidth = this.width;
  46245. var originalHeight = this.height;
  46246. var bpc = this.bpc;
  46247. var rowBytes = originalWidth * numComps * bpc + 7 >> 3;
  46248. var imgArray;
  46249. if (!forceRGBA) {
  46250. var kind;
  46251. if (this.colorSpace.name === 'DeviceGray' && bpc === 1) {
  46252. kind = ImageKind.GRAYSCALE_1BPP;
  46253. } else if (this.colorSpace.name === 'DeviceRGB' && bpc === 8 && !this.needsDecode) {
  46254. kind = ImageKind.RGB_24BPP;
  46255. }
  46256. if (kind && !this.smask && !this.mask && drawWidth === originalWidth && drawHeight === originalHeight) {
  46257. imgData.kind = kind;
  46258. imgArray = this.getImageBytes(originalHeight * rowBytes);
  46259. if (this.image instanceof DecodeStream) {
  46260. imgData.data = imgArray;
  46261. } else {
  46262. var newArray = new Uint8Array(imgArray.length);
  46263. newArray.set(imgArray);
  46264. imgData.data = newArray;
  46265. }
  46266. if (this.needsDecode) {
  46267. assert(kind === ImageKind.GRAYSCALE_1BPP);
  46268. var buffer = imgData.data;
  46269. for (var i = 0, ii = buffer.length; i < ii; i++) {
  46270. buffer[i] ^= 0xff;
  46271. }
  46272. }
  46273. return imgData;
  46274. }
  46275. if (this.image instanceof JpegStream && !this.smask && !this.mask && (this.colorSpace.name === 'DeviceGray' || this.colorSpace.name === 'DeviceRGB' || this.colorSpace.name === 'DeviceCMYK')) {
  46276. imgData.kind = ImageKind.RGB_24BPP;
  46277. imgData.data = this.getImageBytes(originalHeight * rowBytes, drawWidth, drawHeight, true);
  46278. return imgData;
  46279. }
  46280. }
  46281. imgArray = this.getImageBytes(originalHeight * rowBytes);
  46282. var actualHeight = 0 | imgArray.length / rowBytes * drawHeight / originalHeight;
  46283. var comps = this.getComponents(imgArray);
  46284. var alpha01, maybeUndoPreblend;
  46285. if (!forceRGBA && !this.smask && !this.mask) {
  46286. imgData.kind = ImageKind.RGB_24BPP;
  46287. imgData.data = new Uint8Array(drawWidth * drawHeight * 3);
  46288. alpha01 = 0;
  46289. maybeUndoPreblend = false;
  46290. } else {
  46291. imgData.kind = ImageKind.RGBA_32BPP;
  46292. imgData.data = new Uint8Array(drawWidth * drawHeight * 4);
  46293. alpha01 = 1;
  46294. maybeUndoPreblend = true;
  46295. this.fillOpacity(imgData.data, drawWidth, drawHeight, actualHeight, comps);
  46296. }
  46297. if (this.needsDecode) {
  46298. this.decodeBuffer(comps);
  46299. }
  46300. this.colorSpace.fillRgb(imgData.data, originalWidth, originalHeight, drawWidth, drawHeight, actualHeight, bpc, comps, alpha01);
  46301. if (maybeUndoPreblend) {
  46302. this.undoPreblend(imgData.data, drawWidth, actualHeight);
  46303. }
  46304. return imgData;
  46305. },
  46306. fillGrayBuffer: function PDFImage_fillGrayBuffer(buffer) {
  46307. var numComps = this.numComps;
  46308. if (numComps !== 1) {
  46309. error('Reading gray scale from a color image: ' + numComps);
  46310. }
  46311. var width = this.width;
  46312. var height = this.height;
  46313. var bpc = this.bpc;
  46314. var rowBytes = width * numComps * bpc + 7 >> 3;
  46315. var imgArray = this.getImageBytes(height * rowBytes);
  46316. var comps = this.getComponents(imgArray);
  46317. var i, length;
  46318. if (bpc === 1) {
  46319. length = width * height;
  46320. if (this.needsDecode) {
  46321. for (i = 0; i < length; ++i) {
  46322. buffer[i] = comps[i] - 1 & 255;
  46323. }
  46324. } else {
  46325. for (i = 0; i < length; ++i) {
  46326. buffer[i] = -comps[i] & 255;
  46327. }
  46328. }
  46329. return;
  46330. }
  46331. if (this.needsDecode) {
  46332. this.decodeBuffer(comps);
  46333. }
  46334. length = width * height;
  46335. var scale = 255 / ((1 << bpc) - 1);
  46336. for (i = 0; i < length; ++i) {
  46337. buffer[i] = scale * comps[i] | 0;
  46338. }
  46339. },
  46340. getImageBytes: function PDFImage_getImageBytes(length, drawWidth, drawHeight, forceRGB) {
  46341. this.image.reset();
  46342. this.image.drawWidth = drawWidth || this.width;
  46343. this.image.drawHeight = drawHeight || this.height;
  46344. this.image.forceRGB = !!forceRGB;
  46345. return this.image.getBytes(length);
  46346. }
  46347. };
  46348. return PDFImage;
  46349. }();
  46350. exports.PDFImage = PDFImage;
  46351. /***/ }),
  46352. /* 35 */
  46353. /***/ (function(module, exports, __w_pdfjs_require__) {
  46354. "use strict";
  46355. var sharedUtil = __w_pdfjs_require__(0);
  46356. var coreArithmeticDecoder = __w_pdfjs_require__(14);
  46357. var error = sharedUtil.error;
  46358. var log2 = sharedUtil.log2;
  46359. var readInt8 = sharedUtil.readInt8;
  46360. var readUint16 = sharedUtil.readUint16;
  46361. var readUint32 = sharedUtil.readUint32;
  46362. var shadow = sharedUtil.shadow;
  46363. var ArithmeticDecoder = coreArithmeticDecoder.ArithmeticDecoder;
  46364. var Jbig2Image = function Jbig2ImageClosure() {
  46365. function ContextCache() {
  46366. }
  46367. ContextCache.prototype = {
  46368. getContexts: function (id) {
  46369. if (id in this) {
  46370. return this[id];
  46371. }
  46372. return this[id] = new Int8Array(1 << 16);
  46373. }
  46374. };
  46375. function DecodingContext(data, start, end) {
  46376. this.data = data;
  46377. this.start = start;
  46378. this.end = end;
  46379. }
  46380. DecodingContext.prototype = {
  46381. get decoder() {
  46382. var decoder = new ArithmeticDecoder(this.data, this.start, this.end);
  46383. return shadow(this, 'decoder', decoder);
  46384. },
  46385. get contextCache() {
  46386. var cache = new ContextCache();
  46387. return shadow(this, 'contextCache', cache);
  46388. }
  46389. };
  46390. function decodeInteger(contextCache, procedure, decoder) {
  46391. var contexts = contextCache.getContexts(procedure);
  46392. var prev = 1;
  46393. function readBits(length) {
  46394. var v = 0;
  46395. for (var i = 0; i < length; i++) {
  46396. var bit = decoder.readBit(contexts, prev);
  46397. prev = prev < 256 ? prev << 1 | bit : (prev << 1 | bit) & 511 | 256;
  46398. v = v << 1 | bit;
  46399. }
  46400. return v >>> 0;
  46401. }
  46402. var sign = readBits(1);
  46403. 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);
  46404. return sign === 0 ? value : value > 0 ? -value : null;
  46405. }
  46406. function decodeIAID(contextCache, decoder, codeLength) {
  46407. var contexts = contextCache.getContexts('IAID');
  46408. var prev = 1;
  46409. for (var i = 0; i < codeLength; i++) {
  46410. var bit = decoder.readBit(contexts, prev);
  46411. prev = prev << 1 | bit;
  46412. }
  46413. if (codeLength < 31) {
  46414. return prev & (1 << codeLength) - 1;
  46415. }
  46416. return prev & 0x7FFFFFFF;
  46417. }
  46418. var SegmentTypes = [
  46419. 'SymbolDictionary',
  46420. null,
  46421. null,
  46422. null,
  46423. 'IntermediateTextRegion',
  46424. null,
  46425. 'ImmediateTextRegion',
  46426. 'ImmediateLosslessTextRegion',
  46427. null,
  46428. null,
  46429. null,
  46430. null,
  46431. null,
  46432. null,
  46433. null,
  46434. null,
  46435. 'patternDictionary',
  46436. null,
  46437. null,
  46438. null,
  46439. 'IntermediateHalftoneRegion',
  46440. null,
  46441. 'ImmediateHalftoneRegion',
  46442. 'ImmediateLosslessHalftoneRegion',
  46443. null,
  46444. null,
  46445. null,
  46446. null,
  46447. null,
  46448. null,
  46449. null,
  46450. null,
  46451. null,
  46452. null,
  46453. null,
  46454. null,
  46455. 'IntermediateGenericRegion',
  46456. null,
  46457. 'ImmediateGenericRegion',
  46458. 'ImmediateLosslessGenericRegion',
  46459. 'IntermediateGenericRefinementRegion',
  46460. null,
  46461. 'ImmediateGenericRefinementRegion',
  46462. 'ImmediateLosslessGenericRefinementRegion',
  46463. null,
  46464. null,
  46465. null,
  46466. null,
  46467. 'PageInformation',
  46468. 'EndOfPage',
  46469. 'EndOfStripe',
  46470. 'EndOfFile',
  46471. 'Profiles',
  46472. 'Tables',
  46473. null,
  46474. null,
  46475. null,
  46476. null,
  46477. null,
  46478. null,
  46479. null,
  46480. null,
  46481. 'Extension'
  46482. ];
  46483. var CodingTemplates = [
  46484. [
  46485. {
  46486. x: -1,
  46487. y: -2
  46488. },
  46489. {
  46490. x: 0,
  46491. y: -2
  46492. },
  46493. {
  46494. x: 1,
  46495. y: -2
  46496. },
  46497. {
  46498. x: -2,
  46499. y: -1
  46500. },
  46501. {
  46502. x: -1,
  46503. y: -1
  46504. },
  46505. {
  46506. x: 0,
  46507. y: -1
  46508. },
  46509. {
  46510. x: 1,
  46511. y: -1
  46512. },
  46513. {
  46514. x: 2,
  46515. y: -1
  46516. },
  46517. {
  46518. x: -4,
  46519. y: 0
  46520. },
  46521. {
  46522. x: -3,
  46523. y: 0
  46524. },
  46525. {
  46526. x: -2,
  46527. y: 0
  46528. },
  46529. {
  46530. x: -1,
  46531. y: 0
  46532. }
  46533. ],
  46534. [
  46535. {
  46536. x: -1,
  46537. y: -2
  46538. },
  46539. {
  46540. x: 0,
  46541. y: -2
  46542. },
  46543. {
  46544. x: 1,
  46545. y: -2
  46546. },
  46547. {
  46548. x: 2,
  46549. y: -2
  46550. },
  46551. {
  46552. x: -2,
  46553. y: -1
  46554. },
  46555. {
  46556. x: -1,
  46557. y: -1
  46558. },
  46559. {
  46560. x: 0,
  46561. y: -1
  46562. },
  46563. {
  46564. x: 1,
  46565. y: -1
  46566. },
  46567. {
  46568. x: 2,
  46569. y: -1
  46570. },
  46571. {
  46572. x: -3,
  46573. y: 0
  46574. },
  46575. {
  46576. x: -2,
  46577. y: 0
  46578. },
  46579. {
  46580. x: -1,
  46581. y: 0
  46582. }
  46583. ],
  46584. [
  46585. {
  46586. x: -1,
  46587. y: -2
  46588. },
  46589. {
  46590. x: 0,
  46591. y: -2
  46592. },
  46593. {
  46594. x: 1,
  46595. y: -2
  46596. },
  46597. {
  46598. x: -2,
  46599. y: -1
  46600. },
  46601. {
  46602. x: -1,
  46603. y: -1
  46604. },
  46605. {
  46606. x: 0,
  46607. y: -1
  46608. },
  46609. {
  46610. x: 1,
  46611. y: -1
  46612. },
  46613. {
  46614. x: -2,
  46615. y: 0
  46616. },
  46617. {
  46618. x: -1,
  46619. y: 0
  46620. }
  46621. ],
  46622. [
  46623. {
  46624. x: -3,
  46625. y: -1
  46626. },
  46627. {
  46628. x: -2,
  46629. y: -1
  46630. },
  46631. {
  46632. x: -1,
  46633. y: -1
  46634. },
  46635. {
  46636. x: 0,
  46637. y: -1
  46638. },
  46639. {
  46640. x: 1,
  46641. y: -1
  46642. },
  46643. {
  46644. x: -4,
  46645. y: 0
  46646. },
  46647. {
  46648. x: -3,
  46649. y: 0
  46650. },
  46651. {
  46652. x: -2,
  46653. y: 0
  46654. },
  46655. {
  46656. x: -1,
  46657. y: 0
  46658. }
  46659. ]
  46660. ];
  46661. var RefinementTemplates = [
  46662. {
  46663. coding: [
  46664. {
  46665. x: 0,
  46666. y: -1
  46667. },
  46668. {
  46669. x: 1,
  46670. y: -1
  46671. },
  46672. {
  46673. x: -1,
  46674. y: 0
  46675. }
  46676. ],
  46677. reference: [
  46678. {
  46679. x: 0,
  46680. y: -1
  46681. },
  46682. {
  46683. x: 1,
  46684. y: -1
  46685. },
  46686. {
  46687. x: -1,
  46688. y: 0
  46689. },
  46690. {
  46691. x: 0,
  46692. y: 0
  46693. },
  46694. {
  46695. x: 1,
  46696. y: 0
  46697. },
  46698. {
  46699. x: -1,
  46700. y: 1
  46701. },
  46702. {
  46703. x: 0,
  46704. y: 1
  46705. },
  46706. {
  46707. x: 1,
  46708. y: 1
  46709. }
  46710. ]
  46711. },
  46712. {
  46713. coding: [
  46714. {
  46715. x: -1,
  46716. y: -1
  46717. },
  46718. {
  46719. x: 0,
  46720. y: -1
  46721. },
  46722. {
  46723. x: 1,
  46724. y: -1
  46725. },
  46726. {
  46727. x: -1,
  46728. y: 0
  46729. }
  46730. ],
  46731. reference: [
  46732. {
  46733. x: 0,
  46734. y: -1
  46735. },
  46736. {
  46737. x: -1,
  46738. y: 0
  46739. },
  46740. {
  46741. x: 0,
  46742. y: 0
  46743. },
  46744. {
  46745. x: 1,
  46746. y: 0
  46747. },
  46748. {
  46749. x: 0,
  46750. y: 1
  46751. },
  46752. {
  46753. x: 1,
  46754. y: 1
  46755. }
  46756. ]
  46757. }
  46758. ];
  46759. var ReusedContexts = [
  46760. 0x9B25,
  46761. 0x0795,
  46762. 0x00E5,
  46763. 0x0195
  46764. ];
  46765. var RefinementReusedContexts = [
  46766. 0x0020,
  46767. 0x0008
  46768. ];
  46769. function decodeBitmapTemplate0(width, height, decodingContext) {
  46770. var decoder = decodingContext.decoder;
  46771. var contexts = decodingContext.contextCache.getContexts('GB');
  46772. var contextLabel, i, j, pixel, row, row1, row2, bitmap = [];
  46773. var OLD_PIXEL_MASK = 0x7BF7;
  46774. for (i = 0; i < height; i++) {
  46775. row = bitmap[i] = new Uint8Array(width);
  46776. row1 = i < 1 ? row : bitmap[i - 1];
  46777. row2 = i < 2 ? row : bitmap[i - 2];
  46778. contextLabel = row2[0] << 13 | row2[1] << 12 | row2[2] << 11 | row1[0] << 7 | row1[1] << 6 | row1[2] << 5 | row1[3] << 4;
  46779. for (j = 0; j < width; j++) {
  46780. row[j] = pixel = decoder.readBit(contexts, contextLabel);
  46781. contextLabel = (contextLabel & OLD_PIXEL_MASK) << 1 | (j + 3 < width ? row2[j + 3] << 11 : 0) | (j + 4 < width ? row1[j + 4] << 4 : 0) | pixel;
  46782. }
  46783. }
  46784. return bitmap;
  46785. }
  46786. function decodeBitmap(mmr, width, height, templateIndex, prediction, skip, at, decodingContext) {
  46787. if (mmr) {
  46788. error('JBIG2 error: MMR encoding is not supported');
  46789. }
  46790. 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) {
  46791. return decodeBitmapTemplate0(width, height, decodingContext);
  46792. }
  46793. var useskip = !!skip;
  46794. var template = CodingTemplates[templateIndex].concat(at);
  46795. template.sort(function (a, b) {
  46796. return a.y - b.y || a.x - b.x;
  46797. });
  46798. var templateLength = template.length;
  46799. var templateX = new Int8Array(templateLength);
  46800. var templateY = new Int8Array(templateLength);
  46801. var changingTemplateEntries = [];
  46802. var reuseMask = 0, minX = 0, maxX = 0, minY = 0;
  46803. var c, k;
  46804. for (k = 0; k < templateLength; k++) {
  46805. templateX[k] = template[k].x;
  46806. templateY[k] = template[k].y;
  46807. minX = Math.min(minX, template[k].x);
  46808. maxX = Math.max(maxX, template[k].x);
  46809. minY = Math.min(minY, template[k].y);
  46810. if (k < templateLength - 1 && template[k].y === template[k + 1].y && template[k].x === template[k + 1].x - 1) {
  46811. reuseMask |= 1 << templateLength - 1 - k;
  46812. } else {
  46813. changingTemplateEntries.push(k);
  46814. }
  46815. }
  46816. var changingEntriesLength = changingTemplateEntries.length;
  46817. var changingTemplateX = new Int8Array(changingEntriesLength);
  46818. var changingTemplateY = new Int8Array(changingEntriesLength);
  46819. var changingTemplateBit = new Uint16Array(changingEntriesLength);
  46820. for (c = 0; c < changingEntriesLength; c++) {
  46821. k = changingTemplateEntries[c];
  46822. changingTemplateX[c] = template[k].x;
  46823. changingTemplateY[c] = template[k].y;
  46824. changingTemplateBit[c] = 1 << templateLength - 1 - k;
  46825. }
  46826. var sbb_left = -minX;
  46827. var sbb_top = -minY;
  46828. var sbb_right = width - maxX;
  46829. var pseudoPixelContext = ReusedContexts[templateIndex];
  46830. var row = new Uint8Array(width);
  46831. var bitmap = [];
  46832. var decoder = decodingContext.decoder;
  46833. var contexts = decodingContext.contextCache.getContexts('GB');
  46834. var ltp = 0, j, i0, j0, contextLabel = 0, bit, shift;
  46835. for (var i = 0; i < height; i++) {
  46836. if (prediction) {
  46837. var sltp = decoder.readBit(contexts, pseudoPixelContext);
  46838. ltp ^= sltp;
  46839. if (ltp) {
  46840. bitmap.push(row);
  46841. continue;
  46842. }
  46843. }
  46844. row = new Uint8Array(row);
  46845. bitmap.push(row);
  46846. for (j = 0; j < width; j++) {
  46847. if (useskip && skip[i][j]) {
  46848. row[j] = 0;
  46849. continue;
  46850. }
  46851. if (j >= sbb_left && j < sbb_right && i >= sbb_top) {
  46852. contextLabel = contextLabel << 1 & reuseMask;
  46853. for (k = 0; k < changingEntriesLength; k++) {
  46854. i0 = i + changingTemplateY[k];
  46855. j0 = j + changingTemplateX[k];
  46856. bit = bitmap[i0][j0];
  46857. if (bit) {
  46858. bit = changingTemplateBit[k];
  46859. contextLabel |= bit;
  46860. }
  46861. }
  46862. } else {
  46863. contextLabel = 0;
  46864. shift = templateLength - 1;
  46865. for (k = 0; k < templateLength; k++, shift--) {
  46866. j0 = j + templateX[k];
  46867. if (j0 >= 0 && j0 < width) {
  46868. i0 = i + templateY[k];
  46869. if (i0 >= 0) {
  46870. bit = bitmap[i0][j0];
  46871. if (bit) {
  46872. contextLabel |= bit << shift;
  46873. }
  46874. }
  46875. }
  46876. }
  46877. }
  46878. var pixel = decoder.readBit(contexts, contextLabel);
  46879. row[j] = pixel;
  46880. }
  46881. }
  46882. return bitmap;
  46883. }
  46884. function decodeRefinement(width, height, templateIndex, referenceBitmap, offsetX, offsetY, prediction, at, decodingContext) {
  46885. var codingTemplate = RefinementTemplates[templateIndex].coding;
  46886. if (templateIndex === 0) {
  46887. codingTemplate = codingTemplate.concat([at[0]]);
  46888. }
  46889. var codingTemplateLength = codingTemplate.length;
  46890. var codingTemplateX = new Int32Array(codingTemplateLength);
  46891. var codingTemplateY = new Int32Array(codingTemplateLength);
  46892. var k;
  46893. for (k = 0; k < codingTemplateLength; k++) {
  46894. codingTemplateX[k] = codingTemplate[k].x;
  46895. codingTemplateY[k] = codingTemplate[k].y;
  46896. }
  46897. var referenceTemplate = RefinementTemplates[templateIndex].reference;
  46898. if (templateIndex === 0) {
  46899. referenceTemplate = referenceTemplate.concat([at[1]]);
  46900. }
  46901. var referenceTemplateLength = referenceTemplate.length;
  46902. var referenceTemplateX = new Int32Array(referenceTemplateLength);
  46903. var referenceTemplateY = new Int32Array(referenceTemplateLength);
  46904. for (k = 0; k < referenceTemplateLength; k++) {
  46905. referenceTemplateX[k] = referenceTemplate[k].x;
  46906. referenceTemplateY[k] = referenceTemplate[k].y;
  46907. }
  46908. var referenceWidth = referenceBitmap[0].length;
  46909. var referenceHeight = referenceBitmap.length;
  46910. var pseudoPixelContext = RefinementReusedContexts[templateIndex];
  46911. var bitmap = [];
  46912. var decoder = decodingContext.decoder;
  46913. var contexts = decodingContext.contextCache.getContexts('GR');
  46914. var ltp = 0;
  46915. for (var i = 0; i < height; i++) {
  46916. if (prediction) {
  46917. var sltp = decoder.readBit(contexts, pseudoPixelContext);
  46918. ltp ^= sltp;
  46919. if (ltp) {
  46920. error('JBIG2 error: prediction is not supported');
  46921. }
  46922. }
  46923. var row = new Uint8Array(width);
  46924. bitmap.push(row);
  46925. for (var j = 0; j < width; j++) {
  46926. var i0, j0;
  46927. var contextLabel = 0;
  46928. for (k = 0; k < codingTemplateLength; k++) {
  46929. i0 = i + codingTemplateY[k];
  46930. j0 = j + codingTemplateX[k];
  46931. if (i0 < 0 || j0 < 0 || j0 >= width) {
  46932. contextLabel <<= 1;
  46933. } else {
  46934. contextLabel = contextLabel << 1 | bitmap[i0][j0];
  46935. }
  46936. }
  46937. for (k = 0; k < referenceTemplateLength; k++) {
  46938. i0 = i + referenceTemplateY[k] + offsetY;
  46939. j0 = j + referenceTemplateX[k] + offsetX;
  46940. if (i0 < 0 || i0 >= referenceHeight || j0 < 0 || j0 >= referenceWidth) {
  46941. contextLabel <<= 1;
  46942. } else {
  46943. contextLabel = contextLabel << 1 | referenceBitmap[i0][j0];
  46944. }
  46945. }
  46946. var pixel = decoder.readBit(contexts, contextLabel);
  46947. row[j] = pixel;
  46948. }
  46949. }
  46950. return bitmap;
  46951. }
  46952. function decodeSymbolDictionary(huffman, refinement, symbols, numberOfNewSymbols, numberOfExportedSymbols, huffmanTables, templateIndex, at, refinementTemplateIndex, refinementAt, decodingContext) {
  46953. if (huffman) {
  46954. error('JBIG2 error: huffman is not supported');
  46955. }
  46956. var newSymbols = [];
  46957. var currentHeight = 0;
  46958. var symbolCodeLength = log2(symbols.length + numberOfNewSymbols);
  46959. var decoder = decodingContext.decoder;
  46960. var contextCache = decodingContext.contextCache;
  46961. while (newSymbols.length < numberOfNewSymbols) {
  46962. var deltaHeight = decodeInteger(contextCache, 'IADH', decoder);
  46963. currentHeight += deltaHeight;
  46964. var currentWidth = 0;
  46965. while (true) {
  46966. var deltaWidth = decodeInteger(contextCache, 'IADW', decoder);
  46967. if (deltaWidth === null) {
  46968. break;
  46969. }
  46970. currentWidth += deltaWidth;
  46971. var bitmap;
  46972. if (refinement) {
  46973. var numberOfInstances = decodeInteger(contextCache, 'IAAI', decoder);
  46974. if (numberOfInstances > 1) {
  46975. bitmap = decodeTextRegion(huffman, refinement, currentWidth, currentHeight, 0, numberOfInstances, 1, symbols.concat(newSymbols), symbolCodeLength, 0, 0, 1, 0, huffmanTables, refinementTemplateIndex, refinementAt, decodingContext);
  46976. } else {
  46977. var symbolId = decodeIAID(contextCache, decoder, symbolCodeLength);
  46978. var rdx = decodeInteger(contextCache, 'IARDX', decoder);
  46979. var rdy = decodeInteger(contextCache, 'IARDY', decoder);
  46980. var symbol = symbolId < symbols.length ? symbols[symbolId] : newSymbols[symbolId - symbols.length];
  46981. bitmap = decodeRefinement(currentWidth, currentHeight, refinementTemplateIndex, symbol, rdx, rdy, false, refinementAt, decodingContext);
  46982. }
  46983. } else {
  46984. bitmap = decodeBitmap(false, currentWidth, currentHeight, templateIndex, false, null, at, decodingContext);
  46985. }
  46986. newSymbols.push(bitmap);
  46987. }
  46988. }
  46989. var exportedSymbols = [];
  46990. var flags = [], currentFlag = false;
  46991. var totalSymbolsLength = symbols.length + numberOfNewSymbols;
  46992. while (flags.length < totalSymbolsLength) {
  46993. var runLength = decodeInteger(contextCache, 'IAEX', decoder);
  46994. while (runLength--) {
  46995. flags.push(currentFlag);
  46996. }
  46997. currentFlag = !currentFlag;
  46998. }
  46999. for (var i = 0, ii = symbols.length; i < ii; i++) {
  47000. if (flags[i]) {
  47001. exportedSymbols.push(symbols[i]);
  47002. }
  47003. }
  47004. for (var j = 0; j < numberOfNewSymbols; i++, j++) {
  47005. if (flags[i]) {
  47006. exportedSymbols.push(newSymbols[j]);
  47007. }
  47008. }
  47009. return exportedSymbols;
  47010. }
  47011. function decodeTextRegion(huffman, refinement, width, height, defaultPixelValue, numberOfSymbolInstances, stripSize, inputSymbols, symbolCodeLength, transposed, dsOffset, referenceCorner, combinationOperator, huffmanTables, refinementTemplateIndex, refinementAt, decodingContext) {
  47012. if (huffman) {
  47013. error('JBIG2 error: huffman is not supported');
  47014. }
  47015. var bitmap = [];
  47016. var i, row;
  47017. for (i = 0; i < height; i++) {
  47018. row = new Uint8Array(width);
  47019. if (defaultPixelValue) {
  47020. for (var j = 0; j < width; j++) {
  47021. row[j] = defaultPixelValue;
  47022. }
  47023. }
  47024. bitmap.push(row);
  47025. }
  47026. var decoder = decodingContext.decoder;
  47027. var contextCache = decodingContext.contextCache;
  47028. var stripT = -decodeInteger(contextCache, 'IADT', decoder);
  47029. var firstS = 0;
  47030. i = 0;
  47031. while (i < numberOfSymbolInstances) {
  47032. var deltaT = decodeInteger(contextCache, 'IADT', decoder);
  47033. stripT += deltaT;
  47034. var deltaFirstS = decodeInteger(contextCache, 'IAFS', decoder);
  47035. firstS += deltaFirstS;
  47036. var currentS = firstS;
  47037. do {
  47038. var currentT = stripSize === 1 ? 0 : decodeInteger(contextCache, 'IAIT', decoder);
  47039. var t = stripSize * stripT + currentT;
  47040. var symbolId = decodeIAID(contextCache, decoder, symbolCodeLength);
  47041. var applyRefinement = refinement && decodeInteger(contextCache, 'IARI', decoder);
  47042. var symbolBitmap = inputSymbols[symbolId];
  47043. var symbolWidth = symbolBitmap[0].length;
  47044. var symbolHeight = symbolBitmap.length;
  47045. if (applyRefinement) {
  47046. var rdw = decodeInteger(contextCache, 'IARDW', decoder);
  47047. var rdh = decodeInteger(contextCache, 'IARDH', decoder);
  47048. var rdx = decodeInteger(contextCache, 'IARDX', decoder);
  47049. var rdy = decodeInteger(contextCache, 'IARDY', decoder);
  47050. symbolWidth += rdw;
  47051. symbolHeight += rdh;
  47052. symbolBitmap = decodeRefinement(symbolWidth, symbolHeight, refinementTemplateIndex, symbolBitmap, (rdw >> 1) + rdx, (rdh >> 1) + rdy, false, refinementAt, decodingContext);
  47053. }
  47054. var offsetT = t - (referenceCorner & 1 ? 0 : symbolHeight);
  47055. var offsetS = currentS - (referenceCorner & 2 ? symbolWidth : 0);
  47056. var s2, t2, symbolRow;
  47057. if (transposed) {
  47058. for (s2 = 0; s2 < symbolHeight; s2++) {
  47059. row = bitmap[offsetS + s2];
  47060. if (!row) {
  47061. continue;
  47062. }
  47063. symbolRow = symbolBitmap[s2];
  47064. var maxWidth = Math.min(width - offsetT, symbolWidth);
  47065. switch (combinationOperator) {
  47066. case 0:
  47067. for (t2 = 0; t2 < maxWidth; t2++) {
  47068. row[offsetT + t2] |= symbolRow[t2];
  47069. }
  47070. break;
  47071. case 2:
  47072. for (t2 = 0; t2 < maxWidth; t2++) {
  47073. row[offsetT + t2] ^= symbolRow[t2];
  47074. }
  47075. break;
  47076. default:
  47077. error('JBIG2 error: operator ' + combinationOperator + ' is not supported');
  47078. }
  47079. }
  47080. currentS += symbolHeight - 1;
  47081. } else {
  47082. for (t2 = 0; t2 < symbolHeight; t2++) {
  47083. row = bitmap[offsetT + t2];
  47084. if (!row) {
  47085. continue;
  47086. }
  47087. symbolRow = symbolBitmap[t2];
  47088. switch (combinationOperator) {
  47089. case 0:
  47090. for (s2 = 0; s2 < symbolWidth; s2++) {
  47091. row[offsetS + s2] |= symbolRow[s2];
  47092. }
  47093. break;
  47094. case 2:
  47095. for (s2 = 0; s2 < symbolWidth; s2++) {
  47096. row[offsetS + s2] ^= symbolRow[s2];
  47097. }
  47098. break;
  47099. default:
  47100. error('JBIG2 error: operator ' + combinationOperator + ' is not supported');
  47101. }
  47102. }
  47103. currentS += symbolWidth - 1;
  47104. }
  47105. i++;
  47106. var deltaS = decodeInteger(contextCache, 'IADS', decoder);
  47107. if (deltaS === null) {
  47108. break;
  47109. }
  47110. currentS += deltaS + dsOffset;
  47111. } while (true);
  47112. }
  47113. return bitmap;
  47114. }
  47115. function readSegmentHeader(data, start) {
  47116. var segmentHeader = {};
  47117. segmentHeader.number = readUint32(data, start);
  47118. var flags = data[start + 4];
  47119. var segmentType = flags & 0x3F;
  47120. if (!SegmentTypes[segmentType]) {
  47121. error('JBIG2 error: invalid segment type: ' + segmentType);
  47122. }
  47123. segmentHeader.type = segmentType;
  47124. segmentHeader.typeName = SegmentTypes[segmentType];
  47125. segmentHeader.deferredNonRetain = !!(flags & 0x80);
  47126. var pageAssociationFieldSize = !!(flags & 0x40);
  47127. var referredFlags = data[start + 5];
  47128. var referredToCount = referredFlags >> 5 & 7;
  47129. var retainBits = [referredFlags & 31];
  47130. var position = start + 6;
  47131. if (referredFlags === 7) {
  47132. referredToCount = readUint32(data, position - 1) & 0x1FFFFFFF;
  47133. position += 3;
  47134. var bytes = referredToCount + 7 >> 3;
  47135. retainBits[0] = data[position++];
  47136. while (--bytes > 0) {
  47137. retainBits.push(data[position++]);
  47138. }
  47139. } else if (referredFlags === 5 || referredFlags === 6) {
  47140. error('JBIG2 error: invalid referred-to flags');
  47141. }
  47142. segmentHeader.retainBits = retainBits;
  47143. var referredToSegmentNumberSize = segmentHeader.number <= 256 ? 1 : segmentHeader.number <= 65536 ? 2 : 4;
  47144. var referredTo = [];
  47145. var i, ii;
  47146. for (i = 0; i < referredToCount; i++) {
  47147. var number = referredToSegmentNumberSize === 1 ? data[position] : referredToSegmentNumberSize === 2 ? readUint16(data, position) : readUint32(data, position);
  47148. referredTo.push(number);
  47149. position += referredToSegmentNumberSize;
  47150. }
  47151. segmentHeader.referredTo = referredTo;
  47152. if (!pageAssociationFieldSize) {
  47153. segmentHeader.pageAssociation = data[position++];
  47154. } else {
  47155. segmentHeader.pageAssociation = readUint32(data, position);
  47156. position += 4;
  47157. }
  47158. segmentHeader.length = readUint32(data, position);
  47159. position += 4;
  47160. if (segmentHeader.length === 0xFFFFFFFF) {
  47161. if (segmentType === 38) {
  47162. var genericRegionInfo = readRegionSegmentInformation(data, position);
  47163. var genericRegionSegmentFlags = data[position + RegionSegmentInformationFieldLength];
  47164. var genericRegionMmr = !!(genericRegionSegmentFlags & 1);
  47165. var searchPatternLength = 6;
  47166. var searchPattern = new Uint8Array(searchPatternLength);
  47167. if (!genericRegionMmr) {
  47168. searchPattern[0] = 0xFF;
  47169. searchPattern[1] = 0xAC;
  47170. }
  47171. searchPattern[2] = genericRegionInfo.height >>> 24 & 0xFF;
  47172. searchPattern[3] = genericRegionInfo.height >> 16 & 0xFF;
  47173. searchPattern[4] = genericRegionInfo.height >> 8 & 0xFF;
  47174. searchPattern[5] = genericRegionInfo.height & 0xFF;
  47175. for (i = position, ii = data.length; i < ii; i++) {
  47176. var j = 0;
  47177. while (j < searchPatternLength && searchPattern[j] === data[i + j]) {
  47178. j++;
  47179. }
  47180. if (j === searchPatternLength) {
  47181. segmentHeader.length = i + searchPatternLength;
  47182. break;
  47183. }
  47184. }
  47185. if (segmentHeader.length === 0xFFFFFFFF) {
  47186. error('JBIG2 error: segment end was not found');
  47187. }
  47188. } else {
  47189. error('JBIG2 error: invalid unknown segment length');
  47190. }
  47191. }
  47192. segmentHeader.headerEnd = position;
  47193. return segmentHeader;
  47194. }
  47195. function readSegments(header, data, start, end) {
  47196. var segments = [];
  47197. var position = start;
  47198. while (position < end) {
  47199. var segmentHeader = readSegmentHeader(data, position);
  47200. position = segmentHeader.headerEnd;
  47201. var segment = {
  47202. header: segmentHeader,
  47203. data: data
  47204. };
  47205. if (!header.randomAccess) {
  47206. segment.start = position;
  47207. position += segmentHeader.length;
  47208. segment.end = position;
  47209. }
  47210. segments.push(segment);
  47211. if (segmentHeader.type === 51) {
  47212. break;
  47213. }
  47214. }
  47215. if (header.randomAccess) {
  47216. for (var i = 0, ii = segments.length; i < ii; i++) {
  47217. segments[i].start = position;
  47218. position += segments[i].header.length;
  47219. segments[i].end = position;
  47220. }
  47221. }
  47222. return segments;
  47223. }
  47224. function readRegionSegmentInformation(data, start) {
  47225. return {
  47226. width: readUint32(data, start),
  47227. height: readUint32(data, start + 4),
  47228. x: readUint32(data, start + 8),
  47229. y: readUint32(data, start + 12),
  47230. combinationOperator: data[start + 16] & 7
  47231. };
  47232. }
  47233. var RegionSegmentInformationFieldLength = 17;
  47234. function processSegment(segment, visitor) {
  47235. var header = segment.header;
  47236. var data = segment.data, position = segment.start, end = segment.end;
  47237. var args, at, i, atLength;
  47238. switch (header.type) {
  47239. case 0:
  47240. var dictionary = {};
  47241. var dictionaryFlags = readUint16(data, position);
  47242. dictionary.huffman = !!(dictionaryFlags & 1);
  47243. dictionary.refinement = !!(dictionaryFlags & 2);
  47244. dictionary.huffmanDHSelector = dictionaryFlags >> 2 & 3;
  47245. dictionary.huffmanDWSelector = dictionaryFlags >> 4 & 3;
  47246. dictionary.bitmapSizeSelector = dictionaryFlags >> 6 & 1;
  47247. dictionary.aggregationInstancesSelector = dictionaryFlags >> 7 & 1;
  47248. dictionary.bitmapCodingContextUsed = !!(dictionaryFlags & 256);
  47249. dictionary.bitmapCodingContextRetained = !!(dictionaryFlags & 512);
  47250. dictionary.template = dictionaryFlags >> 10 & 3;
  47251. dictionary.refinementTemplate = dictionaryFlags >> 12 & 1;
  47252. position += 2;
  47253. if (!dictionary.huffman) {
  47254. atLength = dictionary.template === 0 ? 4 : 1;
  47255. at = [];
  47256. for (i = 0; i < atLength; i++) {
  47257. at.push({
  47258. x: readInt8(data, position),
  47259. y: readInt8(data, position + 1)
  47260. });
  47261. position += 2;
  47262. }
  47263. dictionary.at = at;
  47264. }
  47265. if (dictionary.refinement && !dictionary.refinementTemplate) {
  47266. at = [];
  47267. for (i = 0; i < 2; i++) {
  47268. at.push({
  47269. x: readInt8(data, position),
  47270. y: readInt8(data, position + 1)
  47271. });
  47272. position += 2;
  47273. }
  47274. dictionary.refinementAt = at;
  47275. }
  47276. dictionary.numberOfExportedSymbols = readUint32(data, position);
  47277. position += 4;
  47278. dictionary.numberOfNewSymbols = readUint32(data, position);
  47279. position += 4;
  47280. args = [
  47281. dictionary,
  47282. header.number,
  47283. header.referredTo,
  47284. data,
  47285. position,
  47286. end
  47287. ];
  47288. break;
  47289. case 6:
  47290. case 7:
  47291. var textRegion = {};
  47292. textRegion.info = readRegionSegmentInformation(data, position);
  47293. position += RegionSegmentInformationFieldLength;
  47294. var textRegionSegmentFlags = readUint16(data, position);
  47295. position += 2;
  47296. textRegion.huffman = !!(textRegionSegmentFlags & 1);
  47297. textRegion.refinement = !!(textRegionSegmentFlags & 2);
  47298. textRegion.stripSize = 1 << (textRegionSegmentFlags >> 2 & 3);
  47299. textRegion.referenceCorner = textRegionSegmentFlags >> 4 & 3;
  47300. textRegion.transposed = !!(textRegionSegmentFlags & 64);
  47301. textRegion.combinationOperator = textRegionSegmentFlags >> 7 & 3;
  47302. textRegion.defaultPixelValue = textRegionSegmentFlags >> 9 & 1;
  47303. textRegion.dsOffset = textRegionSegmentFlags << 17 >> 27;
  47304. textRegion.refinementTemplate = textRegionSegmentFlags >> 15 & 1;
  47305. if (textRegion.huffman) {
  47306. var textRegionHuffmanFlags = readUint16(data, position);
  47307. position += 2;
  47308. textRegion.huffmanFS = textRegionHuffmanFlags & 3;
  47309. textRegion.huffmanDS = textRegionHuffmanFlags >> 2 & 3;
  47310. textRegion.huffmanDT = textRegionHuffmanFlags >> 4 & 3;
  47311. textRegion.huffmanRefinementDW = textRegionHuffmanFlags >> 6 & 3;
  47312. textRegion.huffmanRefinementDH = textRegionHuffmanFlags >> 8 & 3;
  47313. textRegion.huffmanRefinementDX = textRegionHuffmanFlags >> 10 & 3;
  47314. textRegion.huffmanRefinementDY = textRegionHuffmanFlags >> 12 & 3;
  47315. textRegion.huffmanRefinementSizeSelector = !!(textRegionHuffmanFlags & 14);
  47316. }
  47317. if (textRegion.refinement && !textRegion.refinementTemplate) {
  47318. at = [];
  47319. for (i = 0; i < 2; i++) {
  47320. at.push({
  47321. x: readInt8(data, position),
  47322. y: readInt8(data, position + 1)
  47323. });
  47324. position += 2;
  47325. }
  47326. textRegion.refinementAt = at;
  47327. }
  47328. textRegion.numberOfSymbolInstances = readUint32(data, position);
  47329. position += 4;
  47330. if (textRegion.huffman) {
  47331. error('JBIG2 error: huffman is not supported');
  47332. }
  47333. args = [
  47334. textRegion,
  47335. header.referredTo,
  47336. data,
  47337. position,
  47338. end
  47339. ];
  47340. break;
  47341. case 38:
  47342. case 39:
  47343. var genericRegion = {};
  47344. genericRegion.info = readRegionSegmentInformation(data, position);
  47345. position += RegionSegmentInformationFieldLength;
  47346. var genericRegionSegmentFlags = data[position++];
  47347. genericRegion.mmr = !!(genericRegionSegmentFlags & 1);
  47348. genericRegion.template = genericRegionSegmentFlags >> 1 & 3;
  47349. genericRegion.prediction = !!(genericRegionSegmentFlags & 8);
  47350. if (!genericRegion.mmr) {
  47351. atLength = genericRegion.template === 0 ? 4 : 1;
  47352. at = [];
  47353. for (i = 0; i < atLength; i++) {
  47354. at.push({
  47355. x: readInt8(data, position),
  47356. y: readInt8(data, position + 1)
  47357. });
  47358. position += 2;
  47359. }
  47360. genericRegion.at = at;
  47361. }
  47362. args = [
  47363. genericRegion,
  47364. data,
  47365. position,
  47366. end
  47367. ];
  47368. break;
  47369. case 48:
  47370. var pageInfo = {
  47371. width: readUint32(data, position),
  47372. height: readUint32(data, position + 4),
  47373. resolutionX: readUint32(data, position + 8),
  47374. resolutionY: readUint32(data, position + 12)
  47375. };
  47376. if (pageInfo.height === 0xFFFFFFFF) {
  47377. delete pageInfo.height;
  47378. }
  47379. var pageSegmentFlags = data[position + 16];
  47380. readUint16(data, position + 17);
  47381. pageInfo.lossless = !!(pageSegmentFlags & 1);
  47382. pageInfo.refinement = !!(pageSegmentFlags & 2);
  47383. pageInfo.defaultPixelValue = pageSegmentFlags >> 2 & 1;
  47384. pageInfo.combinationOperator = pageSegmentFlags >> 3 & 3;
  47385. pageInfo.requiresBuffer = !!(pageSegmentFlags & 32);
  47386. pageInfo.combinationOperatorOverride = !!(pageSegmentFlags & 64);
  47387. args = [pageInfo];
  47388. break;
  47389. case 49:
  47390. break;
  47391. case 50:
  47392. break;
  47393. case 51:
  47394. break;
  47395. case 62:
  47396. break;
  47397. default:
  47398. error('JBIG2 error: segment type ' + header.typeName + '(' + header.type + ') is not implemented');
  47399. }
  47400. var callbackName = 'on' + header.typeName;
  47401. if (callbackName in visitor) {
  47402. visitor[callbackName].apply(visitor, args);
  47403. }
  47404. }
  47405. function processSegments(segments, visitor) {
  47406. for (var i = 0, ii = segments.length; i < ii; i++) {
  47407. processSegment(segments[i], visitor);
  47408. }
  47409. }
  47410. function parseJbig2(data, start, end) {
  47411. var position = start;
  47412. 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) {
  47413. error('JBIG2 error: invalid header');
  47414. }
  47415. var header = {};
  47416. position += 8;
  47417. var flags = data[position++];
  47418. header.randomAccess = !(flags & 1);
  47419. if (!(flags & 2)) {
  47420. header.numberOfPages = readUint32(data, position);
  47421. position += 4;
  47422. }
  47423. readSegments(header, data, position, end);
  47424. error('Not implemented');
  47425. }
  47426. function parseJbig2Chunks(chunks) {
  47427. var visitor = new SimpleSegmentVisitor();
  47428. for (var i = 0, ii = chunks.length; i < ii; i++) {
  47429. var chunk = chunks[i];
  47430. var segments = readSegments({}, chunk.data, chunk.start, chunk.end);
  47431. processSegments(segments, visitor);
  47432. }
  47433. return visitor.buffer;
  47434. }
  47435. function SimpleSegmentVisitor() {
  47436. }
  47437. SimpleSegmentVisitor.prototype = {
  47438. onPageInformation: function SimpleSegmentVisitor_onPageInformation(info) {
  47439. this.currentPageInfo = info;
  47440. var rowSize = info.width + 7 >> 3;
  47441. var buffer = new Uint8Array(rowSize * info.height);
  47442. if (info.defaultPixelValue) {
  47443. for (var i = 0, ii = buffer.length; i < ii; i++) {
  47444. buffer[i] = 0xFF;
  47445. }
  47446. }
  47447. this.buffer = buffer;
  47448. },
  47449. drawBitmap: function SimpleSegmentVisitor_drawBitmap(regionInfo, bitmap) {
  47450. var pageInfo = this.currentPageInfo;
  47451. var width = regionInfo.width, height = regionInfo.height;
  47452. var rowSize = pageInfo.width + 7 >> 3;
  47453. var combinationOperator = pageInfo.combinationOperatorOverride ? regionInfo.combinationOperator : pageInfo.combinationOperator;
  47454. var buffer = this.buffer;
  47455. var mask0 = 128 >> (regionInfo.x & 7);
  47456. var offset0 = regionInfo.y * rowSize + (regionInfo.x >> 3);
  47457. var i, j, mask, offset;
  47458. switch (combinationOperator) {
  47459. case 0:
  47460. for (i = 0; i < height; i++) {
  47461. mask = mask0;
  47462. offset = offset0;
  47463. for (j = 0; j < width; j++) {
  47464. if (bitmap[i][j]) {
  47465. buffer[offset] |= mask;
  47466. }
  47467. mask >>= 1;
  47468. if (!mask) {
  47469. mask = 128;
  47470. offset++;
  47471. }
  47472. }
  47473. offset0 += rowSize;
  47474. }
  47475. break;
  47476. case 2:
  47477. for (i = 0; i < height; i++) {
  47478. mask = mask0;
  47479. offset = offset0;
  47480. for (j = 0; j < width; j++) {
  47481. if (bitmap[i][j]) {
  47482. buffer[offset] ^= mask;
  47483. }
  47484. mask >>= 1;
  47485. if (!mask) {
  47486. mask = 128;
  47487. offset++;
  47488. }
  47489. }
  47490. offset0 += rowSize;
  47491. }
  47492. break;
  47493. default:
  47494. error('JBIG2 error: operator ' + combinationOperator + ' is not supported');
  47495. }
  47496. },
  47497. onImmediateGenericRegion: function SimpleSegmentVisitor_onImmediateGenericRegion(region, data, start, end) {
  47498. var regionInfo = region.info;
  47499. var decodingContext = new DecodingContext(data, start, end);
  47500. var bitmap = decodeBitmap(region.mmr, regionInfo.width, regionInfo.height, region.template, region.prediction, null, region.at, decodingContext);
  47501. this.drawBitmap(regionInfo, bitmap);
  47502. },
  47503. onImmediateLosslessGenericRegion: function SimpleSegmentVisitor_onImmediateLosslessGenericRegion() {
  47504. this.onImmediateGenericRegion.apply(this, arguments);
  47505. },
  47506. onSymbolDictionary: function SimpleSegmentVisitor_onSymbolDictionary(dictionary, currentSegment, referredSegments, data, start, end) {
  47507. var huffmanTables;
  47508. if (dictionary.huffman) {
  47509. error('JBIG2 error: huffman is not supported');
  47510. }
  47511. var symbols = this.symbols;
  47512. if (!symbols) {
  47513. this.symbols = symbols = {};
  47514. }
  47515. var inputSymbols = [];
  47516. for (var i = 0, ii = referredSegments.length; i < ii; i++) {
  47517. inputSymbols = inputSymbols.concat(symbols[referredSegments[i]]);
  47518. }
  47519. var decodingContext = new DecodingContext(data, start, end);
  47520. symbols[currentSegment] = decodeSymbolDictionary(dictionary.huffman, dictionary.refinement, inputSymbols, dictionary.numberOfNewSymbols, dictionary.numberOfExportedSymbols, huffmanTables, dictionary.template, dictionary.at, dictionary.refinementTemplate, dictionary.refinementAt, decodingContext);
  47521. },
  47522. onImmediateTextRegion: function SimpleSegmentVisitor_onImmediateTextRegion(region, referredSegments, data, start, end) {
  47523. var regionInfo = region.info;
  47524. var huffmanTables;
  47525. var symbols = this.symbols;
  47526. var inputSymbols = [];
  47527. for (var i = 0, ii = referredSegments.length; i < ii; i++) {
  47528. inputSymbols = inputSymbols.concat(symbols[referredSegments[i]]);
  47529. }
  47530. var symbolCodeLength = log2(inputSymbols.length);
  47531. var decodingContext = new DecodingContext(data, start, end);
  47532. 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);
  47533. this.drawBitmap(regionInfo, bitmap);
  47534. },
  47535. onImmediateLosslessTextRegion: function SimpleSegmentVisitor_onImmediateLosslessTextRegion() {
  47536. this.onImmediateTextRegion.apply(this, arguments);
  47537. }
  47538. };
  47539. function Jbig2Image() {
  47540. }
  47541. Jbig2Image.prototype = {
  47542. parseChunks: function Jbig2Image_parseChunks(chunks) {
  47543. return parseJbig2Chunks(chunks);
  47544. }
  47545. };
  47546. return Jbig2Image;
  47547. }();
  47548. exports.Jbig2Image = Jbig2Image;
  47549. /***/ }),
  47550. /* 36 */
  47551. /***/ (function(module, exports, __w_pdfjs_require__) {
  47552. "use strict";
  47553. var sharedUtil = __w_pdfjs_require__(0);
  47554. var warn = sharedUtil.warn;
  47555. var error = sharedUtil.error;
  47556. var JpegImage = function JpegImageClosure() {
  47557. var dctZigZag = new Uint8Array([
  47558. 0,
  47559. 1,
  47560. 8,
  47561. 16,
  47562. 9,
  47563. 2,
  47564. 3,
  47565. 10,
  47566. 17,
  47567. 24,
  47568. 32,
  47569. 25,
  47570. 18,
  47571. 11,
  47572. 4,
  47573. 5,
  47574. 12,
  47575. 19,
  47576. 26,
  47577. 33,
  47578. 40,
  47579. 48,
  47580. 41,
  47581. 34,
  47582. 27,
  47583. 20,
  47584. 13,
  47585. 6,
  47586. 7,
  47587. 14,
  47588. 21,
  47589. 28,
  47590. 35,
  47591. 42,
  47592. 49,
  47593. 56,
  47594. 57,
  47595. 50,
  47596. 43,
  47597. 36,
  47598. 29,
  47599. 22,
  47600. 15,
  47601. 23,
  47602. 30,
  47603. 37,
  47604. 44,
  47605. 51,
  47606. 58,
  47607. 59,
  47608. 52,
  47609. 45,
  47610. 38,
  47611. 31,
  47612. 39,
  47613. 46,
  47614. 53,
  47615. 60,
  47616. 61,
  47617. 54,
  47618. 47,
  47619. 55,
  47620. 62,
  47621. 63
  47622. ]);
  47623. var dctCos1 = 4017;
  47624. var dctSin1 = 799;
  47625. var dctCos3 = 3406;
  47626. var dctSin3 = 2276;
  47627. var dctCos6 = 1567;
  47628. var dctSin6 = 3784;
  47629. var dctSqrt2 = 5793;
  47630. var dctSqrt1d2 = 2896;
  47631. function JpegImage() {
  47632. this.decodeTransform = null;
  47633. this.colorTransform = -1;
  47634. }
  47635. function buildHuffmanTable(codeLengths, values) {
  47636. var k = 0, code = [], i, j, length = 16;
  47637. while (length > 0 && !codeLengths[length - 1]) {
  47638. length--;
  47639. }
  47640. code.push({
  47641. children: [],
  47642. index: 0
  47643. });
  47644. var p = code[0], q;
  47645. for (i = 0; i < length; i++) {
  47646. for (j = 0; j < codeLengths[i]; j++) {
  47647. p = code.pop();
  47648. p.children[p.index] = values[k];
  47649. while (p.index > 0) {
  47650. p = code.pop();
  47651. }
  47652. p.index++;
  47653. code.push(p);
  47654. while (code.length <= i) {
  47655. code.push(q = {
  47656. children: [],
  47657. index: 0
  47658. });
  47659. p.children[p.index] = q.children;
  47660. p = q;
  47661. }
  47662. k++;
  47663. }
  47664. if (i + 1 < length) {
  47665. code.push(q = {
  47666. children: [],
  47667. index: 0
  47668. });
  47669. p.children[p.index] = q.children;
  47670. p = q;
  47671. }
  47672. }
  47673. return code[0].children;
  47674. }
  47675. function getBlockBufferOffset(component, row, col) {
  47676. return 64 * ((component.blocksPerLine + 1) * row + col);
  47677. }
  47678. function decodeScan(data, offset, frame, components, resetInterval, spectralStart, spectralEnd, successivePrev, successive) {
  47679. var mcusPerLine = frame.mcusPerLine;
  47680. var progressive = frame.progressive;
  47681. var startOffset = offset, bitsData = 0, bitsCount = 0;
  47682. function readBit() {
  47683. if (bitsCount > 0) {
  47684. bitsCount--;
  47685. return bitsData >> bitsCount & 1;
  47686. }
  47687. bitsData = data[offset++];
  47688. if (bitsData === 0xFF) {
  47689. var nextByte = data[offset++];
  47690. if (nextByte) {
  47691. error('JPEG error: unexpected marker ' + (bitsData << 8 | nextByte).toString(16));
  47692. }
  47693. }
  47694. bitsCount = 7;
  47695. return bitsData >>> 7;
  47696. }
  47697. function decodeHuffman(tree) {
  47698. var node = tree;
  47699. while (true) {
  47700. node = node[readBit()];
  47701. if (typeof node === 'number') {
  47702. return node;
  47703. }
  47704. if (typeof node !== 'object') {
  47705. error('JPEG error: invalid huffman sequence');
  47706. }
  47707. }
  47708. }
  47709. function receive(length) {
  47710. var n = 0;
  47711. while (length > 0) {
  47712. n = n << 1 | readBit();
  47713. length--;
  47714. }
  47715. return n;
  47716. }
  47717. function receiveAndExtend(length) {
  47718. if (length === 1) {
  47719. return readBit() === 1 ? 1 : -1;
  47720. }
  47721. var n = receive(length);
  47722. if (n >= 1 << length - 1) {
  47723. return n;
  47724. }
  47725. return n + (-1 << length) + 1;
  47726. }
  47727. function decodeBaseline(component, offset) {
  47728. var t = decodeHuffman(component.huffmanTableDC);
  47729. var diff = t === 0 ? 0 : receiveAndExtend(t);
  47730. component.blockData[offset] = component.pred += diff;
  47731. var k = 1;
  47732. while (k < 64) {
  47733. var rs = decodeHuffman(component.huffmanTableAC);
  47734. var s = rs & 15, r = rs >> 4;
  47735. if (s === 0) {
  47736. if (r < 15) {
  47737. break;
  47738. }
  47739. k += 16;
  47740. continue;
  47741. }
  47742. k += r;
  47743. var z = dctZigZag[k];
  47744. component.blockData[offset + z] = receiveAndExtend(s);
  47745. k++;
  47746. }
  47747. }
  47748. function decodeDCFirst(component, offset) {
  47749. var t = decodeHuffman(component.huffmanTableDC);
  47750. var diff = t === 0 ? 0 : receiveAndExtend(t) << successive;
  47751. component.blockData[offset] = component.pred += diff;
  47752. }
  47753. function decodeDCSuccessive(component, offset) {
  47754. component.blockData[offset] |= readBit() << successive;
  47755. }
  47756. var eobrun = 0;
  47757. function decodeACFirst(component, offset) {
  47758. if (eobrun > 0) {
  47759. eobrun--;
  47760. return;
  47761. }
  47762. var k = spectralStart, e = spectralEnd;
  47763. while (k <= e) {
  47764. var rs = decodeHuffman(component.huffmanTableAC);
  47765. var s = rs & 15, r = rs >> 4;
  47766. if (s === 0) {
  47767. if (r < 15) {
  47768. eobrun = receive(r) + (1 << r) - 1;
  47769. break;
  47770. }
  47771. k += 16;
  47772. continue;
  47773. }
  47774. k += r;
  47775. var z = dctZigZag[k];
  47776. component.blockData[offset + z] = receiveAndExtend(s) * (1 << successive);
  47777. k++;
  47778. }
  47779. }
  47780. var successiveACState = 0, successiveACNextValue;
  47781. function decodeACSuccessive(component, offset) {
  47782. var k = spectralStart;
  47783. var e = spectralEnd;
  47784. var r = 0;
  47785. var s;
  47786. var rs;
  47787. while (k <= e) {
  47788. var z = dctZigZag[k];
  47789. switch (successiveACState) {
  47790. case 0:
  47791. rs = decodeHuffman(component.huffmanTableAC);
  47792. s = rs & 15;
  47793. r = rs >> 4;
  47794. if (s === 0) {
  47795. if (r < 15) {
  47796. eobrun = receive(r) + (1 << r);
  47797. successiveACState = 4;
  47798. } else {
  47799. r = 16;
  47800. successiveACState = 1;
  47801. }
  47802. } else {
  47803. if (s !== 1) {
  47804. error('JPEG error: invalid ACn encoding');
  47805. }
  47806. successiveACNextValue = receiveAndExtend(s);
  47807. successiveACState = r ? 2 : 3;
  47808. }
  47809. continue;
  47810. case 1:
  47811. case 2:
  47812. if (component.blockData[offset + z]) {
  47813. component.blockData[offset + z] += readBit() << successive;
  47814. } else {
  47815. r--;
  47816. if (r === 0) {
  47817. successiveACState = successiveACState === 2 ? 3 : 0;
  47818. }
  47819. }
  47820. break;
  47821. case 3:
  47822. if (component.blockData[offset + z]) {
  47823. component.blockData[offset + z] += readBit() << successive;
  47824. } else {
  47825. component.blockData[offset + z] = successiveACNextValue << successive;
  47826. successiveACState = 0;
  47827. }
  47828. break;
  47829. case 4:
  47830. if (component.blockData[offset + z]) {
  47831. component.blockData[offset + z] += readBit() << successive;
  47832. }
  47833. break;
  47834. }
  47835. k++;
  47836. }
  47837. if (successiveACState === 4) {
  47838. eobrun--;
  47839. if (eobrun === 0) {
  47840. successiveACState = 0;
  47841. }
  47842. }
  47843. }
  47844. function decodeMcu(component, decode, mcu, row, col) {
  47845. var mcuRow = mcu / mcusPerLine | 0;
  47846. var mcuCol = mcu % mcusPerLine;
  47847. var blockRow = mcuRow * component.v + row;
  47848. var blockCol = mcuCol * component.h + col;
  47849. var offset = getBlockBufferOffset(component, blockRow, blockCol);
  47850. decode(component, offset);
  47851. }
  47852. function decodeBlock(component, decode, mcu) {
  47853. var blockRow = mcu / component.blocksPerLine | 0;
  47854. var blockCol = mcu % component.blocksPerLine;
  47855. var offset = getBlockBufferOffset(component, blockRow, blockCol);
  47856. decode(component, offset);
  47857. }
  47858. var componentsLength = components.length;
  47859. var component, i, j, k, n;
  47860. var decodeFn;
  47861. if (progressive) {
  47862. if (spectralStart === 0) {
  47863. decodeFn = successivePrev === 0 ? decodeDCFirst : decodeDCSuccessive;
  47864. } else {
  47865. decodeFn = successivePrev === 0 ? decodeACFirst : decodeACSuccessive;
  47866. }
  47867. } else {
  47868. decodeFn = decodeBaseline;
  47869. }
  47870. var mcu = 0, marker;
  47871. var mcuExpected;
  47872. if (componentsLength === 1) {
  47873. mcuExpected = components[0].blocksPerLine * components[0].blocksPerColumn;
  47874. } else {
  47875. mcuExpected = mcusPerLine * frame.mcusPerColumn;
  47876. }
  47877. if (!resetInterval) {
  47878. resetInterval = mcuExpected;
  47879. }
  47880. var h, v;
  47881. while (mcu < mcuExpected) {
  47882. for (i = 0; i < componentsLength; i++) {
  47883. components[i].pred = 0;
  47884. }
  47885. eobrun = 0;
  47886. if (componentsLength === 1) {
  47887. component = components[0];
  47888. for (n = 0; n < resetInterval; n++) {
  47889. decodeBlock(component, decodeFn, mcu);
  47890. mcu++;
  47891. }
  47892. } else {
  47893. for (n = 0; n < resetInterval; n++) {
  47894. for (i = 0; i < componentsLength; i++) {
  47895. component = components[i];
  47896. h = component.h;
  47897. v = component.v;
  47898. for (j = 0; j < v; j++) {
  47899. for (k = 0; k < h; k++) {
  47900. decodeMcu(component, decodeFn, mcu, j, k);
  47901. }
  47902. }
  47903. }
  47904. mcu++;
  47905. }
  47906. }
  47907. bitsCount = 0;
  47908. marker = data[offset] << 8 | data[offset + 1];
  47909. while (data[offset] === 0x00 && offset < data.length - 1) {
  47910. offset++;
  47911. marker = data[offset] << 8 | data[offset + 1];
  47912. }
  47913. if (marker <= 0xFF00) {
  47914. error('JPEG error: marker was not found');
  47915. }
  47916. if (marker >= 0xFFD0 && marker <= 0xFFD7) {
  47917. offset += 2;
  47918. } else {
  47919. break;
  47920. }
  47921. }
  47922. return offset - startOffset;
  47923. }
  47924. function quantizeAndInverse(component, blockBufferOffset, p) {
  47925. var qt = component.quantizationTable, blockData = component.blockData;
  47926. var v0, v1, v2, v3, v4, v5, v6, v7;
  47927. var p0, p1, p2, p3, p4, p5, p6, p7;
  47928. var t;
  47929. if (!qt) {
  47930. error('JPEG error: missing required Quantization Table.');
  47931. }
  47932. for (var row = 0; row < 64; row += 8) {
  47933. p0 = blockData[blockBufferOffset + row];
  47934. p1 = blockData[blockBufferOffset + row + 1];
  47935. p2 = blockData[blockBufferOffset + row + 2];
  47936. p3 = blockData[blockBufferOffset + row + 3];
  47937. p4 = blockData[blockBufferOffset + row + 4];
  47938. p5 = blockData[blockBufferOffset + row + 5];
  47939. p6 = blockData[blockBufferOffset + row + 6];
  47940. p7 = blockData[blockBufferOffset + row + 7];
  47941. p0 *= qt[row];
  47942. if ((p1 | p2 | p3 | p4 | p5 | p6 | p7) === 0) {
  47943. t = dctSqrt2 * p0 + 512 >> 10;
  47944. p[row] = t;
  47945. p[row + 1] = t;
  47946. p[row + 2] = t;
  47947. p[row + 3] = t;
  47948. p[row + 4] = t;
  47949. p[row + 5] = t;
  47950. p[row + 6] = t;
  47951. p[row + 7] = t;
  47952. continue;
  47953. }
  47954. p1 *= qt[row + 1];
  47955. p2 *= qt[row + 2];
  47956. p3 *= qt[row + 3];
  47957. p4 *= qt[row + 4];
  47958. p5 *= qt[row + 5];
  47959. p6 *= qt[row + 6];
  47960. p7 *= qt[row + 7];
  47961. v0 = dctSqrt2 * p0 + 128 >> 8;
  47962. v1 = dctSqrt2 * p4 + 128 >> 8;
  47963. v2 = p2;
  47964. v3 = p6;
  47965. v4 = dctSqrt1d2 * (p1 - p7) + 128 >> 8;
  47966. v7 = dctSqrt1d2 * (p1 + p7) + 128 >> 8;
  47967. v5 = p3 << 4;
  47968. v6 = p5 << 4;
  47969. v0 = v0 + v1 + 1 >> 1;
  47970. v1 = v0 - v1;
  47971. t = v2 * dctSin6 + v3 * dctCos6 + 128 >> 8;
  47972. v2 = v2 * dctCos6 - v3 * dctSin6 + 128 >> 8;
  47973. v3 = t;
  47974. v4 = v4 + v6 + 1 >> 1;
  47975. v6 = v4 - v6;
  47976. v7 = v7 + v5 + 1 >> 1;
  47977. v5 = v7 - v5;
  47978. v0 = v0 + v3 + 1 >> 1;
  47979. v3 = v0 - v3;
  47980. v1 = v1 + v2 + 1 >> 1;
  47981. v2 = v1 - v2;
  47982. t = v4 * dctSin3 + v7 * dctCos3 + 2048 >> 12;
  47983. v4 = v4 * dctCos3 - v7 * dctSin3 + 2048 >> 12;
  47984. v7 = t;
  47985. t = v5 * dctSin1 + v6 * dctCos1 + 2048 >> 12;
  47986. v5 = v5 * dctCos1 - v6 * dctSin1 + 2048 >> 12;
  47987. v6 = t;
  47988. p[row] = v0 + v7;
  47989. p[row + 7] = v0 - v7;
  47990. p[row + 1] = v1 + v6;
  47991. p[row + 6] = v1 - v6;
  47992. p[row + 2] = v2 + v5;
  47993. p[row + 5] = v2 - v5;
  47994. p[row + 3] = v3 + v4;
  47995. p[row + 4] = v3 - v4;
  47996. }
  47997. for (var col = 0; col < 8; ++col) {
  47998. p0 = p[col];
  47999. p1 = p[col + 8];
  48000. p2 = p[col + 16];
  48001. p3 = p[col + 24];
  48002. p4 = p[col + 32];
  48003. p5 = p[col + 40];
  48004. p6 = p[col + 48];
  48005. p7 = p[col + 56];
  48006. if ((p1 | p2 | p3 | p4 | p5 | p6 | p7) === 0) {
  48007. t = dctSqrt2 * p0 + 8192 >> 14;
  48008. t = t < -2040 ? 0 : t >= 2024 ? 255 : t + 2056 >> 4;
  48009. blockData[blockBufferOffset + col] = t;
  48010. blockData[blockBufferOffset + col + 8] = t;
  48011. blockData[blockBufferOffset + col + 16] = t;
  48012. blockData[blockBufferOffset + col + 24] = t;
  48013. blockData[blockBufferOffset + col + 32] = t;
  48014. blockData[blockBufferOffset + col + 40] = t;
  48015. blockData[blockBufferOffset + col + 48] = t;
  48016. blockData[blockBufferOffset + col + 56] = t;
  48017. continue;
  48018. }
  48019. v0 = dctSqrt2 * p0 + 2048 >> 12;
  48020. v1 = dctSqrt2 * p4 + 2048 >> 12;
  48021. v2 = p2;
  48022. v3 = p6;
  48023. v4 = dctSqrt1d2 * (p1 - p7) + 2048 >> 12;
  48024. v7 = dctSqrt1d2 * (p1 + p7) + 2048 >> 12;
  48025. v5 = p3;
  48026. v6 = p5;
  48027. v0 = (v0 + v1 + 1 >> 1) + 4112;
  48028. v1 = v0 - v1;
  48029. t = v2 * dctSin6 + v3 * dctCos6 + 2048 >> 12;
  48030. v2 = v2 * dctCos6 - v3 * dctSin6 + 2048 >> 12;
  48031. v3 = t;
  48032. v4 = v4 + v6 + 1 >> 1;
  48033. v6 = v4 - v6;
  48034. v7 = v7 + v5 + 1 >> 1;
  48035. v5 = v7 - v5;
  48036. v0 = v0 + v3 + 1 >> 1;
  48037. v3 = v0 - v3;
  48038. v1 = v1 + v2 + 1 >> 1;
  48039. v2 = v1 - v2;
  48040. t = v4 * dctSin3 + v7 * dctCos3 + 2048 >> 12;
  48041. v4 = v4 * dctCos3 - v7 * dctSin3 + 2048 >> 12;
  48042. v7 = t;
  48043. t = v5 * dctSin1 + v6 * dctCos1 + 2048 >> 12;
  48044. v5 = v5 * dctCos1 - v6 * dctSin1 + 2048 >> 12;
  48045. v6 = t;
  48046. p0 = v0 + v7;
  48047. p7 = v0 - v7;
  48048. p1 = v1 + v6;
  48049. p6 = v1 - v6;
  48050. p2 = v2 + v5;
  48051. p5 = v2 - v5;
  48052. p3 = v3 + v4;
  48053. p4 = v3 - v4;
  48054. p0 = p0 < 16 ? 0 : p0 >= 4080 ? 255 : p0 >> 4;
  48055. p1 = p1 < 16 ? 0 : p1 >= 4080 ? 255 : p1 >> 4;
  48056. p2 = p2 < 16 ? 0 : p2 >= 4080 ? 255 : p2 >> 4;
  48057. p3 = p3 < 16 ? 0 : p3 >= 4080 ? 255 : p3 >> 4;
  48058. p4 = p4 < 16 ? 0 : p4 >= 4080 ? 255 : p4 >> 4;
  48059. p5 = p5 < 16 ? 0 : p5 >= 4080 ? 255 : p5 >> 4;
  48060. p6 = p6 < 16 ? 0 : p6 >= 4080 ? 255 : p6 >> 4;
  48061. p7 = p7 < 16 ? 0 : p7 >= 4080 ? 255 : p7 >> 4;
  48062. blockData[blockBufferOffset + col] = p0;
  48063. blockData[blockBufferOffset + col + 8] = p1;
  48064. blockData[blockBufferOffset + col + 16] = p2;
  48065. blockData[blockBufferOffset + col + 24] = p3;
  48066. blockData[blockBufferOffset + col + 32] = p4;
  48067. blockData[blockBufferOffset + col + 40] = p5;
  48068. blockData[blockBufferOffset + col + 48] = p6;
  48069. blockData[blockBufferOffset + col + 56] = p7;
  48070. }
  48071. }
  48072. function buildComponentData(frame, component) {
  48073. var blocksPerLine = component.blocksPerLine;
  48074. var blocksPerColumn = component.blocksPerColumn;
  48075. var computationBuffer = new Int16Array(64);
  48076. for (var blockRow = 0; blockRow < blocksPerColumn; blockRow++) {
  48077. for (var blockCol = 0; blockCol < blocksPerLine; blockCol++) {
  48078. var offset = getBlockBufferOffset(component, blockRow, blockCol);
  48079. quantizeAndInverse(component, offset, computationBuffer);
  48080. }
  48081. }
  48082. return component.blockData;
  48083. }
  48084. function clamp0to255(a) {
  48085. return a <= 0 ? 0 : a >= 255 ? 255 : a;
  48086. }
  48087. JpegImage.prototype = {
  48088. parse: function parse(data) {
  48089. function readUint16() {
  48090. var value = data[offset] << 8 | data[offset + 1];
  48091. offset += 2;
  48092. return value;
  48093. }
  48094. function readDataBlock() {
  48095. function isValidMarkerAt(pos) {
  48096. if (pos < data.length - 1) {
  48097. return data[pos] === 0xFF && data[pos + 1] >= 0xC0 && data[pos + 1] <= 0xFE;
  48098. }
  48099. return true;
  48100. }
  48101. var length = readUint16();
  48102. var endOffset = offset + length - 2;
  48103. if (!isValidMarkerAt(endOffset)) {
  48104. warn('readDataBlock - incorrect length, next marker is: ' + (data[endOffset] << 8 | data[endOffset + 1]).toString('16'));
  48105. var pos = offset;
  48106. while (!isValidMarkerAt(pos)) {
  48107. pos++;
  48108. }
  48109. endOffset = pos;
  48110. }
  48111. var array = data.subarray(offset, endOffset);
  48112. offset += array.length;
  48113. return array;
  48114. }
  48115. function prepareComponents(frame) {
  48116. var mcusPerLine = Math.ceil(frame.samplesPerLine / 8 / frame.maxH);
  48117. var mcusPerColumn = Math.ceil(frame.scanLines / 8 / frame.maxV);
  48118. for (var i = 0; i < frame.components.length; i++) {
  48119. component = frame.components[i];
  48120. var blocksPerLine = Math.ceil(Math.ceil(frame.samplesPerLine / 8) * component.h / frame.maxH);
  48121. var blocksPerColumn = Math.ceil(Math.ceil(frame.scanLines / 8) * component.v / frame.maxV);
  48122. var blocksPerLineForMcu = mcusPerLine * component.h;
  48123. var blocksPerColumnForMcu = mcusPerColumn * component.v;
  48124. var blocksBufferSize = 64 * blocksPerColumnForMcu * (blocksPerLineForMcu + 1);
  48125. component.blockData = new Int16Array(blocksBufferSize);
  48126. component.blocksPerLine = blocksPerLine;
  48127. component.blocksPerColumn = blocksPerColumn;
  48128. }
  48129. frame.mcusPerLine = mcusPerLine;
  48130. frame.mcusPerColumn = mcusPerColumn;
  48131. }
  48132. var offset = 0;
  48133. var jfif = null;
  48134. var adobe = null;
  48135. var frame, resetInterval;
  48136. var quantizationTables = [];
  48137. var huffmanTablesAC = [], huffmanTablesDC = [];
  48138. var fileMarker = readUint16();
  48139. if (fileMarker !== 0xFFD8) {
  48140. error('JPEG error: SOI not found');
  48141. }
  48142. fileMarker = readUint16();
  48143. while (fileMarker !== 0xFFD9) {
  48144. var i, j, l;
  48145. switch (fileMarker) {
  48146. case 0xFFE0:
  48147. case 0xFFE1:
  48148. case 0xFFE2:
  48149. case 0xFFE3:
  48150. case 0xFFE4:
  48151. case 0xFFE5:
  48152. case 0xFFE6:
  48153. case 0xFFE7:
  48154. case 0xFFE8:
  48155. case 0xFFE9:
  48156. case 0xFFEA:
  48157. case 0xFFEB:
  48158. case 0xFFEC:
  48159. case 0xFFED:
  48160. case 0xFFEE:
  48161. case 0xFFEF:
  48162. case 0xFFFE:
  48163. var appData = readDataBlock();
  48164. if (fileMarker === 0xFFE0) {
  48165. if (appData[0] === 0x4A && appData[1] === 0x46 && appData[2] === 0x49 && appData[3] === 0x46 && appData[4] === 0) {
  48166. jfif = {
  48167. version: {
  48168. major: appData[5],
  48169. minor: appData[6]
  48170. },
  48171. densityUnits: appData[7],
  48172. xDensity: appData[8] << 8 | appData[9],
  48173. yDensity: appData[10] << 8 | appData[11],
  48174. thumbWidth: appData[12],
  48175. thumbHeight: appData[13],
  48176. thumbData: appData.subarray(14, 14 + 3 * appData[12] * appData[13])
  48177. };
  48178. }
  48179. }
  48180. if (fileMarker === 0xFFEE) {
  48181. if (appData[0] === 0x41 && appData[1] === 0x64 && appData[2] === 0x6F && appData[3] === 0x62 && appData[4] === 0x65) {
  48182. adobe = {
  48183. version: appData[5] << 8 | appData[6],
  48184. flags0: appData[7] << 8 | appData[8],
  48185. flags1: appData[9] << 8 | appData[10],
  48186. transformCode: appData[11]
  48187. };
  48188. }
  48189. }
  48190. break;
  48191. case 0xFFDB:
  48192. var quantizationTablesLength = readUint16();
  48193. var quantizationTablesEnd = quantizationTablesLength + offset - 2;
  48194. var z;
  48195. while (offset < quantizationTablesEnd) {
  48196. var quantizationTableSpec = data[offset++];
  48197. var tableData = new Uint16Array(64);
  48198. if (quantizationTableSpec >> 4 === 0) {
  48199. for (j = 0; j < 64; j++) {
  48200. z = dctZigZag[j];
  48201. tableData[z] = data[offset++];
  48202. }
  48203. } else if (quantizationTableSpec >> 4 === 1) {
  48204. for (j = 0; j < 64; j++) {
  48205. z = dctZigZag[j];
  48206. tableData[z] = readUint16();
  48207. }
  48208. } else {
  48209. error('JPEG error: DQT - invalid table spec');
  48210. }
  48211. quantizationTables[quantizationTableSpec & 15] = tableData;
  48212. }
  48213. break;
  48214. case 0xFFC0:
  48215. case 0xFFC1:
  48216. case 0xFFC2:
  48217. if (frame) {
  48218. error('JPEG error: Only single frame JPEGs supported');
  48219. }
  48220. readUint16();
  48221. frame = {};
  48222. frame.extended = fileMarker === 0xFFC1;
  48223. frame.progressive = fileMarker === 0xFFC2;
  48224. frame.precision = data[offset++];
  48225. frame.scanLines = readUint16();
  48226. frame.samplesPerLine = readUint16();
  48227. frame.components = [];
  48228. frame.componentIds = {};
  48229. var componentsCount = data[offset++], componentId;
  48230. var maxH = 0, maxV = 0;
  48231. for (i = 0; i < componentsCount; i++) {
  48232. componentId = data[offset];
  48233. var h = data[offset + 1] >> 4;
  48234. var v = data[offset + 1] & 15;
  48235. if (maxH < h) {
  48236. maxH = h;
  48237. }
  48238. if (maxV < v) {
  48239. maxV = v;
  48240. }
  48241. var qId = data[offset + 2];
  48242. l = frame.components.push({
  48243. h: h,
  48244. v: v,
  48245. quantizationId: qId,
  48246. quantizationTable: null
  48247. });
  48248. frame.componentIds[componentId] = l - 1;
  48249. offset += 3;
  48250. }
  48251. frame.maxH = maxH;
  48252. frame.maxV = maxV;
  48253. prepareComponents(frame);
  48254. break;
  48255. case 0xFFC4:
  48256. var huffmanLength = readUint16();
  48257. for (i = 2; i < huffmanLength;) {
  48258. var huffmanTableSpec = data[offset++];
  48259. var codeLengths = new Uint8Array(16);
  48260. var codeLengthSum = 0;
  48261. for (j = 0; j < 16; j++, offset++) {
  48262. codeLengthSum += codeLengths[j] = data[offset];
  48263. }
  48264. var huffmanValues = new Uint8Array(codeLengthSum);
  48265. for (j = 0; j < codeLengthSum; j++, offset++) {
  48266. huffmanValues[j] = data[offset];
  48267. }
  48268. i += 17 + codeLengthSum;
  48269. (huffmanTableSpec >> 4 === 0 ? huffmanTablesDC : huffmanTablesAC)[huffmanTableSpec & 15] = buildHuffmanTable(codeLengths, huffmanValues);
  48270. }
  48271. break;
  48272. case 0xFFDD:
  48273. readUint16();
  48274. resetInterval = readUint16();
  48275. break;
  48276. case 0xFFDA:
  48277. readUint16();
  48278. var selectorsCount = data[offset++];
  48279. var components = [], component;
  48280. for (i = 0; i < selectorsCount; i++) {
  48281. var componentIndex = frame.componentIds[data[offset++]];
  48282. component = frame.components[componentIndex];
  48283. var tableSpec = data[offset++];
  48284. component.huffmanTableDC = huffmanTablesDC[tableSpec >> 4];
  48285. component.huffmanTableAC = huffmanTablesAC[tableSpec & 15];
  48286. components.push(component);
  48287. }
  48288. var spectralStart = data[offset++];
  48289. var spectralEnd = data[offset++];
  48290. var successiveApproximation = data[offset++];
  48291. var processed = decodeScan(data, offset, frame, components, resetInterval, spectralStart, spectralEnd, successiveApproximation >> 4, successiveApproximation & 15);
  48292. offset += processed;
  48293. break;
  48294. case 0xFFFF:
  48295. if (data[offset] !== 0xFF) {
  48296. offset--;
  48297. }
  48298. break;
  48299. default:
  48300. if (data[offset - 3] === 0xFF && data[offset - 2] >= 0xC0 && data[offset - 2] <= 0xFE) {
  48301. offset -= 3;
  48302. break;
  48303. }
  48304. error('JPEG error: unknown marker ' + fileMarker.toString(16));
  48305. }
  48306. fileMarker = readUint16();
  48307. }
  48308. this.width = frame.samplesPerLine;
  48309. this.height = frame.scanLines;
  48310. this.jfif = jfif;
  48311. this.adobe = adobe;
  48312. this.components = [];
  48313. for (i = 0; i < frame.components.length; i++) {
  48314. component = frame.components[i];
  48315. var quantizationTable = quantizationTables[component.quantizationId];
  48316. if (quantizationTable) {
  48317. component.quantizationTable = quantizationTable;
  48318. }
  48319. this.components.push({
  48320. output: buildComponentData(frame, component),
  48321. scaleX: component.h / frame.maxH,
  48322. scaleY: component.v / frame.maxV,
  48323. blocksPerLine: component.blocksPerLine,
  48324. blocksPerColumn: component.blocksPerColumn
  48325. });
  48326. }
  48327. this.numComponents = this.components.length;
  48328. },
  48329. _getLinearizedBlockData: function getLinearizedBlockData(width, height) {
  48330. var scaleX = this.width / width, scaleY = this.height / height;
  48331. var component, componentScaleX, componentScaleY, blocksPerScanline;
  48332. var x, y, i, j, k;
  48333. var index;
  48334. var offset = 0;
  48335. var output;
  48336. var numComponents = this.components.length;
  48337. var dataLength = width * height * numComponents;
  48338. var data = new Uint8Array(dataLength);
  48339. var xScaleBlockOffset = new Uint32Array(width);
  48340. var mask3LSB = 0xfffffff8;
  48341. for (i = 0; i < numComponents; i++) {
  48342. component = this.components[i];
  48343. componentScaleX = component.scaleX * scaleX;
  48344. componentScaleY = component.scaleY * scaleY;
  48345. offset = i;
  48346. output = component.output;
  48347. blocksPerScanline = component.blocksPerLine + 1 << 3;
  48348. for (x = 0; x < width; x++) {
  48349. j = 0 | x * componentScaleX;
  48350. xScaleBlockOffset[x] = (j & mask3LSB) << 3 | j & 7;
  48351. }
  48352. for (y = 0; y < height; y++) {
  48353. j = 0 | y * componentScaleY;
  48354. index = blocksPerScanline * (j & mask3LSB) | (j & 7) << 3;
  48355. for (x = 0; x < width; x++) {
  48356. data[offset] = output[index + xScaleBlockOffset[x]];
  48357. offset += numComponents;
  48358. }
  48359. }
  48360. }
  48361. var transform = this.decodeTransform;
  48362. if (transform) {
  48363. for (i = 0; i < dataLength;) {
  48364. for (j = 0, k = 0; j < numComponents; j++, i++, k += 2) {
  48365. data[i] = (data[i] * transform[k] >> 8) + transform[k + 1];
  48366. }
  48367. }
  48368. }
  48369. return data;
  48370. },
  48371. _isColorConversionNeeded: function isColorConversionNeeded() {
  48372. if (this.adobe && this.adobe.transformCode) {
  48373. return true;
  48374. } else if (this.numComponents === 3) {
  48375. if (!this.adobe && this.colorTransform === 0) {
  48376. return false;
  48377. }
  48378. return true;
  48379. }
  48380. if (!this.adobe && this.colorTransform === 1) {
  48381. return true;
  48382. }
  48383. return false;
  48384. },
  48385. _convertYccToRgb: function convertYccToRgb(data) {
  48386. var Y, Cb, Cr;
  48387. for (var i = 0, length = data.length; i < length; i += 3) {
  48388. Y = data[i];
  48389. Cb = data[i + 1];
  48390. Cr = data[i + 2];
  48391. data[i] = clamp0to255(Y - 179.456 + 1.402 * Cr);
  48392. data[i + 1] = clamp0to255(Y + 135.459 - 0.344 * Cb - 0.714 * Cr);
  48393. data[i + 2] = clamp0to255(Y - 226.816 + 1.772 * Cb);
  48394. }
  48395. return data;
  48396. },
  48397. _convertYcckToRgb: function convertYcckToRgb(data) {
  48398. var Y, Cb, Cr, k;
  48399. var offset = 0;
  48400. for (var i = 0, length = data.length; i < length; i += 4) {
  48401. Y = data[i];
  48402. Cb = data[i + 1];
  48403. Cr = data[i + 2];
  48404. k = data[i + 3];
  48405. 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);
  48406. 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);
  48407. 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);
  48408. data[offset++] = clamp0to255(r);
  48409. data[offset++] = clamp0to255(g);
  48410. data[offset++] = clamp0to255(b);
  48411. }
  48412. return data;
  48413. },
  48414. _convertYcckToCmyk: function convertYcckToCmyk(data) {
  48415. var Y, Cb, Cr;
  48416. for (var i = 0, length = data.length; i < length; i += 4) {
  48417. Y = data[i];
  48418. Cb = data[i + 1];
  48419. Cr = data[i + 2];
  48420. data[i] = clamp0to255(434.456 - Y - 1.402 * Cr);
  48421. data[i + 1] = clamp0to255(119.541 - Y + 0.344 * Cb + 0.714 * Cr);
  48422. data[i + 2] = clamp0to255(481.816 - Y - 1.772 * Cb);
  48423. }
  48424. return data;
  48425. },
  48426. _convertCmykToRgb: function convertCmykToRgb(data) {
  48427. var c, m, y, k;
  48428. var offset = 0;
  48429. var min = -255 * 255 * 255;
  48430. var scale = 1 / 255 / 255;
  48431. for (var i = 0, length = data.length; i < length; i += 4) {
  48432. c = data[i];
  48433. m = data[i + 1];
  48434. y = data[i + 2];
  48435. k = data[i + 3];
  48436. 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);
  48437. 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);
  48438. 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);
  48439. data[offset++] = r >= 0 ? 255 : r <= min ? 0 : 255 + r * scale | 0;
  48440. data[offset++] = g >= 0 ? 255 : g <= min ? 0 : 255 + g * scale | 0;
  48441. data[offset++] = b >= 0 ? 255 : b <= min ? 0 : 255 + b * scale | 0;
  48442. }
  48443. return data;
  48444. },
  48445. getData: function getData(width, height, forceRGBoutput) {
  48446. if (this.numComponents > 4) {
  48447. error('JPEG error: Unsupported color mode');
  48448. }
  48449. var data = this._getLinearizedBlockData(width, height);
  48450. if (this.numComponents === 1 && forceRGBoutput) {
  48451. var dataLength = data.length;
  48452. var rgbData = new Uint8Array(dataLength * 3);
  48453. var offset = 0;
  48454. for (var i = 0; i < dataLength; i++) {
  48455. var grayColor = data[i];
  48456. rgbData[offset++] = grayColor;
  48457. rgbData[offset++] = grayColor;
  48458. rgbData[offset++] = grayColor;
  48459. }
  48460. return rgbData;
  48461. } else if (this.numComponents === 3 && this._isColorConversionNeeded()) {
  48462. return this._convertYccToRgb(data);
  48463. } else if (this.numComponents === 4) {
  48464. if (this._isColorConversionNeeded()) {
  48465. if (forceRGBoutput) {
  48466. return this._convertYcckToRgb(data);
  48467. }
  48468. return this._convertYcckToCmyk(data);
  48469. } else if (forceRGBoutput) {
  48470. return this._convertCmykToRgb(data);
  48471. }
  48472. }
  48473. return data;
  48474. }
  48475. };
  48476. return JpegImage;
  48477. }();
  48478. exports.JpegImage = JpegImage;
  48479. /***/ }),
  48480. /* 37 */
  48481. /***/ (function(module, exports, __w_pdfjs_require__) {
  48482. "use strict";
  48483. var sharedUtil = __w_pdfjs_require__(0);
  48484. var getLookupTableFactory = sharedUtil.getLookupTableFactory;
  48485. var getMetrics = getLookupTableFactory(function (t) {
  48486. t['Courier'] = 600;
  48487. t['Courier-Bold'] = 600;
  48488. t['Courier-BoldOblique'] = 600;
  48489. t['Courier-Oblique'] = 600;
  48490. t['Helvetica'] = getLookupTableFactory(function (t) {
  48491. t['space'] = 278;
  48492. t['exclam'] = 278;
  48493. t['quotedbl'] = 355;
  48494. t['numbersign'] = 556;
  48495. t['dollar'] = 556;
  48496. t['percent'] = 889;
  48497. t['ampersand'] = 667;
  48498. t['quoteright'] = 222;
  48499. t['parenleft'] = 333;
  48500. t['parenright'] = 333;
  48501. t['asterisk'] = 389;
  48502. t['plus'] = 584;
  48503. t['comma'] = 278;
  48504. t['hyphen'] = 333;
  48505. t['period'] = 278;
  48506. t['slash'] = 278;
  48507. t['zero'] = 556;
  48508. t['one'] = 556;
  48509. t['two'] = 556;
  48510. t['three'] = 556;
  48511. t['four'] = 556;
  48512. t['five'] = 556;
  48513. t['six'] = 556;
  48514. t['seven'] = 556;
  48515. t['eight'] = 556;
  48516. t['nine'] = 556;
  48517. t['colon'] = 278;
  48518. t['semicolon'] = 278;
  48519. t['less'] = 584;
  48520. t['equal'] = 584;
  48521. t['greater'] = 584;
  48522. t['question'] = 556;
  48523. t['at'] = 1015;
  48524. t['A'] = 667;
  48525. t['B'] = 667;
  48526. t['C'] = 722;
  48527. t['D'] = 722;
  48528. t['E'] = 667;
  48529. t['F'] = 611;
  48530. t['G'] = 778;
  48531. t['H'] = 722;
  48532. t['I'] = 278;
  48533. t['J'] = 500;
  48534. t['K'] = 667;
  48535. t['L'] = 556;
  48536. t['M'] = 833;
  48537. t['N'] = 722;
  48538. t['O'] = 778;
  48539. t['P'] = 667;
  48540. t['Q'] = 778;
  48541. t['R'] = 722;
  48542. t['S'] = 667;
  48543. t['T'] = 611;
  48544. t['U'] = 722;
  48545. t['V'] = 667;
  48546. t['W'] = 944;
  48547. t['X'] = 667;
  48548. t['Y'] = 667;
  48549. t['Z'] = 611;
  48550. t['bracketleft'] = 278;
  48551. t['backslash'] = 278;
  48552. t['bracketright'] = 278;
  48553. t['asciicircum'] = 469;
  48554. t['underscore'] = 556;
  48555. t['quoteleft'] = 222;
  48556. t['a'] = 556;
  48557. t['b'] = 556;
  48558. t['c'] = 500;
  48559. t['d'] = 556;
  48560. t['e'] = 556;
  48561. t['f'] = 278;
  48562. t['g'] = 556;
  48563. t['h'] = 556;
  48564. t['i'] = 222;
  48565. t['j'] = 222;
  48566. t['k'] = 500;
  48567. t['l'] = 222;
  48568. t['m'] = 833;
  48569. t['n'] = 556;
  48570. t['o'] = 556;
  48571. t['p'] = 556;
  48572. t['q'] = 556;
  48573. t['r'] = 333;
  48574. t['s'] = 500;
  48575. t['t'] = 278;
  48576. t['u'] = 556;
  48577. t['v'] = 500;
  48578. t['w'] = 722;
  48579. t['x'] = 500;
  48580. t['y'] = 500;
  48581. t['z'] = 500;
  48582. t['braceleft'] = 334;
  48583. t['bar'] = 260;
  48584. t['braceright'] = 334;
  48585. t['asciitilde'] = 584;
  48586. t['exclamdown'] = 333;
  48587. t['cent'] = 556;
  48588. t['sterling'] = 556;
  48589. t['fraction'] = 167;
  48590. t['yen'] = 556;
  48591. t['florin'] = 556;
  48592. t['section'] = 556;
  48593. t['currency'] = 556;
  48594. t['quotesingle'] = 191;
  48595. t['quotedblleft'] = 333;
  48596. t['guillemotleft'] = 556;
  48597. t['guilsinglleft'] = 333;
  48598. t['guilsinglright'] = 333;
  48599. t['fi'] = 500;
  48600. t['fl'] = 500;
  48601. t['endash'] = 556;
  48602. t['dagger'] = 556;
  48603. t['daggerdbl'] = 556;
  48604. t['periodcentered'] = 278;
  48605. t['paragraph'] = 537;
  48606. t['bullet'] = 350;
  48607. t['quotesinglbase'] = 222;
  48608. t['quotedblbase'] = 333;
  48609. t['quotedblright'] = 333;
  48610. t['guillemotright'] = 556;
  48611. t['ellipsis'] = 1000;
  48612. t['perthousand'] = 1000;
  48613. t['questiondown'] = 611;
  48614. t['grave'] = 333;
  48615. t['acute'] = 333;
  48616. t['circumflex'] = 333;
  48617. t['tilde'] = 333;
  48618. t['macron'] = 333;
  48619. t['breve'] = 333;
  48620. t['dotaccent'] = 333;
  48621. t['dieresis'] = 333;
  48622. t['ring'] = 333;
  48623. t['cedilla'] = 333;
  48624. t['hungarumlaut'] = 333;
  48625. t['ogonek'] = 333;
  48626. t['caron'] = 333;
  48627. t['emdash'] = 1000;
  48628. t['AE'] = 1000;
  48629. t['ordfeminine'] = 370;
  48630. t['Lslash'] = 556;
  48631. t['Oslash'] = 778;
  48632. t['OE'] = 1000;
  48633. t['ordmasculine'] = 365;
  48634. t['ae'] = 889;
  48635. t['dotlessi'] = 278;
  48636. t['lslash'] = 222;
  48637. t['oslash'] = 611;
  48638. t['oe'] = 944;
  48639. t['germandbls'] = 611;
  48640. t['Idieresis'] = 278;
  48641. t['eacute'] = 556;
  48642. t['abreve'] = 556;
  48643. t['uhungarumlaut'] = 556;
  48644. t['ecaron'] = 556;
  48645. t['Ydieresis'] = 667;
  48646. t['divide'] = 584;
  48647. t['Yacute'] = 667;
  48648. t['Acircumflex'] = 667;
  48649. t['aacute'] = 556;
  48650. t['Ucircumflex'] = 722;
  48651. t['yacute'] = 500;
  48652. t['scommaaccent'] = 500;
  48653. t['ecircumflex'] = 556;
  48654. t['Uring'] = 722;
  48655. t['Udieresis'] = 722;
  48656. t['aogonek'] = 556;
  48657. t['Uacute'] = 722;
  48658. t['uogonek'] = 556;
  48659. t['Edieresis'] = 667;
  48660. t['Dcroat'] = 722;
  48661. t['commaaccent'] = 250;
  48662. t['copyright'] = 737;
  48663. t['Emacron'] = 667;
  48664. t['ccaron'] = 500;
  48665. t['aring'] = 556;
  48666. t['Ncommaaccent'] = 722;
  48667. t['lacute'] = 222;
  48668. t['agrave'] = 556;
  48669. t['Tcommaaccent'] = 611;
  48670. t['Cacute'] = 722;
  48671. t['atilde'] = 556;
  48672. t['Edotaccent'] = 667;
  48673. t['scaron'] = 500;
  48674. t['scedilla'] = 500;
  48675. t['iacute'] = 278;
  48676. t['lozenge'] = 471;
  48677. t['Rcaron'] = 722;
  48678. t['Gcommaaccent'] = 778;
  48679. t['ucircumflex'] = 556;
  48680. t['acircumflex'] = 556;
  48681. t['Amacron'] = 667;
  48682. t['rcaron'] = 333;
  48683. t['ccedilla'] = 500;
  48684. t['Zdotaccent'] = 611;
  48685. t['Thorn'] = 667;
  48686. t['Omacron'] = 778;
  48687. t['Racute'] = 722;
  48688. t['Sacute'] = 667;
  48689. t['dcaron'] = 643;
  48690. t['Umacron'] = 722;
  48691. t['uring'] = 556;
  48692. t['threesuperior'] = 333;
  48693. t['Ograve'] = 778;
  48694. t['Agrave'] = 667;
  48695. t['Abreve'] = 667;
  48696. t['multiply'] = 584;
  48697. t['uacute'] = 556;
  48698. t['Tcaron'] = 611;
  48699. t['partialdiff'] = 476;
  48700. t['ydieresis'] = 500;
  48701. t['Nacute'] = 722;
  48702. t['icircumflex'] = 278;
  48703. t['Ecircumflex'] = 667;
  48704. t['adieresis'] = 556;
  48705. t['edieresis'] = 556;
  48706. t['cacute'] = 500;
  48707. t['nacute'] = 556;
  48708. t['umacron'] = 556;
  48709. t['Ncaron'] = 722;
  48710. t['Iacute'] = 278;
  48711. t['plusminus'] = 584;
  48712. t['brokenbar'] = 260;
  48713. t['registered'] = 737;
  48714. t['Gbreve'] = 778;
  48715. t['Idotaccent'] = 278;
  48716. t['summation'] = 600;
  48717. t['Egrave'] = 667;
  48718. t['racute'] = 333;
  48719. t['omacron'] = 556;
  48720. t['Zacute'] = 611;
  48721. t['Zcaron'] = 611;
  48722. t['greaterequal'] = 549;
  48723. t['Eth'] = 722;
  48724. t['Ccedilla'] = 722;
  48725. t['lcommaaccent'] = 222;
  48726. t['tcaron'] = 317;
  48727. t['eogonek'] = 556;
  48728. t['Uogonek'] = 722;
  48729. t['Aacute'] = 667;
  48730. t['Adieresis'] = 667;
  48731. t['egrave'] = 556;
  48732. t['zacute'] = 500;
  48733. t['iogonek'] = 222;
  48734. t['Oacute'] = 778;
  48735. t['oacute'] = 556;
  48736. t['amacron'] = 556;
  48737. t['sacute'] = 500;
  48738. t['idieresis'] = 278;
  48739. t['Ocircumflex'] = 778;
  48740. t['Ugrave'] = 722;
  48741. t['Delta'] = 612;
  48742. t['thorn'] = 556;
  48743. t['twosuperior'] = 333;
  48744. t['Odieresis'] = 778;
  48745. t['mu'] = 556;
  48746. t['igrave'] = 278;
  48747. t['ohungarumlaut'] = 556;
  48748. t['Eogonek'] = 667;
  48749. t['dcroat'] = 556;
  48750. t['threequarters'] = 834;
  48751. t['Scedilla'] = 667;
  48752. t['lcaron'] = 299;
  48753. t['Kcommaaccent'] = 667;
  48754. t['Lacute'] = 556;
  48755. t['trademark'] = 1000;
  48756. t['edotaccent'] = 556;
  48757. t['Igrave'] = 278;
  48758. t['Imacron'] = 278;
  48759. t['Lcaron'] = 556;
  48760. t['onehalf'] = 834;
  48761. t['lessequal'] = 549;
  48762. t['ocircumflex'] = 556;
  48763. t['ntilde'] = 556;
  48764. t['Uhungarumlaut'] = 722;
  48765. t['Eacute'] = 667;
  48766. t['emacron'] = 556;
  48767. t['gbreve'] = 556;
  48768. t['onequarter'] = 834;
  48769. t['Scaron'] = 667;
  48770. t['Scommaaccent'] = 667;
  48771. t['Ohungarumlaut'] = 778;
  48772. t['degree'] = 400;
  48773. t['ograve'] = 556;
  48774. t['Ccaron'] = 722;
  48775. t['ugrave'] = 556;
  48776. t['radical'] = 453;
  48777. t['Dcaron'] = 722;
  48778. t['rcommaaccent'] = 333;
  48779. t['Ntilde'] = 722;
  48780. t['otilde'] = 556;
  48781. t['Rcommaaccent'] = 722;
  48782. t['Lcommaaccent'] = 556;
  48783. t['Atilde'] = 667;
  48784. t['Aogonek'] = 667;
  48785. t['Aring'] = 667;
  48786. t['Otilde'] = 778;
  48787. t['zdotaccent'] = 500;
  48788. t['Ecaron'] = 667;
  48789. t['Iogonek'] = 278;
  48790. t['kcommaaccent'] = 500;
  48791. t['minus'] = 584;
  48792. t['Icircumflex'] = 278;
  48793. t['ncaron'] = 556;
  48794. t['tcommaaccent'] = 278;
  48795. t['logicalnot'] = 584;
  48796. t['odieresis'] = 556;
  48797. t['udieresis'] = 556;
  48798. t['notequal'] = 549;
  48799. t['gcommaaccent'] = 556;
  48800. t['eth'] = 556;
  48801. t['zcaron'] = 500;
  48802. t['ncommaaccent'] = 556;
  48803. t['onesuperior'] = 333;
  48804. t['imacron'] = 278;
  48805. t['Euro'] = 556;
  48806. });
  48807. t['Helvetica-Bold'] = getLookupTableFactory(function (t) {
  48808. t['space'] = 278;
  48809. t['exclam'] = 333;
  48810. t['quotedbl'] = 474;
  48811. t['numbersign'] = 556;
  48812. t['dollar'] = 556;
  48813. t['percent'] = 889;
  48814. t['ampersand'] = 722;
  48815. t['quoteright'] = 278;
  48816. t['parenleft'] = 333;
  48817. t['parenright'] = 333;
  48818. t['asterisk'] = 389;
  48819. t['plus'] = 584;
  48820. t['comma'] = 278;
  48821. t['hyphen'] = 333;
  48822. t['period'] = 278;
  48823. t['slash'] = 278;
  48824. t['zero'] = 556;
  48825. t['one'] = 556;
  48826. t['two'] = 556;
  48827. t['three'] = 556;
  48828. t['four'] = 556;
  48829. t['five'] = 556;
  48830. t['six'] = 556;
  48831. t['seven'] = 556;
  48832. t['eight'] = 556;
  48833. t['nine'] = 556;
  48834. t['colon'] = 333;
  48835. t['semicolon'] = 333;
  48836. t['less'] = 584;
  48837. t['equal'] = 584;
  48838. t['greater'] = 584;
  48839. t['question'] = 611;
  48840. t['at'] = 975;
  48841. t['A'] = 722;
  48842. t['B'] = 722;
  48843. t['C'] = 722;
  48844. t['D'] = 722;
  48845. t['E'] = 667;
  48846. t['F'] = 611;
  48847. t['G'] = 778;
  48848. t['H'] = 722;
  48849. t['I'] = 278;
  48850. t['J'] = 556;
  48851. t['K'] = 722;
  48852. t['L'] = 611;
  48853. t['M'] = 833;
  48854. t['N'] = 722;
  48855. t['O'] = 778;
  48856. t['P'] = 667;
  48857. t['Q'] = 778;
  48858. t['R'] = 722;
  48859. t['S'] = 667;
  48860. t['T'] = 611;
  48861. t['U'] = 722;
  48862. t['V'] = 667;
  48863. t['W'] = 944;
  48864. t['X'] = 667;
  48865. t['Y'] = 667;
  48866. t['Z'] = 611;
  48867. t['bracketleft'] = 333;
  48868. t['backslash'] = 278;
  48869. t['bracketright'] = 333;
  48870. t['asciicircum'] = 584;
  48871. t['underscore'] = 556;
  48872. t['quoteleft'] = 278;
  48873. t['a'] = 556;
  48874. t['b'] = 611;
  48875. t['c'] = 556;
  48876. t['d'] = 611;
  48877. t['e'] = 556;
  48878. t['f'] = 333;
  48879. t['g'] = 611;
  48880. t['h'] = 611;
  48881. t['i'] = 278;
  48882. t['j'] = 278;
  48883. t['k'] = 556;
  48884. t['l'] = 278;
  48885. t['m'] = 889;
  48886. t['n'] = 611;
  48887. t['o'] = 611;
  48888. t['p'] = 611;
  48889. t['q'] = 611;
  48890. t['r'] = 389;
  48891. t['s'] = 556;
  48892. t['t'] = 333;
  48893. t['u'] = 611;
  48894. t['v'] = 556;
  48895. t['w'] = 778;
  48896. t['x'] = 556;
  48897. t['y'] = 556;
  48898. t['z'] = 500;
  48899. t['braceleft'] = 389;
  48900. t['bar'] = 280;
  48901. t['braceright'] = 389;
  48902. t['asciitilde'] = 584;
  48903. t['exclamdown'] = 333;
  48904. t['cent'] = 556;
  48905. t['sterling'] = 556;
  48906. t['fraction'] = 167;
  48907. t['yen'] = 556;
  48908. t['florin'] = 556;
  48909. t['section'] = 556;
  48910. t['currency'] = 556;
  48911. t['quotesingle'] = 238;
  48912. t['quotedblleft'] = 500;
  48913. t['guillemotleft'] = 556;
  48914. t['guilsinglleft'] = 333;
  48915. t['guilsinglright'] = 333;
  48916. t['fi'] = 611;
  48917. t['fl'] = 611;
  48918. t['endash'] = 556;
  48919. t['dagger'] = 556;
  48920. t['daggerdbl'] = 556;
  48921. t['periodcentered'] = 278;
  48922. t['paragraph'] = 556;
  48923. t['bullet'] = 350;
  48924. t['quotesinglbase'] = 278;
  48925. t['quotedblbase'] = 500;
  48926. t['quotedblright'] = 500;
  48927. t['guillemotright'] = 556;
  48928. t['ellipsis'] = 1000;
  48929. t['perthousand'] = 1000;
  48930. t['questiondown'] = 611;
  48931. t['grave'] = 333;
  48932. t['acute'] = 333;
  48933. t['circumflex'] = 333;
  48934. t['tilde'] = 333;
  48935. t['macron'] = 333;
  48936. t['breve'] = 333;
  48937. t['dotaccent'] = 333;
  48938. t['dieresis'] = 333;
  48939. t['ring'] = 333;
  48940. t['cedilla'] = 333;
  48941. t['hungarumlaut'] = 333;
  48942. t['ogonek'] = 333;
  48943. t['caron'] = 333;
  48944. t['emdash'] = 1000;
  48945. t['AE'] = 1000;
  48946. t['ordfeminine'] = 370;
  48947. t['Lslash'] = 611;
  48948. t['Oslash'] = 778;
  48949. t['OE'] = 1000;
  48950. t['ordmasculine'] = 365;
  48951. t['ae'] = 889;
  48952. t['dotlessi'] = 278;
  48953. t['lslash'] = 278;
  48954. t['oslash'] = 611;
  48955. t['oe'] = 944;
  48956. t['germandbls'] = 611;
  48957. t['Idieresis'] = 278;
  48958. t['eacute'] = 556;
  48959. t['abreve'] = 556;
  48960. t['uhungarumlaut'] = 611;
  48961. t['ecaron'] = 556;
  48962. t['Ydieresis'] = 667;
  48963. t['divide'] = 584;
  48964. t['Yacute'] = 667;
  48965. t['Acircumflex'] = 722;
  48966. t['aacute'] = 556;
  48967. t['Ucircumflex'] = 722;
  48968. t['yacute'] = 556;
  48969. t['scommaaccent'] = 556;
  48970. t['ecircumflex'] = 556;
  48971. t['Uring'] = 722;
  48972. t['Udieresis'] = 722;
  48973. t['aogonek'] = 556;
  48974. t['Uacute'] = 722;
  48975. t['uogonek'] = 611;
  48976. t['Edieresis'] = 667;
  48977. t['Dcroat'] = 722;
  48978. t['commaaccent'] = 250;
  48979. t['copyright'] = 737;
  48980. t['Emacron'] = 667;
  48981. t['ccaron'] = 556;
  48982. t['aring'] = 556;
  48983. t['Ncommaaccent'] = 722;
  48984. t['lacute'] = 278;
  48985. t['agrave'] = 556;
  48986. t['Tcommaaccent'] = 611;
  48987. t['Cacute'] = 722;
  48988. t['atilde'] = 556;
  48989. t['Edotaccent'] = 667;
  48990. t['scaron'] = 556;
  48991. t['scedilla'] = 556;
  48992. t['iacute'] = 278;
  48993. t['lozenge'] = 494;
  48994. t['Rcaron'] = 722;
  48995. t['Gcommaaccent'] = 778;
  48996. t['ucircumflex'] = 611;
  48997. t['acircumflex'] = 556;
  48998. t['Amacron'] = 722;
  48999. t['rcaron'] = 389;
  49000. t['ccedilla'] = 556;
  49001. t['Zdotaccent'] = 611;
  49002. t['Thorn'] = 667;
  49003. t['Omacron'] = 778;
  49004. t['Racute'] = 722;
  49005. t['Sacute'] = 667;
  49006. t['dcaron'] = 743;
  49007. t['Umacron'] = 722;
  49008. t['uring'] = 611;
  49009. t['threesuperior'] = 333;
  49010. t['Ograve'] = 778;
  49011. t['Agrave'] = 722;
  49012. t['Abreve'] = 722;
  49013. t['multiply'] = 584;
  49014. t['uacute'] = 611;
  49015. t['Tcaron'] = 611;
  49016. t['partialdiff'] = 494;
  49017. t['ydieresis'] = 556;
  49018. t['Nacute'] = 722;
  49019. t['icircumflex'] = 278;
  49020. t['Ecircumflex'] = 667;
  49021. t['adieresis'] = 556;
  49022. t['edieresis'] = 556;
  49023. t['cacute'] = 556;
  49024. t['nacute'] = 611;
  49025. t['umacron'] = 611;
  49026. t['Ncaron'] = 722;
  49027. t['Iacute'] = 278;
  49028. t['plusminus'] = 584;
  49029. t['brokenbar'] = 280;
  49030. t['registered'] = 737;
  49031. t['Gbreve'] = 778;
  49032. t['Idotaccent'] = 278;
  49033. t['summation'] = 600;
  49034. t['Egrave'] = 667;
  49035. t['racute'] = 389;
  49036. t['omacron'] = 611;
  49037. t['Zacute'] = 611;
  49038. t['Zcaron'] = 611;
  49039. t['greaterequal'] = 549;
  49040. t['Eth'] = 722;
  49041. t['Ccedilla'] = 722;
  49042. t['lcommaaccent'] = 278;
  49043. t['tcaron'] = 389;
  49044. t['eogonek'] = 556;
  49045. t['Uogonek'] = 722;
  49046. t['Aacute'] = 722;
  49047. t['Adieresis'] = 722;
  49048. t['egrave'] = 556;
  49049. t['zacute'] = 500;
  49050. t['iogonek'] = 278;
  49051. t['Oacute'] = 778;
  49052. t['oacute'] = 611;
  49053. t['amacron'] = 556;
  49054. t['sacute'] = 556;
  49055. t['idieresis'] = 278;
  49056. t['Ocircumflex'] = 778;
  49057. t['Ugrave'] = 722;
  49058. t['Delta'] = 612;
  49059. t['thorn'] = 611;
  49060. t['twosuperior'] = 333;
  49061. t['Odieresis'] = 778;
  49062. t['mu'] = 611;
  49063. t['igrave'] = 278;
  49064. t['ohungarumlaut'] = 611;
  49065. t['Eogonek'] = 667;
  49066. t['dcroat'] = 611;
  49067. t['threequarters'] = 834;
  49068. t['Scedilla'] = 667;
  49069. t['lcaron'] = 400;
  49070. t['Kcommaaccent'] = 722;
  49071. t['Lacute'] = 611;
  49072. t['trademark'] = 1000;
  49073. t['edotaccent'] = 556;
  49074. t['Igrave'] = 278;
  49075. t['Imacron'] = 278;
  49076. t['Lcaron'] = 611;
  49077. t['onehalf'] = 834;
  49078. t['lessequal'] = 549;
  49079. t['ocircumflex'] = 611;
  49080. t['ntilde'] = 611;
  49081. t['Uhungarumlaut'] = 722;
  49082. t['Eacute'] = 667;
  49083. t['emacron'] = 556;
  49084. t['gbreve'] = 611;
  49085. t['onequarter'] = 834;
  49086. t['Scaron'] = 667;
  49087. t['Scommaaccent'] = 667;
  49088. t['Ohungarumlaut'] = 778;
  49089. t['degree'] = 400;
  49090. t['ograve'] = 611;
  49091. t['Ccaron'] = 722;
  49092. t['ugrave'] = 611;
  49093. t['radical'] = 549;
  49094. t['Dcaron'] = 722;
  49095. t['rcommaaccent'] = 389;
  49096. t['Ntilde'] = 722;
  49097. t['otilde'] = 611;
  49098. t['Rcommaaccent'] = 722;
  49099. t['Lcommaaccent'] = 611;
  49100. t['Atilde'] = 722;
  49101. t['Aogonek'] = 722;
  49102. t['Aring'] = 722;
  49103. t['Otilde'] = 778;
  49104. t['zdotaccent'] = 500;
  49105. t['Ecaron'] = 667;
  49106. t['Iogonek'] = 278;
  49107. t['kcommaaccent'] = 556;
  49108. t['minus'] = 584;
  49109. t['Icircumflex'] = 278;
  49110. t['ncaron'] = 611;
  49111. t['tcommaaccent'] = 333;
  49112. t['logicalnot'] = 584;
  49113. t['odieresis'] = 611;
  49114. t['udieresis'] = 611;
  49115. t['notequal'] = 549;
  49116. t['gcommaaccent'] = 611;
  49117. t['eth'] = 611;
  49118. t['zcaron'] = 500;
  49119. t['ncommaaccent'] = 611;
  49120. t['onesuperior'] = 333;
  49121. t['imacron'] = 278;
  49122. t['Euro'] = 556;
  49123. });
  49124. t['Helvetica-BoldOblique'] = getLookupTableFactory(function (t) {
  49125. t['space'] = 278;
  49126. t['exclam'] = 333;
  49127. t['quotedbl'] = 474;
  49128. t['numbersign'] = 556;
  49129. t['dollar'] = 556;
  49130. t['percent'] = 889;
  49131. t['ampersand'] = 722;
  49132. t['quoteright'] = 278;
  49133. t['parenleft'] = 333;
  49134. t['parenright'] = 333;
  49135. t['asterisk'] = 389;
  49136. t['plus'] = 584;
  49137. t['comma'] = 278;
  49138. t['hyphen'] = 333;
  49139. t['period'] = 278;
  49140. t['slash'] = 278;
  49141. t['zero'] = 556;
  49142. t['one'] = 556;
  49143. t['two'] = 556;
  49144. t['three'] = 556;
  49145. t['four'] = 556;
  49146. t['five'] = 556;
  49147. t['six'] = 556;
  49148. t['seven'] = 556;
  49149. t['eight'] = 556;
  49150. t['nine'] = 556;
  49151. t['colon'] = 333;
  49152. t['semicolon'] = 333;
  49153. t['less'] = 584;
  49154. t['equal'] = 584;
  49155. t['greater'] = 584;
  49156. t['question'] = 611;
  49157. t['at'] = 975;
  49158. t['A'] = 722;
  49159. t['B'] = 722;
  49160. t['C'] = 722;
  49161. t['D'] = 722;
  49162. t['E'] = 667;
  49163. t['F'] = 611;
  49164. t['G'] = 778;
  49165. t['H'] = 722;
  49166. t['I'] = 278;
  49167. t['J'] = 556;
  49168. t['K'] = 722;
  49169. t['L'] = 611;
  49170. t['M'] = 833;
  49171. t['N'] = 722;
  49172. t['O'] = 778;
  49173. t['P'] = 667;
  49174. t['Q'] = 778;
  49175. t['R'] = 722;
  49176. t['S'] = 667;
  49177. t['T'] = 611;
  49178. t['U'] = 722;
  49179. t['V'] = 667;
  49180. t['W'] = 944;
  49181. t['X'] = 667;
  49182. t['Y'] = 667;
  49183. t['Z'] = 611;
  49184. t['bracketleft'] = 333;
  49185. t['backslash'] = 278;
  49186. t['bracketright'] = 333;
  49187. t['asciicircum'] = 584;
  49188. t['underscore'] = 556;
  49189. t['quoteleft'] = 278;
  49190. t['a'] = 556;
  49191. t['b'] = 611;
  49192. t['c'] = 556;
  49193. t['d'] = 611;
  49194. t['e'] = 556;
  49195. t['f'] = 333;
  49196. t['g'] = 611;
  49197. t['h'] = 611;
  49198. t['i'] = 278;
  49199. t['j'] = 278;
  49200. t['k'] = 556;
  49201. t['l'] = 278;
  49202. t['m'] = 889;
  49203. t['n'] = 611;
  49204. t['o'] = 611;
  49205. t['p'] = 611;
  49206. t['q'] = 611;
  49207. t['r'] = 389;
  49208. t['s'] = 556;
  49209. t['t'] = 333;
  49210. t['u'] = 611;
  49211. t['v'] = 556;
  49212. t['w'] = 778;
  49213. t['x'] = 556;
  49214. t['y'] = 556;
  49215. t['z'] = 500;
  49216. t['braceleft'] = 389;
  49217. t['bar'] = 280;
  49218. t['braceright'] = 389;
  49219. t['asciitilde'] = 584;
  49220. t['exclamdown'] = 333;
  49221. t['cent'] = 556;
  49222. t['sterling'] = 556;
  49223. t['fraction'] = 167;
  49224. t['yen'] = 556;
  49225. t['florin'] = 556;
  49226. t['section'] = 556;
  49227. t['currency'] = 556;
  49228. t['quotesingle'] = 238;
  49229. t['quotedblleft'] = 500;
  49230. t['guillemotleft'] = 556;
  49231. t['guilsinglleft'] = 333;
  49232. t['guilsinglright'] = 333;
  49233. t['fi'] = 611;
  49234. t['fl'] = 611;
  49235. t['endash'] = 556;
  49236. t['dagger'] = 556;
  49237. t['daggerdbl'] = 556;
  49238. t['periodcentered'] = 278;
  49239. t['paragraph'] = 556;
  49240. t['bullet'] = 350;
  49241. t['quotesinglbase'] = 278;
  49242. t['quotedblbase'] = 500;
  49243. t['quotedblright'] = 500;
  49244. t['guillemotright'] = 556;
  49245. t['ellipsis'] = 1000;
  49246. t['perthousand'] = 1000;
  49247. t['questiondown'] = 611;
  49248. t['grave'] = 333;
  49249. t['acute'] = 333;
  49250. t['circumflex'] = 333;
  49251. t['tilde'] = 333;
  49252. t['macron'] = 333;
  49253. t['breve'] = 333;
  49254. t['dotaccent'] = 333;
  49255. t['dieresis'] = 333;
  49256. t['ring'] = 333;
  49257. t['cedilla'] = 333;
  49258. t['hungarumlaut'] = 333;
  49259. t['ogonek'] = 333;
  49260. t['caron'] = 333;
  49261. t['emdash'] = 1000;
  49262. t['AE'] = 1000;
  49263. t['ordfeminine'] = 370;
  49264. t['Lslash'] = 611;
  49265. t['Oslash'] = 778;
  49266. t['OE'] = 1000;
  49267. t['ordmasculine'] = 365;
  49268. t['ae'] = 889;
  49269. t['dotlessi'] = 278;
  49270. t['lslash'] = 278;
  49271. t['oslash'] = 611;
  49272. t['oe'] = 944;
  49273. t['germandbls'] = 611;
  49274. t['Idieresis'] = 278;
  49275. t['eacute'] = 556;
  49276. t['abreve'] = 556;
  49277. t['uhungarumlaut'] = 611;
  49278. t['ecaron'] = 556;
  49279. t['Ydieresis'] = 667;
  49280. t['divide'] = 584;
  49281. t['Yacute'] = 667;
  49282. t['Acircumflex'] = 722;
  49283. t['aacute'] = 556;
  49284. t['Ucircumflex'] = 722;
  49285. t['yacute'] = 556;
  49286. t['scommaaccent'] = 556;
  49287. t['ecircumflex'] = 556;
  49288. t['Uring'] = 722;
  49289. t['Udieresis'] = 722;
  49290. t['aogonek'] = 556;
  49291. t['Uacute'] = 722;
  49292. t['uogonek'] = 611;
  49293. t['Edieresis'] = 667;
  49294. t['Dcroat'] = 722;
  49295. t['commaaccent'] = 250;
  49296. t['copyright'] = 737;
  49297. t['Emacron'] = 667;
  49298. t['ccaron'] = 556;
  49299. t['aring'] = 556;
  49300. t['Ncommaaccent'] = 722;
  49301. t['lacute'] = 278;
  49302. t['agrave'] = 556;
  49303. t['Tcommaaccent'] = 611;
  49304. t['Cacute'] = 722;
  49305. t['atilde'] = 556;
  49306. t['Edotaccent'] = 667;
  49307. t['scaron'] = 556;
  49308. t['scedilla'] = 556;
  49309. t['iacute'] = 278;
  49310. t['lozenge'] = 494;
  49311. t['Rcaron'] = 722;
  49312. t['Gcommaaccent'] = 778;
  49313. t['ucircumflex'] = 611;
  49314. t['acircumflex'] = 556;
  49315. t['Amacron'] = 722;
  49316. t['rcaron'] = 389;
  49317. t['ccedilla'] = 556;
  49318. t['Zdotaccent'] = 611;
  49319. t['Thorn'] = 667;
  49320. t['Omacron'] = 778;
  49321. t['Racute'] = 722;
  49322. t['Sacute'] = 667;
  49323. t['dcaron'] = 743;
  49324. t['Umacron'] = 722;
  49325. t['uring'] = 611;
  49326. t['threesuperior'] = 333;
  49327. t['Ograve'] = 778;
  49328. t['Agrave'] = 722;
  49329. t['Abreve'] = 722;
  49330. t['multiply'] = 584;
  49331. t['uacute'] = 611;
  49332. t['Tcaron'] = 611;
  49333. t['partialdiff'] = 494;
  49334. t['ydieresis'] = 556;
  49335. t['Nacute'] = 722;
  49336. t['icircumflex'] = 278;
  49337. t['Ecircumflex'] = 667;
  49338. t['adieresis'] = 556;
  49339. t['edieresis'] = 556;
  49340. t['cacute'] = 556;
  49341. t['nacute'] = 611;
  49342. t['umacron'] = 611;
  49343. t['Ncaron'] = 722;
  49344. t['Iacute'] = 278;
  49345. t['plusminus'] = 584;
  49346. t['brokenbar'] = 280;
  49347. t['registered'] = 737;
  49348. t['Gbreve'] = 778;
  49349. t['Idotaccent'] = 278;
  49350. t['summation'] = 600;
  49351. t['Egrave'] = 667;
  49352. t['racute'] = 389;
  49353. t['omacron'] = 611;
  49354. t['Zacute'] = 611;
  49355. t['Zcaron'] = 611;
  49356. t['greaterequal'] = 549;
  49357. t['Eth'] = 722;
  49358. t['Ccedilla'] = 722;
  49359. t['lcommaaccent'] = 278;
  49360. t['tcaron'] = 389;
  49361. t['eogonek'] = 556;
  49362. t['Uogonek'] = 722;
  49363. t['Aacute'] = 722;
  49364. t['Adieresis'] = 722;
  49365. t['egrave'] = 556;
  49366. t['zacute'] = 500;
  49367. t['iogonek'] = 278;
  49368. t['Oacute'] = 778;
  49369. t['oacute'] = 611;
  49370. t['amacron'] = 556;
  49371. t['sacute'] = 556;
  49372. t['idieresis'] = 278;
  49373. t['Ocircumflex'] = 778;
  49374. t['Ugrave'] = 722;
  49375. t['Delta'] = 612;
  49376. t['thorn'] = 611;
  49377. t['twosuperior'] = 333;
  49378. t['Odieresis'] = 778;
  49379. t['mu'] = 611;
  49380. t['igrave'] = 278;
  49381. t['ohungarumlaut'] = 611;
  49382. t['Eogonek'] = 667;
  49383. t['dcroat'] = 611;
  49384. t['threequarters'] = 834;
  49385. t['Scedilla'] = 667;
  49386. t['lcaron'] = 400;
  49387. t['Kcommaaccent'] = 722;
  49388. t['Lacute'] = 611;
  49389. t['trademark'] = 1000;
  49390. t['edotaccent'] = 556;
  49391. t['Igrave'] = 278;
  49392. t['Imacron'] = 278;
  49393. t['Lcaron'] = 611;
  49394. t['onehalf'] = 834;
  49395. t['lessequal'] = 549;
  49396. t['ocircumflex'] = 611;
  49397. t['ntilde'] = 611;
  49398. t['Uhungarumlaut'] = 722;
  49399. t['Eacute'] = 667;
  49400. t['emacron'] = 556;
  49401. t['gbreve'] = 611;
  49402. t['onequarter'] = 834;
  49403. t['Scaron'] = 667;
  49404. t['Scommaaccent'] = 667;
  49405. t['Ohungarumlaut'] = 778;
  49406. t['degree'] = 400;
  49407. t['ograve'] = 611;
  49408. t['Ccaron'] = 722;
  49409. t['ugrave'] = 611;
  49410. t['radical'] = 549;
  49411. t['Dcaron'] = 722;
  49412. t['rcommaaccent'] = 389;
  49413. t['Ntilde'] = 722;
  49414. t['otilde'] = 611;
  49415. t['Rcommaaccent'] = 722;
  49416. t['Lcommaaccent'] = 611;
  49417. t['Atilde'] = 722;
  49418. t['Aogonek'] = 722;
  49419. t['Aring'] = 722;
  49420. t['Otilde'] = 778;
  49421. t['zdotaccent'] = 500;
  49422. t['Ecaron'] = 667;
  49423. t['Iogonek'] = 278;
  49424. t['kcommaaccent'] = 556;
  49425. t['minus'] = 584;
  49426. t['Icircumflex'] = 278;
  49427. t['ncaron'] = 611;
  49428. t['tcommaaccent'] = 333;
  49429. t['logicalnot'] = 584;
  49430. t['odieresis'] = 611;
  49431. t['udieresis'] = 611;
  49432. t['notequal'] = 549;
  49433. t['gcommaaccent'] = 611;
  49434. t['eth'] = 611;
  49435. t['zcaron'] = 500;
  49436. t['ncommaaccent'] = 611;
  49437. t['onesuperior'] = 333;
  49438. t['imacron'] = 278;
  49439. t['Euro'] = 556;
  49440. });
  49441. t['Helvetica-Oblique'] = getLookupTableFactory(function (t) {
  49442. t['space'] = 278;
  49443. t['exclam'] = 278;
  49444. t['quotedbl'] = 355;
  49445. t['numbersign'] = 556;
  49446. t['dollar'] = 556;
  49447. t['percent'] = 889;
  49448. t['ampersand'] = 667;
  49449. t['quoteright'] = 222;
  49450. t['parenleft'] = 333;
  49451. t['parenright'] = 333;
  49452. t['asterisk'] = 389;
  49453. t['plus'] = 584;
  49454. t['comma'] = 278;
  49455. t['hyphen'] = 333;
  49456. t['period'] = 278;
  49457. t['slash'] = 278;
  49458. t['zero'] = 556;
  49459. t['one'] = 556;
  49460. t['two'] = 556;
  49461. t['three'] = 556;
  49462. t['four'] = 556;
  49463. t['five'] = 556;
  49464. t['six'] = 556;
  49465. t['seven'] = 556;
  49466. t['eight'] = 556;
  49467. t['nine'] = 556;
  49468. t['colon'] = 278;
  49469. t['semicolon'] = 278;
  49470. t['less'] = 584;
  49471. t['equal'] = 584;
  49472. t['greater'] = 584;
  49473. t['question'] = 556;
  49474. t['at'] = 1015;
  49475. t['A'] = 667;
  49476. t['B'] = 667;
  49477. t['C'] = 722;
  49478. t['D'] = 722;
  49479. t['E'] = 667;
  49480. t['F'] = 611;
  49481. t['G'] = 778;
  49482. t['H'] = 722;
  49483. t['I'] = 278;
  49484. t['J'] = 500;
  49485. t['K'] = 667;
  49486. t['L'] = 556;
  49487. t['M'] = 833;
  49488. t['N'] = 722;
  49489. t['O'] = 778;
  49490. t['P'] = 667;
  49491. t['Q'] = 778;
  49492. t['R'] = 722;
  49493. t['S'] = 667;
  49494. t['T'] = 611;
  49495. t['U'] = 722;
  49496. t['V'] = 667;
  49497. t['W'] = 944;
  49498. t['X'] = 667;
  49499. t['Y'] = 667;
  49500. t['Z'] = 611;
  49501. t['bracketleft'] = 278;
  49502. t['backslash'] = 278;
  49503. t['bracketright'] = 278;
  49504. t['asciicircum'] = 469;
  49505. t['underscore'] = 556;
  49506. t['quoteleft'] = 222;
  49507. t['a'] = 556;
  49508. t['b'] = 556;
  49509. t['c'] = 500;
  49510. t['d'] = 556;
  49511. t['e'] = 556;
  49512. t['f'] = 278;
  49513. t['g'] = 556;
  49514. t['h'] = 556;
  49515. t['i'] = 222;
  49516. t['j'] = 222;
  49517. t['k'] = 500;
  49518. t['l'] = 222;
  49519. t['m'] = 833;
  49520. t['n'] = 556;
  49521. t['o'] = 556;
  49522. t['p'] = 556;
  49523. t['q'] = 556;
  49524. t['r'] = 333;
  49525. t['s'] = 500;
  49526. t['t'] = 278;
  49527. t['u'] = 556;
  49528. t['v'] = 500;
  49529. t['w'] = 722;
  49530. t['x'] = 500;
  49531. t['y'] = 500;
  49532. t['z'] = 500;
  49533. t['braceleft'] = 334;
  49534. t['bar'] = 260;
  49535. t['braceright'] = 334;
  49536. t['asciitilde'] = 584;
  49537. t['exclamdown'] = 333;
  49538. t['cent'] = 556;
  49539. t['sterling'] = 556;
  49540. t['fraction'] = 167;
  49541. t['yen'] = 556;
  49542. t['florin'] = 556;
  49543. t['section'] = 556;
  49544. t['currency'] = 556;
  49545. t['quotesingle'] = 191;
  49546. t['quotedblleft'] = 333;
  49547. t['guillemotleft'] = 556;
  49548. t['guilsinglleft'] = 333;
  49549. t['guilsinglright'] = 333;
  49550. t['fi'] = 500;
  49551. t['fl'] = 500;
  49552. t['endash'] = 556;
  49553. t['dagger'] = 556;
  49554. t['daggerdbl'] = 556;
  49555. t['periodcentered'] = 278;
  49556. t['paragraph'] = 537;
  49557. t['bullet'] = 350;
  49558. t['quotesinglbase'] = 222;
  49559. t['quotedblbase'] = 333;
  49560. t['quotedblright'] = 333;
  49561. t['guillemotright'] = 556;
  49562. t['ellipsis'] = 1000;
  49563. t['perthousand'] = 1000;
  49564. t['questiondown'] = 611;
  49565. t['grave'] = 333;
  49566. t['acute'] = 333;
  49567. t['circumflex'] = 333;
  49568. t['tilde'] = 333;
  49569. t['macron'] = 333;
  49570. t['breve'] = 333;
  49571. t['dotaccent'] = 333;
  49572. t['dieresis'] = 333;
  49573. t['ring'] = 333;
  49574. t['cedilla'] = 333;
  49575. t['hungarumlaut'] = 333;
  49576. t['ogonek'] = 333;
  49577. t['caron'] = 333;
  49578. t['emdash'] = 1000;
  49579. t['AE'] = 1000;
  49580. t['ordfeminine'] = 370;
  49581. t['Lslash'] = 556;
  49582. t['Oslash'] = 778;
  49583. t['OE'] = 1000;
  49584. t['ordmasculine'] = 365;
  49585. t['ae'] = 889;
  49586. t['dotlessi'] = 278;
  49587. t['lslash'] = 222;
  49588. t['oslash'] = 611;
  49589. t['oe'] = 944;
  49590. t['germandbls'] = 611;
  49591. t['Idieresis'] = 278;
  49592. t['eacute'] = 556;
  49593. t['abreve'] = 556;
  49594. t['uhungarumlaut'] = 556;
  49595. t['ecaron'] = 556;
  49596. t['Ydieresis'] = 667;
  49597. t['divide'] = 584;
  49598. t['Yacute'] = 667;
  49599. t['Acircumflex'] = 667;
  49600. t['aacute'] = 556;
  49601. t['Ucircumflex'] = 722;
  49602. t['yacute'] = 500;
  49603. t['scommaaccent'] = 500;
  49604. t['ecircumflex'] = 556;
  49605. t['Uring'] = 722;
  49606. t['Udieresis'] = 722;
  49607. t['aogonek'] = 556;
  49608. t['Uacute'] = 722;
  49609. t['uogonek'] = 556;
  49610. t['Edieresis'] = 667;
  49611. t['Dcroat'] = 722;
  49612. t['commaaccent'] = 250;
  49613. t['copyright'] = 737;
  49614. t['Emacron'] = 667;
  49615. t['ccaron'] = 500;
  49616. t['aring'] = 556;
  49617. t['Ncommaaccent'] = 722;
  49618. t['lacute'] = 222;
  49619. t['agrave'] = 556;
  49620. t['Tcommaaccent'] = 611;
  49621. t['Cacute'] = 722;
  49622. t['atilde'] = 556;
  49623. t['Edotaccent'] = 667;
  49624. t['scaron'] = 500;
  49625. t['scedilla'] = 500;
  49626. t['iacute'] = 278;
  49627. t['lozenge'] = 471;
  49628. t['Rcaron'] = 722;
  49629. t['Gcommaaccent'] = 778;
  49630. t['ucircumflex'] = 556;
  49631. t['acircumflex'] = 556;
  49632. t['Amacron'] = 667;
  49633. t['rcaron'] = 333;
  49634. t['ccedilla'] = 500;
  49635. t['Zdotaccent'] = 611;
  49636. t['Thorn'] = 667;
  49637. t['Omacron'] = 778;
  49638. t['Racute'] = 722;
  49639. t['Sacute'] = 667;
  49640. t['dcaron'] = 643;
  49641. t['Umacron'] = 722;
  49642. t['uring'] = 556;
  49643. t['threesuperior'] = 333;
  49644. t['Ograve'] = 778;
  49645. t['Agrave'] = 667;
  49646. t['Abreve'] = 667;
  49647. t['multiply'] = 584;
  49648. t['uacute'] = 556;
  49649. t['Tcaron'] = 611;
  49650. t['partialdiff'] = 476;
  49651. t['ydieresis'] = 500;
  49652. t['Nacute'] = 722;
  49653. t['icircumflex'] = 278;
  49654. t['Ecircumflex'] = 667;
  49655. t['adieresis'] = 556;
  49656. t['edieresis'] = 556;
  49657. t['cacute'] = 500;
  49658. t['nacute'] = 556;
  49659. t['umacron'] = 556;
  49660. t['Ncaron'] = 722;
  49661. t['Iacute'] = 278;
  49662. t['plusminus'] = 584;
  49663. t['brokenbar'] = 260;
  49664. t['registered'] = 737;
  49665. t['Gbreve'] = 778;
  49666. t['Idotaccent'] = 278;
  49667. t['summation'] = 600;
  49668. t['Egrave'] = 667;
  49669. t['racute'] = 333;
  49670. t['omacron'] = 556;
  49671. t['Zacute'] = 611;
  49672. t['Zcaron'] = 611;
  49673. t['greaterequal'] = 549;
  49674. t['Eth'] = 722;
  49675. t['Ccedilla'] = 722;
  49676. t['lcommaaccent'] = 222;
  49677. t['tcaron'] = 317;
  49678. t['eogonek'] = 556;
  49679. t['Uogonek'] = 722;
  49680. t['Aacute'] = 667;
  49681. t['Adieresis'] = 667;
  49682. t['egrave'] = 556;
  49683. t['zacute'] = 500;
  49684. t['iogonek'] = 222;
  49685. t['Oacute'] = 778;
  49686. t['oacute'] = 556;
  49687. t['amacron'] = 556;
  49688. t['sacute'] = 500;
  49689. t['idieresis'] = 278;
  49690. t['Ocircumflex'] = 778;
  49691. t['Ugrave'] = 722;
  49692. t['Delta'] = 612;
  49693. t['thorn'] = 556;
  49694. t['twosuperior'] = 333;
  49695. t['Odieresis'] = 778;
  49696. t['mu'] = 556;
  49697. t['igrave'] = 278;
  49698. t['ohungarumlaut'] = 556;
  49699. t['Eogonek'] = 667;
  49700. t['dcroat'] = 556;
  49701. t['threequarters'] = 834;
  49702. t['Scedilla'] = 667;
  49703. t['lcaron'] = 299;
  49704. t['Kcommaaccent'] = 667;
  49705. t['Lacute'] = 556;
  49706. t['trademark'] = 1000;
  49707. t['edotaccent'] = 556;
  49708. t['Igrave'] = 278;
  49709. t['Imacron'] = 278;
  49710. t['Lcaron'] = 556;
  49711. t['onehalf'] = 834;
  49712. t['lessequal'] = 549;
  49713. t['ocircumflex'] = 556;
  49714. t['ntilde'] = 556;
  49715. t['Uhungarumlaut'] = 722;
  49716. t['Eacute'] = 667;
  49717. t['emacron'] = 556;
  49718. t['gbreve'] = 556;
  49719. t['onequarter'] = 834;
  49720. t['Scaron'] = 667;
  49721. t['Scommaaccent'] = 667;
  49722. t['Ohungarumlaut'] = 778;
  49723. t['degree'] = 400;
  49724. t['ograve'] = 556;
  49725. t['Ccaron'] = 722;
  49726. t['ugrave'] = 556;
  49727. t['radical'] = 453;
  49728. t['Dcaron'] = 722;
  49729. t['rcommaaccent'] = 333;
  49730. t['Ntilde'] = 722;
  49731. t['otilde'] = 556;
  49732. t['Rcommaaccent'] = 722;
  49733. t['Lcommaaccent'] = 556;
  49734. t['Atilde'] = 667;
  49735. t['Aogonek'] = 667;
  49736. t['Aring'] = 667;
  49737. t['Otilde'] = 778;
  49738. t['zdotaccent'] = 500;
  49739. t['Ecaron'] = 667;
  49740. t['Iogonek'] = 278;
  49741. t['kcommaaccent'] = 500;
  49742. t['minus'] = 584;
  49743. t['Icircumflex'] = 278;
  49744. t['ncaron'] = 556;
  49745. t['tcommaaccent'] = 278;
  49746. t['logicalnot'] = 584;
  49747. t['odieresis'] = 556;
  49748. t['udieresis'] = 556;
  49749. t['notequal'] = 549;
  49750. t['gcommaaccent'] = 556;
  49751. t['eth'] = 556;
  49752. t['zcaron'] = 500;
  49753. t['ncommaaccent'] = 556;
  49754. t['onesuperior'] = 333;
  49755. t['imacron'] = 278;
  49756. t['Euro'] = 556;
  49757. });
  49758. t['Symbol'] = getLookupTableFactory(function (t) {
  49759. t['space'] = 250;
  49760. t['exclam'] = 333;
  49761. t['universal'] = 713;
  49762. t['numbersign'] = 500;
  49763. t['existential'] = 549;
  49764. t['percent'] = 833;
  49765. t['ampersand'] = 778;
  49766. t['suchthat'] = 439;
  49767. t['parenleft'] = 333;
  49768. t['parenright'] = 333;
  49769. t['asteriskmath'] = 500;
  49770. t['plus'] = 549;
  49771. t['comma'] = 250;
  49772. t['minus'] = 549;
  49773. t['period'] = 250;
  49774. t['slash'] = 278;
  49775. t['zero'] = 500;
  49776. t['one'] = 500;
  49777. t['two'] = 500;
  49778. t['three'] = 500;
  49779. t['four'] = 500;
  49780. t['five'] = 500;
  49781. t['six'] = 500;
  49782. t['seven'] = 500;
  49783. t['eight'] = 500;
  49784. t['nine'] = 500;
  49785. t['colon'] = 278;
  49786. t['semicolon'] = 278;
  49787. t['less'] = 549;
  49788. t['equal'] = 549;
  49789. t['greater'] = 549;
  49790. t['question'] = 444;
  49791. t['congruent'] = 549;
  49792. t['Alpha'] = 722;
  49793. t['Beta'] = 667;
  49794. t['Chi'] = 722;
  49795. t['Delta'] = 612;
  49796. t['Epsilon'] = 611;
  49797. t['Phi'] = 763;
  49798. t['Gamma'] = 603;
  49799. t['Eta'] = 722;
  49800. t['Iota'] = 333;
  49801. t['theta1'] = 631;
  49802. t['Kappa'] = 722;
  49803. t['Lambda'] = 686;
  49804. t['Mu'] = 889;
  49805. t['Nu'] = 722;
  49806. t['Omicron'] = 722;
  49807. t['Pi'] = 768;
  49808. t['Theta'] = 741;
  49809. t['Rho'] = 556;
  49810. t['Sigma'] = 592;
  49811. t['Tau'] = 611;
  49812. t['Upsilon'] = 690;
  49813. t['sigma1'] = 439;
  49814. t['Omega'] = 768;
  49815. t['Xi'] = 645;
  49816. t['Psi'] = 795;
  49817. t['Zeta'] = 611;
  49818. t['bracketleft'] = 333;
  49819. t['therefore'] = 863;
  49820. t['bracketright'] = 333;
  49821. t['perpendicular'] = 658;
  49822. t['underscore'] = 500;
  49823. t['radicalex'] = 500;
  49824. t['alpha'] = 631;
  49825. t['beta'] = 549;
  49826. t['chi'] = 549;
  49827. t['delta'] = 494;
  49828. t['epsilon'] = 439;
  49829. t['phi'] = 521;
  49830. t['gamma'] = 411;
  49831. t['eta'] = 603;
  49832. t['iota'] = 329;
  49833. t['phi1'] = 603;
  49834. t['kappa'] = 549;
  49835. t['lambda'] = 549;
  49836. t['mu'] = 576;
  49837. t['nu'] = 521;
  49838. t['omicron'] = 549;
  49839. t['pi'] = 549;
  49840. t['theta'] = 521;
  49841. t['rho'] = 549;
  49842. t['sigma'] = 603;
  49843. t['tau'] = 439;
  49844. t['upsilon'] = 576;
  49845. t['omega1'] = 713;
  49846. t['omega'] = 686;
  49847. t['xi'] = 493;
  49848. t['psi'] = 686;
  49849. t['zeta'] = 494;
  49850. t['braceleft'] = 480;
  49851. t['bar'] = 200;
  49852. t['braceright'] = 480;
  49853. t['similar'] = 549;
  49854. t['Euro'] = 750;
  49855. t['Upsilon1'] = 620;
  49856. t['minute'] = 247;
  49857. t['lessequal'] = 549;
  49858. t['fraction'] = 167;
  49859. t['infinity'] = 713;
  49860. t['florin'] = 500;
  49861. t['club'] = 753;
  49862. t['diamond'] = 753;
  49863. t['heart'] = 753;
  49864. t['spade'] = 753;
  49865. t['arrowboth'] = 1042;
  49866. t['arrowleft'] = 987;
  49867. t['arrowup'] = 603;
  49868. t['arrowright'] = 987;
  49869. t['arrowdown'] = 603;
  49870. t['degree'] = 400;
  49871. t['plusminus'] = 549;
  49872. t['second'] = 411;
  49873. t['greaterequal'] = 549;
  49874. t['multiply'] = 549;
  49875. t['proportional'] = 713;
  49876. t['partialdiff'] = 494;
  49877. t['bullet'] = 460;
  49878. t['divide'] = 549;
  49879. t['notequal'] = 549;
  49880. t['equivalence'] = 549;
  49881. t['approxequal'] = 549;
  49882. t['ellipsis'] = 1000;
  49883. t['arrowvertex'] = 603;
  49884. t['arrowhorizex'] = 1000;
  49885. t['carriagereturn'] = 658;
  49886. t['aleph'] = 823;
  49887. t['Ifraktur'] = 686;
  49888. t['Rfraktur'] = 795;
  49889. t['weierstrass'] = 987;
  49890. t['circlemultiply'] = 768;
  49891. t['circleplus'] = 768;
  49892. t['emptyset'] = 823;
  49893. t['intersection'] = 768;
  49894. t['union'] = 768;
  49895. t['propersuperset'] = 713;
  49896. t['reflexsuperset'] = 713;
  49897. t['notsubset'] = 713;
  49898. t['propersubset'] = 713;
  49899. t['reflexsubset'] = 713;
  49900. t['element'] = 713;
  49901. t['notelement'] = 713;
  49902. t['angle'] = 768;
  49903. t['gradient'] = 713;
  49904. t['registerserif'] = 790;
  49905. t['copyrightserif'] = 790;
  49906. t['trademarkserif'] = 890;
  49907. t['product'] = 823;
  49908. t['radical'] = 549;
  49909. t['dotmath'] = 250;
  49910. t['logicalnot'] = 713;
  49911. t['logicaland'] = 603;
  49912. t['logicalor'] = 603;
  49913. t['arrowdblboth'] = 1042;
  49914. t['arrowdblleft'] = 987;
  49915. t['arrowdblup'] = 603;
  49916. t['arrowdblright'] = 987;
  49917. t['arrowdbldown'] = 603;
  49918. t['lozenge'] = 494;
  49919. t['angleleft'] = 329;
  49920. t['registersans'] = 790;
  49921. t['copyrightsans'] = 790;
  49922. t['trademarksans'] = 786;
  49923. t['summation'] = 713;
  49924. t['parenlefttp'] = 384;
  49925. t['parenleftex'] = 384;
  49926. t['parenleftbt'] = 384;
  49927. t['bracketlefttp'] = 384;
  49928. t['bracketleftex'] = 384;
  49929. t['bracketleftbt'] = 384;
  49930. t['bracelefttp'] = 494;
  49931. t['braceleftmid'] = 494;
  49932. t['braceleftbt'] = 494;
  49933. t['braceex'] = 494;
  49934. t['angleright'] = 329;
  49935. t['integral'] = 274;
  49936. t['integraltp'] = 686;
  49937. t['integralex'] = 686;
  49938. t['integralbt'] = 686;
  49939. t['parenrighttp'] = 384;
  49940. t['parenrightex'] = 384;
  49941. t['parenrightbt'] = 384;
  49942. t['bracketrighttp'] = 384;
  49943. t['bracketrightex'] = 384;
  49944. t['bracketrightbt'] = 384;
  49945. t['bracerighttp'] = 494;
  49946. t['bracerightmid'] = 494;
  49947. t['bracerightbt'] = 494;
  49948. t['apple'] = 790;
  49949. });
  49950. t['Times-Roman'] = getLookupTableFactory(function (t) {
  49951. t['space'] = 250;
  49952. t['exclam'] = 333;
  49953. t['quotedbl'] = 408;
  49954. t['numbersign'] = 500;
  49955. t['dollar'] = 500;
  49956. t['percent'] = 833;
  49957. t['ampersand'] = 778;
  49958. t['quoteright'] = 333;
  49959. t['parenleft'] = 333;
  49960. t['parenright'] = 333;
  49961. t['asterisk'] = 500;
  49962. t['plus'] = 564;
  49963. t['comma'] = 250;
  49964. t['hyphen'] = 333;
  49965. t['period'] = 250;
  49966. t['slash'] = 278;
  49967. t['zero'] = 500;
  49968. t['one'] = 500;
  49969. t['two'] = 500;
  49970. t['three'] = 500;
  49971. t['four'] = 500;
  49972. t['five'] = 500;
  49973. t['six'] = 500;
  49974. t['seven'] = 500;
  49975. t['eight'] = 500;
  49976. t['nine'] = 500;
  49977. t['colon'] = 278;
  49978. t['semicolon'] = 278;
  49979. t['less'] = 564;
  49980. t['equal'] = 564;
  49981. t['greater'] = 564;
  49982. t['question'] = 444;
  49983. t['at'] = 921;
  49984. t['A'] = 722;
  49985. t['B'] = 667;
  49986. t['C'] = 667;
  49987. t['D'] = 722;
  49988. t['E'] = 611;
  49989. t['F'] = 556;
  49990. t['G'] = 722;
  49991. t['H'] = 722;
  49992. t['I'] = 333;
  49993. t['J'] = 389;
  49994. t['K'] = 722;
  49995. t['L'] = 611;
  49996. t['M'] = 889;
  49997. t['N'] = 722;
  49998. t['O'] = 722;
  49999. t['P'] = 556;
  50000. t['Q'] = 722;
  50001. t['R'] = 667;
  50002. t['S'] = 556;
  50003. t['T'] = 611;
  50004. t['U'] = 722;
  50005. t['V'] = 722;
  50006. t['W'] = 944;
  50007. t['X'] = 722;
  50008. t['Y'] = 722;
  50009. t['Z'] = 611;
  50010. t['bracketleft'] = 333;
  50011. t['backslash'] = 278;
  50012. t['bracketright'] = 333;
  50013. t['asciicircum'] = 469;
  50014. t['underscore'] = 500;
  50015. t['quoteleft'] = 333;
  50016. t['a'] = 444;
  50017. t['b'] = 500;
  50018. t['c'] = 444;
  50019. t['d'] = 500;
  50020. t['e'] = 444;
  50021. t['f'] = 333;
  50022. t['g'] = 500;
  50023. t['h'] = 500;
  50024. t['i'] = 278;
  50025. t['j'] = 278;
  50026. t['k'] = 500;
  50027. t['l'] = 278;
  50028. t['m'] = 778;
  50029. t['n'] = 500;
  50030. t['o'] = 500;
  50031. t['p'] = 500;
  50032. t['q'] = 500;
  50033. t['r'] = 333;
  50034. t['s'] = 389;
  50035. t['t'] = 278;
  50036. t['u'] = 500;
  50037. t['v'] = 500;
  50038. t['w'] = 722;
  50039. t['x'] = 500;
  50040. t['y'] = 500;
  50041. t['z'] = 444;
  50042. t['braceleft'] = 480;
  50043. t['bar'] = 200;
  50044. t['braceright'] = 480;
  50045. t['asciitilde'] = 541;
  50046. t['exclamdown'] = 333;
  50047. t['cent'] = 500;
  50048. t['sterling'] = 500;
  50049. t['fraction'] = 167;
  50050. t['yen'] = 500;
  50051. t['florin'] = 500;
  50052. t['section'] = 500;
  50053. t['currency'] = 500;
  50054. t['quotesingle'] = 180;
  50055. t['quotedblleft'] = 444;
  50056. t['guillemotleft'] = 500;
  50057. t['guilsinglleft'] = 333;
  50058. t['guilsinglright'] = 333;
  50059. t['fi'] = 556;
  50060. t['fl'] = 556;
  50061. t['endash'] = 500;
  50062. t['dagger'] = 500;
  50063. t['daggerdbl'] = 500;
  50064. t['periodcentered'] = 250;
  50065. t['paragraph'] = 453;
  50066. t['bullet'] = 350;
  50067. t['quotesinglbase'] = 333;
  50068. t['quotedblbase'] = 444;
  50069. t['quotedblright'] = 444;
  50070. t['guillemotright'] = 500;
  50071. t['ellipsis'] = 1000;
  50072. t['perthousand'] = 1000;
  50073. t['questiondown'] = 444;
  50074. t['grave'] = 333;
  50075. t['acute'] = 333;
  50076. t['circumflex'] = 333;
  50077. t['tilde'] = 333;
  50078. t['macron'] = 333;
  50079. t['breve'] = 333;
  50080. t['dotaccent'] = 333;
  50081. t['dieresis'] = 333;
  50082. t['ring'] = 333;
  50083. t['cedilla'] = 333;
  50084. t['hungarumlaut'] = 333;
  50085. t['ogonek'] = 333;
  50086. t['caron'] = 333;
  50087. t['emdash'] = 1000;
  50088. t['AE'] = 889;
  50089. t['ordfeminine'] = 276;
  50090. t['Lslash'] = 611;
  50091. t['Oslash'] = 722;
  50092. t['OE'] = 889;
  50093. t['ordmasculine'] = 310;
  50094. t['ae'] = 667;
  50095. t['dotlessi'] = 278;
  50096. t['lslash'] = 278;
  50097. t['oslash'] = 500;
  50098. t['oe'] = 722;
  50099. t['germandbls'] = 500;
  50100. t['Idieresis'] = 333;
  50101. t['eacute'] = 444;
  50102. t['abreve'] = 444;
  50103. t['uhungarumlaut'] = 500;
  50104. t['ecaron'] = 444;
  50105. t['Ydieresis'] = 722;
  50106. t['divide'] = 564;
  50107. t['Yacute'] = 722;
  50108. t['Acircumflex'] = 722;
  50109. t['aacute'] = 444;
  50110. t['Ucircumflex'] = 722;
  50111. t['yacute'] = 500;
  50112. t['scommaaccent'] = 389;
  50113. t['ecircumflex'] = 444;
  50114. t['Uring'] = 722;
  50115. t['Udieresis'] = 722;
  50116. t['aogonek'] = 444;
  50117. t['Uacute'] = 722;
  50118. t['uogonek'] = 500;
  50119. t['Edieresis'] = 611;
  50120. t['Dcroat'] = 722;
  50121. t['commaaccent'] = 250;
  50122. t['copyright'] = 760;
  50123. t['Emacron'] = 611;
  50124. t['ccaron'] = 444;
  50125. t['aring'] = 444;
  50126. t['Ncommaaccent'] = 722;
  50127. t['lacute'] = 278;
  50128. t['agrave'] = 444;
  50129. t['Tcommaaccent'] = 611;
  50130. t['Cacute'] = 667;
  50131. t['atilde'] = 444;
  50132. t['Edotaccent'] = 611;
  50133. t['scaron'] = 389;
  50134. t['scedilla'] = 389;
  50135. t['iacute'] = 278;
  50136. t['lozenge'] = 471;
  50137. t['Rcaron'] = 667;
  50138. t['Gcommaaccent'] = 722;
  50139. t['ucircumflex'] = 500;
  50140. t['acircumflex'] = 444;
  50141. t['Amacron'] = 722;
  50142. t['rcaron'] = 333;
  50143. t['ccedilla'] = 444;
  50144. t['Zdotaccent'] = 611;
  50145. t['Thorn'] = 556;
  50146. t['Omacron'] = 722;
  50147. t['Racute'] = 667;
  50148. t['Sacute'] = 556;
  50149. t['dcaron'] = 588;
  50150. t['Umacron'] = 722;
  50151. t['uring'] = 500;
  50152. t['threesuperior'] = 300;
  50153. t['Ograve'] = 722;
  50154. t['Agrave'] = 722;
  50155. t['Abreve'] = 722;
  50156. t['multiply'] = 564;
  50157. t['uacute'] = 500;
  50158. t['Tcaron'] = 611;
  50159. t['partialdiff'] = 476;
  50160. t['ydieresis'] = 500;
  50161. t['Nacute'] = 722;
  50162. t['icircumflex'] = 278;
  50163. t['Ecircumflex'] = 611;
  50164. t['adieresis'] = 444;
  50165. t['edieresis'] = 444;
  50166. t['cacute'] = 444;
  50167. t['nacute'] = 500;
  50168. t['umacron'] = 500;
  50169. t['Ncaron'] = 722;
  50170. t['Iacute'] = 333;
  50171. t['plusminus'] = 564;
  50172. t['brokenbar'] = 200;
  50173. t['registered'] = 760;
  50174. t['Gbreve'] = 722;
  50175. t['Idotaccent'] = 333;
  50176. t['summation'] = 600;
  50177. t['Egrave'] = 611;
  50178. t['racute'] = 333;
  50179. t['omacron'] = 500;
  50180. t['Zacute'] = 611;
  50181. t['Zcaron'] = 611;
  50182. t['greaterequal'] = 549;
  50183. t['Eth'] = 722;
  50184. t['Ccedilla'] = 667;
  50185. t['lcommaaccent'] = 278;
  50186. t['tcaron'] = 326;
  50187. t['eogonek'] = 444;
  50188. t['Uogonek'] = 722;
  50189. t['Aacute'] = 722;
  50190. t['Adieresis'] = 722;
  50191. t['egrave'] = 444;
  50192. t['zacute'] = 444;
  50193. t['iogonek'] = 278;
  50194. t['Oacute'] = 722;
  50195. t['oacute'] = 500;
  50196. t['amacron'] = 444;
  50197. t['sacute'] = 389;
  50198. t['idieresis'] = 278;
  50199. t['Ocircumflex'] = 722;
  50200. t['Ugrave'] = 722;
  50201. t['Delta'] = 612;
  50202. t['thorn'] = 500;
  50203. t['twosuperior'] = 300;
  50204. t['Odieresis'] = 722;
  50205. t['mu'] = 500;
  50206. t['igrave'] = 278;
  50207. t['ohungarumlaut'] = 500;
  50208. t['Eogonek'] = 611;
  50209. t['dcroat'] = 500;
  50210. t['threequarters'] = 750;
  50211. t['Scedilla'] = 556;
  50212. t['lcaron'] = 344;
  50213. t['Kcommaaccent'] = 722;
  50214. t['Lacute'] = 611;
  50215. t['trademark'] = 980;
  50216. t['edotaccent'] = 444;
  50217. t['Igrave'] = 333;
  50218. t['Imacron'] = 333;
  50219. t['Lcaron'] = 611;
  50220. t['onehalf'] = 750;
  50221. t['lessequal'] = 549;
  50222. t['ocircumflex'] = 500;
  50223. t['ntilde'] = 500;
  50224. t['Uhungarumlaut'] = 722;
  50225. t['Eacute'] = 611;
  50226. t['emacron'] = 444;
  50227. t['gbreve'] = 500;
  50228. t['onequarter'] = 750;
  50229. t['Scaron'] = 556;
  50230. t['Scommaaccent'] = 556;
  50231. t['Ohungarumlaut'] = 722;
  50232. t['degree'] = 400;
  50233. t['ograve'] = 500;
  50234. t['Ccaron'] = 667;
  50235. t['ugrave'] = 500;
  50236. t['radical'] = 453;
  50237. t['Dcaron'] = 722;
  50238. t['rcommaaccent'] = 333;
  50239. t['Ntilde'] = 722;
  50240. t['otilde'] = 500;
  50241. t['Rcommaaccent'] = 667;
  50242. t['Lcommaaccent'] = 611;
  50243. t['Atilde'] = 722;
  50244. t['Aogonek'] = 722;
  50245. t['Aring'] = 722;
  50246. t['Otilde'] = 722;
  50247. t['zdotaccent'] = 444;
  50248. t['Ecaron'] = 611;
  50249. t['Iogonek'] = 333;
  50250. t['kcommaaccent'] = 500;
  50251. t['minus'] = 564;
  50252. t['Icircumflex'] = 333;
  50253. t['ncaron'] = 500;
  50254. t['tcommaaccent'] = 278;
  50255. t['logicalnot'] = 564;
  50256. t['odieresis'] = 500;
  50257. t['udieresis'] = 500;
  50258. t['notequal'] = 549;
  50259. t['gcommaaccent'] = 500;
  50260. t['eth'] = 500;
  50261. t['zcaron'] = 444;
  50262. t['ncommaaccent'] = 500;
  50263. t['onesuperior'] = 300;
  50264. t['imacron'] = 278;
  50265. t['Euro'] = 500;
  50266. });
  50267. t['Times-Bold'] = getLookupTableFactory(function (t) {
  50268. t['space'] = 250;
  50269. t['exclam'] = 333;
  50270. t['quotedbl'] = 555;
  50271. t['numbersign'] = 500;
  50272. t['dollar'] = 500;
  50273. t['percent'] = 1000;
  50274. t['ampersand'] = 833;
  50275. t['quoteright'] = 333;
  50276. t['parenleft'] = 333;
  50277. t['parenright'] = 333;
  50278. t['asterisk'] = 500;
  50279. t['plus'] = 570;
  50280. t['comma'] = 250;
  50281. t['hyphen'] = 333;
  50282. t['period'] = 250;
  50283. t['slash'] = 278;
  50284. t['zero'] = 500;
  50285. t['one'] = 500;
  50286. t['two'] = 500;
  50287. t['three'] = 500;
  50288. t['four'] = 500;
  50289. t['five'] = 500;
  50290. t['six'] = 500;
  50291. t['seven'] = 500;
  50292. t['eight'] = 500;
  50293. t['nine'] = 500;
  50294. t['colon'] = 333;
  50295. t['semicolon'] = 333;
  50296. t['less'] = 570;
  50297. t['equal'] = 570;
  50298. t['greater'] = 570;
  50299. t['question'] = 500;
  50300. t['at'] = 930;
  50301. t['A'] = 722;
  50302. t['B'] = 667;
  50303. t['C'] = 722;
  50304. t['D'] = 722;
  50305. t['E'] = 667;
  50306. t['F'] = 611;
  50307. t['G'] = 778;
  50308. t['H'] = 778;
  50309. t['I'] = 389;
  50310. t['J'] = 500;
  50311. t['K'] = 778;
  50312. t['L'] = 667;
  50313. t['M'] = 944;
  50314. t['N'] = 722;
  50315. t['O'] = 778;
  50316. t['P'] = 611;
  50317. t['Q'] = 778;
  50318. t['R'] = 722;
  50319. t['S'] = 556;
  50320. t['T'] = 667;
  50321. t['U'] = 722;
  50322. t['V'] = 722;
  50323. t['W'] = 1000;
  50324. t['X'] = 722;
  50325. t['Y'] = 722;
  50326. t['Z'] = 667;
  50327. t['bracketleft'] = 333;
  50328. t['backslash'] = 278;
  50329. t['bracketright'] = 333;
  50330. t['asciicircum'] = 581;
  50331. t['underscore'] = 500;
  50332. t['quoteleft'] = 333;
  50333. t['a'] = 500;
  50334. t['b'] = 556;
  50335. t['c'] = 444;
  50336. t['d'] = 556;
  50337. t['e'] = 444;
  50338. t['f'] = 333;
  50339. t['g'] = 500;
  50340. t['h'] = 556;
  50341. t['i'] = 278;
  50342. t['j'] = 333;
  50343. t['k'] = 556;
  50344. t['l'] = 278;
  50345. t['m'] = 833;
  50346. t['n'] = 556;
  50347. t['o'] = 500;
  50348. t['p'] = 556;
  50349. t['q'] = 556;
  50350. t['r'] = 444;
  50351. t['s'] = 389;
  50352. t['t'] = 333;
  50353. t['u'] = 556;
  50354. t['v'] = 500;
  50355. t['w'] = 722;
  50356. t['x'] = 500;
  50357. t['y'] = 500;
  50358. t['z'] = 444;
  50359. t['braceleft'] = 394;
  50360. t['bar'] = 220;
  50361. t['braceright'] = 394;
  50362. t['asciitilde'] = 520;
  50363. t['exclamdown'] = 333;
  50364. t['cent'] = 500;
  50365. t['sterling'] = 500;
  50366. t['fraction'] = 167;
  50367. t['yen'] = 500;
  50368. t['florin'] = 500;
  50369. t['section'] = 500;
  50370. t['currency'] = 500;
  50371. t['quotesingle'] = 278;
  50372. t['quotedblleft'] = 500;
  50373. t['guillemotleft'] = 500;
  50374. t['guilsinglleft'] = 333;
  50375. t['guilsinglright'] = 333;
  50376. t['fi'] = 556;
  50377. t['fl'] = 556;
  50378. t['endash'] = 500;
  50379. t['dagger'] = 500;
  50380. t['daggerdbl'] = 500;
  50381. t['periodcentered'] = 250;
  50382. t['paragraph'] = 540;
  50383. t['bullet'] = 350;
  50384. t['quotesinglbase'] = 333;
  50385. t['quotedblbase'] = 500;
  50386. t['quotedblright'] = 500;
  50387. t['guillemotright'] = 500;
  50388. t['ellipsis'] = 1000;
  50389. t['perthousand'] = 1000;
  50390. t['questiondown'] = 500;
  50391. t['grave'] = 333;
  50392. t['acute'] = 333;
  50393. t['circumflex'] = 333;
  50394. t['tilde'] = 333;
  50395. t['macron'] = 333;
  50396. t['breve'] = 333;
  50397. t['dotaccent'] = 333;
  50398. t['dieresis'] = 333;
  50399. t['ring'] = 333;
  50400. t['cedilla'] = 333;
  50401. t['hungarumlaut'] = 333;
  50402. t['ogonek'] = 333;
  50403. t['caron'] = 333;
  50404. t['emdash'] = 1000;
  50405. t['AE'] = 1000;
  50406. t['ordfeminine'] = 300;
  50407. t['Lslash'] = 667;
  50408. t['Oslash'] = 778;
  50409. t['OE'] = 1000;
  50410. t['ordmasculine'] = 330;
  50411. t['ae'] = 722;
  50412. t['dotlessi'] = 278;
  50413. t['lslash'] = 278;
  50414. t['oslash'] = 500;
  50415. t['oe'] = 722;
  50416. t['germandbls'] = 556;
  50417. t['Idieresis'] = 389;
  50418. t['eacute'] = 444;
  50419. t['abreve'] = 500;
  50420. t['uhungarumlaut'] = 556;
  50421. t['ecaron'] = 444;
  50422. t['Ydieresis'] = 722;
  50423. t['divide'] = 570;
  50424. t['Yacute'] = 722;
  50425. t['Acircumflex'] = 722;
  50426. t['aacute'] = 500;
  50427. t['Ucircumflex'] = 722;
  50428. t['yacute'] = 500;
  50429. t['scommaaccent'] = 389;
  50430. t['ecircumflex'] = 444;
  50431. t['Uring'] = 722;
  50432. t['Udieresis'] = 722;
  50433. t['aogonek'] = 500;
  50434. t['Uacute'] = 722;
  50435. t['uogonek'] = 556;
  50436. t['Edieresis'] = 667;
  50437. t['Dcroat'] = 722;
  50438. t['commaaccent'] = 250;
  50439. t['copyright'] = 747;
  50440. t['Emacron'] = 667;
  50441. t['ccaron'] = 444;
  50442. t['aring'] = 500;
  50443. t['Ncommaaccent'] = 722;
  50444. t['lacute'] = 278;
  50445. t['agrave'] = 500;
  50446. t['Tcommaaccent'] = 667;
  50447. t['Cacute'] = 722;
  50448. t['atilde'] = 500;
  50449. t['Edotaccent'] = 667;
  50450. t['scaron'] = 389;
  50451. t['scedilla'] = 389;
  50452. t['iacute'] = 278;
  50453. t['lozenge'] = 494;
  50454. t['Rcaron'] = 722;
  50455. t['Gcommaaccent'] = 778;
  50456. t['ucircumflex'] = 556;
  50457. t['acircumflex'] = 500;
  50458. t['Amacron'] = 722;
  50459. t['rcaron'] = 444;
  50460. t['ccedilla'] = 444;
  50461. t['Zdotaccent'] = 667;
  50462. t['Thorn'] = 611;
  50463. t['Omacron'] = 778;
  50464. t['Racute'] = 722;
  50465. t['Sacute'] = 556;
  50466. t['dcaron'] = 672;
  50467. t['Umacron'] = 722;
  50468. t['uring'] = 556;
  50469. t['threesuperior'] = 300;
  50470. t['Ograve'] = 778;
  50471. t['Agrave'] = 722;
  50472. t['Abreve'] = 722;
  50473. t['multiply'] = 570;
  50474. t['uacute'] = 556;
  50475. t['Tcaron'] = 667;
  50476. t['partialdiff'] = 494;
  50477. t['ydieresis'] = 500;
  50478. t['Nacute'] = 722;
  50479. t['icircumflex'] = 278;
  50480. t['Ecircumflex'] = 667;
  50481. t['adieresis'] = 500;
  50482. t['edieresis'] = 444;
  50483. t['cacute'] = 444;
  50484. t['nacute'] = 556;
  50485. t['umacron'] = 556;
  50486. t['Ncaron'] = 722;
  50487. t['Iacute'] = 389;
  50488. t['plusminus'] = 570;
  50489. t['brokenbar'] = 220;
  50490. t['registered'] = 747;
  50491. t['Gbreve'] = 778;
  50492. t['Idotaccent'] = 389;
  50493. t['summation'] = 600;
  50494. t['Egrave'] = 667;
  50495. t['racute'] = 444;
  50496. t['omacron'] = 500;
  50497. t['Zacute'] = 667;
  50498. t['Zcaron'] = 667;
  50499. t['greaterequal'] = 549;
  50500. t['Eth'] = 722;
  50501. t['Ccedilla'] = 722;
  50502. t['lcommaaccent'] = 278;
  50503. t['tcaron'] = 416;
  50504. t['eogonek'] = 444;
  50505. t['Uogonek'] = 722;
  50506. t['Aacute'] = 722;
  50507. t['Adieresis'] = 722;
  50508. t['egrave'] = 444;
  50509. t['zacute'] = 444;
  50510. t['iogonek'] = 278;
  50511. t['Oacute'] = 778;
  50512. t['oacute'] = 500;
  50513. t['amacron'] = 500;
  50514. t['sacute'] = 389;
  50515. t['idieresis'] = 278;
  50516. t['Ocircumflex'] = 778;
  50517. t['Ugrave'] = 722;
  50518. t['Delta'] = 612;
  50519. t['thorn'] = 556;
  50520. t['twosuperior'] = 300;
  50521. t['Odieresis'] = 778;
  50522. t['mu'] = 556;
  50523. t['igrave'] = 278;
  50524. t['ohungarumlaut'] = 500;
  50525. t['Eogonek'] = 667;
  50526. t['dcroat'] = 556;
  50527. t['threequarters'] = 750;
  50528. t['Scedilla'] = 556;
  50529. t['lcaron'] = 394;
  50530. t['Kcommaaccent'] = 778;
  50531. t['Lacute'] = 667;
  50532. t['trademark'] = 1000;
  50533. t['edotaccent'] = 444;
  50534. t['Igrave'] = 389;
  50535. t['Imacron'] = 389;
  50536. t['Lcaron'] = 667;
  50537. t['onehalf'] = 750;
  50538. t['lessequal'] = 549;
  50539. t['ocircumflex'] = 500;
  50540. t['ntilde'] = 556;
  50541. t['Uhungarumlaut'] = 722;
  50542. t['Eacute'] = 667;
  50543. t['emacron'] = 444;
  50544. t['gbreve'] = 500;
  50545. t['onequarter'] = 750;
  50546. t['Scaron'] = 556;
  50547. t['Scommaaccent'] = 556;
  50548. t['Ohungarumlaut'] = 778;
  50549. t['degree'] = 400;
  50550. t['ograve'] = 500;
  50551. t['Ccaron'] = 722;
  50552. t['ugrave'] = 556;
  50553. t['radical'] = 549;
  50554. t['Dcaron'] = 722;
  50555. t['rcommaaccent'] = 444;
  50556. t['Ntilde'] = 722;
  50557. t['otilde'] = 500;
  50558. t['Rcommaaccent'] = 722;
  50559. t['Lcommaaccent'] = 667;
  50560. t['Atilde'] = 722;
  50561. t['Aogonek'] = 722;
  50562. t['Aring'] = 722;
  50563. t['Otilde'] = 778;
  50564. t['zdotaccent'] = 444;
  50565. t['Ecaron'] = 667;
  50566. t['Iogonek'] = 389;
  50567. t['kcommaaccent'] = 556;
  50568. t['minus'] = 570;
  50569. t['Icircumflex'] = 389;
  50570. t['ncaron'] = 556;
  50571. t['tcommaaccent'] = 333;
  50572. t['logicalnot'] = 570;
  50573. t['odieresis'] = 500;
  50574. t['udieresis'] = 556;
  50575. t['notequal'] = 549;
  50576. t['gcommaaccent'] = 500;
  50577. t['eth'] = 500;
  50578. t['zcaron'] = 444;
  50579. t['ncommaaccent'] = 556;
  50580. t['onesuperior'] = 300;
  50581. t['imacron'] = 278;
  50582. t['Euro'] = 500;
  50583. });
  50584. t['Times-BoldItalic'] = getLookupTableFactory(function (t) {
  50585. t['space'] = 250;
  50586. t['exclam'] = 389;
  50587. t['quotedbl'] = 555;
  50588. t['numbersign'] = 500;
  50589. t['dollar'] = 500;
  50590. t['percent'] = 833;
  50591. t['ampersand'] = 778;
  50592. t['quoteright'] = 333;
  50593. t['parenleft'] = 333;
  50594. t['parenright'] = 333;
  50595. t['asterisk'] = 500;
  50596. t['plus'] = 570;
  50597. t['comma'] = 250;
  50598. t['hyphen'] = 333;
  50599. t['period'] = 250;
  50600. t['slash'] = 278;
  50601. t['zero'] = 500;
  50602. t['one'] = 500;
  50603. t['two'] = 500;
  50604. t['three'] = 500;
  50605. t['four'] = 500;
  50606. t['five'] = 500;
  50607. t['six'] = 500;
  50608. t['seven'] = 500;
  50609. t['eight'] = 500;
  50610. t['nine'] = 500;
  50611. t['colon'] = 333;
  50612. t['semicolon'] = 333;
  50613. t['less'] = 570;
  50614. t['equal'] = 570;
  50615. t['greater'] = 570;
  50616. t['question'] = 500;
  50617. t['at'] = 832;
  50618. t['A'] = 667;
  50619. t['B'] = 667;
  50620. t['C'] = 667;
  50621. t['D'] = 722;
  50622. t['E'] = 667;
  50623. t['F'] = 667;
  50624. t['G'] = 722;
  50625. t['H'] = 778;
  50626. t['I'] = 389;
  50627. t['J'] = 500;
  50628. t['K'] = 667;
  50629. t['L'] = 611;
  50630. t['M'] = 889;
  50631. t['N'] = 722;
  50632. t['O'] = 722;
  50633. t['P'] = 611;
  50634. t['Q'] = 722;
  50635. t['R'] = 667;
  50636. t['S'] = 556;
  50637. t['T'] = 611;
  50638. t['U'] = 722;
  50639. t['V'] = 667;
  50640. t['W'] = 889;
  50641. t['X'] = 667;
  50642. t['Y'] = 611;
  50643. t['Z'] = 611;
  50644. t['bracketleft'] = 333;
  50645. t['backslash'] = 278;
  50646. t['bracketright'] = 333;
  50647. t['asciicircum'] = 570;
  50648. t['underscore'] = 500;
  50649. t['quoteleft'] = 333;
  50650. t['a'] = 500;
  50651. t['b'] = 500;
  50652. t['c'] = 444;
  50653. t['d'] = 500;
  50654. t['e'] = 444;
  50655. t['f'] = 333;
  50656. t['g'] = 500;
  50657. t['h'] = 556;
  50658. t['i'] = 278;
  50659. t['j'] = 278;
  50660. t['k'] = 500;
  50661. t['l'] = 278;
  50662. t['m'] = 778;
  50663. t['n'] = 556;
  50664. t['o'] = 500;
  50665. t['p'] = 500;
  50666. t['q'] = 500;
  50667. t['r'] = 389;
  50668. t['s'] = 389;
  50669. t['t'] = 278;
  50670. t['u'] = 556;
  50671. t['v'] = 444;
  50672. t['w'] = 667;
  50673. t['x'] = 500;
  50674. t['y'] = 444;
  50675. t['z'] = 389;
  50676. t['braceleft'] = 348;
  50677. t['bar'] = 220;
  50678. t['braceright'] = 348;
  50679. t['asciitilde'] = 570;
  50680. t['exclamdown'] = 389;
  50681. t['cent'] = 500;
  50682. t['sterling'] = 500;
  50683. t['fraction'] = 167;
  50684. t['yen'] = 500;
  50685. t['florin'] = 500;
  50686. t['section'] = 500;
  50687. t['currency'] = 500;
  50688. t['quotesingle'] = 278;
  50689. t['quotedblleft'] = 500;
  50690. t['guillemotleft'] = 500;
  50691. t['guilsinglleft'] = 333;
  50692. t['guilsinglright'] = 333;
  50693. t['fi'] = 556;
  50694. t['fl'] = 556;
  50695. t['endash'] = 500;
  50696. t['dagger'] = 500;
  50697. t['daggerdbl'] = 500;
  50698. t['periodcentered'] = 250;
  50699. t['paragraph'] = 500;
  50700. t['bullet'] = 350;
  50701. t['quotesinglbase'] = 333;
  50702. t['quotedblbase'] = 500;
  50703. t['quotedblright'] = 500;
  50704. t['guillemotright'] = 500;
  50705. t['ellipsis'] = 1000;
  50706. t['perthousand'] = 1000;
  50707. t['questiondown'] = 500;
  50708. t['grave'] = 333;
  50709. t['acute'] = 333;
  50710. t['circumflex'] = 333;
  50711. t['tilde'] = 333;
  50712. t['macron'] = 333;
  50713. t['breve'] = 333;
  50714. t['dotaccent'] = 333;
  50715. t['dieresis'] = 333;
  50716. t['ring'] = 333;
  50717. t['cedilla'] = 333;
  50718. t['hungarumlaut'] = 333;
  50719. t['ogonek'] = 333;
  50720. t['caron'] = 333;
  50721. t['emdash'] = 1000;
  50722. t['AE'] = 944;
  50723. t['ordfeminine'] = 266;
  50724. t['Lslash'] = 611;
  50725. t['Oslash'] = 722;
  50726. t['OE'] = 944;
  50727. t['ordmasculine'] = 300;
  50728. t['ae'] = 722;
  50729. t['dotlessi'] = 278;
  50730. t['lslash'] = 278;
  50731. t['oslash'] = 500;
  50732. t['oe'] = 722;
  50733. t['germandbls'] = 500;
  50734. t['Idieresis'] = 389;
  50735. t['eacute'] = 444;
  50736. t['abreve'] = 500;
  50737. t['uhungarumlaut'] = 556;
  50738. t['ecaron'] = 444;
  50739. t['Ydieresis'] = 611;
  50740. t['divide'] = 570;
  50741. t['Yacute'] = 611;
  50742. t['Acircumflex'] = 667;
  50743. t['aacute'] = 500;
  50744. t['Ucircumflex'] = 722;
  50745. t['yacute'] = 444;
  50746. t['scommaaccent'] = 389;
  50747. t['ecircumflex'] = 444;
  50748. t['Uring'] = 722;
  50749. t['Udieresis'] = 722;
  50750. t['aogonek'] = 500;
  50751. t['Uacute'] = 722;
  50752. t['uogonek'] = 556;
  50753. t['Edieresis'] = 667;
  50754. t['Dcroat'] = 722;
  50755. t['commaaccent'] = 250;
  50756. t['copyright'] = 747;
  50757. t['Emacron'] = 667;
  50758. t['ccaron'] = 444;
  50759. t['aring'] = 500;
  50760. t['Ncommaaccent'] = 722;
  50761. t['lacute'] = 278;
  50762. t['agrave'] = 500;
  50763. t['Tcommaaccent'] = 611;
  50764. t['Cacute'] = 667;
  50765. t['atilde'] = 500;
  50766. t['Edotaccent'] = 667;
  50767. t['scaron'] = 389;
  50768. t['scedilla'] = 389;
  50769. t['iacute'] = 278;
  50770. t['lozenge'] = 494;
  50771. t['Rcaron'] = 667;
  50772. t['Gcommaaccent'] = 722;
  50773. t['ucircumflex'] = 556;
  50774. t['acircumflex'] = 500;
  50775. t['Amacron'] = 667;
  50776. t['rcaron'] = 389;
  50777. t['ccedilla'] = 444;
  50778. t['Zdotaccent'] = 611;
  50779. t['Thorn'] = 611;
  50780. t['Omacron'] = 722;
  50781. t['Racute'] = 667;
  50782. t['Sacute'] = 556;
  50783. t['dcaron'] = 608;
  50784. t['Umacron'] = 722;
  50785. t['uring'] = 556;
  50786. t['threesuperior'] = 300;
  50787. t['Ograve'] = 722;
  50788. t['Agrave'] = 667;
  50789. t['Abreve'] = 667;
  50790. t['multiply'] = 570;
  50791. t['uacute'] = 556;
  50792. t['Tcaron'] = 611;
  50793. t['partialdiff'] = 494;
  50794. t['ydieresis'] = 444;
  50795. t['Nacute'] = 722;
  50796. t['icircumflex'] = 278;
  50797. t['Ecircumflex'] = 667;
  50798. t['adieresis'] = 500;
  50799. t['edieresis'] = 444;
  50800. t['cacute'] = 444;
  50801. t['nacute'] = 556;
  50802. t['umacron'] = 556;
  50803. t['Ncaron'] = 722;
  50804. t['Iacute'] = 389;
  50805. t['plusminus'] = 570;
  50806. t['brokenbar'] = 220;
  50807. t['registered'] = 747;
  50808. t['Gbreve'] = 722;
  50809. t['Idotaccent'] = 389;
  50810. t['summation'] = 600;
  50811. t['Egrave'] = 667;
  50812. t['racute'] = 389;
  50813. t['omacron'] = 500;
  50814. t['Zacute'] = 611;
  50815. t['Zcaron'] = 611;
  50816. t['greaterequal'] = 549;
  50817. t['Eth'] = 722;
  50818. t['Ccedilla'] = 667;
  50819. t['lcommaaccent'] = 278;
  50820. t['tcaron'] = 366;
  50821. t['eogonek'] = 444;
  50822. t['Uogonek'] = 722;
  50823. t['Aacute'] = 667;
  50824. t['Adieresis'] = 667;
  50825. t['egrave'] = 444;
  50826. t['zacute'] = 389;
  50827. t['iogonek'] = 278;
  50828. t['Oacute'] = 722;
  50829. t['oacute'] = 500;
  50830. t['amacron'] = 500;
  50831. t['sacute'] = 389;
  50832. t['idieresis'] = 278;
  50833. t['Ocircumflex'] = 722;
  50834. t['Ugrave'] = 722;
  50835. t['Delta'] = 612;
  50836. t['thorn'] = 500;
  50837. t['twosuperior'] = 300;
  50838. t['Odieresis'] = 722;
  50839. t['mu'] = 576;
  50840. t['igrave'] = 278;
  50841. t['ohungarumlaut'] = 500;
  50842. t['Eogonek'] = 667;
  50843. t['dcroat'] = 500;
  50844. t['threequarters'] = 750;
  50845. t['Scedilla'] = 556;
  50846. t['lcaron'] = 382;
  50847. t['Kcommaaccent'] = 667;
  50848. t['Lacute'] = 611;
  50849. t['trademark'] = 1000;
  50850. t['edotaccent'] = 444;
  50851. t['Igrave'] = 389;
  50852. t['Imacron'] = 389;
  50853. t['Lcaron'] = 611;
  50854. t['onehalf'] = 750;
  50855. t['lessequal'] = 549;
  50856. t['ocircumflex'] = 500;
  50857. t['ntilde'] = 556;
  50858. t['Uhungarumlaut'] = 722;
  50859. t['Eacute'] = 667;
  50860. t['emacron'] = 444;
  50861. t['gbreve'] = 500;
  50862. t['onequarter'] = 750;
  50863. t['Scaron'] = 556;
  50864. t['Scommaaccent'] = 556;
  50865. t['Ohungarumlaut'] = 722;
  50866. t['degree'] = 400;
  50867. t['ograve'] = 500;
  50868. t['Ccaron'] = 667;
  50869. t['ugrave'] = 556;
  50870. t['radical'] = 549;
  50871. t['Dcaron'] = 722;
  50872. t['rcommaaccent'] = 389;
  50873. t['Ntilde'] = 722;
  50874. t['otilde'] = 500;
  50875. t['Rcommaaccent'] = 667;
  50876. t['Lcommaaccent'] = 611;
  50877. t['Atilde'] = 667;
  50878. t['Aogonek'] = 667;
  50879. t['Aring'] = 667;
  50880. t['Otilde'] = 722;
  50881. t['zdotaccent'] = 389;
  50882. t['Ecaron'] = 667;
  50883. t['Iogonek'] = 389;
  50884. t['kcommaaccent'] = 500;
  50885. t['minus'] = 606;
  50886. t['Icircumflex'] = 389;
  50887. t['ncaron'] = 556;
  50888. t['tcommaaccent'] = 278;
  50889. t['logicalnot'] = 606;
  50890. t['odieresis'] = 500;
  50891. t['udieresis'] = 556;
  50892. t['notequal'] = 549;
  50893. t['gcommaaccent'] = 500;
  50894. t['eth'] = 500;
  50895. t['zcaron'] = 389;
  50896. t['ncommaaccent'] = 556;
  50897. t['onesuperior'] = 300;
  50898. t['imacron'] = 278;
  50899. t['Euro'] = 500;
  50900. });
  50901. t['Times-Italic'] = getLookupTableFactory(function (t) {
  50902. t['space'] = 250;
  50903. t['exclam'] = 333;
  50904. t['quotedbl'] = 420;
  50905. t['numbersign'] = 500;
  50906. t['dollar'] = 500;
  50907. t['percent'] = 833;
  50908. t['ampersand'] = 778;
  50909. t['quoteright'] = 333;
  50910. t['parenleft'] = 333;
  50911. t['parenright'] = 333;
  50912. t['asterisk'] = 500;
  50913. t['plus'] = 675;
  50914. t['comma'] = 250;
  50915. t['hyphen'] = 333;
  50916. t['period'] = 250;
  50917. t['slash'] = 278;
  50918. t['zero'] = 500;
  50919. t['one'] = 500;
  50920. t['two'] = 500;
  50921. t['three'] = 500;
  50922. t['four'] = 500;
  50923. t['five'] = 500;
  50924. t['six'] = 500;
  50925. t['seven'] = 500;
  50926. t['eight'] = 500;
  50927. t['nine'] = 500;
  50928. t['colon'] = 333;
  50929. t['semicolon'] = 333;
  50930. t['less'] = 675;
  50931. t['equal'] = 675;
  50932. t['greater'] = 675;
  50933. t['question'] = 500;
  50934. t['at'] = 920;
  50935. t['A'] = 611;
  50936. t['B'] = 611;
  50937. t['C'] = 667;
  50938. t['D'] = 722;
  50939. t['E'] = 611;
  50940. t['F'] = 611;
  50941. t['G'] = 722;
  50942. t['H'] = 722;
  50943. t['I'] = 333;
  50944. t['J'] = 444;
  50945. t['K'] = 667;
  50946. t['L'] = 556;
  50947. t['M'] = 833;
  50948. t['N'] = 667;
  50949. t['O'] = 722;
  50950. t['P'] = 611;
  50951. t['Q'] = 722;
  50952. t['R'] = 611;
  50953. t['S'] = 500;
  50954. t['T'] = 556;
  50955. t['U'] = 722;
  50956. t['V'] = 611;
  50957. t['W'] = 833;
  50958. t['X'] = 611;
  50959. t['Y'] = 556;
  50960. t['Z'] = 556;
  50961. t['bracketleft'] = 389;
  50962. t['backslash'] = 278;
  50963. t['bracketright'] = 389;
  50964. t['asciicircum'] = 422;
  50965. t['underscore'] = 500;
  50966. t['quoteleft'] = 333;
  50967. t['a'] = 500;
  50968. t['b'] = 500;
  50969. t['c'] = 444;
  50970. t['d'] = 500;
  50971. t['e'] = 444;
  50972. t['f'] = 278;
  50973. t['g'] = 500;
  50974. t['h'] = 500;
  50975. t['i'] = 278;
  50976. t['j'] = 278;
  50977. t['k'] = 444;
  50978. t['l'] = 278;
  50979. t['m'] = 722;
  50980. t['n'] = 500;
  50981. t['o'] = 500;
  50982. t['p'] = 500;
  50983. t['q'] = 500;
  50984. t['r'] = 389;
  50985. t['s'] = 389;
  50986. t['t'] = 278;
  50987. t['u'] = 500;
  50988. t['v'] = 444;
  50989. t['w'] = 667;
  50990. t['x'] = 444;
  50991. t['y'] = 444;
  50992. t['z'] = 389;
  50993. t['braceleft'] = 400;
  50994. t['bar'] = 275;
  50995. t['braceright'] = 400;
  50996. t['asciitilde'] = 541;
  50997. t['exclamdown'] = 389;
  50998. t['cent'] = 500;
  50999. t['sterling'] = 500;
  51000. t['fraction'] = 167;
  51001. t['yen'] = 500;
  51002. t['florin'] = 500;
  51003. t['section'] = 500;
  51004. t['currency'] = 500;
  51005. t['quotesingle'] = 214;
  51006. t['quotedblleft'] = 556;
  51007. t['guillemotleft'] = 500;
  51008. t['guilsinglleft'] = 333;
  51009. t['guilsinglright'] = 333;
  51010. t['fi'] = 500;
  51011. t['fl'] = 500;
  51012. t['endash'] = 500;
  51013. t['dagger'] = 500;
  51014. t['daggerdbl'] = 500;
  51015. t['periodcentered'] = 250;
  51016. t['paragraph'] = 523;
  51017. t['bullet'] = 350;
  51018. t['quotesinglbase'] = 333;
  51019. t['quotedblbase'] = 556;
  51020. t['quotedblright'] = 556;
  51021. t['guillemotright'] = 500;
  51022. t['ellipsis'] = 889;
  51023. t['perthousand'] = 1000;
  51024. t['questiondown'] = 500;
  51025. t['grave'] = 333;
  51026. t['acute'] = 333;
  51027. t['circumflex'] = 333;
  51028. t['tilde'] = 333;
  51029. t['macron'] = 333;
  51030. t['breve'] = 333;
  51031. t['dotaccent'] = 333;
  51032. t['dieresis'] = 333;
  51033. t['ring'] = 333;
  51034. t['cedilla'] = 333;
  51035. t['hungarumlaut'] = 333;
  51036. t['ogonek'] = 333;
  51037. t['caron'] = 333;
  51038. t['emdash'] = 889;
  51039. t['AE'] = 889;
  51040. t['ordfeminine'] = 276;
  51041. t['Lslash'] = 556;
  51042. t['Oslash'] = 722;
  51043. t['OE'] = 944;
  51044. t['ordmasculine'] = 310;
  51045. t['ae'] = 667;
  51046. t['dotlessi'] = 278;
  51047. t['lslash'] = 278;
  51048. t['oslash'] = 500;
  51049. t['oe'] = 667;
  51050. t['germandbls'] = 500;
  51051. t['Idieresis'] = 333;
  51052. t['eacute'] = 444;
  51053. t['abreve'] = 500;
  51054. t['uhungarumlaut'] = 500;
  51055. t['ecaron'] = 444;
  51056. t['Ydieresis'] = 556;
  51057. t['divide'] = 675;
  51058. t['Yacute'] = 556;
  51059. t['Acircumflex'] = 611;
  51060. t['aacute'] = 500;
  51061. t['Ucircumflex'] = 722;
  51062. t['yacute'] = 444;
  51063. t['scommaaccent'] = 389;
  51064. t['ecircumflex'] = 444;
  51065. t['Uring'] = 722;
  51066. t['Udieresis'] = 722;
  51067. t['aogonek'] = 500;
  51068. t['Uacute'] = 722;
  51069. t['uogonek'] = 500;
  51070. t['Edieresis'] = 611;
  51071. t['Dcroat'] = 722;
  51072. t['commaaccent'] = 250;
  51073. t['copyright'] = 760;
  51074. t['Emacron'] = 611;
  51075. t['ccaron'] = 444;
  51076. t['aring'] = 500;
  51077. t['Ncommaaccent'] = 667;
  51078. t['lacute'] = 278;
  51079. t['agrave'] = 500;
  51080. t['Tcommaaccent'] = 556;
  51081. t['Cacute'] = 667;
  51082. t['atilde'] = 500;
  51083. t['Edotaccent'] = 611;
  51084. t['scaron'] = 389;
  51085. t['scedilla'] = 389;
  51086. t['iacute'] = 278;
  51087. t['lozenge'] = 471;
  51088. t['Rcaron'] = 611;
  51089. t['Gcommaaccent'] = 722;
  51090. t['ucircumflex'] = 500;
  51091. t['acircumflex'] = 500;
  51092. t['Amacron'] = 611;
  51093. t['rcaron'] = 389;
  51094. t['ccedilla'] = 444;
  51095. t['Zdotaccent'] = 556;
  51096. t['Thorn'] = 611;
  51097. t['Omacron'] = 722;
  51098. t['Racute'] = 611;
  51099. t['Sacute'] = 500;
  51100. t['dcaron'] = 544;
  51101. t['Umacron'] = 722;
  51102. t['uring'] = 500;
  51103. t['threesuperior'] = 300;
  51104. t['Ograve'] = 722;
  51105. t['Agrave'] = 611;
  51106. t['Abreve'] = 611;
  51107. t['multiply'] = 675;
  51108. t['uacute'] = 500;
  51109. t['Tcaron'] = 556;
  51110. t['partialdiff'] = 476;
  51111. t['ydieresis'] = 444;
  51112. t['Nacute'] = 667;
  51113. t['icircumflex'] = 278;
  51114. t['Ecircumflex'] = 611;
  51115. t['adieresis'] = 500;
  51116. t['edieresis'] = 444;
  51117. t['cacute'] = 444;
  51118. t['nacute'] = 500;
  51119. t['umacron'] = 500;
  51120. t['Ncaron'] = 667;
  51121. t['Iacute'] = 333;
  51122. t['plusminus'] = 675;
  51123. t['brokenbar'] = 275;
  51124. t['registered'] = 760;
  51125. t['Gbreve'] = 722;
  51126. t['Idotaccent'] = 333;
  51127. t['summation'] = 600;
  51128. t['Egrave'] = 611;
  51129. t['racute'] = 389;
  51130. t['omacron'] = 500;
  51131. t['Zacute'] = 556;
  51132. t['Zcaron'] = 556;
  51133. t['greaterequal'] = 549;
  51134. t['Eth'] = 722;
  51135. t['Ccedilla'] = 667;
  51136. t['lcommaaccent'] = 278;
  51137. t['tcaron'] = 300;
  51138. t['eogonek'] = 444;
  51139. t['Uogonek'] = 722;
  51140. t['Aacute'] = 611;
  51141. t['Adieresis'] = 611;
  51142. t['egrave'] = 444;
  51143. t['zacute'] = 389;
  51144. t['iogonek'] = 278;
  51145. t['Oacute'] = 722;
  51146. t['oacute'] = 500;
  51147. t['amacron'] = 500;
  51148. t['sacute'] = 389;
  51149. t['idieresis'] = 278;
  51150. t['Ocircumflex'] = 722;
  51151. t['Ugrave'] = 722;
  51152. t['Delta'] = 612;
  51153. t['thorn'] = 500;
  51154. t['twosuperior'] = 300;
  51155. t['Odieresis'] = 722;
  51156. t['mu'] = 500;
  51157. t['igrave'] = 278;
  51158. t['ohungarumlaut'] = 500;
  51159. t['Eogonek'] = 611;
  51160. t['dcroat'] = 500;
  51161. t['threequarters'] = 750;
  51162. t['Scedilla'] = 500;
  51163. t['lcaron'] = 300;
  51164. t['Kcommaaccent'] = 667;
  51165. t['Lacute'] = 556;
  51166. t['trademark'] = 980;
  51167. t['edotaccent'] = 444;
  51168. t['Igrave'] = 333;
  51169. t['Imacron'] = 333;
  51170. t['Lcaron'] = 611;
  51171. t['onehalf'] = 750;
  51172. t['lessequal'] = 549;
  51173. t['ocircumflex'] = 500;
  51174. t['ntilde'] = 500;
  51175. t['Uhungarumlaut'] = 722;
  51176. t['Eacute'] = 611;
  51177. t['emacron'] = 444;
  51178. t['gbreve'] = 500;
  51179. t['onequarter'] = 750;
  51180. t['Scaron'] = 500;
  51181. t['Scommaaccent'] = 500;
  51182. t['Ohungarumlaut'] = 722;
  51183. t['degree'] = 400;
  51184. t['ograve'] = 500;
  51185. t['Ccaron'] = 667;
  51186. t['ugrave'] = 500;
  51187. t['radical'] = 453;
  51188. t['Dcaron'] = 722;
  51189. t['rcommaaccent'] = 389;
  51190. t['Ntilde'] = 667;
  51191. t['otilde'] = 500;
  51192. t['Rcommaaccent'] = 611;
  51193. t['Lcommaaccent'] = 556;
  51194. t['Atilde'] = 611;
  51195. t['Aogonek'] = 611;
  51196. t['Aring'] = 611;
  51197. t['Otilde'] = 722;
  51198. t['zdotaccent'] = 389;
  51199. t['Ecaron'] = 611;
  51200. t['Iogonek'] = 333;
  51201. t['kcommaaccent'] = 444;
  51202. t['minus'] = 675;
  51203. t['Icircumflex'] = 333;
  51204. t['ncaron'] = 500;
  51205. t['tcommaaccent'] = 278;
  51206. t['logicalnot'] = 675;
  51207. t['odieresis'] = 500;
  51208. t['udieresis'] = 500;
  51209. t['notequal'] = 549;
  51210. t['gcommaaccent'] = 500;
  51211. t['eth'] = 500;
  51212. t['zcaron'] = 389;
  51213. t['ncommaaccent'] = 500;
  51214. t['onesuperior'] = 300;
  51215. t['imacron'] = 278;
  51216. t['Euro'] = 500;
  51217. });
  51218. t['ZapfDingbats'] = getLookupTableFactory(function (t) {
  51219. t['space'] = 278;
  51220. t['a1'] = 974;
  51221. t['a2'] = 961;
  51222. t['a202'] = 974;
  51223. t['a3'] = 980;
  51224. t['a4'] = 719;
  51225. t['a5'] = 789;
  51226. t['a119'] = 790;
  51227. t['a118'] = 791;
  51228. t['a117'] = 690;
  51229. t['a11'] = 960;
  51230. t['a12'] = 939;
  51231. t['a13'] = 549;
  51232. t['a14'] = 855;
  51233. t['a15'] = 911;
  51234. t['a16'] = 933;
  51235. t['a105'] = 911;
  51236. t['a17'] = 945;
  51237. t['a18'] = 974;
  51238. t['a19'] = 755;
  51239. t['a20'] = 846;
  51240. t['a21'] = 762;
  51241. t['a22'] = 761;
  51242. t['a23'] = 571;
  51243. t['a24'] = 677;
  51244. t['a25'] = 763;
  51245. t['a26'] = 760;
  51246. t['a27'] = 759;
  51247. t['a28'] = 754;
  51248. t['a6'] = 494;
  51249. t['a7'] = 552;
  51250. t['a8'] = 537;
  51251. t['a9'] = 577;
  51252. t['a10'] = 692;
  51253. t['a29'] = 786;
  51254. t['a30'] = 788;
  51255. t['a31'] = 788;
  51256. t['a32'] = 790;
  51257. t['a33'] = 793;
  51258. t['a34'] = 794;
  51259. t['a35'] = 816;
  51260. t['a36'] = 823;
  51261. t['a37'] = 789;
  51262. t['a38'] = 841;
  51263. t['a39'] = 823;
  51264. t['a40'] = 833;
  51265. t['a41'] = 816;
  51266. t['a42'] = 831;
  51267. t['a43'] = 923;
  51268. t['a44'] = 744;
  51269. t['a45'] = 723;
  51270. t['a46'] = 749;
  51271. t['a47'] = 790;
  51272. t['a48'] = 792;
  51273. t['a49'] = 695;
  51274. t['a50'] = 776;
  51275. t['a51'] = 768;
  51276. t['a52'] = 792;
  51277. t['a53'] = 759;
  51278. t['a54'] = 707;
  51279. t['a55'] = 708;
  51280. t['a56'] = 682;
  51281. t['a57'] = 701;
  51282. t['a58'] = 826;
  51283. t['a59'] = 815;
  51284. t['a60'] = 789;
  51285. t['a61'] = 789;
  51286. t['a62'] = 707;
  51287. t['a63'] = 687;
  51288. t['a64'] = 696;
  51289. t['a65'] = 689;
  51290. t['a66'] = 786;
  51291. t['a67'] = 787;
  51292. t['a68'] = 713;
  51293. t['a69'] = 791;
  51294. t['a70'] = 785;
  51295. t['a71'] = 791;
  51296. t['a72'] = 873;
  51297. t['a73'] = 761;
  51298. t['a74'] = 762;
  51299. t['a203'] = 762;
  51300. t['a75'] = 759;
  51301. t['a204'] = 759;
  51302. t['a76'] = 892;
  51303. t['a77'] = 892;
  51304. t['a78'] = 788;
  51305. t['a79'] = 784;
  51306. t['a81'] = 438;
  51307. t['a82'] = 138;
  51308. t['a83'] = 277;
  51309. t['a84'] = 415;
  51310. t['a97'] = 392;
  51311. t['a98'] = 392;
  51312. t['a99'] = 668;
  51313. t['a100'] = 668;
  51314. t['a89'] = 390;
  51315. t['a90'] = 390;
  51316. t['a93'] = 317;
  51317. t['a94'] = 317;
  51318. t['a91'] = 276;
  51319. t['a92'] = 276;
  51320. t['a205'] = 509;
  51321. t['a85'] = 509;
  51322. t['a206'] = 410;
  51323. t['a86'] = 410;
  51324. t['a87'] = 234;
  51325. t['a88'] = 234;
  51326. t['a95'] = 334;
  51327. t['a96'] = 334;
  51328. t['a101'] = 732;
  51329. t['a102'] = 544;
  51330. t['a103'] = 544;
  51331. t['a104'] = 910;
  51332. t['a106'] = 667;
  51333. t['a107'] = 760;
  51334. t['a108'] = 760;
  51335. t['a112'] = 776;
  51336. t['a111'] = 595;
  51337. t['a110'] = 694;
  51338. t['a109'] = 626;
  51339. t['a120'] = 788;
  51340. t['a121'] = 788;
  51341. t['a122'] = 788;
  51342. t['a123'] = 788;
  51343. t['a124'] = 788;
  51344. t['a125'] = 788;
  51345. t['a126'] = 788;
  51346. t['a127'] = 788;
  51347. t['a128'] = 788;
  51348. t['a129'] = 788;
  51349. t['a130'] = 788;
  51350. t['a131'] = 788;
  51351. t['a132'] = 788;
  51352. t['a133'] = 788;
  51353. t['a134'] = 788;
  51354. t['a135'] = 788;
  51355. t['a136'] = 788;
  51356. t['a137'] = 788;
  51357. t['a138'] = 788;
  51358. t['a139'] = 788;
  51359. t['a140'] = 788;
  51360. t['a141'] = 788;
  51361. t['a142'] = 788;
  51362. t['a143'] = 788;
  51363. t['a144'] = 788;
  51364. t['a145'] = 788;
  51365. t['a146'] = 788;
  51366. t['a147'] = 788;
  51367. t['a148'] = 788;
  51368. t['a149'] = 788;
  51369. t['a150'] = 788;
  51370. t['a151'] = 788;
  51371. t['a152'] = 788;
  51372. t['a153'] = 788;
  51373. t['a154'] = 788;
  51374. t['a155'] = 788;
  51375. t['a156'] = 788;
  51376. t['a157'] = 788;
  51377. t['a158'] = 788;
  51378. t['a159'] = 788;
  51379. t['a160'] = 894;
  51380. t['a161'] = 838;
  51381. t['a163'] = 1016;
  51382. t['a164'] = 458;
  51383. t['a196'] = 748;
  51384. t['a165'] = 924;
  51385. t['a192'] = 748;
  51386. t['a166'] = 918;
  51387. t['a167'] = 927;
  51388. t['a168'] = 928;
  51389. t['a169'] = 928;
  51390. t['a170'] = 834;
  51391. t['a171'] = 873;
  51392. t['a172'] = 828;
  51393. t['a173'] = 924;
  51394. t['a162'] = 924;
  51395. t['a174'] = 917;
  51396. t['a175'] = 930;
  51397. t['a176'] = 931;
  51398. t['a177'] = 463;
  51399. t['a178'] = 883;
  51400. t['a179'] = 836;
  51401. t['a193'] = 836;
  51402. t['a180'] = 867;
  51403. t['a199'] = 867;
  51404. t['a181'] = 696;
  51405. t['a200'] = 696;
  51406. t['a182'] = 874;
  51407. t['a201'] = 874;
  51408. t['a183'] = 760;
  51409. t['a184'] = 946;
  51410. t['a197'] = 771;
  51411. t['a185'] = 865;
  51412. t['a194'] = 771;
  51413. t['a198'] = 888;
  51414. t['a186'] = 967;
  51415. t['a195'] = 888;
  51416. t['a187'] = 831;
  51417. t['a188'] = 873;
  51418. t['a189'] = 927;
  51419. t['a190'] = 970;
  51420. t['a191'] = 918;
  51421. });
  51422. });
  51423. exports.getMetrics = getMetrics;
  51424. /***/ }),
  51425. /* 38 */
  51426. /***/ (function(module, exports, __w_pdfjs_require__) {
  51427. "use strict";
  51428. var sharedUtil = __w_pdfjs_require__(0);
  51429. var Uint32ArrayView = sharedUtil.Uint32ArrayView;
  51430. var MurmurHash3_64 = function MurmurHash3_64Closure(seed) {
  51431. var MASK_HIGH = 0xffff0000;
  51432. var MASK_LOW = 0xffff;
  51433. function MurmurHash3_64(seed) {
  51434. var SEED = 0xc3d2e1f0;
  51435. this.h1 = seed ? seed & 0xffffffff : SEED;
  51436. this.h2 = seed ? seed & 0xffffffff : SEED;
  51437. }
  51438. var alwaysUseUint32ArrayView = false;
  51439. try {
  51440. new Uint32Array(new Uint8Array(5).buffer, 0, 1);
  51441. } catch (e) {
  51442. alwaysUseUint32ArrayView = true;
  51443. }
  51444. MurmurHash3_64.prototype = {
  51445. update: function MurmurHash3_64_update(input) {
  51446. var useUint32ArrayView = alwaysUseUint32ArrayView;
  51447. var i;
  51448. if (typeof input === 'string') {
  51449. var data = new Uint8Array(input.length * 2);
  51450. var length = 0;
  51451. for (i = 0; i < input.length; i++) {
  51452. var code = input.charCodeAt(i);
  51453. if (code <= 0xff) {
  51454. data[length++] = code;
  51455. } else {
  51456. data[length++] = code >>> 8;
  51457. data[length++] = code & 0xff;
  51458. }
  51459. }
  51460. } else if (input instanceof Uint8Array) {
  51461. data = input;
  51462. length = data.length;
  51463. } else if (typeof input === 'object' && 'length' in input) {
  51464. data = input;
  51465. length = data.length;
  51466. useUint32ArrayView = true;
  51467. } else {
  51468. throw new Error('Wrong data format in MurmurHash3_64_update. ' + 'Input must be a string or array.');
  51469. }
  51470. var blockCounts = length >> 2;
  51471. var tailLength = length - blockCounts * 4;
  51472. var dataUint32 = useUint32ArrayView ? new Uint32ArrayView(data, blockCounts) : new Uint32Array(data.buffer, 0, blockCounts);
  51473. var k1 = 0;
  51474. var k2 = 0;
  51475. var h1 = this.h1;
  51476. var h2 = this.h2;
  51477. var C1 = 0xcc9e2d51;
  51478. var C2 = 0x1b873593;
  51479. var C1_LOW = C1 & MASK_LOW;
  51480. var C2_LOW = C2 & MASK_LOW;
  51481. for (i = 0; i < blockCounts; i++) {
  51482. if (i & 1) {
  51483. k1 = dataUint32[i];
  51484. k1 = k1 * C1 & MASK_HIGH | k1 * C1_LOW & MASK_LOW;
  51485. k1 = k1 << 15 | k1 >>> 17;
  51486. k1 = k1 * C2 & MASK_HIGH | k1 * C2_LOW & MASK_LOW;
  51487. h1 ^= k1;
  51488. h1 = h1 << 13 | h1 >>> 19;
  51489. h1 = h1 * 5 + 0xe6546b64;
  51490. } else {
  51491. k2 = dataUint32[i];
  51492. k2 = k2 * C1 & MASK_HIGH | k2 * C1_LOW & MASK_LOW;
  51493. k2 = k2 << 15 | k2 >>> 17;
  51494. k2 = k2 * C2 & MASK_HIGH | k2 * C2_LOW & MASK_LOW;
  51495. h2 ^= k2;
  51496. h2 = h2 << 13 | h2 >>> 19;
  51497. h2 = h2 * 5 + 0xe6546b64;
  51498. }
  51499. }
  51500. k1 = 0;
  51501. switch (tailLength) {
  51502. case 3:
  51503. k1 ^= data[blockCounts * 4 + 2] << 16;
  51504. case 2:
  51505. k1 ^= data[blockCounts * 4 + 1] << 8;
  51506. case 1:
  51507. k1 ^= data[blockCounts * 4];
  51508. k1 = k1 * C1 & MASK_HIGH | k1 * C1_LOW & MASK_LOW;
  51509. k1 = k1 << 15 | k1 >>> 17;
  51510. k1 = k1 * C2 & MASK_HIGH | k1 * C2_LOW & MASK_LOW;
  51511. if (blockCounts & 1) {
  51512. h1 ^= k1;
  51513. } else {
  51514. h2 ^= k1;
  51515. }
  51516. }
  51517. this.h1 = h1;
  51518. this.h2 = h2;
  51519. return this;
  51520. },
  51521. hexdigest: function MurmurHash3_64_hexdigest() {
  51522. var h1 = this.h1;
  51523. var h2 = this.h2;
  51524. h1 ^= h2 >>> 1;
  51525. h1 = h1 * 0xed558ccd & MASK_HIGH | h1 * 0x8ccd & MASK_LOW;
  51526. h2 = h2 * 0xff51afd7 & MASK_HIGH | ((h2 << 16 | h1 >>> 16) * 0xafd7ed55 & MASK_HIGH) >>> 16;
  51527. h1 ^= h2 >>> 1;
  51528. h1 = h1 * 0x1a85ec53 & MASK_HIGH | h1 * 0xec53 & MASK_LOW;
  51529. h2 = h2 * 0xc4ceb9fe & MASK_HIGH | ((h2 << 16 | h1 >>> 16) * 0xb9fe1a85 & MASK_HIGH) >>> 16;
  51530. h1 ^= h2 >>> 1;
  51531. for (var i = 0, arr = [
  51532. h1,
  51533. h2
  51534. ], str = ''; i < arr.length; i++) {
  51535. var hex = (arr[i] >>> 0).toString(16);
  51536. while (hex.length < 8) {
  51537. hex = '0' + hex;
  51538. }
  51539. str += hex;
  51540. }
  51541. return str;
  51542. }
  51543. };
  51544. return MurmurHash3_64;
  51545. }();
  51546. exports.MurmurHash3_64 = MurmurHash3_64;
  51547. /***/ }),
  51548. /* 39 */
  51549. /***/ (function(module, exports, __w_pdfjs_require__) {
  51550. "use strict";
  51551. var sharedUtil = __w_pdfjs_require__(0);
  51552. var coreWorker = __w_pdfjs_require__(23);
  51553. var globalScope = sharedUtil.globalScope;
  51554. var OK_RESPONSE = 200;
  51555. var PARTIAL_CONTENT_RESPONSE = 206;
  51556. function NetworkManager(url, args) {
  51557. this.url = url;
  51558. args = args || {};
  51559. this.isHttp = /^https?:/i.test(url);
  51560. this.httpHeaders = this.isHttp && args.httpHeaders || {};
  51561. this.withCredentials = args.withCredentials || false;
  51562. this.getXhr = args.getXhr || function NetworkManager_getXhr() {
  51563. return new XMLHttpRequest();
  51564. };
  51565. this.currXhrId = 0;
  51566. this.pendingRequests = Object.create(null);
  51567. this.loadedRequests = Object.create(null);
  51568. }
  51569. function getArrayBuffer(xhr) {
  51570. var data = xhr.response;
  51571. if (typeof data !== 'string') {
  51572. return data;
  51573. }
  51574. var length = data.length;
  51575. var array = new Uint8Array(length);
  51576. for (var i = 0; i < length; i++) {
  51577. array[i] = data.charCodeAt(i) & 0xFF;
  51578. }
  51579. return array.buffer;
  51580. }
  51581. var supportsMozChunked = function supportsMozChunkedClosure() {
  51582. try {
  51583. var x = new XMLHttpRequest();
  51584. x.open('GET', globalScope.location.href);
  51585. x.responseType = 'moz-chunked-arraybuffer';
  51586. return x.responseType === 'moz-chunked-arraybuffer';
  51587. } catch (e) {
  51588. return false;
  51589. }
  51590. }();
  51591. NetworkManager.prototype = {
  51592. requestRange: function NetworkManager_requestRange(begin, end, listeners) {
  51593. var args = {
  51594. begin: begin,
  51595. end: end
  51596. };
  51597. for (var prop in listeners) {
  51598. args[prop] = listeners[prop];
  51599. }
  51600. return this.request(args);
  51601. },
  51602. requestFull: function NetworkManager_requestFull(listeners) {
  51603. return this.request(listeners);
  51604. },
  51605. request: function NetworkManager_request(args) {
  51606. var xhr = this.getXhr();
  51607. var xhrId = this.currXhrId++;
  51608. var pendingRequest = this.pendingRequests[xhrId] = { xhr: xhr };
  51609. xhr.open('GET', this.url);
  51610. xhr.withCredentials = this.withCredentials;
  51611. for (var property in this.httpHeaders) {
  51612. var value = this.httpHeaders[property];
  51613. if (typeof value === 'undefined') {
  51614. continue;
  51615. }
  51616. xhr.setRequestHeader(property, value);
  51617. }
  51618. if (this.isHttp && 'begin' in args && 'end' in args) {
  51619. var rangeStr = args.begin + '-' + (args.end - 1);
  51620. xhr.setRequestHeader('Range', 'bytes=' + rangeStr);
  51621. pendingRequest.expectedStatus = 206;
  51622. } else {
  51623. pendingRequest.expectedStatus = 200;
  51624. }
  51625. var useMozChunkedLoading = supportsMozChunked && !!args.onProgressiveData;
  51626. if (useMozChunkedLoading) {
  51627. xhr.responseType = 'moz-chunked-arraybuffer';
  51628. pendingRequest.onProgressiveData = args.onProgressiveData;
  51629. pendingRequest.mozChunked = true;
  51630. } else {
  51631. xhr.responseType = 'arraybuffer';
  51632. }
  51633. if (args.onError) {
  51634. xhr.onerror = function (evt) {
  51635. args.onError(xhr.status);
  51636. };
  51637. }
  51638. xhr.onreadystatechange = this.onStateChange.bind(this, xhrId);
  51639. xhr.onprogress = this.onProgress.bind(this, xhrId);
  51640. pendingRequest.onHeadersReceived = args.onHeadersReceived;
  51641. pendingRequest.onDone = args.onDone;
  51642. pendingRequest.onError = args.onError;
  51643. pendingRequest.onProgress = args.onProgress;
  51644. xhr.send(null);
  51645. return xhrId;
  51646. },
  51647. onProgress: function NetworkManager_onProgress(xhrId, evt) {
  51648. var pendingRequest = this.pendingRequests[xhrId];
  51649. if (!pendingRequest) {
  51650. return;
  51651. }
  51652. if (pendingRequest.mozChunked) {
  51653. var chunk = getArrayBuffer(pendingRequest.xhr);
  51654. pendingRequest.onProgressiveData(chunk);
  51655. }
  51656. var onProgress = pendingRequest.onProgress;
  51657. if (onProgress) {
  51658. onProgress(evt);
  51659. }
  51660. },
  51661. onStateChange: function NetworkManager_onStateChange(xhrId, evt) {
  51662. var pendingRequest = this.pendingRequests[xhrId];
  51663. if (!pendingRequest) {
  51664. return;
  51665. }
  51666. var xhr = pendingRequest.xhr;
  51667. if (xhr.readyState >= 2 && pendingRequest.onHeadersReceived) {
  51668. pendingRequest.onHeadersReceived();
  51669. delete pendingRequest.onHeadersReceived;
  51670. }
  51671. if (xhr.readyState !== 4) {
  51672. return;
  51673. }
  51674. if (!(xhrId in this.pendingRequests)) {
  51675. return;
  51676. }
  51677. delete this.pendingRequests[xhrId];
  51678. if (xhr.status === 0 && this.isHttp) {
  51679. if (pendingRequest.onError) {
  51680. pendingRequest.onError(xhr.status);
  51681. }
  51682. return;
  51683. }
  51684. var xhrStatus = xhr.status || OK_RESPONSE;
  51685. var ok_response_on_range_request = xhrStatus === OK_RESPONSE && pendingRequest.expectedStatus === PARTIAL_CONTENT_RESPONSE;
  51686. if (!ok_response_on_range_request && xhrStatus !== pendingRequest.expectedStatus) {
  51687. if (pendingRequest.onError) {
  51688. pendingRequest.onError(xhr.status);
  51689. }
  51690. return;
  51691. }
  51692. this.loadedRequests[xhrId] = true;
  51693. var chunk = getArrayBuffer(xhr);
  51694. if (xhrStatus === PARTIAL_CONTENT_RESPONSE) {
  51695. var rangeHeader = xhr.getResponseHeader('Content-Range');
  51696. var matches = /bytes (\d+)-(\d+)\/(\d+)/.exec(rangeHeader);
  51697. var begin = parseInt(matches[1], 10);
  51698. pendingRequest.onDone({
  51699. begin: begin,
  51700. chunk: chunk
  51701. });
  51702. } else if (pendingRequest.onProgressiveData) {
  51703. pendingRequest.onDone(null);
  51704. } else if (chunk) {
  51705. pendingRequest.onDone({
  51706. begin: 0,
  51707. chunk: chunk
  51708. });
  51709. } else if (pendingRequest.onError) {
  51710. pendingRequest.onError(xhr.status);
  51711. }
  51712. },
  51713. hasPendingRequests: function NetworkManager_hasPendingRequests() {
  51714. for (var xhrId in this.pendingRequests) {
  51715. return true;
  51716. }
  51717. return false;
  51718. },
  51719. getRequestXhr: function NetworkManager_getXhr(xhrId) {
  51720. return this.pendingRequests[xhrId].xhr;
  51721. },
  51722. isStreamingRequest: function NetworkManager_isStreamingRequest(xhrId) {
  51723. return !!this.pendingRequests[xhrId].onProgressiveData;
  51724. },
  51725. isPendingRequest: function NetworkManager_isPendingRequest(xhrId) {
  51726. return xhrId in this.pendingRequests;
  51727. },
  51728. isLoadedRequest: function NetworkManager_isLoadedRequest(xhrId) {
  51729. return xhrId in this.loadedRequests;
  51730. },
  51731. abortAllRequests: function NetworkManager_abortAllRequests() {
  51732. for (var xhrId in this.pendingRequests) {
  51733. this.abortRequest(xhrId | 0);
  51734. }
  51735. },
  51736. abortRequest: function NetworkManager_abortRequest(xhrId) {
  51737. var xhr = this.pendingRequests[xhrId].xhr;
  51738. delete this.pendingRequests[xhrId];
  51739. xhr.abort();
  51740. }
  51741. };
  51742. var assert = sharedUtil.assert;
  51743. var createPromiseCapability = sharedUtil.createPromiseCapability;
  51744. var isInt = sharedUtil.isInt;
  51745. var MissingPDFException = sharedUtil.MissingPDFException;
  51746. var UnexpectedResponseException = sharedUtil.UnexpectedResponseException;
  51747. function PDFNetworkStream(options) {
  51748. this._options = options;
  51749. var source = options.source;
  51750. this._manager = new NetworkManager(source.url, {
  51751. httpHeaders: source.httpHeaders,
  51752. withCredentials: source.withCredentials
  51753. });
  51754. this._rangeChunkSize = source.rangeChunkSize;
  51755. this._fullRequestReader = null;
  51756. this._rangeRequestReaders = [];
  51757. }
  51758. PDFNetworkStream.prototype = {
  51759. _onRangeRequestReaderClosed: function PDFNetworkStream_onRangeRequestReaderClosed(reader) {
  51760. var i = this._rangeRequestReaders.indexOf(reader);
  51761. if (i >= 0) {
  51762. this._rangeRequestReaders.splice(i, 1);
  51763. }
  51764. },
  51765. getFullReader: function PDFNetworkStream_getFullReader() {
  51766. assert(!this._fullRequestReader);
  51767. this._fullRequestReader = new PDFNetworkStreamFullRequestReader(this._manager, this._options);
  51768. return this._fullRequestReader;
  51769. },
  51770. getRangeReader: function PDFNetworkStream_getRangeReader(begin, end) {
  51771. var reader = new PDFNetworkStreamRangeRequestReader(this._manager, begin, end);
  51772. reader.onClosed = this._onRangeRequestReaderClosed.bind(this);
  51773. this._rangeRequestReaders.push(reader);
  51774. return reader;
  51775. },
  51776. cancelAllRequests: function PDFNetworkStream_cancelAllRequests(reason) {
  51777. if (this._fullRequestReader) {
  51778. this._fullRequestReader.cancel(reason);
  51779. }
  51780. var readers = this._rangeRequestReaders.slice(0);
  51781. readers.forEach(function (reader) {
  51782. reader.cancel(reason);
  51783. });
  51784. }
  51785. };
  51786. function PDFNetworkStreamFullRequestReader(manager, options) {
  51787. this._manager = manager;
  51788. var source = options.source;
  51789. var args = {
  51790. onHeadersReceived: this._onHeadersReceived.bind(this),
  51791. onProgressiveData: source.disableStream ? null : this._onProgressiveData.bind(this),
  51792. onDone: this._onDone.bind(this),
  51793. onError: this._onError.bind(this),
  51794. onProgress: this._onProgress.bind(this)
  51795. };
  51796. this._url = source.url;
  51797. this._fullRequestId = manager.requestFull(args);
  51798. this._headersReceivedCapability = createPromiseCapability();
  51799. this._disableRange = options.disableRange || false;
  51800. this._contentLength = source.length;
  51801. this._rangeChunkSize = source.rangeChunkSize;
  51802. if (!this._rangeChunkSize && !this._disableRange) {
  51803. this._disableRange = true;
  51804. }
  51805. this._isStreamingSupported = false;
  51806. this._isRangeSupported = false;
  51807. this._cachedChunks = [];
  51808. this._requests = [];
  51809. this._done = false;
  51810. this._storedError = undefined;
  51811. this.onProgress = null;
  51812. }
  51813. PDFNetworkStreamFullRequestReader.prototype = {
  51814. _validateRangeRequestCapabilities: function PDFNetworkStreamFullRequestReader_validateRangeRequestCapabilities() {
  51815. if (this._disableRange) {
  51816. return false;
  51817. }
  51818. var networkManager = this._manager;
  51819. if (!networkManager.isHttp) {
  51820. return false;
  51821. }
  51822. var fullRequestXhrId = this._fullRequestId;
  51823. var fullRequestXhr = networkManager.getRequestXhr(fullRequestXhrId);
  51824. if (fullRequestXhr.getResponseHeader('Accept-Ranges') !== 'bytes') {
  51825. return false;
  51826. }
  51827. var contentEncoding = fullRequestXhr.getResponseHeader('Content-Encoding') || 'identity';
  51828. if (contentEncoding !== 'identity') {
  51829. return false;
  51830. }
  51831. var length = fullRequestXhr.getResponseHeader('Content-Length');
  51832. length = parseInt(length, 10);
  51833. if (!isInt(length)) {
  51834. return false;
  51835. }
  51836. this._contentLength = length;
  51837. if (length <= 2 * this._rangeChunkSize) {
  51838. return false;
  51839. }
  51840. return true;
  51841. },
  51842. _onHeadersReceived: function PDFNetworkStreamFullRequestReader_onHeadersReceived() {
  51843. if (this._validateRangeRequestCapabilities()) {
  51844. this._isRangeSupported = true;
  51845. }
  51846. var networkManager = this._manager;
  51847. var fullRequestXhrId = this._fullRequestId;
  51848. if (networkManager.isStreamingRequest(fullRequestXhrId)) {
  51849. this._isStreamingSupported = true;
  51850. } else if (this._isRangeSupported) {
  51851. networkManager.abortRequest(fullRequestXhrId);
  51852. }
  51853. this._headersReceivedCapability.resolve();
  51854. },
  51855. _onProgressiveData: function PDFNetworkStreamFullRequestReader_onProgressiveData(chunk) {
  51856. if (this._requests.length > 0) {
  51857. var requestCapability = this._requests.shift();
  51858. requestCapability.resolve({
  51859. value: chunk,
  51860. done: false
  51861. });
  51862. } else {
  51863. this._cachedChunks.push(chunk);
  51864. }
  51865. },
  51866. _onDone: function PDFNetworkStreamFullRequestReader_onDone(args) {
  51867. if (args) {
  51868. this._onProgressiveData(args.chunk);
  51869. }
  51870. this._done = true;
  51871. if (this._cachedChunks.length > 0) {
  51872. return;
  51873. }
  51874. this._requests.forEach(function (requestCapability) {
  51875. requestCapability.resolve({
  51876. value: undefined,
  51877. done: true
  51878. });
  51879. });
  51880. this._requests = [];
  51881. },
  51882. _onError: function PDFNetworkStreamFullRequestReader_onError(status) {
  51883. var url = this._url;
  51884. var exception;
  51885. if (status === 404 || status === 0 && /^file:/.test(url)) {
  51886. exception = new MissingPDFException('Missing PDF "' + url + '".');
  51887. } else {
  51888. exception = new UnexpectedResponseException('Unexpected server response (' + status + ') while retrieving PDF "' + url + '".', status);
  51889. }
  51890. this._storedError = exception;
  51891. this._headersReceivedCapability.reject(exception);
  51892. this._requests.forEach(function (requestCapability) {
  51893. requestCapability.reject(exception);
  51894. });
  51895. this._requests = [];
  51896. this._cachedChunks = [];
  51897. },
  51898. _onProgress: function PDFNetworkStreamFullRequestReader_onProgress(data) {
  51899. if (this.onProgress) {
  51900. this.onProgress({
  51901. loaded: data.loaded,
  51902. total: data.lengthComputable ? data.total : this._contentLength
  51903. });
  51904. }
  51905. },
  51906. get isRangeSupported() {
  51907. return this._isRangeSupported;
  51908. },
  51909. get isStreamingSupported() {
  51910. return this._isStreamingSupported;
  51911. },
  51912. get contentLength() {
  51913. return this._contentLength;
  51914. },
  51915. get headersReady() {
  51916. return this._headersReceivedCapability.promise;
  51917. },
  51918. read: function PDFNetworkStreamFullRequestReader_read() {
  51919. if (this._storedError) {
  51920. return Promise.reject(this._storedError);
  51921. }
  51922. if (this._cachedChunks.length > 0) {
  51923. var chunk = this._cachedChunks.shift();
  51924. return Promise.resolve(chunk);
  51925. }
  51926. if (this._done) {
  51927. return Promise.resolve({
  51928. value: undefined,
  51929. done: true
  51930. });
  51931. }
  51932. var requestCapability = createPromiseCapability();
  51933. this._requests.push(requestCapability);
  51934. return requestCapability.promise;
  51935. },
  51936. cancel: function PDFNetworkStreamFullRequestReader_cancel(reason) {
  51937. this._done = true;
  51938. this._headersReceivedCapability.reject(reason);
  51939. this._requests.forEach(function (requestCapability) {
  51940. requestCapability.resolve({
  51941. value: undefined,
  51942. done: true
  51943. });
  51944. });
  51945. this._requests = [];
  51946. if (this._manager.isPendingRequest(this._fullRequestId)) {
  51947. this._manager.abortRequest(this._fullRequestId);
  51948. }
  51949. this._fullRequestReader = null;
  51950. }
  51951. };
  51952. function PDFNetworkStreamRangeRequestReader(manager, begin, end) {
  51953. this._manager = manager;
  51954. var args = {
  51955. onDone: this._onDone.bind(this),
  51956. onProgress: this._onProgress.bind(this)
  51957. };
  51958. this._requestId = manager.requestRange(begin, end, args);
  51959. this._requests = [];
  51960. this._queuedChunk = null;
  51961. this._done = false;
  51962. this.onProgress = null;
  51963. this.onClosed = null;
  51964. }
  51965. PDFNetworkStreamRangeRequestReader.prototype = {
  51966. _close: function PDFNetworkStreamRangeRequestReader_close() {
  51967. if (this.onClosed) {
  51968. this.onClosed(this);
  51969. }
  51970. },
  51971. _onDone: function PDFNetworkStreamRangeRequestReader_onDone(data) {
  51972. var chunk = data.chunk;
  51973. if (this._requests.length > 0) {
  51974. var requestCapability = this._requests.shift();
  51975. requestCapability.resolve({
  51976. value: chunk,
  51977. done: false
  51978. });
  51979. } else {
  51980. this._queuedChunk = chunk;
  51981. }
  51982. this._done = true;
  51983. this._requests.forEach(function (requestCapability) {
  51984. requestCapability.resolve({
  51985. value: undefined,
  51986. done: true
  51987. });
  51988. });
  51989. this._requests = [];
  51990. this._close();
  51991. },
  51992. _onProgress: function PDFNetworkStreamRangeRequestReader_onProgress(evt) {
  51993. if (!this.isStreamingSupported && this.onProgress) {
  51994. this.onProgress({ loaded: evt.loaded });
  51995. }
  51996. },
  51997. get isStreamingSupported() {
  51998. return false;
  51999. },
  52000. read: function PDFNetworkStreamRangeRequestReader_read() {
  52001. if (this._queuedChunk !== null) {
  52002. var chunk = this._queuedChunk;
  52003. this._queuedChunk = null;
  52004. return Promise.resolve({
  52005. value: chunk,
  52006. done: false
  52007. });
  52008. }
  52009. if (this._done) {
  52010. return Promise.resolve({
  52011. value: undefined,
  52012. done: true
  52013. });
  52014. }
  52015. var requestCapability = createPromiseCapability();
  52016. this._requests.push(requestCapability);
  52017. return requestCapability.promise;
  52018. },
  52019. cancel: function PDFNetworkStreamRangeRequestReader_cancel(reason) {
  52020. this._done = true;
  52021. this._requests.forEach(function (requestCapability) {
  52022. requestCapability.resolve({
  52023. value: undefined,
  52024. done: true
  52025. });
  52026. });
  52027. this._requests = [];
  52028. if (this._manager.isPendingRequest(this._requestId)) {
  52029. this._manager.abortRequest(this._requestId);
  52030. }
  52031. this._close();
  52032. }
  52033. };
  52034. coreWorker.setPDFNetworkStreamClass(PDFNetworkStream);
  52035. exports.PDFNetworkStream = PDFNetworkStream;
  52036. exports.NetworkManager = NetworkManager;
  52037. /***/ }),
  52038. /* 40 */
  52039. /***/ (function(module, exports, __w_pdfjs_require__) {
  52040. "use strict";
  52041. var sharedUtil = __w_pdfjs_require__(0);
  52042. var corePrimitives = __w_pdfjs_require__(1);
  52043. var coreFunction = __w_pdfjs_require__(7);
  52044. var coreColorSpace = __w_pdfjs_require__(4);
  52045. var UNSUPPORTED_FEATURES = sharedUtil.UNSUPPORTED_FEATURES;
  52046. var MissingDataException = sharedUtil.MissingDataException;
  52047. var Util = sharedUtil.Util;
  52048. var assert = sharedUtil.assert;
  52049. var error = sharedUtil.error;
  52050. var info = sharedUtil.info;
  52051. var warn = sharedUtil.warn;
  52052. var isStream = corePrimitives.isStream;
  52053. var PDFFunction = coreFunction.PDFFunction;
  52054. var ColorSpace = coreColorSpace.ColorSpace;
  52055. var ShadingType = {
  52056. FUNCTION_BASED: 1,
  52057. AXIAL: 2,
  52058. RADIAL: 3,
  52059. FREE_FORM_MESH: 4,
  52060. LATTICE_FORM_MESH: 5,
  52061. COONS_PATCH_MESH: 6,
  52062. TENSOR_PATCH_MESH: 7
  52063. };
  52064. var Pattern = function PatternClosure() {
  52065. function Pattern() {
  52066. error('should not call Pattern constructor');
  52067. }
  52068. Pattern.prototype = {
  52069. getPattern: function Pattern_getPattern(ctx) {
  52070. error('Should not call Pattern.getStyle: ' + ctx);
  52071. }
  52072. };
  52073. Pattern.parseShading = function Pattern_parseShading(shading, matrix, xref, res, handler) {
  52074. var dict = isStream(shading) ? shading.dict : shading;
  52075. var type = dict.get('ShadingType');
  52076. try {
  52077. switch (type) {
  52078. case ShadingType.AXIAL:
  52079. case ShadingType.RADIAL:
  52080. return new Shadings.RadialAxial(dict, matrix, xref, res);
  52081. case ShadingType.FREE_FORM_MESH:
  52082. case ShadingType.LATTICE_FORM_MESH:
  52083. case ShadingType.COONS_PATCH_MESH:
  52084. case ShadingType.TENSOR_PATCH_MESH:
  52085. return new Shadings.Mesh(shading, matrix, xref, res);
  52086. default:
  52087. throw new Error('Unsupported ShadingType: ' + type);
  52088. }
  52089. } catch (ex) {
  52090. if (ex instanceof MissingDataException) {
  52091. throw ex;
  52092. }
  52093. handler.send('UnsupportedFeature', { featureId: UNSUPPORTED_FEATURES.shadingPattern });
  52094. warn(ex);
  52095. return new Shadings.Dummy();
  52096. }
  52097. };
  52098. return Pattern;
  52099. }();
  52100. var Shadings = {};
  52101. Shadings.SMALL_NUMBER = 1e-6;
  52102. Shadings.RadialAxial = function RadialAxialClosure() {
  52103. function RadialAxial(dict, matrix, xref, res) {
  52104. this.matrix = matrix;
  52105. this.coordsArr = dict.getArray('Coords');
  52106. this.shadingType = dict.get('ShadingType');
  52107. this.type = 'Pattern';
  52108. var cs = dict.get('ColorSpace', 'CS');
  52109. cs = ColorSpace.parse(cs, xref, res);
  52110. this.cs = cs;
  52111. var t0 = 0.0, t1 = 1.0;
  52112. if (dict.has('Domain')) {
  52113. var domainArr = dict.getArray('Domain');
  52114. t0 = domainArr[0];
  52115. t1 = domainArr[1];
  52116. }
  52117. var extendStart = false, extendEnd = false;
  52118. if (dict.has('Extend')) {
  52119. var extendArr = dict.getArray('Extend');
  52120. extendStart = extendArr[0];
  52121. extendEnd = extendArr[1];
  52122. }
  52123. if (this.shadingType === ShadingType.RADIAL && (!extendStart || !extendEnd)) {
  52124. var x1 = this.coordsArr[0];
  52125. var y1 = this.coordsArr[1];
  52126. var r1 = this.coordsArr[2];
  52127. var x2 = this.coordsArr[3];
  52128. var y2 = this.coordsArr[4];
  52129. var r2 = this.coordsArr[5];
  52130. var distance = Math.sqrt((x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2));
  52131. if (r1 <= r2 + distance && r2 <= r1 + distance) {
  52132. warn('Unsupported radial gradient.');
  52133. }
  52134. }
  52135. this.extendStart = extendStart;
  52136. this.extendEnd = extendEnd;
  52137. var fnObj = dict.get('Function');
  52138. var fn = PDFFunction.parseArray(xref, fnObj);
  52139. var diff = t1 - t0;
  52140. var step = diff / 10;
  52141. var colorStops = this.colorStops = [];
  52142. if (t0 >= t1 || step <= 0) {
  52143. info('Bad shading domain.');
  52144. return;
  52145. }
  52146. var color = new Float32Array(cs.numComps), ratio = new Float32Array(1);
  52147. var rgbColor;
  52148. for (var i = t0; i <= t1; i += step) {
  52149. ratio[0] = i;
  52150. fn(ratio, 0, color, 0);
  52151. rgbColor = cs.getRgb(color, 0);
  52152. var cssColor = Util.makeCssRgb(rgbColor[0], rgbColor[1], rgbColor[2]);
  52153. colorStops.push([
  52154. (i - t0) / diff,
  52155. cssColor
  52156. ]);
  52157. }
  52158. var background = 'transparent';
  52159. if (dict.has('Background')) {
  52160. rgbColor = cs.getRgb(dict.get('Background'), 0);
  52161. background = Util.makeCssRgb(rgbColor[0], rgbColor[1], rgbColor[2]);
  52162. }
  52163. if (!extendStart) {
  52164. colorStops.unshift([
  52165. 0,
  52166. background
  52167. ]);
  52168. colorStops[1][0] += Shadings.SMALL_NUMBER;
  52169. }
  52170. if (!extendEnd) {
  52171. colorStops[colorStops.length - 1][0] -= Shadings.SMALL_NUMBER;
  52172. colorStops.push([
  52173. 1,
  52174. background
  52175. ]);
  52176. }
  52177. this.colorStops = colorStops;
  52178. }
  52179. RadialAxial.prototype = {
  52180. getIR: function RadialAxial_getIR() {
  52181. var coordsArr = this.coordsArr;
  52182. var shadingType = this.shadingType;
  52183. var type, p0, p1, r0, r1;
  52184. if (shadingType === ShadingType.AXIAL) {
  52185. p0 = [
  52186. coordsArr[0],
  52187. coordsArr[1]
  52188. ];
  52189. p1 = [
  52190. coordsArr[2],
  52191. coordsArr[3]
  52192. ];
  52193. r0 = null;
  52194. r1 = null;
  52195. type = 'axial';
  52196. } else if (shadingType === ShadingType.RADIAL) {
  52197. p0 = [
  52198. coordsArr[0],
  52199. coordsArr[1]
  52200. ];
  52201. p1 = [
  52202. coordsArr[3],
  52203. coordsArr[4]
  52204. ];
  52205. r0 = coordsArr[2];
  52206. r1 = coordsArr[5];
  52207. type = 'radial';
  52208. } else {
  52209. error('getPattern type unknown: ' + shadingType);
  52210. }
  52211. var matrix = this.matrix;
  52212. if (matrix) {
  52213. p0 = Util.applyTransform(p0, matrix);
  52214. p1 = Util.applyTransform(p1, matrix);
  52215. if (shadingType === ShadingType.RADIAL) {
  52216. var scale = Util.singularValueDecompose2dScale(matrix);
  52217. r0 *= scale[0];
  52218. r1 *= scale[1];
  52219. }
  52220. }
  52221. return [
  52222. 'RadialAxial',
  52223. type,
  52224. this.colorStops,
  52225. p0,
  52226. p1,
  52227. r0,
  52228. r1
  52229. ];
  52230. }
  52231. };
  52232. return RadialAxial;
  52233. }();
  52234. Shadings.Mesh = function MeshClosure() {
  52235. function MeshStreamReader(stream, context) {
  52236. this.stream = stream;
  52237. this.context = context;
  52238. this.buffer = 0;
  52239. this.bufferLength = 0;
  52240. var numComps = context.numComps;
  52241. this.tmpCompsBuf = new Float32Array(numComps);
  52242. var csNumComps = context.colorSpace.numComps;
  52243. this.tmpCsCompsBuf = context.colorFn ? new Float32Array(csNumComps) : this.tmpCompsBuf;
  52244. }
  52245. MeshStreamReader.prototype = {
  52246. get hasData() {
  52247. if (this.stream.end) {
  52248. return this.stream.pos < this.stream.end;
  52249. }
  52250. if (this.bufferLength > 0) {
  52251. return true;
  52252. }
  52253. var nextByte = this.stream.getByte();
  52254. if (nextByte < 0) {
  52255. return false;
  52256. }
  52257. this.buffer = nextByte;
  52258. this.bufferLength = 8;
  52259. return true;
  52260. },
  52261. readBits: function MeshStreamReader_readBits(n) {
  52262. var buffer = this.buffer;
  52263. var bufferLength = this.bufferLength;
  52264. if (n === 32) {
  52265. if (bufferLength === 0) {
  52266. return (this.stream.getByte() << 24 | this.stream.getByte() << 16 | this.stream.getByte() << 8 | this.stream.getByte()) >>> 0;
  52267. }
  52268. buffer = buffer << 24 | this.stream.getByte() << 16 | this.stream.getByte() << 8 | this.stream.getByte();
  52269. var nextByte = this.stream.getByte();
  52270. this.buffer = nextByte & (1 << bufferLength) - 1;
  52271. return (buffer << 8 - bufferLength | (nextByte & 0xFF) >> bufferLength) >>> 0;
  52272. }
  52273. if (n === 8 && bufferLength === 0) {
  52274. return this.stream.getByte();
  52275. }
  52276. while (bufferLength < n) {
  52277. buffer = buffer << 8 | this.stream.getByte();
  52278. bufferLength += 8;
  52279. }
  52280. bufferLength -= n;
  52281. this.bufferLength = bufferLength;
  52282. this.buffer = buffer & (1 << bufferLength) - 1;
  52283. return buffer >> bufferLength;
  52284. },
  52285. align: function MeshStreamReader_align() {
  52286. this.buffer = 0;
  52287. this.bufferLength = 0;
  52288. },
  52289. readFlag: function MeshStreamReader_readFlag() {
  52290. return this.readBits(this.context.bitsPerFlag);
  52291. },
  52292. readCoordinate: function MeshStreamReader_readCoordinate() {
  52293. var bitsPerCoordinate = this.context.bitsPerCoordinate;
  52294. var xi = this.readBits(bitsPerCoordinate);
  52295. var yi = this.readBits(bitsPerCoordinate);
  52296. var decode = this.context.decode;
  52297. var scale = bitsPerCoordinate < 32 ? 1 / ((1 << bitsPerCoordinate) - 1) : 2.3283064365386963e-10;
  52298. return [
  52299. xi * scale * (decode[1] - decode[0]) + decode[0],
  52300. yi * scale * (decode[3] - decode[2]) + decode[2]
  52301. ];
  52302. },
  52303. readComponents: function MeshStreamReader_readComponents() {
  52304. var numComps = this.context.numComps;
  52305. var bitsPerComponent = this.context.bitsPerComponent;
  52306. var scale = bitsPerComponent < 32 ? 1 / ((1 << bitsPerComponent) - 1) : 2.3283064365386963e-10;
  52307. var decode = this.context.decode;
  52308. var components = this.tmpCompsBuf;
  52309. for (var i = 0, j = 4; i < numComps; i++, j += 2) {
  52310. var ci = this.readBits(bitsPerComponent);
  52311. components[i] = ci * scale * (decode[j + 1] - decode[j]) + decode[j];
  52312. }
  52313. var color = this.tmpCsCompsBuf;
  52314. if (this.context.colorFn) {
  52315. this.context.colorFn(components, 0, color, 0);
  52316. }
  52317. return this.context.colorSpace.getRgb(color, 0);
  52318. }
  52319. };
  52320. function decodeType4Shading(mesh, reader) {
  52321. var coords = mesh.coords;
  52322. var colors = mesh.colors;
  52323. var operators = [];
  52324. var ps = [];
  52325. var verticesLeft = 0;
  52326. while (reader.hasData) {
  52327. var f = reader.readFlag();
  52328. var coord = reader.readCoordinate();
  52329. var color = reader.readComponents();
  52330. if (verticesLeft === 0) {
  52331. assert(0 <= f && f <= 2, 'Unknown type4 flag');
  52332. switch (f) {
  52333. case 0:
  52334. verticesLeft = 3;
  52335. break;
  52336. case 1:
  52337. ps.push(ps[ps.length - 2], ps[ps.length - 1]);
  52338. verticesLeft = 1;
  52339. break;
  52340. case 2:
  52341. ps.push(ps[ps.length - 3], ps[ps.length - 1]);
  52342. verticesLeft = 1;
  52343. break;
  52344. }
  52345. operators.push(f);
  52346. }
  52347. ps.push(coords.length);
  52348. coords.push(coord);
  52349. colors.push(color);
  52350. verticesLeft--;
  52351. reader.align();
  52352. }
  52353. mesh.figures.push({
  52354. type: 'triangles',
  52355. coords: new Int32Array(ps),
  52356. colors: new Int32Array(ps)
  52357. });
  52358. }
  52359. function decodeType5Shading(mesh, reader, verticesPerRow) {
  52360. var coords = mesh.coords;
  52361. var colors = mesh.colors;
  52362. var ps = [];
  52363. while (reader.hasData) {
  52364. var coord = reader.readCoordinate();
  52365. var color = reader.readComponents();
  52366. ps.push(coords.length);
  52367. coords.push(coord);
  52368. colors.push(color);
  52369. }
  52370. mesh.figures.push({
  52371. type: 'lattice',
  52372. coords: new Int32Array(ps),
  52373. colors: new Int32Array(ps),
  52374. verticesPerRow: verticesPerRow
  52375. });
  52376. }
  52377. var MIN_SPLIT_PATCH_CHUNKS_AMOUNT = 3;
  52378. var MAX_SPLIT_PATCH_CHUNKS_AMOUNT = 20;
  52379. var TRIANGLE_DENSITY = 20;
  52380. var getB = function getBClosure() {
  52381. function buildB(count) {
  52382. var lut = [];
  52383. for (var i = 0; i <= count; i++) {
  52384. var t = i / count, t_ = 1 - t;
  52385. lut.push(new Float32Array([
  52386. t_ * t_ * t_,
  52387. 3 * t * t_ * t_,
  52388. 3 * t * t * t_,
  52389. t * t * t
  52390. ]));
  52391. }
  52392. return lut;
  52393. }
  52394. var cache = [];
  52395. return function getB(count) {
  52396. if (!cache[count]) {
  52397. cache[count] = buildB(count);
  52398. }
  52399. return cache[count];
  52400. };
  52401. }();
  52402. function buildFigureFromPatch(mesh, index) {
  52403. var figure = mesh.figures[index];
  52404. assert(figure.type === 'patch', 'Unexpected patch mesh figure');
  52405. var coords = mesh.coords, colors = mesh.colors;
  52406. var pi = figure.coords;
  52407. var ci = figure.colors;
  52408. var figureMinX = Math.min(coords[pi[0]][0], coords[pi[3]][0], coords[pi[12]][0], coords[pi[15]][0]);
  52409. var figureMinY = Math.min(coords[pi[0]][1], coords[pi[3]][1], coords[pi[12]][1], coords[pi[15]][1]);
  52410. var figureMaxX = Math.max(coords[pi[0]][0], coords[pi[3]][0], coords[pi[12]][0], coords[pi[15]][0]);
  52411. var figureMaxY = Math.max(coords[pi[0]][1], coords[pi[3]][1], coords[pi[12]][1], coords[pi[15]][1]);
  52412. var splitXBy = Math.ceil((figureMaxX - figureMinX) * TRIANGLE_DENSITY / (mesh.bounds[2] - mesh.bounds[0]));
  52413. splitXBy = Math.max(MIN_SPLIT_PATCH_CHUNKS_AMOUNT, Math.min(MAX_SPLIT_PATCH_CHUNKS_AMOUNT, splitXBy));
  52414. var splitYBy = Math.ceil((figureMaxY - figureMinY) * TRIANGLE_DENSITY / (mesh.bounds[3] - mesh.bounds[1]));
  52415. splitYBy = Math.max(MIN_SPLIT_PATCH_CHUNKS_AMOUNT, Math.min(MAX_SPLIT_PATCH_CHUNKS_AMOUNT, splitYBy));
  52416. var verticesPerRow = splitXBy + 1;
  52417. var figureCoords = new Int32Array((splitYBy + 1) * verticesPerRow);
  52418. var figureColors = new Int32Array((splitYBy + 1) * verticesPerRow);
  52419. var k = 0;
  52420. var cl = new Uint8Array(3), cr = new Uint8Array(3);
  52421. var c0 = colors[ci[0]], c1 = colors[ci[1]], c2 = colors[ci[2]], c3 = colors[ci[3]];
  52422. var bRow = getB(splitYBy), bCol = getB(splitXBy);
  52423. for (var row = 0; row <= splitYBy; row++) {
  52424. cl[0] = (c0[0] * (splitYBy - row) + c2[0] * row) / splitYBy | 0;
  52425. cl[1] = (c0[1] * (splitYBy - row) + c2[1] * row) / splitYBy | 0;
  52426. cl[2] = (c0[2] * (splitYBy - row) + c2[2] * row) / splitYBy | 0;
  52427. cr[0] = (c1[0] * (splitYBy - row) + c3[0] * row) / splitYBy | 0;
  52428. cr[1] = (c1[1] * (splitYBy - row) + c3[1] * row) / splitYBy | 0;
  52429. cr[2] = (c1[2] * (splitYBy - row) + c3[2] * row) / splitYBy | 0;
  52430. for (var col = 0; col <= splitXBy; col++, k++) {
  52431. if ((row === 0 || row === splitYBy) && (col === 0 || col === splitXBy)) {
  52432. continue;
  52433. }
  52434. var x = 0, y = 0;
  52435. var q = 0;
  52436. for (var i = 0; i <= 3; i++) {
  52437. for (var j = 0; j <= 3; j++, q++) {
  52438. var m = bRow[row][i] * bCol[col][j];
  52439. x += coords[pi[q]][0] * m;
  52440. y += coords[pi[q]][1] * m;
  52441. }
  52442. }
  52443. figureCoords[k] = coords.length;
  52444. coords.push([
  52445. x,
  52446. y
  52447. ]);
  52448. figureColors[k] = colors.length;
  52449. var newColor = new Uint8Array(3);
  52450. newColor[0] = (cl[0] * (splitXBy - col) + cr[0] * col) / splitXBy | 0;
  52451. newColor[1] = (cl[1] * (splitXBy - col) + cr[1] * col) / splitXBy | 0;
  52452. newColor[2] = (cl[2] * (splitXBy - col) + cr[2] * col) / splitXBy | 0;
  52453. colors.push(newColor);
  52454. }
  52455. }
  52456. figureCoords[0] = pi[0];
  52457. figureColors[0] = ci[0];
  52458. figureCoords[splitXBy] = pi[3];
  52459. figureColors[splitXBy] = ci[1];
  52460. figureCoords[verticesPerRow * splitYBy] = pi[12];
  52461. figureColors[verticesPerRow * splitYBy] = ci[2];
  52462. figureCoords[verticesPerRow * splitYBy + splitXBy] = pi[15];
  52463. figureColors[verticesPerRow * splitYBy + splitXBy] = ci[3];
  52464. mesh.figures[index] = {
  52465. type: 'lattice',
  52466. coords: figureCoords,
  52467. colors: figureColors,
  52468. verticesPerRow: verticesPerRow
  52469. };
  52470. }
  52471. function decodeType6Shading(mesh, reader) {
  52472. var coords = mesh.coords;
  52473. var colors = mesh.colors;
  52474. var ps = new Int32Array(16);
  52475. var cs = new Int32Array(4);
  52476. while (reader.hasData) {
  52477. var f = reader.readFlag();
  52478. assert(0 <= f && f <= 3, 'Unknown type6 flag');
  52479. var i, ii;
  52480. var pi = coords.length;
  52481. for (i = 0, ii = f !== 0 ? 8 : 12; i < ii; i++) {
  52482. coords.push(reader.readCoordinate());
  52483. }
  52484. var ci = colors.length;
  52485. for (i = 0, ii = f !== 0 ? 2 : 4; i < ii; i++) {
  52486. colors.push(reader.readComponents());
  52487. }
  52488. var tmp1, tmp2, tmp3, tmp4;
  52489. switch (f) {
  52490. case 0:
  52491. ps[12] = pi + 3;
  52492. ps[13] = pi + 4;
  52493. ps[14] = pi + 5;
  52494. ps[15] = pi + 6;
  52495. ps[8] = pi + 2;
  52496. ps[11] = pi + 7;
  52497. ps[4] = pi + 1;
  52498. ps[7] = pi + 8;
  52499. ps[0] = pi;
  52500. ps[1] = pi + 11;
  52501. ps[2] = pi + 10;
  52502. ps[3] = pi + 9;
  52503. cs[2] = ci + 1;
  52504. cs[3] = ci + 2;
  52505. cs[0] = ci;
  52506. cs[1] = ci + 3;
  52507. break;
  52508. case 1:
  52509. tmp1 = ps[12];
  52510. tmp2 = ps[13];
  52511. tmp3 = ps[14];
  52512. tmp4 = ps[15];
  52513. ps[12] = tmp4;
  52514. ps[13] = pi + 0;
  52515. ps[14] = pi + 1;
  52516. ps[15] = pi + 2;
  52517. ps[8] = tmp3;
  52518. ps[11] = pi + 3;
  52519. ps[4] = tmp2;
  52520. ps[7] = pi + 4;
  52521. ps[0] = tmp1;
  52522. ps[1] = pi + 7;
  52523. ps[2] = pi + 6;
  52524. ps[3] = pi + 5;
  52525. tmp1 = cs[2];
  52526. tmp2 = cs[3];
  52527. cs[2] = tmp2;
  52528. cs[3] = ci;
  52529. cs[0] = tmp1;
  52530. cs[1] = ci + 1;
  52531. break;
  52532. case 2:
  52533. tmp1 = ps[15];
  52534. tmp2 = ps[11];
  52535. ps[12] = ps[3];
  52536. ps[13] = pi + 0;
  52537. ps[14] = pi + 1;
  52538. ps[15] = pi + 2;
  52539. ps[8] = ps[7];
  52540. ps[11] = pi + 3;
  52541. ps[4] = tmp2;
  52542. ps[7] = pi + 4;
  52543. ps[0] = tmp1;
  52544. ps[1] = pi + 7;
  52545. ps[2] = pi + 6;
  52546. ps[3] = pi + 5;
  52547. tmp1 = cs[3];
  52548. cs[2] = cs[1];
  52549. cs[3] = ci;
  52550. cs[0] = tmp1;
  52551. cs[1] = ci + 1;
  52552. break;
  52553. case 3:
  52554. ps[12] = ps[0];
  52555. ps[13] = pi + 0;
  52556. ps[14] = pi + 1;
  52557. ps[15] = pi + 2;
  52558. ps[8] = ps[1];
  52559. ps[11] = pi + 3;
  52560. ps[4] = ps[2];
  52561. ps[7] = pi + 4;
  52562. ps[0] = ps[3];
  52563. ps[1] = pi + 7;
  52564. ps[2] = pi + 6;
  52565. ps[3] = pi + 5;
  52566. cs[2] = cs[0];
  52567. cs[3] = ci;
  52568. cs[0] = cs[1];
  52569. cs[1] = ci + 1;
  52570. break;
  52571. }
  52572. ps[5] = coords.length;
  52573. coords.push([
  52574. (-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,
  52575. (-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
  52576. ]);
  52577. ps[6] = coords.length;
  52578. coords.push([
  52579. (-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,
  52580. (-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
  52581. ]);
  52582. ps[9] = coords.length;
  52583. coords.push([
  52584. (-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,
  52585. (-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
  52586. ]);
  52587. ps[10] = coords.length;
  52588. coords.push([
  52589. (-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,
  52590. (-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
  52591. ]);
  52592. mesh.figures.push({
  52593. type: 'patch',
  52594. coords: new Int32Array(ps),
  52595. colors: new Int32Array(cs)
  52596. });
  52597. }
  52598. }
  52599. function decodeType7Shading(mesh, reader) {
  52600. var coords = mesh.coords;
  52601. var colors = mesh.colors;
  52602. var ps = new Int32Array(16);
  52603. var cs = new Int32Array(4);
  52604. while (reader.hasData) {
  52605. var f = reader.readFlag();
  52606. assert(0 <= f && f <= 3, 'Unknown type7 flag');
  52607. var i, ii;
  52608. var pi = coords.length;
  52609. for (i = 0, ii = f !== 0 ? 12 : 16; i < ii; i++) {
  52610. coords.push(reader.readCoordinate());
  52611. }
  52612. var ci = colors.length;
  52613. for (i = 0, ii = f !== 0 ? 2 : 4; i < ii; i++) {
  52614. colors.push(reader.readComponents());
  52615. }
  52616. var tmp1, tmp2, tmp3, tmp4;
  52617. switch (f) {
  52618. case 0:
  52619. ps[12] = pi + 3;
  52620. ps[13] = pi + 4;
  52621. ps[14] = pi + 5;
  52622. ps[15] = pi + 6;
  52623. ps[8] = pi + 2;
  52624. ps[9] = pi + 13;
  52625. ps[10] = pi + 14;
  52626. ps[11] = pi + 7;
  52627. ps[4] = pi + 1;
  52628. ps[5] = pi + 12;
  52629. ps[6] = pi + 15;
  52630. ps[7] = pi + 8;
  52631. ps[0] = pi;
  52632. ps[1] = pi + 11;
  52633. ps[2] = pi + 10;
  52634. ps[3] = pi + 9;
  52635. cs[2] = ci + 1;
  52636. cs[3] = ci + 2;
  52637. cs[0] = ci;
  52638. cs[1] = ci + 3;
  52639. break;
  52640. case 1:
  52641. tmp1 = ps[12];
  52642. tmp2 = ps[13];
  52643. tmp3 = ps[14];
  52644. tmp4 = ps[15];
  52645. ps[12] = tmp4;
  52646. ps[13] = pi + 0;
  52647. ps[14] = pi + 1;
  52648. ps[15] = pi + 2;
  52649. ps[8] = tmp3;
  52650. ps[9] = pi + 9;
  52651. ps[10] = pi + 10;
  52652. ps[11] = pi + 3;
  52653. ps[4] = tmp2;
  52654. ps[5] = pi + 8;
  52655. ps[6] = pi + 11;
  52656. ps[7] = pi + 4;
  52657. ps[0] = tmp1;
  52658. ps[1] = pi + 7;
  52659. ps[2] = pi + 6;
  52660. ps[3] = pi + 5;
  52661. tmp1 = cs[2];
  52662. tmp2 = cs[3];
  52663. cs[2] = tmp2;
  52664. cs[3] = ci;
  52665. cs[0] = tmp1;
  52666. cs[1] = ci + 1;
  52667. break;
  52668. case 2:
  52669. tmp1 = ps[15];
  52670. tmp2 = ps[11];
  52671. ps[12] = ps[3];
  52672. ps[13] = pi + 0;
  52673. ps[14] = pi + 1;
  52674. ps[15] = pi + 2;
  52675. ps[8] = ps[7];
  52676. ps[9] = pi + 9;
  52677. ps[10] = pi + 10;
  52678. ps[11] = pi + 3;
  52679. ps[4] = tmp2;
  52680. ps[5] = pi + 8;
  52681. ps[6] = pi + 11;
  52682. ps[7] = pi + 4;
  52683. ps[0] = tmp1;
  52684. ps[1] = pi + 7;
  52685. ps[2] = pi + 6;
  52686. ps[3] = pi + 5;
  52687. tmp1 = cs[3];
  52688. cs[2] = cs[1];
  52689. cs[3] = ci;
  52690. cs[0] = tmp1;
  52691. cs[1] = ci + 1;
  52692. break;
  52693. case 3:
  52694. ps[12] = ps[0];
  52695. ps[13] = pi + 0;
  52696. ps[14] = pi + 1;
  52697. ps[15] = pi + 2;
  52698. ps[8] = ps[1];
  52699. ps[9] = pi + 9;
  52700. ps[10] = pi + 10;
  52701. ps[11] = pi + 3;
  52702. ps[4] = ps[2];
  52703. ps[5] = pi + 8;
  52704. ps[6] = pi + 11;
  52705. ps[7] = pi + 4;
  52706. ps[0] = ps[3];
  52707. ps[1] = pi + 7;
  52708. ps[2] = pi + 6;
  52709. ps[3] = pi + 5;
  52710. cs[2] = cs[0];
  52711. cs[3] = ci;
  52712. cs[0] = cs[1];
  52713. cs[1] = ci + 1;
  52714. break;
  52715. }
  52716. mesh.figures.push({
  52717. type: 'patch',
  52718. coords: new Int32Array(ps),
  52719. colors: new Int32Array(cs)
  52720. });
  52721. }
  52722. }
  52723. function updateBounds(mesh) {
  52724. var minX = mesh.coords[0][0], minY = mesh.coords[0][1], maxX = minX, maxY = minY;
  52725. for (var i = 1, ii = mesh.coords.length; i < ii; i++) {
  52726. var x = mesh.coords[i][0], y = mesh.coords[i][1];
  52727. minX = minX > x ? x : minX;
  52728. minY = minY > y ? y : minY;
  52729. maxX = maxX < x ? x : maxX;
  52730. maxY = maxY < y ? y : maxY;
  52731. }
  52732. mesh.bounds = [
  52733. minX,
  52734. minY,
  52735. maxX,
  52736. maxY
  52737. ];
  52738. }
  52739. function packData(mesh) {
  52740. var i, ii, j, jj;
  52741. var coords = mesh.coords;
  52742. var coordsPacked = new Float32Array(coords.length * 2);
  52743. for (i = 0, j = 0, ii = coords.length; i < ii; i++) {
  52744. var xy = coords[i];
  52745. coordsPacked[j++] = xy[0];
  52746. coordsPacked[j++] = xy[1];
  52747. }
  52748. mesh.coords = coordsPacked;
  52749. var colors = mesh.colors;
  52750. var colorsPacked = new Uint8Array(colors.length * 3);
  52751. for (i = 0, j = 0, ii = colors.length; i < ii; i++) {
  52752. var c = colors[i];
  52753. colorsPacked[j++] = c[0];
  52754. colorsPacked[j++] = c[1];
  52755. colorsPacked[j++] = c[2];
  52756. }
  52757. mesh.colors = colorsPacked;
  52758. var figures = mesh.figures;
  52759. for (i = 0, ii = figures.length; i < ii; i++) {
  52760. var figure = figures[i], ps = figure.coords, cs = figure.colors;
  52761. for (j = 0, jj = ps.length; j < jj; j++) {
  52762. ps[j] *= 2;
  52763. cs[j] *= 3;
  52764. }
  52765. }
  52766. }
  52767. function Mesh(stream, matrix, xref, res) {
  52768. assert(isStream(stream), 'Mesh data is not a stream');
  52769. var dict = stream.dict;
  52770. this.matrix = matrix;
  52771. this.shadingType = dict.get('ShadingType');
  52772. this.type = 'Pattern';
  52773. this.bbox = dict.getArray('BBox');
  52774. var cs = dict.get('ColorSpace', 'CS');
  52775. cs = ColorSpace.parse(cs, xref, res);
  52776. this.cs = cs;
  52777. this.background = dict.has('Background') ? cs.getRgb(dict.get('Background'), 0) : null;
  52778. var fnObj = dict.get('Function');
  52779. var fn = fnObj ? PDFFunction.parseArray(xref, fnObj) : null;
  52780. this.coords = [];
  52781. this.colors = [];
  52782. this.figures = [];
  52783. var decodeContext = {
  52784. bitsPerCoordinate: dict.get('BitsPerCoordinate'),
  52785. bitsPerComponent: dict.get('BitsPerComponent'),
  52786. bitsPerFlag: dict.get('BitsPerFlag'),
  52787. decode: dict.getArray('Decode'),
  52788. colorFn: fn,
  52789. colorSpace: cs,
  52790. numComps: fn ? 1 : cs.numComps
  52791. };
  52792. var reader = new MeshStreamReader(stream, decodeContext);
  52793. var patchMesh = false;
  52794. switch (this.shadingType) {
  52795. case ShadingType.FREE_FORM_MESH:
  52796. decodeType4Shading(this, reader);
  52797. break;
  52798. case ShadingType.LATTICE_FORM_MESH:
  52799. var verticesPerRow = dict.get('VerticesPerRow') | 0;
  52800. assert(verticesPerRow >= 2, 'Invalid VerticesPerRow');
  52801. decodeType5Shading(this, reader, verticesPerRow);
  52802. break;
  52803. case ShadingType.COONS_PATCH_MESH:
  52804. decodeType6Shading(this, reader);
  52805. patchMesh = true;
  52806. break;
  52807. case ShadingType.TENSOR_PATCH_MESH:
  52808. decodeType7Shading(this, reader);
  52809. patchMesh = true;
  52810. break;
  52811. default:
  52812. error('Unsupported mesh type.');
  52813. break;
  52814. }
  52815. if (patchMesh) {
  52816. updateBounds(this);
  52817. for (var i = 0, ii = this.figures.length; i < ii; i++) {
  52818. buildFigureFromPatch(this, i);
  52819. }
  52820. }
  52821. updateBounds(this);
  52822. packData(this);
  52823. }
  52824. Mesh.prototype = {
  52825. getIR: function Mesh_getIR() {
  52826. return [
  52827. 'Mesh',
  52828. this.shadingType,
  52829. this.coords,
  52830. this.colors,
  52831. this.figures,
  52832. this.bounds,
  52833. this.matrix,
  52834. this.bbox,
  52835. this.background
  52836. ];
  52837. }
  52838. };
  52839. return Mesh;
  52840. }();
  52841. Shadings.Dummy = function DummyClosure() {
  52842. function Dummy() {
  52843. this.type = 'Pattern';
  52844. }
  52845. Dummy.prototype = {
  52846. getIR: function Dummy_getIR() {
  52847. return ['Dummy'];
  52848. }
  52849. };
  52850. return Dummy;
  52851. }();
  52852. function getTilingPatternIR(operatorList, dict, args) {
  52853. var matrix = dict.getArray('Matrix');
  52854. var bbox = dict.getArray('BBox');
  52855. var xstep = dict.get('XStep');
  52856. var ystep = dict.get('YStep');
  52857. var paintType = dict.get('PaintType');
  52858. var tilingType = dict.get('TilingType');
  52859. return [
  52860. 'TilingPattern',
  52861. args,
  52862. operatorList,
  52863. matrix,
  52864. bbox,
  52865. xstep,
  52866. ystep,
  52867. paintType,
  52868. tilingType
  52869. ];
  52870. }
  52871. exports.Pattern = Pattern;
  52872. exports.getTilingPatternIR = getTilingPatternIR;
  52873. /***/ }),
  52874. /* 41 */
  52875. /***/ (function(module, exports, __w_pdfjs_require__) {
  52876. "use strict";
  52877. var sharedUtil = __w_pdfjs_require__(0);
  52878. var coreStream = __w_pdfjs_require__(2);
  52879. var coreChunkedStream = __w_pdfjs_require__(16);
  52880. var coreDocument = __w_pdfjs_require__(31);
  52881. var warn = sharedUtil.warn;
  52882. var createValidAbsoluteUrl = sharedUtil.createValidAbsoluteUrl;
  52883. var shadow = sharedUtil.shadow;
  52884. var NotImplementedException = sharedUtil.NotImplementedException;
  52885. var MissingDataException = sharedUtil.MissingDataException;
  52886. var createPromiseCapability = sharedUtil.createPromiseCapability;
  52887. var Util = sharedUtil.Util;
  52888. var Stream = coreStream.Stream;
  52889. var ChunkedStreamManager = coreChunkedStream.ChunkedStreamManager;
  52890. var PDFDocument = coreDocument.PDFDocument;
  52891. var BasePdfManager = function BasePdfManagerClosure() {
  52892. function BasePdfManager() {
  52893. throw new Error('Cannot initialize BaseManagerManager');
  52894. }
  52895. BasePdfManager.prototype = {
  52896. get docId() {
  52897. return this._docId;
  52898. },
  52899. get password() {
  52900. return this._password;
  52901. },
  52902. get docBaseUrl() {
  52903. var docBaseUrl = null;
  52904. if (this._docBaseUrl) {
  52905. var absoluteUrl = createValidAbsoluteUrl(this._docBaseUrl);
  52906. if (absoluteUrl) {
  52907. docBaseUrl = absoluteUrl.href;
  52908. } else {
  52909. warn('Invalid absolute docBaseUrl: "' + this._docBaseUrl + '".');
  52910. }
  52911. }
  52912. return shadow(this, 'docBaseUrl', docBaseUrl);
  52913. },
  52914. onLoadedStream: function BasePdfManager_onLoadedStream() {
  52915. throw new NotImplementedException();
  52916. },
  52917. ensureDoc: function BasePdfManager_ensureDoc(prop, args) {
  52918. return this.ensure(this.pdfDocument, prop, args);
  52919. },
  52920. ensureXRef: function BasePdfManager_ensureXRef(prop, args) {
  52921. return this.ensure(this.pdfDocument.xref, prop, args);
  52922. },
  52923. ensureCatalog: function BasePdfManager_ensureCatalog(prop, args) {
  52924. return this.ensure(this.pdfDocument.catalog, prop, args);
  52925. },
  52926. getPage: function BasePdfManager_getPage(pageIndex) {
  52927. return this.pdfDocument.getPage(pageIndex);
  52928. },
  52929. cleanup: function BasePdfManager_cleanup() {
  52930. return this.pdfDocument.cleanup();
  52931. },
  52932. ensure: function BasePdfManager_ensure(obj, prop, args) {
  52933. return new NotImplementedException();
  52934. },
  52935. requestRange: function BasePdfManager_requestRange(begin, end) {
  52936. return new NotImplementedException();
  52937. },
  52938. requestLoadedStream: function BasePdfManager_requestLoadedStream() {
  52939. return new NotImplementedException();
  52940. },
  52941. sendProgressiveData: function BasePdfManager_sendProgressiveData(chunk) {
  52942. return new NotImplementedException();
  52943. },
  52944. updatePassword: function BasePdfManager_updatePassword(password) {
  52945. this._password = password;
  52946. },
  52947. terminate: function BasePdfManager_terminate() {
  52948. return new NotImplementedException();
  52949. }
  52950. };
  52951. return BasePdfManager;
  52952. }();
  52953. var LocalPdfManager = function LocalPdfManagerClosure() {
  52954. function LocalPdfManager(docId, data, password, evaluatorOptions, docBaseUrl) {
  52955. this._docId = docId;
  52956. this._password = password;
  52957. this._docBaseUrl = docBaseUrl;
  52958. this.evaluatorOptions = evaluatorOptions;
  52959. var stream = new Stream(data);
  52960. this.pdfDocument = new PDFDocument(this, stream);
  52961. this._loadedStreamCapability = createPromiseCapability();
  52962. this._loadedStreamCapability.resolve(stream);
  52963. }
  52964. Util.inherit(LocalPdfManager, BasePdfManager, {
  52965. ensure: function LocalPdfManager_ensure(obj, prop, args) {
  52966. return new Promise(function (resolve, reject) {
  52967. try {
  52968. var value = obj[prop];
  52969. var result;
  52970. if (typeof value === 'function') {
  52971. result = value.apply(obj, args);
  52972. } else {
  52973. result = value;
  52974. }
  52975. resolve(result);
  52976. } catch (e) {
  52977. reject(e);
  52978. }
  52979. });
  52980. },
  52981. requestRange: function LocalPdfManager_requestRange(begin, end) {
  52982. return Promise.resolve();
  52983. },
  52984. requestLoadedStream: function LocalPdfManager_requestLoadedStream() {
  52985. },
  52986. onLoadedStream: function LocalPdfManager_onLoadedStream() {
  52987. return this._loadedStreamCapability.promise;
  52988. },
  52989. terminate: function LocalPdfManager_terminate() {
  52990. }
  52991. });
  52992. return LocalPdfManager;
  52993. }();
  52994. var NetworkPdfManager = function NetworkPdfManagerClosure() {
  52995. function NetworkPdfManager(docId, pdfNetworkStream, args, evaluatorOptions, docBaseUrl) {
  52996. this._docId = docId;
  52997. this._password = args.password;
  52998. this._docBaseUrl = docBaseUrl;
  52999. this.msgHandler = args.msgHandler;
  53000. this.evaluatorOptions = evaluatorOptions;
  53001. var params = {
  53002. msgHandler: args.msgHandler,
  53003. url: args.url,
  53004. length: args.length,
  53005. disableAutoFetch: args.disableAutoFetch,
  53006. rangeChunkSize: args.rangeChunkSize
  53007. };
  53008. this.streamManager = new ChunkedStreamManager(pdfNetworkStream, params);
  53009. this.pdfDocument = new PDFDocument(this, this.streamManager.getStream());
  53010. }
  53011. Util.inherit(NetworkPdfManager, BasePdfManager, {
  53012. ensure: function NetworkPdfManager_ensure(obj, prop, args) {
  53013. var pdfManager = this;
  53014. return new Promise(function (resolve, reject) {
  53015. function ensureHelper() {
  53016. try {
  53017. var result;
  53018. var value = obj[prop];
  53019. if (typeof value === 'function') {
  53020. result = value.apply(obj, args);
  53021. } else {
  53022. result = value;
  53023. }
  53024. resolve(result);
  53025. } catch (e) {
  53026. if (!(e instanceof MissingDataException)) {
  53027. reject(e);
  53028. return;
  53029. }
  53030. pdfManager.streamManager.requestRange(e.begin, e.end).then(ensureHelper, reject);
  53031. }
  53032. }
  53033. ensureHelper();
  53034. });
  53035. },
  53036. requestRange: function NetworkPdfManager_requestRange(begin, end) {
  53037. return this.streamManager.requestRange(begin, end);
  53038. },
  53039. requestLoadedStream: function NetworkPdfManager_requestLoadedStream() {
  53040. this.streamManager.requestAllChunks();
  53041. },
  53042. sendProgressiveData: function NetworkPdfManager_sendProgressiveData(chunk) {
  53043. this.streamManager.onReceiveData({ chunk: chunk });
  53044. },
  53045. onLoadedStream: function NetworkPdfManager_onLoadedStream() {
  53046. return this.streamManager.onLoadedStream();
  53047. },
  53048. terminate: function NetworkPdfManager_terminate() {
  53049. this.streamManager.abort();
  53050. }
  53051. });
  53052. return NetworkPdfManager;
  53053. }();
  53054. exports.LocalPdfManager = LocalPdfManager;
  53055. exports.NetworkPdfManager = NetworkPdfManager;
  53056. /***/ }),
  53057. /* 42 */
  53058. /***/ (function(module, exports, __w_pdfjs_require__) {
  53059. "use strict";
  53060. var sharedUtil = __w_pdfjs_require__(0);
  53061. var corePrimitives = __w_pdfjs_require__(1);
  53062. var error = sharedUtil.error;
  53063. var isSpace = sharedUtil.isSpace;
  53064. var EOF = corePrimitives.EOF;
  53065. var PostScriptParser = function PostScriptParserClosure() {
  53066. function PostScriptParser(lexer) {
  53067. this.lexer = lexer;
  53068. this.operators = [];
  53069. this.token = null;
  53070. this.prev = null;
  53071. }
  53072. PostScriptParser.prototype = {
  53073. nextToken: function PostScriptParser_nextToken() {
  53074. this.prev = this.token;
  53075. this.token = this.lexer.getToken();
  53076. },
  53077. accept: function PostScriptParser_accept(type) {
  53078. if (this.token.type === type) {
  53079. this.nextToken();
  53080. return true;
  53081. }
  53082. return false;
  53083. },
  53084. expect: function PostScriptParser_expect(type) {
  53085. if (this.accept(type)) {
  53086. return true;
  53087. }
  53088. error('Unexpected symbol: found ' + this.token.type + ' expected ' + type + '.');
  53089. },
  53090. parse: function PostScriptParser_parse() {
  53091. this.nextToken();
  53092. this.expect(PostScriptTokenTypes.LBRACE);
  53093. this.parseBlock();
  53094. this.expect(PostScriptTokenTypes.RBRACE);
  53095. return this.operators;
  53096. },
  53097. parseBlock: function PostScriptParser_parseBlock() {
  53098. while (true) {
  53099. if (this.accept(PostScriptTokenTypes.NUMBER)) {
  53100. this.operators.push(this.prev.value);
  53101. } else if (this.accept(PostScriptTokenTypes.OPERATOR)) {
  53102. this.operators.push(this.prev.value);
  53103. } else if (this.accept(PostScriptTokenTypes.LBRACE)) {
  53104. this.parseCondition();
  53105. } else {
  53106. return;
  53107. }
  53108. }
  53109. },
  53110. parseCondition: function PostScriptParser_parseCondition() {
  53111. var conditionLocation = this.operators.length;
  53112. this.operators.push(null, null);
  53113. this.parseBlock();
  53114. this.expect(PostScriptTokenTypes.RBRACE);
  53115. if (this.accept(PostScriptTokenTypes.IF)) {
  53116. this.operators[conditionLocation] = this.operators.length;
  53117. this.operators[conditionLocation + 1] = 'jz';
  53118. } else if (this.accept(PostScriptTokenTypes.LBRACE)) {
  53119. var jumpLocation = this.operators.length;
  53120. this.operators.push(null, null);
  53121. var endOfTrue = this.operators.length;
  53122. this.parseBlock();
  53123. this.expect(PostScriptTokenTypes.RBRACE);
  53124. this.expect(PostScriptTokenTypes.IFELSE);
  53125. this.operators[jumpLocation] = this.operators.length;
  53126. this.operators[jumpLocation + 1] = 'j';
  53127. this.operators[conditionLocation] = endOfTrue;
  53128. this.operators[conditionLocation + 1] = 'jz';
  53129. } else {
  53130. error('PS Function: error parsing conditional.');
  53131. }
  53132. }
  53133. };
  53134. return PostScriptParser;
  53135. }();
  53136. var PostScriptTokenTypes = {
  53137. LBRACE: 0,
  53138. RBRACE: 1,
  53139. NUMBER: 2,
  53140. OPERATOR: 3,
  53141. IF: 4,
  53142. IFELSE: 5
  53143. };
  53144. var PostScriptToken = function PostScriptTokenClosure() {
  53145. function PostScriptToken(type, value) {
  53146. this.type = type;
  53147. this.value = value;
  53148. }
  53149. var opCache = Object.create(null);
  53150. PostScriptToken.getOperator = function PostScriptToken_getOperator(op) {
  53151. var opValue = opCache[op];
  53152. if (opValue) {
  53153. return opValue;
  53154. }
  53155. return opCache[op] = new PostScriptToken(PostScriptTokenTypes.OPERATOR, op);
  53156. };
  53157. PostScriptToken.LBRACE = new PostScriptToken(PostScriptTokenTypes.LBRACE, '{');
  53158. PostScriptToken.RBRACE = new PostScriptToken(PostScriptTokenTypes.RBRACE, '}');
  53159. PostScriptToken.IF = new PostScriptToken(PostScriptTokenTypes.IF, 'IF');
  53160. PostScriptToken.IFELSE = new PostScriptToken(PostScriptTokenTypes.IFELSE, 'IFELSE');
  53161. return PostScriptToken;
  53162. }();
  53163. var PostScriptLexer = function PostScriptLexerClosure() {
  53164. function PostScriptLexer(stream) {
  53165. this.stream = stream;
  53166. this.nextChar();
  53167. this.strBuf = [];
  53168. }
  53169. PostScriptLexer.prototype = {
  53170. nextChar: function PostScriptLexer_nextChar() {
  53171. return this.currentChar = this.stream.getByte();
  53172. },
  53173. getToken: function PostScriptLexer_getToken() {
  53174. var comment = false;
  53175. var ch = this.currentChar;
  53176. while (true) {
  53177. if (ch < 0) {
  53178. return EOF;
  53179. }
  53180. if (comment) {
  53181. if (ch === 0x0A || ch === 0x0D) {
  53182. comment = false;
  53183. }
  53184. } else if (ch === 0x25) {
  53185. comment = true;
  53186. } else if (!isSpace(ch)) {
  53187. break;
  53188. }
  53189. ch = this.nextChar();
  53190. }
  53191. switch (ch | 0) {
  53192. case 0x30:
  53193. case 0x31:
  53194. case 0x32:
  53195. case 0x33:
  53196. case 0x34:
  53197. case 0x35:
  53198. case 0x36:
  53199. case 0x37:
  53200. case 0x38:
  53201. case 0x39:
  53202. case 0x2B:
  53203. case 0x2D:
  53204. case 0x2E:
  53205. return new PostScriptToken(PostScriptTokenTypes.NUMBER, this.getNumber());
  53206. case 0x7B:
  53207. this.nextChar();
  53208. return PostScriptToken.LBRACE;
  53209. case 0x7D:
  53210. this.nextChar();
  53211. return PostScriptToken.RBRACE;
  53212. }
  53213. var strBuf = this.strBuf;
  53214. strBuf.length = 0;
  53215. strBuf[0] = String.fromCharCode(ch);
  53216. while ((ch = this.nextChar()) >= 0 && (ch >= 0x41 && ch <= 0x5A || ch >= 0x61 && ch <= 0x7A)) {
  53217. strBuf.push(String.fromCharCode(ch));
  53218. }
  53219. var str = strBuf.join('');
  53220. switch (str.toLowerCase()) {
  53221. case 'if':
  53222. return PostScriptToken.IF;
  53223. case 'ifelse':
  53224. return PostScriptToken.IFELSE;
  53225. default:
  53226. return PostScriptToken.getOperator(str);
  53227. }
  53228. },
  53229. getNumber: function PostScriptLexer_getNumber() {
  53230. var ch = this.currentChar;
  53231. var strBuf = this.strBuf;
  53232. strBuf.length = 0;
  53233. strBuf[0] = String.fromCharCode(ch);
  53234. while ((ch = this.nextChar()) >= 0) {
  53235. if (ch >= 0x30 && ch <= 0x39 || ch === 0x2D || ch === 0x2E) {
  53236. strBuf.push(String.fromCharCode(ch));
  53237. } else {
  53238. break;
  53239. }
  53240. }
  53241. var value = parseFloat(strBuf.join(''));
  53242. if (isNaN(value)) {
  53243. error('Invalid floating point number: ' + value);
  53244. }
  53245. return value;
  53246. }
  53247. };
  53248. return PostScriptLexer;
  53249. }();
  53250. exports.PostScriptLexer = PostScriptLexer;
  53251. exports.PostScriptParser = PostScriptParser;
  53252. /***/ }),
  53253. /* 43 */
  53254. /***/ (function(module, exports, __w_pdfjs_require__) {
  53255. "use strict";
  53256. var sharedUtil = __w_pdfjs_require__(0);
  53257. var coreStream = __w_pdfjs_require__(2);
  53258. var coreEncodings = __w_pdfjs_require__(5);
  53259. var warn = sharedUtil.warn;
  53260. var isSpace = sharedUtil.isSpace;
  53261. var Stream = coreStream.Stream;
  53262. var getEncoding = coreEncodings.getEncoding;
  53263. var HINTING_ENABLED = false;
  53264. var Type1CharString = function Type1CharStringClosure() {
  53265. var COMMAND_MAP = {
  53266. 'hstem': [1],
  53267. 'vstem': [3],
  53268. 'vmoveto': [4],
  53269. 'rlineto': [5],
  53270. 'hlineto': [6],
  53271. 'vlineto': [7],
  53272. 'rrcurveto': [8],
  53273. 'callsubr': [10],
  53274. 'flex': [
  53275. 12,
  53276. 35
  53277. ],
  53278. 'drop': [
  53279. 12,
  53280. 18
  53281. ],
  53282. 'endchar': [14],
  53283. 'rmoveto': [21],
  53284. 'hmoveto': [22],
  53285. 'vhcurveto': [30],
  53286. 'hvcurveto': [31]
  53287. };
  53288. function Type1CharString() {
  53289. this.width = 0;
  53290. this.lsb = 0;
  53291. this.flexing = false;
  53292. this.output = [];
  53293. this.stack = [];
  53294. }
  53295. Type1CharString.prototype = {
  53296. convert: function Type1CharString_convert(encoded, subrs, seacAnalysisEnabled) {
  53297. var count = encoded.length;
  53298. var error = false;
  53299. var wx, sbx, subrNumber;
  53300. for (var i = 0; i < count; i++) {
  53301. var value = encoded[i];
  53302. if (value < 32) {
  53303. if (value === 12) {
  53304. value = (value << 8) + encoded[++i];
  53305. }
  53306. switch (value) {
  53307. case 1:
  53308. if (!HINTING_ENABLED) {
  53309. this.stack = [];
  53310. break;
  53311. }
  53312. error = this.executeCommand(2, COMMAND_MAP.hstem);
  53313. break;
  53314. case 3:
  53315. if (!HINTING_ENABLED) {
  53316. this.stack = [];
  53317. break;
  53318. }
  53319. error = this.executeCommand(2, COMMAND_MAP.vstem);
  53320. break;
  53321. case 4:
  53322. if (this.flexing) {
  53323. if (this.stack.length < 1) {
  53324. error = true;
  53325. break;
  53326. }
  53327. var dy = this.stack.pop();
  53328. this.stack.push(0, dy);
  53329. break;
  53330. }
  53331. error = this.executeCommand(1, COMMAND_MAP.vmoveto);
  53332. break;
  53333. case 5:
  53334. error = this.executeCommand(2, COMMAND_MAP.rlineto);
  53335. break;
  53336. case 6:
  53337. error = this.executeCommand(1, COMMAND_MAP.hlineto);
  53338. break;
  53339. case 7:
  53340. error = this.executeCommand(1, COMMAND_MAP.vlineto);
  53341. break;
  53342. case 8:
  53343. error = this.executeCommand(6, COMMAND_MAP.rrcurveto);
  53344. break;
  53345. case 9:
  53346. this.stack = [];
  53347. break;
  53348. case 10:
  53349. if (this.stack.length < 1) {
  53350. error = true;
  53351. break;
  53352. }
  53353. subrNumber = this.stack.pop();
  53354. error = this.convert(subrs[subrNumber], subrs, seacAnalysisEnabled);
  53355. break;
  53356. case 11:
  53357. return error;
  53358. case 13:
  53359. if (this.stack.length < 2) {
  53360. error = true;
  53361. break;
  53362. }
  53363. wx = this.stack.pop();
  53364. sbx = this.stack.pop();
  53365. this.lsb = sbx;
  53366. this.width = wx;
  53367. this.stack.push(wx, sbx);
  53368. error = this.executeCommand(2, COMMAND_MAP.hmoveto);
  53369. break;
  53370. case 14:
  53371. this.output.push(COMMAND_MAP.endchar[0]);
  53372. break;
  53373. case 21:
  53374. if (this.flexing) {
  53375. break;
  53376. }
  53377. error = this.executeCommand(2, COMMAND_MAP.rmoveto);
  53378. break;
  53379. case 22:
  53380. if (this.flexing) {
  53381. this.stack.push(0);
  53382. break;
  53383. }
  53384. error = this.executeCommand(1, COMMAND_MAP.hmoveto);
  53385. break;
  53386. case 30:
  53387. error = this.executeCommand(4, COMMAND_MAP.vhcurveto);
  53388. break;
  53389. case 31:
  53390. error = this.executeCommand(4, COMMAND_MAP.hvcurveto);
  53391. break;
  53392. case (12 << 8) + 0:
  53393. this.stack = [];
  53394. break;
  53395. case (12 << 8) + 1:
  53396. if (!HINTING_ENABLED) {
  53397. this.stack = [];
  53398. break;
  53399. }
  53400. error = this.executeCommand(2, COMMAND_MAP.vstem);
  53401. break;
  53402. case (12 << 8) + 2:
  53403. if (!HINTING_ENABLED) {
  53404. this.stack = [];
  53405. break;
  53406. }
  53407. error = this.executeCommand(2, COMMAND_MAP.hstem);
  53408. break;
  53409. case (12 << 8) + 6:
  53410. if (seacAnalysisEnabled) {
  53411. this.seac = this.stack.splice(-4, 4);
  53412. error = this.executeCommand(0, COMMAND_MAP.endchar);
  53413. } else {
  53414. error = this.executeCommand(4, COMMAND_MAP.endchar);
  53415. }
  53416. break;
  53417. case (12 << 8) + 7:
  53418. if (this.stack.length < 4) {
  53419. error = true;
  53420. break;
  53421. }
  53422. this.stack.pop();
  53423. wx = this.stack.pop();
  53424. var sby = this.stack.pop();
  53425. sbx = this.stack.pop();
  53426. this.lsb = sbx;
  53427. this.width = wx;
  53428. this.stack.push(wx, sbx, sby);
  53429. error = this.executeCommand(3, COMMAND_MAP.rmoveto);
  53430. break;
  53431. case (12 << 8) + 12:
  53432. if (this.stack.length < 2) {
  53433. error = true;
  53434. break;
  53435. }
  53436. var num2 = this.stack.pop();
  53437. var num1 = this.stack.pop();
  53438. this.stack.push(num1 / num2);
  53439. break;
  53440. case (12 << 8) + 16:
  53441. if (this.stack.length < 2) {
  53442. error = true;
  53443. break;
  53444. }
  53445. subrNumber = this.stack.pop();
  53446. var numArgs = this.stack.pop();
  53447. if (subrNumber === 0 && numArgs === 3) {
  53448. var flexArgs = this.stack.splice(this.stack.length - 17, 17);
  53449. 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]);
  53450. error = this.executeCommand(13, COMMAND_MAP.flex, true);
  53451. this.flexing = false;
  53452. this.stack.push(flexArgs[15], flexArgs[16]);
  53453. } else if (subrNumber === 1 && numArgs === 0) {
  53454. this.flexing = true;
  53455. }
  53456. break;
  53457. case (12 << 8) + 17:
  53458. break;
  53459. case (12 << 8) + 33:
  53460. this.stack = [];
  53461. break;
  53462. default:
  53463. warn('Unknown type 1 charstring command of "' + value + '"');
  53464. break;
  53465. }
  53466. if (error) {
  53467. break;
  53468. }
  53469. continue;
  53470. } else if (value <= 246) {
  53471. value = value - 139;
  53472. } else if (value <= 250) {
  53473. value = (value - 247) * 256 + encoded[++i] + 108;
  53474. } else if (value <= 254) {
  53475. value = -((value - 251) * 256) - encoded[++i] - 108;
  53476. } else {
  53477. value = (encoded[++i] & 0xff) << 24 | (encoded[++i] & 0xff) << 16 | (encoded[++i] & 0xff) << 8 | (encoded[++i] & 0xff) << 0;
  53478. }
  53479. this.stack.push(value);
  53480. }
  53481. return error;
  53482. },
  53483. executeCommand: function (howManyArgs, command, keepStack) {
  53484. var stackLength = this.stack.length;
  53485. if (howManyArgs > stackLength) {
  53486. return true;
  53487. }
  53488. var start = stackLength - howManyArgs;
  53489. for (var i = start; i < stackLength; i++) {
  53490. var value = this.stack[i];
  53491. if (value === (value | 0)) {
  53492. this.output.push(28, value >> 8 & 0xff, value & 0xff);
  53493. } else {
  53494. value = 65536 * value | 0;
  53495. this.output.push(255, value >> 24 & 0xFF, value >> 16 & 0xFF, value >> 8 & 0xFF, value & 0xFF);
  53496. }
  53497. }
  53498. this.output.push.apply(this.output, command);
  53499. if (keepStack) {
  53500. this.stack.splice(start, howManyArgs);
  53501. } else {
  53502. this.stack.length = 0;
  53503. }
  53504. return false;
  53505. }
  53506. };
  53507. return Type1CharString;
  53508. }();
  53509. var Type1Parser = function Type1ParserClosure() {
  53510. var EEXEC_ENCRYPT_KEY = 55665;
  53511. var CHAR_STRS_ENCRYPT_KEY = 4330;
  53512. function isHexDigit(code) {
  53513. return code >= 48 && code <= 57 || code >= 65 && code <= 70 || code >= 97 && code <= 102;
  53514. }
  53515. function decrypt(data, key, discardNumber) {
  53516. if (discardNumber >= data.length) {
  53517. return new Uint8Array(0);
  53518. }
  53519. var r = key | 0, c1 = 52845, c2 = 22719, i, j;
  53520. for (i = 0; i < discardNumber; i++) {
  53521. r = (data[i] + r) * c1 + c2 & (1 << 16) - 1;
  53522. }
  53523. var count = data.length - discardNumber;
  53524. var decrypted = new Uint8Array(count);
  53525. for (i = discardNumber, j = 0; j < count; i++, j++) {
  53526. var value = data[i];
  53527. decrypted[j] = value ^ r >> 8;
  53528. r = (value + r) * c1 + c2 & (1 << 16) - 1;
  53529. }
  53530. return decrypted;
  53531. }
  53532. function decryptAscii(data, key, discardNumber) {
  53533. var r = key | 0, c1 = 52845, c2 = 22719;
  53534. var count = data.length, maybeLength = count >>> 1;
  53535. var decrypted = new Uint8Array(maybeLength);
  53536. var i, j;
  53537. for (i = 0, j = 0; i < count; i++) {
  53538. var digit1 = data[i];
  53539. if (!isHexDigit(digit1)) {
  53540. continue;
  53541. }
  53542. i++;
  53543. var digit2;
  53544. while (i < count && !isHexDigit(digit2 = data[i])) {
  53545. i++;
  53546. }
  53547. if (i < count) {
  53548. var value = parseInt(String.fromCharCode(digit1, digit2), 16);
  53549. decrypted[j++] = value ^ r >> 8;
  53550. r = (value + r) * c1 + c2 & (1 << 16) - 1;
  53551. }
  53552. }
  53553. return Array.prototype.slice.call(decrypted, discardNumber, j);
  53554. }
  53555. function isSpecial(c) {
  53556. return c === 0x2F || c === 0x5B || c === 0x5D || c === 0x7B || c === 0x7D || c === 0x28 || c === 0x29;
  53557. }
  53558. function Type1Parser(stream, encrypted, seacAnalysisEnabled) {
  53559. if (encrypted) {
  53560. var data = stream.getBytes();
  53561. var isBinary = !(isHexDigit(data[0]) && isHexDigit(data[1]) && isHexDigit(data[2]) && isHexDigit(data[3]));
  53562. stream = new Stream(isBinary ? decrypt(data, EEXEC_ENCRYPT_KEY, 4) : decryptAscii(data, EEXEC_ENCRYPT_KEY, 4));
  53563. }
  53564. this.seacAnalysisEnabled = !!seacAnalysisEnabled;
  53565. this.stream = stream;
  53566. this.nextChar();
  53567. }
  53568. Type1Parser.prototype = {
  53569. readNumberArray: function Type1Parser_readNumberArray() {
  53570. this.getToken();
  53571. var array = [];
  53572. while (true) {
  53573. var token = this.getToken();
  53574. if (token === null || token === ']' || token === '}') {
  53575. break;
  53576. }
  53577. array.push(parseFloat(token || 0));
  53578. }
  53579. return array;
  53580. },
  53581. readNumber: function Type1Parser_readNumber() {
  53582. var token = this.getToken();
  53583. return parseFloat(token || 0);
  53584. },
  53585. readInt: function Type1Parser_readInt() {
  53586. var token = this.getToken();
  53587. return parseInt(token || 0, 10) | 0;
  53588. },
  53589. readBoolean: function Type1Parser_readBoolean() {
  53590. var token = this.getToken();
  53591. return token === 'true' ? 1 : 0;
  53592. },
  53593. nextChar: function Type1_nextChar() {
  53594. return this.currentChar = this.stream.getByte();
  53595. },
  53596. getToken: function Type1Parser_getToken() {
  53597. var comment = false;
  53598. var ch = this.currentChar;
  53599. while (true) {
  53600. if (ch === -1) {
  53601. return null;
  53602. }
  53603. if (comment) {
  53604. if (ch === 0x0A || ch === 0x0D) {
  53605. comment = false;
  53606. }
  53607. } else if (ch === 0x25) {
  53608. comment = true;
  53609. } else if (!isSpace(ch)) {
  53610. break;
  53611. }
  53612. ch = this.nextChar();
  53613. }
  53614. if (isSpecial(ch)) {
  53615. this.nextChar();
  53616. return String.fromCharCode(ch);
  53617. }
  53618. var token = '';
  53619. do {
  53620. token += String.fromCharCode(ch);
  53621. ch = this.nextChar();
  53622. } while (ch >= 0 && !isSpace(ch) && !isSpecial(ch));
  53623. return token;
  53624. },
  53625. extractFontProgram: function Type1Parser_extractFontProgram() {
  53626. var stream = this.stream;
  53627. var subrs = [], charstrings = [];
  53628. var privateData = Object.create(null);
  53629. privateData['lenIV'] = 4;
  53630. var program = {
  53631. subrs: [],
  53632. charstrings: [],
  53633. properties: { 'privateData': privateData }
  53634. };
  53635. var token, length, data, lenIV, encoded;
  53636. while ((token = this.getToken()) !== null) {
  53637. if (token !== '/') {
  53638. continue;
  53639. }
  53640. token = this.getToken();
  53641. switch (token) {
  53642. case 'CharStrings':
  53643. this.getToken();
  53644. this.getToken();
  53645. this.getToken();
  53646. this.getToken();
  53647. while (true) {
  53648. token = this.getToken();
  53649. if (token === null || token === 'end') {
  53650. break;
  53651. }
  53652. if (token !== '/') {
  53653. continue;
  53654. }
  53655. var glyph = this.getToken();
  53656. length = this.readInt();
  53657. this.getToken();
  53658. data = stream.makeSubStream(stream.pos, length);
  53659. lenIV = program.properties.privateData['lenIV'];
  53660. encoded = decrypt(data.getBytes(), CHAR_STRS_ENCRYPT_KEY, lenIV);
  53661. stream.skip(length);
  53662. this.nextChar();
  53663. token = this.getToken();
  53664. if (token === 'noaccess') {
  53665. this.getToken();
  53666. }
  53667. charstrings.push({
  53668. glyph: glyph,
  53669. encoded: encoded
  53670. });
  53671. }
  53672. break;
  53673. case 'Subrs':
  53674. this.readInt();
  53675. this.getToken();
  53676. while ((token = this.getToken()) === 'dup') {
  53677. var index = this.readInt();
  53678. length = this.readInt();
  53679. this.getToken();
  53680. data = stream.makeSubStream(stream.pos, length);
  53681. lenIV = program.properties.privateData['lenIV'];
  53682. encoded = decrypt(data.getBytes(), CHAR_STRS_ENCRYPT_KEY, lenIV);
  53683. stream.skip(length);
  53684. this.nextChar();
  53685. token = this.getToken();
  53686. if (token === 'noaccess') {
  53687. this.getToken();
  53688. }
  53689. subrs[index] = encoded;
  53690. }
  53691. break;
  53692. case 'BlueValues':
  53693. case 'OtherBlues':
  53694. case 'FamilyBlues':
  53695. case 'FamilyOtherBlues':
  53696. var blueArray = this.readNumberArray();
  53697. if (blueArray.length > 0 && blueArray.length % 2 === 0 && HINTING_ENABLED) {
  53698. program.properties.privateData[token] = blueArray;
  53699. }
  53700. break;
  53701. case 'StemSnapH':
  53702. case 'StemSnapV':
  53703. program.properties.privateData[token] = this.readNumberArray();
  53704. break;
  53705. case 'StdHW':
  53706. case 'StdVW':
  53707. program.properties.privateData[token] = this.readNumberArray()[0];
  53708. break;
  53709. case 'BlueShift':
  53710. case 'lenIV':
  53711. case 'BlueFuzz':
  53712. case 'BlueScale':
  53713. case 'LanguageGroup':
  53714. case 'ExpansionFactor':
  53715. program.properties.privateData[token] = this.readNumber();
  53716. break;
  53717. case 'ForceBold':
  53718. program.properties.privateData[token] = this.readBoolean();
  53719. break;
  53720. }
  53721. }
  53722. for (var i = 0; i < charstrings.length; i++) {
  53723. glyph = charstrings[i].glyph;
  53724. encoded = charstrings[i].encoded;
  53725. var charString = new Type1CharString();
  53726. var error = charString.convert(encoded, subrs, this.seacAnalysisEnabled);
  53727. var output = charString.output;
  53728. if (error) {
  53729. output = [14];
  53730. }
  53731. program.charstrings.push({
  53732. glyphName: glyph,
  53733. charstring: output,
  53734. width: charString.width,
  53735. lsb: charString.lsb,
  53736. seac: charString.seac
  53737. });
  53738. }
  53739. return program;
  53740. },
  53741. extractFontHeader: function Type1Parser_extractFontHeader(properties) {
  53742. var token;
  53743. while ((token = this.getToken()) !== null) {
  53744. if (token !== '/') {
  53745. continue;
  53746. }
  53747. token = this.getToken();
  53748. switch (token) {
  53749. case 'FontMatrix':
  53750. var matrix = this.readNumberArray();
  53751. properties.fontMatrix = matrix;
  53752. break;
  53753. case 'Encoding':
  53754. var encodingArg = this.getToken();
  53755. var encoding;
  53756. if (!/^\d+$/.test(encodingArg)) {
  53757. encoding = getEncoding(encodingArg);
  53758. } else {
  53759. encoding = [];
  53760. var size = parseInt(encodingArg, 10) | 0;
  53761. this.getToken();
  53762. for (var j = 0; j < size; j++) {
  53763. token = this.getToken();
  53764. while (token !== 'dup' && token !== 'def') {
  53765. token = this.getToken();
  53766. if (token === null) {
  53767. return;
  53768. }
  53769. }
  53770. if (token === 'def') {
  53771. break;
  53772. }
  53773. var index = this.readInt();
  53774. this.getToken();
  53775. var glyph = this.getToken();
  53776. encoding[index] = glyph;
  53777. this.getToken();
  53778. }
  53779. }
  53780. properties.builtInEncoding = encoding;
  53781. break;
  53782. case 'FontBBox':
  53783. var fontBBox = this.readNumberArray();
  53784. properties.ascent = Math.max(fontBBox[3], fontBBox[1]);
  53785. properties.descent = Math.min(fontBBox[1], fontBBox[3]);
  53786. properties.ascentScaled = true;
  53787. break;
  53788. }
  53789. }
  53790. }
  53791. };
  53792. return Type1Parser;
  53793. }();
  53794. exports.Type1Parser = Type1Parser;
  53795. /***/ }),
  53796. /* 44 */
  53797. /***/ (function(module, exports, __w_pdfjs_require__) {
  53798. "use strict";
  53799. var sharedUtil = __w_pdfjs_require__(0);
  53800. var displayDOMUtils = __w_pdfjs_require__(3);
  53801. var displayPatternHelper = __w_pdfjs_require__(46);
  53802. var displayWebGL = __w_pdfjs_require__(25);
  53803. var FONT_IDENTITY_MATRIX = sharedUtil.FONT_IDENTITY_MATRIX;
  53804. var IDENTITY_MATRIX = sharedUtil.IDENTITY_MATRIX;
  53805. var ImageKind = sharedUtil.ImageKind;
  53806. var OPS = sharedUtil.OPS;
  53807. var TextRenderingMode = sharedUtil.TextRenderingMode;
  53808. var Uint32ArrayView = sharedUtil.Uint32ArrayView;
  53809. var Util = sharedUtil.Util;
  53810. var assert = sharedUtil.assert;
  53811. var info = sharedUtil.info;
  53812. var isNum = sharedUtil.isNum;
  53813. var isArray = sharedUtil.isArray;
  53814. var isLittleEndian = sharedUtil.isLittleEndian;
  53815. var error = sharedUtil.error;
  53816. var shadow = sharedUtil.shadow;
  53817. var warn = sharedUtil.warn;
  53818. var TilingPattern = displayPatternHelper.TilingPattern;
  53819. var getShadingPatternFromIR = displayPatternHelper.getShadingPatternFromIR;
  53820. var WebGLUtils = displayWebGL.WebGLUtils;
  53821. var hasCanvasTypedArrays = displayDOMUtils.hasCanvasTypedArrays;
  53822. var MIN_FONT_SIZE = 16;
  53823. var MAX_FONT_SIZE = 100;
  53824. var MAX_GROUP_SIZE = 4096;
  53825. var MIN_WIDTH_FACTOR = 0.65;
  53826. var COMPILE_TYPE3_GLYPHS = true;
  53827. var MAX_SIZE_TO_COMPILE = 1000;
  53828. var FULL_CHUNK_HEIGHT = 16;
  53829. var HasCanvasTypedArraysCached = {
  53830. get value() {
  53831. return shadow(HasCanvasTypedArraysCached, 'value', hasCanvasTypedArrays());
  53832. }
  53833. };
  53834. var IsLittleEndianCached = {
  53835. get value() {
  53836. return shadow(IsLittleEndianCached, 'value', isLittleEndian());
  53837. }
  53838. };
  53839. function addContextCurrentTransform(ctx) {
  53840. if (!ctx.mozCurrentTransform) {
  53841. ctx._originalSave = ctx.save;
  53842. ctx._originalRestore = ctx.restore;
  53843. ctx._originalRotate = ctx.rotate;
  53844. ctx._originalScale = ctx.scale;
  53845. ctx._originalTranslate = ctx.translate;
  53846. ctx._originalTransform = ctx.transform;
  53847. ctx._originalSetTransform = ctx.setTransform;
  53848. ctx._transformMatrix = ctx._transformMatrix || [
  53849. 1,
  53850. 0,
  53851. 0,
  53852. 1,
  53853. 0,
  53854. 0
  53855. ];
  53856. ctx._transformStack = [];
  53857. Object.defineProperty(ctx, 'mozCurrentTransform', {
  53858. get: function getCurrentTransform() {
  53859. return this._transformMatrix;
  53860. }
  53861. });
  53862. Object.defineProperty(ctx, 'mozCurrentTransformInverse', {
  53863. get: function getCurrentTransformInverse() {
  53864. var m = this._transformMatrix;
  53865. var a = m[0], b = m[1], c = m[2], d = m[3], e = m[4], f = m[5];
  53866. var ad_bc = a * d - b * c;
  53867. var bc_ad = b * c - a * d;
  53868. return [
  53869. d / ad_bc,
  53870. b / bc_ad,
  53871. c / bc_ad,
  53872. a / ad_bc,
  53873. (d * e - c * f) / bc_ad,
  53874. (b * e - a * f) / ad_bc
  53875. ];
  53876. }
  53877. });
  53878. ctx.save = function ctxSave() {
  53879. var old = this._transformMatrix;
  53880. this._transformStack.push(old);
  53881. this._transformMatrix = old.slice(0, 6);
  53882. this._originalSave();
  53883. };
  53884. ctx.restore = function ctxRestore() {
  53885. var prev = this._transformStack.pop();
  53886. if (prev) {
  53887. this._transformMatrix = prev;
  53888. this._originalRestore();
  53889. }
  53890. };
  53891. ctx.translate = function ctxTranslate(x, y) {
  53892. var m = this._transformMatrix;
  53893. m[4] = m[0] * x + m[2] * y + m[4];
  53894. m[5] = m[1] * x + m[3] * y + m[5];
  53895. this._originalTranslate(x, y);
  53896. };
  53897. ctx.scale = function ctxScale(x, y) {
  53898. var m = this._transformMatrix;
  53899. m[0] = m[0] * x;
  53900. m[1] = m[1] * x;
  53901. m[2] = m[2] * y;
  53902. m[3] = m[3] * y;
  53903. this._originalScale(x, y);
  53904. };
  53905. ctx.transform = function ctxTransform(a, b, c, d, e, f) {
  53906. var m = this._transformMatrix;
  53907. this._transformMatrix = [
  53908. m[0] * a + m[2] * b,
  53909. m[1] * a + m[3] * b,
  53910. m[0] * c + m[2] * d,
  53911. m[1] * c + m[3] * d,
  53912. m[0] * e + m[2] * f + m[4],
  53913. m[1] * e + m[3] * f + m[5]
  53914. ];
  53915. ctx._originalTransform(a, b, c, d, e, f);
  53916. };
  53917. ctx.setTransform = function ctxSetTransform(a, b, c, d, e, f) {
  53918. this._transformMatrix = [
  53919. a,
  53920. b,
  53921. c,
  53922. d,
  53923. e,
  53924. f
  53925. ];
  53926. ctx._originalSetTransform(a, b, c, d, e, f);
  53927. };
  53928. ctx.rotate = function ctxRotate(angle) {
  53929. var cosValue = Math.cos(angle);
  53930. var sinValue = Math.sin(angle);
  53931. var m = this._transformMatrix;
  53932. this._transformMatrix = [
  53933. m[0] * cosValue + m[2] * sinValue,
  53934. m[1] * cosValue + m[3] * sinValue,
  53935. m[0] * -sinValue + m[2] * cosValue,
  53936. m[1] * -sinValue + m[3] * cosValue,
  53937. m[4],
  53938. m[5]
  53939. ];
  53940. this._originalRotate(angle);
  53941. };
  53942. }
  53943. }
  53944. var CachedCanvases = function CachedCanvasesClosure() {
  53945. function CachedCanvases(canvasFactory) {
  53946. this.canvasFactory = canvasFactory;
  53947. this.cache = Object.create(null);
  53948. }
  53949. CachedCanvases.prototype = {
  53950. getCanvas: function CachedCanvases_getCanvas(id, width, height, trackTransform) {
  53951. var canvasEntry;
  53952. if (this.cache[id] !== undefined) {
  53953. canvasEntry = this.cache[id];
  53954. this.canvasFactory.reset(canvasEntry, width, height);
  53955. canvasEntry.context.setTransform(1, 0, 0, 1, 0, 0);
  53956. } else {
  53957. canvasEntry = this.canvasFactory.create(width, height);
  53958. this.cache[id] = canvasEntry;
  53959. }
  53960. if (trackTransform) {
  53961. addContextCurrentTransform(canvasEntry.context);
  53962. }
  53963. return canvasEntry;
  53964. },
  53965. clear: function () {
  53966. for (var id in this.cache) {
  53967. var canvasEntry = this.cache[id];
  53968. this.canvasFactory.destroy(canvasEntry);
  53969. delete this.cache[id];
  53970. }
  53971. }
  53972. };
  53973. return CachedCanvases;
  53974. }();
  53975. function compileType3Glyph(imgData) {
  53976. var POINT_TO_PROCESS_LIMIT = 1000;
  53977. var width = imgData.width, height = imgData.height;
  53978. var i, j, j0, width1 = width + 1;
  53979. var points = new Uint8Array(width1 * (height + 1));
  53980. var POINT_TYPES = new Uint8Array([
  53981. 0,
  53982. 2,
  53983. 4,
  53984. 0,
  53985. 1,
  53986. 0,
  53987. 5,
  53988. 4,
  53989. 8,
  53990. 10,
  53991. 0,
  53992. 8,
  53993. 0,
  53994. 2,
  53995. 1,
  53996. 0
  53997. ]);
  53998. var lineSize = width + 7 & ~7, data0 = imgData.data;
  53999. var data = new Uint8Array(lineSize * height), pos = 0, ii;
  54000. for (i = 0, ii = data0.length; i < ii; i++) {
  54001. var mask = 128, elem = data0[i];
  54002. while (mask > 0) {
  54003. data[pos++] = elem & mask ? 0 : 255;
  54004. mask >>= 1;
  54005. }
  54006. }
  54007. var count = 0;
  54008. pos = 0;
  54009. if (data[pos] !== 0) {
  54010. points[0] = 1;
  54011. ++count;
  54012. }
  54013. for (j = 1; j < width; j++) {
  54014. if (data[pos] !== data[pos + 1]) {
  54015. points[j] = data[pos] ? 2 : 1;
  54016. ++count;
  54017. }
  54018. pos++;
  54019. }
  54020. if (data[pos] !== 0) {
  54021. points[j] = 2;
  54022. ++count;
  54023. }
  54024. for (i = 1; i < height; i++) {
  54025. pos = i * lineSize;
  54026. j0 = i * width1;
  54027. if (data[pos - lineSize] !== data[pos]) {
  54028. points[j0] = data[pos] ? 1 : 8;
  54029. ++count;
  54030. }
  54031. var sum = (data[pos] ? 4 : 0) + (data[pos - lineSize] ? 8 : 0);
  54032. for (j = 1; j < width; j++) {
  54033. sum = (sum >> 2) + (data[pos + 1] ? 4 : 0) + (data[pos - lineSize + 1] ? 8 : 0);
  54034. if (POINT_TYPES[sum]) {
  54035. points[j0 + j] = POINT_TYPES[sum];
  54036. ++count;
  54037. }
  54038. pos++;
  54039. }
  54040. if (data[pos - lineSize] !== data[pos]) {
  54041. points[j0 + j] = data[pos] ? 2 : 4;
  54042. ++count;
  54043. }
  54044. if (count > POINT_TO_PROCESS_LIMIT) {
  54045. return null;
  54046. }
  54047. }
  54048. pos = lineSize * (height - 1);
  54049. j0 = i * width1;
  54050. if (data[pos] !== 0) {
  54051. points[j0] = 8;
  54052. ++count;
  54053. }
  54054. for (j = 1; j < width; j++) {
  54055. if (data[pos] !== data[pos + 1]) {
  54056. points[j0 + j] = data[pos] ? 4 : 8;
  54057. ++count;
  54058. }
  54059. pos++;
  54060. }
  54061. if (data[pos] !== 0) {
  54062. points[j0 + j] = 4;
  54063. ++count;
  54064. }
  54065. if (count > POINT_TO_PROCESS_LIMIT) {
  54066. return null;
  54067. }
  54068. var steps = new Int32Array([
  54069. 0,
  54070. width1,
  54071. -1,
  54072. 0,
  54073. -width1,
  54074. 0,
  54075. 0,
  54076. 0,
  54077. 1
  54078. ]);
  54079. var outlines = [];
  54080. for (i = 0; count && i <= height; i++) {
  54081. var p = i * width1;
  54082. var end = p + width;
  54083. while (p < end && !points[p]) {
  54084. p++;
  54085. }
  54086. if (p === end) {
  54087. continue;
  54088. }
  54089. var coords = [
  54090. p % width1,
  54091. i
  54092. ];
  54093. var type = points[p], p0 = p, pp;
  54094. do {
  54095. var step = steps[type];
  54096. do {
  54097. p += step;
  54098. } while (!points[p]);
  54099. pp = points[p];
  54100. if (pp !== 5 && pp !== 10) {
  54101. type = pp;
  54102. points[p] = 0;
  54103. } else {
  54104. type = pp & 0x33 * type >> 4;
  54105. points[p] &= type >> 2 | type << 2;
  54106. }
  54107. coords.push(p % width1);
  54108. coords.push(p / width1 | 0);
  54109. --count;
  54110. } while (p0 !== p);
  54111. outlines.push(coords);
  54112. --i;
  54113. }
  54114. var drawOutline = function (c) {
  54115. c.save();
  54116. c.scale(1 / width, -1 / height);
  54117. c.translate(0, -height);
  54118. c.beginPath();
  54119. for (var i = 0, ii = outlines.length; i < ii; i++) {
  54120. var o = outlines[i];
  54121. c.moveTo(o[0], o[1]);
  54122. for (var j = 2, jj = o.length; j < jj; j += 2) {
  54123. c.lineTo(o[j], o[j + 1]);
  54124. }
  54125. }
  54126. c.fill();
  54127. c.beginPath();
  54128. c.restore();
  54129. };
  54130. return drawOutline;
  54131. }
  54132. var CanvasExtraState = function CanvasExtraStateClosure() {
  54133. function CanvasExtraState(old) {
  54134. this.alphaIsShape = false;
  54135. this.fontSize = 0;
  54136. this.fontSizeScale = 1;
  54137. this.textMatrix = IDENTITY_MATRIX;
  54138. this.textMatrixScale = 1;
  54139. this.fontMatrix = FONT_IDENTITY_MATRIX;
  54140. this.leading = 0;
  54141. this.x = 0;
  54142. this.y = 0;
  54143. this.lineX = 0;
  54144. this.lineY = 0;
  54145. this.charSpacing = 0;
  54146. this.wordSpacing = 0;
  54147. this.textHScale = 1;
  54148. this.textRenderingMode = TextRenderingMode.FILL;
  54149. this.textRise = 0;
  54150. this.fillColor = '#000000';
  54151. this.strokeColor = '#000000';
  54152. this.patternFill = false;
  54153. this.fillAlpha = 1;
  54154. this.strokeAlpha = 1;
  54155. this.lineWidth = 1;
  54156. this.activeSMask = null;
  54157. this.resumeSMaskCtx = null;
  54158. this.old = old;
  54159. }
  54160. CanvasExtraState.prototype = {
  54161. clone: function CanvasExtraState_clone() {
  54162. return Object.create(this);
  54163. },
  54164. setCurrentPoint: function CanvasExtraState_setCurrentPoint(x, y) {
  54165. this.x = x;
  54166. this.y = y;
  54167. }
  54168. };
  54169. return CanvasExtraState;
  54170. }();
  54171. var CanvasGraphics = function CanvasGraphicsClosure() {
  54172. var EXECUTION_TIME = 15;
  54173. var EXECUTION_STEPS = 10;
  54174. function CanvasGraphics(canvasCtx, commonObjs, objs, canvasFactory, imageLayer) {
  54175. this.ctx = canvasCtx;
  54176. this.current = new CanvasExtraState();
  54177. this.stateStack = [];
  54178. this.pendingClip = null;
  54179. this.pendingEOFill = false;
  54180. this.res = null;
  54181. this.xobjs = null;
  54182. this.commonObjs = commonObjs;
  54183. this.objs = objs;
  54184. this.canvasFactory = canvasFactory;
  54185. this.imageLayer = imageLayer;
  54186. this.groupStack = [];
  54187. this.processingType3 = null;
  54188. this.baseTransform = null;
  54189. this.baseTransformStack = [];
  54190. this.groupLevel = 0;
  54191. this.smaskStack = [];
  54192. this.smaskCounter = 0;
  54193. this.tempSMask = null;
  54194. this.cachedCanvases = new CachedCanvases(this.canvasFactory);
  54195. if (canvasCtx) {
  54196. addContextCurrentTransform(canvasCtx);
  54197. }
  54198. this.cachedGetSinglePixelWidth = null;
  54199. }
  54200. function putBinaryImageData(ctx, imgData) {
  54201. if (typeof ImageData !== 'undefined' && imgData instanceof ImageData) {
  54202. ctx.putImageData(imgData, 0, 0);
  54203. return;
  54204. }
  54205. var height = imgData.height, width = imgData.width;
  54206. var partialChunkHeight = height % FULL_CHUNK_HEIGHT;
  54207. var fullChunks = (height - partialChunkHeight) / FULL_CHUNK_HEIGHT;
  54208. var totalChunks = partialChunkHeight === 0 ? fullChunks : fullChunks + 1;
  54209. var chunkImgData = ctx.createImageData(width, FULL_CHUNK_HEIGHT);
  54210. var srcPos = 0, destPos;
  54211. var src = imgData.data;
  54212. var dest = chunkImgData.data;
  54213. var i, j, thisChunkHeight, elemsInThisChunk;
  54214. if (imgData.kind === ImageKind.GRAYSCALE_1BPP) {
  54215. var srcLength = src.byteLength;
  54216. var dest32 = HasCanvasTypedArraysCached.value ? new Uint32Array(dest.buffer) : new Uint32ArrayView(dest);
  54217. var dest32DataLength = dest32.length;
  54218. var fullSrcDiff = width + 7 >> 3;
  54219. var white = 0xFFFFFFFF;
  54220. var black = IsLittleEndianCached.value || !HasCanvasTypedArraysCached.value ? 0xFF000000 : 0x000000FF;
  54221. for (i = 0; i < totalChunks; i++) {
  54222. thisChunkHeight = i < fullChunks ? FULL_CHUNK_HEIGHT : partialChunkHeight;
  54223. destPos = 0;
  54224. for (j = 0; j < thisChunkHeight; j++) {
  54225. var srcDiff = srcLength - srcPos;
  54226. var k = 0;
  54227. var kEnd = srcDiff > fullSrcDiff ? width : srcDiff * 8 - 7;
  54228. var kEndUnrolled = kEnd & ~7;
  54229. var mask = 0;
  54230. var srcByte = 0;
  54231. for (; k < kEndUnrolled; k += 8) {
  54232. srcByte = src[srcPos++];
  54233. dest32[destPos++] = srcByte & 128 ? white : black;
  54234. dest32[destPos++] = srcByte & 64 ? white : black;
  54235. dest32[destPos++] = srcByte & 32 ? white : black;
  54236. dest32[destPos++] = srcByte & 16 ? white : black;
  54237. dest32[destPos++] = srcByte & 8 ? white : black;
  54238. dest32[destPos++] = srcByte & 4 ? white : black;
  54239. dest32[destPos++] = srcByte & 2 ? white : black;
  54240. dest32[destPos++] = srcByte & 1 ? white : black;
  54241. }
  54242. for (; k < kEnd; k++) {
  54243. if (mask === 0) {
  54244. srcByte = src[srcPos++];
  54245. mask = 128;
  54246. }
  54247. dest32[destPos++] = srcByte & mask ? white : black;
  54248. mask >>= 1;
  54249. }
  54250. }
  54251. while (destPos < dest32DataLength) {
  54252. dest32[destPos++] = 0;
  54253. }
  54254. ctx.putImageData(chunkImgData, 0, i * FULL_CHUNK_HEIGHT);
  54255. }
  54256. } else if (imgData.kind === ImageKind.RGBA_32BPP) {
  54257. j = 0;
  54258. elemsInThisChunk = width * FULL_CHUNK_HEIGHT * 4;
  54259. for (i = 0; i < fullChunks; i++) {
  54260. dest.set(src.subarray(srcPos, srcPos + elemsInThisChunk));
  54261. srcPos += elemsInThisChunk;
  54262. ctx.putImageData(chunkImgData, 0, j);
  54263. j += FULL_CHUNK_HEIGHT;
  54264. }
  54265. if (i < totalChunks) {
  54266. elemsInThisChunk = width * partialChunkHeight * 4;
  54267. dest.set(src.subarray(srcPos, srcPos + elemsInThisChunk));
  54268. ctx.putImageData(chunkImgData, 0, j);
  54269. }
  54270. } else if (imgData.kind === ImageKind.RGB_24BPP) {
  54271. thisChunkHeight = FULL_CHUNK_HEIGHT;
  54272. elemsInThisChunk = width * thisChunkHeight;
  54273. for (i = 0; i < totalChunks; i++) {
  54274. if (i >= fullChunks) {
  54275. thisChunkHeight = partialChunkHeight;
  54276. elemsInThisChunk = width * thisChunkHeight;
  54277. }
  54278. destPos = 0;
  54279. for (j = elemsInThisChunk; j--;) {
  54280. dest[destPos++] = src[srcPos++];
  54281. dest[destPos++] = src[srcPos++];
  54282. dest[destPos++] = src[srcPos++];
  54283. dest[destPos++] = 255;
  54284. }
  54285. ctx.putImageData(chunkImgData, 0, i * FULL_CHUNK_HEIGHT);
  54286. }
  54287. } else {
  54288. error('bad image kind: ' + imgData.kind);
  54289. }
  54290. }
  54291. function putBinaryImageMask(ctx, imgData) {
  54292. var height = imgData.height, width = imgData.width;
  54293. var partialChunkHeight = height % FULL_CHUNK_HEIGHT;
  54294. var fullChunks = (height - partialChunkHeight) / FULL_CHUNK_HEIGHT;
  54295. var totalChunks = partialChunkHeight === 0 ? fullChunks : fullChunks + 1;
  54296. var chunkImgData = ctx.createImageData(width, FULL_CHUNK_HEIGHT);
  54297. var srcPos = 0;
  54298. var src = imgData.data;
  54299. var dest = chunkImgData.data;
  54300. for (var i = 0; i < totalChunks; i++) {
  54301. var thisChunkHeight = i < fullChunks ? FULL_CHUNK_HEIGHT : partialChunkHeight;
  54302. var destPos = 3;
  54303. for (var j = 0; j < thisChunkHeight; j++) {
  54304. var mask = 0;
  54305. for (var k = 0; k < width; k++) {
  54306. if (!mask) {
  54307. var elem = src[srcPos++];
  54308. mask = 128;
  54309. }
  54310. dest[destPos] = elem & mask ? 0 : 255;
  54311. destPos += 4;
  54312. mask >>= 1;
  54313. }
  54314. }
  54315. ctx.putImageData(chunkImgData, 0, i * FULL_CHUNK_HEIGHT);
  54316. }
  54317. }
  54318. function copyCtxState(sourceCtx, destCtx) {
  54319. var properties = [
  54320. 'strokeStyle',
  54321. 'fillStyle',
  54322. 'fillRule',
  54323. 'globalAlpha',
  54324. 'lineWidth',
  54325. 'lineCap',
  54326. 'lineJoin',
  54327. 'miterLimit',
  54328. 'globalCompositeOperation',
  54329. 'font'
  54330. ];
  54331. for (var i = 0, ii = properties.length; i < ii; i++) {
  54332. var property = properties[i];
  54333. if (sourceCtx[property] !== undefined) {
  54334. destCtx[property] = sourceCtx[property];
  54335. }
  54336. }
  54337. if (sourceCtx.setLineDash !== undefined) {
  54338. destCtx.setLineDash(sourceCtx.getLineDash());
  54339. destCtx.lineDashOffset = sourceCtx.lineDashOffset;
  54340. }
  54341. }
  54342. function composeSMaskBackdrop(bytes, r0, g0, b0) {
  54343. var length = bytes.length;
  54344. for (var i = 3; i < length; i += 4) {
  54345. var alpha = bytes[i];
  54346. if (alpha === 0) {
  54347. bytes[i - 3] = r0;
  54348. bytes[i - 2] = g0;
  54349. bytes[i - 1] = b0;
  54350. } else if (alpha < 255) {
  54351. var alpha_ = 255 - alpha;
  54352. bytes[i - 3] = bytes[i - 3] * alpha + r0 * alpha_ >> 8;
  54353. bytes[i - 2] = bytes[i - 2] * alpha + g0 * alpha_ >> 8;
  54354. bytes[i - 1] = bytes[i - 1] * alpha + b0 * alpha_ >> 8;
  54355. }
  54356. }
  54357. }
  54358. function composeSMaskAlpha(maskData, layerData, transferMap) {
  54359. var length = maskData.length;
  54360. var scale = 1 / 255;
  54361. for (var i = 3; i < length; i += 4) {
  54362. var alpha = transferMap ? transferMap[maskData[i]] : maskData[i];
  54363. layerData[i] = layerData[i] * alpha * scale | 0;
  54364. }
  54365. }
  54366. function composeSMaskLuminosity(maskData, layerData, transferMap) {
  54367. var length = maskData.length;
  54368. for (var i = 3; i < length; i += 4) {
  54369. var y = maskData[i - 3] * 77 + maskData[i - 2] * 152 + maskData[i - 1] * 28;
  54370. layerData[i] = transferMap ? layerData[i] * transferMap[y >> 8] >> 8 : layerData[i] * y >> 16;
  54371. }
  54372. }
  54373. function genericComposeSMask(maskCtx, layerCtx, width, height, subtype, backdrop, transferMap) {
  54374. var hasBackdrop = !!backdrop;
  54375. var r0 = hasBackdrop ? backdrop[0] : 0;
  54376. var g0 = hasBackdrop ? backdrop[1] : 0;
  54377. var b0 = hasBackdrop ? backdrop[2] : 0;
  54378. var composeFn;
  54379. if (subtype === 'Luminosity') {
  54380. composeFn = composeSMaskLuminosity;
  54381. } else {
  54382. composeFn = composeSMaskAlpha;
  54383. }
  54384. var PIXELS_TO_PROCESS = 1048576;
  54385. var chunkSize = Math.min(height, Math.ceil(PIXELS_TO_PROCESS / width));
  54386. for (var row = 0; row < height; row += chunkSize) {
  54387. var chunkHeight = Math.min(chunkSize, height - row);
  54388. var maskData = maskCtx.getImageData(0, row, width, chunkHeight);
  54389. var layerData = layerCtx.getImageData(0, row, width, chunkHeight);
  54390. if (hasBackdrop) {
  54391. composeSMaskBackdrop(maskData.data, r0, g0, b0);
  54392. }
  54393. composeFn(maskData.data, layerData.data, transferMap);
  54394. maskCtx.putImageData(layerData, 0, row);
  54395. }
  54396. }
  54397. function composeSMask(ctx, smask, layerCtx) {
  54398. var mask = smask.canvas;
  54399. var maskCtx = smask.context;
  54400. ctx.setTransform(smask.scaleX, 0, 0, smask.scaleY, smask.offsetX, smask.offsetY);
  54401. var backdrop = smask.backdrop || null;
  54402. if (!smask.transferMap && WebGLUtils.isEnabled) {
  54403. var composed = WebGLUtils.composeSMask(layerCtx.canvas, mask, {
  54404. subtype: smask.subtype,
  54405. backdrop: backdrop
  54406. });
  54407. ctx.setTransform(1, 0, 0, 1, 0, 0);
  54408. ctx.drawImage(composed, smask.offsetX, smask.offsetY);
  54409. return;
  54410. }
  54411. genericComposeSMask(maskCtx, layerCtx, mask.width, mask.height, smask.subtype, backdrop, smask.transferMap);
  54412. ctx.drawImage(mask, 0, 0);
  54413. }
  54414. var LINE_CAP_STYLES = [
  54415. 'butt',
  54416. 'round',
  54417. 'square'
  54418. ];
  54419. var LINE_JOIN_STYLES = [
  54420. 'miter',
  54421. 'round',
  54422. 'bevel'
  54423. ];
  54424. var NORMAL_CLIP = {};
  54425. var EO_CLIP = {};
  54426. CanvasGraphics.prototype = {
  54427. beginDrawing: function CanvasGraphics_beginDrawing(transform, viewport, transparency) {
  54428. var width = this.ctx.canvas.width;
  54429. var height = this.ctx.canvas.height;
  54430. this.ctx.save();
  54431. this.ctx.fillStyle = 'rgb(255, 255, 255)';
  54432. this.ctx.fillRect(0, 0, width, height);
  54433. this.ctx.restore();
  54434. if (transparency) {
  54435. var transparentCanvas = this.cachedCanvases.getCanvas('transparent', width, height, true);
  54436. this.compositeCtx = this.ctx;
  54437. this.transparentCanvas = transparentCanvas.canvas;
  54438. this.ctx = transparentCanvas.context;
  54439. this.ctx.save();
  54440. this.ctx.transform.apply(this.ctx, this.compositeCtx.mozCurrentTransform);
  54441. }
  54442. this.ctx.save();
  54443. if (transform) {
  54444. this.ctx.transform.apply(this.ctx, transform);
  54445. }
  54446. this.ctx.transform.apply(this.ctx, viewport.transform);
  54447. this.baseTransform = this.ctx.mozCurrentTransform.slice();
  54448. if (this.imageLayer) {
  54449. this.imageLayer.beginLayout();
  54450. }
  54451. },
  54452. executeOperatorList: function CanvasGraphics_executeOperatorList(operatorList, executionStartIdx, continueCallback, stepper) {
  54453. var argsArray = operatorList.argsArray;
  54454. var fnArray = operatorList.fnArray;
  54455. var i = executionStartIdx || 0;
  54456. var argsArrayLen = argsArray.length;
  54457. if (argsArrayLen === i) {
  54458. return i;
  54459. }
  54460. var chunkOperations = argsArrayLen - i > EXECUTION_STEPS && typeof continueCallback === 'function';
  54461. var endTime = chunkOperations ? Date.now() + EXECUTION_TIME : 0;
  54462. var steps = 0;
  54463. var commonObjs = this.commonObjs;
  54464. var objs = this.objs;
  54465. var fnId;
  54466. while (true) {
  54467. if (stepper !== undefined && i === stepper.nextBreakPoint) {
  54468. stepper.breakIt(i, continueCallback);
  54469. return i;
  54470. }
  54471. fnId = fnArray[i];
  54472. if (fnId !== OPS.dependency) {
  54473. this[fnId].apply(this, argsArray[i]);
  54474. } else {
  54475. var deps = argsArray[i];
  54476. for (var n = 0, nn = deps.length; n < nn; n++) {
  54477. var depObjId = deps[n];
  54478. var common = depObjId[0] === 'g' && depObjId[1] === '_';
  54479. var objsPool = common ? commonObjs : objs;
  54480. if (!objsPool.isResolved(depObjId)) {
  54481. objsPool.get(depObjId, continueCallback);
  54482. return i;
  54483. }
  54484. }
  54485. }
  54486. i++;
  54487. if (i === argsArrayLen) {
  54488. return i;
  54489. }
  54490. if (chunkOperations && ++steps > EXECUTION_STEPS) {
  54491. if (Date.now() > endTime) {
  54492. continueCallback();
  54493. return i;
  54494. }
  54495. steps = 0;
  54496. }
  54497. }
  54498. },
  54499. endDrawing: function CanvasGraphics_endDrawing() {
  54500. if (this.current.activeSMask !== null) {
  54501. this.endSMaskGroup();
  54502. }
  54503. this.ctx.restore();
  54504. if (this.transparentCanvas) {
  54505. this.ctx = this.compositeCtx;
  54506. this.ctx.save();
  54507. this.ctx.setTransform(1, 0, 0, 1, 0, 0);
  54508. this.ctx.drawImage(this.transparentCanvas, 0, 0);
  54509. this.ctx.restore();
  54510. this.transparentCanvas = null;
  54511. }
  54512. this.cachedCanvases.clear();
  54513. WebGLUtils.clear();
  54514. if (this.imageLayer) {
  54515. this.imageLayer.endLayout();
  54516. }
  54517. },
  54518. setLineWidth: function CanvasGraphics_setLineWidth(width) {
  54519. this.current.lineWidth = width;
  54520. this.ctx.lineWidth = width;
  54521. },
  54522. setLineCap: function CanvasGraphics_setLineCap(style) {
  54523. this.ctx.lineCap = LINE_CAP_STYLES[style];
  54524. },
  54525. setLineJoin: function CanvasGraphics_setLineJoin(style) {
  54526. this.ctx.lineJoin = LINE_JOIN_STYLES[style];
  54527. },
  54528. setMiterLimit: function CanvasGraphics_setMiterLimit(limit) {
  54529. this.ctx.miterLimit = limit;
  54530. },
  54531. setDash: function CanvasGraphics_setDash(dashArray, dashPhase) {
  54532. var ctx = this.ctx;
  54533. if (ctx.setLineDash !== undefined) {
  54534. ctx.setLineDash(dashArray);
  54535. ctx.lineDashOffset = dashPhase;
  54536. }
  54537. },
  54538. setRenderingIntent: function CanvasGraphics_setRenderingIntent(intent) {
  54539. },
  54540. setFlatness: function CanvasGraphics_setFlatness(flatness) {
  54541. },
  54542. setGState: function CanvasGraphics_setGState(states) {
  54543. for (var i = 0, ii = states.length; i < ii; i++) {
  54544. var state = states[i];
  54545. var key = state[0];
  54546. var value = state[1];
  54547. switch (key) {
  54548. case 'LW':
  54549. this.setLineWidth(value);
  54550. break;
  54551. case 'LC':
  54552. this.setLineCap(value);
  54553. break;
  54554. case 'LJ':
  54555. this.setLineJoin(value);
  54556. break;
  54557. case 'ML':
  54558. this.setMiterLimit(value);
  54559. break;
  54560. case 'D':
  54561. this.setDash(value[0], value[1]);
  54562. break;
  54563. case 'RI':
  54564. this.setRenderingIntent(value);
  54565. break;
  54566. case 'FL':
  54567. this.setFlatness(value);
  54568. break;
  54569. case 'Font':
  54570. this.setFont(value[0], value[1]);
  54571. break;
  54572. case 'CA':
  54573. this.current.strokeAlpha = state[1];
  54574. break;
  54575. case 'ca':
  54576. this.current.fillAlpha = state[1];
  54577. this.ctx.globalAlpha = state[1];
  54578. break;
  54579. case 'BM':
  54580. if (value && value.name && value.name !== 'Normal') {
  54581. var mode = value.name.replace(/([A-Z])/g, function (c) {
  54582. return '-' + c.toLowerCase();
  54583. }).substring(1);
  54584. this.ctx.globalCompositeOperation = mode;
  54585. if (this.ctx.globalCompositeOperation !== mode) {
  54586. warn('globalCompositeOperation "' + mode + '" is not supported');
  54587. }
  54588. } else {
  54589. this.ctx.globalCompositeOperation = 'source-over';
  54590. }
  54591. break;
  54592. case 'SMask':
  54593. if (this.current.activeSMask) {
  54594. if (this.stateStack.length > 0 && this.stateStack[this.stateStack.length - 1].activeSMask === this.current.activeSMask) {
  54595. this.suspendSMaskGroup();
  54596. } else {
  54597. this.endSMaskGroup();
  54598. }
  54599. }
  54600. this.current.activeSMask = value ? this.tempSMask : null;
  54601. if (this.current.activeSMask) {
  54602. this.beginSMaskGroup();
  54603. }
  54604. this.tempSMask = null;
  54605. break;
  54606. }
  54607. }
  54608. },
  54609. beginSMaskGroup: function CanvasGraphics_beginSMaskGroup() {
  54610. var activeSMask = this.current.activeSMask;
  54611. var drawnWidth = activeSMask.canvas.width;
  54612. var drawnHeight = activeSMask.canvas.height;
  54613. var cacheId = 'smaskGroupAt' + this.groupLevel;
  54614. var scratchCanvas = this.cachedCanvases.getCanvas(cacheId, drawnWidth, drawnHeight, true);
  54615. var currentCtx = this.ctx;
  54616. var currentTransform = currentCtx.mozCurrentTransform;
  54617. this.ctx.save();
  54618. var groupCtx = scratchCanvas.context;
  54619. groupCtx.scale(1 / activeSMask.scaleX, 1 / activeSMask.scaleY);
  54620. groupCtx.translate(-activeSMask.offsetX, -activeSMask.offsetY);
  54621. groupCtx.transform.apply(groupCtx, currentTransform);
  54622. activeSMask.startTransformInverse = groupCtx.mozCurrentTransformInverse;
  54623. copyCtxState(currentCtx, groupCtx);
  54624. this.ctx = groupCtx;
  54625. this.setGState([
  54626. [
  54627. 'BM',
  54628. 'Normal'
  54629. ],
  54630. [
  54631. 'ca',
  54632. 1
  54633. ],
  54634. [
  54635. 'CA',
  54636. 1
  54637. ]
  54638. ]);
  54639. this.groupStack.push(currentCtx);
  54640. this.groupLevel++;
  54641. },
  54642. suspendSMaskGroup: function CanvasGraphics_endSMaskGroup() {
  54643. var groupCtx = this.ctx;
  54644. this.groupLevel--;
  54645. this.ctx = this.groupStack.pop();
  54646. composeSMask(this.ctx, this.current.activeSMask, groupCtx);
  54647. this.ctx.restore();
  54648. this.ctx.save();
  54649. copyCtxState(groupCtx, this.ctx);
  54650. this.current.resumeSMaskCtx = groupCtx;
  54651. var deltaTransform = Util.transform(this.current.activeSMask.startTransformInverse, groupCtx.mozCurrentTransform);
  54652. this.ctx.transform.apply(this.ctx, deltaTransform);
  54653. groupCtx.save();
  54654. groupCtx.setTransform(1, 0, 0, 1, 0, 0);
  54655. groupCtx.clearRect(0, 0, groupCtx.canvas.width, groupCtx.canvas.height);
  54656. groupCtx.restore();
  54657. },
  54658. resumeSMaskGroup: function CanvasGraphics_endSMaskGroup() {
  54659. var groupCtx = this.current.resumeSMaskCtx;
  54660. var currentCtx = this.ctx;
  54661. this.ctx = groupCtx;
  54662. this.groupStack.push(currentCtx);
  54663. this.groupLevel++;
  54664. },
  54665. endSMaskGroup: function CanvasGraphics_endSMaskGroup() {
  54666. var groupCtx = this.ctx;
  54667. this.groupLevel--;
  54668. this.ctx = this.groupStack.pop();
  54669. composeSMask(this.ctx, this.current.activeSMask, groupCtx);
  54670. this.ctx.restore();
  54671. copyCtxState(groupCtx, this.ctx);
  54672. var deltaTransform = Util.transform(this.current.activeSMask.startTransformInverse, groupCtx.mozCurrentTransform);
  54673. this.ctx.transform.apply(this.ctx, deltaTransform);
  54674. },
  54675. save: function CanvasGraphics_save() {
  54676. this.ctx.save();
  54677. var old = this.current;
  54678. this.stateStack.push(old);
  54679. this.current = old.clone();
  54680. this.current.resumeSMaskCtx = null;
  54681. },
  54682. restore: function CanvasGraphics_restore() {
  54683. if (this.current.resumeSMaskCtx) {
  54684. this.resumeSMaskGroup();
  54685. }
  54686. if (this.current.activeSMask !== null && (this.stateStack.length === 0 || this.stateStack[this.stateStack.length - 1].activeSMask !== this.current.activeSMask)) {
  54687. this.endSMaskGroup();
  54688. }
  54689. if (this.stateStack.length !== 0) {
  54690. this.current = this.stateStack.pop();
  54691. this.ctx.restore();
  54692. this.pendingClip = null;
  54693. this.cachedGetSinglePixelWidth = null;
  54694. }
  54695. },
  54696. transform: function CanvasGraphics_transform(a, b, c, d, e, f) {
  54697. this.ctx.transform(a, b, c, d, e, f);
  54698. this.cachedGetSinglePixelWidth = null;
  54699. },
  54700. constructPath: function CanvasGraphics_constructPath(ops, args) {
  54701. var ctx = this.ctx;
  54702. var current = this.current;
  54703. var x = current.x, y = current.y;
  54704. for (var i = 0, j = 0, ii = ops.length; i < ii; i++) {
  54705. switch (ops[i] | 0) {
  54706. case OPS.rectangle:
  54707. x = args[j++];
  54708. y = args[j++];
  54709. var width = args[j++];
  54710. var height = args[j++];
  54711. if (width === 0) {
  54712. width = this.getSinglePixelWidth();
  54713. }
  54714. if (height === 0) {
  54715. height = this.getSinglePixelWidth();
  54716. }
  54717. var xw = x + width;
  54718. var yh = y + height;
  54719. this.ctx.moveTo(x, y);
  54720. this.ctx.lineTo(xw, y);
  54721. this.ctx.lineTo(xw, yh);
  54722. this.ctx.lineTo(x, yh);
  54723. this.ctx.lineTo(x, y);
  54724. this.ctx.closePath();
  54725. break;
  54726. case OPS.moveTo:
  54727. x = args[j++];
  54728. y = args[j++];
  54729. ctx.moveTo(x, y);
  54730. break;
  54731. case OPS.lineTo:
  54732. x = args[j++];
  54733. y = args[j++];
  54734. ctx.lineTo(x, y);
  54735. break;
  54736. case OPS.curveTo:
  54737. x = args[j + 4];
  54738. y = args[j + 5];
  54739. ctx.bezierCurveTo(args[j], args[j + 1], args[j + 2], args[j + 3], x, y);
  54740. j += 6;
  54741. break;
  54742. case OPS.curveTo2:
  54743. ctx.bezierCurveTo(x, y, args[j], args[j + 1], args[j + 2], args[j + 3]);
  54744. x = args[j + 2];
  54745. y = args[j + 3];
  54746. j += 4;
  54747. break;
  54748. case OPS.curveTo3:
  54749. x = args[j + 2];
  54750. y = args[j + 3];
  54751. ctx.bezierCurveTo(args[j], args[j + 1], x, y, x, y);
  54752. j += 4;
  54753. break;
  54754. case OPS.closePath:
  54755. ctx.closePath();
  54756. break;
  54757. }
  54758. }
  54759. current.setCurrentPoint(x, y);
  54760. },
  54761. closePath: function CanvasGraphics_closePath() {
  54762. this.ctx.closePath();
  54763. },
  54764. stroke: function CanvasGraphics_stroke(consumePath) {
  54765. consumePath = typeof consumePath !== 'undefined' ? consumePath : true;
  54766. var ctx = this.ctx;
  54767. var strokeColor = this.current.strokeColor;
  54768. ctx.lineWidth = Math.max(this.getSinglePixelWidth() * MIN_WIDTH_FACTOR, this.current.lineWidth);
  54769. ctx.globalAlpha = this.current.strokeAlpha;
  54770. if (strokeColor && strokeColor.hasOwnProperty('type') && strokeColor.type === 'Pattern') {
  54771. ctx.save();
  54772. ctx.strokeStyle = strokeColor.getPattern(ctx, this);
  54773. ctx.stroke();
  54774. ctx.restore();
  54775. } else {
  54776. ctx.stroke();
  54777. }
  54778. if (consumePath) {
  54779. this.consumePath();
  54780. }
  54781. ctx.globalAlpha = this.current.fillAlpha;
  54782. },
  54783. closeStroke: function CanvasGraphics_closeStroke() {
  54784. this.closePath();
  54785. this.stroke();
  54786. },
  54787. fill: function CanvasGraphics_fill(consumePath) {
  54788. consumePath = typeof consumePath !== 'undefined' ? consumePath : true;
  54789. var ctx = this.ctx;
  54790. var fillColor = this.current.fillColor;
  54791. var isPatternFill = this.current.patternFill;
  54792. var needRestore = false;
  54793. if (isPatternFill) {
  54794. ctx.save();
  54795. if (this.baseTransform) {
  54796. ctx.setTransform.apply(ctx, this.baseTransform);
  54797. }
  54798. ctx.fillStyle = fillColor.getPattern(ctx, this);
  54799. needRestore = true;
  54800. }
  54801. if (this.pendingEOFill) {
  54802. ctx.fill('evenodd');
  54803. this.pendingEOFill = false;
  54804. } else {
  54805. ctx.fill();
  54806. }
  54807. if (needRestore) {
  54808. ctx.restore();
  54809. }
  54810. if (consumePath) {
  54811. this.consumePath();
  54812. }
  54813. },
  54814. eoFill: function CanvasGraphics_eoFill() {
  54815. this.pendingEOFill = true;
  54816. this.fill();
  54817. },
  54818. fillStroke: function CanvasGraphics_fillStroke() {
  54819. this.fill(false);
  54820. this.stroke(false);
  54821. this.consumePath();
  54822. },
  54823. eoFillStroke: function CanvasGraphics_eoFillStroke() {
  54824. this.pendingEOFill = true;
  54825. this.fillStroke();
  54826. },
  54827. closeFillStroke: function CanvasGraphics_closeFillStroke() {
  54828. this.closePath();
  54829. this.fillStroke();
  54830. },
  54831. closeEOFillStroke: function CanvasGraphics_closeEOFillStroke() {
  54832. this.pendingEOFill = true;
  54833. this.closePath();
  54834. this.fillStroke();
  54835. },
  54836. endPath: function CanvasGraphics_endPath() {
  54837. this.consumePath();
  54838. },
  54839. clip: function CanvasGraphics_clip() {
  54840. this.pendingClip = NORMAL_CLIP;
  54841. },
  54842. eoClip: function CanvasGraphics_eoClip() {
  54843. this.pendingClip = EO_CLIP;
  54844. },
  54845. beginText: function CanvasGraphics_beginText() {
  54846. this.current.textMatrix = IDENTITY_MATRIX;
  54847. this.current.textMatrixScale = 1;
  54848. this.current.x = this.current.lineX = 0;
  54849. this.current.y = this.current.lineY = 0;
  54850. },
  54851. endText: function CanvasGraphics_endText() {
  54852. var paths = this.pendingTextPaths;
  54853. var ctx = this.ctx;
  54854. if (paths === undefined) {
  54855. ctx.beginPath();
  54856. return;
  54857. }
  54858. ctx.save();
  54859. ctx.beginPath();
  54860. for (var i = 0; i < paths.length; i++) {
  54861. var path = paths[i];
  54862. ctx.setTransform.apply(ctx, path.transform);
  54863. ctx.translate(path.x, path.y);
  54864. path.addToPath(ctx, path.fontSize);
  54865. }
  54866. ctx.restore();
  54867. ctx.clip();
  54868. ctx.beginPath();
  54869. delete this.pendingTextPaths;
  54870. },
  54871. setCharSpacing: function CanvasGraphics_setCharSpacing(spacing) {
  54872. this.current.charSpacing = spacing;
  54873. },
  54874. setWordSpacing: function CanvasGraphics_setWordSpacing(spacing) {
  54875. this.current.wordSpacing = spacing;
  54876. },
  54877. setHScale: function CanvasGraphics_setHScale(scale) {
  54878. this.current.textHScale = scale / 100;
  54879. },
  54880. setLeading: function CanvasGraphics_setLeading(leading) {
  54881. this.current.leading = -leading;
  54882. },
  54883. setFont: function CanvasGraphics_setFont(fontRefName, size) {
  54884. var fontObj = this.commonObjs.get(fontRefName);
  54885. var current = this.current;
  54886. if (!fontObj) {
  54887. error('Can\'t find font for ' + fontRefName);
  54888. }
  54889. current.fontMatrix = fontObj.fontMatrix ? fontObj.fontMatrix : FONT_IDENTITY_MATRIX;
  54890. if (current.fontMatrix[0] === 0 || current.fontMatrix[3] === 0) {
  54891. warn('Invalid font matrix for font ' + fontRefName);
  54892. }
  54893. if (size < 0) {
  54894. size = -size;
  54895. current.fontDirection = -1;
  54896. } else {
  54897. current.fontDirection = 1;
  54898. }
  54899. this.current.font = fontObj;
  54900. this.current.fontSize = size;
  54901. if (fontObj.isType3Font) {
  54902. return;
  54903. }
  54904. var name = fontObj.loadedName || 'sans-serif';
  54905. var bold = fontObj.black ? '900' : fontObj.bold ? 'bold' : 'normal';
  54906. var italic = fontObj.italic ? 'italic' : 'normal';
  54907. var typeface = '"' + name + '", ' + fontObj.fallbackName;
  54908. var browserFontSize = size < MIN_FONT_SIZE ? MIN_FONT_SIZE : size > MAX_FONT_SIZE ? MAX_FONT_SIZE : size;
  54909. this.current.fontSizeScale = size / browserFontSize;
  54910. var rule = italic + ' ' + bold + ' ' + browserFontSize + 'px ' + typeface;
  54911. this.ctx.font = rule;
  54912. },
  54913. setTextRenderingMode: function CanvasGraphics_setTextRenderingMode(mode) {
  54914. this.current.textRenderingMode = mode;
  54915. },
  54916. setTextRise: function CanvasGraphics_setTextRise(rise) {
  54917. this.current.textRise = rise;
  54918. },
  54919. moveText: function CanvasGraphics_moveText(x, y) {
  54920. this.current.x = this.current.lineX += x;
  54921. this.current.y = this.current.lineY += y;
  54922. },
  54923. setLeadingMoveText: function CanvasGraphics_setLeadingMoveText(x, y) {
  54924. this.setLeading(-y);
  54925. this.moveText(x, y);
  54926. },
  54927. setTextMatrix: function CanvasGraphics_setTextMatrix(a, b, c, d, e, f) {
  54928. this.current.textMatrix = [
  54929. a,
  54930. b,
  54931. c,
  54932. d,
  54933. e,
  54934. f
  54935. ];
  54936. this.current.textMatrixScale = Math.sqrt(a * a + b * b);
  54937. this.current.x = this.current.lineX = 0;
  54938. this.current.y = this.current.lineY = 0;
  54939. },
  54940. nextLine: function CanvasGraphics_nextLine() {
  54941. this.moveText(0, this.current.leading);
  54942. },
  54943. paintChar: function CanvasGraphics_paintChar(character, x, y) {
  54944. var ctx = this.ctx;
  54945. var current = this.current;
  54946. var font = current.font;
  54947. var textRenderingMode = current.textRenderingMode;
  54948. var fontSize = current.fontSize / current.fontSizeScale;
  54949. var fillStrokeMode = textRenderingMode & TextRenderingMode.FILL_STROKE_MASK;
  54950. var isAddToPathSet = !!(textRenderingMode & TextRenderingMode.ADD_TO_PATH_FLAG);
  54951. var addToPath;
  54952. if (font.disableFontFace || isAddToPathSet) {
  54953. addToPath = font.getPathGenerator(this.commonObjs, character);
  54954. }
  54955. if (font.disableFontFace) {
  54956. ctx.save();
  54957. ctx.translate(x, y);
  54958. ctx.beginPath();
  54959. addToPath(ctx, fontSize);
  54960. if (fillStrokeMode === TextRenderingMode.FILL || fillStrokeMode === TextRenderingMode.FILL_STROKE) {
  54961. ctx.fill();
  54962. }
  54963. if (fillStrokeMode === TextRenderingMode.STROKE || fillStrokeMode === TextRenderingMode.FILL_STROKE) {
  54964. ctx.stroke();
  54965. }
  54966. ctx.restore();
  54967. } else {
  54968. if (fillStrokeMode === TextRenderingMode.FILL || fillStrokeMode === TextRenderingMode.FILL_STROKE) {
  54969. ctx.fillText(character, x, y);
  54970. }
  54971. if (fillStrokeMode === TextRenderingMode.STROKE || fillStrokeMode === TextRenderingMode.FILL_STROKE) {
  54972. ctx.strokeText(character, x, y);
  54973. }
  54974. }
  54975. if (isAddToPathSet) {
  54976. var paths = this.pendingTextPaths || (this.pendingTextPaths = []);
  54977. paths.push({
  54978. transform: ctx.mozCurrentTransform,
  54979. x: x,
  54980. y: y,
  54981. fontSize: fontSize,
  54982. addToPath: addToPath
  54983. });
  54984. }
  54985. },
  54986. get isFontSubpixelAAEnabled() {
  54987. var ctx = this.canvasFactory.create(10, 10).context;
  54988. ctx.scale(1.5, 1);
  54989. ctx.fillText('I', 0, 10);
  54990. var data = ctx.getImageData(0, 0, 10, 10).data;
  54991. var enabled = false;
  54992. for (var i = 3; i < data.length; i += 4) {
  54993. if (data[i] > 0 && data[i] < 255) {
  54994. enabled = true;
  54995. break;
  54996. }
  54997. }
  54998. return shadow(this, 'isFontSubpixelAAEnabled', enabled);
  54999. },
  55000. showText: function CanvasGraphics_showText(glyphs) {
  55001. var current = this.current;
  55002. var font = current.font;
  55003. if (font.isType3Font) {
  55004. return this.showType3Text(glyphs);
  55005. }
  55006. var fontSize = current.fontSize;
  55007. if (fontSize === 0) {
  55008. return;
  55009. }
  55010. var ctx = this.ctx;
  55011. var fontSizeScale = current.fontSizeScale;
  55012. var charSpacing = current.charSpacing;
  55013. var wordSpacing = current.wordSpacing;
  55014. var fontDirection = current.fontDirection;
  55015. var textHScale = current.textHScale * fontDirection;
  55016. var glyphsLength = glyphs.length;
  55017. var vertical = font.vertical;
  55018. var spacingDir = vertical ? 1 : -1;
  55019. var defaultVMetrics = font.defaultVMetrics;
  55020. var widthAdvanceScale = fontSize * current.fontMatrix[0];
  55021. var simpleFillText = current.textRenderingMode === TextRenderingMode.FILL && !font.disableFontFace;
  55022. ctx.save();
  55023. ctx.transform.apply(ctx, current.textMatrix);
  55024. ctx.translate(current.x, current.y + current.textRise);
  55025. if (current.patternFill) {
  55026. ctx.fillStyle = current.fillColor.getPattern(ctx, this);
  55027. }
  55028. if (fontDirection > 0) {
  55029. ctx.scale(textHScale, -1);
  55030. } else {
  55031. ctx.scale(textHScale, 1);
  55032. }
  55033. var lineWidth = current.lineWidth;
  55034. var scale = current.textMatrixScale;
  55035. if (scale === 0 || lineWidth === 0) {
  55036. var fillStrokeMode = current.textRenderingMode & TextRenderingMode.FILL_STROKE_MASK;
  55037. if (fillStrokeMode === TextRenderingMode.STROKE || fillStrokeMode === TextRenderingMode.FILL_STROKE) {
  55038. this.cachedGetSinglePixelWidth = null;
  55039. lineWidth = this.getSinglePixelWidth() * MIN_WIDTH_FACTOR;
  55040. }
  55041. } else {
  55042. lineWidth /= scale;
  55043. }
  55044. if (fontSizeScale !== 1.0) {
  55045. ctx.scale(fontSizeScale, fontSizeScale);
  55046. lineWidth /= fontSizeScale;
  55047. }
  55048. ctx.lineWidth = lineWidth;
  55049. var x = 0, i;
  55050. for (i = 0; i < glyphsLength; ++i) {
  55051. var glyph = glyphs[i];
  55052. if (isNum(glyph)) {
  55053. x += spacingDir * glyph * fontSize / 1000;
  55054. continue;
  55055. }
  55056. var restoreNeeded = false;
  55057. var spacing = (glyph.isSpace ? wordSpacing : 0) + charSpacing;
  55058. var character = glyph.fontChar;
  55059. var accent = glyph.accent;
  55060. var scaledX, scaledY, scaledAccentX, scaledAccentY;
  55061. var width = glyph.width;
  55062. if (vertical) {
  55063. var vmetric, vx, vy;
  55064. vmetric = glyph.vmetric || defaultVMetrics;
  55065. vx = glyph.vmetric ? vmetric[1] : width * 0.5;
  55066. vx = -vx * widthAdvanceScale;
  55067. vy = vmetric[2] * widthAdvanceScale;
  55068. width = vmetric ? -vmetric[0] : width;
  55069. scaledX = vx / fontSizeScale;
  55070. scaledY = (x + vy) / fontSizeScale;
  55071. } else {
  55072. scaledX = x / fontSizeScale;
  55073. scaledY = 0;
  55074. }
  55075. if (font.remeasure && width > 0) {
  55076. var measuredWidth = ctx.measureText(character).width * 1000 / fontSize * fontSizeScale;
  55077. if (width < measuredWidth && this.isFontSubpixelAAEnabled) {
  55078. var characterScaleX = width / measuredWidth;
  55079. restoreNeeded = true;
  55080. ctx.save();
  55081. ctx.scale(characterScaleX, 1);
  55082. scaledX /= characterScaleX;
  55083. } else if (width !== measuredWidth) {
  55084. scaledX += (width - measuredWidth) / 2000 * fontSize / fontSizeScale;
  55085. }
  55086. }
  55087. if (glyph.isInFont || font.missingFile) {
  55088. if (simpleFillText && !accent) {
  55089. ctx.fillText(character, scaledX, scaledY);
  55090. } else {
  55091. this.paintChar(character, scaledX, scaledY);
  55092. if (accent) {
  55093. scaledAccentX = scaledX + accent.offset.x / fontSizeScale;
  55094. scaledAccentY = scaledY - accent.offset.y / fontSizeScale;
  55095. this.paintChar(accent.fontChar, scaledAccentX, scaledAccentY);
  55096. }
  55097. }
  55098. }
  55099. var charWidth = width * widthAdvanceScale + spacing * fontDirection;
  55100. x += charWidth;
  55101. if (restoreNeeded) {
  55102. ctx.restore();
  55103. }
  55104. }
  55105. if (vertical) {
  55106. current.y -= x * textHScale;
  55107. } else {
  55108. current.x += x * textHScale;
  55109. }
  55110. ctx.restore();
  55111. },
  55112. showType3Text: function CanvasGraphics_showType3Text(glyphs) {
  55113. var ctx = this.ctx;
  55114. var current = this.current;
  55115. var font = current.font;
  55116. var fontSize = current.fontSize;
  55117. var fontDirection = current.fontDirection;
  55118. var spacingDir = font.vertical ? 1 : -1;
  55119. var charSpacing = current.charSpacing;
  55120. var wordSpacing = current.wordSpacing;
  55121. var textHScale = current.textHScale * fontDirection;
  55122. var fontMatrix = current.fontMatrix || FONT_IDENTITY_MATRIX;
  55123. var glyphsLength = glyphs.length;
  55124. var isTextInvisible = current.textRenderingMode === TextRenderingMode.INVISIBLE;
  55125. var i, glyph, width, spacingLength;
  55126. if (isTextInvisible || fontSize === 0) {
  55127. return;
  55128. }
  55129. this.cachedGetSinglePixelWidth = null;
  55130. ctx.save();
  55131. ctx.transform.apply(ctx, current.textMatrix);
  55132. ctx.translate(current.x, current.y);
  55133. ctx.scale(textHScale, fontDirection);
  55134. for (i = 0; i < glyphsLength; ++i) {
  55135. glyph = glyphs[i];
  55136. if (isNum(glyph)) {
  55137. spacingLength = spacingDir * glyph * fontSize / 1000;
  55138. this.ctx.translate(spacingLength, 0);
  55139. current.x += spacingLength * textHScale;
  55140. continue;
  55141. }
  55142. var spacing = (glyph.isSpace ? wordSpacing : 0) + charSpacing;
  55143. var operatorList = font.charProcOperatorList[glyph.operatorListId];
  55144. if (!operatorList) {
  55145. warn('Type3 character \"' + glyph.operatorListId + '\" is not available');
  55146. continue;
  55147. }
  55148. this.processingType3 = glyph;
  55149. this.save();
  55150. ctx.scale(fontSize, fontSize);
  55151. ctx.transform.apply(ctx, fontMatrix);
  55152. this.executeOperatorList(operatorList);
  55153. this.restore();
  55154. var transformed = Util.applyTransform([
  55155. glyph.width,
  55156. 0
  55157. ], fontMatrix);
  55158. width = transformed[0] * fontSize + spacing;
  55159. ctx.translate(width, 0);
  55160. current.x += width * textHScale;
  55161. }
  55162. ctx.restore();
  55163. this.processingType3 = null;
  55164. },
  55165. setCharWidth: function CanvasGraphics_setCharWidth(xWidth, yWidth) {
  55166. },
  55167. setCharWidthAndBounds: function CanvasGraphics_setCharWidthAndBounds(xWidth, yWidth, llx, lly, urx, ury) {
  55168. this.ctx.rect(llx, lly, urx - llx, ury - lly);
  55169. this.clip();
  55170. this.endPath();
  55171. },
  55172. getColorN_Pattern: function CanvasGraphics_getColorN_Pattern(IR) {
  55173. var pattern;
  55174. if (IR[0] === 'TilingPattern') {
  55175. var color = IR[1];
  55176. var baseTransform = this.baseTransform || this.ctx.mozCurrentTransform.slice();
  55177. var self = this;
  55178. var canvasGraphicsFactory = {
  55179. createCanvasGraphics: function (ctx) {
  55180. return new CanvasGraphics(ctx, self.commonObjs, self.objs, self.canvasFactory);
  55181. }
  55182. };
  55183. pattern = new TilingPattern(IR, color, this.ctx, canvasGraphicsFactory, baseTransform);
  55184. } else {
  55185. pattern = getShadingPatternFromIR(IR);
  55186. }
  55187. return pattern;
  55188. },
  55189. setStrokeColorN: function CanvasGraphics_setStrokeColorN() {
  55190. this.current.strokeColor = this.getColorN_Pattern(arguments);
  55191. },
  55192. setFillColorN: function CanvasGraphics_setFillColorN() {
  55193. this.current.fillColor = this.getColorN_Pattern(arguments);
  55194. this.current.patternFill = true;
  55195. },
  55196. setStrokeRGBColor: function CanvasGraphics_setStrokeRGBColor(r, g, b) {
  55197. var color = Util.makeCssRgb(r, g, b);
  55198. this.ctx.strokeStyle = color;
  55199. this.current.strokeColor = color;
  55200. },
  55201. setFillRGBColor: function CanvasGraphics_setFillRGBColor(r, g, b) {
  55202. var color = Util.makeCssRgb(r, g, b);
  55203. this.ctx.fillStyle = color;
  55204. this.current.fillColor = color;
  55205. this.current.patternFill = false;
  55206. },
  55207. shadingFill: function CanvasGraphics_shadingFill(patternIR) {
  55208. var ctx = this.ctx;
  55209. this.save();
  55210. var pattern = getShadingPatternFromIR(patternIR);
  55211. ctx.fillStyle = pattern.getPattern(ctx, this, true);
  55212. var inv = ctx.mozCurrentTransformInverse;
  55213. if (inv) {
  55214. var canvas = ctx.canvas;
  55215. var width = canvas.width;
  55216. var height = canvas.height;
  55217. var bl = Util.applyTransform([
  55218. 0,
  55219. 0
  55220. ], inv);
  55221. var br = Util.applyTransform([
  55222. 0,
  55223. height
  55224. ], inv);
  55225. var ul = Util.applyTransform([
  55226. width,
  55227. 0
  55228. ], inv);
  55229. var ur = Util.applyTransform([
  55230. width,
  55231. height
  55232. ], inv);
  55233. var x0 = Math.min(bl[0], br[0], ul[0], ur[0]);
  55234. var y0 = Math.min(bl[1], br[1], ul[1], ur[1]);
  55235. var x1 = Math.max(bl[0], br[0], ul[0], ur[0]);
  55236. var y1 = Math.max(bl[1], br[1], ul[1], ur[1]);
  55237. this.ctx.fillRect(x0, y0, x1 - x0, y1 - y0);
  55238. } else {
  55239. this.ctx.fillRect(-1e10, -1e10, 2e10, 2e10);
  55240. }
  55241. this.restore();
  55242. },
  55243. beginInlineImage: function CanvasGraphics_beginInlineImage() {
  55244. error('Should not call beginInlineImage');
  55245. },
  55246. beginImageData: function CanvasGraphics_beginImageData() {
  55247. error('Should not call beginImageData');
  55248. },
  55249. paintFormXObjectBegin: function CanvasGraphics_paintFormXObjectBegin(matrix, bbox) {
  55250. this.save();
  55251. this.baseTransformStack.push(this.baseTransform);
  55252. if (isArray(matrix) && matrix.length === 6) {
  55253. this.transform.apply(this, matrix);
  55254. }
  55255. this.baseTransform = this.ctx.mozCurrentTransform;
  55256. if (isArray(bbox) && bbox.length === 4) {
  55257. var width = bbox[2] - bbox[0];
  55258. var height = bbox[3] - bbox[1];
  55259. this.ctx.rect(bbox[0], bbox[1], width, height);
  55260. this.clip();
  55261. this.endPath();
  55262. }
  55263. },
  55264. paintFormXObjectEnd: function CanvasGraphics_paintFormXObjectEnd() {
  55265. this.restore();
  55266. this.baseTransform = this.baseTransformStack.pop();
  55267. },
  55268. beginGroup: function CanvasGraphics_beginGroup(group) {
  55269. this.save();
  55270. var currentCtx = this.ctx;
  55271. if (!group.isolated) {
  55272. info('TODO: Support non-isolated groups.');
  55273. }
  55274. if (group.knockout) {
  55275. warn('Knockout groups not supported.');
  55276. }
  55277. var currentTransform = currentCtx.mozCurrentTransform;
  55278. if (group.matrix) {
  55279. currentCtx.transform.apply(currentCtx, group.matrix);
  55280. }
  55281. assert(group.bbox, 'Bounding box is required.');
  55282. var bounds = Util.getAxialAlignedBoundingBox(group.bbox, currentCtx.mozCurrentTransform);
  55283. var canvasBounds = [
  55284. 0,
  55285. 0,
  55286. currentCtx.canvas.width,
  55287. currentCtx.canvas.height
  55288. ];
  55289. bounds = Util.intersect(bounds, canvasBounds) || [
  55290. 0,
  55291. 0,
  55292. 0,
  55293. 0
  55294. ];
  55295. var offsetX = Math.floor(bounds[0]);
  55296. var offsetY = Math.floor(bounds[1]);
  55297. var drawnWidth = Math.max(Math.ceil(bounds[2]) - offsetX, 1);
  55298. var drawnHeight = Math.max(Math.ceil(bounds[3]) - offsetY, 1);
  55299. var scaleX = 1, scaleY = 1;
  55300. if (drawnWidth > MAX_GROUP_SIZE) {
  55301. scaleX = drawnWidth / MAX_GROUP_SIZE;
  55302. drawnWidth = MAX_GROUP_SIZE;
  55303. }
  55304. if (drawnHeight > MAX_GROUP_SIZE) {
  55305. scaleY = drawnHeight / MAX_GROUP_SIZE;
  55306. drawnHeight = MAX_GROUP_SIZE;
  55307. }
  55308. var cacheId = 'groupAt' + this.groupLevel;
  55309. if (group.smask) {
  55310. cacheId += '_smask_' + this.smaskCounter++ % 2;
  55311. }
  55312. var scratchCanvas = this.cachedCanvases.getCanvas(cacheId, drawnWidth, drawnHeight, true);
  55313. var groupCtx = scratchCanvas.context;
  55314. groupCtx.scale(1 / scaleX, 1 / scaleY);
  55315. groupCtx.translate(-offsetX, -offsetY);
  55316. groupCtx.transform.apply(groupCtx, currentTransform);
  55317. if (group.smask) {
  55318. this.smaskStack.push({
  55319. canvas: scratchCanvas.canvas,
  55320. context: groupCtx,
  55321. offsetX: offsetX,
  55322. offsetY: offsetY,
  55323. scaleX: scaleX,
  55324. scaleY: scaleY,
  55325. subtype: group.smask.subtype,
  55326. backdrop: group.smask.backdrop,
  55327. transferMap: group.smask.transferMap || null,
  55328. startTransformInverse: null
  55329. });
  55330. } else {
  55331. currentCtx.setTransform(1, 0, 0, 1, 0, 0);
  55332. currentCtx.translate(offsetX, offsetY);
  55333. currentCtx.scale(scaleX, scaleY);
  55334. }
  55335. copyCtxState(currentCtx, groupCtx);
  55336. this.ctx = groupCtx;
  55337. this.setGState([
  55338. [
  55339. 'BM',
  55340. 'Normal'
  55341. ],
  55342. [
  55343. 'ca',
  55344. 1
  55345. ],
  55346. [
  55347. 'CA',
  55348. 1
  55349. ]
  55350. ]);
  55351. this.groupStack.push(currentCtx);
  55352. this.groupLevel++;
  55353. this.current.activeSMask = null;
  55354. },
  55355. endGroup: function CanvasGraphics_endGroup(group) {
  55356. this.groupLevel--;
  55357. var groupCtx = this.ctx;
  55358. this.ctx = this.groupStack.pop();
  55359. if (this.ctx.imageSmoothingEnabled !== undefined) {
  55360. this.ctx.imageSmoothingEnabled = false;
  55361. } else {
  55362. this.ctx.mozImageSmoothingEnabled = false;
  55363. }
  55364. if (group.smask) {
  55365. this.tempSMask = this.smaskStack.pop();
  55366. } else {
  55367. this.ctx.drawImage(groupCtx.canvas, 0, 0);
  55368. }
  55369. this.restore();
  55370. },
  55371. beginAnnotations: function CanvasGraphics_beginAnnotations() {
  55372. this.save();
  55373. this.current = new CanvasExtraState();
  55374. if (this.baseTransform) {
  55375. this.ctx.setTransform.apply(this.ctx, this.baseTransform);
  55376. }
  55377. },
  55378. endAnnotations: function CanvasGraphics_endAnnotations() {
  55379. this.restore();
  55380. },
  55381. beginAnnotation: function CanvasGraphics_beginAnnotation(rect, transform, matrix) {
  55382. this.save();
  55383. if (isArray(rect) && rect.length === 4) {
  55384. var width = rect[2] - rect[0];
  55385. var height = rect[3] - rect[1];
  55386. this.ctx.rect(rect[0], rect[1], width, height);
  55387. this.clip();
  55388. this.endPath();
  55389. }
  55390. this.transform.apply(this, transform);
  55391. this.transform.apply(this, matrix);
  55392. },
  55393. endAnnotation: function CanvasGraphics_endAnnotation() {
  55394. this.restore();
  55395. },
  55396. paintJpegXObject: function CanvasGraphics_paintJpegXObject(objId, w, h) {
  55397. var domImage = this.objs.get(objId);
  55398. if (!domImage) {
  55399. warn('Dependent image isn\'t ready yet');
  55400. return;
  55401. }
  55402. this.save();
  55403. var ctx = this.ctx;
  55404. ctx.scale(1 / w, -1 / h);
  55405. ctx.drawImage(domImage, 0, 0, domImage.width, domImage.height, 0, -h, w, h);
  55406. if (this.imageLayer) {
  55407. var currentTransform = ctx.mozCurrentTransformInverse;
  55408. var position = this.getCanvasPosition(0, 0);
  55409. this.imageLayer.appendImage({
  55410. objId: objId,
  55411. left: position[0],
  55412. top: position[1],
  55413. width: w / currentTransform[0],
  55414. height: h / currentTransform[3]
  55415. });
  55416. }
  55417. this.restore();
  55418. },
  55419. paintImageMaskXObject: function CanvasGraphics_paintImageMaskXObject(img) {
  55420. var ctx = this.ctx;
  55421. var width = img.width, height = img.height;
  55422. var fillColor = this.current.fillColor;
  55423. var isPatternFill = this.current.patternFill;
  55424. var glyph = this.processingType3;
  55425. if (COMPILE_TYPE3_GLYPHS && glyph && glyph.compiled === undefined) {
  55426. if (width <= MAX_SIZE_TO_COMPILE && height <= MAX_SIZE_TO_COMPILE) {
  55427. glyph.compiled = compileType3Glyph({
  55428. data: img.data,
  55429. width: width,
  55430. height: height
  55431. });
  55432. } else {
  55433. glyph.compiled = null;
  55434. }
  55435. }
  55436. if (glyph && glyph.compiled) {
  55437. glyph.compiled(ctx);
  55438. return;
  55439. }
  55440. var maskCanvas = this.cachedCanvases.getCanvas('maskCanvas', width, height);
  55441. var maskCtx = maskCanvas.context;
  55442. maskCtx.save();
  55443. putBinaryImageMask(maskCtx, img);
  55444. maskCtx.globalCompositeOperation = 'source-in';
  55445. maskCtx.fillStyle = isPatternFill ? fillColor.getPattern(maskCtx, this) : fillColor;
  55446. maskCtx.fillRect(0, 0, width, height);
  55447. maskCtx.restore();
  55448. this.paintInlineImageXObject(maskCanvas.canvas);
  55449. },
  55450. paintImageMaskXObjectRepeat: function CanvasGraphics_paintImageMaskXObjectRepeat(imgData, scaleX, scaleY, positions) {
  55451. var width = imgData.width;
  55452. var height = imgData.height;
  55453. var fillColor = this.current.fillColor;
  55454. var isPatternFill = this.current.patternFill;
  55455. var maskCanvas = this.cachedCanvases.getCanvas('maskCanvas', width, height);
  55456. var maskCtx = maskCanvas.context;
  55457. maskCtx.save();
  55458. putBinaryImageMask(maskCtx, imgData);
  55459. maskCtx.globalCompositeOperation = 'source-in';
  55460. maskCtx.fillStyle = isPatternFill ? fillColor.getPattern(maskCtx, this) : fillColor;
  55461. maskCtx.fillRect(0, 0, width, height);
  55462. maskCtx.restore();
  55463. var ctx = this.ctx;
  55464. for (var i = 0, ii = positions.length; i < ii; i += 2) {
  55465. ctx.save();
  55466. ctx.transform(scaleX, 0, 0, scaleY, positions[i], positions[i + 1]);
  55467. ctx.scale(1, -1);
  55468. ctx.drawImage(maskCanvas.canvas, 0, 0, width, height, 0, -1, 1, 1);
  55469. ctx.restore();
  55470. }
  55471. },
  55472. paintImageMaskXObjectGroup: function CanvasGraphics_paintImageMaskXObjectGroup(images) {
  55473. var ctx = this.ctx;
  55474. var fillColor = this.current.fillColor;
  55475. var isPatternFill = this.current.patternFill;
  55476. for (var i = 0, ii = images.length; i < ii; i++) {
  55477. var image = images[i];
  55478. var width = image.width, height = image.height;
  55479. var maskCanvas = this.cachedCanvases.getCanvas('maskCanvas', width, height);
  55480. var maskCtx = maskCanvas.context;
  55481. maskCtx.save();
  55482. putBinaryImageMask(maskCtx, image);
  55483. maskCtx.globalCompositeOperation = 'source-in';
  55484. maskCtx.fillStyle = isPatternFill ? fillColor.getPattern(maskCtx, this) : fillColor;
  55485. maskCtx.fillRect(0, 0, width, height);
  55486. maskCtx.restore();
  55487. ctx.save();
  55488. ctx.transform.apply(ctx, image.transform);
  55489. ctx.scale(1, -1);
  55490. ctx.drawImage(maskCanvas.canvas, 0, 0, width, height, 0, -1, 1, 1);
  55491. ctx.restore();
  55492. }
  55493. },
  55494. paintImageXObject: function CanvasGraphics_paintImageXObject(objId) {
  55495. var imgData = this.objs.get(objId);
  55496. if (!imgData) {
  55497. warn('Dependent image isn\'t ready yet');
  55498. return;
  55499. }
  55500. this.paintInlineImageXObject(imgData);
  55501. },
  55502. paintImageXObjectRepeat: function CanvasGraphics_paintImageXObjectRepeat(objId, scaleX, scaleY, positions) {
  55503. var imgData = this.objs.get(objId);
  55504. if (!imgData) {
  55505. warn('Dependent image isn\'t ready yet');
  55506. return;
  55507. }
  55508. var width = imgData.width;
  55509. var height = imgData.height;
  55510. var map = [];
  55511. for (var i = 0, ii = positions.length; i < ii; i += 2) {
  55512. map.push({
  55513. transform: [
  55514. scaleX,
  55515. 0,
  55516. 0,
  55517. scaleY,
  55518. positions[i],
  55519. positions[i + 1]
  55520. ],
  55521. x: 0,
  55522. y: 0,
  55523. w: width,
  55524. h: height
  55525. });
  55526. }
  55527. this.paintInlineImageXObjectGroup(imgData, map);
  55528. },
  55529. paintInlineImageXObject: function CanvasGraphics_paintInlineImageXObject(imgData) {
  55530. var width = imgData.width;
  55531. var height = imgData.height;
  55532. var ctx = this.ctx;
  55533. this.save();
  55534. ctx.scale(1 / width, -1 / height);
  55535. var currentTransform = ctx.mozCurrentTransformInverse;
  55536. var a = currentTransform[0], b = currentTransform[1];
  55537. var widthScale = Math.max(Math.sqrt(a * a + b * b), 1);
  55538. var c = currentTransform[2], d = currentTransform[3];
  55539. var heightScale = Math.max(Math.sqrt(c * c + d * d), 1);
  55540. var imgToPaint, tmpCanvas;
  55541. if (imgData instanceof HTMLElement || !imgData.data) {
  55542. imgToPaint = imgData;
  55543. } else {
  55544. tmpCanvas = this.cachedCanvases.getCanvas('inlineImage', width, height);
  55545. var tmpCtx = tmpCanvas.context;
  55546. putBinaryImageData(tmpCtx, imgData);
  55547. imgToPaint = tmpCanvas.canvas;
  55548. }
  55549. var paintWidth = width, paintHeight = height;
  55550. var tmpCanvasId = 'prescale1';
  55551. while (widthScale > 2 && paintWidth > 1 || heightScale > 2 && paintHeight > 1) {
  55552. var newWidth = paintWidth, newHeight = paintHeight;
  55553. if (widthScale > 2 && paintWidth > 1) {
  55554. newWidth = Math.ceil(paintWidth / 2);
  55555. widthScale /= paintWidth / newWidth;
  55556. }
  55557. if (heightScale > 2 && paintHeight > 1) {
  55558. newHeight = Math.ceil(paintHeight / 2);
  55559. heightScale /= paintHeight / newHeight;
  55560. }
  55561. tmpCanvas = this.cachedCanvases.getCanvas(tmpCanvasId, newWidth, newHeight);
  55562. tmpCtx = tmpCanvas.context;
  55563. tmpCtx.clearRect(0, 0, newWidth, newHeight);
  55564. tmpCtx.drawImage(imgToPaint, 0, 0, paintWidth, paintHeight, 0, 0, newWidth, newHeight);
  55565. imgToPaint = tmpCanvas.canvas;
  55566. paintWidth = newWidth;
  55567. paintHeight = newHeight;
  55568. tmpCanvasId = tmpCanvasId === 'prescale1' ? 'prescale2' : 'prescale1';
  55569. }
  55570. ctx.drawImage(imgToPaint, 0, 0, paintWidth, paintHeight, 0, -height, width, height);
  55571. if (this.imageLayer) {
  55572. var position = this.getCanvasPosition(0, -height);
  55573. this.imageLayer.appendImage({
  55574. imgData: imgData,
  55575. left: position[0],
  55576. top: position[1],
  55577. width: width / currentTransform[0],
  55578. height: height / currentTransform[3]
  55579. });
  55580. }
  55581. this.restore();
  55582. },
  55583. paintInlineImageXObjectGroup: function CanvasGraphics_paintInlineImageXObjectGroup(imgData, map) {
  55584. var ctx = this.ctx;
  55585. var w = imgData.width;
  55586. var h = imgData.height;
  55587. var tmpCanvas = this.cachedCanvases.getCanvas('inlineImage', w, h);
  55588. var tmpCtx = tmpCanvas.context;
  55589. putBinaryImageData(tmpCtx, imgData);
  55590. for (var i = 0, ii = map.length; i < ii; i++) {
  55591. var entry = map[i];
  55592. ctx.save();
  55593. ctx.transform.apply(ctx, entry.transform);
  55594. ctx.scale(1, -1);
  55595. ctx.drawImage(tmpCanvas.canvas, entry.x, entry.y, entry.w, entry.h, 0, -1, 1, 1);
  55596. if (this.imageLayer) {
  55597. var position = this.getCanvasPosition(entry.x, entry.y);
  55598. this.imageLayer.appendImage({
  55599. imgData: imgData,
  55600. left: position[0],
  55601. top: position[1],
  55602. width: w,
  55603. height: h
  55604. });
  55605. }
  55606. ctx.restore();
  55607. }
  55608. },
  55609. paintSolidColorImageMask: function CanvasGraphics_paintSolidColorImageMask() {
  55610. this.ctx.fillRect(0, 0, 1, 1);
  55611. },
  55612. paintXObject: function CanvasGraphics_paintXObject() {
  55613. warn('Unsupported \'paintXObject\' command.');
  55614. },
  55615. markPoint: function CanvasGraphics_markPoint(tag) {
  55616. },
  55617. markPointProps: function CanvasGraphics_markPointProps(tag, properties) {
  55618. },
  55619. beginMarkedContent: function CanvasGraphics_beginMarkedContent(tag) {
  55620. },
  55621. beginMarkedContentProps: function CanvasGraphics_beginMarkedContentProps(tag, properties) {
  55622. },
  55623. endMarkedContent: function CanvasGraphics_endMarkedContent() {
  55624. },
  55625. beginCompat: function CanvasGraphics_beginCompat() {
  55626. },
  55627. endCompat: function CanvasGraphics_endCompat() {
  55628. },
  55629. consumePath: function CanvasGraphics_consumePath() {
  55630. var ctx = this.ctx;
  55631. if (this.pendingClip) {
  55632. if (this.pendingClip === EO_CLIP) {
  55633. ctx.clip('evenodd');
  55634. } else {
  55635. ctx.clip();
  55636. }
  55637. this.pendingClip = null;
  55638. }
  55639. ctx.beginPath();
  55640. },
  55641. getSinglePixelWidth: function CanvasGraphics_getSinglePixelWidth(scale) {
  55642. if (this.cachedGetSinglePixelWidth === null) {
  55643. this.ctx.save();
  55644. var inverse = this.ctx.mozCurrentTransformInverse;
  55645. this.ctx.restore();
  55646. this.cachedGetSinglePixelWidth = Math.sqrt(Math.max(inverse[0] * inverse[0] + inverse[1] * inverse[1], inverse[2] * inverse[2] + inverse[3] * inverse[3]));
  55647. }
  55648. return this.cachedGetSinglePixelWidth;
  55649. },
  55650. getCanvasPosition: function CanvasGraphics_getCanvasPosition(x, y) {
  55651. var transform = this.ctx.mozCurrentTransform;
  55652. return [
  55653. transform[0] * x + transform[2] * y + transform[4],
  55654. transform[1] * x + transform[3] * y + transform[5]
  55655. ];
  55656. }
  55657. };
  55658. for (var op in OPS) {
  55659. CanvasGraphics.prototype[OPS[op]] = CanvasGraphics.prototype[op];
  55660. }
  55661. return CanvasGraphics;
  55662. }();
  55663. exports.CanvasGraphics = CanvasGraphics;
  55664. /***/ }),
  55665. /* 45 */
  55666. /***/ (function(module, exports, __w_pdfjs_require__) {
  55667. "use strict";
  55668. var sharedUtil = __w_pdfjs_require__(0);
  55669. var assert = sharedUtil.assert;
  55670. var bytesToString = sharedUtil.bytesToString;
  55671. var string32 = sharedUtil.string32;
  55672. var shadow = sharedUtil.shadow;
  55673. var warn = sharedUtil.warn;
  55674. function FontLoader(docId) {
  55675. this.docId = docId;
  55676. this.styleElement = null;
  55677. this.nativeFontFaces = [];
  55678. this.loadTestFontId = 0;
  55679. this.loadingContext = {
  55680. requests: [],
  55681. nextRequestId: 0
  55682. };
  55683. }
  55684. FontLoader.prototype = {
  55685. insertRule: function fontLoaderInsertRule(rule) {
  55686. var styleElement = this.styleElement;
  55687. if (!styleElement) {
  55688. styleElement = this.styleElement = document.createElement('style');
  55689. styleElement.id = 'PDFJS_FONT_STYLE_TAG_' + this.docId;
  55690. document.documentElement.getElementsByTagName('head')[0].appendChild(styleElement);
  55691. }
  55692. var styleSheet = styleElement.sheet;
  55693. styleSheet.insertRule(rule, styleSheet.cssRules.length);
  55694. },
  55695. clear: function fontLoaderClear() {
  55696. if (this.styleElement) {
  55697. this.styleElement.remove();
  55698. this.styleElement = null;
  55699. }
  55700. this.nativeFontFaces.forEach(function (nativeFontFace) {
  55701. document.fonts.delete(nativeFontFace);
  55702. });
  55703. this.nativeFontFaces.length = 0;
  55704. }
  55705. };
  55706. var getLoadTestFont = function () {
  55707. 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==');
  55708. };
  55709. Object.defineProperty(FontLoader.prototype, 'loadTestFont', {
  55710. get: function () {
  55711. return shadow(this, 'loadTestFont', getLoadTestFont());
  55712. },
  55713. configurable: true
  55714. });
  55715. FontLoader.prototype.addNativeFontFace = function fontLoader_addNativeFontFace(nativeFontFace) {
  55716. this.nativeFontFaces.push(nativeFontFace);
  55717. document.fonts.add(nativeFontFace);
  55718. };
  55719. FontLoader.prototype.bind = function fontLoaderBind(fonts, callback) {
  55720. var rules = [];
  55721. var fontsToLoad = [];
  55722. var fontLoadPromises = [];
  55723. var getNativeFontPromise = function (nativeFontFace) {
  55724. return nativeFontFace.loaded.catch(function (e) {
  55725. warn('Failed to load font "' + nativeFontFace.family + '": ' + e);
  55726. });
  55727. };
  55728. var isFontLoadingAPISupported = FontLoader.isFontLoadingAPISupported && !FontLoader.isSyncFontLoadingSupported;
  55729. for (var i = 0, ii = fonts.length; i < ii; i++) {
  55730. var font = fonts[i];
  55731. if (font.attached || font.loading === false) {
  55732. continue;
  55733. }
  55734. font.attached = true;
  55735. if (isFontLoadingAPISupported) {
  55736. var nativeFontFace = font.createNativeFontFace();
  55737. if (nativeFontFace) {
  55738. this.addNativeFontFace(nativeFontFace);
  55739. fontLoadPromises.push(getNativeFontPromise(nativeFontFace));
  55740. }
  55741. } else {
  55742. var rule = font.createFontFaceRule();
  55743. if (rule) {
  55744. this.insertRule(rule);
  55745. rules.push(rule);
  55746. fontsToLoad.push(font);
  55747. }
  55748. }
  55749. }
  55750. var request = this.queueLoadingCallback(callback);
  55751. if (isFontLoadingAPISupported) {
  55752. Promise.all(fontLoadPromises).then(function () {
  55753. request.complete();
  55754. });
  55755. } else if (rules.length > 0 && !FontLoader.isSyncFontLoadingSupported) {
  55756. this.prepareFontLoadEvent(rules, fontsToLoad, request);
  55757. } else {
  55758. request.complete();
  55759. }
  55760. };
  55761. FontLoader.prototype.queueLoadingCallback = function FontLoader_queueLoadingCallback(callback) {
  55762. function LoadLoader_completeRequest() {
  55763. assert(!request.end, 'completeRequest() cannot be called twice');
  55764. request.end = Date.now();
  55765. while (context.requests.length > 0 && context.requests[0].end) {
  55766. var otherRequest = context.requests.shift();
  55767. setTimeout(otherRequest.callback, 0);
  55768. }
  55769. }
  55770. var context = this.loadingContext;
  55771. var requestId = 'pdfjs-font-loading-' + context.nextRequestId++;
  55772. var request = {
  55773. id: requestId,
  55774. complete: LoadLoader_completeRequest,
  55775. callback: callback,
  55776. started: Date.now()
  55777. };
  55778. context.requests.push(request);
  55779. return request;
  55780. };
  55781. FontLoader.prototype.prepareFontLoadEvent = function fontLoaderPrepareFontLoadEvent(rules, fonts, request) {
  55782. function int32(data, offset) {
  55783. return data.charCodeAt(offset) << 24 | data.charCodeAt(offset + 1) << 16 | data.charCodeAt(offset + 2) << 8 | data.charCodeAt(offset + 3) & 0xff;
  55784. }
  55785. function spliceString(s, offset, remove, insert) {
  55786. var chunk1 = s.substr(0, offset);
  55787. var chunk2 = s.substr(offset + remove);
  55788. return chunk1 + insert + chunk2;
  55789. }
  55790. var i, ii;
  55791. var canvas = document.createElement('canvas');
  55792. canvas.width = 1;
  55793. canvas.height = 1;
  55794. var ctx = canvas.getContext('2d');
  55795. var called = 0;
  55796. function isFontReady(name, callback) {
  55797. called++;
  55798. if (called > 30) {
  55799. warn('Load test font never loaded.');
  55800. callback();
  55801. return;
  55802. }
  55803. ctx.font = '30px ' + name;
  55804. ctx.fillText('.', 0, 20);
  55805. var imageData = ctx.getImageData(0, 0, 1, 1);
  55806. if (imageData.data[3] > 0) {
  55807. callback();
  55808. return;
  55809. }
  55810. setTimeout(isFontReady.bind(null, name, callback));
  55811. }
  55812. var loadTestFontId = 'lt' + Date.now() + this.loadTestFontId++;
  55813. var data = this.loadTestFont;
  55814. var COMMENT_OFFSET = 976;
  55815. data = spliceString(data, COMMENT_OFFSET, loadTestFontId.length, loadTestFontId);
  55816. var CFF_CHECKSUM_OFFSET = 16;
  55817. var XXXX_VALUE = 0x58585858;
  55818. var checksum = int32(data, CFF_CHECKSUM_OFFSET);
  55819. for (i = 0, ii = loadTestFontId.length - 3; i < ii; i += 4) {
  55820. checksum = checksum - XXXX_VALUE + int32(loadTestFontId, i) | 0;
  55821. }
  55822. if (i < loadTestFontId.length) {
  55823. checksum = checksum - XXXX_VALUE + int32(loadTestFontId + 'XXX', i) | 0;
  55824. }
  55825. data = spliceString(data, CFF_CHECKSUM_OFFSET, 4, string32(checksum));
  55826. var url = 'url(data:font/opentype;base64,' + btoa(data) + ');';
  55827. var rule = '@font-face { font-family:"' + loadTestFontId + '";src:' + url + '}';
  55828. this.insertRule(rule);
  55829. var names = [];
  55830. for (i = 0, ii = fonts.length; i < ii; i++) {
  55831. names.push(fonts[i].loadedName);
  55832. }
  55833. names.push(loadTestFontId);
  55834. var div = document.createElement('div');
  55835. div.setAttribute('style', 'visibility: hidden;' + 'width: 10px; height: 10px;' + 'position: absolute; top: 0px; left: 0px;');
  55836. for (i = 0, ii = names.length; i < ii; ++i) {
  55837. var span = document.createElement('span');
  55838. span.textContent = 'Hi';
  55839. span.style.fontFamily = names[i];
  55840. div.appendChild(span);
  55841. }
  55842. document.body.appendChild(div);
  55843. isFontReady(loadTestFontId, function () {
  55844. document.body.removeChild(div);
  55845. request.complete();
  55846. });
  55847. };
  55848. FontLoader.isFontLoadingAPISupported = typeof document !== 'undefined' && !!document.fonts;
  55849. var isSyncFontLoadingSupported = function isSyncFontLoadingSupported() {
  55850. if (typeof navigator === 'undefined') {
  55851. return true;
  55852. }
  55853. var supported = false;
  55854. var m = /Mozilla\/5.0.*?rv:(\d+).*? Gecko/.exec(navigator.userAgent);
  55855. if (m && m[1] >= 14) {
  55856. supported = true;
  55857. }
  55858. return supported;
  55859. };
  55860. Object.defineProperty(FontLoader, 'isSyncFontLoadingSupported', {
  55861. get: function () {
  55862. return shadow(FontLoader, 'isSyncFontLoadingSupported', isSyncFontLoadingSupported());
  55863. },
  55864. enumerable: true,
  55865. configurable: true
  55866. });
  55867. var IsEvalSupportedCached = {
  55868. get value() {
  55869. return shadow(this, 'value', sharedUtil.isEvalSupported());
  55870. }
  55871. };
  55872. var FontFaceObject = function FontFaceObjectClosure() {
  55873. function FontFaceObject(translatedData, options) {
  55874. this.compiledGlyphs = Object.create(null);
  55875. for (var i in translatedData) {
  55876. this[i] = translatedData[i];
  55877. }
  55878. this.options = options;
  55879. }
  55880. FontFaceObject.prototype = {
  55881. createNativeFontFace: function FontFaceObject_createNativeFontFace() {
  55882. if (!this.data) {
  55883. return null;
  55884. }
  55885. if (this.options.disableFontFace) {
  55886. this.disableFontFace = true;
  55887. return null;
  55888. }
  55889. var nativeFontFace = new FontFace(this.loadedName, this.data, {});
  55890. if (this.options.fontRegistry) {
  55891. this.options.fontRegistry.registerFont(this);
  55892. }
  55893. return nativeFontFace;
  55894. },
  55895. createFontFaceRule: function FontFaceObject_createFontFaceRule() {
  55896. if (!this.data) {
  55897. return null;
  55898. }
  55899. if (this.options.disableFontFace) {
  55900. this.disableFontFace = true;
  55901. return null;
  55902. }
  55903. var data = bytesToString(new Uint8Array(this.data));
  55904. var fontName = this.loadedName;
  55905. var url = 'url(data:' + this.mimetype + ';base64,' + btoa(data) + ');';
  55906. var rule = '@font-face { font-family:"' + fontName + '";src:' + url + '}';
  55907. if (this.options.fontRegistry) {
  55908. this.options.fontRegistry.registerFont(this, url);
  55909. }
  55910. return rule;
  55911. },
  55912. getPathGenerator: function FontFaceObject_getPathGenerator(objs, character) {
  55913. if (!(character in this.compiledGlyphs)) {
  55914. var cmds = objs.get(this.loadedName + '_path_' + character);
  55915. var current, i, len;
  55916. if (this.options.isEvalSupported && IsEvalSupportedCached.value) {
  55917. var args, js = '';
  55918. for (i = 0, len = cmds.length; i < len; i++) {
  55919. current = cmds[i];
  55920. if (current.args !== undefined) {
  55921. args = current.args.join(',');
  55922. } else {
  55923. args = '';
  55924. }
  55925. js += 'c.' + current.cmd + '(' + args + ');\n';
  55926. }
  55927. this.compiledGlyphs[character] = new Function('c', 'size', js);
  55928. } else {
  55929. this.compiledGlyphs[character] = function (c, size) {
  55930. for (i = 0, len = cmds.length; i < len; i++) {
  55931. current = cmds[i];
  55932. if (current.cmd === 'scale') {
  55933. current.args = [
  55934. size,
  55935. -size
  55936. ];
  55937. }
  55938. c[current.cmd].apply(c, current.args);
  55939. }
  55940. };
  55941. }
  55942. }
  55943. return this.compiledGlyphs[character];
  55944. }
  55945. };
  55946. return FontFaceObject;
  55947. }();
  55948. exports.FontFaceObject = FontFaceObject;
  55949. exports.FontLoader = FontLoader;
  55950. /***/ }),
  55951. /* 46 */
  55952. /***/ (function(module, exports, __w_pdfjs_require__) {
  55953. "use strict";
  55954. var sharedUtil = __w_pdfjs_require__(0);
  55955. var displayWebGL = __w_pdfjs_require__(25);
  55956. var Util = sharedUtil.Util;
  55957. var info = sharedUtil.info;
  55958. var isArray = sharedUtil.isArray;
  55959. var error = sharedUtil.error;
  55960. var WebGLUtils = displayWebGL.WebGLUtils;
  55961. var ShadingIRs = {};
  55962. ShadingIRs.RadialAxial = {
  55963. fromIR: function RadialAxial_fromIR(raw) {
  55964. var type = raw[1];
  55965. var colorStops = raw[2];
  55966. var p0 = raw[3];
  55967. var p1 = raw[4];
  55968. var r0 = raw[5];
  55969. var r1 = raw[6];
  55970. return {
  55971. type: 'Pattern',
  55972. getPattern: function RadialAxial_getPattern(ctx) {
  55973. var grad;
  55974. if (type === 'axial') {
  55975. grad = ctx.createLinearGradient(p0[0], p0[1], p1[0], p1[1]);
  55976. } else if (type === 'radial') {
  55977. grad = ctx.createRadialGradient(p0[0], p0[1], r0, p1[0], p1[1], r1);
  55978. }
  55979. for (var i = 0, ii = colorStops.length; i < ii; ++i) {
  55980. var c = colorStops[i];
  55981. grad.addColorStop(c[0], c[1]);
  55982. }
  55983. return grad;
  55984. }
  55985. };
  55986. }
  55987. };
  55988. var createMeshCanvas = function createMeshCanvasClosure() {
  55989. function drawTriangle(data, context, p1, p2, p3, c1, c2, c3) {
  55990. var coords = context.coords, colors = context.colors;
  55991. var bytes = data.data, rowSize = data.width * 4;
  55992. var tmp;
  55993. if (coords[p1 + 1] > coords[p2 + 1]) {
  55994. tmp = p1;
  55995. p1 = p2;
  55996. p2 = tmp;
  55997. tmp = c1;
  55998. c1 = c2;
  55999. c2 = tmp;
  56000. }
  56001. if (coords[p2 + 1] > coords[p3 + 1]) {
  56002. tmp = p2;
  56003. p2 = p3;
  56004. p3 = tmp;
  56005. tmp = c2;
  56006. c2 = c3;
  56007. c3 = tmp;
  56008. }
  56009. if (coords[p1 + 1] > coords[p2 + 1]) {
  56010. tmp = p1;
  56011. p1 = p2;
  56012. p2 = tmp;
  56013. tmp = c1;
  56014. c1 = c2;
  56015. c2 = tmp;
  56016. }
  56017. var x1 = (coords[p1] + context.offsetX) * context.scaleX;
  56018. var y1 = (coords[p1 + 1] + context.offsetY) * context.scaleY;
  56019. var x2 = (coords[p2] + context.offsetX) * context.scaleX;
  56020. var y2 = (coords[p2 + 1] + context.offsetY) * context.scaleY;
  56021. var x3 = (coords[p3] + context.offsetX) * context.scaleX;
  56022. var y3 = (coords[p3 + 1] + context.offsetY) * context.scaleY;
  56023. if (y1 >= y3) {
  56024. return;
  56025. }
  56026. var c1r = colors[c1], c1g = colors[c1 + 1], c1b = colors[c1 + 2];
  56027. var c2r = colors[c2], c2g = colors[c2 + 1], c2b = colors[c2 + 2];
  56028. var c3r = colors[c3], c3g = colors[c3 + 1], c3b = colors[c3 + 2];
  56029. var minY = Math.round(y1), maxY = Math.round(y3);
  56030. var xa, car, cag, cab;
  56031. var xb, cbr, cbg, cbb;
  56032. var k;
  56033. for (var y = minY; y <= maxY; y++) {
  56034. if (y < y2) {
  56035. k = y < y1 ? 0 : y1 === y2 ? 1 : (y1 - y) / (y1 - y2);
  56036. xa = x1 - (x1 - x2) * k;
  56037. car = c1r - (c1r - c2r) * k;
  56038. cag = c1g - (c1g - c2g) * k;
  56039. cab = c1b - (c1b - c2b) * k;
  56040. } else {
  56041. k = y > y3 ? 1 : y2 === y3 ? 0 : (y2 - y) / (y2 - y3);
  56042. xa = x2 - (x2 - x3) * k;
  56043. car = c2r - (c2r - c3r) * k;
  56044. cag = c2g - (c2g - c3g) * k;
  56045. cab = c2b - (c2b - c3b) * k;
  56046. }
  56047. k = y < y1 ? 0 : y > y3 ? 1 : (y1 - y) / (y1 - y3);
  56048. xb = x1 - (x1 - x3) * k;
  56049. cbr = c1r - (c1r - c3r) * k;
  56050. cbg = c1g - (c1g - c3g) * k;
  56051. cbb = c1b - (c1b - c3b) * k;
  56052. var x1_ = Math.round(Math.min(xa, xb));
  56053. var x2_ = Math.round(Math.max(xa, xb));
  56054. var j = rowSize * y + x1_ * 4;
  56055. for (var x = x1_; x <= x2_; x++) {
  56056. k = (xa - x) / (xa - xb);
  56057. k = k < 0 ? 0 : k > 1 ? 1 : k;
  56058. bytes[j++] = car - (car - cbr) * k | 0;
  56059. bytes[j++] = cag - (cag - cbg) * k | 0;
  56060. bytes[j++] = cab - (cab - cbb) * k | 0;
  56061. bytes[j++] = 255;
  56062. }
  56063. }
  56064. }
  56065. function drawFigure(data, figure, context) {
  56066. var ps = figure.coords;
  56067. var cs = figure.colors;
  56068. var i, ii;
  56069. switch (figure.type) {
  56070. case 'lattice':
  56071. var verticesPerRow = figure.verticesPerRow;
  56072. var rows = Math.floor(ps.length / verticesPerRow) - 1;
  56073. var cols = verticesPerRow - 1;
  56074. for (i = 0; i < rows; i++) {
  56075. var q = i * verticesPerRow;
  56076. for (var j = 0; j < cols; j++, q++) {
  56077. drawTriangle(data, context, ps[q], ps[q + 1], ps[q + verticesPerRow], cs[q], cs[q + 1], cs[q + verticesPerRow]);
  56078. drawTriangle(data, context, ps[q + verticesPerRow + 1], ps[q + 1], ps[q + verticesPerRow], cs[q + verticesPerRow + 1], cs[q + 1], cs[q + verticesPerRow]);
  56079. }
  56080. }
  56081. break;
  56082. case 'triangles':
  56083. for (i = 0, ii = ps.length; i < ii; i += 3) {
  56084. drawTriangle(data, context, ps[i], ps[i + 1], ps[i + 2], cs[i], cs[i + 1], cs[i + 2]);
  56085. }
  56086. break;
  56087. default:
  56088. error('illigal figure');
  56089. break;
  56090. }
  56091. }
  56092. function createMeshCanvas(bounds, combinesScale, coords, colors, figures, backgroundColor, cachedCanvases) {
  56093. var EXPECTED_SCALE = 1.1;
  56094. var MAX_PATTERN_SIZE = 3000;
  56095. var BORDER_SIZE = 2;
  56096. var offsetX = Math.floor(bounds[0]);
  56097. var offsetY = Math.floor(bounds[1]);
  56098. var boundsWidth = Math.ceil(bounds[2]) - offsetX;
  56099. var boundsHeight = Math.ceil(bounds[3]) - offsetY;
  56100. var width = Math.min(Math.ceil(Math.abs(boundsWidth * combinesScale[0] * EXPECTED_SCALE)), MAX_PATTERN_SIZE);
  56101. var height = Math.min(Math.ceil(Math.abs(boundsHeight * combinesScale[1] * EXPECTED_SCALE)), MAX_PATTERN_SIZE);
  56102. var scaleX = boundsWidth / width;
  56103. var scaleY = boundsHeight / height;
  56104. var context = {
  56105. coords: coords,
  56106. colors: colors,
  56107. offsetX: -offsetX,
  56108. offsetY: -offsetY,
  56109. scaleX: 1 / scaleX,
  56110. scaleY: 1 / scaleY
  56111. };
  56112. var paddedWidth = width + BORDER_SIZE * 2;
  56113. var paddedHeight = height + BORDER_SIZE * 2;
  56114. var canvas, tmpCanvas, i, ii;
  56115. if (WebGLUtils.isEnabled) {
  56116. canvas = WebGLUtils.drawFigures(width, height, backgroundColor, figures, context);
  56117. tmpCanvas = cachedCanvases.getCanvas('mesh', paddedWidth, paddedHeight, false);
  56118. tmpCanvas.context.drawImage(canvas, BORDER_SIZE, BORDER_SIZE);
  56119. canvas = tmpCanvas.canvas;
  56120. } else {
  56121. tmpCanvas = cachedCanvases.getCanvas('mesh', paddedWidth, paddedHeight, false);
  56122. var tmpCtx = tmpCanvas.context;
  56123. var data = tmpCtx.createImageData(width, height);
  56124. if (backgroundColor) {
  56125. var bytes = data.data;
  56126. for (i = 0, ii = bytes.length; i < ii; i += 4) {
  56127. bytes[i] = backgroundColor[0];
  56128. bytes[i + 1] = backgroundColor[1];
  56129. bytes[i + 2] = backgroundColor[2];
  56130. bytes[i + 3] = 255;
  56131. }
  56132. }
  56133. for (i = 0; i < figures.length; i++) {
  56134. drawFigure(data, figures[i], context);
  56135. }
  56136. tmpCtx.putImageData(data, BORDER_SIZE, BORDER_SIZE);
  56137. canvas = tmpCanvas.canvas;
  56138. }
  56139. return {
  56140. canvas: canvas,
  56141. offsetX: offsetX - BORDER_SIZE * scaleX,
  56142. offsetY: offsetY - BORDER_SIZE * scaleY,
  56143. scaleX: scaleX,
  56144. scaleY: scaleY
  56145. };
  56146. }
  56147. return createMeshCanvas;
  56148. }();
  56149. ShadingIRs.Mesh = {
  56150. fromIR: function Mesh_fromIR(raw) {
  56151. var coords = raw[2];
  56152. var colors = raw[3];
  56153. var figures = raw[4];
  56154. var bounds = raw[5];
  56155. var matrix = raw[6];
  56156. var background = raw[8];
  56157. return {
  56158. type: 'Pattern',
  56159. getPattern: function Mesh_getPattern(ctx, owner, shadingFill) {
  56160. var scale;
  56161. if (shadingFill) {
  56162. scale = Util.singularValueDecompose2dScale(ctx.mozCurrentTransform);
  56163. } else {
  56164. scale = Util.singularValueDecompose2dScale(owner.baseTransform);
  56165. if (matrix) {
  56166. var matrixScale = Util.singularValueDecompose2dScale(matrix);
  56167. scale = [
  56168. scale[0] * matrixScale[0],
  56169. scale[1] * matrixScale[1]
  56170. ];
  56171. }
  56172. }
  56173. var temporaryPatternCanvas = createMeshCanvas(bounds, scale, coords, colors, figures, shadingFill ? null : background, owner.cachedCanvases);
  56174. if (!shadingFill) {
  56175. ctx.setTransform.apply(ctx, owner.baseTransform);
  56176. if (matrix) {
  56177. ctx.transform.apply(ctx, matrix);
  56178. }
  56179. }
  56180. ctx.translate(temporaryPatternCanvas.offsetX, temporaryPatternCanvas.offsetY);
  56181. ctx.scale(temporaryPatternCanvas.scaleX, temporaryPatternCanvas.scaleY);
  56182. return ctx.createPattern(temporaryPatternCanvas.canvas, 'no-repeat');
  56183. }
  56184. };
  56185. }
  56186. };
  56187. ShadingIRs.Dummy = {
  56188. fromIR: function Dummy_fromIR() {
  56189. return {
  56190. type: 'Pattern',
  56191. getPattern: function Dummy_fromIR_getPattern() {
  56192. return 'hotpink';
  56193. }
  56194. };
  56195. }
  56196. };
  56197. function getShadingPatternFromIR(raw) {
  56198. var shadingIR = ShadingIRs[raw[0]];
  56199. if (!shadingIR) {
  56200. error('Unknown IR type: ' + raw[0]);
  56201. }
  56202. return shadingIR.fromIR(raw);
  56203. }
  56204. var TilingPattern = function TilingPatternClosure() {
  56205. var PaintType = {
  56206. COLORED: 1,
  56207. UNCOLORED: 2
  56208. };
  56209. var MAX_PATTERN_SIZE = 3000;
  56210. function TilingPattern(IR, color, ctx, canvasGraphicsFactory, baseTransform) {
  56211. this.operatorList = IR[2];
  56212. this.matrix = IR[3] || [
  56213. 1,
  56214. 0,
  56215. 0,
  56216. 1,
  56217. 0,
  56218. 0
  56219. ];
  56220. this.bbox = Util.normalizeRect(IR[4]);
  56221. this.xstep = IR[5];
  56222. this.ystep = IR[6];
  56223. this.paintType = IR[7];
  56224. this.tilingType = IR[8];
  56225. this.color = color;
  56226. this.canvasGraphicsFactory = canvasGraphicsFactory;
  56227. this.baseTransform = baseTransform;
  56228. this.type = 'Pattern';
  56229. this.ctx = ctx;
  56230. }
  56231. TilingPattern.prototype = {
  56232. createPatternCanvas: function TilinPattern_createPatternCanvas(owner) {
  56233. var operatorList = this.operatorList;
  56234. var bbox = this.bbox;
  56235. var xstep = this.xstep;
  56236. var ystep = this.ystep;
  56237. var paintType = this.paintType;
  56238. var tilingType = this.tilingType;
  56239. var color = this.color;
  56240. var canvasGraphicsFactory = this.canvasGraphicsFactory;
  56241. info('TilingType: ' + tilingType);
  56242. var x0 = bbox[0], y0 = bbox[1], x1 = bbox[2], y1 = bbox[3];
  56243. var topLeft = [
  56244. x0,
  56245. y0
  56246. ];
  56247. var botRight = [
  56248. x0 + xstep,
  56249. y0 + ystep
  56250. ];
  56251. var width = botRight[0] - topLeft[0];
  56252. var height = botRight[1] - topLeft[1];
  56253. var matrixScale = Util.singularValueDecompose2dScale(this.matrix);
  56254. var curMatrixScale = Util.singularValueDecompose2dScale(this.baseTransform);
  56255. var combinedScale = [
  56256. matrixScale[0] * curMatrixScale[0],
  56257. matrixScale[1] * curMatrixScale[1]
  56258. ];
  56259. width = Math.min(Math.ceil(Math.abs(width * combinedScale[0])), MAX_PATTERN_SIZE);
  56260. height = Math.min(Math.ceil(Math.abs(height * combinedScale[1])), MAX_PATTERN_SIZE);
  56261. var tmpCanvas = owner.cachedCanvases.getCanvas('pattern', width, height, true);
  56262. var tmpCtx = tmpCanvas.context;
  56263. var graphics = canvasGraphicsFactory.createCanvasGraphics(tmpCtx);
  56264. graphics.groupLevel = owner.groupLevel;
  56265. this.setFillAndStrokeStyleToContext(tmpCtx, paintType, color);
  56266. this.setScale(width, height, xstep, ystep);
  56267. this.transformToScale(graphics);
  56268. var tmpTranslate = [
  56269. 1,
  56270. 0,
  56271. 0,
  56272. 1,
  56273. -topLeft[0],
  56274. -topLeft[1]
  56275. ];
  56276. graphics.transform.apply(graphics, tmpTranslate);
  56277. this.clipBbox(graphics, bbox, x0, y0, x1, y1);
  56278. graphics.executeOperatorList(operatorList);
  56279. return tmpCanvas.canvas;
  56280. },
  56281. setScale: function TilingPattern_setScale(width, height, xstep, ystep) {
  56282. this.scale = [
  56283. width / xstep,
  56284. height / ystep
  56285. ];
  56286. },
  56287. transformToScale: function TilingPattern_transformToScale(graphics) {
  56288. var scale = this.scale;
  56289. var tmpScale = [
  56290. scale[0],
  56291. 0,
  56292. 0,
  56293. scale[1],
  56294. 0,
  56295. 0
  56296. ];
  56297. graphics.transform.apply(graphics, tmpScale);
  56298. },
  56299. scaleToContext: function TilingPattern_scaleToContext() {
  56300. var scale = this.scale;
  56301. this.ctx.scale(1 / scale[0], 1 / scale[1]);
  56302. },
  56303. clipBbox: function clipBbox(graphics, bbox, x0, y0, x1, y1) {
  56304. if (isArray(bbox) && bbox.length === 4) {
  56305. var bboxWidth = x1 - x0;
  56306. var bboxHeight = y1 - y0;
  56307. graphics.ctx.rect(x0, y0, bboxWidth, bboxHeight);
  56308. graphics.clip();
  56309. graphics.endPath();
  56310. }
  56311. },
  56312. setFillAndStrokeStyleToContext: function setFillAndStrokeStyleToContext(context, paintType, color) {
  56313. switch (paintType) {
  56314. case PaintType.COLORED:
  56315. var ctx = this.ctx;
  56316. context.fillStyle = ctx.fillStyle;
  56317. context.strokeStyle = ctx.strokeStyle;
  56318. break;
  56319. case PaintType.UNCOLORED:
  56320. var cssColor = Util.makeCssRgb(color[0], color[1], color[2]);
  56321. context.fillStyle = cssColor;
  56322. context.strokeStyle = cssColor;
  56323. break;
  56324. default:
  56325. error('Unsupported paint type: ' + paintType);
  56326. }
  56327. },
  56328. getPattern: function TilingPattern_getPattern(ctx, owner) {
  56329. var temporaryPatternCanvas = this.createPatternCanvas(owner);
  56330. ctx = this.ctx;
  56331. ctx.setTransform.apply(ctx, this.baseTransform);
  56332. ctx.transform.apply(ctx, this.matrix);
  56333. this.scaleToContext();
  56334. return ctx.createPattern(temporaryPatternCanvas, 'repeat');
  56335. }
  56336. };
  56337. return TilingPattern;
  56338. }();
  56339. exports.getShadingPatternFromIR = getShadingPatternFromIR;
  56340. exports.TilingPattern = TilingPattern;
  56341. /***/ }),
  56342. /* 47 */
  56343. /***/ (function(module, exports, __w_pdfjs_require__) {
  56344. "use strict";
  56345. /* WEBPACK VAR INJECTION */(function(global) {
  56346. if (typeof PDFJS === 'undefined' || !PDFJS.compatibilityChecked) {
  56347. var globalScope = typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : this;
  56348. var userAgent = typeof navigator !== 'undefined' && navigator.userAgent || '';
  56349. var isAndroid = /Android/.test(userAgent);
  56350. var isAndroidPre3 = /Android\s[0-2][^\d]/.test(userAgent);
  56351. var isAndroidPre5 = /Android\s[0-4][^\d]/.test(userAgent);
  56352. var isChrome = userAgent.indexOf('Chrom') >= 0;
  56353. var isChromeWithRangeBug = /Chrome\/(39|40)\./.test(userAgent);
  56354. var isIOSChrome = userAgent.indexOf('CriOS') >= 0;
  56355. var isIE = userAgent.indexOf('Trident') >= 0;
  56356. var isIOS = /\b(iPad|iPhone|iPod)(?=;)/.test(userAgent);
  56357. var isOpera = userAgent.indexOf('Opera') >= 0;
  56358. var isSafari = /Safari\//.test(userAgent) && !/(Chrome\/|Android\s)/.test(userAgent);
  56359. var hasDOM = typeof window === 'object' && typeof document === 'object';
  56360. if (typeof PDFJS === 'undefined') {
  56361. globalScope.PDFJS = {};
  56362. }
  56363. PDFJS.compatibilityChecked = true;
  56364. (function checkTypedArrayCompatibility() {
  56365. if (typeof Uint8Array !== 'undefined') {
  56366. if (typeof Uint8Array.prototype.subarray === 'undefined') {
  56367. Uint8Array.prototype.subarray = function subarray(start, end) {
  56368. return new Uint8Array(this.slice(start, end));
  56369. };
  56370. Float32Array.prototype.subarray = function subarray(start, end) {
  56371. return new Float32Array(this.slice(start, end));
  56372. };
  56373. }
  56374. if (typeof Float64Array === 'undefined') {
  56375. globalScope.Float64Array = Float32Array;
  56376. }
  56377. return;
  56378. }
  56379. function subarray(start, end) {
  56380. return new TypedArray(this.slice(start, end));
  56381. }
  56382. function setArrayOffset(array, offset) {
  56383. if (arguments.length < 2) {
  56384. offset = 0;
  56385. }
  56386. for (var i = 0, n = array.length; i < n; ++i, ++offset) {
  56387. this[offset] = array[i] & 0xFF;
  56388. }
  56389. }
  56390. function TypedArray(arg1) {
  56391. var result, i, n;
  56392. if (typeof arg1 === 'number') {
  56393. result = [];
  56394. for (i = 0; i < arg1; ++i) {
  56395. result[i] = 0;
  56396. }
  56397. } else if ('slice' in arg1) {
  56398. result = arg1.slice(0);
  56399. } else {
  56400. result = [];
  56401. for (i = 0, n = arg1.length; i < n; ++i) {
  56402. result[i] = arg1[i];
  56403. }
  56404. }
  56405. result.subarray = subarray;
  56406. result.buffer = result;
  56407. result.byteLength = result.length;
  56408. result.set = setArrayOffset;
  56409. if (typeof arg1 === 'object' && arg1.buffer) {
  56410. result.buffer = arg1.buffer;
  56411. }
  56412. return result;
  56413. }
  56414. globalScope.Uint8Array = TypedArray;
  56415. globalScope.Int8Array = TypedArray;
  56416. globalScope.Uint32Array = TypedArray;
  56417. globalScope.Int32Array = TypedArray;
  56418. globalScope.Uint16Array = TypedArray;
  56419. globalScope.Float32Array = TypedArray;
  56420. globalScope.Float64Array = TypedArray;
  56421. }());
  56422. (function normalizeURLObject() {
  56423. if (!globalScope.URL) {
  56424. globalScope.URL = globalScope.webkitURL;
  56425. }
  56426. }());
  56427. (function checkObjectDefinePropertyCompatibility() {
  56428. if (typeof Object.defineProperty !== 'undefined') {
  56429. var definePropertyPossible = true;
  56430. try {
  56431. if (hasDOM) {
  56432. Object.defineProperty(new Image(), 'id', { value: 'test' });
  56433. }
  56434. var Test = function Test() {
  56435. };
  56436. Test.prototype = {
  56437. get id() {
  56438. }
  56439. };
  56440. Object.defineProperty(new Test(), 'id', {
  56441. value: '',
  56442. configurable: true,
  56443. enumerable: true,
  56444. writable: false
  56445. });
  56446. } catch (e) {
  56447. definePropertyPossible = false;
  56448. }
  56449. if (definePropertyPossible) {
  56450. return;
  56451. }
  56452. }
  56453. Object.defineProperty = function objectDefineProperty(obj, name, def) {
  56454. delete obj[name];
  56455. if ('get' in def) {
  56456. obj.__defineGetter__(name, def['get']);
  56457. }
  56458. if ('set' in def) {
  56459. obj.__defineSetter__(name, def['set']);
  56460. }
  56461. if ('value' in def) {
  56462. obj.__defineSetter__(name, function objectDefinePropertySetter(value) {
  56463. this.__defineGetter__(name, function objectDefinePropertyGetter() {
  56464. return value;
  56465. });
  56466. return value;
  56467. });
  56468. obj[name] = def.value;
  56469. }
  56470. };
  56471. }());
  56472. (function checkXMLHttpRequestResponseCompatibility() {
  56473. if (typeof XMLHttpRequest === 'undefined') {
  56474. return;
  56475. }
  56476. var xhrPrototype = XMLHttpRequest.prototype;
  56477. var xhr = new XMLHttpRequest();
  56478. if (!('overrideMimeType' in xhr)) {
  56479. Object.defineProperty(xhrPrototype, 'overrideMimeType', {
  56480. value: function xmlHttpRequestOverrideMimeType(mimeType) {
  56481. }
  56482. });
  56483. }
  56484. if ('responseType' in xhr) {
  56485. return;
  56486. }
  56487. Object.defineProperty(xhrPrototype, 'responseType', {
  56488. get: function xmlHttpRequestGetResponseType() {
  56489. return this._responseType || 'text';
  56490. },
  56491. set: function xmlHttpRequestSetResponseType(value) {
  56492. if (value === 'text' || value === 'arraybuffer') {
  56493. this._responseType = value;
  56494. if (value === 'arraybuffer' && typeof this.overrideMimeType === 'function') {
  56495. this.overrideMimeType('text/plain; charset=x-user-defined');
  56496. }
  56497. }
  56498. }
  56499. });
  56500. if (typeof VBArray !== 'undefined') {
  56501. Object.defineProperty(xhrPrototype, 'response', {
  56502. get: function xmlHttpRequestResponseGet() {
  56503. if (this.responseType === 'arraybuffer') {
  56504. return new Uint8Array(new VBArray(this.responseBody).toArray());
  56505. }
  56506. return this.responseText;
  56507. }
  56508. });
  56509. return;
  56510. }
  56511. Object.defineProperty(xhrPrototype, 'response', {
  56512. get: function xmlHttpRequestResponseGet() {
  56513. if (this.responseType !== 'arraybuffer') {
  56514. return this.responseText;
  56515. }
  56516. var text = this.responseText;
  56517. var i, n = text.length;
  56518. var result = new Uint8Array(n);
  56519. for (i = 0; i < n; ++i) {
  56520. result[i] = text.charCodeAt(i) & 0xFF;
  56521. }
  56522. return result.buffer;
  56523. }
  56524. });
  56525. }());
  56526. (function checkWindowBtoaCompatibility() {
  56527. if ('btoa' in globalScope) {
  56528. return;
  56529. }
  56530. var digits = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=';
  56531. globalScope.btoa = function (chars) {
  56532. var buffer = '';
  56533. var i, n;
  56534. for (i = 0, n = chars.length; i < n; i += 3) {
  56535. var b1 = chars.charCodeAt(i) & 0xFF;
  56536. var b2 = chars.charCodeAt(i + 1) & 0xFF;
  56537. var b3 = chars.charCodeAt(i + 2) & 0xFF;
  56538. var d1 = b1 >> 2, d2 = (b1 & 3) << 4 | b2 >> 4;
  56539. var d3 = i + 1 < n ? (b2 & 0xF) << 2 | b3 >> 6 : 64;
  56540. var d4 = i + 2 < n ? b3 & 0x3F : 64;
  56541. buffer += digits.charAt(d1) + digits.charAt(d2) + digits.charAt(d3) + digits.charAt(d4);
  56542. }
  56543. return buffer;
  56544. };
  56545. }());
  56546. (function checkWindowAtobCompatibility() {
  56547. if ('atob' in globalScope) {
  56548. return;
  56549. }
  56550. var digits = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=';
  56551. globalScope.atob = function (input) {
  56552. input = input.replace(/=+$/, '');
  56553. if (input.length % 4 === 1) {
  56554. throw new Error('bad atob input');
  56555. }
  56556. for (var bc = 0, bs, buffer, idx = 0, output = ''; buffer = input.charAt(idx++); ~buffer && (bs = bc % 4 ? bs * 64 + buffer : buffer, bc++ % 4) ? output += String.fromCharCode(255 & bs >> (-2 * bc & 6)) : 0) {
  56557. buffer = digits.indexOf(buffer);
  56558. }
  56559. return output;
  56560. };
  56561. }());
  56562. (function checkFunctionPrototypeBindCompatibility() {
  56563. if (typeof Function.prototype.bind !== 'undefined') {
  56564. return;
  56565. }
  56566. Function.prototype.bind = function functionPrototypeBind(obj) {
  56567. var fn = this, headArgs = Array.prototype.slice.call(arguments, 1);
  56568. var bound = function functionPrototypeBindBound() {
  56569. var args = headArgs.concat(Array.prototype.slice.call(arguments));
  56570. return fn.apply(obj, args);
  56571. };
  56572. return bound;
  56573. };
  56574. }());
  56575. (function checkDatasetProperty() {
  56576. if (!hasDOM) {
  56577. return;
  56578. }
  56579. var div = document.createElement('div');
  56580. if ('dataset' in div) {
  56581. return;
  56582. }
  56583. Object.defineProperty(HTMLElement.prototype, 'dataset', {
  56584. get: function () {
  56585. if (this._dataset) {
  56586. return this._dataset;
  56587. }
  56588. var dataset = {};
  56589. for (var j = 0, jj = this.attributes.length; j < jj; j++) {
  56590. var attribute = this.attributes[j];
  56591. if (attribute.name.substring(0, 5) !== 'data-') {
  56592. continue;
  56593. }
  56594. var key = attribute.name.substring(5).replace(/\-([a-z])/g, function (all, ch) {
  56595. return ch.toUpperCase();
  56596. });
  56597. dataset[key] = attribute.value;
  56598. }
  56599. Object.defineProperty(this, '_dataset', {
  56600. value: dataset,
  56601. writable: false,
  56602. enumerable: false
  56603. });
  56604. return dataset;
  56605. },
  56606. enumerable: true
  56607. });
  56608. }());
  56609. (function checkClassListProperty() {
  56610. function changeList(element, itemName, add, remove) {
  56611. var s = element.className || '';
  56612. var list = s.split(/\s+/g);
  56613. if (list[0] === '') {
  56614. list.shift();
  56615. }
  56616. var index = list.indexOf(itemName);
  56617. if (index < 0 && add) {
  56618. list.push(itemName);
  56619. }
  56620. if (index >= 0 && remove) {
  56621. list.splice(index, 1);
  56622. }
  56623. element.className = list.join(' ');
  56624. return index >= 0;
  56625. }
  56626. if (!hasDOM) {
  56627. return;
  56628. }
  56629. var div = document.createElement('div');
  56630. if ('classList' in div) {
  56631. return;
  56632. }
  56633. var classListPrototype = {
  56634. add: function (name) {
  56635. changeList(this.element, name, true, false);
  56636. },
  56637. contains: function (name) {
  56638. return changeList(this.element, name, false, false);
  56639. },
  56640. remove: function (name) {
  56641. changeList(this.element, name, false, true);
  56642. },
  56643. toggle: function (name) {
  56644. changeList(this.element, name, true, true);
  56645. }
  56646. };
  56647. Object.defineProperty(HTMLElement.prototype, 'classList', {
  56648. get: function () {
  56649. if (this._classList) {
  56650. return this._classList;
  56651. }
  56652. var classList = Object.create(classListPrototype, {
  56653. element: {
  56654. value: this,
  56655. writable: false,
  56656. enumerable: true
  56657. }
  56658. });
  56659. Object.defineProperty(this, '_classList', {
  56660. value: classList,
  56661. writable: false,
  56662. enumerable: false
  56663. });
  56664. return classList;
  56665. },
  56666. enumerable: true
  56667. });
  56668. }());
  56669. (function checkWorkerConsoleCompatibility() {
  56670. if (typeof importScripts === 'undefined' || 'console' in globalScope) {
  56671. return;
  56672. }
  56673. var consoleTimer = {};
  56674. var workerConsole = {
  56675. log: function log() {
  56676. var args = Array.prototype.slice.call(arguments);
  56677. globalScope.postMessage({
  56678. targetName: 'main',
  56679. action: 'console_log',
  56680. data: args
  56681. });
  56682. },
  56683. error: function error() {
  56684. var args = Array.prototype.slice.call(arguments);
  56685. globalScope.postMessage({
  56686. targetName: 'main',
  56687. action: 'console_error',
  56688. data: args
  56689. });
  56690. },
  56691. time: function time(name) {
  56692. consoleTimer[name] = Date.now();
  56693. },
  56694. timeEnd: function timeEnd(name) {
  56695. var time = consoleTimer[name];
  56696. if (!time) {
  56697. throw new Error('Unknown timer name ' + name);
  56698. }
  56699. this.log('Timer:', name, Date.now() - time);
  56700. }
  56701. };
  56702. globalScope.console = workerConsole;
  56703. }());
  56704. (function checkConsoleCompatibility() {
  56705. if (!hasDOM) {
  56706. return;
  56707. }
  56708. if (!('console' in window)) {
  56709. window.console = {
  56710. log: function () {
  56711. },
  56712. error: function () {
  56713. },
  56714. warn: function () {
  56715. }
  56716. };
  56717. return;
  56718. }
  56719. if (!('bind' in console.log)) {
  56720. console.log = function (fn) {
  56721. return function (msg) {
  56722. return fn(msg);
  56723. };
  56724. }(console.log);
  56725. console.error = function (fn) {
  56726. return function (msg) {
  56727. return fn(msg);
  56728. };
  56729. }(console.error);
  56730. console.warn = function (fn) {
  56731. return function (msg) {
  56732. return fn(msg);
  56733. };
  56734. }(console.warn);
  56735. return;
  56736. }
  56737. }());
  56738. (function checkOnClickCompatibility() {
  56739. function ignoreIfTargetDisabled(event) {
  56740. if (isDisabled(event.target)) {
  56741. event.stopPropagation();
  56742. }
  56743. }
  56744. function isDisabled(node) {
  56745. return node.disabled || node.parentNode && isDisabled(node.parentNode);
  56746. }
  56747. if (isOpera) {
  56748. document.addEventListener('click', ignoreIfTargetDisabled, true);
  56749. }
  56750. }());
  56751. (function checkOnBlobSupport() {
  56752. if (isIE || isIOSChrome) {
  56753. PDFJS.disableCreateObjectURL = true;
  56754. }
  56755. }());
  56756. (function checkNavigatorLanguage() {
  56757. if (typeof navigator === 'undefined') {
  56758. return;
  56759. }
  56760. if ('language' in navigator) {
  56761. return;
  56762. }
  56763. PDFJS.locale = navigator.userLanguage || 'en-US';
  56764. }());
  56765. (function checkRangeRequests() {
  56766. if (isSafari || isAndroidPre3 || isChromeWithRangeBug || isIOS) {
  56767. PDFJS.disableRange = true;
  56768. PDFJS.disableStream = true;
  56769. }
  56770. }());
  56771. (function checkHistoryManipulation() {
  56772. if (!hasDOM) {
  56773. return;
  56774. }
  56775. if (!history.pushState || isAndroidPre3) {
  56776. PDFJS.disableHistory = true;
  56777. }
  56778. }());
  56779. (function checkSetPresenceInImageData() {
  56780. if (!hasDOM) {
  56781. return;
  56782. }
  56783. if (window.CanvasPixelArray) {
  56784. if (typeof window.CanvasPixelArray.prototype.set !== 'function') {
  56785. window.CanvasPixelArray.prototype.set = function (arr) {
  56786. for (var i = 0, ii = this.length; i < ii; i++) {
  56787. this[i] = arr[i];
  56788. }
  56789. };
  56790. }
  56791. } else {
  56792. var polyfill = false, versionMatch;
  56793. if (isChrome) {
  56794. versionMatch = userAgent.match(/Chrom(e|ium)\/([0-9]+)\./);
  56795. polyfill = versionMatch && parseInt(versionMatch[2]) < 21;
  56796. } else if (isAndroid) {
  56797. polyfill = isAndroidPre5;
  56798. } else if (isSafari) {
  56799. versionMatch = userAgent.match(/Version\/([0-9]+)\.([0-9]+)\.([0-9]+) Safari\//);
  56800. polyfill = versionMatch && parseInt(versionMatch[1]) < 6;
  56801. }
  56802. if (polyfill) {
  56803. var contextPrototype = window.CanvasRenderingContext2D.prototype;
  56804. var createImageData = contextPrototype.createImageData;
  56805. contextPrototype.createImageData = function (w, h) {
  56806. var imageData = createImageData.call(this, w, h);
  56807. imageData.data.set = function (arr) {
  56808. for (var i = 0, ii = this.length; i < ii; i++) {
  56809. this[i] = arr[i];
  56810. }
  56811. };
  56812. return imageData;
  56813. };
  56814. contextPrototype = null;
  56815. }
  56816. }
  56817. }());
  56818. (function checkRequestAnimationFrame() {
  56819. function fakeRequestAnimationFrame(callback) {
  56820. window.setTimeout(callback, 20);
  56821. }
  56822. if (!hasDOM) {
  56823. return;
  56824. }
  56825. if (isIOS) {
  56826. window.requestAnimationFrame = fakeRequestAnimationFrame;
  56827. return;
  56828. }
  56829. if ('requestAnimationFrame' in window) {
  56830. return;
  56831. }
  56832. window.requestAnimationFrame = window.mozRequestAnimationFrame || window.webkitRequestAnimationFrame || fakeRequestAnimationFrame;
  56833. }());
  56834. (function checkCanvasSizeLimitation() {
  56835. if (isIOS || isAndroid) {
  56836. PDFJS.maxCanvasPixels = 5242880;
  56837. }
  56838. }());
  56839. (function checkFullscreenSupport() {
  56840. if (!hasDOM) {
  56841. return;
  56842. }
  56843. if (isIE && window.parent !== window) {
  56844. PDFJS.disableFullscreen = true;
  56845. }
  56846. }());
  56847. (function checkCurrentScript() {
  56848. if (!hasDOM) {
  56849. return;
  56850. }
  56851. if ('currentScript' in document) {
  56852. return;
  56853. }
  56854. Object.defineProperty(document, 'currentScript', {
  56855. get: function () {
  56856. var scripts = document.getElementsByTagName('script');
  56857. return scripts[scripts.length - 1];
  56858. },
  56859. enumerable: true,
  56860. configurable: true
  56861. });
  56862. }());
  56863. (function checkInputTypeNumberAssign() {
  56864. if (!hasDOM) {
  56865. return;
  56866. }
  56867. var el = document.createElement('input');
  56868. try {
  56869. el.type = 'number';
  56870. } catch (ex) {
  56871. var inputProto = el.constructor.prototype;
  56872. var typeProperty = Object.getOwnPropertyDescriptor(inputProto, 'type');
  56873. Object.defineProperty(inputProto, 'type', {
  56874. get: function () {
  56875. return typeProperty.get.call(this);
  56876. },
  56877. set: function (value) {
  56878. typeProperty.set.call(this, value === 'number' ? 'text' : value);
  56879. },
  56880. enumerable: true,
  56881. configurable: true
  56882. });
  56883. }
  56884. }());
  56885. (function checkDocumentReadyState() {
  56886. if (!hasDOM) {
  56887. return;
  56888. }
  56889. if (!document.attachEvent) {
  56890. return;
  56891. }
  56892. var documentProto = document.constructor.prototype;
  56893. var readyStateProto = Object.getOwnPropertyDescriptor(documentProto, 'readyState');
  56894. Object.defineProperty(documentProto, 'readyState', {
  56895. get: function () {
  56896. var value = readyStateProto.get.call(this);
  56897. return value === 'interactive' ? 'loading' : value;
  56898. },
  56899. set: function (value) {
  56900. readyStateProto.set.call(this, value);
  56901. },
  56902. enumerable: true,
  56903. configurable: true
  56904. });
  56905. }());
  56906. (function checkChildNodeRemove() {
  56907. if (!hasDOM) {
  56908. return;
  56909. }
  56910. if (typeof Element.prototype.remove !== 'undefined') {
  56911. return;
  56912. }
  56913. Element.prototype.remove = function () {
  56914. if (this.parentNode) {
  56915. this.parentNode.removeChild(this);
  56916. }
  56917. };
  56918. }());
  56919. (function checkPromise() {
  56920. if (globalScope.Promise) {
  56921. if (typeof globalScope.Promise.all !== 'function') {
  56922. globalScope.Promise.all = function (iterable) {
  56923. var count = 0, results = [], resolve, reject;
  56924. var promise = new globalScope.Promise(function (resolve_, reject_) {
  56925. resolve = resolve_;
  56926. reject = reject_;
  56927. });
  56928. iterable.forEach(function (p, i) {
  56929. count++;
  56930. p.then(function (result) {
  56931. results[i] = result;
  56932. count--;
  56933. if (count === 0) {
  56934. resolve(results);
  56935. }
  56936. }, reject);
  56937. });
  56938. if (count === 0) {
  56939. resolve(results);
  56940. }
  56941. return promise;
  56942. };
  56943. }
  56944. if (typeof globalScope.Promise.resolve !== 'function') {
  56945. globalScope.Promise.resolve = function (value) {
  56946. return new globalScope.Promise(function (resolve) {
  56947. resolve(value);
  56948. });
  56949. };
  56950. }
  56951. if (typeof globalScope.Promise.reject !== 'function') {
  56952. globalScope.Promise.reject = function (reason) {
  56953. return new globalScope.Promise(function (resolve, reject) {
  56954. reject(reason);
  56955. });
  56956. };
  56957. }
  56958. if (typeof globalScope.Promise.prototype.catch !== 'function') {
  56959. globalScope.Promise.prototype.catch = function (onReject) {
  56960. return globalScope.Promise.prototype.then(undefined, onReject);
  56961. };
  56962. }
  56963. return;
  56964. }
  56965. var STATUS_PENDING = 0;
  56966. var STATUS_RESOLVED = 1;
  56967. var STATUS_REJECTED = 2;
  56968. var REJECTION_TIMEOUT = 500;
  56969. var HandlerManager = {
  56970. handlers: [],
  56971. running: false,
  56972. unhandledRejections: [],
  56973. pendingRejectionCheck: false,
  56974. scheduleHandlers: function scheduleHandlers(promise) {
  56975. if (promise._status === STATUS_PENDING) {
  56976. return;
  56977. }
  56978. this.handlers = this.handlers.concat(promise._handlers);
  56979. promise._handlers = [];
  56980. if (this.running) {
  56981. return;
  56982. }
  56983. this.running = true;
  56984. setTimeout(this.runHandlers.bind(this), 0);
  56985. },
  56986. runHandlers: function runHandlers() {
  56987. var RUN_TIMEOUT = 1;
  56988. var timeoutAt = Date.now() + RUN_TIMEOUT;
  56989. while (this.handlers.length > 0) {
  56990. var handler = this.handlers.shift();
  56991. var nextStatus = handler.thisPromise._status;
  56992. var nextValue = handler.thisPromise._value;
  56993. try {
  56994. if (nextStatus === STATUS_RESOLVED) {
  56995. if (typeof handler.onResolve === 'function') {
  56996. nextValue = handler.onResolve(nextValue);
  56997. }
  56998. } else if (typeof handler.onReject === 'function') {
  56999. nextValue = handler.onReject(nextValue);
  57000. nextStatus = STATUS_RESOLVED;
  57001. if (handler.thisPromise._unhandledRejection) {
  57002. this.removeUnhandeledRejection(handler.thisPromise);
  57003. }
  57004. }
  57005. } catch (ex) {
  57006. nextStatus = STATUS_REJECTED;
  57007. nextValue = ex;
  57008. }
  57009. handler.nextPromise._updateStatus(nextStatus, nextValue);
  57010. if (Date.now() >= timeoutAt) {
  57011. break;
  57012. }
  57013. }
  57014. if (this.handlers.length > 0) {
  57015. setTimeout(this.runHandlers.bind(this), 0);
  57016. return;
  57017. }
  57018. this.running = false;
  57019. },
  57020. addUnhandledRejection: function addUnhandledRejection(promise) {
  57021. this.unhandledRejections.push({
  57022. promise: promise,
  57023. time: Date.now()
  57024. });
  57025. this.scheduleRejectionCheck();
  57026. },
  57027. removeUnhandeledRejection: function removeUnhandeledRejection(promise) {
  57028. promise._unhandledRejection = false;
  57029. for (var i = 0; i < this.unhandledRejections.length; i++) {
  57030. if (this.unhandledRejections[i].promise === promise) {
  57031. this.unhandledRejections.splice(i);
  57032. i--;
  57033. }
  57034. }
  57035. },
  57036. scheduleRejectionCheck: function scheduleRejectionCheck() {
  57037. if (this.pendingRejectionCheck) {
  57038. return;
  57039. }
  57040. this.pendingRejectionCheck = true;
  57041. setTimeout(function rejectionCheck() {
  57042. this.pendingRejectionCheck = false;
  57043. var now = Date.now();
  57044. for (var i = 0; i < this.unhandledRejections.length; i++) {
  57045. if (now - this.unhandledRejections[i].time > REJECTION_TIMEOUT) {
  57046. var unhandled = this.unhandledRejections[i].promise._value;
  57047. var msg = 'Unhandled rejection: ' + unhandled;
  57048. if (unhandled.stack) {
  57049. msg += '\n' + unhandled.stack;
  57050. }
  57051. try {
  57052. throw new Error(msg);
  57053. } catch (_) {
  57054. console.warn(msg);
  57055. }
  57056. this.unhandledRejections.splice(i);
  57057. i--;
  57058. }
  57059. }
  57060. if (this.unhandledRejections.length) {
  57061. this.scheduleRejectionCheck();
  57062. }
  57063. }.bind(this), REJECTION_TIMEOUT);
  57064. }
  57065. };
  57066. var Promise = function Promise(resolver) {
  57067. this._status = STATUS_PENDING;
  57068. this._handlers = [];
  57069. try {
  57070. resolver.call(this, this._resolve.bind(this), this._reject.bind(this));
  57071. } catch (e) {
  57072. this._reject(e);
  57073. }
  57074. };
  57075. Promise.all = function Promise_all(promises) {
  57076. var resolveAll, rejectAll;
  57077. var deferred = new Promise(function (resolve, reject) {
  57078. resolveAll = resolve;
  57079. rejectAll = reject;
  57080. });
  57081. var unresolved = promises.length;
  57082. var results = [];
  57083. if (unresolved === 0) {
  57084. resolveAll(results);
  57085. return deferred;
  57086. }
  57087. function reject(reason) {
  57088. if (deferred._status === STATUS_REJECTED) {
  57089. return;
  57090. }
  57091. results = [];
  57092. rejectAll(reason);
  57093. }
  57094. for (var i = 0, ii = promises.length; i < ii; ++i) {
  57095. var promise = promises[i];
  57096. var resolve = function (i) {
  57097. return function (value) {
  57098. if (deferred._status === STATUS_REJECTED) {
  57099. return;
  57100. }
  57101. results[i] = value;
  57102. unresolved--;
  57103. if (unresolved === 0) {
  57104. resolveAll(results);
  57105. }
  57106. };
  57107. }(i);
  57108. if (Promise.isPromise(promise)) {
  57109. promise.then(resolve, reject);
  57110. } else {
  57111. resolve(promise);
  57112. }
  57113. }
  57114. return deferred;
  57115. };
  57116. Promise.isPromise = function Promise_isPromise(value) {
  57117. return value && typeof value.then === 'function';
  57118. };
  57119. Promise.resolve = function Promise_resolve(value) {
  57120. return new Promise(function (resolve) {
  57121. resolve(value);
  57122. });
  57123. };
  57124. Promise.reject = function Promise_reject(reason) {
  57125. return new Promise(function (resolve, reject) {
  57126. reject(reason);
  57127. });
  57128. };
  57129. Promise.prototype = {
  57130. _status: null,
  57131. _value: null,
  57132. _handlers: null,
  57133. _unhandledRejection: null,
  57134. _updateStatus: function Promise__updateStatus(status, value) {
  57135. if (this._status === STATUS_RESOLVED || this._status === STATUS_REJECTED) {
  57136. return;
  57137. }
  57138. if (status === STATUS_RESOLVED && Promise.isPromise(value)) {
  57139. value.then(this._updateStatus.bind(this, STATUS_RESOLVED), this._updateStatus.bind(this, STATUS_REJECTED));
  57140. return;
  57141. }
  57142. this._status = status;
  57143. this._value = value;
  57144. if (status === STATUS_REJECTED && this._handlers.length === 0) {
  57145. this._unhandledRejection = true;
  57146. HandlerManager.addUnhandledRejection(this);
  57147. }
  57148. HandlerManager.scheduleHandlers(this);
  57149. },
  57150. _resolve: function Promise_resolve(value) {
  57151. this._updateStatus(STATUS_RESOLVED, value);
  57152. },
  57153. _reject: function Promise_reject(reason) {
  57154. this._updateStatus(STATUS_REJECTED, reason);
  57155. },
  57156. then: function Promise_then(onResolve, onReject) {
  57157. var nextPromise = new Promise(function (resolve, reject) {
  57158. this.resolve = resolve;
  57159. this.reject = reject;
  57160. });
  57161. this._handlers.push({
  57162. thisPromise: this,
  57163. onResolve: onResolve,
  57164. onReject: onReject,
  57165. nextPromise: nextPromise
  57166. });
  57167. HandlerManager.scheduleHandlers(this);
  57168. return nextPromise;
  57169. },
  57170. catch: function Promise_catch(onReject) {
  57171. return this.then(undefined, onReject);
  57172. }
  57173. };
  57174. globalScope.Promise = Promise;
  57175. }());
  57176. (function checkWeakMap() {
  57177. if (globalScope.WeakMap) {
  57178. return;
  57179. }
  57180. var id = 0;
  57181. function WeakMap() {
  57182. this.id = '$weakmap' + id++;
  57183. }
  57184. WeakMap.prototype = {
  57185. has: function (obj) {
  57186. return !!Object.getOwnPropertyDescriptor(obj, this.id);
  57187. },
  57188. get: function (obj, defaultValue) {
  57189. return this.has(obj) ? obj[this.id] : defaultValue;
  57190. },
  57191. set: function (obj, value) {
  57192. Object.defineProperty(obj, this.id, {
  57193. value: value,
  57194. enumerable: false,
  57195. configurable: true
  57196. });
  57197. },
  57198. delete: function (obj) {
  57199. delete obj[this.id];
  57200. }
  57201. };
  57202. globalScope.WeakMap = WeakMap;
  57203. }());
  57204. (function checkURLConstructor() {
  57205. var hasWorkingUrl = false;
  57206. try {
  57207. if (typeof URL === 'function' && typeof URL.prototype === 'object' && 'origin' in URL.prototype) {
  57208. var u = new URL('b', 'http://a');
  57209. u.pathname = 'c%20d';
  57210. hasWorkingUrl = u.href === 'http://a/c%20d';
  57211. }
  57212. } catch (e) {
  57213. }
  57214. if (hasWorkingUrl) {
  57215. return;
  57216. }
  57217. var relative = Object.create(null);
  57218. relative['ftp'] = 21;
  57219. relative['file'] = 0;
  57220. relative['gopher'] = 70;
  57221. relative['http'] = 80;
  57222. relative['https'] = 443;
  57223. relative['ws'] = 80;
  57224. relative['wss'] = 443;
  57225. var relativePathDotMapping = Object.create(null);
  57226. relativePathDotMapping['%2e'] = '.';
  57227. relativePathDotMapping['.%2e'] = '..';
  57228. relativePathDotMapping['%2e.'] = '..';
  57229. relativePathDotMapping['%2e%2e'] = '..';
  57230. function isRelativeScheme(scheme) {
  57231. return relative[scheme] !== undefined;
  57232. }
  57233. function invalid() {
  57234. clear.call(this);
  57235. this._isInvalid = true;
  57236. }
  57237. function IDNAToASCII(h) {
  57238. if (h === '') {
  57239. invalid.call(this);
  57240. }
  57241. return h.toLowerCase();
  57242. }
  57243. function percentEscape(c) {
  57244. var unicode = c.charCodeAt(0);
  57245. if (unicode > 0x20 && unicode < 0x7F && [
  57246. 0x22,
  57247. 0x23,
  57248. 0x3C,
  57249. 0x3E,
  57250. 0x3F,
  57251. 0x60
  57252. ].indexOf(unicode) === -1) {
  57253. return c;
  57254. }
  57255. return encodeURIComponent(c);
  57256. }
  57257. function percentEscapeQuery(c) {
  57258. var unicode = c.charCodeAt(0);
  57259. if (unicode > 0x20 && unicode < 0x7F && [
  57260. 0x22,
  57261. 0x23,
  57262. 0x3C,
  57263. 0x3E,
  57264. 0x60
  57265. ].indexOf(unicode) === -1) {
  57266. return c;
  57267. }
  57268. return encodeURIComponent(c);
  57269. }
  57270. var EOF, ALPHA = /[a-zA-Z]/, ALPHANUMERIC = /[a-zA-Z0-9\+\-\.]/;
  57271. function parse(input, stateOverride, base) {
  57272. function err(message) {
  57273. errors.push(message);
  57274. }
  57275. var state = stateOverride || 'scheme start', cursor = 0, buffer = '', seenAt = false, seenBracket = false, errors = [];
  57276. loop:
  57277. while ((input[cursor - 1] !== EOF || cursor === 0) && !this._isInvalid) {
  57278. var c = input[cursor];
  57279. switch (state) {
  57280. case 'scheme start':
  57281. if (c && ALPHA.test(c)) {
  57282. buffer += c.toLowerCase();
  57283. state = 'scheme';
  57284. } else if (!stateOverride) {
  57285. buffer = '';
  57286. state = 'no scheme';
  57287. continue;
  57288. } else {
  57289. err('Invalid scheme.');
  57290. break loop;
  57291. }
  57292. break;
  57293. case 'scheme':
  57294. if (c && ALPHANUMERIC.test(c)) {
  57295. buffer += c.toLowerCase();
  57296. } else if (c === ':') {
  57297. this._scheme = buffer;
  57298. buffer = '';
  57299. if (stateOverride) {
  57300. break loop;
  57301. }
  57302. if (isRelativeScheme(this._scheme)) {
  57303. this._isRelative = true;
  57304. }
  57305. if (this._scheme === 'file') {
  57306. state = 'relative';
  57307. } else if (this._isRelative && base && base._scheme === this._scheme) {
  57308. state = 'relative or authority';
  57309. } else if (this._isRelative) {
  57310. state = 'authority first slash';
  57311. } else {
  57312. state = 'scheme data';
  57313. }
  57314. } else if (!stateOverride) {
  57315. buffer = '';
  57316. cursor = 0;
  57317. state = 'no scheme';
  57318. continue;
  57319. } else if (c === EOF) {
  57320. break loop;
  57321. } else {
  57322. err('Code point not allowed in scheme: ' + c);
  57323. break loop;
  57324. }
  57325. break;
  57326. case 'scheme data':
  57327. if (c === '?') {
  57328. this._query = '?';
  57329. state = 'query';
  57330. } else if (c === '#') {
  57331. this._fragment = '#';
  57332. state = 'fragment';
  57333. } else {
  57334. if (c !== EOF && c !== '\t' && c !== '\n' && c !== '\r') {
  57335. this._schemeData += percentEscape(c);
  57336. }
  57337. }
  57338. break;
  57339. case 'no scheme':
  57340. if (!base || !isRelativeScheme(base._scheme)) {
  57341. err('Missing scheme.');
  57342. invalid.call(this);
  57343. } else {
  57344. state = 'relative';
  57345. continue;
  57346. }
  57347. break;
  57348. case 'relative or authority':
  57349. if (c === '/' && input[cursor + 1] === '/') {
  57350. state = 'authority ignore slashes';
  57351. } else {
  57352. err('Expected /, got: ' + c);
  57353. state = 'relative';
  57354. continue;
  57355. }
  57356. break;
  57357. case 'relative':
  57358. this._isRelative = true;
  57359. if (this._scheme !== 'file') {
  57360. this._scheme = base._scheme;
  57361. }
  57362. if (c === EOF) {
  57363. this._host = base._host;
  57364. this._port = base._port;
  57365. this._path = base._path.slice();
  57366. this._query = base._query;
  57367. this._username = base._username;
  57368. this._password = base._password;
  57369. break loop;
  57370. } else if (c === '/' || c === '\\') {
  57371. if (c === '\\') {
  57372. err('\\ is an invalid code point.');
  57373. }
  57374. state = 'relative slash';
  57375. } else if (c === '?') {
  57376. this._host = base._host;
  57377. this._port = base._port;
  57378. this._path = base._path.slice();
  57379. this._query = '?';
  57380. this._username = base._username;
  57381. this._password = base._password;
  57382. state = 'query';
  57383. } else if (c === '#') {
  57384. this._host = base._host;
  57385. this._port = base._port;
  57386. this._path = base._path.slice();
  57387. this._query = base._query;
  57388. this._fragment = '#';
  57389. this._username = base._username;
  57390. this._password = base._password;
  57391. state = 'fragment';
  57392. } else {
  57393. var nextC = input[cursor + 1];
  57394. var nextNextC = input[cursor + 2];
  57395. if (this._scheme !== 'file' || !ALPHA.test(c) || nextC !== ':' && nextC !== '|' || nextNextC !== EOF && nextNextC !== '/' && nextNextC !== '\\' && nextNextC !== '?' && nextNextC !== '#') {
  57396. this._host = base._host;
  57397. this._port = base._port;
  57398. this._username = base._username;
  57399. this._password = base._password;
  57400. this._path = base._path.slice();
  57401. this._path.pop();
  57402. }
  57403. state = 'relative path';
  57404. continue;
  57405. }
  57406. break;
  57407. case 'relative slash':
  57408. if (c === '/' || c === '\\') {
  57409. if (c === '\\') {
  57410. err('\\ is an invalid code point.');
  57411. }
  57412. if (this._scheme === 'file') {
  57413. state = 'file host';
  57414. } else {
  57415. state = 'authority ignore slashes';
  57416. }
  57417. } else {
  57418. if (this._scheme !== 'file') {
  57419. this._host = base._host;
  57420. this._port = base._port;
  57421. this._username = base._username;
  57422. this._password = base._password;
  57423. }
  57424. state = 'relative path';
  57425. continue;
  57426. }
  57427. break;
  57428. case 'authority first slash':
  57429. if (c === '/') {
  57430. state = 'authority second slash';
  57431. } else {
  57432. err('Expected \'/\', got: ' + c);
  57433. state = 'authority ignore slashes';
  57434. continue;
  57435. }
  57436. break;
  57437. case 'authority second slash':
  57438. state = 'authority ignore slashes';
  57439. if (c !== '/') {
  57440. err('Expected \'/\', got: ' + c);
  57441. continue;
  57442. }
  57443. break;
  57444. case 'authority ignore slashes':
  57445. if (c !== '/' && c !== '\\') {
  57446. state = 'authority';
  57447. continue;
  57448. } else {
  57449. err('Expected authority, got: ' + c);
  57450. }
  57451. break;
  57452. case 'authority':
  57453. if (c === '@') {
  57454. if (seenAt) {
  57455. err('@ already seen.');
  57456. buffer += '%40';
  57457. }
  57458. seenAt = true;
  57459. for (var i = 0; i < buffer.length; i++) {
  57460. var cp = buffer[i];
  57461. if (cp === '\t' || cp === '\n' || cp === '\r') {
  57462. err('Invalid whitespace in authority.');
  57463. continue;
  57464. }
  57465. if (cp === ':' && this._password === null) {
  57466. this._password = '';
  57467. continue;
  57468. }
  57469. var tempC = percentEscape(cp);
  57470. if (this._password !== null) {
  57471. this._password += tempC;
  57472. } else {
  57473. this._username += tempC;
  57474. }
  57475. }
  57476. buffer = '';
  57477. } else if (c === EOF || c === '/' || c === '\\' || c === '?' || c === '#') {
  57478. cursor -= buffer.length;
  57479. buffer = '';
  57480. state = 'host';
  57481. continue;
  57482. } else {
  57483. buffer += c;
  57484. }
  57485. break;
  57486. case 'file host':
  57487. if (c === EOF || c === '/' || c === '\\' || c === '?' || c === '#') {
  57488. if (buffer.length === 2 && ALPHA.test(buffer[0]) && (buffer[1] === ':' || buffer[1] === '|')) {
  57489. state = 'relative path';
  57490. } else if (buffer.length === 0) {
  57491. state = 'relative path start';
  57492. } else {
  57493. this._host = IDNAToASCII.call(this, buffer);
  57494. buffer = '';
  57495. state = 'relative path start';
  57496. }
  57497. continue;
  57498. } else if (c === '\t' || c === '\n' || c === '\r') {
  57499. err('Invalid whitespace in file host.');
  57500. } else {
  57501. buffer += c;
  57502. }
  57503. break;
  57504. case 'host':
  57505. case 'hostname':
  57506. if (c === ':' && !seenBracket) {
  57507. this._host = IDNAToASCII.call(this, buffer);
  57508. buffer = '';
  57509. state = 'port';
  57510. if (stateOverride === 'hostname') {
  57511. break loop;
  57512. }
  57513. } else if (c === EOF || c === '/' || c === '\\' || c === '?' || c === '#') {
  57514. this._host = IDNAToASCII.call(this, buffer);
  57515. buffer = '';
  57516. state = 'relative path start';
  57517. if (stateOverride) {
  57518. break loop;
  57519. }
  57520. continue;
  57521. } else if (c !== '\t' && c !== '\n' && c !== '\r') {
  57522. if (c === '[') {
  57523. seenBracket = true;
  57524. } else if (c === ']') {
  57525. seenBracket = false;
  57526. }
  57527. buffer += c;
  57528. } else {
  57529. err('Invalid code point in host/hostname: ' + c);
  57530. }
  57531. break;
  57532. case 'port':
  57533. if (/[0-9]/.test(c)) {
  57534. buffer += c;
  57535. } else if (c === EOF || c === '/' || c === '\\' || c === '?' || c === '#' || stateOverride) {
  57536. if (buffer !== '') {
  57537. var temp = parseInt(buffer, 10);
  57538. if (temp !== relative[this._scheme]) {
  57539. this._port = temp + '';
  57540. }
  57541. buffer = '';
  57542. }
  57543. if (stateOverride) {
  57544. break loop;
  57545. }
  57546. state = 'relative path start';
  57547. continue;
  57548. } else if (c === '\t' || c === '\n' || c === '\r') {
  57549. err('Invalid code point in port: ' + c);
  57550. } else {
  57551. invalid.call(this);
  57552. }
  57553. break;
  57554. case 'relative path start':
  57555. if (c === '\\') {
  57556. err('\'\\\' not allowed in path.');
  57557. }
  57558. state = 'relative path';
  57559. if (c !== '/' && c !== '\\') {
  57560. continue;
  57561. }
  57562. break;
  57563. case 'relative path':
  57564. if (c === EOF || c === '/' || c === '\\' || !stateOverride && (c === '?' || c === '#')) {
  57565. if (c === '\\') {
  57566. err('\\ not allowed in relative path.');
  57567. }
  57568. var tmp;
  57569. if (tmp = relativePathDotMapping[buffer.toLowerCase()]) {
  57570. buffer = tmp;
  57571. }
  57572. if (buffer === '..') {
  57573. this._path.pop();
  57574. if (c !== '/' && c !== '\\') {
  57575. this._path.push('');
  57576. }
  57577. } else if (buffer === '.' && c !== '/' && c !== '\\') {
  57578. this._path.push('');
  57579. } else if (buffer !== '.') {
  57580. if (this._scheme === 'file' && this._path.length === 0 && buffer.length === 2 && ALPHA.test(buffer[0]) && buffer[1] === '|') {
  57581. buffer = buffer[0] + ':';
  57582. }
  57583. this._path.push(buffer);
  57584. }
  57585. buffer = '';
  57586. if (c === '?') {
  57587. this._query = '?';
  57588. state = 'query';
  57589. } else if (c === '#') {
  57590. this._fragment = '#';
  57591. state = 'fragment';
  57592. }
  57593. } else if (c !== '\t' && c !== '\n' && c !== '\r') {
  57594. buffer += percentEscape(c);
  57595. }
  57596. break;
  57597. case 'query':
  57598. if (!stateOverride && c === '#') {
  57599. this._fragment = '#';
  57600. state = 'fragment';
  57601. } else if (c !== EOF && c !== '\t' && c !== '\n' && c !== '\r') {
  57602. this._query += percentEscapeQuery(c);
  57603. }
  57604. break;
  57605. case 'fragment':
  57606. if (c !== EOF && c !== '\t' && c !== '\n' && c !== '\r') {
  57607. this._fragment += c;
  57608. }
  57609. break;
  57610. }
  57611. cursor++;
  57612. }
  57613. }
  57614. function clear() {
  57615. this._scheme = '';
  57616. this._schemeData = '';
  57617. this._username = '';
  57618. this._password = null;
  57619. this._host = '';
  57620. this._port = '';
  57621. this._path = [];
  57622. this._query = '';
  57623. this._fragment = '';
  57624. this._isInvalid = false;
  57625. this._isRelative = false;
  57626. }
  57627. function JURL(url, base) {
  57628. if (base !== undefined && !(base instanceof JURL)) {
  57629. base = new JURL(String(base));
  57630. }
  57631. this._url = url;
  57632. clear.call(this);
  57633. var input = url.replace(/^[ \t\r\n\f]+|[ \t\r\n\f]+$/g, '');
  57634. parse.call(this, input, null, base);
  57635. }
  57636. JURL.prototype = {
  57637. toString: function () {
  57638. return this.href;
  57639. },
  57640. get href() {
  57641. if (this._isInvalid) {
  57642. return this._url;
  57643. }
  57644. var authority = '';
  57645. if (this._username !== '' || this._password !== null) {
  57646. authority = this._username + (this._password !== null ? ':' + this._password : '') + '@';
  57647. }
  57648. return this.protocol + (this._isRelative ? '//' + authority + this.host : '') + this.pathname + this._query + this._fragment;
  57649. },
  57650. set href(href) {
  57651. clear.call(this);
  57652. parse.call(this, href);
  57653. },
  57654. get protocol() {
  57655. return this._scheme + ':';
  57656. },
  57657. set protocol(protocol) {
  57658. if (this._isInvalid) {
  57659. return;
  57660. }
  57661. parse.call(this, protocol + ':', 'scheme start');
  57662. },
  57663. get host() {
  57664. return this._isInvalid ? '' : this._port ? this._host + ':' + this._port : this._host;
  57665. },
  57666. set host(host) {
  57667. if (this._isInvalid || !this._isRelative) {
  57668. return;
  57669. }
  57670. parse.call(this, host, 'host');
  57671. },
  57672. get hostname() {
  57673. return this._host;
  57674. },
  57675. set hostname(hostname) {
  57676. if (this._isInvalid || !this._isRelative) {
  57677. return;
  57678. }
  57679. parse.call(this, hostname, 'hostname');
  57680. },
  57681. get port() {
  57682. return this._port;
  57683. },
  57684. set port(port) {
  57685. if (this._isInvalid || !this._isRelative) {
  57686. return;
  57687. }
  57688. parse.call(this, port, 'port');
  57689. },
  57690. get pathname() {
  57691. return this._isInvalid ? '' : this._isRelative ? '/' + this._path.join('/') : this._schemeData;
  57692. },
  57693. set pathname(pathname) {
  57694. if (this._isInvalid || !this._isRelative) {
  57695. return;
  57696. }
  57697. this._path = [];
  57698. parse.call(this, pathname, 'relative path start');
  57699. },
  57700. get search() {
  57701. return this._isInvalid || !this._query || this._query === '?' ? '' : this._query;
  57702. },
  57703. set search(search) {
  57704. if (this._isInvalid || !this._isRelative) {
  57705. return;
  57706. }
  57707. this._query = '?';
  57708. if (search[0] === '?') {
  57709. search = search.slice(1);
  57710. }
  57711. parse.call(this, search, 'query');
  57712. },
  57713. get hash() {
  57714. return this._isInvalid || !this._fragment || this._fragment === '#' ? '' : this._fragment;
  57715. },
  57716. set hash(hash) {
  57717. if (this._isInvalid) {
  57718. return;
  57719. }
  57720. this._fragment = '#';
  57721. if (hash[0] === '#') {
  57722. hash = hash.slice(1);
  57723. }
  57724. parse.call(this, hash, 'fragment');
  57725. },
  57726. get origin() {
  57727. var host;
  57728. if (this._isInvalid || !this._scheme) {
  57729. return '';
  57730. }
  57731. switch (this._scheme) {
  57732. case 'data':
  57733. case 'file':
  57734. case 'javascript':
  57735. case 'mailto':
  57736. return 'null';
  57737. }
  57738. host = this.host;
  57739. if (!host) {
  57740. return '';
  57741. }
  57742. return this._scheme + '://' + host;
  57743. }
  57744. };
  57745. var OriginalURL = globalScope.URL;
  57746. if (OriginalURL) {
  57747. JURL.createObjectURL = function (blob) {
  57748. return OriginalURL.createObjectURL.apply(OriginalURL, arguments);
  57749. };
  57750. JURL.revokeObjectURL = function (url) {
  57751. OriginalURL.revokeObjectURL(url);
  57752. };
  57753. }
  57754. globalScope.URL = JURL;
  57755. }());
  57756. }
  57757. /* WEBPACK VAR INJECTION */}.call(exports, __w_pdfjs_require__(13)))
  57758. /***/ }),
  57759. /* 48 */
  57760. /***/ (function(module, exports, __w_pdfjs_require__) {
  57761. "use strict";
  57762. var pdfjsVersion = '1.7.374';
  57763. var pdfjsBuild = 'cfc45e55';
  57764. var pdfjsSharedUtil = __w_pdfjs_require__(0);
  57765. var pdfjsDisplayGlobal = __w_pdfjs_require__(26);
  57766. var pdfjsDisplayAPI = __w_pdfjs_require__(10);
  57767. var pdfjsDisplayTextLayer = __w_pdfjs_require__(12);
  57768. var pdfjsDisplayAnnotationLayer = __w_pdfjs_require__(9);
  57769. var pdfjsDisplayDOMUtils = __w_pdfjs_require__(3);
  57770. var pdfjsDisplaySVG = __w_pdfjs_require__(11);
  57771. exports.PDFJS = pdfjsDisplayGlobal.PDFJS;
  57772. exports.build = pdfjsDisplayAPI.build;
  57773. exports.version = pdfjsDisplayAPI.version;
  57774. exports.getDocument = pdfjsDisplayAPI.getDocument;
  57775. exports.PDFDataRangeTransport = pdfjsDisplayAPI.PDFDataRangeTransport;
  57776. exports.PDFWorker = pdfjsDisplayAPI.PDFWorker;
  57777. exports.renderTextLayer = pdfjsDisplayTextLayer.renderTextLayer;
  57778. exports.AnnotationLayer = pdfjsDisplayAnnotationLayer.AnnotationLayer;
  57779. exports.CustomStyle = pdfjsDisplayDOMUtils.CustomStyle;
  57780. exports.createPromiseCapability = pdfjsSharedUtil.createPromiseCapability;
  57781. exports.PasswordResponses = pdfjsSharedUtil.PasswordResponses;
  57782. exports.InvalidPDFException = pdfjsSharedUtil.InvalidPDFException;
  57783. exports.MissingPDFException = pdfjsSharedUtil.MissingPDFException;
  57784. exports.SVGGraphics = pdfjsDisplaySVG.SVGGraphics;
  57785. exports.UnexpectedResponseException = pdfjsSharedUtil.UnexpectedResponseException;
  57786. exports.OPS = pdfjsSharedUtil.OPS;
  57787. exports.UNSUPPORTED_FEATURES = pdfjsSharedUtil.UNSUPPORTED_FEATURES;
  57788. exports.isValidUrl = pdfjsDisplayDOMUtils.isValidUrl;
  57789. exports.createValidAbsoluteUrl = pdfjsSharedUtil.createValidAbsoluteUrl;
  57790. exports.createObjectURL = pdfjsSharedUtil.createObjectURL;
  57791. exports.removeNullCharacters = pdfjsSharedUtil.removeNullCharacters;
  57792. exports.shadow = pdfjsSharedUtil.shadow;
  57793. exports.createBlob = pdfjsSharedUtil.createBlob;
  57794. exports.getFilenameFromUrl = pdfjsDisplayDOMUtils.getFilenameFromUrl;
  57795. exports.addLinkAttributes = pdfjsDisplayDOMUtils.addLinkAttributes;
  57796. /***/ })
  57797. /******/ ]);
  57798. });